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(),