tor: remove Onion Service upon shutdown
This commit adds a new method to call DEL_ONION when lnd is shutting down. Tor controller will now be aware of the active serviceID and removes the service upon shutdown.
This commit is contained in:
3 files changed
+67
No files matched your search
@@ -20,6 +20,14 @@ const (
|
||||
// request.
|
||||
success = 250
|
||||
|
||||
// invalidNumOfArguments is the Tor Control response code representing
|
||||
// there being an invalid number of arguments.
|
||||
invalidNumOfArguments = 512
|
||||
|
||||
// serviceIDNotRecognized is the Tor Control response code representing
|
||||
// the specified ServiceID is not recognized.
|
||||
serviceIDNotRecognized = 552
|
||||
|
||||
// nonceLen is the length of a nonce generated by either the controller
|
||||
// or the Tor server
|
||||
nonceLen = 32
|
||||
@@ -100,6 +108,9 @@ type Controller struct {
|
||||
// to connect to the LND node. This is required when the Tor server
|
||||
// runs on another host, otherwise the service will not be reachable.
|
||||
targetIPAddress string
|
||||
|
||||
// activeServiceID is the Onion ServiceID created by ADD_ONION.
|
||||
activeServiceID string
|
||||
}
|
||||
|
||||
// NewController returns a new Tor controller that will be able to interact with
|
||||
@@ -142,6 +153,15 @@ func (c *Controller) Stop() error {
|
||||
|
||||
log.Info("Stopping tor controller")
|
||||
|
||||
// Remove the onion service.
|
||||
if err := c.DelOnion(c.activeServiceID); err != nil {
|
||||
log.Errorf("DEL_ONION got error: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
// Reset service ID.
|
||||
c.activeServiceID = ""
|
||||
|
||||
return c.conn.Close()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user