)
const (
- CfgPathEnv = "NNCPCFG"
+ CfgPathEnv = "NNCPCFG"
+ CfgSpoolEnv = "NNCPSPOOL"
+ CfgLogEnv = "NNCPLOG"
)
var (
type CallYAML struct {
Cron string
Nice *int `nice,omitempty`
- Xx *string `xx,omitempty`
+ Xx string `xx,omitempty`
Addr *string `addr,omitempty`
OnlineDeadline *uint `onlinedeadline,omitempty`
MaxOnlineTime *uint `maxonlinetime,omitempty`
nice = uint8(*callYml.Nice)
}
var xx TRxTx
- if callYml.Xx != nil {
- switch *callYml.Xx {
- case "rx":
- xx = TRx
- case "tx":
- xx = TTx
- default:
- return nil, errors.New("xx field must be either \"rx\" or \"tx\"")
- }
+ switch callYml.Xx {
+ case "rx":
+ xx = TRx
+ case "tx":
+ xx = TTx
+ case "":
+ default:
+ return nil, errors.New("xx field must be either \"rx\" or \"tx\"")
}
var addr *string
if callYml.Addr != nil {
calls = append(calls, &Call{
Cron: expr,
Nice: nice,
- Xx: &xx,
+ Xx: xx,
Addr: addr,
OnlineDeadline: onlineDeadline,
MaxOnlineTime: maxOnlineTime,
func CfgParse(data []byte) (*Ctx, error) {
var err error
- if bytes.Compare(data[:8], MagicNNCPBv1[:]) == 0 {
+ if bytes.Compare(data[:8], MagicNNCPBv2[:]) == 0 {
os.Stderr.WriteString("Passphrase:")
password, err := terminal.ReadPassword(0)
if err != nil {
}
return &ctx, nil
}
-
-func CfgPathFromEnv(cmdlineFlag *string) (p string) {
- p = os.Getenv(CfgPathEnv)
- if p == "" {
- p = *cmdlineFlag
- }
- return
-}