forked from q158073378252010/v2ray.fun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwritejson.py
executable file
·72 lines (63 loc) · 2.37 KB
/
writejson.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import json
#打开配置文件
jsonfile = file("/etc/v2ray/config.json")
config = json.load(jsonfile)
#写入配置文件
def Write():
myjsondump=json.dumps(config,indent=1)
openjsonfile=file("/etc/v2ray/config.json","w+")
openjsonfile.writelines(myjsondump)
openjsonfile.close()
#更改UUID
def WriteUUID(myuuid):
config[u"inbound"][u"settings"][u"clients"][0][u"id"]=str(myuuid)
Write()
#更改端口
def WritePort(myport):
config[u"inbound"][u"port"]=int(myport)
Write()
#更改加密方式
def WriteSecurity(mysecurity):
config[u"inbound"][u"settings"][u"clients"][0][u"security"]=str(mysecurity)
Write()
#更改底层传输设置
def WriteStreamNetwork(network,para):
if (network == "tcp" and para=="none"):
streamfile=file("/usr/local/v2ray.fun/json_template/tcp.json")
tcp=json.load(streamfile)
config[u"inbound"][u"streamSettings"]=tcp
Write()
if (network == "tcp" and para != "none"):
streamfile=file("/usr/local/v2ray.fun/json_template/http.json")
http=json.load(streamfile)
http[u"tcpSettings"][u"header"][u"request"][u"headers"][u"Host"]=para
config[u"inbound"][u"streamSettings"]=http
Write()
if (network == "ws"):
streamfile=file("/usr/local/v2ray.fun/json_template/ws.json")
ws=json.load(streamfile)
config[u"inbound"][u"streamSettings"]=ws
Write()
if (network == "mkcp" and para=="none"):
streamfile=file("/usr/local/v2ray.fun/json_template/kcp.json")
kcp=json.load(streamfile)
config[u"inbound"][u"streamSettings"]=kcp
Write()
if (network == "mkcp" and para=="kcp utp"):
streamfile=file("/usr/local/v2ray.fun/json_template/kcp_utp.json")
utp=json.load(streamfile)
config[u"inbound"][u"streamSettings"]=utp
Write()
if (network == "mkcp" and para=="kcp srtp"):
streamfile=file("/usr/local/v2ray.fun/json_template/kcp_srtp.json")
srtp=json.load(streamfile)
config[u"inbound"][u"streamSettings"]=srtp
Write()
if (network == "mkcp" and para=="kcp wechat-video"):
streamfile=file("/usr/local/v2ray.fun/json_template/kcp_wechat.json")
wechat=json.load(streamfile)
config[u"inbound"][u"streamSettings"]=wechat
Write()