Config.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Services;
  4. // Config is singleton instance store all config
  5. final class Config
  6. {
  7. private function __construct()
  8. {
  9. }
  10. public static function getPublicConfig(): array
  11. {
  12. return [
  13. 'appName' => $_ENV['appName'],
  14. 'baseUrl' => $_ENV['baseUrl'],
  15. 'enable_checkin' => $_ENV['enable_checkin'],
  16. 'checkinMin' => $_ENV['checkinMin'],
  17. 'checkinMax' => $_ENV['checkinMax'],
  18. 'jump_delay' => $_ENV['jump_delay'],
  19. 'enable_analytics_code' => $_ENV['enable_analytics_code'],
  20. 'enable_kill' => $_ENV['enable_kill'],
  21. 'enable_change_email' => $_ENV['enable_change_email'],
  22. 'enable_telegram' => $_ENV['enable_telegram'],
  23. 'telegram_bot' => $_ENV['telegram_bot'],
  24. 'subscribeLog' => $_ENV['subscribeLog'],
  25. 'subscribeLog_keep_days' => $_ENV['subscribeLog_keep_days'],
  26. 'enable_r2_client_download' => $_ENV['enable_r2_client_download'],
  27. ];
  28. }
  29. public static function getDbConfig(): array
  30. {
  31. return [
  32. 'driver' => $_ENV['db_driver'],
  33. 'host' => $_ENV['db_host'],
  34. 'unix_socket' => $_ENV['db_socket'],
  35. 'database' => $_ENV['db_database'],
  36. 'username' => $_ENV['db_username'],
  37. 'password' => $_ENV['db_password'],
  38. 'charset' => $_ENV['db_charset'],
  39. 'collation' => $_ENV['db_collation'],
  40. 'prefix' => $_ENV['db_prefix'],
  41. 'port' => $_ENV['db_port'],
  42. ];
  43. }
  44. public static function getSupportParam($type): array
  45. {
  46. return match ($type) {
  47. 'ss_aead_method' => [
  48. 'aes-128-gcm',
  49. 'aes-192-gcm',
  50. 'aes-256-gcm',
  51. 'chacha20-ietf-poly1305',
  52. 'xchacha20-ietf-poly1305',
  53. ],
  54. 'ss_obfs' => [
  55. 'simple_obfs_http',
  56. 'simple_obfs_http_compatible',
  57. 'simple_obfs_tls',
  58. 'simple_obfs_tls_compatible',
  59. ],
  60. 'ss_2022' => [
  61. '2022-blake3-aes-128-gcm',
  62. '2022-blake3-aes-256-gcm',
  63. '2022-blake3-chacha20-poly1305',
  64. ],
  65. default => [
  66. 'aes-128-gcm',
  67. 'aes-192-gcm',
  68. 'aes-256-gcm',
  69. 'chacha20-ietf-poly1305',
  70. 'xchacha20-ietf-poly1305',
  71. 'none',
  72. 'plain',
  73. '2022-blake3-aes-128-gcm',
  74. '2022-blake3-aes-256-gcm',
  75. '2022-blake3-chacha20-poly1305',
  76. ],
  77. };
  78. }
  79. }