Minor cleanups to make golint happy, removed a stray Printf.

This commit is contained in:
Yawning Angel 2015-10-08 21:25:22 +00:00
parent 2beeb7bc51
commit 28616763d2
2 changed files with 8 additions and 8 deletions

View File

@ -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
}

View File

@ -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),
}
}