Documentation ¶
Index ¶
- Constants
- type MessageType
- type WebSocket
- func (ws *WebSocket) AuthPubKey() (a string)
- func (ws *WebSocket) Challenge() (challenge string)
- func (ws *WebSocket) GenerateChallenge() (challenge string)
- func (ws *WebSocket) Ping() (err error)
- func (ws *WebSocket) Pong() (err error)
- func (ws *WebSocket) RealRemote() (remote string)
- func (ws *WebSocket) SetAuthPubKey(a string)
- func (ws *WebSocket) SetRealRemote(remote string)
- func (ws *WebSocket) WriteEnvelope(env enveloper.I) (err error)
- func (ws *WebSocket) WriteTextMessage(b []byte) (err error)
Constants ¶
View Source
const ChallengeLength = 16
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageType ¶
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 gorilla/websocket with mutex locking and NIP-42 IsAuthed support
func (*WebSocket) AuthPubKey ¶
AuthPubKey returns the current authed Pubkey.
func (*WebSocket) GenerateChallenge ¶
GenerateChallenge gathers new entropy to generate a new challenge.
func (*WebSocket) RealRemote ¶
RealRemote returns the current real remote.
func (*WebSocket) SetAuthPubKey ¶
func (*WebSocket) SetRealRemote ¶
func (*WebSocket) WriteEnvelope ¶
WriteEnvelope writes a message with a given websocket type specifier
func (*WebSocket) WriteTextMessage ¶
WriteTextMessage writes a text (binary?) message
Click to show internal directories.
Click to hide internal directories.