mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-09-15 21:00:27 +00:00
34 lines
735 B
Go
34 lines
735 B
Go
package main
|
|
|
|
import (
|
|
"github.com/sagernet/sing-box/daemon"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var commandAPIGroupSelect = &cobra.Command{
|
|
Use: "select <group> <outbound>",
|
|
Short: "Select an outbound in a group",
|
|
Args: cobra.ExactArgs(2),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
return runAPIGroupSelect(args[0], args[1])
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
commandAPIGroup.AddCommand(commandAPIGroupSelect)
|
|
}
|
|
|
|
func runAPIGroupSelect(groupTag string, outboundTag string) error {
|
|
clientConn, client, err := createAPIClient()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer clientConn.Close()
|
|
_, err = client.SelectOutbound(globalCtx, &daemon.SelectOutboundRequest{
|
|
GroupTag: groupTag,
|
|
OutboundTag: outboundTag,
|
|
})
|
|
return err
|
|
}
|