mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-05 16:26:50 +08:00
Add bypass login for TP-Link cameras
This commit is contained in:
@@ -22,6 +22,7 @@ const (
|
||||
AuthUnknown
|
||||
AuthBasic
|
||||
AuthDigest
|
||||
AuthTPLink // https://drmnsamoliu.github.io/video.html
|
||||
)
|
||||
|
||||
func NewAuth(user *url.Userinfo) *Auth {
|
||||
@@ -79,6 +80,8 @@ func (a *Auth) Write(req *Request) {
|
||||
`, uri="%s", response="%s"`, uri, response,
|
||||
)
|
||||
req.Header.Set("Authorization", header)
|
||||
case AuthTPLink:
|
||||
req.URL.Host = "127.0.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +103,15 @@ func (a *Auth) Validate(req *Request) bool {
|
||||
return header == a.header
|
||||
}
|
||||
|
||||
func (a *Auth) ReadNone(res *Response) bool {
|
||||
auth := res.Header.Get("WWW-Authenticate")
|
||||
if strings.Contains(auth, "TP-LINK Streaming Media") {
|
||||
a.Method = AuthTPLink
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func Between(s, sub1, sub2 string) string {
|
||||
i := strings.Index(s, sub1)
|
||||
if i < 0 {
|
||||
|
Reference in New Issue
Block a user