This commit is contained in:
Tokumeikoi 2020-03-30 23:40:55 +08:00
parent 4831c9f194
commit 39fadd8a63
3 changed files with 29 additions and 5 deletions

View File

@ -44,7 +44,7 @@ class ConfigSave extends FormRequest
'stripe_sk_live' => '',
'stripe_pk_live' => '',
'stripe_webhook_key' => '',
'stripe_currency' => 'in:hkd,usd,sgd',
'stripe_currency' => 'in:hkd,usd,sgd,eur',
// bitpayx
'bitpayx_enable' => 'in:0,1',
'bitpayx_appsecret' => '',

View File

@ -43,6 +43,22 @@ class ServerService
$json->inboundDetour[0]->port = (int)$localPort;
$json->inbound->port = (int)$server->server_port;
$json->inbound->streamSettings->network = $server->network;
$json = $this->setNetwork($server, $json);
$json = $this->setRule($server, $json);
$json = $this->setTls($server, $json);
return $json;
}
private function setDns(Server $server, object $json)
{
if ($server->dnsSettings) {
}
}
private function setNetwork(Server $server, object $json)
{
if ($server->networkSettings) {
switch ($server->network) {
case 'tcp':
@ -64,8 +80,12 @@ class ServerService
$json->inbound->streamSettings->quicSettings = json_decode($server->networkSettings);
break;
}
return $json;
}
}
private function setRule(Server $server, object $json)
{
if ($server->ruleSettings) {
$rules = json_decode($server->ruleSettings);
// domain
@ -84,8 +104,12 @@ class ServerService
$protocolObj->outboundTag = 'block';
array_push($json->routing->rules, $protocolObj);
}
return $json;
}
}
private function setTls(Server $server, object $json)
{
if ((int)$server->tls) {
$tlsSettings = json_decode($server->tlsSettings);
$json->inbound->streamSettings->security = 'tls';
@ -101,8 +125,7 @@ class ServerService
$json->inbound->streamSettings->tlsSettings->allowInsecure = (int)$tlsSettings->allowInsecure ? true : false;
}
$json->inbound->streamSettings->tlsSettings->certificates[0] = $tls;
return $json;
}
return $json;
}
}

View File

@ -129,12 +129,13 @@ CREATE TABLE `v2_server` (
`tls` tinyint(4) NOT NULL DEFAULT '0',
`tags` varchar(255) DEFAULT NULL,
`rate` varchar(11) NOT NULL,
`network` varchar(11) NOT NULL,
`network` text NOT NULL,
`settings` text,
`rules` text,
`networkSettings` text,
`tlsSettings` text,
`ruleSettings` text,
`dnsSettings` text,
`show` tinyint(1) NOT NULL DEFAULT '0',
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
@ -243,4 +244,4 @@ CREATE TABLE `v2_user` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 2020-03-17 14:16:01
-- 2020-03-30 09:56:24