2 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
3 Copyright (C) 2016-2021 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
27 "go.cypherpunks.ru/nncp/v6"
31 fmt.Fprintf(os.Stderr, nncp.UsageHeader())
32 fmt.Fprintln(os.Stderr, "nncp-cfgnew -- generate new configuration and keys\nOptions:")
38 noComments = flag.Bool("nocomments", false, "Do not include descriptive comments")
39 version = flag.Bool("version", false, "Print version information")
40 warranty = flag.Bool("warranty", false, "Print warranty information")
42 log.SetFlags(log.Lshortfile)
46 fmt.Println(nncp.Warranty)
50 fmt.Println(nncp.VersionGet())
53 nodeOur, err := nncp.NewNodeGenerate()
59 cfgRaw = fmt.Sprintf(`{
64 # DO NOT show anyone your private keys!!!
80 exec: {sendmail: ["%s"]}
84 nncp.DefaultSpoolPath,
87 nncp.Base32Codec.EncodeToString(nodeOur.ExchPub[:]),
88 nncp.Base32Codec.EncodeToString(nodeOur.ExchPrv[:]),
89 nncp.Base32Codec.EncodeToString(nodeOur.SignPub[:]),
90 nncp.Base32Codec.EncodeToString(nodeOur.SignPrv[:]),
91 nncp.Base32Codec.EncodeToString(nodeOur.NoisePrv[:]),
92 nncp.Base32Codec.EncodeToString(nodeOur.NoisePub[:]),
94 nncp.Base32Codec.EncodeToString(nodeOur.ExchPub[:]),
95 nncp.Base32Codec.EncodeToString(nodeOur.SignPub[:]),
96 nncp.Base32Codec.EncodeToString(nodeOur.NoisePub[:]),
97 nncp.DefaultSendmailPath,
100 cfgRaw = fmt.Sprintf(`{
101 # Path to encrypted packets spool directory
105 # Enforce specified umask usage
107 # Omit progress showing by default
109 # Do not use .hdr files
112 # Enable notification email sending
115 # from: nncp@localhost
116 # to: user+file@example.com
119 # from: nncp@localhost
120 # to: user+freq@example.com
122 # # Send some exec commands execution notifications
124 # # bob neighbour's "somehandle" notification
126 # from: nncp+bob@localhost
127 # to: user+somehandle@example.com
129 # # Any neighboor's "anotherhandle"
131 # from: nncp@localhost
132 # to: user+anotherhandle@example.com
138 # DO NOT show anyone your private keys!!!
150 # You should give public keys below to your neighbours
157 # Default self's sendmail command is used for email notifications sending
162 # Example neighbour, most of fields are optional
165 # exchpub: MJACJ...FAI6A
166 # signpub: T4AFC...N2FRQ
167 # noisepub: UBM5K...VI42A
169 # # He is allowed to send email
170 # # exec: {sendmail: ["%s"]}
172 # # Allow incoming files saving in that directory
173 # # incoming: "/home/alice/incoming"
175 # # Transitional nodes path
176 # # via: ["bob", "eve"]
178 # # Inactivity timeout when session with remote peer should be terminated
179 # # onlinedeadline: 1800
181 # # Maximal online session lifetime
182 # # maxonlinetime: 3600
184 # # If neither freq section, nor freq.path exist, then no freqing allowed
186 # # # Allow freqing from that directory
187 # # path: "/home/bob/pub"
188 # # # Send freqed files with chunks
190 # # # Send freqed files with minumal chunk size
192 # # # Maximal allowable freqing file size
196 # # Set maximal packets per second receive and transmit rates
202 # # lan: "[fe80::1234%%igb0]:5400"
203 # # internet: alice.com:3389
206 # # Calls configuration
209 # # cron: "*/2 * * * *"
210 # # onlinedeadline: 1800
211 # # maxonlinetime: 1750
212 # # nice: PRIORITY+10
217 # # when-tx-exists: true
221 # # autotoss-doseen: true
222 # # autotoss-nofile: true
223 # # autotoss-nofreq: true
224 # # autotoss-noexec: true
225 # # autotoss-notrns: true
231 nncp.DefaultSpoolPath,
234 nncp.Base32Codec.EncodeToString(nodeOur.ExchPub[:]),
235 nncp.Base32Codec.EncodeToString(nodeOur.ExchPrv[:]),
236 nncp.Base32Codec.EncodeToString(nodeOur.SignPub[:]),
237 nncp.Base32Codec.EncodeToString(nodeOur.SignPrv[:]),
238 nncp.Base32Codec.EncodeToString(nodeOur.NoisePrv[:]),
239 nncp.Base32Codec.EncodeToString(nodeOur.NoisePub[:]),
241 nncp.Base32Codec.EncodeToString(nodeOur.ExchPub[:]),
242 nncp.Base32Codec.EncodeToString(nodeOur.SignPub[:]),
243 nncp.Base32Codec.EncodeToString(nodeOur.NoisePub[:]),
244 nncp.DefaultSendmailPath,
245 nncp.DefaultSendmailPath,
248 if _, err = nncp.CfgParse([]byte(cfgRaw)); err != nil {