Differentiate UDP stream and TCP connection in logs

This commit is contained in:
Romain 2023-01-31 16:00:10 +01:00 committed by GitHub
parent 479878503d
commit 38f5024ed0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View file

@ -20,14 +20,14 @@ func NewProxy(address string) (*Proxy, error) {
// ServeUDP implements the Handler interface.
func (p *Proxy) ServeUDP(conn *Conn) {
log.WithoutContext().Debugf("Handling connection from %s to %s", conn.rAddr, p.target)
log.WithoutContext().Debugf("Handling UDP stream from %s to %s", conn.rAddr, p.target)
// needed because of e.g. server.trackedConnection
defer conn.Close()
connBackend, err := net.Dial("udp", p.target)
if err != nil {
log.WithoutContext().Errorf("Error while connecting to backend: %v", err)
log.WithoutContext().Errorf("Error while dialing backend: %v", err)
return
}
@ -40,7 +40,7 @@ func (p *Proxy) ServeUDP(conn *Conn) {
err = <-errChan
if err != nil {
log.WithoutContext().Errorf("Error while serving UDP: %v", err)
log.WithoutContext().Errorf("Error while handling UDP stream: %v", err)
}
<-errChan
@ -55,6 +55,6 @@ func connCopy(dst io.WriteCloser, src io.Reader, errCh chan error) {
errCh <- err
if err := dst.Close(); err != nil {
log.WithoutContext().Debugf("Error while terminating connection: %v", err)
log.WithoutContext().Debugf("Error while terminating UDP stream: %v", err)
}
}