Skip to content
Snippets Groups Projects
Commit 2fd7bfda authored by Jonah Husson's avatar Jonah Husson
Browse files

final updates to params

parent 78f1b71b
No related branches found
No related tags found
No related merge requests found
...@@ -9,5 +9,4 @@ package conf ...@@ -9,5 +9,4 @@ package conf
// Contains Gateways config params // Contains Gateways config params
type Gateway struct { type Gateway struct {
Paths Paths Paths Paths
Address string
} }
...@@ -19,7 +19,6 @@ var ExpectedGateway = Gateway{ ...@@ -19,7 +19,6 @@ var ExpectedGateway = Gateway{
Key: "", Key: "",
Log: "", Log: "",
}, },
Address: "127.0.0.1:80",
} }
// This test checks that unmarshalling the params.yaml file // This test checks that unmarshalling the params.yaml file
......
...@@ -9,6 +9,6 @@ package conf ...@@ -9,6 +9,6 @@ package conf
// Contains Node config params // Contains Node config params
type Node struct { type Node struct {
Paths Paths Paths Paths
Address string ListeningAddress string
Port int Port int
} }
...@@ -8,10 +8,6 @@ package conf ...@@ -8,10 +8,6 @@ package conf
import ( import (
"gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/id"
"gitlab.com/elixxir/primitives/utils"
"gopkg.in/yaml.v2"
"reflect"
"testing"
) )
var nodeID = id.ID([33]byte{82, 253, 252, 7, 33, 130, 101, 79, 22, 63, 95, 15, var nodeID = id.ID([33]byte{82, 253, 252, 7, 33, 130, 101, 79, 22, 63, 95, 15,
...@@ -20,10 +16,11 @@ var nodeID = id.ID([33]byte{82, 253, 252, 7, 33, 130, 101, 79, 22, 63, 95, 15, ...@@ -20,10 +16,11 @@ var nodeID = id.ID([33]byte{82, 253, 252, 7, 33, 130, 101, 79, 22, 63, 95, 15,
var ExpectedNode = Node{ var ExpectedNode = Node{
Paths: ExpectedPaths, Paths: ExpectedPaths,
Address: "127.0.0.1", ListeningAddress: "127.0.0.1",
Port: 80, Port: 80,
} }
/*
// This test checks that unmarshalling the params.yaml file // This test checks that unmarshalling the params.yaml file
// has the expected Node object. // has the expected Node object.
func TestNode_UnmarshallingFileEqualsExpected(t *testing.T) { func TestNode_UnmarshallingFileEqualsExpected(t *testing.T) {
...@@ -42,4 +39,4 @@ func TestNode_UnmarshallingFileEqualsExpected(t *testing.T) { ...@@ -42,4 +39,4 @@ func TestNode_UnmarshallingFileEqualsExpected(t *testing.T) {
"\n\texpected: %#v\n\treceived: %#v", ExpectedNode, actual.Node) "\n\texpected: %#v\n\treceived: %#v", ExpectedNode, actual.Node)
} }
} }*/
...@@ -60,8 +60,12 @@ func NewParams(vip *viper.Viper) (*Params, error) { ...@@ -60,8 +60,12 @@ func NewParams(vip *viper.Viper) (*Params, error) {
params := Params{} params := Params{}
params.Node.Address = vip.GetString("node.address") vip.SetDefault("node.listeningAddress", "0.0.0.0")
params.Node.ListeningAddress = vip.GetString("node.listeningAddress")
params.Node.Port = vip.GetInt("node.Port") params.Node.Port = vip.GetInt("node.Port")
if params.Node.Port == 0 {
jww.FATAL.Panic("Must specify a port to run on")
}
params.Node.Paths.Idf = vip.GetString("node.paths.idf") params.Node.Paths.Idf = vip.GetString("node.paths.idf")
require(params.Node.Paths.Idf, "node.paths.idf") require(params.Node.Paths.Idf, "node.paths.idf")
...@@ -87,7 +91,6 @@ func NewParams(vip *viper.Viper) (*Params, error) { ...@@ -87,7 +91,6 @@ func NewParams(vip *viper.Viper) (*Params, error) {
require(params.Gateway.Paths.Cert, "gateway.paths.cert") require(params.Gateway.Paths.Cert, "gateway.paths.cert")
params.SignedGatewayCertPath = vip.GetString("gateway.paths.signedCert") params.SignedGatewayCertPath = vip.GetString("gateway.paths.signedCert")
params.Gateway.Address = vip.GetString("gateway.address")
params.Permissioning.Paths.Cert = vip.GetString("permissioning.paths.cert") params.Permissioning.Paths.Cert = vip.GetString("permissioning.paths.cert")
require(params.Permissioning.Paths.Cert, "permissioning.paths.cert") require(params.Permissioning.Paths.Cert, "permissioning.paths.cert")
...@@ -153,7 +156,7 @@ func (p *Params) ConvertToDefinition() (*internal.Definition, error) { ...@@ -153,7 +156,7 @@ func (p *Params) ConvertToDefinition() (*internal.Definition, error) {
} }
} }
def.Address = fmt.Sprintf("%s:%d", p.Node.Address, p.Node.Port) def.Address = fmt.Sprintf("%s:%d", p.Node.ListeningAddress, p.Node.Port)
def.TlsCert = tlsCert def.TlsCert = tlsCert
def.TlsKey = tlsKey def.TlsKey = tlsKey
def.LogPath = p.Node.Paths.Log def.LogPath = p.Node.Paths.Log
...@@ -169,7 +172,6 @@ func (p *Params) ConvertToDefinition() (*internal.Definition, error) { ...@@ -169,7 +172,6 @@ func (p *Params) ConvertToDefinition() (*internal.Definition, error) {
jww.INFO.Printf("Using unsigned certificates for first start...") jww.INFO.Printf("Using unsigned certificates for first start...")
} }
def.Gateway.Address = p.Gateway.Address
var GwTlsCerts []byte var GwTlsCerts []byte
if p.Gateway.Paths.Cert != "" { if p.Gateway.Paths.Cert != "" {
...@@ -298,7 +300,7 @@ func createNdf(def *internal.Definition, params *Params) *ndf.NetworkDefinition ...@@ -298,7 +300,7 @@ func createNdf(def *internal.Definition, params *Params) *ndf.NetworkDefinition
// Build our gateway // Build our gateway
ourGateway := ndf.Gateway{ ourGateway := ndf.Gateway{
ID: def.Gateway.ID.Marshal(), ID: def.Gateway.ID.Marshal(),
Address: def.Gateway.Address, Address: "0.0.0.0",
TlsCertificate: string(def.Gateway.TlsCert), TlsCertificate: string(def.Gateway.TlsCert),
} }
......
...@@ -8,7 +8,7 @@ node: ...@@ -8,7 +8,7 @@ node:
key: "~/.elixxir/key.pem" key: "~/.elixxir/key.pem"
log: "~/.elixxir/server.log" log: "~/.elixxir/server.log"
errOutput: "~/.elixxir/error.out" errOutput: "~/.elixxir/error.out"
address: "127.0.0.1" listeningAddress: "127.0.0.1"
port: 80 port: 80
database: database:
name: "name" name: "name"
......
...@@ -52,13 +52,6 @@ func StartServer(vip *viper.Viper) error { ...@@ -52,13 +52,6 @@ func StartServer(vip *viper.Viper) error {
jww.INFO.Printf("Loaded params: %+v", params) jww.INFO.Printf("Loaded params: %+v", params)
//Check that there is a gateway
if len(params.Gateway.Address) < 1 {
// No gateways in config file or passed via command line
return errors.New("Error: No gateway specified! Add to" +
" configuration file!")
}
// Initialize the backend // Initialize the backend
jww.INFO.Printf("Initalizing the backend") jww.INFO.Printf("Initalizing the backend")
dbAddress := params.Database.Address dbAddress := params.Database.Address
......
...@@ -156,17 +156,12 @@ func CreateServerInstance(def *Definition, makeImplementation func(*Instance) *n ...@@ -156,17 +156,12 @@ func CreateServerInstance(def *Definition, makeImplementation func(*Instance) *n
} }
// Add gateways to host object // Add gateways to host object
if instance.definition.Gateway.Address != "" { _, err = instance.network.AddHost(&id.TempGateway,
_, err := instance.network.AddHost(&id.TempGateway, "", instance.definition.Gateway.TlsCert, false, true)
instance.definition.Gateway.Address, instance.definition.Gateway.TlsCert, false, true)
if err != nil { if err != nil {
errMsg := fmt.Sprintf("Count not add gateway %s as host: %+v", errMsg := fmt.Sprintf("Count not add gateway %s as host: %+v",
instance.definition.Gateway.ID, err) instance.definition.Gateway.ID, err)
return nil, errors.New(errMsg) return nil, errors.New(errMsg)
}
} else {
jww.WARN.Printf("No Gateway avalible, starting without gateway")
} }
jww.INFO.Printf("Network Interface Initilized for Node ") jww.INFO.Printf("Network Interface Initilized for Node ")
...@@ -246,7 +241,7 @@ func (i *Instance) RestartNetwork(makeImplementation func(*Instance) *node.Imple ...@@ -246,7 +241,7 @@ func (i *Instance) RestartNetwork(makeImplementation func(*Instance) *node.Imple
return err return err
} }
_, err = i.network.AddHost(i.definition.Gateway.ID, i.definition.Gateway.Address, _, err = i.network.AddHost(i.definition.Gateway.ID, "",
i.definition.Gateway.TlsCert, false, true) i.definition.Gateway.TlsCert, false, true)
i.consensus.SetProtoComms(i.network.ProtoComms) i.consensus.SetProtoComms(i.network.ProtoComms)
......
...@@ -88,15 +88,11 @@ func isValidAuth(instance *internal.Instance, auth *connect.Auth) bool { ...@@ -88,15 +88,11 @@ func isValidAuth(instance *internal.Instance, auth *connect.Auth) bool {
expectedGatewayID := instance.GetID().DeepCopy() expectedGatewayID := instance.GetID().DeepCopy()
expectedGatewayID.SetType(id.Gateway) expectedGatewayID.SetType(id.Gateway)
// Get the gateway address
ourGatewayAddress := instance.GetDefinition().Gateway.Address
// If this is the first poll received, check that the message is authenticated and // If this is the first poll received, check that the message is authenticated and
// that the sender has a temporary gateway ID and that // that the sender has a temporary gateway ID and that
// the sender sends from the address specified in our configuration // the sender sends from the address specified in our configuration
if !instance.IsAfterFirstPoll() { if !instance.IsAfterFirstPoll() {
if !auth.IsAuthenticated || !senderId.Cmp(&id.TempGateway) || if !auth.IsAuthenticated || !senderId.Cmp(&id.TempGateway) {
auth.Sender.GetAddress() != ourGatewayAddress {
return false return false
} }
......
...@@ -541,28 +541,3 @@ func TestReceivePoll_Auth_DoublePoll(t *testing.T) { ...@@ -541,28 +541,3 @@ func TestReceivePoll_Auth_DoublePoll(t *testing.T) {
} }
} }
// Test error case in which sender of ReceivePoll has an unexpected address
func TestReceivePoll_Auth_BadAddress(t *testing.T) {
instance, pollMsg, _, _ := setupTests(t, current.REALTIME)
// Set auth with unexpected address
badGatewayAddress := "0.0.0.0:1234"
// Create host and auth
h, _ := connect.NewHost(instance.GetGateway(), badGatewayAddress, nil, false, false)
auth := &connect.Auth{
IsAuthenticated: true,
Sender: h,
}
// Reset auth error
expectedError := connect.AuthError(auth.Sender.GetId()).Error()
_, err := ReceivePoll(pollMsg, &instance, badGatewayAddress, auth)
if err.Error() != expectedError {
t.Errorf("Did not receive expected error!"+
"\n\tExpected: %v"+
"\n\tReceived: %v", connect.AuthError(auth.Sender.GetId()), err)
}
}
...@@ -29,8 +29,6 @@ import ( ...@@ -29,8 +29,6 @@ import (
// Perform the Node registration process with the Permissioning Server // Perform the Node registration process with the Permissioning Server
func RegisterNode(def *internal.Definition, network *node.Comms, permHost *connect.Host) error { func RegisterNode(def *internal.Definition, network *node.Comms, permHost *connect.Host) error {
// We don't check validity here, because the registration server should. // We don't check validity here, because the registration server should.
gw := strings.Split(def.Gateway.Address, ":")
gwPort, _ := strconv.ParseUint(gw[1], 10, 32)
node := strings.Split(def.Address, ":") node := strings.Split(def.Address, ":")
nodePort, _ := strconv.ParseUint(node[1], 10, 32) nodePort, _ := strconv.ParseUint(node[1], 10, 32)
// Attempt Node registration // Attempt Node registration
...@@ -39,8 +37,8 @@ func RegisterNode(def *internal.Definition, network *node.Comms, permHost *conne ...@@ -39,8 +37,8 @@ func RegisterNode(def *internal.Definition, network *node.Comms, permHost *conne
ID: def.ID.Bytes(), ID: def.ID.Bytes(),
ServerTlsCert: string(def.TlsCert), ServerTlsCert: string(def.TlsCert),
GatewayTlsCert: string(def.Gateway.TlsCert), GatewayTlsCert: string(def.Gateway.TlsCert),
GatewayAddress: gw[0], GatewayAddress: "0.0.0.0", // FIXME (Jonah): this is inefficient, but will work for now
GatewayPort: uint32(gwPort), GatewayPort: 80,
ServerAddress: node[0], ServerAddress: node[0],
ServerPort: uint32(nodePort), ServerPort: uint32(nodePort),
RegistrationCode: def.RegistrationCode, RegistrationCode: def.RegistrationCode,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment