Skip to content

Commit

Permalink
Update support doorbird source #1060
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Dec 5, 2024
1 parent d7cdc8b commit d8c0f9d
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions pkg/doorbird/backchannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package doorbird
import (
"fmt"
"net"
"net/http"
"net/url"
"time"

Expand All @@ -25,19 +24,6 @@ func Dial(rawURL string) (*Client, error) {
user := u.User.Username()
pass, _ := u.User.Password()

rawURL = fmt.Sprintf("http://%s/bha-api/audio-transmit.cgi?http-user=%s&http-password=%s", u.Host, user, pass)

req, err := http.NewRequest("POST", rawURL, nil)
if err != nil {
return nil, err
}
req.Header = http.Header{
"Content-Type": []string{"audio/basic"},
"Content-Length": []string{"9999999"},
"Connection": []string{"Keep-Alive"},
"Cache-Control": []string{"no-cache"},
}

if u.Port() == "" {
u.Host += ":80"
}
Expand All @@ -47,8 +33,15 @@ func Dial(rawURL string) (*Client, error) {
return nil, err
}

s := fmt.Sprintf("POST /bha-api/audio-transmit.cgi?http-user=%s&http-password=%s HTTP/1.0\r\n", user, pass) +
"Content-Type: audio/basic\r\n" +
"Content-Length: 9999999\r\n" +
"Connection: Keep-Alive\r\n" +
"Cache-Control: no-cache\r\n" +
"\r\n"

_ = conn.SetWriteDeadline(time.Now().Add(core.ConnDeadline))
if err = req.Write(conn); err != nil {
if _, err = conn.Write([]byte(s)); err != nil {
return nil, err
}

Expand Down

0 comments on commit d8c0f9d

Please sign in to comment.