与远端建立连接,并进行验证身份.
352928
def connect(self):
        """"""
        self._client = Telnet(self.hostname, self.port)
        self.closed = False
        query = {
            "MPRPC": self.VERSION,
            "AUTH": {
                "USERNAME": self.username,
                "PASSWORD": self.password
            }
        }
        queryb = self.encoder(query)
        if self.debug is True:
            print("send auth {}".format(queryb))
        self._client.write(queryb)
        self.remote_info = self._responsehandler()
728240
function runFile(src, context) {

    // 格式作路径
    src = path.cwd(src);

    // 返回运行结果
    return runCode(fs.readFileSync(src, 'utf8'), {
        __dirname: path.dirname(src),
        __filename: src,
        ...context
    });
}
1069622
protected function _checkTableInfo() {
        // 如果不是Model类 自动记录数据表信息
        // 只在第一次执行记录
        if(empty($this->fields)) {
            // 如果数据表字段没有定义则自动获取
            if(C('DB_FIELDS_CACHE')) {
                $db   =  $this->dbName?:C('DB_NAME');
                $fields = F('_fields/'.strtolower($db.'.'.$this->tablePrefix.$this->name));
                if($fields) {
                    $this->fields   =   $fields;
                    if(!empty($fields['_pk'])){
                        $this->pk       =   $fields['_pk'];
                    }
                    return ;
                }
            }
            // 每次都会读取数据表信息
            $this->flush();
        }
    }
1011097
function analyUrl(ctx, path) {
    // 如果是标准的url，则以http或者https开头
    // 则直接发送请求不做处理
    let isUrl = /^(http:\/\/|https:\/\/)/;
    if (isUrl.test(path)) {
      return {
        url: path,
        method: ctx.method
      }
    }

    // 否则，用"?"切分URL："?"前部用以解析真实的URL
    let urlQueryArr = path.split('?');
    let urlPrefix = urlQueryArr[0] || '';

    // url前部只能包含1个或2个":"，否则报错
    let urlReg = urlPrefix.split(':');
    if (urlReg.length < 2 || urlReg.length > 3) {
      throw `Illegal proxy path：${path} !`;
    }

    let [apiName, urlMethod, urlPath] = urlReg;
    let urlOrigin = getOriginApi(api, apiName);

    if (!urlPath) {
      urlPath = urlMethod;
      urlMethod = ctx.method;
    }

    // 拼接URL
    let urlHref = url_opera.resolve(urlOrigin, urlPath)
    return {
      url: path.replace(urlPrefix, urlHref),
      method: urlMethod.toUpperCase()
    }
  }
50518
@Override
	public void run() {
		int maxNewConnections;

		while (run) {
			maxNewConnections = 0;
			try {
				if (this.lazyInit) { // 无视第一次的信号量
					this.thriftConnectionPartition.getPoolWatchThreadSignalQueue().take();
				}

				maxNewConnections = this.thriftConnectionPartition.getMaxConnections()
						- this.thriftConnectionPartition.getCreatedConnections();

				while (maxNewConnections == 0 || (this.thriftConnectionPartition.getAvailableConnections() * 100
						/ this.thriftConnectionPartition.getMaxConnections() > this.poolAvailabilityThreshold)) {
					if (maxNewConnections == 0) {
						this.thriftConnectionPartition.setUnableToCreateMoreTransactions(true);
					}

					this.thriftConnectionPartition.getPoolWatchThreadSignalQueue().take();
					if (!run) {
						break;
					}
					maxNewConnections = this.thriftConnectionPartition.getMaxConnections()
							- this.thriftConnectionPartition.getCreatedConnections();

				}

				if (maxNewConnections > 0 && !this.thriftConnectionPool.poolShuttingDown) {
					fillConnections(Math.min(maxNewConnections, this.thriftConnectionPartition.getAcquireIncrement()));

					if (this.thriftConnectionPartition.getCreatedConnections() < this.thriftConnectionPartition
							.getMinConnections()) {
						fillConnections(this.thriftConnectionPartition.getMinConnections()
								- this.thriftConnectionPartition.getCreatedConnections());

					}
				}

				if (this.thriftConnectionPool.poolShuttingDown) {
					return;
				}

			} catch (InterruptedException e) {
				// 发生中断事件 停止运行监听器
				if (logger.isDebugEnabled()) {
					logger.debug("Terminating pool watch thread");
				}
				return;
			}
		}
	}
1371197
function ivrDial($number,$userdata,$record)
    {
       //主帐号鉴权信息验证，对必选参数进行判空。
        $auth=$this->accAuth();
        if($auth!=""){
            return $auth;
        }
       // 拼接请求包体
        $body=" <Request>
                  <Appid>$this->AppId</Appid>
                  <Dial number='$number'  userdata='$userdata' record='$record'></Dial>
                </Request>";
        $this->showlog("request body = ".$body);
        // 大写的sig参数
        $sig =  strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
        // 生成请求URL
        $url="https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/ivr/dial?sig=$sig";
        $this->showlog("request url = ".$url);
        // 生成授权：主帐户Id + 英文冒号 + 时间戳。
        $authen = base64_encode($this->AccountSid . ":" . $this->Batch);
        // 生成包头
        $header = array("Accept:application/xml","Content-Type:application/xml;charset=utf-8","Authorization:$authen");
        // 发送请求
        $result = $this->curl_post($url,$body,$header);
        $this->showlog("response body = ".$result);
        $datas = simplexml_load_string(trim($result," \t\n\r"));
      //  if($datas == FALSE){
//            $datas = new stdClass();
//            $datas->statusCode = '172003';
//            $datas->statusMsg = '返回包体错误'; 
//        }
        return $datas;
    }
680410
function(data){
			//console.log(data);
			//丢弃data的第一行
			var res = '', i = 1, len = data.length;
			for(; i < len; i++){
				res += data[i].replace(/^[\t ]+/, '');
			}
			return res;
		}
75489
function callApi(params,key) {
  
  //如果没有设置URL,直接返回
  if(!params.api.url) {
     procRet(params,key);
     return;
  } 
  
  //缓存接口返回
  if (params.res.getCache && params.api.cache) {

    var cacheKey = params.res.genKey(params.domain, params.api.url, JSON.stringify(params.params));

    params.res.getCache(cacheKey, function(err, body) {
      if (!err && body) {
        debug(cacheKey + ' cached!');
        params.body = body;
        procRet(params,key);
      } else {
        callServer(params,key);
        debug(cacheKey + '  cache expired!');
      }
    });
  } else {
    callServer(params,key);
  }
}
664528
private function pars_express()
    {
        //测试下一个是不是结束标记
        if ($this->lexTree->testNext('closeTpl', false)) {
            return null;
        }
        $temp = [
            'map' => self::CODE_EXPRESS,
            'code' => '',
            'node' => '',
            'name' => null,
            'raw' => false
        ];
        $have = false;
        $code = '';
        $node = '';
        $var = null;
        while (true) {
            $ret = $this->parsNext();
            if ($ret === null) {
                if (!$have) {
                    return null;
                }
                $temp['code'] = $code;
                $temp['node'] = $node;
                if ($var) {
                    $temp['var'] = $var;
                }
                return $temp;
            }
            if ($ret['map'] == self::CODE_MODIFIER || $ret['map'] == self::CODE_RAW) {
                $temp['map'] = $ret['map'];
                $temp['code'] = $have ? $code : null;
                $temp['name'] = $ret['name'];
                $temp['node'] = $node;
                $temp['raw'] = $ret['map'] == self::CODE_RAW;
                return $temp;
            }
            if ($ret['map'] != self::CODE_EXPRESS) {
                $this->lexTree->prev();
                if (!$have) {
                    return null;
                }
                $temp['code'] = $code;
                $temp['node'] = $node;
                if ($var) {
                    $temp['var'] = $var;
                }
                return $temp;
            }
            $have = true;
            $code .= $ret['code'] === null ? '' : $ret['code'];
            if (isset($ret['var'])) {
                if ($var == null) {
                    $var = [];
                }
                $var = array_merge($var, $ret['var']);
            }
            $node = $ret['node'];
        }

    }
1232498
async function mitm(options) {
	// 不在参数解构是考虑到时候也许直接把options传给某个库
	const { origin, dest, log = false, host = '0.0.0.0', port = rand(1025, 65535) } = options;
	if (typeof origin !== 'string' || !origin || typeof dest !== 'string' || !dest) {
		throw new TypeError('origin and dest in mitm options must set correctly.');
	}

	if (origin === dest) {
		throw new Error('Same origin and dest may cause request loop.');
	}

	const [originHostname, originPort = 80] = origin.trim().toLowerCase().split(':');
	const [destHostname, destPort = 80] = dest.trim().toLowerCase().split(':');

	const server = new Server();

	// 目前只支持HTTP代理
	server.on('request', (cReq, cRes) => {
		let { hostname, port, pathname } = new URL(cReq.url);
		port = port || 80;

		let opts = {
			protocol: 'http:',
			method: cReq.method,
			path: pathname,
			headers: cReq.headers
		};
		if (hostname === originHostname && port == originPort) {
			opts.hostname = destHostname;
			opts.port = parseInt(destPort, 10);
		} else {
			opts.hostname = hostname;
			opts.port = parseInt(port, 10);
		}
		const sReq = request(opts, sRes => {
			cRes.writeHead(sRes.statusCode, sRes.statusMessage, sRes.headers);
			sRes.pipe(cRes);
		});

		sReq.on('error', function (err) {
			log && logger.error(err.message);
			this.end();
		});

		cReq.pipe(sReq);
	});

	server.on('connect', (req, cSocket, header) => {
		const [hostname, port] = req.url.split(':');
		const sSocket = createConnection(parseInt(port, 10) || 443, hostname, function () {
			cSocket.write('HTTP/1.1 200 Connection Established\r\n\r\n');
			this.write(header);
			this.pipe(cSocket).pipe(this);
		});

		sSocket.on('error', function (err) {
			log && logger.error(err.message);
			this.end();
		});

		cSocket.on('error', function (err) {
			log && logger.error(err.message);
			this.end();
		});
	});

	server.on('error', err => {
		logger.error(err.message);
	});

	// 什么傻屌操作???
	let resolve = null;
	const delayLog = new Promise(rs => resolve = rs);
	server.listen(parseInt(port, 10), host, err => {
		if (err) {
			throw err;
		}
		resolve();
	});

	await delayLog;
	logger.success(`MITM proxy listening on ${chalk.cyan.underline(`http://${host}:${port}`)} From ${chalk.cyan.underline(origin)} to ${chalk.cyan.underline(dest)}`);


	return server;
}
119460
function () {
                    var index = 0;

                    while (index < fireLength) {

                        if ([].indexOf.call(arguments, list[index]) !== -1) {

                            // 从队列中删除当前回调
                            list.splice(index, 1);

                            // 如果当前回调队列被多层嵌套执行
                            // 上几层队列也可能会受到影响
                            if (firing) {
                                if (fireQueue.length) {
                                    fireQueue.forEach(function (value, key) {
                                        // 被删除的回调位于当前索引位置前面
                                        // 当前索引位置自减1
                                        if (index <= value) {
                                            fireQueue[key]--;
                                        }
                                    });
                                }

                                // 如果被删除的函数的索引位置在fireIndex的前面
                                // fireIndex自减1

                                if (index <= fireIndex) {
                                    fireIndex--;
                                }
                            }

                            // 回调列表长度改变
                            fireLength--;
                        } else {
                            index++;
                        }
                    }

                    return this;
                }
765316
private void onConnectEnd(final int rstCode) {
        HMSAgentLog.d("connect end:" + rstCode);

        synchronized (CALLBACK_LOCK) {
            // 回调各个回调接口连接结束
            for (IClientConnectCallback callback : connCallbacks) {
                aSysnCallback(rstCode, callback);
            }
            connCallbacks.clear();

            // 恢复默认不显示
            allowResolveConnectError = false;
        }

        synchronized (STATIC_CALLBACK_LOCK) {
            // 回调各个回调接口连接结束
            for (IClientConnectCallback callback : staticCallbacks) {
                aSysnCallback(rstCode, callback);
            }
            staticCallbacks.clear();
        }
    }
911857
function callBack($from,$to,$customerSerNum,$fromSerNum,$promptTone)
	  {
        //子帐号鉴权信息验证，对必选参数进行判空。
        $auth=$this->subAuth();
        if($auth!=""){
            return $auth;
        }
        // 拼接请求包体
        if($this->BodyType=="json"){
           $body= "{'from':'$from','to':'$to','customerSerNum':'$customerSerNum','fromSerNum':'$fromSerNum','promptTone':'$promptTone'}";
        }else{
           $body= "<CallBack>
                     <from>$from</from>
                     <to>$to</to>
                     <customerSerNum>$customerSerNum</customerSerNum>
                     <fromSerNum>$fromSerNum</fromSerNum>
                     <promptTone>$promptTone</promptTone>
                   </CallBack>";
        }
        $this->showlog("request body = ".$body);
        // 大写的sig参数
        $sig =  strtoupper(md5($this->SubAccountSid . $this->SubAccountToken . $this->Batch));
        // 生成请求URL
        $url="https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/SubAccounts/$this->SubAccountSid/Calls/Callback?sig=$sig";
        $this->showlog("request url = ".$url);
        // 生成授权：子帐号Id + 英文冒号 + 时间戳
        $authen=base64_encode($this->SubAccountSid . ":" . $this->Batch);
        // 生成包头
        $header = array("Accept:application/$this->BodyType","Content-Type:application/$this->BodyType;charset=utf-8","Authorization:$authen");
        // 发请求
        $result = $this->curl_post($url,$body,$header);
        $this->showlog("response body = ".$result);
        if($this->BodyType=="json"){//JSON格式
           $datas=json_decode($result);
        }else{ //xml格式
           $datas = simplexml_load_string(trim($result," \t\n\r"));
        }
      //  if($datas == FALSE){
//            $datas = new stdClass();
//            $datas->statusCode = '172003';
//            $datas->statusMsg = '返回包体错误'; 
//        }
        return $datas;
	}
1265027
@Override
	public void run() {
		ThriftConnectionHandle<T> connection;
		long tmp;
		long nextCheckInMs = this.maxConnectionAge;

		int partitionSize = this.thriftConnectionPartition.getAvailableConnections();
		long currentTime = System.currentTimeMillis();
		for (int i = 0; i < partitionSize; i++) {
			try {
				connection = this.thriftConnectionPartition.poolFreeConnection();

				if (connection != null) {
					connection.setOriginatingPartition(this.thriftConnectionPartition);

					tmp = this.maxConnectionAge - (currentTime - connection.getConnectionCreationTimeInMs());

					if (tmp < nextCheckInMs) {
						nextCheckInMs = tmp;
					}

					// 判断连接是否过期
					if (connection.isExpired(currentTime)) {
						// 关闭连接
						closeConnection(connection);
						continue;
					}

					if (lifoMode == ServiceOrder.LIFO) {
						if (!(connection.getConnectionPartition().getFreeConnections().offer(connection))) {
							connection.internalClose();
						}
					} else {
						this.thriftConnectionPool.putConnectionBackInPartition(connection);
					}
					// 避免cpu使用率过高 进行一段时间休眠
					Thread.sleep(20L);
				}
			} catch (Throwable e) {
				logger.error("Connection max age thread exception.", e);
			}
		}

	}
1006796
function (_this) {
    // 抽屉栏滑动手势控制
    var openNavEventHandler;
    var touchStartX;
    var touchStartY;
    var swipeStartX;
    var swiping = false;
    var maybeSwiping = false;
    var $body = $('body');

    // 手势触发的范围
    var swipeAreaWidth = 24;

    function enableSwipeHandling() {
      if (!openNavEventHandler) {
        $body.on('touchstart', onBodyTouchStart);
        openNavEventHandler = onBodyTouchStart;
      }
    }

    function setPosition(translateX, closeTransform) {
      var rtlTranslateMultiplier = _this.position === 'right' ? -1 : 1;
      var transformCSS = 'translate(' + (-1 * rtlTranslateMultiplier * translateX) + 'px, 0) !important;';
      _this.$drawer.css(
        'cssText',
        'transform:' + transformCSS + (closeTransform ? 'transition: initial !important;' : '')
      );
    }

    function cleanPosition() {
      _this.$drawer.css({
        transform: '',
        transition: '',
      });
    }

    function getMaxTranslateX() {
      return _this.$drawer.width() + 10;
    }

    function getTranslateX(currentX) {
      return Math.min(
        Math.max(
          swiping === 'closing' ? (swipeStartX - currentX) : (getMaxTranslateX() + swipeStartX - currentX),
          0
        ),
        getMaxTranslateX()
      );
    }

    function onBodyTouchStart(event) {
      touchStartX = event.touches[0].pageX;
      if (_this.position === 'right') {
        touchStartX = $body.width() - touchStartX;
      }

      touchStartY = event.touches[0].pageY;

      if (_this.state !== 'opened') {
        if (touchStartX > swipeAreaWidth || openNavEventHandler !== onBodyTouchStart) {
          return;
        }
      }

      maybeSwiping = true;

      $body.on({
        touchmove: onBodyTouchMove,
        touchend: onBodyTouchEnd,
        touchcancel: onBodyTouchMove,
      });
    }

    function onBodyTouchMove(event) {
      var touchX = event.touches[0].pageX;
      if (_this.position === 'right') {
        touchX = $body.width() - touchX;
      }

      var touchY = event.touches[0].pageY;

      if (swiping) {
        setPosition(getTranslateX(touchX), true);
      } else if (maybeSwiping) {
        var dXAbs = Math.abs(touchX - touchStartX);
        var dYAbs = Math.abs(touchY - touchStartY);
        var threshold = 8;

        if (dXAbs > threshold && dYAbs <= threshold) {
          swipeStartX = touchX;
          swiping = _this.state === 'opened' ? 'closing' : 'opening';
          $.lockScreen();
          setPosition(getTranslateX(touchX), true);
        } else if (dXAbs <= threshold && dYAbs > threshold) {
          onBodyTouchEnd();
        }
      }
    }

    function onBodyTouchEnd(event) {
      if (swiping) {
        var touchX = event.changedTouches[0].pageX;
        if (_this.position === 'right') {
          touchX = $body.width() - touchX;
        }

        var translateRatio = getTranslateX(touchX) / getMaxTranslateX();

        maybeSwiping = false;
        var swipingState = swiping;
        swiping = null;

        if (swipingState === 'opening') {
          if (translateRatio < 0.92) {
            cleanPosition();
            _this.open();
          } else {
            cleanPosition();
          }
        } else {
          if (translateRatio > 0.08) {
            cleanPosition();
            _this.close();
          } else {
            cleanPosition();
          }
        }

        $.unlockScreen();
      } else {
        maybeSwiping = false;
      }

      $body.off({
        touchmove: onBodyTouchMove,
        touchend: onBodyTouchEnd,
        touchcancel: onBodyTouchMove,
      });
    }

    if (_this.options.swipe) {
      enableSwipeHandling();
    }
  }
915883
function TTFReader(options) {
            options = options || {};
            options.subset = options.subset || [];       // 子集
            options.hinting = options.hinting || false; // 不保留hints信息
            options.compound2simple = options.compound2simple || false; // 复合字形转简单字形

            this.options = options;
        }
202002
function(_bid,_cid,_data){
        var _batch = _xcache[_bid];
        if (!_batch) return;
        try{
            (_batch.h[_cid].c||f)(_data);
        }catch(ex){
            __onError(
                _bid,_cid,{
                    code:_g._$CODE_ERRCABK,
                    message:'DWR回调执行异常：'+ex.message||ex
                }
            );
        }
    }