Merge branch 'newnym' of openprivacy/libricochet-go into master

This commit is contained in:
Sarah Jamie Lewis 2018-10-08 02:45:01 +00:00 committed by Gogs
commit 6c37867ed1
1 changed files with 20 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package utils
import (
"github.com/yawning/bulb"
"golang.org/x/net/proxy"
"net"
"strings"
@ -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
}