mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-08 01:04:47 +01:00
877ad97a96
* feature: replace RegisterPeer with Login method that does both - registration and login * test: add management login test * feature: add WiretrusteeConfig to the Login response to configure peer global config * feature: add client peer login support * fix: missing parts * chore: update go deps * feature: support Management Service gRPC endpoints [CLIENT] * feature: finalize client sync with management * fix: management store peer key lower case restore * fix: management returns peer ip without a mask * refactor: remove cmd pkg * fix: invalid tun interface name on mac * fix: timeout when calling management client * fix: tests and lint errors * fix: golang-test workflow * fix: client service tests * fix: iface build * feature: detect management scheme on startup * chore: better logs for management * fix: goreleaser * fix: lint errors * fix: signal TLS * fix: direct Wireguard connection * chore: verbose logging on direct connection
33 lines
643 B
Go
33 lines
643 B
Go
package internal
|
|
|
|
import "sync"
|
|
|
|
// A Cond is a condition variable like sync.Cond, but using a channel so we can use select.
|
|
type Cond struct {
|
|
once sync.Once
|
|
C chan struct{}
|
|
}
|
|
|
|
// NewCond creates a new condition variable.
|
|
func NewCond() *Cond {
|
|
return &Cond{C: make(chan struct{})}
|
|
}
|
|
|
|
// Do runs f if the condition hasn't been signaled yet. Afterwards it will be signaled.
|
|
func (c *Cond) Do(f func()) {
|
|
c.once.Do(func() {
|
|
f()
|
|
close(c.C)
|
|
})
|
|
}
|
|
|
|
// Signal closes the condition variable channel.
|
|
func (c *Cond) Signal() {
|
|
c.Do(func() {})
|
|
}
|
|
|
|
// Wait waits for the condition variable channel to close.
|
|
func (c *Cond) Wait() {
|
|
<-c.C
|
|
}
|