Merge pull request 'Fix nil pointer deref on uncommon tor errors' (#19) from quality into master
Reviewed-on: #19
This commit is contained in:
commit
15060335f0
|
@ -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}
|
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)
|
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") {
|
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}}
|
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
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os.CloseLocalListenerOnClose = true
|
||||||
|
|
||||||
ols := &onionListenService{os: os, tp: tp}
|
ols := &onionListenService{os: os, tp: tp}
|
||||||
tp.childListeners[ols.AddressIdentity()] = ols
|
tp.childListeners[ols.AddressIdentity()] = ols
|
||||||
return ols, nil
|
return ols, nil
|
||||||
|
@ -218,7 +223,6 @@ func (tp *torProvider) Restart() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
go tp.restart()
|
go tp.restart()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,5 @@ func TestTorProvider(t *testing.T) {
|
||||||
acn.Restart()
|
acn.Restart()
|
||||||
acn.Restart()
|
acn.Restart()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
acn.Close()
|
acn.Close()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue