2021-08-18 13:35:42 +02:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
mgmtProto "github.com/wiretrustee/wiretrustee/management/proto"
|
|
|
|
mgmt "github.com/wiretrustee/wiretrustee/management/server"
|
|
|
|
sigProto "github.com/wiretrustee/wiretrustee/signal/proto"
|
|
|
|
sig "github.com/wiretrustee/wiretrustee/signal/server"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
"net"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func startSignal(t *testing.T) (*grpc.Server, net.Listener) {
|
|
|
|
lis, err := net.Listen("tcp", ":0")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
s := grpc.NewServer()
|
|
|
|
sigProto.RegisterSignalExchangeServer(s, sig.NewServer())
|
|
|
|
go func() {
|
|
|
|
if err := s.Serve(lis); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
return s, lis
|
|
|
|
}
|
|
|
|
|
|
|
|
func startManagement(config *mgmt.Config, t *testing.T) (*grpc.Server, net.Listener) {
|
|
|
|
lis, err := net.Listen("tcp", ":0")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
s := grpc.NewServer()
|
|
|
|
store, err := mgmt.NewStore(config.Datadir)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2021-08-29 17:48:31 +02:00
|
|
|
peersUpdateManager := mgmt.NewPeersUpdateManager()
|
2022-01-24 11:21:30 +01:00
|
|
|
accountManager := mgmt.NewManager(store, peersUpdateManager, nil)
|
2021-09-02 14:41:54 +02:00
|
|
|
turnManager := mgmt.NewTimeBasedAuthSecretsManager(peersUpdateManager, config.TURNConfig)
|
|
|
|
mgmtServer, err := mgmt.NewServer(config, accountManager, peersUpdateManager, turnManager)
|
2021-08-18 13:35:42 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
mgmtProto.RegisterManagementServiceServer(s, mgmtServer)
|
|
|
|
go func() {
|
|
|
|
if err := s.Serve(lis); err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
return s, lis
|
|
|
|
}
|