Documentation
¶
Index ¶
- Constants
- func CheckError(err error)
- func GeneratePrivateKey() (*rsa.PrivateKey, error)
- func GetOnionAddress(privateKey *rsa.PrivateKey) (string, error)
- func GetRandNumber() *big.Int
- func GetTorHostname(publicKeyBytes []byte) string
- func LoadPrivateKeyFromFile(filename string) (*rsa.PrivateKey, error)
- func ParsePrivateKey(pemData []byte) (*rsa.PrivateKey, error)
- func PrivateKeyToString(privateKey *rsa.PrivateKey) string
- type Error
- type MessageBuilder
- func (mb *MessageBuilder) AckChatMessage(messageID uint32, accepted bool) []byte
- func (mb *MessageBuilder) AckOpenChannel(channelID int32) []byte
- func (mb *MessageBuilder) AuthResult(accepted bool, isKnownContact bool) []byte
- func (mb *MessageBuilder) ChatMessage(message string, messageID uint32, timeDelta int64) []byte
- func (mb *MessageBuilder) ConfirmAuthChannel(channelID int32, serverCookie [16]byte) []byte
- func (mb *MessageBuilder) EnableFeatures(features []string) []byte
- func (mb *MessageBuilder) FeaturesEnabled(features []string) []byte
- func (mb *MessageBuilder) KeepAlive(responseRequested bool) []byte
- func (mb *MessageBuilder) OpenAuthenticationChannel(channelID int32, clientCookie [16]byte) []byte
- func (mb *MessageBuilder) OpenChannel(channelID int32, channelType string) []byte
- func (mb *MessageBuilder) OpenContactRequestChannel(channelID int32, nick string, message string) []byte
- func (mb *MessageBuilder) Proof(publicKeyBytes []byte, signatureBytes []byte) []byte
- func (mb *MessageBuilder) RejectOpenChannel(channelID int32, error string) []byte
- func (mb *MessageBuilder) ReplyToContactRequest(channelID int32, status string) []byte
- func (mb *MessageBuilder) ReplyToContactRequestOnResponse(channelID int32, status string) []byte
- type NetworkResolver
- type RicochetData
- type RicochetNetwork
- type RicochetNetworkInterface
Constants ¶
const ( // InvalidPrivateKeyFileError is a library error, thrown when the given key file fials to load InvalidPrivateKeyFileError = Error("InvalidPrivateKeyFileError") // RicochetKeySize - tor onion services currently use rsa key sizes of 1024 bits RicochetKeySize = 1024 )
const ( VersionNegotiationError = Error("VersionNegotiationError") VersionNegotiationFailed = Error("VersionNegotiationFailed") RicochetConnectionClosed = Error("RicochetConnectionClosed") RicochetProtocolError = Error("RicochetProtocolError") UnknownChannelTypeError = Error("UnknownChannelTypeError") UnexpectedChannelResultError = Error("UnexpectedChannelResultError") // Timeout Errors ActionTimedOutError = Error("ActionTimedOutError") PeerTimedOutError = Error("PeerTimedOutError") // Authentication Errors ClientFailedToAuthenticateError = Error("ClientFailedToAuthenticateError") ServerRejectedClientConnectionError = Error("ServerRejectedClientConnectionError") ChannelClosedByPeerError = Error("ChannelClosedByPeerError") // Channel Management Errors ServerAttemptedToOpenEvenNumberedChannelError = Error("ServerAttemptedToOpenEvenNumberedChannelError") ClientAttemptedToOpenOddNumberedChannelError = Error("ClientAttemptedToOpenOddNumberedChannelError") ChannelIDIsAlreadyInUseError = Error("ChannelIDIsAlreadyInUseError") AttemptToOpenMoreThanOneSingletonChannelError = Error("AttemptToOpenMoreThanOneSingletonChannelError") // Library Use Errors OnionAddressGenerationError = Error("OnionAddressGenerationError") PrivateKeyNotSetError = Error("PrivateKeyNotSet") // Connection Errors ConnectionClosedError = Error("ConnectionClosedError") )
Defining Versions
const ( // InvalidPacketLengthError is returned whenever ricochet receives a packet too small or too large to conform to the spec. InvalidPacketLengthError = Error("InvalidPacketLengthError") // InvalidChannelIDError channels must be between 0 and 65535 InvalidChannelIDError = Error("InvalidChannelIDError") )
const ( // CannotResolveLocalTCPAddressError is thrown when a local ricochet connection has the wrong format. CannotResolveLocalTCPAddressError = Error("CannotResolveLocalTCPAddressError") // CannotDialLocalTCPAddressError is thrown when a connection to a local ricochet address fails. CannotDialLocalTCPAddressError = Error("CannotDialLocalTCPAddressError") // CannotDialRicochetAddressError is thrown when a connection to a ricochet address fails. CannotDialRicochetAddressError = Error("CannotDialRicochetAddressError") )
Variables ¶
This section is empty.
Functions ¶
func CheckError ¶
func CheckError(err error)
CheckError is a helper function for panicing on errors which we need to handle but should be very rare e.g. failures deserializing a protobuf object that should only happen if there was a bug in the underlying library.
func GeneratePrivateKey ¶
func GeneratePrivateKey() (*rsa.PrivateKey, error)
GeneratePrivateKey generates a new private key for use
func GetOnionAddress ¶
func GetOnionAddress(privateKey *rsa.PrivateKey) (string, error)
return an onion address from a private key
func GetRandNumber ¶
GetRandNumber is a helper function which returns a random integer, this is currently mostly used to generate messageids
func GetTorHostname ¶
GetTorHostname takes a []byte contained a DER-encoded RSA public key and returns the first 16 bytes of the base32 encoded sha1 hash of the key. This is the onion hostname of the tor service represented by the public key.
func LoadPrivateKeyFromFile ¶
func LoadPrivateKeyFromFile(filename string) (*rsa.PrivateKey, error)
LoadPrivateKeyFromFile loads a private key from a file...
func ParsePrivateKey ¶
func ParsePrivateKey(pemData []byte) (*rsa.PrivateKey, error)
ParsePrivateKey Convert a private key string to a usable private key
func PrivateKeyToString ¶
func PrivateKeyToString(privateKey *rsa.PrivateKey) string
PrivateKeyToString turns a private key into storable string
Types ¶
type MessageBuilder ¶
type MessageBuilder struct {
}
MessageBuilder allows a client to construct specific data packets for the ricochet protocol.
func (*MessageBuilder) AckChatMessage ¶
func (mb *MessageBuilder) AckChatMessage(messageID uint32, accepted bool) []byte
AckChatMessage constructs a chat message acknowledgement.
func (*MessageBuilder) AckOpenChannel ¶
func (mb *MessageBuilder) AckOpenChannel(channelID int32) []byte
AckOpenChannel constructs a message to acknowledge a previous open channel operation.
func (*MessageBuilder) AuthResult ¶
func (mb *MessageBuilder) AuthResult(accepted bool, isKnownContact bool) []byte
AuthResult constructs a response to a Proof
func (*MessageBuilder) ChatMessage ¶
func (mb *MessageBuilder) ChatMessage(message string, messageID uint32, timeDelta int64) []byte
ChatMessage constructs a chat message with the given content.
func (*MessageBuilder) ConfirmAuthChannel ¶
func (mb *MessageBuilder) ConfirmAuthChannel(channelID int32, serverCookie [16]byte) []byte
ConfirmAuthChannel constructs a message to acknowledge a previous open channel operation.
func (*MessageBuilder) EnableFeatures ¶
func (mb *MessageBuilder) EnableFeatures(features []string) []byte
EnableFeatures ...
func (*MessageBuilder) FeaturesEnabled ¶
func (mb *MessageBuilder) FeaturesEnabled(features []string) []byte
FeaturesEnabled ...
func (*MessageBuilder) KeepAlive ¶
func (mb *MessageBuilder) KeepAlive(responseRequested bool) []byte
KeepAlive ...
func (*MessageBuilder) OpenAuthenticationChannel ¶
func (mb *MessageBuilder) OpenAuthenticationChannel(channelID int32, clientCookie [16]byte) []byte
OpenAuthenticationChannel constructs a message which will reuqest to open a channel for authentication on the given channelID, with the given cookie
func (*MessageBuilder) OpenChannel ¶
func (mb *MessageBuilder) OpenChannel(channelID int32, channelType string) []byte
OpenChannel contructs a message which will request to open a channel for chat on the given channelID.
func (*MessageBuilder) OpenContactRequestChannel ¶
func (mb *MessageBuilder) OpenContactRequestChannel(channelID int32, nick string, message string) []byte
OpenContactRequestChannel contructs a message which will reuqest to open a channel for a contact request on the given channelID, with the given nick and message.
func (*MessageBuilder) Proof ¶
func (mb *MessageBuilder) Proof(publicKeyBytes []byte, signatureBytes []byte) []byte
Proof constructs a proof message with the given public key and signature.
func (*MessageBuilder) RejectOpenChannel ¶
func (mb *MessageBuilder) RejectOpenChannel(channelID int32, error string) []byte
RejectOpenChannel constructs a channel result message, stating the channel failed to open and a reason
func (*MessageBuilder) ReplyToContactRequest ¶
func (mb *MessageBuilder) ReplyToContactRequest(channelID int32, status string) []byte
ReplyToContactRequest constructs a message to acknowledge a contact request
func (*MessageBuilder) ReplyToContactRequestOnResponse ¶
func (mb *MessageBuilder) ReplyToContactRequestOnResponse(channelID int32, status string) []byte
ReplyToContactRequestOnResponse constructs a message to acknowledge contact request
type NetworkResolver ¶
type NetworkResolver struct {
SOCKSProxy string
}
NetworkResolver allows a client to resolve various hostnames to connections The supported types are onions address are:
- ricochet:jlq67qzo6s4yp3sp
- jlq67qzo6s4yp3sp
type RicochetData ¶
RicochetData is a structure containing the raw data and the channel it the message originated on.
func (RicochetData) Equals ¶
func (rd RicochetData) Equals(other RicochetData) bool
Equals compares a RicochetData object to another and returns true if contain the same data.
type RicochetNetwork ¶
type RicochetNetwork struct {
}
RicochetNetwork is a concrete implementation of the RicochetNetworkInterface
func (*RicochetNetwork) RecvRicochetPacket ¶
func (rn *RicochetNetwork) RecvRicochetPacket(reader io.Reader) (RicochetData, error)
RecvRicochetPacket returns the next packet from reader as a RicochetData structure, or an error.
func (*RicochetNetwork) SendRicochetPacket ¶
SendRicochetPacket places the data into a structure needed for the client to decode the packet and writes the packet to the network.