2 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
3 Copyright (C) 2016-2019 Sergey Matveev <stargrave@stargrave.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 // Generate new NNCP node keys and configuration file
26 "go.cypherpunks.ru/nncp/v5"
30 fmt.Fprintf(os.Stderr, nncp.UsageHeader())
31 fmt.Fprintln(os.Stderr, "nncp-cfgnew -- generate new configuration and keys\nOptions:")
37 noComments = flag.Bool("nocomments", false, "Do not include descriptive comments")
38 version = flag.Bool("version", false, "Print version information")
39 warranty = flag.Bool("warranty", false, "Print warranty information")
44 fmt.Println(nncp.Warranty)
48 fmt.Println(nncp.VersionGet())
51 nodeOur, err := nncp.NewNodeGenerate()
57 cfgRaw = fmt.Sprintf(`{
62 # DO NOT show anyone your private keys!!!
78 exec: {sendmail: ["%s"]}
82 nncp.DefaultSpoolPath,
85 nncp.ToBase32(nodeOur.ExchPub[:]),
86 nncp.ToBase32(nodeOur.ExchPrv[:]),
87 nncp.ToBase32(nodeOur.SignPub[:]),
88 nncp.ToBase32(nodeOur.SignPrv[:]),
89 nncp.ToBase32(nodeOur.NoisePub[:]),
90 nncp.ToBase32(nodeOur.NoisePrv[:]),
92 nncp.ToBase32(nodeOur.ExchPub[:]),
93 nncp.ToBase32(nodeOur.SignPub[:]),
94 nncp.ToBase32(nodeOur.NoisePub[:]),
95 nncp.DefaultSendmailPath,
98 cfgRaw = fmt.Sprintf(`{
99 # Path to encrypted packets spool directory
103 # Enforce specified umask usage
106 # Enable notification email sending
109 # from: nncp@localhost
110 # to: user+file@example.com
113 # from: nncp@localhost
114 # to: user+freq@example.com
116 # # Send some exec commands execution notifications
118 # # bob neighbour's "somehandle" notification
120 # from: nncp+bob@localhost
121 # to: user+somehandle@example.com
123 # # Any neighboor's "anotherhandle"
125 # from: nncp@localhost
126 # to: user+anotherhandle@example.com
132 # DO NOT show anyone your private keys!!!
144 # You should give public keys below to your neighbours
151 # Default self's sendmail command is used for email notifications sending
156 # Example neighbour, most of fields are optional
159 # exchpub: MJACJ...FAI6A
160 # signpub: T4AFC...N2FRQ
161 # noisepub: UBM5K...VI42A
163 # # He is allowed to send email
164 # # exec: {sendmail: ["%s"]}
166 # # Allow incoming files saving in that directory
167 # # incoming: "/home/alice/incoming"
169 # # Transitional nodes path
170 # # via: ["bob", "eve"]
172 # # Inactivity timeout when session with remote peer should be terminated
173 # # onlinedeadline: 1800
175 # # Maximal online session lifetime
176 # # maxonlinetime: 3600
178 # # If neither freq section, nor freq.path exist, then no freqing allowed
180 # # # Allow freqing from that directory
181 # # path: "/home/bob/pub"
182 # # # Send freqed files with chunks
184 # # # Send freqed files with minumal chunk size
186 # # # Maximal allowable freqing file size
190 # # Set maximal packets per second receive and transmit rates
196 # # lan: "[fe80::1234%%igb0]:5400"
197 # # internet: alice.com:3389
200 # # Calls configuration
203 # # cron: "*/2 * * * *"
204 # # onlinedeadline: 1800
205 # # maxonlinetime: 1750
206 # # nice: PRIORITY+10
216 nncp.DefaultSpoolPath,
219 nncp.ToBase32(nodeOur.ExchPub[:]),
220 nncp.ToBase32(nodeOur.ExchPrv[:]),
221 nncp.ToBase32(nodeOur.SignPub[:]),
222 nncp.ToBase32(nodeOur.SignPrv[:]),
223 nncp.ToBase32(nodeOur.NoisePub[:]),
224 nncp.ToBase32(nodeOur.NoisePrv[:]),
226 nncp.ToBase32(nodeOur.ExchPub[:]),
227 nncp.ToBase32(nodeOur.SignPub[:]),
228 nncp.ToBase32(nodeOur.NoisePub[:]),
229 nncp.DefaultSendmailPath,
230 nncp.DefaultSendmailPath,
233 if _, err = nncp.CfgParse([]byte(cfgRaw)); err != nil {