Exemple #1
0
 public bool Set(ProxySetupXml xml)
 {
     if (Decode(xml.DeliveryServerAddr, ref DeliveryServerHost, ref DeliveryServerPort) &&
         Decode(xml.LinkProxyAddr, ref LinkProxyIP, ref LinkProxyPort))
     {
         foreach (ProxyXml pxml in xml.Proxies)
         {
             IPAddress ip1 = IPAddress.Any, ip2 = IPAddress.Any, ip3 = IPAddress.Any, ip4 = IPAddress.Any;
             ushort    port1 = 0, port2 = 0, port3 = 0, port4 = 0;
             if (Decode(pxml.UserProxyAddr, ref ip1, ref port1) && Decode(pxml.LinkServerAddr, ref ip2, ref port2) && Decode(pxml.GsProxyAddr, ref ip3, ref port3) && Decode(pxml.ProviderServerAddr, ref ip4, ref port4))
             {
                 Proxies.Add(new Tuple <Tuple <IPAddress, ushort>, Tuple <IPAddress, ushort>, Tuple <IPAddress, ushort>, Tuple <IPAddress, ushort> >(new Tuple <IPAddress, ushort>(ip1, port1), new Tuple <IPAddress, ushort>(ip2, port2), new Tuple <IPAddress, ushort>(ip3, port3), new Tuple <IPAddress, ushort>(ip4, port4)));
             }
             else
             {
                 return(false);
             }
         }
         return(true);
     }
     return(false);
 }
Exemple #2
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: ");
                Console.WriteLine("Windows: MProxy.exe Conf.xml");
                Console.WriteLine("Linux: mono MProxy.exe Conf.xml");
                return;
            }
            XmlSerializer serializer = new XmlSerializer(typeof(ProxySetupXml));

            if (!File.Exists(args[0]))
            {
                Console.WriteLine("Configuration file not found");
            }
            ProxyControl ctrl = null;

            using (StreamReader reader = new StreamReader(args[0]))
            {
                ProxySetupXml xml   = (ProxySetupXml)serializer.Deserialize(reader);
                ProxySetup    setup = new ProxySetup();
                if (!setup.Set(xml))
                {
                    Console.WriteLine("Bad format in file");
                    return;
                }
                ctrl = new ProxyControl(setup);
                ctrl.Run();
            }
            while (true)
            {
                int id = UnixSignal.WaitAny(Signals);
                if (id >= 0 && id < Signals.Length)
                {
                    return;
                }
            }
        }