Browse Source

update: Builder module

dev
dnomd343 2 years ago
parent
commit
4efa3b777b
  1. 2
      Builder/Brook.py
  2. 2
      Builder/Hysteria.py
  3. 4
      Builder/Shadowsocks.py
  4. 4
      Builder/ShadowsocksR.py
  5. 2
      Builder/V2ray.py
  6. 2
      Builder/VLESS.py
  7. 4
      Builder/VMess.py
  8. 4
      Builder/Xray.py
  9. 20
      Builder/__init__.py

2
Builder/Brook.py

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from Basis.Functions import v6AddBracket from Utils.Common import v6AddBracket
def loadOrigin(proxyInfo: dict) -> list: # origin stream def loadOrigin(proxyInfo: dict) -> list: # origin stream
return ['client'] + [ return ['client'] + [

2
Builder/Hysteria.py

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import json import json
from Basis.Functions import v6AddBracket from Utils.Common import v6AddBracket
def load(proxyInfo: dict, socksInfo: dict, configFile: str) -> tuple[list, str, dict]: def load(proxyInfo: dict, socksInfo: dict, configFile: str) -> tuple[list, str, dict]:

4
Builder/Shadowsocks.py

@ -2,8 +2,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import json import json
from Basis.Exception import buildException from Utils.Exception import buildException
from Basis.Constant import ssMethods, ssAllMethods, mbedtlsMethods from Utils.Constant import ssMethods, ssAllMethods, mbedtlsMethods
def loadConfig(proxyInfo: dict, socksInfo: dict) -> dict: # load basic config option def loadConfig(proxyInfo: dict, socksInfo: dict) -> dict: # load basic config option

4
Builder/ShadowsocksR.py

@ -2,8 +2,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import json import json
from Basis.Exception import buildException from Utils.Exception import buildException
from Basis.Constant import ssrMethods, ssrProtocols, ssrObfuscations from Utils.Constant import ssrMethods, ssrProtocols, ssrObfuscations
def load(proxyInfo: dict, socksInfo: dict, configFile: str) -> tuple[list, str, dict]: def load(proxyInfo: dict, socksInfo: dict, configFile: str) -> tuple[list, str, dict]:

2
Builder/V2ray.py

@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import copy import copy
from Basis.Exception import buildException from Utils.Exception import buildException
httpConfig = { # http obfs configure in default httpConfig = { # http obfs configure in default
'type': 'http', 'type': 'http',

2
Builder/VLESS.py

@ -3,7 +3,7 @@
import json import json
from Builder import Xray from Builder import Xray
from Basis.Exception import buildException from Utils.Exception import buildException
def load(proxyInfo: dict, socksInfo: dict, configFile: str) -> tuple[list, str, dict]: def load(proxyInfo: dict, socksInfo: dict, configFile: str) -> tuple[list, str, dict]:

4
Builder/VMess.py

@ -3,8 +3,8 @@
import json import json
from Builder import V2ray from Builder import V2ray
from Basis.Constant import vmessMethods from Utils.Constant import vmessMethods
from Basis.Exception import buildException from Utils.Exception import buildException
def load(proxyInfo: dict, socksInfo: dict, configFile: str) -> tuple[list, str, dict]: def load(proxyInfo: dict, socksInfo: dict, configFile: str) -> tuple[list, str, dict]:

4
Builder/Xray.py

@ -2,8 +2,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from Builder import V2ray from Builder import V2ray
from Basis.Constant import xtlsFlows from Utils.Constant import xtlsFlows
from Basis.Exception import buildException from Utils.Exception import buildException
loadConfig = V2ray.loadConfig loadConfig = V2ray.loadConfig

20
Builder/__init__.py

@ -4,12 +4,12 @@
import os import os
import copy import copy
from Filter import Filter from Filter import Filter
from Basis.Logger import logging from Utils.Logger import logger
from Basis.Process import Process from Utils.Process import Process
from Basis.Functions import v6AddBracket from Utils.Common import v6AddBracket
from Basis.Constant import WorkDir, PathEnv from Utils.Exception import buildException
from Basis.Functions import genFlag, getAvailablePort from Utils.Constant import WorkDir, PathEnv
from Basis.Exception import buildException, filterException from Utils.Common import genFlag, getAvailablePort
from Builder import Brook from Builder import Brook
from Builder import VMess from Builder import VMess
@ -50,14 +50,14 @@ class Builder(object):
output = None # output capture of proxy client (after process exit) output = None # output capture of proxy client (after process exit)
def __loadClient(self): def __loadClient(self):
logging.info('[%s] Builder load %s client at %s -> %s' % ( logger.info('[%s] Builder load %s client at %s -> %s' % (
self.id, self.proxyType, self.id, self.proxyType,
'socks5://%s:%i' % (v6AddBracket(self.socksAddr), self.socksPort), self.proxyInfo 'socks5://%s:%i' % (v6AddBracket(self.socksAddr), self.socksPort), self.proxyInfo
)) ))
configFile = os.path.join( # config file path configFile = os.path.join( # config file path
WorkDir, self.id + clientEntry[self.proxyType][1] # workDir + taskId + file suffix WorkDir, self.id + clientEntry[self.proxyType][1] # workDir + taskId + file suffix
) )
logging.debug('[%s] Builder config file -> %s' % (self.id, configFile)) logger.debug('[%s] Builder config file -> %s' % (self.id, configFile))
command, fileContent, envVar = clientEntry[self.proxyType][0](self.proxyInfo, { # load client boot info command, fileContent, envVar = clientEntry[self.proxyType][0](self.proxyInfo, { # load client boot info
'addr': self.socksAddr, # specify socks5 info 'addr': self.socksAddr, # specify socks5 info
'port': self.socksPort, 'port': self.socksPort,
@ -71,7 +71,7 @@ class Builder(object):
def __init__(self, proxyType: str, proxyInfo: dict, bindAddr: str, taskId: str = '') -> None: # init proxy client def __init__(self, proxyType: str, proxyInfo: dict, bindAddr: str, taskId: str = '') -> None: # init proxy client
self.id = genFlag(length = 12) if taskId == '' else taskId # load task ID self.id = genFlag(length = 12) if taskId == '' else taskId # load task ID
if proxyType not in clientEntry: if proxyType not in clientEntry:
logging.error('[%s] Builder receive unknown proxy type %s' % (self.id, proxyType)) logger.error('[%s] Builder receive unknown proxy type %s' % (self.id, proxyType))
raise buildException('Unknown proxy type') raise buildException('Unknown proxy type')
self.proxyType = proxyType # proxy type -> ss / ssr / vmess ... self.proxyType = proxyType # proxy type -> ss / ssr / vmess ...
self.proxyInfo = Filter(proxyType, proxyInfo) # filter input proxy info self.proxyInfo = Filter(proxyType, proxyInfo) # filter input proxy info
@ -84,6 +84,6 @@ class Builder(object):
return self.__process.status() return self.__process.status()
def destroy(self) -> None: # kill sub process and remove config file def destroy(self) -> None: # kill sub process and remove config file
logging.debug('[%s] Builder destroy' % self.id) logger.debug('[%s] Builder destroy' % self.id)
self.__process.quit() self.__process.quit()
self.output = self.__process.output self.output = self.__process.output

Loading…
Cancel
Save