server

package
v0.0.0-...-9e21bb5 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2018 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UDPPacketSize = 1650
	UDP           = "udp"
	TCP           = "tcp"
)

Variables

View Source
var (
	BlockedIPsMap     = make(map[string]time.Time)
	BlockedIPsMapLock = &sync.RWMutex{}
)
View Source
var (
	IncTxPerSec   uint64
	NewTxPerSec   uint64
	KnownTxPerSec uint64
	ValidTxPerSec uint64
	TipReqPerSec  uint64

	TotalIncTx uint64

	Neighbors     map[string]*Neighbor
	NeighborsLock = &sync.RWMutex{}
)

Functions

func AddNeighbor

func AddNeighbor(address string) error

func BlockIP

func BlockIP(ipAddressWithPort string)

func End

func End()

func GetFormattedAddress

func GetFormattedAddress(identifier string, port string) string

func GetPreferredIP

func GetPreferredIP(knownIPs []*IPAddress, preferIPv6 bool) string

func IsIPBlocked

func IsIPBlocked(ipAddressWithPort string) (blocked bool)

func RemoveBlockedIPsOfNeighbor

func RemoveBlockedIPsOfNeighbor(neighbor *Neighbor)

func RemoveNeighbor

func RemoveNeighbor(address string) error

func Start

func Start()

func UpdateHostnameAddresses

func UpdateHostnameAddresses()

Types

type IPAddress

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

func (*IPAddress) IsIPv6

func (i *IPAddress) IsIPv6() bool

func (*IPAddress) String

func (i *IPAddress) String() string

type Message

type Message struct {
	Neighbor *Neighbor
	Msg      []byte
}

type Neighbor

type Neighbor struct {
	Hostname          string // Formatted like: <domainname> (Empty if its IP address)
	Addr              string // Formatted like: <ip>:<port> OR <domainname>:<port>
	IP                string // Formatted like: XXX.XXX.XXX.XXX (IPv4) OR [x:x:x:...] (IPv6)
	Port              string // Also saved separately from Addr for performance reasons
	IPAddressWithPort string // Formatted like: XXX.XXX.XXX.XXX:x (IPv4) OR [x:x:x:...]:x (IPv6)
	UDPAddr           *net.UDPAddr
	Incoming          int32
	New               int32
	Invalid           int32
	ConnectionType    string // Formatted like: udp
	PreferIPv6        bool
	KnownIPs          []*IPAddress
	LastIncomingTime  time.Time
}

func CheckNeighbourExistsByIPAddressWithPort

func CheckNeighbourExistsByIPAddressWithPort(ipAddressWithPort string, checkAllKnownAddresses bool) (neighborExists bool, neighbor *Neighbor)

func GetNeighborByAddress

func GetNeighborByAddress(address string) *Neighbor

func GetNeighborByIPAddressWithPort

func GetNeighborByIPAddressWithPort(ipAddressWithPort string) *Neighbor

func (*Neighbor) GetPreferredIP

func (nb *Neighbor) GetPreferredIP() string

func (*Neighbor) TrackIncoming

func (nb *Neighbor) TrackIncoming(cnt int32)

func (*Neighbor) TrackInvalid

func (nb *Neighbor) TrackInvalid(cnt int32)

func (*Neighbor) TrackNew

func (nb *Neighbor) TrackNew(cnt int32)

func (*Neighbor) UpdateIPAddressWithPort

func (nb *Neighbor) UpdateIPAddressWithPort(ipAddressWithPort string) (changed bool)

func (*Neighbor) Write

func (nb *Neighbor) Write(msg *Message)

type RawMsg

type RawMsg struct {
	Data *[]byte
	Addr *net.Addr
}

type Server

type Server struct {
	Incoming          chan *RawMsg
	Outgoing          chan *Message
	IncomingWaitGroup *sync.WaitGroup
	OutgoingWaitGroup *sync.WaitGroup

	IncomingQueueQuit chan struct{}
	// contains filtered or unexported fields
}

func GetServer

func GetServer() *Server

func (Server) Write

func (server Server) Write(msg *Message)

Jump to

Keyboard shortcuts

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