Пример #1
0
        public static Process Execute(Shadowsocks server, int listen)
        {
            int    timeout   = SettingManager.Configuration.TimeoutShadowsocks;
            string arguments = $"-s {server.HostAddress} -p {server.HostPort} -l {listen} -k {server.Password} -m {server.Encrypt} -t {timeout}";

            Process process = null;

            try
            {
                process = Process.Start(
                    new ProcessStartInfo
                {
                    FileName         = SSExePath,
                    Arguments        = arguments,
                    WorkingDirectory = App.DirectoryShadowsocks,
                    CreateNoWindow   = true,
                    UseShellExecute  = false,
                    LoadUserProfile  = false,
                });

                return(process);
            }
            catch
            {
                // it is correct
                process?.Dispose();
            }

            return(null);
        }
Пример #2
0
 public ShadowsocksForm(Shadowsocks server = default)
 {
     server ??= new Shadowsocks();
     Server = server;
     CreateTextBox("Password", "Password", s => true, s => server.Password = s, server.Password);
     CreateComboBox("EncryptMethod", "Encrypt Method", SSGlobal.EncryptMethods, s => server.EncryptMethod = s, server.EncryptMethod);
     CreateTextBox("Plugin", "Plugin", s => true, s => server.Plugin = s, server.Plugin);
     CreateTextBox("PluginsOption", "Plugin Options", s => true, s => server.PluginOption = s, server.PluginOption);
 }
Пример #3
0
        public static Shadowsocks Shadowsocks(string text)
        {
            var data        = new Uri(Encoding.UTF8.GetString(Convert.FromBase64String(text.Remove(0, 5))));
            var shadowsocks = new Shadowsocks();

            shadowsocks.Remark  = Uri.UnescapeDataString(data.Fragment.Remove(0, 1));
            shadowsocks.Address = data.Host;
            shadowsocks.Port    = data.Port;

            var info = Encoding.UTF8.GetString(Convert.FromBase64String(data.UserInfo)).Split(':');

            switch (info[0])
            {
            case "aes-256-cfb":
                shadowsocks.EncryptMethod = 0;
                break;

            case "aes-128-cfb":
                shadowsocks.EncryptMethod = 1;
                break;

            case "chacha20":
                shadowsocks.EncryptMethod = 2;
                break;

            case "chacha20-ietf":
                shadowsocks.EncryptMethod = 3;
                break;

            case "aes-256-gcm":
                shadowsocks.EncryptMethod = 4;
                break;

            case "aes-128-gcm":
                shadowsocks.EncryptMethod = 5;
                break;

            case "chacha20-poly1305":
                shadowsocks.EncryptMethod = 6;
                break;

            default:
                throw new Exception(string.Format("不支持的加密方式:{0}", info[0]));
            }

            shadowsocks.Password = info[1];

            return(shadowsocks);
        }
Пример #4
0
 public ServerConfigShadowsocks(Shadowsocks server)
 {
     InitializeComponent();
     DataContext = new ServerConfigShadowsocksVModel(server);
 }
Пример #5
0
        public ShadowsocksForm(Shadowsocks server = default)
        {
            InitializeComponent();

            _server = server ?? new Shadowsocks();
        }
 public ServerConfigShadowsocksVModel(Shadowsocks server)
 {
     ServerEdit = server;
 }
Пример #7
0
        public static string ShadowsocksGet(Shadowsocks shadowsocks, bool bypassChina = true)
        {
            var data = GetGeneric(bypassChina);

            var server = new Objects.v2rayConfig.Protocol.Outbound.ShadowsocksServer()
            {
                address  = shadowsocks.Address,
                port     = shadowsocks.Port,
                password = shadowsocks.Password
            };

            switch (shadowsocks.EncryptMethod)
            {
            case 0:
                server.method = "aes-256-cfb";
                break;

            case 1:
                server.method = "aes-128-cfb";
                break;

            case 2:
                server.method = "chacha20";
                break;

            case 3:
                server.method = "chacha20-ietf";
                break;

            case 4:
                server.method = "aes-256-gcm";
                break;

            case 5:
                server.method = "aes-128-gcm";
                break;

            case 6:
                server.method = "chacha20-poly1305";
                break;

            default:
                server.method = "aes-256-cfb";
                break;
            }

            data.outbounds.Insert(0, new Objects.v2rayConfig.Outbound()
            {
                protocol = "shadowsocks",
                settings = new Objects.v2rayConfig.Protocol.Outbound.Shadowsocks()
                {
                    servers = new List <Objects.v2rayConfig.Protocol.Outbound.ShadowsocksServer>()
                    {
                        server
                    }
                },
                tag = "defaultOutbound"
            });

            return(JsonConvert.SerializeObject(data));
        }