예제 #1
0
파일: v2ray_util.py 프로젝트: Jatteny/v2ray
def change_tls(yn, index_dict):
    if yn == "on":
        print("")
        print("1. Let’s Encrypt 生成证书(准备域名)")
        print("2. 自定义已存在的其他路径的证书(准备证书文件路径)\n")
        choice = input("请选择使用证书方式: ")
        if choice == "1":
            print("\n请将您的域名解析到本VPS的IP地址,否则程序会出错!!\n")
            local_ip = tool_box.get_ip()
            print("本机器IP地址为:" + local_ip + "\n")
            input_domain = input("请输入您绑定的域名:")
            try:
                input_ip = socket.gethostbyname(input_domain)
            except Exception:
                print("\n域名检测错误!!!\n")
                return
            if input_ip != local_ip:
                print("\n输入的域名与本机ip不符!!!\n")
                return

            print("")
            print("正在获取SSL证书,请稍等。。。")
            get_ssl.gen_cert(input_domain)
            crt_file = "/root/.acme.sh/" + input_domain + "_ecc" + "/fullchain.cer"
            key_file = "/root/.acme.sh/" + input_domain + "_ecc" + "/" + input_domain + ".key"
            write_json.write_tls("on",
                                 index_dict,
                                 crt_file=crt_file,
                                 key_file=key_file,
                                 domain=input_domain)
        elif choice == "2":
            crt_file = input("请输入证书cert文件路径: ")
            key_file = input("请输入证书key文件路径: ")
            if not os.path.exists(crt_file) or not os.path.exists(key_file):
                print("证书crt文件或者key文件指定路径不存在!\n")
                return
            domain = tool_box.get_domain_by_crt_file(crt_file)
            if not domain:
                print("证书文件有误!\n")
                return
            write_json.write_tls("on",
                                 index_dict,
                                 crt_file=crt_file,
                                 key_file=key_file,
                                 domain=domain)
        else:
            print("输入有误!\n")
            return

    elif yn == "off":
        write_json.write_tls("off", index_dict)

    print("\n操作完成!\n")
예제 #2
0
def change_tls(yn, index_dict):
    if yn == "on":
        print("\n请将您的域名解析到本VPS的IP地址,否则程序会出错!!\n")
        local_ip = tool_box.get_ip()
        print("本机器IP地址为:" + local_ip + "\n")
        input_domain=str(input("请输入您绑定的域名:"))
        try:
            input_ip = socket.gethostbyname(input_domain)
        except Exception:
            print("\n域名检测错误!!!\n")
            return
        if input_ip != local_ip:
            print("\n输入的域名与本机ip不符!!!\n")
            return

        print("")
        print("正在获取SSL证书,请稍等。")
        get_ssl.getssl(input_domain)
        write_json.write_tls("on",input_domain, index_dict)
    elif yn == "off":
        write_json.write_tls("off","", index_dict)
        
    print("\n操作完成!\n")
예제 #3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import json
import read_json
from base_util import tool_box

#写客户端配置文件函数
def write_client_json():
    my_json_dump=json.dumps(client_config,indent=1)
    with open('/root/config.json', 'w') as write_json_file:
        write_json_file.writelines(my_json_dump)

#获取本机IP地址
myip = tool_box.get_ip()

#打开服务器端配置文件
with open('/etc/v2ray/config.json', 'r') as json_file:
    config = json.load(json_file)

mul_user_conf = read_json.multiUserConf

user_index=0

if len(mul_user_conf) > 1:
    import server_info
    choice=input("请输入要生成客户端json的节点序号:")
    if tool_box.is_number(choice):
        choice = int(choice)
        if choice > 0 and choice <= len(mul_user_conf):
            user_index = choice - 1
예제 #4
0
# -*- coding: utf-8 -*-
import os
import json
import read_json
from base_util import tool_box


#写客户端配置文件函数
def write_client_json():
    my_json_dump = json.dumps(client_config, indent=1)
    with open('/root/config.json', 'w') as write_json_file:
        write_json_file.writelines(my_json_dump)


#获取本机IP地址
myip = tool_box.get_ip()

#打开服务器端配置文件
with open('/etc/v2ray/config.json', 'r') as json_file:
    config = json.load(json_file)

mul_user_conf = read_json.multiUserConf

user_index = 0

if len(mul_user_conf) > 1:
    import server_info
    choice = input("请输入要生成客户端json的节点序号:")
    if tool_box.is_number(choice):
        choice = int(choice)
        if choice > 0 and choice <= len(mul_user_conf):