mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-15 03:11:02 +01:00
44 lines
768 B
Go
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()
|
|
}
|