common

package
v0.0.0-...-a096643 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64ToHex

func Base64ToHex(identity string) (string, error)

Base64ToHex decodes a base 64 string and returns its uppercase hex encoding

func CalculateDescriptorID

func CalculateDescriptorID(permanentID []byte, time int64, replica byte, deviation uint8,
	descriptorCookie string) ([]byte, error)

CalculateDescriptorID computes the v2 descriptor ID

func CalculateOnionAddress

func CalculateOnionAddress(permanentID []byte) string

CalculateOnionAddress returns the v2 onion address given the permanentID

func CalculatePermanentID

func CalculatePermanentID(permanentKey rsa.PublicKey) ([]byte, error)

CalculatePermanentID returns permanentID given the permanentKey(public key)

func DescriptorIDValidUntil

func DescriptorIDValidUntil(permanentID []byte, time int64) int64

DescriptorIDValidUntil calculates seconds until the descriptor ID changes

func GetSecretID

func GetSecretID(serviceID []byte, time int64, descriptorCookie string, replica byte) []byte

GetSecretID returns the secretID which is used to calculate the descriptor ID SecretIDPart = H(time-period | descriptor-cookie | replica)

func LoadKeysFromFile

func LoadKeysFromFile(filePath string) (*rsa.PublicKey, *rsa.PrivateKey, error)

LoadKeysFromFile returns an rsa public/private key pair given pem encoded private key

func NewLogger

func NewLogger(debugMode bool, logFilePath string) (*zap.SugaredLogger, error)

NewLogger returns a new logger

func NewNopLogger

func NewNopLogger() *zap.SugaredLogger

NewNopLogger returns a new nop logger

Types

type ITimeProvider

type ITimeProvider interface {
	Now() time.Time
}

func NewTimeProvider

func NewTimeProvider() ITimeProvider

type MockTimeProvider

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

func (*MockTimeProvider) Now

func (m *MockTimeProvider) Now() time.Time

func (*MockTimeProvider) Set

func (m *MockTimeProvider) Set(theTime time.Time)

type TimeProvider

type TimeProvider struct{}

func (*TimeProvider) Now

func (t *TimeProvider) Now() time.Time

Jump to

Keyboard shortcuts

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