mirror of
https://github.com/netbirdio/netbird.git
synced 2025-03-13 06:08:48 +01:00
52 lines
1003 B
Go
52 lines
1003 B
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/kardianos/service"
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
"google.golang.org/grpc"
|
|
|
|
"github.com/wiretrustee/wiretrustee/client/internal"
|
|
)
|
|
|
|
type program struct {
|
|
ctx context.Context
|
|
cmd *cobra.Command
|
|
args []string
|
|
serv *grpc.Server
|
|
}
|
|
|
|
func newProgram(cmd *cobra.Command, args []string) *program {
|
|
ctx := internal.CtxInitState(cmd.Context())
|
|
return &program{
|
|
ctx: ctx,
|
|
cmd: cmd,
|
|
args: args,
|
|
}
|
|
}
|
|
|
|
func newSVCConfig() *service.Config {
|
|
return &service.Config{
|
|
Name: "wiretrustee",
|
|
DisplayName: "Wiretrustee",
|
|
Description: "A WireGuard-based mesh network that connects your devices into a single private network.",
|
|
}
|
|
}
|
|
|
|
func newSVC(prg *program, conf *service.Config) (service.Service, error) {
|
|
s, err := service.New(prg, conf)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
return nil, err
|
|
}
|
|
return s, nil
|
|
}
|
|
|
|
var serviceCmd = &cobra.Command{
|
|
Use: "service",
|
|
Short: "manages wiretrustee service",
|
|
}
|
|
|