Skip to content

Commit

Permalink
细节调整,更改版本号为 3.8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaHOH committed Aug 25, 2021
1 parent 79b44e3 commit 30b6bd4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
18 changes: 10 additions & 8 deletions launcher/win_tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def get_server_list(self):
for k in ('http', 'https', 'ftp', 'socks'):
v = self.__getattr__(k)
if v:
server_list.append('%s=%s' % (k, v))
server_list.append(f'{k}={v}')
return server_list

@property
Expand Down Expand Up @@ -226,7 +226,7 @@ def on_refresh(systray):
ShowWindow(hwnd, 8)

def on_about(systray):
about = 'GotoX v%s\n\nhttps://github.com/SeaHOH/GotoX' % gotoxver
about = f'GotoX v{gotoxver}\n\nhttps://github.com/SeaHOH/GotoX'
MessageBox(None, about, '关于', 0)

def on_quit(systray):
Expand Down Expand Up @@ -391,7 +391,7 @@ def build_menu(systray):
act_state = proxy_state.type == 2 and LISTEN_ACT in proxy_state and fixed_fState or MFS_ENABLED
sub_menu4 = (
('使用自动代理', on_enable_auto_proxy, auto_state, MFT_RADIOCHECK),
('使用 %s 代理' % LISTEN_ACTTYPE, on_enable_act_proxy, act_state, MFT_RADIOCHECK),
(f'使用 {LISTEN_ACTTYPE} 代理', on_enable_act_proxy, act_state, MFT_RADIOCHECK),
('完全禁用代理', on_disable_proxy, disable_state, MFT_RADIOCHECK),
(None, '-'),
('禁用 HTTP 代理', on_disable_http_proxy, disable_http_state, MFT_RADIOCHECK),
Expand All @@ -405,7 +405,7 @@ def build_menu(systray):
(None, '-'),
visible and ('隐藏窗口', on_hide) or ('显示窗口', on_show),
('创建桌面快捷方式', on_create_shortcut),
('设置系统(IE/Edge)代理', sub_menu4),
(f'设置系统({sys_web_browser})代理', sub_menu4),
('重置 DNS 缓存', on_reset_dns),
('重置自动规则缓存', on_reset_autorule_cache),
('重置自动规则', on_reset_autorule),
Expand All @@ -421,7 +421,7 @@ def update_tip():
new_proxy_state = get_proxy_state()
if last_proxy_state and last_proxy_state.str == new_proxy_state.str:
return
systray_GotoX.update(hover_text='GotoX\n当前系统(IE/Edge)代理:\n%s' % new_proxy_state)
systray_GotoX.update(hover_text=f'GotoX\n当前系统({sys_web_browser})代理:\n{new_proxy_state}')
last_proxy_state = new_proxy_state
return new_proxy_state

Expand All @@ -435,9 +435,10 @@ def notify_proxy_changed():
old_proxy_state = last_proxy_state
new_proxy_state = update_tip()
if new_proxy_state:
text = '设置由:\n%s\n变更为:\n%s' % (old_proxy_state, new_proxy_state)
text = f'设置由:\n{old_proxy_state}\n变更为:\n{new_proxy_state}'
balloons_warning(text, '系统代理改变')

sys_web_browser = sys.getwindowsversion().major < 10 and 'IE' or 'Edge'
last_main_menu = None
last_proxy_state = None
quit_item = '退出', on_quit
Expand All @@ -449,7 +450,7 @@ def notify_proxy_changed():
#load_config()
#os.environ['HTTPS_PROXY'] = os.environ['HTTP_PROXY'] = LISTEN_AUTO.http
sleep(0.1)
balloons_info('''
balloons_info(f'''
GotoX 已经启动。
左键单击:打开菜单
Expand All @@ -459,7 +460,8 @@ def notify_proxy_changed():
右键单击:隐显窗口
当前系统代理设置为:
%s''' % update_tip())
{update_tip()}''')

running = True
if reg_notify is None:
Expand Down
42 changes: 25 additions & 17 deletions local/CFWFetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import zlib
import struct
import json
import math
import random
import logging
import threading
Expand All @@ -18,7 +19,6 @@
from .common.dns import dns, dns_resolve
from .common.net import explode_ip

# IP 数相比请求数极为巨大,无需重复连接同一 IP
http_cfw.max_per_ip = 1
lock = threading.Lock()
_lock_worker = make_lock_decorator(lock)
Expand Down Expand Up @@ -69,23 +69,31 @@ def set_dns():
if dns.gettill(cfw_params.hostname):
return
dns.setpadding(cfw_params.hostname)
if not cfw_iplist:
if GC.CFW_IPLIST:
iplist = GC.CFW_IPLIST
else:
iplist = dns_resolve('cloudflare.com')
if not iplist:
logging.warning('无法解析 cloudflare.com,使用默认 IP 列表')
# https://www.cloudflare.com/ips/
# 百度云加速与 CloudFlare 合作节点,保证可用
iplist = ['162.159.208.0', '162.159.209.0', '162.159.210.0', '162.159.211.0']
if GC.CFW_EXPLODEIP:
# 每个 IP 会自动扩展为 256 个,即填满最后 8 bit 子网
cfw_iplist[:] = sum([explode_ip(ip) for ip in iplist], [])
explodeip = GC.CFW_EXPLODEIP
if GC.CFW_IPLIST:
expire = False
iplist = GC.CFW_IPLIST
else:
expire = 3600
iplist = dns_resolve('cloudflare.com')
if iplist:
expire = 3600 * 6
elif cfw_iplist:
explodeip = False
else:
cfw_iplist[:] = iplist
random.shuffle(cfw_iplist)
dns.set(cfw_params.hostname, cfw_iplist, expire=False)
logging.warning('无法解析 cloudflare.com,使用默认 IP 列表')
# https://www.cloudflare.com/ips/
# 百度云加速与 CloudFlare 合作节点,保证可用
iplist = ['162.159.208.0', '162.159.209.0', '162.159.210.0', '162.159.211.0']
if explodeip:
# 每个 IP 会自动扩展为 256 个,即填满最后 8 bit 子网
cfw_iplist[:] = sum([explode_ip(ip) for ip in iplist], [])
elif iplist:
cfw_iplist[:] = iplist
random.shuffle(cfw_iplist)
dns.set(cfw_params.hostname, cfw_iplist, expire=expire)
# 根据 IP 数限制对同一 IP 请求数
http_cfw.max_per_ip = math.ceil(32 / len(cfw_iplist))

def remove_badip(ip):
with lock:
Expand Down
2 changes: 1 addition & 1 deletion local/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.8.3'
__version__ = '3.8.4'

0 comments on commit 30b6bd4

Please sign in to comment.