diff options
author | crupest <crupest@outlook.com> | 2023-05-31 23:55:57 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-05-31 23:55:57 +0800 |
commit | 4cc25bea963c09a1eb0f951bed1eabc75d196446 (patch) | |
tree | 2f5aa4fe9684a19463255b454162cc84d35ccc2a /tool/modules/nginx.py | |
parent | 4e6260b7d03a38be65203139631d5fda523e80af (diff) | |
download | crupest-4cc25bea963c09a1eb0f951bed1eabc75d196446.tar.gz crupest-4cc25bea963c09a1eb0f951bed1eabc75d196446.tar.bz2 crupest-4cc25bea963c09a1eb0f951bed1eabc75d196446.zip |
Add v2ray.
Diffstat (limited to 'tool/modules/nginx.py')
-rwxr-xr-x | tool/modules/nginx.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tool/modules/nginx.py b/tool/modules/nginx.py index 4f77acd..db350a7 100755 --- a/tool/modules/nginx.py +++ b/tool/modules/nginx.py @@ -50,7 +50,7 @@ def list_domains(domain: str) -> list: return [domain, *list_subdomains(domain)] -def generate_nginx_config(domain: str, dest: str) -> None: +def generate_nginx_config(domain: str, original_config, dest: str) -> None: if not isdir(dest): raise ValueError('dest must be a directory') # copy ssl.conf and https-redirect.conf which need no variable substitution @@ -58,12 +58,19 @@ def generate_nginx_config(domain: str, dest: str) -> None: src = join(nginx_template_dir, filename) dst = join(dest, filename) shutil.copyfile(src, dst) - config = {"CRUPEST_DOMAIN": domain} + config = { + "CRUPEST_DOMAIN": domain, + "CRUPEST_V2RAY_TOKEN": original_config["CRUPEST_V2RAY_TOKEN"], + "CRUPEST_V2RAY_PATH": original_config["CRUPEST_V2RAY_PATH"] + } # generate ssl.conf with open(join(dest, 'ssl.conf'), 'w') as f: f.write(ssl_template.generate(config)) # generate root.conf with open(join(dest, f'{domain}.conf'), 'w') as f: + root_config = config.copy() + root_config["CRUPEST_V2RAY_TOKEN"] = config["CRUPEST_V2RAY_TOKEN"] + root_config["CRUPEST_V2RAY_PATH"] = config["CRUPEST_V2RAY_PATH"] f.write(root_template.generate(config)) # generate nginx config for each site sites: list = server["sites"] @@ -113,7 +120,7 @@ def restart_nginx(force=False) -> bool: return True -def nginx(domain: str, /, console) -> None: +def nginx(domain: str, config, /, console) -> None: bad_files = check_nginx_config_dir(nginx_config_dir, domain) if len(bad_files) > 0: console.print( @@ -133,7 +140,7 @@ def nginx(domain: str, /, console) -> None: os.mkdir(nginx_config_dir) console.print( f"Nginx config directory created at [magenta]{nginx_config_dir}[/]", style="green") - generate_nginx_config(domain, dest=nginx_config_dir) + generate_nginx_config(domain, config, dest=nginx_config_dir) console.print("Nginx config generated.", style="green") if restart_nginx(): console.print('Nginx restarted.', style="green") |