2022-03-08 14:47:55 +01:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-03-26 12:08:54 +01:00
|
|
|
"github.com/netbirdio/netbird/util"
|
2022-03-08 14:47:55 +01:00
|
|
|
"time"
|
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2022-03-26 12:08:54 +01:00
|
|
|
"github.com/netbirdio/netbird/client/proto"
|
2022-03-08 14:47:55 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var downCmd = &cobra.Command{
|
|
|
|
Use: "down",
|
|
|
|
Short: "down wiretrustee connections",
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
SetFlagsFromEnvVars()
|
|
|
|
|
2022-03-10 18:14:07 +01:00
|
|
|
err := util.InitLog(logLevel, logFile)
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("failed initializing log %v", err)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-03-08 14:47:55 +01:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
conn, err := DialClientGRPCServer(ctx, daemonAddr)
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("failed to connect to service CLI interface %v", err)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer conn.Close()
|
|
|
|
|
|
|
|
daemonClient := proto.NewDaemonServiceClient(conn)
|
|
|
|
|
|
|
|
if _, err := daemonClient.Down(ctx, &proto.DownRequest{}); err != nil {
|
|
|
|
log.Errorf("call service down method: %v", err)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|