diff --git a/CMakeLists.txt b/CMakeLists.txt index 2132d5e..08ed3d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,18 +130,15 @@ set(PROJECT_SOURCES include/ui/profile/edit_chain.h src/ui/profile/edit_chain.cpp include/ui/profile/edit_chain.ui - include/ui/profile/edit_socks_http.h - src/ui/profile/edit_socks_http.cpp - include/ui/profile/edit_socks_http.ui include/ui/profile/edit_shadowsocks.h src/ui/profile/edit_shadowsocks.cpp include/ui/profile/edit_shadowsocks.ui include/ui/profile/edit_vmess.h src/ui/profile/edit_vmess.cpp include/ui/profile/edit_vmess.ui - include/ui/profile/edit_trojan_vless.h - src/ui/profile/edit_trojan_vless.cpp - include/ui/profile/edit_trojan_vless.ui + include/ui/profile/edit_vless.h + src/ui/profile/edit_vless.cpp + include/ui/profile/edit_vless.ui include/ui/profile/edit_anytls.h src/ui/profile/edit_anytls.cpp include/ui/profile/edit_anytls.ui @@ -149,10 +146,24 @@ set(PROJECT_SOURCES src/ui/profile/edit_tailscale.cpp include/ui/profile/edit_tailscale.ui include/configs/proxy/Tailscale.hpp - - include/ui/profile/edit_quic.h - src/ui/profile/edit_quic.cpp - include/ui/profile/edit_quic.ui + include/ui/profile/edit_trojan.h + src/ui/profile/edit_trojan.cpp + include/ui/profile/edit_trojan.ui + include/ui/profile/edit_http.h + src/ui/profile/edit_http.cpp + include/ui/profile/edit_http.ui + include/ui/profile/edit_socks.h + src/ui/profile/edit_socks.cpp + include/ui/profile/edit_socks.ui + include/ui/profile/edit_hysteria.h + src/ui/profile/edit_hysteria.cpp + include/ui/profile/edit_hysteria.ui + include/ui/profile/edit_hysteria2.h + src/ui/profile/edit_hysteria2.cpp + include/ui/profile/edit_hysteria2.ui + include/ui/profile/edit_tuic.h + src/ui/profile/edit_tuic.cpp + include/ui/profile/edit_tuic.ui include/ui/profile/edit_custom.h src/ui/profile/edit_custom.cpp @@ -279,6 +290,12 @@ endif () qt_add_executable(Throne MANUAL_FINALIZATION ${PROJECT_SOURCES} + include/ui/profile/edit_socks.h src/ui/profile/edit_socks.cpp include/ui/profile/edit_socks.ui + include/ui/profile/edit_http.h src/ui/profile/edit_http.cpp include/ui/profile/edit_http.ui + include/ui/profile/edit_trojan.h src/ui/profile/edit_trojan.cpp include/ui/profile/edit_trojan.ui + include/ui/profile/edit_hysteria.h src/ui/profile/edit_hysteria.cpp include/ui/profile/edit_hysteria.ui + include/ui/profile/edit_tuic.h src/ui/profile/edit_tuic.cpp include/ui/profile/edit_tuic.ui + include/ui/profile/edit_hysteria2.h src/ui/profile/edit_hysteria2.cpp include/ui/profile/edit_hysteria2.ui ) # Target diff --git a/include/configs/common/Outbound.h b/include/configs/common/Outbound.h index dc2a809..6469fd1 100644 --- a/include/configs/common/Outbound.h +++ b/include/configs/common/Outbound.h @@ -1,18 +1,21 @@ #pragma once #include "DialFields.h" +#include "multiplex.h" +#include "TLS.h" +#include "transport.h" #include "include/configs/baseConfig.h" namespace Configs { - class OutboundCommons : public baseConfig + class outbound : public baseConfig { - public: + public: QString name; QString server; int server_port = 0; std::shared_ptr dialFields = std::make_shared(); - OutboundCommons() + outbound() { _add(new configItem("name", &name, string)); _add(new configItem("server", &server, string)); @@ -20,37 +23,24 @@ namespace Configs _add(new configItem("dial_fields", dynamic_cast(dialFields.get()), jsonStore)); } - // baseConfig overrides - bool ParseFromLink(const QString& link) override; - bool ParseFromJson(const QJsonObject& object) override; - QString ExportToLink() override; - QJsonObject ExportToJson() override; - BuildResult Build() override; - }; - - class outbound : public baseConfig - { - public: - std::shared_ptr commons = std::make_shared(); - void ResolveDomainToIP(const std::function &onFinished); virtual QString GetAddress() { - return commons->server; + return server; } virtual QString DisplayAddress() { - return ::DisplayAddress(commons->server, commons->server_port); + return ::DisplayAddress(server, server_port); } virtual QString DisplayName() { - if (commons->name.isEmpty()) { + if (name.isEmpty()) { return DisplayAddress(); } - return commons->name; + return name; } virtual QString DisplayType() { return {}; }; @@ -60,6 +50,25 @@ namespace Configs return QString("[%1] %2").arg(DisplayType(), DisplayName()); } + virtual bool HasMux() { return false; } + + virtual bool HasTransport() { return false; } + + virtual bool HasTLS() { return false; } + + virtual std::shared_ptr GetTLS() { return std::make_shared(); } + + virtual std::shared_ptr GetTransport() { return std::make_shared(); } + + virtual std::shared_ptr GetMux() { return std::make_shared(); } + virtual bool IsEndpoint() { return false; }; + + // baseConfig overrides + bool ParseFromLink(const QString& link) override; + bool ParseFromJson(const QJsonObject& object) override; + QString ExportToLink() override; + QJsonObject ExportToJson() override; + BuildResult Build() override; }; } diff --git a/include/configs/common/multiplex.h b/include/configs/common/multiplex.h index f949bc5..592d1f3 100644 --- a/include/configs/common/multiplex.h +++ b/include/configs/common/multiplex.h @@ -51,6 +51,18 @@ namespace Configs _add(new configItem("brutal", dynamic_cast(brutal.get()), jsonStore)); } + int getMuxState() { + if (enabled) return 1; + if (!unspecified) return 2; + return 0; + } + + void saveMuxState(int state) { + if (state == 1) enabled = true; + enabled = false; + if (state == 0) unspecified = true; + } + // baseConfig overrides bool ParseFromLink(const QString& link) override; bool ParseFromJson(const QJsonObject& object) override; diff --git a/include/configs/common/transport.h b/include/configs/common/transport.h index 3f95e9c..a062fdc 100644 --- a/include/configs/common/transport.h +++ b/include/configs/common/transport.h @@ -37,6 +37,10 @@ namespace Configs _add(new configItem("service_name", &service_name, string)); } + QString getHeadersString(); + + static QStringList getHeaderPairs(QString rawHeader); + // baseConfig overrides bool ParseFromLink(const QString& link) override; bool ParseFromJson(const QJsonObject& object) override; diff --git a/include/configs/outbounds/anyTLS.h b/include/configs/outbounds/anyTLS.h index f3a6639..7bc6a00 100644 --- a/include/configs/outbounds/anyTLS.h +++ b/include/configs/outbounds/anyTLS.h @@ -15,7 +15,6 @@ namespace Configs anyTLS() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("password", &password, string)); _add(new configItem("idle_session_check_interval", &idle_session_check_interval, string)); _add(new configItem("idle_session_timeout", &idle_session_timeout, string)); @@ -23,6 +22,14 @@ namespace Configs _add(new configItem("tls", dynamic_cast(tls.get()), jsonStore)); } + bool HasTLS() override { + return true; + } + + std::shared_ptr GetTLS() override { + return tls; + } + // baseConfig overrides bool ParseFromLink(const QString& link) override; bool ParseFromJson(const QJsonObject& object) override; diff --git a/include/configs/outbounds/chain.h b/include/configs/outbounds/chain.h index 4e6c0e1..26a98db 100644 --- a/include/configs/outbounds/chain.h +++ b/include/configs/outbounds/chain.h @@ -10,7 +10,6 @@ namespace Configs chain() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("list", &list, integerList)); } diff --git a/include/configs/outbounds/custom.h b/include/configs/outbounds/custom.h index a9c0b00..c60433f 100644 --- a/include/configs/outbounds/custom.h +++ b/include/configs/outbounds/custom.h @@ -11,7 +11,6 @@ namespace Configs Custom() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("config", &config, string)); _add(new configItem("type", &type, string)); } diff --git a/include/configs/outbounds/extracore.h b/include/configs/outbounds/extracore.h index ea19d38..d30798a 100644 --- a/include/configs/outbounds/extracore.h +++ b/include/configs/outbounds/extracore.h @@ -13,7 +13,6 @@ namespace Configs bool noLogs = false; extracore() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("socks_address", &socksAddress, itemType::string)); _add(new configItem("socks_port", &socksPort, itemType::integer)); _add(new configItem("extra_core_path", &extraCorePath, itemType::string)); diff --git a/include/configs/outbounds/http.h b/include/configs/outbounds/http.h index a3c9546..0f3499f 100644 --- a/include/configs/outbounds/http.h +++ b/include/configs/outbounds/http.h @@ -16,7 +16,6 @@ namespace Configs http() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("username", &username, string)); _add(new configItem("password", &password, string)); _add(new configItem("path", &path, string)); @@ -24,6 +23,14 @@ namespace Configs _add(new configItem("tls", dynamic_cast(tls.get()), jsonStore)); } + bool HasTLS() override { + return true; + } + + std::shared_ptr GetTLS() override { + return tls; + } + // baseConfig overrides bool ParseFromLink(const QString& link) override; bool ParseFromJson(const QJsonObject& object) override; diff --git a/include/configs/outbounds/hysteria.h b/include/configs/outbounds/hysteria.h index e07eaa4..0f8c953 100644 --- a/include/configs/outbounds/hysteria.h +++ b/include/configs/outbounds/hysteria.h @@ -21,7 +21,6 @@ namespace Configs hysteria() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("server_ports", &server_ports, stringList)); _add(new configItem("hop_interval", &hop_interval, string)); _add(new configItem("up_mbps", &up_mbps, integer)); @@ -35,6 +34,14 @@ namespace Configs _add(new configItem("tls", dynamic_cast(tls.get()), jsonStore)); } + bool HasTLS() override { + return true; + } + + std::shared_ptr GetTLS() override { + return tls; + } + // baseConfig overrides bool ParseFromLink(const QString& link) override; bool ParseFromJson(const QJsonObject& object) override; diff --git a/include/configs/outbounds/hysteria2.h b/include/configs/outbounds/hysteria2.h index b463250..842efcc 100644 --- a/include/configs/outbounds/hysteria2.h +++ b/include/configs/outbounds/hysteria2.h @@ -18,7 +18,6 @@ namespace Configs hysteria2() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("server_ports", &server_ports, stringList)); _add(new configItem("hop_interval", &hop_interval, string)); _add(new configItem("up_mbps", &up_mbps, integer)); @@ -29,6 +28,14 @@ namespace Configs _add(new configItem("tls", dynamic_cast(tls.get()), jsonStore)); } + bool HasTLS() override { + return true; + } + + std::shared_ptr GetTLS() override { + return tls; + } + // baseConfig overrides bool ParseFromLink(const QString& link) override; bool ParseFromJson(const QJsonObject& object) override; diff --git a/include/configs/outbounds/shadowsocks.h b/include/configs/outbounds/shadowsocks.h index 8c7a435..a133db6 100644 --- a/include/configs/outbounds/shadowsocks.h +++ b/include/configs/outbounds/shadowsocks.h @@ -19,7 +19,6 @@ namespace Configs shadowsocks() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("method", &method, string)); _add(new configItem("password", &password, string)); _add(new configItem("plugin", &plugin, string)); @@ -28,6 +27,14 @@ namespace Configs _add(new configItem("multiplex", dynamic_cast(multiplex.get()), jsonStore)); } + bool HasMux() override { + return true; + } + + std::shared_ptr GetMux() override { + return multiplex; + } + // baseConfig overrides bool ParseFromLink(const QString& link) override; bool ParseFromJson(const QJsonObject& object) override; diff --git a/include/configs/outbounds/socks.h b/include/configs/outbounds/socks.h index 25f91e9..7c52bbd 100644 --- a/include/configs/outbounds/socks.h +++ b/include/configs/outbounds/socks.h @@ -14,7 +14,6 @@ namespace Configs socks() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("username", &username, string)); _add(new configItem("password", &password, string)); _add(new configItem("version", &version, integer)); diff --git a/include/configs/outbounds/ssh.h b/include/configs/outbounds/ssh.h index 2944f8b..230cea8 100644 --- a/include/configs/outbounds/ssh.h +++ b/include/configs/outbounds/ssh.h @@ -17,7 +17,6 @@ namespace Configs ssh() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("user", &user, string)); _add(new configItem("password", &password, string)); _add(new configItem("private_key", &private_key, string)); diff --git a/include/configs/outbounds/tailscale.h b/include/configs/outbounds/tailscale.h index 005b6b3..fde9097 100644 --- a/include/configs/outbounds/tailscale.h +++ b/include/configs/outbounds/tailscale.h @@ -20,7 +20,6 @@ namespace Configs tailscale() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("state_directory", &state_directory, itemType::string)); _add(new configItem("auth_key", &auth_key, itemType::string)); _add(new configItem("control_url", &control_url, itemType::string)); diff --git a/include/configs/outbounds/trojan.h b/include/configs/outbounds/trojan.h index 50d230e..ad528be 100644 --- a/include/configs/outbounds/trojan.h +++ b/include/configs/outbounds/trojan.h @@ -16,13 +16,36 @@ namespace Configs Trojan() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("password", &password, string)); _add(new configItem("tls", dynamic_cast(tls.get()), jsonStore)); _add(new configItem("multiplex", dynamic_cast(multiplex.get()), jsonStore)); _add(new configItem("transport", dynamic_cast(transport.get()), jsonStore)); } + bool HasTLS() override { + return true; + } + + bool HasMux() override { + return true; + } + + bool HasTransport() override { + return true; + } + + std::shared_ptr GetTLS() override { + return tls; + } + + std::shared_ptr GetMux() override { + return multiplex; + } + + std::shared_ptr GetTransport() override { + return transport; + } + // baseConfig overrides bool ParseFromLink(const QString& link) override; bool ParseFromJson(const QJsonObject& object) override; diff --git a/include/configs/outbounds/tuic.h b/include/configs/outbounds/tuic.h index c1fe3f9..6b5cc8f 100644 --- a/include/configs/outbounds/tuic.h +++ b/include/configs/outbounds/tuic.h @@ -22,7 +22,6 @@ namespace Configs tuic() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("uuid", &uuid, string)); _add(new configItem("password", &password, string)); _add(new configItem("congestion_control", &congestion_control, string)); @@ -33,6 +32,14 @@ namespace Configs _add(new configItem("tls", dynamic_cast(tls.get()), jsonStore)); } + bool HasTLS() override { + return true; + } + + std::shared_ptr GetTLS() override { + return tls; + } + // baseConfig overrides bool ParseFromLink(const QString& link) override; bool ParseFromJson(const QJsonObject& object) override; diff --git a/include/configs/outbounds/vless.h b/include/configs/outbounds/vless.h index af5e7a7..27b63f3 100644 --- a/include/configs/outbounds/vless.h +++ b/include/configs/outbounds/vless.h @@ -20,7 +20,6 @@ namespace Configs vless() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("uuid", &uuid, string)); _add(new configItem("flow", &flow, string)); _add(new configItem("tls", dynamic_cast(tls.get()), jsonStore)); @@ -29,6 +28,30 @@ namespace Configs _add(new configItem("transport", dynamic_cast(transport.get()), jsonStore)); } + bool HasTLS() override { + return true; + } + + bool HasMux() override { + return true; + } + + bool HasTransport() override { + return true; + } + + std::shared_ptr GetTLS() override { + return tls; + } + + std::shared_ptr GetMux() override { + return multiplex; + } + + std::shared_ptr GetTransport() override { + return transport; + } + // baseConfig overrides bool ParseFromLink(const QString& link) override; bool ParseFromJson(const QJsonObject& object) override; diff --git a/include/configs/outbounds/vmess.h b/include/configs/outbounds/vmess.h index ed02460..4320e29 100644 --- a/include/configs/outbounds/vmess.h +++ b/include/configs/outbounds/vmess.h @@ -25,7 +25,6 @@ namespace Configs vmess() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); _add(new configItem("uuid", &uuid, string)); _add(new configItem("security", &security, string)); _add(new configItem("alter-id", &alter_id, integer)); @@ -37,6 +36,30 @@ namespace Configs _add(new configItem("multiplex", dynamic_cast(multiplex.get()), jsonStore)); } + bool HasTLS() override { + return true; + } + + bool HasMux() override { + return true; + } + + bool HasTransport() override { + return true; + } + + std::shared_ptr GetTLS() override { + return tls; + } + + std::shared_ptr GetMux() override { + return multiplex; + } + + std::shared_ptr GetTransport() override { + return transport; + } + // baseConfig overrides bool ParseFromLink(const QString& link) override; bool ParseFromJson(const QJsonObject& object) override; diff --git a/include/configs/outbounds/wireguard.h b/include/configs/outbounds/wireguard.h index afd4254..103c1e0 100644 --- a/include/configs/outbounds/wireguard.h +++ b/include/configs/outbounds/wireguard.h @@ -56,8 +56,6 @@ namespace Configs wireguard() : outbound() { - _add(new configItem("commons", dynamic_cast(commons.get()), jsonStore)); - _add(new configItem("private_key", &private_key, itemType::string)); _add(new configItem("peer", dynamic_cast(peer.get()), jsonStore)); _add(new configItem("address", &address, itemType::stringList)); diff --git a/include/dataStore/Database.hpp b/include/dataStore/Database.hpp index 8c8049a..552762d 100644 --- a/include/dataStore/Database.hpp +++ b/include/dataStore/Database.hpp @@ -58,7 +58,7 @@ namespace Configs { void UpdateRouteChains(const QList>& newChain); - QStringList GetExtraCorePaths() const; + [[nodiscard]] QStringList GetExtraCorePaths() const; bool AddExtraCorePath(const QString &path); diff --git a/include/dataStore/ProxyEntity.hpp b/include/dataStore/ProxyEntity.hpp index a0bcfc8..49b5121 100644 --- a/include/dataStore/ProxyEntity.hpp +++ b/include/dataStore/ProxyEntity.hpp @@ -36,7 +36,7 @@ namespace Configs { QString dl_speed; QString ul_speed; QString test_country; - std::shared_ptr bean; + std::shared_ptr _bean; std::shared_ptr outbound; std::shared_ptr traffic_data = std::make_shared(""); diff --git a/include/global/Utils.hpp b/include/global/Utils.hpp index 1cd45e4..5b444cc 100644 --- a/include/global/Utils.hpp +++ b/include/global/Utils.hpp @@ -57,6 +57,8 @@ QStringList SplitLines(const QString &_string); QStringList SplitLinesSkipSharp(const QString &_string, int maxLine = 0); +QStringList SplitAndTrim(QString raw, QString seperator); + // Base64 QByteArray DecodeB64IfValid(const QString &input, QByteArray::Base64Options options = QByteArray::Base64Option::Base64Encoding); diff --git a/include/ui/profile/dialog_edit_profile.h b/include/ui/profile/dialog_edit_profile.h index 6c708ff..3819ff0 100644 --- a/include/ui/profile/dialog_edit_profile.h +++ b/include/ui/profile/dialog_edit_profile.h @@ -25,15 +25,7 @@ public slots: void accept() override; private slots: - - void on_custom_outbound_edit_clicked(); - - void on_custom_config_edit_clicked(); - void on_certificate_edit_clicked(); - - void on_apply_to_group_clicked(); - private: Ui::DialogEditProfile *ui; @@ -50,8 +42,6 @@ private: QString network_title_base; struct { - QString custom_outbound; - QString custom_config; QString certificate; } CACHE; @@ -60,8 +50,6 @@ private: bool onEnd(); void editor_cache_updated_impl(); - - void do_apply_to_group(const std::shared_ptr &group, QWidget *key); }; #endif // DIALOG_EDIT_PROFILE_H diff --git a/include/ui/profile/dialog_edit_profile.ui b/include/ui/profile/dialog_edit_profile.ui index 823dfad..0738be6 100644 --- a/include/ui/profile/dialog_edit_profile.ui +++ b/include/ui/profile/dialog_edit_profile.ui @@ -141,8 +141,28 @@ - - + + + + Server support is required + + + Multiplex + + + + + + + Transport Layer Security. It must be consistent with the server, otherwise, the connection cannot be established. + + + Security + + + + + @@ -150,12 +170,7 @@ - packetaddr - - - - - xudp + tls @@ -170,6 +185,25 @@ + + + + + Keep Default + + + + + On + + + + + Off + + + + @@ -215,69 +249,6 @@ - - - - Server support is required - - - Multiplex - - - - - - - Transport Layer Security. It must be consistent with the server, otherwise, the connection cannot be established. - - - Security - - - - - - - - - - - - - tls - - - - - - - - UDP FullCone Packet encoding for implementing features such as UDP FullCone. Server support is required, if the wrong selection is made, the connection cannot be made. Please leave it blank. - - - Packet Encoding - - - - - - - - Keep Default - - - - - On - - - - - Off - - - - @@ -326,57 +297,8 @@ - - - - - - - 0 - 0 - - - - Custom Outbound Settings - - - - - - Edit - - - - - - - - - - Custom Config Settings - - - - - - Edit - - - - - - - - - - - - Apply settings to this group - - - @@ -431,14 +353,36 @@ Network Settings (%1) - + + + + + + + + + + <html><head/><body><p>http path (ws/http/httpUpgrade)</p><p>serviceName (gRPC)</p></body></html> + + + Path + + + + EarlyData Name - + + + + + + + @@ -457,49 +401,14 @@ - + EarlyData Length - - - - - - <html><head/><body><p>http path (ws/http/httpUpgrade)</p><p>serviceName (gRPC)</p></body></html> - - - Path - - - - - - - - - - - - - - - - - - - <html><head/><body><p>Method of http request, will be converted to uppercase</p></body></html> - - - Method - - - - <html><head/><body><p>http host (ws/http/httpUpgrade)</p></body></html> @@ -509,30 +418,22 @@ - - + + - - - - - - - - - - http - - - - - - + + + + <html><head/><body><p>Method of http request, will be converted to uppercase</p></body></html> + - header type + Method + + + @@ -805,12 +706,8 @@ name address port - custom_outbound_edit - custom_config_edit - apply_to_group network security - packet_encoding multiplex path host diff --git a/include/ui/profile/edit_socks_http.h b/include/ui/profile/edit_http.h similarity index 50% rename from include/ui/profile/edit_socks_http.h rename to include/ui/profile/edit_http.h index 88a1f98..760c743 100644 --- a/include/ui/profile/edit_socks_http.h +++ b/include/ui/profile/edit_http.h @@ -1,26 +1,29 @@ -#pragma once +#ifndef EDIT_HTTP_H +#define EDIT_HTTP_H #include #include "profile_editor.h" -#include "ui_edit_socks_http.h" +#include "ui_edit_http.h" namespace Ui { - class EditSocksHttp; + class EditHttp; } -class EditSocksHttp : public QWidget, public ProfileEditor { +class EditHttp : public QWidget, public ProfileEditor { Q_OBJECT public: - explicit EditSocksHttp(QWidget *parent = nullptr); + explicit EditHttp(QWidget *parent = nullptr); - ~EditSocksHttp() override; + ~EditHttp() override; void onStart(std::shared_ptr _ent) override; bool onEnd() override; private: - Ui::EditSocksHttp *ui; + Ui::EditHttp *ui; std::shared_ptr ent; }; + +#endif diff --git a/include/ui/profile/edit_http.ui b/include/ui/profile/edit_http.ui new file mode 100644 index 0000000..dc89318 --- /dev/null +++ b/include/ui/profile/edit_http.ui @@ -0,0 +1,41 @@ + + + EditHttp + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Username + + + + + + + + + + Password + + + + + + + + + + + diff --git a/include/ui/profile/edit_hysteria.h b/include/ui/profile/edit_hysteria.h new file mode 100644 index 0000000..c0a36fa --- /dev/null +++ b/include/ui/profile/edit_hysteria.h @@ -0,0 +1,29 @@ +#ifndef EDIT_HYSTERIA_H +#define EDIT_HYSTERIA_H + +#include +#include "profile_editor.h" +#include "ui_edit_hysteria.h" + +namespace Ui { + class EditHysteria; +} + +class EditHysteria : public QWidget, public ProfileEditor { + Q_OBJECT + +public: + explicit EditHysteria(QWidget *parent = nullptr); + + ~EditHysteria() override; + + void onStart(std::shared_ptr _ent) override; + + bool onEnd() override; + +private: + Ui::EditHysteria *ui; + std::shared_ptr ent; +}; + +#endif diff --git a/include/ui/profile/edit_hysteria.ui b/include/ui/profile/edit_hysteria.ui new file mode 100644 index 0000000..5aa281d --- /dev/null +++ b/include/ui/profile/edit_hysteria.ui @@ -0,0 +1,118 @@ + + + EditHysteria + + + + 0 + 0 + 400 + 363 + + + + Form + + + + + + Down Mbps + + + + + + + + + + + + + Recv window conn + + + + + + + Hop Interval + + + + + + + + + + Server Ports + + + + + + + Auth + + + + + + + + + + Up Mbps + + + + + + + + + + Auth Str + + + + + + + + + + + + + + + + Obfs + + + + + + + Recv window + + + + + + + + + + Disable Mtu Discovery + + + + + + + + diff --git a/include/ui/profile/edit_hysteria2.h b/include/ui/profile/edit_hysteria2.h new file mode 100644 index 0000000..74edd20 --- /dev/null +++ b/include/ui/profile/edit_hysteria2.h @@ -0,0 +1,29 @@ +#ifndef EDIT_HYSTERIA2_H +#define EDIT_HYSTERIA2_H + +#include +#include "profile_editor.h" +#include "ui_edit_hysteria2.h" + +namespace Ui { + class EditHysteria2; +} + +class EditHysteria2 : public QWidget, public ProfileEditor { + Q_OBJECT + +public: + explicit EditHysteria2(QWidget *parent = nullptr); + + ~EditHysteria2() override; + + void onStart(std::shared_ptr _ent) override; + + bool onEnd() override; + +private: + Ui::EditHysteria2 *ui; + std::shared_ptr ent; +}; + +#endif // EDIT_HYSTERIA2_H diff --git a/include/ui/profile/edit_hysteria2.ui b/include/ui/profile/edit_hysteria2.ui new file mode 100644 index 0000000..caf5e11 --- /dev/null +++ b/include/ui/profile/edit_hysteria2.ui @@ -0,0 +1,81 @@ + + + EditHysteria2 + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + + Server Ports + + + + + + + + + + Password + + + + + + + Down Mbps + + + + + + + Obfs Password + + + + + + + + + + + + + + + + Hop Interval + + + + + + + Up Mbps + + + + + + + + + + + diff --git a/include/ui/profile/edit_quic.h b/include/ui/profile/edit_quic.h deleted file mode 100644 index 7079607..0000000 --- a/include/ui/profile/edit_quic.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include -#include -#include -#include "profile_editor.h" -#include "ui_edit_quic.h" - -QT_BEGIN_NAMESPACE -namespace Ui { - class EditQUIC; -} -QT_END_NAMESPACE - -class EditQUIC : public QWidget, public ProfileEditor { - Q_OBJECT - -public: - explicit EditQUIC(QWidget *parent = nullptr); - - ~EditQUIC() override; - - void onStart(std::shared_ptr _ent) override; - - bool onEnd() override; - - QList> get_editor_cached() override; - -private: - Ui::EditQUIC *ui; - std::shared_ptr ent; - - struct { - QString caText; - } CACHE; - -private slots: - - void on_certificate_clicked(); -}; diff --git a/include/ui/profile/edit_quic.ui b/include/ui/profile/edit_quic.ui deleted file mode 100644 index 80bfe7f..0000000 --- a/include/ui/profile/edit_quic.ui +++ /dev/null @@ -1,412 +0,0 @@ - - - EditQUIC - - - - 0 - 0 - 500 - 628 - - - - EditHysteria - - - - - - - - - - Heartbeat - - - - - - - - 0 - 0 - - - - - - - - - - - - Download (Mbps) - - - - - - - - - - - - Requires sing-box server - - - UDP over Stream - - - - - - - - - Upload (Mbps) - - - - - - - - - - - - Zero Rtt Handshake - - - - - - - - - UDP Relay Mode - - - - - - - - native - - - - - quic - - - - - - - - - - - - Congestion Control - - - - - - - - bbr - - - - - cubic - - - - - new_reno - - - - - - - - - - - - - - <html><head/><body><p>Comma seperated ranges: 100:200,500:600</p></body></html> - - - - - - - Obfs Password - - - - - - - - - - - 0 - 0 - - - - Disable MTU Discovery - - - - - - - <html><head/><body><p>Comma seperated ranges: 100:200,500:600</p></body></html> - - - Port range - - - - - - - - - - Hop Interval - - - - - - - <html><head/><body><p>100ms<br/>1s</p></body></html> - - - - - - - - - - - - - - - 0 - 0 - - - - Auth Type - - - - - - - - 0 - 0 - - - - Auth Payload - - - - - - - - 0 - 0 - - - - Password - - - - - - - UUID - - - - - - - Generate UUID - - - - - - - - - - - - - - NONE - - - - - STRING - - - - - BASE64 - - - - - - - - - - - - Certificate - - - - - - - PushButton - - - - - - - - - - Disable SNI - - - - - - - - - - ALPN - - - - - - - SNI - - - - - - - Allow Insecure - - - - - - - Qt::Orientation::Horizontal - - - QSizePolicy::Policy::Maximum - - - - 40 - 20 - - - - - - - - - - - - recv_window - - - - - - - - - - recv_window_conn - - - - - - - - - - - - - MyLineEdit - QLineEdit -
include/ui/utils/MyLineEdit.h
-
-
- - uploadMbps - downloadMbps - congestionControl - udpRelayMode - heartbeat - zeroRttHandshake - uos - authPayloadType - authPayload - uuid - uuidgen - password - sni - disableSni - alpn - certificate - allowInsecure - streamReceiveWindow - connectionReceiveWindow - - - -
diff --git a/include/ui/profile/edit_socks.h b/include/ui/profile/edit_socks.h new file mode 100644 index 0000000..decd8e8 --- /dev/null +++ b/include/ui/profile/edit_socks.h @@ -0,0 +1,29 @@ +#ifndef EDIT_SOCKS_H +#define EDIT_SOCKS_H + +#include +#include "profile_editor.h" +#include "ui_edit_socks.h" + +namespace Ui { + class EditSocks; +} + +class EditSocks : public QWidget, public ProfileEditor { + Q_OBJECT + +public: + explicit EditSocks(QWidget *parent = nullptr); + + ~EditSocks() override; + + void onStart(std::shared_ptr _ent) override; + + bool onEnd() override; + +private: + Ui::EditSocks *ui; + std::shared_ptr ent; +}; + +#endif // EDIT_SOCKS_H diff --git a/include/ui/profile/edit_socks_http.ui b/include/ui/profile/edit_socks.ui similarity index 69% rename from include/ui/profile/edit_socks_http.ui rename to include/ui/profile/edit_socks.ui index c179709..f06a822 100644 --- a/include/ui/profile/edit_socks_http.ui +++ b/include/ui/profile/edit_socks.ui @@ -1,7 +1,7 @@ - EditSocksHttp - + EditSocks + 0 @@ -11,57 +11,52 @@ - Form + Form - - - - Version - - - - - - - - - - - - - Username - - - - - - - - 5 - - - - - 4 - - - - - - + + Password + + + + Version + + + + + + + Username + + + + + + + + + + + + + + 5 + + + + + 4 + + + + - - version - username - password - diff --git a/include/ui/profile/edit_trojan.h b/include/ui/profile/edit_trojan.h new file mode 100644 index 0000000..ff3c551 --- /dev/null +++ b/include/ui/profile/edit_trojan.h @@ -0,0 +1,29 @@ +#ifndef EDIT_TROJAN_H +#define EDIT_TROJAN_H + +#include +#include "profile_editor.h" +#include "ui_edit_trojan.h" + +namespace Ui { + class EditTrojan; +} + +class EditTrojan : public QWidget, public ProfileEditor { + Q_OBJECT + +public: + explicit EditTrojan(QWidget *parent = nullptr); + + ~EditTrojan() override; + + void onStart(std::shared_ptr _ent) override; + + bool onEnd() override; + +private: + Ui::EditTrojan *ui; + std::shared_ptr ent; +}; + +#endif // EDIT_TROJAN_H diff --git a/include/ui/profile/edit_trojan.ui b/include/ui/profile/edit_trojan.ui new file mode 100644 index 0000000..65eb51c --- /dev/null +++ b/include/ui/profile/edit_trojan.ui @@ -0,0 +1,31 @@ + + + EditTrojan + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Password + + + + + + + + + + + diff --git a/include/ui/profile/edit_tuic.h b/include/ui/profile/edit_tuic.h new file mode 100644 index 0000000..6d05f24 --- /dev/null +++ b/include/ui/profile/edit_tuic.h @@ -0,0 +1,29 @@ +#ifndef EDIT_TUIC_H +#define EDIT_TUIC_H + +#include +#include "profile_editor.h" +#include "ui_edit_tuic.h" + +namespace Ui { + class EditTuic; +} + +class EditTuic : public QWidget, public ProfileEditor { + Q_OBJECT + +public: + explicit EditTuic(QWidget *parent = nullptr); + + ~EditTuic() override; + + void onStart(std::shared_ptr _ent) override; + + bool onEnd() override; + +private: + Ui::EditTuic *ui; + std::shared_ptr ent; +}; + +#endif // EDIT_TUIC_H diff --git a/include/ui/profile/edit_tuic.ui b/include/ui/profile/edit_tuic.ui new file mode 100644 index 0000000..8cca831 --- /dev/null +++ b/include/ui/profile/edit_tuic.ui @@ -0,0 +1,112 @@ + + + EditTuic + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Heartbeat + + + + + + + UDP Relay Mode + + + + + + + Password + + + + + + + Zero RTT Handshake + + + + + + + + + + + + + + + + UUID + + + + + + + + bbr + + + + + cubic + + + + + new_reno + + + + + + + + Congestion Control + + + + + + + + native + + + + + quic + + + + + + + + UDP over Stream + + + + + + + + diff --git a/include/ui/profile/edit_trojan_vless.h b/include/ui/profile/edit_vless.h similarity index 52% rename from include/ui/profile/edit_trojan_vless.h rename to include/ui/profile/edit_vless.h index 7171ccb..8d8ae9f 100644 --- a/include/ui/profile/edit_trojan_vless.h +++ b/include/ui/profile/edit_vless.h @@ -2,29 +2,28 @@ #include #include "profile_editor.h" -#include "ui_edit_trojan_vless.h" +#include "ui_edit_vless.h" QT_BEGIN_NAMESPACE namespace Ui { - class EditTrojanVLESS; + class EditVless; } QT_END_NAMESPACE -class EditTrojanVLESS : public QWidget, public ProfileEditor { +class EditVless : public QWidget, public ProfileEditor { Q_OBJECT public: - explicit EditTrojanVLESS(QWidget *parent = nullptr); + explicit EditVless(QWidget *parent = nullptr); - ~EditTrojanVLESS() override; + ~EditVless() override; void onStart(std::shared_ptr _ent) override; bool onEnd() override; - QComboBox* flow_; - + QComboBox *_flow; private: - Ui::EditTrojanVLESS *ui; + Ui::EditVless *ui; std::shared_ptr ent; }; diff --git a/include/ui/profile/edit_trojan_vless.ui b/include/ui/profile/edit_vless.ui similarity index 72% rename from include/ui/profile/edit_trojan_vless.ui rename to include/ui/profile/edit_vless.ui index 5f05bf7..f02c6ee 100644 --- a/include/ui/profile/edit_trojan_vless.ui +++ b/include/ui/profile/edit_vless.ui @@ -1,7 +1,7 @@ - EditTrojanVLESS - + EditVless + 0 @@ -14,16 +14,6 @@ - - - - - - - Password - - - @@ -40,6 +30,26 @@
+ + + + UUID + + + + + + + + + + Packet Encoding + + + + + + diff --git a/include/ui/profile/edit_vmess.ui b/include/ui/profile/edit_vmess.ui index b9b873b..127cb0e 100644 --- a/include/ui/profile/edit_vmess.ui +++ b/include/ui/profile/edit_vmess.ui @@ -14,62 +14,6 @@ EditVMess - - - - true - - - - auto - - - - - zero - - - - - none - - - - - chacha20-poly1305 - - - - - aes-128-gcm - - - - - - - - Security - - - - - - - Alter Id - - - - - - - UUID - - - - - - @@ -104,6 +48,72 @@ + + + + Alter Id + + + + + + + true + + + + auto + + + + + zero + + + + + none + + + + + chacha20-poly1305 + + + + + aes-128-gcm + + + + + + + + + + + Security + + + + + + + UUID + + + + + + + Packet Encoding + + + + + + diff --git a/src/configs/common/Outbound.cpp b/src/configs/common/Outbound.cpp index ff3a67c..feec382 100644 --- a/src/configs/common/Outbound.cpp +++ b/src/configs/common/Outbound.cpp @@ -2,7 +2,7 @@ #include "include/configs/common/utils.h" namespace Configs { - bool OutboundCommons::ParseFromLink(const QString& link) + bool outbound::ParseFromLink(const QString& link) { auto url = QUrl(link); if (!url.isValid()) return false; @@ -13,7 +13,7 @@ namespace Configs { dialFields->ParseFromLink(link); return true; } - bool OutboundCommons::ParseFromJson(const QJsonObject& object) + bool outbound::ParseFromJson(const QJsonObject& object) { if (object.isEmpty()) return false; if (object.contains("tag")) name = object["tag"].toString(); @@ -22,13 +22,13 @@ namespace Configs { dialFields->ParseFromJson(object); return true; } - QString OutboundCommons::ExportToLink() + QString outbound::ExportToLink() { QUrlQuery query; mergeUrlQuery(query, dialFields->ExportToLink()); return query.toString(); } - QJsonObject OutboundCommons::ExportToJson() + QJsonObject outbound::ExportToJson() { QJsonObject object; if (!name.isEmpty()) object["tag"] = name; @@ -38,7 +38,7 @@ namespace Configs { mergeJsonObjects(object, dialFieldsObj); return object; } - BuildResult OutboundCommons::Build() + BuildResult outbound::Build() { return {ExportToJson(), ""}; } diff --git a/src/configs/common/TLS.cpp b/src/configs/common/TLS.cpp index e89e104..3731a17 100644 --- a/src/configs/common/TLS.cpp +++ b/src/configs/common/TLS.cpp @@ -137,7 +137,13 @@ namespace Configs { } BuildResult Reality::Build() { - return {ExportToJson(), ""}; + QJsonObject object; + if (!public_key.isEmpty() || enabled) { + object["enabled"] = true; + object["public_key"] = public_key; + if (!short_id.isEmpty()) object["short_id"] = short_id; + } + return {object, ""}; } bool TLS::ParseFromLink(const QString& link) diff --git a/src/configs/common/transport.cpp b/src/configs/common/transport.cpp index 652b7cf..8d9be8e 100644 --- a/src/configs/common/transport.cpp +++ b/src/configs/common/transport.cpp @@ -7,6 +7,57 @@ #include "include/configs/common/utils.h" namespace Configs { + + QString Transport::getHeadersString() { + QString result; + for (int i=0;ibean->serverPort = ui->port->text().toInt(); + ent->outbound->name = ui->name->text(); + ent->outbound->server = ui->address->text().remove(' '); + ent->outbound->server_port = ui->port->text().toInt(); - // 右边 stream - auto stream = GetStreamSettings(ent->bean.get()); - if (stream != nullptr) { - stream->network = ui->network->currentText(); - stream->security = ui->security->currentText(); - stream->packet_encoding = ui->packet_encoding->currentText(); - stream->path = ui->path->text(); - stream->host = ui->host->text(); - stream->sni = ui->sni->text(); - stream->alpn = ui->alpn->text(); - stream->utlsFingerprint = ui->utlsFingerprint->currentText(); - stream->enable_tls_fragment = ui->tls_frag->isChecked(); - stream->tls_fragment_fallback_delay = ui->tls_frag_fall_delay->text(); - stream->enable_tls_record_fragment = ui->tls_rec_frag->isChecked(); - stream->allow_insecure = ui->insecure->isChecked(); - stream->headers = ui->headers->text(); - stream->header_type = ui->header_type->currentText(); - stream->method = ui->method->text(); - stream->ws_early_data_name = ui->ws_early_data_name->text(); - stream->ws_early_data_length = ui->ws_early_data_length->text().toInt(); - stream->reality_pbk = ui->reality_pbk->text(); - stream->reality_sid = ui->reality_sid->text(); - ent->bean->mux_state = ui->multiplex->currentIndex(); - ent->bean->enable_brutal = ui->brutal_enable->isChecked(); - ent->bean->brutal_speed = ui->brutal_speed->text().toInt(); - stream->certificate = CACHE.certificate; - - bool validHeaders; - stream->GetHeaderPairs(&validHeaders); - if (!validHeaders) { - MW_show_log("Headers are not valid"); - return false; - } + if (ent->outbound->HasTLS() || ent->outbound->HasTransport()) { + auto tls = ent->outbound->GetTLS(); + auto transport = ent->outbound->GetTransport(); + transport->type = ui->network->currentText(); + tls->enabled = ui->security->currentText() == "tls"; + transport->path = ui->path->text(); + transport->host = ui->host->text(); + tls->server_name = ui->sni->text(); + tls->alpn = SplitAndTrim(ui->alpn->text(), ","); + tls->utls->fingerPrint = ui->utlsFingerprint->currentText(); + tls->utls->enabled = !tls->utls->fingerPrint.isEmpty(); + tls->fragment = ui->tls_frag->isChecked(); + tls->fragment_fallback_delay = ui->tls_frag_fall_delay->text(); + tls->record_fragment = ui->tls_rec_frag->isChecked(); + tls->insecure = ui->insecure->isChecked(); + transport->headers = transport->getHeaderPairs(ui->headers->text()); + transport->method = ui->method->text(); + transport->early_data_header_name = ui->ws_early_data_name->text(); + transport->max_early_data = ui->ws_early_data_length->text().toInt(); + tls->reality->public_key = ui->reality_pbk->text(); + tls->reality->short_id = ui->reality_sid->text(); + tls->certificate = CACHE.certificate; + } + if (ent->outbound->HasMux()) { + auto mux = ent->outbound->GetMux(); + mux->saveMuxState(ui->multiplex->currentIndex()); + mux->brutal->enabled = ui->brutal_enable->isChecked(); + mux->brutal->down_mbps = ui->brutal_speed->text().toInt(); } - - // cached custom - ent->bean->custom_outbound = CACHE.custom_outbound; - ent->bean->custom_config = CACHE.custom_config; return true; } @@ -495,16 +473,6 @@ void DialogEditProfile::editor_cache_updated_impl() { } else { ui->certificate_edit->setText(tr("Already set")); } - if (CACHE.custom_outbound.isEmpty()) { - ui->custom_outbound_edit->setText(tr("Not set")); - } else { - ui->custom_outbound_edit->setText(tr("Already set")); - } - if (CACHE.custom_config.isEmpty()) { - ui->custom_config_edit->setText(tr("Not set")); - } else { - ui->custom_config_edit->setText(tr("Already set")); - } // CACHE macro for (auto a: innerEditor->get_editor_cached()) { @@ -516,16 +484,6 @@ void DialogEditProfile::editor_cache_updated_impl() { } } -void DialogEditProfile::on_custom_outbound_edit_clicked() { - C_EDIT_JSON_ALLOW_EMPTY(custom_outbound) - editor_cache_updated_impl(); -} - -void DialogEditProfile::on_custom_config_edit_clicked() { - C_EDIT_JSON_ALLOW_EMPTY(custom_config) - editor_cache_updated_impl(); -} - void DialogEditProfile::on_certificate_edit_clicked() { bool ok; auto txt = QInputDialog::getMultiLineText(this, tr("Certificate"), "", CACHE.certificate, &ok); @@ -534,91 +492,3 @@ void DialogEditProfile::on_certificate_edit_clicked() { editor_cache_updated_impl(); } } - -void DialogEditProfile::on_apply_to_group_clicked() { - if (apply_to_group_ui.empty()) { - apply_to_group_ui[ui->multiplex] = new FloatCheckBox(ui->multiplex, this); - apply_to_group_ui[ui->sni] = new FloatCheckBox(ui->sni, this); - apply_to_group_ui[ui->alpn] = new FloatCheckBox(ui->alpn, this); - apply_to_group_ui[ui->host] = new FloatCheckBox(ui->host, this); - apply_to_group_ui[ui->path] = new FloatCheckBox(ui->path, this); - apply_to_group_ui[ui->utlsFingerprint] = new FloatCheckBox(ui->utlsFingerprint, this); - apply_to_group_ui[ui->insecure] = new FloatCheckBox(ui->insecure, this); - apply_to_group_ui[ui->certificate_edit] = new FloatCheckBox(ui->certificate_edit, this); - apply_to_group_ui[ui->custom_config_edit] = new FloatCheckBox(ui->custom_config_edit, this); - apply_to_group_ui[ui->custom_outbound_edit] = new FloatCheckBox(ui->custom_outbound_edit, this); - ui->apply_to_group->setText(tr("Confirm")); - } else { - auto group = Configs::profileManager->GetGroup(ent->gid); - if (group == nullptr) { - MessageBoxWarning("failed", "unknown group"); - return; - } - // save this - if (onEnd()) { - ent->Save(); - } else { - MessageBoxWarning("failed", "failed to save"); - return; - } - // copy keys - for (const auto &pair: apply_to_group_ui) { - if (pair.second->isChecked()) { - do_apply_to_group(group, pair.first); - } - delete pair.second; - } - apply_to_group_ui.clear(); - ui->apply_to_group->setText(tr("Apply settings to this group")); - } -} - -void DialogEditProfile::do_apply_to_group(const std::shared_ptr &group, QWidget *key) { - auto stream = GetStreamSettings(ent->bean.get()); - - auto copyStream = [=,this](void *p) { - for (const auto &profile: group->GetProfileEnts()) { - auto newStream = GetStreamSettings(profile->bean.get()); - if (newStream == nullptr) continue; - if (stream == newStream) continue; - newStream->_setValue(stream->_name(p), p); - // qDebug() << newStream->ToJsonBytes(); - profile->Save(); - } - }; - - auto copyBean = [=,this](void *p) { - for (const auto &profile: group->GetProfileEnts()) { - if (profile == ent) continue; - profile->bean->_setValue(ent->bean->_name(p), p); - // qDebug() << profile->bean->ToJsonBytes(); - profile->Save(); - } - }; - - if (key == ui->multiplex) { - copyStream(&ent->bean->mux_state); - } else if (key == ui->brutal_enable) { - copyStream(&ent->bean->enable_brutal); - } else if (key == ui->brutal_speed) { - copyStream(&ent->bean->brutal_speed); - } else if (key == ui->sni) { - copyStream(&stream->sni); - } else if (key == ui->alpn) { - copyStream(&stream->alpn); - } else if (key == ui->host) { - copyStream(&stream->host); - } else if (key == ui->path) { - copyStream(&stream->path); - } else if (key == ui->utlsFingerprint) { - copyStream(&stream->utlsFingerprint); - } else if (key == ui->insecure) { - copyStream(&stream->allow_insecure); - } else if (key == ui->certificate_edit) { - copyStream(&stream->certificate); - } else if (key == ui->custom_config_edit) { - copyBean(&ent->bean->custom_config); - } else if (key == ui->custom_outbound_edit) { - copyBean(&ent->bean->custom_outbound); - } -} diff --git a/src/ui/profile/edit_anytls.cpp b/src/ui/profile/edit_anytls.cpp index 97e5150..eb14c98 100644 --- a/src/ui/profile/edit_anytls.cpp +++ b/src/ui/profile/edit_anytls.cpp @@ -1,7 +1,5 @@ #include "include/ui/profile/edit_anytls.h" -#include "include/configs/proxy/AnyTLSBean.hpp" - #include #include #include "include/global/GuiUtils.hpp" @@ -19,21 +17,21 @@ EditAnyTLS::~EditAnyTLS() { void EditAnyTLS::onStart(std::shared_ptr _ent) { this->ent = _ent; - auto bean = this->ent->AnyTLS(); + auto outbound = this->ent->AnyTLS(); - ui->password->setText(bean->password); - ui->interval->setText(bean->idle_session_check_interval); - ui->timeout->setText(bean->idle_session_timeout); - ui->min->setText(Int2String(bean->min_idle_session)); + ui->password->setText(outbound->password); + ui->interval->setText(outbound->idle_session_check_interval); + ui->timeout->setText(outbound->idle_session_timeout); + ui->min->setText(Int2String(outbound->min_idle_session)); } bool EditAnyTLS::onEnd() { - auto bean = this->ent->AnyTLS(); + auto outbound = this->ent->AnyTLS(); - bean->password = ui->password->text(); - bean->idle_session_check_interval = ui->interval->text(); - bean->idle_session_timeout = ui->timeout->text(); - bean->min_idle_session = ui->min->text().toInt(); + outbound->password = ui->password->text(); + outbound->idle_session_check_interval = ui->interval->text(); + outbound->idle_session_timeout = ui->timeout->text(); + outbound->min_idle_session = ui->min->text().toInt(); return true; } diff --git a/src/ui/profile/edit_chain.cpp b/src/ui/profile/edit_chain.cpp index f7342cb..69ae4ca 100644 --- a/src/ui/profile/edit_chain.cpp +++ b/src/ui/profile/edit_chain.cpp @@ -4,7 +4,6 @@ #include "include/ui/profile/ProxyItem.h" #include "include/dataStore/Database.hpp" -#include "include/configs/proxy/ChainBean.hpp" EditChain::EditChain(QWidget *parent) : QWidget(parent), ui(new Ui::EditChain) { ui->setupUi(this); @@ -16,9 +15,9 @@ EditChain::~EditChain() { void EditChain::onStart(std::shared_ptr _ent) { this->ent = _ent; - auto bean = this->ent->Chain(); + auto outbound = this->ent->Chain(); - for (auto id: bean->list) { + for (auto id: outbound->list) { AddProfileToListIfExist(id); } } @@ -29,13 +28,13 @@ bool EditChain::onEnd() { return false; } - auto bean = this->ent->Chain(); + auto outbound = this->ent->Chain(); QList idList; for (int i = 0; i < ui->listWidget->count(); i++) { idList << ui->listWidget->item(i)->data(114514).toInt(); } - bean->list = idList; + outbound->list = idList; return true; } diff --git a/src/ui/profile/edit_custom.cpp b/src/ui/profile/edit_custom.cpp index 912af93..b3de4d0 100644 --- a/src/ui/profile/edit_custom.cpp +++ b/src/ui/profile/edit_custom.cpp @@ -23,7 +23,7 @@ EditCustom::~EditCustom() { void EditCustom::onStart(std::shared_ptr _ent) { this->ent = _ent; - auto bean = this->ent->Custom(); + auto outbound = this->ent->Custom(); if (preset_core == "outbound") { preset_command = preset_config = ""; @@ -42,7 +42,7 @@ void EditCustom::onStart(std::shared_ptr _ent) { } // load core ui - ui->config_simple->setPlainText(bean->config); + ui->config_simple->setPlainText(outbound->config); // custom internal if (preset_core == "outbound") { @@ -60,10 +60,10 @@ bool EditCustom::onEnd() { return false; } - auto bean = this->ent->Custom(); + auto outbound = this->ent->Custom(); - bean->config = ui->config_simple->toPlainText(); - bean->type = preset_core; + outbound->config = ui->config_simple->toPlainText(); + outbound->type = preset_core; return true; } diff --git a/src/ui/profile/edit_extra_core.cpp b/src/ui/profile/edit_extra_core.cpp index 031e252..4cb4956 100644 --- a/src/ui/profile/edit_extra_core.cpp +++ b/src/ui/profile/edit_extra_core.cpp @@ -18,14 +18,14 @@ EditExtraCore::~EditExtraCore() { void EditExtraCore::onStart(std::shared_ptr _ent) { this->ent = _ent; - auto bean = ent->ExtraCore(); - ui->socks_address->setText(bean->socksAddress); + auto outbound = ent->ExtraCore(); + ui->socks_address->setText(outbound->socksAddress); ui->socks_port->setValidator(new QIntValidator(1, 65534)); - ui->socks_port->setText(Int2String(bean->socksPort)); - ui->config->setPlainText(bean->extraCoreConf); - ui->args->setText(bean->extraCoreArgs); + ui->socks_port->setText(Int2String(outbound->socksPort)); + ui->config->setPlainText(outbound->extraCoreConf); + ui->args->setText(outbound->extraCoreArgs); ui->path_combo->addItems(Configs::profileManager->GetExtraCorePaths()); - ui->path_combo->setCurrentText(bean->extraCorePath); + ui->path_combo->setCurrentText(outbound->extraCorePath); connect(ui->path_button, &QPushButton::pressed, this, [=,this] { @@ -46,12 +46,12 @@ void EditExtraCore::onStart(std::shared_ptr _ent) { } bool EditExtraCore::onEnd() { - auto bean = ent->ExtraCore(); - bean->socksAddress = ui->socks_address->text(); - bean->socksPort = ui->socks_port->text().toInt(); - bean->extraCoreConf = ui->config->toPlainText(); - bean->extraCorePath = ui->path_combo->currentText(); - bean->extraCoreArgs = ui->args->text(); + auto outbound = ent->ExtraCore(); + outbound->socksAddress = ui->socks_address->text(); + outbound->socksPort = ui->socks_port->text().toInt(); + outbound->extraCoreConf = ui->config->toPlainText(); + outbound->extraCorePath = ui->path_combo->currentText(); + outbound->extraCoreArgs = ui->args->text(); return true; } diff --git a/src/ui/profile/edit_http.cpp b/src/ui/profile/edit_http.cpp new file mode 100644 index 0000000..bcdb419 --- /dev/null +++ b/src/ui/profile/edit_http.cpp @@ -0,0 +1,25 @@ +#include "include/ui/profile/edit_http.h" + +EditHttp::EditHttp(QWidget *parent) : QWidget(parent), + ui(new Ui::EditHttp) { + ui->setupUi(this); +} + +EditHttp::~EditHttp() { + delete ui; +} + +void EditHttp::onStart(std::shared_ptr _ent) { + this->ent = _ent; + auto outbound = this->ent->Http(); + + ui->username->setText(outbound->username); + ui->password->setText(outbound->password); +} + +bool EditHttp::onEnd() { + auto outbound = this->ent->Http(); + outbound->username = ui->username->text(); + outbound->password = ui->password->text(); + return true; +} diff --git a/src/ui/profile/edit_hysteria.cpp b/src/ui/profile/edit_hysteria.cpp new file mode 100644 index 0000000..1619a94 --- /dev/null +++ b/src/ui/profile/edit_hysteria.cpp @@ -0,0 +1,41 @@ +#include "include/ui/profile/edit_hysteria.h" + +EditHysteria::EditHysteria(QWidget *parent) + : QWidget(parent), + ui(new Ui::EditHysteria) { + ui->setupUi(this); +} + +EditHysteria::~EditHysteria() { + delete ui; +} + +void EditHysteria::onStart(std::shared_ptr _ent) { + this->ent = _ent; + auto outbound = _ent->Hysteria(); + + ui->server_ports->setText(outbound->server_ports.join(",")); + ui->hop_interval->setText(outbound->hop_interval); + ui->up_mbps->setText(Int2String(outbound->up_mbps)); + ui->down_mbps->setText(Int2String(outbound->down_mbps)); + ui->obfs->setText(outbound->obfs); + ui->auth->setText(outbound->auth); + ui->auth_str->setText(outbound->auth_str); + ui->recv_window->setText(Int2String(outbound->recv_window)); + ui->recv_window_conn->setText(Int2String(outbound->recv_window_conn)); +} + +bool EditHysteria::onEnd() { + auto outbound = ent->Hysteria(); + outbound->server_ports = SplitAndTrim(ui->server_ports->text(), ","); + outbound->hop_interval = ui->hop_interval->text(); + outbound->up_mbps = ui->up_mbps->text().toInt(); + outbound->down_mbps = ui->down_mbps->text().toInt(); + outbound->obfs = ui->obfs->text(); + outbound->auth = ui->auth->text(); + outbound->auth_str = ui->auth_str->text(); + outbound->recv_window = ui->recv_window->text().toInt(); + outbound->recv_window_conn = ui->recv_window_conn->text().toInt(); + return true; +} + diff --git a/src/ui/profile/edit_hysteria2.cpp b/src/ui/profile/edit_hysteria2.cpp new file mode 100644 index 0000000..ad7290a --- /dev/null +++ b/src/ui/profile/edit_hysteria2.cpp @@ -0,0 +1,35 @@ +#include "include/ui/profile/edit_hysteria2.h" + +EditHysteria2::EditHysteria2(QWidget *parent) + : QWidget(parent), + ui(new Ui::EditHysteria2) { + ui->setupUi(this); +} + +EditHysteria2::~EditHysteria2() { + delete ui; +} + +void EditHysteria2::onStart(std::shared_ptr _ent) { + this->ent = _ent; + auto outbound = this->ent->Hysteria2(); + + ui->server_ports->setText(outbound->server_ports.join(",")); + ui->hop_interval->setText(outbound->hop_interval); + ui->up_mbps->setText(Int2String(outbound->up_mbps)); + ui->down_mbps->setText(Int2String(outbound->down_mbps)); + ui->obfs_password->setText(outbound->obfsPassword); + ui->password->setText(outbound->password); +} + +bool EditHysteria2::onEnd() { + auto outbound = this->ent->Hysteria2(); + + outbound->server_ports = SplitAndTrim(ui->server_ports->text(), ","); + outbound->hop_interval = ui->hop_interval->text(); + outbound->up_mbps = ui->up_mbps->text().toInt(); + outbound->down_mbps = ui->down_mbps->text().toInt(); + outbound->obfsPassword = ui->obfs_password->text(); + outbound->password = ui->password->text(); + return true; +} \ No newline at end of file diff --git a/src/ui/profile/edit_quic.cpp b/src/ui/profile/edit_quic.cpp deleted file mode 100644 index 049aecd..0000000 --- a/src/ui/profile/edit_quic.cpp +++ /dev/null @@ -1,154 +0,0 @@ -#include "include/ui/profile/edit_quic.h" - -#include "include/configs/proxy/QUICBean.hpp" - -#include -#include - -EditQUIC::EditQUIC(QWidget *parent) : QWidget(parent), ui(new Ui::EditQUIC) { - ui->setupUi(this); - connect(ui->uuidgen, &QPushButton::clicked, this, [=,this] { ui->uuid->setText(QUuid::createUuid().toString().remove("{").remove("}")); }); -} - -EditQUIC::~EditQUIC() { - delete ui; -} - -void EditQUIC::onStart(std::shared_ptr _ent) { - // this->ent = _ent; - // auto bean = this->ent->QUICBean(); - // - // P_LOAD_INT(uploadMbps); - // P_LOAD_INT(downloadMbps); - // P_LOAD_BOOL(disableMtuDiscovery) - // P_LOAD_STRING(obfsPassword); - // P_LOAD_STRING(authPayload); - // P_LOAD_INT(streamReceiveWindow); - // P_LOAD_INT(connectionReceiveWindow); - // - // P_LOAD_COMBO_INT(authPayloadType); - // P_LOAD_STRING(uuid); - // P_LOAD_STRING(password); - // - // P_LOAD_COMBO_STRING(congestionControl); - // P_LOAD_COMBO_STRING(udpRelayMode); - // P_LOAD_BOOL(zeroRttHandshake); - // P_LOAD_STRING(heartbeat); - // P_LOAD_BOOL(uos); - // - // // TLS - // P_LOAD_STRING(sni); - // P_LOAD_STRING(alpn); - // P_C_LOAD_STRING(caText); - // P_LOAD_BOOL(allowInsecure); - // P_LOAD_BOOL(disableSni); - // - // if (bean->proxy_type == Configs::QUICBean::proxy_Hysteria || bean->proxy_type == Configs::QUICBean::proxy_Hysteria2) { - // ui->uuid->hide(); - // ui->uuid_l->hide(); - // ui->uuidgen->hide(); - // ui->congestionControl->hide(); - // ui->congestionControl_l->hide(); - // ui->udpRelayMode->hide(); - // ui->udpRelayMode_l->hide(); - // ui->zeroRttHandshake->hide(); - // ui->heartbeat->hide(); - // ui->heartbeat_l->hide(); - // ui->uos->hide(); - // ui->port_range->setText(bean->serverPorts.join(",")); - // ui->hop_interval->setText(bean->hop_interval); - // - // if (bean->proxy_type == Configs::QUICBean::proxy_Hysteria) { // hy1 - // ui->password->hide(); - // ui->password_l->hide(); - // } else { // hy2 - // ui->authPayload->hide(); - // ui->authPayload_l->hide(); - // ui->authPayloadType->hide(); - // ui->authPayloadType_l->hide(); - // ui->alpn->hide(); - // ui->alpn_l->hide(); - // ui->TLS->removeItem(ui->alpn_sp); - // ui->disableMtuDiscovery->hide(); - // ui->connectionReceiveWindow->hide(); - // ui->connectionReceiveWindow_l->hide(); - // ui->streamReceiveWindow->hide(); - // ui->streamReceiveWindow_l->hide(); - // } - // } else if (bean->proxy_type == Configs::QUICBean::proxy_TUIC) { - // ui->uploadMbps->hide(); - // ui->uploadMbps_l->hide(); - // ui->downloadMbps->hide(); - // ui->downloadMbps_l->hide(); - // ui->disableMtuDiscovery->hide(); - // ui->obfsPassword->hide(); - // ui->obfsPassword_l->hide(); - // ui->authPayload->hide(); - // ui->authPayload_l->hide(); - // ui->authPayloadType->hide(); - // ui->authPayloadType_l->hide(); - // ui->streamReceiveWindow->hide(); - // ui->streamReceiveWindow_l->hide(); - // ui->connectionReceiveWindow->hide(); - // ui->connectionReceiveWindow_l->hide(); - // ui->port_range->hide(); - // ui->port_range_l->hide(); - // ui->hop_interval->hide(); - // ui->hop_interval_l->hide(); - // } -} - -bool EditQUIC::onEnd() { - // auto bean = this->ent->QUICBean(); - // - // // Hysteria - // P_SAVE_INT(uploadMbps); - // P_SAVE_INT(downloadMbps); - // P_SAVE_BOOL(disableMtuDiscovery) - // P_SAVE_STRING(obfsPassword); - // P_SAVE_COMBO_INT(authPayloadType); - // P_SAVE_STRING(authPayload); - // P_SAVE_INT(streamReceiveWindow); - // P_SAVE_INT(connectionReceiveWindow); - // auto rawPorts = ui->port_range->text(); - // QStringList serverPorts; - // for (const auto& portRange : rawPorts.split(',')) - // { - // if (portRange.trimmed().isEmpty()) continue; - // serverPorts.append(portRange.trimmed()); - // } - // bean->serverPorts = serverPorts; - // bean->hop_interval = ui->hop_interval->text(); - // - // // TUIC - // P_SAVE_STRING(uuid); - // P_SAVE_STRING(password); - // P_SAVE_COMBO_STRING(congestionControl); - // P_SAVE_COMBO_STRING(udpRelayMode); - // P_SAVE_BOOL(zeroRttHandshake); - // P_SAVE_STRING(heartbeat); - // P_SAVE_BOOL(uos); - // - // // TLS - // P_SAVE_STRING(sni); - // P_SAVE_STRING(alpn); - // P_SAVE_BOOL(allowInsecure); - // P_C_SAVE_STRING(caText); - // P_SAVE_BOOL(disableSni); - return true; -} - -QList> EditQUIC::get_editor_cached() { - return { - {ui->certificate, CACHE.caText}, - }; -} - -void EditQUIC::on_certificate_clicked() { - bool ok; - auto txt = QInputDialog::getMultiLineText(this, tr("Certificate"), "", CACHE.caText, &ok); - if (ok) { - CACHE.caText = txt; - editor_cache_updated(); - } -} diff --git a/src/ui/profile/edit_shadowsocks.cpp b/src/ui/profile/edit_shadowsocks.cpp index ea2e87d..c687351 100644 --- a/src/ui/profile/edit_shadowsocks.cpp +++ b/src/ui/profile/edit_shadowsocks.cpp @@ -14,27 +14,27 @@ EditShadowSocks::~EditShadowSocks() { void EditShadowSocks::onStart(std::shared_ptr _ent) { this->ent = _ent; - auto bean = this->ent->ShadowSocks(); + auto outbound = this->ent->ShadowSocks(); - ui->method->setCurrentText(bean->method); - ui->uot->setCurrentIndex(bean->uot); - ui->password->setText(bean->password); - auto ssPlugin = bean->plugin.split(";"); + ui->method->setCurrentText(outbound->method); + ui->uot->setCurrentIndex(outbound->uot); + ui->password->setText(outbound->password); + auto ssPlugin = outbound->plugin.split(";"); if (!ssPlugin.empty()) { ui->plugin->setCurrentText(ssPlugin[0]); - ui->plugin_opts->setText(SubStrAfter(bean->plugin, ";")); + ui->plugin_opts->setText(SubStrAfter(outbound->plugin, ";")); } } bool EditShadowSocks::onEnd() { - auto bean = this->ent->ShadowSocks(); + auto outbound = this->ent->ShadowSocks(); - bean->method = ui->method->currentText(); - bean->password = ui->password->text(); - bean->uot = ui->uot->currentIndex(); - bean->plugin = ui->plugin->currentText(); - if (!bean->plugin.isEmpty()) { - bean->plugin += ";" + ui->plugin_opts->text(); + outbound->method = ui->method->currentText(); + outbound->password = ui->password->text(); + outbound->uot = ui->uot->currentIndex(); + outbound->plugin = ui->plugin->currentText(); + if (!outbound->plugin.isEmpty()) { + outbound->plugin += ";" + ui->plugin_opts->text(); } return true; diff --git a/src/ui/profile/edit_socks.cpp b/src/ui/profile/edit_socks.cpp new file mode 100644 index 0000000..d3aa4f3 --- /dev/null +++ b/src/ui/profile/edit_socks.cpp @@ -0,0 +1,30 @@ +#include "include/ui/profile/edit_socks.h" + +EditSocks::EditSocks(QWidget *parent) + : QWidget(parent), + ui(new Ui::EditSocks) { + + ui->setupUi(this); +} + +EditSocks::~EditSocks() { + delete ui; +} + +void EditSocks::onStart(std::shared_ptr _ent) { + this->ent = _ent; + auto outbound = this->ent->Socks(); + + ui->version->setCurrentText(Int2String(outbound->version)); + ui->username->setText(outbound->username); + ui->password->setText(outbound->password); +} + +bool EditSocks::onEnd() { + auto outbound = this->ent->Socks(); + + outbound->version = ui->version->currentText().toInt(); + outbound->username = ui->username->text(); + outbound->password = ui->password->text(); + return true; +} \ No newline at end of file diff --git a/src/ui/profile/edit_socks_http.cpp b/src/ui/profile/edit_socks_http.cpp deleted file mode 100644 index 3d0bbe3..0000000 --- a/src/ui/profile/edit_socks_http.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "include/ui/profile/edit_socks_http.h" - -EditSocksHttp::EditSocksHttp(QWidget *parent) : QWidget(parent), - ui(new Ui::EditSocksHttp) { - ui->setupUi(this); -} - -EditSocksHttp::~EditSocksHttp() { - delete ui; -} - -void EditSocksHttp::onStart(std::shared_ptr _ent) { - this->ent = _ent; - // auto bean = this->ent->SocksHTTPBean(); - // - // if (bean->socks_http_type == Configs::SocksHttpBean::type_Socks4) { - // ui->version->setCurrentIndex(1); - // } else { - // ui->version->setCurrentIndex(0); - // } - // if (bean->socks_http_type == Configs::SocksHttpBean::type_HTTP) { - // ui->version->setVisible(false); - // ui->version_l->setVisible(false); - // } - // - // ui->username->setText(bean->username); - // ui->password->setText(bean->password); -} - -bool EditSocksHttp::onEnd() { - // auto bean = this->ent->SocksHTTPBean(); - // - // if (ui->version->isVisible()) { - // if (ui->version->currentIndex() == 1) { - // bean->socks_http_type = Configs::SocksHttpBean::type_Socks4; - // } else { - // bean->socks_http_type = Configs::SocksHttpBean::type_Socks5; - // } - // } - // - // bean->username = ui->username->text(); - // bean->password = ui->password->text(); - - return true; -} diff --git a/src/ui/profile/edit_ssh.cpp b/src/ui/profile/edit_ssh.cpp index 515932b..227a1ad 100644 --- a/src/ui/profile/edit_ssh.cpp +++ b/src/ui/profile/edit_ssh.cpp @@ -1,8 +1,6 @@ #include "include/ui/profile/edit_ssh.h" #include -#include "include/configs/proxy/SSHBean.h" - EditSSH::EditSSH(QWidget *parent) : QWidget(parent), ui(new Ui::EditSSH) { ui->setupUi(this); } @@ -13,16 +11,16 @@ EditSSH::~EditSSH() { void EditSSH::onStart(std::shared_ptr _ent) { this->ent = _ent; - auto bean = this->ent->SSH(); + auto outbound = this->ent->SSH(); - ui->user->setText(bean->user); - ui->password->setText(bean->password); - ui->private_key->setText(bean->private_key); - ui->private_key_path->setText(bean->private_key_path); - ui->private_key_pass->setText(bean->private_key_passphrase); - ui->host_key->setText(bean->host_key.join(",")); - ui->host_key_algs->setText(bean->host_key_algorithms.join(",")); - ui->client_version->setText(bean->client_version); + ui->user->setText(outbound->user); + ui->password->setText(outbound->password); + ui->private_key->setText(outbound->private_key); + ui->private_key_path->setText(outbound->private_key_path); + ui->private_key_pass->setText(outbound->private_key_passphrase); + ui->host_key->setText(outbound->host_key.join(",")); + ui->host_key_algs->setText(outbound->host_key_algorithms.join(",")); + ui->client_version->setText(outbound->client_version); connect(ui->choose_pk, &QPushButton::clicked, this, [=,this] { auto fn = QFileDialog::getOpenFileName(this, QObject::tr("Select"), QDir::currentPath(), @@ -34,18 +32,18 @@ void EditSSH::onStart(std::shared_ptr _ent) { } bool EditSSH::onEnd() { - auto bean = this->ent->SSH(); + auto outbound = this->ent->SSH(); - bean->user = ui->user->text(); - bean->password = ui->password->text(); - bean->private_key = ui->private_key->toPlainText(); - bean->private_key_path = ui->private_key_path->text(); - bean->private_key_passphrase = ui->private_key_pass->text(); - if (!ui->host_key->text().trimmed().isEmpty()) bean->host_key = ui->host_key->text().split(","); - else bean->host_key = {}; - if (!ui->host_key_algs->text().trimmed().isEmpty()) bean->host_key_algorithms = ui->host_key_algs->text().split(","); - else bean->host_key_algorithms = {}; - bean->client_version = ui->client_version->text(); + outbound->user = ui->user->text(); + outbound->password = ui->password->text(); + outbound->private_key = ui->private_key->toPlainText(); + outbound->private_key_path = ui->private_key_path->text(); + outbound->private_key_passphrase = ui->private_key_pass->text(); + if (!ui->host_key->text().trimmed().isEmpty()) outbound->host_key = ui->host_key->text().split(","); + else outbound->host_key = {}; + if (!ui->host_key_algs->text().trimmed().isEmpty()) outbound->host_key_algorithms = ui->host_key_algs->text().split(","); + else outbound->host_key_algorithms = {}; + outbound->client_version = ui->client_version->text(); return true; } \ No newline at end of file diff --git a/src/ui/profile/edit_tailscale.cpp b/src/ui/profile/edit_tailscale.cpp index 6c289ba..66a36b6 100644 --- a/src/ui/profile/edit_tailscale.cpp +++ b/src/ui/profile/edit_tailscale.cpp @@ -12,35 +12,35 @@ EditTailScale::~EditTailScale() { void EditTailScale::onStart(std::shared_ptr _ent) { this->ent = _ent; - auto bean = this->ent->Tailscale(); + auto outbound = this->ent->Tailscale(); - ui->state_dir->setText(bean->state_directory); - ui->auth_key->setText(bean->auth_key); - ui->control_plane->setText(bean->control_url); - ui->ephemeral->setChecked(bean->ephemeral); - ui->hostname->setText(bean->hostname); - ui->accept_route->setChecked(bean->accept_routes); - ui->exit_node->setText(bean->exit_node); - ui->exit_node_lan_access->setChecked(bean->exit_node_allow_lan_access); - ui->advertise_routes->setText(bean->advertise_routes.join(",")); - ui->advertise_exit_node->setChecked(bean->advertise_exit_node); - ui->global_dns->setChecked(bean->globalDNS); + ui->state_dir->setText(outbound->state_directory); + ui->auth_key->setText(outbound->auth_key); + ui->control_plane->setText(outbound->control_url); + ui->ephemeral->setChecked(outbound->ephemeral); + ui->hostname->setText(outbound->hostname); + ui->accept_route->setChecked(outbound->accept_routes); + ui->exit_node->setText(outbound->exit_node); + ui->exit_node_lan_access->setChecked(outbound->exit_node_allow_lan_access); + ui->advertise_routes->setText(outbound->advertise_routes.join(",")); + ui->advertise_exit_node->setChecked(outbound->advertise_exit_node); + ui->global_dns->setChecked(outbound->globalDNS); } bool EditTailScale::onEnd() { - auto bean = this->ent->Tailscale(); + auto outbound = this->ent->Tailscale(); - bean->state_directory = ui->state_dir->text(); - bean->auth_key = ui->auth_key->text(); - bean->control_url = ui->control_plane->text(); - bean->ephemeral = ui->ephemeral->isChecked(); - bean->hostname = ui->hostname->text(); - bean->accept_routes = ui->accept_route->isChecked(); - bean->exit_node = ui->exit_node->text(); - bean->exit_node_allow_lan_access = ui->exit_node_lan_access->isChecked(); - bean->advertise_routes = ui->advertise_routes->text().replace(" ", "").split(","); - bean->advertise_exit_node = ui->advertise_exit_node->isChecked(); - bean->globalDNS = ui->global_dns->isChecked(); + outbound->state_directory = ui->state_dir->text(); + outbound->auth_key = ui->auth_key->text(); + outbound->control_url = ui->control_plane->text(); + outbound->ephemeral = ui->ephemeral->isChecked(); + outbound->hostname = ui->hostname->text(); + outbound->accept_routes = ui->accept_route->isChecked(); + outbound->exit_node = ui->exit_node->text(); + outbound->exit_node_allow_lan_access = ui->exit_node_lan_access->isChecked(); + outbound->advertise_routes = ui->advertise_routes->text().replace(" ", "").split(","); + outbound->advertise_exit_node = ui->advertise_exit_node->isChecked(); + outbound->globalDNS = ui->global_dns->isChecked(); return true; } diff --git a/src/ui/profile/edit_trojan.cpp b/src/ui/profile/edit_trojan.cpp new file mode 100644 index 0000000..632b266 --- /dev/null +++ b/src/ui/profile/edit_trojan.cpp @@ -0,0 +1,24 @@ +#include "include/ui/profile/edit_trojan.h" + +EditTrojan::EditTrojan(QWidget *parent) + : QWidget(parent), + ui(new Ui::EditTrojan) { +} + +EditTrojan::~EditTrojan() { + delete ui; +} + +void EditTrojan::onStart(std::shared_ptr _ent) { + this->ent = _ent; + auto outbound = ent->Trojan(); + + ui->password->setText(outbound->password); +} + +bool EditTrojan::onEnd() { + auto outbound = ent->Trojan(); + + outbound->password = ui->password->text(); + return true; +} \ No newline at end of file diff --git a/src/ui/profile/edit_trojan_vless.cpp b/src/ui/profile/edit_trojan_vless.cpp deleted file mode 100644 index 3c9bf1a..0000000 --- a/src/ui/profile/edit_trojan_vless.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "include/ui/profile/edit_trojan_vless.h" - -#include "include/configs/proxy/TrojanVLESSBean.hpp" -#include "include/configs/proxy/Preset.hpp" - -EditTrojanVLESS::EditTrojanVLESS(QWidget *parent) : QWidget(parent), ui(new Ui::EditTrojanVLESS) { - ui->setupUi(this); - flow_ = ui->flow; -} - -EditTrojanVLESS::~EditTrojanVLESS() { - delete ui; -} - -void EditTrojanVLESS::onStart(std::shared_ptr _ent) { - this->ent = _ent; - // auto bean = this->ent->TrojanVLESSBean(); - // if (bean->proxy_type == Configs::TrojanVLESSBean::proxy_VLESS) { - // ui->label->setText("UUID"); - // } - // if (bean->proxy_type != Configs::TrojanVLESSBean::proxy_VLESS) { - // ui->flow->hide(); - // ui->flow_l->hide(); - // } - // ui->password->setText(bean->password); - // ui->flow->addItems(Preset::SingBox::Flows ); - // ui->flow->setCurrentText(bean->flow); -} - -bool EditTrojanVLESS::onEnd() { - // auto bean = this->ent->TrojanVLESSBean(); - // bean->password = ui->password->text(); - // bean->flow = ui->flow->currentText(); - return true; -} diff --git a/src/ui/profile/edit_tuic.cpp b/src/ui/profile/edit_tuic.cpp new file mode 100644 index 0000000..44a097f --- /dev/null +++ b/src/ui/profile/edit_tuic.cpp @@ -0,0 +1,38 @@ +#include "include/ui/profile/edit_tuic.h" + +EditTuic::EditTuic(QWidget *parent) + : QWidget(parent), + ui(new Ui::EditTuic) { + + ui->setupUi(this); +} + +EditTuic::~EditTuic() { + delete ui; +} + +void EditTuic::onStart(std::shared_ptr _ent) { + this->ent = _ent; + auto outbound = ent->TUIC(); + + ui->uuid->setText(outbound->uuid); + ui->password->setText(outbound->password); + ui->congestion_control->setCurrentText(outbound->congestion_control.isEmpty() ? "bbr" : outbound->congestion_control); + ui->udp_relay_mode->setCurrentText(outbound->udp_relay_mode.isEmpty() ? "native" : outbound->udp_relay_mode); + ui->udp_over_stream->setChecked(outbound->udp_over_stream); + ui->zero_rtt->setChecked(outbound->zero_rtt_handshake); + ui->heartbeat->setText(outbound->heartbeat); +} + +bool EditTuic::onEnd() { + auto outbound = ent->TUIC(); + + outbound->uuid = ui->uuid->text(); + outbound->password = ui->password->text(); + outbound->congestion_control = ui->congestion_control->currentText(); + outbound->udp_relay_mode = ui->udp_relay_mode->currentText(); + outbound->udp_over_stream = ui->udp_over_stream->isChecked(); + outbound->zero_rtt_handshake = ui->zero_rtt->isChecked(); + outbound->heartbeat = ui->heartbeat->text(); + return true; +} \ No newline at end of file diff --git a/src/ui/profile/edit_vless.cpp b/src/ui/profile/edit_vless.cpp new file mode 100644 index 0000000..f5f2683 --- /dev/null +++ b/src/ui/profile/edit_vless.cpp @@ -0,0 +1,35 @@ +#include "include/ui/profile/edit_vless.h" + +EditVless::EditVless(QWidget *parent) + : QWidget(parent), + ui(new Ui::EditVless) { + ui->setupUi(this); + + _flow = ui->flow; + QStringList flows = {""}; + flows << Configs::vlessFlows; + ui->flow->addItems(flows); + ui->packet_encoding->addItems(Configs::vPacketEncoding); +} + +EditVless::~EditVless() { + delete ui; +} + +void EditVless::onStart(std::shared_ptr _ent) { + this->ent = _ent; + auto outbound = this->ent->VLESS(); + + ui->uuid->setText(outbound->uuid); + ui->flow->setCurrentText(outbound->flow); + ui->packet_encoding->setCurrentText(outbound->packet_encoding); +} + +bool EditVless::onEnd() { + auto outbound = this->ent->VLESS(); + + outbound->uuid = ui->uuid->text(); + outbound->flow = ui->flow->currentText(); + outbound->packet_encoding = ui->packet_encoding->currentText(); + return true; +} \ No newline at end of file diff --git a/src/ui/profile/edit_vmess.cpp b/src/ui/profile/edit_vmess.cpp index 445d6e8..f6fb63b 100644 --- a/src/ui/profile/edit_vmess.cpp +++ b/src/ui/profile/edit_vmess.cpp @@ -1,12 +1,11 @@ #include "include/ui/profile/edit_vmess.h" -#include "include/configs/proxy/VMessBean.hpp" - #include EditVMess::EditVMess(QWidget *parent) : QWidget(parent), ui(new Ui::EditVMess) { ui->setupUi(this); connect(ui->uuidgen, &QPushButton::clicked, this, [=,this] { ui->uuid->setText(QUuid::createUuid().toString().remove("{").remove("}")); }); + ui->packet_encoding->addItems(Configs::vPacketEncoding); } EditVMess::~EditVMess() { @@ -15,19 +14,21 @@ EditVMess::~EditVMess() { void EditVMess::onStart(std::shared_ptr _ent) { this->ent = _ent; - auto bean = this->ent->VMess(); + auto outbound = this->ent->VMess(); - ui->uuid->setText(bean->uuid); - ui->aid->setText(Int2String(bean->alter_id)); - ui->security->setCurrentText(bean->security); + ui->uuid->setText(outbound->uuid); + ui->aid->setText(Int2String(outbound->alter_id)); + ui->packet_encoding->setCurrentText(outbound->packet_encoding); + ui->security->setCurrentText(outbound->security); } bool EditVMess::onEnd() { - auto bean = this->ent->VMess(); + auto outbound = this->ent->VMess(); - bean->uuid = ui->uuid->text(); - bean->alter_id = ui->aid->text().toInt(); - bean->security = ui->security->currentText(); + outbound->uuid = ui->uuid->text(); + outbound->alter_id = ui->aid->text().toInt(); + outbound->packet_encoding = ui->packet_encoding->currentText(); + outbound->security = ui->security->currentText(); return true; } diff --git a/src/ui/profile/edit_wireguard.cpp b/src/ui/profile/edit_wireguard.cpp index d0ceb94..5e2462f 100644 --- a/src/ui/profile/edit_wireguard.cpp +++ b/src/ui/profile/edit_wireguard.cpp @@ -10,63 +10,63 @@ EditWireguard::~EditWireguard() { void EditWireguard::onStart(std::shared_ptr _ent) { this->ent = _ent; - auto bean = this->ent->Wireguard(); + auto outbound = this->ent->Wireguard(); #ifndef Q_OS_LINUX adjustSize(); #endif - ui->private_key->setText(bean->private_key); - ui->public_key->setText(bean->peer->public_key); - ui->preshared_key->setText(bean->peer->pre_shared_key); - // auto reservedStr = bean->peer->reserved; + ui->private_key->setText(outbound->private_key); + ui->public_key->setText(outbound->peer->public_key); + ui->preshared_key->setText(outbound->peer->pre_shared_key); + // auto reservedStr = outbound->peer->reserved; // ui->reserved->setText(reservedStr); - ui->persistent_keepalive->setText(Int2String(bean->peer->persistent_keepalive)); - ui->mtu->setText(Int2String(bean->mtu)); - ui->sys_ifc->setChecked(bean->system); - ui->local_addr->setText(bean->address.join(",")); - ui->workers->setText(Int2String(bean->worker_count)); + ui->persistent_keepalive->setText(Int2String(outbound->peer->persistent_keepalive)); + ui->mtu->setText(Int2String(outbound->mtu)); + ui->sys_ifc->setChecked(outbound->system); + ui->local_addr->setText(outbound->address.join(",")); + ui->workers->setText(Int2String(outbound->worker_count)); - ui->enable_amnezia->setChecked(bean->enable_amnezia); - ui->junk_packet_count->setText(Int2String(bean->junk_packet_count)); - ui->junk_packet_min_size->setText(Int2String(bean->junk_packet_min_size)); - ui->junk_packet_max_size->setText(Int2String(bean->junk_packet_max_size)); - ui->init_packet_junk_size->setText(Int2String(bean->init_packet_junk_size)); - ui->response_packet_junk_size->setText(Int2String(bean->response_packet_junk_size)); - ui->init_packet_magic_header->setText(Int2String(bean->init_packet_magic_header)); - ui->response_packet_magic_header->setText(Int2String(bean->response_packet_magic_header)); - ui->underload_packet_magic_header->setText(Int2String(bean->underload_packet_magic_header)); - ui->transport_packet_magic_header->setText(Int2String(bean->transport_packet_magic_header)); + ui->enable_amnezia->setChecked(outbound->enable_amnezia); + ui->junk_packet_count->setText(Int2String(outbound->junk_packet_count)); + ui->junk_packet_min_size->setText(Int2String(outbound->junk_packet_min_size)); + ui->junk_packet_max_size->setText(Int2String(outbound->junk_packet_max_size)); + ui->init_packet_junk_size->setText(Int2String(outbound->init_packet_junk_size)); + ui->response_packet_junk_size->setText(Int2String(outbound->response_packet_junk_size)); + ui->init_packet_magic_header->setText(Int2String(outbound->init_packet_magic_header)); + ui->response_packet_magic_header->setText(Int2String(outbound->response_packet_magic_header)); + ui->underload_packet_magic_header->setText(Int2String(outbound->underload_packet_magic_header)); + ui->transport_packet_magic_header->setText(Int2String(outbound->transport_packet_magic_header)); } bool EditWireguard::onEnd() { - auto bean = this->ent->Wireguard(); + auto outbound = this->ent->Wireguard(); - bean->private_key = ui->private_key->text(); - bean->peer->public_key = ui->public_key->text(); - bean->peer->pre_shared_key = ui->preshared_key->text(); + outbound->private_key = ui->private_key->text(); + outbound->peer->public_key = ui->public_key->text(); + outbound->peer->pre_shared_key = ui->preshared_key->text(); auto rawReserved = ui->reserved->text(); - // bean->reserved = {}; + // outbound->reserved = {}; // for (const auto& item: rawReserved.split(",")) { // if (item.trimmed().isEmpty()) continue; - // bean->reserved += item.trimmed().toInt(); + // outbound->reserved += item.trimmed().toInt(); // } - bean->peer->persistent_keepalive = ui->persistent_keepalive->text().toInt(); - bean->mtu = ui->mtu->text().toInt(); - bean->system = ui->sys_ifc->isChecked(); - bean->address = ui->local_addr->text().replace(" ", "").split(","); - bean->worker_count = ui->workers->text().toInt(); + outbound->peer->persistent_keepalive = ui->persistent_keepalive->text().toInt(); + outbound->mtu = ui->mtu->text().toInt(); + outbound->system = ui->sys_ifc->isChecked(); + outbound->address = ui->local_addr->text().replace(" ", "").split(","); + outbound->worker_count = ui->workers->text().toInt(); - bean->enable_amnezia = ui->enable_amnezia->isChecked(); - bean->junk_packet_count = ui->junk_packet_count->text().toInt(); - bean->junk_packet_min_size = ui->junk_packet_min_size->text().toInt(); - bean->junk_packet_max_size = ui->junk_packet_max_size->text().toInt(); - bean->init_packet_junk_size = ui->init_packet_junk_size->text().toInt(); - bean->response_packet_junk_size = ui->response_packet_junk_size->text().toInt(); - bean->init_packet_magic_header = ui->init_packet_magic_header->text().toInt(); - bean->response_packet_magic_header = ui->response_packet_magic_header->text().toInt(); - bean->underload_packet_magic_header = ui->underload_packet_magic_header->text().toInt(); - bean->transport_packet_magic_header = ui->transport_packet_magic_header->text().toInt(); + outbound->enable_amnezia = ui->enable_amnezia->isChecked(); + outbound->junk_packet_count = ui->junk_packet_count->text().toInt(); + outbound->junk_packet_min_size = ui->junk_packet_min_size->text().toInt(); + outbound->junk_packet_max_size = ui->junk_packet_max_size->text().toInt(); + outbound->init_packet_junk_size = ui->init_packet_junk_size->text().toInt(); + outbound->response_packet_junk_size = ui->response_packet_junk_size->text().toInt(); + outbound->init_packet_magic_header = ui->init_packet_magic_header->text().toInt(); + outbound->response_packet_magic_header = ui->response_packet_magic_header->text().toInt(); + outbound->underload_packet_magic_header = ui->underload_packet_magic_header->text().toInt(); + outbound->transport_packet_magic_header = ui->transport_packet_magic_header->text().toInt(); return true; } \ No newline at end of file