[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

@@ -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;
}