예제 #1
0
        public static void Main(string[] args)
        {
            if (args.Length >= 1)
            {
                switch (args[0])
                {
                case "-v":
                case "--version":
                    PrintVersion();
                    break;

                case "-h":
                case "--help":
                    PrintGuide();
                    break;

                default:
                    Conf.Init(args[0]);
                    Server.Start(Conf.LocalAddresses);
                    break;
                }
            }
            else
            {
                PrintGuide();
            }
        }
예제 #2
0
        public void Init(string arg)
        {
            if (Regex.IsMatch(arg, @"\bc=*"))
            {
                Conf.confPath = arg.Substring(2);
            }
            Conf.Init();

            try {
                List <string> remoteAddresses = Conf.allConf["Remote Address"];
                remoteIPEPs = CreateEndPoints(remoteAddresses);
            } catch (KeyNotFoundException) {
                Console.WriteLine("Remote HTTP Address not found.");
            }
            try {
                List <string> localHttpAddresses = Conf.allConf["Local HTTP Address"];
                localHttpIPEPs = CreateEndPoints(localHttpAddresses);
            } catch (KeyNotFoundException) {
                Console.WriteLine("Local HTTP Address not found");
            }
            try {
                List <string> localSocksAddresses = Conf.allConf["Local SOCKS Address"];
                localSocksIPEPs = CreateEndPoints(localSocksAddresses);
            } catch (KeyNotFoundException) {
                Console.WriteLine("Local SOCKS Address not found");
            }
        }
 static void Main(string[] args)
 {
     if (args.Length >= 1)
     {
         Conf.Init(args[0]);
     }
     else
     {
         Conf.Init();
     }
     Server.Start(Conf.localAddresses);
 }
예제 #4
0
        public static void Main(string[] args)
        {
            if (args.Length >= 1)
            {
                switch (args[0])
                {
                case "-v":
                case "--version":
                    PrintVersion();
                    break;

                case "-h":
                case "--help":
                    PrintGuide();
                    break;

                case "--check":
                    string confPath;
                    if (args.Length >= 2)
                    {
                        confPath = args[1];
                    }
                    else
                    {
                        Console.WriteLine(
                            "warning:\tno config file input, using default /etc/eagle-tunnel.conf");
                        confPath = @"/etc/eagle-tunnel.conf";
                    }
                    CheckConfig(confPath);
                    break;

                default:
                    if (File.Exists(args[0]))
                    {
                        Conf.Init(args[0]);
                        PrintArgs();
                        Server.Start(Conf.LocalAddresses);
                    }
                    break;
                }
            }
            else
            {
                PrintGuide();
            }
        }
예제 #5
0
        public void Init(string arg)
        {
            if (Regex.IsMatch(arg, @"\bc=*"))
            {
                Conf.confPath = arg.Substring(2);
            }
            Conf.Init();

            try
            {
                List <ArrayList> remoteHttpAddresses = Conf.allConf["Remote HTTP Address"];
                remoteHttpIPEPs = CreateEndPoints(remoteHttpAddresses);
            }
            catch (KeyNotFoundException knfe)
            {
                Console.WriteLine(knfe.Message + " Remote HTTP Address");
            }
            try
            {
                List <ArrayList> localHttpAddresses = Conf.allConf["Local HTTP Address"];
                localHttpIPEPs = CreateEndPoints(localHttpAddresses);
            }
            catch (KeyNotFoundException knfe)
            {
                Console.WriteLine(knfe.Message + " Local HTTP Address");
            }
            try
            {
                List <ArrayList> remoteSocksAddresses = Conf.allConf["Remote SOCKS Address"];
                remoteSocksIPEPs = CreateEndPoints(remoteSocksAddresses);
            }
            catch (KeyNotFoundException knfe)
            {
                Console.WriteLine(knfe.Message + " Remote SOCKS Address");
            }
            try
            {
                List <ArrayList> localSocksAddresses = Conf.allConf["Local SOCKS Address"];
                localSocksIPEPs = CreateEndPoints(localSocksAddresses);
            }
            catch (KeyNotFoundException knfe)
            {
                Console.WriteLine(knfe.Message + " Local SOCKS Address");
            }
        }
예제 #6
0
 static void Main(string[] args)
 {
     foreach (string arg in args)
     {
         if (Regex.IsMatch(arg, @"\bc=*"))
         {
             Conf.confPath = arg.Substring(2);
         }
     }
     Conf.Init();
     foreach (string arg in args)
     {
         MyConsole.Run(arg);
     }
     Conf.Close();
     MyConsole.Wait();
     MyConsole.Run("close");
 }
        public void Init(string arg)
        {
            if (Regex.IsMatch(arg, @"\bc=*"))
            {
                Conf.confPath = arg.Substring(2);
            }
            Conf.Init();

            string[] remoteHttpAddresses  = Conf.ReadValue("Remote HTTP Address");
            string[] localHttpAddresses   = Conf.ReadValue("Local HTTP Address");
            string[] remoteSocksAddresses = Conf.ReadValue("Remote SOCKS Address");
            string[] localSocksAddresses  = Conf.ReadValue("Local SOCKS Address");

            remoteHttpIPEPs  = CreateEndPoints(Conf.ReadStrs_Split(remoteHttpAddresses));
            remoteSocksIPEPs = CreateEndPoints(Conf.ReadStrs_Split(remoteSocksAddresses));
            localHttpIPEPs   = CreateEndPoints(Conf.ReadStrs_Split(localHttpAddresses));
            localSocksIPEPs  = CreateEndPoints(Conf.ReadStrs_Split(localSocksAddresses));
        }
예제 #8
0
        private static void CheckConfig(string confPath)
        {
            if (!File.Exists(confPath))
            {
                Console.WriteLine("error:\tconfig file not found: -> {0}", confPath);
                return;
            }
            Conf.Init(confPath);

            if (!Conf.allConf.ContainsKey("listen"))
            {
                Console.WriteLine("error:\tno listen");
                return;
            }
            else
            {
                string[] listen = Conf.allConf["listen"][0].Split(':');
                if (!IPAddress.TryParse(listen[0], out IPAddress ipa))
                {
                    Console.WriteLine("error:\tip for listen is invalid ip address");
                    return;
                }
                if (listen.Length >= 2)
                {
                    if (!int.TryParse(listen[1], out int port))
                    {
                        Console.WriteLine("error:\tport for listen is not an integer");
                        return;
                    }
                }
            }

            if (!Conf.allConf.ContainsKey("relayer"))
            {
                if ((Conf.allConf.ContainsKey("http") && Conf.allConf["http"][0] == "on") ||
                    (Conf.allConf.ContainsKey("socks") && Conf.allConf["socks"][0] == "on"))
                {
                    Console.WriteLine("error:\tno relayer for http or socks");
                    return;
                }
            }
            else
            {
                string[] relayer = Conf.allConf["relayer"][0].Split(':');
                if (!IPAddress.TryParse(relayer[0], out IPAddress ipa))
                {
                    Console.WriteLine("error:\tip for relayer is invalid ip address");
                    return;
                }
                if (relayer.Length >= 2)
                {
                    if (!int.TryParse(relayer[1], out int port))
                    {
                        Console.WriteLine("error:\tport for relayer is not an integer");
                        return;
                    }
                }
            }

            if (!Conf.allConf.ContainsKey("config-dir"))
            {
                Console.WriteLine("error:\tno config-dir");
                return;
            }

            if (Conf.allConf.ContainsKey("user-check") &&
                Conf.allConf["user-check"][0] == "on")
            {
                if (EagleTunnelUser.users.Count == 0)
                {
                    Console.WriteLine("error:\tuser-check is on, but there is no user");
                }
            }

            Console.WriteLine("finished:\tno error!");
        }