Surfboard.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Components\Client;
  3. class Surfboard
  4. {
  5. public static function buildShadowsocks($server)
  6. {
  7. $config = array_filter([
  8. "{$server['name']}=custom",
  9. $server['host'],
  10. $server['port'],
  11. $server['method'],
  12. $server['passwd'],
  13. sysConfig('website_url').'/clients/SSEncrypt.module',
  14. 'tfo=true',
  15. "udp-relay={$server['udp']}",
  16. ]);
  17. return implode(',', $config).PHP_EOL;
  18. }
  19. public static function buildVmess($server)
  20. {
  21. $config = [
  22. "{$server['name']}=vmess",
  23. $server['host'],
  24. $server['port'],
  25. "username={$server['uuid']}",
  26. 'tfo=true',
  27. "udp-relay={$server['udp']}",
  28. ];
  29. if ($server['v2_tls']) {
  30. array_push($config, 'tls=true', "sni={$server['v2_host']}");
  31. }
  32. if ($server['v2_net'] === 'ws') {
  33. array_push($config, 'ws=true', "ws-path={$server['v2_path']}", "ws-headers=Host:{$server['v2_host']}");
  34. }
  35. return implode(',', $config).PHP_EOL;
  36. }
  37. }