proxy

package
v0.0.0-...-da828be Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const AuthorizationHeader = "Authorization"
View Source
const ChannelParam = "channel"

channel the client wants to connect to

View Source
const ClientName = "clientName"

The user friendly name of the client

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationError

type AuthenticationError struct {
	Message string
}

func NewAuthenticationError

func NewAuthenticationError(message string) *AuthenticationError

func (*AuthenticationError) Error

func (e *AuthenticationError) Error() string

type Endpoint

type Endpoint struct {
	Ip   string
	Port int
	Name string
}

type Packet

type Packet struct {
	Type   PacketType
	Target Endpoint
	Source Endpoint
	Data   []byte
}

func NewPacketFromBytes

func NewPacketFromBytes(data []byte) (*Packet, error)

FromBytes creates a new packet from a byte array

func NewPacketFromStruct

func NewPacketFromStruct(obj any, typ PacketType) (*Packet, error)

NewPacketFromStruct creates a new packet from a struct with the given packet type

func (*Packet) DecodeJsonData

func (packet *Packet) DecodeJsonData(out any) error

DecodeJsonData inside this packet.

func (*Packet) ToBytes

func (packet *Packet) ToBytes() ([]byte, error)

ToBytes converts the packet to a byte array

type PacketType

type PacketType int
const (
	Data PacketType = iota
	Error
	CriticalError
	// update all clients with the current channel state info. e.g. list of channel members
	// and other channel specific information
	ChannelState
	// sent by a channel member to update their info
	// The server will then emit a ChannelState packet to all clients in the channel
	// to let them know about the new member info
	MemberInfo
	SocketConnect
	SocketDisconnect
)

This enum indicates to the receiver what the packet is for

type ProxyClient

type ProxyClient struct {
	Id            uuid.UUID
	WsCon         *websocket.Conn
	InputChannel  chan Packet
	OutputChannel chan Packet
	CloseChannel  chan bool
	Closed        bool
	Settings      ProxyClientSettings
}

func NewOutgoingSocket

func NewOutgoingSocket(url url.URL, settings ProxyClientSettings) (*ProxyClient, error)

NewOutgoingSocket creates a new outgoing websocket connection to the given url

func UpgradeConnection

func UpgradeConnection(context *gin.Context, settings ProxyClientSettings) (*ProxyClient, error)

func (*ProxyClient) Close

func (client *ProxyClient) Close() error

func (*ProxyClient) Read

func (client *ProxyClient) Read() (Packet, bool)

func (*ProxyClient) Write

func (client *ProxyClient) Write(packet Packet)

type ProxyClientSettings

type ProxyClientSettings struct {
	Name     string
	Channel  string
	Password string
}

Jump to

Keyboard shortcuts

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