From e148d8aedac551a7481fcd8c81ea31c727e1a2f0 Mon Sep 17 00:00:00 2001 From: imbytecat Date: Thu, 22 Aug 2024 13:49:29 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E8=A7=84=E8=8C=83=E5=8C=96=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- router/handler/onvif/connection.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/router/handler/onvif/connection.go b/router/handler/onvif/connection.go index 55b4d39..ba00740 100644 --- a/router/handler/onvif/connection.go +++ b/router/handler/onvif/connection.go @@ -4,6 +4,7 @@ import ( "github.com/gin-gonic/gin" "net/http" "onvif-agent/service/onvif" + "strings" ) var conns = make(map[string]*onvif.Connection) @@ -21,7 +22,13 @@ func CreateConnection(c *gin.Context) { return } - conn, err := onvif.NewConnection(req.Xaddr, req.Username, req.Password) + // 规范化连接地址 + xaddr := req.Xaddr + if !strings.Contains(xaddr, ":") { + xaddr += ":80" + } + + conn, err := onvif.NewConnection(xaddr, req.Username, req.Password) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{ "message": err.Error(),