Skip to content

Commit

Permalink
add vmess grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Nov 15, 2021
1 parent 24aaf09 commit a8d086a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion v2ray
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# bash completion for v2ray/xray
function _auto_tab() {
local options_array=("start" "stop" "restart" "status" "update" "update.sh" "add" "del" "info" "port" "tls" "tfo" "stream" "iptables" "cdn" "stats" "clean" "log" "new" "rm" "-h" "-v" "help" "version")
local add_array=("wechat" "utp" "srtp" "dtls" "wireguard" "socks" "mtproto" "ss" "vless_tcp" "vless_tls" "vless_ws" "vless_xtls" "trojan" "ss" "quic" "h2" "tcp" "tcp_host" "ws" "vless_kcp" "vless_utp" "vless_srtp" "vless_dtls" "vless_wechat" "vless_wireguard" "vless_grpc")
local add_array=("wechat" "utp" "srtp" "dtls" "grpc" "wireguard" "socks" "mtproto" "ss" "vless_tcp" "vless_tls" "vless_ws" "vless_xtls" "trojan" "ss" "quic" "h2" "tcp" "tcp_host" "ws" "vless_kcp" "vless_utp" "vless_srtp" "vless_dtls" "vless_wechat" "vless_wireguard" "vless_grpc")
local log_array=("access" "a" "error" "e")
local cur prev

Expand Down
6 changes: 6 additions & 0 deletions v2ray_util/config_modify/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, group_tag='A', group_index=-1):
(StreamType.MTPROTO, "MTProto"),
(StreamType.SS, "Shadowsocks"),
(StreamType.QUIC, "Quic"),
(StreamType.GRPC, "gRPC"),
(StreamType.VLESS_KCP, "VLESS + mkcp"),
(StreamType.VLESS_UTP, "VLESS + mKCP + utp"),
(StreamType.VLESS_SRTP, "VLESS + mKCP + srtp"),
Expand Down Expand Up @@ -94,6 +95,11 @@ def select(self, sType):
choice = readchar(_("open xray grpc multiMode?(y/n): ")).lower()
if choice == 'y':
kw = {'mode': 'multi'}

elif sType == StreamType.GRPC:
choice = readchar(_("open xray grpc multiMode?(y/n): ")).lower()
if choice == 'y':
kw = {'mode': 'multi'}

elif sType == StreamType.TROJAN:
port_set = all_port()
Expand Down
1 change: 1 addition & 0 deletions v2ray_util/util_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class StreamType(Enum):
MTPROTO = 'mtproto'
H2 = 'h2'
WS = 'ws'
GRPC = 'grpc'
QUIC = 'quic'
KCP = 'kcp'
KCP_UTP = 'utp'
Expand Down
17 changes: 17 additions & 0 deletions v2ray_util/util_core/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,23 @@ def write(self, **kw):
ws["wsSettings"]["headers"]["Host"] = kw['host']
self.part_json["streamSettings"] = ws

elif self.stream_type == StreamType.GRPC:
alpn = ["h2"]
self.part_json["streamSettings"] = self.load_template('tcp.json')
self.part_json["streamSettings"]["network"] = "grpc"
self.part_json["streamSettings"]["grpcSettings"]["serviceName"] = ''.join(random.sample(string.ascii_letters + string.digits, 8))
if "mode" in kw and kw["mode"] == "multi":
self.part_json["streamSettings"]["grpcSettings"]["multiMode"] = True
if "fallbacks" in self.part_json["settings"]:
del self.part_json["settings"]["fallbacks"]
self.save()
if not "certificates" in tls_settings_backup:
from ..config_modify.tls import TLSModifier
tm = TLSModifier(self.group_tag, self.group_index, alpn=alpn)
tm.turn_on(False)
return
tls_settings_backup["alpn"] = alpn

elif "vless" in self.stream_type.value:
alpn = ["http/1.1"]
vless = self.load_template('vless.json')
Expand Down

0 comments on commit a8d086a

Please sign in to comment.