text
stringlengths 1
93.6k
|
|---|
try:
|
return generator.next()
|
except StopIteration as stop:
|
return ""
|
spaces = set(['\x00', ' ', '\t', '\r'])
|
spaces_and_newlines = set(['\x00', ' ', '\t', '\r', '\n'])
|
# <FILESEP>
|
#!/usr/bin/env python
|
# -*- coding: UTF-8 -*-
|
# 建议Python 2.7.9 或 Python 3.4.2 以上运行
|
# 项目地址: https://github.com/hauntek/python-ngrok
|
# Version: v1.56
|
from gevent import monkey; monkey.patch_all()
|
import socket
|
import ssl
|
import json
|
import struct
|
import random
|
import sys
|
import time
|
import logging
|
# import threading
|
import gevent
|
host = 'tunnel.qydev.com' # Ngrok服务器地址
|
port = 4443 # 端口
|
bufsize = 1024 # 吞吐量
|
dualstack = 'IPv4/IPv6' # 服务连接协议 [IPv4/IPv6=双栈]
|
dualstack_or = 0 # 本地转发协议 [0=双栈, 1=IPv4, 2=IPv6]
|
Tunnels = list() # 全局渠道赋值
|
body = dict()
|
body['protocol'] = 'http'
|
body['hostname'] = 'www.xxx.com'
|
body['subdomain'] = ''
|
body['rport'] = 0
|
body['lhost'] = '127.0.0.1'
|
body['lport'] = 80
|
Tunnels.append(body) # 加入渠道队列
|
body = dict()
|
body['protocol'] = 'http'
|
body['hostname'] = ''
|
body['subdomain'] = 'xxx'
|
body['rport'] = 0
|
body['lhost'] = '127.0.0.1'
|
body['lport'] = 80
|
Tunnels.append(body) # 加入渠道队列
|
body = dict()
|
body['protocol'] = 'tcp'
|
body['hostname'] = ''
|
body['subdomain'] = ''
|
body['rport'] = 55499
|
body['lhost'] = '127.0.0.1'
|
body['lport'] = 22
|
Tunnels.append(body) # 加入渠道队列
|
reqIdaddr = dict()
|
localaddr = dict()
|
# 读取配置文件
|
if len(sys.argv) >= 2:
|
file_object = open(sys.argv[1])
|
try:
|
all_the_text = file_object.read()
|
config_object = json.loads(all_the_text)
|
host = config_object["server"]["host"] # Ngrok服务器地址
|
port = int(config_object["server"]["port"]) # 端口
|
bufsize = int(config_object["server"]["bufsize"]) # 吞吐量
|
Tunnels = list() # 重置渠道赋值
|
for Tunnel in config_object["client"]:
|
body = dict()
|
body['protocol'] = Tunnel["protocol"]
|
body['hostname'] = Tunnel["hostname"]
|
body['subdomain'] = Tunnel["subdomain"]
|
body['rport'] = int(Tunnel["rport"])
|
body['lhost'] = Tunnel["lhost"]
|
body['lport'] = int(Tunnel["lport"])
|
Tunnels.append(body) # 加入渠道队列
|
del all_the_text
|
del config_object
|
except Exception:
|
# logger = logging.getLogger('%s' % 'config')
|
# logger.error('The configuration file read failed')
|
# exit(1)
|
pass
|
finally:
|
file_object.close()
|
mainsocket = 0
|
ClientId = ''
|
pingtime = 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.