Dry up creating new AURP peers
This commit is contained in:
parent
a05c069c81
commit
e2c476ffb5
2 changed files with 22 additions and 23 deletions
25
main.go
25
main.go
|
@ -287,18 +287,7 @@ func main() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
peer := &router.AURPPeer{
|
peer := router.NewAURPPeer(routes, ln, peerStr, raddr, localDI, nil, nextConnID)
|
||||||
Transport: &aurp.Transport{
|
|
||||||
LocalDI: localDI,
|
|
||||||
RemoteDI: aurp.IPDomainIdentifier(raddr.IP),
|
|
||||||
LocalConnID: nextConnID,
|
|
||||||
},
|
|
||||||
UDPConn: ln,
|
|
||||||
ConfiguredAddr: peerStr,
|
|
||||||
RemoteAddr: raddr,
|
|
||||||
ReceiveCh: make(chan aurp.Packet, 1024),
|
|
||||||
RouteTable: routes,
|
|
||||||
}
|
|
||||||
aurp.Inc(&nextConnID)
|
aurp.Inc(&nextConnID)
|
||||||
peersMu.Lock()
|
peersMu.Lock()
|
||||||
peers[udpAddrFromNet(raddr)] = peer
|
peers[udpAddrFromNet(raddr)] = peer
|
||||||
|
@ -394,17 +383,7 @@ func main() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// New peer!
|
// New peer!
|
||||||
pr = &router.AURPPeer{
|
pr = router.NewAURPPeer(routes, ln, "", raddr, localDI, dh.SourceDI, nextConnID)
|
||||||
Transport: &aurp.Transport{
|
|
||||||
LocalDI: localDI,
|
|
||||||
RemoteDI: dh.SourceDI, // platinum rule
|
|
||||||
LocalConnID: nextConnID,
|
|
||||||
},
|
|
||||||
UDPConn: ln,
|
|
||||||
RemoteAddr: raddr,
|
|
||||||
ReceiveCh: make(chan aurp.Packet, 1024),
|
|
||||||
RouteTable: routes,
|
|
||||||
}
|
|
||||||
aurp.Inc(&nextConnID)
|
aurp.Inc(&nextConnID)
|
||||||
peers[ra] = pr
|
peers[ra] = pr
|
||||||
goPeerHandler(pr)
|
goPeerHandler(pr)
|
||||||
|
|
|
@ -114,6 +114,7 @@ type AURPPeer struct {
|
||||||
// Route table (the peer will add/remove/update routes and zones)
|
// Route table (the peer will add/remove/update routes and zones)
|
||||||
RouteTable *RouteTable
|
RouteTable *RouteTable
|
||||||
|
|
||||||
|
// Event tuples yet to be sent to this peer in an RI-Upd.
|
||||||
pendingEvents chan aurp.EventTuple
|
pendingEvents chan aurp.EventTuple
|
||||||
|
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
|
@ -121,6 +122,25 @@ type AURPPeer struct {
|
||||||
sstate SenderState
|
sstate SenderState
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewAURPPeer(routes *RouteTable, udpConn *net.UDPConn, peerAddr string, raddr *net.UDPAddr, localDI, remoteDI aurp.DomainIdentifier, connID uint16) *AURPPeer {
|
||||||
|
if remoteDI == nil {
|
||||||
|
remoteDI = aurp.IPDomainIdentifier(raddr.IP)
|
||||||
|
}
|
||||||
|
return &AURPPeer{
|
||||||
|
Transport: &aurp.Transport{
|
||||||
|
LocalDI: localDI,
|
||||||
|
RemoteDI: remoteDI,
|
||||||
|
LocalConnID: connID,
|
||||||
|
},
|
||||||
|
UDPConn: udpConn,
|
||||||
|
ConfiguredAddr: peerAddr,
|
||||||
|
RemoteAddr: raddr,
|
||||||
|
ReceiveCh: make(chan aurp.Packet, 1024),
|
||||||
|
RouteTable: routes,
|
||||||
|
pendingEvents: make(chan aurp.EventTuple, 1024),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (p *AURPPeer) addPendingEvent(ec aurp.EventCode, route *Route) {
|
func (p *AURPPeer) addPendingEvent(ec aurp.EventCode, route *Route) {
|
||||||
// Don't advertise routes to AURP peers to other AURP peers
|
// Don't advertise routes to AURP peers to other AURP peers
|
||||||
if route.AURPPeer != nil {
|
if route.AURPPeer != nil {
|
||||||
|
|
Loading…
Reference in a new issue