2023-07-10 08:36:19 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace NetTunnelApp;
|
|
|
|
|
|
|
|
|
|
public class ServerMenuItems
|
|
|
|
|
{
|
|
|
|
|
private static string _selItems = "";
|
|
|
|
|
|
|
|
|
|
private List<ToolStripMenuItem> _menuItems = new List<ToolStripMenuItem>();
|
|
|
|
|
|
2023-07-14 09:29:02 +00:00
|
|
|
|
private static List<VirtualMathineConfig> _menuDataItems = new List<VirtualMathineConfig>();
|
|
|
|
|
|
2023-07-10 08:36:19 +00:00
|
|
|
|
public ServerMenuItems(List<VirtualMathineConfig> vmList)
|
|
|
|
|
{
|
|
|
|
|
if (_menuItems.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
_menuItems.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-14 09:29:02 +00:00
|
|
|
|
_menuDataItems.Clear();
|
|
|
|
|
_menuDataItems.AddRange(vmList);
|
|
|
|
|
|
2023-07-10 08:36:19 +00:00
|
|
|
|
foreach (var cfg in vmList)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem item = new ToolStripMenuItem();
|
|
|
|
|
|
|
|
|
|
item.Text = cfg.vmName;
|
2023-07-14 09:29:02 +00:00
|
|
|
|
item.Name = "svrMenu_" + cfg.vmId.ToString() + "_" + cfg.vmName;
|
|
|
|
|
|
2023-07-10 08:36:19 +00:00
|
|
|
|
item.Click += delegate(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var control = (ToolStripMenuItem)sender;
|
|
|
|
|
_selItems = control.Name;
|
|
|
|
|
|
|
|
|
|
foreach (var v in _menuItems)
|
|
|
|
|
{
|
|
|
|
|
v.Checked = (_selItems == v.Name);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
_menuItems.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ToolStripMenuItem> GetMenuItems()
|
|
|
|
|
{
|
|
|
|
|
return _menuItems;
|
|
|
|
|
}
|
2023-07-14 09:29:02 +00:00
|
|
|
|
|
|
|
|
|
public static VirtualMathineConfig? GetSelectItemData()
|
|
|
|
|
{
|
|
|
|
|
foreach (var k in _menuDataItems)
|
|
|
|
|
{
|
|
|
|
|
if (_selItems == "svrMenu_" + k.vmId.ToString() + "_" + k.vmName)
|
|
|
|
|
{
|
|
|
|
|
return k;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2023-07-10 08:36:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class UserClientCfg
|
|
|
|
|
{
|
|
|
|
|
///< 用户接入网关控制 ID
|
|
|
|
|
public int scgCtrlAppId;
|
|
|
|
|
|
|
|
|
|
///< 用户接入网关隧道 ID
|
|
|
|
|
public int scgTunnelAppId;
|
|
|
|
|
|
|
|
|
|
///< 用户客户端公钥
|
2023-07-14 09:29:02 +00:00
|
|
|
|
public string cliPublicKey;
|
|
|
|
|
|
|
|
|
|
///< 用户客户端私钥
|
2023-07-10 08:36:19 +00:00
|
|
|
|
public string cliPrivateKey;
|
|
|
|
|
|
|
|
|
|
///< 用户客户端隧道IP地址
|
|
|
|
|
public string cliAddress;
|
|
|
|
|
|
|
|
|
|
///< 用户虚拟机配置列表
|
|
|
|
|
public List<VirtualMathineConfig> vmList;
|
|
|
|
|
|
|
|
|
|
public UserClientCfg()
|
|
|
|
|
{
|
|
|
|
|
vmList = new List<VirtualMathineConfig>();
|
|
|
|
|
}
|
|
|
|
|
}
|