Esempio n. 1
0
        void AddressChangedCallback(object sender, EventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new EventArgsDelegate(AddressChangedCallback), new object[] { sender, e });
                return;
            }

            string        MyProxyNode = ConfigurationManager.AppSettings["MyProxyNode"];
            List <string> myIPs       = NetResolver.GetLocalIPAddress();

            foreach (string ip in myIPs)
            {
                string firstThreeOctets = ip.Substring(0, ip.LastIndexOf("."));
                lblLogstuff.Text = "network changed" + ip;
                log.Debug("Network status changed");

                if (MyProxyNode == firstThreeOctets) // change to current ip address
                {
                    lblLogstuff.Text = "Proxy enabled " + DateTime.Now;
                    log.Debug("IP on same subnet as Proxy...Enabling Proxy settings");
                    NetResolver.ChangeProxy(MyProxyAddress, Convert.ToInt32(MyProxyPort));
                    NetResolver.EnableProxy();
                    getData();
                    return;
                }
                else
                {
                    lblLogstuff.Text = "disabled at " + DateTime.Now;
                    NetResolver.DisableProxy();
                    getData();
                }
            }
        }
Esempio n. 2
0
        void AddressChangedCallback(object sender, EventArgs e)
        {
            try
            {
                log.Debug("AddressChangedCallback");
                string        VesselProxyNode = ConfigurationManager.AppSettings["VesselProxyNode"];
                List <string> myIPs           = NetResolver.GetLocalIPAddress();

                foreach (string ip in myIPs)
                {
                    string firstThreeOctets = ip.Substring(0, ip.LastIndexOf("."));

                    if (VesselProxyNode == firstThreeOctets) // change to current ip address
                    {
                        log.Debug("IP on same subnet as Proxy...Enabling Proxy settings at " + DateTime.Now);
                        NetResolver.ChangeProxy(VesselProxyAddress, Convert.ToInt32(VesselProxyPort));
                        NetResolver.EnableProxy();
                        //   getData();
                        return;
                    }
                    else
                    {
                        log.Debug("Disabling Proxy at " + DateTime.Now);
                        NetResolver.DisableProxy();
                        //  getData();
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
        }
Esempio n. 3
0
 private void btnTurnOn_Click(object sender, EventArgs e)
 {
     NetResolver.ChangeProxy(MyProxyAddress, Convert.ToInt32(MyProxyPort));
     NetResolver.EnableProxy();
     getData();
 }