Skip to content

Commit

Permalink
chore: add more debug log
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <[email protected]>
  • Loading branch information
zhaojh329 committed Jan 16, 2025
1 parent 391096e commit bf00c5c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion device.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (dev *device) readLoop() {
b, err := br.Peek(3)
if err != nil {
if err != io.EOF && !strings.Contains(err.Error(), "use of closed network connection") {
log.Error().Msg(err.Error())
log.Error().Msgf("%s: %s", dev.conn.RemoteAddr(), err.Error())
}
return
}
Expand Down
11 changes: 7 additions & 4 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ func httpProxyRedirect(br *broker, c *gin.Context) {
if location == "" {
location = cfg.HttpProxyRedirURL
if location != "" {
log.Debug().Msgf("use HttpProxyRedirURL from config: %s", location)
log.Debug().Msgf("use HttpProxyRedirURL from config: %s, devid: %s", location, devid)
}
} else {
log.Debug().Msgf("use HttpProxyRedir from HTTP header: %s", location)
log.Debug().Msgf("use HttpProxyRedir from HTTP header: %s, devid: %s", location, devid)
}

if location == "" {
Expand Down Expand Up @@ -361,21 +361,24 @@ func httpProxyRedirect(br *broker, c *gin.Context) {
if v, ok := httpProxySessions.Load(sid); ok {
close(v.(chan struct{}))
httpProxySessions.Delete(sid)
log.Debug().Msgf(`del old httpProxySession "%s" for device "%s"`, sid, devid)
}
}

sid = utils.GenUniqueID("http-proxy")

httpProxySessions.Store(sid, make(chan struct{}))

log.Debug().Msgf(`new httpProxySession "%s" for device "%s"`, sid, devid)

domain := c.Request.Header.Get("HttpProxyRedirDomain")
if domain == "" {
domain = cfg.HttpProxyRedirDomain
if domain != "" {
log.Debug().Msgf("set cookie domain from config: %s", domain)
log.Debug().Msgf("set cookie domain from config: %s, devid: %s", domain, devid)
}
} else {
log.Debug().Msgf("set cookie domain from HTTP header: %s", domain)
log.Debug().Msgf("set cookie domain from HTTP header: %s, devid: %s", domain, devid)
}

c.SetCookie("rtty-http-sid", sid, 0, "", domain, false, true)
Expand Down

0 comments on commit bf00c5c

Please sign in to comment.