tcp

package
v0.0.0-...-7efe5ce Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: GPL-3.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TCP_CHUNK_SIZE = 500

Functions

This section is empty.

Types

type BaseMiddleware

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

func NewBaseMiddleware

func NewBaseMiddleware() *BaseMiddleware

func (*BaseMiddleware) AcceptConnection

func (b *BaseMiddleware) AcceptConnection(*TCPConnection)

func (*BaseMiddleware) DashboardData

func (b *BaseMiddleware) DashboardData() interface{}

func (*BaseMiddleware) DashboardTableHasColumnTitles

func (b *BaseMiddleware) DashboardTableHasColumnTitles() bool

func (*BaseMiddleware) DashboardTitle

func (b *BaseMiddleware) DashboardTitle() string

func (*BaseMiddleware) DashboardType

func (b *BaseMiddleware) DashboardType() string

func (*BaseMiddleware) DropConnection

func (b *BaseMiddleware) DropConnection(*TCPConnection)

func (*BaseMiddleware) Handle

func (b *BaseMiddleware) Handle(ctx *P2PContext)

func (*BaseMiddleware) HandleRequest

func (b *BaseMiddleware) HandleRequest(reqPath string, handler func(*P2PContext))

func (*BaseMiddleware) Name

func (b *BaseMiddleware) Name() string

func (*BaseMiddleware) Start

func (b *BaseMiddleware) Start(ctx *P2PContext)

type FileSyncProvider

type FileSyncProvider struct {
	models.ISyncProvider
}

func NewFileSyncProvider

func NewFileSyncProvider() *FileSyncProvider

func (*FileSyncProvider) SendSyncRequest

func (f *FileSyncProvider) SendSyncRequest(network models.INetwork, ln *node.LocalNode, n *node.RemoteNode) bool

type IMiddleware

type IMiddleware interface {
	models.IDashboardProvider
	Handle(*P2PContext)
	Start(*P2PContext)
	AcceptConnection(*TCPConnection)
	DropConnection(*TCPConnection)
	Name() string
}

type ITCPDialer

type ITCPDialer interface {
	DialRemoteServer(ip net.IP, port int) (net.Conn, error)
}

type MultipartTCPDiagram

type MultipartTCPDiagram struct {
	models.TCPDiagram
	ChunkSize      int    // size of rawData
	ChunkNo        int    // index of all the chunks
	ChunksCount    int    // size of chunks
	RawData        []byte // part of a TCP Diagram or just rawData
	ChunkTotalSize int    // size of all
}

func (*MultipartTCPDiagram) GetChunkNo

func (m *MultipartTCPDiagram) GetChunkNo() int

func (*MultipartTCPDiagram) GetChunkSize

func (m *MultipartTCPDiagram) GetChunkSize() int

func (*MultipartTCPDiagram) GetChunkTotalSize

func (m *MultipartTCPDiagram) GetChunkTotalSize() int

func (*MultipartTCPDiagram) GetChunksCount

func (m *MultipartTCPDiagram) GetChunksCount() int

func (*MultipartTCPDiagram) GetRawData

func (m *MultipartTCPDiagram) GetRawData() []byte

type P2PContext

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

func NewP2PContext

func NewP2PContext(network models.INetwork, localNode *node.LocalNode, nodeProvider models.INodeProvider, params *TCPCallbackParams, middlewares []IMiddleware) *P2PContext

func (*P2PContext) Broadcast

func (ctx *P2PContext) Broadcast(diag models.IDiagram)

func (*P2PContext) BroadcastToNearbyNodes

func (ctx *P2PContext) BroadcastToNearbyNodes(diag models.IDiagram, maxNodeCount int, filter func(_p *node.RemoteNode) bool)

func (*P2PContext) BroadcastToPeers

func (ctx *P2PContext) BroadcastToPeers(diag models.IDiagram, peers []*node.RemoteNode, filter func(_p *node.RemoteNode) bool)

func (*P2PContext) BroadcastWithFilter

func (ctx *P2PContext) BroadcastWithFilter(diag models.IDiagram, filter func(_p *node.RemoteNode) bool)

func (*P2PContext) GetDiagram

func (ctx *P2PContext) GetDiagram(diagRef interface{}) error

Get the diagram as input

func (*P2PContext) GetSkipped

func (ctx *P2PContext) GetSkipped() bool

func (*P2PContext) LocalNode

func (ctx *P2PContext) LocalNode() *node.LocalNode

func (*P2PContext) Middlewares

func (ctx *P2PContext) Middlewares() []IMiddleware

func (*P2PContext) Network

func (ctx *P2PContext) Network() models.INetwork

func (*P2PContext) NewTCPDiagram

func (ctx *P2PContext) NewTCPDiagram() *models.TCPDiagram

func (*P2PContext) Next

func (ctx *P2PContext) Next()

func (*P2PContext) NodeProvider

func (ctx *P2PContext) NodeProvider() models.INodeProvider

func (*P2PContext) Params

func (ctx *P2PContext) Params() *TCPCallbackParams

func (*P2PContext) ResetSkipped

func (ctx *P2PContext) ResetSkipped()

func (*P2PContext) ResolveMultipartDiagram

func (ctx *P2PContext) ResolveMultipartDiagram(mDiag MultipartTCPDiagram) []byte

func (*P2PContext) Send

func (ctx *P2PContext) Send(diag models.IDiagram)

func (*P2PContext) SendToPeer

func (ctx *P2PContext) SendToPeer(diag models.IDiagram, peer *node.RemoteNode)

type RSASecuredTCPService

type RSASecuredTCPService struct {
	*TCPService
	// contains filtered or unexported fields
}

func NewRSASecuredTCPService

func NewRSASecuredTCPService(n *node.LocalNode) *RSASecuredTCPService

func (*RSASecuredTCPService) Start

func (r *RSASecuredTCPService) Start()

type SecuredTCPDialer

type SecuredTCPDialer struct {
	TlsConfig *tls.Config
}

func (*SecuredTCPDialer) DialRemoteServer

func (tcp *SecuredTCPDialer) DialRemoteServer(ip net.IP, port int) (net.Conn, error)

type SyncManager

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

SyncManager what to sync? block? file? config? rawdata? how to sync? from closer nodes? from every nodes? from those who has the content? sync details? blockid? filehash?

func NewSyncManager

func NewSyncManager(nodeProvider models.INodeProvider, network models.INetwork, syncProvider models.ISyncProvider) *SyncManager

func (*SyncManager) Start

func (s *SyncManager) Start()

type TCPCallbackParams

type TCPCallbackParams struct {
	models.CallbackParams
	Connection *TCPConnection
}

func (TCPCallbackParams) GetTCPDiagram

func (u TCPCallbackParams) GetTCPDiagram() models.TCPDiagram

func (TCPCallbackParams) GetTCPRemoteAddr

func (u TCPCallbackParams) GetTCPRemoteAddr() *net.TCPAddr

type TCPConnection

type TCPConnection struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewTCPConnection

func NewTCPConnection(conn net.Conn, isInbound bool) *TCPConnection

func (TCPConnection) GetIsInBound

func (t TCPConnection) GetIsInBound() bool

func (TCPConnection) GetLastActiveTime

func (t TCPConnection) GetLastActiveTime() time.Time

func (TCPConnection) GetNodeID

func (t TCPConnection) GetNodeID() string

func (TCPConnection) WriteBytes

func (t TCPConnection) WriteBytes(bytes []byte)

type TCPDialer

type TCPDialer struct {
}

func (*TCPDialer) DialRemoteServer

func (tcp *TCPDialer) DialRemoteServer(ip net.IP, port int) (net.Conn, error)

type TCPService

type TCPService struct {
	models.INetwork
	// contains filtered or unexported fields
}

func NewTCPService

func NewTCPService(localNode *node.LocalNode) *TCPService

func (*TCPService) GetConnection

func (tcp *TCPService) GetConnection(ip net.IP, port int, nodeId string) (*TCPConnection, error)

func (*TCPService) GetTCPConnections

func (tcp *TCPService) GetTCPConnections() []*TCPConnection

func (*TCPService) RegisterAcceptConnectionEvent

func (tcp *TCPService) RegisterAcceptConnectionEvent(f func(*TCPConnection))

func (*TCPService) RegisterCallback

func (c *TCPService) RegisterCallback(category string, callback func(models.ICallbackParams))

func (*TCPService) RegisterDropConnectionEvent

func (tcp *TCPService) RegisterDropConnectionEvent(f func(*TCPConnection))

func (*TCPService) RemoveCallback

func (c *TCPService) RemoveCallback(category string)

func (*TCPService) Send

func (c *TCPService) Send(ip net.IP, port int, bytes []byte, nodeId string)

func (*TCPService) Start

func (tcp *TCPService) Start()

type TLSSecuredTCPService

type TLSSecuredTCPService struct {
	*TCPService
}

func NewTLSSecuredTCPService

func NewTLSSecuredTCPService(n *node.LocalNode) *TLSSecuredTCPService

Jump to

Keyboard shortcuts

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