Add further documentation to Authenticate().
This commit is contained in:
parent
d109336930
commit
b19f84d674
|
@ -17,8 +17,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Authenticate authenticates with the Tor instance using the "best" possible
|
// Authenticate authenticates with the Tor instance using the "best" possible
|
||||||
// authentication method.
|
// authentication method. The password argument is entirely optional, and will
|
||||||
func (c *Conn) Authenticate(passwd string) error {
|
// only be used if the "SAFECOOKE" and "NULL" authentication methods are not
|
||||||
|
// available and "HASHEDPASSWORD" is.
|
||||||
|
func (c *Conn) Authenticate(password string) error {
|
||||||
if c.isAuthenticated {
|
if c.isAuthenticated {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -123,11 +125,11 @@ func (c *Conn) Authenticate(passwd string) error {
|
||||||
// Despite the name HASHEDPASSWORD, the raw password is actually sent.
|
// Despite the name HASHEDPASSWORD, the raw password is actually sent.
|
||||||
// According to the code, this can either be a QuotedString, or base16
|
// According to the code, this can either be a QuotedString, or base16
|
||||||
// encoded, so go with the later since it's easier to handle.
|
// encoded, so go with the later since it's easier to handle.
|
||||||
if passwd == "" {
|
if password == "" {
|
||||||
return newProtocolError("password auth needs a password")
|
return newProtocolError("password auth needs a password")
|
||||||
}
|
}
|
||||||
passwdStr := hex.EncodeToString([]byte(passwd))
|
passwordStr := hex.EncodeToString([]byte(password))
|
||||||
_, err = c.Request("%s %s", cmdAuthenticate, passwdStr)
|
_, err = c.Request("%s %s", cmdAuthenticate, passwordStr)
|
||||||
c.isAuthenticated = err == nil
|
c.isAuthenticated = err == nil
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
|
|
Reference in New Issue