Whonix Support
This commit is contained in:
parent
a68c0fd160
commit
b353f78908
|
@ -126,8 +126,20 @@ func (t *Tor) Listen(ctx context.Context, conf *ListenConf) (*OnionService, erro
|
||||||
// Create the local listener if necessary
|
// Create the local listener if necessary
|
||||||
svc.LocalListener = conf.LocalListener
|
svc.LocalListener = conf.LocalListener
|
||||||
if svc.LocalListener == nil {
|
if svc.LocalListener == nil {
|
||||||
if svc.LocalListener, err = net.Listen("tcp", "127.0.0.1:"+strconv.Itoa(conf.LocalPort)); err != nil {
|
// To support whonix, and other systems that require external port binding:
|
||||||
return nil, err
|
// If BINE_WHONIX is explictly enabled AND the given directory exists, then bind to an
|
||||||
|
// external port.
|
||||||
|
// See: https://www.whonix.org/wiki/Dev/Project_friendly_applications_best_practices#Listening_Port
|
||||||
|
if bineWhonix := os.Getenv("BINE_WHONIX"); strings.ToLower(bineWhonix) == "true" {
|
||||||
|
if _, err := os.Stat("/usr/share/anon-ws-base-files/workstation"); !os.IsNotExist(err) {
|
||||||
|
if svc.LocalListener, err = net.Listen("tcp", "0.0.0.0:"+strconv.Itoa(conf.LocalPort)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if svc.LocalListener, err = net.Listen("tcp", "127.0.0.1:"+strconv.Itoa(conf.LocalPort)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue