/*
NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2020 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2021 Sergey Matveev <stargrave@stargrave.org>
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
"github.com/gorhill/cronexpr"
"github.com/hjson/hjson-go"
"golang.org/x/crypto/ed25519"
- "golang.org/x/crypto/ssh/terminal"
+ "golang.org/x/term"
)
const (
Addr *string `json:"addr,omitempty"`
OnlineDeadline *uint `json:"onlinedeadline,omitempty"`
MaxOnlineTime *uint `json:"maxonlinetime,omitempty"`
+
+ AutoToss *bool `json:"autotoss,omitempty"`
+ AutoTossDoSeen *bool `json:"autotoss-doseen,omitempty"`
+ AutoTossNoFile *bool `json:"autotoss-nofile,omitempty"`
+ AutoTossNoFreq *bool `json:"autotoss-nofreq,omitempty"`
+ AutoTossNoExec *bool `json:"autotoss-noexec,omitempty"`
+ AutoTossNoTrns *bool `json:"autotoss-notrns,omitempty"`
}
type NodeOurJSON struct {
type CfgJSON struct {
Spool string `json:"spool"`
Log string `json:"log"`
- Umask string `json:"umask",omitempty`
+ Umask string `json:"umask,omitempty"`
- OmitPrgrs bool `json:"noprogress",omitempty`
+ OmitPrgrs bool `json:"noprogress,omitempty"`
Notify *NotifyJSON `json:"notify,omitempty"`
onlineDeadline = time.Duration(*callCfg.OnlineDeadline) * time.Second
}
- var maxOnlineTime time.Duration
- if callCfg.MaxOnlineTime != nil {
- maxOnlineTime = time.Duration(*callCfg.MaxOnlineTime) * time.Second
- }
-
- calls = append(calls, &Call{
+ call := Call{
Cron: expr,
Nice: nice,
Xx: xx,
TxRate: txRate,
Addr: addr,
OnlineDeadline: onlineDeadline,
- MaxOnlineTime: maxOnlineTime,
- })
+ }
+
+ if callCfg.MaxOnlineTime != nil {
+ call.MaxOnlineTime = time.Duration(*callCfg.MaxOnlineTime) * time.Second
+ }
+ if callCfg.AutoToss != nil {
+ call.AutoToss = *callCfg.AutoToss
+ }
+ if callCfg.AutoTossDoSeen != nil {
+ call.AutoTossDoSeen = *callCfg.AutoTossDoSeen
+ }
+ if callCfg.AutoTossNoFile != nil {
+ call.AutoTossNoFile = *callCfg.AutoTossNoFile
+ }
+ if callCfg.AutoTossNoFreq != nil {
+ call.AutoTossNoFreq = *callCfg.AutoTossNoFreq
+ }
+ if callCfg.AutoTossNoExec != nil {
+ call.AutoTossNoExec = *callCfg.AutoTossNoExec
+ }
+ if callCfg.AutoTossNoTrns != nil {
+ call.AutoTossNoTrns = *callCfg.AutoTossNoTrns
+ }
+
+ calls = append(calls, &call)
}
node := Node{
var err error
if bytes.Compare(data[:8], MagicNNCPBv3[:]) == 0 {
os.Stderr.WriteString("Passphrase:") // #nosec G104
- password, err := terminal.ReadPassword(0)
+ password, err := term.ReadPassword(0)
if err != nil {
log.Fatalln(err)
}