SsNode.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Builder;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Relations\HasMany;
  6. use Illuminate\Database\Eloquent\Relations\HasOne;
  7. /**
  8. * SS节点信息
  9. *
  10. * @property int $id
  11. * @property int $type 服务类型:1-ShadowsocksR、2-V2ray
  12. * @property string $name 名称
  13. * @property string|null $country_code 国家代码
  14. * @property string|null $server 服务器域名地址
  15. * @property string|null $ip 服务器IPV4地址
  16. * @property string|null $ipv6 服务器IPV6地址
  17. * @property string|null $relay_server 中转地址
  18. * @property int|null $relay_port 中转端口
  19. * @property int $level 等级:0-无等级,全部可见
  20. * @property int $speed_limit 节点限速,为0表示不限速,单位Byte
  21. * @property int $client_limit 设备数限制
  22. * @property string|null $description 节点简单描述
  23. * @property string $method 加密方式
  24. * @property string $protocol 协议
  25. * @property string|null $protocol_param 协议参数
  26. * @property string $obfs 混淆
  27. * @property string|null $obfs_param 混淆参数
  28. * @property float $traffic_rate 流量比率
  29. * @property int $is_subscribe 是否允许用户订阅该节点:0-否、1-是
  30. * @property int $is_ddns 是否使用DDNS:0-否、1-是
  31. * @property int $is_relay 是否中转节点:0-否、1-是
  32. * @property int $is_udp 是否启用UDP:0-不启用、1-启用
  33. * @property int $push_port 消息推送端口
  34. * @property int $detection_type 节点检测: 0-关闭、1-只检测TCP、2-只检测ICMP、3-检测全部
  35. * @property int $compatible 兼容SS
  36. * @property int $single 启用单端口功能:0-否、1-是
  37. * @property int|null $port 单端口的端口号或连接端口号
  38. * @property string|null $passwd 单端口的连接密码
  39. * @property int $sort 排序值,值越大越靠前显示
  40. * @property int $status 状态:0-维护、1-正常
  41. * @property int $v2_alter_id V2Ray额外ID
  42. * @property int $v2_port V2Ray服务端口
  43. * @property string $v2_method V2Ray加密方式
  44. * @property string $v2_net V2Ray传输协议
  45. * @property string $v2_type V2Ray伪装类型
  46. * @property string $v2_host V2Ray伪装的域名
  47. * @property string $v2_path V2Ray的WS/H2路径
  48. * @property int $v2_tls V2Ray连接TLS:0-未开启、1-开启
  49. * @property string|null $tls_provider V2Ray节点的TLS提供商授权信息
  50. * @property \Illuminate\Support\Carbon $created_at
  51. * @property \Illuminate\Support\Carbon $updated_at
  52. * @property-read \App\Models\NodeAuth|null $auth
  53. * @property-read mixed $type_label
  54. * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\SsNodeLabel[] $label
  55. * @property-read int|null $label_count
  56. * @method static Builder|SsNode newModelQuery()
  57. * @method static Builder|SsNode newQuery()
  58. * @method static Builder|SsNode query()
  59. * @method static Builder|SsNode whereClientLimit($value)
  60. * @method static Builder|SsNode whereCompatible($value)
  61. * @method static Builder|SsNode whereCountryCode($value)
  62. * @method static Builder|SsNode whereCreatedAt($value)
  63. * @method static Builder|SsNode whereDescription($value)
  64. * @method static Builder|SsNode whereDetectionType($value)
  65. * @method static Builder|SsNode whereId($value)
  66. * @method static Builder|SsNode whereIp($value)
  67. * @method static Builder|SsNode whereIpv6($value)
  68. * @method static Builder|SsNode whereIsDdns($value)
  69. * @method static Builder|SsNode whereIsRelay($value)
  70. * @method static Builder|SsNode whereIsSubscribe($value)
  71. * @method static Builder|SsNode whereIsUdp($value)
  72. * @method static Builder|SsNode whereLevel($value)
  73. * @method static Builder|SsNode whereMethod($value)
  74. * @method static Builder|SsNode whereName($value)
  75. * @method static Builder|SsNode whereObfs($value)
  76. * @method static Builder|SsNode whereObfsParam($value)
  77. * @method static Builder|SsNode wherePasswd($value)
  78. * @method static Builder|SsNode wherePort($value)
  79. * @method static Builder|SsNode whereProtocol($value)
  80. * @method static Builder|SsNode whereProtocolParam($value)
  81. * @method static Builder|SsNode wherePushPort($value)
  82. * @method static Builder|SsNode whereRelayPort($value)
  83. * @method static Builder|SsNode whereRelayServer($value)
  84. * @method static Builder|SsNode whereServer($value)
  85. * @method static Builder|SsNode whereSingle($value)
  86. * @method static Builder|SsNode whereSort($value)
  87. * @method static Builder|SsNode whereSpeedLimit($value)
  88. * @method static Builder|SsNode whereStatus($value)
  89. * @method static Builder|SsNode whereTlsProvider($value)
  90. * @method static Builder|SsNode whereTrafficRate($value)
  91. * @method static Builder|SsNode whereType($value)
  92. * @method static Builder|SsNode whereUpdatedAt($value)
  93. * @method static Builder|SsNode whereV2AlterId($value)
  94. * @method static Builder|SsNode whereV2Host($value)
  95. * @method static Builder|SsNode whereV2Method($value)
  96. * @method static Builder|SsNode whereV2Net($value)
  97. * @method static Builder|SsNode whereV2Path($value)
  98. * @method static Builder|SsNode whereV2Port($value)
  99. * @method static Builder|SsNode whereV2Tls($value)
  100. * @method static Builder|SsNode whereV2Type($value)
  101. * @mixin \Eloquent
  102. */
  103. class SsNode extends Model {
  104. protected $table = 'ss_node';
  105. public function label(): HasMany {
  106. return $this->hasMany(SsNodeLabel::class, 'node_id', 'id');
  107. }
  108. public function auth(): HasOne {
  109. return $this->hasOne(NodeAuth::class, 'node_id', 'id');
  110. }
  111. public function getLevel(): HasOne {
  112. return $this->hasOne(Level::class, 'level', 'level');
  113. }
  114. public function getTypeLabelAttribute(): string {
  115. switch($this->attributes['type']){
  116. case 1:
  117. $type_label = 'ShadowsocksR';
  118. break;
  119. case 2:
  120. $type_label = 'V2Ray';
  121. break;
  122. case 3:
  123. $type_label = 'Trojan';
  124. break;
  125. default:
  126. $type_label = 'UnKnown';
  127. }
  128. return $type_label;
  129. }
  130. }