Permalink
Browse files

[*] 修正config改地方后wsgi.py的bug

[*] 修正 custom_func.sample.py
[-] 拆除一个忘了拆的脚手架
  • Loading branch information...
aploium committed Oct 6, 2016
1 parent db38524 commit 354358613fa636def1bb2dd74196c3fa51f18756
Showing with 31 additions and 18 deletions.
  1. +2 −2 config_default.py
  2. +5 −5 custom_func.sample.py
  3. +24 −11 wsgi.py
@@ -447,7 +447,7 @@
# ############## Cron Tasks ##############
# v0.21.4+ Cron Tasks, if you really know what you are doing, please do not disable this option
# 定时任务, 除非你真的知道你在做什么, 否则请不要关闭本选项
enable_cron_tasks = False
enable_cron_tasks = True

# from custom_func import your_own_cron_function

@@ -727,7 +727,7 @@

# v0.25.0+
# 本选项在 unittest 中会自动开启, 不需要人工开启
unittest_mode = True
unittest_mode = False

# v0.25.0+
# 强制内部requests在请求远程服务器时不验证SSL证书
@@ -146,7 +146,7 @@ def demo__custom_identity_verify(identity_dict):
"""
import hashlib
import requests
import config
from zmirror import cfg

if 'cc98_username' not in identity_dict or 'cc98_password' not in identity_dict:
return False
@@ -155,8 +155,8 @@ def demo__custom_identity_verify(identity_dict):
pass_md5 = hashlib.md5()
pass_md5.update(identity_dict['cc98_password'].encode())
pass_md5 = pass_md5.hexdigest()
if config.is_use_proxy:
proxy = config.requests_proxies
if cfg.is_use_proxy:
proxy = cfg.requests_proxies
else:
proxy = None
r = requests.post('http://www.cc98.org/sign.asp', data={
@@ -175,14 +175,14 @@ def demo__custom_identity_verify(identity_dict):

# Demo for Twitter
def demo__handle_expand_url(mobj):
import config
from zmirror.zmirror import add_ssrf_allowed_domain, get_group
from zmirror import cfg

domain = get_group('domain', mobj)
if not domain:
return mobj.group()
add_ssrf_allowed_domain(domain)
if 'https' in get_group('scheme', mobj) or config.force_https_domains == 'ALL':
if 'https' in get_group('scheme', mobj) or cfg.force_https_domains == 'ALL':
scheme_prefix = 'https-'
else:
scheme_prefix = ''
35 wsgi.py
@@ -12,22 +12,35 @@


def main():
from zmirror.zmirror import my_host_port, built_in_server_host, \
built_in_server_debug, built_in_server_extra_params, warnprint, \
errprint
from zmirror.zmirror import warnprint, errprint, infoprint
from zmirror import cfg

if cfg.my_host_port is None:
cfg.my_host_port = 80

infoprint("zmirror is running! Listening: {}:{} ThisDomain: {} Target: {}".format(
cfg.built_in_server_host, cfg.my_host_port, cfg.my_host_name, cfg.target_domain
))

warnprint("You may directly running zmirror, which is NOT recommend for PRODUCTION environment.\n"
"Please deploy it using Apache,You can find a deploy tutorial here:\n"
"https://github.com/aploium/zmirror/wiki/%E9%83%A8%E7%BD%B2%E6%94%AF%E6%8C%81HTTPS%E5%92%8CHTTP2.0%E7%9A%84%E9%95%9C%E5%83%8F")

if my_host_port is None:
my_host_port = 80
if cfg.built_in_server_host == '127.0.0.1':
warnprint(
"Only listening to 127.0.0.1, which means you CANNOT access this zmirror "
"instance from Internet, if you really want to access this instance directly from Internet, "
"please append this line to the `config.py` \n----------\n"
"built_in_server_host = '0.0.0.0'\n"
"----------"
)

try:
application.run(
port=my_host_port,
port=cfg.my_host_port,

# 如果配置文件中开启了多进程, 那么就关掉多线程, 否则默认启用多线程
threaded="processes" not in built_in_server_extra_params,
threaded="processes" not in cfg.built_in_server_extra_params,

# 如果你想直接用本程序给外网访问, 请在 config.py 末尾加两行配置
# !!警告!! 无论如何都不要修改 config_default.py, 否则程序将无法通过 git pull 来升级
@@ -37,11 +50,11 @@ def main():
#
# ps:字母在行首, 行首不要有空格
# !!警告!! 无论如何都不要修改本文件, 否则程序将无法通过 git pull 来升级
debug=built_in_server_debug, # 默认是开启debug模式的
debug=cfg.built_in_server_debug, # 默认是开启debug模式的
# 默认只允许本机访问, 如果你希望让外网访问, 请根据上面的注释修改配置文件
host=built_in_server_host,
host=cfg.built_in_server_host,

**built_in_server_extra_params # extra params
**cfg.built_in_server_extra_params # extra params
)
except OSError as e:
if e.errno in (98, 10013): # Address already in use, 98 for linux, 10013 for win
@@ -50,7 +63,7 @@ def main():
" Linux: netstat -apn |grep \":{port}\"\n"
" Windows: netstat -ano |find \":{port}\"\n\n"
"Or change zmirror\'s port: change(add, if not exist) the `my_host_port` setting in `config.py`\n"
"eg: my_host_port=81".format(port=my_host_port))
"eg: my_host_port=81".format(port=cfg.my_host_port))
exit()
else:
raise

0 comments on commit 3543586

Please sign in to comment.