Merge branch 'newnym' of openprivacy/libricochet-go into master
This commit is contained in:
commit
6c37867ed1
|
@ -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
|
||||
}
|
||||
|
|
Reference in New Issue