1
0

node_client_ip.go 1.4 KB

123456789101112131415161718192021222324252627
  1. package model
  2. // ClientIpEntry is the wire/JSON shape of a single observed client IP with the
  3. // last time it was seen (unix seconds). It mirrors job.IPWithTimestamp and the
  4. // service-internal clientIpEntry so the per-node attribution blob round-trips
  5. // with the existing inbound_client_ips storage.
  6. type ClientIpEntry struct {
  7. IP string `json:"ip"`
  8. Timestamp int64 `json:"timestamp"`
  9. }
  10. // NodeClientIp records which panel (identified by its stable panelGuid) observed
  11. // a client's IPs on its own Xray. Unlike InboundClientIps (a flattened,
  12. // cluster-wide union used for IP-limit counting and that is pushed back to every
  13. // node), this table preserves attribution: it never mixes in IPs a parent pushed
  14. // down, so the master can tell exactly which node a given IP is connecting to.
  15. //
  16. // Rows under the local panel's own panelGuid are written by check_client_ip_job
  17. // from local Xray observations; rows under remote guids are merged in by the node
  18. // sync job from each node's clientIpsByGuid report (its own panelGuid subtree plus
  19. // any descendants), so attribution survives across a chain of nodes.
  20. type NodeClientIp struct {
  21. Id int `json:"id" gorm:"primaryKey;autoIncrement"`
  22. NodeGuid string `json:"nodeGuid" gorm:"uniqueIndex:idx_nodeip_guid_email,priority:1;not null"`
  23. Email string `json:"email" gorm:"uniqueIndex:idx_nodeip_guid_email,priority:2;not null"`
  24. Ips string `json:"ips"`
  25. }