mirror of
https://github.com/v2board/v2board.git
synced 2025-01-10 16:19:10 +08:00
update trojan
This commit is contained in:
parent
37449b6640
commit
75588d46f1
@ -10,9 +10,12 @@ class ServerTrojanSave extends FormRequest
|
|||||||
'show' => '',
|
'show' => '',
|
||||||
'name' => 'required',
|
'name' => 'required',
|
||||||
'group_id' => 'required|array',
|
'group_id' => 'required|array',
|
||||||
'host' => 'required|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i',
|
'parent_id' => 'nullable|integer',
|
||||||
|
'host' => 'required',
|
||||||
'port' => 'required',
|
'port' => 'required',
|
||||||
'server_port' => 'required',
|
'server_port' => 'required',
|
||||||
|
'allow_insecure' => 'nullable|in:0,1',
|
||||||
|
'server_name' => 'nullable',
|
||||||
'tags' => 'nullable|array',
|
'tags' => 'nullable|array',
|
||||||
'rate' => 'required|numeric'
|
'rate' => 'required|numeric'
|
||||||
];
|
];
|
||||||
@ -32,10 +35,11 @@ class ServerTrojanSave extends FormRequest
|
|||||||
'name.required' => '节点名称不能为空',
|
'name.required' => '节点名称不能为空',
|
||||||
'group_id.required' => '权限组不能为空',
|
'group_id.required' => '权限组不能为空',
|
||||||
'group_id.array' => '权限组格式不正确',
|
'group_id.array' => '权限组格式不正确',
|
||||||
|
'parent_id.integer' => '父节点格式不正确',
|
||||||
'host.required' => '节点地址不能为空',
|
'host.required' => '节点地址不能为空',
|
||||||
'host.regex' => '节点地址必须为域名',
|
|
||||||
'port.required' => '连接端口不能为空',
|
'port.required' => '连接端口不能为空',
|
||||||
'server_port.required' => '后端服务端口不能为空',
|
'server_port.required' => '后端服务端口不能为空',
|
||||||
|
'allow_insecure.in' => '允许不安全格式不正确',
|
||||||
'tags.array' => '标签格式不正确',
|
'tags.array' => '标签格式不正确',
|
||||||
'rate.required' => '倍率不能为空',
|
'rate.required' => '倍率不能为空',
|
||||||
'rate.numeric' => '倍率格式不正确'
|
'rate.numeric' => '倍率格式不正确'
|
||||||
|
@ -119,7 +119,7 @@ class ServerService
|
|||||||
|
|
||||||
$json = json_decode(self::TROJAN_CONFIG);
|
$json = json_decode(self::TROJAN_CONFIG);
|
||||||
$json->local_port = $server->server_port;
|
$json->local_port = $server->server_port;
|
||||||
$json->ssl->sni = $server->host;
|
$json->ssl->sni = $server->server_name ? $server->server_name : $server->host;
|
||||||
$json->ssl->cert = "/root/.cert/{$server->host}.crt";
|
$json->ssl->cert = "/root/.cert/{$server->host}.crt";
|
||||||
$json->ssl->key = "/root/.cert/{$server->host}.key";
|
$json->ssl->key = "/root/.cert/{$server->host}.key";
|
||||||
$json->api->api_port = $localPort;
|
$json->api->api_port = $localPort;
|
||||||
|
@ -41,6 +41,8 @@ class Clash
|
|||||||
$array['server'] = $server->host;
|
$array['server'] = $server->host;
|
||||||
$array['port'] = $server->port;
|
$array['port'] = $server->port;
|
||||||
$array['password'] = $password;
|
$array['password'] = $password;
|
||||||
|
$array['sni'] = $server->server_name;
|
||||||
|
$array['skip-cert-verify'] = $server->allow_insecure ? true : false;
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,11 @@ class Helper
|
|||||||
public static function buildTrojanLink(ServerTrojan $server, User $user)
|
public static function buildTrojanLink(ServerTrojan $server, User $user)
|
||||||
{
|
{
|
||||||
$server->name = rawurlencode($server->name);
|
$server->name = rawurlencode($server->name);
|
||||||
$uri = "trojan://{$user->uuid}@{$server->host}:{$server->port}#{$server->name}";
|
$query = http_build_query([
|
||||||
|
'allowInsecure' => $server->allow_insecure,
|
||||||
|
'peer' => $server->server_name
|
||||||
|
]);
|
||||||
|
$uri = "trojan://{$user->uuid}@{$server->host}:{$server->port}?{$query}#{$server->name}";
|
||||||
$uri .= "\r\n";
|
$uri .= "\r\n";
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,8 @@ class QuantumultX
|
|||||||
|
|
||||||
public static function buildTrojan($password, $server)
|
public static function buildTrojan($password, $server)
|
||||||
{
|
{
|
||||||
$uri = "trojan={$server->host}:{$server->port}, password={$password}, over-tls=true, tls-verification=true, fast-open=false, udp-relay=false, tag={$server->name}";
|
$tlsVerification = $server->allow_insecure ? true : false;
|
||||||
|
$uri = "trojan={$server->host}:{$server->port}, password={$password}, over-tls=true, tls-host={$server->server_name}, tls-verification={$tlsVerification}, fast-open=false, udp-relay=false, tag={$server->name}";
|
||||||
$uri .= "\r\n";
|
$uri .= "\r\n";
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
@ -190,15 +190,18 @@ CREATE TABLE `v2_server_stat` (
|
|||||||
|
|
||||||
DROP TABLE IF EXISTS `v2_server_trojan`;
|
DROP TABLE IF EXISTS `v2_server_trojan`;
|
||||||
CREATE TABLE `v2_server_trojan` (
|
CREATE TABLE `v2_server_trojan` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '节点ID',
|
||||||
`group_id` varchar(255) NOT NULL,
|
`group_id` varchar(255) NOT NULL COMMENT '节点组',
|
||||||
`tags` varchar(255) DEFAULT NULL,
|
`parent_id` int(11) DEFAULT NULL COMMENT '父节点',
|
||||||
`name` varchar(255) NOT NULL,
|
`tags` varchar(255) DEFAULT NULL COMMENT '节点标签',
|
||||||
`rate` varchar(11) NOT NULL,
|
`name` varchar(255) NOT NULL COMMENT '节点名称',
|
||||||
`host` varchar(255) NOT NULL,
|
`rate` varchar(11) NOT NULL COMMENT '倍率',
|
||||||
`port` int(11) NOT NULL,
|
`host` varchar(255) NOT NULL COMMENT '主机名',
|
||||||
`server_port` int(11) NOT NULL,
|
`port` int(11) NOT NULL COMMENT '连接端口',
|
||||||
`show` tinyint(1) NOT NULL DEFAULT '0',
|
`server_port` int(11) NOT NULL COMMENT '服务端口',
|
||||||
|
`allow_insecure` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否允许不安全',
|
||||||
|
`server_name` varchar(255) DEFAULT NULL,
|
||||||
|
`show` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否显示',
|
||||||
`sort` int(11) DEFAULT NULL,
|
`sort` int(11) DEFAULT NULL,
|
||||||
`created_at` int(11) NOT NULL,
|
`created_at` int(11) NOT NULL,
|
||||||
`updated_at` int(11) NOT NULL,
|
`updated_at` int(11) NOT NULL,
|
||||||
@ -283,4 +286,4 @@ CREATE TABLE `v2_user` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
-- 2020-06-18 12:12:19
|
-- 2020-07-01 07:01:59
|
||||||
|
@ -286,3 +286,13 @@ ADD `limit_plan_ids` varchar(255) NULL AFTER `limit_use`;
|
|||||||
|
|
||||||
ALTER TABLE `v2_server_trojan`
|
ALTER TABLE `v2_server_trojan`
|
||||||
ADD `server_port` int(11) NOT NULL AFTER `port`;
|
ADD `server_port` int(11) NOT NULL AFTER `port`;
|
||||||
|
|
||||||
|
ALTER TABLE `v2_server_trojan`
|
||||||
|
ADD `parent_id` int(11) NULL AFTER `group_id`;
|
||||||
|
|
||||||
|
ALTER TABLE `v2_server_trojan`
|
||||||
|
ADD `allow_insecure` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否允许不安全' AFTER `server_port`,
|
||||||
|
CHANGE `show` `show` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否显示' AFTER `allow_insecure`;
|
||||||
|
|
||||||
|
ALTER TABLE `v2_server_trojan`
|
||||||
|
ADD `server_name` varchar(255) NULL AFTER `allow_insecure`;
|
||||||
|
2
public/assets/admin/umi.js
vendored
2
public/assets/admin/umi.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user