[Netch] Support TCP Fast Open

This commit is contained in:
Hellojack
2022-06-16 17:01:40 +08:00
committed by GitHub
parent 3fa3c1cfcb
commit 95aa3db415
6 changed files with 74 additions and 1 deletions

View File

@@ -80,6 +80,7 @@ namespace Netch.Forms
this.XrayConeCheckBox = new System.Windows.Forms.CheckBox();
this.TLSAllowInsecureCheckBox = new System.Windows.Forms.CheckBox();
this.UseMuxCheckBox = new System.Windows.Forms.CheckBox();
this.TCPFastOpenBox = new System.Windows.Forms.CheckBox();
this.KCPGroupBox = new System.Windows.Forms.GroupBox();
this.mtuLabel = new System.Windows.Forms.Label();
this.mtuTextBox = new System.Windows.Forms.TextBox();
@@ -590,6 +591,7 @@ namespace Netch.Forms
this.v2rayTabPage.Controls.Add(this.XrayConeCheckBox);
this.v2rayTabPage.Controls.Add(this.TLSAllowInsecureCheckBox);
this.v2rayTabPage.Controls.Add(this.UseMuxCheckBox);
this.v2rayTabPage.Controls.Add(this.TCPFastOpenBox);
this.v2rayTabPage.Controls.Add(this.KCPGroupBox);
this.v2rayTabPage.Location = new System.Drawing.Point(4, 29);
this.v2rayTabPage.Name = "v2rayTabPage";
@@ -628,6 +630,16 @@ namespace Netch.Forms
this.UseMuxCheckBox.Text = "Use Mux";
this.UseMuxCheckBox.UseVisualStyleBackColor = true;
//
// TCPFastOpenBox
//
this.TCPFastOpenBox.AutoSize = true;
this.TCPFastOpenBox.Location = new System.Drawing.Point(300, 42);
this.TCPFastOpenBox.Name = "TCPFastOpenBox";
this.TCPFastOpenBox.Size = new System.Drawing.Size(131, 21);
this.TCPFastOpenBox.TabIndex = 3;
this.TCPFastOpenBox.Text = "TCP FastOpen";
this.TCPFastOpenBox.UseVisualStyleBackColor = true;
//
// KCPGroupBox
//
this.KCPGroupBox.Controls.Add(this.mtuLabel);
@@ -1063,6 +1075,7 @@ namespace Netch.Forms
private System.Windows.Forms.GroupBox KCPGroupBox;
private System.Windows.Forms.CheckBox congestionCheckBox;
private System.Windows.Forms.CheckBox TLSAllowInsecureCheckBox;
private System.Windows.Forms.CheckBox TCPFastOpenBox;
private System.Windows.Forms.Label mtuLabel;
private System.Windows.Forms.TextBox mtuTextBox;
private System.Windows.Forms.Label writeBufferSizeLabel;

View File

@@ -120,11 +120,11 @@ public partial class SettingForm : BindingForm
#endregion
#region V2Ray
BindCheckBox(XrayConeCheckBox, b => Global.Settings.V2RayConfig.XrayCone = b, Global.Settings.V2RayConfig.XrayCone);
BindCheckBox(TLSAllowInsecureCheckBox, b => Global.Settings.V2RayConfig.AllowInsecure = b, Global.Settings.V2RayConfig.AllowInsecure);
BindCheckBox(UseMuxCheckBox, b => Global.Settings.V2RayConfig.UseMux = b, Global.Settings.V2RayConfig.UseMux);
BindCheckBox(TCPFastOpenBox, b => Global.Settings.V2RayConfig.TCPFastOpen = b, Global.Settings.V2RayConfig.TCPFastOpen);
BindTextBox<int>(mtuTextBox, i => true, i => Global.Settings.V2RayConfig.KcpConfig.mtu = i, Global.Settings.V2RayConfig.KcpConfig.mtu);
BindTextBox<int>(ttiTextBox, i => true, i => Global.Settings.V2RayConfig.KcpConfig.tti = i, Global.Settings.V2RayConfig.KcpConfig.tti);

View File

@@ -11,4 +11,6 @@ public class V2rayConfig
public bool V2rayNShareLink { get; set; } = true;
public bool XrayCone { get; set; } = true;
public bool TCPFastOpen { get; set; } = false;
}

View File

@@ -183,6 +183,7 @@
"STUN Server": "STUN 服务器",
"Language": "语言",
"FullCone Support (Required Server Xray-core v1.3.0+)": "FullCone 支持(需服务端 Xray-core v1.3.0+",
"TCP FastOpen": "TCP 快速打开",
"Disable Support Warning": "停用支持警告",
"Profile": "配置名",

View File

@@ -117,6 +117,8 @@ public class StreamSettings
public TlsSettings xtlsSettings { get; set; }
public GrpcSettings grpcSettings { get; set; }
public Sockopt sockopt { get; set; }
}
#region Transport
@@ -184,4 +186,9 @@ public class GrpcSettings
public bool multiMode { get; set; }
}
public class Sockopt
{
public bool tcpFastOpen { get; set; }
}
#endregion

View File

@@ -160,6 +160,17 @@ public static class V2rayConfigUtils
plugin = ss.Plugin ?? "",
pluginOpts = ss.PluginOption ?? ""
};
if (Global.Settings.V2RayConfig.TCPFastOpen)
{
outbound.streamSettings = new StreamSettings
{
sockopt = new Sockopt
{
tcpFastOpen = true
}
};
}
break;
case ShadowsocksRServer ssr:
outbound.protocol = "shadowsocks";
@@ -184,6 +195,17 @@ public static class V2rayConfigUtils
"--protocol-param=" + ssr.ProtocolParam ?? ""
}
};
if (Global.Settings.V2RayConfig.TCPFastOpen)
{
outbound.streamSettings = new StreamSettings
{
sockopt = new Sockopt
{
tcpFastOpen = true
}
};
}
break;
case TrojanServer trojan:
outbound.protocol = "trojan";
@@ -225,6 +247,15 @@ public static class V2rayConfigUtils
break;
}
}
if (Global.Settings.V2RayConfig.TCPFastOpen)
{
outbound.streamSettings.sockopt = new Sockopt
{
tcpFastOpen = true
}
};
}
break;
case WireGuardServer wg:
outbound.protocol = "wireguard";
@@ -238,6 +269,17 @@ public static class V2rayConfigUtils
preSharedKey = wg.PreSharedKey,
mtu = wg.MTU
};
if (Global.Settings.V2RayConfig.TCPFastOpen)
{
outbound.streamSettings = new StreamSettings
{
sockopt = new Sockopt
{
tcpFastOpen = true
}
};
}
break;
}
@@ -366,6 +408,14 @@ public static class V2rayConfigUtils
throw new MessageException($"transfer protocol \"{server.TransferProtocol}\" not implemented yet");
}
if (Global.Settings.V2RayConfig.TCPFastOpen)
{
streamSettings.sockopt = new Sockopt
{
tcpFastOpen = true
};
}
return streamSettings;
}