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/v4"
31 fmt.Fprintf(os.Stderr, nncp.UsageHeader())
32 fmt.Fprintln(os.Stderr, "nncp-cfgnew -- generate new configuration and keys\nOptions:")
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()
55 noisePub := nncp.ToBase32(nodeOur.NoisePub[:])
57 Self: &nncp.NodeOurYAML{
58 Id: nodeOur.Id.String(),
59 ExchPub: nncp.ToBase32(nodeOur.ExchPub[:]),
60 ExchPrv: nncp.ToBase32(nodeOur.ExchPrv[:]),
61 SignPub: nncp.ToBase32(nodeOur.SignPub[:]),
62 SignPrv: nncp.ToBase32(nodeOur.SignPrv[:]),
63 NoisePub: nncp.ToBase32(nodeOur.NoisePub[:]),
64 NoisePrv: nncp.ToBase32(nodeOur.NoisePrv[:]),
66 Neigh: map[string]nncp.NodeYAML{
67 "self": nncp.NodeYAML{
68 Id: nodeOur.Id.String(),
69 ExchPub: nncp.ToBase32(nodeOur.ExchPub[:]),
70 SignPub: nncp.ToBase32(nodeOur.SignPub[:]),
72 Exec: map[string][]string{
73 "sendmail": []string{nncp.DefaultSendmailPath},
77 Spool: nncp.DefaultSpoolPath,
78 Log: nncp.DefaultLogPath,
80 raw, err := yaml.Marshal(&cfg)
84 fmt.Print(string(raw))