server

package
v0.106.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2022 License: MPL-2.0 Imports: 35 Imported by: 0

Documentation

Index

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 GenerateX509Cert(sn *big.Int, from, to time.Time, hostname string) *x509.Certificate

func GenerateX509PEMs added in v0.97.4

func GenerateX509PEMs(cert *x509.Certificate, key *ecdsa.PrivateKey) (certPem, keyPem []byte, err error)

func GetOutboundIP added in v0.102.2

func GetOutboundIP() (net.IP, error)

func PublicTLSCert

func PublicTLSCert() (string, error)

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.PrivateKey
	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 NewConnectionParams(netIP net.IP, port int, privateKey *ecdsa.PrivateKey, notBefore time.Time, mode Mode) *ConnectionParams

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) Generate added in v0.102.2

func (cp *ConnectionParams) Generate() (*url.URL, []byte, error)

Generate returns a *url.URL and encoded pem.Block generated from ConnectionParams set fields

func (*ConnectionParams) ToString added in v0.102.2

func (cp *ConnectionParams) ToString() (string, error)

ToString generates a string required for generating a secure connection to another Status device.

The returned string will look like below:

  • "2:4FHRnp:H6G:6jpbvo2ucrtrnpXXF4DQYuysh697isH9ppd2aT8uSRDh:eQUriVtGtkWhPJFeLZjF:2"

Format bytes encoded into a base58 string, delimited by ":"

  • version
  • net.IP
  • port
  • ecdsa.PrivateKey D field
  • asn1.Marshal time.Time
  • 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 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) (*MediaServer, error)

NewMediaServer returns a *MediaServer

func (*MediaServer) MakeAudioURL added in v0.102.2

func (s *MediaServer) MakeAudioURL(id 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

type Mode added in v0.102.2

type Mode int
const (
	Receiving Mode = iota + 1
	Sending
)

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 {
	// contains filtered or unexported fields
}

PairingPayloadManager is responsible for the whole lifecycle of a PairingPayload

func NewPairingPayloadManager added in v0.106.1

func NewPairingPayloadManager(pk *ecdsa.PrivateKey, config *PairingPayloadManagerConfig) (*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) Received added in v0.106.1

func (ppm *PairingPayloadManager) Received() []byte

Received returns the decrypted input of Receive

func (*PairingPayloadManager) ResetPayload added in v0.106.1

func (ppm *PairingPayloadManager) ResetPayload()

ResetPayload resets all payload state managed by the PairingPayloadManager

func (*PairingPayloadManager) ToSend added in v0.106.1

func (ppm *PairingPayloadManager) ToSend() []byte

ToSend returns the result of Mount

type PairingPayloadManagerConfig added in v0.106.1

type PairingPayloadManagerConfig struct {
	DB           *multiaccounts.Database
	KeystorePath string
	KeyUID       string
	Password     string
}

PairingPayloadManagerConfig represents the initialisation parameters required for a PairingPayloadManager

type PairingPayloadMarshaller added in v0.106.1

type PairingPayloadMarshaller struct {
	*PairingPayload
}

PairingPayloadMarshaller is responsible for marshalling and unmarshalling PairingServer payload data

func NewPairingPayloadMarshaller added in v0.106.1

func NewPairingPayloadMarshaller(p *PairingPayload) *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 PairingServer added in v0.102.2

type PairingServer struct {
	Server
	PayloadManager
	// contains filtered or unexported fields
}

func NewPairingServer added in v0.102.2

func NewPairingServer(config *Config) (*PairingServer, error)

NewPairingServer returns a *PairingServer init from the given *Config

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) 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(pk *ecdsa.PrivateKey) (*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) 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() error
	Receive(data []byte) error
	ToSend() []byte
	Received() []byte
	ResetPayload()
}

PayloadManager is the interface for PayloadManagers and wraps the basic functions for fulfilling payload management

type PayloadRepository added in v0.106.1

type PayloadRepository interface {
	LoadFromSource() error
	StoreToSource() error
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cert *tls.Certificate, hostname string) Server

func (*Server) MakeBaseURL added in v0.102.2

func (s *Server) MakeBaseURL() *url.URL

func (*Server) SetHandlers added in v0.102.2

func (s *Server) SetHandlers(handlers HandlerPatternMap)

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop() error

func (*Server) ToBackground

func (s *Server) ToBackground()

func (*Server) ToForeground

func (s *Server) ToForeground()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL