Skip to content

Commit

Permalink
support v2rayN quic share link
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Apr 11, 2019
1 parent fcdc3be commit 7353bce
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 29 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
> v3.2.0
* 修复单独pip安装时因为翻译'_'模块无法使用的问题
* 支持v2rayN quic vmess分享格式

> v3.1.0
* 修复翻译错误, 流量统计乱码

Expand Down
6 changes: 2 additions & 4 deletions v2ray_util/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
__version__ = '3.1.0'
__version__ = '3.2.0'

from .util_core.utils import i18n_create

i18n_create()
from .util_core.trans import _
4 changes: 1 addition & 3 deletions v2ray_util/config_modify/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from ..util_core.utils import i18n_create

i18n_create()
from ..util_core.trans import _
4 changes: 1 addition & 3 deletions v2ray_util/global_setting/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from ..util_core.utils import i18n_create

i18n_create()
from ..util_core.trans import _
4 changes: 1 addition & 3 deletions v2ray_util/util_core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from .utils import i18n_create

i18n_create()
from .trans import _
6 changes: 5 additions & 1 deletion v2ray_util/util_core/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ def __init__(self, uuid, alter_id: int, network: str, user_number, *, path=None,
self.host = host
self.header = header
self.quic = quic
if quic:
self.header = quic.header
self.host = quic.security
self.path = quic.key

def stream(self):
if self.network == "quic":
Expand Down Expand Up @@ -137,7 +141,7 @@ def link(self, ip, port, tls):
"tls": tls
}
json_data = json.dumps(json_dict)
result_link = "vmess://{}".format(bytes.decode(base64.b64encode(bytes(json_data, 'utf-8')))) if self.network != 'quic' else ''
result_link = "vmess://{}".format(bytes.decode(base64.b64encode(bytes(json_data, 'utf-8'))))
return ColorStr.green(result_link)

class Group:
Expand Down
17 changes: 17 additions & 0 deletions v2ray_util/util_core/trans.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import gettext
import pkg_resources

lang = 'en'
if os.path.exists('/etc/v2ray_util/util.cfg'):
from .config import Config
lang = Config().get_data('lang')
if lang == 'zh':
trans = gettext.translation('lang', pkg_resources.resource_filename('v2ray_util', 'locale_i18n'), languages=['zh_CH'])
else:
trans = gettext.translation('lang', pkg_resources.resource_filename('v2ray_util', 'locale_i18n'), languages=['en_US'])
trans.install()
_ = trans.gettext
14 changes: 1 addition & 13 deletions v2ray_util/util_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,4 @@ def open_port():
os.system(input_cmd.format("tcp", port_str))
os.system(input_cmd.format("udp", port_str))
os.system(output_cmd.format("tcp", port_str))
os.system(output_cmd.format("udp", port_str))

def i18n_create(lang=None):
import gettext
if not os.path.exists('/etc/v2ray_util/util.cfg'):
return
if not lang:
from .config import Config
lang = Config().get_data('lang')
if lang == 'zh':
gettext.translation('lang', pkg_resources.resource_filename('v2ray_util', 'locale_i18n'), languages=['zh_CH']).install()
else:
gettext.translation('lang', pkg_resources.resource_filename('v2ray_util', 'locale_i18n'), languages=['en_US']).install()
os.system(output_cmd.format("udp", port_str))
4 changes: 2 additions & 2 deletions v2ray_util/util_core/v2ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ def convert(cls):

@classmethod
def check(cls):
if not os.path.exists("/etc/v2ray_util/util.cfg"):
subprocess.call("mkdir -p /etc/v2ray_util && cp -f {} /etc/v2ray_util/".format(pkg_resources.resource_filename(__name__, 'util.cfg')), shell=True)
if not os.path.exists("/usr/bin/v2ray/v2ray"):
print(ColorStr.yellow(_("check v2ray no install, auto install v2ray..")))
cls.update()
cls.new()
if not os.path.exists("/etc/v2ray_util/util.cfg"):
subprocess.call("mkdir -p /etc/v2ray_util && cp -f {} /etc/v2ray_util/".format(pkg_resources.resource_filename(__name__, 'util.cfg')), shell=True)

@classmethod
def new(cls):
Expand Down

0 comments on commit 7353bce

Please sign in to comment.