mirror of
https://github.com/netchx/netch.git
synced 2026-03-18 18:13:21 +08:00
77 lines
2.0 KiB
C#
77 lines
2.0 KiB
C#
using System.Collections.Generic;
|
|
using Netch.Controllers;
|
|
using Netch.Interfaces;
|
|
using Netch.Models;
|
|
|
|
namespace Netch.Servers.Shadowsocks
|
|
{
|
|
public class SSController : Guard, IServerController
|
|
{
|
|
public SSController() : base("Shadowsocks.exe")
|
|
{
|
|
}
|
|
|
|
protected override IEnumerable<string> StartedKeywords => new[] { "listening at" };
|
|
|
|
protected override IEnumerable<string> FailedKeywords => new[] { "Invalid config path", "usage", "plugin service exit unexpectedly" };
|
|
|
|
public override string Name => "Shadowsocks";
|
|
|
|
public ushort? Socks5LocalPort { get; set; }
|
|
|
|
public string? LocalAddress { get; set; }
|
|
|
|
public Socks5 Start(in Server s)
|
|
{
|
|
var server = (Shadowsocks)s;
|
|
|
|
var command = new SSParameter
|
|
{
|
|
s = server.AutoResolveHostname(),
|
|
p = server.Port,
|
|
b = this.LocalAddress(),
|
|
l = this.Socks5LocalPort(),
|
|
m = server.EncryptMethod,
|
|
k = server.Password,
|
|
u = true,
|
|
plugin = server.Plugin,
|
|
plugin_opts = server.PluginOption
|
|
};
|
|
|
|
StartGuard(command.ToString());
|
|
return new Socks5(this.LocalAddress(), this.Socks5LocalPort());
|
|
}
|
|
|
|
[Verb]
|
|
private class SSParameter : ParameterBase
|
|
{
|
|
public string? s { get; set; }
|
|
|
|
public ushort? p { get; set; }
|
|
|
|
public string? b { get; set; }
|
|
|
|
public ushort? l { get; set; }
|
|
|
|
public string? m { get; set; }
|
|
|
|
public string? k { get; set; }
|
|
|
|
public bool u { get; set; }
|
|
|
|
[Full]
|
|
[Optional]
|
|
public string? plugin { get; set; }
|
|
|
|
[Full]
|
|
[Optional]
|
|
[RealName("plugin-opts")]
|
|
public string? plugin_opts { get; set; }
|
|
|
|
[Full]
|
|
[Quote]
|
|
[Optional]
|
|
public string? acl { get; set; }
|
|
}
|
|
}
|
|
} |