added proxy protocol

This commit is contained in:
ginuerzh
2022-09-08 21:31:11 +08:00
parent 54e1801e74
commit efd8838c18
22 changed files with 150 additions and 37 deletions

View File

@ -0,0 +1,17 @@
package proxyproto
import (
"net"
proxyproto "github.com/pires/go-proxyproto"
)
func WrapClientConn(ppv int, src, dst net.Addr, c net.Conn) net.Conn {
if ppv <= 0 {
return c
}
header := proxyproto.HeaderProxyFromAddrs(byte(ppv), src, dst)
header.WriteTo(c)
return c
}