Documentation ¶
Index ¶
- func GenerateCertFromKey(pk *ecdsa.PrivateKey, from time.Time, hostname string) (tls.Certificate, []byte, error)
- func GenerateX509Cert(sn *big.Int, from, to time.Time, hostname string) *x509.Certificate
- func GenerateX509PEMs(cert *x509.Certificate, key *ecdsa.PrivateKey) (certPem, keyPem []byte, err error)
- func GetDeviceName() (string, error)
- func GetOutboundIP() (net.IP, error)
- func PublicTLSCert() (string, error)
- func RemoveSuffix(input, suffix string) string
- func StartUpPairingClient(db *multiaccounts.Database, cs, configJSON string) error
- func StartUpPairingServer(db *multiaccounts.Database, mode Mode, configJSON string) (string, error)
- func ToECDSA(d []byte) *ecdsa.PrivateKey
- type Config
- type ConnectionParamVersion
- type ConnectionParams
- type EncryptionPayload
- type Event
- type EventType
- type HandlerPatternMap
- type MediaServer
- func (p *MediaServer) GetPort() int
- func (s *MediaServer) MakeAudioURL(id string) string
- func (s *MediaServer) MakeDiscordAttachmentURL(messageID string, id string) string
- func (s *MediaServer) MakeDiscordAuthorAvatarURL(authorID string) string
- func (s *MediaServer) MakeIdenticonURL(from string) string
- func (s *MediaServer) MakeImageServerURL() string
- func (s *MediaServer) MakeImageURL(id string) string
- func (s *MediaServer) MakeStickerURL(stickerHash string) string
- func (p *MediaServer) MustGetPort() int
- func (p *MediaServer) ResetPort()
- func (p *MediaServer) SetPort(port int) error
- type Mode
- type PairingClient
- type PairingPayload
- type PairingPayloadManager
- type PairingPayloadManagerConfig
- type PairingPayloadMarshaller
- type PairingPayloadRepository
- type PairingPayloadSourceConfig
- type PairingServer
- type PayloadEncryptionManager
- func (pem *PayloadEncryptionManager) Decrypt(data []byte) error
- func (pem *PayloadEncryptionManager) Encrypt(data []byte) error
- func (pem *PayloadEncryptionManager) EncryptPlain(plaintext []byte) ([]byte, error)
- func (pem *PayloadEncryptionManager) LockPayload()
- func (pem *PayloadEncryptionManager) Received() []byte
- func (pem *PayloadEncryptionManager) ResetPayload()
- func (pem *PayloadEncryptionManager) ToSend() []byte
- type PayloadManager
- type PayloadRepository
- type Server
- func (s *Server) AddHandlers(handlers HandlerPatternMap)
- func (p *Server) GetPort() int
- func (s *Server) MakeBaseURL() *url.URL
- func (p *Server) MustGetPort() int
- func (p *Server) ResetPort()
- func (s *Server) SetHandlers(handlers HandlerPatternMap)
- func (p *Server) SetPort(port int) error
- func (s *Server) Start() error
- func (s *Server) Stop() error
- func (s *Server) ToBackground()
- func (s *Server) ToForeground()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateCertFromKey ¶ added in v0.102.2
func GenerateCertFromKey(pk *ecdsa.PrivateKey, from time.Time, hostname string) (tls.Certificate, []byte, error)
func GenerateX509Cert ¶ added in v0.97.4
func GenerateX509PEMs ¶ added in v0.97.4
func GenerateX509PEMs(cert *x509.Certificate, key *ecdsa.PrivateKey) (certPem, keyPem []byte, err error)
func GetDeviceName ¶ added in v0.115.4
func GetOutboundIP ¶ added in v0.102.2
func PublicTLSCert ¶
func RemoveSuffix ¶ added in v0.115.4
func StartUpPairingClient ¶ added in v0.109.1
func StartUpPairingClient(db *multiaccounts.Database, cs, configJSON string) error
func StartUpPairingServer ¶ added in v0.109.1
StartUpPairingServer generates a PairingServer, starts the pairing server in the correct mode and returns the ConnectionParams string to allow a PairingClient to make a successful connection.
func ToECDSA ¶ added in v0.102.2
func ToECDSA(d []byte) *ecdsa.PrivateKey
ToECDSA takes a []byte of D and uses it to create an ecdsa.PublicKey on the elliptic.P256 curve this function is basically a P256 curve version of eth-node/crypto.ToECDSA without all the nice validation
Types ¶
type Config ¶ added in v0.102.2
type Config struct { // Connection fields PK *ecdsa.PublicKey EK []byte Cert *tls.Certificate Hostname string Mode Mode // Payload management fields *PairingPayloadManagerConfig }
type ConnectionParamVersion ¶ added in v0.102.2
type ConnectionParamVersion int
const (
Version1 ConnectionParamVersion = iota + 1
)
type ConnectionParams ¶ added in v0.102.2
type ConnectionParams struct {
// contains filtered or unexported fields
}
func NewConnectionParams ¶ added in v0.102.2
func (*ConnectionParams) FromString ¶ added in v0.102.2
func (cp *ConnectionParams) FromString(s string) error
FromString parses a connection params string required for to securely connect to another Status device. This function parses a connection string generated by ToString
func (*ConnectionParams) ToString ¶ added in v0.102.2
func (cp *ConnectionParams) ToString() string
ToString generates a string required for generating a secure connection to another Status device.
The returned string will look like below:
- "cs2:4FHRnp:H6G:uqnnMwVUfJc2Fkcaojet8F1ufKC3hZdGEt47joyBx9yd:BbnZ7Gc66t54a9kEFCf7FW8SGQuYypwHVeNkRYeNoqV6:2"
Format bytes encoded into a base58 string, delimited by ":"
- string type identifier
- version
- net.IP
- port
- ecdsa CompressedPublicKey
- AES encryption key
- server mode
type EncryptionPayload ¶ added in v0.106.1
type EncryptionPayload struct {
// contains filtered or unexported fields
}
EncryptionPayload represents the plain text and encrypted text of payload data
type EventType ¶ added in v0.109.1
type EventType string
EventType type for event types.
const ( EventConnectionError EventType = "connection-error" EventConnectionSuccess EventType = "connection-success" EventTransferError EventType = "transfer-error" EventTransferSuccess EventType = "transfer-success" EventProcessSuccess EventType = "process-success" EventProcessError EventType = "process-error" )
type HandlerPatternMap ¶ added in v0.102.2
type HandlerPatternMap map[string]http.HandlerFunc
type MediaServer ¶ added in v0.102.2
type MediaServer struct { Server // contains filtered or unexported fields }
func NewMediaServer ¶ added in v0.102.2
func NewMediaServer(db *sql.DB, downloader *ipfs.Downloader, multiaccountsDB *multiaccounts.Database) (*MediaServer, error)
NewMediaServer returns a *MediaServer
func (*MediaServer) GetPort ¶ added in v0.113.0
func (p *MediaServer) GetPort() int
GetPort gets the current value of portManager.port without any concern for the state of its value and therefore does not wait if portManager.port is 0
func (*MediaServer) MakeAudioURL ¶ added in v0.102.2
func (s *MediaServer) MakeAudioURL(id string) string
func (*MediaServer) MakeDiscordAttachmentURL ¶ added in v0.111.5
func (s *MediaServer) MakeDiscordAttachmentURL(messageID string, id string) string
func (*MediaServer) MakeDiscordAuthorAvatarURL ¶ added in v0.111.5
func (s *MediaServer) MakeDiscordAuthorAvatarURL(authorID string) string
func (*MediaServer) MakeIdenticonURL ¶ added in v0.102.2
func (s *MediaServer) MakeIdenticonURL(from string) string
func (*MediaServer) MakeImageServerURL ¶ added in v0.102.2
func (s *MediaServer) MakeImageServerURL() string
func (*MediaServer) MakeImageURL ¶ added in v0.102.2
func (s *MediaServer) MakeImageURL(id string) string
func (*MediaServer) MakeStickerURL ¶ added in v0.102.2
func (s *MediaServer) MakeStickerURL(stickerHash string) string
func (*MediaServer) MustGetPort ¶ added in v0.113.0
func (p *MediaServer) MustGetPort() int
MustGetPort only returns portManager.port if portManager.port is not 0.
type PairingClient ¶ added in v0.102.5
type PairingClient struct { *http.Client PayloadManager // contains filtered or unexported fields }
func NewPairingClient ¶ added in v0.102.5
func NewPairingClient(c *ConnectionParams, config *PairingPayloadManagerConfig) (*PairingClient, error)
func (*PairingClient) PairAccount ¶ added in v0.102.5
func (c *PairingClient) PairAccount() error
type PairingPayload ¶ added in v0.106.1
type PairingPayload struct {
// contains filtered or unexported fields
}
PairingPayload represents the payload structure a PairingServer handles
func (*PairingPayload) ResetPayload ¶ added in v0.106.1
func (pp *PairingPayload) ResetPayload()
type PairingPayloadManager ¶ added in v0.106.1
type PairingPayloadManager struct { *PayloadEncryptionManager // contains filtered or unexported fields }
PairingPayloadManager is responsible for the whole lifecycle of a PairingPayload
func NewPairingPayloadManager ¶ added in v0.106.1
func NewPairingPayloadManager(aesKey []byte, config *PairingPayloadManagerConfig, logger *zap.Logger) (*PairingPayloadManager, error)
NewPairingPayloadManager generates a new and initialised PairingPayloadManager
func (*PairingPayloadManager) Mount ¶ added in v0.106.1
func (ppm *PairingPayloadManager) Mount() error
Mount loads and prepares the payload to be stored in the PairingPayloadManager's state ready for later access
func (*PairingPayloadManager) Receive ¶ added in v0.106.1
func (ppm *PairingPayloadManager) Receive(data []byte) error
Receive takes a []byte representing raw data, parses and stores the data
func (*PairingPayloadManager) ResetPayload ¶ added in v0.106.1
func (ppm *PairingPayloadManager) ResetPayload()
ResetPayload resets all payload state managed by the PairingPayloadManager
type PairingPayloadManagerConfig ¶ added in v0.106.1
type PairingPayloadManagerConfig struct { DB *multiaccounts.Database PairingPayloadSourceConfig }
PairingPayloadManagerConfig represents the initialisation parameters required for a PairingPayloadManager
type PairingPayloadMarshaller ¶ added in v0.106.1
type PairingPayloadMarshaller struct { *PairingPayload // contains filtered or unexported fields }
PairingPayloadMarshaller is responsible for marshalling and unmarshalling PairingServer payload data
func NewPairingPayloadMarshaller ¶ added in v0.106.1
func NewPairingPayloadMarshaller(p *PairingPayload, logger *zap.Logger) *PairingPayloadMarshaller
func (*PairingPayloadMarshaller) MarshalToProtobuf ¶ added in v0.106.1
func (ppm *PairingPayloadMarshaller) MarshalToProtobuf() ([]byte, error)
func (*PairingPayloadMarshaller) UnmarshalProtobuf ¶ added in v0.106.1
func (ppm *PairingPayloadMarshaller) UnmarshalProtobuf(data []byte) error
type PairingPayloadRepository ¶ added in v0.106.1
type PairingPayloadRepository struct { *PairingPayload // contains filtered or unexported fields }
PairingPayloadRepository is responsible for loading, parsing, validating and storing PairingServer payload data
func NewPairingPayloadRepository ¶ added in v0.106.1
func NewPairingPayloadRepository(p *PairingPayload, config *PairingPayloadManagerConfig) *PairingPayloadRepository
func (*PairingPayloadRepository) LoadFromSource ¶ added in v0.106.1
func (ppr *PairingPayloadRepository) LoadFromSource() error
func (*PairingPayloadRepository) StoreToSource ¶ added in v0.106.1
func (ppr *PairingPayloadRepository) StoreToSource() error
type PairingPayloadSourceConfig ¶ added in v0.109.1
type PairingPayloadSourceConfig struct { KeystorePath string `json:"keystorePath"` KeyUID string `json:"keyUID"` Password string `json:"password"` }
PairingPayloadSourceConfig represents location and access data of the pairing payload ONLY available from the application client
type PairingServer ¶ added in v0.102.2
type PairingServer struct { Server PayloadManager // contains filtered or unexported fields }
func MakeFullPairingServer ¶ added in v0.109.1
func MakeFullPairingServer(db *multiaccounts.Database, mode Mode, storeConfig PairingPayloadSourceConfig) (*PairingServer, error)
MakeFullPairingServer generates a fully configured and randomly seeded PairingServer
func NewPairingServer ¶ added in v0.102.2
func NewPairingServer(config *Config) (*PairingServer, error)
NewPairingServer returns a *PairingServer init from the given *Config
func (*PairingServer) GetPort ¶ added in v0.113.0
func (p *PairingServer) GetPort() int
GetPort gets the current value of portManager.port without any concern for the state of its value and therefore does not wait if portManager.port is 0
func (*PairingServer) MakeConnectionParams ¶ added in v0.102.2
func (s *PairingServer) MakeConnectionParams() (*ConnectionParams, error)
MakeConnectionParams generates a *ConnectionParams based on the Server's current state
func (*PairingServer) MustGetPort ¶ added in v0.113.0
func (p *PairingServer) MustGetPort() int
MustGetPort only returns portManager.port if portManager.port is not 0.
func (*PairingServer) ResetPort ¶ added in v0.113.0
func (p *PairingServer) ResetPort()
ResetPort resets portManger.port to 0
func (*PairingServer) SetPort ¶ added in v0.113.0
SetPort sets portManger.port field to the given port value next triggers any given portManger.afterPortChanged function
func (*PairingServer) StartPairing ¶ added in v0.102.5
func (s *PairingServer) StartPairing() error
type PayloadEncryptionManager ¶ added in v0.106.1
type PayloadEncryptionManager struct {
// contains filtered or unexported fields
}
PayloadEncryptionManager is responsible for encrypting and decrypting payload data
func NewPayloadEncryptionManager ¶ added in v0.106.1
func NewPayloadEncryptionManager(aesKey []byte, logger *zap.Logger) (*PayloadEncryptionManager, error)
func (*PayloadEncryptionManager) Decrypt ¶ added in v0.106.1
func (pem *PayloadEncryptionManager) Decrypt(data []byte) error
func (*PayloadEncryptionManager) Encrypt ¶ added in v0.106.1
func (pem *PayloadEncryptionManager) Encrypt(data []byte) error
func (*PayloadEncryptionManager) EncryptPlain ¶ added in v0.106.3
func (pem *PayloadEncryptionManager) EncryptPlain(plaintext []byte) ([]byte, error)
EncryptPlain encrypts any given plain text using the internal AES key and returns the encrypted value This function is different to Encrypt as the internal EncryptionPayload.encrypted value is not set
func (*PayloadEncryptionManager) LockPayload ¶ added in v0.114.3
func (pem *PayloadEncryptionManager) LockPayload()
func (*PayloadEncryptionManager) Received ¶ added in v0.106.1
func (pem *PayloadEncryptionManager) Received() []byte
func (*PayloadEncryptionManager) ResetPayload ¶ added in v0.106.1
func (pem *PayloadEncryptionManager) ResetPayload()
func (*PayloadEncryptionManager) ToSend ¶ added in v0.106.1
func (pem *PayloadEncryptionManager) ToSend() []byte
type PayloadManager ¶ added in v0.102.5
type PayloadManager interface { // Mount Loads the payload into the PayloadManager's state Mount() error // Receive stores data from an inbound source into the PayloadManager's state Receive(data []byte) error // ToSend returns an outbound safe (encrypted) payload ToSend() []byte // Received returns a decrypted and parsed payload from an inbound source Received() []byte // ResetPayload resets all payloads the PayloadManager has in its state ResetPayload() // EncryptPlain encrypts the given plaintext using internal key(s) EncryptPlain(plaintext []byte) ([]byte, error) // LockPayload prevents future excess to outbound safe and received data LockPayload() }
PayloadManager is the interface for PayloadManagers and wraps the basic functions for fulfilling payload management
type PayloadRepository ¶ added in v0.106.1
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) AddHandlers ¶ added in v0.106.3
func (s *Server) AddHandlers(handlers HandlerPatternMap)
func (*Server) GetPort ¶ added in v0.113.0
func (p *Server) GetPort() int
GetPort gets the current value of portManager.port without any concern for the state of its value and therefore does not wait if portManager.port is 0
func (*Server) MakeBaseURL ¶ added in v0.102.2
func (*Server) MustGetPort ¶ added in v0.113.0
func (p *Server) MustGetPort() int
MustGetPort only returns portManager.port if portManager.port is not 0.
func (*Server) ResetPort ¶ added in v0.113.0
func (p *Server) ResetPort()
ResetPort resets portManger.port to 0
func (*Server) SetHandlers ¶ added in v0.102.2
func (s *Server) SetHandlers(handlers HandlerPatternMap)
func (*Server) SetPort ¶ added in v0.113.0
SetPort sets portManger.port field to the given port value next triggers any given portManger.afterPortChanged function
func (*Server) ToBackground ¶
func (s *Server) ToBackground()
func (*Server) ToForeground ¶
func (s *Server) ToForeground()