Example #1
0
        public static void PingServer()
        {
            if (!MainForm.Conf.ServicesEnabled || LoginFailed || MainForm.ShuttingDown)
            {
                return;
            }

            try
            {
                int port = MainForm.Conf.ServerPort;
                if (MainForm.Conf.IPMode == "IPv6")
                {
                    port = MainForm.Conf.LANPort;
                }

                LastLiveCheck = Helper.Now;
                Debug.WriteLine("WEBSERVICE CALL: PingServer");
                bool   success;
                string ip = MainForm.IPAddressExternal(true, out success);
                if (success)
                {
                    WebsiteLive = true;
                    Wsa.PingAliveAsync(MainForm.Conf.WSUsername, MainForm.Conf.WSPassword, port,
                                       MainForm.Conf.IPMode == "IPv4", ip, MainForm.IPAddress, Guid.NewGuid());
                }
            }
            catch (Exception ex)
            {
                WebsiteLive = false;
                Logger.LogExceptionToFile(ex);
            }
        }
Example #2
0
        public static string Connect(bool tryLoopback)
        {
            if (!MainForm.Conf.ServicesEnabled)
            {
                return(WebservicesDisabledMessage);
            }
            string r = "";

            if (WebsiteLive)
            {
                int port = MainForm.Conf.ServerPort;
                if (MainForm.Conf.IPMode == "IPv6")
                {
                    port = MainForm.Conf.LANPort;
                }

                try
                {
                    bool   success;
                    string ip = MainForm.IPAddressExternal(false, out success);
                    if (success)
                    {
                        r = Wsa.Connect2(MainForm.Conf.WSUsername, MainForm.Conf.WSPassword, port,
                                         MainForm.Identifier, tryLoopback, Application.ProductVersion,
                                         MainForm.Conf.ServerName, MainForm.Conf.IPMode == "IPv4", ip, MainForm.Affiliateid,
                                         X509.SslEnabled);
                        if (r == "OK" && tryLoopback)
                        {
                            MainForm.LoopBack = true;
                        }
                    }
                    //Logger.LogMessageToFile("Webservices: " + r);
                }
                catch (Exception ex)
                {
                    Logger.LogExceptionToFile(ex);
                    WebsiteLive = false;
                }

                if (WebsiteLive)
                {
                    LoginFailed = (r == "Webservices_LoginFailed");
                    if (r != "OK")
                    {
                        Logger.LogErrorToFile("Webservices: " + r);
                        return(LocRm.GetString(r));
                    }
                    return(r);
                }
            }
            return(LocRm.GetString("iSpyDown"));
        }
Example #3
0
        private static void ForceSync(string internalIPAddress, int internalPort, string settings)
        {
            if (LoginFailed || !WebsiteLive || !MainForm.Conf.ServicesEnabled || MainForm.ShuttingDown)
                return;

            MainForm.NeedsSync = false;
            int port = MainForm.Conf.ServerPort;
            if (MainForm.Conf.IPMode == "IPv6")
                port = MainForm.Conf.LANPort;

            bool success;
            string ip = MainForm.IPAddressExternal(out success);
            Debug.WriteLine("WEBSERVICE CALL: ForceSync");
            if (success)
                Wsa.SyncAsync(MainForm.Conf.WSUsername, MainForm.Conf.WSPassword, port, internalIPAddress, internalPort, settings, MainForm.Conf.IPMode == "IPv4", ip, Guid.NewGuid());
        }
Example #4
0
        public static string[] TestConnection(string username, string password, bool tryLoopback)
        {
            var r = new string[] {};

            int port = MainForm.Conf.ServerPort;

            if (MainForm.Conf.IPMode == "IPv6")
            {
                port = MainForm.Conf.LANPort;
            }

            try
            {
                bool   success;
                string ip = MainForm.IPAddressExternal(false, out success);
                if (success)
                {
                    r           = Wsa.TestConnection2(username, password, port, MainForm.Identifier, tryLoopback, MainForm.Conf.IPMode == "IPv4", ip, X509.SslEnabled);
                    WebsiteLive = true;
                }
            }
            catch (Exception ex)
            {
                WebsiteLive = false;
                Logger.LogExceptionToFile(ex);
            }
            if (WebsiteLive)
            {
                LoginFailed = (r[0] == "Webservices_LoginFailed");
                if (r.Length == 1 && r[0] != "OK")
                {
                    r[0] = LocRm.GetString(r[0]);
                    Logger.LogErrorToFile("Webservices: " + r[0]);
                }
                if (r.Length > 3 && r[3] != "")
                {
                    r[3] = LocRm.GetString(r[3]);
                    Logger.LogErrorToFile("Webservices: " + r[3]);
                }
                return(r);
            }

            return(new[] { LocRm.GetString("iSpyDown") });
        }
Example #5
0
        private void WebservicesLoad(object sender, EventArgs e)
        {
            txtWANPort.Value        = MainForm.Conf.ServerPort;
            txtUsername.Text        = MainForm.Conf.WSUsername;
            txtPassword.Text        = MainForm.Conf.WSPassword;
            txtLANPort.Text         = MainForm.Conf.LANPort.ToString(CultureInfo.InvariantCulture);
            txtPort.Text            = MainForm.Conf.LANPort.ToString(CultureInfo.InvariantCulture);
            chkReroute.Checked      = MainForm.Conf.DHCPReroute;
            chkEnableIPv6.Checked   = !MainForm.Conf.IPv6Disabled;
            chkBindSpecific.Checked = MainForm.Conf.SpecificIP;

            chkuPNP.Checked = MainForm.Conf.UseUPNP;
            if (!chkuPNP.Checked)
            {
                chkReroute.Checked = chkReroute.Enabled = false;
            }

            bool success;

            lblIPAddresses.Text = LocRm.GetString("PublicIPAddress").Replace("[IP]", MainForm.IPAddressExternal(false, out success));
            int i2 = 0;

            foreach (IPAddress ipadd in MainForm.AddressListIPv4)
            {
                lbIPv4Address.Items.Add(ipadd.ToString());
                if (ipadd.ToString() == MainForm.AddressIPv4)
                {
                    lbIPv4Address.SelectedIndex = i2;
                }
                i2++;
            }
            if (lbIPv4Address.Items.Count > 0 && lbIPv4Address.SelectedIndex == -1)
            {
                lbIPv4Address.SelectedIndex = 0;
            }

            int i = 0;

            foreach (IPAddress ipadd in MainForm.AddressListIPv6)
            {
                lbIPv6Address.Items.Add(ipadd.ToString());
                if (ipadd.ToString() == MainForm.AddressIPv6)
                {
                    lbIPv6Address.SelectedIndex = i;
                }

                i++;
            }

            if (i == 0)
            {
                tcIPMode.TabPages.RemoveAt(1);
            }


            if (tcIPMode.TabPages.Count == 2)
            {
                switch (MainForm.Conf.IPMode)
                {
                case "IPv4":
                    tcIPMode.SelectedIndex = 0;
                    break;

                case "IPv6":
                    tcIPMode.SelectedIndex = 1;
                    break;
                }
            }
            else
            {
                tcIPMode.SelectedIndex = 0;
                MainForm.Conf.IPMode   = "IPv4";
            }
            EnableNext();
            _loaded = true;
        }