(self, get)
| 670 | return public.returnMsg(False, '没有提交修改!') |
| 671 | |
| 672 | def setPanel(self, get): |
| 673 | if not public.IsRestart(): return public.returnMsg(False, 'EXEC_ERR_TASK') |
| 674 | limitip_path = "{}/data/limitip.conf".format(self._setup_path) |
| 675 | if not get.get('limitip') and os.path.exists(limitip_path): |
| 676 | os.truncate(limitip_path, 0) |
| 677 | |
| 678 | if 'limitip' in get: |
| 679 | if get.limitip.find('/') != -1: |
| 680 | return public.returnMsg(False, '授权IP格式不正确,不支持子网段写法') |
| 681 | isReWeb = False |
| 682 | sess_out_path = 'data/session_timeout.pl' |
| 683 | if 'session_timeout' in get: |
| 684 | try: |
| 685 | session_timeout = int(get.session_timeout) |
| 686 | s_time_tmp = public.readFile(sess_out_path) |
| 687 | if not s_time_tmp: s_time_tmp = '0' |
| 688 | if int(s_time_tmp) != session_timeout: |
| 689 | if session_timeout < 300: return public.returnMsg(False, '超时时间不能小于300秒') |
| 690 | if session_timeout > 86400 * 30: return public.returnMsg(False, '超时时间不能大于30天') |
| 691 | public.writeFile(sess_out_path, str(session_timeout)) |
| 692 | isReWeb = True |
| 693 | except: |
| 694 | # return public.returnMsg(False, "超时时间必需是整数!") |
| 695 | pass |
| 696 | # else: |
| 697 | # return public.returnMsg(False, '超时时间不能为空!') |
| 698 | |
| 699 | workers_p = 'data/workers.pl' |
| 700 | if 'workers' in get: |
| 701 | workers = int(get.workers) |
| 702 | if int(public.readFile(workers_p)) != workers: |
| 703 | if workers < 1 or workers > 1024: return public.returnMsg(False, '面板线程数范围应该在1-1024之间') |
| 704 | public.writeFile(workers_p, str(workers)) |
| 705 | isReWeb = True |
| 706 | |
| 707 | if "domain" in get and get.domain != "": |
| 708 | if re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", get.domain): return public.returnMsg(False, |
| 709 | '不能绑定ip') |
| 710 | reg = r"^([\w\-\*]{1,100}\.){1,4}(\w{1,10}|\w{1,10}\.\w{1,10})$" |
| 711 | if not re.match(reg, get.domain): return public.returnMsg(False, 'SITE_ADD_ERR_DOMAIN') |
| 712 | import idna |
| 713 | domain_idna = idna.encode(get.domain.strip()).decode("utf-8") |
| 714 | public.writeFile('data/domain.conf', domain_idna) |
| 715 | public.WriteLog('TYPE_PANEL', 'PANEL_SET_SUCCESS', (get.domain,)) |
| 716 | |
| 717 | if get.get("domain") == "": |
| 718 | if os.path.exists('data/domain.conf'): os.remove('data/domain.conf') |
| 719 | |
| 720 | if "address" in get and get.address != "": |
| 721 | if not public.check_ip(get.address): |
| 722 | return public.returnMsg(False, '请设置正确的服务器ipv4或ipv6地址') |
| 723 | public.writeFile('data/iplist.txt', get.address) |
| 724 | public.WriteLog('TYPE_PANEL', 'PANEL_SET_SUCCESS', (get.address,)) |
| 725 | |
| 726 | oldPort = public.GetHost(True) |
| 727 | if not 'port' in get: |
| 728 | get.port = oldPort |
| 729 | newPort = get.port |
nothing calls this directly
no test coverage detected