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
26 "go.cypherpunks.ru/nncp/v6"
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.Base32Codec.EncodeToString(nodeOur.ExchPub[:]),
86 nncp.Base32Codec.EncodeToString(nodeOur.ExchPrv[:]),
87 nncp.Base32Codec.EncodeToString(nodeOur.SignPub[:]),
88 nncp.Base32Codec.EncodeToString(nodeOur.SignPrv[:]),
89 nncp.Base32Codec.EncodeToString(nodeOur.NoisePrv[:]),
90 nncp.Base32Codec.EncodeToString(nodeOur.NoisePub[:]),
92 nncp.Base32Codec.EncodeToString(nodeOur.ExchPub[:]),
93 nncp.Base32Codec.EncodeToString(nodeOur.SignPub[:]),
94 nncp.Base32Codec.EncodeToString(nodeOur.NoisePub[:]),
95 nncp.DefaultSendmailPath,
98 cfgRaw = fmt.Sprintf(`{
99 # Path to encrypted packets spool directory
103 # Enforce specified umask usage
105 # Omit progress showing by default
107 # Do not use .hdr files
110 # Enable notification email sending
113 # from: nncp@localhost
114 # to: user+file@example.com
117 # from: nncp@localhost
118 # to: user+freq@example.com
120 # # Send some exec commands execution notifications
122 # # bob neighbour's "somehandle" notification
124 # from: nncp+bob@localhost
125 # to: user+somehandle@example.com
127 # # Any neighboor's "anotherhandle"
129 # from: nncp@localhost
130 # to: user+anotherhandle@example.com
136 # DO NOT show anyone your private keys!!!
148 # You should give public keys below to your neighbours
155 # Default self's sendmail command is used for email notifications sending
160 # Example neighbour, most of fields are optional
163 # exchpub: MJACJ...FAI6A
164 # signpub: T4AFC...N2FRQ
165 # noisepub: UBM5K...VI42A
167 # # He is allowed to send email
168 # # exec: {sendmail: ["%s"]}
170 # # Allow incoming files saving in that directory
171 # # incoming: "/home/alice/incoming"
173 # # Transitional nodes path
174 # # via: ["bob", "eve"]
176 # # Inactivity timeout when session with remote peer should be terminated
177 # # onlinedeadline: 1800
179 # # Maximal online session lifetime
180 # # maxonlinetime: 3600
182 # # If neither freq section, nor freq.path exist, then no freqing allowed
184 # # # Allow freqing from that directory
185 # # path: "/home/bob/pub"
186 # # # Send freqed files with chunks
188 # # # Send freqed files with minumal chunk size
190 # # # Maximal allowable freqing file size
194 # # Set maximal packets per second receive and transmit rates
200 # # lan: "[fe80::1234%%igb0]:5400"
201 # # internet: alice.com:3389
204 # # Calls configuration
207 # # cron: "*/2 * * * *"
208 # # onlinedeadline: 1800
209 # # maxonlinetime: 1750
210 # # nice: PRIORITY+10
215 # # when-tx-exists: true
219 # # autotoss-doseen: true
220 # # autotoss-nofile: true
221 # # autotoss-nofreq: true
222 # # autotoss-noexec: true
223 # # autotoss-notrns: true
229 nncp.DefaultSpoolPath,
232 nncp.Base32Codec.EncodeToString(nodeOur.ExchPub[:]),
233 nncp.Base32Codec.EncodeToString(nodeOur.ExchPrv[:]),
234 nncp.Base32Codec.EncodeToString(nodeOur.SignPub[:]),
235 nncp.Base32Codec.EncodeToString(nodeOur.SignPrv[:]),
236 nncp.Base32Codec.EncodeToString(nodeOur.NoisePrv[:]),
237 nncp.Base32Codec.EncodeToString(nodeOur.NoisePub[:]),
239 nncp.Base32Codec.EncodeToString(nodeOur.ExchPub[:]),
240 nncp.Base32Codec.EncodeToString(nodeOur.SignPub[:]),
241 nncp.Base32Codec.EncodeToString(nodeOur.NoisePub[:]),
242 nncp.DefaultSendmailPath,
243 nncp.DefaultSendmailPath,
246 if _, err = nncp.CfgParse([]byte(cfgRaw)); err != nil {