This commit is contained in:
flucont 2022-12-17 17:25:27 +08:00
parent ab81af3b94
commit 2c9f84c121
8 changed files with 192 additions and 151 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
Linux_Version="7.9.6" Linux_Version="7.9.6"
Windows_Version="7.7.0" Windows_Version="7.8.0"
FILES=( FILES=(
public/install/src/panel6.zip public/install/src/panel6.zip

View File

@ -15,9 +15,9 @@ INSERT INTO `cloud_config` (`key`, `value`) VALUES
('new_version', '7.9.6'), ('new_version', '7.9.6'),
('update_msg', '暂无更新日志'), ('update_msg', '暂无更新日志'),
('update_date', '2022-11-29'), ('update_date', '2022-11-29'),
('new_version_win', '7.7.0'), ('new_version_win', '7.8.0'),
('update_msg_win', '暂无更新日志'), ('update_msg_win', '暂无更新日志'),
('update_date_win', '2022-09-09'), ('update_date_win', '2022-12-08'),
('updateall_type', '0'), ('updateall_type', '0'),
('syskey', 'UqP94LtI8eWAIgCP'); ('syskey', 'UqP94LtI8eWAIgCP');

View File

@ -118,6 +118,33 @@ System_Check(){
Install_Check Install_Check
fi fi
} }
Set_Ssl(){
echo -e ""
echo -e "----------------------------------------------------------------------"
echo -e "为了您的面板使用安全建议您开启面板SSL开启后请使用https访问宝塔面板"
echo -e "输入y回车即开启面板SSL并进行下一步安装"
echo -e "输入n回车跳过面板SSL配置直接进行安装"
echo -e "10秒后将跳过SSL配置直接进行面板安装"
echo -e "----------------------------------------------------------------------"
echo -e ""
read -t 10 -p "是否确定开启面板SSL ? (y/n): " yes
if [ $? != 0 ];then
SET_SSL=false
else
case "$yes" in
y)
SET_SSL=true
;;
n)
SET_SSL=false
rm -f /www/server/panel/data/ssl.pl
;;
*)
Set_Ssl
esac
fi
}
Get_Pack_Manager(){ Get_Pack_Manager(){
if [ -f "/usr/bin/yum" ] && [ -d "/etc/yum.repos.d" ]; then if [ -f "/usr/bin/yum" ] && [ -d "/etc/yum.repos.d" ]; then
PM="yum" PM="yum"
@ -204,7 +231,7 @@ get_node_url(){
echo '---------------------------------------------'; echo '---------------------------------------------';
echo "Selected download node..."; echo "Selected download node...";
nodes=(http://dg2.bt.cn http://dg1.bt.cn http://download.bt.cn http://125.90.93.52:5880 http://36.133.1.8:5880 http://123.129.198.197 http://103.179.243.14:5880 http://128.1.164.196); nodes=(https://dg2.bt.cn https://dg1.bt.cn https://download.bt.cn);
if [ "$1" ];then if [ "$1" ];then
nodes=($(echo ${nodes[*]}|sed "s#${1}##")) nodes=($(echo ${nodes[*]}|sed "s#${1}##"))
@ -246,7 +273,7 @@ get_node_url(){
if [ -z "$NODE_URL" ];then if [ -z "$NODE_URL" ];then
NODE_URL=$(cat $tmp_file2|sort -g -t " " -k 1|head -n 1|awk '{print $2}') NODE_URL=$(cat $tmp_file2|sort -g -t " " -k 1|head -n 1|awk '{print $2}')
if [ -z "$NODE_URL" ];then if [ -z "$NODE_URL" ];then
NODE_URL='http://download.bt.cn'; NODE_URL='https://download.bt.cn';
fi fi
fi fi
rm -f $tmp_file1 rm -f $tmp_file1
@ -597,10 +624,7 @@ Install_Bt(){
if [ -f ${setup_path}/server/panel/data/port.pl ];then if [ -f ${setup_path}/server/panel/data/port.pl ];then
panelPort=$(cat ${setup_path}/server/panel/data/port.pl) panelPort=$(cat ${setup_path}/server/panel/data/port.pl)
else else
RE_NUM=$(expr $RANDOM % 3) panelPort=$(expr $RANDOM % 55535 + 10000)
if [ "${RE_NUM}" == "1" ];then
panelPort=$(expr $RANDOM % 55535 + 10000)
fi
fi fi
mkdir -p ${setup_path}/server/panel/logs mkdir -p ${setup_path}/server/panel/logs
mkdir -p ${setup_path}/server/panel/vhost/apache mkdir -p ${setup_path}/server/panel/vhost/apache
@ -701,6 +725,8 @@ Set_Bt_Panel(){
auth_path=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8) auth_path=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)
echo "/${auth_path}" > ${admin_auth} echo "/${auth_path}" > ${admin_auth}
fi fi
auth_path=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)
echo "/${auth_path}" > ${admin_auth}
chmod -R 700 $pyenv_path/pyenv/bin chmod -R 700 $pyenv_path/pyenv/bin
/www/server/panel/pyenv/bin/pip3 install pymongo /www/server/panel/pyenv/bin/pip3 install pymongo
/www/server/panel/pyenv/bin/pip3 install psycopg2-binary /www/server/panel/pyenv/bin/pip3 install psycopg2-binary
@ -708,6 +734,10 @@ Set_Bt_Panel(){
/www/server/panel/pyenv/bin/pip3 install flask-sock /www/server/panel/pyenv/bin/pip3 install flask-sock
auth_path=$(cat ${admin_auth}) auth_path=$(cat ${admin_auth})
cd ${setup_path}/server/panel/ cd ${setup_path}/server/panel/
if [ "$SET_SSL" == true ]; then
btpip install -I pyOpenSSl
btpython /www/server/panel/tools.py ssl
fi
/etc/init.d/bt start /etc/init.d/bt start
$python_bin -m py_compile tools.py $python_bin -m py_compile tools.py
$python_bin tools.py username $python_bin tools.py username
@ -719,7 +749,7 @@ Set_Bt_Panel(){
/etc/init.d/bt restart /etc/init.d/bt restart
sleep 3 sleep 3
isStart=$(ps aux |grep 'BT-Panel'|grep -v grep|awk '{print $2}') isStart=$(ps aux |grep 'BT-Panel'|grep -v grep|awk '{print $2}')
LOCAL_CURL=$(curl 127.0.0.1:8888/login 2>&1 |grep -i html) LOCAL_CURL=$(curl 127.0.0.1:${panelPort}/login 2>&1 |grep -i html)
if [ -z "${isStart}" ] && [ -z "${LOCAL_CURL}" ];then if [ -z "${isStart}" ] && [ -z "${LOCAL_CURL}" ];then
/etc/init.d/bt 22 /etc/init.d/bt 22
cd /www/server/panel/pyenv/bin cd /www/server/panel/pyenv/bin
@ -797,7 +827,6 @@ Get_Ip_Address(){
isHosts=$(cat /etc/hosts|grep 'www.bt.cn') isHosts=$(cat /etc/hosts|grep 'www.bt.cn')
if [ -z "${isHosts}" ];then if [ -z "${isHosts}" ];then
echo "" >> /etc/hosts echo "" >> /etc/hosts
echo "116.213.43.206 www.bt.cn" >> /etc/hosts
getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress) getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)
if [ -z "${getIpAddress}" ];then if [ -z "${getIpAddress}" ];then
sed -i "/bt.cn/d" /etc/hosts sed -i "/bt.cn/d" /etc/hosts
@ -833,6 +862,7 @@ Setup_Count(){
echo /www > /var/bt_setupPath.conf echo /www > /var/bt_setupPath.conf
} }
Install_Main(){ Install_Main(){
#Set_Ssl
startTime=`date +%s` startTime=`date +%s`
Lock_Clear Lock_Clear
System_Check System_Check
@ -890,17 +920,28 @@ fi
Install_Main Install_Main
PANEL_SSL=$(cat /www/server/panel/data/ssl.pl 2> /dev/null)
if [ "${PANEL_SSL}" == "True" ];then
HTTP_S="https"
else
HTTP_S="http"
fi
echo > /www/server/panel/data/bind.pl echo > /www/server/panel/data/bind.pl
echo -e "==================================================================" echo -e "=================================================================="
echo -e "\033[32mCongratulations! Installed successfully!\033[0m" echo -e "\033[32mCongratulations! Installed successfully!\033[0m"
echo -e "==================================================================" echo -e "=================================================================="
echo "外网面板地址: http://${getIpAddress}:${panelPort}${auth_path}" echo "外网面板地址: ${HTTP_S}://${getIpAddress}:${panelPort}${auth_path}"
echo "内网面板地址: http://${LOCAL_IP}:${panelPort}${auth_path}" echo "内网面板地址: ${HTTP_S}://${LOCAL_IP}:${panelPort}${auth_path}"
echo -e "username: $username" echo -e "username: $username"
echo -e "password: $password" echo -e "password: $password"
echo -e "\033[33mIf you cannot access the panel,\033[0m" echo -e "\033[33mIf you cannot access the panel,\033[0m"
echo -e "\033[33mrelease the following panel port [${panelPort}] in the security group\033[0m" echo -e "\033[33mrelease the following panel port [${panelPort}] in the security group\033[0m"
echo -e "\033[33m若无法访问面板请检查防火墙/安全组是否有放行面板[${panelPort}]端口\033[0m" echo -e "\033[33m若无法访问面板请检查防火墙/安全组是否有放行面板[${panelPort}]端口\033[0m"
if [ "${HTTP_S}" == "https" ];then
echo -e "\033[33m因已开启面板自签证书访问面板会提示不匹配证书请参考以下链接配置证书\033[0m"
echo -e "\033[33mhttps://www.bt.cn/bbs/thread-105443-1-1.html\033[0m"
fi
echo -e "==================================================================" echo -e "=================================================================="
endTime=`date +%s` endTime=`date +%s`

View File

@ -10,7 +10,7 @@ export LANG=en_US.UTF-8
export LANGUAGE=en_US:en export LANGUAGE=en_US:en
get_node_url(){ get_node_url(){
nodes=(http://dg2.bt.cn http://dg1.bt.cn http://36.133.1.8:5880 http://123.129.198.197 http://38.34.185.130 http://116.213.43.206:5880 http://128.1.164.196); nodes=(https://dg2.bt.cn https://dg1.bt.cn https://download.bt.cn https://hk1-node.bt.cn https://na1-node.bt.cn https://jp1-node.bt.cn);
if [ "$1" ];then if [ "$1" ];then
nodes=($(echo ${nodes[*]}|sed "s#${1}##")) nodes=($(echo ${nodes[*]}|sed "s#${1}##"))
@ -52,7 +52,7 @@ get_node_url(){
if [ -z "$NODE_URL" ];then if [ -z "$NODE_URL" ];then
NODE_URL=$(cat $tmp_file2|sort -g -t " " -k 1|head -n 1|awk '{print $2}') NODE_URL=$(cat $tmp_file2|sort -g -t " " -k 1|head -n 1|awk '{print $2}')
if [ -z "$NODE_URL" ];then if [ -z "$NODE_URL" ];then
NODE_URL='http://download.bt.cn'; NODE_URL='https://download.bt.cn';
fi fi
fi fi
rm -f $tmp_file1 rm -f $tmp_file1
@ -108,7 +108,7 @@ send_check(){
chmod +x /etc/init.d/bt chmod +x /etc/init.d/bt
p_path2=/www/server/panel/class/common.py p_path2=/www/server/panel/class/common.py
p_version=$(cat $p_path2|grep "version = "|awk '{print $3}'|tr -cd [0-9.]) p_version=$(cat $p_path2|grep "version = "|awk '{print $3}'|tr -cd [0-9.])
curl -sS --connect-timeout 3 -m 60 http://www.bt.cn/api/panel/notpro?version=$p_version curl -sS --connect-timeout 3 -m 60 https://www.bt.cn/api/panel/notpro?version=$p_version
NODE_URL="" NODE_URL=""
exit 0; exit 0;
} }
@ -147,3 +147,4 @@ if [ ! $NODE_URL ];then
get_node_url get_node_url
fi fi

Binary file not shown.

View File

@ -22,7 +22,7 @@ def readReg(path,key):
return False return False
panelPath = readReg(r'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\宝塔面板','PanelPath') panelPath = readReg(r'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\宝塔面板','PanelPath')
if not panelPath: if not panelPath:
panelPath = os.getenv('BT_PANEL') panelPath = os.getenv('BT_PANEL')
if not panelPath: exit(); if not panelPath: exit();
@ -44,11 +44,11 @@ class Sql():
__OPT_FIELD = "*" # field条件 __OPT_FIELD = "*" # field条件
__OPT_PARAM = () # where值 __OPT_PARAM = () # where值
__LOCK = panelPath + '/data/sqlite_lock.pl' __LOCK = panelPath + '/data/sqlite_lock.pl'
def __init__(self): def __init__(self):
self.__DB_FILE = panelPath + '/data/default.db' self.__DB_FILE = panelPath + '/data/default.db'
def __GetConn(self): def __GetConn(self):
#取数据库对象 #取数据库对象
try: try:
if self.__DB_CONN == None: if self.__DB_CONN == None:
@ -62,8 +62,8 @@ class Sql():
#设置表名 #设置表名
self.__DB_TABLE = table self.__DB_TABLE = table
return self return self
def where(self,where,param): def where(self,where,param):
#WHERE条件 #WHERE条件
if where: if where:
@ -73,7 +73,7 @@ class Sql():
def __to_tuple(self,param): def __to_tuple(self,param):
#将参数转换为tuple #将参数转换为tuple
if type(param) != tuple: if type(param) != tuple:
if type(param) == list: if type(param) == list:
param = tuple(param) param = tuple(param)
else: else:
@ -85,7 +85,7 @@ class Sql():
if not pdata: return False if not pdata: return False
keys,param = self.__format_pdata(pdata) keys,param = self.__format_pdata(pdata)
return self.save(keys,param) return self.save(keys,param)
#构造数据 #构造数据
def __format_pdata(self,pdata): def __format_pdata(self,pdata):
keys = pdata.keys() keys = pdata.keys()
@ -98,17 +98,17 @@ class Sql():
#FIELD条件 #FIELD条件
if len(field): if len(field):
self.__OPT_FIELD = field self.__OPT_FIELD = field
return self return self
def getField(self,keyName): def getField(self,keyName):
#取回指定字段 #取回指定字段
result = self.field(keyName).select() result = self.field(keyName).select()
print(result) print(result)
if len(result) != 0: if len(result) != 0:
return result[0][keyName] return result[0][keyName]
return result return result
def __format_field(self,field): def __format_field(self,field):
import re import re
fields = [] fields = []
@ -159,16 +159,16 @@ class Sql():
return data return data
except Exception as ex: except Exception as ex:
return "error: " + str(ex) return "error: " + str(ex)
def setField(self,keyName,keyValue): def setField(self,keyName,keyValue):
#更新指定字段 #更新指定字段
return self.save(keyName,(keyValue,)) return self.save(keyName,(keyValue,))
def commit(self): def commit(self):
self.__close() self.__close()
self.__DB_CONN.commit() self.__DB_CONN.commit()
def save(self,keys,param): def save(self,keys,param):
#更新数据 #更新数据
self.write_lock() self.write_lock()
@ -180,7 +180,7 @@ class Sql():
opt += key + "=?," opt += key + "=?,"
opt = opt[0:len(opt)-1] opt = opt[0:len(opt)-1]
sql = "UPDATE " + self.__DB_TABLE + " SET " + opt+self.__OPT_WHERE sql = "UPDATE " + self.__DB_TABLE + " SET " + opt+self.__OPT_WHERE
#处理拼接WHERE与UPDATE参数 #处理拼接WHERE与UPDATE参数
tmp = list(self.__to_tuple(param)) tmp = list(self.__to_tuple(param))
for arg in self.__OPT_PARAM: for arg in self.__OPT_PARAM:
@ -193,8 +193,8 @@ class Sql():
return result.rowcount return result.rowcount
except Exception as ex: except Exception as ex:
return "error: " + str(ex) return "error: " + str(ex)
def execute(self,sql,param = ()): def execute(self,sql,param = ()):
#执行SQL语句返回受影响行 #执行SQL语句返回受影响行
self.write_lock() self.write_lock()
@ -225,7 +225,7 @@ class Sql():
def rm_lock(self): def rm_lock(self):
if os.path.exists(self.__LOCK): if os.path.exists(self.__LOCK):
os.remove(self.__LOCK) os.remove(self.__LOCK)
def query(self,sql,param = ()): def query(self,sql,param = ()):
#执行SQL语句返回数据集 #执行SQL语句返回数据集
self.__GetConn() self.__GetConn()
@ -236,7 +236,7 @@ class Sql():
return data return data
except Exception as ex: except Exception as ex:
return "error: " + str(ex) return "error: " + str(ex)
def __close(self): def __close(self):
#清理条件属性 #清理条件属性
self.__OPT_WHERE = "" self.__OPT_WHERE = ""
@ -244,8 +244,8 @@ class Sql():
self.__OPT_ORDER = "" self.__OPT_ORDER = ""
self.__OPT_LIMIT = "" self.__OPT_LIMIT = ""
self.__OPT_PARAM = () self.__OPT_PARAM = ()
def close(self): def close(self):
#释放资源 #释放资源
try: try:
@ -254,7 +254,7 @@ class Sql():
except: except:
pass pass
def GetLocalIp(): def GetLocalIp():
""" """
取本地外网IP 取本地外网IP
@ -264,17 +264,16 @@ def GetLocalIp():
filename = panelPath + '/data/iplist.txt' filename = panelPath + '/data/iplist.txt'
ipaddress = readFile(filename) ipaddress = readFile(filename)
if not ipaddress: if not ipaddress:
url = 'http://pv.sohu.com/cityjson?ie=utf-8' url = 'http://www.example.com/api/getIpAddress';
str = httpGet(url) str = httpGet(url)
ipaddress = re.search('\d+.\d+.\d+.\d+',str).group(0)
writeFile(filename,ipaddress) writeFile(filename,ipaddress)
ipaddress = re.search('\d+.\d+.\d+.\d+',ipaddress).group(0); ipaddress = re.search('\d+.\d+.\d+.\d+',ipaddress).group(0);
return ipaddress return ipaddress
except: except:
try: try:
url = 'http://www.example.com/api/getIpAddress'; url = 'https://www.bt.cn/Api/getIpAddress';
str = httpGet(url) str = httpGet(url)
writeFile(filename,ipaddress) writeFile(filename,ipaddress)
return str return str
@ -302,12 +301,12 @@ def start_service(name):
while get_server_status(name) == 0: while get_server_status(name) == 0:
try: try:
win32serviceutil.StartService(name) win32serviceutil.StartService(name)
time.sleep(1); time.sleep(1);
except : time.sleep(1); except : time.sleep(1);
timeout += 1 timeout += 1
if timeout > 10:break if timeout > 10:break
if get_server_status(name) != 0: if get_server_status(name) != 0:
return True,None return True,None
return False,'操作失败10秒内未完成启动服务【{}'.format(name) return False,'操作失败10秒内未完成启动服务【{}'.format(name)
except : except :
@ -319,12 +318,12 @@ def stop_service(name):
while get_server_status(name) == 1: while get_server_status(name) == 1:
try: try:
win32serviceutil.StopService(name) win32serviceutil.StopService(name)
time.sleep(1); time.sleep(1);
except : time.sleep(1); except : time.sleep(1);
timeout += 1 timeout += 1
if timeout > 10:break if timeout > 10:break
if get_server_status(name) != 1: if get_server_status(name) != 1:
return True,None return True,None
return False,'操作失败10秒内未完成启动服务【{}'.format(name) return False,'操作失败10秒内未完成启动服务【{}'.format(name)
except : except :
@ -364,15 +363,15 @@ def downloadFileByWget(url,filename):
if os.path.exists(logPath): os.remove(logPath) if os.path.exists(logPath): os.remove(logPath)
except : pass except : pass
loacl_path = '{}/script/wget.exe'.format(panelPath) loacl_path = '{}/script/wget.exe'.format(panelPath)
if not os.path.exists(loacl_path): downloadFile(get_url()+'/win/panel/data/wget.exe',loacl_path) if not os.path.exists(loacl_path): downloadFile(get_url()+'/win/panel/data/wget.exe',loacl_path)
if os.path.getsize(loacl_path) < 10: if os.path.getsize(loacl_path) < 10:
os.remove(loacl_path) os.remove(loacl_path)
downloadFile(url,filename) downloadFile(url,filename)
else: else:
shell = "{} {} -O {} -t 5 -T 60 --no-check-certificate --auth-no-challenge --force-directorie > {} 2>&1".format(loacl_path,url,filename,logPath) shell = "{} {} -O {} -t 5 -T 60 --no-check-certificate --auth-no-challenge --force-directorie > {} 2>&1".format(loacl_path,url,filename,logPath)
os.system(shell) os.system(shell)
num = 0 num = 0
re_size = 0 re_size = 0
while num <= 5: while num <= 5:
@ -382,17 +381,17 @@ def downloadFileByWget(url,filename):
break; break;
else: else:
re_size = cr_size re_size = cr_size
time.sleep(0.5) time.sleep(0.5)
num += 1 num += 1
if os.path.exists(filename): if os.path.exists(filename):
if os.path.getsize(filename) < 1: if os.path.getsize(filename) < 1:
os.remove(filename) os.remove(filename)
downloadFile(url,filename) downloadFile(url,filename)
else: else:
downloadFile(url,filename) downloadFile(url,filename)
def writeFile(filename,s_body,mode='w+',encoding = 'utf-8'): def writeFile(filename,s_body,mode='w+',encoding = 'utf-8'):
try: try:
fp = open(filename, mode,encoding = encoding); fp = open(filename, mode,encoding = encoding);
fp.write(s_body) fp.write(s_body)
@ -402,7 +401,7 @@ def writeFile(filename,s_body,mode='w+',encoding = 'utf-8'):
return False return False
def readFile(filename,mode = 'r'): def readFile(filename,mode = 'r'):
import os,chardet import os,chardet
if not os.path.exists(filename): return False if not os.path.exists(filename): return False
if not os.path.isfile(filename): return False if not os.path.isfile(filename): return False
@ -425,15 +424,15 @@ def readFile(filename,mode = 'r'):
encoding = 'ansi' encoding = 'ansi'
fp = open(filename, mode,encoding = encoding) fp = open(filename, mode,encoding = encoding)
f_body = fp.read() f_body = fp.read()
try: try:
if f_body[0] == '\ufeff': if f_body[0] == '\ufeff':
#处理带bom格式 #处理带bom格式
new_code = chardet.detect(f_body.encode(encoding))["encoding"] new_code = chardet.detect(f_body.encode(encoding))["encoding"]
f_body = f_body.encode(encoding).decode(new_code); f_body = f_body.encode(encoding).decode(new_code);
except : pass except : pass
fp.close() fp.close()
return f_body return f_body
def httpGet(url,timeout = 60,headers = {}): def httpGet(url,timeout = 60,headers = {}):
@ -445,11 +444,11 @@ def httpGet(url,timeout = 60,headers = {}):
req = urllib.request.Request(url,headers = headers) req = urllib.request.Request(url,headers = headers)
response = urllib.request.urlopen(req,timeout = timeout) response = urllib.request.urlopen(req,timeout = timeout)
result = response.read() result = response.read()
if type(result) == bytes: if type(result) == bytes:
try: try:
result = result.decode('utf-8') result = result.decode('utf-8')
except : except :
result = result.decode('gb2312') result = result.decode('gb2312')
return result return result
except Exception as ex: except Exception as ex:
if headers: return False if headers: return False
@ -470,9 +469,9 @@ def httpPost(url, data, timeout=60, headers={}):
return result return result
except Exception as ex: except Exception as ex:
return str(ex); return str(ex);
def get_timeout(url,timeout=3): def get_timeout(url,timeout=3):
@ -484,10 +483,10 @@ def get_timeout(url,timeout=3):
def get_url(timeout = 0.5): def get_url(timeout = 0.5):
import json import json
try: try:
# #
node_list = [{"protocol":"http://","address":"dg1.bt.cn","port":"80","ping":500},{"protocol":"http://","address":"dg2.bt.cn","port":"80","ping":500},{"protocol":"http://","address":"node.aapanel.com","port":"80","ping":500},{"protocol":"http://","address":"download.bt.cn","port":"80","ping":500}] node_list = [{"protocol":"http://","address":"dg2.bt.cn","port":"80","ping":500},{"protocol":"http://","address":"dg1.bt.cn","port":"80","ping":500},{"protocol":"http://","address":"download.bt.cn","port":"80","ping":500},{"protocol":"http://","address":"hk1-node.bt.cn","port":"80","ping":500},{"protocol":"http://","address":"na1-node.bt.cn","port":"80","ping":500},{"protocol":"http://","address":"jp1-node.bt.cn","port":"80","ping":500}]
mnode1 = [] mnode1 = []
mnode2 = [] mnode2 = []
mnode3 = [] mnode3 = []
@ -510,12 +509,12 @@ def get_url(timeout = 0.5):
mnode = sorted(mnode3,key= lambda x:x['net'],reverse=True) mnode = sorted(mnode3,key= lambda x:x['net'],reverse=True)
else: #终选中等延迟,中等带宽 else: #终选中等延迟,中等带宽
mnode = sorted(mnode2,key= lambda x:x['ping'],reverse=False) mnode = sorted(mnode2,key= lambda x:x['ping'],reverse=False)
if not mnode: return 'http://download.bt.cn' if not mnode: return 'https://download.bt.cn'
#return mnode[0]['protocol'] + mnode[0]['address'] + ':' + mnode[0]['port'] #return mnode[0]['protocol'] + mnode[0]['address'] + ':' + mnode[0]['port']
return "https://" + mnode[0]['address'] return "https://" + mnode[0]['address']
except: except:
return 'http://download.bt.cn' return 'https://download.bt.cn'
@ -529,12 +528,12 @@ def del_file_access(filename,user):
sd = win32security.GetFileSecurity(filename, win32security.DACL_SECURITY_INFORMATION) sd = win32security.GetFileSecurity(filename, win32security.DACL_SECURITY_INFORMATION)
dacl = sd.GetSecurityDescriptorDacl() dacl = sd.GetSecurityDescriptorDacl()
ace_count = dacl.GetAceCount() ace_count = dacl.GetAceCount()
for i in range(ace_count ,0 ,-1): for i in range(ace_count ,0 ,-1):
try: try:
data = {} data = {}
data['rev'], data['access'], usersid = dacl.GetAce(i-1) data['rev'], data['access'], usersid = dacl.GetAce(i-1)
data['user'],data['group'], data['type'] = win32security.LookupAccountSid('', usersid) data['user'],data['group'], data['type'] = win32security.LookupAccountSid('', usersid)
if data['user'].lower() == user.lower(): dacl.DeleteAce(i-1) #删除旧的dacl if data['user'].lower() == user.lower(): dacl.DeleteAce(i-1) #删除旧的dacl
if data['user'].lower() == 'users': dacl.DeleteAce(i-1) #删除旧的dacl if data['user'].lower() == 'users': dacl.DeleteAce(i-1) #删除旧的dacl
@ -542,35 +541,35 @@ def del_file_access(filename,user):
try: try:
#处理拒绝访问 #处理拒绝访问
dacl.DeleteAce(i-1) dacl.DeleteAce(i-1)
except : pass except : pass
sd.SetSecurityDescriptorDacl(1, dacl, 0) sd.SetSecurityDescriptorDacl(1, dacl, 0)
win32security.SetFileSecurity(filename, win32security.DACL_SECURITY_INFORMATION, sd) win32security.SetFileSecurity(filename, win32security.DACL_SECURITY_INFORMATION, sd)
except : except :
pass pass
return True return True
def set_file_access(filename,user,access): def set_file_access(filename,user,access):
try: try:
sd = win32security.GetFileSecurity(filename, win32security.DACL_SECURITY_INFORMATION) sd = win32security.GetFileSecurity(filename, win32security.DACL_SECURITY_INFORMATION)
dacl = sd.GetSecurityDescriptorDacl() dacl = sd.GetSecurityDescriptorDacl()
ace_count = dacl.GetAceCount() ace_count = dacl.GetAceCount()
for i in range(ace_count, 0,-1): for i in range(ace_count, 0,-1):
try: try:
data = {} data = {}
data['rev'], data['access'], usersid = dacl.GetAce(i-1) data['rev'], data['access'], usersid = dacl.GetAce(i-1)
data['user'],data['group'], data['type'] = win32security.LookupAccountSid('', usersid) data['user'],data['group'], data['type'] = win32security.LookupAccountSid('', usersid)
if data['user'].lower() == user.lower(): dacl.DeleteAce(i-1) #删除旧的dacl if data['user'].lower() == user.lower(): dacl.DeleteAce(i-1) #删除旧的dacl
if data['user'].lower() == 'users': dacl.DeleteAce(i-1) #删除旧的dacl if data['user'].lower() == 'users': dacl.DeleteAce(i-1) #删除旧的dacl
except : except :
pass pass
try: try:
userx, domain, type = win32security.LookupAccountName("", user) userx, domain, type = win32security.LookupAccountName("", user)
except : except :
userx, domain, type = win32security.LookupAccountName("", 'IIS APPPOOL\\' + user) userx, domain, type = win32security.LookupAccountName("", 'IIS APPPOOL\\' + user)
if access > 0: dacl.AddAccessAllowedAceEx(win32security.ACL_REVISION, 3, access, userx) if access > 0: dacl.AddAccessAllowedAceEx(win32security.ACL_REVISION, 3, access, userx)
sd.SetSecurityDescriptorDacl(1, dacl, 0) sd.SetSecurityDescriptorDacl(1, dacl, 0)
win32security.SetFileSecurity(filename, win32security.DACL_SECURITY_INFORMATION, sd) win32security.SetFileSecurity(filename, win32security.DACL_SECURITY_INFORMATION, sd)
return True,None return True,None
@ -582,24 +581,24 @@ def ExecShell(cmdstring, cwd=None, timeout=None, shell=True):
cmdstring_list = cmdstring cmdstring_list = cmdstring
else: else:
cmdstring_list = shlex.split(cmdstring) cmdstring_list = shlex.split(cmdstring)
if timeout: if timeout:
end_time = datetime.datetime.now() + datetime.timedelta(seconds=timeout) end_time = datetime.datetime.now() + datetime.timedelta(seconds=timeout)
sub = subprocess.Popen(cmdstring_list, cwd=cwd, stdin=subprocess.PIPE,shell=shell,stdout=subprocess.PIPE,stderr=subprocess.PIPE) sub = subprocess.Popen(cmdstring_list, cwd=cwd, stdin=subprocess.PIPE,shell=shell,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
while sub.poll() is None: while sub.poll() is None:
time.sleep(0.1) time.sleep(0.1)
if timeout: if timeout:
if end_time <= datetime.datetime.now(): if end_time <= datetime.datetime.now():
raise Exception("Timeout%s"%cmdstring) raise Exception("Timeout%s"%cmdstring)
a,e = sub.communicate() a,e = sub.communicate()
if type(a) == bytes: if type(a) == bytes:
try: try:
a = a.decode('utf-8') a = a.decode('utf-8')
except : except :
a = a.decode('gb2312','ignore') a = a.decode('gb2312','ignore')
if type(e) == bytes: if type(e) == bytes:
try: try:
e = e.decode('utf-8') e = e.decode('utf-8')
except : except :
@ -626,7 +625,7 @@ def GetRandomString1(length):
strings += chars[random.randint(0, chrlen)] strings += chars[random.randint(0, chrlen)]
return strings return strings
def GetRandomString2(length): def GetRandomString2(length):
from random import Random from random import Random
strings = '' strings = ''
chars = '!@#$%^&*()_+.,?[]-=' chars = '!@#$%^&*()_+.,?[]-='
@ -637,7 +636,7 @@ def GetRandomString2(length):
return strings return strings
def chdck_salt(): def chdck_salt():
sql = Sql() sql = Sql()
sql.table('users').execute("ALTER TABLE 'users' ADD 'salt' TEXT",()) sql.table('users').execute("ALTER TABLE 'users' ADD 'salt' TEXT",())
@ -657,7 +656,7 @@ def md5(strings):
""" """
import hashlib import hashlib
m = hashlib.md5() m = hashlib.md5()
m.update(strings.encode('utf-8')) m.update(strings.encode('utf-8'))
return m.hexdigest() return m.hexdigest()
@ -673,18 +672,18 @@ def password_salt(password,username=None,uid=None):
salt = sql.table('users').where('id=?',(uid,)).getField('salt') salt = sql.table('users').where('id=?',(uid,)).getField('salt')
return md5(md5(password+'_bt.cn')+salt) return md5(md5(password+'_bt.cn')+salt)
def check_user(username): def check_user(username):
resume = 0 resume = 0
while True: while True:
data, total, resume = win32net.NetUserEnum(None, 3, win32netcon.FILTER_NORMAL_ACCOUNT, resume) data, total, resume = win32net.NetUserEnum(None, 3, win32netcon.FILTER_NORMAL_ACCOUNT, resume)
for user in data: for user in data:
if user['name'] == username: return True if user['name'] == username: return True
if not resume: break if not resume: break
return False return False
def add_user(username,password,ps): def add_user(username,password,ps):
try: try:
if not check_user(username): if not check_user(username):
d = {} d = {}
d['name'] = username d['name'] = username
d['password'] = password d['password'] = password
@ -692,7 +691,7 @@ def add_user(username,password,ps):
d['flags'] = win32netcon.UF_NORMAL_ACCOUNT | win32netcon.UF_SCRIPT d['flags'] = win32netcon.UF_NORMAL_ACCOUNT | win32netcon.UF_SCRIPT
d['priv'] = win32netcon.USER_PRIV_USER d['priv'] = win32netcon.USER_PRIV_USER
win32net.NetUserAdd(None, 1, d) win32net.NetUserAdd(None, 1, d)
#设置用户允许登录服务 #设置用户允许登录服务
handle = win32security.LsaOpenPolicy(None, win32security.POLICY_ALL_ACCESS) handle = win32security.LsaOpenPolicy(None, win32security.POLICY_ALL_ACCESS)
sid_obj, domain, tmp = win32security.LookupAccountName(None, username) sid_obj, domain, tmp = win32security.LookupAccountName(None, username)
@ -713,25 +712,25 @@ def add_user_bywww():
pwd = GetRandomString(64) + GetRandomString1(32) + GetRandomString2(32) pwd = GetRandomString(64) + GetRandomString1(32) + GetRandomString2(32)
status,error = add_user('www',pwd,'用于启动宝塔安装的程序,删除后会导致部分软件无法启动,请勿删除') status,error = add_user('www',pwd,'用于启动宝塔安装的程序,删除后会导致部分软件无法启动,请勿删除')
if not status: if not status:
writeFile(error_path,error) writeFile(error_path,error)
return False return False
return True return True
def add_user_bymysql(): def add_user_bymysql():
pwd = GetRandomString(64) + GetRandomString1(32) + GetRandomString2(32) pwd = GetRandomString(64) + GetRandomString1(32) + GetRandomString2(32)
status,error = add_user('mysql',pwd,'用于启动宝塔安装的程序,删除后会导致部分软件无法启动,请勿删除') status,error = add_user('mysql',pwd,'用于启动宝塔安装的程序,删除后会导致部分软件无法启动,请勿删除')
if not status: if not status:
writeFile(error_path,error) writeFile(error_path,error)
return False return False
return True return True
def getIP(url): def getIP(url):
import socket,re import socket,re
tmp = re.search('http://(.+)\:\d*',url) tmp = re.search('http://(.+)\:\d*',url)
if tmp: if tmp:
domain = tmp.groups()[0] domain = tmp.groups()[0]
myaddr = socket.getaddrinfo(domain, 'http') myaddr = socket.getaddrinfo(domain, 'http')
return myaddr[0][4][0] return myaddr[0][4][0]
@ -756,14 +755,14 @@ def add_panel_dir():
] ]
is_break = False is_break = False
for sobj in slist: for sobj in slist:
if not os.path.exists(sobj[0]): if not os.path.exists(sobj[0]):
os.makedirs(sobj[0]) os.makedirs(sobj[0])
n = 0 n = 0
while n < 5: while n < 5:
if os.path.exists(sobj[0]): break if os.path.exists(sobj[0]): break
os.makedirs(sobj[0]) os.makedirs(sobj[0])
time.sleep(0.5) time.sleep(0.5)
n += 1 n += 1
@ -773,17 +772,17 @@ def add_panel_dir():
del_file_access(sobj[0],'users') del_file_access(sobj[0],'users')
for user in sobj[1]: for user in sobj[1]:
n = 0 n = 0
while n < 3: while n < 3:
status,error = set_file_access(sobj[0],user,2032127) status,error = set_file_access(sobj[0],user,2032127)
if status: break if status: break
time.sleep(0.5) time.sleep(0.5)
if not status: if not status:
writeFile(error_path,"目录{}设置{}权限设置错误 -> {}".format(sobj[0],user,error)) writeFile(error_path,"目录{}设置{}权限设置错误 -> {}".format(sobj[0],user,error))
break break
del_file_access(setupPath,'users') del_file_access(setupPath,'users')
url = get_url() url = get_url()
@ -793,18 +792,18 @@ def add_panel_dir():
download_url = '{}/win/panel/data/{}'.format(url,f_name) download_url = '{}/win/panel/data/{}'.format(url,f_name)
n = 0 n = 0
while n < 10: while n < 10:
n += 1; n += 1;
try: try:
if os.path.exists(local_path) and os.path.getsize(local_path) < 10: os.remove(local_path) if os.path.exists(local_path) and os.path.getsize(local_path) < 10: os.remove(local_path)
if not os.path.exists(local_path): downloadFileByWget(download_url,local_path) if not os.path.exists(local_path): downloadFileByWget(download_url,local_path)
if os.path.getsize(local_path) and os.path.getsize(local_path) > 10: break; if os.path.getsize(local_path) and os.path.getsize(local_path) > 10: break;
writeFile(error_path,'download {} error ->> {} \r\n {}'.format(f_name,download_url,"")) writeFile(error_path,'download {} error ->> {} \r\n {}'.format(f_name,download_url,""))
except : except :
ip = getIP(url) ip = getIP(url)
writeFile(error_path,'download {} error ->> {} \r\n connect {} \r\n {}'.format(ip,f_name,download_url,get_error_info())) writeFile(error_path,'download {} error ->> {} \r\n connect {} \r\n {}'.format(ip,f_name,download_url,get_error_info()))
if n > 5: return False if n > 5: return False
time.sleep(0.2) time.sleep(0.2)
@ -816,9 +815,9 @@ def add_panel_dir():
def unzip(src_path,dst_path): def unzip(src_path,dst_path):
import zipfile import zipfile
zip_file = zipfile.ZipFile(src_path) zip_file = zipfile.ZipFile(src_path)
for names in zip_file.namelist(): for names in zip_file.namelist():
zip_file.extract(names,dst_path) zip_file.extract(names,dst_path)
zip_file.close() zip_file.close()
return True return True
@ -834,44 +833,44 @@ def download_panel(file_list = []):
#下载面板 #下载面板
loacl_path = setupPath + '/panel.zip' loacl_path = setupPath + '/panel.zip'
tmpPath = "{}/temp/panel".format(setupPath) tmpPath = "{}/temp/panel".format(setupPath)
if os.path.exists(loacl_path): os.remove(loacl_path) if os.path.exists(loacl_path): os.remove(loacl_path)
if os.path.exists(tmpPath): shutil.rmtree(tmpPath,True) if os.path.exists(tmpPath): shutil.rmtree(tmpPath,True)
if not os.path.exists(tmpPath): os.makedirs(tmpPath) if not os.path.exists(tmpPath): os.makedirs(tmpPath)
p_ver = sys.argv[2] p_ver = sys.argv[2]
downUrl = url + '/win/panel/panel_' + p_ver + '.zip'; downUrl = url + '/win/panel/panel_' + p_ver + '.zip';
downloadFileByWget(downUrl,loacl_path); downloadFileByWget(downUrl,loacl_path);
unzip(loacl_path,tmpPath) unzip(loacl_path,tmpPath)
for ff_path in file_list: for ff_path in file_list:
if os.path.exists(tmpPath + '/' + ff_path): os.remove(tmpPath + '/' + ff_path) if os.path.exists(tmpPath + '/' + ff_path): os.remove(tmpPath + '/' + ff_path)
tcPath = '{}\class'.format(tmpPath) tcPath = '{}\class'.format(tmpPath)
for name in os.listdir(tcPath): for name in os.listdir(tcPath):
try: try:
if name.find('win_amd64.pyd') >=0: if name.find('win_amd64.pyd') >=0:
oldName = os.path.join(tcPath,name); oldName = os.path.join(tcPath,name);
lName = name.split('.')[0] + '.pyd' lName = name.split('.')[0] + '.pyd'
newName = os.path.join(tcPath,lName) newName = os.path.join(tcPath,lName)
if not os.path.exists(newName):os.rename(oldName,newName) if not os.path.exists(newName):os.rename(oldName,newName)
except :pass except :pass
cPath = '{}/panel/class'.format(setupPath) cPath = '{}/panel/class'.format(setupPath)
if os.path.exists(cPath): if os.path.exists(cPath):
os.system("del /s {}\*.pyc".format(to_path(cPath))) os.system("del /s {}\*.pyc".format(to_path(cPath)))
os.system("del /s {}\*.pyt".format(to_path(cPath))) os.system("del /s {}\*.pyt".format(to_path(cPath)))
for name in os.listdir(cPath): for name in os.listdir(cPath):
try: try:
if name.find('.pyd') >=0: if name.find('.pyd') >=0:
oldName = os.path.join(cPath,name) oldName = os.path.join(cPath,name)
newName = os.path.join(cPath,GetRandomString(8) + '.pyt') newName = os.path.join(cPath,GetRandomString(8) + '.pyt')
os.rename(oldName,newName) os.rename(oldName,newName)
except : pass except : pass
os.system("del /s {}\*.pyc".format(to_path(cPath))) os.system("del /s {}\*.pyc".format(to_path(cPath)))
os.system("del /s {}\*.pyt".format(to_path(cPath))) os.system("del /s {}\*.pyt".format(to_path(cPath)))
os.system("xcopy /s /c /e /y /r {} {}".format(to_path(tmpPath),to_path(panelPath))) os.system("xcopy /s /c /e /y /r {} {}".format(to_path(tmpPath),to_path(panelPath)))
try: try:
os.remove(loacl_path) os.remove(loacl_path)
except : pass except : pass
@ -880,7 +879,7 @@ def download_panel(file_list = []):
shutil.rmtree(tmpPath,True) shutil.rmtree(tmpPath,True)
except : pass except : pass
s_ver = platform.platform() s_ver = platform.platform()
net_v = '45' net_v = '45'
if s_ver.find('2008') >= 0: net_v = '20' if s_ver.find('2008') >= 0: net_v = '20'
writeFile('{}/data/net'.format(setupPath),net_v) writeFile('{}/data/net'.format(setupPath),net_v)
@ -910,7 +909,7 @@ def download_panel(file_list = []):
try: try:
from gevent import monkey from gevent import monkey
except : except :
os.system('"C:\Program Files\python\python.exe" -m pip install gevent') os.system('"C:\Program Files\python\python.exe" -m pip install gevent')
except : except :
writeFile(error_path,get_error_info()) writeFile(error_path,get_error_info())
@ -918,7 +917,7 @@ def update_panel():
file_list = ['config/config.json','config/index.json','data/libList.conf','data/plugin.json'] file_list = ['config/config.json','config/index.json','data/libList.conf','data/plugin.json']
download_panel(file_list) download_panel(file_list)
py_path = 'C:/Program Files/python/python.exe' py_path = 'C:/Program Files/python/python.exe'
ExecShell("\"{}\" {}/panel/runserver.py --startup auto install".format(py_path,setupPath)) ExecShell("\"{}\" {}/panel/runserver.py --startup auto install".format(py_path,setupPath))
@ -929,7 +928,7 @@ def update_panel():
def init_panel_data(): def init_panel_data():
try: try:
sql = Sql() sql = Sql()
username = sql.table('users').where('id=?',(1,)).getField('username') username = sql.table('users').where('id=?',(1,)).getField('username')
if username == 'admin': if username == 'admin':
username = GetRandomString(8) username = GetRandomString(8)
password = GetRandomString(8) password = GetRandomString(8)
@ -937,12 +936,12 @@ def init_panel_data():
sql.table('users').where('id=?',(1,)).setField('username',username) sql.table('users').where('id=?',(1,)).setField('username',username)
pwd = password_salt(md5(password),uid=1) pwd = password_salt(md5(password),uid=1)
result = sql.table('users').where('id=?',(1,)).setField('password',pwd) result = sql.table('users').where('id=?',(1,)).setField('password',pwd)
backup_path = panelPath[:2] + '/backup' backup_path = panelPath[:2] + '/backup'
www_path = panelPath[:2] + '/wwwroot' www_path = panelPath[:2] + '/wwwroot'
if not os.path.exists(backup_path): os.makedirs(backup_path) if not os.path.exists(backup_path): os.makedirs(backup_path)
if not os.path.exists(www_path): os.makedirs(www_path) if not os.path.exists(www_path): os.makedirs(www_path)
@ -953,11 +952,11 @@ def init_panel_data():
if not os.path.exists(bind_path): writeFile(bind_path,'True') if not os.path.exists(bind_path): writeFile(bind_path,'True')
admin_path = panelPath+ '/data/admin_path.pl' admin_path = panelPath+ '/data/admin_path.pl'
if not os.path.exists(admin_path): writeFile(admin_path,"/" + GetRandomString(8)) if not os.path.exists(admin_path): writeFile(admin_path,"/" + GetRandomString(8))
port_path = panelPath+ '/data/port.pl' port_path = panelPath+ '/data/port.pl'
if not os.path.exists(port_path): writeFile(port_path,'8888') if not os.path.exists(port_path): writeFile(port_path,'8888')
recycle_bin_db = panelPath+ '/data/recycle_bin_db.pl' recycle_bin_db = panelPath+ '/data/recycle_bin_db.pl'
if not os.path.exists(recycle_bin_db): writeFile(recycle_bin_db,'True') if not os.path.exists(recycle_bin_db): writeFile(recycle_bin_db,'True')
@ -975,26 +974,26 @@ def init_panel_data():
except : except :
writeFile(error_path,get_error_info()) writeFile(error_path,get_error_info())
return False return False
def add_panel_services(num = 0): def add_panel_services(num = 0):
try: try:
py_path = 'C:/Program Files/python/python.exe' py_path = 'C:/Program Files/python/python.exe'
delete_server('btPanel') delete_server('btPanel')
ret = ExecShell("\"{}\" {}/panel/runserver.py --startup auto install".format(py_path,setupPath)) ret = ExecShell("\"{}\" {}/panel/runserver.py --startup auto install".format(py_path,setupPath))
delete_server('btTask') delete_server('btTask')
ExecShell("\"{}\" {}/panel/task.py --startup auto install".format(py_path,setupPath)) ret1 = ExecShell("\"{}\" {}/panel/task.py --startup auto install".format(py_path,setupPath))
if get_server_status('btPanel') < 0 or get_server_status('btTask') < 0: if get_server_status('btPanel') < 0 or get_server_status('btTask') < 0:
if num <= 0 : if num <= 0 :
localPath = setupPath + "/temp/Time_Zones.reg"; localPath = setupPath + "/temp/Time_Zones.reg";
downloadFileByWget(get_url() + '/win/panel/data/Time_Zones.reg',localPath) downloadFileByWget(get_url() + '/win/panel/data/Time_Zones.reg',localPath)
ExecShell("regedit /s " + localPath) ExecShell("regedit /s " + localPath)
add_panel_services(1) add_panel_services(1)
else: else:
writeFile(error_path,ret[0] + ret[1]) writeFile(error_path,ret[0] + ret[1] + ret1[0] + ret1[1])
else: else:
os.system('sc failure btPanel reset=1800 actions=restart/60000/restart/120000/restart/30000') os.system('sc failure btPanel reset=1800 actions=restart/60000/restart/120000/restart/30000')
os.system('sc failure btTask reset=1800 actions=restart/60000/restart/120000/restart/30000') os.system('sc failure btTask reset=1800 actions=restart/60000/restart/120000/restart/30000')
@ -1005,9 +1004,9 @@ def add_panel_services(num = 0):
def add_firewall_byport(): def add_firewall_byport():
conf = ExecShell('netsh advfirewall firewall show rule "宝塔面板"')[0] conf = ExecShell('netsh advfirewall firewall show rule "宝塔面板"')[0]
if conf.lower().find('tcp') == -1: if conf.lower().find('tcp') == -1:
ExecShell("netsh advfirewall firewall add rule name=宝塔面板 dir=in action=allow protocol=tcp localport=8888"); ExecShell("netsh advfirewall firewall add rule name=宝塔面板 dir=in action=allow protocol=tcp localport=8888");
ExecShell("netsh advfirewall firewall add rule name=网站访问端口 dir=in action=allow protocol=tcp localport=80"); ExecShell("netsh advfirewall firewall add rule name=网站访问端口 dir=in action=allow protocol=tcp localport=80");
ExecShell("netsh advfirewall firewall add rule name=远程桌面 dir=in action=allow protocol=tcp localport=3389"); ExecShell("netsh advfirewall firewall add rule name=远程桌面 dir=in action=allow protocol=tcp localport=3389");
@ -1029,8 +1028,8 @@ def get_error_log():
return error return error
if __name__ == "__main__": if __name__ == "__main__":
stype = sys.argv[1]; stype = sys.argv[1];
if not stype in ['get_error_log']: if not stype in ['get_error_log']:
if os.path.exists(error_path): os.remove(error_path) if os.path.exists(error_path): os.remove(error_path)
result = eval('{}()'.format(stype)) result = eval('{}()'.format(stype))
print(result) print(result)