Fix support raw username/password for tapo source #748
This commit is contained in:
+8
-9
@@ -65,11 +65,6 @@ func (c *Client) newConn() (net.Conn, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// support raw username/password or cloud password in place of username
|
|
||||||
if _, ok := u.User.Password(); !ok {
|
|
||||||
u.User = url.UserPassword("admin", u.User.Username())
|
|
||||||
}
|
|
||||||
|
|
||||||
if u.Port() == "" {
|
if u.Port() == "" {
|
||||||
u.Host += ":8800"
|
u.Host += ":8800"
|
||||||
}
|
}
|
||||||
@@ -269,10 +264,14 @@ func dial(req *http.Request) (net.Conn, *http.Response, error) {
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(auth, `encrypt_type="3"`) {
|
if password == "" {
|
||||||
password = fmt.Sprintf("%32X", sha256.Sum256([]byte(password)))
|
// support cloud password in place of username
|
||||||
} else {
|
if strings.Contains(auth, `encrypt_type="3"`) {
|
||||||
password = fmt.Sprintf("%16X", md5.Sum([]byte(password)))
|
password = fmt.Sprintf("%32X", sha256.Sum256([]byte(username)))
|
||||||
|
} else {
|
||||||
|
password = fmt.Sprintf("%16X", md5.Sum([]byte(username)))
|
||||||
|
}
|
||||||
|
username = "admin"
|
||||||
}
|
}
|
||||||
|
|
||||||
realm := tcp.Between(auth, `realm="`, `"`)
|
realm := tcp.Between(auth, `realm="`, `"`)
|
||||||
|
|||||||
Reference in New Issue
Block a user