]> Cypherpunks.ru repositories - nncp.git/blob - src/tx.go
.nncp.meta must contain payload size, not the full one
[nncp.git] / src / tx.go
1 /*
2 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
3 Copyright (C) 2016-2021 Sergey Matveev <stargrave@stargrave.org>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, version 3 of the License.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 package nncp
19
20 import (
21         "archive/tar"
22         "bufio"
23         "bytes"
24         "errors"
25         "fmt"
26         "io"
27         "os"
28         "path/filepath"
29         "strconv"
30         "strings"
31         "time"
32
33         xdr "github.com/davecgh/go-xdr/xdr2"
34         "github.com/dustin/go-humanize"
35         "github.com/klauspost/compress/zstd"
36         "golang.org/x/crypto/blake2b"
37 )
38
39 const (
40         MaxFileSize = 1 << 62
41
42         TarBlockSize = 512
43         TarExt       = ".tar"
44 )
45
46 type PktEncWriteResult struct {
47         pktEncRaw []byte
48         size      int64
49         err       error
50 }
51
52 func (ctx *Ctx) Tx(
53         node *Node,
54         pkt *Pkt,
55         nice uint8,
56         srcSize, minSize, maxSize int64,
57         src io.Reader,
58         pktName string,
59         areaId *AreaId,
60 ) (*Node, int64, error) {
61         var area *Area
62         if areaId != nil {
63                 area = ctx.AreaId2Area[*areaId]
64                 if area.Prv == nil {
65                         return nil, 0, errors.New("area has no encryption keys")
66                 }
67         }
68         hops := make([]*Node, 0, 1+len(node.Via))
69         hops = append(hops, node)
70         lastNode := node
71         for i := len(node.Via); i > 0; i-- {
72                 lastNode = ctx.Neigh[*node.Via[i-1]]
73                 hops = append(hops, lastNode)
74         }
75         wrappers := len(hops)
76         if area != nil {
77                 wrappers++
78         }
79         var expectedSize int64
80         if srcSize > 0 {
81                 expectedSize = srcSize + PktOverhead
82                 expectedSize += sizePadCalc(expectedSize, minSize, wrappers)
83                 expectedSize = PktEncOverhead + sizeWithTags(expectedSize)
84                 if maxSize != 0 && expectedSize > maxSize {
85                         return nil, 0, TooBig
86                 }
87                 if !ctx.IsEnoughSpace(expectedSize) {
88                         return nil, 0, errors.New("is not enough space")
89                 }
90         }
91         tmp, err := ctx.NewTmpFileWHash()
92         if err != nil {
93                 return nil, 0, err
94         }
95
96         results := make(chan PktEncWriteResult)
97         pipeR, pipeW := io.Pipe()
98         var pipeRPrev io.Reader
99         if area == nil {
100                 go func(src io.Reader, dst io.WriteCloser) {
101                         ctx.LogD("tx", LEs{
102                                 {"Node", hops[0].Id},
103                                 {"Nice", int(nice)},
104                                 {"Size", expectedSize},
105                         }, func(les LEs) string {
106                                 return fmt.Sprintf(
107                                         "Tx packet to %s (source %s) nice: %s",
108                                         ctx.NodeName(hops[0].Id),
109                                         humanize.IBytes(uint64(expectedSize)),
110                                         NicenessFmt(nice),
111                                 )
112                         })
113                         pktEncRaw, size, err := PktEncWrite(
114                                 ctx.Self, hops[0], pkt, nice, minSize, maxSize, wrappers, src, dst,
115                         )
116                         results <- PktEncWriteResult{pktEncRaw, size, err}
117                         dst.Close()
118                 }(src, pipeW)
119         } else {
120                 go func(src io.Reader, dst io.WriteCloser) {
121                         ctx.LogD("tx", LEs{
122                                 {"Area", area.Id},
123                                 {"Nice", int(nice)},
124                                 {"Size", expectedSize},
125                         }, func(les LEs) string {
126                                 return fmt.Sprintf(
127                                         "Tx area packet to %s (source %s) nice: %s",
128                                         ctx.AreaName(areaId),
129                                         humanize.IBytes(uint64(expectedSize)),
130                                         NicenessFmt(nice),
131                                 )
132                         })
133                         areaNode := Node{Id: new(NodeId), ExchPub: new([32]byte)}
134                         copy(areaNode.Id[:], area.Id[:])
135                         copy(areaNode.ExchPub[:], area.Pub[:])
136                         pktEncRaw, size, err := PktEncWrite(
137                                 ctx.Self, &areaNode, pkt, nice, 0, maxSize, 0, src, dst,
138                         )
139                         results <- PktEncWriteResult{pktEncRaw, size, err}
140                         dst.Close()
141                 }(src, pipeW)
142                 pipeRPrev = pipeR
143                 pipeR, pipeW = io.Pipe()
144                 go func(src io.Reader, dst io.WriteCloser) {
145                         pktArea, err := NewPkt(PktTypeArea, 0, area.Id[:])
146                         if err != nil {
147                                 panic(err)
148                         }
149                         ctx.LogD("tx", LEs{
150                                 {"Node", hops[0].Id},
151                                 {"Nice", int(nice)},
152                                 {"Size", expectedSize},
153                         }, func(les LEs) string {
154                                 return fmt.Sprintf(
155                                         "Tx packet to %s (source %s) nice: %s",
156                                         ctx.NodeName(hops[0].Id),
157                                         humanize.IBytes(uint64(expectedSize)),
158                                         NicenessFmt(nice),
159                                 )
160                         })
161                         pktEncRaw, size, err := PktEncWrite(
162                                 ctx.Self, hops[0], pktArea, nice, minSize, maxSize, wrappers, src, dst,
163                         )
164                         results <- PktEncWriteResult{pktEncRaw, size, err}
165                         dst.Close()
166                 }(pipeRPrev, pipeW)
167         }
168         for i := 1; i < len(hops); i++ {
169                 pktTrns, err := NewPkt(PktTypeTrns, 0, hops[i-1].Id[:])
170                 if err != nil {
171                         panic(err)
172                 }
173                 pipeRPrev = pipeR
174                 pipeR, pipeW = io.Pipe()
175                 go func(node *Node, pkt *Pkt, src io.Reader, dst io.WriteCloser) {
176                         ctx.LogD("tx", LEs{
177                                 {"Node", node.Id},
178                                 {"Nice", int(nice)},
179                         }, func(les LEs) string {
180                                 return fmt.Sprintf(
181                                         "Tx trns packet to %s nice: %s",
182                                         ctx.NodeName(node.Id),
183                                         NicenessFmt(nice),
184                                 )
185                         })
186                         pktEncRaw, size, err := PktEncWrite(
187                                 ctx.Self, node, pkt, nice, 0, MaxFileSize, 0, src, dst,
188                         )
189                         results <- PktEncWriteResult{pktEncRaw, size, err}
190                         dst.Close()
191                 }(hops[i], pktTrns, pipeRPrev, pipeW)
192         }
193         go func() {
194                 _, err := CopyProgressed(
195                         tmp.W, pipeR, "Tx",
196                         LEs{{"Pkt", pktName}, {"FullSize", expectedSize}},
197                         ctx.ShowPrgrs,
198                 )
199                 results <- PktEncWriteResult{err: err}
200         }()
201         var pktEncRaw []byte
202         var pktEncMsg []byte
203         var payloadSize int64
204         if area != nil {
205                 r := <-results
206                 payloadSize = r.size
207                 pktEncMsg = r.pktEncRaw
208         }
209         for i := 0; i <= wrappers; i++ {
210                 r := <-results
211                 if r.err != nil {
212                         tmp.Fd.Close()
213                         return nil, 0, err
214                 }
215                 if r.pktEncRaw != nil {
216                         pktEncRaw = r.pktEncRaw
217                         if payloadSize == 0 {
218                                 payloadSize = r.size
219                         }
220                 }
221         }
222         nodePath := filepath.Join(ctx.Spool, lastNode.Id.String())
223         err = tmp.Commit(filepath.Join(nodePath, string(TTx)))
224         os.Symlink(nodePath, filepath.Join(ctx.Spool, lastNode.Name))
225         if err != nil {
226                 return lastNode, 0, err
227         }
228         if ctx.HdrUsage {
229                 ctx.HdrWrite(pktEncRaw, filepath.Join(nodePath, string(TTx), tmp.Checksum()))
230         }
231         if area != nil {
232                 msgHashRaw := blake2b.Sum256(pktEncMsg)
233                 msgHash := Base32Codec.EncodeToString(msgHashRaw[:])
234                 seenDir := filepath.Join(
235                         ctx.Spool, ctx.SelfId.String(), AreaDir, areaId.String(),
236                 )
237                 seenPath := filepath.Join(seenDir, msgHash)
238                 les := LEs{
239                         {"Node", node.Id},
240                         {"Nice", int(nice)},
241                         {"Size", expectedSize},
242                         {"Area", areaId},
243                         {"AreaMsg", msgHash},
244                 }
245                 logMsg := func(les LEs) string {
246                         return fmt.Sprintf(
247                                 "Tx area packet to %s (source %s) nice: %s, area %s: %s",
248                                 ctx.NodeName(node.Id),
249                                 humanize.IBytes(uint64(expectedSize)),
250                                 NicenessFmt(nice),
251                                 area.Name,
252                                 msgHash,
253                         )
254                 }
255                 if err = ensureDir(seenDir); err != nil {
256                         ctx.LogE("tx-mkdir", les, err, logMsg)
257                         return lastNode, 0, err
258                 }
259                 if fd, err := os.Create(seenPath); err == nil {
260                         fd.Close()
261                         if err = DirSync(seenDir); err != nil {
262                                 ctx.LogE("tx-dirsync", les, err, logMsg)
263                                 return lastNode, 0, err
264                         }
265                 }
266                 ctx.LogI("tx-area", les, logMsg)
267         }
268         return lastNode, payloadSize, err
269 }
270
271 type DummyCloser struct{}
272
273 func (dc DummyCloser) Close() error { return nil }
274
275 func prepareTxFile(srcPath string) (
276         reader io.Reader,
277         closer io.Closer,
278         srcSize int64,
279         archived bool,
280         rerr error,
281 ) {
282         if srcPath == "-" {
283                 reader = os.Stdin
284                 closer = os.Stdin
285                 return
286         }
287
288         srcStat, err := os.Stat(srcPath)
289         if err != nil {
290                 rerr = err
291                 return
292         }
293         mode := srcStat.Mode()
294
295         if mode.IsRegular() {
296                 // It is regular file, just send it
297                 src, err := os.Open(srcPath)
298                 if err != nil {
299                         rerr = err
300                         return
301                 }
302                 reader = src
303                 closer = src
304                 srcSize = srcStat.Size()
305                 return
306         }
307
308         if !mode.IsDir() {
309                 rerr = errors.New("unsupported file type")
310                 return
311         }
312
313         // It is directory, create PAX archive with its contents
314         archived = true
315         basePath := filepath.Base(srcPath)
316         rootPath, err := filepath.Abs(srcPath)
317         if err != nil {
318                 rerr = err
319                 return
320         }
321         type einfo struct {
322                 path    string
323                 modTime time.Time
324                 size    int64
325         }
326         dirs := make([]einfo, 0, 1<<10)
327         files := make([]einfo, 0, 1<<10)
328         rerr = filepath.Walk(rootPath, func(path string, info os.FileInfo, err error) error {
329                 if err != nil {
330                         return err
331                 }
332                 if info.IsDir() {
333                         // directory header, PAX record header+contents
334                         srcSize += TarBlockSize + 2*TarBlockSize
335                         dirs = append(dirs, einfo{path: path, modTime: info.ModTime()})
336                 } else {
337                         // file header, PAX record header+contents, file content
338                         srcSize += TarBlockSize + 2*TarBlockSize + info.Size()
339                         if n := info.Size() % TarBlockSize; n != 0 {
340                                 srcSize += TarBlockSize - n // padding
341                         }
342                         files = append(files, einfo{
343                                 path:    path,
344                                 modTime: info.ModTime(),
345                                 size:    info.Size(),
346                         })
347                 }
348                 return nil
349         })
350         if rerr != nil {
351                 return
352         }
353
354         r, w := io.Pipe()
355         reader = r
356         closer = DummyCloser{}
357         srcSize += 2 * TarBlockSize // termination block
358
359         go func() error {
360                 tarWr := tar.NewWriter(w)
361                 hdr := tar.Header{
362                         Typeflag: tar.TypeDir,
363                         Mode:     0777,
364                         PAXRecords: map[string]string{
365                                 "comment": "Autogenerated by " + VersionGet(),
366                         },
367                         Format: tar.FormatPAX,
368                 }
369                 for _, e := range dirs {
370                         hdr.Name = basePath + e.path[len(rootPath):]
371                         hdr.ModTime = e.modTime
372                         if err = tarWr.WriteHeader(&hdr); err != nil {
373                                 return w.CloseWithError(err)
374                         }
375                 }
376                 hdr.Typeflag = tar.TypeReg
377                 hdr.Mode = 0666
378                 for _, e := range files {
379                         hdr.Name = basePath + e.path[len(rootPath):]
380                         hdr.ModTime = e.modTime
381                         hdr.Size = e.size
382                         if err = tarWr.WriteHeader(&hdr); err != nil {
383                                 return w.CloseWithError(err)
384                         }
385                         fd, err := os.Open(e.path)
386                         if err != nil {
387                                 fd.Close()
388                                 return w.CloseWithError(err)
389                         }
390                         if _, err = io.Copy(tarWr, bufio.NewReader(fd)); err != nil {
391                                 fd.Close()
392                                 return w.CloseWithError(err)
393                         }
394                         fd.Close()
395                 }
396                 if err = tarWr.Close(); err != nil {
397                         return w.CloseWithError(err)
398                 }
399                 return w.Close()
400         }()
401         return
402 }
403
404 func (ctx *Ctx) TxFile(
405         node *Node,
406         nice uint8,
407         srcPath, dstPath string,
408         chunkSize, minSize, maxSize int64,
409         areaId *AreaId,
410 ) error {
411         dstPathSpecified := false
412         if dstPath == "" {
413                 if srcPath == "-" {
414                         return errors.New("Must provide destination filename")
415                 }
416                 dstPath = filepath.Base(srcPath)
417         } else {
418                 dstPathSpecified = true
419         }
420         dstPath = filepath.Clean(dstPath)
421         if filepath.IsAbs(dstPath) {
422                 return errors.New("Relative destination path required")
423         }
424         reader, closer, srcSize, archived, err := prepareTxFile(srcPath)
425         if closer != nil {
426                 defer closer.Close()
427         }
428         if err != nil {
429                 return err
430         }
431         if archived && !dstPathSpecified {
432                 dstPath += TarExt
433         }
434
435         if chunkSize == 0 || (srcSize > 0 && srcSize <= chunkSize) {
436                 pkt, err := NewPkt(PktTypeFile, nice, []byte(dstPath))
437                 if err != nil {
438                         return err
439                 }
440                 _, finalSize, err := ctx.Tx(
441                         node, pkt, nice,
442                         srcSize, minSize, maxSize,
443                         bufio.NewReader(reader), dstPath, areaId,
444                 )
445                 les := LEs{
446                         {"Type", "file"},
447                         {"Node", node.Id},
448                         {"Nice", int(nice)},
449                         {"Src", srcPath},
450                         {"Dst", dstPath},
451                         {"Size", finalSize},
452                 }
453                 logMsg := func(les LEs) string {
454                         return fmt.Sprintf(
455                                 "File %s (%s) sent to %s:%s",
456                                 srcPath,
457                                 humanize.IBytes(uint64(finalSize)),
458                                 ctx.NodeName(node.Id),
459                                 dstPath,
460                         )
461                 }
462                 if err == nil {
463                         ctx.LogI("tx", les, logMsg)
464                 } else {
465                         ctx.LogE("tx", les, err, logMsg)
466                 }
467                 return err
468         }
469
470         br := bufio.NewReader(reader)
471         var sizeFull int64
472         var chunkNum int
473         checksums := [][MTHSize]byte{}
474         for {
475                 lr := io.LimitReader(br, chunkSize)
476                 path := dstPath + ChunkedSuffixPart + strconv.Itoa(chunkNum)
477                 pkt, err := NewPkt(PktTypeFile, nice, []byte(path))
478                 if err != nil {
479                         return err
480                 }
481                 hsh := MTHNew(0, 0)
482                 _, size, err := ctx.Tx(
483                         node, pkt, nice,
484                         0, minSize, maxSize,
485                         io.TeeReader(lr, hsh),
486                         path, areaId,
487                 )
488
489                 les := LEs{
490                         {"Type", "file"},
491                         {"Node", node.Id},
492                         {"Nice", int(nice)},
493                         {"Src", srcPath},
494                         {"Dst", path},
495                         {"Size", size},
496                 }
497                 logMsg := func(les LEs) string {
498                         return fmt.Sprintf(
499                                 "File %s (%s) sent to %s:%s",
500                                 srcPath,
501                                 humanize.IBytes(uint64(size)),
502                                 ctx.NodeName(node.Id),
503                                 path,
504                         )
505                 }
506                 if err == nil {
507                         ctx.LogI("tx", les, logMsg)
508                 } else {
509                         ctx.LogE("tx", les, err, logMsg)
510                         return err
511                 }
512
513                 sizeFull += size - PktOverhead
514                 var checksum [MTHSize]byte
515                 hsh.Sum(checksum[:0])
516                 checksums = append(checksums, checksum)
517                 chunkNum++
518                 if size < chunkSize {
519                         break
520                 }
521                 if _, err = br.Peek(1); err != nil {
522                         break
523                 }
524         }
525
526         metaPkt := ChunkedMeta{
527                 Magic:     MagicNNCPMv2.B,
528                 FileSize:  uint64(sizeFull),
529                 ChunkSize: uint64(chunkSize),
530                 Checksums: checksums,
531         }
532         var buf bytes.Buffer
533         _, err = xdr.Marshal(&buf, metaPkt)
534         if err != nil {
535                 return err
536         }
537         path := dstPath + ChunkedSuffixMeta
538         pkt, err := NewPkt(PktTypeFile, nice, []byte(path))
539         if err != nil {
540                 return err
541         }
542         metaPktSize := int64(buf.Len())
543         _, _, err = ctx.Tx(
544                 node,
545                 pkt,
546                 nice,
547                 metaPktSize, minSize, maxSize,
548                 &buf, path, areaId,
549         )
550         les := LEs{
551                 {"Type", "file"},
552                 {"Node", node.Id},
553                 {"Nice", int(nice)},
554                 {"Src", srcPath},
555                 {"Dst", path},
556                 {"Size", metaPktSize},
557         }
558         logMsg := func(les LEs) string {
559                 return fmt.Sprintf(
560                         "File %s (%s) sent to %s:%s",
561                         srcPath,
562                         humanize.IBytes(uint64(metaPktSize)),
563                         ctx.NodeName(node.Id),
564                         path,
565                 )
566         }
567         if err == nil {
568                 ctx.LogI("tx", les, logMsg)
569         } else {
570                 ctx.LogE("tx", les, err, logMsg)
571         }
572         return err
573 }
574
575 func (ctx *Ctx) TxFreq(
576         node *Node,
577         nice, replyNice uint8,
578         srcPath, dstPath string,
579         minSize int64,
580 ) error {
581         dstPath = filepath.Clean(dstPath)
582         if filepath.IsAbs(dstPath) {
583                 return errors.New("Relative destination path required")
584         }
585         srcPath = filepath.Clean(srcPath)
586         if filepath.IsAbs(srcPath) {
587                 return errors.New("Relative source path required")
588         }
589         pkt, err := NewPkt(PktTypeFreq, replyNice, []byte(srcPath))
590         if err != nil {
591                 return err
592         }
593         src := strings.NewReader(dstPath)
594         size := int64(src.Len())
595         _, _, err = ctx.Tx(node, pkt, nice, size, minSize, MaxFileSize, src, srcPath, nil)
596         les := LEs{
597                 {"Type", "freq"},
598                 {"Node", node.Id},
599                 {"Nice", int(nice)},
600                 {"ReplyNice", int(replyNice)},
601                 {"Src", srcPath},
602                 {"Dst", dstPath},
603         }
604         logMsg := func(les LEs) string {
605                 return fmt.Sprintf(
606                         "File request from %s:%s to %s sent",
607                         ctx.NodeName(node.Id), srcPath,
608                         dstPath,
609                 )
610         }
611         if err == nil {
612                 ctx.LogI("tx", les, logMsg)
613         } else {
614                 ctx.LogE("tx", les, err, logMsg)
615         }
616         return err
617 }
618
619 func (ctx *Ctx) TxExec(
620         node *Node,
621         nice, replyNice uint8,
622         handle string,
623         args []string,
624         in io.Reader,
625         minSize int64, maxSize int64,
626         noCompress bool,
627         areaId *AreaId,
628 ) error {
629         path := make([][]byte, 0, 1+len(args))
630         path = append(path, []byte(handle))
631         for _, arg := range args {
632                 path = append(path, []byte(arg))
633         }
634         pktType := PktTypeExec
635         if noCompress {
636                 pktType = PktTypeExecFat
637         }
638         pkt, err := NewPkt(pktType, replyNice, bytes.Join(path, []byte{0}))
639         if err != nil {
640                 return err
641         }
642         compressErr := make(chan error, 1)
643         if !noCompress {
644                 pr, pw := io.Pipe()
645                 compressor, err := zstd.NewWriter(pw, zstd.WithEncoderLevel(zstd.SpeedDefault))
646                 if err != nil {
647                         return err
648                 }
649                 go func(r io.Reader) {
650                         if _, err := io.Copy(compressor, r); err != nil {
651                                 compressErr <- err
652                                 return
653                         }
654                         compressErr <- compressor.Close()
655                         pw.Close()
656                 }(in)
657                 in = pr
658         }
659         _, size, err := ctx.Tx(node, pkt, nice, 0, minSize, maxSize, in, handle, areaId)
660         if !noCompress {
661                 e := <-compressErr
662                 if err == nil {
663                         err = e
664                 }
665         }
666         dst := strings.Join(append([]string{handle}, args...), " ")
667         les := LEs{
668                 {"Type", "exec"},
669                 {"Node", node.Id},
670                 {"Nice", int(nice)},
671                 {"ReplyNice", int(replyNice)},
672                 {"Dst", dst},
673                 {"Size", size},
674         }
675         logMsg := func(les LEs) string {
676                 return fmt.Sprintf(
677                         "Exec sent to %s@%s (%s)",
678                         ctx.NodeName(node.Id), dst, humanize.IBytes(uint64(size)),
679                 )
680         }
681         if err == nil {
682                 ctx.LogI("tx", les, logMsg)
683         } else {
684                 ctx.LogE("tx", les, err, logMsg)
685         }
686         return err
687 }
688
689 func (ctx *Ctx) TxTrns(node *Node, nice uint8, size int64, src io.Reader) error {
690         les := LEs{
691                 {"Type", "trns"},
692                 {"Node", node.Id},
693                 {"Nice", int(nice)},
694                 {"Size", size},
695         }
696         logMsg := func(les LEs) string {
697                 return fmt.Sprintf(
698                         "Transitional packet to %s (%s) (nice %s)",
699                         ctx.NodeName(node.Id),
700                         humanize.IBytes(uint64(size)),
701                         NicenessFmt(nice),
702                 )
703         }
704         ctx.LogD("tx", les, logMsg)
705         if !ctx.IsEnoughSpace(size) {
706                 err := errors.New("is not enough space")
707                 ctx.LogE("tx", les, err, logMsg)
708                 return err
709         }
710         tmp, err := ctx.NewTmpFileWHash()
711         if err != nil {
712                 return err
713         }
714         if _, err = CopyProgressed(
715                 tmp.W, src, "Tx trns",
716                 LEs{{"Pkt", node.Id.String()}, {"FullSize", size}},
717                 ctx.ShowPrgrs,
718         ); err != nil {
719                 return err
720         }
721         nodePath := filepath.Join(ctx.Spool, node.Id.String())
722         err = tmp.Commit(filepath.Join(nodePath, string(TTx)))
723         if err == nil {
724                 ctx.LogI("tx", les, logMsg)
725         } else {
726                 ctx.LogI("tx", append(les, LE{"Err", err}), logMsg)
727         }
728         os.Symlink(nodePath, filepath.Join(ctx.Spool, node.Name))
729         return err
730 }