Browse Source

update: init params of Builder class

master
dnomd343 3 years ago
parent
commit
6db15fb492
  1. 6
      Builder/__init__.py
  2. 37
      demo.py

6
Builder/__init__.py

@ -60,12 +60,12 @@ class Builder(object):
self.__process = Process(self.__workDir, taskId = self.id, self.__process = Process(self.__workDir, taskId = self.id,
isStart = isStart, cmd = command, env = envVar, file = fileObject) isStart = isStart, cmd = command, env = envVar, file = fileObject)
def __init__(self, proxy: dict, taskId: str = '', isStart: bool = True, def __init__(self, proxyType: str, proxyInfo: dict, taskId: str = '', isStart: bool = True,
bind: str = default['bindAddr'], workDir: str = default['workDir']) -> None: bind: str = default['bindAddr'], workDir: str = default['workDir']) -> None:
self.id = genFlag(length = 12) if taskId == '' else taskId self.id = genFlag(length = 12) if taskId == '' else taskId
self.__workDir = workDir self.__workDir = workDir
self.proxyType = proxy['type'] self.proxyType = proxyType
self.proxyInfo = copy.copy(proxy['info']) self.proxyInfo = copy.copy(proxyInfo)
self.socksAddr = bind self.socksAddr = bind
self.socksPort = getAvailablePort() self.socksPort = getAvailablePort()
self.__loadClient(isStart) self.__loadClient(isStart)

37
demo.py

@ -6,31 +6,26 @@ from Builder import Builder
from Basis.Logger import logging from Basis.Logger import logging
proxySS = { proxySS = {
'type': 'ss', 'server': '127.0.0.1',
'info': { 'port': 12345,
'server': '127.0.0.1', 'passwd': 'dnomd343',
'port': 12345, 'method': 'aes-128-ctr',
'passwd': 'dnomd343', 'plugin': None
'method': 'aes-128-ctr',
'plugin': None
}
} }
proxySSR = { proxySSR = {
'type': 'ssr', 'server': '127.0.0.1',
'info': { 'port': 12345,
'server': '127.0.0.1', 'passwd': 'dnomd343',
'port': 12345, 'method': 'aes-128-ctr',
'passwd': 'dnomd343', 'protocol': 'origin',
'method': 'aes-128-ctr', 'protocolParam': '',
'protocol': 'origin', 'obfs': 'plain',
'protocolParam': '', 'obfsParam': '',
'obfs': 'plain',
'obfsParam': '',
}
} }
client = Builder(proxySSR) # client = Builder('ss', proxySS)
client = Builder('ssr', proxySSR)
logging.critical(client.id) logging.critical(client.id)
logging.critical(client.proxyType) logging.critical(client.proxyType)
@ -38,7 +33,7 @@ logging.critical(client.proxyInfo)
logging.critical(client.socksAddr) logging.critical(client.socksAddr)
logging.critical(client.socksPort) logging.critical(client.socksPort)
time.sleep(20) time.sleep(15)
logging.critical(client.status()) logging.critical(client.status())
client.destroy() client.destroy()

Loading…
Cancel
Save