Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Connection.RemoteAddr() by Connection() #171

Merged
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions server/httpconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type httpConnection struct {
conn net.Conn
}

func (c httpConnection) RemoteAddr() net.Addr {
return c.conn.RemoteAddr()
func (c httpConnection) Connection() net.Conn {
return c.conn
}

var _ types.Connection = (*httpConnection)(nil)
Expand Down
2 changes: 1 addition & 1 deletion server/serverimpl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestServerStartAcceptConnection(t *testing.T) {
assert.True(t, atomic.LoadInt32(&connectionCloseCalled) == 0)

// Verify that the RemoteAddr is correct.
require.Equal(t, conn.LocalAddr().String(), srvConn.RemoteAddr().String())
require.Equal(t, conn.LocalAddr().String(), srvConn.Connection().RemoteAddr().String())

// Close the connection from client side.
conn.Close()
Expand Down
4 changes: 2 additions & 2 deletions server/types/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
// Connection represents one OpAMP connection.
// The implementation MUST be a comparable type so that it can be used as a map key.
type Connection interface {
// RemoteAddr returns the remote network address of the connection.
RemoteAddr() net.Addr
// Connection returns the underlying net.Conn
Connection() net.Conn

// Send a message. Should not be called concurrently for the same Connection instance.
// Can be called only for WebSocket connections. Will return an error for plain HTTP
Expand Down
4 changes: 2 additions & 2 deletions server/wsconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type wsConnection struct {

var _ types.Connection = (*wsConnection)(nil)

func (c wsConnection) RemoteAddr() net.Addr {
return c.wsConn.RemoteAddr()
func (c wsConnection) Connection() net.Conn {
return c.wsConn.UnderlyingConn()
}

// Message header is currently uint64 zero value.
Expand Down