From d752a8f5e344adb05af5fba810c94afe19ab77b0 Mon Sep 17 00:00:00 2001 From: Jacob Su Date: Fri, 1 Nov 2024 10:44:40 +0800 Subject: [PATCH] fix the ip address is included in SRSServer.API. e.g. []API := { "127.0.0.1:19851" } --- proxy/srs.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/proxy/srs.go b/proxy/srs.go index b04df9ed7..8428777bc 100644 --- a/proxy/srs.go +++ b/proxy/srs.go @@ -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 }