Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeChallengeString ¶
DecodeChallengeString accepts base64 encoded strings and decodes them, checks their length to be equal to challengeLength, and returns the decoded bytes
func GenerateChallenge ¶
func GenerateChallenge() string
GenerateChallenge returs a base64 encoded string
with challangeLength bytes of random data
Types ¶
type ClientPayload ¶
type ClientPayload struct {
ClientID, ServerID refs.FeedRef
ClientChallenge string
ServerChallenge string
}
ClientPayload is used to create and verify solutions
func (ClientPayload) Sign ¶
func (cr ClientPayload) Sign(privateKey ed25519.PrivateKey) []byte
Sign returns the signature created with the passed privateKey
func (ClientPayload) Validate ¶
func (cr ClientPayload) Validate(signature []byte) bool
Validate checks the signature by calling createMessage() and ed25519.Verify() together with the ClientID public key.
type Event ¶
type Event struct { Worked bool // the token value if it did work Token string // reason why it didn't work Reason error }
Event is the unit of information that is sent over the bridge.
type SignalBridge ¶
type SignalBridge struct {
// contains filtered or unexported fields
}
SignalBridge implements a way for muxrpc and http handlers to communicate about SIWSSB events
func NewSignalBridge ¶
func NewSignalBridge() *SignalBridge
NewSignalBridge returns a new SignalBridge
func (*SignalBridge) GetEventChannel ¶
func (sb *SignalBridge) GetEventChannel(sc string) (<-chan Event, bool)
GetEventChannel returns the channel for the passed challenge from which future events can be read. If sc doesn't exist, the 2nd argument is false.
func (*SignalBridge) RegisterSession ¶
func (sb *SignalBridge) RegisterSession() string
RegisterSession registers a new session on the bridge. It returns a fresh server challenge, which acts as the session key.
func (*SignalBridge) SessionFailed ¶
func (sb *SignalBridge) SessionFailed(sc string, reason error) error
SessionFailed uses the passed challenge to send on and close the open channel. It will return an error if the session doesn't exist.
func (*SignalBridge) SessionWorked ¶
func (sb *SignalBridge) SessionWorked(sc string, token string) error
SessionWorked uses the passed challenge to send on and close the open channel. It will return an error if the session doesn't exist.