def fill_inbounds(http_port, socks_port): http_in = load_TPL("http_in") socks_in = load_TPL("socks_in") http_in['port'] = http_port socks_in['port'] = socks_port config = load_TPL('config') config['inbounds'].append(http_in) config['inbounds'].append(socks_in) return config
def fill_quic(_c, _v): quics = load_TPL("quic") quics["header"]["type"] = _v["type"] quics["security"] = _v["host"] quics["key"] = _v["path"] _c[0]["streamSettings"]["quicSettings"] = quics return _c
def fill_tcp_http(_c, _v): tcps = load_TPL("http") tcps["header"]["type"] = _v["type"] if _v["host"] != "": # multiple host tcps["header"]["request"]["headers"]["Host"] = _v["host"].split(",") if _v["path"] != "": tcps["header"]["request"]["path"] = [_v["path"]] _c[0]["streamSettings"]["tcpSettings"] = tcps return _c
def convert(vmess_link: str): vc = parseLink(vmess_link) if vc is None: return "", "" if not check_link(vc): return "", "" ret['outbounds'] = vmess2outbounds(load_TPL("outbounds"), vc) for item in ret['outbounds']: if vmess_link.startswith(vmscheme) and 'vnext' in item['settings']: item['protocol'] = 'vmess' if not os.path.exists(CONNECTIONS_DIR): os.makedirs(CONNECTIONS_DIR) ran_str = ''.join(random.sample(string.ascii_lowercase, 12)) node_name = vc["ps"] out_path = CONNECTIONS_DIR + ("{}.json".format(ran_str)) with open(out_path, 'w') as f: f.write(json.dumps(ret, indent=4)) return ran_str, node_name
def fill_h2(_c, _v): h2s = load_TPL("h2") h2s["path"] = _v["path"] h2s["host"] = [_v["host"]] _c[0]["streamSettings"]["httpSettings"] = h2s return _c
def fill_ws(_c, _v): wss = load_TPL("ws") wss["path"] = _v["path"] wss["headers"]["Host"] = _v["host"] _c[0]["streamSettings"]["wsSettings"] = wss return _c
def fill_kcp(_c, _v): kcps = load_TPL("kcp") kcps["header"]["type"] = _v["type"] _c[0]["streamSettings"]["kcpSettings"] = kcps return _c