Skip to content

Commit

Permalink
Merge pull request #2167 from sspanel-uim/dev
Browse files Browse the repository at this point in the history
Dev 20230916
  • Loading branch information
M1Screw authored Sep 16, 2023
2 parents 6a97b2f + 70c1c7d commit 8fdefab
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 83 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ext-curl": "*",
"ext-fileinfo": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-mysqli": "*",
"ext-openssl": "*",
"ext-pdo": "*",
Expand Down
62 changes: 27 additions & 35 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 30 additions & 15 deletions config/appprofile.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
],
'dns' => [
'servers' => [
[
'tag' => 'local',
'address' => 'local',
],
[
'tag' => 'cloudflare',
'address' => '1.1.1.1',
'address' => 'https://1.1.1.1/dns-query',
'address_resolver' => 'local',
],
[
'tag' => 'dnspod',
'address' => '119.29.29.29',
'address' => 'https://1.12.12.12/dns-query',
'detour' => 'direct',
],
],
Expand Down Expand Up @@ -48,24 +53,24 @@
'server' => 'dnspod',
],
],
'strategy' => 'prefer_ipv4',
'strategy' => 'prefer_ipv6',
],
'inbounds' => [
[
"type" => "tun",
"inet4_address" => "172.19.0.1/30",
"auto_route" => true,
"strict_route" => true,
"endpoint_independent_nat" => true,
"udp_timeout" => 60,
"platform" => [
"http_proxy" => [
"enabled" => true,
"server" => "127.0.0.1",
"server_port" => 8100,
'type' => 'tun',
'inet4_address' => '172.19.0.1/30',
'auto_route' => true,
'strict_route' => true,
'endpoint_independent_nat' => true,
'udp_timeout' => 60,
'platform' => [
'http_proxy' => [
'enabled' => true,
'server' => '127.0.0.1',
'server_port' => 8100,
],
],
"sniff" => true,
'sniff' => true,
],
[
'type' => 'mixed',
Expand Down Expand Up @@ -95,6 +100,14 @@
],
],
'route' => [
'geoip' => [
'download_url' => 'https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geoip-lite.db',
'download_detour' => 'direct',
],
'geosite' => [
'download_url' => 'https://cdn.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@release/geosite-lite.db',
'download_detour' => 'direct',
],
'rules' => [
[
'protocol' => 'dns',
Expand Down Expand Up @@ -142,7 +155,9 @@
],
'experimental' => [
'clash_api' => [
'external_controller' => '0.0.0.0:9090',
'store_mode' => true,
'store_selected' => true,
'cache_id' => '',
],
],
Expand Down
6 changes: 4 additions & 2 deletions resources/views/tabler/admin/node/create.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
<div class="col">
<select id="sort" class="col form-select">
<option value="14">Trojan</option>
<option value="11">V2Ray</option>
<option value="11">Vmess</option>
<option value="2">TUIC</option>
<option value="1">Shadowsocks2022</option>
<option value="0">Shadowsocks</option>
</select>
</div>
Expand Down Expand Up @@ -184,4 +186,4 @@
});
</script>

{include file='admin/footer.tpl'}
{include file='admin/footer.tpl'}
6 changes: 4 additions & 2 deletions resources/views/tabler/admin/node/edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
<div class="col">
<select id="sort" class="col form-select" value="{$node->sort}">
<option value="14" {if $node->sort === 14}selected{/if}>Trojan</option>
<option value="11" {if $node->sort === 11}selected{/if}>V2Ray</option>
<option value="11" {if $node->sort === 11}selected{/if}>Vmess</option>
<option value="2" {if $node->sort === 2}selected{/if}>TUIC</option>
<option value="1" {if $node->sort === 1}selected{/if}>Shadowsocks2022</option>
<option value="0" {if $node->sort === 0}selected{/if}>Shadowsocks</option>
</select>
</div>
Expand Down Expand Up @@ -233,4 +235,4 @@
});
</script>

{include file='admin/footer.tpl'}
{include file='admin/footer.tpl'}
9 changes: 1 addition & 8 deletions src/Controllers/WebAPI/NodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,14 @@ public function getInfo(ServerRequest $request, Response $response, array $args)
]);
}

if ($node->sort === 0) {
$node_explode = explode(';', $node->server);
$node_server = $node_explode[0];
} else {
$node_server = $node->server;
}

$data = [
'node_group' => $node->node_group,
'node_class' => $node->node_class,
'node_speedlimit' => $node->node_speedlimit,
'traffic_rate' => $node->traffic_rate,
'mu_only' => 0,
'sort' => $node->sort,
'server' => $node_server,
'server' => $node->server,
'custom_config' => json_decode($node->custom_config, true, JSON_UNESCAPED_SLASHES),
'type' => 'SSPanel-UIM',
'version' => VERSION,
Expand Down
13 changes: 13 additions & 0 deletions src/Controllers/WebAPI/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public function index(ServerRequest $request, Response $response, array $args):

$keys_unset = match ((int) $node->sort) {
14, 11 => ['u', 'd', 'transfer_enable', 'method', 'port', 'passwd'],
2 => ['u', 'd', 'transfer_enable', 'method', 'port'],
1 => ['u', 'd', 'transfer_enable', 'method', 'port', 'uuid'],
default => ['u', 'd', 'transfer_enable', 'uuid']
};

Expand All @@ -102,6 +104,17 @@ public function index(ServerRequest $request, Response $response, array $args):
}
}

if ($node->sort === 1) {
$method = json_decode($node->custom_config)->method ?? '2022-blake3-aes-128-gcm';

$pk_len = match ($method) {
'2022-blake3-aes-128-gcm' => 16,
default => 32,
};

$user_raw->passwd = Tools::getSs2022UserPk($user_raw, $pk_len);
}

$user_raw->node_connector = 0;

foreach ($keys_unset as $key) {
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function sort(): string
0 => 'Shadowsocks',
1 => 'Shadowsocks2022',
2 => 'TUIC',
11 => 'V2Ray',
11 => 'Vmess',
14 => 'Trojan',
default => '未知',
};
Expand Down
Loading

0 comments on commit 8fdefab

Please sign in to comment.