Exemplo n.º 1
0
        //线程,处理easy_start按钮事件
        private void dispEasyStart()
        {
            //if (r.setInternetMode_AutoIP(easy_routerAcc, easy_routerPwd)!=1)//先设成自动ip以过二维码
            //{
            //    pubFun_setText_simpleButton_showUser("路由账号或密码错误", Color.Red);
            //}
            PPPOEDiceive pppoeDic = new PPPOEDiceive();     //实例化PPPOE模块
            //NKControl NK = new NKControl();                 //实例化NK_Control模块
            startNK2 NK     = new startNK2();               //实例化NK_Control模块
            network  netSup = new network();

            pppoeDic.Start();
            pubFun_setText_simpleButton_showUser("请在netkeeper上登录", Color.White);
            //NK.runNK();     //启动NK
            NK.startNk(NK.findNk());     //启动NK
            while (true)
            {
                //if (!NK.isAlive())
                //{
                //    pppoeDic.Close();   //结束抓包循环
                //    pubFun_setText_simpleButton_showUser("客户端已被关闭", Color.Red);
                //    return;
                //}
                if (pppoeDic.netAcc != null)    //如果pppoe模块抓取到了账号
                {
                    //NK.closeNK();   //结束NK
                    //NK.killNk();   //结束NK
                    pubFun_setText_simpleButton_showUser("正在处理...", Color.White);
                    if (pppoeDic.netAcc.IndexOf(netAcc()) != -1 && netAcc().Length >= 11)
                    {
                        if (r.routerType != 1)
                        {
                            r.setCloneMAC(easy_routerAcc, easy_routerPwd, "pc");                                                               //先试pc的mac
                        }
                        int callPPPOEResult = r.setInternetMode_PPPOE(easy_routerAcc, easy_routerPwd, pppoeDic.netAcc, pppoeDic.netPwd, 0, 1); //路由PPPOE拨号
                        if (callPPPOEResult == 1)                                                                                              //如果路由PPPOE拨号成功
                        {
                            pubFun_setText_simpleButton_showUser("正在检测网络连接", Color.White);
                            heartBeat hb = new heartBeat(1, 1000 * 60 * 5, netAcc(), netSup.getLocaMac()); //初始化heartbeat对象

                            if (netSup.PingIpOrDomainName("www.baidu.com"))                                //测试网络连接状态
                            {
                                hb.start();                                                                //启动心跳
                                pubFun_setText_simpleButton_showUser("网络已连接,心跳已启动", Color.White);
                                return;
                            }
                            else                                                //没连接的话尝试改变mac
                            {
                                if (r.routerType != 1)
                                {
                                    r.setCloneMAC(easy_routerAcc, easy_routerPwd, "router");        //如果没连好网尝试改变路由的克隆mac为路由的mac
                                }
                            }
                            for (int ap = 0; ap < 3; ap++)                       //最后试三遍有没有联网
                            {
                                if (netSup.PingIpOrDomainName("www.baidu.com"))
                                {
                                    hb.start(); //启动心跳
                                    pubFun_setText_simpleButton_showUser("网络已连接,心跳已启动", Color.White);
                                    return;
                                }
                                else
                                {
                                    pubFun_setText_simpleButton_showUser("网络未连接,请注意克隆MAC可用性和宽带密码正确性", Color.Red);
                                }
                            }
                        }
                        else
                        {
                            pubFun_setText_simpleButton_showUser("拨号失败,请检查路由的账号或密码", Color.Red);
                        }
                    }
                    else
                    {
                        pubFun_setText_simpleButton_showUser("客户端输入了不合法账号", Color.Red);
                    }
                    break;
                }
                Thread.Sleep(200);
            } //end of while(true) loop
        }     //end of thread method
Exemplo n.º 2
0
        private void dispNormalStart()
        {
            if (r.setInternetMode_AutoIP(easy_routerAcc, easy_routerPwd) != 1)//先设成自动ip以过二维码
            {
                pubFun_setText_simpleButton_showUser("路由账号或密码错误", Color.Red);
            }
            PPPOEDiceive pppoeDic = new PPPOEDiceive();     //实例化PPPOE模块
            startNK2     NK       = new startNK2();         //实例化NK_Control模块
            network      netSup   = new network();

            pppoeDic.Start();
            pubFun_setText_simpleButton_showUser("请在netkeeper上登录", Color.White);
            NK.startNk(NK.findNk());     //启动NK
            //Thread.Sleep(800);                              //等待NK客户端启动,以免客户端未启动就被检测到了NK已退出
            while (true)
            {
                //if (!NK.isAlive())
                //{
                //    pppoeDic.Close();   //结束抓包循环
                //    pubFun_setText_simpleButton_showUser("客户端已被关闭", Color.Red);
                //    log.writeLog("NK客户端关闭", log.msgType.warning);
                //    return;
                //}
                if (pppoeDic.netAcc != null)    //如果pppoe模块抓取到了账号
                {
                    //NK.killNk();   //结束NK
                    pubFun_setText_simpleButton_showUser("正在处理...", Color.White);
                    if (pppoeDic.netAcc.IndexOf(netAcc()) != -1 && netAcc().Length >= 11)                                         //如果pppoeDic模块抓取的账号和已授权账号一致
                    {
                        int callPPPOEResult = r.setInternetMode_PPPOE(routerAcc, routerPwd, pppoeDic.netAcc, netPwd, special, 3); //路由PPPOE拨号,手动连接
                        if (callPPPOEResult == 1)                                                                                 //如果路由PPPOE拨号成功
                        {
                            pubFun_setText_simpleButton_showUser("正在检测网络连接", Color.White);
                            heartBeat hb = new heartBeat(1, 1000 * 60 * 5, netAcc(), netSup.getLocaMac()); //初始化heartbeat对象

                            if (netSup.PingIpOrDomainName("www.baidu.com"))                                //测试网络连接状态
                            {
                                hb.start();                                                                //启动心跳
                                pubFun_setText_simpleButton_showUser("网络已连接,心跳已启动", Color.White);
                                return;
                            }
                            else                                                //没连接的话
                            {
                                if (netSup.PingIpOrDomainName("www.baidu.com")) //再试一遍是否联网
                                {
                                    hb.start();                                 //启动心跳
                                    pubFun_setText_simpleButton_showUser("网络已连接,心跳已启动", Color.White);
                                    return;
                                }
                                else
                                {
                                    pubFun_setText_simpleButton_showUser("网络未连接,请注意克隆MAC可用性和宽带密码正确性", Color.Red);
                                }
                            }
                        }
                        else
                        {
                            pubFun_setText_simpleButton_showUser("拨号失败,请检查路由的账号或密码", Color.Red);
                        }
                    }
                    else
                    {
                        pubFun_setText_simpleButton_showUser("客户端输入了不合法账号", Color.Red);
                    }
                    break;
                }
                Thread.Sleep(200);
            }   //end of while(true) loop
        }