1
0

runtime.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package runtime
  2. import (
  3. "context"
  4. "github.com/mhsanaei/3x-ui/v3/internal/database/model"
  5. )
  6. type Runtime interface {
  7. Name() string
  8. AddInbound(ctx context.Context, ib *model.Inbound) error
  9. DelInbound(ctx context.Context, ib *model.Inbound) error
  10. UpdateInbound(ctx context.Context, oldIb, newIb *model.Inbound) error
  11. AddUser(ctx context.Context, ib *model.Inbound, userMap map[string]any) error
  12. RemoveUser(ctx context.Context, ib *model.Inbound, email string) error
  13. // Per-client operations that route through the node's clients API on
  14. // Remote (instead of pushing the whole inbound) so the node applies
  15. // per-user xray API calls without a DelInbound+AddInbound cycle.
  16. UpdateUser(ctx context.Context, ib *model.Inbound, email string, payload model.Client) error
  17. DeleteUser(ctx context.Context, ib *model.Inbound, email string) error
  18. AddClient(ctx context.Context, ib *model.Inbound, client model.Client) error
  19. // DeleteClient removes the client identified by email entirely from the
  20. // runtime's own store: on Remote it hits the node's full-delete endpoint
  21. // (record, attachments, traffic), unlike DeleteUser which only detaches
  22. // from one inbound and leaves the node's client record behind. Local has
  23. // no client store of its own, so it is a no-op there.
  24. DeleteClient(ctx context.Context, email string) error
  25. RestartXray(ctx context.Context) error
  26. ResetClientTraffic(ctx context.Context, ib *model.Inbound, email string) error
  27. ResetInboundTraffic(ctx context.Context, ib *model.Inbound) error
  28. ResetAllTraffics(ctx context.Context) error
  29. }