converge/pkg/comms/agentlistener.go
Erik Brakkee ada34495ef GOB channel for easily and asynchronously using GOB on a single network connection, also dealing with timeouts and errors in a good way.
Protocol version is now checked when the agent connects to the converge server.

Next up: sending connection metadata and username password from server to agent and sending environment information back to the server. This means then that the side channel will only be used for expiry time messages and session type with the client id passed in so the converge server can than correlate the results back to the correct channel.
2024-09-08 11:16:49 +02:00

37 lines
633 B
Go

package comms
import (
"net"
)
type AgentListener struct {
decorated net.Listener
}
func NewAgentListener(listener net.Listener) AgentListener {
return AgentListener{decorated: listener}
}
func (listener AgentListener) Accept() (net.Conn, error) {
conn, err := listener.decorated.Accept()
if err != nil {
return nil, err
}
//_, err = CheckProtocolVersion(Agent, conn)
//if err != nil {
// conn.Close()
// return nil, err
//}
return conn, nil
}
func (listener AgentListener) Close() error {
return listener.decorated.Close()
}
func (listener AgentListener) Addr() net.Addr {
return listener.decorated.Addr()
}