Skip to content

Commit

Permalink
completed cdn translate
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Sep 19, 2019
1 parent 32eb7b1 commit 46198b6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 9 deletions.
36 changes: 30 additions & 6 deletions v2ray_util/config_modify/cdn.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import socket

from .tls import TLSModifier
from ..util_core.selector import GroupSelector
from ..util_core.writer import StreamWriter, GroupWriter
from ..util_core.utils import StreamType, ColorStr
from ..util_core.utils import StreamType, ColorStr, get_ip

class CDNModifier:
def __init__(self, group_tag='A', group_index=-1, domain='', fake_domain=''):
Expand Down Expand Up @@ -33,18 +35,40 @@ def openHttps(self):
TLSModifier(self.group_tag, self.group_index, self.domain).turn_on()

def modify():
gs = GroupSelector("修改为cdn模式")
gs = GroupSelector("run cdn mode")
group = gs.group

if group == None:
exit(-1)
else:
print("")
print("1.修改为cdn模式 80端口 + ws")
print("2.修改为cdn模式 443端口 + ws")
print(_("1.80 port + ws"))
print(_("2.443 port + ws"))
choice = input(_("please select: "))
domain = input("请输入走cdn的域名: ")
fake_domain = input("请输入ws要伪装的域名(不伪装直接回车): ")
if not choice:
return
fake_domain = input(_("please input ws fake domain(enter to no need): "))
domain = input(_("please input run cdn mode domain: "))
if not domain:
print(ColorStr.yellow(_("domain is empty!")))
return
try:
input_ip = socket.gethostbyname(domain)
except Exception:
print(_("domain check error!!!"))
print("")
return

if choice == '2':
local_ip = get_ip()
print(_("local vps ip address: ") + local_ip + "\n")

if input_ip != local_ip:
print(_("domain can't analysis to local ip!!!"))
print(_("if cdn is cloudclare, must open dns only mode!"))
print("")
return

cm = CDNModifier(group.tag, group.index, domain, fake_domain)

if choice == '1':
Expand Down
4 changes: 2 additions & 2 deletions v2ray_util/config_modify/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def turn_on(self):
print("")
choice=input(_("please select: "))
if choice == "1":
local_ip = get_ip()
print(_("local vps ip address: ") + local_ip + "\n")
if not self.domain:
local_ip = get_ip()
print(_("local vps ip address: ") + local_ip + "\n")
input_domain=input(_("please input your vps domain: "))
try:
input_ip = socket.gethostbyname(input_domain)
Expand Down
Binary file modified v2ray_util/locale_i18n/zh_CH/LC_MESSAGES/lang.mo
Binary file not shown.
25 changes: 25 additions & 0 deletions v2ray_util/locale_i18n/zh_CH/LC_MESSAGES/lang.po
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ msgstr "更改Shadowsocks加密方式"
msgid "modify shadowsocks password"
msgstr "更改Shadowsocks密码"

msgid "CDN mode(need domain)"
msgstr "走CDN(需要域名)"

msgid "V2ray Traffic Statistics"
msgstr "流量统计(v2ray)"

Expand Down Expand Up @@ -575,6 +578,28 @@ msgstr "V2ray MTProto/Shadowsocks协议不支持配置https!!!"

### tls.py end ###

### cdn.py start ###
msgid "1.run cdn mode"
msgstr "1.走cdn模式"

msgid "1.80 port + ws"
msgstr "1.80端口 + ws"

msgid "2.443 port + ws"
msgstr "2.443端口 + ws"

msgid "please input ws fake domain(enter to no need): "
msgstr "请输入ws要伪装的域名(不伪装直接回车): "

msgid "please input run cdn mode domain: "
msgstr "请输入走cdn的域名: "

msgid "domain is empty!"
msgstr "域名为空!"

msgid "if cdn is cloudclare, must open dns only mode!"
msgstr "如果是cloudclare cdn, 则需开启dns only模式!"

### update_timer.py start ###

msgid "open"
Expand Down
2 changes: 1 addition & 1 deletion v2ray_util/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def user_manage():

def profile_alter():
show_text = (_("modify email"), _("modify UUID"), _("modify alterID"), _("modify port"), _("modify stream"), _("modify tls"),
_("modify tcpFastOpen"), _("modify dyn_port"), _("modify shadowsocks method"), _("modify shadowsocks password"), _("open CDN"))
_("modify tcpFastOpen"), _("modify dyn_port"), _("modify shadowsocks method"), _("modify shadowsocks password"), _("CDN mode(need domain)"))
print("")
for index, text in enumerate(show_text):
print("{}.{}".format(index + 1, text))
Expand Down

0 comments on commit 46198b6

Please sign in to comment.