Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
midoks committed Dec 18, 2024
1 parent b1826a6 commit 4cd620f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
12 changes: 12 additions & 0 deletions web/admin/site/redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ def get_redirect_conf():
redirect_id = request.form.get("id", '')
return MwSites.instance().getRedirectConf(site_name, redirect_id)

# 设置重定向配置
@blueprint.route('/save_redirect_conf', endpoint='save_redirect_conf', methods=['POST'])
@panel_login_required
def save_redirect_conf():
site_name = request.form.get("siteName", '')
redirect_id = request.form.get("id", '')
config = request.form.get("config", "")
return MwSites.instance().saveRedirectConf(site_name, redirect_id, config)




# 删除重定向配置
@blueprint.route('/del_redirect', endpoint='del_redirect', methods=['POST'])
@panel_login_required
Expand Down
18 changes: 18 additions & 0 deletions web/utils/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,24 @@ def openRedirectByOpen(self, site_name):
self.close_redirect = []
return True

def saveRedirectConf(self, site_name, redirect_id, config):
if redirect_id == '' or site_name == '':
return mw.returnData(False, "必填项不能为空!")

_old_config = mw.readFile("{}/{}/{}.conf".format(self.redirectPath, site_name, redirect_id))
if _old_config == False:
return mw.returnData(False, "非法操作")

mw.writeFile("{}/{}/{}.conf".format(self.redirectPath, site_name, redirect_id), config)
rule_test = mw.checkWebConfig()
if rule_test != True:
mw.writeFile("{}/{}/{}.conf".format(self.redirectPath,site_name, redirect_id), _old_config)
return mw.returnData(False, "OpenResty 配置测试不通过, 请重试: {}".format(rule_test))

self.operateRedirectConf(site_name, 'start')
mw.restartWeb()
return mw.returnData(True, "ok")


def getProxyConf(self, site_name, proxy_id):
if proxy_id == '' or site_name == '':
Expand Down

0 comments on commit 4cd620f

Please sign in to comment.