### Configure Hysteria2 and TUIC Protocols Source: https://context7.com/matsuridayo/nekoray/llms.txt Shows the setup for QUIC-based protocols (Hysteria2 and TUIC) using the QUICBean class. Includes examples for parsing and generating share links. ```cpp #include "fmt/QUICBean.hpp" // Create Hysteria2 configuration NekoGui_fmt::QUICBean hy2Bean(NekoGui_fmt::QUICBean::proxy_Hysteria2); hy2Bean.name = "Hysteria2 Server"; hy2Bean.serverAddress = "hy2.example.com"; hy2Bean.serverPort = 443; hy2Bean.password = "auth_password"; hy2Bean.obfsPassword = "obfs_salamander_password"; hy2Bean.uploadMbps = 100; hy2Bean.downloadMbps = 500; hy2Bean.hopPort = "20000-40000"; hy2Bean.hopInterval = 10; // TLS settings hy2Bean.sni = "hy2.example.com"; hy2Bean.alpn = "h3"; hy2Bean.allowInsecure = false; // Create TUIC configuration NekoGui_fmt::QUICBean tuicBean(NekoGui_fmt::QUICBean::proxy_TUIC); tuicBean.name = "TUIC Server"; tuicBean.serverAddress = "tuic.example.com"; tuicBean.serverPort = 443; tuicBean.uuid = "a3482e88-686a-4a58-8126-99c9df64b7bf"; tuicBean.password = "tuic_password"; tuicBean.congestionControl = "bbr"; tuicBean.udpRelayMode = "native"; tuicBean.zeroRttHandshake = true; tuicBean.sni = "tuic.example.com"; // Parse Hysteria2 share link QString hy2Link = "hy2://password@server:443?sni=example.com&obfs-password=obfs#HY2"; if (hy2Bean.TryParseLink(hy2Link)) { qDebug() << "Server:" << hy2Bean.serverAddress; } // Generate share links QString hy2ShareLink = hy2Bean.ToShareLink(); QString tuicShareLink = tuicBean.ToShareLink(); ``` -------------------------------- ### Custom Core and External Process Management Source: https://context7.com/matsuridayo/nekoray/llms.txt Details on managing custom proxy configurations and external processes using `CustomBean` and `ExternalProcess`. This includes creating internal sing-box outbounds, defining external core configurations with commands and arguments, and manually starting and managing the lifecycle of external processes. Dependencies include 'fmt/CustomBean.hpp' and 'sys/ExternalProcess.hpp'. ```cpp #include "fmt/CustomBean.hpp" #include "sys/ExternalProcess.hpp" // Create custom internal sing-box outbound NekoGui_fmt::CustomBean customBean; customBean.name = "Custom SSH Tunnel"; customBean.core = "internal"; // Use internal sing-box core customBean.config_simple = R"({ "type": "ssh", "server": "ssh.example.com", "server_port": 22, "user": "username", "private_key_path": "/path/to/key" })"; // Create custom external core configuration NekoGui_fmt::CustomBean externalBean; externalBean.name = "Custom Naive"; externalBean.core = "naive"; // External core name externalBean.command = {"--config", "{config}"}; externalBean.config_suffix = "json"; externalBean.config_simple = R"({ "listen": "socks://127.0.0.1:{port}", "proxy": "https://user:pass@server:443" })"; externalBean.mapping_port = 0; // Auto-assign externalBean.socks_port = 0; // Auto-assign // Build external process auto extResult = externalBean.BuildExternal(10808, 10809, 0); if (!extResult.error.isEmpty()) { qDebug() << "Build error:" << extResult.error; return; } // Start external process manually auto process = std::make_shared(); process->tag = "naive-1"; process->program = extResult.program; process->arguments = extResult.arguments; process->env = extResult.env; process->managed = true; process->Start(); // Track running external processes NekoGui_sys::running_ext.push_back(process); // Kill process when done process->Kill(); ``` -------------------------------- ### gRPC Core Communication Source: https://context7.com/matsuridayo/nekoray/llms.txt Endpoints for controlling the nekobox_core backend, including starting proxies, querying traffic statistics, and running latency tests. ```APIDOC ## gRPC Core Communication ### Description Provides methods to interact with the core backend to manage proxy states and monitor performance. ### Method RPC (gRPC) ### Endpoint NekoGui_rpc::Client ### Request Body - **coreconfig** (string) - Required - JSON configuration for the proxy core - **statsoutbounds** (array) - Optional - List of outbounds to track ### Response #### Success Response (200) - **rpcOK** (boolean) - Indicates if the operation was successful - **error** (string) - Error message if operation failed ``` -------------------------------- ### Configure NekoRay DataStore Global Settings (C++) Source: https://context7.com/matsuridayo/nekoray/llms.txt This C++ code snippet demonstrates how to access and configure global settings using the NekoGui::DataStore class. It covers inbound proxy settings, latency test configurations, VPN/TUN mode parameters, multiplexing options, hotkey assignments, Clash API details, and extra core configurations. The settings are saved using the ds->Save() method. ```cpp #include "main/NekoGui_DataStore.hpp" // Access global data store NekoGui::DataStore* ds = NekoGui::dataStore; // Configure inbound proxy ds->inbound_address = "127.0.0.1"; ds->inbound_socks_port = 2080; // Mixed SOCKS/HTTP port ds->inbound_auth->username = "user"; ds->inbound_auth->password = "pass"; // Latency test settings ds->test_latency_url = "http://cp.cloudflare.com/"; ds->test_download_url = "http://cachefly.cachefly.net/10mb.test"; ds->test_download_timeout = 30; // seconds ds->test_concurrent = 5; // concurrent test count // VPN/TUN mode settings ds->vpn_internal_tun = true; ds->vpn_mtu = 9000; ds->vpn_ipv6 = false; ds->vpn_strict_route = false; ds->fake_dns = false; ds->vpn_rule_process = "chrome.exe\nfirefox.exe"; // Process rules ds->vpn_rule_cidr = "192.168.0.0/16"; // CIDR rules // Multiplexing settings ds->mux_protocol = "h2mux"; // or "smux", "yamux" ds->mux_concurrency = 8; ds->mux_default_on = false; ds->mux_padding = false; // Hotkey configuration ds->hotkey_mainwindow = "Ctrl+Shift+N"; ds->hotkey_group = "Ctrl+Shift+G"; ds->hotkey_route = "Ctrl+Shift+R"; ds->hotkey_system_proxy_menu = "Ctrl+Shift+P"; // Clash API settings ds->core_box_clash_api = 9090; // -9090 = disabled ds->core_box_clash_api_secret = "my_secret"; // Remember settings ds->remember_enable = true; ds->remember_id = lastConnectedProfileId; // Configure extra cores ds->extraCore->Set("naive", "/path/to/naive"); ds->extraCore->Set("hysteria2", "/path/to/hysteria2"); QString naivePath = ds->extraCore->Get("naive"); // Save settings ds->Save(); ``` -------------------------------- ### Configure Routing Rules and DNS Source: https://context7.com/matsuridayo/nekoray/llms.txt Demonstrates how to access the Routing class to define direct, proxy, and block rules for domains and IP addresses. It also covers DNS strategy configuration and sniffing modes. ```cpp #include "main/NekoGui_DataStore.hpp" NekoGui::Routing* routing = NekoGui::dataStore->routing.get(); routing->direct_domain = "geosite:cn\ngeosite:private"; routing->direct_ip = "geoip:cn\ngeoip:private\n10.0.0.0/8"; routing->proxy_domain = "geosite:google\ngeosite:github"; routing->block_domain = "geosite:category-ads-all"; routing->def_outbound = "proxy"; routing->remote_dns = "https://dns.google/dns-query"; routing->dns_routing = true; routing->domain_strategy = "AsIs"; routing->sniffing_mode = NekoGui::SniffingMode::FOR_ROUTING; QStringList presets = NekoGui::Routing::List(); NekoGui::Routing::SetToActive("Default"); ``` -------------------------------- ### Configure VLESS and Trojan Protocols Source: https://context7.com/matsuridayo/nekoray/llms.txt Demonstrates how to initialize and configure TrojanVLESSBean for VLESS (with Reality) and Trojan protocols. It also shows how to parse share links into bean objects. ```cpp #include "fmt/TrojanVLESSBean.hpp" // Create VLESS configuration with Reality NekoGui_fmt::TrojanVLESSBean vlessBean(NekoGui_fmt::TrojanVLESSBean::proxy_VLESS); vlessBean.name = "VLESS Reality Server"; vlessBean.serverAddress = "vless.example.com"; vlessBean.serverPort = 443; vlessBean.password = "a3482e88-686a-4a58-8126-99c9df64b7bf"; vlessBean.flow = "xtls-rprx-vision"; // Configure Reality settings vlessBean.stream->network = "tcp"; vlessBean.stream->security = "tls"; vlessBean.stream->reality_pbk = "public_key_base64"; vlessBean.stream->reality_sid = "short_id"; vlessBean.stream->reality_spx = "/"; vlessBean.stream->sni = "www.microsoft.com"; vlessBean.stream->utlsFingerprint = "chrome"; // Create Trojan configuration NekoGui_fmt::TrojanVLESSBean trojanBean(NekoGui_fmt::TrojanVLESSBean::proxy_Trojan); trojanBean.name = "Trojan Server"; trojanBean.serverAddress = "trojan.example.com"; trojanBean.serverPort = 443; trojanBean.password = "trojan_password"; trojanBean.stream->security = "tls"; trojanBean.stream->sni = "trojan.example.com"; trojanBean.stream->alpn = "h2,http/1.1"; // Parse VLESS share link QString vlessLink = "vless://uuid@server:443?security=reality&pbk=key&sid=id&fp=chrome&type=tcp&flow=xtls-rprx-vision#VLESS"; if (vlessBean.TryParseLink(vlessLink)) { qDebug() << "Flow:" << vlessBean.flow; qDebug() << "Reality PBK:" << vlessBean.stream->reality_pbk; } ``` -------------------------------- ### Configure Shadowsocks Protocol Bean in C++ Source: https://context7.com/matsuridayo/nekoray/llms.txt Illustrates the creation and configuration of a Shadowsocks proxy bean, including encryption methods, plugins, and stream settings for TLS transport. It also shows how to parse and generate Shadowsocks share links. Dependencies include NekoGui_fmt::ShadowSocksBean. ```cpp #include "fmt/ShadowSocksBean.hpp" // Create Shadowsocks configuration NekoGui_fmt::ShadowSocksBean ssBean; ssBean.name = "SS Server"; ssBean.serverAddress = "ss.example.com"; ssBean.serverPort = 8388; ssBean.method = "2022-blake3-aes-128-gcm"; // Shadowsocks 2022 format ssBean.password = "base64_encoded_key"; ssBean.plugin = "obfs-local;obfs=http;obfs-host=www.example.com"; ssBean.uot = 1; // Enable UDP over TCP // Configure stream settings for TLS transport ssBean.stream->network = "ws"; ssBean.stream->security = "tls"; ssBean.stream->sni = "ss.example.com"; ssBean.stream->path = "/websocket"; // Parse from share link NekoGui_fmt::ShadowSocksBean parsedBean; if (parsedBean.TryParseLink("ss://YWVzLTI1Ni1nY206cGFzc3dvcmQ@server:8388#MyServer")) { qDebug() << "Server:" << parsedBean.serverAddress; qDebug() << "Method:" << parsedBean.method; } // Generate share link QString shareLink = ssBean.ToShareLink(); // Result: ss://MjAyMi1ibGFrZTMtYWVzLTEyOC1nY206YmFzZTY0X2VuY29kZWRfa2V5QHNzLmV4YW1wbGUuY29tOjg4ODg#U1MlMjBTY3JpdmVy ``` -------------------------------- ### Manage Proxy Profiles and Groups in C++ Source: https://context7.com/matsuridayo/nekoray/llms.txt Demonstrates how to use the ProfileManager class to create, add, organize, and save proxy profiles and groups. It covers creating new profiles, adding them to groups, and moving profiles between groups. Dependencies include NekoGui::ProfileManager and related classes. ```cpp #include "db/Database.hpp" // Access the global profile manager NekoGui::ProfileManager *manager = NekoGui::profileManager; // Create a new Shadowsocks proxy profile auto entity = NekoGui::ProfileManager::NewProxyEntity("shadowsocks"); auto ssBean = entity->ShadowSocksBean(); ssBean->name = "My SS Server"; ssBean->serverAddress = "example.com"; ssBean->serverPort = 8388; ssBean->method = "aes-256-gcm"; ssBean->password = "my_password"; // Add profile to current group (gid = -1 for current group) manager->AddProfile(entity, -1); // Create and add a new group auto group = NekoGui::ProfileManager::NewGroup(); group->name = "Work Servers"; group->url = "https://example.com/subscription"; // Optional subscription URL manager->AddGroup(group); // Get all profiles in a group by display order auto profiles = group->ProfilesWithOrder(); for (const auto& profile : profiles) { qDebug() << profile->bean->DisplayTypeAndName(); qDebug() << "Latency:" << profile->DisplayLatency(); } // Move profile to another group manager->MoveProfile(entity, group->id); // Save all changes manager->SaveManager(); ``` -------------------------------- ### gRPC Client for Core Communication Source: https://context7.com/matsuridayo/nekoray/llms.txt Demonstrates using the gRPC client to interact with the nekobox_core backend. It covers starting/stopping proxies, querying statistics like download/upload bytes, running latency tests, and checking the core's keep-alive status. Dependencies include the 'rpc/gRPC.h' header. ```cpp #include "rpc/gRPC.h" // Access default gRPC client NekoGui_rpc::Client* client = NekoGui_rpc::defaultClient; // Start proxy with configuration libcore::LoadConfigReq startReq; startReq.set_coreconfig(configJson.toStdString()); startReq.add_statsoutbounds("proxy"); bool rpcOK = false; QString error = client->Start(&rpcOK, startReq); if (!rpcOK || !error.isEmpty()) { qDebug() << "Failed to start:" << error; return; } // Query traffic statistics long long downloadBytes = client->QueryStats("proxy", "downlink"); long long uploadBytes = client->QueryStats("proxy", "uplink"); qDebug() << "Download:" << downloadBytes << "Upload:" << uploadBytes; // Run latency test libcore::TestReq testReq; testReq.set_mode(libcore::TestMode::UrlTest); testReq.set_url("http://cp.cloudflare.com/"); testReq.set_timeout(5000); // 5 seconds libcore::TestResp testResp = client->Test(&rpcOK, testReq); if (rpcOK && testResp.error().empty()) { qDebug() << "Latency:" << testResp.ms() << "ms"; } // Stop proxy error = client->Stop(&rpcOK); // Keep-alive check if (!client->KeepAlive()) { qDebug() << "Core process not responding"; } ``` -------------------------------- ### Manage Subscription Updates Source: https://context7.com/matsuridayo/nekoray/llms.txt Shows how to use the GroupUpdater class to perform asynchronous or synchronous subscription updates. It also explains how to configure global subscription settings like proxy usage and auto-update intervals. ```cpp #include "sub/GroupUpdater.hpp" NekoGui_sub::GroupUpdater* updater = NekoGui_sub::groupUpdater; QString subscriptionUrl = "https://example.com/subscription"; int groupId = 1; updater->AsyncUpdate(subscriptionUrl, groupId, []() { qDebug() << "Subscription update completed!"; }); UI_update_all_groups(true); NekoGui::dataStore->sub_use_proxy = true; NekoGui::dataStore->sub_auto_update = 60; ``` -------------------------------- ### Create Executable with CMake (Qt 5 & 6) Source: https://github.com/matsuridayo/nekoray/blob/main/CMakeLists.txt This CMake code defines how to create the main executable target named 'nekobox'. It handles differences between Qt 6 and Qt 5, including specific configurations for Android builds. It also sets properties for the executable such as enabling automatic UI, mock object generation, and resource compilation. ```cmake if (${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_executable(nekobox MANUAL_FINALIZATION ${PROJECT_SOURCES} ) # Define target properties for Android with Qt 6 as: # set_property(TARGET nekobox APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR # ${CMAKE_CURRENT_SOURCE_DIR}/android) # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation else () if (ANDROID) add_library(nekobox SHARED ${PROJECT_SOURCES} ) # Define properties for Android with Qt 5 after find_package() calls as: # set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") else () add_executable(nekobox ${PROJECT_SOURCES} ) endif () endif () # Target set_property(TARGET nekobox PROPERTY AUTOUIC ON) set_property(TARGET nekobox PROPERTY AUTOMOC ON) set_property(TARGET nekobox PROPERTY AUTORCC ON) set_target_properties(nekobox PROPERTIES WIN32_EXECUTABLE TRUE ) ``` -------------------------------- ### Generate sing-box Configuration Source: https://context7.com/matsuridayo/nekoray/llms.txt Utilizes the ConfigBuilder utility to convert proxy profiles into sing-box core configurations. It also demonstrates how to access outbound statistics and generate VPN/TUN configurations. ```cpp #include "db/ConfigBuilder.hpp" // Build configuration for a proxy profile auto entity = NekoGui::profileManager->GetProfile(profileId); auto result = NekoGui::BuildConfig(entity, false, false); if (!result->error.isEmpty()) { qDebug() << "Build error:" << result->error; return; } // Access generated configuration QJsonObject coreConfig = result->coreConfig; QString configJson = QJsonDocument(coreConfig).toJson(); // Access traffic statistics data for (const auto& stat : result->outboundStats) { qDebug() << "Outbound tag:" << QString::fromStdString(stat->tag); } // Build chain proxy configuration QString chainError = NekoGui::BuildChain(chainProfileId, status); // Write VPN/TUN configuration QString vpnConfigPath = NekoGui::WriteVPNSingBoxConfig(); QString vpnScript = NekoGui::WriteVPNLinuxScript(vpnConfigPath); ``` -------------------------------- ### Define Project Sources with CMake Source: https://github.com/matsuridayo/nekoray/blob/main/CMakeLists.txt This CMake code snippet defines the list of source files for the NekoRay project. It includes main application files, third-party libraries, UI components, RPC modules, database interactions, formatting utilities, system utilities, and UI elements. It also incorporates platform-specific sources and Qt resource files. ```cmake set(PROJECT_SOURCES ${PLATFORM_SOURCES} main/main.cpp main/NekoGui.cpp main/NekoGui_Utils.cpp main/HTTPRequestHelper.cpp 3rdparty/base64.cpp 3rdparty/qrcodegen.cpp 3rdparty/QtExtKeySequenceEdit.cpp 3rdparty/qv2ray/v2/ui/QvAutoCompleteTextEdit.cpp 3rdparty/qv2ray/v2/components/proxy/QvProxyConfigurator.cpp 3rdparty/qv2ray/v2/ui/widgets/common/QJsonModel.cpp 3rdparty/qv2ray/v2/ui/widgets/editors/w_JsonEditor.cpp 3rdparty/qv2ray/v2/ui/widgets/editors/w_JsonEditor.hpp 3rdparty/qv2ray/v2/ui/widgets/editors/w_JsonEditor.ui 3rdparty/qv2ray/v3/components/GeositeReader/GeositeReader.cpp 3rdparty/qv2ray/v3/components/GeositeReader/picoproto.cpp rpc/gRPC.cpp db/Database.cpp db/traffic/TrafficLooper.cpp db/ProfileFilter.cpp db/ConfigBuilder.cpp fmt/AbstractBean.cpp fmt/Bean2CoreObj_box.cpp fmt/Bean2External.cpp fmt/Bean2Link.cpp fmt/Link2Bean.cpp fmt/ChainBean.hpp # translate sub/GroupUpdater.cpp sys/ExternalProcess.cpp sys/AutoRun.cpp ui/ThemeManager.cpp ui/Icon.cpp ui/mainwindow_grpc.cpp ui/mainwindow.cpp ui/mainwindow.h ui/mainwindow.ui ui/edit/dialog_edit_profile.h ui/edit/dialog_edit_profile.cpp ui/edit/dialog_edit_profile.ui ui/edit/dialog_edit_group.h ui/edit/dialog_edit_group.cpp ui/edit/dialog_edit_group.ui ui/edit/edit_chain.h ui/edit/edit_chain.cpp ui/edit/edit_chain.ui ui/edit/edit_socks_http.h ui/edit/edit_socks_http.cpp ui/edit/edit_socks_http.ui ui/edit/edit_shadowsocks.h ui/edit/edit_shadowsocks.cpp ui/edit/edit_shadowsocks.ui ui/edit/edit_vmess.h ui/edit/edit_vmess.cpp ui/edit/edit_vmess.ui ui/edit/edit_trojan_vless.h ui/edit/edit_trojan_vless.cpp ui/edit/edit_trojan_vless.ui ui/edit/edit_naive.h ui/edit/edit_naive.cpp ui/edit/edit_naive.ui ui/edit/edit_quic.h ui/edit/edit_quic.cpp ui/edit/edit_quic.ui ui/edit/edit_custom.h ui/edit/edit_custom.cpp ui/edit/edit_custom.ui ui/dialog_basic_settings.cpp ui/dialog_basic_settings.h ui/dialog_basic_settings.ui ui/dialog_manage_groups.cpp ui/dialog_manage_groups.h ui/dialog_manage_groups.ui ui/dialog_manage_routes.cpp ui/dialog_manage_routes.h ui/dialog_manage_routes.ui ui/dialog_vpn_settings.cpp ui/dialog_vpn_settings.h ui/dialog_vpn_settings.ui ui/dialog_hotkey.cpp ui/dialog_hotkey.h ui/dialog_hotkey.ui ui/widget/ProxyItem.cpp ui/widget/ProxyItem.h ui/widget/ProxyItem.ui ui/widget/GroupItem.cpp ui/widget/GroupItem.h ui/widget/GroupItem.ui res/neko.qrc res/theme/feiyangqingyun/qss.qrc ${QV2RAY_RC} ) ``` -------------------------------- ### Configure VMess Protocol Bean in C++ Source: https://context7.com/matsuridayo/nekoray/llms.txt Details the configuration of a VMess proxy bean, supporting both legacy and modern share link formats. It covers setting up server details, UUID, authentication, and transport configurations like WebSocket with TLS. Dependencies include NekoGui_fmt::VMessBean. ```cpp #include "fmt/VMessBean.hpp" // Create VMess configuration NekoGui_fmt::VMessBean vmessBean; vmessBean.name = "VMess Server"; vmessBean.serverAddress = "vmess.example.com"; vmessBean.serverPort = 443; vmessBean.uuid = "a3482e88-686a-4a58-8126-99c9df64b7bf"; vmessBean.aid = 0; // alterId (0 for AEAD) vmessBean.security = "auto"; // Configure WebSocket transport with TLS vmessBean.stream->network = "ws"; vmessBean.stream->security = "tls"; vmessBean.stream->path = "/vmess-ws"; vmessBean.stream->host = "cdn.example.com"; vmessBean.stream->sni = "vmess.example.com"; vmessBean.stream->utlsFingerprint = "chrome"; // Parse v2rayN format share link NekoGui_fmt::VMessBean parsedVmess; QString v2raynLink = "vmess://eyJ2IjoiMiIsInBzIjoiVk1lc3MiLCJhZGQiOiJ2bWVzcy5leGFtcGxlLmNvbSIsInBvcnQiOiI0NDMiLCJpZCI6ImEzNDgyZTg4LTY4NmEtNGE1OC04MTI2LTk5YzlkZjY0YjdiZiIsImFpZCI6IjAiLCJuZXQiOiJ3cyIsInR5cGUiOiIiLCJob3N0IjoiIiwicGF0aCI6Ii92bWVzcy13cyIsInRscyI6InRscyIsInNuaSI6InZtZXNzLmV4YW1wbGUuY29tIn0="; if (parsedVmess.TryParseLink(v2raynLink)) { qDebug() << "UUID:" << parsedVmess.uuid; qDebug() << "Network:" << parsedVmess.stream->network; } // Generate share link (format depends on dataStore->old_share_link_format) QString link = vmessBean.ToShareLink(); ``` -------------------------------- ### Manage Translations with CMake (Qt 5 & 6) Source: https://github.com/matsuridayo/nekoray/blob/main/CMakeLists.txt This CMake code manages the internationalization (i18n) process for the NekoRay project. It defines the translation source files (.ts) and uses Qt's translation tools (lupdate and lrelease) to generate the necessary translation files (.qm). It also configures a resource file for translations. ```cmake # Target Source Translations set(TS_FILES translations/zh_CN.ts translations/fa_IR.ts translations/ru_RU.ts ) set(LUPDATE_OPTIONS -locations none -no-obsolete ) if (${QT_VERSION_MAJOR} GREATER_EQUAL 6) qt_add_lupdate(nekobox TS_FILES ${TS_FILES} OPTIONS ${LUPDATE_OPTIONS}) qt_add_lrelease(nekobox TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES) else () qt5_create_translation(QM_FILES ${PROJECT_SOURCES} ${TS_FILES} OPTIONS ${LUPDATE_OPTIONS}) endif () configure_file(translations/translations.qrc ${CMAKE_BINARY_DIR} COPYONLY) target_sources(nekobox PRIVATE ${CMAKE_BINARY_DIR}/translations.qrc) ``` -------------------------------- ### Monitor Proxy Traffic Statistics Source: https://context7.com/matsuridayo/nekoray/llms.txt Illustrates how to enable and interact with the TrafficLooper to track real-time upload/download speeds and total traffic usage. It includes methods for resetting counters and configuring the monitoring interval. ```cpp #include "db/traffic/TrafficLooper.hpp" #include "db/traffic/TrafficData.hpp" NekoGui_traffic::TrafficLooper* looper = NekoGui_traffic::trafficLooper; looper->loop_enabled = true; looper->Loop(); if (looper->proxy) { qDebug() << "Speed:" << looper->proxy->DisplaySpeed(); qDebug() << "Total:" << looper->proxy->DisplayTraffic(); looper->proxy->Reset(); } NekoGui::dataStore->traffic_loop_interval = 1000; ``` -------------------------------- ### Profile Filtering and Deduplication Utilities Source: https://context7.com/matsuridayo/nekoray/llms.txt Provides functions for managing lists of proxy profiles, including filtering, removing duplicates, and comparing lists. It allows for deduplication based on full profile data or just the address, and finding common or unique profiles between two lists. Dependencies include 'db/ProfileFilter.hpp'. ```cpp #include "db/ProfileFilter.hpp" // Get profiles from a group auto group = NekoGui::profileManager->GetGroup(groupId); QList> profiles = group->Profiles(); // Remove duplicate profiles QList> uniqueProfiles; NekoGui::ProfileFilter::Uniq( profiles, uniqueProfiles, false, // by_address: false = compare full bean, true = compare address only false // keep_last: false = keep first occurrence, true = keep last ); qDebug() << "Unique profiles:" << uniqueProfiles.size(); // Compare two profile lists - find common profiles QList> srcProfiles = groupA->Profiles(); QList> dstProfiles = groupB->Profiles(); QList> commonSrc, commonDst; NekoGui::ProfileFilter::Common( srcProfiles, dstProfiles, commonSrc, commonDst, true // by_address: compare by server address only ); qDebug() << "Common profiles:" << commonSrc.size(); // Find profiles only in source (not in destination) QList> onlyInSrc; NekoGui::ProfileFilter::OnlyInSrc( srcProfiles, dstProfiles, onlyInSrc, false // by_address ); qDebug() << "Profiles only in source:" << onlyInSrc.size(); ``` -------------------------------- ### External Process Management Source: https://context7.com/matsuridayo/nekoray/llms.txt Endpoints for configuring and managing external proxy processes using the CustomBean and ExternalProcess classes. ```APIDOC ## Custom Core and External Process ### Description Allows for the definition and lifecycle management of external proxy cores (e.g., naive, ssh) not handled by the internal core. ### Method POST ### Parameters #### Request Body - **name** (string) - Required - Name of the custom bean - **core** (string) - Required - Core type (internal or external name) - **config_simple** (string) - Required - Configuration JSON string ### Response #### Success Response (200) - **program** (string) - Path to the executable - **arguments** (array) - List of command line arguments - **env** (map) - Environment variables for the process ``` -------------------------------- ### Routing Configuration API Source: https://context7.com/matsuridayo/nekoray/llms.txt Manages routing rules for domains and IP addresses, including direct, proxy, and block rules, along with DNS settings. ```APIDOC ## Routing Configuration ### Description Manages routing rules including direct, proxy, and block rules for domains and IP addresses with DNS configuration. ### Method N/A (Configuration via direct variable assignment) ### Endpoint N/A ### Parameters N/A ### Request Example ```cpp #include "main/NekoGui_DataStore.hpp" // Access active routing configuration NekoGui::Routing* routing = NekoGui::dataStore->routing.get(); // Configure routing rules (one domain/IP per line) routing->direct_domain = "geosite:cn\ngeosite:private"; routing->direct_ip = "geoip:cn\ngeoip:private\n10.0.0.0/8"; routing->proxy_domain = "geosite:google\ngeosite:github"; routing->proxy_ip = ""; routing->block_domain = "geosite:category-ads-all"; routing->block_ip = ""; // Set default outbound behavior routing->def_outbound = "proxy"; // "proxy", "direct", or "block" // Configure DNS settings routing->remote_dns = "https://dns.google/dns-query"; routing->remote_dns_strategy = "prefer_ipv4"; routing->direct_dns = "https://doh.pub/dns-query"; routing->direct_dns_strategy = "prefer_ipv4"; routing->dns_routing = true; routing->dns_final_out = "proxy"; // Set domain strategy for resolution routing->domain_strategy = "AsIs"; // or "IPIfNonMatch", "IPOnDemand" routing->outbound_domain_strategy = "AsIs"; // Configure sniffing mode routing->sniffing_mode = NekoGui::SniffingMode::FOR_ROUTING; // List available routing presets QStringList presets = NekoGui::Routing::List(); // Returns: ["Default", "Custom1", ...] // Activate a routing preset NekoGui::Routing::SetToActive("Default"); ``` ### Response N/A (Configuration is applied directly) ### Response Example N/A ``` -------------------------------- ### Traffic Monitoring API Source: https://context7.com/matsuridayo/nekoray/llms.txt Provides real-time traffic statistics monitoring for proxy connections. ```APIDOC ## Traffic Monitoring ### Description The `TrafficLooper` and `TrafficData` classes provide real-time traffic statistics monitoring for proxy connections. ### Method N/A (Monitoring via direct variable access and function calls) ### Endpoint N/A ### Parameters N/A ### Request Example ```cpp #include "db/traffic/TrafficLooper.hpp" #include "db/traffic/TrafficData.hpp" // Access global traffic looper NekoGui_traffic::TrafficLooper* looper = NekoGui_traffic::trafficLooper; // Enable traffic monitoring looper->loop_enabled = true; // Start monitoring loop (typically called in background thread) looper->Loop(); // Access current proxy traffic data if (looper->proxy) { NekoGui_traffic::TrafficData* proxyTraffic = looper->proxy; qDebug() << "Download:" << proxyTraffic->downlink << "bytes"; qDebug() << "Upload:" << proxyTraffic->uplink << "bytes"; qDebug() << "Download rate:" << proxyTraffic->downlink_rate << "bytes/s"; qDebug() << "Upload rate:" << proxyTraffic->uplink_rate << "bytes/s"; // Get formatted display strings qDebug() << "Speed:" << proxyTraffic->DisplaySpeed(); // Output: "1.5 MB/s↑ 10.2 MB/s↓" qDebug() << "Total:" << proxyTraffic->DisplayTraffic(); // Output: "150 MB↑ 2.3 GB↓" } // Access all monitored items for (const auto& item : looper->items) { qDebug() << "Tag:" << QString::fromStdString(item->tag); qDebug() << item->DisplayTraffic(); } // Reset traffic counters if (looper->proxy) { looper->proxy->Reset(); } // Configure traffic loop interval (milliseconds) NekoGui::dataStore->traffic_loop_interval = 1000; ``` ### Response N/A (Traffic data is accessed directly) ### Response Example N/A ``` -------------------------------- ### Proxy Profile Management API Source: https://context7.com/matsuridayo/nekoray/llms.txt Manage proxy profiles and groups within NekoBox For PC. This includes creating, adding, deleting, and organizing proxy configurations and groups. ```APIDOC ## Proxy Profile Management ### Description Provides centralized management of proxy profiles and groups. It handles loading, saving, adding, deleting, and organizing proxy configurations with support for profile ordering and group-based organization. ### Method N/A (Class methods) ### Endpoint N/A (Class methods) ### Parameters N/A ### Request Example ```cpp #include "db/Database.hpp" // Access the global profile manager NekoGui::ProfileManager *manager = NekoGui::profileManager; // Create a new Shadowsocks proxy profile auto entity = NekoGui::ProfileManager::NewProxyEntity("shadowsocks"); auto ssBean = entity->ShadowSocksBean(); ssBean->name = "My SS Server"; ssBean->serverAddress = "example.com"; ssBean->serverPort = 8388; ssBean->method = "aes-256-gcm"; ssBean->password = "my_password"; // Add profile to current group (gid = -1 for current group) manager->AddProfile(entity, -1); // Create and add a new group auto group = NekoGui::ProfileManager::NewGroup(); group->name = "Work Servers"; group->url = "https://example.com/subscription"; // Optional subscription URL manager->AddGroup(group); // Get all profiles in a group by display order auto profiles = group->ProfilesWithOrder(); for (const auto& profile : profiles) { qDebug() << profile->bean->DisplayTypeAndName(); qDebug() << "Latency:" << profile->DisplayLatency(); } // Move profile to another group manager->MoveProfile(entity, group->id); // Save all changes manager->SaveManager(); ``` ### Response N/A (Class methods) ### Response Example N/A ``` -------------------------------- ### VMess Protocol Bean API Source: https://context7.com/matsuridayo/nekoray/llms.txt Implements VMess protocol configuration, supporting both legacy and modern share link formats. Includes configuration for transport protocols like WebSocket with TLS. ```APIDOC ## VMess Protocol Bean ### Description Implements VMess protocol configuration with support for both legacy and modern share link formats. It allows configuration of transport settings such as WebSocket with TLS. ### Method N/A (Class methods) ### Endpoint N/A (Class methods) ### Parameters N/A ### Request Example ```cpp #include "fmt/VMessBean.hpp" // Create VMess configuration NekoGui_fmt::VMessBean vmessBean; vmessBean.name = "VMess Server"; vmessBean.serverAddress = "vmess.example.com"; vmessBean.serverPort = 443; vmessBean.uuid = "a3482e88-686a-4a58-8126-99c9df64b7bf"; vmessBean.aid = 0; // alterId (0 for AEAD) vmessBean.security = "auto"; // Configure WebSocket transport with TLS vmessBean.stream->network = "ws"; vmessBean.stream->security = "tls"; vmessBean.stream->path = "/vmess-ws"; vmessBean.stream->host = "cdn.example.com"; vmessBean.stream->sni = "vmess.example.com"; vmessBean.stream->utlsFingerprint = "chrome"; // Parse v2rayN format share link NekoGui_fmt::VMessBean parsedVmess; QString v2raynLink = "vmess://eyJ2IjoiMiIsInBzIjoiVk1lc3MiLCJhZGQiOiJ2bWVzcy5leGFtcGxlLmNvbSIsInBvcnQiOiI0NDMiLCJpZCI6ImEzNDgyZTg4LTY4NmEtNGE1OC04MTI2LTk5YzlkZjY0YjdiZiIsImFpZCI6IjAiLCJuZXQiOiJ3cyIsInR5cGUiOiIiLCJob3N0IjoiIiwicGF0aCI6Ii92bWVzcy13cyIsInRscyI6InRscyIsInNuaSI6InZtZXNzLmV4YW1wbGUuY29tIn0="; if (parsedVmess.TryParseLink(v2raynLink)) { qDebug() << "UUID:" << parsedVmess.uuid; qDebug() << "Network:" << parsedVmess.stream->network; } // Generate share link (format depends on dataStore->old_share_link_format) QString link = vmessBean.ToShareLink(); ``` ### Response N/A (Class methods) ### Response Example N/A ``` -------------------------------- ### Shadowsocks Protocol Bean API Source: https://context7.com/matsuridayo/nekoray/llms.txt Represents Shadowsocks proxy configurations, including encryption methods, plugins, and UDP over TCP settings. Supports parsing and generating share links. ```APIDOC ## Shadowsocks Protocol Bean ### Description Implements Shadowsocks proxy configurations with support for various encryption methods, plugins, and UDP over TCP settings. It can parse and generate share links. ### Method N/A (Class methods) ### Endpoint N/A (Class methods) ### Parameters N/A ### Request Example ```cpp #include "fmt/ShadowSocksBean.hpp" // Create Shadowsocks configuration NekoGui_fmt::ShadowSocksBean ssBean; ssBean.name = "SS Server"; ssBean.serverAddress = "ss.example.com"; ssBean.serverPort = 8388; ssBean.method = "2022-blake3-aes-128-gcm"; // Shadowsocks 2022 format ssBean.password = "base64_encoded_key"; ssBean.plugin = "obfs-local;obfs=http;obfs-host=www.example.com"; ssBean.uot = 1; // Enable UDP over TCP // Configure stream settings for TLS transport ssBean.stream->network = "ws"; ssBean.stream->security = "tls"; ssBean.stream->sni = "ss.example.com"; ssBean.stream->path = "/websocket"; // Parse from share link NekoGui_fmt::ShadowSocksBean parsedBean; if (parsedBean.TryParseLink("ss://YWVzLTI1Ni1nY206cGFzc3dvcmQ@server:8388#MyServer")) { qDebug() << "Server:" << parsedBean.serverAddress; qDebug() << "Method:" << parsedBean.method; } // Generate share link QString shareLink = ssBean.ToShareLink(); // Result: ss://MjAyMi1ibGFrZTMtYWVzLTEyOC1nY206YmFzZTY0X2VuY29kZWRfa2V5@ss.example.com:8388#SS%20Server ``` ### Response N/A (Class methods) ### Response Example N/A ``` -------------------------------- ### Profile Filtering and Deduplication Source: https://context7.com/matsuridayo/nekoray/llms.txt Utility methods for managing proxy profile lists, including deduplication and set-based comparisons. ```APIDOC ## Profile Filtering and Deduplication ### Description Provides utility functions to clean and compare proxy profile lists based on full entity comparison or server address. ### Method GET ### Parameters #### Query Parameters - **by_address** (boolean) - Optional - If true, compares profiles based on server address only. - **keep_last** (boolean) - Optional - If true, keeps the last occurrence during deduplication. ### Response #### Success Response (200) - **profiles** (array) - Filtered or compared list of ProxyEntity objects ``` -------------------------------- ### Subscription and Group Updater API Source: https://context7.com/matsuridayo/nekoray/llms.txt Handles subscription updates from various formats and manages groups. ```APIDOC ## Subscription and Group Updater ### Description The `GroupUpdater` class handles subscription updates with support for various formats including Clash, Shadowsocks, and v2rayN. ### Method N/A (Configuration via direct variable assignment and function calls) ### Endpoint N/A ### Parameters N/A ### Request Example ```cpp #include "sub/GroupUpdater.hpp" // Access global group updater NekoGui_sub::GroupUpdater* updater = NekoGui_sub::groupUpdater; // Update subscription asynchronously QString subscriptionUrl = "https://example.com/subscription"; int groupId = 1; // -1 for current group updater->AsyncUpdate(subscriptionUrl, groupId, []() { qDebug() << "Subscription update completed!"; }); // Connect to completion signal QObject::connect(updater, &NekoGui_sub::GroupUpdater::asyncUpdateCallback, [](int gid) { qDebug() << "Group" << gid << "updated"; auto group = NekoGui::profileManager->GetGroup(gid); qDebug() << "Profiles count:" << group->Profiles().size(); }); // Synchronous update (blocking) updater->Update(subscriptionUrl, groupId, false); // Update all groups with auto-update enabled UI_update_all_groups(true); // true = only groups with auto-update allowed // Configure subscription settings via dataStore NekoGui::dataStore->sub_use_proxy = true; // Use proxy for subscription fetches NekoGui::dataStore->sub_clear = true; // Clear old profiles before update NekoGui::dataStore->sub_insecure = false; // Allow insecure TLS NekoGui::dataStore->sub_auto_update = 60; // Auto-update interval in minutes (negative = disabled) ``` ### Response N/A (Updates are asynchronous or blocking) ### Response Example N/A ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.