Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,13 @@ func (s *Session) RemoteAddr() (addr string) {

return fmt.Sprintf("%s:80", host)
}

// LocalAddr returns the local address (ip:port) of the underlying accepted connection.
// It delegates to the topmost parent context so MITM-wrapped conns work transparently.
func (c *Context) LocalAddr() net.Addr {
if c.parent == nil {
return c.conn.LocalAddr()
}

return c.parent.ctx.LocalAddr()
}