Example #1
0
        private void ImportConfig()
        {
            ClearServer();

            VmessItem vmessItem = V2rayConfigHandler.ImportFromClipboardConfig(Utils.GetClipboardData(), out string msg);

            if (vmessItem == null)
            {
                UI.Show(msg);
                return;
            }

            txtAddress.Text  = vmessItem.address;
            txtPort.Text     = vmessItem.port.ToString();
            txtSecurity.Text = vmessItem.security;
            txtId.Text       = vmessItem.id;
            txtRemarks.Text  = vmessItem.remarks;
        }
Example #2
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成功"));
            }
        }
Example #3
0
        private void menuExport2ServerConfig_Click(object sender, EventArgs e)
        {
            int index = GetLvSelectedIndex();

            if (index < 0)
            {
                return;
            }
            if (config.vmess[index].configType != (int)EConfigType.Vmess)
            {
                UI.Show("非Vmess服务,此功能无效");
                return;
            }

            SaveFileDialog fileDialog = new SaveFileDialog();

            fileDialog.Filter           = "Config|*.json";
            fileDialog.FilterIndex      = 2;
            fileDialog.RestoreDirectory = true;
            if (fileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string fileName = fileDialog.FileName;

            if (Utils.IsNullOrEmpty(fileName))
            {
                return;
            }
            Config configCopy = Utils.DeepCopy <Config>(config);

            configCopy.index = index;
            string msg;

            if (V2rayConfigHandler.Export2ServerConfig(configCopy, fileName, out msg) != 0)
            {
                UI.Show(msg);
            }
            else
            {
                UI.Show(string.Format("服务端配置文件保存在:{0}", fileName));
            }
        }
Example #4
0
        private void ImportConfig()
        {
            ClearServer();

            string           msg;
            List <VmessItem> vmessItems = V2rayConfigHandler.ImportFromClipboardConfig(out msg);

            if (vmessItems == null || vmessItems.Count == 0)
            {
                UI.Show(msg);
                return;
            }

            txtAddress.Text  = vmessItems[0].address;
            txtPort.Text     = vmessItems[0].port.ToString();
            cmbSecurity.Text = vmessItems[0].security;
            txtId.Text       = vmessItems[0].id;
            txtRemarks.Text  = vmessItems[0].remarks;
        }
Example #5
0
        /// <summary>
        /// 从剪贴板导入URL
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItemImportClipboard_Click(object sender, EventArgs e)
        {
            ClearServer();

            VmessItem vmessItem = V2rayConfigHandler.ImportFromClipboardConfig(Utils.GetClipboardData(), out string msg);

            if (vmessItem == null)
            {
                UI.ShowWarning(msg);
                return;
            }

            txtAddress.Text        = vmessItem.address;
            txtPort.Text           = vmessItem.port.ToString();
            txtId.Text             = vmessItem.id;
            txtRemarks.Text        = vmessItem.remarks;
            cmbNetwork.Text        = vmessItem.network;
            cmbHeaderType.Text     = vmessItem.headerType;
            txtRequestHost.Text    = vmessItem.requestHost;
            txtPath.Text           = vmessItem.path;
            cmbStreamSecurity.Text = vmessItem.streamSecurity;
        }
Example #6
0
        /// <summary>
        /// 从剪贴板导入URL
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItemImportClipboard_Click(object sender, EventArgs e)
        {
            ClearServer();

            string           msg;
            List <VmessItem> vmessItems = V2rayConfigHandler.ImportFromClipboardConfig(out msg);

            if (vmessItems == null && vmessItems.Count == 0)
            {
                UI.Show(msg);
                return;
            }

            txtAddress.Text        = vmessItems[0].address;
            txtPort.Text           = vmessItems[0].port.ToString();
            txtId.Text             = vmessItems[0].id;
            txtAlterId.Text        = vmessItems[0].alterId.ToString();
            txtRemarks.Text        = vmessItems[0].remarks;
            cmbNetwork.Text        = vmessItems[0].network;
            cmbHeaderType.Text     = vmessItems[0].headerType;
            txtRequestHost.Text    = vmessItems[0].requestHost;
            cmbStreamSecurity.Text = vmessItems[0].streamSecurity;
        }