From 29540dcf71c526de9abe850e50d91f0cb2e9ce14 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 6 Nov 2019 11:26:54 -0800 Subject: [PATCH] Expose Reboot --- connectivity/acn.go | 3 +++ connectivity/localProvider.go | 4 ++++ connectivity/torProvider.go | 7 +++++++ go.mod | 2 ++ 4 files changed, 16 insertions(+) diff --git a/connectivity/acn.go b/connectivity/acn.go index f6b67b4..de17257 100644 --- a/connectivity/acn.go +++ b/connectivity/acn.go @@ -28,6 +28,9 @@ type ACN interface { // Sets the calback function to be called when ACN status changes SetStatusCallback(callback func(int, string)) + // Restarts the underlying connection + Restart() + // Open takes a hostname and returns a net.conn to the derived endpoint // Open allows a client to resolve various hostnames to connections // The supported types are onions address are: diff --git a/connectivity/localProvider.go b/connectivity/localProvider.go index be8dc48..fc71662 100644 --- a/connectivity/localProvider.go +++ b/connectivity/localProvider.go @@ -63,6 +63,10 @@ func (lp *localProvider) Open(hostname string) (net.Conn, string, error) { } +func (lp *localProvider) Restart() { + //noop +} + func (lp *localProvider) Close() { } diff --git a/connectivity/torProvider.go b/connectivity/torProvider.go index 473efb7..d3950c9 100644 --- a/connectivity/torProvider.go +++ b/connectivity/torProvider.go @@ -155,6 +155,13 @@ func (tp *torProvider) Listen(identity PrivateKey, port int) (ListenService, err return ols, nil } +func (tp *torProvider) Restart() { + if tp.statusCallback != nil { + tp.statusCallback(0, "rebooting") + } + tp.restart() +} + func (tp *torProvider) Open(hostname string) (net.Conn, string, error) { tp.lock.Lock() diff --git a/go.mod b/go.mod index 382f90e..7fcefae 100644 --- a/go.mod +++ b/go.mod @@ -9,3 +9,5 @@ require ( golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3 // indirect golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 // indirect ) + +go 1.13