SsConfigSeeder.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace Database\Seeders;
  3. use App\Models\SsConfig;
  4. use Illuminate\Database\Seeder;
  5. class SsConfigSeeder extends Seeder
  6. {
  7. private array $methodList = [
  8. 'none',
  9. 'rc4-md5',
  10. 'aes-128-cfb',
  11. 'aes-192-cfb',
  12. 'aes-256-cfb',
  13. 'aes-128-ctr',
  14. 'aes-192-ctr',
  15. 'aes-256-ctr',
  16. 'camellia-128-cfb',
  17. 'camellia-192-cfb',
  18. 'camellia-256-cfb',
  19. 'salsa20',
  20. 'chacha20',
  21. 'chacha20-ietf',
  22. 'chacha20-ietf-poly1305',
  23. 'chacha20-poly1305',
  24. 'xchacha-ietf-poly1305',
  25. 'aes-128-gcm',
  26. 'aes-192-gcm',
  27. 'aes-256-gcm',
  28. 'sodium-aes-256-gcm',
  29. ];
  30. private array $protocolList = [
  31. 'origin',
  32. 'auth_sha1_v4',
  33. 'auth_aes128_md5',
  34. 'auth_aes128_sha1',
  35. 'auth_chain_a',
  36. 'auth_chain_b',
  37. 'auth_chain_c',
  38. 'auth_chain_d',
  39. 'auth_chain_e',
  40. 'auth_chain_f',
  41. ];
  42. private array $obfsList = [
  43. 'plain',
  44. 'http_simple',
  45. 'http_post',
  46. 'tls1.2_ticket_auth',
  47. 'tls1.2_ticket_fastauth',
  48. ];
  49. public function run(): void
  50. {
  51. foreach ($this->methodList as $i => $method) {
  52. SsConfig::insert(['name' => $method, 'type' => 1]);
  53. if ($i === 0) {
  54. SsConfig::type(1)->whereName($method)->first()->setDefault();
  55. }
  56. }
  57. foreach ($this->protocolList as $i => $method) {
  58. SsConfig::insert(['name' => $method, 'type' => 2]);
  59. if ($i === 0) {
  60. SsConfig::type(2)->whereName($method)->first()->setDefault();
  61. }
  62. }
  63. foreach ($this->obfsList as $i => $obs) {
  64. SsConfig::insert(['name' => $obs, 'type' => 3]);
  65. if ($i === 0) {
  66. SsConfig::type(3)->whereName($obs)->first()->setDefault();
  67. }
  68. }
  69. }
  70. }