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/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.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
108 # Enable notification email sending
111 # from: nncp@localhost
112 # to: user+file@example.com
115 # from: nncp@localhost
116 # to: user+freq@example.com
118 # # Send some exec commands execution notifications
120 # # bob neighbour's "somehandle" notification
122 # from: nncp+bob@localhost
123 # to: user+somehandle@example.com
125 # # Any neighboor's "anotherhandle"
127 # from: nncp@localhost
128 # to: user+anotherhandle@example.com
134 # DO NOT show anyone your private keys!!!
146 # You should give public keys below to your neighbours
153 # Default self's sendmail command is used for email notifications sending
158 # Example neighbour, most of fields are optional
161 # exchpub: MJACJ...FAI6A
162 # signpub: T4AFC...N2FRQ
163 # noisepub: UBM5K...VI42A
165 # # He is allowed to send email
166 # # exec: {sendmail: ["%s"]}
168 # # Allow incoming files saving in that directory
169 # # incoming: "/home/alice/incoming"
171 # # Transitional nodes path
172 # # via: ["bob", "eve"]
174 # # Inactivity timeout when session with remote peer should be terminated
175 # # onlinedeadline: 1800
177 # # Maximal online session lifetime
178 # # maxonlinetime: 3600
180 # # If neither freq section, nor freq.path exist, then no freqing allowed
182 # # # Allow freqing from that directory
183 # # path: "/home/bob/pub"
184 # # # Send freqed files with chunks
186 # # # Send freqed files with minumal chunk size
188 # # # Maximal allowable freqing file size
192 # # Set maximal packets per second receive and transmit rates
198 # # lan: "[fe80::1234%%igb0]:5400"
199 # # internet: alice.com:3389
202 # # Calls configuration
205 # # cron: "*/2 * * * *"
206 # # onlinedeadline: 1800
207 # # maxonlinetime: 1750
208 # # nice: PRIORITY+10
213 # # when-tx-exists: true
217 # # autotoss-doseen: true
218 # # autotoss-nofile: true
219 # # autotoss-nofreq: true
220 # # autotoss-noexec: true
221 # # autotoss-notrns: true
227 nncp.DefaultSpoolPath,
230 nncp.Base32Codec.EncodeToString(nodeOur.ExchPub[:]),
231 nncp.Base32Codec.EncodeToString(nodeOur.ExchPrv[:]),
232 nncp.Base32Codec.EncodeToString(nodeOur.SignPub[:]),
233 nncp.Base32Codec.EncodeToString(nodeOur.SignPrv[:]),
234 nncp.Base32Codec.EncodeToString(nodeOur.NoisePrv[:]),
235 nncp.Base32Codec.EncodeToString(nodeOur.NoisePub[:]),
237 nncp.Base32Codec.EncodeToString(nodeOur.ExchPub[:]),
238 nncp.Base32Codec.EncodeToString(nodeOur.SignPub[:]),
239 nncp.Base32Codec.EncodeToString(nodeOur.NoisePub[:]),
240 nncp.DefaultSendmailPath,
241 nncp.DefaultSendmailPath,
244 if _, err = nncp.CfgParse([]byte(cfgRaw)); err != nil {