Config.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_ticket' => $_ENV['enable_ticket'],
  21. 'enable_kill' => $_ENV['enable_kill'],
  22. 'enable_change_email' => $_ENV['enable_change_email'],
  23. 'enable_telegram' => $_ENV['enable_telegram'],
  24. 'telegram_bot' => $_ENV['telegram_bot'],
  25. 'subscribeLog' => $_ENV['subscribeLog'],
  26. 'subscribeLog_keep_days' => $_ENV['subscribeLog_keep_days'],
  27. 'enable_auto_detect_ban' => $_ENV['enable_auto_detect_ban'],
  28. 'auto_detect_ban_type' => $_ENV['auto_detect_ban_type'],
  29. 'auto_detect_ban_number' => $_ENV['auto_detect_ban_number'],
  30. 'auto_detect_ban_time' => $_ENV['auto_detect_ban_time'],
  31. 'auto_detect_ban' => $_ENV['auto_detect_ban'],
  32. 'sentry_dsn' => ! isset($_ENV['sentry_dsn']) ? $_ENV['sentry_dsn'] : null,
  33. ];
  34. }
  35. public static function getDbConfig(): array
  36. {
  37. return [
  38. 'driver' => $_ENV['db_driver'],
  39. 'host' => $_ENV['db_host'],
  40. 'unix_socket' => $_ENV['db_socket'],
  41. 'database' => $_ENV['db_database'],
  42. 'username' => $_ENV['db_username'],
  43. 'password' => $_ENV['db_password'],
  44. 'charset' => $_ENV['db_charset'],
  45. 'collation' => $_ENV['db_collation'],
  46. 'prefix' => $_ENV['db_prefix'],
  47. 'port' => $_ENV['db_port'],
  48. ];
  49. }
  50. public static function getSupportParam($type): array
  51. {
  52. return match ($type) {
  53. 'ss_aead_method' => [
  54. 'aes-128-gcm',
  55. 'aes-192-gcm',
  56. 'aes-256-gcm',
  57. 'chacha20-ietf-poly1305',
  58. 'xchacha20-ietf-poly1305',
  59. ],
  60. 'ss_obfs' => [
  61. 'simple_obfs_http',
  62. 'simple_obfs_http_compatible',
  63. 'simple_obfs_tls',
  64. 'simple_obfs_tls_compatible',
  65. ],
  66. 'ss_2022' => [
  67. '2022-blake3-aes-128-gcm',
  68. '2022-blake3-aes-256-gcm',
  69. '2022-blake3-chacha20-poly1305',
  70. ],
  71. default => [
  72. 'aes-128-gcm',
  73. 'aes-192-gcm',
  74. 'aes-256-gcm',
  75. 'chacha20-ietf-poly1305',
  76. 'xchacha20-ietf-poly1305',
  77. 'none',
  78. 'plain',
  79. '2022-blake3-aes-128-gcm',
  80. '2022-blake3-aes-256-gcm',
  81. '2022-blake3-chacha20-poly1305',
  82. ],
  83. };
  84. }
  85. }