feat(protocols): add support for ss obfs, ss2022, and vless reality
- Clash and Clash Meta: Added support for Shadowsocks (SS) with obfs. - Loon: Added support for SS2022 and obfs. - Stash: Added support for SS2022, obfs, and VLESS Reality.
This commit is contained in:
@@ -144,6 +144,13 @@ class Clash implements ProtocolInterface
|
|||||||
$array['cipher'] = data_get($protocol_settings, 'cipher');
|
$array['cipher'] = data_get($protocol_settings, 'cipher');
|
||||||
$array['password'] = $uuid;
|
$array['password'] = $uuid;
|
||||||
$array['udp'] = true;
|
$array['udp'] = true;
|
||||||
|
if (data_get($protocol_settings, 'obfs') == 'http') {
|
||||||
|
$array['plugin'] = 'obfs';
|
||||||
|
$array['plugin-opts'] = [
|
||||||
|
'mode' => 'http',
|
||||||
|
'host' => data_get($protocol_settings, 'obfs.host'),
|
||||||
|
];
|
||||||
|
}
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ class ClashMeta implements ProtocolInterface
|
|||||||
|
|
||||||
public static function buildShadowsocks($password, $server)
|
public static function buildShadowsocks($password, $server)
|
||||||
{
|
{
|
||||||
|
$protocol_settings = $server['protocol_settings'];
|
||||||
$array = [];
|
$array = [];
|
||||||
$array['name'] = $server['name'];
|
$array['name'] = $server['name'];
|
||||||
$array['type'] = 'ss';
|
$array['type'] = 'ss';
|
||||||
@@ -161,6 +162,13 @@ class ClashMeta implements ProtocolInterface
|
|||||||
$array['cipher'] = data_get($server['protocol_settings'], 'cipher');
|
$array['cipher'] = data_get($server['protocol_settings'], 'cipher');
|
||||||
$array['password'] = data_get($server, 'password', $password);
|
$array['password'] = data_get($server, 'password', $password);
|
||||||
$array['udp'] = true;
|
$array['udp'] = true;
|
||||||
|
if (data_get($protocol_settings, 'obfs') == 'http') {
|
||||||
|
$array['plugin'] = 'obfs';
|
||||||
|
$array['plugin-opts'] = [
|
||||||
|
'mode' => 'http',
|
||||||
|
'host' => data_get($protocol_settings, 'obfs.host'),
|
||||||
|
];
|
||||||
|
}
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-8
@@ -31,12 +31,6 @@ class Loon implements ProtocolInterface
|
|||||||
foreach ($servers as $item) {
|
foreach ($servers as $item) {
|
||||||
if (
|
if (
|
||||||
$item['type'] === 'shadowsocks'
|
$item['type'] === 'shadowsocks'
|
||||||
&& in_array(data_get($item['protocol_settings'], 'cipher'), [
|
|
||||||
'aes-128-gcm',
|
|
||||||
'aes-192-gcm',
|
|
||||||
'aes-256-gcm',
|
|
||||||
'chacha20-ietf-poly1305'
|
|
||||||
])
|
|
||||||
) {
|
) {
|
||||||
$uri .= self::buildShadowsocks($item['password'], $item);
|
$uri .= self::buildShadowsocks($item['password'], $item);
|
||||||
}
|
}
|
||||||
@@ -58,6 +52,10 @@ class Loon implements ProtocolInterface
|
|||||||
public static function buildShadowsocks($password, $server)
|
public static function buildShadowsocks($password, $server)
|
||||||
{
|
{
|
||||||
$cipher = data_get($server['protocol_settings'], 'cipher');
|
$cipher = data_get($server['protocol_settings'], 'cipher');
|
||||||
|
$obfs = data_get($server['protocol_settings'], 'obfs');
|
||||||
|
$obfs_host = data_get($server['protocol_settings'], 'obfs_settings.host');
|
||||||
|
$obfs_uri = data_get($server['protocol_settings'], 'obfs_settings.path', '/');
|
||||||
|
|
||||||
$config = [
|
$config = [
|
||||||
"{$server['name']}=Shadowsocks",
|
"{$server['name']}=Shadowsocks",
|
||||||
"{$server['host']}",
|
"{$server['host']}",
|
||||||
@@ -67,9 +65,15 @@ class Loon implements ProtocolInterface
|
|||||||
'fast-open=false',
|
'fast-open=false',
|
||||||
'udp=true'
|
'udp=true'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($obfs && $obfs_host) {
|
||||||
|
$config[] = "obfs-name={$obfs}";
|
||||||
|
$config[] = "obfs-host={$obfs_host}";
|
||||||
|
$config[] = "obfs-uri={$obfs_uri}";
|
||||||
|
}
|
||||||
|
|
||||||
$config = array_filter($config);
|
$config = array_filter($config);
|
||||||
$uri = implode(',', $config);
|
$uri = implode(',', $config) . "\r\n";
|
||||||
$uri .= "\r\n";
|
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-11
@@ -5,6 +5,7 @@ namespace App\Protocols;
|
|||||||
use App\Models\ServerHysteria;
|
use App\Models\ServerHysteria;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
use App\Contracts\ProtocolInterface;
|
use App\Contracts\ProtocolInterface;
|
||||||
|
use App\Utils\Helper;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
|
|
||||||
class Stash implements ProtocolInterface
|
class Stash implements ProtocolInterface
|
||||||
@@ -49,12 +50,6 @@ class Stash implements ProtocolInterface
|
|||||||
foreach ($servers as $item) {
|
foreach ($servers as $item) {
|
||||||
if (
|
if (
|
||||||
$item['type'] === 'shadowsocks'
|
$item['type'] === 'shadowsocks'
|
||||||
&& in_array(data_get($item, 'protocol_settings.cipher'), [
|
|
||||||
'aes-128-gcm',
|
|
||||||
'aes-192-gcm',
|
|
||||||
'aes-256-gcm',
|
|
||||||
'chacha20-ietf-poly1305'
|
|
||||||
])
|
|
||||||
) {
|
) {
|
||||||
array_push($proxy, self::buildShadowsocks($item['password'], $item));
|
array_push($proxy, self::buildShadowsocks($item['password'], $item));
|
||||||
array_push($proxies, $item['name']);
|
array_push($proxies, $item['name']);
|
||||||
@@ -65,9 +60,6 @@ class Stash implements ProtocolInterface
|
|||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
$item['type'] === 'vless'
|
$item['type'] === 'vless'
|
||||||
&& in_array(data_get($item['protocol_settings'], 'network'), ['tcp', 'ws', 'grpc', 'http', 'h2'])
|
|
||||||
&& in_array(data_get($item['protocol_settings'], 'tls'), [1, 0])
|
|
||||||
&& in_array(data_get($item['protocol_settings'], 'flow'), ['xtls-rprx-origin', 'xtls-rprx-direct', 'xtls-rprx-splice'])
|
|
||||||
) {
|
) {
|
||||||
array_push($proxy, self::buildVless($user['uuid'], $item));
|
array_push($proxy, self::buildVless($user['uuid'], $item));
|
||||||
array_push($proxies, $item['name']);
|
array_push($proxies, $item['name']);
|
||||||
@@ -145,6 +137,13 @@ class Stash implements ProtocolInterface
|
|||||||
$array['cipher'] = data_get($protocol_settings, 'cipher');
|
$array['cipher'] = data_get($protocol_settings, 'cipher');
|
||||||
$array['password'] = $uuid;
|
$array['password'] = $uuid;
|
||||||
$array['udp'] = true;
|
$array['udp'] = true;
|
||||||
|
if (data_get($protocol_settings, 'obfs') == 'http') {
|
||||||
|
$array['plugin'] = 'obfs';
|
||||||
|
$array['plugin-opts'] = [
|
||||||
|
'mode' => 'http',
|
||||||
|
'host' => data_get($protocol_settings, 'obfs.host'),
|
||||||
|
];
|
||||||
|
}
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,8 +201,7 @@ class Stash implements ProtocolInterface
|
|||||||
$array['flow'] = data_get($protocol_settings, 'flow');
|
$array['flow'] = data_get($protocol_settings, 'flow');
|
||||||
$array['udp'] = true;
|
$array['udp'] = true;
|
||||||
|
|
||||||
$fingerprints = ['chrome', 'firefox', 'safari', 'ios', 'edge', 'qq']; //随机客户端指纹
|
$array['client-fingerprint'] = Helper::getRandFingerprint();
|
||||||
$array['client-fingerprint'] = $fingerprints[rand(0, count($fingerprints) - 1)];
|
|
||||||
|
|
||||||
switch (data_get($protocol_settings, 'tls')) {
|
switch (data_get($protocol_settings, 'tls')) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -213,6 +211,12 @@ class Stash implements ProtocolInterface
|
|||||||
$array['servername'] = $serverName;
|
$array['servername'] = $serverName;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
$array['tls'] = true;
|
||||||
|
$array['reality-opts']= [
|
||||||
|
'public-key' => data_get($protocol_settings, 'reality_settings.public_key'),
|
||||||
|
'short-id' => data_get($protocol_settings, 'reality_settings.short_id')
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (data_get($protocol_settings, 'network')) {
|
switch (data_get($protocol_settings, 'network')) {
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ class Helper
|
|||||||
|
|
||||||
public static function getRandFingerprint() {
|
public static function getRandFingerprint() {
|
||||||
$fingerprints = ['chrome', 'firefox', 'safari', 'ios', 'edge', 'qq'];
|
$fingerprints = ['chrome', 'firefox', 'safari', 'ios', 'edge', 'qq'];
|
||||||
return \Arr::random($fingerprints);
|
return Arr::random($fingerprints);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function encodeURIComponent($str) {
|
public static function encodeURIComponent($str) {
|
||||||
|
|||||||
Reference in New Issue
Block a user