|
|
|
@ -96,6 +96,7 @@ type Dialer struct {
|
|
|
|
dnsCache *dnscache.MessageCache // nil until first non-empty SetExitDNSDoH
|
|
|
|
dnsCache *dnscache.MessageCache // nil until first non-empty SetExitDNSDoH
|
|
|
|
nextSysConnID int
|
|
|
|
nextSysConnID int
|
|
|
|
activeSysConns map[int]net.Conn // active connections not yet closed
|
|
|
|
activeSysConns map[int]net.Conn // active connections not yet closed
|
|
|
|
|
|
|
|
bus *eventbus.Bus // only used for comparison with already set bus.
|
|
|
|
eventClient *eventbus.Client
|
|
|
|
eventClient *eventbus.Client
|
|
|
|
eventBusSubs eventbus.Monitor
|
|
|
|
eventBusSubs eventbus.Monitor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -226,14 +227,17 @@ func (d *Dialer) NetMon() *netmon.Monitor {
|
|
|
|
func (d *Dialer) SetBus(bus *eventbus.Bus) {
|
|
|
|
func (d *Dialer) SetBus(bus *eventbus.Bus) {
|
|
|
|
d.mu.Lock()
|
|
|
|
d.mu.Lock()
|
|
|
|
defer d.mu.Unlock()
|
|
|
|
defer d.mu.Unlock()
|
|
|
|
if d.eventClient != nil {
|
|
|
|
if d.bus == bus {
|
|
|
|
panic("eventbus has already been set")
|
|
|
|
return
|
|
|
|
|
|
|
|
} else if d.bus != nil {
|
|
|
|
|
|
|
|
panic("different eventbus has already been set")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Having multiple watchers could lead to problems,
|
|
|
|
// Having multiple watchers could lead to problems,
|
|
|
|
// so unregister the callback if it exists.
|
|
|
|
// so unregister the callback if it exists.
|
|
|
|
if d.netMonUnregister != nil {
|
|
|
|
if d.netMonUnregister != nil {
|
|
|
|
d.netMonUnregister()
|
|
|
|
d.netMonUnregister()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d.bus = bus
|
|
|
|
d.eventClient = bus.Client("tsdial.Dialer")
|
|
|
|
d.eventClient = bus.Client("tsdial.Dialer")
|
|
|
|
d.eventBusSubs = d.eventClient.Monitor(d.linkChangeWatcher(d.eventClient))
|
|
|
|
d.eventBusSubs = d.eventClient.Monitor(d.linkChangeWatcher(d.eventClient))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|