util

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2017 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CmpPrice added in v0.3.0

func CmpPrice(x, y string) (int, error)

CmpPrice transforms the given prices in string format and compares them, returning:

	-1 if x <  y
  0 if x == y
 +1 if x >  y

func DirectoryExists added in v0.3.0

func DirectoryExists(p string) bool

DirectoryExists returns true if the given directory exists

func EqualAddresses added in v0.3.0

func EqualAddresses(a, b common.Address) bool

EqualAddresses checks if provided Addresses are equal

func ExtractMethod added in v0.3.0

func ExtractMethod(fullMethod string) string

func ForwardMetadata added in v0.3.0

func ForwardMetadata(ctx context.Context) context.Context

ForwardMetadata is a helper function for gRPC proxy that chains incoming request with some outgoing request. It simply forwards incoming context metadata without changes by toggling internal outgoing key.

func GenerateCert added in v0.3.0

func GenerateCert(ethpriv *ecdsa.PrivateKey, validPeriod time.Duration) (cert []byte, key []byte, err error)

GenerateCert generates new PEM encoded x509cert and privatekey key. Generated certificate contains signature of a publick key by eth key

func GetAvailableIPs added in v0.3.0

func GetAvailableIPs() (availableIPs []net.IP, err error)

func GetLocalIP

func GetLocalIP() string

GetLocalIP find local non-loopback ip addr

func GetPlatformName added in v0.3.0

func GetPlatformName() string

func GetUserHomeDir added in v0.3.0

func GetUserHomeDir() (homeDir string, err error)

func LoadYamlFile added in v0.3.0

func LoadYamlFile(from string, to interface{}) error

func MakeGrpcClient added in v0.3.0

func MakeGrpcClient(ctx context.Context, addr string, creds credentials.TransportCredentials, opts ...grpc.DialOption) (*grpc.ClientConn, error)

MakeGrpcClient creates new gRPC client connection on given addr and wraps it with given credentials

func MakeGrpcServer added in v0.3.0

func MakeGrpcServer(creds credentials.TransportCredentials, extraopts ...grpc.ServerOption) *grpc.Server

MakeGrpcServer creates new gRPC server

func MakeWalletAuthenticatedClient added in v0.3.0

func MakeWalletAuthenticatedClient(ctx context.Context, creds credentials.TransportCredentials, endpoint string,
	opts ...grpc.DialOption) (*grpc.ClientConn, error)

func NewTLS added in v0.3.0

NewTLS wraps TLS TransportCredentials from grpc to add custom logic

func NewWalletAccess added in v0.3.0

func NewWalletAccess(wallet *SelfSignedWallet) credentials.PerRPCCredentials

NewWalletAccess constructs the new PerRPCCredentials using with given self-signed wallet.

func NewWalletAuthenticator added in v0.3.0

func ParseBigInt added in v0.3.0

func ParseBigInt(s string) (*big.Int, error)

ParseBigInt parses the given string and converts it to *big.Int

func ParseEndpoint added in v0.3.0

func ParseEndpoint(endpoint string) (string, ethcommon.Address, error)

func ParseEndpointPort added in v0.3.0

func ParseEndpointPort(s string) (string, error)

func PubKeyToAddr added in v0.3.0

func PubKeyToAddr(key ecdsa.PublicKey) common.Address

func PubKeyToString added in v0.3.0

func PubKeyToString(key ecdsa.PublicKey) string

func VerifyEqualPrice added in v0.3.0

func VerifyEqualPrice(x, y string) error

func VerifySelfSignedWallet added in v0.3.0

func VerifySelfSignedWallet(signedWallet string) (string, error)

Types

type EthAuthInfo added in v0.3.0

type EthAuthInfo struct {
	TLS    credentials.TLSInfo
	Wallet ethcommon.Address
}

EthAuthInfo implements credentials.AuthInfo It provides access to a wallet of a connected user

func (EthAuthInfo) AuthType added in v0.3.0

func (e EthAuthInfo) AuthType() string

AuthType implements credentials.AuthInfo interface

type HitlessCertRotator added in v0.3.0

type HitlessCertRotator interface {
	GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error)
	GetClientCertificate(*tls.CertificateRequestInfo) (*tls.Certificate, error)
	Close()
}

HitlessCertRotator renews TLS cert periodically

func NewHitlessCertRotator added in v0.3.0

func NewHitlessCertRotator(ctx context.Context, ethPriv *ecdsa.PrivateKey) (HitlessCertRotator, *tls.Config, error)

type ImmediateTicker added in v0.3.0

type ImmediateTicker struct {
	C <-chan time.Time // The channel on which the ticks are delivered.
	// contains filtered or unexported fields
}

func NewImmediateTicker added in v0.3.0

func NewImmediateTicker(d time.Duration) *ImmediateTicker

func (*ImmediateTicker) Stop added in v0.3.0

func (t *ImmediateTicker) Stop()

type PortBinding added in v0.3.0

type PortBinding interface {
	// Network shows name of the network (for example, "tcp", "udp").
	Network() string
	// Port describes a port.
	Port() uint16
}

func ParsePortBinding added in v0.3.0

func ParsePortBinding(v string) (PortBinding, error)

ParsePortBinding parses the given Docker port binding into components. For example `8080/tcp`.

type SelfSignedWallet added in v0.3.0

type SelfSignedWallet struct {
	Message string
}

func NewSelfSignedWallet added in v0.3.0

func NewSelfSignedWallet(key *ecdsa.PrivateKey) (*SelfSignedWallet, error)

type WalletAccess added in v0.3.0

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

WalletAccess supplies PerRPCCredentials from a given self-signed wallet.

func (WalletAccess) GetRequestMetadata added in v0.3.0

func (c WalletAccess) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

func (WalletAccess) RequireTransportSecurity added in v0.3.0

func (c WalletAccess) RequireTransportSecurity() bool

type WalletAuthenticator added in v0.3.0

type WalletAuthenticator struct {
	credentials.TransportCredentials
	Wallet ethcommon.Address
}

func (*WalletAuthenticator) ClientHandshake added in v0.3.0

func (w *WalletAuthenticator) ClientHandshake(ctx context.Context, arg string, conn net.Conn) (net.Conn, credentials.AuthInfo, error)

func (*WalletAuthenticator) ServerHandshake added in v0.3.0

func (w *WalletAuthenticator) ServerHandshake(conn net.Conn) (net.Conn, credentials.AuthInfo, error)

Jump to

Keyboard shortcuts

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