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!!!
78 exec: {sendmail: ["%s"]}
82 nncp.DefaultSpoolPath,
85 nncp.ToBase32(nodeOur.ExchPub[:]),
86 nncp.ToBase32(nodeOur.ExchPrv[:]),
87 nncp.ToBase32(nodeOur.SignPub[:]),
88 nncp.ToBase32(nodeOur.SignPrv[:]),
89 nncp.ToBase32(nodeOur.NoisePub[:]),
90 nncp.ToBase32(nodeOur.NoisePrv[:]),
92 nncp.ToBase32(nodeOur.ExchPub[:]),
93 nncp.ToBase32(nodeOur.SignPub[:]),
94 nncp.ToBase32(nodeOur.NoisePub[:]),
95 nncp.DefaultSendmailPath,
98 cfgRaw = fmt.Sprintf(`{
99 # Path to encrypted packets spool directory
103 # Enforce specified umask usage
106 # Enable notification email sending
109 # from: nncp@localhost
110 # to: user+file@example.com
113 # from: nncp@localhost
114 # to: user+freq@example.com
119 # DO NOT show anyone your private keys!!!
131 # You should give public keys below to your neighbours
138 # Default self's sendmail command is used for email notifications sending
143 # Example neighbour, most of fields are optional
146 # exchpub: MJACJ...FAI6A
147 # signpub: T4AFC...N2FRQ
148 # noisepub: UBM5K...VI42A
150 # # He is allowed to send email
151 # exec: {sendmail: ["/usr/sbin/sendmail"]}
153 # # Allow incoming files saving in that directory
154 # incoming: "/home/alice/incoming"
156 # # Transitional nodes path
157 # via: ["bob", "eve"]
159 # # Inactivity timeout when session with remote peer should be terminated
160 # onlinedeadline: 1800
162 # # Maximal online session lifetime
163 # maxonlinetime: 3600
165 # # Allow freqing from that directory
166 # freq: "/home/bob/pub"
167 # # Send freqed files with chunks
169 # # Send freqed files with minumal chunk size
172 # # Set maximal packets per second receive and transmit rates
178 # lan: "[fe80::1234%%igb0]:5400"
179 # internet: alice.com:3389
182 # # Calls configuration
185 # cron: "*/2 * * * *"
186 # onlinedeadline: 1800
187 # maxonlinetime: 1750
198 nncp.DefaultSpoolPath,
201 nncp.ToBase32(nodeOur.ExchPub[:]),
202 nncp.ToBase32(nodeOur.ExchPrv[:]),
203 nncp.ToBase32(nodeOur.SignPub[:]),
204 nncp.ToBase32(nodeOur.SignPrv[:]),
205 nncp.ToBase32(nodeOur.NoisePub[:]),
206 nncp.ToBase32(nodeOur.NoisePrv[:]),
208 nncp.ToBase32(nodeOur.ExchPub[:]),
209 nncp.ToBase32(nodeOur.SignPub[:]),
210 nncp.ToBase32(nodeOur.NoisePub[:]),
211 nncp.DefaultSendmailPath,
214 if _, err = nncp.CfgParse([]byte(cfgRaw)); err != nil {