xrayAddUser 通过 in-process proxy.UserManager 接口热增用户。
(ctx context.Context, instance *xrayCore.Instance, tag string, user *protocol.MemoryUser)
| 902 | |
| 903 | // xrayAddUser 通过 in-process proxy.UserManager 接口热增用户。 |
| 904 | func xrayAddUser(ctx context.Context, instance *xrayCore.Instance, tag string, user *protocol.MemoryUser) error { |
| 905 | ihm, ok := instance.GetFeature(inbound.ManagerType()).(inbound.Manager) |
| 906 | if !ok { |
| 907 | return fmt.Errorf("AddUser: inbound manager not available") |
| 908 | } |
| 909 | handler, err := ihm.GetHandler(ctx, tag) |
| 910 | if err != nil { |
| 911 | return fmt.Errorf("AddUser: get handler %q: %w", tag, err) |
| 912 | } |
| 913 | gi, ok := handler.(proxy.GetInbound) |
| 914 | if !ok { |
| 915 | return fmt.Errorf("AddUser: handler %q does not support GetInbound", tag) |
| 916 | } |
| 917 | um, ok := gi.GetInbound().(proxy.UserManager) |
| 918 | if !ok { |
| 919 | return fmt.Errorf("AddUser: inbound %q does not support UserManager", tag) |
| 920 | } |
| 921 | return um.AddUser(ctx, user) |
| 922 | } |
| 923 | |
| 924 | // xrayRemoveUser 通过 in-process proxy.UserManager 接口热删用户。 |
| 925 | func xrayRemoveUser(ctx context.Context, instance *xrayCore.Instance, tag, email string) error { |
no test coverage detected