ability to change subdomain for openconnect
This commit is contained in:
+41
-2
@@ -358,6 +358,9 @@ class Bot
|
||||
case preg_match('~^/changeCamouflage$~', $this->input['callback'], $m):
|
||||
$this->changeCamouflage();
|
||||
break;
|
||||
case preg_match('~^/changeOcDomain$~', $this->input['callback'], $m):
|
||||
$this->changeOcDomain();
|
||||
break;
|
||||
case preg_match('~^/changeOcPass$~', $this->input['callback'], $m):
|
||||
$this->changeOcPass();
|
||||
break;
|
||||
@@ -816,7 +819,7 @@ class Bot
|
||||
$this->input['chat'],
|
||||
"@{$this->input['username']} enter camouflage key",
|
||||
$this->input['message_id'],
|
||||
reply: 'enter password',
|
||||
reply: 'enter camouflage key',
|
||||
);
|
||||
$_SESSION['reply'][$r['result']['message_id']] = [
|
||||
'start_message' => $this->input['message_id'],
|
||||
@@ -826,6 +829,22 @@ class Bot
|
||||
];
|
||||
}
|
||||
|
||||
public function changeOcDomain()
|
||||
{
|
||||
$r = $this->send(
|
||||
$this->input['chat'],
|
||||
"@{$this->input['username']} enter subdomain",
|
||||
$this->input['message_id'],
|
||||
reply: 'enter subdomain',
|
||||
);
|
||||
$_SESSION['reply'][$r['result']['message_id']] = [
|
||||
'start_message' => $this->input['message_id'],
|
||||
'start_callback' => $this->input['callback_id'],
|
||||
'callback' => 'chOcSubdomain',
|
||||
'args' => [],
|
||||
];
|
||||
}
|
||||
|
||||
public function changeOcDns()
|
||||
{
|
||||
$r = $this->send(
|
||||
@@ -987,6 +1006,20 @@ class Bot
|
||||
$this->menu('oc');
|
||||
}
|
||||
|
||||
public function chOcSubdomain($domain)
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
if (empty($domain)) {
|
||||
unset($pac["oc_domain"]);
|
||||
} else {
|
||||
$pac["oc_domain"] = $domain;
|
||||
}
|
||||
$this->setPacConf($pac);
|
||||
$this->chocdomain($pac['domain']);
|
||||
$this->setUpstreamDomainOcserv($pac['domain']);
|
||||
$this->menu('oc');
|
||||
}
|
||||
|
||||
public function chnplogin($user)
|
||||
{
|
||||
$pac = $this->getPacConf();
|
||||
@@ -4926,6 +4959,12 @@ DNS-over-HTTPS with IP:
|
||||
$text[] = "<code>https://$oc.$domain/?$cs</code>";
|
||||
}
|
||||
$text[] = "password: <span class='tg-spoiler'>$pass</span>";
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('change subdomain'),
|
||||
'callback_data' => "/changeOcDomain",
|
||||
],
|
||||
];
|
||||
$data[] = [
|
||||
[
|
||||
'text' => $this->i18n('change secret'),
|
||||
@@ -6386,7 +6425,7 @@ DNS-over-HTTPS with IP:
|
||||
|
||||
public function getHashSubdomain($subdomain)
|
||||
{
|
||||
return substr(hash('sha256', "$subdomain{$this->key}"), 0, 8);
|
||||
return $this->getPacConf()["{$subdomain}_domain"] ?: substr(hash('sha256', "$subdomain{$this->key}"), 0, 8);
|
||||
}
|
||||
|
||||
public function addWg($page)
|
||||
|
||||
Reference in New Issue
Block a user