mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-04 22:11:29 +02:00
Renaming
This commit is contained in:
@@ -51,7 +51,7 @@ import (
|
||||
|
||||
// androidRunOverride is set on Android to inject mobile dependencies
|
||||
// when using embed.Client (which calls Run() with empty MobileDependency).
|
||||
var androidRunOverride func(c *ConnectClient, config *profilemanager.Config, runningChan chan struct{}, logPath string) error
|
||||
var androidRunOverride func(c *ConnectClient, config *profilemanager.Config, connEstablishedChan chan struct{}, logPath string) error
|
||||
|
||||
type ConnectClient struct {
|
||||
ctx context.Context
|
||||
@@ -88,11 +88,11 @@ func (c *ConnectClient) SetUpdateManager(um *updater.Manager) {
|
||||
|
||||
// Run with main logic. md carries optional gRPC metadata (e.g. the UI
|
||||
// user-agent) to forward to the management/signal services; nil when none.
|
||||
func (c *ConnectClient) Run(config *profilemanager.Config, md metadata.MD, runningChan chan struct{}, logPath string) error {
|
||||
func (c *ConnectClient) Run(config *profilemanager.Config, md metadata.MD, connEstablishedChan chan struct{}, logPath string) error {
|
||||
if androidRunOverride != nil {
|
||||
return androidRunOverride(c, config, runningChan, logPath)
|
||||
return androidRunOverride(c, config, connEstablishedChan, logPath)
|
||||
}
|
||||
return c.sup.start(config, md, MobileDependency{}, runningChan, logPath)
|
||||
return c.sup.start(config, md, MobileDependency{}, connEstablishedChan, logPath)
|
||||
}
|
||||
|
||||
// RunAsync starts a client run without blocking. Used by the daemon, which
|
||||
@@ -160,7 +160,7 @@ func (c *ConnectClient) RunOniOS(
|
||||
|
||||
// run executes a single client run. runCtx is owned by the supervisor: cancelling
|
||||
// it tears the run down (it is the parent of the per-attempt engine context).
|
||||
func (c *ConnectClient) run(runCtx context.Context, config *profilemanager.Config, mobileDependency MobileDependency, runningChan chan struct{}, logPath string) error {
|
||||
func (c *ConnectClient) run(runCtx context.Context, config *profilemanager.Config, mobileDependency MobileDependency, connEstablishedChan chan struct{}, logPath string) error {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
rec := c.statusRecorder
|
||||
@@ -423,11 +423,11 @@ func (c *ConnectClient) run(runCtx context.Context, config *profilemanager.Confi
|
||||
log.Infof("Netbird engine started, the IP is: %s", peerConfig.GetAddress())
|
||||
state.Set(StatusConnected)
|
||||
|
||||
if runningChan != nil {
|
||||
if connEstablishedChan != nil {
|
||||
select {
|
||||
case <-runningChan:
|
||||
case <-connEstablishedChan:
|
||||
default:
|
||||
close(runningChan)
|
||||
close(connEstablishedChan)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,14 +65,14 @@ func init() {
|
||||
// dependencies so the engine's existing Android code paths work unchanged.
|
||||
// Applications that need P2P ICE or real DNS should replace this by
|
||||
// setting androidRunOverride before calling Start().
|
||||
androidRunOverride = func(c *ConnectClient, config *profilemanager.Config, runningChan chan struct{}, logPath string) error {
|
||||
androidRunOverride = func(c *ConnectClient, config *profilemanager.Config, connEstablishedChan chan struct{}, logPath string) error {
|
||||
return c.runOnAndroidEmbed(
|
||||
config,
|
||||
noopIFaceDiscover{},
|
||||
noopNetworkChangeListener{},
|
||||
[]netip.AddrPort{},
|
||||
noopDnsReadyListener{},
|
||||
runningChan,
|
||||
connEstablishedChan,
|
||||
logPath,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/netbirdio/netbird/client/internal/stdnet"
|
||||
)
|
||||
|
||||
// runOnAndroidEmbed is like RunOnAndroid but accepts a runningChan
|
||||
// runOnAndroidEmbed is like RunOnAndroid but accepts a connEstablishedChan
|
||||
// so embed.Client.Start() can detect when the engine is ready.
|
||||
// It provides complete MobileDependency so the engine's existing
|
||||
// Android code paths work unchanged.
|
||||
@@ -21,7 +21,7 @@ func (c *ConnectClient) runOnAndroidEmbed(
|
||||
networkChangeListener listener.NetworkChangeListener,
|
||||
dnsAddresses []netip.AddrPort,
|
||||
dnsReadyListener dns.ReadyListener,
|
||||
runningChan chan struct{},
|
||||
connEstablishedChan chan struct{},
|
||||
logPath string,
|
||||
) error {
|
||||
mobileDependency := MobileDependency{
|
||||
@@ -30,5 +30,5 @@ func (c *ConnectClient) runOnAndroidEmbed(
|
||||
HostDNSAddresses: dnsAddresses,
|
||||
DnsReadyListener: dnsReadyListener,
|
||||
}
|
||||
return c.sup.start(config, nil, mobileDependency, runningChan, logPath)
|
||||
return c.sup.start(config, nil, mobileDependency, connEstablishedChan, logPath)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ type lifecycleCmd struct {
|
||||
config *profilemanager.Config
|
||||
md metadata.MD
|
||||
mobileDep MobileDependency
|
||||
runningChan chan struct{}
|
||||
connEstablishedChan chan struct{}
|
||||
logPath string
|
||||
done chan error
|
||||
reply chan bool
|
||||
@@ -60,7 +60,7 @@ type lifecycleCmd struct {
|
||||
// ended is closed (broadcast) when the run terminates, so any number of waiters
|
||||
// can observe it; err is the run's end result, valid only after ended is closed.
|
||||
// The "established" signal is not duplicated here — it is the start command's
|
||||
// runningChan, snapshotted directly from curStart when a waiter needs it.
|
||||
// connEstablishedChan, snapshotted directly from curStart when a waiter needs it.
|
||||
type runState struct {
|
||||
ended chan struct{} // closed by finishRun when the run terminates
|
||||
err error // run end result, valid after ended is closed
|
||||
@@ -74,7 +74,7 @@ type runEndResult struct {
|
||||
|
||||
// runFunc executes a single client run bound to the supervisor-owned context,
|
||||
// with the config supplied by the start request.
|
||||
type runFunc func(ctx context.Context, config *profilemanager.Config, mobileDep MobileDependency, runningChan chan struct{}, logPath string) error
|
||||
type runFunc func(ctx context.Context, config *profilemanager.Config, mobileDep MobileDependency, connEstablishedChan chan struct{}, logPath string) error
|
||||
|
||||
// supervisor serializes start/stop of a single client run. Every request goes
|
||||
// through cmdCh and is handled one at a time by the loop goroutine, so two
|
||||
@@ -150,7 +150,7 @@ func (s *supervisor) handleStart(cmd lifecycleCmd) {
|
||||
go func(ctx context.Context, cfg *profilemanager.Config, m MobileDependency, rc chan struct{}, lp string) {
|
||||
err := s.run(ctx, cfg, m, rc, lp)
|
||||
s.runEnded <- runEndResult{err: err}
|
||||
}(runCtx, cmd.config, cmd.mobileDep, cmd.runningChan, cmd.logPath)
|
||||
}(runCtx, cmd.config, cmd.mobileDep, cmd.connEstablishedChan, cmd.logPath)
|
||||
}
|
||||
|
||||
func (s *supervisor) handleStop(cmd lifecycleCmd) {
|
||||
@@ -194,7 +194,7 @@ func (s *supervisor) handleWaitEstablished(cmd lifecycleCmd) {
|
||||
return
|
||||
}
|
||||
rs := s.curRun
|
||||
established := s.curStart.runningChan
|
||||
established := s.curStart.connEstablishedChan
|
||||
ctx := cmd.waitCtx
|
||||
go func() {
|
||||
select {
|
||||
@@ -233,8 +233,8 @@ func (s *supervisor) shutdown() {
|
||||
// startAsync enqueues a start without blocking. If done is non-nil it receives
|
||||
// the run's end result (or errAlreadyRunning on rejection, or the context error
|
||||
// on shutdown).
|
||||
func (s *supervisor) startAsync(config *profilemanager.Config, md metadata.MD, mobileDep MobileDependency, runningChan chan struct{}, logPath string, done chan error) {
|
||||
cmd := lifecycleCmd{op: opStart, config: config, md: md, mobileDep: mobileDep, runningChan: runningChan, logPath: logPath, done: done}
|
||||
func (s *supervisor) startAsync(config *profilemanager.Config, md metadata.MD, mobileDep MobileDependency, connEstablishedChan chan struct{}, logPath string, done chan error) {
|
||||
cmd := lifecycleCmd{op: opStart, config: config, md: md, mobileDep: mobileDep, connEstablishedChan: connEstablishedChan, logPath: logPath, done: done}
|
||||
select {
|
||||
case s.cmdCh <- cmd:
|
||||
case <-s.ctx.Done():
|
||||
@@ -244,9 +244,9 @@ func (s *supervisor) startAsync(config *profilemanager.Config, md metadata.MD, m
|
||||
|
||||
// start enqueues a start and blocks until the run terminates, preserving the
|
||||
// blocking contract of the legacy Run entry points.
|
||||
func (s *supervisor) start(config *profilemanager.Config, md metadata.MD, mobileDep MobileDependency, runningChan chan struct{}, logPath string) error {
|
||||
func (s *supervisor) start(config *profilemanager.Config, md metadata.MD, mobileDep MobileDependency, connEstablishedChan chan struct{}, logPath string) error {
|
||||
done := make(chan error, 1)
|
||||
s.startAsync(config, md, mobileDep, runningChan, logPath, done)
|
||||
s.startAsync(config, md, mobileDep, connEstablishedChan, logPath, done)
|
||||
select {
|
||||
case err := <-done:
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user