add TakeOwnership call once tor started to help ensure tor ends; add support for __OwningControllerProcess
This commit is contained in:
parent
51029af959
commit
bbe4198a41
|
@ -335,6 +335,7 @@ func (tp *torProvider) restart() {
|
|||
}
|
||||
tp.lastRestartTime = time.Now()
|
||||
tp.isClosed = false
|
||||
tp.t.Control.TakeOwnership()
|
||||
go tp.monitorRestart()
|
||||
} else {
|
||||
log.Errorf("Error restarting Tor process: %v", err)
|
||||
|
@ -431,6 +432,7 @@ func NewTorACNWithAuth(appDirectory string, bundledTorPath string, dataDir strin
|
|||
tp, err := startTor(appDirectory, bundledTorPath, dataDir, controlPort, authenticator)
|
||||
if err == nil {
|
||||
tp.isClosed = false
|
||||
tp.t.Control.TakeOwnership()
|
||||
go tp.monitorRestart()
|
||||
}
|
||||
return tp, err
|
||||
|
|
|
@ -42,15 +42,28 @@ func (tb *TorrcBuilder) WithControlPort(port int) *TorrcBuilder {
|
|||
return tb
|
||||
}
|
||||
|
||||
// WithLog sets the Log to file directive to the specified with with the specified log level
|
||||
// WithLog sets the Log to file directive to the specified file with the specified log level
|
||||
func (tb *TorrcBuilder) WithLog(logfile string, level TorLogLevel) *TorrcBuilder {
|
||||
tb.lines = append(tb.lines, fmt.Sprintf("Log %v file %v", level, logfile))
|
||||
return tb
|
||||
}
|
||||
|
||||
// WithCustom clobbers the torrc builder and allows the client to set any option they want, while benefiting
|
||||
// WithSocksTimeout adjusts how long before a timeout error is generated trying to connect to the SOCKS port
|
||||
func (tb *TorrcBuilder) WithSocksTimeout(timeOutSecs int) *TorrcBuilder {
|
||||
tb.lines = append(tb.lines, fmt.Sprintf("SocksTimeout %v", timeOutSecs))
|
||||
return tb
|
||||
}
|
||||
|
||||
// WithCustom appends to the torrc builder and allows the client to set any option they want, while benefiting
|
||||
// from other configuration options.
|
||||
func (tb *TorrcBuilder) WithCustom(lines []string) *TorrcBuilder {
|
||||
tb.lines = append(tb.lines, lines...)
|
||||
return tb
|
||||
}
|
||||
|
||||
// UseCustom clobbers the torrc builder and allows the client to set any option they want, while benefiting
|
||||
// from other configuration options.
|
||||
func (tb *TorrcBuilder) UseCustom(lines []string) *TorrcBuilder {
|
||||
tb.lines = lines
|
||||
return tb
|
||||
}
|
||||
|
@ -66,6 +79,12 @@ func (tb *TorrcBuilder) WithOnionTrafficOnly() *TorrcBuilder {
|
|||
return tb
|
||||
}
|
||||
|
||||
// WithOwningPid adds a __OwningControllerProcess line to the config that will attempt to have tor monitor parent PID health and die when parent dies
|
||||
func (tb *TorrcBuilder) WithOwningPid(pid int) *TorrcBuilder {
|
||||
tb.lines = append(tb.lines, fmt.Sprintf("__OwningControllerProcess %v", pid))
|
||||
return tb
|
||||
}
|
||||
|
||||
// WithHashedPassword sets a password for the control port.
|
||||
func (tb *TorrcBuilder) WithHashedPassword(password string) *TorrcBuilder {
|
||||
var salt [8]byte
|
||||
|
|
Loading…
Reference in New Issue