From 4efa3b777b246f82214eff939b6a7d53b9c62a4d Mon Sep 17 00:00:00 2001 From: dnomd343 Date: Wed, 7 Sep 2022 16:58:06 +0800 Subject: [PATCH] update: Builder module --- Builder/Brook.py | 2 +- Builder/Hysteria.py | 2 +- Builder/Shadowsocks.py | 4 ++-- Builder/ShadowsocksR.py | 4 ++-- Builder/V2ray.py | 2 +- Builder/VLESS.py | 2 +- Builder/VMess.py | 4 ++-- Builder/Xray.py | 4 ++-- Builder/__init__.py | 20 ++++++++++---------- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Builder/Brook.py b/Builder/Brook.py index 99a4776..3ee6fe4 100644 --- a/Builder/Brook.py +++ b/Builder/Brook.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -from Basis.Functions import v6AddBracket +from Utils.Common import v6AddBracket def loadOrigin(proxyInfo: dict) -> list: # origin stream return ['client'] + [ diff --git a/Builder/Hysteria.py b/Builder/Hysteria.py index 2afdc4e..cc95936 100644 --- a/Builder/Hysteria.py +++ b/Builder/Hysteria.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- import json -from Basis.Functions import v6AddBracket +from Utils.Common import v6AddBracket def load(proxyInfo: dict, socksInfo: dict, configFile: str) -> tuple[list, str, dict]: diff --git a/Builder/Shadowsocks.py b/Builder/Shadowsocks.py index da6fe63..ad134d2 100644 --- a/Builder/Shadowsocks.py +++ b/Builder/Shadowsocks.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- import json -from Basis.Exception import buildException -from Basis.Constant import ssMethods, ssAllMethods, mbedtlsMethods +from Utils.Exception import buildException +from Utils.Constant import ssMethods, ssAllMethods, mbedtlsMethods def loadConfig(proxyInfo: dict, socksInfo: dict) -> dict: # load basic config option diff --git a/Builder/ShadowsocksR.py b/Builder/ShadowsocksR.py index 70549ca..8fd4ad0 100644 --- a/Builder/ShadowsocksR.py +++ b/Builder/ShadowsocksR.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- import json -from Basis.Exception import buildException -from Basis.Constant import ssrMethods, ssrProtocols, ssrObfuscations +from Utils.Exception import buildException +from Utils.Constant import ssrMethods, ssrProtocols, ssrObfuscations def load(proxyInfo: dict, socksInfo: dict, configFile: str) -> tuple[list, str, dict]: diff --git a/Builder/V2ray.py b/Builder/V2ray.py index a66709d..2adc5c5 100644 --- a/Builder/V2ray.py +++ b/Builder/V2ray.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- import copy -from Basis.Exception import buildException +from Utils.Exception import buildException httpConfig = { # http obfs configure in default 'type': 'http', diff --git a/Builder/VLESS.py b/Builder/VLESS.py index a9b6d8f..05a0260 100644 --- a/Builder/VLESS.py +++ b/Builder/VLESS.py @@ -3,7 +3,7 @@ import json 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]: diff --git a/Builder/VMess.py b/Builder/VMess.py index eebf5db..68340b7 100644 --- a/Builder/VMess.py +++ b/Builder/VMess.py @@ -3,8 +3,8 @@ import json from Builder import V2ray -from Basis.Constant import vmessMethods -from Basis.Exception import buildException +from Utils.Constant import vmessMethods +from Utils.Exception import buildException def load(proxyInfo: dict, socksInfo: dict, configFile: str) -> tuple[list, str, dict]: diff --git a/Builder/Xray.py b/Builder/Xray.py index 5726ae0..f0c945f 100644 --- a/Builder/Xray.py +++ b/Builder/Xray.py @@ -2,8 +2,8 @@ # -*- coding: utf-8 -*- from Builder import V2ray -from Basis.Constant import xtlsFlows -from Basis.Exception import buildException +from Utils.Constant import xtlsFlows +from Utils.Exception import buildException loadConfig = V2ray.loadConfig diff --git a/Builder/__init__.py b/Builder/__init__.py index 63aea63..7abb46e 100644 --- a/Builder/__init__.py +++ b/Builder/__init__.py @@ -4,12 +4,12 @@ import os import copy from Filter import Filter -from Basis.Logger import logging -from Basis.Process import Process -from Basis.Functions import v6AddBracket -from Basis.Constant import WorkDir, PathEnv -from Basis.Functions import genFlag, getAvailablePort -from Basis.Exception import buildException, filterException +from Utils.Logger import logger +from Utils.Process import Process +from Utils.Common import v6AddBracket +from Utils.Exception import buildException +from Utils.Constant import WorkDir, PathEnv +from Utils.Common import genFlag, getAvailablePort from Builder import Brook from Builder import VMess @@ -50,14 +50,14 @@ class Builder(object): output = None # output capture of proxy client (after process exit) 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, 'socks5://%s:%i' % (v6AddBracket(self.socksAddr), self.socksPort), self.proxyInfo )) configFile = os.path.join( # config file path 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 'addr': self.socksAddr, # specify socks5 info '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 self.id = genFlag(length = 12) if taskId == '' else taskId # load task ID 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') self.proxyType = proxyType # proxy type -> ss / ssr / vmess ... self.proxyInfo = Filter(proxyType, proxyInfo) # filter input proxy info @@ -84,6 +84,6 @@ class Builder(object): return self.__process.status() 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.output = self.__process.output