예제 #1
0
        public static bool ChangeTransmitServer(BaseServer server)
        {
            if (SettingManager.RemoteServer == null || !SettingManager.RemoteServer.IsServerEqual(server))
            {
                ServerManager.RemoveProcess(SettingManager.RemoteServer);
                if (ServerManager.AddProcess(server, SettingManager.Configuration.LocalSocks5Port))
                {
                    SettingManager.RemoteServer = server;
                    return(true);
                }
            }

            return(false);
        }
예제 #2
0
        public static void StartServerPool()
        {
            if (ServerManager.ShadowsocksList.Count < 1)
            {
                return;
            }

            List <int> portInUse = NetworkUtil.GetPortInUse(2000);

            foreach (Shadowsocks server in ServerManager.ShadowsocksList)
            {
                int listen = NetworkUtil.GetAvailablePort(2000, portInUse);
                if (listen > 0)
                {
                    ServerManager.AddProcess(server, listen);
                    portInUse.Add(listen);
                }
            }

            SettingManager.IsServerPoolEnabled = true;
        }
예제 #3
0
        public static bool StartServer()
        {
            Config     config    = SettingManager.Configuration;
            List <int> portInUse = NetworkUtil.GetPortInUse(2000);

            // proxy port
            if (config.SystemProxyPort == 0 || portInUse.Contains(config.SystemProxyPort))
            {
                config.SystemProxyPort = NetworkUtil.GetAvailablePort(2000, portInUse);
                portInUse.Add(config.SystemProxyPort);
            }
            else
            {
                portInUse.Add(config.SystemProxyPort);
            }

            // shadowsocks port
            if (config.LocalSocks5Port == 0 || portInUse.Contains(config.LocalSocks5Port))
            {
                config.LocalSocks5Port = NetworkUtil.GetAvailablePort(2000, portInUse);
                portInUse.Add(config.LocalSocks5Port);
            }
            else
            {
                portInUse.Add(config.LocalSocks5Port);
            }

            if (!ProcPrivoxy.Start(config.SystemProxyPort, config.LocalSocks5Port))
            {
                return(false);
            }

            if (SettingManager.RemoteServer != null)
            {
                return(ServerManager.AddProcess(SettingManager.RemoteServer, config.LocalSocks5Port));
            }

            return(true);
        }