diff --git a/3rdparty/qv2ray/v2/ui/LogHighlighter.cpp b/3rdparty/qv2ray/v2/ui/LogHighlighter.cpp deleted file mode 100644 index e24d02b..0000000 --- a/3rdparty/qv2ray/v2/ui/LogHighlighter.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "LogHighlighter.hpp" - -#define TO_EOL "(([\\s\\S]*)|([\\d\\D]*)|([\\w\\W]*))$" -#define REGEX_IPV6_ADDR \ - R"(\[\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*\])" -#define REGEX_IPV4_ADDR \ - R"((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5]))" -#define REGEX_PORT_NUMBER R"(([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-5]{2}[0-3][0-5])*)" - -namespace Qv2ray::ui { - SyntaxHighlighter::SyntaxHighlighter(bool darkMode, QTextDocument *parent) : QSyntaxHighlighter(parent) { - HighlightingRule rule; - - if (darkMode) { - tcpudpFormat.setForeground(QColor(0, 200, 230)); - ipHostFormat.setForeground(Qt::yellow); - warningFormat.setForeground(QColor(255, 160, 15)); - warningFormat2.setForeground(Qt::cyan); - } else { - ipHostFormat.setForeground(QColor(0, 52, 130)); - tcpudpFormat.setForeground(QColor(0, 52, 130)); - warningFormat.setBackground(QColor(255, 160, 15)); - warningFormat.setForeground(Qt::white); - warningFormat2.setForeground(Qt::darkCyan); - } - const static QColor darkGreenColor(10, 180, 0); - - acceptedFormat.setForeground(darkGreenColor); - acceptedFormat.setFontItalic(true); - acceptedFormat.setFontWeight(QFont::Bold); - rule.pattern = QRegularExpression("\\saccepted\\s"); - rule.format = acceptedFormat; - highlightingRules.append(rule); - // - rejectedFormat.setFontWeight(QFont::Bold); - rejectedFormat.setBackground(Qt::red); - rejectedFormat.setForeground(Qt::white); - rejectedFormat.setFontWeight(QFont::Bold); - rule.pattern = QRegularExpression("\\srejected\\s" TO_EOL); - rule.format = rejectedFormat; - highlightingRules.append(rule); - // - dateFormat.setForeground(darkMode ? Qt::cyan : Qt::darkCyan); - rule.pattern = QRegularExpression("\\d\\d\\d\\d/\\d\\d/\\d\\d"); - rule.format = dateFormat; - highlightingRules.append(rule); - // - timeFormat.setForeground(darkMode ? Qt::cyan : Qt::darkCyan); - rule.pattern = QRegularExpression("\\d\\d:\\d\\d:\\d\\d"); - rule.format = timeFormat; - highlightingRules.append(rule); - // - debugFormat.setForeground(Qt::darkGray); - rule.pattern = QRegularExpression("\\[D[Ee][Bb][Uu].*?\\]"); - rule.format = debugFormat; - highlightingRules.append(rule); - // - infoFormat.setForeground(darkMode ? Qt::lightGray : Qt::darkCyan); - rule.pattern = QRegularExpression("\\[I[Nn][Ff][Oo].*?\\]"); - rule.format = infoFormat; - highlightingRules.append(rule); - // - warningFormat.setFontWeight(QFont::Bold); - warningFormat2.setFontWeight(QFont::Bold); - rule.pattern = QRegularExpression("\\[W[Aa][Rr][Nn].*?\\]"); - rule.format = warningFormat2; - highlightingRules.append(rule); - // - rule.pattern = QRegularExpression("\\[E[Rr][Rr][Oo].*?\\]"); - rule.format = rejectedFormat; - highlightingRules.append(rule); - - // - v2rayComponentFormat.setForeground(darkMode ? darkGreenColor : Qt::darkYellow); - rule.pattern = QRegularExpression(R"( (\w+\/)+\w+: )"); - rule.format = v2rayComponentFormat; - highlightingRules.append(rule); - // - failedFormat.setFontWeight(QFont::Bold); - failedFormat.setBackground(Qt::red); - failedFormat.setForeground(Qt::white); - rule.pattern = QRegularExpression("failed"); - rule.format = failedFormat; - highlightingRules.append(rule); - // - rule.pattern = QRegularExpression(">>>>+"); - rule.format = warningFormat; - highlightingRules.append(rule); - // - rule.pattern = QRegularExpression("<<<<+"); - rule.format = warningFormat; - highlightingRules.append(rule); - - { - // IP IPv6 Host; - rule.pattern = QRegularExpression(REGEX_IPV4_ADDR ":" REGEX_PORT_NUMBER); - rule.pattern.setPatternOptions(QRegularExpression::ExtendedPatternSyntaxOption); - rule.format = ipHostFormat; - highlightingRules.append(rule); - // - rule.pattern = QRegularExpression(REGEX_IPV6_ADDR ":" REGEX_PORT_NUMBER); - rule.pattern.setPatternOptions(QRegularExpression::ExtendedPatternSyntaxOption); - rule.format = ipHostFormat; - highlightingRules.append(rule); - // - rule.pattern = QRegularExpression("([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}(/|):" REGEX_PORT_NUMBER); - rule.pattern.setPatternOptions(QRegularExpression::PatternOption::ExtendedPatternSyntaxOption); - rule.format = ipHostFormat; - highlightingRules.append(rule); - } - - for (const auto &pattern: {"tcp:", "udp:"}) { - tcpudpFormat.setFontWeight(QFont::Bold); - rule.pattern = QRegularExpression(pattern); - rule.format = tcpudpFormat; - highlightingRules.append(rule); - } - } - - void SyntaxHighlighter::highlightBlock(const QString &text) { - for (const HighlightingRule &rule: highlightingRules) { - QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text); - - while (matchIterator.hasNext()) { - QRegularExpressionMatch match = matchIterator.next(); - setFormat(match.capturedStart(), match.capturedLength(), rule.format); - } - } - - setCurrentBlockState(0); - } -} // namespace Qv2ray::ui diff --git a/3rdparty/qv2ray/v2/ui/LogHighlighter.hpp b/3rdparty/qv2ray/v2/ui/LogHighlighter.hpp deleted file mode 100644 index 4c24a44..0000000 --- a/3rdparty/qv2ray/v2/ui/LogHighlighter.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#pragma once - -#include -#include -#include -#include - -namespace Qv2ray { - namespace ui { - class SyntaxHighlighter : public QSyntaxHighlighter { - Q_OBJECT - - public: - explicit SyntaxHighlighter(bool darkMode, QTextDocument *parent = nullptr); - - protected: - void highlightBlock(const QString &text) override; - - private: - struct HighlightingRule { - QRegularExpression pattern; - QTextCharFormat format; - }; - QVector highlightingRules; - - QTextCharFormat tcpudpFormat; - QTextCharFormat dateFormat; - QTextCharFormat acceptedFormat; - QTextCharFormat rejectedFormat; - QTextCharFormat failedFormat; - QTextCharFormat warningFormat; - QTextCharFormat warningFormat2; - QTextCharFormat infoFormat; - QTextCharFormat debugFormat; - QTextCharFormat timeFormat; - QTextCharFormat ipHostFormat; - QTextCharFormat v2rayComponentFormat; - }; - } // namespace ui -} // namespace Qv2ray - -using namespace Qv2ray::ui; diff --git a/CMakeLists.txt b/CMakeLists.txt index 727aeda..7321c0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,7 +131,6 @@ set(PROJECT_SOURCES 3rdparty/qrcodegen.cpp 3rdparty/QtExtKeySequenceEdit.cpp - 3rdparty/qv2ray/v2/ui/LogHighlighter.cpp 3rdparty/qv2ray/v2/ui/QvAutoCompleteTextEdit.cpp 3rdparty/qv2ray/v2/components/proxy/QvProxyConfigurator.cpp 3rdparty/qv2ray/v2/ui/widgets/common/QJsonModel.cpp diff --git a/db/ConfigBuilder.cpp b/db/ConfigBuilder.cpp index 54f1ed5..db6c1c0 100644 --- a/db/ConfigBuilder.cpp +++ b/db/ConfigBuilder.cpp @@ -22,7 +22,7 @@ namespace NekoGui { } QString genTunName() { - auto tun_name = "nekobox-tun"; + auto tun_name = "neko-tun"; #ifdef Q_OS_MACOS tun_name = "utun9"; #endif @@ -726,8 +726,8 @@ namespace NekoGui { QString WriteVPNSingBoxConfig() { // tun user rule - auto match_out = dataStore->vpn_rule_white ? "nekobox-socks" : "direct"; - auto no_match_out = dataStore->vpn_rule_white ? "direct" : "nekobox-socks"; + auto match_out = dataStore->vpn_rule_white ? "neko-socks" : "direct"; + auto no_match_out = dataStore->vpn_rule_white ? "direct" : "neko-socks"; QString process_name_rule = dataStore->vpn_rule_process.trimmed(); if (!process_name_rule.isEmpty()) { diff --git a/res/vpn/sing-box-vpn.json b/res/vpn/sing-box-vpn.json index adb32e3..eb8f9a8 100644 --- a/res/vpn/sing-box-vpn.json +++ b/res/vpn/sing-box-vpn.json @@ -12,7 +12,7 @@ { "tag": "dns-remote", "address": "8.8.8.8", - "detour": "nekoray-socks" + "detour": "neko-socks" }, { "tag": "dns-direct", @@ -75,7 +75,7 @@ "outbounds": [ { "type": "socks", - "tag": "nekoray-socks", + "tag": "neko-socks", "udp_fragment": true, //%SOCKS_USER_PASS% "server": "127.0.0.1", diff --git a/ui/mainwindow.cpp b/ui/mainwindow.cpp index 3106d48..d7ed7c4 100644 --- a/ui/mainwindow.cpp +++ b/ui/mainwindow.cpp @@ -21,7 +21,6 @@ #include "3rdparty/qrcodegen.hpp" #include "3rdparty/VT100Parser.hpp" #include "3rdparty/qv2ray/v2/components/proxy/QvProxyConfigurator.hpp" -#include "3rdparty/qv2ray/v2/ui/LogHighlighter.hpp" #ifndef NKR_NO_ZXING #include "3rdparty/ZxingQtReader.hpp" @@ -107,7 +106,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi // Setup log UI ui->splitter->restoreState(DecodeB64IfValid(NekoGui::dataStore->splitter_state)); - new SyntaxHighlighter(false, qvLogDocument); qvLogDocument->setUndoRedoEnabled(false); ui->masterLogBrowser->setUndoRedoEnabled(false); ui->masterLogBrowser->setDocument(qvLogDocument);