after failing a new connection, flush the onion descriptor cache and try again in case the destination has cycled since its last use
This commit is contained in:
parent
530fa1f39f
commit
06381579e5
|
@ -4,6 +4,7 @@ import (
|
|||
"golang.org/x/net/proxy"
|
||||
"net"
|
||||
"strings"
|
||||
"github.com/yawning/bulb"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -53,8 +54,26 @@ func (nr *NetworkResolver) Resolve(hostname string) (net.Conn, string, error) {
|
|||
|
||||
conn, err := torDialer.Dial("tcp", resolvedHostname+".onion:9878")
|
||||
if err != nil {
|
||||
return nil, "", CannotDialRicochetAddressError
|
||||
NewNym("127.0.0.1:9051", "tcp4", "", 9878)
|
||||
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
return conn, resolvedHostname, nil
|
||||
}
|
||||
|
||||
// runs SIGNAL NEWNYM on the tor control port to flush the onion descriptors cache
|
||||
func NewNym(torControlAddress string, torControlSocketType string, authentication string, onionport uint16) error {
|
||||
c, err := bulb.Dial(torControlSocketType, torControlAddress)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = c.Authenticate(authentication)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = c.Request("SIGNAL NEWNYM")
|
||||
return err
|
||||
}
|
Reference in New Issue