$item['remark'], 'type' => 'ss', 'server' => $item['address'], 'port' => $item['port'], 'cipher' => $item['method'], 'password' => $item['passwd'], 'udp' => true ]; if ($item['obfs'] != 'plain') { switch ($item['obfs']) { case 'simple_obfs_http': $return['plugin'] = 'obfs'; $return['plugin-opts']['mode'] = 'http'; break; case 'simple_obfs_tls': $return['plugin'] = 'obfs'; $return['plugin-opts']['mode'] = 'tls'; break; case 'v2ray': $return['plugin'] = 'v2ray-plugin'; $return['plugin-opts']['mode'] = 'websocket'; if ($item['tls'] == 'tls') { $return['plugin-opts']['tls'] = true; if ($item['verify_cert'] == false) { $return['plugin-opts']['skip-cert-verify'] = true; } } $return['plugin-opts']['host'] = $item['host']; $return['plugin-opts']['path'] = $item['path']; break; } if ($item['obfs'] != 'v2ray') { if ($item['obfs_param'] != '') { $return['plugin-opts']['host'] = $item['obfs_param']; } else { $return['plugin-opts']['host'] = 'windowsupdate.windows.com'; } } } break; case 'ssr': if ( in_array($item['method'], ['rc4-md5-6', 'des-ede3-cfb', 'xsalsa20', 'none']) || in_array($item['protocol'], array_merge(Config::getSupportParam('allow_none_protocol'), ['verify_deflate'])) || in_array($item['obfs'], ['tls1.2_ticket_fastauth']) ) { // 不支持的 break; } $return = [ 'name' => $item['remark'], 'type' => 'ssr', 'server' => $item['address'], 'port' => $item['port'], 'cipher' => $item['method'], 'password' => $item['passwd'], 'protocol' => $item['protocol'], 'protocolparam' => $item['protocol_param'], 'obfs' => $item['obfs'], 'obfsparam' => $item['obfs_param'] ]; break; case 'vmess': if (!in_array($item['net'], array('ws', 'tcp'))) { break; } $return = [ 'name' => $item['remark'], 'type' => 'vmess', 'server' => $item['add'], 'port' => $item['port'], 'uuid' => $item['id'], 'alterId' => $item['aid'], 'cipher' => 'auto', 'udp' => true ]; if ($item['net'] == 'ws') { $return['network'] = 'ws'; $return['ws-path'] = $item['path']; $return['ws-headers']['Host'] = ($item['host'] != '' ? $item['host'] : $item['add']); } if ($item['tls'] == 'tls') { $return['tls'] = true; if ($item['verify_cert'] == false) { $return['skip-cert-verify'] = true; } } break; } return $return; } public static function getShadowrocketURI($item) { $return = null; switch ($item['type']) { case 'ss': if (in_array($item['obfs'], Config::getSupportParam('ss_obfs'))) { $return = (URL::getItemUrl($item, 1)); } else { if ($item['obfs'] == 'v2ray') { $v2rayplugin = [ 'address' => $item['address'], 'port' => (string) $item['port'], 'path' => $item['path'], 'host' => $item['host'], 'mode' => 'websocket', ]; $v2rayplugin['tls'] = $item['tls'] == 'tls' ? true : false; if ($v2rayplugin['tls']) { if ($v2rayplugin['host'] != '' && $v2rayplugin['host'] != 'microsoft.com'){ $v2rayplugin['peer'] = $v2rayplugin['host']; }else { $v2rayplugin['peer'] = $v2rayplugin['address']; } }else { $v2rayplugin['peer'] = ''; } $return = ('ss://' . Tools::base64_url_encode($item['method'] . ':' . $item['passwd'] . '@' . $item['address'] . ':' . $item['port']) . '?v2ray-plugin=' . base64_encode(json_encode($v2rayplugin)) . '#' . rawurlencode($item['remark'])); } if ($item['obfs'] == 'plain') { $return = (URL::getItemUrl($item, 2)); } } break; case 'ssr': $return = (URL::getItemUrl($item, 0)); break; case 'vmess': if (!in_array($item['net'], ['tcp', 'ws', 'http', 'h2'])) { break; } $obfs = ''; switch ($item['net']) { case 'ws': $obfs .= ($item['host'] != '' ? ('&obfsParam=' . $item['host'] . '&path=' . $item['path'] . '&obfs=websocket') : ('&obfsParam=' . $item['add'] . '&path=' . $item['path'] . '&obfs=websocket')); break; case 'kcp': $obfs .= 'obfsParam={"header":' . '"' . ($item['headerType'] == '' || $item['headerType'] == 'noop' ? 'none' : $item['headerType']) . '"' . '}&obfs=mkcp'; break; case 'mkcp': $obfs .= 'obfsParam={"header":' . '"' . ($item['headerType'] == '' || $item['headerType'] == 'noop' ? 'none' : $item['headerType']) . '"' . '}&obfs=mkcp'; break; case 'h2': $obfs .= ($item['host'] != '' ? ('&obfsParam=' . $item['host'] . '&path=' . $item['path'] . '&obfs=h2') : ('&obfsParam=' . $item['add'] . '&path=' . $item['path'] . '&obfs=h2')); break; default: $obfs .= '&obfs=none'; break; } $tls = ''; if ($item['tls'] == 'tls') { $tls = '&tls=1'; if ($item['verify_cert'] == false){ $tls .= '&allowInsecure=1'; } $tls .= '&peer=' . $item['host']; } $return = ('vmess://' . Tools::base64_url_encode('chacha20-poly1305:' . $item['id'] . '@' . $item['add'] . ':' . $item['port']) . '?remarks=' . rawurlencode($item['remark']) . $obfs . $tls); break; } return $return; } public static function getKitsunebiURI($item) { $return = null; switch ($item['type']) { case 'ss': if (in_array($item['obfs'], ['v2ray', 'simple_obfs_http', 'simple_obfs_tls'])) { break; } $return = (URL::getItemUrl($item, 2)); break; case 'vmess': $network = ($item['net'] == 'tls' ? '&network=tcp' : ('&network=' . $item['net'])); $protocol = ''; switch ($item['net']) { case 'kcp': $protocol .= ('&kcpheader=' . $item['headerType']); break; case 'ws': $protocol .= ('&wspath=' . $item['path'] . '&wsHost=' . $item['host']); break; case 'h2': $protocol .= ('&h2Path=' . $item['path'] . '&h2Host=' . $item['host']); break; } $tls = ''; if ($item['tls'] == 'tls') { $tls = '&tls=1'; if ($item['verify_cert'] == false) { $tls .= '&allowInsecure=1'; } } $return .= ('vmess://' . base64_encode('auto:' . $item['id'] . '@' . $item['add'] . ':' . $item['port']) . '?remark=' . rawurlencode($item['remark']) . $network . $protocol . '&aid=' . $item['aid'] . $tls); break; } return $return; } public static function getSSDURI($item) { $return = null; switch ($item['type']) { case 'ss': # 666 $return['remarks'] = $item['remark']; $return['server'] = $item['address']; $return['port'] = $item['port']; $return['encryption'] = $item['method']; $return['password'] = $item['passwd']; $plugin_options = ''; if ($item['obfs'] != 'plain') { switch ($item['obfs']) { case 'simple_obfs_http': $return['plugin'] = 'simple-obfs'; $plugin_options .= 'obfs=http;obfs-host=' . $item['obfs_param']; break; case 'simple_obfs_tls': $return['plugin'] = 'simple-obfs'; $plugin_options .= 'obfs=tls;obfs-host=' . $item['obfs_param']; break; case 'v2ray': $return['plugin'] = 'v2ray'; if ($item['net'] == 'ws') { $plugin_options .= 'mode=ws'; } if ($item['tls'] == 'tls') { $plugin_options .= ';security=tls'; } else { $plugin_options .= ';security=none'; } $plugin_options .= ';path=' . $item['path']; if ($item['host'] != '') { $plugin_options .= ';host=' . $item['host']; } else { $plugin_options .= ';host=' . $item['address']; } break; } } $return['plugin_options'] = $plugin_options; $return['ratio'] = $item['ratio']; break; } return $return; } public static function getSSJSON($item) { $return = null; switch ($item['type']) { case 'ss': # 666 $return['remarks'] = $item['remark']; $return['server'] = $item['address']; $return['server_port'] = $item['port']; $return['method'] = $item['method']; $return['password'] = $item['passwd']; if ($item['obfs'] != 'plain') { $plugin_options = ''; switch ($item['obfs']) { case 'simple_obfs_http': $return['plugin'] = 'simple-obfs'; $plugin_options .= 'obfs=http;obfs-host=' . $item['obfs_param']; break; case 'simple_obfs_tls': $return['plugin'] = 'simple-obfs'; $plugin_options .= 'obfs=tls;obfs-host=' . $item['obfs_param']; break; case 'v2ray': $return['plugin'] = 'v2ray'; if ($item['net'] == 'ws') { $plugin_options .= 'mode=ws'; } if ($item['tls'] == 'tls') { $plugin_options .= ';security=tls'; } else { $plugin_options .= ';security=none'; } $plugin_options .= ';path=' . $item['path']; if ($item['host'] != '') { $plugin_options .= ';host=' . $item['host']; } else { $plugin_options .= ';host=' . $item['address']; } break; } $return['plugin_opts'] = $plugin_options; } break; } return $return; } }