Files
aaPanel/script/vhost_virtual.py
T
Jack a24f2e23c6 Update to 7.25.0
1. Added Mail Marketing Automation trigger tasks
2. Added Mail Marketing Groups Import, Export, Merge
3. Added Mail Marketing Subscribers to support paste import
4. Added Mail Marketing Template Import Export Duplicate
5. Added Mail server add timed automatic reply
6. Added HTTPS Protection function for Website (disables automatic HTTP to HTTPS redirection when enabled)
7. Optimize Website Interface Button Integration
8. Optimize the response speed of WP Toolkit interface
2025-03-13 17:52:26 +08:00

35 lines
1.6 KiB
Python

#coding: utf-8
#多用户放行端口脚本
import sys,os
os.chdir('/www/server/panel/')
sys.path.insert(0,"class/")
sys.path.insert(0,"class_v2/")
import public
import yaml
public.print_log("vhost_virtual.py")
default_yaml = '{}/vhost_virtual/manifest/config/default.yaml'.format(public.GetConfigValue('setup_path'))
not_accept_port_file = '{}/vhost_virtual/config/not_accept_port.pl'.format(public.GetConfigValue('setup_path'))
import firewalls
get = public.dict_obj()
get.ps = "vhost virtual service"
if not os.path.exists(not_accept_port_file):
with open(default_yaml, 'r') as file:
data=yaml.safe_load(file)
try:
if data["server"].get("address"):
http_port=data["server"]["address"]
#如果存在:用:分割端口,并取第二个端口和去除空格
if ":" in http_port:
get.port=http_port.split(":")[1].strip()
if get.port !="" and public.M('firewall').where("port=?",(get.port,)).count()<1::
firewalls.firewalls().AddAcceptPort(get)
if data["server"].get("httpsAddr"):
https_port = data["server"]["httpsAddr"]
#如果存在:用:分割端口,并取第二个端口和去除空格
if ":" in https_port:
get.port=https_port.split(":")[1].strip()
if get.port !="" and public.M('firewall').where("port=?",(get.port,)).count()<1::
firewalls.firewalls().AddAcceptPort(get)
except Exception as e:
public.print_log("e111--------------:{}".format(e))