MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / app_bind

Method app_bind

mod/project/node/nodeutil/base.py:98–125  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

96 return host
97
98 def app_bind(self) -> Optional[str]:
99 if self.app_key is None:
100 return "app秘钥解析失败,请重新确认秘钥信息"
101 version, arch = _get_os_info()
102 public.print_log(self.app_key.app_token)
103 pdata = {
104 "bind_token": self.app_key.app_token,
105 "client_brand": "BT-Panel",
106 "client_model": "Linux" if not version else "Linux {} {}".format(version, arch)
107 }
108 header = {
109 'Content-Type': 'application/x-www-form-urlencoded',
110 "User-Agent": "Bt-Panel/Node Manager"
111 }
112 bind_url = self.app_key.origin + "/check_bind"
113 try:
114 res = requests.post(bind_url, data=pdata, headers=header, verify=False, timeout=self.timeout)
115 if res.status_code != 200:
116 return "绑定请求失败,返回状态码:%s,响应信息为:%s" % (res.status_code, res.text)
117 res_str = res.text.strip()
118 if res_str == "0":
119 return "绑定失败,请检查您的密钥是否正确"
120 elif res_str == "1":
121 return None
122 else:
123 return "绑定失败,错误信息为:{}".format(json.loads(res_str))
124 except Exception as e:
125 return "网络连接失败,无法请求到目标服务器"
126
127 def app_bind_status(self) -> Optional[str]:
128 if self.app_key is None:

Callers 1

bind_appMethod · 0.95

Calls 5

_get_os_infoFunction · 0.85
print_logMethod · 0.45
formatMethod · 0.45
postMethod · 0.45
loadsMethod · 0.45

Tested by

no test coverage detected