Fix nil pointer deref on uncommon tor errors #19
|
@ -192,17 +192,22 @@ func (tp *torProvider) Listen(identity connectivity.PrivateKey, port int) (conne
|
|||
|
||||
conf := &tor.ListenConf{NoWait: true, Version3: true, Key: identity, RemotePorts: []int{port}, Detach: true, DiscardKey: true, LocalListener: localListener}
|
||||
os, err := tp.t.Listen(nil, conf)
|
||||
|
||||
// Reattach to the old local listener...
|
||||
// Note: this code probably shouldn't be hit in Cwtch anymore because we purge torrc on restart.
|
||||
if err != nil && strings.Contains(err.Error(), "550 Unspecified Tor error: Onion address collision") {
|
||||
log.Errorf("550 Unspecified Tor error: Onion address collision - Recovering, but this probably indicates some weird tor configuration issue...")
|
||||
os = &tor.OnionService{Tor: tp.t, LocalListener: localListener, ID: onion, Version3: true, Key: bineed255192.FromCryptoPrivateKey(privkey), ClientAuths: make(map[string]string, 0), RemotePorts: []int{port}}
|
||||
err = nil
|
||||
}
|
||||
// Not set in t.Listen if supplied, we want it to handle this however
|
||||
os.CloseLocalListenerOnClose = true
|
||||
|
||||
// Any other errors require an immediate return as os is likely nil...
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
os.CloseLocalListenerOnClose = true
|
||||
|
||||
ols := &onionListenService{os: os, tp: tp}
|
||||
tp.childListeners[ols.AddressIdentity()] = ols
|
||||
return ols, nil
|
||||
|
@ -218,7 +223,6 @@ func (tp *torProvider) Restart() {
|
|||
return
|
||||
}
|
||||
|
||||
|
||||
go tp.restart()
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,5 @@ func TestTorProvider(t *testing.T) {
|
|||
acn.Restart()
|
||||
acn.Restart()
|
||||
|
||||
|
||||
|
||||
acn.Close()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue