From ca629a80a3854242c6d2b371d9362281ab694f88 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 19 Oct 2023 22:18:10 +0200 Subject: [PATCH] refactor: new boxo/namesys This applies changes necessary after https://github.com/ipfs/boxo/pull/459 we need this to unblock https://github.com/ipfs/kubo/pull/10161 --- go.mod | 2 +- go.sum | 4 ++-- ipfs/go.mod | 2 +- ipfs/go.sum | 8 ++------ ipfs/namesys.go | 31 ++++++++----------------------- nopfs-kubo-plugin/README.md | 10 +++++++++- 6 files changed, 23 insertions(+), 34 deletions(-) diff --git a/go.mod b/go.mod index 626fa31..5e17048 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/fsnotify/fsnotify v1.6.0 - github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3 + github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9 github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-log/v2 v2.5.1 github.com/multiformats/go-multicodec v0.9.0 diff --git a/go.sum b/go.sum index b80ea0e..1cd4ac9 100644 --- a/go.sum +++ b/go.sum @@ -5,8 +5,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3 h1:sgrhALL6mBoZsNvJ2zUcITcN6IW3y14ej6w7gv5RcOI= -github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= +github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9 h1:dmjRJU0cMxrGIcd9gBgrRATl2DL0xrmJM/jedPKhQbQ= +github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= diff --git a/ipfs/go.mod b/ipfs/go.mod index a5785ca..b49dd9f 100644 --- a/ipfs/go.mod +++ b/ipfs/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/ipfs-shipyard/nopfs v0.0.12-0.20231012170252-ab19c8a36941 - github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3 + github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9 github.com/ipfs/go-block-format v0.1.2 github.com/ipfs/go-cid v0.4.1 github.com/ipfs/go-log/v2 v2.5.1 diff --git a/ipfs/go.sum b/ipfs/go.sum index 7355744..9bbcd1f 100644 --- a/ipfs/go.sum +++ b/ipfs/go.sum @@ -86,16 +86,12 @@ github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uG github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4= github.com/hashicorp/golang-lru/v2 v2.0.5/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/huin/goupnp v1.2.0 h1:uOKW26NG1hsSSbXIZ1IR7XP9Gjd1U8pnLaCMgntmkmY= -github.com/ipfs-shipyard/nopfs v0.0.11 h1:+JrOqVs4Za0eu4jntdAqxoWolWcmtJnTQXxn2Y/Io2E= -github.com/ipfs-shipyard/nopfs v0.0.11/go.mod h1:zCmxRNQBYwTRYemK6zcKBGLKN9DkDJYNzmNMqw9GtIA= github.com/ipfs-shipyard/nopfs v0.0.12-0.20231012170252-ab19c8a36941 h1:IkOu07ym9Pi+O5Xl50CpMjvqULLFatzNY3+dyI54swM= github.com/ipfs-shipyard/nopfs v0.0.12-0.20231012170252-ab19c8a36941/go.mod h1:kuVnRVtaUO33/H05F/TH0pia1Pr/VW3DrFRGZGP4bpg= github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= -github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI= -github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= -github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3 h1:sgrhALL6mBoZsNvJ2zUcITcN6IW3y14ej6w7gv5RcOI= -github.com/ipfs/boxo v0.13.2-0.20231012132507-6602207a8fa3/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= +github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9 h1:dmjRJU0cMxrGIcd9gBgrRATl2DL0xrmJM/jedPKhQbQ= +github.com/ipfs/boxo v0.13.2-0.20231019090647-a7e134e54ff9/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA= github.com/ipfs/go-block-format v0.1.2 h1:GAjkfhVx1f4YTODS6Esrj1wt2HhrtwTnhEr+DyPUaJo= github.com/ipfs/go-block-format v0.1.2/go.mod h1:mACVcrxarQKstUU3Yf/RdwbC4DzPV6++rO2a3d+a/KE= diff --git a/ipfs/namesys.go b/ipfs/namesys.go index b8f8e1a..95a2030 100644 --- a/ipfs/namesys.go +++ b/ipfs/namesys.go @@ -4,7 +4,6 @@ import ( "context" "github.com/ipfs-shipyard/nopfs" - opts "github.com/ipfs/boxo/coreiface/options/namesys" "github.com/ipfs/boxo/namesys" "github.com/ipfs/boxo/path" crypto "github.com/libp2p/go-libp2p/core/crypto" @@ -29,35 +28,21 @@ func WrapNameSystem(ns namesys.NameSystem, blocker *nopfs.Blocker) namesys.NameS } // Resolve resolves an IPNS name unless it is blocked. -func (ns *NameSystem) Resolve(ctx context.Context, name string, options ...opts.ResolveOpt) (path.Path, error) { - p, err := path.NewPath(name) - if err != nil { - return nil, err - } +func (ns *NameSystem) Resolve(ctx context.Context, p path.Path, options ...namesys.ResolveOption) (namesys.Result, error) { if err := ns.blocker.IsPathBlocked(p).ToError(); err != nil { logger.Warn(err.Response) - return nil, err + return namesys.Result{}, err } - return ns.ns.Resolve(ctx, name, options...) + return ns.ns.Resolve(ctx, p, options...) } // ResolveAsync resolves an IPNS name asynchronously unless it is blocked. -func (ns *NameSystem) ResolveAsync(ctx context.Context, name string, options ...opts.ResolveOpt) <-chan namesys.Result { - p, err := path.NewPath(name) - if err != nil { - ch := make(chan namesys.Result, 1) - ch <- namesys.Result{ - Path: nil, - Err: err, - } - close(ch) - return ch - } +func (ns *NameSystem) ResolveAsync(ctx context.Context, p path.Path, options ...namesys.ResolveOption) <-chan namesys.AsyncResult { status := ns.blocker.IsPathBlocked(p) if err := status.ToError(); err != nil { logger.Warn(err.Response) - ch := make(chan namesys.Result, 1) - ch <- namesys.Result{ + ch := make(chan namesys.AsyncResult, 1) + ch <- namesys.AsyncResult{ Path: status.Path, Err: err, } @@ -65,10 +50,10 @@ func (ns *NameSystem) ResolveAsync(ctx context.Context, name string, options ... return ch } - return ns.ns.ResolveAsync(ctx, name, options...) + return ns.ns.ResolveAsync(ctx, p, options...) } // Publish publishes an IPNS record. -func (ns *NameSystem) Publish(ctx context.Context, name crypto.PrivKey, value path.Path, options ...opts.PublishOption) error { +func (ns *NameSystem) Publish(ctx context.Context, name crypto.PrivKey, value path.Path, options ...namesys.PublishOption) error { return ns.ns.Publish(ctx, name, value, options...) } diff --git a/nopfs-kubo-plugin/README.md b/nopfs-kubo-plugin/README.md index c31f5d0..0e49933 100644 --- a/nopfs-kubo-plugin/README.md +++ b/nopfs-kubo-plugin/README.md @@ -1,4 +1,12 @@ -# nopfs-kubo-plugin +# nopfs-kubo-plugin (for Kubo <=0.23) + +> ### ℹ️ Kubo 0.24 shipped with this plugin built-in +> +> It now lives at [ipfs/kubo/plugin/plugins/nopfs](https://github.com/ipfs/kubo/tree/master/plugin/plugins/nopfs) +> +> This version will no longer be maintained. +> +> Learn more at [`kubo/docs/content-blocking.md`](https://github.com/ipfs/kubo/blob/master/docs/content-blocking.md) ## Installation