]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/node.go
Raise copyright years
[nncp.git] / src / node.go
index ac78301f802464dae9c763de4de93495c259f748..c965796ead59c38de3c774ef6968d41fe66a3c12 100644 (file)
@@ -1,6 +1,6 @@
 /*
 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2019 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
@@ -21,6 +21,7 @@ import (
        "crypto/rand"
        "errors"
        "sync"
+       "time"
 
        "github.com/flynn/noise"
        "golang.org/x/crypto/blake2b"
@@ -31,7 +32,7 @@ import (
 type NodeId [blake2b.Size256]byte
 
 func (id NodeId) String() string {
-       return ToBase32(id[:])
+       return Base32Codec.EncodeToString(id[:])
 }
 
 type Node struct {
@@ -42,15 +43,16 @@ type Node struct {
        NoisePub       *[32]byte
        Exec           map[string][]string
        Incoming       *string
-       Freq           *string
+       FreqPath       *string
        FreqChunked    int64
        FreqMinSize    int64
+       FreqMaxSize    int64
        Via            []*NodeId
        Addrs          map[string]string
        RxRate         int
        TxRate         int
-       OnlineDeadline uint
-       MaxOnlineTime  uint
+       OnlineDeadline time.Duration
+       MaxOnlineTime  time.Duration
        Calls          []*Call
 
        Busy bool
@@ -100,15 +102,17 @@ func NewNodeGenerate() (*NodeOur, error) {
 
 func (nodeOur *NodeOur) Their() *Node {
        return &Node{
-               Name:    "self",
-               Id:      nodeOur.Id,
-               ExchPub: nodeOur.ExchPub,
-               SignPub: nodeOur.SignPub,
+               Name:        "self",
+               Id:          nodeOur.Id,
+               ExchPub:     nodeOur.ExchPub,
+               SignPub:     nodeOur.SignPub,
+               FreqChunked: MaxFileSize,
+               FreqMaxSize: MaxFileSize,
        }
 }
 
 func NodeIdFromString(raw string) (*NodeId, error) {
-       decoded, err := FromBase32(raw)
+       decoded, err := Base32Codec.DecodeString(raw)
        if err != nil {
                return nil, err
        }