mirror of https://github.com/jumpserver/jumpserver
perf: 优化Magnus Ports端口映射配置项
parent
93e5a0ba5c
commit
c6a3a141bb
|
@ -485,8 +485,7 @@ class Config(dict):
|
||||||
'SECURITY_DATA_CRYPTO_ALGO': None,
|
'SECURITY_DATA_CRYPTO_ALGO': None,
|
||||||
'GMSSL_ENABLED': False,
|
'GMSSL_ENABLED': False,
|
||||||
# Magnus 组件需要监听的端口范围
|
# Magnus 组件需要监听的端口范围
|
||||||
'MAGNUS_DB_PORTS_START': 30000,
|
'MAGNUS_PORTS': '30000-30100',
|
||||||
'MAGNUS_DB_PORTS_LIMIT_COUNT': 1000,
|
|
||||||
|
|
||||||
# 记录清理清理
|
# 记录清理清理
|
||||||
'LOGIN_LOG_KEEP_DAYS': 200,
|
'LOGIN_LOG_KEEP_DAYS': 200,
|
||||||
|
|
|
@ -179,5 +179,4 @@ SESSION_RSA_PRIVATE_KEY_NAME = 'jms_private_key'
|
||||||
SESSION_RSA_PUBLIC_KEY_NAME = 'jms_public_key'
|
SESSION_RSA_PUBLIC_KEY_NAME = 'jms_public_key'
|
||||||
|
|
||||||
# Magnus DB Port
|
# Magnus DB Port
|
||||||
MAGNUS_DB_PORTS_START = CONFIG.MAGNUS_DB_PORTS_START
|
MAGNUS_PORTS = CONFIG.MAGNUS_PORTS
|
||||||
MAGNUS_DB_PORTS_LIMIT_COUNT = CONFIG.MAGNUS_DB_PORTS_LIMIT_COUNT
|
|
||||||
|
|
|
@ -20,15 +20,20 @@ class DBPortManager(object):
|
||||||
CACHE_KEY = 'PORT_DB_MAPPER'
|
CACHE_KEY = 'PORT_DB_MAPPER'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.port_start = settings.MAGNUS_DB_PORTS_START
|
try:
|
||||||
self.port_limit = settings.MAGNUS_DB_PORTS_LIMIT_COUNT
|
port_start, port_end = settings.MAGNUS_PORTS.split('-')
|
||||||
self.port_end = self.port_start + self.port_limit
|
port_start, port_end = int(port_start), int(port_end)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error('MAGNUS_PORTS config error: {}'.format(e))
|
||||||
|
port_start, port_end = 30000, 30100
|
||||||
|
|
||||||
|
self.port_start, self.port_end = port_start, port_end
|
||||||
# 可以使用的端口列表
|
# 可以使用的端口列表
|
||||||
self.all_available_ports = list(range(self.port_start, self.port_end))
|
self.all_available_ports = list(range(self.port_start, self.port_end + 1))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def magnus_listen_port_range(self):
|
def magnus_listen_port_range(self):
|
||||||
return f'{self.port_start}-{self.port_end - 1}'
|
return settings.MAGNUS_PORTS
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
with tmp_to_root_org():
|
with tmp_to_root_org():
|
||||||
|
|
Loading…
Reference in New Issue