From dd8267097ec000443f83997f68aa3a896cdd7bd8 Mon Sep 17 00:00:00 2001 From: ishkong <19740260+ishkong@users.noreply.github.com> Date: Sun, 21 Jul 2024 13:58:22 +0800 Subject: [PATCH 1/3] feat: Support Shadowsocks obfs config --- app/Services/ServerService.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Services/ServerService.php b/app/Services/ServerService.php index 6973556..8da9a3f 100644 --- a/app/Services/ServerService.php +++ b/app/Services/ServerService.php @@ -161,6 +161,11 @@ class ServerService $userKey = Helper::uuidToBase64($user['uuid'], $config['userKeySize']); $shadowsocks[$key]['password'] = "{$serverKey}:{$userKey}"; } + if ($v['obfs'] === 'http') { + $shadowsocks[$key]['obfs'] = 'http'; + $shadowsocks[$key]['obfs-host'] = $v['obfs_settings']['host']; + $shadowsocks[$key]['obfs-path'] = $v['obfs_settings']['path']; + } $servers[] = $shadowsocks[$key]->toArray(); } return $servers; From e46f2b3390f87cdd73bc94c59a1ee8d01d086aac Mon Sep 17 00:00:00 2001 From: ishkong <19740260+ishkong@users.noreply.github.com> Date: Sun, 21 Jul 2024 14:01:03 +0800 Subject: [PATCH 2/3] feat: Support shadowrocket to get obfs parameters in shadowsocks. --- app/Protocols/Shadowrocket.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Protocols/Shadowrocket.php b/app/Protocols/Shadowrocket.php index 57ab17f..c4cc8db 100644 --- a/app/Protocols/Shadowrocket.php +++ b/app/Protocols/Shadowrocket.php @@ -58,7 +58,11 @@ class Shadowrocket ['-', '_', ''], base64_encode("{$server['cipher']}:{$password}") ); - return "ss://{$str}@{$server['host']}:{$server['port']}#{$name}\r\n"; + $uri = "ss://{$str}@{$server['host']}:{$server['port']}"; + if ($server['obfs'] == 'http') { + $uri .= "?plugin=obfs-local;obfs=http;obfs-host={$server['obfs-host']};obfs-uri={$server['obfs-path']}"; + } + return $uri."#{$name}\r\n"; } public static function buildVmess($uuid, $server) @@ -283,4 +287,4 @@ class Shadowrocket } return $uri; } -} \ No newline at end of file +} From b8c2197e89481c49a7a52eb9b309dfb1cc6db30a Mon Sep 17 00:00:00 2001 From: ishkong <19740260+ishkong@users.noreply.github.com> Date: Sun, 21 Jul 2024 17:29:12 +0800 Subject: [PATCH 3/3] feat: Support V2RayNG to get obfs parameters in shadowsocks. --- app/Protocols/V2rayNG.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Protocols/V2rayNG.php b/app/Protocols/V2rayNG.php index c758cfb..7b1ba53 100644 --- a/app/Protocols/V2rayNG.php +++ b/app/Protocols/V2rayNG.php @@ -46,7 +46,11 @@ class V2rayNG ['-', '_', ''], base64_encode("{$server['cipher']}:{$password}") ); - return "ss://{$str}@{$server['host']}:{$server['port']}#{$name}\r\n"; + $uri = "ss://{$str}@{$server['host']}:{$server['port']}"; + if ($server['obfs'] == 'http') { + $uri .= "?plugin=obfs-local;obfs=http;obfs-host={$server['obfs-host']};path={$server['obfs-path']}"; + } + return $uri."#{$name}\r\n"; } public static function buildVmess($uuid, $server)