discover

package
v0.0.0-...-eeae653 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NEW_BUCKET_COUNT int = 64

TODO 这些都加到配置里面8

View Source
var NEW_BUCKET_LENGTH int = 64
View Source
var TRIED_BUCKET_COUNT int = 64
View Source
var TRIED_BUCKET_LENGTH int = 16

Functions

This section is empty.

Types

type Bucket

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

Bucket 路由桶

func (*Bucket) AddNewNode

func (bucket *Bucket) AddNewNode(n *commonModels.Node) *error.Error

AddNewNode 添加节点到新桶里

func (*Bucket) AddSeed

func (bucket *Bucket) AddSeed(node *commonModels.Node) *error.Error

AddSeed 添加一个节点到种子 这里有可能是在初始化阶段就添加,也有可能在收到邻居信息的时候添加

func (*Bucket) Build

func (bucket *Bucket) Build(prop map[string]interface{})

Build 初始化路由桶

func (*Bucket) CollectSeedFromConf

func (bucket *Bucket) CollectSeedFromConf()

CollectSeedFromConf 从配置中获取种子

func (*Bucket) GetNewBucket

func (bucket *Bucket) GetNewBucket() map[int][]*commonModels.Node

GetNewBucket 反射

func (*Bucket) GetRandomNode

func (bucket *Bucket) GetRandomNode() *commonModels.Node

GetRandomNode 获得一个随机节点,给tcp服务进行连接尝试

func (*Bucket) GetSeed

func (bucket *Bucket) GetSeed() *commonModels.Node

GetSeed 取出一个种子节点,并删除

func (*Bucket) IsNodeExist

func (bucket *Bucket) IsNodeExist(n *commonModels.Node) bool

IsNodeExist 检查节点是否存在路由桶里

type PingPongCachePackage

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

PingPongCachePackage 处理PingPong的缓存数据

func CreatePingPongCache

func CreatePingPongCache(nodeID string) *PingPongCachePackage

CreatePingPongCache 初始化一个缓存对象

func (*PingPongCachePackage) GetDoingPing

func (c *PingPongCachePackage) GetDoingPing() bool

GetDoingPing 反射

func (*PingPongCachePackage) GetPing

func (c *PingPongCachePackage) GetPing() bool

GetPing 反射

func (*PingPongCachePackage) GetPong

func (c *PingPongCachePackage) GetPong() bool

GetPong 反射

func (*PingPongCachePackage) SetDoingPing

func (c *PingPongCachePackage) SetDoingPing()

SetDoingPing 反射

func (*PingPongCachePackage) SetReceivePing

func (c *PingPongCachePackage) SetReceivePing()

SetReceivePing 反射

func (*PingPongCachePackage) SetReceivePong

func (c *PingPongCachePackage) SetReceivePong()

SetReceivePong 反射

type Shaker

type Shaker struct {
	NodeID     string
	SocketConn *net.UDPConn
}

Shaker 握手对象handle

func (Shaker) DoPing

func (s Shaker) DoPing(targetIP string, targetServicePort string) interface{}

*

  • 处理Pong数据包
  • @param targetIP string 目标IP
  • @param targetServicePort string 目标服务端口

func (Shaker) DoPong

func (s Shaker) DoPong(targetIP string, targetServicePort string) interface{}

*

  • 处理Pong数据包
  • @param targetIP string 目标IP
  • @param targetServicePort string 目标服务端口

func (Shaker) Send

func (s Shaker) Send(message string, targetIP string, targetServicePort string) interface{}

*

  • 把数据发送到目标地址
  • @param message string 数据内容
  • @param targetIP string 目标IP
  • @param targetServicePort string 目标服务端口

func (*Shaker) SetNodeID

func (s *Shaker) SetNodeID(nodeID string)

SetNodeID 必须使用指针,不然改不了数值

func (*Shaker) SetSocketConn

func (s *Shaker) SetSocketConn(socketConn *net.UDPConn)

SetSocketConn 把socket设置进来

Jump to

Keyboard shortcuts

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