Documentation ¶
Index ¶
- Constants
- type Manager
- func (lt *Manager) AppendToTable(datfile string, n *Node)
- func (lt *Manager) Get(datfile string, def Slice) Slice
- func (lt *Manager) GetNodestrSlice() []string
- func (lt *Manager) GetNodestrSliceInTable(datfile string) []string
- func (lt *Manager) Initialize(allnodes Slice)
- func (lt *Manager) Join(n *Node) bool
- func (lt *Manager) ListLen() int
- func (lt *Manager) NodeLen() int
- func (lt *Manager) NodesForGet(datfile string, searchDepth int) Slice
- func (lt *Manager) Random(exclude Slice, num int) []*Node
- func (lt *Manager) RemoveFromAllTable(n *Node) bool
- func (lt *Manager) RemoveFromList(n *Node) bool
- func (lt *Manager) RemoveFromTable(datfile string, n *Node) bool
- func (lt *Manager) ReplaceNodeInList(n *Node) *Node
- func (lt *Manager) Sync()
- func (lt *Manager) TellUpdate(datfile string, stamp int64, id string, node *Node)
- type ManagerConfig
- type Myself
- type Node
- type NodeConfig
- type Slice
Constants ¶
const ( //Disconnected represents mynode is disconnected. Disconnected = iota //Port0 represents mynode is behind NAT and not opened. Port0 //UPnP represents mynode is opned by uPnP. UPnP //Normal represents port was opened manually. Normal //Relay represents relayed Relay )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct { *ManagerConfig // contains filtered or unexported fields }
Manager represents the map that maps datfile to it's source node list.
func NewManager ¶
func NewManager(cfg *ManagerConfig) *Manager
NewManager read the file and returns NodeManager obj.
func (*Manager) AppendToTable ¶
AppendToTable add node n to table if it is allowd and list doesn't have it.
func (*Manager) GetNodestrSlice ¶
GetNodestrSlice returns Nodestr of all nodes.
func (*Manager) GetNodestrSliceInTable ¶
GetNodestrSliceInTable returns Nodestr slice of nodes associated datfile thread.
func (*Manager) Initialize ¶
Initialize pings one of initNode except myself and added it if success, and get another node info from each nodes in nodelist.
func (*Manager) Join ¶
Join tells n to join and adds n to nodelist if welcomed. if n returns another nodes, repeats it and return true.. removes fron nodelist if not welcomed and return false.
func (*Manager) NodesForGet ¶ added in v0.0.6
NodesForGet returns nodes which has datfile cache , and that extends nodes to #searchDepth .
func (*Manager) Random ¶
Random selects # of min(all # of nodes,n) nodes randomly except exclude nodes.
func (*Manager) RemoveFromAllTable ¶
RemoveFromAllTable removes node n from all tables and return true if exists. or returns false if not exists.
func (*Manager) RemoveFromList ¶
RemoveFromList removes node n from nodelist and return true if exists. or returns false if not exists.
func (*Manager) RemoveFromTable ¶
RemoveFromTable removes node n and return true if exists. or returns false if not exists.
func (*Manager) ReplaceNodeInList ¶
ReplaceNodeInList removes one node and say bye to the node and add n in nodelist. if len(node)>defaultnode
type ManagerConfig ¶
type ManagerConfig struct { Lookup string Fmutex *sync.RWMutex NodeAllow *util.RegexpList NodeDeny *util.RegexpList Myself *Myself InitNode *util.ConfList }
ManagerConfig contains params for NodeManager struct.
type Myself ¶
Myself contains my node info.
func NewMyself ¶
func NewMyself(internalPort int, path string, serverName string, serveHTTP http.HandlerFunc, networkMode string) *Myself
NewMyself returns Myself obj.
func (*Myself) IPPortPath ¶
IPPortPath returns node ojb contains ip:port/path.
func (*Myself) InitConnection ¶ added in v0.0.13
InitConnection setups connection.
func (*Myself) RelayServer ¶ added in v0.0.5
RelayServer returns nodestr of relay server.
type Node ¶
type Node struct { *NodeConfig Nodestr string }
Node represents node info.
func MustNewNodes ¶ added in v0.0.11
MustNewNodes makes node slice from names.
func (*Node) GetherNodes ¶ added in v0.0.11
GetherNodes gethers nodes from n.
type NodeConfig ¶
type NodeConfig struct { Myself *Myself NodeAllow *util.RegexpList NodeDeny *util.RegexpList Version string }
NodeConfig contains params for Node struct.
var NodeCfg *NodeConfig
NodeCfg is a global stuf for Node struct. it must be set before using it.