Documentation ¶
Index ¶
- Constants
- type B
- type E
- type MessageType
- type N
- type S
- type WS
- func (ws *WS) AuthPub() (a B)
- func (ws *WS) Challenge() (challenge B)
- func (ws *WS) GenerateChallenge() (challenge S)
- func (ws *WS) HasAuth() bool
- func (ws *WS) Ping() (err E)
- func (ws *WS) Pong() (err E)
- func (ws *WS) Remote() (remote S)
- func (ws *WS) SetAuthPubKey(a B)
- func (ws *WS) SetRealRemote(remote S)
- func (ws *WS) WriteEnvelope(env enveloper.I) (err error)
- func (ws *WS) WriteTextMessage(b B) (err E)
Constants ¶
View Source
const ChallengeHRP = "nch"
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 = w.TextMessage // BinaryMessage denotes a binary data message. BinaryMessage MessageType = w.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 = w.CloseMessage // PingMessage denotes a ping control message. The optional message payload is UTF-8 encoded text. PingMessage MessageType = w.PingMessage // PongMessage denotes a pong control message. The optional message payload is UTF-8 encoded text. PongMessage MessageType = w.PongMessage )
The message types are defined in RFC 6455, section 11.8.
Repeating here for shorter names.
type WS ¶
type WS struct { Conn *w.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 }
WS is a wrapper around a gorilla/websocket with mutex locking and NIP-42 IsAuthed support
func (*WS) GenerateChallenge ¶
GenerateChallenge gathers new entropy to generate a new challenge, stores it and returns it.
func (*WS) SetAuthPubKey ¶
SetAuthPubKey loads the outhPubKey atomic of the websocket. Note that []byte is a reference so the caller should not mutate it. Calls to access it are copied as above.
func (*WS) SetRealRemote ¶
func (*WS) WriteEnvelope ¶
WriteEnvelope writes a message with a given websocket type specifier
func (*WS) WriteTextMessage ¶
WriteTextMessage writes a text (binary?) message
Click to show internal directories.
Click to hide internal directories.