diff --git a/cmd_onion.go b/cmd_onion.go index db0e8d0..fd12ed2 100644 --- a/cmd_onion.go +++ b/cmd_onion.go @@ -14,7 +14,7 @@ import ( // OnionInfo is the result of the AddOnion command. type OnionInfo struct { - OnionId string + OnionID string KeyType string Key string @@ -33,7 +33,6 @@ func (c *Conn) AddOnion(virtPort int, target, keyType, keyContent string, new bo request += fmt.Sprintf("%s:%s", keyType, keyContent) } request += fmt.Sprintf(" Port=%d,%s\n", virtPort, target) - fmt.Printf("DEBUG request: %s\n", request) response, err := c.Request(request) if err != nil { return nil, err @@ -42,7 +41,7 @@ func (c *Conn) AddOnion(virtPort int, target, keyType, keyContent string, new bo onionInfo.RawResponse = response fields = strings.Split(fmt.Sprintf("%s", response.Data), "ServiceID=") fields = strings.Split(fields[1], " ") - onionInfo.OnionId = fields[0] + onionInfo.OnionID = fields[0] if new { fields = strings.Split(fmt.Sprintf("%s", response.Data), "PrivateKey=") @@ -55,8 +54,9 @@ func (c *Conn) AddOnion(virtPort int, target, keyType, keyContent string, new bo return &onionInfo, nil } -func (c *Conn) DeleteOnion(serviceId string) error { - var deleteCmd string = fmt.Sprintf("DEL_ONION %s\n", serviceId) +// DeleteOnion issues a DEL_ONION command and returns the parsed response. +func (c *Conn) DeleteOnion(serviceID string) error { + var deleteCmd string = fmt.Sprintf("DEL_ONION %s\n", serviceID) _, err := c.Request(deleteCmd) return err } diff --git a/utils/connection.go b/utils/connection.go index 2750a63..d1a9696 100644 --- a/utils/connection.go +++ b/utils/connection.go @@ -178,7 +178,7 @@ func (o *OnionListener) Accept() (net.Conn, error) { var conn net.Conn var err error - if o.onionInfo.OnionId == "" { + if o.onionInfo.OnionID == "" { return nil, fmt.Errorf("OnionListener: onion service not initialized.\n") } @@ -191,7 +191,7 @@ func (o *OnionListener) Accept() (net.Conn, error) { } func (o *OnionListener) Close() error { - err := o.controller.DeleteOnion(o.onionInfo.OnionId) + err := o.controller.DeleteOnion(o.onionInfo.OnionID) if err != nil { return fmt.Errorf("OnionListener: DeleteHiddenService failure: %s\n", err) } @@ -201,6 +201,6 @@ func (o *OnionListener) Close() error { func (o *OnionListener) Addr() net.Addr { return OnionAddr{ network: "tor", - address: fmt.Sprintf("%s.onion:%d", o.onionInfo.OnionId, o.options.OnionServicePort), + address: fmt.Sprintf("%s.onion:%d", o.onionInfo.OnionID, o.options.OnionServicePort), } }