]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cypherpunks.ru/nncp/node.go
Forbid any later GNU GPL versions autousage
[nncp.git] / src / cypherpunks.ru / nncp / node.go
index 1e1b5bab3b3e96da17bd4aad8784f188707b348e..ac78301f802464dae9c763de4de93495c259f748 100644 (file)
@@ -1,11 +1,10 @@
 /*
 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2017 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2019 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
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+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
@@ -24,7 +23,6 @@ import (
        "sync"
 
        "github.com/flynn/noise"
-       "github.com/gorhill/cronexpr"
        "golang.org/x/crypto/blake2b"
        "golang.org/x/crypto/ed25519"
        "golang.org/x/crypto/nacl/box"
@@ -42,12 +40,17 @@ type Node struct {
        ExchPub        *[32]byte
        SignPub        ed25519.PublicKey
        NoisePub       *[32]byte
-       Sendmail       []string
+       Exec           map[string][]string
        Incoming       *string
        Freq           *string
+       FreqChunked    int64
+       FreqMinSize    int64
        Via            []*NodeId
        Addrs          map[string]string
-       OnlineDeadline int
+       RxRate         int
+       TxRate         int
+       OnlineDeadline uint
+       MaxOnlineTime  uint
        Calls          []*Call
 
        Busy bool
@@ -64,14 +67,6 @@ type NodeOur struct {
        NoisePrv *[32]byte
 }
 
-type Call struct {
-       Cron           *cronexpr.Expression
-       Nice           uint8
-       Xx             *TRxTx
-       Addr           *string
-       OnlineDeadline int
-}
-
 func NewNodeGenerate() (*NodeOur, error) {
        exchPub, exchPrv, err := box.GenerateKey(rand.Reader)
        if err != nil {
@@ -81,7 +76,10 @@ func NewNodeGenerate() (*NodeOur, error) {
        if err != nil {
                return nil, err
        }
-       noiseKey := noise.DH25519.GenerateKeypair(rand.Reader)
+       noiseKey, err := noise.DH25519.GenerateKeypair(rand.Reader)
+       if err != nil {
+               return nil, err
+       }
        noisePub := new([32]byte)
        noisePrv := new([32]byte)
        copy(noisePrv[:], noiseKey.Private)