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/v7"
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 # MultiCast Discovery:
113 # List of interfaces where to listen for MCD announcements
114 # mcd-listen: ["em0", "igb1"]
115 # Interfaces and intervals (in seconds) where to send MCD announcements
116 # mcd-send: {em0: 60, igb1: 5}
118 # Enable notification email sending
121 # from: nncp@localhost
122 # to: user+file@example.com
125 # from: nncp@localhost
126 # to: user+freq@example.com
128 # # Send some exec commands execution notifications
130 # # bob neighbour's "somehandle" notification
132 # from: nncp+bob@localhost
133 # to: user+somehandle@example.com
135 # # Any neighboor's "anotherhandle"
137 # from: nncp@localhost
138 # to: user+anotherhandle@example.com
144 # DO NOT show anyone your private keys!!!
156 # You should give public keys below to your neighbours
163 # Default self's sendmail command is used for email notifications sending
168 # Example neighbour, most of fields are optional
171 # exchpub: MJACJ...FAI6A
172 # signpub: T4AFC...N2FRQ
173 # noisepub: UBM5K...VI42A
175 # # He is allowed to send email
176 # # exec: {sendmail: ["%s"]}
178 # # Allow incoming files saving in that directory
179 # # incoming: "/home/alice/incoming"
181 # # Transitional nodes path
182 # # via: ["bob", "eve"]
184 # # Inactivity timeout when session with remote peer should be terminated
185 # # onlinedeadline: 1800
187 # # Maximal online session lifetime
188 # # maxonlinetime: 3600
190 # # If neither freq section, nor freq.path exist, then no freqing allowed
192 # # # Allow freqing from that directory
193 # # path: "/home/bob/pub"
194 # # # Send freqed files with chunks
196 # # # Send freqed files with minumal chunk size
198 # # # Maximal allowable freqing file size
202 # # Set maximal packets per second receive and transmit rates
208 # # lan: "[fe80::1234%%igb0]:5400"
209 # # internet: alice.com:3389
212 # # Calls configuration
215 # # cron: "*/2 * * * *"
216 # # onlinedeadline: 1800
217 # # maxonlinetime: 1750
218 # # nice: PRIORITY+10
223 # # when-tx-exists: true
228 # # autotoss-doseen: true
229 # # autotoss-nofile: true
230 # # autotoss-nofreq: true
231 # # autotoss-noexec: true
232 # # autotoss-notrns: true
238 nncp.DefaultSpoolPath,
241 nncp.Base32Codec.EncodeToString(nodeOur.ExchPub[:]),
242 nncp.Base32Codec.EncodeToString(nodeOur.ExchPrv[:]),
243 nncp.Base32Codec.EncodeToString(nodeOur.SignPub[:]),
244 nncp.Base32Codec.EncodeToString(nodeOur.SignPrv[:]),
245 nncp.Base32Codec.EncodeToString(nodeOur.NoisePrv[:]),
246 nncp.Base32Codec.EncodeToString(nodeOur.NoisePub[:]),
248 nncp.Base32Codec.EncodeToString(nodeOur.ExchPub[:]),
249 nncp.Base32Codec.EncodeToString(nodeOur.SignPub[:]),
250 nncp.Base32Codec.EncodeToString(nodeOur.NoisePub[:]),
251 nncp.DefaultSendmailPath,
252 nncp.DefaultSendmailPath,
255 if _, err = nncp.CfgParse([]byte(cfgRaw)); err != nil {