begin fixing routing problems
This commit is contained in:
parent
88761f0719
commit
d7d5c44ced
3 changed files with 11 additions and 7 deletions
|
|
@ -64,5 +64,5 @@ func (host *LuxHost) Heartbeat() error {
|
|||
}
|
||||
|
||||
state.Write(&packet.Buffer)
|
||||
return host.router.Multicast(packet)
|
||||
return host.router.Multicast(packet, proto.LuxTypeNode)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ type LuxRoute struct {
|
|||
Nonces LuxNonceList
|
||||
}
|
||||
|
||||
// !!!!!
|
||||
// TODO: map key can be destination ID, while Key (+ ID) in route struct would be SOURCE
|
||||
type LuxRouter struct {
|
||||
thisKey crypto.LuxKey
|
||||
keyStore crypto.LuxKeyStore
|
||||
|
|
@ -301,9 +303,9 @@ func (r *LuxRouter) Send(packet LuxPacket) error {
|
|||
return route.Associated.Send(dgram)
|
||||
}
|
||||
|
||||
func (r *LuxRouter) Multicast(packet LuxPacket) error {
|
||||
func (r *LuxRouter) Multicast(packet LuxPacket, group proto.LuxType) error {
|
||||
for _, route := range r.routes {
|
||||
if bytes.Equal(route.Key.Id.UUID[:], packet.Target.UUID[:]) {
|
||||
if route.Key.Type == group {
|
||||
packet.Nonce = GenerateLuxNonce()
|
||||
dgram, err := EncryptLuxPacket(packet, route.Key, route.Destination)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -20,17 +20,19 @@ func (*DummyWANProvider) Provide() (host.LuxOption, error) {
|
|||
func TestHeartbeatMulticast(t *testing.T) {
|
||||
ks := crypto.NewLuxKeyStore("/tmp/keystore.dat")
|
||||
|
||||
keyNode, _ := crypto.NewLuxKey(proto.LuxTypeNode)
|
||||
ks.Put(keyNode)
|
||||
keyNodeA, _ := crypto.NewLuxKey(proto.LuxTypeNode)
|
||||
ks.Put(keyNodeA)
|
||||
keyNodeB, _ := crypto.NewLuxKey(proto.LuxTypeNode)
|
||||
ks.Put(keyNodeB)
|
||||
keyHost, _ := crypto.NewLuxKey(proto.LuxTypeHost)
|
||||
ks.Put(keyHost)
|
||||
|
||||
nodeA := net.NewLuxRouter(keyNode, ks)
|
||||
nodeA := net.NewLuxRouter(keyNodeA, ks)
|
||||
nodeA.CreateInboundChannel(net.LuxChannelInterior, "127.0.0.1:9979")
|
||||
nodeA.Start()
|
||||
defer nodeA.Stop()
|
||||
|
||||
nodeB := net.NewLuxRouter(keyNode, ks)
|
||||
nodeB := net.NewLuxRouter(keyNodeB, ks)
|
||||
nodeB.CreateInboundChannel(net.LuxChannelInterior, "127.0.0.2:9979")
|
||||
nodeB.Start()
|
||||
defer nodeB.Stop()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue