def SetPanelSSL(self, get): if hasattr(get, "email"): rep_mail = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$" if not re.search(rep_mail, get.email): return public.returnMsg(False, '邮箱格式不合法') import setPanelLets sp = setPanelLets.setPanelLets() sps = sp.set_lets(get) return sps else: sslConf = '/www/server/panel/data/ssl.pl' if os.path.exists(sslConf): os.system('rm -f ' + sslConf) return public.returnMsg(True, 'PANEL_SSL_CLOSE') else: os.system('pip install cffi') os.system('pip install cryptography') os.system('pip install pyOpenSSL') try: if not self.CreateSSL(): return public.returnMsg(False, 'PANEL_SSL_ERR') public.writeFile(sslConf, 'True') except Exception as ex: return public.returnMsg(False, 'PANEL_SSL_ERR') return public.returnMsg(True, 'PANEL_SSL_OPEN')
def SetPanelSSL(self,get): if hasattr(get,"email"): #rep_mail = "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$" rep_mail = "[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?" if not re.search(rep_mail,get.email): return public.returnMsg(False,'邮箱格式不合法') import setPanelLets sp = setPanelLets.setPanelLets() sps = sp.set_lets(get) return sps else: sslConf = '/www/server/panel/data/ssl.pl'; if os.path.exists(sslConf): public.ExecShell('rm -f ' + sslConf); return public.returnMsg(True,'PANEL_SSL_CLOSE'); else: public.ExecShell('pip install cffi'); public.ExecShell('pip install cryptography'); public.ExecShell('pip install pyOpenSSL'); try: if not self.CreateSSL(): return public.returnMsg(False,'PANEL_SSL_ERR'); public.writeFile(sslConf,'True') except Exception as ex: return public.returnMsg(False,'PANEL_SSL_ERR'); return public.returnMsg(True,'PANEL_SSL_OPEN');
def check_panel_ssl(): try: while True: lets_info = public.readFile("/www/server/panel/ssl/lets.info") if lets_info: lets_info = json.loads(lets_info) cert_info_file = "/www/server/panel/vhost/ssl/" + lets_info["domain"] + "/info.json" cert_info = public.readFile(cert_info_file) if cert_info: cert_info = json.loads(cert_info) if setPanelLets.setPanelLets().copy_cert(cert_info): strTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))) public.writeFile("/tmp/panelSSL.pl","{} 面板证书更新成功".format(strTime)) time.sleep(60) except: e = public.get_error_info() public.writeFile("/tmp/panelSSL.pl", str(e))
def check_panel_ssl(): # info_file="" try: while True: lets_info = public.readFile("/www/server/panel/ssl/lets.info") if not lets_info: time.sleep(600) continue lets_info = loads(lets_info) if setPanelLets.setPanelLets().check_cert_update(lets_info['domain']): strTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))) public.writeFile("/tmp/panelSSL.pl","{} Panel certificate updated successfully\n".format(strTime),"a+") public.writeFile('/www/server/panel/data/reload.pl',"1") time.sleep(60) except: e = public.get_error_info() public.writeFile("/tmp/panelSSL.pl", str(e),"a+")
def get_cert_source(self, get): import setPanelLets sp = setPanelLets.setPanelLets() spg = sp.get_cert_source() return spg
#coding: utf-8 import os, sys, time os.chdir('/www/server/panel/') sys.path.insert(0, "class/") import setPanelLets, public from json import loads lets_info = public.readFile("/www/server/panel/ssl/lets.info") if lets_info: lets_info = loads(lets_info) if setPanelLets.setPanelLets().check_cert_update(lets_info['domain']): strTime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))) public.writeFile( "/tmp/panelSSL.pl", "{} Panel certificate updated successfully\n".format(strTime), "a+") public.writeFile('/www/server/panel/data/reload.pl', "1")