예제 #1
0
        static void Main(string[] args)
        {
            if (!Environment.UserInteractive)
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[] { new OutlineService() };
                ServiceBase.Run(ServicesToRun);
            }
            else
            {
                var service = new OutlineService();
                // To run as a service from the command-line:
                // service.OnStart(null);
                // System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
                if (args.Length < 2)
                {
                    ShowUsageAndExit();
                }
                switch (args[0])
                {
                case "on":
                    service.ConfigureRouting(args[1], false);
                    break;

                case "off":
                    if (args.Length < 3)
                    {
                        ShowUsageAndExit();
                    }
                    service.ResetRouting(args[1], Int32.Parse(args[2]));
                    break;

                default:
                    ShowUsageAndExit();
                    break;
                }
                Console.WriteLine($"network config: {service.GetNetworkInfo()}");
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: 84321567/vpn
        static void Main(string[] args)
        {
            if (!Environment.UserInteractive)
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[] { new OutlineService() };
                ServiceBase.Run(ServicesToRun);
            }
            else
            {
                var service = new OutlineService();
                // To run as a service from the command-line:
                // service.OnStart(null);
                // System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
                if (args.Length != 2)
                {
                    ShowUsageAndExit();
                }
                switch (args[0])
                {
                case "on":
                    service.ConfigureRouting("10.0.85.1", args[1], false);
                    break;

                case "off":
                    // "Ethernet" is the most common name but will probably need to be changed on VMs, etc.
                    service.ResetRouting(args[1], "Ethernet");
                    break;

                default:
                    ShowUsageAndExit();
                    break;
                }
                Console.WriteLine($"network config: {service.GetNetworkInfo()}");
            }
        }