Surfboard.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Components\Client;
  3. class Surfboard
  4. {
  5. public static function buildShadowsocks($server)
  6. {
  7. $config = [
  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. $config = array_filter($config);
  18. return implode(',', $config).PHP_EOL;
  19. }
  20. public static function buildVmess($server)
  21. {
  22. $config = [
  23. "{$server['name']}=vmess",
  24. $server['host'],
  25. $server['port'],
  26. "username={$server['uuid']}",
  27. 'tfo=true',
  28. "udp-relay={$server['udp']}",
  29. ];
  30. if ($server['v2_tls']) {
  31. $config = array_merge($config, ['tls=true', "sni={$server['v2_host']}"]);
  32. }
  33. if ($server['v2_net'] === 'ws') {
  34. $config = array_merge($config, ['ws=true', "ws-path={$server['v2_path']}", "ws-headers=Host:{$server['v2_host']}"]);
  35. }
  36. return implode(',', $config).PHP_EOL;
  37. }
  38. }