mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Move some things around a bit, delete session workers
This commit is contained in:
parent
b2f4f2e1b6
commit
b20c8b6da5
3 changed files with 32 additions and 159 deletions
|
@ -254,6 +254,38 @@ func (c *Core) Stop() {
|
|||
c.admin.close()
|
||||
}
|
||||
|
||||
// Dial opens a session to the given node. The first paramter should be "nodeid"
|
||||
// and the second parameter should contain a hexadecimal representation of the
|
||||
// target node ID.
|
||||
func (c *Core) Dial(network, address string) (Conn, error) {
|
||||
conn := Conn{}
|
||||
nodeID := crypto.NodeID{}
|
||||
nodeMask := crypto.NodeID{}
|
||||
// Process
|
||||
switch network {
|
||||
case "nodeid":
|
||||
// A node ID was provided - we don't need to do anything special with it
|
||||
dest, err := hex.DecodeString(address)
|
||||
if err != nil {
|
||||
return Conn{}, err
|
||||
}
|
||||
copy(nodeID[:], dest)
|
||||
for i := range nodeMask {
|
||||
nodeMask[i] = 0xFF
|
||||
}
|
||||
default:
|
||||
// An unexpected address type was given, so give up
|
||||
return Conn{}, errors.New("unexpected address type")
|
||||
}
|
||||
conn.core = c
|
||||
conn.nodeID = &nodeID
|
||||
conn.nodeMask = &nodeMask
|
||||
conn.core.router.doAdmin(func() {
|
||||
conn.startSearch()
|
||||
})
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
// ListenTCP starts a new TCP listener. The input URI should match that of the
|
||||
// "Listen" configuration item, e.g.
|
||||
// tcp://a.b.c.d:e
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue