netbird/relay/client/manager.go
2024-05-23 13:24:02 +02:00

44 lines
768 B
Go

package client
import (
"context"
"sync"
)
type Manager struct {
ctx context.Context
ctxCancel context.CancelFunc
srvAddress string
peerID string
wg sync.WaitGroup
clients map[string]*Client
clientsMutex sync.RWMutex
}
func NewManager(ctx context.Context, serverAddress string, peerID string) *Manager {
ctx, cancel := context.WithCancel(ctx)
return &Manager{
ctx: ctx,
ctxCancel: cancel,
srvAddress: serverAddress,
peerID: peerID,
clients: make(map[string]*Client),
}
}
func (m *Manager) Teardown() {
m.ctxCancel()
m.wg.Wait()
}
func (m *Manager) newSrvConnection(address string) {
if _, ok := m.clients[address]; ok {
return
}
// client := NewClient(address, m.peerID)
//err = client.Connect()
}