util

package
v0.0.0-...-ec14ce0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2018 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCert

func CheckCert(cert *x509.Certificate) (string, error)

func DirectoryExists

func DirectoryExists(p string) bool

DirectoryExists returns true if the given directory exists

func EqualAddresses

func EqualAddresses(a, b common.Address) bool

EqualAddresses checks if provided Addresses are equal

func ExtractMethod

func ExtractMethod(fullMethod string) string

func GenerateCert

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

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

func GetLocalIP

func GetLocalIP() string

GetLocalIP find local non-loopback ip addr

func GetPlatformName

func GetPlatformName() string

func GetUserHomeDir

func GetUserHomeDir() (homeDir string, err error)

func LoadYamlFile

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

func MakeGrpcClient

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

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

MakeGrpcServer creates new gRPC server

func MakeWalletAuthenticatedClient

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

func NewTLS

NewTLS wraps TLS TransportCredentials from grpc to add custom logic

func NewWalletAccess

func NewWalletAccess(wallet *SelfSignedWallet) credentials.PerRPCCredentials

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

func ParseBigInt

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

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

func ParseEndpoint

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

func ParseEndpointPort

func ParseEndpointPort(s string) (string, error)

func PubKeyToAddr

func PubKeyToAddr(key ecdsa.PublicKey) common.Address

func PubKeyToString

func PubKeyToString(key ecdsa.PublicKey) string

func VerifySelfSignedWallet

func VerifySelfSignedWallet(signedWallet string) (string, error)

Types

type EthAuthInfo

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

func (e EthAuthInfo) AuthType() string

AuthType implements credentials.AuthInfo interface

func (EthAuthInfo) WalletAddress

func (e EthAuthInfo) WalletAddress() ethcommon.Address

WalletAddress returns ethereum wallet address.

type HitlessCertRotator

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

HitlessCertRotator renews TLS cert periodically

func NewHitlessCertRotator

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

type PortBinding

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

func ParsePortBinding

func ParsePortBinding(v string) (PortBinding, error)

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

type SelfSignedWallet

type SelfSignedWallet struct {
	Message string
}

func NewSelfSignedWallet

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

type WalletAccess

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

WalletAccess supplies PerRPCCredentials from a given self-signed wallet.

func (WalletAccess) GetRequestMetadata

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

func (WalletAccess) RequireTransportSecurity

func (c WalletAccess) RequireTransportSecurity() bool

type WalletAuthenticator

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

func (*WalletAuthenticator) ClientHandshake

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

func (*WalletAuthenticator) ServerHandshake

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