strip some code
This commit is contained in:
parent
74c5102e41
commit
f6b4a9da1c
@ -682,11 +682,6 @@ func (n *network) processCtrlChan(listener tunnel.Listener) {
|
|||||||
|
|
||||||
log.Tracef("Network router flushing routes for: %s", pbRtrSolicit.Id)
|
log.Tracef("Network router flushing routes for: %s", pbRtrSolicit.Id)
|
||||||
|
|
||||||
// advertise all the routes when a new node has connected
|
|
||||||
if err := n.router.Solicit(); err != nil {
|
|
||||||
log.Debugf("Network failed to solicit routes: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
peer := &node{
|
peer := &node{
|
||||||
id: pbRtrSolicit.Id,
|
id: pbRtrSolicit.Id,
|
||||||
link: m.msg.Header["Micro-Link"],
|
link: m.msg.Header["Micro-Link"],
|
||||||
@ -698,6 +693,11 @@ func (n *network) processCtrlChan(listener tunnel.Listener) {
|
|||||||
default:
|
default:
|
||||||
// don't block
|
// don't block
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// advertise all the routes when a new node has connected
|
||||||
|
if err := n.router.Solicit(); err != nil {
|
||||||
|
log.Debugf("Network failed to solicit routes: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case <-n.closed:
|
case <-n.closed:
|
||||||
return
|
return
|
||||||
@ -773,10 +773,7 @@ func (n *network) processNetChan(listener tunnel.Listener) {
|
|||||||
log.Debugf("Network failed to advertise peers: %v", err)
|
log.Debugf("Network failed to advertise peers: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// advertise all the routes when a new node has connected
|
<-time.After(time.Millisecond * 100)
|
||||||
if err := n.router.Solicit(); err != nil {
|
|
||||||
log.Debugf("Network failed to solicit routes: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// specify that we're soliciting
|
// specify that we're soliciting
|
||||||
select {
|
select {
|
||||||
@ -784,6 +781,12 @@ func (n *network) processNetChan(listener tunnel.Listener) {
|
|||||||
default:
|
default:
|
||||||
// don't block
|
// don't block
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// advertise all the routes when a new node has connected
|
||||||
|
if err := n.router.Solicit(); err != nil {
|
||||||
|
log.Debugf("Network failed to solicit routes: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
}()
|
}()
|
||||||
case "peer":
|
case "peer":
|
||||||
// mark the time the message has been received
|
// mark the time the message has been received
|
||||||
@ -829,7 +832,7 @@ func (n *network) processNetChan(listener tunnel.Listener) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// wait for a second
|
// wait for a second
|
||||||
<-time.After(time.Second)
|
<-time.After(time.Millisecond * 100)
|
||||||
|
|
||||||
// then solicit this peer
|
// then solicit this peer
|
||||||
if err := n.sendTo("solicit", ControlChannel, peer, msg); err != nil {
|
if err := n.sendTo("solicit", ControlChannel, peer, msg); err != nil {
|
||||||
@ -1373,6 +1376,7 @@ func (n *network) Close() error {
|
|||||||
default:
|
default:
|
||||||
// TODO: send close message to the network channel
|
// TODO: send close message to the network channel
|
||||||
close(n.closed)
|
close(n.closed)
|
||||||
|
|
||||||
// set connected to false
|
// set connected to false
|
||||||
n.connected = false
|
n.connected = false
|
||||||
|
|
||||||
@ -1389,6 +1393,7 @@ func (n *network) Close() error {
|
|||||||
if err := n.sendMsg("close", NetworkChannel, msg); err != nil {
|
if err := n.sendMsg("close", NetworkChannel, msg); err != nil {
|
||||||
log.Debugf("Network failed to send close message: %s", err)
|
log.Debugf("Network failed to send close message: %s", err)
|
||||||
}
|
}
|
||||||
|
<-time.After(time.Millisecond * 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
return n.close()
|
return n.close()
|
||||||
|
@ -42,9 +42,6 @@ type tun struct {
|
|||||||
// close channel
|
// close channel
|
||||||
closed chan bool
|
closed chan bool
|
||||||
|
|
||||||
// control channel to indicate link change
|
|
||||||
updated chan bool
|
|
||||||
|
|
||||||
// a map of sessions based on Micro-Tunnel-Channel
|
// a map of sessions based on Micro-Tunnel-Channel
|
||||||
sessions map[string]*session
|
sessions map[string]*session
|
||||||
|
|
||||||
@ -266,7 +263,6 @@ func (t *tun) manageLink(link *link) {
|
|||||||
// manageLinks is a function that can be called to immediately to link setup
|
// manageLinks is a function that can be called to immediately to link setup
|
||||||
// it purges dead links while generating new links for any nodes not connected
|
// it purges dead links while generating new links for any nodes not connected
|
||||||
func (t *tun) manageLinks() {
|
func (t *tun) manageLinks() {
|
||||||
// if we need to notify of updates
|
|
||||||
delLinks := make(map[*link]string)
|
delLinks := make(map[*link]string)
|
||||||
connected := make(map[string]bool)
|
connected := make(map[string]bool)
|
||||||
|
|
||||||
@ -323,9 +319,6 @@ func (t *tun) manageLinks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
t.Unlock()
|
t.Unlock()
|
||||||
|
|
||||||
// links were deleted so notify
|
|
||||||
go t.notify()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
@ -359,9 +352,6 @@ func (t *tun) manageLinks() {
|
|||||||
t.links[node] = link
|
t.links[node] = link
|
||||||
|
|
||||||
t.Unlock()
|
t.Unlock()
|
||||||
|
|
||||||
// notify ourselves of the change
|
|
||||||
go t.notify()
|
|
||||||
}(node)
|
}(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,17 +361,6 @@ func (t *tun) manageLinks() {
|
|||||||
|
|
||||||
// process outgoing messages sent by all local sessions
|
// process outgoing messages sent by all local sessions
|
||||||
func (t *tun) process() {
|
func (t *tun) process() {
|
||||||
// wait for the first update
|
|
||||||
<-t.updated
|
|
||||||
|
|
||||||
// get the list of links
|
|
||||||
var links []*link
|
|
||||||
t.RLock()
|
|
||||||
for _, link := range t.links {
|
|
||||||
links = append(links, link)
|
|
||||||
}
|
|
||||||
t.RUnlock()
|
|
||||||
|
|
||||||
// manage the send buffer
|
// manage the send buffer
|
||||||
// all pseudo sessions throw everything down this
|
// all pseudo sessions throw everything down this
|
||||||
for {
|
for {
|
||||||
@ -391,8 +370,10 @@ func (t *tun) process() {
|
|||||||
var sendTo []*link
|
var sendTo []*link
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
t.RLock()
|
||||||
|
|
||||||
// build the list of links ot send to
|
// build the list of links ot send to
|
||||||
for _, link := range links {
|
for _, link := range t.links {
|
||||||
// get the values we need
|
// get the values we need
|
||||||
link.RLock()
|
link.RLock()
|
||||||
id := link.id
|
id := link.id
|
||||||
@ -443,6 +424,8 @@ func (t *tun) process() {
|
|||||||
sendTo = append(sendTo, link)
|
sendTo = append(sendTo, link)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t.RUnlock()
|
||||||
|
|
||||||
// no links to send to
|
// no links to send to
|
||||||
if len(sendTo) == 0 {
|
if len(sendTo) == 0 {
|
||||||
log.Debugf("No links to send message type: %s channel: %s", msg.typ, msg.channel)
|
log.Debugf("No links to send message type: %s channel: %s", msg.typ, msg.channel)
|
||||||
@ -452,15 +435,6 @@ func (t *tun) process() {
|
|||||||
|
|
||||||
// send the message
|
// send the message
|
||||||
t.sendTo(sendTo, msg)
|
t.sendTo(sendTo, msg)
|
||||||
case <-t.updated:
|
|
||||||
t.RLock()
|
|
||||||
var newLinks []*link
|
|
||||||
for _, link := range t.links {
|
|
||||||
newLinks = append(newLinks, link)
|
|
||||||
}
|
|
||||||
t.RUnlock()
|
|
||||||
// links were updated
|
|
||||||
links = newLinks
|
|
||||||
case <-t.closed:
|
case <-t.closed:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -582,18 +556,6 @@ func (t *tun) delLink(remote string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
t.Unlock()
|
t.Unlock()
|
||||||
|
|
||||||
// let ourselves know of a link change
|
|
||||||
go t.notify()
|
|
||||||
}
|
|
||||||
|
|
||||||
// notify ourselves of a link change
|
|
||||||
func (t *tun) notify() {
|
|
||||||
select {
|
|
||||||
case t.updated <- true:
|
|
||||||
// unblock after a second
|
|
||||||
case <-time.After(time.Second):
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// process incoming messages
|
// process incoming messages
|
||||||
@ -670,8 +632,6 @@ func (t *tun) listen(link *link) {
|
|||||||
t.links[link.Remote()] = link
|
t.links[link.Remote()] = link
|
||||||
t.Unlock()
|
t.Unlock()
|
||||||
|
|
||||||
// notify of link change
|
|
||||||
go t.notify()
|
|
||||||
// send back an announcement of our channels discovery
|
// send back an announcement of our channels discovery
|
||||||
go t.announce("", "", link)
|
go t.announce("", "", link)
|
||||||
// ask for the things on the other wise
|
// ask for the things on the other wise
|
||||||
@ -691,6 +651,8 @@ func (t *tun) listen(link *link) {
|
|||||||
// remove the channel mapping for it. should we also close sessions?
|
// remove the channel mapping for it. should we also close sessions?
|
||||||
if sessionId == "listener" {
|
if sessionId == "listener" {
|
||||||
link.delChannel(channel)
|
link.delChannel(channel)
|
||||||
|
// TODO: find all the non listener unicast sessions
|
||||||
|
// and close them. think aboud edge cases first
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -949,9 +911,6 @@ func (t *tun) setupLinks() {
|
|||||||
|
|
||||||
// wait for all threads to finish
|
// wait for all threads to finish
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
// notify ourselves of the update
|
|
||||||
t.notify()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect the tunnel to all the nodes and listen for incoming tunnel connections
|
// connect the tunnel to all the nodes and listen for incoming tunnel connections
|
||||||
|
Loading…
Reference in New Issue
Block a user