Skip to content
Snippets Groups Projects
Commit 5c24177d authored by dylan.peiry's avatar dylan.peiry
Browse files

parsing node config from file passed as argument

parent 56d6f635
No related branches found
No related tags found
No related merge requests found
module freenet
go 1.19
require gopkg.in/yaml.v2 v2.4.0
go.sum 0 → 100644
package helper
import "fmt"
type NodeWrapper struct {
Resource Resource `yaml:"resource"`
Stora0lwe
}
import (
"fmt"
)
type Node struct {
Resource Resource `json:"resource"`
......
resource:
name: "b"
address: "127.0.0.11"
storage:
data:
- id: 10
resource:
name: "b"
......
resource:
name: "c"
address: "127.0.0.12"
storage:
data:
- id: 15
resource:
name: "c"
......
No preview for this file type
......@@ -3,25 +3,42 @@ package main
import (
"fmt"
"freenet/helper"
"gopkg.in/yaml.v2"
"os"
)
var node helper.Node
func main() {
//read arguments passed to the program
//./server <port> <config_number> <mode>
// port is the port the server will listen on
// config_number represents de number of the neighbour-x.yaml file to load
// mode is INIT or WAIT (INIT for the server that will run the search, WAIT for the servers that will listen)
args := os.Args
configFile := fmt.Sprintf("neighbour-%s.yaml", args[1])
node = parseConfigFile(configFile)
fmt.Printf("Node{%s}", node)
//initialize socket connection
//if INIT
//run the search algorithm and send message to the servers
//if WAIT
//wait and listen for new connections
//debugTypesPrint()
}
debugTypesPrint()
func parseConfigFile(file string) helper.Node {
var node helper.Node
yamlFile, err := os.ReadFile(file)
if err != nil {
panic(err)
}
err = yaml.Unmarshal(yamlFile, &node)
return node
}
func parseNodeConfig() {
func usage() {
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment