diff --git a/config/config.go b/config/config.go index 62d5a8d..7364323 100644 --- a/config/config.go +++ b/config/config.go @@ -7,21 +7,16 @@ package config -import ( - "github.com/libp2p/go-libp2p/core/connmgr" -) - // Config describes a set of settings for a libp2p node type Config struct { ListenPort int - ConnManager connmgr.ConnManager BootPeers []string Workspace string PrivatekeyPath string ProtocolPrefix string PublicIpv4 string - BucketSize int - Version string + RecordCacheLen int + DialTimeout int } // Option is a libp2p config option that can be given to the libp2p constructor diff --git a/core/fileblock.go b/core/fileblock.go deleted file mode 100644 index 16c8a8c..0000000 --- a/core/fileblock.go +++ /dev/null @@ -1,176 +0,0 @@ -/* - Copyright (C) CESS. All rights reserved. - Copyright (C) Cumulus Encrypted Storage System. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 -*/ - -package core - -import ( - "context" - "fmt" - "log" - "os" - "path/filepath" - "strings" - - ds "github.com/ipfs/go-datastore" - query "github.com/ipfs/go-datastore/query" -) - -var data = ".data" - -// Datastore uses a uses a file per key to store values. -type Datastore struct { - path string -} - -var _ ds.Datastore = (*Datastore)(nil) -var _ ds.Batching = (*Datastore)(nil) -var _ ds.PersistentDatastore = (*Datastore)(nil) - -// NewDatastore returns a new fs Datastore at given `path` -func NewDatastore(path string) (*Datastore, error) { - err := os.MkdirAll(path, 0755) - if err != nil { - return &Datastore{}, err - } - if !isDir(path) { - return nil, fmt.Errorf("failed to find directory at: %v (file? perms?)", path) - } - - return &Datastore{path: path}, nil -} - -// KeyFilename returns the filename associated with `key` -func (d *Datastore) KeyFilename(key ds.Key) string { - return filepath.Join(d.path, key.Name(), data) -} - -// Put stores the given value. -func (d *Datastore) Put(ctx context.Context, key ds.Key, value []byte) (err error) { - fn := d.KeyFilename(key) - // mkdirall above. - err = os.MkdirAll(filepath.Dir(fn), 0755) - if err != nil { - return err - } - return os.WriteFile(fn, value, 0666) -} - -// Sync would ensure that any previous Puts under the prefix are written to disk. -// However, they already are. -func (d *Datastore) Sync(ctx context.Context, prefix ds.Key) error { - return nil -} - -// Get returns the value for given key -func (d *Datastore) Get(ctx context.Context, key ds.Key) (value []byte, err error) { - fn := d.KeyFilename(key) - if !isFile(fn) { - return nil, ds.ErrNotFound - } - - return os.ReadFile(fn) -} - -// Has returns whether the datastore has a value for a given key -func (d *Datastore) Has(ctx context.Context, key ds.Key) (exists bool, err error) { - return ds.GetBackedHas(ctx, d, key) -} - -func (d *Datastore) GetSize(ctx context.Context, key ds.Key) (size int, err error) { - return ds.GetBackedSize(ctx, d, key) -} - -// Delete removes the value for given key -func (d *Datastore) Delete(ctx context.Context, key ds.Key) (err error) { - fn := d.KeyFilename(key) - if !isFile(fn) { - return nil - } - - err = os.Remove(fn) - if os.IsNotExist(err) { - err = nil // idempotent - } - return err -} - -// Query implements Datastore.Query -func (d *Datastore) Query(ctx context.Context, q query.Query) (query.Results, error) { - results := make(chan query.Result) - - walkFn := func(path string, info os.FileInfo, _ error) error { - // remove ds path prefix - relPath, err := filepath.Rel(d.path, path) - if err == nil { - path = filepath.ToSlash(relPath) - } - - if !info.IsDir() { - path = strings.TrimSuffix(path, data) - var result query.Result - key := ds.NewKey(path) - result.Entry.Key = key.String() - if !q.KeysOnly { - result.Entry.Value, result.Error = d.Get(ctx, key) - } - results <- result - } - return nil - } - - go func() { - filepath.Walk(d.path, walkFn) - close(results) - }() - r := query.ResultsWithChan(q, results) - r = query.NaiveQueryApply(q, r) - return r, nil -} - -// isDir returns whether given path is a directory -func isDir(path string) bool { - finfo, err := os.Stat(path) - if err != nil { - return false - } - - return finfo.IsDir() -} - -// isFile returns whether given path is a file -func isFile(path string) bool { - finfo, err := os.Stat(path) - if err != nil { - return false - } - - return !finfo.IsDir() -} - -func (d *Datastore) Close() error { - return nil -} - -func (d *Datastore) Batch(ctx context.Context) (ds.Batch, error) { - return ds.NewBasicBatch(d), nil -} - -// DiskUsage returns the disk size used by the datastore in bytes. -func (d *Datastore) DiskUsage(ctx context.Context) (uint64, error) { - var du uint64 - err := filepath.Walk(d.path, func(p string, f os.FileInfo, err error) error { - if err != nil { - log.Println(err) - return err - } - if f != nil && f.Mode().IsRegular() { - du += uint64(f.Size()) - } - return nil - }) - return du, err -} diff --git a/core/node.go b/core/node.go index 4a25aac..ff858bc 100644 --- a/core/node.go +++ b/core/node.go @@ -11,6 +11,7 @@ import ( "context" "crypto/rand" "fmt" + "log" "os" "path/filepath" "sync/atomic" @@ -23,7 +24,6 @@ import ( "github.com/gogo/protobuf/proto" "github.com/libp2p/go-libp2p" dht "github.com/libp2p/go-libp2p-kad-dht" - "github.com/libp2p/go-libp2p/p2p/transport/tcp" "github.com/libp2p/go-libp2p/core/connmgr" "github.com/libp2p/go-libp2p/core/crypto" @@ -34,7 +34,6 @@ import ( "github.com/libp2p/go-libp2p/core/peerstore" "github.com/libp2p/go-libp2p/core/protocol" rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager" - tls "github.com/libp2p/go-libp2p/p2p/security/tls" "github.com/mr-tron/base58" ma "github.com/multiformats/go-multiaddr" "github.com/pkg/errors" @@ -296,12 +295,12 @@ func NewPeerNode(ctx context.Context, cfg *config.Config) (*PeerNode, error) { opts = append(opts, libp2p.Identity(prvKey), libp2p.ListenAddrStrings(fmt.Sprintf("/ip4/0.0.0.0/tcp/%d", cfg.ListenPort)), - libp2p.ConnectionManager(cfg.ConnManager), - libp2p.Transport(tcp.NewTCPTransport), - libp2p.Security(tls.ID, tls.New), libp2p.ProtocolVersion(cfg.ProtocolPrefix+p2pProtocolVer), + libp2p.WithDialTimeout(time.Second*time.Duration(cfg.DialTimeout)), + libp2p.DisableIdentifyAddressDiscovery(), libp2p.DisableMetrics(), - libp2p.EnableRelay(), + libp2p.DisableRelay(), + libp2p.Ping(false), ) bhost, err := libp2p.New(opts...) @@ -331,22 +330,24 @@ func NewPeerNode(ctx context.Context, cfg *config.Config) (*PeerNode, error) { protocols: NewProtocol(), } - peer_node.dhtable, peer_node.bootnode, peer_node.netenv, err = NewDHT(ctx, bhost, cfg.BucketSize, cfg.Version, boots, cfg.ProtocolPrefix, peer_node.dhtProtocolVersion) + peer_node.dhtable, peer_node.bootnode, peer_node.netenv, err = NewDHT(ctx, bhost, boots, cfg.ProtocolPrefix, peer_node.dhtProtocolVersion) if err != nil { return nil, fmt.Errorf("[NewDHT] %v", err) } + peer_node.initProtocol(cfg.ProtocolPrefix, cfg.RecordCacheLen) + if len(boots) > 0 { peer_node.dir, err = mkdir(cfg.Workspace) if err != nil { return nil, err } - peer_node.initProtocol(cfg.ProtocolPrefix) bootstrapAddr, _ := ma.NewMultiaddr(peer_node.bootnode) peerinfo, _ := peer.AddrInfoFromP2pAddr(bootstrapAddr) - peer_node.OnlineAction(peerinfo.ID) - } else { - peer_node.OnlineProtocol = peer_node.NewOnlineProtocol() + err = peer_node.OnlineAction(peerinfo.ID) + if err != nil { + log.Println("online failed: ", err) + } } return peer_node, nil @@ -648,22 +649,19 @@ func verifyWorkspace(ws string) error { return nil } -func (n *PeerNode) initProtocol(protocolPrefix string) { +func (n *PeerNode) initProtocol(protocolPrefix string, cacheLen int) { n.SetProtocolPrefix(protocolPrefix) - n.WriteFileProtocol = n.NewWriteFileProtocol() - n.ReadFileProtocol = n.NewReadFileProtocol() n.ReadDataProtocol = n.NewReadDataProtocol() n.ReadDataStatProtocol = n.NewReadDataStatProtocol() - n.OnlineProtocol = n.NewOnlineProtocol() + n.OnlineProtocol = n.NewOnlineProtocol(cacheLen) + n.WriteDataProtocol = n.NewWriteDataProtocol() } -func NewDHT(ctx context.Context, h host.Host, bucketsize int, version string, boot_nodes []string, protocolPrefix, dhtProtocol string) (*dht.IpfsDHT, string, string, error) { +func NewDHT(ctx context.Context, h host.Host, boot_nodes []string, protocolPrefix, dhtProtocol string) (*dht.IpfsDHT, string, string, error) { var options []dht.Option options = append(options, dht.ProtocolPrefix(protocol.ID(protocolPrefix)), dht.V1ProtocolOverride(protocol.ID(dhtProtocol)), - dht.Resiliency(10), - dht.BucketSize(bucketsize), ) if len(boot_nodes) == 0 { diff --git a/core/online.go b/core/online.go index b59576b..c4fc0b5 100644 --- a/core/online.go +++ b/core/online.go @@ -8,126 +8,55 @@ package core import ( - "errors" - "io" - "sync" + "fmt" "time" "github.com/CESSProject/p2p-go/pb" - "github.com/google/uuid" "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/protocol" - "google.golang.org/protobuf/proto" ) // pattern: /protocol-name/request-or-response-message/version const OnlineRequest = "/online/req/v0" -const OnlineResponse = "/online/resp/v0" type onlineResp struct { - ch chan bool *pb.MessageData } type OnlineProtocol struct { // local host *PeerNode - *sync.Mutex - requests map[string]*onlineResp // determine whether it is your own response + record chan string } -func (n *PeerNode) NewOnlineProtocol() *OnlineProtocol { - e := OnlineProtocol{PeerNode: n, Mutex: new(sync.Mutex), requests: make(map[string]*onlineResp)} - n.SetStreamHandler(protocol.ID(n.protocolPrefix+OnlineResponse), e.onOnlineResponse) +func (n *PeerNode) NewOnlineProtocol(cacheLen int) *OnlineProtocol { + if cacheLen <= 0 { + cacheLen = 1000 + } + e := OnlineProtocol{PeerNode: n, record: make(chan string, cacheLen)} + n.SetStreamHandler(protocol.ID(n.protocolPrefix+OnlineRequest), e.onOnlineResponse) return &e } func (e *protocols) OnlineAction(id peer.ID) error { - var err error - var ok bool - // create message data - req := &pb.MessageData{ - Id: uuid.New().String(), - NodeId: e.OnlineProtocol.ID().String(), - } - - // store request so response handler has access to it - respChan := make(chan bool, 1) - - e.OnlineProtocol.Lock() - for { - if _, ok := e.OnlineProtocol.requests[req.Id]; ok { - req.Id = uuid.New().String() - continue - } - e.OnlineProtocol.requests[req.Id] = &onlineResp{ - ch: respChan, - MessageData: &pb.MessageData{ - Id: req.Id, - }, - } - break - } - e.OnlineProtocol.Unlock() - - defer func() { - e.OnlineProtocol.Lock() - delete(e.OnlineProtocol.requests, req.Id) - close(respChan) - e.OnlineProtocol.Unlock() - }() - - timeout := time.NewTicker(P2PWriteReqRespTime) - defer timeout.Stop() - - err = e.OnlineProtocol.SendProtoMessage(id, protocol.ID(e.ProtocolPrefix+OnlineRequest), req) + err := e.OnlineProtocol.SendProtoMessage(id, protocol.ID(e.ProtocolPrefix+OnlineRequest), &pb.MessageData{}) if err != nil { return err } - - // wait response - timeout.Reset(P2PWriteReqRespTime) - select { - case ok = <-respChan: - if !ok { - return errors.New(ERR_RespFailure) - } - return nil - case <-timeout.C: - return errors.New(ERR_TimeOut) - } + time.Sleep(time.Second) + return nil } // remote peer response handler func (e *OnlineProtocol) onOnlineResponse(s network.Stream) { - defer s.Close() - - data := &pb.MessageData{} - buf, err := io.ReadAll(s) - if err != nil { - s.Reset() - return - } - - // unmarshal it - err = proto.Unmarshal(buf, data) - if err != nil { - s.Reset() - return + record := fmt.Sprintf("%v/p2p/%s", s.Conn().RemoteMultiaddr(), s.Conn().RemotePeer().String()) + s.Close() + if len(e.record) < 100 { + e.record <- record } +} - if data.NodeId == "" { - s.Reset() - return - } - - // locate request data and remove it if found - e.OnlineProtocol.Lock() - defer e.OnlineProtocol.Unlock() - - _, ok := e.requests[data.Id] - if ok { - e.requests[data.Id].ch <- true - } +func (e *OnlineProtocol) GetRecord() <-chan string { + return e.record } diff --git a/core/protocol.go b/core/protocol.go index 7897ab4..6998d85 100644 --- a/core/protocol.go +++ b/core/protocol.go @@ -8,21 +8,22 @@ package core import ( + "context" + "github.com/libp2p/go-libp2p/core/peer" ) type Protocol interface { - WriteFileAction(id peer.ID, roothash, path string) error - ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error - ReadDataAction(id peer.ID, name, savepath string, size int64) error - ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error) + WriteDataAction(ctx context.Context, id peer.ID, file, fid, fragment string) error + ReadDataAction(ctx context.Context, id peer.ID, name, savepath string) (int64, error) + ReadDataStatAction(ctx context.Context, id peer.ID, name string) (uint64, error) OnlineAction(id peer.ID) error + GetRecord() <-chan string } type protocols struct { ProtocolPrefix string - *WriteFileProtocol - *ReadFileProtocol + *WriteDataProtocol *ReadDataProtocol *ReadDataStatProtocol *OnlineProtocol diff --git a/core/readdata.go b/core/readdata.go index 2e5b777..4858440 100644 --- a/core/readdata.go +++ b/core/readdata.go @@ -8,15 +8,14 @@ package core import ( - "bufio" + "context" "fmt" + "io" "os" "path/filepath" "sync" - "time" "github.com/CESSProject/p2p-go/pb" - "github.com/pkg/errors" "github.com/google/uuid" "github.com/libp2p/go-libp2p/core/network" @@ -27,11 +26,11 @@ import ( // pattern: /protocol-name/request-or-response-message/version const readDataRequest = "/data/readreq/v0" - -//const readDataResponse = "/data/readresp/v0" +const readDataResponse = "/data/readresp/v0" type readDataResp struct { - *pb.ReadfileResponse + ch chan bool + *pb.ReadDataResponse } type ReadDataProtocol struct { @@ -43,51 +42,36 @@ type ReadDataProtocol struct { func (n *PeerNode) NewReadDataProtocol() *ReadDataProtocol { e := ReadDataProtocol{PeerNode: n, Mutex: new(sync.Mutex), requests: make(map[string]*readDataResp)} n.SetStreamHandler(protocol.ID(n.protocolPrefix+readDataRequest), e.onReadDataRequest) + n.SetStreamHandler(protocol.ID(n.protocolPrefix+readDataResponse), e.onReadDataResponse) return &e } -func (e *protocols) ReadDataAction(id peer.ID, name, savepath string, size int64) error { - if size <= 0 { - return errors.New("invalid size") - } - - offset, err := checkFileSize(savepath) - if err != nil { - return err - } - - var f *os.File - if offset > 0 { - if offset > size { - return fmt.Errorf("the file already exists and the size is greater than %d", size) - } - if offset == size { - return nil +func (e *protocols) ReadDataAction(ctx context.Context, id peer.ID, name, savepath string) (int64, error) { + fstat, err := os.Stat(savepath) + if err == nil { + if fstat.IsDir() { + return 0, fmt.Errorf("%s is a directory", savepath) } - f, err = os.OpenFile(savepath, os.O_WRONLY|os.O_APPEND, os.ModePerm) - if err != nil { - return errors.Wrapf(err, "open an existing file: ") - } - } else { - f, err = os.OpenFile(savepath, os.O_WRONLY|os.O_CREATE|os.O_WRONLY|os.O_APPEND, os.ModePerm) - if err != nil { - return errors.Wrapf(err, "open file: ") + if fstat.Size() > 0 { + return fstat.Size(), nil } + os.Remove(savepath) } - defer f.Close() - req := pb.ReadfileRequest{ - Roothash: "", - Datahash: name, + req := pb.ReadDataRequest{ MessageData: e.ReadDataProtocol.NewMessageData(uuid.New().String(), false), + Name: name, } - + respChan := make(chan bool, 1) e.ReadDataProtocol.Lock() for { if _, ok := e.ReadDataProtocol.requests[req.MessageData.Id]; ok { req.MessageData.Id = uuid.New().String() continue } + e.ReadDataProtocol.requests[req.MessageData.Id] = &readDataResp{ + ch: respChan, + } break } e.ReadDataProtocol.Unlock() @@ -95,214 +79,121 @@ func (e *protocols) ReadDataAction(id peer.ID, name, savepath string, size int64 defer func() { e.ReadDataProtocol.Lock() delete(e.ReadDataProtocol.requests, req.MessageData.Id) + close(respChan) e.ReadDataProtocol.Unlock() }() - timeout := time.NewTicker(P2PReadReqRespTime) - defer timeout.Stop() - - stream, err := e.ReadDataProtocol.NewPeerStream(id, protocol.ID(e.ProtocolPrefix+readDataRequest)) + err = e.ReadDataProtocol.SendProtoMessage(id, protocol.ID(e.ProtocolPrefix+readDataRequest), &req) if err != nil { - return err + return 0, fmt.Errorf("SendProtoMessage: %v", err) } - defer stream.Close() - - rw := bufio.NewReadWriter(bufio.NewReader(stream), bufio.NewWriter(stream)) - num := 0 - tmpbuf := make([]byte, 0) - recvbuf := make([]byte, 65*1024) - recvdata := &pb.ReadfileResponse{} for { - req.Offset = offset - - buf, err := proto.Marshal(&req) - if err != nil { - return errors.Wrapf(err, "[Marshal]") - } - - _, err = rw.Write(buf) - if err != nil { - return errors.Wrapf(err, "[rw.Write]") - } - - err = rw.Flush() - if err != nil { - return errors.Wrapf(err, "[rw.Flush]") - } - - timeout.Reset(P2PReadReqRespTime) select { - case <-timeout.C: - return fmt.Errorf("%s", ERR_TimeOut) - default: - num, _ = rw.Read(recvbuf) - err = proto.Unmarshal(recvbuf[:num], recvdata) + case <-ctx.Done(): + return 0, fmt.Errorf(ERR_RecvTimeOut) + case <-respChan: + e.ReadDataProtocol.Lock() + resp, ok := e.ReadDataProtocol.requests[req.MessageData.Id] + e.ReadDataProtocol.Unlock() + if !ok { + return 0, fmt.Errorf("received empty data") + } + if resp.Code != P2PResponseOK { + return 0, fmt.Errorf("received code: %d err: %v", resp.Code, resp.Msg) + } + if len(resp.Data) != int(resp.DataLength) { + return 0, fmt.Errorf("received code: %d and len(data)=%d != datalength=%d", resp.Code, len(resp.Data), resp.DataLength) + } + err = os.WriteFile(savepath, resp.Data, 0755) if err != nil { - tmpbuf = append(tmpbuf, recvbuf[:num]...) - err = proto.Unmarshal(tmpbuf, recvdata) - if err != nil { - break - } - tmpbuf = make([]byte, 0) - } - - if recvdata.MessageData == nil { - break - } - - if recvdata.Length > 0 { - num, err = f.Write(recvdata.Data[:recvdata.Length]) - if err != nil { - return errors.Wrapf(err, "[write file]") - } - err = f.Sync() - if err != nil { - return errors.Wrapf(err, "[sync file]") - } - } - - if recvdata.Code == P2PResponseFinish { - return nil - } - - if recvdata.Code != P2PResponseOK { - return errors.New("not fount") + return 0, fmt.Errorf("received suc, local WriteFile failed: %v", err) } - - offset = req.Offset + int64(num) + return resp.DataLength, nil } } } func (e *ReadDataProtocol) onReadDataRequest(s network.Stream) { - rw := bufio.NewReadWriter(bufio.NewReader(s), bufio.NewWriter(s)) - go e.readData(rw) -} - -func (e *ReadDataProtocol) readData(rw *bufio.ReadWriter) { - var err error - data := &pb.ReadfileRequest{} - recvbuf := make([]byte, 1024) - tmpbuf := make([]byte, 0) - tick := time.NewTicker(time.Second * 20) - defer tick.Stop() - for { - select { - case <-tick.C: - return - default: - num, _ := rw.Read(recvbuf) - err = proto.Unmarshal(recvbuf[:num], data) - if err != nil { - tmpbuf = append(tmpbuf, recvbuf[:num]...) - err = proto.Unmarshal(tmpbuf, data) - if err != nil { - break - } - tmpbuf = make([]byte, 0) - } + defer s.Close() - fpath := FindFile(e.ReadDataProtocol.GetDirs().FileDir, data.Datahash) - if fpath == "" { - fpath = filepath.Join(e.ReadDataProtocol.GetDirs().TmpDir, data.Datahash) - } - - resp := &pb.ReadfileResponse{ - MessageData: e.ReadDataProtocol.NewMessageData(data.MessageData.Id, false), - Code: P2PResponseOK, - Offset: data.Offset, - Length: 0, - } - - _, err = os.Stat(fpath) - if err != nil { - resp.Code = P2PResponseRemoteFailed - resp.Data = make([]byte, 0) - buffer, _ := proto.Marshal(resp) - rw.Write(buffer) - rw.Flush() - return - } - - f, err := os.Open(fpath) - if err != nil { - resp.Code = P2PResponseRemoteFailed - resp.Data = make([]byte, 0) - buffer, _ := proto.Marshal(resp) - rw.Write(buffer) - rw.Flush() - return - } - defer f.Close() + // get request data + data := &pb.ReadDataRequest{} + buf, err := io.ReadAll(s) + if err != nil { + s.Reset() + return + } - fstat, err := f.Stat() - if err != nil { - resp.Code = P2PResponseRemoteFailed - resp.Data = make([]byte, 0) - buffer, _ := proto.Marshal(resp) - rw.Write(buffer) - rw.Flush() - return - } + // unmarshal it + err = proto.Unmarshal(buf, data) + if err != nil { + s.Reset() + return + } - _, err = f.Seek(data.Offset, 0) - if err != nil { - resp.Code = P2PResponseRemoteFailed - resp.Data = make([]byte, 0) - buffer, _ := proto.Marshal(resp) - rw.Write(buffer) - rw.Flush() - return - } + resp := &pb.ReadDataResponse{ + MessageData: e.NewMessageData(data.MessageData.Id, false), + } - var readBuf = make([]byte, FileProtocolBufSize) - num, err = f.Read(readBuf) - if err != nil { - resp.Code = P2PResponseRemoteFailed - resp.Data = make([]byte, 0) - buffer, _ := proto.Marshal(resp) - rw.Write(buffer) - rw.Flush() - return - } + fpath := FindFile(e.ReadDataProtocol.GetDirs().FileDir, data.Name) + if fpath == "" { + fpath = filepath.Join(e.ReadDataProtocol.GetDirs().TmpDir, data.Name) + } - if num+int(data.Offset) >= int(fstat.Size()) { - resp.Code = P2PResponseFinish - } + fstat, err := os.Stat(fpath) + if err != nil { + resp.Code = P2PResponseEmpty + resp.Msg = "not fount" + e.ReadDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+readDataResponse), resp) + return + } - resp.Length = uint32(num) - resp.Data = readBuf[:num] + if fstat.Size() < FragmentSize { + resp.Code = P2PResponseForbid + resp.Msg = "i am also receiving the file, please read it later." + e.ReadDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+readDataResponse), resp) + return + } - buffer, err := proto.Marshal(resp) - if err != nil { - resp.Code = P2PResponseRemoteFailed - resp.Length = 0 - resp.Data = make([]byte, 0) - buffer, _ := proto.Marshal(resp) - rw.Write(buffer) - rw.Flush() - return - } - rw.Write(buffer) - rw.Flush() - if resp.Code == P2PResponseFinish { - return - } - tick.Reset(time.Second * 20) - } + buffer, err := os.ReadFile(fpath) + if err != nil { + resp.Code = P2PResponseRemoteFailed + resp.Msg = fmt.Sprintf("os.ReadFile: %v", err) + e.ReadDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+readDataResponse), resp) + return } + + resp.Code = P2PResponseOK + resp.Data = buffer + resp.DataLength = int64(len(buffer)) + resp.Msg = "success" + e.ReadDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+readDataResponse), resp) + return } -func checkFileSize(file string) (int64, error) { - fstat, err := os.Stat(file) +func (e *ReadDataProtocol) onReadDataResponse(s network.Stream) { + defer s.Close() + data := &pb.ReadDataResponse{} + buf, err := io.ReadAll(s) if err != nil { - return 0, nil + s.Reset() + return } - if fstat.IsDir() { - return 0, fmt.Errorf("%s is a directory", file) + // unmarshal it + err = proto.Unmarshal(buf, data) + if err != nil { + s.Reset() + return } - return fstat.Size(), nil + // locate request data and remove it if found + e.ReadDataProtocol.Lock() + _, ok := e.requests[data.MessageData.Id] + if ok { + e.requests[data.MessageData.Id].ch <- true + e.requests[data.MessageData.Id].ReadDataResponse = data + } + e.ReadDataProtocol.Unlock() } diff --git a/core/readfile.go b/core/readfile.go deleted file mode 100644 index 0eb4e8e..0000000 --- a/core/readfile.go +++ /dev/null @@ -1,328 +0,0 @@ -/* - Copyright (C) CESS. All rights reserved. - Copyright (C) Cumulus Encrypted Storage System. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 -*/ - -package core - -import ( - "fmt" - "io" - "io/fs" - "os" - "path/filepath" - "sync" - "time" - - "github.com/CESSProject/p2p-go/pb" - "github.com/pkg/errors" - - "github.com/google/uuid" - "github.com/libp2p/go-libp2p/core/network" - "github.com/libp2p/go-libp2p/core/peer" - "github.com/libp2p/go-libp2p/core/protocol" - "google.golang.org/protobuf/proto" -) - -// pattern: /protocol-name/request-or-response-message/version -const readFileRequest = "/file/readreq/v0" -const readFileResponse = "/file/readresp/v0" - -type ReadFileServerHandle func(req *pb.ReadfileRequest) (*pb.ReadfileResponse, error) - -type readMsgResp struct { - ch chan bool - *pb.ReadfileResponse -} - -type ReadFileProtocol struct { - *PeerNode // local host - *sync.Mutex - handle ReadFileServerHandle - requests map[string]*readMsgResp // determine whether it is your own response -} - -func (n *PeerNode) NewReadFileProtocol() *ReadFileProtocol { - e := ReadFileProtocol{PeerNode: n, Mutex: new(sync.Mutex), requests: make(map[string]*readMsgResp)} - n.SetStreamHandler(protocol.ID(n.protocolPrefix+readFileRequest), e.onReadFileRequest) - n.SetStreamHandler(protocol.ID(n.protocolPrefix+readFileResponse), e.onReadFileResponse) - return &e -} - -func (e *protocols) ReadFileAction(id peer.ID, roothash, datahash, path string, size int64) error { - var err error - var hash string - var offset int64 - var fstat fs.FileInfo - var f *os.File - - if size != FragmentSize { - return errors.New("invalid size") - } - - fstat, err = os.Stat(path) - if err == nil { - if fstat.IsDir() { - return fmt.Errorf("%s is a directory", path) - } - if fstat.Size() < size { - offset = fstat.Size() - } else if fstat.Size() == size { - hash, err = CalcPathSHA256(path) - if err != nil { - return errors.Wrapf(err, "[calc file sha256]") - } - if hash == datahash { - return nil - } - return fmt.Errorf("fragment hash does not match file") - } else { - buf, err := os.ReadFile(path) - if err != nil { - return errors.Wrapf(err, "[read file]") - } - hash, err = CalcSHA256(buf[:size]) - if err != nil { - return errors.Wrapf(err, "[calc buf sha256]") - } - if hash == datahash { - f, err = os.OpenFile(path, os.O_WRONLY|os.O_TRUNC, 0) - if err != nil { - return errors.Wrapf(err, "[open file]") - } - defer f.Close() - _, err = f.Write(buf[:size]) - if err != nil { - return errors.Wrapf(err, "[write file]") - } - err = f.Sync() - if err != nil { - return errors.Wrapf(err, "[sync file]") - } - return nil - } - os.Remove(path) - } - } - f, err = os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, os.ModePerm) - if err != nil { - return errors.Wrapf(err, "[open file]") - } - defer f.Close() - defer f.Sync() - req := &pb.ReadfileRequest{ - Roothash: roothash, - Datahash: datahash, - Offset: offset, - MessageData: e.ReadFileProtocol.NewMessageData(uuid.New().String(), false), - } - return e.readFileAction(id, req, func(req *pb.ReadfileRequest, resp *readMsgResp) error { - num, err := f.Write(resp.Data[:resp.Length]) - if err != nil { - return errors.Wrapf(err, "[write file]") - } - req.Offset += int64(num) - return nil - }) -} - -func (e *protocols) ReadFileActionWithExtension(id peer.ID, roothash, datahash string, writer io.Writer, extData []byte) error { - req := &pb.ReadfileRequest{ - Roothash: roothash, - Datahash: datahash, - ExtendData: extData, - MessageData: e.ReadFileProtocol.NewMessageData(uuid.New().String(), false), - } - return e.readFileAction(id, req, func(req *pb.ReadfileRequest, resp *readMsgResp) error { - num, err := writer.Write(resp.Data[:resp.Length]) - if err != nil { - return errors.Wrapf(err, "[write file]") - } - req.Offset += int64(num) - return nil - }) -} - -func (e *ReadFileProtocol) readFileAction( - id peer.ID, req *pb.ReadfileRequest, callback func(req *pb.ReadfileRequest, resp *readMsgResp, - ) error) error { - // store request so response handler has access to it - var respChan = make(chan bool, 1) - e.ReadFileProtocol.Lock() - for { - if _, ok := e.ReadFileProtocol.requests[req.MessageData.Id]; ok { - req.MessageData.Id = uuid.New().String() - continue - } - e.ReadFileProtocol.requests[req.MessageData.Id] = &readMsgResp{ - ch: respChan, - } - break - } - e.ReadFileProtocol.Unlock() - defer func() { - e.ReadFileProtocol.Lock() - delete(e.ReadFileProtocol.requests, req.MessageData.Id) - close(respChan) - e.ReadFileProtocol.Unlock() - }() - timeout := time.NewTicker(P2PReadReqRespTime) - defer timeout.Stop() - for { - err := e.ReadFileProtocol.SendProtoMessage(id, protocol.ID(e.ProtocolPrefix+readFileRequest), req) - if err != nil { - return errors.Wrapf(err, "[SendProtoMessage]") - } - - // - timeout.Reset(P2PReadReqRespTime) - select { - case ok := <-respChan: - if !ok { - return errors.New(ERR_RespFailure) - } - case <-timeout.C: - return errors.New(ERR_TimeOut) - } - - e.ReadFileProtocol.Lock() - resp, ok := e.ReadFileProtocol.requests[req.MessageData.Id] - if !ok { - e.ReadFileProtocol.Unlock() - return errors.New(ERR_RespFailure) - } - e.ReadFileProtocol.Unlock() - - if resp.ReadfileResponse == nil { - return errors.New(ERR_RespFailure) - } - if len(resp.ReadfileResponse.Data) == 0 || resp.Length == 0 { - if resp.Code == P2PResponseFinish { - return nil - } - return errors.New(ERR_RespFailure) - } - err = callback(req, resp) - if err != nil { - return err - } - if resp.Code == P2PResponseFinish { - return nil - } - } -} - -func (e *ReadFileProtocol) SetReadFileServiceHandle(handle ReadFileServerHandle) { - e.handle = handle -} - -func (e *ReadFileProtocol) DefaultReadFileServerHandle(req *pb.ReadfileRequest) (*pb.ReadfileResponse, error) { - var code = P2PResponseOK - fpath := filepath.Join(e.ReadFileProtocol.GetDirs().TmpDir, req.Roothash, req.Datahash) - - if _, err := os.Stat(fpath); err != nil { - fpath = filepath.Join(e.ReadFileProtocol.GetDirs().FileDir, req.Roothash, req.Datahash) - } - - f, err := os.Open(fpath) - if err != nil { - return &pb.ReadfileResponse{Code: P2PResponseFailed}, err - } - defer f.Close() - - fstat, err := f.Stat() - if err != nil { - return &pb.ReadfileResponse{Code: P2PResponseRemoteFailed}, err - } - - if _, err = f.Seek(req.Offset, 0); err != nil { - return &pb.ReadfileResponse{Code: P2PResponseRemoteFailed}, err - } - - var readBuf = make([]byte, FileProtocolBufSize) - num, err := f.Read(readBuf) - if err != nil { - return &pb.ReadfileResponse{Code: P2PResponseRemoteFailed}, err - } - - if num+int(req.Offset) >= int(fstat.Size()) { - code = P2PResponseFinish - } - - // send response to the request using the message string he provided - resp := &pb.ReadfileResponse{ - Code: code, - Offset: req.Offset, - Length: uint32(num), - Data: readBuf[:num], - } - return resp, nil -} - -// remote peer requests handler -func (e *ReadFileProtocol) onReadFileRequest(s network.Stream) { - defer s.Close() - - // get request data - data := &pb.ReadfileRequest{} - buf, err := io.ReadAll(s) - if err != nil { - s.Reset() - return - } - - // unmarshal it - err = proto.Unmarshal(buf, data) - if err != nil { - s.Reset() - return - } - handle := e.handle - if handle == nil { - handle = e.DefaultReadFileServerHandle - } - resp, err := handle(data) - if err != nil && resp == nil { - s.Reset() - return - } - resp.MessageData = e.ReadFileProtocol.NewMessageData(data.MessageData.Id, false) - e.ReadFileProtocol.SendProtoMessage( - s.Conn().RemotePeer(), - protocol.ID(e.ProtocolPrefix+readFileResponse), - resp, - ) -} - -// remote peer requests handler -func (e *ReadFileProtocol) onReadFileResponse(s network.Stream) { - defer s.Close() - data := &pb.ReadfileResponse{} - buf, err := io.ReadAll(s) - if err != nil { - s.Reset() - return - } - - // unmarshal it - err = proto.Unmarshal(buf, data) - if err != nil { - s.Reset() - return - } - - e.ReadFileProtocol.Lock() - defer e.ReadFileProtocol.Unlock() - // locate request data and remove it if found - _, ok := e.requests[data.MessageData.Id] - if ok { - if data.Code == P2PResponseOK || data.Code == P2PResponseFinish { - e.requests[data.MessageData.Id].ch <- true - e.requests[data.MessageData.Id].ReadfileResponse = data - } else { - e.requests[data.MessageData.Id].ch <- false - } - } -} diff --git a/core/readstat.go b/core/readstat.go index 120042d..22fd819 100644 --- a/core/readstat.go +++ b/core/readstat.go @@ -8,13 +8,13 @@ package core import ( + "context" + "fmt" "io" "os" "sync" - "time" "github.com/CESSProject/p2p-go/pb" - "github.com/pkg/errors" "github.com/google/uuid" "github.com/libp2p/go-libp2p/core/network" @@ -45,16 +45,12 @@ func (n *PeerNode) NewReadDataStatProtocol() *ReadDataStatProtocol { return &e } -func (e *protocols) ReadDataStatAction(id peer.ID, roothash string, datahash string) (uint64, error) { - var ok bool - var err error - var req pb.ReadDataStatRequest - req.Roothash = roothash - req.Datahash = datahash - req.MessageData = e.ReadDataStatProtocol.NewMessageData(uuid.New().String(), false) - - // store request so response handler has access to it - var respChan = make(chan bool, 1) +func (e *protocols) ReadDataStatAction(ctx context.Context, id peer.ID, name string) (uint64, error) { + req := pb.ReadDataStatRequest{ + MessageData: e.ReadDataStatProtocol.NewMessageData(uuid.New().String(), false), + Name: name, + } + respChan := make(chan bool, 1) e.ReadDataStatProtocol.Lock() for { if _, ok := e.ReadDataStatProtocol.requests[req.MessageData.Id]; ok { @@ -67,93 +63,85 @@ func (e *protocols) ReadDataStatAction(id peer.ID, roothash string, datahash str break } e.ReadDataStatProtocol.Unlock() + defer func() { e.ReadDataStatProtocol.Lock() delete(e.ReadDataStatProtocol.requests, req.MessageData.Id) close(respChan) e.ReadDataStatProtocol.Unlock() }() - timeout := time.NewTicker(P2PReadReqRespTime) - defer timeout.Stop() - err = e.ReadDataStatProtocol.SendProtoMessage(id, protocol.ID(e.ProtocolPrefix+readDataStatRequest), &req) + err := e.ReadDataStatProtocol.SendProtoMessage(id, protocol.ID(e.ProtocolPrefix+readDataStatRequest), &req) if err != nil { - return 0, errors.Wrapf(err, "[SendProtoMessage]") + return 0, fmt.Errorf("SendProtoMessage: %v", err) } - // - timeout.Reset(P2PReadReqRespTime) - select { - case ok = <-respChan: - if !ok { - return 0, errors.New(ERR_RespFailure) + for { + select { + case <-ctx.Done(): + return 0, fmt.Errorf(ERR_RecvTimeOut) + case <-respChan: + e.ReadDataStatProtocol.Lock() + resp, ok := e.ReadDataStatProtocol.requests[req.MessageData.Id] + e.ReadDataStatProtocol.Unlock() + if !ok { + return 0, fmt.Errorf("received empty data") + } + if resp.Code != P2PResponseOK { + return 0, fmt.Errorf("received code: %d err: %v", resp.Code, resp.Msg) + } + return uint64(resp.Size), nil } - case <-timeout.C: - return 0, errors.New(ERR_TimeOut) - } - - e.ReadDataStatProtocol.Lock() - resp, ok := e.ReadDataStatProtocol.requests[req.MessageData.Id] - if !ok { - e.ReadDataStatProtocol.Unlock() - return 0, errors.New(ERR_RespFailure) - } - e.ReadDataStatProtocol.Unlock() - - if resp.ReadDataStatResponse == nil { - return 0, errors.New(ERR_RespFailure) } - - if resp.Code != P2PResponseOK { - return 0, errors.New(ERR_RespFailure) - } - return uint64(resp.DataSize), nil } // remote peer requests handler func (e *ReadDataProtocol) onReadDataStatRequest(s network.Stream) { defer s.Close() - var resp = &pb.ReadDataStatResponse{ - Code: P2PResponseFailed, - } + // get request data - var data = &pb.ReadDataStatRequest{} + data := &pb.ReadDataStatRequest{} buf, err := io.ReadAll(s) if err != nil { - e.ReadDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+readDataStatResponse), resp) + s.Reset() return } // unmarshal it err = proto.Unmarshal(buf, data) if err != nil { - e.ReadDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+readDataStatResponse), resp) + s.Reset() return } - fpath := FindFile(e.ReadDataProtocol.GetDirs().FileDir, data.Datahash) + resp := &pb.ReadDataStatResponse{ + MessageData: e.NewMessageData(data.MessageData.Id, false), + } + + fpath := FindFile(e.ReadDataProtocol.GetDirs().FileDir, data.Name) if fpath == "" { - fpath = FindFile(e.ReadDataProtocol.GetDirs().TmpDir, data.Datahash) + fpath = FindFile(e.ReadDataProtocol.GetDirs().TmpDir, data.Name) } fstat, err := os.Stat(fpath) if err != nil { resp.Code = P2PResponseEmpty - e.ReadDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+readDataStatResponse), resp) + resp.Msg = fmt.Sprintf("not found") + e.ReadDataStatProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+readDataStatResponse), resp) return } // send response to the request using the message string he provided resp.Code = P2PResponseOK - resp.DataHash = data.Datahash - resp.DataSize = fstat.Size() - resp.MessageData = e.ReadDataStatProtocol.NewMessageData(data.MessageData.Id, false) - e.ReadDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+readDataStatResponse), resp) + resp.Size = fstat.Size() + resp.Msg = "success" + e.ReadDataStatProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+readDataStatResponse), resp) } // remote peer requests handler func (e *ReadDataStatProtocol) onReadDataStatResponse(s network.Stream) { defer s.Close() - var data = &pb.ReadDataStatResponse{} + + data := &pb.ReadDataStatResponse{} buf, err := io.ReadAll(s) if err != nil { s.Reset() @@ -167,22 +155,11 @@ func (e *ReadDataStatProtocol) onReadDataStatResponse(s network.Stream) { return } - if data.MessageData == nil { - s.Reset() - return - } - e.ReadDataStatProtocol.Lock() - defer e.ReadDataStatProtocol.Unlock() - - // locate request data and remove it if found _, ok := e.requests[data.MessageData.Id] if ok { - if data.Code == P2PResponseOK { - e.requests[data.MessageData.Id].ch <- true - e.requests[data.MessageData.Id].ReadDataStatResponse = data - } else { - e.requests[data.MessageData.Id].ch <- false - } + e.requests[data.MessageData.Id].ch <- true + e.requests[data.MessageData.Id].ReadDataStatResponse = data } + e.ReadDataStatProtocol.Unlock() } diff --git a/core/types.go b/core/types.go index 18a642e..1226ee5 100644 --- a/core/types.go +++ b/core/types.go @@ -21,6 +21,7 @@ const P2PResponseFinish uint32 = 210 const P2PResponseFailed uint32 = 400 const P2PResponseRemoteFailed uint32 = 500 const P2PResponseEmpty uint32 = 404 +const P2PResponseForbid uint32 = 403 const MaxFileNameLength = 255 const MaxCustomDataLength = 255 @@ -31,7 +32,8 @@ const ( ) const ( - ERR_TimeOut = "receiving data timeout" + ERR_RecvTimeOut = "receiving data timeout" + ERR_WriteTimeOut = "writing data timeout" ERR_RespFailure = "peer response failure" ERR_RespInvalidData = "peer response invalid data" ERR_RespEmptyData = "received empty data" diff --git a/core/utils.go b/core/utils.go index c5655aa..dfe2ebe 100644 --- a/core/utils.go +++ b/core/utils.go @@ -239,7 +239,7 @@ func FreeLocalPort(port uint32) bool { func FindFile(dir, name string) string { var result string - err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { + filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { if err != nil { return err } @@ -249,6 +249,5 @@ func FindFile(dir, name string) string { } return nil }) - _ = err return result } diff --git a/core/writedata.go b/core/writedata.go new file mode 100644 index 0000000..59403ed --- /dev/null +++ b/core/writedata.go @@ -0,0 +1,260 @@ +/* + Copyright (C) CESS. All rights reserved. + Copyright (C) Cumulus Encrypted Storage System. All rights reserved. + + SPDX-License-Identifier: Apache-2.0 +*/ + +package core + +import ( + "context" + "fmt" + "io" + "os" + "path/filepath" + "sync" + + "github.com/CESSProject/p2p-go/pb" + + "github.com/google/uuid" + "github.com/libp2p/go-libp2p/core/network" + "github.com/libp2p/go-libp2p/core/peer" + "github.com/libp2p/go-libp2p/core/protocol" + "google.golang.org/protobuf/proto" +) + +// pattern: /protocol-name/request-or-response-message/version +const writeDataRequest = "/data/writereq/v0" +const writeDataResponse = "/data/writeresp/v0" + +type writeDataResp struct { + ch chan bool + *pb.WriteDataResponse +} + +type WriteDataProtocol struct { + *PeerNode // local host + *sync.Mutex + requests map[string]*writeDataResp // determine whether it is your own response +} + +func (n *PeerNode) NewWriteDataProtocol() *WriteDataProtocol { + e := WriteDataProtocol{PeerNode: n, Mutex: new(sync.Mutex), requests: make(map[string]*writeDataResp)} + n.SetStreamHandler(protocol.ID(n.protocolPrefix+writeDataRequest), e.onWriteDataRequest) + n.SetStreamHandler(protocol.ID(n.protocolPrefix+writeDataResponse), e.onWriteDataResponse) + return &e +} + +func (e *protocols) WriteDataAction(ctx context.Context, id peer.ID, file, fid, fragment string) error { + buf, err := os.ReadFile(file) + if err != nil { + return fmt.Errorf("[os.ReadFile] %v", err) + } + + req := pb.WriteDataRequest{ + MessageData: e.WriteDataProtocol.NewMessageData(uuid.New().String(), false), + Fid: fid, + Datahash: fragment, + Data: buf, + DataLength: int64(len(buf)), + } + respChan := make(chan bool, 1) + e.WriteDataProtocol.Lock() + for { + if _, ok := e.WriteDataProtocol.requests[req.MessageData.Id]; ok { + req.MessageData.Id = uuid.New().String() + continue + } + e.WriteDataProtocol.requests[req.MessageData.Id] = &writeDataResp{ + ch: respChan, + } + break + } + e.WriteDataProtocol.Unlock() + + defer func() { + e.WriteDataProtocol.Lock() + delete(e.WriteDataProtocol.requests, req.MessageData.Id) + close(respChan) + e.WriteDataProtocol.Unlock() + }() + + err = e.WriteDataProtocol.SendProtoMessage(id, protocol.ID(e.ProtocolPrefix+writeDataRequest), &req) + if err != nil { + return err + } + + for { + select { + case <-ctx.Done(): + return fmt.Errorf(ERR_RecvTimeOut) + case <-respChan: + e.WriteDataProtocol.Lock() + resp, ok := e.WriteDataProtocol.requests[req.MessageData.Id] + e.WriteDataProtocol.Unlock() + if !ok { + return fmt.Errorf("received empty data") + } + if resp.Code != P2PResponseOK { + return fmt.Errorf("received code: %d err: %v", resp.Code, resp.Msg) + } + return nil + } + } +} + +func (e *WriteDataProtocol) onWriteDataRequest(s network.Stream) { + if !e.enableRecv { + s.Reset() + return + } + defer s.Close() + + // get request data + data := &pb.WriteDataRequest{} + buf, err := io.ReadAll(s) + if err != nil { + s.Reset() + return + } + + // unmarshal it + err = proto.Unmarshal(buf, data) + if err != nil { + s.Reset() + return + } + + resp := &pb.WriteDataResponse{ + MessageData: e.NewMessageData(data.MessageData.Id, false), + } + + dir := filepath.Join(e.GetDirs().TmpDir, data.Fid) + err = os.MkdirAll(dir, DirMode) + if err != nil { + resp.Code = P2PResponseRemoteFailed + resp.Msg = fmt.Sprintf("os.MkdirAll: %v", err) + e.WriteDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+writeDataResponse), resp) + return + } + + hash, err := CalcSHA256(data.Data) + if err != nil { + resp.Code = P2PResponseRemoteFailed + resp.Msg = fmt.Sprintf("CalcSHA256(len=%d): %v", len(data.Data), err) + e.WriteDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+writeDataResponse), resp) + return + } + + if data.Datahash != "" { + if hash != data.Datahash { + resp.Code = P2PResponseFailed + resp.Msg = fmt.Sprintf("received data hash: %s != recalculated hash: %s", data.Datahash, hash) + e.WriteDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+writeDataResponse), resp) + return + } + } + + fpath := filepath.Join(dir, hash) + fstat, err := os.Stat(fpath) + if err == nil { + if fstat.Size() == data.DataLength { + resp.Code = P2PResponseOK + resp.Msg = "success" + e.WriteDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+writeDataResponse), resp) + return + } + os.Remove(fpath) + } + + if data.Datahash == ZeroFileHash_8M { + err = writeZeroToFile(fpath, FragmentSize) + if err != nil { + resp.Code = P2PResponseRemoteFailed + resp.Msg = fmt.Sprintf("writeZeroToFile: %v", err) + e.WriteDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+writeDataResponse), resp) + return + } + resp.Code = P2PResponseOK + resp.Msg = "success" + e.WriteDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+writeDataResponse), resp) + return + } + + f, err := os.Create(fpath) + if err != nil { + resp.Code = P2PResponseRemoteFailed + resp.Msg = fmt.Sprintf("os.Create: %v", err) + e.WriteDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+writeDataResponse), resp) + return + } + defer f.Close() + + _, err = f.Write(data.Data) + if err != nil { + resp.Code = P2PResponseRemoteFailed + resp.Msg = fmt.Sprintf("f.Write: %v", err) + e.WriteDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+writeDataResponse), resp) + return + } + + err = f.Sync() + if err != nil { + resp.Code = P2PResponseRemoteFailed + resp.Msg = fmt.Sprintf("f.Sync: %v", err) + e.WriteDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+writeDataResponse), resp) + return + } + + resp.Code = P2PResponseOK + resp.Msg = "success" + e.WriteDataProtocol.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+writeDataResponse), resp) + return +} + +func (e *WriteDataProtocol) onWriteDataResponse(s network.Stream) { + defer s.Close() + + data := &pb.WriteDataResponse{} + buf, err := io.ReadAll(s) + if err != nil { + s.Reset() + return + } + + // unmarshal it + err = proto.Unmarshal(buf, data) + if err != nil { + s.Reset() + return + } + + // locate request data and remove it if found + e.WriteDataProtocol.Lock() + _, ok := e.requests[data.MessageData.Id] + if ok { + e.requests[data.MessageData.Id].ch <- true + e.requests[data.MessageData.Id].WriteDataResponse = data + } + e.WriteDataProtocol.Unlock() +} + +func writeZeroToFile(file string, size int64) error { + fstat, err := os.Stat(file) + if err == nil { + if fstat.Size() == size { + return nil + } + } + f, err := os.OpenFile(file, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, os.ModePerm) + if err != nil { + return err + } + defer f.Close() + _, err = f.Write(make([]byte, size)) + if err != nil { + return err + } + return f.Sync() +} diff --git a/core/writefile.go b/core/writefile.go deleted file mode 100644 index 20e62dd..0000000 --- a/core/writefile.go +++ /dev/null @@ -1,335 +0,0 @@ -/* - Copyright (C) CESS. All rights reserved. - Copyright (C) Cumulus Encrypted Storage System. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 -*/ - -package core - -import ( - "errors" - "io" - "os" - "path/filepath" - "sync" - "time" - - "github.com/CESSProject/p2p-go/pb" - - "github.com/google/uuid" - "github.com/libp2p/go-libp2p/core/network" - "github.com/libp2p/go-libp2p/core/peer" - "github.com/libp2p/go-libp2p/core/protocol" - "google.golang.org/protobuf/proto" -) - -// pattern: /protocol-name/request-or-response-message/version -const writeFileRequest = "/file/writereq/v0" -const writeFileResponse = "/file/writeresp/v0" - -type writeMsgResp struct { - ch chan bool - *pb.WritefileResponse -} - -type WriteFileProtocol struct { // local host - *PeerNode - *sync.Mutex - requests map[string]*writeMsgResp // determine whether it is your own response -} - -func (n *PeerNode) NewWriteFileProtocol() *WriteFileProtocol { - e := WriteFileProtocol{PeerNode: n, Mutex: new(sync.Mutex), requests: make(map[string]*writeMsgResp)} - n.SetStreamHandler(protocol.ID(n.protocolPrefix+writeFileRequest), e.onWriteFileRequest) - n.SetStreamHandler(protocol.ID(n.protocolPrefix+writeFileResponse), e.onWriteFileResponse) - return &e -} - -func (e *protocols) WriteFileAction(id peer.ID, roothash, path string) error { - var err error - var ok bool - var num int - var offset int64 - var f *os.File - // create message data - req := &pb.WritefileRequest{ - MessageData: e.WriteFileProtocol.NewMessageData(uuid.New().String(), false), - Roothash: roothash, - } - - fstat, err := os.Stat(path) - if err != nil { - return err - } - - if fstat.Size() != FragmentSize { - return errors.New("invalid fragment size") - } - - req.Datahash, err = CalcPathSHA256(path) - if err != nil { - return err - } - - f, err = os.Open(path) - if err != nil { - return err - } - defer f.Close() - - // store request so response handler has access to it - respChan := make(chan bool, 1) - - e.WriteFileProtocol.Lock() - for { - if _, ok := e.WriteFileProtocol.requests[req.MessageData.Id]; ok { - req.MessageData.Id = uuid.New().String() - continue - } - e.WriteFileProtocol.requests[req.MessageData.Id] = &writeMsgResp{ - ch: respChan, - } - break - } - e.WriteFileProtocol.Unlock() - - defer func() { - e.WriteFileProtocol.Lock() - delete(e.WriteFileProtocol.requests, req.MessageData.Id) - close(respChan) - e.WriteFileProtocol.Unlock() - }() - - timeout := time.NewTicker(P2PWriteReqRespTime) - defer timeout.Stop() - buf := make([]byte, FileProtocolBufSize) - for { - _, err = f.Seek(offset, 0) - if err != nil { - return err - } - num, err = f.Read(buf) - if err != nil && err != io.EOF { - return err - } - - if num == 0 { - break - } - - req.Data = buf[:num] - req.Length = uint32(num) - req.Offset = offset - req.MessageData.Timestamp = time.Now().Unix() - - err = e.WriteFileProtocol.SendProtoMessage(id, protocol.ID(e.ProtocolPrefix+writeFileRequest), req) - if err != nil { - return err - } - - // wait response - timeout.Reset(P2PWriteReqRespTime) - select { - case ok = <-respChan: - if !ok { - return errors.New(ERR_RespFailure) - } - case <-timeout.C: - return errors.New(ERR_TimeOut) - } - - e.WriteFileProtocol.Lock() - resp, ok := e.WriteFileProtocol.requests[req.MessageData.Id] - if !ok { - e.WriteFileProtocol.Unlock() - return errors.New(ERR_RespFailure) - } - e.WriteFileProtocol.Unlock() - - if resp.WritefileResponse == nil { - return errors.New(ERR_RespFailure) - } - - if resp.WritefileResponse.Code == P2PResponseFinish { - return nil - } - - if resp.WritefileResponse.Code == P2PResponseOK { - offset = resp.Offset - } else { - return errors.New(ERR_RespFailure) - } - } - return errors.New(ERR_RespInvalidData) -} - -// remote peer requests handler -func (e *WriteFileProtocol) onWriteFileRequest(s network.Stream) { - defer s.Close() - - if !e.enableRecv { - s.Reset() - return - } - - // get request data - data := &pb.WritefileRequest{} - buf, err := io.ReadAll(s) - if err != nil { - s.Reset() - return - } - - // unmarshal it - err = proto.Unmarshal(buf, data) - if err != nil { - s.Reset() - return - } - - resp := &pb.WritefileResponse{ - MessageData: e.NewMessageData(data.MessageData.Id, false), - Code: P2PResponseOK, - Offset: 0, - } - - dir := filepath.Join(e.GetDirs().TmpDir, data.Roothash) - fstat, err := os.Stat(dir) - if err != nil { - err = os.MkdirAll(dir, DirMode) - if err != nil { - s.Reset() - return - } - } else { - if !fstat.IsDir() { - os.Remove(dir) - err = os.MkdirAll(dir, DirMode) - if err != nil { - s.Reset() - return - } - } - } - var size int64 - - fpath := filepath.Join(dir, data.Datahash) - - if data.Datahash == ZeroFileHash_8M { - f, err := os.Create(fpath) - if err != nil { - s.Reset() - return - } - defer f.Close() - _, err = f.Write(make([]byte, FragmentSize)) - if err != nil { - s.Reset() - return - } - err = f.Sync() - if err != nil { - s.Reset() - return - } - resp.Code = P2PResponseFinish - e.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+writeFileResponse), resp) - return - } - - fstat, err = os.Stat(fpath) - if err == nil { - size = fstat.Size() - if size >= FragmentSize { - time.Sleep(time.Second * 5) - if size > FragmentSize { - os.Remove(fpath) - } else { - hash, err := CalcPathSHA256(fpath) - if err != nil || hash != data.Datahash { - os.Remove(fpath) - } else { - resp.Code = P2PResponseFinish - } - } - - e.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+writeFileResponse), resp) - return - } - } - - f, err := os.OpenFile(fpath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, os.ModePerm) - if err != nil { - s.Reset() - return - } - defer f.Close() - fstat, err = f.Stat() - if err != nil { - s.Reset() - return - } - size = fstat.Size() - - _, err = f.Write(data.Data[:data.Length]) - if err != nil { - s.Reset() - return - } - err = f.Sync() - if err != nil { - s.Reset() - return - } - if int(int(size)+int(data.Length)) == FragmentSize { - hash, err := CalcPathSHA256(fpath) - if err != nil || hash != data.Datahash { - os.Remove(fpath) - } else { - resp.Code = P2PResponseFinish - } - } else { - resp.Offset = size + int64(data.Length) - } - // send response to the request using the message string he provided - e.SendProtoMessage(s.Conn().RemotePeer(), protocol.ID(e.ProtocolPrefix+writeFileResponse), resp) -} - -// remote peer response handler -func (e *WriteFileProtocol) onWriteFileResponse(s network.Stream) { - defer s.Close() - - data := &pb.WritefileResponse{} - buf, err := io.ReadAll(s) - if err != nil { - s.Reset() - return - } - - // unmarshal it - err = proto.Unmarshal(buf, data) - if err != nil { - s.Reset() - return - } - - if data.MessageData == nil { - s.Reset() - return - } - - // locate request data and remove it if found - e.WriteFileProtocol.Lock() - defer e.WriteFileProtocol.Unlock() - - _, ok := e.requests[data.MessageData.Id] - if ok { - if data.Code == P2PResponseOK || data.Code == P2PResponseFinish { - e.requests[data.MessageData.Id].ch <- true - e.requests[data.MessageData.Id].WritefileResponse = data - } else { - e.requests[data.MessageData.Id].ch <- false - } - } -} diff --git a/defaults.go b/defaults.go index 3ac5607..8cfc9c6 100644 --- a/defaults.go +++ b/defaults.go @@ -9,9 +9,6 @@ package p2pgo import ( "os" - "time" - - "github.com/libp2p/go-libp2p/p2p/net/connmgr" ) // DefaultListenPort configures libp2p to use default port. @@ -20,16 +17,6 @@ var DefaultListenPort = func(cfg *Config) error { return cfg.Apply(ListenPort(port)) } -// DefaultConnectionManager creates a default connection manager. -var DefaultConnectionManager = func(cfg *Config) error { - mgr, err := connmgr.NewConnManager(10, 100, connmgr.WithGracePeriod(time.Minute), connmgr.WithSilencePeriod(time.Minute)) - if err != nil { - return err - } - cfg.ConnManager = mgr - return nil -} - // DefaultWorkSpace configures libp2p to use default work space. var DefaultWorkSpace = func(cfg *Config) error { dir, err := os.Getwd() @@ -40,8 +27,13 @@ var DefaultWorkSpace = func(cfg *Config) error { } // DefaultWorkSpace configures libp2p to use default work space. -var DefaultBucketSize = func(cfg *Config) error { - return cfg.Apply(BucketSize(100)) +var DefaultDialTimeout = func(cfg *Config) error { + return cfg.Apply(DialTimeout(10)) +} + +// DefaultWorkSpace configures libp2p to use default work space. +var DefaultRecordCacheLen = func(cfg *Config) error { + return cfg.Apply(RecordCacheLen(1000)) } // Complete list of default options and when to fallback on them. @@ -56,17 +48,17 @@ var defaults = []struct { fallback: func(cfg *Config) bool { return cfg.ListenPort == 0 }, opt: DefaultListenPort, }, - { - fallback: func(cfg *Config) bool { return cfg.ConnManager == nil }, - opt: DefaultConnectionManager, - }, { fallback: func(cfg *Config) bool { return cfg.Workspace == "" }, opt: DefaultWorkSpace, }, { - fallback: func(cfg *Config) bool { return cfg.BucketSize == 0 }, - opt: DefaultBucketSize, + fallback: func(cfg *Config) bool { return cfg.DialTimeout == 0 }, + opt: DefaultDialTimeout, + }, + { + fallback: func(cfg *Config) bool { return cfg.RecordCacheLen <= 0 }, + opt: DefaultRecordCacheLen, }, } diff --git a/examples/online/example_online.go b/examples/online/example_online.go deleted file mode 100644 index 32fbc57..0000000 --- a/examples/online/example_online.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) CESS. All rights reserved. - Copyright (C) Cumulus Encrypted Storage System. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 -*/ - -package main - -import ( - "context" - "flag" - "fmt" - "log" - "time" - - p2pgo "github.com/CESSProject/p2p-go" - "github.com/libp2p/go-libp2p/core/peer" - ma "github.com/multiformats/go-multiaddr" -) - -func main() { - ctx := context.Background() - sourcePort1 := flag.Int("p1", 15000, "Source port number") - // To construct a simple host with all the default settings, just use `New` - h1, err := p2pgo.New( - ctx, - p2pgo.PrivatekeyFile(".private1"), - p2pgo.ListenPort(*sourcePort1), // regular tcp connections - p2pgo.Workspace("."), - p2pgo.BootPeers([]string{"_dnsaddr.boot-bucket-devnet.cess.cloud"}), - ) - if err != nil { - log.Println("[p2pgo.New]", err) - return - } - defer h1.Close() - - log.Println("node1:", h1.Addrs(), h1.ID()) - - remote := "/ip4/127.0.0.1/tcp/8001/p2p/12D3KooWGDk9JJ5F6UPNuutEKSbHrTXnF5eSn3zKaR27amgU6o9S" - - maddr, err := ma.NewMultiaddr(remote) - if err != nil { - log.Println("[ma.NewMultiaddr]", err) - return - } - // Extract the peer ID from the multiaddr. - info, err := peer.AddrInfoFromP2pAddr(maddr) - if err != nil { - log.Println("[peer.AddrInfoFromP2pAddr]", err) - return - } - h1.Peerstore().AddAddr(info.ID, maddr, time.Hour) - - err = h1.OnlineAction(info.ID) - fmt.Println(err) -} diff --git a/examples/pub/pub.go b/examples/pub/pub.go index 3e7098d..bee7506 100644 --- a/examples/pub/pub.go +++ b/examples/pub/pub.go @@ -9,36 +9,21 @@ package main import ( "context" - "encoding/json" "fmt" "log" "os" "strconv" - "time" p2pgo "github.com/CESSProject/p2p-go" "github.com/CESSProject/p2p-go/config" "github.com/CESSProject/p2p-go/core" - dht "github.com/libp2p/go-libp2p-kad-dht" pubsub "github.com/libp2p/go-libp2p-pubsub" - "github.com/libp2p/go-libp2p/core/host" - "github.com/libp2p/go-libp2p/core/network" - "github.com/libp2p/go-libp2p/core/peer" - "github.com/libp2p/go-libp2p/p2p/discovery/mdns" - drouting "github.com/libp2p/go-libp2p/p2p/discovery/routing" - dutil "github.com/libp2p/go-libp2p/p2p/discovery/util" ) type Nnode struct { *core.PeerNode } -var findpeers chan peer.AddrInfo - -func init() { - findpeers = make(chan peer.AddrInfo, 1000) -} - func main() { //var ok bool ctx := context.Background() @@ -52,8 +37,7 @@ func main() { ctx, p2pgo.ListenPort(port), p2pgo.Workspace("/home/test/boot"), - p2pgo.BucketSize(1000), - p2pgo.ProtocolPrefix(config.TestnetProtocolPrefix), + p2pgo.ProtocolPrefix(config.DevnetProtocolPrefix), ) if err != nil { panic(err) @@ -71,13 +55,6 @@ func main() { panic(err) } - go Discover(ctx, peer_node.GetHost(), peer_node.GetDHTable(), peer_node.GetRendezvousVersion()) - - // setup local mDNS discovery - if err := setupDiscovery(peer_node.GetHost()); err != nil { - panic(err) - } - // join the pubsub topic called librum topic, err := gossipSub.Join(core.NetworkRoom) if err != nil { @@ -85,80 +62,14 @@ func main() { } // create publisher - publish(ctx, topic) + publish(ctx, topic, peer_node) } // start publisher to topic -func publish(ctx context.Context, topic *pubsub.Topic) { - for p := range findpeers { - data, err := json.Marshal(p) - if err != nil { - continue - } - log.Printf("Published peer: %v", p) - topic.Publish(ctx, data) +func publish(ctx context.Context, topic *pubsub.Topic, pnode *core.PeerNode) { + ch := pnode.GetRecord() + for p := range ch { + log.Printf("Published peer: %s", p) + topic.Publish(ctx, []byte(p)) } } - -func Discover(ctx context.Context, h host.Host, dht *dht.IpfsDHT, rendezvous string) { - var routingDiscovery = drouting.NewRoutingDiscovery(dht) - - dutil.Advertise(ctx, routingDiscovery, rendezvous) - - ticker := time.NewTicker(time.Second * 1) - defer ticker.Stop() - - for { - select { - case <-ctx.Done(): - return - case <-ticker.C: - peers, err := routingDiscovery.FindPeers(ctx, rendezvous) - if err != nil { - log.Fatal(err) - } - - for p := range peers { - if p.ID == h.ID() { - continue - } - findpeers <- p - fmt.Printf("Find peer: %s\n", p.ID.String()) - if h.Network().Connectedness(p.ID) != network.Connected { - _, err = h.Network().DialPeer(ctx, p.ID) - if err != nil { - continue - } - fmt.Printf("Connected to peer %s\n", p.ID.String()) - } - } - } - } -} - -// discoveryNotifee gets notified when we find a new peer via mDNS discovery -type discoveryNotifee struct { - h host.Host -} - -// HandlePeerFound connects to peers discovered via mDNS. Once they're connected, -// the PubSub system will automatically start interacting with them if they also -// support PubSub. -func (n *discoveryNotifee) HandlePeerFound(pi peer.AddrInfo) { - if pi.ID != n.h.ID() { - fmt.Printf("discovered new peer %s\n", pi.ID.String()) - err := n.h.Connect(context.Background(), pi) - if err != nil { - fmt.Printf("error connecting to peer %s: %s\n", pi.ID.String(), err) - } - findpeers <- pi - } -} - -// setupDiscovery creates an mDNS discovery service and attaches it to the libp2p Host. -// This lets us automatically discover peers on the same LAN and connect to them. -func setupDiscovery(h host.Host) error { - // setup mDNS discovery to find local peers - s := mdns.NewMdnsService(h, core.NetworkRoom, &discoveryNotifee{h: h}) - return s.Start() -} diff --git a/examples/readdata/example_readdata.go b/examples/readdata/example_readdata.go index f4e380f..b75e763 100644 --- a/examples/readdata/example_readdata.go +++ b/examples/readdata/example_readdata.go @@ -11,18 +11,18 @@ import ( "context" "flag" "fmt" + "time" p2pgo "github.com/CESSProject/p2p-go" - "github.com/libp2p/go-libp2p/core/peer" - ma "github.com/multiformats/go-multiaddr" ) -var BootPeers = []string{ +var P2P_BOOT_ADDRS = []string{ "_dnsaddr.boot-miner-devnet.cess.cloud", } +var save_file = "save_file" + func main() { - file := "readfile" ctx := context.Background() sourcePort1 := flag.Int("p1", 15000, "Source port number") sourcePort2 := flag.Int("p2", 15001, "Source port number") @@ -30,9 +30,9 @@ func main() { // peer1 peer1, err := p2pgo.New( ctx, - p2pgo.ListenPort(*sourcePort1), p2pgo.Workspace("./peer1"), - p2pgo.BootPeers(BootPeers), + p2pgo.ListenPort(*sourcePort1), + p2pgo.BootPeers(P2P_BOOT_ADDRS), ) if err != nil { panic(err) @@ -44,9 +44,9 @@ func main() { // peer2 peer2, err := p2pgo.New( ctx, - p2pgo.ListenPort(*sourcePort2), p2pgo.Workspace("./peer2"), - p2pgo.BootPeers(BootPeers), + p2pgo.ListenPort(*sourcePort2), + p2pgo.BootPeers(P2P_BOOT_ADDRS), ) if err != nil { panic(err) @@ -55,35 +55,17 @@ func main() { fmt.Println("node2:", peer2.Addrs(), peer2.ID()) - remoteAddrs := peer2.Addrs() - - for _, v := range remoteAddrs { - remoteAddr, err := ma.NewMultiaddr(fmt.Sprintf("%s/p2p/%s", v, peer2.ID().String())) - if err != nil { - fmt.Println("NewMultiaddr err: ", err) - continue - } - info, err := peer.AddrInfoFromP2pAddr(remoteAddr) - if err != nil { - fmt.Println("AddrInfoFromP2pAddr err: ", err) - continue - } + peer1.Peerstore().AddAddrs(peer2.ID(), peer2.Addrs(), time.Second*5) - err = peer1.Connect(context.TODO(), *info) - if err != nil { - fmt.Println("Connect err: ", err) - continue - } + // you need to put the test.txt file in ./peer2/file directory + // note: the size of test.txt should not be less than 8388608 + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() - // you need to put the test.txt file in ./peer2/file directory - // the size cannot exceed the size of test.txt - err = peer1.ReadDataAction(info.ID, "test.txt", file, 20) - if err != nil { - fmt.Println("ReadDataAction err: ", err) - continue - } - fmt.Println("ok") + size, err := peer1.ReadDataAction(ctx, peer2.ID(), "test.txt", save_file) + if err != nil { + fmt.Println("ReadDataAction err: ", err) return } - fmt.Println("failed") + fmt.Println("success, size: ", size) } diff --git a/examples/readfile/readfile.go b/examples/readfile/readfile.go deleted file mode 100644 index f216add..0000000 --- a/examples/readfile/readfile.go +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) CESS. All rights reserved. - Copyright (C) Cumulus Encrypted Storage System. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 -*/ - -package main - -import ( - "context" - "flag" - "fmt" - - p2pgo "github.com/CESSProject/p2p-go" - "github.com/CESSProject/p2p-go/core" - "github.com/libp2p/go-libp2p/core/peer" - ma "github.com/multiformats/go-multiaddr" -) - -var BootPeers = []string{ - "_dnsaddr.boot-miner-devnet.cess.cloud", -} - -func main() { - ctx := context.Background() - sourcePort1 := flag.Int("p1", 15000, "Source port number") - sourcePort2 := flag.Int("p2", 15001, "Source port number") - - // peer1 - peer1, err := p2pgo.New( - ctx, - p2pgo.Workspace("./peer1"), - p2pgo.ListenPort(*sourcePort1), - p2pgo.BootPeers(BootPeers), - ) - if err != nil { - panic(err) - } - defer peer1.Close() - - fmt.Println("peer1:", peer1.Addrs(), peer1.ID()) - - // peer2 - peer2, err := p2pgo.New( - ctx, - p2pgo.Workspace("./peer2"), - p2pgo.ListenPort(*sourcePort2), - p2pgo.BootPeers(BootPeers), - ) - if err != nil { - panic(err) - } - defer peer2.Close() - - fmt.Println("peer2:", peer2.Addrs(), peer2.ID()) - - remoteAddrs := peer2.Addrs() - - for _, v := range remoteAddrs { - remoteAddr, err := ma.NewMultiaddr(fmt.Sprintf("%s/p2p/%s", v, peer2.ID().String())) - if err != nil { - fmt.Println("NewMultiaddr err: ", err) - continue - } - - info, err := peer.AddrInfoFromP2pAddr(remoteAddr) - if err != nil { - fmt.Println("AddrInfoFromP2pAddr err: ", err) - continue - } - - err = peer1.Connect(context.TODO(), *info) - if err != nil { - fmt.Println("Connect err: ", err) - continue - } - - err = peer1.ReadFileAction(info.ID, "fid", "fragment_hash", "test_file", core.FragmentSize) - if err != nil { - fmt.Println("ReadDataAction err: ", err) - continue - } - fmt.Println("ok") - return - } - fmt.Println("failed") -} diff --git a/examples/readstat/example_readstat.go b/examples/readstat/example_readstat.go index 7bbfb17..34e07a7 100644 --- a/examples/readstat/example_readstat.go +++ b/examples/readstat/example_readstat.go @@ -9,30 +9,29 @@ package main import ( "context" + "flag" "fmt" - "log" + "time" p2pgo "github.com/CESSProject/p2p-go" - "github.com/libp2p/go-libp2p/core/peer" - ma "github.com/multiformats/go-multiaddr" ) -const P2P_PORT1 = 4001 -const P2P_PORT2 = 4002 - var P2P_BOOT_ADDRS = []string{ - //testnet "_dnsaddr.boot-miner-devnet.cess.cloud", } +var read_remote_file = "" + func main() { ctx := context.Background() + sourcePort1 := flag.Int("p1", 15000, "Source port number") + sourcePort2 := flag.Int("p2", 15001, "Source port number") // peer1 peer1, err := p2pgo.New( ctx, p2pgo.Workspace("./peer1"), - p2pgo.ListenPort(P2P_PORT1), + p2pgo.ListenPort(*sourcePort1), p2pgo.BootPeers(P2P_BOOT_ADDRS), ) if err != nil { @@ -40,11 +39,13 @@ func main() { } defer peer1.Close() + fmt.Println("peer1:", peer1.Addrs(), peer1.ID()) + // peer2 peer2, err := p2pgo.New( ctx, p2pgo.Workspace("./peer2"), - p2pgo.ListenPort(P2P_PORT2), + p2pgo.ListenPort(*sourcePort2), p2pgo.BootPeers(P2P_BOOT_ADDRS), ) if err != nil { @@ -52,21 +53,18 @@ func main() { } defer peer2.Close() - maddr, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/192.168.110.247/tcp/%d/p2p/%s", P2P_PORT2, peer2.ID())) - if err != nil { - panic(err) - } + fmt.Println("peer2:", peer2.Addrs(), peer2.ID()) - target_addr, err := peer.AddrInfoFromP2pAddr(maddr) - if err != nil { - panic(err) - } + peer1.Peerstore().AddAddrs(peer2.ID(), peer2.Addrs(), time.Second*5) - err = peer1.Connect(ctx, *target_addr) + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + + // you need to put read_remote_file in the ./peer2/file directory + size, err := peer1.ReadDataStatAction(ctx, peer2.ID(), read_remote_file) if err != nil { - panic(err) + fmt.Println("ReadDataStatAction err: ", err) + return } - - fragmentsize, err := peer1.ReadDataStatAction(target_addr.ID, "test_fid", "fragment_hash") - log.Println("fragment size: ", fragmentsize, " err: ", err) + fmt.Println("success, remote file size: ", size) } diff --git a/examples/rpc/rpc.go b/examples/rpc/rpc.go deleted file mode 100644 index e8b9d8d..0000000 --- a/examples/rpc/rpc.go +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (C) CESS. All rights reserved. - Copyright (C) Cumulus Encrypted Storage System. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 -*/ - -package main - -import ( - "fmt" - "time" - - "github.com/CESSProject/p2p-go/core" - "github.com/CESSProject/p2p-go/pb" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" -) - -func main() { - var n = &core.PeerNode{} - result, err := n.RequestSpaceProofVerifySingleBlock( - "127.0.0.1:10010", - &pb.RequestSpaceProofVerify{}, - time.Minute, - []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}, - nil, - ) - if err != nil { - fmt.Println("err: ", err) - } else { - fmt.Println("result: ", result) - } -} diff --git a/examples/sub/sub.go b/examples/sub/sub.go index bdf6088..b7d3a40 100644 --- a/examples/sub/sub.go +++ b/examples/sub/sub.go @@ -19,11 +19,12 @@ import ( "github.com/libp2p/go-libp2p/core/peer" ) -const P2P_PORT = 4001 +const P2P_PORT = 4002 var P2P_BOOT_ADDRS = []string{ //testnet - "_dnsaddr.boot-miner-devnet.cess.cloud", + //"_dnsaddr.boot-miner-testnet.cess.network", + "/ip4/192.168.110.247/tcp/3328/p2p/12D3KooWCQBqdQGJj1FUkt7FYdmLhwAxQ1sXC1TSn985MKg6nTbn", } func main() { @@ -40,6 +41,9 @@ func main() { } defer peer_node.Close() + fmt.Println(peer_node.Addrs()) + fmt.Println(peer_node.ID().String()) + // create a new PubSub service using the GossipSub router gossipSub, err := pubsub.NewGossipSub(ctx, peer_node.GetHost()) if err != nil { diff --git a/examples/writedata/example_writedata.go b/examples/writedata/example_writedata.go new file mode 100644 index 0000000..80b6ac3 --- /dev/null +++ b/examples/writedata/example_writedata.go @@ -0,0 +1,70 @@ +/* + Copyright (C) CESS. All rights reserved. + Copyright (C) Cumulus Encrypted Storage System. All rights reserved. + + SPDX-License-Identifier: Apache-2.0 +*/ + +package main + +import ( + "context" + "flag" + "fmt" + "time" + + p2pgo "github.com/CESSProject/p2p-go" +) + +var P2P_BOOT_ADDRS = []string{ + "_dnsaddr.boot-miner-devnet.cess.cloud", +} + +var send_file = "" +var send_file_hash = "" + +func main() { + ctx := context.Background() + sourcePort1 := flag.Int("p1", 15000, "Source port number") + sourcePort2 := flag.Int("p2", 15001, "Source port number") + + // peer1 + peer1, err := p2pgo.New( + ctx, + p2pgo.Workspace("./peer1"), + p2pgo.ListenPort(*sourcePort1), + p2pgo.BootPeers(P2P_BOOT_ADDRS), + ) + if err != nil { + panic(err) + } + defer peer1.Close() + + fmt.Println("node1:", peer1.Addrs(), peer1.ID()) + + // peer2 + peer2, err := p2pgo.New( + ctx, + p2pgo.Workspace("./peer2"), + p2pgo.ListenPort(*sourcePort2), + p2pgo.BootPeers(P2P_BOOT_ADDRS), + ) + if err != nil { + panic(err) + } + defer peer2.Close() + + fmt.Println("node2:", peer2.Addrs(), peer2.ID()) + + peer1.Peerstore().AddAddrs(peer2.ID(), peer2.Addrs(), time.Second*5) + + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + + err = peer1.WriteDataAction(ctx, peer2.ID(), send_file, "fid", send_file_hash) + if err != nil { + fmt.Println("WriteDataAction err: ", err) + return + } + fmt.Println("success") +} diff --git a/examples/writedata/writedata b/examples/writedata/writedata new file mode 100755 index 0000000..895d4bd Binary files /dev/null and b/examples/writedata/writedata differ diff --git a/examples/writefile/writefile.go b/examples/writefile/writefile.go deleted file mode 100644 index 1e16421..0000000 --- a/examples/writefile/writefile.go +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright (C) CESS. All rights reserved. - Copyright (C) Cumulus Encrypted Storage System. All rights reserved. - - SPDX-License-Identifier: Apache-2.0 -*/ - -package main - -import ( - "context" - "fmt" - "os" - - p2pgo "github.com/CESSProject/p2p-go" - "github.com/CESSProject/p2p-go/core" - "github.com/libp2p/go-libp2p/core/peer" - ma "github.com/multiformats/go-multiaddr" -) - -const P2P_PORT1 = 4001 -const P2P_PORT2 = 4002 - -var P2P_BOOT_ADDRS = []string{ - //testnet - "_dnsaddr.boot-miner-devnet.cess.cloud", -} - -func main() { - ctx := context.Background() - - // peer1 - peer1, err := p2pgo.New( - ctx, - p2pgo.Workspace("./peer1"), - p2pgo.ListenPort(P2P_PORT1), - p2pgo.BootPeers(P2P_BOOT_ADDRS), - ) - if err != nil { - panic(err) - } - defer peer1.Close() - - // peer2 - peer2, err := p2pgo.New( - ctx, - p2pgo.Workspace("./peer2"), - p2pgo.ListenPort(P2P_PORT2), - p2pgo.BootPeers(P2P_BOOT_ADDRS), - ) - if err != nil { - panic(err) - } - defer peer2.Close() - - maddr, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/192.168.110.247/tcp/%d/p2p/%s", P2P_PORT2, peer2.ID())) - if err != nil { - panic(err) - } - - target_addr, err := peer.AddrInfoFromP2pAddr(maddr) - if err != nil { - panic(err) - } - - err = peer1.Connect(ctx, *target_addr) - if err != nil { - panic(err) - } - - err = os.WriteFile("./test_file", make([]byte, core.FragmentSize), os.ModePerm) - if err != nil { - panic(err) - } - defer os.Remove("./test_file") - - err = peer1.WriteFileAction(target_addr.ID, "test_fid", "./test_file") - fmt.Println("err: ", err) -} diff --git a/go.mod b/go.mod index d711d86..2e74223 100644 --- a/go.mod +++ b/go.mod @@ -7,37 +7,37 @@ toolchain go1.21.12 require ( github.com/gogo/protobuf v1.3.2 github.com/google/uuid v1.6.0 - github.com/ipfs/go-datastore v0.6.0 - github.com/libp2p/go-libp2p v0.32.2 + github.com/libp2p/go-libp2p v0.36.1 github.com/libp2p/go-libp2p-kad-dht v0.25.2 - github.com/libp2p/go-libp2p-pubsub v0.10.0 + github.com/libp2p/go-libp2p-pubsub v0.11.0 github.com/mr-tron/base58 v1.2.0 - github.com/multiformats/go-multiaddr v0.12.2 + github.com/multiformats/go-multiaddr v0.13.0 github.com/pkg/errors v0.9.1 google.golang.org/grpc v1.62.1 - google.golang.org/protobuf v1.33.0 + google.golang.org/protobuf v1.34.2 ) require ( github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/containerd/cgroups v1.1.0 // indirect github.com/coreos/go-systemd/v22 v22.5.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/docker/go-units v0.5.0 // indirect - github.com/elastic/gosigar v0.14.2 // indirect + github.com/elastic/gosigar v0.14.3 // indirect github.com/flynn/noise v1.1.0 // indirect github.com/francoispqt/gojay v1.2.13 // indirect - github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect + github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/gopacket v1.1.19 // indirect - github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 // indirect - github.com/gorilla/websocket v1.5.1 // indirect + github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect + github.com/gorilla/websocket v1.5.3 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect @@ -45,14 +45,15 @@ require ( github.com/huin/goupnp v1.3.0 // indirect github.com/ipfs/boxo v0.16.0 // indirect github.com/ipfs/go-cid v0.4.1 // indirect + github.com/ipfs/go-datastore v0.6.0 // indirect github.com/ipfs/go-log v1.0.5 // indirect github.com/ipfs/go-log/v2 v2.5.1 // indirect github.com/ipld/go-ipld-prime v0.21.0 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect github.com/jbenet/goprocess v0.1.4 // indirect - github.com/klauspost/compress v1.17.6 // indirect - github.com/klauspost/cpuid/v2 v2.2.7 // indirect + github.com/klauspost/compress v1.17.9 // indirect + github.com/klauspost/cpuid/v2 v2.2.8 // indirect github.com/koron/go-ssdp v0.0.4 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/libp2p/go-cidranger v1.1.0 // indirect @@ -66,10 +67,9 @@ require ( github.com/libp2p/go-netroute v0.2.1 // indirect github.com/libp2p/go-reuseport v0.4.0 // indirect github.com/libp2p/go-yamux/v4 v4.0.1 // indirect - github.com/libp2p/zeroconf/v2 v2.2.0 // indirect github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/miekg/dns v1.1.58 // indirect + github.com/miekg/dns v1.1.61 // indirect github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect github.com/minio/sha256-simd v1.0.1 // indirect @@ -82,40 +82,60 @@ require ( github.com/multiformats/go-multihash v0.2.3 // indirect github.com/multiformats/go-multistream v0.5.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect - github.com/onsi/ginkgo/v2 v2.15.0 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/onsi/ginkgo/v2 v2.19.1 // indirect github.com/opencontainers/runtime-spec v1.2.0 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect + github.com/pion/datachannel v1.5.8 // indirect + github.com/pion/dtls/v2 v2.2.12 // indirect + github.com/pion/ice/v2 v2.3.32 // indirect + github.com/pion/interceptor v0.1.29 // indirect + github.com/pion/logging v0.2.2 // indirect + github.com/pion/mdns v0.0.12 // indirect + github.com/pion/randutil v0.1.0 // indirect + github.com/pion/rtcp v1.2.14 // indirect + github.com/pion/rtp v1.8.8 // indirect + github.com/pion/sctp v1.8.20 // indirect + github.com/pion/sdp/v3 v3.0.9 // indirect + github.com/pion/srtp/v2 v2.0.20 // indirect + github.com/pion/stun v0.6.1 // indirect + github.com/pion/transport/v2 v2.2.9 // indirect + github.com/pion/turn/v2 v2.1.6 // indirect + github.com/pion/webrtc/v3 v3.2.50 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polydawn/refmt v0.89.0 // indirect - github.com/prometheus/client_golang v1.18.0 // indirect - github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.47.0 // indirect - github.com/prometheus/procfs v0.12.0 // indirect + github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect github.com/quic-go/qpack v0.4.0 // indirect - github.com/quic-go/qtls-go1-20 v0.3.4 // indirect - github.com/quic-go/quic-go v0.39.4 // indirect - github.com/quic-go/webtransport-go v0.6.0 // indirect + github.com/quic-go/quic-go v0.45.2 // indirect + github.com/quic-go/webtransport-go v0.8.0 // indirect github.com/raulk/go-watchdog v1.3.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect + github.com/stretchr/testify v1.9.0 // indirect github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect + github.com/wlynxg/anet v0.0.3 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/otel v1.21.0 // indirect go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect go.uber.org/dig v1.17.1 // indirect - go.uber.org/fx v1.20.1 // indirect + go.uber.org/fx v1.22.1 // indirect go.uber.org/mock v0.4.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.19.0 // indirect - golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect - golang.org/x/mod v0.15.0 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.18.0 // indirect + golang.org/x/crypto v0.25.0 // indirect + golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect + golang.org/x/mod v0.19.0 // indirect + golang.org/x/net v0.27.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect + golang.org/x/tools v0.23.0 // indirect gonum.org/v1/gonum v0.14.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect - lukechampine.com/blake3 v1.2.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + lukechampine.com/blake3 v1.3.0 // indirect ) diff --git a/go.sum b/go.sum index 8882f0e..40bb599 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cilium/ebpf v0.2.0/go.mod h1:To2CFviqOWL/M0gIMsvSMlqe7em/l1ALkX1PyjrX2Qs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= @@ -40,15 +40,15 @@ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/elastic/gosigar v0.12.0/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= -github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/4= -github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= +github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/uo= +github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -65,12 +65,12 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -115,10 +115,11 @@ github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 h1:E/LAvt58di64hlYjx7AsNS6C/ysHWYo+2qPCZKTQhRo= -github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k= +github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= @@ -126,8 +127,8 @@ github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE0 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c h1:7lF+Vz0LqiRidnzC1Oq86fpX1q/iEv2KJdrCtttYjT4= github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -173,10 +174,10 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI= -github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= -github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= -github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= +github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= +github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/koron/go-ssdp v0.0.4 h1:1IDwrghSKYM7yLf7XCzbByg2sJ/JcNOZRXS2jczTwz0= github.com/koron/go-ssdp v0.0.4/go.mod h1:oDXq+E5IL5q0U8uSBcoAXzTzInwy5lEgC91HoKtbmZk= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -194,16 +195,16 @@ github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38y github.com/libp2p/go-cidranger v1.1.0/go.mod h1:KWZTfSr+r9qEo9OkI9/SIEeAtw+NNoU0dXIXt15Okic= github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= -github.com/libp2p/go-libp2p v0.32.2 h1:s8GYN4YJzgUoyeYNPdW7JZeZ5Ee31iNaIBfGYMAY4FQ= -github.com/libp2p/go-libp2p v0.32.2/go.mod h1:E0LKe+diV/ZVJVnOJby8VC5xzHF0660osg71skcxJvk= +github.com/libp2p/go-libp2p v0.36.1 h1:piAHesy0/8ifBEBUS8HF2m7ywR5vnktUFv00dTsVKcs= +github.com/libp2p/go-libp2p v0.36.1/go.mod h1:vHzel3CpRB+vS11fIjZSJAU4ALvieKV9VZHC9VerHj8= github.com/libp2p/go-libp2p-asn-util v0.4.1 h1:xqL7++IKD9TBFMgnLPZR6/6iYhawHKHl950SO9L6n94= github.com/libp2p/go-libp2p-asn-util v0.4.1/go.mod h1:d/NI6XZ9qxw67b4e+NgpQexCIiFYJjErASrYW4PFDN8= github.com/libp2p/go-libp2p-kad-dht v0.25.2 h1:FOIk9gHoe4YRWXTu8SY9Z1d0RILol0TrtApsMDPjAVQ= github.com/libp2p/go-libp2p-kad-dht v0.25.2/go.mod h1:6za56ncRHYXX4Nc2vn8z7CZK0P4QiMcrn77acKLM2Oo= github.com/libp2p/go-libp2p-kbucket v0.6.3 h1:p507271wWzpy2f1XxPzCQG9NiN6R6lHL9GiSErbQQo0= github.com/libp2p/go-libp2p-kbucket v0.6.3/go.mod h1:RCseT7AH6eJWxxk2ol03xtP9pEHetYSPXOaJnOiD8i0= -github.com/libp2p/go-libp2p-pubsub v0.10.0 h1:wS0S5FlISavMaAbxyQn3dxMOe2eegMfswM471RuHJwA= -github.com/libp2p/go-libp2p-pubsub v0.10.0/go.mod h1:1OxbaT/pFRO5h+Dpze8hdHQ63R0ke55XTs6b6NwLLkw= +github.com/libp2p/go-libp2p-pubsub v0.11.0 h1:+JvS8Kty0OiyUiN0i8H5JbaCgjnJTRnTHe4rU88dLFc= +github.com/libp2p/go-libp2p-pubsub v0.11.0/go.mod h1:QEb+hEV9WL9wCiUAnpY29FZR6W3zK8qYlaml8R4q6gQ= github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3queqa1NkQ0= github.com/libp2p/go-libp2p-record v0.2.0/go.mod h1:I+3zMkvvg5m2OcSdoL0KPljyJyvNDFGKX7QdlpYUcwk= github.com/libp2p/go-libp2p-routing-helpers v0.7.3 h1:u1LGzAMVRK9Nqq5aYDVOiq/HaB93U9WWczBzGyAC5ZY= @@ -220,8 +221,6 @@ github.com/libp2p/go-reuseport v0.4.0 h1:nR5KU7hD0WxXCJbmw7r2rhRYruNRl2koHw8fQsc github.com/libp2p/go-reuseport v0.4.0/go.mod h1:ZtI03j/wO5hZVDFo2jKywN6bYKWLOy8Se6DrI2E1cLU= github.com/libp2p/go-yamux/v4 v4.0.1 h1:FfDR4S1wj6Bw2Pqbc8Uz7pCxeRBPbwsBbEdfwiCypkQ= github.com/libp2p/go-yamux/v4 v4.0.1/go.mod h1:NWjl8ZTLOGlozrXSOZ/HlfG++39iKNnM5wwmtQP1YB4= -github.com/libp2p/zeroconf/v2 v2.2.0 h1:Cup06Jv6u81HLhIj1KasuNM/RHHrJ8T7wOTS4+Tv53Q= -github.com/libp2p/zeroconf/v2 v2.2.0/go.mod h1:fuJqLnUwZTshS3U/bMRJ3+ow/v9oid1n0DmyYyNO1Xs= github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8u83wA0rVZ8ttrq5CpaPZdvrK0LP2lOk= @@ -232,9 +231,8 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= -github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= -github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY= +github.com/miekg/dns v1.1.61 h1:nLxbwF3XxhwVSm8g9Dghm9MHPaUZuqhPiGL+675ZmEs= +github.com/miekg/dns v1.1.61/go.mod h1:mnAarhS3nWaW+NVP2wTkYVIZyHNJ098SJZUki3eykwQ= github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c h1:bzE/A84HN25pxAuk9Eej1Kz9OUelF97nAc82bDquQI8= github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c/go.mod h1:0SQS9kMwD2VsyFEB++InYyBJroV/FRmBgcydeSUcJms= github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b h1:z78hV3sbSMAUoyUMM0I83AUIT6Hu17AWfgjzIbtrYFc= @@ -256,8 +254,8 @@ github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9 github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= github.com/multiformats/go-multiaddr v0.1.1/go.mod h1:aMKBKNEYmzmDmxfX88/vz+J5IU55txyt0p4aiWVohjo= github.com/multiformats/go-multiaddr v0.2.0/go.mod h1:0nO36NvPpyV4QzvTLi/lafl2y95ncPj0vFwVF6k6wJ4= -github.com/multiformats/go-multiaddr v0.12.2 h1:9G9sTY/wCYajKa9lyfWPmpZAwe6oV+Wb1zcmMS1HG24= -github.com/multiformats/go-multiaddr v0.12.2/go.mod h1:GKyaTYjZRdcUhyOetrxTk9z0cW+jA/YrnqTOvKgi44M= +github.com/multiformats/go-multiaddr v0.13.0 h1:BCBzs61E3AGHcYYTv8dqRH43ZfyrqM8RXVPT8t13tLQ= +github.com/multiformats/go-multiaddr v0.13.0/go.mod h1:sBXrNzucqkFJhvKOiwwLyqamGa/P5EIXNPLovyhQCII= github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= github.com/multiformats/go-multiaddr-dns v0.3.1/go.mod h1:G/245BRQ6FJGmryJCrOuTdB37AMA5AMOVuO6NY3JwTk= github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E= @@ -274,12 +272,14 @@ github.com/multiformats/go-multistream v0.5.0/go.mod h1:n6tMZiwiP2wUsR8DgfDWw1dy github.com/multiformats/go-varint v0.0.1/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= -github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= -github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= -github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= -github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= +github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0= +github.com/onsi/ginkgo/v2 v2.19.1/go.mod h1:O3DtEWQkPa/F7fBMgmZQKKsluAy8pd3rEQdrjkPb9zA= +github.com/onsi/gomega v1.34.0 h1:eSSPsPNp6ZpsG8X1OVmOTxig+CblTc4AxpPBykhe2Os= +github.com/onsi/gomega v1.34.0/go.mod h1:MIKI8c+f+QLWk+hxbePD4i0LMJSExPaZOVfkoex4cAo= github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk= github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= @@ -288,6 +288,49 @@ github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYr github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= +github.com/pion/datachannel v1.5.8 h1:ph1P1NsGkazkjrvyMfhRBUAWMxugJjq2HfQifaOoSNo= +github.com/pion/datachannel v1.5.8/go.mod h1:PgmdpoaNBLX9HNzNClmdki4DYW5JtI7Yibu8QzbL3tI= +github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s= +github.com/pion/dtls/v2 v2.2.12 h1:KP7H5/c1EiVAAKUmXyCzPiQe5+bCJrpOeKg/L05dunk= +github.com/pion/dtls/v2 v2.2.12/go.mod h1:d9SYc9fch0CqK90mRk1dC7AkzzpwJj6u2GU3u+9pqFE= +github.com/pion/ice/v2 v2.3.32 h1:VwE/uEeqiMm0zUWpdt1DJtnqEkj3UjEbhX92/CurtWI= +github.com/pion/ice/v2 v2.3.32/go.mod h1:8fac0+qftclGy1tYd/nfwfHC729BLaxtVqMdMVCAVPU= +github.com/pion/interceptor v0.1.29 h1:39fsnlP1U8gw2JzOFWdfCU82vHvhW9o0rZnZF56wF+M= +github.com/pion/interceptor v0.1.29/go.mod h1:ri+LGNjRUc5xUNtDEPzfdkmSqISixVTBF/z/Zms/6T4= +github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= +github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= +github.com/pion/mdns v0.0.12 h1:CiMYlY+O0azojWDmxdNr7ADGrnZ+V6Ilfner+6mSVK8= +github.com/pion/mdns v0.0.12/go.mod h1:VExJjv8to/6Wqm1FXK+Ii/Z9tsVk/F5sD/N70cnYFbk= +github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA= +github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8= +github.com/pion/rtcp v1.2.12/go.mod h1:sn6qjxvnwyAkkPzPULIbVqSKI5Dv54Rv7VG0kNxh9L4= +github.com/pion/rtcp v1.2.14 h1:KCkGV3vJ+4DAJmvP0vaQShsb0xkRfWkO540Gy102KyE= +github.com/pion/rtcp v1.2.14/go.mod h1:sn6qjxvnwyAkkPzPULIbVqSKI5Dv54Rv7VG0kNxh9L4= +github.com/pion/rtp v1.8.3/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU= +github.com/pion/rtp v1.8.8 h1:EtYFHI0rpUEjT/RMnGfb1vdJhbYmPG77szD72uUnSxs= +github.com/pion/rtp v1.8.8/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU= +github.com/pion/sctp v1.8.20 h1:sOc3lkV/tQaP57ZUEXIMdM2V92IIB2ia5v/ygnBxaEg= +github.com/pion/sctp v1.8.20/go.mod h1:oTxw8i5m+WbDHZJL/xUpe6CPIn1Y0GIKKwTLF4h53H8= +github.com/pion/sdp/v3 v3.0.9 h1:pX++dCHoHUwq43kuwf3PyJfHlwIj4hXA7Vrifiq0IJY= +github.com/pion/sdp/v3 v3.0.9/go.mod h1:B5xmvENq5IXJimIO4zfp6LAe1fD9N+kFv+V/1lOdz8M= +github.com/pion/srtp/v2 v2.0.20 h1:HNNny4s+OUmG280ETrCdgFndp4ufx3/uy85EawYEhTk= +github.com/pion/srtp/v2 v2.0.20/go.mod h1:0KJQjA99A6/a0DOVTu1PhDSw0CXF2jTkqOoMg3ODqdA= +github.com/pion/stun v0.6.1 h1:8lp6YejULeHBF8NmV8e2787BogQhduZugh5PdhDyyN4= +github.com/pion/stun v0.6.1/go.mod h1:/hO7APkX4hZKu/D0f2lHzNyvdkTGtIy3NDmLR7kSz/8= +github.com/pion/transport/v2 v2.2.1/go.mod h1:cXXWavvCnFF6McHTft3DWS9iic2Mftcz1Aq29pGcU5g= +github.com/pion/transport/v2 v2.2.3/go.mod h1:q2U/tf9FEfnSBGSW6w5Qp5PFWRLRj3NjLhCCgpRK4p0= +github.com/pion/transport/v2 v2.2.4/go.mod h1:q2U/tf9FEfnSBGSW6w5Qp5PFWRLRj3NjLhCCgpRK4p0= +github.com/pion/transport/v2 v2.2.8/go.mod h1:sq1kSLWs+cHW9E+2fJP95QudkzbK7wscs8yYgQToO5E= +github.com/pion/transport/v2 v2.2.9 h1:WEDygVovkJlV2CCunM9KS2kds+kcl7zdIefQA5y/nkE= +github.com/pion/transport/v2 v2.2.9/go.mod h1:sq1kSLWs+cHW9E+2fJP95QudkzbK7wscs8yYgQToO5E= +github.com/pion/transport/v3 v3.0.1/go.mod h1:UY7kiITrlMv7/IKgd5eTUcaahZx5oUN3l9SzK5f5xE0= +github.com/pion/transport/v3 v3.0.6 h1:k1mQU06bmmX143qSWgXFqSH1KUJceQvIUuVH/K5ELWw= +github.com/pion/transport/v3 v3.0.6/go.mod h1:HvJr2N/JwNJAfipsRleqwFoR3t/pWyHeZUs89v3+t5s= +github.com/pion/turn/v2 v2.1.3/go.mod h1:huEpByKKHix2/b9kmTAM3YoX6MKP+/D//0ClgUYR2fY= +github.com/pion/turn/v2 v2.1.6 h1:Xr2niVsiPTB0FPtt+yAWKFUkU1eotQbGgpTIld4x1Gc= +github.com/pion/turn/v2 v2.1.6/go.mod h1:huEpByKKHix2/b9kmTAM3YoX6MKP+/D//0ClgUYR2fY= +github.com/pion/webrtc/v3 v3.2.50 h1:C/rwL2mBfCxHv6tlLzDAO3krJpQXfVx8A8WHnGJ2j34= +github.com/pion/webrtc/v3 v3.2.50/go.mod h1:dytYYoSBy7ZUWhJMbndx9UckgYvzNAfL7xgVnrIKxqo= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -296,26 +339,24 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/polydawn/refmt v0.89.0 h1:ADJTApkvkeBZsN0tBTx8QjpD9JkmxbKp0cxfr9qszm4= github.com/polydawn/refmt v0.89.0/go.mod h1:/zvteZs/GwLtCgZ4BL6CBsk9IKIlexP43ObX9AxTqTw= github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= -github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= -github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= -github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= -github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.39.4 h1:PelfiuG7wXEffUT2yceiqz5V6Pc0TA5ruOd1LcmFc1s= -github.com/quic-go/quic-go v0.39.4/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= -github.com/quic-go/webtransport-go v0.6.0 h1:CvNsKqc4W2HljHJnoT+rMmbRJybShZ0YPFDD3NxaZLY= -github.com/quic-go/webtransport-go v0.6.0/go.mod h1:9KjU4AEBqEQidGHNDkZrb8CAa1abRaosM2yGOyiikEc= +github.com/quic-go/quic-go v0.45.2 h1:DfqBmqjb4ExSdxRIb/+qXhPC+7k6+DUNZha4oeiC9fY= +github.com/quic-go/quic-go v0.45.2/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI= +github.com/quic-go/webtransport-go v0.8.0 h1:HxSrwun11U+LlmwpgM1kEqIqH90IT4N8auv/cD7QFJg= +github.com/quic-go/webtransport-go v0.8.0/go.mod h1:N99tjprW432Ut5ONql/aUhSLT0YVSlwHohQsuac9WaM= github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtDqv66NfsMU= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -359,16 +400,18 @@ github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= @@ -378,9 +421,12 @@ github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSD github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1/go.mod h1:8UvriyWtv5Q5EOgjHaSseUEdkQfvwFv1I/In/O2M9gc= +github.com/wlynxg/anet v0.0.3 h1:PvR53psxFXstc12jelG6f1Lv4MWqE0tI76/hHGjh9rg= +github.com/wlynxg/anet v0.0.3/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= @@ -392,12 +438,10 @@ go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8 go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/dig v1.17.1 h1:Tga8Lz8PcYNsWsyHMZ1Vm0OQOUaJNDyvPImgbAu9YSc= go.uber.org/dig v1.17.1/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE= -go.uber.org/fx v1.20.1 h1:zVwVQGS8zYvhh9Xxcu4w1M6ESyeMzebzj2NbSayZ4Mk= -go.uber.org/fx v1.20.1/go.mod h1:iSYNbHf2y55acNCwCXKx7LbWb5WG1Bnue5RDXz1OREg= +go.uber.org/fx v1.22.1 h1:nvvln7mwyT5s1q201YE29V/BFrGor6vMiDNpU/78Mys= +go.uber.org/fx v1.22.1/go.mod h1:HT2M7d7RHo+ebKGh9NRcrsrHHfpZ60nW3QRubMRfv48= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= @@ -423,11 +467,15 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE= -golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -439,8 +487,10 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= -golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -458,9 +508,14 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210423184538-5f58ad60dda6/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -474,8 +529,10 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180810173357-98c5dad5d1a0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -490,23 +547,41 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210426080607-c94f62235c83/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -524,8 +599,10 @@ golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= -golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= +golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -567,10 +644,11 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= @@ -590,7 +668,7 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= -lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= +lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE= +lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= diff --git a/options.go b/options.go index 8351dbc..abb0281 100644 --- a/options.go +++ b/options.go @@ -7,12 +7,6 @@ package p2pgo -import ( - "time" - - "github.com/libp2p/go-libp2p/p2p/net/connmgr" -) - // ListenPort configuration listening port func ListenPort(port int) Option { return func(cfg *Config) error { @@ -29,24 +23,6 @@ func Workspace(workspace string) Option { } } -// MaxConnection configuration max connection -func MaxConnection(low, high int) Option { - return func(cfg *Config) error { - if low < 0 { - low = 1 - } - if high < 0 { - high = low - } - mgr, err := connmgr.NewConnManager(low, high, connmgr.WithGracePeriod(time.Hour), connmgr.WithSilencePeriod(time.Minute)) - if err != nil { - return nil - } - cfg.ConnManager = mgr - return nil - } -} - // BootPeers configuration bootstrap nodes func BootPeers(bootpeers []string) Option { return func(cfg *Config) error { @@ -63,7 +39,7 @@ func PrivatekeyFile(privatekey string) Option { } } -// PrivatekeyFile configuration privatekey file +// set protocol prefix func ProtocolPrefix(protocolPrefix string) Option { return func(cfg *Config) error { cfg.ProtocolPrefix = protocolPrefix @@ -71,26 +47,18 @@ func ProtocolPrefix(protocolPrefix string) Option { } } -// PrivatekeyFile configuration privatekey file -func PublicIpv4(ip string) Option { - return func(cfg *Config) error { - cfg.PublicIpv4 = ip - return nil - } -} - -// BucketSize configuration bucket size -func BucketSize(size int) Option { +// set timeout for dialing +func DialTimeout(timeout int) Option { return func(cfg *Config) error { - cfg.BucketSize = size + cfg.DialTimeout = timeout return nil } } -// Version configuration version -func Version(ver string) Option { +// set the boot node to record the cache channel length of other nodes +func RecordCacheLen(length int) Option { return func(cfg *Config) error { - cfg.Version = ver + cfg.RecordCacheLen = length return nil } } diff --git a/pb/p2p.pb.go b/pb/p2p.pb.go index bf1fb9b..8736097 100644 --- a/pb/p2p.pb.go +++ b/pb/p2p.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0-devel -// protoc v5.26.1 +// protoc-gen-go v1.34.2 +// protoc v3.12.4 // source: p2p.proto package pb @@ -118,27 +118,19 @@ func (x *MessageData) GetGossip() bool { } // a protocol define a set of reuqest and responses -type WritefileRequest struct { +type ReadDataRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Roothash uniquely identifies a user data - Roothash string `protobuf:"bytes,1,opt,name=Roothash,proto3" json:"Roothash,omitempty"` - // Datahash is the currently written data hash value - Datahash string `protobuf:"bytes,2,opt,name=Datahash,proto3" json:"Datahash,omitempty"` - // Data is the data written this time - Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"` - // MessageData is a generic message - MessageData *MessageData `protobuf:"bytes,4,opt,name=messageData,proto3" json:"messageData,omitempty"` - // Offset is the offset of this write - Offset int64 `protobuf:"varint,5,opt,name=Offset,proto3" json:"Offset,omitempty"` - // Length is the length of the data written this time - Length uint32 `protobuf:"varint,6,opt,name=Length,proto3" json:"Length,omitempty"` -} - -func (x *WritefileRequest) Reset() { - *x = WritefileRequest{} + // generic message + MessageData *MessageData `protobuf:"bytes,1,opt,name=messageData,proto3" json:"messageData,omitempty"` + // file name + Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` +} + +func (x *ReadDataRequest) Reset() { + *x = ReadDataRequest{} if protoimpl.UnsafeEnabled { mi := &file_p2p_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -146,13 +138,13 @@ func (x *WritefileRequest) Reset() { } } -func (x *WritefileRequest) String() string { +func (x *ReadDataRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*WritefileRequest) ProtoMessage() {} +func (*ReadDataRequest) ProtoMessage() {} -func (x *WritefileRequest) ProtoReflect() protoreflect.Message { +func (x *ReadDataRequest) ProtoReflect() protoreflect.Message { mi := &file_p2p_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -164,68 +156,44 @@ func (x *WritefileRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use WritefileRequest.ProtoReflect.Descriptor instead. -func (*WritefileRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use ReadDataRequest.ProtoReflect.Descriptor instead. +func (*ReadDataRequest) Descriptor() ([]byte, []int) { return file_p2p_proto_rawDescGZIP(), []int{1} } -func (x *WritefileRequest) GetRoothash() string { - if x != nil { - return x.Roothash - } - return "" -} - -func (x *WritefileRequest) GetDatahash() string { - if x != nil { - return x.Datahash - } - return "" -} - -func (x *WritefileRequest) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -func (x *WritefileRequest) GetMessageData() *MessageData { +func (x *ReadDataRequest) GetMessageData() *MessageData { if x != nil { return x.MessageData } return nil } -func (x *WritefileRequest) GetOffset() int64 { +func (x *ReadDataRequest) GetName() string { if x != nil { - return x.Offset + return x.Name } - return 0 -} - -func (x *WritefileRequest) GetLength() uint32 { - if x != nil { - return x.Length - } - return 0 + return "" } -type WritefileResponse struct { +type ReadDataResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // MessageData is a generic message + // generic message MessageData *MessageData `protobuf:"bytes,1,opt,name=messageData,proto3" json:"messageData,omitempty"` - // Offset is the write offset the receiver wants - Offset int64 `protobuf:"varint,2,opt,name=Offset,proto3" json:"Offset,omitempty"` - // Code indicates the result of this transfer - Code uint32 `protobuf:"varint,3,opt,name=Code,proto3" json:"Code,omitempty"` + // Data is the returned data + Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"` + // Data length + DataLength int64 `protobuf:"varint,3,opt,name=DataLength,proto3" json:"DataLength,omitempty"` + // response code + Code uint32 `protobuf:"varint,4,opt,name=Code,proto3" json:"Code,omitempty"` + // response message + Msg string `protobuf:"bytes,5,opt,name=Msg,proto3" json:"Msg,omitempty"` } -func (x *WritefileResponse) Reset() { - *x = WritefileResponse{} +func (x *ReadDataResponse) Reset() { + *x = ReadDataResponse{} if protoimpl.UnsafeEnabled { mi := &file_p2p_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -233,13 +201,13 @@ func (x *WritefileResponse) Reset() { } } -func (x *WritefileResponse) String() string { +func (x *ReadDataResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*WritefileResponse) ProtoMessage() {} +func (*ReadDataResponse) ProtoMessage() {} -func (x *WritefileResponse) ProtoReflect() protoreflect.Message { +func (x *ReadDataResponse) ProtoReflect() protoreflect.Message { mi := &file_p2p_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -251,52 +219,60 @@ func (x *WritefileResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use WritefileResponse.ProtoReflect.Descriptor instead. -func (*WritefileResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use ReadDataResponse.ProtoReflect.Descriptor instead. +func (*ReadDataResponse) Descriptor() ([]byte, []int) { return file_p2p_proto_rawDescGZIP(), []int{2} } -func (x *WritefileResponse) GetMessageData() *MessageData { +func (x *ReadDataResponse) GetMessageData() *MessageData { if x != nil { return x.MessageData } return nil } -func (x *WritefileResponse) GetOffset() int64 { +func (x *ReadDataResponse) GetData() []byte { if x != nil { - return x.Offset + return x.Data + } + return nil +} + +func (x *ReadDataResponse) GetDataLength() int64 { + if x != nil { + return x.DataLength } return 0 } -func (x *WritefileResponse) GetCode() uint32 { +func (x *ReadDataResponse) GetCode() uint32 { if x != nil { return x.Code } return 0 } +func (x *ReadDataResponse) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + // a protocol define a set of reuqest and responses -type ReadfileRequest struct { +type ReadDataStatRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Roothash uniquely identifies a user data - Roothash string `protobuf:"bytes,1,opt,name=Roothash,proto3" json:"Roothash,omitempty"` - // Datahash is the currently written data hash value - Datahash string `protobuf:"bytes,2,opt,name=Datahash,proto3" json:"Datahash,omitempty"` - // MessageData is a generic message - MessageData *MessageData `protobuf:"bytes,3,opt,name=messageData,proto3" json:"messageData,omitempty"` - // Offset is the offset that the reader wants to read - Offset int64 `protobuf:"varint,4,opt,name=offset,proto3" json:"offset,omitempty"` - // Extended data is used to expand business use - ExtendData []byte `protobuf:"bytes,5,opt,name=extendData,proto3" json:"extendData,omitempty"` + // generic message + MessageData *MessageData `protobuf:"bytes,1,opt,name=messageData,proto3" json:"messageData,omitempty"` + // file name + Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` } -func (x *ReadfileRequest) Reset() { - *x = ReadfileRequest{} +func (x *ReadDataStatRequest) Reset() { + *x = ReadDataStatRequest{} if protoimpl.UnsafeEnabled { mi := &file_p2p_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -304,13 +280,13 @@ func (x *ReadfileRequest) Reset() { } } -func (x *ReadfileRequest) String() string { +func (x *ReadDataStatRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ReadfileRequest) ProtoMessage() {} +func (*ReadDataStatRequest) ProtoMessage() {} -func (x *ReadfileRequest) ProtoReflect() protoreflect.Message { +func (x *ReadDataStatRequest) ProtoReflect() protoreflect.Message { mi := &file_p2p_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -322,65 +298,42 @@ func (x *ReadfileRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ReadfileRequest.ProtoReflect.Descriptor instead. -func (*ReadfileRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use ReadDataStatRequest.ProtoReflect.Descriptor instead. +func (*ReadDataStatRequest) Descriptor() ([]byte, []int) { return file_p2p_proto_rawDescGZIP(), []int{3} } -func (x *ReadfileRequest) GetRoothash() string { - if x != nil { - return x.Roothash - } - return "" -} - -func (x *ReadfileRequest) GetDatahash() string { - if x != nil { - return x.Datahash - } - return "" -} - -func (x *ReadfileRequest) GetMessageData() *MessageData { +func (x *ReadDataStatRequest) GetMessageData() *MessageData { if x != nil { return x.MessageData } return nil } -func (x *ReadfileRequest) GetOffset() int64 { - if x != nil { - return x.Offset - } - return 0 -} - -func (x *ReadfileRequest) GetExtendData() []byte { +func (x *ReadDataStatRequest) GetName() string { if x != nil { - return x.ExtendData + return x.Name } - return nil + return "" } -type ReadfileResponse struct { +type ReadDataStatResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Data is the returned data - Data []byte `protobuf:"bytes,1,opt,name=Data,proto3" json:"Data,omitempty"` - // MessageData is a generic message - MessageData *MessageData `protobuf:"bytes,2,opt,name=messageData,proto3" json:"messageData,omitempty"` - // Offset is the data offset returned by the peer - Offset int64 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"` + // generic message + MessageData *MessageData `protobuf:"bytes,1,opt,name=messageData,proto3" json:"messageData,omitempty"` // Code indicates the result of this transfer - Code uint32 `protobuf:"varint,4,opt,name=code,proto3" json:"code,omitempty"` - // Length is the returned data length - Length uint32 `protobuf:"varint,5,opt,name=length,proto3" json:"length,omitempty"` + Code uint32 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"` + // Offset is the write offset the receiver wants + Size int64 `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"` + // response message + Msg string `protobuf:"bytes,4,opt,name=msg,proto3" json:"msg,omitempty"` } -func (x *ReadfileResponse) Reset() { - *x = ReadfileResponse{} +func (x *ReadDataStatResponse) Reset() { + *x = ReadDataStatResponse{} if protoimpl.UnsafeEnabled { mi := &file_p2p_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -388,13 +341,13 @@ func (x *ReadfileResponse) Reset() { } } -func (x *ReadfileResponse) String() string { +func (x *ReadDataStatResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ReadfileResponse) ProtoMessage() {} +func (*ReadDataStatResponse) ProtoMessage() {} -func (x *ReadfileResponse) ProtoReflect() protoreflect.Message { +func (x *ReadDataStatResponse) ProtoReflect() protoreflect.Message { mi := &file_p2p_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -406,62 +359,58 @@ func (x *ReadfileResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ReadfileResponse.ProtoReflect.Descriptor instead. -func (*ReadfileResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use ReadDataStatResponse.ProtoReflect.Descriptor instead. +func (*ReadDataStatResponse) Descriptor() ([]byte, []int) { return file_p2p_proto_rawDescGZIP(), []int{4} } -func (x *ReadfileResponse) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -func (x *ReadfileResponse) GetMessageData() *MessageData { +func (x *ReadDataStatResponse) GetMessageData() *MessageData { if x != nil { return x.MessageData } return nil } -func (x *ReadfileResponse) GetOffset() int64 { +func (x *ReadDataStatResponse) GetCode() uint32 { if x != nil { - return x.Offset + return x.Code } return 0 } -func (x *ReadfileResponse) GetCode() uint32 { +func (x *ReadDataStatResponse) GetSize() int64 { if x != nil { - return x.Code + return x.Size } return 0 } -func (x *ReadfileResponse) GetLength() uint32 { +func (x *ReadDataStatResponse) GetMsg() string { if x != nil { - return x.Length + return x.Msg } - return 0 + return "" } -// a protocol define a set of reuqest and responses -type ReadDataStatRequest struct { +type WriteDataRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Roothash uniquely identifies a user data - Roothash string `protobuf:"bytes,1,opt,name=Roothash,proto3" json:"Roothash,omitempty"` - // Datahash is the currently written data hash value - Datahash string `protobuf:"bytes,2,opt,name=Datahash,proto3" json:"Datahash,omitempty"` - // MessageData is a generic message - MessageData *MessageData `protobuf:"bytes,3,opt,name=messageData,proto3" json:"messageData,omitempty"` -} - -func (x *ReadDataStatRequest) Reset() { - *x = ReadDataStatRequest{} + // generic message + MessageData *MessageData `protobuf:"bytes,1,opt,name=messageData,proto3" json:"messageData,omitempty"` + // Fid + Fid string `protobuf:"bytes,2,opt,name=Fid,proto3" json:"Fid,omitempty"` + // Datahash = sha256sum(Data) + Datahash string `protobuf:"bytes,3,opt,name=Datahash,proto3" json:"Datahash,omitempty"` + // Data + Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"` + // Data length + DataLength int64 `protobuf:"varint,5,opt,name=DataLength,proto3" json:"DataLength,omitempty"` +} + +func (x *WriteDataRequest) Reset() { + *x = WriteDataRequest{} if protoimpl.UnsafeEnabled { mi := &file_p2p_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -469,13 +418,13 @@ func (x *ReadDataStatRequest) Reset() { } } -func (x *ReadDataStatRequest) String() string { +func (x *WriteDataRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ReadDataStatRequest) ProtoMessage() {} +func (*WriteDataRequest) ProtoMessage() {} -func (x *ReadDataStatRequest) ProtoReflect() protoreflect.Message { +func (x *WriteDataRequest) ProtoReflect() protoreflect.Message { mi := &file_p2p_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -487,49 +436,61 @@ func (x *ReadDataStatRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ReadDataStatRequest.ProtoReflect.Descriptor instead. -func (*ReadDataStatRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use WriteDataRequest.ProtoReflect.Descriptor instead. +func (*WriteDataRequest) Descriptor() ([]byte, []int) { return file_p2p_proto_rawDescGZIP(), []int{5} } -func (x *ReadDataStatRequest) GetRoothash() string { +func (x *WriteDataRequest) GetMessageData() *MessageData { + if x != nil { + return x.MessageData + } + return nil +} + +func (x *WriteDataRequest) GetFid() string { if x != nil { - return x.Roothash + return x.Fid } return "" } -func (x *ReadDataStatRequest) GetDatahash() string { +func (x *WriteDataRequest) GetDatahash() string { if x != nil { return x.Datahash } return "" } -func (x *ReadDataStatRequest) GetMessageData() *MessageData { +func (x *WriteDataRequest) GetData() []byte { if x != nil { - return x.MessageData + return x.Data } return nil } -type ReadDataStatResponse struct { +func (x *WriteDataRequest) GetDataLength() int64 { + if x != nil { + return x.DataLength + } + return 0 +} + +type WriteDataResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Code indicates the result of this transfer - Code uint32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` - // Offset is the write offset the receiver wants - DataSize int64 `protobuf:"varint,2,opt,name=dataSize,proto3" json:"dataSize,omitempty"` - // Datahash is the currently written data hash value - DataHash string `protobuf:"bytes,3,opt,name=dataHash,proto3" json:"dataHash,omitempty"` - // MessageData is a generic message - MessageData *MessageData `protobuf:"bytes,4,opt,name=messageData,proto3" json:"messageData,omitempty"` + // generic message + MessageData *MessageData `protobuf:"bytes,1,opt,name=messageData,proto3" json:"messageData,omitempty"` + // response code + Code uint32 `protobuf:"varint,2,opt,name=Code,proto3" json:"Code,omitempty"` + // response message + Msg string `protobuf:"bytes,3,opt,name=Msg,proto3" json:"Msg,omitempty"` } -func (x *ReadDataStatResponse) Reset() { - *x = ReadDataStatResponse{} +func (x *WriteDataResponse) Reset() { + *x = WriteDataResponse{} if protoimpl.UnsafeEnabled { mi := &file_p2p_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -537,13 +498,13 @@ func (x *ReadDataStatResponse) Reset() { } } -func (x *ReadDataStatResponse) String() string { +func (x *WriteDataResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ReadDataStatResponse) ProtoMessage() {} +func (*WriteDataResponse) ProtoMessage() {} -func (x *ReadDataStatResponse) ProtoReflect() protoreflect.Message { +func (x *WriteDataResponse) ProtoReflect() protoreflect.Message { mi := &file_p2p_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -555,39 +516,32 @@ func (x *ReadDataStatResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ReadDataStatResponse.ProtoReflect.Descriptor instead. -func (*ReadDataStatResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use WriteDataResponse.ProtoReflect.Descriptor instead. +func (*WriteDataResponse) Descriptor() ([]byte, []int) { return file_p2p_proto_rawDescGZIP(), []int{6} } -func (x *ReadDataStatResponse) GetCode() uint32 { +func (x *WriteDataResponse) GetMessageData() *MessageData { if x != nil { - return x.Code + return x.MessageData } - return 0 + return nil } -func (x *ReadDataStatResponse) GetDataSize() int64 { +func (x *WriteDataResponse) GetCode() uint32 { if x != nil { - return x.DataSize + return x.Code } return 0 } -func (x *ReadDataStatResponse) GetDataHash() string { +func (x *WriteDataResponse) GetMsg() string { if x != nil { - return x.DataHash + return x.Msg } return "" } -func (x *ReadDataStatResponse) GetMessageData() *MessageData { - if x != nil { - return x.MessageData - } - return nil -} - var File_p2p_proto protoreflect.FileDescriptor var file_p2p_proto_rawDesc = []byte{ @@ -604,69 +558,58 @@ var file_p2p_proto_rawDesc = []byte{ 0x52, 0x04, 0x73, 0x69, 0x67, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x6f, 0x73, 0x73, 0x69, 0x70, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x67, 0x6f, 0x73, 0x73, 0x69, 0x70, 0x22, 0xc6, 0x01, 0x0a, - 0x10, 0x57, 0x72, 0x69, 0x74, 0x65, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x52, 0x6f, 0x6f, 0x74, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x52, 0x6f, 0x6f, 0x74, 0x68, 0x61, 0x73, 0x68, 0x12, 0x1a, 0x0a, - 0x08, 0x44, 0x61, 0x74, 0x61, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x44, 0x61, 0x74, 0x61, 0x68, 0x61, 0x73, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, - 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x36, 0x0a, - 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x16, 0x0a, - 0x06, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x4c, - 0x65, 0x6e, 0x67, 0x74, 0x68, 0x22, 0x77, 0x0a, 0x11, 0x57, 0x72, 0x69, 0x74, 0x65, 0x66, 0x69, - 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x0b, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x14, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, - 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x06, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, - 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0xb9, - 0x01, 0x0a, 0x0f, 0x52, 0x65, 0x61, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x52, 0x6f, 0x6f, 0x74, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x52, 0x6f, 0x6f, 0x74, 0x68, 0x61, 0x73, 0x68, 0x12, 0x1a, - 0x0a, 0x08, 0x44, 0x61, 0x74, 0x61, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x44, 0x61, 0x74, 0x61, 0x68, 0x61, 0x73, 0x68, 0x12, 0x36, 0x0a, 0x0b, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x14, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, - 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, - 0x74, 0x65, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, - 0x65, 0x78, 0x74, 0x65, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x61, 0x22, 0xa2, 0x01, 0x0a, 0x10, 0x52, - 0x65, 0x61, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, - 0x61, 0x74, 0x61, 0x12, 0x36, 0x0a, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, - 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0b, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x6f, - 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, - 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, - 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x22, - 0x85, 0x01, 0x0a, 0x13, 0x52, 0x65, 0x61, 0x64, 0x44, 0x61, 0x74, 0x61, 0x53, 0x74, 0x61, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x52, 0x6f, 0x6f, 0x74, 0x68, - 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x52, 0x6f, 0x6f, 0x74, 0x68, - 0x61, 0x73, 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x44, 0x61, 0x74, 0x61, 0x68, 0x61, 0x73, 0x68, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x44, 0x61, 0x74, 0x61, 0x68, 0x61, 0x73, 0x68, 0x12, - 0x36, 0x0a, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x67, 0x6f, 0x73, 0x73, 0x69, 0x70, 0x22, 0x5d, 0x0a, 0x0f, + 0x52, 0x65, 0x61, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x36, 0x0a, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0b, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x22, 0x9a, 0x01, 0x0a, 0x14, 0x52, 0x65, 0x61, 0x64, - 0x44, 0x61, 0x74, 0x61, 0x53, 0x74, 0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, - 0x63, 0x6f, 0x64, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x53, 0x69, 0x7a, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x53, 0x69, 0x7a, 0x65, - 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x48, 0x61, 0x73, 0x68, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x48, 0x61, 0x73, 0x68, 0x12, 0x36, 0x0a, 0x0b, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x44, 0x61, 0x74, 0x61, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x2f, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xa4, 0x01, 0x0a, 0x10, + 0x52, 0x65, 0x61, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x36, 0x0a, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0b, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1e, 0x0a, 0x0a, + 0x44, 0x61, 0x74, 0x61, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x0a, 0x44, 0x61, 0x74, 0x61, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, + 0x43, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, + 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, + 0x73, 0x67, 0x22, 0x61, 0x0a, 0x13, 0x52, 0x65, 0x61, 0x64, 0x44, 0x61, 0x74, 0x61, 0x53, 0x74, + 0x61, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x36, 0x0a, 0x0b, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, + 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x44, 0x61, 0x74, 0x61, 0x52, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, + 0x61, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x88, 0x01, 0x0a, 0x14, 0x52, 0x65, 0x61, 0x64, 0x44, 0x61, + 0x74, 0x61, 0x53, 0x74, 0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, + 0x0a, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, + 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x10, + 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, + 0x22, 0xac, 0x01, 0x0a, 0x10, 0x57, 0x72, 0x69, 0x74, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x36, 0x0a, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x32, 0x70, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, + 0x52, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, + 0x03, 0x46, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x46, 0x69, 0x64, 0x12, + 0x1a, 0x0a, 0x08, 0x44, 0x61, 0x74, 0x61, 0x68, 0x61, 0x73, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x44, 0x61, 0x74, 0x61, 0x68, 0x61, 0x73, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x44, + 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, + 0x1e, 0x0a, 0x0a, 0x44, 0x61, 0x74, 0x61, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0a, 0x44, 0x61, 0x74, 0x61, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x22, + 0x71, 0x0a, 0x11, 0x57, 0x72, 0x69, 0x74, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, + 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x32, 0x70, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, + 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, + 0x43, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, + 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, + 0x73, 0x67, 0x42, 0x07, 0x5a, 0x05, 0x2e, 0x2f, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -682,22 +625,22 @@ func file_p2p_proto_rawDescGZIP() []byte { } var file_p2p_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_p2p_proto_goTypes = []interface{}{ +var file_p2p_proto_goTypes = []any{ (*MessageData)(nil), // 0: p2p.api.MessageData - (*WritefileRequest)(nil), // 1: p2p.api.WritefileRequest - (*WritefileResponse)(nil), // 2: p2p.api.WritefileResponse - (*ReadfileRequest)(nil), // 3: p2p.api.ReadfileRequest - (*ReadfileResponse)(nil), // 4: p2p.api.ReadfileResponse - (*ReadDataStatRequest)(nil), // 5: p2p.api.ReadDataStatRequest - (*ReadDataStatResponse)(nil), // 6: p2p.api.ReadDataStatResponse + (*ReadDataRequest)(nil), // 1: p2p.api.ReadDataRequest + (*ReadDataResponse)(nil), // 2: p2p.api.ReadDataResponse + (*ReadDataStatRequest)(nil), // 3: p2p.api.ReadDataStatRequest + (*ReadDataStatResponse)(nil), // 4: p2p.api.ReadDataStatResponse + (*WriteDataRequest)(nil), // 5: p2p.api.WriteDataRequest + (*WriteDataResponse)(nil), // 6: p2p.api.WriteDataResponse } var file_p2p_proto_depIdxs = []int32{ - 0, // 0: p2p.api.WritefileRequest.messageData:type_name -> p2p.api.MessageData - 0, // 1: p2p.api.WritefileResponse.messageData:type_name -> p2p.api.MessageData - 0, // 2: p2p.api.ReadfileRequest.messageData:type_name -> p2p.api.MessageData - 0, // 3: p2p.api.ReadfileResponse.messageData:type_name -> p2p.api.MessageData - 0, // 4: p2p.api.ReadDataStatRequest.messageData:type_name -> p2p.api.MessageData - 0, // 5: p2p.api.ReadDataStatResponse.messageData:type_name -> p2p.api.MessageData + 0, // 0: p2p.api.ReadDataRequest.messageData:type_name -> p2p.api.MessageData + 0, // 1: p2p.api.ReadDataResponse.messageData:type_name -> p2p.api.MessageData + 0, // 2: p2p.api.ReadDataStatRequest.messageData:type_name -> p2p.api.MessageData + 0, // 3: p2p.api.ReadDataStatResponse.messageData:type_name -> p2p.api.MessageData + 0, // 4: p2p.api.WriteDataRequest.messageData:type_name -> p2p.api.MessageData + 0, // 5: p2p.api.WriteDataResponse.messageData:type_name -> p2p.api.MessageData 6, // [6:6] is the sub-list for method output_type 6, // [6:6] is the sub-list for method input_type 6, // [6:6] is the sub-list for extension type_name @@ -711,7 +654,7 @@ func file_p2p_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_p2p_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_p2p_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*MessageData); i { case 0: return &v.state @@ -723,8 +666,8 @@ func file_p2p_proto_init() { return nil } } - file_p2p_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WritefileRequest); i { + file_p2p_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*ReadDataRequest); i { case 0: return &v.state case 1: @@ -735,8 +678,8 @@ func file_p2p_proto_init() { return nil } } - file_p2p_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*WritefileResponse); i { + file_p2p_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*ReadDataResponse); i { case 0: return &v.state case 1: @@ -747,8 +690,8 @@ func file_p2p_proto_init() { return nil } } - file_p2p_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReadfileRequest); i { + file_p2p_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*ReadDataStatRequest); i { case 0: return &v.state case 1: @@ -759,8 +702,8 @@ func file_p2p_proto_init() { return nil } } - file_p2p_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReadfileResponse); i { + file_p2p_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*ReadDataStatResponse); i { case 0: return &v.state case 1: @@ -771,8 +714,8 @@ func file_p2p_proto_init() { return nil } } - file_p2p_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReadDataStatRequest); i { + file_p2p_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*WriteDataRequest); i { case 0: return &v.state case 1: @@ -783,8 +726,8 @@ func file_p2p_proto_init() { return nil } } - file_p2p_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReadDataStatResponse); i { + file_p2p_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*WriteDataResponse); i { case 0: return &v.state case 1: diff --git a/pb/p2p.proto b/pb/p2p.proto index 44c5a42..ae0efba 100644 --- a/pb/p2p.proto +++ b/pb/p2p.proto @@ -16,81 +16,70 @@ message MessageData { bool gossip = 7; // true to have receiver peer gossip the message to neighbors } -//// writefile protocol +//// read data protocol // a protocol define a set of reuqest and responses -message WritefileRequest { - // Roothash uniquely identifies a user data - string Roothash = 1; - // Datahash is the currently written data hash value - string Datahash = 2; - // Data is the data written this time - bytes Data = 3; - // MessageData is a generic message - MessageData messageData = 4; - // Offset is the offset of this write - int64 Offset = 5; - // Length is the length of the data written this time - uint32 Length = 6; +message ReadDataRequest { + // generic message + MessageData messageData = 1; + // file name + string Name = 2; } -message WritefileResponse { - // MessageData is a generic message +message ReadDataResponse { + // generic message MessageData messageData = 1; - // Offset is the write offset the receiver wants - int64 Offset = 2; - // Code indicates the result of this transfer - uint32 Code = 3; + // Data is the returned data + bytes Data = 2; + // Data length + int64 DataLength = 3; + // response code + uint32 Code = 4; + // response message + string Msg = 5; } -//// readfile protocol +//// read data stat protocol // a protocol define a set of reuqest and responses -message ReadfileRequest { - // Roothash uniquely identifies a user data - string Roothash = 1; - // Datahash is the currently written data hash value - string Datahash = 2; - // MessageData is a generic message - MessageData messageData = 3; - // Offset is the offset that the reader wants to read - int64 offset = 4; - // Extended data is used to expand business - bytes extendData=5; +message ReadDataStatRequest { + // generic message + MessageData messageData = 1; + // file name + string Name = 2; } -message ReadfileResponse { - // Data is the returned data - bytes Data = 1; - // MessageData is a generic message - MessageData messageData = 2; - // Offset is the data offset returned by the peer - int64 offset = 3; +message ReadDataStatResponse { + // generic message + MessageData messageData = 1; // Code indicates the result of this transfer - uint32 code = 4; - // Length is the returned data length - uint32 length = 5; + uint32 code = 2; + // Offset is the write offset the receiver wants + int64 size = 3; + // response message + string msg = 4; } -//// readDataStat protocol +//// write data protocol -// a protocol define a set of reuqest and responses -message ReadDataStatRequest { - // Roothash uniquely identifies a user data - string Roothash = 1; - // Datahash is the currently written data hash value - string Datahash = 2; - // MessageData is a generic message - MessageData messageData = 3; +message WriteDataRequest { + // generic message + MessageData messageData = 1; + // Fid + string Fid = 2; + // Datahash = sha256sum(Data) + string Datahash = 3; + // Data + bytes Data = 4; + // Data length + int64 DataLength = 5; } -message ReadDataStatResponse { - // Code indicates the result of this transfer - uint32 code = 1; - // Offset is the write offset the receiver wants - int64 dataSize = 2; - // Datahash is the currently written data hash value - string dataHash = 3; - // MessageData is a generic message - MessageData messageData = 4; +message WriteDataResponse { + // generic message + MessageData messageData = 1; + // response code + uint32 Code = 2; + // response message + string Msg = 3; } \ No newline at end of file