File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ type Dialer struct {
9696 dnsCache * dnscache.MessageCache // nil until first non-empty SetExitDNSDoH
9797 nextSysConnID int
9898 activeSysConns map [int ]net.Conn // active connections not yet closed
99+ bus * eventbus.Bus // only used for comparison with already set bus.
99100 eventClient * eventbus.Client
100101 eventBusSubs eventbus.Monitor
101102}
@@ -226,14 +227,17 @@ func (d *Dialer) NetMon() *netmon.Monitor {
226227func (d * Dialer ) SetBus (bus * eventbus.Bus ) {
227228 d .mu .Lock ()
228229 defer d .mu .Unlock ()
229- if d .eventClient != nil {
230- panic ("eventbus has already been set" )
230+ if d .bus == bus {
231+ return
232+ } else if d .bus != nil {
233+ panic ("different eventbus has already been set" )
231234 }
232235 // Having multiple watchers could lead to problems,
233236 // so unregister the callback if it exists.
234237 if d .netMonUnregister != nil {
235238 d .netMonUnregister ()
236239 }
240+ d .bus = bus
237241 d .eventClient = bus .Client ("tsdial.Dialer" )
238242 d .eventBusSubs = d .eventClient .Monitor (d .linkChangeWatcher (d .eventClient ))
239243}
You can’t perform that action at this time.
0 commit comments