Skip to content

Commit

Permalink
fix the ip address is included in SRSServer.API.
Browse files Browse the repository at this point in the history
e.g. []API := { "127.0.0.1:19851" }
  • Loading branch information
suzp1984 committed Nov 1, 2024
1 parent b5036eb commit d752a8f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion proxy/srs.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,14 @@ func (v *SRSServer) Format(f fmt.State, c rune) {
}

func (v *SRSServer) ApiRequest(ctx context.Context, r *http.Request, body []byte) ([]byte, error) {
url := "http://" + v.IP + ":" + v.API[0] + r.URL.Path
var url string
// if the v.API[0] contains ip address, e.g. 127.0.0.1:1985, then use it as the ip address
if strings.Contains(v.API[0], ":") && strings.Index(v.API[0], ":") > 0 {
url = "http://" + v.API[0] + r.URL.Path
} else {
url = "http://" + v.IP + ":" + v.API[0] + r.URL.Path
}

if r.URL.RawQuery != "" {
url += "?" + r.URL.RawQuery
}
Expand Down

0 comments on commit d752a8f

Please sign in to comment.