Exemple #1
0
        public static void _returnEth()
        {
            BridgeList._lcl_bridge("p");
            Data._lcl_bridge = Data._tmp;
            string patern = "[(ID=]+\\d+[)|]+[Operating]+g";
            string repl   = "";
            Regex  rgx    = new System.Text.RegularExpressions.Regex(patern);
            string input  = Data._lcl_bridge;
            string result1;
            string result2 = rgx.Replace(input, repl).Trim();

            if (result2.Contains("|Operating"))
            {
                string result1a = result2.Replace("|Operating", "").Replace(" ", " ").Trim();
                result1 = result1a;
            }
            else
            {
                result1 = result2;
            }

            var    ip   = "127.0.0.1";
            ushort port = 5555;
            var    pw   = "pirkon12";

            using (var softEther = new SoftEther(ip, port))
            {
                var connectResult = softEther.Connect();
                if (!connectResult.Valid())
                {
                    return;
                }
                var authResult = softEther.Authenticate(pw);
                if (!authResult.Valid())
                {
                    return;
                }
                var EthDev = softEther.ServerApi.GetEthernetDeviceList();
                for (int i = 0; i < EthDev.Elements.Count; i++)
                {
                    if (EthDev.Elements[i].DeviceName.Contains(result1))
                    {
                        Data._bridgeWindowsname = EthDev.Elements[i].NetworkConnectionName;
                    }
                }
                return;
            }
        }
Exemple #2
0
        public static void _brdgeNicName()
        {
            BridgeList._lcl_bridge("p");
            Data._lcl_bridge = Data._tmp;
            //string nic_Descr = string.Empty;
            string patern  = "[(ID=]+\\d+[)|]+[Operating]+g";
            string repl    = "";
            Regex  rgx     = new System.Text.RegularExpressions.Regex(patern);
            string input   = Data._lcl_bridge;
            string result1 = rgx.Replace(input, repl).Trim();

            if (result1.Contains("(2)"))
            {
                string relult3 = ReplaceLastOccurance(result1, "(2)", "#2");
                result            = relult3;
                Data.netnamefound = true;
            }
            else
            {
                _returnEth();
                Data.netnamefound = true;
                return;
            }

            // Console.WriteLine(result);
            NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface adapter in interfaces)
            {
                string _rt1 = adapter.Description.Trim();
                // string _rt2 = adapter.Id.Trim();
                ;
                if (_rt1 == result.Trim())

                {
                    Data._bridgeWindowsname   = adapter.Name.ToString();
                    Data._localBridgeDHCPflag = adapter.GetIPProperties().GetIPv4Properties().IsDhcpEnabled;
                }
            }

            return;
        }