common

package
v0.0.0-...-c729bb3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2019 License: LGPL-3.0 Imports: 32 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// NodeAvailableRep - global definition for reputation value of node availability
	NodeAvailableRep = 10

	// GoP2PTestnetID - GoP2P testing network identifier
	GoP2PTestnetID = 4519161392015

	// ConnectionDelimiter - GoP2P standard connection delimiter
	ConnectionDelimiter = byte('\f')

	// ProtobufPrefix - GoP2P standard protobuf message prefix
	ProtobufPrefix = "ProtoID"
)

Variables

View Source
var (
	// ExtIPProviders - preset macro defining list of available external IP checking services
	ExtIPProviders = []string{"http://checkip.amazonaws.com/", "http://icanhazip.com/", "http://www.trackip.net/ip", "http://bot.whatismyipaddress.com/", "https://ipecho.net/plain", "http://myexternalip.com/raw"}

	// GeneralTLSConfig - general global GoP2P TLS Config
	GeneralTLSConfig = &tls.Config{
		Certificates:       []tls.Certificate{getTLSCerts("GoP2PGeneral")},
		InsecureSkipVerify: true,
		ServerName:         "localhost"}

	// Silent - silence common.Println calls
	Silent = false
)

Functions

func CheckAddress

func CheckAddress(address string) error

CheckAddress - check that specified IP address can be pinged, and is available on specified port

func ConvertStringToReflectValues

func ConvertStringToReflectValues(inputs []string) []reflect.Value

ConvertStringToReflectValues - convert string to []reflect.Value

func DelaySeconds

func DelaySeconds(seconds uint) bool

DelaySeconds - wait until duration passed, return true once duration completed

func Forever

func Forever()

Forever - prevent thread from closing

func GenerateTLSCertificates

func GenerateTLSCertificates(namePrefix string) error

GenerateTLSCertificates - generate necessary TLS certificates, keys

func GetCommonByteDifference

func GetCommonByteDifference(b [][]byte) ([]byte, error)

GetCommonByteDifference - attempt to fetch most similar byte array in array of byte arrays

func GetCurrentDir

func GetCurrentDir() (string, error)

GetCurrentDir - returns current execution directory

func GetCurrentTime

func GetCurrentTime() time.Time

GetCurrentTime - get current time in the UTC format

func GetExtIPAddrWithUPnP

func GetExtIPAddrWithUPnP() (string, error)

GetExtIPAddrWithUPnP - retrieve the external IP address of the current machine via upnp

func GetExtIPAddrWithoutUPnP

func GetExtIPAddrWithoutUPnP() (string, error)

GetExtIPAddrWithoutUPnP - retrieve the external IP address of the current machine w/o upnp

func InterfaceFromBytes

func InterfaceFromBytes(data []byte, buffer interface{}) (interface{}, error)

InterfaceFromBytes - attempt to decode specified byte array to interface

func MarshalInterfaceToMap

func MarshalInterfaceToMap(object interface{}) (map[string]string, error)

MarshalInterfaceToMap - attempt to map interface to string map

func ParseShardAddress

func ParseShardAddress(address string) ([]string, error)

ParseShardAddress - attempt to fetch node addresses from shard address

func ParseStringMethodCall

func ParseStringMethodCall(input string) (string, string, []string, error)

ParseStringMethodCall - attempt to parse string as method call, returning receiver, method name, and params

func ParseStringParams

func ParseStringParams(input string) ([]string, error)

ParseStringParams - attempt to fetch string parameters from (..., ..., ...) style call

func Print

func Print(i interface{})

Print - print

func Printf

func Printf(format string, i ...interface{})

Printf - print

func Println

func Println(i interface{})

Println - print

func ReadConnectionAsync

func ReadConnectionAsync(conn *tls.Conn, buffer chan []byte, finished chan bool, err chan error)

ReadConnectionAsync - attempt to read entirety of specified connection in an asynchronous fashion, returning data byte value

func ReadConnectionDelim

func ReadConnectionDelim(conn *tls.Conn) ([]byte, error)

ReadConnectionDelim - attempt to read connection until occurrence of standard GoP2P connection delimiter

func ReadConnectionWaitAsync

func ReadConnectionWaitAsync(conn *tls.Conn) ([]byte, error)

ReadConnectionWaitAsync - attempt to read from connection in an asynchronous fashion, after waiting for peer to write

func ReadConnectionWaitAsyncNoTLS

func ReadConnectionWaitAsyncNoTLS(conn net.Conn) ([]byte, error)

ReadConnectionWaitAsyncNoTLS - attempt to read from connection in an asynchronous fashion, after waiting for peer to write

func ReadGob

func ReadGob(filePath string, object interface{}) error

ReadGob - read gob specified at path

func SafeSlice

func SafeSlice(b []byte) string

SafeSlice - fetch sliced byte array input (max 20 chars)

func SeedAddress

func SeedAddress(seeds []string, shardID string) (string, error)

SeedAddress - generated shard address from seeds

func SendBytes

func SendBytes(b []byte, address string) error

SendBytes - attempt to send specified bytes to given address

func SendBytesAsync

func SendBytesAsync(b []byte, address string, finished *[]bool) error

SendBytesAsync - attempt to send specified bytes to given address in an asynchronous manner

func SendBytesAsyncRoutine

func SendBytesAsyncRoutine(b []byte, address string, finished chan bool) error

SendBytesAsyncRoutine - attempt to send specified bytes to given address in an asynchronous, go routine-based manner.

func SendBytesNoTLS

func SendBytesNoTLS(b []byte, address string) error

SendBytesNoTLS - send bytes to address without TLS

func SendBytesResult

func SendBytesResult(b []byte, address string) ([]byte, error)

SendBytesResult - attempt to send specified bytes to given address, returning result

func SendBytesResultBufferAsync

func SendBytesResultBufferAsync(b []byte, buffer *[][]byte, address string) error

SendBytesResultBufferAsync - attempt to send specified bytes to given address in an asynchronous fashion, reading the result into a given buffer

func SendBytesReusable

func SendBytesReusable(b []byte, address string) (*tls.Conn, error)

SendBytesReusable - attempt to send specified bytes to given address and return created connection

func SendBytesWithConnection

func SendBytesWithConnection(connection *tls.Conn, b []byte) error

SendBytesWithConnection - attempt to send specified bytes to given address via given connection

func SerializeToBytes

func SerializeToBytes(object interface{}) ([]byte, error)

SerializeToBytes - attempt to convert specified interface to byte array

func SerializeToString

func SerializeToString(object interface{}) (string, error)

SerializeToString - attempt to get string representation of specified object

func Sha3

func Sha3(b []byte) string

Sha3 - hash specified byte array

func StringFetchCallReceiver

func StringFetchCallReceiver(input string) string

StringFetchCallReceiver - attempt to fetch receiver from string, as if it were a x.y(..., ..., ...) style method call

func StringInSlice

func StringInSlice(s []string, v string) bool

StringInSlice - check if value is in slice

func StringStripParentheses

func StringStripParentheses(input string) string

StringStripParentheses - strip parantheses from string

func StringStripReceiverCall

func StringStripReceiverCall(input string) string

StringStripReceiverCall - strip receiver from string method call

func UnmarshalInterfaceFromMap

func UnmarshalInterfaceFromMap(object map[string]interface{}) (interface{}, error)

UnmarshalInterfaceFromMap - attempt to convert specified map to interface

func UnmarshalInterfaceFromStringMap

func UnmarshalInterfaceFromStringMap(buffer interface{}, object map[string]string) (interface{}, error)

UnmarshalInterfaceFromStringMap - attempt to convert specified map to interface

func WriteGob

func WriteGob(filePath string, object interface{}) error

WriteGob - create gob from specified object, at filePath

Types

This section is empty.

Jump to

Keyboard shortcuts

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