Skip to content

Commit

Permalink
精简json template
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Nov 27, 2018
1 parent 672c0d8 commit f6a6715
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 154 deletions.
9 changes: 5 additions & 4 deletions json_template/client.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
"streamSettings": {
"security": "",
"tlsSettings": {},
"wsSettings": null,
"httpSettings": null,
"wsSettings": {},
"httpSettings": {},
"network": "tcp",
"kcpSettings": null,
"tcpSettings": null
"kcpSettings": {},
"tcpSettings": {},
"quicSettings": {}
},
"mux": {
"enabled": true
Expand Down
9 changes: 5 additions & 4 deletions json_template/client_socks.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
"streamSettings": {
"security": "",
"tlsSettings": {},
"wsSettings": null,
"httpSettings": null,
"wsSettings": {},
"httpSettings": {},
"network": "tcp",
"kcpSettings": null,
"tcpSettings": null
"kcpSettings": {},
"tcpSettings": {},
"quicSettings": {}
},
"mux": {
"enabled": true
Expand Down
7 changes: 4 additions & 3 deletions json_template/http.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"network": "tcp",
"security": "none",
"tlsSettings": {},
"httpSettings": null,
"httpSettings": {},
"tcpSettings": {
"connectionReuse": true,
"header": {
Expand Down Expand Up @@ -50,6 +50,7 @@
}
}
},
"kcpSettings": null,
"wsSettings": null
"kcpSettings": {},
"wsSettings": {},
"quicSettings": {}
}
7 changes: 4 additions & 3 deletions json_template/http2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"network": "h2",
"security": "tls",
"tlsSettings": {},
"tcpSettings": null,
"tcpSettings": {},
"httpSettings": {
"path": "/ray/"
},
"kcpSettings": null,
"wsSettings": null
"kcpSettings": {},
"wsSettings": {},
"quicSettings": {}
}
11 changes: 5 additions & 6 deletions json_template/kcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"network": "kcp",
"security": "none",
"tlsSettings": {},
"tcpSettings": null,
"httpSettings": null,
"tcpSettings": {},
"httpSettings": {},
"kcpSettings": {
"mtu": 1350,
"tti": 50,
Expand All @@ -13,10 +13,9 @@
"readBufferSize": 2,
"writeBufferSize": 2,
"header": {
"type": "none",
"request": null,
"response": null
"type": "none"
}
},
"wsSettings": null
"wsSettings": {},
"quicSettings": {}
}
22 changes: 0 additions & 22 deletions json_template/kcp_dtls.json

This file was deleted.

22 changes: 0 additions & 22 deletions json_template/kcp_srtp.json

This file was deleted.

22 changes: 0 additions & 22 deletions json_template/kcp_utp.json

This file was deleted.

22 changes: 0 additions & 22 deletions json_template/kcp_wechat.json

This file was deleted.

22 changes: 0 additions & 22 deletions json_template/kcp_wireguard.json

This file was deleted.

9 changes: 5 additions & 4 deletions json_template/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
"streamSettings": {
"security": "none",
"tlsSettings": {},
"wsSettings": null,
"httpSettings": null,
"wsSettings": {},
"httpSettings": {},
"network": "",
"kcpSettings": null,
"tcpSettings": null
"kcpSettings": {},
"tcpSettings": {},
"quicSettings": {}
}
}
],
Expand Down
5 changes: 1 addition & 4 deletions json_template/socks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@
"pass": "socks"
}
],
"udp": true,
"ip": "127.0.0.1",
"timeout": 0,
"userLevel": 0
"udp": true
}
2 changes: 1 addition & 1 deletion json_template/ss.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"settings": {
"method": "aes-128-gcm",
"password": "password",
"network":"tcp, udp"
"network":"tcp,udp"
}
}
9 changes: 5 additions & 4 deletions json_template/tcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"network": "tcp",
"security": "none",
"tlsSettings": {},
"tcpSettings": null,
"kcpSettings": null,
"wsSettings": null,
"httpSettings": null
"tcpSettings": {},
"kcpSettings": {},
"wsSettings": {},
"httpSettings": {},
"quicSettings": {}
}
9 changes: 5 additions & 4 deletions json_template/ws.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"network": "ws",
"security": "none",
"tlsSettings": {},
"tcpSettings": null,
"kcpSettings": null,
"httpSettings": null,
"tcpSettings": {},
"kcpSettings": {},
"httpSettings": {},
"wsSettings": {
"connectionReuse": true,
"path": "",
"headers": {
"Host": ""
}
}
},
"quicSettings": {}
}
19 changes: 12 additions & 7 deletions writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,24 @@ def write(self, **kw):
self.part_json["streamSettings"] = self.load_template('kcp.json')

elif self.stream_type == StreamType.KCP_UTP:
self.part_json["streamSettings"] = self.load_template('kcp_utp.json')
self.part_json["streamSettings"] = self.load_template('kcp.json')
self.part_json["streamSettings"]["kcpSettings"]["header"]["type"] = "utp"

elif self.stream_type == StreamType.KCP_SRTP:
self.part_json["streamSettings"] = self.load_template('kcp_srtp.json')
self.part_json["streamSettings"] = self.load_template('kcp.json')
self.part_json["streamSettings"]["kcpSettings"]["header"]["type"] = "srtp"

elif self.stream_type == StreamType.KCP_WECHAT:
self.part_json["streamSettings"] = self.load_template('kcp_wechat.json')
self.part_json["streamSettings"] = self.load_template('kcp.json')
self.part_json["streamSettings"]["kcpSettings"]["header"]["type"] = "wechat-video"

elif self.stream_type == StreamType.KCP_DTLS:
self.part_json["streamSettings"] = self.load_template('kcp_dtls.json')
self.part_json["streamSettings"] = self.load_template('kcp.json')
self.part_json["streamSettings"]["kcpSettings"]["header"]["type"] = "dtls"

elif self.stream_type == StreamType.KCP_WG:
self.part_json["streamSettings"] = self.load_template('kcp_wireguard.json')
self.part_json["streamSettings"] = self.load_template('kcp.json')
self.part_json["streamSettings"]["kcpSettings"]["header"]["type"] = "wireguard"

elif self.stream_type == StreamType.TCP:
self.part_json["streamSettings"] = self.load_template('tcp.json')
Expand Down Expand Up @@ -267,8 +272,8 @@ def write_tls(self, status = False, *, crt_file=None, key_file=None, domain=None
else:
if self.part_json["streamSettings"]["network"] == StreamType.H2.value:
print("关闭tls同时也会关闭HTTP/2!\n")
print("已重置为kcp utp传输方式, 若要其他方式请自行切换")
self.part_json["streamSettings"] = self.load_template('kcp_utp.json')
print("已重置为kcp传输方式, 若要其他方式请自行切换")
self.part_json["streamSettings"] = self.load_template('kcp.json')
else:
self.part_json["streamSettings"]["security"] = "none"
self.part_json["streamSettings"]["tlsSettings"] = {}
Expand Down

0 comments on commit f6a6715

Please sign in to comment.