unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob e3502eb64451701b334eebccccb9169010185a77 4005 bytes (raw)
name: gnu/packages/patches/yggdrasil-extra-config.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
 
diff --git a/cmd/yggdrasil/main.go b/cmd/yggdrasil/main.go
index 813e950..08d35cc 100644
--- a/cmd/yggdrasil/main.go
+++ b/cmd/yggdrasil/main.go
@@ -40,11 +40,12 @@ type node struct {
 	admin     module.Module // admin.AdminSocket
 }
 
-func readConfig(useconf *bool, useconffile *string, normaliseconf *bool) *config.NodeConfig {
+func readConfig(useconf *bool, useconffile *string, extraconffile *string, normaliseconf *bool) *config.NodeConfig {
 	// Use a configuration file. If -useconf, the configuration will be read
 	// from stdin. If -useconffile, the configuration will be read from the
 	// filesystem.
 	var conf []byte
+	var extraconf []byte
 	var err error
 	if *useconffile != "" {
 		// Read the file from the filesystem
@@ -56,6 +57,21 @@ func readConfig(useconf *bool, useconffile *string, normaliseconf *bool) *config
 	if err != nil {
 		panic(err)
 	}
+	if *extraconffile != "" {
+		extraconf, err = ioutil.ReadFile(*extraconffile);
+	}
+	if err != nil {
+		panic(err)
+	}
+	// Generate a new configuration - this gives us a set of sane defaults -
+	// then parse the configuration we loaded above on top of it. The effect
+	// of this is that any configuration item that is missing from the provided
+	// configuration will use a sane default.
+	cfg := config.GenerateConfig()
+	var confs [2][]byte
+	confs[0]=conf
+	confs[1]=extraconf
+	for _, conf := range confs {
 	// If there's a byte order mark - which Windows 10 is now incredibly fond of
 	// throwing everywhere when it's converting things into UTF-16 for the hell
 	// of it - remove it and decode back down into UTF-8. This is necessary
@@ -69,11 +85,6 @@ func readConfig(useconf *bool, useconffile *string, normaliseconf *bool) *config
 			panic(err)
 		}
 	}
-	// Generate a new configuration - this gives us a set of sane defaults -
-	// then parse the configuration we loaded above on top of it. The effect
-	// of this is that any configuration item that is missing from the provided
-	// configuration will use a sane default.
-	cfg := config.GenerateConfig()
 	var dat map[string]interface{}
 	if err := hjson.Unmarshal(conf, &dat); err != nil {
 		panic(err)
@@ -112,6 +123,7 @@ func readConfig(useconf *bool, useconffile *string, normaliseconf *bool) *config
 	if err = mapstructure.Decode(dat, &cfg); err != nil {
 		panic(err)
 	}
+	}
 	return cfg
 }
 
@@ -164,6 +176,7 @@ func main() {
 	genconf := flag.Bool("genconf", false, "print a new config to stdout")
 	useconf := flag.Bool("useconf", false, "read HJSON/JSON config from stdin")
 	useconffile := flag.String("useconffile", "", "read HJSON/JSON config from specified file path")
+	extraconffile := flag.String("extraconffile", "", "extra (usually private) HJSON/JSON config from specified file path")
 	normaliseconf := flag.Bool("normaliseconf", false, "use in combination with either -useconf or -useconffile, outputs your configuration normalised")
 	confjson := flag.Bool("json", false, "print configuration from -genconf or -normaliseconf as JSON instead of HJSON")
 	autoconf := flag.Bool("autoconf", false, "automatic mode (dynamic IP, peer with IPv6 neighbors)")
@@ -187,7 +200,7 @@ func main() {
 		cfg = config.GenerateConfig()
 	case *useconffile != "" || *useconf:
 		// Read the configuration from either stdin or from the filesystem
-		cfg = readConfig(useconf, useconffile, normaliseconf)
+		cfg = readConfig(useconf, useconffile, extraconffile, normaliseconf)
 		// If the -normaliseconf option was specified then remarshal the above
 		// configuration and print it back to stdout. This lets the user update
 		// their configuration file with newly mapped names (like above) or to
@@ -332,7 +345,7 @@ func main() {
 			goto exit
 		case _ = <-r:
 			if *useconffile != "" {
-				cfg = readConfig(useconf, useconffile, normaliseconf)
+				cfg = readConfig(useconf, useconffile, extraconffile, normaliseconf)
 				logger.Infoln("Reloading configuration from", *useconffile)
 				n.core.UpdateConfig(cfg)
 				n.tuntap.UpdateConfig(cfg)

debug log:

solving e3502eb644 ...
found e3502eb644 in https://yhetil.org/guix-patches/20200611155656.7ece9c24@riseup.net/ ||
	https://yhetil.org/guix-patches/20200713162330.79213853@riseup.net/ ||
	https://yhetil.org/guix-patches/20200903195947.7b4e10c8@riseup.net/

applying [1/1] https://yhetil.org/guix-patches/20200611155656.7ece9c24@riseup.net/
diff --git a/gnu/packages/patches/yggdrasil-extra-config.patch b/gnu/packages/patches/yggdrasil-extra-config.patch
new file mode 100644
index 0000000000..e3502eb644

1:12: space before tab in indent.
 	admin     module.Module // admin.AdminSocket
1:14: trailing whitespace.
 
1:17: space before tab in indent.
 	// Use a configuration file. If -useconf, the configuration will be read
1:18: space before tab in indent.
 	// from stdin. If -useconffile, the configuration will be read from the
1:19: space before tab in indent.
 	// filesystem.
Checking patch gnu/packages/patches/yggdrasil-extra-config.patch...
Applied patch gnu/packages/patches/yggdrasil-extra-config.patch cleanly.
warning: squelched 39 whitespace errors
warning: 44 lines add whitespace errors.

skipping https://yhetil.org/guix-patches/20200713162330.79213853@riseup.net/ for e3502eb644
skipping https://yhetil.org/guix-patches/20200903195947.7b4e10c8@riseup.net/ for e3502eb644
index at:
100644 e3502eb64451701b334eebccccb9169010185a77	gnu/packages/patches/yggdrasil-extra-config.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).