vpn tcpip stack select for windows

This commit is contained in:
arm64v8a
2022-09-07 18:00:01 +08:00
parent b409962d83
commit d7d788cd22
6 changed files with 20 additions and 10 deletions

View File

@@ -7,6 +7,8 @@
%IPV6_ADDRESS% %IPV6_ADDRESS%
"mtu": %MTU%, "mtu": %MTU%,
"auto_route": true, "auto_route": true,
"stack": "%STACK%",
"endpoint_independent_nat": true,
"sniff": false "sniff": false
} }
], ],

View File

@@ -14,4 +14,8 @@ namespace Preset {
" }\n" " }\n"
"}"; "}";
} }
namespace SingBox {
inline QStringList VpnImplementation = {"gvisor", "lwip", "system"};
}
} }

View File

@@ -33,7 +33,7 @@ if [ "$GOOS" != "windows" ]; then
fi fi
#### Go ext: sing-box #### #### Go ext: sing-box ####
curl -Lso sing-box.zip https://github.com/SagerNet/sing-box/releases/download/v1.0-beta1/sing-box-1.0-beta1-windows-amd64.zip curl -Lso sing-box.zip https://github.com/SagerNet/sing-box/releases/download/v1.0-beta1/sing-box-1.0-beta1-windows-amd64.zip # TODO Update for system stack
unzip sing-box.zip unzip sing-box.zip
mv sing-box-*/sing-box.exe $DEST mv sing-box-*/sing-box.exe $DEST
rm -rf sing-box.zip sing-box-* rm -rf sing-box.zip sing-box-*

View File

@@ -124,7 +124,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox1">
<layout class="QHBoxLayout" name="horizontalLayout_9" stretch="0,8,1,1"> <layout class="QHBoxLayout" name="horizontalLayout_9" stretch="0,8,1,1">
<item> <item>
<widget class="QLabel" name="label_13"> <widget class="QLabel" name="label_13">
@@ -221,7 +221,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="horizontalGroupBox"> <widget class="QGroupBox" name="horizontalGroupBox1">
<layout class="QHBoxLayout" name="horizontalLayout_18"> <layout class="QHBoxLayout" name="horizontalLayout_18">
<item> <item>
<widget class="QCheckBox" name="check_include_pre"> <widget class="QCheckBox" name="check_include_pre">
@@ -265,7 +265,7 @@
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_5"> <layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="0"> <item row="1" column="0">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox2">
<layout class="QHBoxLayout" name="horizontalLayout_7"> <layout class="QHBoxLayout" name="horizontalLayout_7">
<item> <item>
<widget class="QLabel" name="label_15"> <widget class="QLabel" name="label_15">
@@ -402,7 +402,7 @@
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QGroupBox" name="horizontalGroupBox"> <widget class="QGroupBox" name="horizontalGroupBox2">
<layout class="QHBoxLayout" name="horizontalLayout_20"> <layout class="QHBoxLayout" name="horizontalLayout_20">
<item> <item>
<widget class="QCheckBox" name="start_minimal"> <widget class="QCheckBox" name="start_minimal">

View File

@@ -3,6 +3,7 @@
#include "qv2ray/v2/ui/widgets/editors/w_JsonEditor.hpp" #include "qv2ray/v2/ui/widgets/editors/w_JsonEditor.hpp"
#include "qv2ray/v3/components/GeositeReader/GeositeReader.hpp" #include "qv2ray/v3/components/GeositeReader/GeositeReader.hpp"
#include "fmt/Preset.hpp"
#include "main/GuiUtils.hpp" #include "main/GuiUtils.hpp"
#include <QFile> #include <QFile>
@@ -43,10 +44,11 @@ DialogManageRoutes::DialogManageRoutes(QWidget *parent) :
ui->vpn_implementation->setCurrentIndex(NekoRay::dataStore->vpn_implementation); ui->vpn_implementation->setCurrentIndex(NekoRay::dataStore->vpn_implementation);
ui->vpn_mtu->setCurrentText(Int2String(NekoRay::dataStore->vpn_mtu)); ui->vpn_mtu->setCurrentText(Int2String(NekoRay::dataStore->vpn_mtu));
ui->vpn_ipv6->setChecked(NekoRay::dataStore->vpn_ipv6); ui->vpn_ipv6->setChecked(NekoRay::dataStore->vpn_ipv6);
//
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
ui->vpn_implementation->setEditable(true); ui->vpn_implementation->setItemText(0, Preset::SingBox::VpnImplementation[0]);
ui->vpn_implementation->setCurrentText("Windows: sing-box gVisor"); ui->vpn_implementation->setItemText(1, Preset::SingBox::VpnImplementation[1]);
ui->vpn_implementation->setDisabled(true); ui->vpn_implementation->setItemText(2, Preset::SingBox::VpnImplementation[2]);
#endif #endif
// //
connect(ui->custom_route_edit, &QPushButton::clicked, this, [=] { connect(ui->custom_route_edit, &QPushButton::clicked, this, [=] {
@@ -109,11 +111,11 @@ void DialogManageRoutes::accept() {
auto mtu = ui->vpn_mtu->currentText().toInt(); auto mtu = ui->vpn_mtu->currentText().toInt();
if (mtu > 10000 || mtu < 1000) mtu = 9000; if (mtu > 10000 || mtu < 1000) mtu = 9000;
auto ipv6 = ui->vpn_ipv6->isChecked(); auto ipv6 = ui->vpn_ipv6->isChecked();
#ifndef Q_OS_WIN //
auto impl = ui->vpn_implementation->currentIndex(); auto impl = ui->vpn_implementation->currentIndex();
vpnChanged |= NekoRay::dataStore->vpn_implementation != impl; vpnChanged |= NekoRay::dataStore->vpn_implementation != impl;
NekoRay::dataStore->vpn_implementation = impl; NekoRay::dataStore->vpn_implementation = impl;
#endif //
vpnChanged |= NekoRay::dataStore->fake_dns != fakedns; vpnChanged |= NekoRay::dataStore->fake_dns != fakedns;
vpnChanged |= NekoRay::dataStore->vpn_mtu != mtu; vpnChanged |= NekoRay::dataStore->vpn_mtu != mtu;
vpnChanged |= NekoRay::dataStore->vpn_ipv6 != ipv6; vpnChanged |= NekoRay::dataStore->vpn_ipv6 != ipv6;

View File

@@ -1,6 +1,7 @@
#include "./ui_mainwindow.h" #include "./ui_mainwindow.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "fmt/Preset.hpp"
#include "db/ProfileFilter.hpp" #include "db/ProfileFilter.hpp"
#include "db/ConfigBuilder.hpp" #include "db/ConfigBuilder.hpp"
#include "sub/GroupUpdater.hpp" #include "sub/GroupUpdater.hpp"
@@ -1401,6 +1402,7 @@ bool MainWindow::StartVPNProcess() {
auto config = ReadFileText(configFn) auto config = ReadFileText(configFn)
.replace("%IPV6_ADDRESS%", NekoRay::dataStore->vpn_ipv6 ? "\"inet6_address\": \"fdfe:dcba:9876::1/128\"," : "") .replace("%IPV6_ADDRESS%", NekoRay::dataStore->vpn_ipv6 ? "\"inet6_address\": \"fdfe:dcba:9876::1/128\"," : "")
.replace("%MTU%", Int2String(NekoRay::dataStore->vpn_mtu)) .replace("%MTU%", Int2String(NekoRay::dataStore->vpn_mtu))
.replace("%STACK%", Preset::SingBox::VpnImplementation[NekoRay::dataStore->vpn_implementation])
.replace("%PORT%", Int2String(NekoRay::dataStore->inbound_socks_port)); .replace("%PORT%", Int2String(NekoRay::dataStore->inbound_socks_port));
#else #else
auto protectPath = QDir::currentPath() + "/protect"; auto protectPath = QDir::currentPath() + "/protect";