Ejemplo n.º 1
0
        public void Initialize()
        {
            OnClientMessageEvent("VPN初始化开始...");
            string initProcessMessage = "";
            this.AllUsersPhoneBook = new RasPhoneBook();
            this.Dialer = new RasDialer();
            if (!checkdnspoisoning("vpn.51sync.com"))
            {
                //kryptotelurlbackup = "http://200.63.44.24";
                //kryptotelurl = "http://216.185.105.35";
                initProcessMessage += "认证网络失败";
            }
            else
                initProcessMessage += "认证网络正常";
            updateIpaddress();
            if (!checkdnspoisoning("vpn.51sync.com"))
            {
                //vpnoneclickurl = "http://216.185.105.35/vpnoneclick";
                initProcessMessage += ";VPN网络不正常";
            }
            else
            {
                initProcessMessage += ";VPN网络正常";
            }
            /**
            this.macAdd = macAddress = this.GetMACAddress();
            this.GetUserNamePassword(macAddress);
            while (this.subscriptiontype != "ELITE" || DateTime.Parse(this.expiringDate).Date < DateTime.Now.Date)
            {
                macAddress = GenNewMac(macAddress);
                OnClientMessageEvent("认证信息修正+" + generateNewMACCount);
                generateNewMACCount++;
                this.GetUserNamePassword(macAddress);
            }
            if (this.macAdd != macAddress)
            {
                OnClientMessageEvent("绑定到本机当前MAC的试用许可已过期。");
                OnClientMessageEvent("将本机MAC地址修改为"+macAddress.Replace(":","").ToUpper()+"以绕过版本许可限制。");
            }
            */
            this.Initialized = true;
            OnClientMessageEvent(initProcessMessage);
            RasConnection conn = GetActiveConnection();
            if (conn != null)
            {
                OnClientMessageEvent("当前活动VPN连接:" + conn.EntryName + "");
                this.connectionVar = conn;
                this.connectionstatus = connectionVar.GetConnectionStatus();
                this.connectionHandle = connectionVar.Handle;
                this.flagConnected = true;
                this.lastServerUsed = conn.EntryName;
                this.Dialer.EntryName = conn.EntryName;
                this.Dialer.PhoneBookPath = RasPhoneBook.GetPhoneBookPath(RasPhoneBookType.User);
                this.Dialer.Credentials = new NetworkCredential(this.userName, this.passWord);
            }
            OnInitializeCompletedEvent();
            OnClientMessageEvent("VPN初始化完成," + ((this.publicIpAddress.Trim().Length == 0) ? ("外网IP检测失败,请访问http://ip138.com查看") : "当前连接IP:" + this.publicIpAddress + ",请点击连接"));

        }
Ejemplo n.º 2
0
        public void GetConnectionStatusTest()
        {
            RasConnectionStatus expected = new RasConnectionStatus()
            {
                ConnectionState = RasConnectionState.Connected
            };

            Mock<IRasHelper> mock = new Mock<IRasHelper>();
            RasHelper.Instance = mock.Object;

            mock.Setup(o => o.GetConnectionStatus(It.IsAny<RasHandle>())).Returns(expected);

            RasConnection target = new RasConnection();
            RasConnectionStatus actual = target.GetConnectionStatus();

            Assert.AreSame(expected, actual);
        }
Ejemplo n.º 3
0
 public void checkConnectionStatus()
 {
     try
     {
         if (connectionVar != null)
         {
             this.connectionstatus = this.connectionVar.GetConnectionStatus();
             OnConnectionStatusChangedEvent(this.connectionstatus.ConnectionState);
         }
         else
         {
             OnConnectionStatusChangedEvent(RasConnectionState.Disconnected);
             OnClientDialCompleted(this, new DialCompletedEventArgs(null, null, false, false, false, null));
             this.flagConnected = false;
         }
     }
     catch (Exception exception1)
     {
         OnClientExceptionEvent(exception1);
     }
 }