diff --git a/network/dataStructures/roundData.go b/network/dataStructures/roundData.go index caa0bb8754cf941748a2d0fff665ba7423761d86..9ca93daaeb01d0758b6da5f5e15dd4eb65f1ed2e 100644 --- a/network/dataStructures/roundData.go +++ b/network/dataStructures/roundData.go @@ -59,6 +59,6 @@ func (d *Data) GetLastRoundID() id.Round { } // Gets the ID of the oldest roundd in the buffer -func (d *Data) GetOldestRoundID() id.Round { +func (d *Data) GetOldestRoundID() id.Round { return id.Round(d.rounds.GetOldestId()) } diff --git a/network/instance.go b/network/instance.go index 1b02af24116e00871edd53945c640200e7ed2836..112946f3cf9ddc1e5ba50719293e4f86b23ea4cf 100644 --- a/network/instance.go +++ b/network/instance.go @@ -38,6 +38,10 @@ type Instance struct { ipOverride *ds.IpOverrideList + // Determines whether auth is enabled + // on communication with gateways + gatewayAuth bool + // Network Health networkHealth chan Heartbeat @@ -614,9 +618,7 @@ func (i *Instance) updateConns(def *ndf.NetworkDefinition, isGateway, isNode boo gwParams := connect.GetDefaultHostParams() gwParams.MaxRetries = 3 gwParams.EnableCoolOff = true - if i.comm.Id.GetType() != id.Gateway { - gwParams.AuthEnabled = false - } + gwParams.AuthEnabled = i.gatewayAuth _, err := i.comm.AddHost(gwid, addr, []byte(gateway.TlsCertificate), gwParams) if err != nil { return errors.WithMessagef(err, "Could not add gateway host %s", gwid) @@ -686,3 +688,9 @@ func (i *Instance) updateConns(def *ndf.NetworkDefinition, isGateway, isNode boo } return nil } + +// SetGatewayAuth will force authentication on all communications with gateways +// intended for use between Gateway <-> Gateway communications +func (i *Instance) SetGatewayAuthentication() { + i.gatewayAuth = true +} diff --git a/network/instance_test.go b/network/instance_test.go index d12aca75a4ab4243be53d73f6951cd111135fa71..8dd80d105fed00d920cedb5dc627065d66367a6d 100644 --- a/network/instance_test.go +++ b/network/instance_test.go @@ -202,7 +202,7 @@ func setupComm(t *testing.T) (*Instance, *mixmessages.NDF) { err = signature.Sign(f, privKey) testManager := connect.NewManagerTesting(t) pc := &connect.ProtoComms{ - Id:id.NewIdFromString("User", id.User, t), + Id: id.NewIdFromString("User", id.User, t), Manager: testManager, } i, err := NewInstance(pc, baseNDF, baseNDF, nil) @@ -362,7 +362,7 @@ func TestInstance_UpdateGatewayConnections(t *testing.T) { secured, _ := NewSecuredNdf(testutils.NDF) testManager := connect.NewManagerTesting(t) pc := &connect.ProtoComms{ - Id:id.NewIdFromString("User", id.User, t), + Id: id.NewIdFromString("User", id.User, t), Manager: testManager, } i := Instance{