Skip to content
Snippets Groups Projects
Commit 9555871e authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

changed how the serve rimpl is created. some tests still broken

parent 3369180a
No related branches found
No related tags found
No related merge requests found
Showing with 126 additions and 5 deletions
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
...@@ -8,21 +8,27 @@ ...@@ -8,21 +8,27 @@
package cmd package cmd
import ( import (
"encoding/base64"
"encoding/json" "encoding/json"
"fmt"
"github.com/pkg/errors"
"gitlab.com/elixxir/crypto/csprng" "gitlab.com/elixxir/crypto/csprng"
"gitlab.com/elixxir/crypto/large"
"gitlab.com/elixxir/crypto/signature" "gitlab.com/elixxir/crypto/signature"
"gitlab.com/elixxir/primitives/circuit"
"gitlab.com/elixxir/primitives/id" "gitlab.com/elixxir/primitives/id"
"gitlab.com/elixxir/server/globals" "gitlab.com/elixxir/server/globals"
"gitlab.com/elixxir/server/io" "gitlab.com/elixxir/server/io"
"gitlab.com/elixxir/server/node" "gitlab.com/elixxir/server/node"
"gitlab.com/elixxir/server/server" "gitlab.com/elixxir/server/server"
"gitlab.com/elixxir/server/services"
"io/ioutil" "io/ioutil"
"time" "time"
//"encoding/binary" //"encoding/binary"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper" "github.com/spf13/viper"
"gitlab.com/elixxir/server/server/conf" "gitlab.com/elixxir/server/cmd/conf"
//"gitlab.com/elixxir/comms/connect" //"gitlab.com/elixxir/comms/connect"
//"gitlab.com/elixxir/comms/node" //"gitlab.com/elixxir/comms/node"
...@@ -128,8 +134,20 @@ func StartServer(vip *viper.Viper) { ...@@ -128,8 +134,20 @@ func StartServer(vip *viper.Viper) {
//TODO: store DSA key for NDF //TODO: store DSA key for NDF
def := convertParams(params, pubKey, privateKey)
def.UserRegistry = userDatabase
def.ResourceMonitor = resourceMonitor
PanicHandler := func(g, m string, err error) {
jww.FATAL.Panicf(fmt.Sprintf("Error in module %s of graph %s: %+v", g,
m, err))
}
def.GraphGenerator = services.NewGraphGenerator(4, PanicHandler,
uint8(runtime.NumCPU()), 4, 0.0)
// Create instance // Create instance
instance := server.CreateServerInstance(params, userDatabase, pubKey, privateKey, resourceMonitor) instance := server.CreateServerInstance(nil)
if instance.IsFirstNode() { if instance.IsFirstNode() {
instance.InitFirstNode() instance.InitFirstNode()
...@@ -163,3 +181,106 @@ func PopulateDummyUsers(ur globals.UserRegistry, grp *cyclic.Group) { ...@@ -163,3 +181,106 @@ func PopulateDummyUsers(ur globals.UserRegistry, grp *cyclic.Group) {
ur.UpsertUser(u) ur.UpsertUser(u)
} }
} }
func convertParams(params *conf.Params, pub *signature.DSAPublicKey,
priv *signature.DSAPrivateKey) *server.Definition {
def := server.Definition{}
def.Flags.KeepBuffers = params.KeepBuffers
def.Flags.SkipReg = params.SkipReg
def.Flags.Verbose = params.Verbose
var tlsCert, tlsKey []byte
var err error
if params.Node.Paths.Cert != "" {
tlsCert, err = ioutil.ReadFile(params.Node.Paths.Cert)
if err != nil {
jww.FATAL.Panicf("Could not load TLS Cert: %+v", err)
}
}
if params.Node.Paths.Key != "" {
tlsKey, err = ioutil.ReadFile(params.Node.Paths.Key)
if err != nil {
jww.FATAL.Panicf("Could not load TLS Key: %+v", err)
}
}
var nodes []server.Node
var nodeIDs []*id.Node
var nodeIDDecodeErrorHappened bool
for i := range params.Node.Ids {
nodeID, err := base64.StdEncoding.DecodeString(params.Node.Ids[i])
if err != nil {
// This indicates a server misconfiguration which needs fixing for
// the server to function properly
err = errors.Wrapf(err, "Node ID at index %v failed to decode", i)
jww.ERROR.Print(err)
nodeIDDecodeErrorHappened = true
}
n := server.Node{
ID: id.NewNodeFromBytes(nodeID),
TLS_Cert: tlsCert,
Address: params.Node.Addresses[i],
}
nodes = append(nodes, n)
nodeIDs = append(nodeIDs, id.NewNodeFromBytes(nodeID))
}
if nodeIDDecodeErrorHappened {
jww.FATAL.Panic("One or more node IDs didn't base64 decode correctly")
}
def.ID = nodes[params.Index].ID
def.Address = nodes[params.Index].Address
def.TLS_Cert = tlsCert
def.TLS_Key = tlsKey
def.LogPath = params.Node.Paths.Log
def.MetricLogPath = params.Metrics.Log
def.Gateway.Address = params.Gateways.Addresses[params.Index]
var GWtlsCert []byte
if params.Gateways.Paths.Cert != "" {
GWtlsCert, err = ioutil.ReadFile(params.Gateways.Paths.Cert)
if err != nil {
jww.FATAL.Panicf("Could not load gateway TLS Cert: %+v", err)
}
}
def.Gateway.TLS_Cert = GWtlsCert
def.Gateway.ID = def.ID.NewGateway()
def.BatchSize = params.Batch
def.CmixGroup = params.Groups.GetCMix()
def.E2EGroup = params.Groups.GetE2E()
def.Topology = circuit.New(nodeIDs)
def.Nodes = nodes
var PermTlsCert []byte
if params.Permissioning.Paths.Cert != "" {
tlsCert, err = ioutil.ReadFile(params.Permissioning.Paths.Cert)
if err != nil {
jww.FATAL.Panicf("Could not load permissioning TLS Cert: %+v", err)
}
}
def.Permissioning.TLS_Cert = PermTlsCert
def.Permissioning.Address = params.Permissioning.Address
dsaParams := signature.CustomDSAParams(def.CmixGroup.GetP(),
def.CmixGroup.GetQ(), def.CmixGroup.GetG())
def.Permissioning.DSA_PubKey = signature.ReconstructPublicKey(dsaParams,
large.NewIntFromString(params.Permissioning.PublicKey, 16))
return &def
}
...@@ -24,7 +24,7 @@ const PERFORMANCE_CHECK_PERIOD = time.Duration(2) * time.Minute ...@@ -24,7 +24,7 @@ const PERFORMANCE_CHECK_PERIOD = time.Duration(2) * time.Minute
// MonitorMemoryUsage Checks and prints a warning every time thread or memory // MonitorMemoryUsage Checks and prints a warning every time thread or memory
// usage fo the system jumps a designated amount. // usage fo the system jumps a designated amount.
func MonitorMemoryUsage() measure.ResourceMonitor { func MonitorMemoryUsage() *measure.ResourceMonitor {
resourceMonitor := measure.ResourceMonitor{} resourceMonitor := measure.ResourceMonitor{}
...@@ -158,7 +158,7 @@ func MonitorMemoryUsage() measure.ResourceMonitor { ...@@ -158,7 +158,7 @@ func MonitorMemoryUsage() measure.ResourceMonitor {
}() }()
return resourceMonitor return &resourceMonitor
} }
func truncateFuncName(name string) string { func truncateFuncName(name string) string {
......
...@@ -5,7 +5,7 @@ import: ...@@ -5,7 +5,7 @@ import:
repo: git@gitlab.com:elixxir/crypto repo: git@gitlab.com:elixxir/crypto
vcs: git vcs: git
- package: gitlab.com/elixxir/comms - package: gitlab.com/elixxir/comms
version: dispatch version: xx-1377-signedmessage
repo: git@gitlab.com:elixxir/comms repo: git@gitlab.com:elixxir/comms
vcs: git vcs: git
- package: gitlab.com/elixxir/primitives - package: gitlab.com/elixxir/primitives
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment