$ids ?? [], 'proxies' => $proxies ?? []]; } public static function buildShadowsocks(array $server): ?array { $supportedMethods = ['aes-128-gcm', 'aes-192-gcm', 'aes-256-gcm', 'chacha20-ietf-poly1305', 'xchacha20-ietf-poly1305', 'aes-128-cfb', 'aes-192-cfb', 'aes-256-cfb', 'rc4-md5', 'chacha20-ietf', 'xchacha20', 'aes-128-ctr', 'aes-192-ctr', 'aes-256-ctr']; if (! in_array($server['method'], $supportedMethods, true)) { return null; } return [ 'name' => $server['name'], 'type' => 'ss', 'server' => $server['host'], 'port' => $server['port'], 'cipher' => $server['method'], 'password' => $server['passwd'], 'udp' => $server['udp'], ]; } public static function buildShadowsocksr(array $server): ?array { $supportedMethods = ['aes-128-cfb', 'aes-192-cfb', 'aes-256-cfb', 'rc4-md5', 'chacha20-ietf', 'xchacha20', 'none']; $supportedObfuscations = ['plain', 'http_simple', 'http_post', 'random_head', 'tls1.2_ticket_auth', 'tls1.2_ticket_fastauth']; $supportedProtocols = ['origin', 'auth_sha1_v4', 'auth_aes128_md5', 'auth_aes128_sha1', 'auth_chain_a', 'auth_chain_b']; if (! in_array($server['method'], $supportedMethods, true) || ! in_array($server['obfs'], $supportedObfuscations, true) || ! in_array($server['protocol'], $supportedProtocols, true)) { return null; } return [ 'name' => $server['name'], 'type' => 'ssr', 'server' => $server['host'], 'port' => $server['port'], 'password' => $server['passwd'], 'cipher' => $server['method'], 'obfs' => $server['obfs'], 'obfs-param' => $server['obfs_param'] ?? '', 'protocol' => $server['protocol'], 'protocol-param' => $server['protocol_param'] ?? '', 'udp' => $server['udp'], ]; } public static function buildVmess(array $server): ?array { $supportedMethods = ['auto', 'aes-128-gcm', 'chacha20-poly1305', 'none']; $supportedNetworks = ['ws', 'h2', 'http', 'grpc']; if (! in_array($server['method'], $supportedMethods, true) || ($server['v2_net'] && ! in_array($server['v2_net'], $supportedNetworks, true))) { return null; } $array = [ 'name' => $server['name'], 'type' => 'vmess', 'server' => $server['host'], 'port' => $server['port'], 'uuid' => $server['uuid'], 'alterId' => $server['v2_alter_id'], 'cipher' => $server['method'], 'udp' => $server['udp'], ]; if (isset($server['v2_tls']) && $server['v2_tls']) { $array['tls'] = true; $array['servername'] = $server['v2_host']; } $array['network'] = $server['v2_net']; if (isset($server['v2_net']) && $server['v2_net'] === 'ws') { $array['ws-opts'] = []; $array['ws-opts']['path'] = $server['v2_path']; if ($server['v2_host']) { $array['ws-opts']['headers'] = ['Host' => $server['v2_host']]; } $array['ws-path'] = $server['v2_path']; if ($server['v2_host']) { $array['ws-headers'] = ['Host' => $server['v2_host']]; } } return $array; } public static function buildTrojan(array $server): array { $array = [ 'name' => $server['name'], 'type' => 'trojan', 'server' => $server['host'], 'port' => $server['port'], 'password' => $server['passwd'], 'udp' => $server['udp'], ]; if (isset($server['sni'])) { $array['sni'] = $server['sni']; } if (isset($server['allow_insecure'])) { $array['skip-cert-verify'] = $server['allow_insecure']; } return $array; } public static function buildHysteria2(array $server): array|string|null { return null; } }