mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:59:25 +08:00
设置手动代理配置
This commit is contained in:
+10
-1
@@ -47,7 +47,7 @@ def set_proxy():
|
||||
proxy_id = request.form.get('id', '')
|
||||
return MwSites.instance().setProxy(site_name,site_from,to,host,name,open_proxy, open_cache,cache_time, proxy_id)
|
||||
|
||||
# 获取代理状态
|
||||
# 设置代理状态
|
||||
@blueprint.route('/set_proxy_status', endpoint='set_proxy_status', methods=['POST'])
|
||||
@panel_login_required
|
||||
def set_proxy_status():
|
||||
@@ -65,6 +65,15 @@ def get_proxy_conf():
|
||||
rid = request.form.get("id", '')
|
||||
return MwSites.instance().getProxyConf(site_name, rid)
|
||||
|
||||
# 设置代理
|
||||
@blueprint.route('/get_proxy_conf', endpoint='get_proxy_conf', methods=['POST'])
|
||||
@panel_login_required
|
||||
def get_proxy_conf():
|
||||
site_name = request.form.get("siteName", '')
|
||||
rid = request.form.get("id", '')
|
||||
config = request.form.get("config", "")
|
||||
return MwSites.instance().saveProxyConf(site_name, rid, config)
|
||||
|
||||
|
||||
# 删除代理配置
|
||||
@blueprint.route('/del_proxy', endpoint='del_proxy', methods=['POST'])
|
||||
|
||||
@@ -1709,6 +1709,25 @@ location ^~ {from} {\n\
|
||||
data = mw.readFile(conf_file)
|
||||
return mw.returnData(True, "ok", {"result": data})
|
||||
|
||||
def saveProxyConf(self, site_name, proxy_id, config):
|
||||
|
||||
if proxy_id == '' or site_name == '':
|
||||
return mw.returnData(False, "必填项不能为空!")
|
||||
|
||||
proxy_file = "{}/{}/{}.conf".format(self.proxyPath, site_name, proxy_id)
|
||||
mw.backFile(proxy_file)
|
||||
mw.writeFile(proxy_file, config)
|
||||
rule_test = mw.checkWebConfig()
|
||||
if rule_test != True:
|
||||
mw.restoreFile(proxy_file)
|
||||
mw.removeBackFile(proxy_file)
|
||||
return mw.returnData(False, "OpenResty 配置测试不通过, 请重试: {}".format(rule_test))
|
||||
|
||||
mw.removeBackFile(proxy_file)
|
||||
self.operateRedirectConf(site_name, 'start')
|
||||
mw.restartWeb()
|
||||
return mw.returnData(True, "ok")
|
||||
|
||||
def delProxy(self, site_name, proxy_id):
|
||||
if proxy_id == '' or site_name == '':
|
||||
return mw.returnData(False, "必填项不能为空!")
|
||||
|
||||
Reference in New Issue
Block a user