feat(nodes): Implement advanced node management and certificate generation
This commit is contained in:
@ -35,7 +35,7 @@ class Command(Enum):
|
||||
SHOW_USER_URI = os.path.join(SCRIPT_DIR, 'hysteria2', 'show_user_uri.py')
|
||||
WRAPPER_URI = os.path.join(SCRIPT_DIR, 'hysteria2', 'wrapper_uri.py')
|
||||
IP_ADD = os.path.join(SCRIPT_DIR, 'hysteria2', 'ip.py')
|
||||
NODE_MANAGER = os.path.join(SCRIPT_DIR, 'hysteria2', 'node.py')
|
||||
NODE_MANAGER = os.path.join(SCRIPT_DIR, 'nodes', 'node.py')
|
||||
MANAGE_OBFS = os.path.join(SCRIPT_DIR, 'hysteria2', 'manage_obfs.py')
|
||||
MASQUERADE_SCRIPT = os.path.join(SCRIPT_DIR, 'hysteria2', 'masquerade.py')
|
||||
EXTRA_CONFIG_SCRIPT = os.path.join(SCRIPT_DIR, 'hysteria2', 'extra_config.py')
|
||||
@ -464,11 +464,16 @@ def edit_ip_address(ipv4: str, ipv6: str):
|
||||
if ipv6:
|
||||
run_cmd(['python3', Command.IP_ADD.value, 'edit', '-6', ipv6])
|
||||
|
||||
def add_node(name: str, ip: str):
|
||||
def add_node(name: str, ip: str, sni: Optional[str] = None, pinSHA256: Optional[str] = None):
|
||||
"""
|
||||
Adds a new external node.
|
||||
"""
|
||||
return run_cmd(['python3', Command.NODE_MANAGER.value, 'add', '--name', name, '--ip', ip])
|
||||
command = ['python3', Command.NODE_MANAGER.value, 'add', '--name', name, '--ip', ip]
|
||||
if sni:
|
||||
command.extend(['--sni', sni])
|
||||
if pinSHA256:
|
||||
command.extend(['--pinSHA256', pinSHA256])
|
||||
return run_cmd(command)
|
||||
|
||||
def delete_node(name: str):
|
||||
"""
|
||||
@ -482,6 +487,12 @@ def list_nodes():
|
||||
"""
|
||||
return run_cmd(['python3', Command.NODE_MANAGER.value, 'list'])
|
||||
|
||||
def generate_node_cert():
|
||||
"""
|
||||
Generates a self-signed certificate for nodes.
|
||||
"""
|
||||
return run_cmd(['python3', Command.NODE_MANAGER.value, 'generate-cert'])
|
||||
|
||||
def update_geo(country: str):
|
||||
'''
|
||||
Updates geographic data files based on the specified country.
|
||||
@ -775,4 +786,4 @@ def get_ip_limiter_config() -> dict[str, int | None]:
|
||||
except Exception as e:
|
||||
print(f"Error reading IP Limiter config from .configs.env: {e}")
|
||||
return {"block_duration": None, "max_ips": None}
|
||||
# endregion
|
||||
# endregion
|
||||
Reference in New Issue
Block a user