Skip to content

Commit 7f5bd7e

Browse files
authored
Merge pull request #703 from kuizw9/master
Fix General.php for support AnyTLS and Shadowrocket.php for support Socks Node Name Display
2 parents b00b435 + 315b06d commit 7f5bd7e

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

app/Protocols/General.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class General extends AbstractProtocol
1717
Server::TYPE_SHADOWSOCKS,
1818
Server::TYPE_TROJAN,
1919
Server::TYPE_HYSTERIA,
20+
Server::TYPE_ANYTLS,
2021
Server::TYPE_SOCKS,
2122
];
2223

@@ -38,6 +39,7 @@ public function handle()
3839
Server::TYPE_SHADOWSOCKS => self::buildShadowsocks($item['password'], $item),
3940
Server::TYPE_TROJAN => self::buildTrojan($item['password'], $item),
4041
Server::TYPE_HYSTERIA => self::buildHysteria($item['password'], $item),
42+
Server::TYPE_ANYTLS => self::buildAnyTLS($item['password'], $item),
4143
Server::TYPE_SOCKS => self::buildSocks($item['password'], $item),
4244
default => '',
4345
};
@@ -255,6 +257,20 @@ public static function buildHysteria($password, $server)
255257
return $uri;
256258
}
257259

260+
public static function buildAnyTLS($password, $server)
261+
{
262+
$protocol_settings = $server['protocol_settings'];
263+
$name = rawurlencode($server['name']);
264+
$params = [
265+
'sni' => data_get($protocol_settings, 'tls.server_name'),
266+
'insecure' => data_get($protocol_settings, 'tls.allow_insecure')
267+
];
268+
$query = http_build_query($params);
269+
$uri = "anytls://{$password}@{$server['host']}:{$server['port']}?{$query}#{$name}";
270+
$uri .= "\r\n";
271+
return $uri;
272+
}
273+
258274
public static function buildSocks($password, $server)
259275
{
260276
$name = rawurlencode($server['name']);

app/Protocols/Shadowrocket.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,10 @@ public static function buildAnyTLS($password, $server)
356356
}
357357

358358
public static function buildSocks($password, $server)
359-
{
360-
$uri = "socks://" . base64_encode("{$password}:{$password}@{$server['host']}:{$server['port']}") . "?method=auto";
359+
{
360+
$protocol_settings = $server['protocol_settings'];
361+
$name = rawurlencode($server['name']);
362+
$uri = "socks://" . base64_encode("{$password}:{$password}@{$server['host']}:{$server['port']}") . "?method=auto#{$name}";
361363
$uri .= "\r\n";
362364
return $uri;
363365
}

0 commit comments

Comments
 (0)