示例#1
0
        public Login()
        {
            InitializeComponent();
            string userid     = INIhelp.GetValue("userid");
            string userpwd    = INIhelp.GetValue("userpwd");
            string serverIp   = INIhelp.GetValue("serverip");
            string serverPort = INIhelp.GetValue("serverport");
            string saveUser   = INIhelp.GetValue("saveuser");

            if (!"false".Equals(INIhelp.GetValue("isNewVersion")))
            {
                updateMessage updateM = new updateMessage();
                INIhelp.SetValue("isNewVersion", "false");
                updateM.ShowDialog(); // 模式窗体
            }
            this.serverIP.Text   = serverIp;
            this.serverPort.Text = serverPort;
            this.userName.Text   = userid;
            this.passWord.Text   = userpwd;
            if ("true" == saveUser)
            {
                this.saveUsername.Checked = true;
            }
            else
            {
                this.saveUsername.Checked = false;
            }
        }
示例#2
0
        public static void saveConfig()
        {
            String links = "";

            for (int i = 0; i < ipconfigList.Count; i++)
            {
                links += (ipconfigList[i]["AG_IP"] + ":" + ipconfigList[i]["AG_PORT"] + ";" + ipconfigList[i]["RM_IP"] + ":" + ipconfigList[i]["RM_PORT"]);
                if (i != (ipconfigList.Count - 1))
                {
                    links += "|";
                }
            }
            INIhelp.SetValue("link", links);
        }
示例#3
0
        /// <summary>
        /// 启动服务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void startPort_Click(object sender, EventArgs e)
        {
            if (PublicVariable4CS.portOpen)
            {
                PublicVariable4CS.portOpen   = !PublicVariable4CS.portOpen;
                this.toolStripMenuItem2.Text = "开启端口映射";

                //this.startPort.Visible = false;
            }
            else
            {
                PublicVariable4CS.portOpen   = !PublicVariable4CS.portOpen;
                this.toolStripMenuItem2.Text = "停止端口映射";
                this.startPort.Visible       = false;


                int ret = this.portList.Rows.Count;
                if (ret > 0)
                {
                    for (int i = 0; i < ret - 1; i++)
                    {
                        DataGridViewRow tmpRow   = this.portList.Rows[i];
                        int[]           tmpPorts = new int[2];
                        String[]        tmpIPs   = new String[2];
                        try
                        {
                            tmpIPs[0] = tmpRow.Cells[0].Value.ToString();
                            tmpIPs[1] = tmpRow.Cells[2].Value.ToString();

                            tmpPorts[0] = int.Parse(tmpRow.Cells[1].Value.ToString());
                            tmpPorts[1] = int.Parse(tmpRow.Cells[3].Value.ToString());
                        }catch (Exception ex)
                        {
                            MessageBox.Show("第" + (i + 1) + "行不符合规范!");
                            return;
                        }

                        try {
                            object listenPort = (object)(new String[] { tmpPorts[0] + "", tmpIPs[1] + ":" + tmpPorts[1] });
                            ThreadPool.QueueUserWorkItem(new WaitCallback(localListener1), listenPort);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("启动监听程序时发生错误:" + ex.ToString());
                        }
                    }
                    string links = "";
                    string host  = "";
                    for (int i = 0; i < ret - 1; i++)
                    {
                        try
                        {
                            DataGridViewRow tmpRow = this.portList.Rows[i];
                            links += tmpRow.Cells[0].Value.ToString();
                            links += ":";
                            links += tmpRow.Cells[1].Value.ToString();
                            links += ";";
                            links += tmpRow.Cells[2].Value.ToString();
                            links += ":";
                            links += tmpRow.Cells[3].Value.ToString();
                            if (i != (ret - 2))
                            {
                                links += "|";
                            }

                            host += ("127.0.0.1:" + tmpRow.Cells[0].Value.ToString() + "|");
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("第" + (i + 1) + "行不符合规范!");
                            return;
                        }
                    }
                    if (PublicVariable4CS.UAC)
                    {
                        updateHosts(host);
                    }
                    else
                    {
                        MessageBox.Show("权限不足,代理地址无法使用,请使用127.0.0.1加代理端口号进行端口转发");
                    }
                    INIhelp.SetValue("link", links);
                }
            }
        }
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.saveUsername.Checked)
            {
                INIhelp.SetValue("userid", this.userName.Text);
                INIhelp.SetValue("userpwd", this.passWord.Text);
                INIhelp.SetValue("serverip", this.serverIP.Text);
                INIhelp.SetValue("serverport", this.serverPort.Text);
                INIhelp.SetValue("saveuser", "true");
            }
            else
            {
                INIhelp.SetValue("userid", "");
                INIhelp.SetValue("userpwd", "");
                INIhelp.SetValue("saveuser", "false");
            }
            PublicVariable4CS.UserName   = this.userName.Text;
            PublicVariable4CS.PassWord   = this.passWord.Text;
            PublicVariable4CS.ServerIP   = this.serverIP.Text;
            PublicVariable4CS.ServerPort = int.Parse(this.serverPort.Text);
            PublicVariable4CS.SaveUser   = this.saveUsername.Checked;

            PublicVariable4CS.ver = 2.0;

            PublicVariable4CS.serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPAddress  ip    = IPAddress.Parse(PublicVariable4CS.ServerIP);
            IPEndPoint point = new IPEndPoint(ip, PublicVariable4CS.ServerPort);

            try {
                //绑定IP地址和端口号
                PublicVariable4CS.serverSocket.Connect(point);
                Hashtable sendTable = new Hashtable();

                sendTable.Add("VER", PublicVariable4CS.ver);
                sendTable.Add("TYPE", "LOGIN");
                sendTable.Add("USER", PublicVariable4CS.UserName);
                sendTable.Add("PWD", PublicVariable4CS.PassWord);


                //发送登录信息
                PublicVariable4CS.serverSocket.Send(Encoding.UTF8.GetBytes(PublicVariable4CS.setMessages(sendTable)));
                byte[] dat = new byte[2048];

                String    data     = System.Text.Encoding.UTF8.GetString(dat, 0, PublicVariable4CS.serverSocket.Receive(dat));
                Hashtable getTable = PublicVariable4CS.getMessages(data);
                if ((string)getTable["TYPE"] == "LOGIN-RE")
                {
                    if ((string)getTable["RE_ANSWER"] == "TRUE")
                    {
                        PublicVariable4CS.UserDesc = (string)getTable["USERDESC"];
                        PublicVariable4CS.INHERIT  = (string)getTable["INHERIT"];
                        PublicVariable4CS.login    = true;
                        this.Close();
                    }
                    else if ((string)getTable["RE_ANSWER"] == "FALSE")
                    {
                        MessageBox.Show("登陆失败:" + (string)getTable["RE_MESSAGE"]);
                    }
                    else
                    {
                        String a = "服务器响应异常!" + data;
                        PublicVariable4CS.errorMessage(a);
                    }
                }
                else
                {
                    PublicVariable4CS.errorMessage("答复类型错误:" + (string)getTable["TYPE"]);
                }
            }
            catch (Exception ex)
            {
                PublicVariable4CS.errorMessage("服务器连接错误,请检查服务器地址是否正确,并保证网络连接正常!\n" + ex);
            }
            ;
        }