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!!!
77 exec: {sendmail: ["%s"]}
81 nncp.DefaultSpoolPath,
84 nncp.ToBase32(nodeOur.ExchPub[:]),
85 nncp.ToBase32(nodeOur.ExchPrv[:]),
86 nncp.ToBase32(nodeOur.SignPub[:]),
87 nncp.ToBase32(nodeOur.SignPrv[:]),
88 nncp.ToBase32(nodeOur.NoisePub[:]),
89 nncp.ToBase32(nodeOur.NoisePrv[:]),
91 nncp.ToBase32(nodeOur.ExchPub[:]),
92 nncp.ToBase32(nodeOur.SignPub[:]),
93 nncp.ToBase32(nodeOur.NoisePub[:]),
94 nncp.DefaultSendmailPath,
97 cfgRaw = fmt.Sprintf(`{
98 # Path to encrypted packets spool directory
103 # Enable notification email sending
106 # from: nncp@localhost
107 # to: user+file@example.com
110 # from: nncp@localhost
111 # to: user+freq@example.com
116 # DO NOT show anyone your private keys!!!
127 # You should give public keys below to your neighbours
134 # Default self's sendmail command is used for email notifications sending
139 # Example neighbour, most of fields are optional
142 # exchpub: MJACJ...FAI6A
143 # signpub: T4AFC...N2FRQ
144 # noisepub: UBM5K...VI42A
146 # # He is allowed to send email
147 # exec: {sendmail: ["/usr/sbin/sendmail"]}
149 # # Allow incoming files saving in that directory
150 # incoming: "/home/alice/incoming"
152 # # Transitional nodes path
153 # via: ["bob", "eve"]
155 # # Inactivity timeout when session with remote peer should be terminated
156 # onlinedeadline: 1800
158 # # Maximal online session lifetime
159 # maxonlinetime: 3600
161 # # Allow freqing from that directory
162 # freq: "/home/bob/pub"
163 # # Send freqed files with chunks
165 # # Send freqed files with minumal chunk size
168 # # Set maximal packets per second receive and transmit rates
174 # lan: "[fe80::1234%%igb0]:5400"
175 # internet: alice.com:3389
178 # # Calls configuration
181 # cron: "*/2 * * * *"
182 # onlinedeadline: 1800
183 # maxonlinetime: 1750
194 nncp.DefaultSpoolPath,
197 nncp.ToBase32(nodeOur.ExchPub[:]),
198 nncp.ToBase32(nodeOur.ExchPrv[:]),
199 nncp.ToBase32(nodeOur.SignPub[:]),
200 nncp.ToBase32(nodeOur.SignPrv[:]),
201 nncp.ToBase32(nodeOur.NoisePub[:]),
202 nncp.ToBase32(nodeOur.NoisePrv[:]),
204 nncp.ToBase32(nodeOur.ExchPub[:]),
205 nncp.ToBase32(nodeOur.SignPub[:]),
206 nncp.ToBase32(nodeOur.NoisePub[:]),
207 nncp.DefaultSendmailPath,
210 if _, err = nncp.CfgParse([]byte(cfgRaw)); err != nil {