-
Notifications
You must be signed in to change notification settings - Fork 465
/
handlerServiceClient.go
42 lines (36 loc) · 1.14 KB
/
handlerServiceClient.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package v2ray_ssrpanel_plugin
import (
"context"
"google.golang.org/grpc"
"v2ray.com/core/app/proxyman/command"
"v2ray.com/core/common/protocol"
"v2ray.com/core/common/serial"
)
type HandlerServiceClient struct {
command.HandlerServiceClient
inboundTag string
}
func NewHandlerServiceClient(client *grpc.ClientConn, inboundTag string) *HandlerServiceClient {
return &HandlerServiceClient{
HandlerServiceClient: command.NewHandlerServiceClient(client),
inboundTag: inboundTag,
}
}
func (h *HandlerServiceClient) DelUser(email string) error {
req := &command.AlterInboundRequest{
Tag: h.inboundTag,
Operation: serial.ToTypedMessage(&command.RemoveUserOperation{Email: email}),
}
return h.AlterInbound(req)
}
func (h *HandlerServiceClient) AddUser(user *protocol.User) error {
req := &command.AlterInboundRequest{
Tag: h.inboundTag,
Operation: serial.ToTypedMessage(&command.AddUserOperation{User: user}),
}
return h.AlterInbound(req)
}
func (h *HandlerServiceClient) AlterInbound(req *command.AlterInboundRequest) error {
_, err := h.HandlerServiceClient.AlterInbound(context.Background(), req)
return err
}