mirror of
https://github.com/netchx/netch.git
synced 2026-03-14 17:43:18 +08:00
SOCKS : Support version 4 & 4a
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
"Address": "地址",
|
||||
"Username": "用户名",
|
||||
"Password": "密码",
|
||||
"Version": "版本",
|
||||
"User ID": "用户 ID",
|
||||
"Alter ID": "额外 ID",
|
||||
"Transfer Protocol": "传输协议",
|
||||
|
||||
@@ -12,6 +12,11 @@ public class Socks5Form : ServerForm
|
||||
Server = server;
|
||||
CreateTextBox("Username", "Username", s => true, s => server.Username = s, server.Username.ValueOrDefault());
|
||||
CreateTextBox("Password", "Password", s => true, s => server.Password = s, server.Password.ValueOrDefault());
|
||||
CreateComboBox("Version",
|
||||
"Version",
|
||||
SOCKSGlobal.Versions,
|
||||
s => server.Version = s,
|
||||
server.Version);
|
||||
(_remoteHostnameLabel, _remoteHostnameTextBox) = CreateTextBox("RemoteHostname",
|
||||
"Remote Address",
|
||||
s => true,
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Netch.Servers;
|
||||
|
||||
public class Socks5Server : Server
|
||||
{
|
||||
public override string Type { get; } = "Socks5";
|
||||
public override string Type { get; } = "SOCKS";
|
||||
|
||||
/// <summary>
|
||||
/// 密码
|
||||
@@ -18,6 +18,11 @@ public class Socks5Server : Server
|
||||
|
||||
public string? RemoteHostname { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 版本
|
||||
/// </summary>
|
||||
public string Version { get; set; } = SOCKSGlobal.Versions[0];
|
||||
|
||||
public override string MaskedData()
|
||||
{
|
||||
return $"Auth: {Auth()}";
|
||||
@@ -48,4 +53,14 @@ public class Socks5Server : Server
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(Username) && !string.IsNullOrWhiteSpace(Password);
|
||||
}
|
||||
}
|
||||
|
||||
public class SOCKSGlobal
|
||||
{
|
||||
public static readonly List<string> Versions = new()
|
||||
{
|
||||
"5",
|
||||
"4a",
|
||||
"4"
|
||||
};
|
||||
}
|
||||
@@ -7,11 +7,11 @@ public class Socks5Util : IServerUtil
|
||||
{
|
||||
public ushort Priority { get; } = 0;
|
||||
|
||||
public string TypeName { get; } = "Socks5";
|
||||
public string TypeName { get; } = "SOCKS";
|
||||
|
||||
public string FullName { get; } = "Socks5";
|
||||
public string FullName { get; } = "SOCKS";
|
||||
|
||||
public string ShortName { get; } = "S5";
|
||||
public string ShortName { get; } = "SOCKS";
|
||||
|
||||
public string[] UriScheme { get; } = { };
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ public class OutboundConfiguration
|
||||
|
||||
public object[] servers { get; set; }
|
||||
|
||||
public string version { get; set; }
|
||||
|
||||
public string address { get; set; }
|
||||
|
||||
public ushort port { get; set; }
|
||||
|
||||
@@ -42,7 +42,7 @@ public static class V2rayConfigUtils
|
||||
|
||||
switch (server)
|
||||
{
|
||||
case Socks5Server socks5:
|
||||
case Socks5Server socks:
|
||||
{
|
||||
outbound.protocol = "socks";
|
||||
outbound.settings.servers = new object[]
|
||||
@@ -51,19 +51,20 @@ public static class V2rayConfigUtils
|
||||
{
|
||||
address = await server.AutoResolveHostnameAsync(),
|
||||
port = server.Port,
|
||||
users = socks5.Auth()
|
||||
users = socks.Auth()
|
||||
? new[]
|
||||
{
|
||||
new
|
||||
{
|
||||
user = socks5.Username,
|
||||
pass = socks5.Password,
|
||||
user = socks.Username,
|
||||
pass = socks.Password,
|
||||
level = 1
|
||||
}
|
||||
}
|
||||
: null
|
||||
}
|
||||
};
|
||||
outbound.settings.version = socks.Version;
|
||||
|
||||
outbound.mux.enabled = false;
|
||||
outbound.mux.concurrency = -1;
|
||||
|
||||
Reference in New Issue
Block a user