/* NNCP -- Node to Node copy, utilities for store-and-forward data exchange Copyright (C) 2016-2019 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ // Generate new NNCP node keys and configuration file package main import ( "flag" "fmt" "os" "go.cypherpunks.ru/nncp/v5" ) func usage() { fmt.Fprintf(os.Stderr, nncp.UsageHeader()) fmt.Fprintln(os.Stderr, "nncp-cfgnew -- generate new configuration and keys\nOptions:") flag.PrintDefaults() } func main() { var ( noComments = flag.Bool("nocomments", false, "Do not include descriptive comments") version = flag.Bool("version", false, "Print version information") warranty = flag.Bool("warranty", false, "Print warranty information") ) flag.Usage = usage flag.Parse() if *warranty { fmt.Println(nncp.Warranty) return } if *version { fmt.Println(nncp.VersionGet()) return } nodeOur, err := nncp.NewNodeGenerate() if err != nil { panic(err) } var cfgRaw string if *noComments { cfgRaw = fmt.Sprintf(`{ spool: %s log: %s self: { # DO NOT show anyone your private keys!!! id: %s exchpub: %s exchprv: %s signpub: %s signprv: %s noiseprv: %s noisepub: %s } neigh: { self: { id: %s exchpub: %s signpub: %s noisepub: %s exec: {sendmail: ["%s"]} } } }`, nncp.DefaultSpoolPath, nncp.DefaultLogPath, nodeOur.Id.String(), nncp.ToBase32(nodeOur.ExchPub[:]), nncp.ToBase32(nodeOur.ExchPrv[:]), nncp.ToBase32(nodeOur.SignPub[:]), nncp.ToBase32(nodeOur.SignPrv[:]), nncp.ToBase32(nodeOur.NoisePub[:]), nncp.ToBase32(nodeOur.NoisePrv[:]), nodeOur.Id.String(), nncp.ToBase32(nodeOur.ExchPub[:]), nncp.ToBase32(nodeOur.SignPub[:]), nncp.ToBase32(nodeOur.NoisePub[:]), nncp.DefaultSendmailPath, ) } else { cfgRaw = fmt.Sprintf(`{ # Path to encrypted packets spool directory spool: %s # Path to log file log: %s # Enforce specified umask usage # umask: "022" # Enable notification email sending # notify: { # file: { # from: nncp@localhost # to: user+file@example.com # } # freq: { # from: nncp@localhost # to: user+freq@example.com # } # } self: { # DO NOT show anyone your private keys!!! id: %s exchpub: %s exchprv: %s signpub: %s signprv: %s noiseprv: %s noisepub: %s } neigh: { self: { # You should give public keys below to your neighbours id: %s exchpub: %s signpub: %s noisepub: %s exec: { # Default self's sendmail command is used for email notifications sending sendmail: ["%s"] } } # Example neighbour, most of fields are optional # alice: { # id: XJZBK...65IJQ # exchpub: MJACJ...FAI6A # signpub: T4AFC...N2FRQ # noisepub: UBM5K...VI42A # # # He is allowed to send email # exec: {sendmail: ["/usr/sbin/sendmail"]} # # # Allow incoming files saving in that directory # incoming: "/home/alice/incoming" # # # Transitional nodes path # via: ["bob", "eve"] # # # Inactivity timeout when session with remote peer should be terminated # onlinedeadline: 1800 # # # Maximal online session lifetime # maxonlinetime: 3600 # # # Allow freqing from that directory # freq: "/home/bob/pub" # # Send freqed files with chunks # freqchunked: 1024 # # Send freqed files with minumal chunk size # freqminsize: 2048 # # # Set maximal packets per second receive and transmit rates # rxrate: 10 # txrate: 20 # # # Address aliases # addrs: { # lan: "[fe80::1234%%igb0]:5400" # internet: alice.com:3389 # } # # # Calls configuration # calls: [ # { # cron: "*/2 * * * *" # onlinedeadline: 1800 # maxonlinetime: 1750 # nice: PRIORITY+10 # rxrate: 10 # txrate: 20 # xx: rx # addr: lan # }, # ] # } } }`, nncp.DefaultSpoolPath, nncp.DefaultLogPath, nodeOur.Id.String(), nncp.ToBase32(nodeOur.ExchPub[:]), nncp.ToBase32(nodeOur.ExchPrv[:]), nncp.ToBase32(nodeOur.SignPub[:]), nncp.ToBase32(nodeOur.SignPrv[:]), nncp.ToBase32(nodeOur.NoisePub[:]), nncp.ToBase32(nodeOur.NoisePrv[:]), nodeOur.Id.String(), nncp.ToBase32(nodeOur.ExchPub[:]), nncp.ToBase32(nodeOur.SignPub[:]), nncp.ToBase32(nodeOur.NoisePub[:]), nncp.DefaultSendmailPath, ) } if _, err = nncp.CfgParse([]byte(cfgRaw)); err != nil { panic(err) } fmt.Println(cfgRaw) }