mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-10-09 23:55:42 +00:00
Add api command
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing-box/daemon"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
)
|
||||
|
||||
var commandAPIGroup = &cobra.Command{
|
||||
Use: "group",
|
||||
Short: "Manage outbound groups",
|
||||
}
|
||||
|
||||
func init() {
|
||||
commandAPIRoot.AddCommand(commandAPIGroup)
|
||||
}
|
||||
|
||||
func fetchGroups(client daemon.StartedServiceClient) ([]*daemon.Group, error) {
|
||||
stream, err := client.SubscribeGroups(globalCtx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groups, err := stream.Recv()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return groups.GetGroup(), nil
|
||||
}
|
||||
Reference in New Issue
Block a user