| 1182 | |
| 1183 | |
| 1184 | class LocalNode(ServerNode): |
| 1185 | is_local = True |
| 1186 | |
| 1187 | def __init__(self): |
| 1188 | super().__init__("", "", "") |
| 1189 | |
| 1190 | def create_php_site(self, site_name: str, port: int = 80, **kwargs) -> Tuple[Optional[int], str]: |
| 1191 | path = "/www/wwwroot/{}".format(site_name) |
| 1192 | webname = { |
| 1193 | "domain": site_name if port in (80, 443) else "{}:{}".format(site_name, port), |
| 1194 | "domainlist": [], |
| 1195 | "count": 0 |
| 1196 | } |
| 1197 | pdata = { |
| 1198 | "path": path, |
| 1199 | "ftp": "false", |
| 1200 | "type": "PHP", |
| 1201 | "type_id": "0", |
| 1202 | "ps": kwargs.get("ps") if kwargs.get("ps", None) else "{}【负载均衡站点】".format(site_name), |
| 1203 | "port": str(port), |
| 1204 | "version": "00", |
| 1205 | "sql": "false", |
| 1206 | "webname": json.dumps(webname) |
| 1207 | } |
| 1208 | |
| 1209 | if "/www/server/panel/class" not in sys.path: |
| 1210 | sys.path.insert(0, "/www/server/panel/class") |
| 1211 | |
| 1212 | from panelSite import panelSite |
| 1213 | |
| 1214 | res = panelSite().AddSite(public.to_dict_obj(pdata)) |
| 1215 | |
| 1216 | if "siteId" in res: |
| 1217 | return res["siteId"], "" |
| 1218 | if "status" in res and not res["status"]: |
| 1219 | return 0, res.get("msg", "未知错误") |
| 1220 | return 0, "未知错误" |
| 1221 | |
| 1222 | @staticmethod |
| 1223 | def site_proxy_list(site_name: str) -> List[dict]: |
| 1224 | from mod.base.web_conf.proxy import RealProxy |
| 1225 | data = RealProxy(config_prefix="").get_proxy_list(public.to_dict_obj({ |
| 1226 | "sitename": site_name |
| 1227 | })) |
| 1228 | if isinstance(data, list) and data: |
| 1229 | return data |
| 1230 | |
| 1231 | from panelSite import panelSite |
| 1232 | |
| 1233 | data = panelSite().GetProxyList(public.to_dict_obj({ |
| 1234 | "sitename": site_name |
| 1235 | })) |
| 1236 | if isinstance(data, list) and data: |
| 1237 | return data |
| 1238 | return [] |
| 1239 | |
| 1240 | def show_name(self) -> str: |
| 1241 | return "本机节点" |
no outgoing calls
no test coverage detected