Beispiel #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string address  = txtAddress.Text;
            string port     = txtPort.Text;
            string id       = txtId.Text;
            string security = cmbSecurity.Text;
            string remarks  = txtRemarks.Text;

            if (Utils.IsNullOrEmpty(address))
            {
                UI.Show("请填写服务器地址");
                return;
            }
            if (Utils.IsNullOrEmpty(port) || !Utils.IsNumberic(port))
            {
                UI.Show("请填写正确格式服务器端口");
                return;
            }
            if (Utils.IsNullOrEmpty(id))
            {
                UI.Show("请填写密码");
                return;
            }
            if (Utils.IsNullOrEmpty(security))
            {
                UI.Show("请选择加密方式");
                return;
            }

            VmessItem vmessItem = new VmessItem();

            vmessItem.address  = address;
            vmessItem.port     = Utils.ToInt(port);
            vmessItem.id       = id;
            vmessItem.security = security;
            vmessItem.remarks  = remarks;

            if (ConfigHandler.AddShadowsocksServer(ref config, vmessItem, EditIndex) == 0)
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                UI.Show("操作失败,请检查重试");
            }
        }
Beispiel #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string address  = txtAddress.Text;
            string port     = txtPort.Text;
            string id       = txtId.Text;
            string security = cmbSecurity.Text;
            string remarks  = txtRemarks.Text;
            string ota      = cmbOta.Text;

            if (Utils.IsNullOrEmpty(address))
            {
                UI.Show(UIRes.I18N("FillServerAddress"));
                return;
            }
            if (Utils.IsNullOrEmpty(port) || !Utils.IsNumberic(port))
            {
                UI.Show(UIRes.I18N("FillCorrectServerPort"));
                return;
            }
            if (Utils.IsNullOrEmpty(id))
            {
                UI.Show(UIRes.I18N("FillPassword"));
                return;
            }
            if (Utils.IsNullOrEmpty(security))
            {
                UI.Show(UIRes.I18N("PleaseSelectEncryption"));
                return;
            }

            vmessItem.address  = address;
            vmessItem.port     = Utils.ToInt(port);
            vmessItem.id       = id;
            vmessItem.security = security;
            vmessItem.remarks  = remarks;
            vmessItem.ota      = Convert.ToBoolean(ota);

            if (ConfigHandler.AddShadowsocksServer(ref config, vmessItem, EditIndex) == 0)
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                UI.Show(UIRes.I18N("OperationFailed"));
            }
        }
Beispiel #3
0
        private void menuAddServers_Click(object sender, EventArgs e)
        {
            string clipboardData = Utils.GetClipboardData();

            if (Utils.IsNullOrEmpty(clipboardData))
            {
                return;
            }
            if (clipboardData.IndexOf("vmess") == clipboardData.LastIndexOf("vmess"))
            {
                clipboardData = clipboardData.Replace("\r\n", "").Replace("\n", "");
            }
            int countServers = 0;

            string[] arrData = clipboardData.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            foreach (string str in arrData)
            {
                string    msg;
                VmessItem vmessItem = V2rayConfigHandler.ImportFromClipboardConfig(str, out msg);
                if (vmessItem == null)
                {
                    continue;
                }
                if (vmessItem.configType == (int)EConfigType.Vmess)
                {
                    if (ConfigHandler.AddServer(ref config, vmessItem, -1) == 0)
                    {
                        countServers++;
                    }
                }
                else if (vmessItem.configType == (int)EConfigType.Shadowsocks)
                {
                    if (ConfigHandler.AddShadowsocksServer(ref config, vmessItem, -1) == 0)
                    {
                        countServers++;
                    }
                }
            }
            if (countServers > 0)
            {
                RefreshServers();
                UI.Show(string.Format("从剪贴板导入批量URL成功"));
            }
        }
Beispiel #4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string remarks = txtRemarks.Text;
            string address = txtAddress.Text;
            string port    = txtPort.Text;

            string id       = string.Empty;
            string alterId  = string.Empty;
            string security = string.Empty;
            string flow     = string.Empty;

            switch (eConfigType)
            {
            case EConfigType.VMess:
                id       = txtId.Text;
                alterId  = txtAlterId.Text;
                security = cmbSecurity.Text;
                break;

            case EConfigType.Shadowsocks:
                id       = txtId3.Text;
                security = cmbSecurity3.Text;
                break;

            case EConfigType.Socks:
                id       = txtId4.Text;
                security = txtSecurity4.Text;
                break;

            case EConfigType.VLESS:
                id       = txtId5.Text;
                flow     = cmbFlow5.Text;
                security = cmbSecurity5.Text;
                break;

            case EConfigType.Trojan:
                id   = txtId6.Text;
                flow = cmbFlow6.Text;
                break;
            }

            if (Utils.IsNullOrEmpty(address))
            {
                UI.Show(ResUI.FillServerAddress);
                return;
            }
            if (Utils.IsNullOrEmpty(port) || !Utils.IsNumberic(port))
            {
                UI.Show(ResUI.FillCorrectServerPort);
                return;
            }
            if (eConfigType == EConfigType.Shadowsocks)
            {
                if (Utils.IsNullOrEmpty(id))
                {
                    UI.Show(ResUI.FillPassword);
                    return;
                }
                if (Utils.IsNullOrEmpty(security))
                {
                    UI.Show(ResUI.PleaseSelectEncryption);
                    return;
                }
            }
            if (eConfigType != EConfigType.Socks)
            {
                if (Utils.IsNullOrEmpty(id))
                {
                    UI.Show(ResUI.FillUUID);
                    return;
                }
            }

            transportControl.EndBindingServer();

            vmessItem.remarks  = remarks;
            vmessItem.address  = address;
            vmessItem.port     = Utils.ToInt(port);
            vmessItem.id       = id;
            vmessItem.alterId  = Utils.ToInt(alterId);
            vmessItem.security = security;

            if (Utils.IsNullOrEmpty(cmbCoreType.Text))
            {
                vmessItem.coreType = null;
            }
            else
            {
                vmessItem.coreType = (ECoreType)Enum.Parse(typeof(ECoreType), cmbCoreType.Text);
            }

            int ret = -1;

            switch (eConfigType)
            {
            case EConfigType.VMess:
                ret = ConfigHandler.AddServer(ref config, vmessItem);
                break;

            case EConfigType.Shadowsocks:
                ret = ConfigHandler.AddShadowsocksServer(ref config, vmessItem);
                break;

            case EConfigType.Socks:
                ret = ConfigHandler.AddSocksServer(ref config, vmessItem);
                break;

            case EConfigType.VLESS:
                vmessItem.flow = flow;
                ret            = ConfigHandler.AddVlessServer(ref config, vmessItem);
                break;

            case EConfigType.Trojan:
                vmessItem.flow = flow;
                ret            = ConfigHandler.AddTrojanServer(ref config, vmessItem);
                break;
            }

            if (ret == 0)
            {
                DialogResult = DialogResult.OK;
            }
            else
            {
                UI.ShowWarning(ResUI.OperationFailed);
            }
        }