예제 #1
0
        public static bool InitServer(string address)
        {
            try
            {
                if (pacPort != Global.pacPort)
                {
                    if (server != null)
                    {
                        server.Stop();
                        server = null;
                    }

                    if (server == null)
                    {
                        string prefixes = string.Format("http://{0}:{1}/pac/", address, Global.pacPort);
                        Utils.SaveLog("Webserver prefixes " + prefixes);

                        HttpWebServer ws = new HttpWebServer(SendResponse, prefixes);
                        ws.Run();

                        //pacPort = Global.pacPort;
                    }
                }
                Utils.SaveLog("Webserver at " + address);
            }
            catch (Exception ex)
            {
                Utils.SaveLog("Webserver InitServer " + ex.Message);
                return(false);
            }
            return(true);
        }
예제 #2
0
        public static void Init(Config config)
        {
            string address = "127.0.0.1";

            pacList = GetPacList(address);
            string prefixes = string.Format("http://{0}:{1}/pac/", address, Global.pacPort);

            Utils.SaveLog("Webserver prefixes " + prefixes);
            ws = new HttpWebServer(SendResponse, prefixes);
            ws.Run();

            if (config.allowLANConn)
            {
                List <string> lstIPAddress = Utils.GetHostIPAddress();
                if (lstIPAddress.Count <= 0)
                {
                    return;
                }
                pacListLAN = GetPacList(lstIPAddress[0]);
                string prefixesLAN = string.Format("http://{0}:{1}/pac/", lstIPAddress[0], Global.pacPort);
                Utils.SaveLog("Webserver prefixes " + prefixesLAN);
                wsLAN = new HttpWebServer(SendResponseLAN, prefixesLAN);
                wsLAN.Run();
            }
        }
예제 #3
0
        public static void InitServer(string address)
        {
            try
            {
                if (!pacList.ContainsKey(address))
                {
                    pacList.Add(address, GetPacList(address));
                }

                string prefixes = string.Format("http://{0}:{1}/pac/", address, Global.pacPort);
                Utils.SaveLog("Webserver prefixes " + prefixes);

                HttpWebServer ws = new HttpWebServer(SendResponse, prefixes);
                ws.Run();

                if (!httpWebServer.ContainsKey(address) && ws != null)
                {
                    httpWebServer.Add(address, ws);
                }
            }
            catch (Exception ex)
            {
                Utils.SaveLog("Webserver InitServer " + ex.Message);
            }
        }
예제 #4
0
        public static void Init(Config config)
        {
            pacList = GetPacList();

            string prefixes = string.Format("http://*:{0}/pac/", Global.pacPort);

            ws = new HttpWebServer(SendResponse, prefixes);
            ws.Run();
        }
예제 #5
0
        public static void Stop()
        {
            try
            {
                if (server != null)
                {
                    server.Stop();
                    server = null;
                }
                if (serverB != null)
                {
                    serverB.Stop();
                    serverB = null;
                }
            }
            catch (Exception ex)
            {
                Utils.SaveLog("Webserver Stop " + ex.Message);
            }

            //try
            //{
            //    if (httpWebServer == null)
            //    {
            //        return;
            //    }
            //    foreach (var key in httpWebServer.Keys)
            //    {
            //        Utils.SaveLog("Webserver Stop " + key.ToString());
            //        ((HttpWebServer)httpWebServer[key]).Stop();
            //    }
            //    httpWebServer.Clear();
            //}
            //catch (Exception ex)
            //{
            //    Utils.SaveLog("Webserver Stop " + ex.Message);
            //}
        }