Example #1
0
        public static PkData GetAccountInfo(string accountId, string credentials)
        {
            object[]   val;
            IPkService proxy = XmlRpcProxyGen.Create <IPkService>();

            try
            {
                val = proxy.get_account_info(accountId, credentials, "");
            }
            catch (Exception e)
            {
                PkLogging.Logger(PkLogging.Level.Error, "Unable to connect to the Pagekite Service"
                                 + Environment.NewLine + "Exception: " + e.Message, true);
                val = null;
            }

            if (val == null)
            {
                return(null);
            }

            string ok = val[0].ToString();

            if (!ok.Equals("ok"))
            {
                PkLogging.Logger(PkLogging.Level.Error, "Unable to update account information");
                return(null);
            }

            XmlRpcStruct serviceStruct = (XmlRpcStruct)val[1];

            PkData data = new PkData();

            XmlRpcStruct serviceData = (XmlRpcStruct)serviceStruct["data"];

            data.ServiceInfo.Secret   = serviceData["_ss"].ToString();
            data.ServiceInfo.DaysLeft = "unknown";
            data.ServiceInfo.MbLeft   = "unknown";

            if (serviceData.Contains("days_left"))
            {
                data.ServiceInfo.DaysLeft = serviceData["days_left"].ToString();
            }
            if (serviceData.Contains("quota_mb_left"))
            {
                data.ServiceInfo.MbLeft = serviceData["quota_mb_left"].ToString();
            }

            object[] serviceKites = (object[])serviceData["kites"];

            foreach (XmlRpcStruct serviceKite in serviceKites)
            {
                PkKite kite = new PkKite();
                kite.Domain = serviceKite["domain"].ToString();
                kite.Secret = serviceKite["ssecret"].ToString();
                data.Kites.Add(kite.Domain, kite);
            }

            return(data);
        }
Example #2
0
        private void kiteDataView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex != this.kiteDataView.Columns["Details"].Index)
            {
                return;
            }

            string key  = this.kiteDataView.Rows[e.RowIndex].Cells["Domain"].Value.ToString();
            PkKite kite = new PkKite();

            kite.Domain = key;

            PkKiteUpdateEventArgs args = new PkKiteUpdateEventArgs("details", kite);

            this.OnDetails_Click(args);
        }
Example #3
0
        private void OnAdd_Click(object sender, EventArgs e)
        {
            using (PkAddKiteForm addKite = new PkAddKiteForm())
            {
                Dictionary <string, string[]> domains = PkService.GetAvailableDomains(this.data.ServiceInfo.AccountId, this.data.ServiceInfo.Credentials);

                addKite.SetComboBox(domains);

                var result = addKite.ShowDialog();

                if (result == DialogResult.OK)
                {
                    if (PkService.AddKite(this.data.ServiceInfo.AccountId, this.data.ServiceInfo.Credentials, addKite.Kitename))
                    {
                        PkKite kite = new PkKite();
                        kite.Domain = addKite.Kitename;
                        kite.Secret = this.data.ServiceInfo.Secret;
                        this.data.Kites.Add(kite.Domain, kite);
                        this.kitePanel.AddKite(kite);
                        this.data.Save();
                    }
                }
            }
        }
Example #4
0
        public void setDetails(PkKite kite, bool flying)
        {
            if (flying)
            {
                this.saveButton.Enabled = false;
            }

            this.domainLabel.Text = kite.Domain;

            this.httpCheckBox.Checked      = kite.HTTP.Enabled;
            this.httpsCheckBox.Checked     = kite.HTTPS.Enabled;
            this.sshCheckBox.Checked       = kite.SSH.Enabled;
            this.minecraftCheckBox.Checked = kite.Minecraft.Enabled;

            this.httpPortTextBox.Enabled      = kite.HTTP.Enabled;
            this.httpsPortTextBox.Enabled     = kite.HTTPS.Enabled;
            this.sshPortTextBox.Enabled       = kite.SSH.Enabled;
            this.minecraftPortTextBox.Enabled = kite.Minecraft.Enabled;

            this.httpPortTextBox.Text      = kite.HTTP.Port.ToString();
            this.httpsPortTextBox.Text     = kite.HTTPS.Port.ToString();
            this.sshPortTextBox.Text       = kite.SSH.Port.ToString();
            this.minecraftPortTextBox.Text = kite.Minecraft.Port.ToString();
        }
Example #5
0
 public PkKiteUpdateEventArgs(string Event, PkKite kite)
 {
     this.pEvent = Event;
     this.pKite  = kite;
 }
Example #6
0
        private bool AddKite(PkKite kite)
        {
            bool ok = true;

            if (ok && kite.HTTP.Enabled)
            {
                if (0 > this.pk.add_kite(kite.HTTP.Proto, kite.Domain, 0,
                                         kite.Secret,
                                         "localhost", kite.HTTP.Port))
                {
                    PkLogging.Logger(PkLogging.Level.Error,
                                     "Unable to add kite" +
                                     " | Domain: " + kite.Domain +
                                     " | Proto: " + kite.HTTP.Proto +
                                     " | Port: " + kite.HTTP.Port.ToString());
                    ok = false;
                }
            }

            if (ok && kite.HTTPS.Enabled)
            {
                if (0 > this.pk.add_kite(kite.HTTPS.Proto, kite.Domain, 0,
                                         kite.Secret,
                                         "localhost", kite.HTTPS.Port))
                {
                    PkLogging.Logger(PkLogging.Level.Error,
                                     "Unable to add kite" +
                                     " | Domain: " + kite.Domain +
                                     " | Proto: " + kite.HTTPS.Proto +
                                     " | Port: " + kite.HTTPS.Port.ToString());
                    ok = false;
                }
            }

            if (ok && kite.SSH.Enabled)
            {
                if (0 > this.pk.add_kite(kite.SSH.Proto, kite.Domain, 22,
                                         kite.Secret,
                                         "localhost", kite.SSH.Port))
                {
                    PkLogging.Logger(PkLogging.Level.Error,
                                     "Unable to add kite" +
                                     " | Domain: " + kite.Domain +
                                     " | Proto: " + kite.SSH.Proto +
                                     " | Port: " + kite.SSH.Port.ToString());
                    ok = false;
                }
            }

            if (ok && kite.Minecraft.Enabled)
            {
                if (0 > this.pk.add_kite(kite.Minecraft.Proto, kite.Domain, 0,
                                         kite.Secret,
                                         "localhost", kite.Minecraft.Port))
                {
                    PkLogging.Logger(PkLogging.Level.Error,
                                     "Unable to add kite" +
                                     " | Domain: " + kite.Domain +
                                     " | Proto: " + kite.Minecraft.Proto +
                                     " | Port: " + kite.Minecraft.Port.ToString());
                    ok = false;
                }
            }

            return(ok);
        }
Example #7
0
 private void SaveKite(PkKite kite)
 {
     kite.Secret = this.data.Kites[kite.Domain].Secret;
     this.data.Kites[kite.Domain] = kite;
     this.data.Save();
 }
Example #8
0
 public void AddKite(PkKite kite)
 {
     this.kiteDataView.Rows.Add(false, kite.Domain, "Grounded", "Details");
 }
Example #9
0
        private void OnSave_Click(object sender, EventArgs e)
        {
            this.Kite = new PkKite();

//            kite.Domain = this.domainTextBox.Text;

            this.Kite.Domain = this.domainLabel.Text;

            this.Kite.HTTP.Enabled      = this.httpCheckBox.Checked;
            this.Kite.HTTPS.Enabled     = this.httpsCheckBox.Checked;
            this.Kite.SSH.Enabled       = this.sshCheckBox.Checked;
            this.Kite.Minecraft.Enabled = this.minecraftCheckBox.Checked;

            if (this.Kite.HTTP.Enabled)
            {
                this.Kite.HTTP.Port = this.validatePort(this.httpPortTextBox.Text);

                if (this.Kite.HTTP.Port == 0)
                {
                    PkLogging.Logger(PkLogging.Level.Warning, "Invalid port number", true);
                    return;
                }
            }

            if (this.Kite.HTTPS.Enabled)
            {
                this.Kite.HTTPS.Port = this.validatePort(this.httpsPortTextBox.Text);

                if (this.Kite.HTTPS.Port == 0)
                {
                    PkLogging.Logger(PkLogging.Level.Warning, "Invalid port number", true);
                    return;
                }
            }

            if (this.Kite.SSH.Enabled)
            {
                this.Kite.SSH.Port = this.validatePort(this.sshPortTextBox.Text);

                if (this.Kite.SSH.Port == 0)
                {
                    PkLogging.Logger(PkLogging.Level.Warning, "Invalid port number", true);
                    return;
                }
            }

            if (this.Kite.Minecraft.Enabled)
            {
                this.Kite.Minecraft.Port = this.validatePort(this.minecraftPortTextBox.Text);

                if (this.Kite.Minecraft.Port == 0)
                {
                    PkLogging.Logger(PkLogging.Level.Warning, "Invalid port number", true);
                    return;
                }
            }

            /*           PkKiteUpdateEventArgs args = new PkKiteUpdateEventArgs("save", kite);
             *         PkKiteUpdateHandler handler = this.KiteUpdated;
             *
             *         if(handler != null)
             *         {
             *             handler(this, args);
             *         }
             */

            this.DialogResult = DialogResult.OK;
            this.Close();
        }