From f9da4e204abec2e352619c5b4122acc9107bba7c Mon Sep 17 00:00:00 2001 From: Aurora Gaffney Date: Wed, 3 Apr 2024 17:59:00 -0500 Subject: [PATCH] feat: use recognizable values for local/remote address on mock conn Fixes #9 --- connection.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/connection.go b/connection.go index eee7bd2..b4a3913 100644 --- a/connection.go +++ b/connection.go @@ -120,12 +120,16 @@ func (c *Connection) Close() error { // LocalAddr provides a proxy to the client-side connection's LocalAddr function. This is needed to satisfy the net.Conn interface func (c *Connection) LocalAddr() net.Addr { - return c.conn.LocalAddr() + return MockAddr{ + addr: fmt.Sprintf("mock-local:%p", c), + } } // RemoteAddr provides a proxy to the client-side connection's RemoteAddr function. This is needed to satisfy the net.Conn interface func (c *Connection) RemoteAddr() net.Addr { - return c.conn.RemoteAddr() + return MockAddr{ + addr: fmt.Sprintf("mock-remote:%p", c), + } } // SetDeadline provides a proxy to the client-side connection's SetDeadline function. This is needed to satisfy the net.Conn interface @@ -270,3 +274,15 @@ func (c *Connection) processOutputEntry(entry ConversationEntryOutput) error { } return nil } + +type MockAddr struct { + addr string +} + +func (m MockAddr) Network() string { + return "mock" +} + +func (m MockAddr) String() string { + return m.addr +}