From: Sergey Matveev Date: Sun, 10 Jun 2018 15:17:16 +0000 (+0300) Subject: Split long lines X-Git-Tag: 3.3^2~2 X-Git-Url: http://www.git.cypherpunks.ru/?a=commitdiff_plain;h=10cca26e7daf070e661e546d9e8b627a61375936;p=nncp.git Split long lines --- diff --git a/src/cypherpunks.ru/nncp/call.go b/src/cypherpunks.ru/nncp/call.go index fbdd05b..6a2c38b 100644 --- a/src/cypherpunks.ru/nncp/call.go +++ b/src/cypherpunks.ru/nncp/call.go @@ -36,7 +36,13 @@ type Call struct { MaxOnlineTime uint } -func (ctx *Ctx) CallNode(node *Node, addrs []string, nice uint8, xxOnly TRxTx, rxRate, txRate int, onlineDeadline, maxOnlineTime uint) (isGood bool) { +func (ctx *Ctx) CallNode( + node *Node, + addrs []string, + nice uint8, + xxOnly TRxTx, + rxRate, txRate int, + onlineDeadline, maxOnlineTime uint) (isGood bool) { for _, addr := range addrs { sds := SDS{"node": node.Id, "addr": addr} ctx.LogD("call", sds, "dialing") diff --git a/src/cypherpunks.ru/nncp/pkt.go b/src/cypherpunks.ru/nncp/pkt.go index 63c0a10..855037d 100644 --- a/src/cypherpunks.ru/nncp/pkt.go +++ b/src/cypherpunks.ru/nncp/pkt.go @@ -174,7 +174,14 @@ func ae(keyEnc *[32]byte, r io.Reader, w io.Writer) (int, error) { return written, nil } -func PktEncWrite(our *NodeOur, their *Node, pkt *Pkt, nice uint8, size, padSize int64, data io.Reader, out io.Writer) error { +func PktEncWrite( + our *NodeOur, + their *Node, + pkt *Pkt, + nice uint8, + size, padSize int64, + data io.Reader, + out io.Writer) error { pubEph, prvEph, err := box.GenerateKey(rand.Reader) if err != nil { return err @@ -298,7 +305,11 @@ func TbsVerify(our *NodeOur, their *Node, pktEnc *PktEnc) (bool, error) { return ed25519.Verify(their.SignPub, tbsBuf.Bytes(), pktEnc.Sign[:]), nil } -func PktEncRead(our *NodeOur, nodes map[NodeId]*Node, data io.Reader, out io.Writer) (*Node, int64, error) { +func PktEncRead( + our *NodeOur, + nodes map[NodeId]*Node, + data io.Reader, + out io.Writer) (*Node, int64, error) { var pktEnc PktEnc _, err := xdr.Unmarshal(data, &pktEnc) if err != nil { diff --git a/src/cypherpunks.ru/nncp/pkt_test.go b/src/cypherpunks.ru/nncp/pkt_test.go index e0765b3..5775e73 100644 --- a/src/cypherpunks.ru/nncp/pkt_test.go +++ b/src/cypherpunks.ru/nncp/pkt_test.go @@ -81,7 +81,12 @@ func TestPktEncRead(t *testing.T) { if err != nil { panic(err) } - f := func(path string, pathSize uint8, data [1 << 16]byte, size, padSize uint16, junk []byte) bool { + f := func( + path string, + pathSize uint8, + data [1 << 16]byte, + size, padSize uint16, + junk []byte) bool { dataR := bytes.NewReader(data[:]) var ct bytes.Buffer if len(path) > int(pathSize) { diff --git a/src/cypherpunks.ru/nncp/sp.go b/src/cypherpunks.ru/nncp/sp.go index d2f329e..957dec9 100644 --- a/src/cypherpunks.ru/nncp/sp.go +++ b/src/cypherpunks.ru/nncp/sp.go @@ -202,7 +202,8 @@ func (state *SPState) NotAlive() bool { if state.maxOnlineTime > 0 && state.started.Add(time.Duration(state.maxOnlineTime)*time.Second).Before(now) { return true } - return uint(now.Sub(state.RxLastSeen).Seconds()) >= state.onlineDeadline && uint(now.Sub(state.TxLastSeen).Seconds()) >= state.onlineDeadline + return uint(now.Sub(state.RxLastSeen).Seconds()) >= state.onlineDeadline && + uint(now.Sub(state.TxLastSeen).Seconds()) >= state.onlineDeadline } func (state *SPState) dirUnlock() { @@ -273,7 +274,13 @@ func (ctx *Ctx) infosOur(nodeId *NodeId, nice uint8, seen *map[[32]byte]uint8) [ return payloadsSplit(payloads) } -func (ctx *Ctx) StartI(conn net.Conn, nodeId *NodeId, nice uint8, xxOnly TRxTx, rxRate, txRate int, onlineDeadline, maxOnlineTime uint) (*SPState, error) { +func (ctx *Ctx) StartI( + conn net.Conn, + nodeId *NodeId, + nice uint8, + xxOnly TRxTx, + rxRate, txRate int, + onlineDeadline, maxOnlineTime uint) (*SPState, error) { err := ctx.ensureRxDir(nodeId) if err != nil { return nil, err @@ -491,7 +498,10 @@ func (ctx *Ctx) StartR(conn net.Conn, nice uint8, xxOnly TRxTx) (*SPState, error return &state, err } -func (state *SPState) StartWorkers(conn net.Conn, infosPayloads [][]byte, payload []byte) error { +func (state *SPState) StartWorkers( + conn net.Conn, + infosPayloads [][]byte, + payload []byte) error { sds := SDS{"node": state.Node.Id, "nice": strconv.Itoa(int(state.nice))} if len(infosPayloads) > 1 { go func() { diff --git a/src/cypherpunks.ru/nncp/toss.go b/src/cypherpunks.ru/nncp/toss.go index 86d154b..fa49c16 100644 --- a/src/cypherpunks.ru/nncp/toss.go +++ b/src/cypherpunks.ru/nncp/toss.go @@ -52,7 +52,10 @@ func newNotification(fromTo *FromToYAML, subject string) io.Reader { )) } -func (ctx *Ctx) Toss(nodeId *NodeId, nice uint8, dryRun, doSeen, noFile, noFreq, noExec, noTrns bool) bool { +func (ctx *Ctx) Toss( + nodeId *NodeId, + nice uint8, + dryRun, doSeen, noFile, noFreq, noExec, noTrns bool) bool { isBad := false for job := range ctx.Jobs(nodeId, TRx) { pktName := filepath.Base(job.Fd.Name()) diff --git a/src/cypherpunks.ru/nncp/tx.go b/src/cypherpunks.ru/nncp/tx.go index 4319813..0692eca 100644 --- a/src/cypherpunks.ru/nncp/tx.go +++ b/src/cypherpunks.ru/nncp/tx.go @@ -36,7 +36,12 @@ import ( "golang.org/x/crypto/blake2b" ) -func (ctx *Ctx) Tx(node *Node, pkt *Pkt, nice uint8, size, minSize int64, src io.Reader) (*Node, error) { +func (ctx *Ctx) Tx( + node *Node, + pkt *Pkt, + nice uint8, + size, minSize int64, + src io.Reader) (*Node, error) { tmp, err := ctx.NewTmpFileWHash() if err != nil { return nil, err @@ -180,7 +185,12 @@ func (ctx *Ctx) TxFile(node *Node, nice uint8, srcPath, dstPath string, minSize return err } -func (ctx *Ctx) TxFileChunked(node *Node, nice uint8, srcPath, dstPath string, minSize int64, chunkSize int64) error { +func (ctx *Ctx) TxFileChunked( + node *Node, + nice uint8, + srcPath, dstPath string, + minSize int64, + chunkSize int64) error { if dstPath == "" { if srcPath == "-" { return errors.New("Must provide destination filename") @@ -312,7 +322,11 @@ func (ctx *Ctx) TxFileChunked(node *Node, nice uint8, srcPath, dstPath string, m return err } -func (ctx *Ctx) TxFreq(node *Node, nice, replyNice uint8, srcPath, dstPath string, minSize int64) error { +func (ctx *Ctx) TxFreq( + node *Node, + nice, replyNice uint8, + srcPath, dstPath string, + minSize int64) error { dstPath = filepath.Clean(dstPath) if filepath.IsAbs(dstPath) { return errors.New("Relative destination path required") @@ -345,7 +359,13 @@ func (ctx *Ctx) TxFreq(node *Node, nice, replyNice uint8, srcPath, dstPath strin return err } -func (ctx *Ctx) TxExec(node *Node, nice, replyNice uint8, handle string, args []string, body []byte, minSize int64) error { +func (ctx *Ctx) TxExec( + node *Node, + nice, replyNice uint8, + handle string, + args []string, + body []byte, + minSize int64) error { path := make([][]byte, 0, 1+len(args)) path = append(path, []byte(handle)) for _, arg := range args {