parse real client IP

This commit is contained in:
ginuerzh
2025-07-15 19:59:10 +08:00
parent d9a2f44a78
commit afcf4a5252
24 changed files with 232 additions and 74 deletions
+15 -2
View File
@@ -8,8 +8,9 @@ import (
)
type conn struct {
session *wt.Session
stream *wt.Stream
session *wt.Session
stream *wt.Stream
clientAddr net.Addr
}
func Conn(session *wt.Session, stream *wt.Stream) net.Conn {
@@ -19,6 +20,14 @@ func Conn(session *wt.Session, stream *wt.Stream) net.Conn {
}
}
func ConnWithClientAddr(session *wt.Session, stream *wt.Stream, clientAddr net.Addr) net.Conn {
return &conn{
session: session,
stream: stream,
clientAddr: clientAddr,
}
}
func (c *conn) Read(b []byte) (n int, err error) {
return c.stream.Read(b)
}
@@ -39,6 +48,10 @@ func (c *conn) RemoteAddr() net.Addr {
return c.session.RemoteAddr()
}
func (c *conn) ClientAddr() net.Addr {
return c.clientAddr
}
func (c *conn) SetDeadline(t time.Time) error {
return c.stream.SetDeadline(t)
}