comm

package
v0.5.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2025 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ConnectionModePacket = "packet"
	ConnectionModeLog    = "log"
)

Connection mode constants

View Source
const MinClientVersion = "v0.5.0"
View Source
const MinServerVersion = "v0.5.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientHandshakePacket added in v0.2.0

type ClientHandshakePacket struct {
	OutrigSDK string `json:"outrigsdk"`
	Mode      string `json:"mode"`
	Submode   string `json:"submode,omitempty"`
	AppRunID  string `json:"apprunid,omitempty"`
}

ClientHandshakePacket represents the JSON structure for client handshake

type ConnWrap

type ConnWrap struct {
	Conn           net.Conn
	Reader         *bufio.Reader
	PeerName       string
	ServerResponse *ServerHandshakeResponse // set on client side connections
}

ConnWrap wraps a net.Conn and a bufio.Reader for convenient line-based communication.

func Connect

func Connect(mode string, submode string, appRunId string, domainSocketPath string, serverAddr string) (*ConnWrap, error, error)

Connect attempts to connect to either a domain socket or TCP server, performs the handshake with the specified mode, submode, and appRunId, and returns a new ConnWrap if successful.

If domainSocketPath is not empty, it will first try to connect to the domain socket. If that fails and serverAddr is not empty, it will fall back to TCP. When both domainSocketPath and serverAddr are empty or "-", the function returns (nil, nil, nil) without error.

The function returns (ConnWrap, PermanentError, TransientError)

func MakeConnWrap

func MakeConnWrap(conn net.Conn, peerName string) *ConnWrap

MakeConnWrap creates a new ConnWrap from a net.Conn.

func (*ConnWrap) ClientHandshake

func (cw *ConnWrap) ClientHandshake(modeName string, submode string, appRunId string) (*ServerHandshakeResponse, error)

ClientHandshake performs the client side of the handshake protocol with the server. It receives a ServerHandshakePacket, validates compatibility, sends a ClientHandshakePacket, and processes the server's response.

func (*ConnWrap) Close

func (cw *ConnWrap) Close() error

Close closes the underlying connection.

func (*ConnWrap) ReadLine

func (cw *ConnWrap) ReadLine() (string, error)

ReadLine reads a line from the connection.

func (*ConnWrap) ServerHandshake

func (cw *ConnWrap) ServerHandshake(webServerPort int) (*ClientHandshakePacket, error)

ServerHandshake performs the server side of the handshake protocol. It sends a ServerHandshakePacket, reads a ClientHandshakePacket, validates it, and sends a response.

func (*ConnWrap) WriteLine

func (cw *ConnWrap) WriteLine(line string) error

WriteLine writes a line to the connection.

type ServerHandshakePacket added in v0.2.0

type ServerHandshakePacket struct {
	OutrigVersion string `json:"outrigversion"`
}

type ServerHandshakeResponse added in v0.2.0

type ServerHandshakeResponse struct {
	Success        bool   `json:"success"`
	Error          string `json:"error,omitempty"`
	ServerHttpPort int    `json:"serverhttpport,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL