uds

package
v0.0.0-...-8ac4b46 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Debug = false
)

Functions

func ParseMessage

func ParseMessage(data []byte, mtype int) (cmd string, meta map[string]string, outd []byte, end int)

Parse a message. Currently used in the UDS mapping, using a HTTP1-like text format Matches code in android java code - may be replaced with gRPC proto framing.

func SendFrameLenBinary

func SendFrameLenBinary(con io.Writer, data ...[]byte) (int, error)

Send a binary packet, with len prefix. Currently used in the UDS mapping.

Types

type UdsConn

type UdsConn struct {
	msgs.MsgConnection

	Handler msgs.MessageHandler

	Reader *bufio.Reader

	// Name of the UDS file. The unix addr will be under net=unix, as @Name
	Name string

	// Received file descriptors.
	Files []*os.File

	Pid      int32
	Uid, Gid uint32
	// contains filtered or unexported fields
}

UdsConn represents a client or server connection. This is not thread safe, should be used from a single receiver routine. Implements msgs.Framer and has a Send function.

func Dial

func Dial(ifname string, mux *msgs.Mux, initial map[string]string) (*UdsConn, error)

Dial a single client connection and handshake.

func (*UdsConn) Close

func (uds *UdsConn) Close()

func (*UdsConn) File

func (uds *UdsConn) File() *os.File

File returns a received file descriptor, or nil

func (*UdsConn) HandleStream

func (conn *UdsConn) HandleStream()

Handle the client messages, after dialing to a server.

func (*UdsConn) Read

func (uds *UdsConn) Read(out []byte) (int, error)

func (*UdsConn) Redial

func (uc *UdsConn) Redial() error

func (*UdsConn) SendMessage

func (uds *UdsConn) SendMessage(m *msgs.Message) error

Distribute the message to all UDS connections Implements the Transport interface.

func (*UdsConn) SendMessageDirect

func (uds *UdsConn) SendMessageDirect(cmd string, meta map[string]string, data []byte) error

Send a message over a UDS connection. Framed with a length prefix.

func (*UdsConn) WriteFD

func (uds *UdsConn) WriteFD(data []byte, file *os.File) (int, error)

WriteFD will write data as well as File

func (*UdsConn) WriteFDs

func (uds *UdsConn) WriteFDs(data []byte, file []*os.File) (int, error)

type UdsServer

type UdsServer struct {

	// Name of the server.
	Name string

	Gid int
	// contains filtered or unexported fields
}

func NewServer

func NewServer(name string, mux *msgs.Mux) (*UdsServer, error)

Create a UDS server listening on 'name'. go Dial() must be called to accept.

Messages posted on the mux will be sent to all clients (that subscribe - TODO). Messages received from clients will be passed to mux handlers.

func (*UdsServer) Close

func (uds *UdsServer) Close()

func (*UdsServer) Start

func (uds *UdsServer) Start() error

Jump to

Keyboard shortcuts

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