server

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2019 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	//StormDBPeers is the main object for peers db
	StormDBPeers *storm.DB

	//DefaultExpirationTime is the default expiration time used on the database
	DefaultExpirationTime = &buntdb.SetOptions{Expires: false} // never expire

	//PUBLIC_SERVER_READ_TIMEOUT_STR will be used to hold env var
	PUBLIC_SERVER_READ_TIMEOUT_STR = os.Getenv("PUBLIC_SERVER_READ_TIMEOUT")

	//PUBLIC_SERVER_WRITE_TIMEOUT_STR will be used to hold env var
	PUBLIC_SERVER_WRITE_TIMEOUT_STR = os.Getenv("PUBLIC_SERVER_WRITE_TIMEOUT")

	//PRIVATE_SERVER_READ_TIMEOUT_STR will be used to hold env var
	PRIVATE_SERVER_READ_TIMEOUT_STR = os.Getenv("PRIVATE_SERVER_READ_TIMEOUT")

	//PRIVATE_SERVER_WRITE_TIMEOUT_STR will be used to hold env var
	PRIVATE_SERVER_WRITE_TIMEOUT_STR = os.Getenv("PRIVATE_SERVER_WRITE_TIMEOUT")
	//PUBLIC_SERVER_READ_TIMEOUT will be used to hold env var
	PUBLIC_SERVER_READ_TIMEOUT = 120
	//PUBLIC_SERVER_WRITE_TIMEOUT will be used to hold env var
	PUBLIC_SERVER_WRITE_TIMEOUT = 120
	//PRIVATE_SERVER_READ_TIMEOUT   will be used to hold env var
	PRIVATE_SERVER_READ_TIMEOUT = 60
	//PRIVATE_SERVER_WRITE_TIMEOUT  will be used to hold env var
	PRIVATE_SERVER_WRITE_TIMEOUT = 60
)

Functions

func AddPeer

func AddPeer(node *discover.Node) error

AddPeer will add a peer

func DoUnixGetJSONRequest added in v1.0.2

func DoUnixGetJSONRequest(t *testing.T, endpoint string, json string) string

DoUnixGetJSONRequest is used for test real request calls.

func DoUnixPostJSONRequest added in v1.0.2

func DoUnixPostJSONRequest(t *testing.T, endpoint string, json string) string

DoUnixPostJSONRequest is used for test real request calls.

func DoUnixPostRequest added in v1.0.2

func DoUnixPostRequest(t *testing.T, endpoint string, payload []byte, headers http.Header) string

DoUnixPostRequest is used for test real request calls.

func DoUnixRequest added in v1.0.2

func DoUnixRequest(t *testing.T, endpoint string) string

DoUnixRequest is used for test real request calls.

func GetExternalIP

func GetExternalIP() (string, error)

GetExternalIP Get the external IP

func GetPeerListSend

func GetPeerListSend(peer *p2p.Peer, rw p2p.MsgWriter)

GetPeerListSend will get peers

func GetPeerNodeID

func GetPeerNodeID(id string) string

GetPeerNodeID will get peer node

func GetSocketClient

func GetSocketClient(socketFile string) http.Client

GetSocketClient is used for test real request calls.

func InitP2PPeers

func InitP2PPeers(peers []model.PeerNode)

InitP2PPeers will init peers

func InitP2PServer

func InitP2PServer(bootstrapNodes []*discover.Node) (*p2p.Server, error)

InitP2PServer will init p2p peers

func InitP2p

func InitP2p()

InitP2p will init p2p

func InitRouting

func InitRouting() (*mux.Router, *mux.Router)

InitRouting will init routing

func IsPeerAlreadyAdded

func IsPeerAlreadyAdded(parsedPeer *discover.Node) bool

IsPeerAlreadyAdded check if peer already connected

func NewServer

func NewServer(Hostaddr, Port string) (*http.Server, *http.Server)

NewServer will create a new http server instance -- pub and private

func PeerList

func PeerList(p2pMessage Message)

PeerList will init all peers provided on the p2p message

func SendMsg

func SendMsg(peer *p2p.Peer, rw p2p.MsgWriter, err error, outmsg Message)

SendMsg will send a message

func SetLogger

func SetLogger(loggers *logrus.Entry)

SetLogger set the logger

func StartServer

func StartServer()

StartServer will start the server

func SubscribeP2P

func SubscribeP2P()

SubscribeP2P will subscribe p2p

Types

type Message

type Message struct {
	Header string `json:"content"`
	Body   string `json:"body"`
}

Message holds header and body

type Peer

type Peer struct {
	ID         string
	Dest       string
	SourcePort int
}

Peer is the main peer struct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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