relayws

package
v1.1.22 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const ChallengeLength = 16

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageType added in v1.1.16

type MessageType int
const (
	// TextMessage denotes a text data message. The text message payload is
	// interpreted as UTF-8 encoded text data.
	TextMessage MessageType = websocket.TextMessage

	// BinaryMessage denotes a binary data message.
	BinaryMessage MessageType = websocket.BinaryMessage

	// CloseMessage denotes a close control message. The optional message
	// payload contains a numeric code and text. Use the FormatCloseMessage
	// function to format a close message payload.
	CloseMessage MessageType = websocket.CloseMessage

	// PingMessage denotes a ping control message. The optional message payload
	// is UTF-8 encoded text.
	PingMessage MessageType = websocket.PingMessage

	// PongMessage denotes a pong control message. The optional message payload
	// is UTF-8 encoded text.
	PongMessage MessageType = websocket.PongMessage
)

The message types are defined in RFC 6455, section 11.8.

Repeating here for shorter names.

type WebSocket

type WebSocket struct {
	Conn *websocket.Conn

	Request *http.Request // original request

	Pending atomic.Value // for DM CLI authentication

	Authed       chan struct{}
	OffenseCount atomic.Uint32 // when client does dumb stuff, increment this
	// contains filtered or unexported fields
}

WebSocket is a wrapper around a fasthttp/websocket with mutex locking and NIP-42 Auth support

func (*WebSocket) AuthPubKey

func (ws *WebSocket) AuthPubKey() (a string)

AuthPubKey returns the current authed Pubkey.

func (*WebSocket) Challenge

func (ws *WebSocket) Challenge() (challenge string)

Challenge returns the current challenge on a websocket.

func (*WebSocket) GenerateChallenge

func (ws *WebSocket) GenerateChallenge() (challenge string)

GenerateChallenge gathers new entropy to generate a new challenge.

func (*WebSocket) RealRemote

func (ws *WebSocket) RealRemote() (remote string)

RealRemote returns the current real remote.

func (*WebSocket) SetAuthPubKey

func (ws *WebSocket) SetAuthPubKey(a string)

func (*WebSocket) SetRealRemote

func (ws *WebSocket) SetRealRemote(remote string)

func (*WebSocket) WriteEnvelope

func (ws *WebSocket) WriteEnvelope(env enveloper.I) (err error)

WriteEnvelope writes a message with a given websocket type specifier

func (*WebSocket) WriteMessage

func (ws *WebSocket) WriteMessage(t MessageType, b []byte) (err error)

WriteMessage writes a message with a given websocket type specifier

Jump to

Keyboard shortcuts

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