From 0cc547ba5ce468b4d79e2c023ad7b49f0438e20e Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 26 Jun 2014 00:38:48 -0700 Subject: [PATCH 001/674] Big things have small beginnings. This commit was moved from ipfs/kubo@9d0e6a7ffb5deea2c8c8e555d7bf6bcab6fdc6ac From ec154ba3d1328121e7641e1ffa1680664f53a92e Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Thu, 22 Jan 2015 01:05:07 -0800 Subject: [PATCH 002/674] refactor(core) extract corehttp package PACKAGE DOCUMENTATION package corehttp FUNCTIONS func GatewayOption(n *core.IpfsNode, mux *http.ServeMux) error func ListenAndServe(n *core.IpfsNode, addr ma.Multiaddr, options ...ServeOption) error func WebUIOption(n *core.IpfsNode, mux *http.ServeMux) error TYPES type ServeOption func(*core.IpfsNode, *http.ServeMux) error func DaemonOption(cctx commands.Context) ServeOption This commit was moved from ipfs/kubo@fadedf9e68278402c18b7e8c3d79552414b85e6b --- gateway/core/corehttp/corehttp.go | 100 +++++++++++ gateway/core/corehttp/gateway_handler.go | 210 +++++++++++++++++++++++ 2 files changed, 310 insertions(+) create mode 100644 gateway/core/corehttp/corehttp.go create mode 100644 gateway/core/corehttp/gateway_handler.go diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go new file mode 100644 index 000000000..14d2d231c --- /dev/null +++ b/gateway/core/corehttp/corehttp.go @@ -0,0 +1,100 @@ +package corehttp + +import ( + "fmt" + "net/http" + "os" + + manners "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/braintree/manners" + ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" + manet "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" + commands "github.com/jbenet/go-ipfs/commands" + cmdsHttp "github.com/jbenet/go-ipfs/commands/http" + core "github.com/jbenet/go-ipfs/core" + corecommands "github.com/jbenet/go-ipfs/core/commands" + eventlog "github.com/jbenet/go-ipfs/thirdparty/eventlog" +) + +var log = eventlog.Logger("core/server") + +const ( + // TODO rename + originEnvKey = "API_ORIGIN" + webuiPath = "/ipfs/QmTWvqK9dYvqjAMAcCeUun8b45Fwu7wPhEN9B9TsGbkXfJ" +) + +type ServeOption func(*core.IpfsNode, *http.ServeMux) error + +func ListenAndServe(n *core.IpfsNode, addr ma.Multiaddr, options ...ServeOption) error { + mux := http.NewServeMux() + for _, option := range options { + if err := option(n, mux); err != nil { + return err + } + } + return listenAndServe("API", n, addr, mux) +} + +func CommandsOption(cctx commands.Context) ServeOption { + return func(n *core.IpfsNode, mux *http.ServeMux) error { + origin := os.Getenv(originEnvKey) + cmdHandler := cmdsHttp.NewHandler(cctx, corecommands.Root, origin) + mux.Handle(cmdsHttp.ApiPath+"/", cmdHandler) + return nil + } +} + +func GatewayOption(n *core.IpfsNode, mux *http.ServeMux) error { + gateway, err := newGatewayHandler(n) + if err != nil { + return err + } + mux.Handle("/ipfs/", gateway) + return nil +} + +func WebUIOption(n *core.IpfsNode, mux *http.ServeMux) error { + mux.Handle("/webui/", &redirectHandler{webuiPath}) + return nil +} + +func listenAndServe(name string, node *core.IpfsNode, addr ma.Multiaddr, mux *http.ServeMux) error { + _, host, err := manet.DialArgs(addr) + if err != nil { + return err + } + + server := manners.NewServer() + + // if the server exits beforehand + var serverError error + serverExited := make(chan struct{}) + + go func() { + fmt.Printf("%s server listening on %s\n", name, addr) + serverError = server.ListenAndServe(host, mux) + close(serverExited) + }() + + // wait for server to exit. + select { + case <-serverExited: + + // if node being closed before server exits, close server + case <-node.Closing(): + log.Infof("server at %s terminating...", addr) + server.Shutdown <- true + <-serverExited // now, DO wait until server exit + } + + log.Infof("server at %s terminated", addr) + return serverError +} + +type redirectHandler struct { + path string +} + +func (i *redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, i.path, 302) +} diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go new file mode 100644 index 000000000..139e7cf20 --- /dev/null +++ b/gateway/core/corehttp/gateway_handler.go @@ -0,0 +1,210 @@ +package corehttp + +import ( + "html/template" + "io" + "mime" + "net/http" + "strings" + + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" + mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" + + core "github.com/jbenet/go-ipfs/core" + "github.com/jbenet/go-ipfs/importer" + chunk "github.com/jbenet/go-ipfs/importer/chunk" + dag "github.com/jbenet/go-ipfs/merkledag" + "github.com/jbenet/go-ipfs/routing" + uio "github.com/jbenet/go-ipfs/unixfs/io" + u "github.com/jbenet/go-ipfs/util" +) + +type gateway interface { + ResolvePath(string) (*dag.Node, error) + NewDagFromReader(io.Reader) (*dag.Node, error) + AddNodeToDAG(nd *dag.Node) (u.Key, error) + NewDagReader(nd *dag.Node) (io.Reader, error) +} + +// shortcut for templating +type webHandler map[string]interface{} + +// struct for directory listing +type directoryItem struct { + Size uint64 + Name string +} + +// gatewayHandler is a HTTP handler that serves IPFS objects (accessible by default at /ipfs/) +// (it serves requests like GET /ipfs/QmVRzPKPzNtSrEzBFm2UZfxmPAgnaLke4DMcerbsGGSaFe/link) +type gatewayHandler struct { + node *core.IpfsNode + dirList *template.Template +} + +func newGatewayHandler(node *core.IpfsNode) (*gatewayHandler, error) { + i := &gatewayHandler{ + node: node, + } + err := i.loadTemplate() + if err != nil { + return nil, err + } + return i, nil +} + +// Load the directroy list template +func (i *gatewayHandler) loadTemplate() error { + t, err := template.New("dir").Parse(listingTemplate) + if err != nil { + return err + } + i.dirList = t + return nil +} + +func (i *gatewayHandler) ResolvePath(path string) (*dag.Node, error) { + return i.node.Resolver.ResolvePath(path) +} + +func (i *gatewayHandler) NewDagFromReader(r io.Reader) (*dag.Node, error) { + return importer.BuildDagFromReader( + r, i.node.DAG, i.node.Pinning.GetManual(), chunk.DefaultSplitter) +} + +func (i *gatewayHandler) AddNodeToDAG(nd *dag.Node) (u.Key, error) { + return i.node.DAG.Add(nd) +} + +func (i *gatewayHandler) NewDagReader(nd *dag.Node) (io.Reader, error) { + return uio.NewDagReader(nd, i.node.DAG) +} + +func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + path := r.URL.Path[5:] + log := log.Prefix("serving %s", path) + + nd, err := i.ResolvePath(path) + if err != nil { + if err == routing.ErrNotFound { + w.WriteHeader(http.StatusNotFound) + } else if err == context.DeadlineExceeded { + w.WriteHeader(http.StatusRequestTimeout) + } else { + w.WriteHeader(http.StatusBadRequest) + } + + log.Error(err) + w.Write([]byte(err.Error())) + return + } + + extensionIndex := strings.LastIndex(path, ".") + if extensionIndex != -1 { + extension := path[extensionIndex:] + mimeType := mime.TypeByExtension(extension) + if len(mimeType) > 0 { + w.Header().Add("Content-Type", mimeType) + } + } + + dr, err := i.NewDagReader(nd) + if err == nil { + io.Copy(w, dr) + return + } + + if err != uio.ErrIsDir { + // not a directory and still an error + internalWebError(w, err) + return + } + + log.Debug("listing directory") + if path[len(path)-1:] != "/" { + log.Debug("missing trailing slash, redirect") + http.Redirect(w, r, "/ipfs/"+path+"/", 307) + return + } + + // storage for directory listing + var dirListing []directoryItem + // loop through files + for _, link := range nd.Links { + if link.Name != "index.html" { + dirListing = append(dirListing, directoryItem{link.Size, link.Name}) + continue + } + + log.Debug("found index") + // return index page instead. + nd, err := i.ResolvePath(path + "/index.html") + if err != nil { + internalWebError(w, err) + return + } + dr, err := i.NewDagReader(nd) + if err != nil { + internalWebError(w, err) + return + } + // write to request + io.Copy(w, dr) + } + + // template and return directory listing + hndlr := webHandler{"listing": dirListing, "path": path} + if err := i.dirList.Execute(w, hndlr); err != nil { + internalWebError(w, err) + return + } +} + +func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { + nd, err := i.NewDagFromReader(r.Body) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + log.Error(err) + w.Write([]byte(err.Error())) + return + } + + k, err := i.AddNodeToDAG(nd) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + log.Error(err) + w.Write([]byte(err.Error())) + return + } + + //TODO: return json representation of list instead + w.WriteHeader(http.StatusCreated) + w.Write([]byte(mh.Multihash(k).B58String())) +} + +// return a 500 error and log +func internalWebError(w http.ResponseWriter, err error) { + w.WriteHeader(http.StatusInternalServerError) + w.Write([]byte(err.Error())) + log.Error("%s", err) +} + +// Directory listing template +var listingTemplate = ` + + + + + {{ .path }} + + +

Index of {{ .path }}

+
    +
  • ..
  • + {{ range $item := .listing }} +
  • {{ $item.Name }} - {{ $item.Size }} bytes
  • + {{ end }} +
+ + +` From c4fb02f622971118a78cbf1bc74246ed3ea368c5 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Thu, 22 Jan 2015 01:27:40 -0800 Subject: [PATCH 003/674] separate concerns This commit was moved from ipfs/kubo@fadede6cb2b5edfd293e3324a803e486e005a602 --- gateway/core/corehttp/commands.go | 25 ++++++++++++++++++++ gateway/core/corehttp/corehttp.go | 39 +------------------------------ gateway/core/corehttp/gateway.go | 16 +++++++++++++ gateway/core/corehttp/webui.go | 25 ++++++++++++++++++++ 4 files changed, 67 insertions(+), 38 deletions(-) create mode 100644 gateway/core/corehttp/commands.go create mode 100644 gateway/core/corehttp/gateway.go create mode 100644 gateway/core/corehttp/webui.go diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go new file mode 100644 index 000000000..3b9ac262c --- /dev/null +++ b/gateway/core/corehttp/commands.go @@ -0,0 +1,25 @@ +package corehttp + +import ( + "net/http" + "os" + + commands "github.com/jbenet/go-ipfs/commands" + cmdsHttp "github.com/jbenet/go-ipfs/commands/http" + core "github.com/jbenet/go-ipfs/core" + corecommands "github.com/jbenet/go-ipfs/core/commands" +) + +const ( + // TODO rename + originEnvKey = "API_ORIGIN" +) + +func CommandsOption(cctx commands.Context) ServeOption { + return func(n *core.IpfsNode, mux *http.ServeMux) error { + origin := os.Getenv(originEnvKey) + cmdHandler := cmdsHttp.NewHandler(cctx, corecommands.Root, origin) + mux.Handle(cmdsHttp.ApiPath+"/", cmdHandler) + return nil + } +} diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 14d2d231c..1fe007675 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -3,24 +3,18 @@ package corehttp import ( "fmt" "net/http" - "os" manners "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/braintree/manners" ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" manet "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" - commands "github.com/jbenet/go-ipfs/commands" - cmdsHttp "github.com/jbenet/go-ipfs/commands/http" core "github.com/jbenet/go-ipfs/core" - corecommands "github.com/jbenet/go-ipfs/core/commands" eventlog "github.com/jbenet/go-ipfs/thirdparty/eventlog" ) var log = eventlog.Logger("core/server") const ( - // TODO rename - originEnvKey = "API_ORIGIN" - webuiPath = "/ipfs/QmTWvqK9dYvqjAMAcCeUun8b45Fwu7wPhEN9B9TsGbkXfJ" +// TODO rename ) type ServeOption func(*core.IpfsNode, *http.ServeMux) error @@ -35,29 +29,6 @@ func ListenAndServe(n *core.IpfsNode, addr ma.Multiaddr, options ...ServeOption) return listenAndServe("API", n, addr, mux) } -func CommandsOption(cctx commands.Context) ServeOption { - return func(n *core.IpfsNode, mux *http.ServeMux) error { - origin := os.Getenv(originEnvKey) - cmdHandler := cmdsHttp.NewHandler(cctx, corecommands.Root, origin) - mux.Handle(cmdsHttp.ApiPath+"/", cmdHandler) - return nil - } -} - -func GatewayOption(n *core.IpfsNode, mux *http.ServeMux) error { - gateway, err := newGatewayHandler(n) - if err != nil { - return err - } - mux.Handle("/ipfs/", gateway) - return nil -} - -func WebUIOption(n *core.IpfsNode, mux *http.ServeMux) error { - mux.Handle("/webui/", &redirectHandler{webuiPath}) - return nil -} - func listenAndServe(name string, node *core.IpfsNode, addr ma.Multiaddr, mux *http.ServeMux) error { _, host, err := manet.DialArgs(addr) if err != nil { @@ -90,11 +61,3 @@ func listenAndServe(name string, node *core.IpfsNode, addr ma.Multiaddr, mux *ht log.Infof("server at %s terminated", addr) return serverError } - -type redirectHandler struct { - path string -} - -func (i *redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, i.path, 302) -} diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go new file mode 100644 index 000000000..c3f0a5593 --- /dev/null +++ b/gateway/core/corehttp/gateway.go @@ -0,0 +1,16 @@ +package corehttp + +import ( + "net/http" + + core "github.com/jbenet/go-ipfs/core" +) + +func GatewayOption(n *core.IpfsNode, mux *http.ServeMux) error { + gateway, err := newGatewayHandler(n) + if err != nil { + return err + } + mux.Handle("/ipfs/", gateway) + return nil +} diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go new file mode 100644 index 000000000..b1fd08559 --- /dev/null +++ b/gateway/core/corehttp/webui.go @@ -0,0 +1,25 @@ +package corehttp + +import ( + "net/http" + + core "github.com/jbenet/go-ipfs/core" +) + +const ( + // TODO rename + webuiPath = "/ipfs/QmTWvqK9dYvqjAMAcCeUun8b45Fwu7wPhEN9B9TsGbkXfJ" +) + +func WebUIOption(n *core.IpfsNode, mux *http.ServeMux) error { + mux.Handle("/webui/", &redirectHandler{webuiPath}) + return nil +} + +type redirectHandler struct { + path string +} + +func (i *redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, i.path, 302) +} From de8d9e5616a9db3fedeb73d156c1b941a95e762c Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Mon, 12 Jan 2015 11:02:32 -0800 Subject: [PATCH 004/674] cmd/ipfs: gatewayHandler: Fixed directory listing getting appended to index.html pages This commit was moved from ipfs/kubo@81d17e0843b234a98309dd16639055b843900741 --- gateway/core/corehttp/gateway_handler.go | 46 +++++++++++++----------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 139e7cf20..65d7975d8 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -130,33 +130,37 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // storage for directory listing var dirListing []directoryItem // loop through files + foundIndex := false for _, link := range nd.Links { - if link.Name != "index.html" { - dirListing = append(dirListing, directoryItem{link.Size, link.Name}) - continue + if link.Name == "index.html" { + log.Debug("found index") + foundIndex = true + // return index page instead. + nd, err := i.ResolvePath(path + "/index.html") + if err != nil { + internalWebError(w, err) + return + } + dr, err := i.NewDagReader(nd) + if err != nil { + internalWebError(w, err) + return + } + // write to request + io.Copy(w, dr) + break } - log.Debug("found index") - // return index page instead. - nd, err := i.ResolvePath(path + "/index.html") - if err != nil { - internalWebError(w, err) - return - } - dr, err := i.NewDagReader(nd) - if err != nil { + dirListing = append(dirListing, directoryItem{link.Size, link.Name}) + } + + if !foundIndex { + // template and return directory listing + hndlr := webHandler{"listing": dirListing, "path": path} + if err := i.dirList.Execute(w, hndlr); err != nil { internalWebError(w, err) return } - // write to request - io.Copy(w, dr) - } - - // template and return directory listing - hndlr := webHandler{"listing": dirListing, "path": path} - if err := i.dirList.Execute(w, hndlr); err != nil { - internalWebError(w, err) - return } } From 58e5c5bbbb6045d0af82bdf6db3501ca60c2a00b Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Sat, 24 Jan 2015 00:24:44 -0800 Subject: [PATCH 005/674] remove prefix logger This commit was moved from ipfs/kubo@6fedf259eb6561e6b49562d432213a4b71bf5b4f --- gateway/core/corehttp/gateway_handler.go | 1 - 1 file changed, 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 65d7975d8..ec4596a61 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -82,7 +82,6 @@ func (i *gatewayHandler) NewDagReader(nd *dag.Node) (io.Reader, error) { func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { path := r.URL.Path[5:] - log := log.Prefix("serving %s", path) nd, err := i.ResolvePath(path) if err != nil { From bf217df1bdc2759bf530586cc1f186d0f3235df8 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Fri, 23 Jan 2015 21:28:54 -0800 Subject: [PATCH 006/674] perform multiaddr conversion in the function This commit was moved from ipfs/kubo@e9d3c9828c40b8afc1ca8257176ab9b71e4202e5 --- gateway/core/corehttp/corehttp.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 1fe007675..32b27b261 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -19,7 +19,17 @@ const ( type ServeOption func(*core.IpfsNode, *http.ServeMux) error -func ListenAndServe(n *core.IpfsNode, addr ma.Multiaddr, options ...ServeOption) error { +// ListenAndServe runs an HTTP server listening at |listeningMultiAddr| with +// the given serve options. The address must be provided in multiaddr format. +// +// TODO intelligently parse address strings in other formats so long as they +// unambiguously map to a valid multiaddr. e.g. for convenience, ":8080" should +// map to "/ip4/0.0.0.0/tcp/8080". +func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...ServeOption) error { + addr, err := ma.NewMultiaddr(listeningMultiAddr) + if err != nil { + return err + } mux := http.NewServeMux() for _, option := range options { if err := option(n, mux); err != nil { From 5362645a6fcf67c64006bc63eeb3aec3218a4406 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 25 Jan 2015 08:54:33 +0000 Subject: [PATCH 007/674] implement seeking in the dagreader This commit was moved from ipfs/kubo@26826bd55eb2c12001e65d458d6ed1d89b01f176 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ec4596a61..796a1962c 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -77,7 +77,7 @@ func (i *gatewayHandler) AddNodeToDAG(nd *dag.Node) (u.Key, error) { } func (i *gatewayHandler) NewDagReader(nd *dag.Node) (io.Reader, error) { - return uio.NewDagReader(nd, i.node.DAG) + return uio.NewDagReader(i.node.Context(), nd, i.node.DAG) } func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { From beeed20fc282318077493022ae80c0cf0ab729d7 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Mon, 26 Jan 2015 22:00:38 -0800 Subject: [PATCH 008/674] core/corehttp: Support Range requests in gateway handler This commit was moved from ipfs/kubo@d338a81eca5260ad6b587b3a7905ef316448c891 --- gateway/core/corehttp/gateway_handler.go | 38 ++++++++++-------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 796a1962c..f7c5bc195 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -3,9 +3,9 @@ package corehttp import ( "html/template" "io" - "mime" "net/http" - "strings" + "path" + "time" "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" @@ -23,7 +23,7 @@ type gateway interface { ResolvePath(string) (*dag.Node, error) NewDagFromReader(io.Reader) (*dag.Node, error) AddNodeToDAG(nd *dag.Node) (u.Key, error) - NewDagReader(nd *dag.Node) (io.Reader, error) + NewDagReader(nd *dag.Node) (io.ReadSeeker, error) } // shortcut for templating @@ -63,8 +63,8 @@ func (i *gatewayHandler) loadTemplate() error { return nil } -func (i *gatewayHandler) ResolvePath(path string) (*dag.Node, error) { - return i.node.Resolver.ResolvePath(path) +func (i *gatewayHandler) ResolvePath(p string) (*dag.Node, error) { + return i.node.Resolver.ResolvePath(p) } func (i *gatewayHandler) NewDagFromReader(r io.Reader) (*dag.Node, error) { @@ -76,14 +76,14 @@ func (i *gatewayHandler) AddNodeToDAG(nd *dag.Node) (u.Key, error) { return i.node.DAG.Add(nd) } -func (i *gatewayHandler) NewDagReader(nd *dag.Node) (io.Reader, error) { +func (i *gatewayHandler) NewDagReader(nd *dag.Node) (io.ReadSeeker, error) { return uio.NewDagReader(i.node.Context(), nd, i.node.DAG) } func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - path := r.URL.Path[5:] + urlPath := r.URL.Path[5:] - nd, err := i.ResolvePath(path) + nd, err := i.ResolvePath(urlPath) if err != nil { if err == routing.ErrNotFound { w.WriteHeader(http.StatusNotFound) @@ -98,18 +98,12 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - extensionIndex := strings.LastIndex(path, ".") - if extensionIndex != -1 { - extension := path[extensionIndex:] - mimeType := mime.TypeByExtension(extension) - if len(mimeType) > 0 { - w.Header().Add("Content-Type", mimeType) - } - } - dr, err := i.NewDagReader(nd) if err == nil { - io.Copy(w, dr) + _, name := path.Split(urlPath) + // set modtime to a really long time ago, since files are immutable and should stay cached + modtime := time.Unix(1, 0) + http.ServeContent(w, r, name, modtime, dr) return } @@ -120,9 +114,9 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } log.Debug("listing directory") - if path[len(path)-1:] != "/" { + if urlPath[len(urlPath)-1:] != "/" { log.Debug("missing trailing slash, redirect") - http.Redirect(w, r, "/ipfs/"+path+"/", 307) + http.Redirect(w, r, "/ipfs/"+urlPath+"/", 307) return } @@ -135,7 +129,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { log.Debug("found index") foundIndex = true // return index page instead. - nd, err := i.ResolvePath(path + "/index.html") + nd, err := i.ResolvePath(urlPath + "/index.html") if err != nil { internalWebError(w, err) return @@ -155,7 +149,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if !foundIndex { // template and return directory listing - hndlr := webHandler{"listing": dirListing, "path": path} + hndlr := webHandler{"listing": dirListing, "path": urlPath} if err := i.dirList.Execute(w, hndlr); err != nil { internalWebError(w, err) return From 2315cdfe29398794b1a0bf7c04cc7e24c1c5654e Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Mon, 26 Jan 2015 22:37:43 -0800 Subject: [PATCH 009/674] core/corehttp: Handle IPNS paths in gateway This commit was moved from ipfs/kubo@b8fcece0e56f7f6287b7582ba62a47a8506cbc7d --- gateway/core/corehttp/gateway.go | 1 + gateway/core/corehttp/gateway_handler.go | 55 +++++++++++++++++------- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index c3f0a5593..d9de13903 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -12,5 +12,6 @@ func GatewayOption(n *core.IpfsNode, mux *http.ServeMux) error { return err } mux.Handle("/ipfs/", gateway) + mux.Handle("/ipns/", gateway) return nil } diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index f7c5bc195..dde669c0e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -5,6 +5,7 @@ import ( "io" "net/http" "path" + "strings" "time" "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" @@ -33,6 +34,7 @@ type webHandler map[string]interface{} type directoryItem struct { Size uint64 Name string + Path string } // gatewayHandler is a HTTP handler that serves IPFS objects (accessible by default at /ipfs/) @@ -63,8 +65,26 @@ func (i *gatewayHandler) loadTemplate() error { return nil } -func (i *gatewayHandler) ResolvePath(p string) (*dag.Node, error) { - return i.node.Resolver.ResolvePath(p) +func (i *gatewayHandler) ResolvePath(ctx context.Context, p string) (*dag.Node, string, error) { + if strings.HasPrefix(p, "/ipns/") { + elements := strings.Split(path.Clean(p[6:]), "/") + k, err := i.node.Namesys.Resolve(ctx, elements[0]) + if err != nil { + return nil, "", err + } + + elements[0] = k.Pretty() + p = path.Join(elements...) + } + if !strings.HasPrefix(p, "/ipfs/") { + p = path.Join("/ipfs/", p) + } + + node, err := i.node.Resolver.ResolvePath(p) + if err != nil { + return nil, "", err + } + return node, p, err } func (i *gatewayHandler) NewDagFromReader(r io.Reader) (*dag.Node, error) { @@ -81,9 +101,12 @@ func (i *gatewayHandler) NewDagReader(nd *dag.Node) (io.ReadSeeker, error) { } func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - urlPath := r.URL.Path[5:] + ctx, cancel := context.WithCancel(i.node.Context()) + defer cancel() - nd, err := i.ResolvePath(urlPath) + urlPath := r.URL.Path + + nd, p, err := i.ResolvePath(ctx, urlPath) if err != nil { if err == routing.ErrNotFound { w.WriteHeader(http.StatusNotFound) @@ -98,6 +121,8 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } + w.Header().Set("X-IPFS-Path", p) + dr, err := i.NewDagReader(nd) if err == nil { _, name := path.Split(urlPath) @@ -113,13 +138,6 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - log.Debug("listing directory") - if urlPath[len(urlPath)-1:] != "/" { - log.Debug("missing trailing slash, redirect") - http.Redirect(w, r, "/ipfs/"+urlPath+"/", 307) - return - } - // storage for directory listing var dirListing []directoryItem // loop through files @@ -129,7 +147,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { log.Debug("found index") foundIndex = true // return index page instead. - nd, err := i.ResolvePath(urlPath + "/index.html") + nd, _, err := i.ResolvePath(ctx, urlPath+"/index.html") if err != nil { internalWebError(w, err) return @@ -144,12 +162,17 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { break } - dirListing = append(dirListing, directoryItem{link.Size, link.Name}) + di := directoryItem{link.Size, link.Name, path.Join(p, link.Name)} + dirListing = append(dirListing, di) } if !foundIndex { // template and return directory listing - hndlr := webHandler{"listing": dirListing, "path": urlPath} + hndlr := webHandler{ + "listing": dirListing, + "path": urlPath, + "actualPath": p, + } if err := i.dirList.Execute(w, hndlr); err != nil { internalWebError(w, err) return @@ -198,8 +221,8 @@ var listingTemplate = `

Index of {{ .path }}

  • ..
  • - {{ range $item := .listing }} -
  • {{ $item.Name }} - {{ $item.Size }} bytes
  • + {{ range .listing }} +
  • {{ .Name }} - {{ .Size }} bytes
  • {{ end }}
From 5851050c5d8395c6385dc9948d795de8ad14f50d Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Mon, 26 Jan 2015 23:03:05 -0800 Subject: [PATCH 010/674] core/corehttp: Added RedirectOption This commit was moved from ipfs/kubo@e2be5c2039f87ca2517d6a43ac217f23682315c2 --- gateway/core/corehttp/redirect.go | 23 +++++++++++++++++++++++ gateway/core/corehttp/webui.go | 25 +++---------------------- 2 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 gateway/core/corehttp/redirect.go diff --git a/gateway/core/corehttp/redirect.go b/gateway/core/corehttp/redirect.go new file mode 100644 index 000000000..249d8801b --- /dev/null +++ b/gateway/core/corehttp/redirect.go @@ -0,0 +1,23 @@ +package corehttp + +import ( + "net/http" + + core "github.com/jbenet/go-ipfs/core" +) + +func RedirectOption(path string, redirect string) ServeOption { + handler := &redirectHandler{redirect} + return func(n *core.IpfsNode, mux *http.ServeMux) error { + mux.Handle("/"+path, handler) + return nil + } +} + +type redirectHandler struct { + path string +} + +func (i *redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, i.path, 302) +} diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index b1fd08559..46056496b 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,25 +1,6 @@ package corehttp -import ( - "net/http" +// TODO: move to IPNS +const webuiPath = "/ipfs/QmctngrQAt9fjpQUZr7Bx3BsXUcif52eZGTizWhvcShsjz" - core "github.com/jbenet/go-ipfs/core" -) - -const ( - // TODO rename - webuiPath = "/ipfs/QmTWvqK9dYvqjAMAcCeUun8b45Fwu7wPhEN9B9TsGbkXfJ" -) - -func WebUIOption(n *core.IpfsNode, mux *http.ServeMux) error { - mux.Handle("/webui/", &redirectHandler{webuiPath}) - return nil -} - -type redirectHandler struct { - path string -} - -func (i *redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, i.path, 302) -} +var WebUIOption = RedirectOption("webui", webuiPath) From b09e07878e9c1201b093c7769a59650cedefe959 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Tue, 27 Jan 2015 00:21:42 -0800 Subject: [PATCH 011/674] core/corehttp: gateway_handler: Redirect to path with trailing slash when showing a directory's index.html This commit was moved from ipfs/kubo@58d401c3b0b0ab4e3712641f75e217e1a032fa0b --- gateway/core/corehttp/gateway_handler.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index dde669c0e..c2c1917b6 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -144,6 +144,11 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { foundIndex := false for _, link := range nd.Links { if link.Name == "index.html" { + if urlPath[len(urlPath)-1] != '/' { + http.Redirect(w, r, urlPath+"/", 302) + return + } + log.Debug("found index") foundIndex = true // return index page instead. From 088aa07f4ad8292312626e4e57dc129bd95602c2 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Tue, 27 Jan 2015 00:36:14 -0800 Subject: [PATCH 012/674] core/corehttp: Close DAGReaders when done This commit was moved from ipfs/kubo@950e492fc4a0ce4cfbb279d6930036e38b90b7da --- gateway/core/corehttp/gateway_handler.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index c2c1917b6..1cb12c3f8 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -24,7 +24,7 @@ type gateway interface { ResolvePath(string) (*dag.Node, error) NewDagFromReader(io.Reader) (*dag.Node, error) AddNodeToDAG(nd *dag.Node) (u.Key, error) - NewDagReader(nd *dag.Node) (io.ReadSeeker, error) + NewDagReader(nd *dag.Node) (uio.ReadSeekCloser, error) } // shortcut for templating @@ -96,7 +96,7 @@ func (i *gatewayHandler) AddNodeToDAG(nd *dag.Node) (u.Key, error) { return i.node.DAG.Add(nd) } -func (i *gatewayHandler) NewDagReader(nd *dag.Node) (io.ReadSeeker, error) { +func (i *gatewayHandler) NewDagReader(nd *dag.Node) (uio.ReadSeekCloser, error) { return uio.NewDagReader(i.node.Context(), nd, i.node.DAG) } @@ -125,6 +125,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { dr, err := i.NewDagReader(nd) if err == nil { + defer dr.Close() _, name := path.Split(urlPath) // set modtime to a really long time ago, since files are immutable and should stay cached modtime := time.Unix(1, 0) @@ -162,6 +163,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { internalWebError(w, err) return } + defer dr.Close() // write to request io.Copy(w, dr) break From 194a9f2c2add1b8df67b0c4e050bbc9196e32d0e Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Tue, 27 Jan 2015 00:54:13 -0800 Subject: [PATCH 013/674] core/corehttp: Added handling of /ipns//x paths This commit was moved from ipfs/kubo@2759d1c1263f0428c016c4e04c3f1cd2d475c753 --- gateway/core/corehttp/gateway_handler.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1cb12c3f8..038968a5f 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -66,9 +66,12 @@ func (i *gatewayHandler) loadTemplate() error { } func (i *gatewayHandler) ResolvePath(ctx context.Context, p string) (*dag.Node, string, error) { + p = path.Clean(p) + if strings.HasPrefix(p, "/ipns/") { - elements := strings.Split(path.Clean(p[6:]), "/") - k, err := i.node.Namesys.Resolve(ctx, elements[0]) + elements := strings.Split(p[6:], "/") + hash := elements[0] + k, err := i.node.Namesys.Resolve(ctx, hash) if err != nil { return nil, "", err } @@ -169,16 +172,15 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { break } - di := directoryItem{link.Size, link.Name, path.Join(p, link.Name)} + di := directoryItem{link.Size, link.Name, path.Join(urlPath, link.Name)} dirListing = append(dirListing, di) } if !foundIndex { // template and return directory listing hndlr := webHandler{ - "listing": dirListing, - "path": urlPath, - "actualPath": p, + "listing": dirListing, + "path": urlPath, } if err := i.dirList.Execute(w, hndlr); err != nil { internalWebError(w, err) From 6b0eeed444b0cbc29c93dbcdd26807bf26f7afb5 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Tue, 27 Jan 2015 01:01:47 -0800 Subject: [PATCH 014/674] core/corehttp: Use consts for path prefixes This commit was moved from ipfs/kubo@e4eb964f6949bb1ef44ce292abaa06e9b1b676b0 --- gateway/core/corehttp/gateway_handler.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 038968a5f..fe4bd2c15 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -20,6 +20,11 @@ import ( u "github.com/jbenet/go-ipfs/util" ) +const ( + IpfsPathPrefix = "/ipfs/" + IpnsPathPrefix = "/ipns/" +) + type gateway interface { ResolvePath(string) (*dag.Node, error) NewDagFromReader(io.Reader) (*dag.Node, error) @@ -68,8 +73,8 @@ func (i *gatewayHandler) loadTemplate() error { func (i *gatewayHandler) ResolvePath(ctx context.Context, p string) (*dag.Node, string, error) { p = path.Clean(p) - if strings.HasPrefix(p, "/ipns/") { - elements := strings.Split(p[6:], "/") + if strings.HasPrefix(p, IpnsPathPrefix) { + elements := strings.Split(p[len(IpnsPathPrefix):], "/") hash := elements[0] k, err := i.node.Namesys.Resolve(ctx, hash) if err != nil { @@ -79,8 +84,8 @@ func (i *gatewayHandler) ResolvePath(ctx context.Context, p string) (*dag.Node, elements[0] = k.Pretty() p = path.Join(elements...) } - if !strings.HasPrefix(p, "/ipfs/") { - p = path.Join("/ipfs/", p) + if !strings.HasPrefix(p, IpfsPathPrefix) { + p = path.Join(IpfsPathPrefix, p) } node, err := i.node.Resolver.ResolvePath(p) From 1b6c240e063b4b6f6632634449e50d53e18f5b04 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Wed, 28 Jan 2015 03:36:34 -0800 Subject: [PATCH 015/674] core/corehttp: Added cache headers to gatewayy requests This commit was moved from ipfs/kubo@fb986fd82277dda1e7d919a9980483339ac45bc7 --- gateway/core/corehttp/gateway_handler.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index fe4bd2c15..85bb90bf4 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -130,6 +130,8 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } w.Header().Set("X-IPFS-Path", p) + w.Header().Set("Etag", path.Base(p)) + w.Header().Set("Cache-Control", "public, max-age=29030400") dr, err := i.NewDagReader(nd) if err == nil { From 6566167ac6f5b5bf104915332a8b670a8a786aec Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Wed, 28 Jan 2015 03:42:07 -0800 Subject: [PATCH 016/674] core/corehttp: Handle Etag for caching This commit was moved from ipfs/kubo@cea68afa2e8d78fd64ac476eeedc3e7b2ffc4d9d --- gateway/core/corehttp/gateway_handler.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 85bb90bf4..37fe1d5c5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -129,8 +129,14 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } + etag := path.Base(p) + if r.Header.Get("If-None-Match") == etag { + w.WriteHeader(http.StatusNotModified) + return + } + + w.Header().Set("Etag", etag) w.Header().Set("X-IPFS-Path", p) - w.Header().Set("Etag", path.Base(p)) w.Header().Set("Cache-Control", "public, max-age=29030400") dr, err := i.NewDagReader(nd) From be166cd9f8d930fa6d7432e1a4f9864fbf993ea8 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Wed, 28 Jan 2015 13:10:34 -0800 Subject: [PATCH 017/674] gateway: reordered headers to avoid error cc @mappum This commit was moved from ipfs/kubo@c36e8dd04c326bd38f1cff5f196efbba72050240 --- gateway/core/corehttp/gateway_handler.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 37fe1d5c5..4547efac8 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -135,11 +135,20 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - w.Header().Set("Etag", etag) w.Header().Set("X-IPFS-Path", p) - w.Header().Set("Cache-Control", "public, max-age=29030400") dr, err := i.NewDagReader(nd) + if err != nil && err != uio.ErrIsDir { + // not a directory and still an error + internalWebError(w, err) + return + } + + // set these headers _after_ the error, for we may just not have it + // and dont want the client to cache a 500 response... + w.Header().Set("Etag", etag) + w.Header().Set("Cache-Control", "public, max-age=29030400") + if err == nil { defer dr.Close() _, name := path.Split(urlPath) @@ -149,12 +158,6 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - if err != uio.ErrIsDir { - // not a directory and still an error - internalWebError(w, err) - return - } - // storage for directory listing var dirListing []directoryItem // loop through files From 0be18ea3c32cb7b4d1e59200b1faa6248778915c Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 28 Jan 2015 05:18:39 +0000 Subject: [PATCH 018/674] implement path type This commit was moved from ipfs/kubo@abb3c9c9c4ee5911bd570926e722277a49e4b3f5 --- gateway/core/corehttp/gateway_handler.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 4547efac8..570e2c999 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -4,7 +4,7 @@ import ( "html/template" "io" "net/http" - "path" + gopath "path" "strings" "time" @@ -15,6 +15,7 @@ import ( "github.com/jbenet/go-ipfs/importer" chunk "github.com/jbenet/go-ipfs/importer/chunk" dag "github.com/jbenet/go-ipfs/merkledag" + path "github.com/jbenet/go-ipfs/path" "github.com/jbenet/go-ipfs/routing" uio "github.com/jbenet/go-ipfs/unixfs/io" u "github.com/jbenet/go-ipfs/util" @@ -71,7 +72,7 @@ func (i *gatewayHandler) loadTemplate() error { } func (i *gatewayHandler) ResolvePath(ctx context.Context, p string) (*dag.Node, string, error) { - p = path.Clean(p) + p = gopath.Clean(p) if strings.HasPrefix(p, IpnsPathPrefix) { elements := strings.Split(p[len(IpnsPathPrefix):], "/") @@ -82,13 +83,13 @@ func (i *gatewayHandler) ResolvePath(ctx context.Context, p string) (*dag.Node, } elements[0] = k.Pretty() - p = path.Join(elements...) + p = gopath.Join(elements...) } if !strings.HasPrefix(p, IpfsPathPrefix) { - p = path.Join(IpfsPathPrefix, p) + p = gopath.Join(IpfsPathPrefix, p) } - node, err := i.node.Resolver.ResolvePath(p) + node, err := i.node.Resolver.ResolvePath(path.Path(p)) if err != nil { return nil, "", err } @@ -129,7 +130,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - etag := path.Base(p) + etag := gopath.Base(p) if r.Header.Get("If-None-Match") == etag { w.WriteHeader(http.StatusNotModified) return @@ -151,7 +152,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if err == nil { defer dr.Close() - _, name := path.Split(urlPath) + _, name := gopath.Split(urlPath) // set modtime to a really long time ago, since files are immutable and should stay cached modtime := time.Unix(1, 0) http.ServeContent(w, r, name, modtime, dr) @@ -188,7 +189,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { break } - di := directoryItem{link.Size, link.Name, path.Join(urlPath, link.Name)} + di := directoryItem{link.Size, link.Name, gopath.Join(urlPath, link.Name)} dirListing = append(dirListing, di) } From 8e430b080125dfd00e02b6c14cd5560ce3a92233 Mon Sep 17 00:00:00 2001 From: Mildred Ki'Lya Date: Wed, 21 Jan 2015 15:51:28 +0100 Subject: [PATCH 019/674] HTTP: add handlers to allow object creation and modification This commit was moved from ipfs/kubo@d221d55d85629512711e7ffbe248c5d56f247d39 --- gateway/core/corehttp/gateway_handler.go | 206 ++++++++++++++++++++++- 1 file changed, 198 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 570e2c999..6140c17e3 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -1,6 +1,7 @@ package corehttp import ( + "fmt" "html/template" "io" "net/http" @@ -17,6 +18,7 @@ import ( dag "github.com/jbenet/go-ipfs/merkledag" path "github.com/jbenet/go-ipfs/path" "github.com/jbenet/go-ipfs/routing" + ufs "github.com/jbenet/go-ipfs/unixfs" uio "github.com/jbenet/go-ipfs/unixfs/io" u "github.com/jbenet/go-ipfs/util" ) @@ -101,6 +103,10 @@ func (i *gatewayHandler) NewDagFromReader(r io.Reader) (*dag.Node, error) { r, i.node.DAG, i.node.Pinning.GetManual(), chunk.DefaultSplitter) } +func NewDagEmptyDir() *dag.Node { + return &dag.Node{Data: ufs.FolderPBData()} +} + func (i *gatewayHandler) AddNodeToDAG(nd *dag.Node) (u.Key, error) { return i.node.DAG.Add(nd) } @@ -110,6 +116,33 @@ func (i *gatewayHandler) NewDagReader(nd *dag.Node) (uio.ReadSeekCloser, error) } func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if r.Method == "POST" { + i.postHandler(w, r) + return + } + + if r.Method == "PUT" { + i.putHandler(w, r) + return + } + + if r.Method == "DELETE" { + i.deleteHandler(w, r) + return + } + + if r.Method == "GET" { + i.getHandler(w, r) + return + } + + errmsg := "Method " + r.Method + " not allowed: " + "bad request for " + r.URL.Path + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(errmsg)) + log.Error(errmsg) +} + +func (i *gatewayHandler) getHandler(w http.ResponseWriter, r *http.Request) { ctx, cancel := context.WithCancel(i.node.Context()) defer cancel() @@ -209,23 +242,180 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { nd, err := i.NewDagFromReader(r.Body) if err != nil { - w.WriteHeader(http.StatusInternalServerError) - log.Error(err) - w.Write([]byte(err.Error())) + internalWebError(w, err) return } k, err := i.AddNodeToDAG(nd) if err != nil { - w.WriteHeader(http.StatusInternalServerError) - log.Error(err) + internalWebError(w, err) + return + } + + h := mh.Multihash(k).B58String() + w.Header().Set("IPFS-Hash", h) + http.Redirect(w, r, IpfsPathPrefix+h, http.StatusCreated) +} + +func (i *gatewayHandler) putEmptyDirHandler(w http.ResponseWriter, r *http.Request) { + newnode := NewDagEmptyDir() + + key, err := i.node.DAG.Add(newnode) + if err != nil { + webError(w, "Could not recursively add new node", err, http.StatusInternalServerError) + return + } + + w.Header().Set("IPFS-Hash", key.String()) + http.Redirect(w, r, IpfsPathPrefix+key.String()+"/", http.StatusCreated) +} + +func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { + urlPath := r.URL.Path + pathext := urlPath[5:] + var err error + if urlPath == IpfsPathPrefix + "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/" { + i.putEmptyDirHandler(w, r) + return + } + + var newnode *dag.Node + if pathext[len(pathext)-1] == '/' { + newnode = NewDagEmptyDir() + } else { + newnode, err = i.NewDagFromReader(r.Body) + if err != nil { + webError(w, "Could not create DAG from request", err, http.StatusInternalServerError) + return + } + } + + h, components, err := path.SplitAbsPath(path.Path(urlPath)) + if err != nil { + webError(w, "Could not split path", err, http.StatusInternalServerError) + return + } + + if len(components) < 1 { + err = fmt.Errorf("Cannot override existing object") + w.WriteHeader(http.StatusBadRequest) w.Write([]byte(err.Error())) + log.Error("%s", err) + return + } + + rootnd, err := i.node.Resolver.DAG.Get(u.Key(h)) + if err != nil { + webError(w, "Could not resolve root object", err, http.StatusBadRequest) + return + } + + // resolving path components into merkledag nodes. if a component does not + // resolve, create empty directories (which will be linked and populated below.) + path_nodes, err := i.node.Resolver.ResolveLinks(rootnd, components[:len(components)-1]) + if _, ok := err.(path.ErrNoLink); ok { + // Create empty directories, links will be made further down the code + for len(path_nodes) < len(components) { + path_nodes = append(path_nodes, NewDagEmptyDir()) + } + } else if err != nil { + webError(w, "Could not resolve parent object", err, http.StatusBadRequest) + return + } + + for i := len(path_nodes) - 1; i >= 0; i-- { + newnode, err = path_nodes[i].UpdateNodeLink(components[i], newnode) + if err != nil { + webError(w, "Could not update node links", err, http.StatusInternalServerError) + return + } + } + + err = i.node.DAG.AddRecursive(newnode) + if err != nil { + webError(w, "Could not add recursively new node", err, http.StatusInternalServerError) + return + } + + // Redirect to new path + key, err := newnode.Key() + if err != nil { + webError(w, "Could not get key of new node", err, http.StatusInternalServerError) + return + } + + w.Header().Set("IPFS-Hash", key.String()) + http.Redirect(w, r, IpfsPathPrefix+key.String()+"/"+strings.Join(components, "/"), http.StatusCreated) +} + +func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { + urlPath := r.URL.Path + h, components, err := path.SplitAbsPath(path.Path(urlPath)) + if err != nil { + webError(w, "Could not split path", err, http.StatusInternalServerError) + return + } + + rootnd, err := i.node.Resolver.DAG.Get(u.Key(h)) + if err != nil { + webError(w, "Could not resolve root object", err, http.StatusBadRequest) return } - //TODO: return json representation of list instead - w.WriteHeader(http.StatusCreated) - w.Write([]byte(mh.Multihash(k).B58String())) + path_nodes, err := i.node.Resolver.ResolveLinks(rootnd, components[:len(components)-1]) + if err != nil { + webError(w, "Could not resolve parent object", err, http.StatusBadRequest) + return + } + + err = path_nodes[len(path_nodes)-1].RemoveNodeLink(components[len(components)-1]) + if err != nil { + webError(w, "Could not delete link", err, http.StatusBadRequest) + return + } + + newnode := path_nodes[len(path_nodes)-1] + for i := len(path_nodes) - 2; i >= 0; i-- { + newnode, err = path_nodes[i].UpdateNodeLink(components[i], newnode) + if err != nil { + webError(w, "Could not update node links", err, http.StatusInternalServerError) + return + } + } + + err = i.node.DAG.AddRecursive(newnode) + if err != nil { + webError(w, "Could not add recursively new node", err, http.StatusInternalServerError) + return + } + + // Redirect to new path + key, err := newnode.Key() + if err != nil { + webError(w, "Could not get key of new node", err, http.StatusInternalServerError) + return + } + + w.Header().Set("IPFS-Hash", key.String()) + http.Redirect(w, r, IpfsPathPrefix+key.String()+"/"+strings.Join(components[:len(components)-1], "/"), http.StatusCreated) +} + +func webError(w http.ResponseWriter, message string, err error, defaultCode int) { + if _, ok := err.(path.ErrNoLink); ok { + webErrorWithCode(w, message, err, http.StatusNotFound) + } else if err == routing.ErrNotFound { + webErrorWithCode(w, message, err, http.StatusNotFound) + } else if err == context.DeadlineExceeded { + webErrorWithCode(w, message, err, http.StatusRequestTimeout) + } else { + webErrorWithCode(w, message, err, defaultCode) + } +} + +func webErrorWithCode(w http.ResponseWriter, message string, err error, code int) { + w.WriteHeader(code) + log.Errorf("%s: %s", message, err) + w.Write([]byte(message + ": " + err.Error())) } // return a 500 error and log From 1ddd99d3987144eb86f19d7fa09980ada4e08fad Mon Sep 17 00:00:00 2001 From: Mildred Ki'Lya Date: Wed, 28 Jan 2015 12:57:09 +0100 Subject: [PATCH 020/674] Make gateway read-only by default and add option to make it writable This commit was moved from ipfs/kubo@7d09da3c8b0b5d2dd2cf0d357cb4976093fafa92 --- gateway/core/corehttp/gateway.go | 16 ++++++++------- gateway/core/corehttp/gateway_handler.go | 26 ++++++++++++++++-------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index d9de13903..43ba3fffd 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -6,12 +6,14 @@ import ( core "github.com/jbenet/go-ipfs/core" ) -func GatewayOption(n *core.IpfsNode, mux *http.ServeMux) error { - gateway, err := newGatewayHandler(n) - if err != nil { - return err - } - mux.Handle("/ipfs/", gateway) +func GatewayOption(writable bool) ServeOption { + return func(n *core.IpfsNode, mux *http.ServeMux) error { + gateway, err := newGatewayHandler(n, writable) + if err != nil { + return err + } + mux.Handle("/ipfs/", gateway) mux.Handle("/ipns/", gateway) - return nil + return nil + } } diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 6140c17e3..e06762a15 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -48,13 +48,15 @@ type directoryItem struct { // gatewayHandler is a HTTP handler that serves IPFS objects (accessible by default at /ipfs/) // (it serves requests like GET /ipfs/QmVRzPKPzNtSrEzBFm2UZfxmPAgnaLke4DMcerbsGGSaFe/link) type gatewayHandler struct { - node *core.IpfsNode - dirList *template.Template + node *core.IpfsNode + dirList *template.Template + writable bool } -func newGatewayHandler(node *core.IpfsNode) (*gatewayHandler, error) { +func newGatewayHandler(node *core.IpfsNode, writable bool) (*gatewayHandler, error) { i := &gatewayHandler{ - node: node, + node: node, + writable: writable, } err := i.loadTemplate() if err != nil { @@ -116,17 +118,17 @@ func (i *gatewayHandler) NewDagReader(nd *dag.Node) (uio.ReadSeekCloser, error) } func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if r.Method == "POST" { + if i.writable && r.Method == "POST" { i.postHandler(w, r) return } - if r.Method == "PUT" { + if i.writable && r.Method == "PUT" { i.putHandler(w, r) return } - if r.Method == "DELETE" { + if i.writable && r.Method == "DELETE" { i.deleteHandler(w, r) return } @@ -136,8 +138,14 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - errmsg := "Method " + r.Method + " not allowed: " + "bad request for " + r.URL.Path - w.WriteHeader(http.StatusBadRequest) + errmsg := "Method " + r.Method + " not allowed: " + if !i.writable { + w.WriteHeader(http.StatusMethodNotAllowed) + errmsg = errmsg + "read only access" + } else { + w.WriteHeader(http.StatusBadRequest) + errmsg = errmsg + "bad request for " + r.URL.Path + } w.Write([]byte(errmsg)) log.Error(errmsg) } From 299e8b3073b0c08224da74b8fedff5eb5a2143ed Mon Sep 17 00:00:00 2001 From: Mildred Ki'Lya Date: Wed, 28 Jan 2015 13:06:11 +0100 Subject: [PATCH 021/674] HTTP Gateway: add /ipns/ GET requests This commit was moved from ipfs/kubo@295cc443da69cd0714a28685b2a0662e655fbd46 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 36 +++++++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 43ba3fffd..c6b5545e9 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -13,7 +13,7 @@ func GatewayOption(writable bool) ServeOption { return err } mux.Handle("/ipfs/", gateway) - mux.Handle("/ipns/", gateway) + mux.Handle("/ipns/", gateway) return nil } } diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index e06762a15..328d8cce9 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -75,7 +75,7 @@ func (i *gatewayHandler) loadTemplate() error { return nil } -func (i *gatewayHandler) ResolvePath(ctx context.Context, p string) (*dag.Node, string, error) { +func (i *gatewayHandler) resolveNamePath(ctx context.Context, p string) (string, error) { p = gopath.Clean(p) if strings.HasPrefix(p, IpnsPathPrefix) { @@ -83,7 +83,7 @@ func (i *gatewayHandler) ResolvePath(ctx context.Context, p string) (*dag.Node, hash := elements[0] k, err := i.node.Namesys.Resolve(ctx, hash) if err != nil { - return nil, "", err + return "", err } elements[0] = k.Pretty() @@ -92,6 +92,14 @@ func (i *gatewayHandler) ResolvePath(ctx context.Context, p string) (*dag.Node, if !strings.HasPrefix(p, IpfsPathPrefix) { p = gopath.Join(IpfsPathPrefix, p) } + return p, nil +} + +func (i *gatewayHandler) ResolvePath(ctx context.Context, p string) (*dag.Node, string, error) { + p, err := i.resolveNamePath(ctx, p) + if err != nil { + return nil, "", err + } node, err := i.node.Resolver.ResolvePath(path.Path(p)) if err != nil { @@ -298,7 +306,17 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { } } - h, components, err := path.SplitAbsPath(path.Path(urlPath)) + ctx, cancel := context.WithCancel(i.node.Context()) + defer cancel() + + ipfspath, err := i.resolveNamePath(ctx, urlPath) + if err != nil { + // FIXME HTTP error code + webError(w, "Could not resolve name", err, http.StatusInternalServerError) + return + } + + h, components, err := path.SplitAbsPath(path.Path(ipfspath)) if err != nil { webError(w, "Could not split path", err, http.StatusInternalServerError) return @@ -358,7 +376,17 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { urlPath := r.URL.Path - h, components, err := path.SplitAbsPath(path.Path(urlPath)) + ctx, cancel := context.WithCancel(i.node.Context()) + defer cancel() + + ipfspath, err := i.resolveNamePath(ctx, urlPath) + if err != nil { + // FIXME HTTP error code + webError(w, "Could not resolve name", err, http.StatusInternalServerError) + return + } + + h, components, err := path.SplitAbsPath(path.Path(ipfspath)) if err != nil { webError(w, "Could not split path", err, http.StatusInternalServerError) return From 4f79042038790914704bb70e08e2c788a249f537 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Sat, 31 Jan 2015 19:15:46 -0800 Subject: [PATCH 022/674] test/sharness: fix errors - core: daemon stdout print to cmd + daemon init checks - core: fixed bug where the gateway was printed as "API" - sharness/test-lib: daemon init checks - sharness/test-lib: portable TCP port check - sharness/init: fix test bits output - sharness: use common hashes in one place. - move t0100-http-gateway -> t0111-gateway-writable - sharness: test-lib funcs for gateway config - sharness/t0111-gateway-writable: use sh funcs - sharness/t0111-gateway-writable: fixes - escape all vars (always `cmd "$VAR"` never `cmd $VAR`) - use $FILEPATH, not $path - last test seems to fail This commit was moved from ipfs/kubo@f1d34a2a8514c2273c87b062fe9d3ccaaaadaccc --- gateway/core/corehttp/corehttp.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 32b27b261..104b6566f 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -1,7 +1,6 @@ package corehttp import ( - "fmt" "net/http" manners "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/braintree/manners" @@ -36,10 +35,10 @@ func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...Serv return err } } - return listenAndServe("API", n, addr, mux) + return listenAndServe(n, addr, mux) } -func listenAndServe(name string, node *core.IpfsNode, addr ma.Multiaddr, mux *http.ServeMux) error { +func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, mux *http.ServeMux) error { _, host, err := manet.DialArgs(addr) if err != nil { return err @@ -52,7 +51,6 @@ func listenAndServe(name string, node *core.IpfsNode, addr ma.Multiaddr, mux *ht serverExited := make(chan struct{}) go func() { - fmt.Printf("%s server listening on %s\n", name, addr) serverError = server.ListenAndServe(host, mux) close(serverExited) }() From 2397dc506c09dffe16b369cbb07b2d35ff94571b Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Tue, 3 Feb 2015 01:06:07 -0800 Subject: [PATCH 023/674] logs: removed all log.Errors unhelpful to users Let's save log.Error for things the user can take action on. Moved all our diagnostics to log.Debug. We can ideally reduce them even further. This commit was moved from ipfs/kubo@58f39687cfcb5dc3063ba4d9043ea597cbb9bf05 --- gateway/core/corehttp/gateway_handler.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 328d8cce9..5ea654360 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -155,7 +155,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { errmsg = errmsg + "bad request for " + r.URL.Path } w.Write([]byte(errmsg)) - log.Error(errmsg) + log.Debug(errmsg) } func (i *gatewayHandler) getHandler(w http.ResponseWriter, r *http.Request) { @@ -174,7 +174,6 @@ func (i *gatewayHandler) getHandler(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusBadRequest) } - log.Error(err) w.Write([]byte(err.Error())) return } @@ -290,7 +289,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { urlPath := r.URL.Path pathext := urlPath[5:] var err error - if urlPath == IpfsPathPrefix + "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/" { + if urlPath == IpfsPathPrefix+"QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/" { i.putEmptyDirHandler(w, r) return } @@ -326,7 +325,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { err = fmt.Errorf("Cannot override existing object") w.WriteHeader(http.StatusBadRequest) w.Write([]byte(err.Error())) - log.Error("%s", err) + log.Debug("%s", err) return } @@ -450,7 +449,7 @@ func webError(w http.ResponseWriter, message string, err error, defaultCode int) func webErrorWithCode(w http.ResponseWriter, message string, err error, code int) { w.WriteHeader(code) - log.Errorf("%s: %s", message, err) + log.Debugf("%s: %s", message, err) w.Write([]byte(message + ": " + err.Error())) } @@ -458,7 +457,7 @@ func webErrorWithCode(w http.ResponseWriter, message string, err error, code int func internalWebError(w http.ResponseWriter, err error) { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte(err.Error())) - log.Error("%s", err) + log.Debug("%s", err) } // Directory listing template From d9b0eddafc4c9a1147fb408872d1adcd0979ce61 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Tue, 3 Feb 2015 15:48:10 -0800 Subject: [PATCH 024/674] feat(corehttp) add a Gateway blocklist use pointer use func comment on decider to clarify whether it allows or denies fix set conf gstw This commit was moved from ipfs/kubo@d50a7ff0037b2fb6d787cf6fb1c3d14a429b1ea0 --- gateway/core/corehttp/gateway.go | 59 +++++++++++++++++++++++- gateway/core/corehttp/gateway_handler.go | 21 ++++++--- 2 files changed, 71 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index c6b5545e9..0e0601b34 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -2,13 +2,30 @@ package corehttp import ( "net/http" + "sync" core "github.com/jbenet/go-ipfs/core" ) -func GatewayOption(writable bool) ServeOption { +// Gateway should be instantiated using NewGateway +type Gateway struct { + Config GatewayConfig +} + +type GatewayConfig struct { + BlockList *BlockList + Writable bool +} + +func NewGateway(conf GatewayConfig) *Gateway { + return &Gateway{ + Config: conf, + } +} + +func (g *Gateway) ServeOption() ServeOption { return func(n *core.IpfsNode, mux *http.ServeMux) error { - gateway, err := newGatewayHandler(n, writable) + gateway, err := newGatewayHandler(n, g.Config) if err != nil { return err } @@ -17,3 +34,41 @@ func GatewayOption(writable bool) ServeOption { return nil } } + +func GatewayOption(writable bool) ServeOption { + g := NewGateway(GatewayConfig{ + Writable: writable, + BlockList: &BlockList{}, + }) + return g.ServeOption() +} + +// Decider decides whether to Allow string +type Decider func(string) bool + +type BlockList struct { + + mu sync.RWMutex + d Decider +} + +func (b *BlockList) ShouldAllow(s string) bool { + b.mu.RLock() + d := b.d + b.mu.RUnlock() + if d == nil { + return true + } + return d(s) +} + +// SetDecider atomically swaps the blocklist's decider +func (b *BlockList) SetDecider(d Decider) { + b.mu.Lock() + b.d = d + b.mu.Unlock() +} + +func (b *BlockList) ShouldBlock(s string) bool { + return !b.ShouldAllow(s) +} diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 5ea654360..93c33cb2e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -50,13 +50,13 @@ type directoryItem struct { type gatewayHandler struct { node *core.IpfsNode dirList *template.Template - writable bool + config GatewayConfig } -func newGatewayHandler(node *core.IpfsNode, writable bool) (*gatewayHandler, error) { +func newGatewayHandler(node *core.IpfsNode, conf GatewayConfig) (*gatewayHandler, error) { i := &gatewayHandler{ node: node, - writable: writable, + config: conf, } err := i.loadTemplate() if err != nil { @@ -125,18 +125,20 @@ func (i *gatewayHandler) NewDagReader(nd *dag.Node) (uio.ReadSeekCloser, error) return uio.NewDagReader(i.node.Context(), nd, i.node.DAG) } +// TODO(btc): break this apart into separate handlers using a more expressive +// muxer func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if i.writable && r.Method == "POST" { + if i.config.Writable && r.Method == "POST" { i.postHandler(w, r) return } - if i.writable && r.Method == "PUT" { + if i.config.Writable && r.Method == "PUT" { i.putHandler(w, r) return } - if i.writable && r.Method == "DELETE" { + if i.config.Writable && r.Method == "DELETE" { i.deleteHandler(w, r) return } @@ -147,7 +149,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } errmsg := "Method " + r.Method + " not allowed: " - if !i.writable { + if !i.config.Writable { w.WriteHeader(http.StatusMethodNotAllowed) errmsg = errmsg + "read only access" } else { @@ -164,6 +166,11 @@ func (i *gatewayHandler) getHandler(w http.ResponseWriter, r *http.Request) { urlPath := r.URL.Path + if i.config.BlockList != nil && i.config.BlockList.ShouldBlock(urlPath) { + w.WriteHeader(http.StatusNotFound) + return + } + nd, p, err := i.ResolvePath(ctx, urlPath) if err != nil { if err == routing.ErrNotFound { From 79bda8216a0637efec88ee2ed0bfe3c395c58b41 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Mon, 2 Feb 2015 17:25:28 -0800 Subject: [PATCH 025/674] core/corehttp: Added Suborigin header to gateway responses This commit was moved from ipfs/kubo@262e78122a4a0829056379332c4b4e330c1a837c --- gateway/core/corehttp/gateway_handler.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 93c33cb2e..cef5b5a0d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -193,6 +193,12 @@ func (i *gatewayHandler) getHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("X-IPFS-Path", p) + // Suborigin header, sandboxes apps from each other in the browser (even + // though they are served from the same gateway domain). NOTE: This is not + // yet widely supported by browsers. + pathRoot := strings.SplitN(urlPath, "/", 4)[2] + w.Header().Set("Suborigin", pathRoot) + dr, err := i.NewDagReader(nd) if err != nil && err != uio.ErrIsDir { // not a directory and still an error From c16699f92f221f1703893a363331e3c6e3c9fa2b Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Mon, 2 Feb 2015 18:00:04 -0800 Subject: [PATCH 026/674] core/corehttp: Added gateway path whitelisting This commit was moved from ipfs/kubo@b1ca07d6c5fcd0db16e5594d2c15c2ab02f49908 --- gateway/core/corehttp/gateway.go | 1 - gateway/core/corehttp/gateway_handler.go | 10 +++++----- gateway/core/corehttp/webui.go | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 0e0601b34..ae0b45c6c 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -47,7 +47,6 @@ func GatewayOption(writable bool) ServeOption { type Decider func(string) bool type BlockList struct { - mu sync.RWMutex d Decider } diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index cef5b5a0d..dd160cff8 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -48,15 +48,15 @@ type directoryItem struct { // gatewayHandler is a HTTP handler that serves IPFS objects (accessible by default at /ipfs/) // (it serves requests like GET /ipfs/QmVRzPKPzNtSrEzBFm2UZfxmPAgnaLke4DMcerbsGGSaFe/link) type gatewayHandler struct { - node *core.IpfsNode - dirList *template.Template - config GatewayConfig + node *core.IpfsNode + dirList *template.Template + config GatewayConfig } func newGatewayHandler(node *core.IpfsNode, conf GatewayConfig) (*gatewayHandler, error) { i := &gatewayHandler{ - node: node, - config: conf, + node: node, + config: conf, } err := i.loadTemplate() if err != nil { diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 46056496b..09d75008c 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,6 +1,6 @@ package corehttp // TODO: move to IPNS -const webuiPath = "/ipfs/QmctngrQAt9fjpQUZr7Bx3BsXUcif52eZGTizWhvcShsjz" +const WebUIPath = "/ipfs/QmctngrQAt9fjpQUZr7Bx3BsXUcif52eZGTizWhvcShsjz" -var WebUIOption = RedirectOption("webui", webuiPath) +var WebUIOption = RedirectOption("webui", WebUIPath) From b06943b408da0fa100f295a141c3d080f2f58abb Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Wed, 4 Feb 2015 18:43:48 -0800 Subject: [PATCH 027/674] core/corehttp: Return 403 for blocked requests instead of 404 This commit was moved from ipfs/kubo@2d173c3a257b1a90c7104b677661bb3727adbf89 --- gateway/core/corehttp/gateway_handler.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index dd160cff8..6c5f70818 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -167,7 +167,8 @@ func (i *gatewayHandler) getHandler(w http.ResponseWriter, r *http.Request) { urlPath := r.URL.Path if i.config.BlockList != nil && i.config.BlockList.ShouldBlock(urlPath) { - w.WriteHeader(http.StatusNotFound) + w.WriteHeader(http.StatusForbidden) + w.Write([]byte("403 - Forbidden")) return } From 3734b1f18f483db6c9be475e31bbdfb87b603f53 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Wed, 4 Feb 2015 21:39:48 -0800 Subject: [PATCH 028/674] core/corehttp: Updated WebUI hash This commit was moved from ipfs/kubo@0195c0366478f2debc1f17ecc178833ef307322d --- gateway/core/corehttp/webui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 09d75008c..18f5f2eb0 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,6 +1,6 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmctngrQAt9fjpQUZr7Bx3BsXUcif52eZGTizWhvcShsjz" +const WebUIPath = "/ipfs/QmSHDxWsMPuJQKWmVA1rB5a3NX2Eme5fPqNb63qwaqiqSp" var WebUIOption = RedirectOption("webui", WebUIPath) From 6624b5ecb03dbc03cd92da987f08b77f20fa79f2 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Fri, 6 Feb 2015 07:30:42 -0800 Subject: [PATCH 029/674] corehttp: allow all webui paths we published. Otherwise we break users links! cc @mappum This commit was moved from ipfs/kubo@64a4c27913318530b460500d1aafceaa476a773c --- gateway/core/corehttp/webui.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 18f5f2eb0..2bcb0d946 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -3,4 +3,10 @@ package corehttp // TODO: move to IPNS const WebUIPath = "/ipfs/QmSHDxWsMPuJQKWmVA1rB5a3NX2Eme5fPqNb63qwaqiqSp" +// this is a list of all past webUI paths. +var WebUIPaths = []string{ + WebUIPath, + "/ipfs/QmctngrQAt9fjpQUZr7Bx3BsXUcif52eZGTizWhvcShsjz", +} + var WebUIOption = RedirectOption("webui", WebUIPath) From e21111cfad3961ba224b3d3117e78061d73845e8 Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Wed, 4 Feb 2015 18:50:14 -0800 Subject: [PATCH 030/674] allow access to the field for convenience decalarative configuration is superior. the thread-safety because important during normal operation This commit was moved from ipfs/kubo@db644fe1b7d612082395d07feb5a7f1b544a0260 --- gateway/core/corehttp/gateway.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index ae0b45c6c..9c20cd5a9 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -48,12 +48,12 @@ type Decider func(string) bool type BlockList struct { mu sync.RWMutex - d Decider + Decider Decider } func (b *BlockList) ShouldAllow(s string) bool { b.mu.RLock() - d := b.d + d := b.Decider b.mu.RUnlock() if d == nil { return true @@ -61,10 +61,11 @@ func (b *BlockList) ShouldAllow(s string) bool { return d(s) } -// SetDecider atomically swaps the blocklist's decider +// SetDecider atomically swaps the blocklist's decider. This method is +// thread-safe. func (b *BlockList) SetDecider(d Decider) { b.mu.Lock() - b.d = d + b.Decider = d b.mu.Unlock() } From 352a98d07597bb4e752b8a6a7eb81db372ab8f62 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Sat, 7 Feb 2015 10:09:59 -0800 Subject: [PATCH 031/674] gateway: dont cache ipns paths ipns paths are mutable and should not be cached. this error is a byproduct of the currently messy gateway route. We should split the /ipfs and /ipns routes up. This commit was moved from ipfs/kubo@872c64dd79bb1bc0e10aa8e2021710e4fb42f13d --- gateway/core/corehttp/gateway_handler.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 6c5f70818..4fcca2421 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -209,14 +209,20 @@ func (i *gatewayHandler) getHandler(w http.ResponseWriter, r *http.Request) { // set these headers _after_ the error, for we may just not have it // and dont want the client to cache a 500 response... - w.Header().Set("Etag", etag) - w.Header().Set("Cache-Control", "public, max-age=29030400") + // and only if it's /ipfs! + // TODO: break this out when we split /ipfs /ipns routes. + modtime := time.Now() + if strings.HasPrefix(urlPath, IpfsPathPrefix) { + w.Header().Set("Etag", etag) + w.Header().Set("Cache-Control", "public, max-age=29030400") + + // set modtime to a really long time ago, since files are immutable and should stay cached + modtime = time.Unix(1, 0) + } if err == nil { defer dr.Close() _, name := gopath.Split(urlPath) - // set modtime to a really long time ago, since files are immutable and should stay cached - modtime := time.Unix(1, 0) http.ServeContent(w, r, name, modtime, dr) return } From 1a9a313d9781252b192e78115df74646e25678c8 Mon Sep 17 00:00:00 2001 From: Kevin Wallace Date: Mon, 2 Feb 2015 22:50:13 -0800 Subject: [PATCH 032/674] corehttp: ServeOption supports chaining muxes Each option now additionally returns the mux to be used by future options. If every options returns the mux it was passed, the current behavior is unchanged. However, if the option returns an a new mux, it can mediate requests to handlers provided by future options: return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { childMux := http.NewServeMux() mux.Handle("/", handlerThatDelegatesToChildMux) return childMux, nil } License: MIT Signed-off-by: Kevin Wallace This commit was moved from ipfs/kubo@fbd76ebb5b5390a5037340003e77f06e04e3e87a --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/corehttp.go | 18 ++++++++++-------- gateway/core/corehttp/gateway.go | 10 +++++----- gateway/core/corehttp/redirect.go | 4 ++-- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 3b9ac262c..6128ed717 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -16,10 +16,10 @@ const ( ) func CommandsOption(cctx commands.Context) ServeOption { - return func(n *core.IpfsNode, mux *http.ServeMux) error { + return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { origin := os.Getenv(originEnvKey) cmdHandler := cmdsHttp.NewHandler(cctx, corecommands.Root, origin) mux.Handle(cmdsHttp.ApiPath+"/", cmdHandler) - return nil + return mux, nil } } diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 104b6566f..4e5dce98b 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,11 +12,11 @@ import ( var log = eventlog.Logger("core/server") -const ( -// TODO rename -) - -type ServeOption func(*core.IpfsNode, *http.ServeMux) error +// ServeOption registers any HTTP handlers it provides on the given mux. +// It returns the mux to expose to future options, which may be a new mux if it +// is interested in mediating requests to future options, or the same mux +// initially passed in if not. +type ServeOption func(*core.IpfsNode, *http.ServeMux) (*http.ServeMux, error) // ListenAndServe runs an HTTP server listening at |listeningMultiAddr| with // the given serve options. The address must be provided in multiaddr format. @@ -29,13 +29,15 @@ func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...Serv if err != nil { return err } - mux := http.NewServeMux() + topMux := http.NewServeMux() + mux := topMux for _, option := range options { - if err := option(n, mux); err != nil { + mux, err = option(n, mux) + if err != nil { return err } } - return listenAndServe(n, addr, mux) + return listenAndServe(n, addr, topMux) } func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, mux *http.ServeMux) error { diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 9c20cd5a9..139c317b2 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -24,14 +24,14 @@ func NewGateway(conf GatewayConfig) *Gateway { } func (g *Gateway) ServeOption() ServeOption { - return func(n *core.IpfsNode, mux *http.ServeMux) error { + return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { gateway, err := newGatewayHandler(n, g.Config) if err != nil { - return err + return nil, err } mux.Handle("/ipfs/", gateway) mux.Handle("/ipns/", gateway) - return nil + return mux, nil } } @@ -47,8 +47,8 @@ func GatewayOption(writable bool) ServeOption { type Decider func(string) bool type BlockList struct { - mu sync.RWMutex - Decider Decider + mu sync.RWMutex + Decider Decider } func (b *BlockList) ShouldAllow(s string) bool { diff --git a/gateway/core/corehttp/redirect.go b/gateway/core/corehttp/redirect.go index 249d8801b..0048e1786 100644 --- a/gateway/core/corehttp/redirect.go +++ b/gateway/core/corehttp/redirect.go @@ -8,9 +8,9 @@ import ( func RedirectOption(path string, redirect string) ServeOption { handler := &redirectHandler{redirect} - return func(n *core.IpfsNode, mux *http.ServeMux) error { + return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { mux.Handle("/"+path, handler) - return nil + return mux, nil } } From ad480398af73ab0f0726580c81a0dc3c2f5542b3 Mon Sep 17 00:00:00 2001 From: Kevin Wallace Date: Mon, 2 Feb 2015 22:55:23 -0800 Subject: [PATCH 033/674] gateway: attempt to resolve hostname to ipfs path This allows someone to host a static site by pointing a TXT record at their content in IPFS, and a CNAME record at an IPFS gateway. Note that such a setup technically violates RFC1912 (section 2.4; "A CNAME record is not allowed to coexist with any other data."), but tends to work in practice. We may want to consider changing the DNS->IPFS resolution scheme to allow this scenario to be RFC-compliant (e.g. store the mapping on a well-known subdomain to allow CNAME records on the domain itself). License: MIT Signed-off-by: Kevin Wallace This commit was moved from ipfs/kubo@084cdc3ed842c84da357bf0ea441c9207c08c3ca --- gateway/core/corehttp/ipns_hostname.go | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 gateway/core/corehttp/ipns_hostname.go diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go new file mode 100644 index 000000000..27d683250 --- /dev/null +++ b/gateway/core/corehttp/ipns_hostname.go @@ -0,0 +1,29 @@ +package corehttp + +import ( + "net/http" + "strings" + + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" + "github.com/jbenet/go-ipfs/core" +) + +// IPNSHostnameOption rewrites an incoming request if its Host: header contains +// an IPNS name. +// The rewritten request points at the resolved name on the gateway handler. +func IPNSHostnameOption() ServeOption { + return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { + childMux := http.NewServeMux() + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + ctx, cancel := context.WithCancel(n.Context()) + defer cancel() + + host := strings.SplitN(r.Host, ":", 2)[0] + if k, err := n.Namesys.Resolve(ctx, host); err == nil { + r.URL.Path = "/ipfs/" + k.Pretty() + r.URL.Path + } + childMux.ServeHTTP(w, r) + }) + return childMux, nil + } +} From 78b28342086ae3f48ee37d78a3d532ec9446c55b Mon Sep 17 00:00:00 2001 From: Kevin Wallace Date: Sun, 8 Feb 2015 11:33:16 -0800 Subject: [PATCH 034/674] corehttp: tear off makeHandler, for tests License: MIT Signed-off-by: Kevin Wallace This commit was moved from ipfs/kubo@794b7b7b3e82168ed02600cf76669a05b6970729 --- gateway/core/corehttp/corehttp.go | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 4e5dce98b..6deac03ac 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -18,6 +18,21 @@ var log = eventlog.Logger("core/server") // initially passed in if not. type ServeOption func(*core.IpfsNode, *http.ServeMux) (*http.ServeMux, error) +// makeHandler turns a list of ServeOptions into a http.Handler that implements +// all of the given options, in order. +func makeHandler(n *core.IpfsNode, options ...ServeOption) (http.Handler, error) { + topMux := http.NewServeMux() + mux := topMux + for _, option := range options { + var err error + mux, err = option(n, mux) + if err != nil { + return nil, err + } + } + return topMux, nil +} + // ListenAndServe runs an HTTP server listening at |listeningMultiAddr| with // the given serve options. The address must be provided in multiaddr format. // @@ -29,18 +44,14 @@ func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...Serv if err != nil { return err } - topMux := http.NewServeMux() - mux := topMux - for _, option := range options { - mux, err = option(n, mux) - if err != nil { - return err - } + handler, err := makeHandler(n, options...) + if err != nil { + return err } - return listenAndServe(n, addr, topMux) + return listenAndServe(n, addr, handler) } -func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, mux *http.ServeMux) error { +func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler) error { _, host, err := manet.DialArgs(addr) if err != nil { return err @@ -53,7 +64,7 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, mux *http.ServeMux) serverExited := make(chan struct{}) go func() { - serverError = server.ListenAndServe(host, mux) + serverError = server.ListenAndServe(host, handler) close(serverExited) }() From ce2a5831c6e31872474cef6609ed560661f81c24 Mon Sep 17 00:00:00 2001 From: Kevin Wallace Date: Sun, 8 Feb 2015 12:49:21 -0800 Subject: [PATCH 035/674] corehttp: add test for gateway with mocked namesys License: MIT Signed-off-by: Kevin Wallace This commit was moved from ipfs/kubo@e5abf0764c9c178bbce1b1ba47ddd3efedc40066 --- gateway/core/corehttp/gateway_test.go | 125 ++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 gateway/core/corehttp/gateway_test.go diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go new file mode 100644 index 000000000..74bb3af92 --- /dev/null +++ b/gateway/core/corehttp/gateway_test.go @@ -0,0 +1,125 @@ +package corehttp + +import ( + "errors" + "fmt" + "io/ioutil" + "net/http" + "net/http/httptest" + "strings" + "testing" + + context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" + b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58" + core "github.com/jbenet/go-ipfs/core" + coreunix "github.com/jbenet/go-ipfs/core/coreunix" + namesys "github.com/jbenet/go-ipfs/namesys" + ci "github.com/jbenet/go-ipfs/p2p/crypto" + repo "github.com/jbenet/go-ipfs/repo" + config "github.com/jbenet/go-ipfs/repo/config" + u "github.com/jbenet/go-ipfs/util" + testutil "github.com/jbenet/go-ipfs/util/testutil" +) + +type mockNamesys map[string]string + +func (m mockNamesys) Resolve(ctx context.Context, name string) (value u.Key, err error) { + enc, ok := m[name] + if !ok { + return "", namesys.ErrResolveFailed + } + dec := b58.Decode(enc) + if len(dec) == 0 { + return "", fmt.Errorf("invalid b58 string for name %q: %q", name, enc) + } + return u.Key(dec), nil +} + +func (m mockNamesys) CanResolve(name string) bool { + _, ok := m[name] + return ok +} + +func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value u.Key) error { + return errors.New("not implemented for mockNamesys") +} + +func newNodeWithMockNamesys(t *testing.T, ns mockNamesys) *core.IpfsNode { + c := config.Config{ + Identity: config.Identity{ + PeerID: "Qmfoo", // required by offline node + }, + } + r := &repo.Mock{ + C: c, + D: testutil.ThreadSafeCloserMapDatastore(), + } + n, err := core.NewIPFSNode(context.Background(), core.Offline(r)) + if err != nil { + t.Fatal(err) + } + n.Namesys = ns + return n +} + +func TestGatewayGet(t *testing.T) { + ns := mockNamesys{} + n := newNodeWithMockNamesys(t, ns) + k, err := coreunix.Add(n, strings.NewReader("fnord")) + if err != nil { + t.Fatal(err) + } + ns["example.com"] = k + + h, err := makeHandler(n, + IPNSHostnameOption(), + GatewayOption(false), + ) + if err != nil { + t.Fatal(err) + } + + ts := httptest.NewServer(h) + defer ts.Close() + + for _, test := range []struct { + host string + path string + status int + text string + }{ + {"localhost:5001", "/", http.StatusNotFound, "404 page not found\n"}, + {"localhost:5001", "/" + k, http.StatusNotFound, "404 page not found\n"}, + {"localhost:5001", "/ipfs/" + k, http.StatusOK, "fnord"}, + {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusBadRequest, namesys.ErrResolveFailed.Error()}, + {"localhost:5001", "/ipns/example.com", http.StatusOK, "fnord"}, + {"example.com", "/", http.StatusOK, "fnord"}, + } { + var c http.Client + r, err := http.NewRequest("GET", ts.URL+test.path, nil) + if err != nil { + t.Fatal(err) + } + r.Host = test.host + resp, err := c.Do(r) + + urlstr := "http://" + test.host + test.path + if err != nil { + t.Errorf("error requesting %s: %s", urlstr, err) + continue + } + defer resp.Body.Close() + if resp.StatusCode != test.status { + t.Errorf("got %d, expected %d from %s", resp.StatusCode, test.status, urlstr) + continue + } + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + t.Fatalf("error reading response from %s: %s", urlstr, err) + } + if string(body) != test.text { + t.Errorf("unexpected response body from %s: expected %q; got %q", urlstr, test.text, body) + continue + } + } +} From 88c0e44b46460dae1eb009c3bdee9d468dde40c6 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Mon, 16 Feb 2015 04:34:20 -0800 Subject: [PATCH 036/674] new webui hash This commit was moved from ipfs/kubo@01feeac1bbaeb8768053e52b8402e7757d2c76cb --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 2bcb0d946..accb70b35 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmSHDxWsMPuJQKWmVA1rB5a3NX2Eme5fPqNb63qwaqiqSp" +const WebUIPath = "/ipfs/QmaaqrHyAQm7gALkRW8DcfGX3u8q9rWKnxEMmf7m9z515w" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/QmSHDxWsMPuJQKWmVA1rB5a3NX2Eme5fPqNb63qwaqiqSp", "/ipfs/QmctngrQAt9fjpQUZr7Bx3BsXUcif52eZGTizWhvcShsjz", } From 7fed7e6e2d4ef5c807690012c32a2eab22804613 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Mon, 16 Feb 2015 13:53:21 -0800 Subject: [PATCH 037/674] updated webui This commit was moved from ipfs/kubo@34e4d8c3a637fcceee1bfae83e266bdc23e8714e --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index accb70b35..aab17b316 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmaaqrHyAQm7gALkRW8DcfGX3u8q9rWKnxEMmf7m9z515w" +const WebUIPath = "/ipfs/QmXdu7HWdV6CUaUabd9q2ZeA4iHZLVyDRj3Gi4dsJsWjbr" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/QmaaqrHyAQm7gALkRW8DcfGX3u8q9rWKnxEMmf7m9z515w", "/ipfs/QmSHDxWsMPuJQKWmVA1rB5a3NX2Eme5fPqNb63qwaqiqSp", "/ipfs/QmctngrQAt9fjpQUZr7Bx3BsXUcif52eZGTizWhvcShsjz", } From 4df43098c13fe92c9bc4c014e5faa38d96fb19b4 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 20 Feb 2015 11:49:48 -0800 Subject: [PATCH 038/674] add version info endpoint to gateway This commit was moved from ipfs/kubo@69e09d40c56570f9eaad8692c0d125c60d598b18 --- gateway/core/corehttp/gateway.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 139c317b2..3535b5299 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -1,10 +1,12 @@ package corehttp import ( + "fmt" "net/http" "sync" core "github.com/jbenet/go-ipfs/core" + id "github.com/jbenet/go-ipfs/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway @@ -43,6 +45,16 @@ func GatewayOption(writable bool) ServeOption { return g.ServeOption() } +func VersionOption() ServeOption { + return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { + mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion) + fmt.Fprintf(w, "Protocol Version: %s\n", id.IpfsVersion) + }) + return mux, nil + } +} + // Decider decides whether to Allow string type Decider func(string) bool From ac5cde39f1f2bb967d470d821fadf7f900f7f6b0 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 23 Feb 2015 16:51:09 +0100 Subject: [PATCH 039/674] rewrote import paths of go.net/context to use golang.org/x/context - updated go-ctxgroup and goprocess ctxgroup: AddChildGroup was changed to AddChild. Used in two files: - p2p/net/mock/mock_net.go - routing/dht/dht.go - updated context from hg repo to git prev. commit in hg was ad01a6fcc8a19d3a4478c836895ffe883bd2ceab. (context: make parentCancelCtx iterative) represents commit 84f8955a887232b6308d79c68b8db44f64df455c in git repo - updated context to master (b6fdb7d8a4ccefede406f8fe0f017fb58265054c) Aaron Jacobs (2): net/context: Don't accept a context in the DoSomethingSlow example. context: Be clear that users must cancel the result of WithCancel. Andrew Gerrand (1): go.net: use golang.org/x/... import paths Bryan C. Mills (1): net/context: Don't leak goroutines in Done example. Damien Neil (1): context: fix removal of cancelled timer contexts from parent David Symonds (2): context: Fix WithValue example code. net: add import comments. Sameer Ajmani (1): context: fix TestAllocs to account for ints in interfaces This commit was moved from ipfs/kubo@92d08db7a587784be89c876c1532006a0c0b3773 --- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/ipns_hostname.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 4fcca2421..eceed8481 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" core "github.com/jbenet/go-ipfs/core" "github.com/jbenet/go-ipfs/importer" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 74bb3af92..879f72f20 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -9,8 +9,8 @@ import ( "strings" "testing" - context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58" + context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" core "github.com/jbenet/go-ipfs/core" coreunix "github.com/jbenet/go-ipfs/core/coreunix" namesys "github.com/jbenet/go-ipfs/namesys" diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 27d683250..29c947d91 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -4,7 +4,7 @@ import ( "net/http" "strings" - "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" "github.com/jbenet/go-ipfs/core" ) From 629b900a10d002b144f3cb4460339479bad9efc6 Mon Sep 17 00:00:00 2001 From: bbenshoof Date: Wed, 25 Feb 2015 09:18:40 -0500 Subject: [PATCH 040/674] fixing bug 812 This commit was moved from ipfs/kubo@ac5cfc566443172feec4abbc910e47088f657c94 --- gateway/core/corehttp/redirect.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/redirect.go b/gateway/core/corehttp/redirect.go index 0048e1786..4258d71f8 100644 --- a/gateway/core/corehttp/redirect.go +++ b/gateway/core/corehttp/redirect.go @@ -9,7 +9,7 @@ import ( func RedirectOption(path string, redirect string) ServeOption { handler := &redirectHandler{redirect} return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { - mux.Handle("/"+path, handler) + mux.Handle("/"+path+"/", handler) return mux, nil } } From a9357f83f5f7898da460e3c5789e69a6dbfed30b Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Mon, 2 Mar 2015 23:31:44 -0800 Subject: [PATCH 041/674] published new webui /ipfs/QmXX7YRpU7nNBKfw75VG7Y1c3GwpSAGHRev67XVPgZFv9R https://github.com/protocol/ipfs-webui/commit/ee74f75d0b30d59326a813fb4467c91190cb87a6 This commit was moved from ipfs/kubo@7bc1de4ec50b17cbe49668b028d368edbebaf59d --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index aab17b316..951fa0e70 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmXdu7HWdV6CUaUabd9q2ZeA4iHZLVyDRj3Gi4dsJsWjbr" +const WebUIPath = "/ipfs/QmXX7YRpU7nNBKfw75VG7Y1c3GwpSAGHRev67XVPgZFv9R" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/QmXdu7HWdV6CUaUabd9q2ZeA4iHZLVyDRj3Gi4dsJsWjbr", "/ipfs/QmaaqrHyAQm7gALkRW8DcfGX3u8q9rWKnxEMmf7m9z515w", "/ipfs/QmSHDxWsMPuJQKWmVA1rB5a3NX2Eme5fPqNb63qwaqiqSp", "/ipfs/QmctngrQAt9fjpQUZr7Bx3BsXUcif52eZGTizWhvcShsjz", From 170cba3cbf6808329f9747c4d7a51f36b8c63b9b Mon Sep 17 00:00:00 2001 From: Andy Leap Date: Mon, 16 Mar 2015 16:08:45 -0400 Subject: [PATCH 042/674] Fixes issue #924 This commit was moved from ipfs/kubo@89ca37d1d1a7c86638c3eb18ea20b2a3079333b5 --- gateway/core/corehttp/gateway_handler.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index eceed8481..18791a771 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -174,15 +174,7 @@ func (i *gatewayHandler) getHandler(w http.ResponseWriter, r *http.Request) { nd, p, err := i.ResolvePath(ctx, urlPath) if err != nil { - if err == routing.ErrNotFound { - w.WriteHeader(http.StatusNotFound) - } else if err == context.DeadlineExceeded { - w.WriteHeader(http.StatusRequestTimeout) - } else { - w.WriteHeader(http.StatusBadRequest) - } - - w.Write([]byte(err.Error())) + webError(w, "Path Resolve error", err, http.StatusBadRequest) return } From a380151978dad59513e4a8e2f3cfbb3187274d1c Mon Sep 17 00:00:00 2001 From: Andy Leap Date: Mon, 16 Mar 2015 16:27:34 -0400 Subject: [PATCH 043/674] Fixing test failure(issue with looking for exact text) This commit was moved from ipfs/kubo@512171aa98416a602461e6514d00f1db57a663a4 --- gateway/core/corehttp/gateway_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 879f72f20..7a0dbfa8b 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -91,7 +91,7 @@ func TestGatewayGet(t *testing.T) { {"localhost:5001", "/", http.StatusNotFound, "404 page not found\n"}, {"localhost:5001", "/" + k, http.StatusNotFound, "404 page not found\n"}, {"localhost:5001", "/ipfs/" + k, http.StatusOK, "fnord"}, - {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusBadRequest, namesys.ErrResolveFailed.Error()}, + {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusBadRequest, "Path Resolve error: " + namesys.ErrResolveFailed.Error()}, {"localhost:5001", "/ipns/example.com", http.StatusOK, "fnord"}, {"example.com", "/", http.StatusOK, "fnord"}, } { From 0aabd9d630fb5398f8b688c92938f5d0abb74c1b Mon Sep 17 00:00:00 2001 From: Ho-Sheng Hsiao Date: Mon, 30 Mar 2015 20:04:32 -0700 Subject: [PATCH 044/674] Reorged imports from jbenet/go-ipfs to ipfs/go-ipfs - Modified Godeps/Godeps.json by hand - [TEST] Updated welcome docs hash to sharness - [TEST] Updated contact doc - [TEST] disabled breaking test (t0080-repo refs local) This commit was moved from ipfs/kubo@bf22aeec0ad277a9933972521f693208a9f3256c --- gateway/core/corehttp/commands.go | 8 ++++---- gateway/core/corehttp/corehttp.go | 10 +++++----- gateway/core/corehttp/gateway.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 24 ++++++++++++------------ gateway/core/corehttp/gateway_test.go | 20 ++++++++++---------- gateway/core/corehttp/ipns_hostname.go | 4 ++-- gateway/core/corehttp/redirect.go | 2 +- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 6128ed717..f3e5c8a45 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -4,10 +4,10 @@ import ( "net/http" "os" - commands "github.com/jbenet/go-ipfs/commands" - cmdsHttp "github.com/jbenet/go-ipfs/commands/http" - core "github.com/jbenet/go-ipfs/core" - corecommands "github.com/jbenet/go-ipfs/core/commands" + commands "github.com/ipfs/go-ipfs/commands" + cmdsHttp "github.com/ipfs/go-ipfs/commands/http" + core "github.com/ipfs/go-ipfs/core" + corecommands "github.com/ipfs/go-ipfs/core/commands" ) const ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 6deac03ac..2c679eb1f 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -3,11 +3,11 @@ package corehttp import ( "net/http" - manners "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/braintree/manners" - ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" - manet "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" - core "github.com/jbenet/go-ipfs/core" - eventlog "github.com/jbenet/go-ipfs/thirdparty/eventlog" + manners "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/braintree/manners" + ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" + manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" + core "github.com/ipfs/go-ipfs/core" + eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" ) var log = eventlog.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 3535b5299..0a84178b8 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -5,8 +5,8 @@ import ( "net/http" "sync" - core "github.com/jbenet/go-ipfs/core" - id "github.com/jbenet/go-ipfs/p2p/protocol/identify" + core "github.com/ipfs/go-ipfs/core" + id "github.com/ipfs/go-ipfs/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 18791a771..6a493d037 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -9,18 +9,18 @@ import ( "strings" "time" - mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" - "github.com/jbenet/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" - - core "github.com/jbenet/go-ipfs/core" - "github.com/jbenet/go-ipfs/importer" - chunk "github.com/jbenet/go-ipfs/importer/chunk" - dag "github.com/jbenet/go-ipfs/merkledag" - path "github.com/jbenet/go-ipfs/path" - "github.com/jbenet/go-ipfs/routing" - ufs "github.com/jbenet/go-ipfs/unixfs" - uio "github.com/jbenet/go-ipfs/unixfs/io" - u "github.com/jbenet/go-ipfs/util" + mh "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" + + core "github.com/ipfs/go-ipfs/core" + "github.com/ipfs/go-ipfs/importer" + chunk "github.com/ipfs/go-ipfs/importer/chunk" + dag "github.com/ipfs/go-ipfs/merkledag" + path "github.com/ipfs/go-ipfs/path" + "github.com/ipfs/go-ipfs/routing" + ufs "github.com/ipfs/go-ipfs/unixfs" + uio "github.com/ipfs/go-ipfs/unixfs/io" + u "github.com/ipfs/go-ipfs/util" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 7a0dbfa8b..807876477 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -9,16 +9,16 @@ import ( "strings" "testing" - b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58" - context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" - core "github.com/jbenet/go-ipfs/core" - coreunix "github.com/jbenet/go-ipfs/core/coreunix" - namesys "github.com/jbenet/go-ipfs/namesys" - ci "github.com/jbenet/go-ipfs/p2p/crypto" - repo "github.com/jbenet/go-ipfs/repo" - config "github.com/jbenet/go-ipfs/repo/config" - u "github.com/jbenet/go-ipfs/util" - testutil "github.com/jbenet/go-ipfs/util/testutil" + b58 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58" + context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" + core "github.com/ipfs/go-ipfs/core" + coreunix "github.com/ipfs/go-ipfs/core/coreunix" + namesys "github.com/ipfs/go-ipfs/namesys" + ci "github.com/ipfs/go-ipfs/p2p/crypto" + repo "github.com/ipfs/go-ipfs/repo" + config "github.com/ipfs/go-ipfs/repo/config" + u "github.com/ipfs/go-ipfs/util" + testutil "github.com/ipfs/go-ipfs/util/testutil" ) type mockNamesys map[string]string diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 29c947d91..3d6c8d0c5 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -4,8 +4,8 @@ import ( "net/http" "strings" - "github.com/jbenet/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" - "github.com/jbenet/go-ipfs/core" + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" + "github.com/ipfs/go-ipfs/core" ) // IPNSHostnameOption rewrites an incoming request if its Host: header contains diff --git a/gateway/core/corehttp/redirect.go b/gateway/core/corehttp/redirect.go index 4258d71f8..67d6c0773 100644 --- a/gateway/core/corehttp/redirect.go +++ b/gateway/core/corehttp/redirect.go @@ -3,7 +3,7 @@ package corehttp import ( "net/http" - core "github.com/jbenet/go-ipfs/core" + core "github.com/ipfs/go-ipfs/core" ) func RedirectOption(path string, redirect string) ServeOption { From 768f5dfacf0d52dcefe7d0053e7e23fd0025a5da Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Sun, 12 Apr 2015 02:35:16 -0700 Subject: [PATCH 045/674] corehttp: added support for HEAD requests This commit adds HEAD support to the IPFS Gateway. Related: #840 This commit was moved from ipfs/kubo@3c1d78c67207eb23201438f9509386afdc5aad38 --- gateway/core/corehttp/gateway_handler.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 6a493d037..16a5c10cc 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -144,7 +144,12 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if r.Method == "GET" { - i.getHandler(w, r) + i.getOrHeadHandler(w, r) + return + } + + if r.Method == "HEAD" { + i.getOrHeadHandler(w, r) return } @@ -160,7 +165,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { log.Debug(errmsg) } -func (i *gatewayHandler) getHandler(w http.ResponseWriter, r *http.Request) { +func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) { ctx, cancel := context.WithCancel(i.node.Context()) defer cancel() @@ -244,8 +249,11 @@ func (i *gatewayHandler) getHandler(w http.ResponseWriter, r *http.Request) { return } defer dr.Close() + // write to request - io.Copy(w, dr) + if r.Method != "HEAD" { + io.Copy(w, dr) + } break } @@ -259,9 +267,12 @@ func (i *gatewayHandler) getHandler(w http.ResponseWriter, r *http.Request) { "listing": dirListing, "path": urlPath, } - if err := i.dirList.Execute(w, hndlr); err != nil { - internalWebError(w, err) - return + + if r.Method != "HEAD" { + if err := i.dirList.Execute(w, hndlr); err != nil { + internalWebError(w, err) + return + } } } } From 8db5cd5285cb693e3f579e18f0bf4a43d7eb7133 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 3 Apr 2015 17:40:03 -0700 Subject: [PATCH 046/674] fix for #1008 and other pinning fixes This commit adds a new set of sharness tests for pinning, and addresses bugs that were pointed out by said tests. test/sharness: added more pinning tests Pinning is currently broken. See issue #1051. This commit introduces a few more pinning tests. These are by no means exhaustive, but definitely surface the present problems going on. I believe these tests are correct, but not sure. Pushing them as failing so that pinning is fixed in this PR. make pinning and merkledag.Get take contexts improve 'add' commands usage of pinning FIXUP: fix 'pin lists look good' ipfs-pin-stat simple script to help check pinning This is a simple shell script to help check pinning. We ought to strive towards making adding commands this easy. The http api is great and powerful, but our setup right now gets in the way. Perhaps we can clean up that area. updated t0081-repo-pinning - fixed a couple bugs with the tests - made it a bit clearer (still a lot going on) - the remaining tests are correct and highlight a problem with pinning. Namely, that recursive pinning is buggy. At least: towards the end of the test, $HASH_DIR4 and $HASH_FILE4 should be pinned indirectly, but they're not. And thus get gc-ed out. There may be other problems too. cc @whyrusleeping fix grep params for context deadline check fix bugs in pin and pin tests check for block local before checking recursive pin This commit was moved from ipfs/kubo@0a6b880bee0117f657aedbbd24bfc07a2361e3da --- gateway/core/corehttp/gateway_handler.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 16a5c10cc..3947a78b6 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -352,7 +352,9 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } - rootnd, err := i.node.Resolver.DAG.Get(u.Key(h)) + tctx, cancel := context.WithTimeout(ctx, time.Minute) + defer cancel() + rootnd, err := i.node.Resolver.DAG.Get(tctx, u.Key(h)) if err != nil { webError(w, "Could not resolve root object", err, http.StatusBadRequest) return @@ -414,7 +416,9 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { return } - rootnd, err := i.node.Resolver.DAG.Get(u.Key(h)) + tctx, cancel := context.WithTimeout(ctx, time.Minute) + defer cancel() + rootnd, err := i.node.Resolver.DAG.Get(tctx, u.Key(h)) if err != nil { webError(w, "Could not resolve root object", err, http.StatusBadRequest) return From 64bf4fbe7a1060387ce9c23db7ac998327dc944d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 17 Apr 2015 18:45:58 +0200 Subject: [PATCH 047/674] corehttp: log when server takes a long time to shut down The server may stay alive for quite a while due to waiting on open connections to close before shutting down. We should find ways to terminate these connections in a more controlled manner, but in the meantime it's helpful to be able to see why a shutdown of the ipfs daemon is taking so long. This commit was moved from ipfs/kubo@cc830ff2eec6832ab7e8e0663fdeb469a49873f9 --- gateway/core/corehttp/corehttp.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 2c679eb1f..38e13a882 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -2,6 +2,7 @@ package corehttp import ( "net/http" + "time" manners "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/braintree/manners" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" @@ -76,7 +77,17 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler case <-node.Closing(): log.Infof("server at %s terminating...", addr) server.Shutdown <- true - <-serverExited // now, DO wait until server exit + + outer: + for { + // wait until server exits + select { + case <-serverExited: + break outer + case <-time.After(5 * time.Second): + log.Infof("waiting for server at %s to terminate...", addr) + } + } } log.Infof("server at %s terminated", addr) From 28cc4c25349783295d403e5e0149341a6c19e29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 17 Apr 2015 18:46:00 +0200 Subject: [PATCH 048/674] corehttp: ensure node closing/teardown waits for server termination When closing a node, the node itself only takes care of tearing down its own children. As corehttp sets up a server based on a node, it needs to also ensure that the server is accounted for when determining if the node has been fully closed. This commit was moved from ipfs/kubo@c9d308491004ae42dc7757c6f5176846410876de --- gateway/core/corehttp/corehttp.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 38e13a882..c03b75f86 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -64,6 +64,9 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler var serverError error serverExited := make(chan struct{}) + node.Children().Add(1) + defer node.Children().Done() + go func() { serverError = server.ListenAndServe(host, handler) close(serverExited) From 18838285622590975271baf081854e3fb9e264e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 17 Apr 2015 18:46:01 +0200 Subject: [PATCH 049/674] corehttp: disable HTTP keep-alive when shutting down server Once the server is asked to shut down, we stop accepting new connections, but the 'manners' graceful shutdown will wait for all existing connections closed to close before finishing. For keep-alive connections this will never happen unless the client detects that the server is shutting down through the ipfs API itself, and closes the connection in response. This is a problem e.g. with the webui's connections visualization, which polls the swarm/peers endpoint once a second, and never detects that the API server was shut down. We can mitigate this by telling the server to disable keep-alive, which will add a 'Connection: close' header to the next HTTP response on the connection. A well behaving client should then treat that correspondingly by closing the connection. Unfortunately this doesn't happen immediately in all cases, presumably depending on the keep-alive timeout of the browser that set up the connection, but it's at least a step in the right direction. This commit was moved from ipfs/kubo@6fe85496f5dcad75bdb2b72a187f6503397627e6 --- gateway/core/corehttp/corehttp.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index c03b75f86..ff9bac704 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -79,6 +79,10 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler // if node being closed before server exits, close server case <-node.Closing(): log.Infof("server at %s terminating...", addr) + + // make sure keep-alive connections do not keep the server running + server.InnerServer.SetKeepAlivesEnabled(false) + server.Shutdown <- true outer: From b39aba508554458307997d11b6f565d91a8f2859 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 17 Apr 2015 21:14:25 -0700 Subject: [PATCH 050/674] refactored ipns records to point to paths Also changed the ipns dns resolution to use the "dnslink" format This commit was moved from ipfs/kubo@3d80b9d27d2e568418d0c4401b0a949aedddf0d4 --- gateway/core/corehttp/gateway_handler.go | 4 ++-- gateway/core/corehttp/gateway_test.go | 22 +++++++++------------- gateway/core/corehttp/ipns_hostname.go | 2 +- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 3947a78b6..315591724 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -81,12 +81,12 @@ func (i *gatewayHandler) resolveNamePath(ctx context.Context, p string) (string, if strings.HasPrefix(p, IpnsPathPrefix) { elements := strings.Split(p[len(IpnsPathPrefix):], "/") hash := elements[0] - k, err := i.node.Namesys.Resolve(ctx, hash) + rp, err := i.node.Namesys.Resolve(ctx, hash) if err != nil { return "", err } - elements[0] = k.Pretty() + elements = append(rp.Segments(), elements[1:]...) p = gopath.Join(elements...) } if !strings.HasPrefix(p, IpfsPathPrefix) { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 807876477..818338c1c 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -2,37 +2,31 @@ package corehttp import ( "errors" - "fmt" "io/ioutil" "net/http" "net/http/httptest" "strings" "testing" - b58 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" core "github.com/ipfs/go-ipfs/core" coreunix "github.com/ipfs/go-ipfs/core/coreunix" namesys "github.com/ipfs/go-ipfs/namesys" ci "github.com/ipfs/go-ipfs/p2p/crypto" + path "github.com/ipfs/go-ipfs/path" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" - u "github.com/ipfs/go-ipfs/util" testutil "github.com/ipfs/go-ipfs/util/testutil" ) -type mockNamesys map[string]string +type mockNamesys map[string]path.Path -func (m mockNamesys) Resolve(ctx context.Context, name string) (value u.Key, err error) { - enc, ok := m[name] +func (m mockNamesys) Resolve(ctx context.Context, name string) (value path.Path, err error) { + p, ok := m[name] if !ok { return "", namesys.ErrResolveFailed } - dec := b58.Decode(enc) - if len(dec) == 0 { - return "", fmt.Errorf("invalid b58 string for name %q: %q", name, enc) - } - return u.Key(dec), nil + return p, nil } func (m mockNamesys) CanResolve(name string) bool { @@ -40,7 +34,7 @@ func (m mockNamesys) CanResolve(name string) bool { return ok } -func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value u.Key) error { +func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value path.Path) error { return errors.New("not implemented for mockNamesys") } @@ -63,13 +57,14 @@ func newNodeWithMockNamesys(t *testing.T, ns mockNamesys) *core.IpfsNode { } func TestGatewayGet(t *testing.T) { + t.Skip("not sure whats going on here") ns := mockNamesys{} n := newNodeWithMockNamesys(t, ns) k, err := coreunix.Add(n, strings.NewReader("fnord")) if err != nil { t.Fatal(err) } - ns["example.com"] = k + ns["example.com"] = path.FromString("/ipfs/" + k) h, err := makeHandler(n, IPNSHostnameOption(), @@ -82,6 +77,7 @@ func TestGatewayGet(t *testing.T) { ts := httptest.NewServer(h) defer ts.Close() + t.Log(ts.URL) for _, test := range []struct { host string path string diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 3d6c8d0c5..abfcf4a63 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -20,7 +20,7 @@ func IPNSHostnameOption() ServeOption { host := strings.SplitN(r.Host, ":", 2)[0] if k, err := n.Namesys.Resolve(ctx, host); err == nil { - r.URL.Path = "/ipfs/" + k.Pretty() + r.URL.Path + r.URL.Path = "/ipfs/" + k.String() + r.URL.Path } childMux.ServeHTTP(w, r) }) From 66a2982725cdc1936c692a568ac8a02954c3e590 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 19 Apr 2015 11:17:06 -0700 Subject: [PATCH 051/674] address comments from CR This commit was moved from ipfs/kubo@e3255f46e1461df9db0540d82a0b46f79cad1771 --- gateway/core/corehttp/ipns_hostname.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index abfcf4a63..7361001d1 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -19,8 +19,8 @@ func IPNSHostnameOption() ServeOption { defer cancel() host := strings.SplitN(r.Host, ":", 2)[0] - if k, err := n.Namesys.Resolve(ctx, host); err == nil { - r.URL.Path = "/ipfs/" + k.String() + r.URL.Path + if p, err := n.Namesys.Resolve(ctx, host); err == nil { + r.URL.Path = "/ipfs/" + p.String() + r.URL.Path } childMux.ServeHTTP(w, r) }) From a93de201e99adbbdd99ebc678cc0165d0853e5d9 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 2 May 2015 08:35:34 -0700 Subject: [PATCH 052/674] core/corehttp/corehttp: Add a package comment I'm not entirely clear on the role that this package is filling, but this description seems like a reasonable guess based on a quick skim through it's exported API. This commit was moved from ipfs/kubo@e02fc1ec6b351bae94df63ffc8280d9319abc0ca --- gateway/core/corehttp/corehttp.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index ff9bac704..e8852baaf 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -1,3 +1,7 @@ +/* +Package corehttp provides utilities for the webui, gateways, and other +high-level HTTP interfaces to IPFS. +*/ package corehttp import ( From 198de2bdea164499ca2c16f32944a6dbe7a033f3 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 1 May 2015 17:33:24 +0200 Subject: [PATCH 053/674] core: add context.Context param to core.Resolve() commands/object: remove objectData() and objectLinks() helpers resolver: added context parameters sharness: $HASH carried the \r from the http protocol with sharness: write curl output to individual files http gw: break PUT handler until PR#1191 This commit was moved from ipfs/kubo@f640ba00891489361947b49dd5ce05b3349f154a --- gateway/core/corehttp/gateway_handler.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 315591724..78795b636 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -1,6 +1,7 @@ package corehttp import ( + "errors" "fmt" "html/template" "io" @@ -101,7 +102,7 @@ func (i *gatewayHandler) ResolvePath(ctx context.Context, p string) (*dag.Node, return nil, "", err } - node, err := i.node.Resolver.ResolvePath(path.Path(p)) + node, err := i.node.Resolver.ResolvePath(ctx, path.Path(p)) if err != nil { return nil, "", err } @@ -309,6 +310,9 @@ func (i *gatewayHandler) putEmptyDirHandler(w http.ResponseWriter, r *http.Reque } func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { + // TODO(cryptix): will be resolved in PR#1191 + webErrorWithCode(w, "Sorry, PUT is bugged right now, closing request", errors.New("handler disabled"), http.StatusInternalServerError) + return urlPath := r.URL.Path pathext := urlPath[5:] var err error @@ -362,7 +366,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { // resolving path components into merkledag nodes. if a component does not // resolve, create empty directories (which will be linked and populated below.) - path_nodes, err := i.node.Resolver.ResolveLinks(rootnd, components[:len(components)-1]) + path_nodes, err := i.node.Resolver.ResolveLinks(tctx, rootnd, components[:len(components)-1]) if _, ok := err.(path.ErrNoLink); ok { // Create empty directories, links will be made further down the code for len(path_nodes) < len(components) { @@ -424,7 +428,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { return } - path_nodes, err := i.node.Resolver.ResolveLinks(rootnd, components[:len(components)-1]) + path_nodes, err := i.node.Resolver.ResolveLinks(tctx, rootnd, components[:len(components)-1]) if err != nil { webError(w, "Could not resolve parent object", err, http.StatusBadRequest) return From 25816ff162a6ed7c4447755efe2e47c06e0df4df Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 1 May 2015 16:32:40 +0200 Subject: [PATCH 054/674] http gw: remove unused interface This commit was moved from ipfs/kubo@e633250c3830b985d170e77c84e043c5914b0c61 --- gateway/core/corehttp/gateway_handler.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 78795b636..434b2ed80 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -29,13 +29,6 @@ const ( IpnsPathPrefix = "/ipns/" ) -type gateway interface { - ResolvePath(string) (*dag.Node, error) - NewDagFromReader(io.Reader) (*dag.Node, error) - AddNodeToDAG(nd *dag.Node) (u.Key, error) - NewDagReader(nd *dag.Node) (uio.ReadSeekCloser, error) -} - // shortcut for templating type webHandler map[string]interface{} From 9d8126862b43487dc80794cd5229125abd9ce4e1 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 3 May 2015 05:04:05 +0200 Subject: [PATCH 055/674] http gw: removed ResolvePath() in favour of core.Resolve() This commit was moved from ipfs/kubo@1502f6bc71ba8fa48fcc4d1959f405f038d04d9a --- gateway/core/corehttp/gateway_handler.go | 102 +++++++++-------------- 1 file changed, 39 insertions(+), 63 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 434b2ed80..ebc77f7f7 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -69,39 +69,8 @@ func (i *gatewayHandler) loadTemplate() error { return nil } -func (i *gatewayHandler) resolveNamePath(ctx context.Context, p string) (string, error) { - p = gopath.Clean(p) - - if strings.HasPrefix(p, IpnsPathPrefix) { - elements := strings.Split(p[len(IpnsPathPrefix):], "/") - hash := elements[0] - rp, err := i.node.Namesys.Resolve(ctx, hash) - if err != nil { - return "", err - } - - elements = append(rp.Segments(), elements[1:]...) - p = gopath.Join(elements...) - } - if !strings.HasPrefix(p, IpfsPathPrefix) { - p = gopath.Join(IpfsPathPrefix, p) - } - return p, nil -} - -func (i *gatewayHandler) ResolvePath(ctx context.Context, p string) (*dag.Node, string, error) { - p, err := i.resolveNamePath(ctx, p) - if err != nil { - return nil, "", err - } - - node, err := i.node.Resolver.ResolvePath(ctx, path.Path(p)) - if err != nil { - return nil, "", err - } - return node, p, err -} +// TODO(cryptix): these four helper funcs shoudl also be available elsewhere, i think? func (i *gatewayHandler) NewDagFromReader(r io.Reader) (*dag.Node, error) { return importer.BuildDagFromReader( r, i.node.DAG, i.node.Pinning.GetManual(), chunk.DefaultSplitter) @@ -119,30 +88,23 @@ func (i *gatewayHandler) NewDagReader(nd *dag.Node) (uio.ReadSeekCloser, error) return uio.NewDagReader(i.node.Context(), nd, i.node.DAG) } -// TODO(btc): break this apart into separate handlers using a more expressive -// muxer +// TODO(btc): break this apart into separate handlers using a more expressive muxer func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if i.config.Writable && r.Method == "POST" { - i.postHandler(w, r) - return - } - - if i.config.Writable && r.Method == "PUT" { - i.putHandler(w, r) - return - } - - if i.config.Writable && r.Method == "DELETE" { - i.deleteHandler(w, r) - return - } - - if r.Method == "GET" { - i.getOrHeadHandler(w, r) - return + if i.config.Writable { + switch r.Method { + case "POST": + i.postHandler(w, r) + return + case "PUT": + i.putHandler(w, r) + return + case "DELETE": + i.deleteHandler(w, r) + return + } } - if r.Method == "HEAD" { + if r.Method == "GET" || r.Method == "HEAD" { i.getOrHeadHandler(w, r) return } @@ -156,7 +118,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { errmsg = errmsg + "bad request for " + r.URL.Path } w.Write([]byte(errmsg)) - log.Debug(errmsg) + log.Error(errmsg) // TODO(cryptix): Why are we ignoring handler errors? } func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) { @@ -171,19 +133,19 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } - nd, p, err := i.ResolvePath(ctx, urlPath) + nd, err := core.Resolve(ctx, i.node, path.Path(urlPath)) if err != nil { webError(w, "Path Resolve error", err, http.StatusBadRequest) return } - etag := gopath.Base(p) + etag := gopath.Base(urlPath) if r.Header.Get("If-None-Match") == etag { w.WriteHeader(http.StatusNotModified) return } - w.Header().Set("X-IPFS-Path", p) + w.Header().Set("X-IPFS-Path", urlPath) // Suborigin header, sandboxes apps from each other in the browser (even // though they are served from the same gateway domain). NOTE: This is not @@ -232,7 +194,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request log.Debug("found index") foundIndex = true // return index page instead. - nd, _, err := i.ResolvePath(ctx, urlPath+"/index.html") + nd, err := core.Resolve(ctx, i.node, path.Path(urlPath+"/index.html")) if err != nil { internalWebError(w, err) return @@ -328,14 +290,20 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { ctx, cancel := context.WithCancel(i.node.Context()) defer cancel() - ipfspath, err := i.resolveNamePath(ctx, urlPath) + ipfsNode, err := core.Resolve(ctx, i.node, path.Path(urlPath)) if err != nil { // FIXME HTTP error code webError(w, "Could not resolve name", err, http.StatusInternalServerError) return } - h, components, err := path.SplitAbsPath(path.Path(ipfspath)) + k, err := ipfsNode.Key() + if err != nil { + webError(w, "Could not get key from resolved node", err, http.StatusInternalServerError) + return + } + + h, components, err := path.SplitAbsPath(path.FromKey(k)) if err != nil { webError(w, "Could not split path", err, http.StatusInternalServerError) return @@ -351,6 +319,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { tctx, cancel := context.WithTimeout(ctx, time.Minute) defer cancel() + // TODO(cryptix): could this be core.Resolve() too? rootnd, err := i.node.Resolver.DAG.Get(tctx, u.Key(h)) if err != nil { webError(w, "Could not resolve root object", err, http.StatusBadRequest) @@ -400,14 +369,20 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { ctx, cancel := context.WithCancel(i.node.Context()) defer cancel() - ipfspath, err := i.resolveNamePath(ctx, urlPath) + ipfsNode, err := core.Resolve(ctx, i.node, path.Path(urlPath)) if err != nil { // FIXME HTTP error code webError(w, "Could not resolve name", err, http.StatusInternalServerError) return } - h, components, err := path.SplitAbsPath(path.Path(ipfspath)) + k, err := ipfsNode.Key() + if err != nil { + webError(w, "Could not get key from resolved node", err, http.StatusInternalServerError) + return + } + + h, components, err := path.SplitAbsPath(path.FromKey(k)) if err != nil { webError(w, "Could not split path", err, http.StatusInternalServerError) return @@ -427,6 +402,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { return } + // TODO(cyrptix): assumes len(path_nodes) > 1 - not found is an error above? err = path_nodes[len(path_nodes)-1].RemoveNodeLink(components[len(components)-1]) if err != nil { webError(w, "Could not delete link", err, http.StatusBadRequest) @@ -481,7 +457,7 @@ func webErrorWithCode(w http.ResponseWriter, message string, err error, code int func internalWebError(w http.ResponseWriter, err error) { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte(err.Error())) - log.Debug("%s", err) + log.Error("%s", err) // TODO(cryptix): Why are we ignoring handler errors? } // Directory listing template From 6ed4c21cf354ac08f8ad5bf27239c95c4cf1747d Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 4 May 2015 13:39:30 +0200 Subject: [PATCH 056/674] http gw: some golinting and unexport unused symbols - NewDagReader() used the wrong context - Ip?sPathPrefix isn't used anywhere - a little bit of error handling cleanup This commit was moved from ipfs/kubo@96846358cc0d1ed383cfa829dd2178ebf2bc4c58 --- gateway/core/corehttp/gateway_handler.go | 83 ++++++++++-------------- 1 file changed, 35 insertions(+), 48 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ebc77f7f7..2999494b1 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -25,8 +25,8 @@ import ( ) const ( - IpfsPathPrefix = "/ipfs/" - IpnsPathPrefix = "/ipns/" + ipfsPathPrefix = "/ipfs/" + ipnsPathPrefix = "/ipns/" ) // shortcut for templating @@ -69,25 +69,16 @@ func (i *gatewayHandler) loadTemplate() error { return nil } - -// TODO(cryptix): these four helper funcs shoudl also be available elsewhere, i think? -func (i *gatewayHandler) NewDagFromReader(r io.Reader) (*dag.Node, error) { +// TODO(cryptix): find these helpers somewhere else +func (i *gatewayHandler) newDagFromReader(r io.Reader) (*dag.Node, error) { return importer.BuildDagFromReader( r, i.node.DAG, i.node.Pinning.GetManual(), chunk.DefaultSplitter) } -func NewDagEmptyDir() *dag.Node { +func newDagEmptyDir() *dag.Node { return &dag.Node{Data: ufs.FolderPBData()} } -func (i *gatewayHandler) AddNodeToDAG(nd *dag.Node) (u.Key, error) { - return i.node.DAG.Add(nd) -} - -func (i *gatewayHandler) NewDagReader(nd *dag.Node) (uio.ReadSeekCloser, error) { - return uio.NewDagReader(i.node.Context(), nd, i.node.DAG) -} - // TODO(btc): break this apart into separate handlers using a more expressive muxer func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if i.config.Writable { @@ -117,8 +108,8 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusBadRequest) errmsg = errmsg + "bad request for " + r.URL.Path } - w.Write([]byte(errmsg)) - log.Error(errmsg) // TODO(cryptix): Why are we ignoring handler errors? + fmt.Fprint(w, errmsg) + log.Error(errmsg) // TODO(cryptix): log errors until we have a better way to expose these (counter metrics maybe) } func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) { @@ -153,7 +144,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request pathRoot := strings.SplitN(urlPath, "/", 4)[2] w.Header().Set("Suborigin", pathRoot) - dr, err := i.NewDagReader(nd) + dr, err := uio.NewDagReader(ctx, nd, i.node.DAG) if err != nil && err != uio.ErrIsDir { // not a directory and still an error internalWebError(w, err) @@ -165,7 +156,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // and only if it's /ipfs! // TODO: break this out when we split /ipfs /ipns routes. modtime := time.Now() - if strings.HasPrefix(urlPath, IpfsPathPrefix) { + if strings.HasPrefix(urlPath, ipfsPathPrefix) { w.Header().Set("Etag", etag) w.Header().Set("Cache-Control", "public, max-age=29030400") @@ -199,7 +190,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request internalWebError(w, err) return } - dr, err := i.NewDagReader(nd) + dr, err := uio.NewDagReader(ctx, nd, i.node.DAG) if err != nil { internalWebError(w, err) return @@ -234,13 +225,13 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { - nd, err := i.NewDagFromReader(r.Body) + nd, err := i.newDagFromReader(r.Body) if err != nil { internalWebError(w, err) return } - k, err := i.AddNodeToDAG(nd) + k, err := i.node.DAG.Add(nd) if err != nil { internalWebError(w, err) return @@ -248,11 +239,11 @@ func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { h := mh.Multihash(k).B58String() w.Header().Set("IPFS-Hash", h) - http.Redirect(w, r, IpfsPathPrefix+h, http.StatusCreated) + http.Redirect(w, r, ipfsPathPrefix+h, http.StatusCreated) } func (i *gatewayHandler) putEmptyDirHandler(w http.ResponseWriter, r *http.Request) { - newnode := NewDagEmptyDir() + newnode := newDagEmptyDir() key, err := i.node.DAG.Add(newnode) if err != nil { @@ -261,7 +252,7 @@ func (i *gatewayHandler) putEmptyDirHandler(w http.ResponseWriter, r *http.Reque } w.Header().Set("IPFS-Hash", key.String()) - http.Redirect(w, r, IpfsPathPrefix+key.String()+"/", http.StatusCreated) + http.Redirect(w, r, ipfsPathPrefix+key.String()+"/", http.StatusCreated) } func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { @@ -271,16 +262,16 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { urlPath := r.URL.Path pathext := urlPath[5:] var err error - if urlPath == IpfsPathPrefix+"QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/" { + if urlPath == ipfsPathPrefix+"QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/" { i.putEmptyDirHandler(w, r) return } var newnode *dag.Node if pathext[len(pathext)-1] == '/' { - newnode = NewDagEmptyDir() + newnode = newDagEmptyDir() } else { - newnode, err = i.NewDagFromReader(r.Body) + newnode, err = i.newDagFromReader(r.Body) if err != nil { webError(w, "Could not create DAG from request", err, http.StatusInternalServerError) return @@ -311,9 +302,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { if len(components) < 1 { err = fmt.Errorf("Cannot override existing object") - w.WriteHeader(http.StatusBadRequest) - w.Write([]byte(err.Error())) - log.Debug("%s", err) + webError(w, "http gateway", err, http.StatusBadRequest) return } @@ -328,19 +317,19 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { // resolving path components into merkledag nodes. if a component does not // resolve, create empty directories (which will be linked and populated below.) - path_nodes, err := i.node.Resolver.ResolveLinks(tctx, rootnd, components[:len(components)-1]) + pathNodes, err := i.node.Resolver.ResolveLinks(tctx, rootnd, components[:len(components)-1]) if _, ok := err.(path.ErrNoLink); ok { // Create empty directories, links will be made further down the code - for len(path_nodes) < len(components) { - path_nodes = append(path_nodes, NewDagEmptyDir()) + for len(pathNodes) < len(components) { + pathNodes = append(pathNodes, newDagEmptyDir()) } } else if err != nil { webError(w, "Could not resolve parent object", err, http.StatusBadRequest) return } - for i := len(path_nodes) - 1; i >= 0; i-- { - newnode, err = path_nodes[i].UpdateNodeLink(components[i], newnode) + for i := len(pathNodes) - 1; i >= 0; i-- { + newnode, err = pathNodes[i].UpdateNodeLink(components[i], newnode) if err != nil { webError(w, "Could not update node links", err, http.StatusInternalServerError) return @@ -361,7 +350,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { } w.Header().Set("IPFS-Hash", key.String()) - http.Redirect(w, r, IpfsPathPrefix+key.String()+"/"+strings.Join(components, "/"), http.StatusCreated) + http.Redirect(w, r, ipfsPathPrefix+key.String()+"/"+strings.Join(components, "/"), http.StatusCreated) } func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { @@ -396,22 +385,22 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { return } - path_nodes, err := i.node.Resolver.ResolveLinks(tctx, rootnd, components[:len(components)-1]) + pathNodes, err := i.node.Resolver.ResolveLinks(tctx, rootnd, components[:len(components)-1]) if err != nil { webError(w, "Could not resolve parent object", err, http.StatusBadRequest) return } - // TODO(cyrptix): assumes len(path_nodes) > 1 - not found is an error above? - err = path_nodes[len(path_nodes)-1].RemoveNodeLink(components[len(components)-1]) + // TODO(cyrptix): assumes len(pathNodes) > 1 - not found is an error above? + err = pathNodes[len(pathNodes)-1].RemoveNodeLink(components[len(components)-1]) if err != nil { webError(w, "Could not delete link", err, http.StatusBadRequest) return } - newnode := path_nodes[len(path_nodes)-1] - for i := len(path_nodes) - 2; i >= 0; i-- { - newnode, err = path_nodes[i].UpdateNodeLink(components[i], newnode) + newnode := pathNodes[len(pathNodes)-1] + for i := len(pathNodes) - 2; i >= 0; i-- { + newnode, err = pathNodes[i].UpdateNodeLink(components[i], newnode) if err != nil { webError(w, "Could not update node links", err, http.StatusInternalServerError) return @@ -432,7 +421,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { } w.Header().Set("IPFS-Hash", key.String()) - http.Redirect(w, r, IpfsPathPrefix+key.String()+"/"+strings.Join(components[:len(components)-1], "/"), http.StatusCreated) + http.Redirect(w, r, ipfsPathPrefix+key.String()+"/"+strings.Join(components[:len(components)-1], "/"), http.StatusCreated) } func webError(w http.ResponseWriter, message string, err error, defaultCode int) { @@ -449,15 +438,13 @@ func webError(w http.ResponseWriter, message string, err error, defaultCode int) func webErrorWithCode(w http.ResponseWriter, message string, err error, code int) { w.WriteHeader(code) - log.Debugf("%s: %s", message, err) - w.Write([]byte(message + ": " + err.Error())) + log.Errorf("%s: %s", message, err) // TODO(cryptix): log errors until we have a better way to expose these (counter metrics maybe) + fmt.Fprintf(w, "%s: %s", message, err) } // return a 500 error and log func internalWebError(w http.ResponseWriter, err error) { - w.WriteHeader(http.StatusInternalServerError) - w.Write([]byte(err.Error())) - log.Error("%s", err) // TODO(cryptix): Why are we ignoring handler errors? + webErrorWithCode(w, "internalWebError", err, http.StatusInternalServerError) } // Directory listing template From 16bccd3dedfc9117f09c309cae196aeb23fd0eef Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 4 May 2015 14:02:04 +0200 Subject: [PATCH 057/674] http gw: remove newDagEmptyDir helper This commit was moved from ipfs/kubo@31b83abfe4d12b89229d2d0610cd0731ff5f5653 --- gateway/core/corehttp/gateway_handler.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 2999494b1..31ead9239 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -19,7 +19,6 @@ import ( dag "github.com/ipfs/go-ipfs/merkledag" path "github.com/ipfs/go-ipfs/path" "github.com/ipfs/go-ipfs/routing" - ufs "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" u "github.com/ipfs/go-ipfs/util" ) @@ -71,14 +70,12 @@ func (i *gatewayHandler) loadTemplate() error { // TODO(cryptix): find these helpers somewhere else func (i *gatewayHandler) newDagFromReader(r io.Reader) (*dag.Node, error) { + // TODO(cryptix): change and remove this helper once PR1136 is merged + // return ufs.AddFromReader(i.node, r.Body) return importer.BuildDagFromReader( r, i.node.DAG, i.node.Pinning.GetManual(), chunk.DefaultSplitter) } -func newDagEmptyDir() *dag.Node { - return &dag.Node{Data: ufs.FolderPBData()} -} - // TODO(btc): break this apart into separate handlers using a more expressive muxer func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if i.config.Writable { @@ -243,7 +240,7 @@ func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { } func (i *gatewayHandler) putEmptyDirHandler(w http.ResponseWriter, r *http.Request) { - newnode := newDagEmptyDir() + newnode := uio.NewDirectory(i.node.DAG).GetNode() key, err := i.node.DAG.Add(newnode) if err != nil { @@ -269,7 +266,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { var newnode *dag.Node if pathext[len(pathext)-1] == '/' { - newnode = newDagEmptyDir() + newnode = uio.NewDirectory(i.node.DAG).GetNode() } else { newnode, err = i.newDagFromReader(r.Body) if err != nil { @@ -321,7 +318,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { if _, ok := err.(path.ErrNoLink); ok { // Create empty directories, links will be made further down the code for len(pathNodes) < len(components) { - pathNodes = append(pathNodes, newDagEmptyDir()) + pathNodes = append(pathNodes, uio.NewDirectory(i.node.DAG).GetNode()) } } else if err != nil { webError(w, "Could not resolve parent object", err, http.StatusBadRequest) From e198237144b6ea16f692d7434009f12d38387e92 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 9 May 2015 11:49:02 +0200 Subject: [PATCH 058/674] unixfs/io: added NewEmptyDirectory() some golinting along the way This commit was moved from ipfs/kubo@87ce7abe47a8fa24a23f01e71fd172cd2f05d1d5 --- gateway/core/corehttp/gateway_handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 31ead9239..8a28e3093 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -240,7 +240,7 @@ func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { } func (i *gatewayHandler) putEmptyDirHandler(w http.ResponseWriter, r *http.Request) { - newnode := uio.NewDirectory(i.node.DAG).GetNode() + newnode := uio.NewEmptyDirectory() key, err := i.node.DAG.Add(newnode) if err != nil { @@ -266,7 +266,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { var newnode *dag.Node if pathext[len(pathext)-1] == '/' { - newnode = uio.NewDirectory(i.node.DAG).GetNode() + newnode = uio.NewEmptyDirectory() } else { newnode, err = i.newDagFromReader(r.Body) if err != nil { From 05740b4f4f33dfddef962c5974cb0eeb4e2dfd89 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 9 May 2015 11:21:35 +0200 Subject: [PATCH 059/674] http gw: disable PUT and writable tests - again... :( This commit was moved from ipfs/kubo@4537311f59ceff8688bd8b27e128893c6261a7be --- gateway/core/corehttp/gateway_handler.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 8a28e3093..efc35c445 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -10,7 +10,6 @@ import ( "strings" "time" - mh "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" core "github.com/ipfs/go-ipfs/core" @@ -234,9 +233,8 @@ func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { return } - h := mh.Multihash(k).B58String() - w.Header().Set("IPFS-Hash", h) - http.Redirect(w, r, ipfsPathPrefix+h, http.StatusCreated) + w.Header().Set("IPFS-Hash", k.String()) + http.Redirect(w, r, ipfsPathPrefix+k.String(), http.StatusCreated) } func (i *gatewayHandler) putEmptyDirHandler(w http.ResponseWriter, r *http.Request) { @@ -253,7 +251,7 @@ func (i *gatewayHandler) putEmptyDirHandler(w http.ResponseWriter, r *http.Reque } func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { - // TODO(cryptix): will be resolved in PR#1191 + // TODO(cryptix): either ask mildred about the flow of this or rewrite it webErrorWithCode(w, "Sorry, PUT is bugged right now, closing request", errors.New("handler disabled"), http.StatusInternalServerError) return urlPath := r.URL.Path From cd09dad3eef3d640f4fd77c8cd103ba4aba4d332 Mon Sep 17 00:00:00 2001 From: Vijayee Kulkaa Date: Mon, 18 May 2015 09:27:00 -0400 Subject: [PATCH 060/674] removed braintree/manners This commit was moved from ipfs/kubo@fcb8be5607a1c0bae6e88b0b437284169595e65d --- gateway/core/corehttp/corehttp.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index e8852baaf..9947430d1 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -8,7 +8,6 @@ import ( "net/http" "time" - manners "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/braintree/manners" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" core "github.com/ipfs/go-ipfs/core" @@ -62,7 +61,7 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler return err } - server := manners.NewServer() + server := &http.Server{Addr: host, Handler: handler} // if the server exits beforehand var serverError error @@ -72,7 +71,7 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler defer node.Children().Done() go func() { - serverError = server.ListenAndServe(host, handler) + serverError = server.ListenAndServe() close(serverExited) }() @@ -85,9 +84,7 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler log.Infof("server at %s terminating...", addr) // make sure keep-alive connections do not keep the server running - server.InnerServer.SetKeepAlivesEnabled(false) - - server.Shutdown <- true + server.SetKeepAlivesEnabled(false) outer: for { From 67ad08e2f4de4e826c2b0e36127bece20760ec48 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 7 May 2015 14:31:14 -0700 Subject: [PATCH 061/674] namesys: Add recursive resolution This allows direct access to the earlier protocol-specific Resolve implementations. The guts of each protocol-specific resolver are in the internal resolveOnce method, and we've added a new: ResolveN(ctx, name, depth) method to the public interface. There's also: Resolve(ctx, name) which wraps ResolveN using DefaultDepthLimit. The extra API endpoint is intended to reduce the likelyhood of clients accidentally calling the more dangerous ResolveN with a nonsensically high or infinite depth. On IRC on 2015-05-17, Juan said: 15:34 If 90% of uses is the reduced API with no chance to screw it up, that's a huge win. 15:34 Why would those 90% not just set depth=0 or depth=1, depending on which they need? 15:34 Because people will start writing `r.Resolve(ctx, name, d)` where d is a variable. 15:35 And then accidentally set that variable to some huge number? 15:35 Grom experience, i've seen this happen _dozens_ of times. people screw trivial things up. 15:35 Why won't those same people be using ResolveN? 15:36 Because almost every example they see will tell them to use Resolve(), and they will mostly stay away from ResolveN. The per-prodocol versions also resolve recursively within their protocol. For example: DNSResolver.Resolve(ctx, "ipfs.io", 0) will recursively resolve DNS links until the referenced value is no longer a DNS link. I also renamed the multi-protocol ipfs NameSystem (defined in namesys/namesys.go) to 'mpns' (for Multi-Protocol Name System), because I wasn't clear on whether IPNS applied to the whole system or just to to the DHT-based system. The new name is unambiguously multi-protocol, which is good. It would be nice to have a distinct name for the DHT-based link system. Now that resolver output is always prefixed with a namespace and unprefixed mpns resolver input is interpreted as /ipfs/, core/corehttp/ipns_hostname.go can dispense with it's old manual /ipfs/ injection. Now that the Resolver interface handles recursion, we don't need the resolveRecurse helper in core/pathresolver.go. The pathresolver cleanup also called for an adjustment to FromSegments to more easily get slash-prefixed paths. Now that recursive resolution with the namesys/namesys.go composite resolver always gets you to an /ipfs/... path, there's no need for the /ipns/ special case in fuse/ipns/ipns_unix.go. Now that DNS links can be things other than /ipfs/ or DHT-link references (e.g. they could be /ipns/ references) I've also loosened the ParsePath logic to only attempt multihash validation on IPFS paths. It checks to ensure that other paths have a known-protocol prefix, but otherwise leaves them alone. I also changed some key-stringification from .Pretty() to .String() following the potential deprecation mentioned in util/key.go. This commit was moved from ipfs/kubo@3ead2443e5cd55ef551b811ac0a6764ed65c3ec1 --- gateway/core/corehttp/gateway_test.go | 9 ++++----- gateway/core/corehttp/ipns_hostname.go | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 818338c1c..01d4295b7 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -22,6 +22,10 @@ import ( type mockNamesys map[string]path.Path func (m mockNamesys) Resolve(ctx context.Context, name string) (value path.Path, err error) { + return m.ResolveN(ctx, name, namesys.DefaultDepthLimit) +} + +func (m mockNamesys) ResolveN(ctx context.Context, name string, depth int) (value path.Path, err error) { p, ok := m[name] if !ok { return "", namesys.ErrResolveFailed @@ -29,11 +33,6 @@ func (m mockNamesys) Resolve(ctx context.Context, name string) (value path.Path, return p, nil } -func (m mockNamesys) CanResolve(name string) bool { - _, ok := m[name] - return ok -} - func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value path.Path) error { return errors.New("not implemented for mockNamesys") } diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 7361001d1..a6e8e91f5 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -20,7 +20,7 @@ func IPNSHostnameOption() ServeOption { host := strings.SplitN(r.Host, ":", 2)[0] if p, err := n.Namesys.Resolve(ctx, host); err == nil { - r.URL.Path = "/ipfs/" + p.String() + r.URL.Path + r.URL.Path = p.String() + r.URL.Path } childMux.ServeHTTP(w, r) }) From cd28920aeb118f550b15c9aaa1b5239abfe12bf0 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 16 May 2015 15:12:24 +0200 Subject: [PATCH 062/674] Fix: Using the `dnslink` feature led to infinite redirects fixes #1233 This commit was moved from ipfs/kubo@1b3797474f4f5a8a9be533da8c7eca2372d2befe --- gateway/core/corehttp/ipns_hostname.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index a6e8e91f5..f651cc60f 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -2,6 +2,7 @@ package corehttp import ( "net/http" + "path" "strings" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" @@ -20,7 +21,7 @@ func IPNSHostnameOption() ServeOption { host := strings.SplitN(r.Host, ":", 2)[0] if p, err := n.Namesys.Resolve(ctx, host); err == nil { - r.URL.Path = p.String() + r.URL.Path + r.URL.Path = path.Join(p.String(), r.URL.Path) } childMux.ServeHTTP(w, r) }) From a5e87ae5ff45b6a2f6a085be675fdce140cb541b Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 20 May 2015 22:42:54 -0700 Subject: [PATCH 063/674] do http server properly so daemon can shut down This commit was moved from ipfs/kubo@f6fadc4c91407f39e1cc4f12f5c9424794c04b90 --- gateway/core/corehttp/corehttp.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 9947430d1..18afa30e5 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -5,6 +5,7 @@ high-level HTTP interfaces to IPFS. package corehttp import ( + "net" "net/http" "time" @@ -56,12 +57,15 @@ func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...Serv } func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler) error { - _, host, err := manet.DialArgs(addr) + netarg, host, err := manet.DialArgs(addr) if err != nil { return err } - server := &http.Server{Addr: host, Handler: handler} + list, err := net.Listen(netarg, host) + if err != nil { + return err + } // if the server exits beforehand var serverError error @@ -71,7 +75,7 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler defer node.Children().Done() go func() { - serverError = server.ListenAndServe() + serverError = http.Serve(list, handler) close(serverExited) }() @@ -83,14 +87,15 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler case <-node.Closing(): log.Infof("server at %s terminating...", addr) - // make sure keep-alive connections do not keep the server running - server.SetKeepAlivesEnabled(false) + list.Close() outer: for { // wait until server exits select { case <-serverExited: + // if the server exited as we are closing, we really dont care about errors + serverError = nil break outer case <-time.After(5 * time.Second): log.Infof("waiting for server at %s to terminate...", addr) From ecec4ae0d33145333117056f36b987dc6cc9c7fc Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 21 May 2015 08:44:17 +0200 Subject: [PATCH 064/674] Fix: dnslink domain resolving was broken; Add: no caching for those fixes #1234 fixes #1267 This commit was moved from ipfs/kubo@373260d373c4066fa89ae60209f80e1fac92800c --- gateway/core/corehttp/ipns_hostname.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index f651cc60f..a7631c5a4 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -5,6 +5,7 @@ import ( "path" "strings" + isd "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-is-domain" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" "github.com/ipfs/go-ipfs/core" ) @@ -20,8 +21,11 @@ func IPNSHostnameOption() ServeOption { defer cancel() host := strings.SplitN(r.Host, ":", 2)[0] - if p, err := n.Namesys.Resolve(ctx, host); err == nil { - r.URL.Path = path.Join(p.String(), r.URL.Path) + if len(host) > 0 && isd.IsDomain(host) { + name := "/ipns/" + host + if _, err := n.Namesys.Resolve(ctx, name); err == nil { + r.URL.Path = path.Join("/ipns/", host) + r.URL.Path + } } childMux.ServeHTTP(w, r) }) From ff2f3c432e5259249d5207e747916932a68ee9a0 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 21 May 2015 08:51:18 +0200 Subject: [PATCH 065/674] removed requirement of path package This commit was moved from ipfs/kubo@8df8737f6aea0d407db13b30a3b108549a356462 --- gateway/core/corehttp/ipns_hostname.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index a7631c5a4..6f31e5268 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -2,7 +2,6 @@ package corehttp import ( "net/http" - "path" "strings" isd "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-is-domain" @@ -24,7 +23,7 @@ func IPNSHostnameOption() ServeOption { if len(host) > 0 && isd.IsDomain(host) { name := "/ipns/" + host if _, err := n.Namesys.Resolve(ctx, name); err == nil { - r.URL.Path = path.Join("/ipns/", host) + r.URL.Path + r.URL.Path = name + r.URL.Path } } childMux.ServeHTTP(w, r) From 87e04e13a568cdf563bec8b4a38503d7def7c200 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 19 May 2015 08:52:30 -0700 Subject: [PATCH 066/674] change pinning to happen in a callback This commit was moved from ipfs/kubo@dd928a2b1d9bfde65653d3053aef53249fd8a164 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index efc35c445..4fc84dbc5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -72,7 +72,7 @@ func (i *gatewayHandler) newDagFromReader(r io.Reader) (*dag.Node, error) { // TODO(cryptix): change and remove this helper once PR1136 is merged // return ufs.AddFromReader(i.node, r.Body) return importer.BuildDagFromReader( - r, i.node.DAG, i.node.Pinning.GetManual(), chunk.DefaultSplitter) + r, i.node.DAG, chunk.DefaultSplitter, importer.BasicPinnerCB(i.node.Pinning.GetManual())) } // TODO(btc): break this apart into separate handlers using a more expressive muxer From bd01c3bf6d690687b8a9bb15caf7856141cd4cf7 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Mon, 1 Jun 2015 00:37:02 -0700 Subject: [PATCH 067/674] updated webui to 0.2.0 This commit was moved from ipfs/kubo@e9fec3d5ee1d595017d9d0133a8e3d5a55edb630 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 951fa0e70..a125b4331 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmXX7YRpU7nNBKfw75VG7Y1c3GwpSAGHRev67XVPgZFv9R" +const WebUIPath = "/ipfs/QmS2HL9v5YeKgQkkWMvs1EMnFtUowTEdFfSSeMT4pos1e6" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/QmXX7YRpU7nNBKfw75VG7Y1c3GwpSAGHRev67XVPgZFv9R", "/ipfs/QmXdu7HWdV6CUaUabd9q2ZeA4iHZLVyDRj3Gi4dsJsWjbr", "/ipfs/QmaaqrHyAQm7gALkRW8DcfGX3u8q9rWKnxEMmf7m9z515w", "/ipfs/QmSHDxWsMPuJQKWmVA1rB5a3NX2Eme5fPqNb63qwaqiqSp", From 3da991d4193eb51cf69bc39e0ba1780458f45443 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 1 Jun 2015 16:10:08 -0700 Subject: [PATCH 068/674] move util.Key into its own package under blocks This commit was moved from ipfs/kubo@ef294431d4497433f69a77dc4981c1e5e575a07e --- gateway/core/corehttp/gateway_handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 4fc84dbc5..9b66cd13a 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -12,6 +12,7 @@ import ( "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" + key "github.com/ipfs/go-ipfs/blocks/key" core "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/importer" chunk "github.com/ipfs/go-ipfs/importer/chunk" @@ -19,7 +20,6 @@ import ( path "github.com/ipfs/go-ipfs/path" "github.com/ipfs/go-ipfs/routing" uio "github.com/ipfs/go-ipfs/unixfs/io" - u "github.com/ipfs/go-ipfs/util" ) const ( @@ -304,7 +304,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { tctx, cancel := context.WithTimeout(ctx, time.Minute) defer cancel() // TODO(cryptix): could this be core.Resolve() too? - rootnd, err := i.node.Resolver.DAG.Get(tctx, u.Key(h)) + rootnd, err := i.node.Resolver.DAG.Get(tctx, key.Key(h)) if err != nil { webError(w, "Could not resolve root object", err, http.StatusBadRequest) return @@ -374,7 +374,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { tctx, cancel := context.WithTimeout(ctx, time.Minute) defer cancel() - rootnd, err := i.node.Resolver.DAG.Get(tctx, u.Key(h)) + rootnd, err := i.node.Resolver.DAG.Get(tctx, key.Key(h)) if err != nil { webError(w, "Could not resolve root object", err, http.StatusBadRequest) return From 18adce78e670d7c4ceca7aba0c909fa0264d7ac1 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 24 May 2015 00:48:23 +0200 Subject: [PATCH 069/674] http endpoints: dont print before listen also splits api, gw and fuse bring up into helper functions This commit was moved from ipfs/kubo@07b3415cdbc4c82cf2204bcb1df28ec65f46cb1e --- gateway/core/corehttp/corehttp.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 18afa30e5..95a159fa2 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -5,6 +5,7 @@ high-level HTTP interfaces to IPFS. package corehttp import ( + "fmt" "net" "net/http" "time" @@ -49,20 +50,26 @@ func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...Serv if err != nil { return err } - handler, err := makeHandler(n, options...) + + list, err := manet.Listen(addr) if err != nil { return err } - return listenAndServe(n, addr, handler) + + // we might have listened to /tcp/0 - lets see what we are listing on + addr = list.Multiaddr() + fmt.Printf("API server listening on %s\n", addr) + + return Serve(n, list.NetListener(), options...) } -func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler) error { - netarg, host, err := manet.DialArgs(addr) +func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error { + handler, err := makeHandler(node, options...) if err != nil { return err } - list, err := net.Listen(netarg, host) + addr, err := manet.FromNetAddr(lis.Addr()) if err != nil { return err } @@ -75,7 +82,7 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler defer node.Children().Done() go func() { - serverError = http.Serve(list, handler) + serverError = http.Serve(lis, handler) close(serverExited) }() @@ -87,7 +94,7 @@ func listenAndServe(node *core.IpfsNode, addr ma.Multiaddr, handler http.Handler case <-node.Closing(): log.Infof("server at %s terminating...", addr) - list.Close() + lis.Close() outer: for { From f30179fe9bbba9256c7ff9ecdafadc47dc8c1cd5 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 16 Jun 2015 19:45:53 -0700 Subject: [PATCH 070/674] move eventlogs to an http endpoint License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@a676b5a8ac2848a57318283f4b2b52d7d8686323 --- gateway/core/corehttp/logs.go | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 gateway/core/corehttp/logs.go diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go new file mode 100644 index 000000000..4cdf529ad --- /dev/null +++ b/gateway/core/corehttp/logs.go @@ -0,0 +1,42 @@ +package corehttp + +import ( + "io" + "net/http" + + core "github.com/ipfs/go-ipfs/core" + "github.com/ipfs/go-ipfs/thirdparty/eventlog" +) + +type writeErrNotifier struct { + w io.Writer + errs chan error +} + +func newWriteErrNotifier(w io.Writer) (io.Writer, <-chan error) { + ch := make(chan error, 1) + return &writeErrNotifier{ + w: w, + errs: ch, + }, ch +} + +func (w *writeErrNotifier) Write(b []byte) (int, error) { + n, err := w.w.Write(b) + if err != nil { + w.errs <- err + } + return n, err +} + +func LogOption() ServeOption { + return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { + mux.HandleFunc("/logs", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + wnf, errs := newWriteErrNotifier(w) + eventlog.WriterGroup.AddWriter(wnf) + <-errs + }) + return mux, nil + } +} From 8a07c605a645f28d42d1dcbd0f996f5220410e3d Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 17 Jun 2015 10:55:07 -0700 Subject: [PATCH 071/674] clean up unused log options License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@90896f283f5046feed3fcc1cd21454900b7cd009 --- gateway/core/corehttp/logs.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 4cdf529ad..4e46d0af0 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -24,7 +24,10 @@ func newWriteErrNotifier(w io.Writer) (io.Writer, <-chan error) { func (w *writeErrNotifier) Write(b []byte) (int, error) { n, err := w.w.Write(b) if err != nil { - w.errs <- err + select { + case w.errs <- err: + default: + } } return n, err } From f386abba1866fe509cf2ec228b4c9030470e4b12 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 18 Jun 2015 08:18:55 -0700 Subject: [PATCH 072/674] add sharness test for log endpoint License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@96e98a8e13c42def19c57093ff62b68b897af441 --- gateway/core/corehttp/logs.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 4e46d0af0..7624644cf 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -29,6 +29,9 @@ func (w *writeErrNotifier) Write(b []byte) (int, error) { default: } } + if f, ok := w.w.(http.Flusher); ok { + f.Flush() + } return n, err } @@ -38,6 +41,7 @@ func LogOption() ServeOption { w.WriteHeader(200) wnf, errs := newWriteErrNotifier(w) eventlog.WriterGroup.AddWriter(wnf) + log.Event(n.Context(), "log API client connected") <-errs }) return mux, nil From 5ce3d102a48f645dbcc5d5e7c044791219275c94 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sat, 20 Jun 2015 00:59:54 +0200 Subject: [PATCH 073/674] api: add /metrics endpoint for prometheus License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@ed8d3ae3881367260e97c754652829f27a209233 --- gateway/core/corehttp/prometheus.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 gateway/core/corehttp/prometheus.go diff --git a/gateway/core/corehttp/prometheus.go b/gateway/core/corehttp/prometheus.go new file mode 100644 index 000000000..d6e8ef4d0 --- /dev/null +++ b/gateway/core/corehttp/prometheus.go @@ -0,0 +1,16 @@ +package corehttp + +import ( + "net/http" + + prom "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus" + + "github.com/ipfs/go-ipfs/core" +) + +func PrometheusOption(path string) ServeOption { + return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { + mux.Handle(path, prom.Handler()) + return mux, nil + } +} From a8a44db17a99a83c7b78a7a8e1e9c55477112892 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 20 Jun 2015 00:59:48 +0200 Subject: [PATCH 074/674] http/gateway: - First tab at integrating @krl's new index page File icons are embedded in side icons.css (QmXB7PLRWH6bCiwrGh2MrBBjNkLv3mY3JdYXCikYZSwLED contains both the icons and bootstrap) - Fix back links (..) (fixes #1365) Thanks @JasonWoof for the insight. The back links now stop a t the root hash and work for links that do and dont end with a slash. License: MIT Signed-off-by: Henry This commit was moved from ipfs/kubo@0ed49dbbfb27d1f61f1df144a1ac0be97657a04f --- gateway/core/corehttp/gateway_handler.go | 80 ++++------- gateway/core/corehttp/gateway_indexPage.go | 160 +++++++++++++++++++++ 2 files changed, 189 insertions(+), 51 deletions(-) create mode 100644 gateway/core/corehttp/gateway_indexPage.go diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 9b66cd13a..11d353a23 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -27,16 +27,6 @@ const ( ipnsPathPrefix = "/ipns/" ) -// shortcut for templating -type webHandler map[string]interface{} - -// struct for directory listing -type directoryItem struct { - Size uint64 - Name string - Path string -} - // gatewayHandler is a HTTP handler that serves IPFS objects (accessible by default at /ipfs/) // (it serves requests like GET /ipfs/QmVRzPKPzNtSrEzBFm2UZfxmPAgnaLke4DMcerbsGGSaFe/link) type gatewayHandler struct { @@ -50,23 +40,9 @@ func newGatewayHandler(node *core.IpfsNode, conf GatewayConfig) (*gatewayHandler node: node, config: conf, } - err := i.loadTemplate() - if err != nil { - return nil, err - } return i, nil } -// Load the directroy list template -func (i *gatewayHandler) loadTemplate() error { - t, err := template.New("dir").Parse(listingTemplate) - if err != nil { - return err - } - i.dirList = t - return nil -} - // TODO(cryptix): find these helpers somewhere else func (i *gatewayHandler) newDagFromReader(r io.Reader) (*dag.Node, error) { // TODO(cryptix): change and remove this helper once PR1136 is merged @@ -205,14 +181,36 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } if !foundIndex { - // template and return directory listing - hndlr := webHandler{ - "listing": dirListing, - "path": urlPath, - } - if r.Method != "HEAD" { - if err := i.dirList.Execute(w, hndlr); err != nil { + // construct the correct back link + // https://github.com/ipfs/go-ipfs/issues/1365 + var backLink string = r.URL.Path + + // don't go further up than /ipfs/$hash/ + pathSplit := strings.Split(backLink, "/") + switch { + // keep backlink + case len(pathSplit) == 3: // url: /ipfs/$hash + + // keep backlink + case len(pathSplit) == 4 && pathSplit[3] == "": // url: /ipfs/$hash/ + + // add the correct link depending on wether the path ends with a slash + default: + if strings.HasSuffix(backLink, "/") { + backLink += "./.." + } else { + backLink += "/.." + } + } + + tplData := listingTemplateData{ + Listing: dirListing, + Path: urlPath, + BackLink: backLink, + } + err := listingTemplate.Execute(w, tplData) + if err != nil { internalWebError(w, err) return } @@ -441,23 +439,3 @@ func webErrorWithCode(w http.ResponseWriter, message string, err error, code int func internalWebError(w http.ResponseWriter, err error) { webErrorWithCode(w, "internalWebError", err, http.StatusInternalServerError) } - -// Directory listing template -var listingTemplate = ` - - - - - {{ .path }} - - -

Index of {{ .path }}

-
    -
  • ..
  • - {{ range .listing }} -
  • {{ .Name }} - {{ .Size }} bytes
  • - {{ end }} -
- - -` diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go new file mode 100644 index 000000000..242e1ac20 --- /dev/null +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -0,0 +1,160 @@ +package corehttp + +import ( + "html/template" + "path" +) + +// structs for directory listing +type listingTemplateData struct { + Listing []directoryItem + Path string + BackLink string +} + +type directoryItem struct { + Size uint64 + Name string + Path string +} + +// Directory listing template +var listingTemplate = template.Must(template.New("dir").Funcs(template.FuncMap{"iconFromExt": iconFromExt}).Parse(` + + + + + + + + + + {{ .Path }} + + + +
+
+
+
+ Index of {{ .Path }} +
+ + + + + + + {{ range .Listing }} + + + + + + {{ end }} +
+
 
+
+ .. +
+
 
+
+ {{ .Name }} + {{ .Size }} bytes
+
+
+ + +`)) + +// helper to guess the type/icon for it by the extension name +func iconFromExt(name string) string { + ext := path.Ext(name) + _, ok := knownIcons[ext] + if !ok { + // default blank icon + return "ipfs-_blank" + } + return "ipfs-" + ext[1:] // slice of the first dot +} + +var knownIcons = map[string]bool{ + ".aac": true, + ".aiff": true, + ".ai": true, + ".avi": true, + ".bmp": true, + ".c": true, + ".cpp": true, + ".css": true, + ".dat": true, + ".dmg": true, + ".doc": true, + ".dotx": true, + ".dwg": true, + ".dxf": true, + ".eps": true, + ".exe": true, + ".flv": true, + ".gif": true, + ".h": true, + ".hpp": true, + ".html": true, + ".ics": true, + ".iso": true, + ".java": true, + ".jpg": true, + ".js": true, + ".key": true, + ".less": true, + ".mid": true, + ".mp3": true, + ".mp4": true, + ".mpg": true, + ".odf": true, + ".ods": true, + ".odt": true, + ".otp": true, + ".ots": true, + ".ott": true, + ".pdf": true, + ".php": true, + ".png": true, + ".ppt": true, + ".psd": true, + ".py": true, + ".qt": true, + ".rar": true, + ".rb": true, + ".rtf": true, + ".sass": true, + ".scss": true, + ".sql": true, + ".tga": true, + ".tgz": true, + ".tiff": true, + ".txt": true, + ".wav": true, + ".xls": true, + ".xlsx": true, + ".xml": true, + ".yml": true, + ".zip": true, +} From c5025154d42c8de6096415301d0d765f7619cf1b Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 20 Jun 2015 15:41:54 +0200 Subject: [PATCH 075/674] http/index: fix indention and remove unused field License: MIT Signed-off-by: Henry This commit was moved from ipfs/kubo@053e531dac5d08fbec6f1937f0fb995fb103f99a --- gateway/core/corehttp/gateway_handler.go | 6 +- gateway/core/corehttp/gateway_indexPage.go | 118 ++++++++++----------- 2 files changed, 61 insertions(+), 63 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 11d353a23..6ea7b906f 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -3,7 +3,6 @@ package corehttp import ( "errors" "fmt" - "html/template" "io" "net/http" gopath "path" @@ -30,9 +29,8 @@ const ( // gatewayHandler is a HTTP handler that serves IPFS objects (accessible by default at /ipfs/) // (it serves requests like GET /ipfs/QmVRzPKPzNtSrEzBFm2UZfxmPAgnaLke4DMcerbsGGSaFe/link) type gatewayHandler struct { - node *core.IpfsNode - dirList *template.Template - config GatewayConfig + node *core.IpfsNode + config GatewayConfig } func newGatewayHandler(node *core.IpfsNode, conf GatewayConfig) (*gatewayHandler, error) { diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index 242e1ac20..79ad935b1 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -22,65 +22,65 @@ type directoryItem struct { var listingTemplate = template.Must(template.New("dir").Funcs(template.FuncMap{"iconFromExt": iconFromExt}).Parse(` - - - - - - - - {{ .Path }} - - - -
-
-
-
- Index of {{ .Path }} -
- - - - - - - {{ range .Listing }} - - - - - - {{ end }} -
-
 
-
- .. -
-
 
-
- {{ .Name }} - {{ .Size }} bytes
-
-
- + + + + + + + + {{ .Path }} + + + +
+
+
+
+ Index of {{ .Path }} +
+ + + + + + + {{ range .Listing }} + + + + + + {{ end }} +
+
 
+
+ .. +
+
 
+
+ {{ .Name }} + {{ .Size }} bytes
+
+
+ `)) From 367d0580fa7c64b2e0c2e5f55b5d76c5b6fc677b Mon Sep 17 00:00:00 2001 From: rht Date: Thu, 18 Jun 2015 17:17:38 +0700 Subject: [PATCH 076/674] Change Process interface into object variable License: MIT Signed-off-by: rht This commit was moved from ipfs/kubo@007a12e7efb2b26eb79d335f2e8b968c4c541623 --- gateway/core/corehttp/corehttp.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 95a159fa2..042f056ad 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,6 +12,7 @@ import ( ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess" core "github.com/ipfs/go-ipfs/core" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" ) @@ -78,20 +79,17 @@ func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error var serverError error serverExited := make(chan struct{}) - node.Children().Add(1) - defer node.Children().Done() - - go func() { + node.Process().Go(func(p goprocess.Process) { serverError = http.Serve(lis, handler) close(serverExited) - }() + }) // wait for server to exit. select { case <-serverExited: // if node being closed before server exits, close server - case <-node.Closing(): + case <-node.Process().Closing(): log.Infof("server at %s terminating...", addr) lis.Close() From 2bb3cf26cce9356c1085e078566def4c89c2e637 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 23 Jul 2015 18:44:46 -0700 Subject: [PATCH 077/674] Added API + Gateway support for arbitrary HTTP headers This commit fixes + improves CORS support License: MIT Signed-off-by: Juan Batiz-Benet This commit was moved from ipfs/kubo@7cf5e87cfe881fd09486ea038fa7870f60afe54f --- gateway/core/corehttp/commands.go | 61 ++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index f3e5c8a45..f8e676600 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -3,22 +3,71 @@ package corehttp import ( "net/http" "os" + "strings" + + cors "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/rs/cors" commands "github.com/ipfs/go-ipfs/commands" cmdsHttp "github.com/ipfs/go-ipfs/commands/http" core "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + config "github.com/ipfs/go-ipfs/repo/config" ) -const ( - // TODO rename - originEnvKey = "API_ORIGIN" -) +const originEnvKey = "API_ORIGIN" +const originEnvKeyDeprecate = `You are using the ` + originEnvKey + `ENV Variable. +This functionality is deprecated, and will be removed in future versions. +Instead, try either adding headers to the config, or passing them via +cli arguments: + + ipfs config API.HTTPHeaders 'Access-Control-Allow-Origin' '*' + ipfs daemon + +or + + ipfs daemon --api-http-header 'Access-Control-Allow-Origin: *' +` + +func addCORSFromEnv(c *cmdsHttp.ServerConfig) { + origin := os.Getenv(originEnvKey) + if origin != "" { + log.Warning(originEnvKeyDeprecate) + if c.CORSOpts == nil { + c.CORSOpts.AllowedOrigins = []string{origin} + } + c.CORSOpts.AllowedOrigins = append(c.CORSOpts.AllowedOrigins, origin) + } +} + +func addCORSFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { + log.Info("Using API.HTTPHeaders:", nc.API.HTTPHeaders) + + if acao := nc.API.HTTPHeaders["Access-Control-Allow-Origin"]; acao != nil { + c.CORSOpts.AllowedOrigins = acao + } + if acam := nc.API.HTTPHeaders["Access-Control-Allow-Methods"]; acam != nil { + c.CORSOpts.AllowedMethods = acam + } + if acac := nc.API.HTTPHeaders["Access-Control-Allow-Credentials"]; acac != nil { + for _, v := range acac { + c.CORSOpts.AllowCredentials = (strings.ToLower(v) == "true") + } + } +} func CommandsOption(cctx commands.Context) ServeOption { return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { - origin := os.Getenv(originEnvKey) - cmdHandler := cmdsHttp.NewHandler(cctx, corecommands.Root, origin) + + cfg := &cmdsHttp.ServerConfig{ + CORSOpts: &cors.Options{ + AllowedMethods: []string{"GET", "POST", "PUT"}, + }, + } + + addCORSFromConfig(cfg, n.Repo.Config()) + addCORSFromEnv(cfg) + + cmdHandler := cmdsHttp.NewHandler(cctx, corecommands.Root, cfg) mux.Handle(cmdsHttp.ApiPath+"/", cmdHandler) return mux, nil } From c993cecb517ac4c10d3e0800c7877ee2948aba18 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Tue, 28 Jul 2015 07:50:20 -0700 Subject: [PATCH 078/674] implement arbitrary HTTP header support this commit adds the ability to specify arbitrary HTTP headers for either the Gateway or the API. simply set the desired headers on the config: ipfs config --json API.HTTPHeaders.X-MyHdr '["meow :)"]' ipfs config --json Gateway.HTTPHeaders.X-MyHdr '["meow :)"]' License: MIT Signed-off-by: Juan Batiz-Benet This commit was moved from ipfs/kubo@4a571b099b013018703951c1c8f812ceadd1fe12 --- gateway/core/corehttp/commands.go | 6 ++++-- gateway/core/corehttp/gateway.go | 4 ++++ gateway/core/corehttp/gateway_handler.go | 11 +++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index f8e676600..97b9c2b4b 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -39,7 +39,7 @@ func addCORSFromEnv(c *cmdsHttp.ServerConfig) { } } -func addCORSFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { +func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { log.Info("Using API.HTTPHeaders:", nc.API.HTTPHeaders) if acao := nc.API.HTTPHeaders["Access-Control-Allow-Origin"]; acao != nil { @@ -53,6 +53,8 @@ func addCORSFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { c.CORSOpts.AllowCredentials = (strings.ToLower(v) == "true") } } + + c.Headers = nc.API.HTTPHeaders } func CommandsOption(cctx commands.Context) ServeOption { @@ -64,7 +66,7 @@ func CommandsOption(cctx commands.Context) ServeOption { }, } - addCORSFromConfig(cfg, n.Repo.Config()) + addHeadersFromConfig(cfg, n.Repo.Config()) addCORSFromEnv(cfg) cmdHandler := cmdsHttp.NewHandler(cctx, corecommands.Root, cfg) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 0a84178b8..f70a1d11f 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -15,6 +15,7 @@ type Gateway struct { } type GatewayConfig struct { + Headers map[string][]string BlockList *BlockList Writable bool } @@ -27,6 +28,9 @@ func NewGateway(conf GatewayConfig) *Gateway { func (g *Gateway) ServeOption() ServeOption { return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { + // pass user's HTTP headers + g.Config.Headers = n.Repo.Config().Gateway.HTTPHeaders + gateway, err := newGatewayHandler(n, g.Config) if err != nil { return nil, err diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 6ea7b906f..671a1c5e8 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -106,6 +106,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } + i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("X-IPFS-Path", urlPath) // Suborigin header, sandboxes apps from each other in the browser (even @@ -229,6 +230,7 @@ func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { return } + i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("IPFS-Hash", k.String()) http.Redirect(w, r, ipfsPathPrefix+k.String(), http.StatusCreated) } @@ -242,6 +244,7 @@ func (i *gatewayHandler) putEmptyDirHandler(w http.ResponseWriter, r *http.Reque return } + i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("IPFS-Hash", key.String()) http.Redirect(w, r, ipfsPathPrefix+key.String()+"/", http.StatusCreated) } @@ -340,6 +343,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } + i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("IPFS-Hash", key.String()) http.Redirect(w, r, ipfsPathPrefix+key.String()+"/"+strings.Join(components, "/"), http.StatusCreated) } @@ -411,10 +415,17 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { return } + i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("IPFS-Hash", key.String()) http.Redirect(w, r, ipfsPathPrefix+key.String()+"/"+strings.Join(components[:len(components)-1], "/"), http.StatusCreated) } +func (i *gatewayHandler) addUserHeaders(w http.ResponseWriter) { + for k, v := range i.config.Headers { + w.Header()[k] = v + } +} + func webError(w http.ResponseWriter, message string, err error, defaultCode int) { if _, ok := err.(path.ErrNoLink); ok { webErrorWithCode(w, message, err, http.StatusNotFound) From 7b098f292bdc519b86ee718187bc4bfdc6d8998c Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Tue, 28 Jul 2015 22:57:11 -0700 Subject: [PATCH 079/674] fix API handler to respect referer + exit on CORS this commit makes the API handler short circuit the request if the CORS headers say its not allowed. (the CORS handler only sets the headers, but does not short-circuit) It also makes the handler respect the referer again. See security discussion at https://github.com/ipfs/go-ipfs/issues/1532 License: MIT Signed-off-by: Juan Batiz-Benet This commit was moved from ipfs/kubo@d5f94be474ebb723efa3002517a03fc79290585f --- gateway/core/corehttp/commands.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 97b9c2b4b..0a65fcc3a 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -42,13 +42,13 @@ func addCORSFromEnv(c *cmdsHttp.ServerConfig) { func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { log.Info("Using API.HTTPHeaders:", nc.API.HTTPHeaders) - if acao := nc.API.HTTPHeaders["Access-Control-Allow-Origin"]; acao != nil { + if acao := nc.API.HTTPHeaders[cmdsHttp.ACAOrigin]; acao != nil { c.CORSOpts.AllowedOrigins = acao } - if acam := nc.API.HTTPHeaders["Access-Control-Allow-Methods"]; acam != nil { + if acam := nc.API.HTTPHeaders[cmdsHttp.ACAMethods]; acam != nil { c.CORSOpts.AllowedMethods = acam } - if acac := nc.API.HTTPHeaders["Access-Control-Allow-Credentials"]; acac != nil { + if acac := nc.API.HTTPHeaders[cmdsHttp.ACACredentials]; acac != nil { for _, v := range acac { c.CORSOpts.AllowCredentials = (strings.ToLower(v) == "true") } From 0ccfb889bab33b95526ccb2d2b6b89ad67ace838 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Fri, 31 Jul 2015 17:34:56 -0400 Subject: [PATCH 080/674] corehttp: add net.Listener to ServeOption ServeOptions take the node and muxer, they should get the listener too as sometimes they need to operate on the listener address. License: MIT Signed-off-by: Juan Batiz-Benet This commit was moved from ipfs/kubo@3f1cbe2f437c9aad8b972b40283d2dc69a2bd6b9 --- gateway/core/corehttp/commands.go | 3 ++- gateway/core/corehttp/corehttp.go | 8 ++++---- gateway/core/corehttp/gateway.go | 5 +++-- gateway/core/corehttp/gateway_test.go | 20 ++++++++++++++++---- gateway/core/corehttp/ipns_hostname.go | 3 ++- gateway/core/corehttp/logs.go | 3 ++- gateway/core/corehttp/prometheus.go | 3 ++- gateway/core/corehttp/redirect.go | 3 ++- 8 files changed, 33 insertions(+), 15 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 0a65fcc3a..1793c5539 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -1,6 +1,7 @@ package corehttp import ( + "net" "net/http" "os" "strings" @@ -58,7 +59,7 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { } func CommandsOption(cctx commands.Context) ServeOption { - return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { + return func(n *core.IpfsNode, l net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { cfg := &cmdsHttp.ServerConfig{ CORSOpts: &cors.Options{ diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 042f056ad..dc221f3cd 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -23,16 +23,16 @@ var log = eventlog.Logger("core/server") // It returns the mux to expose to future options, which may be a new mux if it // is interested in mediating requests to future options, or the same mux // initially passed in if not. -type ServeOption func(*core.IpfsNode, *http.ServeMux) (*http.ServeMux, error) +type ServeOption func(*core.IpfsNode, net.Listener, *http.ServeMux) (*http.ServeMux, error) // makeHandler turns a list of ServeOptions into a http.Handler that implements // all of the given options, in order. -func makeHandler(n *core.IpfsNode, options ...ServeOption) (http.Handler, error) { +func makeHandler(n *core.IpfsNode, l net.Listener, options ...ServeOption) (http.Handler, error) { topMux := http.NewServeMux() mux := topMux for _, option := range options { var err error - mux, err = option(n, mux) + mux, err = option(n, l, mux) if err != nil { return nil, err } @@ -65,7 +65,7 @@ func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...Serv } func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error { - handler, err := makeHandler(node, options...) + handler, err := makeHandler(node, lis, options...) if err != nil { return err } diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index f70a1d11f..584a89437 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -2,6 +2,7 @@ package corehttp import ( "fmt" + "net" "net/http" "sync" @@ -27,7 +28,7 @@ func NewGateway(conf GatewayConfig) *Gateway { } func (g *Gateway) ServeOption() ServeOption { - return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { + return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { // pass user's HTTP headers g.Config.Headers = n.Repo.Config().Gateway.HTTPHeaders @@ -50,7 +51,7 @@ func GatewayOption(writable bool) ServeOption { } func VersionOption() ServeOption { - return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { + return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion) fmt.Fprintf(w, "Protocol Version: %s\n", id.IpfsVersion) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 01d4295b7..7ad3584da 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -55,6 +55,14 @@ func newNodeWithMockNamesys(t *testing.T, ns mockNamesys) *core.IpfsNode { return n } +type delegatedHandler struct { + http.Handler +} + +func (dh *delegatedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + dh.Handler.ServeHTTP(w, r) +} + func TestGatewayGet(t *testing.T) { t.Skip("not sure whats going on here") ns := mockNamesys{} @@ -65,7 +73,14 @@ func TestGatewayGet(t *testing.T) { } ns["example.com"] = path.FromString("/ipfs/" + k) - h, err := makeHandler(n, + // need this variable here since we need to construct handler with + // listener, and server with handler. yay cycles. + dh := &delegatedHandler{} + ts := httptest.NewServer(dh) + defer ts.Close() + + dh.Handler, err = makeHandler(n, + ts.Listener, IPNSHostnameOption(), GatewayOption(false), ) @@ -73,9 +88,6 @@ func TestGatewayGet(t *testing.T) { t.Fatal(err) } - ts := httptest.NewServer(h) - defer ts.Close() - t.Log(ts.URL) for _, test := range []struct { host string diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 6f31e5268..10edb0ace 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -1,6 +1,7 @@ package corehttp import ( + "net" "net/http" "strings" @@ -13,7 +14,7 @@ import ( // an IPNS name. // The rewritten request points at the resolved name on the gateway handler. func IPNSHostnameOption() ServeOption { - return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { + return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { childMux := http.NewServeMux() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { ctx, cancel := context.WithCancel(n.Context()) diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 7624644cf..59b87b9bc 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -2,6 +2,7 @@ package corehttp import ( "io" + "net" "net/http" core "github.com/ipfs/go-ipfs/core" @@ -36,7 +37,7 @@ func (w *writeErrNotifier) Write(b []byte) (int, error) { } func LogOption() ServeOption { - return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { + return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/logs", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) wnf, errs := newWriteErrNotifier(w) diff --git a/gateway/core/corehttp/prometheus.go b/gateway/core/corehttp/prometheus.go index d6e8ef4d0..0642c04b5 100644 --- a/gateway/core/corehttp/prometheus.go +++ b/gateway/core/corehttp/prometheus.go @@ -1,6 +1,7 @@ package corehttp import ( + "net" "net/http" prom "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus" @@ -9,7 +10,7 @@ import ( ) func PrometheusOption(path string) ServeOption { - return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { + return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.Handle(path, prom.Handler()) return mux, nil } diff --git a/gateway/core/corehttp/redirect.go b/gateway/core/corehttp/redirect.go index 67d6c0773..ec70ffaf9 100644 --- a/gateway/core/corehttp/redirect.go +++ b/gateway/core/corehttp/redirect.go @@ -1,6 +1,7 @@ package corehttp import ( + "net" "net/http" core "github.com/ipfs/go-ipfs/core" @@ -8,7 +9,7 @@ import ( func RedirectOption(path string, redirect string) ServeOption { handler := &redirectHandler{redirect} - return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) { + return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.Handle("/"+path+"/", handler) return mux, nil } From 5d8247040edfe0f6e2f931f65b415e189c5a2b5c Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Fri, 31 Jul 2015 17:36:02 -0400 Subject: [PATCH 081/674] fix cors: defaults should take the port of the listener need to do it this way to avoid VERY confusing situations where the user would change the API port (to another port, or maybe even to :0). this way things dont break on the user, and by default, users only need to change the API address and things should still "just work" License: MIT Signed-off-by: Juan Batiz-Benet This commit was moved from ipfs/kubo@3ee83a7c5eae50496a9a349330bc70e4d635393c --- gateway/core/corehttp/commands.go | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 1793c5539..d96818e2a 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -4,6 +4,7 @@ import ( "net" "net/http" "os" + "strconv" "strings" cors "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/rs/cors" @@ -29,6 +30,13 @@ or ipfs daemon --api-http-header 'Access-Control-Allow-Origin: *' ` +var defaultLocalhostOrigins = []string{ + "http://127.0.0.1:", + "https://127.0.0.1:", + "http://localhost:", + "https://localhost:", +} + func addCORSFromEnv(c *cmdsHttp.ServerConfig) { origin := os.Getenv(originEnvKey) if origin != "" { @@ -58,6 +66,39 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { c.Headers = nc.API.HTTPHeaders } +func addCORSDefaults(c *cmdsHttp.ServerConfig) { + // by default use localhost origins + if len(c.CORSOpts.AllowedOrigins) == 0 { + c.CORSOpts.AllowedOrigins = defaultLocalhostOrigins + } + + // by default, use GET, PUT, POST + if len(c.CORSOpts.AllowedMethods) == 0 { + c.CORSOpts.AllowedMethods = []string{"GET", "POST", "PUT"} + } +} + +func patchCORSVars(c *cmdsHttp.ServerConfig, addr net.Addr) { + + // we have to grab the port from an addr, which may be an ip6 addr. + // TODO: this should take multiaddrs and derive port from there. + port := "" + if tcpaddr, ok := addr.(*net.TCPAddr); ok { + port = strconv.Itoa(tcpaddr.Port) + } else if udpaddr, ok := addr.(*net.UDPAddr); ok { + port = strconv.Itoa(udpaddr.Port) + } + + // we're listening on tcp/udp with ports. ("udp!?" you say? yeah... it happens...) + for i, o := range c.CORSOpts.AllowedOrigins { + // TODO: allow replacing . tricky, ip4 and ip6 and hostnames... + if port != "" { + o = strings.Replace(o, "", port, -1) + } + c.CORSOpts.AllowedOrigins[i] = o + } +} + func CommandsOption(cctx commands.Context) ServeOption { return func(n *core.IpfsNode, l net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { @@ -69,6 +110,8 @@ func CommandsOption(cctx commands.Context) ServeOption { addHeadersFromConfig(cfg, n.Repo.Config()) addCORSFromEnv(cfg) + addCORSDefaults(cfg) + patchCORSVars(cfg, l.Addr()) cmdHandler := cmdsHttp.NewHandler(cctx, corecommands.Root, cfg) mux.Handle(cmdsHttp.ApiPath+"/", cmdHandler) From e2680db2e491a1b567bb0ebb4926fecea199370b Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 29 Jul 2015 13:08:37 -0700 Subject: [PATCH 082/674] use rabin fingerprinting for a chunker License: MIT Signed-off-by: Jeromy implement rabin fingerprinting as a chunker for ipfs License: MIT Signed-off-by: Jeromy vendor correctly License: MIT Signed-off-by: Jeromy refactor chunking interface a little License: MIT Signed-off-by: Jeromy work chunking interface changes up into importer License: MIT Signed-off-by: Jeromy move chunker type parsing into its own file in chunk License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@39a23392c184a288db29201c5f6535fb3454a12f --- gateway/core/corehttp/gateway_handler.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 671a1c5e8..550943675 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -46,7 +46,9 @@ func (i *gatewayHandler) newDagFromReader(r io.Reader) (*dag.Node, error) { // TODO(cryptix): change and remove this helper once PR1136 is merged // return ufs.AddFromReader(i.node, r.Body) return importer.BuildDagFromReader( - r, i.node.DAG, chunk.DefaultSplitter, importer.BasicPinnerCB(i.node.Pinning.GetManual())) + i.node.DAG, + chunk.DefaultSplitter(r), + importer.BasicPinnerCB(i.node.Pinning.GetManual())) } // TODO(btc): break this apart into separate handlers using a more expressive muxer From 671ce9555054f10e95b35d252498c5a1928c54db Mon Sep 17 00:00:00 2001 From: rht Date: Sat, 15 Aug 2015 11:10:07 +0700 Subject: [PATCH 083/674] Add readonly api to gateway Based on https://github.com/ipfs/go-ipfs/pull/1389 License: MIT Signed-off-by: rht This commit was moved from ipfs/kubo@dd99a70a7dda920a0f7dad5ad14e980202fae3ce --- gateway/core/corehttp/commands.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index d96818e2a..e3a64f0f8 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -99,7 +99,7 @@ func patchCORSVars(c *cmdsHttp.ServerConfig, addr net.Addr) { } } -func CommandsOption(cctx commands.Context) ServeOption { +func commandsOption(cctx commands.Context, command *commands.Command) ServeOption { return func(n *core.IpfsNode, l net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { cfg := &cmdsHttp.ServerConfig{ @@ -113,8 +113,16 @@ func CommandsOption(cctx commands.Context) ServeOption { addCORSDefaults(cfg) patchCORSVars(cfg, l.Addr()) - cmdHandler := cmdsHttp.NewHandler(cctx, corecommands.Root, cfg) + cmdHandler := cmdsHttp.NewHandler(cctx, command, cfg) mux.Handle(cmdsHttp.ApiPath+"/", cmdHandler) return mux, nil } } + +func CommandsOption(cctx commands.Context) ServeOption { + return commandsOption(cctx, corecommands.Root) +} + +func CommandsROOption(cctx commands.Context) ServeOption { + return commandsOption(cctx, corecommands.RootRO) +} From fa95a279757eaac88478a84074e6444c8e28d01f Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sun, 16 Aug 2015 00:52:59 +0200 Subject: [PATCH 084/674] gateway: bring back TestGatewayGet test License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@a3a10a4bc11cb268bb06cabc81d0f860493e161f --- gateway/core/corehttp/gateway_test.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 7ad3584da..09415c712 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -37,7 +37,7 @@ func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value path.Pa return errors.New("not implemented for mockNamesys") } -func newNodeWithMockNamesys(t *testing.T, ns mockNamesys) *core.IpfsNode { +func newNodeWithMockNamesys(ns mockNamesys) (*core.IpfsNode, error) { c := config.Config{ Identity: config.Identity{ PeerID: "Qmfoo", // required by offline node @@ -49,10 +49,10 @@ func newNodeWithMockNamesys(t *testing.T, ns mockNamesys) *core.IpfsNode { } n, err := core.NewIPFSNode(context.Background(), core.Offline(r)) if err != nil { - t.Fatal(err) + return nil, err } n.Namesys = ns - return n + return n, nil } type delegatedHandler struct { @@ -64,14 +64,19 @@ func (dh *delegatedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func TestGatewayGet(t *testing.T) { - t.Skip("not sure whats going on here") + // mock node and namesys ns := mockNamesys{} - n := newNodeWithMockNamesys(t, ns) + n, err := newNodeWithMockNamesys(ns) + if err != nil { + t.Fatal(err) + } + + // mock ipfs object k, err := coreunix.Add(n, strings.NewReader("fnord")) if err != nil { t.Fatal(err) } - ns["example.com"] = path.FromString("/ipfs/" + k) + ns["/ipns/example.com"] = path.FromString("/ipfs/" + k) // need this variable here since we need to construct handler with // listener, and server with handler. yay cycles. From a6aa610eb89a7ac3cd29b0fcfd10a968e07db43d Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sat, 15 Aug 2015 01:41:48 +0200 Subject: [PATCH 085/674] gateway: make IPNSHostname complete IPNSHostnameOption() touches the URL path only on the way in, but not on the way out. This commit makes it complete by touching the following URLs in responses: - Heading, file links, back links in directory listings - Redirecting /foo to /foo/ if there's an index.html link - Omit Suborigin header License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@09d750172473a7991bca0b0dad9529a5bdbda2fb --- gateway/core/corehttp/gateway_handler.go | 55 +++++- gateway/core/corehttp/gateway_test.go | 222 ++++++++++++++++++++++- gateway/core/corehttp/ipns_hostname.go | 1 + 3 files changed, 258 insertions(+), 20 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 550943675..154db3b53 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -90,6 +90,19 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request urlPath := r.URL.Path + // IPNSHostnameOption might have constructed an IPNS path using the Host header. + // In this case, we need the original path for constructing redirects + // and links that match the requested URL. + // For example, http://example.net would become /ipns/example.net, and + // the redirects and links would end up as http://example.net/ipns/example.net + originalUrlPath := urlPath + ipnsHostname := false + hdr := r.Header["X-IPNS-Original-Path"] + if len(hdr) > 0 { + originalUrlPath = hdr[0] + ipnsHostname = true + } + if i.config.BlockList != nil && i.config.BlockList.ShouldBlock(urlPath) { w.WriteHeader(http.StatusForbidden) w.Write([]byte("403 - Forbidden")) @@ -112,10 +125,17 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request w.Header().Set("X-IPFS-Path", urlPath) // Suborigin header, sandboxes apps from each other in the browser (even - // though they are served from the same gateway domain). NOTE: This is not - // yet widely supported by browsers. - pathRoot := strings.SplitN(urlPath, "/", 4)[2] - w.Header().Set("Suborigin", pathRoot) + // though they are served from the same gateway domain). + // + // Omited if the path was treated by IPNSHostnameOption(), for example + // a request for http://example.net/ would be changed to /ipns/example.net/, + // which would turn into an incorrect Suborigin: example.net header. + // + // NOTE: This is not yet widely supported by browsers. + if !ipnsHostname { + pathRoot := strings.SplitN(urlPath, "/", 4)[2] + w.Header().Set("Suborigin", pathRoot) + } dr, err := uio.NewDagReader(ctx, nd, i.node.DAG) if err != nil && err != uio.ErrIsDir { @@ -150,13 +170,16 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request foundIndex := false for _, link := range nd.Links { if link.Name == "index.html" { + log.Debugf("found index.html link for %s", urlPath) + foundIndex = true + if urlPath[len(urlPath)-1] != '/' { - http.Redirect(w, r, urlPath+"/", 302) + // See comment above where originalUrlPath is declared. + http.Redirect(w, r, originalUrlPath+"/", 302) + log.Debugf("redirect to %s", originalUrlPath+"/") return } - log.Debug("found index") - foundIndex = true // return index page instead. nd, err := core.Resolve(ctx, i.node, path.Path(urlPath+"/index.html")) if err != nil { @@ -177,7 +200,8 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request break } - di := directoryItem{link.Size, link.Name, gopath.Join(urlPath, link.Name)} + // See comment above where originalUrlPath is declared. + di := directoryItem{link.Size, link.Name, gopath.Join(originalUrlPath, link.Name)} dirListing = append(dirListing, di) } @@ -185,7 +209,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request if r.Method != "HEAD" { // construct the correct back link // https://github.com/ipfs/go-ipfs/issues/1365 - var backLink string = r.URL.Path + var backLink string = urlPath // don't go further up than /ipfs/$hash/ pathSplit := strings.Split(backLink, "/") @@ -205,9 +229,20 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } } + // strip /ipfs/$hash from backlink if IPNSHostnameOption touched the path. + if ipnsHostname { + backLink = "/" + if len(pathSplit) > 5 { + // also strip the trailing segment, because it's a backlink + backLinkParts := pathSplit[3 : len(pathSplit)-2] + backLink += strings.Join(backLinkParts, "/") + "/" + } + } + + // See comment above where originalUrlPath is declared. tplData := listingTemplateData{ Listing: dirListing, - Path: urlPath, + Path: originalUrlPath, BackLink: backLink, } err := listingTemplate.Execute(w, tplData) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 09415c712..a90bd641e 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -63,26 +63,30 @@ func (dh *delegatedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { dh.Handler.ServeHTTP(w, r) } -func TestGatewayGet(t *testing.T) { - // mock node and namesys - ns := mockNamesys{} - n, err := newNodeWithMockNamesys(ns) - if err != nil { - t.Fatal(err) +func doWithoutRedirect(req *http.Request) (*http.Response, error) { + tag := "without-redirect" + c := &http.Client{ + CheckRedirect: func(req *http.Request, via []*http.Request) error { + return errors.New(tag) + }, + } + res, err := c.Do(req) + if err != nil && !strings.Contains(err.Error(), tag) { + return nil, err } + return res, nil +} - // mock ipfs object - k, err := coreunix.Add(n, strings.NewReader("fnord")) +func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, *core.IpfsNode) { + n, err := newNodeWithMockNamesys(ns) if err != nil { t.Fatal(err) } - ns["/ipns/example.com"] = path.FromString("/ipfs/" + k) // need this variable here since we need to construct handler with // listener, and server with handler. yay cycles. dh := &delegatedHandler{} ts := httptest.NewServer(dh) - defer ts.Close() dh.Handler, err = makeHandler(n, ts.Listener, @@ -93,6 +97,20 @@ func TestGatewayGet(t *testing.T) { t.Fatal(err) } + return ts, n +} + +func TestGatewayGet(t *testing.T) { + ns := mockNamesys{} + ts, n := newTestServerAndNode(t, ns) + defer ts.Close() + + k, err := coreunix.Add(n, strings.NewReader("fnord")) + if err != nil { + t.Fatal(err) + } + ns["/ipns/example.com"] = path.FromString("/ipfs/" + k) + t.Log(ts.URL) for _, test := range []struct { host string @@ -135,3 +153,187 @@ func TestGatewayGet(t *testing.T) { } } } + +func TestIPNSHostnameRedirect(t *testing.T) { + ns := mockNamesys{} + ts, n := newTestServerAndNode(t, ns) + t.Logf("test server url: %s", ts.URL) + defer ts.Close() + + // create /ipns/example.net/foo/index.html + _, dagn1, err := coreunix.AddWrapped(n, strings.NewReader("_"), "_") + if err != nil { + t.Fatal(err) + } + _, dagn2, err := coreunix.AddWrapped(n, strings.NewReader("_"), "index.html") + if err != nil { + t.Fatal(err) + } + dagn1.AddNodeLink("foo", dagn2) + if err != nil { + t.Fatal(err) + } + + err = n.DAG.AddRecursive(dagn1) + if err != nil { + t.Fatal(err) + } + + k, err := dagn1.Key() + if err != nil { + t.Fatal(err) + } + t.Logf("k: %s\n", k) + ns["/ipns/example.net"] = path.FromString("/ipfs/" + k.String()) + + // make request to directory containing index.html + req, err := http.NewRequest("GET", ts.URL+"/foo", nil) + if err != nil { + t.Fatal(err) + } + req.Host = "example.net" + + res, err := doWithoutRedirect(req) + if err != nil { + t.Fatal(err) + } + + // expect 302 redirect to same path, but with trailing slash + if res.StatusCode != 302 { + t.Errorf("status is %d, expected 302", res.StatusCode) + } + hdr := res.Header["Location"] + if len(hdr) < 1 { + t.Errorf("location header not present") + } else if hdr[0] != "/foo/" { + t.Errorf("location header is %v, expected /foo/", hdr[0]) + } +} + +func TestIPNSHostnameBacklinks(t *testing.T) { + ns := mockNamesys{} + ts, n := newTestServerAndNode(t, ns) + t.Logf("test server url: %s", ts.URL) + defer ts.Close() + + // create /ipns/example.net/foo/ + _, dagn1, err := coreunix.AddWrapped(n, strings.NewReader("1"), "file.txt") + if err != nil { + t.Fatal(err) + } + _, dagn2, err := coreunix.AddWrapped(n, strings.NewReader("2"), "file.txt") + if err != nil { + t.Fatal(err) + } + _, dagn3, err := coreunix.AddWrapped(n, strings.NewReader("3"), "file.txt") + if err != nil { + t.Fatal(err) + } + dagn2.AddNodeLink("bar", dagn3) + dagn1.AddNodeLink("foo", dagn2) + if err != nil { + t.Fatal(err) + } + + err = n.DAG.AddRecursive(dagn1) + if err != nil { + t.Fatal(err) + } + + k, err := dagn1.Key() + if err != nil { + t.Fatal(err) + } + t.Logf("k: %s\n", k) + ns["/ipns/example.net"] = path.FromString("/ipfs/" + k.String()) + + // make request to directory listing + req, err := http.NewRequest("GET", ts.URL+"/foo/", nil) + if err != nil { + t.Fatal(err) + } + req.Host = "example.net" + + res, err := doWithoutRedirect(req) + if err != nil { + t.Fatal(err) + } + + // expect correct backlinks + body, err := ioutil.ReadAll(res.Body) + if err != nil { + t.Fatalf("error reading response: %s", err) + } + s := string(body) + t.Logf("body: %s\n", string(body)) + + if !strings.Contains(s, "Index of /foo/") { + t.Fatalf("expected a path in directory listing") + } + if !strings.Contains(s, "") { + t.Fatalf("expected backlink in directory listing") + } + if !strings.Contains(s, "") { + t.Fatalf("expected file in directory listing") + } + + // make request to directory listing + req, err = http.NewRequest("GET", ts.URL, nil) + if err != nil { + t.Fatal(err) + } + req.Host = "example.net" + + res, err = doWithoutRedirect(req) + if err != nil { + t.Fatal(err) + } + + // expect correct backlinks + body, err = ioutil.ReadAll(res.Body) + if err != nil { + t.Fatalf("error reading response: %s", err) + } + s = string(body) + t.Logf("body: %s\n", string(body)) + + if !strings.Contains(s, "Index of /") { + t.Fatalf("expected a path in directory listing") + } + if !strings.Contains(s, "") { + t.Fatalf("expected backlink in directory listing") + } + if !strings.Contains(s, "") { + t.Fatalf("expected file in directory listing") + } + + // make request to directory listing + req, err = http.NewRequest("GET", ts.URL+"/foo/bar/", nil) + if err != nil { + t.Fatal(err) + } + req.Host = "example.net" + + res, err = doWithoutRedirect(req) + if err != nil { + t.Fatal(err) + } + + // expect correct backlinks + body, err = ioutil.ReadAll(res.Body) + if err != nil { + t.Fatalf("error reading response: %s", err) + } + s = string(body) + t.Logf("body: %s\n", string(body)) + + if !strings.Contains(s, "Index of /foo/bar/") { + t.Fatalf("expected a path in directory listing") + } + if !strings.Contains(s, "") { + t.Fatalf("expected backlink in directory listing") + } + if !strings.Contains(s, "") { + t.Fatalf("expected file in directory listing") + } +} diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 10edb0ace..94faccd5d 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -24,6 +24,7 @@ func IPNSHostnameOption() ServeOption { if len(host) > 0 && isd.IsDomain(host) { name := "/ipns/" + host if _, err := n.Namesys.Resolve(ctx, name); err == nil { + r.Header["X-IPNS-Original-Path"] = []string{r.URL.Path} r.URL.Path = name + r.URL.Path } } From f08edebbe9527de45d1230da48ca219bb396dd74 Mon Sep 17 00:00:00 2001 From: rht Date: Sun, 23 Aug 2015 22:12:23 +0700 Subject: [PATCH 086/674] Localize the scope of context.WithCancel for every DAG.Get Instead put it inside of DAG.Get. The fix is applied only in the case when the context.WithCancel before a DAG.Get is also used later on in the scope. License: MIT Signed-off-by: rht This commit was moved from ipfs/kubo@de5c0ceff0857ee3ee4be85785b3253c0ef98c28 --- gateway/core/corehttp/gateway_handler.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 154db3b53..fccc10d0d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -367,8 +367,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { } } - err = i.node.DAG.AddRecursive(newnode) - if err != nil { + if err := i.node.DAG.AddRecursive(newnode); err != nil { webError(w, "Could not add recursively new node", err, http.StatusInternalServerError) return } @@ -439,8 +438,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { } } - err = i.node.DAG.AddRecursive(newnode) - if err != nil { + if err := i.node.DAG.AddRecursive(newnode); err != nil { webError(w, "Could not add recursively new node", err, http.StatusInternalServerError) return } From 9bf2279de31a84dd7bd7f9feffafcb3f9459ddb2 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 13 Aug 2015 11:44:10 -0700 Subject: [PATCH 087/674] replace nodebuilder with a nicer interface License: MIT Signed-off-by: Jeromy use NewNode instead of NewIPFSNode in most of the codebase License: MIT Signed-off-by: Jeromy make mocknet work with node constructor better License: MIT Signed-off-by: Jeromy finish cleanup of old construction method License: MIT Signed-off-by: Jeromy blockservice.New doesnt return an error anymore License: MIT Signed-off-by: Jeromy break up node construction into separate function License: MIT Signed-off-by: Jeromy add error case to default filling on node constructor License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@94000e64907f78406f9ed80e091b728bc608e284 --- gateway/core/corehttp/gateway_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index a90bd641e..e84c6f51c 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -47,7 +47,7 @@ func newNodeWithMockNamesys(ns mockNamesys) (*core.IpfsNode, error) { C: c, D: testutil.ThreadSafeCloserMapDatastore(), } - n, err := core.NewIPFSNode(context.Background(), core.Offline(r)) + n, err := core.NewNode(context.Background(), &core.BuildCfg{Repo: r}) if err != nil { return nil, err } From fd83424a245cb6b2db2d0c7a4e73b7c06a6e0e03 Mon Sep 17 00:00:00 2001 From: rht Date: Thu, 16 Jul 2015 16:40:29 +0700 Subject: [PATCH 088/674] Move dir-index-html + assets to a separate repo License: MIT Signed-off-by: rht This commit was moved from ipfs/kubo@4681db6f4c8a36e918dad2ee182d53409bba802f --- gateway/core/corehttp/gateway_indexPage.go | 168 ++++----------------- 1 file changed, 32 insertions(+), 136 deletions(-) diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index 79ad935b1..f6fa92f9e 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -1,8 +1,10 @@ package corehttp import ( + "github.com/ipfs/go-ipfs/assets" "html/template" "path" + "strings" ) // structs for directory listing @@ -18,143 +20,37 @@ type directoryItem struct { Path string } -// Directory listing template -var listingTemplate = template.Must(template.New("dir").Funcs(template.FuncMap{"iconFromExt": iconFromExt}).Parse(` - - - - - - - - - - {{ .Path }} - - - -
-
-
-
- Index of {{ .Path }} -
- - - - - - - {{ range .Listing }} - - - - - - {{ end }} -
-
 
-
- .. -
-
 
-
- {{ .Name }} - {{ .Size }} bytes
-
-
- - -`)) +var listingTemplate *template.Template -// helper to guess the type/icon for it by the extension name -func iconFromExt(name string) string { - ext := path.Ext(name) - _, ok := knownIcons[ext] - if !ok { - // default blank icon - return "ipfs-_blank" +func init() { + assetPath := "../vendor/src/QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7/dir-index-html/" + knownIconsBytes, err := assets.Asset(assetPath + "knownIcons.txt") + if err != nil { + panic(err) + } + knownIcons := make(map[string]struct{}) + for _, ext := range strings.Split(strings.TrimSuffix(string(knownIconsBytes), "\n"), "\n") { + knownIcons[ext] = struct{}{} + } + + // helper to guess the type/icon for it by the extension name + iconFromExt := func(name string) string { + ext := path.Ext(name) + _, ok := knownIcons[ext] + if !ok { + // default blank icon + return "ipfs-_blank" + } + return "ipfs-" + ext[1:] // slice of the first dot + } + + // Directory listing template + dirIndexBytes, err := assets.Asset(assetPath + "dir-index.html") + if err != nil { + panic(err) } - return "ipfs-" + ext[1:] // slice of the first dot -} -var knownIcons = map[string]bool{ - ".aac": true, - ".aiff": true, - ".ai": true, - ".avi": true, - ".bmp": true, - ".c": true, - ".cpp": true, - ".css": true, - ".dat": true, - ".dmg": true, - ".doc": true, - ".dotx": true, - ".dwg": true, - ".dxf": true, - ".eps": true, - ".exe": true, - ".flv": true, - ".gif": true, - ".h": true, - ".hpp": true, - ".html": true, - ".ics": true, - ".iso": true, - ".java": true, - ".jpg": true, - ".js": true, - ".key": true, - ".less": true, - ".mid": true, - ".mp3": true, - ".mp4": true, - ".mpg": true, - ".odf": true, - ".ods": true, - ".odt": true, - ".otp": true, - ".ots": true, - ".ott": true, - ".pdf": true, - ".php": true, - ".png": true, - ".ppt": true, - ".psd": true, - ".py": true, - ".qt": true, - ".rar": true, - ".rb": true, - ".rtf": true, - ".sass": true, - ".scss": true, - ".sql": true, - ".tga": true, - ".tgz": true, - ".tiff": true, - ".txt": true, - ".wav": true, - ".xls": true, - ".xlsx": true, - ".xml": true, - ".yml": true, - ".zip": true, + listingTemplate = template.Must(template.New("dir").Funcs(template.FuncMap{ + "iconFromExt": iconFromExt, + }).Parse(string(dirIndexBytes))) } From 795e454790ce175d64ffbdca2f803933263326f3 Mon Sep 17 00:00:00 2001 From: rht Date: Fri, 28 Aug 2015 20:01:16 +0700 Subject: [PATCH 089/674] Humanize bytes in dir index listing Fixes https://github.com/ipfs/dir-index-html/issues/3 License: MIT Signed-off-by: rht This commit was moved from ipfs/kubo@4b3a21ecebb34cfef4d8d088a265fbb7dada9e63 --- gateway/core/corehttp/gateway_handler.go | 3 ++- gateway/core/corehttp/gateway_indexPage.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index fccc10d0d..aa8dc32d3 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -9,6 +9,7 @@ import ( "strings" "time" + humanize "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/dustin/go-humanize" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" key "github.com/ipfs/go-ipfs/blocks/key" @@ -201,7 +202,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } // See comment above where originalUrlPath is declared. - di := directoryItem{link.Size, link.Name, gopath.Join(originalUrlPath, link.Name)} + di := directoryItem{humanize.Bytes(link.Size), link.Name, gopath.Join(originalUrlPath, link.Name)} dirListing = append(dirListing, di) } diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index f6fa92f9e..700b33d89 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -15,7 +15,7 @@ type listingTemplateData struct { } type directoryItem struct { - Size uint64 + Size string Name string Path string } @@ -23,7 +23,7 @@ type directoryItem struct { var listingTemplate *template.Template func init() { - assetPath := "../vendor/src/QmeNXKecZ7CQagtkQUJxG3yS7UcvU6puS777dQsx3amkS7/dir-index-html/" + assetPath := "../vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/" knownIconsBytes, err := assets.Asset(assetPath + "knownIcons.txt") if err != nil { panic(err) From db2fceb74996209d6cca69ee5b222e1ff43563ae Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 3 Sep 2015 09:28:36 -0700 Subject: [PATCH 090/674] fix panic caused by accessing config after repo closed License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@ab0c668ab8bb4bb91fa497a185debb5d29df6a77 --- gateway/core/corehttp/commands.go | 6 +++++- gateway/core/corehttp/gateway.go | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index e3a64f0f8..99f544905 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -107,8 +107,12 @@ func commandsOption(cctx commands.Context, command *commands.Command) ServeOptio AllowedMethods: []string{"GET", "POST", "PUT"}, }, } + rcfg, err := n.Repo.Config() + if err != nil { + return nil, err + } - addHeadersFromConfig(cfg, n.Repo.Config()) + addHeadersFromConfig(cfg, rcfg) addCORSFromEnv(cfg) addCORSDefaults(cfg) patchCORSVars(cfg, l.Addr()) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 584a89437..2aa95b951 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -30,7 +30,12 @@ func NewGateway(conf GatewayConfig) *Gateway { func (g *Gateway) ServeOption() ServeOption { return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { // pass user's HTTP headers - g.Config.Headers = n.Repo.Config().Gateway.HTTPHeaders + cfg, err := n.Repo.Config() + if err != nil { + return nil, err + } + + g.Config.Headers = cfg.Gateway.HTTPHeaders gateway, err := newGatewayHandler(n, g.Config) if err != nil { From 51e7b8cb66b36405c96aae9b8d0258321b62be12 Mon Sep 17 00:00:00 2001 From: rht Date: Fri, 4 Sep 2015 22:39:30 +0700 Subject: [PATCH 091/674] Bump version of dir-index-html Based on https://github.com/ipfs/go-ipfs/pull/1615 License: MIT Signed-off-by: rht This commit was moved from ipfs/kubo@8ec121239e3241071ddebe8e3574623e1fda3a06 --- gateway/core/corehttp/gateway_indexPage.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index 700b33d89..4485c84e6 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -1,10 +1,11 @@ package corehttp import ( - "github.com/ipfs/go-ipfs/assets" "html/template" "path" "strings" + + "github.com/ipfs/go-ipfs/assets" ) // structs for directory listing @@ -23,7 +24,7 @@ type directoryItem struct { var listingTemplate *template.Template func init() { - assetPath := "../vendor/src/QmeMZwyPnHMkvgdUNtdNcTX425gTCi5DCMeHLwTXbKoUB8/dir-index-html/" + assetPath := "../vendor/dir-index-html-v1.0.0/" knownIconsBytes, err := assets.Asset(assetPath + "knownIcons.txt") if err != nil { panic(err) From 84296c52d7d6ef14b74c9603c170b40cd4becc01 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 14 Sep 2015 17:33:03 -0700 Subject: [PATCH 092/674] extract logging License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@e5a2896c0eb64d3aad9bacec3f49c58f37a6b15b --- gateway/core/corehttp/corehttp.go | 4 ++-- gateway/core/corehttp/logs.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index dc221f3cd..9662c25f1 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -14,10 +14,10 @@ import ( manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess" core "github.com/ipfs/go-ipfs/core" - eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" + logging "github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0" ) -var log = eventlog.Logger("core/server") +var log = logging.Logger("core/server") // ServeOption registers any HTTP handlers it provides on the given mux. // It returns the mux to expose to future options, which may be a new mux if it diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 59b87b9bc..e0bcc3c6e 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - "github.com/ipfs/go-ipfs/thirdparty/eventlog" + logging "github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0" ) type writeErrNotifier struct { @@ -41,7 +41,7 @@ func LogOption() ServeOption { mux.HandleFunc("/logs", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) wnf, errs := newWriteErrNotifier(w) - eventlog.WriterGroup.AddWriter(wnf) + logging.WriterGroup.AddWriter(wnf) log.Event(n.Context(), "log API client connected") <-errs }) From fb4e24167b7a024fc5e541168450d52d4d495d66 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 30 Sep 2015 11:03:44 -0700 Subject: [PATCH 093/674] make publish more configurable and add test for repub License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@e5512b411532b93696ced59dff88b1f0d87ea331 --- gateway/core/corehttp/gateway_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index e84c6f51c..9c258cbae 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -7,6 +7,7 @@ import ( "net/http/httptest" "strings" "testing" + "time" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" core "github.com/ipfs/go-ipfs/core" @@ -37,6 +38,10 @@ func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value path.Pa return errors.New("not implemented for mockNamesys") } +func (m mockNamesys) PublishWithEOL(ctx context.Context, name ci.PrivKey, value path.Path, _ time.Time) error { + return errors.New("not implemented for mockNamesys") +} + func newNodeWithMockNamesys(ns mockNamesys) (*core.IpfsNode, error) { c := config.Config{ Identity: config.Identity{ From 02f82bd162ea082f27e8181b1d99ef0b9e20415e Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 1 Oct 2015 11:22:28 -0700 Subject: [PATCH 094/674] replace imports with absolute path instead of using symlink License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@8f0623255de22e1a00139ba07abd8e1f2f78e5f2 --- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/logs.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 9662c25f1..901afd91e 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -14,7 +14,7 @@ import ( manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess" core "github.com/ipfs/go-ipfs/core" - logging "github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0" + logging "github.com/ipfs/go-ipfs/vendor/QmXJkcEXB6C9h6Ytb6rrUTFU56Ro62zxgrbxTT3dgjQGA8/go-log" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index e0bcc3c6e..b16db8b7e 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - logging "github.com/ipfs/go-ipfs/vendor/go-log-v1.0.0" + logging "github.com/ipfs/go-ipfs/vendor/QmXJkcEXB6C9h6Ytb6rrUTFU56Ro62zxgrbxTT3dgjQGA8/go-log" ) type writeErrNotifier struct { From d3d0f554106a79a5815caf359c5842208fbfb0fc Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Mon, 5 Oct 2015 03:53:49 +0200 Subject: [PATCH 095/674] daemon: instrument the gateway and api HTTP handlers License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@dd20f4845477de3a38740135282986faff04173a --- gateway/core/corehttp/prometheus.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/prometheus.go b/gateway/core/corehttp/prometheus.go index 0642c04b5..2605e6cbe 100644 --- a/gateway/core/corehttp/prometheus.go +++ b/gateway/core/corehttp/prometheus.go @@ -11,7 +11,15 @@ import ( func PrometheusOption(path string) ServeOption { return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - mux.Handle(path, prom.Handler()) + mux.Handle(path, prom.UninstrumentedHandler()) return mux, nil } } + +func PrometheusCollectorOption(handlerName string) ServeOption { + return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { + childMux := http.NewServeMux() + mux.HandleFunc("/", prom.InstrumentHandler(handlerName, childMux)) + return childMux, nil + } +} From 179da572379d69e83520c253eabca390a032acde Mon Sep 17 00:00:00 2001 From: Artem Andreenko Date: Tue, 13 Oct 2015 01:09:55 +0300 Subject: [PATCH 096/674] fix races in http cors License: MIT Signed-off-by: Artem Andreenko This commit was moved from ipfs/kubo@45550858449935c831c037e5061912c7fb28175f --- gateway/core/corehttp/commands.go | 35 ++++++++++++++----------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 99f544905..882121c4e 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -7,8 +7,6 @@ import ( "strconv" "strings" - cors "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/rs/cors" - commands "github.com/ipfs/go-ipfs/commands" cmdsHttp "github.com/ipfs/go-ipfs/commands/http" core "github.com/ipfs/go-ipfs/core" @@ -41,10 +39,10 @@ func addCORSFromEnv(c *cmdsHttp.ServerConfig) { origin := os.Getenv(originEnvKey) if origin != "" { log.Warning(originEnvKeyDeprecate) - if c.CORSOpts == nil { - c.CORSOpts.AllowedOrigins = []string{origin} + if len(c.AllowedOrigins()) == 0 { + c.SetAllowedOrigins([]string{origin}...) } - c.CORSOpts.AllowedOrigins = append(c.CORSOpts.AllowedOrigins, origin) + c.AppendAllowedOrigins(origin) } } @@ -52,14 +50,14 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { log.Info("Using API.HTTPHeaders:", nc.API.HTTPHeaders) if acao := nc.API.HTTPHeaders[cmdsHttp.ACAOrigin]; acao != nil { - c.CORSOpts.AllowedOrigins = acao + c.SetAllowedOrigins(acao...) } if acam := nc.API.HTTPHeaders[cmdsHttp.ACAMethods]; acam != nil { - c.CORSOpts.AllowedMethods = acam + c.SetAllowedMethods(acam...) } if acac := nc.API.HTTPHeaders[cmdsHttp.ACACredentials]; acac != nil { for _, v := range acac { - c.CORSOpts.AllowCredentials = (strings.ToLower(v) == "true") + c.SetAllowCredentials(strings.ToLower(v) == "true") } } @@ -68,13 +66,13 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { func addCORSDefaults(c *cmdsHttp.ServerConfig) { // by default use localhost origins - if len(c.CORSOpts.AllowedOrigins) == 0 { - c.CORSOpts.AllowedOrigins = defaultLocalhostOrigins + if len(c.AllowedOrigins()) == 0 { + c.SetAllowedOrigins(defaultLocalhostOrigins...) } // by default, use GET, PUT, POST - if len(c.CORSOpts.AllowedMethods) == 0 { - c.CORSOpts.AllowedMethods = []string{"GET", "POST", "PUT"} + if len(c.AllowedMethods()) == 0 { + c.SetAllowedMethods("GET", "POST", "PUT") } } @@ -90,23 +88,22 @@ func patchCORSVars(c *cmdsHttp.ServerConfig, addr net.Addr) { } // we're listening on tcp/udp with ports. ("udp!?" you say? yeah... it happens...) - for i, o := range c.CORSOpts.AllowedOrigins { + origins := c.AllowedOrigins() + for i, o := range origins { // TODO: allow replacing . tricky, ip4 and ip6 and hostnames... if port != "" { o = strings.Replace(o, "", port, -1) } - c.CORSOpts.AllowedOrigins[i] = o + origins[i] = o } + c.SetAllowedOrigins(origins...) } func commandsOption(cctx commands.Context, command *commands.Command) ServeOption { return func(n *core.IpfsNode, l net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - cfg := &cmdsHttp.ServerConfig{ - CORSOpts: &cors.Options{ - AllowedMethods: []string{"GET", "POST", "PUT"}, - }, - } + cfg := cmdsHttp.NewServerConfig() + cfg.SetAllowedMethods("GET", "POST", "PUT") rcfg, err := n.Repo.Config() if err != nil { return nil, err From 157330b009522fbe8e715fde96c952b2bb462098 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 27 Oct 2015 10:47:32 -0700 Subject: [PATCH 097/674] update code to use new logging changes License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@c023d187b5f1f914ad11b23363a181a288ae83b1 --- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/logs.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 901afd91e..8df8eda19 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -14,7 +14,7 @@ import ( manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess" core "github.com/ipfs/go-ipfs/core" - logging "github.com/ipfs/go-ipfs/vendor/QmXJkcEXB6C9h6Ytb6rrUTFU56Ro62zxgrbxTT3dgjQGA8/go-log" + logging "github.com/ipfs/go-ipfs/vendor/QmTBXYb6y2ZcJmoXVKk3pf9rzSEjbCg7tQaJW7RSuH14nv/go-log" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index b16db8b7e..701179f7d 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - logging "github.com/ipfs/go-ipfs/vendor/QmXJkcEXB6C9h6Ytb6rrUTFU56Ro62zxgrbxTT3dgjQGA8/go-log" + logging "github.com/ipfs/go-ipfs/vendor/QmTBXYb6y2ZcJmoXVKk3pf9rzSEjbCg7tQaJW7RSuH14nv/go-log" ) type writeErrNotifier struct { From 12eb08720e3b2dc64de98538def9beb73879621d Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 22 Oct 2015 23:32:57 +0200 Subject: [PATCH 098/674] fixing putHandler for --writable http gateway I disabled this a long time ago and never refactored it. About time. License: MIT Signed-off-by: Henry This commit was moved from ipfs/kubo@b8b4e4566517e6c4647e25b1cf0bcbc196ff7ddb --- gateway/core/corehttp/gateway_handler.go | 130 +++++++++-------------- 1 file changed, 49 insertions(+), 81 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index aa8dc32d3..b95c7482f 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -6,6 +6,7 @@ import ( "io" "net/http" gopath "path" + "path/filepath" "strings" "time" @@ -17,6 +18,7 @@ import ( "github.com/ipfs/go-ipfs/importer" chunk "github.com/ipfs/go-ipfs/importer/chunk" dag "github.com/ipfs/go-ipfs/merkledag" + dagutils "github.com/ipfs/go-ipfs/merkledag/utils" path "github.com/ipfs/go-ipfs/path" "github.com/ipfs/go-ipfs/routing" uio "github.com/ipfs/go-ipfs/unixfs/io" @@ -273,116 +275,82 @@ func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, ipfsPathPrefix+k.String(), http.StatusCreated) } -func (i *gatewayHandler) putEmptyDirHandler(w http.ResponseWriter, r *http.Request) { - newnode := uio.NewEmptyDirectory() - - key, err := i.node.DAG.Add(newnode) +func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { + rootPath, err := path.ParsePath(r.URL.Path) if err != nil { - webError(w, "Could not recursively add new node", err, http.StatusInternalServerError) + webError(w, "putHandler: ipfs path not valid", err, http.StatusBadRequest) return } - i.addUserHeaders(w) // ok, _now_ write user's headers. - w.Header().Set("IPFS-Hash", key.String()) - http.Redirect(w, r, ipfsPathPrefix+key.String()+"/", http.StatusCreated) -} - -func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { - // TODO(cryptix): either ask mildred about the flow of this or rewrite it - webErrorWithCode(w, "Sorry, PUT is bugged right now, closing request", errors.New("handler disabled"), http.StatusInternalServerError) - return - urlPath := r.URL.Path - pathext := urlPath[5:] - var err error - if urlPath == ipfsPathPrefix+"QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/" { - i.putEmptyDirHandler(w, r) + rsegs := rootPath.Segments() + if rsegs[0] == ipnsPathPrefix { + webError(w, "putHandler: updating named entries not supported", errors.New("WritableGateway: ipns put not supported"), http.StatusBadRequest) return } var newnode *dag.Node - if pathext[len(pathext)-1] == '/' { + if rsegs[len(rsegs)-1] == "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" { newnode = uio.NewEmptyDirectory() } else { - newnode, err = i.newDagFromReader(r.Body) + putNode, err := i.newDagFromReader(r.Body) if err != nil { - webError(w, "Could not create DAG from request", err, http.StatusInternalServerError) + webError(w, "putHandler: Could not create DAG from request", err, http.StatusInternalServerError) return } + newnode = putNode } - ctx, cancel := context.WithCancel(i.node.Context()) - defer cancel() - - ipfsNode, err := core.Resolve(ctx, i.node, path.Path(urlPath)) - if err != nil { - // FIXME HTTP error code - webError(w, "Could not resolve name", err, http.StatusInternalServerError) - return - } - - k, err := ipfsNode.Key() - if err != nil { - webError(w, "Could not get key from resolved node", err, http.StatusInternalServerError) - return - } - - h, components, err := path.SplitAbsPath(path.FromKey(k)) - if err != nil { - webError(w, "Could not split path", err, http.StatusInternalServerError) - return + var newPath string + if len(rsegs) > 1 { + newPath = strings.Join(rsegs[2:], "/") } - if len(components) < 1 { - err = fmt.Errorf("Cannot override existing object") - webError(w, "http gateway", err, http.StatusBadRequest) - return - } - - tctx, cancel := context.WithTimeout(ctx, time.Minute) - defer cancel() - // TODO(cryptix): could this be core.Resolve() too? - rootnd, err := i.node.Resolver.DAG.Get(tctx, key.Key(h)) - if err != nil { - webError(w, "Could not resolve root object", err, http.StatusBadRequest) - return - } + var newkey key.Key + rnode, err := core.Resolve(i.node.Context(), i.node, rootPath) + switch ev := err.(type) { + case path.ErrNoLink: + // ev.Node < node where resolve failed + // ev.Name < new link + // but we need to patch from the root + rnode, err := i.node.DAG.Get(i.node.Context(), key.B58KeyDecode(rsegs[1])) + if err != nil { + webError(w, "putHandler: Could not create DAG from request", err, http.StatusInternalServerError) + return + } - // resolving path components into merkledag nodes. if a component does not - // resolve, create empty directories (which will be linked and populated below.) - pathNodes, err := i.node.Resolver.ResolveLinks(tctx, rootnd, components[:len(components)-1]) - if _, ok := err.(path.ErrNoLink); ok { - // Create empty directories, links will be made further down the code - for len(pathNodes) < len(components) { - pathNodes = append(pathNodes, uio.NewDirectory(i.node.DAG).GetNode()) + e := dagutils.NewDagEditor(i.node.DAG, rnode) + err = e.InsertNodeAtPath(i.node.Context(), newPath, newnode, uio.NewEmptyDirectory) + if err != nil { + webError(w, "putHandler: InsertNodeAtPath failed", err, http.StatusInternalServerError) + return } - } else if err != nil { - webError(w, "Could not resolve parent object", err, http.StatusBadRequest) - return - } - for i := len(pathNodes) - 1; i >= 0; i-- { - newnode, err = pathNodes[i].UpdateNodeLink(components[i], newnode) + newkey, err = e.GetNode().Key() if err != nil { - webError(w, "Could not update node links", err, http.StatusInternalServerError) + webError(w, "putHandler: could not get key of edited node", err, http.StatusInternalServerError) return } - } - if err := i.node.DAG.AddRecursive(newnode); err != nil { - webError(w, "Could not add recursively new node", err, http.StatusInternalServerError) - return - } + case nil: + // object set-data case + rnode.Data = newnode.Data - // Redirect to new path - key, err := newnode.Key() - if err != nil { - webError(w, "Could not get key of new node", err, http.StatusInternalServerError) + newkey, err = i.node.DAG.Add(rnode) + if err != nil { + nnk, _ := newnode.Key() + rk, _ := rnode.Key() + webError(w, fmt.Sprintf("putHandler: Could not add newnode(%q) to root(%q)", nnk.B58String(), rk.B58String()), err, http.StatusInternalServerError) + return + } + default: + log.Warningf("putHandler: unhandled resolve error %T", ev) + webError(w, "could not resolve root DAG", ev, http.StatusInternalServerError) return } i.addUserHeaders(w) // ok, _now_ write user's headers. - w.Header().Set("IPFS-Hash", key.String()) - http.Redirect(w, r, ipfsPathPrefix+key.String()+"/"+strings.Join(components, "/"), http.StatusCreated) + w.Header().Set("IPFS-Hash", newkey.String()) + http.Redirect(w, r, filepath.Join(ipfsPathPrefix, newkey.String(), newPath), http.StatusCreated) } func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { From 877b1c039e1440e562985ae27905cb0883084c32 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 31 Oct 2015 01:32:11 +0100 Subject: [PATCH 099/674] putHandler: addressed CR from @jbenet License: MIT Signed-off-by: Henry This commit was moved from ipfs/kubo@c1847e9f693e716a54e0223e44729c76ef64308b --- gateway/core/corehttp/gateway_handler.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index b95c7482f..d9864c051 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -6,7 +6,6 @@ import ( "io" "net/http" gopath "path" - "path/filepath" "strings" "time" @@ -276,6 +275,10 @@ func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { } func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { + // TODO(cryptix): move me to ServeHTTP and pass into all handlers + ctx, cancel := context.WithCancel(i.node.Context()) + defer cancel() + rootPath, err := path.ParsePath(r.URL.Path) if err != nil { webError(w, "putHandler: ipfs path not valid", err, http.StatusBadRequest) @@ -306,20 +309,20 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { } var newkey key.Key - rnode, err := core.Resolve(i.node.Context(), i.node, rootPath) + rnode, err := core.Resolve(ctx, i.node, rootPath) switch ev := err.(type) { case path.ErrNoLink: // ev.Node < node where resolve failed // ev.Name < new link // but we need to patch from the root - rnode, err := i.node.DAG.Get(i.node.Context(), key.B58KeyDecode(rsegs[1])) + rnode, err := i.node.DAG.Get(ctx, key.B58KeyDecode(rsegs[1])) if err != nil { webError(w, "putHandler: Could not create DAG from request", err, http.StatusInternalServerError) return } e := dagutils.NewDagEditor(i.node.DAG, rnode) - err = e.InsertNodeAtPath(i.node.Context(), newPath, newnode, uio.NewEmptyDirectory) + err = e.InsertNodeAtPath(ctx, newPath, newnode, uio.NewEmptyDirectory) if err != nil { webError(w, "putHandler: InsertNodeAtPath failed", err, http.StatusInternalServerError) return @@ -350,7 +353,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("IPFS-Hash", newkey.String()) - http.Redirect(w, r, filepath.Join(ipfsPathPrefix, newkey.String(), newPath), http.StatusCreated) + http.Redirect(w, r, gopath.Join(ipfsPathPrefix, newkey.String(), newPath), http.StatusCreated) } func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { From 3e503babadc2400df3a43cdb61f6e0d78401ed3d Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Sat, 31 Oct 2015 01:22:42 -0400 Subject: [PATCH 100/674] webui updated to disable logs to: /ipfs/QmR9MzChjp1MdFWik7NjEjqKQMzVmBkdK3dz14A6B5Cupm https://github.com/ipfs/webui/pull/91 License: MIT Signed-off-by: Juan Batiz-Benet This commit was moved from ipfs/kubo@b675bfc5959bb5d58a1721a2ff6db2108ebfd2ba --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index a125b4331..5705fe0d3 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmS2HL9v5YeKgQkkWMvs1EMnFtUowTEdFfSSeMT4pos1e6" +const WebUIPath = "/ipfs/QmR9MzChjp1MdFWik7NjEjqKQMzVmBkdK3dz14A6B5Cupm" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -11,6 +11,7 @@ var WebUIPaths = []string{ "/ipfs/QmaaqrHyAQm7gALkRW8DcfGX3u8q9rWKnxEMmf7m9z515w", "/ipfs/QmSHDxWsMPuJQKWmVA1rB5a3NX2Eme5fPqNb63qwaqiqSp", "/ipfs/QmctngrQAt9fjpQUZr7Bx3BsXUcif52eZGTizWhvcShsjz", + "/ipfs/QmS2HL9v5YeKgQkkWMvs1EMnFtUowTEdFfSSeMT4pos1e6", } var WebUIOption = RedirectOption("webui", WebUIPath) From 0dc3e4415fdf44e816275c67855d78052c5959e7 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 29 Oct 2015 21:22:53 -0700 Subject: [PATCH 101/674] vendor logging lib update License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@94bdce63a7d51e7ffee09fdbb6a5fa4d47ae1c6f --- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/logs.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 8df8eda19..155f532a4 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -14,7 +14,7 @@ import ( manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess" core "github.com/ipfs/go-ipfs/core" - logging "github.com/ipfs/go-ipfs/vendor/QmTBXYb6y2ZcJmoXVKk3pf9rzSEjbCg7tQaJW7RSuH14nv/go-log" + logging "github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 701179f7d..e5c67ace5 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - logging "github.com/ipfs/go-ipfs/vendor/QmTBXYb6y2ZcJmoXVKk3pf9rzSEjbCg7tQaJW7RSuH14nv/go-log" + logging "github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log" ) type writeErrNotifier struct { From 24824ad2f3fece975047f1923607aac5531ff6cf Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 29 Oct 2015 21:26:12 -0700 Subject: [PATCH 102/674] fix log hanging issue, and implement close-notify for commands License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@2f5563b3c0059c7bec1ab3896fe7e62315083b21 --- gateway/core/corehttp/logs.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index e5c67ace5..6964a2f79 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -14,7 +14,7 @@ type writeErrNotifier struct { errs chan error } -func newWriteErrNotifier(w io.Writer) (io.Writer, <-chan error) { +func newWriteErrNotifier(w io.Writer) (io.WriteCloser, <-chan error) { ch := make(chan error, 1) return &writeErrNotifier{ w: w, @@ -36,6 +36,14 @@ func (w *writeErrNotifier) Write(b []byte) (int, error) { return n, err } +func (w *writeErrNotifier) Close() error { + select { + case w.errs <- io.EOF: + default: + } + return nil +} + func LogOption() ServeOption { return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/logs", func(w http.ResponseWriter, r *http.Request) { From 8249f305af7647b3eec4453db21ee7ec7c52218c Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Mon, 16 Nov 2015 07:00:14 +0100 Subject: [PATCH 103/674] gateway: add path prefix for directory listings License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@021ef4341854cb364d8f23649427efc38087dd4f --- gateway/core/corehttp/gateway_handler.go | 20 +++++--- gateway/core/corehttp/gateway_test.go | 59 +++++++++++++++++++++++- gateway/core/corehttp/ipns_hostname.go | 2 +- 3 files changed, 72 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d9864c051..59c57e437 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -92,16 +92,24 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request urlPath := r.URL.Path + // If the gateway is behind a reverse proxy and mounted at a sub-path, + // the prefix header can be set to signal this sub-path. + // It will be prepended to links in directory listings and the index.html redirect. + prefix := "" + if prefixHdr := r.Header["X-Ipfs-Gateway-Prefix"]; len(prefixHdr) > 0 { + log.Debugf("X-Ipfs-Gateway-Prefix: %s", prefixHdr[0]) + prefix = prefixHdr[0] + } + // IPNSHostnameOption might have constructed an IPNS path using the Host header. // In this case, we need the original path for constructing redirects // and links that match the requested URL. // For example, http://example.net would become /ipns/example.net, and // the redirects and links would end up as http://example.net/ipns/example.net - originalUrlPath := urlPath + originalUrlPath := prefix + urlPath ipnsHostname := false - hdr := r.Header["X-IPNS-Original-Path"] - if len(hdr) > 0 { - originalUrlPath = hdr[0] + if hdr := r.Header["X-Ipns-Original-Path"]; len(hdr) > 0 { + originalUrlPath = prefix + hdr[0] ipnsHostname = true } @@ -211,7 +219,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request if r.Method != "HEAD" { // construct the correct back link // https://github.com/ipfs/go-ipfs/issues/1365 - var backLink string = urlPath + var backLink string = prefix + urlPath // don't go further up than /ipfs/$hash/ pathSplit := strings.Split(backLink, "/") @@ -233,7 +241,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // strip /ipfs/$hash from backlink if IPNSHostnameOption touched the path. if ipnsHostname { - backLink = "/" + backLink = prefix + "/" if len(pathSplit) > 5 { // also strip the trailing segment, because it's a backlink backLinkParts := pathSplit[3 : len(pathSplit)-2] diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 9c258cbae..75b7120e3 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -213,6 +213,30 @@ func TestIPNSHostnameRedirect(t *testing.T) { } else if hdr[0] != "/foo/" { t.Errorf("location header is %v, expected /foo/", hdr[0]) } + + // make request with prefix to directory containing index.html + req, err = http.NewRequest("GET", ts.URL+"/foo", nil) + if err != nil { + t.Fatal(err) + } + req.Host = "example.net" + req.Header.Set("X-Ipfs-Gateway-Prefix", "/prefix") + + res, err = doWithoutRedirect(req) + if err != nil { + t.Fatal(err) + } + + // expect 302 redirect to same path, but with prefix and trailing slash + if res.StatusCode != 302 { + t.Errorf("status is %d, expected 302", res.StatusCode) + } + hdr = res.Header["Location"] + if len(hdr) < 1 { + t.Errorf("location header not present") + } else if hdr[0] != "/prefix/foo/" { + t.Errorf("location header is %v, expected /prefix/foo/", hdr[0]) + } } func TestIPNSHostnameBacklinks(t *testing.T) { @@ -282,7 +306,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { t.Fatalf("expected file in directory listing") } - // make request to directory listing + // make request to directory listing at root req, err = http.NewRequest("GET", ts.URL, nil) if err != nil { t.Fatal(err) @@ -294,7 +318,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { t.Fatal(err) } - // expect correct backlinks + // expect correct backlinks at root body, err = ioutil.ReadAll(res.Body) if err != nil { t.Fatalf("error reading response: %s", err) @@ -341,4 +365,35 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "
") { t.Fatalf("expected file in directory listing") } + + // make request to directory listing with prefix + req, err = http.NewRequest("GET", ts.URL, nil) + if err != nil { + t.Fatal(err) + } + req.Host = "example.net" + req.Header.Set("X-Ipfs-Gateway-Prefix", "/prefix") + + res, err = doWithoutRedirect(req) + if err != nil { + t.Fatal(err) + } + + // expect correct backlinks with prefix + body, err = ioutil.ReadAll(res.Body) + if err != nil { + t.Fatalf("error reading response: %s", err) + } + s = string(body) + t.Logf("body: %s\n", string(body)) + + if !strings.Contains(s, "Index of /prefix") { + t.Fatalf("expected a path in directory listing") + } + if !strings.Contains(s, "") { + t.Fatalf("expected backlink in directory listing") + } + if !strings.Contains(s, "") { + t.Fatalf("expected file in directory listing") + } } diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 94faccd5d..dd6a64d5f 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -24,7 +24,7 @@ func IPNSHostnameOption() ServeOption { if len(host) > 0 && isd.IsDomain(host) { name := "/ipns/" + host if _, err := n.Namesys.Resolve(ctx, name); err == nil { - r.Header["X-IPNS-Original-Path"] = []string{r.URL.Path} + r.Header["X-Ipns-Original-Path"] = []string{r.URL.Path} r.URL.Path = name + r.URL.Path } } From e87365bbe998bea09e96bc434aa624fc07e62ed2 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Tue, 24 Nov 2015 00:59:19 +0100 Subject: [PATCH 104/674] gateway: add tests for /version License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@8ab0ddfe44b709b111544aff3105b0506de00202 --- gateway/core/corehttp/gateway_test.go | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 75b7120e3..935085aaf 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -14,6 +14,7 @@ import ( coreunix "github.com/ipfs/go-ipfs/core/coreunix" namesys "github.com/ipfs/go-ipfs/namesys" ci "github.com/ipfs/go-ipfs/p2p/crypto" + id "github.com/ipfs/go-ipfs/p2p/protocol/identify" path "github.com/ipfs/go-ipfs/path" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" @@ -95,6 +96,7 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, *core dh.Handler, err = makeHandler(n, ts.Listener, + VersionOption(), IPNSHostnameOption(), GatewayOption(false), ) @@ -397,3 +399,33 @@ func TestIPNSHostnameBacklinks(t *testing.T) { t.Fatalf("expected file in directory listing") } } + +func TestVersion(t *testing.T) { + ns := mockNamesys{} + ts, _ := newTestServerAndNode(t, ns) + t.Logf("test server url: %s", ts.URL) + defer ts.Close() + + req, err := http.NewRequest("GET", ts.URL+"/version", nil) + if err != nil { + t.Fatal(err) + } + + res, err := doWithoutRedirect(req) + if err != nil { + t.Fatal(err) + } + body, err := ioutil.ReadAll(res.Body) + if err != nil { + t.Fatalf("error reading response: %s", err) + } + s := string(body) + + if !strings.Contains(s, "Client Version: "+id.ClientVersion) { + t.Fatalf("response doesn't contain client version:\n%s", s) + } + + if !strings.Contains(s, "Protocol Version: "+id.IpfsVersion) { + t.Fatalf("response doesn't contain protocol version:\n%s", s) + } +} From c194aa81f00f9af6d6b994c7b7f1226f824c6897 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Tue, 24 Nov 2015 00:59:51 +0100 Subject: [PATCH 105/674] gateway: add CurrentCommit to /version License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@3e03ae8f77f13c933471e2d032474c11a5dc8daf --- gateway/core/corehttp/gateway.go | 4 +++- gateway/core/corehttp/gateway_test.go | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 2aa95b951..e5d6569a7 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,6 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" id "github.com/ipfs/go-ipfs/p2p/protocol/identify" + config "github.com/ipfs/go-ipfs/repo/config" ) // Gateway should be instantiated using NewGateway @@ -58,7 +59,8 @@ func GatewayOption(writable bool) ServeOption { func VersionOption() ServeOption { return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion) + fmt.Fprintf(w, "Commit: %s\n", config.CurrentCommit) + fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion) fmt.Fprintf(w, "Protocol Version: %s\n", id.IpfsVersion) }) return mux, nil diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 935085aaf..ffc49c604 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -401,6 +401,8 @@ func TestIPNSHostnameBacklinks(t *testing.T) { } func TestVersion(t *testing.T) { + config.CurrentCommit = "theshortcommithash" + ns := mockNamesys{} ts, _ := newTestServerAndNode(t, ns) t.Logf("test server url: %s", ts.URL) @@ -421,6 +423,10 @@ func TestVersion(t *testing.T) { } s := string(body) + if !strings.Contains(s, "Commit: theshortcommithash") { + t.Fatalf("response doesn't contain commit:\n%s", s) + } + if !strings.Contains(s, "Client Version: "+id.ClientVersion) { t.Fatalf("response doesn't contain client version:\n%s", s) } From 7a4aa46bdea690ae93d731860d0f43d0895f4825 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 30 Nov 2015 14:43:37 -0800 Subject: [PATCH 106/674] hard code things License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@bdc1b27c51ff3dc7b465c8c5c0a98b97ae6454dc --- gateway/core/corehttp/gateway_handler.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 59c57e437..8cb6dc0f8 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -134,6 +134,11 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("X-IPFS-Path", urlPath) + // set 'allowed' headers + w.Header().Set("Access-Control-Allow-Headers", "X-Stream-Output, X-Chunked-Output") + // expose those headers + w.Header().Set("Access-Control-Expose-Headers", "X-Stream-Output, X-Chunked-Output") + // Suborigin header, sandboxes apps from each other in the browser (even // though they are served from the same gateway domain). // From ded484d2d422e5b1e00436869cf991ee38d3681e Mon Sep 17 00:00:00 2001 From: Dominic Della Valle Date: Mon, 2 Nov 2015 16:08:39 -0500 Subject: [PATCH 107/674] Fix path parsing for add command License: MIT Signed-off-by: Dominic Della Valle This commit was moved from ipfs/kubo@a6eb32b77c3d4d205b9b3a397984efb878d77b4f --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 8cb6dc0f8..509e751de 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -174,7 +174,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request if err == nil { defer dr.Close() - _, name := gopath.Split(urlPath) + name := gopath.Base(urlPath) http.ServeContent(w, r, name, modtime, dr) return } From 1c8fcd9491c5a7415ecf67b8b9469c978a80f64b Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 2 Dec 2015 20:48:37 -0800 Subject: [PATCH 108/674] fixup panic catching in http handler funcs License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@8ad1141436dbb795e2b545378527e6f7ad96685e --- gateway/core/corehttp/gateway_handler.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 509e751de..1cc172e50 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -6,6 +6,7 @@ import ( "io" "net/http" gopath "path" + "runtime/debug" "strings" "time" @@ -55,6 +56,14 @@ func (i *gatewayHandler) newDagFromReader(r io.Reader) (*dag.Node, error) { // TODO(btc): break this apart into separate handlers using a more expressive muxer func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + defer func() { + if r := recover(); r != nil { + log.Error("A panic occurred in the gateway handler!") + log.Error(r) + debug.PrintStack() + } + }() + if i.config.Writable { switch r.Method { case "POST": From d2d01cf0b648ceb11269f711f68e1f32a838b919 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Tue, 12 Jan 2016 16:41:16 +0100 Subject: [PATCH 109/674] feat: Update to the latest version of the webui License: MIT Signed-off-by: Friedel Ziegelmayer This commit was moved from ipfs/kubo@ab61ef2024b7d3a8f6def6676e9fd1ef4135c0b2 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 5705fe0d3..db08731a9 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmR9MzChjp1MdFWik7NjEjqKQMzVmBkdK3dz14A6B5Cupm" +const WebUIPath = "/ipfs/QmRyWyKWmphamkMRnJVjUTzSFSAAZowYP4rnbgnfMXC9Mr" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -12,6 +12,7 @@ var WebUIPaths = []string{ "/ipfs/QmSHDxWsMPuJQKWmVA1rB5a3NX2Eme5fPqNb63qwaqiqSp", "/ipfs/QmctngrQAt9fjpQUZr7Bx3BsXUcif52eZGTizWhvcShsjz", "/ipfs/QmS2HL9v5YeKgQkkWMvs1EMnFtUowTEdFfSSeMT4pos1e6", + "/ipfs/QmR9MzChjp1MdFWik7NjEjqKQMzVmBkdK3dz14A6B5Cupm", } var WebUIOption = RedirectOption("webui", WebUIPath) From 6f9aa3c6f983790c32ac3ba4e7ebe2df2ec1ee0d Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Fri, 8 May 2015 11:00:55 -0700 Subject: [PATCH 110/674] Simplify Pinner interface by folding ManualPinner into Pinner Pinner had method GetManual that returned a ManualPinner, so every Pinner had to implement ManualPinner anyway. License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@c9ce2e724a34d18cca84d89ddd6c6c08bd445b11 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1cc172e50..4b5526a66 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -51,7 +51,7 @@ func (i *gatewayHandler) newDagFromReader(r io.Reader) (*dag.Node, error) { return importer.BuildDagFromReader( i.node.DAG, chunk.DefaultSplitter(r), - importer.BasicPinnerCB(i.node.Pinning.GetManual())) + importer.BasicPinnerCB(i.node.Pinning)) } // TODO(btc): break this apart into separate handlers using a more expressive muxer From 40d20efa8775c7f1b943111e24d33406484c7549 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 23 Jun 2015 16:01:32 -0700 Subject: [PATCH 111/674] implement mark and sweep GC License: MIT Signed-off-by: Jeromy dont GC blocks used by pinner License: MIT Signed-off-by: Jeromy comment GC algo License: MIT Signed-off-by: Jeromy add lock to blockstore to prevent GC from eating wanted blocks License: MIT Signed-off-by: Jeromy improve FetchGraph License: MIT Signed-off-by: Jeromy separate interfaces for blockstore and GCBlockstore License: MIT Signed-off-by: Jeromy reintroduce indirect pinning, add enumerateChildren dag method License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@b12ee40abaee684979198dbcaa39b8e31267648b --- gateway/core/corehttp/gateway_handler.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 4b5526a66..224f405d6 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -50,8 +50,7 @@ func (i *gatewayHandler) newDagFromReader(r io.Reader) (*dag.Node, error) { // return ufs.AddFromReader(i.node, r.Body) return importer.BuildDagFromReader( i.node.DAG, - chunk.DefaultSplitter(r), - importer.BasicPinnerCB(i.node.Pinning)) + chunk.DefaultSplitter(r)) } // TODO(btc): break this apart into separate handlers using a more expressive muxer From 58169e45501a70318eab94acc8bb283e9ec59e68 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 13 Nov 2015 10:19:47 -0800 Subject: [PATCH 112/674] rework editor creation and finalization License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@efac042e82e3b6d1574ecb70b1c2db0f59fe5f08 --- gateway/core/corehttp/gateway_handler.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 224f405d6..026896ab5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -342,14 +342,20 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } - e := dagutils.NewDagEditor(i.node.DAG, rnode) + e := dagutils.NewDagEditor(rnode, i.node.DAG) err = e.InsertNodeAtPath(ctx, newPath, newnode, uio.NewEmptyDirectory) if err != nil { webError(w, "putHandler: InsertNodeAtPath failed", err, http.StatusInternalServerError) return } - newkey, err = e.GetNode().Key() + nnode, err := e.Finalize(i.node.DAG) + if err != nil { + webError(w, "putHandler: could not get node", err, http.StatusInternalServerError) + return + } + + newkey, err = nnode.Key() if err != nil { webError(w, "putHandler: could not get key of edited node", err, http.StatusInternalServerError) return From f4d2e3adec11e4b9f7a5a579879d4aa379b57d6b Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 19 Nov 2015 15:28:33 -0800 Subject: [PATCH 113/674] add closenotify and large timeout to gateway License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@bf955f35601e84989835fbf430e8e26b3e8f29a8 --- gateway/core/corehttp/gateway_handler.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 026896ab5..4eb9255fe 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -95,9 +95,20 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) { - ctx, cancel := context.WithCancel(i.node.Context()) + ctx, cancel := context.WithTimeout(i.node.Context(), time.Hour) + // the hour is a hard fallback, we don't expect it to happen, but just in case defer cancel() + if cn, ok := w.(http.CloseNotifier); ok { + go func() { + select { + case <-cn.CloseNotify(): + case <-ctx.Done(): + } + cancel() + }() + } + urlPath := r.URL.Path // If the gateway is behind a reverse proxy and mounted at a sub-path, From 8a8144dbfd420bc14e3eb8e96179765509a50d82 Mon Sep 17 00:00:00 2001 From: rht Date: Tue, 17 Nov 2015 15:36:48 +0700 Subject: [PATCH 114/674] Replace strings.Join(elms, "/") with path.Join(elms) License: MIT Signed-off-by: rht This commit was moved from ipfs/kubo@ffd859232d82561e49662a95a67bb297933e6d07 --- gateway/core/corehttp/gateway_handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 4eb9255fe..24fedd1fd 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -269,7 +269,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request if len(pathSplit) > 5 { // also strip the trailing segment, because it's a backlink backLinkParts := pathSplit[3 : len(pathSplit)-2] - backLink += strings.Join(backLinkParts, "/") + "/" + backLink += path.Join(backLinkParts) + "/" } } @@ -337,7 +337,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { var newPath string if len(rsegs) > 1 { - newPath = strings.Join(rsegs[2:], "/") + newPath = path.Join(rsegs[2:]) } var newkey key.Key @@ -462,7 +462,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("IPFS-Hash", key.String()) - http.Redirect(w, r, ipfsPathPrefix+key.String()+"/"+strings.Join(components[:len(components)-1], "/"), http.StatusCreated) + http.Redirect(w, r, gopath.Join(ipfsPathPrefix+key.String(), path.Join(components[:len(components)-1])), http.StatusCreated) } func (i *gatewayHandler) addUserHeaders(w http.ResponseWriter) { From f05d09c427097125d919fe81345089e01e8911bb Mon Sep 17 00:00:00 2001 From: rht Date: Tue, 24 Nov 2015 13:59:34 +0700 Subject: [PATCH 115/674] strings.Split -> path.SplitList License: MIT Signed-off-by: rht This commit was moved from ipfs/kubo@743f3edcbb261d5cd889d037d79fdf0a8b4e7dad --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 24fedd1fd..1bb03ec00 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -246,7 +246,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request var backLink string = prefix + urlPath // don't go further up than /ipfs/$hash/ - pathSplit := strings.Split(backLink, "/") + pathSplit := path.SplitList(backLink) switch { // keep backlink case len(pathSplit) == 3: // url: /ipfs/$hash From de161cd62c0b5708bcfedd3b9b08cacac8f85c4d Mon Sep 17 00:00:00 2001 From: Etienne Laurin Date: Thu, 26 Nov 2015 03:08:12 +0000 Subject: [PATCH 116/674] use ServeContent for index.html One advantage is that it sets the Content-Type header correctly. License: MIT Signed-off-by: Etienne Laurin This commit was moved from ipfs/kubo@a83c3a334f116ceacba37ee3cb37e0e849ec07e3 --- gateway/core/corehttp/gateway_handler.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1bb03ec00..3d8baf826 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -228,9 +228,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request defer dr.Close() // write to request - if r.Method != "HEAD" { - io.Copy(w, dr) - } + http.ServeContent(w, r, "index.html", modtime, dr) break } From d7ea08d8dc8692fa7883d60e3a79c8b234c6f1eb Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 21 Jan 2016 23:05:18 +0100 Subject: [PATCH 117/674] Gateway: add support for HTTP OPTIONS request type OPTIONS is a noop request that is used by the browsers to check if server will accept cross-site XMLHttpRequest (indicated by the presence of CORS headers) Before this fix user could enable CORS headers in the Gateway config, but XHR failed due to the lack of support for OPTIONS request type (as described in https://git.io/vzgGe) License: MIT Signed-off-by: Marcin Rataj This commit was moved from ipfs/kubo@8651143344fc14e5157635b5be84c86f63002440 --- gateway/core/corehttp/gateway_handler.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 3d8baf826..ddabc474d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -82,6 +82,11 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } + if r.Method == "OPTIONS" { + i.optionsHandler(w, r) + return + } + errmsg := "Method " + r.Method + " not allowed: " if !i.config.Writable { w.WriteHeader(http.StatusMethodNotAllowed) @@ -94,6 +99,15 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { log.Error(errmsg) // TODO(cryptix): log errors until we have a better way to expose these (counter metrics maybe) } +func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request) { + /* + OPTIONS is a noop request that is used by the browsers to check + if server accepts cross-site XMLHttpRequest (indicated by the presence of CORS headers) + https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Preflighted_requests + */ + i.addUserHeaders(w) // return all custom headers (including CORS ones, if set) +} + func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) { ctx, cancel := context.WithTimeout(i.node.Context(), time.Hour) // the hour is a hard fallback, we don't expect it to happen, but just in case From 6ab7a87f0ce9b935c063fff5e35ebb50e0f6c8c5 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 27 Jan 2016 14:28:34 -0800 Subject: [PATCH 118/674] initial vendoring of libp2p outside of the repo with gx License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@0e312f5caff049073b3a6d8c9ff693c3c7389495 --- gateway/core/corehttp/corehttp.go | 6 +++--- gateway/core/corehttp/gateway.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 8 ++++---- gateway/core/corehttp/ipns_hostname.go | 2 +- gateway/core/corehttp/logs.go | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 155f532a4..cfccd7bc4 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -10,11 +10,11 @@ import ( "net/http" "time" - ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" - manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" + ma "gx/ipfs/QmR3JkmZBKYXgNMNsNZawm914455Qof3PEopwuVSeXG7aV/go-multiaddr" + manet "gx/ipfs/QmYtzQmUwPFGxjCXctJ8e6GXS8sYfoXy2pdeMbS5SFWqRi/go-multiaddr-net" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess" core "github.com/ipfs/go-ipfs/core" - logging "github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log" + logging "gx/ipfs/QmaPaGNE2GqnfJjRRpQuQuFHuJn4FZvsrGxdik4kgxCkBi/go-log" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index e5d6569a7..072e90765 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,8 +7,8 @@ import ( "sync" core "github.com/ipfs/go-ipfs/core" - id "github.com/ipfs/go-ipfs/p2p/protocol/identify" config "github.com/ipfs/go-ipfs/repo/config" + id "gx/ipfs/QmY3NAw959vbE1oJooP9HchcRdBsbxhgQsEZTRhKgvoSuC/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway @@ -61,7 +61,7 @@ func VersionOption() ServeOption { mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Commit: %s\n", config.CurrentCommit) fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion) - fmt.Fprintf(w, "Protocol Version: %s\n", id.IpfsVersion) + fmt.Fprintf(w, "Protocol Version: %s\n", id.LibP2PVersion) }) return mux, nil } diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ddabc474d..ebf0b3c6e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -11,7 +11,7 @@ import ( "time" humanize "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/dustin/go-humanize" - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" + "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" key "github.com/ipfs/go-ipfs/blocks/key" core "github.com/ipfs/go-ipfs/core" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index ffc49c604..229757191 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -9,16 +9,16 @@ import ( "testing" "time" - context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" core "github.com/ipfs/go-ipfs/core" coreunix "github.com/ipfs/go-ipfs/core/coreunix" namesys "github.com/ipfs/go-ipfs/namesys" - ci "github.com/ipfs/go-ipfs/p2p/crypto" - id "github.com/ipfs/go-ipfs/p2p/protocol/identify" path "github.com/ipfs/go-ipfs/path" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/util/testutil" + ci "gx/ipfs/QmY3NAw959vbE1oJooP9HchcRdBsbxhgQsEZTRhKgvoSuC/go-libp2p/p2p/crypto" + id "gx/ipfs/QmY3NAw959vbE1oJooP9HchcRdBsbxhgQsEZTRhKgvoSuC/go-libp2p/p2p/protocol/identify" + context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) type mockNamesys map[string]path.Path @@ -431,7 +431,7 @@ func TestVersion(t *testing.T) { t.Fatalf("response doesn't contain client version:\n%s", s) } - if !strings.Contains(s, "Protocol Version: "+id.IpfsVersion) { + if !strings.Contains(s, "Protocol Version: "+id.LibP2PVersion) { t.Fatalf("response doesn't contain protocol version:\n%s", s) } } diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index dd6a64d5f..3e768fa45 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -6,7 +6,7 @@ import ( "strings" isd "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-is-domain" - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" + "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" "github.com/ipfs/go-ipfs/core" ) diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 6964a2f79..11a7223b4 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - logging "github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log" + logging "gx/ipfs/QmaPaGNE2GqnfJjRRpQuQuFHuJn4FZvsrGxdik4kgxCkBi/go-log" ) type writeErrNotifier struct { From 7dac99fd18ea1da266ec798fc39d5775b0311cd7 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 28 Jan 2016 09:43:06 -0800 Subject: [PATCH 119/674] go-keyspace dep from libp2p added License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@3d0aa592ecdd6f29556a7dcf3c90dd0fd692c076 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 072e90765..705d2180d 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmY3NAw959vbE1oJooP9HchcRdBsbxhgQsEZTRhKgvoSuC/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZxtCsPRgCnCXwVPUjcBiFckkG5NMYM4Pthwe6X4C8uQq/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 229757191..074b2c10f 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,8 +16,8 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/util/testutil" - ci "gx/ipfs/QmY3NAw959vbE1oJooP9HchcRdBsbxhgQsEZTRhKgvoSuC/go-libp2p/p2p/crypto" - id "gx/ipfs/QmY3NAw959vbE1oJooP9HchcRdBsbxhgQsEZTRhKgvoSuC/go-libp2p/p2p/protocol/identify" + ci "gx/ipfs/QmZxtCsPRgCnCXwVPUjcBiFckkG5NMYM4Pthwe6X4C8uQq/go-libp2p/p2p/crypto" + id "gx/ipfs/QmZxtCsPRgCnCXwVPUjcBiFckkG5NMYM4Pthwe6X4C8uQq/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From db3726814d31e93dd7ac0b33d4099b8b083ebcf9 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 28 Jan 2016 10:07:26 -0800 Subject: [PATCH 120/674] correct go-log dep License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@0e8a6700f9994b505d860569c458a0b72984b231 --- gateway/core/corehttp/corehttp.go | 6 +++--- gateway/core/corehttp/ipns_hostname.go | 2 +- gateway/core/corehttp/logs.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index cfccd7bc4..ed14165ce 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -10,11 +10,11 @@ import ( "net/http" "time" - ma "gx/ipfs/QmR3JkmZBKYXgNMNsNZawm914455Qof3PEopwuVSeXG7aV/go-multiaddr" - manet "gx/ipfs/QmYtzQmUwPFGxjCXctJ8e6GXS8sYfoXy2pdeMbS5SFWqRi/go-multiaddr-net" "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess" core "github.com/ipfs/go-ipfs/core" - logging "gx/ipfs/QmaPaGNE2GqnfJjRRpQuQuFHuJn4FZvsrGxdik4kgxCkBi/go-log" + ma "gx/ipfs/QmR3JkmZBKYXgNMNsNZawm914455Qof3PEopwuVSeXG7aV/go-multiaddr" + manet "gx/ipfs/QmYtzQmUwPFGxjCXctJ8e6GXS8sYfoXy2pdeMbS5SFWqRi/go-multiaddr-net" + logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 3e768fa45..c6b144040 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -6,8 +6,8 @@ import ( "strings" isd "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-is-domain" - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" "github.com/ipfs/go-ipfs/core" + "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) // IPNSHostnameOption rewrites an incoming request if its Host: header contains diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 11a7223b4..82bd2ab79 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - logging "gx/ipfs/QmaPaGNE2GqnfJjRRpQuQuFHuJn4FZvsrGxdik4kgxCkBi/go-log" + logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log" ) type writeErrNotifier struct { From b2f4c261fd98c5b9ea153329aca11bc036e87003 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 31 Jan 2016 10:19:50 -0800 Subject: [PATCH 121/674] update libp2p dep License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@c0101c0c4ba2ff55964981ab029f44ebc2a92b82 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 705d2180d..2346104a1 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmZxtCsPRgCnCXwVPUjcBiFckkG5NMYM4Pthwe6X4C8uQq/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQQCBoWhMZtStYuAAo2uDNNLit9n7yX5ANBecfjKq4XBn/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 074b2c10f..b1753487b 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,8 +16,8 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/util/testutil" - ci "gx/ipfs/QmZxtCsPRgCnCXwVPUjcBiFckkG5NMYM4Pthwe6X4C8uQq/go-libp2p/p2p/crypto" - id "gx/ipfs/QmZxtCsPRgCnCXwVPUjcBiFckkG5NMYM4Pthwe6X4C8uQq/go-libp2p/p2p/protocol/identify" + ci "gx/ipfs/QmQQCBoWhMZtStYuAAo2uDNNLit9n7yX5ANBecfjKq4XBn/go-libp2p/p2p/crypto" + id "gx/ipfs/QmQQCBoWhMZtStYuAAo2uDNNLit9n7yX5ANBecfjKq4XBn/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From e6cf7556e7de2ee25b2f404835cf0f765e137abc Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 31 Jan 2016 15:37:39 -0800 Subject: [PATCH 122/674] do that last thing again License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@2263539c1ca4ecfb78eb097c4c1abbe643065b1e --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 2346104a1..a1b663973 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmQQCBoWhMZtStYuAAo2uDNNLit9n7yX5ANBecfjKq4XBn/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index b1753487b..7624714fa 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,8 +16,8 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/util/testutil" - ci "gx/ipfs/QmQQCBoWhMZtStYuAAo2uDNNLit9n7yX5ANBecfjKq4XBn/go-libp2p/p2p/crypto" - id "gx/ipfs/QmQQCBoWhMZtStYuAAo2uDNNLit9n7yX5ANBecfjKq4XBn/go-libp2p/p2p/protocol/identify" + ci "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/crypto" + id "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From 717839ce2af0eba6a64fdcbd9e463ad9d715decc Mon Sep 17 00:00:00 2001 From: Robert Carlsen Date: Tue, 9 Feb 2016 11:09:43 -0600 Subject: [PATCH 123/674] fix another panic where CloseNotify was called from wrong goroutine panic: net/http: CloseNotify called after ServeHTTP finished goroutine 180 [running]: net/http.(*response).CloseNotify(0xc8220684e0, 0x0) /home/r/go/src/net/http/server.go:1535 +0x9d github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/prometheus/client_golang/ /home/r/src/github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/prome github.com/ipfs/go-ipfs/core/corehttp.(*gatewayHandler).getOrHeadHandler.func1(0x7 /home/r/src/github.com/ipfs/go-ipfs/core/corehttp/gateway_handler.go:119 + created by github.com/ipfs/go-ipfs/core/corehttp.(*gatewayHandler).getOrHeadHandle /home/r/src/github.com/ipfs/go-ipfs/core/corehttp/gateway_handler.go:123 + License: MIT Signed-off-by: Robert Carlsen This commit was moved from ipfs/kubo@5367ee76d0390ca7d12c5355cea7a8343385f5df --- gateway/core/corehttp/gateway_handler.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ebf0b3c6e..ca7938346 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -114,9 +114,10 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request defer cancel() if cn, ok := w.(http.CloseNotifier); ok { + clientGone := cn.CloseNotify() go func() { select { - case <-cn.CloseNotify(): + case <-clientGone: case <-ctx.Done(): } cancel() From caa2167f61a48eb2337320736833fee69eafb8c7 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 8 Feb 2016 16:45:15 -0800 Subject: [PATCH 124/674] remove goprocess from godeps, use gx vendored one License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@3faedb52086cf16b88cc83d3c0e9eedae2b83758 --- gateway/core/corehttp/corehttp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index ed14165ce..8efe554e6 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -10,8 +10,8 @@ import ( "net/http" "time" - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess" core "github.com/ipfs/go-ipfs/core" + "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" ma "gx/ipfs/QmR3JkmZBKYXgNMNsNZawm914455Qof3PEopwuVSeXG7aV/go-multiaddr" manet "gx/ipfs/QmYtzQmUwPFGxjCXctJ8e6GXS8sYfoXy2pdeMbS5SFWqRi/go-multiaddr-net" logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log" From 41a0927ed5dd9f80ae0286871dd1267a76e65d10 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 9 Feb 2016 10:56:19 -0800 Subject: [PATCH 125/674] Use gx vendored go-ipfs-utils where possible For the rest of the packages in util, move them to thirdparty and update the references. util is gone! License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@d7dab3afea5f67b941b0be9e2a4ced3672d610c9 --- gateway/core/corehttp/gateway_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 7624714fa..551fbf6f5 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -15,7 +15,7 @@ import ( path "github.com/ipfs/go-ipfs/path" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" - testutil "github.com/ipfs/go-ipfs/util/testutil" + testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" ci "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/crypto" id "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" From 02f2e6ca30b559320069c94c9b17fa6e47fe7cb0 Mon Sep 17 00:00:00 2001 From: Adrian Ulrich Date: Thu, 17 Dec 2015 09:31:16 +0100 Subject: [PATCH 126/674] Use net/url to escape paths in web-ui License: MIT Signed-off-by: Adrian Ulrich This commit was moved from ipfs/kubo@ec7623bb817c881f659ab9fbad1c3f8b9e63394e --- gateway/core/corehttp/gateway_indexPage.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index 4485c84e6..366c99aca 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -2,6 +2,7 @@ package corehttp import ( "html/template" + "net/url" "path" "strings" @@ -45,6 +46,12 @@ func init() { return "ipfs-" + ext[1:] // slice of the first dot } + // custom template-escaping function to escape a full path, including '#' and '?' + urlEscape := func(rawUrl string) string { + pathUrl := url.URL{Path: rawUrl} + return pathUrl.String() + } + // Directory listing template dirIndexBytes, err := assets.Asset(assetPath + "dir-index.html") if err != nil { @@ -53,5 +60,6 @@ func init() { listingTemplate = template.Must(template.New("dir").Funcs(template.FuncMap{ "iconFromExt": iconFromExt, + "urlEscape": urlEscape, }).Parse(string(dirIndexBytes))) } From b4a171828d7b76f160ca143da9067e44d44bcca7 Mon Sep 17 00:00:00 2001 From: Stephen Whitmore Date: Wed, 2 Mar 2016 16:46:49 -0800 Subject: [PATCH 127/674] adds tests for gateway url escaping License: MIT Signed-off-by: Stephen Whitmore This commit was moved from ipfs/kubo@1ee3645a4940b5bcb369af249bf881c070ee30a6 --- gateway/core/corehttp/gateway_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 551fbf6f5..5479830d3 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -261,7 +261,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { t.Fatal(err) } dagn2.AddNodeLink("bar", dagn3) - dagn1.AddNodeLink("foo", dagn2) + dagn1.AddNodeLink("foo? #<'", dagn2) if err != nil { t.Fatal(err) } @@ -279,7 +279,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { ns["/ipns/example.net"] = path.FromString("/ipfs/" + k.String()) // make request to directory listing - req, err := http.NewRequest("GET", ts.URL+"/foo/", nil) + req, err := http.NewRequest("GET", ts.URL+"/foo%3F%20%23%3C%27/", nil) if err != nil { t.Fatal(err) } @@ -298,13 +298,13 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s := string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /foo/") { + if !strings.Contains(s, "Index of /foo? #<'/") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { t.Fatalf("expected backlink in directory listing") } - if !strings.Contains(s, "") { + if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } @@ -339,7 +339,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { } // make request to directory listing - req, err = http.NewRequest("GET", ts.URL+"/foo/bar/", nil) + req, err = http.NewRequest("GET", ts.URL+"/foo%3F%20%23%3C%27/bar/", nil) if err != nil { t.Fatal(err) } @@ -358,13 +358,13 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s = string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /foo/bar/") { + if !strings.Contains(s, "Index of /foo? #<'/bar/") { t.Fatalf("expected a path in directory listing") } - if !strings.Contains(s, "") { + if !strings.Contains(s, "") { t.Fatalf("expected backlink in directory listing") } - if !strings.Contains(s, "") { + if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } From 5809568b4c5a93fbf130f78cf66b61f6090a813e Mon Sep 17 00:00:00 2001 From: Mildred Ki'Lya Date: Sun, 28 Feb 2016 11:30:26 +0100 Subject: [PATCH 128/674] merkledag: Remove unused AddRecursive and RemoveRecursive License: MIT Signed-off-by: Mildred Ki'Lya This commit was moved from ipfs/kubo@b3c9922c7b14757353dcdb2c1f4903e010682c91 --- gateway/core/corehttp/gateway_handler.go | 12 ++++++++---- gateway/core/corehttp/gateway_test.go | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ca7938346..54ef9c7b7 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -453,16 +453,20 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { } newnode := pathNodes[len(pathNodes)-1] - for i := len(pathNodes) - 2; i >= 0; i-- { - newnode, err = pathNodes[i].UpdateNodeLink(components[i], newnode) + for j := len(pathNodes) - 2; j >= 0; j-- { + if _, err := i.node.DAG.Add(newnode); err != nil { + webError(w, "Could not add node", err, http.StatusInternalServerError) + return + } + newnode, err = pathNodes[j].UpdateNodeLink(components[j], newnode) if err != nil { webError(w, "Could not update node links", err, http.StatusInternalServerError) return } } - if err := i.node.DAG.AddRecursive(newnode); err != nil { - webError(w, "Could not add recursively new node", err, http.StatusInternalServerError) + if _, err := i.node.DAG.Add(newnode); err != nil { + webError(w, "Could not add root node", err, http.StatusInternalServerError) return } diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 551fbf6f5..1e3a1c6f7 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -181,7 +181,12 @@ func TestIPNSHostnameRedirect(t *testing.T) { t.Fatal(err) } - err = n.DAG.AddRecursive(dagn1) + _, err = n.DAG.Add(dagn2) + if err != nil { + t.Fatal(err) + } + + _, err = n.DAG.Add(dagn1) if err != nil { t.Fatal(err) } @@ -266,7 +271,15 @@ func TestIPNSHostnameBacklinks(t *testing.T) { t.Fatal(err) } - err = n.DAG.AddRecursive(dagn1) + _, err = n.DAG.Add(dagn3) + if err != nil { + t.Fatal(err) + } + _, err = n.DAG.Add(dagn2) + if err != nil { + t.Fatal(err) + } + _, err = n.DAG.Add(dagn1) if err != nil { t.Fatal(err) } From e4b1ab095b6bbeeddb5e11a5202bf0a21e05cd26 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 9 Mar 2016 09:53:19 -0800 Subject: [PATCH 129/674] update libp2p dep License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@97d583dd8f56aabc2eb1c4ae816d4d1f8360972c --- gateway/core/corehttp/corehttp.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 8efe554e6..2a932a5cb 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -11,10 +11,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + manet "gx/ipfs/QmQB7mNP3QE7b4zP2MQmsyJDqG5hzYE2CL8k1VyLWky2Ed/go-multiaddr-net" "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" - ma "gx/ipfs/QmR3JkmZBKYXgNMNsNZawm914455Qof3PEopwuVSeXG7aV/go-multiaddr" - manet "gx/ipfs/QmYtzQmUwPFGxjCXctJ8e6GXS8sYfoXy2pdeMbS5SFWqRi/go-multiaddr-net" logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log" + ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index a1b663973..85a55495e 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmNefBbWHR9JEiP3KDVqZsBLQVRmH3GBG2D2Ke24SsFqfW/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 41f7814cf..fc9f6d658 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,8 +16,8 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - ci "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/crypto" - id "gx/ipfs/QmUBogf4nUefBjmYjn6jfsfPJRkmDGSeMhNj4usRKq69f4/go-libp2p/p2p/protocol/identify" + ci "gx/ipfs/QmNefBbWHR9JEiP3KDVqZsBLQVRmH3GBG2D2Ke24SsFqfW/go-libp2p/p2p/crypto" + id "gx/ipfs/QmNefBbWHR9JEiP3KDVqZsBLQVRmH3GBG2D2Ke24SsFqfW/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From 5147aa268bfaf8de75ee12dc7f3ff083e37f7450 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Mon, 14 Mar 2016 20:18:39 +0100 Subject: [PATCH 130/674] feat: Update the webui to work with the latest changes in 0.4 License: MIT Signed-off-by: dignifiedquire This commit was moved from ipfs/kubo@c0ec80215e74f0f3b2d2ff02500cd8b134201f94 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index db08731a9..8d4445ef3 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmRyWyKWmphamkMRnJVjUTzSFSAAZowYP4rnbgnfMXC9Mr" +const WebUIPath = "/ipfs/QmU3o9bvfenhTKhxUakbYrLDnZU7HezAVxPM6Ehjw9Xjqy" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -13,6 +13,7 @@ var WebUIPaths = []string{ "/ipfs/QmctngrQAt9fjpQUZr7Bx3BsXUcif52eZGTizWhvcShsjz", "/ipfs/QmS2HL9v5YeKgQkkWMvs1EMnFtUowTEdFfSSeMT4pos1e6", "/ipfs/QmR9MzChjp1MdFWik7NjEjqKQMzVmBkdK3dz14A6B5Cupm", + "/ipfs/QmRyWyKWmphamkMRnJVjUTzSFSAAZowYP4rnbgnfMXC9Mr", } var WebUIOption = RedirectOption("webui", WebUIPath) From 14d32ab9caaaf119172f0de2296e19aee1b32844 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 29 Mar 2016 19:18:14 -0700 Subject: [PATCH 131/674] update utp and cleanup more godeps along the way License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@9f75ac4d75c4792b60e7ead86f6dcdc07ee8e187 --- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 2a932a5cb..c40c16252 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -11,8 +11,8 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - manet "gx/ipfs/QmQB7mNP3QE7b4zP2MQmsyJDqG5hzYE2CL8k1VyLWky2Ed/go-multiaddr-net" "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" + manet "gx/ipfs/QmYVqhVfbK4BKvbW88Lhm26b3ud14sTBvcm1H7uWUx1Fkp/go-multiaddr-net" logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log" ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 85a55495e..ce6ed50da 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmNefBbWHR9JEiP3KDVqZsBLQVRmH3GBG2D2Ke24SsFqfW/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmSN2ELGRp4T9kjqiSsSNJRUeR9JKXzQEgwe1HH3tdSGbC/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index fc9f6d658..d52d8f551 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,8 +16,8 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - ci "gx/ipfs/QmNefBbWHR9JEiP3KDVqZsBLQVRmH3GBG2D2Ke24SsFqfW/go-libp2p/p2p/crypto" - id "gx/ipfs/QmNefBbWHR9JEiP3KDVqZsBLQVRmH3GBG2D2Ke24SsFqfW/go-libp2p/p2p/protocol/identify" + ci "gx/ipfs/QmSN2ELGRp4T9kjqiSsSNJRUeR9JKXzQEgwe1HH3tdSGbC/go-libp2p/p2p/crypto" + id "gx/ipfs/QmSN2ELGRp4T9kjqiSsSNJRUeR9JKXzQEgwe1HH3tdSGbC/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From d2ab652dfd2b867be7336be7c5df15e8df33ae6d Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Mon, 28 Mar 2016 19:21:48 -0400 Subject: [PATCH 132/674] gateway: enforce allowlist for path prefixes The gateway accepts an X-Ipfs-Path-Prefix header, and assumes that it is mounted in a reverse proxy like nginx, at this path. Links in directory listings, as well as trailing-slash redirects need to be rewritten with that prefix in mind. We don't want a potential attacker to be able to pass in arbitrary path prefixes, which would end up in redirects and directory listings, which is why every prefix has to be explicitly allowed in the config. Previously, we'd accept *any* X-Ipfs-Path-Prefix header. Example: We mount blog.ipfs.io (a dnslink page) at ipfs.io/blog. nginx_ipfs.conf: location /blog/ { rewrite "^/blog(/.*)$" $1 break; proxy_set_header Host blog.ipfs.io; proxy_set_header X-Ipfs-Gateway-Prefix /blog; proxy_pass http://127.0.0.1:8080; } .ipfs/config: "Gateway": { "PathPrefixes": ["/blog"], // ... }, dnslink: > dig TXT _dnslink.blog.ipfs.io dnslink=/ipfs/QmWcBjXPAEdhXDATV4ghUpkAonNBbiyFx1VmmHcQe9HEGd License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@09937f84b64212896e1d80147f828d86ebc19d68 --- gateway/core/corehttp/gateway.go | 14 +++--- gateway/core/corehttp/gateway_handler.go | 9 +++- gateway/core/corehttp/gateway_test.go | 60 ++++++++++++++++++++---- 3 files changed, 67 insertions(+), 16 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index ce6ed50da..c2831dfe1 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -17,9 +17,10 @@ type Gateway struct { } type GatewayConfig struct { - Headers map[string][]string - BlockList *BlockList - Writable bool + Headers map[string][]string + BlockList *BlockList + Writable bool + PathPrefixes []string } func NewGateway(conf GatewayConfig) *Gateway { @@ -48,10 +49,11 @@ func (g *Gateway) ServeOption() ServeOption { } } -func GatewayOption(writable bool) ServeOption { +func GatewayOption(writable bool, prefixes []string) ServeOption { g := NewGateway(GatewayConfig{ - Writable: writable, - BlockList: &BlockList{}, + Writable: writable, + BlockList: &BlockList{}, + PathPrefixes: prefixes, }) return g.ServeOption() } diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 54ef9c7b7..d8bd7676f 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -131,8 +131,13 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // It will be prepended to links in directory listings and the index.html redirect. prefix := "" if prefixHdr := r.Header["X-Ipfs-Gateway-Prefix"]; len(prefixHdr) > 0 { - log.Debugf("X-Ipfs-Gateway-Prefix: %s", prefixHdr[0]) - prefix = prefixHdr[0] + prfx := prefixHdr[0] + for _, p := range i.config.PathPrefixes { + if prfx == p || strings.HasPrefix(prfx, p+"/") { + prefix = prfx + break + } + } } // IPNSHostnameOption might have constructed an IPNS path using the Host header. diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index d52d8f551..acff78262 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -98,7 +98,7 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, *core ts.Listener, VersionOption(), IPNSHostnameOption(), - GatewayOption(false), + GatewayOption(false, []string{"/good-prefix"}), ) if err != nil { t.Fatal(err) @@ -227,7 +227,7 @@ func TestIPNSHostnameRedirect(t *testing.T) { t.Fatal(err) } req.Host = "example.net" - req.Header.Set("X-Ipfs-Gateway-Prefix", "/prefix") + req.Header.Set("X-Ipfs-Gateway-Prefix", "/good-prefix") res, err = doWithoutRedirect(req) if err != nil { @@ -241,8 +241,8 @@ func TestIPNSHostnameRedirect(t *testing.T) { hdr = res.Header["Location"] if len(hdr) < 1 { t.Errorf("location header not present") - } else if hdr[0] != "/prefix/foo/" { - t.Errorf("location header is %v, expected /prefix/foo/", hdr[0]) + } else if hdr[0] != "/good-prefix/foo/" { + t.Errorf("location header is %v, expected /good-prefix/foo/", hdr[0]) } } @@ -387,7 +387,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { t.Fatal(err) } req.Host = "example.net" - req.Header.Set("X-Ipfs-Gateway-Prefix", "/prefix") + req.Header.Set("X-Ipfs-Gateway-Prefix", "/good-prefix") res, err = doWithoutRedirect(req) if err != nil { @@ -402,13 +402,57 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s = string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /prefix") { + if !strings.Contains(s, "Index of /good-prefix") { t.Fatalf("expected a path in directory listing") } - if !strings.Contains(s, "") { + if !strings.Contains(s, "") { t.Fatalf("expected backlink in directory listing") } - if !strings.Contains(s, "") { + if !strings.Contains(s, "") { + t.Fatalf("expected file in directory listing") + } + + // make request to directory listing with illegal prefix + req, err = http.NewRequest("GET", ts.URL, nil) + if err != nil { + t.Fatal(err) + } + req.Host = "example.net" + req.Header.Set("X-Ipfs-Gateway-Prefix", "/bad-prefix") + + res, err = doWithoutRedirect(req) + if err != nil { + t.Fatal(err) + } + + // make request to directory listing with evil prefix + req, err = http.NewRequest("GET", ts.URL, nil) + if err != nil { + t.Fatal(err) + } + req.Host = "example.net" + req.Header.Set("X-Ipfs-Gateway-Prefix", "//good-prefix/foo") + + res, err = doWithoutRedirect(req) + if err != nil { + t.Fatal(err) + } + + // expect correct backlinks without illegal prefix + body, err = ioutil.ReadAll(res.Body) + if err != nil { + t.Fatalf("error reading response: %s", err) + } + s = string(body) + t.Logf("body: %s\n", string(body)) + + if !strings.Contains(s, "Index of /") { + t.Fatalf("expected a path in directory listing") + } + if !strings.Contains(s, "") { + t.Fatalf("expected backlink in directory listing") + } + if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } } From 227bae94d45fda4db896cf85171e8b7095435bda Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 6 Apr 2016 15:42:06 -0700 Subject: [PATCH 133/674] switch to new libp2p with mss crypto License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@8f3a51ac42c54afeb3cae2ad6e5dee43a7796bef --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index c2831dfe1..d9b65238e 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmSN2ELGRp4T9kjqiSsSNJRUeR9JKXzQEgwe1HH3tdSGbC/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZMehXD2w81qeVJP6r1mmocxwsD7kqAvuzGm2QWDw1H88/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index acff78262..ce9925183 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,8 +16,8 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - ci "gx/ipfs/QmSN2ELGRp4T9kjqiSsSNJRUeR9JKXzQEgwe1HH3tdSGbC/go-libp2p/p2p/crypto" - id "gx/ipfs/QmSN2ELGRp4T9kjqiSsSNJRUeR9JKXzQEgwe1HH3tdSGbC/go-libp2p/p2p/protocol/identify" + ci "gx/ipfs/QmZMehXD2w81qeVJP6r1mmocxwsD7kqAvuzGm2QWDw1H88/go-libp2p/p2p/crypto" + id "gx/ipfs/QmZMehXD2w81qeVJP6r1mmocxwsD7kqAvuzGm2QWDw1H88/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From 7e1f82d08453bef56dfdc0fa273ebf1e267f2ebe Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 11 Apr 2016 12:52:54 -0700 Subject: [PATCH 134/674] update libp2p dep to fix hanging listeners problem License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@bdc5456d52e5e04eab9b3a484582f3116bb91a2f --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index d9b65238e..0fdb78c70 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmZMehXD2w81qeVJP6r1mmocxwsD7kqAvuzGm2QWDw1H88/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index ce9925183..4ca7454b1 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,9 +16,9 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - ci "gx/ipfs/QmZMehXD2w81qeVJP6r1mmocxwsD7kqAvuzGm2QWDw1H88/go-libp2p/p2p/crypto" - id "gx/ipfs/QmZMehXD2w81qeVJP6r1mmocxwsD7kqAvuzGm2QWDw1H88/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + ci "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/crypto" + id "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path From f87c80a16c7c71640983fbc9f3c7132dccdf90c8 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Tue, 5 Apr 2016 13:23:00 -0400 Subject: [PATCH 135/674] metrics: add prometheus back With a proper IpfsCollector object and tests, this time. The collector object makes it easy to add further metrics, like e.g. bitswap wants/provs. License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@caec086c2853a6f4690d18cce360e94cbd088722 --- gateway/core/corehttp/metrics.go | 53 +++++++++++++++++++++++++++ gateway/core/corehttp/metrics_test.go | 46 +++++++++++++++++++++++ gateway/core/corehttp/prometheus.go | 25 ------------- 3 files changed, 99 insertions(+), 25 deletions(-) create mode 100644 gateway/core/corehttp/metrics.go create mode 100644 gateway/core/corehttp/metrics_test.go delete mode 100644 gateway/core/corehttp/prometheus.go diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go new file mode 100644 index 000000000..5d00a3c4c --- /dev/null +++ b/gateway/core/corehttp/metrics.go @@ -0,0 +1,53 @@ +package corehttp + +import ( + "net" + "net/http" + + prometheus "gx/ipfs/QmdhsRK1EK2fvAz2i2SH5DEfkL6seDuyMYEsxKa9Braim3/client_golang/prometheus" + + core "github.com/ipfs/go-ipfs/core" +) + +// This adds the scraping endpoint which Prometheus uses to fetch metrics. +func MetricsScrapingOption(path string) ServeOption { + return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { + mux.Handle(path, prometheus.UninstrumentedHandler()) + return mux, nil + } +} + +// This adds collection of net/http-related metrics +func MetricsCollectionOption(handlerName string) ServeOption { + return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { + childMux := http.NewServeMux() + mux.HandleFunc("/", prometheus.InstrumentHandler(handlerName, childMux)) + return childMux, nil + } +} + +var ( + peersTotalMetric = prometheus.NewDesc( + prometheus.BuildFQName("ipfs", "p2p", "peers_total"), + "Number of connected peers", nil, nil) +) + +type IpfsNodeCollector struct { + Node *core.IpfsNode +} + +func (_ IpfsNodeCollector) Describe(ch chan<- *prometheus.Desc) { + ch <- peersTotalMetric +} + +func (c IpfsNodeCollector) Collect(ch chan<- prometheus.Metric) { + ch <- prometheus.MustNewConstMetric( + peersTotalMetric, + prometheus.GaugeValue, + c.PeersTotalValue(), + ) +} + +func (c IpfsNodeCollector) PeersTotalValue() float64 { + return float64(len(c.Node.PeerHost.Network().Conns())) +} diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go new file mode 100644 index 000000000..da6146392 --- /dev/null +++ b/gateway/core/corehttp/metrics_test.go @@ -0,0 +1,46 @@ +package corehttp + +import ( + "testing" + "time" + + core "github.com/ipfs/go-ipfs/core" + context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + bhost "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/net" + testutil "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/test/util" +) + +// This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect +// It builds 4 nodes and connects them, one being the sole center. +// Then it checks that the center reports the correct number of peers. +func TestPeersTotal(t *testing.T) { + ctx := context.Background() + + hosts := make([]*bhost.BasicHost, 4) + for i := 0; i < 4; i++ { + hosts[i] = testutil.GenHostSwarm(t, ctx) + } + + dial := func(a, b inet.Network) { + testutil.DivulgeAddresses(b, a) + if _, err := a.DialPeer(ctx, b.LocalPeer()); err != nil { + t.Fatalf("Failed to dial: %s", err) + } + } + + dial(hosts[0].Network(), hosts[1].Network()) + dial(hosts[0].Network(), hosts[2].Network()) + dial(hosts[0].Network(), hosts[3].Network()) + + // there's something wrong with dial, i think. it's not finishing + // completely. there must be some async stuff. + <-time.After(100 * time.Millisecond) + + node := &core.IpfsNode{PeerHost: hosts[0]} + collector := IpfsNodeCollector{Node: node} + actual := collector.PeersTotalValue() + if actual != 3 { + t.Fatalf("expected 3 peers, got %d", int(actual)) + } +} diff --git a/gateway/core/corehttp/prometheus.go b/gateway/core/corehttp/prometheus.go deleted file mode 100644 index 2605e6cbe..000000000 --- a/gateway/core/corehttp/prometheus.go +++ /dev/null @@ -1,25 +0,0 @@ -package corehttp - -import ( - "net" - "net/http" - - prom "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus" - - "github.com/ipfs/go-ipfs/core" -) - -func PrometheusOption(path string) ServeOption { - return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - mux.Handle(path, prom.UninstrumentedHandler()) - return mux, nil - } -} - -func PrometheusCollectorOption(handlerName string) ServeOption { - return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - childMux := http.NewServeMux() - mux.HandleFunc("/", prom.InstrumentHandler(handlerName, childMux)) - return childMux, nil - } -} From 7ea960cc1568e6849eb5027ebc1b9465f49074e0 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sat, 16 Apr 2016 21:23:47 -0700 Subject: [PATCH 136/674] Update go-libp2p License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@907f4fadbdd74ba99288f2bdf078d77547d08389 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 4 ++-- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 0fdb78c70..02f2ea98b 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 4ca7454b1..ad3bb0920 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,9 +16,9 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" + ci "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/crypto" + id "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - ci "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/crypto" - id "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index da6146392..b88f838dd 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,10 +5,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + bhost "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/net" + testutil "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - bhost "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/net" - testutil "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/test/util" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From aa75363659a530f583d3320b9740ef5a011ef5ba Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sat, 16 Apr 2016 21:38:22 -0700 Subject: [PATCH 137/674] Use extracted go-libp2p-crypto, -secio, -peer packages License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@00ec976e1dff4cc0053c4a7d4754e6ac2c0d3d9d --- gateway/core/corehttp/gateway_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index ad3bb0920..5a59bae6d 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,7 +16,7 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - ci "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/crypto" + ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" id "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From 813f3ad47913074a307cc389809d1db4c95402ff Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 27 Apr 2016 10:39:48 -0700 Subject: [PATCH 138/674] update libp2p with utp dep License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@cffec77cea05314e0aef079efcba530b8d74a7b3 --- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index c40c16252..49f215839 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,7 +12,7 @@ import ( core "github.com/ipfs/go-ipfs/core" "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" - manet "gx/ipfs/QmYVqhVfbK4BKvbW88Lhm26b3ud14sTBvcm1H7uWUx1Fkp/go-multiaddr-net" + manet "gx/ipfs/QmTrxSBY8Wqd5aBB4MeizeSzS5xFbK8dQBrYaMsiGnCBhb/go-multiaddr-net" logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log" ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 02f2ea98b..3a4678a56 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 5a59bae6d..776b0a842 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,7 +17,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" - id "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index b88f838dd..2aa85ca83 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,9 +5,9 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/net" - testutil "gx/ipfs/QmYgaiNVVL7f2nydijAwpDRunRkmxfu3PoK87Y3pH84uAW/go-libp2p/p2p/test/util" + bhost "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net" + testutil "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From 2f15d2b41b73fe3c88d4c645024b7feec0eda899 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 4 May 2016 22:56:39 +0200 Subject: [PATCH 139/674] Update go-log to 1.1.0 and fix calls to go-log.Uuid License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@57b494a70ccec5cc92cabf5ae5fadd5191f64629 --- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/logs.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 49f215839..7b024036a 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -13,7 +13,7 @@ import ( core "github.com/ipfs/go-ipfs/core" "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" manet "gx/ipfs/QmTrxSBY8Wqd5aBB4MeizeSzS5xFbK8dQBrYaMsiGnCBhb/go-multiaddr-net" - logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log" + logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log" ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr" ) diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 82bd2ab79..081df6197 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log" + logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log" ) type writeErrNotifier struct { From 5e0b49fea29718dc14bdb819ae716baf28993d8f Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 10 May 2016 16:06:28 -0700 Subject: [PATCH 140/674] update libp2p with go-multiaddr and go-stream-muxer updates License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@6359dc9d5e271be68a3a2f13e74e77c4905e83ec --- gateway/core/corehttp/corehttp.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 7b024036a..11b7da4aa 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,9 +12,9 @@ import ( core "github.com/ipfs/go-ipfs/core" "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" - manet "gx/ipfs/QmTrxSBY8Wqd5aBB4MeizeSzS5xFbK8dQBrYaMsiGnCBhb/go-multiaddr-net" + manet "gx/ipfs/QmUBa4w6CbHJUMeGJPDiMEDWsM93xToK1fTnFXnrC8Hksw/go-multiaddr-net" + ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr" logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log" - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 3a4678a56..8d3887f85 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 776b0a842..b9f2ab924 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,8 +17,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" - id "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + id "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 2aa85ca83..17eb1bc75 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,10 +5,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/net" - testutil "gx/ipfs/QmXDvxcXUYn2DDnGKJwdQPxkJgG83jBTp5UmmNzeHzqbj5/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + bhost "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net" + testutil "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/test/util" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 52540673b8b0d15b4fda55ea56e5a452a4fd51db Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Thu, 12 May 2016 12:05:23 +0200 Subject: [PATCH 141/674] Set Cache-Control immutable Given that /ipfs/ resources never change, we can easily benefit from this new cache control extension. Support for this is about to land in Firefox 49: https://bugzilla.mozilla.org/show_bug.cgi?id=1267474 For more details, there is a good blogpost about this here: https://bitsup.blogspot.de/2016/05/cache-control-immutable.html This header is ignored by clients that don't support it. License: MIT Signed-off-by: kpcyrd This commit was moved from ipfs/kubo@c2a3e3169d60f9b42bbdb8bd6359815bdc7de271 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d8bd7676f..d0366390d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -205,7 +205,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request modtime := time.Now() if strings.HasPrefix(urlPath, ipfsPathPrefix) { w.Header().Set("Etag", etag) - w.Header().Set("Cache-Control", "public, max-age=29030400") + w.Header().Set("Cache-Control", "public, max-age=29030400, immutable") // set modtime to a really long time ago, since files are immutable and should stay cached modtime = time.Unix(1, 0) From 2e4f666da179f91c2990dc36b3552fa9fbf51dfb Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 13 May 2016 13:42:46 -0700 Subject: [PATCH 142/674] update deps to introduce yamux hang fix License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@a657ccf6c0abf9ea18f9222ad2643962b5185b44 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 8d3887f85..43d25b4ff 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZpVD1kkRwoC67vNknvCrY72pjmVdtZ7txSk8mtCbuwd3/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index b9f2ab924..ed0ffc2db 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,8 +17,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" + id "gx/ipfs/QmZpVD1kkRwoC67vNknvCrY72pjmVdtZ7txSk8mtCbuwd3/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - id "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 17eb1bc75..ae8d01522 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,10 +5,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + bhost "gx/ipfs/QmZpVD1kkRwoC67vNknvCrY72pjmVdtZ7txSk8mtCbuwd3/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmZpVD1kkRwoC67vNknvCrY72pjmVdtZ7txSk8mtCbuwd3/go-libp2p/p2p/net" + testutil "gx/ipfs/QmZpVD1kkRwoC67vNknvCrY72pjmVdtZ7txSk8mtCbuwd3/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - bhost "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/net" - testutil "gx/ipfs/QmcQTVCQWCN2MYgBHpFXE5S56rcg2mRsxaRgMYmA1UWgA8/go-libp2p/p2p/test/util" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 787634eab6b99ffb49ef8965b4511cf8574f56d2 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 16 May 2016 11:22:36 -0700 Subject: [PATCH 143/674] update libp2p to v3.2.1 License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@23c8ed93fd997504f3596ee05a6e1df6fe4a42bb --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 43d25b4ff..54e157e98 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmZpVD1kkRwoC67vNknvCrY72pjmVdtZ7txSk8mtCbuwd3/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmUHrgorZ1F9yGkgF2His5fsQ9xtCzjdsPGjizmcEW94i5/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index ed0ffc2db..ed5bde3cd 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,7 +17,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" - id "gx/ipfs/QmZpVD1kkRwoC67vNknvCrY72pjmVdtZ7txSk8mtCbuwd3/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmUHrgorZ1F9yGkgF2His5fsQ9xtCzjdsPGjizmcEW94i5/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index ae8d01522..93995d608 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,9 +5,9 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmZpVD1kkRwoC67vNknvCrY72pjmVdtZ7txSk8mtCbuwd3/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmZpVD1kkRwoC67vNknvCrY72pjmVdtZ7txSk8mtCbuwd3/go-libp2p/p2p/net" - testutil "gx/ipfs/QmZpVD1kkRwoC67vNknvCrY72pjmVdtZ7txSk8mtCbuwd3/go-libp2p/p2p/test/util" + bhost "gx/ipfs/QmUHrgorZ1F9yGkgF2His5fsQ9xtCzjdsPGjizmcEW94i5/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmUHrgorZ1F9yGkgF2His5fsQ9xtCzjdsPGjizmcEW94i5/go-libp2p/p2p/net" + testutil "gx/ipfs/QmUHrgorZ1F9yGkgF2His5fsQ9xtCzjdsPGjizmcEW94i5/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From cdf263ec9f33c8ceb3d26f4aff880605dfe5ba91 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 17 May 2016 10:23:10 -0700 Subject: [PATCH 144/674] update go-libp2p 3.2.2, nil maddr fixes License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@e22345ae656e87da2562784daed9b4a0c52361f3 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 54e157e98..3fa0b11cb 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmUHrgorZ1F9yGkgF2His5fsQ9xtCzjdsPGjizmcEW94i5/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmVL44QeoQDTYK8RVdpkyja7uYcK3WDNoBNHVLonf9YDtm/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index ed5bde3cd..57a992e38 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,7 +17,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" - id "gx/ipfs/QmUHrgorZ1F9yGkgF2His5fsQ9xtCzjdsPGjizmcEW94i5/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmVL44QeoQDTYK8RVdpkyja7uYcK3WDNoBNHVLonf9YDtm/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 93995d608..7495360f7 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,9 +5,9 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmUHrgorZ1F9yGkgF2His5fsQ9xtCzjdsPGjizmcEW94i5/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmUHrgorZ1F9yGkgF2His5fsQ9xtCzjdsPGjizmcEW94i5/go-libp2p/p2p/net" - testutil "gx/ipfs/QmUHrgorZ1F9yGkgF2His5fsQ9xtCzjdsPGjizmcEW94i5/go-libp2p/p2p/test/util" + bhost "gx/ipfs/QmVL44QeoQDTYK8RVdpkyja7uYcK3WDNoBNHVLonf9YDtm/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmVL44QeoQDTYK8RVdpkyja7uYcK3WDNoBNHVLonf9YDtm/go-libp2p/p2p/net" + testutil "gx/ipfs/QmVL44QeoQDTYK8RVdpkyja7uYcK3WDNoBNHVLonf9YDtm/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From 4742cb6bab68c47a78fc7bc64c8af3547a3cd0b8 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Wed, 18 May 2016 04:07:43 +0200 Subject: [PATCH 145/674] metrics: add transport label to p2p_peers_total Gives us per-transport peers counts: ipfs_p2p_peers_total{transport="/ip4/tcp"} 25 ipfs_p2p_peers_total{transport="/ip6/tcp"} 13 ipfs_p2p_peers_total{transport="/ip6/udp/utp"} 17 License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@05cb7a1bc2b83a70f17b0cb895922f2bc63ef8aa --- gateway/core/corehttp/metrics.go | 27 +++++++++++++++++++-------- gateway/core/corehttp/metrics_test.go | 9 ++++++--- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 5d00a3c4c..4dee41aed 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -29,7 +29,7 @@ func MetricsCollectionOption(handlerName string) ServeOption { var ( peersTotalMetric = prometheus.NewDesc( prometheus.BuildFQName("ipfs", "p2p", "peers_total"), - "Number of connected peers", nil, nil) + "Number of connected peers", []string{"transport"}, nil) ) type IpfsNodeCollector struct { @@ -41,13 +41,24 @@ func (_ IpfsNodeCollector) Describe(ch chan<- *prometheus.Desc) { } func (c IpfsNodeCollector) Collect(ch chan<- prometheus.Metric) { - ch <- prometheus.MustNewConstMetric( - peersTotalMetric, - prometheus.GaugeValue, - c.PeersTotalValue(), - ) + for tr, val := range c.PeersTotalValues() { + ch <- prometheus.MustNewConstMetric( + peersTotalMetric, + prometheus.GaugeValue, + val, + tr, + ) + } } -func (c IpfsNodeCollector) PeersTotalValue() float64 { - return float64(len(c.Node.PeerHost.Network().Conns())) +func (c IpfsNodeCollector) PeersTotalValues() map[string]float64 { + vals := make(map[string]float64) + for _, conn := range c.Node.PeerHost.Network().Conns() { + tr := "" + for _, proto := range conn.RemoteMultiaddr().Protocols() { + tr = tr + "/" + proto.Name + } + vals[tr] = vals[tr] + 1 + } + return vals } diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 7495360f7..98859f00f 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -39,8 +39,11 @@ func TestPeersTotal(t *testing.T) { node := &core.IpfsNode{PeerHost: hosts[0]} collector := IpfsNodeCollector{Node: node} - actual := collector.PeersTotalValue() - if actual != 3 { - t.Fatalf("expected 3 peers, got %d", int(actual)) + actual := collector.PeersTotalValues() + if len(actual) != 1 { + t.Fatalf("expected 1 peers transport, got %d", len(actual)) + } + if actual["/ip4/tcp"] != float64(3) { + t.Fatalf("expected 3 peers, got %s", actual["/ip4/tcp"]) } } From 769081d8b21ebab375fb87ae25e13f90514a75ce Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Sun, 15 May 2016 14:46:08 +0200 Subject: [PATCH 146/674] Make errors more reasonable in case of node in offline mode License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@a77fa94fdfc1151244ddbbe4fea930bf1258049d --- gateway/core/corehttp/gateway_handler.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d0366390d..32269a170 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -159,7 +159,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } nd, err := core.Resolve(ctx, i.node, path.Path(urlPath)) - if err != nil { + // If node is in offline mode the error code and message should be different + if err == core.ErrNoNamesys && !i.node.OnlineMode() { + w.WriteHeader(http.StatusServiceUnavailable) + fmt.Fprint(w, "Could not resolve path. Node is in offline mode.") + return + } else if err != nil { webError(w, "Path Resolve error", err, http.StatusBadRequest) return } From 6e60017eabaa9a730eaca6047a656d554e610f89 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 30 May 2016 22:14:21 -0700 Subject: [PATCH 147/674] update libp2p to v3.2.3 License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@aae6a2c3793811a75f3b6828db02d5d7dc33e01f --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 3fa0b11cb..361306e21 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmVL44QeoQDTYK8RVdpkyja7uYcK3WDNoBNHVLonf9YDtm/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmRW2xiYTpDLWTHb822ZYbPBoh3dGLJwaXLGS9tnPyWZpq/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 57a992e38..b9fedb3c1 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,8 +16,8 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" + id "gx/ipfs/QmRW2xiYTpDLWTHb822ZYbPBoh3dGLJwaXLGS9tnPyWZpq/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" - id "gx/ipfs/QmVL44QeoQDTYK8RVdpkyja7uYcK3WDNoBNHVLonf9YDtm/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 98859f00f..5f3003f73 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,9 +5,9 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmVL44QeoQDTYK8RVdpkyja7uYcK3WDNoBNHVLonf9YDtm/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmVL44QeoQDTYK8RVdpkyja7uYcK3WDNoBNHVLonf9YDtm/go-libp2p/p2p/net" - testutil "gx/ipfs/QmVL44QeoQDTYK8RVdpkyja7uYcK3WDNoBNHVLonf9YDtm/go-libp2p/p2p/test/util" + bhost "gx/ipfs/QmRW2xiYTpDLWTHb822ZYbPBoh3dGLJwaXLGS9tnPyWZpq/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmRW2xiYTpDLWTHb822ZYbPBoh3dGLJwaXLGS9tnPyWZpq/go-libp2p/p2p/net" + testutil "gx/ipfs/QmRW2xiYTpDLWTHb822ZYbPBoh3dGLJwaXLGS9tnPyWZpq/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From 4c85dd17e32992560a5551347e7cb0a1f71c8bb0 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 1 Jun 2016 15:51:39 -0700 Subject: [PATCH 148/674] update libp2p to v3.3.1 License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@7274c6be35561d3c20bf186efadfdff797e50ad6 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 361306e21..cff9a719c 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmRW2xiYTpDLWTHb822ZYbPBoh3dGLJwaXLGS9tnPyWZpq/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQgQeBQxQmJdeUSaDagc8cr2ompDwGn13Cybjdtzfuaki/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index b9fedb3c1..4b1ba032f 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,7 +16,7 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmRW2xiYTpDLWTHb822ZYbPBoh3dGLJwaXLGS9tnPyWZpq/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQgQeBQxQmJdeUSaDagc8cr2ompDwGn13Cybjdtzfuaki/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 5f3003f73..88271fb00 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,9 +5,9 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmRW2xiYTpDLWTHb822ZYbPBoh3dGLJwaXLGS9tnPyWZpq/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmRW2xiYTpDLWTHb822ZYbPBoh3dGLJwaXLGS9tnPyWZpq/go-libp2p/p2p/net" - testutil "gx/ipfs/QmRW2xiYTpDLWTHb822ZYbPBoh3dGLJwaXLGS9tnPyWZpq/go-libp2p/p2p/test/util" + bhost "gx/ipfs/QmQgQeBQxQmJdeUSaDagc8cr2ompDwGn13Cybjdtzfuaki/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmQgQeBQxQmJdeUSaDagc8cr2ompDwGn13Cybjdtzfuaki/go-libp2p/p2p/net" + testutil "gx/ipfs/QmQgQeBQxQmJdeUSaDagc8cr2ompDwGn13Cybjdtzfuaki/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From ade71c78e28b33b07819aa319bf35810142c3000 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 7 Jun 2016 00:20:06 -0700 Subject: [PATCH 149/674] update libp2p to version 3.2.2 License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@afbc6be0a6b804b2f74246da69835e9d54fd020f --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index cff9a719c..28178370a 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmQgQeBQxQmJdeUSaDagc8cr2ompDwGn13Cybjdtzfuaki/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmXJBB9U6e6ennAJPzk8E2rSaVGuHVR2jCxE9H9gPDtRrq/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 4b1ba032f..e245951f1 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,8 +16,8 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmQgQeBQxQmJdeUSaDagc8cr2ompDwGn13Cybjdtzfuaki/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" + id "gx/ipfs/QmXJBB9U6e6ennAJPzk8E2rSaVGuHVR2jCxE9H9gPDtRrq/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 88271fb00..7721b54e0 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,9 +5,9 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmQgQeBQxQmJdeUSaDagc8cr2ompDwGn13Cybjdtzfuaki/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmQgQeBQxQmJdeUSaDagc8cr2ompDwGn13Cybjdtzfuaki/go-libp2p/p2p/net" - testutil "gx/ipfs/QmQgQeBQxQmJdeUSaDagc8cr2ompDwGn13Cybjdtzfuaki/go-libp2p/p2p/test/util" + bhost "gx/ipfs/QmXJBB9U6e6ennAJPzk8E2rSaVGuHVR2jCxE9H9gPDtRrq/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmXJBB9U6e6ennAJPzk8E2rSaVGuHVR2jCxE9H9gPDtRrq/go-libp2p/p2p/net" + testutil "gx/ipfs/QmXJBB9U6e6ennAJPzk8E2rSaVGuHVR2jCxE9H9gPDtRrq/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From c2455662dd0e43772484b9657f1d9265dae1f4a4 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 8 Jun 2016 19:07:43 +0200 Subject: [PATCH 150/674] Move go-humanize to gx License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@6d4975d82c41068dc93700215b9a5c692a77d1e5 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 32269a170..f6f870559 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -10,7 +10,7 @@ import ( "strings" "time" - humanize "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/dustin/go-humanize" + humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" key "github.com/ipfs/go-ipfs/blocks/key" From 6fed52816f881aa16f15577b718090935a561397 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 9 Jun 2016 22:12:52 +0200 Subject: [PATCH 151/674] Update go-log https://github.com/ipfs/go-log/pull/3 License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@eaccd07505e81da0b2dc3aeefb03aabd693a91b3 --- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/logs.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 11b7da4aa..7c45ccac2 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -13,8 +13,8 @@ import ( core "github.com/ipfs/go-ipfs/core" "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" manet "gx/ipfs/QmUBa4w6CbHJUMeGJPDiMEDWsM93xToK1fTnFXnrC8Hksw/go-multiaddr-net" + logging "gx/ipfs/QmYtB7Qge8cJpXc4irsEp8zRqfnZMBeB7aTrMEkPk67DRv/go-log" ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr" - logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 081df6197..78dd03525 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - logging "gx/ipfs/QmaDNZ4QMdBdku1YZWBysufYyoQt1negQGNav6PLYarbY8/go-log" + logging "gx/ipfs/QmYtB7Qge8cJpXc4irsEp8zRqfnZMBeB7aTrMEkPk67DRv/go-log" ) type writeErrNotifier struct { From f52bdec57ebb146d69a148be42fa323e68db12f7 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sat, 11 Jun 2016 10:33:44 -0700 Subject: [PATCH 152/674] pull in libp2p updates with utp fixes License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@7c8e64143687daa36dd80df108391f5c372b5263 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 28178370a..69ffb649f 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmXJBB9U6e6ennAJPzk8E2rSaVGuHVR2jCxE9H9gPDtRrq/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQkQP7WmeT9FRJDsEzAaGYDparttDiB6mCpVBrq2MuWQS/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index e245951f1..316c64c83 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,8 +16,8 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" + id "gx/ipfs/QmQkQP7WmeT9FRJDsEzAaGYDparttDiB6mCpVBrq2MuWQS/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" - id "gx/ipfs/QmXJBB9U6e6ennAJPzk8E2rSaVGuHVR2jCxE9H9gPDtRrq/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 7721b54e0..bd561007a 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,9 +5,9 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmXJBB9U6e6ennAJPzk8E2rSaVGuHVR2jCxE9H9gPDtRrq/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmXJBB9U6e6ennAJPzk8E2rSaVGuHVR2jCxE9H9gPDtRrq/go-libp2p/p2p/net" - testutil "gx/ipfs/QmXJBB9U6e6ennAJPzk8E2rSaVGuHVR2jCxE9H9gPDtRrq/go-libp2p/p2p/test/util" + bhost "gx/ipfs/QmQkQP7WmeT9FRJDsEzAaGYDparttDiB6mCpVBrq2MuWQS/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmQkQP7WmeT9FRJDsEzAaGYDparttDiB6mCpVBrq2MuWQS/go-libp2p/p2p/net" + testutil "gx/ipfs/QmQkQP7WmeT9FRJDsEzAaGYDparttDiB6mCpVBrq2MuWQS/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From 4ae712e5c1943d10af9ee156e12f6f855847de0f Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sat, 11 Jun 2016 11:22:01 -0700 Subject: [PATCH 153/674] update iptb and multinode tests License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@4c1201badbb84c94473ee99bd1a7ff94f2e6cad3 --- gateway/core/corehttp/corehttp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 7c45ccac2..dd28a87bc 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -11,8 +11,8 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + manet "gx/ipfs/QmPpRcbNUXauP3zWZ1NJMLWpe4QnmEHrd2ba2D3yqWznw7/go-multiaddr-net" "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" - manet "gx/ipfs/QmUBa4w6CbHJUMeGJPDiMEDWsM93xToK1fTnFXnrC8Hksw/go-multiaddr-net" logging "gx/ipfs/QmYtB7Qge8cJpXc4irsEp8zRqfnZMBeB7aTrMEkPk67DRv/go-log" ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr" ) From 2cdcc82fa3e4b4c7b3fa0913559a776f988ad6a5 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 15 Jun 2016 13:04:49 -0700 Subject: [PATCH 154/674] update go-libp2p to 3.3.4 License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@de56a47bc0ecff992e4a76fc2c219dea531f3909 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 69ffb649f..0d9453e1e 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmQkQP7WmeT9FRJDsEzAaGYDparttDiB6mCpVBrq2MuWQS/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmdBpVuSYuTGDA8Kn66CbKvEThXqKUh2nTANZEhzSxqrmJ/go-libp2p/p2p/protocol/identify" ) // Gateway should be instantiated using NewGateway diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 316c64c83..f8a01aa52 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,9 +16,9 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmQkQP7WmeT9FRJDsEzAaGYDparttDiB6mCpVBrq2MuWQS/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + id "gx/ipfs/QmdBpVuSYuTGDA8Kn66CbKvEThXqKUh2nTANZEhzSxqrmJ/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index bd561007a..25ed8f57d 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,10 +5,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmQkQP7WmeT9FRJDsEzAaGYDparttDiB6mCpVBrq2MuWQS/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmQkQP7WmeT9FRJDsEzAaGYDparttDiB6mCpVBrq2MuWQS/go-libp2p/p2p/net" - testutil "gx/ipfs/QmQkQP7WmeT9FRJDsEzAaGYDparttDiB6mCpVBrq2MuWQS/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + bhost "gx/ipfs/QmdBpVuSYuTGDA8Kn66CbKvEThXqKUh2nTANZEhzSxqrmJ/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmdBpVuSYuTGDA8Kn66CbKvEThXqKUh2nTANZEhzSxqrmJ/go-libp2p/p2p/net" + testutil "gx/ipfs/QmdBpVuSYuTGDA8Kn66CbKvEThXqKUh2nTANZEhzSxqrmJ/go-libp2p/p2p/test/util" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 0b27d0e12d99e14ad31a3f6cade63dc253a41647 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Fri, 17 Jun 2016 16:33:25 +0200 Subject: [PATCH 155/674] gateway: clean up its surface, and remove BlockList This patch is in preparation for the gateway's extraction. It's interesting to trace technical debt back to its origin, understanding the circumstances in which it was introduced and built up, and then cutting it back at exactly the right places. - Clean up the gateway's surface The option builder GatewayOption() now takes only arguments which are relevant for HTTP handler muxing, i.e. the paths where the gateway should be mounted. All other configuration happens through the GatewayConfig object. - Remove BlockList I know why this was introduced in the first place, but it never ended up fulfilling that purpose. Somehow it was only ever used by the API server, not the gateway, which really doesn't make sense. It was also never wired up with CLI nor fs-repo. Eventually @krl started punching holes into it to make the Web UI accessible. - Remove --unrestricted-api This was holes being punched into BlockList too, for accessing /ipfs and /ipn on the API server. With BlockList removed and /ipfs and /ipns freely accessible, putting this option out of action is safe. With the next major release, the option can be removed for good. License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@1afebc21f324982141ca8a29710da0d6f83ca804 --- gateway/core/corehttp/gateway.go | 68 +++--------------------- gateway/core/corehttp/gateway_handler.go | 10 +--- gateway/core/corehttp/gateway_test.go | 8 ++- 3 files changed, 17 insertions(+), 69 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 0d9453e1e..d0cf597bf 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -4,60 +4,38 @@ import ( "fmt" "net" "net/http" - "sync" core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" id "gx/ipfs/QmdBpVuSYuTGDA8Kn66CbKvEThXqKUh2nTANZEhzSxqrmJ/go-libp2p/p2p/protocol/identify" ) -// Gateway should be instantiated using NewGateway -type Gateway struct { - Config GatewayConfig -} - type GatewayConfig struct { Headers map[string][]string - BlockList *BlockList Writable bool PathPrefixes []string } -func NewGateway(conf GatewayConfig) *Gateway { - return &Gateway{ - Config: conf, - } -} - -func (g *Gateway) ServeOption() ServeOption { +func GatewayOption(paths ...string) ServeOption { return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - // pass user's HTTP headers cfg, err := n.Repo.Config() if err != nil { return nil, err } - g.Config.Headers = cfg.Gateway.HTTPHeaders + gateway := newGatewayHandler(n, GatewayConfig{ + Headers: cfg.Gateway.HTTPHeaders, + Writable: cfg.Gateway.Writable, + PathPrefixes: cfg.Gateway.PathPrefixes, + }) - gateway, err := newGatewayHandler(n, g.Config) - if err != nil { - return nil, err + for _, p := range paths { + mux.Handle(p+"/", gateway) } - mux.Handle("/ipfs/", gateway) - mux.Handle("/ipns/", gateway) return mux, nil } } -func GatewayOption(writable bool, prefixes []string) ServeOption { - g := NewGateway(GatewayConfig{ - Writable: writable, - BlockList: &BlockList{}, - PathPrefixes: prefixes, - }) - return g.ServeOption() -} - func VersionOption() ServeOption { return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { @@ -68,33 +46,3 @@ func VersionOption() ServeOption { return mux, nil } } - -// Decider decides whether to Allow string -type Decider func(string) bool - -type BlockList struct { - mu sync.RWMutex - Decider Decider -} - -func (b *BlockList) ShouldAllow(s string) bool { - b.mu.RLock() - d := b.Decider - b.mu.RUnlock() - if d == nil { - return true - } - return d(s) -} - -// SetDecider atomically swaps the blocklist's decider. This method is -// thread-safe. -func (b *BlockList) SetDecider(d Decider) { - b.mu.Lock() - b.Decider = d - b.mu.Unlock() -} - -func (b *BlockList) ShouldBlock(s string) bool { - return !b.ShouldAllow(s) -} diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index f6f870559..8313e877e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -36,12 +36,12 @@ type gatewayHandler struct { config GatewayConfig } -func newGatewayHandler(node *core.IpfsNode, conf GatewayConfig) (*gatewayHandler, error) { +func newGatewayHandler(node *core.IpfsNode, conf GatewayConfig) *gatewayHandler { i := &gatewayHandler{ node: node, config: conf, } - return i, nil + return i } // TODO(cryptix): find these helpers somewhere else @@ -152,12 +152,6 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request ipnsHostname = true } - if i.config.BlockList != nil && i.config.BlockList.ShouldBlock(urlPath) { - w.WriteHeader(http.StatusForbidden) - w.Write([]byte("403 - Forbidden")) - return - } - nd, err := core.Resolve(ctx, i.node, path.Path(urlPath)) // If node is in offline mode the error code and message should be different if err == core.ErrNoNamesys && !i.node.OnlineMode() { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index f8a01aa52..b966d329f 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -89,6 +89,12 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, *core t.Fatal(err) } + cfg, err := n.Repo.Config() + if err != nil { + t.Fatal(err) + } + cfg.Gateway.PathPrefixes = []string{"/good-prefix"} + // need this variable here since we need to construct handler with // listener, and server with handler. yay cycles. dh := &delegatedHandler{} @@ -98,7 +104,7 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, *core ts.Listener, VersionOption(), IPNSHostnameOption(), - GatewayOption(false, []string{"/good-prefix"}), + GatewayOption("/ipfs", "/ipns"), ) if err != nil { t.Fatal(err) From f9498adec96afd544e9bc441b050eb856d0086e0 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 24 Jun 2016 18:38:07 +0200 Subject: [PATCH 156/674] Update go-log in whole dependency tree (#2898) * Update golog in go-ipfs License: MIT Signed-off-by: Jakub Sztandera * Update go-libp2p for go-log License: MIT Signed-off-by: Jakub Sztandera * Update go-libp2p-secio for go-log License: MIT Signed-off-by: Jakub Sztandera * Update go-libp2p-crypto for go-log License: MIT Signed-off-by: Jakub Sztandera * Update go-libp2p-peer for go-log License: MIT Signed-off-by: Jakub Sztandera * Import peersore, it wasn't imported License: MIT Signed-off-by: Jakub Sztandera * Update peerstore License: MIT Signed-off-by: Jakub Sztandera * Update peer License: MIT Signed-off-by: Jakub Sztandera * Update secio License: MIT Signed-off-by: Jakub Sztandera * Update go-libp2p License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@ce8c8a7a715cb887630f852b5305bb22d070b145 --- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 4 ++-- gateway/core/corehttp/logs.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index dd28a87bc..bbd5c061a 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -11,9 +11,9 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + logging "gx/ipfs/QmNQynaz7qfriSUJkiEZUrm2Wen1u3Kj9goZzWtrPyu7XR/go-log" manet "gx/ipfs/QmPpRcbNUXauP3zWZ1NJMLWpe4QnmEHrd2ba2D3yqWznw7/go-multiaddr-net" "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" - logging "gx/ipfs/QmYtB7Qge8cJpXc4irsEp8zRqfnZMBeB7aTrMEkPk67DRv/go-log" ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index d0cf597bf..2d6ca62f9 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,7 +7,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmdBpVuSYuTGDA8Kn66CbKvEThXqKUh2nTANZEhzSxqrmJ/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZ8bCZpMWDbFSh6h2zgTYwrhnjrGM5c9WCzw72SU8p63b/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index b966d329f..4602f6b5b 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,9 +16,9 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - ci "gx/ipfs/QmUEUu1CM8bxBJxc3ZLojAi8evhTr4byQogWstABet79oY/go-libp2p-crypto" + ci "gx/ipfs/QmUWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP/go-libp2p-crypto" + id "gx/ipfs/QmZ8bCZpMWDbFSh6h2zgTYwrhnjrGM5c9WCzw72SU8p63b/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - id "gx/ipfs/QmdBpVuSYuTGDA8Kn66CbKvEThXqKUh2nTANZEhzSxqrmJ/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 78dd03525..9ac63648a 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - logging "gx/ipfs/QmYtB7Qge8cJpXc4irsEp8zRqfnZMBeB7aTrMEkPk67DRv/go-log" + logging "gx/ipfs/QmNQynaz7qfriSUJkiEZUrm2Wen1u3Kj9goZzWtrPyu7XR/go-log" ) type writeErrNotifier struct { diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 25ed8f57d..2c68e0bb1 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,10 +5,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + bhost "gx/ipfs/QmZ8bCZpMWDbFSh6h2zgTYwrhnjrGM5c9WCzw72SU8p63b/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmZ8bCZpMWDbFSh6h2zgTYwrhnjrGM5c9WCzw72SU8p63b/go-libp2p/p2p/net" + testutil "gx/ipfs/QmZ8bCZpMWDbFSh6h2zgTYwrhnjrGM5c9WCzw72SU8p63b/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - bhost "gx/ipfs/QmdBpVuSYuTGDA8Kn66CbKvEThXqKUh2nTANZEhzSxqrmJ/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmdBpVuSYuTGDA8Kn66CbKvEThXqKUh2nTANZEhzSxqrmJ/go-libp2p/p2p/net" - testutil "gx/ipfs/QmdBpVuSYuTGDA8Kn66CbKvEThXqKUh2nTANZEhzSxqrmJ/go-libp2p/p2p/test/util" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From d00b8e3cef18556771dc82f2118261c1aef0c7ff Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 4 Jul 2016 12:27:26 -0700 Subject: [PATCH 157/674] update go-libp2p License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@979edf3a96572e5c2ed9137023fa4c9b7ae01aa2 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 2d6ca62f9..ccc706269 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,7 +7,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmZ8bCZpMWDbFSh6h2zgTYwrhnjrGM5c9WCzw72SU8p63b/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmVCe3SNMjkcPgnpFhZs719dheq6xE7gJwjzV7aWcUM4Ms/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 4602f6b5b..fc25bf4ca 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,7 +17,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" ci "gx/ipfs/QmUWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP/go-libp2p-crypto" - id "gx/ipfs/QmZ8bCZpMWDbFSh6h2zgTYwrhnjrGM5c9WCzw72SU8p63b/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmVCe3SNMjkcPgnpFhZs719dheq6xE7gJwjzV7aWcUM4Ms/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 2c68e0bb1..2bd115ae0 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,9 +5,9 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmZ8bCZpMWDbFSh6h2zgTYwrhnjrGM5c9WCzw72SU8p63b/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmZ8bCZpMWDbFSh6h2zgTYwrhnjrGM5c9WCzw72SU8p63b/go-libp2p/p2p/net" - testutil "gx/ipfs/QmZ8bCZpMWDbFSh6h2zgTYwrhnjrGM5c9WCzw72SU8p63b/go-libp2p/p2p/test/util" + bhost "gx/ipfs/QmVCe3SNMjkcPgnpFhZs719dheq6xE7gJwjzV7aWcUM4Ms/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmVCe3SNMjkcPgnpFhZs719dheq6xE7gJwjzV7aWcUM4Ms/go-libp2p/p2p/net" + testutil "gx/ipfs/QmVCe3SNMjkcPgnpFhZs719dheq6xE7gJwjzV7aWcUM4Ms/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" ) From c8ca6253b302668e2d5bb0da27b87d9b3575e24e Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 10 Jul 2016 00:40:23 -0700 Subject: [PATCH 158/674] cache encoded data when reading dag nodes from disk License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@bf23516dc0dea968ebe9458b7a1ad3ccc39258d1 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 8313e877e..88b7a8587 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -391,7 +391,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { case nil: // object set-data case - rnode.Data = newnode.Data + rnode.SetData(newnode.Data()) newkey, err = i.node.DAG.Add(rnode) if err != nil { From 13a8a7615c45f385ed5f421a77eb79e82f235d1d Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 12 Aug 2016 16:41:18 +0200 Subject: [PATCH 159/674] deps: move go-is-domain to gx License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@cf23ab9ff4bb8f9cfe99d65a32869a3fd71b7554 --- gateway/core/corehttp/ipns_hostname.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index c6b144040..b9fc25c1a 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -5,9 +5,9 @@ import ( "net/http" "strings" - isd "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-is-domain" "github.com/ipfs/go-ipfs/core" "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + isd "gx/ipfs/QmaeHSCBd9XjXxmgHEiKkHtLcMCb2eZsPLKT7bHgBfBkqw/go-is-domain" ) // IPNSHostnameOption rewrites an incoming request if its Host: header contains From 7245a94e6ccfcb48ef39c80809f3e32b2db6fe74 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 22 Aug 2016 22:29:25 -0700 Subject: [PATCH 160/674] update deps for libp2p 3.4.0 License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@05b197df2dd9b9202f071b617ed68660eb0e1b58 --- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 4 ++-- gateway/core/corehttp/logs.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index bbd5c061a..51deda011 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -11,9 +11,9 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - logging "gx/ipfs/QmNQynaz7qfriSUJkiEZUrm2Wen1u3Kj9goZzWtrPyu7XR/go-log" manet "gx/ipfs/QmPpRcbNUXauP3zWZ1NJMLWpe4QnmEHrd2ba2D3yqWznw7/go-multiaddr-net" "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" + logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index ccc706269..54bd8e407 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,7 +7,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmVCe3SNMjkcPgnpFhZs719dheq6xE7gJwjzV7aWcUM4Ms/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/Qmf4ETeAWXuThBfWwonVyFqGFSgTWepUDEr1txcctvpTXS/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index fc25bf4ca..b532913fd 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,9 +16,9 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - ci "gx/ipfs/QmUWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP/go-libp2p-crypto" - id "gx/ipfs/QmVCe3SNMjkcPgnpFhZs719dheq6xE7gJwjzV7aWcUM4Ms/go-libp2p/p2p/protocol/identify" + ci "gx/ipfs/QmVoi5es8D5fNHZDqoW6DgDAEPEV5hQp8GBz161vZXiwpQ/go-libp2p-crypto" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + id "gx/ipfs/Qmf4ETeAWXuThBfWwonVyFqGFSgTWepUDEr1txcctvpTXS/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 9ac63648a..d0dd96aa1 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - logging "gx/ipfs/QmNQynaz7qfriSUJkiEZUrm2Wen1u3Kj9goZzWtrPyu7XR/go-log" + logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" ) type writeErrNotifier struct { diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 2bd115ae0..5d3a72e22 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,10 +5,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmVCe3SNMjkcPgnpFhZs719dheq6xE7gJwjzV7aWcUM4Ms/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmVCe3SNMjkcPgnpFhZs719dheq6xE7gJwjzV7aWcUM4Ms/go-libp2p/p2p/net" - testutil "gx/ipfs/QmVCe3SNMjkcPgnpFhZs719dheq6xE7gJwjzV7aWcUM4Ms/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + bhost "gx/ipfs/Qmf4ETeAWXuThBfWwonVyFqGFSgTWepUDEr1txcctvpTXS/go-libp2p/p2p/host/basic" + inet "gx/ipfs/Qmf4ETeAWXuThBfWwonVyFqGFSgTWepUDEr1txcctvpTXS/go-libp2p/p2p/net" + testutil "gx/ipfs/Qmf4ETeAWXuThBfWwonVyFqGFSgTWepUDEr1txcctvpTXS/go-libp2p/p2p/test/util" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 575ce9a26d30de1c76aec353a1c2390bdcbd7ab9 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 1 Sep 2016 07:50:27 -0700 Subject: [PATCH 161/674] integrate CIDv0 License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@c8fe49593448927ea4114f27805b3bccab9eab22 --- gateway/core/corehttp/gateway_handler.go | 55 ++++++++++-------------- gateway/core/corehttp/gateway_test.go | 10 +---- 2 files changed, 25 insertions(+), 40 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 88b7a8587..659d847b3 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -12,8 +12,8 @@ import ( humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + cid "gx/ipfs/QmfSc2xehWmWLnwwYR91Y8QF4xdASypTFVknutoKQS3GHp/go-cid" - key "github.com/ipfs/go-ipfs/blocks/key" core "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/importer" chunk "github.com/ipfs/go-ipfs/importer/chunk" @@ -357,14 +357,20 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { newPath = path.Join(rsegs[2:]) } - var newkey key.Key + var newcid *cid.Cid rnode, err := core.Resolve(ctx, i.node, rootPath) switch ev := err.(type) { case path.ErrNoLink: // ev.Node < node where resolve failed // ev.Name < new link // but we need to patch from the root - rnode, err := i.node.DAG.Get(ctx, key.B58KeyDecode(rsegs[1])) + c, err := cid.Decode(rsegs[1]) + if err != nil { + webError(w, "putHandler: bad input path", err, http.StatusBadRequest) + return + } + + rnode, err := i.node.DAG.Get(ctx, c) if err != nil { webError(w, "putHandler: Could not create DAG from request", err, http.StatusInternalServerError) return @@ -383,21 +389,17 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } - newkey, err = nnode.Key() - if err != nil { - webError(w, "putHandler: could not get key of edited node", err, http.StatusInternalServerError) - return - } + newcid = nnode.Cid() case nil: // object set-data case rnode.SetData(newnode.Data()) - newkey, err = i.node.DAG.Add(rnode) + newcid, err = i.node.DAG.Add(rnode) if err != nil { - nnk, _ := newnode.Key() - rk, _ := rnode.Key() - webError(w, fmt.Sprintf("putHandler: Could not add newnode(%q) to root(%q)", nnk.B58String(), rk.B58String()), err, http.StatusInternalServerError) + nnk := newnode.Cid() + rk := rnode.Cid() + webError(w, fmt.Sprintf("putHandler: Could not add newnode(%q) to root(%q)", nnk.String(), rk.String()), err, http.StatusInternalServerError) return } default: @@ -407,8 +409,8 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { } i.addUserHeaders(w) // ok, _now_ write user's headers. - w.Header().Set("IPFS-Hash", newkey.String()) - http.Redirect(w, r, gopath.Join(ipfsPathPrefix, newkey.String(), newPath), http.StatusCreated) + w.Header().Set("IPFS-Hash", newcid.String()) + http.Redirect(w, r, gopath.Join(ipfsPathPrefix, newcid.String(), newPath), http.StatusCreated) } func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { @@ -416,20 +418,13 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { ctx, cancel := context.WithCancel(i.node.Context()) defer cancel() - ipfsNode, err := core.Resolve(ctx, i.node, path.Path(urlPath)) + p, err := path.ParsePath(urlPath) if err != nil { - // FIXME HTTP error code - webError(w, "Could not resolve name", err, http.StatusInternalServerError) + webError(w, "failed to parse path", err, http.StatusBadRequest) return } - k, err := ipfsNode.Key() - if err != nil { - webError(w, "Could not get key from resolved node", err, http.StatusInternalServerError) - return - } - - h, components, err := path.SplitAbsPath(path.FromKey(k)) + c, components, err := path.SplitAbsPath(p) if err != nil { webError(w, "Could not split path", err, http.StatusInternalServerError) return @@ -437,7 +432,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { tctx, cancel := context.WithTimeout(ctx, time.Minute) defer cancel() - rootnd, err := i.node.Resolver.DAG.Get(tctx, key.Key(h)) + rootnd, err := i.node.Resolver.DAG.Get(tctx, c) if err != nil { webError(w, "Could not resolve root object", err, http.StatusBadRequest) return @@ -475,15 +470,11 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { } // Redirect to new path - key, err := newnode.Key() - if err != nil { - webError(w, "Could not get key of new node", err, http.StatusInternalServerError) - return - } + ncid := newnode.Cid() i.addUserHeaders(w) // ok, _now_ write user's headers. - w.Header().Set("IPFS-Hash", key.String()) - http.Redirect(w, r, gopath.Join(ipfsPathPrefix+key.String(), path.Join(components[:len(components)-1])), http.StatusCreated) + w.Header().Set("IPFS-Hash", ncid.String()) + http.Redirect(w, r, gopath.Join(ipfsPathPrefix+ncid.String(), path.Join(components[:len(components)-1])), http.StatusCreated) } func (i *gatewayHandler) addUserHeaders(w http.ResponseWriter) { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index b532913fd..81e0412b3 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -197,10 +197,7 @@ func TestIPNSHostnameRedirect(t *testing.T) { t.Fatal(err) } - k, err := dagn1.Key() - if err != nil { - t.Fatal(err) - } + k := dagn1.Key() t.Logf("k: %s\n", k) ns["/ipns/example.net"] = path.FromString("/ipfs/" + k.String()) @@ -290,10 +287,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { t.Fatal(err) } - k, err := dagn1.Key() - if err != nil { - t.Fatal(err) - } + k := dagn1.Key() t.Logf("k: %s\n", k) ns["/ipns/example.net"] = path.FromString("/ipfs/" + k.String()) From 11ecc14889aa9c4a76c7f83409e4c6a728db3d80 Mon Sep 17 00:00:00 2001 From: George Antoniadis Date: Fri, 9 Sep 2016 15:41:28 +0100 Subject: [PATCH 162/674] Extract key and datastore License: MIT Signed-off-by: George Antoniadis This commit was moved from ipfs/kubo@6859b8ccd8ae73ca7d50833b90ca69a6b37b9611 --- gateway/core/corehttp/corehttp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 51deda011..e4f952919 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,7 +12,7 @@ import ( core "github.com/ipfs/go-ipfs/core" manet "gx/ipfs/QmPpRcbNUXauP3zWZ1NJMLWpe4QnmEHrd2ba2D3yqWznw7/go-multiaddr-net" - "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" + "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr" ) From 77f3664bfee8b9ac30412f80ef2c906835f77158 Mon Sep 17 00:00:00 2001 From: George Antoniadis Date: Sat, 10 Sep 2016 23:22:17 +0100 Subject: [PATCH 163/674] Extract peerset, update peer, peerset, secio, libp2p License: MIT Signed-off-by: George Antoniadis This commit was moved from ipfs/kubo@89d8ca5798e72f22f9f6aff62b270c6b3ac1fa92 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 54bd8e407..869fbf815 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,7 +7,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/Qmf4ETeAWXuThBfWwonVyFqGFSgTWepUDEr1txcctvpTXS/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmXnaDLonE9YBTVDdWBM6Jb5YxxmW1MHMkXzgsnu1jTEmK/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 81e0412b3..f9e8fc0f1 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,8 +17,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" ci "gx/ipfs/QmVoi5es8D5fNHZDqoW6DgDAEPEV5hQp8GBz161vZXiwpQ/go-libp2p-crypto" + id "gx/ipfs/QmXnaDLonE9YBTVDdWBM6Jb5YxxmW1MHMkXzgsnu1jTEmK/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - id "gx/ipfs/Qmf4ETeAWXuThBfWwonVyFqGFSgTWepUDEr1txcctvpTXS/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 5d3a72e22..7d2dcf7fd 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,10 +5,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + bhost "gx/ipfs/QmXnaDLonE9YBTVDdWBM6Jb5YxxmW1MHMkXzgsnu1jTEmK/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmXnaDLonE9YBTVDdWBM6Jb5YxxmW1MHMkXzgsnu1jTEmK/go-libp2p/p2p/net" + testutil "gx/ipfs/QmXnaDLonE9YBTVDdWBM6Jb5YxxmW1MHMkXzgsnu1jTEmK/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - bhost "gx/ipfs/Qmf4ETeAWXuThBfWwonVyFqGFSgTWepUDEr1txcctvpTXS/go-libp2p/p2p/host/basic" - inet "gx/ipfs/Qmf4ETeAWXuThBfWwonVyFqGFSgTWepUDEr1txcctvpTXS/go-libp2p/p2p/net" - testutil "gx/ipfs/Qmf4ETeAWXuThBfWwonVyFqGFSgTWepUDEr1txcctvpTXS/go-libp2p/p2p/test/util" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 623c526fd31559679c07a6d0bb6fc146512a6d97 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sun, 11 Sep 2016 05:51:44 +0200 Subject: [PATCH 164/674] gateway: fix --writable flag :| License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@fc8e6de6a9232830b4219adbf1bbd7a1073f668a --- gateway/core/corehttp/gateway.go | 4 ++-- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 869fbf815..06e073297 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -16,7 +16,7 @@ type GatewayConfig struct { PathPrefixes []string } -func GatewayOption(paths ...string) ServeOption { +func GatewayOption(writable bool, paths ...string) ServeOption { return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { cfg, err := n.Repo.Config() if err != nil { @@ -25,7 +25,7 @@ func GatewayOption(paths ...string) ServeOption { gateway := newGatewayHandler(n, GatewayConfig{ Headers: cfg.Gateway.HTTPHeaders, - Writable: cfg.Gateway.Writable, + Writable: writable, PathPrefixes: cfg.Gateway.PathPrefixes, }) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index f9e8fc0f1..61c120cc7 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -104,7 +104,7 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, *core ts.Listener, VersionOption(), IPNSHostnameOption(), - GatewayOption("/ipfs", "/ipns"), + GatewayOption(false, "/ipfs", "/ipns"), ) if err != nil { t.Fatal(err) From 01a04c8ecbe74fdac0d48a619c2cc6458993a67b Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 12 Sep 2016 07:47:04 -0700 Subject: [PATCH 165/674] Update libp2p to have fixed spdystream dep License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@1bb6a842c5b32f1cc72849ee09b2c74807c4eef5 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 869fbf815..a59bea4c4 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,7 +7,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmXnaDLonE9YBTVDdWBM6Jb5YxxmW1MHMkXzgsnu1jTEmK/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmcpZpCmnfjRunzeYtXZdtcy16P2mC65CThjb7aA8sPqNY/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index f9e8fc0f1..500a3c90c 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,8 +17,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" ci "gx/ipfs/QmVoi5es8D5fNHZDqoW6DgDAEPEV5hQp8GBz161vZXiwpQ/go-libp2p-crypto" - id "gx/ipfs/QmXnaDLonE9YBTVDdWBM6Jb5YxxmW1MHMkXzgsnu1jTEmK/go-libp2p/p2p/protocol/identify" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + id "gx/ipfs/QmcpZpCmnfjRunzeYtXZdtcy16P2mC65CThjb7aA8sPqNY/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 7d2dcf7fd..a06fd187b 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,10 +5,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmXnaDLonE9YBTVDdWBM6Jb5YxxmW1MHMkXzgsnu1jTEmK/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmXnaDLonE9YBTVDdWBM6Jb5YxxmW1MHMkXzgsnu1jTEmK/go-libp2p/p2p/net" - testutil "gx/ipfs/QmXnaDLonE9YBTVDdWBM6Jb5YxxmW1MHMkXzgsnu1jTEmK/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + bhost "gx/ipfs/QmcpZpCmnfjRunzeYtXZdtcy16P2mC65CThjb7aA8sPqNY/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmcpZpCmnfjRunzeYtXZdtcy16P2mC65CThjb7aA8sPqNY/go-libp2p/p2p/net" + testutil "gx/ipfs/QmcpZpCmnfjRunzeYtXZdtcy16P2mC65CThjb7aA8sPqNY/go-libp2p/p2p/test/util" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From f893f425d7f62b76510097272fe45d289d48487f Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 12 Sep 2016 14:26:55 -0700 Subject: [PATCH 166/674] Update libp2p to 3.5.2 License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@1de17e2233ca2875db17c39fd40e8a09b936feda --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index a59bea4c4..acb1c923c 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,7 +7,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmcpZpCmnfjRunzeYtXZdtcy16P2mC65CThjb7aA8sPqNY/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmUuwQUJmtvC6ReYcu7xaYKEUM3pD46H18dFn3LBhVt2Di/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 500a3c90c..ed600d2bf 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,9 +16,9 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" + id "gx/ipfs/QmUuwQUJmtvC6ReYcu7xaYKEUM3pD46H18dFn3LBhVt2Di/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmVoi5es8D5fNHZDqoW6DgDAEPEV5hQp8GBz161vZXiwpQ/go-libp2p-crypto" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - id "gx/ipfs/QmcpZpCmnfjRunzeYtXZdtcy16P2mC65CThjb7aA8sPqNY/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index a06fd187b..41a0af581 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,10 +5,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + bhost "gx/ipfs/QmUuwQUJmtvC6ReYcu7xaYKEUM3pD46H18dFn3LBhVt2Di/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmUuwQUJmtvC6ReYcu7xaYKEUM3pD46H18dFn3LBhVt2Di/go-libp2p/p2p/net" + testutil "gx/ipfs/QmUuwQUJmtvC6ReYcu7xaYKEUM3pD46H18dFn3LBhVt2Di/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - bhost "gx/ipfs/QmcpZpCmnfjRunzeYtXZdtcy16P2mC65CThjb7aA8sPqNY/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmcpZpCmnfjRunzeYtXZdtcy16P2mC65CThjb7aA8sPqNY/go-libp2p/p2p/net" - testutil "gx/ipfs/QmcpZpCmnfjRunzeYtXZdtcy16P2mC65CThjb7aA8sPqNY/go-libp2p/p2p/test/util" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 96d0177d98ce1211054ae547f3a3062ed2f36248 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Mon, 5 Sep 2016 16:38:44 +0200 Subject: [PATCH 167/674] metrics: update prometheus License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@a2bb6e8edf22e7339f4835ca022ebd9bc812c231 --- gateway/core/corehttp/metrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 4dee41aed..5e16d04f4 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -4,9 +4,9 @@ import ( "net" "net/http" - prometheus "gx/ipfs/QmdhsRK1EK2fvAz2i2SH5DEfkL6seDuyMYEsxKa9Braim3/client_golang/prometheus" - core "github.com/ipfs/go-ipfs/core" + + prometheus "gx/ipfs/QmR3KwhXCRLTNZB59vELb2HhEWrGy9nuychepxFtj3wWYa/client_golang/prometheus" ) // This adds the scraping endpoint which Prometheus uses to fetch metrics. From b6d8304201acf9561ba937bd31078eaf871dcf62 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 6 Sep 2016 09:49:59 +0200 Subject: [PATCH 168/674] metrics: fix peer number metric in offline mode License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@7faa32459af68ee8b49b7ec2bf54030b31a0f139 --- gateway/core/corehttp/metrics.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 5e16d04f4..0ef0ba6f4 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -53,6 +53,9 @@ func (c IpfsNodeCollector) Collect(ch chan<- prometheus.Metric) { func (c IpfsNodeCollector) PeersTotalValues() map[string]float64 { vals := make(map[string]float64) + if c.Node.PeerHost == nil { + return vals + } for _, conn := range c.Node.PeerHost.Network().Conns() { tr := "" for _, proto := range conn.RemoteMultiaddr().Protocols() { From 1578fb9918bac7f2374d59aa705c4d8d536c6d34 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 13 Sep 2016 15:17:07 -0700 Subject: [PATCH 169/674] routing: use extracted dht and routing code License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@2e6e0f18e3d7345536e46a48e318f9faee732ec6 --- gateway/core/corehttp/gateway_handler.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 659d847b3..ae1097965 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -10,18 +10,18 @@ import ( "strings" "time" - humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - cid "gx/ipfs/QmfSc2xehWmWLnwwYR91Y8QF4xdASypTFVknutoKQS3GHp/go-cid" - core "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/importer" chunk "github.com/ipfs/go-ipfs/importer/chunk" dag "github.com/ipfs/go-ipfs/merkledag" dagutils "github.com/ipfs/go-ipfs/merkledag/utils" path "github.com/ipfs/go-ipfs/path" - "github.com/ipfs/go-ipfs/routing" uio "github.com/ipfs/go-ipfs/unixfs/io" + + humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" + "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + routing "gx/ipfs/QmcoQiBzRaaVv1DZbbXoDWiEtvDN94Ca1DcwnQKK2tP92s/go-libp2p-routing" + cid "gx/ipfs/QmfSc2xehWmWLnwwYR91Y8QF4xdASypTFVknutoKQS3GHp/go-cid" ) const ( From 35a67cd2b5d8cca0983dccef1971bb982d625bd4 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 25 Sep 2016 23:42:14 -0700 Subject: [PATCH 170/674] update libp2p and dht packages License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@e43c770530ca32180de8b5f2b151b73393b3d535 --- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index e4f952919..51deda011 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,7 +12,7 @@ import ( core "github.com/ipfs/go-ipfs/core" manet "gx/ipfs/QmPpRcbNUXauP3zWZ1NJMLWpe4QnmEHrd2ba2D3yqWznw7/go-multiaddr-net" - "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" + "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 9a8fd005d..731a09187 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,7 +7,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmUuwQUJmtvC6ReYcu7xaYKEUM3pD46H18dFn3LBhVt2Di/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmbiRCGZqhfcSjnm9icGz3oNQQdPLAnLWnKHXixaEWXVCN/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ae1097965..407e8db10 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -20,7 +20,7 @@ import ( humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - routing "gx/ipfs/QmcoQiBzRaaVv1DZbbXoDWiEtvDN94Ca1DcwnQKK2tP92s/go-libp2p-routing" + routing "gx/ipfs/QmemZcG8WprPbnVX3AM43GhhSUiA3V6NjcTLAguvWzkdpQ/go-libp2p-routing" cid "gx/ipfs/QmfSc2xehWmWLnwwYR91Y8QF4xdASypTFVknutoKQS3GHp/go-cid" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index ac72580bd..9abcd7dc8 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,9 +16,9 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmUuwQUJmtvC6ReYcu7xaYKEUM3pD46H18dFn3LBhVt2Di/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmVoi5es8D5fNHZDqoW6DgDAEPEV5hQp8GBz161vZXiwpQ/go-libp2p-crypto" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + id "gx/ipfs/QmbiRCGZqhfcSjnm9icGz3oNQQdPLAnLWnKHXixaEWXVCN/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 41a0af581..5ad77f337 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,10 +5,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmUuwQUJmtvC6ReYcu7xaYKEUM3pD46H18dFn3LBhVt2Di/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmUuwQUJmtvC6ReYcu7xaYKEUM3pD46H18dFn3LBhVt2Di/go-libp2p/p2p/net" - testutil "gx/ipfs/QmUuwQUJmtvC6ReYcu7xaYKEUM3pD46H18dFn3LBhVt2Di/go-libp2p/p2p/test/util" context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" + bhost "gx/ipfs/QmbiRCGZqhfcSjnm9icGz3oNQQdPLAnLWnKHXixaEWXVCN/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmbiRCGZqhfcSjnm9icGz3oNQQdPLAnLWnKHXixaEWXVCN/go-libp2p/p2p/net" + testutil "gx/ipfs/QmbiRCGZqhfcSjnm9icGz3oNQQdPLAnLWnKHXixaEWXVCN/go-libp2p/p2p/test/util" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 330f0915c1b2d70a9eb7b698defff6672c50ade9 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 30 Sep 2016 16:33:00 -0700 Subject: [PATCH 171/674] update floodsub version 0.6.2 License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@91db6f31c28e9bb59729cb85e254354114c207dc --- gateway/core/corehttp/corehttp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 51deda011..f776fbc63 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -11,9 +11,9 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - manet "gx/ipfs/QmPpRcbNUXauP3zWZ1NJMLWpe4QnmEHrd2ba2D3yqWznw7/go-multiaddr-net" "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" + manet "gx/ipfs/QmY83KqqnQ286ZWbV2x7ixpeemH3cBpk8R54egS619WYff/go-multiaddr-net" ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr" ) From 4906ff36daa251118d52b8b084554ea059bdf9c4 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 5 Oct 2016 15:49:08 -0700 Subject: [PATCH 172/674] update to libp2p 4.0.1 and propogate other changes License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@1f9ec4e3ed1334ad4aa66a82391d1bc57cd03cf6 --- gateway/core/corehttp/corehttp.go | 6 +++--- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 6 +++--- gateway/core/corehttp/gateway_test.go | 6 +++--- gateway/core/corehttp/ipns_hostname.go | 2 +- gateway/core/corehttp/metrics_test.go | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index f776fbc63..06e7cc8c5 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -11,10 +11,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess" + "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" - manet "gx/ipfs/QmY83KqqnQ286ZWbV2x7ixpeemH3cBpk8R54egS619WYff/go-multiaddr-net" - ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr" + manet "gx/ipfs/QmT6Cp31887FpAc25z25YHgpFJohZedrYLWPPspRtj1Brp/go-multiaddr-net" + ma "gx/ipfs/QmUAQaWbKxGCUTuoQVvvicbQNZ9APF5pDGWyAZSe93AtKH/go-multiaddr" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 731a09187..4aa26fed7 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,7 +7,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmbiRCGZqhfcSjnm9icGz3oNQQdPLAnLWnKHXixaEWXVCN/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmcRa2qn6iCmap9bjp8jAwkvYAq13AUfxdY3rrYiaJbLum/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 407e8db10..73059cacc 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -18,10 +18,10 @@ import ( path "github.com/ipfs/go-ipfs/path" uio "github.com/ipfs/go-ipfs/unixfs/io" + "context" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - routing "gx/ipfs/QmemZcG8WprPbnVX3AM43GhhSUiA3V6NjcTLAguvWzkdpQ/go-libp2p-routing" - cid "gx/ipfs/QmfSc2xehWmWLnwwYR91Y8QF4xdASypTFVknutoKQS3GHp/go-cid" + routing "gx/ipfs/QmXKuGUzLcgoQvp8M6ZEJzupWUNmx8NoqXEbYLMDjL4rjj/go-libp2p-routing" + cid "gx/ipfs/QmakyCk6Vnn16WEKjbkxieZmM2YLTzkFWizbmGowoYPjro/go-cid" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 9abcd7dc8..ba8a936ac 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -9,6 +9,7 @@ import ( "testing" "time" + context "context" core "github.com/ipfs/go-ipfs/core" coreunix "github.com/ipfs/go-ipfs/core/coreunix" namesys "github.com/ipfs/go-ipfs/namesys" @@ -16,9 +17,8 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - ci "gx/ipfs/QmVoi5es8D5fNHZDqoW6DgDAEPEV5hQp8GBz161vZXiwpQ/go-libp2p-crypto" - context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - id "gx/ipfs/QmbiRCGZqhfcSjnm9icGz3oNQQdPLAnLWnKHXixaEWXVCN/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmcRa2qn6iCmap9bjp8jAwkvYAq13AUfxdY3rrYiaJbLum/go-libp2p/p2p/protocol/identify" + ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index b9fc25c1a..e22912e3d 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -5,8 +5,8 @@ import ( "net/http" "strings" + "context" "github.com/ipfs/go-ipfs/core" - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" isd "gx/ipfs/QmaeHSCBd9XjXxmgHEiKkHtLcMCb2eZsPLKT7bHgBfBkqw/go-is-domain" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 5ad77f337..278f10951 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -4,11 +4,11 @@ import ( "testing" "time" + context "context" core "github.com/ipfs/go-ipfs/core" - context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context" - bhost "gx/ipfs/QmbiRCGZqhfcSjnm9icGz3oNQQdPLAnLWnKHXixaEWXVCN/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmbiRCGZqhfcSjnm9icGz3oNQQdPLAnLWnKHXixaEWXVCN/go-libp2p/p2p/net" - testutil "gx/ipfs/QmbiRCGZqhfcSjnm9icGz3oNQQdPLAnLWnKHXixaEWXVCN/go-libp2p/p2p/test/util" + bhost "gx/ipfs/QmcRa2qn6iCmap9bjp8jAwkvYAq13AUfxdY3rrYiaJbLum/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmcRa2qn6iCmap9bjp8jAwkvYAq13AUfxdY3rrYiaJbLum/go-libp2p/p2p/test/util" + inet "gx/ipfs/QmdXimY9QHaasZmw6hWojWnCJvfgxETjZQfg9g6ZrA9wMX/go-libp2p-net" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From abe5c6cd8026c62d587443e2966217d1d22572de Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sat, 8 Oct 2016 17:59:41 -0700 Subject: [PATCH 173/674] bitswap: protocol extension to handle cids This change adds the /ipfs/bitswap/1.1.0 protocol. The new protocol adds a 'payload' field to the protobuf message and deprecates the existing 'blocks' field. The 'payload' field is an array of pairs of cid prefixes and block data. The cid prefixes are used to ensure the correct codecs and hash functions are used to handle the block on the receiving end. License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@f4d7369c4a0eda7adf6fa0277a48db057e6c8ca2 --- gateway/core/corehttp/gateway_handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 73059cacc..62cfa7269 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -19,9 +19,9 @@ import ( uio "github.com/ipfs/go-ipfs/unixfs/io" "context" + routing "gx/ipfs/QmNUgVQTYnXQVrGT2rajZYsuKV8GYdiL91cdZSQDKNPNgE/go-libp2p-routing" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - routing "gx/ipfs/QmXKuGUzLcgoQvp8M6ZEJzupWUNmx8NoqXEbYLMDjL4rjj/go-libp2p-routing" - cid "gx/ipfs/QmakyCk6Vnn16WEKjbkxieZmM2YLTzkFWizbmGowoYPjro/go-cid" + cid "gx/ipfs/QmXUuRadqDq5BuFWzVU6VuKaSjTcNm1gNCtLvvP1TJCW4z/go-cid" ) const ( From 18d25839a7305d9dd118135eacb1c6744a20a6f6 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 9 Oct 2016 12:59:36 -0700 Subject: [PATCH 174/674] merkledag: change 'Node' to be an interface Also change existing 'Node' type to 'ProtoNode' and use that most everywhere for now. As we move forward with the integration we will try and use the Node interface in more places that we're currently using ProtoNode. License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@01aee44679dd8cacd0ca198206041e3c3d7c48af --- gateway/core/corehttp/gateway_handler.go | 62 +++++++++++++++++++----- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 62cfa7269..9b7572d88 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -45,7 +45,7 @@ func newGatewayHandler(node *core.IpfsNode, conf GatewayConfig) *gatewayHandler } // TODO(cryptix): find these helpers somewhere else -func (i *gatewayHandler) newDagFromReader(r io.Reader) (*dag.Node, error) { +func (i *gatewayHandler) newDagFromReader(r io.Reader) (*dag.ProtoNode, error) { // TODO(cryptix): change and remove this helper once PR1136 is merged // return ufs.AddFromReader(i.node, r.Body) return importer.BuildDagFromReader( @@ -163,6 +163,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } + pbnd, ok := nd.(*dag.ProtoNode) + if !ok { + webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) + return + } + etag := gopath.Base(urlPath) if r.Header.Get("If-None-Match") == etag { w.WriteHeader(http.StatusNotModified) @@ -190,7 +196,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request w.Header().Set("Suborigin", pathRoot) } - dr, err := uio.NewDagReader(ctx, nd, i.node.DAG) + dr, err := uio.NewDagReader(ctx, pbnd, i.node.DAG) if err != nil && err != uio.ErrIsDir { // not a directory and still an error internalWebError(w, err) @@ -221,7 +227,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request var dirListing []directoryItem // loop through files foundIndex := false - for _, link := range nd.Links { + for _, link := range nd.Links() { if link.Name == "index.html" { log.Debugf("found index.html link for %s", urlPath) foundIndex = true @@ -239,7 +245,14 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request internalWebError(w, err) return } - dr, err := uio.NewDagReader(ctx, nd, i.node.DAG) + + pbnd, ok := nd.(*dag.ProtoNode) + if !ok { + internalWebError(w, dag.ErrNotProtobuf) + return + } + + dr, err := uio.NewDagReader(ctx, pbnd, i.node.DAG) if err != nil { internalWebError(w, err) return @@ -340,7 +353,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } - var newnode *dag.Node + var newnode *dag.ProtoNode if rsegs[len(rsegs)-1] == "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" { newnode = uio.NewEmptyDirectory() } else { @@ -376,7 +389,13 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } - e := dagutils.NewDagEditor(rnode, i.node.DAG) + pbnd, ok := rnode.(*dag.ProtoNode) + if !ok { + webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) + return + } + + e := dagutils.NewDagEditor(pbnd, i.node.DAG) err = e.InsertNodeAtPath(ctx, newPath, newnode, uio.NewEmptyDirectory) if err != nil { webError(w, "putHandler: InsertNodeAtPath failed", err, http.StatusInternalServerError) @@ -392,13 +411,19 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { newcid = nnode.Cid() case nil: + pbnd, ok := rnode.(*dag.ProtoNode) + if !ok { + webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) + return + } + // object set-data case - rnode.SetData(newnode.Data()) + pbnd.SetData(newnode.Data()) - newcid, err = i.node.DAG.Add(rnode) + newcid, err = i.node.DAG.Add(pbnd) if err != nil { nnk := newnode.Cid() - rk := rnode.Cid() + rk := pbnd.Cid() webError(w, fmt.Sprintf("putHandler: Could not add newnode(%q) to root(%q)", nnk.String(), rk.String()), err, http.StatusInternalServerError) return } @@ -444,20 +469,33 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { return } + pbnd, ok := pathNodes[len(pathNodes)-1].(*dag.ProtoNode) + if !ok { + webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) + return + } + // TODO(cyrptix): assumes len(pathNodes) > 1 - not found is an error above? - err = pathNodes[len(pathNodes)-1].RemoveNodeLink(components[len(components)-1]) + err = pbnd.RemoveNodeLink(components[len(components)-1]) if err != nil { webError(w, "Could not delete link", err, http.StatusBadRequest) return } - newnode := pathNodes[len(pathNodes)-1] + var newnode *dag.ProtoNode = pbnd for j := len(pathNodes) - 2; j >= 0; j-- { if _, err := i.node.DAG.Add(newnode); err != nil { webError(w, "Could not add node", err, http.StatusInternalServerError) return } - newnode, err = pathNodes[j].UpdateNodeLink(components[j], newnode) + + pathpb, ok := pathNodes[j].(*dag.ProtoNode) + if !ok { + webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) + return + } + + newnode, err = pathpb.UpdateNodeLink(components[j], newnode) if err != nil { webError(w, "Could not update node links", err, http.StatusInternalServerError) return From 33a493a60e20a6ab5b7d2f4b1ce19d8310e2294e Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sat, 15 Oct 2016 09:06:44 -0700 Subject: [PATCH 175/674] unixfs: allow use of raw merkledag nodes for unixfs files License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@ded60a73562a9df9a67ef328d364431a40d1a37c --- gateway/core/corehttp/gateway_handler.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 9b7572d88..3e71129dc 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -1,6 +1,7 @@ package corehttp import ( + "context" "errors" "fmt" "io" @@ -18,10 +19,10 @@ import ( path "github.com/ipfs/go-ipfs/path" uio "github.com/ipfs/go-ipfs/unixfs/io" - "context" routing "gx/ipfs/QmNUgVQTYnXQVrGT2rajZYsuKV8GYdiL91cdZSQDKNPNgE/go-libp2p-routing" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmXUuRadqDq5BuFWzVU6VuKaSjTcNm1gNCtLvvP1TJCW4z/go-cid" + node "gx/ipfs/QmZx42H5khbVQhV5odp66TApShV4XCujYazcvYduZ4TroB/go-ipld-node" ) const ( @@ -45,7 +46,7 @@ func newGatewayHandler(node *core.IpfsNode, conf GatewayConfig) *gatewayHandler } // TODO(cryptix): find these helpers somewhere else -func (i *gatewayHandler) newDagFromReader(r io.Reader) (*dag.ProtoNode, error) { +func (i *gatewayHandler) newDagFromReader(r io.Reader) (node.Node, error) { // TODO(cryptix): change and remove this helper once PR1136 is merged // return ufs.AddFromReader(i.node, r.Body) return importer.BuildDagFromReader( @@ -353,7 +354,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } - var newnode *dag.ProtoNode + var newnode node.Node if rsegs[len(rsegs)-1] == "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" { newnode = uio.NewEmptyDirectory() } else { @@ -417,8 +418,14 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } + pbnewnode, ok := newnode.(*dag.ProtoNode) + if !ok { + webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) + return + } + // object set-data case - pbnd.SetData(newnode.Data()) + pbnd.SetData(pbnewnode.Data()) newcid, err = i.node.DAG.Add(pbnd) if err != nil { From e81dde1efb933ee2b331ce65745d870cf77bf6f8 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 18 Oct 2016 14:41:47 -0700 Subject: [PATCH 176/674] fix add/cat of small files License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@8ce9963289bcba3f596353f28a942814b5bfff65 --- gateway/core/corehttp/gateway_test.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index ba8a936ac..42959ffaf 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -1,6 +1,7 @@ package corehttp import ( + "context" "errors" "io/ioutil" "net/http" @@ -9,14 +10,15 @@ import ( "testing" "time" - context "context" core "github.com/ipfs/go-ipfs/core" coreunix "github.com/ipfs/go-ipfs/core/coreunix" + dag "github.com/ipfs/go-ipfs/merkledag" namesys "github.com/ipfs/go-ipfs/namesys" path "github.com/ipfs/go-ipfs/path" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" + id "gx/ipfs/QmcRa2qn6iCmap9bjp8jAwkvYAq13AUfxdY3rrYiaJbLum/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" ) @@ -178,11 +180,13 @@ func TestIPNSHostnameRedirect(t *testing.T) { if err != nil { t.Fatal(err) } + _, dagn2, err := coreunix.AddWrapped(n, strings.NewReader("_"), "index.html") if err != nil { t.Fatal(err) } - dagn1.AddNodeLink("foo", dagn2) + + dagn1.(*dag.ProtoNode).AddNodeLink("foo", dagn2) if err != nil { t.Fatal(err) } @@ -197,7 +201,7 @@ func TestIPNSHostnameRedirect(t *testing.T) { t.Fatal(err) } - k := dagn1.Key() + k := dagn1.Cid() t.Logf("k: %s\n", k) ns["/ipns/example.net"] = path.FromString("/ipfs/" + k.String()) @@ -268,8 +272,8 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if err != nil { t.Fatal(err) } - dagn2.AddNodeLink("bar", dagn3) - dagn1.AddNodeLink("foo? #<'", dagn2) + dagn2.(*dag.ProtoNode).AddNodeLink("bar", dagn3) + dagn1.(*dag.ProtoNode).AddNodeLink("foo? #<'", dagn2) if err != nil { t.Fatal(err) } @@ -287,7 +291,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { t.Fatal(err) } - k := dagn1.Key() + k := dagn1.Cid() t.Logf("k: %s\n", k) ns["/ipns/example.net"] = path.FromString("/ipfs/" + k.String()) From 2191748dd21c90da11cdac639776a51b80c0c203 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 24 Oct 2016 20:39:27 -0700 Subject: [PATCH 177/674] update to new cid and ipld node packages License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@eac13abaec35a8a70bb0a87b2738634e9b324143 --- gateway/core/corehttp/gateway_handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 3e71129dc..99b59a1fa 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -19,10 +19,10 @@ import ( path "github.com/ipfs/go-ipfs/path" uio "github.com/ipfs/go-ipfs/unixfs/io" - routing "gx/ipfs/QmNUgVQTYnXQVrGT2rajZYsuKV8GYdiL91cdZSQDKNPNgE/go-libp2p-routing" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - cid "gx/ipfs/QmXUuRadqDq5BuFWzVU6VuKaSjTcNm1gNCtLvvP1TJCW4z/go-cid" - node "gx/ipfs/QmZx42H5khbVQhV5odp66TApShV4XCujYazcvYduZ4TroB/go-ipld-node" + routing "gx/ipfs/QmQKEgGgYCDyk8VNY6A65FpuE4YwbspvjXHco1rdb75PVc/go-libp2p-routing" + node "gx/ipfs/QmU7bFWQ793qmvNy7outdCaMfSDNk8uqhx4VNrxYj5fj5g/go-ipld-node" + cid "gx/ipfs/QmXfiyr2RWEXpVDdaYnD2HNiBk6UBddsvEP4RPfXb6nGqY/go-cid" ) const ( From 6d2ca5eb001f9c718d989f494308408d8d329217 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 19 Oct 2016 10:05:58 -0700 Subject: [PATCH 178/674] make path resolver no longer require whole node for construction License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@67c2a4ec14a230818e0cd0052725ac001b048968 --- gateway/core/corehttp/gateway_handler.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 99b59a1fa..c35431cbe 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -17,6 +17,7 @@ import ( dag "github.com/ipfs/go-ipfs/merkledag" dagutils "github.com/ipfs/go-ipfs/merkledag/utils" path "github.com/ipfs/go-ipfs/path" + ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" @@ -153,7 +154,13 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request ipnsHostname = true } - nd, err := core.Resolve(ctx, i.node, path.Path(urlPath)) + p, err := path.ParsePath(urlPath) + if err != nil { + webError(w, "Invalid Path Error", err, http.StatusBadRequest) + return + } + + nd, err := core.Resolve(ctx, i.node.Namesys, i.node.Resolver, p) // If node is in offline mode the error code and message should be different if err == core.ErrNoNamesys && !i.node.OnlineMode() { w.WriteHeader(http.StatusServiceUnavailable) @@ -240,8 +247,14 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } + p, err := path.ParsePath(urlPath + "/index.html") + if err != nil { + internalWebError(w, err) + return + } + // return index page instead. - nd, err := core.Resolve(ctx, i.node, path.Path(urlPath+"/index.html")) + nd, err := core.Resolve(ctx, i.node.Namesys, i.node.Resolver, p) if err != nil { internalWebError(w, err) return @@ -356,7 +369,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { var newnode node.Node if rsegs[len(rsegs)-1] == "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" { - newnode = uio.NewEmptyDirectory() + newnode = ft.EmptyDirNode() } else { putNode, err := i.newDagFromReader(r.Body) if err != nil { @@ -372,7 +385,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { } var newcid *cid.Cid - rnode, err := core.Resolve(ctx, i.node, rootPath) + rnode, err := core.Resolve(ctx, i.node.Namesys, i.node.Resolver, rootPath) switch ev := err.(type) { case path.ErrNoLink: // ev.Node < node where resolve failed @@ -397,7 +410,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { } e := dagutils.NewDagEditor(pbnd, i.node.DAG) - err = e.InsertNodeAtPath(ctx, newPath, newnode, uio.NewEmptyDirectory) + err = e.InsertNodeAtPath(ctx, newPath, newnode, ft.EmptyDirNode) if err != nil { webError(w, "putHandler: InsertNodeAtPath failed", err, http.StatusInternalServerError) return From 2430d87d4db6caebfeee95109d30fd1a402b470b Mon Sep 17 00:00:00 2001 From: Richard Littauer Date: Fri, 1 Jul 2016 18:36:55 +0100 Subject: [PATCH 179/674] Changed so only explicit ipfs cli commands are lowercased License: MIT Signed-off-by: Richard Littauer This commit was moved from ipfs/kubo@9843e86258102a4d3edf4eec1923097009dbcfab --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index c35431cbe..ea0ef5c5d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -357,7 +357,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { rootPath, err := path.ParsePath(r.URL.Path) if err != nil { - webError(w, "putHandler: ipfs path not valid", err, http.StatusBadRequest) + webError(w, "putHandler: IPFS path not valid", err, http.StatusBadRequest) return } From e20272a555af288726987b91e6bd770801e95236 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 30 Oct 2016 19:01:03 -0700 Subject: [PATCH 180/674] update go-libp2p-swarm with deadlock fixes License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@afce683eaebf2ddbbb397a4b359083f53cb5c296 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 4aa26fed7..c4b1e5186 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,7 +7,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmcRa2qn6iCmap9bjp8jAwkvYAq13AUfxdY3rrYiaJbLum/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQ7iWUfqrLEoJwsoNdrZu4625bKyhZCi4Sh6MfjywEfbG/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 42959ffaf..69044fc8f 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmcRa2qn6iCmap9bjp8jAwkvYAq13AUfxdY3rrYiaJbLum/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQ7iWUfqrLEoJwsoNdrZu4625bKyhZCi4Sh6MfjywEfbG/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 278f10951..1426e90d5 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -6,8 +6,8 @@ import ( context "context" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmcRa2qn6iCmap9bjp8jAwkvYAq13AUfxdY3rrYiaJbLum/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/QmcRa2qn6iCmap9bjp8jAwkvYAq13AUfxdY3rrYiaJbLum/go-libp2p/p2p/test/util" + bhost "gx/ipfs/QmQ7iWUfqrLEoJwsoNdrZu4625bKyhZCi4Sh6MfjywEfbG/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmQ7iWUfqrLEoJwsoNdrZu4625bKyhZCi4Sh6MfjywEfbG/go-libp2p/p2p/test/util" inet "gx/ipfs/QmdXimY9QHaasZmw6hWojWnCJvfgxETjZQfg9g6ZrA9wMX/go-libp2p-net" ) From 282600f753d7fd32bb0f66339d5d06805c77a020 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Thu, 1 Sep 2016 02:59:50 +0200 Subject: [PATCH 181/674] gateway: bring back dir-index-html assets License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@02aa6b4714a63e424212ce2e29d0f4db03fb3b33 --- gateway/core/corehttp/gateway_indexPage.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index 366c99aca..dbcdca708 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -25,8 +25,7 @@ type directoryItem struct { var listingTemplate *template.Template func init() { - assetPath := "../vendor/dir-index-html-v1.0.0/" - knownIconsBytes, err := assets.Asset(assetPath + "knownIcons.txt") + knownIconsBytes, err := assets.Asset("dir-index-html/knownIcons.txt") if err != nil { panic(err) } @@ -53,7 +52,7 @@ func init() { } // Directory listing template - dirIndexBytes, err := assets.Asset(assetPath + "dir-index.html") + dirIndexBytes, err := assets.Asset("dir-index-html/dir-index.html") if err != nil { panic(err) } From 388ab70390c5b82a1972943802ef4559b60358af Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 3 Nov 2016 20:06:32 -0700 Subject: [PATCH 182/674] update go-libp2p License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@ec2122090742aa3c1e969e7bcfe8cbee79a5ec1f --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index c4b1e5186..ff2884fd0 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,7 +7,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmQ7iWUfqrLEoJwsoNdrZu4625bKyhZCi4Sh6MfjywEfbG/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmVN76ekoYakYa8WVDwhkUsnjt2MYuFpQs1uuU57T5KMD8/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 69044fc8f..3f786bb17 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmQ7iWUfqrLEoJwsoNdrZu4625bKyhZCi4Sh6MfjywEfbG/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmVN76ekoYakYa8WVDwhkUsnjt2MYuFpQs1uuU57T5KMD8/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 1426e90d5..055dc5c32 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -6,9 +6,9 @@ import ( context "context" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmQ7iWUfqrLEoJwsoNdrZu4625bKyhZCi4Sh6MfjywEfbG/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/QmQ7iWUfqrLEoJwsoNdrZu4625bKyhZCi4Sh6MfjywEfbG/go-libp2p/p2p/test/util" - inet "gx/ipfs/QmdXimY9QHaasZmw6hWojWnCJvfgxETjZQfg9g6ZrA9wMX/go-libp2p-net" + bhost "gx/ipfs/QmVN76ekoYakYa8WVDwhkUsnjt2MYuFpQs1uuU57T5KMD8/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmVN76ekoYakYa8WVDwhkUsnjt2MYuFpQs1uuU57T5KMD8/go-libp2p/p2p/test/util" + inet "gx/ipfs/QmdysBu77i3YaagNtMAjiCJdeWWvds18ho5XEB784guQ41/go-libp2p-net" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From b159887576262e9d9ad42693517a78f8d3777e84 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sat, 5 Nov 2016 20:10:32 -0700 Subject: [PATCH 183/674] update to libp2p 4.0.4 License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@25d9f8afd1cc33189c362372e53c7a3346804d5c --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index ff2884fd0..85b56e723 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,7 +7,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmVN76ekoYakYa8WVDwhkUsnjt2MYuFpQs1uuU57T5KMD8/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQfvKShQ2v7nkfCE4ygisxpcSBFvBYaorQ54SibY6PGXV/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 3f786bb17..98f8c37fd 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmVN76ekoYakYa8WVDwhkUsnjt2MYuFpQs1uuU57T5KMD8/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQfvKShQ2v7nkfCE4ygisxpcSBFvBYaorQ54SibY6PGXV/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 055dc5c32..cb86583a7 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -6,8 +6,8 @@ import ( context "context" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmVN76ekoYakYa8WVDwhkUsnjt2MYuFpQs1uuU57T5KMD8/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/QmVN76ekoYakYa8WVDwhkUsnjt2MYuFpQs1uuU57T5KMD8/go-libp2p/p2p/test/util" + bhost "gx/ipfs/QmQfvKShQ2v7nkfCE4ygisxpcSBFvBYaorQ54SibY6PGXV/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmQfvKShQ2v7nkfCE4ygisxpcSBFvBYaorQ54SibY6PGXV/go-libp2p/p2p/test/util" inet "gx/ipfs/QmdysBu77i3YaagNtMAjiCJdeWWvds18ho5XEB784guQ41/go-libp2p-net" ) From 62734dc8d02645bef1559f567b98f3e82b43bb75 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sun, 11 Sep 2016 05:18:25 +0200 Subject: [PATCH 184/674] gateway: use core api for serving GET/HEAD requests License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@029f971d9cb7e89e523568758c01e2c9924e5af9 --- gateway/core/corehttp/gateway.go | 5 +- gateway/core/corehttp/gateway_handler.go | 65 +++++++++--------------- 2 files changed, 26 insertions(+), 44 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 85b56e723..6663e8b73 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -6,6 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" + coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" id "gx/ipfs/QmQfvKShQ2v7nkfCE4ygisxpcSBFvBYaorQ54SibY6PGXV/go-libp2p/p2p/protocol/identify" ) @@ -27,7 +28,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { Headers: cfg.Gateway.HTTPHeaders, Writable: writable, PathPrefixes: cfg.Gateway.PathPrefixes, - }) + }, coreapi.NewUnixfsAPI(n)) for _, p := range paths { mux.Handle(p+"/", gateway) @@ -37,7 +38,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { } func VersionOption() ServeOption { - return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { + return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Commit: %s\n", config.CurrentCommit) fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ea0ef5c5d..c1da7d2d5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,9 +16,10 @@ import ( chunk "github.com/ipfs/go-ipfs/importer/chunk" dag "github.com/ipfs/go-ipfs/merkledag" dagutils "github.com/ipfs/go-ipfs/merkledag/utils" + + coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" path "github.com/ipfs/go-ipfs/path" ft "github.com/ipfs/go-ipfs/unixfs" - uio "github.com/ipfs/go-ipfs/unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" routing "gx/ipfs/QmQKEgGgYCDyk8VNY6A65FpuE4YwbspvjXHco1rdb75PVc/go-libp2p-routing" @@ -36,12 +37,14 @@ const ( type gatewayHandler struct { node *core.IpfsNode config GatewayConfig + api coreiface.UnixfsAPI } -func newGatewayHandler(node *core.IpfsNode, conf GatewayConfig) *gatewayHandler { +func newGatewayHandler(n *core.IpfsNode, c GatewayConfig, api coreiface.UnixfsAPI) *gatewayHandler { i := &gatewayHandler{ - node: node, - config: conf, + node: n, + config: c, + api: api, } return i } @@ -154,27 +157,19 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request ipnsHostname = true } - p, err := path.ParsePath(urlPath) - if err != nil { - webError(w, "Invalid Path Error", err, http.StatusBadRequest) - return - } - - nd, err := core.Resolve(ctx, i.node.Namesys, i.node.Resolver, p) - // If node is in offline mode the error code and message should be different - if err == core.ErrNoNamesys && !i.node.OnlineMode() { + dr, err := i.api.Cat(ctx, urlPath) + dir := false + if err == coreiface.ErrIsDir { + dir = true + } else if err == coreiface.ErrOffline { w.WriteHeader(http.StatusServiceUnavailable) fmt.Fprint(w, "Could not resolve path. Node is in offline mode.") return } else if err != nil { webError(w, "Path Resolve error", err, http.StatusBadRequest) return - } - - pbnd, ok := nd.(*dag.ProtoNode) - if !ok { - webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) - return + } else { + defer dr.Close() } etag := gopath.Base(urlPath) @@ -204,13 +199,6 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request w.Header().Set("Suborigin", pathRoot) } - dr, err := uio.NewDagReader(ctx, pbnd, i.node.DAG) - if err != nil && err != uio.ErrIsDir { - // not a directory and still an error - internalWebError(w, err) - return - } - // set these headers _after_ the error, for we may just not have it // and dont want the client to cache a 500 response... // and only if it's /ipfs! @@ -224,18 +212,23 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request modtime = time.Unix(1, 0) } - if err == nil { - defer dr.Close() + if !dir { name := gopath.Base(urlPath) http.ServeContent(w, r, name, modtime, dr) return } + links, err := i.api.Ls(ctx, urlPath) + if err != nil { + internalWebError(w, err) + return + } + // storage for directory listing var dirListing []directoryItem // loop through files foundIndex := false - for _, link := range nd.Links() { + for _, link := range links { if link.Name == "index.html" { log.Debugf("found index.html link for %s", urlPath) foundIndex = true @@ -254,19 +247,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } // return index page instead. - nd, err := core.Resolve(ctx, i.node.Namesys, i.node.Resolver, p) - if err != nil { - internalWebError(w, err) - return - } - - pbnd, ok := nd.(*dag.ProtoNode) - if !ok { - internalWebError(w, dag.ErrNotProtobuf) - return - } - - dr, err := uio.NewDagReader(ctx, pbnd, i.node.DAG) + dr, err := i.api.Cat(ctx, p.String()) if err != nil { internalWebError(w, err) return From ffb9dc17cdcc722d50c93e5408b5bbaf2a13c661 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Tue, 20 Sep 2016 04:31:57 +0200 Subject: [PATCH 185/674] gateway: move context/close-notify wiring License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@c31e4f7226467ed8e703bfbff553ef1c2f586018 --- gateway/core/corehttp/gateway_handler.go | 33 ++++++++++++------------ 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index c1da7d2d5..542229cdd 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -60,6 +60,21 @@ func (i *gatewayHandler) newDagFromReader(r io.Reader) (node.Node, error) { // TODO(btc): break this apart into separate handlers using a more expressive muxer func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + ctx, cancel := context.WithTimeout(i.node.Context(), time.Hour) + // the hour is a hard fallback, we don't expect it to happen, but just in case + defer cancel() + + if cn, ok := w.(http.CloseNotifier); ok { + clientGone := cn.CloseNotify() + go func() { + select { + case <-clientGone: + case <-ctx.Done(): + } + cancel() + }() + } + defer func() { if r := recover(); r != nil { log.Error("A panic occurred in the gateway handler!") @@ -83,7 +98,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if r.Method == "GET" || r.Method == "HEAD" { - i.getOrHeadHandler(w, r) + i.getOrHeadHandler(ctx, w, r) return } @@ -113,21 +128,7 @@ func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request) i.addUserHeaders(w) // return all custom headers (including CORS ones, if set) } -func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) { - ctx, cancel := context.WithTimeout(i.node.Context(), time.Hour) - // the hour is a hard fallback, we don't expect it to happen, but just in case - defer cancel() - - if cn, ok := w.(http.CloseNotifier); ok { - clientGone := cn.CloseNotify() - go func() { - select { - case <-clientGone: - case <-ctx.Done(): - } - cancel() - }() - } +func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { urlPath := r.URL.Path From 5e0b554671e2f72212211a767f5da95a1b12bb81 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Tue, 20 Sep 2016 04:32:37 +0200 Subject: [PATCH 186/674] gateway: use core api for serving POST requests License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@0097b422de1ecc612bc04ca3e7c1dbd8f8495788 --- gateway/core/corehttp/gateway_handler.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 542229cdd..8bf781ef7 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -86,7 +86,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if i.config.Writable { switch r.Method { case "POST": - i.postHandler(w, r) + i.postHandler(ctx, w, r) return case "PUT": i.putHandler(w, r) @@ -314,14 +314,8 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } } -func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { - nd, err := i.newDagFromReader(r.Body) - if err != nil { - internalWebError(w, err) - return - } - - k, err := i.node.DAG.Add(nd) +func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { + k, err := i.api.Add(ctx, r.Body) if err != nil { internalWebError(w, err) return From e0f84d5b5559aa4394d3e24ec7f9ffebd3d66ecc Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 10 Nov 2016 17:38:10 -0800 Subject: [PATCH 187/674] update to go-libp2p 4.1.0 License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@7fbaae49be5c7be83d8da49f2c62841e85975559 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 85b56e723..78e0571f2 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,7 +7,7 @@ import ( core "github.com/ipfs/go-ipfs/core" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmQfvKShQ2v7nkfCE4ygisxpcSBFvBYaorQ54SibY6PGXV/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmUYzZRJcuUxLSnSzF1bSyw1jYbNAULkBrbS6rnr7F72uK/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 98f8c37fd..42e0a6ac9 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmQfvKShQ2v7nkfCE4ygisxpcSBFvBYaorQ54SibY6PGXV/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmUYzZRJcuUxLSnSzF1bSyw1jYbNAULkBrbS6rnr7F72uK/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index cb86583a7..9b056a9a9 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -6,9 +6,9 @@ import ( context "context" core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmQfvKShQ2v7nkfCE4ygisxpcSBFvBYaorQ54SibY6PGXV/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/QmQfvKShQ2v7nkfCE4ygisxpcSBFvBYaorQ54SibY6PGXV/go-libp2p/p2p/test/util" - inet "gx/ipfs/QmdysBu77i3YaagNtMAjiCJdeWWvds18ho5XEB784guQ41/go-libp2p-net" + inet "gx/ipfs/QmU3pGGVT1riXp5dBJbNrGpxssVScfvk9236drRHZZbKJ1/go-libp2p-net" + bhost "gx/ipfs/QmUYzZRJcuUxLSnSzF1bSyw1jYbNAULkBrbS6rnr7F72uK/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmUYzZRJcuUxLSnSzF1bSyw1jYbNAULkBrbS6rnr7F72uK/go-libp2p/p2p/test/util" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From bc52486376ac23df266a7ece756e90151efb5d0f Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 15 Nov 2016 18:00:49 -0800 Subject: [PATCH 188/674] update to newer ipld node interface with Copy and better Tree License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@396c629301c2c5cdf23f9d77ea9430e322f480a9 --- gateway/core/corehttp/gateway_handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 8bf781ef7..3bfa74b42 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -22,9 +22,9 @@ import ( ft "github.com/ipfs/go-ipfs/unixfs" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - routing "gx/ipfs/QmQKEgGgYCDyk8VNY6A65FpuE4YwbspvjXHco1rdb75PVc/go-libp2p-routing" - node "gx/ipfs/QmU7bFWQ793qmvNy7outdCaMfSDNk8uqhx4VNrxYj5fj5g/go-ipld-node" - cid "gx/ipfs/QmXfiyr2RWEXpVDdaYnD2HNiBk6UBddsvEP4RPfXb6nGqY/go-cid" + routing "gx/ipfs/QmUrCwTDvJgmBbJVHu1HGEyqDaod3dR6sEkZkpxZk4u47c/go-libp2p-routing" + node "gx/ipfs/QmUsVJ7AEnGyjX8YWnrwq9vmECVGwBQNAKPpgz5KSg8dcq/go-ipld-node" + cid "gx/ipfs/QmcEcrBAMrwMyhSjXt4yfyPpzgSuV8HLHavnfmiKCSRqZU/go-cid" ) const ( From 2cdd60097b8dc0d4e845a5a9ba31ea0fc2a05577 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 15 Jul 2016 12:31:02 +0100 Subject: [PATCH 189/674] gateway: degrade error in gateway to log to reduce noise It logs all errors including expired IPNS keys and other non important errors. License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@82d46a5b5be372a4c0171d41de77992e175c4547 --- gateway/core/corehttp/gateway_handler.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 3bfa74b42..2c6302fb8 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -12,12 +12,12 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/importer" chunk "github.com/ipfs/go-ipfs/importer/chunk" dag "github.com/ipfs/go-ipfs/merkledag" dagutils "github.com/ipfs/go-ipfs/merkledag/utils" - - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" + "github.com/ipfs/go-ipfs/namesys" path "github.com/ipfs/go-ipfs/path" ft "github.com/ipfs/go-ipfs/unixfs" @@ -166,6 +166,11 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr w.WriteHeader(http.StatusServiceUnavailable) fmt.Fprint(w, "Could not resolve path. Node is in offline mode.") return + } else if err == namesys.ErrResolveFailed { + // Don't log that error as it is just noise + w.WriteHeader(http.StatusBadRequest) + fmt.Fprintf(w, "Path Resolve error: %s", err.Error()) + return } else if err != nil { webError(w, "Path Resolve error", err, http.StatusBadRequest) return @@ -531,7 +536,8 @@ func webError(w http.ResponseWriter, message string, err error, defaultCode int) func webErrorWithCode(w http.ResponseWriter, message string, err error, code int) { w.WriteHeader(code) - log.Errorf("%s: %s", message, err) // TODO(cryptix): log errors until we have a better way to expose these (counter metrics maybe) + + log.Errorf("%s: %s", message, err) // TODO(cryptix): log until we have a better way to expose these (counter metrics maybe) fmt.Fprintf(w, "%s: %s", message, err) } From d6d63afe4f318d40e26ae6ba7bb7bf6dec7f119d Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 8 Sep 2016 11:28:40 +0200 Subject: [PATCH 190/674] gateway: use switch for error handling License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@43320e1b7f91a3af799102dbb0f9bba8cd5de44c --- gateway/core/corehttp/gateway_handler.go | 25 +++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 2c6302fb8..0e45c198c 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -160,22 +160,29 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr dr, err := i.api.Cat(ctx, urlPath) dir := false - if err == coreiface.ErrIsDir { + switch err { + case nil: + // core.Resolve worked + defer dr.Close() + case coreiface.ErrIsDir: dir = true - } else if err == coreiface.ErrOffline { - w.WriteHeader(http.StatusServiceUnavailable) - fmt.Fprint(w, "Could not resolve path. Node is in offline mode.") - return - } else if err == namesys.ErrResolveFailed { + case namesys.ErrResolveFailed: // Don't log that error as it is just noise w.WriteHeader(http.StatusBadRequest) fmt.Fprintf(w, "Path Resolve error: %s", err.Error()) + log.Info("Path Resolve error: %s", err.Error()) return - } else if err != nil { + case coreiface.ErrOffline: + if !i.node.OnlineMode() { + w.WriteHeader(http.StatusServiceUnavailable) + fmt.Fprint(w, "Could not resolve path. Node is in offline mode.") + return + } + fallthrough + default: + // all other erros webError(w, "Path Resolve error", err, http.StatusBadRequest) return - } else { - defer dr.Close() } etag := gopath.Base(urlPath) From 557e5cbde43a7ff5187f9b737cb341becdcc8ef4 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 4 Oct 2016 18:25:23 +0200 Subject: [PATCH 191/674] gateway: change status code of failed namesys resution to 500 License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@ce96b915e75392baaa866b6f23e58f42f862f9d6 --- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 0e45c198c..9a665d95c 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -168,7 +168,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr dir = true case namesys.ErrResolveFailed: // Don't log that error as it is just noise - w.WriteHeader(http.StatusBadRequest) + w.WriteHeader(http.StatusInternalServerError) fmt.Fprintf(w, "Path Resolve error: %s", err.Error()) log.Info("Path Resolve error: %s", err.Error()) return diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 42e0a6ac9..d4b0e9075 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -136,7 +136,7 @@ func TestGatewayGet(t *testing.T) { {"localhost:5001", "/", http.StatusNotFound, "404 page not found\n"}, {"localhost:5001", "/" + k, http.StatusNotFound, "404 page not found\n"}, {"localhost:5001", "/ipfs/" + k, http.StatusOK, "fnord"}, - {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusBadRequest, "Path Resolve error: " + namesys.ErrResolveFailed.Error()}, + {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusInternalServerError, "Path Resolve error: " + namesys.ErrResolveFailed.Error()}, {"localhost:5001", "/ipns/example.com", http.StatusOK, "fnord"}, {"example.com", "/", http.StatusOK, "fnord"}, } { From ebceb73a3a9867d9ef5109d48a9d4591ad3cde8d Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 18 Nov 2016 00:24:00 +0100 Subject: [PATCH 192/674] Update go-libp2p across codebase License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@1e170e8d6d75898ebad1ba0e556fd9ab35df6a74 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index d85d9e0a5..bdff1cf39 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmUYzZRJcuUxLSnSzF1bSyw1jYbNAULkBrbS6rnr7F72uK/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZyBJGpRnbQ7oUstoGNZbhXC4HJuFUCgpp8pmsVTUwdS3/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index d4b0e9075..a9437e01b 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmUYzZRJcuUxLSnSzF1bSyw1jYbNAULkBrbS6rnr7F72uK/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZyBJGpRnbQ7oUstoGNZbhXC4HJuFUCgpp8pmsVTUwdS3/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 9b056a9a9..f06d83952 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -1,14 +1,15 @@ package corehttp import ( + "context" "testing" "time" - context "context" core "github.com/ipfs/go-ipfs/core" + inet "gx/ipfs/QmU3pGGVT1riXp5dBJbNrGpxssVScfvk9236drRHZZbKJ1/go-libp2p-net" - bhost "gx/ipfs/QmUYzZRJcuUxLSnSzF1bSyw1jYbNAULkBrbS6rnr7F72uK/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/QmUYzZRJcuUxLSnSzF1bSyw1jYbNAULkBrbS6rnr7F72uK/go-libp2p/p2p/test/util" + bhost "gx/ipfs/QmZyBJGpRnbQ7oUstoGNZbhXC4HJuFUCgpp8pmsVTUwdS3/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmcDTquYLTYirqj71RRWKUWEEw3nJt11Awzun5ep8kfY7W/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect @@ -19,7 +20,7 @@ func TestPeersTotal(t *testing.T) { hosts := make([]*bhost.BasicHost, 4) for i := 0; i < 4; i++ { - hosts[i] = testutil.GenHostSwarm(t, ctx) + hosts[i] = bhost.New(testutil.GenSwarmNetwork(t, ctx)) } dial := func(a, b inet.Network) { From 2202e94e98a7c44e5a4392913a62fd00e02affc9 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 28 Nov 2016 22:29:38 -0800 Subject: [PATCH 193/674] bubble up go-datastore deps License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@53d47669daaa3a302826ec2fd346d317d10d9ce7 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 6 +++--- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index bdff1cf39..caa8311b8 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmZyBJGpRnbQ7oUstoGNZbhXC4HJuFUCgpp8pmsVTUwdS3/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmbzCT1CwxVZ2ednptC9RavuJe7Bv8DDi2Ne89qUrA37XM/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 9a665d95c..c2844089d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -22,9 +22,9 @@ import ( ft "github.com/ipfs/go-ipfs/unixfs" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - routing "gx/ipfs/QmUrCwTDvJgmBbJVHu1HGEyqDaod3dR6sEkZkpxZk4u47c/go-libp2p-routing" - node "gx/ipfs/QmUsVJ7AEnGyjX8YWnrwq9vmECVGwBQNAKPpgz5KSg8dcq/go-ipld-node" - cid "gx/ipfs/QmcEcrBAMrwMyhSjXt4yfyPpzgSuV8HLHavnfmiKCSRqZU/go-cid" + node "gx/ipfs/QmRSU5EqqWVZSNdbU51yXmVoF1uNw3JgTNB6RaiL7DZM16/go-ipld-node" + routing "gx/ipfs/QmbkGVaN9W6RYJK4Ws5FvMKXKDqdRQ5snhtaa92qP6L8eU/go-libp2p-routing" + cid "gx/ipfs/QmcTcsTvfaeEBRFo1TkFgT8sRmgi1n1LTZpecfVP8fzpGD/go-cid" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index a9437e01b..9f1eefc95 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmZyBJGpRnbQ7oUstoGNZbhXC4HJuFUCgpp8pmsVTUwdS3/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmbzCT1CwxVZ2ednptC9RavuJe7Bv8DDi2Ne89qUrA37XM/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index f06d83952..320bf7628 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - inet "gx/ipfs/QmU3pGGVT1riXp5dBJbNrGpxssVScfvk9236drRHZZbKJ1/go-libp2p-net" - bhost "gx/ipfs/QmZyBJGpRnbQ7oUstoGNZbhXC4HJuFUCgpp8pmsVTUwdS3/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/QmcDTquYLTYirqj71RRWKUWEEw3nJt11Awzun5ep8kfY7W/go-libp2p-netutil" + inet "gx/ipfs/QmQx1dHDDYENugYgqA22BaBrRfuv1coSsuPiM7rYh1wwGH/go-libp2p-net" + testutil "gx/ipfs/QmWdGJY4fcsfhLHucEfivw8J71yUqNUFbzdU1jnJBnN5Xh/go-libp2p-netutil" + bhost "gx/ipfs/QmbzCT1CwxVZ2ednptC9RavuJe7Bv8DDi2Ne89qUrA37XM/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 630596a1e88a829807b5f595930604cc1afa728f Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Mon, 19 Dec 2016 13:59:38 +0100 Subject: [PATCH 194/674] gateway: remove Suborigins as it conflicts the spec The Suborigins spec was changed and we have to adjust, the spec is still unstable and it might change in future. Currently the only browser supporting it (Chrome) errors out on it as it doesn't confront spec it uses. See https://github.com/ipfs/specs/issues/131 License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@912a9720bdbe1ed0071383be371b902a6f79c780 --- gateway/core/corehttp/gateway_handler.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index c2844089d..69082de8c 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -199,19 +199,6 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // expose those headers w.Header().Set("Access-Control-Expose-Headers", "X-Stream-Output, X-Chunked-Output") - // Suborigin header, sandboxes apps from each other in the browser (even - // though they are served from the same gateway domain). - // - // Omited if the path was treated by IPNSHostnameOption(), for example - // a request for http://example.net/ would be changed to /ipns/example.net/, - // which would turn into an incorrect Suborigin: example.net header. - // - // NOTE: This is not yet widely supported by browsers. - if !ipnsHostname { - pathRoot := strings.SplitN(urlPath, "/", 4)[2] - w.Header().Set("Suborigin", pathRoot) - } - // set these headers _after_ the error, for we may just not have it // and dont want the client to cache a 500 response... // and only if it's /ipfs! From 03b812700bec6796f9f0bcd6e2238003f42ca477 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 27 Dec 2016 02:13:59 -0800 Subject: [PATCH 195/674] update libp2p for identify configuration updates License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@d8f257c264f67f9fbcc4cccf935d77c89c9e8bc7 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index caa8311b8..bb2ee128c 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmbzCT1CwxVZ2ednptC9RavuJe7Bv8DDi2Ne89qUrA37XM/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQHmMFyhfp2ZXnbYWqAWhEideDCNDM6hzJwqCU29Y5zV2/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 9f1eefc95..d4b64b378 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmbzCT1CwxVZ2ednptC9RavuJe7Bv8DDi2Ne89qUrA37XM/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQHmMFyhfp2ZXnbYWqAWhEideDCNDM6hzJwqCU29Y5zV2/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 320bf7628..54d094d7a 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" + bhost "gx/ipfs/QmQHmMFyhfp2ZXnbYWqAWhEideDCNDM6hzJwqCU29Y5zV2/go-libp2p/p2p/host/basic" inet "gx/ipfs/QmQx1dHDDYENugYgqA22BaBrRfuv1coSsuPiM7rYh1wwGH/go-libp2p-net" testutil "gx/ipfs/QmWdGJY4fcsfhLHucEfivw8J71yUqNUFbzdU1jnJBnN5Xh/go-libp2p-netutil" - bhost "gx/ipfs/QmbzCT1CwxVZ2ednptC9RavuJe7Bv8DDi2Ne89qUrA37XM/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 65cd5272e623611b46411c2276be5dd9b1a39071 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 10 Jan 2017 05:56:28 -0800 Subject: [PATCH 196/674] update go-libp2p with negotiate lazy fixes License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@30aacd1b0ac3c6c722beb4a86b0619fc07f89a4b --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index bb2ee128c..ab439725a 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmQHmMFyhfp2ZXnbYWqAWhEideDCNDM6hzJwqCU29Y5zV2/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmdzDdLZ7nj133QvNHypyS9Y39g35bMFk5DJ2pmX7YqtKU/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index d4b64b378..9bf67ec22 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmQHmMFyhfp2ZXnbYWqAWhEideDCNDM6hzJwqCU29Y5zV2/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmdzDdLZ7nj133QvNHypyS9Y39g35bMFk5DJ2pmX7YqtKU/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 54d094d7a..922cebfa2 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmQHmMFyhfp2ZXnbYWqAWhEideDCNDM6hzJwqCU29Y5zV2/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmPS1HTBHiJcqxDAZ4s8bGt22HtL3oC67TPR3BsrvM44Z1/go-libp2p-netutil" inet "gx/ipfs/QmQx1dHDDYENugYgqA22BaBrRfuv1coSsuPiM7rYh1wwGH/go-libp2p-net" - testutil "gx/ipfs/QmWdGJY4fcsfhLHucEfivw8J71yUqNUFbzdU1jnJBnN5Xh/go-libp2p-netutil" + bhost "gx/ipfs/QmdzDdLZ7nj133QvNHypyS9Y39g35bMFk5DJ2pmX7YqtKU/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 591df79d1a78df71550d5d94ec83865bbea92164 Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Thu, 9 Feb 2017 12:44:30 +0100 Subject: [PATCH 197/674] feat(webui): update to new version Closes #3664 License: MIT Signed-off-by: Friedel This commit was moved from ipfs/kubo@49c30f6efe60c67362fa7301612d0a1501f5331d --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 8d4445ef3..1f4ea2975 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmU3o9bvfenhTKhxUakbYrLDnZU7HezAVxPM6Ehjw9Xjqy" +const WebUIPath = "/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -14,6 +14,7 @@ var WebUIPaths = []string{ "/ipfs/QmS2HL9v5YeKgQkkWMvs1EMnFtUowTEdFfSSeMT4pos1e6", "/ipfs/QmR9MzChjp1MdFWik7NjEjqKQMzVmBkdK3dz14A6B5Cupm", "/ipfs/QmRyWyKWmphamkMRnJVjUTzSFSAAZowYP4rnbgnfMXC9Mr", + "/ipfs/QmU3o9bvfenhTKhxUakbYrLDnZU7HezAVxPM6Ehjw9Xjqy", } var WebUIOption = RedirectOption("webui", WebUIPath) From 14b3bb23034a3b2a8ff092b2cc1f475c72a7a4e8 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 2 Feb 2017 20:09:02 -0800 Subject: [PATCH 198/674] update go-multihash and bubble up deps License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@b4eeff2d84447eb367360a5b4adef16188a32a27 --- gateway/core/corehttp/corehttp.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 6 +++--- gateway/core/corehttp/gateway_test.go | 4 ++-- gateway/core/corehttp/metrics.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 06e7cc8c5..fec5f08e2 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,9 +12,9 @@ import ( core "github.com/ipfs/go-ipfs/core" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" + ma "gx/ipfs/QmSWLfmj5frN9xVLMMN846dMDriy5wN5jeghUm7aTW3DAG/go-multiaddr" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" - manet "gx/ipfs/QmT6Cp31887FpAc25z25YHgpFJohZedrYLWPPspRtj1Brp/go-multiaddr-net" - ma "gx/ipfs/QmUAQaWbKxGCUTuoQVvvicbQNZ9APF5pDGWyAZSe93AtKH/go-multiaddr" + manet "gx/ipfs/QmVCNGTyD4EkvNYaAp253uMQ9Rjsjy2oGMvcdJJUoVRfja/go-multiaddr-net" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index ab439725a..74b1cc325 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmdzDdLZ7nj133QvNHypyS9Y39g35bMFk5DJ2pmX7YqtKU/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 69082de8c..07336d1e3 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -22,9 +22,9 @@ import ( ft "github.com/ipfs/go-ipfs/unixfs" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - node "gx/ipfs/QmRSU5EqqWVZSNdbU51yXmVoF1uNw3JgTNB6RaiL7DZM16/go-ipld-node" - routing "gx/ipfs/QmbkGVaN9W6RYJK4Ws5FvMKXKDqdRQ5snhtaa92qP6L8eU/go-libp2p-routing" - cid "gx/ipfs/QmcTcsTvfaeEBRFo1TkFgT8sRmgi1n1LTZpecfVP8fzpGD/go-cid" + cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid" + node "gx/ipfs/QmYDscK7dmdo2GZ9aumS8s5auUUAH5mR1jvj5pYhWusfK7/go-ipld-node" + routing "gx/ipfs/QmZghcVHwXQC3Zvnvn24LgTmSPkEn2o3PDyKb6nrtPRzRh/go-libp2p-routing" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 9bf67ec22..a474ac25b 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,8 +19,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmdzDdLZ7nj133QvNHypyS9Y39g35bMFk5DJ2pmX7YqtKU/go-libp2p/p2p/protocol/identify" - ci "gx/ipfs/QmfWDLQjGjVe4fr5CoztYW2DYYjRysMJrFe1RCsXLPTf46/go-libp2p-crypto" + ci "gx/ipfs/QmNiCwBNA8MWDADTFVq1BonUEJbS2SvjAoNkZZrhEwcuUi/go-libp2p-crypto" + id "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 0ef0ba6f4..51a6c13ed 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -6,7 +6,7 @@ import ( core "github.com/ipfs/go-ipfs/core" - prometheus "gx/ipfs/QmR3KwhXCRLTNZB59vELb2HhEWrGy9nuychepxFtj3wWYa/client_golang/prometheus" + prometheus "gx/ipfs/QmX3QZ5jHEPidwUrymXV1iSCSUhdGxj15sm2gP4jKMef7B/client_golang/prometheus" ) // This adds the scraping endpoint which Prometheus uses to fetch metrics. diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 922cebfa2..748ee898e 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - testutil "gx/ipfs/QmPS1HTBHiJcqxDAZ4s8bGt22HtL3oC67TPR3BsrvM44Z1/go-libp2p-netutil" - inet "gx/ipfs/QmQx1dHDDYENugYgqA22BaBrRfuv1coSsuPiM7rYh1wwGH/go-libp2p-net" - bhost "gx/ipfs/QmdzDdLZ7nj133QvNHypyS9Y39g35bMFk5DJ2pmX7YqtKU/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmRuZnMorqodado1yeTQiv1i9rmtKj29CjPSsBKM7DFXV4/go-libp2p-net" + bhost "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmTcGn1vzu7YNxz6FEXvfUfMy6WmYeQ5VtU3MbWM8c92rB/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 35782b5879191d79bb549a4c9cc78149581e004d Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 16 Feb 2017 15:19:48 +0100 Subject: [PATCH 199/674] deps: update dependencies for PNet License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@4eed546e067f04e6278fe580a47dd4328426ec84 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 74b1cc325..169f4c781 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index a474ac25b..9e1abfd78 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,7 +20,7 @@ import ( testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" ci "gx/ipfs/QmNiCwBNA8MWDADTFVq1BonUEJbS2SvjAoNkZZrhEwcuUi/go-libp2p-crypto" - id "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 748ee898e..81b5dccb9 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -8,8 +8,8 @@ import ( core "github.com/ipfs/go-ipfs/core" inet "gx/ipfs/QmRuZnMorqodado1yeTQiv1i9rmtKj29CjPSsBKM7DFXV4/go-libp2p-net" - bhost "gx/ipfs/QmSNJRX4uphb3Eyp69uYbpRVvgqjPxfjnJmjcdMWkDH5Pn/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/QmTcGn1vzu7YNxz6FEXvfUfMy6WmYeQ5VtU3MbWM8c92rB/go-libp2p-netutil" + bhost "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmdGRzr9bPTt2ZrBFaq5R2zzD7JFXNRxXZGkzsVcW6pEzh/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 5a44a663666b7d4cf673e48790c6af02d588580c Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 5 Mar 2017 23:06:04 -0800 Subject: [PATCH 200/674] update go-libp2p-kad-dht with getclosestpeers fix License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@4e168dc323bcaab39bfb91efea49778777d944d0 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 4 ++-- gateway/core/corehttp/metrics_test.go | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 169f4c781..e212c183b 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmeWJwi61vii5g8zQUB9UGegfUbmhTKHgeDFP9XuSp5jZ4/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 07336d1e3..67dae923b 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -22,9 +22,9 @@ import ( ft "github.com/ipfs/go-ipfs/unixfs" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" + routing "gx/ipfs/QmUc6twRJRE9MNrUGd8eo9WjHHxebGppdZfptGCASkR7fF/go-libp2p-routing" cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid" node "gx/ipfs/QmYDscK7dmdo2GZ9aumS8s5auUUAH5mR1jvj5pYhWusfK7/go-ipld-node" - routing "gx/ipfs/QmZghcVHwXQC3Zvnvn24LgTmSPkEn2o3PDyKb6nrtPRzRh/go-libp2p-routing" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 9e1abfd78..a120e57ca 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,8 +19,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - ci "gx/ipfs/QmNiCwBNA8MWDADTFVq1BonUEJbS2SvjAoNkZZrhEwcuUi/go-libp2p-crypto" - id "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/protocol/identify" + ci "gx/ipfs/QmPGxZ1DP2w45WcogpW1h43BvseXbfke9N91qotpoQcUeS/go-libp2p-crypto" + id "gx/ipfs/QmeWJwi61vii5g8zQUB9UGegfUbmhTKHgeDFP9XuSp5jZ4/go-libp2p/p2p/protocol/identify" ) type mockNamesys map[string]path.Path diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 81b5dccb9..31b9b291c 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - inet "gx/ipfs/QmRuZnMorqodado1yeTQiv1i9rmtKj29CjPSsBKM7DFXV4/go-libp2p-net" - bhost "gx/ipfs/QmU3g3psEDiC4tQh1Qu2NYg5aYVQqxC3m74ZavLwPfJEtu/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/QmdGRzr9bPTt2ZrBFaq5R2zzD7JFXNRxXZGkzsVcW6pEzh/go-libp2p-netutil" + testutil "gx/ipfs/QmNqvnxGtJBaKQnenD6uboNGdjSjHGmZGRxMHEevKJe5Pk/go-libp2p-netutil" + inet "gx/ipfs/QmVtMT3fD7DzQNW7hdm6Xe6KPstzcggrhNpeVZ4422UpKK/go-libp2p-net" + bhost "gx/ipfs/QmeWJwi61vii5g8zQUB9UGegfUbmhTKHgeDFP9XuSp5jZ4/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From b591471c6b53f053248bf4ca4a683920ae6a3afe Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Wed, 16 Nov 2016 06:21:15 +0100 Subject: [PATCH 201/674] coreapi: smarter way of dealing with the different APIs License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@e260d2fd066158dfd7ae8e5ae7e25ac202cdaa90 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index e212c183b..84b9b2467 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -28,7 +28,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { Headers: cfg.Gateway.HTTPHeaders, Writable: writable, PathPrefixes: cfg.Gateway.PathPrefixes, - }, coreapi.NewUnixfsAPI(n)) + }, coreapi.NewCoreAPI(n)) for _, p := range paths { mux.Handle(p+"/", gateway) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 67dae923b..03d5ca18f 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -37,10 +37,10 @@ const ( type gatewayHandler struct { node *core.IpfsNode config GatewayConfig - api coreiface.UnixfsAPI + api coreiface.CoreAPI } -func newGatewayHandler(n *core.IpfsNode, c GatewayConfig, api coreiface.UnixfsAPI) *gatewayHandler { +func newGatewayHandler(n *core.IpfsNode, c GatewayConfig, api coreiface.CoreAPI) *gatewayHandler { i := &gatewayHandler{ node: n, config: c, @@ -158,7 +158,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr ipnsHostname = true } - dr, err := i.api.Cat(ctx, urlPath) + dr, err := i.api.Unixfs().Cat(ctx, urlPath) dir := false switch err { case nil: @@ -218,7 +218,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - links, err := i.api.Ls(ctx, urlPath) + links, err := i.api.Unixfs().Ls(ctx, urlPath) if err != nil { internalWebError(w, err) return @@ -247,7 +247,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } // return index page instead. - dr, err := i.api.Cat(ctx, p.String()) + dr, err := i.api.Unixfs().Cat(ctx, p.String()) if err != nil { internalWebError(w, err) return @@ -314,7 +314,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { - k, err := i.api.Add(ctx, r.Body) + k, err := i.api.Unixfs().Add(ctx, r.Body) if err != nil { internalWebError(w, err) return From e87bf1a12eca2a80e07513497906824838b328a8 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Fri, 17 Mar 2017 03:47:59 +0100 Subject: [PATCH 202/674] coreapi: make the interfaces path centric The new coreiface.Path maps a path to the cid.Cid resulting from a full path resolution. The path is internally represented as a go-ipfs/path.Path, but that doesn't matter to the outside. Apart from the path-to-CID mapping, it also aims to hold all resolved segment CIDs of the path. Right now it only exposes Root(), and only for flat paths a la /ipfs/Qmfoo. In other cases, the root is nil. In the future, resolution will internally use go-ipfs/path.Resolver.ResolvePathComponents and thus always return the proper resolved segments, via Root(), or a future Segments() func. - Add coreiface.Path with Cid() and Root(). - Add CoreAPI.ResolvePath() for getting a coreiface.Path. - All functions now expect and return coreiface.Path. - Add ParsePath() and ParseCid() for constructing a coreiface.Path. - Add coreiface.Node and Link which are simply go-ipld-node.Node and Link. - Add CoreAPI.ResolveNode() for getting a Node from a Path. License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@ee45b8d32f90313901429e7536c143e20dd5ff79 --- gateway/core/corehttp/gateway_handler.go | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 03d5ca18f..7c1c4ead7 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -12,6 +12,7 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + coreapi "github.com/ipfs/go-ipfs/core/coreapi" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/importer" chunk "github.com/ipfs/go-ipfs/importer/chunk" @@ -158,7 +159,13 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr ipnsHostname = true } - dr, err := i.api.Unixfs().Cat(ctx, urlPath) + parsedPath, err := coreapi.ParsePath(urlPath) + if err != nil { + webError(w, "invalid ipfs path", err, http.StatusBadRequest) + return + } + + dr, err := i.api.Unixfs().Cat(ctx, parsedPath) dir := false switch err { case nil: @@ -218,7 +225,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - links, err := i.api.Unixfs().Ls(ctx, urlPath) + links, err := i.api.Unixfs().Ls(ctx, parsedPath) if err != nil { internalWebError(w, err) return @@ -240,14 +247,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - p, err := path.ParsePath(urlPath + "/index.html") - if err != nil { - internalWebError(w, err) - return - } - - // return index page instead. - dr, err := i.api.Unixfs().Cat(ctx, p.String()) + dr, err := i.api.Unixfs().Cat(ctx, coreapi.ParseCid(link.Cid)) if err != nil { internalWebError(w, err) return @@ -314,15 +314,15 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { - k, err := i.api.Unixfs().Add(ctx, r.Body) + p, err := i.api.Unixfs().Add(ctx, r.Body) if err != nil { internalWebError(w, err) return } i.addUserHeaders(w) // ok, _now_ write user's headers. - w.Header().Set("IPFS-Hash", k.String()) - http.Redirect(w, r, ipfsPathPrefix+k.String(), http.StatusCreated) + w.Header().Set("IPFS-Hash", p.Cid().String()) + http.Redirect(w, r, p.String(), http.StatusCreated) } func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { From c116a06dc0e0a4b7de18ddd2794c31f2483b3fd1 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sat, 11 Mar 2017 04:25:03 +0100 Subject: [PATCH 203/674] gateway: simplify error responses, switch to 404 License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@9e4800d40a4ed35e5c7507f3fdb1ec132249b149 --- gateway/core/corehttp/gateway_handler.go | 17 ++++------------- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 67dae923b..0a958a977 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -17,7 +17,6 @@ import ( chunk "github.com/ipfs/go-ipfs/importer/chunk" dag "github.com/ipfs/go-ipfs/merkledag" dagutils "github.com/ipfs/go-ipfs/merkledag/utils" - "github.com/ipfs/go-ipfs/namesys" path "github.com/ipfs/go-ipfs/path" ft "github.com/ipfs/go-ipfs/unixfs" @@ -162,26 +161,18 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr dir := false switch err { case nil: - // core.Resolve worked + // Cat() worked defer dr.Close() case coreiface.ErrIsDir: dir = true - case namesys.ErrResolveFailed: - // Don't log that error as it is just noise - w.WriteHeader(http.StatusInternalServerError) - fmt.Fprintf(w, "Path Resolve error: %s", err.Error()) - log.Info("Path Resolve error: %s", err.Error()) - return case coreiface.ErrOffline: if !i.node.OnlineMode() { - w.WriteHeader(http.StatusServiceUnavailable) - fmt.Fprint(w, "Could not resolve path. Node is in offline mode.") + webError(w, "ipfs cat "+urlPath, err, http.StatusServiceUnavailable) return } fallthrough default: - // all other erros - webError(w, "Path Resolve error", err, http.StatusBadRequest) + webError(w, "ipfs cat "+urlPath, err, http.StatusNotFound) return } @@ -532,7 +523,7 @@ func webErrorWithCode(w http.ResponseWriter, message string, err error, code int w.WriteHeader(code) log.Errorf("%s: %s", message, err) // TODO(cryptix): log until we have a better way to expose these (counter metrics maybe) - fmt.Fprintf(w, "%s: %s", message, err) + fmt.Fprintf(w, "%s: %s\n", message, err) } // return a 500 error and log diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index a120e57ca..8f307b2c7 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -136,7 +136,7 @@ func TestGatewayGet(t *testing.T) { {"localhost:5001", "/", http.StatusNotFound, "404 page not found\n"}, {"localhost:5001", "/" + k, http.StatusNotFound, "404 page not found\n"}, {"localhost:5001", "/ipfs/" + k, http.StatusOK, "fnord"}, - {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusInternalServerError, "Path Resolve error: " + namesys.ErrResolveFailed.Error()}, + {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusNotFound, "ipfs cat /ipns/nxdomain.example.com: " + namesys.ErrResolveFailed.Error() + "\n"}, {"localhost:5001", "/ipns/example.com", http.StatusOK, "fnord"}, {"example.com", "/", http.StatusOK, "fnord"}, } { From 251c93a949e3de4430fd46228b0ee80a8402c2d6 Mon Sep 17 00:00:00 2001 From: Remco Bloemen Date: Tue, 18 Apr 2017 16:22:53 +0100 Subject: [PATCH 204/674] gateway: use CID as an ETag strong validator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Always use the fully resolved CID from api.ResolveNode as the ETag (also for IPNS). * Format the result as a valid "Strong Validator" (double quotes around the encoded CID). Fixes #3868 License: MIT Signed-off-by: Remco Bloemen This commit was moved from ipfs/kubo@8db6f86de6085b78bc03bccdc26d11a7350058d4 --- gateway/core/corehttp/gateway_handler.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 264f074d9..00e87eb66 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -183,7 +183,16 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - etag := gopath.Base(urlPath) + // Resolve path to the final DAG node for the ETag + dagnode, err := i.api.ResolveNode(ctx, parsedPath) + if err != nil { + // Unixfs().Cat() also calls ResolveNode, so it should not fail here. + webError(w, "could not resolve ipfs path", err, http.StatusBadRequest) + return + } + + // Check etag send back to us + etag := "\"" + dagnode.Cid().String() + "\"" if r.Header.Get("If-None-Match") == etag { w.WriteHeader(http.StatusNotModified) return @@ -191,6 +200,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("X-IPFS-Path", urlPath) + w.Header().Set("Etag", etag) // set 'allowed' headers w.Header().Set("Access-Control-Allow-Headers", "X-Stream-Output, X-Chunked-Output") @@ -203,7 +213,6 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // TODO: break this out when we split /ipfs /ipns routes. modtime := time.Now() if strings.HasPrefix(urlPath, ipfsPathPrefix) { - w.Header().Set("Etag", etag) w.Header().Set("Cache-Control", "public, max-age=29030400, immutable") // set modtime to a really long time ago, since files are immutable and should stay cached From eb20e3fb49b40f9c875c295c0bce7c923ec49bea Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Wed, 19 Apr 2017 05:10:41 +0200 Subject: [PATCH 205/674] gateway: fix erroneous Cache-Control: immutable on dir listings License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@2c4e6434adadb9ab0f0c1be9f9046d2761d8fc0f --- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 29 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 264f074d9..5a7d3b79a 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -202,7 +202,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // and only if it's /ipfs! // TODO: break this out when we split /ipfs /ipns routes. modtime := time.Now() - if strings.HasPrefix(urlPath, ipfsPathPrefix) { + if strings.HasPrefix(urlPath, ipfsPathPrefix) && !dir { w.Header().Set("Etag", etag) w.Header().Set("Cache-Control", "public, max-age=29030400, immutable") diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 8f307b2c7..55c0b15ee 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -23,6 +23,9 @@ import ( id "gx/ipfs/QmeWJwi61vii5g8zQUB9UGegfUbmhTKHgeDFP9XuSp5jZ4/go-libp2p/p2p/protocol/identify" ) +// `ipfs object new unixfs-dir` +var emptyDir = "/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" + type mockNamesys map[string]path.Path func (m mockNamesys) Resolve(ctx context.Context, name string) (value path.Path, err error) { @@ -461,6 +464,32 @@ func TestIPNSHostnameBacklinks(t *testing.T) { } } +func TestCacheControlImmutable(t *testing.T) { + ts, _ := newTestServerAndNode(t, nil) + t.Logf("test server url: %s", ts.URL) + defer ts.Close() + + req, err := http.NewRequest("GET", ts.URL+emptyDir+"/", nil) + if err != nil { + t.Fatal(err) + } + + res, err := doWithoutRedirect(req) + if err != nil { + t.Fatal(err) + } + + // check the immutable tag isn't set + hdrs, ok := res.Header["Cache-Control"] + if ok { + for _, hdr := range hdrs { + if strings.Contains(hdr, "immutable") { + t.Fatalf("unexpected Cache-Control: immutable on directory listing: %s", hdr) + } + } + } +} + func TestVersion(t *testing.T) { config.CurrentCommit = "theshortcommithash" From e0e1d046cc414db2bb774dd57a57332189986591 Mon Sep 17 00:00:00 2001 From: Remco Bloemen Date: Tue, 18 Apr 2017 17:22:01 +0100 Subject: [PATCH 206/674] gateway: re-use resolved path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of resolving a node, we resolve a path. This resolved path is then re-used for Cat and Ls. This way, a resolve operation is only done once. The error messages for a failed resolve is changed from `ipfs cat …` to `ipfs resolve …` to better reflect the API calls. The test is updated accordingly. License: MIT Signed-off-by: Remco Bloemen This commit was moved from ipfs/kubo@a90f4967e30fc5f16d362f1b9844196e1bd24101 --- gateway/core/corehttp/gateway_handler.go | 31 ++++++++++++------------ gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 00e87eb66..3d282c27f 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -164,35 +164,36 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - dr, err := i.api.Unixfs().Cat(ctx, parsedPath) - dir := false + // Resolve path to the final DAG node for the ETag + resolvedPath, err := i.api.ResolvePath(ctx, parsedPath) switch err { case nil: - // Cat() worked - defer dr.Close() - case coreiface.ErrIsDir: - dir = true case coreiface.ErrOffline: if !i.node.OnlineMode() { - webError(w, "ipfs cat "+urlPath, err, http.StatusServiceUnavailable) + webError(w, "ipfs resolve -r "+urlPath, err, http.StatusServiceUnavailable) return } fallthrough default: - webError(w, "ipfs cat "+urlPath, err, http.StatusNotFound) + webError(w, "ipfs resolve -r "+urlPath, err, http.StatusNotFound) return } - // Resolve path to the final DAG node for the ETag - dagnode, err := i.api.ResolveNode(ctx, parsedPath) - if err != nil { - // Unixfs().Cat() also calls ResolveNode, so it should not fail here. - webError(w, "could not resolve ipfs path", err, http.StatusBadRequest) + dr, err := i.api.Unixfs().Cat(ctx, resolvedPath) + dir := false + switch err { + case nil: + // Cat() worked + defer dr.Close() + case coreiface.ErrIsDir: + dir = true + default: + webError(w, "ipfs cat "+urlPath, err, http.StatusNotFound) return } // Check etag send back to us - etag := "\"" + dagnode.Cid().String() + "\"" + etag := "\"" + resolvedPath.Cid().String() + "\"" if r.Header.Get("If-None-Match") == etag { w.WriteHeader(http.StatusNotModified) return @@ -225,7 +226,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - links, err := i.api.Unixfs().Ls(ctx, parsedPath) + links, err := i.api.Unixfs().Ls(ctx, resolvedPath) if err != nil { internalWebError(w, err) return diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 8f307b2c7..8b639f1f2 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -136,7 +136,7 @@ func TestGatewayGet(t *testing.T) { {"localhost:5001", "/", http.StatusNotFound, "404 page not found\n"}, {"localhost:5001", "/" + k, http.StatusNotFound, "404 page not found\n"}, {"localhost:5001", "/ipfs/" + k, http.StatusOK, "fnord"}, - {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusNotFound, "ipfs cat /ipns/nxdomain.example.com: " + namesys.ErrResolveFailed.Error() + "\n"}, + {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusNotFound, "ipfs resolve -r /ipns/nxdomain.example.com: " + namesys.ErrResolveFailed.Error() + "\n"}, {"localhost:5001", "/ipns/example.com", http.StatusOK, "fnord"}, {"example.com", "/", http.StatusOK, "fnord"}, } { From 1c9f6d4c5f44884c918d7fd76c02a8564231ce63 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 24 Mar 2017 23:51:18 -0700 Subject: [PATCH 207/674] bubble up updates from go-multihash changes License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@b15470d548755abb0376e948fd37a165f0b6e1e2 --- gateway/core/corehttp/corehttp.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 6 +++--- gateway/core/corehttp/gateway_test.go | 4 ++-- gateway/core/corehttp/metrics_test.go | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index fec5f08e2..6809f270d 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,9 +12,9 @@ import ( core "github.com/ipfs/go-ipfs/core" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" - ma "gx/ipfs/QmSWLfmj5frN9xVLMMN846dMDriy5wN5jeghUm7aTW3DAG/go-multiaddr" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" - manet "gx/ipfs/QmVCNGTyD4EkvNYaAp253uMQ9Rjsjy2oGMvcdJJUoVRfja/go-multiaddr-net" + ma "gx/ipfs/QmcyqRMCAXVtYPS4DiBrA7sezL9rRGfW8Ctx7cywL4TXJj/go-multiaddr" + manet "gx/ipfs/Qmf1Gq7N45Rpuw7ev47uWgH6dLPtdnvcMRNPkVBwqjLJg2/go-multiaddr-net" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 84b9b2467..b54a7cb34 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmeWJwi61vii5g8zQUB9UGegfUbmhTKHgeDFP9XuSp5jZ4/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmRai5yZNL67pWCoznW7sBdFnqZrFULuJ5w8KhmRyhdgN4/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d36d0dd65..cbc891694 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -22,9 +22,9 @@ import ( ft "github.com/ipfs/go-ipfs/unixfs" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - routing "gx/ipfs/QmUc6twRJRE9MNrUGd8eo9WjHHxebGppdZfptGCASkR7fF/go-libp2p-routing" - cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid" - node "gx/ipfs/QmYDscK7dmdo2GZ9aumS8s5auUUAH5mR1jvj5pYhWusfK7/go-ipld-node" + cid "gx/ipfs/QmYhQaCYEcaPPjxJX7YcPcVKkQfRy6sJ7B3XmGFk82XYdQ/go-cid" + routing "gx/ipfs/QmafuecpeZp3k3sHJ5mUARHd4795revuadECQMkmHB8LfW/go-libp2p-routing" + node "gx/ipfs/Qmb3Hm9QDFmfYuET4pu7Kyg8JV78jFa1nvZx5vnCZsK4ck/go-ipld-format" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index c63591899..527f6b32d 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,8 +19,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - ci "gx/ipfs/QmPGxZ1DP2w45WcogpW1h43BvseXbfke9N91qotpoQcUeS/go-libp2p-crypto" - id "gx/ipfs/QmeWJwi61vii5g8zQUB9UGegfUbmhTKHgeDFP9XuSp5jZ4/go-libp2p/p2p/protocol/identify" + ci "gx/ipfs/QmP1DfoUjiWH2ZBo1PBH6FupdBucbDepx3HpWmEY6JMUpY/go-libp2p-crypto" + id "gx/ipfs/QmRai5yZNL67pWCoznW7sBdFnqZrFULuJ5w8KhmRyhdgN4/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 31b9b291c..5ce9dc1ab 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - testutil "gx/ipfs/QmNqvnxGtJBaKQnenD6uboNGdjSjHGmZGRxMHEevKJe5Pk/go-libp2p-netutil" - inet "gx/ipfs/QmVtMT3fD7DzQNW7hdm6Xe6KPstzcggrhNpeVZ4422UpKK/go-libp2p-net" - bhost "gx/ipfs/QmeWJwi61vii5g8zQUB9UGegfUbmhTKHgeDFP9XuSp5jZ4/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/QmRai5yZNL67pWCoznW7sBdFnqZrFULuJ5w8KhmRyhdgN4/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmVHSBsn8LEeay8m5ERebgUVuhzw838PsyTttCmP6GMJkg/go-libp2p-net" + testutil "gx/ipfs/QmcCgouQ5iXfmxmVNc1fpXLacRSPMNHx4tzqDpou6XNvvd/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From edef958431db384b30a8545dbb1392d307197c7c Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 20 Apr 2017 19:09:38 +0200 Subject: [PATCH 208/674] deps: Update go-is-domain to contain new gTLD It should resolve issues with newer gTLDs being not selected License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@d1e3fc5c87d92b5c341083c4eb1049fa01a66c8e --- gateway/core/corehttp/ipns_hostname.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index e22912e3d..fb3b72a28 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -7,7 +7,7 @@ import ( "context" "github.com/ipfs/go-ipfs/core" - isd "gx/ipfs/QmaeHSCBd9XjXxmgHEiKkHtLcMCb2eZsPLKT7bHgBfBkqw/go-is-domain" + isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) // IPNSHostnameOption rewrites an incoming request if its Host: header contains From cf465fa9455afc6e48e26ca0c3b15540d8354ae2 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Mon, 24 Apr 2017 14:57:57 +0200 Subject: [PATCH 209/674] mics: cleanup imports in touched files License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@fe969d18beb6395c0d06179ba950b671b9f37bf7 --- gateway/core/corehttp/ipns_hostname.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index fb3b72a28..6a36bd8c4 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -1,12 +1,13 @@ package corehttp import ( + "context" "net" "net/http" "strings" - "context" "github.com/ipfs/go-ipfs/core" + isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) From 8a9e81b6a4f3e67ec9b303bc75033309a71ff976 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 4 May 2017 17:41:05 -0700 Subject: [PATCH 210/674] improved gateway directory listing for sharded nodes License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@5bb480b4dab0a4a7b1fd8cd0a496f84fff911a65 --- gateway/core/corehttp/gateway_handler.go | 150 ++++++++++++----------- 1 file changed, 81 insertions(+), 69 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index cbc891694..c639201b5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "net/http" + "os" gopath "path" "runtime/debug" "strings" @@ -20,6 +21,7 @@ import ( dagutils "github.com/ipfs/go-ipfs/merkledag/utils" path "github.com/ipfs/go-ipfs/path" ft "github.com/ipfs/go-ipfs/unixfs" + uio "github.com/ipfs/go-ipfs/unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmYhQaCYEcaPPjxJX7YcPcVKkQfRy6sJ7B3XmGFk82XYdQ/go-cid" @@ -227,92 +229,102 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - links, err := i.api.Unixfs().Ls(ctx, resolvedPath) + nd, err := i.api.ResolveNode(ctx, resolvedPath) if err != nil { internalWebError(w, err) return } - // storage for directory listing - var dirListing []directoryItem - // loop through files - foundIndex := false - for _, link := range links { - if link.Name == "index.html" { - log.Debugf("found index.html link for %s", urlPath) - foundIndex = true - - if urlPath[len(urlPath)-1] != '/' { - // See comment above where originalUrlPath is declared. - http.Redirect(w, r, originalUrlPath+"/", 302) - log.Debugf("redirect to %s", originalUrlPath+"/") - return - } + dirr, err := uio.NewDirectoryFromNode(i.node.DAG, nd) + if err != nil { + internalWebError(w, err) + return + } - dr, err := i.api.Unixfs().Cat(ctx, coreapi.ParseCid(link.Cid)) - if err != nil { - internalWebError(w, err) - return - } - defer dr.Close() + ixnd, err := dirr.Find(ctx, "index.html") + switch { + case err == nil: + log.Debugf("found index.html link for %s", urlPath) + + if urlPath[len(urlPath)-1] != '/' { + // See comment above where originalUrlPath is declared. + http.Redirect(w, r, originalUrlPath+"/", 302) + log.Debugf("redirect to %s", originalUrlPath+"/") + return + } - // write to request - http.ServeContent(w, r, "index.html", modtime, dr) - break + dr, err := i.api.Unixfs().Cat(ctx, coreapi.ParseCid(ixnd.Cid())) + if err != nil { + internalWebError(w, err) + return } + defer dr.Close() + // write to request + http.ServeContent(w, r, "index.html", modtime, dr) + return + default: + internalWebError(w, err) + return + case os.IsNotExist(err): + } + + if r.Method == "HEAD" { + return + } + + // storage for directory listing + var dirListing []directoryItem + dirr.ForEachLink(ctx, func(link *node.Link) error { // See comment above where originalUrlPath is declared. di := directoryItem{humanize.Bytes(link.Size), link.Name, gopath.Join(originalUrlPath, link.Name)} dirListing = append(dirListing, di) - } + return nil + }) - if !foundIndex { - if r.Method != "HEAD" { - // construct the correct back link - // https://github.com/ipfs/go-ipfs/issues/1365 - var backLink string = prefix + urlPath - - // don't go further up than /ipfs/$hash/ - pathSplit := path.SplitList(backLink) - switch { - // keep backlink - case len(pathSplit) == 3: // url: /ipfs/$hash - - // keep backlink - case len(pathSplit) == 4 && pathSplit[3] == "": // url: /ipfs/$hash/ - - // add the correct link depending on wether the path ends with a slash - default: - if strings.HasSuffix(backLink, "/") { - backLink += "./.." - } else { - backLink += "/.." - } - } + // construct the correct back link + // https://github.com/ipfs/go-ipfs/issues/1365 + var backLink string = prefix + urlPath - // strip /ipfs/$hash from backlink if IPNSHostnameOption touched the path. - if ipnsHostname { - backLink = prefix + "/" - if len(pathSplit) > 5 { - // also strip the trailing segment, because it's a backlink - backLinkParts := pathSplit[3 : len(pathSplit)-2] - backLink += path.Join(backLinkParts) + "/" - } - } + // don't go further up than /ipfs/$hash/ + pathSplit := path.SplitList(backLink) + switch { + // keep backlink + case len(pathSplit) == 3: // url: /ipfs/$hash - // See comment above where originalUrlPath is declared. - tplData := listingTemplateData{ - Listing: dirListing, - Path: originalUrlPath, - BackLink: backLink, - } - err := listingTemplate.Execute(w, tplData) - if err != nil { - internalWebError(w, err) - return - } + // keep backlink + case len(pathSplit) == 4 && pathSplit[3] == "": // url: /ipfs/$hash/ + + // add the correct link depending on wether the path ends with a slash + default: + if strings.HasSuffix(backLink, "/") { + backLink += "./.." + } else { + backLink += "/.." } } + + // strip /ipfs/$hash from backlink if IPNSHostnameOption touched the path. + if ipnsHostname { + backLink = prefix + "/" + if len(pathSplit) > 5 { + // also strip the trailing segment, because it's a backlink + backLinkParts := pathSplit[3 : len(pathSplit)-2] + backLink += path.Join(backLinkParts) + "/" + } + } + + // See comment above where originalUrlPath is declared. + tplData := listingTemplateData{ + Listing: dirListing, + Path: originalUrlPath, + BackLink: backLink, + } + err = listingTemplate.Execute(w, tplData) + if err != nil { + internalWebError(w, err) + return + } } func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { From e257996099aec9b63ec4e0968e980dfb083c4c34 Mon Sep 17 00:00:00 2001 From: James Stanley Date: Wed, 10 May 2017 10:39:37 +0100 Subject: [PATCH 211/674] Add Suborigin header to gateway responses (#3209) This existed before but was disabled in 630596a because the Suborigin spec changed and it became incompatible. This commit updates the generated Suborigin header to be conformant with the latest spec. License: MIT Signed-off-by: James Stanley This commit was moved from ipfs/kubo@cb2a38d89b3c02b509f1d974b60f114cf7cf44ac --- gateway/core/corehttp/gateway_handler.go | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index c639201b5..d0ea65dc7 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -27,6 +27,7 @@ import ( cid "gx/ipfs/QmYhQaCYEcaPPjxJX7YcPcVKkQfRy6sJ7B3XmGFk82XYdQ/go-cid" routing "gx/ipfs/QmafuecpeZp3k3sHJ5mUARHd4795revuadECQMkmHB8LfW/go-libp2p-routing" node "gx/ipfs/Qmb3Hm9QDFmfYuET4pu7Kyg8JV78jFa1nvZx5vnCZsK4ck/go-ipld-format" + multibase "gx/ipfs/QmcxkxTVuURV2Ptse8TvkqH5BQDwV62X1x19JqqvbBzwUM/go-multibase" ) const ( @@ -210,6 +211,39 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // expose those headers w.Header().Set("Access-Control-Expose-Headers", "X-Stream-Output, X-Chunked-Output") + // Suborigin header, sandboxes apps from each other in the browser (even + // though they are served from the same gateway domain). + // + // Omitted if the path was treated by IPNSHostnameOption(), for example + // a request for http://example.net/ would be changed to /ipns/example.net/, + // which would turn into an incorrect Suborigin header. + // In this case the correct thing to do is omit the header because it is already + // handled correctly without a Suborigin. + // + // NOTE: This is not yet widely supported by browsers. + if !ipnsHostname { + // e.g.: 1="ipfs", 2="QmYuNaKwY...", ... + pathComponents := strings.SplitN(urlPath, "/", 4) + + var suboriginRaw []byte + cidDecoded, err := cid.Decode(pathComponents[2]) + if err != nil { + // component 2 doesn't decode with cid, so it must be a hostname + suboriginRaw = []byte(strings.ToLower(pathComponents[2])) + } else { + suboriginRaw = cidDecoded.Bytes() + } + + base32Encoded, err := multibase.Encode(multibase.Base32, suboriginRaw) + if err != nil { + internalWebError(w, err) + return + } + + suborigin := pathComponents[1] + "000" + strings.ToLower(base32Encoded) + w.Header().Set("Suborigin", suborigin) + } + // set these headers _after_ the error, for we may just not have it // and dont want the client to cache a 500 response... // and only if it's /ipfs! From 85a7d8ba54df2c5893fdefc3edb8d0746bd03d05 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 16 May 2017 19:35:43 -0700 Subject: [PATCH 212/674] update to dht code with provide announce option License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@0418930ca89f6d3ab4c2ffadfbb0b9f5ff02a197 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d0ea65dc7..55c333792 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -24,8 +24,8 @@ import ( uio "github.com/ipfs/go-ipfs/unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" + routing "gx/ipfs/QmXiH3yLocPhjkAmL8R29fKRcEKoVXKCaVDbAS9tdTrVEd/go-libp2p-routing" cid "gx/ipfs/QmYhQaCYEcaPPjxJX7YcPcVKkQfRy6sJ7B3XmGFk82XYdQ/go-cid" - routing "gx/ipfs/QmafuecpeZp3k3sHJ5mUARHd4795revuadECQMkmHB8LfW/go-libp2p-routing" node "gx/ipfs/Qmb3Hm9QDFmfYuET4pu7Kyg8JV78jFa1nvZx5vnCZsK4ck/go-ipld-format" multibase "gx/ipfs/QmcxkxTVuURV2Ptse8TvkqH5BQDwV62X1x19JqqvbBzwUM/go-multibase" ) From ca1f9dd8c67f3370cd86c1b37509e698f3638612 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 24 May 2017 09:12:27 -0700 Subject: [PATCH 213/674] make odds of 'process added after close' panic less likely License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@53f1a9a50a156630d3d2f6c01814d33791f7bb9c --- gateway/core/corehttp/corehttp.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 6809f270d..57478a628 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -79,6 +79,12 @@ func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error var serverError error serverExited := make(chan struct{}) + select { + case <-node.Process().Closing(): + return fmt.Errorf("failed to start server, process closing") + default: + } + node.Process().Go(func(p goprocess.Process) { serverError = http.Serve(lis, handler) close(serverExited) From 89a691863f8eaf22c873517e5f47c3aac576815e Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Tue, 30 May 2017 02:26:05 +0200 Subject: [PATCH 214/674] gx: update go-libp2p-peerstore, go-libp2p, go-libp2p-kbucket License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@64ced367ac64cbd682aa3c3557ee82fcbd606b9c --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index b54a7cb34..6d2eb1ebd 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmRai5yZNL67pWCoznW7sBdFnqZrFULuJ5w8KhmRyhdgN4/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQA5mdxru8Bh6dpC9PJfSkumqnmHgJX7knxSgBo5Lpime/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 55c333792..ceaec886a 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -23,8 +23,8 @@ import ( ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" + routing "gx/ipfs/QmNdaQ8itUU9jEZUwTsG4gHMaPmRfi6FEe89QjQAFbep3M/go-libp2p-routing" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - routing "gx/ipfs/QmXiH3yLocPhjkAmL8R29fKRcEKoVXKCaVDbAS9tdTrVEd/go-libp2p-routing" cid "gx/ipfs/QmYhQaCYEcaPPjxJX7YcPcVKkQfRy6sJ7B3XmGFk82XYdQ/go-cid" node "gx/ipfs/Qmb3Hm9QDFmfYuET4pu7Kyg8JV78jFa1nvZx5vnCZsK4ck/go-ipld-format" multibase "gx/ipfs/QmcxkxTVuURV2Ptse8TvkqH5BQDwV62X1x19JqqvbBzwUM/go-multibase" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 527f6b32d..005f2844b 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,7 +20,7 @@ import ( testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" ci "gx/ipfs/QmP1DfoUjiWH2ZBo1PBH6FupdBucbDepx3HpWmEY6JMUpY/go-libp2p-crypto" - id "gx/ipfs/QmRai5yZNL67pWCoznW7sBdFnqZrFULuJ5w8KhmRyhdgN4/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQA5mdxru8Bh6dpC9PJfSkumqnmHgJX7knxSgBo5Lpime/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 5ce9dc1ab..cdb9a93b2 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmRai5yZNL67pWCoznW7sBdFnqZrFULuJ5w8KhmRyhdgN4/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmVHSBsn8LEeay8m5ERebgUVuhzw838PsyTttCmP6GMJkg/go-libp2p-net" - testutil "gx/ipfs/QmcCgouQ5iXfmxmVNc1fpXLacRSPMNHx4tzqDpou6XNvvd/go-libp2p-netutil" + bhost "gx/ipfs/QmQA5mdxru8Bh6dpC9PJfSkumqnmHgJX7knxSgBo5Lpime/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmRscs8KxrSmSv4iuevHv8JfuUzHBMoqiaHzxfDRiksd6e/go-libp2p-net" + testutil "gx/ipfs/Qma2j8dYePrvN5DoNgwh1uAuu3FFtEtrUQFmr737ws8nCp/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From c1d667ea2c41ae9b435acc7e444565e9c2f02563 Mon Sep 17 00:00:00 2001 From: zramsay Date: Wed, 31 May 2017 16:56:11 -0400 Subject: [PATCH 215/674] apply the megacheck tool to improve code quality License: MIT Signed-off-by: Zach Ramsay This commit was moved from ipfs/kubo@c5df8f0796fa5bc252f3311deb03eccf0266f546 --- gateway/core/corehttp/gateway_test.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 005f2844b..5ef5d0aee 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -427,11 +427,6 @@ func TestIPNSHostnameBacklinks(t *testing.T) { req.Host = "example.net" req.Header.Set("X-Ipfs-Gateway-Prefix", "/bad-prefix") - res, err = doWithoutRedirect(req) - if err != nil { - t.Fatal(err) - } - // make request to directory listing with evil prefix req, err = http.NewRequest("GET", ts.URL, nil) if err != nil { From 56096b0da8a4a4aa51392f94c82bfa3b8ff9bfc2 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Thu, 8 Jun 2017 03:20:04 +0200 Subject: [PATCH 216/674] gateway: don't redirect to trailing slash if it's go get This enables `go get` to parse go-import meta tags from index.html files stored in IPFS. One tiny step toward whyrusleeping/gx-go#2. For an import like `ipfs.io/ipfs/QmFoo/mypkg`, the gateway would previously redirect to `/ipfs/QmFoo/mypkg/` (note the trailing slash), which the `go get` tool can't deal with. Thankfully, `go get` sets a URL query parameter (`?go-get=1`) which we can use to switch off the redirect in this case. License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@4fe5b3eab706eb75e5597ba063375902f483a3e7 --- gateway/core/corehttp/gateway_handler.go | 4 +++- gateway/core/corehttp/gateway_test.go | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ceaec886a..113fe52b5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -280,7 +280,9 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr case err == nil: log.Debugf("found index.html link for %s", urlPath) - if urlPath[len(urlPath)-1] != '/' { + dirwithoutslash := urlPath[len(urlPath)-1] != '/' + goget := r.URL.Query().Get("go-get") == "1" + if dirwithoutslash && !goget { // See comment above where originalUrlPath is declared. http.Redirect(w, r, originalUrlPath+"/", 302) log.Debugf("redirect to %s", originalUrlPath+"/") diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 005f2844b..14f942b1f 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -490,6 +490,27 @@ func TestCacheControlImmutable(t *testing.T) { } } +func TestGoGetSupport(t *testing.T) { + ts, _ := newTestServerAndNode(t, nil) + t.Logf("test server url: %s", ts.URL) + defer ts.Close() + + // mimic go-get + req, err := http.NewRequest("GET", ts.URL+emptyDir+"?go-get=1", nil) + if err != nil { + t.Fatal(err) + } + + res, err := doWithoutRedirect(req) + if err != nil { + t.Fatal(err) + } + + if res.StatusCode != 200 { + t.Errorf("status is %d, expected 200", res.StatusCode) + } +} + func TestVersion(t *testing.T) { config.CurrentCommit = "theshortcommithash" From e3b44b721e36512fee2cb7e02427c27b2d41ef22 Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 14 Jun 2017 23:01:48 +0300 Subject: [PATCH 217/674] check strong and weak ETag validator CDN may change strong ETag validator to weak ETag validator. License: MIT Signed-off-by: Ivan This commit was moved from ipfs/kubo@8b88b7ffd2dce4ffaf69087c5e1962ace18f27d8 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 113fe52b5..463289121 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -197,7 +197,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // Check etag send back to us etag := "\"" + resolvedPath.Cid().String() + "\"" - if r.Header.Get("If-None-Match") == etag { + if r.Header.Get("If-None-Match") == etag || r.Header.Get("If-None-Match") == "W/"+etag { w.WriteHeader(http.StatusNotModified) return } From 39169fe5876292955edb162d6598fd89725a3ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 22 Jun 2017 16:59:59 +0200 Subject: [PATCH 218/674] Show escaped url in gateway 404 message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@5ebf897f6f3b86d9dc84273d5e1d3fefedbd8066 --- gateway/core/corehttp/gateway_handler.go | 9 +++++---- gateway/core/corehttp/gateway_test.go | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 113fe52b5..c7b4c6e6f 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -134,6 +134,7 @@ func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request) func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { urlPath := r.URL.Path + escapedURLPath := r.URL.EscapedPath() // If the gateway is behind a reverse proxy and mounted at a sub-path, // the prefix header can be set to signal this sub-path. @@ -173,12 +174,12 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr case nil: case coreiface.ErrOffline: if !i.node.OnlineMode() { - webError(w, "ipfs resolve -r "+urlPath, err, http.StatusServiceUnavailable) + webError(w, "ipfs resolve -r "+escapedURLPath, err, http.StatusServiceUnavailable) return } fallthrough default: - webError(w, "ipfs resolve -r "+urlPath, err, http.StatusNotFound) + webError(w, "ipfs resolve -r "+escapedURLPath, err, http.StatusNotFound) return } @@ -191,7 +192,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr case coreiface.ErrIsDir: dir = true default: - webError(w, "ipfs cat "+urlPath, err, http.StatusNotFound) + webError(w, "ipfs cat "+escapedURLPath, err, http.StatusNotFound) return } @@ -278,7 +279,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr ixnd, err := dirr.Find(ctx, "index.html") switch { case err == nil: - log.Debugf("found index.html link for %s", urlPath) + log.Debugf("found index.html link for %s", escapedURLPath) dirwithoutslash := urlPath[len(urlPath)-1] != '/' goget := r.URL.Query().Get("go-get") == "1" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index da60e8a65..3a4760e71 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -140,6 +140,7 @@ func TestGatewayGet(t *testing.T) { {"localhost:5001", "/" + k, http.StatusNotFound, "404 page not found\n"}, {"localhost:5001", "/ipfs/" + k, http.StatusOK, "fnord"}, {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusNotFound, "ipfs resolve -r /ipns/nxdomain.example.com: " + namesys.ErrResolveFailed.Error() + "\n"}, + {"localhost:5001", "/ipns/%0D%0A%0D%0Ahello", http.StatusNotFound, "ipfs resolve -r /ipns/%0D%0A%0D%0Ahello: " + namesys.ErrResolveFailed.Error() + "\n"}, {"localhost:5001", "/ipns/example.com", http.StatusOK, "fnord"}, {"example.com", "/", http.StatusOK, "fnord"}, } { From 26ed679b6472522ea91f47102ea1af009d04d967 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sun, 18 Jun 2017 13:07:24 -0700 Subject: [PATCH 219/674] blocks: gx import go-block-format And updated related dependencies. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@13636bef50437fa6c03f31bb8ecbfdafe6306e10 --- gateway/core/corehttp/gateway_handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index c7b4c6e6f..1da84eef5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -24,9 +24,9 @@ import ( uio "github.com/ipfs/go-ipfs/unixfs/io" routing "gx/ipfs/QmNdaQ8itUU9jEZUwTsG4gHMaPmRfi6FEe89QjQAFbep3M/go-libp2p-routing" + cid "gx/ipfs/QmNw61A6sJoXMeP37mJRtQZdNhj5e3FdjoTN3v4FyE96Gk/go-cid" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - cid "gx/ipfs/QmYhQaCYEcaPPjxJX7YcPcVKkQfRy6sJ7B3XmGFk82XYdQ/go-cid" - node "gx/ipfs/Qmb3Hm9QDFmfYuET4pu7Kyg8JV78jFa1nvZx5vnCZsK4ck/go-ipld-format" + node "gx/ipfs/QmUBtPvHKFAX43XMsyxsYpMi3U5VwZ4jYFTo4kFhvAR33G/go-ipld-format" multibase "gx/ipfs/QmcxkxTVuURV2Ptse8TvkqH5BQDwV62X1x19JqqvbBzwUM/go-multibase" ) From be0782a18f3d3382136313f7dfd0a1a20a7b8127 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 19 Jun 2017 19:11:32 -0700 Subject: [PATCH 220/674] gx import/update libp2p/go-libp2p-routing For some reason, this was referenced but wasn't listed in packages.json. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@520938a9ec9994da318729c7a29c5eb194b8a024 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1da84eef5..8dd88595e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -23,10 +23,10 @@ import ( ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" - routing "gx/ipfs/QmNdaQ8itUU9jEZUwTsG4gHMaPmRfi6FEe89QjQAFbep3M/go-libp2p-routing" cid "gx/ipfs/QmNw61A6sJoXMeP37mJRtQZdNhj5e3FdjoTN3v4FyE96Gk/go-cid" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" node "gx/ipfs/QmUBtPvHKFAX43XMsyxsYpMi3U5VwZ4jYFTo4kFhvAR33G/go-ipld-format" + routing "gx/ipfs/QmaNDbaV1wvPRLxTYepVsXrppXNjQ1NbrnG7ibAgKeyaXD/go-libp2p-routing" multibase "gx/ipfs/QmcxkxTVuURV2Ptse8TvkqH5BQDwV62X1x19JqqvbBzwUM/go-multibase" ) From 8f9b67ca86af3e5097bc5622704f67ecaa8c97e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 4 Jul 2017 20:18:57 +0200 Subject: [PATCH 221/674] Update go-datastore to 1.2.2, go-cid to 0.7.16 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@8ab93aaeb220a2ea31b0420479eba4b99cc592d4 --- gateway/core/corehttp/gateway_handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 8dd88595e..6ec2c3893 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -23,10 +23,10 @@ import ( ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" - cid "gx/ipfs/QmNw61A6sJoXMeP37mJRtQZdNhj5e3FdjoTN3v4FyE96Gk/go-cid" + routing "gx/ipfs/QmP1wMAqk6aZYRZirbaAwmrNeqFRgQrwBt3orUtvSa1UYD/go-libp2p-routing" + node "gx/ipfs/QmPAKbSsgEX5B6fpmxa61jXYnoWzZr5sNafd3qgPiSH8Uv/go-ipld-format" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - node "gx/ipfs/QmUBtPvHKFAX43XMsyxsYpMi3U5VwZ4jYFTo4kFhvAR33G/go-ipld-format" - routing "gx/ipfs/QmaNDbaV1wvPRLxTYepVsXrppXNjQ1NbrnG7ibAgKeyaXD/go-libp2p-routing" + cid "gx/ipfs/Qma4RJSuh7mMeJQYCqMbKzekn6EwBo7HEs5AQYjVRMQATB/go-cid" multibase "gx/ipfs/QmcxkxTVuURV2Ptse8TvkqH5BQDwV62X1x19JqqvbBzwUM/go-multibase" ) From 19f0395e5e480c6ae16b044e565d36a71075810b Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 3 Apr 2017 19:21:52 -0700 Subject: [PATCH 222/674] implement bitswap sessions License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@bda8c3a6873e35eb674ad17633f35e6720931f94 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 6ec2c3893..a8ebc390a 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -27,7 +27,7 @@ import ( node "gx/ipfs/QmPAKbSsgEX5B6fpmxa61jXYnoWzZr5sNafd3qgPiSH8Uv/go-ipld-format" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/Qma4RJSuh7mMeJQYCqMbKzekn6EwBo7HEs5AQYjVRMQATB/go-cid" - multibase "gx/ipfs/QmcxkxTVuURV2Ptse8TvkqH5BQDwV62X1x19JqqvbBzwUM/go-multibase" + multibase "gx/ipfs/Qme4T6BE4sQxg7ZouamF5M7Tx1ZFTqzcns7BkyQPXpoT99/go-multibase" ) const ( From 7d313bf246afe107d806d64faa01b4cb83589e18 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Tue, 11 Jul 2017 19:17:51 -0700 Subject: [PATCH 223/674] update go-multihash and bubble up changes License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@cccc6a94a32d2b2f56b9234efb3e9e1a9fd0f390 --- gateway/core/corehttp/corehttp.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 6 +++--- gateway/core/corehttp/gateway_test.go | 4 ++-- gateway/core/corehttp/metrics_test.go | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 57478a628..57935abdf 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -13,8 +13,8 @@ import ( core "github.com/ipfs/go-ipfs/core" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" - ma "gx/ipfs/QmcyqRMCAXVtYPS4DiBrA7sezL9rRGfW8Ctx7cywL4TXJj/go-multiaddr" - manet "gx/ipfs/Qmf1Gq7N45Rpuw7ev47uWgH6dLPtdnvcMRNPkVBwqjLJg2/go-multiaddr-net" + manet "gx/ipfs/QmX3U3YXCQ6UYBxq2LVWF8dARS1hPUTEYLrSx654Qyxyw6/go-multiaddr-net" + ma "gx/ipfs/QmXY77cVe7rVRQXZZQRioukUM7aRW3BTcAgJe12MCtb3Ji/go-multiaddr" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 6d2eb1ebd..cd287241a 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmQA5mdxru8Bh6dpC9PJfSkumqnmHgJX7knxSgBo5Lpime/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmapADMpK4e5kFGBxC2aHreaDqKP9vmMng5f91MA14Ces9/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index a8ebc390a..301742ad6 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -23,10 +23,10 @@ import ( ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" - routing "gx/ipfs/QmP1wMAqk6aZYRZirbaAwmrNeqFRgQrwBt3orUtvSa1UYD/go-libp2p-routing" - node "gx/ipfs/QmPAKbSsgEX5B6fpmxa61jXYnoWzZr5sNafd3qgPiSH8Uv/go-ipld-format" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - cid "gx/ipfs/Qma4RJSuh7mMeJQYCqMbKzekn6EwBo7HEs5AQYjVRMQATB/go-cid" + routing "gx/ipfs/QmPjTrrSfE6TzLv6ya6VWhGcCgPrUAdcgrDcQyRDX2VyW1/go-libp2p-routing" + cid "gx/ipfs/QmTprEaAA2A9bst5XH7exuyi5KzNMK3SEDNN8rBDnKWcUS/go-cid" + node "gx/ipfs/QmYNyRZJBUYPNrLszFmrBrPJbsBh2vMsefz5gnDpB5M1P6/go-ipld-format" multibase "gx/ipfs/Qme4T6BE4sQxg7ZouamF5M7Tx1ZFTqzcns7BkyQPXpoT99/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 3a4760e71..3d2564a84 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,8 +19,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - ci "gx/ipfs/QmP1DfoUjiWH2ZBo1PBH6FupdBucbDepx3HpWmEY6JMUpY/go-libp2p-crypto" - id "gx/ipfs/QmQA5mdxru8Bh6dpC9PJfSkumqnmHgJX7knxSgBo5Lpime/go-libp2p/p2p/protocol/identify" + ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" + id "gx/ipfs/QmapADMpK4e5kFGBxC2aHreaDqKP9vmMng5f91MA14Ces9/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index cdb9a93b2..a72075e46 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmQA5mdxru8Bh6dpC9PJfSkumqnmHgJX7knxSgBo5Lpime/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmRscs8KxrSmSv4iuevHv8JfuUzHBMoqiaHzxfDRiksd6e/go-libp2p-net" - testutil "gx/ipfs/Qma2j8dYePrvN5DoNgwh1uAuu3FFtEtrUQFmr737ws8nCp/go-libp2p-netutil" + testutil "gx/ipfs/QmViDDJGzv2TKrheoxckReECc72iRgaYsobG2HYUGWuPVF/go-libp2p-netutil" + inet "gx/ipfs/QmahYsGWry85Y7WUe2SX5G4JkH2zifEQAUtJVLZ24aC9DF/go-libp2p-net" + bhost "gx/ipfs/QmapADMpK4e5kFGBxC2aHreaDqKP9vmMng5f91MA14Ces9/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 832719a9070333e3b1b18b7021548d8263b2f169 Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Sun, 16 Jul 2017 15:34:02 +0200 Subject: [PATCH 224/674] core/http/gateway: Expose `Content-Range` header The `Content-Range` header is necessary for extracting (only) the metadata of audio files. License: MIT Signed-off-by: Steven Vandevelde This commit was moved from ipfs/kubo@20ad44af1cfbc8504c9456a8f9d8b66607c36cf3 --- gateway/core/corehttp/gateway_handler.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 301742ad6..a4677d09e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -208,9 +208,17 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr w.Header().Set("Etag", etag) // set 'allowed' headers - w.Header().Set("Access-Control-Allow-Headers", "X-Stream-Output, X-Chunked-Output") - // expose those headers - w.Header().Set("Access-Control-Expose-Headers", "X-Stream-Output, X-Chunked-Output") + // & expose those headers + var allowedHeadersArr = []string{ + "Content-Range", + "X-Chunked-Output", + "X-Stream-Output", + } + + var allowedHeaders = strings.Join(allowedHeadersArr, ", ") + + w.Header().Set("Access-Control-Allow-Headers", allowedHeaders) + w.Header().Set("Access-Control-Expose-Headers", allowedHeaders) // Suborigin header, sandboxes apps from each other in the browser (even // though they are served from the same gateway domain). From 914760e5c8e5f0acac7759d36bb2c90e4cfe500b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 27 Jul 2017 00:02:03 -0700 Subject: [PATCH 225/674] gx: update deps License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@28be1d4c584a4d6ee9a3f16a97e9519eec4dc9ae --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index cd287241a..00f299c3b 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmapADMpK4e5kFGBxC2aHreaDqKP9vmMng5f91MA14Ces9/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmSatLR9HCrZjPqomt6VdNCoJmHMz8NP34WfpfBznJZ25M/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 3d2564a84..ac87190d5 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,8 +19,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" + id "gx/ipfs/QmSatLR9HCrZjPqomt6VdNCoJmHMz8NP34WfpfBznJZ25M/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" - id "gx/ipfs/QmapADMpK4e5kFGBxC2aHreaDqKP9vmMng5f91MA14Ces9/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index a72075e46..9fe8c18f9 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - testutil "gx/ipfs/QmViDDJGzv2TKrheoxckReECc72iRgaYsobG2HYUGWuPVF/go-libp2p-netutil" + bhost "gx/ipfs/QmSatLR9HCrZjPqomt6VdNCoJmHMz8NP34WfpfBznJZ25M/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmV5Ny5H649nHUEYjtZistVPQVqqNVMZC5khmQvnprzdNZ/go-libp2p-netutil" inet "gx/ipfs/QmahYsGWry85Y7WUe2SX5G4JkH2zifEQAUtJVLZ24aC9DF/go-libp2p-net" - bhost "gx/ipfs/QmapADMpK4e5kFGBxC2aHreaDqKP9vmMng5f91MA14Ces9/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From cd3d7ad1d171f5d7f6d052f2c2da82b578fa52b0 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 31 Jul 2017 14:04:40 -0700 Subject: [PATCH 226/674] gx: update go-libp2p-swarm fixes #4102 (fixed in go-libp2p-swarm) License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@38a9be5a0a6bb54be8cabb53933d0039bd6305b5 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 00f299c3b..15ecad213 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmSatLR9HCrZjPqomt6VdNCoJmHMz8NP34WfpfBznJZ25M/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZPBrKq6S1fdYaRAzYZivJL12QkUqHwnNzF9wC8VXC4bo/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index ac87190d5..36ec969c4 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" - id "gx/ipfs/QmSatLR9HCrZjPqomt6VdNCoJmHMz8NP34WfpfBznJZ25M/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZPBrKq6S1fdYaRAzYZivJL12QkUqHwnNzF9wC8VXC4bo/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 9fe8c18f9..947d5b052 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,8 +7,8 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmSatLR9HCrZjPqomt6VdNCoJmHMz8NP34WfpfBznJZ25M/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/QmV5Ny5H649nHUEYjtZistVPQVqqNVMZC5khmQvnprzdNZ/go-libp2p-netutil" + testutil "gx/ipfs/QmSTbByZ1rJVn8KANcoiLDiPH2pgDaz33uT6JW6B9nMBW5/go-libp2p-netutil" + bhost "gx/ipfs/QmZPBrKq6S1fdYaRAzYZivJL12QkUqHwnNzF9wC8VXC4bo/go-libp2p/p2p/host/basic" inet "gx/ipfs/QmahYsGWry85Y7WUe2SX5G4JkH2zifEQAUtJVLZ24aC9DF/go-libp2p-net" ) From db22af086c0c9979c57518d0c2e9776aee01a11c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 16 Aug 2017 16:51:18 -0700 Subject: [PATCH 227/674] extract update go-testutil License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@19c3bd82a34c15777ab83a4e92e6bc9293d75580 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 6 +++--- gateway/core/corehttp/metrics_test.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 15ecad213..f8dc52632 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmZPBrKq6S1fdYaRAzYZivJL12QkUqHwnNzF9wC8VXC4bo/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmXZ6XetFwaDNmszPCux9DaKqMykEJGDtWHSqprn94UXzM/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 36ec969c4..f1df688f8 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,9 +17,9 @@ import ( path "github.com/ipfs/go-ipfs/path" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" - testutil "github.com/ipfs/go-ipfs/thirdparty/testutil" + ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" - id "gx/ipfs/QmZPBrKq6S1fdYaRAzYZivJL12QkUqHwnNzF9wC8VXC4bo/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmXZ6XetFwaDNmszPCux9DaKqMykEJGDtWHSqprn94UXzM/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) @@ -56,7 +56,7 @@ func newNodeWithMockNamesys(ns mockNamesys) (*core.IpfsNode, error) { } r := &repo.Mock{ C: c, - D: testutil.ThreadSafeCloserMapDatastore(), + D: ds2.ThreadSafeCloserMapDatastore(), } n, err := core.NewNode(context.Background(), &core.BuildCfg{Repo: r}) if err != nil { diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 947d5b052..05332d409 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,8 +7,8 @@ import ( core "github.com/ipfs/go-ipfs/core" - testutil "gx/ipfs/QmSTbByZ1rJVn8KANcoiLDiPH2pgDaz33uT6JW6B9nMBW5/go-libp2p-netutil" - bhost "gx/ipfs/QmZPBrKq6S1fdYaRAzYZivJL12QkUqHwnNzF9wC8VXC4bo/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/QmXZ6XetFwaDNmszPCux9DaKqMykEJGDtWHSqprn94UXzM/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmZG4W8GR9FpC4z69Vab9ENtEoxKjDnTym5oa7Q3Yr7P4o/go-libp2p-netutil" inet "gx/ipfs/QmahYsGWry85Y7WUe2SX5G4JkH2zifEQAUtJVLZ24aC9DF/go-libp2p-net" ) From e4b7b2c4be562de2a8eb00e179f094a4c200efc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 23 Aug 2017 16:32:32 +0200 Subject: [PATCH 228/674] gx: update go-reuseport MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@e34a5e9c0d015096e2170a535e72efa4438d8170 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index f8dc52632..6574dc834 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmXZ6XetFwaDNmszPCux9DaKqMykEJGDtWHSqprn94UXzM/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZyngpQxUGyx1T2bzEcst6YzERkvVwDzBMbsSQF4f1smE/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index f1df688f8..549e743dc 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" - id "gx/ipfs/QmXZ6XetFwaDNmszPCux9DaKqMykEJGDtWHSqprn94UXzM/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZyngpQxUGyx1T2bzEcst6YzERkvVwDzBMbsSQF4f1smE/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 05332d409..668d7e37c 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,8 +7,8 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmXZ6XetFwaDNmszPCux9DaKqMykEJGDtWHSqprn94UXzM/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/QmZG4W8GR9FpC4z69Vab9ENtEoxKjDnTym5oa7Q3Yr7P4o/go-libp2p-netutil" + testutil "gx/ipfs/QmYdcTdkuCvFXLj2uejJF5aY3HWhtd8JLT4BjPxF9BNPYf/go-libp2p-netutil" + bhost "gx/ipfs/QmZyngpQxUGyx1T2bzEcst6YzERkvVwDzBMbsSQF4f1smE/go-libp2p/p2p/host/basic" inet "gx/ipfs/QmahYsGWry85Y7WUe2SX5G4JkH2zifEQAUtJVLZ24aC9DF/go-libp2p-net" ) From b513bd693c9bea529e1683e23c3b13b4d0fc7a22 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 28 Aug 2017 20:32:16 -0700 Subject: [PATCH 229/674] gx: update go-cid, go-multibase, base32 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@70d662994064c72f52f4617e49e96b2c36446fa3 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 8 ++++---- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 6574dc834..ca51f0949 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmZyngpQxUGyx1T2bzEcst6YzERkvVwDzBMbsSQF4f1smE/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmbRT4BwPQEx4CPCd8LKYL46tFWYneGswQnHFdsuiczJRL/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index a4677d09e..f02e87407 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -23,11 +23,11 @@ import ( ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" + cid "gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid" + node "gx/ipfs/QmPN7cwmpcc4DWXb4KTB9dNAJgjuPY69h3npsMfhRrQL9c/go-ipld-format" + routing "gx/ipfs/QmPR2JzfKd9poHx9XBhzoFeBBC31ZM3W5iUPKJZWyaoZZm/go-libp2p-routing" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - routing "gx/ipfs/QmPjTrrSfE6TzLv6ya6VWhGcCgPrUAdcgrDcQyRDX2VyW1/go-libp2p-routing" - cid "gx/ipfs/QmTprEaAA2A9bst5XH7exuyi5KzNMK3SEDNN8rBDnKWcUS/go-cid" - node "gx/ipfs/QmYNyRZJBUYPNrLszFmrBrPJbsBh2vMsefz5gnDpB5M1P6/go-ipld-format" - multibase "gx/ipfs/Qme4T6BE4sQxg7ZouamF5M7Tx1ZFTqzcns7BkyQPXpoT99/go-multibase" + multibase "gx/ipfs/QmafgXF3u3QSWErQoZ2URmQp5PFG384htoE7J338nS2H7T/go-multibase" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 549e743dc..36322dedb 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,8 +19,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" - id "gx/ipfs/QmZyngpQxUGyx1T2bzEcst6YzERkvVwDzBMbsSQF4f1smE/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" + id "gx/ipfs/QmbRT4BwPQEx4CPCd8LKYL46tFWYneGswQnHFdsuiczJRL/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 668d7e37c..85f3c67d4 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - testutil "gx/ipfs/QmYdcTdkuCvFXLj2uejJF5aY3HWhtd8JLT4BjPxF9BNPYf/go-libp2p-netutil" - bhost "gx/ipfs/QmZyngpQxUGyx1T2bzEcst6YzERkvVwDzBMbsSQF4f1smE/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmYTeBaLWbFKQAtVTHbxvTbKfgqrGJUupK4UwjeugownfD/go-libp2p-netutil" inet "gx/ipfs/QmahYsGWry85Y7WUe2SX5G4JkH2zifEQAUtJVLZ24aC9DF/go-libp2p-net" + bhost "gx/ipfs/QmbRT4BwPQEx4CPCd8LKYL46tFWYneGswQnHFdsuiczJRL/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 98a997f2407f088786784f252e9ff0e48537ace9 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 4 Sep 2017 23:37:11 -0700 Subject: [PATCH 230/674] gx: update go-ws-transport License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@0eba4f3138752e9b6f501a3813ed02784484dab1 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index ca51f0949..331a66a01 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmbRT4BwPQEx4CPCd8LKYL46tFWYneGswQnHFdsuiczJRL/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmXZyBQMkqSYigxhJResC6fLWDGFhbphK67eZoqMDUvBmK/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 36322dedb..509826c30 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,8 +19,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" + id "gx/ipfs/QmXZyBQMkqSYigxhJResC6fLWDGFhbphK67eZoqMDUvBmK/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" - id "gx/ipfs/QmbRT4BwPQEx4CPCd8LKYL46tFWYneGswQnHFdsuiczJRL/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 85f3c67d4..15d9488a9 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - testutil "gx/ipfs/QmYTeBaLWbFKQAtVTHbxvTbKfgqrGJUupK4UwjeugownfD/go-libp2p-netutil" + testutil "gx/ipfs/QmQ1bJEsmdEiGfTQRoj6CsshWmAKduAEDEbwzbvk5QT5Ui/go-libp2p-netutil" + bhost "gx/ipfs/QmXZyBQMkqSYigxhJResC6fLWDGFhbphK67eZoqMDUvBmK/go-libp2p/p2p/host/basic" inet "gx/ipfs/QmahYsGWry85Y7WUe2SX5G4JkH2zifEQAUtJVLZ24aC9DF/go-libp2p-net" - bhost "gx/ipfs/QmbRT4BwPQEx4CPCd8LKYL46tFWYneGswQnHFdsuiczJRL/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 74545fe14fd0dd48db906dd665a5c89d8805a466 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 14 Sep 2017 11:39:25 -0700 Subject: [PATCH 231/674] gx: update go-stream-muxer Introduces a new Reset method on streams that kills both sides of the connection. Close now officially just closes the write side (what it did all along...) * Also pull through shiny new go-multiplexer fixes. * Also pull in go-reuseport update. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@8deaaa8d8c0457d70feb1ae4bb71cb845e22c405 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 331a66a01..124f85e69 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmXZyBQMkqSYigxhJResC6fLWDGFhbphK67eZoqMDUvBmK/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZ3ma9g2NTg7GNF1ntWNRa1GW9jVzGq8UE9cKCwRKv6dS/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 509826c30..33b68b1be 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" - id "gx/ipfs/QmXZyBQMkqSYigxhJResC6fLWDGFhbphK67eZoqMDUvBmK/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZ3ma9g2NTg7GNF1ntWNRa1GW9jVzGq8UE9cKCwRKv6dS/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 15d9488a9..3ab9fd6eb 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - testutil "gx/ipfs/QmQ1bJEsmdEiGfTQRoj6CsshWmAKduAEDEbwzbvk5QT5Ui/go-libp2p-netutil" - bhost "gx/ipfs/QmXZyBQMkqSYigxhJResC6fLWDGFhbphK67eZoqMDUvBmK/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmahYsGWry85Y7WUe2SX5G4JkH2zifEQAUtJVLZ24aC9DF/go-libp2p-net" + inet "gx/ipfs/QmNa31VPzC561NWwRsJLE7nGYZYuuD2QfpK2b1q9BK54J1/go-libp2p-net" + testutil "gx/ipfs/QmP4cEjmvf8tC6ykxKXrvmYLo8vqtGsgduMatjbAKnBzv8/go-libp2p-netutil" + bhost "gx/ipfs/QmZ3ma9g2NTg7GNF1ntWNRa1GW9jVzGq8UE9cKCwRKv6dS/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 7989de7425fadf92a814e3143ab672ab13f6d17c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 15 Sep 2017 18:56:44 -0700 Subject: [PATCH 232/674] update yamux We need to cancel out all readers/writers on stream reset. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@3f6df3a5f40f9e4ba79767dbd92127b8bba28bb7 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 124f85e69..7da6369a9 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmZ3ma9g2NTg7GNF1ntWNRa1GW9jVzGq8UE9cKCwRKv6dS/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmRQ76P5dgvxTujhfPsCRAG83rC15jgb1G9bKLuomuC6dQ/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 33b68b1be..68fb49e2a 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" - id "gx/ipfs/QmZ3ma9g2NTg7GNF1ntWNRa1GW9jVzGq8UE9cKCwRKv6dS/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmRQ76P5dgvxTujhfPsCRAG83rC15jgb1G9bKLuomuC6dQ/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 3ab9fd6eb..5d3ae6b73 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -8,8 +8,8 @@ import ( core "github.com/ipfs/go-ipfs/core" inet "gx/ipfs/QmNa31VPzC561NWwRsJLE7nGYZYuuD2QfpK2b1q9BK54J1/go-libp2p-net" - testutil "gx/ipfs/QmP4cEjmvf8tC6ykxKXrvmYLo8vqtGsgduMatjbAKnBzv8/go-libp2p-netutil" - bhost "gx/ipfs/QmZ3ma9g2NTg7GNF1ntWNRa1GW9jVzGq8UE9cKCwRKv6dS/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/QmRQ76P5dgvxTujhfPsCRAG83rC15jgb1G9bKLuomuC6dQ/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmdzuGp4a9pahgXuBeReHdYGUzdVX3FUCwfmWVo5mQfkTi/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 098631ab66b3c97823901821331566e737ffc30f Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 6 Oct 2017 08:42:59 -0700 Subject: [PATCH 233/674] update deps for new connmgr code License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@94ec788555de19fbef06e974eafd17c56d2b95dc --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 7da6369a9..f9fed9d40 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmRQ76P5dgvxTujhfPsCRAG83rC15jgb1G9bKLuomuC6dQ/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/Qmbgce14YTWE2qhE49JVvTBPaHTyz3FaFmqQPyuZAz6C28/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 68fb49e2a..22973da2c 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,8 +19,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" - id "gx/ipfs/QmRQ76P5dgvxTujhfPsCRAG83rC15jgb1G9bKLuomuC6dQ/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" + id "gx/ipfs/Qmbgce14YTWE2qhE49JVvTBPaHTyz3FaFmqQPyuZAz6C28/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 5d3ae6b73..f07449863 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" inet "gx/ipfs/QmNa31VPzC561NWwRsJLE7nGYZYuuD2QfpK2b1q9BK54J1/go-libp2p-net" - bhost "gx/ipfs/QmRQ76P5dgvxTujhfPsCRAG83rC15jgb1G9bKLuomuC6dQ/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/Qmbgce14YTWE2qhE49JVvTBPaHTyz3FaFmqQPyuZAz6C28/go-libp2p/p2p/host/basic" testutil "gx/ipfs/QmdzuGp4a9pahgXuBeReHdYGUzdVX3FUCwfmWVo5mQfkTi/go-libp2p-netutil" ) From 30271bc454f527df4650dd0a850507f90133cf70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 18 Oct 2017 20:10:22 +0200 Subject: [PATCH 234/674] gateway: fix seeker can't seek on specific files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@e71dce5dfba3616e5ade4abf0844925389497a56 --- gateway/core/corehttp/gateway_handler.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index f02e87407..336169404 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -268,7 +268,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr if !dir { name := gopath.Base(urlPath) - http.ServeContent(w, r, name, modtime, dr) + i.serverFile(w, r, name, modtime, dr) return } @@ -372,6 +372,17 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } } +func (i *gatewayHandler) serverFile(w http.ResponseWriter, req *http.Request, name string, modtime time.Time, content io.ReadSeeker) { + http.ServeContent(w, req, name, modtime, content) + //TODO: check for errors in ServeContent.. somehow + + // If http.ServeContent can't figure out content size it won't write it to the + // responseWriter, Content-Length not being set is a good indicator of this + if req.Method != "HEAD" && w.Header().Get("Content-Length") == "" { + io.Copy(w, content) + } +} + func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { p, err := i.api.Unixfs().Add(ctx, r.Body) if err != nil { From 2b59e93176b707d2db84e5cb5d1f4449e9f71ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 18 Oct 2017 22:25:36 +0200 Subject: [PATCH 235/674] gateway: custom seeker for files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@3fbb77153b676c773dd12821cf46be1ed351f65f --- gateway/core/corehttp/gateway_handler.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 336169404..0a7e657de 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -372,7 +372,31 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } } +type sizeReadSeeker interface { + Size() uint64 + + io.ReadSeeker +} + +type sizeSeeker struct { + sizeReadSeeker +} + +func (s *sizeSeeker) Seek(offset int64, whence int) (int64, error) { + if whence == io.SeekEnd && offset == 0 { + return int64(s.Size()), nil + } + + return s.sizeReadSeeker.Seek(offset, whence) +} + func (i *gatewayHandler) serverFile(w http.ResponseWriter, req *http.Request, name string, modtime time.Time, content io.ReadSeeker) { + if sp, ok := content.(sizeReadSeeker); ok { + content = &sizeSeeker{ + sizeReadSeeker: sp, + } + } + http.ServeContent(w, req, name, modtime, content) //TODO: check for errors in ServeContent.. somehow From 0bb0a346e2886ef1250fd06d725797b2ef81c280 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 19 Oct 2017 07:51:55 -0700 Subject: [PATCH 236/674] gx update go-peerstream, go-libp2p-floodsub License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@2f9e9ec571f509350e369b13ec4b37eff8ae85e4 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index f9fed9d40..ce238fb4e 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,7 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/Qmbgce14YTWE2qhE49JVvTBPaHTyz3FaFmqQPyuZAz6C28/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmefgzMbKZYsmHFkLqxgaTBG9ypeEjrdWRD5WXH4j1cWDL/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 22973da2c..f37ce7030 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,7 +20,7 @@ import ( ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" - id "gx/ipfs/Qmbgce14YTWE2qhE49JVvTBPaHTyz3FaFmqQPyuZAz6C28/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmefgzMbKZYsmHFkLqxgaTBG9ypeEjrdWRD5WXH4j1cWDL/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index f07449863..640c4ed9e 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -8,8 +8,8 @@ import ( core "github.com/ipfs/go-ipfs/core" inet "gx/ipfs/QmNa31VPzC561NWwRsJLE7nGYZYuuD2QfpK2b1q9BK54J1/go-libp2p-net" - bhost "gx/ipfs/Qmbgce14YTWE2qhE49JVvTBPaHTyz3FaFmqQPyuZAz6C28/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/QmdzuGp4a9pahgXuBeReHdYGUzdVX3FUCwfmWVo5mQfkTi/go-libp2p-netutil" + testutil "gx/ipfs/QmQGX417WoxKxDJeHqouMEmmH4G1RCENNSzkZYHrXy3Xb3/go-libp2p-netutil" + bhost "gx/ipfs/QmefgzMbKZYsmHFkLqxgaTBG9ypeEjrdWRD5WXH4j1cWDL/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From d125db3b5de79c794ba6446467e1f4dce4868d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 18 Oct 2017 22:26:03 +0200 Subject: [PATCH 237/674] merkledag: keep key order in dedupeKeys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@913f9641e4518ffa2609e09429254019385222af --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 0a7e657de..19b0de41c 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -373,7 +373,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } type sizeReadSeeker interface { - Size() uint64 + Size() uint64 io.ReadSeeker } From 81b07f54e27b537e49c343584d43f17dbafe4369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 20 Oct 2017 13:36:37 +0200 Subject: [PATCH 238/674] gateway: apply review to serveFile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@cbccd847aba20203da8fc3232712ce150936f38c --- gateway/core/corehttp/gateway_handler.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 19b0de41c..6e19f94ec 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -268,7 +268,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr if !dir { name := gopath.Base(urlPath) - i.serverFile(w, r, name, modtime, dr) + i.serveFile(w, r, name, modtime, dr) return } @@ -390,7 +390,7 @@ func (s *sizeSeeker) Seek(offset int64, whence int) (int64, error) { return s.sizeReadSeeker.Seek(offset, whence) } -func (i *gatewayHandler) serverFile(w http.ResponseWriter, req *http.Request, name string, modtime time.Time, content io.ReadSeeker) { +func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, name string, modtime time.Time, content io.ReadSeeker) { if sp, ok := content.(sizeReadSeeker); ok { content = &sizeSeeker{ sizeReadSeeker: sp, @@ -398,13 +398,6 @@ func (i *gatewayHandler) serverFile(w http.ResponseWriter, req *http.Request, na } http.ServeContent(w, req, name, modtime, content) - //TODO: check for errors in ServeContent.. somehow - - // If http.ServeContent can't figure out content size it won't write it to the - // responseWriter, Content-Length not being set is a good indicator of this - if req.Method != "HEAD" && w.Header().Get("Content-Length") == "" { - io.Copy(w, content) - } } func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { From f6762667e50ed8bdb7ef60c81da6d6115646a20b Mon Sep 17 00:00:00 2001 From: Jan Winkelmann Date: Sat, 1 Apr 2017 16:58:17 +0200 Subject: [PATCH 239/674] cmd: use go-ipfs-cmds License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@f28752494989792342168e0d7422bfb81ae508f1 --- gateway/core/corehttp/commands.go | 11 ++++++----- gateway/core/corehttp/gateway.go | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 882121c4e..9f689e9f4 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -7,11 +7,12 @@ import ( "strconv" "strings" - commands "github.com/ipfs/go-ipfs/commands" - cmdsHttp "github.com/ipfs/go-ipfs/commands/http" core "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" config "github.com/ipfs/go-ipfs/repo/config" + + cmds "gx/ipfs/QmQVvuDwXUGbtYmbmTcbLtGRYXnEbymaR2zEj38GVysqWe/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmQVvuDwXUGbtYmbmTcbLtGRYXnEbymaR2zEj38GVysqWe/go-ipfs-cmds/http" ) const originEnvKey = "API_ORIGIN" @@ -99,7 +100,7 @@ func patchCORSVars(c *cmdsHttp.ServerConfig, addr net.Addr) { c.SetAllowedOrigins(origins...) } -func commandsOption(cctx commands.Context, command *commands.Command) ServeOption { +func commandsOption(cctx cmds.Context, command *cmds.Command) ServeOption { return func(n *core.IpfsNode, l net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { cfg := cmdsHttp.NewServerConfig() @@ -120,10 +121,10 @@ func commandsOption(cctx commands.Context, command *commands.Command) ServeOptio } } -func CommandsOption(cctx commands.Context) ServeOption { +func CommandsOption(cctx cmds.Context) ServeOption { return commandsOption(cctx, corecommands.Root) } -func CommandsROOption(cctx commands.Context) ServeOption { +func CommandsROOption(cctx cmds.Context) ServeOption { return commandsOption(cctx, corecommands.RootRO) } diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index ce238fb4e..b46f6668d 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -8,6 +8,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" + id "gx/ipfs/QmefgzMbKZYsmHFkLqxgaTBG9ypeEjrdWRD5WXH4j1cWDL/go-libp2p/p2p/protocol/identify" ) From c511cdb1602cf469866cb60f73bbc91af4c7219f Mon Sep 17 00:00:00 2001 From: keks Date: Mon, 23 Oct 2017 16:50:39 +0200 Subject: [PATCH 240/674] compatible to js-ipfs-api License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@0d9d21875c21e71f485605976490c90b5f723866 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 9f689e9f4..3910076f3 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -11,8 +11,8 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmQVvuDwXUGbtYmbmTcbLtGRYXnEbymaR2zEj38GVysqWe/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmQVvuDwXUGbtYmbmTcbLtGRYXnEbymaR2zEj38GVysqWe/go-ipfs-cmds/http" + cmds "gx/ipfs/QmUsuV7rMitqBCk2UPmX1f3Vtp4tJNi6xvXpkQgKujjW5R/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmUsuV7rMitqBCk2UPmX1f3Vtp4tJNi6xvXpkQgKujjW5R/go-ipfs-cmds/http" ) const originEnvKey = "API_ORIGIN" From 264bf9be408b8747319718283100587f0e904a7a Mon Sep 17 00:00:00 2001 From: keks Date: Thu, 26 Oct 2017 13:19:27 +0200 Subject: [PATCH 241/674] update to go-ipfs-cmds 0.4.9 License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@d95a87cf5793138e653aab4ded394781fe6a4874 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 3910076f3..7874733fc 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -11,8 +11,8 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmUsuV7rMitqBCk2UPmX1f3Vtp4tJNi6xvXpkQgKujjW5R/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmUsuV7rMitqBCk2UPmX1f3Vtp4tJNi6xvXpkQgKujjW5R/go-ipfs-cmds/http" + cmds "gx/ipfs/QmUgr8HrEkQqXfBPtj1A2UEg1V7cvhUhDsmL44wFPCJk5k/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmUgr8HrEkQqXfBPtj1A2UEg1V7cvhUhDsmL44wFPCJk5k/go-ipfs-cmds/http" ) const originEnvKey = "API_ORIGIN" From 6b21549f9059e9614bc506c2f0a478271432f51a Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 20 Nov 2017 16:25:06 -0800 Subject: [PATCH 242/674] gx: massive update Note: This commit is technically broken. However, I need to make a bunch of cmds changes to make this work and I'd rather not bundle both changes into a single commit. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@76e1da02a89bdea225dbe2b33cb52993bf486c27 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 7874733fc..1d4ae0f9f 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -11,8 +11,8 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmUgr8HrEkQqXfBPtj1A2UEg1V7cvhUhDsmL44wFPCJk5k/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmUgr8HrEkQqXfBPtj1A2UEg1V7cvhUhDsmL44wFPCJk5k/go-ipfs-cmds/http" + cmds "gx/ipfs/QmQtQuaQvS5mKJVoCvL5FvrYH7oZPjxsVHf2bKSGgcVmZt/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmQtQuaQvS5mKJVoCvL5FvrYH7oZPjxsVHf2bKSGgcVmZt/go-ipfs-cmds/http" ) const originEnvKey = "API_ORIGIN" diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index b46f6668d..18fa354ab 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmefgzMbKZYsmHFkLqxgaTBG9ypeEjrdWRD5WXH4j1cWDL/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmTzs3Gp2rU3HuNayjBVG7qBgbaKWE8bgtwJ7faRxAe9UP/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index f37ce7030..47e5d03cc 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,8 +19,8 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" + id "gx/ipfs/QmTzs3Gp2rU3HuNayjBVG7qBgbaKWE8bgtwJ7faRxAe9UP/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" - id "gx/ipfs/QmefgzMbKZYsmHFkLqxgaTBG9ypeEjrdWRD5WXH4j1cWDL/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 640c4ed9e..32c8ac0b6 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - inet "gx/ipfs/QmNa31VPzC561NWwRsJLE7nGYZYuuD2QfpK2b1q9BK54J1/go-libp2p-net" - testutil "gx/ipfs/QmQGX417WoxKxDJeHqouMEmmH4G1RCENNSzkZYHrXy3Xb3/go-libp2p-netutil" - bhost "gx/ipfs/QmefgzMbKZYsmHFkLqxgaTBG9ypeEjrdWRD5WXH4j1cWDL/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/QmTzs3Gp2rU3HuNayjBVG7qBgbaKWE8bgtwJ7faRxAe9UP/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/QmUUNDRYXgfqdjxTg79ogkciczU5y4WY1tKMU2vEX9CRN7/go-libp2p-netutil" + inet "gx/ipfs/QmbD5yKbXahNvoMqzeuNyKQA9vAs9fUvJg2GXeWU1fVqY5/go-libp2p-net" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 4ab7218c5857e10ed76c8faafe1ad31e32b46c9e Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 7 Jul 2017 18:32:59 +0300 Subject: [PATCH 243/674] namesys/pubsub: publisher and resolver Commits: namesys: pubsub Publisher and Resolver namesys/pubsub: pacify code climate. namesys/pubsub: timeout for rendezvous namesys/pubsub: filter self in bootstrap connections namesys/pubsub: Publish to the correct topic License: MIT Signed-off-by: vyzo namesys/pubsub: unit test Commits: namesys/pubsub: test namesys/pubsub_test: pacify code climate namesys/pubsub: update test to use extant mock routing License: MIT Signed-off-by: vyzo namesys/pubsub: integrate namesys pubsub namesys: integrate pubsub resolvers namesys/pubsub_test: tweak delays - trying to make travis happy. namesys/pubsub: fix duplicate bootstraps - subscription key is topic, not ipnskey. namesys/pubsub: no warning needed on cancellation namesys/pubsub: warning for receive errors - and more informative error messages at that. namesys/pubsub_test: smaller test - make it work with seemingly low fdlimits in travis/macosx. also, more informative test failures. namesys/pubsub: add delay to let pubsub perform handshake namesys/pubsub: update gx imports namesys/pubsub_test: preconnect publisher, reduce delays - preconnects the publisher to the receivers in order to avoid bootstrap flakiness with connectivity problems in travis. reduces sleeps to 1s for flood propagation (3s seems excessive with 5 hosts). namesys/pubsub: drop named return values in resolveOnce - per review comment. namesys/pubsub: check errors namesys/pubsub: store bytes in resolver datastore namesys/pubsub: resolver Cancel - for canceling subscriptions, pre whyrusleeping's request. namesys/pubsub: fix resolution without /ipns prefix - also improve the logging a bit. namesys/pubsub: don't resolve own keys through pubsub namesys/pubsub: signal ErrResolveFailed on resolution failure namesys/pubsub: use sync datastore, resolver lock only for subs namesys/pubsub_test: coverage for Cancel License: MIT Signed-off-by: vyzo namesys/pubsub: parallelize dht and pubsub publishing Commits: namesys/pubsub: code cosmetics namesys: parallelize publishing with dht and pubsub namesys/pubsub: periodically reprovide topic rendezvous namesys/pubsub: cancelation for rendezvous goroutine namesys/pubsub: log ipns record seqno on publish License: MIT Signed-off-by: vyzo namesys/pubsub: error checking License: MIT Signed-off-by: vyzo namesys/pubsub: --enable-namesys-pubsub option and management Commits: package.json: update go-libp2p-blankhost namesys: fix stale package imports update go-testutil namesys/pubsub: reduce bootstrap provide period to 8hr namesys/pubsub: try to extract the key from id first option to enable ipns pubsub: --enable-namesys-pubsub ipfs name pubsub management subcommands corehttp/gateway_test: mockNamesys needs to implement GetResolver pacify code climate License: MIT Signed-off-by: vyzo namesys/pubsub: pubsub sharness test test/sharness: test for ipns pubsub namesys/pubsub: return boolean indicator on Cancel package.json: remove duplicate entry for go-testutil update gx deps, testutil to 1.1.12 fix jenkins failure: use tabs in t0183-namesys-pubsub t0183: use 4 spaces for tabification License: MIT Signed-off-by: vyzo namesys/pubsub: update for new command interface License: MIT Signed-off-by: vyzo namesys/pubsub: fix sharness test for broken MacOS echo echo -n "" should print -n, but hey it's a mac. License: MIT Signed-off-by: vyzo This commit was moved from ipfs/kubo@e45df729bea560b879e69a6200755be797d63c74 --- gateway/core/corehttp/gateway_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 47e5d03cc..518fa678c 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -48,6 +48,10 @@ func (m mockNamesys) PublishWithEOL(ctx context.Context, name ci.PrivKey, value return errors.New("not implemented for mockNamesys") } +func (m mockNamesys) GetResolver(subs string) (namesys.Resolver, bool) { + return nil, false +} + func newNodeWithMockNamesys(ns mockNamesys) (*core.IpfsNode, error) { c := config.Config{ Identity: config.Identity{ From 5b0640a7819c068dd47b48bb21c6ac82049e5195 Mon Sep 17 00:00:00 2001 From: keks Date: Wed, 22 Nov 2017 19:00:59 +0100 Subject: [PATCH 244/674] update go-ipfs-cmds to 0.4.11 to include @frist's uuid logging License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@8e5fbe9aa1b5464c6f3fc6a5c475ac9cb9241c45 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 1d4ae0f9f..0fdf89c6d 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -11,8 +11,8 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmQtQuaQvS5mKJVoCvL5FvrYH7oZPjxsVHf2bKSGgcVmZt/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmQtQuaQvS5mKJVoCvL5FvrYH7oZPjxsVHf2bKSGgcVmZt/go-ipfs-cmds/http" + cmds "gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/http" ) const originEnvKey = "API_ORIGIN" From fc9f8fe3e7230facb4f99f183d6cda70be96395d Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 2 Dec 2017 11:52:03 +0000 Subject: [PATCH 245/674] Update WebUI version License: MIT Signed-off-by: Henrique Dias This commit was moved from ipfs/kubo@351185382d6dfb8b1efc6e6d140a4551d267bce6 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 1f4ea2975..9a2e7cbca 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ" +const WebUIPath = "/ipfs/QmQLXHs7K98JNQdWrBB2cQLJahPhmupbDjRuH1b9ibmwVa" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -15,6 +15,7 @@ var WebUIPaths = []string{ "/ipfs/QmR9MzChjp1MdFWik7NjEjqKQMzVmBkdK3dz14A6B5Cupm", "/ipfs/QmRyWyKWmphamkMRnJVjUTzSFSAAZowYP4rnbgnfMXC9Mr", "/ipfs/QmU3o9bvfenhTKhxUakbYrLDnZU7HezAVxPM6Ehjw9Xjqy", + "/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ" } var WebUIOption = RedirectOption("webui", WebUIPath) From 269cdb911de18572ceee9f9c340840cd1bd5e7fa Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 2 Dec 2017 12:05:55 +0000 Subject: [PATCH 246/674] Add trailing comma License: MIT Signed-off-by: Henrique Dias This commit was moved from ipfs/kubo@4df6385f555218c641d2cedf86c85443008f5d39 --- gateway/core/corehttp/webui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 9a2e7cbca..1f99a3524 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -15,7 +15,7 @@ var WebUIPaths = []string{ "/ipfs/QmR9MzChjp1MdFWik7NjEjqKQMzVmBkdK3dz14A6B5Cupm", "/ipfs/QmRyWyKWmphamkMRnJVjUTzSFSAAZowYP4rnbgnfMXC9Mr", "/ipfs/QmU3o9bvfenhTKhxUakbYrLDnZU7HezAVxPM6Ehjw9Xjqy", - "/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ" + "/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ", } var WebUIOption = RedirectOption("webui", WebUIPath) From 735d8c122b8ac36c62fcc18ac25abac0b98a2a51 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sun, 26 Nov 2017 03:37:50 +0100 Subject: [PATCH 247/674] gateway: degrade most logging to debug level License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@55692ac9b631270afca30a4fc1ab9937df1cb9ce --- gateway/core/corehttp/gateway_handler.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1d29cd07f..db7e2f1e0 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -119,7 +119,6 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { errmsg = errmsg + "bad request for " + r.URL.Path } fmt.Fprint(w, errmsg) - log.Error(errmsg) // TODO(cryptix): log errors until we have a better way to expose these (counter metrics maybe) } func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request) { @@ -287,14 +286,11 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr ixnd, err := dirr.Find(ctx, "index.html") switch { case err == nil: - log.Debugf("found index.html link for %s", escapedURLPath) - dirwithoutslash := urlPath[len(urlPath)-1] != '/' goget := r.URL.Query().Get("go-get") == "1" if dirwithoutslash && !goget { // See comment above where originalUrlPath is declared. http.Redirect(w, r, originalUrlPath+"/", 302) - log.Debugf("redirect to %s", originalUrlPath+"/") return } @@ -510,7 +506,6 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } default: - log.Warningf("putHandler: unhandled resolve error %T", ev) webError(w, "could not resolve root DAG", ev, http.StatusInternalServerError) return } @@ -618,8 +613,10 @@ func webError(w http.ResponseWriter, message string, err error, defaultCode int) func webErrorWithCode(w http.ResponseWriter, message string, err error, code int) { w.WriteHeader(code) - log.Errorf("%s: %s", message, err) // TODO(cryptix): log until we have a better way to expose these (counter metrics maybe) fmt.Fprintf(w, "%s: %s\n", message, err) + if code >= 500 { + log.Warningf("server error: %s: %s", err) + } } // return a 500 error and log From 3b0fd0ac9a398f44dab66bdeade1610e60dcf96e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sun, 3 Dec 2017 21:34:29 -0800 Subject: [PATCH 248/674] gx: update go-multihash License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@dfe7ef4fcfaf340846ee16031550601b3ff625d6 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/corehttp.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 6 +++--- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 0fdf89c6d..3a95203c5 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -11,8 +11,8 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmamUWYjFeYYzFDFPTvnmGkozJigsoDWUA4zoifTRFTnwK/go-ipfs-cmds/http" + cmds "gx/ipfs/QmP9vZfc5WSjfGTXmwX2EcicMFzmZ6fXn7HTdKYat6ccmH/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmP9vZfc5WSjfGTXmwX2EcicMFzmZ6fXn7HTdKYat6ccmH/go-ipfs-cmds/http" ) const originEnvKey = "API_ORIGIN" diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 57935abdf..2686ca675 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,9 +12,9 @@ import ( core "github.com/ipfs/go-ipfs/core" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" + manet "gx/ipfs/QmSGL5Uoa6gKHgBBwQG8u1CWKUC8ZnwaZiLgFVTFBR2bxr/go-multiaddr-net" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" - manet "gx/ipfs/QmX3U3YXCQ6UYBxq2LVWF8dARS1hPUTEYLrSx654Qyxyw6/go-multiaddr-net" - ma "gx/ipfs/QmXY77cVe7rVRQXZZQRioukUM7aRW3BTcAgJe12MCtb3Ji/go-multiaddr" + ma "gx/ipfs/QmW8s4zTsUoX1Q6CeYxVKPyqSKbF7H1YDUyTostBtZ8DaG/go-multiaddr" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 18fa354ab..54fcd3e9b 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmTzs3Gp2rU3HuNayjBVG7qBgbaKWE8bgtwJ7faRxAe9UP/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/Qma23bpHwQrQyvKeBemaeJh7sAoRHggPkgnge1B9489ff5/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index db7e2f1e0..bf164f9cb 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -23,11 +23,11 @@ import ( ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" - cid "gx/ipfs/QmNp85zy9RLrQ5oQD4hPyS39ezrrXpcaa7R4Y9kxdWQLLQ/go-cid" - node "gx/ipfs/QmPN7cwmpcc4DWXb4KTB9dNAJgjuPY69h3npsMfhRrQL9c/go-ipld-format" - routing "gx/ipfs/QmPR2JzfKd9poHx9XBhzoFeBBC31ZM3W5iUPKJZWyaoZZm/go-libp2p-routing" + node "gx/ipfs/QmNwUEK7QbwSqyKBu3mMtToo8SUc6wQJ7gdZq4gGGJqfnf/go-ipld-format" + routing "gx/ipfs/QmPCGUjMRuBcPybZFpjhzpifwPP9wPRoiy5geTQKU4vqWA/go-libp2p-routing" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" multibase "gx/ipfs/QmafgXF3u3QSWErQoZ2URmQp5PFG384htoE7J338nS2H7T/go-multibase" + cid "gx/ipfs/QmeSrf6pzut73u6zLQkRFQ3ygt3k6XFT2kjdYP8Tnkwwyg/go-cid" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 518fa678c..97a2bbe64 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" - id "gx/ipfs/QmTzs3Gp2rU3HuNayjBVG7qBgbaKWE8bgtwJ7faRxAe9UP/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/Qma23bpHwQrQyvKeBemaeJh7sAoRHggPkgnge1B9489ff5/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 32c8ac0b6..3c452d5fa 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmTzs3Gp2rU3HuNayjBVG7qBgbaKWE8bgtwJ7faRxAe9UP/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/QmUUNDRYXgfqdjxTg79ogkciczU5y4WY1tKMU2vEX9CRN7/go-libp2p-netutil" - inet "gx/ipfs/QmbD5yKbXahNvoMqzeuNyKQA9vAs9fUvJg2GXeWU1fVqY5/go-libp2p-net" + inet "gx/ipfs/QmU4vCDZTPLDqSDKguWbHCiUe46mZUtmM2g2suBZ9NE8ko/go-libp2p-net" + testutil "gx/ipfs/QmZTcPxK6VqrwY94JpKZPvEqAZ6tEr1rLrpcqJbbRZbg2V/go-libp2p-netutil" + bhost "gx/ipfs/Qma23bpHwQrQyvKeBemaeJh7sAoRHggPkgnge1B9489ff5/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 475fb8e35bf10712d269872b8ebf445455ccdb62 Mon Sep 17 00:00:00 2001 From: Iaroslav Gridin Date: Tue, 29 Aug 2017 02:30:45 +0300 Subject: [PATCH 249/674] Set filename in Content-Disposition if filename=x is passed in URI query License: MIT Signed-off-by: Iaroslav Gridin This commit was moved from ipfs/kubo@7b34b7f533bb1544472b3d40a33f3a403a7a29c8 --- gateway/core/corehttp/gateway_handler.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index bf164f9cb..caef0822d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "net/http" + "net/url" "os" gopath "path" "runtime/debug" @@ -131,7 +132,6 @@ func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request) } func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { - urlPath := r.URL.Path escapedURLPath := r.URL.EscapedPath() @@ -266,7 +266,14 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } if !dir { - name := gopath.Base(urlPath) + urlFilename := r.URL.Query().Get("filename") + var name string + if urlFilename != "" { + w.Header().Set("Content-Disposition", fmt.Sprintf("inline; filename*=UTF-8''%s", url.PathEscape(urlFilename))) + name = urlFilename + } else { + name = gopath.Base(urlPath) + } i.serveFile(w, r, name, modtime, dr) return } From 004d8f0054babd52ae33f6cee9bda2ad2920f6bf Mon Sep 17 00:00:00 2001 From: keks Date: Mon, 20 Nov 2017 15:11:10 +0100 Subject: [PATCH 250/674] start adopting cmds3.0 - lots of errors! - move go-ipfs-cmds/legacy to go-ipfs/commands/legacy - update cmds,cmdkit; go test ./... ok License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@bd9576fa57a28a1eda14830ffd5bd7a9b18e83e4 --- gateway/core/corehttp/commands.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 3a95203c5..cc4be85fe 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -7,12 +7,13 @@ import ( "strconv" "strings" + oldcmds "github.com/ipfs/go-ipfs/commands" core "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmP9vZfc5WSjfGTXmwX2EcicMFzmZ6fXn7HTdKYat6ccmH/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmP9vZfc5WSjfGTXmwX2EcicMFzmZ6fXn7HTdKYat6ccmH/go-ipfs-cmds/http" + cmds "gx/ipfs/QmTwKPLyeRKuDawuy6CAn1kRj1FVoqBEM8sviAUWN7NW9K/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmTwKPLyeRKuDawuy6CAn1kRj1FVoqBEM8sviAUWN7NW9K/go-ipfs-cmds/http" ) const originEnvKey = "API_ORIGIN" @@ -29,6 +30,8 @@ or ipfs daemon --api-http-header 'Access-Control-Allow-Origin: *' ` +const APIPath = "/api/v0" + var defaultLocalhostOrigins = []string{ "http://127.0.0.1:", "https://127.0.0.1:", @@ -100,7 +103,7 @@ func patchCORSVars(c *cmdsHttp.ServerConfig, addr net.Addr) { c.SetAllowedOrigins(origins...) } -func commandsOption(cctx cmds.Context, command *cmds.Command) ServeOption { +func commandsOption(cctx oldcmds.Context, command *cmds.Command) ServeOption { return func(n *core.IpfsNode, l net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { cfg := cmdsHttp.NewServerConfig() @@ -115,16 +118,16 @@ func commandsOption(cctx cmds.Context, command *cmds.Command) ServeOption { addCORSDefaults(cfg) patchCORSVars(cfg, l.Addr()) - cmdHandler := cmdsHttp.NewHandler(cctx, command, cfg) - mux.Handle(cmdsHttp.ApiPath+"/", cmdHandler) + cmdHandler := cmdsHttp.NewHandler(&cctx, command, cfg) + mux.Handle(APIPath, cmdHandler) return mux, nil } } -func CommandsOption(cctx cmds.Context) ServeOption { +func CommandsOption(cctx oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.Root) } -func CommandsROOption(cctx cmds.Context) ServeOption { +func CommandsROOption(cctx oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.RootRO) } From 93b9968e905d79ab2df1aaa86366a25ccdcefed2 Mon Sep 17 00:00:00 2001 From: keks Date: Mon, 27 Nov 2017 17:42:41 +0100 Subject: [PATCH 251/674] check api version in corehttp - add comments, trim api path prefix - corehttp: add option to set HTTP header "Server" - daemon: use new corehttp options License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@c1d6230bc0e03f25b04f607f8d8ed9158656338c --- gateway/core/corehttp/commands.go | 47 +++++++++++ gateway/core/corehttp/option_test.go | 113 +++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 gateway/core/corehttp/option_test.go diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index cc4be85fe..c3d476531 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -1,6 +1,8 @@ package corehttp import ( + "errors" + "fmt" "net" "net/http" "os" @@ -10,12 +12,18 @@ import ( oldcmds "github.com/ipfs/go-ipfs/commands" core "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" cmds "gx/ipfs/QmTwKPLyeRKuDawuy6CAn1kRj1FVoqBEM8sviAUWN7NW9K/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmTwKPLyeRKuDawuy6CAn1kRj1FVoqBEM8sviAUWN7NW9K/go-ipfs-cmds/http" ) +var ( + errApiVersionMismatch = errors.New("api version mismatch") +) + +const apiPath = "/api/v0" const originEnvKey = "API_ORIGIN" const originEnvKeyDeprecate = `You are using the ` + originEnvKey + `ENV Variable. This functionality is deprecated, and will be removed in future versions. @@ -131,3 +139,42 @@ func CommandsOption(cctx oldcmds.Context) ServeOption { func CommandsROOption(cctx oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.RootRO) } + +// CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/go-ipfs/` +func CheckVersionOption() ServeOption { + daemonVersion := config.ApiVersion + + return ServeOption(func(n *core.IpfsNode, l net.Listener, next *http.ServeMux) (*http.ServeMux, error) { + mux := http.NewServeMux() + mux.HandleFunc(APIPath+"/", func(w http.ResponseWriter, r *http.Request) { + pth := path.SplitList(r.URL.Path[len(APIPath):]) + // backwards compatibility to previous version check + if pth[1] != "version" { + clientVersion := r.UserAgent() + // skips check if client is not go-ipfs + if clientVersion != "" && strings.Contains(clientVersion, "/go-ipfs/") && daemonVersion != clientVersion { + http.Error(w, fmt.Sprintf("%s (%s != %s)", errApiVersionMismatch, daemonVersion, clientVersion), http.StatusBadRequest) + return + } + } + + next.ServeHTTP(w, r) + }) + mux.HandleFunc("/", next.ServeHTTP) + + return mux, nil + }) +} + +// ServerNameOption returns a ServeOption that makes the http server set the Server HTTP header. +func ServerNameOption(name string) ServeOption { + return ServeOption(func(n *core.IpfsNode, l net.Listener, next *http.ServeMux) (*http.ServeMux, error) { + mux := http.NewServeMux() + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Server", name) + next.ServeHTTP(w, r) + }) + + return mux, nil + }) +} diff --git a/gateway/core/corehttp/option_test.go b/gateway/core/corehttp/option_test.go new file mode 100644 index 000000000..37c88cce4 --- /dev/null +++ b/gateway/core/corehttp/option_test.go @@ -0,0 +1,113 @@ +package corehttp + +import ( + "fmt" + "io" + "net/http" + "net/http/httptest" + "testing" + + config "github.com/ipfs/go-ipfs/repo/config" +) + +type testcasecheckversion struct { + userAgent string + uri string + shouldHandle bool + responseBody string + responseCode int +} + +func (tc testcasecheckversion) body() string { + if !tc.shouldHandle && tc.responseBody == "" { + return fmt.Sprintf("%s (%s != %s)\n", errApiVersionMismatch, config.ApiVersion, tc.userAgent) + } + + return tc.responseBody +} + +func TestCheckVersionOption(t *testing.T) { + tcs := []testcasecheckversion{ + {"/go-ipfs/0.1/", APIPath + "/test/", false, "", http.StatusBadRequest}, + {"/go-ipfs/0.1/", APIPath + "/version", true, "check!", http.StatusOK}, + {config.ApiVersion, APIPath + "/test", true, "check!", http.StatusOK}, + {"Mozilla Firefox/no go-ipfs node", APIPath + "/test", true, "check!", http.StatusOK}, + {"/go-ipfs/0.1/", "/webui", true, "check!", http.StatusOK}, + } + + for _, tc := range tcs { + t.Logf("%#v", tc) + r := httptest.NewRequest("POST", tc.uri, nil) + r.Header.Add("User-Agent", tc.userAgent) // old version, should fail + + called := false + inner := http.NewServeMux() + inner.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + called = true + if !tc.shouldHandle { + t.Error("handler was called even though version didn't match") + } else { + io.WriteString(w, "check!") + } + }) + + mux, err := CheckVersionOption()(nil, nil, inner) + if err != nil { + t.Fatal(err) + } + + w := httptest.NewRecorder() + + mux.ServeHTTP(w, r) + + if tc.shouldHandle && !called { + t.Error("handler wasn't called even though it should have") + } + + if w.Code != tc.responseCode { + t.Errorf("expected code %d but got %d", tc.responseCode, w.Code) + } + + if w.Body.String() != tc.body() { + t.Errorf("expected error message %q, got %q", tc.body(), w.Body.String()) + } + } +} + +func TestServerNameOption(t *testing.T) { + type testcase struct { + name string + } + + tcs := []testcase{ + {"go-ipfs/0.4.13"}, + {"go-ipfs/" + config.CurrentVersionNumber}, + } + + assert := func(name string, exp, got interface{}) { + if got != exp { + t.Errorf("%s: got %q, expected %q", name, got, exp) + } + } + + for _, tc := range tcs { + t.Logf("%#v", tc) + r := httptest.NewRequest("POST", "/", nil) + + inner := http.NewServeMux() + inner.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + // this block is intentionally left blank. + }) + + mux, err := ServerNameOption(tc.name)(nil, nil, inner) + if err != nil { + t.Fatal(err) + } + + w := httptest.NewRecorder() + + mux.ServeHTTP(w, r) + srvHdr := w.Header().Get("Server") + assert("Server header", tc.name, srvHdr) + } +} From 4d08130d1103e006ee1703be50c76355e2196faa Mon Sep 17 00:00:00 2001 From: keks Date: Fri, 1 Dec 2017 10:40:26 +0100 Subject: [PATCH 252/674] go test passes, sharness fails pass API path to cmds, fix options in add. License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@84101c8a2aa45a223492f0aa73a9f863f5686f93 --- gateway/core/corehttp/commands.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index c3d476531..4a545bc0a 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,15 +15,14 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmTwKPLyeRKuDawuy6CAn1kRj1FVoqBEM8sviAUWN7NW9K/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmTwKPLyeRKuDawuy6CAn1kRj1FVoqBEM8sviAUWN7NW9K/go-ipfs-cmds/http" + cmds "gx/ipfs/QmYopJAcV7R9SbxiPBCvqhnt8EusQpWPHewoZakCMt8hps/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmYopJAcV7R9SbxiPBCvqhnt8EusQpWPHewoZakCMt8hps/go-ipfs-cmds/http" ) var ( errApiVersionMismatch = errors.New("api version mismatch") ) -const apiPath = "/api/v0" const originEnvKey = "API_ORIGIN" const originEnvKeyDeprecate = `You are using the ` + originEnvKey + `ENV Variable. This functionality is deprecated, and will be removed in future versions. @@ -116,6 +115,7 @@ func commandsOption(cctx oldcmds.Context, command *cmds.Command) ServeOption { cfg := cmdsHttp.NewServerConfig() cfg.SetAllowedMethods("GET", "POST", "PUT") + cfg.APIPath = APIPath rcfg, err := n.Repo.Config() if err != nil { return nil, err @@ -127,7 +127,7 @@ func commandsOption(cctx oldcmds.Context, command *cmds.Command) ServeOption { patchCORSVars(cfg, l.Addr()) cmdHandler := cmdsHttp.NewHandler(&cctx, command, cfg) - mux.Handle(APIPath, cmdHandler) + mux.Handle(APIPath+"/", cmdHandler) return mux, nil } } @@ -146,21 +146,22 @@ func CheckVersionOption() ServeOption { return ServeOption(func(n *core.IpfsNode, l net.Listener, next *http.ServeMux) (*http.ServeMux, error) { mux := http.NewServeMux() - mux.HandleFunc(APIPath+"/", func(w http.ResponseWriter, r *http.Request) { - pth := path.SplitList(r.URL.Path[len(APIPath):]) - // backwards compatibility to previous version check - if pth[1] != "version" { - clientVersion := r.UserAgent() - // skips check if client is not go-ipfs - if clientVersion != "" && strings.Contains(clientVersion, "/go-ipfs/") && daemonVersion != clientVersion { - http.Error(w, fmt.Sprintf("%s (%s != %s)", errApiVersionMismatch, daemonVersion, clientVersion), http.StatusBadRequest) - return + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + if strings.HasPrefix(r.URL.Path, APIPath) { + pth := path.SplitList(r.URL.Path[len(APIPath):]) + // backwards compatibility to previous version check + if pth[1] != "version" { + clientVersion := r.UserAgent() + // skips check if client is not go-ipfs + if clientVersion != "" && strings.Contains(clientVersion, "/go-ipfs/") && daemonVersion != clientVersion { + http.Error(w, fmt.Sprintf("%s (%s != %s)", errApiVersionMismatch, daemonVersion, clientVersion), http.StatusBadRequest) + return + } } } next.ServeHTTP(w, r) }) - mux.HandleFunc("/", next.ServeHTTP) return mux, nil }) From 04d2d0f4f11e5806b19ae5c165d4112fe7385e54 Mon Sep 17 00:00:00 2001 From: keks Date: Sat, 16 Dec 2017 15:54:57 +0100 Subject: [PATCH 253/674] add TODO License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@e8ad0944489166614b380f1368e7467704143bd0 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 4a545bc0a..ed8f18b98 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmYopJAcV7R9SbxiPBCvqhnt8EusQpWPHewoZakCMt8hps/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmYopJAcV7R9SbxiPBCvqhnt8EusQpWPHewoZakCMt8hps/go-ipfs-cmds/http" + cmds "gx/ipfs/QmXPgUkyFLMN3c79WrGM2VbjWynSPnmaHjF2AviBVQE2i7/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmXPgUkyFLMN3c79WrGM2VbjWynSPnmaHjF2AviBVQE2i7/go-ipfs-cmds/http" ) var ( From 048fca67e6f882d9f874093ff15eca3a51ec75e1 Mon Sep 17 00:00:00 2001 From: keks Date: Mon, 18 Dec 2017 15:38:55 +0100 Subject: [PATCH 254/674] remove dead code, update TODO License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@7d57def06e11a88c76e6731c8518db146b25d397 --- gateway/core/corehttp/commands.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index ed8f18b98..e520904f0 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -166,16 +166,3 @@ func CheckVersionOption() ServeOption { return mux, nil }) } - -// ServerNameOption returns a ServeOption that makes the http server set the Server HTTP header. -func ServerNameOption(name string) ServeOption { - return ServeOption(func(n *core.IpfsNode, l net.Listener, next *http.ServeMux) (*http.ServeMux, error) { - mux := http.NewServeMux() - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Server", name) - next.ServeHTTP(w, r) - }) - - return mux, nil - }) -} From e88da36ae4fbf9669311dc6ea3dd9a473e201589 Mon Sep 17 00:00:00 2001 From: keks Date: Mon, 18 Dec 2017 16:51:01 +0100 Subject: [PATCH 255/674] update dependencies and update TODO broken sharness test t0110 has been fixed in master License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@fbc36b8962aa2bea08e767f0175f1632a8cc35de --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index e520904f0..85b1f8091 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmXPgUkyFLMN3c79WrGM2VbjWynSPnmaHjF2AviBVQE2i7/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmXPgUkyFLMN3c79WrGM2VbjWynSPnmaHjF2AviBVQE2i7/go-ipfs-cmds/http" + cmds "gx/ipfs/QmUthF74m2X24Y1CFdq6wyu6QSm9Q6JEVPZ1c5XJtccW2y/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmUthF74m2X24Y1CFdq6wyu6QSm9Q6JEVPZ1c5XJtccW2y/go-ipfs-cmds/http" ) var ( From 8fd1f43c6e5ce9506c020c4a52c4415993e864c3 Mon Sep 17 00:00:00 2001 From: keks Date: Mon, 18 Dec 2017 17:03:03 +0100 Subject: [PATCH 256/674] remove test for deleted fuction License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@8294f0a34597858d987b85bcf4e9e64de7268b8d --- gateway/core/corehttp/option_test.go | 38 ---------------------------- 1 file changed, 38 deletions(-) diff --git a/gateway/core/corehttp/option_test.go b/gateway/core/corehttp/option_test.go index 37c88cce4..1e80e5d98 100644 --- a/gateway/core/corehttp/option_test.go +++ b/gateway/core/corehttp/option_test.go @@ -73,41 +73,3 @@ func TestCheckVersionOption(t *testing.T) { } } } - -func TestServerNameOption(t *testing.T) { - type testcase struct { - name string - } - - tcs := []testcase{ - {"go-ipfs/0.4.13"}, - {"go-ipfs/" + config.CurrentVersionNumber}, - } - - assert := func(name string, exp, got interface{}) { - if got != exp { - t.Errorf("%s: got %q, expected %q", name, got, exp) - } - } - - for _, tc := range tcs { - t.Logf("%#v", tc) - r := httptest.NewRequest("POST", "/", nil) - - inner := http.NewServeMux() - inner.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - // this block is intentionally left blank. - }) - - mux, err := ServerNameOption(tc.name)(nil, nil, inner) - if err != nil { - t.Fatal(err) - } - - w := httptest.NewRecorder() - - mux.ServeHTTP(w, r) - srvHdr := w.Header().Get("Server") - assert("Server header", tc.name, srvHdr) - } -} From 677f0fbb4e487c7bb9d8641ccb9480a551345dc2 Mon Sep 17 00:00:00 2001 From: keks Date: Mon, 18 Dec 2017 17:29:24 +0100 Subject: [PATCH 257/674] fix ServerNameOption License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@52bc29823066fccf3c05ed72e9c01d5757d75af9 --- gateway/core/corehttp/commands.go | 10 ++++++---- gateway/core/corehttp/option_test.go | 16 ++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 85b1f8091..f2c85e743 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -144,11 +144,13 @@ func CommandsROOption(cctx oldcmds.Context) ServeOption { func CheckVersionOption() ServeOption { daemonVersion := config.ApiVersion - return ServeOption(func(n *core.IpfsNode, l net.Listener, next *http.ServeMux) (*http.ServeMux, error) { + return ServeOption(func(n *core.IpfsNode, l net.Listener, parent *http.ServeMux) (*http.ServeMux, error) { mux := http.NewServeMux() - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + parent.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { if strings.HasPrefix(r.URL.Path, APIPath) { - pth := path.SplitList(r.URL.Path[len(APIPath):]) + cmdqry := r.URL.Path[len(APIPath):] + pth := path.SplitList(cmdqry) + // backwards compatibility to previous version check if pth[1] != "version" { clientVersion := r.UserAgent() @@ -160,7 +162,7 @@ func CheckVersionOption() ServeOption { } } - next.ServeHTTP(w, r) + mux.ServeHTTP(w, r) }) return mux, nil diff --git a/gateway/core/corehttp/option_test.go b/gateway/core/corehttp/option_test.go index 1e80e5d98..b32e2afcf 100644 --- a/gateway/core/corehttp/option_test.go +++ b/gateway/core/corehttp/option_test.go @@ -41,8 +41,13 @@ func TestCheckVersionOption(t *testing.T) { r.Header.Add("User-Agent", tc.userAgent) // old version, should fail called := false - inner := http.NewServeMux() - inner.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + root := http.NewServeMux() + mux, err := CheckVersionOption()(nil, nil, root) + if err != nil { + t.Fatal(err) + } + + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { called = true if !tc.shouldHandle { t.Error("handler was called even though version didn't match") @@ -51,14 +56,9 @@ func TestCheckVersionOption(t *testing.T) { } }) - mux, err := CheckVersionOption()(nil, nil, inner) - if err != nil { - t.Fatal(err) - } - w := httptest.NewRecorder() - mux.ServeHTTP(w, r) + root.ServeHTTP(w, r) if tc.shouldHandle && !called { t.Error("handler wasn't called even though it should have") From 6c778887dea1987873214cf0b099e7411e63ccbd Mon Sep 17 00:00:00 2001 From: keks Date: Wed, 20 Dec 2017 11:11:48 +0100 Subject: [PATCH 258/674] update go-ipfs-cmds License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@94266bf2e4613f57229e9de1a7e358cab92155de --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index f2c85e743..fee78525d 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmUthF74m2X24Y1CFdq6wyu6QSm9Q6JEVPZ1c5XJtccW2y/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmUthF74m2X24Y1CFdq6wyu6QSm9Q6JEVPZ1c5XJtccW2y/go-ipfs-cmds/http" + cmds "gx/ipfs/QmULd2tG5e3Hu6fdN1teSsXQFxzWmVWDmdMNMXutQnCbz9/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmULd2tG5e3Hu6fdN1teSsXQFxzWmVWDmdMNMXutQnCbz9/go-ipfs-cmds/http" ) var ( From 3246cc35318b6ba327a802100b651418b2105a71 Mon Sep 17 00:00:00 2001 From: keks Date: Wed, 20 Dec 2017 11:24:30 +0100 Subject: [PATCH 259/674] update go-ipfs-cmds License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@b23c3295e62fb831f355f21255c02b3f7a841a2c --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index fee78525d..dbd30e7c1 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmULd2tG5e3Hu6fdN1teSsXQFxzWmVWDmdMNMXutQnCbz9/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmULd2tG5e3Hu6fdN1teSsXQFxzWmVWDmdMNMXutQnCbz9/go-ipfs-cmds/http" + cmds "gx/ipfs/QmYEkjf6AXPMZgqoNUfDa7AYT6wPyNYnXnV4iPusGtusUt/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmYEkjf6AXPMZgqoNUfDa7AYT6wPyNYnXnV4iPusGtusUt/go-ipfs-cmds/http" ) var ( From bb3cd5ff36840af8935ae608db3374fdda579291 Mon Sep 17 00:00:00 2001 From: keks Date: Wed, 20 Dec 2017 11:36:41 +0100 Subject: [PATCH 260/674] update go-ipfs-cmds yet again License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@7b1963906bb364417ada02be022314ae392af846 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index dbd30e7c1..1812a92ae 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmYEkjf6AXPMZgqoNUfDa7AYT6wPyNYnXnV4iPusGtusUt/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmYEkjf6AXPMZgqoNUfDa7AYT6wPyNYnXnV4iPusGtusUt/go-ipfs-cmds/http" + cmds "gx/ipfs/QmUjA7onJjYmZ2TivD83MeCfXf5o1U4ByVJWPjRru5NA4t/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmUjA7onJjYmZ2TivD83MeCfXf5o1U4ByVJWPjRru5NA4t/go-ipfs-cmds/http" ) var ( From ccfe285acc4340745c8eeb17d845e84cd659aa36 Mon Sep 17 00:00:00 2001 From: keks Date: Wed, 20 Dec 2017 13:24:14 +0100 Subject: [PATCH 261/674] update go-ipfs-cmds License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@1cc7e2a28eb99b7e167e6d29e0b426f7128654a7 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 1812a92ae..cf49cc56f 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmUjA7onJjYmZ2TivD83MeCfXf5o1U4ByVJWPjRru5NA4t/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmUjA7onJjYmZ2TivD83MeCfXf5o1U4ByVJWPjRru5NA4t/go-ipfs-cmds/http" + cmds "gx/ipfs/QmUkTTz5YDkkJWFYfEUpgsR1cvY4KjBzo5VXwwB7UVCn1t/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmUkTTz5YDkkJWFYfEUpgsR1cvY4KjBzo5VXwwB7UVCn1t/go-ipfs-cmds/http" ) var ( From 25c7c76edeb7dd6fd7fb68f44c6ed2b86e9bb5a1 Mon Sep 17 00:00:00 2001 From: keks Date: Wed, 20 Dec 2017 13:37:32 +0100 Subject: [PATCH 262/674] update go-ipfs-cmds License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@091eeee2433d8f7b425a0d24addaa31d8f9303eb --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index cf49cc56f..09b6cdf66 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmUkTTz5YDkkJWFYfEUpgsR1cvY4KjBzo5VXwwB7UVCn1t/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmUkTTz5YDkkJWFYfEUpgsR1cvY4KjBzo5VXwwB7UVCn1t/go-ipfs-cmds/http" + cmds "gx/ipfs/QmVs8An1faiQrNXtY8e51o5ssnrQs3YYBUfPbCMo34onJr/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmVs8An1faiQrNXtY8e51o5ssnrQs3YYBUfPbCMo34onJr/go-ipfs-cmds/http" ) var ( From 8b85478035892cb749852b4b4f7455b6ee469c6b Mon Sep 17 00:00:00 2001 From: keks Date: Wed, 20 Dec 2017 17:41:00 +0100 Subject: [PATCH 263/674] use *oldcmds.Context consistently instead of non-ptr License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@aec44bc430542d4f7a2cee906ad9da3e17722529 --- gateway/core/corehttp/commands.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 09b6cdf66..9c4dcd176 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -110,7 +110,7 @@ func patchCORSVars(c *cmdsHttp.ServerConfig, addr net.Addr) { c.SetAllowedOrigins(origins...) } -func commandsOption(cctx oldcmds.Context, command *cmds.Command) ServeOption { +func commandsOption(cctx *oldcmds.Context, command *cmds.Command) ServeOption { return func(n *core.IpfsNode, l net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { cfg := cmdsHttp.NewServerConfig() @@ -132,11 +132,11 @@ func commandsOption(cctx oldcmds.Context, command *cmds.Command) ServeOption { } } -func CommandsOption(cctx oldcmds.Context) ServeOption { +func CommandsOption(cctx *oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.Root) } -func CommandsROOption(cctx oldcmds.Context) ServeOption { +func CommandsROOption(cctx *oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.RootRO) } From bca2ee088e4718ab88a89976c607f2b413d0385e Mon Sep 17 00:00:00 2001 From: keks Date: Wed, 20 Dec 2017 18:46:34 +0100 Subject: [PATCH 264/674] Revert "use *oldcmds.Context consistently instead of non-ptr" This reverts commit 852adb1c4a42a254286ac26b3bae7ea3a7bb69df. License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@d93c0b6a4b75fa886e2fd6c0ec587d04be0a20c2 --- gateway/core/corehttp/commands.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 9c4dcd176..09b6cdf66 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -110,7 +110,7 @@ func patchCORSVars(c *cmdsHttp.ServerConfig, addr net.Addr) { c.SetAllowedOrigins(origins...) } -func commandsOption(cctx *oldcmds.Context, command *cmds.Command) ServeOption { +func commandsOption(cctx oldcmds.Context, command *cmds.Command) ServeOption { return func(n *core.IpfsNode, l net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { cfg := cmdsHttp.NewServerConfig() @@ -132,11 +132,11 @@ func commandsOption(cctx *oldcmds.Context, command *cmds.Command) ServeOption { } } -func CommandsOption(cctx *oldcmds.Context) ServeOption { +func CommandsOption(cctx oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.Root) } -func CommandsROOption(cctx *oldcmds.Context) ServeOption { +func CommandsROOption(cctx oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.RootRO) } From 8233065df7456d9947d808d4ea87cf5e5505e7fd Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sat, 6 Jan 2018 14:28:16 -0800 Subject: [PATCH 265/674] some fixes for latest from go-ipfs-cmds License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@267c19ab9ddb3c8fd495c5def756ce455510b778 --- gateway/core/corehttp/commands.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 09b6cdf66..8c245ca8e 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -73,6 +73,7 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { } c.Headers = nc.API.HTTPHeaders + c.Headers["Server"] = []string{"go-ipfs/" + config.CurrentVersionNumber} } func addCORSDefaults(c *cmdsHttp.ServerConfig) { From ede875c235d086ee2f65a0ae6ce5c315704f377a Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 8 Jan 2018 18:37:46 -0800 Subject: [PATCH 266/674] update to final cmds1.0 License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@bf804cca669f40d8a28fade4e11949a5eaf533ae --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 8c245ca8e..b299a437d 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmVs8An1faiQrNXtY8e51o5ssnrQs3YYBUfPbCMo34onJr/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmVs8An1faiQrNXtY8e51o5ssnrQs3YYBUfPbCMo34onJr/go-ipfs-cmds/http" + cmds "gx/ipfs/QmfVXM8xWBJZZMC3mJkv64dkWUeoqGKTcKDSMtiJ6AdZXM/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmfVXM8xWBJZZMC3mJkv64dkWUeoqGKTcKDSMtiJ6AdZXM/go-ipfs-cmds/http" ) var ( From 5c7ef741ed52cff939fc4f7c0930d70ce50a562f Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 11 Jan 2018 14:01:48 -0800 Subject: [PATCH 267/674] golint: fix variable name License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@9080a588d81f0759f225f65d71efdfb6178e1d41 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/option_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index b299a437d..5ab953ecb 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -20,7 +20,7 @@ import ( ) var ( - errApiVersionMismatch = errors.New("api version mismatch") + errAPIVersionMismatch = errors.New("api version mismatch") ) const originEnvKey = "API_ORIGIN" @@ -157,7 +157,7 @@ func CheckVersionOption() ServeOption { clientVersion := r.UserAgent() // skips check if client is not go-ipfs if clientVersion != "" && strings.Contains(clientVersion, "/go-ipfs/") && daemonVersion != clientVersion { - http.Error(w, fmt.Sprintf("%s (%s != %s)", errApiVersionMismatch, daemonVersion, clientVersion), http.StatusBadRequest) + http.Error(w, fmt.Sprintf("%s (%s != %s)", errAPIVersionMismatch, daemonVersion, clientVersion), http.StatusBadRequest) return } } diff --git a/gateway/core/corehttp/option_test.go b/gateway/core/corehttp/option_test.go index b32e2afcf..c600a0603 100644 --- a/gateway/core/corehttp/option_test.go +++ b/gateway/core/corehttp/option_test.go @@ -20,7 +20,7 @@ type testcasecheckversion struct { func (tc testcasecheckversion) body() string { if !tc.shouldHandle && tc.responseBody == "" { - return fmt.Sprintf("%s (%s != %s)\n", errApiVersionMismatch, config.ApiVersion, tc.userAgent) + return fmt.Sprintf("%s (%s != %s)\n", errAPIVersionMismatch, config.ApiVersion, tc.userAgent) } return tc.responseBody From b387f8127a2ddf63d56a9c142331d3570264ed20 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 11 Jan 2018 14:02:13 -0800 Subject: [PATCH 268/674] golint: documentation fixes License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@652ac620b149aae0d7669f96b76a0a84413c1de8 --- gateway/core/corehttp/commands.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 5ab953ecb..b9d2efa88 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -37,6 +37,7 @@ or ipfs daemon --api-http-header 'Access-Control-Allow-Origin: *' ` +// APIPath is the path at which the API is mounted. const APIPath = "/api/v0" var defaultLocalhostOrigins = []string{ From 99953fde8e411e88982a826b76168828641553f5 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 11 Jan 2018 15:35:24 -0800 Subject: [PATCH 269/674] update go-ipfs-cmds Fix a nil pointer exception when no timeout is set and an HTTP request fails. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@0bdc2574ce27e0cce0c1c3cad766f87645aa0740 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index b9d2efa88..f918fd084 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmfVXM8xWBJZZMC3mJkv64dkWUeoqGKTcKDSMtiJ6AdZXM/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmfVXM8xWBJZZMC3mJkv64dkWUeoqGKTcKDSMtiJ6AdZXM/go-ipfs-cmds/http" + cmds "gx/ipfs/QmeQHu2YxKwgyThinyW7S3GtebRToQcxQKqxNQaRBBGzuG/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmeQHu2YxKwgyThinyW7S3GtebRToQcxQKqxNQaRBBGzuG/go-ipfs-cmds/http" ) var ( From 7293c5a6ada6fefd070e482e35fe27ed7ce12959 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Thu, 18 Jan 2018 21:52:48 -0800 Subject: [PATCH 270/674] update go-ipfs-cmds, fix context closing issue License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@176d15656d95edf7d60e7944cdc32349a95a1263 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index f918fd084..b25a96b33 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmeQHu2YxKwgyThinyW7S3GtebRToQcxQKqxNQaRBBGzuG/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmeQHu2YxKwgyThinyW7S3GtebRToQcxQKqxNQaRBBGzuG/go-ipfs-cmds/http" + cmds "gx/ipfs/QmUEB5nT4LG3TkUd5mkHrfRESUSgaUD4r7jSAYvvPeuWT9/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmUEB5nT4LG3TkUd5mkHrfRESUSgaUD4r7jSAYvvPeuWT9/go-ipfs-cmds/http" ) var ( From d4a9289ffcb005bcc3856cf6a1bf2d092afa5a5c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 23 Jan 2018 20:04:45 -0800 Subject: [PATCH 271/674] fix code-climate issues License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@31bb782e77bba47c04f65910a280d005e409e96d --- gateway/core/corehttp/commands.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index b25a96b33..60be1b1f7 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -134,10 +134,14 @@ func commandsOption(cctx oldcmds.Context, command *cmds.Command) ServeOption { } } +// CommandsOption constructs a ServerOption for hooking the commands into the +// HTTP server. func CommandsOption(cctx oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.Root) } +// CommandsOption constructs a ServerOption for hooking the read-only commands +// into the HTTP server. func CommandsROOption(cctx oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.RootRO) } From c95378cb7ba33c6140d8586c94aea2c844b840e3 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 23 Jan 2018 20:27:15 -0800 Subject: [PATCH 272/674] fix doc comment on CommandsROOption License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@418bb65d9db9fa26482344be5d4faa03b9a4c29a --- gateway/core/corehttp/commands.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 60be1b1f7..96cc28e9f 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -140,7 +140,7 @@ func CommandsOption(cctx oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.Root) } -// CommandsOption constructs a ServerOption for hooking the read-only commands +// CommandsROOption constructs a ServerOption for hooking the read-only commands // into the HTTP server. func CommandsROOption(cctx oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.RootRO) From 79daee362bf90316d12d2d54e39b8eda505bfb24 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 23 Jan 2018 23:36:47 -0800 Subject: [PATCH 273/674] fix a race and a potential race in http options License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@20a044e38305fb6000c20be74a438c05a710e159 --- gateway/core/corehttp/commands.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 96cc28e9f..e1d4bfd3b 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -73,7 +73,13 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { } } - c.Headers = nc.API.HTTPHeaders + c.Headers = make(map[string][]string, len(nc.API.HTTPHeaders)) + + // Copy these because the config is shared and this function is called + // in multiple places concurrently. Updating these in-place *is* racy. + for h, v := range nc.API.HTTPHeaders { + c.Headers[h] = v + } c.Headers["Server"] = []string{"go-ipfs/" + config.CurrentVersionNumber} } @@ -101,15 +107,16 @@ func patchCORSVars(c *cmdsHttp.ServerConfig, addr net.Addr) { } // we're listening on tcp/udp with ports. ("udp!?" you say? yeah... it happens...) - origins := c.AllowedOrigins() - for i, o := range origins { + oldOrigins := c.AllowedOrigins() + newOrigins := make([]string, len(oldOrigins)) + for i, o := range oldOrigins { // TODO: allow replacing . tricky, ip4 and ip6 and hostnames... if port != "" { o = strings.Replace(o, "", port, -1) } - origins[i] = o + newOrigins[i] = o } - c.SetAllowedOrigins(origins...) + c.SetAllowedOrigins(newOrigins...) } func commandsOption(cctx oldcmds.Context, command *cmds.Command) ServeOption { From 048028db6abdfdb9aa9f8cbdf6c5a84b231e24cc Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 23 Jan 2018 23:36:51 -0800 Subject: [PATCH 274/674] don't set origins twice ... License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@a784589d2aa9a57e22903c7c0850c0d2436928a5 --- gateway/core/corehttp/commands.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index e1d4bfd3b..9dfdfe70a 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -51,9 +51,6 @@ func addCORSFromEnv(c *cmdsHttp.ServerConfig) { origin := os.Getenv(originEnvKey) if origin != "" { log.Warning(originEnvKeyDeprecate) - if len(c.AllowedOrigins()) == 0 { - c.SetAllowedOrigins([]string{origin}...) - } c.AppendAllowedOrigins(origin) } } From 926635137e326bfeb9c603913330090b6e8b8178 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 24 Jan 2018 15:55:28 -0800 Subject: [PATCH 275/674] gx: mass update License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@fe8846fcd75bb576f2302973cb4110f73450b937 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/corehttp.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 8 ++++---- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 9dfdfe70a..108792cc7 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmUEB5nT4LG3TkUd5mkHrfRESUSgaUD4r7jSAYvvPeuWT9/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmUEB5nT4LG3TkUd5mkHrfRESUSgaUD4r7jSAYvvPeuWT9/go-ipfs-cmds/http" + cmds "gx/ipfs/Qmc5paX4ECBARnAKkcAmUYHBGor228Tkfxeya3Nu2KRL46/go-ipfs-cmds" + cmdsHttp "gx/ipfs/Qmc5paX4ECBARnAKkcAmUYHBGor228Tkfxeya3Nu2KRL46/go-ipfs-cmds/http" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 2686ca675..dd5ea2a7b 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -11,10 +11,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + manet "gx/ipfs/QmRK2LxanhK2gZq6k6R7vk5ZoYZk8ULSSTB7FzDsMUX6CB/go-multiaddr-net" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" - manet "gx/ipfs/QmSGL5Uoa6gKHgBBwQG8u1CWKUC8ZnwaZiLgFVTFBR2bxr/go-multiaddr-net" logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" - ma "gx/ipfs/QmW8s4zTsUoX1Q6CeYxVKPyqSKbF7H1YDUyTostBtZ8DaG/go-multiaddr" + ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 54fcd3e9b..14d3be7ff 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/Qma23bpHwQrQyvKeBemaeJh7sAoRHggPkgnge1B9489ff5/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmNRN4eZGmY89CRC4T5PC4xDYRx6GkDKEfRnvrT65fVeio/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index bf164f9cb..f4f99cfeb 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -23,11 +23,11 @@ import ( ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" - node "gx/ipfs/QmNwUEK7QbwSqyKBu3mMtToo8SUc6wQJ7gdZq4gGGJqfnf/go-ipld-format" - routing "gx/ipfs/QmPCGUjMRuBcPybZFpjhzpifwPP9wPRoiy5geTQKU4vqWA/go-libp2p-routing" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - multibase "gx/ipfs/QmafgXF3u3QSWErQoZ2URmQp5PFG384htoE7J338nS2H7T/go-multibase" - cid "gx/ipfs/QmeSrf6pzut73u6zLQkRFQ3ygt3k6XFT2kjdYP8Tnkwwyg/go-cid" + routing "gx/ipfs/QmRijoA6zGS98ELTDbGsLWPZbVotYsGbjp3RbXcKCYBeon/go-libp2p-routing" + cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid" + node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" + multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 97a2bbe64..32c03a886 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" - id "gx/ipfs/Qma23bpHwQrQyvKeBemaeJh7sAoRHggPkgnge1B9489ff5/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmNRN4eZGmY89CRC4T5PC4xDYRx6GkDKEfRnvrT65fVeio/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 3c452d5fa..4401b460c 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - inet "gx/ipfs/QmU4vCDZTPLDqSDKguWbHCiUe46mZUtmM2g2suBZ9NE8ko/go-libp2p-net" - testutil "gx/ipfs/QmZTcPxK6VqrwY94JpKZPvEqAZ6tEr1rLrpcqJbbRZbg2V/go-libp2p-netutil" - bhost "gx/ipfs/Qma23bpHwQrQyvKeBemaeJh7sAoRHggPkgnge1B9489ff5/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/QmNRN4eZGmY89CRC4T5PC4xDYRx6GkDKEfRnvrT65fVeio/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmQm7WmgYCa4RSz76tKEYpRjApjnRw8ZTUVQC15b8JM4a2/go-libp2p-net" + testutil "gx/ipfs/QmV1axkk86DDkYwS269AvPy9eV5h7mUyHveJkSVHPjrQtY/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 9fa584c4e1b777c0d06755d0696008c600bb306e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 25 Jan 2018 14:32:40 -0800 Subject: [PATCH 276/674] fix tests that use invalid peer IDs Our code now better validates peer IDs. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@8899e986703ad4f597c637564e2d59d3c2bb8645 --- gateway/core/corehttp/gateway_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 32c03a886..6b396812e 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -55,7 +55,7 @@ func (m mockNamesys) GetResolver(subs string) (namesys.Resolver, bool) { func newNodeWithMockNamesys(ns mockNamesys) (*core.IpfsNode, error) { c := config.Config{ Identity: config.Identity{ - PeerID: "Qmfoo", // required by offline node + PeerID: "QmTFauExutTsy4XP6JbMFcw2Wa9645HJt2bTqL6qYDCKfe", // required by offline node }, } r := &repo.Mock{ From 4dc49feb97ffa844b65a9633c570afe9e3245a6e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 25 Jan 2018 12:21:51 -0800 Subject: [PATCH 277/674] merkledag: switch to new dag interface Also: * Update the blockstore/blockservice methods to match. * Construct a new temporary offline dag instead of having a GetOfflineLinkService method. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@d154b4a990d14126227b68d21274191046a186b5 --- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 16 +++++++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index f4f99cfeb..1dbc8f4f2 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -474,7 +474,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } - nnode, err := e.Finalize(i.node.DAG) + nnode, err := e.Finalize(ctx, i.node.DAG) if err != nil { webError(w, "putHandler: could not get node", err, http.StatusInternalServerError) return @@ -498,11 +498,11 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { // object set-data case pbnd.SetData(pbnewnode.Data()) - newcid, err = i.node.DAG.Add(pbnd) + newcid = pbnd.Cid() + err = i.node.DAG.Add(ctx, pbnd) if err != nil { nnk := newnode.Cid() - rk := pbnd.Cid() - webError(w, fmt.Sprintf("putHandler: Could not add newnode(%q) to root(%q)", nnk.String(), rk.String()), err, http.StatusInternalServerError) + webError(w, fmt.Sprintf("putHandler: Could not add newnode(%q) to root(%q)", nnk.String(), newcid.String()), err, http.StatusInternalServerError) return } default: @@ -561,7 +561,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { var newnode *dag.ProtoNode = pbnd for j := len(pathNodes) - 2; j >= 0; j-- { - if _, err := i.node.DAG.Add(newnode); err != nil { + if err := i.node.DAG.Add(ctx, newnode); err != nil { webError(w, "Could not add node", err, http.StatusInternalServerError) return } @@ -579,7 +579,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { } } - if _, err := i.node.DAG.Add(newnode); err != nil { + if err := i.node.DAG.Add(ctx, newnode); err != nil { webError(w, "Could not add root node", err, http.StatusInternalServerError) return } diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 6b396812e..ca03dcca5 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -178,6 +178,9 @@ func TestGatewayGet(t *testing.T) { } func TestIPNSHostnameRedirect(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + ns := mockNamesys{} ts, n := newTestServerAndNode(t, ns) t.Logf("test server url: %s", ts.URL) @@ -199,12 +202,12 @@ func TestIPNSHostnameRedirect(t *testing.T) { t.Fatal(err) } - _, err = n.DAG.Add(dagn2) + err = n.DAG.Add(ctx, dagn2) if err != nil { t.Fatal(err) } - _, err = n.DAG.Add(dagn1) + err = n.DAG.Add(ctx, dagn1) if err != nil { t.Fatal(err) } @@ -262,6 +265,9 @@ func TestIPNSHostnameRedirect(t *testing.T) { } func TestIPNSHostnameBacklinks(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + ns := mockNamesys{} ts, n := newTestServerAndNode(t, ns) t.Logf("test server url: %s", ts.URL) @@ -286,15 +292,15 @@ func TestIPNSHostnameBacklinks(t *testing.T) { t.Fatal(err) } - _, err = n.DAG.Add(dagn3) + err = n.DAG.Add(ctx, dagn3) if err != nil { t.Fatal(err) } - _, err = n.DAG.Add(dagn2) + err = n.DAG.Add(ctx, dagn2) if err != nil { t.Fatal(err) } - _, err = n.DAG.Add(dagn1) + err = n.DAG.Add(ctx, dagn1) if err != nil { t.Fatal(err) } From c9f254f6b29d7f3415b0036a4c00488168b5647b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 27 Jan 2018 18:03:59 -0800 Subject: [PATCH 278/674] update go-lib2p-loggables fixes a UUID bug I introduced (UUIDs were always an error value) License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@5acbecc26b53cddbe74484b2fdf4f55212fa9687 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 108792cc7..e555970df 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/Qmc5paX4ECBARnAKkcAmUYHBGor228Tkfxeya3Nu2KRL46/go-ipfs-cmds" - cmdsHttp "gx/ipfs/Qmc5paX4ECBARnAKkcAmUYHBGor228Tkfxeya3Nu2KRL46/go-ipfs-cmds/http" + cmds "gx/ipfs/QmPq2D7Yoyev7yeMuMnkEYBqmQuUu5kb91UXPPoiik1Xyp/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmPq2D7Yoyev7yeMuMnkEYBqmQuUu5kb91UXPPoiik1Xyp/go-ipfs-cmds/http" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 14d3be7ff..ecd5876bd 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmNRN4eZGmY89CRC4T5PC4xDYRx6GkDKEfRnvrT65fVeio/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmPd5qhppUqewTQMfStvNNCFtcxiWGsnE6Vs3va6788gsX/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index ca03dcca5..f03219264 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" - id "gx/ipfs/QmNRN4eZGmY89CRC4T5PC4xDYRx6GkDKEfRnvrT65fVeio/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmPd5qhppUqewTQMfStvNNCFtcxiWGsnE6Vs3va6788gsX/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 4401b460c..1c04ecaf8 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmNRN4eZGmY89CRC4T5PC4xDYRx6GkDKEfRnvrT65fVeio/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/QmPd5qhppUqewTQMfStvNNCFtcxiWGsnE6Vs3va6788gsX/go-libp2p/p2p/host/basic" inet "gx/ipfs/QmQm7WmgYCa4RSz76tKEYpRjApjnRw8ZTUVQC15b8JM4a2/go-libp2p-net" - testutil "gx/ipfs/QmV1axkk86DDkYwS269AvPy9eV5h7mUyHveJkSVHPjrQtY/go-libp2p-netutil" + testutil "gx/ipfs/QmWUugnJBbcuin8qdfiCYKAsNkG8NeDLhzoBqRaqXhAHd4/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From a2bc6aeb49266bdddefa6ce67be6f36d116c0ad2 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 29 Jan 2018 11:55:34 -0800 Subject: [PATCH 279/674] rename import of go-ipld-format from node/format to ipld License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@f9d935b9841ec061e8e10fb9c3aac5b7917720cd --- gateway/core/corehttp/gateway_handler.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1dbc8f4f2..aedcac227 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -26,7 +26,7 @@ import ( humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" routing "gx/ipfs/QmRijoA6zGS98ELTDbGsLWPZbVotYsGbjp3RbXcKCYBeon/go-libp2p-routing" cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid" - node "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" + ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase" ) @@ -53,7 +53,7 @@ func newGatewayHandler(n *core.IpfsNode, c GatewayConfig, api coreiface.CoreAPI) } // TODO(cryptix): find these helpers somewhere else -func (i *gatewayHandler) newDagFromReader(r io.Reader) (node.Node, error) { +func (i *gatewayHandler) newDagFromReader(r io.Reader) (ipld.Node, error) { // TODO(cryptix): change and remove this helper once PR1136 is merged // return ufs.AddFromReader(i.node, r.Body) return importer.BuildDagFromReader( @@ -316,7 +316,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // storage for directory listing var dirListing []directoryItem - dirr.ForEachLink(ctx, func(link *node.Link) error { + dirr.ForEachLink(ctx, func(link *ipld.Link) error { // See comment above where originalUrlPath is declared. di := directoryItem{humanize.Bytes(link.Size), link.Name, gopath.Join(originalUrlPath, link.Name)} dirListing = append(dirListing, di) @@ -425,7 +425,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } - var newnode node.Node + var newnode ipld.Node if rsegs[len(rsegs)-1] == "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" { newnode = ft.EmptyDirNode() } else { From e62f5b422226c00435ba0b6de9c61039506c4b15 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 31 Jan 2018 18:54:57 -0800 Subject: [PATCH 280/674] gx: update go-log License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@b2cbfd299cb842b671ae66220324e7f9f599bf9f --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/logs.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index e555970df..a77b1bbc2 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmPq2D7Yoyev7yeMuMnkEYBqmQuUu5kb91UXPPoiik1Xyp/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmPq2D7Yoyev7yeMuMnkEYBqmQuUu5kb91UXPPoiik1Xyp/go-ipfs-cmds/http" + cmds "gx/ipfs/QmZ9hww8R3FKrDRCYPxhN13m6XgjPDpaSvdUfisPvERzXz/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmZ9hww8R3FKrDRCYPxhN13m6XgjPDpaSvdUfisPvERzXz/go-ipfs-cmds/http" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index dd5ea2a7b..19a414c69 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,8 +12,8 @@ import ( core "github.com/ipfs/go-ipfs/core" manet "gx/ipfs/QmRK2LxanhK2gZq6k6R7vk5ZoYZk8ULSSTB7FzDsMUX6CB/go-multiaddr-net" + logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" - logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index ecd5876bd..1bd35c13d 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmPd5qhppUqewTQMfStvNNCFtcxiWGsnE6Vs3va6788gsX/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmNh1kGFFdsPu79KNSaL4NUKUPb4Eiz4KHdMtFY6664RDp/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index aedcac227..5048821ea 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -24,7 +24,7 @@ import ( uio "github.com/ipfs/go-ipfs/unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - routing "gx/ipfs/QmRijoA6zGS98ELTDbGsLWPZbVotYsGbjp3RbXcKCYBeon/go-libp2p-routing" + routing "gx/ipfs/QmTiWLZ6Fo5j4KcTVutZJ5KWRRJrbxzmxA4td8NfEdrPh7/go-libp2p-routing" cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid" ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index f03219264..5dbb7ee88 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( config "github.com/ipfs/go-ipfs/repo/config" ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" - id "gx/ipfs/QmPd5qhppUqewTQMfStvNNCFtcxiWGsnE6Vs3va6788gsX/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmNh1kGFFdsPu79KNSaL4NUKUPb4Eiz4KHdMtFY6664RDp/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index d0dd96aa1..5eb85e90c 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log" + logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log" ) type writeErrNotifier struct { diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 1c04ecaf8..1b94dffba 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmPd5qhppUqewTQMfStvNNCFtcxiWGsnE6Vs3va6788gsX/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmQm7WmgYCa4RSz76tKEYpRjApjnRw8ZTUVQC15b8JM4a2/go-libp2p-net" - testutil "gx/ipfs/QmWUugnJBbcuin8qdfiCYKAsNkG8NeDLhzoBqRaqXhAHd4/go-libp2p-netutil" + bhost "gx/ipfs/QmNh1kGFFdsPu79KNSaL4NUKUPb4Eiz4KHdMtFY6664RDp/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmXfkENeeBvh3zYA51MaSdGUdBjhQ99cP5WQe8zgr6wchG/go-libp2p-net" + testutil "gx/ipfs/QmYVR3C8DWPHdHxvLtNFYfjsXgaRAdh6hPMNH3KiwCgu4o/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From ee39af50f814ac5407f8bff90fa042df4e023a3f Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Mon, 5 Feb 2018 20:28:27 +0100 Subject: [PATCH 281/674] WIP: Extract: importers/chunk module as go-ipfs-chunker License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@c613fbec3870f7cf97fc271dcbf69ccf34c1c0b5 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 5048821ea..41e532638 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,12 +16,12 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/importer" - chunk "github.com/ipfs/go-ipfs/importer/chunk" dag "github.com/ipfs/go-ipfs/merkledag" dagutils "github.com/ipfs/go-ipfs/merkledag/utils" path "github.com/ipfs/go-ipfs/path" ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" + chunk "gx/ipfs/QmQXcAyrC4VBu9ZBqxoCthPot9PNhb4Uiw6iBDfQXudZJd/go-ipfs-chunker" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" routing "gx/ipfs/QmTiWLZ6Fo5j4KcTVutZJ5KWRRJrbxzmxA4td8NfEdrPh7/go-libp2p-routing" From af84af152e164fe3d41962f6705955bca08ee1f0 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 7 Feb 2018 10:39:41 +0100 Subject: [PATCH 282/674] go-ipfs-chunker: Use the stable gx'ed release License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@1811425aabad029e3d4e1e0cc58b86056fcd290b --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 41e532638..15cadf9cb 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -21,7 +21,7 @@ import ( path "github.com/ipfs/go-ipfs/path" ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" - chunk "gx/ipfs/QmQXcAyrC4VBu9ZBqxoCthPot9PNhb4Uiw6iBDfQXudZJd/go-ipfs-chunker" + chunk "gx/ipfs/QmcYFMP9mfpJ2swedZCBskeAoxGKGBGY7LaS6VZ1jEWqUs/go-ipfs-chunker" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" routing "gx/ipfs/QmTiWLZ6Fo5j4KcTVutZJ5KWRRJrbxzmxA4td8NfEdrPh7/go-libp2p-routing" From 58e19dd6ccf69157845df6c87db69b01fb5996f7 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 8 Feb 2018 12:43:29 +0100 Subject: [PATCH 283/674] Extract chunker: Use last gx'ed go-ipfs-chunker License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@76d228cf75b2734260b2d5fbbd55f8c24c135568 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 15cadf9cb..c2000878c 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -21,10 +21,10 @@ import ( path "github.com/ipfs/go-ipfs/path" ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" - chunk "gx/ipfs/QmcYFMP9mfpJ2swedZCBskeAoxGKGBGY7LaS6VZ1jEWqUs/go-ipfs-chunker" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" routing "gx/ipfs/QmTiWLZ6Fo5j4KcTVutZJ5KWRRJrbxzmxA4td8NfEdrPh7/go-libp2p-routing" + chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker" cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid" ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase" From 94c4ed2421c82c77373a55e4699c109cb310d9ad Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 8 Feb 2018 12:49:39 +0100 Subject: [PATCH 284/674] Extract: chunker: rename "chunk" to "chunker" as it is more consistent License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@381977476f465842f27118c65a7a819c8111ce98 --- gateway/core/corehttp/gateway_handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index c2000878c..fed287594 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -24,7 +24,7 @@ import ( humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" routing "gx/ipfs/QmTiWLZ6Fo5j4KcTVutZJ5KWRRJrbxzmxA4td8NfEdrPh7/go-libp2p-routing" - chunk "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker" + chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker" cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid" ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase" @@ -58,7 +58,7 @@ func (i *gatewayHandler) newDagFromReader(r io.Reader) (ipld.Node, error) { // return ufs.AddFromReader(i.node, r.Body) return importer.BuildDagFromReader( i.node.DAG, - chunk.DefaultSplitter(r)) + chunker.DefaultSplitter(r)) } // TODO(btc): break this apart into separate handlers using a more expressive muxer From f7388cc3ce57fb8cb4217da76ca30039696793a9 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 16 Feb 2018 00:09:50 +0100 Subject: [PATCH 285/674] Feat: Separate "path" from "path/resolver" Currently the "path" module does two very different things: * Defines how ipfs paths look like and provides tools to parse/split etc. * Provides a resolver to resolve paths. This moves the resolver stuff to `path/resolver` and leaves the path utilities in `path`. The result is that now the IPFS `path` package just defines what a path looks like and becomes a module that can be exported/re-used without problems. Currently there are circular dependency cycles (resolve_test -> merkledag/utils, merkledag->path), which the prevent the export of merkledag itself. License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@93d1a695d49867fcd530cd236ed6dd43ab454c50 --- gateway/core/corehttp/gateway_handler.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index fed287594..842d30d46 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -19,6 +19,7 @@ import ( dag "github.com/ipfs/go-ipfs/merkledag" dagutils "github.com/ipfs/go-ipfs/merkledag/utils" path "github.com/ipfs/go-ipfs/path" + resolver "github.com/ipfs/go-ipfs/path/resolver" ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" @@ -445,7 +446,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { var newcid *cid.Cid rnode, err := core.Resolve(ctx, i.node.Namesys, i.node.Resolver, rootPath) switch ev := err.(type) { - case path.ErrNoLink: + case resolver.ErrNoLink: // ev.Node < node where resolve failed // ev.Name < new link // but we need to patch from the root @@ -599,7 +600,7 @@ func (i *gatewayHandler) addUserHeaders(w http.ResponseWriter) { } func webError(w http.ResponseWriter, message string, err error, defaultCode int) { - if _, ok := err.(path.ErrNoLink); ok { + if _, ok := err.(resolver.ErrNoLink); ok { webErrorWithCode(w, message, err, http.StatusNotFound) } else if err == routing.ErrNotFound { webErrorWithCode(w, message, err, http.StatusNotFound) From 14306adac8363b515600206a94309213420ad37b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 20 Feb 2018 16:43:00 -0800 Subject: [PATCH 286/674] update go-ipfs-cmds * May fix #4670 * Fixes #4683 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@2c68c1540711754d0ebd6810bbc75031dfd69f79 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index a77b1bbc2..168667c4c 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmZ9hww8R3FKrDRCYPxhN13m6XgjPDpaSvdUfisPvERzXz/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmZ9hww8R3FKrDRCYPxhN13m6XgjPDpaSvdUfisPvERzXz/go-ipfs-cmds/http" + cmds "gx/ipfs/QmabLouZTZwhfALuBcssPvkzhbYGMb4394huT7HY4LQ6d3/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmabLouZTZwhfALuBcssPvkzhbYGMb4394huT7HY4LQ6d3/go-ipfs-cmds/http" ) var ( From e2c25f9b69e9dbe2d593dd6fdffe6f47387ed367 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 20 Feb 2018 17:37:35 -0800 Subject: [PATCH 287/674] fix a bunch of go vet errors License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@45756b6d64c8373e41727fab9a8798eb10275f80 --- gateway/core/corehttp/metrics_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 1b94dffba..89ba5f2f2 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -45,6 +45,6 @@ func TestPeersTotal(t *testing.T) { t.Fatalf("expected 1 peers transport, got %d", len(actual)) } if actual["/ip4/tcp"] != float64(3) { - t.Fatalf("expected 3 peers, got %s", actual["/ip4/tcp"]) + t.Fatalf("expected 3 peers, got %f", actual["/ip4/tcp"]) } } From 01114b4deac31470d5576f03ed9e46b9ffa7d2bb Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Fri, 23 Feb 2018 11:47:30 -0500 Subject: [PATCH 288/674] Add options for record count and timeout for resolving DHT paths License: MIT Signed-off-by: Dirk McCormick This commit was moved from ipfs/kubo@1abf8366ee2a38c47b7fcc4a14654e24e9492159 --- gateway/core/corehttp/ipns_hostname.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 6a36bd8c4..a8e534ece 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/ipfs/go-ipfs/core" + namesys "github.com/ipfs/go-ipfs/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) @@ -24,7 +25,7 @@ func IPNSHostnameOption() ServeOption { host := strings.SplitN(r.Host, ":", 2)[0] if len(host) > 0 && isd.IsDomain(host) { name := "/ipns/" + host - if _, err := n.Namesys.Resolve(ctx, name); err == nil { + if _, err := n.Namesys.Resolve(ctx, name, namesys.DefaultResolveOpts()); err == nil { r.Header["X-Ipns-Original-Path"] = []string{r.URL.Path} r.URL.Path = name + r.URL.Path } From c8c78fdecfdada8d1d6387317d7d3c2a9d26956a Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Sun, 25 Feb 2018 20:46:55 -0500 Subject: [PATCH 289/674] Fix gateway test License: MIT Signed-off-by: Dirk McCormick This commit was moved from ipfs/kubo@5096025df2f6b034a9389da26dff0ec748461ec4 --- gateway/core/corehttp/gateway_test.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 5dbb7ee88..e5d328ded 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -28,11 +28,7 @@ var emptyDir = "/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" type mockNamesys map[string]path.Path -func (m mockNamesys) Resolve(ctx context.Context, name string) (value path.Path, err error) { - return m.ResolveN(ctx, name, namesys.DefaultDepthLimit) -} - -func (m mockNamesys) ResolveN(ctx context.Context, name string, depth int) (value path.Path, err error) { +func (m mockNamesys) Resolve(ctx context.Context, name string, opts *namesys.ResolveOpts) (value path.Path, err error) { p, ok := m[name] if !ok { return "", namesys.ErrResolveFailed From 9e17bc6c77b3bc612526b04898f0a90cd5f12752 Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Wed, 28 Feb 2018 16:57:24 -0500 Subject: [PATCH 290/674] Use variadic options License: MIT Signed-off-by: Dirk McCormick This commit was moved from ipfs/kubo@e8f79c88036362d99d2b06e3fa7fae974090cd6f --- gateway/core/corehttp/gateway_test.go | 3 ++- gateway/core/corehttp/ipns_hostname.go | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index e5d328ded..d91bb7cff 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -14,6 +14,7 @@ import ( coreunix "github.com/ipfs/go-ipfs/core/coreunix" dag "github.com/ipfs/go-ipfs/merkledag" namesys "github.com/ipfs/go-ipfs/namesys" + nsopts "github.com/ipfs/go-ipfs/namesys/opts" path "github.com/ipfs/go-ipfs/path" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" @@ -28,7 +29,7 @@ var emptyDir = "/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" type mockNamesys map[string]path.Path -func (m mockNamesys) Resolve(ctx context.Context, name string, opts *namesys.ResolveOpts) (value path.Path, err error) { +func (m mockNamesys) Resolve(ctx context.Context, name string, opts ...nsopts.ResolveOpt) (value path.Path, err error) { p, ok := m[name] if !ok { return "", namesys.ErrResolveFailed diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index a8e534ece..6a36bd8c4 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -7,7 +7,6 @@ import ( "strings" "github.com/ipfs/go-ipfs/core" - namesys "github.com/ipfs/go-ipfs/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) @@ -25,7 +24,7 @@ func IPNSHostnameOption() ServeOption { host := strings.SplitN(r.Host, ":", 2)[0] if len(host) > 0 && isd.IsDomain(host) { name := "/ipns/" + host - if _, err := n.Namesys.Resolve(ctx, name, namesys.DefaultResolveOpts()); err == nil { + if _, err := n.Namesys.Resolve(ctx, name); err == nil { r.Header["X-Ipns-Original-Path"] = []string{r.URL.Path} r.URL.Path = name + r.URL.Path } From 64cb4876b8a904dff3dcb2d9f07e9ed4ab1665c8 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 17 Mar 2018 12:22:20 -0700 Subject: [PATCH 291/674] pre-populate required arguments from request body This way, we can always assume that indexing a required argument works. Also: * test that the command tree doesn't have any obvious bugs (duplicate options, arguments in the wrong order, etc). * simplify the usage ParseBodyArgs. * remove unnecessary check in the get command. fixes #4823 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@45fd7d213ffe090111906743c245e33ed4a20826 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 168667c4c..f076a3205 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmabLouZTZwhfALuBcssPvkzhbYGMb4394huT7HY4LQ6d3/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmabLouZTZwhfALuBcssPvkzhbYGMb4394huT7HY4LQ6d3/go-ipfs-cmds/http" + cmds "gx/ipfs/QmSBXjZJCTmRSLXzXr4duHKzWfgDX8aJ6XuPXCQZuVU1LP/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmSBXjZJCTmRSLXzXr4duHKzWfgDX8aJ6XuPXCQZuVU1LP/go-ipfs-cmds/http" ) var ( From a7393368e9bf05751d0e987841f03390c188dafb Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 19 Mar 2018 15:58:34 -0700 Subject: [PATCH 292/674] check arguments after handling help otherwise, we block on required arguments from stdin before processing the help flag. fixes #4837 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@7824c2cf4eca4e78c76149c80b2171a6121e0421 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index f076a3205..f01d9233f 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmSBXjZJCTmRSLXzXr4duHKzWfgDX8aJ6XuPXCQZuVU1LP/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmSBXjZJCTmRSLXzXr4duHKzWfgDX8aJ6XuPXCQZuVU1LP/go-ipfs-cmds/http" + cmds "gx/ipfs/QmfAkMSt9Fwzk48QDJecPcwCUjnf2uG7MLnmCGTp4C6ouL/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmfAkMSt9Fwzk48QDJecPcwCUjnf2uG7MLnmCGTp4C6ouL/go-ipfs-cmds/http" ) var ( From 1505924dcc059c1aa2d839a20c79e991b9410d10 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 27 Feb 2018 22:07:15 +0100 Subject: [PATCH 293/674] Replace the rest of thirdparty/datastore2 with go-datastore License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@30cf14ef9edc9565b41e687c15b61491543269e6 --- gateway/core/corehttp/gateway_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index d91bb7cff..af7a2b726 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,9 +18,10 @@ import ( path "github.com/ipfs/go-ipfs/path" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" - ds2 "github.com/ipfs/go-ipfs/thirdparty/datastore2" id "gx/ipfs/QmNh1kGFFdsPu79KNSaL4NUKUPb4Eiz4KHdMtFY6664RDp/go-libp2p/p2p/protocol/identify" + datastore "gx/ipfs/QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9/go-datastore" + syncds "gx/ipfs/QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9/go-datastore/sync" ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" ) @@ -57,7 +58,7 @@ func newNodeWithMockNamesys(ns mockNamesys) (*core.IpfsNode, error) { } r := &repo.Mock{ C: c, - D: ds2.ThreadSafeCloserMapDatastore(), + D: syncds.MutexWrap(datastore.NewMapDatastore()), } n, err := core.NewNode(context.Background(), &core.BuildCfg{Repo: r}) if err != nil { From 6ff7a7f4c96fa19613d4b297d9776281a9d57294 Mon Sep 17 00:00:00 2001 From: Dominic Della Valle Date: Tue, 24 Apr 2018 15:01:16 -0400 Subject: [PATCH 294/674] gx: update go-ipfs-cmds License: MIT Signed-off-by: Dominic Della Valle This commit was moved from ipfs/kubo@b675ade0d8a5695940b05143b7042cf88971bd96 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index f01d9233f..1321ec710 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmfAkMSt9Fwzk48QDJecPcwCUjnf2uG7MLnmCGTp4C6ouL/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmfAkMSt9Fwzk48QDJecPcwCUjnf2uG7MLnmCGTp4C6ouL/go-ipfs-cmds/http" + cmds "gx/ipfs/QmTjNRVt2fvaRFu93keEC7z5M1GS1iH6qZ9227htQioTUY/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmTjNRVt2fvaRFu93keEC7z5M1GS1iH6qZ9227htQioTUY/go-ipfs-cmds/http" ) var ( From 02fcbdef427b31700bfe94390949e8048a1858aa Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 3 May 2018 21:39:52 -0700 Subject: [PATCH 295/674] update deps License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@1e9e2f453c435272433a96ebfba5c4319cc08534 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 4 ++-- gateway/core/corehttp/gateway_test.go | 8 ++++---- gateway/core/corehttp/logs.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 1321ec710..22a5c5beb 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmTjNRVt2fvaRFu93keEC7z5M1GS1iH6qZ9227htQioTUY/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmTjNRVt2fvaRFu93keEC7z5M1GS1iH6qZ9227htQioTUY/go-ipfs-cmds/http" + cmds "gx/ipfs/QmSKYWC84fqkKB54Te5JMcov2MBVzucXaRGxFqByzzCbHe/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmSKYWC84fqkKB54Te5JMcov2MBVzucXaRGxFqByzzCbHe/go-ipfs-cmds/http" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 19a414c69..1b88f39b4 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,8 +12,8 @@ import ( core "github.com/ipfs/go-ipfs/core" manet "gx/ipfs/QmRK2LxanhK2gZq6k6R7vk5ZoYZk8ULSSTB7FzDsMUX6CB/go-multiaddr-net" - logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" + logging "gx/ipfs/QmTG23dvpBCBjqQwyDxV8CQT6jmS4PSftNr1VqHhE3MLy7/go-log" ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 1bd35c13d..660a42079 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmNh1kGFFdsPu79KNSaL4NUKUPb4Eiz4KHdMtFY6664RDp/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmWsV6kzPaYGBDVyuUfWBvyQygEc9Qrv9vzo8vZ7X4mdLN/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 842d30d46..de03f1a2b 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -24,8 +24,8 @@ import ( uio "github.com/ipfs/go-ipfs/unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - routing "gx/ipfs/QmTiWLZ6Fo5j4KcTVutZJ5KWRRJrbxzmxA4td8NfEdrPh7/go-libp2p-routing" - chunker "gx/ipfs/QmWo8jYc19ppG7YoTsrr2kEtLRbARTJho5oNXFTR6B7Peq/go-ipfs-chunker" + routing "gx/ipfs/QmUHRKTeaoASDvDj7cTAXsmjAY7KQ13ErtzkQHZQq6uFUz/go-libp2p-routing" + chunker "gx/ipfs/QmbGDSVKnYJZrtUnyxwsUpCeuigshNuVFxXCpv13jXecq1/go-ipfs-chunker" cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid" ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index af7a2b726..2b9e8369f 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,10 +19,10 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmNh1kGFFdsPu79KNSaL4NUKUPb4Eiz4KHdMtFY6664RDp/go-libp2p/p2p/protocol/identify" - datastore "gx/ipfs/QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9/go-datastore" - syncds "gx/ipfs/QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9/go-datastore/sync" - ci "gx/ipfs/QmaPbCnUMBohSGo3KnxEa2bHqyJVVeEEcwtqJAYxerieBo/go-libp2p-crypto" + id "gx/ipfs/QmWsV6kzPaYGBDVyuUfWBvyQygEc9Qrv9vzo8vZ7X4mdLN/go-libp2p/p2p/protocol/identify" + ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" + datastore "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore" + syncds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/sync" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 5eb85e90c..6521e94a0 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - logging "gx/ipfs/QmRb5jh8z2E8hMGN2tkvs1yHynUanqnZ3UeKwgN1i9P1F8/go-log" + logging "gx/ipfs/QmTG23dvpBCBjqQwyDxV8CQT6jmS4PSftNr1VqHhE3MLy7/go-log" ) type writeErrNotifier struct { diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 89ba5f2f2..e33fef8f5 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmNh1kGFFdsPu79KNSaL4NUKUPb4Eiz4KHdMtFY6664RDp/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmXfkENeeBvh3zYA51MaSdGUdBjhQ99cP5WQe8zgr6wchG/go-libp2p-net" - testutil "gx/ipfs/QmYVR3C8DWPHdHxvLtNFYfjsXgaRAdh6hPMNH3KiwCgu4o/go-libp2p-netutil" + bhost "gx/ipfs/QmWsV6kzPaYGBDVyuUfWBvyQygEc9Qrv9vzo8vZ7X4mdLN/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmXoz9o2PT3tEzf7hicegwex5UgVP54n3k82K7jrWFyN86/go-libp2p-net" + testutil "gx/ipfs/Qmb6BsZf6Y3kxffXMNTubGPF1w1bkHtpvhfYbmnwP3NQyw/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 63b33a9d0331b486f0494a43e6dd89d1aae7f640 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 25 Apr 2018 00:00:37 -0700 Subject: [PATCH 296/674] only resolve dnslinks once in the gateway If the domain has a DNS-Link, we want to use it even if it points to, e.g., an IPNS address that doesn't resolve. fixes #4973 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@31bb974bb1f2292fa69dc11a4bb3cfd1e2a0a61c --- gateway/core/corehttp/ipns_hostname.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 6a36bd8c4..265feef80 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -6,7 +6,8 @@ import ( "net/http" "strings" - "github.com/ipfs/go-ipfs/core" + core "github.com/ipfs/go-ipfs/core" + nsopts "github.com/ipfs/go-ipfs/namesys/opts" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) @@ -24,7 +25,7 @@ func IPNSHostnameOption() ServeOption { host := strings.SplitN(r.Host, ":", 2)[0] if len(host) > 0 && isd.IsDomain(host) { name := "/ipns/" + host - if _, err := n.Namesys.Resolve(ctx, name); err == nil { + if _, err := n.Namesys.Resolve(ctx, name, nsopts.Depth(1)); err == nil { r.Header["X-Ipns-Original-Path"] = []string{r.URL.Path} r.URL.Path = name + r.URL.Path } From d3148dfd55641a1797c82c63acbf8782259289f6 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 25 Apr 2018 10:53:24 -0700 Subject: [PATCH 297/674] add test for 4973 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@e9928f76916023d5a8372e2635c46e2e746dcfd1 --- gateway/core/corehttp/gateway_test.go | 34 +++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index af7a2b726..b9ffb260e 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "io/ioutil" + "math" "net/http" "net/http/httptest" "strings" @@ -31,11 +32,25 @@ var emptyDir = "/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" type mockNamesys map[string]path.Path func (m mockNamesys) Resolve(ctx context.Context, name string, opts ...nsopts.ResolveOpt) (value path.Path, err error) { - p, ok := m[name] - if !ok { - return "", namesys.ErrResolveFailed + cfg := nsopts.DefaultResolveOpts() + for _, o := range opts { + o(cfg) } - return p, nil + depth := cfg.Depth + if depth == nsopts.UnlimitedDepth { + depth = math.MaxUint64 + } + for depth > 0 && strings.HasPrefix(name, "/ipns/") { + depth-- + + var ok bool + value, ok = m[name] + if !ok { + return "", namesys.ErrResolveFailed + } + name = value.String() + } + return value, nil } func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value path.Path) error { @@ -130,6 +145,10 @@ func TestGatewayGet(t *testing.T) { t.Fatal(err) } ns["/ipns/example.com"] = path.FromString("/ipfs/" + k) + ns["/ipns/working.example.com"] = path.FromString("/ipfs/" + k) + ns["/ipns/double.example.com"] = path.FromString("/ipns/working.example.com") + ns["/ipns/triple.example.com"] = path.FromString("/ipns/double.example.com") + ns["/ipns/broken.example.com"] = path.FromString("/ipns/" + k) t.Log(ts.URL) for _, test := range []struct { @@ -145,6 +164,13 @@ func TestGatewayGet(t *testing.T) { {"localhost:5001", "/ipns/%0D%0A%0D%0Ahello", http.StatusNotFound, "ipfs resolve -r /ipns/%0D%0A%0D%0Ahello: " + namesys.ErrResolveFailed.Error() + "\n"}, {"localhost:5001", "/ipns/example.com", http.StatusOK, "fnord"}, {"example.com", "/", http.StatusOK, "fnord"}, + + {"working.example.com", "/", http.StatusOK, "fnord"}, + {"double.example.com", "/", http.StatusOK, "fnord"}, + {"triple.example.com", "/", http.StatusOK, "fnord"}, + {"working.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/working.example.com/ipfs/" + k + ": no link named \"ipfs\" under " + k + "\n"}, + {"broken.example.com", "/", http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/: " + namesys.ErrResolveFailed.Error() + "\n"}, + {"broken.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/ipfs/" + k + ": " + namesys.ErrResolveFailed.Error() + "\n"}, } { var c http.Client r, err := http.NewRequest("GET", ts.URL+test.path, nil) From db4fdcd5a7c3fe634022567e4b5b50f1145f4cc2 Mon Sep 17 00:00:00 2001 From: Brendan McMillion Date: Sun, 3 Jun 2018 13:55:36 -0700 Subject: [PATCH 298/674] Fix panic. Don't handle errors with fallthrough. License: MIT Signed-off-by: Brendan McMillion This commit was moved from ipfs/kubo@8387c394e9cec5e7a6b18d8f23486da3ae555aca --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 21 +++++++-------------- gateway/core/corehttp/ipns_hostname.go | 2 +- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 22a5c5beb..eaae1de21 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -162,10 +162,10 @@ func CheckVersionOption() ServeOption { pth := path.SplitList(cmdqry) // backwards compatibility to previous version check - if pth[1] != "version" { + if len(pth) >= 2 && pth[1] != "version" { clientVersion := r.UserAgent() // skips check if client is not go-ipfs - if clientVersion != "" && strings.Contains(clientVersion, "/go-ipfs/") && daemonVersion != clientVersion { + if strings.Contains(clientVersion, "/go-ipfs/") && daemonVersion != clientVersion { http.Error(w, fmt.Sprintf("%s (%s != %s)", errAPIVersionMismatch, daemonVersion, clientVersion), http.StatusBadRequest) return } diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index de03f1a2b..9f1e8ff12 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -132,7 +132,6 @@ func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request) } func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { - urlPath := r.URL.Path escapedURLPath := r.URL.EscapedPath() @@ -140,8 +139,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // the prefix header can be set to signal this sub-path. // It will be prepended to links in directory listings and the index.html redirect. prefix := "" - if prefixHdr := r.Header["X-Ipfs-Gateway-Prefix"]; len(prefixHdr) > 0 { - prfx := prefixHdr[0] + if prfx := r.Header.Get("X-Ipfs-Gateway-Prefix"); len(prfx) > 0 { for _, p := range i.config.PathPrefixes { if prfx == p || strings.HasPrefix(prfx, p+"/") { prefix = prfx @@ -157,8 +155,8 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // the redirects and links would end up as http://example.net/ipns/example.net originalUrlPath := prefix + urlPath ipnsHostname := false - if hdr := r.Header["X-Ipns-Original-Path"]; len(hdr) > 0 { - originalUrlPath = prefix + hdr[0] + if hdr := r.Header.Get("X-Ipns-Original-Path"); len(hdr) > 0 { + originalUrlPath = prefix + hdr ipnsHostname = true } @@ -170,15 +168,10 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // Resolve path to the final DAG node for the ETag resolvedPath, err := i.api.ResolvePath(ctx, parsedPath) - switch err { - case nil: - case coreiface.ErrOffline: - if !i.node.OnlineMode() { - webError(w, "ipfs resolve -r "+escapedURLPath, err, http.StatusServiceUnavailable) - return - } - fallthrough - default: + if err == coreiface.ErrOffline && !i.node.OnlineMode() { + webError(w, "ipfs resolve -r "+escapedURLPath, err, http.StatusServiceUnavailable) + return + } else if err != nil { webError(w, "ipfs resolve -r "+escapedURLPath, err, http.StatusNotFound) return } diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 265feef80..7bce62ad3 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -26,7 +26,7 @@ func IPNSHostnameOption() ServeOption { if len(host) > 0 && isd.IsDomain(host) { name := "/ipns/" + host if _, err := n.Namesys.Resolve(ctx, name, nsopts.Depth(1)); err == nil { - r.Header["X-Ipns-Original-Path"] = []string{r.URL.Path} + r.Header.Set("X-Ipns-Original-Path", r.URL.Path) r.URL.Path = name + r.URL.Path } } From c7b27ffd398b62063281027b91b620ef7d57aca0 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 4 Jun 2018 09:53:40 -0700 Subject: [PATCH 299/674] update multiplexers License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@c9c9986c9eeb07d4658e9077a9ea1e286f324409 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 660a42079..ca4f6f8e6 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmWsV6kzPaYGBDVyuUfWBvyQygEc9Qrv9vzo8vZ7X4mdLN/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmY6iAoG9DVgZwh5ZRcQEpa2uErAe1Hbei8qXPCjpDS9Ge/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 6482c9738..2caff20cc 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,7 +20,7 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmWsV6kzPaYGBDVyuUfWBvyQygEc9Qrv9vzo8vZ7X4mdLN/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmY6iAoG9DVgZwh5ZRcQEpa2uErAe1Hbei8qXPCjpDS9Ge/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" datastore "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore" syncds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/sync" diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index e33fef8f5..997506e5e 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmWsV6kzPaYGBDVyuUfWBvyQygEc9Qrv9vzo8vZ7X4mdLN/go-libp2p/p2p/host/basic" inet "gx/ipfs/QmXoz9o2PT3tEzf7hicegwex5UgVP54n3k82K7jrWFyN86/go-libp2p-net" - testutil "gx/ipfs/Qmb6BsZf6Y3kxffXMNTubGPF1w1bkHtpvhfYbmnwP3NQyw/go-libp2p-netutil" + bhost "gx/ipfs/QmY6iAoG9DVgZwh5ZRcQEpa2uErAe1Hbei8qXPCjpDS9Ge/go-libp2p/p2p/host/basic" + testutil "gx/ipfs/Qma2UuHusnaFV24DgeZ5hyrM9uc4UdyVaZbtn2FQsPRhES/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 26a7d5d527716906558afcf757f865e1c2ac8258 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 7 Mar 2018 22:06:17 -0800 Subject: [PATCH 300/674] transport refactor update License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@b84a71de8cf58643faa0ffdaafa8ba4e0da2e2e3 --- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 1b88f39b4..34ce9651c 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -61,7 +61,7 @@ func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...Serv addr = list.Multiaddr() fmt.Printf("API server listening on %s\n", addr) - return Serve(n, list.NetListener(), options...) + return Serve(n, manet.NetListener(list), options...) } func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error { diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 997506e5e..ded143888 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" + swarmt "gx/ipfs/QmRpKdg1xs4Yyrn9yrVYRBp7AQqyRxMLpD6Jgp1eZAGqEr/go-libp2p-swarm/testing" inet "gx/ipfs/QmXoz9o2PT3tEzf7hicegwex5UgVP54n3k82K7jrWFyN86/go-libp2p-net" bhost "gx/ipfs/QmY6iAoG9DVgZwh5ZRcQEpa2uErAe1Hbei8qXPCjpDS9Ge/go-libp2p/p2p/host/basic" - testutil "gx/ipfs/Qma2UuHusnaFV24DgeZ5hyrM9uc4UdyVaZbtn2FQsPRhES/go-libp2p-netutil" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect @@ -20,11 +20,11 @@ func TestPeersTotal(t *testing.T) { hosts := make([]*bhost.BasicHost, 4) for i := 0; i < 4; i++ { - hosts[i] = bhost.New(testutil.GenSwarmNetwork(t, ctx)) + hosts[i] = bhost.New(swarmt.GenSwarm(t, ctx)) } dial := func(a, b inet.Network) { - testutil.DivulgeAddresses(b, a) + swarmt.DivulgeAddresses(b, a) if _, err := a.DialPeer(ctx, b.LocalPeer()); err != nil { t.Fatalf("Failed to dial: %s", err) } From 6094d4a9c606e5a6ad320a05b10cee2a036ee11e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 5 Jun 2018 23:55:08 -0700 Subject: [PATCH 301/674] update gx imports License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@39f927aa04b88061139f1c19e20db3f1ae25f91b --- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 34ce9651c..ef5502a10 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -11,10 +11,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - manet "gx/ipfs/QmRK2LxanhK2gZq6k6R7vk5ZoYZk8ULSSTB7FzDsMUX6CB/go-multiaddr-net" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" logging "gx/ipfs/QmTG23dvpBCBjqQwyDxV8CQT6jmS4PSftNr1VqHhE3MLy7/go-log" ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr" + manet "gx/ipfs/QmcGXGdw9BWDysPJQHxJinjGHha3eEg4vzFETre4woNwcX/go-multiaddr-net" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index ca4f6f8e6..fcf325766 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmY6iAoG9DVgZwh5ZRcQEpa2uErAe1Hbei8qXPCjpDS9Ge/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmRvoAami8AAf5Yy6jcPq5KqQT1ZCaoi9dF1vdKAghmq9X/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index de03f1a2b..d56d8593c 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -24,7 +24,7 @@ import ( uio "github.com/ipfs/go-ipfs/unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - routing "gx/ipfs/QmUHRKTeaoASDvDj7cTAXsmjAY7KQ13ErtzkQHZQq6uFUz/go-libp2p-routing" + routing "gx/ipfs/QmXijJ3T9MjB2v8xpFDoEX6FqR9u8PkJkzu49TgwJ8Ndr5/go-libp2p-routing" chunker "gx/ipfs/QmbGDSVKnYJZrtUnyxwsUpCeuigshNuVFxXCpv13jXecq1/go-ipfs-chunker" cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid" ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 2caff20cc..5b3dae812 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,7 +20,7 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmY6iAoG9DVgZwh5ZRcQEpa2uErAe1Hbei8qXPCjpDS9Ge/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmRvoAami8AAf5Yy6jcPq5KqQT1ZCaoi9dF1vdKAghmq9X/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" datastore "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore" syncds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/sync" diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index ded143888..c09065750 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - swarmt "gx/ipfs/QmRpKdg1xs4Yyrn9yrVYRBp7AQqyRxMLpD6Jgp1eZAGqEr/go-libp2p-swarm/testing" - inet "gx/ipfs/QmXoz9o2PT3tEzf7hicegwex5UgVP54n3k82K7jrWFyN86/go-libp2p-net" - bhost "gx/ipfs/QmY6iAoG9DVgZwh5ZRcQEpa2uErAe1Hbei8qXPCjpDS9Ge/go-libp2p/p2p/host/basic" + swarmt "gx/ipfs/QmPzT3rJnSP8VFP1kw7Ly7HP8AprKNZtwLHXHnxfVSbWT3/go-libp2p-swarm/testing" + bhost "gx/ipfs/QmRvoAami8AAf5Yy6jcPq5KqQT1ZCaoi9dF1vdKAghmq9X/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmYj8wdn5sZEHX2XMDWGBvcXJNdzVbaVpHmXvhHBVZepen/go-libp2p-net" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 27bda4e889969619514d0d108d30bfd0cb85ff4c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 8 Jun 2018 22:01:00 -0700 Subject: [PATCH 302/674] gx update go-log, sys, go-crypto * go-log * sys * go-crypto License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@85acad9a015225ae5fa381d5284d559b9739edb6 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/corehttp.go | 6 +++--- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 8 ++++---- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/logs.go | 4 ++-- gateway/core/corehttp/metrics_test.go | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 22a5c5beb..f424c9c4c 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmSKYWC84fqkKB54Te5JMcov2MBVzucXaRGxFqByzzCbHe/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmSKYWC84fqkKB54Te5JMcov2MBVzucXaRGxFqByzzCbHe/go-ipfs-cmds/http" + cmds "gx/ipfs/QmaFrNcnXHp579hUixbcTH1TNtNwsMogtBCwUUUwzBwYoM/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmaFrNcnXHp579hUixbcTH1TNtNwsMogtBCwUUUwzBwYoM/go-ipfs-cmds/http" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index ef5502a10..3e6e296f6 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -11,10 +11,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + manet "gx/ipfs/QmNqRnejxJxjRroz7buhrjfU8i3yNBLa81hFtmf2pXEffN/go-multiaddr-net" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" - logging "gx/ipfs/QmTG23dvpBCBjqQwyDxV8CQT6jmS4PSftNr1VqHhE3MLy7/go-log" - ma "gx/ipfs/QmWWQ2Txc2c6tqjsBpzg5Ar652cHPGNsQQp2SejkNmkUMb/go-multiaddr" - manet "gx/ipfs/QmcGXGdw9BWDysPJQHxJinjGHha3eEg4vzFETre4woNwcX/go-multiaddr-net" + ma "gx/ipfs/QmUxSEGbv2nmYNnfXi7839wwQqTN3kwQeUxe8dTjZWZs7J/go-multiaddr" + logging "gx/ipfs/Qmbi1CTJsbnBZjCEgc2otwu8cUFPsGpzWXG7edVCLZ7Gvk/go-log" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index fcf325766..272c1cc3e 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmRvoAami8AAf5Yy6jcPq5KqQT1ZCaoi9dF1vdKAghmq9X/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmUEAR2pS7fP1GPseS3i8MWFyENs7oDp4CZrgn8FCjbsBu/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d56d8593c..46e517b62 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -24,10 +24,10 @@ import ( uio "github.com/ipfs/go-ipfs/unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - routing "gx/ipfs/QmXijJ3T9MjB2v8xpFDoEX6FqR9u8PkJkzu49TgwJ8Ndr5/go-libp2p-routing" - chunker "gx/ipfs/QmbGDSVKnYJZrtUnyxwsUpCeuigshNuVFxXCpv13jXecq1/go-ipfs-chunker" - cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid" - ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format" + chunker "gx/ipfs/QmR4G4WBNGA5S5pvjFiTkuehstC9769sLAHei8vZernhYR/go-ipfs-chunker" + routing "gx/ipfs/QmUV9hDAAyjeGbxbXkJ2sYqZ6dTd1DXJ2REhYEkRm178Tg/go-libp2p-routing" + ipld "gx/ipfs/QmWi2BYBL5gJ3CiAiQchg6rn1A8iBsrWy51EYxvHVjFvLb/go-ipld-format" + cid "gx/ipfs/QmapdYm1b22Frv3k17fqrBYTFRxwiaVJkB299Mfn33edeB/go-cid" multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 5b3dae812..e921b36b1 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,7 +20,7 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmRvoAami8AAf5Yy6jcPq5KqQT1ZCaoi9dF1vdKAghmq9X/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmUEAR2pS7fP1GPseS3i8MWFyENs7oDp4CZrgn8FCjbsBu/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" datastore "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore" syncds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/sync" diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 6521e94a0..ad9712a11 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - logging "gx/ipfs/QmTG23dvpBCBjqQwyDxV8CQT6jmS4PSftNr1VqHhE3MLy7/go-log" + lwriter "gx/ipfs/Qmbi1CTJsbnBZjCEgc2otwu8cUFPsGpzWXG7edVCLZ7Gvk/go-log/writer" ) type writeErrNotifier struct { @@ -49,7 +49,7 @@ func LogOption() ServeOption { mux.HandleFunc("/logs", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) wnf, errs := newWriteErrNotifier(w) - logging.WriterGroup.AddWriter(wnf) + lwriter.WriterGroup.AddWriter(wnf) log.Event(n.Context(), "log API client connected") <-errs }) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index c09065750..55deb8803 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - swarmt "gx/ipfs/QmPzT3rJnSP8VFP1kw7Ly7HP8AprKNZtwLHXHnxfVSbWT3/go-libp2p-swarm/testing" - bhost "gx/ipfs/QmRvoAami8AAf5Yy6jcPq5KqQT1ZCaoi9dF1vdKAghmq9X/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmYj8wdn5sZEHX2XMDWGBvcXJNdzVbaVpHmXvhHBVZepen/go-libp2p-net" + swarmt "gx/ipfs/QmSvhbgtjQJKdT5avEeb7cvjYs7YrhebJyM1K6GAnkKgfd/go-libp2p-swarm/testing" + bhost "gx/ipfs/QmUEAR2pS7fP1GPseS3i8MWFyENs7oDp4CZrgn8FCjbsBu/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmXdgNhVEgjLxjUoMs5ViQL7pboAt3Y7V7eGHRiE4qrmTE/go-libp2p-net" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 934eb6b6ac2933b02440b9d6a33aa460b550993a Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 25 Jun 2018 20:41:25 -0700 Subject: [PATCH 303/674] gx update Updates: * go-kad-dht: Query performance improvements, DHT client fixes, validates records on *local* put. * go-libp2p-swarm/go-libp2p-transport: Timeout improvements. * go-multiaddr-net: Exposes useful Conn methods (CloseWrite, CloseRead, etc.) * go-log: fixes possible panic when enabling/disabling events. * go-multiaddr: fixes possible panic when stringifying malformed multiaddrs, adds support for consuming /p2p/ multiaddrs. fixes #5113 unblocks #4895 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@3eba14aa2420890032024b474320ec2fb6803092 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/corehttp.go | 6 +++--- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 4 ++-- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/logs.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 4ae80c38f..aac8937ec 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" - cmds "gx/ipfs/QmaFrNcnXHp579hUixbcTH1TNtNwsMogtBCwUUUwzBwYoM/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmaFrNcnXHp579hUixbcTH1TNtNwsMogtBCwUUUwzBwYoM/go-ipfs-cmds/http" + cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds/http" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 3e6e296f6..dfa0ed58b 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -11,10 +11,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - manet "gx/ipfs/QmNqRnejxJxjRroz7buhrjfU8i3yNBLa81hFtmf2pXEffN/go-multiaddr-net" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" - ma "gx/ipfs/QmUxSEGbv2nmYNnfXi7839wwQqTN3kwQeUxe8dTjZWZs7J/go-multiaddr" - logging "gx/ipfs/Qmbi1CTJsbnBZjCEgc2otwu8cUFPsGpzWXG7edVCLZ7Gvk/go-log" + manet "gx/ipfs/QmV6FjemM1K8oXjrvuq3wuVWWoU2TLDPmNnKrxHzY3v6Ai/go-multiaddr-net" + ma "gx/ipfs/QmYmsdtJ3HsodkePE3eU3TsCaP2YvPZJ4LoXnNkDE5Tpt7/go-multiaddr" + logging "gx/ipfs/QmcVVHfdyv15GVPk7NrxdWjh2hLVccXnoD8j2tyQShiXJb/go-log" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 272c1cc3e..62d3d5292 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmUEAR2pS7fP1GPseS3i8MWFyENs7oDp4CZrgn8FCjbsBu/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZ86eLPtXkQ1Dfa992Q8NpXArUoWWh3y728JDcWvzRrvC/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index e2fd4803e..8c4f2dc0d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -24,9 +24,9 @@ import ( uio "github.com/ipfs/go-ipfs/unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - chunker "gx/ipfs/QmR4G4WBNGA5S5pvjFiTkuehstC9769sLAHei8vZernhYR/go-ipfs-chunker" - routing "gx/ipfs/QmUV9hDAAyjeGbxbXkJ2sYqZ6dTd1DXJ2REhYEkRm178Tg/go-libp2p-routing" + routing "gx/ipfs/QmPpdpS9fknTBM3qHDcpayU6nYPZQeVjia2fbNrD8YWDe6/go-libp2p-routing" ipld "gx/ipfs/QmWi2BYBL5gJ3CiAiQchg6rn1A8iBsrWy51EYxvHVjFvLb/go-ipld-format" + chunker "gx/ipfs/QmXnzH7wowyLZy8XJxxaQCVTgLMcDXdMBznmsrmQWCyiQV/go-ipfs-chunker" cid "gx/ipfs/QmapdYm1b22Frv3k17fqrBYTFRxwiaVJkB299Mfn33edeB/go-cid" multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index e921b36b1..e1e026cd1 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,7 +20,7 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmUEAR2pS7fP1GPseS3i8MWFyENs7oDp4CZrgn8FCjbsBu/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmZ86eLPtXkQ1Dfa992Q8NpXArUoWWh3y728JDcWvzRrvC/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" datastore "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore" syncds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/sync" diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index ad9712a11..063e070cb 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - lwriter "gx/ipfs/Qmbi1CTJsbnBZjCEgc2otwu8cUFPsGpzWXG7edVCLZ7Gvk/go-log/writer" + lwriter "gx/ipfs/QmcVVHfdyv15GVPk7NrxdWjh2hLVccXnoD8j2tyQShiXJb/go-log/writer" ) type writeErrNotifier struct { diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 55deb8803..6ada8fd41 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - swarmt "gx/ipfs/QmSvhbgtjQJKdT5avEeb7cvjYs7YrhebJyM1K6GAnkKgfd/go-libp2p-swarm/testing" - bhost "gx/ipfs/QmUEAR2pS7fP1GPseS3i8MWFyENs7oDp4CZrgn8FCjbsBu/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmXdgNhVEgjLxjUoMs5ViQL7pboAt3Y7V7eGHRiE4qrmTE/go-libp2p-net" + inet "gx/ipfs/QmPjvxTpVH8qJyQDnxnsxF9kv9jezKD1kozz1hs3fCGsNh/go-libp2p-net" + swarmt "gx/ipfs/QmVqCSwuzgDfhLMTmFfUePTGX78PBjzuHcbSWWNPrnrmKy/go-libp2p-swarm/testing" + bhost "gx/ipfs/QmZ86eLPtXkQ1Dfa992Q8NpXArUoWWh3y728JDcWvzRrvC/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 2ccbcc6556859f96d55ace79bee57793632f5e78 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sat, 7 Jul 2018 00:18:30 -0700 Subject: [PATCH 304/674] correctly handle multi-hop dnslink resolution Namesys returns `ErrResolveRecursion` when it stops recursing due to a depth limit. It doesn't return success. Alternative to #5199. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@6a81c72cfb8d8c8e71307fb386e2ff3d3395df06 --- gateway/core/corehttp/gateway_test.go | 5 ++++- gateway/core/corehttp/ipns_hostname.go | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index e1e026cd1..900020cba 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -40,7 +40,10 @@ func (m mockNamesys) Resolve(ctx context.Context, name string, opts ...nsopts.Re if depth == nsopts.UnlimitedDepth { depth = math.MaxUint64 } - for depth > 0 && strings.HasPrefix(name, "/ipns/") { + for strings.HasPrefix(name, "/ipns/") { + if depth <= 0 { + return value, namesys.ErrResolveRecursion + } depth-- var ok bool diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 7bce62ad3..346acc6c3 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -7,6 +7,7 @@ import ( "strings" core "github.com/ipfs/go-ipfs/core" + namesys "github.com/ipfs/go-ipfs/namesys" nsopts "github.com/ipfs/go-ipfs/namesys/opts" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" @@ -25,7 +26,8 @@ func IPNSHostnameOption() ServeOption { host := strings.SplitN(r.Host, ":", 2)[0] if len(host) > 0 && isd.IsDomain(host) { name := "/ipns/" + host - if _, err := n.Namesys.Resolve(ctx, name, nsopts.Depth(1)); err == nil { + _, err := n.Namesys.Resolve(ctx, name, nsopts.Depth(1)) + if err == nil || err == namesys.ErrResolveRecursion { r.Header.Set("X-Ipns-Original-Path", r.URL.Path) r.URL.Path = name + r.URL.Path } From 1ee710d87b0fcb235024339074ee21e841a137a5 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 16 Jul 2018 15:16:49 -0700 Subject: [PATCH 305/674] update go-cid alternative to #5243 that updates go-cid and all packages that depend on it License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@9a9979b1938d7f69d5a3e19960ce0a49453e6bd6 --- gateway/core/corehttp/gateway_handler.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 8c4f2dc0d..a53c71f2a 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -24,10 +24,10 @@ import ( uio "github.com/ipfs/go-ipfs/unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - routing "gx/ipfs/QmPpdpS9fknTBM3qHDcpayU6nYPZQeVjia2fbNrD8YWDe6/go-libp2p-routing" - ipld "gx/ipfs/QmWi2BYBL5gJ3CiAiQchg6rn1A8iBsrWy51EYxvHVjFvLb/go-ipld-format" - chunker "gx/ipfs/QmXnzH7wowyLZy8XJxxaQCVTgLMcDXdMBznmsrmQWCyiQV/go-ipfs-chunker" - cid "gx/ipfs/QmapdYm1b22Frv3k17fqrBYTFRxwiaVJkB299Mfn33edeB/go-cid" + chunker "gx/ipfs/QmVDjhUMtkRskBFAVNwyXuLSKbeAya7JKPnzAxMKDaK4x4/go-ipfs-chunker" + cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid" + routing "gx/ipfs/QmZ383TySJVeZWzGnWui6pRcKyYZk9VkKTuW7tmKRWk5au/go-libp2p-routing" + ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format" multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase" ) From 4f8369b4b96dced603e23b4c60129abbf5e65e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 2 Feb 2018 16:00:37 +0100 Subject: [PATCH 306/674] coreapi: expand public path api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@338e90e9c8391828b362b84624811c764d14313b --- gateway/core/corehttp/gateway_handler.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index a53c71f2a..2f0303d26 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -13,7 +13,6 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - coreapi "github.com/ipfs/go-ipfs/core/coreapi" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/importer" dag "github.com/ipfs/go-ipfs/merkledag" @@ -160,7 +159,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr ipnsHostname = true } - parsedPath, err := coreapi.ParsePath(urlPath) + parsedPath, err := i.api.ParsePath(ctx, urlPath) if err != nil { webError(w, "invalid ipfs path", err, http.StatusBadRequest) return @@ -288,7 +287,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - dr, err := i.api.Unixfs().Cat(ctx, coreapi.ParseCid(ixnd.Cid())) + dr, err := i.api.Unixfs().Cat(ctx, i.api.ParseCid(ixnd.Cid())) if err != nil { internalWebError(w, err) return From 39491372a1a307731a5ff114af45ce2ec138677a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 30 Mar 2018 22:21:57 +0200 Subject: [PATCH 307/674] coreapi: remove ctx from ParsePath, split ParseCid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@f5f44ab246bb58d39372df88760722dd9e9f14e5 --- gateway/core/corehttp/gateway_handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 2f0303d26..0f148a495 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -159,7 +159,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr ipnsHostname = true } - parsedPath, err := i.api.ParsePath(ctx, urlPath) + parsedPath, err := i.api.ParsePath(urlPath) if err != nil { webError(w, "invalid ipfs path", err, http.StatusBadRequest) return @@ -287,7 +287,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - dr, err := i.api.Unixfs().Cat(ctx, i.api.ParseCid(ixnd.Cid())) + dr, err := i.api.Unixfs().Cat(ctx, i.api.IpfsPath(ixnd.Cid())) if err != nil { internalWebError(w, err) return From 0b4aaf81f13555ffa7461837020660dfa0162d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 6 Jun 2018 21:00:50 +0200 Subject: [PATCH 308/674] coreapi: fix TestGatewayGet after rebase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@0adb69a7734bb6b9e15c5f895341dd33206c5bc7 --- gateway/core/corehttp/gateway_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 900020cba..e8ac70783 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -171,7 +171,7 @@ func TestGatewayGet(t *testing.T) { {"working.example.com", "/", http.StatusOK, "fnord"}, {"double.example.com", "/", http.StatusOK, "fnord"}, {"triple.example.com", "/", http.StatusOK, "fnord"}, - {"working.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/working.example.com/ipfs/" + k + ": no link named \"ipfs\" under " + k + "\n"}, + {"working.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/working.example.com/ipfs/" + k + ": no link by that name\n"}, {"broken.example.com", "/", http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/: " + namesys.ErrResolveFailed.Error() + "\n"}, {"broken.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/ipfs/" + k + ": " + namesys.ErrResolveFailed.Error() + "\n"}, } { From 60949cd5965290ab6592fc430eb86c0e535be6d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 12 Jun 2018 03:52:26 +0200 Subject: [PATCH 309/674] coreapi: move path utils to interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@7adf1cb40d013ea9e6b1af09276542df8ace4bbc --- gateway/core/corehttp/gateway_handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 0f148a495..1236b30f5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -159,7 +159,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr ipnsHostname = true } - parsedPath, err := i.api.ParsePath(urlPath) + parsedPath, err := coreiface.ParsePath(urlPath) if err != nil { webError(w, "invalid ipfs path", err, http.StatusBadRequest) return @@ -287,7 +287,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - dr, err := i.api.Unixfs().Cat(ctx, i.api.IpfsPath(ixnd.Cid())) + dr, err := i.api.Unixfs().Cat(ctx, coreiface.IpfsPath(ixnd.Cid())) if err != nil { internalWebError(w, err) return From f3fb5ae8aedba6eadf9cb4eb663c2801141479f0 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 20 Jul 2018 21:07:58 -0700 Subject: [PATCH 310/674] gx update deps Updates: * go-net * go-text * dns * prometheus * protobuf (golang, not gogo) License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@53235242a1bf471725cd8a779ffa95b3fb6b7c4d --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 62d3d5292..b67511887 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmZ86eLPtXkQ1Dfa992Q8NpXArUoWWh3y728JDcWvzRrvC/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmY51bqSM5XgxQZqsBrQcRkKTnCb8EKpJpR9K6Qax7Njco/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index e8ac70783..d51932391 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,7 +20,7 @@ import ( repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmZ86eLPtXkQ1Dfa992Q8NpXArUoWWh3y728JDcWvzRrvC/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmY51bqSM5XgxQZqsBrQcRkKTnCb8EKpJpR9K6Qax7Njco/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" datastore "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore" syncds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/sync" diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 51a6c13ed..0428c8fd1 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -6,7 +6,7 @@ import ( core "github.com/ipfs/go-ipfs/core" - prometheus "gx/ipfs/QmX3QZ5jHEPidwUrymXV1iSCSUhdGxj15sm2gP4jKMef7B/client_golang/prometheus" + prometheus "gx/ipfs/QmYYv3QFnfQbiwmi1tpkgKF8o4xFnZoBrvpupTiGJwL9nH/client_golang/prometheus" ) // This adds the scraping endpoint which Prometheus uses to fetch metrics. diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 6ada8fd41..7e932c1a9 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -8,8 +8,8 @@ import ( core "github.com/ipfs/go-ipfs/core" inet "gx/ipfs/QmPjvxTpVH8qJyQDnxnsxF9kv9jezKD1kozz1hs3fCGsNh/go-libp2p-net" - swarmt "gx/ipfs/QmVqCSwuzgDfhLMTmFfUePTGX78PBjzuHcbSWWNPrnrmKy/go-libp2p-swarm/testing" - bhost "gx/ipfs/QmZ86eLPtXkQ1Dfa992Q8NpXArUoWWh3y728JDcWvzRrvC/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/QmY51bqSM5XgxQZqsBrQcRkKTnCb8EKpJpR9K6Qax7Njco/go-libp2p/p2p/host/basic" + swarmt "gx/ipfs/QmemVjhp1UuWPQqrWSvPcaqH3QJRMjMqNm4T2RULMkDDQe/go-libp2p-swarm/testing" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 89f30fd440172254210666d415eed28cf95a119e Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 27 Jul 2018 13:12:13 -0700 Subject: [PATCH 311/674] move dagutils package to top level in preparation for merkledag extraction License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@e78911ce94ef60049f3473654b5a5de3e9023d55 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1236b30f5..7e8635708 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -14,9 +14,9 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" + "github.com/ipfs/go-ipfs/dagutils" "github.com/ipfs/go-ipfs/importer" dag "github.com/ipfs/go-ipfs/merkledag" - dagutils "github.com/ipfs/go-ipfs/merkledag/utils" path "github.com/ipfs/go-ipfs/path" resolver "github.com/ipfs/go-ipfs/path/resolver" ft "github.com/ipfs/go-ipfs/unixfs" From fc3739c73c9a2aeb88e382797c254aa2b9ab92a3 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sat, 28 Jul 2018 00:50:53 -0700 Subject: [PATCH 312/674] Extract dagservice, move dagutils to top level License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@28fdee7fcec69900db627228d6855388a323f5a7 --- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 7e8635708..94aa8f64d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,11 +16,11 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" "github.com/ipfs/go-ipfs/importer" - dag "github.com/ipfs/go-ipfs/merkledag" path "github.com/ipfs/go-ipfs/path" resolver "github.com/ipfs/go-ipfs/path/resolver" ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" + dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" chunker "gx/ipfs/QmVDjhUMtkRskBFAVNwyXuLSKbeAya7JKPnzAxMKDaK4x4/go-ipfs-chunker" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index d51932391..55f850759 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -13,12 +13,12 @@ import ( core "github.com/ipfs/go-ipfs/core" coreunix "github.com/ipfs/go-ipfs/core/coreunix" - dag "github.com/ipfs/go-ipfs/merkledag" namesys "github.com/ipfs/go-ipfs/namesys" nsopts "github.com/ipfs/go-ipfs/namesys/opts" path "github.com/ipfs/go-ipfs/path" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" + dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag" id "gx/ipfs/QmY51bqSM5XgxQZqsBrQcRkKTnCb8EKpJpR9K6Qax7Njco/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" From 82b49c1b44856cb69a059bfaf46ae28f100edb60 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sat, 28 Jul 2018 23:57:42 -0700 Subject: [PATCH 313/674] Extract path and resolver License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@ede2caba468baff344052181c644682689a20c82 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 4 ++-- gateway/core/corehttp/gateway_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index aac8937ec..9105443e3 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -12,8 +12,8 @@ import ( oldcmds "github.com/ipfs/go-ipfs/commands" core "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - path "github.com/ipfs/go-ipfs/path" config "github.com/ipfs/go-ipfs/repo/config" + path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path" cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds/http" diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 94aa8f64d..622136299 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,11 +16,11 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" "github.com/ipfs/go-ipfs/importer" - path "github.com/ipfs/go-ipfs/path" - resolver "github.com/ipfs/go-ipfs/path/resolver" ft "github.com/ipfs/go-ipfs/unixfs" uio "github.com/ipfs/go-ipfs/unixfs/io" dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag" + path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path" + resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" chunker "gx/ipfs/QmVDjhUMtkRskBFAVNwyXuLSKbeAya7JKPnzAxMKDaK4x4/go-ipfs-chunker" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 55f850759..829d0b592 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -15,10 +15,10 @@ import ( coreunix "github.com/ipfs/go-ipfs/core/coreunix" namesys "github.com/ipfs/go-ipfs/namesys" nsopts "github.com/ipfs/go-ipfs/namesys/opts" - path "github.com/ipfs/go-ipfs/path" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag" + path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path" id "gx/ipfs/QmY51bqSM5XgxQZqsBrQcRkKTnCb8EKpJpR9K6Qax7Njco/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" From 5e0592381b13401f1cd11e7983fc179dc2d01e62 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 30 Jul 2018 14:35:15 -0700 Subject: [PATCH 314/674] extract go-unixfs (importers and unixfs) License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@b96a7a0579c1b94828cfe544c9a9f0b0830fefc6 --- gateway/core/corehttp/gateway_handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 622136299..8f47d79da 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,10 +15,10 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - "github.com/ipfs/go-ipfs/importer" - ft "github.com/ipfs/go-ipfs/unixfs" - uio "github.com/ipfs/go-ipfs/unixfs/io" dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag" + ft "gx/ipfs/QmSaz8Qg77gGqvDvLKeSAY7ivDEnramSWF6T7TcRwFpHtP/go-unixfs" + "gx/ipfs/QmSaz8Qg77gGqvDvLKeSAY7ivDEnramSWF6T7TcRwFpHtP/go-unixfs/importer" + uio "gx/ipfs/QmSaz8Qg77gGqvDvLKeSAY7ivDEnramSWF6T7TcRwFpHtP/go-unixfs/io" path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path" resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver" From 483e1f4e4e48553fe8edbd0188f4267254095dfe Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 31 Jul 2018 12:45:39 -0700 Subject: [PATCH 315/674] wait for all connections to close before exiting on shutdown. Using httpServer.Shutdown will: 1. Close the listener (preventing new connections). 2. Close each connection as outstanding requests finish. This prevent us from shutting down before outstanding requests get a chance to respond. fixes #4055 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@00158c4b9240fa62743220f288a8c40fd4e850d6 --- gateway/core/corehttp/corehttp.go | 56 ++++++++++++++++++------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index dfa0ed58b..ee24953c4 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -5,6 +5,7 @@ high-level HTTP interfaces to IPFS. package corehttp import ( + "context" "fmt" "net" "net/http" @@ -12,6 +13,7 @@ import ( core "github.com/ipfs/go-ipfs/core" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" + periodicproc "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/periodic" manet "gx/ipfs/QmV6FjemM1K8oXjrvuq3wuVWWoU2TLDPmNnKrxHzY3v6Ai/go-multiaddr-net" ma "gx/ipfs/QmYmsdtJ3HsodkePE3eU3TsCaP2YvPZJ4LoXnNkDE5Tpt7/go-multiaddr" logging "gx/ipfs/QmcVVHfdyv15GVPk7NrxdWjh2hLVccXnoD8j2tyQShiXJb/go-log" @@ -19,6 +21,10 @@ import ( var log = logging.Logger("core/server") +// shutdownTimeout is the timeout after which we'll stop waiting for hung +// commands to return on shutdown. +const shutdownTimeout = 30 * time.Second + // ServeOption registers any HTTP handlers it provides on the given mux. // It returns the mux to expose to future options, which may be a new mux if it // is interested in mediating requests to future options, or the same mux @@ -65,6 +71,9 @@ func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...Serv } func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error { + // make sure we close this no matter what. + defer lis.Close() + handler, err := makeHandler(node, lis, options...) if err != nil { return err @@ -75,43 +84,44 @@ func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error return err } - // if the server exits beforehand - var serverError error - serverExited := make(chan struct{}) - select { case <-node.Process().Closing(): return fmt.Errorf("failed to start server, process closing") default: } - node.Process().Go(func(p goprocess.Process) { - serverError = http.Serve(lis, handler) - close(serverExited) + server := &http.Server{ + Handler: handler, + } + + var serverError error + serverProc := node.Process().Go(func(p goprocess.Process) { + serverError = server.Serve(lis) }) // wait for server to exit. select { - case <-serverExited: - + case <-serverProc.Closed(): // if node being closed before server exits, close server case <-node.Process().Closing(): log.Infof("server at %s terminating...", addr) - lis.Close() - - outer: - for { - // wait until server exits - select { - case <-serverExited: - // if the server exited as we are closing, we really dont care about errors - serverError = nil - break outer - case <-time.After(5 * time.Second): - log.Infof("waiting for server at %s to terminate...", addr) - } - } + warnProc := periodicproc.Tick(5*time.Second, func(_ goprocess.Process) { + log.Infof("waiting for server at %s to terminate...", addr) + }) + + // This timeout shouldn't be necessary if all of our commands + // are obeying their contexts but we should have *some* timeout. + ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout) + defer cancel() + err := server.Shutdown(ctx) + + // Should have already closed but we still need to wait for it + // to set the error. + <-serverProc.Closed() + serverError = err + + warnProc.Close() } log.Infof("server at %s terminated", addr) From f1ae1ccb044ead99b73db2b240a295b8a1c5bb78 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 5 Aug 2018 13:22:51 -0700 Subject: [PATCH 316/674] Update bitswap deps License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@042a9729a227f5ee7be049ea0bef5142a86d44c8 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 9105443e3..f00bc4f59 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -13,7 +13,7 @@ import ( core "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" config "github.com/ipfs/go-ipfs/repo/config" - path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path" + path "gx/ipfs/Qme34dT9spiPgunbueNtziRX4SvfLHDFZQvmTBVK8p4qNT/go-path" cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds/http" diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 8f47d79da..b40fb3919 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,12 +15,12 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag" - ft "gx/ipfs/QmSaz8Qg77gGqvDvLKeSAY7ivDEnramSWF6T7TcRwFpHtP/go-unixfs" - "gx/ipfs/QmSaz8Qg77gGqvDvLKeSAY7ivDEnramSWF6T7TcRwFpHtP/go-unixfs/importer" - uio "gx/ipfs/QmSaz8Qg77gGqvDvLKeSAY7ivDEnramSWF6T7TcRwFpHtP/go-unixfs/io" - path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path" - resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver" + ft "gx/ipfs/QmWdTRLi3H7ZJQ8s7NYo8oitz5JHEEPKLn1QPMsJVWg2Ew/go-unixfs" + "gx/ipfs/QmWdTRLi3H7ZJQ8s7NYo8oitz5JHEEPKLn1QPMsJVWg2Ew/go-unixfs/importer" + uio "gx/ipfs/QmWdTRLi3H7ZJQ8s7NYo8oitz5JHEEPKLn1QPMsJVWg2Ew/go-unixfs/io" + dag "gx/ipfs/Qma2BR57Wqp8w9vPreK4dEzoXXk8DFFRL3LresMZg4QpzN/go-merkledag" + path "gx/ipfs/Qme34dT9spiPgunbueNtziRX4SvfLHDFZQvmTBVK8p4qNT/go-path" + resolver "gx/ipfs/Qme34dT9spiPgunbueNtziRX4SvfLHDFZQvmTBVK8p4qNT/go-path/resolver" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" chunker "gx/ipfs/QmVDjhUMtkRskBFAVNwyXuLSKbeAya7JKPnzAxMKDaK4x4/go-ipfs-chunker" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 829d0b592..8df99d31e 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,8 +17,8 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" - dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag" - path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path" + dag "gx/ipfs/Qma2BR57Wqp8w9vPreK4dEzoXXk8DFFRL3LresMZg4QpzN/go-merkledag" + path "gx/ipfs/Qme34dT9spiPgunbueNtziRX4SvfLHDFZQvmTBVK8p4qNT/go-path" id "gx/ipfs/QmY51bqSM5XgxQZqsBrQcRkKTnCb8EKpJpR9K6Qax7Njco/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" From 1c846f70b3f6c297dc9daeb08fe9858d77dc87aa Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 6 Aug 2018 22:10:53 -0700 Subject: [PATCH 317/674] gx: update deps License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@3e13277dd408d10d5fbeda8be9875096b8b330f4 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index f00bc4f59..fe741249b 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -13,7 +13,7 @@ import ( core "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" config "github.com/ipfs/go-ipfs/repo/config" - path "gx/ipfs/Qme34dT9spiPgunbueNtziRX4SvfLHDFZQvmTBVK8p4qNT/go-path" + path "gx/ipfs/QmY2QaawxgJw2rn7WsFNkWEYph3z2azpyYdrhAc1JctDmE/go-path" cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds/http" diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index b40fb3919..5f9a6f144 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,12 +15,12 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - ft "gx/ipfs/QmWdTRLi3H7ZJQ8s7NYo8oitz5JHEEPKLn1QPMsJVWg2Ew/go-unixfs" - "gx/ipfs/QmWdTRLi3H7ZJQ8s7NYo8oitz5JHEEPKLn1QPMsJVWg2Ew/go-unixfs/importer" - uio "gx/ipfs/QmWdTRLi3H7ZJQ8s7NYo8oitz5JHEEPKLn1QPMsJVWg2Ew/go-unixfs/io" - dag "gx/ipfs/Qma2BR57Wqp8w9vPreK4dEzoXXk8DFFRL3LresMZg4QpzN/go-merkledag" - path "gx/ipfs/Qme34dT9spiPgunbueNtziRX4SvfLHDFZQvmTBVK8p4qNT/go-path" - resolver "gx/ipfs/Qme34dT9spiPgunbueNtziRX4SvfLHDFZQvmTBVK8p4qNT/go-path/resolver" + ft "gx/ipfs/QmVxjT67BU1QZUPzSLNZT6DkDzVNfPfkzqNyJYFXxSH2hA/go-unixfs" + "gx/ipfs/QmVxjT67BU1QZUPzSLNZT6DkDzVNfPfkzqNyJYFXxSH2hA/go-unixfs/importer" + uio "gx/ipfs/QmVxjT67BU1QZUPzSLNZT6DkDzVNfPfkzqNyJYFXxSH2hA/go-unixfs/io" + path "gx/ipfs/QmY2QaawxgJw2rn7WsFNkWEYph3z2azpyYdrhAc1JctDmE/go-path" + resolver "gx/ipfs/QmY2QaawxgJw2rn7WsFNkWEYph3z2azpyYdrhAc1JctDmE/go-path/resolver" + dag "gx/ipfs/QmfKKGzisaoP4oiHQSHz1zLbXDCTeXe7NVfX1FAMKzcHmt/go-merkledag" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" chunker "gx/ipfs/QmVDjhUMtkRskBFAVNwyXuLSKbeAya7JKPnzAxMKDaK4x4/go-ipfs-chunker" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 8df99d31e..c2764f16a 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,8 +17,8 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" - dag "gx/ipfs/Qma2BR57Wqp8w9vPreK4dEzoXXk8DFFRL3LresMZg4QpzN/go-merkledag" - path "gx/ipfs/Qme34dT9spiPgunbueNtziRX4SvfLHDFZQvmTBVK8p4qNT/go-path" + path "gx/ipfs/QmY2QaawxgJw2rn7WsFNkWEYph3z2azpyYdrhAc1JctDmE/go-path" + dag "gx/ipfs/QmfKKGzisaoP4oiHQSHz1zLbXDCTeXe7NVfX1FAMKzcHmt/go-merkledag" id "gx/ipfs/QmY51bqSM5XgxQZqsBrQcRkKTnCb8EKpJpR9K6Qax7Njco/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" From af87a8c2a35f48fc1d2337d2981201d6c0772d4f Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 8 Aug 2018 18:51:17 -0700 Subject: [PATCH 318/674] update gogo-protobuf fixes #3214 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@594d95af5d28950db1b0eac796f117d3fbff681c --- gateway/core/corehttp/commands.go | 6 +++--- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 16 ++++++++-------- gateway/core/corehttp/gateway_test.go | 8 ++++---- gateway/core/corehttp/logs.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index fe741249b..1eed5666a 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -13,10 +13,10 @@ import ( core "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" config "github.com/ipfs/go-ipfs/repo/config" - path "gx/ipfs/QmY2QaawxgJw2rn7WsFNkWEYph3z2azpyYdrhAc1JctDmE/go-path" + path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" - cmds "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmNueRyPRQiV7PUEpnP4GgGLuK1rKQLaRW7sfPvUetYig1/go-ipfs-cmds/http" + cmds "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds/http" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index ee24953c4..f5bb0882e 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,11 +12,11 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + logging "gx/ipfs/QmRREK2CAZ5Re2Bd9zZFG6FeYDppUWt5cMgsoUEp3ktgSr/go-log" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" periodicproc "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/periodic" manet "gx/ipfs/QmV6FjemM1K8oXjrvuq3wuVWWoU2TLDPmNnKrxHzY3v6Ai/go-multiaddr-net" ma "gx/ipfs/QmYmsdtJ3HsodkePE3eU3TsCaP2YvPZJ4LoXnNkDE5Tpt7/go-multiaddr" - logging "gx/ipfs/QmcVVHfdyv15GVPk7NrxdWjh2hLVccXnoD8j2tyQShiXJb/go-log" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index b67511887..78c57773e 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" config "github.com/ipfs/go-ipfs/repo/config" - id "gx/ipfs/QmY51bqSM5XgxQZqsBrQcRkKTnCb8EKpJpR9K6Qax7Njco/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 5f9a6f144..94c918dc2 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,18 +15,18 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - ft "gx/ipfs/QmVxjT67BU1QZUPzSLNZT6DkDzVNfPfkzqNyJYFXxSH2hA/go-unixfs" - "gx/ipfs/QmVxjT67BU1QZUPzSLNZT6DkDzVNfPfkzqNyJYFXxSH2hA/go-unixfs/importer" - uio "gx/ipfs/QmVxjT67BU1QZUPzSLNZT6DkDzVNfPfkzqNyJYFXxSH2hA/go-unixfs/io" - path "gx/ipfs/QmY2QaawxgJw2rn7WsFNkWEYph3z2azpyYdrhAc1JctDmE/go-path" - resolver "gx/ipfs/QmY2QaawxgJw2rn7WsFNkWEYph3z2azpyYdrhAc1JctDmE/go-path/resolver" - dag "gx/ipfs/QmfKKGzisaoP4oiHQSHz1zLbXDCTeXe7NVfX1FAMKzcHmt/go-merkledag" + path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" + resolver "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path/resolver" + ft "gx/ipfs/QmWJRM6rLjXGEXb5JkKu17Y68eJtCFcKPyRhb8JH2ELZ2Q/go-unixfs" + "gx/ipfs/QmWJRM6rLjXGEXb5JkKu17Y68eJtCFcKPyRhb8JH2ELZ2Q/go-unixfs/importer" + uio "gx/ipfs/QmWJRM6rLjXGEXb5JkKu17Y68eJtCFcKPyRhb8JH2ELZ2Q/go-unixfs/io" + dag "gx/ipfs/QmXkZeJmx4c3ddjw81DQMUpM1e5LjAack5idzZYWUb2qAJ/go-merkledag" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - chunker "gx/ipfs/QmVDjhUMtkRskBFAVNwyXuLSKbeAya7JKPnzAxMKDaK4x4/go-ipfs-chunker" cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid" - routing "gx/ipfs/QmZ383TySJVeZWzGnWui6pRcKyYZk9VkKTuW7tmKRWk5au/go-libp2p-routing" ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format" + chunker "gx/ipfs/Qmc3UwSvJkntxu2gKDPCqJEzmhqVeJtTbrVxJm6tsdmMF1/go-ipfs-chunker" + routing "gx/ipfs/QmewrvpGvgK9qkCtXsGNwXiQzyux4jcHNjoyVrGdsgtNK5/go-libp2p-routing" multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index c2764f16a..a74bb6a5d 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,11 +17,11 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" config "github.com/ipfs/go-ipfs/repo/config" - path "gx/ipfs/QmY2QaawxgJw2rn7WsFNkWEYph3z2azpyYdrhAc1JctDmE/go-path" - dag "gx/ipfs/QmfKKGzisaoP4oiHQSHz1zLbXDCTeXe7NVfX1FAMKzcHmt/go-merkledag" + path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" + dag "gx/ipfs/QmXkZeJmx4c3ddjw81DQMUpM1e5LjAack5idzZYWUb2qAJ/go-merkledag" - id "gx/ipfs/QmY51bqSM5XgxQZqsBrQcRkKTnCb8EKpJpR9K6Qax7Njco/go-libp2p/p2p/protocol/identify" - ci "gx/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5/go-libp2p-crypto" + ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" + id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" datastore "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore" syncds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/sync" ) diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 063e070cb..d0829de12 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - lwriter "gx/ipfs/QmcVVHfdyv15GVPk7NrxdWjh2hLVccXnoD8j2tyQShiXJb/go-log/writer" + lwriter "gx/ipfs/QmRREK2CAZ5Re2Bd9zZFG6FeYDppUWt5cMgsoUEp3ktgSr/go-log/writer" ) type writeErrNotifier struct { diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 7e932c1a9..dc09ef470 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - inet "gx/ipfs/QmPjvxTpVH8qJyQDnxnsxF9kv9jezKD1kozz1hs3fCGsNh/go-libp2p-net" - bhost "gx/ipfs/QmY51bqSM5XgxQZqsBrQcRkKTnCb8EKpJpR9K6Qax7Njco/go-libp2p/p2p/host/basic" - swarmt "gx/ipfs/QmemVjhp1UuWPQqrWSvPcaqH3QJRMjMqNm4T2RULMkDDQe/go-libp2p-swarm/testing" + bhost "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmVwU7Mgwg6qaPn9XXz93ANfq1PTxcduGRzfe41Sygg4mR/go-libp2p-net" + swarmt "gx/ipfs/QmdjC8HtKZpEufBL1u7WxvQn78Lqq2Wk31NJS8WvFX3crB/go-libp2p-swarm/testing" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From d646a12aaea2b1f7cf395b796d29f32bcc03e98e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 23 Jul 2018 16:44:29 +0200 Subject: [PATCH 319/674] Update imports to point to go-ipfs-config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@6fcd205e20c08ec24d61bd616a08832abdb3775d --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 1eed5666a..9318f7110 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -12,11 +12,11 @@ import ( oldcmds "github.com/ipfs/go-ipfs/commands" core "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - config "github.com/ipfs/go-ipfs/repo/config" - path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" + path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" cmds "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds/http" + config "gx/ipfs/QmbfPqH4QFLQWdfXa111eBKgdTiLkZv2Pc4Qpm2byUeByU/go-ipfs-config" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 78c57773e..4b2f0cd8e 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - config "github.com/ipfs/go-ipfs/repo/config" id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" + config "gx/ipfs/QmbfPqH4QFLQWdfXa111eBKgdTiLkZv2Pc4Qpm2byUeByU/go-ipfs-config" ) type GatewayConfig struct { From ea410fea13205c23ec8a3902b0a7f4797921216f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 23 Jul 2018 19:11:39 +0200 Subject: [PATCH 320/674] repo: move version.go back here MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@b65cf84a34508761e610cc4ab37b5e636bdbcc51 --- gateway/core/corehttp/commands.go | 7 ++++--- gateway/core/corehttp/gateway.go | 4 ++-- gateway/core/corehttp/gateway_test.go | 6 +++--- gateway/core/corehttp/option_test.go | 6 +++--- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 9318f7110..905d48c8f 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -12,11 +12,12 @@ import ( oldcmds "github.com/ipfs/go-ipfs/commands" core "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + repo "github.com/ipfs/go-ipfs/repo" path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" cmds "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds/http" - config "gx/ipfs/QmbfPqH4QFLQWdfXa111eBKgdTiLkZv2Pc4Qpm2byUeByU/go-ipfs-config" + config "gx/ipfs/QmSzU7M24odFR3icDsAK8P8SQoaELzDFv3n3fTPy2grrEL/go-ipfs-config" ) var ( @@ -77,7 +78,7 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { for h, v := range nc.API.HTTPHeaders { c.Headers[h] = v } - c.Headers["Server"] = []string{"go-ipfs/" + config.CurrentVersionNumber} + c.Headers["Server"] = []string{"go-ipfs/" + repo.CurrentVersionNumber} } func addCORSDefaults(c *cmdsHttp.ServerConfig) { @@ -152,7 +153,7 @@ func CommandsROOption(cctx oldcmds.Context) ServeOption { // CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/go-ipfs/` func CheckVersionOption() ServeOption { - daemonVersion := config.ApiVersion + daemonVersion := repo.ApiVersion return ServeOption(func(n *core.IpfsNode, l net.Listener, parent *http.ServeMux) (*http.ServeMux, error) { mux := http.NewServeMux() diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 4b2f0cd8e..f9db2a23d 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" + repo "github.com/ipfs/go-ipfs/repo" id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" - config "gx/ipfs/QmbfPqH4QFLQWdfXa111eBKgdTiLkZv2Pc4Qpm2byUeByU/go-ipfs-config" ) type GatewayConfig struct { @@ -41,7 +41,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { func VersionOption() ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, "Commit: %s\n", config.CurrentCommit) + fmt.Fprintf(w, "Commit: %s\n", repo.CurrentCommit) fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion) fmt.Fprintf(w, "Protocol Version: %s\n", id.LibP2PVersion) }) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index a74bb6a5d..9c1b53180 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,12 +16,12 @@ import ( namesys "github.com/ipfs/go-ipfs/namesys" nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" - config "github.com/ipfs/go-ipfs/repo/config" + path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" dag "gx/ipfs/QmXkZeJmx4c3ddjw81DQMUpM1e5LjAack5idzZYWUb2qAJ/go-merkledag" - ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" + config "gx/ipfs/QmSzU7M24odFR3icDsAK8P8SQoaELzDFv3n3fTPy2grrEL/go-ipfs-config" datastore "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore" syncds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/sync" ) @@ -545,7 +545,7 @@ func TestGoGetSupport(t *testing.T) { } func TestVersion(t *testing.T) { - config.CurrentCommit = "theshortcommithash" + repo.CurrentCommit = "theshortcommithash" ns := mockNamesys{} ts, _ := newTestServerAndNode(t, ns) diff --git a/gateway/core/corehttp/option_test.go b/gateway/core/corehttp/option_test.go index c600a0603..ecc572eaa 100644 --- a/gateway/core/corehttp/option_test.go +++ b/gateway/core/corehttp/option_test.go @@ -7,7 +7,7 @@ import ( "net/http/httptest" "testing" - config "github.com/ipfs/go-ipfs/repo/config" + "github.com/ipfs/go-ipfs/repo" ) type testcasecheckversion struct { @@ -20,7 +20,7 @@ type testcasecheckversion struct { func (tc testcasecheckversion) body() string { if !tc.shouldHandle && tc.responseBody == "" { - return fmt.Sprintf("%s (%s != %s)\n", errAPIVersionMismatch, config.ApiVersion, tc.userAgent) + return fmt.Sprintf("%s (%s != %s)\n", errAPIVersionMismatch, repo.ApiVersion, tc.userAgent) } return tc.responseBody @@ -30,7 +30,7 @@ func TestCheckVersionOption(t *testing.T) { tcs := []testcasecheckversion{ {"/go-ipfs/0.1/", APIPath + "/test/", false, "", http.StatusBadRequest}, {"/go-ipfs/0.1/", APIPath + "/version", true, "check!", http.StatusOK}, - {config.ApiVersion, APIPath + "/test", true, "check!", http.StatusOK}, + {repo.ApiVersion, APIPath + "/test", true, "check!", http.StatusOK}, {"Mozilla Firefox/no go-ipfs node", APIPath + "/test", true, "check!", http.StatusOK}, {"/go-ipfs/0.1/", "/webui", true, "check!", http.StatusOK}, } From fc721d3d51c1d229add3a9fe776269050c1c2063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 24 Jul 2018 01:29:43 +0200 Subject: [PATCH 321/674] Update iptb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@d52091fa55dea3523c5229d3423691ec220f786d --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 905d48c8f..ce602abf6 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -17,7 +17,7 @@ import ( path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" cmds "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds/http" - config "gx/ipfs/QmSzU7M24odFR3icDsAK8P8SQoaELzDFv3n3fTPy2grrEL/go-ipfs-config" + config "gx/ipfs/QmYyFh6g1C9uieTpH8CR8PpWBUQjvMDJTsRhJWx5qkXy39/go-ipfs-config" ) var ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 9c1b53180..522b07927 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -21,7 +21,7 @@ import ( dag "gx/ipfs/QmXkZeJmx4c3ddjw81DQMUpM1e5LjAack5idzZYWUb2qAJ/go-merkledag" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" - config "gx/ipfs/QmSzU7M24odFR3icDsAK8P8SQoaELzDFv3n3fTPy2grrEL/go-ipfs-config" + config "gx/ipfs/QmYyFh6g1C9uieTpH8CR8PpWBUQjvMDJTsRhJWx5qkXy39/go-ipfs-config" datastore "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore" syncds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/sync" ) From 5ddddc16b7cadb61080ecbf2f4c48c36fd93d46c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 25 Jul 2018 10:27:20 +0200 Subject: [PATCH 322/674] move version.go to top level package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@ffc74391d5b14af149b74e11fb6f37d0812ad404 --- gateway/core/corehttp/commands.go | 8 ++++---- gateway/core/corehttp/gateway.go | 4 ++-- gateway/core/corehttp/gateway_test.go | 3 ++- gateway/core/corehttp/option_test.go | 6 +++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index ce602abf6..f779018b3 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -9,10 +9,10 @@ import ( "strconv" "strings" + version "github.com/ipfs/go-ipfs" oldcmds "github.com/ipfs/go-ipfs/commands" - core "github.com/ipfs/go-ipfs/core" + "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - repo "github.com/ipfs/go-ipfs/repo" path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" cmds "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds" @@ -78,7 +78,7 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { for h, v := range nc.API.HTTPHeaders { c.Headers[h] = v } - c.Headers["Server"] = []string{"go-ipfs/" + repo.CurrentVersionNumber} + c.Headers["Server"] = []string{"go-ipfs/" + version.CurrentVersionNumber} } func addCORSDefaults(c *cmdsHttp.ServerConfig) { @@ -153,7 +153,7 @@ func CommandsROOption(cctx oldcmds.Context) ServeOption { // CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/go-ipfs/` func CheckVersionOption() ServeOption { - daemonVersion := repo.ApiVersion + daemonVersion := version.ApiVersion return ServeOption(func(n *core.IpfsNode, l net.Listener, parent *http.ServeMux) (*http.ServeMux, error) { mux := http.NewServeMux() diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index f9db2a23d..acdea180d 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -5,9 +5,9 @@ import ( "net" "net/http" + version "github.com/ipfs/go-ipfs" core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - repo "github.com/ipfs/go-ipfs/repo" id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" ) @@ -41,7 +41,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { func VersionOption() ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, "Commit: %s\n", repo.CurrentCommit) + fmt.Fprintf(w, "Commit: %s\n", version.CurrentCommit) fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion) fmt.Fprintf(w, "Protocol Version: %s\n", id.LibP2PVersion) }) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 522b07927..86631a5f8 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -11,6 +11,7 @@ import ( "testing" "time" + version "github.com/ipfs/go-ipfs" core "github.com/ipfs/go-ipfs/core" coreunix "github.com/ipfs/go-ipfs/core/coreunix" namesys "github.com/ipfs/go-ipfs/namesys" @@ -545,7 +546,7 @@ func TestGoGetSupport(t *testing.T) { } func TestVersion(t *testing.T) { - repo.CurrentCommit = "theshortcommithash" + version.CurrentCommit = "theshortcommithash" ns := mockNamesys{} ts, _ := newTestServerAndNode(t, ns) diff --git a/gateway/core/corehttp/option_test.go b/gateway/core/corehttp/option_test.go index ecc572eaa..22157618c 100644 --- a/gateway/core/corehttp/option_test.go +++ b/gateway/core/corehttp/option_test.go @@ -7,7 +7,7 @@ import ( "net/http/httptest" "testing" - "github.com/ipfs/go-ipfs/repo" + version "github.com/ipfs/go-ipfs" ) type testcasecheckversion struct { @@ -20,7 +20,7 @@ type testcasecheckversion struct { func (tc testcasecheckversion) body() string { if !tc.shouldHandle && tc.responseBody == "" { - return fmt.Sprintf("%s (%s != %s)\n", errAPIVersionMismatch, repo.ApiVersion, tc.userAgent) + return fmt.Sprintf("%s (%s != %s)\n", errAPIVersionMismatch, version.ApiVersion, tc.userAgent) } return tc.responseBody @@ -30,7 +30,7 @@ func TestCheckVersionOption(t *testing.T) { tcs := []testcasecheckversion{ {"/go-ipfs/0.1/", APIPath + "/test/", false, "", http.StatusBadRequest}, {"/go-ipfs/0.1/", APIPath + "/version", true, "check!", http.StatusOK}, - {repo.ApiVersion, APIPath + "/test", true, "check!", http.StatusOK}, + {version.ApiVersion, APIPath + "/test", true, "check!", http.StatusOK}, {"Mozilla Firefox/no go-ipfs node", APIPath + "/test", true, "check!", http.StatusOK}, {"/go-ipfs/0.1/", "/webui", true, "check!", http.StatusOK}, } From 69b937f8ae218e7624ab7b0c232f3a0ff461f1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 9 Aug 2018 12:06:10 +0200 Subject: [PATCH 323/674] gx: Update config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@838a30cd2272aded16f2298551c5bc0ae4b5c23a --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index f779018b3..6b1b94330 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,9 +15,9 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" + config "gx/ipfs/QmRwCaRYotCqXsVZAXwWhEJ8A74iAaKnY7MUe6sDgFjrE5/go-ipfs-config" cmds "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds/http" - config "gx/ipfs/QmYyFh6g1C9uieTpH8CR8PpWBUQjvMDJTsRhJWx5qkXy39/go-ipfs-config" ) var ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 86631a5f8..7e2103970 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,10 +19,10 @@ import ( repo "github.com/ipfs/go-ipfs/repo" path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" - dag "gx/ipfs/QmXkZeJmx4c3ddjw81DQMUpM1e5LjAack5idzZYWUb2qAJ/go-merkledag" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" + config "gx/ipfs/QmRwCaRYotCqXsVZAXwWhEJ8A74iAaKnY7MUe6sDgFjrE5/go-ipfs-config" id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" - config "gx/ipfs/QmYyFh6g1C9uieTpH8CR8PpWBUQjvMDJTsRhJWx5qkXy39/go-ipfs-config" + dag "gx/ipfs/QmXkZeJmx4c3ddjw81DQMUpM1e5LjAack5idzZYWUb2qAJ/go-merkledag" datastore "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore" syncds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/sync" ) From 799ad76530fcd7b09b132c44bea69afbc96fc026 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 10 Aug 2018 17:21:28 -0700 Subject: [PATCH 324/674] update cmdkit to fix the progress bar The progressbar should now correctly calculate the size of a directory (by ignoring the directory sizes). fixes #5288 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@f0769366f10649f3cb9470f70e5ee8b13d90ae07 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 6b1b94330..471379996 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -16,8 +16,8 @@ import ( path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" config "gx/ipfs/QmRwCaRYotCqXsVZAXwWhEJ8A74iAaKnY7MUe6sDgFjrE5/go-ipfs-config" - cmds "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds/http" + cmds "gx/ipfs/QmUQb3xtNzkQCgTj2NjaqcJZNv2nfSSub2QAdy9DtQMRBT/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmUQb3xtNzkQCgTj2NjaqcJZNv2nfSSub2QAdy9DtQMRBT/go-ipfs-cmds/http" ) var ( diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 94c918dc2..8f743f70e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -17,10 +17,10 @@ import ( "github.com/ipfs/go-ipfs/dagutils" path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" resolver "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path/resolver" - ft "gx/ipfs/QmWJRM6rLjXGEXb5JkKu17Y68eJtCFcKPyRhb8JH2ELZ2Q/go-unixfs" - "gx/ipfs/QmWJRM6rLjXGEXb5JkKu17Y68eJtCFcKPyRhb8JH2ELZ2Q/go-unixfs/importer" - uio "gx/ipfs/QmWJRM6rLjXGEXb5JkKu17Y68eJtCFcKPyRhb8JH2ELZ2Q/go-unixfs/io" dag "gx/ipfs/QmXkZeJmx4c3ddjw81DQMUpM1e5LjAack5idzZYWUb2qAJ/go-merkledag" + ft "gx/ipfs/Qmdqe1sKBpz6W8xFDptGfmzgCPQ5CXNuQPhZeELqMowgsQ/go-unixfs" + "gx/ipfs/Qmdqe1sKBpz6W8xFDptGfmzgCPQ5CXNuQPhZeELqMowgsQ/go-unixfs/importer" + uio "gx/ipfs/Qmdqe1sKBpz6W8xFDptGfmzgCPQ5CXNuQPhZeELqMowgsQ/go-unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid" From 3b6bb31c158f5304ead69b71e2533c3d2d44f698 Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Sun, 12 Aug 2018 19:15:07 -0400 Subject: [PATCH 325/674] Gx updates and fixes to use new cid.Builder interface. License: MIT Signed-off-by: Kevin Atkinson This commit was moved from ipfs/kubo@075ecb09d0189cf4c9107c9549d6a42f946aac65 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 22 +++++++++++----------- gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 471379996..7e5988c0d 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,8 +14,8 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" config "gx/ipfs/QmRwCaRYotCqXsVZAXwWhEJ8A74iAaKnY7MUe6sDgFjrE5/go-ipfs-config" + path "gx/ipfs/QmTG5WFmAM4uAnqGskeAPijdpTmmNDLJNCQ71NqfdvC6hV/go-path" cmds "gx/ipfs/QmUQb3xtNzkQCgTj2NjaqcJZNv2nfSSub2QAdy9DtQMRBT/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmUQb3xtNzkQCgTj2NjaqcJZNv2nfSSub2QAdy9DtQMRBT/go-ipfs-cmds/http" ) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 8f743f70e..6b2a88ced 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,19 +15,19 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" - resolver "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path/resolver" - dag "gx/ipfs/QmXkZeJmx4c3ddjw81DQMUpM1e5LjAack5idzZYWUb2qAJ/go-merkledag" - ft "gx/ipfs/Qmdqe1sKBpz6W8xFDptGfmzgCPQ5CXNuQPhZeELqMowgsQ/go-unixfs" - "gx/ipfs/Qmdqe1sKBpz6W8xFDptGfmzgCPQ5CXNuQPhZeELqMowgsQ/go-unixfs/importer" - uio "gx/ipfs/Qmdqe1sKBpz6W8xFDptGfmzgCPQ5CXNuQPhZeELqMowgsQ/go-unixfs/io" + path "gx/ipfs/QmTG5WFmAM4uAnqGskeAPijdpTmmNDLJNCQ71NqfdvC6hV/go-path" + resolver "gx/ipfs/QmTG5WFmAM4uAnqGskeAPijdpTmmNDLJNCQ71NqfdvC6hV/go-path/resolver" + ft "gx/ipfs/QmTbas51oodp3ZJrqsWYs1yqSxcD7LEJBv4djRV2VrY8wv/go-unixfs" + "gx/ipfs/QmTbas51oodp3ZJrqsWYs1yqSxcD7LEJBv4djRV2VrY8wv/go-unixfs/importer" + uio "gx/ipfs/QmTbas51oodp3ZJrqsWYs1yqSxcD7LEJBv4djRV2VrY8wv/go-unixfs/io" + dag "gx/ipfs/QmXhrNaxjxNLwAHnWQScc6GxvpJMyn8wfdRmGDbUQwpfth/go-merkledag" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid" - ipld "gx/ipfs/QmZtNq8dArGfnpCZfx2pUNY7UcjGhVp5qqwQ4hH6mpTMRQ/go-ipld-format" - chunker "gx/ipfs/Qmc3UwSvJkntxu2gKDPCqJEzmhqVeJtTbrVxJm6tsdmMF1/go-ipfs-chunker" - routing "gx/ipfs/QmewrvpGvgK9qkCtXsGNwXiQzyux4jcHNjoyVrGdsgtNK5/go-libp2p-routing" - multibase "gx/ipfs/QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup/go-multibase" + multibase "gx/ipfs/QmSbvata2WqNkqGtZNg8MR3SKwnB8iQ7vTPJgWqB8bC5kR/go-multibase" + ipld "gx/ipfs/QmUSyMZ8Vt4vTZr5HdDEgEfpwAXfQRuDdfCFTt7XBzhxpQ/go-ipld-format" + cid "gx/ipfs/Qmdu2AYUV7yMoVBQPxXNfe7FJcdx16kYtsx6jAPKWQYF1y/go-cid" + chunker "gx/ipfs/Qme4ThG6LN6EMrMYyf2AMywAZaGbTYxQu4njfcSSkcisLi/go-ipfs-chunker" + routing "gx/ipfs/QmfGeECX7CxJAFXwGKx2cn7csnxAtwJw8e3XtoNVf6bqcv/go-libp2p-routing" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 7e2103970..e6d9a7522 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,11 +18,11 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" - path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" config "gx/ipfs/QmRwCaRYotCqXsVZAXwWhEJ8A74iAaKnY7MUe6sDgFjrE5/go-ipfs-config" + path "gx/ipfs/QmTG5WFmAM4uAnqGskeAPijdpTmmNDLJNCQ71NqfdvC6hV/go-path" id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" - dag "gx/ipfs/QmXkZeJmx4c3ddjw81DQMUpM1e5LjAack5idzZYWUb2qAJ/go-merkledag" + dag "gx/ipfs/QmXhrNaxjxNLwAHnWQScc6GxvpJMyn8wfdRmGDbUQwpfth/go-merkledag" datastore "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore" syncds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/sync" ) From 200eb8d6ffc1cb5ba0b2e6bacfa283aa09f573de Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 13 Aug 2018 14:29:22 -0700 Subject: [PATCH 326/674] update go-datastore to use []byte values instead of {}interface values * Most of our datastores barf on non []byte values. * We have to have a bunch of "is this a []byte" checks. * Saves some allocations. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@79e7d5e542d729e3706fda0fc0cb320f418048cb --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 7e5988c0d..cfbb0db12 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,9 +15,9 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" config "gx/ipfs/QmRwCaRYotCqXsVZAXwWhEJ8A74iAaKnY7MUe6sDgFjrE5/go-ipfs-config" - path "gx/ipfs/QmTG5WFmAM4uAnqGskeAPijdpTmmNDLJNCQ71NqfdvC6hV/go-path" cmds "gx/ipfs/QmUQb3xtNzkQCgTj2NjaqcJZNv2nfSSub2QAdy9DtQMRBT/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmUQb3xtNzkQCgTj2NjaqcJZNv2nfSSub2QAdy9DtQMRBT/go-ipfs-cmds/http" + path "gx/ipfs/QmV1W98rBAovVJGkeYHfqJ19JdT9dQbbWsCq9zPaMyrxYx/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 6b2a88ced..cccd752f5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,12 +15,12 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - path "gx/ipfs/QmTG5WFmAM4uAnqGskeAPijdpTmmNDLJNCQ71NqfdvC6hV/go-path" - resolver "gx/ipfs/QmTG5WFmAM4uAnqGskeAPijdpTmmNDLJNCQ71NqfdvC6hV/go-path/resolver" - ft "gx/ipfs/QmTbas51oodp3ZJrqsWYs1yqSxcD7LEJBv4djRV2VrY8wv/go-unixfs" - "gx/ipfs/QmTbas51oodp3ZJrqsWYs1yqSxcD7LEJBv4djRV2VrY8wv/go-unixfs/importer" - uio "gx/ipfs/QmTbas51oodp3ZJrqsWYs1yqSxcD7LEJBv4djRV2VrY8wv/go-unixfs/io" - dag "gx/ipfs/QmXhrNaxjxNLwAHnWQScc6GxvpJMyn8wfdRmGDbUQwpfth/go-merkledag" + path "gx/ipfs/QmV1W98rBAovVJGkeYHfqJ19JdT9dQbbWsCq9zPaMyrxYx/go-path" + resolver "gx/ipfs/QmV1W98rBAovVJGkeYHfqJ19JdT9dQbbWsCq9zPaMyrxYx/go-path/resolver" + dag "gx/ipfs/QmYxX4VfVcxmfsj8U6T5kVtFvHsSidy9tmPyPTW5fy7H3q/go-merkledag" + ft "gx/ipfs/QmagwbbPqiN1oa3SDMZvpTFE5tNuegF1ULtuJvA9EVzsJv/go-unixfs" + "gx/ipfs/QmagwbbPqiN1oa3SDMZvpTFE5tNuegF1ULtuJvA9EVzsJv/go-unixfs/importer" + uio "gx/ipfs/QmagwbbPqiN1oa3SDMZvpTFE5tNuegF1ULtuJvA9EVzsJv/go-unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" multibase "gx/ipfs/QmSbvata2WqNkqGtZNg8MR3SKwnB8iQ7vTPJgWqB8bC5kR/go-multibase" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index e6d9a7522..5d7bc591b 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,11 +20,11 @@ import ( ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" config "gx/ipfs/QmRwCaRYotCqXsVZAXwWhEJ8A74iAaKnY7MUe6sDgFjrE5/go-ipfs-config" - path "gx/ipfs/QmTG5WFmAM4uAnqGskeAPijdpTmmNDLJNCQ71NqfdvC6hV/go-path" id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" - dag "gx/ipfs/QmXhrNaxjxNLwAHnWQScc6GxvpJMyn8wfdRmGDbUQwpfth/go-merkledag" - datastore "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore" - syncds "gx/ipfs/QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i/go-datastore/sync" + path "gx/ipfs/QmV1W98rBAovVJGkeYHfqJ19JdT9dQbbWsCq9zPaMyrxYx/go-path" + datastore "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore" + syncds "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore/sync" + dag "gx/ipfs/QmYxX4VfVcxmfsj8U6T5kVtFvHsSidy9tmPyPTW5fy7H3q/go-merkledag" ) // `ipfs object new unixfs-dir` From 0bf3f94fcb6ec7d786b27d370df4d410fcea74f1 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 15 Aug 2018 08:30:22 -0700 Subject: [PATCH 327/674] gx: update go-cid License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@2450ddde8123eeeecd293ea6c4df711afd0de946 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 20 ++++++++++---------- gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index cfbb0db12..90db8c68c 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -17,7 +17,7 @@ import ( config "gx/ipfs/QmRwCaRYotCqXsVZAXwWhEJ8A74iAaKnY7MUe6sDgFjrE5/go-ipfs-config" cmds "gx/ipfs/QmUQb3xtNzkQCgTj2NjaqcJZNv2nfSSub2QAdy9DtQMRBT/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmUQb3xtNzkQCgTj2NjaqcJZNv2nfSSub2QAdy9DtQMRBT/go-ipfs-cmds/http" - path "gx/ipfs/QmV1W98rBAovVJGkeYHfqJ19JdT9dQbbWsCq9zPaMyrxYx/go-path" + path "gx/ipfs/QmWMcvZbNvk5codeqbm7L89C9kqSwka4KaHnDb8HRnxsSL/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index cccd752f5..bcd1afd93 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,19 +15,19 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - path "gx/ipfs/QmV1W98rBAovVJGkeYHfqJ19JdT9dQbbWsCq9zPaMyrxYx/go-path" - resolver "gx/ipfs/QmV1W98rBAovVJGkeYHfqJ19JdT9dQbbWsCq9zPaMyrxYx/go-path/resolver" - dag "gx/ipfs/QmYxX4VfVcxmfsj8U6T5kVtFvHsSidy9tmPyPTW5fy7H3q/go-merkledag" - ft "gx/ipfs/QmagwbbPqiN1oa3SDMZvpTFE5tNuegF1ULtuJvA9EVzsJv/go-unixfs" - "gx/ipfs/QmagwbbPqiN1oa3SDMZvpTFE5tNuegF1ULtuJvA9EVzsJv/go-unixfs/importer" - uio "gx/ipfs/QmagwbbPqiN1oa3SDMZvpTFE5tNuegF1ULtuJvA9EVzsJv/go-unixfs/io" + dag "gx/ipfs/QmQzSpSjkdGHW6WFBhUG6P3t9K8yv7iucucT1cQaqJ6tgd/go-merkledag" + path "gx/ipfs/QmWMcvZbNvk5codeqbm7L89C9kqSwka4KaHnDb8HRnxsSL/go-path" + resolver "gx/ipfs/QmWMcvZbNvk5codeqbm7L89C9kqSwka4KaHnDb8HRnxsSL/go-path/resolver" + ft "gx/ipfs/QmWv8MYwgPK4zXYv1et1snWJ6FWGqaL6xY2y9X1bRSKBxk/go-unixfs" + "gx/ipfs/QmWv8MYwgPK4zXYv1et1snWJ6FWGqaL6xY2y9X1bRSKBxk/go-unixfs/importer" + uio "gx/ipfs/QmWv8MYwgPK4zXYv1et1snWJ6FWGqaL6xY2y9X1bRSKBxk/go-unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" + routing "gx/ipfs/QmSD6bSPcXaaR7LpQHjytLWQD7DrCsb415CWfpbd9Szemb/go-libp2p-routing" multibase "gx/ipfs/QmSbvata2WqNkqGtZNg8MR3SKwnB8iQ7vTPJgWqB8bC5kR/go-multibase" - ipld "gx/ipfs/QmUSyMZ8Vt4vTZr5HdDEgEfpwAXfQRuDdfCFTt7XBzhxpQ/go-ipld-format" - cid "gx/ipfs/Qmdu2AYUV7yMoVBQPxXNfe7FJcdx16kYtsx6jAPKWQYF1y/go-cid" - chunker "gx/ipfs/Qme4ThG6LN6EMrMYyf2AMywAZaGbTYxQu4njfcSSkcisLi/go-ipfs-chunker" - routing "gx/ipfs/QmfGeECX7CxJAFXwGKx2cn7csnxAtwJw8e3XtoNVf6bqcv/go-libp2p-routing" + chunker "gx/ipfs/QmWbCAB5f3LDumj4ncz1UCHSiyXrXxkMxZB6Wv35xi4P8z/go-ipfs-chunker" + cid "gx/ipfs/QmYjnkEL7i731PirfVH1sis89evN7jt4otSHw5D2xXXwUV/go-cid" + ipld "gx/ipfs/QmaA8GkXUYinkkndvg7T6Tx7gYXemhxjaxLisEPes7Rf1P/go-ipld-format" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 5d7bc591b..71f995dda 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,12 +19,12 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" + dag "gx/ipfs/QmQzSpSjkdGHW6WFBhUG6P3t9K8yv7iucucT1cQaqJ6tgd/go-merkledag" config "gx/ipfs/QmRwCaRYotCqXsVZAXwWhEJ8A74iAaKnY7MUe6sDgFjrE5/go-ipfs-config" id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" - path "gx/ipfs/QmV1W98rBAovVJGkeYHfqJ19JdT9dQbbWsCq9zPaMyrxYx/go-path" datastore "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore" syncds "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore/sync" - dag "gx/ipfs/QmYxX4VfVcxmfsj8U6T5kVtFvHsSidy9tmPyPTW5fy7H3q/go-merkledag" + path "gx/ipfs/QmWMcvZbNvk5codeqbm7L89C9kqSwka4KaHnDb8HRnxsSL/go-path" ) // `ipfs object new unixfs-dir` From 94080c6ab51e356af35383ffa20c5954d4e1ed8b Mon Sep 17 00:00:00 2001 From: vyzo Date: Sun, 12 Aug 2018 14:22:54 +0300 Subject: [PATCH 328/674] update go-ipfs-config License: MIT Signed-off-by: vyzo This commit was moved from ipfs/kubo@e002de957122e2e4c7aa5e6bfde3834f67485aee --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 90db8c68c..6376b004b 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,7 +14,7 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - config "gx/ipfs/QmRwCaRYotCqXsVZAXwWhEJ8A74iAaKnY7MUe6sDgFjrE5/go-ipfs-config" + config "gx/ipfs/QmQSG7YCizeUH2bWatzp6uK9Vm3m7LA5jpxGa9QqgpNKw4/go-ipfs-config" cmds "gx/ipfs/QmUQb3xtNzkQCgTj2NjaqcJZNv2nfSSub2QAdy9DtQMRBT/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmUQb3xtNzkQCgTj2NjaqcJZNv2nfSSub2QAdy9DtQMRBT/go-ipfs-cmds/http" path "gx/ipfs/QmWMcvZbNvk5codeqbm7L89C9kqSwka4KaHnDb8HRnxsSL/go-path" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 71f995dda..43384c7b9 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,8 +19,8 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" + config "gx/ipfs/QmQSG7YCizeUH2bWatzp6uK9Vm3m7LA5jpxGa9QqgpNKw4/go-ipfs-config" dag "gx/ipfs/QmQzSpSjkdGHW6WFBhUG6P3t9K8yv7iucucT1cQaqJ6tgd/go-merkledag" - config "gx/ipfs/QmRwCaRYotCqXsVZAXwWhEJ8A74iAaKnY7MUe6sDgFjrE5/go-ipfs-config" id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" datastore "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore" syncds "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore/sync" From 2f4b56dc7d97fa4c7aba67a141421a68c0dc2337 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 21 Aug 2018 17:10:11 -0700 Subject: [PATCH 329/674] gx: update go-cid, go-libp2p-peer, go-ipfs-cmds, go-ipfs-cmdkit License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@656d7cc1a61f55bb4d9251def093ae5d3ce0abe6 --- gateway/core/corehttp/commands.go | 8 ++++---- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 20 ++++++++++---------- gateway/core/corehttp/gateway_test.go | 8 ++++---- gateway/core/corehttp/metrics_test.go | 6 +++--- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 6376b004b..41f389046 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - config "gx/ipfs/QmQSG7YCizeUH2bWatzp6uK9Vm3m7LA5jpxGa9QqgpNKw4/go-ipfs-config" - cmds "gx/ipfs/QmUQb3xtNzkQCgTj2NjaqcJZNv2nfSSub2QAdy9DtQMRBT/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmUQb3xtNzkQCgTj2NjaqcJZNv2nfSSub2QAdy9DtQMRBT/go-ipfs-cmds/http" - path "gx/ipfs/QmWMcvZbNvk5codeqbm7L89C9kqSwka4KaHnDb8HRnxsSL/go-path" + cmds "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds/http" + config "gx/ipfs/QmTyiSs9VgdVb4pnzdjtKhcfdTkHFEaNn6xnCbZq4DTFRt/go-ipfs-config" + path "gx/ipfs/QmdMPBephdLYNESkruDX2hcDTgFYhoCt4LimWhgnomSdV2/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index acdea180d..5755f8a95 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQiaskfWpdRJ4x2spEQjPFTUkEB87KDYu91qnNYBqvvcX/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 6c917031d..100ffb994 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,19 +16,19 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - dag "gx/ipfs/QmQzSpSjkdGHW6WFBhUG6P3t9K8yv7iucucT1cQaqJ6tgd/go-merkledag" - path "gx/ipfs/QmWMcvZbNvk5codeqbm7L89C9kqSwka4KaHnDb8HRnxsSL/go-path" - resolver "gx/ipfs/QmWMcvZbNvk5codeqbm7L89C9kqSwka4KaHnDb8HRnxsSL/go-path/resolver" - ft "gx/ipfs/QmWv8MYwgPK4zXYv1et1snWJ6FWGqaL6xY2y9X1bRSKBxk/go-unixfs" - "gx/ipfs/QmWv8MYwgPK4zXYv1et1snWJ6FWGqaL6xY2y9X1bRSKBxk/go-unixfs/importer" - uio "gx/ipfs/QmWv8MYwgPK4zXYv1et1snWJ6FWGqaL6xY2y9X1bRSKBxk/go-unixfs/io" + ft "gx/ipfs/QmQjEpRiwVvtowhq69dAtB4jhioPVFXiCcWZm9Sfgn7eqc/go-unixfs" + "gx/ipfs/QmQjEpRiwVvtowhq69dAtB4jhioPVFXiCcWZm9Sfgn7eqc/go-unixfs/importer" + uio "gx/ipfs/QmQjEpRiwVvtowhq69dAtB4jhioPVFXiCcWZm9Sfgn7eqc/go-unixfs/io" + dag "gx/ipfs/QmRiQCJZ91B7VNmLvA6sxzDuBJGSojS3uXHHVuNr3iueNZ/go-merkledag" + path "gx/ipfs/QmdMPBephdLYNESkruDX2hcDTgFYhoCt4LimWhgnomSdV2/go-path" + resolver "gx/ipfs/QmdMPBephdLYNESkruDX2hcDTgFYhoCt4LimWhgnomSdV2/go-path/resolver" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - routing "gx/ipfs/QmSD6bSPcXaaR7LpQHjytLWQD7DrCsb415CWfpbd9Szemb/go-libp2p-routing" + routing "gx/ipfs/QmS4niovD1U6pRjUBXivr1zvvLBqiTKbERjFo994JU7oQS/go-libp2p-routing" multibase "gx/ipfs/QmSbvata2WqNkqGtZNg8MR3SKwnB8iQ7vTPJgWqB8bC5kR/go-multibase" - chunker "gx/ipfs/QmWbCAB5f3LDumj4ncz1UCHSiyXrXxkMxZB6Wv35xi4P8z/go-ipfs-chunker" - cid "gx/ipfs/QmYjnkEL7i731PirfVH1sis89evN7jt4otSHw5D2xXXwUV/go-cid" - ipld "gx/ipfs/QmaA8GkXUYinkkndvg7T6Tx7gYXemhxjaxLisEPes7Rf1P/go-ipld-format" + ipld "gx/ipfs/QmX5CsuHyVZeTLxgRSYkgLSDQKb9UjE8xnhQzCEJWWWFsC/go-ipld-format" + chunker "gx/ipfs/QmXzBbJo2sLf3uwjNTeoWYiJV7CjAhkiA4twtLvwJSSNdK/go-ipfs-chunker" + cid "gx/ipfs/QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb/go-cid" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 43384c7b9..687ac625b 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,12 +19,12 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - config "gx/ipfs/QmQSG7YCizeUH2bWatzp6uK9Vm3m7LA5jpxGa9QqgpNKw4/go-ipfs-config" - dag "gx/ipfs/QmQzSpSjkdGHW6WFBhUG6P3t9K8yv7iucucT1cQaqJ6tgd/go-merkledag" - id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmQiaskfWpdRJ4x2spEQjPFTUkEB87KDYu91qnNYBqvvcX/go-libp2p/p2p/protocol/identify" + dag "gx/ipfs/QmRiQCJZ91B7VNmLvA6sxzDuBJGSojS3uXHHVuNr3iueNZ/go-merkledag" + config "gx/ipfs/QmTyiSs9VgdVb4pnzdjtKhcfdTkHFEaNn6xnCbZq4DTFRt/go-ipfs-config" datastore "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore" syncds "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore/sync" - path "gx/ipfs/QmWMcvZbNvk5codeqbm7L89C9kqSwka4KaHnDb8HRnxsSL/go-path" + path "gx/ipfs/QmdMPBephdLYNESkruDX2hcDTgFYhoCt4LimWhgnomSdV2/go-path" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index dc09ef470..95adc3c13 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmVwU7Mgwg6qaPn9XXz93ANfq1PTxcduGRzfe41Sygg4mR/go-libp2p-net" - swarmt "gx/ipfs/QmdjC8HtKZpEufBL1u7WxvQn78Lqq2Wk31NJS8WvFX3crB/go-libp2p-swarm/testing" + swarmt "gx/ipfs/QmPWNZRUybw3nwJH3mpkrwB97YEQmXRkzvyh34rpJiih6Q/go-libp2p-swarm/testing" + bhost "gx/ipfs/QmQiaskfWpdRJ4x2spEQjPFTUkEB87KDYu91qnNYBqvvcX/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmX5J1q63BrrDTbpcHifrFbxH3cMZsvaNajy6u3zCpzBXs/go-libp2p-net" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From a7f19e9bd24a76aaae87061c912e58f2325635a2 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 26 Aug 2018 10:51:38 +0700 Subject: [PATCH 330/674] update go-ipfs-config to version 0.2.5 License: MIT Signed-off-by: Marten Seemann This commit was moved from ipfs/kubo@1c57b1d287ad8a976444488e0a5003e3cb1fde66 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 41f389046..fca4fef11 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -16,8 +16,8 @@ import ( cmds "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds/http" - config "gx/ipfs/QmTyiSs9VgdVb4pnzdjtKhcfdTkHFEaNn6xnCbZq4DTFRt/go-ipfs-config" path "gx/ipfs/QmdMPBephdLYNESkruDX2hcDTgFYhoCt4LimWhgnomSdV2/go-path" + config "gx/ipfs/Qmdpmn9dQFSFeCfwpaZdbeYSFxJmbtSTArU4kMZByjmPAJ/go-ipfs-config" ) var ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 687ac625b..6297570e4 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -21,10 +21,10 @@ import ( ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" id "gx/ipfs/QmQiaskfWpdRJ4x2spEQjPFTUkEB87KDYu91qnNYBqvvcX/go-libp2p/p2p/protocol/identify" dag "gx/ipfs/QmRiQCJZ91B7VNmLvA6sxzDuBJGSojS3uXHHVuNr3iueNZ/go-merkledag" - config "gx/ipfs/QmTyiSs9VgdVb4pnzdjtKhcfdTkHFEaNn6xnCbZq4DTFRt/go-ipfs-config" datastore "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore" syncds "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore/sync" path "gx/ipfs/QmdMPBephdLYNESkruDX2hcDTgFYhoCt4LimWhgnomSdV2/go-path" + config "gx/ipfs/Qmdpmn9dQFSFeCfwpaZdbeYSFxJmbtSTArU4kMZByjmPAJ/go-ipfs-config" ) // `ipfs object new unixfs-dir` From 3f6c68db6f45c0e8b47ae3de9d5104717943489f Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 29 Aug 2018 21:04:56 -0700 Subject: [PATCH 331/674] gx update deps License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@46a1d9d39b3dbee1cacfb8086c4c790339751658 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 8 ++++---- gateway/core/corehttp/metrics_test.go | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index fca4fef11..6dc99af90 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -16,8 +16,8 @@ import ( cmds "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds/http" - path "gx/ipfs/QmdMPBephdLYNESkruDX2hcDTgFYhoCt4LimWhgnomSdV2/go-path" - config "gx/ipfs/Qmdpmn9dQFSFeCfwpaZdbeYSFxJmbtSTArU4kMZByjmPAJ/go-ipfs-config" + path "gx/ipfs/QmTKaiDxQqVxmA1bRipSuP7hnTSgnMSmEa98NYeS6fcoiv/go-path" + config "gx/ipfs/QmXUU23sGKdT7AHpyJ4aSvYpXbWjbiuYG1CYhZ3ai3btkG/go-ipfs-config" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 5755f8a95..6465ece63 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmQiaskfWpdRJ4x2spEQjPFTUkEB87KDYu91qnNYBqvvcX/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/Qmf1u2efhjXYtuyP8SMHYtw4dCkbghnniex2PSp7baA7FP/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 100ffb994..25faf6a12 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,12 +16,12 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - ft "gx/ipfs/QmQjEpRiwVvtowhq69dAtB4jhioPVFXiCcWZm9Sfgn7eqc/go-unixfs" - "gx/ipfs/QmQjEpRiwVvtowhq69dAtB4jhioPVFXiCcWZm9Sfgn7eqc/go-unixfs/importer" - uio "gx/ipfs/QmQjEpRiwVvtowhq69dAtB4jhioPVFXiCcWZm9Sfgn7eqc/go-unixfs/io" - dag "gx/ipfs/QmRiQCJZ91B7VNmLvA6sxzDuBJGSojS3uXHHVuNr3iueNZ/go-merkledag" - path "gx/ipfs/QmdMPBephdLYNESkruDX2hcDTgFYhoCt4LimWhgnomSdV2/go-path" - resolver "gx/ipfs/QmdMPBephdLYNESkruDX2hcDTgFYhoCt4LimWhgnomSdV2/go-path/resolver" + dag "gx/ipfs/QmRDaC5z6yXkXTTSWzaxs2sSVBon5RRCN6eNtMmpuHtKCr/go-merkledag" + path "gx/ipfs/QmTKaiDxQqVxmA1bRipSuP7hnTSgnMSmEa98NYeS6fcoiv/go-path" + resolver "gx/ipfs/QmTKaiDxQqVxmA1bRipSuP7hnTSgnMSmEa98NYeS6fcoiv/go-path/resolver" + ft "gx/ipfs/QmVNEJ5Vk1e2G5kHMiuVbpD6VQZiK1oS6aWZKjcUQW7hEy/go-unixfs" + "gx/ipfs/QmVNEJ5Vk1e2G5kHMiuVbpD6VQZiK1oS6aWZKjcUQW7hEy/go-unixfs/importer" + uio "gx/ipfs/QmVNEJ5Vk1e2G5kHMiuVbpD6VQZiK1oS6aWZKjcUQW7hEy/go-unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" routing "gx/ipfs/QmS4niovD1U6pRjUBXivr1zvvLBqiTKbERjFo994JU7oQS/go-libp2p-routing" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 6297570e4..211da131a 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,12 +19,12 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - id "gx/ipfs/QmQiaskfWpdRJ4x2spEQjPFTUkEB87KDYu91qnNYBqvvcX/go-libp2p/p2p/protocol/identify" - dag "gx/ipfs/QmRiQCJZ91B7VNmLvA6sxzDuBJGSojS3uXHHVuNr3iueNZ/go-merkledag" + dag "gx/ipfs/QmRDaC5z6yXkXTTSWzaxs2sSVBon5RRCN6eNtMmpuHtKCr/go-merkledag" + path "gx/ipfs/QmTKaiDxQqVxmA1bRipSuP7hnTSgnMSmEa98NYeS6fcoiv/go-path" datastore "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore" syncds "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore/sync" - path "gx/ipfs/QmdMPBephdLYNESkruDX2hcDTgFYhoCt4LimWhgnomSdV2/go-path" - config "gx/ipfs/Qmdpmn9dQFSFeCfwpaZdbeYSFxJmbtSTArU4kMZByjmPAJ/go-ipfs-config" + config "gx/ipfs/QmXUU23sGKdT7AHpyJ4aSvYpXbWjbiuYG1CYhZ3ai3btkG/go-ipfs-config" + id "gx/ipfs/Qmf1u2efhjXYtuyP8SMHYtw4dCkbghnniex2PSp7baA7FP/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 95adc3c13..0b7195e40 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - swarmt "gx/ipfs/QmPWNZRUybw3nwJH3mpkrwB97YEQmXRkzvyh34rpJiih6Q/go-libp2p-swarm/testing" - bhost "gx/ipfs/QmQiaskfWpdRJ4x2spEQjPFTUkEB87KDYu91qnNYBqvvcX/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmX5J1q63BrrDTbpcHifrFbxH3cMZsvaNajy6u3zCpzBXs/go-libp2p-net" + inet "gx/ipfs/QmQSbtGXCyNrj34LWL8EgXyNNYDZ8r3SwQcpW5pPxVhLnM/go-libp2p-net" + swarmt "gx/ipfs/Qmcc5CPuKyfDZNmqXNkk6j23CyZqZGypUv952NLHYGbeni/go-libp2p-swarm/testing" + bhost "gx/ipfs/Qmf1u2efhjXYtuyP8SMHYtw4dCkbghnniex2PSp7baA7FP/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 7a8fab77be7bf1282337720f832102997e894db1 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 6 Sep 2018 11:00:17 -0700 Subject: [PATCH 332/674] improve gateway options test Unfortunately, this doesn't really test the *actual* gateway config as it uses the options specified by the test. However, it's a step in the right direction. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@eabd6a0ad4fe0bde0c344b0c3086c480b0b6bc4e --- gateway/core/corehttp/gateway_test.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 211da131a..ebc312a0d 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -128,9 +128,9 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, *core dh.Handler, err = makeHandler(n, ts.Listener, - VersionOption(), IPNSHostnameOption(), GatewayOption(false, "/ipfs", "/ipns"), + VersionOption(), ) if err != nil { t.Fatal(err) @@ -290,6 +290,23 @@ func TestIPNSHostnameRedirect(t *testing.T) { } else if hdr[0] != "/good-prefix/foo/" { t.Errorf("location header is %v, expected /good-prefix/foo/", hdr[0]) } + + // make sure /version isn't exposed + req, err = http.NewRequest("GET", ts.URL+"/version", nil) + if err != nil { + t.Fatal(err) + } + req.Host = "example.net" + req.Header.Set("X-Ipfs-Gateway-Prefix", "/good-prefix") + + res, err = doWithoutRedirect(req) + if err != nil { + t.Fatal(err) + } + + if res.StatusCode != 404 { + t.Fatalf("expected a 404 error, got: %s", res.Status) + } } func TestIPNSHostnameBacklinks(t *testing.T) { From a16d71d4f9d720cfeab9f12265b34ce698dabfce Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 7 Sep 2018 23:40:08 -0700 Subject: [PATCH 333/674] gx: update peerstore Also: * Updates go-floodsub to fix a data race. * Updates golang-lru License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@a6e617f55c0a2b3b6cb22ecaf7c0005ff399cd83 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 14 +++++++------- gateway/core/corehttp/gateway_test.go | 12 ++++++------ gateway/core/corehttp/metrics_test.go | 6 +++--- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 6dc99af90..4215dbea8 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + path "gx/ipfs/QmNgXoHgXU1HzNb2HEZmRww9fDKE9NfDsvQwWLHiKHpvKM/go-path" cmds "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds/http" - path "gx/ipfs/QmTKaiDxQqVxmA1bRipSuP7hnTSgnMSmEa98NYeS6fcoiv/go-path" - config "gx/ipfs/QmXUU23sGKdT7AHpyJ4aSvYpXbWjbiuYG1CYhZ3ai3btkG/go-ipfs-config" + config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 6465ece63..67e26b5da 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/Qmf1u2efhjXYtuyP8SMHYtw4dCkbghnniex2PSp7baA7FP/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmUEqyXr97aUbNmQADHYNknjwjjdVpJXEt1UZXmSG81EV4/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 25faf6a12..24f8ff7e8 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,18 +16,18 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - dag "gx/ipfs/QmRDaC5z6yXkXTTSWzaxs2sSVBon5RRCN6eNtMmpuHtKCr/go-merkledag" - path "gx/ipfs/QmTKaiDxQqVxmA1bRipSuP7hnTSgnMSmEa98NYeS6fcoiv/go-path" - resolver "gx/ipfs/QmTKaiDxQqVxmA1bRipSuP7hnTSgnMSmEa98NYeS6fcoiv/go-path/resolver" - ft "gx/ipfs/QmVNEJ5Vk1e2G5kHMiuVbpD6VQZiK1oS6aWZKjcUQW7hEy/go-unixfs" - "gx/ipfs/QmVNEJ5Vk1e2G5kHMiuVbpD6VQZiK1oS6aWZKjcUQW7hEy/go-unixfs/importer" - uio "gx/ipfs/QmVNEJ5Vk1e2G5kHMiuVbpD6VQZiK1oS6aWZKjcUQW7hEy/go-unixfs/io" + path "gx/ipfs/QmNgXoHgXU1HzNb2HEZmRww9fDKE9NfDsvQwWLHiKHpvKM/go-path" + resolver "gx/ipfs/QmNgXoHgXU1HzNb2HEZmRww9fDKE9NfDsvQwWLHiKHpvKM/go-path/resolver" + dag "gx/ipfs/QmNr4E8z9bGTztvHJktp7uQaMdx9p3r9Asrq6eYk7iCh4a/go-merkledag" + ft "gx/ipfs/QmWAfTyD6KEBm7bzqNRBPvqKrZCDtn5PGbs9V1DKfnVK59/go-unixfs" + "gx/ipfs/QmWAfTyD6KEBm7bzqNRBPvqKrZCDtn5PGbs9V1DKfnVK59/go-unixfs/importer" + uio "gx/ipfs/QmWAfTyD6KEBm7bzqNRBPvqKrZCDtn5PGbs9V1DKfnVK59/go-unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - routing "gx/ipfs/QmS4niovD1U6pRjUBXivr1zvvLBqiTKbERjFo994JU7oQS/go-libp2p-routing" multibase "gx/ipfs/QmSbvata2WqNkqGtZNg8MR3SKwnB8iQ7vTPJgWqB8bC5kR/go-multibase" ipld "gx/ipfs/QmX5CsuHyVZeTLxgRSYkgLSDQKb9UjE8xnhQzCEJWWWFsC/go-ipld-format" chunker "gx/ipfs/QmXzBbJo2sLf3uwjNTeoWYiJV7CjAhkiA4twtLvwJSSNdK/go-ipfs-chunker" + routing "gx/ipfs/QmY9JUvS8kbgao3XbPh6WAV3ChE2nxGKhcGTHiwMC4gmcU/go-libp2p-routing" cid "gx/ipfs/QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb/go-cid" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 211da131a..248a9c3e6 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,13 +18,13 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" + path "gx/ipfs/QmNgXoHgXU1HzNb2HEZmRww9fDKE9NfDsvQwWLHiKHpvKM/go-path" + dag "gx/ipfs/QmNr4E8z9bGTztvHJktp7uQaMdx9p3r9Asrq6eYk7iCh4a/go-merkledag" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - dag "gx/ipfs/QmRDaC5z6yXkXTTSWzaxs2sSVBon5RRCN6eNtMmpuHtKCr/go-merkledag" - path "gx/ipfs/QmTKaiDxQqVxmA1bRipSuP7hnTSgnMSmEa98NYeS6fcoiv/go-path" - datastore "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore" - syncds "gx/ipfs/QmVG5gxteQNEMhrS8prJSmU2C9rebtFuTd3SYZ5kE3YZ5k/go-datastore/sync" - config "gx/ipfs/QmXUU23sGKdT7AHpyJ4aSvYpXbWjbiuYG1CYhZ3ai3btkG/go-ipfs-config" - id "gx/ipfs/Qmf1u2efhjXYtuyP8SMHYtw4dCkbghnniex2PSp7baA7FP/go-libp2p/p2p/protocol/identify" + datastore "gx/ipfs/QmSpg1CvpXQQow5ernt1gNBXaXV6yxyNqi7XoeerWfzB5w/go-datastore" + syncds "gx/ipfs/QmSpg1CvpXQQow5ernt1gNBXaXV6yxyNqi7XoeerWfzB5w/go-datastore/sync" + id "gx/ipfs/QmUEqyXr97aUbNmQADHYNknjwjjdVpJXEt1UZXmSG81EV4/go-libp2p/p2p/protocol/identify" + config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 0b7195e40..9f29753aa 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - inet "gx/ipfs/QmQSbtGXCyNrj34LWL8EgXyNNYDZ8r3SwQcpW5pPxVhLnM/go-libp2p-net" - swarmt "gx/ipfs/Qmcc5CPuKyfDZNmqXNkk6j23CyZqZGypUv952NLHYGbeni/go-libp2p-swarm/testing" - bhost "gx/ipfs/Qmf1u2efhjXYtuyP8SMHYtw4dCkbghnniex2PSp7baA7FP/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/QmUEqyXr97aUbNmQADHYNknjwjjdVpJXEt1UZXmSG81EV4/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmZNJyx9GGCX4GeuHnLB8fxaxMLs4MjTjHokxfQcCd6Nve/go-libp2p-net" + swarmt "gx/ipfs/QmeDpqUwwdye8ABKVMPXKuWwPVURFdqTqssbTUB39E2Nwd/go-libp2p-swarm/testing" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 899c4ecf82b047514600640f92c25b326e13648f Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Tue, 11 Sep 2018 22:19:44 -0400 Subject: [PATCH 334/674] gx update and fix code to use new Cid type License: MIT Signed-off-by: Kevin Atkinson This commit was moved from ipfs/kubo@d3174f4bd96941381d4ada02d1a7a105db3f0151 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 24 ++++++++++++------------ gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 4215dbea8..f6318bfef 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,9 +14,9 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - path "gx/ipfs/QmNgXoHgXU1HzNb2HEZmRww9fDKE9NfDsvQwWLHiKHpvKM/go-path" cmds "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds/http" + path "gx/ipfs/QmRYx6fJzTWFoeTo3qQn64iDrVC154Gy9waQDhvKRr2ND3/go-path" config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" ) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 24f8ff7e8..1a7e29425 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,19 +16,19 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - path "gx/ipfs/QmNgXoHgXU1HzNb2HEZmRww9fDKE9NfDsvQwWLHiKHpvKM/go-path" - resolver "gx/ipfs/QmNgXoHgXU1HzNb2HEZmRww9fDKE9NfDsvQwWLHiKHpvKM/go-path/resolver" - dag "gx/ipfs/QmNr4E8z9bGTztvHJktp7uQaMdx9p3r9Asrq6eYk7iCh4a/go-merkledag" - ft "gx/ipfs/QmWAfTyD6KEBm7bzqNRBPvqKrZCDtn5PGbs9V1DKfnVK59/go-unixfs" - "gx/ipfs/QmWAfTyD6KEBm7bzqNRBPvqKrZCDtn5PGbs9V1DKfnVK59/go-unixfs/importer" - uio "gx/ipfs/QmWAfTyD6KEBm7bzqNRBPvqKrZCDtn5PGbs9V1DKfnVK59/go-unixfs/io" + ft "gx/ipfs/QmPXzQ9LAFGZjcifFANCQFQiYt5SXgJziGoxUfJULVpHyA/go-unixfs" + "gx/ipfs/QmPXzQ9LAFGZjcifFANCQFQiYt5SXgJziGoxUfJULVpHyA/go-unixfs/importer" + uio "gx/ipfs/QmPXzQ9LAFGZjcifFANCQFQiYt5SXgJziGoxUfJULVpHyA/go-unixfs/io" + path "gx/ipfs/QmRYx6fJzTWFoeTo3qQn64iDrVC154Gy9waQDhvKRr2ND3/go-path" + resolver "gx/ipfs/QmRYx6fJzTWFoeTo3qQn64iDrVC154Gy9waQDhvKRr2ND3/go-path/resolver" + dag "gx/ipfs/QmURqt1jB9Yu3X4Tr9WQJf36QGN7vi8mGTzjnX2ij1CJwC/go-merkledag" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - multibase "gx/ipfs/QmSbvata2WqNkqGtZNg8MR3SKwnB8iQ7vTPJgWqB8bC5kR/go-multibase" - ipld "gx/ipfs/QmX5CsuHyVZeTLxgRSYkgLSDQKb9UjE8xnhQzCEJWWWFsC/go-ipld-format" - chunker "gx/ipfs/QmXzBbJo2sLf3uwjNTeoWYiJV7CjAhkiA4twtLvwJSSNdK/go-ipfs-chunker" - routing "gx/ipfs/QmY9JUvS8kbgao3XbPh6WAV3ChE2nxGKhcGTHiwMC4gmcU/go-libp2p-routing" - cid "gx/ipfs/QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb/go-cid" + cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" + ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format" + routing "gx/ipfs/QmdKS5YtmuSWKuLLgbHG176mS3VX3AKiyVmaaiAfvgcuch/go-libp2p-routing" + chunker "gx/ipfs/QmdSeG9s4EQ9TGruJJS9Us38TQDZtMmFGwzTYUDVqNTURm/go-ipfs-chunker" + multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) const ( @@ -443,7 +443,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { newPath = path.Join(rsegs[2:]) } - var newcid *cid.Cid + var newcid cid.Cid rnode, err := core.Resolve(ctx, i.node.Namesys, i.node.Resolver, rootPath) switch ev := err.(type) { case resolver.ErrNoLink: diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 248a9c3e6..f474fb7b3 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,12 +18,12 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" - path "gx/ipfs/QmNgXoHgXU1HzNb2HEZmRww9fDKE9NfDsvQwWLHiKHpvKM/go-path" - dag "gx/ipfs/QmNr4E8z9bGTztvHJktp7uQaMdx9p3r9Asrq6eYk7iCh4a/go-merkledag" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" + path "gx/ipfs/QmRYx6fJzTWFoeTo3qQn64iDrVC154Gy9waQDhvKRr2ND3/go-path" datastore "gx/ipfs/QmSpg1CvpXQQow5ernt1gNBXaXV6yxyNqi7XoeerWfzB5w/go-datastore" syncds "gx/ipfs/QmSpg1CvpXQQow5ernt1gNBXaXV6yxyNqi7XoeerWfzB5w/go-datastore/sync" id "gx/ipfs/QmUEqyXr97aUbNmQADHYNknjwjjdVpJXEt1UZXmSG81EV4/go-libp2p/p2p/protocol/identify" + dag "gx/ipfs/QmURqt1jB9Yu3X4Tr9WQJf36QGN7vi8mGTzjnX2ij1CJwC/go-merkledag" config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" ) From 0ffc397e224032ce4ac4be46816f1494ab570b3e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 11 Sep 2018 20:34:52 -0700 Subject: [PATCH 335/674] gx: fix hashes (some extra files got committed) License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@54e2cc629a9d726afd07bbdc0f6e733a948762c6 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index f6318bfef..59d0d49b2 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -16,7 +16,7 @@ import ( cmds "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds/http" - path "gx/ipfs/QmRYx6fJzTWFoeTo3qQn64iDrVC154Gy9waQDhvKRr2ND3/go-path" + path "gx/ipfs/QmX7uSbkNz76yNwBhuwYwRbhihLnJqM73VTCjS3UMJud9A/go-path" config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" ) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1a7e29425..7d1bbb6f5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,12 +16,12 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - ft "gx/ipfs/QmPXzQ9LAFGZjcifFANCQFQiYt5SXgJziGoxUfJULVpHyA/go-unixfs" - "gx/ipfs/QmPXzQ9LAFGZjcifFANCQFQiYt5SXgJziGoxUfJULVpHyA/go-unixfs/importer" - uio "gx/ipfs/QmPXzQ9LAFGZjcifFANCQFQiYt5SXgJziGoxUfJULVpHyA/go-unixfs/io" - path "gx/ipfs/QmRYx6fJzTWFoeTo3qQn64iDrVC154Gy9waQDhvKRr2ND3/go-path" - resolver "gx/ipfs/QmRYx6fJzTWFoeTo3qQn64iDrVC154Gy9waQDhvKRr2ND3/go-path/resolver" - dag "gx/ipfs/QmURqt1jB9Yu3X4Tr9WQJf36QGN7vi8mGTzjnX2ij1CJwC/go-merkledag" + ft "gx/ipfs/QmPL8bYtbACcSFFiSr4s2du7Na382NxRADR8hC7D9FkEA2/go-unixfs" + "gx/ipfs/QmPL8bYtbACcSFFiSr4s2du7Na382NxRADR8hC7D9FkEA2/go-unixfs/importer" + uio "gx/ipfs/QmPL8bYtbACcSFFiSr4s2du7Na382NxRADR8hC7D9FkEA2/go-unixfs/io" + path "gx/ipfs/QmX7uSbkNz76yNwBhuwYwRbhihLnJqM73VTCjS3UMJud9A/go-path" + resolver "gx/ipfs/QmX7uSbkNz76yNwBhuwYwRbhihLnJqM73VTCjS3UMJud9A/go-path/resolver" + dag "gx/ipfs/QmXv5mwmQ74r4aiHcNeQ4GAmfB3aWJuqaE4WyDfDfvkgLM/go-merkledag" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index f474fb7b3..3d096fc87 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,11 +19,11 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - path "gx/ipfs/QmRYx6fJzTWFoeTo3qQn64iDrVC154Gy9waQDhvKRr2ND3/go-path" datastore "gx/ipfs/QmSpg1CvpXQQow5ernt1gNBXaXV6yxyNqi7XoeerWfzB5w/go-datastore" syncds "gx/ipfs/QmSpg1CvpXQQow5ernt1gNBXaXV6yxyNqi7XoeerWfzB5w/go-datastore/sync" id "gx/ipfs/QmUEqyXr97aUbNmQADHYNknjwjjdVpJXEt1UZXmSG81EV4/go-libp2p/p2p/protocol/identify" - dag "gx/ipfs/QmURqt1jB9Yu3X4Tr9WQJf36QGN7vi8mGTzjnX2ij1CJwC/go-merkledag" + path "gx/ipfs/QmX7uSbkNz76yNwBhuwYwRbhihLnJqM73VTCjS3UMJud9A/go-path" + dag "gx/ipfs/QmXv5mwmQ74r4aiHcNeQ4GAmfB3aWJuqaE4WyDfDfvkgLM/go-merkledag" config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" ) From 04552c7f85ee2b18591aacde53b913465317f939 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Thu, 13 Sep 2018 02:01:17 +0200 Subject: [PATCH 336/674] api: fix outdated HTTPHeaders config documentation License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@9b374c0041e07326da32fba1eaa7d6e92e3a8b9c --- gateway/core/corehttp/commands.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 59d0d49b2..c4d6112cc 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -30,12 +30,8 @@ This functionality is deprecated, and will be removed in future versions. Instead, try either adding headers to the config, or passing them via cli arguments: - ipfs config API.HTTPHeaders 'Access-Control-Allow-Origin' '*' + ipfs config API.HTTPHeaders --json '{"Access-Control-Allow-Origin": ["*"]}' ipfs daemon - -or - - ipfs daemon --api-http-header 'Access-Control-Allow-Origin: *' ` // APIPath is the path at which the API is mounted. From 52d84be7f7095f4f78f27c8f336da662dbe28e20 Mon Sep 17 00:00:00 2001 From: keks Date: Fri, 13 Apr 2018 16:14:30 +0200 Subject: [PATCH 337/674] big squash commit excerpt of commit messages: - update postrun functions in core/commands - sharness: allow setting -i with TEST_IMMEDIATE=1 - cmds Run func returns error now - gx update cmdkit to 1.1.2 and cmds to 2.0.0-beta1 License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@908ffddc1bdce22173099914e36d1698fb3c30b3 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index c4d6112cc..df9db75d3 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - cmds "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmPTfgFTo9PFr1PvPKyKoeMgBvYPh6cX3aDP7DHKVbnCbi/go-ipfs-cmds/http" path "gx/ipfs/QmX7uSbkNz76yNwBhuwYwRbhihLnJqM73VTCjS3UMJud9A/go-path" config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" + cmds "gx/ipfs/QmZVPuwGNz2s9THwLS4psrJGam6NSEQMvDTaaZgNfqQBCE/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmZVPuwGNz2s9THwLS4psrJGam6NSEQMvDTaaZgNfqQBCE/go-ipfs-cmds/http" ) var ( From 1b09a6e2cc76d30df82f4e3ef84535dd6532cfa7 Mon Sep 17 00:00:00 2001 From: keks Date: Thu, 23 Aug 2018 19:09:15 +0200 Subject: [PATCH 338/674] update go-ipfs-cmds to 2.0.0-beta2 License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@ef21c3bfabb39c60b75dc03aa0e0d69f6b832ac4 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index df9db75d3..f8805ca1e 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + cmds "gx/ipfs/QmSwR1QndLsdnw2mpW2rrywoCUPeY7o8UxtK1dLpPCNFGD/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmSwR1QndLsdnw2mpW2rrywoCUPeY7o8UxtK1dLpPCNFGD/go-ipfs-cmds/http" path "gx/ipfs/QmX7uSbkNz76yNwBhuwYwRbhihLnJqM73VTCjS3UMJud9A/go-path" config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" - cmds "gx/ipfs/QmZVPuwGNz2s9THwLS4psrJGam6NSEQMvDTaaZgNfqQBCE/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmZVPuwGNz2s9THwLS4psrJGam6NSEQMvDTaaZgNfqQBCE/go-ipfs-cmds/http" ) var ( From 36ab7981daf2296c15ee25b421128a778092b3a1 Mon Sep 17 00:00:00 2001 From: keks Date: Mon, 17 Sep 2018 16:12:10 +0200 Subject: [PATCH 339/674] update cmds to 2.0.0-rc1 License: MIT Signed-off-by: keks This commit was moved from ipfs/kubo@f4b32e36f48e375301300bb53846eb02edaaf538 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index f8805ca1e..24a6b3cd4 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - cmds "gx/ipfs/QmSwR1QndLsdnw2mpW2rrywoCUPeY7o8UxtK1dLpPCNFGD/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmSwR1QndLsdnw2mpW2rrywoCUPeY7o8UxtK1dLpPCNFGD/go-ipfs-cmds/http" path "gx/ipfs/QmX7uSbkNz76yNwBhuwYwRbhihLnJqM73VTCjS3UMJud9A/go-path" config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" + cmds "gx/ipfs/QmdsFzGmSLMQQaaPhcgGkpDjPocqBWLFA829u6iMv5huPw/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmdsFzGmSLMQQaaPhcgGkpDjPocqBWLFA829u6iMv5huPw/go-ipfs-cmds/http" ) var ( From 8ddf6da97ce459f8bacc60e1a258399607459220 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 19 Sep 2018 14:16:49 -0700 Subject: [PATCH 340/674] gx: update go-ipfs-cmds to the final release License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@b7484c1bca66960f5302faa81ffeb0f2b0ddd421 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 24a6b3cd4..0704d3f63 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + cmds "gx/ipfs/QmPXR4tNdLbp8HsZiPMjpsgqphX9Vhw2J6Jh5MKH2ovW3D/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmPXR4tNdLbp8HsZiPMjpsgqphX9Vhw2J6Jh5MKH2ovW3D/go-ipfs-cmds/http" path "gx/ipfs/QmX7uSbkNz76yNwBhuwYwRbhihLnJqM73VTCjS3UMJud9A/go-path" config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" - cmds "gx/ipfs/QmdsFzGmSLMQQaaPhcgGkpDjPocqBWLFA829u6iMv5huPw/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmdsFzGmSLMQQaaPhcgGkpDjPocqBWLFA829u6iMv5huPw/go-ipfs-cmds/http" ) var ( From 341408ef0be8df06ee8e9e946bd01378fc3c4190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 24 Sep 2018 14:03:57 +0200 Subject: [PATCH 341/674] gx: update go-libp2p-routing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@91833e288f4d449c85f93d15f4be2ad5199327d9 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 14 +++++++------- gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 0704d3f63..e7e779c72 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -16,8 +16,8 @@ import ( cmds "gx/ipfs/QmPXR4tNdLbp8HsZiPMjpsgqphX9Vhw2J6Jh5MKH2ovW3D/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmPXR4tNdLbp8HsZiPMjpsgqphX9Vhw2J6Jh5MKH2ovW3D/go-ipfs-cmds/http" - path "gx/ipfs/QmX7uSbkNz76yNwBhuwYwRbhihLnJqM73VTCjS3UMJud9A/go-path" config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" + path "gx/ipfs/Qmc17MNY1xUgiE2nopbi6KATWau9qcGZtdmKKuXvFMVUgc/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 7d1bbb6f5..852ae1d00 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,17 +16,17 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - ft "gx/ipfs/QmPL8bYtbACcSFFiSr4s2du7Na382NxRADR8hC7D9FkEA2/go-unixfs" - "gx/ipfs/QmPL8bYtbACcSFFiSr4s2du7Na382NxRADR8hC7D9FkEA2/go-unixfs/importer" - uio "gx/ipfs/QmPL8bYtbACcSFFiSr4s2du7Na382NxRADR8hC7D9FkEA2/go-unixfs/io" - path "gx/ipfs/QmX7uSbkNz76yNwBhuwYwRbhihLnJqM73VTCjS3UMJud9A/go-path" - resolver "gx/ipfs/QmX7uSbkNz76yNwBhuwYwRbhihLnJqM73VTCjS3UMJud9A/go-path/resolver" - dag "gx/ipfs/QmXv5mwmQ74r4aiHcNeQ4GAmfB3aWJuqaE4WyDfDfvkgLM/go-merkledag" + dag "gx/ipfs/QmVB15p7qNVQQGC5RQcAQAovDFaQpRNqorbRwpvdNjHmVC/go-merkledag" + ft "gx/ipfs/QmWqiuwk7ZzUFQvfBuQDwxPxyAQtNMxGYwZkjJuF6GgWQk/go-unixfs" + "gx/ipfs/QmWqiuwk7ZzUFQvfBuQDwxPxyAQtNMxGYwZkjJuF6GgWQk/go-unixfs/importer" + uio "gx/ipfs/QmWqiuwk7ZzUFQvfBuQDwxPxyAQtNMxGYwZkjJuF6GgWQk/go-unixfs/io" + path "gx/ipfs/Qmc17MNY1xUgiE2nopbi6KATWau9qcGZtdmKKuXvFMVUgc/go-path" + resolver "gx/ipfs/Qmc17MNY1xUgiE2nopbi6KATWau9qcGZtdmKKuXvFMVUgc/go-path/resolver" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" + routing "gx/ipfs/QmaM261ArNTmKMybV4LKy68JTZrf5CkCbRGDxsZwYHgqDS/go-libp2p-routing" ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format" - routing "gx/ipfs/QmdKS5YtmuSWKuLLgbHG176mS3VX3AKiyVmaaiAfvgcuch/go-libp2p-routing" chunker "gx/ipfs/QmdSeG9s4EQ9TGruJJS9Us38TQDZtMmFGwzTYUDVqNTURm/go-ipfs-chunker" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index f9379374d..b2ebd111c 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -22,9 +22,9 @@ import ( datastore "gx/ipfs/QmSpg1CvpXQQow5ernt1gNBXaXV6yxyNqi7XoeerWfzB5w/go-datastore" syncds "gx/ipfs/QmSpg1CvpXQQow5ernt1gNBXaXV6yxyNqi7XoeerWfzB5w/go-datastore/sync" id "gx/ipfs/QmUEqyXr97aUbNmQADHYNknjwjjdVpJXEt1UZXmSG81EV4/go-libp2p/p2p/protocol/identify" - path "gx/ipfs/QmX7uSbkNz76yNwBhuwYwRbhihLnJqM73VTCjS3UMJud9A/go-path" - dag "gx/ipfs/QmXv5mwmQ74r4aiHcNeQ4GAmfB3aWJuqaE4WyDfDfvkgLM/go-merkledag" + dag "gx/ipfs/QmVB15p7qNVQQGC5RQcAQAovDFaQpRNqorbRwpvdNjHmVC/go-merkledag" config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" + path "gx/ipfs/Qmc17MNY1xUgiE2nopbi6KATWau9qcGZtdmKKuXvFMVUgc/go-path" ) // `ipfs object new unixfs-dir` From 59348dd160623ab06b5efc1012159d2e111f57f5 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 24 Sep 2018 05:36:29 -0700 Subject: [PATCH 342/674] gx: update go-log go-ipld-cbor (and friends) License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@dac058f8be2d99cf22b2d0905c27fd4c09ff003c --- gateway/core/corehttp/commands.go | 8 ++++---- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 16 ++++++++-------- gateway/core/corehttp/gateway_test.go | 12 ++++++------ gateway/core/corehttp/logs.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index e7e779c72..5cd6670e2 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - cmds "gx/ipfs/QmPXR4tNdLbp8HsZiPMjpsgqphX9Vhw2J6Jh5MKH2ovW3D/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmPXR4tNdLbp8HsZiPMjpsgqphX9Vhw2J6Jh5MKH2ovW3D/go-ipfs-cmds/http" - config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" - path "gx/ipfs/Qmc17MNY1xUgiE2nopbi6KATWau9qcGZtdmKKuXvFMVUgc/go-path" + config "gx/ipfs/QmVBUpxsHh53rNcufqxMpLAmz37eGyLJUaexDy1W9YkiNk/go-ipfs-config" + cmds "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds/http" + path "gx/ipfs/QmcjwUb36Z16NJkvDX6ccXPqsFswo6AsRXynyXcLLCphV2/go-path" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index f5bb0882e..43f0f47ca 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,11 +12,11 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - logging "gx/ipfs/QmRREK2CAZ5Re2Bd9zZFG6FeYDppUWt5cMgsoUEp3ktgSr/go-log" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" periodicproc "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/periodic" manet "gx/ipfs/QmV6FjemM1K8oXjrvuq3wuVWWoU2TLDPmNnKrxHzY3v6Ai/go-multiaddr-net" ma "gx/ipfs/QmYmsdtJ3HsodkePE3eU3TsCaP2YvPZJ4LoXnNkDE5Tpt7/go-multiaddr" + logging "gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 67e26b5da..eaba8fc3f 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmUEqyXr97aUbNmQADHYNknjwjjdVpJXEt1UZXmSG81EV4/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmVsVARb86uSe1qYouewFMNd2p2sp2NGWm1JGPReVDWchW/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 852ae1d00..9e0b8e1ec 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,18 +16,18 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - dag "gx/ipfs/QmVB15p7qNVQQGC5RQcAQAovDFaQpRNqorbRwpvdNjHmVC/go-merkledag" - ft "gx/ipfs/QmWqiuwk7ZzUFQvfBuQDwxPxyAQtNMxGYwZkjJuF6GgWQk/go-unixfs" - "gx/ipfs/QmWqiuwk7ZzUFQvfBuQDwxPxyAQtNMxGYwZkjJuF6GgWQk/go-unixfs/importer" - uio "gx/ipfs/QmWqiuwk7ZzUFQvfBuQDwxPxyAQtNMxGYwZkjJuF6GgWQk/go-unixfs/io" - path "gx/ipfs/Qmc17MNY1xUgiE2nopbi6KATWau9qcGZtdmKKuXvFMVUgc/go-path" - resolver "gx/ipfs/Qmc17MNY1xUgiE2nopbi6KATWau9qcGZtdmKKuXvFMVUgc/go-path/resolver" + ft "gx/ipfs/QmU4x3742bvgfxJsByEDpBnifJqjJdV6x528co4hwKCn46/go-unixfs" + "gx/ipfs/QmU4x3742bvgfxJsByEDpBnifJqjJdV6x528co4hwKCn46/go-unixfs/importer" + uio "gx/ipfs/QmU4x3742bvgfxJsByEDpBnifJqjJdV6x528co4hwKCn46/go-unixfs/io" + dag "gx/ipfs/QmcBoNcAP6qDjgRBew7yjvCqHq7p5jMstE44jPUBWBxzsV/go-merkledag" + path "gx/ipfs/QmcjwUb36Z16NJkvDX6ccXPqsFswo6AsRXynyXcLLCphV2/go-path" + resolver "gx/ipfs/QmcjwUb36Z16NJkvDX6ccXPqsFswo6AsRXynyXcLLCphV2/go-path/resolver" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" - routing "gx/ipfs/QmaM261ArNTmKMybV4LKy68JTZrf5CkCbRGDxsZwYHgqDS/go-libp2p-routing" + chunker "gx/ipfs/QmULKgr55cSWR8Kiwy3cVRcAiGVnR6EVSaB7hJcWS4138p/go-ipfs-chunker" + routing "gx/ipfs/QmVBnJDKhtFXTRVjXKinqpwGu8t1DyNqPKan2iGX8PR8xG/go-libp2p-routing" ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format" - chunker "gx/ipfs/QmdSeG9s4EQ9TGruJJS9Us38TQDZtMmFGwzTYUDVqNTURm/go-ipfs-chunker" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index b2ebd111c..83e2ea5e8 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,12 +19,12 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - datastore "gx/ipfs/QmSpg1CvpXQQow5ernt1gNBXaXV6yxyNqi7XoeerWfzB5w/go-datastore" - syncds "gx/ipfs/QmSpg1CvpXQQow5ernt1gNBXaXV6yxyNqi7XoeerWfzB5w/go-datastore/sync" - id "gx/ipfs/QmUEqyXr97aUbNmQADHYNknjwjjdVpJXEt1UZXmSG81EV4/go-libp2p/p2p/protocol/identify" - dag "gx/ipfs/QmVB15p7qNVQQGC5RQcAQAovDFaQpRNqorbRwpvdNjHmVC/go-merkledag" - config "gx/ipfs/QmYVqYJTVjetcf1guieEgWpK1PZtHPytP624vKzTF1P3r2/go-ipfs-config" - path "gx/ipfs/Qmc17MNY1xUgiE2nopbi6KATWau9qcGZtdmKKuXvFMVUgc/go-path" + datastore "gx/ipfs/QmUyz7JTJzgegC6tiJrfby3mPhzcdswVtG4x58TQ6pq8jV/go-datastore" + syncds "gx/ipfs/QmUyz7JTJzgegC6tiJrfby3mPhzcdswVtG4x58TQ6pq8jV/go-datastore/sync" + config "gx/ipfs/QmVBUpxsHh53rNcufqxMpLAmz37eGyLJUaexDy1W9YkiNk/go-ipfs-config" + id "gx/ipfs/QmVsVARb86uSe1qYouewFMNd2p2sp2NGWm1JGPReVDWchW/go-libp2p/p2p/protocol/identify" + dag "gx/ipfs/QmcBoNcAP6qDjgRBew7yjvCqHq7p5jMstE44jPUBWBxzsV/go-merkledag" + path "gx/ipfs/QmcjwUb36Z16NJkvDX6ccXPqsFswo6AsRXynyXcLLCphV2/go-path" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index d0829de12..0c55fe583 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - lwriter "gx/ipfs/QmRREK2CAZ5Re2Bd9zZFG6FeYDppUWt5cMgsoUEp3ktgSr/go-log/writer" + lwriter "gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log/writer" ) type writeErrNotifier struct { diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 9f29753aa..09bcf6140 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmUEqyXr97aUbNmQADHYNknjwjjdVpJXEt1UZXmSG81EV4/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmZNJyx9GGCX4GeuHnLB8fxaxMLs4MjTjHokxfQcCd6Nve/go-libp2p-net" - swarmt "gx/ipfs/QmeDpqUwwdye8ABKVMPXKuWwPVURFdqTqssbTUB39E2Nwd/go-libp2p-swarm/testing" + swarmt "gx/ipfs/QmPQoCVRHaGD25VffyB7DFV5qP65hFSQJdSDy75P1vYBKe/go-libp2p-swarm/testing" + bhost "gx/ipfs/QmVsVARb86uSe1qYouewFMNd2p2sp2NGWm1JGPReVDWchW/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmfDPh144WGBqRxZb1TGDHerbMnZATrHZggAPw7putNnBq/go-libp2p-net" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 450829b47e7fb8579c39c75b2da989474dd9a4ab Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 26 Sep 2018 21:10:51 +0200 Subject: [PATCH 343/674] pprof: create HTTP endpoint for setting MutexProfileFraction Allows to dynamically change the MutexProfileFraction to enable and disable mutex profiling. It should be very useful for detecting deadlocks, lock contention and general concurrency problems. How to use: To enable run: curl -X POST -v 'localhost:5001/debug/pprof-mutex/?fraction=10 To disable: curl -X POST -v 'localhost:5001/debug/pprof-mutex/?fraction=0' Fraction defines which fraction of events will be profiled. Higher it is the lower performance impact but less reliable the result. To fetch the result use: go tool pprof $PATH_TO_IPFS_BIN http://localhost:5001/debug/pprof/mutex License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@50fffa2973452862ff1a805956f324da1b887f36 --- gateway/core/corehttp/mutex_profile.go | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 gateway/core/corehttp/mutex_profile.go diff --git a/gateway/core/corehttp/mutex_profile.go b/gateway/core/corehttp/mutex_profile.go new file mode 100644 index 000000000..db39a7bc9 --- /dev/null +++ b/gateway/core/corehttp/mutex_profile.go @@ -0,0 +1,45 @@ +package corehttp + +import ( + "net" + "net/http" + "runtime" + "strconv" + + core "github.com/ipfs/go-ipfs/core" +) + +// MutexFractionOption allows to set runtime.SetMutexProfileFraction via HTTP +// using POST request with parameter 'fraction'. +func MutexFractionOption(path string) ServeOption { + return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { + mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } + if err := r.ParseForm(); err != nil { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(err.Error())) + return + } + + asfr := r.Form.Get("fraction") + if len(asfr) == 0 { + w.WriteHeader(http.StatusBadRequest) + return + } + + fr, err := strconv.Atoi(asfr) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(err.Error())) + return + } + log.Infof("Setting MutexProfileFraction to %d", fr) + runtime.SetMutexProfileFraction(fr) + }) + + return mux, nil + } +} From fed0ef6ffa0d7595c166e7f88e624e222d29dc69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 28 Aug 2018 01:06:12 +0200 Subject: [PATCH 344/674] namesys: async: go vet fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@6adb15f4fb3c2bc64207972339f4f0a32b1cf834 --- gateway/core/corehttp/gateway_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 83e2ea5e8..f93c8844c 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -35,7 +35,7 @@ type mockNamesys map[string]path.Path func (m mockNamesys) Resolve(ctx context.Context, name string, opts ...nsopts.ResolveOpt) (value path.Path, err error) { cfg := nsopts.DefaultResolveOpts() for _, o := range opts { - o(cfg) + o(&cfg) } depth := cfg.Depth if depth == nsopts.UnlimitedDepth { @@ -57,6 +57,14 @@ func (m mockNamesys) Resolve(ctx context.Context, name string, opts ...nsopts.Re return value, nil } +func (m mockNamesys) ResolveAsync(ctx context.Context, name string, opts ...nsopts.ResolveOpt) <-chan namesys.Result { + out := make(chan namesys.Result, 1) + v, err := m.Resolve(ctx, name, opts...) + out <- namesys.Result{Path: v, Err: err} + close(out) + return nil +} + func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value path.Path) error { return errors.New("not implemented for mockNamesys") } From e84af84ebb788c24e6a5840b1c62f96c6bf0d5ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 3 Oct 2018 15:05:46 +0200 Subject: [PATCH 345/674] coreapi unixfs: multi file support in unixfs coreapi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@e6bc92342503edba0b7d71cfafa1747fa1cc6816 --- gateway/core/corehttp/gateway_handler.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 9e0b8e1ec..e5e2ae78a 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "io" + "io/ioutil" "net/http" "net/url" "os" @@ -25,6 +26,7 @@ import ( humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" + files "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit/files" chunker "gx/ipfs/QmULKgr55cSWR8Kiwy3cVRcAiGVnR6EVSaB7hJcWS4138p/go-ipfs-chunker" routing "gx/ipfs/QmVBnJDKhtFXTRVjXKinqpwGu8t1DyNqPKan2iGX8PR8xG/go-libp2p-routing" ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format" @@ -398,7 +400,7 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam } func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { - p, err := i.api.Unixfs().Add(ctx, r.Body) + p, err := i.api.Unixfs().Add(ctx, files.NewReaderFile("", "", ioutil.NopCloser(r.Body), nil)) if err != nil { internalWebError(w, err) return From ce48c2df0015e6b794511cbab1ed20ee336ca770 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Wed, 3 Oct 2018 07:35:57 +0200 Subject: [PATCH 346/674] gx: update go-datastore, go-libp2p-swarm License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@2c3ed7efb04bd0b0ffddb8fbeb0a5237ef0db579 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 14 +++++++------- gateway/core/corehttp/gateway_test.go | 12 ++++++------ gateway/core/corehttp/metrics_test.go | 6 +++--- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 5cd6670e2..c55928cc7 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - config "gx/ipfs/QmVBUpxsHh53rNcufqxMpLAmz37eGyLJUaexDy1W9YkiNk/go-ipfs-config" cmds "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds/http" - path "gx/ipfs/QmcjwUb36Z16NJkvDX6ccXPqsFswo6AsRXynyXcLLCphV2/go-path" + config "gx/ipfs/QmYJi32193V4FBJa4pXXwVNh4puvY7Qn3X5e1r3xQVWgY1/go-ipfs-config" + path "gx/ipfs/QmbE9gr6c2FomTgc2pRZRTooHpchJ1uaZKremypyWJMV4t/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index eaba8fc3f..99c948a1b 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmVsVARb86uSe1qYouewFMNd2p2sp2NGWm1JGPReVDWchW/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/Qmd9zWxAeeDJoLdxqvaDXAGtoafX5cc9Tp25DNm9W7fVnB/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 9e0b8e1ec..cffb846b3 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,17 +16,17 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - ft "gx/ipfs/QmU4x3742bvgfxJsByEDpBnifJqjJdV6x528co4hwKCn46/go-unixfs" - "gx/ipfs/QmU4x3742bvgfxJsByEDpBnifJqjJdV6x528co4hwKCn46/go-unixfs/importer" - uio "gx/ipfs/QmU4x3742bvgfxJsByEDpBnifJqjJdV6x528co4hwKCn46/go-unixfs/io" - dag "gx/ipfs/QmcBoNcAP6qDjgRBew7yjvCqHq7p5jMstE44jPUBWBxzsV/go-merkledag" - path "gx/ipfs/QmcjwUb36Z16NJkvDX6ccXPqsFswo6AsRXynyXcLLCphV2/go-path" - resolver "gx/ipfs/QmcjwUb36Z16NJkvDX6ccXPqsFswo6AsRXynyXcLLCphV2/go-path/resolver" + dag "gx/ipfs/QmRfWhkc5eHLzZ1FActaXNeThijM2CY6JWc2qynQExFFJm/go-merkledag" + ft "gx/ipfs/QmXYXeWXMa6XaqLthwc9gYzBdobRGBemWNv228XnAwqW9q/go-unixfs" + "gx/ipfs/QmXYXeWXMa6XaqLthwc9gYzBdobRGBemWNv228XnAwqW9q/go-unixfs/importer" + uio "gx/ipfs/QmXYXeWXMa6XaqLthwc9gYzBdobRGBemWNv228XnAwqW9q/go-unixfs/io" + path "gx/ipfs/QmbE9gr6c2FomTgc2pRZRTooHpchJ1uaZKremypyWJMV4t/go-path" + resolver "gx/ipfs/QmbE9gr6c2FomTgc2pRZRTooHpchJ1uaZKremypyWJMV4t/go-path/resolver" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" + routing "gx/ipfs/QmQRfifvvbJ8xTKj4KX1VvGWK26hnPiy8eQvW1hmjc82nD/go-libp2p-routing" chunker "gx/ipfs/QmULKgr55cSWR8Kiwy3cVRcAiGVnR6EVSaB7hJcWS4138p/go-ipfs-chunker" - routing "gx/ipfs/QmVBnJDKhtFXTRVjXKinqpwGu8t1DyNqPKan2iGX8PR8xG/go-libp2p-routing" ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 83e2ea5e8..59f1a5a87 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,12 +19,12 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - datastore "gx/ipfs/QmUyz7JTJzgegC6tiJrfby3mPhzcdswVtG4x58TQ6pq8jV/go-datastore" - syncds "gx/ipfs/QmUyz7JTJzgegC6tiJrfby3mPhzcdswVtG4x58TQ6pq8jV/go-datastore/sync" - config "gx/ipfs/QmVBUpxsHh53rNcufqxMpLAmz37eGyLJUaexDy1W9YkiNk/go-ipfs-config" - id "gx/ipfs/QmVsVARb86uSe1qYouewFMNd2p2sp2NGWm1JGPReVDWchW/go-libp2p/p2p/protocol/identify" - dag "gx/ipfs/QmcBoNcAP6qDjgRBew7yjvCqHq7p5jMstE44jPUBWBxzsV/go-merkledag" - path "gx/ipfs/QmcjwUb36Z16NJkvDX6ccXPqsFswo6AsRXynyXcLLCphV2/go-path" + dag "gx/ipfs/QmRfWhkc5eHLzZ1FActaXNeThijM2CY6JWc2qynQExFFJm/go-merkledag" + config "gx/ipfs/QmYJi32193V4FBJa4pXXwVNh4puvY7Qn3X5e1r3xQVWgY1/go-ipfs-config" + path "gx/ipfs/QmbE9gr6c2FomTgc2pRZRTooHpchJ1uaZKremypyWJMV4t/go-path" + datastore "gx/ipfs/QmbQshXLNcCPRUGZv4sBGxnZNAHREA6MKeomkwihNXPZWP/go-datastore" + syncds "gx/ipfs/QmbQshXLNcCPRUGZv4sBGxnZNAHREA6MKeomkwihNXPZWP/go-datastore/sync" + id "gx/ipfs/Qmd9zWxAeeDJoLdxqvaDXAGtoafX5cc9Tp25DNm9W7fVnB/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 09bcf6140..128e941f6 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - swarmt "gx/ipfs/QmPQoCVRHaGD25VffyB7DFV5qP65hFSQJdSDy75P1vYBKe/go-libp2p-swarm/testing" - bhost "gx/ipfs/QmVsVARb86uSe1qYouewFMNd2p2sp2NGWm1JGPReVDWchW/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmfDPh144WGBqRxZb1TGDHerbMnZATrHZggAPw7putNnBq/go-libp2p-net" + inet "gx/ipfs/QmQdLcvoy3JuSqhV6iwQ9T6Cv7hWLAdzob4jUZRPqFL67Z/go-libp2p-net" + swarmt "gx/ipfs/QmcyQj1V6Ht8uSrRqj865UXGUo5Sc8GxNA4U8bLQxCSmfX/go-libp2p-swarm/testing" + bhost "gx/ipfs/Qmd9zWxAeeDJoLdxqvaDXAGtoafX5cc9Tp25DNm9W7fVnB/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From e81bba9da51a4d7a418da56e5ca6d31a960c1678 Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Wed, 3 Oct 2018 08:16:06 +0200 Subject: [PATCH 347/674] gx: update go-ipfs-config, iptb License: MIT Signed-off-by: Lars Gierth This commit was moved from ipfs/kubo@fc2575740e279bdffc88ae5475ffd396c2218d6b --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index c55928cc7..5df2612f1 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,9 +14,9 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" cmds "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds/http" - config "gx/ipfs/QmYJi32193V4FBJa4pXXwVNh4puvY7Qn3X5e1r3xQVWgY1/go-ipfs-config" path "gx/ipfs/QmbE9gr6c2FomTgc2pRZRTooHpchJ1uaZKremypyWJMV4t/go-path" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 59f1a5a87..c79107e5b 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,7 +20,7 @@ import ( ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" dag "gx/ipfs/QmRfWhkc5eHLzZ1FActaXNeThijM2CY6JWc2qynQExFFJm/go-merkledag" - config "gx/ipfs/QmYJi32193V4FBJa4pXXwVNh4puvY7Qn3X5e1r3xQVWgY1/go-ipfs-config" + config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" path "gx/ipfs/QmbE9gr6c2FomTgc2pRZRTooHpchJ1uaZKremypyWJMV4t/go-path" datastore "gx/ipfs/QmbQshXLNcCPRUGZv4sBGxnZNAHREA6MKeomkwihNXPZWP/go-datastore" syncds "gx/ipfs/QmbQshXLNcCPRUGZv4sBGxnZNAHREA6MKeomkwihNXPZWP/go-datastore/sync" From 38f666e1857ad73ec65cc8c274355f3f5dc19700 Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Thu, 4 Oct 2018 19:11:27 -0400 Subject: [PATCH 348/674] gx update go-libp2p-peerstore License: MIT Signed-off-by: Kevin Atkinson This commit was moved from ipfs/kubo@2e975add22593ec5a993a0e8b392579e47b57ca4 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 5df2612f1..371d083f6 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -17,7 +17,7 @@ import ( config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" cmds "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds/http" - path "gx/ipfs/QmbE9gr6c2FomTgc2pRZRTooHpchJ1uaZKremypyWJMV4t/go-path" + path "gx/ipfs/QmYh33CFYYEgQNSZ9PEP7ZN57dhErRZ7NfLS1BUA9GBBRk/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index cffb846b3..1ee91e72d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,12 +16,12 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - dag "gx/ipfs/QmRfWhkc5eHLzZ1FActaXNeThijM2CY6JWc2qynQExFFJm/go-merkledag" - ft "gx/ipfs/QmXYXeWXMa6XaqLthwc9gYzBdobRGBemWNv228XnAwqW9q/go-unixfs" - "gx/ipfs/QmXYXeWXMa6XaqLthwc9gYzBdobRGBemWNv228XnAwqW9q/go-unixfs/importer" - uio "gx/ipfs/QmXYXeWXMa6XaqLthwc9gYzBdobRGBemWNv228XnAwqW9q/go-unixfs/io" - path "gx/ipfs/QmbE9gr6c2FomTgc2pRZRTooHpchJ1uaZKremypyWJMV4t/go-path" - resolver "gx/ipfs/QmbE9gr6c2FomTgc2pRZRTooHpchJ1uaZKremypyWJMV4t/go-path/resolver" + path "gx/ipfs/QmYh33CFYYEgQNSZ9PEP7ZN57dhErRZ7NfLS1BUA9GBBRk/go-path" + resolver "gx/ipfs/QmYh33CFYYEgQNSZ9PEP7ZN57dhErRZ7NfLS1BUA9GBBRk/go-path/resolver" + dag "gx/ipfs/Qmb5kvkvMyuaJ9e58vLh3TdRWgH9CCQPLJD4BgvNQvQFwf/go-merkledag" + ft "gx/ipfs/QmdF8ovKr2zNMWi2hiDMqQAQeNw35xwytb1W7Ydwsf1ufx/go-unixfs" + "gx/ipfs/QmdF8ovKr2zNMWi2hiDMqQAQeNw35xwytb1W7Ydwsf1ufx/go-unixfs/importer" + uio "gx/ipfs/QmdF8ovKr2zNMWi2hiDMqQAQeNw35xwytb1W7Ydwsf1ufx/go-unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index c79107e5b..46f505631 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,9 +19,9 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - dag "gx/ipfs/QmRfWhkc5eHLzZ1FActaXNeThijM2CY6JWc2qynQExFFJm/go-merkledag" config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" - path "gx/ipfs/QmbE9gr6c2FomTgc2pRZRTooHpchJ1uaZKremypyWJMV4t/go-path" + path "gx/ipfs/QmYh33CFYYEgQNSZ9PEP7ZN57dhErRZ7NfLS1BUA9GBBRk/go-path" + dag "gx/ipfs/Qmb5kvkvMyuaJ9e58vLh3TdRWgH9CCQPLJD4BgvNQvQFwf/go-merkledag" datastore "gx/ipfs/QmbQshXLNcCPRUGZv4sBGxnZNAHREA6MKeomkwihNXPZWP/go-datastore" syncds "gx/ipfs/QmbQshXLNcCPRUGZv4sBGxnZNAHREA6MKeomkwihNXPZWP/go-datastore/sync" id "gx/ipfs/Qmd9zWxAeeDJoLdxqvaDXAGtoafX5cc9Tp25DNm9W7fVnB/go-libp2p/p2p/protocol/identify" From d641d412cc915fabc8bd61812ffafb0ee6de4fbd Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Thu, 4 Oct 2018 19:32:33 -0400 Subject: [PATCH 349/674] gx update libp2p/go-buffer-pool License: MIT Signed-off-by: Kevin Atkinson This commit was moved from ipfs/kubo@d127f1be98f0d8d4816efb584f4f8eb7a39b4fef --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 6 +++--- gateway/core/corehttp/metrics_test.go | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 371d083f6..e07422b61 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,9 +15,9 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" + path "gx/ipfs/QmV4QxScV9Y7LbaWhHazFfRd8uyeUd4pAH8a7fFFbi5odJ/go-path" cmds "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds/http" - path "gx/ipfs/QmYh33CFYYEgQNSZ9PEP7ZN57dhErRZ7NfLS1BUA9GBBRk/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 99c948a1b..a0c607df8 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/Qmd9zWxAeeDJoLdxqvaDXAGtoafX5cc9Tp25DNm9W7fVnB/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmNmj2AeM46ZQqHARnWidb5qqHoZJFeYWzmG65jviJDRQY/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1ee91e72d..779a64da4 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,12 +16,12 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - path "gx/ipfs/QmYh33CFYYEgQNSZ9PEP7ZN57dhErRZ7NfLS1BUA9GBBRk/go-path" - resolver "gx/ipfs/QmYh33CFYYEgQNSZ9PEP7ZN57dhErRZ7NfLS1BUA9GBBRk/go-path/resolver" - dag "gx/ipfs/Qmb5kvkvMyuaJ9e58vLh3TdRWgH9CCQPLJD4BgvNQvQFwf/go-merkledag" - ft "gx/ipfs/QmdF8ovKr2zNMWi2hiDMqQAQeNw35xwytb1W7Ydwsf1ufx/go-unixfs" - "gx/ipfs/QmdF8ovKr2zNMWi2hiDMqQAQeNw35xwytb1W7Ydwsf1ufx/go-unixfs/importer" - uio "gx/ipfs/QmdF8ovKr2zNMWi2hiDMqQAQeNw35xwytb1W7Ydwsf1ufx/go-unixfs/io" + dag "gx/ipfs/QmTGpm48qm4fUZ9E5hMXy4ZngJUYCMKu15rTMVR3BSEnPm/go-merkledag" + path "gx/ipfs/QmV4QxScV9Y7LbaWhHazFfRd8uyeUd4pAH8a7fFFbi5odJ/go-path" + resolver "gx/ipfs/QmV4QxScV9Y7LbaWhHazFfRd8uyeUd4pAH8a7fFFbi5odJ/go-path/resolver" + ft "gx/ipfs/QmavvHwEZTkNShKWK1jRejv2Y8oF6ZYxdGxytL3Mwvices/go-unixfs" + "gx/ipfs/QmavvHwEZTkNShKWK1jRejv2Y8oF6ZYxdGxytL3Mwvices/go-unixfs/importer" + uio "gx/ipfs/QmavvHwEZTkNShKWK1jRejv2Y8oF6ZYxdGxytL3Mwvices/go-unixfs/io" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 46f505631..a1afff08a 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,13 +18,13 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" + id "gx/ipfs/QmNmj2AeM46ZQqHARnWidb5qqHoZJFeYWzmG65jviJDRQY/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" - path "gx/ipfs/QmYh33CFYYEgQNSZ9PEP7ZN57dhErRZ7NfLS1BUA9GBBRk/go-path" - dag "gx/ipfs/Qmb5kvkvMyuaJ9e58vLh3TdRWgH9CCQPLJD4BgvNQvQFwf/go-merkledag" + dag "gx/ipfs/QmTGpm48qm4fUZ9E5hMXy4ZngJUYCMKu15rTMVR3BSEnPm/go-merkledag" + path "gx/ipfs/QmV4QxScV9Y7LbaWhHazFfRd8uyeUd4pAH8a7fFFbi5odJ/go-path" datastore "gx/ipfs/QmbQshXLNcCPRUGZv4sBGxnZNAHREA6MKeomkwihNXPZWP/go-datastore" syncds "gx/ipfs/QmbQshXLNcCPRUGZv4sBGxnZNAHREA6MKeomkwihNXPZWP/go-datastore/sync" - id "gx/ipfs/Qmd9zWxAeeDJoLdxqvaDXAGtoafX5cc9Tp25DNm9W7fVnB/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 128e941f6..10dff2ccf 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" + bhost "gx/ipfs/QmNmj2AeM46ZQqHARnWidb5qqHoZJFeYWzmG65jviJDRQY/go-libp2p/p2p/host/basic" inet "gx/ipfs/QmQdLcvoy3JuSqhV6iwQ9T6Cv7hWLAdzob4jUZRPqFL67Z/go-libp2p-net" - swarmt "gx/ipfs/QmcyQj1V6Ht8uSrRqj865UXGUo5Sc8GxNA4U8bLQxCSmfX/go-libp2p-swarm/testing" - bhost "gx/ipfs/Qmd9zWxAeeDJoLdxqvaDXAGtoafX5cc9Tp25DNm9W7fVnB/go-libp2p/p2p/host/basic" + swarmt "gx/ipfs/QmcALnLPFXgLLaZkXzGv99yt8xPfiWqFTumiXpWBJbU9cY/go-libp2p-swarm/testing" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 8419810463e4afa177e25ebfd427c3cea8ded413 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 4 Oct 2018 15:36:29 -0700 Subject: [PATCH 350/674] don't use the domain name as a filename in /ipns/a.com fixes #5369 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@47e7f693ebc22f9f7b5e1876fd16b31c46a83307 --- gateway/core/corehttp/gateway_handler.go | 10 +++++++++- gateway/core/corehttp/gateway_test.go | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 9e0b8e1ec..bba9dde90 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -266,7 +266,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr w.Header().Set("Content-Disposition", fmt.Sprintf("inline; filename*=UTF-8''%s", url.PathEscape(urlFilename))) name = urlFilename } else { - name = gopath.Base(urlPath) + name = getFilename(urlPath) } i.serveFile(w, r, name, modtime, dr) return @@ -624,3 +624,11 @@ func webErrorWithCode(w http.ResponseWriter, message string, err error, code int func internalWebError(w http.ResponseWriter, err error) { webErrorWithCode(w, "internalWebError", err, http.StatusInternalServerError) } + +func getFilename(s string) string { + if (strings.HasPrefix(s, ipfsPathPrefix) || strings.HasPrefix(s, ipnsPathPrefix)) && strings.Count(gopath.Clean(s), "/") <= 2 { + // Don't want to treat ipfs.io in /ipns/ipfs.io as a filename. + return "" + } + return gopath.Base(s) +} diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 83e2ea5e8..106f4c214 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -153,6 +153,7 @@ func TestGatewayGet(t *testing.T) { ns["/ipns/double.example.com"] = path.FromString("/ipns/working.example.com") ns["/ipns/triple.example.com"] = path.FromString("/ipns/double.example.com") ns["/ipns/broken.example.com"] = path.FromString("/ipns/" + k) + ns["/ipns/example.man"] = path.FromString("/ipfs/" + k) t.Log(ts.URL) for _, test := range []struct { @@ -175,6 +176,7 @@ func TestGatewayGet(t *testing.T) { {"working.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/working.example.com/ipfs/" + k + ": no link by that name\n"}, {"broken.example.com", "/", http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/: " + namesys.ErrResolveFailed.Error() + "\n"}, {"broken.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/ipfs/" + k + ": " + namesys.ErrResolveFailed.Error() + "\n"}, + {"example.man", "/", http.StatusOK, "fnord"}, } { var c http.Client r, err := http.NewRequest("GET", ts.URL+test.path, nil) @@ -190,6 +192,10 @@ func TestGatewayGet(t *testing.T) { continue } defer resp.Body.Close() + contentType := resp.Header.Get("Content-Type") + if contentType != "text/plain; charset=utf-8" { + t.Errorf("expected content type to be text/plain, got %s", contentType) + } if resp.StatusCode != test.status { t.Errorf("got %d, expected %d from %s", resp.StatusCode, test.status, urlstr) continue From c8a15ccec27f3c6a088b0209b1f7320c9ec738d9 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 4 Oct 2018 21:42:07 -0700 Subject: [PATCH 351/674] gateway test: document why .man License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@afd81fd5dd973a065b7002fb4176f507a2c728df --- gateway/core/corehttp/gateway_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 106f4c214..bfd7b506b 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -153,6 +153,11 @@ func TestGatewayGet(t *testing.T) { ns["/ipns/double.example.com"] = path.FromString("/ipns/working.example.com") ns["/ipns/triple.example.com"] = path.FromString("/ipns/double.example.com") ns["/ipns/broken.example.com"] = path.FromString("/ipns/" + k) + // We picked .man because: + // 1. It's a valid TLD. + // 2. Go treats it as the file extension for "man" files (even though + // nobody actually *uses* this extension, AFAIK). + // 3. Go accepts "fnord" (the test value) as a valid man file. ns["/ipns/example.man"] = path.FromString("/ipfs/" + k) t.Log(ts.URL) @@ -176,6 +181,7 @@ func TestGatewayGet(t *testing.T) { {"working.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/working.example.com/ipfs/" + k + ": no link by that name\n"}, {"broken.example.com", "/", http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/: " + namesys.ErrResolveFailed.Error() + "\n"}, {"broken.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/ipfs/" + k + ": " + namesys.ErrResolveFailed.Error() + "\n"}, + // This test case ensures we don't treat the TLD as a file extension. {"example.man", "/", http.StatusOK, "fnord"}, } { var c http.Client From 23f65c8cfa66b2b48b7a1621e4a561c347d44cc3 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 5 Oct 2018 11:24:36 -0700 Subject: [PATCH 352/674] gateway_test: comment on platform dependence License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@f498459ad2934a46578e97f4d96bd92d68eed5a2 --- gateway/core/corehttp/gateway_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index bfd7b506b..ce178ffed 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -157,7 +157,9 @@ func TestGatewayGet(t *testing.T) { // 1. It's a valid TLD. // 2. Go treats it as the file extension for "man" files (even though // nobody actually *uses* this extension, AFAIK). - // 3. Go accepts "fnord" (the test value) as a valid man file. + // + // Unfortunately, this may not work on all platforms as file type + // detection is platform dependent. ns["/ipns/example.man"] = path.FromString("/ipfs/" + k) t.Log(ts.URL) From 91c11c73985b86bedb9d7aeb1732afeefb52bc3a Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 5 Oct 2018 14:11:56 -0700 Subject: [PATCH 353/674] gx: update stuff * go-datastore and friends: GetSize * badger: new release, fewer allocations * go-mplex: send fewer packets * go-bitswap: pack multiple blocks in a single message, fewer allocations * go-buffer-pool: replace the buffer pool from go-msgio * yamux: fixed data race and uses go-buffer-pool for stream read-buffers to reduce memory and allocations. * go-libp2p-secio: get rid of a hot-spot allocation * go-libp2p-peerstore: reduced allocations (at the cost of some memory) More? License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@098933ade48a28806370757a861f4c6eb2244cfb --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 16 ++++++++-------- gateway/core/corehttp/gateway_test.go | 10 +++++----- gateway/core/corehttp/metrics_test.go | 6 +++--- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index e07422b61..d98469ee3 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,8 +14,8 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + path "gx/ipfs/QmQmMu1vsgsjxyB8tzrA6ZTCTCLDLVaXMb4Q57r2v886Sx/go-path" config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" - path "gx/ipfs/QmV4QxScV9Y7LbaWhHazFfRd8uyeUd4pAH8a7fFFbi5odJ/go-path" cmds "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds/http" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index a0c607df8..3ab6dcde3 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmNmj2AeM46ZQqHARnWidb5qqHoZJFeYWzmG65jviJDRQY/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmU9Cf9q5TBCAC3kg74Fqr6K7DQTwa41C44YypYqB2GfR8/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1f2466acc..00631df41 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -17,18 +17,18 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - dag "gx/ipfs/QmTGpm48qm4fUZ9E5hMXy4ZngJUYCMKu15rTMVR3BSEnPm/go-merkledag" - path "gx/ipfs/QmV4QxScV9Y7LbaWhHazFfRd8uyeUd4pAH8a7fFFbi5odJ/go-path" - resolver "gx/ipfs/QmV4QxScV9Y7LbaWhHazFfRd8uyeUd4pAH8a7fFFbi5odJ/go-path/resolver" - ft "gx/ipfs/QmavvHwEZTkNShKWK1jRejv2Y8oF6ZYxdGxytL3Mwvices/go-unixfs" - "gx/ipfs/QmavvHwEZTkNShKWK1jRejv2Y8oF6ZYxdGxytL3Mwvices/go-unixfs/importer" - uio "gx/ipfs/QmavvHwEZTkNShKWK1jRejv2Y8oF6ZYxdGxytL3Mwvices/go-unixfs/io" + ft "gx/ipfs/QmQDcPcBH8nfz3JB4K4oEvxhRmBwCrMgvG966XpExEWexf/go-unixfs" + "gx/ipfs/QmQDcPcBH8nfz3JB4K4oEvxhRmBwCrMgvG966XpExEWexf/go-unixfs/importer" + uio "gx/ipfs/QmQDcPcBH8nfz3JB4K4oEvxhRmBwCrMgvG966XpExEWexf/go-unixfs/io" + path "gx/ipfs/QmQmMu1vsgsjxyB8tzrA6ZTCTCLDLVaXMb4Q57r2v886Sx/go-path" + resolver "gx/ipfs/QmQmMu1vsgsjxyB8tzrA6ZTCTCLDLVaXMb4Q57r2v886Sx/go-path/resolver" + dag "gx/ipfs/QmXTw4By9FMZAt7qJm4JoJuNBrBgqMMzkS4AjKc4zqTUVd/go-merkledag" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" - routing "gx/ipfs/QmQRfifvvbJ8xTKj4KX1VvGWK26hnPiy8eQvW1hmjc82nD/go-libp2p-routing" files "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit/files" - chunker "gx/ipfs/QmULKgr55cSWR8Kiwy3cVRcAiGVnR6EVSaB7hJcWS4138p/go-ipfs-chunker" + routing "gx/ipfs/QmVQPj6rHdqz6dDQrjcdP36zDYLaoB7xwqRg39kx2PqqKU/go-libp2p-routing" + chunker "gx/ipfs/QmbrQ27wGQeE8spxjbw9mk5Ef7as4tRFSnWLkEGg4xeg2f/go-ipfs-chunker" ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index a3f299bb6..8b5b143b3 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,13 +18,13 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" - id "gx/ipfs/QmNmj2AeM46ZQqHARnWidb5qqHoZJFeYWzmG65jviJDRQY/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" + path "gx/ipfs/QmQmMu1vsgsjxyB8tzrA6ZTCTCLDLVaXMb4Q57r2v886Sx/go-path" config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" - dag "gx/ipfs/QmTGpm48qm4fUZ9E5hMXy4ZngJUYCMKu15rTMVR3BSEnPm/go-merkledag" - path "gx/ipfs/QmV4QxScV9Y7LbaWhHazFfRd8uyeUd4pAH8a7fFFbi5odJ/go-path" - datastore "gx/ipfs/QmbQshXLNcCPRUGZv4sBGxnZNAHREA6MKeomkwihNXPZWP/go-datastore" - syncds "gx/ipfs/QmbQshXLNcCPRUGZv4sBGxnZNAHREA6MKeomkwihNXPZWP/go-datastore/sync" + id "gx/ipfs/QmU9Cf9q5TBCAC3kg74Fqr6K7DQTwa41C44YypYqB2GfR8/go-libp2p/p2p/protocol/identify" + dag "gx/ipfs/QmXTw4By9FMZAt7qJm4JoJuNBrBgqMMzkS4AjKc4zqTUVd/go-merkledag" + datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore" + syncds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore/sync" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 10dff2ccf..5a08b81f9 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmNmj2AeM46ZQqHARnWidb5qqHoZJFeYWzmG65jviJDRQY/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmQdLcvoy3JuSqhV6iwQ9T6Cv7hWLAdzob4jUZRPqFL67Z/go-libp2p-net" - swarmt "gx/ipfs/QmcALnLPFXgLLaZkXzGv99yt8xPfiWqFTumiXpWBJbU9cY/go-libp2p-swarm/testing" + bhost "gx/ipfs/QmU9Cf9q5TBCAC3kg74Fqr6K7DQTwa41C44YypYqB2GfR8/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmWUPYHpNv4YahaBYXovuEJttgfqcNcN9Gg4arhQYcRoqa/go-libp2p-net" + swarmt "gx/ipfs/Qmb55o5PuhvqwjdVLvc4VV3ouLziYc6TfwM9LC6GwBQokn/go-libp2p-swarm/testing" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 8ceddc38f76caa2bacf431680197d923c1049607 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 10 Oct 2018 14:06:57 +0100 Subject: [PATCH 354/674] gx: update go-buffer-pool Turns out that `pool.Put(buf)` had to *allocate* because we needed to turn `[]byte` into `interface{}`. Apparently, we've never done this correctly we just never noticed because we never really used buffer pools extensively. However, since migrating yamux to a buffer-pool backed buffer, this started showing up in allocation profiles. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@8117a2bceea626ea67a5febd7632bf019490df89 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 16 ++++++++-------- gateway/core/corehttp/gateway_test.go | 6 +++--- gateway/core/corehttp/metrics_test.go | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index d98469ee3..cec69965a 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,8 +14,8 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - path "gx/ipfs/QmQmMu1vsgsjxyB8tzrA6ZTCTCLDLVaXMb4Q57r2v886Sx/go-path" config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" + path "gx/ipfs/QmTy6VoHV2E5baEFDXbp1xmHhxSVff5qTSrTsoXxD1eB2P/go-path" cmds "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds/http" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 3ab6dcde3..c9c7c2cb0 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmU9Cf9q5TBCAC3kg74Fqr6K7DQTwa41C44YypYqB2GfR8/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmcmNfbQznhk66ipFiaRHmZU8DVpvDKFfHrRo9q5wsHzZP/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 00631df41..3a32e8210 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -17,18 +17,18 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - ft "gx/ipfs/QmQDcPcBH8nfz3JB4K4oEvxhRmBwCrMgvG966XpExEWexf/go-unixfs" - "gx/ipfs/QmQDcPcBH8nfz3JB4K4oEvxhRmBwCrMgvG966XpExEWexf/go-unixfs/importer" - uio "gx/ipfs/QmQDcPcBH8nfz3JB4K4oEvxhRmBwCrMgvG966XpExEWexf/go-unixfs/io" - path "gx/ipfs/QmQmMu1vsgsjxyB8tzrA6ZTCTCLDLVaXMb4Q57r2v886Sx/go-path" - resolver "gx/ipfs/QmQmMu1vsgsjxyB8tzrA6ZTCTCLDLVaXMb4Q57r2v886Sx/go-path/resolver" - dag "gx/ipfs/QmXTw4By9FMZAt7qJm4JoJuNBrBgqMMzkS4AjKc4zqTUVd/go-merkledag" + ft "gx/ipfs/QmNWmxWDZjv1dMUvz3sgThydJfeNUxxXaaZptF6E9b59vQ/go-unixfs" + "gx/ipfs/QmNWmxWDZjv1dMUvz3sgThydJfeNUxxXaaZptF6E9b59vQ/go-unixfs/importer" + uio "gx/ipfs/QmNWmxWDZjv1dMUvz3sgThydJfeNUxxXaaZptF6E9b59vQ/go-unixfs/io" + dag "gx/ipfs/QmTpyXP1bsqJvyW5VcNmALPCb47VPJFy2T8icGASNy4ML1/go-merkledag" + path "gx/ipfs/QmTy6VoHV2E5baEFDXbp1xmHhxSVff5qTSrTsoXxD1eB2P/go-path" + resolver "gx/ipfs/QmTy6VoHV2E5baEFDXbp1xmHhxSVff5qTSrTsoXxD1eB2P/go-path/resolver" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" + routing "gx/ipfs/QmPmFeQ5oY5G6M7aBWggi5phxEPXwsQntE1DFcUzETULdp/go-libp2p-routing" files "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit/files" - routing "gx/ipfs/QmVQPj6rHdqz6dDQrjcdP36zDYLaoB7xwqRg39kx2PqqKU/go-libp2p-routing" - chunker "gx/ipfs/QmbrQ27wGQeE8spxjbw9mk5Ef7as4tRFSnWLkEGg4xeg2f/go-ipfs-chunker" + chunker "gx/ipfs/QmTUTG9Jg9ZRA1EzTPGTDvnwfcfKhDMnqANnP9fe4rSjMR/go-ipfs-chunker" ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 8b5b143b3..747c7edfa 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,12 +19,12 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - path "gx/ipfs/QmQmMu1vsgsjxyB8tzrA6ZTCTCLDLVaXMb4Q57r2v886Sx/go-path" config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" - id "gx/ipfs/QmU9Cf9q5TBCAC3kg74Fqr6K7DQTwa41C44YypYqB2GfR8/go-libp2p/p2p/protocol/identify" - dag "gx/ipfs/QmXTw4By9FMZAt7qJm4JoJuNBrBgqMMzkS4AjKc4zqTUVd/go-merkledag" + dag "gx/ipfs/QmTpyXP1bsqJvyW5VcNmALPCb47VPJFy2T8icGASNy4ML1/go-merkledag" + path "gx/ipfs/QmTy6VoHV2E5baEFDXbp1xmHhxSVff5qTSrTsoXxD1eB2P/go-path" datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore" syncds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore/sync" + id "gx/ipfs/QmcmNfbQznhk66ipFiaRHmZU8DVpvDKFfHrRo9q5wsHzZP/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 5a08b81f9..7f46f9f97 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmU9Cf9q5TBCAC3kg74Fqr6K7DQTwa41C44YypYqB2GfR8/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmWUPYHpNv4YahaBYXovuEJttgfqcNcN9Gg4arhQYcRoqa/go-libp2p-net" - swarmt "gx/ipfs/Qmb55o5PuhvqwjdVLvc4VV3ouLziYc6TfwM9LC6GwBQokn/go-libp2p-swarm/testing" + swarmt "gx/ipfs/QmR2Yj7Eod2U77DqUHRwNSbV2mtqeRHmVdCfsLkXZwJVLy/go-libp2p-swarm/testing" + inet "gx/ipfs/QmSTaEYUgDe1r581hxyd2u9582Hgp3KX4wGwYbRqz2u9Qh/go-libp2p-net" + bhost "gx/ipfs/QmcmNfbQznhk66ipFiaRHmZU8DVpvDKFfHrRo9q5wsHzZP/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 86f2d446b9c89a9d68e2af7f030ab7f550fdf3e8 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 12 Oct 2018 16:15:40 +0100 Subject: [PATCH 355/674] gx: update yamux and refmt * yamux: fix memory leak. * refmt: obey the "empty" tag. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@4f53736430e52a1fbccff33e5aa66585a2dc6312 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 6 +++--- gateway/core/corehttp/metrics_test.go | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index cec69965a..79bfd0f4d 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,9 +15,9 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" - path "gx/ipfs/QmTy6VoHV2E5baEFDXbp1xmHhxSVff5qTSrTsoXxD1eB2P/go-path" cmds "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds/http" + path "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index c9c7c2cb0..c08e5bd0d 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmcmNfbQznhk66ipFiaRHmZU8DVpvDKFfHrRo9q5wsHzZP/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmPL3AKtiaQyYpchZceXBZhZ3MSnoGqJvLZrc7fzDTTQdJ/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 3a32e8210..fc25d53f8 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -17,12 +17,12 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - ft "gx/ipfs/QmNWmxWDZjv1dMUvz3sgThydJfeNUxxXaaZptF6E9b59vQ/go-unixfs" - "gx/ipfs/QmNWmxWDZjv1dMUvz3sgThydJfeNUxxXaaZptF6E9b59vQ/go-unixfs/importer" - uio "gx/ipfs/QmNWmxWDZjv1dMUvz3sgThydJfeNUxxXaaZptF6E9b59vQ/go-unixfs/io" - dag "gx/ipfs/QmTpyXP1bsqJvyW5VcNmALPCb47VPJFy2T8icGASNy4ML1/go-merkledag" - path "gx/ipfs/QmTy6VoHV2E5baEFDXbp1xmHhxSVff5qTSrTsoXxD1eB2P/go-path" - resolver "gx/ipfs/QmTy6VoHV2E5baEFDXbp1xmHhxSVff5qTSrTsoXxD1eB2P/go-path/resolver" + ft "gx/ipfs/QmRX6WZhMinQrQhyuwaqNHYQtNPhtBwzxKFySzNMaJmW9v/go-unixfs" + "gx/ipfs/QmRX6WZhMinQrQhyuwaqNHYQtNPhtBwzxKFySzNMaJmW9v/go-unixfs/importer" + uio "gx/ipfs/QmRX6WZhMinQrQhyuwaqNHYQtNPhtBwzxKFySzNMaJmW9v/go-unixfs/io" + dag "gx/ipfs/QmVvNkTCx8V9Zei8xuTYTBdUXmbnDRS4iNuw1SztYyhQwQ/go-merkledag" + path "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path" + resolver "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path/resolver" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 747c7edfa..aebe93d8c 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,13 +18,13 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" + id "gx/ipfs/QmPL3AKtiaQyYpchZceXBZhZ3MSnoGqJvLZrc7fzDTTQdJ/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" - dag "gx/ipfs/QmTpyXP1bsqJvyW5VcNmALPCb47VPJFy2T8icGASNy4ML1/go-merkledag" - path "gx/ipfs/QmTy6VoHV2E5baEFDXbp1xmHhxSVff5qTSrTsoXxD1eB2P/go-path" + dag "gx/ipfs/QmVvNkTCx8V9Zei8xuTYTBdUXmbnDRS4iNuw1SztYyhQwQ/go-merkledag" datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore" syncds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore/sync" - id "gx/ipfs/QmcmNfbQznhk66ipFiaRHmZU8DVpvDKFfHrRo9q5wsHzZP/go-libp2p/p2p/protocol/identify" + path "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 7f46f9f97..0572c8a9f 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - swarmt "gx/ipfs/QmR2Yj7Eod2U77DqUHRwNSbV2mtqeRHmVdCfsLkXZwJVLy/go-libp2p-swarm/testing" + bhost "gx/ipfs/QmPL3AKtiaQyYpchZceXBZhZ3MSnoGqJvLZrc7fzDTTQdJ/go-libp2p/p2p/host/basic" inet "gx/ipfs/QmSTaEYUgDe1r581hxyd2u9582Hgp3KX4wGwYbRqz2u9Qh/go-libp2p-net" - bhost "gx/ipfs/QmcmNfbQznhk66ipFiaRHmZU8DVpvDKFfHrRo9q5wsHzZP/go-libp2p/p2p/host/basic" + swarmt "gx/ipfs/QmYyFNDLTSy6rW99K8vHPvFPLa5bB4zoy8gGZENoiaBN6R/go-libp2p-swarm/testing" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From f62666f1c596ee400e9a687a4215f0b59ac61004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 16 Oct 2018 11:41:00 +0200 Subject: [PATCH 356/674] namesys: review fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@7dbeb27e5b1e18f126aaaf3bd2cd8eba81ec675f --- gateway/core/corehttp/gateway_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 701f16f07..e7e34af55 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -62,7 +62,7 @@ func (m mockNamesys) ResolveAsync(ctx context.Context, name string, opts ...nsop v, err := m.Resolve(ctx, name, opts...) out <- namesys.Result{Path: v, Err: err} close(out) - return nil + return out } func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value path.Path) error { From b62510cc965472255fe9baacdff0c676fe0e2739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 18 Oct 2018 10:16:31 +0200 Subject: [PATCH 357/674] gx: update to use extracted go-ipfs-files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@59e5a9c6523a4dcce3d378299602c145475f375a --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 79bfd0f4d..4581e1a1b 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,9 +14,9 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + cmds "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds/http" config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" - cmds "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmXTmUCBtDUrzDYVzASogLiNph7EBuYqEgPL7QoHNMzUnz/go-ipfs-cmds/http" path "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path" ) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index fc25d53f8..fc4d4fe65 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -17,19 +17,19 @@ import ( core "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - ft "gx/ipfs/QmRX6WZhMinQrQhyuwaqNHYQtNPhtBwzxKFySzNMaJmW9v/go-unixfs" - "gx/ipfs/QmRX6WZhMinQrQhyuwaqNHYQtNPhtBwzxKFySzNMaJmW9v/go-unixfs/importer" - uio "gx/ipfs/QmRX6WZhMinQrQhyuwaqNHYQtNPhtBwzxKFySzNMaJmW9v/go-unixfs/io" - dag "gx/ipfs/QmVvNkTCx8V9Zei8xuTYTBdUXmbnDRS4iNuw1SztYyhQwQ/go-merkledag" - path "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path" - resolver "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path/resolver" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" routing "gx/ipfs/QmPmFeQ5oY5G6M7aBWggi5phxEPXwsQntE1DFcUzETULdp/go-libp2p-routing" - files "gx/ipfs/QmSP88ryZkHSRn1fnngAaV2Vcn63WUJzAavnRM9CVdU1Ky/go-ipfs-cmdkit/files" chunker "gx/ipfs/QmTUTG9Jg9ZRA1EzTPGTDvnwfcfKhDMnqANnP9fe4rSjMR/go-ipfs-chunker" + dag "gx/ipfs/QmVvNkTCx8V9Zei8xuTYTBdUXmbnDRS4iNuw1SztYyhQwQ/go-merkledag" + ft "gx/ipfs/QmWE6Ftsk98cG2MTVgH4wJT8VP2nL9TuBkYTrz9GSqcsh5/go-unixfs" + "gx/ipfs/QmWE6Ftsk98cG2MTVgH4wJT8VP2nL9TuBkYTrz9GSqcsh5/go-unixfs/importer" + uio "gx/ipfs/QmWE6Ftsk98cG2MTVgH4wJT8VP2nL9TuBkYTrz9GSqcsh5/go-unixfs/io" + files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format" + path "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path" + resolver "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path/resolver" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) From 9d6a5cb25454c3c71afc484fad65a3e39b215e09 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 18 Oct 2018 19:05:11 +0100 Subject: [PATCH 358/674] update the webui Because the current one is *so* broken it's not worth waiting for an actual release. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@def2147c48d78074105fff141b37f4da890499c2 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 1f99a3524..c02b75f68 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmQLXHs7K98JNQdWrBB2cQLJahPhmupbDjRuH1b9ibmwVa" +const WebUIPath = "/ipfs/QmRuvWJz1Fc8B9cTsAYANHTXqGmKR9DVfY5nvMD1uA2WQ8" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/QmQLXHs7K98JNQdWrBB2cQLJahPhmupbDjRuH1b9ibmwVa", "/ipfs/QmXX7YRpU7nNBKfw75VG7Y1c3GwpSAGHRev67XVPgZFv9R", "/ipfs/QmXdu7HWdV6CUaUabd9q2ZeA4iHZLVyDRj3Gi4dsJsWjbr", "/ipfs/QmaaqrHyAQm7gALkRW8DcfGX3u8q9rWKnxEMmf7m9z515w", From 1bcfd610c902ae7eda834d3ae1252a1b9b16872b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 22 Oct 2018 09:22:21 -0700 Subject: [PATCH 359/674] update webui to 2.1.0 This brings us on-par with js-ipfs. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@c430e53a173c19f1375109db3db7d5dc3bc3e162 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index c02b75f68..caa63df66 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmRuvWJz1Fc8B9cTsAYANHTXqGmKR9DVfY5nvMD1uA2WQ8" +const WebUIPath = "/ipfs/QmSDgpiHco5yXdyVTfhKxr3aiJ82ynz8V14QcGKicM3rVh" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/QmRuvWJz1Fc8B9cTsAYANHTXqGmKR9DVfY5nvMD1uA2WQ8", "/ipfs/QmQLXHs7K98JNQdWrBB2cQLJahPhmupbDjRuH1b9ibmwVa", "/ipfs/QmXX7YRpU7nNBKfw75VG7Y1c3GwpSAGHRev67XVPgZFv9R", "/ipfs/QmXdu7HWdV6CUaUabd9q2ZeA4iHZLVyDRj3Gi4dsJsWjbr", From b1e4e970841b2b10835ed868a3b17a090127872f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 9 Oct 2018 18:57:25 +0200 Subject: [PATCH 360/674] coreapi unixfs: remove Cat, use sessions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@34b1313d829d8e8324e3181b4cf4a02c925414e7 --- gateway/core/corehttp/gateway_handler.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index fc4d4fe65..99f4f9c3c 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -178,14 +178,12 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - dr, err := i.api.Unixfs().Cat(ctx, resolvedPath) - dir := false + dr, err := i.api.Unixfs().Get(ctx, resolvedPath) + dir := dr.IsDirectory() switch err { case nil: // Cat() worked defer dr.Close() - case coreiface.ErrIsDir: - dir = true default: webError(w, "ipfs cat "+escapedURLPath, err, http.StatusNotFound) return @@ -270,7 +268,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } else { name = getFilename(urlPath) } - i.serveFile(w, r, name, modtime, dr) + i.serveFile(w, r, name, modtime, dr.(io.ReadSeeker)) return } @@ -297,7 +295,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - dr, err := i.api.Unixfs().Cat(ctx, coreiface.IpfsPath(ixnd.Cid())) + dr, err := i.api.Unixfs().Get(ctx, coreiface.IpfsPath(ixnd.Cid())) if err != nil { internalWebError(w, err) return @@ -305,7 +303,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr defer dr.Close() // write to request - http.ServeContent(w, r, "index.html", modtime, dr) + http.ServeContent(w, r, "index.html", modtime, dr.(io.ReadSeeker)) return default: internalWebError(w, err) From 85473fe5cbf22209050edbbc3257d6358f91f212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 10 Oct 2018 13:47:34 +0200 Subject: [PATCH 361/674] coreapi unixfs: fix Get seeking in gateway MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@7915d26090a91024795cabf09a8e121cbf73ca4a --- gateway/core/corehttp/gateway_handler.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 99f4f9c3c..615c34a77 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -179,11 +179,13 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } dr, err := i.api.Unixfs().Get(ctx, resolvedPath) - dir := dr.IsDirectory() - switch err { - case nil: - // Cat() worked - defer dr.Close() + dir := false + switch { + case err == nil: + dir = dr.IsDirectory() + if !dir { + defer dr.Close() + } default: webError(w, "ipfs cat "+escapedURLPath, err, http.StatusNotFound) return @@ -370,7 +372,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } type sizeReadSeeker interface { - Size() uint64 + Size() (int64, error) io.ReadSeeker } @@ -381,7 +383,7 @@ type sizeSeeker struct { func (s *sizeSeeker) Seek(offset int64, whence int) (int64, error) { if whence == io.SeekEnd && offset == 0 { - return int64(s.Size()), nil + return s.Size() } return s.sizeReadSeeker.Seek(offset, whence) From 2a2bb855e471fb124a377a32410de477005ea91a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 15 Oct 2018 12:45:49 +0200 Subject: [PATCH 362/674] coreapi unixfs: Return seeker from get MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@faf5230e69231c701795bf4591fc48327cd0d618 --- gateway/core/corehttp/gateway_handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 615c34a77..29db4c98b 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -270,7 +270,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } else { name = getFilename(urlPath) } - i.serveFile(w, r, name, modtime, dr.(io.ReadSeeker)) + i.serveFile(w, r, name, modtime, dr) return } @@ -305,7 +305,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr defer dr.Close() // write to request - http.ServeContent(w, r, "index.html", modtime, dr.(io.ReadSeeker)) + http.ServeContent(w, r, "index.html", modtime, dr) return default: internalWebError(w, err) From bda969c4a00ed398d45950ee7d6b85752031dc9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 23 Oct 2018 01:14:00 +0200 Subject: [PATCH 363/674] coreapi unixfs: gw handler cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@519c67a00cd0b5354f4489b736350bea35bcac80 --- gateway/core/corehttp/gateway_handler.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 29db4c98b..88c489ebc 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -179,18 +179,16 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } dr, err := i.api.Unixfs().Get(ctx, resolvedPath) - dir := false - switch { - case err == nil: - dir = dr.IsDirectory() - if !dir { - defer dr.Close() - } - default: + if err != nil { webError(w, "ipfs cat "+escapedURLPath, err, http.StatusNotFound) return } + dir := dr.IsDirectory() + if !dir { + defer dr.Close() + } + // Check etag send back to us etag := "\"" + resolvedPath.Cid().String() + "\"" if r.Header.Get("If-None-Match") == etag || r.Header.Get("If-None-Match") == "W/"+etag { From a78884967cc55337ce0919631e832d2e695856e8 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 24 Oct 2018 09:59:18 -0700 Subject: [PATCH 364/674] gx update License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@c97c3459bef2a3bc8ba8731625204f9473b485e1 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/corehttp.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 14 +++++++------- gateway/core/corehttp/gateway_test.go | 8 ++++---- gateway/core/corehttp/metrics_test.go | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 4581e1a1b..c63183ed0 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + config "gx/ipfs/QmNUhkTWN7iynJZTj1RcTsQDSRGGkh87zMo9ELypxhY8Y6/go-ipfs-config" cmds "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds/http" - config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" - path "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path" + path "gx/ipfs/QmayGyPXjTt3cGzjCR3wb5HsHQX7LaJcWUbZemGDn6rKWq/go-path" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 43f0f47ca..37429c21a 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -14,9 +14,9 @@ import ( core "github.com/ipfs/go-ipfs/core" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" periodicproc "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/periodic" - manet "gx/ipfs/QmV6FjemM1K8oXjrvuq3wuVWWoU2TLDPmNnKrxHzY3v6Ai/go-multiaddr-net" - ma "gx/ipfs/QmYmsdtJ3HsodkePE3eU3TsCaP2YvPZJ4LoXnNkDE5Tpt7/go-multiaddr" + ma "gx/ipfs/QmT4U94DnD8FRfqr21obWY32HLM5VExccPKMjQHofeYqr9/go-multiaddr" logging "gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log" + manet "gx/ipfs/Qmaabb1tJZ2CX5cp6MuuiGgns71NYoxdgQP6Xdid1dVceC/go-multiaddr-net" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index c08e5bd0d..7f6a14bc7 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmPL3AKtiaQyYpchZceXBZhZ3MSnoGqJvLZrc7fzDTTQdJ/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmabWrc5aEQ36iWgJZonKgHpttvyDhHoWBoCtesuyMn9XF/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 88c489ebc..ab81bd6e9 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -20,16 +20,16 @@ import ( humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" - routing "gx/ipfs/QmPmFeQ5oY5G6M7aBWggi5phxEPXwsQntE1DFcUzETULdp/go-libp2p-routing" chunker "gx/ipfs/QmTUTG9Jg9ZRA1EzTPGTDvnwfcfKhDMnqANnP9fe4rSjMR/go-ipfs-chunker" - dag "gx/ipfs/QmVvNkTCx8V9Zei8xuTYTBdUXmbnDRS4iNuw1SztYyhQwQ/go-merkledag" - ft "gx/ipfs/QmWE6Ftsk98cG2MTVgH4wJT8VP2nL9TuBkYTrz9GSqcsh5/go-unixfs" - "gx/ipfs/QmWE6Ftsk98cG2MTVgH4wJT8VP2nL9TuBkYTrz9GSqcsh5/go-unixfs/importer" - uio "gx/ipfs/QmWE6Ftsk98cG2MTVgH4wJT8VP2nL9TuBkYTrz9GSqcsh5/go-unixfs/io" + ft "gx/ipfs/QmU7HFzvfEvimC6wJehti4rcEkvQhvtgo1koHhPN4TXav4/go-unixfs" + "gx/ipfs/QmU7HFzvfEvimC6wJehti4rcEkvQhvtgo1koHhPN4TXav4/go-unixfs/importer" + uio "gx/ipfs/QmU7HFzvfEvimC6wJehti4rcEkvQhvtgo1koHhPN4TXav4/go-unixfs/io" + dag "gx/ipfs/QmY5xpETYHq3PPvaJnafyLWKqk5y7cZnUeBqLRtLUpEV3s/go-merkledag" files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" + path "gx/ipfs/QmayGyPXjTt3cGzjCR3wb5HsHQX7LaJcWUbZemGDn6rKWq/go-path" + resolver "gx/ipfs/QmayGyPXjTt3cGzjCR3wb5HsHQX7LaJcWUbZemGDn6rKWq/go-path/resolver" + routing "gx/ipfs/QmcQ81jSyWCp1jpkQ8CMbtpXT3jK7Wg6ZtYmoyWFgBoF9c/go-libp2p-routing" ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format" - path "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path" - resolver "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path/resolver" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index e7e34af55..c520a40c2 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,13 +18,13 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" - id "gx/ipfs/QmPL3AKtiaQyYpchZceXBZhZ3MSnoGqJvLZrc7fzDTTQdJ/go-libp2p/p2p/protocol/identify" + config "gx/ipfs/QmNUhkTWN7iynJZTj1RcTsQDSRGGkh87zMo9ELypxhY8Y6/go-ipfs-config" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config" - dag "gx/ipfs/QmVvNkTCx8V9Zei8xuTYTBdUXmbnDRS4iNuw1SztYyhQwQ/go-merkledag" + dag "gx/ipfs/QmY5xpETYHq3PPvaJnafyLWKqk5y7cZnUeBqLRtLUpEV3s/go-merkledag" datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore" syncds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore/sync" - path "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path" + id "gx/ipfs/QmabWrc5aEQ36iWgJZonKgHpttvyDhHoWBoCtesuyMn9XF/go-libp2p/p2p/protocol/identify" + path "gx/ipfs/QmayGyPXjTt3cGzjCR3wb5HsHQX7LaJcWUbZemGDn6rKWq/go-path" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 0572c8a9f..0ea2d8527 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmPL3AKtiaQyYpchZceXBZhZ3MSnoGqJvLZrc7fzDTTQdJ/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmSTaEYUgDe1r581hxyd2u9582Hgp3KX4wGwYbRqz2u9Qh/go-libp2p-net" - swarmt "gx/ipfs/QmYyFNDLTSy6rW99K8vHPvFPLa5bB4zoy8gGZENoiaBN6R/go-libp2p-swarm/testing" + inet "gx/ipfs/QmXuRkCR7BNQa9uqfpTiFWsTQLzmTWYg91Ja1w95gnqb6u/go-libp2p-net" + bhost "gx/ipfs/QmabWrc5aEQ36iWgJZonKgHpttvyDhHoWBoCtesuyMn9XF/go-libp2p/p2p/host/basic" + swarmt "gx/ipfs/QmbJrDrS4zNqFEXAZuzJ1Jq6YZ1FS2PdVY1zmDFm9M8Lda/go-libp2p-swarm/testing" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 88d2c95ebc8bbcbef5976235c620eafcf946c230 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 24 Oct 2018 12:49:25 -0700 Subject: [PATCH 365/674] gx update go-libp2p License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@636bbc7e2b6339ba253f3ce9e17cf0b0a51f3c12 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 6 +++--- gateway/core/corehttp/metrics_test.go | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index c63183ed0..94b74d74e 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,9 +15,9 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" config "gx/ipfs/QmNUhkTWN7iynJZTj1RcTsQDSRGGkh87zMo9ELypxhY8Y6/go-ipfs-config" + path "gx/ipfs/QmQ4sKWqHhSYekzST5RwT4VHdQB4df6JWLHNy7tuWTo8uY/go-path" cmds "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds/http" - path "gx/ipfs/QmayGyPXjTt3cGzjCR3wb5HsHQX7LaJcWUbZemGDn6rKWq/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 7f6a14bc7..c840bd845 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmabWrc5aEQ36iWgJZonKgHpttvyDhHoWBoCtesuyMn9XF/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmRqtXHu5gsCLpf2s1R2jQuKJBowYKkg6FGQiGCbzttSd1/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ab81bd6e9..e089b4ab7 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -20,16 +20,16 @@ import ( humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" + path "gx/ipfs/QmQ4sKWqHhSYekzST5RwT4VHdQB4df6JWLHNy7tuWTo8uY/go-path" + resolver "gx/ipfs/QmQ4sKWqHhSYekzST5RwT4VHdQB4df6JWLHNy7tuWTo8uY/go-path/resolver" chunker "gx/ipfs/QmTUTG9Jg9ZRA1EzTPGTDvnwfcfKhDMnqANnP9fe4rSjMR/go-ipfs-chunker" - ft "gx/ipfs/QmU7HFzvfEvimC6wJehti4rcEkvQhvtgo1koHhPN4TXav4/go-unixfs" - "gx/ipfs/QmU7HFzvfEvimC6wJehti4rcEkvQhvtgo1koHhPN4TXav4/go-unixfs/importer" - uio "gx/ipfs/QmU7HFzvfEvimC6wJehti4rcEkvQhvtgo1koHhPN4TXav4/go-unixfs/io" - dag "gx/ipfs/QmY5xpETYHq3PPvaJnafyLWKqk5y7cZnUeBqLRtLUpEV3s/go-merkledag" files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" - path "gx/ipfs/QmayGyPXjTt3cGzjCR3wb5HsHQX7LaJcWUbZemGDn6rKWq/go-path" - resolver "gx/ipfs/QmayGyPXjTt3cGzjCR3wb5HsHQX7LaJcWUbZemGDn6rKWq/go-path/resolver" routing "gx/ipfs/QmcQ81jSyWCp1jpkQ8CMbtpXT3jK7Wg6ZtYmoyWFgBoF9c/go-libp2p-routing" + dag "gx/ipfs/QmcescwzzD86xrxoXNJ6VwSw46wLC91QzFDnozYRVf4KnX/go-merkledag" ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format" + ft "gx/ipfs/QmeA7Cd6kMzQNDFzfXXhe64jX1XufcL8B79hwguu5v6ib9/go-unixfs" + "gx/ipfs/QmeA7Cd6kMzQNDFzfXXhe64jX1XufcL8B79hwguu5v6ib9/go-unixfs/importer" + uio "gx/ipfs/QmeA7Cd6kMzQNDFzfXXhe64jX1XufcL8B79hwguu5v6ib9/go-unixfs/io" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index c520a40c2..b752dc1fb 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,11 +20,11 @@ import ( config "gx/ipfs/QmNUhkTWN7iynJZTj1RcTsQDSRGGkh87zMo9ELypxhY8Y6/go-ipfs-config" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - dag "gx/ipfs/QmY5xpETYHq3PPvaJnafyLWKqk5y7cZnUeBqLRtLUpEV3s/go-merkledag" + path "gx/ipfs/QmQ4sKWqHhSYekzST5RwT4VHdQB4df6JWLHNy7tuWTo8uY/go-path" + id "gx/ipfs/QmRqtXHu5gsCLpf2s1R2jQuKJBowYKkg6FGQiGCbzttSd1/go-libp2p/p2p/protocol/identify" datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore" syncds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore/sync" - id "gx/ipfs/QmabWrc5aEQ36iWgJZonKgHpttvyDhHoWBoCtesuyMn9XF/go-libp2p/p2p/protocol/identify" - path "gx/ipfs/QmayGyPXjTt3cGzjCR3wb5HsHQX7LaJcWUbZemGDn6rKWq/go-path" + dag "gx/ipfs/QmcescwzzD86xrxoXNJ6VwSw46wLC91QzFDnozYRVf4KnX/go-merkledag" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 0ea2d8527..de4801daf 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,8 +7,8 @@ import ( core "github.com/ipfs/go-ipfs/core" + bhost "gx/ipfs/QmRqtXHu5gsCLpf2s1R2jQuKJBowYKkg6FGQiGCbzttSd1/go-libp2p/p2p/host/basic" inet "gx/ipfs/QmXuRkCR7BNQa9uqfpTiFWsTQLzmTWYg91Ja1w95gnqb6u/go-libp2p-net" - bhost "gx/ipfs/QmabWrc5aEQ36iWgJZonKgHpttvyDhHoWBoCtesuyMn9XF/go-libp2p/p2p/host/basic" swarmt "gx/ipfs/QmbJrDrS4zNqFEXAZuzJ1Jq6YZ1FS2PdVY1zmDFm9M8Lda/go-libp2p-swarm/testing" ) From 6b08b891b7a70565b656d42f1e846d79754253d4 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 24 Oct 2018 15:01:31 -0700 Subject: [PATCH 366/674] gx: update yamux (fixes a panic due to a race) License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@e35d4ea58b8f18a4603055e7eeb2a326ac518452 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 6 +++--- gateway/core/corehttp/metrics_test.go | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 94b74d74e..4b0494d73 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,7 +15,7 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" config "gx/ipfs/QmNUhkTWN7iynJZTj1RcTsQDSRGGkh87zMo9ELypxhY8Y6/go-ipfs-config" - path "gx/ipfs/QmQ4sKWqHhSYekzST5RwT4VHdQB4df6JWLHNy7tuWTo8uY/go-path" + path "gx/ipfs/QmRKuTyCzg7HFBcV1YUhzStroGtJSb8iWgyxfsDCwFhWTS/go-path" cmds "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds/http" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index c840bd845..9da8728f5 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmRqtXHu5gsCLpf2s1R2jQuKJBowYKkg6FGQiGCbzttSd1/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmUDTcnDp2WssbmiDLC6aYurUeyt7QeRakHUQMxA2mZ5iB/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index e089b4ab7..c217d834f 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -20,16 +20,16 @@ import ( humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" - path "gx/ipfs/QmQ4sKWqHhSYekzST5RwT4VHdQB4df6JWLHNy7tuWTo8uY/go-path" - resolver "gx/ipfs/QmQ4sKWqHhSYekzST5RwT4VHdQB4df6JWLHNy7tuWTo8uY/go-path/resolver" + path "gx/ipfs/QmRKuTyCzg7HFBcV1YUhzStroGtJSb8iWgyxfsDCwFhWTS/go-path" + resolver "gx/ipfs/QmRKuTyCzg7HFBcV1YUhzStroGtJSb8iWgyxfsDCwFhWTS/go-path/resolver" + ft "gx/ipfs/QmTJUySFxXjh54zEoFbzQEmGD3yj89XKS3A28y7Nqsn1TC/go-unixfs" + "gx/ipfs/QmTJUySFxXjh54zEoFbzQEmGD3yj89XKS3A28y7Nqsn1TC/go-unixfs/importer" + uio "gx/ipfs/QmTJUySFxXjh54zEoFbzQEmGD3yj89XKS3A28y7Nqsn1TC/go-unixfs/io" chunker "gx/ipfs/QmTUTG9Jg9ZRA1EzTPGTDvnwfcfKhDMnqANnP9fe4rSjMR/go-ipfs-chunker" + dag "gx/ipfs/QmY8BMUSpCwNiTmFhACmC9Bt1qT63cHP35AoQAus4x14qH/go-merkledag" files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" routing "gx/ipfs/QmcQ81jSyWCp1jpkQ8CMbtpXT3jK7Wg6ZtYmoyWFgBoF9c/go-libp2p-routing" - dag "gx/ipfs/QmcescwzzD86xrxoXNJ6VwSw46wLC91QzFDnozYRVf4KnX/go-merkledag" ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format" - ft "gx/ipfs/QmeA7Cd6kMzQNDFzfXXhe64jX1XufcL8B79hwguu5v6ib9/go-unixfs" - "gx/ipfs/QmeA7Cd6kMzQNDFzfXXhe64jX1XufcL8B79hwguu5v6ib9/go-unixfs/importer" - uio "gx/ipfs/QmeA7Cd6kMzQNDFzfXXhe64jX1XufcL8B79hwguu5v6ib9/go-unixfs/io" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index b752dc1fb..d589646e4 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,11 +20,11 @@ import ( config "gx/ipfs/QmNUhkTWN7iynJZTj1RcTsQDSRGGkh87zMo9ELypxhY8Y6/go-ipfs-config" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - path "gx/ipfs/QmQ4sKWqHhSYekzST5RwT4VHdQB4df6JWLHNy7tuWTo8uY/go-path" - id "gx/ipfs/QmRqtXHu5gsCLpf2s1R2jQuKJBowYKkg6FGQiGCbzttSd1/go-libp2p/p2p/protocol/identify" + path "gx/ipfs/QmRKuTyCzg7HFBcV1YUhzStroGtJSb8iWgyxfsDCwFhWTS/go-path" + id "gx/ipfs/QmUDTcnDp2WssbmiDLC6aYurUeyt7QeRakHUQMxA2mZ5iB/go-libp2p/p2p/protocol/identify" + dag "gx/ipfs/QmY8BMUSpCwNiTmFhACmC9Bt1qT63cHP35AoQAus4x14qH/go-merkledag" datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore" syncds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore/sync" - dag "gx/ipfs/QmcescwzzD86xrxoXNJ6VwSw46wLC91QzFDnozYRVf4KnX/go-merkledag" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index de4801daf..7ea7df674 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmRqtXHu5gsCLpf2s1R2jQuKJBowYKkg6FGQiGCbzttSd1/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/QmUDTcnDp2WssbmiDLC6aYurUeyt7QeRakHUQMxA2mZ5iB/go-libp2p/p2p/host/basic" + swarmt "gx/ipfs/QmVHhT8NxtApPTndiZPe4JNGNUxGWtJe3ebyxtRz4HnbEp/go-libp2p-swarm/testing" inet "gx/ipfs/QmXuRkCR7BNQa9uqfpTiFWsTQLzmTWYg91Ja1w95gnqb6u/go-libp2p-net" - swarmt "gx/ipfs/QmbJrDrS4zNqFEXAZuzJ1Jq6YZ1FS2PdVY1zmDFm9M8Lda/go-libp2p-swarm/testing" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 985971287c4b7155561f66ee37d66ccf816d9c59 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 25 Oct 2018 10:47:24 -0700 Subject: [PATCH 367/674] configurable pubsub singing I'd like to sneak this into the release so we can turn on strict verification ASAP. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@2b0bc7e08463a24660830182249826228a79fc5b --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 4b0494d73..57e292c90 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,7 +14,7 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - config "gx/ipfs/QmNUhkTWN7iynJZTj1RcTsQDSRGGkh87zMo9ELypxhY8Y6/go-ipfs-config" + config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" path "gx/ipfs/QmRKuTyCzg7HFBcV1YUhzStroGtJSb8iWgyxfsDCwFhWTS/go-path" cmds "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds/http" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index d589646e4..6c7b33057 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,7 +18,7 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" - config "gx/ipfs/QmNUhkTWN7iynJZTj1RcTsQDSRGGkh87zMo9ELypxhY8Y6/go-ipfs-config" + config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" path "gx/ipfs/QmRKuTyCzg7HFBcV1YUhzStroGtJSb8iWgyxfsDCwFhWTS/go-path" id "gx/ipfs/QmUDTcnDp2WssbmiDLC6aYurUeyt7QeRakHUQMxA2mZ5iB/go-libp2p/p2p/protocol/identify" From e85d2b96b89f90c394875e9477e06211f1143cab Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 26 Oct 2018 04:14:47 -0700 Subject: [PATCH 368/674] gx: update go-ipfs-cmds (no code changes) License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@37f0fd92c7d73c191c4e7ad649a3f344b340285a --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 57e292c90..c6190d597 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -16,8 +16,8 @@ import ( config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" path "gx/ipfs/QmRKuTyCzg7HFBcV1YUhzStroGtJSb8iWgyxfsDCwFhWTS/go-path" - cmds "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmRRovo1DE6i5cMjCbf19mQCSuszF6SKwdZNUMS7MtBnH1/go-ipfs-cmds/http" + cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds/http" ) var ( From 6affefb74450249f7607f4342c3794996e675719 Mon Sep 17 00:00:00 2001 From: Dominic Della Valle Date: Fri, 26 Oct 2018 19:50:32 -0400 Subject: [PATCH 369/674] gx: update go-ipfs-cmds to 2.0.5 License: MIT Signed-off-by: Dominic Della Valle This commit was moved from ipfs/kubo@38cae95f30818e96b66a9778ec4e114319b7b236 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index c6190d597..607c55f3f 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -16,8 +16,8 @@ import ( config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" path "gx/ipfs/QmRKuTyCzg7HFBcV1YUhzStroGtJSb8iWgyxfsDCwFhWTS/go-path" - cmds "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmdTmGruUz23vgzym3uWpnAEQdGdGifQqBvP8UXSRjG8gZ/go-ipfs-cmds/http" + cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds/http" ) var ( From bba98f5b2b20d3ddea00155b095d8acd5f718bcf Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Sat, 27 Oct 2018 03:30:18 +0200 Subject: [PATCH 370/674] Bubble deps License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@ef7234d269c8f6083decfeea5b0f11ccb2bd4965 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 14 +++++++------- gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 607c55f3f..43c1a25b9 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,9 +15,9 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" - path "gx/ipfs/QmRKuTyCzg7HFBcV1YUhzStroGtJSb8iWgyxfsDCwFhWTS/go-path" cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds/http" + path "gx/ipfs/QmZbQUht8hzKmQxLHnzY14WSuoQqYkR5mn4cunchyWPmhn/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index c217d834f..73123e53e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -20,17 +20,17 @@ import ( humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" - path "gx/ipfs/QmRKuTyCzg7HFBcV1YUhzStroGtJSb8iWgyxfsDCwFhWTS/go-path" - resolver "gx/ipfs/QmRKuTyCzg7HFBcV1YUhzStroGtJSb8iWgyxfsDCwFhWTS/go-path/resolver" - ft "gx/ipfs/QmTJUySFxXjh54zEoFbzQEmGD3yj89XKS3A28y7Nqsn1TC/go-unixfs" - "gx/ipfs/QmTJUySFxXjh54zEoFbzQEmGD3yj89XKS3A28y7Nqsn1TC/go-unixfs/importer" - uio "gx/ipfs/QmTJUySFxXjh54zEoFbzQEmGD3yj89XKS3A28y7Nqsn1TC/go-unixfs/io" + ipld "gx/ipfs/QmR7TcHkR9nxkUorfi8XMTAMLUK7GiP64TWWBzY3aacc1o/go-ipld-format" + dag "gx/ipfs/QmSei8kFMfqdJq7Q68d2LMnHbTWKKg2daA29ezUYFAUNgc/go-merkledag" chunker "gx/ipfs/QmTUTG9Jg9ZRA1EzTPGTDvnwfcfKhDMnqANnP9fe4rSjMR/go-ipfs-chunker" - dag "gx/ipfs/QmY8BMUSpCwNiTmFhACmC9Bt1qT63cHP35AoQAus4x14qH/go-merkledag" files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" + path "gx/ipfs/QmZbQUht8hzKmQxLHnzY14WSuoQqYkR5mn4cunchyWPmhn/go-path" + resolver "gx/ipfs/QmZbQUht8hzKmQxLHnzY14WSuoQqYkR5mn4cunchyWPmhn/go-path/resolver" routing "gx/ipfs/QmcQ81jSyWCp1jpkQ8CMbtpXT3jK7Wg6ZtYmoyWFgBoF9c/go-libp2p-routing" - ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" + ft "gx/ipfs/QmfB3oNXGGq9S4B2a9YeCajoATms3Zw2VvDm8fK7VeLSV8/go-unixfs" + "gx/ipfs/QmfB3oNXGGq9S4B2a9YeCajoATms3Zw2VvDm8fK7VeLSV8/go-unixfs/importer" + uio "gx/ipfs/QmfB3oNXGGq9S4B2a9YeCajoATms3Zw2VvDm8fK7VeLSV8/go-unixfs/io" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 6c7b33057..e8304512e 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,9 +20,9 @@ import ( config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - path "gx/ipfs/QmRKuTyCzg7HFBcV1YUhzStroGtJSb8iWgyxfsDCwFhWTS/go-path" + dag "gx/ipfs/QmSei8kFMfqdJq7Q68d2LMnHbTWKKg2daA29ezUYFAUNgc/go-merkledag" id "gx/ipfs/QmUDTcnDp2WssbmiDLC6aYurUeyt7QeRakHUQMxA2mZ5iB/go-libp2p/p2p/protocol/identify" - dag "gx/ipfs/QmY8BMUSpCwNiTmFhACmC9Bt1qT63cHP35AoQAus4x14qH/go-merkledag" + path "gx/ipfs/QmZbQUht8hzKmQxLHnzY14WSuoQqYkR5mn4cunchyWPmhn/go-path" datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore" syncds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore/sync" ) From fdcd83539ae3587a6d9e76edeb528e9714304ee3 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 30 Oct 2018 09:27:41 -0700 Subject: [PATCH 371/674] gx: update go-path fixes the changed path cat error causing the js-ipfs-api tests to fail License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@af53380e8c06a1ef842ff4e22e91381652463277 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 4 ++-- gateway/core/corehttp/gateway_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 43c1a25b9..017f5bb81 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -17,7 +17,7 @@ import ( config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds/http" - path "gx/ipfs/QmZbQUht8hzKmQxLHnzY14WSuoQqYkR5mn4cunchyWPmhn/go-path" + path "gx/ipfs/QmT3rzed1ppXefourpmoZ7tyVQfsGPQZ1pHDngLmCvXxd3/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 73123e53e..210058d48 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -22,10 +22,10 @@ import ( cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" ipld "gx/ipfs/QmR7TcHkR9nxkUorfi8XMTAMLUK7GiP64TWWBzY3aacc1o/go-ipld-format" dag "gx/ipfs/QmSei8kFMfqdJq7Q68d2LMnHbTWKKg2daA29ezUYFAUNgc/go-merkledag" + path "gx/ipfs/QmT3rzed1ppXefourpmoZ7tyVQfsGPQZ1pHDngLmCvXxd3/go-path" + resolver "gx/ipfs/QmT3rzed1ppXefourpmoZ7tyVQfsGPQZ1pHDngLmCvXxd3/go-path/resolver" chunker "gx/ipfs/QmTUTG9Jg9ZRA1EzTPGTDvnwfcfKhDMnqANnP9fe4rSjMR/go-ipfs-chunker" files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" - path "gx/ipfs/QmZbQUht8hzKmQxLHnzY14WSuoQqYkR5mn4cunchyWPmhn/go-path" - resolver "gx/ipfs/QmZbQUht8hzKmQxLHnzY14WSuoQqYkR5mn4cunchyWPmhn/go-path/resolver" routing "gx/ipfs/QmcQ81jSyWCp1jpkQ8CMbtpXT3jK7Wg6ZtYmoyWFgBoF9c/go-libp2p-routing" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ft "gx/ipfs/QmfB3oNXGGq9S4B2a9YeCajoATms3Zw2VvDm8fK7VeLSV8/go-unixfs" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index e8304512e..6dcdb151f 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -21,8 +21,8 @@ import ( config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" dag "gx/ipfs/QmSei8kFMfqdJq7Q68d2LMnHbTWKKg2daA29ezUYFAUNgc/go-merkledag" + path "gx/ipfs/QmT3rzed1ppXefourpmoZ7tyVQfsGPQZ1pHDngLmCvXxd3/go-path" id "gx/ipfs/QmUDTcnDp2WssbmiDLC6aYurUeyt7QeRakHUQMxA2mZ5iB/go-libp2p/p2p/protocol/identify" - path "gx/ipfs/QmZbQUht8hzKmQxLHnzY14WSuoQqYkR5mn4cunchyWPmhn/go-path" datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore" syncds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore/sync" ) From bf419cd71154c9dfa48005d249b8f8046f8383fa Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 30 Oct 2018 10:36:16 -0700 Subject: [PATCH 372/674] fix expected error message in gateway test License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@d98351720ab9d6df37fe82c94e6a72c58ced388f --- gateway/core/corehttp/gateway_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 6dcdb151f..d10a7bc93 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -188,7 +188,7 @@ func TestGatewayGet(t *testing.T) { {"working.example.com", "/", http.StatusOK, "fnord"}, {"double.example.com", "/", http.StatusOK, "fnord"}, {"triple.example.com", "/", http.StatusOK, "fnord"}, - {"working.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/working.example.com/ipfs/" + k + ": no link by that name\n"}, + {"working.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/working.example.com/ipfs/" + k + ": no link named \"ipfs\" under " + k + "\n"}, {"broken.example.com", "/", http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/: " + namesys.ErrResolveFailed.Error() + "\n"}, {"broken.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/ipfs/" + k + ": " + namesys.ErrResolveFailed.Error() + "\n"}, // This test case ensures we don't treat the TLD as a file extension. From 96058304a67606b4f6e7d3368cbd13aaa786fa15 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 30 Oct 2018 15:38:49 -0700 Subject: [PATCH 373/674] fix prometheus concurrent map write bug fixes #4132 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@4674f199133c029189db72cfcea1e72adcb91af6 --- gateway/core/corehttp/metrics.go | 73 ++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 0428c8fd1..df7fba670 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -6,13 +6,14 @@ import ( core "github.com/ipfs/go-ipfs/core" - prometheus "gx/ipfs/QmYYv3QFnfQbiwmi1tpkgKF8o4xFnZoBrvpupTiGJwL9nH/client_golang/prometheus" + prometheus "gx/ipfs/QmTQuFQWHAWy4wMH6ZyPfGiawA5u9T8rs79FENoV8yXaoS/client_golang/prometheus" + promhttp "gx/ipfs/QmTQuFQWHAWy4wMH6ZyPfGiawA5u9T8rs79FENoV8yXaoS/client_golang/prometheus/promhttp" ) // This adds the scraping endpoint which Prometheus uses to fetch metrics. func MetricsScrapingOption(path string) ServeOption { return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - mux.Handle(path, prometheus.UninstrumentedHandler()) + mux.Handle(path, promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{})) return mux, nil } } @@ -20,8 +21,74 @@ func MetricsScrapingOption(path string) ServeOption { // This adds collection of net/http-related metrics func MetricsCollectionOption(handlerName string) ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { + // Adapted from github.com/prometheus/client_golang/prometheus/http.go + // Work around https://github.com/prometheus/client_golang/pull/311 + opts := prometheus.SummaryOpts{ + Subsystem: "http", + ConstLabels: prometheus.Labels{"handler": handlerName}, + Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, + } + + reqCnt := prometheus.NewCounterVec( + prometheus.CounterOpts{ + Namespace: opts.Namespace, + Subsystem: opts.Subsystem, + Name: "requests_total", + Help: "Total number of HTTP requests made.", + ConstLabels: opts.ConstLabels, + }, + []string{"method", "code"}, + ) + if err := prometheus.Register(reqCnt); err != nil { + if are, ok := err.(prometheus.AlreadyRegisteredError); ok { + reqCnt = are.ExistingCollector.(*prometheus.CounterVec) + } else { + return nil, err + } + } + + opts.Name = "request_duration_microseconds" + opts.Help = "The HTTP request latencies in microseconds." + reqDur := prometheus.NewSummaryVec(opts, nil) + if err := prometheus.Register(reqDur); err != nil { + if are, ok := err.(prometheus.AlreadyRegisteredError); ok { + reqDur = are.ExistingCollector.(*prometheus.SummaryVec) + } else { + return nil, err + } + } + + opts.Name = "request_size_bytes" + opts.Help = "The HTTP request sizes in bytes." + reqSz := prometheus.NewSummaryVec(opts, nil) + if err := prometheus.Register(reqSz); err != nil { + if are, ok := err.(prometheus.AlreadyRegisteredError); ok { + reqSz = are.ExistingCollector.(*prometheus.SummaryVec) + } else { + return nil, err + } + } + + opts.Name = "response_size_bytes" + opts.Help = "The HTTP response sizes in bytes." + resSz := prometheus.NewSummaryVec(opts, nil) + if err := prometheus.Register(resSz); err != nil { + if are, ok := err.(prometheus.AlreadyRegisteredError); ok { + resSz = are.ExistingCollector.(*prometheus.SummaryVec) + } else { + return nil, err + } + } + + // Construct the mux childMux := http.NewServeMux() - mux.HandleFunc("/", prometheus.InstrumentHandler(handlerName, childMux)) + var promMux http.Handler = childMux + promMux = promhttp.InstrumentHandlerResponseSize(resSz, promMux) + promMux = promhttp.InstrumentHandlerRequestSize(reqSz, promMux) + promMux = promhttp.InstrumentHandlerDuration(reqDur, promMux) + promMux = promhttp.InstrumentHandlerCounter(reqCnt, promMux) + mux.Handle("/", promMux) + return childMux, nil } } From 2ad28be0920150fd0f7d43de2cbd14b097aac299 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 31 Oct 2018 05:12:35 -0700 Subject: [PATCH 374/674] metrics: we're now recording latency seconds, not microseconds License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@bf69017e251e9369bdde6961f991746b9d34e30b --- gateway/core/corehttp/metrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index df7fba670..6be50dbaf 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -47,8 +47,8 @@ func MetricsCollectionOption(handlerName string) ServeOption { } } - opts.Name = "request_duration_microseconds" - opts.Help = "The HTTP request latencies in microseconds." + opts.Name = "request_duration_seconds" + opts.Help = "The HTTP request latencies in seconds." reqDur := prometheus.NewSummaryVec(opts, nil) if err := prometheus.Register(reqDur); err != nil { if are, ok := err.(prometheus.AlreadyRegisteredError); ok { From 1390fd8aa47f9f9b19ffe011ec8a2342ebab2fa1 Mon Sep 17 00:00:00 2001 From: hannahhoward Date: Thu, 1 Nov 2018 14:06:19 -0700 Subject: [PATCH 375/674] Update go-mfs and go-unixfs So we can get go-unixfs v1.2.0 License: MIT Signed-off-by: hannahhoward This commit was moved from ipfs/kubo@943a5de974550eb46de52edff3999ca149dbe4c1 --- gateway/core/corehttp/gateway_handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 210058d48..9664da119 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -25,12 +25,12 @@ import ( path "gx/ipfs/QmT3rzed1ppXefourpmoZ7tyVQfsGPQZ1pHDngLmCvXxd3/go-path" resolver "gx/ipfs/QmT3rzed1ppXefourpmoZ7tyVQfsGPQZ1pHDngLmCvXxd3/go-path/resolver" chunker "gx/ipfs/QmTUTG9Jg9ZRA1EzTPGTDvnwfcfKhDMnqANnP9fe4rSjMR/go-ipfs-chunker" + ft "gx/ipfs/QmUaZkqxmKvUX16F8XeAAk9LVvmNMktvbhcx4PG4s8SqDG/go-unixfs" + "gx/ipfs/QmUaZkqxmKvUX16F8XeAAk9LVvmNMktvbhcx4PG4s8SqDG/go-unixfs/importer" + uio "gx/ipfs/QmUaZkqxmKvUX16F8XeAAk9LVvmNMktvbhcx4PG4s8SqDG/go-unixfs/io" files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" routing "gx/ipfs/QmcQ81jSyWCp1jpkQ8CMbtpXT3jK7Wg6ZtYmoyWFgBoF9c/go-libp2p-routing" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" - ft "gx/ipfs/QmfB3oNXGGq9S4B2a9YeCajoATms3Zw2VvDm8fK7VeLSV8/go-unixfs" - "gx/ipfs/QmfB3oNXGGq9S4B2a9YeCajoATms3Zw2VvDm8fK7VeLSV8/go-unixfs/importer" - uio "gx/ipfs/QmfB3oNXGGq9S4B2a9YeCajoATms3Zw2VvDm8fK7VeLSV8/go-unixfs/io" ) const ( From 26dee4894086d52f767b7e0ef77bde61a3399fcf Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 2 Nov 2018 13:16:34 -0700 Subject: [PATCH 376/674] gx: update go-ipld-cbor (might as well do this at the same time) License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@ec9fac73794646e47c355e2621160f6c4cd74adb --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 017f5bb81..0d24382bb 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -17,7 +17,7 @@ import ( config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds/http" - path "gx/ipfs/QmT3rzed1ppXefourpmoZ7tyVQfsGPQZ1pHDngLmCvXxd3/go-path" + path "gx/ipfs/QmUB3RFRDctDp1k73mDJydzWiKdiuNHfyuoRPQeU52rWWT/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 9664da119..95818b198 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -21,15 +21,15 @@ import ( humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" ipld "gx/ipfs/QmR7TcHkR9nxkUorfi8XMTAMLUK7GiP64TWWBzY3aacc1o/go-ipld-format" - dag "gx/ipfs/QmSei8kFMfqdJq7Q68d2LMnHbTWKKg2daA29ezUYFAUNgc/go-merkledag" - path "gx/ipfs/QmT3rzed1ppXefourpmoZ7tyVQfsGPQZ1pHDngLmCvXxd3/go-path" - resolver "gx/ipfs/QmT3rzed1ppXefourpmoZ7tyVQfsGPQZ1pHDngLmCvXxd3/go-path/resolver" chunker "gx/ipfs/QmTUTG9Jg9ZRA1EzTPGTDvnwfcfKhDMnqANnP9fe4rSjMR/go-ipfs-chunker" - ft "gx/ipfs/QmUaZkqxmKvUX16F8XeAAk9LVvmNMktvbhcx4PG4s8SqDG/go-unixfs" - "gx/ipfs/QmUaZkqxmKvUX16F8XeAAk9LVvmNMktvbhcx4PG4s8SqDG/go-unixfs/importer" - uio "gx/ipfs/QmUaZkqxmKvUX16F8XeAAk9LVvmNMktvbhcx4PG4s8SqDG/go-unixfs/io" + path "gx/ipfs/QmUB3RFRDctDp1k73mDJydzWiKdiuNHfyuoRPQeU52rWWT/go-path" + resolver "gx/ipfs/QmUB3RFRDctDp1k73mDJydzWiKdiuNHfyuoRPQeU52rWWT/go-path/resolver" + dag "gx/ipfs/QmXyuFW7at4r9dxRAbrPU9JpHW5aqngAFyxvyhvYjzxRKS/go-merkledag" files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" routing "gx/ipfs/QmcQ81jSyWCp1jpkQ8CMbtpXT3jK7Wg6ZtYmoyWFgBoF9c/go-libp2p-routing" + ft "gx/ipfs/Qmcba8ak38WXFWuaLak5pfJPUDFxcSWbkycBNQfmarpuTv/go-unixfs" + "gx/ipfs/Qmcba8ak38WXFWuaLak5pfJPUDFxcSWbkycBNQfmarpuTv/go-unixfs/importer" + uio "gx/ipfs/Qmcba8ak38WXFWuaLak5pfJPUDFxcSWbkycBNQfmarpuTv/go-unixfs/io" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index d10a7bc93..a724c93fe 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,9 +20,9 @@ import ( config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - dag "gx/ipfs/QmSei8kFMfqdJq7Q68d2LMnHbTWKKg2daA29ezUYFAUNgc/go-merkledag" - path "gx/ipfs/QmT3rzed1ppXefourpmoZ7tyVQfsGPQZ1pHDngLmCvXxd3/go-path" + path "gx/ipfs/QmUB3RFRDctDp1k73mDJydzWiKdiuNHfyuoRPQeU52rWWT/go-path" id "gx/ipfs/QmUDTcnDp2WssbmiDLC6aYurUeyt7QeRakHUQMxA2mZ5iB/go-libp2p/p2p/protocol/identify" + dag "gx/ipfs/QmXyuFW7at4r9dxRAbrPU9JpHW5aqngAFyxvyhvYjzxRKS/go-merkledag" datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore" syncds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore/sync" ) From 7cce85e43952ce3c44a2fb3c9477400be40bb96b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 2 Nov 2018 17:15:21 -0700 Subject: [PATCH 377/674] gx: update go-log and sha256 fixes #5709 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@0d80fc54c39ffa820510770ef0b05c8a6e5b9ed8 --- gateway/core/corehttp/commands.go | 8 ++++---- gateway/core/corehttp/corehttp.go | 6 +++--- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 20 ++++++++++---------- gateway/core/corehttp/gateway_test.go | 10 +++++----- gateway/core/corehttp/logs.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 0d24382bb..ead27d401 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" - cmds "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmSXUokcP4TJpFfqozT69AVAYRtzXVMUjzQVkYX41R9Svs/go-ipfs-cmds/http" - path "gx/ipfs/QmUB3RFRDctDp1k73mDJydzWiKdiuNHfyuoRPQeU52rWWT/go-path" + path "gx/ipfs/QmRG3XuGwT7GYuAqgWDJBKTzdaHMwAnc1x7J2KHEXNHxzG/go-path" + cmds "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds" + cmdsHttp "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds/http" + config "gx/ipfs/QmbK4EmM2Xx5fmbqK38TGP3PpY66r3tkXLZTcc7dF9mFwM/go-ipfs-config" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 37429c21a..fabc8b265 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,11 +12,11 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" + manet "gx/ipfs/QmQVUtnrNGtCRkCMpXgpApfzQjc8FDaDVxHqWH8cnZQeh5/go-multiaddr-net" + ma "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" periodicproc "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/periodic" - ma "gx/ipfs/QmT4U94DnD8FRfqr21obWY32HLM5VExccPKMjQHofeYqr9/go-multiaddr" - logging "gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log" - manet "gx/ipfs/Qmaabb1tJZ2CX5cp6MuuiGgns71NYoxdgQP6Xdid1dVceC/go-multiaddr-net" + logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 9da8728f5..2b63312fe 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmUDTcnDp2WssbmiDLC6aYurUeyt7QeRakHUQMxA2mZ5iB/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmXnpYYg2onGLXVxM4Q5PEFcx29k8zeJQkPeLAk9h9naxg/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 95818b198..d0d057bd3 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -19,17 +19,17 @@ import ( "github.com/ipfs/go-ipfs/dagutils" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid" - ipld "gx/ipfs/QmR7TcHkR9nxkUorfi8XMTAMLUK7GiP64TWWBzY3aacc1o/go-ipld-format" - chunker "gx/ipfs/QmTUTG9Jg9ZRA1EzTPGTDvnwfcfKhDMnqANnP9fe4rSjMR/go-ipfs-chunker" - path "gx/ipfs/QmUB3RFRDctDp1k73mDJydzWiKdiuNHfyuoRPQeU52rWWT/go-path" - resolver "gx/ipfs/QmUB3RFRDctDp1k73mDJydzWiKdiuNHfyuoRPQeU52rWWT/go-path/resolver" - dag "gx/ipfs/QmXyuFW7at4r9dxRAbrPU9JpHW5aqngAFyxvyhvYjzxRKS/go-merkledag" + chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" + cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + path "gx/ipfs/QmRG3XuGwT7GYuAqgWDJBKTzdaHMwAnc1x7J2KHEXNHxzG/go-path" + resolver "gx/ipfs/QmRG3XuGwT7GYuAqgWDJBKTzdaHMwAnc1x7J2KHEXNHxzG/go-path/resolver" + ft "gx/ipfs/QmXLCwhHh7bxRsBnCKNE9BAN87V44aSxXLquZYTtjr6fZ3/go-unixfs" + "gx/ipfs/QmXLCwhHh7bxRsBnCKNE9BAN87V44aSxXLquZYTtjr6fZ3/go-unixfs/importer" + uio "gx/ipfs/QmXLCwhHh7bxRsBnCKNE9BAN87V44aSxXLquZYTtjr6fZ3/go-unixfs/io" + routing "gx/ipfs/QmYyg3UnyiQubxjs4uhKixPxR7eeKrhJ5Vyz6Et4Tet18B/go-libp2p-routing" files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" - routing "gx/ipfs/QmcQ81jSyWCp1jpkQ8CMbtpXT3jK7Wg6ZtYmoyWFgBoF9c/go-libp2p-routing" - ft "gx/ipfs/Qmcba8ak38WXFWuaLak5pfJPUDFxcSWbkycBNQfmarpuTv/go-unixfs" - "gx/ipfs/Qmcba8ak38WXFWuaLak5pfJPUDFxcSWbkycBNQfmarpuTv/go-unixfs/importer" - uio "gx/ipfs/Qmcba8ak38WXFWuaLak5pfJPUDFxcSWbkycBNQfmarpuTv/go-unixfs/io" + dag "gx/ipfs/QmaDBne4KeY3UepeqSVKYpSmQGa3q9zP6x3LfVF2UjF3Hc/go-merkledag" + ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index a724c93fe..0afeae17d 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,13 +18,13 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" - config "gx/ipfs/QmPEpj17FDRpc7K1aArKZp3RsHtzRMKykeK9GVgn4WQGPR/go-ipfs-config" - ci "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto" - path "gx/ipfs/QmUB3RFRDctDp1k73mDJydzWiKdiuNHfyuoRPQeU52rWWT/go-path" - id "gx/ipfs/QmUDTcnDp2WssbmiDLC6aYurUeyt7QeRakHUQMxA2mZ5iB/go-libp2p/p2p/protocol/identify" - dag "gx/ipfs/QmXyuFW7at4r9dxRAbrPU9JpHW5aqngAFyxvyhvYjzxRKS/go-merkledag" + ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" + path "gx/ipfs/QmRG3XuGwT7GYuAqgWDJBKTzdaHMwAnc1x7J2KHEXNHxzG/go-path" + id "gx/ipfs/QmXnpYYg2onGLXVxM4Q5PEFcx29k8zeJQkPeLAk9h9naxg/go-libp2p/p2p/protocol/identify" + dag "gx/ipfs/QmaDBne4KeY3UepeqSVKYpSmQGa3q9zP6x3LfVF2UjF3Hc/go-merkledag" datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore" syncds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore/sync" + config "gx/ipfs/QmbK4EmM2Xx5fmbqK38TGP3PpY66r3tkXLZTcc7dF9mFwM/go-ipfs-config" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 0c55fe583..482aa3686 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - lwriter "gx/ipfs/QmZChCsSt8DctjceaL56Eibc29CVQq4dGKRXC5JRZ6Ppae/go-log/writer" + lwriter "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log/writer" ) type writeErrNotifier struct { diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 7ea7df674..874ff5a69 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmUDTcnDp2WssbmiDLC6aYurUeyt7QeRakHUQMxA2mZ5iB/go-libp2p/p2p/host/basic" - swarmt "gx/ipfs/QmVHhT8NxtApPTndiZPe4JNGNUxGWtJe3ebyxtRz4HnbEp/go-libp2p-swarm/testing" - inet "gx/ipfs/QmXuRkCR7BNQa9uqfpTiFWsTQLzmTWYg91Ja1w95gnqb6u/go-libp2p-net" + inet "gx/ipfs/QmRKbEchaYADxSCyyjhDh4cTrUby8ftXUb8MRLBTHQYupw/go-libp2p-net" + bhost "gx/ipfs/QmXnpYYg2onGLXVxM4Q5PEFcx29k8zeJQkPeLAk9h9naxg/go-libp2p/p2p/host/basic" + swarmt "gx/ipfs/QmcYC4ayKi7bq8xecEZxHVEuTL6HREZWTTErrSRd1S3Spz/go-libp2p-swarm/testing" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 7a0755fb8743db98089b31f9d3bffe6299563623 Mon Sep 17 00:00:00 2001 From: hannahhoward Date: Sat, 10 Nov 2018 18:37:06 -0800 Subject: [PATCH 378/674] Update go-ipfs-delay and assoc deps License: MIT Signed-off-by: hannahhoward This commit was moved from ipfs/kubo@0963c9cdcb2b5f38c557ebb534b8881766f40a8e --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 14 +++++++------- gateway/core/corehttp/gateway_test.go | 10 +++++----- gateway/core/corehttp/metrics_test.go | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index ead27d401..60e351ec0 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,7 +14,7 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - path "gx/ipfs/QmRG3XuGwT7GYuAqgWDJBKTzdaHMwAnc1x7J2KHEXNHxzG/go-path" + path "gx/ipfs/QmVi2uUygezqaMTqs3Yzt5FcZFHJoYD4B7jQ2BELjj7ZuY/go-path" cmds "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds" cmdsHttp "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds/http" config "gx/ipfs/QmbK4EmM2Xx5fmbqK38TGP3PpY66r3tkXLZTcc7dF9mFwM/go-ipfs-config" diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 2b63312fe..9a3215c48 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmXnpYYg2onGLXVxM4Q5PEFcx29k8zeJQkPeLAk9h9naxg/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmVvV8JQmmqPCwXAaesWJPheUiEFQJ9HWRhWhuFuxVQxpR/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d0d057bd3..01274cb6e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -21,14 +21,14 @@ import ( humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - path "gx/ipfs/QmRG3XuGwT7GYuAqgWDJBKTzdaHMwAnc1x7J2KHEXNHxzG/go-path" - resolver "gx/ipfs/QmRG3XuGwT7GYuAqgWDJBKTzdaHMwAnc1x7J2KHEXNHxzG/go-path/resolver" - ft "gx/ipfs/QmXLCwhHh7bxRsBnCKNE9BAN87V44aSxXLquZYTtjr6fZ3/go-unixfs" - "gx/ipfs/QmXLCwhHh7bxRsBnCKNE9BAN87V44aSxXLquZYTtjr6fZ3/go-unixfs/importer" - uio "gx/ipfs/QmXLCwhHh7bxRsBnCKNE9BAN87V44aSxXLquZYTtjr6fZ3/go-unixfs/io" - routing "gx/ipfs/QmYyg3UnyiQubxjs4uhKixPxR7eeKrhJ5Vyz6Et4Tet18B/go-libp2p-routing" + ft "gx/ipfs/QmUnHNqhSB1JgzVCxL1Kz3yb4bdyB4q1Z9AD5AUBVmt3fZ/go-unixfs" + "gx/ipfs/QmUnHNqhSB1JgzVCxL1Kz3yb4bdyB4q1Z9AD5AUBVmt3fZ/go-unixfs/importer" + uio "gx/ipfs/QmUnHNqhSB1JgzVCxL1Kz3yb4bdyB4q1Z9AD5AUBVmt3fZ/go-unixfs/io" + path "gx/ipfs/QmVi2uUygezqaMTqs3Yzt5FcZFHJoYD4B7jQ2BELjj7ZuY/go-path" + resolver "gx/ipfs/QmVi2uUygezqaMTqs3Yzt5FcZFHJoYD4B7jQ2BELjj7ZuY/go-path/resolver" + routing "gx/ipfs/QmZBH87CAPFHcc7cYmBqeSQ98zQ3SX9KUxiYgzPmLWNVKz/go-libp2p-routing" files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" - dag "gx/ipfs/QmaDBne4KeY3UepeqSVKYpSmQGa3q9zP6x3LfVF2UjF3Hc/go-merkledag" + dag "gx/ipfs/QmcGt25mrjuB2kKW2zhPbXVZNHc4yoTDQ65NA8m6auP2f1/go-merkledag" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 0afeae17d..963ffbe41 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,12 +19,12 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" - path "gx/ipfs/QmRG3XuGwT7GYuAqgWDJBKTzdaHMwAnc1x7J2KHEXNHxzG/go-path" - id "gx/ipfs/QmXnpYYg2onGLXVxM4Q5PEFcx29k8zeJQkPeLAk9h9naxg/go-libp2p/p2p/protocol/identify" - dag "gx/ipfs/QmaDBne4KeY3UepeqSVKYpSmQGa3q9zP6x3LfVF2UjF3Hc/go-merkledag" - datastore "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore" - syncds "gx/ipfs/QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D/go-datastore/sync" + path "gx/ipfs/QmVi2uUygezqaMTqs3Yzt5FcZFHJoYD4B7jQ2BELjj7ZuY/go-path" + id "gx/ipfs/QmVvV8JQmmqPCwXAaesWJPheUiEFQJ9HWRhWhuFuxVQxpR/go-libp2p/p2p/protocol/identify" config "gx/ipfs/QmbK4EmM2Xx5fmbqK38TGP3PpY66r3tkXLZTcc7dF9mFwM/go-ipfs-config" + dag "gx/ipfs/QmcGt25mrjuB2kKW2zhPbXVZNHc4yoTDQ65NA8m6auP2f1/go-merkledag" + datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" + syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 874ff5a69..ead0147f0 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - inet "gx/ipfs/QmRKbEchaYADxSCyyjhDh4cTrUby8ftXUb8MRLBTHQYupw/go-libp2p-net" - bhost "gx/ipfs/QmXnpYYg2onGLXVxM4Q5PEFcx29k8zeJQkPeLAk9h9naxg/go-libp2p/p2p/host/basic" - swarmt "gx/ipfs/QmcYC4ayKi7bq8xecEZxHVEuTL6HREZWTTErrSRd1S3Spz/go-libp2p-swarm/testing" + swarmt "gx/ipfs/QmQrYHkcGprZBUFnRigeiZFkaFDBHtmRhDdPpSiiUTRNwv/go-libp2p-swarm/testing" + bhost "gx/ipfs/QmVvV8JQmmqPCwXAaesWJPheUiEFQJ9HWRhWhuFuxVQxpR/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmenvQQy4bFGSiHJUGupVmCRHfetg5rH3vTp9Z2f6v2KXR/go-libp2p-net" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 6631278db588bcd09fd7b09f02b104314df33f82 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 18 Nov 2018 16:11:43 -0800 Subject: [PATCH 379/674] Switch to using request.Context() License: MIT Signed-off-by: Jeromy This commit was moved from ipfs/kubo@da4674f0b9b329c716a51f4fd0f505844c9ca0fd --- gateway/core/corehttp/gateway_handler.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 01274cb6e..2f4455db5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -64,23 +64,11 @@ func (i *gatewayHandler) newDagFromReader(r io.Reader) (ipld.Node, error) { chunker.DefaultSplitter(r)) } -// TODO(btc): break this apart into separate handlers using a more expressive muxer func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - ctx, cancel := context.WithTimeout(i.node.Context(), time.Hour) // the hour is a hard fallback, we don't expect it to happen, but just in case + ctx, cancel := context.WithTimeout(r.Context(), time.Hour) defer cancel() - if cn, ok := w.(http.CloseNotifier); ok { - clientGone := cn.CloseNotify() - go func() { - select { - case <-clientGone: - case <-ctx.Done(): - } - cancel() - }() - } - defer func() { if r := recover(); r != nil { log.Error("A panic occurred in the gateway handler!") From de483fa9d86fce294043b1066b05b9128bbf41e7 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 26 Nov 2018 17:42:13 -0800 Subject: [PATCH 380/674] gx: update go-ipfs-config * AutoRelay options for #5785. * Badger truncate-by-default option for #5275, #5625. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@cef645936d47d49c8819b269f6584332b46675a1 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 60e351ec0..216f9349e 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,9 +15,9 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" path "gx/ipfs/QmVi2uUygezqaMTqs3Yzt5FcZFHJoYD4B7jQ2BELjj7ZuY/go-path" + config "gx/ipfs/QmXctaABKwgzmQgNM4bucMJf7zJnxxvhmPM1Pw95dxUfB5/go-ipfs-config" cmds "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds" cmdsHttp "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds/http" - config "gx/ipfs/QmbK4EmM2Xx5fmbqK38TGP3PpY66r3tkXLZTcc7dF9mFwM/go-ipfs-config" ) var ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 963ffbe41..d93184852 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -21,7 +21,7 @@ import ( ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" path "gx/ipfs/QmVi2uUygezqaMTqs3Yzt5FcZFHJoYD4B7jQ2BELjj7ZuY/go-path" id "gx/ipfs/QmVvV8JQmmqPCwXAaesWJPheUiEFQJ9HWRhWhuFuxVQxpR/go-libp2p/p2p/protocol/identify" - config "gx/ipfs/QmbK4EmM2Xx5fmbqK38TGP3PpY66r3tkXLZTcc7dF9mFwM/go-ipfs-config" + config "gx/ipfs/QmXctaABKwgzmQgNM4bucMJf7zJnxxvhmPM1Pw95dxUfB5/go-ipfs-config" dag "gx/ipfs/QmcGt25mrjuB2kKW2zhPbXVZNHc4yoTDQ65NA8m6auP2f1/go-merkledag" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" From a0e392310fc6a8101ba80e1ec9b632614945e7f6 Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Wed, 28 Nov 2018 17:21:36 -0500 Subject: [PATCH 381/674] Gx update go-merkledag and related deps. License: MIT Signed-off-by: Kevin Atkinson This commit was moved from ipfs/kubo@feb480897524261089ab09d68ea75ea198012e90 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 216f9349e..5fd0cdb4c 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,7 +14,7 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - path "gx/ipfs/QmVi2uUygezqaMTqs3Yzt5FcZFHJoYD4B7jQ2BELjj7ZuY/go-path" + path "gx/ipfs/QmQtg7N4XjAk2ZYpBjjv8B6gQprsRekabHBCnF6i46JYKJ/go-path" config "gx/ipfs/QmXctaABKwgzmQgNM4bucMJf7zJnxxvhmPM1Pw95dxUfB5/go-ipfs-config" cmds "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds" cmdsHttp "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds/http" diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 2f4455db5..dac1be79c 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -19,17 +19,17 @@ import ( "github.com/ipfs/go-ipfs/dagutils" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" + path "gx/ipfs/QmQtg7N4XjAk2ZYpBjjv8B6gQprsRekabHBCnF6i46JYKJ/go-path" + resolver "gx/ipfs/QmQtg7N4XjAk2ZYpBjjv8B6gQprsRekabHBCnF6i46JYKJ/go-path/resolver" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - ft "gx/ipfs/QmUnHNqhSB1JgzVCxL1Kz3yb4bdyB4q1Z9AD5AUBVmt3fZ/go-unixfs" - "gx/ipfs/QmUnHNqhSB1JgzVCxL1Kz3yb4bdyB4q1Z9AD5AUBVmt3fZ/go-unixfs/importer" - uio "gx/ipfs/QmUnHNqhSB1JgzVCxL1Kz3yb4bdyB4q1Z9AD5AUBVmt3fZ/go-unixfs/io" - path "gx/ipfs/QmVi2uUygezqaMTqs3Yzt5FcZFHJoYD4B7jQ2BELjj7ZuY/go-path" - resolver "gx/ipfs/QmVi2uUygezqaMTqs3Yzt5FcZFHJoYD4B7jQ2BELjj7ZuY/go-path/resolver" + ft "gx/ipfs/QmXAFxWtAB9YAMzMy9op6m95hWYu2CC5rmTsijkYL12Kvu/go-unixfs" + "gx/ipfs/QmXAFxWtAB9YAMzMy9op6m95hWYu2CC5rmTsijkYL12Kvu/go-unixfs/importer" + uio "gx/ipfs/QmXAFxWtAB9YAMzMy9op6m95hWYu2CC5rmTsijkYL12Kvu/go-unixfs/io" routing "gx/ipfs/QmZBH87CAPFHcc7cYmBqeSQ98zQ3SX9KUxiYgzPmLWNVKz/go-libp2p-routing" files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" - dag "gx/ipfs/QmcGt25mrjuB2kKW2zhPbXVZNHc4yoTDQ65NA8m6auP2f1/go-merkledag" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" + dag "gx/ipfs/QmdURv6Sbob8TVW2tFFve9vcEWrSUgwPqeqnXyvYhLrkyd/go-merkledag" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index d93184852..209bafc98 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,10 +19,10 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" - path "gx/ipfs/QmVi2uUygezqaMTqs3Yzt5FcZFHJoYD4B7jQ2BELjj7ZuY/go-path" + path "gx/ipfs/QmQtg7N4XjAk2ZYpBjjv8B6gQprsRekabHBCnF6i46JYKJ/go-path" id "gx/ipfs/QmVvV8JQmmqPCwXAaesWJPheUiEFQJ9HWRhWhuFuxVQxpR/go-libp2p/p2p/protocol/identify" config "gx/ipfs/QmXctaABKwgzmQgNM4bucMJf7zJnxxvhmPM1Pw95dxUfB5/go-ipfs-config" - dag "gx/ipfs/QmcGt25mrjuB2kKW2zhPbXVZNHc4yoTDQ65NA8m6auP2f1/go-merkledag" + dag "gx/ipfs/QmdURv6Sbob8TVW2tFFve9vcEWrSUgwPqeqnXyvYhLrkyd/go-merkledag" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" ) From 74f93d22a57820c5fab5432da4ae5a76b0a51a7c Mon Sep 17 00:00:00 2001 From: Chris Boddy Date: Wed, 26 Sep 2018 22:34:05 +0100 Subject: [PATCH 382/674] [http_proxy_over_p2p] more tests, fix build License: MIT Signed-off-by: Chris Boddy This commit was moved from ipfs/kubo@c862ac1fb47c7833c2b614fafaf46a56d4e25343 --- gateway/core/corehttp/proxy.go | 93 +++++++++++++++++++++++++++++ gateway/core/corehttp/proxy_test.go | 45 ++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 gateway/core/corehttp/proxy.go create mode 100644 gateway/core/corehttp/proxy_test.go diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go new file mode 100644 index 000000000..47b26be17 --- /dev/null +++ b/gateway/core/corehttp/proxy.go @@ -0,0 +1,93 @@ +package corehttp + +import ( + "bufio" + "fmt" + "net" + "net/http" + "strings" + + core "github.com/ipfs/go-ipfs/core" + + protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" + peer "gx/ipfs/QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3/go-libp2p-peer" +) + +func ProxyOption() ServeOption { + return func(ipfsNode *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { + mux.HandleFunc("/proxy/", func(w http.ResponseWriter, request *http.Request) { + // parse request + parsedRequest, err := parseRequest(request) + if err != nil { + handleError(w, "Failed to parse request", err, 400) + return + } + + // open connect to peer + stream, err := ipfsNode.P2P.PeerHost.NewStream(ipfsNode.Context(), parsedRequest.target, protocol.ID("/x/"+parsedRequest.name)) + if err != nil { + msg := fmt.Sprintf("Failed to open stream '%v' to target peer '%v'", parsedRequest.name, parsedRequest.target) + handleError(w, msg, err, 500) + return + } + + // send request to peer + proxyReq, err := http.NewRequest(request.Method, parsedRequest.httpPath, request.Body) + + if err != nil { + handleError(w, "Failed to format proxy request", err, 500) + return + } + + proxyReq.Write(stream) + + s := bufio.NewReader(stream) + proxyResponse, err := http.ReadResponse(s, proxyReq) + defer func() { proxyResponse.Body.Close() }() + if err != nil { + msg := fmt.Sprintf("Failed to send request to stream '%v' to peer '%v'", parsedRequest.name, parsedRequest.target) + handleError(w, msg, err, 500) + return + } + // send client response + proxyResponse.Write(w) + }) + return mux, nil + } +} + +type proxyRequest struct { + target peer.ID + name string + httpPath string // path to send to the proxy-host +} + +// from the url path parse the peer-ID, name and http path +// /proxy/http/$peer_id/$name/$http_path +func parseRequest(request *http.Request) (*proxyRequest, error) { + path := request.URL.Path + + split := strings.SplitN(path, "/", 6) + if len(split) < 6 { + return nil, fmt.Errorf("Invalid request path '%s'", path) + } + + if split[2] != "http" { + return nil, fmt.Errorf("Invalid proxy request protocol '%s'", split[2]) + } + + peerID, err := peer.IDB58Decode(split[3]) + + if err != nil { + return nil, err + } + + return &proxyRequest{peerID, split[4], split[5]}, nil +} + +// log error and send response to client +func handleError(w http.ResponseWriter, msg string, err error, code int) { + w.WriteHeader(code) + fmt.Fprintf(w, "%s: %s\n", msg, err) + log.Warningf("server error: %s: %s", err) +} diff --git a/gateway/core/corehttp/proxy_test.go b/gateway/core/corehttp/proxy_test.go new file mode 100644 index 000000000..e5b085895 --- /dev/null +++ b/gateway/core/corehttp/proxy_test.go @@ -0,0 +1,45 @@ +package corehttp + +import ( + "github.com/ipfs/go-ipfs/thirdparty/assert" + "net/http" + "strings" + "testing" +) + +func TestParseRequest(t *testing.T) { + url := "http://localhost:5001/proxy/http/QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT/test-name/path/to/index.txt" + req, _ := http.NewRequest("GET", url, strings.NewReader("")) + + parsed, err := parseRequest(req) + if err != nil { + t.Error(err) + } + assert.True(parsed.httpPath == "path/to/index.txt", t, "proxy request path") + assert.True(parsed.name == "test-name", t, "proxy request name") + assert.True(parsed.target.Pretty() == "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", t, "proxy request peer-id") +} + +func TestParseRequestInvalidProtocol(t *testing.T) { + url := "http://localhost:5001/proxy/invalid/QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT/test-name/path/to/index.txt" + req, _ := http.NewRequest("GET", url, strings.NewReader("")) + + _, err := parseRequest(req) + if err == nil { + t.Fail() + } + + assert.True(err.Error() == "Invalid proxy request protocol 'invalid'", t, "fails with invalid proxy") +} + +func TestParseRequestInvalidPath(t *testing.T) { + url := "http://localhost:5001/proxy/http/foobar" + req, _ := http.NewRequest("GET", url, strings.NewReader("")) + + _, err := parseRequest(req) + if err == nil { + t.Fail() + } + + assert.True(err.Error() == "Invalid request path '/proxy/http/foobar'", t, "fails with invalid path") +} From 9784212260babb758457f86b1e9aef186d83facc Mon Sep 17 00:00:00 2001 From: Chris Boddy Date: Sat, 29 Sep 2018 16:09:44 +0100 Subject: [PATCH 383/674] [http_proxy_over_p2p] Add sharness tests for http-proxy-over-p2p License: MIT Signed-off-by: Chris Boddy This commit was moved from ipfs/kubo@1945e44f7fa786682287b0a775675646d18c9a63 --- gateway/core/corehttp/proxy.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 47b26be17..a3e2c735d 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -43,6 +43,7 @@ func ProxyOption() ServeOption { s := bufio.NewReader(stream) proxyResponse, err := http.ReadResponse(s, proxyReq) + defer func() { proxyResponse.Body.Close() }() if err != nil { msg := fmt.Sprintf("Failed to send request to stream '%v' to peer '%v'", parsedRequest.name, parsedRequest.target) From ac3fa9a77d20b745d67b71d4600ba1152b0d6c0c Mon Sep 17 00:00:00 2001 From: Dr Ian Preston Date: Tue, 2 Oct 2018 00:42:05 +0100 Subject: [PATCH 384/674] change handler mount point to /proxy/http/ License: MIT Signed-off-by: Ian Preston This commit was moved from ipfs/kubo@22f3b11621cea0ef4f9617c53f8e05da3ab49e56 --- gateway/core/corehttp/proxy.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index a3e2c735d..8e236d155 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -15,7 +15,7 @@ import ( func ProxyOption() ServeOption { return func(ipfsNode *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - mux.HandleFunc("/proxy/", func(w http.ResponseWriter, request *http.Request) { + mux.HandleFunc("/proxy/http/", func(w http.ResponseWriter, request *http.Request) { // parse request parsedRequest, err := parseRequest(request) if err != nil { @@ -73,10 +73,6 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { return nil, fmt.Errorf("Invalid request path '%s'", path) } - if split[2] != "http" { - return nil, fmt.Errorf("Invalid proxy request protocol '%s'", split[2]) - } - peerID, err := peer.IDB58Decode(split[3]) if err != nil { From 090ed0cdf8bc72e57fef61a111b313b75be29539 Mon Sep 17 00:00:00 2001 From: Chris Boddy Date: Tue, 2 Oct 2018 09:51:51 +0100 Subject: [PATCH 385/674] [http_proxy_over_p2p] remove now superfluous test License: MIT Signed-off-by: Chris Boddy This commit was moved from ipfs/kubo@335bca2bb7da738d329e25fd0cf1f7b705fcf52a --- gateway/core/corehttp/proxy.go | 3 +++ gateway/core/corehttp/proxy_test.go | 12 ------------ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 8e236d155..4683bc2ca 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -5,6 +5,7 @@ import ( "fmt" "net" "net/http" + //"net/http/httputil" "strings" core "github.com/ipfs/go-ipfs/core" @@ -13,6 +14,7 @@ import ( peer "gx/ipfs/QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3/go-libp2p-peer" ) +// This adds an endpoint for proxying a request to another ipfs peer func ProxyOption() ServeOption { return func(ipfsNode *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/proxy/http/", func(w http.ResponseWriter, request *http.Request) { @@ -31,6 +33,7 @@ func ProxyOption() ServeOption { return } + //httputil.ReverseProxy( // send request to peer proxyReq, err := http.NewRequest(request.Method, parsedRequest.httpPath, request.Body) diff --git a/gateway/core/corehttp/proxy_test.go b/gateway/core/corehttp/proxy_test.go index e5b085895..e3279317c 100644 --- a/gateway/core/corehttp/proxy_test.go +++ b/gateway/core/corehttp/proxy_test.go @@ -20,18 +20,6 @@ func TestParseRequest(t *testing.T) { assert.True(parsed.target.Pretty() == "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", t, "proxy request peer-id") } -func TestParseRequestInvalidProtocol(t *testing.T) { - url := "http://localhost:5001/proxy/invalid/QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT/test-name/path/to/index.txt" - req, _ := http.NewRequest("GET", url, strings.NewReader("")) - - _, err := parseRequest(req) - if err == nil { - t.Fail() - } - - assert.True(err.Error() == "Invalid proxy request protocol 'invalid'", t, "fails with invalid proxy") -} - func TestParseRequestInvalidPath(t *testing.T) { url := "http://localhost:5001/proxy/http/foobar" req, _ := http.NewRequest("GET", url, strings.NewReader("")) From 48a4a4a5bbbd80f8c4a0672ab4e9d142d4b16d9b Mon Sep 17 00:00:00 2001 From: Chris Boddy Date: Tue, 2 Oct 2018 17:18:32 +0100 Subject: [PATCH 386/674] [http_proxy_over_p2p] httputil.ReverseProxy Reimplement http-request proxying ala httputil.ReverseProxy. NB: this is proxies the request synchronously (sends all request-body before reading any response). License: MIT Signed-off-by: Chris Boddy This commit was moved from ipfs/kubo@5f246e3211cba21c2e6122ee1c535458b13ad3a5 --- gateway/core/corehttp/proxy.go | 49 +++++++++++++++++----------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 4683bc2ca..7a9946ff4 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -5,16 +5,17 @@ import ( "fmt" "net" "net/http" - //"net/http/httputil" + "net/http/httputil" "strings" core "github.com/ipfs/go-ipfs/core" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" peer "gx/ipfs/QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3/go-libp2p-peer" + inet "gx/ipfs/QmfDPh144WGBqRxZb1TGDHerbMnZATrHZggAPw7putNnBq/go-libp2p-net" ) -// This adds an endpoint for proxying a request to another ipfs peer +// This adds an endpoint for proxying a HTTP request to another ipfs peer func ProxyOption() ServeOption { return func(ipfsNode *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/proxy/http/", func(w http.ResponseWriter, request *http.Request) { @@ -33,28 +34,7 @@ func ProxyOption() ServeOption { return } - //httputil.ReverseProxy( - // send request to peer - proxyReq, err := http.NewRequest(request.Method, parsedRequest.httpPath, request.Body) - - if err != nil { - handleError(w, "Failed to format proxy request", err, 500) - return - } - - proxyReq.Write(stream) - - s := bufio.NewReader(stream) - proxyResponse, err := http.ReadResponse(s, proxyReq) - - defer func() { proxyResponse.Body.Close() }() - if err != nil { - msg := fmt.Sprintf("Failed to send request to stream '%v' to peer '%v'", parsedRequest.name, parsedRequest.target) - handleError(w, msg, err, 500) - return - } - // send client response - proxyResponse.Write(w) + newReverseHttpProxy(parsedRequest, &stream).ServeHTTP(w, request) }) return mux, nil } @@ -85,9 +65,28 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { return &proxyRequest{peerID, split[4], split[5]}, nil } -// log error and send response to client func handleError(w http.ResponseWriter, msg string, err error, code int) { w.WriteHeader(code) fmt.Fprintf(w, "%s: %s\n", msg, err) log.Warningf("server error: %s: %s", err) } + +func newReverseHttpProxy(req *proxyRequest, streamToPeer *inet.Stream) *httputil.ReverseProxy { + director := func(r *http.Request) { + r.URL.Path = req.httpPath //the scheme etc. doesn't matter + } + + return &httputil.ReverseProxy{ + Director: director, + Transport: &roundTripper{streamToPeer}} +} + +type roundTripper struct { + stream *inet.Stream +} + +func (self *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + req.Write(*self.stream) + s := bufio.NewReader(*self.stream) + return http.ReadResponse(s, req) +} From d931e65fe50f83a54b498a6fac61a4ec7f025c9f Mon Sep 17 00:00:00 2001 From: Chris Boddy Date: Tue, 2 Oct 2018 17:40:21 +0100 Subject: [PATCH 387/674] [http_proxy_over_p2p] proxy async. Simultaneously send request-body while reading response-body when proxying requests. License: MIT Signed-off-by: Chris Boddy This commit was moved from ipfs/kubo@90f5bad718a544bc1cf9ba67695fafc458581171 --- gateway/core/corehttp/proxy.go | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 7a9946ff4..66baf8826 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -15,7 +15,7 @@ import ( inet "gx/ipfs/QmfDPh144WGBqRxZb1TGDHerbMnZATrHZggAPw7putNnBq/go-libp2p-net" ) -// This adds an endpoint for proxying a HTTP request to another ipfs peer +// ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer func ProxyOption() ServeOption { return func(ipfsNode *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/proxy/http/", func(w http.ResponseWriter, request *http.Request) { @@ -33,8 +33,8 @@ func ProxyOption() ServeOption { handleError(w, msg, err, 500) return } - - newReverseHttpProxy(parsedRequest, &stream).ServeHTTP(w, request) + //send proxy request and response to client + newReverseHTTPProxy(parsedRequest, &stream).ServeHTTP(w, request) }) return mux, nil } @@ -71,7 +71,7 @@ func handleError(w http.ResponseWriter, msg string, err error, code int) { log.Warningf("server error: %s: %s", err) } -func newReverseHttpProxy(req *proxyRequest, streamToPeer *inet.Stream) *httputil.ReverseProxy { +func newReverseHTTPProxy(req *proxyRequest, streamToPeer *inet.Stream) *httputil.ReverseProxy { director := func(r *http.Request) { r.URL.Path = req.httpPath //the scheme etc. doesn't matter } @@ -85,8 +85,19 @@ type roundTripper struct { stream *inet.Stream } -func (self *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { - req.Write(*self.stream) - s := bufio.NewReader(*self.stream) +func (rt *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + + sendRequest := func() { + err := req.Write(*rt.stream) + if err != nil { + (*(rt.stream)).Close() + } + if req.Body != nil { + req.Body.Close() + } + } + //send request while reading response + go sendRequest() + s := bufio.NewReader(*rt.stream) return http.ReadResponse(s, req) } From 9b4113e69a280b115c85b0f826e8a0ce1f8ef5d6 Mon Sep 17 00:00:00 2001 From: Dr Ian Preston Date: Tue, 2 Oct 2018 22:23:30 +0100 Subject: [PATCH 388/674] fix non empty paths in p2p http proxy License: MIT Signed-off-by: Ian Preston This commit was moved from ipfs/kubo@f052d18471b3bcbf72f7557ae5262459571b15cc --- gateway/core/corehttp/proxy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 66baf8826..200b3276f 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -62,7 +62,7 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { return nil, err } - return &proxyRequest{peerID, split[4], split[5]}, nil + return &proxyRequest{peerID, split[4], "/" + split[5]}, nil } func handleError(w http.ResponseWriter, msg string, err error, code int) { From 2fa0034582afdee0fd8ee63fb72ccdb2594d78b9 Mon Sep 17 00:00:00 2001 From: Dr Ian Preston Date: Wed, 3 Oct 2018 19:20:33 +0100 Subject: [PATCH 389/674] Remove unnecessary pointer usage. Make sure the p2p stream is closed eventually License: MIT Signed-off-by: Ian Preston This commit was moved from ipfs/kubo@c67d2b41862cb6f74c3fc5f49be9b0fbe4b24e66 --- gateway/core/corehttp/proxy.go | 39 ++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 200b3276f..70a836ae6 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -4,6 +4,7 @@ import ( "bufio" "fmt" "net" + "io" "net/http" "net/http/httputil" "strings" @@ -34,7 +35,7 @@ func ProxyOption() ServeOption { return } //send proxy request and response to client - newReverseHTTPProxy(parsedRequest, &stream).ServeHTTP(w, request) + newReverseHTTPProxy(parsedRequest, stream).ServeHTTP(w, request) }) return mux, nil } @@ -71,7 +72,7 @@ func handleError(w http.ResponseWriter, msg string, err error, code int) { log.Warningf("server error: %s: %s", err) } -func newReverseHTTPProxy(req *proxyRequest, streamToPeer *inet.Stream) *httputil.ReverseProxy { +func newReverseHTTPProxy(req *proxyRequest, streamToPeer inet.Stream) *httputil.ReverseProxy { director := func(r *http.Request) { r.URL.Path = req.httpPath //the scheme etc. doesn't matter } @@ -82,15 +83,28 @@ func newReverseHTTPProxy(req *proxyRequest, streamToPeer *inet.Stream) *httputil } type roundTripper struct { - stream *inet.Stream + stream inet.Stream +} + +// we wrap the response body and close the stream +// only when it's closed. +type respBody struct { + io.ReadCloser + stream inet.Stream +} + +// Closes the response's body and the connection. +func (rb *respBody) Close() error { + rb.stream.Close() + return rb.ReadCloser.Close() } func (rt *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { sendRequest := func() { - err := req.Write(*rt.stream) + err := req.Write(rt.stream) if err != nil { - (*(rt.stream)).Close() + rt.stream.Close() } if req.Body != nil { req.Body.Close() @@ -98,6 +112,17 @@ func (rt *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { } //send request while reading response go sendRequest() - s := bufio.NewReader(*rt.stream) - return http.ReadResponse(s, req) + s := bufio.NewReader(rt.stream) + + resp, err := http.ReadResponse(s, req) + if err != nil { + return resp, err + } + + resp.Body = &respBody{ + ReadCloser: resp.Body, + stream: rt.stream, + } + + return resp, nil } From c02c094aa55a690760a2a91df2c24f86dcc198f7 Mon Sep 17 00:00:00 2001 From: Dr Ian Preston Date: Wed, 3 Oct 2018 19:31:40 +0100 Subject: [PATCH 390/674] Use request context in p2p stream http proxy License: MIT Signed-off-by: Ian Preston This commit was moved from ipfs/kubo@6e24fc609a7c2595f969dcf9e5a70a6d87a5ddfe --- gateway/core/corehttp/proxy.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 70a836ae6..b92cb341d 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -3,8 +3,8 @@ package corehttp import ( "bufio" "fmt" - "net" "io" + "net" "net/http" "net/http/httputil" "strings" @@ -28,7 +28,7 @@ func ProxyOption() ServeOption { } // open connect to peer - stream, err := ipfsNode.P2P.PeerHost.NewStream(ipfsNode.Context(), parsedRequest.target, protocol.ID("/x/"+parsedRequest.name)) + stream, err := ipfsNode.P2P.PeerHost.NewStream(request.Context(), parsedRequest.target, protocol.ID("/x/"+parsedRequest.name)) if err != nil { msg := fmt.Sprintf("Failed to open stream '%v' to target peer '%v'", parsedRequest.name, parsedRequest.target) handleError(w, msg, err, 500) @@ -121,7 +121,7 @@ func (rt *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { resp.Body = &respBody{ ReadCloser: resp.Body, - stream: rt.stream, + stream: rt.stream, } return resp, nil From 376bc8f9386cbb4769ceb5626759d076dd311a1f Mon Sep 17 00:00:00 2001 From: Dr Ian Preston Date: Wed, 3 Oct 2018 22:49:11 +0100 Subject: [PATCH 391/674] Improve p2p stream closing in http proxy License: MIT Signed-off-by: Ian Preston This commit was moved from ipfs/kubo@d30c41a5e04ecca3603fc8b7d18e3260dab54f10 --- gateway/core/corehttp/proxy.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index b92cb341d..5d1874471 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -95,7 +95,11 @@ type respBody struct { // Closes the response's body and the connection. func (rb *respBody) Close() error { - rb.stream.Close() + if err := rb.stream.Close(); err != nil { + rb.stream.Reset() + } else { + go inet.AwaitEOF(rb.stream) + } return rb.ReadCloser.Close() } From 5748d0425babf1ab7dbb579b0d8be26850830dfa Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 5 Oct 2018 00:01:13 +0200 Subject: [PATCH 392/674] Use go-libp2p-http License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@f03efbd200c34ba1e98b699d3ebb46df92e72701 --- gateway/core/corehttp/proxy.go | 90 +++++----------------------------- 1 file changed, 12 insertions(+), 78 deletions(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 5d1874471..30a5cc163 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -1,19 +1,17 @@ package corehttp import ( - "bufio" "fmt" - "io" "net" "net/http" "net/http/httputil" + "net/url" "strings" core "github.com/ipfs/go-ipfs/core" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" - peer "gx/ipfs/QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3/go-libp2p-peer" - inet "gx/ipfs/QmfDPh144WGBqRxZb1TGDHerbMnZATrHZggAPw7putNnBq/go-libp2p-net" + p2phttp "gx/ipfs/QmcLYfmHLsaVRKGMZQovwEYhHAjWtRjg1Lij3pnzw5UkRD/go-libp2p-http" ) // ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer @@ -27,23 +25,24 @@ func ProxyOption() ServeOption { return } - // open connect to peer - stream, err := ipfsNode.P2P.PeerHost.NewStream(request.Context(), parsedRequest.target, protocol.ID("/x/"+parsedRequest.name)) + target, err := url.Parse(fmt.Sprintf("libp2p://%s/%s", parsedRequest.target, parsedRequest.httpPath)) if err != nil { - msg := fmt.Sprintf("Failed to open stream '%v' to target peer '%v'", parsedRequest.name, parsedRequest.target) - handleError(w, msg, err, 500) + handleError(w, "Failed to parse url", err, 400) return } - //send proxy request and response to client - newReverseHTTPProxy(parsedRequest, stream).ServeHTTP(w, request) + + rt := p2phttp.NewTransport(ipfsNode.P2P.PeerHost, p2phttp.ProtocolOption(parsedRequest.name)) + proxy := httputil.NewSingleHostReverseProxy(target) + proxy.Transport = rt + proxy.ServeHTTP(w, request) }) return mux, nil } } type proxyRequest struct { - target peer.ID - name string + target string + name protocol.ID httpPath string // path to send to the proxy-host } @@ -57,13 +56,7 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { return nil, fmt.Errorf("Invalid request path '%s'", path) } - peerID, err := peer.IDB58Decode(split[3]) - - if err != nil { - return nil, err - } - - return &proxyRequest{peerID, split[4], "/" + split[5]}, nil + return &proxyRequest{split[3], protocol.ID(split[4]), "/" + split[5]}, nil } func handleError(w http.ResponseWriter, msg string, err error, code int) { @@ -71,62 +64,3 @@ func handleError(w http.ResponseWriter, msg string, err error, code int) { fmt.Fprintf(w, "%s: %s\n", msg, err) log.Warningf("server error: %s: %s", err) } - -func newReverseHTTPProxy(req *proxyRequest, streamToPeer inet.Stream) *httputil.ReverseProxy { - director := func(r *http.Request) { - r.URL.Path = req.httpPath //the scheme etc. doesn't matter - } - - return &httputil.ReverseProxy{ - Director: director, - Transport: &roundTripper{streamToPeer}} -} - -type roundTripper struct { - stream inet.Stream -} - -// we wrap the response body and close the stream -// only when it's closed. -type respBody struct { - io.ReadCloser - stream inet.Stream -} - -// Closes the response's body and the connection. -func (rb *respBody) Close() error { - if err := rb.stream.Close(); err != nil { - rb.stream.Reset() - } else { - go inet.AwaitEOF(rb.stream) - } - return rb.ReadCloser.Close() -} - -func (rt *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { - - sendRequest := func() { - err := req.Write(rt.stream) - if err != nil { - rt.stream.Close() - } - if req.Body != nil { - req.Body.Close() - } - } - //send request while reading response - go sendRequest() - s := bufio.NewReader(rt.stream) - - resp, err := http.ReadResponse(s, req) - if err != nil { - return resp, err - } - - resp.Body = &respBody{ - ReadCloser: resp.Body, - stream: rt.stream, - } - - return resp, nil -} From d589bc5833cd3a102c463bbca55369731ad456b3 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 5 Oct 2018 02:39:09 +0200 Subject: [PATCH 393/674] Let URL's host take precedence License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@2cc1a995664407a075b6c33aeea081a53da5370a --- gateway/core/corehttp/proxy.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 30a5cc163..64648d784 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -25,6 +25,7 @@ func ProxyOption() ServeOption { return } + request.Host = "" // Let URL's Host take precedence. target, err := url.Parse(fmt.Sprintf("libp2p://%s/%s", parsedRequest.target, parsedRequest.httpPath)) if err != nil { handleError(w, "Failed to parse url", err, 400) From fdba77bab3148b2b7cb3a5a9851bd713f1b353e7 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 5 Oct 2018 02:58:05 +0200 Subject: [PATCH 394/674] Fix test License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@91c919a47e5d7c9bf2ac066f07035a0648b788ae --- gateway/core/corehttp/proxy_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/proxy_test.go b/gateway/core/corehttp/proxy_test.go index e3279317c..d56599ec0 100644 --- a/gateway/core/corehttp/proxy_test.go +++ b/gateway/core/corehttp/proxy_test.go @@ -1,10 +1,11 @@ package corehttp import ( - "github.com/ipfs/go-ipfs/thirdparty/assert" "net/http" "strings" "testing" + + "github.com/ipfs/go-ipfs/thirdparty/assert" ) func TestParseRequest(t *testing.T) { @@ -15,9 +16,9 @@ func TestParseRequest(t *testing.T) { if err != nil { t.Error(err) } - assert.True(parsed.httpPath == "path/to/index.txt", t, "proxy request path") + assert.True(parsed.httpPath == "/path/to/index.txt", t, "proxy request path") assert.True(parsed.name == "test-name", t, "proxy request name") - assert.True(parsed.target.Pretty() == "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", t, "proxy request peer-id") + assert.True(parsed.target == "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", t, "proxy request peer-id") } func TestParseRequestInvalidPath(t *testing.T) { From 3876edeacb646cc42a89f9a659ea142cb41b47e7 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 5 Oct 2018 11:21:34 +0200 Subject: [PATCH 395/674] Fix request path. Wasn't using proxy correctly License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@42a843d66b90fe9c9bd19913165e59aae8c33374 --- gateway/core/corehttp/proxy.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 64648d784..5d85d7609 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -26,7 +26,8 @@ func ProxyOption() ServeOption { } request.Host = "" // Let URL's Host take precedence. - target, err := url.Parse(fmt.Sprintf("libp2p://%s/%s", parsedRequest.target, parsedRequest.httpPath)) + request.URL.Path = parsedRequest.httpPath + target, err := url.Parse(fmt.Sprintf("libp2p://%s", parsedRequest.target)) if err != nil { handleError(w, "Failed to parse url", err, 400) return @@ -57,7 +58,7 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { return nil, fmt.Errorf("Invalid request path '%s'", path) } - return &proxyRequest{split[3], protocol.ID(split[4]), "/" + split[5]}, nil + return &proxyRequest{split[3], protocol.ID(split[4]), split[5]}, nil } func handleError(w http.ResponseWriter, msg string, err error, code int) { From 341dc0be7308872b2c41b82e12060c863a4b4e6d Mon Sep 17 00:00:00 2001 From: Dr Ian Preston Date: Wed, 10 Oct 2018 19:03:01 +0100 Subject: [PATCH 396/674] fix test License: MIT Signed-off-by: Ian Preston This commit was moved from ipfs/kubo@654105a2104209e0653c236387dcabfa195be783 --- gateway/core/corehttp/proxy_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/proxy_test.go b/gateway/core/corehttp/proxy_test.go index d56599ec0..b8d8e0e8b 100644 --- a/gateway/core/corehttp/proxy_test.go +++ b/gateway/core/corehttp/proxy_test.go @@ -16,7 +16,7 @@ func TestParseRequest(t *testing.T) { if err != nil { t.Error(err) } - assert.True(parsed.httpPath == "/path/to/index.txt", t, "proxy request path") + assert.True(parsed.httpPath == "path/to/index.txt", t, "proxy request path") assert.True(parsed.name == "test-name", t, "proxy request name") assert.True(parsed.target == "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", t, "proxy request peer-id") } From 12ab1e47cecec62f4465600abf1cc37d6d1346e5 Mon Sep 17 00:00:00 2001 From: Chris Boddy Date: Wed, 24 Oct 2018 09:00:31 +0100 Subject: [PATCH 397/674] [http_proxy_over_p2p] url-decode the proxy name and fix test License: MIT Signed-off-by: Chris Boddy This commit was moved from ipfs/kubo@3f6b866edca6368cd1fb5edde6778596d6aca38e --- gateway/core/corehttp/proxy.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 5d85d7609..3b358ee90 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -57,8 +57,13 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { if len(split) < 6 { return nil, fmt.Errorf("Invalid request path '%s'", path) } + //url-decode the name + decodedName, err := url.PathUnescape(split[4]) + if err != nil { + return nil, err + } - return &proxyRequest{split[3], protocol.ID(split[4]), split[5]}, nil + return &proxyRequest{split[3], protocol.ID(decodedName), split[5]}, nil } func handleError(w http.ResponseWriter, msg string, err error, code int) { From 603b32eb6bcac618b7107c4890791da859bbb775 Mon Sep 17 00:00:00 2001 From: Dr Ian Preston Date: Sun, 28 Oct 2018 13:52:47 +0000 Subject: [PATCH 398/674] Don't url decode protocol name. It won't work. License: MIT Signed-off-by: Ian Preston This commit was moved from ipfs/kubo@13b0483df04b134e6c047d52304b5954b37f33ea --- gateway/core/corehttp/proxy.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 3b358ee90..5d85d7609 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -57,13 +57,8 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { if len(split) < 6 { return nil, fmt.Errorf("Invalid request path '%s'", path) } - //url-decode the name - decodedName, err := url.PathUnescape(split[4]) - if err != nil { - return nil, err - } - return &proxyRequest{split[3], protocol.ID(decodedName), split[5]}, nil + return &proxyRequest{split[3], protocol.ID(split[4]), split[5]}, nil } func handleError(w http.ResponseWriter, msg string, err error, code int) { From 247b4207db0661aeb2a6ff2cd928a3f88525a4f8 Mon Sep 17 00:00:00 2001 From: Dr Ian Preston Date: Sat, 10 Nov 2018 22:08:51 +0000 Subject: [PATCH 399/674] switch to new path format in p2p http proxy License: MIT Signed-off-by: Ian Preston This commit was moved from ipfs/kubo@fd43f473b4698fe027dd93f3eac96dd47564d243 --- gateway/core/corehttp/proxy.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 5d85d7609..89d0affd6 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -17,7 +17,7 @@ import ( // ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer func ProxyOption() ServeOption { return func(ipfsNode *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - mux.HandleFunc("/proxy/http/", func(w http.ResponseWriter, request *http.Request) { + mux.HandleFunc("/p2p/", func(w http.ResponseWriter, request *http.Request) { // parse request parsedRequest, err := parseRequest(request) if err != nil { @@ -49,16 +49,27 @@ type proxyRequest struct { } // from the url path parse the peer-ID, name and http path -// /proxy/http/$peer_id/$name/$http_path +// /p2p/$peer_id/http/$http_path +// or +// /p2p/$peer_id/x/$protocol/http/$http_path func parseRequest(request *http.Request) (*proxyRequest, error) { path := request.URL.Path - split := strings.SplitN(path, "/", 6) - if len(split) < 6 { + split := strings.SplitN(path, "/", 5) + if len(split) < 5 { return nil, fmt.Errorf("Invalid request path '%s'", path) } - return &proxyRequest{split[3], protocol.ID(split[4]), split[5]}, nil + if split[3] == "http" { + return &proxyRequest{split[2], protocol.ID("/http"), split[4]}, nil + } + + split = strings.SplitN(path, "/", 7) + if split[3] != "x" || split[5] != "http" { + return nil, fmt.Errorf("Invalid request path '%s'", path) + } + + return &proxyRequest{split[2], protocol.ID("/x/" + split[4] + "/http"), split[6]}, nil } func handleError(w http.ResponseWriter, msg string, err error, code int) { From 0536c58107bb010f78b2f983f840ab173f4bd903 Mon Sep 17 00:00:00 2001 From: Dr Ian Preston Date: Sat, 10 Nov 2018 22:24:41 +0000 Subject: [PATCH 400/674] fix tests License: MIT Signed-off-by: Ian Preston This commit was moved from ipfs/kubo@47d45c7af86151864ac727fd1162cb0669991bdf --- gateway/core/corehttp/proxy_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/proxy_test.go b/gateway/core/corehttp/proxy_test.go index b8d8e0e8b..c8a2620e9 100644 --- a/gateway/core/corehttp/proxy_test.go +++ b/gateway/core/corehttp/proxy_test.go @@ -9,7 +9,7 @@ import ( ) func TestParseRequest(t *testing.T) { - url := "http://localhost:5001/proxy/http/QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT/test-name/path/to/index.txt" + url := "http://localhost:5001/p2p/QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT/http/path/to/index.txt" req, _ := http.NewRequest("GET", url, strings.NewReader("")) parsed, err := parseRequest(req) @@ -17,12 +17,12 @@ func TestParseRequest(t *testing.T) { t.Error(err) } assert.True(parsed.httpPath == "path/to/index.txt", t, "proxy request path") - assert.True(parsed.name == "test-name", t, "proxy request name") + assert.True(parsed.name == "/http", t, "proxy request name") assert.True(parsed.target == "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", t, "proxy request peer-id") } func TestParseRequestInvalidPath(t *testing.T) { - url := "http://localhost:5001/proxy/http/foobar" + url := "http://localhost:5001/p2p/http/foobar" req, _ := http.NewRequest("GET", url, strings.NewReader("")) _, err := parseRequest(req) @@ -30,5 +30,5 @@ func TestParseRequestInvalidPath(t *testing.T) { t.Fail() } - assert.True(err.Error() == "Invalid request path '/proxy/http/foobar'", t, "fails with invalid path") + assert.True(err.Error() == "Invalid request path '/p2p/http/foobar'", t, "fails with invalid path") } From f83c509af48027e587bcba48807f585f84326a45 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 12 Nov 2018 16:21:27 -0800 Subject: [PATCH 401/674] uses the global PeerHost and don't expose the P2P one License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@b720d1f0b58321ff209131ef8de04ce53ea093e6 --- gateway/core/corehttp/proxy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 89d0affd6..6c3b793d2 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -33,7 +33,7 @@ func ProxyOption() ServeOption { return } - rt := p2phttp.NewTransport(ipfsNode.P2P.PeerHost, p2phttp.ProtocolOption(parsedRequest.name)) + rt := p2phttp.NewTransport(ipfsNode.PeerHost, p2phttp.ProtocolOption(parsedRequest.name)) proxy := httputil.NewSingleHostReverseProxy(target) proxy.Transport = rt proxy.ServeHTTP(w, request) From c6796239ce1f155aecbdb6f8bb7c036a09babc8c Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 15 Nov 2018 21:13:04 +0000 Subject: [PATCH 402/674] Apply suggestions from code review License: MIT Signed-off-by: Ian Preston Co-Authored-By: ianopolous This commit was moved from ipfs/kubo@3b2ce4a85daef99c0fd56173316950b82b9d147b --- gateway/core/corehttp/proxy.go | 6 +++--- gateway/core/corehttp/proxy_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 6c3b793d2..c9d74fa92 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -21,7 +21,7 @@ func ProxyOption() ServeOption { // parse request parsedRequest, err := parseRequest(request) if err != nil { - handleError(w, "Failed to parse request", err, 400) + handleError(w, "failed to parse request", err, 400) return } @@ -29,7 +29,7 @@ func ProxyOption() ServeOption { request.URL.Path = parsedRequest.httpPath target, err := url.Parse(fmt.Sprintf("libp2p://%s", parsedRequest.target)) if err != nil { - handleError(w, "Failed to parse url", err, 400) + handleError(w, "failed to parse url", err, 400) return } @@ -75,5 +75,5 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { func handleError(w http.ResponseWriter, msg string, err error, code int) { w.WriteHeader(code) fmt.Fprintf(w, "%s: %s\n", msg, err) - log.Warningf("server error: %s: %s", err) + log.Warningf("http proxy error: %s: %s", err) } diff --git a/gateway/core/corehttp/proxy_test.go b/gateway/core/corehttp/proxy_test.go index c8a2620e9..b328fcf2d 100644 --- a/gateway/core/corehttp/proxy_test.go +++ b/gateway/core/corehttp/proxy_test.go @@ -14,7 +14,7 @@ func TestParseRequest(t *testing.T) { parsed, err := parseRequest(req) if err != nil { - t.Error(err) + t.Fatal(err) } assert.True(parsed.httpPath == "path/to/index.txt", t, "proxy request path") assert.True(parsed.name == "/http", t, "proxy request name") From e70df8dd073e7dabe408d368f15194db09b2a6a0 Mon Sep 17 00:00:00 2001 From: Dr Ian Preston Date: Thu, 15 Nov 2018 22:13:35 +0000 Subject: [PATCH 403/674] add more p2p http proxy tests License: MIT Signed-off-by: Ian Preston This commit was moved from ipfs/kubo@9956630e0c4ca6620ceb74fc7b76d4dc5b0f3834 --- gateway/core/corehttp/proxy_test.go | 51 ++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/gateway/core/corehttp/proxy_test.go b/gateway/core/corehttp/proxy_test.go index b328fcf2d..653142f3d 100644 --- a/gateway/core/corehttp/proxy_test.go +++ b/gateway/core/corehttp/proxy_test.go @@ -6,29 +6,50 @@ import ( "testing" "github.com/ipfs/go-ipfs/thirdparty/assert" + + protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" ) +type TestCase struct { + urlprefix string + target string + name string + path string +} + +var validtestCases = []TestCase{ + {"http://localhost:5001", "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", "/http", "path/to/index.txt"}, + {"http://localhost:5001", "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", "/x/custom/http", "path/to/index.txt"}, + {"http://localhost:5001", "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", "/x/custom/http", "http/path/to/index.txt"}, +} + func TestParseRequest(t *testing.T) { - url := "http://localhost:5001/p2p/QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT/http/path/to/index.txt" - req, _ := http.NewRequest("GET", url, strings.NewReader("")) + for _, tc := range validtestCases { + url := tc.urlprefix + "/p2p/" + tc.target + tc.name + "/" + tc.path + req, _ := http.NewRequest("GET", url, strings.NewReader("")) - parsed, err := parseRequest(req) - if err != nil { - t.Fatal(err) + parsed, err := parseRequest(req) + if err != nil { + t.Fatal(err) + } + assert.True(parsed.httpPath == tc.path, t, "proxy request path") + assert.True(parsed.name == protocol.ID(tc.name), t, "proxy request name") + assert.True(parsed.target == tc.target, t, "proxy request peer-id") } - assert.True(parsed.httpPath == "path/to/index.txt", t, "proxy request path") - assert.True(parsed.name == "/http", t, "proxy request name") - assert.True(parsed.target == "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", t, "proxy request peer-id") +} + +var invalidtestCases = []string{ + "http://localhost:5001/p2p/http/foobar", } func TestParseRequestInvalidPath(t *testing.T) { - url := "http://localhost:5001/p2p/http/foobar" - req, _ := http.NewRequest("GET", url, strings.NewReader("")) + for _, tc := range invalidtestCases { + url := tc + req, _ := http.NewRequest("GET", url, strings.NewReader("")) - _, err := parseRequest(req) - if err == nil { - t.Fail() + _, err := parseRequest(req) + if err == nil { + t.Fail() + } } - - assert.True(err.Error() == "Invalid request path '/p2p/http/foobar'", t, "fails with invalid path") } From ed093897d855784357be5485bfb8930e6b2adbf2 Mon Sep 17 00:00:00 2001 From: Dr Ian Preston Date: Wed, 21 Nov 2018 00:30:08 +0000 Subject: [PATCH 404/674] Add another test case for invalid p2p http proxy path License: MIT Signed-off-by: Ian Preston This commit was moved from ipfs/kubo@869498499213ee9795ef8ad86f0f49b3019a643f --- gateway/core/corehttp/proxy_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gateway/core/corehttp/proxy_test.go b/gateway/core/corehttp/proxy_test.go index 653142f3d..786dcf3d9 100644 --- a/gateway/core/corehttp/proxy_test.go +++ b/gateway/core/corehttp/proxy_test.go @@ -40,6 +40,7 @@ func TestParseRequest(t *testing.T) { var invalidtestCases = []string{ "http://localhost:5001/p2p/http/foobar", + "http://localhost:5001/p2p/QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT/x/custom/foobar", } func TestParseRequestInvalidPath(t *testing.T) { From 3696177021c35854b71bd73ed77b1e31188900bf Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 7 Dec 2018 15:37:23 -0800 Subject: [PATCH 405/674] gx: update go-libp2p-peer Reverts the changes that allowed small keys (ed25519 keys) to be inlined. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@9dcec2b3e276458638fcf32a770e05e8fb2e44f8 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 14 +++++++------- gateway/core/corehttp/gateway_test.go | 8 ++++---- gateway/core/corehttp/metrics_test.go | 6 +++--- gateway/core/corehttp/proxy.go | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 5fd0cdb4c..5a2deb2e3 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,8 +14,8 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - path "gx/ipfs/QmQtg7N4XjAk2ZYpBjjv8B6gQprsRekabHBCnF6i46JYKJ/go-path" - config "gx/ipfs/QmXctaABKwgzmQgNM4bucMJf7zJnxxvhmPM1Pw95dxUfB5/go-ipfs-config" + config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" + path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" cmds "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds" cmdsHttp "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds/http" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 9a3215c48..5fad3acf3 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmVvV8JQmmqPCwXAaesWJPheUiEFQJ9HWRhWhuFuxVQxpR/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index dac1be79c..7c6d272aa 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -19,17 +19,17 @@ import ( "github.com/ipfs/go-ipfs/dagutils" humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - path "gx/ipfs/QmQtg7N4XjAk2ZYpBjjv8B6gQprsRekabHBCnF6i46JYKJ/go-path" - resolver "gx/ipfs/QmQtg7N4XjAk2ZYpBjjv8B6gQprsRekabHBCnF6i46JYKJ/go-path/resolver" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - ft "gx/ipfs/QmXAFxWtAB9YAMzMy9op6m95hWYu2CC5rmTsijkYL12Kvu/go-unixfs" - "gx/ipfs/QmXAFxWtAB9YAMzMy9op6m95hWYu2CC5rmTsijkYL12Kvu/go-unixfs/importer" - uio "gx/ipfs/QmXAFxWtAB9YAMzMy9op6m95hWYu2CC5rmTsijkYL12Kvu/go-unixfs/io" - routing "gx/ipfs/QmZBH87CAPFHcc7cYmBqeSQ98zQ3SX9KUxiYgzPmLWNVKz/go-libp2p-routing" + routing "gx/ipfs/QmRASJXJUFygM5qU4YrH7k7jD6S4Hg8nJmgqJ4bYJvLatd/go-libp2p-routing" + path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + resolver "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" - dag "gx/ipfs/QmdURv6Sbob8TVW2tFFve9vcEWrSUgwPqeqnXyvYhLrkyd/go-merkledag" + dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" + ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" + "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/importer" + uio "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/io" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 209bafc98..7af8bdf3a 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,10 +19,10 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" - path "gx/ipfs/QmQtg7N4XjAk2ZYpBjjv8B6gQprsRekabHBCnF6i46JYKJ/go-path" - id "gx/ipfs/QmVvV8JQmmqPCwXAaesWJPheUiEFQJ9HWRhWhuFuxVQxpR/go-libp2p/p2p/protocol/identify" - config "gx/ipfs/QmXctaABKwgzmQgNM4bucMJf7zJnxxvhmPM1Pw95dxUfB5/go-ipfs-config" - dag "gx/ipfs/QmdURv6Sbob8TVW2tFFve9vcEWrSUgwPqeqnXyvYhLrkyd/go-merkledag" + id "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/protocol/identify" + config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" + path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index ead0147f0..bb40562a0 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - swarmt "gx/ipfs/QmQrYHkcGprZBUFnRigeiZFkaFDBHtmRhDdPpSiiUTRNwv/go-libp2p-swarm/testing" - bhost "gx/ipfs/QmVvV8JQmmqPCwXAaesWJPheUiEFQJ9HWRhWhuFuxVQxpR/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmenvQQy4bFGSiHJUGupVmCRHfetg5rH3vTp9Z2f6v2KXR/go-libp2p-net" + inet "gx/ipfs/QmPtFaR7BWHLAjSwLh9kXcyrgTzDpuhcWLkx8ioa9RMYnx/go-libp2p-net" + swarmt "gx/ipfs/QmQdLXW5JTSsrVb3ZpnpbASRwyM8CcE4XcM5nPbN19dWLr/go-libp2p-swarm/testing" + bhost "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index c9d74fa92..03c1af65d 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" + p2phttp "gx/ipfs/QmWGnBLJhzZ3xV5YQuS6CqczN143YmGAFQTMAdJ31msoK5/go-libp2p-http" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" - p2phttp "gx/ipfs/QmcLYfmHLsaVRKGMZQovwEYhHAjWtRjg1Lij3pnzw5UkRD/go-libp2p-http" ) // ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer From cdec21f13002f0e5b9165ec82ff689be9e497f55 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 12 Dec 2018 16:35:32 -0800 Subject: [PATCH 406/674] gx: update go-ipfs-cmds License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@90926ca5c71461abe515491e5b35382ebd827f2b --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 5a2deb2e3..c51417293 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds/http" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - cmds "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds" - cmdsHttp "gx/ipfs/Qma6uuSyjkecGhMFFLfzyJDPyoDtNJSHJNweDccZhaWkgU/go-ipfs-cmds/http" ) var ( From ba7cdec7b13f8208f36dd3820c102a8aff67e5e0 Mon Sep 17 00:00:00 2001 From: Diogo Silva Date: Tue, 18 Dec 2018 18:00:24 +0000 Subject: [PATCH 407/674] feat: update Web UI to v2.3.0 License: MIT Signed-off-by: Diogo Silva This commit was moved from ipfs/kubo@58694cb67e68b998e9aeaaa5d832275ce7ea5499 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index caa63df66..d11d25ae5 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmSDgpiHco5yXdyVTfhKxr3aiJ82ynz8V14QcGKicM3rVh" +const WebUIPath = "/ipfs/QmUnXcWZC5Ve21gUseouJsH5mLAyz5JPp8aHsg8qVUUK8e" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/QmSDgpiHco5yXdyVTfhKxr3aiJ82ynz8V14QcGKicM3rVh", "/ipfs/QmRuvWJz1Fc8B9cTsAYANHTXqGmKR9DVfY5nvMD1uA2WQ8", "/ipfs/QmQLXHs7K98JNQdWrBB2cQLJahPhmupbDjRuH1b9ibmwVa", "/ipfs/QmXX7YRpU7nNBKfw75VG7Y1c3GwpSAGHRev67XVPgZFv9R", From 60d4ed90120de9da6d666fbf63a8d2ccca0bc9de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 26 Oct 2018 14:14:49 +0200 Subject: [PATCH 408/674] gx: update go-ipfs-files to 2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@0618fd77beb88e1ac70b8a2d2c12ca95fde2d7ee --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index c51417293..73b38d4f7 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - cmds "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmPdvMtgpnMuU68mWhGtzCxnddXJoV96tT9aPcNbQsqPaM/go-ipfs-cmds/http" config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds/http" ) var ( diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 7c6d272aa..3379689f4 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -22,14 +22,14 @@ import ( chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" routing "gx/ipfs/QmRASJXJUFygM5qU4YrH7k7jD6S4Hg8nJmgqJ4bYJvLatd/go-libp2p-routing" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" resolver "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" - files "gx/ipfs/QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC/go-ipfs-files" + ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" + "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer" + uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - ft "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs" - "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/importer" - uio "gx/ipfs/QmdYvDbHp7qAhZ7GsCj6e1cMo55ND6y2mjWVzwdvcv4f12/go-unixfs/io" multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) From d98ab3661b25132bcbf4f15999bf91225f0852a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 26 Oct 2018 15:56:30 +0200 Subject: [PATCH 409/674] files2.0: fix build errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@ce952a56414a288207b1ce0d79deafe90c2d77f3 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 3379689f4..103916c77 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -386,7 +386,7 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam } func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { - p, err := i.api.Unixfs().Add(ctx, files.NewReaderFile("", "", ioutil.NopCloser(r.Body), nil)) + p, err := i.api.Unixfs().Add(ctx, files.NewReaderFile(ioutil.NopCloser(r.Body), nil)) if err != nil { internalWebError(w, err) return From 8db4aadff2f892d6b21b18813c41575ccfbb37db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 19 Nov 2018 03:24:42 +0100 Subject: [PATCH 410/674] files2.0: updates for file type split MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@adc74907554e7018b5a173e0621ada07f73d04c9 --- gateway/core/corehttp/gateway_handler.go | 28 ++++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 103916c77..e0330185e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -172,10 +172,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - dir := dr.IsDirectory() - if !dir { - defer dr.Close() - } + defer dr.Close() // Check etag send back to us etag := "\"" + resolvedPath.Cid().String() + "\"" @@ -240,14 +237,14 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // TODO: break this out when we split /ipfs /ipns routes. modtime := time.Now() - if strings.HasPrefix(urlPath, ipfsPathPrefix) && !dir { - w.Header().Set("Cache-Control", "public, max-age=29030400, immutable") + if f, ok := dr.(files.File); ok { + if strings.HasPrefix(urlPath, ipfsPathPrefix) { + w.Header().Set("Cache-Control", "public, max-age=29030400, immutable") - // set modtime to a really long time ago, since files are immutable and should stay cached - modtime = time.Unix(1, 0) - } + // set modtime to a really long time ago, since files are immutable and should stay cached + modtime = time.Unix(1, 0) + } - if !dir { urlFilename := r.URL.Query().Get("filename") var name string if urlFilename != "" { @@ -256,8 +253,9 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } else { name = getFilename(urlPath) } - i.serveFile(w, r, name, modtime, dr) + i.serveFile(w, r, name, modtime, f) return + } nd, err := i.api.ResolveNode(ctx, resolvedPath) @@ -290,8 +288,14 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } defer dr.Close() + f, ok := dr.(files.File) + if !ok { + internalWebError(w, files.ErrNotReader) + return + } + // write to request - http.ServeContent(w, r, "index.html", modtime, dr) + http.ServeContent(w, r, "index.html", modtime, f) return default: internalWebError(w, err) From f20fe01f33e6bafb38e5f436eb9b991a5d4d5223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 13 Dec 2018 22:41:21 +0100 Subject: [PATCH 411/674] files2.0: refactored helpers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@eed806a58b6eab0c1a703250ae6d607fdfc64bd3 --- gateway/core/corehttp/gateway_handler.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index e0330185e..553ebdcf8 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -14,23 +13,23 @@ import ( "strings" "time" - core "github.com/ipfs/go-ipfs/core" + "github.com/ipfs/go-ipfs/core" coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - humanize "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" + "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" - cid "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - routing "gx/ipfs/QmRASJXJUFygM5qU4YrH7k7jD6S4Hg8nJmgqJ4bYJvLatd/go-libp2p-routing" - files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" - path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - resolver "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" + "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" + "gx/ipfs/QmRASJXJUFygM5qU4YrH7k7jD6S4Hg8nJmgqJ4bYJvLatd/go-libp2p-routing" + "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" + "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer" uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" - multibase "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" + "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) const ( @@ -390,7 +389,7 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam } func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { - p, err := i.api.Unixfs().Add(ctx, files.NewReaderFile(ioutil.NopCloser(r.Body), nil)) + p, err := i.api.Unixfs().Add(ctx, files.NewReaderFile(r.Body)) if err != nil { internalWebError(w, err) return From b8665c5a9727b1cb9bde412410e84a9285f50fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 6 Dec 2018 22:25:48 +0100 Subject: [PATCH 412/674] coreapi: global offline option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@c832a32a4c5b6633df9efe4793edb837317ed9fd --- gateway/core/corehttp/gateway.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 5fad3acf3..52560750a 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -25,11 +25,16 @@ func GatewayOption(writable bool, paths ...string) ServeOption { return nil, err } + api, err := coreapi.NewCoreAPI(n) + if err != nil { + return nil, err + } + gateway := newGatewayHandler(n, GatewayConfig{ Headers: cfg.Gateway.HTTPHeaders, Writable: writable, PathPrefixes: cfg.Gateway.PathPrefixes, - }, coreapi.NewCoreAPI(n)) + }, api) for _, p := range paths { mux.Handle(p+"/", gateway) From f8e0281eb1c1f3065d03e3afb5fef6235ac87e8f Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 20 Dec 2018 08:35:04 -0800 Subject: [PATCH 413/674] gx: update go-ipfs-config License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@58942911390388819d48780b09ecf6f9a66982b4 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 73b38d4f7..99d3b3eff 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds/http" + config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" ) var ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 7af8bdf3a..3aa82c9ce 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,8 +20,8 @@ import ( ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" id "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/protocol/identify" - config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" From 910355fd40b0dffa3924a61d3c199a0b6ea81b31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 3 Jan 2019 23:13:25 +0100 Subject: [PATCH 414/674] gx: update go-ipfs-config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@7b4ab36817c8dffade3781fa269bf8f88dde58b4 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 99d3b3eff..5ccb31d98 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds/http" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" ) var ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 3aa82c9ce..162f70b8a 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -20,8 +20,8 @@ import ( ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" id "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/protocol/identify" + config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - config "gx/ipfs/QmcZfkbgwwwH5ZLTQRHkSQBDiDqd3skY2eU6MZRgWuXcse/go-ipfs-config" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" From 1ada492a043dc299bb7f350ccd2c58a8fba7fbe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 26 Oct 2018 02:28:28 +0200 Subject: [PATCH 415/674] NoFetch gateway option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@aa5daed3cb0fe9a98f6ab0bba1a50eddfc6cc572 --- gateway/core/corehttp/gateway.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 52560750a..de909a0ef 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -2,6 +2,7 @@ package corehttp import ( "fmt" + "github.com/ipfs/go-ipfs/core/coreapi/interface/options" "net" "net/http" @@ -25,7 +26,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { return nil, err } - api, err := coreapi.NewCoreAPI(n) + api, err := coreapi.NewCoreAPI(n, options.Api.Offline(cfg.Gateway.NoFetch)) if err != nil { return nil, err } From 5371ed615792aafd50ff40ff8d74b3e7a6a444e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 4 Jan 2019 02:35:40 +0100 Subject: [PATCH 416/674] Fix offline gateway directory logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@6cee21d39a2f76ea75d487e35230c801c5eff25c --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 49 +++++++++++------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index de909a0ef..105f24361 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -2,13 +2,13 @@ package corehttp import ( "fmt" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" "net" "net/http" version "github.com/ipfs/go-ipfs" core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" + options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" id "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/protocol/identify" ) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 553ebdcf8..e80a9fa45 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -7,7 +7,6 @@ import ( "io" "net/http" "net/url" - "os" gopath "path" "runtime/debug" "strings" @@ -26,7 +25,6 @@ import ( "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer" - uio "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/io" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" @@ -254,22 +252,14 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } i.serveFile(w, r, name, modtime, f) return - - } - - nd, err := i.api.ResolveNode(ctx, resolvedPath) - if err != nil { - internalWebError(w, err) - return } - - dirr, err := uio.NewDirectoryFromNode(i.node.DAG, nd) - if err != nil { - internalWebError(w, err) + dir, ok := dr.(files.Directory) + if !ok { + internalWebError(w, fmt.Errorf("unsupported file type")) return } - ixnd, err := dirr.Find(ctx, "index.html") + idx, err := i.api.Unixfs().Get(ctx, coreiface.Join(resolvedPath, "index.html")) switch { case err == nil: dirwithoutslash := urlPath[len(urlPath)-1] != '/' @@ -280,14 +270,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - dr, err := i.api.Unixfs().Get(ctx, coreiface.IpfsPath(ixnd.Cid())) - if err != nil { - internalWebError(w, err) - return - } - defer dr.Close() - - f, ok := dr.(files.File) + f, ok := idx.(files.File) if !ok { internalWebError(w, files.ErrNotReader) return @@ -297,9 +280,11 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr http.ServeContent(w, r, "index.html", modtime, f) return default: + if _, ok := err.(resolver.ErrNoLink); ok { + break + } internalWebError(w, err) return - case os.IsNotExist(err): } if r.Method == "HEAD" { @@ -308,12 +293,22 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // storage for directory listing var dirListing []directoryItem - dirr.ForEachLink(ctx, func(link *ipld.Link) error { + dirit := dir.Entries() + for dirit.Next() { // See comment above where originalUrlPath is declared. - di := directoryItem{humanize.Bytes(link.Size), link.Name, gopath.Join(originalUrlPath, link.Name)} + s, err := dirit.Node().Size() + if err != nil { + internalWebError(w, err) + return + } + + di := directoryItem{humanize.Bytes(uint64(s)), dirit.Name(), gopath.Join(originalUrlPath, dirit.Name())} dirListing = append(dirListing, di) - return nil - }) + } + if dirit.Err() != nil { + internalWebError(w, dirit.Err()) + return + } // construct the correct back link // https://github.com/ipfs/go-ipfs/issues/1365 From 4b82d6d76a4a1b00a321cd206eeda52fb00945df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 4 Jan 2019 15:56:08 +0100 Subject: [PATCH 417/674] gateway: use Api.FetchBlocks for NoFetch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@c9168ecf058af53adcb5712f3706af0a534df381 --- gateway/core/corehttp/gateway.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 105f24361..6aad23786 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -26,7 +26,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { return nil, err } - api, err := coreapi.NewCoreAPI(n, options.Api.Offline(cfg.Gateway.NoFetch)) + api, err := coreapi.NewCoreAPI(n, options.Api.FetchBlocks(!cfg.Gateway.NoFetch)) if err != nil { return nil, err } From 49c15c550e652826642d2370695015615825bba5 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 4 Jan 2019 11:18:24 -0800 Subject: [PATCH 418/674] api: let the CORs library handle CORs headers License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@543be29796eee1e72280d22ddde12b57ef5c7ad7 --- gateway/core/corehttp/commands.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 99d3b3eff..aa2f51065 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -67,12 +67,17 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { } } - c.Headers = make(map[string][]string, len(nc.API.HTTPHeaders)) + c.Headers = make(map[string][]string, len(nc.API.HTTPHeaders)+1) // Copy these because the config is shared and this function is called // in multiple places concurrently. Updating these in-place *is* racy. for h, v := range nc.API.HTTPHeaders { - c.Headers[h] = v + switch h { + case cmdsHttp.ACAOrigin, cmdsHttp.ACAMethods, cmdsHttp.ACACredentials: + // these are handled by the CORs library. + default: + c.Headers[h] = v + } } c.Headers["Server"] = []string{"go-ipfs/" + version.CurrentVersionNumber} } From faf068b9b758b9ae1daf522792cb8c2935470b93 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 4 Jan 2019 12:08:57 -0800 Subject: [PATCH 419/674] gateway: fix CORs headers fixes #5138 -- always add user-agent to access-control-allow-headers. fixes #5888 -- same with content-type. fixes #5892 -- extend user-provided headers instead of overriding them. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@82629c00ec12e376e26b28d3551395d5e2dfb85c --- gateway/core/corehttp/gateway.go | 58 +++++++++++++++++++++++- gateway/core/corehttp/gateway_handler.go | 13 ------ 2 files changed, 57 insertions(+), 14 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 52560750a..ae3e035d8 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -4,6 +4,7 @@ import ( "fmt" "net" "net/http" + "sort" version "github.com/ipfs/go-ipfs" core "github.com/ipfs/go-ipfs/core" @@ -18,6 +19,26 @@ type GatewayConfig struct { PathPrefixes []string } +// A helper function to clean up a set of headers: +// 1. Canonicalizes. +// 2. Deduplicates. +// 3. Sorts. +func cleanHeaderSet(headers []string) []string { + // Deduplicate and canonicalize. + m := make(map[string]struct{}, len(headers)) + for _, h := range headers { + m[http.CanonicalHeaderKey(h)] = struct{}{} + } + result := make([]string, 0, len(m)) + for k := range m { + result = append(result, k) + } + + // Sort + sort.Strings(result) + return result +} + func GatewayOption(writable bool, paths ...string) ServeOption { return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { cfg, err := n.Repo.Config() @@ -30,8 +51,43 @@ func GatewayOption(writable bool, paths ...string) ServeOption { return nil, err } + headers := make(map[string][]string, len(cfg.Gateway.HTTPHeaders)) + for h, v := range cfg.Gateway.HTTPHeaders { + headers[h] = v + } + + // Hard-coded headers. + const ACAHeadersName = "Access-Control-Allow-Headers" + const ACEHeadersName = "Access-Control-Expose-Headers" + const ACAOriginName = "Access-Control-Allow-Origin" + const ACAMethodsName = "Access-Control-Allow-Methods" + + if _, ok := headers[ACAOriginName]; !ok { + // Default to *all* + headers[ACAOriginName] = []string{"*"} + } + if _, ok := headers[ACAMethodsName]; !ok { + // Default to GET + headers[ACAMethodsName] = []string{"GET"} + } + + headers[ACAHeadersName] = cleanHeaderSet( + append([]string{ + "Content-Type", + "User-Agent", + "Range", + "X-Requested-With", + }, headers[ACAHeadersName]...)) + + headers[ACEHeadersName] = cleanHeaderSet( + append([]string{ + "Content-Range", + "X-Chunked-Output", + "X-Stream-Output", + }, headers[ACEHeadersName]...)) + gateway := newGatewayHandler(n, GatewayConfig{ - Headers: cfg.Gateway.HTTPHeaders, + Headers: headers, Writable: writable, PathPrefixes: cfg.Gateway.PathPrefixes, }, api) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 553ebdcf8..bb6ff51c4 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -184,19 +184,6 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr w.Header().Set("X-IPFS-Path", urlPath) w.Header().Set("Etag", etag) - // set 'allowed' headers - // & expose those headers - var allowedHeadersArr = []string{ - "Content-Range", - "X-Chunked-Output", - "X-Stream-Output", - } - - var allowedHeaders = strings.Join(allowedHeadersArr, ", ") - - w.Header().Set("Access-Control-Allow-Headers", allowedHeaders) - w.Header().Set("Access-Control-Expose-Headers", allowedHeaders) - // Suborigin header, sandboxes apps from each other in the browser (even // though they are served from the same gateway domain). // From f23457c632a4a63197db9c4a240410610ea53b45 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 4 Jan 2019 13:00:31 -0800 Subject: [PATCH 420/674] gateway, api: canonicalize headers from user config License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@4bbf4cc9a08a55f1e0f69447a06179f2106e48c0 --- gateway/core/corehttp/commands.go | 1 + gateway/core/corehttp/gateway.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index aa2f51065..3b2a971b9 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -72,6 +72,7 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { // Copy these because the config is shared and this function is called // in multiple places concurrently. Updating these in-place *is* racy. for h, v := range nc.API.HTTPHeaders { + h = http.CanonicalHeaderKey(h) switch h { case cmdsHttp.ACAOrigin, cmdsHttp.ACAMethods, cmdsHttp.ACACredentials: // these are handled by the CORs library. diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index ae3e035d8..044144a76 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -53,7 +53,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { headers := make(map[string][]string, len(cfg.Gateway.HTTPHeaders)) for h, v := range cfg.Gateway.HTTPHeaders { - headers[h] = v + headers[http.CanonicalHeaderKey(h)] = v } // Hard-coded headers. From 8ae690a73456f99ea189de997ef527c83ff1eb4e Mon Sep 17 00:00:00 2001 From: Jack Loughran <30052269+jackloughran@users.noreply.github.com> Date: Thu, 8 Nov 2018 08:04:13 -0500 Subject: [PATCH 421/674] show hash if not in original url Change the template handler to pass the hash to the directory listing template if the original url doesn't contain the hash. The directory listing template will display the hash in grey under the original url if the hash is passed to it. License: MIT Signed-off-by: Jack Loughran This commit was moved from ipfs/kubo@9ef14863075ff30a75d35dea5d1ca7ef2a94e800 --- gateway/core/corehttp/gateway_handler.go | 6 ++++++ gateway/core/corehttp/gateway_indexPage.go | 1 + gateway/core/corehttp/gateway_test.go | 15 +++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 553ebdcf8..b850578f4 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -347,11 +347,17 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } } + var hash string + if !strings.Contains(originalUrlPath, "ipfs") { + hash = resolvedPath.Cid().String() + } + // See comment above where originalUrlPath is declared. tplData := listingTemplateData{ Listing: dirListing, Path: originalUrlPath, BackLink: backLink, + Hash: hash, } err = listingTemplate.Execute(w, tplData) if err != nil { diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index dbcdca708..5575baea4 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -14,6 +14,7 @@ type listingTemplateData struct { Listing []directoryItem Path string BackLink string + Hash string } type directoryItem struct { diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 3aa82c9ce..d8c3132e3 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -405,6 +405,9 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } + if !strings.Contains(s, dagn2.Cid().String()) { + t.Fatalf("expected hash in directory listing") + } // make request to directory listing at root req, err = http.NewRequest("GET", ts.URL, nil) @@ -435,6 +438,9 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } + if !strings.Contains(s, dagn1.Cid().String()) { + t.Fatalf("expected hash in directory listing") + } // make request to directory listing req, err = http.NewRequest("GET", ts.URL+"/foo%3F%20%23%3C%27/bar/", nil) @@ -465,6 +471,9 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } + if !strings.Contains(s, dagn3.Cid().String()) { + t.Fatalf("expected hash in directory listing") + } // make request to directory listing with prefix req, err = http.NewRequest("GET", ts.URL, nil) @@ -496,6 +505,9 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } + if !strings.Contains(s, dagn1.Cid().String()) { + t.Fatalf("expected hash in directory listing") + } // make request to directory listing with illegal prefix req, err = http.NewRequest("GET", ts.URL, nil) @@ -535,6 +547,9 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } + if !strings.Contains(s, dagn1.Cid().String()) { + t.Fatalf("expected hash in directory listing") + } } func TestCacheControlImmutable(t *testing.T) { From b16fca0b20347a1f6ad52151bac86c27d4ff182c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 3 Jan 2019 17:00:55 -0800 Subject: [PATCH 422/674] gateway index: fix check for displaying CID. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@65fc4b45e9f74fdc42ec60a2ae89d8487aa9ce59 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index b850578f4..6b7c15d41 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -348,7 +348,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } var hash string - if !strings.Contains(originalUrlPath, "ipfs") { + if !strings.HasPrefix(originalUrlPath, ipfsPathPrefix) { hash = resolvedPath.Cid().String() } From 27d98a2a428b04d52c99f2fbff12e28c5968592b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 5 Jan 2019 22:29:46 +0100 Subject: [PATCH 423/674] gateway: cleanup err switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@818e0e40c7163bea0f3f171028a895f6e181aebb --- gateway/core/corehttp/gateway_handler.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index e80a9fa45..0e1e7e0af 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -260,8 +260,8 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } idx, err := i.api.Unixfs().Get(ctx, coreiface.Join(resolvedPath, "index.html")) - switch { - case err == nil: + switch err.(type) { + case nil: dirwithoutslash := urlPath[len(urlPath)-1] != '/' goget := r.URL.Query().Get("go-get") == "1" if dirwithoutslash && !goget { @@ -279,10 +279,9 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // write to request http.ServeContent(w, r, "index.html", modtime, f) return + case resolver.ErrNoLink: + // no index.html; noop default: - if _, ok := err.(resolver.ErrNoLink); ok { - break - } internalWebError(w, err) return } From 9a561cc82236128975dcc85f7e4c205e688745a0 Mon Sep 17 00:00:00 2001 From: Diogo Silva Date: Mon, 7 Jan 2019 14:24:23 +0000 Subject: [PATCH 424/674] feat: update to Web UI v2.3.2 License: MIT Signed-off-by: Diogo Silva This commit was moved from ipfs/kubo@94de5d551f30633c63f15f8a119c6a1afeea7987 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index d11d25ae5..c4bb3648e 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmUnXcWZC5Ve21gUseouJsH5mLAyz5JPp8aHsg8qVUUK8e" +const WebUIPath = "/ipfs/QmenEBWcAk3tN94fSKpKFtUMwty1qNwSYw3DMDFV6cPBXA" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/QmUnXcWZC5Ve21gUseouJsH5mLAyz5JPp8aHsg8qVUUK8e", "/ipfs/QmSDgpiHco5yXdyVTfhKxr3aiJ82ynz8V14QcGKicM3rVh", "/ipfs/QmRuvWJz1Fc8B9cTsAYANHTXqGmKR9DVfY5nvMD1uA2WQ8", "/ipfs/QmQLXHs7K98JNQdWrBB2cQLJahPhmupbDjRuH1b9ibmwVa", From 1f3572f12f291a2cd6e014de750bfe60efcf7e63 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 8 Jan 2019 19:19:34 -0800 Subject: [PATCH 425/674] gx: update deps Importantly: * fixes a bunch of MFS bugs * pulls in some bitswap improvements License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@08cc5da55f9fa7732b0228ebdfd9e14cad18e3e2 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/corehttp.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 8 ++++---- gateway/core/corehttp/metrics_test.go | 6 +++--- gateway/core/corehttp/proxy.go | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 2bfa470f2..537e982de 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" - path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" + path "gx/ipfs/QmNYPETsdAu2uQ1k9q9S1jYEGURaLHV6cbYRSVFVRftpF8/go-path" cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds/http" + config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index fabc8b265..c8d8fdfa1 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,10 +12,10 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - manet "gx/ipfs/QmQVUtnrNGtCRkCMpXgpApfzQjc8FDaDVxHqWH8cnZQeh5/go-multiaddr-net" - ma "gx/ipfs/QmRKLtwMw131aK7ugC3G7ybpumMz78YrJe5dzneyindvG1/go-multiaddr" + ma "gx/ipfs/QmNTCey11oxhb1AxDnQBRHtdhap6Ctud872NjAYPYYXPuc/go-multiaddr" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" periodicproc "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/periodic" + manet "gx/ipfs/QmZcLBXKaFe8ND5YHPkJRAwmhJGrVsi1JqDZNyJ4nRK5Mj/go-multiaddr-net" logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 098df6bd8..fe3eb4e86 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -11,7 +11,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - id "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmYxivS34F2M2n44WQQnRHGAKS8aoRUxwGpi9wk4Cdn4Jf/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 44e823990..7850bb069 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,17 +16,17 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" + "gx/ipfs/QmNYPETsdAu2uQ1k9q9S1jYEGURaLHV6cbYRSVFVRftpF8/go-path" + "gx/ipfs/QmNYPETsdAu2uQ1k9q9S1jYEGURaLHV6cbYRSVFVRftpF8/go-path/resolver" "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" + ft "gx/ipfs/QmQXze9tG878pa4Euya4rrDpyTNX3kQe4dhCaBzBozGgpe/go-unixfs" + "gx/ipfs/QmQXze9tG878pa4Euya4rrDpyTNX3kQe4dhCaBzBozGgpe/go-unixfs/importer" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - "gx/ipfs/QmRASJXJUFygM5qU4YrH7k7jD6S4Hg8nJmgqJ4bYJvLatd/go-libp2p-routing" + dag "gx/ipfs/QmTQdH4848iTVCJmKXYyRiK72HufWTLYQQ8iN3JaQ8K1Hq/go-merkledag" + "gx/ipfs/QmTiRqrF5zkdZyrdsL5qndG1UbeWi8k8N2pYxCtXWrahR2/go-libp2p-routing" "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" - "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path/resolver" - ft "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs" - "gx/ipfs/Qmbvw7kpSM2p6rbQ57WGRhhqNfCiNGW6EKH4xgHLw4bsnB/go-unixfs/importer" ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" - dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 5378427a4..3c0fd4467 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,11 +18,11 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" + path "gx/ipfs/QmNYPETsdAu2uQ1k9q9S1jYEGURaLHV6cbYRSVFVRftpF8/go-path" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" - id "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/protocol/identify" - config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config" - path "gx/ipfs/QmZErC2Ay6WuGi96CPg316PwitdwgLo6RxZRqVjJjRj2MR/go-path" - dag "gx/ipfs/QmdV35UHnL1FM52baPkeUo6u7Fxm2CRUkPTLRPxeF8a4Ap/go-merkledag" + dag "gx/ipfs/QmTQdH4848iTVCJmKXYyRiK72HufWTLYQQ8iN3JaQ8K1Hq/go-merkledag" + id "gx/ipfs/QmYxivS34F2M2n44WQQnRHGAKS8aoRUxwGpi9wk4Cdn4Jf/go-libp2p/p2p/protocol/identify" + config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index bb40562a0..f505bae7a 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - inet "gx/ipfs/QmPtFaR7BWHLAjSwLh9kXcyrgTzDpuhcWLkx8ioa9RMYnx/go-libp2p-net" - swarmt "gx/ipfs/QmQdLXW5JTSsrVb3ZpnpbASRwyM8CcE4XcM5nPbN19dWLr/go-libp2p-swarm/testing" - bhost "gx/ipfs/QmRBaUEQEeFWywfrZJ64QgsmvcqgLSK3VbvGMR2NM2Edpf/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmNgLg1NTw37iWbYPKcyK85YJ9Whs1MkPtJwhfqbNYAyKg/go-libp2p-net" + bhost "gx/ipfs/QmYxivS34F2M2n44WQQnRHGAKS8aoRUxwGpi9wk4Cdn4Jf/go-libp2p/p2p/host/basic" + swarmt "gx/ipfs/QmegQFxhr1J6yZ1vDQuDmJi5jntmj6BL96S11HVtXNCaHb/go-libp2p-swarm/testing" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 03c1af65d..5f26c36b5 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -10,7 +10,7 @@ import ( core "github.com/ipfs/go-ipfs/core" - p2phttp "gx/ipfs/QmWGnBLJhzZ3xV5YQuS6CqczN143YmGAFQTMAdJ31msoK5/go-libp2p-http" + p2phttp "gx/ipfs/QmQz2LTeFhCwFthG1r28ETquLtVk9oNzqPdB4DnTaya4eH/go-libp2p-http" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" ) From 1411efc0b0fbd53c774e7cbc184dd26bbb3a224d Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Thu, 10 Jan 2019 21:31:11 +0100 Subject: [PATCH 426/674] Bubble go-ipfs-cmds 2.0.10 License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@ab270fbaa7d8e7bb13c14792b68f25496a0aadc0 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 537e982de..67c431f9d 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,8 +15,8 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" path "gx/ipfs/QmNYPETsdAu2uQ1k9q9S1jYEGURaLHV6cbYRSVFVRftpF8/go-path" - cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds/http" + cmds "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds/http" config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config" ) From b1bc50d261f56552b81a83ba1ba9a6814c08a66d Mon Sep 17 00:00:00 2001 From: Diogo Silva Date: Wed, 16 Jan 2019 13:12:52 +0000 Subject: [PATCH 427/674] chore: update to Web UI v2.3.3 License: MIT Signed-off-by: Diogo Silva This commit was moved from ipfs/kubo@e935daa382a76561bb4583e6457b06d8dcb6416c --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index c4bb3648e..d76281984 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmenEBWcAk3tN94fSKpKFtUMwty1qNwSYw3DMDFV6cPBXA" +const WebUIPath = "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/QmenEBWcAk3tN94fSKpKFtUMwty1qNwSYw3DMDFV6cPBXA", "/ipfs/QmUnXcWZC5Ve21gUseouJsH5mLAyz5JPp8aHsg8qVUUK8e", "/ipfs/QmSDgpiHco5yXdyVTfhKxr3aiJ82ynz8V14QcGKicM3rVh", "/ipfs/QmRuvWJz1Fc8B9cTsAYANHTXqGmKR9DVfY5nvMD1uA2WQ8", From 49c1858a8c5de9fdf450dee5cbb1c7cda76649b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 14 Jan 2019 22:05:10 +0100 Subject: [PATCH 428/674] gx: update go-unixfs to 1.2.14 and go-bitswap to 1.1.21 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (and everything else...) License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@53e55e3314f150202f92f0bacf93c8e444a24273 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 67c431f9d..ee13a1382 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,9 +14,9 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - path "gx/ipfs/QmNYPETsdAu2uQ1k9q9S1jYEGURaLHV6cbYRSVFVRftpF8/go-path" cmds "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds/http" + path "gx/ipfs/QmWqh9oob7ZHQRwU5CdTqpnC8ip8BEkFNrwXRxeNo5Y7vA/go-path" config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config" ) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 7850bb069..e4adb4b65 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,17 +16,17 @@ import ( coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" - "gx/ipfs/QmNYPETsdAu2uQ1k9q9S1jYEGURaLHV6cbYRSVFVRftpF8/go-path" - "gx/ipfs/QmNYPETsdAu2uQ1k9q9S1jYEGURaLHV6cbYRSVFVRftpF8/go-path/resolver" "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - ft "gx/ipfs/QmQXze9tG878pa4Euya4rrDpyTNX3kQe4dhCaBzBozGgpe/go-unixfs" - "gx/ipfs/QmQXze9tG878pa4Euya4rrDpyTNX3kQe4dhCaBzBozGgpe/go-unixfs/importer" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - dag "gx/ipfs/QmTQdH4848iTVCJmKXYyRiK72HufWTLYQQ8iN3JaQ8K1Hq/go-merkledag" + ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" + ft "gx/ipfs/QmSMJ4rZbCJaih3y82Ebq7BZqK6vU2FHsKcWKQiE1DPTpS/go-unixfs" + "gx/ipfs/QmSMJ4rZbCJaih3y82Ebq7BZqK6vU2FHsKcWKQiE1DPTpS/go-unixfs/importer" "gx/ipfs/QmTiRqrF5zkdZyrdsL5qndG1UbeWi8k8N2pYxCtXWrahR2/go-libp2p-routing" + "gx/ipfs/QmWqh9oob7ZHQRwU5CdTqpnC8ip8BEkFNrwXRxeNo5Y7vA/go-path" + "gx/ipfs/QmWqh9oob7ZHQRwU5CdTqpnC8ip8BEkFNrwXRxeNo5Y7vA/go-path/resolver" "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" - ipld "gx/ipfs/QmcKKBwfz6FyQdHR2jsXrrF6XeSBXYL86anmWNewpFpoF5/go-ipld-format" + dag "gx/ipfs/Qmb2UEG2TAeVrEJSjqsZF7Y2he7wRDkrdt6c3bECxwZf4k/go-merkledag" "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 3c0fd4467..62ccaed6f 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,10 +18,10 @@ import ( nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" - path "gx/ipfs/QmNYPETsdAu2uQ1k9q9S1jYEGURaLHV6cbYRSVFVRftpF8/go-path" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" - dag "gx/ipfs/QmTQdH4848iTVCJmKXYyRiK72HufWTLYQQ8iN3JaQ8K1Hq/go-merkledag" + path "gx/ipfs/QmWqh9oob7ZHQRwU5CdTqpnC8ip8BEkFNrwXRxeNo5Y7vA/go-path" id "gx/ipfs/QmYxivS34F2M2n44WQQnRHGAKS8aoRUxwGpi9wk4Cdn4Jf/go-libp2p/p2p/protocol/identify" + dag "gx/ipfs/Qmb2UEG2TAeVrEJSjqsZF7Y2he7wRDkrdt6c3bECxwZf4k/go-merkledag" config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" From e05b2251e670f3d8aca44da6ce567b012f76b08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 22 Jan 2019 15:00:41 +0100 Subject: [PATCH 429/674] Drop some coreunix code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@a49c07a1766c9786079ee9f79dd95ac2039d1371 --- gateway/core/corehttp/gateway_test.go | 125 ++++++++++++-------------- 1 file changed, 56 insertions(+), 69 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 62ccaed6f..184ed0f6f 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -13,15 +13,17 @@ import ( version "github.com/ipfs/go-ipfs" core "github.com/ipfs/go-ipfs/core" - coreunix "github.com/ipfs/go-ipfs/core/coreunix" + "github.com/ipfs/go-ipfs/core/coreapi" + "github.com/ipfs/go-ipfs/core/coreapi/interface" + "github.com/ipfs/go-ipfs/core/coreapi/interface/options" namesys "github.com/ipfs/go-ipfs/namesys" nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" path "gx/ipfs/QmWqh9oob7ZHQRwU5CdTqpnC8ip8BEkFNrwXRxeNo5Y7vA/go-path" + files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" id "gx/ipfs/QmYxivS34F2M2n44WQQnRHGAKS8aoRUxwGpi9wk4Cdn4Jf/go-libp2p/p2p/protocol/identify" - dag "gx/ipfs/Qmb2UEG2TAeVrEJSjqsZF7Y2he7wRDkrdt6c3bECxwZf4k/go-merkledag" config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" @@ -117,7 +119,7 @@ func doWithoutRedirect(req *http.Request) (*http.Response, error) { return res, nil } -func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, *core.IpfsNode) { +func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, iface.CoreAPI, context.Context) { n, err := newNodeWithMockNamesys(ns) if err != nil { t.Fatal(err) @@ -144,23 +146,28 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, *core t.Fatal(err) } - return ts, n + api, err := coreapi.NewCoreAPI(n) + if err != nil { + t.Fatal(err) + } + + return ts, api, n.Context() } func TestGatewayGet(t *testing.T) { ns := mockNamesys{} - ts, n := newTestServerAndNode(t, ns) + ts, api, ctx := newTestServerAndNode(t, ns) defer ts.Close() - k, err := coreunix.Add(n, strings.NewReader("fnord")) + k, err := api.Unixfs().Add(ctx, files.NewBytesFile([]byte("fnord"))) if err != nil { t.Fatal(err) } - ns["/ipns/example.com"] = path.FromString("/ipfs/" + k) - ns["/ipns/working.example.com"] = path.FromString("/ipfs/" + k) + ns["/ipns/example.com"] = path.FromString(k.String()) + ns["/ipns/working.example.com"] = path.FromString(k.String()) ns["/ipns/double.example.com"] = path.FromString("/ipns/working.example.com") ns["/ipns/triple.example.com"] = path.FromString("/ipns/double.example.com") - ns["/ipns/broken.example.com"] = path.FromString("/ipns/" + k) + ns["/ipns/broken.example.com"] = path.FromString("/ipns/" + k.Cid().String()) // We picked .man because: // 1. It's a valid TLD. // 2. Go treats it as the file extension for "man" files (even though @@ -168,18 +175,18 @@ func TestGatewayGet(t *testing.T) { // // Unfortunately, this may not work on all platforms as file type // detection is platform dependent. - ns["/ipns/example.man"] = path.FromString("/ipfs/" + k) + ns["/ipns/example.man"] = path.FromString(k.String()) t.Log(ts.URL) - for _, test := range []struct { + for i, test := range []struct { host string path string status int text string }{ {"localhost:5001", "/", http.StatusNotFound, "404 page not found\n"}, - {"localhost:5001", "/" + k, http.StatusNotFound, "404 page not found\n"}, - {"localhost:5001", "/ipfs/" + k, http.StatusOK, "fnord"}, + {"localhost:5001", "/" + k.Cid().String(), http.StatusNotFound, "404 page not found\n"}, + {"localhost:5001", k.String(), http.StatusOK, "fnord"}, {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusNotFound, "ipfs resolve -r /ipns/nxdomain.example.com: " + namesys.ErrResolveFailed.Error() + "\n"}, {"localhost:5001", "/ipns/%0D%0A%0D%0Ahello", http.StatusNotFound, "ipfs resolve -r /ipns/%0D%0A%0D%0Ahello: " + namesys.ErrResolveFailed.Error() + "\n"}, {"localhost:5001", "/ipns/example.com", http.StatusOK, "fnord"}, @@ -188,9 +195,9 @@ func TestGatewayGet(t *testing.T) { {"working.example.com", "/", http.StatusOK, "fnord"}, {"double.example.com", "/", http.StatusOK, "fnord"}, {"triple.example.com", "/", http.StatusOK, "fnord"}, - {"working.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/working.example.com/ipfs/" + k + ": no link named \"ipfs\" under " + k + "\n"}, + {"working.example.com", k.String(), http.StatusNotFound, "ipfs resolve -r /ipns/working.example.com" + k.String() + ": no link named \"ipfs\" under " + k.Cid().String() + "\n"}, {"broken.example.com", "/", http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/: " + namesys.ErrResolveFailed.Error() + "\n"}, - {"broken.example.com", "/ipfs/" + k, http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/ipfs/" + k + ": " + namesys.ErrResolveFailed.Error() + "\n"}, + {"broken.example.com", k.String(), http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com" + k.String() + ": " + namesys.ErrResolveFailed.Error() + "\n"}, // This test case ensures we don't treat the TLD as a file extension. {"example.man", "/", http.StatusOK, "fnord"}, } { @@ -213,7 +220,7 @@ func TestGatewayGet(t *testing.T) { t.Errorf("expected content type to be text/plain, got %s", contentType) } if resp.StatusCode != test.status { - t.Errorf("got %d, expected %d from %s", resp.StatusCode, test.status, urlstr) + t.Errorf("(%d) got %d, expected %d from %s", i, resp.StatusCode, test.status, urlstr) continue } body, err := ioutil.ReadAll(resp.Body) @@ -232,39 +239,26 @@ func TestIPNSHostnameRedirect(t *testing.T) { defer cancel() ns := mockNamesys{} - ts, n := newTestServerAndNode(t, ns) + ts, api, ctx := newTestServerAndNode(t, ns) t.Logf("test server url: %s", ts.URL) defer ts.Close() // create /ipns/example.net/foo/index.html - _, dagn1, err := coreunix.AddWrapped(n, strings.NewReader("_"), "_") - if err != nil { - t.Fatal(err) - } - - _, dagn2, err := coreunix.AddWrapped(n, strings.NewReader("_"), "index.html") - if err != nil { - t.Fatal(err) - } - - dagn1.(*dag.ProtoNode).AddNodeLink("foo", dagn2) - if err != nil { - t.Fatal(err) - } - err = n.DAG.Add(ctx, dagn2) - if err != nil { - t.Fatal(err) - } + f1 := files.NewMapDirectory(map[string]files.Node{ + "_": files.NewBytesFile([]byte("_")), + "foo": files.NewMapDirectory(map[string]files.Node{ + "index.html": files.NewBytesFile([]byte("_")), + }), + }) - err = n.DAG.Add(ctx, dagn1) + k, err := api.Unixfs().Add(ctx, f1, options.Unixfs.Wrap(true)) if err != nil { t.Fatal(err) } - k := dagn1.Cid() t.Logf("k: %s\n", k) - ns["/ipns/example.net"] = path.FromString("/ipfs/" + k.String()) + ns["/ipns/example.net"] = path.FromString(k.String()) // make request to directory containing index.html req, err := http.NewRequest("GET", ts.URL+"/foo", nil) @@ -336,45 +330,38 @@ func TestIPNSHostnameBacklinks(t *testing.T) { defer cancel() ns := mockNamesys{} - ts, n := newTestServerAndNode(t, ns) + ts, api, ctx := newTestServerAndNode(t, ns) t.Logf("test server url: %s", ts.URL) defer ts.Close() + f1 := files.NewMapDirectory(map[string]files.Node{ + "file.txt": files.NewBytesFile([]byte("1")), + "foo? #<'": files.NewMapDirectory(map[string]files.Node{ + "file.txt": files.NewBytesFile([]byte("2")), + "bar": files.NewMapDirectory(map[string]files.Node{ + "file.txt": files.NewBytesFile([]byte("3")), + }), + }), + }) + // create /ipns/example.net/foo/ - _, dagn1, err := coreunix.AddWrapped(n, strings.NewReader("1"), "file.txt") - if err != nil { - t.Fatal(err) - } - _, dagn2, err := coreunix.AddWrapped(n, strings.NewReader("2"), "file.txt") - if err != nil { - t.Fatal(err) - } - _, dagn3, err := coreunix.AddWrapped(n, strings.NewReader("3"), "file.txt") - if err != nil { - t.Fatal(err) - } - dagn2.(*dag.ProtoNode).AddNodeLink("bar", dagn3) - dagn1.(*dag.ProtoNode).AddNodeLink("foo? #<'", dagn2) + k, err := api.Unixfs().Add(ctx, f1, options.Unixfs.Wrap(true)) if err != nil { t.Fatal(err) } - err = n.DAG.Add(ctx, dagn3) + k2, err := api.ResolvePath(ctx, iface.Join(k, "foo? #<'")) if err != nil { t.Fatal(err) } - err = n.DAG.Add(ctx, dagn2) - if err != nil { - t.Fatal(err) - } - err = n.DAG.Add(ctx, dagn1) + + k3, err := api.ResolvePath(ctx, iface.Join(k, "foo? #<'/bar")) if err != nil { t.Fatal(err) } - k := dagn1.Cid() t.Logf("k: %s\n", k) - ns["/ipns/example.net"] = path.FromString("/ipfs/" + k.String()) + ns["/ipns/example.net"] = path.FromString(k.String()) // make request to directory listing req, err := http.NewRequest("GET", ts.URL+"/foo%3F%20%23%3C%27/", nil) @@ -405,7 +392,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } - if !strings.Contains(s, dagn2.Cid().String()) { + if !strings.Contains(s, k2.Cid().String()) { t.Fatalf("expected hash in directory listing") } @@ -438,7 +425,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } - if !strings.Contains(s, dagn1.Cid().String()) { + if !strings.Contains(s, k.Cid().String()) { t.Fatalf("expected hash in directory listing") } @@ -471,7 +458,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } - if !strings.Contains(s, dagn3.Cid().String()) { + if !strings.Contains(s, k3.Cid().String()) { t.Fatalf("expected hash in directory listing") } @@ -505,7 +492,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } - if !strings.Contains(s, dagn1.Cid().String()) { + if !strings.Contains(s, k.Cid().String()) { t.Fatalf("expected hash in directory listing") } @@ -547,13 +534,13 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } - if !strings.Contains(s, dagn1.Cid().String()) { + if !strings.Contains(s, k.Cid().String()) { t.Fatalf("expected hash in directory listing") } } func TestCacheControlImmutable(t *testing.T) { - ts, _ := newTestServerAndNode(t, nil) + ts, _, _ := newTestServerAndNode(t, nil) t.Logf("test server url: %s", ts.URL) defer ts.Close() @@ -579,7 +566,7 @@ func TestCacheControlImmutable(t *testing.T) { } func TestGoGetSupport(t *testing.T) { - ts, _ := newTestServerAndNode(t, nil) + ts, _, _ := newTestServerAndNode(t, nil) t.Logf("test server url: %s", ts.URL) defer ts.Close() @@ -603,7 +590,7 @@ func TestVersion(t *testing.T) { version.CurrentCommit = "theshortcommithash" ns := mockNamesys{} - ts, _ := newTestServerAndNode(t, ns) + ts, _, _ := newTestServerAndNode(t, ns) t.Logf("test server url: %s", ts.URL) defer ts.Close() From f0486081e7eff159b4ca89ad1cc80ce54e5798ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 30 Jan 2019 17:42:14 +0100 Subject: [PATCH 430/674] gx: update go-unixfs to propagate archive changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@7c2aa0e9a90f6882c0f987c679b66bdcc200df2c --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 6 +++--- gateway/core/corehttp/gateway_test.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index ee13a1382..3cbad69fc 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,8 +14,8 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - cmds "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmWGm4AbZEbnmdgVTza52MSNpEmBdFVqzmAysRbjrRyGbH/go-ipfs-cmds/http" + cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds/http" path "gx/ipfs/QmWqh9oob7ZHQRwU5CdTqpnC8ip8BEkFNrwXRxeNo5Y7vA/go-path" config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config" ) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index e4adb4b65..4e795d41c 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -17,15 +17,15 @@ import ( "github.com/ipfs/go-ipfs/dagutils" "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" + ft "gx/ipfs/QmQ1JnYpnzkaurjW1yxkQxC2w3K1PorNE1nv1vaP5Le7sq/go-unixfs" + "gx/ipfs/QmQ1JnYpnzkaurjW1yxkQxC2w3K1PorNE1nv1vaP5Le7sq/go-unixfs/importer" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" - ft "gx/ipfs/QmSMJ4rZbCJaih3y82Ebq7BZqK6vU2FHsKcWKQiE1DPTpS/go-unixfs" - "gx/ipfs/QmSMJ4rZbCJaih3y82Ebq7BZqK6vU2FHsKcWKQiE1DPTpS/go-unixfs/importer" "gx/ipfs/QmTiRqrF5zkdZyrdsL5qndG1UbeWi8k8N2pYxCtXWrahR2/go-libp2p-routing" "gx/ipfs/QmWqh9oob7ZHQRwU5CdTqpnC8ip8BEkFNrwXRxeNo5Y7vA/go-path" "gx/ipfs/QmWqh9oob7ZHQRwU5CdTqpnC8ip8BEkFNrwXRxeNo5Y7vA/go-path/resolver" - "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" + "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" dag "gx/ipfs/Qmb2UEG2TAeVrEJSjqsZF7Y2he7wRDkrdt6c3bECxwZf4k/go-merkledag" "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 184ed0f6f..06885b7e4 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -22,8 +22,8 @@ import ( ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" path "gx/ipfs/QmWqh9oob7ZHQRwU5CdTqpnC8ip8BEkFNrwXRxeNo5Y7vA/go-path" - files "gx/ipfs/QmXWZCd8jfaHmt4UDSnjKmGcrQMw95bDGWqEeVLVJjoANX/go-ipfs-files" id "gx/ipfs/QmYxivS34F2M2n44WQQnRHGAKS8aoRUxwGpi9wk4Cdn4Jf/go-libp2p/p2p/protocol/identify" + files "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" From 508a930765c8c6f5fcd1a8460399d6ab7e0418fe Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 7 Feb 2019 17:11:29 -0800 Subject: [PATCH 431/674] gx: update go-libp2p-peer Switch _back_ to the 0.4.18 style of peer IDs while we figure things out. See https://github.com/libp2p/specs/issues/138. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@2c93eeffc6ee84470c217a86c6cbef3070d27b83 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 6 +++--- gateway/core/corehttp/metrics_test.go | 6 +++--- gateway/core/corehttp/proxy.go | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 3cbad69fc..adddc257b 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds/http" - path "gx/ipfs/QmWqh9oob7ZHQRwU5CdTqpnC8ip8BEkFNrwXRxeNo5Y7vA/go-path" - config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config" + config "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index fe3eb4e86..7db412a72 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -11,7 +11,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - id "gx/ipfs/QmYxivS34F2M2n44WQQnRHGAKS8aoRUxwGpi9wk4Cdn4Jf/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 4e795d41c..d4e0ec51e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -17,16 +17,16 @@ import ( "github.com/ipfs/go-ipfs/dagutils" "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - ft "gx/ipfs/QmQ1JnYpnzkaurjW1yxkQxC2w3K1PorNE1nv1vaP5Le7sq/go-unixfs" - "gx/ipfs/QmQ1JnYpnzkaurjW1yxkQxC2w3K1PorNE1nv1vaP5Le7sq/go-unixfs/importer" + "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" + "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path/resolver" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" - "gx/ipfs/QmTiRqrF5zkdZyrdsL5qndG1UbeWi8k8N2pYxCtXWrahR2/go-libp2p-routing" - "gx/ipfs/QmWqh9oob7ZHQRwU5CdTqpnC8ip8BEkFNrwXRxeNo5Y7vA/go-path" - "gx/ipfs/QmWqh9oob7ZHQRwU5CdTqpnC8ip8BEkFNrwXRxeNo5Y7vA/go-path/resolver" + "gx/ipfs/QmRjT8Bkut84fHf9nxMQBxGsqLAkqzMdFaemDK7e61dBNZ/go-libp2p-routing" + dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" + ft "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" + "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs/importer" "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" - dag "gx/ipfs/Qmb2UEG2TAeVrEJSjqsZF7Y2he7wRDkrdt6c3bECxwZf4k/go-merkledag" "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 06885b7e4..e580d0945 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -21,10 +21,10 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" - path "gx/ipfs/QmWqh9oob7ZHQRwU5CdTqpnC8ip8BEkFNrwXRxeNo5Y7vA/go-path" - id "gx/ipfs/QmYxivS34F2M2n44WQQnRHGAKS8aoRUxwGpi9wk4Cdn4Jf/go-libp2p/p2p/protocol/identify" + path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" + id "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/protocol/identify" + config "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config" files "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" - config "gx/ipfs/QmcRKBUqc2p3L1ZraoJjbXfs9E6xzvEuyK9iypb5RGwfsr/go-ipfs-config" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index f505bae7a..0b2fcda68 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - inet "gx/ipfs/QmNgLg1NTw37iWbYPKcyK85YJ9Whs1MkPtJwhfqbNYAyKg/go-libp2p-net" - bhost "gx/ipfs/QmYxivS34F2M2n44WQQnRHGAKS8aoRUxwGpi9wk4Cdn4Jf/go-libp2p/p2p/host/basic" - swarmt "gx/ipfs/QmegQFxhr1J6yZ1vDQuDmJi5jntmj6BL96S11HVtXNCaHb/go-libp2p-swarm/testing" + bhost "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/host/basic" + swarmt "gx/ipfs/QmTJCJaS8Cpjc2MkoS32iwr4zMZtbLkaF9GJsUgH1uwtN9/go-libp2p-swarm/testing" + inet "gx/ipfs/QmZ7cBWUXkyWTMN4qH6NGoyMVs7JugyFChBNP4ZUp5rJHH/go-libp2p-net" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 5f26c36b5..dc9cc4295 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -10,7 +10,7 @@ import ( core "github.com/ipfs/go-ipfs/core" - p2phttp "gx/ipfs/QmQz2LTeFhCwFthG1r28ETquLtVk9oNzqPdB4DnTaya4eH/go-libp2p-http" + p2phttp "gx/ipfs/QmSiDBZWfzobZdgoEPYSNwZ9ehW2oSW1cWVkt7gXmN8apz/go-libp2p-http" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" ) From 06812686bd86a944fd3854f4e857006abbc804e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 8 Feb 2019 19:23:01 +0100 Subject: [PATCH 432/674] coreapi: move namesys options to coreapi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@1ff6349729e4a04242714e13e469c0434d681505 --- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/ipns_hostname.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index e580d0945..2000945c0 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,8 +16,8 @@ import ( "github.com/ipfs/go-ipfs/core/coreapi" "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/core/coreapi/interface/options" + nsopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" namesys "github.com/ipfs/go-ipfs/namesys" - nsopts "github.com/ipfs/go-ipfs/namesys/opts" repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 346acc6c3..dedf88627 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -7,8 +7,8 @@ import ( "strings" core "github.com/ipfs/go-ipfs/core" + nsopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" namesys "github.com/ipfs/go-ipfs/namesys" - nsopts "github.com/ipfs/go-ipfs/namesys/opts" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) From c86e78c6819e5dee8f52c52da2975d2240bb7884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 9 Feb 2019 01:40:57 +0100 Subject: [PATCH 433/674] coreapi: update imports to updated interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@7ed6b518b677734c8e725a1031ddd48093e23125 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 6 +++--- gateway/core/corehttp/ipns_hostname.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 7db412a72..781333824 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,7 +9,7 @@ import ( version "github.com/ipfs/go-ipfs" core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - options "github.com/ipfs/go-ipfs/core/coreapi/interface/options" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" id "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/protocol/identify" ) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d4e0ec51e..b82301e66 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -13,8 +13,8 @@ import ( "time" "github.com/ipfs/go-ipfs/core" - coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface" "github.com/ipfs/go-ipfs/dagutils" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 2000945c0..b8ceee393 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -14,11 +14,11 @@ import ( version "github.com/ipfs/go-ipfs" core "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/core/coreapi" - "github.com/ipfs/go-ipfs/core/coreapi/interface" - "github.com/ipfs/go-ipfs/core/coreapi/interface/options" - nsopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" namesys "github.com/ipfs/go-ipfs/namesys" repo "github.com/ipfs/go-ipfs/repo" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" + nsopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index dedf88627..e04eac1bb 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -7,8 +7,8 @@ import ( "strings" core "github.com/ipfs/go-ipfs/core" - nsopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options/namesys" namesys "github.com/ipfs/go-ipfs/namesys" + nsopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) From c852a23c8b596d96be6a7abfef7e44907df76070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 9 Feb 2019 01:57:26 +0100 Subject: [PATCH 434/674] coreapi: fix import grouping after extracting iface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@648cc40ec3013d4d85fe4aad443bc8189165c204 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 6 +++--- gateway/core/corehttp/ipns_hostname.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 781333824..326a087cd 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,9 +9,9 @@ import ( version "github.com/ipfs/go-ipfs" core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" id "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/protocol/identify" + options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index b82301e66..836d57dc0 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -14,7 +14,6 @@ import ( "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/dagutils" - coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" @@ -24,6 +23,7 @@ import ( ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" "gx/ipfs/QmRjT8Bkut84fHf9nxMQBxGsqLAkqzMdFaemDK7e61dBNZ/go-libp2p-routing" dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" + coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" ft "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs/importer" "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index b8ceee393..829b309a8 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,14 +16,14 @@ import ( "github.com/ipfs/go-ipfs/core/coreapi" namesys "github.com/ipfs/go-ipfs/namesys" repo "github.com/ipfs/go-ipfs/repo" - "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" - "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" - nsopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" id "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/protocol/identify" config "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" + "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" + nsopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" files "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index e04eac1bb..cd2f187ee 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -8,8 +8,8 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" - nsopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" + nsopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) From 92e5d0ab3b960498c0a803f3618da099bde6da19 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 11 Feb 2019 08:46:22 -0800 Subject: [PATCH 435/674] gx: update go-ipfs-files fix compatibility issue with js-ipfs License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@e97a60b073c5e70f26612886e030e715449471e6 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 8 ++++---- gateway/core/corehttp/gateway_test.go | 8 ++++---- gateway/core/corehttp/ipns_hostname.go | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index adddc257b..bfe383e8d 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,9 +14,9 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + cmds "gx/ipfs/QmPHTMcFRnDfyF8mk7RXHoZXNQ3uvBHDmuLgvkG7RLwN6t/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmPHTMcFRnDfyF8mk7RXHoZXNQ3uvBHDmuLgvkG7RLwN6t/go-ipfs-cmds/http" path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" - cmds "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmR77mMvvh8mJBBWQmBfQBu8oD38NUN4KE9SL2gDgAQNc6/go-ipfs-cmds/http" config "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 326a087cd..8e2aa516e 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -11,7 +11,7 @@ import ( coreapi "github.com/ipfs/go-ipfs/core/coreapi" id "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/protocol/identify" - options "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" + options "gx/ipfs/QmVSbopkxvLSRFuUn1SeHoEcArhCLn2okUbVpLvhQ1pm1X/interface-go-ipfs-core/options" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 836d57dc0..c6a8bbacd 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -18,16 +18,16 @@ import ( "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path/resolver" + "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" "gx/ipfs/QmRjT8Bkut84fHf9nxMQBxGsqLAkqzMdFaemDK7e61dBNZ/go-libp2p-routing" dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" - coreiface "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" - ft "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs" - "gx/ipfs/QmZArMcsVDsXdcLbUx4844CuqKXBpbxdeiryM4cnmGTNRq/go-unixfs/importer" - "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" + coreiface "gx/ipfs/QmVSbopkxvLSRFuUn1SeHoEcArhCLn2okUbVpLvhQ1pm1X/interface-go-ipfs-core" "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" + ft "gx/ipfs/QmetDvVkKzbr8PYuBV6S48q5DU9EUQktYjo9KdkA3zbQgK/go-unixfs" + "gx/ipfs/QmetDvVkKzbr8PYuBV6S48q5DU9EUQktYjo9KdkA3zbQgK/go-unixfs/importer" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 829b309a8..8c1ba73c7 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,12 +19,12 @@ import ( ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" + files "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" id "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/protocol/identify" config "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config" - "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core" - "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options" - nsopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" - files "gx/ipfs/QmaXvvAVAQ5ABqM5xtjYmV85xmN5MkWAZsX9H9Fwo4FVXp/go-ipfs-files" + "gx/ipfs/QmVSbopkxvLSRFuUn1SeHoEcArhCLn2okUbVpLvhQ1pm1X/interface-go-ipfs-core" + "gx/ipfs/QmVSbopkxvLSRFuUn1SeHoEcArhCLn2okUbVpLvhQ1pm1X/interface-go-ipfs-core/options" + nsopts "gx/ipfs/QmVSbopkxvLSRFuUn1SeHoEcArhCLn2okUbVpLvhQ1pm1X/interface-go-ipfs-core/options/namesys" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" ) diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index cd2f187ee..818e6a81d 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" - nsopts "gx/ipfs/QmWqb6eEpQ2qtu2jmcDWJXebP7YS14fwor8562g795ZxjH/interface-go-ipfs-core/options/namesys" + nsopts "gx/ipfs/QmVSbopkxvLSRFuUn1SeHoEcArhCLn2okUbVpLvhQ1pm1X/interface-go-ipfs-core/options/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) From f4924cf235c9428c8175cfa7fe378272a94a85a0 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 14 Feb 2019 14:58:35 -0800 Subject: [PATCH 436/674] gx: update libp2p stuff License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@cf0d4706e2d2022496f37da70e6a23448942e2ab --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 10 +++++----- gateway/core/corehttp/ipns_hostname.go | 2 +- gateway/core/corehttp/metrics_test.go | 2 +- gateway/core/corehttp/proxy.go | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index bfe383e8d..0a93333e6 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -16,7 +16,7 @@ import ( cmds "gx/ipfs/QmPHTMcFRnDfyF8mk7RXHoZXNQ3uvBHDmuLgvkG7RLwN6t/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmPHTMcFRnDfyF8mk7RXHoZXNQ3uvBHDmuLgvkG7RLwN6t/go-ipfs-cmds/http" - path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" + path "gx/ipfs/QmQiXYqcxU5AvpAJkfbXUEZgUYKog1Pd2Cv3WBiW2Hpe8M/go-path" config "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config" ) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 8e2aa516e..00205f337 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/protocol/identify" - options "gx/ipfs/QmVSbopkxvLSRFuUn1SeHoEcArhCLn2okUbVpLvhQ1pm1X/interface-go-ipfs-core/options" + options "gx/ipfs/QmNmqKNivNTN11HrKWJYt29n6Z2fuzkeDheQV62dbxNuLb/interface-go-ipfs-core/options" + id "gx/ipfs/QmebEmt23jQxrwnqBkFL4qbpE8EnnQunpv5U32LS5ESus1/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index c6a8bbacd..34271801e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,19 +15,19 @@ import ( "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/dagutils" + coreiface "gx/ipfs/QmNmqKNivNTN11HrKWJYt29n6Z2fuzkeDheQV62dbxNuLb/interface-go-ipfs-core" "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" - "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path/resolver" + "gx/ipfs/QmQiXYqcxU5AvpAJkfbXUEZgUYKog1Pd2Cv3WBiW2Hpe8M/go-path" + "gx/ipfs/QmQiXYqcxU5AvpAJkfbXUEZgUYKog1Pd2Cv3WBiW2Hpe8M/go-path/resolver" "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" + dag "gx/ipfs/QmQvMsV5aPyd7eMd3U1hvAUhZEupG3rXbVZn7ppU5RE6bt/go-merkledag" chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" "gx/ipfs/QmRjT8Bkut84fHf9nxMQBxGsqLAkqzMdFaemDK7e61dBNZ/go-libp2p-routing" - dag "gx/ipfs/QmUtsx89yiCY6F8mbpP6ecXckiSzCBH7EvkKZuZEHBcr1m/go-merkledag" - coreiface "gx/ipfs/QmVSbopkxvLSRFuUn1SeHoEcArhCLn2okUbVpLvhQ1pm1X/interface-go-ipfs-core" + ft "gx/ipfs/QmSygPSC63Uka8z9PYokAS4thiMAor17vhXUTi4qmKHh6P/go-unixfs" + "gx/ipfs/QmSygPSC63Uka8z9PYokAS4thiMAor17vhXUTi4qmKHh6P/go-unixfs/importer" "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" - ft "gx/ipfs/QmetDvVkKzbr8PYuBV6S48q5DU9EUQktYjo9KdkA3zbQgK/go-unixfs" - "gx/ipfs/QmetDvVkKzbr8PYuBV6S48q5DU9EUQktYjo9KdkA3zbQgK/go-unixfs/importer" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 8c1ba73c7..bb1c3f7ec 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,13 +18,13 @@ import ( repo "github.com/ipfs/go-ipfs/repo" ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" - path "gx/ipfs/QmQ3YSqfxunT5QBg6KBVskKyRE26q6hjSMyhpxchpm7jEN/go-path" + "gx/ipfs/QmNmqKNivNTN11HrKWJYt29n6Z2fuzkeDheQV62dbxNuLb/interface-go-ipfs-core" + "gx/ipfs/QmNmqKNivNTN11HrKWJYt29n6Z2fuzkeDheQV62dbxNuLb/interface-go-ipfs-core/options" + nsopts "gx/ipfs/QmNmqKNivNTN11HrKWJYt29n6Z2fuzkeDheQV62dbxNuLb/interface-go-ipfs-core/options/namesys" + path "gx/ipfs/QmQiXYqcxU5AvpAJkfbXUEZgUYKog1Pd2Cv3WBiW2Hpe8M/go-path" files "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" - id "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/protocol/identify" config "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config" - "gx/ipfs/QmVSbopkxvLSRFuUn1SeHoEcArhCLn2okUbVpLvhQ1pm1X/interface-go-ipfs-core" - "gx/ipfs/QmVSbopkxvLSRFuUn1SeHoEcArhCLn2okUbVpLvhQ1pm1X/interface-go-ipfs-core/options" - nsopts "gx/ipfs/QmVSbopkxvLSRFuUn1SeHoEcArhCLn2okUbVpLvhQ1pm1X/interface-go-ipfs-core/options/namesys" + id "gx/ipfs/QmebEmt23jQxrwnqBkFL4qbpE8EnnQunpv5U32LS5ESus1/go-libp2p/p2p/protocol/identify" datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" ) diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 818e6a81d..45129bd95 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" - nsopts "gx/ipfs/QmVSbopkxvLSRFuUn1SeHoEcArhCLn2okUbVpLvhQ1pm1X/interface-go-ipfs-core/options/namesys" + nsopts "gx/ipfs/QmNmqKNivNTN11HrKWJYt29n6Z2fuzkeDheQV62dbxNuLb/interface-go-ipfs-core/options/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 0b2fcda68..65f71919b 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmSgtf5vHyugoxcwMbyNy6bZ9qPDDTJSYEED2GkWjLwitZ/go-libp2p/p2p/host/basic" swarmt "gx/ipfs/QmTJCJaS8Cpjc2MkoS32iwr4zMZtbLkaF9GJsUgH1uwtN9/go-libp2p-swarm/testing" inet "gx/ipfs/QmZ7cBWUXkyWTMN4qH6NGoyMVs7JugyFChBNP4ZUp5rJHH/go-libp2p-net" + bhost "gx/ipfs/QmebEmt23jQxrwnqBkFL4qbpE8EnnQunpv5U32LS5ESus1/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index dc9cc4295..df66d4590 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" - p2phttp "gx/ipfs/QmSiDBZWfzobZdgoEPYSNwZ9ehW2oSW1cWVkt7gXmN8apz/go-libp2p-http" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" + p2phttp "gx/ipfs/QmbaG5aJzUQtpukF9fxrM6q2ZeCPrZxtdnudEcdiEaeL2n/go-libp2p-http" ) // ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer From 4ba27a3379fac35575fcaddad634356fbe379f39 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Mon, 18 Feb 2019 17:37:09 +0100 Subject: [PATCH 437/674] Update protobuf License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@28cf3de0f9e22124de614c7645ed4555ef76c9a1 --- gateway/core/corehttp/commands.go | 8 ++++---- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/gateway.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 16 ++++++++-------- gateway/core/corehttp/gateway_test.go | 18 +++++++++--------- gateway/core/corehttp/ipns_hostname.go | 2 +- gateway/core/corehttp/logs.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- gateway/core/corehttp/proxy.go | 2 +- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 0a93333e6..dbff220cf 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - cmds "gx/ipfs/QmPHTMcFRnDfyF8mk7RXHoZXNQ3uvBHDmuLgvkG7RLwN6t/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmPHTMcFRnDfyF8mk7RXHoZXNQ3uvBHDmuLgvkG7RLwN6t/go-ipfs-cmds/http" - path "gx/ipfs/QmQiXYqcxU5AvpAJkfbXUEZgUYKog1Pd2Cv3WBiW2Hpe8M/go-path" - config "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config" + config "gx/ipfs/QmRLDpfN3yCpHx4C6wwTkrFFK6bNxzBkgDbJPRsb5VLMQ2/go-ipfs-config" + cmds "gx/ipfs/QmUkb7H2WRutVR91pzoHZPwhbAMFgZMiuGZ2CZ3StuWsJ1/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmUkb7H2WRutVR91pzoHZPwhbAMFgZMiuGZ2CZ3StuWsJ1/go-ipfs-cmds/http" + path "gx/ipfs/QmXgYy6EgbKrpXFtfdHumWsEMd1HrsqGXtovrfBnMgbpfy/go-path" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index c8d8fdfa1..32a9a7834 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -16,7 +16,7 @@ import ( "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" periodicproc "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/periodic" manet "gx/ipfs/QmZcLBXKaFe8ND5YHPkJRAwmhJGrVsi1JqDZNyJ4nRK5Mj/go-multiaddr-net" - logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log" + logging "gx/ipfs/QmbkT7eMTyXfpeyB3ZMxxcxg7XH8t6uXp49jqzz4HB7BGF/go-log" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 00205f337..58b8a52b5 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - options "gx/ipfs/QmNmqKNivNTN11HrKWJYt29n6Z2fuzkeDheQV62dbxNuLb/interface-go-ipfs-core/options" - id "gx/ipfs/QmebEmt23jQxrwnqBkFL4qbpE8EnnQunpv5U32LS5ESus1/go-libp2p/p2p/protocol/identify" + options "gx/ipfs/QmNt8iUv3uJoVrJ3Ls4cgMLk124V4Bt1JxuUMWbjULt9ns/interface-go-ipfs-core/options" + id "gx/ipfs/QmcNGX5RaxPPCYwa6yGXM1EcUbrreTTinixLcYGmMwf1sx/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 34271801e..79e2e05f5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,18 +15,18 @@ import ( "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/dagutils" - coreiface "gx/ipfs/QmNmqKNivNTN11HrKWJYt29n6Z2fuzkeDheQV62dbxNuLb/interface-go-ipfs-core" + coreiface "gx/ipfs/QmNt8iUv3uJoVrJ3Ls4cgMLk124V4Bt1JxuUMWbjULt9ns/interface-go-ipfs-core" "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" - "gx/ipfs/QmQiXYqcxU5AvpAJkfbXUEZgUYKog1Pd2Cv3WBiW2Hpe8M/go-path" - "gx/ipfs/QmQiXYqcxU5AvpAJkfbXUEZgUYKog1Pd2Cv3WBiW2Hpe8M/go-path/resolver" "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" - dag "gx/ipfs/QmQvMsV5aPyd7eMd3U1hvAUhZEupG3rXbVZn7ppU5RE6bt/go-merkledag" - chunker "gx/ipfs/QmR4QQVkBZsZENRjYFVi8dEtPL3daZRNKk24m4r6WKJHNm/go-ipfs-chunker" "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" - "gx/ipfs/QmRjT8Bkut84fHf9nxMQBxGsqLAkqzMdFaemDK7e61dBNZ/go-libp2p-routing" - ft "gx/ipfs/QmSygPSC63Uka8z9PYokAS4thiMAor17vhXUTi4qmKHh6P/go-unixfs" - "gx/ipfs/QmSygPSC63Uka8z9PYokAS4thiMAor17vhXUTi4qmKHh6P/go-unixfs/importer" + "gx/ipfs/QmWaDSNoSdSXU9b6udyaq9T8y6LkzMwqWxECznFqvtcTsk/go-libp2p-routing" + "gx/ipfs/QmXgYy6EgbKrpXFtfdHumWsEMd1HrsqGXtovrfBnMgbpfy/go-path" + "gx/ipfs/QmXgYy6EgbKrpXFtfdHumWsEMd1HrsqGXtovrfBnMgbpfy/go-path/resolver" + chunker "gx/ipfs/QmXivYDjgMqNQXbEQVC7TMuZnRADCa71ABQUQxWPZPTLbd/go-ipfs-chunker" + ft "gx/ipfs/QmcTSz9ByVBLGkQBNgxFPvKAjMFriKX8PiyhHfjXQzPN23/go-unixfs" + "gx/ipfs/QmcTSz9ByVBLGkQBNgxFPvKAjMFriKX8PiyhHfjXQzPN23/go-unixfs/importer" + dag "gx/ipfs/Qmccmovpo9isKeaaDzcxvT7mVJN1uKwn2xzSs1y8hb6PEs/go-merkledag" "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index bb1c3f7ec..aa5e61cb2 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,16 +17,16 @@ import ( namesys "github.com/ipfs/go-ipfs/namesys" repo "github.com/ipfs/go-ipfs/repo" - ci "gx/ipfs/QmNiJiXwWE3kRhZrC5ej3kSjWHm337pYfhjLGSCDNKJP2s/go-libp2p-crypto" - "gx/ipfs/QmNmqKNivNTN11HrKWJYt29n6Z2fuzkeDheQV62dbxNuLb/interface-go-ipfs-core" - "gx/ipfs/QmNmqKNivNTN11HrKWJYt29n6Z2fuzkeDheQV62dbxNuLb/interface-go-ipfs-core/options" - nsopts "gx/ipfs/QmNmqKNivNTN11HrKWJYt29n6Z2fuzkeDheQV62dbxNuLb/interface-go-ipfs-core/options/namesys" - path "gx/ipfs/QmQiXYqcxU5AvpAJkfbXUEZgUYKog1Pd2Cv3WBiW2Hpe8M/go-path" + "gx/ipfs/QmNt8iUv3uJoVrJ3Ls4cgMLk124V4Bt1JxuUMWbjULt9ns/interface-go-ipfs-core" + "gx/ipfs/QmNt8iUv3uJoVrJ3Ls4cgMLk124V4Bt1JxuUMWbjULt9ns/interface-go-ipfs-core/options" + nsopts "gx/ipfs/QmNt8iUv3uJoVrJ3Ls4cgMLk124V4Bt1JxuUMWbjULt9ns/interface-go-ipfs-core/options/namesys" files "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" - config "gx/ipfs/QmTbcMKv6GU3fxhnNcbzYChdox9Fdd7VpucM3PQ7UWjX3D/go-ipfs-config" - id "gx/ipfs/QmebEmt23jQxrwnqBkFL4qbpE8EnnQunpv5U32LS5ESus1/go-libp2p/p2p/protocol/identify" - datastore "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore" - syncds "gx/ipfs/Qmf4xQhNomPNhrtZc67qSnfJSjxjXs9LWvknJtSXwimPrM/go-datastore/sync" + config "gx/ipfs/QmRLDpfN3yCpHx4C6wwTkrFFK6bNxzBkgDbJPRsb5VLMQ2/go-ipfs-config" + ci "gx/ipfs/QmTW4SdgBWq9GjsBsHeUx8WuGxzhgzAf88UMH2w62PC8yK/go-libp2p-crypto" + datastore "gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore" + syncds "gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore/sync" + path "gx/ipfs/QmXgYy6EgbKrpXFtfdHumWsEMd1HrsqGXtovrfBnMgbpfy/go-path" + id "gx/ipfs/QmcNGX5RaxPPCYwa6yGXM1EcUbrreTTinixLcYGmMwf1sx/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 45129bd95..e73938b9b 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" - nsopts "gx/ipfs/QmNmqKNivNTN11HrKWJYt29n6Z2fuzkeDheQV62dbxNuLb/interface-go-ipfs-core/options/namesys" + nsopts "gx/ipfs/QmNt8iUv3uJoVrJ3Ls4cgMLk124V4Bt1JxuUMWbjULt9ns/interface-go-ipfs-core/options/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 482aa3686..4fcfd1fb2 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - lwriter "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log/writer" + lwriter "gx/ipfs/QmbkT7eMTyXfpeyB3ZMxxcxg7XH8t6uXp49jqzz4HB7BGF/go-log/writer" ) type writeErrNotifier struct { diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 65f71919b..c2c27c65d 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - swarmt "gx/ipfs/QmTJCJaS8Cpjc2MkoS32iwr4zMZtbLkaF9GJsUgH1uwtN9/go-libp2p-swarm/testing" - inet "gx/ipfs/QmZ7cBWUXkyWTMN4qH6NGoyMVs7JugyFChBNP4ZUp5rJHH/go-libp2p-net" - bhost "gx/ipfs/QmebEmt23jQxrwnqBkFL4qbpE8EnnQunpv5U32LS5ESus1/go-libp2p/p2p/host/basic" + inet "gx/ipfs/QmTGxDz2CjBucFzPNTiWwzQmTWdrBnzqbqrMucDYMsjuPb/go-libp2p-net" + swarmt "gx/ipfs/QmU7iTrsNaJfu1Rf5DrvaJLH9wJtQwmP4Dj8oPduprAU68/go-libp2p-swarm/testing" + bhost "gx/ipfs/QmcNGX5RaxPPCYwa6yGXM1EcUbrreTTinixLcYGmMwf1sx/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index df66d4590..d105029fb 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" + p2phttp "gx/ipfs/QmYZJAgzELw6KpnLQL4GL67NGgSjX125BgfVa3tTF7JJeX/go-libp2p-http" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" - p2phttp "gx/ipfs/QmbaG5aJzUQtpukF9fxrM6q2ZeCPrZxtdnudEcdiEaeL2n/go-libp2p-http" ) // ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer From 4d9ee1904fa033b1d799d7761939e9d459ec6fdb Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 19 Feb 2019 03:48:04 -0800 Subject: [PATCH 438/674] coreapi: return coreiface.ErrNotSupported when "catting" symlinks. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@91ca5911be778f0ac4abd82b7b0a5c3e3a3a4307 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 6 +++--- gateway/core/corehttp/ipns_hostname.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 58b8a52b5..7b259c9b9 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -10,7 +10,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - options "gx/ipfs/QmNt8iUv3uJoVrJ3Ls4cgMLk124V4Bt1JxuUMWbjULt9ns/interface-go-ipfs-core/options" + options "gx/ipfs/QmNuVxikLRanHXwpw3sy58Vt5yMd4K5BRmWsUqYCctRRVE/interface-go-ipfs-core/options" id "gx/ipfs/QmcNGX5RaxPPCYwa6yGXM1EcUbrreTTinixLcYGmMwf1sx/go-libp2p/p2p/protocol/identify" ) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 79e2e05f5..acaa21d11 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,7 +15,7 @@ import ( "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/dagutils" - coreiface "gx/ipfs/QmNt8iUv3uJoVrJ3Ls4cgMLk124V4Bt1JxuUMWbjULt9ns/interface-go-ipfs-core" + coreiface "gx/ipfs/QmNuVxikLRanHXwpw3sy58Vt5yMd4K5BRmWsUqYCctRRVE/interface-go-ipfs-core" "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index aa5e61cb2..544d715fc 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,9 +17,9 @@ import ( namesys "github.com/ipfs/go-ipfs/namesys" repo "github.com/ipfs/go-ipfs/repo" - "gx/ipfs/QmNt8iUv3uJoVrJ3Ls4cgMLk124V4Bt1JxuUMWbjULt9ns/interface-go-ipfs-core" - "gx/ipfs/QmNt8iUv3uJoVrJ3Ls4cgMLk124V4Bt1JxuUMWbjULt9ns/interface-go-ipfs-core/options" - nsopts "gx/ipfs/QmNt8iUv3uJoVrJ3Ls4cgMLk124V4Bt1JxuUMWbjULt9ns/interface-go-ipfs-core/options/namesys" + "gx/ipfs/QmNuVxikLRanHXwpw3sy58Vt5yMd4K5BRmWsUqYCctRRVE/interface-go-ipfs-core" + "gx/ipfs/QmNuVxikLRanHXwpw3sy58Vt5yMd4K5BRmWsUqYCctRRVE/interface-go-ipfs-core/options" + nsopts "gx/ipfs/QmNuVxikLRanHXwpw3sy58Vt5yMd4K5BRmWsUqYCctRRVE/interface-go-ipfs-core/options/namesys" files "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" config "gx/ipfs/QmRLDpfN3yCpHx4C6wwTkrFFK6bNxzBkgDbJPRsb5VLMQ2/go-ipfs-config" ci "gx/ipfs/QmTW4SdgBWq9GjsBsHeUx8WuGxzhgzAf88UMH2w62PC8yK/go-libp2p-crypto" diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index e73938b9b..96a5d87d3 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" - nsopts "gx/ipfs/QmNt8iUv3uJoVrJ3Ls4cgMLk124V4Bt1JxuUMWbjULt9ns/interface-go-ipfs-core/options/namesys" + nsopts "gx/ipfs/QmNuVxikLRanHXwpw3sy58Vt5yMd4K5BRmWsUqYCctRRVE/interface-go-ipfs-core/options/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) From aafd275af952fc36528468621a18c296ca324620 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 19 Feb 2019 13:12:21 -0800 Subject: [PATCH 439/674] gx: update deps * Updates go-ipfs-cmds to try to get the tests to pass on travis. * While we're at it, fix duplicate gx deps. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@2f17b951c2ff29e9f250c5285bd85b23dc4f06fb --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index dbff220cf..bce140f90 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,9 +14,9 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" + cmds "gx/ipfs/QmQtQrtNioesAWtrx8csBvfY37gTe94d6wQ3VikZUjxD39/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmQtQrtNioesAWtrx8csBvfY37gTe94d6wQ3VikZUjxD39/go-ipfs-cmds/http" config "gx/ipfs/QmRLDpfN3yCpHx4C6wwTkrFFK6bNxzBkgDbJPRsb5VLMQ2/go-ipfs-config" - cmds "gx/ipfs/QmUkb7H2WRutVR91pzoHZPwhbAMFgZMiuGZ2CZ3StuWsJ1/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmUkb7H2WRutVR91pzoHZPwhbAMFgZMiuGZ2CZ3StuWsJ1/go-ipfs-cmds/http" path "gx/ipfs/QmXgYy6EgbKrpXFtfdHumWsEMd1HrsqGXtovrfBnMgbpfy/go-path" ) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index acaa21d11..e50a40f8a 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -16,7 +16,7 @@ import ( "github.com/ipfs/go-ipfs/dagutils" coreiface "gx/ipfs/QmNuVxikLRanHXwpw3sy58Vt5yMd4K5BRmWsUqYCctRRVE/interface-go-ipfs-core" - "gx/ipfs/QmPSBJL4momYnE7DcUyk2DVhD6rH488ZmHBGLbxNdhU44K/go-humanize" + "gx/ipfs/QmQMxG9D52TirZd9eLA37nxiNspnMRkKbyPWrVAa1gvtSy/go-humanize" "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" From 54cb6ea1688f9c68da5ddebf23f2033f42726332 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 20 Feb 2019 17:19:54 -0800 Subject: [PATCH 440/674] gx: update go-bitswap and go-libp2p-kad-dht * go-bitswap: fix some race conditions. * go-libp2p-kad-dht: fix a goroutine leak. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@f924f57c619dcde1e9a04610ed34e72318fffba9 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 8 ++++---- gateway/core/corehttp/ipns_hostname.go | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index bce140f90..daabfa2cf 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -17,7 +17,7 @@ import ( cmds "gx/ipfs/QmQtQrtNioesAWtrx8csBvfY37gTe94d6wQ3VikZUjxD39/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmQtQrtNioesAWtrx8csBvfY37gTe94d6wQ3VikZUjxD39/go-ipfs-cmds/http" config "gx/ipfs/QmRLDpfN3yCpHx4C6wwTkrFFK6bNxzBkgDbJPRsb5VLMQ2/go-ipfs-config" - path "gx/ipfs/QmXgYy6EgbKrpXFtfdHumWsEMd1HrsqGXtovrfBnMgbpfy/go-path" + path "gx/ipfs/QmaVydE6qtiiMhRUraPrzL6dvtfHPNR6Y9JJZcTwDAw9dY/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 7b259c9b9..e1571010b 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -10,7 +10,7 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - options "gx/ipfs/QmNuVxikLRanHXwpw3sy58Vt5yMd4K5BRmWsUqYCctRRVE/interface-go-ipfs-core/options" + options "gx/ipfs/QmUM3JbzMPPVpsUvUcfCdmeU2tssrdVPnUn5E6RawFjDLC/interface-go-ipfs-core/options" id "gx/ipfs/QmcNGX5RaxPPCYwa6yGXM1EcUbrreTTinixLcYGmMwf1sx/go-libp2p/p2p/protocol/identify" ) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index e50a40f8a..a4cca87c7 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,19 +15,19 @@ import ( "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/dagutils" - coreiface "gx/ipfs/QmNuVxikLRanHXwpw3sy58Vt5yMd4K5BRmWsUqYCctRRVE/interface-go-ipfs-core" "gx/ipfs/QmQMxG9D52TirZd9eLA37nxiNspnMRkKbyPWrVAa1gvtSy/go-humanize" "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" + coreiface "gx/ipfs/QmUM3JbzMPPVpsUvUcfCdmeU2tssrdVPnUn5E6RawFjDLC/interface-go-ipfs-core" + dag "gx/ipfs/QmUsnWBZaqpZ8i2wX37V2wC5hcB7VWB3zsUcNsyQ1Be5AX/go-merkledag" "gx/ipfs/QmWaDSNoSdSXU9b6udyaq9T8y6LkzMwqWxECznFqvtcTsk/go-libp2p-routing" - "gx/ipfs/QmXgYy6EgbKrpXFtfdHumWsEMd1HrsqGXtovrfBnMgbpfy/go-path" - "gx/ipfs/QmXgYy6EgbKrpXFtfdHumWsEMd1HrsqGXtovrfBnMgbpfy/go-path/resolver" chunker "gx/ipfs/QmXivYDjgMqNQXbEQVC7TMuZnRADCa71ABQUQxWPZPTLbd/go-ipfs-chunker" - ft "gx/ipfs/QmcTSz9ByVBLGkQBNgxFPvKAjMFriKX8PiyhHfjXQzPN23/go-unixfs" - "gx/ipfs/QmcTSz9ByVBLGkQBNgxFPvKAjMFriKX8PiyhHfjXQzPN23/go-unixfs/importer" - dag "gx/ipfs/Qmccmovpo9isKeaaDzcxvT7mVJN1uKwn2xzSs1y8hb6PEs/go-merkledag" + "gx/ipfs/QmaVydE6qtiiMhRUraPrzL6dvtfHPNR6Y9JJZcTwDAw9dY/go-path" + "gx/ipfs/QmaVydE6qtiiMhRUraPrzL6dvtfHPNR6Y9JJZcTwDAw9dY/go-path/resolver" "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" + ft "gx/ipfs/QmfKmRac17N7UmsV16vifHtB5Eqz3hTyKcu22Qb2oFoZyR/go-unixfs" + "gx/ipfs/QmfKmRac17N7UmsV16vifHtB5Eqz3hTyKcu22Qb2oFoZyR/go-unixfs/importer" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 544d715fc..14db6fa82 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,15 +17,15 @@ import ( namesys "github.com/ipfs/go-ipfs/namesys" repo "github.com/ipfs/go-ipfs/repo" - "gx/ipfs/QmNuVxikLRanHXwpw3sy58Vt5yMd4K5BRmWsUqYCctRRVE/interface-go-ipfs-core" - "gx/ipfs/QmNuVxikLRanHXwpw3sy58Vt5yMd4K5BRmWsUqYCctRRVE/interface-go-ipfs-core/options" - nsopts "gx/ipfs/QmNuVxikLRanHXwpw3sy58Vt5yMd4K5BRmWsUqYCctRRVE/interface-go-ipfs-core/options/namesys" files "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" config "gx/ipfs/QmRLDpfN3yCpHx4C6wwTkrFFK6bNxzBkgDbJPRsb5VLMQ2/go-ipfs-config" ci "gx/ipfs/QmTW4SdgBWq9GjsBsHeUx8WuGxzhgzAf88UMH2w62PC8yK/go-libp2p-crypto" + "gx/ipfs/QmUM3JbzMPPVpsUvUcfCdmeU2tssrdVPnUn5E6RawFjDLC/interface-go-ipfs-core" + "gx/ipfs/QmUM3JbzMPPVpsUvUcfCdmeU2tssrdVPnUn5E6RawFjDLC/interface-go-ipfs-core/options" + nsopts "gx/ipfs/QmUM3JbzMPPVpsUvUcfCdmeU2tssrdVPnUn5E6RawFjDLC/interface-go-ipfs-core/options/namesys" datastore "gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore" syncds "gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore/sync" - path "gx/ipfs/QmXgYy6EgbKrpXFtfdHumWsEMd1HrsqGXtovrfBnMgbpfy/go-path" + path "gx/ipfs/QmaVydE6qtiiMhRUraPrzL6dvtfHPNR6Y9JJZcTwDAw9dY/go-path" id "gx/ipfs/QmcNGX5RaxPPCYwa6yGXM1EcUbrreTTinixLcYGmMwf1sx/go-libp2p/p2p/protocol/identify" ) diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 96a5d87d3..c719ac80b 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" - nsopts "gx/ipfs/QmNuVxikLRanHXwpw3sy58Vt5yMd4K5BRmWsUqYCctRRVE/interface-go-ipfs-core/options/namesys" + nsopts "gx/ipfs/QmUM3JbzMPPVpsUvUcfCdmeU2tssrdVPnUn5E6RawFjDLC/interface-go-ipfs-core/options/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) From aff2cd86ac4559b86cc8f41bc8e0c07c097be140 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 20 Feb 2019 20:29:06 -0800 Subject: [PATCH 441/674] gx: update go-cid License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@fea7ae727ff5372b5b5a58bb9eed91989d71e748 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 20 ++++++++++---------- gateway/core/corehttp/gateway_test.go | 10 +++++----- gateway/core/corehttp/ipns_hostname.go | 2 +- gateway/core/corehttp/metrics_test.go | 2 +- gateway/core/corehttp/proxy.go | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index daabfa2cf..0127a1c38 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -16,8 +16,8 @@ import ( cmds "gx/ipfs/QmQtQrtNioesAWtrx8csBvfY37gTe94d6wQ3VikZUjxD39/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmQtQrtNioesAWtrx8csBvfY37gTe94d6wQ3VikZUjxD39/go-ipfs-cmds/http" + path "gx/ipfs/QmR3bNAtBoTN6xZ2HQNqpRQARcDoazH9jU6zKUNjFyQKWS/go-path" config "gx/ipfs/QmRLDpfN3yCpHx4C6wwTkrFFK6bNxzBkgDbJPRsb5VLMQ2/go-ipfs-config" - path "gx/ipfs/QmaVydE6qtiiMhRUraPrzL6dvtfHPNR6Y9JJZcTwDAw9dY/go-path" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index e1571010b..908859308 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - options "gx/ipfs/QmUM3JbzMPPVpsUvUcfCdmeU2tssrdVPnUn5E6RawFjDLC/interface-go-ipfs-core/options" - id "gx/ipfs/QmcNGX5RaxPPCYwa6yGXM1EcUbrreTTinixLcYGmMwf1sx/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmcZUhA1xQo8meuYBFLcTHqQb2ogpDCTZUTfTrko7PUeHs/go-libp2p/p2p/protocol/identify" + options "gx/ipfs/QmeWKXQfEqbtUDCiQBAHzSZDja9br5LdPgk8eHu86oJxgr/interface-go-ipfs-core/options" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index a4cca87c7..658eb3cb0 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -17,17 +17,17 @@ import ( "gx/ipfs/QmQMxG9D52TirZd9eLA37nxiNspnMRkKbyPWrVAa1gvtSy/go-humanize" "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" - "gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid" - ipld "gx/ipfs/QmRL22E4paat7ky7vx9MLpR97JHHbFPrg3ytFQw6qp1y1s/go-ipld-format" - coreiface "gx/ipfs/QmUM3JbzMPPVpsUvUcfCdmeU2tssrdVPnUn5E6RawFjDLC/interface-go-ipfs-core" - dag "gx/ipfs/QmUsnWBZaqpZ8i2wX37V2wC5hcB7VWB3zsUcNsyQ1Be5AX/go-merkledag" - "gx/ipfs/QmWaDSNoSdSXU9b6udyaq9T8y6LkzMwqWxECznFqvtcTsk/go-libp2p-routing" - chunker "gx/ipfs/QmXivYDjgMqNQXbEQVC7TMuZnRADCa71ABQUQxWPZPTLbd/go-ipfs-chunker" - "gx/ipfs/QmaVydE6qtiiMhRUraPrzL6dvtfHPNR6Y9JJZcTwDAw9dY/go-path" - "gx/ipfs/QmaVydE6qtiiMhRUraPrzL6dvtfHPNR6Y9JJZcTwDAw9dY/go-path/resolver" + "gx/ipfs/QmR3bNAtBoTN6xZ2HQNqpRQARcDoazH9jU6zKUNjFyQKWS/go-path" + "gx/ipfs/QmR3bNAtBoTN6xZ2HQNqpRQARcDoazH9jU6zKUNjFyQKWS/go-path/resolver" + dag "gx/ipfs/QmScf5hnTEK8fDpRJAbcdMnKXpKUp1ytdymzXUbXDCFssp/go-merkledag" + "gx/ipfs/QmTbxNB1NwDesLmKTscr4udL2tVP7MaxvXnD1D9yX7g3PN/go-cid" + ft "gx/ipfs/QmVytt7Vtb9jbGN2uNfEm15t78pBUjw1SS72nkJFcWYZwe/go-unixfs" + "gx/ipfs/QmVytt7Vtb9jbGN2uNfEm15t78pBUjw1SS72nkJFcWYZwe/go-unixfs/importer" + chunker "gx/ipfs/QmYmZ81dU5nnmBFy5MmktXLZpt8QCWhRJd6M1uxVF6vke8/go-ipfs-chunker" + ipld "gx/ipfs/QmZ6nzCLwGLVfRzYLpD7pW6UNuBDKEcA2imJtVpbEx2rxy/go-ipld-format" + "gx/ipfs/QmcxZXMqFu4vjLQRfG2tAcg6DPQNurgZ2SQ5iQVk6dXQjn/go-libp2p-routing" + coreiface "gx/ipfs/QmeWKXQfEqbtUDCiQBAHzSZDja9br5LdPgk8eHu86oJxgr/interface-go-ipfs-core" "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" - ft "gx/ipfs/QmfKmRac17N7UmsV16vifHtB5Eqz3hTyKcu22Qb2oFoZyR/go-unixfs" - "gx/ipfs/QmfKmRac17N7UmsV16vifHtB5Eqz3hTyKcu22Qb2oFoZyR/go-unixfs/importer" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 14db6fa82..396b753ec 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -18,15 +18,15 @@ import ( repo "github.com/ipfs/go-ipfs/repo" files "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" + path "gx/ipfs/QmR3bNAtBoTN6xZ2HQNqpRQARcDoazH9jU6zKUNjFyQKWS/go-path" config "gx/ipfs/QmRLDpfN3yCpHx4C6wwTkrFFK6bNxzBkgDbJPRsb5VLMQ2/go-ipfs-config" ci "gx/ipfs/QmTW4SdgBWq9GjsBsHeUx8WuGxzhgzAf88UMH2w62PC8yK/go-libp2p-crypto" - "gx/ipfs/QmUM3JbzMPPVpsUvUcfCdmeU2tssrdVPnUn5E6RawFjDLC/interface-go-ipfs-core" - "gx/ipfs/QmUM3JbzMPPVpsUvUcfCdmeU2tssrdVPnUn5E6RawFjDLC/interface-go-ipfs-core/options" - nsopts "gx/ipfs/QmUM3JbzMPPVpsUvUcfCdmeU2tssrdVPnUn5E6RawFjDLC/interface-go-ipfs-core/options/namesys" datastore "gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore" syncds "gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore/sync" - path "gx/ipfs/QmaVydE6qtiiMhRUraPrzL6dvtfHPNR6Y9JJZcTwDAw9dY/go-path" - id "gx/ipfs/QmcNGX5RaxPPCYwa6yGXM1EcUbrreTTinixLcYGmMwf1sx/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmcZUhA1xQo8meuYBFLcTHqQb2ogpDCTZUTfTrko7PUeHs/go-libp2p/p2p/protocol/identify" + "gx/ipfs/QmeWKXQfEqbtUDCiQBAHzSZDja9br5LdPgk8eHu86oJxgr/interface-go-ipfs-core" + "gx/ipfs/QmeWKXQfEqbtUDCiQBAHzSZDja9br5LdPgk8eHu86oJxgr/interface-go-ipfs-core/options" + nsopts "gx/ipfs/QmeWKXQfEqbtUDCiQBAHzSZDja9br5LdPgk8eHu86oJxgr/interface-go-ipfs-core/options/namesys" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index c719ac80b..6cf35f9ca 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -9,8 +9,8 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" - nsopts "gx/ipfs/QmUM3JbzMPPVpsUvUcfCdmeU2tssrdVPnUn5E6RawFjDLC/interface-go-ipfs-core/options/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" + nsopts "gx/ipfs/QmeWKXQfEqbtUDCiQBAHzSZDja9br5LdPgk8eHu86oJxgr/interface-go-ipfs-core/options/namesys" ) // IPNSHostnameOption rewrites an incoming request if its Host: header contains diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index c2c27c65d..8d939df55 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -9,7 +9,7 @@ import ( inet "gx/ipfs/QmTGxDz2CjBucFzPNTiWwzQmTWdrBnzqbqrMucDYMsjuPb/go-libp2p-net" swarmt "gx/ipfs/QmU7iTrsNaJfu1Rf5DrvaJLH9wJtQwmP4Dj8oPduprAU68/go-libp2p-swarm/testing" - bhost "gx/ipfs/QmcNGX5RaxPPCYwa6yGXM1EcUbrreTTinixLcYGmMwf1sx/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/QmcZUhA1xQo8meuYBFLcTHqQb2ogpDCTZUTfTrko7PUeHs/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index d105029fb..9b01ab993 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" - p2phttp "gx/ipfs/QmYZJAgzELw6KpnLQL4GL67NGgSjX125BgfVa3tTF7JJeX/go-libp2p-http" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" + p2phttp "gx/ipfs/Qmb5UdtFV53eNv3SgLWi7oT5sWcMDvvW3v5GZnCo1SYtYg/go-libp2p-http" ) // ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer From ecf7d13e394b4ec60860e844d22f29e020f09adb Mon Sep 17 00:00:00 2001 From: Diogo Silva Date: Mon, 25 Feb 2019 16:38:52 +0000 Subject: [PATCH 442/674] chore: update to Web UI 2.4.0 License: MIT Signed-off-by: Diogo Silva This commit was moved from ipfs/kubo@ded265fc67ae07ae35a034b7d18aa29113c27f7e --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index d76281984..8979da25f 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ" +const WebUIPath = "/ipfs/Qmb6o8HKrouK2WXVFS8753BArqnx5xz68tk6779ncPxpd8" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ", "/ipfs/QmenEBWcAk3tN94fSKpKFtUMwty1qNwSYw3DMDFV6cPBXA", "/ipfs/QmUnXcWZC5Ve21gUseouJsH5mLAyz5JPp8aHsg8qVUUK8e", "/ipfs/QmSDgpiHco5yXdyVTfhKxr3aiJ82ynz8V14QcGKicM3rVh", From 09754adee15e09414db212d52e0ff1fe134491a4 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 25 Feb 2019 16:45:43 -0700 Subject: [PATCH 443/674] gx: update go-ipfs-cmds fixes #6021 License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@3c2536dd819d939f0269918373da2ff25bf4a64c --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 0127a1c38..4a0651a6c 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - cmds "gx/ipfs/QmQtQrtNioesAWtrx8csBvfY37gTe94d6wQ3VikZUjxD39/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmQtQrtNioesAWtrx8csBvfY37gTe94d6wQ3VikZUjxD39/go-ipfs-cmds/http" path "gx/ipfs/QmR3bNAtBoTN6xZ2HQNqpRQARcDoazH9jU6zKUNjFyQKWS/go-path" config "gx/ipfs/QmRLDpfN3yCpHx4C6wwTkrFFK6bNxzBkgDbJPRsb5VLMQ2/go-ipfs-config" + cmds "gx/ipfs/QmWmn1Fo7ECXJYGAUf6wFWd677wVuryWePqUD678Dkt4ok/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmWmn1Fo7ECXJYGAUf6wFWd677wVuryWePqUD678Dkt4ok/go-ipfs-cmds/http" ) var ( From abded1625abc73b052ebd6de27a66f23c29325cc Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 26 Feb 2019 09:12:43 -0700 Subject: [PATCH 444/674] Revert "chore: update to Web UI 2.4.0" This commit was moved from ipfs/kubo@e804bafc79363f3b1d52c3c8b4c00b478266a2a7 --- gateway/core/corehttp/webui.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 8979da25f..d76281984 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,12 +1,11 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/Qmb6o8HKrouK2WXVFS8753BArqnx5xz68tk6779ncPxpd8" +const WebUIPath = "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, - "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ", "/ipfs/QmenEBWcAk3tN94fSKpKFtUMwty1qNwSYw3DMDFV6cPBXA", "/ipfs/QmUnXcWZC5Ve21gUseouJsH5mLAyz5JPp8aHsg8qVUUK8e", "/ipfs/QmSDgpiHco5yXdyVTfhKxr3aiJ82ynz8V14QcGKicM3rVh", From 4c725f4b52e27f4c12789906cd41b2882c7a54cf Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Wed, 27 Feb 2019 01:10:59 +0000 Subject: [PATCH 445/674] Gx Bubble. libp2p-6.0.38 License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@6972a9aa4da94bbd27ae856472276c93ae4cbe93 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/corehttp.go | 4 ++-- gateway/core/corehttp/gateway.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 14 +++++++------- gateway/core/corehttp/gateway_test.go | 12 ++++++------ gateway/core/corehttp/ipns_hostname.go | 2 +- gateway/core/corehttp/metrics_test.go | 6 +++--- gateway/core/corehttp/proxy.go | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 4a0651a6c..137f4a8c1 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,8 +14,8 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - path "gx/ipfs/QmR3bNAtBoTN6xZ2HQNqpRQARcDoazH9jU6zKUNjFyQKWS/go-path" - config "gx/ipfs/QmRLDpfN3yCpHx4C6wwTkrFFK6bNxzBkgDbJPRsb5VLMQ2/go-ipfs-config" + path "gx/ipfs/QmQ8Y8pKbrdAFuoHnnduWp81qS5LESWATnjmUEqhopRbJo/go-path" + config "gx/ipfs/QmUAuYuiafnJRZxDDX7MuruMNsicYNuyub5vUeAcupUBNs/go-ipfs-config" cmds "gx/ipfs/QmWmn1Fo7ECXJYGAUf6wFWd677wVuryWePqUD678Dkt4ok/go-ipfs-cmds" cmdsHttp "gx/ipfs/QmWmn1Fo7ECXJYGAUf6wFWd677wVuryWePqUD678Dkt4ok/go-ipfs-cmds/http" ) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 32a9a7834..75ec9b954 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,11 +12,11 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - ma "gx/ipfs/QmNTCey11oxhb1AxDnQBRHtdhap6Ctud872NjAYPYYXPuc/go-multiaddr" "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" periodicproc "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/periodic" - manet "gx/ipfs/QmZcLBXKaFe8ND5YHPkJRAwmhJGrVsi1JqDZNyJ4nRK5Mj/go-multiaddr-net" + ma "gx/ipfs/QmTZBfrPJmjWsCvHEtX5FE6KimVJhsJg5sBbqEFYf4UZtL/go-multiaddr" logging "gx/ipfs/QmbkT7eMTyXfpeyB3ZMxxcxg7XH8t6uXp49jqzz4HB7BGF/go-log" + manet "gx/ipfs/Qmc85NSvmSG4Frn9Vb2cBc1rMyULH6D3TNVEfCzSKoUpip/go-multiaddr-net" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 908859308..baa7dbd5d 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmcZUhA1xQo8meuYBFLcTHqQb2ogpDCTZUTfTrko7PUeHs/go-libp2p/p2p/protocol/identify" - options "gx/ipfs/QmeWKXQfEqbtUDCiQBAHzSZDja9br5LdPgk8eHu86oJxgr/interface-go-ipfs-core/options" + options "gx/ipfs/QmVzvYWRABgGEv4iu3M9wivWbZKTW29qsU4VTZ2iZEoExX/interface-go-ipfs-core/options" + id "gx/ipfs/QmWRUZmLb9qEpwuHTtrzbdE5LQxm64qftncw5o8tBVPobL/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 658eb3cb0..9e19e1d4c 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,18 +15,18 @@ import ( "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/dagutils" + dag "gx/ipfs/QmP9i4G9nRcfKBnpk1A7CwU7ppLkSn2j6vJeWn2AJ8rfcN/go-merkledag" + "gx/ipfs/QmQ8Y8pKbrdAFuoHnnduWp81qS5LESWATnjmUEqhopRbJo/go-path" + "gx/ipfs/QmQ8Y8pKbrdAFuoHnnduWp81qS5LESWATnjmUEqhopRbJo/go-path/resolver" "gx/ipfs/QmQMxG9D52TirZd9eLA37nxiNspnMRkKbyPWrVAa1gvtSy/go-humanize" "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" - "gx/ipfs/QmR3bNAtBoTN6xZ2HQNqpRQARcDoazH9jU6zKUNjFyQKWS/go-path" - "gx/ipfs/QmR3bNAtBoTN6xZ2HQNqpRQARcDoazH9jU6zKUNjFyQKWS/go-path/resolver" - dag "gx/ipfs/QmScf5hnTEK8fDpRJAbcdMnKXpKUp1ytdymzXUbXDCFssp/go-merkledag" + ft "gx/ipfs/QmSbCXEwpsog4vBf53YntmGk9uHsgZNuU5oBKv3o2kkTSe/go-unixfs" + "gx/ipfs/QmSbCXEwpsog4vBf53YntmGk9uHsgZNuU5oBKv3o2kkTSe/go-unixfs/importer" "gx/ipfs/QmTbxNB1NwDesLmKTscr4udL2tVP7MaxvXnD1D9yX7g3PN/go-cid" - ft "gx/ipfs/QmVytt7Vtb9jbGN2uNfEm15t78pBUjw1SS72nkJFcWYZwe/go-unixfs" - "gx/ipfs/QmVytt7Vtb9jbGN2uNfEm15t78pBUjw1SS72nkJFcWYZwe/go-unixfs/importer" + coreiface "gx/ipfs/QmVzvYWRABgGEv4iu3M9wivWbZKTW29qsU4VTZ2iZEoExX/interface-go-ipfs-core" chunker "gx/ipfs/QmYmZ81dU5nnmBFy5MmktXLZpt8QCWhRJd6M1uxVF6vke8/go-ipfs-chunker" + "gx/ipfs/QmYxUdYY9S6yg5tSPVin5GFTvtfsLauVcr7reHDD3dM8xf/go-libp2p-routing" ipld "gx/ipfs/QmZ6nzCLwGLVfRzYLpD7pW6UNuBDKEcA2imJtVpbEx2rxy/go-ipld-format" - "gx/ipfs/QmcxZXMqFu4vjLQRfG2tAcg6DPQNurgZ2SQ5iQVk6dXQjn/go-libp2p-routing" - coreiface "gx/ipfs/QmeWKXQfEqbtUDCiQBAHzSZDja9br5LdPgk8eHu86oJxgr/interface-go-ipfs-core" "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 396b753ec..f9a1ff74d 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,16 +17,16 @@ import ( namesys "github.com/ipfs/go-ipfs/namesys" repo "github.com/ipfs/go-ipfs/repo" + path "gx/ipfs/QmQ8Y8pKbrdAFuoHnnduWp81qS5LESWATnjmUEqhopRbJo/go-path" files "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" - path "gx/ipfs/QmR3bNAtBoTN6xZ2HQNqpRQARcDoazH9jU6zKUNjFyQKWS/go-path" - config "gx/ipfs/QmRLDpfN3yCpHx4C6wwTkrFFK6bNxzBkgDbJPRsb5VLMQ2/go-ipfs-config" ci "gx/ipfs/QmTW4SdgBWq9GjsBsHeUx8WuGxzhgzAf88UMH2w62PC8yK/go-libp2p-crypto" + config "gx/ipfs/QmUAuYuiafnJRZxDDX7MuruMNsicYNuyub5vUeAcupUBNs/go-ipfs-config" datastore "gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore" syncds "gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore/sync" - id "gx/ipfs/QmcZUhA1xQo8meuYBFLcTHqQb2ogpDCTZUTfTrko7PUeHs/go-libp2p/p2p/protocol/identify" - "gx/ipfs/QmeWKXQfEqbtUDCiQBAHzSZDja9br5LdPgk8eHu86oJxgr/interface-go-ipfs-core" - "gx/ipfs/QmeWKXQfEqbtUDCiQBAHzSZDja9br5LdPgk8eHu86oJxgr/interface-go-ipfs-core/options" - nsopts "gx/ipfs/QmeWKXQfEqbtUDCiQBAHzSZDja9br5LdPgk8eHu86oJxgr/interface-go-ipfs-core/options/namesys" + "gx/ipfs/QmVzvYWRABgGEv4iu3M9wivWbZKTW29qsU4VTZ2iZEoExX/interface-go-ipfs-core" + "gx/ipfs/QmVzvYWRABgGEv4iu3M9wivWbZKTW29qsU4VTZ2iZEoExX/interface-go-ipfs-core/options" + nsopts "gx/ipfs/QmVzvYWRABgGEv4iu3M9wivWbZKTW29qsU4VTZ2iZEoExX/interface-go-ipfs-core/options/namesys" + id "gx/ipfs/QmWRUZmLb9qEpwuHTtrzbdE5LQxm64qftncw5o8tBVPobL/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 6cf35f9ca..061c1c263 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -9,8 +9,8 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" + nsopts "gx/ipfs/QmVzvYWRABgGEv4iu3M9wivWbZKTW29qsU4VTZ2iZEoExX/interface-go-ipfs-core/options/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" - nsopts "gx/ipfs/QmeWKXQfEqbtUDCiQBAHzSZDja9br5LdPgk8eHu86oJxgr/interface-go-ipfs-core/options/namesys" ) // IPNSHostnameOption rewrites an incoming request if its Host: header contains diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 8d939df55..c78f77656 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - inet "gx/ipfs/QmTGxDz2CjBucFzPNTiWwzQmTWdrBnzqbqrMucDYMsjuPb/go-libp2p-net" - swarmt "gx/ipfs/QmU7iTrsNaJfu1Rf5DrvaJLH9wJtQwmP4Dj8oPduprAU68/go-libp2p-swarm/testing" - bhost "gx/ipfs/QmcZUhA1xQo8meuYBFLcTHqQb2ogpDCTZUTfTrko7PUeHs/go-libp2p/p2p/host/basic" + bhost "gx/ipfs/QmWRUZmLb9qEpwuHTtrzbdE5LQxm64qftncw5o8tBVPobL/go-libp2p/p2p/host/basic" + swarmt "gx/ipfs/QmX9A6whepz59nU5jU9fbVQGkZQspdWkvcpP7gCihoKnGS/go-libp2p-swarm/testing" + inet "gx/ipfs/QmY3ArotKMKaL7YGfbQfyDrib6RVraLqZYWXZvVgZktBxp/go-libp2p-net" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 9b01ab993..23aa55462 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" + p2phttp "gx/ipfs/QmUgYx5qgavtQFAUtgcfFJZdXZfYY7hAN3EUF4yrPhjJnb/go-libp2p-http" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" - p2phttp "gx/ipfs/Qmb5UdtFV53eNv3SgLWi7oT5sWcMDvvW3v5GZnCo1SYtYg/go-libp2p-http" ) // ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer From ea0ec3ce4e0327be062a3c9c6a6fc54666769fbd Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 27 Feb 2019 12:39:24 -0800 Subject: [PATCH 446/674] gx: update go-ipfs-cmds, go-bitswap, go-libp2p-kad-dht, and go-mplex Fixes the latest batch of bugs found in RC testing. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@f227862e8888204cde2636d4c3786e1f5fcb4b2d --- gateway/core/corehttp/commands.go | 6 +++--- gateway/core/corehttp/gateway.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ gateway/core/corehttp/gateway_test.go | 10 +++++----- gateway/core/corehttp/ipns_hostname.go | 2 +- gateway/core/corehttp/metrics_test.go | 4 ++-- gateway/core/corehttp/proxy.go | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 137f4a8c1..accef30c9 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - path "gx/ipfs/QmQ8Y8pKbrdAFuoHnnduWp81qS5LESWATnjmUEqhopRbJo/go-path" + path "gx/ipfs/QmQAgv6Gaoe2tQpcabqwKXKChp2MZ7i3UXv9DqTTaxCaTR/go-path" config "gx/ipfs/QmUAuYuiafnJRZxDDX7MuruMNsicYNuyub5vUeAcupUBNs/go-ipfs-config" - cmds "gx/ipfs/QmWmn1Fo7ECXJYGAUf6wFWd677wVuryWePqUD678Dkt4ok/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmWmn1Fo7ECXJYGAUf6wFWd677wVuryWePqUD678Dkt4ok/go-ipfs-cmds/http" + cmds "gx/ipfs/QmX6AchyJgso1WNamTJMdxfzGiWuYu94K6tF9MJ66rRhAu/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmX6AchyJgso1WNamTJMdxfzGiWuYu94K6tF9MJ66rRhAu/go-ipfs-cmds/http" ) var ( diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index baa7dbd5d..88d8bf447 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - options "gx/ipfs/QmVzvYWRABgGEv4iu3M9wivWbZKTW29qsU4VTZ2iZEoExX/interface-go-ipfs-core/options" - id "gx/ipfs/QmWRUZmLb9qEpwuHTtrzbdE5LQxm64qftncw5o8tBVPobL/go-libp2p/p2p/protocol/identify" + id "gx/ipfs/QmRxk6AUaGaKCfzS1xSNRojiAPd7h2ih8GuCdjJBF3Y6GK/go-libp2p/p2p/protocol/identify" + options "gx/ipfs/QmXLwxifxwfc2bAwq6rdjbYqAsGzWsDE9RM5TWMGtykyj6/interface-go-ipfs-core/options" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 9e19e1d4c..1c3675e6b 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,18 +15,18 @@ import ( "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/dagutils" - dag "gx/ipfs/QmP9i4G9nRcfKBnpk1A7CwU7ppLkSn2j6vJeWn2AJ8rfcN/go-merkledag" - "gx/ipfs/QmQ8Y8pKbrdAFuoHnnduWp81qS5LESWATnjmUEqhopRbJo/go-path" - "gx/ipfs/QmQ8Y8pKbrdAFuoHnnduWp81qS5LESWATnjmUEqhopRbJo/go-path/resolver" + dag "gx/ipfs/QmPJNbVw8o3ohC43ppSXyNXwYKsWShG4zygnirHptfbHri/go-merkledag" + "gx/ipfs/QmQAgv6Gaoe2tQpcabqwKXKChp2MZ7i3UXv9DqTTaxCaTR/go-path" + "gx/ipfs/QmQAgv6Gaoe2tQpcabqwKXKChp2MZ7i3UXv9DqTTaxCaTR/go-path/resolver" "gx/ipfs/QmQMxG9D52TirZd9eLA37nxiNspnMRkKbyPWrVAa1gvtSy/go-humanize" "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" - ft "gx/ipfs/QmSbCXEwpsog4vBf53YntmGk9uHsgZNuU5oBKv3o2kkTSe/go-unixfs" - "gx/ipfs/QmSbCXEwpsog4vBf53YntmGk9uHsgZNuU5oBKv3o2kkTSe/go-unixfs/importer" "gx/ipfs/QmTbxNB1NwDesLmKTscr4udL2tVP7MaxvXnD1D9yX7g3PN/go-cid" - coreiface "gx/ipfs/QmVzvYWRABgGEv4iu3M9wivWbZKTW29qsU4VTZ2iZEoExX/interface-go-ipfs-core" + coreiface "gx/ipfs/QmXLwxifxwfc2bAwq6rdjbYqAsGzWsDE9RM5TWMGtykyj6/interface-go-ipfs-core" chunker "gx/ipfs/QmYmZ81dU5nnmBFy5MmktXLZpt8QCWhRJd6M1uxVF6vke8/go-ipfs-chunker" "gx/ipfs/QmYxUdYY9S6yg5tSPVin5GFTvtfsLauVcr7reHDD3dM8xf/go-libp2p-routing" ipld "gx/ipfs/QmZ6nzCLwGLVfRzYLpD7pW6UNuBDKEcA2imJtVpbEx2rxy/go-ipld-format" + ft "gx/ipfs/QmcYUTQ7tBZeH1CLsZM2S3xhMEZdvUgXvbjhpMsLDpk3oJ/go-unixfs" + "gx/ipfs/QmcYUTQ7tBZeH1CLsZM2S3xhMEZdvUgXvbjhpMsLDpk3oJ/go-unixfs/importer" "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index f9a1ff74d..6bbd784d4 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -17,16 +17,16 @@ import ( namesys "github.com/ipfs/go-ipfs/namesys" repo "github.com/ipfs/go-ipfs/repo" - path "gx/ipfs/QmQ8Y8pKbrdAFuoHnnduWp81qS5LESWATnjmUEqhopRbJo/go-path" + path "gx/ipfs/QmQAgv6Gaoe2tQpcabqwKXKChp2MZ7i3UXv9DqTTaxCaTR/go-path" files "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" + id "gx/ipfs/QmRxk6AUaGaKCfzS1xSNRojiAPd7h2ih8GuCdjJBF3Y6GK/go-libp2p/p2p/protocol/identify" ci "gx/ipfs/QmTW4SdgBWq9GjsBsHeUx8WuGxzhgzAf88UMH2w62PC8yK/go-libp2p-crypto" config "gx/ipfs/QmUAuYuiafnJRZxDDX7MuruMNsicYNuyub5vUeAcupUBNs/go-ipfs-config" datastore "gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore" syncds "gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore/sync" - "gx/ipfs/QmVzvYWRABgGEv4iu3M9wivWbZKTW29qsU4VTZ2iZEoExX/interface-go-ipfs-core" - "gx/ipfs/QmVzvYWRABgGEv4iu3M9wivWbZKTW29qsU4VTZ2iZEoExX/interface-go-ipfs-core/options" - nsopts "gx/ipfs/QmVzvYWRABgGEv4iu3M9wivWbZKTW29qsU4VTZ2iZEoExX/interface-go-ipfs-core/options/namesys" - id "gx/ipfs/QmWRUZmLb9qEpwuHTtrzbdE5LQxm64qftncw5o8tBVPobL/go-libp2p/p2p/protocol/identify" + "gx/ipfs/QmXLwxifxwfc2bAwq6rdjbYqAsGzWsDE9RM5TWMGtykyj6/interface-go-ipfs-core" + "gx/ipfs/QmXLwxifxwfc2bAwq6rdjbYqAsGzWsDE9RM5TWMGtykyj6/interface-go-ipfs-core/options" + nsopts "gx/ipfs/QmXLwxifxwfc2bAwq6rdjbYqAsGzWsDE9RM5TWMGtykyj6/interface-go-ipfs-core/options/namesys" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 061c1c263..9b706dec8 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -9,7 +9,7 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" - nsopts "gx/ipfs/QmVzvYWRABgGEv4iu3M9wivWbZKTW29qsU4VTZ2iZEoExX/interface-go-ipfs-core/options/namesys" + nsopts "gx/ipfs/QmXLwxifxwfc2bAwq6rdjbYqAsGzWsDE9RM5TWMGtykyj6/interface-go-ipfs-core/options/namesys" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index c78f77656..7542260eb 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmWRUZmLb9qEpwuHTtrzbdE5LQxm64qftncw5o8tBVPobL/go-libp2p/p2p/host/basic" - swarmt "gx/ipfs/QmX9A6whepz59nU5jU9fbVQGkZQspdWkvcpP7gCihoKnGS/go-libp2p-swarm/testing" + bhost "gx/ipfs/QmRxk6AUaGaKCfzS1xSNRojiAPd7h2ih8GuCdjJBF3Y6GK/go-libp2p/p2p/host/basic" inet "gx/ipfs/QmY3ArotKMKaL7YGfbQfyDrib6RVraLqZYWXZvVgZktBxp/go-libp2p-net" + swarmt "gx/ipfs/Qma3Xp3FXFSP4prirEiRYHJ2tgGE8EAx9i6JLziPLpAQjq/go-libp2p-swarm/testing" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 23aa55462..63f397cbf 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" - p2phttp "gx/ipfs/QmUgYx5qgavtQFAUtgcfFJZdXZfYY7hAN3EUF4yrPhjJnb/go-libp2p-http" protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" + p2phttp "gx/ipfs/QmeXGHY2ntPsXLX28oGD2ufJB9EdvByz41Tt2sWrYPC7JJ/go-libp2p-http" ) // ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer From 7b63ad2aa6d9cc4ac84b71ec53fdb2196e08da91 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 1 Mar 2019 12:17:49 -0800 Subject: [PATCH 447/674] gx: update cmds and flatfs fixes #6028, fixes crash when writing after closing on flatfs. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@3fa1bfe1bc3a454143684f30cccb62d5267025d4 --- gateway/core/corehttp/commands.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index accef30c9..d05a7bcba 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -15,9 +15,9 @@ import ( corecommands "github.com/ipfs/go-ipfs/core/commands" path "gx/ipfs/QmQAgv6Gaoe2tQpcabqwKXKChp2MZ7i3UXv9DqTTaxCaTR/go-path" + cmds "gx/ipfs/QmQkW9fnCsg9SLHdViiAh6qfBppodsPZVpU92dZLqYtEfs/go-ipfs-cmds" + cmdsHttp "gx/ipfs/QmQkW9fnCsg9SLHdViiAh6qfBppodsPZVpU92dZLqYtEfs/go-ipfs-cmds/http" config "gx/ipfs/QmUAuYuiafnJRZxDDX7MuruMNsicYNuyub5vUeAcupUBNs/go-ipfs-config" - cmds "gx/ipfs/QmX6AchyJgso1WNamTJMdxfzGiWuYu94K6tF9MJ66rRhAu/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmX6AchyJgso1WNamTJMdxfzGiWuYu94K6tF9MJ66rRhAu/go-ipfs-cmds/http" ) var ( From 2becf00a750da1ea56ff56b5b0c8967364620e7e Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 4 Mar 2019 18:59:41 -0800 Subject: [PATCH 448/674] split 'mode' into IsOnline and IsDaemon flags 1. They don't _have_ to be mutually exclusive. 2. local, mode, etc is _really_ confusing. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@3dac4609a86996fe43215b72bb62c657befc6b11 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1c3675e6b..ad5b47d2d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -155,7 +155,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr // Resolve path to the final DAG node for the ETag resolvedPath, err := i.api.ResolvePath(ctx, parsedPath) - if err == coreiface.ErrOffline && !i.node.OnlineMode() { + if err == coreiface.ErrOffline && !i.node.IsOnline { webError(w, "ipfs resolve -r "+escapedURLPath, err, http.StatusServiceUnavailable) return } else if err != nil { From c5be156ff2b86a4e2c36d11ac403ad55ff3ca39d Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 4 Mar 2019 19:35:43 -0800 Subject: [PATCH 449/674] fix gateway_test on 32bit oses License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@23616af3144e00d4627808f0338ed99df4b827ad --- gateway/core/corehttp/gateway_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 6bbd784d4..28d9feccc 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -4,7 +4,6 @@ import ( "context" "errors" "io/ioutil" - "math" "net/http" "net/http/httptest" "strings" @@ -41,7 +40,8 @@ func (m mockNamesys) Resolve(ctx context.Context, name string, opts ...nsopts.Re } depth := cfg.Depth if depth == nsopts.UnlimitedDepth { - depth = math.MaxUint64 + // max uint + depth = ^uint(0) } for strings.HasPrefix(name, "/ipns/") { if depth <= 0 { From 4ea814cb44f88b88d291bfaa3afd3849bcbafc35 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Sat, 2 Mar 2019 19:26:36 +0100 Subject: [PATCH 450/674] gx: unrewrite License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@42e191c0170a8e818c3302dab9b5afbf968df405 --- gateway/core/corehttp/commands.go | 8 ++++---- gateway/core/corehttp/corehttp.go | 10 ++++----- gateway/core/corehttp/gateway.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 26 ++++++++++++------------ gateway/core/corehttp/gateway_test.go | 20 +++++++++--------- gateway/core/corehttp/ipns_hostname.go | 4 ++-- gateway/core/corehttp/logs.go | 2 +- gateway/core/corehttp/metrics.go | 4 ++-- gateway/core/corehttp/metrics_test.go | 6 +++--- gateway/core/corehttp/proxy.go | 4 ++-- gateway/core/corehttp/proxy_test.go | 2 +- 11 files changed, 45 insertions(+), 45 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index d05a7bcba..5ddfb9d80 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -14,10 +14,10 @@ import ( "github.com/ipfs/go-ipfs/core" corecommands "github.com/ipfs/go-ipfs/core/commands" - path "gx/ipfs/QmQAgv6Gaoe2tQpcabqwKXKChp2MZ7i3UXv9DqTTaxCaTR/go-path" - cmds "gx/ipfs/QmQkW9fnCsg9SLHdViiAh6qfBppodsPZVpU92dZLqYtEfs/go-ipfs-cmds" - cmdsHttp "gx/ipfs/QmQkW9fnCsg9SLHdViiAh6qfBppodsPZVpU92dZLqYtEfs/go-ipfs-cmds/http" - config "gx/ipfs/QmUAuYuiafnJRZxDDX7MuruMNsicYNuyub5vUeAcupUBNs/go-ipfs-config" + cmds "github.com/ipfs/go-ipfs-cmds" + cmdsHttp "github.com/ipfs/go-ipfs-cmds/http" + config "github.com/ipfs/go-ipfs-config" + path "github.com/ipfs/go-path" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 75ec9b954..330e8e9c2 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -12,11 +12,11 @@ import ( "time" core "github.com/ipfs/go-ipfs/core" - "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess" - periodicproc "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess/periodic" - ma "gx/ipfs/QmTZBfrPJmjWsCvHEtX5FE6KimVJhsJg5sBbqEFYf4UZtL/go-multiaddr" - logging "gx/ipfs/QmbkT7eMTyXfpeyB3ZMxxcxg7XH8t6uXp49jqzz4HB7BGF/go-log" - manet "gx/ipfs/Qmc85NSvmSG4Frn9Vb2cBc1rMyULH6D3TNVEfCzSKoUpip/go-multiaddr-net" + logging "github.com/ipfs/go-log" + "github.com/jbenet/goprocess" + periodicproc "github.com/jbenet/goprocess/periodic" + ma "github.com/multiformats/go-multiaddr" + manet "github.com/multiformats/go-multiaddr-net" ) var log = logging.Logger("core/server") diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 88d8bf447..d3600bb73 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - id "gx/ipfs/QmRxk6AUaGaKCfzS1xSNRojiAPd7h2ih8GuCdjJBF3Y6GK/go-libp2p/p2p/protocol/identify" - options "gx/ipfs/QmXLwxifxwfc2bAwq6rdjbYqAsGzWsDE9RM5TWMGtykyj6/interface-go-ipfs-core/options" + options "github.com/ipfs/interface-go-ipfs-core/options" + id "github.com/libp2p/go-libp2p/p2p/protocol/identify" ) type GatewayConfig struct { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ad5b47d2d..a62aee4cd 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -15,19 +15,19 @@ import ( "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/dagutils" - dag "gx/ipfs/QmPJNbVw8o3ohC43ppSXyNXwYKsWShG4zygnirHptfbHri/go-merkledag" - "gx/ipfs/QmQAgv6Gaoe2tQpcabqwKXKChp2MZ7i3UXv9DqTTaxCaTR/go-path" - "gx/ipfs/QmQAgv6Gaoe2tQpcabqwKXKChp2MZ7i3UXv9DqTTaxCaTR/go-path/resolver" - "gx/ipfs/QmQMxG9D52TirZd9eLA37nxiNspnMRkKbyPWrVAa1gvtSy/go-humanize" - "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" - "gx/ipfs/QmTbxNB1NwDesLmKTscr4udL2tVP7MaxvXnD1D9yX7g3PN/go-cid" - coreiface "gx/ipfs/QmXLwxifxwfc2bAwq6rdjbYqAsGzWsDE9RM5TWMGtykyj6/interface-go-ipfs-core" - chunker "gx/ipfs/QmYmZ81dU5nnmBFy5MmktXLZpt8QCWhRJd6M1uxVF6vke8/go-ipfs-chunker" - "gx/ipfs/QmYxUdYY9S6yg5tSPVin5GFTvtfsLauVcr7reHDD3dM8xf/go-libp2p-routing" - ipld "gx/ipfs/QmZ6nzCLwGLVfRzYLpD7pW6UNuBDKEcA2imJtVpbEx2rxy/go-ipld-format" - ft "gx/ipfs/QmcYUTQ7tBZeH1CLsZM2S3xhMEZdvUgXvbjhpMsLDpk3oJ/go-unixfs" - "gx/ipfs/QmcYUTQ7tBZeH1CLsZM2S3xhMEZdvUgXvbjhpMsLDpk3oJ/go-unixfs/importer" - "gx/ipfs/QmekxXDhCxCJRNuzmHreuaT3BsuJcsjcXWNrtV9C8DRHtd/go-multibase" + "github.com/dustin/go-humanize" + "github.com/ipfs/go-cid" + chunker "github.com/ipfs/go-ipfs-chunker" + "github.com/ipfs/go-ipfs-files" + ipld "github.com/ipfs/go-ipld-format" + dag "github.com/ipfs/go-merkledag" + "github.com/ipfs/go-path" + "github.com/ipfs/go-path/resolver" + ft "github.com/ipfs/go-unixfs" + "github.com/ipfs/go-unixfs/importer" + coreiface "github.com/ipfs/interface-go-ipfs-core" + "github.com/libp2p/go-libp2p-routing" + "github.com/multiformats/go-multibase" ) const ( diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 28d9feccc..d7e5a8be7 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -16,16 +16,16 @@ import ( namesys "github.com/ipfs/go-ipfs/namesys" repo "github.com/ipfs/go-ipfs/repo" - path "gx/ipfs/QmQAgv6Gaoe2tQpcabqwKXKChp2MZ7i3UXv9DqTTaxCaTR/go-path" - files "gx/ipfs/QmQmhotPUzVrMEWNK3x1R5jQ5ZHWyL7tVUrmRPjrBrvyCb/go-ipfs-files" - id "gx/ipfs/QmRxk6AUaGaKCfzS1xSNRojiAPd7h2ih8GuCdjJBF3Y6GK/go-libp2p/p2p/protocol/identify" - ci "gx/ipfs/QmTW4SdgBWq9GjsBsHeUx8WuGxzhgzAf88UMH2w62PC8yK/go-libp2p-crypto" - config "gx/ipfs/QmUAuYuiafnJRZxDDX7MuruMNsicYNuyub5vUeAcupUBNs/go-ipfs-config" - datastore "gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore" - syncds "gx/ipfs/QmUadX5EcvrBmxAV9sE7wUWtWSqxns5K84qKJBixmcT1w9/go-datastore/sync" - "gx/ipfs/QmXLwxifxwfc2bAwq6rdjbYqAsGzWsDE9RM5TWMGtykyj6/interface-go-ipfs-core" - "gx/ipfs/QmXLwxifxwfc2bAwq6rdjbYqAsGzWsDE9RM5TWMGtykyj6/interface-go-ipfs-core/options" - nsopts "gx/ipfs/QmXLwxifxwfc2bAwq6rdjbYqAsGzWsDE9RM5TWMGtykyj6/interface-go-ipfs-core/options/namesys" + datastore "github.com/ipfs/go-datastore" + syncds "github.com/ipfs/go-datastore/sync" + config "github.com/ipfs/go-ipfs-config" + files "github.com/ipfs/go-ipfs-files" + path "github.com/ipfs/go-path" + "github.com/ipfs/interface-go-ipfs-core" + "github.com/ipfs/interface-go-ipfs-core/options" + nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" + ci "github.com/libp2p/go-libp2p-crypto" + id "github.com/libp2p/go-libp2p/p2p/protocol/identify" ) // `ipfs object new unixfs-dir` diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 9b706dec8..d5512779b 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -9,8 +9,8 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" - nsopts "gx/ipfs/QmXLwxifxwfc2bAwq6rdjbYqAsGzWsDE9RM5TWMGtykyj6/interface-go-ipfs-core/options/namesys" - isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" + nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" + isd "github.com/jbenet/go-is-domain" ) // IPNSHostnameOption rewrites an incoming request if its Host: header contains diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 4fcfd1fb2..387508b6d 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -6,7 +6,7 @@ import ( "net/http" core "github.com/ipfs/go-ipfs/core" - lwriter "gx/ipfs/QmbkT7eMTyXfpeyB3ZMxxcxg7XH8t6uXp49jqzz4HB7BGF/go-log/writer" + lwriter "github.com/ipfs/go-log/writer" ) type writeErrNotifier struct { diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 6be50dbaf..3f8c68ccd 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -6,8 +6,8 @@ import ( core "github.com/ipfs/go-ipfs/core" - prometheus "gx/ipfs/QmTQuFQWHAWy4wMH6ZyPfGiawA5u9T8rs79FENoV8yXaoS/client_golang/prometheus" - promhttp "gx/ipfs/QmTQuFQWHAWy4wMH6ZyPfGiawA5u9T8rs79FENoV8yXaoS/client_golang/prometheus/promhttp" + prometheus "github.com/prometheus/client_golang/prometheus" + promhttp "github.com/prometheus/client_golang/prometheus/promhttp" ) // This adds the scraping endpoint which Prometheus uses to fetch metrics. diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 7542260eb..49270a71a 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,9 +7,9 @@ import ( core "github.com/ipfs/go-ipfs/core" - bhost "gx/ipfs/QmRxk6AUaGaKCfzS1xSNRojiAPd7h2ih8GuCdjJBF3Y6GK/go-libp2p/p2p/host/basic" - inet "gx/ipfs/QmY3ArotKMKaL7YGfbQfyDrib6RVraLqZYWXZvVgZktBxp/go-libp2p-net" - swarmt "gx/ipfs/Qma3Xp3FXFSP4prirEiRYHJ2tgGE8EAx9i6JLziPLpAQjq/go-libp2p-swarm/testing" + inet "github.com/libp2p/go-libp2p-net" + swarmt "github.com/libp2p/go-libp2p-swarm/testing" + bhost "github.com/libp2p/go-libp2p/p2p/host/basic" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 63f397cbf..b0579cb93 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" - protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" - p2phttp "gx/ipfs/QmeXGHY2ntPsXLX28oGD2ufJB9EdvByz41Tt2sWrYPC7JJ/go-libp2p-http" + p2phttp "github.com/hsanjuan/go-libp2p-http" + protocol "github.com/libp2p/go-libp2p-protocol" ) // ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer diff --git a/gateway/core/corehttp/proxy_test.go b/gateway/core/corehttp/proxy_test.go index 786dcf3d9..966f12c37 100644 --- a/gateway/core/corehttp/proxy_test.go +++ b/gateway/core/corehttp/proxy_test.go @@ -7,7 +7,7 @@ import ( "github.com/ipfs/go-ipfs/thirdparty/assert" - protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol" + protocol "github.com/libp2p/go-libp2p-protocol" ) type TestCase struct { From 282026eae3f623a4c1eeb21337624a1ff6d06fcd Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Sun, 3 Mar 2019 23:09:47 +0100 Subject: [PATCH 451/674] gomod/gx: use correct go-is-domain License: MIT Signed-off-by: Jakub Sztandera This commit was moved from ipfs/kubo@dc6423f7de68d06a92cdf03dd089caa2c87b8174 --- gateway/core/corehttp/gateway_test.go | 5 +++-- gateway/core/corehttp/ipns_hostname.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index d7e5a8be7..a2a77d1c5 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -21,7 +21,7 @@ import ( config "github.com/ipfs/go-ipfs-config" files "github.com/ipfs/go-ipfs-files" path "github.com/ipfs/go-path" - "github.com/ipfs/interface-go-ipfs-core" + iface "github.com/ipfs/interface-go-ipfs-core" "github.com/ipfs/interface-go-ipfs-core/options" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" ci "github.com/libp2p/go-libp2p-crypto" @@ -219,11 +219,12 @@ func TestGatewayGet(t *testing.T) { if contentType != "text/plain; charset=utf-8" { t.Errorf("expected content type to be text/plain, got %s", contentType) } + body, err := ioutil.ReadAll(resp.Body) if resp.StatusCode != test.status { t.Errorf("(%d) got %d, expected %d from %s", i, resp.StatusCode, test.status, urlstr) + t.Errorf("Body: %s", body) continue } - body, err := ioutil.ReadAll(resp.Body) if err != nil { t.Fatalf("error reading response from %s: %s", urlstr, err) } diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index d5512779b..1c926dca1 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -9,8 +9,8 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" + isd "github.com/gxed/go-is-domain" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" - isd "github.com/jbenet/go-is-domain" ) // IPNSHostnameOption rewrites an incoming request if its Host: header contains From 1d3ab94130f80685a9681d4a313e14e68ce5f7fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 4 Mar 2019 14:50:48 +0100 Subject: [PATCH 452/674] coreapi add wrap: fix gotests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@2e8bb8c0e6e1e77b0a6fd2628f31fc3426036b29 --- gateway/core/corehttp/gateway_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index a2a77d1c5..11baad3a2 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -253,7 +253,7 @@ func TestIPNSHostnameRedirect(t *testing.T) { }), }) - k, err := api.Unixfs().Add(ctx, f1, options.Unixfs.Wrap(true)) + k, err := api.Unixfs().Add(ctx, f1) if err != nil { t.Fatal(err) } @@ -346,7 +346,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { }) // create /ipns/example.net/foo/ - k, err := api.Unixfs().Add(ctx, f1, options.Unixfs.Wrap(true)) + k, err := api.Unixfs().Add(ctx, f1) if err != nil { t.Fatal(err) } From fd536be9527930032c8ce8702582d2ef0fe1f359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sun, 10 Mar 2019 22:50:37 +0100 Subject: [PATCH 453/674] coreapi: remove hidden file handling in add MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@c5b81e918f9326704d2e0a7602b932a4bfc63a6b --- gateway/core/corehttp/gateway_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 11baad3a2..b44f9ef4f 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -22,7 +22,6 @@ import ( files "github.com/ipfs/go-ipfs-files" path "github.com/ipfs/go-path" iface "github.com/ipfs/interface-go-ipfs-core" - "github.com/ipfs/interface-go-ipfs-core/options" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" ci "github.com/libp2p/go-libp2p-crypto" id "github.com/libp2p/go-libp2p/p2p/protocol/identify" From 76d851dad1dc57bcda9c07f61f5fcbb6b8089b2d Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 21 Mar 2019 22:53:07 -0700 Subject: [PATCH 454/674] deps: switch back to jbenet go-is-domain Also fixes https://github.com/ipfs/go-ipfs/issues/4153. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@b02bb95f4ab1b758a2dfe3956ca8eb316eec3b4c --- gateway/core/corehttp/ipns_hostname.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index 1c926dca1..d5512779b 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -9,8 +9,8 @@ import ( core "github.com/ipfs/go-ipfs/core" namesys "github.com/ipfs/go-ipfs/namesys" - isd "github.com/gxed/go-is-domain" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" + isd "github.com/jbenet/go-is-domain" ) // IPNSHostnameOption rewrites an incoming request if its Host: header contains From 4e58c7b2bd740db4a2c47c3c7ce0417e48afdda6 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 27 Mar 2019 14:46:29 +0000 Subject: [PATCH 455/674] chore: fix a bunch of issues caught by golangci-lint Most of these are probably harmless but a few looked like they might actually be bugs. Most of them are just faulty tests. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@1f293eff1b3da26a0c1e4c7d1c45adb88f536dd8 --- gateway/core/corehttp/gateway_test.go | 8 +------- gateway/core/corehttp/mutex_profile.go | 4 ++-- gateway/core/corehttp/option_test.go | 4 +++- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index b44f9ef4f..72193cf52 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -43,7 +43,7 @@ func (m mockNamesys) Resolve(ctx context.Context, name string, opts ...nsopts.Re depth = ^uint(0) } for strings.HasPrefix(name, "/ipns/") { - if depth <= 0 { + if depth == 0 { return value, namesys.ErrResolveRecursion } depth-- @@ -235,9 +235,6 @@ func TestGatewayGet(t *testing.T) { } func TestIPNSHostnameRedirect(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - ns := mockNamesys{} ts, api, ctx := newTestServerAndNode(t, ns) t.Logf("test server url: %s", ts.URL) @@ -326,9 +323,6 @@ func TestIPNSHostnameRedirect(t *testing.T) { } func TestIPNSHostnameBacklinks(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - ns := mockNamesys{} ts, api, ctx := newTestServerAndNode(t, ns) t.Logf("test server url: %s", ts.URL) diff --git a/gateway/core/corehttp/mutex_profile.go b/gateway/core/corehttp/mutex_profile.go index db39a7bc9..f8d66e5ef 100644 --- a/gateway/core/corehttp/mutex_profile.go +++ b/gateway/core/corehttp/mutex_profile.go @@ -20,7 +20,7 @@ func MutexFractionOption(path string) ServeOption { } if err := r.ParseForm(); err != nil { w.WriteHeader(http.StatusBadRequest) - w.Write([]byte(err.Error())) + _, _ = w.Write([]byte(err.Error())) return } @@ -33,7 +33,7 @@ func MutexFractionOption(path string) ServeOption { fr, err := strconv.Atoi(asfr) if err != nil { w.WriteHeader(http.StatusBadRequest) - w.Write([]byte(err.Error())) + _, _ = w.Write([]byte(err.Error())) return } log.Infof("Setting MutexProfileFraction to %d", fr) diff --git a/gateway/core/corehttp/option_test.go b/gateway/core/corehttp/option_test.go index 22157618c..17fcefe09 100644 --- a/gateway/core/corehttp/option_test.go +++ b/gateway/core/corehttp/option_test.go @@ -52,7 +52,9 @@ func TestCheckVersionOption(t *testing.T) { if !tc.shouldHandle { t.Error("handler was called even though version didn't match") } else { - io.WriteString(w, "check!") + if _, err := io.WriteString(w, "check!"); err != nil { + t.Error(err) + } } }) From 4bc19fa53bab14076c9de4794e6b08c36a303ab0 Mon Sep 17 00:00:00 2001 From: Oli Evans Date: Wed, 3 Apr 2019 11:43:45 +0100 Subject: [PATCH 456/674] feat: update to IPFS Web UI 2.4.4 - Improved MFS file manager - Opt-in, anonymouse, self-hosted web analytics (see https://github.com/ipfs-shipyard/ipfs-webui/pull/985) - Bug fixes and UX improvements https://github.com/ipfs-shipyard/ipfs-webui/releases/tag/v2.4.4 License: MIT Signed-off-by: Oli Evans This commit was moved from ipfs/kubo@6ab34b7f8ad4a9101e1bce3cb5c36e170bb11047 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index d76281984..15aaade45 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ" +const WebUIPath = "/ipfs/QmfQkD8pBSBCBxWEwFSu4XaDVSWK6bjnNuaWZjMyQbyDub" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ" "/ipfs/QmenEBWcAk3tN94fSKpKFtUMwty1qNwSYw3DMDFV6cPBXA", "/ipfs/QmUnXcWZC5Ve21gUseouJsH5mLAyz5JPp8aHsg8qVUUK8e", "/ipfs/QmSDgpiHco5yXdyVTfhKxr3aiJ82ynz8V14QcGKicM3rVh", From a4122c92284f07e5dc28733a4fc9178ba9b53c43 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 3 Apr 2019 05:28:33 -0700 Subject: [PATCH 457/674] fix(webui): syntax License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@c083e8fcc17c1cf579d1bae2525bf93ab646a824 --- gateway/core/corehttp/webui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 15aaade45..0df21d5f5 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -6,7 +6,7 @@ const WebUIPath = "/ipfs/QmfQkD8pBSBCBxWEwFSu4XaDVSWK6bjnNuaWZjMyQbyDub" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, - "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ" + "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ", "/ipfs/QmenEBWcAk3tN94fSKpKFtUMwty1qNwSYw3DMDFV6cPBXA", "/ipfs/QmUnXcWZC5Ve21gUseouJsH5mLAyz5JPp8aHsg8qVUUK8e", "/ipfs/QmSDgpiHco5yXdyVTfhKxr3aiJ82ynz8V14QcGKicM3rVh", From d724a2c0d4b65e583e227c7a99ca5b9d2c8b3f13 Mon Sep 17 00:00:00 2001 From: Masashi Salvador Mitsuzawa Date: Mon, 15 Apr 2019 11:59:39 +0900 Subject: [PATCH 458/674] fix the wrong path configuration in root redirection before: when path = "" => // -> handler after: when path = "" => / -> handler License: MIT Signed-off-by: Masashi Salvador Mitsuzawa This commit was moved from ipfs/kubo@04c87264b17db5ad4bb51ba33b92709211dbd069 --- gateway/core/corehttp/redirect.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/redirect.go b/gateway/core/corehttp/redirect.go index ec70ffaf9..e7b961e60 100644 --- a/gateway/core/corehttp/redirect.go +++ b/gateway/core/corehttp/redirect.go @@ -10,7 +10,11 @@ import ( func RedirectOption(path string, redirect string) ServeOption { handler := &redirectHandler{redirect} return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - mux.Handle("/"+path+"/", handler) + if len(path) > 0 { + mux.Handle("/"+path+"/", handler) + } else { + mux.Handle("/", handler) + } return mux, nil } } From 4299138ed24597919771de4d1355778a93bcfa02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 25 Mar 2019 17:04:59 +0100 Subject: [PATCH 459/674] coreapi: Update path error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@2e77df04ca89d738c3090b093de5b2251161663b --- gateway/core/corehttp/gateway_handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index a62aee4cd..638131d83 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -147,8 +147,8 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr ipnsHostname = true } - parsedPath, err := coreiface.ParsePath(urlPath) - if err != nil { + parsedPath := coreiface.ParsePath(urlPath) + if err := parsedPath.IsValid(); err != nil { webError(w, "invalid ipfs path", err, http.StatusBadRequest) return } From ae8dac84ae091af31273bb4e4c806a8089bc546b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 26 Mar 2019 14:56:54 +0100 Subject: [PATCH 460/674] coreiface: updates for moving path to subpackage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@667b7f9927801c7ef170c1f399254028833244f0 --- gateway/core/corehttp/gateway_handler.go | 5 +++-- gateway/core/corehttp/gateway_test.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 638131d83..d9bb818e1 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -26,6 +26,7 @@ import ( ft "github.com/ipfs/go-unixfs" "github.com/ipfs/go-unixfs/importer" coreiface "github.com/ipfs/interface-go-ipfs-core" + ipath "github.com/ipfs/interface-go-ipfs-core/path" "github.com/libp2p/go-libp2p-routing" "github.com/multiformats/go-multibase" ) @@ -147,7 +148,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr ipnsHostname = true } - parsedPath := coreiface.ParsePath(urlPath) + parsedPath := ipath.ParsePath(urlPath) if err := parsedPath.IsValid(); err != nil { webError(w, "invalid ipfs path", err, http.StatusBadRequest) return @@ -246,7 +247,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - idx, err := i.api.Unixfs().Get(ctx, coreiface.Join(resolvedPath, "index.html")) + idx, err := i.api.Unixfs().Get(ctx, ipath.Join(resolvedPath, "index.html")) switch err.(type) { case nil: dirwithoutslash := urlPath[len(urlPath)-1] != '/' diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 72193cf52..3578f33ad 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -23,6 +23,7 @@ import ( path "github.com/ipfs/go-path" iface "github.com/ipfs/interface-go-ipfs-core" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" + ipath "github.com/ipfs/interface-go-ipfs-core/path" ci "github.com/libp2p/go-libp2p-crypto" id "github.com/libp2p/go-libp2p/p2p/protocol/identify" ) @@ -344,12 +345,12 @@ func TestIPNSHostnameBacklinks(t *testing.T) { t.Fatal(err) } - k2, err := api.ResolvePath(ctx, iface.Join(k, "foo? #<'")) + k2, err := api.ResolvePath(ctx, ipath.Join(k, "foo? #<'")) if err != nil { t.Fatal(err) } - k3, err := api.ResolvePath(ctx, iface.Join(k, "foo? #<'/bar")) + k3, err := api.ResolvePath(ctx, ipath.Join(k, "foo? #<'/bar")) if err != nil { t.Fatal(err) } From 6832490849b41a73996af73ba6e0f6ccd1812f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 26 Mar 2019 15:11:03 +0100 Subject: [PATCH 461/674] coreiface: updates for path name refactor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@a54b64bedee45f67287f412ffa2780f8ac65306e --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d9bb818e1..cdbcce594 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -148,7 +148,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr ipnsHostname = true } - parsedPath := ipath.ParsePath(urlPath) + parsedPath := ipath.New(urlPath) if err := parsedPath.IsValid(); err != nil { webError(w, "invalid ipfs path", err, http.StatusBadRequest) return From f5377f52ebdb9b4f9c30afbc42bcd8b4d44798cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Fri, 29 Mar 2019 15:55:52 +0100 Subject: [PATCH 462/674] Fix goprocess / lifecycle / ctx relations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@cc2be2e73a5f568643680f876ba3ff377d67f08b --- gateway/core/corehttp/corehttp.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 330e8e9c2..c52bea8f5 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -85,7 +85,7 @@ func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error } select { - case <-node.Process().Closing(): + case <-node.Process.Closing(): return fmt.Errorf("failed to start server, process closing") default: } @@ -95,7 +95,7 @@ func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error } var serverError error - serverProc := node.Process().Go(func(p goprocess.Process) { + serverProc := node.Process.Go(func(p goprocess.Process) { serverError = server.Serve(lis) }) @@ -103,7 +103,7 @@ func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error select { case <-serverProc.Closed(): // if node being closed before server exits, close server - case <-node.Process().Closing(): + case <-node.Process.Closing(): log.Infof("server at %s terminating...", addr) warnProc := periodicproc.Tick(5*time.Second, func(_ goprocess.Process) { From 6077854a439a11d4312de1f558abc6ff277cdf26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 3 Apr 2019 03:51:45 +0200 Subject: [PATCH 463/674] Move pathresolve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Łukasz Magiera This commit was moved from ipfs/kubo@7046626eccfb1d8e1c500a637c4f85dbef373972 --- gateway/core/corehttp/gateway_handler.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index cdbcce594..72566930b 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -14,6 +14,7 @@ import ( "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/dagutils" + "github.com/ipfs/go-ipfs/namesys/resolve" "github.com/dustin/go-humanize" "github.com/ipfs/go-cid" @@ -423,7 +424,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { } var newcid cid.Cid - rnode, err := core.Resolve(ctx, i.node.Namesys, i.node.Resolver, rootPath) + rnode, err := resolve.Resolve(ctx, i.node.Namesys, i.node.Resolver, rootPath) switch ev := err.(type) { case resolver.ErrNoLink: // ev.Node < node where resolve failed From 2e8c3ecee2cabfd673c460f4d37a2ffbd4bcaef8 Mon Sep 17 00:00:00 2001 From: tg Date: Mon, 22 Apr 2019 20:39:21 +0300 Subject: [PATCH 464/674] core/corehttp/gateway_handler: pass a request ctx instead of the node ctx License: MIT Signed-off-by: Georgij Tolstov This commit was moved from ipfs/kubo@d2836de5774efea366301298bfc363a95b0d6fab --- gateway/core/corehttp/gateway_handler.go | 74 +++++++++++++----------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 72566930b..50ee377f8 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -19,7 +19,7 @@ import ( "github.com/dustin/go-humanize" "github.com/ipfs/go-cid" chunker "github.com/ipfs/go-ipfs-chunker" - "github.com/ipfs/go-ipfs-files" + files "github.com/ipfs/go-ipfs-files" ipld "github.com/ipfs/go-ipld-format" dag "github.com/ipfs/go-merkledag" "github.com/ipfs/go-path" @@ -28,7 +28,7 @@ import ( "github.com/ipfs/go-unixfs/importer" coreiface "github.com/ipfs/interface-go-ipfs-core" ipath "github.com/ipfs/interface-go-ipfs-core/path" - "github.com/libp2p/go-libp2p-routing" + routing "github.com/libp2p/go-libp2p-routing" "github.com/multiformats/go-multibase" ) @@ -67,6 +67,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // the hour is a hard fallback, we don't expect it to happen, but just in case ctx, cancel := context.WithTimeout(r.Context(), time.Hour) defer cancel() + r = r.WithContext(ctx) defer func() { if r := recover(); r != nil { @@ -79,7 +80,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if i.config.Writable { switch r.Method { case "POST": - i.postHandler(ctx, w, r) + i.postHandler(w, r) return case "PUT": i.putHandler(w, r) @@ -91,7 +92,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if r.Method == "GET" || r.Method == "HEAD" { - i.getOrHeadHandler(ctx, w, r) + i.getOrHeadHandler(w, r) return } @@ -120,7 +121,7 @@ func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request) i.addUserHeaders(w) // return all custom headers (including CORS ones, if set) } -func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { +func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) { urlPath := r.URL.Path escapedURLPath := r.URL.EscapedPath() @@ -156,7 +157,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr } // Resolve path to the final DAG node for the ETag - resolvedPath, err := i.api.ResolvePath(ctx, parsedPath) + resolvedPath, err := i.api.ResolvePath(r.Context(), parsedPath) if err == coreiface.ErrOffline && !i.node.IsOnline { webError(w, "ipfs resolve -r "+escapedURLPath, err, http.StatusServiceUnavailable) return @@ -165,7 +166,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - dr, err := i.api.Unixfs().Get(ctx, resolvedPath) + dr, err := i.api.Unixfs().Get(r.Context(), resolvedPath) if err != nil { webError(w, "ipfs cat "+escapedURLPath, err, http.StatusNotFound) return @@ -248,7 +249,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr return } - idx, err := i.api.Unixfs().Get(ctx, ipath.Join(resolvedPath, "index.html")) + idx, err := i.api.Unixfs().Get(r.Context(), ipath.Join(resolvedPath, "index.html")) switch err.(type) { case nil: dirwithoutslash := urlPath[len(urlPath)-1] != '/' @@ -377,8 +378,8 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam http.ServeContent(w, req, name, modtime, content) } -func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { - p, err := i.api.Unixfs().Add(ctx, files.NewReaderFile(r.Body)) +func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { + p, err := i.api.Unixfs().Add(r.Context(), files.NewReaderFile(r.Body)) if err != nil { internalWebError(w, err) return @@ -390,10 +391,6 @@ func (i *gatewayHandler) postHandler(ctx context.Context, w http.ResponseWriter, } func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { - // TODO(cryptix): move me to ServeHTTP and pass into all handlers - ctx, cancel := context.WithCancel(i.node.Context()) - defer cancel() - rootPath, err := path.ParsePath(r.URL.Path) if err != nil { webError(w, "putHandler: IPFS path not valid", err, http.StatusBadRequest) @@ -424,7 +421,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { } var newcid cid.Cid - rnode, err := resolve.Resolve(ctx, i.node.Namesys, i.node.Resolver, rootPath) + rnode, err := resolve.Resolve(r.Context(), i.node.Namesys, i.node.Resolver, rootPath) switch ev := err.(type) { case resolver.ErrNoLink: // ev.Node < node where resolve failed @@ -436,7 +433,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { return } - rnode, err := i.node.DAG.Get(ctx, c) + rnode, err := i.node.DAG.Get(r.Context(), c) if err != nil { webError(w, "putHandler: Could not create DAG from request", err, http.StatusInternalServerError) return @@ -449,13 +446,13 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { } e := dagutils.NewDagEditor(pbnd, i.node.DAG) - err = e.InsertNodeAtPath(ctx, newPath, newnode, ft.EmptyDirNode) + err = e.InsertNodeAtPath(r.Context(), newPath, newnode, ft.EmptyDirNode) if err != nil { webError(w, "putHandler: InsertNodeAtPath failed", err, http.StatusInternalServerError) return } - nnode, err := e.Finalize(ctx, i.node.DAG) + nnode, err := e.Finalize(r.Context(), i.node.DAG) if err != nil { webError(w, "putHandler: could not get node", err, http.StatusInternalServerError) return @@ -480,7 +477,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { pbnd.SetData(pbnewnode.Data()) newcid = pbnd.Cid() - err = i.node.DAG.Add(ctx, pbnd) + err = i.node.DAG.Add(r.Context(), pbnd) if err != nil { nnk := newnode.Cid() webError(w, fmt.Sprintf("putHandler: Could not add newnode(%q) to root(%q)", nnk.String(), newcid.String()), err, http.StatusInternalServerError) @@ -498,8 +495,6 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { urlPath := r.URL.Path - ctx, cancel := context.WithCancel(i.node.Context()) - defer cancel() p, err := path.ParsePath(urlPath) if err != nil { @@ -513,17 +508,9 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { return } - tctx, cancel := context.WithTimeout(ctx, time.Minute) - defer cancel() - rootnd, err := i.node.Resolver.DAG.Get(tctx, c) - if err != nil { - webError(w, "Could not resolve root object", err, http.StatusBadRequest) - return - } - - pathNodes, err := i.node.Resolver.ResolveLinks(tctx, rootnd, components[:len(components)-1]) + pathNodes, err := i.resolvePathComponents(r.Context(), c, components) if err != nil { - webError(w, "Could not resolve parent object", err, http.StatusBadRequest) + webError(w, "Could not resolve path components", err, http.StatusBadRequest) return } @@ -542,7 +529,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { var newnode *dag.ProtoNode = pbnd for j := len(pathNodes) - 2; j >= 0; j-- { - if err := i.node.DAG.Add(ctx, newnode); err != nil { + if err := i.node.DAG.Add(r.Context(), newnode); err != nil { webError(w, "Could not add node", err, http.StatusInternalServerError) return } @@ -560,7 +547,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { } } - if err := i.node.DAG.Add(ctx, newnode); err != nil { + if err := i.node.DAG.Add(r.Context(), newnode); err != nil { webError(w, "Could not add root node", err, http.StatusInternalServerError) return } @@ -573,6 +560,27 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, gopath.Join(ipfsPathPrefix+ncid.String(), path.Join(components[:len(components)-1])), http.StatusCreated) } +func (i *gatewayHandler) resolvePathComponents( + ctx context.Context, + c cid.Cid, + components []string, +) ([]ipld.Node, error) { + tctx, cancel := context.WithTimeout(ctx, time.Minute) + defer cancel() + + rootnd, err := i.node.Resolver.DAG.Get(tctx, c) + if err != nil { + return nil, fmt.Errorf("Could not resolve root object: %s", err) + } + + pathNodes, err := i.node.Resolver.ResolveLinks(tctx, rootnd, components[:len(components)-1]) + if err != nil { + return nil, fmt.Errorf("Could not resolve parent object: %s", err) + } + + return pathNodes, nil +} + func (i *gatewayHandler) addUserHeaders(w http.ResponseWriter) { for k, v := range i.config.Headers { w.Header()[k] = v From 38d2c189e6bec1adb93fdbf4c9a50c29134b2f57 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 10 May 2019 23:53:44 -0700 Subject: [PATCH 465/674] chore: fix linter nits License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@4924b80e1007ba8a39d02df7bc6a1b914a367185 --- gateway/core/corehttp/commands.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 5ddfb9d80..a198ea11b 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -61,10 +61,8 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { if acam := nc.API.HTTPHeaders[cmdsHttp.ACAMethods]; acam != nil { c.SetAllowedMethods(acam...) } - if acac := nc.API.HTTPHeaders[cmdsHttp.ACACredentials]; acac != nil { - for _, v := range acac { - c.SetAllowCredentials(strings.ToLower(v) == "true") - } + for _, v := range nc.API.HTTPHeaders[cmdsHttp.ACACredentials] { + c.SetAllowCredentials(strings.ToLower(v) == "true") } c.Headers = make(map[string][]string, len(nc.API.HTTPHeaders)+1) From 91b894d57a8678bbafcb995a02016eeca61397f9 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 24 May 2019 19:33:59 -0700 Subject: [PATCH 466/674] fix: use http.Error for sending errors This sets a few headers that prevent browsers from misinterpreting the error text. This commit was moved from ipfs/kubo@23d35184c34251fdf388aca4aa12a924f5cab760 --- gateway/core/corehttp/gateway_handler.go | 11 +++++------ gateway/core/corehttp/mutex_profile.go | 10 ++++------ gateway/core/corehttp/proxy.go | 4 +--- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 50ee377f8..d3cca5d3d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -102,14 +102,15 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } errmsg := "Method " + r.Method + " not allowed: " + var status int if !i.config.Writable { - w.WriteHeader(http.StatusMethodNotAllowed) + status = http.StatusMethodNotAllowed errmsg = errmsg + "read only access" } else { - w.WriteHeader(http.StatusBadRequest) + status = http.StatusBadRequest errmsg = errmsg + "bad request for " + r.URL.Path } - fmt.Fprint(w, errmsg) + http.Error(w, errmsg, status) } func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request) { @@ -600,9 +601,7 @@ func webError(w http.ResponseWriter, message string, err error, defaultCode int) } func webErrorWithCode(w http.ResponseWriter, message string, err error, code int) { - w.WriteHeader(code) - - fmt.Fprintf(w, "%s: %s\n", message, err) + http.Error(w, fmt.Sprintf("%s: %s", message, err), code) if code >= 500 { log.Warningf("server error: %s: %s", err) } diff --git a/gateway/core/corehttp/mutex_profile.go b/gateway/core/corehttp/mutex_profile.go index f8d66e5ef..fbb23340d 100644 --- a/gateway/core/corehttp/mutex_profile.go +++ b/gateway/core/corehttp/mutex_profile.go @@ -15,25 +15,23 @@ func MutexFractionOption(path string) ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { - w.WriteHeader(http.StatusMethodNotAllowed) + http.Error(w, "only POST allowed", http.StatusMethodNotAllowed) return } if err := r.ParseForm(); err != nil { - w.WriteHeader(http.StatusBadRequest) - _, _ = w.Write([]byte(err.Error())) + http.Error(w, err.Error(), http.StatusBadRequest) return } asfr := r.Form.Get("fraction") if len(asfr) == 0 { - w.WriteHeader(http.StatusBadRequest) + http.Error(w, "parameter 'fraction' must be set", http.StatusBadRequest) return } fr, err := strconv.Atoi(asfr) if err != nil { - w.WriteHeader(http.StatusBadRequest) - _, _ = w.Write([]byte(err.Error())) + http.Error(w, err.Error(), http.StatusBadRequest) return } log.Infof("Setting MutexProfileFraction to %d", fr) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index b0579cb93..02255d255 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -73,7 +73,5 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { } func handleError(w http.ResponseWriter, msg string, err error, code int) { - w.WriteHeader(code) - fmt.Fprintf(w, "%s: %s\n", msg, err) - log.Warningf("http proxy error: %s: %s", err) + http.Error(w, fmt.Sprintf("%s: %s", msg, err), code) } From 41850b12a653adb292b864284e1194015c3dfe4c Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 31 May 2019 16:51:08 +0100 Subject: [PATCH 467/674] feat: update Web UI to v2.4.6 This commit was moved from ipfs/kubo@5cd15049ad7783ad03e00ea3b1064b7136f20b60 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 0df21d5f5..665e5c240 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmfQkD8pBSBCBxWEwFSu4XaDVSWK6bjnNuaWZjMyQbyDub" +const WebUIPath = "/ipfs/QmQNHd1suZTktPRhP7DD4nKWG46ZRSxkwHocycHVrK3dYW" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/QmfQkD8pBSBCBxWEwFSu4XaDVSWK6bjnNuaWZjMyQbyDub", "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ", "/ipfs/QmenEBWcAk3tN94fSKpKFtUMwty1qNwSYw3DMDFV6cPBXA", "/ipfs/QmUnXcWZC5Ve21gUseouJsH5mLAyz5JPp8aHsg8qVUUK8e", From a759dbb90e8d74725601a5b69fbfed8a06c39616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Tue, 28 May 2019 17:21:57 +0100 Subject: [PATCH 468/674] migrate to go-libp2p-core. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #6391 License: MIT Signed-off-by: Raúl Kripalani This commit was moved from ipfs/kubo@e8c2852179b03a95c8d198895b246b1e3ffaeed8 --- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/metrics_test.go | 2 +- gateway/core/corehttp/proxy.go | 2 +- gateway/core/corehttp/proxy_test.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d3cca5d3d..3f212d918 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -28,7 +28,7 @@ import ( "github.com/ipfs/go-unixfs/importer" coreiface "github.com/ipfs/interface-go-ipfs-core" ipath "github.com/ipfs/interface-go-ipfs-core/path" - routing "github.com/libp2p/go-libp2p-routing" + routing "github.com/libp2p/go-libp2p-core/routing" "github.com/multiformats/go-multibase" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 3578f33ad..0e08ea2ff 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -24,7 +24,7 @@ import ( iface "github.com/ipfs/interface-go-ipfs-core" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" ipath "github.com/ipfs/interface-go-ipfs-core/path" - ci "github.com/libp2p/go-libp2p-crypto" + ci "github.com/libp2p/go-libp2p-core/crypto" id "github.com/libp2p/go-libp2p/p2p/protocol/identify" ) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 49270a71a..847d681a5 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,7 +7,7 @@ import ( core "github.com/ipfs/go-ipfs/core" - inet "github.com/libp2p/go-libp2p-net" + inet "github.com/libp2p/go-libp2p-core/network" swarmt "github.com/libp2p/go-libp2p-swarm/testing" bhost "github.com/libp2p/go-libp2p/p2p/host/basic" ) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 02255d255..64d796cba 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -11,7 +11,7 @@ import ( core "github.com/ipfs/go-ipfs/core" p2phttp "github.com/hsanjuan/go-libp2p-http" - protocol "github.com/libp2p/go-libp2p-protocol" + protocol "github.com/libp2p/go-libp2p-core/protocol" ) // ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer diff --git a/gateway/core/corehttp/proxy_test.go b/gateway/core/corehttp/proxy_test.go index 966f12c37..98d749e0c 100644 --- a/gateway/core/corehttp/proxy_test.go +++ b/gateway/core/corehttp/proxy_test.go @@ -7,7 +7,7 @@ import ( "github.com/ipfs/go-ipfs/thirdparty/assert" - protocol "github.com/libp2p/go-libp2p-protocol" + protocol "github.com/libp2p/go-libp2p-core/protocol" ) type TestCase struct { From 7838129f3d9e143d099f60c20e3e40083e4b5976 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Tue, 4 Jun 2019 16:48:25 -0700 Subject: [PATCH 469/674] add unixfs get metric License: MIT Signed-off-by: whyrusleeping This commit was moved from ipfs/kubo@846b6b5d9523ba2a859370b48fa8bb20d918d08b --- gateway/core/corehttp/gateway_handler.go | 2 ++ gateway/core/corehttp/metrics.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 3f212d918..91bfb1978 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -123,6 +123,7 @@ func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request) } func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) { + begin := time.Now() urlPath := r.URL.Path escapedURLPath := r.URL.EscapedPath() @@ -172,6 +173,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request webError(w, "ipfs cat "+escapedURLPath, err, http.StatusNotFound) return } + unixfsGetMetric.Observe(time.Since(begin).Seconds()) defer dr.Close() diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 3f8c68ccd..92b5a3a82 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -97,6 +97,9 @@ var ( peersTotalMetric = prometheus.NewDesc( prometheus.BuildFQName("ipfs", "p2p", "peers_total"), "Number of connected peers", []string{"transport"}, nil) + unixfsGetMetric = prometheus.NewSummary(prometheus.SummaryOpts{ + Name: "unixfsGet", + }) ) type IpfsNodeCollector struct { From 9d0eeee84311e35af02d0378ce7bbe0eb7dadb24 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 4 Jun 2019 17:19:48 -0700 Subject: [PATCH 470/674] gateway: expand get metric metadata This commit was moved from ipfs/kubo@ebd89b4011c300601f7b1cfcda01ee51221b748b --- gateway/core/corehttp/metrics.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 92b5a3a82..7a7f30dd9 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -97,8 +97,12 @@ var ( peersTotalMetric = prometheus.NewDesc( prometheus.BuildFQName("ipfs", "p2p", "peers_total"), "Number of connected peers", []string{"transport"}, nil) + unixfsGetMetric = prometheus.NewSummary(prometheus.SummaryOpts{ - Name: "unixfsGet", + Namespace: "ipfs", + Subsystem: "http", + Name: "unixfs_get_latency_seconds", + Help: "The time till the first block is received when 'getting' a file from the gateway.", }) ) From fc15b8867d899129ab49be295d6f4cab0d87b7d1 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 4 Jun 2019 17:34:53 -0700 Subject: [PATCH 471/674] gateway: label get requests latency with the path namespace This commit was moved from ipfs/kubo@d460150f4382b6439bd13c886d725b382ef6542f --- gateway/core/corehttp/gateway_handler.go | 3 ++- gateway/core/corehttp/metrics.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 91bfb1978..1aa343a55 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -173,7 +173,8 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request webError(w, "ipfs cat "+escapedURLPath, err, http.StatusNotFound) return } - unixfsGetMetric.Observe(time.Since(begin).Seconds()) + + unixfsGetMetric.WithLabelValues(parsedPath.Namespace()).Observe(time.Since(begin).Seconds()) defer dr.Close() diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 7a7f30dd9..b0aebd397 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -98,12 +98,12 @@ var ( prometheus.BuildFQName("ipfs", "p2p", "peers_total"), "Number of connected peers", []string{"transport"}, nil) - unixfsGetMetric = prometheus.NewSummary(prometheus.SummaryOpts{ + unixfsGetMetric = prometheus.NewSummaryVec(prometheus.SummaryOpts{ Namespace: "ipfs", Subsystem: "http", Name: "unixfs_get_latency_seconds", Help: "The time till the first block is received when 'getting' a file from the gateway.", - }) + }, []string{"namespace"}) ) type IpfsNodeCollector struct { From 94fd5ab99acf5331ea54009caaf4b8280d0c8b14 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Sat, 8 Jun 2019 00:51:18 +0200 Subject: [PATCH 472/674] Deps: update go-libp2p-http to its new libp2p location License: MIT Signed-off-by: Hector Sanjuan This commit was moved from ipfs/kubo@98a508fdd177866a03bca494524b3a3772a27755 --- gateway/core/corehttp/proxy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/proxy.go index 64d796cba..17cb00528 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/proxy.go @@ -10,8 +10,8 @@ import ( core "github.com/ipfs/go-ipfs/core" - p2phttp "github.com/hsanjuan/go-libp2p-http" protocol "github.com/libp2p/go-libp2p-core/protocol" + p2phttp "github.com/libp2p/go-libp2p-http" ) // ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer From 226bd65a0238bcdfe14ef0fb5fed8f413d08d2b3 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 25 Jul 2019 17:30:35 -0700 Subject: [PATCH 473/674] fix and improve the writable gateway 1. Fix handling of PUT. The simple implementation was the correct implementation, I have no idea what was going on here. 2. Use MFS everywhere to reduce code duplication and add support for sharded directories. 3. _Correctly_ block IPNS. 4. Remove the dependency on `core.IpfsNode`. 5. Remove support for putting empty directories with a well-known CID. It was useless as directories are automatically created. This commit was moved from ipfs/kubo@521a29956b35ceeba775d6f699edc02c29c1857e --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 281 +++++++++++------------ 2 files changed, 130 insertions(+), 153 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index d3600bb73..24d26739b 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -87,7 +87,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { "X-Stream-Output", }, headers[ACEHeadersName]...)) - gateway := newGatewayHandler(n, GatewayConfig{ + gateway := newGatewayHandler(GatewayConfig{ Headers: headers, Writable: writable, PathPrefixes: cfg.Gateway.PathPrefixes, diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1aa343a55..384f6dc45 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -2,30 +2,23 @@ package corehttp import ( "context" - "errors" "fmt" "io" "net/http" "net/url" + "os" gopath "path" "runtime/debug" "strings" "time" - "github.com/ipfs/go-ipfs/core" - "github.com/ipfs/go-ipfs/dagutils" - "github.com/ipfs/go-ipfs/namesys/resolve" - "github.com/dustin/go-humanize" "github.com/ipfs/go-cid" - chunker "github.com/ipfs/go-ipfs-chunker" files "github.com/ipfs/go-ipfs-files" - ipld "github.com/ipfs/go-ipld-format" dag "github.com/ipfs/go-merkledag" + "github.com/ipfs/go-mfs" "github.com/ipfs/go-path" "github.com/ipfs/go-path/resolver" - ft "github.com/ipfs/go-unixfs" - "github.com/ipfs/go-unixfs/importer" coreiface "github.com/ipfs/interface-go-ipfs-core" ipath "github.com/ipfs/interface-go-ipfs-core/path" routing "github.com/libp2p/go-libp2p-core/routing" @@ -40,27 +33,36 @@ const ( // gatewayHandler is a HTTP handler that serves IPFS objects (accessible by default at /ipfs/) // (it serves requests like GET /ipfs/QmVRzPKPzNtSrEzBFm2UZfxmPAgnaLke4DMcerbsGGSaFe/link) type gatewayHandler struct { - node *core.IpfsNode config GatewayConfig api coreiface.CoreAPI } -func newGatewayHandler(n *core.IpfsNode, c GatewayConfig, api coreiface.CoreAPI) *gatewayHandler { +func newGatewayHandler(c GatewayConfig, api coreiface.CoreAPI) *gatewayHandler { i := &gatewayHandler{ - node: n, config: c, api: api, } return i } -// TODO(cryptix): find these helpers somewhere else -func (i *gatewayHandler) newDagFromReader(r io.Reader) (ipld.Node, error) { - // TODO(cryptix): change and remove this helper once PR1136 is merged - // return ufs.AddFromReader(i.node, r.Body) - return importer.BuildDagFromReader( - i.node.DAG, - chunker.DefaultSplitter(r)) +func parseIpfsPath(p string) (cid.Cid, string, error) { + rootPath, err := path.ParsePath(p) + if err != nil { + return cid.Cid{}, "", err + } + + // Check the path. + rsegs := rootPath.Segments() + if rsegs[0] != "ipfs" { + return cid.Cid{}, "", fmt.Errorf("WritableGateway: only ipfs paths supported") + } + + rootCid, err := cid.Decode(rsegs[1]) + if err != nil { + return cid.Cid{}, "", err + } + + return rootCid, path.Join(rsegs[2:]), nil } func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { @@ -160,10 +162,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // Resolve path to the final DAG node for the ETag resolvedPath, err := i.api.ResolvePath(r.Context(), parsedPath) - if err == coreiface.ErrOffline && !i.node.IsOnline { + switch err { + case nil: + case coreiface.ErrOffline: webError(w, "ipfs resolve -r "+escapedURLPath, err, http.StatusServiceUnavailable) return - } else if err != nil { + default: webError(w, "ipfs resolve -r "+escapedURLPath, err, http.StatusNotFound) return } @@ -395,102 +399,91 @@ func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { } func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { - rootPath, err := path.ParsePath(r.URL.Path) + ctx := r.Context() + ds := i.api.Dag() + + // Parse the path + rootCid, newPath, err := parseIpfsPath(r.URL.Path) if err != nil { - webError(w, "putHandler: IPFS path not valid", err, http.StatusBadRequest) + webError(w, "WritableGateway: failed to parse the path", err, http.StatusBadRequest) return } - - rsegs := rootPath.Segments() - if rsegs[0] == ipnsPathPrefix { - webError(w, "putHandler: updating named entries not supported", errors.New("WritableGateway: ipns put not supported"), http.StatusBadRequest) + if newPath == "" || newPath == "/" { + http.Error(w, "WritableGateway: empty path", http.StatusBadRequest) return } + newDirectory, newFileName := gopath.Split(newPath) - var newnode ipld.Node - if rsegs[len(rsegs)-1] == "QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" { - newnode = ft.EmptyDirNode() - } else { - putNode, err := i.newDagFromReader(r.Body) - if err != nil { - webError(w, "putHandler: Could not create DAG from request", err, http.StatusInternalServerError) - return - } - newnode = putNode - } + // Resolve the old root. - var newPath string - if len(rsegs) > 1 { - newPath = path.Join(rsegs[2:]) + rnode, err := ds.Get(ctx, rootCid) + if err != nil { + webError(w, "WritableGateway: Could not create DAG from request", err, http.StatusInternalServerError) + return } - var newcid cid.Cid - rnode, err := resolve.Resolve(r.Context(), i.node.Namesys, i.node.Resolver, rootPath) - switch ev := err.(type) { - case resolver.ErrNoLink: - // ev.Node < node where resolve failed - // ev.Name < new link - // but we need to patch from the root - c, err := cid.Decode(rsegs[1]) - if err != nil { - webError(w, "putHandler: bad input path", err, http.StatusBadRequest) - return - } - - rnode, err := i.node.DAG.Get(r.Context(), c) - if err != nil { - webError(w, "putHandler: Could not create DAG from request", err, http.StatusInternalServerError) - return - } - - pbnd, ok := rnode.(*dag.ProtoNode) - if !ok { - webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) - return - } - - e := dagutils.NewDagEditor(pbnd, i.node.DAG) - err = e.InsertNodeAtPath(r.Context(), newPath, newnode, ft.EmptyDirNode) - if err != nil { - webError(w, "putHandler: InsertNodeAtPath failed", err, http.StatusInternalServerError) - return - } - - nnode, err := e.Finalize(r.Context(), i.node.DAG) - if err != nil { - webError(w, "putHandler: could not get node", err, http.StatusInternalServerError) - return - } + pbnd, ok := rnode.(*dag.ProtoNode) + if !ok { + webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) + return + } - newcid = nnode.Cid() + // Create the new file. + newFilePath, err := i.api.Unixfs().Add(ctx, files.NewReaderFile(r.Body)) + if err != nil { + webError(w, "WritableGateway: could not create DAG from request", err, http.StatusInternalServerError) + return + } - case nil: - pbnd, ok := rnode.(*dag.ProtoNode) - if !ok { - webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) - return - } + newFile, err := ds.Get(ctx, newFilePath.Cid()) + if err != nil { + webError(w, "WritableGateway: failed to resolve new file", err, http.StatusInternalServerError) + return + } - pbnewnode, ok := newnode.(*dag.ProtoNode) - if !ok { - webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) - return - } + // Patch the new file into the old root. - // object set-data case - pbnd.SetData(pbnewnode.Data()) + root, err := mfs.NewRoot(ctx, ds, pbnd, nil) + if err != nil { + webError(w, "WritableGateway: failed to create MFS root", err, http.StatusBadRequest) + return + } - newcid = pbnd.Cid() - err = i.node.DAG.Add(r.Context(), pbnd) + if newDirectory != "" { + err := mfs.Mkdir(root, newDirectory, mfs.MkdirOpts{Mkparents: true, Flush: false}) if err != nil { - nnk := newnode.Cid() - webError(w, fmt.Sprintf("putHandler: Could not add newnode(%q) to root(%q)", nnk.String(), newcid.String()), err, http.StatusInternalServerError) + webError(w, "WritableGateway: failed to create MFS directory", err, http.StatusInternalServerError) return } + } + dirNode, err := mfs.Lookup(root, newDirectory) + if err != nil { + webError(w, "WritableGateway: failed to lookup directory", err, http.StatusInternalServerError) + return + } + dir, ok := dirNode.(*mfs.Directory) + if !ok { + http.Error(w, "WritableGateway: target directory is not a directory", http.StatusBadRequest) + return + } + err = dir.Unlink(newFileName) + switch err { + case os.ErrNotExist, nil: default: - webError(w, "could not resolve root DAG", ev, http.StatusInternalServerError) + webError(w, "WritableGateway: failed to replace existing file", err, http.StatusBadRequest) return } + err = dir.AddChild(newFileName, newFile) + if err != nil { + webError(w, "WritableGateway: failed to link file into directory", err, http.StatusInternalServerError) + return + } + nnode, err := root.GetDirectory().GetNode() + if err != nil { + webError(w, "WritableGateway: failed to finalize", err, http.StatusInternalServerError) + return + } + newcid := nnode.Cid() i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("IPFS-Hash", newcid.String()) @@ -498,91 +491,75 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { } func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { - urlPath := r.URL.Path + ctx := r.Context() + + // parse the path - p, err := path.ParsePath(urlPath) + rootCid, newPath, err := parseIpfsPath(r.URL.Path) if err != nil { - webError(w, "failed to parse path", err, http.StatusBadRequest) + webError(w, "WritableGateway: failed to parse the path", err, http.StatusBadRequest) return } - - c, components, err := path.SplitAbsPath(p) - if err != nil { - webError(w, "Could not split path", err, http.StatusInternalServerError) + if newPath == "" || newPath == "/" { + http.Error(w, "WritableGateway: empty path", http.StatusBadRequest) return } + directory, filename := gopath.Split(newPath) + + // lookup the root - pathNodes, err := i.resolvePathComponents(r.Context(), c, components) + rootNodeIPLD, err := i.api.Dag().Get(ctx, rootCid) if err != nil { - webError(w, "Could not resolve path components", err, http.StatusBadRequest) + webError(w, "WritableGateway: failed to resolve root CID", err, http.StatusInternalServerError) return } - - pbnd, ok := pathNodes[len(pathNodes)-1].(*dag.ProtoNode) + rootNode, ok := rootNodeIPLD.(*dag.ProtoNode) if !ok { - webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) + http.Error(w, "WritableGateway: empty path", http.StatusInternalServerError) return } - // TODO(cyrptix): assumes len(pathNodes) > 1 - not found is an error above? - err = pbnd.RemoveNodeLink(components[len(components)-1]) + // construct the mfs root + + root, err := mfs.NewRoot(ctx, i.api.Dag(), rootNode, nil) if err != nil { - webError(w, "Could not delete link", err, http.StatusBadRequest) + webError(w, "WritableGateway: failed to construct the MFS root", err, http.StatusBadRequest) return } - var newnode *dag.ProtoNode = pbnd - for j := len(pathNodes) - 2; j >= 0; j-- { - if err := i.node.DAG.Add(r.Context(), newnode); err != nil { - webError(w, "Could not add node", err, http.StatusInternalServerError) - return - } + // lookup the parent directory - pathpb, ok := pathNodes[j].(*dag.ProtoNode) - if !ok { - webError(w, "Cannot read non protobuf nodes through gateway", dag.ErrNotProtobuf, http.StatusBadRequest) - return - } - - newnode, err = pathpb.UpdateNodeLink(components[j], newnode) - if err != nil { - webError(w, "Could not update node links", err, http.StatusInternalServerError) - return - } + parentNode, err := mfs.Lookup(root, directory) + if err != nil { + webError(w, "WritableGateway: failed to look up parent", err, http.StatusInternalServerError) + return } - if err := i.node.DAG.Add(r.Context(), newnode); err != nil { - webError(w, "Could not add root node", err, http.StatusInternalServerError) + parent, ok := parentNode.(*mfs.Directory) + if !ok { + http.Error(w, "WritableGateway: parent is not a directory", http.StatusInternalServerError) return } - // Redirect to new path - ncid := newnode.Cid() + // delete the file - i.addUserHeaders(w) // ok, _now_ write user's headers. - w.Header().Set("IPFS-Hash", ncid.String()) - http.Redirect(w, r, gopath.Join(ipfsPathPrefix+ncid.String(), path.Join(components[:len(components)-1])), http.StatusCreated) -} - -func (i *gatewayHandler) resolvePathComponents( - ctx context.Context, - c cid.Cid, - components []string, -) ([]ipld.Node, error) { - tctx, cancel := context.WithTimeout(ctx, time.Minute) - defer cancel() - - rootnd, err := i.node.Resolver.DAG.Get(tctx, c) - if err != nil { - return nil, fmt.Errorf("Could not resolve root object: %s", err) + switch parent.Unlink(filename) { + case nil, os.ErrNotExist: + default: + webError(w, "WritableGateway: failed to remove file", err, http.StatusInternalServerError) + return } - pathNodes, err := i.node.Resolver.ResolveLinks(tctx, rootnd, components[:len(components)-1]) + nnode, err := root.GetDirectory().GetNode() if err != nil { - return nil, fmt.Errorf("Could not resolve parent object: %s", err) + webError(w, "WritableGateway: failed to finalize", err, http.StatusInternalServerError) } + ncid := nnode.Cid() - return pathNodes, nil + i.addUserHeaders(w) // ok, _now_ write user's headers. + w.Header().Set("IPFS-Hash", ncid.String()) + // note: StatusCreated is technically correct here as we created a new resource. + http.Redirect(w, r, gopath.Join(ipfsPathPrefix+ncid.String(), directory), http.StatusCreated) } func (i *gatewayHandler) addUserHeaders(w http.ResponseWriter) { From 7a1e19615fd4a6d79b510a0f01840a2942aa63d9 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 13 Aug 2019 15:20:13 +0100 Subject: [PATCH 474/674] feat: web ui 2.5.0 This commit was moved from ipfs/kubo@b0f496e79f1e6ce28181e0a4a4a08099d5482c63 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 665e5c240..39b3fad2c 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmQNHd1suZTktPRhP7DD4nKWG46ZRSxkwHocycHVrK3dYW" +const WebUIPath = "/ipfs/QmNyMYhwJUS1cVvaWoVBhrW8KPj1qmie7rZcWo8f1Bvkhz" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -23,6 +23,7 @@ var WebUIPaths = []string{ "/ipfs/QmRyWyKWmphamkMRnJVjUTzSFSAAZowYP4rnbgnfMXC9Mr", "/ipfs/QmU3o9bvfenhTKhxUakbYrLDnZU7HezAVxPM6Ehjw9Xjqy", "/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ", + "/ipfs/QmQNHd1suZTktPRhP7DD4nKWG46ZRSxkwHocycHVrK3dYW", } var WebUIOption = RedirectOption("webui", WebUIPath) From e9344581f800331bcad7f0acb7cc7aaab8c1fcc9 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 6 Sep 2019 09:04:21 +0100 Subject: [PATCH 475/674] feat: web ui 2.5.1 This commit was moved from ipfs/kubo@de87c3aa45a224963398b28c2e72938ae3952416 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 39b3fad2c..89d9c156c 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmNyMYhwJUS1cVvaWoVBhrW8KPj1qmie7rZcWo8f1Bvkhz" +const WebUIPath = "/ipfs/QmVTiRTQ72qiH4usAGT4c6qVxCMv4hFMUH9fvU6mktaXdP" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -24,6 +24,7 @@ var WebUIPaths = []string{ "/ipfs/QmU3o9bvfenhTKhxUakbYrLDnZU7HezAVxPM6Ehjw9Xjqy", "/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ", "/ipfs/QmQNHd1suZTktPRhP7DD4nKWG46ZRSxkwHocycHVrK3dYW", + "/ipfs/QmNyMYhwJUS1cVvaWoVBhrW8KPj1qmie7rZcWo8f1Bvkhz", } var WebUIOption = RedirectOption("webui", WebUIPath) From 2928ae9db099fc246540a542ce8cf04b1f8cdb0d Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Thu, 12 Sep 2019 10:06:24 +0100 Subject: [PATCH 476/674] feat: webui 2.5.3 Superseeds #6635. This commit was moved from ipfs/kubo@7c6ba8f724cb730a15d19a36e91a48bc6c96853c --- gateway/core/corehttp/webui.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 89d9c156c..e91230c93 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmVTiRTQ72qiH4usAGT4c6qVxCMv4hFMUH9fvU6mktaXdP" +const WebUIPath = "/ipfs/QmUtMmxgHnDvQq4bpH6Y9MaLN1hpfjJz5LZcq941BEqEXs" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -25,6 +25,8 @@ var WebUIPaths = []string{ "/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ", "/ipfs/QmQNHd1suZTktPRhP7DD4nKWG46ZRSxkwHocycHVrK3dYW", "/ipfs/QmNyMYhwJUS1cVvaWoVBhrW8KPj1qmie7rZcWo8f1Bvkhz", + "/ipfs/QmVTiRTQ72qiH4usAGT4c6qVxCMv4hFMUH9fvU6mktaXdP", + "/ipfs/QmYcP4sp1nraBiCYi6i9kqdaKobrK32yyMpTrM5JDA8a2C", } var WebUIOption = RedirectOption("webui", WebUIPath) From 8fd5fabe65886f66da3c17c7a2e1f63b89c7975f Mon Sep 17 00:00:00 2001 From: Adrian Lanzafame Date: Sun, 15 Sep 2019 11:07:51 +1000 Subject: [PATCH 477/674] ipfs namespace is now being provided to prometheus This commit was moved from ipfs/kubo@03017cb2014827bde3807cf97054f64f82e955dc --- gateway/core/corehttp/metrics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index b0aebd397..54080b451 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -24,6 +24,7 @@ func MetricsCollectionOption(handlerName string) ServeOption { // Adapted from github.com/prometheus/client_golang/prometheus/http.go // Work around https://github.com/prometheus/client_golang/pull/311 opts := prometheus.SummaryOpts{ + Namespace: "ipfs", Subsystem: "http", ConstLabels: prometheus.Labels{"handler": handlerName}, Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, @@ -31,7 +32,6 @@ func MetricsCollectionOption(handlerName string) ServeOption { reqCnt := prometheus.NewCounterVec( prometheus.CounterOpts{ - Namespace: opts.Namespace, Subsystem: opts.Subsystem, Name: "requests_total", Help: "Total number of HTTP requests made.", From 2b8a4fe0ffeffcf9e4e24785a2cd404a3c995b63 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 23 Sep 2019 15:44:21 +0100 Subject: [PATCH 478/674] feat: web ui 2.5.4 This commit was moved from ipfs/kubo@36acc402aaeaddd5ff9c66b493dd5070242497c6 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index e91230c93..3cbfad285 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmUtMmxgHnDvQq4bpH6Y9MaLN1hpfjJz5LZcq941BEqEXs" +const WebUIPath = "/ipfs/QmPURAjo3oneGH53ovt68UZEBvsc8nNmEhQZEpsVEQUMZE" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -27,6 +27,7 @@ var WebUIPaths = []string{ "/ipfs/QmNyMYhwJUS1cVvaWoVBhrW8KPj1qmie7rZcWo8f1Bvkhz", "/ipfs/QmVTiRTQ72qiH4usAGT4c6qVxCMv4hFMUH9fvU6mktaXdP", "/ipfs/QmYcP4sp1nraBiCYi6i9kqdaKobrK32yyMpTrM5JDA8a2C", + "/ipfs/QmUtMmxgHnDvQq4bpH6Y9MaLN1hpfjJz5LZcq941BEqEXs", } var WebUIOption = RedirectOption("webui", WebUIPath) From 21056aa5abff08cb340bb39804dda6ac4ac6336c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 26 Sep 2019 15:38:12 -0700 Subject: [PATCH 479/674] chore: fix deprecation warnings This commit was moved from ipfs/kubo@853ed0be5d317ae72086a646dbf0d5116107fb28 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 24d26739b..e294cd308 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -104,7 +104,7 @@ func VersionOption() ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Commit: %s\n", version.CurrentCommit) - fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion) + fmt.Fprintf(w, "Client Version: %s\n", version.UserAgent) fmt.Fprintf(w, "Protocol Version: %s\n", id.LibP2PVersion) }) return mux, nil diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 0e08ea2ff..c37f9082e 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -608,7 +608,7 @@ func TestVersion(t *testing.T) { t.Fatalf("response doesn't contain commit:\n%s", s) } - if !strings.Contains(s, "Client Version: "+id.ClientVersion) { + if !strings.Contains(s, "Client Version: "+version.UserAgent) { t.Fatalf("response doesn't contain client version:\n%s", s) } From 58b1f6a7db43a6f96e28b72445e0cd8665869f4e Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 8 Oct 2019 08:33:58 +0100 Subject: [PATCH 480/674] feat: web ui 2.5.7 Relevant release notes can be found on [v2.5.5](https://github.com/ipfs-shipyard/ipfs-webui/releases/tag/v2.5.5). This commit was moved from ipfs/kubo@bb59c24947e8b43d77e35c0d78466124e69aec71 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 3cbfad285..debca29ca 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmPURAjo3oneGH53ovt68UZEBvsc8nNmEhQZEpsVEQUMZE" +const WebUIPath = "/ipfs/QmeSXt32frzhvewLKwA1dePTSjkTfGVwTh55ZcsJxrCSnk" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -28,6 +28,7 @@ var WebUIPaths = []string{ "/ipfs/QmVTiRTQ72qiH4usAGT4c6qVxCMv4hFMUH9fvU6mktaXdP", "/ipfs/QmYcP4sp1nraBiCYi6i9kqdaKobrK32yyMpTrM5JDA8a2C", "/ipfs/QmUtMmxgHnDvQq4bpH6Y9MaLN1hpfjJz5LZcq941BEqEXs", + "/ipfs/QmPURAjo3oneGH53ovt68UZEBvsc8nNmEhQZEpsVEQUMZE", } var WebUIOption = RedirectOption("webui", WebUIPath) From 500266b085f2b8c72bd3865fcd532c160784877c Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 21 Oct 2019 08:31:33 +0100 Subject: [PATCH 481/674] feat: web ui 2.5.8 This commit was moved from ipfs/kubo@a1854101c0a37137abbad5b9ebd827f5bf51542c --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index debca29ca..5454aebb4 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmeSXt32frzhvewLKwA1dePTSjkTfGVwTh55ZcsJxrCSnk" +const webUIPath = "/ipfs/QmcjeTciMNgEBe4xXvEaA4TQtwTRkXucx7DmKWViXSmX7m" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -29,6 +29,7 @@ var WebUIPaths = []string{ "/ipfs/QmYcP4sp1nraBiCYi6i9kqdaKobrK32yyMpTrM5JDA8a2C", "/ipfs/QmUtMmxgHnDvQq4bpH6Y9MaLN1hpfjJz5LZcq941BEqEXs", "/ipfs/QmPURAjo3oneGH53ovt68UZEBvsc8nNmEhQZEpsVEQUMZE", + "/ipfs/QmeSXt32frzhvewLKwA1dePTSjkTfGVwTh55ZcsJxrCSnk", } var WebUIOption = RedirectOption("webui", WebUIPath) From 38de0a1f5772b8b9a74100e61c4b7d8a3113948f Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 21 Oct 2019 20:24:15 +0100 Subject: [PATCH 482/674] Update webui.go This commit was moved from ipfs/kubo@f3f3899a6892073de30a97dc3c3fd9e5d2be782d --- gateway/core/corehttp/webui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 5454aebb4..cbaef67ee 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const webUIPath = "/ipfs/QmcjeTciMNgEBe4xXvEaA4TQtwTRkXucx7DmKWViXSmX7m" +const WebUIPath = "/ipfs/QmcjeTciMNgEBe4xXvEaA4TQtwTRkXucx7DmKWViXSmX7m" // this is a list of all past webUI paths. var WebUIPaths = []string{ From d00df4f6bcd2813d5278351bae14f613538f3dbc Mon Sep 17 00:00:00 2001 From: Adrian Lanzafame Date: Wed, 23 Oct 2019 10:46:11 +1000 Subject: [PATCH 483/674] pass opts.Namespace along like before This commit was moved from ipfs/kubo@48f25d9ed7ac149a67b23c179f7c60f12484de68 --- gateway/core/corehttp/metrics.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 54080b451..1288484d3 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -32,6 +32,7 @@ func MetricsCollectionOption(handlerName string) ServeOption { reqCnt := prometheus.NewCounterVec( prometheus.CounterOpts{ + Namespace: opts.Namespace, Subsystem: opts.Subsystem, Name: "requests_total", Help: "Total number of HTTP requests made.", From 23387494a53062ce20b29f51a0a5af38260a0fe3 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 30 Oct 2019 17:50:29 +0000 Subject: [PATCH 484/674] feat: web ui 2.6.0 See https://github.com/ipfs-shipyard/ipfs-webui/releases/tag/v2.6.0. This commit was moved from ipfs/kubo@29d6d7e3cd85e4f51b11fb87bbb6a221c4b37ae4 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index cbaef67ee..0a993cfa2 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmcjeTciMNgEBe4xXvEaA4TQtwTRkXucx7DmKWViXSmX7m" +const WebUIPath = "/ipfs/QmfNbSskgvTXYhuqP8tb9AKbCkyRcCy3WeiXwD9y5LeoqK" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -30,6 +30,7 @@ var WebUIPaths = []string{ "/ipfs/QmUtMmxgHnDvQq4bpH6Y9MaLN1hpfjJz5LZcq941BEqEXs", "/ipfs/QmPURAjo3oneGH53ovt68UZEBvsc8nNmEhQZEpsVEQUMZE", "/ipfs/QmeSXt32frzhvewLKwA1dePTSjkTfGVwTh55ZcsJxrCSnk", + "/ipfs/QmcjeTciMNgEBe4xXvEaA4TQtwTRkXucx7DmKWViXSmX7m", } var WebUIOption = RedirectOption("webui", WebUIPath) From 53ec4bb001a2596229238af72d266449239d6fd1 Mon Sep 17 00:00:00 2001 From: Djalil Dreamski <32184973+dreamski21@users.noreply.github.com> Date: Sat, 2 Nov 2019 21:56:54 +0100 Subject: [PATCH 485/674] fix #2203: omit the charset attribute when Content-Type is text/html License: MIT Signed-off-by: Abdeldjalil Hebal This commit was moved from ipfs/kubo@aefff4865471471deb8afd3a7cb59875e921b936 --- gateway/core/corehttp/gateway_handler.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 384f6dc45..51f90fe8f 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -383,6 +383,12 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam } } + mime := http.DetectContentType(content) + if strings.HasPrefix(mime, "text/html;") { + mime = "text/html" + } + w.Header().Set("Content-Type", mime) + http.ServeContent(w, req, name, modtime, content) } From dc5135fdf034bde530e4dafdee760770cdc44d26 Mon Sep 17 00:00:00 2001 From: Djalil Dreamski <32184973+dreamski21@users.noreply.github.com> Date: Tue, 5 Nov 2019 17:36:26 +0100 Subject: [PATCH 486/674] Update gateway_handler.go This commit was moved from ipfs/kubo@69f81a11dd23b41a4672722ad65c485400cdb14d --- gateway/core/corehttp/gateway_handler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 51f90fe8f..540b83347 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -383,7 +383,10 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam } } - mime := http.DetectContentType(content) + buf := make([]byte, 512) + _, _ = content.Read(buf) + mime := http.DetectContentType(buf) + if strings.HasPrefix(mime, "text/html;") { mime = "text/html" } From 2e654bbe9bc3a6c96978fc23bf321268684d2e64 Mon Sep 17 00:00:00 2001 From: Djalil Dreamski <32184973+dreamski21@users.noreply.github.com> Date: Wed, 6 Nov 2019 01:52:49 +0100 Subject: [PATCH 487/674] gateway: ServeFile: use file extension to determine Content-Type License: MIT Signed-off-by: Abdeldjalil Hebal This commit was moved from ipfs/kubo@a29a9dbb98207c8c3312c5d0c0eb53abeb7eec05 --- gateway/core/corehttp/gateway_handler.go | 25 ++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 540b83347..14973b0d7 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -11,7 +11,8 @@ import ( "runtime/debug" "strings" "time" - + "mime" + "github.com/dustin/go-humanize" "github.com/ipfs/go-cid" files "github.com/ipfs/go-ipfs-files" @@ -383,15 +384,23 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam } } - buf := make([]byte, 512) - _, _ = content.Read(buf) - mime := http.DetectContentType(buf) - - if strings.HasPrefix(mime, "text/html;") { - mime = "text/html" + ctype := mime.TypeByExtension(gopath.Ext(name)) + if ctype == "" { + buf := make([]byte, 512) + n, _ := io.ReadFull(content, buf[:]) + ctype = http.DetectContentType(buf[:n]) + _, err := content.Seek(0, io.SeekStart) + if err != nil { + Error(w, "seeker can't seek", http.StatusInternalServerError) + return + } + } + if strings.HasPrefix(ctype, "text/html;") { + ctype = "text/html" } - w.Header().Set("Content-Type", mime) + w.Header().Set("Content-Type", ctype) + _, _ = content.Seek(0, io.SeekStart) http.ServeContent(w, req, name, modtime, content) } From 78a4807d098c2dbd20020706b038ee3933dea5c9 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 6 Nov 2019 11:44:32 +0000 Subject: [PATCH 488/674] chore(gateway): fix import ordering This commit was moved from ipfs/kubo@ebf2e7da361e170391c2bef1658a856358e04ffe --- gateway/core/corehttp/gateway_handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 14973b0d7..96aaf5a26 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "io" + "mime" "net/http" "net/url" "os" @@ -11,8 +12,7 @@ import ( "runtime/debug" "strings" "time" - "mime" - + "github.com/dustin/go-humanize" "github.com/ipfs/go-cid" files "github.com/ipfs/go-ipfs-files" From 5ed8dc68db4390fb408cbfee82eb8b52f8f06a65 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 6 Nov 2019 11:44:56 +0000 Subject: [PATCH 489/674] chore(gateway): fix error call This commit was moved from ipfs/kubo@a12d2e265e665021ca3a94b4b6c1a28e3293516b --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 96aaf5a26..96db4400b 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -391,7 +391,7 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam ctype = http.DetectContentType(buf[:n]) _, err := content.Seek(0, io.SeekStart) if err != nil { - Error(w, "seeker can't seek", http.StatusInternalServerError) + http.Error(w, "seeker can't seek", http.StatusInternalServerError) return } } From 984f87ad8550c765ef03c6df31e1786bd7bba3bb Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 6 Nov 2019 11:45:41 +0000 Subject: [PATCH 490/674] chore(gateway): remove redundant seek This commit was moved from ipfs/kubo@69f6e08d9de44a78fa53154aa01870e66f77002f --- gateway/core/corehttp/gateway_handler.go | 1 - 1 file changed, 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 96db4400b..07d0c59e1 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -400,7 +400,6 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam } w.Header().Set("Content-Type", ctype) - _, _ = content.Seek(0, io.SeekStart) http.ServeContent(w, req, name, modtime, content) } From 3d40d6be74b48e8f00c124277f7822dbe4c4874b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 6 Nov 2019 11:47:27 +0000 Subject: [PATCH 491/674] chore(gateway): document encoding fix This commit was moved from ipfs/kubo@7ae6f6fa3eaaa503049caa07508c44adfe33ff60 --- gateway/core/corehttp/gateway_handler.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 07d0c59e1..c67b56ad0 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -395,6 +395,10 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam return } } + // Strip the encoding from the HTML Content-Type header and let the + // browser figure it out. + // + // Fixes https://github.com/ipfs/go-ipfs/issues/2203 if strings.HasPrefix(ctype, "text/html;") { ctype = "text/html" } From 2b8c94286482744aa2b7c12ea73bbb05aedbb5b9 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 12 Nov 2019 23:37:40 +0000 Subject: [PATCH 492/674] feat: web ui 2.7.1 This commit was moved from ipfs/kubo@f4a4bacceec4a3f150c2c6425f717ebf960f0ff7 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 0a993cfa2..3e98fac16 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmfNbSskgvTXYhuqP8tb9AKbCkyRcCy3WeiXwD9y5LeoqK" +const WebUIPath = "/ipfs/QmPkojhjJkJ5LEGBDrAvdftrjAYmi9GU5Cq27mWvZTDieW" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -31,6 +31,7 @@ var WebUIPaths = []string{ "/ipfs/QmPURAjo3oneGH53ovt68UZEBvsc8nNmEhQZEpsVEQUMZE", "/ipfs/QmeSXt32frzhvewLKwA1dePTSjkTfGVwTh55ZcsJxrCSnk", "/ipfs/QmcjeTciMNgEBe4xXvEaA4TQtwTRkXucx7DmKWViXSmX7m", + "/ipfs/QmfNbSskgvTXYhuqP8tb9AKbCkyRcCy3WeiXwD9y5LeoqK", } var WebUIOption = RedirectOption("webui", WebUIPath) From 75eafd5a6f7bd8cafda5f2d8ea3744448566d16c Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 4 Dec 2019 08:15:58 +0000 Subject: [PATCH 493/674] feat: web ui 2.7.2 This commit was moved from ipfs/kubo@5ab7a70131cb69f2999e86a24a82dc451c0aa0a0 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 3e98fac16..21d3eeea6 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmPkojhjJkJ5LEGBDrAvdftrjAYmi9GU5Cq27mWvZTDieW" +const WebUIPath = "/ipfs/Qmexhq2sBHnXQbvyP2GfUdbnY7HCagH2Mw5vUNSBn2nxip" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -32,6 +32,7 @@ var WebUIPaths = []string{ "/ipfs/QmeSXt32frzhvewLKwA1dePTSjkTfGVwTh55ZcsJxrCSnk", "/ipfs/QmcjeTciMNgEBe4xXvEaA4TQtwTRkXucx7DmKWViXSmX7m", "/ipfs/QmfNbSskgvTXYhuqP8tb9AKbCkyRcCy3WeiXwD9y5LeoqK", + "/ipfs/QmPkojhjJkJ5LEGBDrAvdftrjAYmi9GU5Cq27mWvZTDieW", } var WebUIOption = RedirectOption("webui", WebUIPath) From 2e46fb71834279cb582a34b1e1cdf152039232e1 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 17 Dec 2019 02:11:35 +0100 Subject: [PATCH 494/674] fix: limit SW registration to content root Introduces hardening proposed in: https://github.com/ipfs/go-ipfs/issues/4025#issuecomment-342250616 License: MIT Signed-off-by: Marcin Rataj This commit was moved from ipfs/kubo@115b2ba6cdbf956abbf5711ea4befab25ff2555e --- gateway/core/corehttp/gateway_handler.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index c67b56ad0..e8839087a 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -9,6 +9,7 @@ import ( "net/url" "os" gopath "path" + "regexp" "runtime/debug" "strings" "time" @@ -155,6 +156,18 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request ipnsHostname = true } + // Service Worker registration request + if r.Header.Get("Service-Worker") == "script" { + // Disallow Service Worker registration on namespace roots + // https://github.com/ipfs/go-ipfs/issues/4025 + matched, _ := regexp.MatchString(`^/ip[fn]s/[^/]+$`, r.URL.Path) + if matched { + err := fmt.Errorf("registration is not allowed for this scope") + webError(w, "navigator.serviceWorker", err, http.StatusBadRequest) + return + } + } + parsedPath := ipath.New(urlPath) if err := parsedPath.IsValid(); err != nil { webError(w, "invalid ipfs path", err, http.StatusBadRequest) From ed0df14084c1fd03ce0be46354e088bf3dc58072 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 26 Sep 2019 12:25:42 -0700 Subject: [PATCH 495/674] fix(gateway): serve the index with serveFile This commit was moved from ipfs/kubo@62451039ecca70a5d6d836e822200adbf2d0dda7 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index e8839087a..2024df390 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -289,7 +289,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } // write to request - http.ServeContent(w, r, "index.html", modtime, f) + i.serveFile(w, r, "index.html", modtime, f) return case resolver.ErrNoLink: // no index.html; noop From e839abb427ebf7f8a0409b7076afce58f169f2df Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 26 Sep 2019 12:34:09 -0700 Subject: [PATCH 496/674] fix(gateway): gracefully handle files with unknown sizes in directory listings This commit was moved from ipfs/kubo@e8a6c0c050e398a5b5f896770c7e79226eea6e4d --- gateway/core/corehttp/gateway_handler.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 2024df390..f627d72c4 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -306,14 +306,14 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request var dirListing []directoryItem dirit := dir.Entries() for dirit.Next() { - // See comment above where originalUrlPath is declared. - s, err := dirit.Node().Size() - if err != nil { - internalWebError(w, err) - return + size := "?" + if s, err := dirit.Node().Size(); err == nil { + // Size may not be defined/supported. Continue anyways. + size = humanize.Bytes(uint64(s)) } - di := directoryItem{humanize.Bytes(uint64(s)), dirit.Name(), gopath.Join(originalUrlPath, dirit.Name())} + // See comment above where originalUrlPath is declared. + di := directoryItem{size, dirit.Name(), gopath.Join(originalUrlPath, dirit.Name())} dirListing = append(dirListing, di) } if dirit.Err() != nil { From f488b0d3487bacd7e5d4e3f35b93c4a4b2b6fcf4 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 26 Sep 2019 13:26:51 -0700 Subject: [PATCH 497/674] fix(gateway): better seeking/sized 1. Require files to have known sizes. We can add support for unknown sizes _later_ but we can't use ServeContent for those files. 2. Replace the `sizeReadSeeker` with a `lazySeeker`. This one makes no assumptions about how it's used so we're less likely to run into weird bugs. This commit was moved from ipfs/kubo@3859f08bf79c9a68933c9d398f834c5c32462664 --- gateway/core/corehttp/gateway_handler.go | 28 ++++------- gateway/core/corehttp/lazyseek.go | 60 ++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 19 deletions(-) create mode 100644 gateway/core/corehttp/lazyseek.go diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index f627d72c4..38f1f53b3 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -372,29 +372,19 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } } -type sizeReadSeeker interface { +type sized interface { Size() (int64, error) - - io.ReadSeeker -} - -type sizeSeeker struct { - sizeReadSeeker } -func (s *sizeSeeker) Seek(offset int64, whence int) (int64, error) { - if whence == io.SeekEnd && offset == 0 { - return s.Size() +func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, name string, modtime time.Time, file files.File) { + size, err := file.Size() + if err != nil { + http.Error(w, "cannot serve files with unknown sizes", http.StatusBadGateway) + return } - - return s.sizeReadSeeker.Seek(offset, whence) -} - -func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, name string, modtime time.Time, content io.ReadSeeker) { - if sp, ok := content.(sizeReadSeeker); ok { - content = &sizeSeeker{ - sizeReadSeeker: sp, - } + content := &lazySeeker{ + size: size, + reader: file, } ctype := mime.TypeByExtension(gopath.Ext(name)) diff --git a/gateway/core/corehttp/lazyseek.go b/gateway/core/corehttp/lazyseek.go new file mode 100644 index 000000000..4c5624bcf --- /dev/null +++ b/gateway/core/corehttp/lazyseek.go @@ -0,0 +1,60 @@ +package corehttp + +import ( + "fmt" + "io" +) + +// The HTTP server uses seek to determine the file size. Actually _seeking_ can +// be slow so we wrap the seeker in a _lazy_ seeker. +type lazySeeker struct { + reader io.ReadSeeker + + size int64 + offset int64 + realOffset int64 +} + +func (s *lazySeeker) Seek(offset int64, whence int) (int64, error) { + switch whence { + case io.SeekEnd: + return s.Seek(s.size+offset, io.SeekStart) + case io.SeekCurrent: + return s.Seek(s.offset+offset, io.SeekStart) + case io.SeekStart: + if offset < 0 { + return s.offset, fmt.Errorf("invalid seek offset") + } + s.offset = offset + return s.offset, nil + default: + return s.offset, fmt.Errorf("invalid whence: %d", whence) + } +} + +func (s *lazySeeker) Read(b []byte) (int, error) { + // If we're past the end, EOF. + if s.offset >= s.size { + return 0, io.EOF + } + + // actually seek + for s.offset != s.realOffset { + off, err := s.reader.Seek(s.offset, io.SeekStart) + if err != nil { + return 9, err + } + s.realOffset = off + } + off, err := s.reader.Read(b) + s.realOffset += int64(off) + s.offset += int64(off) + return off, err +} + +func (s *lazySeeker) Close() error { + if closer, ok := s.reader.(io.Closer); ok { + return closer.Close() + } + return nil +} From 093f27267bebb1ace6b31049d5698bd5191a76bc Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 26 Sep 2019 13:53:54 -0700 Subject: [PATCH 498/674] fix(gateway): correct symlink content type We should be _resolving_ symlinks (sometimes, still need to figure out when to do this WRT IPNS). However, that's a larger feature. This commit was moved from ipfs/kubo@1a06fb6e2f721b5443495c42d066125ef98edb6c --- gateway/core/corehttp/gateway_handler.go | 40 ++++++++++++++---------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 38f1f53b3..55128842a 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -382,28 +382,36 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam http.Error(w, "cannot serve files with unknown sizes", http.StatusBadGateway) return } + content := &lazySeeker{ size: size, reader: file, } - ctype := mime.TypeByExtension(gopath.Ext(name)) - if ctype == "" { - buf := make([]byte, 512) - n, _ := io.ReadFull(content, buf[:]) - ctype = http.DetectContentType(buf[:n]) - _, err := content.Seek(0, io.SeekStart) - if err != nil { - http.Error(w, "seeker can't seek", http.StatusInternalServerError) - return + var ctype string + if _, isSymlink := file.(*files.Symlink); isSymlink { + // We should be smarter about resolving symlinks but this is the + // "most correct" we can be without doing that. + ctype = "inode/symlink" + } else { + ctype = mime.TypeByExtension(gopath.Ext(name)) + if ctype == "" { + buf := make([]byte, 512) + n, _ := io.ReadFull(content, buf[:]) + ctype = http.DetectContentType(buf[:n]) + _, err := content.Seek(0, io.SeekStart) + if err != nil { + http.Error(w, "seeker can't seek", http.StatusInternalServerError) + return + } + } + // Strip the encoding from the HTML Content-Type header and let the + // browser figure it out. + // + // Fixes https://github.com/ipfs/go-ipfs/issues/2203 + if strings.HasPrefix(ctype, "text/html;") { + ctype = "text/html" } - } - // Strip the encoding from the HTML Content-Type header and let the - // browser figure it out. - // - // Fixes https://github.com/ipfs/go-ipfs/issues/2203 - if strings.HasPrefix(ctype, "text/html;") { - ctype = "text/html" } w.Header().Set("Content-Type", ctype) From 484378d7ad0da873bebf8e42af49abee495f5a08 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 26 Sep 2019 14:19:46 -0700 Subject: [PATCH 499/674] chore(gateway): remove dead code This commit was moved from ipfs/kubo@453b78962b790eeac117172d81385a5189716aae --- gateway/core/corehttp/gateway_handler.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 55128842a..a501e21dd 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -372,10 +372,6 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } } -type sized interface { - Size() (int64, error) -} - func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, name string, modtime time.Time, file files.File) { size, err := file.Size() if err != nil { From 5ffac66b0b5e94e5b2892b22bb8c70618dc5a3e3 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 3 Jan 2020 18:07:20 -0800 Subject: [PATCH 500/674] fix(gateway): fix seek read length typo This commit was moved from ipfs/kubo@6cb03d4dfd87770fcce330cbfe5e36126c63339a --- gateway/core/corehttp/lazyseek.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/lazyseek.go b/gateway/core/corehttp/lazyseek.go index 4c5624bcf..2a379dc91 100644 --- a/gateway/core/corehttp/lazyseek.go +++ b/gateway/core/corehttp/lazyseek.go @@ -42,7 +42,7 @@ func (s *lazySeeker) Read(b []byte) (int, error) { for s.offset != s.realOffset { off, err := s.reader.Seek(s.offset, io.SeekStart) if err != nil { - return 9, err + return 0, err } s.realOffset = off } From 1fb1df9d3807d9dfdfc564dd12fdd0726ca1f5cb Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 3 Jan 2020 18:08:28 -0800 Subject: [PATCH 501/674] test(gateway): test the lazy seeker This commit was moved from ipfs/kubo@c64eb11992f755f88424afa2d8dacfc8b16d09fe --- gateway/core/corehttp/lazyseek_test.go | 137 +++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 gateway/core/corehttp/lazyseek_test.go diff --git a/gateway/core/corehttp/lazyseek_test.go b/gateway/core/corehttp/lazyseek_test.go new file mode 100644 index 000000000..144e57d0f --- /dev/null +++ b/gateway/core/corehttp/lazyseek_test.go @@ -0,0 +1,137 @@ +package corehttp + +import ( + "fmt" + "io" + "io/ioutil" + "strings" + "testing" +) + +type badSeeker struct { + io.ReadSeeker +} + +var badSeekErr = fmt.Errorf("I'm a bad seeker") + +func (bs badSeeker) Seek(offset int64, whence int) (int64, error) { + off, err := bs.ReadSeeker.Seek(0, io.SeekCurrent) + if err != nil { + panic(err) + } + return off, badSeekErr +} + +func TestLazySeekerError(t *testing.T) { + underlyingBuffer := strings.NewReader("fubar") + s := &lazySeeker{ + reader: badSeeker{underlyingBuffer}, + size: underlyingBuffer.Size(), + } + off, err := s.Seek(0, io.SeekEnd) + if err != nil { + t.Fatal(err) + } + if off != s.size { + t.Fatal("expected to seek to the end") + } + + // shouldn't have actually seeked. + b, err := ioutil.ReadAll(s) + if err != nil { + t.Fatal(err) + } + if len(b) != 0 { + t.Fatal("expected to read nothing") + } + + // shouldn't need to actually seek. + off, err = s.Seek(0, io.SeekStart) + if err != nil { + t.Fatal(err) + } + if off != 0 { + t.Fatal("expected to seek to the start") + } + b, err = ioutil.ReadAll(s) + if err != nil { + t.Fatal(err) + } + if string(b) != "fubar" { + t.Fatal("expected to read string") + } + + // should fail the second time. + off, err = s.Seek(0, io.SeekStart) + if err != nil { + t.Fatal(err) + } + if off != 0 { + t.Fatal("expected to seek to the start") + } + // right here... + b, err = ioutil.ReadAll(s) + if err == nil { + t.Fatalf("expected an error, got output %s", string(b)) + } + if err != badSeekErr { + t.Fatalf("expected a bad seek error, got %s", err) + } + if len(b) != 0 { + t.Fatalf("expected to read nothing") + } +} + +func TestLazySeeker(t *testing.T) { + underlyingBuffer := strings.NewReader("fubar") + s := &lazySeeker{ + reader: underlyingBuffer, + size: underlyingBuffer.Size(), + } + expectByte := func(b byte) { + t.Helper() + var buf [1]byte + n, err := io.ReadFull(s, buf[:]) + if err != nil { + t.Fatal(err) + } + if n != 1 { + t.Fatalf("expected to read one byte, read %d", n) + } + if buf[0] != b { + t.Fatalf("expected %b, got %b", b, buf[0]) + } + } + expectSeek := func(whence int, off, expOff int64, expErr string) { + t.Helper() + n, err := s.Seek(off, whence) + if expErr == "" { + if err != nil { + t.Fatal("unexpected seek error: ", err) + } + } else { + if err == nil || err.Error() != expErr { + t.Fatalf("expected %s, got %s", err, expErr) + } + } + if n != expOff { + t.Fatalf("expected offset %d, got, %d", expOff, n) + } + } + + expectSeek(io.SeekEnd, 0, s.size, "") + b, err := ioutil.ReadAll(s) + if err != nil { + t.Fatal(err) + } + if len(b) != 0 { + t.Fatal("expected to read nothing") + } + expectSeek(io.SeekEnd, -1, s.size-1, "") + expectByte('r') + expectSeek(io.SeekStart, 0, 0, "") + expectByte('f') + expectSeek(io.SeekCurrent, 1, 2, "") + expectByte('b') + expectSeek(io.SeekCurrent, -100, 3, "invalid seek offset") +} From 13bce94dbdfebf307a44c328fe44181672a60d0d Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 26 Feb 2019 17:53:04 -0700 Subject: [PATCH 502/674] http: use Method* constants License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@5eea0a4ba0f4f9dc223ca3d5e34fc226085070d2 --- gateway/core/corehttp/commands.go | 4 ++-- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_handler.go | 12 +++++------ gateway/core/corehttp/gateway_test.go | 26 ++++++++++++------------ gateway/core/corehttp/option_test.go | 2 +- gateway/core/corehttp/proxy_test.go | 4 ++-- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index a198ea11b..867805ce2 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -89,7 +89,7 @@ func addCORSDefaults(c *cmdsHttp.ServerConfig) { // by default, use GET, PUT, POST if len(c.AllowedMethods()) == 0 { - c.SetAllowedMethods("GET", "POST", "PUT") + c.SetAllowedMethods(http.MethodGet, http.MethodPost, http.MethodPut) } } @@ -121,7 +121,7 @@ func commandsOption(cctx oldcmds.Context, command *cmds.Command) ServeOption { return func(n *core.IpfsNode, l net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { cfg := cmdsHttp.NewServerConfig() - cfg.SetAllowedMethods("GET", "POST", "PUT") + cfg.SetAllowedMethods(http.MethodGet, http.MethodPost, http.MethodPut) cfg.APIPath = APIPath rcfg, err := n.Repo.Config() if err != nil { diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index e294cd308..f400c515b 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -69,7 +69,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { } if _, ok := headers[ACAMethodsName]; !ok { // Default to GET - headers[ACAMethodsName] = []string{"GET"} + headers[ACAMethodsName] = []string{http.MethodGet} } headers[ACAHeadersName] = cleanHeaderSet( diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index a501e21dd..d9ff2dc8b 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -83,24 +83,24 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if i.config.Writable { switch r.Method { - case "POST": + case http.MethodPost: i.postHandler(w, r) return - case "PUT": + case http.MethodPut: i.putHandler(w, r) return - case "DELETE": + case http.MethodDelete: i.deleteHandler(w, r) return } } - if r.Method == "GET" || r.Method == "HEAD" { + if r.Method == http.MethodGet || r.Method == http.MethodHead { i.getOrHeadHandler(w, r) return } - if r.Method == "OPTIONS" { + if r.Method == http.MethodOptions { i.optionsHandler(w, r) return } @@ -298,7 +298,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } - if r.Method == "HEAD" { + if r.Method == http.MethodHead { return } diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index c37f9082e..9128aa017 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -202,7 +202,7 @@ func TestGatewayGet(t *testing.T) { {"example.man", "/", http.StatusOK, "fnord"}, } { var c http.Client - r, err := http.NewRequest("GET", ts.URL+test.path, nil) + r, err := http.NewRequest(http.MethodGet, ts.URL+test.path, nil) if err != nil { t.Fatal(err) } @@ -259,7 +259,7 @@ func TestIPNSHostnameRedirect(t *testing.T) { ns["/ipns/example.net"] = path.FromString(k.String()) // make request to directory containing index.html - req, err := http.NewRequest("GET", ts.URL+"/foo", nil) + req, err := http.NewRequest(http.MethodGet, ts.URL+"/foo", nil) if err != nil { t.Fatal(err) } @@ -282,7 +282,7 @@ func TestIPNSHostnameRedirect(t *testing.T) { } // make request with prefix to directory containing index.html - req, err = http.NewRequest("GET", ts.URL+"/foo", nil) + req, err = http.NewRequest(http.MethodGet, ts.URL+"/foo", nil) if err != nil { t.Fatal(err) } @@ -306,7 +306,7 @@ func TestIPNSHostnameRedirect(t *testing.T) { } // make sure /version isn't exposed - req, err = http.NewRequest("GET", ts.URL+"/version", nil) + req, err = http.NewRequest(http.MethodGet, ts.URL+"/version", nil) if err != nil { t.Fatal(err) } @@ -359,7 +359,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { ns["/ipns/example.net"] = path.FromString(k.String()) // make request to directory listing - req, err := http.NewRequest("GET", ts.URL+"/foo%3F%20%23%3C%27/", nil) + req, err := http.NewRequest(http.MethodGet, ts.URL+"/foo%3F%20%23%3C%27/", nil) if err != nil { t.Fatal(err) } @@ -392,7 +392,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { } // make request to directory listing at root - req, err = http.NewRequest("GET", ts.URL, nil) + req, err = http.NewRequest(http.MethodGet, ts.URL, nil) if err != nil { t.Fatal(err) } @@ -425,7 +425,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { } // make request to directory listing - req, err = http.NewRequest("GET", ts.URL+"/foo%3F%20%23%3C%27/bar/", nil) + req, err = http.NewRequest(http.MethodGet, ts.URL+"/foo%3F%20%23%3C%27/bar/", nil) if err != nil { t.Fatal(err) } @@ -458,7 +458,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { } // make request to directory listing with prefix - req, err = http.NewRequest("GET", ts.URL, nil) + req, err = http.NewRequest(http.MethodGet, ts.URL, nil) if err != nil { t.Fatal(err) } @@ -492,7 +492,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { } // make request to directory listing with illegal prefix - req, err = http.NewRequest("GET", ts.URL, nil) + req, err = http.NewRequest(http.MethodGet, ts.URL, nil) if err != nil { t.Fatal(err) } @@ -500,7 +500,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { req.Header.Set("X-Ipfs-Gateway-Prefix", "/bad-prefix") // make request to directory listing with evil prefix - req, err = http.NewRequest("GET", ts.URL, nil) + req, err = http.NewRequest(http.MethodGet, ts.URL, nil) if err != nil { t.Fatal(err) } @@ -539,7 +539,7 @@ func TestCacheControlImmutable(t *testing.T) { t.Logf("test server url: %s", ts.URL) defer ts.Close() - req, err := http.NewRequest("GET", ts.URL+emptyDir+"/", nil) + req, err := http.NewRequest(http.MethodGet, ts.URL+emptyDir+"/", nil) if err != nil { t.Fatal(err) } @@ -566,7 +566,7 @@ func TestGoGetSupport(t *testing.T) { defer ts.Close() // mimic go-get - req, err := http.NewRequest("GET", ts.URL+emptyDir+"?go-get=1", nil) + req, err := http.NewRequest(http.MethodGet, ts.URL+emptyDir+"?go-get=1", nil) if err != nil { t.Fatal(err) } @@ -589,7 +589,7 @@ func TestVersion(t *testing.T) { t.Logf("test server url: %s", ts.URL) defer ts.Close() - req, err := http.NewRequest("GET", ts.URL+"/version", nil) + req, err := http.NewRequest(http.MethodGet, ts.URL+"/version", nil) if err != nil { t.Fatal(err) } diff --git a/gateway/core/corehttp/option_test.go b/gateway/core/corehttp/option_test.go index 17fcefe09..57f8d3b16 100644 --- a/gateway/core/corehttp/option_test.go +++ b/gateway/core/corehttp/option_test.go @@ -37,7 +37,7 @@ func TestCheckVersionOption(t *testing.T) { for _, tc := range tcs { t.Logf("%#v", tc) - r := httptest.NewRequest("POST", tc.uri, nil) + r := httptest.NewRequest(http.MethodPost, tc.uri, nil) r.Header.Add("User-Agent", tc.userAgent) // old version, should fail called := false diff --git a/gateway/core/corehttp/proxy_test.go b/gateway/core/corehttp/proxy_test.go index 98d749e0c..9f99463d9 100644 --- a/gateway/core/corehttp/proxy_test.go +++ b/gateway/core/corehttp/proxy_test.go @@ -26,7 +26,7 @@ var validtestCases = []TestCase{ func TestParseRequest(t *testing.T) { for _, tc := range validtestCases { url := tc.urlprefix + "/p2p/" + tc.target + tc.name + "/" + tc.path - req, _ := http.NewRequest("GET", url, strings.NewReader("")) + req, _ := http.NewRequest(http.MethodGet, url, strings.NewReader("")) parsed, err := parseRequest(req) if err != nil { @@ -46,7 +46,7 @@ var invalidtestCases = []string{ func TestParseRequestInvalidPath(t *testing.T) { for _, tc := range invalidtestCases { url := tc - req, _ := http.NewRequest("GET", url, strings.NewReader("")) + req, _ := http.NewRequest(http.MethodGet, url, strings.NewReader("")) _, err := parseRequest(req) if err == nil { From ef0dc270e78665cc49b716cf5134c26b78c3f861 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 26 Feb 2019 17:55:42 -0700 Subject: [PATCH 503/674] gateway: cleanup logic License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@725e6844ee734591022e0ce8ddc0e526241def0d --- gateway/core/corehttp/gateway_handler.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d9ff2dc8b..62d151ee4 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -95,12 +95,11 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } - if r.Method == http.MethodGet || r.Method == http.MethodHead { + switch r.Method { + case http.MethodGet, http.MethodHead: i.getOrHeadHandler(w, r) return - } - - if r.Method == http.MethodOptions { + case http.MethodOptions: i.optionsHandler(w, r) return } From bb228d14560a61cf9e3b2e80e3e9d1932e55e9ac Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 17 Dec 2019 02:11:35 +0100 Subject: [PATCH 504/674] fix: limit SW registration to content root Introduces hardening proposed in: https://github.com/ipfs/go-ipfs/issues/4025#issuecomment-342250616 License: MIT Signed-off-by: Marcin Rataj This commit was moved from ipfs/kubo@455e49835500fb46053f68d1236a103d75db18df --- gateway/core/corehttp/gateway_handler.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d3cca5d3d..a828b9f5f 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -8,6 +8,7 @@ import ( "net/http" "net/url" gopath "path" + "regexp" "runtime/debug" "strings" "time" @@ -151,6 +152,18 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request ipnsHostname = true } + // Service Worker registration request + if r.Header.Get("Service-Worker") == "script" { + // Disallow Service Worker registration on namespace roots + // https://github.com/ipfs/go-ipfs/issues/4025 + matched, _ := regexp.MatchString(`^/ip[fn]s/[^/]+$`, r.URL.Path) + if matched { + err := fmt.Errorf("registration is not allowed for this scope") + webError(w, "navigator.serviceWorker", err, http.StatusBadRequest) + return + } + } + parsedPath := ipath.New(urlPath) if err := parsedPath.IsValid(); err != nil { webError(w, "invalid ipfs path", err, http.StatusBadRequest) From 797d2e2877c504273133c7407ac0080454c01388 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 4 Dec 2019 08:15:58 +0000 Subject: [PATCH 505/674] feat: webui 2.7.2 https://github.com/ipfs-shipyard/ipfs-webui/releases/tag/v2.7.2 License: MIT Signed-off-by: Marcin Rataj This commit was moved from ipfs/kubo@b2777eebbf0bc5a840bf94d1c27d75a68aa23001 --- gateway/core/corehttp/webui.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 0df21d5f5..8f692fb6b 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/QmfQkD8pBSBCBxWEwFSu4XaDVSWK6bjnNuaWZjMyQbyDub" +const WebUIPath = "/ipfs/Qmexhq2sBHnXQbvyP2GfUdbnY7HCagH2Mw5vUNSBn2nxip" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -22,6 +22,17 @@ var WebUIPaths = []string{ "/ipfs/QmRyWyKWmphamkMRnJVjUTzSFSAAZowYP4rnbgnfMXC9Mr", "/ipfs/QmU3o9bvfenhTKhxUakbYrLDnZU7HezAVxPM6Ehjw9Xjqy", "/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ", + "/ipfs/QmfQkD8pBSBCBxWEwFSu4XaDVSWK6bjnNuaWZjMyQbyDub", + "/ipfs/QmQNHd1suZTktPRhP7DD4nKWG46ZRSxkwHocycHVrK3dYW", + "/ipfs/QmNyMYhwJUS1cVvaWoVBhrW8KPj1qmie7rZcWo8f1Bvkhz", + "/ipfs/QmVTiRTQ72qiH4usAGT4c6qVxCMv4hFMUH9fvU6mktaXdP", + "/ipfs/QmYcP4sp1nraBiCYi6i9kqdaKobrK32yyMpTrM5JDA8a2C", + "/ipfs/QmUtMmxgHnDvQq4bpH6Y9MaLN1hpfjJz5LZcq941BEqEXs", + "/ipfs/QmPURAjo3oneGH53ovt68UZEBvsc8nNmEhQZEpsVEQUMZE", + "/ipfs/QmeSXt32frzhvewLKwA1dePTSjkTfGVwTh55ZcsJxrCSnk", + "/ipfs/QmcjeTciMNgEBe4xXvEaA4TQtwTRkXucx7DmKWViXSmX7m", + "/ipfs/QmfNbSskgvTXYhuqP8tb9AKbCkyRcCy3WeiXwD9y5LeoqK", + "/ipfs/QmPkojhjJkJ5LEGBDrAvdftrjAYmi9GU5Cq27mWvZTDieW", } var WebUIOption = RedirectOption("webui", WebUIPath) From ac6b82ac26c4335af127430531db822e0549f363 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 16 Jan 2020 15:48:20 -0800 Subject: [PATCH 506/674] fix: migrate from deprecated warning function This commit was moved from ipfs/kubo@a53d48059bff98e3a48faf79103651ce301a7ab2 --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_handler.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 867805ce2..d63099bfb 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -47,7 +47,7 @@ var defaultLocalhostOrigins = []string{ func addCORSFromEnv(c *cmdsHttp.ServerConfig) { origin := os.Getenv(originEnvKey) if origin != "" { - log.Warning(originEnvKeyDeprecate) + log.Warn(originEnvKeyDeprecate) c.AppendAllowedOrigins(origin) } } diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 62d151ee4..de8038f53 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -610,7 +610,7 @@ func webError(w http.ResponseWriter, message string, err error, defaultCode int) func webErrorWithCode(w http.ResponseWriter, message string, err error, code int) { http.Error(w, fmt.Sprintf("%s: %s", message, err), code) if code >= 500 { - log.Warningf("server error: %s: %s", err) + log.Warnf("server error: %s: %s", err) } } From 5a0b56d141b5811ee9050f08ea723d5ae4957762 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 16 Jan 2020 16:18:53 -0800 Subject: [PATCH 507/674] fix(tracing): remove event tracing We've deprecated this system and have yet to move to a new system. We might as well remove everything, switch to a new system, then deliberately trace the entire system. This commit was moved from ipfs/kubo@906f45edd9899352efba710e2f53978fc4b8c6e4 --- gateway/core/corehttp/logs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 387508b6d..99e8fa885 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -50,7 +50,7 @@ func LogOption() ServeOption { w.WriteHeader(200) wnf, errs := newWriteErrNotifier(w) lwriter.WriterGroup.AddWriter(wnf) - log.Event(n.Context(), "log API client connected") + log.Event(n.Context(), "log API client connected") //nolint deprecated <-errs }) return mux, nil From 5f8bf3ab0aa2e79e4512cff6078373bac6c24096 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 14 Mar 2019 16:07:01 -0700 Subject: [PATCH 508/674] rename ProxyOption to P2PProxyOption (we're implementing an _actual_ proxy) License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@11c229bb14726e2bdd99d706ded2383a4a41adb4 --- gateway/core/corehttp/{proxy.go => p2p_proxy.go} | 4 ++-- gateway/core/corehttp/{proxy_test.go => p2p_proxy_test.go} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename gateway/core/corehttp/{proxy.go => p2p_proxy.go} (94%) rename gateway/core/corehttp/{proxy_test.go => p2p_proxy_test.go} (100%) diff --git a/gateway/core/corehttp/proxy.go b/gateway/core/corehttp/p2p_proxy.go similarity index 94% rename from gateway/core/corehttp/proxy.go rename to gateway/core/corehttp/p2p_proxy.go index 17cb00528..0a615c33a 100644 --- a/gateway/core/corehttp/proxy.go +++ b/gateway/core/corehttp/p2p_proxy.go @@ -14,8 +14,8 @@ import ( p2phttp "github.com/libp2p/go-libp2p-http" ) -// ProxyOption is an endpoint for proxying a HTTP request to another ipfs peer -func ProxyOption() ServeOption { +// P2PProxyOption is an endpoint for proxying a HTTP request to another ipfs peer +func P2PProxyOption() ServeOption { return func(ipfsNode *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/p2p/", func(w http.ResponseWriter, request *http.Request) { // parse request diff --git a/gateway/core/corehttp/proxy_test.go b/gateway/core/corehttp/p2p_proxy_test.go similarity index 100% rename from gateway/core/corehttp/proxy_test.go rename to gateway/core/corehttp/p2p_proxy_test.go From 5429ceb50762074ec0df66ecf322d89eeb306ad7 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 14 Mar 2019 16:09:00 -0700 Subject: [PATCH 509/674] gateway: simplify/improve dnslink rewrite handling Instead of adding a new fake header (that could be spoofed by the client...), just read the original request URI from the request object. This also removes support for suborigins. They have never been implemented in browsers and it looks like efforts have stalled. We can add support back if we need it but, well, maintaining support was going to be more trouble than it was worth. License: MIT Signed-off-by: Steven Allen This commit was moved from ipfs/kubo@72490f7ed04494b5d96bae06476faff472bc37a9 --- gateway/core/corehttp/gateway_handler.go | 59 +++--------------------- gateway/core/corehttp/ipns_hostname.go | 1 - 2 files changed, 7 insertions(+), 53 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index de8038f53..5b1382a86 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -24,7 +24,6 @@ import ( coreiface "github.com/ipfs/interface-go-ipfs-core" ipath "github.com/ipfs/interface-go-ipfs-core/path" routing "github.com/libp2p/go-libp2p-core/routing" - "github.com/multiformats/go-multibase" ) const ( @@ -148,12 +147,11 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // and links that match the requested URL. // For example, http://example.net would become /ipns/example.net, and // the redirects and links would end up as http://example.net/ipns/example.net - originalUrlPath := prefix + urlPath - ipnsHostname := false - if hdr := r.Header.Get("X-Ipns-Original-Path"); len(hdr) > 0 { - originalUrlPath = prefix + hdr - ipnsHostname = true + requestURI, err := url.ParseRequestURI(r.RequestURI) + if err != nil { + webError(w, "failed to parse request path", err, http.StatusInternalServerError) } + originalUrlPath := prefix + requestURI.Path // Service Worker registration request if r.Header.Get("Service-Worker") == "script" { @@ -206,39 +204,6 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request w.Header().Set("X-IPFS-Path", urlPath) w.Header().Set("Etag", etag) - // Suborigin header, sandboxes apps from each other in the browser (even - // though they are served from the same gateway domain). - // - // Omitted if the path was treated by IPNSHostnameOption(), for example - // a request for http://example.net/ would be changed to /ipns/example.net/, - // which would turn into an incorrect Suborigin header. - // In this case the correct thing to do is omit the header because it is already - // handled correctly without a Suborigin. - // - // NOTE: This is not yet widely supported by browsers. - if !ipnsHostname { - // e.g.: 1="ipfs", 2="QmYuNaKwY...", ... - pathComponents := strings.SplitN(urlPath, "/", 4) - - var suboriginRaw []byte - cidDecoded, err := cid.Decode(pathComponents[2]) - if err != nil { - // component 2 doesn't decode with cid, so it must be a hostname - suboriginRaw = []byte(strings.ToLower(pathComponents[2])) - } else { - suboriginRaw = cidDecoded.Bytes() - } - - base32Encoded, err := multibase.Encode(multibase.Base32, suboriginRaw) - if err != nil { - internalWebError(w, err) - return - } - - suborigin := pathComponents[1] + "000" + strings.ToLower(base32Encoded) - w.Header().Set("Suborigin", suborigin) - } - // set these headers _after_ the error, for we may just not have it // and dont want the client to cache a 500 response... // and only if it's /ipfs! @@ -322,10 +287,10 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // construct the correct back link // https://github.com/ipfs/go-ipfs/issues/1365 - var backLink string = prefix + urlPath + var backLink string = originalUrlPath // don't go further up than /ipfs/$hash/ - pathSplit := path.SplitList(backLink) + pathSplit := path.SplitList(urlPath) switch { // keep backlink case len(pathSplit) == 3: // url: /ipfs/$hash @@ -342,18 +307,8 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } } - // strip /ipfs/$hash from backlink if IPNSHostnameOption touched the path. - if ipnsHostname { - backLink = prefix + "/" - if len(pathSplit) > 5 { - // also strip the trailing segment, because it's a backlink - backLinkParts := pathSplit[3 : len(pathSplit)-2] - backLink += path.Join(backLinkParts) + "/" - } - } - var hash string - if !strings.HasPrefix(originalUrlPath, ipfsPathPrefix) { + if !strings.HasPrefix(urlPath, ipfsPathPrefix) { hash = resolvedPath.Cid().String() } diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go index d5512779b..ddcd58c61 100644 --- a/gateway/core/corehttp/ipns_hostname.go +++ b/gateway/core/corehttp/ipns_hostname.go @@ -28,7 +28,6 @@ func IPNSHostnameOption() ServeOption { name := "/ipns/" + host _, err := n.Namesys.Resolve(ctx, name, nsopts.Depth(1)) if err == nil || err == namesys.ErrResolveRecursion { - r.Header.Set("X-Ipns-Original-Path", r.URL.Path) r.URL.Path = name + r.URL.Path } } From df091792b3930a89abc6620ec52f92c0be54db40 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 14 Mar 2019 17:21:38 -0700 Subject: [PATCH 510/674] feat(gateway): subdomain and proxy gateway License: MIT Signed-off-by: Marcin Rataj This commit was moved from ipfs/kubo@3ecccd6e1dff567db8da8a53cebd8226ecf2f446 --- gateway/core/corehttp/corehttp.go | 14 +- gateway/core/corehttp/gateway_handler.go | 9 +- gateway/core/corehttp/gateway_test.go | 18 +- gateway/core/corehttp/hostname.go | 358 +++++++++++++++++++++++ gateway/core/corehttp/hostname_test.go | 152 ++++++++++ gateway/core/corehttp/ipns_hostname.go | 38 --- 6 files changed, 537 insertions(+), 52 deletions(-) create mode 100644 gateway/core/corehttp/hostname.go create mode 100644 gateway/core/corehttp/hostname_test.go delete mode 100644 gateway/core/corehttp/ipns_hostname.go diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index c52bea8f5..d99a07691 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -43,7 +43,17 @@ func makeHandler(n *core.IpfsNode, l net.Listener, options ...ServeOption) (http return nil, err } } - return topMux, nil + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // ServeMux does not support requests with CONNECT method, + // so we need to handle them separately + // https://golang.org/src/net/http/request.go#L111 + if r.Method == http.MethodConnect { + w.WriteHeader(http.StatusOK) + return + } + topMux.ServeHTTP(w, r) + }) + return handler, nil } // ListenAndServe runs an HTTP server listening at |listeningMultiAddr| with @@ -70,6 +80,8 @@ func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...Serv return Serve(n, manet.NetListener(list), options...) } +// Serve accepts incoming HTTP connections on the listener and pass them +// to ServeOption handlers. func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error { // make sure we close this no matter what. defer lis.Close() diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 5b1382a86..cf7420243 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -14,12 +14,12 @@ import ( "strings" "time" - "github.com/dustin/go-humanize" + humanize "github.com/dustin/go-humanize" "github.com/ipfs/go-cid" files "github.com/ipfs/go-ipfs-files" dag "github.com/ipfs/go-merkledag" - "github.com/ipfs/go-mfs" - "github.com/ipfs/go-path" + mfs "github.com/ipfs/go-mfs" + path "github.com/ipfs/go-path" "github.com/ipfs/go-path/resolver" coreiface "github.com/ipfs/interface-go-ipfs-core" ipath "github.com/ipfs/interface-go-ipfs-core/path" @@ -142,7 +142,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } } - // IPNSHostnameOption might have constructed an IPNS path using the Host header. + // HostnameOption might have constructed an IPNS/IPFS path using the Host header. // In this case, we need the original path for constructing redirects // and links that match the requested URL. // For example, http://example.net would become /ipns/example.net, and @@ -150,6 +150,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request requestURI, err := url.ParseRequestURI(r.RequestURI) if err != nil { webError(w, "failed to parse request path", err, http.StatusInternalServerError) + return } originalUrlPath := prefix + requestURI.Path diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 9128aa017..daf1af07c 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -138,7 +138,7 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, iface dh.Handler, err = makeHandler(n, ts.Listener, - IPNSHostnameOption(), + HostnameOption(), GatewayOption(false, "/ipfs", "/ipns"), VersionOption(), ) @@ -184,12 +184,12 @@ func TestGatewayGet(t *testing.T) { status int text string }{ - {"localhost:5001", "/", http.StatusNotFound, "404 page not found\n"}, - {"localhost:5001", "/" + k.Cid().String(), http.StatusNotFound, "404 page not found\n"}, - {"localhost:5001", k.String(), http.StatusOK, "fnord"}, - {"localhost:5001", "/ipns/nxdomain.example.com", http.StatusNotFound, "ipfs resolve -r /ipns/nxdomain.example.com: " + namesys.ErrResolveFailed.Error() + "\n"}, - {"localhost:5001", "/ipns/%0D%0A%0D%0Ahello", http.StatusNotFound, "ipfs resolve -r /ipns/%0D%0A%0D%0Ahello: " + namesys.ErrResolveFailed.Error() + "\n"}, - {"localhost:5001", "/ipns/example.com", http.StatusOK, "fnord"}, + {"127.0.0.1:8080", "/", http.StatusNotFound, "404 page not found\n"}, + {"127.0.0.1:8080", "/" + k.Cid().String(), http.StatusNotFound, "404 page not found\n"}, + {"127.0.0.1:8080", k.String(), http.StatusOK, "fnord"}, + {"127.0.0.1:8080", "/ipns/nxdomain.example.com", http.StatusNotFound, "ipfs resolve -r /ipns/nxdomain.example.com: " + namesys.ErrResolveFailed.Error() + "\n"}, + {"127.0.0.1:8080", "/ipns/%0D%0A%0D%0Ahello", http.StatusNotFound, "ipfs resolve -r /ipns/%0D%0A%0D%0Ahello: " + namesys.ErrResolveFailed.Error() + "\n"}, + {"127.0.0.1:8080", "/ipns/example.com", http.StatusOK, "fnord"}, {"example.com", "/", http.StatusOK, "fnord"}, {"working.example.com", "/", http.StatusOK, "fnord"}, @@ -381,7 +381,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "Index of /foo? #<'/") { t.Fatalf("expected a path in directory listing") } - if !strings.Contains(s, "") { + if !strings.Contains(s, "") { t.Fatalf("expected backlink in directory listing") } if !strings.Contains(s, "") { @@ -447,7 +447,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "Index of /foo? #<'/bar/") { t.Fatalf("expected a path in directory listing") } - if !strings.Contains(s, "") { + if !strings.Contains(s, "") { t.Fatalf("expected backlink in directory listing") } if !strings.Contains(s, "") { diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go new file mode 100644 index 000000000..910ba5bc8 --- /dev/null +++ b/gateway/core/corehttp/hostname.go @@ -0,0 +1,358 @@ +package corehttp + +import ( + "context" + "fmt" + "net" + "net/http" + "net/url" + "strings" + + cid "github.com/ipfs/go-cid" + core "github.com/ipfs/go-ipfs/core" + coreapi "github.com/ipfs/go-ipfs/core/coreapi" + namesys "github.com/ipfs/go-ipfs/namesys" + isd "github.com/jbenet/go-is-domain" + "github.com/libp2p/go-libp2p-core/peer" + mbase "github.com/multiformats/go-multibase" + + config "github.com/ipfs/go-ipfs-config" + iface "github.com/ipfs/interface-go-ipfs-core" + options "github.com/ipfs/interface-go-ipfs-core/options" + nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" +) + +var defaultPaths = []string{"/ipfs/", "/ipns/", "/api/", "/p2p/", "/version"} + +var pathGatewaySpec = config.GatewaySpec{ + Paths: defaultPaths, + UseSubdomains: false, +} + +var subdomainGatewaySpec = config.GatewaySpec{ + Paths: defaultPaths, + UseSubdomains: true, +} + +var defaultKnownGateways = map[string]config.GatewaySpec{ + "localhost": subdomainGatewaySpec, + "ipfs.io": pathGatewaySpec, + "gateway.ipfs.io": pathGatewaySpec, + "dweb.link": subdomainGatewaySpec, +} + +// HostnameOption rewrites an incoming request based on the Host header. +func HostnameOption() ServeOption { + return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { + childMux := http.NewServeMux() + + coreApi, err := coreapi.NewCoreAPI(n) + if err != nil { + return nil, err + } + + cfg, err := n.Repo.Config() + if err != nil { + return nil, err + } + knownGateways := make( + map[string]config.GatewaySpec, + len(defaultKnownGateways)+len(cfg.Gateway.PublicGateways), + ) + for hostname, gw := range defaultKnownGateways { + knownGateways[hostname] = gw + } + for hostname, gw := range cfg.Gateway.PublicGateways { + if gw == nil { + // Allows the user to remove gateways but _also_ + // allows us to continuously update the list. + delete(knownGateways, hostname) + } else { + knownGateways[hostname] = *gw + } + } + + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + // Unfortunately, many (well, ipfs.io) gateways use + // DNSLink so if we blindly rewrite with DNSLink, we'll + // break /ipfs links. + // + // We fix this by maintaining a list of known gateways + // and the paths that they serve "gateway" content on. + // That way, we can use DNSLink for everything else. + + // HTTP Host & Path check: is this one of our "known gateways"? + if gw, ok := isKnownHostname(r.Host, knownGateways); ok { + // This is a known gateway but request is not using + // the subdomain feature. + + // Does this gateway _handle_ this path? + if hasPrefix(r.URL.Path, gw.Paths...) { + // It does. + + // Should this gateway use subdomains instead of paths? + if gw.UseSubdomains { + // Yes, redirect if applicable + // Example: dweb.link/ipfs/{cid} → {cid}.ipfs.dweb.link + if newURL, ok := toSubdomainURL(r.Host, r.URL.Path, r); ok { + http.Redirect(w, r, newURL, http.StatusMovedPermanently) + return + } + } + + // Not a subdomain resource, continue with path processing + // Example: 127.0.0.1:8080/ipfs/{CID}, ipfs.io/ipfs/{CID} etc + childMux.ServeHTTP(w, r) + return + } + // Not a whitelisted path + + // Try DNSLink, if it was not explicitly disabled for the hostname + if !gw.NoDNSLink && isDNSLinkRequest(n.Context(), coreApi, r) { + // rewrite path and handle as DNSLink + r.URL.Path = "/ipns/" + stripPort(r.Host) + r.URL.Path + childMux.ServeHTTP(w, r) + return + } + + // If not, resource does not exist on the hostname, return 404 + http.NotFound(w, r) + return + } + + // HTTP Host check: is this one of our subdomain-based "known gateways"? + // Example: {cid}.ipfs.localhost, {cid}.ipfs.dweb.link + if gw, hostname, ns, rootID, ok := knownSubdomainDetails(r.Host, knownGateways); ok { + // Looks like we're using known subdomain gateway. + + // Assemble original path prefix. + pathPrefix := "/" + ns + "/" + rootID + + // Does this gateway _handle_ this path? + if !(gw.UseSubdomains && hasPrefix(pathPrefix, gw.Paths...)) { + // If not, resource does not exist, return 404 + http.NotFound(w, r) + return + } + + // Do we need to fix multicodec in PeerID represented as CIDv1? + if isPeerIDNamespace(ns) { + keyCid, err := cid.Decode(rootID) + if err == nil && keyCid.Type() != cid.Libp2pKey { + if newURL, ok := toSubdomainURL(hostname, pathPrefix+r.URL.Path, r); ok { + // Redirect to CID fixed inside of toSubdomainURL() + http.Redirect(w, r, newURL, http.StatusMovedPermanently) + return + } + } + } + + // Rewrite the path to not use subdomains + r.URL.Path = pathPrefix + r.URL.Path + + // Serve path request + childMux.ServeHTTP(w, r) + return + } + // We don't have a known gateway. Fallback on DNSLink lookup + + // Wildcard HTTP Host check: + // 1. is wildcard DNSLink enabled (Gateway.NoDNSLink=false)? + // 2. does Host header include a fully qualified domain name (FQDN)? + // 3. does DNSLink record exist in DNS? + if !cfg.Gateway.NoDNSLink && isDNSLinkRequest(n.Context(), coreApi, r) { + // rewrite path and handle as DNSLink + r.URL.Path = "/ipns/" + stripPort(r.Host) + r.URL.Path + childMux.ServeHTTP(w, r) + return + } + + // else, treat it as an old school gateway, I guess. + childMux.ServeHTTP(w, r) + }) + return childMux, nil + } +} + +// isKnownHostname checks Gateway.PublicGateways and returns matching +// GatewaySpec with gracefull fallback to version without port +func isKnownHostname(hostname string, knownGateways map[string]config.GatewaySpec) (gw config.GatewaySpec, ok bool) { + // Try hostname (host+optional port - value from Host header as-is) + if gw, ok := knownGateways[hostname]; ok { + return gw, ok + } + // Fallback to hostname without port + gw, ok = knownGateways[stripPort(hostname)] + return gw, ok +} + +// Parses Host header and looks for a known subdomain gateway host. +// If found, returns GatewaySpec and subdomain components. +// Note: hostname is host + optional port +func knownSubdomainDetails(hostname string, knownGateways map[string]config.GatewaySpec) (gw config.GatewaySpec, knownHostname, ns, rootID string, ok bool) { + labels := strings.Split(hostname, ".") + // Look for FQDN of a known gateway hostname. + // Example: given "dist.ipfs.io.ipns.dweb.link": + // 1. Lookup "link" TLD in knownGateways: negative + // 2. Lookup "dweb.link" in knownGateways: positive + // + // Stops when we have 2 or fewer labels left as we need at least a + // rootId and a namespace. + for i := len(labels) - 1; i >= 2; i-- { + fqdn := strings.Join(labels[i:], ".") + gw, ok := isKnownHostname(fqdn, knownGateways) + if !ok { + continue + } + + ns := labels[i-1] + if !isSubdomainNamespace(ns) { + break + } + + // Merge remaining labels (could be a FQDN with DNSLink) + rootID := strings.Join(labels[:i-1], ".") + return gw, fqdn, ns, rootID, true + } + // not a known subdomain gateway + return gw, "", "", "", false +} + +// isDNSLinkRequest returns bool that indicates if request +// should return data from content path listed in DNSLink record (if exists) +func isDNSLinkRequest(ctx context.Context, ipfs iface.CoreAPI, r *http.Request) bool { + fqdn := stripPort(r.Host) + if len(fqdn) == 0 && !isd.IsDomain(fqdn) { + return false + } + name := "/ipns/" + fqdn + // check if DNSLink exists + depth := options.Name.ResolveOption(nsopts.Depth(1)) + _, err := ipfs.Name().Resolve(ctx, name, depth) + return err == nil || err == namesys.ErrResolveRecursion +} + +func isSubdomainNamespace(ns string) bool { + switch ns { + case "ipfs", "ipns", "p2p", "ipld": + return true + default: + return false + } +} + +func isPeerIDNamespace(ns string) bool { + switch ns { + case "ipns", "p2p": + return true + default: + return false + } +} + +// Converts a hostname/path to a subdomain-based URL, if applicable. +func toSubdomainURL(hostname, path string, r *http.Request) (redirURL string, ok bool) { + var scheme, ns, rootID, rest string + + query := r.URL.RawQuery + parts := strings.SplitN(path, "/", 4) + safeRedirectURL := func(in string) (out string, ok bool) { + safeURI, err := url.ParseRequestURI(in) + if err != nil { + return "", false + } + return safeURI.String(), true + } + + // Support X-Forwarded-Proto if added by a reverse proxy + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto + xproto := r.Header.Get("X-Forwarded-Proto") + if xproto == "https" { + scheme = "https:" + } else { + scheme = "http:" + } + + switch len(parts) { + case 4: + rest = parts[3] + fallthrough + case 3: + ns = parts[1] + rootID = parts[2] + default: + return "", false + } + + if !isSubdomainNamespace(ns) { + return "", false + } + + // add prefix if query is present + if query != "" { + query = "?" + query + } + + // Normalize problematic PeerIDs (eg. ed25519+identity) to CID representation + if isPeerIDNamespace(ns) && !isd.IsDomain(rootID) { + peerID, err := peer.Decode(rootID) + // Note: PeerID CIDv1 with protobuf multicodec will fail, but we fix it + // in the next block + if err == nil { + rootID = peer.ToCid(peerID).String() + } + } + + // If rootID is a CID, ensure it uses DNS-friendly text representation + if rootCid, err := cid.Decode(rootID); err == nil { + multicodec := rootCid.Type() + + // PeerIDs represented as CIDv1 are expected to have libp2p-key + // multicodec (https://github.com/libp2p/specs/pull/209). + // We ease the transition by fixing multicodec on the fly: + // https://github.com/ipfs/go-ipfs/issues/5287#issuecomment-492163929 + if isPeerIDNamespace(ns) && multicodec != cid.Libp2pKey { + multicodec = cid.Libp2pKey + } + + // if object turns out to be a valid CID, + // ensure text representation used in subdomain is CIDv1 in Base32 + // https://github.com/ipfs/in-web-browsers/issues/89 + rootID, err = cid.NewCidV1(multicodec, rootCid.Hash()).StringOfBase(mbase.Base32) + if err != nil { + // should not error, but if it does, its clealy not possible to + // produce a subdomain URL + return "", false + } + } + + return safeRedirectURL(fmt.Sprintf( + "%s//%s.%s.%s/%s%s", + scheme, + rootID, + ns, + hostname, + rest, + query, + )) +} + +func hasPrefix(path string, prefixes ...string) bool { + for _, prefix := range prefixes { + // Assume people are creative with trailing slashes in Gateway config + p := strings.TrimSuffix(prefix, "/") + // Support for both /version and /ipfs/$cid + if p == path || strings.HasPrefix(path, p+"/") { + return true + } + } + return false +} + +func stripPort(hostname string) string { + host, _, err := net.SplitHostPort(hostname) + if err == nil { + return host + } + return hostname +} diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go new file mode 100644 index 000000000..9a2974648 --- /dev/null +++ b/gateway/core/corehttp/hostname_test.go @@ -0,0 +1,152 @@ +package corehttp + +import ( + "net/http/httptest" + "testing" + + config "github.com/ipfs/go-ipfs-config" +) + +func TestToSubdomainURL(t *testing.T) { + r := httptest.NewRequest("GET", "http://request-stub.example.com", nil) + for _, test := range []struct { + // in: + hostname string + path string + // out: + url string + ok bool + }{ + // DNSLink + {"localhost", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost/", true}, + // Hostname with port + {"localhost:8080", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost:8080/", true}, + // CIDv0 → CIDv1base32 + {"localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.localhost/", true}, + // PeerID as CIDv1 needs to have libp2p-key multicodec + {"localhost", "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", "http://bafzbeieqhtl2l3mrszjnhv6hf2iloiitsx7mexiolcnywnbcrzkqxwslja.ipns.localhost/", true}, + {"localhost", "/ipns/bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "http://bafzbeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm.ipns.localhost/", true}, + // PeerID: ed25519+identity multihash + {"localhost", "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://bafzaajaiaejcat4yhiwnr2qz73mtu6vrnj2krxlpfoa3wo2pllfi37quorgwh2jw.ipns.localhost/", true}, + } { + url, ok := toSubdomainURL(test.hostname, test.path, r) + if ok != test.ok || url != test.url { + t.Errorf("(%s, %s) returned (%s, %t), expected (%s, %t)", test.hostname, test.path, url, ok, test.url, ok) + } + } +} + +func TestHasPrefix(t *testing.T) { + for _, test := range []struct { + prefixes []string + path string + out bool + }{ + {[]string{"/ipfs"}, "/ipfs/cid", true}, + {[]string{"/ipfs/"}, "/ipfs/cid", true}, + {[]string{"/version/"}, "/version", true}, + {[]string{"/version"}, "/version", true}, + } { + out := hasPrefix(test.path, test.prefixes...) + if out != test.out { + t.Errorf("(%+v, %s) returned '%t', expected '%t'", test.prefixes, test.path, out, test.out) + } + } +} + +func TestPortStripping(t *testing.T) { + for _, test := range []struct { + in string + out string + }{ + {"localhost:8080", "localhost"}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.localhost:8080", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.localhost"}, + {"example.com:443", "example.com"}, + {"example.com", "example.com"}, + {"foo-dweb.ipfs.pvt.k12.ma.us:8080", "foo-dweb.ipfs.pvt.k12.ma.us"}, + {"localhost", "localhost"}, + {"[::1]:8080", "::1"}, + } { + out := stripPort(test.in) + if out != test.out { + t.Errorf("(%s): returned '%s', expected '%s'", test.in, out, test.out) + } + } + +} + +func TestKnownSubdomainDetails(t *testing.T) { + gwSpec := config.GatewaySpec{ + UseSubdomains: true, + } + knownGateways := map[string]config.GatewaySpec{ + "localhost": gwSpec, + "dweb.link": gwSpec, + "dweb.ipfs.pvt.k12.ma.us": gwSpec, // note the sneaky ".ipfs." ;-) + } + + for _, test := range []struct { + // in: + hostHeader string + // out: + hostname string + ns string + rootID string + ok bool + }{ + // no subdomain + {"127.0.0.1:8080", "", "", "", false}, + {"[::1]:8080", "", "", "", false}, + {"hey.look.example.com", "", "", "", false}, + {"dweb.link", "", "", "", false}, + // malformed Host header + {".....dweb.link", "", "", "", false}, + {"link", "", "", "", false}, + {"8080:dweb.link", "", "", "", false}, + {" ", "", "", "", false}, + {"", "", "", "", false}, + // unknown gateway host + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.unknown.example.com", "", "", "", false}, + // cid in subdomain, known gateway + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.localhost:8080", "localhost:8080", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.link", "dweb.link", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, + // capture everything before .ipfs. + {"foo.bar.boo-buzz.ipfs.dweb.link", "dweb.link", "ipfs", "foo.bar.boo-buzz", true}, + // ipns + {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.localhost:8080", "localhost:8080", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, + {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.dweb.link", "dweb.link", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, + // edge case check: public gateway under long TLD (see: https://publicsuffix.org) + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.ipfs.pvt.k12.ma.us", "dweb.ipfs.pvt.k12.ma.us", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, + {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.dweb.ipfs.pvt.k12.ma.us", "dweb.ipfs.pvt.k12.ma.us", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, + // dnslink in subdomain + {"en.wikipedia-on-ipfs.org.ipns.localhost:8080", "localhost:8080", "ipns", "en.wikipedia-on-ipfs.org", true}, + {"en.wikipedia-on-ipfs.org.ipns.localhost", "localhost", "ipns", "en.wikipedia-on-ipfs.org", true}, + {"dist.ipfs.io.ipns.localhost:8080", "localhost:8080", "ipns", "dist.ipfs.io", true}, + {"en.wikipedia-on-ipfs.org.ipns.dweb.link", "dweb.link", "ipns", "en.wikipedia-on-ipfs.org", true}, + // edge case check: public gateway under long TLD (see: https://publicsuffix.org) + {"foo.dweb.ipfs.pvt.k12.ma.us", "", "", "", false}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.ipfs.pvt.k12.ma.us", "dweb.ipfs.pvt.k12.ma.us", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, + {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.dweb.ipfs.pvt.k12.ma.us", "dweb.ipfs.pvt.k12.ma.us", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, + // other namespaces + {"api.localhost", "", "", "", false}, + {"peerid.p2p.localhost", "localhost", "p2p", "peerid", true}, + } { + gw, hostname, ns, rootID, ok := knownSubdomainDetails(test.hostHeader, knownGateways) + if ok != test.ok { + t.Errorf("knownSubdomainDetails(%s): ok is %t, expected %t", test.hostHeader, ok, test.ok) + } + if rootID != test.rootID { + t.Errorf("knownSubdomainDetails(%s): rootID is '%s', expected '%s'", test.hostHeader, rootID, test.rootID) + } + if ns != test.ns { + t.Errorf("knownSubdomainDetails(%s): ns is '%s', expected '%s'", test.hostHeader, ns, test.ns) + } + if hostname != test.hostname { + t.Errorf("knownSubdomainDetails(%s): hostname is '%s', expected '%s'", test.hostHeader, hostname, test.hostname) + } + if ok && gw.UseSubdomains != gwSpec.UseSubdomains { + t.Errorf("knownSubdomainDetails(%s): gw is %+v, expected %+v", test.hostHeader, gw, gwSpec) + } + } + +} diff --git a/gateway/core/corehttp/ipns_hostname.go b/gateway/core/corehttp/ipns_hostname.go deleted file mode 100644 index ddcd58c61..000000000 --- a/gateway/core/corehttp/ipns_hostname.go +++ /dev/null @@ -1,38 +0,0 @@ -package corehttp - -import ( - "context" - "net" - "net/http" - "strings" - - core "github.com/ipfs/go-ipfs/core" - namesys "github.com/ipfs/go-ipfs/namesys" - - nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" - isd "github.com/jbenet/go-is-domain" -) - -// IPNSHostnameOption rewrites an incoming request if its Host: header contains -// an IPNS name. -// The rewritten request points at the resolved name on the gateway handler. -func IPNSHostnameOption() ServeOption { - return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - childMux := http.NewServeMux() - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - ctx, cancel := context.WithCancel(n.Context()) - defer cancel() - - host := strings.SplitN(r.Host, ":", 2)[0] - if len(host) > 0 && isd.IsDomain(host) { - name := "/ipns/" + host - _, err := n.Namesys.Resolve(ctx, name, nsopts.Depth(1)) - if err == nil || err == namesys.ErrResolveRecursion { - r.URL.Path = name + r.URL.Path - } - } - childMux.ServeHTTP(w, r) - }) - return childMux, nil - } -} From 6ac071648e21beb66885056b0ab424f5c5a96ca0 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 11 Mar 2020 18:07:28 +0100 Subject: [PATCH 511/674] fix(gateway): curl without redirect on localhost When request is sent to http://localhost:8080/ipfs/$cid response has HTTP 301 status code and "Location" header with redirect destination at $cid.ipfs.localhost:8080 Redirect is followed by browsersi, but not by commandline tools. Status 301 is ignored by curl in default mode: it will print response and won't follow redirect, user needs to add -L for that. To fix curl, we return correct payload in body of HTTP 301 response, but set Clear-Site-Data header to ensure Origin sandbox can't be abused. This requires a surgical workaround: If Location header is present in ResponseWriter's Header map, we ensure http.ServeContent() returns HTTP 301 Context: https://github.com/ipfs/go-ipfs/pull/6982 License: MIT Signed-off-by: Marcin Rataj This commit was moved from ipfs/kubo@f9567a0a0fb12b2d27735708e85b9e16a84f528c --- gateway/core/corehttp/gateway_handler.go | 20 ++++++++++++++++++++ gateway/core/corehttp/hostname.go | 20 ++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index cf7420243..d3c4d2639 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -38,6 +38,25 @@ type gatewayHandler struct { api coreiface.CoreAPI } +// StatusResponseWriter enables us to override HTTP Status Code passed to +// WriteHeader function inside of http.ServeContent. Decision is based on +// presence of HTTP Headers such as Location. +type statusResponseWriter struct { + http.ResponseWriter +} + +func (sw *statusResponseWriter) WriteHeader(code int) { + // Check if we need to adjust Status Code to account for scheduled redirect + // This enables us to return payload along with HTTP 301 + // for subdomain redirect in web browsers while also returning body for cli + // tools which do not follow redirects by default (curl, wget). + redirect := sw.ResponseWriter.Header().Get("Location") + if redirect != "" && code == http.StatusOK { + code = http.StatusMovedPermanently + } + sw.ResponseWriter.WriteHeader(code) +} + func newGatewayHandler(c GatewayConfig, api coreiface.CoreAPI) *gatewayHandler { i := &gatewayHandler{ config: c, @@ -366,6 +385,7 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam } w.Header().Set("Content-Type", ctype) + w = &statusResponseWriter{w} http.ServeContent(w, req, name, modtime, content) } diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 910ba5bc8..143435106 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -95,8 +95,24 @@ func HostnameOption() ServeOption { // Yes, redirect if applicable // Example: dweb.link/ipfs/{cid} → {cid}.ipfs.dweb.link if newURL, ok := toSubdomainURL(r.Host, r.URL.Path, r); ok { - http.Redirect(w, r, newURL, http.StatusMovedPermanently) - return + // Just to be sure single Origin can't be abused in + // web browsers that ignored the redirect for some + // reason, Clear-Site-Data header clears browsing + // data (cookies, storage etc) associated with + // hostname's root Origin + // Note: we can't use "*" due to bug in Chromium: + // https://bugs.chromium.org/p/chromium/issues/detail?id=898503 + w.Header().Set("Clear-Site-Data", "\"cookies\", \"storage\"") + + // Set "Location" header with redirect destination. + // It is ignored by curl in default mode, but will + // be respected by user agents that follow + // redirects by default, namely web browsers + w.Header().Set("Location", newURL) + + // Note: we continue regular gateway processing: + // HTTP Status Code http.StatusMovedPermanently + // will be set later, in statusResponseWriter } } From 7ce444abd0f5b4ca1c93122b9e92769cc716c215 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Sat, 4 Apr 2020 01:55:36 +0200 Subject: [PATCH 512/674] HTTP API: Disallow GET requests on API This commit upgrades go-ipfs-cmds and configures the commands HTTP API Handler to only allow POST/OPTIONS, disallowing GET and others in the handling of command requests in the IPFS HTTP API (where before every type of request method was handled, with GET/POST/PUT/PATCH being equivalent). The Read-Only commands that the HTTP API attaches to the gateway endpoint will additional handled GET as they did before (but stop handling PUT,DELETEs). By limiting the request types we address the possibility that a website accessed by a browser abuses the IPFS API by issuing GET requests to it which have no Origin or Referrer set, and are thus bypass CORS and CSRF protections. This is a breaking change for clients that relay on GET requests against the HTTP endpoint (usually :5001). Applications integrating on top of the gateway-read-only API should still work (including cross-domain access). Co-Authored-By: Steven Allen Co-Authored-By: Marcin Rataj This commit was moved from ipfs/kubo@1b490476e5517931b8d31a6636e7008771db201d --- gateway/core/corehttp/commands.go | 18 ++++++++++++------ gateway/core/corehttp/webui.go | 3 ++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index d63099bfb..0f9b8d603 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -117,11 +117,17 @@ func patchCORSVars(c *cmdsHttp.ServerConfig, addr net.Addr) { c.SetAllowedOrigins(newOrigins...) } -func commandsOption(cctx oldcmds.Context, command *cmds.Command) ServeOption { +func commandsOption(cctx oldcmds.Context, command *cmds.Command, allowGet bool) ServeOption { return func(n *core.IpfsNode, l net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { cfg := cmdsHttp.NewServerConfig() - cfg.SetAllowedMethods(http.MethodGet, http.MethodPost, http.MethodPut) + cfg.AllowGet = allowGet + corsAllowedMethods := []string{http.MethodPost} + if allowGet { + corsAllowedMethods = append(corsAllowedMethods, http.MethodGet) + } + + cfg.SetAllowedMethods(corsAllowedMethods...) cfg.APIPath = APIPath rcfg, err := n.Repo.Config() if err != nil { @@ -140,15 +146,15 @@ func commandsOption(cctx oldcmds.Context, command *cmds.Command) ServeOption { } // CommandsOption constructs a ServerOption for hooking the commands into the -// HTTP server. +// HTTP server. It will NOT allow GET requests. func CommandsOption(cctx oldcmds.Context) ServeOption { - return commandsOption(cctx, corecommands.Root) + return commandsOption(cctx, corecommands.Root, false) } // CommandsROOption constructs a ServerOption for hooking the read-only commands -// into the HTTP server. +// into the HTTP server. It will allow GET requests. func CommandsROOption(cctx oldcmds.Context) ServeOption { - return commandsOption(cctx, corecommands.RootRO) + return commandsOption(cctx, corecommands.RootRO, true) } // CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/go-ipfs/` diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 21d3eeea6..4a31f719a 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/Qmexhq2sBHnXQbvyP2GfUdbnY7HCagH2Mw5vUNSBn2nxip" +const WebUIPath = "/ipfs/bafybeihpkhgv3jfnyx5qcexded7agjpwbgvtc3o6lnk6n3cs37fh4xx4fe" // this is a list of all past webUI paths. var WebUIPaths = []string{ @@ -33,6 +33,7 @@ var WebUIPaths = []string{ "/ipfs/QmcjeTciMNgEBe4xXvEaA4TQtwTRkXucx7DmKWViXSmX7m", "/ipfs/QmfNbSskgvTXYhuqP8tb9AKbCkyRcCy3WeiXwD9y5LeoqK", "/ipfs/QmPkojhjJkJ5LEGBDrAvdftrjAYmi9GU5Cq27mWvZTDieW", + "/ipfs/Qmexhq2sBHnXQbvyP2GfUdbnY7HCagH2Mw5vUNSBn2nxip", } var WebUIOption = RedirectOption("webui", WebUIPath) From ecb855b21a5a4722a802632fedb2520e532c4657 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Sat, 4 Apr 2020 02:06:06 +0200 Subject: [PATCH 513/674] corehttp: Gateway handler: add Allow headers when returning MethodNotAllowed Spec says that response with 405 must set Allow headers. This commit was moved from ipfs/kubo@73405436159b5953f6ed107f45d7aa3badf4bf44 --- gateway/core/corehttp/gateway_handler.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d3c4d2639..d26f21d54 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -127,6 +127,9 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if !i.config.Writable { status = http.StatusMethodNotAllowed errmsg = errmsg + "read only access" + w.Header().Add("Allow", http.MethodGet) + w.Header().Add("Allow", http.MethodHead) + w.Header().Add("Allow", http.MethodOptions) } else { status = http.StatusBadRequest errmsg = errmsg + "bad request for " + r.URL.Path From 4764185f1f630983206969a9aef8583171f6c184 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 14 Apr 2020 17:51:25 +0200 Subject: [PATCH 514/674] feat: webui v2.7.4 (supersedes v2.7.3) License: MIT Signed-off-by: Marcin Rataj This commit was moved from ipfs/kubo@7d397ac219f57bc1e74d7808dc17f228104e3bd6 --- gateway/core/corehttp/webui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 4a31f719a..5e9839a6d 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeihpkhgv3jfnyx5qcexded7agjpwbgvtc3o6lnk6n3cs37fh4xx4fe" +const WebUIPath = "/ipfs/bafybeigxqbvc6qxk2wkdyzpkh7mr7zh5pxbvpjb6a6mxdtpwhlqaf4qj5a" // this is a list of all past webUI paths. var WebUIPaths = []string{ From e1dd5d93264450172cf44608c388416ff72cbb9f Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 15 Apr 2020 13:42:29 +0200 Subject: [PATCH 515/674] fix: subdomain redirect for dir CIDs Closes #7164 License: MIT Signed-off-by: Marcin Rataj This commit was moved from ipfs/kubo@8290ec11c376d8246a7e592eb4e6472479833077 --- gateway/core/corehttp/gateway_handler.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d26f21d54..8c7cea134 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -342,6 +342,16 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request BackLink: backLink, Hash: hash, } + + // See statusResponseWriter.WriteHeader + // and https://github.com/ipfs/go-ipfs/issues/7164 + // Note: this needs to occur before listingTemplate.Execute otherwise we get + // superfluous response.WriteHeader call from prometheus/client_golang + if w.Header().Get("Location") != "" { + w.WriteHeader(http.StatusMovedPermanently) + return + } + err = listingTemplate.Execute(w, tplData) if err != nil { internalWebError(w, err) From 0431eec7f9f4174c151dee6dceacfff9a1a0a1c8 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 17 Apr 2020 20:10:21 +0100 Subject: [PATCH 516/674] feat: webui 2.7.5 This commit was moved from ipfs/kubo@135c4519973fdb05e354770c9fe220349272a768 --- gateway/core/corehttp/webui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 5e9839a6d..02f2da73a 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeigxqbvc6qxk2wkdyzpkh7mr7zh5pxbvpjb6a6mxdtpwhlqaf4qj5a" +const WebUIPath = "/ipfs/bafybeidatpz2hli6fgu3zul5woi27ujesdf5o5a7bu622qj6ugharciwjq" // this is a list of all past webUI paths. var WebUIPaths = []string{ From df6d11ff8ea83fe6faf6a6f4ae075bf4c7239ef0 Mon Sep 17 00:00:00 2001 From: Dimitris Apostolou Date: Sat, 18 Apr 2020 17:45:01 +0300 Subject: [PATCH 517/674] Fix typos and cleanup This commit was moved from ipfs/kubo@1e437c7e972aa08d1de59f016d3297cf9b5a3106 --- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/gateway_handler.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index d99a07691..1b0a79ee6 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -73,7 +73,7 @@ func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...Serv return err } - // we might have listened to /tcp/0 - lets see what we are listing on + // we might have listened to /tcp/0 - let's see what we are listing on addr = list.Multiaddr() fmt.Printf("API server listening on %s\n", addr) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 8c7cea134..f91d42b61 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -228,7 +228,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request w.Header().Set("Etag", etag) // set these headers _after_ the error, for we may just not have it - // and dont want the client to cache a 500 response... + // and don't want the client to cache a 500 response... // and only if it's /ipfs! // TODO: break this out when we split /ipfs /ipns routes. modtime := time.Now() @@ -321,7 +321,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // keep backlink case len(pathSplit) == 4 && pathSplit[3] == "": // url: /ipfs/$hash/ - // add the correct link depending on wether the path ends with a slash + // add the correct link depending on whether the path ends with a slash default: if strings.HasSuffix(backLink, "/") { backLink += "./.." From 18d90d85683096ad6fc18c3e68a50a82838c2b38 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sun, 26 Apr 2020 16:09:02 -0700 Subject: [PATCH 518/674] feat: always show the hash Previously, we only showed this /ipns paths. However, knowing the hash of the current directory is useful regardless. This commit was moved from ipfs/kubo@d8bc5c991e29c5de0c090ff851f6abdf00180a67 --- gateway/core/corehttp/gateway_handler.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index f91d42b61..f34bbeb76 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -330,10 +330,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } } - var hash string - if !strings.HasPrefix(urlPath, ipfsPathPrefix) { - hash = resolvedPath.Cid().String() - } + hash := resolvedPath.Cid().String() // See comment above where originalUrlPath is declared. tplData := listingTemplateData{ From 6161b22ad3a687501d29e5de1e43d02ec961d4d6 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sun, 26 Apr 2020 16:11:20 -0700 Subject: [PATCH 519/674] feat: show the absolute path every time Even for dnslink websites. fixes https://github.com/ipfs/go-ipfs/issues/7205 This commit was moved from ipfs/kubo@46ae021733e825cb46c915518897816b191c60ef --- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index f34bbeb76..2729f04e6 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -335,7 +335,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // See comment above where originalUrlPath is declared. tplData := listingTemplateData{ Listing: dirListing, - Path: originalUrlPath, + Path: urlPath, BackLink: backLink, Hash: hash, } diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index daf1af07c..edae35e3f 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -378,7 +378,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s := string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /foo? #<'/") { + if !strings.Contains(s, "Index of /ipns/example.net/foo? #<'/") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { @@ -444,7 +444,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s = string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /foo? #<'/bar/") { + if !strings.Contains(s, "Index of /ipns/example.net/foo? #<'/bar/") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { @@ -478,7 +478,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s = string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /good-prefix") { + if !strings.Contains(s, "Index of /ipns/example.net") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { From d6424eb2bdbd0cdcdc95ec5c46497f1d8fbd16c9 Mon Sep 17 00:00:00 2001 From: Gowtham G Date: Fri, 1 May 2020 12:19:36 +0530 Subject: [PATCH 520/674] Fixes #7252 - Uses gabriel-vasile/mimetype to support additional content types This commit was moved from ipfs/kubo@2e87ac88a35f15d06702594c2ddad27c2606ee90 --- gateway/core/corehttp/gateway_handler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 2729f04e6..561f46e19 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -3,6 +3,7 @@ package corehttp import ( "context" "fmt" + "github.com/gabriel-vasile/mimetype" "io" "mime" "net/http" @@ -378,7 +379,9 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam if ctype == "" { buf := make([]byte, 512) n, _ := io.ReadFull(content, buf[:]) - ctype = http.DetectContentType(buf[:n]) + // uses https://github.com/gabriel-vasile/mimetype library to determine the content type. + // Fixes https://github.com/ipfs/go-ipfs/issues/7252 + ctype = mimetype.Detect(buf[:n]).String() _, err := content.Seek(0, io.SeekStart) if err != nil { http.Error(w, "seeker can't seek", http.StatusInternalServerError) From 91707d75974f804cca95cc71c9052c6ace3eb3e3 Mon Sep 17 00:00:00 2001 From: Gowtham G Date: Fri, 1 May 2020 20:29:32 +0530 Subject: [PATCH 521/674] #7252 - read content directly instead of sending 512bytes This commit was moved from ipfs/kubo@9201b1dde6f994d918825488fa879431bcb7e8b7 --- gateway/core/corehttp/gateway_handler.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 561f46e19..b401e3455 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -377,12 +377,16 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam } else { ctype = mime.TypeByExtension(gopath.Ext(name)) if ctype == "" { - buf := make([]byte, 512) - n, _ := io.ReadFull(content, buf[:]) // uses https://github.com/gabriel-vasile/mimetype library to determine the content type. // Fixes https://github.com/ipfs/go-ipfs/issues/7252 - ctype = mimetype.Detect(buf[:n]).String() - _, err := content.Seek(0, io.SeekStart) + mimeType, err := mimetype.DetectReader(content) + if err != nil { + http.Error(w, "cannot detect content-type", http.StatusInternalServerError) + return + } + + ctype = mimeType.String() + _, err = content.Seek(0, io.SeekStart) if err != nil { http.Error(w, "seeker can't seek", http.StatusInternalServerError) return From d9b848394e18e92e923f8a3cdf684a70c300b892 Mon Sep 17 00:00:00 2001 From: Gowtham G Date: Fri, 1 May 2020 22:37:20 +0530 Subject: [PATCH 522/674] #7252 - print error message This commit was moved from ipfs/kubo@214d29ebf8859ff0550c9b0f2fd21958d67b370a --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index b401e3455..f956ca80a 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -381,7 +381,7 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam // Fixes https://github.com/ipfs/go-ipfs/issues/7252 mimeType, err := mimetype.DetectReader(content) if err != nil { - http.Error(w, "cannot detect content-type", http.StatusInternalServerError) + http.Error(w, fmt.Sprintf("cannot detect content-type: %s", err.Error()), http.StatusInternalServerError) return } From 973bcef747b657026d35c8d72037f4fc5a0582cf Mon Sep 17 00:00:00 2001 From: Gowtham G Date: Sat, 2 May 2020 14:19:01 +0530 Subject: [PATCH 523/674] optimize import order This commit was moved from ipfs/kubo@e93f2002f592e018e97eecb30d6a12f48908af23 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index f956ca80a..2c3821ea0 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -3,7 +3,6 @@ package corehttp import ( "context" "fmt" - "github.com/gabriel-vasile/mimetype" "io" "mime" "net/http" @@ -16,6 +15,7 @@ import ( "time" humanize "github.com/dustin/go-humanize" + "github.com/gabriel-vasile/mimetype" "github.com/ipfs/go-cid" files "github.com/ipfs/go-ipfs-files" dag "github.com/ipfs/go-merkledag" From 156284e087961a01bfdea17d843c9ab6fa8a6e3a Mon Sep 17 00:00:00 2001 From: JP Hastings-Spital Date: Sat, 9 May 2020 00:16:25 +0100 Subject: [PATCH 524/674] Gateway renders pretty 404 pages if available In the same way that an `index.html` file is rendered, if one is present, when the requested path is a directory, now an `ipfs-404.html` file is rendered if the requested file is not present within the specified IPFS object. `ipfs-404.html` files are looked for in the directory of the requested path and each parent until one is found, falling back on the well-known 404 error message. License: MIT Signed-off-by: JP Hastings-Spital This commit was moved from ipfs/kubo@dfceafdbd3debca60959bdb9ecb28dd4c431c163 --- gateway/core/corehttp/gateway_handler.go | 81 ++++++++++++++++++++++++ gateway/core/corehttp/gateway_test.go | 64 +++++++++++++++++++ 2 files changed, 145 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 2c3821ea0..f5624f5a9 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -11,6 +11,7 @@ import ( gopath "path" "regexp" "runtime/debug" + "strconv" "strings" "time" @@ -203,6 +204,10 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request webError(w, "ipfs resolve -r "+escapedURLPath, err, http.StatusServiceUnavailable) return default: + if i.servePretty404IfPresent(w, r, parsedPath) { + return + } + webError(w, "ipfs resolve -r "+escapedURLPath, err, http.StatusNotFound) return } @@ -290,6 +295,10 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } + if i.servePretty404IfPresent(w, r, parsedPath) { + return + } + // storage for directory listing var dirListing []directoryItem dirit := dir.Entries() @@ -406,6 +415,36 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, nam http.ServeContent(w, req, name, modtime, content) } +func (i *gatewayHandler) servePretty404IfPresent(w http.ResponseWriter, r *http.Request, parsedPath ipath.Path) bool { + resolved404Path, ctype, err := i.searchUpTreeFor404(r, parsedPath) + if err != nil { + return false + } + + dr, err := i.api.Unixfs().Get(r.Context(), resolved404Path) + if err != nil { + return false + } + defer dr.Close() + + f, ok := dr.(files.File) + if !ok { + return false + } + + size, err := f.Size() + if err != nil { + return false + } + + log.Debugf("using pretty 404 file for %s", parsedPath.String()) + w.Header().Set("Content-Type", ctype) + w.Header().Set("Content-Length", strconv.FormatInt(size, 10)) + w.WriteHeader(http.StatusNotFound) + _, err = io.CopyN(w, f, size) + return err == nil +} + func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { p, err := i.api.Unixfs().Add(r.Context(), files.NewReaderFile(r.Body)) if err != nil { @@ -619,3 +658,45 @@ func getFilename(s string) string { } return gopath.Base(s) } + +func (i *gatewayHandler) searchUpTreeFor404(r *http.Request, parsedPath ipath.Path) (ipath.Resolved, string, error) { + filename404, ctype, err := preferred404Filename(r.Header.Values("Accept")) + if err != nil { + return nil, "", err + } + + pathComponents := strings.Split(parsedPath.String(), "/") + + for idx := len(pathComponents); idx >= 3; idx-- { + pretty404 := gopath.Join(append(pathComponents[0:idx], filename404)...) + parsed404Path := ipath.New("/" + pretty404) + if parsed404Path.IsValid() != nil { + break + } + resolvedPath, err := i.api.ResolvePath(r.Context(), parsed404Path) + if err != nil { + continue + } + return resolvedPath, ctype, nil + } + + return nil, "", fmt.Errorf("no pretty 404 in any parent folder") +} + +func preferred404Filename(acceptHeaders []string) (string, string, error) { + // If we ever want to offer a 404 file for a different content type + // then this function will need to parse q weightings, but for now + // the presence of anything matching HTML is enough. + for _, acceptHeader := range acceptHeaders { + accepted := strings.Split(acceptHeader, ",") + for _, spec := range accepted { + contentType := strings.SplitN(spec, ";", 1)[0] + switch contentType { + case "*/*", "text/*", "text/html": + return "ipfs-404.html", "text/html", nil + } + } + } + + return "", "", fmt.Errorf("there is no 404 file for the requested content types") +} diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index edae35e3f..ecbb47aaa 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -235,6 +235,70 @@ func TestGatewayGet(t *testing.T) { } } +func TestPretty404(t *testing.T) { + ns := mockNamesys{} + ts, api, ctx := newTestServerAndNode(t, ns) + defer ts.Close() + + f1 := files.NewMapDirectory(map[string]files.Node{ + "ipfs-404.html": files.NewBytesFile([]byte("Custom 404")), + "deeper": files.NewMapDirectory(map[string]files.Node{ + "ipfs-404.html": files.NewBytesFile([]byte("Deep custom 404")), + }), + }) + + k, err := api.Unixfs().Add(ctx, f1) + if err != nil { + t.Fatal(err) + } + + host := "example.net" + ns["/ipns/"+host] = path.FromString(k.String()) + + for _, test := range []struct { + path string + accept string + status int + text string + }{ + {"/ipfs-404.html", "text/html", http.StatusOK, "Custom 404"}, + {"/nope", "text/html", http.StatusNotFound, "Custom 404"}, + {"/nope", "text/*", http.StatusNotFound, "Custom 404"}, + {"/nope", "*/*", http.StatusNotFound, "Custom 404"}, + {"/nope", "application/json", http.StatusNotFound, "ipfs resolve -r /ipns/example.net/nope: no link named \"nope\" under QmcmnF7XG5G34RdqYErYDwCKNFQ6jb8oKVR21WAJgubiaj\n"}, + {"/deeper/nope", "text/html", http.StatusNotFound, "Deep custom 404"}, + {"/deeper/", "text/html", http.StatusNotFound, "Deep custom 404"}, + {"/deeper", "text/html", http.StatusNotFound, "Deep custom 404"}, + {"/nope/nope", "text/html", http.StatusNotFound, "Custom 404"}, + } { + var c http.Client + req, err := http.NewRequest("GET", ts.URL+test.path, nil) + if err != nil { + t.Fatal(err) + } + req.Header.Add("Accept", test.accept) + req.Host = host + resp, err := c.Do(req) + + if err != nil { + t.Fatalf("error requesting %s: %s", test.path, err) + } + + defer resp.Body.Close() + if resp.StatusCode != test.status { + t.Fatalf("got %d, expected %d, from %s", resp.StatusCode, test.status, test.path) + } + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + t.Fatalf("error reading response from %s: %s", test.path, err) + } + + if string(body) != test.text { + t.Fatalf("unexpected response body from %s: got %q, expected %q", test.path, body, test.text) + } + } +} + func TestIPNSHostnameRedirect(t *testing.T) { ns := mockNamesys{} ts, api, ctx := newTestServerAndNode(t, ns) From 85cba15eadd784e7b7b75fb4a3046f0ccdf65e3d Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 20 May 2020 13:21:50 +0200 Subject: [PATCH 525/674] fix(gateway): fix status code for HEAD on redirects Report a consistent status code for HEAD requests that end up in a redirect. This commit was moved from ipfs/kubo@7c7888c4db5a0d552ec174687275549fdd0908fd --- gateway/core/corehttp/gateway_handler.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index f5624f5a9..e24a999d5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -291,6 +291,15 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } + // See statusResponseWriter.WriteHeader + // and https://github.com/ipfs/go-ipfs/issues/7164 + // Note: this needs to occur before listingTemplate.Execute otherwise we get + // superfluous response.WriteHeader call from prometheus/client_golang + if w.Header().Get("Location") != "" { + w.WriteHeader(http.StatusMovedPermanently) + return + } + if r.Method == http.MethodHead { return } @@ -350,15 +359,6 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request Hash: hash, } - // See statusResponseWriter.WriteHeader - // and https://github.com/ipfs/go-ipfs/issues/7164 - // Note: this needs to occur before listingTemplate.Execute otherwise we get - // superfluous response.WriteHeader call from prometheus/client_golang - if w.Header().Get("Location") != "" { - w.WriteHeader(http.StatusMovedPermanently) - return - } - err = listingTemplate.Execute(w, tplData) if err != nil { internalWebError(w, err) From c6fc093eea96657cf58dfcf649663ab38c15e809 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 18 May 2020 13:58:09 +0200 Subject: [PATCH 526/674] fix(gateway): ensure directory listings have Content-Type text/html Files already have an explicit Content-Type set. Be sure to do this for directory listings as well to avoid a fallback to autodetection in net/http. That fallback fails when a ResponseWriter is installed that performs compression. This commit was moved from ipfs/kubo@d4952f2a73b2dd33d8c35ab1bae3bc381fdb5088 --- gateway/core/corehttp/gateway_handler.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index e24a999d5..78afb2bf7 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -300,6 +300,9 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } + // A HTML directory index will be presented, be sure to set the correct + // type instead of relying on autodetection (which may fail). + w.Header().Set("Content-Type", "text/html") if r.Method == http.MethodHead { return } From 12f186a523dde78aca86673a5591eaf594be2125 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 20 May 2020 19:07:49 -0700 Subject: [PATCH 527/674] fix: support directory listings even if a 404 page is present fixes https://github.com/ipfs/go-ipfs/pull/4233#issuecomment-631454543 Basically, there's a trade-off here: 1. We can support directory listings while supporting 404 pages (this PR). 2. If a 404 page is present, directory listings don't work. Given that option 1 is more flexible and users shouldn't be _too_ confused if they land on a directory with no index.html page, I've gone with that option. This commit was moved from ipfs/kubo@6a2fe0a20de795732477c707b606eb947a326402 --- gateway/core/corehttp/gateway_handler.go | 4 ---- gateway/core/corehttp/gateway_test.go | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 78afb2bf7..ba264c095 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -307,10 +307,6 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } - if i.servePretty404IfPresent(w, r, parsedPath) { - return - } - // storage for directory listing var dirListing []directoryItem dirit := dir.Entries() diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index ecbb47aaa..a8a07aa48 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -267,8 +267,8 @@ func TestPretty404(t *testing.T) { {"/nope", "*/*", http.StatusNotFound, "Custom 404"}, {"/nope", "application/json", http.StatusNotFound, "ipfs resolve -r /ipns/example.net/nope: no link named \"nope\" under QmcmnF7XG5G34RdqYErYDwCKNFQ6jb8oKVR21WAJgubiaj\n"}, {"/deeper/nope", "text/html", http.StatusNotFound, "Deep custom 404"}, - {"/deeper/", "text/html", http.StatusNotFound, "Deep custom 404"}, - {"/deeper", "text/html", http.StatusNotFound, "Deep custom 404"}, + {"/deeper/", "text/html", http.StatusOK, ""}, + {"/deeper", "text/html", http.StatusOK, ""}, {"/nope/nope", "text/html", http.StatusNotFound, "Custom 404"}, } { var c http.Client @@ -293,7 +293,7 @@ func TestPretty404(t *testing.T) { t.Fatalf("error reading response from %s: %s", test.path, err) } - if string(body) != test.text { + if test.text != "" && string(body) != test.text { t.Fatalf("unexpected response body from %s: got %q, expected %q", test.path, body, test.text) } } From de69041f1d1abcfd4b98f8b7b3f7043809bfd433 Mon Sep 17 00:00:00 2001 From: Peter Rabbitson Date: Sun, 23 Jun 2019 21:17:39 +0200 Subject: [PATCH 528/674] Include the git blob id of the dir-index bundle in the ETag While the content of raw files retrieved via the gateway should never change, the look and feel of the directory index can and will change between versions of go-ipfs. Incorporate the hash of assets/bindata.go into the ETag when appropriate This commit was moved from ipfs/kubo@2d5f8b4ebe015817b2ea285a4d589e5d796bf8a3 --- gateway/core/corehttp/gateway_handler.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ba264c095..a1549efdd 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -19,6 +19,7 @@ import ( "github.com/gabriel-vasile/mimetype" "github.com/ipfs/go-cid" files "github.com/ipfs/go-ipfs-files" + assets "github.com/ipfs/go-ipfs/assets" dag "github.com/ipfs/go-merkledag" mfs "github.com/ipfs/go-mfs" path "github.com/ipfs/go-path" @@ -222,16 +223,26 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request defer dr.Close() - // Check etag send back to us - etag := "\"" + resolvedPath.Cid().String() + "\"" - if r.Header.Get("If-None-Match") == etag || r.Header.Get("If-None-Match") == "W/"+etag { + var responseEtag string + + // we need to figure out whether this is a directory before doing most of the heavy lifting below + _, ok := dr.(files.Directory) + + if ok && assets.BindataVersionHash != "" { + responseEtag = `"DirIndex-` + assets.BindataVersionHash + `_CID-` + resolvedPath.Cid().String() + `"` + } else { + responseEtag = `"` + resolvedPath.Cid().String() + `"` + } + + // Check etag sent back to us + if r.Header.Get("If-None-Match") == responseEtag || r.Header.Get("If-None-Match") == `W/`+responseEtag { w.WriteHeader(http.StatusNotModified) return } i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("X-IPFS-Path", urlPath) - w.Header().Set("Etag", etag) + w.Header().Set("Etag", responseEtag) // set these headers _after_ the error, for we may just not have it // and don't want the client to cache a 500 response... From 20eab31a219e937e19376bef5da3146d2c760b12 Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Thu, 28 May 2020 10:53:25 +0900 Subject: [PATCH 529/674] chore: update WebUI to 2.8.0 This commit was moved from ipfs/kubo@58aac04a53d60d683cbe64fc26f6b0abac4e855b --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 02f2da73a..22143e49a 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeidatpz2hli6fgu3zul5woi27ujesdf5o5a7bu622qj6ugharciwjq" +const WebUIPath = "/ipfs/bafybeicp23nbcxtt2k2twyfivcbrc6kr3l5lnaiv3ozvwbemtrb7v52r6i" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeidatpz2hli6fgu3zul5woi27ujesdf5o5a7bu622qj6ugharciwjq", "/ipfs/QmfQkD8pBSBCBxWEwFSu4XaDVSWK6bjnNuaWZjMyQbyDub", "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ", "/ipfs/QmenEBWcAk3tN94fSKpKFtUMwty1qNwSYw3DMDFV6cPBXA", From 787581221fe2519c74aee10cb9441bce3914fbb9 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 28 May 2020 23:04:35 +0200 Subject: [PATCH 530/674] feat: webui v2.9.0 This commit was moved from ipfs/kubo@0f76ed79f97de7d2c886385ada0030b2e8ee42c8 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 22143e49a..f94df7850 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeicp23nbcxtt2k2twyfivcbrc6kr3l5lnaiv3ozvwbemtrb7v52r6i" +const WebUIPath = "/ipfs/bafybeigkbbjnltbd4ewfj7elajsbnjwinyk6tiilczkqsibf3o7dcr6nn4" // v2.9.0 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeicp23nbcxtt2k2twyfivcbrc6kr3l5lnaiv3ozvwbemtrb7v52r6i", "/ipfs/bafybeidatpz2hli6fgu3zul5woi27ujesdf5o5a7bu622qj6ugharciwjq", "/ipfs/QmfQkD8pBSBCBxWEwFSu4XaDVSWK6bjnNuaWZjMyQbyDub", "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ", From 4e3488c9c0e9a31410100342a3722b3748ecc0de Mon Sep 17 00:00:00 2001 From: Shotaro Yamada Date: Thu, 28 May 2020 10:53:25 +0900 Subject: [PATCH 531/674] chore: update WebUI to 2.8.0 (cherry picked from commit 20eab31a219e937e19376bef5da3146d2c760b12) This commit was moved from ipfs/kubo@bd9382fe41e2946ac80ee4156ed4c11d3defc311 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 02f2da73a..22143e49a 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeidatpz2hli6fgu3zul5woi27ujesdf5o5a7bu622qj6ugharciwjq" +const WebUIPath = "/ipfs/bafybeicp23nbcxtt2k2twyfivcbrc6kr3l5lnaiv3ozvwbemtrb7v52r6i" // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeidatpz2hli6fgu3zul5woi27ujesdf5o5a7bu622qj6ugharciwjq", "/ipfs/QmfQkD8pBSBCBxWEwFSu4XaDVSWK6bjnNuaWZjMyQbyDub", "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ", "/ipfs/QmenEBWcAk3tN94fSKpKFtUMwty1qNwSYw3DMDFV6cPBXA", From 2af18acd26a6af722c9dc9ed4a7ac6c41e01cf15 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 28 May 2020 23:04:35 +0200 Subject: [PATCH 532/674] feat: webui v2.9.0 (cherry picked from commit 787581221fe2519c74aee10cb9441bce3914fbb9) This commit was moved from ipfs/kubo@5be7e0f8dea4595496dcfa1e52a9380e1f83e551 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 22143e49a..f94df7850 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeicp23nbcxtt2k2twyfivcbrc6kr3l5lnaiv3ozvwbemtrb7v52r6i" +const WebUIPath = "/ipfs/bafybeigkbbjnltbd4ewfj7elajsbnjwinyk6tiilczkqsibf3o7dcr6nn4" // v2.9.0 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeicp23nbcxtt2k2twyfivcbrc6kr3l5lnaiv3ozvwbemtrb7v52r6i", "/ipfs/bafybeidatpz2hli6fgu3zul5woi27ujesdf5o5a7bu622qj6ugharciwjq", "/ipfs/QmfQkD8pBSBCBxWEwFSu4XaDVSWK6bjnNuaWZjMyQbyDub", "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ", From 67db99d861138173f075ed07e6c8813fc0ac4c45 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 17 Jun 2020 19:44:28 -0700 Subject: [PATCH 533/674] fix: use the correct context when resolving dnsaddr links This commit was moved from ipfs/kubo@84341d0c5a66fdf88278ccfba8f1d9703b8fc8e1 --- gateway/core/corehttp/hostname.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 143435106..d8656da23 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -124,7 +124,7 @@ func HostnameOption() ServeOption { // Not a whitelisted path // Try DNSLink, if it was not explicitly disabled for the hostname - if !gw.NoDNSLink && isDNSLinkRequest(n.Context(), coreApi, r) { + if !gw.NoDNSLink && isDNSLinkRequest(r.Context(), coreApi, r) { // rewrite path and handle as DNSLink r.URL.Path = "/ipns/" + stripPort(r.Host) + r.URL.Path childMux.ServeHTTP(w, r) @@ -176,7 +176,7 @@ func HostnameOption() ServeOption { // 1. is wildcard DNSLink enabled (Gateway.NoDNSLink=false)? // 2. does Host header include a fully qualified domain name (FQDN)? // 3. does DNSLink record exist in DNS? - if !cfg.Gateway.NoDNSLink && isDNSLinkRequest(n.Context(), coreApi, r) { + if !cfg.Gateway.NoDNSLink && isDNSLinkRequest(r.Context(), coreApi, r) { // rewrite path and handle as DNSLink r.URL.Path = "/ipns/" + stripPort(r.Host) + r.URL.Path childMux.ServeHTTP(w, r) From b2c1ae60f1dc08e44bb8a5d367c622f3594baca0 Mon Sep 17 00:00:00 2001 From: Rafael Ramalho Date: Mon, 22 Jun 2020 17:39:30 +0100 Subject: [PATCH 534/674] chore: bump webui version This commit was moved from ipfs/kubo@cc4a136360697ec7633fe19db80555de2af5e58b --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index f94df7850..e00cf788f 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeigkbbjnltbd4ewfj7elajsbnjwinyk6tiilczkqsibf3o7dcr6nn4" // v2.9.0 +const WebUIPath = "/ipfs/bafybeid6luolenf4fcsuaw5rgdwpqbyerce4x3mi3hxfdtp5pwco7h7qyq" // v2.10.0 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeigkbbjnltbd4ewfj7elajsbnjwinyk6tiilczkqsibf3o7dcr6nn4", "/ipfs/bafybeicp23nbcxtt2k2twyfivcbrc6kr3l5lnaiv3ozvwbemtrb7v52r6i", "/ipfs/bafybeidatpz2hli6fgu3zul5woi27ujesdf5o5a7bu622qj6ugharciwjq", "/ipfs/QmfQkD8pBSBCBxWEwFSu4XaDVSWK6bjnNuaWZjMyQbyDub", From b6d36d97fbd1da2fd1b700ebda97ba11ec5f2e9f Mon Sep 17 00:00:00 2001 From: Rafael Ramalho Date: Tue, 23 Jun 2020 16:28:38 +0100 Subject: [PATCH 535/674] chore:bump webui version to 2.10.1 This commit was moved from ipfs/kubo@4c38ea748a6d7f6d5b9d4900dc77f976d049d427 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index e00cf788f..2728bc7b3 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeid6luolenf4fcsuaw5rgdwpqbyerce4x3mi3hxfdtp5pwco7h7qyq" // v2.10.0 +const WebUIPath = "/ipfs/bafybeibnnxd4etu4tq5fuhu3z5p4rfu3buabfkeyr3o3s4h6wtesvvw6mu" // v2.10.1 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeid6luolenf4fcsuaw5rgdwpqbyerce4x3mi3hxfdtp5pwco7h7qyq", "/ipfs/bafybeigkbbjnltbd4ewfj7elajsbnjwinyk6tiilczkqsibf3o7dcr6nn4", "/ipfs/bafybeicp23nbcxtt2k2twyfivcbrc6kr3l5lnaiv3ozvwbemtrb7v52r6i", "/ipfs/bafybeidatpz2hli6fgu3zul5woi27ujesdf5o5a7bu622qj6ugharciwjq", From 84e3c2244d29fc7da570eb0c4e3f85f4d47d3a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Wed, 1 Jul 2020 12:52:14 +0200 Subject: [PATCH 536/674] feat: support X-Forwarded-Host when doing gateway redirect This commit was moved from ipfs/kubo@87dfc46e037c06e7580dcb645f967c736a3830af --- gateway/core/corehttp/hostname.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index d8656da23..edcd8b718 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -81,8 +81,15 @@ func HostnameOption() ServeOption { // and the paths that they serve "gateway" content on. // That way, we can use DNSLink for everything else. + // Support X-Forwarded-Host if added by a reverse proxy + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host + host := r.Host + if xHost := r.Header.Get("X-Forwarded-Host"); xHost != "" { + host = xHost + } + // HTTP Host & Path check: is this one of our "known gateways"? - if gw, ok := isKnownHostname(r.Host, knownGateways); ok { + if gw, ok := isKnownHostname(host, knownGateways); ok { // This is a known gateway but request is not using // the subdomain feature. @@ -94,7 +101,7 @@ func HostnameOption() ServeOption { if gw.UseSubdomains { // Yes, redirect if applicable // Example: dweb.link/ipfs/{cid} → {cid}.ipfs.dweb.link - if newURL, ok := toSubdomainURL(r.Host, r.URL.Path, r); ok { + if newURL, ok := toSubdomainURL(host, r.URL.Path, r); ok { // Just to be sure single Origin can't be abused in // web browsers that ignored the redirect for some // reason, Clear-Site-Data header clears browsing @@ -124,9 +131,9 @@ func HostnameOption() ServeOption { // Not a whitelisted path // Try DNSLink, if it was not explicitly disabled for the hostname - if !gw.NoDNSLink && isDNSLinkRequest(r.Context(), coreApi, r) { + if !gw.NoDNSLink && isDNSLinkRequest(r.Context(), coreApi, host) { // rewrite path and handle as DNSLink - r.URL.Path = "/ipns/" + stripPort(r.Host) + r.URL.Path + r.URL.Path = "/ipns/" + stripPort(host) + r.URL.Path childMux.ServeHTTP(w, r) return } @@ -138,7 +145,7 @@ func HostnameOption() ServeOption { // HTTP Host check: is this one of our subdomain-based "known gateways"? // Example: {cid}.ipfs.localhost, {cid}.ipfs.dweb.link - if gw, hostname, ns, rootID, ok := knownSubdomainDetails(r.Host, knownGateways); ok { + if gw, hostname, ns, rootID, ok := knownSubdomainDetails(host, knownGateways); ok { // Looks like we're using known subdomain gateway. // Assemble original path prefix. @@ -176,9 +183,9 @@ func HostnameOption() ServeOption { // 1. is wildcard DNSLink enabled (Gateway.NoDNSLink=false)? // 2. does Host header include a fully qualified domain name (FQDN)? // 3. does DNSLink record exist in DNS? - if !cfg.Gateway.NoDNSLink && isDNSLinkRequest(r.Context(), coreApi, r) { + if !cfg.Gateway.NoDNSLink && isDNSLinkRequest(r.Context(), coreApi, host) { // rewrite path and handle as DNSLink - r.URL.Path = "/ipns/" + stripPort(r.Host) + r.URL.Path + r.URL.Path = "/ipns/" + stripPort(host) + r.URL.Path childMux.ServeHTTP(w, r) return } @@ -236,8 +243,8 @@ func knownSubdomainDetails(hostname string, knownGateways map[string]config.Gate // isDNSLinkRequest returns bool that indicates if request // should return data from content path listed in DNSLink record (if exists) -func isDNSLinkRequest(ctx context.Context, ipfs iface.CoreAPI, r *http.Request) bool { - fqdn := stripPort(r.Host) +func isDNSLinkRequest(ctx context.Context, ipfs iface.CoreAPI, host string) bool { + fqdn := stripPort(host) if len(fqdn) == 0 && !isd.IsDomain(fqdn) { return false } From c1cfe2f170de6cca072a470280510fdd9035b057 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 25 May 2020 16:15:34 +0200 Subject: [PATCH 537/674] feat: support ED25519 libp2p-key in subdomains This: - adds subdomain gateway support for ED25519 CIDs in a way that fits in a single DNS label to enable TLS for every IPNS website. - cleans up subdomain redirect logic and adds more explicit error handling. TL;DR on router logic: When CID is longer than 63 characters, router at /ipfs/* and /ipns/* converts to Base36, and if that does not help, returns a human readable 400 Bad Request error. Addressing code review: https://github.com/ipfs/go-ipfs/pull/7441#pullrequestreview-440043209 refactor: use b36 for all libp2p-keys in subdomains Consensus reached in https://github.com/ipfs/go-ipfs/pull/7441#discussion_r452372828 https://github.com/ipfs/go-ipfs/pull/7441#discussion_r451477890 https://github.com/ipfs/go-ipfs/pull/7441#discussion_r452500272 This commit was moved from ipfs/kubo@231fab811d83322e61fe8d9c65d7bcd9fd6d243c --- gateway/core/corehttp/hostname.go | 137 +++++++++++++++++++------ gateway/core/corehttp/hostname_test.go | 54 ++++++++-- 2 files changed, 148 insertions(+), 43 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index edcd8b718..f29b4d11f 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -41,12 +41,15 @@ var defaultKnownGateways = map[string]config.GatewaySpec{ "dweb.link": subdomainGatewaySpec, } +// Label's max length in DNS (https://tools.ietf.org/html/rfc1034#page-7) +const dnsLabelMaxLength int = 63 + // HostnameOption rewrites an incoming request based on the Host header. func HostnameOption() ServeOption { return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { childMux := http.NewServeMux() - coreApi, err := coreapi.NewCoreAPI(n) + coreAPI, err := coreapi.NewCoreAPI(n) if err != nil { return nil, err } @@ -101,7 +104,12 @@ func HostnameOption() ServeOption { if gw.UseSubdomains { // Yes, redirect if applicable // Example: dweb.link/ipfs/{cid} → {cid}.ipfs.dweb.link - if newURL, ok := toSubdomainURL(host, r.URL.Path, r); ok { + newURL, err := toSubdomainURL(host, r.URL.Path, r) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + if newURL != "" { // Just to be sure single Origin can't be abused in // web browsers that ignored the redirect for some // reason, Clear-Site-Data header clears browsing @@ -131,7 +139,7 @@ func HostnameOption() ServeOption { // Not a whitelisted path // Try DNSLink, if it was not explicitly disabled for the hostname - if !gw.NoDNSLink && isDNSLinkRequest(r.Context(), coreApi, host) { + if !gw.NoDNSLink && isDNSLinkRequest(r.Context(), coreAPI, host) { // rewrite path and handle as DNSLink r.URL.Path = "/ipns/" + stripPort(host) + r.URL.Path childMux.ServeHTTP(w, r) @@ -158,16 +166,44 @@ func HostnameOption() ServeOption { return } - // Do we need to fix multicodec in PeerID represented as CIDv1? - if isPeerIDNamespace(ns) { - keyCid, err := cid.Decode(rootID) - if err == nil && keyCid.Type() != cid.Libp2pKey { - if newURL, ok := toSubdomainURL(hostname, pathPrefix+r.URL.Path, r); ok { - // Redirect to CID fixed inside of toSubdomainURL() + // Check if rootID is a valid CID + if rootCID, err := cid.Decode(rootID); err == nil { + // Do we need to redirect root CID to a canonical DNS representation? + dnsCID, err := toDNSPrefix(rootID, rootCID) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + if !strings.HasPrefix(r.Host, dnsCID) { + dnsPrefix := "/" + ns + "/" + dnsCID + newURL, err := toSubdomainURL(hostname, dnsPrefix+r.URL.Path, r) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + if newURL != "" { + // Redirect to deterministic CID to ensure CID + // always gets the same Origin on the web http.Redirect(w, r, newURL, http.StatusMovedPermanently) return } } + + // Do we need to fix multicodec in PeerID represented as CIDv1? + if isPeerIDNamespace(ns) { + if rootCID.Type() != cid.Libp2pKey { + newURL, err := toSubdomainURL(hostname, pathPrefix+r.URL.Path, r) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + if newURL != "" { + // Redirect to CID fixed inside of toSubdomainURL() + http.Redirect(w, r, newURL, http.StatusMovedPermanently) + return + } + } + } } // Rewrite the path to not use subdomains @@ -183,7 +219,7 @@ func HostnameOption() ServeOption { // 1. is wildcard DNSLink enabled (Gateway.NoDNSLink=false)? // 2. does Host header include a fully qualified domain name (FQDN)? // 3. does DNSLink record exist in DNS? - if !cfg.Gateway.NoDNSLink && isDNSLinkRequest(r.Context(), coreApi, host) { + if !cfg.Gateway.NoDNSLink && isDNSLinkRequest(r.Context(), coreAPI, host) { // rewrite path and handle as DNSLink r.URL.Path = "/ipns/" + stripPort(host) + r.URL.Path childMux.ServeHTTP(w, r) @@ -273,18 +309,38 @@ func isPeerIDNamespace(ns string) bool { } } +// Converts an identifier to DNS-safe representation that fits in 63 characters +func toDNSPrefix(rootID string, rootCID cid.Cid) (prefix string, err error) { + // Return as-is if things fit + if len(rootID) <= dnsLabelMaxLength { + return rootID, nil + } + + // Convert to Base36 and see if that helped + rootID, err = cid.NewCidV1(rootCID.Type(), rootCID.Hash()).StringOfBase(mbase.Base36) + if err != nil { + return "", err + } + if len(rootID) <= dnsLabelMaxLength { + return rootID, nil + } + + // Can't win with DNS at this point, return error + return "", fmt.Errorf("CID incompatible with DNS label length limit of 63: %s", rootID) +} + // Converts a hostname/path to a subdomain-based URL, if applicable. -func toSubdomainURL(hostname, path string, r *http.Request) (redirURL string, ok bool) { +func toSubdomainURL(hostname, path string, r *http.Request) (redirURL string, err error) { var scheme, ns, rootID, rest string query := r.URL.RawQuery parts := strings.SplitN(path, "/", 4) - safeRedirectURL := func(in string) (out string, ok bool) { + safeRedirectURL := func(in string) (out string, err error) { safeURI, err := url.ParseRequestURI(in) if err != nil { - return "", false + return "", err } - return safeURI.String(), true + return safeURI.String(), nil } // Support X-Forwarded-Proto if added by a reverse proxy @@ -304,11 +360,11 @@ func toSubdomainURL(hostname, path string, r *http.Request) (redirURL string, ok ns = parts[1] rootID = parts[2] default: - return "", false + return "", nil } if !isSubdomainNamespace(ns) { - return "", false + return "", nil } // add prefix if query is present @@ -327,25 +383,42 @@ func toSubdomainURL(hostname, path string, r *http.Request) (redirURL string, ok } // If rootID is a CID, ensure it uses DNS-friendly text representation - if rootCid, err := cid.Decode(rootID); err == nil { - multicodec := rootCid.Type() - - // PeerIDs represented as CIDv1 are expected to have libp2p-key - // multicodec (https://github.com/libp2p/specs/pull/209). - // We ease the transition by fixing multicodec on the fly: - // https://github.com/ipfs/go-ipfs/issues/5287#issuecomment-492163929 - if isPeerIDNamespace(ns) && multicodec != cid.Libp2pKey { - multicodec = cid.Libp2pKey + if rootCID, err := cid.Decode(rootID); err == nil { + multicodec := rootCID.Type() + var base mbase.Encoding = mbase.Base32 + + // Normalizations specific to /ipns/{libp2p-key} + if isPeerIDNamespace(ns) { + // Using Base36 for /ipns/ for consistency + // Context: https://github.com/ipfs/go-ipfs/pull/7441#discussion_r452372828 + base = mbase.Base36 + + // PeerIDs represented as CIDv1 are expected to have libp2p-key + // multicodec (https://github.com/libp2p/specs/pull/209). + // We ease the transition by fixing multicodec on the fly: + // https://github.com/ipfs/go-ipfs/issues/5287#issuecomment-492163929 + if multicodec != cid.Libp2pKey { + multicodec = cid.Libp2pKey + } } - // if object turns out to be a valid CID, - // ensure text representation used in subdomain is CIDv1 in Base32 - // https://github.com/ipfs/in-web-browsers/issues/89 - rootID, err = cid.NewCidV1(multicodec, rootCid.Hash()).StringOfBase(mbase.Base32) + // Ensure CID text representation used in subdomain is compatible + // with the way DNS and URIs are implemented in user agents. + // + // 1. Switch to CIDv1 and enable case-insensitive Base encoding + // to avoid issues when user agent force-lowercases the hostname + // before making the request + // (https://github.com/ipfs/in-web-browsers/issues/89) + rootCID = cid.NewCidV1(multicodec, rootCID.Hash()) + rootID, err = rootCID.StringOfBase(base) + if err != nil { + return "", err + } + // 2. Make sure CID fits in a DNS label, adjust encoding if needed + // (https://github.com/ipfs/go-ipfs/issues/7318) + rootID, err = toDNSPrefix(rootID, rootCID) if err != nil { - // should not error, but if it does, its clealy not possible to - // produce a subdomain URL - return "", false + return "", err } } diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index 9a2974648..cf00e8271 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -1,9 +1,11 @@ package corehttp import ( + "errors" "net/http/httptest" "testing" + cid "github.com/ipfs/go-cid" config "github.com/ipfs/go-ipfs-config" ) @@ -15,23 +17,25 @@ func TestToSubdomainURL(t *testing.T) { path string // out: url string - ok bool + err error }{ // DNSLink - {"localhost", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost/", true}, + {"localhost", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost/", nil}, // Hostname with port - {"localhost:8080", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost:8080/", true}, + {"localhost:8080", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost:8080/", nil}, // CIDv0 → CIDv1base32 - {"localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.localhost/", true}, + {"localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.localhost/", nil}, + // CIDv1 with long sha512 + {"localhost", "/ipfs/bafkrgqe3ohjcjplc6n4f3fwunlj6upltggn7xqujbsvnvyw764srszz4u4rshq6ztos4chl4plgg4ffyyxnayrtdi5oc4xb2332g645433aeg", "", errors.New("CID incompatible with DNS label length limit of 63: kf1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5oj")}, // PeerID as CIDv1 needs to have libp2p-key multicodec - {"localhost", "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", "http://bafzbeieqhtl2l3mrszjnhv6hf2iloiitsx7mexiolcnywnbcrzkqxwslja.ipns.localhost/", true}, - {"localhost", "/ipns/bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "http://bafzbeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm.ipns.localhost/", true}, - // PeerID: ed25519+identity multihash - {"localhost", "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://bafzaajaiaejcat4yhiwnr2qz73mtu6vrnj2krxlpfoa3wo2pllfi37quorgwh2jw.ipns.localhost/", true}, + {"localhost", "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", "http://k2k4r8n0flx3ra0y5dr8fmyvwbzy3eiztmtq6th694k5a3rznayp3e4o.ipns.localhost/", nil}, + {"localhost", "/ipns/bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "http://k2k4r8l9ja7hkzynavdqup76ou46tnvuaqegbd04a4o1mpbsey0meucb.ipns.localhost/", nil}, + // PeerID: ed25519+identity multihash → CIDv1Base36 + {"localhost", "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://k51qzi5uqu5di608geewp3nqkg0bpujoasmka7ftkyxgcm3fh1aroup0gsdrna.ipns.localhost/", nil}, } { - url, ok := toSubdomainURL(test.hostname, test.path, r) - if ok != test.ok || url != test.url { - t.Errorf("(%s, %s) returned (%s, %t), expected (%s, %t)", test.hostname, test.path, url, ok, test.url, ok) + url, err := toSubdomainURL(test.hostname, test.path, r) + if url != test.url || !equalError(err, test.err) { + t.Errorf("(%s, %s) returned (%s, %v), expected (%s, %v)", test.hostname, test.path, url, err, test.url, test.err) } } } @@ -75,6 +79,30 @@ func TestPortStripping(t *testing.T) { } +func TestDNSPrefix(t *testing.T) { + for _, test := range []struct { + in string + out string + err error + }{ + // <= 63 + {"QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", nil}, + {"bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", nil}, + // > 63 + // PeerID: ed25519+identity multihash → CIDv1Base36 + {"bafzaajaiaejca4syrpdu6gdx4wsdnokxkprgzxf4wrstuc34gxw5k5jrag2so5gk", "k51qzi5uqu5dj16qyiq0tajolkojyl9qdkr254920wxv7ghtuwcz593tp69z9m", nil}, + // CIDv1 with long sha512 → error + {"bafkrgqe3ohjcjplc6n4f3fwunlj6upltggn7xqujbsvnvyw764srszz4u4rshq6ztos4chl4plgg4ffyyxnayrtdi5oc4xb2332g645433aeg", "", errors.New("CID incompatible with DNS label length limit of 63: kf1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5oj")}, + } { + inCID, _ := cid.Decode(test.in) + out, err := toDNSPrefix(test.in, inCID) + if out != test.out || !equalError(err, test.err) { + t.Errorf("(%s): returned (%s, %v) expected (%s, %v)", test.in, out, err, test.out, test.err) + } + } + +} + func TestKnownSubdomainDetails(t *testing.T) { gwSpec := config.GatewaySpec{ UseSubdomains: true, @@ -150,3 +178,7 @@ func TestKnownSubdomainDetails(t *testing.T) { } } + +func equalError(a, b error) bool { + return (a == nil && b == nil) || (a != nil && b != nil && a.Error() == b.Error()) +} From 3937f1f675e9d0e206a6110cc7967819c6217e49 Mon Sep 17 00:00:00 2001 From: Stephen Solka Date: Sat, 18 Jul 2020 14:47:07 -0400 Subject: [PATCH 538/674] use t.Cleanup() to reduce the need to clean up servers This commit was moved from ipfs/kubo@4dbdbe0e029d5af826919376579268da0bc68019 --- gateway/core/corehttp/gateway_test.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index a8a07aa48..d8b7eaa5f 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -135,6 +135,7 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, iface // listener, and server with handler. yay cycles. dh := &delegatedHandler{} ts := httptest.NewServer(dh) + t.Cleanup(func() { ts.Close() }) dh.Handler, err = makeHandler(n, ts.Listener, @@ -157,7 +158,6 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, iface func TestGatewayGet(t *testing.T) { ns := mockNamesys{} ts, api, ctx := newTestServerAndNode(t, ns) - defer ts.Close() k, err := api.Unixfs().Add(ctx, files.NewBytesFile([]byte("fnord"))) if err != nil { @@ -238,7 +238,6 @@ func TestGatewayGet(t *testing.T) { func TestPretty404(t *testing.T) { ns := mockNamesys{} ts, api, ctx := newTestServerAndNode(t, ns) - defer ts.Close() f1 := files.NewMapDirectory(map[string]files.Node{ "ipfs-404.html": files.NewBytesFile([]byte("Custom 404")), @@ -303,7 +302,6 @@ func TestIPNSHostnameRedirect(t *testing.T) { ns := mockNamesys{} ts, api, ctx := newTestServerAndNode(t, ns) t.Logf("test server url: %s", ts.URL) - defer ts.Close() // create /ipns/example.net/foo/index.html @@ -391,7 +389,6 @@ func TestIPNSHostnameBacklinks(t *testing.T) { ns := mockNamesys{} ts, api, ctx := newTestServerAndNode(t, ns) t.Logf("test server url: %s", ts.URL) - defer ts.Close() f1 := files.NewMapDirectory(map[string]files.Node{ "file.txt": files.NewBytesFile([]byte("1")), @@ -601,7 +598,6 @@ func TestIPNSHostnameBacklinks(t *testing.T) { func TestCacheControlImmutable(t *testing.T) { ts, _, _ := newTestServerAndNode(t, nil) t.Logf("test server url: %s", ts.URL) - defer ts.Close() req, err := http.NewRequest(http.MethodGet, ts.URL+emptyDir+"/", nil) if err != nil { @@ -627,7 +623,6 @@ func TestCacheControlImmutable(t *testing.T) { func TestGoGetSupport(t *testing.T) { ts, _, _ := newTestServerAndNode(t, nil) t.Logf("test server url: %s", ts.URL) - defer ts.Close() // mimic go-get req, err := http.NewRequest(http.MethodGet, ts.URL+emptyDir+"?go-get=1", nil) @@ -651,7 +646,6 @@ func TestVersion(t *testing.T) { ns := mockNamesys{} ts, _, _ := newTestServerAndNode(t, ns) t.Logf("test server url: %s", ts.URL) - defer ts.Close() req, err := http.NewRequest(http.MethodGet, ts.URL+"/version", nil) if err != nil { From 4030f32451874701ba73058d15bef991a0070cbe Mon Sep 17 00:00:00 2001 From: Rafael Ramalho Date: Thu, 16 Jul 2020 19:24:37 +0100 Subject: [PATCH 539/674] chore: bump webui version This commit was moved from ipfs/kubo@e3905e1fdc7551980dc3874e71f0b43e1831deff --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 2728bc7b3..8eff65c2d 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeibnnxd4etu4tq5fuhu3z5p4rfu3buabfkeyr3o3s4h6wtesvvw6mu" // v2.10.1 +const WebUIPath = "/ipfs/bafybeihpetclqvwb4qnmumvcn7nh4pxrtugrlpw4jgjpqicdxsv7opdm6e" // v2.10.2 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeibnnxd4etu4tq5fuhu3z5p4rfu3buabfkeyr3o3s4h6wtesvvw6mu", "/ipfs/bafybeid6luolenf4fcsuaw5rgdwpqbyerce4x3mi3hxfdtp5pwco7h7qyq", "/ipfs/bafybeigkbbjnltbd4ewfj7elajsbnjwinyk6tiilczkqsibf3o7dcr6nn4", "/ipfs/bafybeicp23nbcxtt2k2twyfivcbrc6kr3l5lnaiv3ozvwbemtrb7v52r6i", From 542242c6a3fa5b17d01f9c2439f611e2ee776fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Mur=C3=A9?= Date: Thu, 14 May 2020 20:35:11 +0200 Subject: [PATCH 540/674] feat: wildcard support for public gateways Add support for one or more wildcards in the hostname definition of a public gateway. This is useful for example to support easily multiples environment. Wildcarded hostname are set in the config as for example "*.domain.tld". This commit was moved from ipfs/kubo@13e6bcfb4f7d2db7d80af77f1b32b2394abca9da --- gateway/core/corehttp/hostname.go | 98 +++++++++++++++++++------- gateway/core/corehttp/hostname_test.go | 86 ++++++++++++---------- 2 files changed, 124 insertions(+), 60 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index f29b4d11f..04f640e2f 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -6,6 +6,7 @@ import ( "net" "net/http" "net/url" + "regexp" "strings" cid "github.com/ipfs/go-cid" @@ -24,17 +25,17 @@ import ( var defaultPaths = []string{"/ipfs/", "/ipns/", "/api/", "/p2p/", "/version"} -var pathGatewaySpec = config.GatewaySpec{ +var pathGatewaySpec = &config.GatewaySpec{ Paths: defaultPaths, UseSubdomains: false, } -var subdomainGatewaySpec = config.GatewaySpec{ +var subdomainGatewaySpec = &config.GatewaySpec{ Paths: defaultPaths, UseSubdomains: true, } -var defaultKnownGateways = map[string]config.GatewaySpec{ +var defaultKnownGateways = map[string]*config.GatewaySpec{ "localhost": subdomainGatewaySpec, "ipfs.io": pathGatewaySpec, "gateway.ipfs.io": pathGatewaySpec, @@ -58,22 +59,8 @@ func HostnameOption() ServeOption { if err != nil { return nil, err } - knownGateways := make( - map[string]config.GatewaySpec, - len(defaultKnownGateways)+len(cfg.Gateway.PublicGateways), - ) - for hostname, gw := range defaultKnownGateways { - knownGateways[hostname] = gw - } - for hostname, gw := range cfg.Gateway.PublicGateways { - if gw == nil { - // Allows the user to remove gateways but _also_ - // allows us to continuously update the list. - delete(knownGateways, hostname) - } else { - knownGateways[hostname] = *gw - } - } + + knownGateways := prepareKnownGateways(cfg.Gateway.PublicGateways) mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { // Unfortunately, many (well, ipfs.io) gateways use @@ -233,22 +220,85 @@ func HostnameOption() ServeOption { } } +type gatewayHosts struct { + exact map[string]*config.GatewaySpec + wildcard []wildcardHost +} + +type wildcardHost struct { + re *regexp.Regexp + spec *config.GatewaySpec +} + +func prepareKnownGateways(publicGateways map[string]*config.GatewaySpec) gatewayHosts { + var hosts gatewayHosts + + if len(publicGateways) == 0 { + hosts.exact = make( + map[string]*config.GatewaySpec, + len(defaultKnownGateways), + ) + for hostname, gw := range defaultKnownGateways { + hosts.exact[hostname] = gw + } + return hosts + } + + hosts.exact = make(map[string]*config.GatewaySpec, len(publicGateways)) + + for hostname, gw := range publicGateways { + if gw == nil { + continue + } + if strings.Contains(hostname, "*") { + // from *.domain.tld, construct a regexp that match any direct subdomain + // of .domain.tld. + // + // Regexp will be in the form of ^[^.]+\.domain.tld(?::\d+)?$ + + escaped := strings.ReplaceAll(hostname, ".", `\.`) + regexed := strings.ReplaceAll(escaped, "*", "[^.]+") + + re, err := regexp.Compile(fmt.Sprintf(`^%s(?::\d+)?$`, regexed)) + if err != nil { + log.Warn("invalid wildcard gateway hostname \"%s\"", hostname) + } + + hosts.wildcard = append(hosts.wildcard, wildcardHost{re: re, spec: gw}) + } else { + hosts.exact[hostname] = gw + } + } + + return hosts +} + // isKnownHostname checks Gateway.PublicGateways and returns matching // GatewaySpec with gracefull fallback to version without port -func isKnownHostname(hostname string, knownGateways map[string]config.GatewaySpec) (gw config.GatewaySpec, ok bool) { +func isKnownHostname(hostname string, knownGateways gatewayHosts) (gw *config.GatewaySpec, ok bool) { // Try hostname (host+optional port - value from Host header as-is) - if gw, ok := knownGateways[hostname]; ok { + if gw, ok := knownGateways.exact[hostname]; ok { + return gw, ok + } + // Also test without port + if gw, ok = knownGateways.exact[stripPort(hostname)]; ok { return gw, ok } - // Fallback to hostname without port - gw, ok = knownGateways[stripPort(hostname)] + + // Wildcard support. Test both with and without port. + for _, host := range knownGateways.wildcard { + if host.re.MatchString(hostname) { + return host.spec, true + } + } + return gw, ok } // Parses Host header and looks for a known subdomain gateway host. // If found, returns GatewaySpec and subdomain components. // Note: hostname is host + optional port -func knownSubdomainDetails(hostname string, knownGateways map[string]config.GatewaySpec) (gw config.GatewaySpec, knownHostname, ns, rootID string, ok bool) { +func knownSubdomainDetails(hostname string, knownGateways gatewayHosts) (gw *config.GatewaySpec, knownHostname, ns, rootID string, ok bool) { labels := strings.Split(hostname, ".") // Look for FQDN of a known gateway hostname. // Example: given "dist.ipfs.io.ipns.dweb.link": diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index cf00e8271..472dbcf16 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -32,6 +32,7 @@ func TestToSubdomainURL(t *testing.T) { {"localhost", "/ipns/bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "http://k2k4r8l9ja7hkzynavdqup76ou46tnvuaqegbd04a4o1mpbsey0meucb.ipns.localhost/", nil}, // PeerID: ed25519+identity multihash → CIDv1Base36 {"localhost", "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://k51qzi5uqu5di608geewp3nqkg0bpujoasmka7ftkyxgcm3fh1aroup0gsdrna.ipns.localhost/", nil}, + {"sub.localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.sub.localhost/", nil}, } { url, err := toSubdomainURL(test.hostname, test.path, r) if url != test.url || !equalError(err, test.err) { @@ -104,60 +105,73 @@ func TestDNSPrefix(t *testing.T) { } func TestKnownSubdomainDetails(t *testing.T) { - gwSpec := config.GatewaySpec{ - UseSubdomains: true, - } - knownGateways := map[string]config.GatewaySpec{ - "localhost": gwSpec, - "dweb.link": gwSpec, - "dweb.ipfs.pvt.k12.ma.us": gwSpec, // note the sneaky ".ipfs." ;-) - } + gwLocalhost := &config.GatewaySpec{} + gwDweb := &config.GatewaySpec{} + gwLong := &config.GatewaySpec{} + gwWildcard1 := &config.GatewaySpec{} + gwWildcard2 := &config.GatewaySpec{} + + knownGateways := prepareKnownGateways(map[string]*config.GatewaySpec{ + "localhost": gwLocalhost, + "dweb.link": gwDweb, + "dweb.ipfs.pvt.k12.ma.us": gwLong, // note the sneaky ".ipfs." ;-) + "*.wildcard1.tld": gwWildcard1, + "*.*.wildcard2.tld": gwWildcard2, + }) for _, test := range []struct { // in: hostHeader string // out: + gw *config.GatewaySpec hostname string ns string rootID string ok bool }{ // no subdomain - {"127.0.0.1:8080", "", "", "", false}, - {"[::1]:8080", "", "", "", false}, - {"hey.look.example.com", "", "", "", false}, - {"dweb.link", "", "", "", false}, + {"127.0.0.1:8080", nil, "", "", "", false}, + {"[::1]:8080", nil, "", "", "", false}, + {"hey.look.example.com", nil, "", "", "", false}, + {"dweb.link", nil, "", "", "", false}, // malformed Host header - {".....dweb.link", "", "", "", false}, - {"link", "", "", "", false}, - {"8080:dweb.link", "", "", "", false}, - {" ", "", "", "", false}, - {"", "", "", "", false}, + {".....dweb.link", nil, "", "", "", false}, + {"link", nil, "", "", "", false}, + {"8080:dweb.link", nil, "", "", "", false}, + {" ", nil, "", "", "", false}, + {"", nil, "", "", "", false}, // unknown gateway host - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.unknown.example.com", "", "", "", false}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.unknown.example.com", nil, "", "", "", false}, // cid in subdomain, known gateway - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.localhost:8080", "localhost:8080", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.link", "dweb.link", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.localhost:8080", gwLocalhost, "localhost:8080", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.link", gwDweb, "dweb.link", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, // capture everything before .ipfs. - {"foo.bar.boo-buzz.ipfs.dweb.link", "dweb.link", "ipfs", "foo.bar.boo-buzz", true}, + {"foo.bar.boo-buzz.ipfs.dweb.link", gwDweb, "dweb.link", "ipfs", "foo.bar.boo-buzz", true}, // ipns - {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.localhost:8080", "localhost:8080", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, - {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.dweb.link", "dweb.link", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, + {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.localhost:8080", gwLocalhost, "localhost:8080", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, + {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.dweb.link", gwDweb, "dweb.link", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, // edge case check: public gateway under long TLD (see: https://publicsuffix.org) - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.ipfs.pvt.k12.ma.us", "dweb.ipfs.pvt.k12.ma.us", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, - {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.dweb.ipfs.pvt.k12.ma.us", "dweb.ipfs.pvt.k12.ma.us", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.ipfs.pvt.k12.ma.us", gwLong, "dweb.ipfs.pvt.k12.ma.us", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, + {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.dweb.ipfs.pvt.k12.ma.us", gwLong, "dweb.ipfs.pvt.k12.ma.us", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, // dnslink in subdomain - {"en.wikipedia-on-ipfs.org.ipns.localhost:8080", "localhost:8080", "ipns", "en.wikipedia-on-ipfs.org", true}, - {"en.wikipedia-on-ipfs.org.ipns.localhost", "localhost", "ipns", "en.wikipedia-on-ipfs.org", true}, - {"dist.ipfs.io.ipns.localhost:8080", "localhost:8080", "ipns", "dist.ipfs.io", true}, - {"en.wikipedia-on-ipfs.org.ipns.dweb.link", "dweb.link", "ipns", "en.wikipedia-on-ipfs.org", true}, + {"en.wikipedia-on-ipfs.org.ipns.localhost:8080", gwLocalhost, "localhost:8080", "ipns", "en.wikipedia-on-ipfs.org", true}, + {"en.wikipedia-on-ipfs.org.ipns.localhost", gwLocalhost, "localhost", "ipns", "en.wikipedia-on-ipfs.org", true}, + {"dist.ipfs.io.ipns.localhost:8080", gwLocalhost, "localhost:8080", "ipns", "dist.ipfs.io", true}, + {"en.wikipedia-on-ipfs.org.ipns.dweb.link", gwDweb, "dweb.link", "ipns", "en.wikipedia-on-ipfs.org", true}, // edge case check: public gateway under long TLD (see: https://publicsuffix.org) - {"foo.dweb.ipfs.pvt.k12.ma.us", "", "", "", false}, - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.ipfs.pvt.k12.ma.us", "dweb.ipfs.pvt.k12.ma.us", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, - {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.dweb.ipfs.pvt.k12.ma.us", "dweb.ipfs.pvt.k12.ma.us", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, + {"foo.dweb.ipfs.pvt.k12.ma.us", nil, "", "", "", false}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.ipfs.pvt.k12.ma.us", gwLong, "dweb.ipfs.pvt.k12.ma.us", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, + {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.dweb.ipfs.pvt.k12.ma.us", gwLong, "dweb.ipfs.pvt.k12.ma.us", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, // other namespaces - {"api.localhost", "", "", "", false}, - {"peerid.p2p.localhost", "localhost", "p2p", "peerid", true}, + {"api.localhost", nil, "", "", "", false}, + {"peerid.p2p.localhost", gwLocalhost, "localhost", "p2p", "peerid", true}, + // wildcards + {"wildcard1.tld", nil, "", "", "", false}, + {".wildcard1.tld", nil, "", "", "", false}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.wildcard1.tld", nil, "", "", "", false}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.sub.wildcard1.tld", gwWildcard1, "sub.wildcard1.tld", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.sub1.sub2.wildcard1.tld", nil, "", "", "", false}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.sub1.sub2.wildcard2.tld", gwWildcard2, "sub1.sub2.wildcard2.tld", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, } { gw, hostname, ns, rootID, ok := knownSubdomainDetails(test.hostHeader, knownGateways) if ok != test.ok { @@ -172,8 +186,8 @@ func TestKnownSubdomainDetails(t *testing.T) { if hostname != test.hostname { t.Errorf("knownSubdomainDetails(%s): hostname is '%s', expected '%s'", test.hostHeader, hostname, test.hostname) } - if ok && gw.UseSubdomains != gwSpec.UseSubdomains { - t.Errorf("knownSubdomainDetails(%s): gw is %+v, expected %+v", test.hostHeader, gw, gwSpec) + if gw != test.gw { + t.Errorf("knownSubdomainDetails(%s): gw is %+v, expected %+v", test.hostHeader, gw, test.gw) } } From c0b7f3f0710d4e5a4348e0b8c51e2cc44f45fe0e Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 6 Aug 2020 14:00:16 +0200 Subject: [PATCH 541/674] test(gateway): IPNS cleanup and implicit defaults fix This ensures implicit defaults are always present, even when Gateway.PublicGateways is defined in the config. User still can disable them, but needs to do it per hostname. License: MIT Signed-off-by: Marcin Rataj This commit was moved from ipfs/kubo@2ff6f1a80d6a070465e8c157a750ecf17687642b --- gateway/core/corehttp/hostname.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 04f640e2f..e94be2c82 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -233,21 +233,19 @@ type wildcardHost struct { func prepareKnownGateways(publicGateways map[string]*config.GatewaySpec) gatewayHosts { var hosts gatewayHosts - if len(publicGateways) == 0 { - hosts.exact = make( - map[string]*config.GatewaySpec, - len(defaultKnownGateways), - ) - for hostname, gw := range defaultKnownGateways { - hosts.exact[hostname] = gw - } - return hosts - } + hosts.exact = make(map[string]*config.GatewaySpec, len(publicGateways)+len(defaultKnownGateways)) - hosts.exact = make(map[string]*config.GatewaySpec, len(publicGateways)) + // First, implicit defaults such as subdomain gateway on localhost + for hostname, gw := range defaultKnownGateways { + hosts.exact[hostname] = gw + } + // Then apply values from Gateway.PublicGateways, if present in the config for hostname, gw := range publicGateways { if gw == nil { + // Remove any implicit defaults, if present. This is useful when one + // wants to disable subdomain gateway on localhost etc. + delete(hosts.exact, hostname) continue } if strings.Contains(hostname, "*") { From c37f055a823ab57295f2a7d3084ee8ab5436abcc Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 19 Aug 2020 15:59:47 +0200 Subject: [PATCH 542/674] refactor: cleanup/comment https://github.com/ipfs/go-ipfs/pull/7319#discussion_r472734905 License: MIT Signed-off-by: Marcin Rataj This commit was moved from ipfs/kubo@6b6569f3e5c1cb2e229b98c26c88ffa34f0abe81 --- gateway/core/corehttp/hostname.go | 12 ++++++------ gateway/core/corehttp/hostname_test.go | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index e94be2c82..880ec8787 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -141,12 +141,12 @@ func HostnameOption() ServeOption { // HTTP Host check: is this one of our subdomain-based "known gateways"? // Example: {cid}.ipfs.localhost, {cid}.ipfs.dweb.link if gw, hostname, ns, rootID, ok := knownSubdomainDetails(host, knownGateways); ok { - // Looks like we're using known subdomain gateway. + // Looks like we're using a known gateway in subdomain mode. // Assemble original path prefix. pathPrefix := "/" + ns + "/" + rootID - // Does this gateway _handle_ this path? + // Does this gateway _handle_ subdomains AND this path? if !(gw.UseSubdomains && hasPrefix(pathPrefix, gw.Paths...)) { // If not, resource does not exist, return 404 http.NotFound(w, r) @@ -290,10 +290,10 @@ func isKnownHostname(hostname string, knownGateways gatewayHosts) (gw *config.Ga } } - return gw, ok + return nil, false } -// Parses Host header and looks for a known subdomain gateway host. +// Parses Host header and looks for a known gateway matching subdomain host. // If found, returns GatewaySpec and subdomain components. // Note: hostname is host + optional port func knownSubdomainDetails(hostname string, knownGateways gatewayHosts) (gw *config.GatewaySpec, knownHostname, ns, rootID string, ok bool) { @@ -321,8 +321,8 @@ func knownSubdomainDetails(hostname string, knownGateways gatewayHosts) (gw *con rootID := strings.Join(labels[:i-1], ".") return gw, fqdn, ns, rootID, true } - // not a known subdomain gateway - return gw, "", "", "", false + // no match + return nil, "", "", "", false } // isDNSLinkRequest returns bool that indicates if request diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index 472dbcf16..3a316ede5 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -105,11 +105,11 @@ func TestDNSPrefix(t *testing.T) { } func TestKnownSubdomainDetails(t *testing.T) { - gwLocalhost := &config.GatewaySpec{} - gwDweb := &config.GatewaySpec{} - gwLong := &config.GatewaySpec{} - gwWildcard1 := &config.GatewaySpec{} - gwWildcard2 := &config.GatewaySpec{} + gwLocalhost := &config.GatewaySpec{Paths: []string{"/ipfs", "/ipns", "/api"}, UseSubdomains: true} + gwDweb := &config.GatewaySpec{Paths: []string{"/ipfs", "/ipns", "/api"}, UseSubdomains: true} + gwLong := &config.GatewaySpec{Paths: []string{"/ipfs", "/ipns", "/api"}, UseSubdomains: true} + gwWildcard1 := &config.GatewaySpec{Paths: []string{"/ipfs", "/ipns", "/api"}, UseSubdomains: true} + gwWildcard2 := &config.GatewaySpec{Paths: []string{"/ipfs", "/ipns", "/api"}, UseSubdomains: true} knownGateways := prepareKnownGateways(map[string]*config.GatewaySpec{ "localhost": gwLocalhost, From 529c1727820853ea5461ca3c291d44f6b87b33e7 Mon Sep 17 00:00:00 2001 From: Kevin Neaton Date: Thu, 9 Jul 2020 23:46:05 -0400 Subject: [PATCH 543/674] feat: Directory page UI improvements These changes are needed to prepare for the Directory page UI improvements implemented in https://github.com/ipfs/dir-index-html/issues/37. - update dir-index-html type structs - emit gateway URL for root links - emit CID of each directoryItem - emit size of directory - emit breadcrumbs This commit was moved from ipfs/kubo@044790a83857c4b396ce5c336045d6b10f5e4075 --- gateway/core/corehttp/gateway_handler.go | 42 ++++++++++++++++--- gateway/core/corehttp/gateway_indexPage.go | 49 +++++++++++++++++++--- gateway/core/corehttp/hostname.go | 6 ++- 3 files changed, 86 insertions(+), 11 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index a1549efdd..b9e7f144b 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -328,8 +328,20 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request size = humanize.Bytes(uint64(s)) } + hash := "" + if r, err := i.api.ResolvePath(r.Context(), ipath.Join(resolvedPath, dirit.Name())); err == nil { + // Path may not be resolved. Continue anyways. + hash = r.Cid().String() + } + // See comment above where originalUrlPath is declared. - di := directoryItem{size, dirit.Name(), gopath.Join(originalUrlPath, dirit.Name())} + di := directoryItem{ + Size: size, + Name: dirit.Name(), + Path: gopath.Join(originalUrlPath, dirit.Name()), + Hash: hash, + ShortHash: shortHash(hash), + } dirListing = append(dirListing, di) } if dirit.Err() != nil { @@ -359,14 +371,34 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } } + size := "?" + if s, err := dir.Size(); err == nil { + // Size may not be defined/supported. Continue anyways. + size = humanize.Bytes(uint64(s)) + } + hash := resolvedPath.Cid().String() + // Storage for gateway URL to be used when linking to other rootIDs. This + // will be blank unless subdomain resolution is being used for this request. + var gwURL string + + // Get gateway hostname and build gateway URL. + if h, ok := r.Context().Value("gw-hostname").(string); ok { + gwURL = "//" + h + } else { + gwURL = "" + } + // See comment above where originalUrlPath is declared. tplData := listingTemplateData{ - Listing: dirListing, - Path: urlPath, - BackLink: backLink, - Hash: hash, + GatewayURL: gwURL, + Listing: dirListing, + Size: size, + Path: urlPath, + Breadcrumbs: breadcrumbs(urlPath), + BackLink: backLink, + Hash: hash, } err = listingTemplate.Execute(w, tplData) diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index 5575baea4..c9a948708 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -7,22 +7,61 @@ import ( "strings" "github.com/ipfs/go-ipfs/assets" + ipfspath "github.com/ipfs/go-path" ) // structs for directory listing type listingTemplateData struct { - Listing []directoryItem - Path string - BackLink string - Hash string + GatewayURL string + Listing []directoryItem + Size string + Path string + Breadcrumbs []breadcrumb + BackLink string + Hash string } type directoryItem struct { - Size string + Size string + Name string + Path string + Hash string + ShortHash string +} + +type breadcrumb struct { Name string Path string } +func breadcrumbs(urlPath string) []breadcrumb { + var ret []breadcrumb + + p, err := ipfspath.ParsePath(urlPath) + if err != nil { + // No breadcrumbs, fallback to bare Path in template + return ret + } + + segs := p.Segments() + for i, seg := range segs { + if i == 0 { + ret = append(ret, breadcrumb{Name: seg}) + } else { + ret = append(ret, breadcrumb{ + Name: seg, + Path: "/" + strings.Join(segs[0:i+1], "/"), + }) + } + } + + return ret +} + +func shortHash(hash string) string { + return (hash[0:4] + "\u2026" + hash[len(hash)-4:]) +} + var listingTemplate *template.Template func init() { diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 880ec8787..8b2666afb 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -143,6 +143,10 @@ func HostnameOption() ServeOption { if gw, hostname, ns, rootID, ok := knownSubdomainDetails(host, knownGateways); ok { // Looks like we're using a known gateway in subdomain mode. + // Add gateway hostname context for linking to other root ids. + // Example: localhost/ipfs/{cid} + ctx := context.WithValue(r.Context(), "gw-hostname", hostname) + // Assemble original path prefix. pathPrefix := "/" + ns + "/" + rootID @@ -197,7 +201,7 @@ func HostnameOption() ServeOption { r.URL.Path = pathPrefix + r.URL.Path // Serve path request - childMux.ServeHTTP(w, r) + childMux.ServeHTTP(w, r.WithContext(ctx)) return } // We don't have a known gateway. Fallback on DNSLink lookup From 000ac7f97bf5832c04448f24f725500a904c327d Mon Sep 17 00:00:00 2001 From: Kevin Neaton Date: Sat, 25 Jul 2020 23:13:33 -0400 Subject: [PATCH 544/674] test: update gateway tests for dir-index-html v1.1.0 This commit was moved from ipfs/kubo@2feff332354b376a211c956902e0ad64de61fa0c --- gateway/core/corehttp/gateway_test.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index a8a07aa48..68991bc76 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "net/http" "net/http/httptest" + "regexp" "strings" "testing" "time" @@ -154,6 +155,11 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, iface return ts, api, n.Context() } +func matchPathOrBreadcrumbs(s string, expected string) bool { + matched, _ := regexp.MatchString("Index of\n[\t ]*"+regexp.QuoteMeta(expected), s) + return matched +} + func TestGatewayGet(t *testing.T) { ns := mockNamesys{} ts, api, ctx := newTestServerAndNode(t, ns) @@ -442,7 +448,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s := string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /ipns/example.net/foo? #<'/") { + if !matchPathOrBreadcrumbs(s, "/ipns/example.net/foo? #<'") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { @@ -475,7 +481,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s = string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /") { + if !matchPathOrBreadcrumbs(s, "/") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { @@ -508,7 +514,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s = string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /ipns/example.net/foo? #<'/bar/") { + if !matchPathOrBreadcrumbs(s, "/ipns/example.net/foo? #<'/bar") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { @@ -542,7 +548,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s = string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /ipns/example.net") { + if !matchPathOrBreadcrumbs(s, "/ipns/example.net") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { @@ -584,7 +590,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s = string(body) t.Logf("body: %s\n", string(body)) - if !strings.Contains(s, "Index of /") { + if !matchPathOrBreadcrumbs(s, "/") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { From 030025e7a7bf06dc8da0acefb92466785d54b8c4 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Wed, 19 Aug 2020 23:52:53 -0400 Subject: [PATCH 545/674] chore: update go-multiaddr and go-multiaddr-net This commit was moved from ipfs/kubo@b88bdfeb9db0677213f57466b8b617fa3284b107 --- gateway/core/corehttp/corehttp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 1b0a79ee6..143327149 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -16,7 +16,7 @@ import ( "github.com/jbenet/goprocess" periodicproc "github.com/jbenet/goprocess/periodic" ma "github.com/multiformats/go-multiaddr" - manet "github.com/multiformats/go-multiaddr-net" + manet "github.com/multiformats/go-multiaddr/net" ) var log = logging.Logger("core/server") From 95182c2c59e7bce8ccdf323af8d80b6eb6f0b443 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 16 Sep 2020 22:10:36 +0200 Subject: [PATCH 546/674] feat(gateway): ?filename with download=true This implements 'attachment' mode triggered then ?filename parameter is accompanied with &download=true When Content-Disposition: attachment is detected by a modern browser it will skip rendering and immediately open the "save as" dialog, making this useful feature for using IPFS gateway as target of "Download" links on various websites. Parameter name was suggested in: https://github.com/ipfs/go-ipfs/pull/4177#issuecomment-414870327 This commit was moved from ipfs/kubo@fd01acdfc0cede60706d59cfdeaa9784c8f7c8f3 --- gateway/core/corehttp/gateway_handler.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index b9e7f144b..0c708f87b 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -261,7 +261,11 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request urlFilename := r.URL.Query().Get("filename") var name string if urlFilename != "" { - w.Header().Set("Content-Disposition", fmt.Sprintf("inline; filename*=UTF-8''%s", url.PathEscape(urlFilename))) + disposition := "inline" + if r.URL.Query().Get("download") == "true" { + disposition = "attachment" + } + w.Header().Set("Content-Disposition", fmt.Sprintf("%s; filename*=UTF-8''%s", disposition, url.PathEscape(urlFilename))) name = urlFilename } else { name = getFilename(urlPath) From d92fd649ac8688197a1f377a53eb370d31165a08 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 16 Sep 2020 22:39:04 +0200 Subject: [PATCH 547/674] feat(gateway): Content-Disposition for legacy clients This adds ASCII-only filename for clients that do not implement RFC 5987 Closes #7648 This commit was moved from ipfs/kubo@19ec5f4a51e9c53c8d6b2df7d8472058d342b4c6 --- gateway/core/corehttp/gateway_handler.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 0c708f87b..b7a2b7e38 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -34,6 +34,8 @@ const ( ipnsPathPrefix = "/ipns/" ) +var onlyAscii = regexp.MustCompile("[[:^ascii:]]") + // gatewayHandler is a HTTP handler that serves IPFS objects (accessible by default at /ipfs/) // (it serves requests like GET /ipfs/QmVRzPKPzNtSrEzBFm2UZfxmPAgnaLke4DMcerbsGGSaFe/link) type gatewayHandler struct { @@ -265,7 +267,9 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request if r.URL.Query().Get("download") == "true" { disposition = "attachment" } - w.Header().Set("Content-Disposition", fmt.Sprintf("%s; filename*=UTF-8''%s", disposition, url.PathEscape(urlFilename))) + utf8Name := url.PathEscape(urlFilename) + asciiName := url.PathEscape(onlyAscii.ReplaceAllLiteralString(urlFilename, "_")) + w.Header().Set("Content-Disposition", fmt.Sprintf("%s; filename=\"%s\"; filename*=UTF-8''%s", disposition, asciiName, utf8Name)) name = urlFilename } else { name = getFilename(urlPath) From 17ef979297081fec20b5b3231b1d5071ac4e8726 Mon Sep 17 00:00:00 2001 From: Rafael Ramalho Date: Thu, 10 Sep 2020 19:47:44 +0100 Subject: [PATCH 548/674] chore: bump webui version This commit was moved from ipfs/kubo@1b4f5e72ad11c42e6a9e12b3799c97e17a0bb617 --- gateway/core/corehttp/webui.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 8eff65c2d..b0f4256c8 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,13 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeihpetclqvwb4qnmumvcn7nh4pxrtugrlpw4jgjpqicdxsv7opdm6e" // v2.10.2 +const WebUIPath = "/ipfs/bafybeianwe4vy7sprht5sm3hshvxjeqhwcmvbzq73u55sdhqngmohkjgs4" // v2.11.1 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeicitin4p7ggmyjaubqpi3xwnagrwarsy6hiihraafk5rcrxqxju6m", + "/ipfs/bafybeihpetclqvwb4qnmumvcn7nh4pxrtugrlpw4jgjpqicdxsv7opdm6e", "/ipfs/bafybeibnnxd4etu4tq5fuhu3z5p4rfu3buabfkeyr3o3s4h6wtesvvw6mu", "/ipfs/bafybeid6luolenf4fcsuaw5rgdwpqbyerce4x3mi3hxfdtp5pwco7h7qyq", "/ipfs/bafybeigkbbjnltbd4ewfj7elajsbnjwinyk6tiilczkqsibf3o7dcr6nn4", From f6b3ba239ce5d7380d4e4c4c80038ed3a6b8946e Mon Sep 17 00:00:00 2001 From: Rafael Ramalho Date: Thu, 10 Sep 2020 19:47:44 +0100 Subject: [PATCH 549/674] chore: bump webui version (cherry picked from commit 17ef979297081fec20b5b3231b1d5071ac4e8726) This commit was moved from ipfs/kubo@54e743779cf279c0328c6b4b523c888382a71de2 --- gateway/core/corehttp/webui.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 8eff65c2d..b0f4256c8 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,13 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeihpetclqvwb4qnmumvcn7nh4pxrtugrlpw4jgjpqicdxsv7opdm6e" // v2.10.2 +const WebUIPath = "/ipfs/bafybeianwe4vy7sprht5sm3hshvxjeqhwcmvbzq73u55sdhqngmohkjgs4" // v2.11.1 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeicitin4p7ggmyjaubqpi3xwnagrwarsy6hiihraafk5rcrxqxju6m", + "/ipfs/bafybeihpetclqvwb4qnmumvcn7nh4pxrtugrlpw4jgjpqicdxsv7opdm6e", "/ipfs/bafybeibnnxd4etu4tq5fuhu3z5p4rfu3buabfkeyr3o3s4h6wtesvvw6mu", "/ipfs/bafybeid6luolenf4fcsuaw5rgdwpqbyerce4x3mi3hxfdtp5pwco7h7qyq", "/ipfs/bafybeigkbbjnltbd4ewfj7elajsbnjwinyk6tiilczkqsibf3o7dcr6nn4", From d29bc1aa30f7c8648935adb6a06abf35d059e29a Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 25 Sep 2020 22:26:44 +0200 Subject: [PATCH 550/674] fix(gateway): correct breadcrumbs on dnslink site This commit was moved from ipfs/kubo@cd1feb3af4e42a835870aca96243b55760ab5f04 --- gateway/core/corehttp/gateway_handler.go | 11 ++++++++--- gateway/core/corehttp/gateway_indexPage.go | 19 +++++++++++++++++-- gateway/core/corehttp/gateway_test.go | 8 +++++--- gateway/core/corehttp/hostname.go | 21 ++++++++++++++------- 4 files changed, 44 insertions(+), 15 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index b9e7f144b..cff82fef7 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -379,8 +379,9 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request hash := resolvedPath.Cid().String() - // Storage for gateway URL to be used when linking to other rootIDs. This - // will be blank unless subdomain resolution is being used for this request. + // Gateway root URL to be used when linking to other rootIDs. + // This will be blank unless subdomain or DNSLink resolution is being used + // for this request. var gwURL string // Get gateway hostname and build gateway URL. @@ -396,11 +397,15 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request Listing: dirListing, Size: size, Path: urlPath, - Breadcrumbs: breadcrumbs(urlPath), + Breadcrumbs: breadcrumbs(urlPath, gwURL), BackLink: backLink, Hash: hash, } + // TODO: remove logging below + // tplDataJSON, _ := json.MarshalIndent(tplData, "", " ") + // fmt.Println(string(tplDataJSON)) + err = listingTemplate.Execute(w, tplData) if err != nil { internalWebError(w, err) diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index c9a948708..5cbf33bec 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -34,7 +34,7 @@ type breadcrumb struct { Path string } -func breadcrumbs(urlPath string) []breadcrumb { +func breadcrumbs(urlPath string, gwRootURL string) []breadcrumb { var ret []breadcrumb p, err := ipfspath.ParsePath(urlPath) @@ -42,8 +42,9 @@ func breadcrumbs(urlPath string) []breadcrumb { // No breadcrumbs, fallback to bare Path in template return ret } - segs := p.Segments() + ns := segs[0] + contentRoot := segs[1] for i, seg := range segs { if i == 0 { ret = append(ret, breadcrumb{Name: seg}) @@ -55,6 +56,20 @@ func breadcrumbs(urlPath string) []breadcrumb { } } + // Drop the /ipns/ prefix from breadcrumb Paths when directory listing + // on a DNSLink website (loaded due to Host header in HTTP request). + // Necessary because gwRootURL won't have a public gateway mounted. + if ns == "ipns" && (("//" + contentRoot) == gwRootURL) { + prefix := "/ipns/" + contentRoot + for i, crumb := range ret { + if strings.HasPrefix(crumb.Path, prefix) { + ret[i].Path = strings.Replace(crumb.Path, prefix, "", 1) + } + } + // Make contentRoot breadcrumb link to the website root + ret[1].Path = "/" + } + return ret } diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index f4d6d810d..46bf76a5e 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -391,6 +391,8 @@ func TestIPNSHostnameRedirect(t *testing.T) { } } +// Test directory listing on DNSLink website +// (scenario when Host header is the same as URL hostname) func TestIPNSHostnameBacklinks(t *testing.T) { ns := mockNamesys{} ts, api, ctx := newTestServerAndNode(t, ns) @@ -445,7 +447,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s := string(body) t.Logf("body: %s\n", string(body)) - if !matchPathOrBreadcrumbs(s, "/ipns/example.net/foo? #<'") { + if !matchPathOrBreadcrumbs(s, "/ipns/example.net/foo? #<'") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { @@ -511,7 +513,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s = string(body) t.Logf("body: %s\n", string(body)) - if !matchPathOrBreadcrumbs(s, "/ipns/example.net/foo? #<'/bar") { + if !matchPathOrBreadcrumbs(s, "/ipns/example.net/foo? #<'/bar") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { @@ -545,7 +547,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { s = string(body) t.Logf("body: %s\n", string(body)) - if !matchPathOrBreadcrumbs(s, "/ipns/example.net") { + if !matchPathOrBreadcrumbs(s, "/ipns/example.net") { t.Fatalf("expected a path in directory listing") } if !strings.Contains(s, "") { diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 8b2666afb..4a531a4d3 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -129,7 +129,7 @@ func HostnameOption() ServeOption { if !gw.NoDNSLink && isDNSLinkRequest(r.Context(), coreAPI, host) { // rewrite path and handle as DNSLink r.URL.Path = "/ipns/" + stripPort(host) + r.URL.Path - childMux.ServeHTTP(w, r) + childMux.ServeHTTP(w, withHostnameContext(r, host)) return } @@ -143,10 +143,6 @@ func HostnameOption() ServeOption { if gw, hostname, ns, rootID, ok := knownSubdomainDetails(host, knownGateways); ok { // Looks like we're using a known gateway in subdomain mode. - // Add gateway hostname context for linking to other root ids. - // Example: localhost/ipfs/{cid} - ctx := context.WithValue(r.Context(), "gw-hostname", hostname) - // Assemble original path prefix. pathPrefix := "/" + ns + "/" + rootID @@ -201,7 +197,7 @@ func HostnameOption() ServeOption { r.URL.Path = pathPrefix + r.URL.Path // Serve path request - childMux.ServeHTTP(w, r.WithContext(ctx)) + childMux.ServeHTTP(w, withHostnameContext(r, hostname)) return } // We don't have a known gateway. Fallback on DNSLink lookup @@ -213,7 +209,7 @@ func HostnameOption() ServeOption { if !cfg.Gateway.NoDNSLink && isDNSLinkRequest(r.Context(), coreAPI, host) { // rewrite path and handle as DNSLink r.URL.Path = "/ipns/" + stripPort(host) + r.URL.Path - childMux.ServeHTTP(w, r) + childMux.ServeHTTP(w, withHostnameContext(r, host)) return } @@ -234,6 +230,17 @@ type wildcardHost struct { spec *config.GatewaySpec } +// Extends request context to include hostname of a canonical gateway root +// (subdomain root or dnslink fqdn) +func withHostnameContext(r *http.Request, hostname string) *http.Request { + // This is required for links on directory listing pages to work correctly + // on subdomain and dnslink gateways. While DNSlink could read value from + // Host header, subdomain gateways have more comples rules (knownSubdomainDetails) + // More: https://github.com/ipfs/dir-index-html/issues/42 + ctx := context.WithValue(r.Context(), "gw-hostname", hostname) + return r.WithContext(ctx) +} + func prepareKnownGateways(publicGateways map[string]*config.GatewaySpec) gatewayHosts { var hosts gatewayHosts From 543a726c18dd5384f6039f209a53c03c3af33a3d Mon Sep 17 00:00:00 2001 From: Rafael Ramalho Date: Mon, 28 Sep 2020 18:10:23 +0100 Subject: [PATCH 551/674] chore: bump webui version This commit was moved from ipfs/kubo@43b8a314f16a90bf5be7e85bb719a216fc425c14 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index b0f4256c8..c41be6300 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeianwe4vy7sprht5sm3hshvxjeqhwcmvbzq73u55sdhqngmohkjgs4" // v2.11.1 +const WebUIPath = "/ipfs/bafybeifekmcbbi4nwyj4aasti6x3nuhyli464wfjjfdjg4xnz53lhyiedq" // v2.11.2 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeianwe4vy7sprht5sm3hshvxjeqhwcmvbzq73u55sdhqngmohkjgs4", "/ipfs/bafybeicitin4p7ggmyjaubqpi3xwnagrwarsy6hiihraafk5rcrxqxju6m", "/ipfs/bafybeihpetclqvwb4qnmumvcn7nh4pxrtugrlpw4jgjpqicdxsv7opdm6e", "/ipfs/bafybeibnnxd4etu4tq5fuhu3z5p4rfu3buabfkeyr3o3s4h6wtesvvw6mu", From 0872de957ebe8c8ad0dd0fe06526747f763a7808 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 28 Sep 2020 14:09:29 +0200 Subject: [PATCH 552/674] fix(gw): links in CID column on dir listing This switches go-ipfs to dir-index-html after https://github.com/ipfs/dir-index-html/pull/43 got merged to master This commit was moved from ipfs/kubo@c94bd768d2f755c8825674e72539d49a82503d12 --- gateway/core/corehttp/gateway_handler.go | 5 ++++- gateway/core/corehttp/gateway_indexPage.go | 23 ++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index cff82fef7..e531640da 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -391,13 +391,16 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request gwURL = "" } + dnslink := hasDNSLinkOrigin(gwURL, urlPath) + // See comment above where originalUrlPath is declared. tplData := listingTemplateData{ GatewayURL: gwURL, + DNSLink: dnslink, Listing: dirListing, Size: size, Path: urlPath, - Breadcrumbs: breadcrumbs(urlPath, gwURL), + Breadcrumbs: breadcrumbs(urlPath, dnslink), BackLink: backLink, Hash: hash, } diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index 5cbf33bec..f735aa0e6 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -13,6 +13,7 @@ import ( // structs for directory listing type listingTemplateData struct { GatewayURL string + DNSLink bool Listing []directoryItem Size string Path string @@ -34,7 +35,7 @@ type breadcrumb struct { Path string } -func breadcrumbs(urlPath string, gwRootURL string) []breadcrumb { +func breadcrumbs(urlPath string, dnslinkOrigin bool) []breadcrumb { var ret []breadcrumb p, err := ipfspath.ParsePath(urlPath) @@ -43,7 +44,6 @@ func breadcrumbs(urlPath string, gwRootURL string) []breadcrumb { return ret } segs := p.Segments() - ns := segs[0] contentRoot := segs[1] for i, seg := range segs { if i == 0 { @@ -56,10 +56,11 @@ func breadcrumbs(urlPath string, gwRootURL string) []breadcrumb { } } - // Drop the /ipns/ prefix from breadcrumb Paths when directory listing - // on a DNSLink website (loaded due to Host header in HTTP request). - // Necessary because gwRootURL won't have a public gateway mounted. - if ns == "ipns" && (("//" + contentRoot) == gwRootURL) { + // Drop the /ipns/ prefix from breadcrumb Paths when directory + // listing on a DNSLink website (loaded due to Host header in HTTP + // request). Necessary because the hostname most likely won't have a + // public gateway mounted. + if dnslinkOrigin { prefix := "/ipns/" + contentRoot for i, crumb := range ret { if strings.HasPrefix(crumb.Path, prefix) { @@ -77,6 +78,16 @@ func shortHash(hash string) string { return (hash[0:4] + "\u2026" + hash[len(hash)-4:]) } +// helper to detect DNSLink website context +// (when hostname from gwURL is matching /ipns/ in path) +func hasDNSLinkOrigin(gwURL string, path string) bool { + if gwURL != "" { + dnslinkRoot := strings.Replace(gwURL, "//", "/ipns/", 1) + return strings.HasPrefix(path, dnslinkRoot) + } + return false +} + var listingTemplate *template.Template func init() { From 60703d471be14206fbe4f76134eedfd1f146a491 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 29 Sep 2020 02:27:28 +0200 Subject: [PATCH 553/674] test(gw): add t0115-gateway-dir-listing.sh to sharness This adds proper end-to-end tests for directory listing on Gateway port that protects us against regressions oni each gw type: - path gateway - subdomain gateway - dnslink website gateway Tests cover: - etag/unicode support - breadcrumbs - file name column - hash column This commit was moved from ipfs/kubo@3ed46d995fee555f924b9163e491e37845ad8818 --- gateway/core/corehttp/gateway_handler.go | 4 ---- gateway/core/corehttp/gateway_indexPage.go | 4 ++-- gateway/core/corehttp/gateway_test.go | 12 +++++++++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index e531640da..9af249520 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -405,10 +405,6 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request Hash: hash, } - // TODO: remove logging below - // tplDataJSON, _ := json.MarshalIndent(tplData, "", " ") - // fmt.Println(string(tplDataJSON)) - err = listingTemplate.Execute(w, tplData) if err != nil { internalWebError(w, err) diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index f735aa0e6..6e1722116 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -82,8 +82,8 @@ func shortHash(hash string) string { // (when hostname from gwURL is matching /ipns/ in path) func hasDNSLinkOrigin(gwURL string, path string) bool { if gwURL != "" { - dnslinkRoot := strings.Replace(gwURL, "//", "/ipns/", 1) - return strings.HasPrefix(path, dnslinkRoot) + fqdn := stripPort(strings.TrimPrefix(gwURL, "//")) + return strings.HasPrefix(path, "/ipns/"+fqdn) } return false } diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 46bf76a5e..f98b4a773 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -393,6 +393,8 @@ func TestIPNSHostnameRedirect(t *testing.T) { // Test directory listing on DNSLink website // (scenario when Host header is the same as URL hostname) +// This is basic regression test: additional end-to-end tests +// can be found in test/sharness/t0115-gateway-dir-listing.sh func TestIPNSHostnameBacklinks(t *testing.T) { ns := mockNamesys{} ts, api, ctx := newTestServerAndNode(t, ns) @@ -439,7 +441,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { t.Fatal(err) } - // expect correct backlinks + // expect correct links body, err := ioutil.ReadAll(res.Body) if err != nil { t.Fatalf("error reading response: %s", err) @@ -456,6 +458,10 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } + if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } + if !strings.Contains(s, " Date: Tue, 6 Oct 2020 19:57:18 +0200 Subject: [PATCH 554/674] feat: ipfs-webui v2.11.3 https://github.com/ipfs-shipyard/ipfs-webui/releases/tag/v2.11.3 This commit was moved from ipfs/kubo@00147106f42158fccee0f74373cd86dec977b23d --- gateway/core/corehttp/webui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index c41be6300..24def6c4d 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeifekmcbbi4nwyj4aasti6x3nuhyli464wfjjfdjg4xnz53lhyiedq" // v2.11.2 +const WebUIPath = "/ipfs/bafybeigv2xkwu2v27rx56m7ndg5dnz4b7235pn33andlriqhyy5s6nwyvq" // v2.11.3 // this is a list of all past webUI paths. var WebUIPaths = []string{ From 3fa5b9e913c8eeb771fd140fd317af6e509b0785 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 7 Oct 2020 15:01:32 +0200 Subject: [PATCH 555/674] feat: ipfs-webui v2.11.4 This commit was moved from ipfs/kubo@f62656630bf6eedd75b6f87f53cae930cd6bb824 --- gateway/core/corehttp/webui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 24def6c4d..b52644c96 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeigv2xkwu2v27rx56m7ndg5dnz4b7235pn33andlriqhyy5s6nwyvq" // v2.11.3 +const WebUIPath = "/ipfs/bafybeif4zkmu7qdhkpf3pnhwxipylqleof7rl6ojbe7mq3fzogz6m4xk3i" // v2.11.4 // this is a list of all past webUI paths. var WebUIPaths = []string{ From ce0319c3f7d65560828d5dd3f1a73b16227e34ce Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 14 Oct 2020 00:46:57 +0200 Subject: [PATCH 556/674] fix(gw): preserve query on website redirect This commit was moved from ipfs/kubo@6ffd0aa22ea6a454740c3b8c83a566d4faa3dc62 --- gateway/core/corehttp/gateway_handler.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index b7a2b7e38..30d2a563e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -290,7 +290,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request goget := r.URL.Query().Get("go-get") == "1" if dirwithoutslash && !goget { // See comment above where originalUrlPath is declared. - http.Redirect(w, r, originalUrlPath+"/", 302) + suffix := "/" + if r.URL.RawQuery != "" { + // preserve query parameters + suffix = suffix + "?" + r.URL.RawQuery + } + http.Redirect(w, r, originalUrlPath+suffix, 302) return } From 28276f8871387e1fa903ea7f08f9381ed08012d1 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 20 Oct 2020 00:40:46 +0200 Subject: [PATCH 557/674] fix: localhost API access via ipv6 This adds localhost ipv6 addresses to the allowlist for use in browser context and fixes WebUI on ipv6-only deployments: http://[::1]:5001/webui We were missing CORS/Origin tests for API port so I've added basic ones and included localhost/127.0.0.1/::1 variants. This commit was moved from ipfs/kubo@d1c20bdff75d96a72ee0fe004c01a606df933c23 --- gateway/core/corehttp/commands.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 0f9b8d603..c5443f6eb 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -40,6 +40,8 @@ const APIPath = "/api/v0" var defaultLocalhostOrigins = []string{ "http://127.0.0.1:", "https://127.0.0.1:", + "http://[::1]:", + "https://[::1]:", "http://localhost:", "https://localhost:", } From a91aef2509e6843f8bf352197e162721651e2627 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Tue, 1 Dec 2020 11:01:40 -0500 Subject: [PATCH 558/674] p2p-proxy: better request length checking This commit was moved from ipfs/kubo@a329e4fc6674909336c56fae2258c6f906af0dbf --- gateway/core/corehttp/p2p_proxy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/p2p_proxy.go b/gateway/core/corehttp/p2p_proxy.go index 0a615c33a..c4b34b592 100644 --- a/gateway/core/corehttp/p2p_proxy.go +++ b/gateway/core/corehttp/p2p_proxy.go @@ -65,7 +65,7 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { } split = strings.SplitN(path, "/", 7) - if split[3] != "x" || split[5] != "http" { + if len(split) < 7 || split[3] != "x" || split[5] != "http" { return nil, fmt.Errorf("Invalid request path '%s'", path) } From 83dca91226d4f031529bd162b5a7e1db020d15c6 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Tue, 1 Dec 2020 11:02:48 -0500 Subject: [PATCH 559/674] p2p-proxy: earlier peerID validation check This commit was moved from ipfs/kubo@76f3395ee6c455679d2659a3e1281a98fb3050ec --- gateway/core/corehttp/p2p_proxy.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gateway/core/corehttp/p2p_proxy.go b/gateway/core/corehttp/p2p_proxy.go index c4b34b592..1dee5055a 100644 --- a/gateway/core/corehttp/p2p_proxy.go +++ b/gateway/core/corehttp/p2p_proxy.go @@ -9,6 +9,7 @@ import ( "strings" core "github.com/ipfs/go-ipfs/core" + peer "github.com/libp2p/go-libp2p-core/peer" protocol "github.com/libp2p/go-libp2p-core/protocol" p2phttp "github.com/libp2p/go-libp2p-http" @@ -60,6 +61,10 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { return nil, fmt.Errorf("Invalid request path '%s'", path) } + if _, err := peer.Decode(split[2]); err != nil { + return nil, fmt.Errorf("Invalid request path '%s'", path) + } + if split[3] == "http" { return &proxyRequest{split[2], protocol.ID("/http"), split[4]}, nil } From d9719f1fd4378867bb14cc2f50c38398d3f2d98f Mon Sep 17 00:00:00 2001 From: lanzafame Date: Fri, 24 Jul 2020 12:59:26 +1000 Subject: [PATCH 560/674] register quic opencensus metrics This commit was moved from ipfs/kubo@3d9821260adabb6b8a573fc5cdd7a4619f663d50 --- gateway/core/corehttp/metrics.go | 47 +++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 1288484d3..e5bd81283 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -3,9 +3,14 @@ package corehttp import ( "net" "net/http" + "time" core "github.com/ipfs/go-ipfs/core" + "go.opencensus.io/stats/view" + "go.opencensus.io/zpages" + ocprom "contrib.go.opencensus.io/exporter/prometheus" + quicmetrics "github.com/lucas-clemente/quic-go/metrics" prometheus "github.com/prometheus/client_golang/prometheus" promhttp "github.com/prometheus/client_golang/prometheus/promhttp" ) @@ -18,9 +23,43 @@ func MetricsScrapingOption(path string) ServeOption { } } +// This adds collection of OpenCensus metrics +func MetricsOpenCensusCollectionOption() ServeOption { + return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { + log.Error("Init OpenCensus") + + promRegistry := prometheus.NewRegistry() + pe, err := ocprom.NewExporter(ocprom.Options{ + Namespace: "ipfs_oc", + Registry: promRegistry, + OnError: func(err error) { + log.Errorw("OC ERROR", "error", err) + }, + }) + if err != nil { + return nil, err + } + + // register prometheus with opencensus + view.RegisterExporter(pe) + view.SetReportingPeriod(2 * time.Second) + + if err := view.Register(quicmetrics.DefaultViews...); err != nil { + return nil, err + } + + // Construct the mux + zpages.Handle(mux, "/ocmetrics/debug") + mux.Handle("/ocmetrics", pe) + + return mux, nil + } +} + // This adds collection of net/http-related metrics func MetricsCollectionOption(handlerName string) ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { + promRegistry := prometheus.NewRegistry() // Adapted from github.com/prometheus/client_golang/prometheus/http.go // Work around https://github.com/prometheus/client_golang/pull/311 opts := prometheus.SummaryOpts{ @@ -40,7 +79,7 @@ func MetricsCollectionOption(handlerName string) ServeOption { }, []string{"method", "code"}, ) - if err := prometheus.Register(reqCnt); err != nil { + if err := promRegistry.Register(reqCnt); err != nil { if are, ok := err.(prometheus.AlreadyRegisteredError); ok { reqCnt = are.ExistingCollector.(*prometheus.CounterVec) } else { @@ -51,7 +90,7 @@ func MetricsCollectionOption(handlerName string) ServeOption { opts.Name = "request_duration_seconds" opts.Help = "The HTTP request latencies in seconds." reqDur := prometheus.NewSummaryVec(opts, nil) - if err := prometheus.Register(reqDur); err != nil { + if err := promRegistry.Register(reqDur); err != nil { if are, ok := err.(prometheus.AlreadyRegisteredError); ok { reqDur = are.ExistingCollector.(*prometheus.SummaryVec) } else { @@ -62,7 +101,7 @@ func MetricsCollectionOption(handlerName string) ServeOption { opts.Name = "request_size_bytes" opts.Help = "The HTTP request sizes in bytes." reqSz := prometheus.NewSummaryVec(opts, nil) - if err := prometheus.Register(reqSz); err != nil { + if err := promRegistry.Register(reqSz); err != nil { if are, ok := err.(prometheus.AlreadyRegisteredError); ok { reqSz = are.ExistingCollector.(*prometheus.SummaryVec) } else { @@ -73,7 +112,7 @@ func MetricsCollectionOption(handlerName string) ServeOption { opts.Name = "response_size_bytes" opts.Help = "The HTTP response sizes in bytes." resSz := prometheus.NewSummaryVec(opts, nil) - if err := prometheus.Register(resSz); err != nil { + if err := promRegistry.Register(resSz); err != nil { if are, ok := err.(prometheus.AlreadyRegisteredError); ok { resSz = are.ExistingCollector.(*prometheus.SummaryVec) } else { From aca550418da5eec808492aee2baff31c3b8e4903 Mon Sep 17 00:00:00 2001 From: lanzafame Date: Tue, 29 Sep 2020 10:35:07 +1000 Subject: [PATCH 561/674] change the scraping url This commit was moved from ipfs/kubo@024bf80e6a574e791b397bcba5875dae76c32c3b --- gateway/core/corehttp/metrics.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index e5bd81283..de0dcd743 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -49,8 +49,8 @@ func MetricsOpenCensusCollectionOption() ServeOption { } // Construct the mux - zpages.Handle(mux, "/ocmetrics/debug") - mux.Handle("/ocmetrics", pe) + zpages.Handle(mux, "/debug/metrics/oc/debugz") + mux.Handle("/debug/metrics/oc", pe) return mux, nil } From 1e0ccb6bcc3057664820be01cb86913bc88bb2e3 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Tue, 8 Dec 2020 21:46:49 -0500 Subject: [PATCH 562/674] fix: decrease log level of opencensus initialization This commit was moved from ipfs/kubo@fb3316ad05c0497fa2d5ba752e0efdebf40ac054 --- gateway/core/corehttp/metrics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index de0dcd743..8a73111fc 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -26,7 +26,7 @@ func MetricsScrapingOption(path string) ServeOption { // This adds collection of OpenCensus metrics func MetricsOpenCensusCollectionOption() ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - log.Error("Init OpenCensus") + log.Info("Init OpenCensus") promRegistry := prometheus.NewRegistry() pe, err := ocprom.NewExporter(ocprom.Options{ From 9da88513e4f649941524b2f2521769c37906f231 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 1 Jan 2021 21:39:42 +0100 Subject: [PATCH 563/674] feat(gw): support inlined DNSLink names with TLS Problem statement and rationale for doing this can be found under "Option C" at: https://github.com/ipfs/in-web-browsers/issues/169 TLDR is: `https://dweb.link/ipns/my.v-long.example.com` can be loaded from a subdomain gateway with a wildcard TLS cert if represented as a single DNS label: `https://my-v--long-example-com.ipns.dweb.link` This commit was moved from ipfs/kubo@09178aa717689a0ef9fd2042ad355320a16ffb35 --- gateway/core/corehttp/hostname.go | 125 ++++++++++++++++++++----- gateway/core/corehttp/hostname_test.go | 111 ++++++++++++++++++---- 2 files changed, 198 insertions(+), 38 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 4a531a4d3..7e2d07821 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -91,7 +91,7 @@ func HostnameOption() ServeOption { if gw.UseSubdomains { // Yes, redirect if applicable // Example: dweb.link/ipfs/{cid} → {cid}.ipfs.dweb.link - newURL, err := toSubdomainURL(host, r.URL.Path, r) + newURL, err := toSubdomainURL(host, r.URL.Path, r, coreAPI) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -126,7 +126,7 @@ func HostnameOption() ServeOption { // Not a whitelisted path // Try DNSLink, if it was not explicitly disabled for the hostname - if !gw.NoDNSLink && isDNSLinkRequest(r.Context(), coreAPI, host) { + if !gw.NoDNSLink && isDNSLinkName(r.Context(), coreAPI, host) { // rewrite path and handle as DNSLink r.URL.Path = "/ipns/" + stripPort(host) + r.URL.Path childMux.ServeHTTP(w, withHostnameContext(r, host)) @@ -139,8 +139,10 @@ func HostnameOption() ServeOption { } // HTTP Host check: is this one of our subdomain-based "known gateways"? - // Example: {cid}.ipfs.localhost, {cid}.ipfs.dweb.link - if gw, hostname, ns, rootID, ok := knownSubdomainDetails(host, knownGateways); ok { + // IPFS details extracted from the host: {rootID}.{ns}.{gwHostname} + // /ipfs/ example: {cid}.ipfs.localhost:8080, {cid}.ipfs.dweb.link + // /ipns/ example: {libp2p-key}.ipns.localhost:8080, {inlined-dnslink-fqdn}.ipns.dweb.link + if gw, gwHostname, ns, rootID, ok := knownSubdomainDetails(host, knownGateways); ok { // Looks like we're using a known gateway in subdomain mode. // Assemble original path prefix. @@ -156,14 +158,14 @@ func HostnameOption() ServeOption { // Check if rootID is a valid CID if rootCID, err := cid.Decode(rootID); err == nil { // Do we need to redirect root CID to a canonical DNS representation? - dnsCID, err := toDNSPrefix(rootID, rootCID) + dnsCID, err := toDNSLabel(rootID, rootCID) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } if !strings.HasPrefix(r.Host, dnsCID) { dnsPrefix := "/" + ns + "/" + dnsCID - newURL, err := toSubdomainURL(hostname, dnsPrefix+r.URL.Path, r) + newURL, err := toSubdomainURL(gwHostname, dnsPrefix+r.URL.Path, r, coreAPI) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -179,7 +181,7 @@ func HostnameOption() ServeOption { // Do we need to fix multicodec in PeerID represented as CIDv1? if isPeerIDNamespace(ns) { if rootCID.Type() != cid.Libp2pKey { - newURL, err := toSubdomainURL(hostname, pathPrefix+r.URL.Path, r) + newURL, err := toSubdomainURL(gwHostname, pathPrefix+r.URL.Path, r, coreAPI) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -191,13 +193,36 @@ func HostnameOption() ServeOption { } } } + } else { // rootID is not a CID.. + + // Check if rootID is a single DNS label with an inlined + // DNSLink FQDN a single DNS label. We support this so + // loading DNSLink names over TLS "just works" on public + // HTTP gateways. + // + // Rationale for doing this can be found under "Option C" + // at: https://github.com/ipfs/in-web-browsers/issues/169 + // + // TLDR is: + // https://dweb.link/ipns/my.v-long.example.com + // can be loaded from a subdomain gateway with a wildcard + // TLS cert if represented as a single DNS label: + // https://my-v--long-example-com.ipns.dweb.link + if ns == "ipns" && !strings.Contains(rootID, ".") { + // my-v--long-example-com → my.v-long.example.com + dnslinkFQDN := toDNSLinkFQDN(rootID) + if isDNSLinkName(r.Context(), coreAPI, dnslinkFQDN) { + // update path prefix to use real FQDN with DNSLink + pathPrefix = "/ipns/" + dnslinkFQDN + } + } } // Rewrite the path to not use subdomains r.URL.Path = pathPrefix + r.URL.Path // Serve path request - childMux.ServeHTTP(w, withHostnameContext(r, hostname)) + childMux.ServeHTTP(w, withHostnameContext(r, gwHostname)) return } // We don't have a known gateway. Fallback on DNSLink lookup @@ -206,7 +231,7 @@ func HostnameOption() ServeOption { // 1. is wildcard DNSLink enabled (Gateway.NoDNSLink=false)? // 2. does Host header include a fully qualified domain name (FQDN)? // 3. does DNSLink record exist in DNS? - if !cfg.Gateway.NoDNSLink && isDNSLinkRequest(r.Context(), coreAPI, host) { + if !cfg.Gateway.NoDNSLink && isDNSLinkName(r.Context(), coreAPI, host) { // rewrite path and handle as DNSLink r.URL.Path = "/ipns/" + stripPort(host) + r.URL.Path childMux.ServeHTTP(w, withHostnameContext(r, host)) @@ -305,9 +330,10 @@ func isKnownHostname(hostname string, knownGateways gatewayHosts) (gw *config.Ga } // Parses Host header and looks for a known gateway matching subdomain host. -// If found, returns GatewaySpec and subdomain components. +// If found, returns GatewaySpec and subdomain components extracted from Host +// header: {rootID}.{ns}.{gwHostname} // Note: hostname is host + optional port -func knownSubdomainDetails(hostname string, knownGateways gatewayHosts) (gw *config.GatewaySpec, knownHostname, ns, rootID string, ok bool) { +func knownSubdomainDetails(hostname string, knownGateways gatewayHosts) (gw *config.GatewaySpec, gwHostname, ns, rootID string, ok bool) { labels := strings.Split(hostname, ".") // Look for FQDN of a known gateway hostname. // Example: given "dist.ipfs.io.ipns.dweb.link": @@ -336,9 +362,8 @@ func knownSubdomainDetails(hostname string, knownGateways gatewayHosts) (gw *con return nil, "", "", "", false } -// isDNSLinkRequest returns bool that indicates if request -// should return data from content path listed in DNSLink record (if exists) -func isDNSLinkRequest(ctx context.Context, ipfs iface.CoreAPI, host string) bool { +// isDNSLinkName returns bool if a valid DNS TXT record exist for provided host +func isDNSLinkName(ctx context.Context, ipfs iface.CoreAPI, host string) bool { fqdn := stripPort(host) if len(fqdn) == 0 && !isd.IsDomain(fqdn) { return false @@ -368,8 +393,8 @@ func isPeerIDNamespace(ns string) bool { } } -// Converts an identifier to DNS-safe representation that fits in 63 characters -func toDNSPrefix(rootID string, rootCID cid.Cid) (prefix string, err error) { +// Converts a CID to DNS-safe representation that fits in 63 characters +func toDNSLabel(rootID string, rootCID cid.Cid) (dnsCID string, err error) { // Return as-is if things fit if len(rootID) <= dnsLabelMaxLength { return rootID, nil @@ -388,12 +413,45 @@ func toDNSPrefix(rootID string, rootCID cid.Cid) (prefix string, err error) { return "", fmt.Errorf("CID incompatible with DNS label length limit of 63: %s", rootID) } +// Returns true if HTTP request involves TLS certificate. +// See https://github.com/ipfs/in-web-browsers/issues/169 to uderstand how it +// impacts DNSLink websites on public gateways. +func isHTTPSRequest(r *http.Request) bool { + // X-Forwarded-Proto if added by a reverse proxy + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto + xproto := r.Header.Get("X-Forwarded-Proto") + // Is request a native TLS (not used atm, but future-proofing) + // or a proxied HTTPS (eg. go-ipfs behind nginx at a public gw)? + return r.URL.Scheme == "https" || xproto == "https" +} + +// Converts a FQDN to DNS-safe representation that fits in 63 characters: +// my.v-long.example.com → my-v--long-example-com +func toDNSLinkDNSLabel(fqdn string) (dnsLabel string, err error) { + dnsLabel = strings.ReplaceAll(fqdn, "-", "--") + dnsLabel = strings.ReplaceAll(dnsLabel, ".", "-") + if len(dnsLabel) > dnsLabelMaxLength { + return "", fmt.Errorf("DNSLink representation incompatible with DNS label length limit of 63: %s", dnsLabel) + } + return dnsLabel, nil +} + +// Converts a DNS-safe representation of DNSLink FQDN to real FQDN: +// my-v--long-example-com → my.v-long.example.com +func toDNSLinkFQDN(dnsLabel string) (fqdn string) { + fqdn = strings.ReplaceAll(dnsLabel, "--", "@") // @ placeholder is unused in DNS labels + fqdn = strings.ReplaceAll(fqdn, "-", ".") + fqdn = strings.ReplaceAll(fqdn, "@", "-") + return fqdn +} + // Converts a hostname/path to a subdomain-based URL, if applicable. -func toSubdomainURL(hostname, path string, r *http.Request) (redirURL string, err error) { +func toSubdomainURL(hostname, path string, r *http.Request, ipfs iface.CoreAPI) (redirURL string, err error) { var scheme, ns, rootID, rest string query := r.URL.RawQuery parts := strings.SplitN(path, "/", 4) + isHTTPS := isHTTPSRequest(r) safeRedirectURL := func(in string) (out string, err error) { safeURI, err := url.ParseRequestURI(in) if err != nil { @@ -402,10 +460,7 @@ func toSubdomainURL(hostname, path string, r *http.Request) (redirURL string, er return safeURI.String(), nil } - // Support X-Forwarded-Proto if added by a reverse proxy - // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto - xproto := r.Header.Get("X-Forwarded-Proto") - if xproto == "https" { + if isHTTPS { scheme = "https:" } else { scheme = "http:" @@ -475,10 +530,36 @@ func toSubdomainURL(hostname, path string, r *http.Request) (redirURL string, er } // 2. Make sure CID fits in a DNS label, adjust encoding if needed // (https://github.com/ipfs/go-ipfs/issues/7318) - rootID, err = toDNSPrefix(rootID, rootCID) + rootID, err = toDNSLabel(rootID, rootCID) if err != nil { return "", err } + } else { // rootID is not a CID + + // Check if rootID is a FQDN with DNSLink and convert it to TLS-safe + // representation that fits in a single DNS label. We support this so + // loading DNSLink names over TLS "just works" on public HTTP gateways + // that pass 'https' in X-Forwarded-Proto to go-ipfs. + // + // Rationale can be found under "Option C" + // at: https://github.com/ipfs/in-web-browsers/issues/169 + // + // TLDR is: + // /ipns/my.v-long.example.com + // can be loaded from a subdomain gateway with a wildcard TLS cert if + // represented as a single DNS label: + // https://my-v--long-example-com.ipns.dweb.link + if isHTTPS && ns == "ipns" && strings.Contains(rootID, ".") { + if isDNSLinkName(r.Context(), ipfs, rootID) { + // my.v-long.example.com → my-v--long-example-com + dnsLabel, err := toDNSLinkDNSLabel(rootID) + if err != nil { + return "", err + } + // update path prefix to use real FQDN with DNSLink + rootID = dnsLabel + } + } } return safeRedirectURL(fmt.Sprintf( diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index 3a316ede5..f469a7720 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -2,41 +2,121 @@ package corehttp import ( "errors" + "net/http" "net/http/httptest" "testing" cid "github.com/ipfs/go-cid" config "github.com/ipfs/go-ipfs-config" + files "github.com/ipfs/go-ipfs-files" + coreapi "github.com/ipfs/go-ipfs/core/coreapi" + path "github.com/ipfs/go-path" ) func TestToSubdomainURL(t *testing.T) { - r := httptest.NewRequest("GET", "http://request-stub.example.com", nil) + ns := mockNamesys{} + n, err := newNodeWithMockNamesys(ns) + if err != nil { + t.Fatal(err) + } + coreAPI, err := coreapi.NewCoreAPI(n) + if err != nil { + t.Fatal(err) + } + testCID, err := coreAPI.Unixfs().Add(n.Context(), files.NewBytesFile([]byte("fnord"))) + if err != nil { + t.Fatal(err) + } + ns["/ipns/dnslink.long-name.example.com"] = path.FromString(testCID.String()) + ns["/ipns/dnslink.too-long.f1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5o.example.com"] = path.FromString(testCID.String()) + httpRequest := httptest.NewRequest("GET", "http://127.0.0.1:8080", nil) + httpsRequest := httptest.NewRequest("GET", "https://https-request-stub.example.com", nil) + httpsProxiedRequest := httptest.NewRequest("GET", "http://proxied-https-request-stub.example.com", nil) + httpsProxiedRequest.Header.Set("X-Forwarded-Proto", "https") + for _, test := range []struct { // in: - hostname string - path string + request *http.Request + gwHostname string + path string // out: url string err error }{ // DNSLink - {"localhost", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost/", nil}, + {httpRequest, "localhost", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost/", nil}, // Hostname with port - {"localhost:8080", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost:8080/", nil}, + {httpRequest, "localhost:8080", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost:8080/", nil}, // CIDv0 → CIDv1base32 - {"localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.localhost/", nil}, + {httpRequest, "localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.localhost/", nil}, // CIDv1 with long sha512 - {"localhost", "/ipfs/bafkrgqe3ohjcjplc6n4f3fwunlj6upltggn7xqujbsvnvyw764srszz4u4rshq6ztos4chl4plgg4ffyyxnayrtdi5oc4xb2332g645433aeg", "", errors.New("CID incompatible with DNS label length limit of 63: kf1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5oj")}, + {httpRequest, "localhost", "/ipfs/bafkrgqe3ohjcjplc6n4f3fwunlj6upltggn7xqujbsvnvyw764srszz4u4rshq6ztos4chl4plgg4ffyyxnayrtdi5oc4xb2332g645433aeg", "", errors.New("CID incompatible with DNS label length limit of 63: kf1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5oj")}, // PeerID as CIDv1 needs to have libp2p-key multicodec - {"localhost", "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", "http://k2k4r8n0flx3ra0y5dr8fmyvwbzy3eiztmtq6th694k5a3rznayp3e4o.ipns.localhost/", nil}, - {"localhost", "/ipns/bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "http://k2k4r8l9ja7hkzynavdqup76ou46tnvuaqegbd04a4o1mpbsey0meucb.ipns.localhost/", nil}, + {httpRequest, "localhost", "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", "http://k2k4r8n0flx3ra0y5dr8fmyvwbzy3eiztmtq6th694k5a3rznayp3e4o.ipns.localhost/", nil}, + {httpRequest, "localhost", "/ipns/bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "http://k2k4r8l9ja7hkzynavdqup76ou46tnvuaqegbd04a4o1mpbsey0meucb.ipns.localhost/", nil}, // PeerID: ed25519+identity multihash → CIDv1Base36 - {"localhost", "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://k51qzi5uqu5di608geewp3nqkg0bpujoasmka7ftkyxgcm3fh1aroup0gsdrna.ipns.localhost/", nil}, - {"sub.localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.sub.localhost/", nil}, + {httpRequest, "localhost", "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://k51qzi5uqu5di608geewp3nqkg0bpujoasmka7ftkyxgcm3fh1aroup0gsdrna.ipns.localhost/", nil}, + {httpRequest, "sub.localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.sub.localhost/", nil}, + // HTTPS requires DNSLink name to fit in a single DNS label – see "Option C" from https://github.com/ipfs/in-web-browsers/issues/169 + {httpRequest, "dweb.link", "/ipns/dnslink.long-name.example.com", "http://dnslink.long-name.example.com.ipns.dweb.link/", nil}, + {httpsRequest, "dweb.link", "/ipns/dnslink.long-name.example.com", "https://dnslink-long--name-example-com.ipns.dweb.link/", nil}, + {httpsProxiedRequest, "dweb.link", "/ipns/dnslink.long-name.example.com", "https://dnslink-long--name-example-com.ipns.dweb.link/", nil}, } { - url, err := toSubdomainURL(test.hostname, test.path, r) + url, err := toSubdomainURL(test.gwHostname, test.path, test.request, coreAPI) if url != test.url || !equalError(err, test.err) { - t.Errorf("(%s, %s) returned (%s, %v), expected (%s, %v)", test.hostname, test.path, url, err, test.url, test.err) + t.Errorf("(%s, %s) returned (%s, %v), expected (%s, %v)", test.gwHostname, test.path, url, err, test.url, test.err) + } + } +} + +func TestToDNSLinkDNSLabel(t *testing.T) { + for _, test := range []struct { + in string + out string + err error + }{ + {"dnslink.long-name.example.com", "dnslink-long--name-example-com", nil}, + {"dnslink.too-long.f1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5o.example.com", "", errors.New("DNSLink representation incompatible with DNS label length limit of 63: dnslink-too--long-f1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5o-example-com")}, + } { + out, err := toDNSLinkDNSLabel(test.in) + if out != test.out || !equalError(err, test.err) { + t.Errorf("(%s) returned (%s, %v), expected (%s, %v)", test.in, out, err, test.out, test.err) + } + } +} + +func TestToDNSLinkFQDN(t *testing.T) { + for _, test := range []struct { + in string + out string + }{ + {"singlelabel", "singlelabel"}, + {"docs-ipfs-io", "docs.ipfs.io"}, + {"dnslink-long--name-example-com", "dnslink.long-name.example.com"}, + } { + out := toDNSLinkFQDN(test.in) + if out != test.out { + t.Errorf("(%s) returned (%s), expected (%s)", test.in, out, test.out) + } + } +} + +func TestIsHTTPSRequest(t *testing.T) { + httpRequest := httptest.NewRequest("GET", "http://127.0.0.1:8080", nil) + httpsRequest := httptest.NewRequest("GET", "https://https-request-stub.example.com", nil) + httpsProxiedRequest := httptest.NewRequest("GET", "http://proxied-https-request-stub.example.com", nil) + httpsProxiedRequest.Header.Set("X-Forwarded-Proto", "https") + for _, test := range []struct { + in *http.Request + out bool + }{ + {httpRequest, false}, + {httpsRequest, true}, + {httpsProxiedRequest, true}, + } { + out := isHTTPSRequest(test.in) + if out != test.out { + t.Errorf("(%+v): returned %t, expected %t", test.in, out, test.out) } } } @@ -77,10 +157,9 @@ func TestPortStripping(t *testing.T) { t.Errorf("(%s): returned '%s', expected '%s'", test.in, out, test.out) } } - } -func TestDNSPrefix(t *testing.T) { +func TestToDNSLabel(t *testing.T) { for _, test := range []struct { in string out string @@ -96,7 +175,7 @@ func TestDNSPrefix(t *testing.T) { {"bafkrgqe3ohjcjplc6n4f3fwunlj6upltggn7xqujbsvnvyw764srszz4u4rshq6ztos4chl4plgg4ffyyxnayrtdi5oc4xb2332g645433aeg", "", errors.New("CID incompatible with DNS label length limit of 63: kf1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5oj")}, } { inCID, _ := cid.Decode(test.in) - out, err := toDNSPrefix(test.in, inCID) + out, err := toDNSLabel(test.in, inCID) if out != test.out || !equalError(err, test.err) { t.Errorf("(%s): returned (%s, %v) expected (%s, %v)", test.in, out, err, test.out, test.err) } From f554a8b30258457ae987eb3bee55f40a5b49d567 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 8 Jan 2021 00:31:46 +0100 Subject: [PATCH 564/674] test: false for isHTTPSRequest As suggested in https://github.com/ipfs/go-ipfs/pull/7847#discussion_r551933162 This commit was moved from ipfs/kubo@88dd257ace53b56759a760ab9df189e43a7fda17 --- gateway/core/corehttp/hostname.go | 2 +- gateway/core/corehttp/hostname_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 7e2d07821..3ce1d08c2 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -414,7 +414,7 @@ func toDNSLabel(rootID string, rootCID cid.Cid) (dnsCID string, err error) { } // Returns true if HTTP request involves TLS certificate. -// See https://github.com/ipfs/in-web-browsers/issues/169 to uderstand how it +// See https://github.com/ipfs/in-web-browsers/issues/169 to understand how it // impacts DNSLink websites on public gateways. func isHTTPSRequest(r *http.Request) bool { // X-Forwarded-Proto if added by a reverse proxy diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index f469a7720..3ece5e88f 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -106,6 +106,9 @@ func TestIsHTTPSRequest(t *testing.T) { httpsRequest := httptest.NewRequest("GET", "https://https-request-stub.example.com", nil) httpsProxiedRequest := httptest.NewRequest("GET", "http://proxied-https-request-stub.example.com", nil) httpsProxiedRequest.Header.Set("X-Forwarded-Proto", "https") + httpProxiedRequest := httptest.NewRequest("GET", "http://proxied-http-request-stub.example.com", nil) + httpProxiedRequest.Header.Set("X-Forwarded-Proto", "http") + oddballRequest := httptest.NewRequest("GET", "foo://127.0.0.1:8080", nil) for _, test := range []struct { in *http.Request out bool @@ -113,6 +116,8 @@ func TestIsHTTPSRequest(t *testing.T) { {httpRequest, false}, {httpsRequest, true}, {httpsProxiedRequest, true}, + {httpProxiedRequest, false}, + {oddballRequest, false}, } { out := isHTTPSRequest(test.in) if out != test.out { From 5ff1d82b067d6d88ef6e079c13d1a2b9f405b94d Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 14 Jan 2021 20:14:35 +0100 Subject: [PATCH 565/674] fix: check if rootID has DNSLink before uninlining This kinda enables to run their custom DNS resolver with custom tlds/names that are independent from the public DNS network. This commit was moved from ipfs/kubo@f932510b88a08bb674e4191431b3d33a7b3ec690 --- gateway/core/corehttp/hostname.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 3ce1d08c2..da133f7ab 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -209,11 +209,14 @@ func HostnameOption() ServeOption { // TLS cert if represented as a single DNS label: // https://my-v--long-example-com.ipns.dweb.link if ns == "ipns" && !strings.Contains(rootID, ".") { - // my-v--long-example-com → my.v-long.example.com - dnslinkFQDN := toDNSLinkFQDN(rootID) - if isDNSLinkName(r.Context(), coreAPI, dnslinkFQDN) { - // update path prefix to use real FQDN with DNSLink - pathPrefix = "/ipns/" + dnslinkFQDN + // if there is no TXT recordfor rootID + if !isDNSLinkName(r.Context(), coreAPI, rootID) { + // my-v--long-example-com → my.v-long.example.com + dnslinkFQDN := toDNSLinkFQDN(rootID) + if isDNSLinkName(r.Context(), coreAPI, dnslinkFQDN) { + // update path prefix to use real FQDN with DNSLink + pathPrefix = "/ipns/" + dnslinkFQDN + } } } } From 3820d16721968c4aac6c5f026841079e38aba1ba Mon Sep 17 00:00:00 2001 From: Dennis Trautwein Date: Sat, 5 Dec 2020 17:02:40 +0100 Subject: [PATCH 566/674] feat: support requests from registerProtocolHandler This commit adds support for requests produced by navigator.registerProtocolHandler on gateways. Now one can register `dweb.link` as an URI handler for `ipfs://`: ``` navigator.registerProtocolHandler('ipfs', 'https://dweb.link/ipfs/?uri=%s', 'ipfs resolver') ``` Then opening `ipfs://QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR` will produce an HTTP GET call to: ``` https://dweb.link/ipfs?uri=ipfs%3A%2F%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR ``` The query parameter `uri` will now be parsed and the given content identifier resolved via: `https://dweb.link/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR` This commit was moved from ipfs/kubo@36368ee4ddfb8943d96f2e34b3283d11a1498ff6 --- gateway/core/corehttp/gateway_handler.go | 17 ++++++++++ gateway/core/corehttp/gateway_test.go | 41 ++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index b78bacb02..8c34ba454 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -181,6 +181,23 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } originalUrlPath := prefix + requestURI.Path + // Query parameter handling to support requests produced by navigator.registerProtocolHandler. + // E.g. This code will redirect calls to /ipfs/?uri=ipfs%3A%2F%2Fcontent-identifier + // to /ipfs/content-identifier. + if uri := r.URL.Query().Get("uri"); uri != "" { + u, err := url.Parse(uri) + if err != nil { + webError(w, "failed to parse uri query parameter", err, http.StatusBadRequest) + return + } + if u.Scheme != "ipfs" && u.Scheme != "ipns" { + webError(w, "uri query parameter scheme must be ipfs or ipns", err, http.StatusBadRequest) + return + } + http.Redirect(w, r, gopath.Join("/", prefix, u.Scheme, u.Host), http.StatusMovedPermanently) + return + } + // Service Worker registration request if r.Header.Get("Service-Worker") == "script" { // Disallow Service Worker registration on namespace roots diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index f98b4a773..049ccd27c 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -161,6 +161,47 @@ func matchPathOrBreadcrumbs(s string, expected string) bool { return matched } +func TestUriQueryRedirect(t *testing.T) { + ts, _, _ := newTestServerAndNode(t, mockNamesys{}) + + cid := "QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR" + for i, test := range []struct { + path string + status int + location string + }{ + {"/ipfs/?uri=ipfs://" + cid, http.StatusMovedPermanently, "/ipfs/" + cid}, + {"/ipfs/?uri=ipfs%3A%2F%2F" + cid, http.StatusMovedPermanently, "/ipfs/" + cid}, + {"/ipfs?uri=ipfs://" + cid, http.StatusMovedPermanently, "/ipfs/?uri=ipfs://" + cid}, + {"/ipfs/?uri=ipns://" + cid, http.StatusMovedPermanently, "/ipns/" + cid}, + {"/ipns?uri=ipns://" + cid, http.StatusMovedPermanently, "/ipns/?uri=ipns://" + cid}, + {"/ipns/?uri=ipfs://" + cid, http.StatusMovedPermanently, "/ipfs/" + cid}, + {"/ipns/?uri=ipfs://" + cid, http.StatusMovedPermanently, "/ipfs/" + cid}, + {"/ipfs/?uri=unsupported://" + cid, http.StatusBadRequest, ""}, + {"/ipfs/?uri=" + cid, http.StatusBadRequest, ""}, + } { + + r, err := http.NewRequest(http.MethodGet, ts.URL+test.path, nil) + if err != nil { + t.Fatal(err) + } + resp, err := doWithoutRedirect(r) + if err != nil { + t.Fatal(err) + } + defer resp.Body.Close() + + if resp.StatusCode != test.status { + t.Errorf("(%d) got %d, expected %d from %s", i, resp.StatusCode, test.status, ts.URL+test.path) + } + + locHdr := resp.Header.Get("Location") + if locHdr != test.location { + t.Errorf("(%d) location header got %s, expected %s from %s", i, locHdr, test.location, ts.URL+test.path) + } + } +} + func TestGatewayGet(t *testing.T) { ns := mockNamesys{} ts, api, ctx := newTestServerAndNode(t, ns) From 1def9d88b3de9b00cc62f3bf899d66939518dac5 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sat, 12 Dec 2020 02:43:16 +0100 Subject: [PATCH 567/674] fix: ?uri= url-decode and preserve query This makes ?uri= param able to process URIs passed by web browsers https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler This commit was moved from ipfs/kubo@3de5b14e0c248ab1f611215836ace4e134a25b61 --- gateway/core/corehttp/gateway_handler.go | 21 ++++++++++++++++----- gateway/core/corehttp/gateway_test.go | 10 ++++++++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 8c34ba454..2ef4fefb1 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -181,10 +181,17 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } originalUrlPath := prefix + requestURI.Path - // Query parameter handling to support requests produced by navigator.registerProtocolHandler. - // E.g. This code will redirect calls to /ipfs/?uri=ipfs%3A%2F%2Fcontent-identifier - // to /ipfs/content-identifier. - if uri := r.URL.Query().Get("uri"); uri != "" { + // ?uri query param support for requests produced by web browsers + // via navigator.registerProtocolHandler Web API + // https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler + // TLDR: redirect /ipfs/?uri=ipfs%3A%2F%2Fcid%3Fquery%3Dval to /ipfs/cid?query=val + if uriParam := r.URL.Query().Get("uri"); uriParam != "" { + // Browsers will pass URI in URL-escaped form, we need to unescape it first + uri, err := url.QueryUnescape(uriParam) + if err != nil { + webError(w, "failed to unescape uri query parameter", err, http.StatusBadRequest) + return + } u, err := url.Parse(uri) if err != nil { webError(w, "failed to parse uri query parameter", err, http.StatusBadRequest) @@ -194,7 +201,11 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request webError(w, "uri query parameter scheme must be ipfs or ipns", err, http.StatusBadRequest) return } - http.Redirect(w, r, gopath.Join("/", prefix, u.Scheme, u.Host), http.StatusMovedPermanently) + path := u.Path + if u.RawQuery != "" { // preserve query if present + path = path + "?" + u.RawQuery + } + http.Redirect(w, r, gopath.Join("/", prefix, u.Scheme, u.Host, path), http.StatusMovedPermanently) return } diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 049ccd27c..d4fcf5a38 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -170,12 +170,18 @@ func TestUriQueryRedirect(t *testing.T) { status int location string }{ + // - Browsers will send original URI in URL-escaped form + // - We expect query parameters to be persisted + // - We drop fragments, as those should not be sent by a browser + {"/ipfs/?uri=ipfs%3A%2F%2FQmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco%2Fwiki%2FFoo_%C4%85%C4%99.html%3Ffilename%3Dtest-%C4%99.html%23header-%C4%85", http.StatusMovedPermanently, "/ipfs/QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco/wiki/Foo_%c4%85%c4%99.html?filename=test-%c4%99.html"}, + {"/ipfs/?uri=ipns%3A%2F%2Fexample.com%2Fwiki%2FFoo_%C4%85%C4%99.html%3Ffilename%3Dtest-%C4%99.html", http.StatusMovedPermanently, "/ipns/example.com/wiki/Foo_%c4%85%c4%99.html?filename=test-%c4%99.html"}, {"/ipfs/?uri=ipfs://" + cid, http.StatusMovedPermanently, "/ipfs/" + cid}, - {"/ipfs/?uri=ipfs%3A%2F%2F" + cid, http.StatusMovedPermanently, "/ipfs/" + cid}, {"/ipfs?uri=ipfs://" + cid, http.StatusMovedPermanently, "/ipfs/?uri=ipfs://" + cid}, {"/ipfs/?uri=ipns://" + cid, http.StatusMovedPermanently, "/ipns/" + cid}, + {"/ipns/?uri=ipfs%3A%2F%2FQmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco%2Fwiki%2FFoo_%C4%85%C4%99.html%3Ffilename%3Dtest-%C4%99.html%23header-%C4%85", http.StatusMovedPermanently, "/ipfs/QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco/wiki/Foo_%c4%85%c4%99.html?filename=test-%c4%99.html"}, + {"/ipns/?uri=ipns%3A%2F%2Fexample.com%2Fwiki%2FFoo_%C4%85%C4%99.html%3Ffilename%3Dtest-%C4%99.html", http.StatusMovedPermanently, "/ipns/example.com/wiki/Foo_%c4%85%c4%99.html?filename=test-%c4%99.html"}, {"/ipns?uri=ipns://" + cid, http.StatusMovedPermanently, "/ipns/?uri=ipns://" + cid}, - {"/ipns/?uri=ipfs://" + cid, http.StatusMovedPermanently, "/ipfs/" + cid}, + {"/ipns/?uri=ipns://" + cid, http.StatusMovedPermanently, "/ipns/" + cid}, {"/ipns/?uri=ipfs://" + cid, http.StatusMovedPermanently, "/ipfs/" + cid}, {"/ipfs/?uri=unsupported://" + cid, http.StatusBadRequest, ""}, {"/ipfs/?uri=" + cid, http.StatusBadRequest, ""}, From ed06bc0867417c2c052bd93add91f5be7a2ef068 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sat, 12 Dec 2020 12:28:42 +0100 Subject: [PATCH 568/674] refactor: remove redundant urlescape URL.Query() will already decode the query parameters This commit was moved from ipfs/kubo@abb25a1cfc202ab4427bb1d3fa0c16d6e2700bd5 --- gateway/core/corehttp/gateway_handler.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 2ef4fefb1..e47198174 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -186,13 +186,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler // TLDR: redirect /ipfs/?uri=ipfs%3A%2F%2Fcid%3Fquery%3Dval to /ipfs/cid?query=val if uriParam := r.URL.Query().Get("uri"); uriParam != "" { - // Browsers will pass URI in URL-escaped form, we need to unescape it first - uri, err := url.QueryUnescape(uriParam) - if err != nil { - webError(w, "failed to unescape uri query parameter", err, http.StatusBadRequest) - return - } - u, err := url.Parse(uri) + u, err := url.Parse(uriParam) if err != nil { webError(w, "failed to parse uri query parameter", err, http.StatusBadRequest) return From 8582496d91e36fcd2a31c9f06898c292f8175b67 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 14 Jan 2021 20:51:02 +0100 Subject: [PATCH 569/674] test: cover 2 remaining lines This commit was moved from ipfs/kubo@a0f90d3a140a4616c5930bcb8c62445717ccc857 --- gateway/core/corehttp/gateway_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index d4fcf5a38..a05e456ab 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -184,6 +184,7 @@ func TestUriQueryRedirect(t *testing.T) { {"/ipns/?uri=ipns://" + cid, http.StatusMovedPermanently, "/ipns/" + cid}, {"/ipns/?uri=ipfs://" + cid, http.StatusMovedPermanently, "/ipfs/" + cid}, {"/ipfs/?uri=unsupported://" + cid, http.StatusBadRequest, ""}, + {"/ipfs/?uri=invaliduri", http.StatusBadRequest, ""}, {"/ipfs/?uri=" + cid, http.StatusBadRequest, ""}, } { From cd00521ca493bfd381b9562edd6ec811077a01a0 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 29 Jan 2021 22:08:16 +0100 Subject: [PATCH 570/674] fix: remove use of Clear-Site-Data We used Clear-Site-Data to cushion transition period for local gateway exposed at http://localhost while we were still figuring out security-related details. In the final implementation subdomain gateways are not tied to a hostname explicitly, which removes the risk of cookies leaking, removing the need for the header. Turns out it causes issues for Firefox users, so let's just remove it. Closes https://github.com/ipfs-shipyard/ipfs-companion/issues/977 This commit was moved from ipfs/kubo@d61ae2bcb48be6067acaaa9c0d1c51483f891b0b --- gateway/core/corehttp/hostname.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index da133f7ab..d4006cb84 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -97,15 +97,6 @@ func HostnameOption() ServeOption { return } if newURL != "" { - // Just to be sure single Origin can't be abused in - // web browsers that ignored the redirect for some - // reason, Clear-Site-Data header clears browsing - // data (cookies, storage etc) associated with - // hostname's root Origin - // Note: we can't use "*" due to bug in Chromium: - // https://bugs.chromium.org/p/chromium/issues/detail?id=898503 - w.Header().Set("Clear-Site-Data", "\"cookies\", \"storage\"") - // Set "Location" header with redirect destination. // It is ignored by curl in default mode, but will // be respected by user agents that follow From 326de7ab79559df1284d093fcc344db3f1ac5db5 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sat, 20 Feb 2021 00:09:17 +0100 Subject: [PATCH 571/674] =?UTF-8?q?feat(gw):=20/ipfs/ipfs/{cid}=20?= =?UTF-8?q?=E2=86=92=20/ipfs/{cid}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will try to recover from invalid paths like /ipfs/ipfs/{cid} and redirect to proper one, when possible. This commit was moved from ipfs/kubo@15e3732afd29b380f6a12b06303dce49abe46f82 --- gateway/core/corehttp/gateway_handler.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index e47198174..cf5acf209 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -217,6 +217,17 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request parsedPath := ipath.New(urlPath) if err := parsedPath.IsValid(); err != nil { + // Attempt to fix redundant /ipfs/ namespace as long resulting + // 'intended' path is valid. This is in case gremlins were tickled + // wrong way and user ended up at /ipfs/ipfs/{cid} or /ipfs/ipns/{id} + // like in bafybeien3m7mdn6imm425vc2s22erzyhbvk5n3ofzgikkhmdkh5cuqbpbq + // :^)) + intendedPath := ipath.New(strings.TrimPrefix(urlPath, "/ipfs")) + if err2 := intendedPath.IsValid(); err2 == nil { + intendedURL := strings.Replace(r.URL.String(), urlPath, intendedPath.String(), 1) + http.Redirect(w, r, intendedURL, http.StatusMovedPermanently) + return + } webError(w, "invalid ipfs path", err, http.StatusBadRequest) return } From 9cb582111483c667e0a8da26f688c9fb5dd7a21e Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sat, 27 Feb 2021 00:48:12 +0100 Subject: [PATCH 572/674] refactor: show error, delay redirect This implements error page that does not hide the problem, but still redirects to a valid path after short delay: https://github.com/ipfs/go-ipfs/pull/7930#issuecomment-786882748 This commit was moved from ipfs/kubo@dae7387584ed15beebac70e32b878113cdb904b6 --- gateway/core/corehttp/gateway_handler.go | 34 ++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index cf5acf209..289fdd725 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -3,6 +3,7 @@ package corehttp import ( "context" "fmt" + "html/template" "io" "mime" "net/http" @@ -36,6 +37,16 @@ const ( var onlyAscii = regexp.MustCompile("[[:^ascii:]]") +// HTML-based redirect for errors which can be recovered from, but we want +// to provide hint to people that they should fix things on their end. +var redirectTemplate = template.Must(template.New("redirect").Parse(`
{{.ErrorMsg}}
(if a redirect does not happen in 10 seconds, use "{{.SuggestedPath}}" instead)
`)) + +type redirectTemplateData struct { + RedirectURL string + SuggestedPath string + ErrorMsg string +} + // gatewayHandler is a HTTP handler that serves IPFS objects (accessible by default at /ipfs/) // (it serves requests like GET /ipfs/QmVRzPKPzNtSrEzBFm2UZfxmPAgnaLke4DMcerbsGGSaFe/link) type gatewayHandler struct { @@ -216,19 +227,32 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } parsedPath := ipath.New(urlPath) - if err := parsedPath.IsValid(); err != nil { - // Attempt to fix redundant /ipfs/ namespace as long resulting + if pathErr := parsedPath.IsValid(); pathErr != nil { + // Attempt to fix redundant /ipfs/ namespace as long as resulting // 'intended' path is valid. This is in case gremlins were tickled // wrong way and user ended up at /ipfs/ipfs/{cid} or /ipfs/ipns/{id} // like in bafybeien3m7mdn6imm425vc2s22erzyhbvk5n3ofzgikkhmdkh5cuqbpbq // :^)) intendedPath := ipath.New(strings.TrimPrefix(urlPath, "/ipfs")) - if err2 := intendedPath.IsValid(); err2 == nil { + if err := intendedPath.IsValid(); err == nil { intendedURL := strings.Replace(r.URL.String(), urlPath, intendedPath.String(), 1) - http.Redirect(w, r, intendedURL, http.StatusMovedPermanently) + // return HTML that + // - points at correct canonical path via header + // - displays error + // - redirects to intendedURL after a delay + err = redirectTemplate.Execute(w, redirectTemplateData{ + RedirectURL: intendedURL, + SuggestedPath: intendedPath.String(), + ErrorMsg: pathErr.Error(), + }) + if err != nil { + internalWebError(w, err) + return + } return } - webError(w, "invalid ipfs path", err, http.StatusBadRequest) + // unable to fix path, returning error + webError(w, "invalid ipfs path", pathErr, http.StatusBadRequest) return } From 0c39f74628f83ce2f44e0a836b6c1554f18353f2 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Fri, 19 Feb 2021 00:33:43 +0100 Subject: [PATCH 573/674] Extract the namesys and the keystore submodules Namesys is a very useful submodule. Given a ValueStore and a Datastore it can resolve and publish /ipns/ paths. This functionality does not need to be sequestered inside go-ipfs as it can and should be used without IPFS, for example, for implementing lightweight IPNS publishing services or for resolving /ipns/ paths. "keystore" extraction was necessary, as there is a dependency to it in namesys. Keystore is also a useful module by itself within the stack. Fixes #6537 This commit was moved from ipfs/kubo@3db9551f7948809e6f9104651412557fbde08af0 --- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/hostname.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index a05e456ab..053c22f9a 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -14,8 +14,8 @@ import ( version "github.com/ipfs/go-ipfs" core "github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/core/coreapi" - namesys "github.com/ipfs/go-ipfs/namesys" repo "github.com/ipfs/go-ipfs/repo" + namesys "github.com/ipfs/go-namesys" datastore "github.com/ipfs/go-datastore" syncds "github.com/ipfs/go-datastore/sync" diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index da133f7ab..6d2955e49 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -12,7 +12,7 @@ import ( cid "github.com/ipfs/go-cid" core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" - namesys "github.com/ipfs/go-ipfs/namesys" + namesys "github.com/ipfs/go-namesys" isd "github.com/jbenet/go-is-domain" "github.com/libp2p/go-libp2p-core/peer" mbase "github.com/multiformats/go-multibase" From 86742cd7eeec9c1fa36e61fd4995a0966955aae0 Mon Sep 17 00:00:00 2001 From: lanzafame Date: Wed, 17 Mar 2021 10:15:42 +1000 Subject: [PATCH 574/674] revert registration of metrics against unexposed prom registry This commit was moved from ipfs/kubo@4ba03fa8df0e0d398bb946421c2a179828595221 --- gateway/core/corehttp/metrics.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 8a73111fc..f84a6e18d 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -59,7 +59,6 @@ func MetricsOpenCensusCollectionOption() ServeOption { // This adds collection of net/http-related metrics func MetricsCollectionOption(handlerName string) ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - promRegistry := prometheus.NewRegistry() // Adapted from github.com/prometheus/client_golang/prometheus/http.go // Work around https://github.com/prometheus/client_golang/pull/311 opts := prometheus.SummaryOpts{ @@ -79,7 +78,7 @@ func MetricsCollectionOption(handlerName string) ServeOption { }, []string{"method", "code"}, ) - if err := promRegistry.Register(reqCnt); err != nil { + if err := prometheus.Register(reqCnt); err != nil { if are, ok := err.(prometheus.AlreadyRegisteredError); ok { reqCnt = are.ExistingCollector.(*prometheus.CounterVec) } else { @@ -90,7 +89,7 @@ func MetricsCollectionOption(handlerName string) ServeOption { opts.Name = "request_duration_seconds" opts.Help = "The HTTP request latencies in seconds." reqDur := prometheus.NewSummaryVec(opts, nil) - if err := promRegistry.Register(reqDur); err != nil { + if err := prometheus.Register(reqDur); err != nil { if are, ok := err.(prometheus.AlreadyRegisteredError); ok { reqDur = are.ExistingCollector.(*prometheus.SummaryVec) } else { @@ -101,7 +100,7 @@ func MetricsCollectionOption(handlerName string) ServeOption { opts.Name = "request_size_bytes" opts.Help = "The HTTP request sizes in bytes." reqSz := prometheus.NewSummaryVec(opts, nil) - if err := promRegistry.Register(reqSz); err != nil { + if err := prometheus.Register(reqSz); err != nil { if are, ok := err.(prometheus.AlreadyRegisteredError); ok { reqSz = are.ExistingCollector.(*prometheus.SummaryVec) } else { @@ -112,7 +111,7 @@ func MetricsCollectionOption(handlerName string) ServeOption { opts.Name = "response_size_bytes" opts.Help = "The HTTP response sizes in bytes." resSz := prometheus.NewSummaryVec(opts, nil) - if err := promRegistry.Register(resSz); err != nil { + if err := prometheus.Register(resSz); err != nil { if are, ok := err.(prometheus.AlreadyRegisteredError); ok { resSz = are.ExistingCollector.(*prometheus.SummaryVec) } else { From 0eca026a7a6d033564d20062c19f68c2033f2ece Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 18 Mar 2021 21:15:07 +0100 Subject: [PATCH 575/674] refactor: addressing review - moved to separate utility function - return Bad Request error - improved escaping of values passed via URL path This commit was moved from ipfs/kubo@b81b7549d34e0b549c0035286bdd02b2be50030c --- gateway/core/corehttp/gateway_handler.go | 60 +++++++++++++++--------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 289fdd725..2d6b5f037 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -39,7 +39,17 @@ var onlyAscii = regexp.MustCompile("[[:^ascii:]]") // HTML-based redirect for errors which can be recovered from, but we want // to provide hint to people that they should fix things on their end. -var redirectTemplate = template.Must(template.New("redirect").Parse(`
{{.ErrorMsg}}
(if a redirect does not happen in 10 seconds, use "{{.SuggestedPath}}" instead)
`)) +var redirectTemplate = template.Must(template.New("redirect").Parse(` + + + + + + + +
{{.ErrorMsg}}
(if a redirect does not happen in 10 seconds, use "{{.SuggestedPath}}" instead)
+ +`)) type redirectTemplateData struct { RedirectURL string @@ -228,27 +238,9 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request parsedPath := ipath.New(urlPath) if pathErr := parsedPath.IsValid(); pathErr != nil { - // Attempt to fix redundant /ipfs/ namespace as long as resulting - // 'intended' path is valid. This is in case gremlins were tickled - // wrong way and user ended up at /ipfs/ipfs/{cid} or /ipfs/ipns/{id} - // like in bafybeien3m7mdn6imm425vc2s22erzyhbvk5n3ofzgikkhmdkh5cuqbpbq - // :^)) - intendedPath := ipath.New(strings.TrimPrefix(urlPath, "/ipfs")) - if err := intendedPath.IsValid(); err == nil { - intendedURL := strings.Replace(r.URL.String(), urlPath, intendedPath.String(), 1) - // return HTML that - // - points at correct canonical path via header - // - displays error - // - redirects to intendedURL after a delay - err = redirectTemplate.Execute(w, redirectTemplateData{ - RedirectURL: intendedURL, - SuggestedPath: intendedPath.String(), - ErrorMsg: pathErr.Error(), - }) - if err != nil { - internalWebError(w, err) - return - } + if fixErr := fixupSuperfluousNamespace(w, r, pathErr, urlPath); fixErr == nil { + // the error was due to redundant namespace, which we were able to fix + // by returning error/redirect page, nothing left to do here return } // unable to fix path, returning error @@ -816,3 +808,27 @@ func preferred404Filename(acceptHeaders []string) (string, string, error) { return "", "", fmt.Errorf("there is no 404 file for the requested content types") } + +// Attempt to fix redundant /ipfs/ namespace as long as resulting +// 'intended' path is valid. This is in case gremlins were tickled +// wrong way and user ended up at /ipfs/ipfs/{cid} or /ipfs/ipns/{id} +// like in bafybeien3m7mdn6imm425vc2s22erzyhbvk5n3ofzgikkhmdkh5cuqbpbq :^)) +func fixupSuperfluousNamespace(w http.ResponseWriter, r *http.Request, pathErr error, urlPath string) error { + intendedPath := ipath.New(strings.TrimPrefix(urlPath, "/ipfs")) + err := intendedPath.IsValid() + if err != nil { + // not a superfluous namespace + return err + } + intendedURL := strings.Replace(r.URL.String(), urlPath, intendedPath.String(), 1) + // return HTTP 400 (Bad Request) with HTML error page that: + // - points at correct canonical path via header + // - displays human-readable error + // - redirects to intendedURL after a short delay + w.WriteHeader(http.StatusBadRequest) + return redirectTemplate.Execute(w, redirectTemplateData{ + RedirectURL: intendedURL, + SuggestedPath: intendedPath.String(), + ErrorMsg: fmt.Sprintf("invalid path: %q should be %q", urlPath, intendedPath.String()), + }) +} From 9e5f7baa4e9ee82c4f5d1050acc1848959850b73 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 18 Mar 2021 21:48:04 +0100 Subject: [PATCH 576/674] refactor: explicit prefix check https://github.com/ipfs/go-ipfs/pull/7930#discussion_r584001161 This commit was moved from ipfs/kubo@450baef0e9c113e4751b559dd0562f7c98302668 --- gateway/core/corehttp/gateway_handler.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 2d6b5f037..07f08656c 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -238,7 +238,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request parsedPath := ipath.New(urlPath) if pathErr := parsedPath.IsValid(); pathErr != nil { - if fixErr := fixupSuperfluousNamespace(w, r, pathErr, urlPath); fixErr == nil { + if fixupSuperfluousNamespace(w, r, urlPath) { // the error was due to redundant namespace, which we were able to fix // by returning error/redirect page, nothing left to do here return @@ -813,12 +813,13 @@ func preferred404Filename(acceptHeaders []string) (string, string, error) { // 'intended' path is valid. This is in case gremlins were tickled // wrong way and user ended up at /ipfs/ipfs/{cid} or /ipfs/ipns/{id} // like in bafybeien3m7mdn6imm425vc2s22erzyhbvk5n3ofzgikkhmdkh5cuqbpbq :^)) -func fixupSuperfluousNamespace(w http.ResponseWriter, r *http.Request, pathErr error, urlPath string) error { +func fixupSuperfluousNamespace(w http.ResponseWriter, r *http.Request, urlPath string) bool { + if !(strings.HasPrefix(urlPath, "/ipfs/ipfs/") || strings.HasPrefix(urlPath, "/ipfs/ipns/")) { + return false // not a superfluous namespace + } intendedPath := ipath.New(strings.TrimPrefix(urlPath, "/ipfs")) - err := intendedPath.IsValid() - if err != nil { - // not a superfluous namespace - return err + if err := intendedPath.IsValid(); err != nil { + return false // not a valid path } intendedURL := strings.Replace(r.URL.String(), urlPath, intendedPath.String(), 1) // return HTTP 400 (Bad Request) with HTML error page that: @@ -830,5 +831,5 @@ func fixupSuperfluousNamespace(w http.ResponseWriter, r *http.Request, pathErr e RedirectURL: intendedURL, SuggestedPath: intendedPath.String(), ErrorMsg: fmt.Sprintf("invalid path: %q should be %q", urlPath, intendedPath.String()), - }) + }) == nil } From b3e5c1f3fccaf4f419a98e261d32ec98f9066e59 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 18 Mar 2021 23:48:53 +0100 Subject: [PATCH 577/674] refactor: safer query handling https://github.com/ipfs/go-ipfs/pull/7930#discussion_r597246135 This commit was moved from ipfs/kubo@a35ffee1364b72e50f66fdd1a03f7a3665d99309 --- gateway/core/corehttp/gateway_handler.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 07f08656c..4d0a34c23 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -238,7 +238,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request parsedPath := ipath.New(urlPath) if pathErr := parsedPath.IsValid(); pathErr != nil { - if fixupSuperfluousNamespace(w, r, urlPath) { + if fixupSuperfluousNamespace(w, urlPath, r.URL.RawQuery) { // the error was due to redundant namespace, which we were able to fix // by returning error/redirect page, nothing left to do here return @@ -813,7 +813,7 @@ func preferred404Filename(acceptHeaders []string) (string, string, error) { // 'intended' path is valid. This is in case gremlins were tickled // wrong way and user ended up at /ipfs/ipfs/{cid} or /ipfs/ipns/{id} // like in bafybeien3m7mdn6imm425vc2s22erzyhbvk5n3ofzgikkhmdkh5cuqbpbq :^)) -func fixupSuperfluousNamespace(w http.ResponseWriter, r *http.Request, urlPath string) bool { +func fixupSuperfluousNamespace(w http.ResponseWriter, urlPath string, urlQuery string) bool { if !(strings.HasPrefix(urlPath, "/ipfs/ipfs/") || strings.HasPrefix(urlPath, "/ipfs/ipns/")) { return false // not a superfluous namespace } @@ -821,7 +821,12 @@ func fixupSuperfluousNamespace(w http.ResponseWriter, r *http.Request, urlPath s if err := intendedPath.IsValid(); err != nil { return false // not a valid path } - intendedURL := strings.Replace(r.URL.String(), urlPath, intendedPath.String(), 1) + intendedURL := intendedPath.String() + if urlQuery != "" { + // we render HTML, so ensure query entries are properly escaped + q, _ := url.ParseQuery(urlQuery) + intendedURL = intendedURL + "?" + q.Encode() + } // return HTTP 400 (Bad Request) with HTML error page that: // - points at correct canonical path via header // - displays human-readable error From 609ddbcce1f3d6fa83024e1876c0d66aad4604b4 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sat, 20 Mar 2021 00:00:58 +0100 Subject: [PATCH 578/674] fix: no fixup if X-Ipfs-Gateway-Prefix is present https://github.com/ipfs/go-ipfs/pull/7930#discussion_r597976690 This commit was moved from ipfs/kubo@763a120ed28c6cd2e77077c6bb0281c583a6b580 --- gateway/core/corehttp/gateway_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 4d0a34c23..0275c873d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -238,7 +238,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request parsedPath := ipath.New(urlPath) if pathErr := parsedPath.IsValid(); pathErr != nil { - if fixupSuperfluousNamespace(w, urlPath, r.URL.RawQuery) { + if prefix == "" && fixupSuperfluousNamespace(w, urlPath, r.URL.RawQuery) { // the error was due to redundant namespace, which we were able to fix // by returning error/redirect page, nothing left to do here return From 8736ffcf5b16d35403b679dcad2c1f73f8f469f0 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sat, 20 Mar 2021 00:53:08 +0100 Subject: [PATCH 579/674] chore: deprecate Gateway.PathPrefixes Context: https://github.com/ipfs/go-ipfs/issues/7702#issuecomment-803136077 This commit was moved from ipfs/kubo@2f105f79b9fc12c4321a2333652ba1a7fb17e936 --- gateway/core/corehttp/gateway_handler.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index e47198174..261c2920f 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -159,6 +159,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // If the gateway is behind a reverse proxy and mounted at a sub-path, // the prefix header can be set to signal this sub-path. // It will be prepended to links in directory listings and the index.html redirect. + // TODO: this feature is deprecated and will be removed (https://github.com/ipfs/go-ipfs/issues/7702) prefix := "" if prfx := r.Header.Get("X-Ipfs-Gateway-Prefix"); len(prfx) > 0 { for _, p := range i.config.PathPrefixes { From 0d301bd954190d3b316ac7b00440efcfc882c54f Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 12 Apr 2021 18:03:44 +0200 Subject: [PATCH 580/674] fix(gw): remove hardcoded hostnames This closes #7317 by removing hardcoded PL hostnames from default config, making the localhost the only implicit gateway hostname. This commit was moved from ipfs/kubo@9f8964e6f9fe881014d0dd20b9f1a069971c1874 --- gateway/core/corehttp/hostname.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 2030989e2..6740f0e59 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -23,12 +23,7 @@ import ( nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" ) -var defaultPaths = []string{"/ipfs/", "/ipns/", "/api/", "/p2p/", "/version"} - -var pathGatewaySpec = &config.GatewaySpec{ - Paths: defaultPaths, - UseSubdomains: false, -} +var defaultPaths = []string{"/ipfs/", "/ipns/", "/api/", "/p2p/"} var subdomainGatewaySpec = &config.GatewaySpec{ Paths: defaultPaths, @@ -36,10 +31,7 @@ var subdomainGatewaySpec = &config.GatewaySpec{ } var defaultKnownGateways = map[string]*config.GatewaySpec{ - "localhost": subdomainGatewaySpec, - "ipfs.io": pathGatewaySpec, - "gateway.ipfs.io": pathGatewaySpec, - "dweb.link": subdomainGatewaySpec, + "localhost": subdomainGatewaySpec, } // Label's max length in DNS (https://tools.ietf.org/html/rfc1034#page-7) From a1ebcb340098035e75bfca1e2784f31cec545b18 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 28 Apr 2021 10:59:37 -0700 Subject: [PATCH 581/674] chore: update webui to 2.12.1 This commit was moved from ipfs/kubo@a006ded0101c679d6bc38ef3aee36c2d4e04ea43 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index b52644c96..69e848140 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeif4zkmu7qdhkpf3pnhwxipylqleof7rl6ojbe7mq3fzogz6m4xk3i" // v2.11.4 +const WebUIPath = "/ipfs/bafybeid3rof2bfszwia2g7ijjzac5ycaczje3vr3sxdtcxziaf6fvi6mwu" // v2.12.1 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeif4zkmu7qdhkpf3pnhwxipylqleof7rl6ojbe7mq3fzogz6m4xk3i", "/ipfs/bafybeianwe4vy7sprht5sm3hshvxjeqhwcmvbzq73u55sdhqngmohkjgs4", "/ipfs/bafybeicitin4p7ggmyjaubqpi3xwnagrwarsy6hiihraafk5rcrxqxju6m", "/ipfs/bafybeihpetclqvwb4qnmumvcn7nh4pxrtugrlpw4jgjpqicdxsv7opdm6e", From e6f6c42e6ec5a0178971991bb74703ebe7470105 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 30 Apr 2021 16:12:21 +0200 Subject: [PATCH 582/674] feat: ipfs-webui v2.12.2 https://github.com/ipfs/ipfs-webui/releases/tag/v2.12.2 This commit was moved from ipfs/kubo@a9868105f09438d3d6dd3fc3b2a2c85d1bc3fde8 --- gateway/core/corehttp/webui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 69e848140..6191119ca 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeid3rof2bfszwia2g7ijjzac5ycaczje3vr3sxdtcxziaf6fvi6mwu" // v2.12.1 +const WebUIPath = "/ipfs/bafybeifuexpvt6g4bkbmsrlb7rnudskfakn6vdrtoja4ml4zbxne2hu6bq" // v2.12.2 // this is a list of all past webUI paths. var WebUIPaths = []string{ From 3255dd9440c46635cfdf1002a935a375bbbcc627 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sat, 20 Mar 2021 12:54:36 +0800 Subject: [PATCH 583/674] update quic-go to v0.21.0-rc.1 This commit was moved from ipfs/kubo@473d7d5851783c45e95a27bf77ac3292918c641a --- gateway/core/corehttp/metrics.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index f84a6e18d..f34881f41 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -10,7 +10,6 @@ import ( "go.opencensus.io/zpages" ocprom "contrib.go.opencensus.io/exporter/prometheus" - quicmetrics "github.com/lucas-clemente/quic-go/metrics" prometheus "github.com/prometheus/client_golang/prometheus" promhttp "github.com/prometheus/client_golang/prometheus/promhttp" ) @@ -44,10 +43,6 @@ func MetricsOpenCensusCollectionOption() ServeOption { view.RegisterExporter(pe) view.SetReportingPeriod(2 * time.Second) - if err := view.Register(quicmetrics.DefaultViews...); err != nil { - return nil, err - } - // Construct the mux zpages.Handle(mux, "/debug/metrics/oc/debugz") mux.Handle("/debug/metrics/oc", pe) From 37f4857a4d05b88a4241078f48301bc0b92ae921 Mon Sep 17 00:00:00 2001 From: divingpetrel Date: Tue, 13 Apr 2021 16:53:22 +0100 Subject: [PATCH 584/674] feat support non-ICANN DNS This commit was moved from ipfs/kubo@24dd662d381cb60502a996e5be23e1bfd0c51a87 --- gateway/core/corehttp/hostname.go | 9 ++++++--- gateway/core/corehttp/hostname_test.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 6740f0e59..b6246e281 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -13,8 +13,9 @@ import ( core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" namesys "github.com/ipfs/go-namesys" - isd "github.com/jbenet/go-is-domain" "github.com/libp2p/go-libp2p-core/peer" + dns "github.com/miekg/dns" + mbase "github.com/multiformats/go-multibase" config "github.com/ipfs/go-ipfs-config" @@ -351,9 +352,11 @@ func knownSubdomainDetails(hostname string, knownGateways gatewayHosts) (gw *con // isDNSLinkName returns bool if a valid DNS TXT record exist for provided host func isDNSLinkName(ctx context.Context, ipfs iface.CoreAPI, host string) bool { fqdn := stripPort(host) - if len(fqdn) == 0 && !isd.IsDomain(fqdn) { + + if _, ok := dns.IsDomainName(fqdn); !ok && len(fqdn) == 0 { return false } + name := "/ipns/" + fqdn // check if DNSLink exists depth := options.Name.ResolveOption(nsopts.Depth(1)) @@ -473,7 +476,7 @@ func toSubdomainURL(hostname, path string, r *http.Request, ipfs iface.CoreAPI) } // Normalize problematic PeerIDs (eg. ed25519+identity) to CID representation - if isPeerIDNamespace(ns) && !isd.IsDomain(rootID) { + if _, ok := dns.IsDomainName(rootID); !ok && isPeerIDNamespace(ns) { peerID, err := peer.Decode(rootID) // Note: PeerID CIDv1 with protobuf multicodec will fail, but we fix it // in the next block diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index 3ece5e88f..9bee6768a 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -55,7 +55,7 @@ func TestToSubdomainURL(t *testing.T) { {httpRequest, "localhost", "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", "http://k2k4r8n0flx3ra0y5dr8fmyvwbzy3eiztmtq6th694k5a3rznayp3e4o.ipns.localhost/", nil}, {httpRequest, "localhost", "/ipns/bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "http://k2k4r8l9ja7hkzynavdqup76ou46tnvuaqegbd04a4o1mpbsey0meucb.ipns.localhost/", nil}, // PeerID: ed25519+identity multihash → CIDv1Base36 - {httpRequest, "localhost", "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://k51qzi5uqu5di608geewp3nqkg0bpujoasmka7ftkyxgcm3fh1aroup0gsdrna.ipns.localhost/", nil}, + {httpRequest, "localhost", "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5.ipns.localhost/", nil}, {httpRequest, "sub.localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.sub.localhost/", nil}, // HTTPS requires DNSLink name to fit in a single DNS label – see "Option C" from https://github.com/ipfs/in-web-browsers/issues/169 {httpRequest, "dweb.link", "/ipns/dnslink.long-name.example.com", "http://dnslink.long-name.example.com.ipns.dweb.link/", nil}, From f1c5bb9746d73d92a9c5eeb6044c71309b0c1ab6 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 21 Apr 2021 20:36:35 +0200 Subject: [PATCH 585/674] refactor: add isDomainNameAndNotPeerID This ensures we exclude valid PeerIDs from code paths that require DNSLink names. Ref. https://github.com/ipfs/go-ipfs/pull/8071#pullrequestreview-639409245 This commit was moved from ipfs/kubo@28d4d9b327b83cef407a8a79e7162ab54bcfa63d --- gateway/core/corehttp/hostname.go | 20 ++++++++++++++++---- gateway/core/corehttp/hostname_test.go | 21 ++++++++++++++++++++- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index b6246e281..c02c3aeec 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -349,15 +349,27 @@ func knownSubdomainDetails(hostname string, knownGateways gatewayHosts) (gw *con return nil, "", "", "", false } +// isDomainNameAndNotPeerID returns bool if string looks like a valid DNS name AND is not a PeerID +func isDomainNameAndNotPeerID(hostname string) bool { + if len(hostname) == 0 { + return false + } + if _, err := peer.Decode(hostname); err == nil { + return false + } + _, ok := dns.IsDomainName(hostname) + return ok +} + // isDNSLinkName returns bool if a valid DNS TXT record exist for provided host func isDNSLinkName(ctx context.Context, ipfs iface.CoreAPI, host string) bool { - fqdn := stripPort(host) + dnslinkName := stripPort(host) - if _, ok := dns.IsDomainName(fqdn); !ok && len(fqdn) == 0 { + if !isDomainNameAndNotPeerID(dnslinkName) { return false } - name := "/ipns/" + fqdn + name := "/ipns/" + dnslinkName // check if DNSLink exists depth := options.Name.ResolveOption(nsopts.Depth(1)) _, err := ipfs.Name().Resolve(ctx, name, depth) @@ -476,7 +488,7 @@ func toSubdomainURL(hostname, path string, r *http.Request, ipfs iface.CoreAPI) } // Normalize problematic PeerIDs (eg. ed25519+identity) to CID representation - if _, ok := dns.IsDomainName(rootID); !ok && isPeerIDNamespace(ns) { + if isPeerIDNamespace(ns) && !isDomainNameAndNotPeerID(rootID) { peerID, err := peer.Decode(rootID) // Note: PeerID CIDv1 with protobuf multicodec will fail, but we fix it // in the next block diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index 9bee6768a..6575ee1e8 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -55,7 +55,7 @@ func TestToSubdomainURL(t *testing.T) { {httpRequest, "localhost", "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", "http://k2k4r8n0flx3ra0y5dr8fmyvwbzy3eiztmtq6th694k5a3rznayp3e4o.ipns.localhost/", nil}, {httpRequest, "localhost", "/ipns/bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "http://k2k4r8l9ja7hkzynavdqup76ou46tnvuaqegbd04a4o1mpbsey0meucb.ipns.localhost/", nil}, // PeerID: ed25519+identity multihash → CIDv1Base36 - {httpRequest, "localhost", "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5.ipns.localhost/", nil}, + {httpRequest, "localhost", "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://k51qzi5uqu5di608geewp3nqkg0bpujoasmka7ftkyxgcm3fh1aroup0gsdrna.ipns.localhost/", nil}, {httpRequest, "sub.localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.sub.localhost/", nil}, // HTTPS requires DNSLink name to fit in a single DNS label – see "Option C" from https://github.com/ipfs/in-web-browsers/issues/169 {httpRequest, "dweb.link", "/ipns/dnslink.long-name.example.com", "http://dnslink.long-name.example.com.ipns.dweb.link/", nil}, @@ -144,6 +144,25 @@ func TestHasPrefix(t *testing.T) { } } +func TestIsDomainNameAndNotPeerID(t *testing.T) { + for _, test := range []struct { + hostname string + out bool + }{ + {"", false}, + {"example.com", true}, + {"non-icann.something", true}, + {"..", false}, + {"12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", false}, // valid peerid + {"k51qzi5uqu5di608geewp3nqkg0bpujoasmka7ftkyxgcm3fh1aroup0gsdrna", false}, // valid peerid + } { + out := isDomainNameAndNotPeerID(test.hostname) + if out != test.out { + t.Errorf("(%s) returned '%t', expected '%t'", test.hostname, out, test.out) + } + } +} + func TestPortStripping(t *testing.T) { for _, test := range []struct { in string From 6cb184af90eba258e24441f79a4a5e07a44d82ec Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 21 May 2021 19:01:34 +0200 Subject: [PATCH 586/674] fix: webui-2.12.3 This bumps webui to bugfix release based on feedback from 0.9.0-rc1: https://github.com/ipfs/ipfs-webui/releases/tag/v2.12.3 This commit was moved from ipfs/kubo@2c431eb825b3a8ab39eafdf29c41fcc4c25c529d --- gateway/core/corehttp/webui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 6191119ca..8bff09a6b 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeifuexpvt6g4bkbmsrlb7rnudskfakn6vdrtoja4ml4zbxne2hu6bq" // v2.12.2 +const WebUIPath = "/ipfs/bafybeid26vjplsejg7t3nrh7mxmiaaxriebbm4xxrxxdunlk7o337m5sqq" // v2.12.3 // this is a list of all past webUI paths. var WebUIPaths = []string{ From 6fe1b17b62691ec1b0bd4dca071dac365e24a2be Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 21 May 2021 19:01:34 +0200 Subject: [PATCH 587/674] fix: webui-2.12.3 This bumps webui to bugfix release based on feedback from 0.9.0-rc1: https://github.com/ipfs/ipfs-webui/releases/tag/v2.12.3 (cherry picked from commit 6cb184af90eba258e24441f79a4a5e07a44d82ec) This commit was moved from ipfs/kubo@73e35592877820875d334f33a915651ee0530191 --- gateway/core/corehttp/webui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 6191119ca..8bff09a6b 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,7 +1,7 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeifuexpvt6g4bkbmsrlb7rnudskfakn6vdrtoja4ml4zbxne2hu6bq" // v2.12.2 +const WebUIPath = "/ipfs/bafybeid26vjplsejg7t3nrh7mxmiaaxriebbm4xxrxxdunlk7o337m5sqq" // v2.12.3 // this is a list of all past webUI paths. var WebUIPaths = []string{ From 0fb688da39d091e788e01a9536aab23cafa304ba Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 5 Jul 2021 14:55:15 +0200 Subject: [PATCH 588/674] feat: webui v2.12.4 This commit was moved from ipfs/kubo@c7444fb61a4f965b789e4c69942ccc5ad261dce0 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 8bff09a6b..298163e3a 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeid26vjplsejg7t3nrh7mxmiaaxriebbm4xxrxxdunlk7o337m5sqq" // v2.12.3 +const WebUIPath = "/ipfs/bafybeiflkjt66aetfgcrgvv75izymd5kc47g6luepqmfq6zsf5w6ueth6y" // v2.12.4 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeid26vjplsejg7t3nrh7mxmiaaxriebbm4xxrxxdunlk7o337m5sqq", "/ipfs/bafybeif4zkmu7qdhkpf3pnhwxipylqleof7rl6ojbe7mq3fzogz6m4xk3i", "/ipfs/bafybeianwe4vy7sprht5sm3hshvxjeqhwcmvbzq73u55sdhqngmohkjgs4", "/ipfs/bafybeicitin4p7ggmyjaubqpi3xwnagrwarsy6hiihraafk5rcrxqxju6m", From 9f8876ec261fa2cc10360c390788b1cb01de2bc3 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 5 Jul 2021 14:55:15 +0200 Subject: [PATCH 589/674] feat: webui v2.12.4 (cherry picked from commit 0fb688da39d091e788e01a9536aab23cafa304ba) This commit was moved from ipfs/kubo@1df585b10ccf0bc4eceb3ef91fdef8c9f1f2de4b --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 8bff09a6b..298163e3a 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeid26vjplsejg7t3nrh7mxmiaaxriebbm4xxrxxdunlk7o337m5sqq" // v2.12.3 +const WebUIPath = "/ipfs/bafybeiflkjt66aetfgcrgvv75izymd5kc47g6luepqmfq6zsf5w6ueth6y" // v2.12.4 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeid26vjplsejg7t3nrh7mxmiaaxriebbm4xxrxxdunlk7o337m5sqq", "/ipfs/bafybeif4zkmu7qdhkpf3pnhwxipylqleof7rl6ojbe7mq3fzogz6m4xk3i", "/ipfs/bafybeianwe4vy7sprht5sm3hshvxjeqhwcmvbzq73u55sdhqngmohkjgs4", "/ipfs/bafybeicitin4p7ggmyjaubqpi3xwnagrwarsy6hiihraafk5rcrxqxju6m", From ffd5714283500ebc561c316955c026cae3de9c7c Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 30 Jul 2021 11:33:53 -0700 Subject: [PATCH 590/674] fix: avoid panic on short hash (caught higher up but should still be fixed) This commit was moved from ipfs/kubo@0858dc62aa7303c0da67289eee590013730c631b --- gateway/core/corehttp/gateway_indexPage.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index 6e1722116..3bee4822b 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -75,6 +75,9 @@ func breadcrumbs(urlPath string, dnslinkOrigin bool) []breadcrumb { } func shortHash(hash string) string { + if len(hash) <= 8 { + return hash + } return (hash[0:4] + "\u2026" + hash[len(hash)-4:]) } From e52ba61bf8d9b5c6f0e5a6f9673f5cf8540f5e8d Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 30 Jul 2021 11:34:15 -0700 Subject: [PATCH 591/674] fix: abort when we fail to resolve CIDs I believe we figured that these were for "informational purposes", but really, we _should_ always be able to resolve names to CIDs. If we can't, there's probably something wrong with the directory. This commit was moved from ipfs/kubo@66a76d27f36f202f006a6fe04809df1a3529a3be --- gateway/core/corehttp/gateway_handler.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ccec95b01..8e8300b65 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -391,11 +391,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request size = humanize.Bytes(uint64(s)) } - hash := "" - if r, err := i.api.ResolvePath(r.Context(), ipath.Join(resolvedPath, dirit.Name())); err == nil { - // Path may not be resolved. Continue anyways. - hash = r.Cid().String() + resolved, err := i.api.ResolvePath(r.Context(), ipath.Join(resolvedPath, dirit.Name())) + if err != nil { + internalWebError(w, err) + return } + hash := resolved.Cid().String() // See comment above where originalUrlPath is declared. di := directoryItem{ From f0caf2eda01248831b402c75dd285f45187cb536 Mon Sep 17 00:00:00 2001 From: Adrian Lanzafame Date: Tue, 30 Jul 2019 15:14:17 +1000 Subject: [PATCH 592/674] feat: register first block metric by default This commit was moved from ipfs/kubo@02823935aaf5920148059eb5c58a80bd9a36e36c --- gateway/core/corehttp/gateway_handler.go | 27 +++++++++++++++++++++--- gateway/core/corehttp/metrics.go | 16 ++++++-------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ccec95b01..78f49add5 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -28,6 +28,7 @@ import ( coreiface "github.com/ipfs/interface-go-ipfs-core" ipath "github.com/ipfs/interface-go-ipfs-core/path" routing "github.com/libp2p/go-libp2p-core/routing" + prometheus "github.com/prometheus/client_golang/prometheus" ) const ( @@ -62,6 +63,8 @@ type redirectTemplateData struct { type gatewayHandler struct { config GatewayConfig api coreiface.CoreAPI + + unixfsGetMetric *prometheus.SummaryVec } // StatusResponseWriter enables us to override HTTP Status Code passed to @@ -84,9 +87,27 @@ func (sw *statusResponseWriter) WriteHeader(code int) { } func newGatewayHandler(c GatewayConfig, api coreiface.CoreAPI) *gatewayHandler { + unixfsGetMetric := prometheus.NewSummaryVec( + prometheus.SummaryOpts{ + Namespace: "ipfs", + Subsystem: "http", + Name: "unixfs_get_latency_seconds", + Help: "The time till the first block is received when 'getting' a file from the gateway.", + }, + []string{"gateway"}, + ) + if err := prometheus.Register(unixfsGetMetric); err != nil { + if are, ok := err.(prometheus.AlreadyRegisteredError); ok { + unixfsGetMetric = are.ExistingCollector.(*prometheus.SummaryVec) + } else { + log.Errorf("failed to register unixfsGetMetric: %v", err) + } + } + i := &gatewayHandler{ - config: c, - api: api, + config: c, + api: api, + unixfsGetMetric: unixfsGetMetric, } return i } @@ -271,7 +292,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } - unixfsGetMetric.WithLabelValues(parsedPath.Namespace()).Observe(time.Since(begin).Seconds()) + i.unixfsGetMetric.WithLabelValues(parsedPath.Namespace()).Observe(time.Since(begin).Seconds()) defer dr.Close() diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index f34881f41..e7f36113b 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -14,7 +14,7 @@ import ( promhttp "github.com/prometheus/client_golang/prometheus/promhttp" ) -// This adds the scraping endpoint which Prometheus uses to fetch metrics. +// MetricsScrapingOption adds the scraping endpoint which Prometheus uses to fetch metrics. func MetricsScrapingOption(path string) ServeOption { return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.Handle(path, promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{})) @@ -51,7 +51,7 @@ func MetricsOpenCensusCollectionOption() ServeOption { } } -// This adds collection of net/http-related metrics +// MetricsCollectionOption adds collection of net/http-related metrics. func MetricsCollectionOption(handlerName string) ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { // Adapted from github.com/prometheus/client_golang/prometheus/http.go @@ -130,14 +130,10 @@ func MetricsCollectionOption(handlerName string) ServeOption { var ( peersTotalMetric = prometheus.NewDesc( prometheus.BuildFQName("ipfs", "p2p", "peers_total"), - "Number of connected peers", []string{"transport"}, nil) - - unixfsGetMetric = prometheus.NewSummaryVec(prometheus.SummaryOpts{ - Namespace: "ipfs", - Subsystem: "http", - Name: "unixfs_get_latency_seconds", - Help: "The time till the first block is received when 'getting' a file from the gateway.", - }, []string{"namespace"}) + "Number of connected peers", + []string{"transport"}, + nil, + ) ) type IpfsNodeCollector struct { From b47513a80098e033cdf29bc2440d162e82d50781 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Wed, 18 Aug 2021 18:33:16 +0200 Subject: [PATCH 593/674] update go-libp2p to v0.15.0-rc.1 This commit was moved from ipfs/kubo@c95d6ca08c2336c8587427de1bbb6d80c3564db3 --- gateway/core/corehttp/metrics_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 847d681a5..f9fa10f67 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - core "github.com/ipfs/go-ipfs/core" + "github.com/ipfs/go-ipfs/core" inet "github.com/libp2p/go-libp2p-core/network" swarmt "github.com/libp2p/go-libp2p-swarm/testing" @@ -20,7 +20,11 @@ func TestPeersTotal(t *testing.T) { hosts := make([]*bhost.BasicHost, 4) for i := 0; i < 4; i++ { - hosts[i] = bhost.New(swarmt.GenSwarm(t, ctx)) + var err error + hosts[i], err = bhost.NewHost(ctx, swarmt.GenSwarm(t, ctx), nil) + if err != nil { + t.Fatal(err) + } } dial := func(a, b inet.Network) { From c61387997955bdd6112c3407c2c578d4c74272f6 Mon Sep 17 00:00:00 2001 From: Lucas Molas Date: Tue, 21 Sep 2021 15:31:08 -0300 Subject: [PATCH 594/674] feat(cli): add daemon option --agent-version-suffix (#8419) * feat(cli): add daemon option --agent-version-suffix * fix sharness test when commit is empty (release) This commit was moved from ipfs/kubo@3a84352f1811b22a17530ddb6a2da4f13fbfeef5 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index f400c515b..fb1524da5 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -104,7 +104,7 @@ func VersionOption() ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Commit: %s\n", version.CurrentCommit) - fmt.Fprintf(w, "Client Version: %s\n", version.UserAgent) + fmt.Fprintf(w, "Client Version: %s\n", version.GetUserAgentVersion()) fmt.Fprintf(w, "Protocol Version: %s\n", id.LibP2PVersion) }) return mux, nil diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 053c22f9a..48c604e4a 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -732,7 +732,7 @@ func TestVersion(t *testing.T) { t.Fatalf("response doesn't contain commit:\n%s", s) } - if !strings.Contains(s, "Client Version: "+version.UserAgent) { + if !strings.Contains(s, "Client Version: "+version.GetUserAgentVersion()) { t.Fatalf("response doesn't contain client version:\n%s", s) } From 99e0fae00c8eab81c7d1fb0cb327dfd5677b04c9 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 21 Sep 2021 20:36:27 +0200 Subject: [PATCH 595/674] feat: ipfs-webui v2.13.0 (#8430) Release Notes: https://github.com/ipfs/ipfs-webui/releases/tag/v2.13.0 This commit was moved from ipfs/kubo@6a10c1df818eb81366024c5c5f6ced8ea0783c45 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 298163e3a..72656751a 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeiflkjt66aetfgcrgvv75izymd5kc47g6luepqmfq6zsf5w6ueth6y" // v2.12.4 +const WebUIPath = "/ipfs/bafybeihcyruaeza7uyjd6ugicbcrqumejf6uf353e5etdkhotqffwtguva" // v2.13.0 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeiflkjt66aetfgcrgvv75izymd5kc47g6luepqmfq6zsf5w6ueth6y", "/ipfs/bafybeid26vjplsejg7t3nrh7mxmiaaxriebbm4xxrxxdunlk7o337m5sqq", "/ipfs/bafybeif4zkmu7qdhkpf3pnhwxipylqleof7rl6ojbe7mq3fzogz6m4xk3i", "/ipfs/bafybeianwe4vy7sprht5sm3hshvxjeqhwcmvbzq73u55sdhqngmohkjgs4", From b894270d73a109031402343f2d2e40286cfca8d7 Mon Sep 17 00:00:00 2001 From: Lucas Molas Date: Tue, 21 Sep 2021 15:31:08 -0300 Subject: [PATCH 596/674] feat(cli): add daemon option --agent-version-suffix (#8419) * feat(cli): add daemon option --agent-version-suffix * fix sharness test when commit is empty (release) (cherry picked from commit c61387997955bdd6112c3407c2c578d4c74272f6) This commit was moved from ipfs/kubo@94bd2981b920cd2104ef79a96e55ad8471e27e9a --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index f400c515b..fb1524da5 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -104,7 +104,7 @@ func VersionOption() ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Commit: %s\n", version.CurrentCommit) - fmt.Fprintf(w, "Client Version: %s\n", version.UserAgent) + fmt.Fprintf(w, "Client Version: %s\n", version.GetUserAgentVersion()) fmt.Fprintf(w, "Protocol Version: %s\n", id.LibP2PVersion) }) return mux, nil diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 053c22f9a..48c604e4a 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -732,7 +732,7 @@ func TestVersion(t *testing.T) { t.Fatalf("response doesn't contain commit:\n%s", s) } - if !strings.Contains(s, "Client Version: "+version.UserAgent) { + if !strings.Contains(s, "Client Version: "+version.GetUserAgentVersion()) { t.Fatalf("response doesn't contain client version:\n%s", s) } From 722feb9b6461ff076e0112524d7084ad56449ba0 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 21 Sep 2021 20:36:27 +0200 Subject: [PATCH 597/674] feat: ipfs-webui v2.13.0 (#8430) Release Notes: https://github.com/ipfs/ipfs-webui/releases/tag/v2.13.0 (cherry picked from commit 99e0fae00c8eab81c7d1fb0cb327dfd5677b04c9) This commit was moved from ipfs/kubo@f7fd3e57a1ce5bbeb78db5c276e4efe780527d60 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 298163e3a..72656751a 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeiflkjt66aetfgcrgvv75izymd5kc47g6luepqmfq6zsf5w6ueth6y" // v2.12.4 +const WebUIPath = "/ipfs/bafybeihcyruaeza7uyjd6ugicbcrqumejf6uf353e5etdkhotqffwtguva" // v2.13.0 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeiflkjt66aetfgcrgvv75izymd5kc47g6luepqmfq6zsf5w6ueth6y", "/ipfs/bafybeid26vjplsejg7t3nrh7mxmiaaxriebbm4xxrxxdunlk7o337m5sqq", "/ipfs/bafybeif4zkmu7qdhkpf3pnhwxipylqleof7rl6ojbe7mq3fzogz6m4xk3i", "/ipfs/bafybeianwe4vy7sprht5sm3hshvxjeqhwcmvbzq73u55sdhqngmohkjgs4", From aa3a0747e5fb28d14b27d81274f24f737a4e15e0 Mon Sep 17 00:00:00 2001 From: Petar Maymounkov Date: Mon, 4 Oct 2021 08:49:39 -0700 Subject: [PATCH 598/674] add more logging to flaky TestPeersTotal Cannot reproduce the flakiness at the moment. The report suggests that connections are established on different transports. Adding logging to show what these transports are. This commit was moved from ipfs/kubo@f50d43eb0d9826362d1c9a80c9c5cdee6e78d307 --- gateway/core/corehttp/metrics_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index f9fa10f67..200414d4e 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -46,7 +46,7 @@ func TestPeersTotal(t *testing.T) { collector := IpfsNodeCollector{Node: node} actual := collector.PeersTotalValues() if len(actual) != 1 { - t.Fatalf("expected 1 peers transport, got %d", len(actual)) + t.Fatalf("expected 1 peers transport, got %d, transport map %v", len(actual), actual) } if actual["/ip4/tcp"] != float64(3) { t.Fatalf("expected 3 peers, got %f", actual["/ip4/tcp"]) From 0191d6a5295d44f89ea0f16cbee82adc55ddd6ba Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 1 Oct 2021 18:39:29 +0200 Subject: [PATCH 599/674] chore: update dir-index-html to v1.2.2 https://github.com/ipfs/dir-index-html/releases/tag/1.2.2 This commit was moved from ipfs/kubo@0b923b7951832fc9b3cb8d7fd8f3f4f995f836b2 --- gateway/core/corehttp/gateway_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 48c604e4a..8cccde0e2 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -506,7 +506,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "
") { t.Fatalf("expected file in directory listing") } - if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } - if !strings.Contains(s, " Date: Wed, 17 Nov 2021 22:16:06 +0200 Subject: [PATCH 600/674] Fix typos (#8548) This commit was moved from ipfs/kubo@0c2f9d5950c4245d89fcaf39dd1baa754587231b --- gateway/core/corehttp/hostname.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index c02c3aeec..e294a561b 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -295,7 +295,7 @@ func prepareKnownGateways(publicGateways map[string]*config.GatewaySpec) gateway } // isKnownHostname checks Gateway.PublicGateways and returns matching -// GatewaySpec with gracefull fallback to version without port +// GatewaySpec with graceful fallback to version without port func isKnownHostname(hostname string, knownGateways gatewayHosts) (gw *config.GatewaySpec, ok bool) { // Try hostname (host+optional port - value from Host header as-is) if gw, ok := knownGateways.exact[hostname]; ok { From 6fc0de95370f3e9b3a73d301f6e9aa02eca9194c Mon Sep 17 00:00:00 2001 From: mathew-cf <68972715+mathew-cf@users.noreply.github.com> Date: Tue, 23 Nov 2021 11:11:37 -0600 Subject: [PATCH 601/674] fix: multiple subdomain gateways on same domain (#8556) This commit was moved from ipfs/kubo@11404a9a030db5710be7603114e1e32b5782a145 --- gateway/core/corehttp/hostname.go | 2 +- gateway/core/corehttp/hostname_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index e294a561b..57c2c2191 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -338,7 +338,7 @@ func knownSubdomainDetails(hostname string, knownGateways gatewayHosts) (gw *con ns := labels[i-1] if !isSubdomainNamespace(ns) { - break + continue } // Merge remaining labels (could be a FQDN with DNSLink) diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index 6575ee1e8..f7ba89a8c 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -217,6 +217,7 @@ func TestKnownSubdomainDetails(t *testing.T) { knownGateways := prepareKnownGateways(map[string]*config.GatewaySpec{ "localhost": gwLocalhost, "dweb.link": gwDweb, + "devgateway.dweb.link": gwDweb, "dweb.ipfs.pvt.k12.ma.us": gwLong, // note the sneaky ".ipfs." ;-) "*.wildcard1.tld": gwWildcard1, "*.*.wildcard2.tld": gwWildcard2, @@ -248,6 +249,7 @@ func TestKnownSubdomainDetails(t *testing.T) { // cid in subdomain, known gateway {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.localhost:8080", gwLocalhost, "localhost:8080", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.link", gwDweb, "dweb.link", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, + {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.devgateway.dweb.link", gwDweb, "devgateway.dweb.link", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, // capture everything before .ipfs. {"foo.bar.boo-buzz.ipfs.dweb.link", gwDweb, "dweb.link", "ipfs", "foo.bar.boo-buzz", true}, // ipns From 718dd1cc5ed43641b66ba7eafa5f7d018cd177a8 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Mon, 29 Nov 2021 13:58:05 -0500 Subject: [PATCH 602/674] feat: go-libp2p 0.16, UnixFS autosharding and go-datastore with contexts (#8563) * plumb through go-datastore context changes * update go-libp2p to v0.16.0 * use LIBP2P_TCP_REUSEPORT instead of IPFS_REUSEPORT * use relay config * making deprecation notice match the go-ipfs-config key * docs(config): circuit relay v2 * docs(config): fix links and headers * feat(config): Internal.Libp2pForceReachability This switches to config that supports setting and reading Internal.Libp2pForceReachability OptionalString flag * use configuration option for static relays * chore: go-ipfs-config v0.18.0 https://github.com/ipfs/go-ipfs-config/releases/tag/v0.18.0 * feat: circuit v1 migration prompt when Swarm.EnableRelayHop is set (#8559) * exit when Swarm.EnableRelayHop is set * docs: Experimental.ShardingEnabled migration This ensures existing users of global sharding experiment get notified that the flag no longer works + that autosharding happens automatically. For people who NEED to keep the old behavior (eg. have no time to migrate today) there is a note about restoring it with `UnixFSShardingSizeThreshold`. * chore: add dag-jose code to the cid command output * add support for setting automatic unixfs sharding threshold from the config * test: have tests use low cutoff for sharding to mimic old behavior * test: change error message to match the current error * test: Add automatic sharding/unsharding tests (#8547) * test: refactored naming in the sharding sharness tests to make more sense * ci: set interop test executor to convenience image for Go1.16 + Node * ci: use interop master Co-authored-by: Marcin Rataj Co-authored-by: Marten Seemann Co-authored-by: Marcin Rataj Co-authored-by: Gus Eggert Co-authored-by: Lucas Molas This commit was moved from ipfs/kubo@52c177ced94a1dca6f2a440ba9f25a184ff75ddb --- gateway/core/corehttp/metrics_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 200414d4e..dc3b68bc9 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -21,7 +21,7 @@ func TestPeersTotal(t *testing.T) { hosts := make([]*bhost.BasicHost, 4) for i := 0; i < 4; i++ { var err error - hosts[i], err = bhost.NewHost(ctx, swarmt.GenSwarm(t, ctx), nil) + hosts[i], err = bhost.NewHost(swarmt.GenSwarm(t), nil) if err != nil { t.Fatal(err) } From 4e0783950dfcbcacf161ac03d153ec03d91bd36a Mon Sep 17 00:00:00 2001 From: Lucas Molas Date: Thu, 2 Dec 2021 22:03:00 -0300 Subject: [PATCH 603/674] fix(corehttp): adjust peer counting metrics (#8577) This commit was moved from ipfs/kubo@9d197ca732b5b1f80a907d35f36d6d0c0b6828cf --- gateway/core/corehttp/metrics.go | 13 +++++++++++-- gateway/core/corehttp/metrics_test.go | 12 +++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index e7f36113b..c3dbde0ac 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -160,9 +160,18 @@ func (c IpfsNodeCollector) PeersTotalValues() map[string]float64 { if c.Node.PeerHost == nil { return vals } - for _, conn := range c.Node.PeerHost.Network().Conns() { + for _, peerID := range c.Node.PeerHost.Network().Peers() { + // Each peer may have more than one connection (see for an explanation + // https://github.com/libp2p/go-libp2p-swarm/commit/0538806), so we grab + // only one, the first (an arbitrary and non-deterministic choice), which + // according to ConnsToPeer is the oldest connection in the list + // (https://github.com/libp2p/go-libp2p-swarm/blob/v0.2.6/swarm.go#L362-L364). + conns := c.Node.PeerHost.Network().ConnsToPeer(peerID) + if len(conns) == 0 { + continue + } tr := "" - for _, proto := range conn.RemoteMultiaddr().Protocols() { + for _, proto := range conns[0].RemoteMultiaddr().Protocols() { tr = tr + "/" + proto.Name } vals[tr] = vals[tr] + 1 diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index dc3b68bc9..76f79d2ee 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -44,11 +44,13 @@ func TestPeersTotal(t *testing.T) { node := &core.IpfsNode{PeerHost: hosts[0]} collector := IpfsNodeCollector{Node: node} - actual := collector.PeersTotalValues() - if len(actual) != 1 { - t.Fatalf("expected 1 peers transport, got %d, transport map %v", len(actual), actual) + peersTransport := collector.PeersTotalValues() + if len(peersTransport) > 2 { + t.Fatalf("expected at most 2 peers transport (tcp and upd/quic), got %d, transport map %v", + len(peersTransport), peersTransport) } - if actual["/ip4/tcp"] != float64(3) { - t.Fatalf("expected 3 peers, got %f", actual["/ip4/tcp"]) + totalPeers := peersTransport["/ip4/tcp"] + peersTransport["/ip4/udp/quic"] + if totalPeers != 3 { + t.Fatalf("expected 3 peers in either tcp or upd/quic transport, got %f", totalPeers) } } From 7358d051ce0e0661bc6ee7b15df91ae086309d69 Mon Sep 17 00:00:00 2001 From: Lucas Molas Date: Thu, 2 Dec 2021 22:03:00 -0300 Subject: [PATCH 604/674] fix(corehttp): adjust peer counting metrics (#8577) (cherry picked from commit 9d197ca732b5b1f80a907d35f36d6d0c0b6828cf) This commit was moved from ipfs/kubo@042efd3982da2ae703cdd0a6953dc500fc636537 --- gateway/core/corehttp/metrics.go | 13 +++++++++++-- gateway/core/corehttp/metrics_test.go | 12 +++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index e7f36113b..c3dbde0ac 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -160,9 +160,18 @@ func (c IpfsNodeCollector) PeersTotalValues() map[string]float64 { if c.Node.PeerHost == nil { return vals } - for _, conn := range c.Node.PeerHost.Network().Conns() { + for _, peerID := range c.Node.PeerHost.Network().Peers() { + // Each peer may have more than one connection (see for an explanation + // https://github.com/libp2p/go-libp2p-swarm/commit/0538806), so we grab + // only one, the first (an arbitrary and non-deterministic choice), which + // according to ConnsToPeer is the oldest connection in the list + // (https://github.com/libp2p/go-libp2p-swarm/blob/v0.2.6/swarm.go#L362-L364). + conns := c.Node.PeerHost.Network().ConnsToPeer(peerID) + if len(conns) == 0 { + continue + } tr := "" - for _, proto := range conn.RemoteMultiaddr().Protocols() { + for _, proto := range conns[0].RemoteMultiaddr().Protocols() { tr = tr + "/" + proto.Name } vals[tr] = vals[tr] + 1 diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index dc3b68bc9..76f79d2ee 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -44,11 +44,13 @@ func TestPeersTotal(t *testing.T) { node := &core.IpfsNode{PeerHost: hosts[0]} collector := IpfsNodeCollector{Node: node} - actual := collector.PeersTotalValues() - if len(actual) != 1 { - t.Fatalf("expected 1 peers transport, got %d, transport map %v", len(actual), actual) + peersTransport := collector.PeersTotalValues() + if len(peersTransport) > 2 { + t.Fatalf("expected at most 2 peers transport (tcp and upd/quic), got %d, transport map %v", + len(peersTransport), peersTransport) } - if actual["/ip4/tcp"] != float64(3) { - t.Fatalf("expected 3 peers, got %f", actual["/ip4/tcp"]) + totalPeers := peersTransport["/ip4/tcp"] + peersTransport["/ip4/udp/quic"] + if totalPeers != 3 { + t.Fatalf("expected 3 peers in either tcp or upd/quic transport, got %f", totalPeers) } } From d9673097fab155dd7a9192d813d6b192642c7b77 Mon Sep 17 00:00:00 2001 From: Manuel Alonso Date: Tue, 15 Feb 2022 23:13:09 +0100 Subject: [PATCH 605/674] chore(gateway): debug logging for the http requests (#8518) * chore(gateway): better logging for the http requests * chore(gateway): removed defer and add more data to the final log * chore(gateway): debug logging refactor * chore(gateway): use debug w/o context when only msg * doc: add cmd for log level * chore: add more logs and address fedback * chore(gateway): log subdomains and from=requestURI, refactor * chore(gateway): fix debug redirect This commit was moved from ipfs/kubo@edb32ac3d743404118834f8c371a3fdf45c2ea66 --- gateway/core/corehttp/gateway_handler.go | 45 +++++++++++++++++++----- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index f5ee54d8c..1262101be 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -82,6 +82,7 @@ func (sw *statusResponseWriter) WriteHeader(code int) { redirect := sw.ResponseWriter.Header().Get("Location") if redirect != "" && code == http.StatusOK { code = http.StatusMovedPermanently + log.Debugw("subdomain redirect", "location", redirect, "status", code) } sw.ResponseWriter.WriteHeader(code) } @@ -198,6 +199,9 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request urlPath := r.URL.Path escapedURLPath := r.URL.EscapedPath() + logger := log.With("from", r.RequestURI) + logger.Debug("http request received") + // If the gateway is behind a reverse proxy and mounted at a sub-path, // the prefix header can be set to signal this sub-path. // It will be prepended to links in directory listings and the index.html redirect. @@ -210,6 +214,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request break } } + logger.Debugw("sub-path (deprecrated)", "prefix", prefix) } // HostnameOption might have constructed an IPNS/IPFS path using the Host header. @@ -242,7 +247,10 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request if u.RawQuery != "" { // preserve query if present path = path + "?" + u.RawQuery } - http.Redirect(w, r, gopath.Join("/", prefix, u.Scheme, u.Host, path), http.StatusMovedPermanently) + + redirectURL := gopath.Join("/", prefix, u.Scheme, u.Host, path) + logger.Debugw("uri param, redirect", "to", redirectURL, "status", http.StatusMovedPermanently) + http.Redirect(w, r, redirectURL, http.StatusMovedPermanently) return } @@ -263,6 +271,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request if prefix == "" && fixupSuperfluousNamespace(w, urlPath, r.URL.RawQuery) { // the error was due to redundant namespace, which we were able to fix // by returning error/redirect page, nothing left to do here + logger.Debugw("redundant namespace; noop") return } // unable to fix path, returning error @@ -279,6 +288,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return default: if i.servePretty404IfPresent(w, r, parsedPath) { + logger.Debugw("serve pretty 404 if present") return } @@ -345,6 +355,8 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } else { name = getFilename(urlPath) } + + logger.Debugw("serving file", "name", name) i.serveFile(w, r, name, modtime, f) return } @@ -354,7 +366,8 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } - idx, err := i.api.Unixfs().Get(r.Context(), ipath.Join(resolvedPath, "index.html")) + idxPath := ipath.Join(resolvedPath, "index.html") + idx, err := i.api.Unixfs().Get(r.Context(), idxPath) switch err.(type) { case nil: dirwithoutslash := urlPath[len(urlPath)-1] != '/' @@ -366,7 +379,10 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // preserve query parameters suffix = suffix + "?" + r.URL.RawQuery } - http.Redirect(w, r, originalUrlPath+suffix, 302) + + redirectURL := originalUrlPath + suffix + logger.Debugw("serving index.html file", "to", redirectURL, "status", http.StatusFound, "path", idxPath) + http.Redirect(w, r, redirectURL, http.StatusFound) return } @@ -376,11 +392,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } + logger.Debugw("serving index.html file", "path", idxPath) // write to request i.serveFile(w, r, "index.html", modtime, f) return case resolver.ErrNoLink: - // no index.html; noop + logger.Debugw("no index.html; noop", "path", idxPath) default: internalWebError(w, err) return @@ -391,6 +408,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // Note: this needs to occur before listingTemplate.Execute otherwise we get // superfluous response.WriteHeader call from prometheus/client_golang if w.Header().Get("Location") != "" { + logger.Debugw("location moved permanently", "status", http.StatusMovedPermanently) w.WriteHeader(http.StatusMovedPermanently) return } @@ -399,6 +417,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // type instead of relying on autodetection (which may fail). w.Header().Set("Content-Type", "text/html") if r.Method == http.MethodHead { + logger.Debug("return as request's HTTP method is HEAD") return } @@ -490,8 +509,9 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request Hash: hash, } - err = listingTemplate.Execute(w, tplData) - if err != nil { + logger.Debugw("request processed", "tplDataDNSLink", dnslink, "tplDataSize", size, "tplDataBackLink", backLink, "tplDataHash", hash, "duration", time.Since(begin)) + + if err := listingTemplate.Execute(w, tplData); err != nil { internalWebError(w, err) return } @@ -568,7 +588,7 @@ func (i *gatewayHandler) servePretty404IfPresent(w http.ResponseWriter, r *http. return false } - log.Debugf("using pretty 404 file for %s", parsedPath.String()) + log.Debugw("using pretty 404 file", "path", parsedPath) w.Header().Set("Content-Type", ctype) w.Header().Set("Content-Length", strconv.FormatInt(size, 10)) w.WriteHeader(http.StatusNotFound) @@ -585,6 +605,7 @@ func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("IPFS-Hash", p.Cid().String()) + log.Debugw("CID created, http redirect", "from", r.URL, "to", p, "status", http.StatusCreated) http.Redirect(w, r, p.String(), http.StatusCreated) } @@ -677,7 +698,10 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("IPFS-Hash", newcid.String()) - http.Redirect(w, r, gopath.Join(ipfsPathPrefix, newcid.String(), newPath), http.StatusCreated) + + redirectURL := gopath.Join(ipfsPathPrefix, newcid.String(), newPath) + log.Debugw("CID replaced, redirect", "from", r.URL, "to", redirectURL, "status", http.StatusCreated) + http.Redirect(w, r, redirectURL, http.StatusCreated) } func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { @@ -748,8 +772,11 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("IPFS-Hash", ncid.String()) + + redirectURL := gopath.Join(ipfsPathPrefix+ncid.String(), directory) // note: StatusCreated is technically correct here as we created a new resource. - http.Redirect(w, r, gopath.Join(ipfsPathPrefix+ncid.String(), directory), http.StatusCreated) + log.Debugw("CID deleted, redirect", "from", r.RequestURI, "to", redirectURL, "status", http.StatusCreated) + http.Redirect(w, r, redirectURL, http.StatusCreated) } func (i *gatewayHandler) addUserHeaders(w http.ResponseWriter) { From 085c3fd228ca208115fa58a02704e903a2f2848a Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 1 Mar 2022 18:04:31 +0100 Subject: [PATCH 606/674] feat: X-Ipfs-Roots for smarter HTTP caches (#8720) This commit was moved from ipfs/kubo@caba3b264340d77f0848bd5362472822e95ea101 --- gateway/core/corehttp/gateway_handler.go | 54 ++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1262101be..d6e45ba92 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -327,6 +327,13 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request w.Header().Set("X-IPFS-Path", urlPath) w.Header().Set("Etag", responseEtag) + if rootCids, err := i.buildIpfsRootsHeader(urlPath, r); err == nil { + w.Header().Set("X-Ipfs-Roots", rootCids) + } else { // this should never happen, as we resolved the urlPath already + webError(w, "error while resolving X-Ipfs-Roots", err, http.StatusInternalServerError) + return + } + // set these headers _after_ the error, for we may just not have it // and don't want the client to cache a 500 response... // and only if it's /ipfs! @@ -391,6 +398,9 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request internalWebError(w, files.ErrNotReader) return } + // static index.html → no need to generate dynamic dir-index-html + // replace mutable DirIndex Etag with immutable dir CID + w.Header().Set("Etag", `"`+resolvedPath.Cid().String()+`"`) logger.Debugw("serving index.html file", "path", idxPath) // write to request @@ -785,6 +795,50 @@ func (i *gatewayHandler) addUserHeaders(w http.ResponseWriter) { } } +// Set X-Ipfs-Roots with logical CID array for efficient HTTP cache invalidation. +func (i *gatewayHandler) buildIpfsRootsHeader(contentPath string, r *http.Request) (string, error) { + /* + These are logical roots where each CID represent one path segment + and resolves to either a directory or the root block of a file. + The main purpose of this header is allow HTTP caches to do smarter decisions + around cache invalidation (eg. keep specific subdirectory/file if it did not change) + + A good example is Wikipedia, which is HAMT-sharded, but we only care about + logical roots that represent each segment of the human-readable content + path: + + Given contentPath = /ipns/en.wikipedia-on-ipfs.org/wiki/Block_of_Wikipedia_in_Turkey + rootCidList is a generated by doing `ipfs resolve -r` on each sub path: + /ipns/en.wikipedia-on-ipfs.org → bafybeiaysi4s6lnjev27ln5icwm6tueaw2vdykrtjkwiphwekaywqhcjze + /ipns/en.wikipedia-on-ipfs.org/wiki/ → bafybeihn2f7lhumh4grizksi2fl233cyszqadkn424ptjajfenykpsaiw4 + /ipns/en.wikipedia-on-ipfs.org/wiki/Block_of_Wikipedia_in_Turkey → bafkreibn6euazfvoghepcm4efzqx5l3hieof2frhp254hio5y7n3hv5rma + + The result is an ordered array of values: + X-Ipfs-Roots: bafybeiaysi4s6lnjev27ln5icwm6tueaw2vdykrtjkwiphwekaywqhcjze,bafybeihn2f7lhumh4grizksi2fl233cyszqadkn424ptjajfenykpsaiw4,bafkreibn6euazfvoghepcm4efzqx5l3hieof2frhp254hio5y7n3hv5rma + + Note that while the top one will change every time any article is changed, + the last root (responsible for specific article) may not change at all. + */ + var sp strings.Builder + var pathRoots []string + pathSegments := strings.Split(contentPath[6:], "/") + sp.WriteString(contentPath[:5]) // /ipfs or /ipns + for _, root := range pathSegments { + if root == "" { + continue + } + sp.WriteString("/") + sp.WriteString(root) + resolvedSubPath, err := i.api.ResolvePath(r.Context(), ipath.New(sp.String())) + if err != nil { + return "", err + } + pathRoots = append(pathRoots, resolvedSubPath.Cid().String()) + } + rootCidList := strings.Join(pathRoots, ",") // convention from rfc2616#sec4.2 + return rootCidList, nil +} + func webError(w http.ResponseWriter, message string, err error, defaultCode int) { if _, ok := err.(resolver.ErrNoLink); ok { webErrorWithCode(w, message, err, http.StatusNotFound) From de094cb5a2060c6b69a684ba02583ca0c05db79e Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 1 Mar 2022 19:03:06 +0100 Subject: [PATCH 607/674] feat: ipfs-webui v2.15 (#8712) Release Notes: https://github.com/ipfs/ipfs-webui/releases/tag/v2.15.0 This commit was moved from ipfs/kubo@d5ad847e05865e81957c43f526600860c06dbb84 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 72656751a..0ed60f760 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeihcyruaeza7uyjd6ugicbcrqumejf6uf353e5etdkhotqffwtguva" // v2.13.0 +const WebUIPath = "/ipfs/bafybeiednzu62vskme5wpoj4bjjikeg3xovfpp4t7vxk5ty2jxdi4mv4bu" // v2.15.0 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeihcyruaeza7uyjd6ugicbcrqumejf6uf353e5etdkhotqffwtguva", "/ipfs/bafybeiflkjt66aetfgcrgvv75izymd5kc47g6luepqmfq6zsf5w6ueth6y", "/ipfs/bafybeid26vjplsejg7t3nrh7mxmiaaxriebbm4xxrxxdunlk7o337m5sqq", "/ipfs/bafybeif4zkmu7qdhkpf3pnhwxipylqleof7rl6ojbe7mq3fzogz6m4xk3i", From 10692b9b4f19bb2edabd2b6d203ed9345cc6f7c3 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 2 Mar 2022 14:48:24 +0100 Subject: [PATCH 608/674] fix: rewrite dependencies over the go-ipfs-config package This commit was moved from ipfs/kubo@8d549f03f3e02ef6c5efad11c9aab969fc6861ed --- gateway/core/corehttp/commands.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/hostname.go | 2 +- gateway/core/corehttp/hostname_test.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index c5443f6eb..8de1e6be4 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -16,7 +16,7 @@ import ( cmds "github.com/ipfs/go-ipfs-cmds" cmdsHttp "github.com/ipfs/go-ipfs-cmds/http" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" path "github.com/ipfs/go-path" ) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 8cccde0e2..ae0104217 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,8 +19,8 @@ import ( datastore "github.com/ipfs/go-datastore" syncds "github.com/ipfs/go-datastore/sync" - config "github.com/ipfs/go-ipfs-config" files "github.com/ipfs/go-ipfs-files" + config "github.com/ipfs/go-ipfs/config" path "github.com/ipfs/go-path" iface "github.com/ipfs/interface-go-ipfs-core" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 57c2c2191..6c0ad5bca 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -18,7 +18,7 @@ import ( mbase "github.com/multiformats/go-multibase" - config "github.com/ipfs/go-ipfs-config" + config "github.com/ipfs/go-ipfs/config" iface "github.com/ipfs/interface-go-ipfs-core" options "github.com/ipfs/interface-go-ipfs-core/options" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index f7ba89a8c..df0f4f229 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -7,8 +7,8 @@ import ( "testing" cid "github.com/ipfs/go-cid" - config "github.com/ipfs/go-ipfs-config" files "github.com/ipfs/go-ipfs-files" + config "github.com/ipfs/go-ipfs/config" coreapi "github.com/ipfs/go-ipfs/core/coreapi" path "github.com/ipfs/go-path" ) From 20807cdc957b69f802213917b391d72ac6d8a2ee Mon Sep 17 00:00:00 2001 From: Gus Eggert Date: Fri, 11 Mar 2022 14:32:59 -0500 Subject: [PATCH 609/674] feat: add endpoint for enabling block profiling (#8469) This commit was moved from ipfs/kubo@0487f03eaea8f0207e2dec65809bc678813a1ec3 --- gateway/core/corehttp/mutex_profile.go | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gateway/core/corehttp/mutex_profile.go b/gateway/core/corehttp/mutex_profile.go index fbb23340d..a8265326c 100644 --- a/gateway/core/corehttp/mutex_profile.go +++ b/gateway/core/corehttp/mutex_profile.go @@ -41,3 +41,38 @@ func MutexFractionOption(path string) ServeOption { return mux, nil } } + +// BlockProfileRateOption allows to set runtime.SetBlockProfileRate via HTTP +// using POST request with parameter 'rate'. +// The profiler tries to sample 1 event every nanoseconds. +// If rate == 1, then the profiler samples every blocking event. +// To disable, set rate = 0. +func BlockProfileRateOption(path string) ServeOption { + return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { + mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost { + http.Error(w, "only POST allowed", http.StatusMethodNotAllowed) + return + } + if err := r.ParseForm(); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + + rateStr := r.Form.Get("rate") + if len(rateStr) == 0 { + http.Error(w, "parameter 'rate' must be set", http.StatusBadRequest) + return + } + + rate, err := strconv.Atoi(rateStr) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + log.Infof("Setting BlockProfileRate to %d", rate) + runtime.SetBlockProfileRate(rate) + }) + return mux, nil + } +} From 8fc128f6808225938c182212f72342771fe4dc11 Mon Sep 17 00:00:00 2001 From: Dave Justice Date: Wed, 16 Mar 2022 19:07:52 -0400 Subject: [PATCH 610/674] fix: allow ipfs-companion browser extension to access RPC API (#8690) * fix: add companion ids to allow origins - fixes #8689 - Adds the chrome-extension ids for ipfs-companion and ipfs-companion-beta to the allowed origins list, this allows us to accesss ipfs api from a manifest v3 extension. - added tests in t0401-api-browser-security.sh * fix: companion when custom CORS *-Origin is set Companion extension should be able to access RPC API even when custom Access-Control-Allow-Origin is set Co-authored-by: Marcin Rataj This commit was moved from ipfs/kubo@6774ef9dfdd5aa1e7b34cdd048cb8efedee4e305 --- gateway/core/corehttp/commands.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 8de1e6be4..14b503ff5 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -46,6 +46,11 @@ var defaultLocalhostOrigins = []string{ "https://localhost:", } +var companionBrowserExtensionOrigins = []string{ + "chrome-extension://nibjojkomfdiaoajekhjakgkdhaomnch", // ipfs-companion + "chrome-extension://hjoieblefckbooibpepigmacodalfndh", // ipfs-companion-beta +} + func addCORSFromEnv(c *cmdsHttp.ServerConfig) { origin := os.Getenv(originEnvKey) if origin != "" { @@ -84,10 +89,9 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { } func addCORSDefaults(c *cmdsHttp.ServerConfig) { - // by default use localhost origins - if len(c.AllowedOrigins()) == 0 { - c.SetAllowedOrigins(defaultLocalhostOrigins...) - } + // always safelist certain origins + c.AppendAllowedOrigins(defaultLocalhostOrigins...) + c.AppendAllowedOrigins(companionBrowserExtensionOrigins...) // by default, use GET, PUT, POST if len(c.AllowedMethods()) == 0 { From 3a09cab756dc5133c1d4d3319a59ddaafebc106a Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 17 Mar 2022 17:15:24 +0100 Subject: [PATCH 611/674] feat(gateway): Block and CAR response formats (#8758) * feat: serveRawBlock implements ?format=block * feat: serveCar implements ?format=car * feat(gw): ?format= or Accept HTTP header - extracted file-like content type responses to separate .go files - Accept HTTP header with support for application/vnd.ipld.* types * fix: use .bin for raw block content-disposition .raw may be handled by something, depending on OS, and .bin seems to be universally "binary file" across all systems: https://en.wikipedia.org/wiki/List_of_filename_extensions_(A%E2%80%93E) * refactor: gateway_handler_unixfs.go - Moved UnixFS response handling to gateway_handler_unixfs*.go files. - Removed support for X-Ipfs-Gateway-Prefix (Closes #7702) * refactor: prefix cleanup and readable paths - removed dead code after X-Ipfs-Gateway-Prefix is gone (https://github.com/ipfs/go-ipfs/issues/7702) - escaped special characters in content paths returned with http.Error making them both safer and easier to reason about (e.g. when invisible whitespace Unicode is used) This commit was moved from ipfs/kubo@4cabdfefbf9b5d13e5064cedab37b01af18d78b5 --- gateway/core/corehttp/gateway_handler.go | 474 ++++++------------ .../core/corehttp/gateway_handler_block.go | 38 ++ gateway/core/corehttp/gateway_handler_car.go | 72 +++ .../core/corehttp/gateway_handler_unixfs.go | 37 ++ .../corehttp/gateway_handler_unixfs_dir.go | 197 ++++++++ .../corehttp/gateway_handler_unixfs_file.go | 83 +++ gateway/core/corehttp/gateway_test.go | 90 +--- 7 files changed, 596 insertions(+), 395 deletions(-) create mode 100644 gateway/core/corehttp/gateway_handler_block.go create mode 100644 gateway/core/corehttp/gateway_handler_car.go create mode 100644 gateway/core/corehttp/gateway_handler_unixfs.go create mode 100644 gateway/core/corehttp/gateway_handler_unixfs_dir.go create mode 100644 gateway/core/corehttp/gateway_handler_unixfs_file.go diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d6e45ba92..45356271d 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -5,7 +5,6 @@ import ( "fmt" "html/template" "io" - "mime" "net/http" "net/url" "os" @@ -16,11 +15,8 @@ import ( "strings" "time" - humanize "github.com/dustin/go-humanize" - "github.com/gabriel-vasile/mimetype" - "github.com/ipfs/go-cid" + cid "github.com/ipfs/go-cid" files "github.com/ipfs/go-ipfs-files" - assets "github.com/ipfs/go-ipfs/assets" dag "github.com/ipfs/go-merkledag" mfs "github.com/ipfs/go-mfs" path "github.com/ipfs/go-path" @@ -32,11 +28,13 @@ import ( ) const ( - ipfsPathPrefix = "/ipfs/" - ipnsPathPrefix = "/ipns/" + ipfsPathPrefix = "/ipfs/" + ipnsPathPrefix = "/ipns/" + immutableCacheControl = "public, max-age=29030400, immutable" ) var onlyAscii = regexp.MustCompile("[[:^ascii:]]") +var noModtime = time.Unix(0, 0) // disables Last-Modified header if passed as modtime // HTML-based redirect for errors which can be recovered from, but we want // to provide hint to people that they should fix things on their end. @@ -89,6 +87,7 @@ func (sw *statusResponseWriter) WriteHeader(code int) { func newGatewayHandler(c GatewayConfig, api coreiface.CoreAPI) *gatewayHandler { unixfsGetMetric := prometheus.NewSummaryVec( + // TODO: deprecate and switch to content type agnostic metrics: https://github.com/ipfs/go-ipfs/issues/8441 prometheus.SummaryOpts{ Namespace: "ipfs", Subsystem: "http", @@ -196,38 +195,17 @@ func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request) func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) { begin := time.Now() - urlPath := r.URL.Path - escapedURLPath := r.URL.EscapedPath() logger := log.With("from", r.RequestURI) logger.Debug("http request received") - // If the gateway is behind a reverse proxy and mounted at a sub-path, - // the prefix header can be set to signal this sub-path. - // It will be prepended to links in directory listings and the index.html redirect. - // TODO: this feature is deprecated and will be removed (https://github.com/ipfs/go-ipfs/issues/7702) - prefix := "" - if prfx := r.Header.Get("X-Ipfs-Gateway-Prefix"); len(prfx) > 0 { - for _, p := range i.config.PathPrefixes { - if prfx == p || strings.HasPrefix(prfx, p+"/") { - prefix = prfx - break - } - } - logger.Debugw("sub-path (deprecrated)", "prefix", prefix) - } - - // HostnameOption might have constructed an IPNS/IPFS path using the Host header. - // In this case, we need the original path for constructing redirects - // and links that match the requested URL. - // For example, http://example.net would become /ipns/example.net, and - // the redirects and links would end up as http://example.net/ipns/example.net - requestURI, err := url.ParseRequestURI(r.RequestURI) - if err != nil { - webError(w, "failed to parse request path", err, http.StatusInternalServerError) + // X-Ipfs-Gateway-Prefix was removed (https://github.com/ipfs/go-ipfs/issues/7702) + // TODO: remove this after go-ipfs 0.13 ships + if prfx := r.Header.Get("X-Ipfs-Gateway-Prefix"); prfx != "" { + err := fmt.Errorf("X-Ipfs-Gateway-Prefix support was removed: https://github.com/ipfs/go-ipfs/issues/7702") + webError(w, "unsupported HTTP header", err, http.StatusBadRequest) return } - originalUrlPath := prefix + requestURI.Path // ?uri query param support for requests produced by web browsers // via navigator.registerProtocolHandler Web API @@ -248,7 +226,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request path = path + "?" + u.RawQuery } - redirectURL := gopath.Join("/", prefix, u.Scheme, u.Host, path) + redirectURL := gopath.Join("/", u.Scheme, u.Host, path) logger.Debugw("uri param, redirect", "to", redirectURL, "status", http.StatusMovedPermanently) http.Redirect(w, r, redirectURL, http.StatusMovedPermanently) return @@ -266,9 +244,9 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } } - parsedPath := ipath.New(urlPath) - if pathErr := parsedPath.IsValid(); pathErr != nil { - if prefix == "" && fixupSuperfluousNamespace(w, urlPath, r.URL.RawQuery) { + contentPath := ipath.New(r.URL.Path) + if pathErr := contentPath.IsValid(); pathErr != nil { + if fixupSuperfluousNamespace(w, r.URL.Path, r.URL.RawQuery) { // the error was due to redundant namespace, which we were able to fix // by returning error/redirect page, nothing left to do here logger.Debugw("redundant namespace; noop") @@ -280,304 +258,75 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } // Resolve path to the final DAG node for the ETag - resolvedPath, err := i.api.ResolvePath(r.Context(), parsedPath) + resolvedPath, err := i.api.ResolvePath(r.Context(), contentPath) switch err { case nil: case coreiface.ErrOffline: - webError(w, "ipfs resolve -r "+escapedURLPath, err, http.StatusServiceUnavailable) + webError(w, "ipfs resolve -r "+debugStr(contentPath.String()), err, http.StatusServiceUnavailable) return default: - if i.servePretty404IfPresent(w, r, parsedPath) { + // if Accept is text/html, see if ipfs-404.html is present + if i.servePretty404IfPresent(w, r, contentPath) { logger.Debugw("serve pretty 404 if present") return } - webError(w, "ipfs resolve -r "+escapedURLPath, err, http.StatusNotFound) - return - } - - dr, err := i.api.Unixfs().Get(r.Context(), resolvedPath) - if err != nil { - webError(w, "ipfs cat "+escapedURLPath, err, http.StatusNotFound) + webError(w, "ipfs resolve -r "+debugStr(contentPath.String()), err, http.StatusNotFound) return } - i.unixfsGetMetric.WithLabelValues(parsedPath.Namespace()).Observe(time.Since(begin).Seconds()) - - defer dr.Close() - - var responseEtag string + // Detect when explicit Accept header or ?format parameter are present + responseFormat := customResponseFormat(r) - // we need to figure out whether this is a directory before doing most of the heavy lifting below - _, ok := dr.(files.Directory) - - if ok && assets.BindataVersionHash != "" { - responseEtag = `"DirIndex-` + assets.BindataVersionHash + `_CID-` + resolvedPath.Cid().String() + `"` - } else { - responseEtag = `"` + resolvedPath.Cid().String() + `"` + // Finish early if client already has matching Etag + if r.Header.Get("If-None-Match") == getEtag(r, resolvedPath.Cid()) { + w.WriteHeader(http.StatusNotModified) + return } - // Check etag sent back to us - if r.Header.Get("If-None-Match") == responseEtag || r.Header.Get("If-None-Match") == `W/`+responseEtag { - w.WriteHeader(http.StatusNotModified) + // Update the global metric of the time it takes to read the final root block of the requested resource + // NOTE: for legacy reasons this happens before we go into content-type specific code paths + _, err = i.api.Block().Get(r.Context(), resolvedPath) + if err != nil { + webError(w, "ipfs block get "+resolvedPath.Cid().String(), err, http.StatusInternalServerError) return } + i.unixfsGetMetric.WithLabelValues(contentPath.Namespace()).Observe(time.Since(begin).Seconds()) + // HTTP Headers i.addUserHeaders(w) // ok, _now_ write user's headers. - w.Header().Set("X-IPFS-Path", urlPath) - w.Header().Set("Etag", responseEtag) + w.Header().Set("X-Ipfs-Path", contentPath.String()) - if rootCids, err := i.buildIpfsRootsHeader(urlPath, r); err == nil { + if rootCids, err := i.buildIpfsRootsHeader(contentPath.String(), r); err == nil { w.Header().Set("X-Ipfs-Roots", rootCids) - } else { // this should never happen, as we resolved the urlPath already + } else { // this should never happen, as we resolved the contentPath already webError(w, "error while resolving X-Ipfs-Roots", err, http.StatusInternalServerError) return } - // set these headers _after_ the error, for we may just not have it - // and don't want the client to cache a 500 response... - // and only if it's /ipfs! - // TODO: break this out when we split /ipfs /ipns routes. - modtime := time.Now() - - if f, ok := dr.(files.File); ok { - if strings.HasPrefix(urlPath, ipfsPathPrefix) { - w.Header().Set("Cache-Control", "public, max-age=29030400, immutable") - - // set modtime to a really long time ago, since files are immutable and should stay cached - modtime = time.Unix(1, 0) - } - - urlFilename := r.URL.Query().Get("filename") - var name string - if urlFilename != "" { - disposition := "inline" - if r.URL.Query().Get("download") == "true" { - disposition = "attachment" - } - utf8Name := url.PathEscape(urlFilename) - asciiName := url.PathEscape(onlyAscii.ReplaceAllLiteralString(urlFilename, "_")) - w.Header().Set("Content-Disposition", fmt.Sprintf("%s; filename=\"%s\"; filename*=UTF-8''%s", disposition, asciiName, utf8Name)) - name = urlFilename - } else { - name = getFilename(urlPath) - } - - logger.Debugw("serving file", "name", name) - i.serveFile(w, r, name, modtime, f) + // Support custom response formats passed via ?format or Accept HTTP header + switch responseFormat { + case "": // The implicit response format is UnixFS + logger.Debugw("serving unixfs", "path", contentPath) + i.serveUnixFs(w, r, resolvedPath, contentPath, logger) return - } - dir, ok := dr.(files.Directory) - if !ok { - internalWebError(w, fmt.Errorf("unsupported file type")) + case "application/vnd.ipld.raw": + logger.Debugw("serving raw block", "path", contentPath) + i.serveRawBlock(w, r, resolvedPath.Cid(), contentPath) return - } - - idxPath := ipath.Join(resolvedPath, "index.html") - idx, err := i.api.Unixfs().Get(r.Context(), idxPath) - switch err.(type) { - case nil: - dirwithoutslash := urlPath[len(urlPath)-1] != '/' - goget := r.URL.Query().Get("go-get") == "1" - if dirwithoutslash && !goget { - // See comment above where originalUrlPath is declared. - suffix := "/" - if r.URL.RawQuery != "" { - // preserve query parameters - suffix = suffix + "?" + r.URL.RawQuery - } - - redirectURL := originalUrlPath + suffix - logger.Debugw("serving index.html file", "to", redirectURL, "status", http.StatusFound, "path", idxPath) - http.Redirect(w, r, redirectURL, http.StatusFound) - return - } - - f, ok := idx.(files.File) - if !ok { - internalWebError(w, files.ErrNotReader) - return - } - // static index.html → no need to generate dynamic dir-index-html - // replace mutable DirIndex Etag with immutable dir CID - w.Header().Set("Etag", `"`+resolvedPath.Cid().String()+`"`) - - logger.Debugw("serving index.html file", "path", idxPath) - // write to request - i.serveFile(w, r, "index.html", modtime, f) - return - case resolver.ErrNoLink: - logger.Debugw("no index.html; noop", "path", idxPath) - default: - internalWebError(w, err) - return - } - - // See statusResponseWriter.WriteHeader - // and https://github.com/ipfs/go-ipfs/issues/7164 - // Note: this needs to occur before listingTemplate.Execute otherwise we get - // superfluous response.WriteHeader call from prometheus/client_golang - if w.Header().Get("Location") != "" { - logger.Debugw("location moved permanently", "status", http.StatusMovedPermanently) - w.WriteHeader(http.StatusMovedPermanently) + case "application/vnd.ipld.car", "application/vnd.ipld.car; version=1": + logger.Debugw("serving car stream", "path", contentPath) + i.serveCar(w, r, resolvedPath.Cid(), contentPath) return - } - - // A HTML directory index will be presented, be sure to set the correct - // type instead of relying on autodetection (which may fail). - w.Header().Set("Content-Type", "text/html") - if r.Method == http.MethodHead { - logger.Debug("return as request's HTTP method is HEAD") + default: // catch-all for unsuported application/vnd.* + err := fmt.Errorf("unsupported format %q", responseFormat) + webError(w, "failed respond with requested content type", err, http.StatusBadRequest) return } - - // storage for directory listing - var dirListing []directoryItem - dirit := dir.Entries() - for dirit.Next() { - size := "?" - if s, err := dirit.Node().Size(); err == nil { - // Size may not be defined/supported. Continue anyways. - size = humanize.Bytes(uint64(s)) - } - - resolved, err := i.api.ResolvePath(r.Context(), ipath.Join(resolvedPath, dirit.Name())) - if err != nil { - internalWebError(w, err) - return - } - hash := resolved.Cid().String() - - // See comment above where originalUrlPath is declared. - di := directoryItem{ - Size: size, - Name: dirit.Name(), - Path: gopath.Join(originalUrlPath, dirit.Name()), - Hash: hash, - ShortHash: shortHash(hash), - } - dirListing = append(dirListing, di) - } - if dirit.Err() != nil { - internalWebError(w, dirit.Err()) - return - } - - // construct the correct back link - // https://github.com/ipfs/go-ipfs/issues/1365 - var backLink string = originalUrlPath - - // don't go further up than /ipfs/$hash/ - pathSplit := path.SplitList(urlPath) - switch { - // keep backlink - case len(pathSplit) == 3: // url: /ipfs/$hash - - // keep backlink - case len(pathSplit) == 4 && pathSplit[3] == "": // url: /ipfs/$hash/ - - // add the correct link depending on whether the path ends with a slash - default: - if strings.HasSuffix(backLink, "/") { - backLink += "./.." - } else { - backLink += "/.." - } - } - - size := "?" - if s, err := dir.Size(); err == nil { - // Size may not be defined/supported. Continue anyways. - size = humanize.Bytes(uint64(s)) - } - - hash := resolvedPath.Cid().String() - - // Gateway root URL to be used when linking to other rootIDs. - // This will be blank unless subdomain or DNSLink resolution is being used - // for this request. - var gwURL string - - // Get gateway hostname and build gateway URL. - if h, ok := r.Context().Value("gw-hostname").(string); ok { - gwURL = "//" + h - } else { - gwURL = "" - } - - dnslink := hasDNSLinkOrigin(gwURL, urlPath) - - // See comment above where originalUrlPath is declared. - tplData := listingTemplateData{ - GatewayURL: gwURL, - DNSLink: dnslink, - Listing: dirListing, - Size: size, - Path: urlPath, - Breadcrumbs: breadcrumbs(urlPath, dnslink), - BackLink: backLink, - Hash: hash, - } - - logger.Debugw("request processed", "tplDataDNSLink", dnslink, "tplDataSize", size, "tplDataBackLink", backLink, "tplDataHash", hash, "duration", time.Since(begin)) - - if err := listingTemplate.Execute(w, tplData); err != nil { - internalWebError(w, err) - return - } -} - -func (i *gatewayHandler) serveFile(w http.ResponseWriter, req *http.Request, name string, modtime time.Time, file files.File) { - size, err := file.Size() - if err != nil { - http.Error(w, "cannot serve files with unknown sizes", http.StatusBadGateway) - return - } - - content := &lazySeeker{ - size: size, - reader: file, - } - - var ctype string - if _, isSymlink := file.(*files.Symlink); isSymlink { - // We should be smarter about resolving symlinks but this is the - // "most correct" we can be without doing that. - ctype = "inode/symlink" - } else { - ctype = mime.TypeByExtension(gopath.Ext(name)) - if ctype == "" { - // uses https://github.com/gabriel-vasile/mimetype library to determine the content type. - // Fixes https://github.com/ipfs/go-ipfs/issues/7252 - mimeType, err := mimetype.DetectReader(content) - if err != nil { - http.Error(w, fmt.Sprintf("cannot detect content-type: %s", err.Error()), http.StatusInternalServerError) - return - } - - ctype = mimeType.String() - _, err = content.Seek(0, io.SeekStart) - if err != nil { - http.Error(w, "seeker can't seek", http.StatusInternalServerError) - return - } - } - // Strip the encoding from the HTML Content-Type header and let the - // browser figure it out. - // - // Fixes https://github.com/ipfs/go-ipfs/issues/2203 - if strings.HasPrefix(ctype, "text/html;") { - ctype = "text/html" - } - } - w.Header().Set("Content-Type", ctype) - - w = &statusResponseWriter{w} - http.ServeContent(w, req, name, modtime, content) } -func (i *gatewayHandler) servePretty404IfPresent(w http.ResponseWriter, r *http.Request, parsedPath ipath.Path) bool { - resolved404Path, ctype, err := i.searchUpTreeFor404(r, parsedPath) +func (i *gatewayHandler) servePretty404IfPresent(w http.ResponseWriter, r *http.Request, contentPath ipath.Path) bool { + resolved404Path, ctype, err := i.searchUpTreeFor404(r, contentPath) if err != nil { return false } @@ -598,7 +347,7 @@ func (i *gatewayHandler) servePretty404IfPresent(w http.ResponseWriter, r *http. return false } - log.Debugw("using pretty 404 file", "path", parsedPath) + log.Debugw("using pretty 404 file", "path", contentPath) w.Header().Set("Content-Type", ctype) w.Header().Set("Content-Length", strconv.FormatInt(size, 10)) w.WriteHeader(http.StatusNotFound) @@ -795,6 +544,67 @@ func (i *gatewayHandler) addUserHeaders(w http.ResponseWriter) { } } +func addCacheControlHeaders(w http.ResponseWriter, r *http.Request, contentPath ipath.Path, fileCid cid.Cid) (modtime time.Time) { + // Set Etag to based on CID (override whatever was set before) + w.Header().Set("Etag", getEtag(r, fileCid)) + + // Set Cache-Control and Last-Modified based on contentPath properties + if contentPath.Mutable() { + // mutable namespaces such as /ipns/ can't be cached forever + + /* For now we set Last-Modified to Now() to leverage caching heuristics built into modern browsers: + * https://github.com/ipfs/go-ipfs/pull/8074#pullrequestreview-645196768 + * but we should not set it to fake values and use Cache-Control based on TTL instead */ + modtime = time.Now() + + // TODO: set Cache-Control based on TTL of IPNS/DNSLink: https://github.com/ipfs/go-ipfs/issues/1818#issuecomment-1015849462 + // TODO: set Last-Modified based on /ipns/ publishing timestamp? + + } else { + // immutable! CACHE ALL THE THINGS, FOREVER! wolololol + w.Header().Set("Cache-Control", immutableCacheControl) + + // Set modtime to 'zero time' to disable Last-Modified header (superseded by Cache-Control) + modtime = noModtime + + // TODO: set Last-Modified? - TBD - /ipfs/ modification metadata is present in unixfs 1.5 https://github.com/ipfs/go-ipfs/issues/6920? + } + + return modtime +} + +// Set Content-Disposition if filename URL query param is present, return preferred filename +func addContentDispositionHeader(w http.ResponseWriter, r *http.Request, contentPath ipath.Path) string { + /* This logic enables: + * - creation of HTML links that trigger "Save As.." dialog instead of being rendered by the browser + * - overriding the filename used when saving subresource assets on HTML page + * - providing a default filename for HTTP clients when downloading direct /ipfs/CID without any subpath + */ + + // URL param ?filename=cat.jpg triggers Content-Disposition: [..] filename + // which impacts default name used in "Save As.." dialog + name := getFilename(contentPath) + urlFilename := r.URL.Query().Get("filename") + if urlFilename != "" { + disposition := "inline" + // URL param ?download=true triggers Content-Disposition: [..] attachment + // which skips rendering and forces "Save As.." dialog in browsers + if r.URL.Query().Get("download") == "true" { + disposition = "attachment" + } + setContentDispositionHeader(w, urlFilename, disposition) + name = urlFilename + } + return name +} + +// Set Content-Disposition to arbitrary filename and disposition +func setContentDispositionHeader(w http.ResponseWriter, filename string, disposition string) { + utf8Name := url.PathEscape(filename) + asciiName := url.PathEscape(onlyAscii.ReplaceAllLiteralString(filename, "_")) + w.Header().Set("Content-Disposition", fmt.Sprintf("%s; filename=\"%s\"; filename*=UTF-8''%s", disposition, asciiName, utf8Name)) +} + // Set X-Ipfs-Roots with logical CID array for efficient HTTP cache invalidation. func (i *gatewayHandler) buildIpfsRootsHeader(contentPath string, r *http.Request) (string, error) { /* @@ -854,7 +664,7 @@ func webError(w http.ResponseWriter, message string, err error, defaultCode int) func webErrorWithCode(w http.ResponseWriter, message string, err error, code int) { http.Error(w, fmt.Sprintf("%s: %s", message, err), code) if code >= 500 { - log.Warnf("server error: %s: %s", err) + log.Warnf("server error: %s: %s", message, err) } } @@ -863,7 +673,8 @@ func internalWebError(w http.ResponseWriter, err error) { webErrorWithCode(w, "internalWebError", err, http.StatusInternalServerError) } -func getFilename(s string) string { +func getFilename(contentPath ipath.Path) string { + s := contentPath.String() if (strings.HasPrefix(s, ipfsPathPrefix) || strings.HasPrefix(s, ipnsPathPrefix)) && strings.Count(gopath.Clean(s), "/") <= 2 { // Don't want to treat ipfs.io in /ipns/ipfs.io as a filename. return "" @@ -871,13 +682,51 @@ func getFilename(s string) string { return gopath.Base(s) } -func (i *gatewayHandler) searchUpTreeFor404(r *http.Request, parsedPath ipath.Path) (ipath.Resolved, string, error) { +// generate Etag value based on HTTP request and CID +func getEtag(r *http.Request, cid cid.Cid) string { + prefix := `"` + suffix := `"` + responseFormat := customResponseFormat(r) + if responseFormat != "" { + // application/vnd.ipld.foo → foo + f := responseFormat[strings.LastIndex(responseFormat, ".")+1:] + // Etag: "cid.foo" (gives us nice compression together with Content-Disposition in block (raw) and car responses) + suffix = `.` + f + suffix + } + // TODO: include selector suffix when https://github.com/ipfs/go-ipfs/issues/8769 lands + return prefix + cid.String() + suffix +} + +// return explicit response format if specified in request as query parameter or via Accept HTTP header +func customResponseFormat(r *http.Request) string { + if formatParam := r.URL.Query().Get("format"); formatParam != "" { + // translate query param to a content type + switch formatParam { + case "raw": + return "application/vnd.ipld.raw" + case "car": + return "application/vnd.ipld.car" + } + } + // Browsers and other user agents will send Accept header with generic types like: + // Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 + // We only care about explciit, vendor-specific content-types. + for _, accept := range r.Header.Values("Accept") { + // respond to the very first ipld content type + if strings.HasPrefix(accept, "application/vnd.ipld") { + return accept + } + } + return "" +} + +func (i *gatewayHandler) searchUpTreeFor404(r *http.Request, contentPath ipath.Path) (ipath.Resolved, string, error) { filename404, ctype, err := preferred404Filename(r.Header.Values("Accept")) if err != nil { return nil, "", err } - pathComponents := strings.Split(parsedPath.String(), "/") + pathComponents := strings.Split(contentPath.String(), "/") for idx := len(pathComponents); idx >= 3; idx-- { pretty404 := gopath.Join(append(pathComponents[0:idx], filename404)...) @@ -913,6 +762,15 @@ func preferred404Filename(acceptHeaders []string) (string, string, error) { return "", "", fmt.Errorf("there is no 404 file for the requested content types") } +// returns unquoted path with all special characters revealed as \u codes +func debugStr(path string) string { + q := fmt.Sprintf("%+q", path) + if len(q) >= 3 { + q = q[1 : len(q)-1] + } + return q +} + // Attempt to fix redundant /ipfs/ namespace as long as resulting // 'intended' path is valid. This is in case gremlins were tickled // wrong way and user ended up at /ipfs/ipfs/{cid} or /ipfs/ipns/{id} diff --git a/gateway/core/corehttp/gateway_handler_block.go b/gateway/core/corehttp/gateway_handler_block.go new file mode 100644 index 000000000..3b93851d2 --- /dev/null +++ b/gateway/core/corehttp/gateway_handler_block.go @@ -0,0 +1,38 @@ +package corehttp + +import ( + "bytes" + "io/ioutil" + "net/http" + + cid "github.com/ipfs/go-cid" + ipath "github.com/ipfs/interface-go-ipfs-core/path" +) + +// serveRawBlock returns bytes behind a raw block +func (i *gatewayHandler) serveRawBlock(w http.ResponseWriter, r *http.Request, blockCid cid.Cid, contentPath ipath.Path) { + blockReader, err := i.api.Block().Get(r.Context(), contentPath) + if err != nil { + webError(w, "ipfs block get "+blockCid.String(), err, http.StatusInternalServerError) + return + } + block, err := ioutil.ReadAll(blockReader) + if err != nil { + webError(w, "ipfs block get "+blockCid.String(), err, http.StatusInternalServerError) + return + } + content := bytes.NewReader(block) + + // Set Content-Disposition + name := blockCid.String() + ".bin" + setContentDispositionHeader(w, name, "attachment") + + // Set remaining headers + modtime := addCacheControlHeaders(w, r, contentPath, blockCid) + w.Header().Set("Content-Type", "application/vnd.ipld.raw") + w.Header().Set("X-Content-Type-Options", "nosniff") // no funny business in the browsers :^) + + // Done: http.ServeContent will take care of + // If-None-Match+Etag, Content-Length and range requests + http.ServeContent(w, r, name, modtime, content) +} diff --git a/gateway/core/corehttp/gateway_handler_car.go b/gateway/core/corehttp/gateway_handler_car.go new file mode 100644 index 000000000..43ce99eef --- /dev/null +++ b/gateway/core/corehttp/gateway_handler_car.go @@ -0,0 +1,72 @@ +package corehttp + +import ( + "context" + "net/http" + + blocks "github.com/ipfs/go-block-format" + cid "github.com/ipfs/go-cid" + coreiface "github.com/ipfs/interface-go-ipfs-core" + ipath "github.com/ipfs/interface-go-ipfs-core/path" + gocar "github.com/ipld/go-car" + selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" +) + +// serveCar returns a CAR stream for specific DAG+selector +func (i *gatewayHandler) serveCar(w http.ResponseWriter, r *http.Request, rootCid cid.Cid, contentPath ipath.Path) { + ctx, cancel := context.WithCancel(r.Context()) + defer cancel() + + // Set Content-Disposition + name := rootCid.String() + ".car" + setContentDispositionHeader(w, name, "attachment") + + // Weak Etag W/ because we can't guarantee byte-for-byte identical responses + // (CAR is streamed, and in theory, blocks may arrive from datastore in non-deterministic order) + etag := `W/` + getEtag(r, rootCid) + w.Header().Set("Etag", etag) + + // Finish early if Etag match + if r.Header.Get("If-None-Match") == etag { + w.WriteHeader(http.StatusNotModified) + return + } + + // Make it clear we don't support range-requests over a car stream + // Partial downloads and resumes should be handled using + // IPLD selectors: https://github.com/ipfs/go-ipfs/issues/8769 + w.Header().Set("Accept-Ranges", "none") + + // Explicit Cache-Control to ensure fresh stream on retry. + // CAR stream could be interrupted, and client should be able to resume and get full response, not the truncated one + w.Header().Set("Cache-Control", "no-cache, no-transform") + + w.Header().Set("Content-Type", "application/vnd.ipld.car; version=1") + w.Header().Set("X-Content-Type-Options", "nosniff") // no funny business in the browsers :^) + + // Same go-car settings as dag.export command + store := dagStore{dag: i.api.Dag(), ctx: ctx} + + // TODO: support selectors passed as request param: https://github.com/ipfs/go-ipfs/issues/8769 + dag := gocar.Dag{Root: rootCid, Selector: selectorparse.CommonSelector_ExploreAllRecursively} + car := gocar.NewSelectiveCar(ctx, store, []gocar.Dag{dag}, gocar.TraverseLinksOnlyOnce()) + + if err := car.Write(w); err != nil { + // We return error as a trailer, however it is not something browsers can access + // (https://github.com/mdn/browser-compat-data/issues/14703) + // Due to this, we suggest client always verify that + // the received CAR stream response is matching requested DAG selector + w.Header().Set("X-Stream-Error", err.Error()) + return + } +} + +type dagStore struct { + dag coreiface.APIDagService + ctx context.Context +} + +func (ds dagStore) Get(c cid.Cid) (blocks.Block, error) { + obj, err := ds.dag.Get(ds.ctx, c) + return obj, err +} diff --git a/gateway/core/corehttp/gateway_handler_unixfs.go b/gateway/core/corehttp/gateway_handler_unixfs.go new file mode 100644 index 000000000..6f476b2af --- /dev/null +++ b/gateway/core/corehttp/gateway_handler_unixfs.go @@ -0,0 +1,37 @@ +package corehttp + +import ( + "fmt" + "html" + "net/http" + + files "github.com/ipfs/go-ipfs-files" + ipath "github.com/ipfs/interface-go-ipfs-core/path" + "go.uber.org/zap" +) + +func (i *gatewayHandler) serveUnixFs(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, logger *zap.SugaredLogger) { + // Handling UnixFS + dr, err := i.api.Unixfs().Get(r.Context(), resolvedPath) + if err != nil { + webError(w, "ipfs cat "+html.EscapeString(contentPath.String()), err, http.StatusNotFound) + return + } + defer dr.Close() + + // Handling Unixfs file + if f, ok := dr.(files.File); ok { + logger.Debugw("serving unixfs file", "path", contentPath) + i.serveFile(w, r, contentPath, resolvedPath.Cid(), f) + return + } + + // Handling Unixfs directory + dir, ok := dr.(files.Directory) + if !ok { + internalWebError(w, fmt.Errorf("unsupported UnixFs type")) + return + } + logger.Debugw("serving unixfs directory", "path", contentPath) + i.serveDirectory(w, r, resolvedPath, contentPath, dir, logger) +} diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go new file mode 100644 index 000000000..8e7e131dd --- /dev/null +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -0,0 +1,197 @@ +package corehttp + +import ( + "net/http" + "net/url" + gopath "path" + "strings" + + "github.com/dustin/go-humanize" + files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-ipfs/assets" + path "github.com/ipfs/go-path" + "github.com/ipfs/go-path/resolver" + ipath "github.com/ipfs/interface-go-ipfs-core/path" + "go.uber.org/zap" +) + +// serveDirectory returns the best representation of UnixFS directory +// +// It will return index.html if present, or generate directory listing otherwise. +func (i *gatewayHandler) serveDirectory(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, dir files.Directory, logger *zap.SugaredLogger) { + + // HostnameOption might have constructed an IPNS/IPFS path using the Host header. + // In this case, we need the original path for constructing redirects + // and links that match the requested URL. + // For example, http://example.net would become /ipns/example.net, and + // the redirects and links would end up as http://example.net/ipns/example.net + requestURI, err := url.ParseRequestURI(r.RequestURI) + if err != nil { + webError(w, "failed to parse request path", err, http.StatusInternalServerError) + return + } + originalUrlPath := requestURI.Path + + // Check if directory has index.html, if so, serveFile + idxPath := ipath.Join(resolvedPath, "index.html") + idx, err := i.api.Unixfs().Get(r.Context(), idxPath) + switch err.(type) { + case nil: + cpath := contentPath.String() + dirwithoutslash := cpath[len(cpath)-1] != '/' + goget := r.URL.Query().Get("go-get") == "1" + if dirwithoutslash && !goget { + // See comment above where originalUrlPath is declared. + suffix := "/" + if r.URL.RawQuery != "" { + // preserve query parameters + suffix = suffix + "?" + r.URL.RawQuery + } + + redirectURL := originalUrlPath + suffix + logger.Debugw("serving index.html file", "to", redirectURL, "status", http.StatusFound, "path", idxPath) + http.Redirect(w, r, redirectURL, http.StatusFound) + return + } + + f, ok := idx.(files.File) + if !ok { + internalWebError(w, files.ErrNotReader) + return + } + + logger.Debugw("serving index.html file", "path", idxPath) + // write to request + i.serveFile(w, r, idxPath, resolvedPath.Cid(), f) + return + case resolver.ErrNoLink: + logger.Debugw("no index.html; noop", "path", idxPath) + default: + internalWebError(w, err) + return + } + + // See statusResponseWriter.WriteHeader + // and https://github.com/ipfs/go-ipfs/issues/7164 + // Note: this needs to occur before listingTemplate.Execute otherwise we get + // superfluous response.WriteHeader call from prometheus/client_golang + if w.Header().Get("Location") != "" { + logger.Debugw("location moved permanently", "status", http.StatusMovedPermanently) + w.WriteHeader(http.StatusMovedPermanently) + return + } + + // A HTML directory index will be presented, be sure to set the correct + // type instead of relying on autodetection (which may fail). + w.Header().Set("Content-Type", "text/html") + + // Generated dir index requires custom Etag (it may change between go-ipfs versions) + if assets.BindataVersionHash != "" { + dirEtag := `"DirIndex-` + assets.BindataVersionHash + `_CID-` + resolvedPath.Cid().String() + `"` + w.Header().Set("Etag", dirEtag) + if r.Header.Get("If-None-Match") == dirEtag { + w.WriteHeader(http.StatusNotModified) + return + } + } + + if r.Method == http.MethodHead { + logger.Debug("return as request's HTTP method is HEAD") + return + } + + // storage for directory listing + var dirListing []directoryItem + dirit := dir.Entries() + for dirit.Next() { + size := "?" + if s, err := dirit.Node().Size(); err == nil { + // Size may not be defined/supported. Continue anyways. + size = humanize.Bytes(uint64(s)) + } + + resolved, err := i.api.ResolvePath(r.Context(), ipath.Join(resolvedPath, dirit.Name())) + if err != nil { + internalWebError(w, err) + return + } + hash := resolved.Cid().String() + + // See comment above where originalUrlPath is declared. + di := directoryItem{ + Size: size, + Name: dirit.Name(), + Path: gopath.Join(originalUrlPath, dirit.Name()), + Hash: hash, + ShortHash: shortHash(hash), + } + dirListing = append(dirListing, di) + } + if dirit.Err() != nil { + internalWebError(w, dirit.Err()) + return + } + + // construct the correct back link + // https://github.com/ipfs/go-ipfs/issues/1365 + var backLink string = originalUrlPath + + // don't go further up than /ipfs/$hash/ + pathSplit := path.SplitList(contentPath.String()) + switch { + // keep backlink + case len(pathSplit) == 3: // url: /ipfs/$hash + + // keep backlink + case len(pathSplit) == 4 && pathSplit[3] == "": // url: /ipfs/$hash/ + + // add the correct link depending on whether the path ends with a slash + default: + if strings.HasSuffix(backLink, "/") { + backLink += "./.." + } else { + backLink += "/.." + } + } + + size := "?" + if s, err := dir.Size(); err == nil { + // Size may not be defined/supported. Continue anyways. + size = humanize.Bytes(uint64(s)) + } + + hash := resolvedPath.Cid().String() + + // Gateway root URL to be used when linking to other rootIDs. + // This will be blank unless subdomain or DNSLink resolution is being used + // for this request. + var gwURL string + + // Get gateway hostname and build gateway URL. + if h, ok := r.Context().Value("gw-hostname").(string); ok { + gwURL = "//" + h + } else { + gwURL = "" + } + + dnslink := hasDNSLinkOrigin(gwURL, contentPath.String()) + + // See comment above where originalUrlPath is declared. + tplData := listingTemplateData{ + GatewayURL: gwURL, + DNSLink: dnslink, + Listing: dirListing, + Size: size, + Path: contentPath.String(), + Breadcrumbs: breadcrumbs(contentPath.String(), dnslink), + BackLink: backLink, + Hash: hash, + } + + logger.Debugw("request processed", "tplDataDNSLink", dnslink, "tplDataSize", size, "tplDataBackLink", backLink, "tplDataHash", hash) + + if err := listingTemplate.Execute(w, tplData); err != nil { + internalWebError(w, err) + return + } +} diff --git a/gateway/core/corehttp/gateway_handler_unixfs_file.go b/gateway/core/corehttp/gateway_handler_unixfs_file.go new file mode 100644 index 000000000..19e6d6795 --- /dev/null +++ b/gateway/core/corehttp/gateway_handler_unixfs_file.go @@ -0,0 +1,83 @@ +package corehttp + +import ( + "fmt" + "io" + "mime" + "net/http" + gopath "path" + "strings" + + "github.com/gabriel-vasile/mimetype" + cid "github.com/ipfs/go-cid" + files "github.com/ipfs/go-ipfs-files" + ipath "github.com/ipfs/interface-go-ipfs-core/path" +) + +// serveFile returns data behind a file along with HTTP headers based on +// the file itself, its CID and the contentPath used for accessing it. +func (i *gatewayHandler) serveFile(w http.ResponseWriter, r *http.Request, contentPath ipath.Path, fileCid cid.Cid, file files.File) { + + // Set Cache-Control and read optional Last-Modified time + modtime := addCacheControlHeaders(w, r, contentPath, fileCid) + + // Set Content-Disposition + name := addContentDispositionHeader(w, r, contentPath) + + // Prepare size value for Content-Length HTTP header (set inside of http.ServeContent) + size, err := file.Size() + if err != nil { + http.Error(w, "cannot serve files with unknown sizes", http.StatusBadGateway) + return + } + + // Lazy seeker enables efficient range-requests and HTTP HEAD responses + content := &lazySeeker{ + size: size, + reader: file, + } + + // Calculate deterministic value for Content-Type HTTP header + // (we prefer to do it here, rather than using implicit sniffing in http.ServeContent) + var ctype string + if _, isSymlink := file.(*files.Symlink); isSymlink { + // We should be smarter about resolving symlinks but this is the + // "most correct" we can be without doing that. + ctype = "inode/symlink" + } else { + ctype = mime.TypeByExtension(gopath.Ext(name)) + if ctype == "" { + // uses https://github.com/gabriel-vasile/mimetype library to determine the content type. + // Fixes https://github.com/ipfs/go-ipfs/issues/7252 + mimeType, err := mimetype.DetectReader(content) + if err != nil { + http.Error(w, fmt.Sprintf("cannot detect content-type: %s", err.Error()), http.StatusInternalServerError) + return + } + + ctype = mimeType.String() + _, err = content.Seek(0, io.SeekStart) + if err != nil { + http.Error(w, "seeker can't seek", http.StatusInternalServerError) + return + } + } + // Strip the encoding from the HTML Content-Type header and let the + // browser figure it out. + // + // Fixes https://github.com/ipfs/go-ipfs/issues/2203 + if strings.HasPrefix(ctype, "text/html;") { + ctype = "text/html" + } + } + // Setting explicit Content-Type to avoid mime-type sniffing on the client + // (unifies behavior across gateways and web browsers) + w.Header().Set("Content-Type", ctype) + + // special fixup around redirects + w = &statusResponseWriter{w} + + // Done: http.ServeContent will take care of + // If-None-Match+Etag, Content-Length and range requests + http.ServeContent(w, r, name, modtime, content) +} diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index ae0104217..2cba931dd 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -126,12 +126,6 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, iface t.Fatal(err) } - cfg, err := n.Repo.Config() - if err != nil { - t.Fatal(err) - } - cfg.Gateway.PathPrefixes = []string{"/good-prefix"} - // need this variable here since we need to construct handler with // listener, and server with handler. yay cycles. dh := &delegatedHandler{} @@ -242,7 +236,7 @@ func TestGatewayGet(t *testing.T) { {"127.0.0.1:8080", "/" + k.Cid().String(), http.StatusNotFound, "404 page not found\n"}, {"127.0.0.1:8080", k.String(), http.StatusOK, "fnord"}, {"127.0.0.1:8080", "/ipns/nxdomain.example.com", http.StatusNotFound, "ipfs resolve -r /ipns/nxdomain.example.com: " + namesys.ErrResolveFailed.Error() + "\n"}, - {"127.0.0.1:8080", "/ipns/%0D%0A%0D%0Ahello", http.StatusNotFound, "ipfs resolve -r /ipns/%0D%0A%0D%0Ahello: " + namesys.ErrResolveFailed.Error() + "\n"}, + {"127.0.0.1:8080", "/ipns/%0D%0A%0D%0Ahello", http.StatusNotFound, "ipfs resolve -r /ipns/\\r\\n\\r\\nhello: " + namesys.ErrResolveFailed.Error() + "\n"}, {"127.0.0.1:8080", "/ipns/example.com", http.StatusOK, "fnord"}, {"example.com", "/", http.StatusOK, "fnord"}, @@ -403,7 +397,6 @@ func TestIPNSHostnameRedirect(t *testing.T) { t.Fatal(err) } req.Host = "example.net" - req.Header.Set("X-Ipfs-Gateway-Prefix", "/good-prefix") res, err = doWithoutRedirect(req) if err != nil { @@ -417,8 +410,8 @@ func TestIPNSHostnameRedirect(t *testing.T) { hdr = res.Header["Location"] if len(hdr) < 1 { t.Errorf("location header not present") - } else if hdr[0] != "/good-prefix/foo/" { - t.Errorf("location header is %v, expected /good-prefix/foo/", hdr[0]) + } else if hdr[0] != "/foo/" { + t.Errorf("location header is %v, expected /foo/", hdr[0]) } // make sure /version isn't exposed @@ -427,7 +420,6 @@ func TestIPNSHostnameRedirect(t *testing.T) { t.Fatal(err) } req.Host = "example.net" - req.Header.Set("X-Ipfs-Gateway-Prefix", "/good-prefix") res, err = doWithoutRedirect(req) if err != nil { @@ -583,82 +575,6 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, k3.Cid().String()) { t.Fatalf("expected hash in directory listing") } - - // make request to directory listing with prefix - req, err = http.NewRequest(http.MethodGet, ts.URL, nil) - if err != nil { - t.Fatal(err) - } - req.Host = "example.net" - req.Header.Set("X-Ipfs-Gateway-Prefix", "/good-prefix") - - res, err = doWithoutRedirect(req) - if err != nil { - t.Fatal(err) - } - - // expect correct backlinks with prefix - body, err = ioutil.ReadAll(res.Body) - if err != nil { - t.Fatalf("error reading response: %s", err) - } - s = string(body) - t.Logf("body: %s\n", string(body)) - - if !matchPathOrBreadcrumbs(s, "/ipns/example.net") { - t.Fatalf("expected a path in directory listing") - } - if !strings.Contains(s, "") { - t.Fatalf("expected backlink in directory listing") - } - if !strings.Contains(s, "") { - t.Fatalf("expected file in directory listing") - } - if !strings.Contains(s, k.Cid().String()) { - t.Fatalf("expected hash in directory listing") - } - - // make request to directory listing with illegal prefix - req, err = http.NewRequest(http.MethodGet, ts.URL, nil) - if err != nil { - t.Fatal(err) - } - req.Host = "example.net" - req.Header.Set("X-Ipfs-Gateway-Prefix", "/bad-prefix") - - // make request to directory listing with evil prefix - req, err = http.NewRequest(http.MethodGet, ts.URL, nil) - if err != nil { - t.Fatal(err) - } - req.Host = "example.net" - req.Header.Set("X-Ipfs-Gateway-Prefix", "//good-prefix/foo") - - res, err = doWithoutRedirect(req) - if err != nil { - t.Fatal(err) - } - - // expect correct backlinks without illegal prefix - body, err = ioutil.ReadAll(res.Body) - if err != nil { - t.Fatalf("error reading response: %s", err) - } - s = string(body) - t.Logf("body: %s\n", string(body)) - - if !matchPathOrBreadcrumbs(s, "/") { - t.Fatalf("expected a path in directory listing") - } - if !strings.Contains(s, "") { - t.Fatalf("expected backlink in directory listing") - } - if !strings.Contains(s, "") { - t.Fatalf("expected file in directory listing") - } - if !strings.Contains(s, k.Cid().String()) { - t.Fatalf("expected hash in directory listing") - } } func TestCacheControlImmutable(t *testing.T) { From 7927c02c507fe1412a09a05f9215dbe898fa6560 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Mon, 21 Mar 2022 10:57:08 -0400 Subject: [PATCH 612/674] feat: add gateway histogram metrics (#8443) * feat(gw): response type histogram metrics - response-type agnostic firstContentBlockGetMetric which counts the latency til the first content block. - car/block/file/gen-dir-index duration histogram metrics that show how long each response type takes * docs: improve metrics descriptions * feat: more gw histogram buckets 0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10, 30, 60 secs as suggested in reviews at https://github.com/ipfs/go-ipfs/pull/8443 Co-authored-by: Marcin Rataj Co-authored-by: Gus Eggert This commit was moved from ipfs/kubo@beaa8fc29b472214283b9aab884ed92f03908d13 --- gateway/core/corehttp/gateway_handler.go | 107 +++++++++++++++--- .../core/corehttp/gateway_handler_block.go | 6 +- gateway/core/corehttp/gateway_handler_car.go | 6 +- .../core/corehttp/gateway_handler_unixfs.go | 7 +- .../corehttp/gateway_handler_unixfs_dir.go | 8 +- .../corehttp/gateway_handler_unixfs_file.go | 6 +- 6 files changed, 116 insertions(+), 24 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 45356271d..eca2efff6 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -62,7 +62,15 @@ type gatewayHandler struct { config GatewayConfig api coreiface.CoreAPI - unixfsGetMetric *prometheus.SummaryVec + // generic metrics + firstContentBlockGetMetric *prometheus.HistogramVec + unixfsGetMetric *prometheus.SummaryVec // deprecated, use firstContentBlockGetMetric + + // response type metrics + unixfsFileGetMetric *prometheus.HistogramVec + unixfsGenDirGetMetric *prometheus.HistogramVec + carStreamGetMetric *prometheus.HistogramVec + rawBlockGetMetric *prometheus.HistogramVec } // StatusResponseWriter enables us to override HTTP Status Code passed to @@ -85,29 +93,93 @@ func (sw *statusResponseWriter) WriteHeader(code int) { sw.ResponseWriter.WriteHeader(code) } -func newGatewayHandler(c GatewayConfig, api coreiface.CoreAPI) *gatewayHandler { - unixfsGetMetric := prometheus.NewSummaryVec( - // TODO: deprecate and switch to content type agnostic metrics: https://github.com/ipfs/go-ipfs/issues/8441 +func newGatewaySummaryMetric(name string, help string) *prometheus.SummaryVec { + summaryMetric := prometheus.NewSummaryVec( prometheus.SummaryOpts{ Namespace: "ipfs", Subsystem: "http", - Name: "unixfs_get_latency_seconds", - Help: "The time till the first block is received when 'getting' a file from the gateway.", + Name: name, + Help: help, + }, + []string{"gateway"}, + ) + if err := prometheus.Register(summaryMetric); err != nil { + if are, ok := err.(prometheus.AlreadyRegisteredError); ok { + summaryMetric = are.ExistingCollector.(*prometheus.SummaryVec) + } else { + log.Errorf("failed to register ipfs_http_%s: %v", name, err) + } + } + return summaryMetric +} + +func newGatewayHistogramMetric(name string, help string) *prometheus.HistogramVec { + // We can add buckets as a parameter in the future, but for now using static defaults + // suggested in https://github.com/ipfs/go-ipfs/issues/8441 + defaultBuckets := []float64{0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10, 30, 60} + histogramMetric := prometheus.NewHistogramVec( + prometheus.HistogramOpts{ + Namespace: "ipfs", + Subsystem: "http", + Name: name, + Help: help, + Buckets: defaultBuckets, }, []string{"gateway"}, ) - if err := prometheus.Register(unixfsGetMetric); err != nil { + if err := prometheus.Register(histogramMetric); err != nil { if are, ok := err.(prometheus.AlreadyRegisteredError); ok { - unixfsGetMetric = are.ExistingCollector.(*prometheus.SummaryVec) + histogramMetric = are.ExistingCollector.(*prometheus.HistogramVec) } else { - log.Errorf("failed to register unixfsGetMetric: %v", err) + log.Errorf("failed to register ipfs_http_%s: %v", name, err) } } + return histogramMetric +} +func newGatewayHandler(c GatewayConfig, api coreiface.CoreAPI) *gatewayHandler { i := &gatewayHandler{ - config: c, - api: api, - unixfsGetMetric: unixfsGetMetric, + config: c, + api: api, + // Improved Metrics + // ---------------------------- + // Time till the first content block (bar in /ipfs/cid/foo/bar) + // (format-agnostic, across all response types) + firstContentBlockGetMetric: newGatewayHistogramMetric( + "gw_first_content_block_get_latency_seconds", + "The time till the first content block is received on GET from the gateway.", + ), + + // Response-type specific metrics + // ---------------------------- + // UnixFS: time it takes to return a file + unixfsFileGetMetric: newGatewayHistogramMetric( + "gw_unixfs_file_get_duration_seconds", + "The time to serve an entire UnixFS file from the gateway.", + ), + // UnixFS: time it takes to generate static HTML with directory listing + unixfsGenDirGetMetric: newGatewayHistogramMetric( + "gw_unixfs_gen_dir_listing_get_duration_seconds", + "The time to serve a generated UnixFS HTML directory listing from the gateway.", + ), + // CAR: time it takes to return requested CAR stream + carStreamGetMetric: newGatewayHistogramMetric( + "gw_car_stream_get_duration_seconds", + "The time to GET an entire CAR stream from the gateway.", + ), + // Block: time it takes to return requested Block + rawBlockGetMetric: newGatewayHistogramMetric( + "gw_raw_block_get_duration_seconds", + "The time to GET an entire raw Block from the gateway.", + ), + + // Legacy Metrics + // ---------------------------- + unixfsGetMetric: newGatewaySummaryMetric( // TODO: remove? + // (deprecated, use firstContentBlockGetMetric instead) + "unixfs_get_latency_seconds", + "The time to receive the first UnixFS node on a GET from the gateway.", + ), } return i } @@ -291,7 +363,10 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request webError(w, "ipfs block get "+resolvedPath.Cid().String(), err, http.StatusInternalServerError) return } - i.unixfsGetMetric.WithLabelValues(contentPath.Namespace()).Observe(time.Since(begin).Seconds()) + ns := contentPath.Namespace() + timeToGetFirstContentBlock := time.Since(begin).Seconds() + i.unixfsGetMetric.WithLabelValues(ns).Observe(timeToGetFirstContentBlock) // deprecated, use firstContentBlockGetMetric instead + i.firstContentBlockGetMetric.WithLabelValues(ns).Observe(timeToGetFirstContentBlock) // HTTP Headers i.addUserHeaders(w) // ok, _now_ write user's headers. @@ -308,15 +383,15 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request switch responseFormat { case "": // The implicit response format is UnixFS logger.Debugw("serving unixfs", "path", contentPath) - i.serveUnixFs(w, r, resolvedPath, contentPath, logger) + i.serveUnixFs(w, r, resolvedPath, contentPath, begin, logger) return case "application/vnd.ipld.raw": logger.Debugw("serving raw block", "path", contentPath) - i.serveRawBlock(w, r, resolvedPath.Cid(), contentPath) + i.serveRawBlock(w, r, resolvedPath.Cid(), contentPath, begin) return case "application/vnd.ipld.car", "application/vnd.ipld.car; version=1": logger.Debugw("serving car stream", "path", contentPath) - i.serveCar(w, r, resolvedPath.Cid(), contentPath) + i.serveCar(w, r, resolvedPath.Cid(), contentPath, begin) return default: // catch-all for unsuported application/vnd.* err := fmt.Errorf("unsupported format %q", responseFormat) diff --git a/gateway/core/corehttp/gateway_handler_block.go b/gateway/core/corehttp/gateway_handler_block.go index 3b93851d2..13d7ebefd 100644 --- a/gateway/core/corehttp/gateway_handler_block.go +++ b/gateway/core/corehttp/gateway_handler_block.go @@ -4,13 +4,14 @@ import ( "bytes" "io/ioutil" "net/http" + "time" cid "github.com/ipfs/go-cid" ipath "github.com/ipfs/interface-go-ipfs-core/path" ) // serveRawBlock returns bytes behind a raw block -func (i *gatewayHandler) serveRawBlock(w http.ResponseWriter, r *http.Request, blockCid cid.Cid, contentPath ipath.Path) { +func (i *gatewayHandler) serveRawBlock(w http.ResponseWriter, r *http.Request, blockCid cid.Cid, contentPath ipath.Path, begin time.Time) { blockReader, err := i.api.Block().Get(r.Context(), contentPath) if err != nil { webError(w, "ipfs block get "+blockCid.String(), err, http.StatusInternalServerError) @@ -35,4 +36,7 @@ func (i *gatewayHandler) serveRawBlock(w http.ResponseWriter, r *http.Request, b // Done: http.ServeContent will take care of // If-None-Match+Etag, Content-Length and range requests http.ServeContent(w, r, name, modtime, content) + + // Update metrics + i.rawBlockGetMetric.WithLabelValues(contentPath.Namespace()).Observe(time.Since(begin).Seconds()) } diff --git a/gateway/core/corehttp/gateway_handler_car.go b/gateway/core/corehttp/gateway_handler_car.go index 43ce99eef..5f0f2117f 100644 --- a/gateway/core/corehttp/gateway_handler_car.go +++ b/gateway/core/corehttp/gateway_handler_car.go @@ -3,6 +3,7 @@ package corehttp import ( "context" "net/http" + "time" blocks "github.com/ipfs/go-block-format" cid "github.com/ipfs/go-cid" @@ -13,7 +14,7 @@ import ( ) // serveCar returns a CAR stream for specific DAG+selector -func (i *gatewayHandler) serveCar(w http.ResponseWriter, r *http.Request, rootCid cid.Cid, contentPath ipath.Path) { +func (i *gatewayHandler) serveCar(w http.ResponseWriter, r *http.Request, rootCid cid.Cid, contentPath ipath.Path, begin time.Time) { ctx, cancel := context.WithCancel(r.Context()) defer cancel() @@ -59,6 +60,9 @@ func (i *gatewayHandler) serveCar(w http.ResponseWriter, r *http.Request, rootCi w.Header().Set("X-Stream-Error", err.Error()) return } + + // Update metrics + i.carStreamGetMetric.WithLabelValues(contentPath.Namespace()).Observe(time.Since(begin).Seconds()) } type dagStore struct { diff --git a/gateway/core/corehttp/gateway_handler_unixfs.go b/gateway/core/corehttp/gateway_handler_unixfs.go index 6f476b2af..ed15f4139 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs.go +++ b/gateway/core/corehttp/gateway_handler_unixfs.go @@ -4,13 +4,14 @@ import ( "fmt" "html" "net/http" + "time" files "github.com/ipfs/go-ipfs-files" ipath "github.com/ipfs/interface-go-ipfs-core/path" "go.uber.org/zap" ) -func (i *gatewayHandler) serveUnixFs(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, logger *zap.SugaredLogger) { +func (i *gatewayHandler) serveUnixFs(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, logger *zap.SugaredLogger) { // Handling UnixFS dr, err := i.api.Unixfs().Get(r.Context(), resolvedPath) if err != nil { @@ -22,7 +23,7 @@ func (i *gatewayHandler) serveUnixFs(w http.ResponseWriter, r *http.Request, res // Handling Unixfs file if f, ok := dr.(files.File); ok { logger.Debugw("serving unixfs file", "path", contentPath) - i.serveFile(w, r, contentPath, resolvedPath.Cid(), f) + i.serveFile(w, r, contentPath, resolvedPath.Cid(), f, begin) return } @@ -33,5 +34,5 @@ func (i *gatewayHandler) serveUnixFs(w http.ResponseWriter, r *http.Request, res return } logger.Debugw("serving unixfs directory", "path", contentPath) - i.serveDirectory(w, r, resolvedPath, contentPath, dir, logger) + i.serveDirectory(w, r, resolvedPath, contentPath, dir, begin, logger) } diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index 8e7e131dd..87708159e 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -5,6 +5,7 @@ import ( "net/url" gopath "path" "strings" + "time" "github.com/dustin/go-humanize" files "github.com/ipfs/go-ipfs-files" @@ -18,7 +19,7 @@ import ( // serveDirectory returns the best representation of UnixFS directory // // It will return index.html if present, or generate directory listing otherwise. -func (i *gatewayHandler) serveDirectory(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, dir files.Directory, logger *zap.SugaredLogger) { +func (i *gatewayHandler) serveDirectory(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, dir files.Directory, begin time.Time, logger *zap.SugaredLogger) { // HostnameOption might have constructed an IPNS/IPFS path using the Host header. // In this case, we need the original path for constructing redirects @@ -62,7 +63,7 @@ func (i *gatewayHandler) serveDirectory(w http.ResponseWriter, r *http.Request, logger.Debugw("serving index.html file", "path", idxPath) // write to request - i.serveFile(w, r, idxPath, resolvedPath.Cid(), f) + i.serveFile(w, r, idxPath, resolvedPath.Cid(), f, begin) return case resolver.ErrNoLink: logger.Debugw("no index.html; noop", "path", idxPath) @@ -194,4 +195,7 @@ func (i *gatewayHandler) serveDirectory(w http.ResponseWriter, r *http.Request, internalWebError(w, err) return } + + // Update metrics + i.unixfsGenDirGetMetric.WithLabelValues(contentPath.Namespace()).Observe(time.Since(begin).Seconds()) } diff --git a/gateway/core/corehttp/gateway_handler_unixfs_file.go b/gateway/core/corehttp/gateway_handler_unixfs_file.go index 19e6d6795..9807969fe 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_file.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_file.go @@ -7,6 +7,7 @@ import ( "net/http" gopath "path" "strings" + "time" "github.com/gabriel-vasile/mimetype" cid "github.com/ipfs/go-cid" @@ -16,7 +17,7 @@ import ( // serveFile returns data behind a file along with HTTP headers based on // the file itself, its CID and the contentPath used for accessing it. -func (i *gatewayHandler) serveFile(w http.ResponseWriter, r *http.Request, contentPath ipath.Path, fileCid cid.Cid, file files.File) { +func (i *gatewayHandler) serveFile(w http.ResponseWriter, r *http.Request, contentPath ipath.Path, fileCid cid.Cid, file files.File, begin time.Time) { // Set Cache-Control and read optional Last-Modified time modtime := addCacheControlHeaders(w, r, contentPath, fileCid) @@ -80,4 +81,7 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, r *http.Request, conte // Done: http.ServeContent will take care of // If-None-Match+Etag, Content-Length and range requests http.ServeContent(w, r, name, modtime, content) + + // Update metrics + i.unixfsFileGetMetric.WithLabelValues(contentPath.Namespace()).Observe(time.Since(begin).Seconds()) } From 97a588865af4418d82224d3806ae48510e4ef6be Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 1 Apr 2022 18:12:46 +0200 Subject: [PATCH 613/674] fix(gw): validate requested CAR version (#8835) * fix(gw): validate requested CAR version This adds validation of 'application/vnd.ipld.car;version=n' passed in the Accept header by HTTP clients to align Gateway behavior with the spec submitted to IANA. * test: fix comment in test/sharness/t0118-gateway-car.sh Co-authored-by: Gus Eggert Co-authored-by: Gus Eggert This commit was moved from ipfs/kubo@5fa556945e2a9733f39e1bfcc242cba4c31c070b --- gateway/core/corehttp/gateway_handler.go | 30 +++++++++++++------- gateway/core/corehttp/gateway_handler_car.go | 12 +++++++- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index eca2efff6..6d90dd008 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -5,6 +5,7 @@ import ( "fmt" "html/template" "io" + "mime" "net/http" "net/url" "os" @@ -348,7 +349,11 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } // Detect when explicit Accept header or ?format parameter are present - responseFormat := customResponseFormat(r) + responseFormat, formatParams, err := customResponseFormat(r) + if err != nil { + webError(w, "error while processing the Accept header", err, http.StatusBadRequest) + return + } // Finish early if client already has matching Etag if r.Header.Get("If-None-Match") == getEtag(r, resolvedPath.Cid()) { @@ -389,9 +394,10 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request logger.Debugw("serving raw block", "path", contentPath) i.serveRawBlock(w, r, resolvedPath.Cid(), contentPath, begin) return - case "application/vnd.ipld.car", "application/vnd.ipld.car; version=1": + case "application/vnd.ipld.car": logger.Debugw("serving car stream", "path", contentPath) - i.serveCar(w, r, resolvedPath.Cid(), contentPath, begin) + carVersion := formatParams["version"] + i.serveCar(w, r, resolvedPath.Cid(), contentPath, carVersion, begin) return default: // catch-all for unsuported application/vnd.* err := fmt.Errorf("unsupported format %q", responseFormat) @@ -761,8 +767,8 @@ func getFilename(contentPath ipath.Path) string { func getEtag(r *http.Request, cid cid.Cid) string { prefix := `"` suffix := `"` - responseFormat := customResponseFormat(r) - if responseFormat != "" { + responseFormat, _, err := customResponseFormat(r) + if err == nil && responseFormat != "" { // application/vnd.ipld.foo → foo f := responseFormat[strings.LastIndex(responseFormat, ".")+1:] // Etag: "cid.foo" (gives us nice compression together with Content-Disposition in block (raw) and car responses) @@ -773,14 +779,14 @@ func getEtag(r *http.Request, cid cid.Cid) string { } // return explicit response format if specified in request as query parameter or via Accept HTTP header -func customResponseFormat(r *http.Request) string { +func customResponseFormat(r *http.Request) (mediaType string, params map[string]string, err error) { if formatParam := r.URL.Query().Get("format"); formatParam != "" { // translate query param to a content type switch formatParam { case "raw": - return "application/vnd.ipld.raw" + return "application/vnd.ipld.raw", nil, nil case "car": - return "application/vnd.ipld.car" + return "application/vnd.ipld.car", nil, nil } } // Browsers and other user agents will send Accept header with generic types like: @@ -789,10 +795,14 @@ func customResponseFormat(r *http.Request) string { for _, accept := range r.Header.Values("Accept") { // respond to the very first ipld content type if strings.HasPrefix(accept, "application/vnd.ipld") { - return accept + mediatype, params, err := mime.ParseMediaType(accept) + if err != nil { + return "", nil, err + } + return mediatype, params, nil } } - return "" + return "", nil, nil } func (i *gatewayHandler) searchUpTreeFor404(r *http.Request, contentPath ipath.Path) (ipath.Resolved, string, error) { diff --git a/gateway/core/corehttp/gateway_handler_car.go b/gateway/core/corehttp/gateway_handler_car.go index 5f0f2117f..c6587e564 100644 --- a/gateway/core/corehttp/gateway_handler_car.go +++ b/gateway/core/corehttp/gateway_handler_car.go @@ -2,6 +2,7 @@ package corehttp import ( "context" + "fmt" "net/http" "time" @@ -14,10 +15,19 @@ import ( ) // serveCar returns a CAR stream for specific DAG+selector -func (i *gatewayHandler) serveCar(w http.ResponseWriter, r *http.Request, rootCid cid.Cid, contentPath ipath.Path, begin time.Time) { +func (i *gatewayHandler) serveCar(w http.ResponseWriter, r *http.Request, rootCid cid.Cid, contentPath ipath.Path, carVersion string, begin time.Time) { ctx, cancel := context.WithCancel(r.Context()) defer cancel() + switch carVersion { + case "": // noop, client does not care about version + case "1": // noop, we support this + default: + err := fmt.Errorf("only version=1 is supported") + webError(w, "unsupported CAR version", err, http.StatusBadRequest) + return + } + // Set Content-Disposition name := rootCid.String() + ".car" setContentDispositionHeader(w, name, "attachment") From 57bfeaee9e7e958e6eb5f1644156e5d9f44a376d Mon Sep 17 00:00:00 2001 From: Gus Eggert Date: Mon, 4 Apr 2022 13:24:05 -0400 Subject: [PATCH 614/674] feat: add basic gateway tracing (#8595) * add deprecation warning when tracer plugins are loaded * add response format attribute to span in gateway handler * add note about tracing's experimental status in godoc * add nil check for TTL when adding name span attrs * add basic sharness test for integration with otel collector * add nil check in UnixFSAPI.processLink * test: sharness check all json objs for swarm span * add env var docs to docs/environment-variables.md * chore: pin the otel collector version * add tracing spans per response type (#8841) * docs: tracing with jaeger-ui Co-authored-by: Marcin Rataj This commit was moved from ipfs/kubo@f855bfe6ef8fe8a2633df889ce766cddc8d0effb --- gateway/core/corehttp/gateway.go | 5 ++++- gateway/core/corehttp/gateway_handler.go | 8 ++++++-- gateway/core/corehttp/gateway_handler_block.go | 11 ++++++++--- gateway/core/corehttp/gateway_handler_car.go | 10 ++++++++-- gateway/core/corehttp/gateway_handler_unixfs.go | 9 +++++++-- gateway/core/corehttp/gateway_handler_unixfs_dir.go | 11 ++++++++--- gateway/core/corehttp/gateway_handler_unixfs_file.go | 10 +++++++--- 7 files changed, 48 insertions(+), 16 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index fb1524da5..2e794b53f 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -9,6 +9,7 @@ import ( version "github.com/ipfs/go-ipfs" core "github.com/ipfs/go-ipfs/core" coreapi "github.com/ipfs/go-ipfs/core/coreapi" + "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" options "github.com/ipfs/interface-go-ipfs-core/options" id "github.com/libp2p/go-libp2p/p2p/protocol/identify" @@ -87,12 +88,14 @@ func GatewayOption(writable bool, paths ...string) ServeOption { "X-Stream-Output", }, headers[ACEHeadersName]...)) - gateway := newGatewayHandler(GatewayConfig{ + var gateway http.Handler = newGatewayHandler(GatewayConfig{ Headers: headers, Writable: writable, PathPrefixes: cfg.Gateway.PathPrefixes, }, api) + gateway = otelhttp.NewHandler(gateway, "Gateway.Request") + for _, p := range paths { mux.Handle(p+"/", gateway) } diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 6d90dd008..32d2eebae 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -26,6 +26,8 @@ import ( ipath "github.com/ipfs/interface-go-ipfs-core/path" routing "github.com/libp2p/go-libp2p-core/routing" prometheus "github.com/prometheus/client_golang/prometheus" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" ) const ( @@ -354,6 +356,8 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request webError(w, "error while processing the Accept header", err, http.StatusBadRequest) return } + trace.SpanFromContext(r.Context()).SetAttributes(attribute.String("ResponseFormat", responseFormat)) + trace.SpanFromContext(r.Context()).SetAttributes(attribute.String("ResolvedPath", resolvedPath.String())) // Finish early if client already has matching Etag if r.Header.Get("If-None-Match") == getEtag(r, resolvedPath.Cid()) { @@ -392,12 +396,12 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return case "application/vnd.ipld.raw": logger.Debugw("serving raw block", "path", contentPath) - i.serveRawBlock(w, r, resolvedPath.Cid(), contentPath, begin) + i.serveRawBlock(w, r, resolvedPath, contentPath, begin) return case "application/vnd.ipld.car": logger.Debugw("serving car stream", "path", contentPath) carVersion := formatParams["version"] - i.serveCar(w, r, resolvedPath.Cid(), contentPath, carVersion, begin) + i.serveCar(w, r, resolvedPath, contentPath, carVersion, begin) return default: // catch-all for unsuported application/vnd.* err := fmt.Errorf("unsupported format %q", responseFormat) diff --git a/gateway/core/corehttp/gateway_handler_block.go b/gateway/core/corehttp/gateway_handler_block.go index 13d7ebefd..891c418c8 100644 --- a/gateway/core/corehttp/gateway_handler_block.go +++ b/gateway/core/corehttp/gateway_handler_block.go @@ -6,13 +6,18 @@ import ( "net/http" "time" - cid "github.com/ipfs/go-cid" + "github.com/ipfs/go-ipfs/tracing" ipath "github.com/ipfs/interface-go-ipfs-core/path" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" ) // serveRawBlock returns bytes behind a raw block -func (i *gatewayHandler) serveRawBlock(w http.ResponseWriter, r *http.Request, blockCid cid.Cid, contentPath ipath.Path, begin time.Time) { - blockReader, err := i.api.Block().Get(r.Context(), contentPath) +func (i *gatewayHandler) serveRawBlock(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time) { + ctx, span := tracing.Span(r.Context(), "Gateway", "ServeRawBlock", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) + defer span.End() + blockCid := resolvedPath.Cid() + blockReader, err := i.api.Block().Get(ctx, resolvedPath) if err != nil { webError(w, "ipfs block get "+blockCid.String(), err, http.StatusInternalServerError) return diff --git a/gateway/core/corehttp/gateway_handler_car.go b/gateway/core/corehttp/gateway_handler_car.go index c6587e564..d7dca46b3 100644 --- a/gateway/core/corehttp/gateway_handler_car.go +++ b/gateway/core/corehttp/gateway_handler_car.go @@ -8,15 +8,20 @@ import ( blocks "github.com/ipfs/go-block-format" cid "github.com/ipfs/go-cid" + "github.com/ipfs/go-ipfs/tracing" coreiface "github.com/ipfs/interface-go-ipfs-core" ipath "github.com/ipfs/interface-go-ipfs-core/path" gocar "github.com/ipld/go-car" selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" ) // serveCar returns a CAR stream for specific DAG+selector -func (i *gatewayHandler) serveCar(w http.ResponseWriter, r *http.Request, rootCid cid.Cid, contentPath ipath.Path, carVersion string, begin time.Time) { - ctx, cancel := context.WithCancel(r.Context()) +func (i *gatewayHandler) serveCar(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, carVersion string, begin time.Time) { + ctx, span := tracing.Span(r.Context(), "Gateway", "ServeCar", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) + defer span.End() + ctx, cancel := context.WithCancel(ctx) defer cancel() switch carVersion { @@ -27,6 +32,7 @@ func (i *gatewayHandler) serveCar(w http.ResponseWriter, r *http.Request, rootCi webError(w, "unsupported CAR version", err, http.StatusBadRequest) return } + rootCid := resolvedPath.Cid() // Set Content-Disposition name := rootCid.String() + ".car" diff --git a/gateway/core/corehttp/gateway_handler_unixfs.go b/gateway/core/corehttp/gateway_handler_unixfs.go index ed15f4139..2252b3891 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs.go +++ b/gateway/core/corehttp/gateway_handler_unixfs.go @@ -7,13 +7,18 @@ import ( "time" files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-ipfs/tracing" ipath "github.com/ipfs/interface-go-ipfs-core/path" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" "go.uber.org/zap" ) func (i *gatewayHandler) serveUnixFs(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, logger *zap.SugaredLogger) { + ctx, span := tracing.Span(r.Context(), "Gateway", "ServeUnixFs", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) + defer span.End() // Handling UnixFS - dr, err := i.api.Unixfs().Get(r.Context(), resolvedPath) + dr, err := i.api.Unixfs().Get(ctx, resolvedPath) if err != nil { webError(w, "ipfs cat "+html.EscapeString(contentPath.String()), err, http.StatusNotFound) return @@ -23,7 +28,7 @@ func (i *gatewayHandler) serveUnixFs(w http.ResponseWriter, r *http.Request, res // Handling Unixfs file if f, ok := dr.(files.File); ok { logger.Debugw("serving unixfs file", "path", contentPath) - i.serveFile(w, r, contentPath, resolvedPath.Cid(), f, begin) + i.serveFile(w, r, resolvedPath, contentPath, f, begin) return } diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index 87708159e..e458e8030 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -10,9 +10,12 @@ import ( "github.com/dustin/go-humanize" files "github.com/ipfs/go-ipfs-files" "github.com/ipfs/go-ipfs/assets" + "github.com/ipfs/go-ipfs/tracing" path "github.com/ipfs/go-path" "github.com/ipfs/go-path/resolver" ipath "github.com/ipfs/interface-go-ipfs-core/path" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" "go.uber.org/zap" ) @@ -20,6 +23,8 @@ import ( // // It will return index.html if present, or generate directory listing otherwise. func (i *gatewayHandler) serveDirectory(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, dir files.Directory, begin time.Time, logger *zap.SugaredLogger) { + ctx, span := tracing.Span(r.Context(), "Gateway", "ServeDirectory", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) + defer span.End() // HostnameOption might have constructed an IPNS/IPFS path using the Host header. // In this case, we need the original path for constructing redirects @@ -35,7 +40,7 @@ func (i *gatewayHandler) serveDirectory(w http.ResponseWriter, r *http.Request, // Check if directory has index.html, if so, serveFile idxPath := ipath.Join(resolvedPath, "index.html") - idx, err := i.api.Unixfs().Get(r.Context(), idxPath) + idx, err := i.api.Unixfs().Get(ctx, idxPath) switch err.(type) { case nil: cpath := contentPath.String() @@ -63,7 +68,7 @@ func (i *gatewayHandler) serveDirectory(w http.ResponseWriter, r *http.Request, logger.Debugw("serving index.html file", "path", idxPath) // write to request - i.serveFile(w, r, idxPath, resolvedPath.Cid(), f, begin) + i.serveFile(w, r, resolvedPath, idxPath, f, begin) return case resolver.ErrNoLink: logger.Debugw("no index.html; noop", "path", idxPath) @@ -111,7 +116,7 @@ func (i *gatewayHandler) serveDirectory(w http.ResponseWriter, r *http.Request, size = humanize.Bytes(uint64(s)) } - resolved, err := i.api.ResolvePath(r.Context(), ipath.Join(resolvedPath, dirit.Name())) + resolved, err := i.api.ResolvePath(ctx, ipath.Join(resolvedPath, dirit.Name())) if err != nil { internalWebError(w, err) return diff --git a/gateway/core/corehttp/gateway_handler_unixfs_file.go b/gateway/core/corehttp/gateway_handler_unixfs_file.go index 9807969fe..e8a3718fc 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_file.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_file.go @@ -10,17 +10,21 @@ import ( "time" "github.com/gabriel-vasile/mimetype" - cid "github.com/ipfs/go-cid" files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-ipfs/tracing" ipath "github.com/ipfs/interface-go-ipfs-core/path" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" ) // serveFile returns data behind a file along with HTTP headers based on // the file itself, its CID and the contentPath used for accessing it. -func (i *gatewayHandler) serveFile(w http.ResponseWriter, r *http.Request, contentPath ipath.Path, fileCid cid.Cid, file files.File, begin time.Time) { +func (i *gatewayHandler) serveFile(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, file files.File, begin time.Time) { + _, span := tracing.Span(r.Context(), "Gateway", "ServeFile", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) + defer span.End() // Set Cache-Control and read optional Last-Modified time - modtime := addCacheControlHeaders(w, r, contentPath, fileCid) + modtime := addCacheControlHeaders(w, r, contentPath, resolvedPath.Cid()) // Set Content-Disposition name := addContentDispositionHeader(w, r, contentPath) From c2c9c1e5c73e7586e0c65e04ade37f798eb2b75f Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 8 Apr 2022 21:07:44 +0100 Subject: [PATCH 615/674] fix(gw): update metrics only when payload data sent (#8827) * fix: report gateway http metrics only when response is successful * fix(gw): 304 Not Modified as no-op This fix ensures we don't do any additional work when Etag match what user already has in their own cache. Co-authored-by: Marcin Rataj This commit was moved from ipfs/kubo@fbf76663f4db6f3c4ed89d8c017d9319d2727121 --- gateway/core/corehttp/gateway_handler.go | 60 +++++++++++++++++-- .../core/corehttp/gateway_handler_block.go | 10 ++-- .../corehttp/gateway_handler_unixfs_dir.go | 7 ++- .../corehttp/gateway_handler_unixfs_file.go | 11 ++-- 4 files changed, 74 insertions(+), 14 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 32d2eebae..b14b88739 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -36,8 +36,10 @@ const ( immutableCacheControl = "public, max-age=29030400, immutable" ) -var onlyAscii = regexp.MustCompile("[[:^ascii:]]") -var noModtime = time.Unix(0, 0) // disables Last-Modified header if passed as modtime +var ( + onlyAscii = regexp.MustCompile("[[:^ascii:]]") + noModtime = time.Unix(0, 0) // disables Last-Modified header if passed as modtime +) // HTML-based redirect for errors which can be recovered from, but we want // to provide hint to people that they should fix things on their end. @@ -96,6 +98,54 @@ func (sw *statusResponseWriter) WriteHeader(code int) { sw.ResponseWriter.WriteHeader(code) } +// ServeContent replies to the request using the content in the provided ReadSeeker +// and returns the status code written and any error encountered during a write. +// It wraps http.ServeContent which takes care of If-None-Match+Etag, +// Content-Length and range requests. +func ServeContent(w http.ResponseWriter, req *http.Request, name string, modtime time.Time, content io.ReadSeeker) (int, bool, error) { + ew := &errRecordingResponseWriter{ResponseWriter: w} + http.ServeContent(ew, req, name, modtime, content) + + // When we calculate some metrics we want a flag that lets us to ignore + // errors and 304 Not Modified, and only care when requested data + // was sent in full. + dataSent := ew.code/100 == 2 && ew.err == nil + + return ew.code, dataSent, ew.err +} + +// errRecordingResponseWriter wraps a ResponseWriter to record the status code and any write error. +type errRecordingResponseWriter struct { + http.ResponseWriter + code int + err error +} + +func (w *errRecordingResponseWriter) WriteHeader(code int) { + if w.code == 0 { + w.code = code + } + w.ResponseWriter.WriteHeader(code) +} + +func (w *errRecordingResponseWriter) Write(p []byte) (int, error) { + n, err := w.ResponseWriter.Write(p) + if err != nil && w.err == nil { + w.err = err + } + return n, err +} + +// ReadFrom exposes errRecordingResponseWriter's underlying ResponseWriter to io.Copy +// to allow optimized methods to be taken advantage of. +func (w *errRecordingResponseWriter) ReadFrom(r io.Reader) (n int64, err error) { + n, err = io.Copy(w.ResponseWriter, r) + if err != nil && w.err == nil { + w.err = err + } + return n, err +} + func newGatewaySummaryMetric(name string, help string) *prometheus.SummaryVec { summaryMetric := prometheus.NewSummaryVec( prometheus.SummaryOpts{ @@ -360,7 +410,8 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request trace.SpanFromContext(r.Context()).SetAttributes(attribute.String("ResolvedPath", resolvedPath.String())) // Finish early if client already has matching Etag - if r.Header.Get("If-None-Match") == getEtag(r, resolvedPath.Cid()) { + ifNoneMatch := r.Header.Get("If-None-Match") + if ifNoneMatch == getEtag(r, resolvedPath.Cid()) || ifNoneMatch == getDirListingEtag(resolvedPath.Cid()) { w.WriteHeader(http.StatusNotModified) return } @@ -401,7 +452,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request case "application/vnd.ipld.car": logger.Debugw("serving car stream", "path", contentPath) carVersion := formatParams["version"] - i.serveCar(w, r, resolvedPath, contentPath, carVersion, begin) + i.serveCar(w, r, resolvedPath, contentPath, carVersion, begin) return default: // catch-all for unsuported application/vnd.* err := fmt.Errorf("unsupported format %q", responseFormat) @@ -644,7 +695,6 @@ func addCacheControlHeaders(w http.ResponseWriter, r *http.Request, contentPath // TODO: set Cache-Control based on TTL of IPNS/DNSLink: https://github.com/ipfs/go-ipfs/issues/1818#issuecomment-1015849462 // TODO: set Last-Modified based on /ipns/ publishing timestamp? - } else { // immutable! CACHE ALL THE THINGS, FOREVER! wolololol w.Header().Set("Cache-Control", immutableCacheControl) diff --git a/gateway/core/corehttp/gateway_handler_block.go b/gateway/core/corehttp/gateway_handler_block.go index 891c418c8..afd553d30 100644 --- a/gateway/core/corehttp/gateway_handler_block.go +++ b/gateway/core/corehttp/gateway_handler_block.go @@ -38,10 +38,12 @@ func (i *gatewayHandler) serveRawBlock(w http.ResponseWriter, r *http.Request, r w.Header().Set("Content-Type", "application/vnd.ipld.raw") w.Header().Set("X-Content-Type-Options", "nosniff") // no funny business in the browsers :^) - // Done: http.ServeContent will take care of + // ServeContent will take care of // If-None-Match+Etag, Content-Length and range requests - http.ServeContent(w, r, name, modtime, content) + _, dataSent, _ := ServeContent(w, r, name, modtime, content) - // Update metrics - i.rawBlockGetMetric.WithLabelValues(contentPath.Namespace()).Observe(time.Since(begin).Seconds()) + if dataSent { + // Update metrics + i.rawBlockGetMetric.WithLabelValues(contentPath.Namespace()).Observe(time.Since(begin).Seconds()) + } } diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index e458e8030..158277135 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -8,6 +8,7 @@ import ( "time" "github.com/dustin/go-humanize" + cid "github.com/ipfs/go-cid" files "github.com/ipfs/go-ipfs-files" "github.com/ipfs/go-ipfs/assets" "github.com/ipfs/go-ipfs/tracing" @@ -93,7 +94,7 @@ func (i *gatewayHandler) serveDirectory(w http.ResponseWriter, r *http.Request, // Generated dir index requires custom Etag (it may change between go-ipfs versions) if assets.BindataVersionHash != "" { - dirEtag := `"DirIndex-` + assets.BindataVersionHash + `_CID-` + resolvedPath.Cid().String() + `"` + dirEtag := getDirListingEtag(resolvedPath.Cid()) w.Header().Set("Etag", dirEtag) if r.Header.Get("If-None-Match") == dirEtag { w.WriteHeader(http.StatusNotModified) @@ -204,3 +205,7 @@ func (i *gatewayHandler) serveDirectory(w http.ResponseWriter, r *http.Request, // Update metrics i.unixfsGenDirGetMetric.WithLabelValues(contentPath.Namespace()).Observe(time.Since(begin).Seconds()) } + +func getDirListingEtag(dirCid cid.Cid) string { + return `"DirIndex-` + assets.BindataVersionHash + `_CID-` + dirCid.String() + `"` +} diff --git a/gateway/core/corehttp/gateway_handler_unixfs_file.go b/gateway/core/corehttp/gateway_handler_unixfs_file.go index e8a3718fc..2938c8f48 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_file.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_file.go @@ -82,10 +82,13 @@ func (i *gatewayHandler) serveFile(w http.ResponseWriter, r *http.Request, resol // special fixup around redirects w = &statusResponseWriter{w} - // Done: http.ServeContent will take care of + // ServeContent will take care of // If-None-Match+Etag, Content-Length and range requests - http.ServeContent(w, r, name, modtime, content) + _, dataSent, _ := ServeContent(w, r, name, modtime, content) - // Update metrics - i.unixfsFileGetMetric.WithLabelValues(contentPath.Namespace()).Observe(time.Since(begin).Seconds()) + // Was response successful? + if dataSent { + // Update metrics + i.unixfsFileGetMetric.WithLabelValues(contentPath.Namespace()).Observe(time.Since(begin).Seconds()) + } } From 3be8c5a7229c741bfed81674755eeec0f49c8d79 Mon Sep 17 00:00:00 2001 From: makeworld <25111343+makeworld-the-better-one@users.noreply.github.com> Date: Fri, 8 Apr 2022 17:09:23 -0400 Subject: [PATCH 616/674] fix(gw): missing return if dir fails to finalize (#8806) This commit was moved from ipfs/kubo@52bf1339460220b80d6afdd21eb710ef7d8eaf18 --- gateway/core/corehttp/gateway_handler.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index b14b88739..d2446450b 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -662,6 +662,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { nnode, err := root.GetDirectory().GetNode() if err != nil { webError(w, "WritableGateway: failed to finalize", err, http.StatusInternalServerError) + return } ncid := nnode.Cid() From 03c018793a450d8f4e02ede5be59ece53bbd5a21 Mon Sep 17 00:00:00 2001 From: Gus Eggert Date: Mon, 11 Apr 2022 17:09:00 -0400 Subject: [PATCH 617/674] fix: fix context plumbing in gateway handlers (#8871) This ensures that child contexts are passed around between the handlers so that traces show the call hierarchy correctly. This commit was moved from ipfs/kubo@9bd346e25004df4fd7927ab151097f975fb433c2 --- gateway/core/corehttp/gateway_handler.go | 6 +++--- gateway/core/corehttp/gateway_handler_block.go | 5 +++-- gateway/core/corehttp/gateway_handler_car.go | 6 +++--- gateway/core/corehttp/gateway_handler_unixfs.go | 11 ++++++----- gateway/core/corehttp/gateway_handler_unixfs_dir.go | 7 ++++--- gateway/core/corehttp/gateway_handler_unixfs_file.go | 5 +++-- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index d2446450b..0c34cc9b1 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -443,16 +443,16 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request switch responseFormat { case "": // The implicit response format is UnixFS logger.Debugw("serving unixfs", "path", contentPath) - i.serveUnixFs(w, r, resolvedPath, contentPath, begin, logger) + i.serveUnixFS(r.Context(), w, r, resolvedPath, contentPath, begin, logger) return case "application/vnd.ipld.raw": logger.Debugw("serving raw block", "path", contentPath) - i.serveRawBlock(w, r, resolvedPath, contentPath, begin) + i.serveRawBlock(r.Context(), w, r, resolvedPath, contentPath, begin) return case "application/vnd.ipld.car": logger.Debugw("serving car stream", "path", contentPath) carVersion := formatParams["version"] - i.serveCar(w, r, resolvedPath, contentPath, carVersion, begin) + i.serveCAR(r.Context(), w, r, resolvedPath, contentPath, carVersion, begin) return default: // catch-all for unsuported application/vnd.* err := fmt.Errorf("unsupported format %q", responseFormat) diff --git a/gateway/core/corehttp/gateway_handler_block.go b/gateway/core/corehttp/gateway_handler_block.go index afd553d30..8d6ce0f36 100644 --- a/gateway/core/corehttp/gateway_handler_block.go +++ b/gateway/core/corehttp/gateway_handler_block.go @@ -2,6 +2,7 @@ package corehttp import ( "bytes" + "context" "io/ioutil" "net/http" "time" @@ -13,8 +14,8 @@ import ( ) // serveRawBlock returns bytes behind a raw block -func (i *gatewayHandler) serveRawBlock(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time) { - ctx, span := tracing.Span(r.Context(), "Gateway", "ServeRawBlock", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) +func (i *gatewayHandler) serveRawBlock(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time) { + ctx, span := tracing.Span(ctx, "Gateway", "ServeRawBlock", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) defer span.End() blockCid := resolvedPath.Cid() blockReader, err := i.api.Block().Get(ctx, resolvedPath) diff --git a/gateway/core/corehttp/gateway_handler_car.go b/gateway/core/corehttp/gateway_handler_car.go index d7dca46b3..195808870 100644 --- a/gateway/core/corehttp/gateway_handler_car.go +++ b/gateway/core/corehttp/gateway_handler_car.go @@ -17,9 +17,9 @@ import ( "go.opentelemetry.io/otel/trace" ) -// serveCar returns a CAR stream for specific DAG+selector -func (i *gatewayHandler) serveCar(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, carVersion string, begin time.Time) { - ctx, span := tracing.Span(r.Context(), "Gateway", "ServeCar", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) +// serveCAR returns a CAR stream for specific DAG+selector +func (i *gatewayHandler) serveCAR(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, carVersion string, begin time.Time) { + ctx, span := tracing.Span(ctx, "Gateway", "ServeCAR", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) defer span.End() ctx, cancel := context.WithCancel(ctx) defer cancel() diff --git a/gateway/core/corehttp/gateway_handler_unixfs.go b/gateway/core/corehttp/gateway_handler_unixfs.go index 2252b3891..f91e2df3b 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs.go +++ b/gateway/core/corehttp/gateway_handler_unixfs.go @@ -1,6 +1,7 @@ package corehttp import ( + "context" "fmt" "html" "net/http" @@ -14,8 +15,8 @@ import ( "go.uber.org/zap" ) -func (i *gatewayHandler) serveUnixFs(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, logger *zap.SugaredLogger) { - ctx, span := tracing.Span(r.Context(), "Gateway", "ServeUnixFs", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) +func (i *gatewayHandler) serveUnixFS(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, logger *zap.SugaredLogger) { + ctx, span := tracing.Span(ctx, "Gateway", "ServeUnixFS", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) defer span.End() // Handling UnixFS dr, err := i.api.Unixfs().Get(ctx, resolvedPath) @@ -28,16 +29,16 @@ func (i *gatewayHandler) serveUnixFs(w http.ResponseWriter, r *http.Request, res // Handling Unixfs file if f, ok := dr.(files.File); ok { logger.Debugw("serving unixfs file", "path", contentPath) - i.serveFile(w, r, resolvedPath, contentPath, f, begin) + i.serveFile(ctx, w, r, resolvedPath, contentPath, f, begin) return } // Handling Unixfs directory dir, ok := dr.(files.Directory) if !ok { - internalWebError(w, fmt.Errorf("unsupported UnixFs type")) + internalWebError(w, fmt.Errorf("unsupported UnixFS type")) return } logger.Debugw("serving unixfs directory", "path", contentPath) - i.serveDirectory(w, r, resolvedPath, contentPath, dir, begin, logger) + i.serveDirectory(ctx, w, r, resolvedPath, contentPath, dir, begin, logger) } diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index 158277135..7d491ea49 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -1,6 +1,7 @@ package corehttp import ( + "context" "net/http" "net/url" gopath "path" @@ -23,8 +24,8 @@ import ( // serveDirectory returns the best representation of UnixFS directory // // It will return index.html if present, or generate directory listing otherwise. -func (i *gatewayHandler) serveDirectory(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, dir files.Directory, begin time.Time, logger *zap.SugaredLogger) { - ctx, span := tracing.Span(r.Context(), "Gateway", "ServeDirectory", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) +func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, dir files.Directory, begin time.Time, logger *zap.SugaredLogger) { + ctx, span := tracing.Span(ctx, "Gateway", "ServeDirectory", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) defer span.End() // HostnameOption might have constructed an IPNS/IPFS path using the Host header. @@ -69,7 +70,7 @@ func (i *gatewayHandler) serveDirectory(w http.ResponseWriter, r *http.Request, logger.Debugw("serving index.html file", "path", idxPath) // write to request - i.serveFile(w, r, resolvedPath, idxPath, f, begin) + i.serveFile(ctx, w, r, resolvedPath, idxPath, f, begin) return case resolver.ErrNoLink: logger.Debugw("no index.html; noop", "path", idxPath) diff --git a/gateway/core/corehttp/gateway_handler_unixfs_file.go b/gateway/core/corehttp/gateway_handler_unixfs_file.go index 2938c8f48..1852705fd 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_file.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_file.go @@ -1,6 +1,7 @@ package corehttp import ( + "context" "fmt" "io" "mime" @@ -19,8 +20,8 @@ import ( // serveFile returns data behind a file along with HTTP headers based on // the file itself, its CID and the contentPath used for accessing it. -func (i *gatewayHandler) serveFile(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, file files.File, begin time.Time) { - _, span := tracing.Span(r.Context(), "Gateway", "ServeFile", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) +func (i *gatewayHandler) serveFile(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, file files.File, begin time.Time) { + _, span := tracing.Span(ctx, "Gateway", "ServeFile", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) defer span.End() // Set Cache-Control and read optional Last-Modified time From e01550b957dbacff3305bea1a059ac9e7e1ec7ff Mon Sep 17 00:00:00 2001 From: Franky W Date: Thu, 31 Mar 2022 12:25:49 +0200 Subject: [PATCH 618/674] Remove gobindata Since go1.16, there are built in tools that allow for embeding filesystem inside the binary. We now make use of the `embed` package to have all files put into the binary, removing the need to generate the files and removes dependencies Co-authored-by: Jorropo This commit was moved from ipfs/kubo@9210c08fa69c454e14fc183b5d4237ddecbf3550 --- gateway/core/corehttp/gateway_handler_unixfs_dir.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index 7d491ea49..f462e52f8 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -94,7 +94,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit w.Header().Set("Content-Type", "text/html") // Generated dir index requires custom Etag (it may change between go-ipfs versions) - if assets.BindataVersionHash != "" { + if assets.AssetHash != "" { dirEtag := getDirListingEtag(resolvedPath.Cid()) w.Header().Set("Etag", dirEtag) if r.Header.Get("If-None-Match") == dirEtag { @@ -208,5 +208,5 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit } func getDirListingEtag(dirCid cid.Cid) string { - return `"DirIndex-` + assets.BindataVersionHash + `_CID-` + dirCid.String() + `"` + return `"DirIndex-` + assets.AssetHash + `_CID-` + dirCid.String() + `"` } From 2703c9a1a6ba367fb6c93616337b5eba26b621e3 Mon Sep 17 00:00:00 2001 From: Franky W Date: Mon, 11 Apr 2022 15:31:46 +0200 Subject: [PATCH 619/674] Change `assets.Asset` from a `func` to the embed.FS This removes the delegation to the function and requires all callers that used the `asset.Asset` func to access to asset via the `embed.FS` This commit was moved from ipfs/kubo@70398d275cad281bb55362632dd5a1ce7cb6e80e --- gateway/core/corehttp/gateway_indexPage.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index 3bee4822b..fbea91649 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -94,7 +94,7 @@ func hasDNSLinkOrigin(gwURL string, path string) bool { var listingTemplate *template.Template func init() { - knownIconsBytes, err := assets.Asset("dir-index-html/knownIcons.txt") + knownIconsBytes, err := assets.Asset.ReadFile("dir-index-html/knownIcons.txt") if err != nil { panic(err) } @@ -121,7 +121,7 @@ func init() { } // Directory listing template - dirIndexBytes, err := assets.Asset("dir-index-html/dir-index.html") + dirIndexBytes, err := assets.Asset.ReadFile("dir-index-html/dir-index.html") if err != nil { panic(err) } From 177ce46592403836ed0dce416faf54e49b09f3ac Mon Sep 17 00:00:00 2001 From: Justin Johnson Date: Fri, 15 Apr 2022 09:06:43 -0500 Subject: [PATCH 620/674] chore(gw): extract logical functions to improve readability (#8885) * Extract functions from getOrHeadHandler to improve readability and prepare for later refactorings * Address PR feedback on when to return errors or booleans * Be explicit about use of *requestError vs error This commit was moved from ipfs/kubo@e07baf5835f646352df14fa21ed641053cd0f81b --- gateway/core/corehttp/gateway_handler.go | 212 +++++++++++++++-------- 1 file changed, 139 insertions(+), 73 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 0c34cc9b1..52d86257b 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -28,6 +28,7 @@ import ( prometheus "github.com/prometheus/client_golang/prometheus" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" + "go.uber.org/zap" ) const ( @@ -85,6 +86,25 @@ type statusResponseWriter struct { http.ResponseWriter } +// Custom type for collecting error details to be handled by `webRequestError` +type requestError struct { + Message string + StatusCode int + Err error +} + +func (r *requestError) Error() string { + return r.Err.Error() +} + +func newRequestError(message string, err error, statusCode int) *requestError { + return &requestError{ + Message: message, + Err: err, + StatusCode: statusCode, + } +} + func (sw *statusResponseWriter) WriteHeader(code int) { // Check if we need to adjust Status Code to account for scheduled redirect // This enables us to return payload along with HTTP 301 @@ -324,61 +344,22 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request logger := log.With("from", r.RequestURI) logger.Debug("http request received") - // X-Ipfs-Gateway-Prefix was removed (https://github.com/ipfs/go-ipfs/issues/7702) - // TODO: remove this after go-ipfs 0.13 ships - if prfx := r.Header.Get("X-Ipfs-Gateway-Prefix"); prfx != "" { - err := fmt.Errorf("X-Ipfs-Gateway-Prefix support was removed: https://github.com/ipfs/go-ipfs/issues/7702") - webError(w, "unsupported HTTP header", err, http.StatusBadRequest) + if err := handleUnsupportedHeaders(r); err != nil { + webRequestError(w, err) return } - // ?uri query param support for requests produced by web browsers - // via navigator.registerProtocolHandler Web API - // https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler - // TLDR: redirect /ipfs/?uri=ipfs%3A%2F%2Fcid%3Fquery%3Dval to /ipfs/cid?query=val - if uriParam := r.URL.Query().Get("uri"); uriParam != "" { - u, err := url.Parse(uriParam) - if err != nil { - webError(w, "failed to parse uri query parameter", err, http.StatusBadRequest) - return - } - if u.Scheme != "ipfs" && u.Scheme != "ipns" { - webError(w, "uri query parameter scheme must be ipfs or ipns", err, http.StatusBadRequest) - return - } - path := u.Path - if u.RawQuery != "" { // preserve query if present - path = path + "?" + u.RawQuery - } - - redirectURL := gopath.Join("/", u.Scheme, u.Host, path) - logger.Debugw("uri param, redirect", "to", redirectURL, "status", http.StatusMovedPermanently) - http.Redirect(w, r, redirectURL, http.StatusMovedPermanently) + if requestHandled := handleProtocolHandlerRedirect(w, r, logger); requestHandled { return } - // Service Worker registration request - if r.Header.Get("Service-Worker") == "script" { - // Disallow Service Worker registration on namespace roots - // https://github.com/ipfs/go-ipfs/issues/4025 - matched, _ := regexp.MatchString(`^/ip[fn]s/[^/]+$`, r.URL.Path) - if matched { - err := fmt.Errorf("registration is not allowed for this scope") - webError(w, "navigator.serviceWorker", err, http.StatusBadRequest) - return - } + if err := handleServiceWorkerRegistration(r); err != nil { + webRequestError(w, err) + return } contentPath := ipath.New(r.URL.Path) - if pathErr := contentPath.IsValid(); pathErr != nil { - if fixupSuperfluousNamespace(w, r.URL.Path, r.URL.RawQuery) { - // the error was due to redundant namespace, which we were able to fix - // by returning error/redirect page, nothing left to do here - logger.Debugw("redundant namespace; noop") - return - } - // unable to fix path, returning error - webError(w, "invalid ipfs path", pathErr, http.StatusBadRequest) + if requestHandled := handleSuperfluousNamespace(w, r, contentPath); requestHandled { return } @@ -416,26 +397,13 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } - // Update the global metric of the time it takes to read the final root block of the requested resource - // NOTE: for legacy reasons this happens before we go into content-type specific code paths - _, err = i.api.Block().Get(r.Context(), resolvedPath) - if err != nil { - webError(w, "ipfs block get "+resolvedPath.Cid().String(), err, http.StatusInternalServerError) + if err := i.handleGettingFirstBlock(r, begin, contentPath, resolvedPath); err != nil { + webRequestError(w, err) return } - ns := contentPath.Namespace() - timeToGetFirstContentBlock := time.Since(begin).Seconds() - i.unixfsGetMetric.WithLabelValues(ns).Observe(timeToGetFirstContentBlock) // deprecated, use firstContentBlockGetMetric instead - i.firstContentBlockGetMetric.WithLabelValues(ns).Observe(timeToGetFirstContentBlock) - // HTTP Headers - i.addUserHeaders(w) // ok, _now_ write user's headers. - w.Header().Set("X-Ipfs-Path", contentPath.String()) - - if rootCids, err := i.buildIpfsRootsHeader(contentPath.String(), r); err == nil { - w.Header().Set("X-Ipfs-Roots", rootCids) - } else { // this should never happen, as we resolved the contentPath already - webError(w, "error while resolving X-Ipfs-Roots", err, http.StatusInternalServerError) + if err := i.setCommonHeaders(w, r, contentPath); err != nil { + webRequestError(w, err) return } @@ -785,6 +753,10 @@ func (i *gatewayHandler) buildIpfsRootsHeader(contentPath string, r *http.Reques return rootCidList, nil } +func webRequestError(w http.ResponseWriter, err *requestError) { + webError(w, err.Message, err.Err, err.StatusCode) +} + func webError(w http.ResponseWriter, message string, err error, defaultCode int) { if _, ok := err.(resolver.ErrNoLink); ok { webErrorWithCode(w, message, err, http.StatusNotFound) @@ -911,32 +883,126 @@ func debugStr(path string) string { return q } +func handleUnsupportedHeaders(r *http.Request) (err *requestError) { + // X-Ipfs-Gateway-Prefix was removed (https://github.com/ipfs/go-ipfs/issues/7702) + // TODO: remove this after go-ipfs 0.13 ships + if prfx := r.Header.Get("X-Ipfs-Gateway-Prefix"); prfx != "" { + err := fmt.Errorf("X-Ipfs-Gateway-Prefix support was removed: https://github.com/ipfs/go-ipfs/issues/7702") + return newRequestError("unsupported HTTP header", err, http.StatusBadRequest) + } + return nil +} + +// ?uri query param support for requests produced by web browsers +// via navigator.registerProtocolHandler Web API +// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler +// TLDR: redirect /ipfs/?uri=ipfs%3A%2F%2Fcid%3Fquery%3Dval to /ipfs/cid?query=val +func handleProtocolHandlerRedirect(w http.ResponseWriter, r *http.Request, logger *zap.SugaredLogger) (requestHandled bool) { + if uriParam := r.URL.Query().Get("uri"); uriParam != "" { + u, err := url.Parse(uriParam) + if err != nil { + webError(w, "failed to parse uri query parameter", err, http.StatusBadRequest) + return true + } + if u.Scheme != "ipfs" && u.Scheme != "ipns" { + webError(w, "uri query parameter scheme must be ipfs or ipns", err, http.StatusBadRequest) + return true + } + path := u.Path + if u.RawQuery != "" { // preserve query if present + path = path + "?" + u.RawQuery + } + + redirectURL := gopath.Join("/", u.Scheme, u.Host, path) + logger.Debugw("uri param, redirect", "to", redirectURL, "status", http.StatusMovedPermanently) + http.Redirect(w, r, redirectURL, http.StatusMovedPermanently) + return true + } + + return false +} + +// Disallow Service Worker registration on namespace roots +// https://github.com/ipfs/go-ipfs/issues/4025 +func handleServiceWorkerRegistration(r *http.Request) (err *requestError) { + if r.Header.Get("Service-Worker") == "script" { + matched, _ := regexp.MatchString(`^/ip[fn]s/[^/]+$`, r.URL.Path) + if matched { + err := fmt.Errorf("registration is not allowed for this scope") + return newRequestError("navigator.serviceWorker", err, http.StatusBadRequest) + } + } + + return nil +} + // Attempt to fix redundant /ipfs/ namespace as long as resulting // 'intended' path is valid. This is in case gremlins were tickled // wrong way and user ended up at /ipfs/ipfs/{cid} or /ipfs/ipns/{id} // like in bafybeien3m7mdn6imm425vc2s22erzyhbvk5n3ofzgikkhmdkh5cuqbpbq :^)) -func fixupSuperfluousNamespace(w http.ResponseWriter, urlPath string, urlQuery string) bool { - if !(strings.HasPrefix(urlPath, "/ipfs/ipfs/") || strings.HasPrefix(urlPath, "/ipfs/ipns/")) { - return false // not a superfluous namespace +func handleSuperfluousNamespace(w http.ResponseWriter, r *http.Request, contentPath ipath.Path) (requestHandled bool) { + // If the path is valid, there's nothing to do + if pathErr := contentPath.IsValid(); pathErr == nil { + return false + } + + // If there's no superflous namespace, there's nothing to do + if !(strings.HasPrefix(r.URL.Path, "/ipfs/ipfs/") || strings.HasPrefix(r.URL.Path, "/ipfs/ipns/")) { + return false } - intendedPath := ipath.New(strings.TrimPrefix(urlPath, "/ipfs")) + + // Attempt to fix the superflous namespace + intendedPath := ipath.New(strings.TrimPrefix(r.URL.Path, "/ipfs")) if err := intendedPath.IsValid(); err != nil { - return false // not a valid path + webError(w, "invalid ipfs path", err, http.StatusBadRequest) + return true } intendedURL := intendedPath.String() - if urlQuery != "" { + if r.URL.RawQuery != "" { // we render HTML, so ensure query entries are properly escaped - q, _ := url.ParseQuery(urlQuery) + q, _ := url.ParseQuery(r.URL.RawQuery) intendedURL = intendedURL + "?" + q.Encode() } // return HTTP 400 (Bad Request) with HTML error page that: // - points at correct canonical path via header // - displays human-readable error // - redirects to intendedURL after a short delay + w.WriteHeader(http.StatusBadRequest) - return redirectTemplate.Execute(w, redirectTemplateData{ + if err := redirectTemplate.Execute(w, redirectTemplateData{ RedirectURL: intendedURL, SuggestedPath: intendedPath.String(), - ErrorMsg: fmt.Sprintf("invalid path: %q should be %q", urlPath, intendedPath.String()), - }) == nil + ErrorMsg: fmt.Sprintf("invalid path: %q should be %q", r.URL.Path, intendedPath.String()), + }); err != nil { + webError(w, "failed to redirect when fixing superfluous namespace", err, http.StatusBadRequest) + } + + return true +} + +func (i *gatewayHandler) handleGettingFirstBlock(r *http.Request, begin time.Time, contentPath ipath.Path, resolvedPath ipath.Resolved) *requestError { + // Update the global metric of the time it takes to read the final root block of the requested resource + // NOTE: for legacy reasons this happens before we go into content-type specific code paths + _, err := i.api.Block().Get(r.Context(), resolvedPath) + if err != nil { + return newRequestError("ipfs block get "+resolvedPath.Cid().String(), err, http.StatusInternalServerError) + } + ns := contentPath.Namespace() + timeToGetFirstContentBlock := time.Since(begin).Seconds() + i.unixfsGetMetric.WithLabelValues(ns).Observe(timeToGetFirstContentBlock) // deprecated, use firstContentBlockGetMetric instead + i.firstContentBlockGetMetric.WithLabelValues(ns).Observe(timeToGetFirstContentBlock) + return nil +} + +func (i *gatewayHandler) setCommonHeaders(w http.ResponseWriter, r *http.Request, contentPath ipath.Path) *requestError { + i.addUserHeaders(w) // ok, _now_ write user's headers. + w.Header().Set("X-Ipfs-Path", contentPath.String()) + + if rootCids, err := i.buildIpfsRootsHeader(contentPath.String(), r); err == nil { + w.Header().Set("X-Ipfs-Roots", rootCids) + } else { // this should never happen, as we resolved the contentPath already + return newRequestError("error while resolving X-Ipfs-Roots", err, http.StatusInternalServerError) + } + + return nil } From 88cc0da692792b0b3575f7c7d20fbecea7e2b100 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 19 Apr 2022 20:57:11 +0200 Subject: [PATCH 621/674] feat(gw): improved If-None-Match support (#8891) Improves the way we handle If-None-Match header: - Support for more than one Etag passed in If-None-Match - Match both strong and weak Etags to maximize caching across various HTTP clients and libraries (some send weak Etags by default) - Support for wildcard '*' - Tests for If-None-Match behavior This commit was moved from ipfs/kubo@67fdb6efcdd1d4c0c0ee6fef7190b92c13184dbd --- gateway/core/corehttp/gateway_handler.go | 83 +++++++++++++++++-- .../corehttp/gateway_handler_unixfs_dir.go | 12 +-- gateway/core/corehttp/gateway_test.go | 25 ++++++ 3 files changed, 106 insertions(+), 14 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 52d86257b..f32fac54e 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -7,6 +7,7 @@ import ( "io" "mime" "net/http" + "net/textproto" "net/url" "os" gopath "path" @@ -390,11 +391,18 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request trace.SpanFromContext(r.Context()).SetAttributes(attribute.String("ResponseFormat", responseFormat)) trace.SpanFromContext(r.Context()).SetAttributes(attribute.String("ResolvedPath", resolvedPath.String())) - // Finish early if client already has matching Etag - ifNoneMatch := r.Header.Get("If-None-Match") - if ifNoneMatch == getEtag(r, resolvedPath.Cid()) || ifNoneMatch == getDirListingEtag(resolvedPath.Cid()) { - w.WriteHeader(http.StatusNotModified) - return + // Detect when If-None-Match HTTP header allows returning HTTP 304 Not Modified + if inm := r.Header.Get("If-None-Match"); inm != "" { + pathCid := resolvedPath.Cid() + // need to check against both File and Dir Etag variants + // because this inexpensive check happens before we do any I/O + cidEtag := getEtag(r, pathCid) + dirEtag := getDirListingEtag(pathCid) + if etagMatch(inm, cidEtag, dirEtag) { + // Finish early if client already has a matching Etag + w.WriteHeader(http.StatusNotModified) + return + } } if err := i.handleGettingFirstBlock(r, begin, contentPath, resolvedPath); err != nil { @@ -790,6 +798,71 @@ func getFilename(contentPath ipath.Path) string { return gopath.Base(s) } +// etagMatch evaluates if we can respond with HTTP 304 Not Modified +// It supports multiple weak and strong etags passed in If-None-Matc stringh +// including the wildcard one. +func etagMatch(ifNoneMatchHeader string, cidEtag string, dirEtag string) bool { + buf := ifNoneMatchHeader + for { + buf = textproto.TrimString(buf) + if len(buf) == 0 { + break + } + if buf[0] == ',' { + buf = buf[1:] + continue + } + // If-None-Match: * should match against any etag + if buf[0] == '*' { + return true + } + etag, remain := scanETag(buf) + if etag == "" { + break + } + // Check for match both strong and weak etags + if etagWeakMatch(etag, cidEtag) || etagWeakMatch(etag, dirEtag) { + return true + } + buf = remain + } + return false +} + +// scanETag determines if a syntactically valid ETag is present at s. If so, +// the ETag and remaining text after consuming ETag is returned. Otherwise, +// it returns "", "". +// (This is the same logic as one executed inside of http.ServeContent) +func scanETag(s string) (etag string, remain string) { + s = textproto.TrimString(s) + start := 0 + if strings.HasPrefix(s, "W/") { + start = 2 + } + if len(s[start:]) < 2 || s[start] != '"' { + return "", "" + } + // ETag is either W/"text" or "text". + // See RFC 7232 2.3. + for i := start + 1; i < len(s); i++ { + c := s[i] + switch { + // Character values allowed in ETags. + case c == 0x21 || c >= 0x23 && c <= 0x7E || c >= 0x80: + case c == '"': + return s[:i+1], s[i+1:] + default: + return "", "" + } + } + return "", "" +} + +// etagWeakMatch reports whether a and b match using weak ETag comparison. +func etagWeakMatch(a, b string) bool { + return strings.TrimPrefix(a, "W/") == strings.TrimPrefix(b, "W/") +} + // generate Etag value based on HTTP request and CID func getEtag(r *http.Request, cid cid.Cid) string { prefix := `"` diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index f462e52f8..d2cce5868 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -93,15 +93,9 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit // type instead of relying on autodetection (which may fail). w.Header().Set("Content-Type", "text/html") - // Generated dir index requires custom Etag (it may change between go-ipfs versions) - if assets.AssetHash != "" { - dirEtag := getDirListingEtag(resolvedPath.Cid()) - w.Header().Set("Etag", dirEtag) - if r.Header.Get("If-None-Match") == dirEtag { - w.WriteHeader(http.StatusNotModified) - return - } - } + // Generated dir index requires custom Etag (output may change between go-ipfs versions) + dirEtag := getDirListingEtag(resolvedPath.Cid()) + w.Header().Set("Etag", dirEtag) if r.Method == http.MethodHead { logger.Debug("return as request's HTTP method is HEAD") diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 2cba931dd..303e4a1ac 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -656,3 +656,28 @@ func TestVersion(t *testing.T) { t.Fatalf("response doesn't contain protocol version:\n%s", s) } } + +func TestEtagMatch(t *testing.T) { + for _, test := range []struct { + header string // value in If-None-Match HTTP header + cidEtag string + dirEtag string + expected bool // expected result of etagMatch(header, cidEtag, dirEtag) + }{ + {"", `"etag"`, "", false}, // no If-None-Match + {"", "", `"etag"`, false}, // no If-None-Match + {`"etag"`, `"etag"`, "", true}, // file etag match + {`W/"etag"`, `"etag"`, "", true}, // file etag match + {`"foo", W/"bar", W/"etag"`, `"etag"`, "", true}, // file etag match (array) + {`"foo",W/"bar",W/"etag"`, `"etag"`, "", true}, // file etag match (compact array) + {`"etag"`, "", `W/"etag"`, true}, // dir etag match + {`"etag"`, "", `W/"etag"`, true}, // dir etag match + {`W/"etag"`, "", `W/"etag"`, true}, // dir etag match + {`*`, `"etag"`, "", true}, // wildcard etag match + } { + result := etagMatch(test.header, test.cidEtag, test.dirEtag) + if result != test.expected { + t.Fatalf("unexpected result of etagMatch(%q, %q, %q), got %t, expected %t", test.header, test.cidEtag, test.dirEtag, result, test.expected) + } + } +} From e433566d424c66809021e045023f186c801cdc3e Mon Sep 17 00:00:00 2001 From: Lucas Molas Date: Thu, 28 Apr 2022 14:36:57 -0300 Subject: [PATCH 622/674] feat(gateway): Gateway.FastDirIndexThreshold (#8853) * fix(core/gateway): option to limit directory size listing * feat(gw): HTMLDirListingLimit This is alternative take on the way we limit the HTML listing output. Instead of a hard cut-off, we list up to HTMLDirListingLimit. When a directory has more items than HTMLDirListingLimit we show additional header and footer informing user that only $HTMLDirListingLimit items are listed. This is a better UX. * fix: 0 disables Gateway.HTMLDirListingLimit * refactor: Gateway.FastDirIndexThreshold see explainer in docs/config.md * refactor: prealoc slices * docs: Gateway.FastDirIndexThreshold * refactor: core/corehttp/gateway_handler.go https://github.com/ipfs/go-ipfs/pull/8853#discussion_r851437088 * docs: apply suggestions from code review Co-authored-by: Alan Shaw Co-authored-by: Marcin Rataj Co-authored-by: Alan Shaw This commit was moved from ipfs/kubo@25cc85fa9359f907f348e0c2139f2b535313c56c --- gateway/core/corehttp/gateway.go | 14 ++-- .../core/corehttp/gateway_handler_unixfs.go | 2 + .../corehttp/gateway_handler_unixfs_dir.go | 66 +++++++++++-------- gateway/core/corehttp/gateway_indexPage.go | 17 ++--- 4 files changed, 58 insertions(+), 41 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 2e794b53f..a4ae53831 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -16,9 +16,10 @@ import ( ) type GatewayConfig struct { - Headers map[string][]string - Writable bool - PathPrefixes []string + Headers map[string][]string + Writable bool + PathPrefixes []string + FastDirIndexThreshold int } // A helper function to clean up a set of headers: @@ -89,9 +90,10 @@ func GatewayOption(writable bool, paths ...string) ServeOption { }, headers[ACEHeadersName]...)) var gateway http.Handler = newGatewayHandler(GatewayConfig{ - Headers: headers, - Writable: writable, - PathPrefixes: cfg.Gateway.PathPrefixes, + Headers: headers, + Writable: writable, + PathPrefixes: cfg.Gateway.PathPrefixes, + FastDirIndexThreshold: int(cfg.Gateway.FastDirIndexThreshold.WithDefault(100)), }, api) gateway = otelhttp.NewHandler(gateway, "Gateway.Request") diff --git a/gateway/core/corehttp/gateway_handler_unixfs.go b/gateway/core/corehttp/gateway_handler_unixfs.go index f91e2df3b..b318a641a 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs.go +++ b/gateway/core/corehttp/gateway_handler_unixfs.go @@ -18,6 +18,7 @@ import ( func (i *gatewayHandler) serveUnixFS(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, logger *zap.SugaredLogger) { ctx, span := tracing.Span(ctx, "Gateway", "ServeUnixFS", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) defer span.End() + // Handling UnixFS dr, err := i.api.Unixfs().Get(ctx, resolvedPath) if err != nil { @@ -39,6 +40,7 @@ func (i *gatewayHandler) serveUnixFS(ctx context.Context, w http.ResponseWriter, internalWebError(w, fmt.Errorf("unsupported UnixFS type")) return } + logger.Debugw("serving unixfs directory", "path", contentPath) i.serveDirectory(ctx, w, r, resolvedPath, contentPath, dir, begin, logger) } diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index d2cce5868..1e059200a 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -15,6 +15,7 @@ import ( "github.com/ipfs/go-ipfs/tracing" path "github.com/ipfs/go-path" "github.com/ipfs/go-path/resolver" + options "github.com/ipfs/interface-go-ipfs-core/options" ipath "github.com/ipfs/interface-go-ipfs-core/path" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -102,36 +103,46 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit return } + // Optimization 1: + // List children without fetching their root blocks (fast, but no size info) + results, err := i.api.Unixfs().Ls(ctx, resolvedPath, options.Unixfs.ResolveChildren(false)) + if err != nil { + internalWebError(w, err) + return + } + // storage for directory listing - var dirListing []directoryItem - dirit := dir.Entries() - for dirit.Next() { - size := "?" - if s, err := dirit.Node().Size(); err == nil { - // Size may not be defined/supported. Continue anyways. - size = humanize.Bytes(uint64(s)) - } + dirListing := make([]directoryItem, 0, len(results)) - resolved, err := i.api.ResolvePath(ctx, ipath.Join(resolvedPath, dirit.Name())) - if err != nil { + for link := range results { + if link.Err != nil { internalWebError(w, err) return } - hash := resolved.Cid().String() - - // See comment above where originalUrlPath is declared. + hash := link.Cid.String() di := directoryItem{ - Size: size, - Name: dirit.Name(), - Path: gopath.Join(originalUrlPath, dirit.Name()), + Size: "", // no size because we did not fetch child nodes + Name: link.Name, + Path: gopath.Join(originalUrlPath, link.Name), Hash: hash, ShortHash: shortHash(hash), } dirListing = append(dirListing, di) } - if dirit.Err() != nil { - internalWebError(w, dirit.Err()) - return + + // Optimization 2: fetch sizes only for dirs below FastDirIndexThreshold + if len(dirListing) < i.config.FastDirIndexThreshold { + dirit := dir.Entries() + linkNo := 0 + for dirit.Next() { + size := "?" + if s, err := dirit.Node().Size(); err == nil { + // Size may not be defined/supported. Continue anyways. + size = humanize.Bytes(uint64(s)) + } + dirListing[linkNo].Size = size + linkNo++ + } } // construct the correct back link @@ -180,14 +191,15 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit // See comment above where originalUrlPath is declared. tplData := listingTemplateData{ - GatewayURL: gwURL, - DNSLink: dnslink, - Listing: dirListing, - Size: size, - Path: contentPath.String(), - Breadcrumbs: breadcrumbs(contentPath.String(), dnslink), - BackLink: backLink, - Hash: hash, + GatewayURL: gwURL, + DNSLink: dnslink, + Listing: dirListing, + Size: size, + Path: contentPath.String(), + Breadcrumbs: breadcrumbs(contentPath.String(), dnslink), + BackLink: backLink, + Hash: hash, + FastDirIndexThreshold: i.config.FastDirIndexThreshold, } logger.Debugw("request processed", "tplDataDNSLink", dnslink, "tplDataSize", size, "tplDataBackLink", backLink, "tplDataHash", hash) diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index fbea91649..6cc548cdc 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -12,14 +12,15 @@ import ( // structs for directory listing type listingTemplateData struct { - GatewayURL string - DNSLink bool - Listing []directoryItem - Size string - Path string - Breadcrumbs []breadcrumb - BackLink string - Hash string + GatewayURL string + DNSLink bool + Listing []directoryItem + Size string + Path string + Breadcrumbs []breadcrumb + BackLink string + Hash string + FastDirIndexThreshold int } type directoryItem struct { From ba03bd86efc691ddc7c5ab80ecac96697dde7634 Mon Sep 17 00:00:00 2001 From: Antonio Navarro Perez Date: Wed, 4 May 2022 17:02:07 +0200 Subject: [PATCH 623/674] chore: fix linting errors (#8930) This commit was moved from ipfs/kubo@afd11f1019f0c79a4a6f8b25cc4232239409cc58 --- gateway/core/corehttp/hostname.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 6c0ad5bca..93dde67ab 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -249,6 +249,7 @@ func withHostnameContext(r *http.Request, hostname string) *http.Request { // on subdomain and dnslink gateways. While DNSlink could read value from // Host header, subdomain gateways have more comples rules (knownSubdomainDetails) // More: https://github.com/ipfs/dir-index-html/issues/42 + // nolint: staticcheck // non-backward compatible change ctx := context.WithValue(r.Context(), "gw-hostname", hostname) return r.WithContext(ctx) } From e195b35ff6ce2ce4cb1fa95c13b00843e9c36304 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 19 May 2022 20:11:19 +0200 Subject: [PATCH 624/674] fix: JS caching via Access-Control-Expose-Headers (#8984) This fix safelists additional headers allowing JS running on websites to read them when IPFS resource is downloaded via Fetch API. These headers provide metadata necessary for making smart caching decisions when IPFS resources are downloaded via Service Worker or a similar middleware on the edge. This commit was moved from ipfs/kubo@650bc246ab4a7c2a11a207e3bf9d74c07d190eb7 --- gateway/core/corehttp/gateway.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index a4ae53831..84ad13897 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -84,9 +84,12 @@ func GatewayOption(writable bool, paths ...string) ServeOption { headers[ACEHeadersName] = cleanHeaderSet( append([]string{ + "Content-Length", "Content-Range", "X-Chunked-Output", "X-Stream-Output", + "X-Ipfs-Path", + "X-Ipfs-Roots", }, headers[ACEHeadersName]...)) var gateway http.Handler = newGatewayHandler(GatewayConfig{ From 0f6329e3b091b1bfe931fccb54fe253709a86dd9 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 19 May 2022 20:11:19 +0200 Subject: [PATCH 625/674] fix: JS caching via Access-Control-Expose-Headers (#8984) This fix safelists additional headers allowing JS running on websites to read them when IPFS resource is downloaded via Fetch API. These headers provide metadata necessary for making smart caching decisions when IPFS resources are downloaded via Service Worker or a similar middleware on the edge. (cherry picked from commit e195b35ff6ce2ce4cb1fa95c13b00843e9c36304) This commit was moved from ipfs/kubo@4449909b2da690d3677903fc0b1797c1ad00275b --- gateway/core/corehttp/gateway.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index a4ae53831..84ad13897 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -84,9 +84,12 @@ func GatewayOption(writable bool, paths ...string) ServeOption { headers[ACEHeadersName] = cleanHeaderSet( append([]string{ + "Content-Length", "Content-Range", "X-Chunked-Output", "X-Stream-Output", + "X-Ipfs-Path", + "X-Ipfs-Roots", }, headers[ACEHeadersName]...)) var gateway http.Handler = newGatewayHandler(GatewayConfig{ From c94a766eb276315c34f6e3cd0ed0d7d1d9b93a14 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Thu, 9 Jun 2022 14:55:30 +0200 Subject: [PATCH 626/674] fix: honor url filename when downloading as CAR/BLOCK This commit was moved from ipfs/kubo@33843bfe3a577ee3425cd81733bd79f8d4b8a92b --- gateway/core/corehttp/gateway_handler_block.go | 7 ++++++- gateway/core/corehttp/gateway_handler_car.go | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler_block.go b/gateway/core/corehttp/gateway_handler_block.go index 8d6ce0f36..b545d2e51 100644 --- a/gateway/core/corehttp/gateway_handler_block.go +++ b/gateway/core/corehttp/gateway_handler_block.go @@ -31,7 +31,12 @@ func (i *gatewayHandler) serveRawBlock(ctx context.Context, w http.ResponseWrite content := bytes.NewReader(block) // Set Content-Disposition - name := blockCid.String() + ".bin" + var name string + if urlFilename := r.URL.Query().Get("filename"); urlFilename != "" { + name = urlFilename + } else { + name = blockCid.String() + ".bin" + } setContentDispositionHeader(w, name, "attachment") // Set remaining headers diff --git a/gateway/core/corehttp/gateway_handler_car.go b/gateway/core/corehttp/gateway_handler_car.go index 195808870..e6d2f663d 100644 --- a/gateway/core/corehttp/gateway_handler_car.go +++ b/gateway/core/corehttp/gateway_handler_car.go @@ -35,7 +35,12 @@ func (i *gatewayHandler) serveCAR(ctx context.Context, w http.ResponseWriter, r rootCid := resolvedPath.Cid() // Set Content-Disposition - name := rootCid.String() + ".car" + var name string + if urlFilename := r.URL.Query().Get("filename"); urlFilename != "" { + name = urlFilename + } else { + name = rootCid.String() + ".car" + } setContentDispositionHeader(w, name, "attachment") // Weak Etag W/ because we can't guarantee byte-for-byte identical responses From b1186fa73e42b2f15b7489f6f4839bfe5b8bd1e1 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Tue, 14 Jun 2022 18:37:02 +0200 Subject: [PATCH 627/674] chore: replace ioutil with io and os (#8969) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Håvard Anda Estensen This commit was moved from ipfs/kubo@a433064d72599311702c332546d46ec5e4e647d0 --- gateway/core/corehttp/gateway_handler_block.go | 4 ++-- gateway/core/corehttp/gateway_test.go | 14 +++++++------- gateway/core/corehttp/lazyseek_test.go | 9 ++++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler_block.go b/gateway/core/corehttp/gateway_handler_block.go index b545d2e51..814ec9544 100644 --- a/gateway/core/corehttp/gateway_handler_block.go +++ b/gateway/core/corehttp/gateway_handler_block.go @@ -3,7 +3,7 @@ package corehttp import ( "bytes" "context" - "io/ioutil" + "io" "net/http" "time" @@ -23,7 +23,7 @@ func (i *gatewayHandler) serveRawBlock(ctx context.Context, w http.ResponseWrite webError(w, "ipfs block get "+blockCid.String(), err, http.StatusInternalServerError) return } - block, err := ioutil.ReadAll(blockReader) + block, err := io.ReadAll(blockReader) if err != nil { webError(w, "ipfs block get "+blockCid.String(), err, http.StatusInternalServerError) return diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 303e4a1ac..e3bc95a08 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -3,7 +3,7 @@ package corehttp import ( "context" "errors" - "io/ioutil" + "io" "net/http" "net/http/httptest" "regexp" @@ -267,7 +267,7 @@ func TestGatewayGet(t *testing.T) { if contentType != "text/plain; charset=utf-8" { t.Errorf("expected content type to be text/plain, got %s", contentType) } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if resp.StatusCode != test.status { t.Errorf("(%d) got %d, expected %d from %s", i, resp.StatusCode, test.status, urlstr) t.Errorf("Body: %s", body) @@ -335,7 +335,7 @@ func TestPretty404(t *testing.T) { if resp.StatusCode != test.status { t.Fatalf("got %d, expected %d, from %s", resp.StatusCode, test.status, test.path) } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { t.Fatalf("error reading response from %s: %s", test.path, err) } @@ -482,7 +482,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { } // expect correct links - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) if err != nil { t.Fatalf("error reading response: %s", err) } @@ -519,7 +519,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { } // expect correct backlinks at root - body, err = ioutil.ReadAll(res.Body) + body, err = io.ReadAll(res.Body) if err != nil { t.Fatalf("error reading response: %s", err) } @@ -556,7 +556,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { } // expect correct backlinks - body, err = ioutil.ReadAll(res.Body) + body, err = io.ReadAll(res.Body) if err != nil { t.Fatalf("error reading response: %s", err) } @@ -638,7 +638,7 @@ func TestVersion(t *testing.T) { if err != nil { t.Fatal(err) } - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) if err != nil { t.Fatalf("error reading response: %s", err) } diff --git a/gateway/core/corehttp/lazyseek_test.go b/gateway/core/corehttp/lazyseek_test.go index 144e57d0f..2733acafb 100644 --- a/gateway/core/corehttp/lazyseek_test.go +++ b/gateway/core/corehttp/lazyseek_test.go @@ -3,7 +3,6 @@ package corehttp import ( "fmt" "io" - "io/ioutil" "strings" "testing" ) @@ -37,7 +36,7 @@ func TestLazySeekerError(t *testing.T) { } // shouldn't have actually seeked. - b, err := ioutil.ReadAll(s) + b, err := io.ReadAll(s) if err != nil { t.Fatal(err) } @@ -53,7 +52,7 @@ func TestLazySeekerError(t *testing.T) { if off != 0 { t.Fatal("expected to seek to the start") } - b, err = ioutil.ReadAll(s) + b, err = io.ReadAll(s) if err != nil { t.Fatal(err) } @@ -70,7 +69,7 @@ func TestLazySeekerError(t *testing.T) { t.Fatal("expected to seek to the start") } // right here... - b, err = ioutil.ReadAll(s) + b, err = io.ReadAll(s) if err == nil { t.Fatalf("expected an error, got output %s", string(b)) } @@ -120,7 +119,7 @@ func TestLazySeeker(t *testing.T) { } expectSeek(io.SeekEnd, 0, s.size, "") - b, err := ioutil.ReadAll(s) + b, err := io.ReadAll(s) if err != nil { t.Fatal(err) } From aedec6f94797eb72a26fac6df9fd6516e5e36705 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 12 Jun 2022 17:53:00 +0200 Subject: [PATCH 628/674] update go-libp2p to v0.20.2 This commit was moved from ipfs/kubo@ec61dd410d022191115b96a15c4d9a5462988e96 --- gateway/core/corehttp/metrics_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index 76f79d2ee..fe37515d5 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -8,8 +8,8 @@ import ( "github.com/ipfs/go-ipfs/core" inet "github.com/libp2p/go-libp2p-core/network" - swarmt "github.com/libp2p/go-libp2p-swarm/testing" bhost "github.com/libp2p/go-libp2p/p2p/host/basic" + swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing" ) // This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect From 857f12b805436840c128f03f19a1baff249df52c Mon Sep 17 00:00:00 2001 From: Jorropo Date: Wed, 6 Jul 2022 15:05:14 +0200 Subject: [PATCH 629/674] chore: update go-car This commit was moved from ipfs/kubo@cbf5fdae5517b06491deba2d3cc31b7ff41451fe --- gateway/core/corehttp/gateway_handler_car.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler_car.go b/gateway/core/corehttp/gateway_handler_car.go index e6d2f663d..72231ceaf 100644 --- a/gateway/core/corehttp/gateway_handler_car.go +++ b/gateway/core/corehttp/gateway_handler_car.go @@ -86,12 +86,12 @@ func (i *gatewayHandler) serveCAR(ctx context.Context, w http.ResponseWriter, r i.carStreamGetMetric.WithLabelValues(contentPath.Namespace()).Observe(time.Since(begin).Seconds()) } +// FIXME(@Jorropo): https://github.com/ipld/go-car/issues/315 type dagStore struct { dag coreiface.APIDagService ctx context.Context } -func (ds dagStore) Get(c cid.Cid) (blocks.Block, error) { - obj, err := ds.dag.Get(ds.ctx, c) - return obj, err +func (ds dagStore) Get(_ context.Context, c cid.Cid) (blocks.Block, error) { + return ds.dag.Get(ds.ctx, c) } From add052cb69cb3fef8889f23c7096b5e447916856 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Wed, 6 Jul 2022 15:05:14 +0200 Subject: [PATCH 630/674] chore: update go-car (cherry picked from commit 857f12b805436840c128f03f19a1baff249df52c) This commit was moved from ipfs/kubo@bc4f854ade2c5713bb9bba2039d3ee8fc03c6441 --- gateway/core/corehttp/gateway_handler_car.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler_car.go b/gateway/core/corehttp/gateway_handler_car.go index 195808870..5294d6598 100644 --- a/gateway/core/corehttp/gateway_handler_car.go +++ b/gateway/core/corehttp/gateway_handler_car.go @@ -81,12 +81,12 @@ func (i *gatewayHandler) serveCAR(ctx context.Context, w http.ResponseWriter, r i.carStreamGetMetric.WithLabelValues(contentPath.Namespace()).Observe(time.Since(begin).Seconds()) } +// FIXME(@Jorropo): https://github.com/ipld/go-car/issues/315 type dagStore struct { dag coreiface.APIDagService ctx context.Context } -func (ds dagStore) Get(c cid.Cid) (blocks.Block, error) { - obj, err := ds.dag.Get(ds.ctx, c) - return obj, err +func (ds dagStore) Get(_ context.Context, c cid.Cid) (blocks.Block, error) { + return ds.dag.Get(ds.ctx, c) } From 2871589632f0685133bd0d39dc25fda75073b3a7 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 5 Jul 2022 01:06:01 +0200 Subject: [PATCH 631/674] fix: correct cache-control in car responses Context: https://github.com/ipfs/specs/pull/295 This commit was moved from ipfs/kubo@289e465f0589a33c3333efe6eab26695e3a78df4 --- gateway/core/corehttp/gateway_handler_car.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler_car.go b/gateway/core/corehttp/gateway_handler_car.go index 72231ceaf..05c297664 100644 --- a/gateway/core/corehttp/gateway_handler_car.go +++ b/gateway/core/corehttp/gateway_handler_car.go @@ -43,8 +43,14 @@ func (i *gatewayHandler) serveCAR(ctx context.Context, w http.ResponseWriter, r } setContentDispositionHeader(w, name, "attachment") - // Weak Etag W/ because we can't guarantee byte-for-byte identical responses - // (CAR is streamed, and in theory, blocks may arrive from datastore in non-deterministic order) + // Set Cache-Control (same logic as for a regular files) + addCacheControlHeaders(w, r, contentPath, rootCid) + + // Weak Etag W/ because we can't guarantee byte-for-byte identical + // responses, but still want to benefit from HTTP Caching. Two CAR + // responses for the same CID and selector will be logically equivalent, + // but when CAR is streamed, then in theory, blocks may arrive from + // datastore in non-deterministic order. etag := `W/` + getEtag(r, rootCid) w.Header().Set("Etag", etag) @@ -55,14 +61,10 @@ func (i *gatewayHandler) serveCAR(ctx context.Context, w http.ResponseWriter, r } // Make it clear we don't support range-requests over a car stream - // Partial downloads and resumes should be handled using - // IPLD selectors: https://github.com/ipfs/go-ipfs/issues/8769 + // Partial downloads and resumes should be handled using requests for + // sub-DAGs and IPLD selectors: https://github.com/ipfs/go-ipfs/issues/8769 w.Header().Set("Accept-Ranges", "none") - // Explicit Cache-Control to ensure fresh stream on retry. - // CAR stream could be interrupted, and client should be able to resume and get full response, not the truncated one - w.Header().Set("Cache-Control", "no-cache, no-transform") - w.Header().Set("Content-Type", "application/vnd.ipld.car; version=1") w.Header().Set("X-Content-Type-Options", "nosniff") // no funny business in the browsers :^) From 727a167f6b203873f064c28ea45ecc41e57fe487 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 9 May 2022 20:17:09 +0200 Subject: [PATCH 632/674] refactor: rename to kubo This commit was moved from ipfs/kubo@82467bc936fe24355c930f7226fce7e41fee591c --- gateway/core/corehttp/commands.go | 10 +++++----- gateway/core/corehttp/corehttp.go | 2 +- gateway/core/corehttp/gateway.go | 6 +++--- gateway/core/corehttp/gateway_handler.go | 16 ++++++++-------- gateway/core/corehttp/gateway_handler_block.go | 2 +- gateway/core/corehttp/gateway_handler_car.go | 4 ++-- gateway/core/corehttp/gateway_handler_unixfs.go | 2 +- .../core/corehttp/gateway_handler_unixfs_dir.go | 8 ++++---- .../core/corehttp/gateway_handler_unixfs_file.go | 6 +++--- gateway/core/corehttp/gateway_indexPage.go | 2 +- gateway/core/corehttp/gateway_test.go | 10 +++++----- gateway/core/corehttp/hostname.go | 12 ++++++------ gateway/core/corehttp/hostname_test.go | 4 ++-- gateway/core/corehttp/logs.go | 2 +- gateway/core/corehttp/metrics.go | 2 +- gateway/core/corehttp/metrics_test.go | 2 +- gateway/core/corehttp/mutex_profile.go | 2 +- gateway/core/corehttp/option_test.go | 2 +- gateway/core/corehttp/p2p_proxy.go | 2 +- gateway/core/corehttp/p2p_proxy_test.go | 2 +- gateway/core/corehttp/redirect.go | 2 +- 21 files changed, 50 insertions(+), 50 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index 14b503ff5..b433dfea7 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -9,15 +9,15 @@ import ( "strconv" "strings" - version "github.com/ipfs/go-ipfs" - oldcmds "github.com/ipfs/go-ipfs/commands" - "github.com/ipfs/go-ipfs/core" - corecommands "github.com/ipfs/go-ipfs/core/commands" + version "github.com/ipfs/kubo" + oldcmds "github.com/ipfs/kubo/commands" + "github.com/ipfs/kubo/core" + corecommands "github.com/ipfs/kubo/core/commands" cmds "github.com/ipfs/go-ipfs-cmds" cmdsHttp "github.com/ipfs/go-ipfs-cmds/http" - config "github.com/ipfs/go-ipfs/config" path "github.com/ipfs/go-path" + config "github.com/ipfs/kubo/config" ) var ( diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go index 143327149..fe9f1b1db 100644 --- a/gateway/core/corehttp/corehttp.go +++ b/gateway/core/corehttp/corehttp.go @@ -11,8 +11,8 @@ import ( "net/http" "time" - core "github.com/ipfs/go-ipfs/core" logging "github.com/ipfs/go-log" + core "github.com/ipfs/kubo/core" "github.com/jbenet/goprocess" periodicproc "github.com/jbenet/goprocess/periodic" ma "github.com/multiformats/go-multiaddr" diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 84ad13897..dcaf92f29 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -6,9 +6,9 @@ import ( "net/http" "sort" - version "github.com/ipfs/go-ipfs" - core "github.com/ipfs/go-ipfs/core" - coreapi "github.com/ipfs/go-ipfs/core/coreapi" + version "github.com/ipfs/kubo" + core "github.com/ipfs/kubo/core" + coreapi "github.com/ipfs/kubo/core/coreapi" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" options "github.com/ipfs/interface-go-ipfs-core/options" diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index f32fac54e..e7c6df4a6 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -189,7 +189,7 @@ func newGatewaySummaryMetric(name string, help string) *prometheus.SummaryVec { func newGatewayHistogramMetric(name string, help string) *prometheus.HistogramVec { // We can add buckets as a parameter in the future, but for now using static defaults - // suggested in https://github.com/ipfs/go-ipfs/issues/8441 + // suggested in https://github.com/ipfs/kubo/issues/8441 defaultBuckets := []float64{0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10, 30, 60} histogramMetric := prometheus.NewHistogramVec( prometheus.HistogramOpts{ @@ -666,11 +666,11 @@ func addCacheControlHeaders(w http.ResponseWriter, r *http.Request, contentPath // mutable namespaces such as /ipns/ can't be cached forever /* For now we set Last-Modified to Now() to leverage caching heuristics built into modern browsers: - * https://github.com/ipfs/go-ipfs/pull/8074#pullrequestreview-645196768 + * https://github.com/ipfs/kubo/pull/8074#pullrequestreview-645196768 * but we should not set it to fake values and use Cache-Control based on TTL instead */ modtime = time.Now() - // TODO: set Cache-Control based on TTL of IPNS/DNSLink: https://github.com/ipfs/go-ipfs/issues/1818#issuecomment-1015849462 + // TODO: set Cache-Control based on TTL of IPNS/DNSLink: https://github.com/ipfs/kubo/issues/1818#issuecomment-1015849462 // TODO: set Last-Modified based on /ipns/ publishing timestamp? } else { // immutable! CACHE ALL THE THINGS, FOREVER! wolololol @@ -679,7 +679,7 @@ func addCacheControlHeaders(w http.ResponseWriter, r *http.Request, contentPath // Set modtime to 'zero time' to disable Last-Modified header (superseded by Cache-Control) modtime = noModtime - // TODO: set Last-Modified? - TBD - /ipfs/ modification metadata is present in unixfs 1.5 https://github.com/ipfs/go-ipfs/issues/6920? + // TODO: set Last-Modified? - TBD - /ipfs/ modification metadata is present in unixfs 1.5 https://github.com/ipfs/kubo/issues/6920? } return modtime @@ -874,7 +874,7 @@ func getEtag(r *http.Request, cid cid.Cid) string { // Etag: "cid.foo" (gives us nice compression together with Content-Disposition in block (raw) and car responses) suffix = `.` + f + suffix } - // TODO: include selector suffix when https://github.com/ipfs/go-ipfs/issues/8769 lands + // TODO: include selector suffix when https://github.com/ipfs/kubo/issues/8769 lands return prefix + cid.String() + suffix } @@ -957,10 +957,10 @@ func debugStr(path string) string { } func handleUnsupportedHeaders(r *http.Request) (err *requestError) { - // X-Ipfs-Gateway-Prefix was removed (https://github.com/ipfs/go-ipfs/issues/7702) + // X-Ipfs-Gateway-Prefix was removed (https://github.com/ipfs/kubo/issues/7702) // TODO: remove this after go-ipfs 0.13 ships if prfx := r.Header.Get("X-Ipfs-Gateway-Prefix"); prfx != "" { - err := fmt.Errorf("X-Ipfs-Gateway-Prefix support was removed: https://github.com/ipfs/go-ipfs/issues/7702") + err := fmt.Errorf("X-Ipfs-Gateway-Prefix support was removed: https://github.com/ipfs/kubo/issues/7702") return newRequestError("unsupported HTTP header", err, http.StatusBadRequest) } return nil @@ -996,7 +996,7 @@ func handleProtocolHandlerRedirect(w http.ResponseWriter, r *http.Request, logge } // Disallow Service Worker registration on namespace roots -// https://github.com/ipfs/go-ipfs/issues/4025 +// https://github.com/ipfs/kubo/issues/4025 func handleServiceWorkerRegistration(r *http.Request) (err *requestError) { if r.Header.Get("Service-Worker") == "script" { matched, _ := regexp.MatchString(`^/ip[fn]s/[^/]+$`, r.URL.Path) diff --git a/gateway/core/corehttp/gateway_handler_block.go b/gateway/core/corehttp/gateway_handler_block.go index 814ec9544..3bf7c76be 100644 --- a/gateway/core/corehttp/gateway_handler_block.go +++ b/gateway/core/corehttp/gateway_handler_block.go @@ -7,8 +7,8 @@ import ( "net/http" "time" - "github.com/ipfs/go-ipfs/tracing" ipath "github.com/ipfs/interface-go-ipfs-core/path" + "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" ) diff --git a/gateway/core/corehttp/gateway_handler_car.go b/gateway/core/corehttp/gateway_handler_car.go index 05c297664..3363c5199 100644 --- a/gateway/core/corehttp/gateway_handler_car.go +++ b/gateway/core/corehttp/gateway_handler_car.go @@ -8,9 +8,9 @@ import ( blocks "github.com/ipfs/go-block-format" cid "github.com/ipfs/go-cid" - "github.com/ipfs/go-ipfs/tracing" coreiface "github.com/ipfs/interface-go-ipfs-core" ipath "github.com/ipfs/interface-go-ipfs-core/path" + "github.com/ipfs/kubo/tracing" gocar "github.com/ipld/go-car" selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" "go.opentelemetry.io/otel/attribute" @@ -71,7 +71,7 @@ func (i *gatewayHandler) serveCAR(ctx context.Context, w http.ResponseWriter, r // Same go-car settings as dag.export command store := dagStore{dag: i.api.Dag(), ctx: ctx} - // TODO: support selectors passed as request param: https://github.com/ipfs/go-ipfs/issues/8769 + // TODO: support selectors passed as request param: https://github.com/ipfs/kubo/issues/8769 dag := gocar.Dag{Root: rootCid, Selector: selectorparse.CommonSelector_ExploreAllRecursively} car := gocar.NewSelectiveCar(ctx, store, []gocar.Dag{dag}, gocar.TraverseLinksOnlyOnce()) diff --git a/gateway/core/corehttp/gateway_handler_unixfs.go b/gateway/core/corehttp/gateway_handler_unixfs.go index b318a641a..0aec83a8b 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs.go +++ b/gateway/core/corehttp/gateway_handler_unixfs.go @@ -8,8 +8,8 @@ import ( "time" files "github.com/ipfs/go-ipfs-files" - "github.com/ipfs/go-ipfs/tracing" ipath "github.com/ipfs/interface-go-ipfs-core/path" + "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" "go.uber.org/zap" diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index 1e059200a..30e1b5ec7 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -11,12 +11,12 @@ import ( "github.com/dustin/go-humanize" cid "github.com/ipfs/go-cid" files "github.com/ipfs/go-ipfs-files" - "github.com/ipfs/go-ipfs/assets" - "github.com/ipfs/go-ipfs/tracing" path "github.com/ipfs/go-path" "github.com/ipfs/go-path/resolver" options "github.com/ipfs/interface-go-ipfs-core/options" ipath "github.com/ipfs/interface-go-ipfs-core/path" + "github.com/ipfs/kubo/assets" + "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" "go.uber.org/zap" @@ -81,7 +81,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit } // See statusResponseWriter.WriteHeader - // and https://github.com/ipfs/go-ipfs/issues/7164 + // and https://github.com/ipfs/kubo/issues/7164 // Note: this needs to occur before listingTemplate.Execute otherwise we get // superfluous response.WriteHeader call from prometheus/client_golang if w.Header().Get("Location") != "" { @@ -146,7 +146,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit } // construct the correct back link - // https://github.com/ipfs/go-ipfs/issues/1365 + // https://github.com/ipfs/kubo/issues/1365 var backLink string = originalUrlPath // don't go further up than /ipfs/$hash/ diff --git a/gateway/core/corehttp/gateway_handler_unixfs_file.go b/gateway/core/corehttp/gateway_handler_unixfs_file.go index 1852705fd..5053558dc 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_file.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_file.go @@ -12,8 +12,8 @@ import ( "github.com/gabriel-vasile/mimetype" files "github.com/ipfs/go-ipfs-files" - "github.com/ipfs/go-ipfs/tracing" ipath "github.com/ipfs/interface-go-ipfs-core/path" + "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" ) @@ -54,7 +54,7 @@ func (i *gatewayHandler) serveFile(ctx context.Context, w http.ResponseWriter, r ctype = mime.TypeByExtension(gopath.Ext(name)) if ctype == "" { // uses https://github.com/gabriel-vasile/mimetype library to determine the content type. - // Fixes https://github.com/ipfs/go-ipfs/issues/7252 + // Fixes https://github.com/ipfs/kubo/issues/7252 mimeType, err := mimetype.DetectReader(content) if err != nil { http.Error(w, fmt.Sprintf("cannot detect content-type: %s", err.Error()), http.StatusInternalServerError) @@ -71,7 +71,7 @@ func (i *gatewayHandler) serveFile(ctx context.Context, w http.ResponseWriter, r // Strip the encoding from the HTML Content-Type header and let the // browser figure it out. // - // Fixes https://github.com/ipfs/go-ipfs/issues/2203 + // Fixes https://github.com/ipfs/kubo/issues/2203 if strings.HasPrefix(ctype, "text/html;") { ctype = "text/html" } diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index 6cc548cdc..1168d6556 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -6,8 +6,8 @@ import ( "path" "strings" - "github.com/ipfs/go-ipfs/assets" ipfspath "github.com/ipfs/go-path" + "github.com/ipfs/kubo/assets" ) // structs for directory listing diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index e3bc95a08..5f7cf0cb5 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -11,20 +11,20 @@ import ( "testing" "time" - version "github.com/ipfs/go-ipfs" - core "github.com/ipfs/go-ipfs/core" - "github.com/ipfs/go-ipfs/core/coreapi" - repo "github.com/ipfs/go-ipfs/repo" namesys "github.com/ipfs/go-namesys" + version "github.com/ipfs/kubo" + core "github.com/ipfs/kubo/core" + "github.com/ipfs/kubo/core/coreapi" + repo "github.com/ipfs/kubo/repo" datastore "github.com/ipfs/go-datastore" syncds "github.com/ipfs/go-datastore/sync" files "github.com/ipfs/go-ipfs-files" - config "github.com/ipfs/go-ipfs/config" path "github.com/ipfs/go-path" iface "github.com/ipfs/interface-go-ipfs-core" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" ipath "github.com/ipfs/interface-go-ipfs-core/path" + config "github.com/ipfs/kubo/config" ci "github.com/libp2p/go-libp2p-core/crypto" id "github.com/libp2p/go-libp2p/p2p/protocol/identify" ) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 93dde67ab..658eb34d4 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -10,18 +10,18 @@ import ( "strings" cid "github.com/ipfs/go-cid" - core "github.com/ipfs/go-ipfs/core" - coreapi "github.com/ipfs/go-ipfs/core/coreapi" namesys "github.com/ipfs/go-namesys" + core "github.com/ipfs/kubo/core" + coreapi "github.com/ipfs/kubo/core/coreapi" "github.com/libp2p/go-libp2p-core/peer" dns "github.com/miekg/dns" mbase "github.com/multiformats/go-multibase" - config "github.com/ipfs/go-ipfs/config" iface "github.com/ipfs/interface-go-ipfs-core" options "github.com/ipfs/interface-go-ipfs-core/options" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" + config "github.com/ipfs/kubo/config" ) var defaultPaths = []string{"/ipfs/", "/ipns/", "/api/", "/p2p/"} @@ -506,13 +506,13 @@ func toSubdomainURL(hostname, path string, r *http.Request, ipfs iface.CoreAPI) // Normalizations specific to /ipns/{libp2p-key} if isPeerIDNamespace(ns) { // Using Base36 for /ipns/ for consistency - // Context: https://github.com/ipfs/go-ipfs/pull/7441#discussion_r452372828 + // Context: https://github.com/ipfs/kubo/pull/7441#discussion_r452372828 base = mbase.Base36 // PeerIDs represented as CIDv1 are expected to have libp2p-key // multicodec (https://github.com/libp2p/specs/pull/209). // We ease the transition by fixing multicodec on the fly: - // https://github.com/ipfs/go-ipfs/issues/5287#issuecomment-492163929 + // https://github.com/ipfs/kubo/issues/5287#issuecomment-492163929 if multicodec != cid.Libp2pKey { multicodec = cid.Libp2pKey } @@ -531,7 +531,7 @@ func toSubdomainURL(hostname, path string, r *http.Request, ipfs iface.CoreAPI) return "", err } // 2. Make sure CID fits in a DNS label, adjust encoding if needed - // (https://github.com/ipfs/go-ipfs/issues/7318) + // (https://github.com/ipfs/kubo/issues/7318) rootID, err = toDNSLabel(rootID, rootCID) if err != nil { return "", err diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index df0f4f229..c2aa9b757 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -8,9 +8,9 @@ import ( cid "github.com/ipfs/go-cid" files "github.com/ipfs/go-ipfs-files" - config "github.com/ipfs/go-ipfs/config" - coreapi "github.com/ipfs/go-ipfs/core/coreapi" path "github.com/ipfs/go-path" + config "github.com/ipfs/kubo/config" + coreapi "github.com/ipfs/kubo/core/coreapi" ) func TestToSubdomainURL(t *testing.T) { diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go index 99e8fa885..944e62c5b 100644 --- a/gateway/core/corehttp/logs.go +++ b/gateway/core/corehttp/logs.go @@ -5,8 +5,8 @@ import ( "net" "net/http" - core "github.com/ipfs/go-ipfs/core" lwriter "github.com/ipfs/go-log/writer" + core "github.com/ipfs/kubo/core" ) type writeErrNotifier struct { diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index c3dbde0ac..4e2b81d13 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -5,7 +5,7 @@ import ( "net/http" "time" - core "github.com/ipfs/go-ipfs/core" + core "github.com/ipfs/kubo/core" "go.opencensus.io/stats/view" "go.opencensus.io/zpages" diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index fe37515d5..faa037b73 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/ipfs/go-ipfs/core" + "github.com/ipfs/kubo/core" inet "github.com/libp2p/go-libp2p-core/network" bhost "github.com/libp2p/go-libp2p/p2p/host/basic" diff --git a/gateway/core/corehttp/mutex_profile.go b/gateway/core/corehttp/mutex_profile.go index a8265326c..bbaad5b3a 100644 --- a/gateway/core/corehttp/mutex_profile.go +++ b/gateway/core/corehttp/mutex_profile.go @@ -6,7 +6,7 @@ import ( "runtime" "strconv" - core "github.com/ipfs/go-ipfs/core" + core "github.com/ipfs/kubo/core" ) // MutexFractionOption allows to set runtime.SetMutexProfileFraction via HTTP diff --git a/gateway/core/corehttp/option_test.go b/gateway/core/corehttp/option_test.go index 57f8d3b16..b401be9d5 100644 --- a/gateway/core/corehttp/option_test.go +++ b/gateway/core/corehttp/option_test.go @@ -7,7 +7,7 @@ import ( "net/http/httptest" "testing" - version "github.com/ipfs/go-ipfs" + version "github.com/ipfs/kubo" ) type testcasecheckversion struct { diff --git a/gateway/core/corehttp/p2p_proxy.go b/gateway/core/corehttp/p2p_proxy.go index 1dee5055a..ebf754100 100644 --- a/gateway/core/corehttp/p2p_proxy.go +++ b/gateway/core/corehttp/p2p_proxy.go @@ -8,7 +8,7 @@ import ( "net/url" "strings" - core "github.com/ipfs/go-ipfs/core" + core "github.com/ipfs/kubo/core" peer "github.com/libp2p/go-libp2p-core/peer" protocol "github.com/libp2p/go-libp2p-core/protocol" diff --git a/gateway/core/corehttp/p2p_proxy_test.go b/gateway/core/corehttp/p2p_proxy_test.go index 9f99463d9..48633a116 100644 --- a/gateway/core/corehttp/p2p_proxy_test.go +++ b/gateway/core/corehttp/p2p_proxy_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/ipfs/go-ipfs/thirdparty/assert" + "github.com/ipfs/kubo/thirdparty/assert" protocol "github.com/libp2p/go-libp2p-core/protocol" ) diff --git a/gateway/core/corehttp/redirect.go b/gateway/core/corehttp/redirect.go index e7b961e60..5af596bd6 100644 --- a/gateway/core/corehttp/redirect.go +++ b/gateway/core/corehttp/redirect.go @@ -4,7 +4,7 @@ import ( "net" "net/http" - core "github.com/ipfs/go-ipfs/core" + core "github.com/ipfs/kubo/core" ) func RedirectOption(path string, redirect string) ServeOption { From 65a77e8db3f67166b4d55499c021e4c04301178b Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 6 Jul 2022 20:16:02 +0200 Subject: [PATCH 633/674] fix(cmds): use kubo in CheckVersionOption Using both names to avoid dev problems during the transition from go-ipfs 0.13 to kubo 0.14 This commit was moved from ipfs/kubo@9dbc9dfeb2ed47b6aae4bb1d78c637df96fc53c4 --- gateway/core/corehttp/commands.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go index b433dfea7..c0ebf5506 100644 --- a/gateway/core/corehttp/commands.go +++ b/gateway/core/corehttp/commands.go @@ -85,7 +85,7 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { c.Headers[h] = v } } - c.Headers["Server"] = []string{"go-ipfs/" + version.CurrentVersionNumber} + c.Headers["Server"] = []string{"kubo/" + version.CurrentVersionNumber} } func addCORSDefaults(c *cmdsHttp.ServerConfig) { @@ -163,7 +163,7 @@ func CommandsROOption(cctx oldcmds.Context) ServeOption { return commandsOption(cctx, corecommands.RootRO, true) } -// CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/go-ipfs/` +// CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/kubo/` or `/go-ipfs/` func CheckVersionOption() ServeOption { daemonVersion := version.ApiVersion @@ -177,8 +177,8 @@ func CheckVersionOption() ServeOption { // backwards compatibility to previous version check if len(pth) >= 2 && pth[1] != "version" { clientVersion := r.UserAgent() - // skips check if client is not go-ipfs - if strings.Contains(clientVersion, "/go-ipfs/") && daemonVersion != clientVersion { + // skips check if client is not kubo (go-ipfs) + if (strings.Contains(clientVersion, "/go-ipfs/") || strings.Contains(clientVersion, "/kubo/")) && daemonVersion != clientVersion { http.Error(w, fmt.Sprintf("%s (%s != %s)", errAPIVersionMismatch, daemonVersion, clientVersion), http.StatusBadRequest) return } From dd6c933beab5e7c38c977b3f65cd37ef838b9213 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Wed, 29 Jun 2022 11:37:08 -0700 Subject: [PATCH 634/674] chore(deps): webui v2.15.1 https://github.com/ipfs/ipfs-webui/releases/tag/v2.15.1 This commit was moved from ipfs/kubo@fbd65e0c8d4e8f23db2434c7d0a5b857132475fa --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 0ed60f760..ae893fd09 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeiednzu62vskme5wpoj4bjjikeg3xovfpp4t7vxk5ty2jxdi4mv4bu" // v2.15.0 +const WebUIPath = "/ipfs/bafybeibozpulxtpv5nhfa2ue3dcjx23ndh3gwr5vwllk7ptoyfwnfjjr4q" // v2.15.1 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeiednzu62vskme5wpoj4bjjikeg3xovfpp4t7vxk5ty2jxdi4mv4bu", "/ipfs/bafybeihcyruaeza7uyjd6ugicbcrqumejf6uf353e5etdkhotqffwtguva", "/ipfs/bafybeiflkjt66aetfgcrgvv75izymd5kc47g6luepqmfq6zsf5w6ueth6y", "/ipfs/bafybeid26vjplsejg7t3nrh7mxmiaaxriebbm4xxrxxdunlk7o337m5sqq", From 77f4da3d8aaaa142cc8d8d3d41490243cb21061a Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 5 Jul 2022 15:39:44 +0200 Subject: [PATCH 635/674] feat(gw): Cache-Control: only-if-cached This implements the only-if-cached behavior documented in specs: https://github.com/ipfs/specs/blob/main/http-gateways/PATH_GATEWAY.md#cache-control-request-header https://github.com/ipfs/specs/blob/main/http-gateways/PATH_GATEWAY.md#only-if-cached-head-behavior This commit was moved from ipfs/kubo@58aaee00f80cf913174cf47f8c40367b70b8a5df --- gateway/core/corehttp/gateway.go | 6 +++- gateway/core/corehttp/gateway_handler.go | 46 ++++++++++++++++++++---- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index dcaf92f29..2d300183a 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -92,12 +92,16 @@ func GatewayOption(writable bool, paths ...string) ServeOption { "X-Ipfs-Roots", }, headers[ACEHeadersName]...)) - var gateway http.Handler = newGatewayHandler(GatewayConfig{ + var gateway http.Handler + gateway, err = newGatewayHandler(GatewayConfig{ Headers: headers, Writable: writable, PathPrefixes: cfg.Gateway.PathPrefixes, FastDirIndexThreshold: int(cfg.Gateway.FastDirIndexThreshold.WithDefault(100)), }, api) + if err != nil { + return nil, err + } gateway = otelhttp.NewHandler(gateway, "Gateway.Request") diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index e7c6df4a6..238473bbb 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -24,6 +24,7 @@ import ( path "github.com/ipfs/go-path" "github.com/ipfs/go-path/resolver" coreiface "github.com/ipfs/interface-go-ipfs-core" + options "github.com/ipfs/interface-go-ipfs-core/options" ipath "github.com/ipfs/interface-go-ipfs-core/path" routing "github.com/libp2p/go-libp2p-core/routing" prometheus "github.com/prometheus/client_golang/prometheus" @@ -66,8 +67,9 @@ type redirectTemplateData struct { // gatewayHandler is a HTTP handler that serves IPFS objects (accessible by default at /ipfs/) // (it serves requests like GET /ipfs/QmVRzPKPzNtSrEzBFm2UZfxmPAgnaLke4DMcerbsGGSaFe/link) type gatewayHandler struct { - config GatewayConfig - api coreiface.CoreAPI + config GatewayConfig + api coreiface.CoreAPI + offlineApi coreiface.CoreAPI // generic metrics firstContentBlockGetMetric *prometheus.HistogramVec @@ -211,10 +213,15 @@ func newGatewayHistogramMetric(name string, help string) *prometheus.HistogramVe return histogramMetric } -func newGatewayHandler(c GatewayConfig, api coreiface.CoreAPI) *gatewayHandler { +func newGatewayHandler(c GatewayConfig, api coreiface.CoreAPI) (*gatewayHandler, error) { + offlineApi, err := api.WithOptions(options.Api.Offline(true)) + if err != nil { + return nil, err + } i := &gatewayHandler{ - config: c, - api: api, + config: c, + api: api, + offlineApi: offlineApi, // Improved Metrics // ---------------------------- // Time till the first content block (bar in /ipfs/cid/foo/bar) @@ -255,7 +262,7 @@ func newGatewayHandler(c GatewayConfig, api coreiface.CoreAPI) *gatewayHandler { "The time to receive the first UnixFS node on a GET from the gateway.", ), } - return i + return i, nil } func parseIpfsPath(p string) (cid.Cid, string, error) { @@ -360,6 +367,11 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } contentPath := ipath.New(r.URL.Path) + + if requestHandled := i.handleOnlyIfCached(w, r, contentPath, logger); requestHandled { + return + } + if requestHandled := handleSuperfluousNamespace(w, r, contentPath); requestHandled { return } @@ -956,6 +968,28 @@ func debugStr(path string) string { return q } +// Detect 'Cache-Control: only-if-cached' in request and return data if it is already in the local datastore. +// https://github.com/ipfs/specs/blob/main/http-gateways/PATH_GATEWAY.md#cache-control-request-header +func (i *gatewayHandler) handleOnlyIfCached(w http.ResponseWriter, r *http.Request, contentPath ipath.Path, logger *zap.SugaredLogger) (requestHandled bool) { + if r.Header.Get("Cache-Control") == "only-if-cached" { + _, err := i.offlineApi.Block().Stat(r.Context(), contentPath) + if err != nil { + if r.Method == http.MethodHead { + w.WriteHeader(http.StatusPreconditionFailed) + return true + } + errMsg := fmt.Sprintf("%q not in local datastore", contentPath.String()) + http.Error(w, errMsg, http.StatusPreconditionFailed) + return true + } + if r.Method == http.MethodHead { + w.WriteHeader(http.StatusOK) + return true + } + } + return false +} + func handleUnsupportedHeaders(r *http.Request) (err *requestError) { // X-Ipfs-Gateway-Prefix was removed (https://github.com/ipfs/kubo/issues/7702) // TODO: remove this after go-ipfs 0.13 ships From a4632a65a2a1cf97b5802baede96a240cf590df0 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 18 Jul 2022 23:41:55 +0200 Subject: [PATCH 636/674] fix(gw): no backlink when listing root dir Closes #9071 This commit was moved from ipfs/kubo@a6687744c703c5c020f4c004ca73f024c3bae4f7 --- gateway/core/corehttp/gateway_handler_unixfs_dir.go | 6 ++++-- gateway/core/corehttp/gateway_test.go | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index 30e1b5ec7..4b8b7bc1f 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -152,11 +152,13 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit // don't go further up than /ipfs/$hash/ pathSplit := path.SplitList(contentPath.String()) switch { - // keep backlink + // skip backlink when listing a content root case len(pathSplit) == 3: // url: /ipfs/$hash + backLink = "" - // keep backlink + // skip backlink when listing a content root case len(pathSplit) == 4 && pathSplit[3] == "": // url: /ipfs/$hash/ + backLink = "" // add the correct link depending on whether the path ends with a slash default: diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 5f7cf0cb5..5ac27341d 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -529,8 +529,8 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !matchPathOrBreadcrumbs(s, "/") { t.Fatalf("expected a path in directory listing") } - if !strings.Contains(s, "") { - t.Fatalf("expected backlink in directory listing") + if strings.Contains(s, "") { + t.Fatalf("expected no backlink in directory listing of the root CID") } if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") From 8478dbccbebad2305226fa531b7cb7081985ff89 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 21 Jul 2022 03:41:41 +0200 Subject: [PATCH 637/674] fix(gw): cache-control of index.html websites This fixes a regression introduced in 0.13.0, where websites hosted via index.html placed in UnixFS directory were always returned with Cache-Control: public, max-age=29030400, immutable even when loaded from mutable /ipns/ contentPath. This commit was moved from ipfs/kubo@e832cc2c1db13ee93e5907380a7ea7af9c2a45d4 --- gateway/core/corehttp/gateway_handler_unixfs_dir.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index 4b8b7bc1f..9ba904475 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -42,7 +42,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit originalUrlPath := requestURI.Path // Check if directory has index.html, if so, serveFile - idxPath := ipath.Join(resolvedPath, "index.html") + idxPath := ipath.Join(contentPath, "index.html") idx, err := i.api.Unixfs().Get(ctx, idxPath) switch err.(type) { case nil: From 6b88d07cd743eebffb15ebcd351f4d690861b9de Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 21 Jul 2022 03:41:41 +0200 Subject: [PATCH 638/674] fix(gw): cache-control of index.html websites This fixes a regression introduced in 0.13.0, where websites hosted via index.html placed in UnixFS directory were always returned with Cache-Control: public, max-age=29030400, immutable even when loaded from mutable /ipns/ contentPath. (cherry picked from commit 8478dbccbebad2305226fa531b7cb7081985ff89) This commit was moved from ipfs/kubo@84c3f101fdb5b0a9d79999feaa5f44c710b3e938 --- gateway/core/corehttp/gateway_handler_unixfs_dir.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index 30e1b5ec7..83397b1af 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -42,7 +42,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit originalUrlPath := requestURI.Path // Check if directory has index.html, if so, serveFile - idxPath := ipath.Join(resolvedPath, "index.html") + idxPath := ipath.Join(contentPath, "index.html") idx, err := i.api.Unixfs().Get(ctx, idxPath) switch err.(type) { case nil: From c92ba64ba85adb6caf206c83b0b2a142bde486df Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Thu, 30 Jun 2022 10:12:16 +0100 Subject: [PATCH 639/674] feat: make corehttp a reusable component This commit was moved from ipfs/kubo@f4d87419ce702ac127943d43a1844e55b6fdab52 --- gateway/core/corehttp/gateway.go | 107 ++++++++++++++--------- gateway/core/corehttp/gateway_handler.go | 18 ++-- 2 files changed, 77 insertions(+), 48 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 2d300183a..b559d9cb9 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -1,18 +1,20 @@ package corehttp import ( + "context" "fmt" "net" "net/http" "sort" + coreiface "github.com/ipfs/interface-go-ipfs-core" + options "github.com/ipfs/interface-go-ipfs-core/options" + path "github.com/ipfs/interface-go-ipfs-core/path" version "github.com/ipfs/kubo" core "github.com/ipfs/kubo/core" coreapi "github.com/ipfs/kubo/core/coreapi" - "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" - - options "github.com/ipfs/interface-go-ipfs-core/options" id "github.com/libp2p/go-libp2p/p2p/protocol/identify" + "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" ) type GatewayConfig struct { @@ -22,6 +24,21 @@ type GatewayConfig struct { FastDirIndexThreshold int } +// NodeAPI defines the minimal set of API services required by a gateway handler +type NodeAPI interface { + // Unixfs returns an implementation of Unixfs API + Unixfs() coreiface.UnixfsAPI + + // Block returns an implementation of Block API + Block() coreiface.BlockAPI + + // Dag returns an implementation of Dag API + Dag() coreiface.APIDagService + + // ResolvePath resolves the path using Unixfs resolver + ResolvePath(context.Context, path.Path) (path.Resolved, error) +} + // A helper function to clean up a set of headers: // 1. Canonicalizes. // 2. Deduplicates. @@ -59,49 +76,22 @@ func GatewayOption(writable bool, paths ...string) ServeOption { headers[http.CanonicalHeaderKey(h)] = v } - // Hard-coded headers. - const ACAHeadersName = "Access-Control-Allow-Headers" - const ACEHeadersName = "Access-Control-Expose-Headers" - const ACAOriginName = "Access-Control-Allow-Origin" - const ACAMethodsName = "Access-Control-Allow-Methods" - - if _, ok := headers[ACAOriginName]; !ok { - // Default to *all* - headers[ACAOriginName] = []string{"*"} + acheaders := AccessControlHeaders() + for k, v := range acheaders { + headers[k] = v } - if _, ok := headers[ACAMethodsName]; !ok { - // Default to GET - headers[ACAMethodsName] = []string{http.MethodGet} + + offlineApi, err := api.WithOptions(options.Api.Offline(true)) + if err != nil { + return nil, err } - headers[ACAHeadersName] = cleanHeaderSet( - append([]string{ - "Content-Type", - "User-Agent", - "Range", - "X-Requested-With", - }, headers[ACAHeadersName]...)) - - headers[ACEHeadersName] = cleanHeaderSet( - append([]string{ - "Content-Length", - "Content-Range", - "X-Chunked-Output", - "X-Stream-Output", - "X-Ipfs-Path", - "X-Ipfs-Roots", - }, headers[ACEHeadersName]...)) - - var gateway http.Handler - gateway, err = newGatewayHandler(GatewayConfig{ + gateway := NewGatewayHandler(GatewayConfig{ Headers: headers, Writable: writable, PathPrefixes: cfg.Gateway.PathPrefixes, FastDirIndexThreshold: int(cfg.Gateway.FastDirIndexThreshold.WithDefault(100)), - }, api) - if err != nil { - return nil, err - } + }, api, offlineApi) gateway = otelhttp.NewHandler(gateway, "Gateway.Request") @@ -112,6 +102,45 @@ func GatewayOption(writable bool, paths ...string) ServeOption { } } +func AccessControlHeaders() map[string][]string { + headers := make(map[string][]string) + + // Hard-coded headers. + const ACAHeadersName = "Access-Control-Allow-Headers" + const ACEHeadersName = "Access-Control-Expose-Headers" + const ACAOriginName = "Access-Control-Allow-Origin" + const ACAMethodsName = "Access-Control-Allow-Methods" + + if _, ok := headers[ACAOriginName]; !ok { + // Default to *all* + headers[ACAOriginName] = []string{"*"} + } + if _, ok := headers[ACAMethodsName]; !ok { + // Default to GET + headers[ACAMethodsName] = []string{http.MethodGet} + } + + headers[ACAHeadersName] = cleanHeaderSet( + append([]string{ + "Content-Type", + "User-Agent", + "Range", + "X-Requested-With", + }, headers[ACAHeadersName]...)) + + headers[ACEHeadersName] = cleanHeaderSet( + append([]string{ + "Content-Length", + "Content-Range", + "X-Chunked-Output", + "X-Stream-Output", + "X-Ipfs-Path", + "X-Ipfs-Roots", + }, headers[ACEHeadersName]...)) + + return headers +} + func VersionOption() ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 238473bbb..a6261c0ab 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -24,7 +24,6 @@ import ( path "github.com/ipfs/go-path" "github.com/ipfs/go-path/resolver" coreiface "github.com/ipfs/interface-go-ipfs-core" - options "github.com/ipfs/interface-go-ipfs-core/options" ipath "github.com/ipfs/interface-go-ipfs-core/path" routing "github.com/libp2p/go-libp2p-core/routing" prometheus "github.com/prometheus/client_golang/prometheus" @@ -68,8 +67,8 @@ type redirectTemplateData struct { // (it serves requests like GET /ipfs/QmVRzPKPzNtSrEzBFm2UZfxmPAgnaLke4DMcerbsGGSaFe/link) type gatewayHandler struct { config GatewayConfig - api coreiface.CoreAPI - offlineApi coreiface.CoreAPI + api NodeAPI + offlineApi NodeAPI // generic metrics firstContentBlockGetMetric *prometheus.HistogramVec @@ -213,11 +212,12 @@ func newGatewayHistogramMetric(name string, help string) *prometheus.HistogramVe return histogramMetric } -func newGatewayHandler(c GatewayConfig, api coreiface.CoreAPI) (*gatewayHandler, error) { - offlineApi, err := api.WithOptions(options.Api.Offline(true)) - if err != nil { - return nil, err - } +// NewGatewayHandler returns an http.Handler that can act as a gateway to IPFS content +func NewGatewayHandler(c GatewayConfig, api NodeAPI, offlineApi NodeAPI) http.Handler { + return newGatewayHandler(c, api, offlineApi) +} + +func newGatewayHandler(c GatewayConfig, api NodeAPI, offlineApi NodeAPI) *gatewayHandler { i := &gatewayHandler{ config: c, api: api, @@ -262,7 +262,7 @@ func newGatewayHandler(c GatewayConfig, api coreiface.CoreAPI) (*gatewayHandler, "The time to receive the first UnixFS node on a GET from the gateway.", ), } - return i, nil + return i } func parseIpfsPath(p string) (cid.Cid, string, error) { From 7693baa9214cfacc5b46f5dafa811669234283f9 Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Fri, 1 Jul 2022 09:01:48 +0100 Subject: [PATCH 640/674] Change AccessControlHeaders funtion to modify an existing set of headers This commit was moved from ipfs/kubo@2ece5556f0c773bdc0ba6aa8dfa8a6bf00a2cba5 --- gateway/core/corehttp/gateway.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index b559d9cb9..775961bf0 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -76,10 +76,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { headers[http.CanonicalHeaderKey(h)] = v } - acheaders := AccessControlHeaders() - for k, v := range acheaders { - headers[k] = v - } + AddAccessControlHeaders(headers) offlineApi, err := api.WithOptions(options.Api.Offline(true)) if err != nil { @@ -102,9 +99,16 @@ func GatewayOption(writable bool, paths ...string) ServeOption { } } -func AccessControlHeaders() map[string][]string { - headers := make(map[string][]string) - +// AddAccessControlHeaders adds default headers used for controlling +// cross-origin requests. This function adds several values to the +// Access-Control-Allow-Headers and Access-Control-Expose-Headers entries. +// If the Access-Control-Allow-Origin entry is missing a value of '*' is +// added, indicating that browsers should allow requesting code from any +// origin to access the resource. +// If the Access-Control-Allow-Methods entry is missing a value of 'GET' is +// added, indicating that browsers may use the GET method when issuing cross +// origin requests. +func AddAccessControlHeaders(headers map[string][]string) { // Hard-coded headers. const ACAHeadersName = "Access-Control-Allow-Headers" const ACEHeadersName = "Access-Control-Expose-Headers" @@ -137,8 +141,6 @@ func AccessControlHeaders() map[string][]string { "X-Ipfs-Path", "X-Ipfs-Roots", }, headers[ACEHeadersName]...)) - - return headers } func VersionOption() ServeOption { From 974dfcb0f230cad8d8964bd9e4632ffc3170b556 Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Thu, 21 Jul 2022 15:14:52 +0100 Subject: [PATCH 641/674] Clarify offlineApi argument This commit was moved from ipfs/kubo@f8cdd96c2a85bc0ccaad70f9a0f26c85e728566a --- gateway/core/corehttp/gateway_handler.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index a6261c0ab..46618e1af 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -213,6 +213,7 @@ func newGatewayHistogramMetric(name string, help string) *prometheus.HistogramVe } // NewGatewayHandler returns an http.Handler that can act as a gateway to IPFS content +// offlineApi is a version of the API that should not make network requests for missing data func NewGatewayHandler(c GatewayConfig, api NodeAPI, offlineApi NodeAPI) http.Handler { return newGatewayHandler(c, api, offlineApi) } From a53a3ee99eb794b659aebb9f4cbc89eb94aff2fa Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 19 Jul 2022 01:17:37 +0200 Subject: [PATCH 642/674] fix(gw): ensure dir URLs have trailing slash This fixes a regression around directory listing and index.html hosting. Seems that during one of recent refactors code changed and we no longer check for trailing slash in HTTP request path, but look at content path instead. This cleans this up and also ensures dir behavior is the same for both index.html hosting and dir-index-html (generated listing). It also adds more tests so we catch any future regressions. This commit was moved from ipfs/kubo@3182986151d7ccaa110dd894d6fcba0ab77382f3 --- .../corehttp/gateway_handler_unixfs_dir.go | 30 ++++++++++--------- gateway/core/corehttp/gateway_test.go | 16 +++++----- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index 9ba904475..a6ab7cb55 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -41,28 +41,30 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit } originalUrlPath := requestURI.Path - // Check if directory has index.html, if so, serveFile - idxPath := ipath.Join(contentPath, "index.html") - idx, err := i.api.Unixfs().Get(ctx, idxPath) - switch err.(type) { - case nil: - cpath := contentPath.String() - dirwithoutslash := cpath[len(cpath)-1] != '/' + // Ensure directory paths end with '/' + if originalUrlPath[len(originalUrlPath)-1] != '/' { + // don't redirect to trailing slash if it's go get + // https://github.com/ipfs/kubo/pull/3963 goget := r.URL.Query().Get("go-get") == "1" - if dirwithoutslash && !goget { - // See comment above where originalUrlPath is declared. + if !goget { suffix := "/" + // preserve query parameters if r.URL.RawQuery != "" { - // preserve query parameters suffix = suffix + "?" + r.URL.RawQuery } - + // /ipfs/cid/foo?bar must be redirected to /ipfs/cid/foo/?bar redirectURL := originalUrlPath + suffix - logger.Debugw("serving index.html file", "to", redirectURL, "status", http.StatusFound, "path", idxPath) - http.Redirect(w, r, redirectURL, http.StatusFound) + logger.Debugw("directory location moved permanently", "status", http.StatusMovedPermanently) + http.Redirect(w, r, redirectURL, http.StatusMovedPermanently) return } + } + // Check if directory has index.html, if so, serveFile + idxPath := ipath.Join(contentPath, "index.html") + idx, err := i.api.Unixfs().Get(ctx, idxPath) + switch err.(type) { + case nil: f, ok := idx.(files.File) if !ok { internalWebError(w, files.ErrNotReader) @@ -163,7 +165,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit // add the correct link depending on whether the path ends with a slash default: if strings.HasSuffix(backLink, "/") { - backLink += "./.." + backLink += ".." } else { backLink += "/.." } diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 5ac27341d..b6b504907 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -380,9 +380,9 @@ func TestIPNSHostnameRedirect(t *testing.T) { t.Fatal(err) } - // expect 302 redirect to same path, but with trailing slash - if res.StatusCode != 302 { - t.Errorf("status is %d, expected 302", res.StatusCode) + // expect 301 redirect to same path, but with trailing slash + if res.StatusCode != 301 { + t.Errorf("status is %d, expected 301", res.StatusCode) } hdr := res.Header["Location"] if len(hdr) < 1 { @@ -403,9 +403,9 @@ func TestIPNSHostnameRedirect(t *testing.T) { t.Fatal(err) } - // expect 302 redirect to same path, but with prefix and trailing slash - if res.StatusCode != 302 { - t.Errorf("status is %d, expected 302", res.StatusCode) + // expect 301 redirect to same path, but with prefix and trailing slash + if res.StatusCode != 301 { + t.Errorf("status is %d, expected 301", res.StatusCode) } hdr = res.Header["Location"] if len(hdr) < 1 { @@ -492,7 +492,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !matchPathOrBreadcrumbs(s, "/ipns/example.net/foo? #<'") { t.Fatalf("expected a path in directory listing") } - if !strings.Contains(s, "") { + if !strings.Contains(s, "") { t.Fatalf("expected backlink in directory listing") } if !strings.Contains(s, "") { @@ -566,7 +566,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !matchPathOrBreadcrumbs(s, "/ipns/example.net/foo? #<'/bar") { t.Fatalf("expected a path in directory listing") } - if !strings.Contains(s, "") { + if !strings.Contains(s, "") { t.Fatalf("expected backlink in directory listing") } if !strings.Contains(s, "") { From 37bc760d96264a46c949587a2c3c7c414fa15011 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 19 Jul 2022 22:04:25 +0200 Subject: [PATCH 643/674] fix(gw): 404 when a valid DAG is missing link This commit was moved from ipfs/kubo@7992025254c70cda1b5fd084b7a8a28b1f06958f --- gateway/core/corehttp/gateway_handler.go | 6 ++++-- gateway/core/corehttp/gateway_handler_unixfs.go | 2 +- gateway/core/corehttp/gateway_test.go | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 238473bbb..2a7ee155f 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -19,6 +19,7 @@ import ( cid "github.com/ipfs/go-cid" files "github.com/ipfs/go-ipfs-files" + ipld "github.com/ipfs/go-ipld-format" dag "github.com/ipfs/go-merkledag" mfs "github.com/ipfs/go-mfs" path "github.com/ipfs/go-path" @@ -389,8 +390,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request logger.Debugw("serve pretty 404 if present") return } - - webError(w, "ipfs resolve -r "+debugStr(contentPath.String()), err, http.StatusNotFound) + webError(w, "ipfs resolve -r "+debugStr(contentPath.String()), err, http.StatusBadRequest) return } @@ -782,6 +782,8 @@ func webError(w http.ResponseWriter, message string, err error, defaultCode int) webErrorWithCode(w, message, err, http.StatusNotFound) } else if err == routing.ErrNotFound { webErrorWithCode(w, message, err, http.StatusNotFound) + } else if ipld.IsNotFound(err) { + webErrorWithCode(w, message, err, http.StatusNotFound) } else if err == context.DeadlineExceeded { webErrorWithCode(w, message, err, http.StatusRequestTimeout) } else { diff --git a/gateway/core/corehttp/gateway_handler_unixfs.go b/gateway/core/corehttp/gateway_handler_unixfs.go index 0aec83a8b..75d51d93a 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs.go +++ b/gateway/core/corehttp/gateway_handler_unixfs.go @@ -22,7 +22,7 @@ func (i *gatewayHandler) serveUnixFS(ctx context.Context, w http.ResponseWriter, // Handling UnixFS dr, err := i.api.Unixfs().Get(ctx, resolvedPath) if err != nil { - webError(w, "ipfs cat "+html.EscapeString(contentPath.String()), err, http.StatusNotFound) + webError(w, "ipfs cat "+html.EscapeString(contentPath.String()), err, http.StatusBadRequest) return } defer dr.Close() diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index b6b504907..18fe6ce17 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -235,8 +235,8 @@ func TestGatewayGet(t *testing.T) { {"127.0.0.1:8080", "/", http.StatusNotFound, "404 page not found\n"}, {"127.0.0.1:8080", "/" + k.Cid().String(), http.StatusNotFound, "404 page not found\n"}, {"127.0.0.1:8080", k.String(), http.StatusOK, "fnord"}, - {"127.0.0.1:8080", "/ipns/nxdomain.example.com", http.StatusNotFound, "ipfs resolve -r /ipns/nxdomain.example.com: " + namesys.ErrResolveFailed.Error() + "\n"}, - {"127.0.0.1:8080", "/ipns/%0D%0A%0D%0Ahello", http.StatusNotFound, "ipfs resolve -r /ipns/\\r\\n\\r\\nhello: " + namesys.ErrResolveFailed.Error() + "\n"}, + {"127.0.0.1:8080", "/ipns/nxdomain.example.com", http.StatusBadRequest, "ipfs resolve -r /ipns/nxdomain.example.com: " + namesys.ErrResolveFailed.Error() + "\n"}, + {"127.0.0.1:8080", "/ipns/%0D%0A%0D%0Ahello", http.StatusBadRequest, "ipfs resolve -r /ipns/\\r\\n\\r\\nhello: " + namesys.ErrResolveFailed.Error() + "\n"}, {"127.0.0.1:8080", "/ipns/example.com", http.StatusOK, "fnord"}, {"example.com", "/", http.StatusOK, "fnord"}, @@ -244,8 +244,8 @@ func TestGatewayGet(t *testing.T) { {"double.example.com", "/", http.StatusOK, "fnord"}, {"triple.example.com", "/", http.StatusOK, "fnord"}, {"working.example.com", k.String(), http.StatusNotFound, "ipfs resolve -r /ipns/working.example.com" + k.String() + ": no link named \"ipfs\" under " + k.Cid().String() + "\n"}, - {"broken.example.com", "/", http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com/: " + namesys.ErrResolveFailed.Error() + "\n"}, - {"broken.example.com", k.String(), http.StatusNotFound, "ipfs resolve -r /ipns/broken.example.com" + k.String() + ": " + namesys.ErrResolveFailed.Error() + "\n"}, + {"broken.example.com", "/", http.StatusBadRequest, "ipfs resolve -r /ipns/broken.example.com/: " + namesys.ErrResolveFailed.Error() + "\n"}, + {"broken.example.com", k.String(), http.StatusBadRequest, "ipfs resolve -r /ipns/broken.example.com" + k.String() + ": " + namesys.ErrResolveFailed.Error() + "\n"}, // This test case ensures we don't treat the TLD as a file extension. {"example.man", "/", http.StatusOK, "fnord"}, } { From ca977433dd999a9183a1e3f0edc13b5a6d5a68b4 Mon Sep 17 00:00:00 2001 From: Seungbae Yu Date: Sat, 6 Aug 2022 01:01:10 +0900 Subject: [PATCH 644/674] docs: replace `docs.ipfs.io` with `docs.ipfs.tech` (#9158) * docs: fix redirecting URL in README.md * all: replace `docs.ipfs.io` with `docs.ipfs.tech` * apply suggestions from code review Co-authored-by: Marcin Rataj This commit was moved from ipfs/kubo@cb280cbf16d60a68621a883c56ba3f984907128e --- gateway/core/corehttp/hostname_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index c2aa9b757..21810196a 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -91,7 +91,7 @@ func TestToDNSLinkFQDN(t *testing.T) { out string }{ {"singlelabel", "singlelabel"}, - {"docs-ipfs-io", "docs.ipfs.io"}, + {"docs-ipfs-tech", "docs.ipfs.tech"}, {"dnslink-long--name-example-com", "dnslink.long-name.example.com"}, } { out := toDNSLinkFQDN(test.in) From 5b7d96e05cb47cdf6af36d658900fd3284046564 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 12 Aug 2022 23:03:48 +0200 Subject: [PATCH 645/674] chore: switch to dist.ipfs.tech Part of https://github.com/protocol/bifrost-infra/issues/2018 ensures the domain used for fetching migrations is not impacted by ipfs.io being blocked at DNS level by some ISPs. This commit was moved from ipfs/kubo@837f6ee92b6ee00e7c7e364084fa93959073c8c7 --- gateway/core/corehttp/hostname.go | 2 +- gateway/core/corehttp/hostname_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 658eb34d4..4d648d294 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -324,7 +324,7 @@ func isKnownHostname(hostname string, knownGateways gatewayHosts) (gw *config.Ga func knownSubdomainDetails(hostname string, knownGateways gatewayHosts) (gw *config.GatewaySpec, gwHostname, ns, rootID string, ok bool) { labels := strings.Split(hostname, ".") // Look for FQDN of a known gateway hostname. - // Example: given "dist.ipfs.io.ipns.dweb.link": + // Example: given "dist.ipfs.tech.ipns.dweb.link": // 1. Lookup "link" TLD in knownGateways: negative // 2. Lookup "dweb.link" in knownGateways: positive // diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index 21810196a..60b537239 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -261,7 +261,7 @@ func TestKnownSubdomainDetails(t *testing.T) { // dnslink in subdomain {"en.wikipedia-on-ipfs.org.ipns.localhost:8080", gwLocalhost, "localhost:8080", "ipns", "en.wikipedia-on-ipfs.org", true}, {"en.wikipedia-on-ipfs.org.ipns.localhost", gwLocalhost, "localhost", "ipns", "en.wikipedia-on-ipfs.org", true}, - {"dist.ipfs.io.ipns.localhost:8080", gwLocalhost, "localhost:8080", "ipns", "dist.ipfs.io", true}, + {"dist.ipfs.tech.ipns.localhost:8080", gwLocalhost, "localhost:8080", "ipns", "dist.ipfs.tech", true}, {"en.wikipedia-on-ipfs.org.ipns.dweb.link", gwDweb, "dweb.link", "ipns", "en.wikipedia-on-ipfs.org", true}, // edge case check: public gateway under long TLD (see: https://publicsuffix.org) {"foo.dweb.ipfs.pvt.k12.ma.us", nil, "", "", "", false}, From bb0912a183b8bfa874caecf02c2881bbb38da0c7 Mon Sep 17 00:00:00 2001 From: Marco Munizaga Date: Fri, 12 Aug 2022 08:31:19 -0700 Subject: [PATCH 646/674] Move register exporter to metrics file This commit was moved from ipfs/kubo@27b046f98e0de1ffb5dc46696e3895f7c98edbcc --- gateway/core/corehttp/metrics.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index 4e2b81d13..da2d576a2 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -51,6 +51,30 @@ func MetricsOpenCensusCollectionOption() ServeOption { } } +// MetricsOpenCensusDefaultPrometheusRegistry registers the default prometheus +// registry as an exporter to OpenCensus metrics. This means that OpenCensus +// metrics will show up in the prometheus metrics endpoint +func MetricsOpenCensusDefaultPrometheusRegistry() ServeOption { + return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { + log.Info("Init OpenCensus with default prometheus registry") + + pe, err := ocprom.NewExporter(ocprom.Options{ + Registry: prometheus.DefaultRegisterer.(*prometheus.Registry), + OnError: func(err error) { + log.Errorw("OC default registry ERROR", "error", err) + }, + }) + if err != nil { + return nil, err + } + + // register prometheus with opencensus + view.RegisterExporter(pe) + + return mux, nil + } +} + // MetricsCollectionOption adds collection of net/http-related metrics. func MetricsCollectionOption(handlerName string) ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { From b4f4ce8baeb686a9ed56e2c5b627459a2dc8ccae Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 22 Apr 2022 01:05:30 +0200 Subject: [PATCH 647/674] chore: remove Gateway.PathPrefixes Closes #7702 This commit was moved from ipfs/kubo@c9693edbc5099f5536da3169dffb52164ab6f850 --- gateway/core/corehttp/gateway.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 775961bf0..d403919eb 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -20,7 +20,6 @@ import ( type GatewayConfig struct { Headers map[string][]string Writable bool - PathPrefixes []string FastDirIndexThreshold int } @@ -86,7 +85,6 @@ func GatewayOption(writable bool, paths ...string) ServeOption { gateway := NewGatewayHandler(GatewayConfig{ Headers: headers, Writable: writable, - PathPrefixes: cfg.Gateway.PathPrefixes, FastDirIndexThreshold: int(cfg.Gateway.FastDirIndexThreshold.WithDefault(100)), }, api, offlineApi) From a434e7c34e10f8414fce969990bf3fd19e68c59d Mon Sep 17 00:00:00 2001 From: Jorropo Date: Wed, 31 Aug 2022 17:58:41 +0200 Subject: [PATCH 648/674] fix(gw): send 200 for empty files Fixes #9238 This commit was moved from ipfs/kubo@df222053856d3967ff0b4d6bc513bdb66ceedd6f --- gateway/core/corehttp/gateway_handler_unixfs_file.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gateway/core/corehttp/gateway_handler_unixfs_file.go b/gateway/core/corehttp/gateway_handler_unixfs_file.go index 5053558dc..9463be1ac 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_file.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_file.go @@ -37,6 +37,15 @@ func (i *gatewayHandler) serveFile(ctx context.Context, w http.ResponseWriter, r return } + if size == 0 { + // We override null files to 200 to avoid issues with fragment caching reverse proxies. + // Also whatever you are asking for, it's cheaper to just give you the complete file (nothing). + // TODO: remove this if clause once https://github.com/golang/go/issues/54794 is fixed in two latest releases of go + w.Header().Set("Content-Type", "text/plain") + w.WriteHeader(http.StatusOK) + return + } + // Lazy seeker enables efficient range-requests and HTTP HEAD responses content := &lazySeeker{ size: size, From c1b76cdca01e5ff63834d365783027c5f9296744 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Mon, 29 Aug 2022 13:55:00 +0200 Subject: [PATCH 649/674] chore: bump go-libp2p v0.22.0 & go1.18&go1.19 Fixes: #9225 This commit was moved from ipfs/kubo@196887cbe5fbcd41243c1dfb0db681a1cc2914ff --- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/hostname.go | 2 +- gateway/core/corehttp/metrics_test.go | 2 +- gateway/core/corehttp/p2p_proxy.go | 4 ++-- gateway/core/corehttp/p2p_proxy_test.go | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index a6dbdcb20..ca3867001 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -26,7 +26,7 @@ import ( "github.com/ipfs/go-path/resolver" coreiface "github.com/ipfs/interface-go-ipfs-core" ipath "github.com/ipfs/interface-go-ipfs-core/path" - routing "github.com/libp2p/go-libp2p-core/routing" + routing "github.com/libp2p/go-libp2p/core/routing" prometheus "github.com/prometheus/client_golang/prometheus" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 18fe6ce17..380a3ae0c 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -25,7 +25,7 @@ import ( nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" ipath "github.com/ipfs/interface-go-ipfs-core/path" config "github.com/ipfs/kubo/config" - ci "github.com/libp2p/go-libp2p-core/crypto" + ci "github.com/libp2p/go-libp2p/core/crypto" id "github.com/libp2p/go-libp2p/p2p/protocol/identify" ) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 4d648d294..3d022fc5a 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -13,7 +13,7 @@ import ( namesys "github.com/ipfs/go-namesys" core "github.com/ipfs/kubo/core" coreapi "github.com/ipfs/kubo/core/coreapi" - "github.com/libp2p/go-libp2p-core/peer" + "github.com/libp2p/go-libp2p/core/peer" dns "github.com/miekg/dns" mbase "github.com/multiformats/go-multibase" diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go index faa037b73..267d4ae97 100644 --- a/gateway/core/corehttp/metrics_test.go +++ b/gateway/core/corehttp/metrics_test.go @@ -7,7 +7,7 @@ import ( "github.com/ipfs/kubo/core" - inet "github.com/libp2p/go-libp2p-core/network" + inet "github.com/libp2p/go-libp2p/core/network" bhost "github.com/libp2p/go-libp2p/p2p/host/basic" swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing" ) diff --git a/gateway/core/corehttp/p2p_proxy.go b/gateway/core/corehttp/p2p_proxy.go index ebf754100..44c20c2ad 100644 --- a/gateway/core/corehttp/p2p_proxy.go +++ b/gateway/core/corehttp/p2p_proxy.go @@ -9,10 +9,10 @@ import ( "strings" core "github.com/ipfs/kubo/core" - peer "github.com/libp2p/go-libp2p-core/peer" + peer "github.com/libp2p/go-libp2p/core/peer" - protocol "github.com/libp2p/go-libp2p-core/protocol" p2phttp "github.com/libp2p/go-libp2p-http" + protocol "github.com/libp2p/go-libp2p/core/protocol" ) // P2PProxyOption is an endpoint for proxying a HTTP request to another ipfs peer diff --git a/gateway/core/corehttp/p2p_proxy_test.go b/gateway/core/corehttp/p2p_proxy_test.go index 48633a116..969bc31e1 100644 --- a/gateway/core/corehttp/p2p_proxy_test.go +++ b/gateway/core/corehttp/p2p_proxy_test.go @@ -7,7 +7,7 @@ import ( "github.com/ipfs/kubo/thirdparty/assert" - protocol "github.com/libp2p/go-libp2p-core/protocol" + protocol "github.com/libp2p/go-libp2p/core/protocol" ) type TestCase struct { From ced2e3aafdb0d3a8b3fd3de732822ccefe4b0bf0 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Mon, 12 Sep 2022 06:40:46 -0700 Subject: [PATCH 650/674] feat: ipfs-webui v2.18.0 (#9262) https://github.com/ipfs/ipfs-webui/releases/tag/v2.18.0 This commit was moved from ipfs/kubo@007295d34d4ae9ab0269d585183d020ec365472e --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index ae893fd09..1f1ab1254 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeibozpulxtpv5nhfa2ue3dcjx23ndh3gwr5vwllk7ptoyfwnfjjr4q" // v2.15.1 +const WebUIPath = "/ipfs/bafybeidb5eryh72zajiokdggzo7yct2d6hhcflncji5im2y5w26uuygdsm" // v2.18.0 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeibozpulxtpv5nhfa2ue3dcjx23ndh3gwr5vwllk7ptoyfwnfjjr4q", "/ipfs/bafybeiednzu62vskme5wpoj4bjjikeg3xovfpp4t7vxk5ty2jxdi4mv4bu", "/ipfs/bafybeihcyruaeza7uyjd6ugicbcrqumejf6uf353e5etdkhotqffwtguva", "/ipfs/bafybeiflkjt66aetfgcrgvv75izymd5kc47g6luepqmfq6zsf5w6ueth6y", From 93a90fac04d5b018129ae643ec221575bccf8dc2 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 13 Sep 2022 14:12:26 -0700 Subject: [PATCH 651/674] feat: ipfs-webui v2.18.1 This commit was moved from ipfs/kubo@87dc8de461f28c851502fc8fe3a405f0445444dd --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 1f1ab1254..4952dc16f 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeidb5eryh72zajiokdggzo7yct2d6hhcflncji5im2y5w26uuygdsm" // v2.18.0 +const WebUIPath = "/ipfs/bafybeiageaoxg6d7npaof6eyzqbwvbubyler7bq44hayik2hvqcggg7d2y" // v2.18.1 // this is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeidb5eryh72zajiokdggzo7yct2d6hhcflncji5im2y5w26uuygdsm", "/ipfs/bafybeibozpulxtpv5nhfa2ue3dcjx23ndh3gwr5vwllk7ptoyfwnfjjr4q", "/ipfs/bafybeiednzu62vskme5wpoj4bjjikeg3xovfpp4t7vxk5ty2jxdi4mv4bu", "/ipfs/bafybeihcyruaeza7uyjd6ugicbcrqumejf6uf353e5etdkhotqffwtguva", From 146e8d09529a66f3390814b298d1e417cd9b66fc Mon Sep 17 00:00:00 2001 From: Jorropo Date: Tue, 20 Sep 2022 23:04:52 +0200 Subject: [PATCH 652/674] chore: bump go-libp2p v0.23.1 This does not include any WebTransport config code in Kubo, this will be done later in an other PR. This commit was moved from ipfs/kubo@74aaf37cec10510506f2f619b3b1003c823a1d24 --- gateway/core/corehttp/gateway.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index d403919eb..b9fff49b5 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -146,7 +146,7 @@ func VersionOption() ServeOption { mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Commit: %s\n", version.CurrentCommit) fmt.Fprintf(w, "Client Version: %s\n", version.GetUserAgentVersion()) - fmt.Fprintf(w, "Protocol Version: %s\n", id.LibP2PVersion) + fmt.Fprintf(w, "Protocol Version: %s\n", id.DefaultProtocolVersion) }) return mux, nil } diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 380a3ae0c..f4dda631e 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -652,7 +652,7 @@ func TestVersion(t *testing.T) { t.Fatalf("response doesn't contain client version:\n%s", s) } - if !strings.Contains(s, "Protocol Version: "+id.LibP2PVersion) { + if !strings.Contains(s, "Protocol Version: "+id.DefaultProtocolVersion) { t.Fatalf("response doesn't contain protocol version:\n%s", s) } } From 59b3312f61cf08989219c70f0219fa5ba82915cd Mon Sep 17 00:00:00 2001 From: Justin Johnson Date: Fri, 23 Sep 2022 11:44:19 -0500 Subject: [PATCH 653/674] feat(gateway): _redirects file support (#8890) https://github.com/ipfs/kubo/pull/8890 https://github.com/ipfs/specs/pull/290 This commit was moved from ipfs/kubo@bcaacdd6c3168392c2e2673e5a35e8a8387edbbc --- gateway/core/corehttp/gateway_handler.go | 136 +++------ .../gateway_handler_unixfs__redirects.go | 287 ++++++++++++++++++ .../corehttp/gateway_handler_unixfs_dir.go | 2 +- gateway/core/corehttp/hostname.go | 7 +- 4 files changed, 340 insertions(+), 92 deletions(-) create mode 100644 gateway/core/corehttp/gateway_handler_unixfs__redirects.go diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index ca3867001..585ca89cb 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -13,7 +13,6 @@ import ( gopath "path" "regexp" "runtime/debug" - "strconv" "strings" "time" @@ -378,23 +377,6 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } - // Resolve path to the final DAG node for the ETag - resolvedPath, err := i.api.ResolvePath(r.Context(), contentPath) - switch err { - case nil: - case coreiface.ErrOffline: - webError(w, "ipfs resolve -r "+debugStr(contentPath.String()), err, http.StatusServiceUnavailable) - return - default: - // if Accept is text/html, see if ipfs-404.html is present - if i.servePretty404IfPresent(w, r, contentPath) { - logger.Debugw("serve pretty 404 if present") - return - } - webError(w, "ipfs resolve -r "+debugStr(contentPath.String()), err, http.StatusBadRequest) - return - } - // Detect when explicit Accept header or ?format parameter are present responseFormat, formatParams, err := customResponseFormat(r) if err != nil { @@ -402,6 +384,11 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request return } trace.SpanFromContext(r.Context()).SetAttributes(attribute.String("ResponseFormat", responseFormat)) + + resolvedPath, contentPath, ok := i.handlePathResolution(w, r, responseFormat, contentPath, logger) + if !ok { + return + } trace.SpanFromContext(r.Context()).SetAttributes(attribute.String("ResolvedPath", resolvedPath.String())) // Detect when If-None-Match HTTP header allows returning HTTP 304 Not Modified @@ -450,36 +437,6 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } } -func (i *gatewayHandler) servePretty404IfPresent(w http.ResponseWriter, r *http.Request, contentPath ipath.Path) bool { - resolved404Path, ctype, err := i.searchUpTreeFor404(r, contentPath) - if err != nil { - return false - } - - dr, err := i.api.Unixfs().Get(r.Context(), resolved404Path) - if err != nil { - return false - } - defer dr.Close() - - f, ok := dr.(files.File) - if !ok { - return false - } - - size, err := f.Size() - if err != nil { - return false - } - - log.Debugw("using pretty 404 file", "path", contentPath) - w.Header().Set("Content-Type", ctype) - w.Header().Set("Content-Length", strconv.FormatInt(size, 10)) - w.WriteHeader(http.StatusNotFound) - _, err = io.CopyN(w, f, size) - return err == nil -} - func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { p, err := i.api.Unixfs().Add(r.Context(), files.NewReaderFile(r.Body)) if err != nil { @@ -920,55 +877,56 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string] return "", nil, nil } -func (i *gatewayHandler) searchUpTreeFor404(r *http.Request, contentPath ipath.Path) (ipath.Resolved, string, error) { - filename404, ctype, err := preferred404Filename(r.Header.Values("Accept")) - if err != nil { - return nil, "", err +// returns unquoted path with all special characters revealed as \u codes +func debugStr(path string) string { + q := fmt.Sprintf("%+q", path) + if len(q) >= 3 { + q = q[1 : len(q)-1] } + return q +} - pathComponents := strings.Split(contentPath.String(), "/") - - for idx := len(pathComponents); idx >= 3; idx-- { - pretty404 := gopath.Join(append(pathComponents[0:idx], filename404)...) - parsed404Path := ipath.New("/" + pretty404) - if parsed404Path.IsValid() != nil { - break - } - resolvedPath, err := i.api.ResolvePath(r.Context(), parsed404Path) - if err != nil { - continue - } - return resolvedPath, ctype, nil - } +// Resolve the provided contentPath including any special handling related to +// the requested responseFormat. Returned ok flag indicates if gateway handler +// should continue processing the request. +func (i *gatewayHandler) handlePathResolution(w http.ResponseWriter, r *http.Request, responseFormat string, contentPath ipath.Path, logger *zap.SugaredLogger) (resolvedPath ipath.Resolved, newContentPath ipath.Path, ok bool) { + // Attempt to resolve the provided path. + resolvedPath, err := i.api.ResolvePath(r.Context(), contentPath) - return nil, "", fmt.Errorf("no pretty 404 in any parent folder") -} + switch err { + case nil: + return resolvedPath, contentPath, true + case coreiface.ErrOffline: + webError(w, "ipfs resolve -r "+debugStr(contentPath.String()), err, http.StatusServiceUnavailable) + return nil, nil, false + default: + // The path can't be resolved. + if isUnixfsResponseFormat(responseFormat) { + // If we have origin isolation (subdomain gw, DNSLink website), + // and response type is UnixFS (default for website hosting) + // check for presence of _redirects file and apply rules defined there. + // See: https://github.com/ipfs/specs/pull/290 + if hasOriginIsolation(r) { + resolvedPath, newContentPath, ok, hadMatchingRule := i.serveRedirectsIfPresent(w, r, resolvedPath, contentPath, logger) + if hadMatchingRule { + logger.Debugw("applied a rule from _redirects file") + return resolvedPath, newContentPath, ok + } + } -func preferred404Filename(acceptHeaders []string) (string, string, error) { - // If we ever want to offer a 404 file for a different content type - // then this function will need to parse q weightings, but for now - // the presence of anything matching HTML is enough. - for _, acceptHeader := range acceptHeaders { - accepted := strings.Split(acceptHeader, ",") - for _, spec := range accepted { - contentType := strings.SplitN(spec, ";", 1)[0] - switch contentType { - case "*/*", "text/*", "text/html": - return "ipfs-404.html", "text/html", nil + // if Accept is text/html, see if ipfs-404.html is present + // This logic isn't documented and will likely be removed at some point. + // Any 404 logic in _redirects above will have already run by this time, so it's really an extra fall back + if i.serveLegacy404IfPresent(w, r, contentPath) { + logger.Debugw("served legacy 404") + return nil, nil, false } } - } - return "", "", fmt.Errorf("there is no 404 file for the requested content types") -} - -// returns unquoted path with all special characters revealed as \u codes -func debugStr(path string) string { - q := fmt.Sprintf("%+q", path) - if len(q) >= 3 { - q = q[1 : len(q)-1] + // Note: webError will replace http.StatusBadRequest with StatusNotFound if necessary + webError(w, "ipfs resolve -r "+debugStr(contentPath.String()), err, http.StatusBadRequest) + return nil, nil, false } - return q } // Detect 'Cache-Control: only-if-cached' in request and return data if it is already in the local datastore. diff --git a/gateway/core/corehttp/gateway_handler_unixfs__redirects.go b/gateway/core/corehttp/gateway_handler_unixfs__redirects.go new file mode 100644 index 000000000..81cf05731 --- /dev/null +++ b/gateway/core/corehttp/gateway_handler_unixfs__redirects.go @@ -0,0 +1,287 @@ +package corehttp + +import ( + "fmt" + "io" + "net/http" + gopath "path" + "strconv" + "strings" + + files "github.com/ipfs/go-ipfs-files" + redirects "github.com/ipfs/go-ipfs-redirects-file" + ipath "github.com/ipfs/interface-go-ipfs-core/path" + "go.uber.org/zap" +) + +// Resolving a UnixFS path involves determining if the provided `path.Path` exists and returning the `path.Resolved` +// corresponding to that path. For UnixFS, path resolution is more involved. +// +// When a path under requested CID does not exist, Gateway will check if a `_redirects` file exists +// underneath the root CID of the path, and apply rules defined there. +// See sepcification introduced in: https://github.com/ipfs/specs/pull/290 +// +// Scenario 1: +// If a path exists, we always return the `path.Resolved` corresponding to that path, regardless of the existence of a `_redirects` file. +// +// Scenario 2: +// If a path does not exist, usually we should return a `nil` resolution path and an error indicating that the path +// doesn't exist. However, a `_redirects` file may exist and contain a redirect rule that redirects that path to a different path. +// We need to evaluate the rule and perform the redirect if present. +// +// Scenario 3: +// Another possibility is that the path corresponds to a rewrite rule (i.e. a rule with a status of 200). +// In this case, we don't perform a redirect, but do need to return a `path.Resolved` and `path.Path` corresponding to +// the rewrite destination path. +// +// Note that for security reasons, redirect rules are only processed when the request has origin isolation. +// See https://github.com/ipfs/specs/pull/290 for more information. +func (i *gatewayHandler) serveRedirectsIfPresent(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, logger *zap.SugaredLogger) (newResolvedPath ipath.Resolved, newContentPath ipath.Path, continueProcessing bool, hadMatchingRule bool) { + redirectsFile := i.getRedirectsFile(r, contentPath, logger) + if redirectsFile != nil { + redirectRules, err := i.getRedirectRules(r, redirectsFile) + if err != nil { + internalWebError(w, err) + return nil, nil, false, true + } + + redirected, newPath, err := i.handleRedirectsFileRules(w, r, contentPath, redirectRules) + if err != nil { + err = fmt.Errorf("trouble processing _redirects file at %q: %w", redirectsFile.String(), err) + internalWebError(w, err) + return nil, nil, false, true + } + + if redirected { + return nil, nil, false, true + } + + // 200 is treated as a rewrite, so update the path and continue + if newPath != "" { + // Reassign contentPath and resolvedPath since the URL was rewritten + contentPath = ipath.New(newPath) + resolvedPath, err = i.api.ResolvePath(r.Context(), contentPath) + if err != nil { + internalWebError(w, err) + return nil, nil, false, true + } + + return resolvedPath, contentPath, true, true + } + } + // No matching rule, paths remain the same, continue regular processing + return resolvedPath, contentPath, true, false +} + +func (i *gatewayHandler) handleRedirectsFileRules(w http.ResponseWriter, r *http.Request, contentPath ipath.Path, redirectRules []redirects.Rule) (redirected bool, newContentPath string, err error) { + // Attempt to match a rule to the URL path, and perform the corresponding redirect or rewrite + pathParts := strings.Split(contentPath.String(), "/") + if len(pathParts) > 3 { + // All paths should start with /ipfs/cid/, so get the path after that + urlPath := "/" + strings.Join(pathParts[3:], "/") + rootPath := strings.Join(pathParts[:3], "/") + // Trim off the trailing / + urlPath = strings.TrimSuffix(urlPath, "/") + + for _, rule := range redirectRules { + // Error right away if the rule is invalid + if !rule.MatchAndExpandPlaceholders(urlPath) { + continue + } + + // We have a match! + + // Rewrite + if rule.Status == 200 { + // Prepend the rootPath + toPath := rootPath + rule.To + return false, toPath, nil + } + + // Or 4xx + if rule.Status == 404 || rule.Status == 410 || rule.Status == 451 { + toPath := rootPath + rule.To + content4xxPath := ipath.New(toPath) + err := i.serve4xx(w, r, content4xxPath, rule.Status) + return true, toPath, err + } + + // Or redirect + if rule.Status >= 301 && rule.Status <= 308 { + http.Redirect(w, r, rule.To, rule.Status) + return true, "", nil + } + } + } + + // No redirects matched + return false, "", nil +} + +func (i *gatewayHandler) getRedirectRules(r *http.Request, redirectsFilePath ipath.Resolved) ([]redirects.Rule, error) { + // Convert the path into a file node + node, err := i.api.Unixfs().Get(r.Context(), redirectsFilePath) + if err != nil { + return nil, fmt.Errorf("could not get _redirects: %w", err) + } + defer node.Close() + + // Convert the node into a file + f, ok := node.(files.File) + if !ok { + return nil, fmt.Errorf("could not parse _redirects: %w", err) + } + + // Parse redirect rules from file + redirectRules, err := redirects.Parse(f) + if err != nil { + return nil, fmt.Errorf("could not parse _redirects: %w", err) + } + + return redirectRules, nil +} + +// Returns a resolved path to the _redirects file located in the root CID path of the requested path +func (i *gatewayHandler) getRedirectsFile(r *http.Request, contentPath ipath.Path, logger *zap.SugaredLogger) ipath.Resolved { + // contentPath is the full ipfs path to the requested resource, + // regardless of whether path or subdomain resolution is used. + rootPath := getRootPath(contentPath) + + // Check for _redirects file. + // Any path resolution failures are ignored and we just assume there's no _redirects file. + // Note that ignoring these errors also ensures that the use of the empty CID (bafkqaaa) in tests doesn't fail. + path := ipath.Join(rootPath, "_redirects") + resolvedPath, err := i.api.ResolvePath(r.Context(), path) + if err != nil { + return nil + } + return resolvedPath +} + +// Returns the root CID Path for the given path +func getRootPath(path ipath.Path) ipath.Path { + parts := strings.Split(path.String(), "/") + return ipath.New(gopath.Join("/", path.Namespace(), parts[2])) +} + +func (i *gatewayHandler) serve4xx(w http.ResponseWriter, r *http.Request, content4xxPath ipath.Path, status int) error { + resolved4xxPath, err := i.api.ResolvePath(r.Context(), content4xxPath) + if err != nil { + return err + } + + node, err := i.api.Unixfs().Get(r.Context(), resolved4xxPath) + if err != nil { + return err + } + defer node.Close() + + f, ok := node.(files.File) + if !ok { + return fmt.Errorf("could not convert node for %d page to file", status) + } + + size, err := f.Size() + if err != nil { + return fmt.Errorf("could not get size of %d page", status) + } + + log.Debugf("using _redirects: custom %d file at %q", status, content4xxPath) + w.Header().Set("Content-Type", "text/html") + w.Header().Set("Content-Length", strconv.FormatInt(size, 10)) + addCacheControlHeaders(w, r, content4xxPath, resolved4xxPath.Cid()) + w.WriteHeader(status) + _, err = io.CopyN(w, f, size) + return err +} + +func hasOriginIsolation(r *http.Request) bool { + _, gw := r.Context().Value(requestContextKey("gw-hostname")).(string) + _, dnslink := r.Context().Value("dnslink-hostname").(string) + + if gw || dnslink { + return true + } + + return false +} + +func isUnixfsResponseFormat(responseFormat string) bool { + // The implicit response format is UnixFS + return responseFormat == "" +} + +// Deprecated: legacy ipfs-404.html files are superseded by _redirects file +// This is provided only for backward-compatibility, until websites migrate +// to 404s managed via _redirects file (https://github.com/ipfs/specs/pull/290) +func (i *gatewayHandler) serveLegacy404IfPresent(w http.ResponseWriter, r *http.Request, contentPath ipath.Path) bool { + resolved404Path, ctype, err := i.searchUpTreeFor404(r, contentPath) + if err != nil { + return false + } + + dr, err := i.api.Unixfs().Get(r.Context(), resolved404Path) + if err != nil { + return false + } + defer dr.Close() + + f, ok := dr.(files.File) + if !ok { + return false + } + + size, err := f.Size() + if err != nil { + return false + } + + log.Debugw("using pretty 404 file", "path", contentPath) + w.Header().Set("Content-Type", ctype) + w.Header().Set("Content-Length", strconv.FormatInt(size, 10)) + w.WriteHeader(http.StatusNotFound) + _, err = io.CopyN(w, f, size) + return err == nil +} + +func (i *gatewayHandler) searchUpTreeFor404(r *http.Request, contentPath ipath.Path) (ipath.Resolved, string, error) { + filename404, ctype, err := preferred404Filename(r.Header.Values("Accept")) + if err != nil { + return nil, "", err + } + + pathComponents := strings.Split(contentPath.String(), "/") + + for idx := len(pathComponents); idx >= 3; idx-- { + pretty404 := gopath.Join(append(pathComponents[0:idx], filename404)...) + parsed404Path := ipath.New("/" + pretty404) + if parsed404Path.IsValid() != nil { + break + } + resolvedPath, err := i.api.ResolvePath(r.Context(), parsed404Path) + if err != nil { + continue + } + return resolvedPath, ctype, nil + } + + return nil, "", fmt.Errorf("no pretty 404 in any parent folder") +} + +func preferred404Filename(acceptHeaders []string) (string, string, error) { + // If we ever want to offer a 404 file for a different content type + // then this function will need to parse q weightings, but for now + // the presence of anything matching HTML is enough. + for _, acceptHeader := range acceptHeaders { + accepted := strings.Split(acceptHeader, ",") + for _, spec := range accepted { + contentType := strings.SplitN(spec, ";", 1)[0] + switch contentType { + case "*/*", "text/*", "text/html": + return "ipfs-404.html", "text/html", nil + } + } + } + + return "", "", fmt.Errorf("there is no 404 file for the requested content types") +} diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index a6ab7cb55..511066f43 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -185,7 +185,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit var gwURL string // Get gateway hostname and build gateway URL. - if h, ok := r.Context().Value("gw-hostname").(string); ok { + if h, ok := r.Context().Value(requestContextKey("gw-hostname")).(string); ok { gwURL = "//" + h } else { gwURL = "" diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 3d022fc5a..5445740e6 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -221,7 +221,8 @@ func HostnameOption() ServeOption { if !cfg.Gateway.NoDNSLink && isDNSLinkName(r.Context(), coreAPI, host) { // rewrite path and handle as DNSLink r.URL.Path = "/ipns/" + stripPort(host) + r.URL.Path - childMux.ServeHTTP(w, withHostnameContext(r, host)) + ctx := context.WithValue(r.Context(), requestContextKey("dnslink-hostname"), host) + childMux.ServeHTTP(w, withHostnameContext(r.WithContext(ctx), host)) return } @@ -242,6 +243,8 @@ type wildcardHost struct { spec *config.GatewaySpec } +type requestContextKey string + // Extends request context to include hostname of a canonical gateway root // (subdomain root or dnslink fqdn) func withHostnameContext(r *http.Request, hostname string) *http.Request { @@ -250,7 +253,7 @@ func withHostnameContext(r *http.Request, hostname string) *http.Request { // Host header, subdomain gateways have more comples rules (knownSubdomainDetails) // More: https://github.com/ipfs/dir-index-html/issues/42 // nolint: staticcheck // non-backward compatible change - ctx := context.WithValue(r.Context(), "gw-hostname", hostname) + ctx := context.WithValue(r.Context(), requestContextKey("gw-hostname"), hostname) return r.WithContext(ctx) } From 637ed0f60509a8f91c525c0fcffa926035cb890b Mon Sep 17 00:00:00 2001 From: Gus Eggert Date: Thu, 6 Oct 2022 10:18:40 -0400 Subject: [PATCH 654/674] ci: add stylecheck to golangci-lint (#9334) This commit was moved from ipfs/kubo@e550d9e4761ea394357c413c02ade142c0dea88c --- gateway/core/corehttp/gateway.go | 4 ++-- gateway/core/corehttp/gateway_handler.go | 16 ++++++++-------- .../core/corehttp/gateway_handler_unixfs_dir.go | 10 +++++----- gateway/core/corehttp/gateway_indexPage.go | 4 ++-- gateway/core/corehttp/lazyseek_test.go | 6 +++--- gateway/core/corehttp/metrics.go | 2 +- gateway/core/corehttp/p2p_proxy.go | 6 +++--- gateway/core/corehttp/redirect.go | 2 +- gateway/core/corehttp/webui.go | 2 +- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index b9fff49b5..0d0a234d9 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -77,7 +77,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { AddAccessControlHeaders(headers) - offlineApi, err := api.WithOptions(options.Api.Offline(true)) + offlineAPI, err := api.WithOptions(options.Api.Offline(true)) if err != nil { return nil, err } @@ -86,7 +86,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption { Headers: headers, Writable: writable, FastDirIndexThreshold: int(cfg.Gateway.FastDirIndexThreshold.WithDefault(100)), - }, api, offlineApi) + }, api, offlineAPI) gateway = otelhttp.NewHandler(gateway, "Gateway.Request") diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 585ca89cb..a96799f58 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -39,7 +39,7 @@ const ( ) var ( - onlyAscii = regexp.MustCompile("[[:^ascii:]]") + onlyASCII = regexp.MustCompile("[[:^ascii:]]") noModtime = time.Unix(0, 0) // disables Last-Modified header if passed as modtime ) @@ -68,7 +68,7 @@ type redirectTemplateData struct { type gatewayHandler struct { config GatewayConfig api NodeAPI - offlineApi NodeAPI + offlineAPI NodeAPI // generic metrics firstContentBlockGetMetric *prometheus.HistogramVec @@ -214,15 +214,15 @@ func newGatewayHistogramMetric(name string, help string) *prometheus.HistogramVe // NewGatewayHandler returns an http.Handler that can act as a gateway to IPFS content // offlineApi is a version of the API that should not make network requests for missing data -func NewGatewayHandler(c GatewayConfig, api NodeAPI, offlineApi NodeAPI) http.Handler { - return newGatewayHandler(c, api, offlineApi) +func NewGatewayHandler(c GatewayConfig, api NodeAPI, offlineAPI NodeAPI) http.Handler { + return newGatewayHandler(c, api, offlineAPI) } -func newGatewayHandler(c GatewayConfig, api NodeAPI, offlineApi NodeAPI) *gatewayHandler { +func newGatewayHandler(c GatewayConfig, api NodeAPI, offlineAPI NodeAPI) *gatewayHandler { i := &gatewayHandler{ config: c, api: api, - offlineApi: offlineApi, + offlineAPI: offlineAPI, // Improved Metrics // ---------------------------- // Time till the first content block (bar in /ipfs/cid/foo/bar) @@ -683,7 +683,7 @@ func addContentDispositionHeader(w http.ResponseWriter, r *http.Request, content // Set Content-Disposition to arbitrary filename and disposition func setContentDispositionHeader(w http.ResponseWriter, filename string, disposition string) { utf8Name := url.PathEscape(filename) - asciiName := url.PathEscape(onlyAscii.ReplaceAllLiteralString(filename, "_")) + asciiName := url.PathEscape(onlyASCII.ReplaceAllLiteralString(filename, "_")) w.Header().Set("Content-Disposition", fmt.Sprintf("%s; filename=\"%s\"; filename*=UTF-8''%s", disposition, asciiName, utf8Name)) } @@ -933,7 +933,7 @@ func (i *gatewayHandler) handlePathResolution(w http.ResponseWriter, r *http.Req // https://github.com/ipfs/specs/blob/main/http-gateways/PATH_GATEWAY.md#cache-control-request-header func (i *gatewayHandler) handleOnlyIfCached(w http.ResponseWriter, r *http.Request, contentPath ipath.Path, logger *zap.SugaredLogger) (requestHandled bool) { if r.Header.Get("Cache-Control") == "only-if-cached" { - _, err := i.offlineApi.Block().Stat(r.Context(), contentPath) + _, err := i.offlineAPI.Block().Stat(r.Context(), contentPath) if err != nil { if r.Method == http.MethodHead { w.WriteHeader(http.StatusPreconditionFailed) diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index 511066f43..1c803b13b 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -39,10 +39,10 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit webError(w, "failed to parse request path", err, http.StatusInternalServerError) return } - originalUrlPath := requestURI.Path + originalURLPath := requestURI.Path // Ensure directory paths end with '/' - if originalUrlPath[len(originalUrlPath)-1] != '/' { + if originalURLPath[len(originalURLPath)-1] != '/' { // don't redirect to trailing slash if it's go get // https://github.com/ipfs/kubo/pull/3963 goget := r.URL.Query().Get("go-get") == "1" @@ -53,7 +53,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit suffix = suffix + "?" + r.URL.RawQuery } // /ipfs/cid/foo?bar must be redirected to /ipfs/cid/foo/?bar - redirectURL := originalUrlPath + suffix + redirectURL := originalURLPath + suffix logger.Debugw("directory location moved permanently", "status", http.StatusMovedPermanently) http.Redirect(w, r, redirectURL, http.StatusMovedPermanently) return @@ -125,7 +125,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit di := directoryItem{ Size: "", // no size because we did not fetch child nodes Name: link.Name, - Path: gopath.Join(originalUrlPath, link.Name), + Path: gopath.Join(originalURLPath, link.Name), Hash: hash, ShortHash: shortHash(hash), } @@ -149,7 +149,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit // construct the correct back link // https://github.com/ipfs/kubo/issues/1365 - var backLink string = originalUrlPath + backLink := originalURLPath // don't go further up than /ipfs/$hash/ pathSplit := path.SplitList(contentPath.String()) diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index 1168d6556..19e444da3 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -117,8 +117,8 @@ func init() { // custom template-escaping function to escape a full path, including '#' and '?' urlEscape := func(rawUrl string) string { - pathUrl := url.URL{Path: rawUrl} - return pathUrl.String() + pathURL := url.URL{Path: rawUrl} + return pathURL.String() } // Directory listing template diff --git a/gateway/core/corehttp/lazyseek_test.go b/gateway/core/corehttp/lazyseek_test.go index 2733acafb..49aca0a0e 100644 --- a/gateway/core/corehttp/lazyseek_test.go +++ b/gateway/core/corehttp/lazyseek_test.go @@ -11,14 +11,14 @@ type badSeeker struct { io.ReadSeeker } -var badSeekErr = fmt.Errorf("I'm a bad seeker") +var errBadSeek = fmt.Errorf("bad seeker") func (bs badSeeker) Seek(offset int64, whence int) (int64, error) { off, err := bs.ReadSeeker.Seek(0, io.SeekCurrent) if err != nil { panic(err) } - return off, badSeekErr + return off, errBadSeek } func TestLazySeekerError(t *testing.T) { @@ -73,7 +73,7 @@ func TestLazySeekerError(t *testing.T) { if err == nil { t.Fatalf("expected an error, got output %s", string(b)) } - if err != badSeekErr { + if err != errBadSeek { t.Fatalf("expected a bad seek error, got %s", err) } if len(b) != 0 { diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go index da2d576a2..e26be1ca9 100644 --- a/gateway/core/corehttp/metrics.go +++ b/gateway/core/corehttp/metrics.go @@ -164,7 +164,7 @@ type IpfsNodeCollector struct { Node *core.IpfsNode } -func (_ IpfsNodeCollector) Describe(ch chan<- *prometheus.Desc) { +func (IpfsNodeCollector) Describe(ch chan<- *prometheus.Desc) { ch <- peersTotalMetric } diff --git a/gateway/core/corehttp/p2p_proxy.go b/gateway/core/corehttp/p2p_proxy.go index 44c20c2ad..e239f47cd 100644 --- a/gateway/core/corehttp/p2p_proxy.go +++ b/gateway/core/corehttp/p2p_proxy.go @@ -58,11 +58,11 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { split := strings.SplitN(path, "/", 5) if len(split) < 5 { - return nil, fmt.Errorf("Invalid request path '%s'", path) + return nil, fmt.Errorf("invalid request path '%s'", path) } if _, err := peer.Decode(split[2]); err != nil { - return nil, fmt.Errorf("Invalid request path '%s'", path) + return nil, fmt.Errorf("invalid request path '%s'", path) } if split[3] == "http" { @@ -71,7 +71,7 @@ func parseRequest(request *http.Request) (*proxyRequest, error) { split = strings.SplitN(path, "/", 7) if len(split) < 7 || split[3] != "x" || split[5] != "http" { - return nil, fmt.Errorf("Invalid request path '%s'", path) + return nil, fmt.Errorf("invalid request path '%s'", path) } return &proxyRequest{split[2], protocol.ID("/x/" + split[4] + "/http"), split[6]}, nil diff --git a/gateway/core/corehttp/redirect.go b/gateway/core/corehttp/redirect.go index 5af596bd6..bcd536d23 100644 --- a/gateway/core/corehttp/redirect.go +++ b/gateway/core/corehttp/redirect.go @@ -24,5 +24,5 @@ type redirectHandler struct { } func (i *redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, i.path, 302) + http.Redirect(w, r, i.path, http.StatusFound) } diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 4952dc16f..98e69cd5c 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -3,7 +3,7 @@ package corehttp // TODO: move to IPNS const WebUIPath = "/ipfs/bafybeiageaoxg6d7npaof6eyzqbwvbubyler7bq44hayik2hvqcggg7d2y" // v2.18.1 -// this is a list of all past webUI paths. +// WebUIPaths is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, "/ipfs/bafybeidb5eryh72zajiokdggzo7yct2d6hhcflncji5im2y5w26uuygdsm", From 84f396d22ae8e2e4858745d371440d814168ed1b Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 11 Oct 2022 15:45:43 +0200 Subject: [PATCH 655/674] fix: add InlineDNSLink flag to PublicGateways config (#9328) https://github.com/ipfs/kubo/issues/9243 Co-authored-by: Marcin Rataj This commit was moved from ipfs/kubo@4291d6b2369b8f1dc3cd5c191cd4f3b099df1560 --- gateway/core/corehttp/hostname.go | 14 ++++++---- gateway/core/corehttp/hostname_test.go | 36 ++++++++++++++------------ 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 5445740e6..39e857aad 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -84,7 +84,8 @@ func HostnameOption() ServeOption { if gw.UseSubdomains { // Yes, redirect if applicable // Example: dweb.link/ipfs/{cid} → {cid}.ipfs.dweb.link - newURL, err := toSubdomainURL(host, r.URL.Path, r, coreAPI) + useInlinedDNSLink := gw.InlineDNSLink.WithDefault(config.DefaultInlineDNSLink) + newURL, err := toSubdomainURL(host, r.URL.Path, r, useInlinedDNSLink, coreAPI) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -132,6 +133,9 @@ func HostnameOption() ServeOption { // Assemble original path prefix. pathPrefix := "/" + ns + "/" + rootID + // Retrieve whether or not we should inline DNSLink. + useInlinedDNSLink := gw.InlineDNSLink.WithDefault(config.DefaultInlineDNSLink) + // Does this gateway _handle_ subdomains AND this path? if !(gw.UseSubdomains && hasPrefix(pathPrefix, gw.Paths...)) { // If not, resource does not exist, return 404 @@ -149,7 +153,7 @@ func HostnameOption() ServeOption { } if !strings.HasPrefix(r.Host, dnsCID) { dnsPrefix := "/" + ns + "/" + dnsCID - newURL, err := toSubdomainURL(gwHostname, dnsPrefix+r.URL.Path, r, coreAPI) + newURL, err := toSubdomainURL(gwHostname, dnsPrefix+r.URL.Path, r, useInlinedDNSLink, coreAPI) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -165,7 +169,7 @@ func HostnameOption() ServeOption { // Do we need to fix multicodec in PeerID represented as CIDv1? if isPeerIDNamespace(ns) { if rootCID.Type() != cid.Libp2pKey { - newURL, err := toSubdomainURL(gwHostname, pathPrefix+r.URL.Path, r, coreAPI) + newURL, err := toSubdomainURL(gwHostname, pathPrefix+r.URL.Path, r, useInlinedDNSLink, coreAPI) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -451,7 +455,7 @@ func toDNSLinkFQDN(dnsLabel string) (fqdn string) { } // Converts a hostname/path to a subdomain-based URL, if applicable. -func toSubdomainURL(hostname, path string, r *http.Request, ipfs iface.CoreAPI) (redirURL string, err error) { +func toSubdomainURL(hostname, path string, r *http.Request, inlineDNSLink bool, ipfs iface.CoreAPI) (redirURL string, err error) { var scheme, ns, rootID, rest string query := r.URL.RawQuery @@ -554,7 +558,7 @@ func toSubdomainURL(hostname, path string, r *http.Request, ipfs iface.CoreAPI) // can be loaded from a subdomain gateway with a wildcard TLS cert if // represented as a single DNS label: // https://my-v--long-example-com.ipns.dweb.link - if isHTTPS && ns == "ipns" && strings.Contains(rootID, ".") { + if (inlineDNSLink || isHTTPS) && ns == "ipns" && strings.Contains(rootID, ".") { if isDNSLinkName(r.Context(), ipfs, rootID) { // my.v-long.example.com → my-v--long-example-com dnsLabel, err := toDNSLinkDNSLabel(rootID) diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index 60b537239..6f0713528 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -36,35 +36,39 @@ func TestToSubdomainURL(t *testing.T) { for _, test := range []struct { // in: - request *http.Request - gwHostname string - path string + request *http.Request + gwHostname string + inlineDNSLink bool + path string // out: url string err error }{ // DNSLink - {httpRequest, "localhost", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost/", nil}, + {httpRequest, "localhost", false, "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost/", nil}, // Hostname with port - {httpRequest, "localhost:8080", "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost:8080/", nil}, + {httpRequest, "localhost:8080", false, "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost:8080/", nil}, // CIDv0 → CIDv1base32 - {httpRequest, "localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.localhost/", nil}, + {httpRequest, "localhost", false, "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.localhost/", nil}, // CIDv1 with long sha512 - {httpRequest, "localhost", "/ipfs/bafkrgqe3ohjcjplc6n4f3fwunlj6upltggn7xqujbsvnvyw764srszz4u4rshq6ztos4chl4plgg4ffyyxnayrtdi5oc4xb2332g645433aeg", "", errors.New("CID incompatible with DNS label length limit of 63: kf1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5oj")}, + {httpRequest, "localhost", false, "/ipfs/bafkrgqe3ohjcjplc6n4f3fwunlj6upltggn7xqujbsvnvyw764srszz4u4rshq6ztos4chl4plgg4ffyyxnayrtdi5oc4xb2332g645433aeg", "", errors.New("CID incompatible with DNS label length limit of 63: kf1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5oj")}, // PeerID as CIDv1 needs to have libp2p-key multicodec - {httpRequest, "localhost", "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", "http://k2k4r8n0flx3ra0y5dr8fmyvwbzy3eiztmtq6th694k5a3rznayp3e4o.ipns.localhost/", nil}, - {httpRequest, "localhost", "/ipns/bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "http://k2k4r8l9ja7hkzynavdqup76ou46tnvuaqegbd04a4o1mpbsey0meucb.ipns.localhost/", nil}, + {httpRequest, "localhost", false, "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", "http://k2k4r8n0flx3ra0y5dr8fmyvwbzy3eiztmtq6th694k5a3rznayp3e4o.ipns.localhost/", nil}, + {httpRequest, "localhost", false, "/ipns/bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "http://k2k4r8l9ja7hkzynavdqup76ou46tnvuaqegbd04a4o1mpbsey0meucb.ipns.localhost/", nil}, // PeerID: ed25519+identity multihash → CIDv1Base36 - {httpRequest, "localhost", "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://k51qzi5uqu5di608geewp3nqkg0bpujoasmka7ftkyxgcm3fh1aroup0gsdrna.ipns.localhost/", nil}, - {httpRequest, "sub.localhost", "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.sub.localhost/", nil}, + {httpRequest, "localhost", false, "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://k51qzi5uqu5di608geewp3nqkg0bpujoasmka7ftkyxgcm3fh1aroup0gsdrna.ipns.localhost/", nil}, + {httpRequest, "sub.localhost", false, "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.sub.localhost/", nil}, // HTTPS requires DNSLink name to fit in a single DNS label – see "Option C" from https://github.com/ipfs/in-web-browsers/issues/169 - {httpRequest, "dweb.link", "/ipns/dnslink.long-name.example.com", "http://dnslink.long-name.example.com.ipns.dweb.link/", nil}, - {httpsRequest, "dweb.link", "/ipns/dnslink.long-name.example.com", "https://dnslink-long--name-example-com.ipns.dweb.link/", nil}, - {httpsProxiedRequest, "dweb.link", "/ipns/dnslink.long-name.example.com", "https://dnslink-long--name-example-com.ipns.dweb.link/", nil}, + {httpRequest, "dweb.link", false, "/ipns/dnslink.long-name.example.com", "http://dnslink.long-name.example.com.ipns.dweb.link/", nil}, + {httpsRequest, "dweb.link", false, "/ipns/dnslink.long-name.example.com", "https://dnslink-long--name-example-com.ipns.dweb.link/", nil}, + {httpsProxiedRequest, "dweb.link", false, "/ipns/dnslink.long-name.example.com", "https://dnslink-long--name-example-com.ipns.dweb.link/", nil}, + // HTTP requests can also be converted to fit into a single DNS label - https://github.com/ipfs/kubo/issues/9243 + {httpRequest, "localhost", true, "/ipns/dnslink.long-name.example.com", "http://dnslink-long--name-example-com.ipns.localhost/", nil}, + {httpRequest, "dweb.link", true, "/ipns/dnslink.long-name.example.com", "http://dnslink-long--name-example-com.ipns.dweb.link/", nil}, } { - url, err := toSubdomainURL(test.gwHostname, test.path, test.request, coreAPI) + url, err := toSubdomainURL(test.gwHostname, test.path, test.request, test.inlineDNSLink, coreAPI) if url != test.url || !equalError(err, test.err) { - t.Errorf("(%s, %s) returned (%s, %v), expected (%s, %v)", test.gwHostname, test.path, url, err, test.url, test.err) + t.Errorf("(%s, %v, %s) returned (%s, %v), expected (%s, %v)", test.gwHostname, test.inlineDNSLink, test.path, url, err, test.url, test.err) } } } From e0100849cf30ee549547cea4a164facb15071761 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Mon, 3 Oct 2022 12:42:48 -0700 Subject: [PATCH 656/674] feat: webui@v2.19.0 This commit was moved from ipfs/kubo@396660956f55f0ed069247b8c914beca7387856e --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 98e69cd5c..75385a0d1 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeiageaoxg6d7npaof6eyzqbwvbubyler7bq44hayik2hvqcggg7d2y" // v2.18.1 +const WebUIPath = "/ipfs/bafybeiavrvt53fks6u32n5p2morgblcmck4bh4ymf4rrwu7ah5zsykmqqa" // v2.19.0 // WebUIPaths is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeiageaoxg6d7npaof6eyzqbwvbubyler7bq44hayik2hvqcggg7d2y", "/ipfs/bafybeidb5eryh72zajiokdggzo7yct2d6hhcflncji5im2y5w26uuygdsm", "/ipfs/bafybeibozpulxtpv5nhfa2ue3dcjx23ndh3gwr5vwllk7ptoyfwnfjjr4q", "/ipfs/bafybeiednzu62vskme5wpoj4bjjikeg3xovfpp4t7vxk5ty2jxdi4mv4bu", From 772fab3a74c6f6d6194b5958912bd6160a83000f Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 9 Nov 2022 19:20:33 +0100 Subject: [PATCH 657/674] feat(gateway): TAR response format (#9029) Implementation of IPIP-288 (https://github.com/ipfs/specs/pull/288) Co-authored-by: Marcin Rataj This commit was moved from ipfs/kubo@a210abd74364076404c18df1acbeed8bd6a5d6b7 --- gateway/core/corehttp/gateway_handler.go | 18 ++-- gateway/core/corehttp/gateway_handler_tar.go | 92 ++++++++++++++++++++ 2 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 gateway/core/corehttp/gateway_handler_tar.go diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index a96799f58..7f0f11885 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -430,6 +430,10 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request carVersion := formatParams["version"] i.serveCAR(r.Context(), w, r, resolvedPath, contentPath, carVersion, begin) return + case "application/x-tar": + logger.Debugw("serving tar file", "path", contentPath) + i.serveTAR(r.Context(), w, r, resolvedPath, contentPath, begin, logger) + return default: // catch-all for unsuported application/vnd.* err := fmt.Errorf("unsupported format %q", responseFormat) webError(w, "failed respond with requested content type", err, http.StatusBadRequest) @@ -842,9 +846,10 @@ func getEtag(r *http.Request, cid cid.Cid) string { responseFormat, _, err := customResponseFormat(r) if err == nil && responseFormat != "" { // application/vnd.ipld.foo → foo - f := responseFormat[strings.LastIndex(responseFormat, ".")+1:] - // Etag: "cid.foo" (gives us nice compression together with Content-Disposition in block (raw) and car responses) - suffix = `.` + f + suffix + // application/x-bar → x-bar + shortFormat := responseFormat[strings.LastIndexAny(responseFormat, "/.")+1:] + // Etag: "cid.shortFmt" (gives us nice compression together with Content-Disposition in block (raw) and car responses) + suffix = `.` + shortFormat + suffix } // TODO: include selector suffix when https://github.com/ipfs/kubo/issues/8769 lands return prefix + cid.String() + suffix @@ -859,14 +864,17 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string] return "application/vnd.ipld.raw", nil, nil case "car": return "application/vnd.ipld.car", nil, nil + case "tar": + return "application/x-tar", nil, nil } } // Browsers and other user agents will send Accept header with generic types like: // Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 - // We only care about explciit, vendor-specific content-types. + // We only care about explicit, vendor-specific content-types. for _, accept := range r.Header.Values("Accept") { // respond to the very first ipld content type - if strings.HasPrefix(accept, "application/vnd.ipld") { + if strings.HasPrefix(accept, "application/vnd.ipld") || + strings.HasPrefix(accept, "application/x-tar") { mediatype, params, err := mime.ParseMediaType(accept) if err != nil { return "", nil, err diff --git a/gateway/core/corehttp/gateway_handler_tar.go b/gateway/core/corehttp/gateway_handler_tar.go new file mode 100644 index 000000000..532d88757 --- /dev/null +++ b/gateway/core/corehttp/gateway_handler_tar.go @@ -0,0 +1,92 @@ +package corehttp + +import ( + "context" + "html" + "net/http" + "time" + + files "github.com/ipfs/go-ipfs-files" + ipath "github.com/ipfs/interface-go-ipfs-core/path" + "github.com/ipfs/kubo/tracing" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" + "go.uber.org/zap" +) + +var unixEpochTime = time.Unix(0, 0) + +func (i *gatewayHandler) serveTAR(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, logger *zap.SugaredLogger) { + ctx, span := tracing.Span(ctx, "Gateway", "ServeTAR", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) + defer span.End() + + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + // Get Unixfs file + file, err := i.api.Unixfs().Get(ctx, resolvedPath) + if err != nil { + webError(w, "ipfs cat "+html.EscapeString(contentPath.String()), err, http.StatusBadRequest) + return + } + defer file.Close() + + rootCid := resolvedPath.Cid() + + // Set Cache-Control and read optional Last-Modified time + modtime := addCacheControlHeaders(w, r, contentPath, rootCid) + + // Weak Etag W/ because we can't guarantee byte-for-byte identical + // responses, but still want to benefit from HTTP Caching. Two TAR + // responses for the same CID will be logically equivalent, + // but when TAR is streamed, then in theory, files and directories + // may arrive in different order (depends on TAR lib and filesystem/inodes). + etag := `W/` + getEtag(r, rootCid) + w.Header().Set("Etag", etag) + + // Finish early if Etag match + if r.Header.Get("If-None-Match") == etag { + w.WriteHeader(http.StatusNotModified) + return + } + + // Set Content-Disposition + var name string + if urlFilename := r.URL.Query().Get("filename"); urlFilename != "" { + name = urlFilename + } else { + name = rootCid.String() + ".tar" + } + setContentDispositionHeader(w, name, "attachment") + + // Construct the TAR writer + tarw, err := files.NewTarWriter(w) + if err != nil { + webError(w, "could not build tar writer", err, http.StatusInternalServerError) + return + } + defer tarw.Close() + + // Sets correct Last-Modified header. This code is borrowed from the standard + // library (net/http/server.go) as we cannot use serveFile without throwing the entire + // TAR into the memory first. + if !(modtime.IsZero() || modtime.Equal(unixEpochTime)) { + w.Header().Set("Last-Modified", modtime.UTC().Format(http.TimeFormat)) + } + + w.Header().Set("Content-Type", "application/x-tar") + w.Header().Set("X-Content-Type-Options", "nosniff") // no funny business in the browsers :^) + + // The TAR has a top-level directory (or file) named by the CID. + if err := tarw.WriteFile(file, rootCid.String()); err != nil { + w.Header().Set("X-Stream-Error", err.Error()) + // Trailer headers do not work in web browsers + // (see https://github.com/mdn/browser-compat-data/issues/14703) + // and we have limited options around error handling in browser contexts. + // To improve UX/DX, we finish response stream with error message, allowing client to + // (1) detect error by having corrupted TAR + // (2) be able to reason what went wrong by instecting the tail of TAR stream + _, _ = w.Write([]byte(err.Error())) + return + } +} From 9abf0810d0632b17bb9698d6f1897d90aa456345 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Thu, 10 Nov 2022 00:30:58 +0100 Subject: [PATCH 658/674] feat: ipfs-webui 2.20.0 https://github.com/ipfs/ipfs-webui/releases/tag/v2.20.0 This commit was moved from ipfs/kubo@72262a8e10f5b4285185890e679d52b29f350f63 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index 75385a0d1..c196c0eef 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeiavrvt53fks6u32n5p2morgblcmck4bh4ymf4rrwu7ah5zsykmqqa" // v2.19.0 +const WebUIPath = "/ipfs/bafybeibjbq3tmmy7wuihhhwvbladjsd3gx3kfjepxzkq6wylik6wc3whzy" // v2.20.0 // WebUIPaths is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeiavrvt53fks6u32n5p2morgblcmck4bh4ymf4rrwu7ah5zsykmqqa", "/ipfs/bafybeiageaoxg6d7npaof6eyzqbwvbubyler7bq44hayik2hvqcggg7d2y", "/ipfs/bafybeidb5eryh72zajiokdggzo7yct2d6hhcflncji5im2y5w26uuygdsm", "/ipfs/bafybeibozpulxtpv5nhfa2ue3dcjx23ndh3gwr5vwllk7ptoyfwnfjjr4q", From 79843b4f2a3fdabe6a1679e712b300d8d3953bd6 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 5 Dec 2022 20:22:26 +0100 Subject: [PATCH 659/674] feat(gateway): JSON and CBOR response formats (IPIP-328) (#9335) https://github.com/ipfs/kubo/pull/9335 https://github.com/ipfs/specs/pull/328 Co-authored-by: Marcin Rataj This commit was moved from ipfs/kubo@fdd19656c465f07ff6d7be653f5438d74a0c0c2f --- gateway/core/corehttp/gateway_handler.go | 30 +- .../core/corehttp/gateway_handler_codec.go | 258 ++++++++++++++++++ gateway/core/corehttp/gateway_test.go | 8 +- 3 files changed, 288 insertions(+), 8 deletions(-) create mode 100644 gateway/core/corehttp/gateway_handler_codec.go diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 7f0f11885..1222b17bc 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -26,6 +26,7 @@ import ( coreiface "github.com/ipfs/interface-go-ipfs-core" ipath "github.com/ipfs/interface-go-ipfs-core/path" routing "github.com/libp2p/go-libp2p/core/routing" + mc "github.com/multiformats/go-multicodec" prometheus "github.com/prometheus/client_golang/prometheus" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" @@ -417,9 +418,15 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // Support custom response formats passed via ?format or Accept HTTP header switch responseFormat { - case "": // The implicit response format is UnixFS - logger.Debugw("serving unixfs", "path", contentPath) - i.serveUnixFS(r.Context(), w, r, resolvedPath, contentPath, begin, logger) + case "": + switch resolvedPath.Cid().Prefix().Codec { + case uint64(mc.Json), uint64(mc.DagJson), uint64(mc.Cbor), uint64(mc.DagCbor): + logger.Debugw("serving codec", "path", contentPath) + i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat) + default: + logger.Debugw("serving unixfs", "path", contentPath) + i.serveUnixFS(r.Context(), w, r, resolvedPath, contentPath, begin, logger) + } return case "application/vnd.ipld.raw": logger.Debugw("serving raw block", "path", contentPath) @@ -434,6 +441,11 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request logger.Debugw("serving tar file", "path", contentPath) i.serveTAR(r.Context(), w, r, resolvedPath, contentPath, begin, logger) return + case "application/json", "application/vnd.ipld.dag-json", + "application/cbor", "application/vnd.ipld.dag-cbor": + logger.Debugw("serving codec", "path", contentPath) + i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat) + return default: // catch-all for unsuported application/vnd.* err := fmt.Errorf("unsupported format %q", responseFormat) webError(w, "failed respond with requested content type", err, http.StatusBadRequest) @@ -866,6 +878,14 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string] return "application/vnd.ipld.car", nil, nil case "tar": return "application/x-tar", nil, nil + case "dag-json": + return "application/vnd.ipld.dag-json", nil, nil + case "json": + return "application/json", nil, nil + case "dag-cbor": + return "application/vnd.ipld.dag-cbor", nil, nil + case "cbor": + return "application/cbor", nil, nil } } // Browsers and other user agents will send Accept header with generic types like: @@ -874,7 +894,9 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string] for _, accept := range r.Header.Values("Accept") { // respond to the very first ipld content type if strings.HasPrefix(accept, "application/vnd.ipld") || - strings.HasPrefix(accept, "application/x-tar") { + strings.HasPrefix(accept, "application/x-tar") || + strings.HasPrefix(accept, "application/json") || + strings.HasPrefix(accept, "application/cbor") { mediatype, params, err := mime.ParseMediaType(accept) if err != nil { return "", nil, err diff --git a/gateway/core/corehttp/gateway_handler_codec.go b/gateway/core/corehttp/gateway_handler_codec.go new file mode 100644 index 000000000..95a151c79 --- /dev/null +++ b/gateway/core/corehttp/gateway_handler_codec.go @@ -0,0 +1,258 @@ +package corehttp + +import ( + "bytes" + "context" + "fmt" + "html" + "io" + "net/http" + "strings" + "time" + + cid "github.com/ipfs/go-cid" + ipldlegacy "github.com/ipfs/go-ipld-legacy" + ipath "github.com/ipfs/interface-go-ipfs-core/path" + "github.com/ipfs/kubo/assets" + dih "github.com/ipfs/kubo/assets/dag-index-html" + "github.com/ipfs/kubo/tracing" + "github.com/ipld/go-ipld-prime" + "github.com/ipld/go-ipld-prime/multicodec" + mc "github.com/multiformats/go-multicodec" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" +) + +// codecToContentType maps the supported IPLD codecs to the HTTP Content +// Type they should have. +var codecToContentType = map[uint64]string{ + uint64(mc.Json): "application/json", + uint64(mc.Cbor): "application/cbor", + uint64(mc.DagJson): "application/vnd.ipld.dag-json", + uint64(mc.DagCbor): "application/vnd.ipld.dag-cbor", +} + +// contentTypeToCodecs maps the HTTP Content Type to the respective +// possible codecs. If the original data is in one of those codecs, +// we stream the raw bytes. Otherwise, we encode in the last codec +// of the list. +var contentTypeToCodecs = map[string][]uint64{ + "application/json": {uint64(mc.Json), uint64(mc.DagJson)}, + "application/vnd.ipld.dag-json": {uint64(mc.DagJson)}, + "application/cbor": {uint64(mc.Cbor), uint64(mc.DagCbor)}, + "application/vnd.ipld.dag-cbor": {uint64(mc.DagCbor)}, +} + +// contentTypeToExtension maps the HTTP Content Type to the respective file +// extension, used in Content-Disposition header when downloading the file. +var contentTypeToExtension = map[string]string{ + "application/json": ".json", + "application/vnd.ipld.dag-json": ".json", + "application/cbor": ".cbor", + "application/vnd.ipld.dag-cbor": ".cbor", +} + +func (i *gatewayHandler) serveCodec(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, requestedContentType string) { + ctx, span := tracing.Span(ctx, "Gateway", "ServeCodec", trace.WithAttributes(attribute.String("path", resolvedPath.String()), attribute.String("requestedContentType", requestedContentType))) + defer span.End() + + cidCodec := resolvedPath.Cid().Prefix().Codec + responseContentType := requestedContentType + + // If the resolved path still has some remainder, return error for now. + // TODO: handle this when we have IPLD Patch (https://ipld.io/specs/patch/) via HTTP PUT + // TODO: (depends on https://github.com/ipfs/kubo/issues/4801 and https://github.com/ipfs/kubo/issues/4782) + if resolvedPath.Remainder() != "" { + path := strings.TrimSuffix(resolvedPath.String(), resolvedPath.Remainder()) + err := fmt.Errorf("%q of %q could not be returned: reading IPLD Kinds other than Links (CBOR Tag 42) is not implemented: try reading %q instead", resolvedPath.Remainder(), resolvedPath.String(), path) + webError(w, "unsupported pathing", err, http.StatusNotImplemented) + return + } + + // If no explicit content type was requested, the response will have one based on the codec from the CID + if requestedContentType == "" { + cidContentType, ok := codecToContentType[cidCodec] + if !ok { + // Should not happen unless function is called with wrong parameters. + err := fmt.Errorf("content type not found for codec: %v", cidCodec) + webError(w, "internal error", err, http.StatusInternalServerError) + return + } + responseContentType = cidContentType + } + + // Set HTTP headers (for caching etc) + modtime := addCacheControlHeaders(w, r, contentPath, resolvedPath.Cid()) + name := setCodecContentDisposition(w, r, resolvedPath, responseContentType) + w.Header().Set("Content-Type", responseContentType) + w.Header().Set("X-Content-Type-Options", "nosniff") + + // No content type is specified by the user (via Accept, or format=). However, + // we support this format. Let's handle it. + if requestedContentType == "" { + isDAG := cidCodec == uint64(mc.DagJson) || cidCodec == uint64(mc.DagCbor) + acceptsHTML := strings.Contains(r.Header.Get("Accept"), "text/html") + download := r.URL.Query().Get("download") == "true" + + if isDAG && acceptsHTML && !download { + i.serveCodecHTML(ctx, w, r, resolvedPath, contentPath) + } else { + i.serveCodecRaw(ctx, w, r, resolvedPath, contentPath, name, modtime) + } + + return + } + + // Otherwise, the user has requested a specific content type. Let's first get + // the codecs that can be used with this content type. + codecs, ok := contentTypeToCodecs[requestedContentType] + if !ok { + // This is never supposed to happen unless function is called with wrong parameters. + err := fmt.Errorf("unsupported content type: %s", requestedContentType) + webError(w, err.Error(), err, http.StatusInternalServerError) + return + } + + // If we need to convert, use the last codec (strict dag- variant) + toCodec := codecs[len(codecs)-1] + + // If the requested content type has "dag-", ALWAYS go through the encoding + // process in order to validate the content. + if strings.Contains(requestedContentType, "dag-") { + i.serveCodecConverted(ctx, w, r, resolvedPath, contentPath, toCodec, modtime) + return + } + + // Otherwise, check if the data is encoded with the requested content type. + // If so, we can directly stream the raw data. serveRawBlock cannot be directly + // used here as it sets different headers. + for _, codec := range codecs { + if resolvedPath.Cid().Prefix().Codec == codec { + i.serveCodecRaw(ctx, w, r, resolvedPath, contentPath, name, modtime) + return + } + } + + // Finally, if nothing of the above is true, we have to actually convert the codec. + i.serveCodecConverted(ctx, w, r, resolvedPath, contentPath, toCodec, modtime) +} + +func (i *gatewayHandler) serveCodecHTML(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path) { + // A HTML directory index will be presented, be sure to set the correct + // type instead of relying on autodetection (which may fail). + w.Header().Set("Content-Type", "text/html") + + // Clear Content-Disposition -- we want HTML to be rendered inline + w.Header().Del("Content-Disposition") + + // Generated index requires custom Etag (output may change between Kubo versions) + dagEtag := getDagIndexEtag(resolvedPath.Cid()) + w.Header().Set("Etag", dagEtag) + + // Remove Cache-Control for now to match UnixFS dir-index-html responses + // (we don't want browser to cache HTML forever) + // TODO: if we ever change behavior for UnixFS dir listings, same changes should be applied here + w.Header().Del("Cache-Control") + + cidCodec := mc.Code(resolvedPath.Cid().Prefix().Codec) + if err := dih.DagIndexTemplate.Execute(w, dih.DagIndexTemplateData{ + Path: contentPath.String(), + CID: resolvedPath.Cid().String(), + CodecName: cidCodec.String(), + CodecHex: fmt.Sprintf("0x%x", uint64(cidCodec)), + }); err != nil { + webError(w, "failed to generate HTML listing for this DAG: try fetching raw block with ?format=raw", err, http.StatusInternalServerError) + } +} + +func (i *gatewayHandler) serveCodecRaw(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, name string, modtime time.Time) { + blockCid := resolvedPath.Cid() + blockReader, err := i.api.Block().Get(ctx, resolvedPath) + if err != nil { + webError(w, "ipfs block get "+blockCid.String(), err, http.StatusInternalServerError) + return + } + block, err := io.ReadAll(blockReader) + if err != nil { + webError(w, "ipfs block get "+blockCid.String(), err, http.StatusInternalServerError) + return + } + content := bytes.NewReader(block) + + // ServeContent will take care of + // If-None-Match+Etag, Content-Length and range requests + _, _, _ = ServeContent(w, r, name, modtime, content) +} + +func (i *gatewayHandler) serveCodecConverted(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, toCodec uint64, modtime time.Time) { + obj, err := i.api.Dag().Get(ctx, resolvedPath.Cid()) + if err != nil { + webError(w, "ipfs dag get "+html.EscapeString(resolvedPath.String()), err, http.StatusInternalServerError) + return + } + + universal, ok := obj.(ipldlegacy.UniversalNode) + if !ok { + err = fmt.Errorf("%T is not a valid IPLD node", obj) + webError(w, err.Error(), err, http.StatusInternalServerError) + return + } + finalNode := universal.(ipld.Node) + + encoder, err := multicodec.LookupEncoder(toCodec) + if err != nil { + webError(w, err.Error(), err, http.StatusInternalServerError) + return + } + + // Ensure IPLD node conforms to the codec specification. + var buf bytes.Buffer + err = encoder(finalNode, &buf) + if err != nil { + webError(w, err.Error(), err, http.StatusInternalServerError) + return + } + + // Sets correct Last-Modified header. This code is borrowed from the standard + // library (net/http/server.go) as we cannot use serveFile. + if !(modtime.IsZero() || modtime.Equal(unixEpochTime)) { + w.Header().Set("Last-Modified", modtime.UTC().Format(http.TimeFormat)) + } + + _, _ = w.Write(buf.Bytes()) +} + +func setCodecContentDisposition(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentType string) string { + var dispType, name string + + ext, ok := contentTypeToExtension[contentType] + if !ok { + // Should never happen. + ext = ".bin" + } + + if urlFilename := r.URL.Query().Get("filename"); urlFilename != "" { + name = urlFilename + } else { + name = resolvedPath.Cid().String() + ext + } + + // JSON should be inlined, but ?download=true should still override + if r.URL.Query().Get("download") == "true" { + dispType = "attachment" + } else { + switch ext { + case ".json": // codecs that serialize to JSON can be rendered by browsers + dispType = "inline" + default: // everything else is assumed binary / opaque bytes + dispType = "attachment" + } + } + + setContentDispositionHeader(w, name, dispType) + return name +} + +func getDagIndexEtag(dagCid cid.Cid) string { + return `"DagIndex-` + assets.AssetHash + `_CID-` + dagCid.String() + `"` +} diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index f4dda631e..0d2f07dbe 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -498,9 +498,9 @@ func TestIPNSHostnameBacklinks(t *testing.T) { if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } - if !strings.Contains(s, "") { t.Fatalf("expected file in directory listing") } - if !strings.Contains(s, " Date: Sat, 10 Dec 2022 00:27:04 +0100 Subject: [PATCH 660/674] fix: support /quic-v1 in webui v0.21 https://github.com/ipfs/ipfs-webui/releases/tag/v2.21.0 This commit was moved from ipfs/kubo@15093a00116ecf6b550023155f31a33f4bba6403 --- gateway/core/corehttp/webui.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go index c196c0eef..e8531459d 100644 --- a/gateway/core/corehttp/webui.go +++ b/gateway/core/corehttp/webui.go @@ -1,11 +1,12 @@ package corehttp // TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeibjbq3tmmy7wuihhhwvbladjsd3gx3kfjepxzkq6wylik6wc3whzy" // v2.20.0 +const WebUIPath = "/ipfs/bafybeiequgo72mrvuml56j4gk7crewig5bavumrrzhkqbim6b3s2yqi7ty" // v2.21.0 // WebUIPaths is a list of all past webUI paths. var WebUIPaths = []string{ WebUIPath, + "/ipfs/bafybeibjbq3tmmy7wuihhhwvbladjsd3gx3kfjepxzkq6wylik6wc3whzy", "/ipfs/bafybeiavrvt53fks6u32n5p2morgblcmck4bh4ymf4rrwu7ah5zsykmqqa", "/ipfs/bafybeiageaoxg6d7npaof6eyzqbwvbubyler7bq44hayik2hvqcggg7d2y", "/ipfs/bafybeidb5eryh72zajiokdggzo7yct2d6hhcflncji5im2y5w26uuygdsm", From 0293d8cc123c5563552a0eefc1a0e7f2174df499 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 12 Dec 2022 21:45:13 +0100 Subject: [PATCH 661/674] feat: fast directory listings with DAG Size column (#9481) Co-authored-by: Marcin Rataj This commit was moved from ipfs/kubo@7bdb341132533ef6857849587a8c5cf87e5e6e3c --- gateway/core/corehttp/gateway.go | 10 ++-- .../corehttp/gateway_handler_unixfs_dir.go | 48 +++++++------------ gateway/core/corehttp/gateway_indexPage.go | 17 ++++--- 3 files changed, 30 insertions(+), 45 deletions(-) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 0d0a234d9..334000b5a 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -18,9 +18,8 @@ import ( ) type GatewayConfig struct { - Headers map[string][]string - Writable bool - FastDirIndexThreshold int + Headers map[string][]string + Writable bool } // NodeAPI defines the minimal set of API services required by a gateway handler @@ -83,9 +82,8 @@ func GatewayOption(writable bool, paths ...string) ServeOption { } gateway := NewGatewayHandler(GatewayConfig{ - Headers: headers, - Writable: writable, - FastDirIndexThreshold: int(cfg.Gateway.FastDirIndexThreshold.WithDefault(100)), + Headers: headers, + Writable: writable, }, api, offlineAPI) gateway = otelhttp.NewHandler(gateway, "Gateway.Request") diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index 1c803b13b..5e90a8a79 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -105,25 +105,29 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit return } - // Optimization 1: - // List children without fetching their root blocks (fast, but no size info) - results, err := i.api.Unixfs().Ls(ctx, resolvedPath, options.Unixfs.ResolveChildren(false)) + // Optimization: use Unixfs.Ls without resolving children, but using the + // cumulative DAG size as the file size. This allows for a fast listing + // while keeping a good enough Size field. + results, err := i.api.Unixfs().Ls(ctx, + resolvedPath, + options.Unixfs.ResolveChildren(false), + options.Unixfs.UseCumulativeSize(true), + ) if err != nil { internalWebError(w, err) return } - // storage for directory listing dirListing := make([]directoryItem, 0, len(results)) - for link := range results { if link.Err != nil { internalWebError(w, err) return } + hash := link.Cid.String() di := directoryItem{ - Size: "", // no size because we did not fetch child nodes + Size: humanize.Bytes(uint64(link.Size)), Name: link.Name, Path: gopath.Join(originalURLPath, link.Name), Hash: hash, @@ -132,21 +136,6 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit dirListing = append(dirListing, di) } - // Optimization 2: fetch sizes only for dirs below FastDirIndexThreshold - if len(dirListing) < i.config.FastDirIndexThreshold { - dirit := dir.Entries() - linkNo := 0 - for dirit.Next() { - size := "?" - if s, err := dirit.Node().Size(); err == nil { - // Size may not be defined/supported. Continue anyways. - size = humanize.Bytes(uint64(s)) - } - dirListing[linkNo].Size = size - linkNo++ - } - } - // construct the correct back link // https://github.com/ipfs/kubo/issues/1365 backLink := originalURLPath @@ -195,15 +184,14 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit // See comment above where originalUrlPath is declared. tplData := listingTemplateData{ - GatewayURL: gwURL, - DNSLink: dnslink, - Listing: dirListing, - Size: size, - Path: contentPath.String(), - Breadcrumbs: breadcrumbs(contentPath.String(), dnslink), - BackLink: backLink, - Hash: hash, - FastDirIndexThreshold: i.config.FastDirIndexThreshold, + GatewayURL: gwURL, + DNSLink: dnslink, + Listing: dirListing, + Size: size, + Path: contentPath.String(), + Breadcrumbs: breadcrumbs(contentPath.String(), dnslink), + BackLink: backLink, + Hash: hash, } logger.Debugw("request processed", "tplDataDNSLink", dnslink, "tplDataSize", size, "tplDataBackLink", backLink, "tplDataHash", hash) diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway_indexPage.go index 19e444da3..b0db8ac1a 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway_indexPage.go @@ -12,15 +12,14 @@ import ( // structs for directory listing type listingTemplateData struct { - GatewayURL string - DNSLink bool - Listing []directoryItem - Size string - Path string - Breadcrumbs []breadcrumb - BackLink string - Hash string - FastDirIndexThreshold int + GatewayURL string + DNSLink bool + Listing []directoryItem + Size string + Path string + Breadcrumbs []breadcrumb + BackLink string + Hash string } type directoryItem struct { From b5822ac338e27b4c0e2d238c8d3c51bab03a2718 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 11 Jan 2023 03:40:58 +0100 Subject: [PATCH 662/674] fix(gateway): JSON when Accept is a list Block/CAR responses always had single explicit type, and we did not bother with implementing/testing lists. With the introduction of JSON people may start passing a list. This is the most basic fix which will return on the first matching type (in order). This does not implements weights (can be added in future, if needed). Closes #9520 This commit was moved from ipfs/kubo@f6825ab662c8ec097fd7bfd8ad0c5193960f5c7b --- gateway/core/corehttp/gateway_handler.go | 26 ++++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1222b17bc..64c388df4 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -890,18 +890,22 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string] } // Browsers and other user agents will send Accept header with generic types like: // Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 - // We only care about explicit, vendor-specific content-types. - for _, accept := range r.Header.Values("Accept") { - // respond to the very first ipld content type - if strings.HasPrefix(accept, "application/vnd.ipld") || - strings.HasPrefix(accept, "application/x-tar") || - strings.HasPrefix(accept, "application/json") || - strings.HasPrefix(accept, "application/cbor") { - mediatype, params, err := mime.ParseMediaType(accept) - if err != nil { - return "", nil, err + // We only care about explicit, vendor-specific content-types and respond to the first match (in order). + // TODO: make this RFC compliant and respect weights (eg. return CAR for Accept:application/vnd.ipld.dag-json;q=0.1,application/vnd.ipld.car;q=0.2) + for _, header := range r.Header.Values("Accept") { + for _, value := range strings.Split(header, ",") { + accept := strings.TrimSpace(value) + // respond to the very first matching content type + if strings.HasPrefix(accept, "application/vnd.ipld") || + strings.HasPrefix(accept, "application/x-tar") || + strings.HasPrefix(accept, "application/json") || + strings.HasPrefix(accept, "application/cbor") { + mediatype, params, err := mime.ParseMediaType(accept) + if err != nil { + return "", nil, err + } + return mediatype, params, nil } - return mediatype, params, nil } } return "", nil, nil From 1c039807b020a05d42024f6a4f3f2bcd80eaf448 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 13 Jan 2023 14:27:03 +0100 Subject: [PATCH 663/674] chore: migrate from go-ipfs-files to go-libipfs/files (#9535) This commit was moved from ipfs/kubo@255e64e49e837afce534555f3451e2cffe9f0dcb --- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_handler_tar.go | 2 +- gateway/core/corehttp/gateway_handler_unixfs.go | 2 +- gateway/core/corehttp/gateway_handler_unixfs__redirects.go | 2 +- gateway/core/corehttp/gateway_handler_unixfs_dir.go | 2 +- gateway/core/corehttp/gateway_handler_unixfs_file.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/hostname_test.go | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 64c388df4..c20f112d7 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -17,8 +17,8 @@ import ( "time" cid "github.com/ipfs/go-cid" - files "github.com/ipfs/go-ipfs-files" ipld "github.com/ipfs/go-ipld-format" + "github.com/ipfs/go-libipfs/files" dag "github.com/ipfs/go-merkledag" mfs "github.com/ipfs/go-mfs" path "github.com/ipfs/go-path" diff --git a/gateway/core/corehttp/gateway_handler_tar.go b/gateway/core/corehttp/gateway_handler_tar.go index 532d88757..14edf4fbf 100644 --- a/gateway/core/corehttp/gateway_handler_tar.go +++ b/gateway/core/corehttp/gateway_handler_tar.go @@ -6,7 +6,7 @@ import ( "net/http" "time" - files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-libipfs/files" ipath "github.com/ipfs/interface-go-ipfs-core/path" "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" diff --git a/gateway/core/corehttp/gateway_handler_unixfs.go b/gateway/core/corehttp/gateway_handler_unixfs.go index 75d51d93a..045c0f81d 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs.go +++ b/gateway/core/corehttp/gateway_handler_unixfs.go @@ -7,7 +7,7 @@ import ( "net/http" "time" - files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-libipfs/files" ipath "github.com/ipfs/interface-go-ipfs-core/path" "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" diff --git a/gateway/core/corehttp/gateway_handler_unixfs__redirects.go b/gateway/core/corehttp/gateway_handler_unixfs__redirects.go index 81cf05731..6906683a6 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs__redirects.go +++ b/gateway/core/corehttp/gateway_handler_unixfs__redirects.go @@ -8,8 +8,8 @@ import ( "strconv" "strings" - files "github.com/ipfs/go-ipfs-files" redirects "github.com/ipfs/go-ipfs-redirects-file" + "github.com/ipfs/go-libipfs/files" ipath "github.com/ipfs/interface-go-ipfs-core/path" "go.uber.org/zap" ) diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index 5e90a8a79..03d67e1c0 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -10,7 +10,7 @@ import ( "github.com/dustin/go-humanize" cid "github.com/ipfs/go-cid" - files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-libipfs/files" path "github.com/ipfs/go-path" "github.com/ipfs/go-path/resolver" options "github.com/ipfs/interface-go-ipfs-core/options" diff --git a/gateway/core/corehttp/gateway_handler_unixfs_file.go b/gateway/core/corehttp/gateway_handler_unixfs_file.go index 9463be1ac..1abdc823e 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_file.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_file.go @@ -11,7 +11,7 @@ import ( "time" "github.com/gabriel-vasile/mimetype" - files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-libipfs/files" ipath "github.com/ipfs/interface-go-ipfs-core/path" "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 0d2f07dbe..74723579d 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( datastore "github.com/ipfs/go-datastore" syncds "github.com/ipfs/go-datastore/sync" - files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-libipfs/files" path "github.com/ipfs/go-path" iface "github.com/ipfs/interface-go-ipfs-core" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index 6f0713528..b4a8b8d16 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -7,7 +7,7 @@ import ( "testing" cid "github.com/ipfs/go-cid" - files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-libipfs/files" path "github.com/ipfs/go-path" config "github.com/ipfs/kubo/config" coreapi "github.com/ipfs/kubo/core/coreapi" From 1d99d71f3bb49ada2cc60960ff5f3cecf741123a Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 21 Jan 2023 04:21:18 +0100 Subject: [PATCH 664/674] fix(gateway): undesired conversions to dag-json and friends (#9566) * fix(gateway): do not convert unixfs/raw into dag-* unless explicit * fix(gateway): keep only dag-json|dag-cbor handling * fix: allow requesting dag-json as application/json - adds bunch of additional tests including JSON file on UnixFS - fix: dag-json codec (0x0129) can be returned as plain json - fix: json codec (0x0200) cna be retrurned as plain json * fix: using ?format|Accept with CID w/ codec works * docs(changelog): cbor and json on gateway Co-authored-by: Marcin Rataj This commit was moved from ipfs/kubo@c706c638fc33f2ad28110858f6e25de32a7eac7f --- gateway/core/corehttp/gateway_handler.go | 21 ++--- .../core/corehttp/gateway_handler_codec.go | 83 +++++++++---------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index c20f112d7..1c6797e68 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -418,9 +418,9 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // Support custom response formats passed via ?format or Accept HTTP header switch responseFormat { - case "": - switch resolvedPath.Cid().Prefix().Codec { - case uint64(mc.Json), uint64(mc.DagJson), uint64(mc.Cbor), uint64(mc.DagCbor): + case "", "application/json", "application/cbor": + switch mc.Code(resolvedPath.Cid().Prefix().Codec) { + case mc.Json, mc.DagJson, mc.Cbor, mc.DagCbor: logger.Debugw("serving codec", "path", contentPath) i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat) default: @@ -441,14 +441,13 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request logger.Debugw("serving tar file", "path", contentPath) i.serveTAR(r.Context(), w, r, resolvedPath, contentPath, begin, logger) return - case "application/json", "application/vnd.ipld.dag-json", - "application/cbor", "application/vnd.ipld.dag-cbor": + case "application/vnd.ipld.dag-json", "application/vnd.ipld.dag-cbor": logger.Debugw("serving codec", "path", contentPath) i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat) return default: // catch-all for unsuported application/vnd.* err := fmt.Errorf("unsupported format %q", responseFormat) - webError(w, "failed respond with requested content type", err, http.StatusBadRequest) + webError(w, "failed to respond with requested content type", err, http.StatusBadRequest) return } } @@ -878,14 +877,14 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string] return "application/vnd.ipld.car", nil, nil case "tar": return "application/x-tar", nil, nil - case "dag-json": - return "application/vnd.ipld.dag-json", nil, nil case "json": return "application/json", nil, nil - case "dag-cbor": - return "application/vnd.ipld.dag-cbor", nil, nil case "cbor": return "application/cbor", nil, nil + case "dag-json": + return "application/vnd.ipld.dag-json", nil, nil + case "dag-cbor": + return "application/vnd.ipld.dag-cbor", nil, nil } } // Browsers and other user agents will send Accept header with generic types like: @@ -908,6 +907,8 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string] } } } + // If none of special-cased content types is found, return empty string + // to indicate default, implicit UnixFS response should be prepared return "", nil, nil } diff --git a/gateway/core/corehttp/gateway_handler_codec.go b/gateway/core/corehttp/gateway_handler_codec.go index 95a151c79..93e9593b7 100644 --- a/gateway/core/corehttp/gateway_handler_codec.go +++ b/gateway/core/corehttp/gateway_handler_codec.go @@ -25,22 +25,25 @@ import ( // codecToContentType maps the supported IPLD codecs to the HTTP Content // Type they should have. -var codecToContentType = map[uint64]string{ - uint64(mc.Json): "application/json", - uint64(mc.Cbor): "application/cbor", - uint64(mc.DagJson): "application/vnd.ipld.dag-json", - uint64(mc.DagCbor): "application/vnd.ipld.dag-cbor", +var codecToContentType = map[mc.Code]string{ + mc.Json: "application/json", + mc.Cbor: "application/cbor", + mc.DagJson: "application/vnd.ipld.dag-json", + mc.DagCbor: "application/vnd.ipld.dag-cbor", } -// contentTypeToCodecs maps the HTTP Content Type to the respective -// possible codecs. If the original data is in one of those codecs, -// we stream the raw bytes. Otherwise, we encode in the last codec -// of the list. -var contentTypeToCodecs = map[string][]uint64{ - "application/json": {uint64(mc.Json), uint64(mc.DagJson)}, - "application/vnd.ipld.dag-json": {uint64(mc.DagJson)}, - "application/cbor": {uint64(mc.Cbor), uint64(mc.DagCbor)}, - "application/vnd.ipld.dag-cbor": {uint64(mc.DagCbor)}, +// contentTypeToRaw maps the HTTP Content Type to the respective codec that +// allows raw response without any conversion. +var contentTypeToRaw = map[string][]mc.Code{ + "application/json": {mc.Json, mc.DagJson}, + "application/cbor": {mc.Cbor, mc.DagCbor}, +} + +// contentTypeToCodec maps the HTTP Content Type to the respective codec. We +// only add here the codecs that we want to convert-to-from. +var contentTypeToCodec = map[string]mc.Code{ + "application/vnd.ipld.dag-json": mc.DagJson, + "application/vnd.ipld.dag-cbor": mc.DagCbor, } // contentTypeToExtension maps the HTTP Content Type to the respective file @@ -56,7 +59,7 @@ func (i *gatewayHandler) serveCodec(ctx context.Context, w http.ResponseWriter, ctx, span := tracing.Span(ctx, "Gateway", "ServeCodec", trace.WithAttributes(attribute.String("path", resolvedPath.String()), attribute.String("requestedContentType", requestedContentType))) defer span.End() - cidCodec := resolvedPath.Cid().Prefix().Codec + cidCodec := mc.Code(resolvedPath.Cid().Prefix().Codec) responseContentType := requestedContentType // If the resolved path still has some remainder, return error for now. @@ -90,22 +93,36 @@ func (i *gatewayHandler) serveCodec(ctx context.Context, w http.ResponseWriter, // No content type is specified by the user (via Accept, or format=). However, // we support this format. Let's handle it. if requestedContentType == "" { - isDAG := cidCodec == uint64(mc.DagJson) || cidCodec == uint64(mc.DagCbor) + isDAG := cidCodec == mc.DagJson || cidCodec == mc.DagCbor acceptsHTML := strings.Contains(r.Header.Get("Accept"), "text/html") download := r.URL.Query().Get("download") == "true" if isDAG && acceptsHTML && !download { i.serveCodecHTML(ctx, w, r, resolvedPath, contentPath) } else { + // This covers CIDs with codec 'json' and 'cbor' as those do not have + // an explicit requested content type. i.serveCodecRaw(ctx, w, r, resolvedPath, contentPath, name, modtime) } return } - // Otherwise, the user has requested a specific content type. Let's first get - // the codecs that can be used with this content type. - codecs, ok := contentTypeToCodecs[requestedContentType] + // If DAG-JSON or DAG-CBOR was requested using corresponding plain content type + // return raw block as-is, without conversion + skipCodecs, ok := contentTypeToRaw[requestedContentType] + if ok { + for _, skipCodec := range skipCodecs { + if skipCodec == cidCodec { + i.serveCodecRaw(ctx, w, r, resolvedPath, contentPath, name, modtime) + return + } + } + } + + // Otherwise, the user has requested a specific content type (a DAG-* variant). + // Let's first get the codecs that can be used with this content type. + toCodec, ok := contentTypeToCodec[requestedContentType] if !ok { // This is never supposed to happen unless function is called with wrong parameters. err := fmt.Errorf("unsupported content type: %s", requestedContentType) @@ -113,27 +130,7 @@ func (i *gatewayHandler) serveCodec(ctx context.Context, w http.ResponseWriter, return } - // If we need to convert, use the last codec (strict dag- variant) - toCodec := codecs[len(codecs)-1] - - // If the requested content type has "dag-", ALWAYS go through the encoding - // process in order to validate the content. - if strings.Contains(requestedContentType, "dag-") { - i.serveCodecConverted(ctx, w, r, resolvedPath, contentPath, toCodec, modtime) - return - } - - // Otherwise, check if the data is encoded with the requested content type. - // If so, we can directly stream the raw data. serveRawBlock cannot be directly - // used here as it sets different headers. - for _, codec := range codecs { - if resolvedPath.Cid().Prefix().Codec == codec { - i.serveCodecRaw(ctx, w, r, resolvedPath, contentPath, name, modtime) - return - } - } - - // Finally, if nothing of the above is true, we have to actually convert the codec. + // This handles DAG-* conversions and validations. i.serveCodecConverted(ctx, w, r, resolvedPath, contentPath, toCodec, modtime) } @@ -165,6 +162,7 @@ func (i *gatewayHandler) serveCodecHTML(ctx context.Context, w http.ResponseWrit } } +// serveCodecRaw returns the raw block without any conversion func (i *gatewayHandler) serveCodecRaw(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, name string, modtime time.Time) { blockCid := resolvedPath.Cid() blockReader, err := i.api.Block().Get(ctx, resolvedPath) @@ -184,7 +182,8 @@ func (i *gatewayHandler) serveCodecRaw(ctx context.Context, w http.ResponseWrite _, _, _ = ServeContent(w, r, name, modtime, content) } -func (i *gatewayHandler) serveCodecConverted(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, toCodec uint64, modtime time.Time) { +// serveCodecConverted returns payload converted to codec specified in toCodec +func (i *gatewayHandler) serveCodecConverted(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, toCodec mc.Code, modtime time.Time) { obj, err := i.api.Dag().Get(ctx, resolvedPath.Cid()) if err != nil { webError(w, "ipfs dag get "+html.EscapeString(resolvedPath.String()), err, http.StatusInternalServerError) @@ -199,7 +198,7 @@ func (i *gatewayHandler) serveCodecConverted(ctx context.Context, w http.Respons } finalNode := universal.(ipld.Node) - encoder, err := multicodec.LookupEncoder(toCodec) + encoder, err := multicodec.LookupEncoder(uint64(toCodec)) if err != nil { webError(w, err.Error(), err, http.StatusInternalServerError) return From 1e4d1b088a09ef16e792a76ea83d45551d4e3caf Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 11 Jan 2023 03:40:58 +0100 Subject: [PATCH 665/674] fix(gateway): JSON when Accept is a list Block/CAR responses always had single explicit type, and we did not bother with implementing/testing lists. With the introduction of JSON people may start passing a list. This is the most basic fix which will return on the first matching type (in order). This does not implements weights (can be added in future, if needed). Closes #9520 This commit was moved from ipfs/kubo@b333740468fc6bd249878f8b82ef59a431879a6a --- gateway/core/corehttp/gateway_handler.go | 26 ++++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1222b17bc..64c388df4 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -890,18 +890,22 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string] } // Browsers and other user agents will send Accept header with generic types like: // Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 - // We only care about explicit, vendor-specific content-types. - for _, accept := range r.Header.Values("Accept") { - // respond to the very first ipld content type - if strings.HasPrefix(accept, "application/vnd.ipld") || - strings.HasPrefix(accept, "application/x-tar") || - strings.HasPrefix(accept, "application/json") || - strings.HasPrefix(accept, "application/cbor") { - mediatype, params, err := mime.ParseMediaType(accept) - if err != nil { - return "", nil, err + // We only care about explicit, vendor-specific content-types and respond to the first match (in order). + // TODO: make this RFC compliant and respect weights (eg. return CAR for Accept:application/vnd.ipld.dag-json;q=0.1,application/vnd.ipld.car;q=0.2) + for _, header := range r.Header.Values("Accept") { + for _, value := range strings.Split(header, ",") { + accept := strings.TrimSpace(value) + // respond to the very first matching content type + if strings.HasPrefix(accept, "application/vnd.ipld") || + strings.HasPrefix(accept, "application/x-tar") || + strings.HasPrefix(accept, "application/json") || + strings.HasPrefix(accept, "application/cbor") { + mediatype, params, err := mime.ParseMediaType(accept) + if err != nil { + return "", nil, err + } + return mediatype, params, nil } - return mediatype, params, nil } } return "", nil, nil From b10c4d94bd50ad1659282beae4631b1c2bbe6746 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 13 Jan 2023 14:27:03 +0100 Subject: [PATCH 666/674] chore: migrate from go-ipfs-files to go-libipfs/files (#9535) This commit was moved from ipfs/kubo@4ddeda55c04f50a21a6991071fad3f699e008aa6 --- gateway/core/corehttp/gateway_handler.go | 2 +- gateway/core/corehttp/gateway_handler_tar.go | 2 +- gateway/core/corehttp/gateway_handler_unixfs.go | 2 +- gateway/core/corehttp/gateway_handler_unixfs__redirects.go | 2 +- gateway/core/corehttp/gateway_handler_unixfs_dir.go | 2 +- gateway/core/corehttp/gateway_handler_unixfs_file.go | 2 +- gateway/core/corehttp/gateway_test.go | 2 +- gateway/core/corehttp/hostname_test.go | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 64c388df4..c20f112d7 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -17,8 +17,8 @@ import ( "time" cid "github.com/ipfs/go-cid" - files "github.com/ipfs/go-ipfs-files" ipld "github.com/ipfs/go-ipld-format" + "github.com/ipfs/go-libipfs/files" dag "github.com/ipfs/go-merkledag" mfs "github.com/ipfs/go-mfs" path "github.com/ipfs/go-path" diff --git a/gateway/core/corehttp/gateway_handler_tar.go b/gateway/core/corehttp/gateway_handler_tar.go index 532d88757..14edf4fbf 100644 --- a/gateway/core/corehttp/gateway_handler_tar.go +++ b/gateway/core/corehttp/gateway_handler_tar.go @@ -6,7 +6,7 @@ import ( "net/http" "time" - files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-libipfs/files" ipath "github.com/ipfs/interface-go-ipfs-core/path" "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" diff --git a/gateway/core/corehttp/gateway_handler_unixfs.go b/gateway/core/corehttp/gateway_handler_unixfs.go index 75d51d93a..045c0f81d 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs.go +++ b/gateway/core/corehttp/gateway_handler_unixfs.go @@ -7,7 +7,7 @@ import ( "net/http" "time" - files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-libipfs/files" ipath "github.com/ipfs/interface-go-ipfs-core/path" "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" diff --git a/gateway/core/corehttp/gateway_handler_unixfs__redirects.go b/gateway/core/corehttp/gateway_handler_unixfs__redirects.go index 81cf05731..6906683a6 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs__redirects.go +++ b/gateway/core/corehttp/gateway_handler_unixfs__redirects.go @@ -8,8 +8,8 @@ import ( "strconv" "strings" - files "github.com/ipfs/go-ipfs-files" redirects "github.com/ipfs/go-ipfs-redirects-file" + "github.com/ipfs/go-libipfs/files" ipath "github.com/ipfs/interface-go-ipfs-core/path" "go.uber.org/zap" ) diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway_handler_unixfs_dir.go index 5e90a8a79..03d67e1c0 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_dir.go @@ -10,7 +10,7 @@ import ( "github.com/dustin/go-humanize" cid "github.com/ipfs/go-cid" - files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-libipfs/files" path "github.com/ipfs/go-path" "github.com/ipfs/go-path/resolver" options "github.com/ipfs/interface-go-ipfs-core/options" diff --git a/gateway/core/corehttp/gateway_handler_unixfs_file.go b/gateway/core/corehttp/gateway_handler_unixfs_file.go index 9463be1ac..1abdc823e 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_file.go +++ b/gateway/core/corehttp/gateway_handler_unixfs_file.go @@ -11,7 +11,7 @@ import ( "time" "github.com/gabriel-vasile/mimetype" - files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-libipfs/files" ipath "github.com/ipfs/interface-go-ipfs-core/path" "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 0d2f07dbe..74723579d 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -19,7 +19,7 @@ import ( datastore "github.com/ipfs/go-datastore" syncds "github.com/ipfs/go-datastore/sync" - files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-libipfs/files" path "github.com/ipfs/go-path" iface "github.com/ipfs/interface-go-ipfs-core" nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go index 6f0713528..b4a8b8d16 100644 --- a/gateway/core/corehttp/hostname_test.go +++ b/gateway/core/corehttp/hostname_test.go @@ -7,7 +7,7 @@ import ( "testing" cid "github.com/ipfs/go-cid" - files "github.com/ipfs/go-ipfs-files" + "github.com/ipfs/go-libipfs/files" path "github.com/ipfs/go-path" config "github.com/ipfs/kubo/config" coreapi "github.com/ipfs/kubo/core/coreapi" From 4b0b73ce854be0fbea000261a0e834debcab6cfb Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 21 Jan 2023 04:21:18 +0100 Subject: [PATCH 667/674] fix(gateway): undesired conversions to dag-json and friends (#9566) * fix(gateway): do not convert unixfs/raw into dag-* unless explicit * fix(gateway): keep only dag-json|dag-cbor handling * fix: allow requesting dag-json as application/json - adds bunch of additional tests including JSON file on UnixFS - fix: dag-json codec (0x0129) can be returned as plain json - fix: json codec (0x0200) cna be retrurned as plain json * fix: using ?format|Accept with CID w/ codec works * docs(changelog): cbor and json on gateway Co-authored-by: Marcin Rataj This commit was moved from ipfs/kubo@14703e19e31b78b2170e3a7ee7bc209249c9575f --- gateway/core/corehttp/gateway_handler.go | 21 ++--- .../core/corehttp/gateway_handler_codec.go | 83 +++++++++---------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index c20f112d7..1c6797e68 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -418,9 +418,9 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request // Support custom response formats passed via ?format or Accept HTTP header switch responseFormat { - case "": - switch resolvedPath.Cid().Prefix().Codec { - case uint64(mc.Json), uint64(mc.DagJson), uint64(mc.Cbor), uint64(mc.DagCbor): + case "", "application/json", "application/cbor": + switch mc.Code(resolvedPath.Cid().Prefix().Codec) { + case mc.Json, mc.DagJson, mc.Cbor, mc.DagCbor: logger.Debugw("serving codec", "path", contentPath) i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat) default: @@ -441,14 +441,13 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request logger.Debugw("serving tar file", "path", contentPath) i.serveTAR(r.Context(), w, r, resolvedPath, contentPath, begin, logger) return - case "application/json", "application/vnd.ipld.dag-json", - "application/cbor", "application/vnd.ipld.dag-cbor": + case "application/vnd.ipld.dag-json", "application/vnd.ipld.dag-cbor": logger.Debugw("serving codec", "path", contentPath) i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat) return default: // catch-all for unsuported application/vnd.* err := fmt.Errorf("unsupported format %q", responseFormat) - webError(w, "failed respond with requested content type", err, http.StatusBadRequest) + webError(w, "failed to respond with requested content type", err, http.StatusBadRequest) return } } @@ -878,14 +877,14 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string] return "application/vnd.ipld.car", nil, nil case "tar": return "application/x-tar", nil, nil - case "dag-json": - return "application/vnd.ipld.dag-json", nil, nil case "json": return "application/json", nil, nil - case "dag-cbor": - return "application/vnd.ipld.dag-cbor", nil, nil case "cbor": return "application/cbor", nil, nil + case "dag-json": + return "application/vnd.ipld.dag-json", nil, nil + case "dag-cbor": + return "application/vnd.ipld.dag-cbor", nil, nil } } // Browsers and other user agents will send Accept header with generic types like: @@ -908,6 +907,8 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string] } } } + // If none of special-cased content types is found, return empty string + // to indicate default, implicit UnixFS response should be prepared return "", nil, nil } diff --git a/gateway/core/corehttp/gateway_handler_codec.go b/gateway/core/corehttp/gateway_handler_codec.go index 95a151c79..93e9593b7 100644 --- a/gateway/core/corehttp/gateway_handler_codec.go +++ b/gateway/core/corehttp/gateway_handler_codec.go @@ -25,22 +25,25 @@ import ( // codecToContentType maps the supported IPLD codecs to the HTTP Content // Type they should have. -var codecToContentType = map[uint64]string{ - uint64(mc.Json): "application/json", - uint64(mc.Cbor): "application/cbor", - uint64(mc.DagJson): "application/vnd.ipld.dag-json", - uint64(mc.DagCbor): "application/vnd.ipld.dag-cbor", +var codecToContentType = map[mc.Code]string{ + mc.Json: "application/json", + mc.Cbor: "application/cbor", + mc.DagJson: "application/vnd.ipld.dag-json", + mc.DagCbor: "application/vnd.ipld.dag-cbor", } -// contentTypeToCodecs maps the HTTP Content Type to the respective -// possible codecs. If the original data is in one of those codecs, -// we stream the raw bytes. Otherwise, we encode in the last codec -// of the list. -var contentTypeToCodecs = map[string][]uint64{ - "application/json": {uint64(mc.Json), uint64(mc.DagJson)}, - "application/vnd.ipld.dag-json": {uint64(mc.DagJson)}, - "application/cbor": {uint64(mc.Cbor), uint64(mc.DagCbor)}, - "application/vnd.ipld.dag-cbor": {uint64(mc.DagCbor)}, +// contentTypeToRaw maps the HTTP Content Type to the respective codec that +// allows raw response without any conversion. +var contentTypeToRaw = map[string][]mc.Code{ + "application/json": {mc.Json, mc.DagJson}, + "application/cbor": {mc.Cbor, mc.DagCbor}, +} + +// contentTypeToCodec maps the HTTP Content Type to the respective codec. We +// only add here the codecs that we want to convert-to-from. +var contentTypeToCodec = map[string]mc.Code{ + "application/vnd.ipld.dag-json": mc.DagJson, + "application/vnd.ipld.dag-cbor": mc.DagCbor, } // contentTypeToExtension maps the HTTP Content Type to the respective file @@ -56,7 +59,7 @@ func (i *gatewayHandler) serveCodec(ctx context.Context, w http.ResponseWriter, ctx, span := tracing.Span(ctx, "Gateway", "ServeCodec", trace.WithAttributes(attribute.String("path", resolvedPath.String()), attribute.String("requestedContentType", requestedContentType))) defer span.End() - cidCodec := resolvedPath.Cid().Prefix().Codec + cidCodec := mc.Code(resolvedPath.Cid().Prefix().Codec) responseContentType := requestedContentType // If the resolved path still has some remainder, return error for now. @@ -90,22 +93,36 @@ func (i *gatewayHandler) serveCodec(ctx context.Context, w http.ResponseWriter, // No content type is specified by the user (via Accept, or format=). However, // we support this format. Let's handle it. if requestedContentType == "" { - isDAG := cidCodec == uint64(mc.DagJson) || cidCodec == uint64(mc.DagCbor) + isDAG := cidCodec == mc.DagJson || cidCodec == mc.DagCbor acceptsHTML := strings.Contains(r.Header.Get("Accept"), "text/html") download := r.URL.Query().Get("download") == "true" if isDAG && acceptsHTML && !download { i.serveCodecHTML(ctx, w, r, resolvedPath, contentPath) } else { + // This covers CIDs with codec 'json' and 'cbor' as those do not have + // an explicit requested content type. i.serveCodecRaw(ctx, w, r, resolvedPath, contentPath, name, modtime) } return } - // Otherwise, the user has requested a specific content type. Let's first get - // the codecs that can be used with this content type. - codecs, ok := contentTypeToCodecs[requestedContentType] + // If DAG-JSON or DAG-CBOR was requested using corresponding plain content type + // return raw block as-is, without conversion + skipCodecs, ok := contentTypeToRaw[requestedContentType] + if ok { + for _, skipCodec := range skipCodecs { + if skipCodec == cidCodec { + i.serveCodecRaw(ctx, w, r, resolvedPath, contentPath, name, modtime) + return + } + } + } + + // Otherwise, the user has requested a specific content type (a DAG-* variant). + // Let's first get the codecs that can be used with this content type. + toCodec, ok := contentTypeToCodec[requestedContentType] if !ok { // This is never supposed to happen unless function is called with wrong parameters. err := fmt.Errorf("unsupported content type: %s", requestedContentType) @@ -113,27 +130,7 @@ func (i *gatewayHandler) serveCodec(ctx context.Context, w http.ResponseWriter, return } - // If we need to convert, use the last codec (strict dag- variant) - toCodec := codecs[len(codecs)-1] - - // If the requested content type has "dag-", ALWAYS go through the encoding - // process in order to validate the content. - if strings.Contains(requestedContentType, "dag-") { - i.serveCodecConverted(ctx, w, r, resolvedPath, contentPath, toCodec, modtime) - return - } - - // Otherwise, check if the data is encoded with the requested content type. - // If so, we can directly stream the raw data. serveRawBlock cannot be directly - // used here as it sets different headers. - for _, codec := range codecs { - if resolvedPath.Cid().Prefix().Codec == codec { - i.serveCodecRaw(ctx, w, r, resolvedPath, contentPath, name, modtime) - return - } - } - - // Finally, if nothing of the above is true, we have to actually convert the codec. + // This handles DAG-* conversions and validations. i.serveCodecConverted(ctx, w, r, resolvedPath, contentPath, toCodec, modtime) } @@ -165,6 +162,7 @@ func (i *gatewayHandler) serveCodecHTML(ctx context.Context, w http.ResponseWrit } } +// serveCodecRaw returns the raw block without any conversion func (i *gatewayHandler) serveCodecRaw(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, name string, modtime time.Time) { blockCid := resolvedPath.Cid() blockReader, err := i.api.Block().Get(ctx, resolvedPath) @@ -184,7 +182,8 @@ func (i *gatewayHandler) serveCodecRaw(ctx context.Context, w http.ResponseWrite _, _, _ = ServeContent(w, r, name, modtime, content) } -func (i *gatewayHandler) serveCodecConverted(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, toCodec uint64, modtime time.Time) { +// serveCodecConverted returns payload converted to codec specified in toCodec +func (i *gatewayHandler) serveCodecConverted(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, toCodec mc.Code, modtime time.Time) { obj, err := i.api.Dag().Get(ctx, resolvedPath.Cid()) if err != nil { webError(w, "ipfs dag get "+html.EscapeString(resolvedPath.String()), err, http.StatusInternalServerError) @@ -199,7 +198,7 @@ func (i *gatewayHandler) serveCodecConverted(ctx context.Context, w http.Respons } finalNode := universal.(ipld.Node) - encoder, err := multicodec.LookupEncoder(toCodec) + encoder, err := multicodec.LookupEncoder(uint64(toCodec)) if err != nil { webError(w, err.Error(), err, http.StatusInternalServerError) return From 64b4f6680aaf2fb9736f86f8b14a3a19a22269ff Mon Sep 17 00:00:00 2001 From: Jorropo Date: Thu, 26 Jan 2023 16:24:40 +0100 Subject: [PATCH 668/674] chore: bump go-libipfs to replace go-block-format Includes changes from: - https://github.com/ipfs/go-block-format/pull/37 - https://github.com/ipfs/go-libipfs/pull/58 This commit was moved from ipfs/kubo@f20c980f2d60347b0c971c11b48a9fdd2ab11ecd --- gateway/core/corehttp/gateway_handler_car.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway/core/corehttp/gateway_handler_car.go b/gateway/core/corehttp/gateway_handler_car.go index 3363c5199..9f704d6ca 100644 --- a/gateway/core/corehttp/gateway_handler_car.go +++ b/gateway/core/corehttp/gateway_handler_car.go @@ -6,8 +6,8 @@ import ( "net/http" "time" - blocks "github.com/ipfs/go-block-format" cid "github.com/ipfs/go-cid" + blocks "github.com/ipfs/go-libipfs/blocks" coreiface "github.com/ipfs/interface-go-ipfs-core" ipath "github.com/ipfs/interface-go-ipfs-core/path" "github.com/ipfs/kubo/tracing" From 9a451ff27bc7951ef938d68cba94fb2b6f5e6028 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 27 Jan 2023 02:33:13 +0100 Subject: [PATCH 669/674] fix(ipns): honour --ttl flag in 'ipfs name publish' (#9471) * fix: honour --ttl flag in 'ipfs name publish' * docs(cli): ipfs name inspect --help Co-authored-by: Marcin Rataj This commit was moved from ipfs/kubo@94e7f79805d08e07bd67eaaa1dad58a4d764226b --- gateway/core/corehttp/gateway_test.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 74723579d..877ac9739 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -9,7 +9,6 @@ import ( "regexp" "strings" "testing" - "time" namesys "github.com/ipfs/go-namesys" version "github.com/ipfs/kubo" @@ -68,11 +67,7 @@ func (m mockNamesys) ResolveAsync(ctx context.Context, name string, opts ...nsop return out } -func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value path.Path) error { - return errors.New("not implemented for mockNamesys") -} - -func (m mockNamesys) PublishWithEOL(ctx context.Context, name ci.PrivKey, value path.Path, _ time.Time) error { +func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value path.Path, opts ...nsopts.PublishOption) error { return errors.New("not implemented for mockNamesys") } From 41f6bbf12a8cea41af04a65aafde4d24395205ca Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 27 Jan 2023 04:46:50 +0100 Subject: [PATCH 670/674] feat(gateway): IPNS record response format (IPIP-351) (#9399) * feat(gateway): IPNS record response format * docs(rpc): mark as experimental: routing provide, get, put Co-authored-by: Marcin Rataj This commit was moved from ipfs/kubo@a3c70a11e68bae6f56763bf971a9477762dd22fe --- gateway/core/corehttp/gateway.go | 4 ++ gateway/core/corehttp/gateway_handler.go | 8 ++- .../corehttp/gateway_handler_ipns_record.go | 71 +++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 gateway/core/corehttp/gateway_handler_ipns_record.go diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 334000b5a..00c2f7483 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -33,6 +33,10 @@ type NodeAPI interface { // Dag returns an implementation of Dag API Dag() coreiface.APIDagService + // Routing returns an implementation of Routing API. + // Used for returning signed IPNS records, see IPIP-0328 + Routing() coreiface.RoutingAPI + // ResolvePath resolves the path using Unixfs resolver ResolvePath(context.Context, path.Path) (path.Resolved, error) } diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway_handler.go index 1c6797e68..c3e8fa0d6 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway_handler.go @@ -444,6 +444,9 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request case "application/vnd.ipld.dag-json", "application/vnd.ipld.dag-cbor": logger.Debugw("serving codec", "path", contentPath) i.serveCodec(r.Context(), w, r, resolvedPath, contentPath, begin, responseFormat) + case "application/vnd.ipfs.ipns-record": + logger.Debugw("serving ipns record", "path", contentPath) + i.serveIpnsRecord(r.Context(), w, r, resolvedPath, contentPath, begin, logger) return default: // catch-all for unsuported application/vnd.* err := fmt.Errorf("unsupported format %q", responseFormat) @@ -885,6 +888,8 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string] return "application/vnd.ipld.dag-json", nil, nil case "dag-cbor": return "application/vnd.ipld.dag-cbor", nil, nil + case "ipns-record": + return "application/vnd.ipfs.ipns-record", nil, nil } } // Browsers and other user agents will send Accept header with generic types like: @@ -898,7 +903,8 @@ func customResponseFormat(r *http.Request) (mediaType string, params map[string] if strings.HasPrefix(accept, "application/vnd.ipld") || strings.HasPrefix(accept, "application/x-tar") || strings.HasPrefix(accept, "application/json") || - strings.HasPrefix(accept, "application/cbor") { + strings.HasPrefix(accept, "application/cbor") || + strings.HasPrefix(accept, "application/vnd.ipfs") { mediatype, params, err := mime.ParseMediaType(accept) if err != nil { return "", nil, err diff --git a/gateway/core/corehttp/gateway_handler_ipns_record.go b/gateway/core/corehttp/gateway_handler_ipns_record.go new file mode 100644 index 000000000..16d9663fa --- /dev/null +++ b/gateway/core/corehttp/gateway_handler_ipns_record.go @@ -0,0 +1,71 @@ +package corehttp + +import ( + "context" + "errors" + "fmt" + "net/http" + "strings" + "time" + + "github.com/gogo/protobuf/proto" + ipns_pb "github.com/ipfs/go-ipns/pb" + path "github.com/ipfs/go-path" + ipath "github.com/ipfs/interface-go-ipfs-core/path" + "go.uber.org/zap" +) + +func (i *gatewayHandler) serveIpnsRecord(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, logger *zap.SugaredLogger) { + if contentPath.Namespace() != "ipns" { + err := fmt.Errorf("%s is not an IPNS link", contentPath.String()) + webError(w, err.Error(), err, http.StatusBadRequest) + return + } + + key := contentPath.String() + key = strings.TrimSuffix(key, "/") + if strings.Count(key, "/") > 2 { + err := errors.New("cannot find ipns key for subpath") + webError(w, err.Error(), err, http.StatusBadRequest) + return + } + + rawRecord, err := i.api.Routing().Get(ctx, key) + if err != nil { + webError(w, err.Error(), err, http.StatusInternalServerError) + return + } + + var record ipns_pb.IpnsEntry + err = proto.Unmarshal(rawRecord, &record) + if err != nil { + webError(w, err.Error(), err, http.StatusInternalServerError) + return + } + + // Set cache control headers based on the TTL set in the IPNS record. If the + // TTL is not present, we use the Last-Modified tag. We are tracking IPNS + // caching on: https://github.com/ipfs/kubo/issues/1818. + // TODO: use addCacheControlHeaders once #1818 is fixed. + w.Header().Set("Etag", getEtag(r, resolvedPath.Cid())) + if record.Ttl != nil { + seconds := int(time.Duration(*record.Ttl).Seconds()) + w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", seconds)) + } else { + w.Header().Set("Last-Modified", time.Now().UTC().Format(http.TimeFormat)) + } + + // Set Content-Disposition + var name string + if urlFilename := r.URL.Query().Get("filename"); urlFilename != "" { + name = urlFilename + } else { + name = path.SplitList(key)[2] + ".ipns-record" + } + setContentDispositionHeader(w, name, "attachment") + + w.Header().Set("Content-Type", "application/vnd.ipfs.ipns-record") + w.Header().Set("X-Content-Type-Options", "nosniff") + + _, _ = w.Write(rawRecord) +} From 35c75a70a05a1220ea3138799e39c9402406a133 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 25 Jan 2023 11:18:40 +0100 Subject: [PATCH 671/674] refactor: prepare gateway for extraction This commit was moved from ipfs/kubo@5908bbc7242acd656fc138554949372d8dd75e2f --- gateway/core/corehttp/gateway.go | 97 +---- gateway/core/corehttp/gateway/README.md | 35 ++ .../core/corehttp/gateway/assets/README.md | 27 ++ .../assets/assets.go} | 180 +++++--- gateway/core/corehttp/gateway/assets/build.sh | 14 + .../corehttp/gateway/assets/dag-index.html | 67 +++ .../gateway/assets/directory-index.html | 99 +++++ .../corehttp/gateway/assets/knownIcons.txt | 65 +++ .../gateway/assets/src/dag-index.html | 66 +++ .../gateway/assets/src/directory-index.html | 98 +++++ .../corehttp/gateway/assets/src/icons.css | 403 ++++++++++++++++++ .../corehttp/gateway/assets/src/style.css | 212 +++++++++ .../core/corehttp/gateway/assets/test/main.go | 126 ++++++ gateway/core/corehttp/gateway/gateway.go | 107 +++++ .../handler.go} | 67 +-- .../handler_block.go} | 7 +- .../handler_car.go} | 7 +- .../handler_codec.go} | 18 +- .../handler_ipns_record.go} | 4 +- .../handler_tar.go} | 7 +- gateway/core/corehttp/gateway/handler_test.go | 28 ++ .../handler_unixfs.go} | 7 +- .../handler_unixfs__redirects.go} | 20 +- .../handler_unixfs_dir.go} | 25 +- .../handler_unixfs_file.go} | 7 +- .../core/corehttp/{ => gateway}/lazyseek.go | 2 +- .../corehttp/{ => gateway}/lazyseek_test.go | 2 +- gateway/core/corehttp/gateway_test.go | 25 -- gateway/core/corehttp/hostname.go | 7 +- 29 files changed, 1565 insertions(+), 264 deletions(-) create mode 100644 gateway/core/corehttp/gateway/README.md create mode 100644 gateway/core/corehttp/gateway/assets/README.md rename gateway/core/corehttp/{gateway_indexPage.go => gateway/assets/assets.go} (50%) create mode 100755 gateway/core/corehttp/gateway/assets/build.sh create mode 100644 gateway/core/corehttp/gateway/assets/dag-index.html create mode 100644 gateway/core/corehttp/gateway/assets/directory-index.html create mode 100644 gateway/core/corehttp/gateway/assets/knownIcons.txt create mode 100644 gateway/core/corehttp/gateway/assets/src/dag-index.html create mode 100644 gateway/core/corehttp/gateway/assets/src/directory-index.html create mode 100644 gateway/core/corehttp/gateway/assets/src/icons.css create mode 100644 gateway/core/corehttp/gateway/assets/src/style.css create mode 100644 gateway/core/corehttp/gateway/assets/test/main.go create mode 100644 gateway/core/corehttp/gateway/gateway.go rename gateway/core/corehttp/{gateway_handler.go => gateway/handler.go} (93%) rename gateway/core/corehttp/{gateway_handler_block.go => gateway/handler_block.go} (80%) rename gateway/core/corehttp/{gateway_handler_car.go => gateway/handler_car.go} (89%) rename gateway/core/corehttp/{gateway_handler_codec.go => gateway/handler_codec.go} (88%) rename gateway/core/corehttp/{gateway_handler_ipns_record.go => gateway/handler_ipns_record.go} (89%) rename gateway/core/corehttp/{gateway_handler_tar.go => gateway/handler_tar.go} (88%) create mode 100644 gateway/core/corehttp/gateway/handler_test.go rename gateway/core/corehttp/{gateway_handler_unixfs.go => gateway/handler_unixfs.go} (71%) rename gateway/core/corehttp/{gateway_handler_unixfs__redirects.go => gateway/handler_unixfs__redirects.go} (87%) rename gateway/core/corehttp/{gateway_handler_unixfs_dir.go => gateway/handler_unixfs_dir.go} (87%) rename gateway/core/corehttp/{gateway_handler_unixfs_file.go => gateway/handler_unixfs_file.go} (89%) rename gateway/core/corehttp/{ => gateway}/lazyseek.go (98%) rename gateway/core/corehttp/{ => gateway}/lazyseek_test.go (99%) diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go index 00c2f7483..7d7674ef0 100644 --- a/gateway/core/corehttp/gateway.go +++ b/gateway/core/corehttp/gateway.go @@ -1,66 +1,19 @@ package corehttp import ( - "context" "fmt" "net" "net/http" - "sort" - coreiface "github.com/ipfs/interface-go-ipfs-core" options "github.com/ipfs/interface-go-ipfs-core/options" - path "github.com/ipfs/interface-go-ipfs-core/path" version "github.com/ipfs/kubo" core "github.com/ipfs/kubo/core" coreapi "github.com/ipfs/kubo/core/coreapi" + "github.com/ipfs/kubo/core/corehttp/gateway" id "github.com/libp2p/go-libp2p/p2p/protocol/identify" "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" ) -type GatewayConfig struct { - Headers map[string][]string - Writable bool -} - -// NodeAPI defines the minimal set of API services required by a gateway handler -type NodeAPI interface { - // Unixfs returns an implementation of Unixfs API - Unixfs() coreiface.UnixfsAPI - - // Block returns an implementation of Block API - Block() coreiface.BlockAPI - - // Dag returns an implementation of Dag API - Dag() coreiface.APIDagService - - // Routing returns an implementation of Routing API. - // Used for returning signed IPNS records, see IPIP-0328 - Routing() coreiface.RoutingAPI - - // ResolvePath resolves the path using Unixfs resolver - ResolvePath(context.Context, path.Path) (path.Resolved, error) -} - -// A helper function to clean up a set of headers: -// 1. Canonicalizes. -// 2. Deduplicates. -// 3. Sorts. -func cleanHeaderSet(headers []string) []string { - // Deduplicate and canonicalize. - m := make(map[string]struct{}, len(headers)) - for _, h := range headers { - m[http.CanonicalHeaderKey(h)] = struct{}{} - } - result := make([]string, 0, len(m)) - for k := range m { - result = append(result, k) - } - - // Sort - sort.Strings(result) - return result -} - func GatewayOption(writable bool, paths ...string) ServeOption { return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { cfg, err := n.Repo.Config() @@ -78,14 +31,14 @@ func GatewayOption(writable bool, paths ...string) ServeOption { headers[http.CanonicalHeaderKey(h)] = v } - AddAccessControlHeaders(headers) + gateway.AddAccessControlHeaders(headers) offlineAPI, err := api.WithOptions(options.Api.Offline(true)) if err != nil { return nil, err } - gateway := NewGatewayHandler(GatewayConfig{ + gateway := gateway.NewHandler(gateway.Config{ Headers: headers, Writable: writable, }, api, offlineAPI) @@ -99,50 +52,6 @@ func GatewayOption(writable bool, paths ...string) ServeOption { } } -// AddAccessControlHeaders adds default headers used for controlling -// cross-origin requests. This function adds several values to the -// Access-Control-Allow-Headers and Access-Control-Expose-Headers entries. -// If the Access-Control-Allow-Origin entry is missing a value of '*' is -// added, indicating that browsers should allow requesting code from any -// origin to access the resource. -// If the Access-Control-Allow-Methods entry is missing a value of 'GET' is -// added, indicating that browsers may use the GET method when issuing cross -// origin requests. -func AddAccessControlHeaders(headers map[string][]string) { - // Hard-coded headers. - const ACAHeadersName = "Access-Control-Allow-Headers" - const ACEHeadersName = "Access-Control-Expose-Headers" - const ACAOriginName = "Access-Control-Allow-Origin" - const ACAMethodsName = "Access-Control-Allow-Methods" - - if _, ok := headers[ACAOriginName]; !ok { - // Default to *all* - headers[ACAOriginName] = []string{"*"} - } - if _, ok := headers[ACAMethodsName]; !ok { - // Default to GET - headers[ACAMethodsName] = []string{http.MethodGet} - } - - headers[ACAHeadersName] = cleanHeaderSet( - append([]string{ - "Content-Type", - "User-Agent", - "Range", - "X-Requested-With", - }, headers[ACAHeadersName]...)) - - headers[ACEHeadersName] = cleanHeaderSet( - append([]string{ - "Content-Length", - "Content-Range", - "X-Chunked-Output", - "X-Stream-Output", - "X-Ipfs-Path", - "X-Ipfs-Roots", - }, headers[ACEHeadersName]...)) -} - func VersionOption() ServeOption { return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { diff --git a/gateway/core/corehttp/gateway/README.md b/gateway/core/corehttp/gateway/README.md new file mode 100644 index 000000000..102121d92 --- /dev/null +++ b/gateway/core/corehttp/gateway/README.md @@ -0,0 +1,35 @@ +# IPFS Gateway + +> IPFS Gateway HTTP handler. + +## Documentation + +* Go Documentation: https://pkg.go.dev/github.com/ipfs/kubo/core/corehttp/gateway + +## Example + +```go +// Initialize your headers and apply the default headers. +headers := map[string][]string{} +gateway.AddAccessControlHeaders(headers) + +conf := gateway.Config{ + Writable: false, + Headers: headers, +} + +// Initialize a NodeAPI interface for both an online and offline versions. +// The offline version should not make any network request for missing content. +ipfs := ... +offlineIPFS := ... + +// Create http mux and setup gateway handler. +mux := http.NewServeMux() +gwHandler := gateway.NewHandler(conf, ipfs, offlineIPFS) +mux.Handle("/ipfs/", gwHandler) +mux.Handle("/ipns/", gwHandler) + +// Start the server on :8080 and voilá! You have an IPFS gateway running +// in http://localhost:8080. +_ = http.ListenAndServe(":8080", mux) +``` \ No newline at end of file diff --git a/gateway/core/corehttp/gateway/assets/README.md b/gateway/core/corehttp/gateway/assets/README.md new file mode 100644 index 000000000..25d1a35e8 --- /dev/null +++ b/gateway/core/corehttp/gateway/assets/README.md @@ -0,0 +1,27 @@ +# Required Assets for the Gateway + +> DAG and Directory HTML for HTTP gateway + +## Updating + +When making updates to the templates, please note the following: + +1. Make your changes to the (human-friendly) source documents in the `src` directory. +2. Before testing or releasing, go to `assets/` and run `go generate .`. + +## Testing + +1. Make sure you have [Go](https://golang.org/dl/) installed +2. Start the test server, which lives in its own directory: + +```bash +> cd test +> go run . +``` + +This will listen on [`localhost:3000`](http://localhost:3000/) and reload the template every time you refresh the page. Here you have two pages: + +- [`localhost:3000/dag`](http://localhost:3000/dag) for the DAG template preview; and +- [`localhost:3000/directory`](http://localhost:3000/directory) for the Directory template preview. + +If you get a "no such file or directory" error upon trying `go run .`, make sure you ran `go generate .` to generate the minified artifact that the test is looking for. diff --git a/gateway/core/corehttp/gateway_indexPage.go b/gateway/core/corehttp/gateway/assets/assets.go similarity index 50% rename from gateway/core/corehttp/gateway_indexPage.go rename to gateway/core/corehttp/gateway/assets/assets.go index b0db8ac1a..2e442dd13 100644 --- a/gateway/core/corehttp/gateway_indexPage.go +++ b/gateway/core/corehttp/gateway/assets/assets.go @@ -1,28 +1,131 @@ -package corehttp +//go:generate ./build.sh +package assets import ( + "embed" + "io" + "io/fs" + "net" + "strconv" + "html/template" "net/url" "path" "strings" + "github.com/cespare/xxhash" + ipfspath "github.com/ipfs/go-path" - "github.com/ipfs/kubo/assets" ) -// structs for directory listing -type listingTemplateData struct { +//go:embed dag-index.html directory-index.html knownIcons.txt +var asset embed.FS + +// AssetHash a non-cryptographic hash of all embedded assets +var AssetHash string + +var ( + DirectoryTemplate *template.Template + DagTemplate *template.Template +) + +func init() { + initAssetsHash() + initTemplates() +} + +func initAssetsHash() { + sum := xxhash.New() + err := fs.WalkDir(asset, ".", func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + + if d.IsDir() { + return nil + } + + file, err := asset.Open(path) + if err != nil { + return err + } + defer file.Close() + _, err = io.Copy(sum, file) + return err + }) + if err != nil { + panic("error creating asset sum: " + err.Error()) + } + + AssetHash = strconv.FormatUint(sum.Sum64(), 32) +} + +func initTemplates() { + knownIconsBytes, err := asset.ReadFile("knownIcons.txt") + if err != nil { + panic(err) + } + knownIcons := make(map[string]struct{}) + for _, ext := range strings.Split(strings.TrimSuffix(string(knownIconsBytes), "\n"), "\n") { + knownIcons[ext] = struct{}{} + } + + // helper to guess the type/icon for it by the extension name + iconFromExt := func(name string) string { + ext := path.Ext(name) + _, ok := knownIcons[ext] + if !ok { + // default blank icon + return "ipfs-_blank" + } + return "ipfs-" + ext[1:] // slice of the first dot + } + + // custom template-escaping function to escape a full path, including '#' and '?' + urlEscape := func(rawUrl string) string { + pathURL := url.URL{Path: rawUrl} + return pathURL.String() + } + + // Directory listing template + dirIndexBytes, err := asset.ReadFile("directory-index.html") + if err != nil { + panic(err) + } + + DirectoryTemplate = template.Must(template.New("dir").Funcs(template.FuncMap{ + "iconFromExt": iconFromExt, + "urlEscape": urlEscape, + }).Parse(string(dirIndexBytes))) + + // DAG Index template + dagIndexBytes, err := asset.ReadFile("dag-index.html") + if err != nil { + panic(err) + } + + DagTemplate = template.Must(template.New("dir").Parse(string(dagIndexBytes))) +} + +type DagTemplateData struct { + Path string + CID string + CodecName string + CodecHex string +} + +type DirectoryTemplateData struct { GatewayURL string DNSLink bool - Listing []directoryItem + Listing []DirectoryItem Size string Path string - Breadcrumbs []breadcrumb + Breadcrumbs []Breadcrumb BackLink string Hash string } -type directoryItem struct { +type DirectoryItem struct { Size string Name string Path string @@ -30,33 +133,33 @@ type directoryItem struct { ShortHash string } -type breadcrumb struct { +type Breadcrumb struct { Name string Path string } -func breadcrumbs(urlPath string, dnslinkOrigin bool) []breadcrumb { - var ret []breadcrumb +func Breadcrumbs(urlPath string, dnslinkOrigin bool) []Breadcrumb { + var ret []Breadcrumb p, err := ipfspath.ParsePath(urlPath) if err != nil { - // No breadcrumbs, fallback to bare Path in template + // No assets.Breadcrumbs, fallback to bare Path in template return ret } segs := p.Segments() contentRoot := segs[1] for i, seg := range segs { if i == 0 { - ret = append(ret, breadcrumb{Name: seg}) + ret = append(ret, Breadcrumb{Name: seg}) } else { - ret = append(ret, breadcrumb{ + ret = append(ret, Breadcrumb{ Name: seg, Path: "/" + strings.Join(segs[0:i+1], "/"), }) } } - // Drop the /ipns/ prefix from breadcrumb Paths when directory + // Drop the /ipns/ prefix from assets.Breadcrumb Paths when directory // listing on a DNSLink website (loaded due to Host header in HTTP // request). Necessary because the hostname most likely won't have a // public gateway mounted. @@ -67,14 +170,14 @@ func breadcrumbs(urlPath string, dnslinkOrigin bool) []breadcrumb { ret[i].Path = strings.Replace(crumb.Path, prefix, "", 1) } } - // Make contentRoot breadcrumb link to the website root + // Make contentRoot assets.Breadcrumb link to the website root ret[1].Path = "/" } return ret } -func shortHash(hash string) string { +func ShortHash(hash string) string { if len(hash) <= 8 { return hash } @@ -83,7 +186,7 @@ func shortHash(hash string) string { // helper to detect DNSLink website context // (when hostname from gwURL is matching /ipns/ in path) -func hasDNSLinkOrigin(gwURL string, path string) bool { +func HasDNSLinkOrigin(gwURL string, path string) bool { if gwURL != "" { fqdn := stripPort(strings.TrimPrefix(gwURL, "//")) return strings.HasPrefix(path, "/ipns/"+fqdn) @@ -91,43 +194,10 @@ func hasDNSLinkOrigin(gwURL string, path string) bool { return false } -var listingTemplate *template.Template - -func init() { - knownIconsBytes, err := assets.Asset.ReadFile("dir-index-html/knownIcons.txt") - if err != nil { - panic(err) - } - knownIcons := make(map[string]struct{}) - for _, ext := range strings.Split(strings.TrimSuffix(string(knownIconsBytes), "\n"), "\n") { - knownIcons[ext] = struct{}{} - } - - // helper to guess the type/icon for it by the extension name - iconFromExt := func(name string) string { - ext := path.Ext(name) - _, ok := knownIcons[ext] - if !ok { - // default blank icon - return "ipfs-_blank" - } - return "ipfs-" + ext[1:] // slice of the first dot - } - - // custom template-escaping function to escape a full path, including '#' and '?' - urlEscape := func(rawUrl string) string { - pathURL := url.URL{Path: rawUrl} - return pathURL.String() - } - - // Directory listing template - dirIndexBytes, err := assets.Asset.ReadFile("dir-index-html/dir-index.html") - if err != nil { - panic(err) +func stripPort(hostname string) string { + host, _, err := net.SplitHostPort(hostname) + if err == nil { + return host } - - listingTemplate = template.Must(template.New("dir").Funcs(template.FuncMap{ - "iconFromExt": iconFromExt, - "urlEscape": urlEscape, - }).Parse(string(dirIndexBytes))) + return hostname } diff --git a/gateway/core/corehttp/gateway/assets/build.sh b/gateway/core/corehttp/gateway/assets/build.sh new file mode 100755 index 000000000..531bbfc02 --- /dev/null +++ b/gateway/core/corehttp/gateway/assets/build.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -euo pipefail + +function build() { + rm -f $1 + sed '/ ./base-html.html + (echo "") > ./minified-wrapped-style.html + sed '/<\/title>/ r ./minified-wrapped-style.html' ./base-html.html > ./$1 + rm ./base-html.html && rm ./minified-wrapped-style.html +} + +build "directory-index.html" +build "dag-index.html" diff --git a/gateway/core/corehttp/gateway/assets/dag-index.html b/gateway/core/corehttp/gateway/assets/dag-index.html new file mode 100644 index 000000000..5bba8f5c0 --- /dev/null +++ b/gateway/core/corehttp/gateway/assets/dag-index.html @@ -0,0 +1,67 @@ + +{{ $root := . }} + + + + + + + + + + + + + + + + + +{{ .Path }} + + + + +
+
+

CID: {{.CID}}
+ Codec: {{.CodecName}} ({{.CodecHex}})

+
+
+ + + + + + + +
+

Preview as JSON
(application/json)

+
+

Or download as: +

+

+
+
+
+ + diff --git a/gateway/core/corehttp/gateway/assets/directory-index.html b/gateway/core/corehttp/gateway/assets/directory-index.html new file mode 100644 index 000000000..d861cb657 --- /dev/null +++ b/gateway/core/corehttp/gateway/assets/directory-index.html @@ -0,0 +1,99 @@ + +{{ $root := . }} + + + + + + + + + + + + + + + + + +{{ .Path }} + + + + +
+
+
+ + Index of + {{ range .Breadcrumbs -}} + /{{ if .Path }}{{ .Name }}{{ else }}{{ .Name }}{{ end }} + {{- else }} + {{ .Path }} + {{ end }} + + {{ if .Hash }} +
+ {{ .Hash }} +
+ {{ end }} +
+ {{ if .Size }} +
+  {{ .Size }} +
+ {{ end }} +
+
+ + {{ if .BackLink }} + + + + + + + {{ end }} + {{ range .Listing }} + + + + + + + {{ end }} +
+
 
+
+ .. +
+
 
+
+ {{ .Name }} + + {{ if .Hash }} + + {{ .ShortHash }} + + {{ end }} + {{ .Size }}
+
+
+ + diff --git a/gateway/core/corehttp/gateway/assets/knownIcons.txt b/gateway/core/corehttp/gateway/assets/knownIcons.txt new file mode 100644 index 000000000..c110530ea --- /dev/null +++ b/gateway/core/corehttp/gateway/assets/knownIcons.txt @@ -0,0 +1,65 @@ +.aac +.aiff +.ai +.avi +.bmp +.c +.cpp +.css +.dat +.dmg +.doc +.dotx +.dwg +.dxf +.eps +.exe +.flv +.gif +.h +.hpp +.html +.ics +.iso +.java +.jpg +.jpeg +.js +.key +.less +.mid +.mkv +.mov +.mp3 +.mp4 +.mpg +.odf +.ods +.odt +.otp +.ots +.ott +.pdf +.php +.png +.ppt +.psd +.py +.qt +.rar +.rb +.rtf +.sass +.scss +.sql +.tga +.tgz +.tiff +.txt +.wav +.wmv +.xls +.xlsx +.xml +.yml +.zip diff --git a/gateway/core/corehttp/gateway/assets/src/dag-index.html b/gateway/core/corehttp/gateway/assets/src/dag-index.html new file mode 100644 index 000000000..7a42ef6be --- /dev/null +++ b/gateway/core/corehttp/gateway/assets/src/dag-index.html @@ -0,0 +1,66 @@ + +{{ $root := . }} + + + + + + + + + + + + + + + + + + + +{{ .Path }} + + + +
+
+

CID: {{.CID}}
+ Codec: {{.CodecName}} ({{.CodecHex}})

+
+
+ + + + + + + +
+

Preview as JSON
(application/json)

+
+

Or download as: +

+

+
+
+
+ + diff --git a/gateway/core/corehttp/gateway/assets/src/directory-index.html b/gateway/core/corehttp/gateway/assets/src/directory-index.html new file mode 100644 index 000000000..109c7afbf --- /dev/null +++ b/gateway/core/corehttp/gateway/assets/src/directory-index.html @@ -0,0 +1,98 @@ + +{{ $root := . }} + + + + + + + + + + + + + + + + + + + +{{ .Path }} + + + +
+
+
+ + Index of + {{ range .Breadcrumbs -}} + /{{ if .Path }}{{ .Name }}{{ else }}{{ .Name }}{{ end }} + {{- else }} + {{ .Path }} + {{ end }} + + {{ if .Hash }} +
+ {{ .Hash }} +
+ {{ end }} +
+ {{ if .Size }} +
+  {{ .Size }} +
+ {{ end }} +
+
+ + {{ if .BackLink }} + + + + + + + {{ end }} + {{ range .Listing }} + + + + + + + {{ end }} +
+
 
+
+ .. +
+
 
+
+ {{ .Name }} + + {{ if .Hash }} + + {{ .ShortHash }} + + {{ end }} + {{ .Size }}
+
+
+ + diff --git a/gateway/core/corehttp/gateway/assets/src/icons.css b/gateway/core/corehttp/gateway/assets/src/icons.css new file mode 100644 index 000000000..dcdbd3cd9 --- /dev/null +++ b/gateway/core/corehttp/gateway/assets/src/icons.css @@ -0,0 +1,403 @@ +/* Source - fileicons.org */ + +.ipfs-_blank { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAWBJREFUeNqEUj1LxEAQnd1MVA4lyIEWx6UIKEGUExGsbC3tLfwJ/hT/g7VlCnubqxXBwg/Q4hQP/LhKL5nZuBsvuGfW5MGyuzM7jzdvVuR5DgYnZ+f99ai7Vt5t9K9unu4HLweI3qWYxI6PDosdy0fhcntxO44CcOBzPA7mfEyuHwf7ntQk4jcnywOxIlfxOCNYaLVgb6cXbkTdhJXq2SIlNMC0xIqhHczDbi8OVzpLSUa0WebRfmigLHqj1EcPZnwf7gbDIrYVRyEinurj6jTBHyI7pqVrFQqEbt6TEmZ9v1NRAJNC1xTYxIQh/MmRUlmFQE3qWOW1nqB2TWk1/3tgJV0waVvkFIEeZbHq4ElyKzAmEXOx6gnEVJuWBzmkRJBRPYGZBDsVaOlpSgVJE2yVaAe/0kx/3azBRO0VsbMFZE3CDSZKweZfYIVg+DZ6v7h9GDVOwZPw/PoxKu/fAgwALbDAXf7DdQkAAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-_page { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmhJREFUeNpsUztv01AYPfdhOy/XTZ80VV1VoCqlA2zQqUgwMEErWBALv4GJDfEDmOEHsFTqVCTExAiiSI2QEKJKESVFFBWo04TESRzfy2c7LY/kLtf2d8+555zvM9NaI1ora5svby9OnbUEBxgDlIKiWjXQeLy19/X17sEtcPY2rtHS96/Hu0RvXXLz+cUzM87zShsI29DpHCYt4E6Box4IZzTnbDx7V74GjhOSfwgE0H2638K9h08A3iHGVbjTw7g6YmAyw/BgecHNGGJjvfQhIfmfIFDAXJpjuugi7djIFVI4P0plctgJQ0xnFe5eOO02OwEp2VkhSCnC8WOCdqgwnzFx4/IyppwRVN+XYXsecqZA1pB48ekAnw9/4GZx3L04N/GoTwEjX4cNH5vlPfjtAIYp8cWrQutxrC5Mod3VsXVTMFSqtaE+gl9dhaUxE2tXZiF7nYiiatJ3v5s8R/1yOCNLOuwjkELiTbmC9dJHpIaGASsDkoFQGJQwHWMcHWJYOmUj1OjvQotuytt5nHMLEGkCyx6QU384jwkUAd2sxJbS/QShZtg/8rHzzQOzSaFhxQrA6YgQMQHojCUlgnCAAvKFBoXXaHfArSCZDE0gyWJgFIKmvUFKO4MUNIk2a4+hODtDUVuJ/J732AKS6ZtImdTyAQQB3bZN8l9t75IFh0JMUdVKsohsUPqRgnka0tYgggYpCHkKGTsHI5NOMojB4iTICCepvX53AIEfQta1iUCmoTiBmdEri2RgddKFhuJoqb/af/yw/d3zTNM6UkaOfis62aUgddAbnz+rXuPY+Vnzjt9/CzAAbmLjCrfBiRgAAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-aac { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnhJREFUeNp0Uk1PE0EYftruVlvAUkhVEPoBcsEoLRJBY01MPHjCs3cvogcT/4qJJN5NvHhoohcOnPw4YEGIkCh+oLGBKm3Z7nZ3dme2vjOhTcjiJJvZzPvOM8/HG2q325Dr3kLp7Y1ibpIxjs4KhQBZfvV6s7K5Vb0bjeof5ZlcGysP1a51mifODybvzE8mzCbrAoTDIThMoGXZiZ4YSiurf+Z1XeuCqJ7Oj+sK3jQcNAmg8xkGQ71mYejcAB49vpmeuzJccl0+dUj6KIAvfHCPg3N+uAv4vg9BOxcCmfEzuP/genpmeqhEMgude10Jwm+DuUIyUdTlqu2byoMfX/dRermBeExHsTiWNi3+lMpzRwDki8zxCIATmzbevfmClukiP5NFhJgwkjeRTeLShdOoVJqnAgwkgCAZ6+UdLC9twjQZ8pdzioFkZBHY3q6B3l4dJEEEPOCeD4cYVH7Xsf15F+FImC775INAJBJSkVoWo0QY9YqgiR4ZZzRaGBkdwK3bFxGLRZUfB3Rm2x4x9CGtsUxH9QYkKICDFuLxKAozGZwdTqBRs2FbLlXbiPdECMCHadj/AaDXZNFqedCIvnRcS4UpRo7+hC5zUmw8Ope9wUFinvpmZ7NKt2RTmB4hKZo6n8qP4Oq1HBkKlVYAQBrUlziB0XQSif4YmQhksgNIJk9iaLhPaV9b/Um+uJSCdzyDbGZQRSkvjo+n4JNxubGUSsCj+ZCpODYjkGMAND2k7exUsfhkCd+29yguB88Wl7FW/o6tT7/gcXqAgGv7hhx1LWBireHVn79YP6ChQ3njb/eFlfWqGqT3H3ZlGIhGI2i2UO/U/wkwAAmoalcxlNA1AAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-ai { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAk5JREFUeNpsU01vElEUPTPzZqBAQaSFQiJYUmlKYhoTF41L3Tbu/Q/+AvsX3Bp/gPsuWLrqyqQ7TUxMtAvF1tYGoXwNw7wv7zwYgtKX3Lw379575p5z77O01ohW+/DVh8zj7aYKhflGdG9ZsGwLNydffgVfr19YHvsEa+Zu/nxndob5StQK+dyzvZzyw/gKlmMj7IygFM+xvNcanp4/t5dAomXHBy2UUBOO2MAl/B9/cPb6PULuoHx0WM0e3GvpUOxD3wZAJWutZqYUYmqpSg5OMgH3YQObL59W0/ullpryR3HegkKEqiWBSGV4R3vQ7sIhScTZFTpHx3A215B5sluVY/WWMg7+ATB/lcLsKpTonHzD+OMFEuTz8ikkt9Kwt9YJZB38cpBdoQAZJdLvCGByfoPB6Xdk90pYy6Xg3c/DaWwArg09DaG5lCsUFN0pckZAojdC8m4auBqaALuSgez7VB1RtDSUWOQvUaBLFUzJBMJ2DwmPgd1Jwm0WoSgJfjDvrTKxtwAIyEkAOQ5hU//Zdg5uowDlUNMnwZLW0sSuUuACYhwQRwFvJxupCjEYUUccOkoaKmdOlZnY1TkgAcXAhxhOwLsDsHoN3u4O5JTDfVCH6I9nfjId3gIgSUATFJk/hVevGtOMwS0XwQ3AzB/FrlKg8Q27I2javVoZrFgwD4qVipAEyMlnaFArzaj/D0DiMXlJAFQyK2r8fnMMRZp4lQ1MaSL5tU/1kqAkMCh2tYI+7+kh70cjPbr4bEZ51jZr8TJnB9PJXpz3V4ABAPOQVJn2Q60GAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-aiff { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAohJREFUeNpkU9tqE1EUXZmZpE3aTBLbJFPTtFURtSCthr7UCyKKFJ/9An3og6Ag/oXfoUj7og9asCBYKT6UIPHaWtpq7NU2aZK5z5wZ9xxMpMwZDuewz9prr32ZiO/7CNaDx3OLt6fOjBqGg/aKRCIInp8+KzfKH7fudnVF58nE16el+/yU2mBFSWZKpWJKVc0OgUBo02K4NDmU6o75Mx+Wdu9IUXFeiOA/pn1xHeYaugVDdzpbp91qGlAKGTx8dC19/Wpxhjnsxj/RRwk85hGJC9d1O6fneWAuoztDYSSLe9OT6SuXB2ccx73Z9uukwDwfls1g0xZIY/Ad/Gnyt/XVfbyYrSDRE8PExHB6/8B6QuaxIwRBFMt0iIAiMx+LCys8jfGJEUik2WpZOD2SQf9oDtVqQwopCAiY66FS/om3b75CVS2MlU7AJ2WiJBCZjZ2dJuRkDJZFwFAR7UCBja3fNfxY2YEoCtRCj9em3Tpds6FpJseGCBxS0GgYGBzqw62p84gnYnAI2CSbSbPhEpFAaE2zODaUAlWWwDoS5DheGqbWpVE/0CmqCY9qkEyINBceb2uADRNQ8bSWAVVzIFKomCQim+0luS4yKYlsHlRyZo7EsSEC23K5vAsXh/H92zZkuRvxeBS5nEx2yp2KqhxPoV5TYS/8CtdApylM9sZQKKSQzyeRTseRV2QoAzIYY8jme5DN9fI0dQoUIjANGydP9VM7PZw9p/AiBpNYrdbw/t0yTJqRtdU9UrfJCUMpSJIgbWzsYe51BcViHzLHeqCRqhZ1YX1tFwNfZBxS9O3NWkAcHqR606k/n/3coKAoV/Y7vQ/OYCZevlrmv3c0GsFh06u3/f4KMABvSWfDHmbK2gAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-avi { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAm1JREFUeNpsU8tu00AUPXZcN0nzTpq2KQ3pAwkIAnWHqCoeexBb+AQ+ABZ8A2s+AIkdm266QUJIFWKBkHg1KpRHi5omJGkbJ3bGHj+4M1EQrTvSyGPPueeec++1EgQBxHp+/9mbyuriRZdxjJaiKBD3W+u1+p9a856max+gDO8ebT+WT20Ezi9NZi/crqadvn2MQBAGfpCOpqNru2937vxPIpY6Onjccx3Twck9MBiSU0ncfHirXFmZX3Md9wqCUwiEVN/zaQfHt0vfbBe5uQyuPVgpl5Zn11ybL4/i/lkICOw5niQRGQShoiqI6Bo43W2ub8n3hRtLZT7gTynk6gkCX9gAOxpAnxhHZDwC1/aI1EViJolu/QhKRMHZ1UX0Gr1USIEn5FPWHy+/wTokkrQOq2vBaHZBN4hmY9Jwfr4An/teiEB45ZZDwDiMhoExT0N+sYDCuUkkplLIlXP4/XEXdo+RUhdhBSSfUwtVTUG8MIHK9QVqI7D/uY6vr2pwmCPrkz+Tk9gwARWQ9WxppbXZhNnpw+ya4A5HZi6L4lIR8WyCcL6sTZiAWjWgAmpxkn5+kqTamK6WkCwmERmLDLvjB0ML9ikWXPLFuozYOap3L8HYN6DHdbS/d5CeTVBndBz87FCBLYkNTyIjBQemnIEsSY5lYrK1+UoWcToLMjEHAyIQ2BCBSx/NVh+ZUhrqmEqBebS3WyhdLg0zt/ugAaIklsSGLHCLa6zDMGhZ2HjyGsnpFPqNHnY2fmHv3R5SMymYbROszSQ2ROAY9qHiofvlxSc5xsKKqqnY3diRE9h4X5d/pzg7lnM4ivsrwADe9Wg/CQJgFAAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-bmp { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmZJREFUeNp0U+1rUlEY/13v9YV0vq2wttI5CdpL9aEGBZUDv0df668I6n+or0UQ/RuuD0EgVDAZrsKF4AR1a6COKW5qXvXec27PuVeda3bgcF6e8/ye5/d7niMZhgExnK9fbTrm5pbBGMZDkgCyq+VyhTUaT6Eo2ZHJePPWXJXRhez3B1yxmM/QdctXUSCgtV4Py4CvY3cky4e1x5DlLCaGbbzjXDcousG5OQe5HPRSCQPK4PpsEM/XH4WvhS4noeu3JwHGGRiULhsMoKZS4I0GtEIB9mgULJGA0+9DPBpBT7sffvf1W/Lg6OgJufw8C0CRGEXWazUwiiyFQjA8bsjVKjaJzovMD/Q5gxyJhG2cvyeXe2cAuADQNGBmBvLaGuTFRaDfh31lBTWi9pumjbK0B4JQul3vOQpM8JdskOLrdCvDcDjAsjtg5TIkoiKLaokMNR2cnZbqNAMycqG7XbHKR2fMzwO/dsxSwu0BiBJsNsv2LwAJAJCI5ux2gXYbqNetcz5PoORI1cDS0n8AxGW7A+zvEYBKZ2ZlcsEtJLbedMjePBaCTQMghx45ulyWkzxMVUQ2RMQhLfFO16YAqCrixPnm6iqKrRb2W23EfF4cUNSrHg90cr7hDyB33MTnSmUKALVs4uIlROjxg+AsPhGVl3fuIl2tIOB0Ya91gkOi9mxhAal0ekork1ic/kGLBORMxy2K1qS9V1ZQbNThIj2EGh+2tsyOnSai8r1UxMNIBB+LRTTULr4Uds0K1tU/uOLxIrmbNz8XXSrnASSpubG9fbKRyVh1n/zSw29t9oC1b47MfwUYAAUsLiWr4QUJAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-c { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAcxJREFUeNqEUk1rE0EYfmZnkgoJCaGNCehuJTalhJZSUZB66a0HwXsP/Qn+FM+9+hty0LNYCr2I7UVLIW0Fc0hpQpSS7O7MrO9MspuvVV8YMnk/nn2e5x0WRRFMvP/w6WSz5jbi/9NxfP693Wp3DrJCnMW5d28P7a+IE15lufR8o1ZEStwPhkWHsWbrZ+eNEPxsuubEF6m0TBv2Q4liPofXuzveulttSqW2UwH+GjqC0horpSL2njU89+FyMwjlTlxOJMTa9ZQHzDQIjgwdom9zLzfXPc75kbnOAswBJTlC2XrqQRMLxhi442DgB4UFBhgPpm3B5pgBHNUUxQKAHs8pHf3TEuFMetM9IKr/i2mWMwC0SnuSFTG2YKyppwKYVdGO7TFhzBqGIenVeLCUtfURgErucx5ECKREKBU4d3B718PHz6cICGT/1Qs8qpQtGOdyhtGEARWDQFqQJSeDL98u4VbLaKw9IRAJPwjtoJGlVAoDQ800+fRFTTYXcjlcXN2g++s36p5Lzzlve1iEROa8BGH1EbrSAeqrjxEqicHQt8/YSDHMpaNs7wJAp9vvfb287idboAVkRAa5fBYXP9rxO4Mgf0xvPPdHgAEA8OoGd40i1j0AAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-cpp { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAfJJREFUeNqEUs9PE0EU/mZ2WgqpXX+QIDFdalVslh8NlAOQaOKFAwfvHvwT/FM8e/U/MOnBmwcj8WD0ACEGghIkbU0baaEthe3OTJ0ZWV26q37JZt68ee/b9733yGAwgMbL12/fz+azbnAPY2Nrt7Zfqz9JMrYZ+J4/e2pOFjiciRvXlgp5GzHonXk2o6S8V6k/TjBrM/xGA4MLyeOSPZ8jkx7D+uqCU3Amy1yIYizB36AlCSkwfjWDR4uu40yMl/s+XwjeWThQQ4Z6QNSnSkYykcDXasP4lmfvOZTSF9q8TDBEFPbN5bOqCglCCCxK0TvvZyIV4CIxbgpC+4gm/PUmFCIE8iJPyME/e8Lon9j4HvyHYLjKSwRCSEUgf9+15mFbx8QS6CZJMzJ9SlBCwX3fJDLG4PX7ykcwkmQmJtpEhWa7g1dvNlSwjwelebz7tAXLolh0p/Fxe9fErK2WDFGEgKjxfNjegX0lDTc/heNuF99/HGEslcKXwyoazWNDdlCr6+DoJgrBzdI0T9rYO6yg2zszMlaKM3Dv5OBzbuyZuzm1B16U4Nzz2f3cFOx0Gq12F9cztpExncsqYoaHpSIKtx0zJdVIFpHQ6py29muNk1uTN829o/6SHEnh80HFaE6NjmLnWxUJy1LyTltB3k8BBgBeEeQTiWRskAAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-css { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAk1JREFUeNpsUktvUlEQ/u5DoCLl/RAKKKUvWmIxjYntQtcu3LvwJ/hTXLt16coFC2PsojEaMKZtCqFaTdGmjbS0CG3By+vei3OOBSGXSU7uzNyZ78z3zRF6vR6YvXzzPrMUCyf68bB9zO+VfpROn5hkOdfPPX/2lH/lfiLidztX5mN2jLGG0rKLENIE8liWpdzwP7HvqJqujmvudFU4bFY8Wk1FZsOBtKppd8YCDNu77CZevd3gflfTUFcUhP0ePLibiIR9rjSBpgwAfe4dVcV6dhtep4PH5msylGYLrzeybErcT85FYiH/CyPAf74gObC2vMhzsiRhPhpC6eQUM+EA1pJzILEnjRSuJsju7MJqsUCSRei6Dp3yXqcdGlHZ/rLPazQWGCn8+6YW4pAkEW0SjzUzanWlCa/LgcR0lNfovTEi6lcIkzesnM/R8RlN0INGp3h4DHoDsE5YRvQyiKiRSMzikRAOS2WoqoZWu41K7RwzlOOAVDMMMHhIGvFlRxJFrKYW0ep0IYgC3SDh4b1lTJjNfENsrazOAMAw680mPuW+8lFno1P4XDigRhOiwQAyJK7TbsNS/PaA7giAIAhYz2yRgBIfsVA8wIetPG6FAqhdNrC5u0f+TUyHgyMTDDToEt/ftQsEvW4EPG5OZcrvw0mlimarTXkPfpXPcNlQoGtjACgpryQXsPNtH/nvRXqBJpoKHMzGNkNB0Odls7LNyAYKpUq1dt1iuvB7fRDp9kr9D1xOFwkpoksXusmXaZWFn0coV89r/b6/AgwAkUENaQaRxswAAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-dat { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAfVJREFUeNqMU01PE1EUPe/Na0uptmlASg3MoiZgCA3hQ8PHAjbqwsS9C3+CP8W1W/+BSReyYUPwI4QAVkAgUEgIbVIg1FZb2pl5b3zv2cHBjsaTTOa+e989OffcGeK6LhTevFv+OJoZHPHOfrz/sl86KpWfhxnLe7lXL1/oN/MSZqonOXU/k0AA6lfNhEFIrlAsP2PMyPtr1AscLpyg5pbtIHErhqez4+awmc45nI8FEvwNaiQuBHqTcSxMjJhmX0/Osp1xr878FxWEzwMinxAzEA4xFIpnOjedHTKpYbxW4U2CP4j8uWxmUKsghMCgFI2mFe9QgHZj0Ba4yhFF+KvGJToIRLuPC/efnjD6+26wB1Lq/xgbSCBXKeWJG/OTdky8cWTdT3C9RmWSGk2XCLlWo4xTNbfN5qh7PpXM72GjZeHt0gpq9QbmH4whGb+NpU/reDQ7hcWVVXxvXOHxzCQopQEKXKEbL6o1ZIcy+LC5g62DY2zsHeC0fA4zndIrHOjvg2XbAQRSfsuy9XxC2qzi/H5B6/68W0AsGkW0KyJPBLbDO0fg3JX/CUM81i0bD6WKe6j9qOPJ3EMcF0tSNsFA6g6alqW+VtZBUL78Vtk+Oqne7U9rs5qOQCjSheJFBeFIFOfVujSUYu3rIc4uqxWv76cAAwCwbvRb3SgYxQAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-dmg { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAn9JREFUeNpsU01rE1EUPe9lkk47yWTStCmtNhFSWxos2EXVhSsRcasuxYV05V8Qf4DgD/AvCK5EV1oFI7iUBqmCNdDvppq2mWSSzEzy3vPOpFFq+uDNfR/3nnvueXeYUgrBWH1/9/NE7k5BKRnuRcfF2qdnmJq9DeF9tQ+2isuMsxXGWHh/a1mEVsPJSI5fSU3OPEj291IIlN49RXz0KqzEQjIeZS/L5Y/3wPGhDxIM/i/A7fZWgVG0t5EaG0ZUa0JGM8gvPrZmLt58QYwv91mfAqCIE0sAqgumBFITGQzpUYhuF0KfRa7waDyXXXolpVrsh/0tgSLDr5I+wUZo1UHCSkAficPzY6juFSmbRPrC/azjq+fkcO00gAqoU7B0ETKkfWbuCTjTYeq5oESAauexcTScX+ZACWFm0YQSLZKhHdr67+/wW0e0dgjYo3sCEXXybYtBDVSHLp2es3IpsILS24c42lkBg6DzRjgRzCDZ/xr0GNRJwwYiWgzt+hYMawleu0V3wbkT+kUirOc7IGJAz68R/Qak1BAlx3hqASPGBJRXpXOv58dkz3eAgQoOm4hyj57NgZm0MHvpBmK6QdUdg/DAg9cRkhicBSDaKJdeo1bdxmR2DtWDDUxl51HZ+QHTysD3XdQO95Gfv06aeGcAdBrY3Chi8lwO3768QWX7J5q1XWyVSxgajiOXLyBG2hzurRKV9lmt7ISNkkjo6HhNyjoK+2gXRsKE57ZIE2ot10Z1fz0Ue4ABVw3NMjnW14rInh8jTYywoTg3EOFpOM4mXNfH9PQUfGlrAwBOs3I8ljbtuMWhRWzIIPrkn+GcYcgIWEowbZ+0qB334/4IMADESjqbnHbH0gAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-doc { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAppJREFUeNpsU79PFEEU/mZ39vZu77g7DokcP04BBSUmiEKCSCxs7Ei00JAYO2NlTKyMrX+CJhaGwopSQ0dMtFEsbDRBgiZEQIF4IHcg+2t2Z8eZ5QDlnM1mZ9+8973vfe8NEUJArfSNhzPG0VIfeIiDRSDkw1cWVt3N8rhG6SdSO2Gvn8dfuueqZwuNZqk3Jxg7iNcIfBbgXD6ZC8u5qffzX8eoYeyDxC77uygKhcouovgVUQj1H4YB2ovNuD9+tTTU0zMVBmG/+C8AIYh8F361DL/yE5HnADKYlVdg6MDAmW7cuz5WGuw+PsWDYGAvbL8ECFUt4K7/AHd/I9c7BLaxinD2Ld5Zo7g78RLuRhlBS2cpWbGfStfhfwCEpK0nUjCbWuGsLciSOELPhkq/YgdY3l6HsLfRcLYf+pHNbH0JigEPkLAyMsiEJ7NrqQzM1i7wyhoMZqOhvQs6Z0ovXgdAJACRoulEg5HOwrOroKk0zOY2BDtVpTF0CU6kLkQJXa+BNEoG0lMSsBBKQXWNQktmoGcaYeSaQCIVWOvUYQAiWZFQtk5mSMoSzEILtBrTfEcviC5bwVwQmoh96wA0ic5dB57ngeoaTIPCdb34zDITYNLOOIeVSsW+dQC+7+NSWx6jJ4tY/rWNV7PfcGv0tBoPTM7M4eKJVgx2FTE9u4QPS6x+kHzfw/mOAjarW2hJG3hy8zIceweuY+PRtREMdzbjzcd5WBqPB6xeRGUMGRzHjWvMmxQ7tiOF1JBN6FiTd6Sy9RuFbHpX7MMMqOD088Ii+op5OUAO7jyeRGfBwrF8Cg8mXuDL4neMXzgFwhwZz+hf7a9d5yu3Z6DTPjVQIY9k7erO7Y63Lvc8ErEeyq6JaM6efjai4v4IMABI0DEPqPKkigAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-dotx { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAndJREFUeNpsU01rE1EUPTPzJk0y+WhMStW2qdVWxUVEQUF0I+4ELQiC7lz4N9z0T+hG9wrdZKUgLqulhrbSag1CKpT0g7RpYjqZmffle5NEKdMHlzfvvXvPPffcO4aUEno9f3Vt4dTp+BXOe+fB0u/NbVpv7h89NU1j1TCM8H7+xY9wJwPHZMbOjRadLAvE/2gToJTiTPx89k+OlVd/LT+0TPIPpO/SzyQk40xCMxBSZ9Z3CoAx5DOjeHT7SbE0XSpzwa8OWB9jINELolQg8AR0EgUKn1PIlIWpkUt4cPNxkTOU12trs8p95RiAXpqaztqou8q6SKQJJmZSqGwsodFsIJk1kcyLYv7IeafcLx4HUNkFF4jFTExMZ0B9DrfD4HUEusYhWs4GPEJg5wly/tBYRIOeDhpEwlS34xcyajdQr3UwOT2MlJOEBRuGNHWp9AQRVXDfQiFV/U5GBSiQ5p6ngBEa5z3fiIhC6g6IMDBwOdoHPkYnHPVyhN0tF7E4QSpr94CEOKELffq+y9Bq+DCJ7rWBoQQBVbPR2O6G4OlsLASJMtCZfQqm0NP5IVWnamdAkUxbyuIYtD7wWegb0YAzAVMkkI6NwPM9xEwHloyDGAmk7AKS9rAS0FKOdugbYeAHPu7OPEM+MY7q3hIKqTFQHmC3XcONc/fxdfMDrk/ew/edzyhvvTmBAddocVRqH3Frahau56qpZDho7+PnTgXffi/gbHYmLEvPSIQBp5JU62sYz13G609zKBXvoOMdYn2zgm7Xg2MVML/4Eu3uPgxhk2gXmNl8v/i2pcXTP8tKdTEcbWLZqDQXwu/l6pfwbEnSGsT9FWAA4mdHv2/9YJ4AAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-dwg { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAoFJREFUeNpsU0tPE2EUPfOg006hD4rQh8WgbCSwkKgbF2owujaCiQsXxpX+D6MmbtXEsHCLmIAbE6NLo8YlGIxREIshIqVl+mQ6j8/zFVCb4UtuZua795577rl3FCEE5Bl79vPd5LHYiOP7cH1AUWi85ytmvlas1bJ9E5ryBntH3BpuP/X9i7ovkluuiE8N9SDepaLpCcRCCqa/VDCaMuIjSWP25Upl6n+QDoCz6Yh7KKzh3sI2LuUimPtRRyaqodj0MDloYiITSTi+mH29Wu0AUf9CsZPJoW5czJl48LmCc5kIKo5Al67B9gUGYxrun+5NnMlFZ+GKiQADj2a7AquseLIvjMv5KMaSBu4sWVir+3i8VIVKYSby0UTdFU8Znu8AYBHQgVOJEN5uOXi4UsdawwU0FSf6TaSoyw6DRvukPkgGWpDKy4F8a3jImCrqFDFn6rhKPR4VGnhvOTAY3WLcjifcQAsqRfhUc/Gq1MKNbBh9nIAMDjEppocxs9HCMktfGTCwP/oOBkUKNk/qF3pDYC6Ktk8RfWzyaaoKrqdDaBDwya8W1m0/CPCR3kFy7CcnmWQRUJqcRJFUKtTnPCeR71LwoeYF92CYyVnCFZpCTrRtCv5to2St8SOrKxiPqEEA4fkYT+mI0rdoeUiH1XZVuQPpsIKqw2QmfifTsnOABiWySlH9uU0Hh2MqjsZV5LtpPSoGeN9rKnhBX7ehoOSLIIPfnGONXGMMWN7xUfVldYDbjM3mrh5HCDgS17DhHgDQcIU+XbBxnDTn1x1UuQcJ9iv7l5Q5e1zLGri92EDJFnoAgHtcfr6wbbVXUqq193+0z97n3UJt1+d51n7aHwEGAAHXJoAuZNlzAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-dxf { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAo5JREFUeNpsU0trE1EYPfNMmtdoH2kDNmJbaVFcaBVFpAsREQpFwY0bu3HjQnTj1mVd+ANcuC3qQixmry6E0kWFVIQ+bKy2tbFJm3emyXTujGca+4DkwsedfLnn3POd77uS67rw1vC79ek7fZEzpu3AYUqS9tKQGZPLpa3VXP0uFCmJ/8t9OLC3q/uJbcs5bkIybvdHoMsSbLKENRmvU2WcNnTjRFD7ML1WGSPJHI6sA4KRWMAWVDPxLYex3iCmfpuIh1QsFSyMxQO4GvXHHwOJ6XWSyIck8v6HQsnjAxFc7vTj2VwBg4aG78VdBHQFCk+dbVcxMdwev9gTSEC455sIBOu2KLsoJFzqasP9vjCeDBlYqzn4VXXwarGKZN7Crd5QfLDT/7KpBM84c9fFUFjFp2wdk6smflRsKKqMa7EgfJJ3Ac2OKlit2pEmBTQfngdpnupoU7BUtRGiiTe7fXiRqmK+KuDn6TpvYogmBRJcrOwIJLIWxmM+dOsyLKryQAaJpjJ1/AxrGO3SqdZt7kKZJrzJWBg5piHENuY8vV6e0UOye1TyftvC5l+gZB8SHJTwpSx4q4JeTUKaxhXoR57h7Rn+3iFolJ3xvPhab6HgJG/pJ7jsNP4sUX+jZiCgEsWd/DjH5IrSYpBUAr0yHpzSoXKOP25a6OBhndh0zcX1qIYM2RIbu6i0KiHD5B/GTMHG03kTGpEL7H80wHFOWwhqDZ+SpkBOtCDYJDhZE4gRcKNbYynAqbCMbXpwpVPFbEng0aKJGbYzK1p4wIegLlcEPmdt+DjXbzcsxFlCynRwwVAwW6hjqeg0Zt521SYCWCJvbe0Un29UDx7Hgrs3IEitHXkw3jOv2fl92D8BBgAJeyqBh90ENQAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-eps { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmlJREFUeNp0U01vElEUPfMFCEVArdoSqEA0KV246UJdUJM2Lo2JK/9FjXu3utJqTNz4D9worrsQExbFpAFT0TYp0CZ8pIAiyMfMvBnvm2Foa9uX3Lw7c98979x77hNM0wRf7ufPsq7Z2SQYw2QJAkDxQalUZa3WI8hy3gmZr15bu+z8kILBkCeRCJi6bufKMji0NhwiCQR6iitdatTvQ5LyOLLEiWcYukm3m4Zhmbq1BX13FyoxuH7xAlbvpqKRK1fT0PWbRwEmDEyiy1QVg/V1GO02tO1tKLEY2PIy3KEAlmJRDLXb0TeZL+n9g4MHlLJ5HIBuYnSzXq+DlcsQLk/D9Hoh1WrIUjlPcpsYGQzS3LWoaBhvKeXWMQCDA1D9pt8PaXERUjwOjEZQFhZQp9L2yERiqYRCkPt/z58ogTGqHQLE1BLgUmC6XGD5AlipBIFKkbhanKHGYLBDqQ4ZED0OAbfLlo8OIxwGvhVgyTHlA3xkomjH/gegBgDURMv6faDbBZpN+/tHkUApkdTA/PwZAPxntwdUyjYA/+ZMqJHjLgM9iv/6zRt2GgMaIE21aVIjnSm0DGPfmhzyde0UAE2Dj+p7urKCPvkZku9eJILOSMUnkvVhIo7GYIB3xSKYdhoA1erXGVKXpvFxZwdBonnD68PQ7YEwM4O4xwMPxc8RYE87g4FIcz+kvfmnA0YzIJIy77/m0OCqsTkkCTysKPjJG3viLei63Gm3kCO6UWqcMejjxecMPmxsoFKtYop6UNirYL9Wtc5OHqzznIXHq1na7OfMJROcK8a6O7MjW7nfzZdrd7jzT4ABACh3NGsh3GcdAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-exe { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAo1JREFUeNp0k8tPE1EUxr+ZzvRJO62lUAQaKIQ0FVJFjBBdoIkrDDHuXJi4NnHtX+HCjW408Q/QmHTRaCRRohIJifgiiBICTQu29mHfnc7MHc+MlECKdxZz595zf+c737nD6boOYzxJLC6Nhwej7e/24HkO779s7G6mMjcEwfKZ21+/d+em+RbagaFev28qEpZwzKg3ZckqCPH1nfS8hScIdyhBe6JqTG3PfyTTeLrwFhvbKdy9/xi5QglXL0yGJsKDccZY7LDIAwWHpSferWBh+RN8ni4UylVER8MY6PHj0uSpUK0hxzfTmWsUtnoEwO3rer64jEyxim6/Hy67DXaHExvJX3jw7CX8XjfORUdDlOohhU4fAVjILCPbm9V1yIqK2FgYt+ZmsZcv4lH8Nb5upXD7+hVMjIRQa8qeDg8UTYPU5cTcxSk4nS709XTD53ZhpD+IYMAPj+TBz93fZiz5oHV4AP1fGdlyHZIkIZkrI7GyhnK9CZXy+Aig6p1+HQAY003AcF8AVtGGfLWG9XTO4MLZ5cL0WAixoT4zVmPHADSiMo3hzHA/xgeDWFjbNg8H3A7kKnX0koEcPdTu/ylgRGZgOjNv38zoSXC8BZJDRKOlwGEV0VJVGM0y4joAPO1spXbx6sNHeD1uRIYGUCxVSRlDt1fC8rfvcDnsmJ+dOaLgoAs6AVLZPJJ7WdhEkUyT8GJpBflSBcVKDTvpDBw2GzQqQT1OgaZqUOhtFQUTUKnVTVWNpgy51YLVKph7sqKYkA4A1ScEfT66vm5kC3+ofh6Xz59FQ5bpkvE4QW3M5Apoyorhl9ABIKnFgNdTOh2NkJG6WSf9eRBJtmFwLDJmriUzeaOkYvvcXwEGAIVNH6cDA1DkAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-flv { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmtJREFUeNpsUl1PE0EUPbssLYUCXdpaC9gWoSTgAyFigiRGY+KjvuuTr/4A44MP/gx/gMYfwIsan0RjIjGiJIZgSIGFIoXSD0t3Z3dnd70zpITazuZmJzP3nnvumaMEQQCx3jx69SV3a3KWMxetpSgKxP3m242Do43SQy2k/YRydvds67n8a63k+FRSn7l/bdg5tdsAuM3he/5weDC8vLdqPLgIIpba2niux52mg//DqlsYSg3iztO7mczN3DJ3+ByCLgCBH4hOFEF7cDpzPCRyOpaeLGXSc2PL3HbnW3XaRQCPEgWI2MsRVAVqrwbX9bHxbhOKpiJ/bzpDOr2k68V2BtRNzMtqDEqPejY/4zSGjb54BM0mQ8k4xsDoIMauXxnqYOD7PmwScP31d0SS/eAuh1lrolFpIBQNQw2pqJdqsAlIceB1AJCIkkE/FZskXDQVRXw6IYHiE0nBEcaPXSSvJnGwWkQXAE4acAhbxPMJpOdHweoMhc9b2F8zwKizbdlyPLVH7QLg+JKBYzoorxzjz3oRzUoToaEw9KyO8XQW5AE5jrFT6AbAYVVNxCZ0Ka3So+DSTAoDiej5ywTySbls1OEDobhFlMcXxrHw+AbINEjNXgb7y6BndLhk8cRkHHbD7g4gEhiJFxsdhrDqaamBaDKKerGGSKwPI9kR9EZCaNA5ubE7A5s8IFhsrxQkgJhZoa/06xC5xRz2v+3BOjFlbqcGlquxsondT9vY+2pAJdeZR6fI355CgQCN2A4O1w7gkQ7cdLUOAKdhV6uFSv3kd/n8mT68eC8dKWLnY4FsfeZQh7nVVt0/AQYAsf5g+SvepeQAAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-gif { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmVJREFUeNp0U0tPE1EU/trplAqlL0laiw40xASByEJIZFGVnSvj1j+gWxNXJq7VrbrwF7h10cSNhMRHojEuACVBKmH6SJQyJeXRxzzv9dyZPiCtN5lMe8853znf953xcc4hztDzZ1+C6fQMHAfd4/MBFG+p6h/n4OAeAoGNToi/eOm+A50LKRaLh6amoty2vVpZdotNXccMEK3LwZxa2bsDSdrAqePv/mLM5tSdMwYBYqyvw9zdhUn/L59P4OGtG8qlZCoH254/DdCdQBCxqZu+ugqnWoW9swN5ehp2NotgIo6bGQWGtaS8+vQ5V9a0u5S+1gfABEilAqdUgm98HDwUQkDT8JXoPPq+BoM5kCYmFT9jryn1+hkAt7heBx8dhbSwACmTAUwTgdlZ/CVKJaLnI1GD8TikZiPSR8Gxib8chH95mZTxgwWHwH7+gFMswqcokIRbjMO2HDCnZ1VvArpjEmnKZc8+cZJJYGsLsMiZ8AgwEqaY6Mb6RQR33JFhGECzCRyfAFXNu9v+RVNRZWIMuDJNuYMAaDycUFGhCOgtuAtFVDA83G5A8TrFDw+F5QMAxAKJJxz2xnW3RPJGbm+rCyjotZetH4DGzaSSeDA3h4Zl4R0JOEZWTpIzF4n/m995bNdqZwB6m0gFft3Ak6vz+KYWwFsGlqIxXItEcDt1ARMEtKdVgZb+fwA0G2C2hXM0ZTZNRcSf0b1pmXi7uYnjI+Lfanm5fRQsK8BIxKcrK7i/uIgP+Tw+FlREqHN5fx/vyU4uHBE6UO4gDWqk/JFaLuMxcXeFk6TuJ90V0HOk1in7J8AAjmgkPfjU+isAAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-h { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAbRJREFUeNqMUk1Lw0AQnf0woK0ttVqp0hwqVCl+UBERT94F7x78Cf4Uz179DT14F8WbYHtRkBYRLNqDtdaPZLObuLs1NGlXcWDJZGbey+x7QUEQgIqT07PL5WKhHL5H46J+22q22vsWpbWwdnR4oJ80LNiz2czGUjENhvj4ctIE4Wrj8XmPUlKL9nCYcOFzE9j1OKSTCdjdrtiLdr7KhVgzEvwW6krC92E6k4Kd9bJt57JV5vFK2KfRQRV+RAMkzxglYI1RaDy2dW1rpWRjQo5VGicYIorWVooFvQVCCAjG8Omw1MgG8AM0uSBUDSnCfk/IGCHwf3DCD/7UhOLBrFkDuep/hDUSSCv1iYo4rIfqGwmUSNJjfYbBcQKhZw0aBMA4B48LwBhBt/cON80HmM9NQ6fXg/Wlku4TwmNWDzaQqzHG+0PSKod5cH5Vh2RiAhYKc8DlV1UPSyuFMGygVlMg1/P6BC6DqXQK8jNZDXAYA1f21V34wMXYFaiyVw0rJyzLgs3VMkxOjGtix/V0XWChZ0cI2i/dzvXdfTd0Qf91BMPrhyNzgKfOmxaWypqaDXHfAgwAtCL8XOfF47gAAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-hpp { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAehJREFUeNqEUk1v00AUHK/XKf1yZdESVRBXjRSRFqMQVBA5Ic5I3DnwE/gpnLnyG3LgXglx4UDDLZS0RWkDLiRxSusk9u6GXSembmLgWZbX7+2bnZl92mg0goo3b3ffO/ncdvyfjHef6q2Dlvs8Q2ktzr16+SL60jhhZ69bO8X8ClLC7w9XdKJVG8fuM0r1WrJG4gXjgqU1D0MGc2kBTytl+7a9XmWcl1IB/hZKEhccq5aJJ/e3bTu7Wg1CVo7rNLlRhUh4oMnXoDoyhoHGyWmUe+QUbELIa7W8CjAFlMzdzeckCwFN06ATAn8QmDMMMGlMuwWucpoCHNe4jBkAMenjYvRPTyi53JvuwX8AplleAeBcRFrH6rXIxLim9I/pi3QA1RhKaYxdjkN8IwalCMIwWs9ljMkh0wzk+9M7w179C3LZNXxve2h+c3Hu91HeKmD/6zHOLnw83ilB1/V0CeqU3Q81LC/O41b2Btx2N2JVP2riR8eTUxmi0TzBwrKZMsqMoz8MsDh/DWuWhUBKURLKxQIeOMWoptYPnS1c+INZBkwISomOSsmBZS7B+3WOzZvrKGzkMAiGqNy7g+LmRkRfekBnANy2163PZXrSbrQ6vch19Xz8fPDHyL39QzkHBKedXjfu+y3AAGU37INBJto1AAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-html { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmBJREFUeNqEUktPE1EU/mY605a+hhZTBNKRDApNrWIRA4nEBUZdmCgLNi4MK5f+FNdu3bFv1J1EXODCR1JJSMTwpqUP6NiCpe10Zjz3hj5Mm3iSybl37jnf+c53jmDbNpi9eb+6Ftcisea909bWNzNb6dwzSXKkhIt/r14+515qBqmDA8HpqKagh53XaopblpIbe+knDpFAhPab2Dw0TKvRK7lmNODzePBgZlK9oUWSpmVNdpIU8T+jaMsyMaD4MDcZVa+NhJMN00w0n6V2nN3yQgdHWZag+LzYPTomIAtT0THVtPGanmb/BbjwLFkvn2IttYGYplKyDzsHh7gdmyAWfh5zVq0Guhg4RAHFUhmfvq3j134aXo8bd+ITnMFOOovU5jbGRoZwNxFn1cxuAIcDW/sZDjA/c4u+BNxOJyxqaenpI3z88gMfPn9Hv98HQZS6RazW6kjExvFi8TGdDSy/W0Emf4LS6R8sv11BmfzSwkPcm74Jo9Ei0GZgmkw8QCOao8OXcaz/5vSZnPdnp3ApqBBLkWJE0Ci7ASzbIhCLLQ1E0iOkBDh9NpUgiUejo8oNuJwyn0YPABtn51UYFFivG3yBGCNZkuDtc/MW+ZQI3OrYpBaARCKufk3B5XIiWyhiL5ODp8+FfFHH+KiKSqWKUL8fC/NznGlPBmz+24dZjKnD0CJDcMoyW0SqXuMtHBFw7rhIAD1ErNUNafxKBNevapwu65NpEQ4FqXIA+RMd6VwBP3cPSERb6gLIFIq61+UqGWaFdcrVt/lmAuWjAi2aiMFwmOYuIJ/N6M28vwIMAMoNDyg4rcU9AAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-ics { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAhRJREFUeNqEUkFPE0EU/mZ2dra7bLNpi2AxQFKalkJrohICiYkXPagXrx78Df4K48GDBzmQePLMhUODNxQ5ciEkJVqDtJGmMWrCATRbd2ecoS5u3aovmezsvu9973vfPiKlhI4XL7c2r5YL81LIELEghLA3u/udxmHnPmfGW/Wuv+LpwwdneRYBx7PeWK0wOYYhcXxyckGV1fdbnbuMsXcklqPRJQxFMKz4RxDCtVO4s3xlRjWoB0FYjlQPEEBieChwKCRGMx5uLtaKs1P5ei8IKlGa/YkXMXYtlTEDlsnw/mMXhBJcqxSK6vlcpa4PEpCooUyIqs5M6hG1o2CUwqA091cFcYLf/sjzcX75EiQIojI9779CTYR4jwTBf+r7GAwh0AxCiL6JMT/04vQ79u8aI2O/7Jzg69o6Go8ewycUahtBpADhHKLnK/eVbkMdtROWIv80NQ2sPhncA9Htwn+9hZG0rY6DzFwJl+7dhs0ZstUy8rduwPS/wd/ehmi3kwq4zTHiWUgXp+EuL8FvNvFl5Rn4xAS86iyI2kY3n0Mv48ByrOQmancdi8I0Kcj3U5iuA29xAelKCUHrEIayzltagG2E4IwkFaQgSC6lYI09iN0d8It5uNV5nG5sgJdKYC0G8WoTOZvBISFNEBxnsuzD3GX4vfDsszzqAu0jkJQDedCGbB6AWg54pYbPo+NGVPdTgAEAqQq70PytIL0AAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-iso { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAjlJREFUeNp0kstrU0EUxr/k5qbJzdPYpGkpsUJoA2q1oLjTdiGiIC5cuXHlxv9BEOrStTvBnQvRrSAIsejCrlqpsURq2hCJNQ+TNLm5uc/x3MmzJh34mDNnvvnNzOE4GGOwx8+t9XQkfn0VE0Y5/7Z+kHm+dvOhtd3P9c/xwNZh7nWaMYtNUmX/Fct/vlN7/8J5aRRgyzm8xzpRDjGE2aVH4VTqdnoUYg/XkEhmy+Cx3DhA5tMzdFolvg5Mx3Fx9SmH0JIg79Zo3j4GADMIokJTKtjbfAKXU4Y/2NvSfyH75TFOxa9Cmr0XnlPFl5ReOQ6wNMDsoFX6AElqQlNV1KsOuNwS/AGFjEUIDhmn5+/DMM16/9igBowAzFKIswPJr6MjlxFP3sV04gaP7RzMPe6xvWM1gNUBM2UKYlBau3QghGphg29J3gDlLLilWNdD3gkvIIDRhD9yGe2mCV0V4HFXuCxT5Dlv8Dz3sIkAs03FalDxBMQSt9BRBMhNncuO7dyU28c9tnf8C/Q0ZtR4GImeQSj8APLRH772BWcgiFODffCv/t8H9tO0v3RjV7VqkeeXLlzDfvYjj88uXhl4JwIsrYxmLY/M1gYclIvGE9jZfNPrSCD3/QgLyeWTADV6wW9AryIcCkB0u1Aq/oCPumlufoF72vIheaLDr4wCLIOqrYnULA14PSoqpSJEAUilZrD77Sv3LK+cI0+Be8cAbbmAOrob0agtD491LYfkoqvnyZLsWRkA/gkwABL4S3L78XYyAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-java { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAjxJREFUeNp8U01v00AUnNiOEyepQyhQobRBSlVIoRCBEPTAjQsSEneE+An8FM5cuXLNoQduIAE3qopKNJAIIppA2jrOR93aa6/N8yZuUxyxkrXr3ffmzczbTQRBgHC83nj3ca28dD36nx6fvnzrNNrdp4oibyUmey9fPBezEgWVFuYLdyvlPGaMY4fl1aRS+9pqP5ElAkmcnknRwuO+Nyt5u/ETYfyj9WrpZnmpxn2/Ok1Swn/GvtnH5k4TLue4kNfxoFoprRQv1TzOb8cAIu3+ZD7oD/Hm7XuxzqRUNDtdkuLiTmW5tFxceBXlnXgQTAORSMt2oGezUJJJrK9dFWdEH7Ik4dB29LiESeUEJXd7/dAT3L+1ivlCHr8NEzutXTBvbJPPSdO/AH5wysChwM/1HzCGlmAzOrKxu2eCud6Z2Jke2MwThpUXL6Nn2ZAVFTlNw70bK0iRnGAq9qwHtOmTRpsx1NsHyKRVnNPnoMoK9kc2BjbD4vk5JGV5NkBoEPM4FFnCteJFWOS4ntHEfphQyKaFTWFLw704AJ26ZFx/ZEEi3YyY0O1Dmr4EKTUHA8hUnS6siI0DEHLYog+b28RCRuNXR/iQUpPUEQ+NVht6Lodnjx+GXYgDSFRnq97Ed2pXSlXhUSeGhxYc5sKlNXM5DGLR2TMwfZVPAIi+otGNWy1fEZUKeo4qc4ysI+F8VksLIJfYcD9QYgB/DNPMptWBlsnBIS86xmDMTBo/PWd0LB6VZfdEbJT3V4ABAA5HIzlv9dtdAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-jpeg, +.ipfs-jpg { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmlJREFUeNpsU8luUlEY/s4dmMpkWxRopGJNNbiwhk1tItbGtXHr0hcwmvgOdWld6Bu4coXumtREE3ZKu8FgOlC1kIoXtC3jPfdc/8PUIpzkBM7wf+f/hsts24YczuerGUc0moBlYTAYA+i8sbdXtAzjITRtq39kr73s/Gr9DTUYPOeamwvYnHdrdR0SnDebuCbswJGqpX+Uf92Hqm7hzFAG/4TgNr1uCwEJ0trcBC8U0Kb1/PQkHt9JxSLnL6TB+Y2zAIMOJBGLXmtsbEAYBsx8HnqCGKVScAX8uHf5EpqmGXv18VO6VDEe0PXsKABN8+AAgiabmYFNNJTDQ2RUFc8+Z9G0OPR4PKYwvKari0MAgiY/OQGCAajhMNR4nDZMaInrKBGl70SPMScck1NQG3X/CAWLE3/dAWV5hRRVIJxOWNksrP19sFgMqqAebUGYHMI6teq0A9oTVAhqu2sfbYYjsL7lCZ3683gA70T3TK7/B4BNoO020GwB9TpwfAz8LgMtWn/NkV8EHgoB81c7nYwCyBZlEVkHcqMTKFnkmehJTOPvEfCnKi0fAyADJKfXC/h83TaZTJjaa5lANLpOFqAXtlEAorAwO9u5syT5UxLfU0e3o1FMu1x4u7ODYq02BKAMAVSrSNLrK1MhLPj8mNF0vFm+C1ZvwKBwXXE4AGn1WAASazESwUW3BzUSMeJ2o1Aq4sPurvQYSRLwlhRR6mSaYyi0WlpAJrFRx3ouh5/lMt5lv8BLwXp0M4lSpYL17e2uK5wP6lj/c2ZPn2RI+YT8fDvqoyegVLyfG5kBKaQQOfvF2pLc+ifAABiQH3PEc1i/AAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-js { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RUQ5ODY5Q0NGMTE4MTFFMTlDRjlDN0VBQTY3QTk0MTEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RUQ5ODY5Q0RGMTE4MTFFMTlDRjlDN0VBQTY3QTk0MTEiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpFRDk4NjlDQUYxMTgxMUUxOUNGOUM3RUFBNjdBOTQxMSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpFRDk4NjlDQkYxMTgxMUUxOUNGOUM3RUFBNjdBOTQxMSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PoT8zQ8AAAJdSURBVHjadFNbTxNREP52t7S0bktbKFAvTUVaw60YqkExUTD6oD74qC/yD/wp/gh885XEEI0RAyYQUiMpIBGMkYR6o23abi+73e2uc04v1LROMtnZPTPffvPNHMGyLDB7sbJ2ciUSli3U35smkK9t7x9v7n2dD/g8KUkUwWqeP3vKz23NxJGzgwOx0RC6mSgIo+WKuvP56MeUzy2nJEk8PWsGJVVTuhWbpgmHw47FB7d98Wg4mVWK52o1sxOg3Va3PmFp+Q2PdUquaFUM9/vw+O6cP3bxwm46Xwh1ALR3/vL1e+hGjcc9koScUsTSq3coVDQsXJ3wzo5HEs3clgZNMTVdx1T0Ep7cn6//QRQwMhzA6uZHLD5cIFEFSKIU+G8LK+tb0KsGZKcTJoEyP08AbpcLy6sbPKdQrigdAGaDwWxsDH1uGbliCYIgcM8WFPg8Mq5Pjzdyu4jYbCE44EepXMHuwXe+A8x3KKYxYsjvbUzmlPGpBmYdgI1oYjSMbL4Ao1YXMkcM2Dd2xnbAamPQAqg1GORLZdycmYTdJqFKk2DPR3fmwI4zBDrg9RADqxPAbPBif2WTSB584/3/TGegEOit+DRcvQ4OZJi1LgwIQKVCg2i6nb1I7H3Br3QWqT9pBAP9uDY5xjdSM3RqxeoUkfVnEOW8UkLykERTNXjkM7h3Iw6NNvHw6JjuhAhVrba0+QeALozcI9nQR0VvNxJc/ZmxCNGvIBQcpDG6udA22kyW29HC72wu8yG579ZoiSYuR/ly2+y9CA4NceWLmo717T1i5ULqJNtapL8CDACskxPFZRxLwQAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-key { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAlZJREFUeNpsU11PE0EUPbM7u/2AtJUWU6qiiSYYo5EmmPDCD9AH46sx8cEnja/+CB989z+Y+MKPgMiDsYQACcbaWBBogYD92t2Zud7ZlQZsbzKZ3bl3zj3n3IwgItjYeDO3MlWme0bjUth8e8/fO2tHzx3XqUEk50uft+Ndnhdmc3SlfNPkVZT8Cy600DoIISvVfKYtlvfX1p66XmoIYsMZdjJQWvEFbbsC/S5g2QhSkKUK7rx6OzvzqLpsovAhaAxA3DUBQn2TUFsl7KwTfm4Z9DoO5LW7uPXi9Wxpfn7ZKF09vyPxX2iWcNRkKGZz0mQWKoNs8AVB6x1yRY2pYnc2LLofuXTxMgAlmlXIfngCxNxEzM+DPv6NQa2BygLgZyX6JT83ngHTN5GAL0WSoUQkSQnXkyBh/k0GegTAaldM20sTKvet+yyhIZApECamL0jUSe3oFChx3TopM4TeEQP2gc6BgGIwb4KGNXRhCkMGxgg2kJeybRiZM45D8W61qEAknSmpHStBhywu0nFVupSCTAcM4ECwqapv+NQ6LS9JGALoMIIoPYDjZiEL1xHtbyO39AQUDaA7R1AH23DSeSA4hv5RG/VAhxomPYP8sw9A4TaC9iHkjUWmrtGvbyC18BLe3GP0m3WW4I5hEBEnPIStXzyuFIxb4EkMEJ79Qa/xHbKxCdM7xeCwzUZOjgEwnuzt7qLz6T3cySmQP43uzjeIiTJM6io6W19B/NLCKMVGCzkCoLR/0lrfOI2fNy/huKC1FTsK/rbGNeMRC8dHpHByfu+vAAMAL/0jvAVZQl0AAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-less { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RjZERjZENTJGMTE4MTFFMUIwOEVERjQ5MTZEMkVBREUiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RjZERjZENTNGMTE4MTFFMUIwOEVERjQ5MTZEMkVBREUiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpGNkRGNkQ1MEYxMTgxMUUxQjA4RURGNDkxNkQyRUFERSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpGNkRGNkQ1MUYxMTgxMUUxQjA4RURGNDkxNkQyRUFERSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pl1w97IAAAJhSURBVHjahJNLbxJRFMf/wPAIMIxMkUI7tS0VYqlGDLGhjdKkqyZ24cJFN925de+XcONHaHRj4k7TND6SGo1VWwmp2kSLhlqMDbQ87gzPYcY7k4GgoJ6bmdw598zvnvM/95pUVYVma+svcovx8yMnFZHAMJPJBJfDzq5vpX6+/vD5qo/z7DOMBdo/d26t6jFMJ3iY51jBz4M+LP6wxEw40Gy23qYzB3HO7fpmpZCOmfEfa7Xb4NxOrC4lvbPToe2yKE3K1PdPwNOtHdx79ESfq4qKkijB5/XgevIyHxEC24USmewDqD2ABxubaLRkfW6zMqjWGlh7/ByyAtxYnOPnL0Q2+gGGmKRaw8zUBJaTiS5QOO1FJnuIAM8hciaIWHgi8NcSNt+loVDY8JBXh2ojJAR1HbTSNFMUpV8Dxcjg0nSYBrtBxdLbqI1iheCUh9XXNGurAwCdEkb9QyBSFam9TDfoPZ1LUg1BH28IiwEARTVAQOzcFKRaHZpLoa9avY6L1Gfs0c32t4PU6W2lWsV8LAorw0Cs1nXftYWE3qZGqwWHzYp2zzlgetuolVFvtiDLbRRKFTAWCxx2G/KlMtXFhWPqOzsWHJwBx7rxKv2R7mwFz3lw9/5DLC/M4Us2RwV0g3U58XJnF7dvrsBOoX0Abbej/DFKRMKI30fTVGC32WA2m5H9cQQvhYi0vE/7Wdgczn6ARA9QPBrBszcp/XvpyqxebzQ0Tlsq6llxLhe9bD4cFMr9XdjLHpLv+SLGBYHAYiVu1kNOpAaRTWbCejgiw0zGhFGSK1aw+zXbvfK/BBgAPwADAs5GpGsAAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-logo { + background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 553 235.3'%3E%3Cdefs%3E%3C/defs%3E%3Cpath fill='%23ffffff' d='M239 63h17.8v105H239V63zm35.6 0h36.3c7.9 0 14.5.9 19.6 2.6s9.2 4.1 12.1 7.1a24.45 24.45 0 0 1 6.2 10.2 40.75 40.75 0 0 1 1.8 12.1 45.69 45.69 0 0 1-1.8 12.9 26.58 26.58 0 0 1-6.2 10.8 30.59 30.59 0 0 1-12.1 7.3c-5.1 1.8-11.5 2.7-19.3 2.7h-19.1V168h-17.5V63zm36.2 51a38.37 38.37 0 0 0 11.1-1.3 16.3 16.3 0 0 0 6.8-3.7 13.34 13.34 0 0 0 3.5-5.8 29.75 29.75 0 0 0 1-7.6 25.68 25.68 0 0 0-1-7.7 12 12 0 0 0-3.6-5.5 17.15 17.15 0 0 0-6.9-3.4 41.58 41.58 0 0 0-10.9-1.2h-18.5V114h18.5zm119.9-51v15.3h-49.2V108h46.3v15.4h-46.3V168h-17.8V63h67zm26.2 72.9c.8 6.9 3.3 11.9 7.4 15s10.4 4.7 18.6 4.7a32.61 32.61 0 0 0 10.1-1.3 20.52 20.52 0 0 0 6.6-3.5 12 12 0 0 0 3.5-5.2 19.08 19.08 0 0 0 1-6.4 16.14 16.14 0 0 0-.7-4.9 12.87 12.87 0 0 0-2.6-4.5 16.59 16.59 0 0 0-5.1-3.6 35 35 0 0 0-8.2-2.4l-13.4-2.5a89.76 89.76 0 0 1-14.1-3.7 33.51 33.51 0 0 1-10.4-5.8 22.28 22.28 0 0 1-6.3-8.8 34.1 34.1 0 0 1-2.1-12.7 26 26 0 0 1 11.3-22.4 36.35 36.35 0 0 1 12.6-5.6 65.89 65.89 0 0 1 15.8-1.8c7.2 0 13.3.8 18.2 2.5a34.46 34.46 0 0 1 11.9 6.5 28.21 28.21 0 0 1 6.9 9.3 42.1 42.1 0 0 1 3.2 11l-16.8 2.6c-1.4-5.9-3.7-10.2-7.1-13.1s-8.7-4.3-16.1-4.3a43.9 43.9 0 0 0-10.5 1.1 19.47 19.47 0 0 0-6.8 3.1 11.63 11.63 0 0 0-3.7 4.6 14.08 14.08 0 0 0-1.1 5.4c0 4.6 1.2 8 3.7 10.3s6.9 4 13.2 5.3l14.5 2.8c11.1 2.1 19.2 5.6 24.4 10.5s7.8 12.1 7.8 21.4a31.37 31.37 0 0 1-2.4 12.3 25.27 25.27 0 0 1-7.4 9.8 36.58 36.58 0 0 1-12.4 6.6 56 56 0 0 1-17.3 2.4c-13.4 0-24-2.8-31.6-8.5s-11.9-14.4-12.6-26.2h18z'/%3E%3Cpath fill='%23469ea2' d='M30.3 164l84 48.5 84-48.5V67l-84-48.5-84 48.5v97z'/%3E%3Cpath fill='%236acad1' d='M105.7 30.1l-61 35.2a18.19 18.19 0 0 1 0 3.3l60.9 35.2a14.55 14.55 0 0 1 17.3 0l60.9-35.2a18.19 18.19 0 0 1 0-3.3L123 30.1a14.55 14.55 0 0 1-17.3 0zm84 48.2l-61 35.6a14.73 14.73 0 0 1-8.6 15l.1 70a15.57 15.57 0 0 1 2.8 1.6l60.9-35.2a14.73 14.73 0 0 1 8.6-15V79.9a20 20 0 0 1-2.8-1.6zm-150.8.4a15.57 15.57 0 0 1-2.8 1.6v70.4a14.38 14.38 0 0 1 8.6 15l60.9 35.2a15.57 15.57 0 0 1 2.8-1.6v-70.4a14.38 14.38 0 0 1-8.6-15L38.9 78.7z'/%3E%3Cpath fill='%23469ea2' d='M114.3 29l75.1 43.4v86.7l-75.1 43.4-75.1-43.4V72.3L114.3 29m0-10.3l-84 48.5v97l84 48.5 84-48.5v-97l-84-48.5z'/%3E%3Cpath fill='%23469ea2' d='M114.9 132h-1.2A15.66 15.66 0 0 1 98 116.3v-1.2a15.66 15.66 0 0 1 15.7-15.7h1.2a15.66 15.66 0 0 1 15.7 15.7v1.2a15.66 15.66 0 0 1-15.7 15.7zm0 64.5h-1.2a15.65 15.65 0 0 0-13.7 8l14.3 8.2 14.3-8.2a15.65 15.65 0 0 0-13.7-8zm83.5-48.5h-.6a15.66 15.66 0 0 0-15.7 15.7v1.2a15.13 15.13 0 0 0 2 7.6l14.3-8.3V148zm-14.3-89a15.4 15.4 0 0 0-2 7.6v1.2a15.66 15.66 0 0 0 15.7 15.7h.6V67.2L184.1 59zm-69.8-40.3L100 26.9a15.73 15.73 0 0 0 13.7 8.1h1.2a15.65 15.65 0 0 0 13.7-8l-14.3-8.3zM44.6 58.9l-14.3 8.3v16.3h.6a15.66 15.66 0 0 0 15.7-15.7v-1.2a16.63 16.63 0 0 0-2-7.7zM30.9 148h-.6v16.2l14.3 8.3a15.4 15.4 0 0 0 2-7.6v-1.2A15.66 15.66 0 0 0 30.9 148z'/%3E%3Cpath fill='%23083b54' fill-opacity='0.15' d='M114.3 213.2v-97.1l-84-48.5v97.1z'/%3E%3Cpath fill='%23083b54' fill-opacity='0.05' d='M198.4 163.8v-97l-84 48.5v97.1z'/%3E%3C/svg%3E%0A"); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-mid { + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-mkv { + background-image:url("data:image/svg+xml;charset=utf8,%3Csvg id='Layer_2' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 100'%3E%3Cstyle/%3E%3ClinearGradient id='SVGID_1_' gradientUnits='userSpaceOnUse' x1='36.2' y1='101' x2='36.2' y2='3.005' gradientTransform='matrix(1 0 0 -1 0 102)'%3E%3Cstop offset='0' stop-color='%23e2cde4'/%3E%3Cstop offset='.17' stop-color='%23e0cae2'/%3E%3Cstop offset='.313' stop-color='%23dbc0dd'/%3E%3Cstop offset='.447' stop-color='%23d2b1d4'/%3E%3Cstop offset='.575' stop-color='%23c79dc7'/%3E%3Cstop offset='.698' stop-color='%23ba84b9'/%3E%3Cstop offset='.819' stop-color='%23ab68a9'/%3E%3Cstop offset='.934' stop-color='%239c4598'/%3E%3Cstop offset='1' stop-color='%23932a8e'/%3E%3C/linearGradient%3E%3Cpath d='M45.2 1l27 26.7V99H.2V1h45z' fill='url(%23SVGID_1_)'/%3E%3Cpath d='M45.2 1l27 26.7V99H.2V1h45z' fill-opacity='0' stroke='%23882383' stroke-width='2'/%3E%3Cpath d='M7.5 91.1V71.2h6.1l3.6 13.5 3.6-13.5h6.1V91h-3.8V75.4l-4 15.6h-3.9l-4-15.6V91H7.5zm23.5 0V71.2h4V80l8.2-8.8h5.4L41.1 79l8 12.1h-5.2l-5.5-9.3-3.4 3.3v6h-4zm25.2 0L49 71.3h4.4L58.5 86l4.9-14.7h4.3l-7.2 19.8h-4.3z' fill='%23fff'/%3E%3ClinearGradient id='SVGID_2_' gradientUnits='userSpaceOnUse' x1='18.2' y1='50.023' x2='18.2' y2='50.023' gradientTransform='matrix(1 0 0 -1 0 102)'%3E%3Cstop offset='.005' stop-color='%23963491'/%3E%3Cstop offset='1' stop-color='%2370136b'/%3E%3C/linearGradient%3E%3ClinearGradient id='SVGID_3_' gradientUnits='userSpaceOnUse' x1='11.511' y1='51.716' x2='65.211' y2='51.716' gradientTransform='matrix(1 0 0 -1 0 102)'%3E%3Cstop offset='.005' stop-color='%23963491'/%3E%3Cstop offset='1' stop-color='%2370136b'/%3E%3C/linearGradient%3E%3Cpath d='M64.3 55.5c-1.7-.2-3.4-.3-5.1-.3-7.3-.1-13.3 1.6-18.8 3.7S29.6 63.6 23.3 64c-3.4.2-7.3-.6-8.5-2.4-.8-1.3-.8-3.5-1-5.7-.6-5.7-1.6-11.7-2.4-17.3.8-.9 2.1-1.3 3.4-1.7.4 1.1.2 2.7.6 3.8 7.1.7 13.6-.4 20-1.5 6.3-1.1 12.4-2.2 19.4-2.6 3.4-.2 6.9-.2 10.3 0m-9.9 15.3c.5-.2 1.1-.3 1.9-.2.2-3.7.3-7.3.3-11.2-6.2.2-11.9.9-17 2.2.2 4 .4 7.8.3 12 4-1.1 7.7-2.5 12.6-2.7m2-12.1h1.1c.4-.4.2-1.2.2-1.9-1.5-.6-1.8 1-1.3 1.9zm3.9-.2h1.5V38h-1.3c0 .7-.4.9-.2 1.7zm4 0c.5-.1.8 0 1.1.2.4-.3.2-1.2.2-1.9h-1.3v1.7zm-11.5.3h.9c.4-.3.2-1.2.2-1.9-1.4-.4-1.6 1.2-1.1 1.9zm-4 .4c.7.2.8-.3 1.5-.2v-1.7c-1.5-.4-1.7.6-1.5 1.9zm-3.6-1.1c0 .6-.1 1.4.2 1.7.5.1.5-.4 1.1-.2-.2-.6.5-2-.4-1.9-.1.4-.8.1-.9.4zm-31.5.8c.4-.1 1.1.6 1.3 0-.5 0-.1-.8-.2-1.1-.7.2-1.3.3-1.1 1.1zm28.3-.4c-.3.3.2 1.1 0 1.9.6.2.6-.3 1.1-.2-.2-.6.5-2-.4-1.9-.1.3-.4.2-.7.2zm-3.5 2.8c.5-.1.9-.2 1.3-.4.2-.8-.4-.9-.2-1.7h-.9c-.3.3-.1 1.3-.2 2.1zm26.9-1.8c-2.1-.1-3.3-.2-5.5-.2-.5 3.4 0 7.8-.5 11.2 2.4 0 3.6.1 5.8.3M33.4 41.6c.5.2.1 1.2.2 1.7.5-.1 1.1-.2 1.5-.4.6-1.9-.9-2.4-1.7-1.3zm-4.7.6v1.9c.9.2 1.2-.2 1.9-.2-.1-.7.2-1.7-.2-2.1-.5.2-1.3.1-1.7.4zm-5.3.6c.3.5 0 1.6.4 2.1.7.1.8-.4 1.5-.2-.1-.7-.3-1.2-.2-2.1-.8-.2-.9.3-1.7.2zm-7.5 2H17c.2-.9-.4-1.2-.2-2.1-.4.1-1.2-.3-1.3.2.6.2-.1 1.7.4 1.9zm3.4 1c.1 4.1.9 9.3 1.4 13.7 8 .1 13.1-2.7 19.2-4.5-.5-3.9.1-8.7-.7-12.2-6.2 1.6-12.1 3.2-19.9 3zm.5-.8h1.1c.4-.5-.2-1.2 0-2.1h-1.5c.1.7.1 1.6.4 2.1zm-5.4 7.8c.2 0 .3.2.4.4-.4-.7-.7.5-.2.6.1-.2 0-.4.2-.4.3.5-.8.7-.2.8.7-.5 1.3-1.2 2.4-1.5-.1 1.5.4 2.4.4 3.8-.7.5-1.7.7-1.9 1.7 1.2.7 2.5 1.2 4.2 1.3-.7-4.9-1.1-8.8-1.6-13.7-2.2.3-4-.8-5.1-.9.9.8.6 2.5.8 3.6 0-.2 0-.4.2-.4-.1.7.1 1.7-.2 2.1.7.3.5-.2.4.9m44.6 3.2h1.1c.3-.3.2-1.1.2-1.7h-1.3v1.7zm-4-1.4v1.3c.4.4.7-.2 1.5 0v-1.5c-.6 0-1.2 0-1.5.2zm7.6 1.4h1.3v-1.5h-1.3c.1.5 0 1 0 1.5zm-11-1v1.3h1.1c.3-.3.4-1.7-.2-1.7-.1.4-.8.1-.9.4zm-3.6.4c.1.6-.3 1.7.4 1.7 0-.3.5-.2.9-.2-.2-.5.4-1.8-.4-1.7-.1.3-.6.2-.9.2zm-3.4 1v1.5c.7.2.6-.4 1.3-.2-.2-.5.4-1.8-.4-1.7-.1.3-.8.2-.9.4zM15 57c.7-.5 1.3-1.7.2-2.3-.7.4-.8 1.6-.2 2.3zm26.1-1.3c-.1.7.4.8.2 1.5.9 0 1.2-.6 1.1-1.7-.4-.5-.8.1-1.3.2zm-3 2.7c1 0 1.2-.8 1.1-1.9h-.9c-.3.4-.1 1.3-.2 1.9zm-3.6-.4v1.7c.6-.1 1.3-.2 1.5-.8-.6 0 .3-1.6-.6-1.3 0 .4-.7.1-.9.4zM16 60.8c-.4-.7-.2-2-1.3-1.9.2.7.2 2.7 1.3 1.9zm13.8-.9c.5 0 .1.9.2 1.3.8.1 1.2-.2 1.7-.4v-1.7c-.9-.1-1.6.1-1.9.8zm-4.7.6c0 .8-.1 1.7.4 1.9 0-.5.8-.1 1.1-.2.3-.3-.2-1.1 0-1.9-.7-.2-1 .1-1.5.2zM19 62.3v-1.7c-.5 0-.6-.4-1.3-.2-.1 1.1 0 2.1 1.3 1.9zm2.5.2h1.3c.2-.9-.3-1.1-.2-1.9h-1.3c-.1.9.2 1.2.2 1.9z' fill='url(%23SVGID_3_)'/%3E%3ClinearGradient id='SVGID_4_' gradientUnits='userSpaceOnUse' x1='45.269' y1='74.206' x2='58.769' y2='87.706' gradientTransform='matrix(1 0 0 -1 0 102)'%3E%3Cstop offset='0' stop-color='%23f9eff6'/%3E%3Cstop offset='.378' stop-color='%23f8edf5'/%3E%3Cstop offset='.515' stop-color='%23f3e6f1'/%3E%3Cstop offset='.612' stop-color='%23ecdbeb'/%3E%3Cstop offset='.69' stop-color='%23e3cce2'/%3E%3Cstop offset='.757' stop-color='%23d7b8d7'/%3E%3Cstop offset='.817' stop-color='%23caa1c9'/%3E%3Cstop offset='.871' stop-color='%23bc88bb'/%3E%3Cstop offset='.921' stop-color='%23ae6cab'/%3E%3Cstop offset='.965' stop-color='%239f4d9b'/%3E%3Cstop offset='1' stop-color='%23932a8e'/%3E%3C/linearGradient%3E%3Cpath d='M45.2 1l27 26.7h-27V1z' fill='url(%23SVGID_4_)'/%3E%3Cpath d='M45.2 1l27 26.7h-27V1z' fill-opacity='0' stroke='%23882383' stroke-width='2' stroke-linejoin='bevel'/%3E%3C/svg%3E"); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-mov { + background-image:url("data:image/svg+xml;charset=utf8,%3Csvg id='Layer_2' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 100'%3E%3Cstyle/%3E%3ClinearGradient id='SVGID_1_' gradientUnits='userSpaceOnUse' x1='36.2' y1='101' x2='36.2' y2='3.005' gradientTransform='matrix(1 0 0 -1 0 102)'%3E%3Cstop offset='0' stop-color='%23e2cde4'/%3E%3Cstop offset='.17' stop-color='%23e0cae2'/%3E%3Cstop offset='.313' stop-color='%23dbc0dd'/%3E%3Cstop offset='.447' stop-color='%23d2b1d4'/%3E%3Cstop offset='.575' stop-color='%23c79dc7'/%3E%3Cstop offset='.698' stop-color='%23ba84b9'/%3E%3Cstop offset='.819' stop-color='%23ab68a9'/%3E%3Cstop offset='.934' stop-color='%239c4598'/%3E%3Cstop offset='1' stop-color='%23932a8e'/%3E%3C/linearGradient%3E%3Cpath d='M45.2 1l27 26.7V99H.2V1h45z' fill='url(%23SVGID_1_)'/%3E%3Cpath d='M45.2 1l27 26.7V99H.2V1h45z' fill-opacity='0' stroke='%23882383' stroke-width='2'/%3E%3Cpath d='M6.1 91.1V71.2h6.1l3.6 13.5 3.6-13.5h6.1V91h-3.8V75.4l-4 15.6h-3.9l-4-15.6V91H6.1zm22.6-9.8c0-2 .3-3.7.9-5.1.5-1 1.1-1.9 1.9-2.7.8-.8 1.7-1.4 2.6-1.8 1.2-.5 2.7-.8 4.3-.8 3 0 5.3.9 7.1 2.7 1.8 1.8 2.7 4.3 2.7 7.6 0 3.2-.9 5.7-2.6 7.5-1.8 1.8-4.1 2.7-7.1 2.7s-5.4-.9-7.1-2.7c-1.8-1.8-2.7-4.3-2.7-7.4zm4.1-.2c0 2.2.5 4 1.6 5.1 1 1.2 2.4 1.7 4 1.7s2.9-.6 4-1.7c1-1.2 1.6-2.9 1.6-5.2 0-2.3-.5-4-1.5-5.1-1-1.1-2.3-1.7-4-1.7s-3 .6-4 1.7c-1.1 1.2-1.7 3-1.7 5.2zm23.6 10l-7.2-19.8h4.4L58.7 86l4.9-14.7h4.3l-7.2 19.8h-4.3z' fill='%23fff'/%3E%3ClinearGradient id='SVGID_2_' gradientUnits='userSpaceOnUse' x1='18.2' y1='50.023' x2='18.2' y2='50.023' gradientTransform='matrix(1 0 0 -1 0 102)'%3E%3Cstop offset='.005' stop-color='%23963491'/%3E%3Cstop offset='1' stop-color='%2370136b'/%3E%3C/linearGradient%3E%3ClinearGradient id='SVGID_3_' gradientUnits='userSpaceOnUse' x1='11.511' y1='51.716' x2='65.211' y2='51.716' gradientTransform='matrix(1 0 0 -1 0 102)'%3E%3Cstop offset='.005' stop-color='%23963491'/%3E%3Cstop offset='1' stop-color='%2370136b'/%3E%3C/linearGradient%3E%3Cpath d='M64.3 55.5c-1.7-.2-3.4-.3-5.1-.3-7.3-.1-13.3 1.6-18.8 3.7S29.6 63.6 23.3 64c-3.4.2-7.3-.6-8.5-2.4-.8-1.3-.8-3.5-1-5.7-.6-5.7-1.6-11.7-2.4-17.3.8-.9 2.1-1.3 3.4-1.7.4 1.1.2 2.7.6 3.8 7.1.7 13.6-.4 20-1.5 6.3-1.1 12.4-2.2 19.4-2.6 3.4-.2 6.9-.2 10.3 0m-9.9 15.3c.5-.2 1.1-.3 1.9-.2.2-3.7.3-7.3.3-11.2-6.2.2-11.9.9-17 2.2.2 4 .4 7.8.3 12 4-1.1 7.7-2.5 12.6-2.7m2-12.1h1.1c.4-.4.2-1.2.2-1.9-1.5-.6-1.8 1-1.3 1.9zm3.9-.2h1.5V38h-1.3c0 .7-.4.9-.2 1.7zm4 0c.5-.1.8 0 1.1.2.4-.3.2-1.2.2-1.9h-1.3v1.7zm-11.5.3h.9c.4-.3.2-1.2.2-1.9-1.4-.4-1.6 1.2-1.1 1.9zm-4 .4c.7.2.8-.3 1.5-.2v-1.7c-1.5-.4-1.7.6-1.5 1.9zm-3.6-1.1c0 .6-.1 1.4.2 1.7.5.1.5-.4 1.1-.2-.2-.6.5-2-.4-1.9-.1.4-.8.1-.9.4zm-31.5.8c.4-.1 1.1.6 1.3 0-.5 0-.1-.8-.2-1.1-.7.2-1.3.3-1.1 1.1zm28.3-.4c-.3.3.2 1.1 0 1.9.6.2.6-.3 1.1-.2-.2-.6.5-2-.4-1.9-.1.3-.4.2-.7.2zm-3.5 2.8c.5-.1.9-.2 1.3-.4.2-.8-.4-.9-.2-1.7h-.9c-.3.3-.1 1.3-.2 2.1zm26.9-1.8c-2.1-.1-3.3-.2-5.5-.2-.5 3.4 0 7.8-.5 11.2 2.4 0 3.6.1 5.8.3M33.4 41.6c.5.2.1 1.2.2 1.7.5-.1 1.1-.2 1.5-.4.6-1.9-.9-2.4-1.7-1.3zm-4.7.6v1.9c.9.2 1.2-.2 1.9-.2-.1-.7.2-1.7-.2-2.1-.5.2-1.3.1-1.7.4zm-5.3.6c.3.5 0 1.6.4 2.1.7.1.8-.4 1.5-.2-.1-.7-.3-1.2-.2-2.1-.8-.2-.9.3-1.7.2zm-7.5 2H17c.2-.9-.4-1.2-.2-2.1-.4.1-1.2-.3-1.3.2.6.2-.1 1.7.4 1.9zm3.4 1c.1 4.1.9 9.3 1.4 13.7 8 .1 13.1-2.7 19.2-4.5-.5-3.9.1-8.7-.7-12.2-6.2 1.6-12.1 3.2-19.9 3zm.5-.8h1.1c.4-.5-.2-1.2 0-2.1h-1.5c.1.7.1 1.6.4 2.1zm-5.4 7.8c.2 0 .3.2.4.4-.4-.7-.7.5-.2.6.1-.2 0-.4.2-.4.3.5-.8.7-.2.8.7-.5 1.3-1.2 2.4-1.5-.1 1.5.4 2.4.4 3.8-.7.5-1.7.7-1.9 1.7 1.2.7 2.5 1.2 4.2 1.3-.7-4.9-1.1-8.8-1.6-13.7-2.2.3-4-.8-5.1-.9.9.8.6 2.5.8 3.6 0-.2 0-.4.2-.4-.1.7.1 1.7-.2 2.1.7.3.5-.2.4.9m44.6 3.2h1.1c.3-.3.2-1.1.2-1.7h-1.3v1.7zm-4-1.4v1.3c.4.4.7-.2 1.5 0v-1.5c-.6 0-1.2 0-1.5.2zm7.6 1.4h1.3v-1.5h-1.3c.1.5 0 1 0 1.5zm-11-1v1.3h1.1c.3-.3.4-1.7-.2-1.7-.1.4-.8.1-.9.4zm-3.6.4c.1.6-.3 1.7.4 1.7 0-.3.5-.2.9-.2-.2-.5.4-1.8-.4-1.7-.1.3-.6.2-.9.2zm-3.4 1v1.5c.7.2.6-.4 1.3-.2-.2-.5.4-1.8-.4-1.7-.1.3-.8.2-.9.4zM15 57c.7-.5 1.3-1.7.2-2.3-.7.4-.8 1.6-.2 2.3zm26.1-1.3c-.1.7.4.8.2 1.5.9 0 1.2-.6 1.1-1.7-.4-.5-.8.1-1.3.2zm-3 2.7c1 0 1.2-.8 1.1-1.9h-.9c-.3.4-.1 1.3-.2 1.9zm-3.6-.4v1.7c.6-.1 1.3-.2 1.5-.8-.6 0 .3-1.6-.6-1.3 0 .4-.7.1-.9.4zM16 60.8c-.4-.7-.2-2-1.3-1.9.2.7.2 2.7 1.3 1.9zm13.8-.9c.5 0 .1.9.2 1.3.8.1 1.2-.2 1.7-.4v-1.7c-.9-.1-1.6.1-1.9.8zm-4.7.6c0 .8-.1 1.7.4 1.9 0-.5.8-.1 1.1-.2.3-.3-.2-1.1 0-1.9-.7-.2-1 .1-1.5.2zM19 62.3v-1.7c-.5 0-.6-.4-1.3-.2-.1 1.1 0 2.1 1.3 1.9zm2.5.2h1.3c.2-.9-.3-1.1-.2-1.9h-1.3c-.1.9.2 1.2.2 1.9z' fill='url(%23SVGID_3_)'/%3E%3ClinearGradient id='SVGID_4_' gradientUnits='userSpaceOnUse' x1='45.269' y1='74.206' x2='58.769' y2='87.706' gradientTransform='matrix(1 0 0 -1 0 102)'%3E%3Cstop offset='0' stop-color='%23f9eff6'/%3E%3Cstop offset='.378' stop-color='%23f8edf5'/%3E%3Cstop offset='.515' stop-color='%23f3e6f1'/%3E%3Cstop offset='.612' stop-color='%23ecdbeb'/%3E%3Cstop offset='.69' stop-color='%23e3cce2'/%3E%3Cstop offset='.757' stop-color='%23d7b8d7'/%3E%3Cstop offset='.817' stop-color='%23caa1c9'/%3E%3Cstop offset='.871' stop-color='%23bc88bb'/%3E%3Cstop offset='.921' stop-color='%23ae6cab'/%3E%3Cstop offset='.965' stop-color='%239f4d9b'/%3E%3Cstop offset='1' stop-color='%23932a8e'/%3E%3C/linearGradient%3E%3Cpath d='M45.2 1l27 26.7h-27V1z' fill='url(%23SVGID_4_)'/%3E%3Cpath d='M45.2 1l27 26.7h-27V1z' fill-opacity='0' stroke='%23882383' stroke-width='2' stroke-linejoin='bevel'/%3E%3C/svg%3E"); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-mp3 { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnxJREFUeNp0U89PE0EU/ra7XWxpSsFYIbVQf9REFBHkYBRIPJh4wrN3DsZ4MPGP8b/wUCIHEw5EY0w04o9ILcREGmwVgaXbbXdnd2bXNxPahGyczebtzrz3ve99740WRRHkWn5cebu4cH6SMY7e0jRAHr9c3WxsVvcemmbys9yT6+uHJ8oaPefypdPDD5Ymh5w26wMkEho8JtDtuEOZFCrvN/4uJZNGH0T59D58X/C27aFNAL3Xthmsww5GCyN4+uzu+OLtQsUPxPQx6ZMAoQjBAw7O+bEVCMMQgqygs+LFs1h+dGd8bna0QmXO9OL6JYgwAvOFZKKoy3V44CgNfv7Yx8oLH+lUEgvzF8Ydhz+n41snAGRG5gUEwClzhHdvttFxfNyYK0EnJozKK5eGcf1qHo1GOxtjwI+pfvm4g/W1qtJgerYE2SXJSIL9+W0jk0mCShAxDXgQKgbNXxZq35vQKCiKQkSUXdc1+gcch1FHGPmKuIgBCdc66qJQHMG9+1NIpUylxxHtuW6gEiTIu+N4yjdWgty0yTmdNjFzcwKjY0MU7MLt+IjoSad16FoIx3b/A0DZ7FYXnsdpAjUMDOjI5zPgfoBsRodhhGhZHfBBU/nGAGRtxWIOg5lT2NtrI5dL0SB5KJzLodloqXaOEatPGztKq5gG3S5DNjuAK5NjKJfPYKI0okBkSdemCiSgS/rkQNLSePtxBj4LSCwfFtE0krqqX7ZVMnu9XlMXy2l7ME0dzA3iANQyY6vWxC61UY41zTyNcYh6/QCNXQvzi5dR39nHVq1BUyuMGAARsF6tbbe4iKD1r7Om5iFBdmW1SsDflLiuB6sX90+AAQDHAW7dW0YnzgAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-mp4 { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnBJREFUeNpsk99r01AUx79psrTrujVtbceabnZs4DYRHSoMh6Dgq77rn+AfoA/+If4Bok+C0CfxVRDBh+I2NqZzrpS1DVvbtU3SJPcm8SSlsJlecsn9dT73nO85V/B9H0H78OLdt/LDlQ1uMYybIAgI9n99OWxoe83nkiz9hDDae330JvxL48O51Xxm/enNtKPbVwAh0Ec6kYpXat9Pnl2GBC02HrjM5Y7h4P8+7FtIFVJ49OrxUnl7ucIdfhv+BIDv+fBcj7p/tXMPrs2RXVTw4OX2UnFTrXCbbY7tpMsA13FDSDAOQ4gJEGUJLs0PPh9CkESsPrmxxEz2lra3rnpAt3G6adgdQhBpmeLkFodNmsjpOPoXBrQTDcmFFNS7i3MRDzzPCw/vva8ikU+COQxm14BBhvJcHLGpGPTOAJxxeLbrRgAkYujBdH4G5oWJWXUW19YL4XqunAMFhnq1BqWYgaY1MAHASQOiU96zKzkU76mwehaOvx6h9uMv7KFN3RopL4oTAI4HRh4wSl399xla+00YbR3yrIzM9SzSqgJJnoKcklGrH08CcJjnBtLLCsSEGGpSWJvHtDKNoFippsJ0ulIsDDUCCATMlBQkNuahEyiZTcLsmFBKaQxaOk53TlHeKkM70AjAooCghBOk9sKtIvqtPqS4FBaRnJSRX8tj2DOh3lFB5Qw2ZNFK5LRo6w4sKt2ggAzywidAMN/9uIPSZglBLDO5FF3mRD3wHE9qVRvoHrUpfn+UEQK0/7ShtwboHJ6jdH8RZxSC57hSVETb7e5/2u0FxqPHJow+8iZ4lYY2QGu3idhIxO7Y7p8AAwALCGZKEPBGCgAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-mpg { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnxJREFUeNpsU0tPE1EU/ubRdlqmnUBboa0UeUQDiUGCC1+JmrhxoXt/gBvXJi74If4AV0Y3sNKF0YUaICqoIfjgVShEiGF4tDOdO/fOeOaSKtie5GZu7pzz3e/c7ztKGIaI4vn9p+/P3h4e4a6Pv6EoQBDiy7P5rc1P1Xt6XP8M5ejXo6UJ+dWbuemeTGdpvNdiNe9YvQLe4Bi4PmTpRmyq8m71rp74BxKF2twIHvAo+f/l1T2Yp0zceHizfOZa/xRnfBRhG4CQqAYioBWeXDyA8Di6ei1ceXC1XBwrTXHPH2vW6ccBBBMI6BsSUEQzakGL6xB0tvjyBxRNxdCtc2Xf8R9TyaWTDOg2TjfVdw6hqIoE9B2GxkEDWlLH7s4ette2kSp0oDRezrQwCIIA3oGHr0/mKMmE53qo23W4+w5S+Q5ohob9X3tgHgO8ULQACC7gMx9mKQP30EW6mEHpYi8xcJEdzMucjfkKcrTfmqmiFYBxCF/Id+gayKJwoQjHdrA5v4HK7Cq44KjZNWpagaqp7QACks0H9znW365ia24DzoEDozOJbH8eVtGShXHTwNracnsG7q6LzsEuaAlNPm9h7DSSVjLyCMkppDI+GS2StQWA1RlKo0X56n2X+6QHkmkDakxF9WMVqWyK+s/BrthYfvWz1Ug+zUDcjMPMm0h3pxEjFma3CbIuCud7oMc0LL1ZgmElpGJtW3B+15HIGNITrMYIlOH7i0U41NrInREylYbu4R5qQbQBaAh95fVKZCnpQCnb9DrWZyrRERS6NDeUw+yHaXh7rt4C4B8y+9vkwn7kwKNRpDoa9aiFKBYnF+RcREqQ2e1m3R8BBgAy9kz9ysCE6QAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-odf { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAi5JREFUeNp0UktrU0EU/mbu3FfE1KRRUpWYheALNBURUVy7cy9UkO6KW/+Lbt0IPsFui4gLBbUqFaUuXETUKCYa0jS5yZ2ZO557b5MmTXpgmDPnfOc7jznMGINYPi0de5UvmpORxpjE/kbNqW005DVu8TWw1H758ZfkFgNgJmtyxSPRjJIj0QTW/RDiYGXGb7Dl32/eXrVsd0gSCx9miqC0ooCdp69g5Q/h6OLN0ty5ynIkwzMwUwh2FwMdcbDiCZQXlkqFCpEoPT/wih1YjLInANcD+/Ua9bu3wJlGvrBZCmet2+S6ME5g4oGlZ9A/I70XCDhhDexPNTFmswJBwcnuXkF86VSNZxVu0ukLSGnBcqlnN4HoCQIaIuIv7LUooMOgQ7q75LAAb59B9gCBHSKgqemRr94mMKmD24CfM8nb7THYGQNLpAkUkcb66JyGBFFEWRVL57gFEH5qj8Lxwca2qS3EZaugmzAw24dR/XQgwtsCSBjPIdWbUoE2UJLBnV8Ac/ciWHsK9/glWLnD6K2vgPszsOdOQdfeQ1c/ThKoTgDn9A3KUED/52d45xchZsvorD6Bf/Z60riV3Q9Z/0bbGU1uopYGkfERSQ3VbsMwl0qlqoIARmSoPYXWy0dor79LfBMEEd8jGs/uQ3Yl7PJFNFbuEXiV2riCf88fovXhBbo/vqP3t02/ZYmJFqTkzY160Go9uEMbFK8hR/NrdXtFuUVmnmySVGgO4v4LMAAjRgmO+SJJiQAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-ods { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAetJREFUeNqMUj1IHEEU/i7u7Z23e8tGgneGQPw3hZDkkhQiSuwMQREba4uUgpVlCrvEQhurkCoWqcQQ0oTAaYKNqJygGEwgHCSB6Knn7eXcdX/GmdHVPWYFP3gw78173/vmvYkQQsAwNvckq96UnyIEh7/d4t7uUd/8y+85P+bXSX4grkhI6nJYPW7LrXpBK2YxiSoShhu4Buq1NPofDeqdrZ3Z4cl7D4J3UtA5VyVAlmJoru9Af2ZAp1lcCQ3nqgiuKmbY3l/BH+MnHM9GVLP0Ww3KNA33CQoQQnL834Fj74PUGkANEIkCSSsa8gQqgYTIcB0PVsXB318GInRiCVWCkpRFAs+j5gKlA4t29Ggh4d0t04FKt9PQqF4UFgumSEA8ApeaElilWbYRVy/lsns/N1QBkxtENF4jxPxcgcB1CZVOrvMteK5IQDtJJIGh++PcX9iYwWjXK37+vP0WdYk0Ht99jtX8JywWFkQChw4tc+cZcvlF7rMze+ubbxN40fMalRMDP/6twaiUeK7wlZ0TD0a5hLTWxo2d45KKprqHKJslTsy209s2wnMFBTYNZjc/oLt9gPvLOx+hxVJIKS2YW5pCbSyJTGMK775O8VyBwDJd2LTDl/X5i8v3S7NVw9vJb51tITDEUwEGANCx2/rXEEFFAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-odt { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAepJREFUeNqMkz1II1EQx/+7Ca6JkqyYiJ8cKEpAQbBQFDm0sVOsFBS9wt5KOTgEG5twxVlZ+XEnKNiIghYKxx5nwEpIIXaiSAgKGmMi0d23u8+3T7OaZJEMLG9mmPnN/w1vBUopLPNNhRWXHOyDg0nx82TiJtZPlPVoNpftc2cTotcHtxx06kdXpSQ/BvzKESZzIDmAz6y+NojOjpDMZiqRPIgNoFyWM8DrKUV7axO+gcp4g7AzmquAdVNqOgL2z2I4id1B0wgeygOyt/rLL5buLwAIDgA9dY+L+DkuDQOCrkMgBsRglcMOqAGwIstMg8AkGsuZMNUMRMkLqE+QGloglvlA7uIOAKvZajR0qJkUj/XHe0BTIclVKKlrfKsj9qA8gA6wqSJzPaXlr7ky//tdLEUfawsBjExUFGVWbT7AxSa42H2LMfODmvd3wKb7RAMLYwM8nts8xJ/pEe7/3PmP2eGv3D+9usb35W0bINoA7RmjXSHsH0f5Z/mUSZ0Ir2JmsBtD80s8/rGyzWsLFTD5yUQCbfUBHl9d38LvkdDTXIuHVBo0k+bbt06qO+yAPGXwe/cA4wO9PN44jKDG70GougIzi2tQ00ms7/3lpwnBBgjZ37Kkd1Shht5XzBIFl/ufFtniT/lFgAEAU//g6kvdGBMAAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-otp { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAcJJREFUeNqMkssvA1EUxr+ZjkdbrfFKVD12ErYSRELY2fkH+BMsLcQaSwsrSzZi47EjJEQkEhYkFlhYSVtFpdqOqpk717l3jKZmiC+5mZlzv/s795wzCuccQncz3YeRBj4KHz0/RrOZe2NsZPP20o255zQ3EAxzEAC+6uzTw13G4TFQAakA/CWtIYbY0KBOrx7IvwDQqlHV1o3YxKTOvyAUvfQCfqmA3e4ikyS/zRAKvOot7eoSHEgZIHrCfQAfBqBaKQQDKScQAExd8emBANg+2U2CvNMkkgSqBmrCxFB8mujeoJBWwEqARcssKTAJEGrmaGrjqK1zvNknH4BtyxKl2VUpRxmj5W+x73q9AEaZrR/ND1EJluIpS3i9JQiA+a+hSq8HwJjTsLrRaWitPTCOlhEZn5N75sM1qigmlN+dB3u++Qao5W4TtbEXXIsiszGL4PA00itTsu6XnQWo0TjMTAJqfMDx/ryBJcaVzSNSH4fW0Q+rkIf5rsjRiid7yyN7uoXS3Zn0egE0NiORAN9bQ017D1Lri7CLlP2EDr3Rf7C/itzV2bfXA/igLDaRixfngFhSCooH2xVPCWBlwKcAAwBX1suA6te+hAAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-ots { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAfZJREFUeNqMUk1rE1EUPS8zmabJdDKB2glEwY9ExJYiBUEQpV25qgtBXfgbpEtXuujKf+AfEKRddOdOGHClbYVCvyKWaijT2mhjphk7Sd7Me76ZONp0EsiBYWbOvfe88+69hHOOAE9f3zTVnDKNHvhlsfqPw/rM0ovyWsRFdXJEpDIyRnSlVz0KSkmvabaJeXSJBEhgAJzTDNybmtUnS5Pmg/lrN07H5NM/f13FoMgpXDSuhiIiK3Qi6LUugX7FAbaPPsJqfIHHKCStqRsXVFPQuZgD9BBxjikSiRq41AAkgCQBzVf0+BWEBX7GBm0xgHHUqk1UbBuEcIydzyCZlOI9YEGuDxwduCCitS3Xh3viCZ4jrcq4PJ6DLHd67tjtuAAXib54dCPVEfQ5XIcik/0/2iDeOYz3ceCxrisMi904y0XiMQFfkB7lg6xFHwFxEqUMV0anUNBLWKm8xd3i4zBWOzmASx0UsiW831mA59Xjm+h7HCOygduXHqJatzA7Poey9QnXjTuoVD/j/sRcmDOWLgqnLC5A2wwST+Pn8T629lahSCo291bwu9XA7vcy3m2+gTaUR14thrk9BXasbdiOjSe3nmPpwys0xSi/HpbDd3bIQC6dx/q3ZbRb/j8BEi3Po5cTJpHI9CBNDEa++GyDBN9/BBgAwfDlCVUQaNAAAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-ott { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAdFJREFUeNqMU89r02AYfpJ0iVm7EqhVOxw7dDBEdpiCE1RoEZRddvUgbIex/Rs7eehppyF4LOzQu4MxwYp0HgShIuwwUVSCVtl0s13afl+SzzcpyZYmyF74eN583/s+PO+PSEIIeJZdrtQVI19Cgmk/Ph39bpllXq82g7sgLxVcyKNZpIx8Uj5u5zSjc9Gov8ZihCRC8D+7On4JczevGeTGSEIC4ctKJtB1DTPXi1iCCEkIm1EFlC2Em0iwtWfinXkIzjiO0jljtDC5TtflGIGUQMB+mfja/oPv2Rx9MMjpMdJxOXyXTwkcwIkewfqQ1QtQNB385zcI14FrtQexsSb6SRysZ4Fbf+F6eHwATc9gJGNAm5iCTL5n/LCVRGADNoeaGoHqyaXj5gqQlTODovcwNk5Aj6wXqV8eCo7EDhMonEHpW+dZC7gUG98D3geo7vkb01h9cAvPdt76OGy1xntUd3bjUxAk3+l2sHJ/FgtrT0MUJNfDSm0bjQ/72Hzxxo+NK+h3B7XRNO4UrwymQtMIkdTBU0m+sBOayLsn8Ka78mQDjx/e87HXPkb1+UsfP37+AmZ1fP/suknBb6nefVQXjl06TxMlJfWKNWr+Kv8TYAAkUueexJF47QAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-pdf { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmhJREFUeNp0U0trU0EYPTP35qYxaW6TlDapNKWGbgo2FkF8rARB6rboXusf0F/hyq2U4krFqugqSBeuAyL4SERBstHa0iR9JKZJ7mvu+M0tqZGkH3x8987jzDnnm2FSSqh4ns0VU1ybFzj674Wa3uWiWbfsFQb+jrGj8Xvbm0HlvYVRxhJprpmTlGmum+OMm5uNPZNbtjk3l82ey8++8oW4Jv/H/wdA456g2kvH99FyHNiuAz2dwflbN8YW8zMK5Go/CMfQkAhpGsyQgRCtlpE4jIULyC9fHzu7MPPEl/5ib6WOE0JJNRiHHg6j86mMjw/2gG4bkbY4PW4Yj2j64skA5FTHdaEMPiAJszt1sK0d4suJmY4k0+IDDGRfqmh0u5gejQc+fG8eYCIahRQCEfgQnIuhEkgtONE+dGxYxEDj1DhiEycZ+1YXdUpHCqTMJIYyEES5aXXQsi2kYlGEia5GtHVKn+amPBeCutPgfLALPuVu+xDVPw2EQyFEjHDghbpYNm1yKVVnYjTOerepn4E6XQmLGSPkPkOXWATMSDcjQEkAaqOu6+i/rccALtFL53LI3r0Nq1ZD4/MXZJaWYFer+PXiJc6s3IEgY3+uPYZHTAcAHM+DTE8gnM1CSyaCulv+GrRy8uYyElcu4XfhLVpkpNtn/DGA5Uu0abFH36WnzzCayWAkmYJvWeCkfb9SwY+NDbSoOx4bYqJF8rZqVRRXV/HhzWtUSmWwmWl0RmN4v76OUqGASrmMOkntSHF8MOs954dT08W248wzYsJDOujRBAaqqikTpRo/qqd0/dv97c3Lat9fAQYA4z8bX9nTsb8AAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-php { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAhNJREFUeNqMkltrE0EUx//ZbDaXNrvZzdIkbYOXGgxYQlCK2IIY6EufxGdB8Av44AdR8AP44JOPBR+Ego0PClUKTTXQSmkTYtOkmubSJrQ1e3H2yJSEJNIDs3PmP+f89pyZcdm2DcdWvn7LzkxFHmCIra7nm9ulg8yLZ09yXON55Dgjt1PM2iPs0+aW/frdh8bzV2/SvQBnCLiEqcFxLKSSodlrU9leiGPihWePBkgeEZO6ShC2dCAZNuf6ADb+ldQ5PUPx4BCFcgXfdwq4Ph1Dtd5CZi4Nw7SQiMdCXkl6yVIy/QBWgcU+yx/XsLK2cdHndqlK/lZxH/OpJO7fnsWY3z/YAq+g0TmHpoUH2vB5PXi8RD9Fo10aAmDJTgWyIuOupmK38rsPcOvqJO33XWEvwLJsmKxHRVEwf/MKWl/yUMf8mIloWN8rw+sP0D6PHQmYuzGNgCRiMZVA17IQV4OIaTI8buH/AJMFd02Tkp05PO4jnWvc57EDAINt7u1X8Pb9KgI+Lxbv3cFR8xjx6AQ+b+Txs/qL9KePlih2CMBCq92hg2qzt1AoV7H5YxdhdqhHzRbgcpFeqdUplpvQW4FhmAixZ/sws4BoWCM/qmsE5XqE3dDQCrqGAYWdejqZgK6GUD8+IV9VghBFN1RZJv3sT5diBwC15gncggCPJKF0WCPN8dun55jQdVpz3Ynl9leAAQAJhiGatD9AOgAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-png { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmtJREFUeNpsU9tOE1EUXXPp0CAUWmJbC04xBANNTF+kKhG8fID6aqL/gPEj9E0lIf6Dj30HL03wxQtVIC0QKrWxNG1Dk9Z2Oj1zxn1m0oIZTnIyZ8/ee+211z5Hsm0bYg29fLGpxWIJWBYGS5IA8ncKhT9Wvf4Yqprtu+w3q85X7f9QxseD/pmZMZsxN9fnc5JNw0ACGGv6tPSvyvEDKEoWZ5Y8OHHObKpucw4B0t3agnl4CJPs2YkQVu4s61ORaBqMJc8CDBiIRhhVM9bXYdVqYAcH8M3NgS0tQQsFcfdKHEbvlr6WyaR/V6uPKPy7B4DT7lUq4MUipMlJ2MPDUKtVfKZ2nn/5BoNbkONxXeb8LYXe/A9AJLNWCxgdhZJagDI9DZg9qIkEytRSkdqTSFQtGILSbgc8LViM+tc0yPfukzIyOJ359k9YR0eQdB2KmBbpwXoM3Dod1SkD+scpEapCI5DdpsJhIJcjajQZagcjI+5oLe4VkeQnyiZgdIH2X6BJ7dSqQLfrggjw0AQwP+/GegCIHppNoFAgEMO1RZKo7BQgRi3yN05cnwdA0BQMAgF3C6pnbuNg92M9AFT1diSCh6kb+FGvo2MxnBB9ocZxp4Mns1cde213B81e7xwAcl4jkaa0IUSjUdLJwkL0Ej6VSvArCt7l81iku6GrKnYEU89VJlSJRmR0Dax+fI9suYxSo4HlWIw6M3FBlnD9YhiXabyOsOeIqG7TzDeIYo6EDGp+ZPb2kKKqH8h+mkxiI5/D1/19J3bwYPvPWXq2skkiJVxesqt0XzghpKM8nRVV2Lv2q9eLIvSfAAMAaacnllcFBmYAAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-ppt { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAkhJREFUeNpsU11rE0EUPTM7ySZpmzT9DNamWAtFfSiCigr+AxF9zKtv/hvf/Aki+FEi6ov4ItWHPGiwiBUKoUqqTUJImmR3M7Mz3t0kNe1m4LIwc+65595zlxljEJzdR5uf5nLmsvZx6gSvtd9W9bjhF7jg5dH9nRc/wq8YXaTSJptb0xklx7IZoKUEz1zJ2DUU69/37vFYrDxegJ9U0lC+AoIIVGg9CL+vIObP48KDQn7x0sWiVnJrnEDg7KGk+i/Ac4iUM/R7BsmrSSxtXMfa3X7el8+Kjf3KfUJ+iRJQw4w0Tc8BRyWGRAZY3rBR/VlC+XED2ayDhZyXl03+hNA3TxNQshlGLAnE44zCIL1goXZwiMNvB1i6zbC0KuAsxNITWwgNMYPeLVJiFEO9ArjHAivrAjNzBr4f4vwIgdGD4YUACsZCE8AtYGWT5jCsGQw5wEYJzP/pj5RwYTA1b07eQmfZ8P0sgdaM2FlYwWkMgMpl6NQAO33GKM0wsQWflkh1uqGVmVWblsiDkQyqxwfag35SqcktaEWTUTHYNx4iGU/C29+BvX4Lpu/C7zYgFjegSY63WySsHyXwpYHU00ieu0bAOuJbBTArBkiXKiaAmTzcvRJUV9E8rOgqBwqlY8ASs/AadbRLb8CzeTjVClqft6FdB17tL7yeCbFRBYoLr6vR/PiSEl5BZJaBD0/R2nkOZqfQ2fsKt+0SEQ+GLSIEUvJm+6jbah2+pS2aon+4g/afd4SYJVuA7vvXdC/IHQtSoTnK+yfAAIEaId1m+vudAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-psd { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAqxJREFUeNpsU01ME0EYfbtdKKWGtoItRWgJHApCBE2I0YuoiSaaeDJeOJh41YN3TfTixcRwMfEk8eDJGA+Eg0YTTRRMg02KKFooCBbTlkJLS7f7P+u3K9Xo8iWT3Zn55s173/uGM00TVlwZfzJztD92iKO5ouvQGQPHcQDN380vlDPr65fdLj4Oa41i9sFt+ytgN7o7woGOrqgvvpLBaF8vWj1NUAwGTVNRM3mf5vU/zaU+XySQuTqIFXz9hxmGLkoS7r+YxvVnrzGzlgXPDOzUZPT4m3Dt/KlIuH9oUjXYEHZZ/wOgGQZi4TZcGI5hLb+FO++TSOSKcLtcMA0dI0EPrp4+HtnfG5skiUecDGwQE2MjAwiGWlFVNDz+tIyCokJhPKYSX7Gdz2I01hOJdnY9rJ/7UwPGTEiqjtbmJtw4MYx78S/4Wa3h5UoOYwPdIOp2Xi/t18rlFgcDw6o+ydiWVRwOBnCpL0oOAMmNEhLZIgSeoxwGSWcERon/M9DoBknTIdNQNAMnO4PIVGpIFXcwndlA2OtGc4MAxml27p4AIulWSIa9QVadiYSoJxhqBJivKgh5ad3k9gaw6JdlDaqq7q5wINY4F22HaLHSDZQkBW72O9cBYFEviBIURQH7a7MN0uDisUW12ZZcaGlmdq4DwCqeTo1zNtZuW7hUqGIw7MNqSUS2ImNsKEpSdEwt5lGhfQdAkQBEoub3NNrDJfAIeBuRrcrY5xGQ2RFJAjl00I8PCckJUCB9q1URBnk38XEJEuk41tmGwZAf66s1VOh2keqwoUnYpFxHH4iKIixkN3HzVQKP3iQR/5GDKMuYmE3h+fx3MHqh1sMafztHLuiCg0FAk0uFdLqcpGY5QEXbTC/j7mIaVjc18DxufUtBJ/vcggs+3ijVz/0SYABsJHPUtu/OYwAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-py { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAlVJREFUeNpsUktvEmEUPTPzTUFmgJK2UqXQFG3pA6OBLrQxamJcaYwuu3Dp0l9iXLvVtRuDpgt3JIYaTVSaxtRHsJq2xEJBHgXmifebMhECXzKZme+ee+65516h2+2Cn2cb2VwyHl12//vP2/zOQaF4uD7GWN69e/LogfNm7kUsPBFaXYwHMeK0OlpQEJApHJTuykzK98dE98O0bLM/UNgr4v32Dj1fwSQRt9dSsfmZcMa0rIv9ODaqYrPVxuPnL1Cu1aEbJu7fvIZUIo4bqeVYRzcyv/8c3SPYpwECt/dmu4ON3Ed4TymI+hQc1ZqoE+F+uQLDsnHlwkKMscJTgl4eJOi9fxZLePNhGx6ZQRRFqH4VjZaGSv0Y6cQcJLpra0ZguIWegqDiw7lYBBZV6xiGk9DQDLzK5bEyF4Hi9VLMsoYI7J6Es5PjeHjnOl5ubqHaaJGBEkzbxplQAKIgDmBHekDTgI+qKKqKLvNApgmEgyquLs1CoFn2Y4cIeLJpkjoCLkWnUSIF3JxISIUsCjAoxhWNJLBIJs3YeXj/08oYZkOKY65HllE/bkMmY504YUd40HUq2JSSyW6iVPmLiXE/ZMYQCU+hXK3h1toqdNN0sEObyKtqtDQ6kXDwcadDS2TBryp4nX2HxXjsJK6bDnZIAZem6Tp5YMMmicn5OC4lztNWtvB9cg+hQABtWjKL2jH/T3GgBcYDXEE6mcDM6SlaJAGMWkivLBC54ZgniZaDHSI4rNSqn7/t1vgkGJPwZXffSeCjk2iUWz9+nSTQN8e6ef8EGAClUi/qoiOc3wAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-qt { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnVJREFUeNpsU8tu00AUPU5sp41NkzRxpfSZqi0VIIQqEEJUZYXECvbwCWxYsuBD+ABUFrDrCnWBQEJdIWigBSr6pqRJ1ebhxrE9M7aZmSrQ4o505fHMnXPPPWdGiaIIYrx89GKpNDdxmXkU3aEoCsT+z8W1Sm21+jCpJctQTvaerj+TX7WbnJ+0cpfuX8mQtn8GgJ4AZtIFY2Hz3foDVRcgyt+cRHcS0IARh+D/8G0PpmVi7smd0dLs+AIjwTVEiANEYYQwCHlEZyJgIQKfoX84g9uPZ0cHZ4YWmE9nuufU0wABCSSImMsWEgqSuoqA/39/swZFTWLy7vQo7dDnfPvWWQa8GuOV3IYLJXmyzDzG2/ChZ3pwbHdQ267BKJoYuj7SF2MQhiF8LuDK/Gf0DKTBKINz1IbTbEMzU1ANDW7LAfEIQKIgBsBFlAx6LYOz6MAcvoDCtAVGGPKlAiIu/F55F33FDA6W93EOAOMaMOl7biKPwRtD8Foetj5sYPfTDtxjl1f3Ubo5jkQieQ4ACSUD2iE4XDpAdbUiW9D7UsiN9WNkZgxajwbd0LGzt3keAJPUc1N5SVeENT0Ao2BKV6QzwlZeRBSKAYhe3aYHcZWn7l1EfjyPypcK9LQGa8qCvW9j9+MvaasQOHaRhGWdhsNLR8hwodYWf6B4tYjDjSOovRqq32rSYq/lytw4A77o1V2ERiAtzY5kkUrrsH+3QF2KY87ArTtQuQ6nAf4x6FCV1D001+vYersBM2vA4y1Rm2D7/Rac/TZIw4d/6MrcGAPf9htN0miJh7Lyuoyvr8rQeP9iVJcrSKgJ+TrFcyYebXTP/RFgAFQobmIOBxbsAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-rar { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnpJREFUeNpsUktPE1EU/u68OgylZXi0hZACQU1LEKKCMcat7jTRnQsXxsQtv4E/4M74P1iriUaNCw1FgxpjCJQKKAU60+m8mJnrmSll4XCTc8+959zz3e88GOcc8aq9evChOHl/lvMoubvWX/z4+BwTlbvw7bXdg8b7h6LE1gGW+O88CRMt4XTlR6/rYxce5Xv3jlHH19fPkBu+gWy5mlcFb3Wn/umeKOEMJF5C7xCFbtA9dRXjFoYKGiTRAlPGUV1aKU9O3VwNQ74A8DQAIZxqAuAhBPIMFYpQVAVB4CPSZjEzv1weH5tbDQN+JQ2Abu488mnzIbAAA3o/VK2PwDJo7r5Fy7ZRuvi4PFS6+qIXdVYD8Jg6BUcuOD8BozSLlRWyicgVKkTMQWwUlFF0Ooe5FIPk57BD7G0SiywyjD8bCDyHsOkeeeR3SUxEkROmU6BfQYFJMHfhWXV8efkUrb13VPMTsrcTQSzxZ/+n0GVA6EGbSGdgG9vo15fg2nFgbO8k70SRdd+mahDT81vUxTZRlJBRMsjq89C0EXCvSf7TIBZ136YZUJEiE7LgJ2dN01BZuE0dkIhxE7KcQTK1QUj+cwAEyrPZ+IydzRoyah+mLy2isbWBweESJEnB9q+1RM9Ub9GQOWkABg8HjRr2d9Yh0hTlBlRsfn+D4vg0BvUC9rZqECUJuk7Tzr1zahCYlB6HJAREPwfbbMBzLBzsbUKVI0qBgQkc+SxgWUYaIAqOpKwKXJ6bgGlaaDV/YvHaFNrtDsKTfVSrJeqIg/bRNwjclFIALeP3saybhu8SC4VBHwnhBXXIKocYRXD9QzBi4Xgchmkd9+L+CTAAMqwy+ZzluBgAAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-rb { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAixJREFUeNqEUktvElEU/mag5f2yJhXLwxIt0kiqsVEXujP+A925cu1Pce3WtXVtYuJCF7KtTY0NrVQIpRVKeXTkMcO9F8+9ZVooJJ5kcmbmfOe733fO1YbDIWS8+/g1dycVX7W/xyO3vdsuVKqvnE7HZ230783rlyo7bVBicSGyfjsVwozomVbIPe/c+FmsPHfoRKJd1HT7hXHBZjVbA4aA14NnD9bC2VR8gwuxPi5Sx39Cp+M0XUP0ahhP1jLhW7HFD4zze3b93ILtXYyyVKlR8/5hFbnvO9gtlrGSjOF+OpXkYviWyo8mCS4R6bqO4p86vm3v4fC4DrPfw4unj1XN6JvBaQtjChzUXK43sVU4wNFJA43Tv/B73edQwTmfIhAjCVL6UdPAj1IVFSKhCdAcAI9rnjBiAjtBYEu3GEeh1sKJ0YXR68sVIujzIhzwY8DEBHZqiLRKkicQDfvABxaiQTc4Y/C65pCOXwcjcmlvJgHtlwi4epYifiQWgmoLZwPW6HQG07LgcOgKO0UglAKOTt/E+09fwAiUWU7QAE9xUK3jbvomsispZVHMVEDSZdHo9rCZ/4VIMKAu0XGjpU7d2S8hk0pCELHEzrjKnCQOYJoD+Dxu1RyiwUm5LaMDo9NFt2cqDLvY4oQFp/QpfT/MrmI5FkWebt+NpWto0j2QmQkOjZ9hpwhqjXZzM/+7LU+cc7lRrjXh8/lVLRK5ovLWXglOsiOxdt8/AQYAzv8qbmu6vgEAAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-rtf { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAe5JREFUeNqEU01PE0EYfnZmd5FSvgLYFuwWt9EgHyEaox68eDJevHvwJ/hTPHv1N/QgZ2NC4g3kUAQKFKGhjVKqRrvbnRlnht262FHfy+y8877PPM8z71pCCKh4/ebt+rJfXEz26Vjf2mnsN5rPKKWbVpx7+eK5Xu2kyMtNTd5d8MdhiJ9BOO7atFI9ajy1UyAqSPIRMR6ZmoNehNHMMB7fX/UWvEKFMbYKE8DfQnAhwRmmJkbx6M6S5+WmK2Evup2c9yUk2nnKA0XVcSiGXAe1k5beP1i+4RFCXqnPywB/AKVzK34RjHNYlgVKCH50w7EBBogbTa/AVM5SgBdn0gc2AMDjPsbFPz2xye9asweS6n+NTbG8BCCfUtLjff2WoVnVpAH6z6hMUtJE3EykYfpF4vUiL3QNS7FMeSAQRBHW3r1Hq91B+VoBQRji4+ExFsvz6Hz7jm7Yw5OH92AcJKW9G4SoHhzhy/lXbB98Qmm2oCXN5WawsV2TACEoJXqwTKOsb3BtR2ucmZxANpPB8JUhyPnHWDaDpfJ1eZFALzJJ4MKO5MEtv4TSXB7V/br8iQLMz+almRZWbvoo5q9qRlxwewCgeXbe3qrVO5ZkUD/9jJGRLPaOm6COi92TU1DbxYe9umRD0DrrtJO+XwIMABWp9nS+FgaoAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-sass { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MDNDMTBBM0JGMTE5MTFFMTg3N0NFOTIyMTQ2QzhBNkQiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MDNDMTBBM0NGMTE5MTFFMTg3N0NFOTIyMTQ2QzhBNkQiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDowM0MxMEEzOUYxMTkxMUUxODc3Q0U5MjIxNDZDOEE2RCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDowM0MxMEEzQUYxMTkxMUUxODc3Q0U5MjIxNDZDOEE2RCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Po72XUcAAAJcSURBVHjahFJdTxNBFD1bykc/ttvdtttWGgI0bYrUgDZoNYqRJ014kMRXHvwB/hQTH/wFhMREJfFBQxBjhMRIFEQSCAlQxKYGggiU3e3HbnfX2bFt1EU9k9m9mblz5p4zlzFNExYmpue/jmTSZw5PZAl1MAwDT0c7O72wvPdudeNakPNtOZ0tsM7cvzdOc5yN5LDAsTFRAJks/kC2PxFRVe39Si6f4byez62EpAEH/gNN18F53Ri/Ocxf7OtdLMpKT42s/ZPg1cISJp/P0tg0TBzLCoK8D7eHh4RkLLJ4cCz12AjMXwgez8yhqtVo3NbqRKlcxcSL16gZwJ2Ry8KVc8kZO0HdTKlURn+8G6PD2SZhLMQj96WAiMAh2RXFYKI78lcJcx9WYBCycICnpNbojUWpD5Y0C4Zh2D0w6hWc70uQZC+IWfQZrXF0IsHvY+meBd08haAhoVMMQFJKWF7PNZM+klhRyogGhbqxOIXAMOtEwGAqDqVcgbVkkE+5UsEAWavf0az2t0ZqvK2qabh6IU3joizDwTgwej1LdVfJXkdbK8mt2QkayO99A0/0trQ46I1lVcX+UREhnsP34yLp1AD1xibBMuntpzU8mJyi3Tc1O4+l9U06n7x8Q/8PHz1DrrALt8tlr0CrkbJMHTop9Sk5sLa1g8L+ARJdnShKClY3tunN69t5iGLYTlCtakjFY7gxNABdN3B37BaqqoYT8pyX0in4ORbRkIA46YlDRbUTbBZ2Jb/Pw4qiKFnapcpPo9pdbrg8DjAOBsFgELJmsGs7eWkkc5bu/xBgAHkWC6UPADTOAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-scss { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RkM4QjYyNDVGMTE4MTFFMTlBREZCNDNEM0ExMTk0MUIiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RkM4QjYyNDZGMTE4MTFFMTlBREZCNDNEM0ExMTk0MUIiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpGQzhCNjI0M0YxMTgxMUUxOUFERkI0M0QzQTExOTQxQiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpGQzhCNjI0NEYxMTgxMUUxOUFERkI0M0QzQTExOTQxQiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pkf1yeMAAAJbSURBVHjahFNdTxNBFD0tLULpB91uodVWPmorUIxo0VSiNSExMYYHE33l0Ud/in+C+OSjYgjRGDBRCKJIUkIEWi0WKlja0ul22+5219lJ26gLeiezuXvn7rnnnrlrUFUVms3Mvd2bjIyezRVLBA0zGAzo6jhjm1te+7EU37rFO+w7JlMbtG+ePJ5mOaZmci/nsPl6ONBtw18WDQc9tZq0sp7YjTisXV/NFKRpRvzHpHodDqsF03djzuvDg6vHJWFAprF/Arxe/oins6+YryoqCiUBvNOO+7FrXMjnWc0WyIAOQP0N4Nn8IqqSzPx2swllsYqZl28gK8DDyRvcxKXQvB6gISYpiwgH+jEVi7YAfW4nEqk0PJwDofNejAX7Pae2sPhhHQoF63U5Gai2Bn1epoPWmmaKoug1UBoMrgwHabIVVCx2jdrKFwm67TZ2plldPQGg2cK5HheIUMbaZqKV9In6giDCy3MNYXECgKI2gICxoQAEsQItpNCHWKngMo01arTY/jFIzbutShJuXh1Fm9FImYiM7tTtKOtbO+toN9Nc+fQ5SGUOIVYl7HzPIH2YRZ0y2KZ+sVzBHn2v1mpMGx0DTaR3nzfwfGEJdybGkdo/wEigDyvxLzg4yiESvojZhfd49OAeLJ2degaSLIPOO6vwgiYaaRErTRREEdn8MeJbSVZ5M7nLdNExqFLaQwEfFfACQn1+HBWKSKb3MT4Sgstuh9vVDa+bQ4DORE6o6RlspzMk9TOPfr+fiLJCLFYr3TZSKNcI7+aJwWQmPM+TkqRg49tu65f/JcAAMwMas6WUKd8AAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-sql { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAh5JREFUeNp8kctrE1EUxr+ZyXMkoa1NBROaSkpTBE23PhZ25cql2y5duvAPUdGFS1FxIRRBXZlFQ9GVdDENIhGJxkDsw2mneZnM83ruNZlOmNoDhzlzz3d/9zv3Sowx8Ch/qlYK2XM3cEJsbH0+qjV/rd6/u6aN18b7RMFT+9aosP/Ex+0ae/puw7j36PlKEMAzctKJ3aGFamMHjV0d+wcGitkMrpWWp6hVIciEk2MAOwbUWjosx0UiFoWqJpGMx5DNzODq5aIPoa82AWBg/lyKLMH1PMp/a9XvLXLzG1cuFlBaWpiKxaIPSLY6CaC93ggQjyiQZRkeQSzLRovGaPciWLt5faSWEBoh6KBvOhiaNga0+Y9pwaFxvu7rfp8F5pWDt+qNMp2IijHGwddWCvN+33/CoAOP5nVdT9SdoQ1JkggiQ6Yvr7V60+9z7akA2gfH9cRF8hO5F5Ve4lQAF9uuK+qFsylkzsQxrcaQm04hdWkR83Mzfp9rQ3fAFzu9Ph6+WMfjl6/pGBdb2jbKmx8QlRjWy5vkyhUZBPgOeGNHN9AbDLGUz6He2hVj3Ll9C8/evsdgaMK0HV8bcmDTU0UUBYXcedR+NLGnH0I3jvDk1Rsy46FP4C/1BtrdntCGHNiOAzWZgEKQ5Qt5lIqLojbaXSQTcRy2OwT4SZqk0IYAOgkVWUE+lxX/zb0DpFNpkTzmZmfFtzewhHYcfwUYAMZmVaZQlLFHAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-tga { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnxJREFUeNp0U89PE0EU/ra725K22ILRGipb22pMG6JcSEQTbUIwnozxpBcvepeEP0KPogcT/wlNT17kIKbEmChFUYKGVtL0R2gLtNCl3Z1Z3+zSAlonmezOe/O+973vvZEsy4JYnqdPMu6RkSQYQ29JEkB+PZcrslrtPhQl23VZc8/tr9I1yMHg0EA8HrBM04lVFAhoY38fSSDQVN3pfKV8G7KcxZHl6v1xblqU3eLc3p2VFZjr6+gQgwsnhzGTuq6Nhs6kYZqXjwL0GFhEl3U60OfnwWs1GGtrUKNRsKkpeIIBpKIRtI1J7cX7hXRhc/MOhXw5DkCZGG2zXAajzFIoBMvng1ypIKOqmP30GW3OIEcimovzlxRy5RgAFwDEAIODkCcmIMdiQLsNdWwMZdJlg8pzEUt1aBhKq3XinxKYqF9yQbqRIqsMy+0Gyy47bKgUWXSLtDENE5wdtuqQATm50F1VnPbRGeEw8HXZbiV8fsDvI9ldju9vADAyihLEbrWAZhOoVp3z6iqBUiB1A4nEfwCEsbkL/M4TgE5n5jDx+oTEzp1d8m9tC8H6MaAB0imzx0NU/WKUYE+loEyawDBo2ui6TGfT6ANAxrvx87gYCGCxXEKVJvCWFsG3eh1vN/J4OD6Od4UC8o0G3TX7TGLHwI9iEQmvF9X6Fh7F4/iYy+GcLOMSlfEgGsP0qdNOmX0BiGKpVkV1bw/1nW2b/gCpf1PTcI+Y7eg6ps+G4bG4PR99SjAVo9HE4q+fKNE0vl5awuSohjeijbRefVjAtUgEQRK7Yhi9OKn7nKWZxxlSPWl3QwgnaIrW8QMhD542vUbx/W49m7sq4v4IMABOqi3Ej7bAEAAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-tgz { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnhJREFUeNpsU1trE0EYPbMzSTfdtInFtkkpiaXVWou2FRUEn/so6JugL/oH/Af+B1988if40jcFERQURNBSQdDWlLQN2lsue8neZsZvc7FoOrDszM75znfOmVmmtUYyvry++36yfOeS1qqzDtvH2P76ApPlW3Drb2sHex/uccHWAdbZX30kO2+B3siN3zhTnHuQ66+95i423jzFzOVljBdKOZNHazvVT7e5wF+SZBj9iZJ+3J11mbW2kR8T4LwFli5i4fqTUvnczTUp9RLtDhKgJx0q4dEwWAxrREKICHEsoYYXMXvlcWmquLgmY71yCkG/c0AkARgLMZpnMDMpGNzEYe0dGp6HwvmHpbHC1Wf9MnFCkHQOyYEPzSJwQ2B65Tm5NZG3Fshim6wbMNJn4bpHowMKtIqo2COgR2IcAptwjvcgo6i77igjEmVDqbY8xQJ1VwRULhiBI6+G9Zf3cbTziuzIDkmHSNqECTFgQScEcYuc2NA8TcdYwXD+GkK/TYVN+u72WrIudiAD8o6oAR2RRCmQMjis3CIy1iSpPySCXhFTXeyAgh4BR+JVw8pauLi0Cp4yCX9A90FQhnSBYtnF/k+Q+HYam9itfIZB3QvT8zj8XSW5EhNTs9ivbSLwPUzPLNPJBIMEKnaQYg6aB9+RGR5F5VsNgnNKXMI1NdJGG5WfHzFVLJ7k8c8xUngpVodlDSGbFYj8Y4yMpOG09lHf3yIFPzA3fwHZTAQVtU4JUTeFDrdgDdlI8wAz5Qy2KxswReI7QODZcOr0ZH3q2hIDBI7zq16tuk3FNPxAI4wN+pkoccYoE4YJU5EdUtM4Qst26v26PwIMAKj3P/2YUKgYAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-tiff { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmRJREFUeNp0UktPE1EU/qYzHWstlrYJNcWUElyUJsaNGh9B0g1Lo0v9Ey78EbrVxBhXuHShm25YGBJRQpAYBDEWpaEPEhksdVpbyjzveO4MfZDCTWbauefc736PIziOA77OPH2yJCcSGdg2uksQAKofFou/7VrtASRpvVNynj13f6XOhjg8HAlMTIQdy/LO+v3uYUPTkAHCTb+cK+0pdyGK6+hbvu4/xiyHbncYAwfR19ZgbG/DoO9LsSgeTd9JXoxfyMG2rvQDdBlwIZauQ5ufh12twioU4E+nYU1NIRCNIDs+Bt28mXzx8VNuZ796j9q/DgAwomwqClilAmF0FE4wCInAlkjO4y+r0JgNX2os6XPYS2q/cQyAcQatFjA0BPH6NYipccAwIGUy2CVJFZInkKlyJAqx3T4/IMGmJkeWIWSz5KgI5pdhb3yDXS5DSCYh8rTID8s0wexeVD0GtMd85KkkefFxUfE47M1NokbJkByEQl6tL+ouAI+MUwbFhnYbaJKc/Sqg0x4H4eDRGDA56fUOABA9/GsCpaIHwr8FOhQ823O5RfW66tUGADhNy3RNRDjcN41HLxdQ8J6jYTsOQLfOJBK4f+s2/uoathoNGKT1MtFeVHZxdWTEZfEq/wMKl3rCJOIzTV6ADs2R5ulYDDNkYjp0DhrF+zCVgkw31+v1UxjQZkNV0SADd2o1MIuc9gmY+/kLxb0/UFoHePd9A1qzeUoKpilx9xcLWzgg+u/zeVfuQqkM9bCN1ysrWKXxdtPgvScwUAm58XZ52W16QyPtifRUzi588GbEi1ztHPsvwAC4uC9qhnsZvwAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-txt { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAeJJREFUeNp8UrtOG1EQPfsyXiyzBguIJSyChZBBEFCKpKHLo6egpErNn8CHgH8gkZIiTSIXLhJAWCgkoMgRMSiRBSK29z4y9+I1d/HCrFb3MTPnnjkzlpQSynY+fP70fGF2gQuByCz6lfdd9Uurfvrrjes6762eb3tzQ69uFJwPsqOPC+MBEmxxphi4tlU5OGmsOzaBWLc+O9oIIVhScidkyGZ8vH62nHtSKlaI4cse6TjAfSaFBBcco0EWqyvzubmpyQrj/FXk75cQaSEMeMXU8xykPA/Hjd/6/LRcyjEpt2i7HAe4A2TeLZWKUOJaVLxj27j813EHGKCXaAJExu/4BOdiAED08riQD2riOrexyRoYc3CvsAbLGAAjZga7vgZG23WMCdBvoxKJc36TRBlMiaa2JByjNqqD8qkYc1pjDK7abey+/YhrWlfKswhpiCR96aEU9o5+QE3g2ovVWDm2Sc22bBQm8vrVpbkS9r+doPr1EOWZaQ0yFoxg2PcREosEAI4uvZhJpzFMP+cSXRbq+043RManez+tNWKMI6GN0g0Z04HFR+NoNC/0yx717efZOSbzY3AcR4Op2AGA5p/W31r9e0vNgSrh9OwCrpeCkqvZuqTybnpRqx/r2CjvvwADAJC/7lzAzQmwAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-wav { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAApFJREFUeNpsU1tPE0EYPXtpKbX0wqUQKVQMFdIXQBNCQBs06KP+B8ODGh+Mf4b/4IsGE54kxhcMBrkp7YOQgBRvSKG73fvsrt8Otoask0xmd+b7zpxzvm8E3/cRjPkniyulW0NFy2JoDkEAguOlpXJ9p3L8MBqVl4O9YHxae8pXuRlcGO7KPLhfTDVUqwUgigJMy4Whm6lEXHjxYf3XnByRN0QB/2KaH7btMlUxoRJAcyqKhdOaht7+DJ49n+2cvTnwynXcsb+kLwJ4rgfmMDDGWqvneXCZS9ND7mov5h9ND85M9y86Dpto5rUkuJ4Py3YDJpy6QGJPayqB+Njf+43XL220t0cwOZkfrNXsBUqZugDA6CbLdAiAwaek1ZU9LmP8Rh6S78GsGxjOp9FdzKJaVZIhBgGASzK21w/wbrnCk8euX+EMAjaaZuPHdwUdHVFYluuGPGCORwwYjg5rqOwccRk+3Ux0IEvntmsNG4ZmUayL/wAwKHUNfZfTKN0ZRaw9Cof8qJ/pMAyHy5KkAMTksSEJtnMenM7EMVMawbejMzJRh67bXEYiIXEAVTW50SEAhzqwfqrBcXx4VOhYm4RsNgHbsJFOyZTsQ1MN+hcohoUlkFiMT+TQFpMwXOjGpXgE+XwGk1N5pFJtKNCequgYGupCRBbCDOp0KBJc4VoP3dyBONW8uydBgBHUThqQKCk3mEZ/LoUG+RBioJO7VarAwEAntjYPiUUW9Hh4b2R7k9j98hN37xWx8fGAt3eIAdVMLn+uUv+b2KReSCZjZJiB9bV9jIz2ofr1BKvvd7G9dRC80lae0HzOt+cWVnrSKDrMJykifwNBpCgE/UAllEXufmDu8Zlffvvm8XSQ90eAAQA0pF7c08o4PAAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-wmv { + background-image:url("data:image/svg+xml;charset=utf8,%3Csvg id='Layer_2' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 100'%3E%3Cstyle/%3E%3ClinearGradient id='SVGID_1_' gradientUnits='userSpaceOnUse' x1='36.2' y1='101' x2='36.2' y2='3.005' gradientTransform='matrix(1 0 0 -1 0 102)'%3E%3Cstop offset='0' stop-color='%23e2cde4'/%3E%3Cstop offset='.17' stop-color='%23e0cae2'/%3E%3Cstop offset='.313' stop-color='%23dbc0dd'/%3E%3Cstop offset='.447' stop-color='%23d2b1d4'/%3E%3Cstop offset='.575' stop-color='%23c79dc7'/%3E%3Cstop offset='.698' stop-color='%23ba84b9'/%3E%3Cstop offset='.819' stop-color='%23ab68a9'/%3E%3Cstop offset='.934' stop-color='%239c4598'/%3E%3Cstop offset='1' stop-color='%23932a8e'/%3E%3C/linearGradient%3E%3Cpath d='M45.2 1l27 26.7V99H.2V1h45z' fill='url(%23SVGID_1_)'/%3E%3Cpath d='M45.2 1l27 26.7V99H.2V1h45z' fill-opacity='0' stroke='%23882383' stroke-width='2'/%3E%3Cpath d='M9.1 91.1L4.7 72.5h3.9l2.8 12.8 3.4-12.8h4.5l3.3 13 2.9-13h3.8l-4.6 18.6h-4L17 77.2l-3.7 13.9H9.1zm22.1 0V72.5h5.7l3.4 12.7 3.4-12.7h5.7v18.6h-3.5V76.4l-3.7 14.7h-3.7l-3.7-14.7v14.7h-3.6zm26.7 0l-6.7-18.6h4.1l4.8 13.8 4.6-13.8h4L62 91.1h-4.1z' fill='%23fff'/%3E%3ClinearGradient id='SVGID_2_' gradientUnits='userSpaceOnUse' x1='18.2' y1='50.023' x2='18.2' y2='50.023' gradientTransform='matrix(1 0 0 -1 0 102)'%3E%3Cstop offset='.005' stop-color='%23963491'/%3E%3Cstop offset='1' stop-color='%2370136b'/%3E%3C/linearGradient%3E%3ClinearGradient id='SVGID_3_' gradientUnits='userSpaceOnUse' x1='11.511' y1='51.716' x2='65.211' y2='51.716' gradientTransform='matrix(1 0 0 -1 0 102)'%3E%3Cstop offset='.005' stop-color='%23963491'/%3E%3Cstop offset='1' stop-color='%2370136b'/%3E%3C/linearGradient%3E%3Cpath d='M64.3 55.5c-1.7-.2-3.4-.3-5.1-.3-7.3-.1-13.3 1.6-18.8 3.7S29.6 63.6 23.3 64c-3.4.2-7.3-.6-8.5-2.4-.8-1.3-.8-3.5-1-5.7-.6-5.7-1.6-11.7-2.4-17.3.8-.9 2.1-1.3 3.4-1.7.4 1.1.2 2.7.6 3.8 7.1.7 13.6-.4 20-1.5 6.3-1.1 12.4-2.2 19.4-2.6 3.4-.2 6.9-.2 10.3 0m-9.9 15.3c.5-.2 1.1-.3 1.9-.2.2-3.7.3-7.3.3-11.2-6.2.2-11.9.9-17 2.2.2 4 .4 7.8.3 12 4-1.1 7.7-2.5 12.6-2.7m2-12.1h1.1c.4-.4.2-1.2.2-1.9-1.5-.6-1.8 1-1.3 1.9zm3.9-.2h1.5V38h-1.3c0 .7-.4.9-.2 1.7zm4 0c.5-.1.8 0 1.1.2.4-.3.2-1.2.2-1.9h-1.3v1.7zm-11.5.3h.9c.4-.3.2-1.2.2-1.9-1.4-.4-1.6 1.2-1.1 1.9zm-4 .4c.7.2.8-.3 1.5-.2v-1.7c-1.5-.4-1.7.6-1.5 1.9zm-3.6-1.1c0 .6-.1 1.4.2 1.7.5.1.5-.4 1.1-.2-.2-.6.5-2-.4-1.9-.1.4-.8.1-.9.4zm-31.5.8c.4-.1 1.1.6 1.3 0-.5 0-.1-.8-.2-1.1-.7.2-1.3.3-1.1 1.1zm28.3-.4c-.3.3.2 1.1 0 1.9.6.2.6-.3 1.1-.2-.2-.6.5-2-.4-1.9-.1.3-.4.2-.7.2zm-3.5 2.8c.5-.1.9-.2 1.3-.4.2-.8-.4-.9-.2-1.7h-.9c-.3.3-.1 1.3-.2 2.1zm26.9-1.8c-2.1-.1-3.3-.2-5.5-.2-.5 3.4 0 7.8-.5 11.2 2.4 0 3.6.1 5.8.3M33.4 41.6c.5.2.1 1.2.2 1.7.5-.1 1.1-.2 1.5-.4.6-1.9-.9-2.4-1.7-1.3zm-4.7.6v1.9c.9.2 1.2-.2 1.9-.2-.1-.7.2-1.7-.2-2.1-.5.2-1.3.1-1.7.4zm-5.3.6c.3.5 0 1.6.4 2.1.7.1.8-.4 1.5-.2-.1-.7-.3-1.2-.2-2.1-.8-.2-.9.3-1.7.2zm-7.5 2H17c.2-.9-.4-1.2-.2-2.1-.4.1-1.2-.3-1.3.2.6.2-.1 1.7.4 1.9zm3.4 1c.1 4.1.9 9.3 1.4 13.7 8 .1 13.1-2.7 19.2-4.5-.5-3.9.1-8.7-.7-12.2-6.2 1.6-12.1 3.2-19.9 3zm.5-.8h1.1c.4-.5-.2-1.2 0-2.1h-1.5c.1.7.1 1.6.4 2.1zm-5.4 7.8c.2 0 .3.2.4.4-.4-.7-.7.5-.2.6.1-.2 0-.4.2-.4.3.5-.8.7-.2.8.7-.5 1.3-1.2 2.4-1.5-.1 1.5.4 2.4.4 3.8-.7.5-1.7.7-1.9 1.7 1.2.7 2.5 1.2 4.2 1.3-.7-4.9-1.1-8.8-1.6-13.7-2.2.3-4-.8-5.1-.9.9.8.6 2.5.8 3.6 0-.2 0-.4.2-.4-.1.7.1 1.7-.2 2.1.7.3.5-.2.4.9m44.6 3.2h1.1c.3-.3.2-1.1.2-1.7h-1.3v1.7zm-4-1.4v1.3c.4.4.7-.2 1.5 0v-1.5c-.6 0-1.2 0-1.5.2zm7.6 1.4h1.3v-1.5h-1.3c.1.5 0 1 0 1.5zm-11-1v1.3h1.1c.3-.3.4-1.7-.2-1.7-.1.4-.8.1-.9.4zm-3.6.4c.1.6-.3 1.7.4 1.7 0-.3.5-.2.9-.2-.2-.5.4-1.8-.4-1.7-.1.3-.6.2-.9.2zm-3.4 1v1.5c.7.2.6-.4 1.3-.2-.2-.5.4-1.8-.4-1.7-.1.3-.8.2-.9.4zM15 57c.7-.5 1.3-1.7.2-2.3-.7.4-.8 1.6-.2 2.3zm26.1-1.3c-.1.7.4.8.2 1.5.9 0 1.2-.6 1.1-1.7-.4-.5-.8.1-1.3.2zm-3 2.7c1 0 1.2-.8 1.1-1.9h-.9c-.3.4-.1 1.3-.2 1.9zm-3.6-.4v1.7c.6-.1 1.3-.2 1.5-.8-.6 0 .3-1.6-.6-1.3 0 .4-.7.1-.9.4zM16 60.8c-.4-.7-.2-2-1.3-1.9.2.7.2 2.7 1.3 1.9zm13.8-.9c.5 0 .1.9.2 1.3.8.1 1.2-.2 1.7-.4v-1.7c-.9-.1-1.6.1-1.9.8zm-4.7.6c0 .8-.1 1.7.4 1.9 0-.5.8-.1 1.1-.2.3-.3-.2-1.1 0-1.9-.7-.2-1 .1-1.5.2zM19 62.3v-1.7c-.5 0-.6-.4-1.3-.2-.1 1.1 0 2.1 1.3 1.9zm2.5.2h1.3c.2-.9-.3-1.1-.2-1.9h-1.3c-.1.9.2 1.2.2 1.9z' fill='url(%23SVGID_3_)'/%3E%3ClinearGradient id='SVGID_4_' gradientUnits='userSpaceOnUse' x1='45.269' y1='74.206' x2='58.769' y2='87.706' gradientTransform='matrix(1 0 0 -1 0 102)'%3E%3Cstop offset='0' stop-color='%23f9eff6'/%3E%3Cstop offset='.378' stop-color='%23f8edf5'/%3E%3Cstop offset='.515' stop-color='%23f3e6f1'/%3E%3Cstop offset='.612' stop-color='%23ecdbeb'/%3E%3Cstop offset='.69' stop-color='%23e3cce2'/%3E%3Cstop offset='.757' stop-color='%23d7b8d7'/%3E%3Cstop offset='.817' stop-color='%23caa1c9'/%3E%3Cstop offset='.871' stop-color='%23bc88bb'/%3E%3Cstop offset='.921' stop-color='%23ae6cab'/%3E%3Cstop offset='.965' stop-color='%239f4d9b'/%3E%3Cstop offset='1' stop-color='%23932a8e'/%3E%3C/linearGradient%3E%3Cpath d='M45.2 1l27 26.7h-27V1z' fill='url(%23SVGID_4_)'/%3E%3Cpath d='M45.2 1l27 26.7h-27V1z' fill-opacity='0' stroke='%23882383' stroke-width='2' stroke-linejoin='bevel'/%3E%3C/svg%3E"); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-xls { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmxJREFUeNpsU0trFEEQ/mamZ3Y2+0zIC2MmITEkUYgERFQErx5E8KTi1b/h79A/4SW3nCNeYggBYZVEMU/y3N3Z7M7OTD/G6lk2ruw20zRdU/XV91VVG0mSQK/3n1a/jky6d6Xs3G8WXS+Pw5N6LXjLLGuna/78oZKerGsYKtrDE16uJGL1L9gEOOcYd2dL1fNwrbL//aXN7J1efPMmkUqEFAk0A0VZNbFEaQCBscIkXj975y3NLq9xye8PBkAniHOFph+j2eC4rsdoB4LsFubGl/Hq8RtvYWpxTQi52o1jvWiGYaRZL0/auDgOkC/Z8BYL2Pqxidp1FZkhoDxpeaXA/Ujuj/4HoOxKKjiOiek7RUShRNQWaNYFQuMafrYCxiw4ozZKfqbYJ0EvRdl1DQyyTs8XCNTA6UELMwvDyLpZWIZNNlNLlQOK2LMJRJ+5AkuZ1S7CFFzJzk56GnUjQWlYkqCoBWFbonEVYcLLA4dNnB624GQsDBWIgfZJEgxkoChzSFWvn4VpQemDm2VwXQsXJwF1h6c+gxlQ5jgSiEUEt0wdIe7tMES+nEG2aCLiJMOIIWIr9e0DEELAMUrwRuchVAyTKimUwO75Jm6VF3Bv7imOaj+xd7UFKVS/BPJF1b/E4tgTrE49J60O5kceoNqowiuuYKa8ghHXA48U9MT2AQgyRvTThE30bQiaSGa4yLMJNFo+Dq/2cHt4CYlwyFf2S6BHwwrMw/avDbR5C1k7h1YQ4KH3Amf+AcZyEbZPv9CItzQD1l9EbtYOjv74v/d3O9RMPTDrsEwGIWN8q2yk7XNYRs9JrRv3V4ABADSGR6eQ0/NQAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-xlsx { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmlJREFUeNpsU8tqFEEUPVXdPY/ueWZIoiYZiSYKYhJc6EbduHOhgijo3t/wH1z6B0JAhOyMILhxo4kJGk1ASTAxwWF0Mpp5dHc9vFUzYwidaoqmq+8959xzbzGtNcx69PTS26ETmQtS9r4Hy/xv7MW7jV+th5yzVcaYPX/++It9u4NAv+CVR6tBUUTqMJsDcRzjZOZM8W9ZLKx+/XDb4e5/kH5In0lpIYWGUaC0YTZnBCAEKoVR3L36oDo7NbsglZwbqD6iQKOXFMcKUVfBkBAoQhlD5xxMDp/HrSv3q1JgYW3z0x0KXzkCYJaRZljru23aHWTzLiamAyytv0O9UYdf5PArqlppBfMUfu4oALErqZBKcUxMFRCHEp0DgW5Lo4N9NIN1dF0XXsVFOUyPJTzo+WBANDidjp8tgHGG3c0DnJ4uIRf4cOCBaW5KjY8xkZL72xpJ9QcFz5bVqHUJGHZL2YtNmKi06YCyiVFb4s/vEKMTAf1p4edOG6mMi1zR6wEpdUwX+vLDtkCzHoK7ptcM6ayLmGajvtex4PliyoIkFRjmUEASelB2rXQRSfjUCT9PlWpmW21iTGzCAyEkUixPRqXhe2V4zKczbdmybgkpJ0cGOuA6Y2MTCsKoi5HsNK7N3MN+uwYaWbxYfoLLkzdxcew6lrYWaZhm8PHHG3zffp1UwJSHz9vvkU8PodbcQYYYS5lxYkxTkGdVDQdV1Js1qPgYD6JIuIE7gsXVefIhIuM05k7dwMbeMmh87a18ufIMaVYyprrJLgje2Nr+1tzYXANnDnr3zRhHj37Vvy2wpXHtNAd5/wQYAD6WMuT2CwoVAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-xml { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAilJREFUeNqMks1PE0EYxh+g3W2t1G0sEqyISynUFJsSOShNwCamiYZED3LgIkcuxoN/iCZePZiYGD2aGD+i0F5KMChxlVaakAK2ykcAt+WzdLu7zkxo3WZL4pu8mXfmeeY3885ug67roPFh5nvc62m9hjoR+5LMp7MrkYf370qVtco+VtCUFpbj+jGR+JbWn76OyQ8ePwsZATQb8R/hanZgINgj9IqeuBFCw1Kt9OMBnNWCs24XwkG/QKYUEiGjVAPQof/rq0783pShET3ULQo8xz0iS5FaANmrHQH2DoqY+DSLSz6RzecWlnD9ymU47LYjd4O5BXqDTG4FM3NpTEkpdJ5rw0AowLRMbhUfp58gTOaD/UHmNQPI6YmvKWRX1zESHUJ/oBs2nmPa+Mgw0ZIM3tZyGoJwygzQNB2jNyJIZX7iB0lpPoM70UGmPX8zCU+rG8NDVxHwdiC5mKsPUFUN/gvtLLf39sFzVqaN3YrC6TjBauqhXhNA1TQoqloV7Da+pjZq1FsXUCamF29j6LvYhf3iISamZ3Fv9DZevouhRzzPfOG+3hpA9U9UyioOlTJ7pFeTCQS6RGzIebyf+oz5pSzWtmSW1EO9phvQ00slBRt/8qR3DoWdXbiczUiTzd52D+tdLmyTB14mx1rMAKVcRpEATjrsuElee/HXGmnFRyBOGD30C/nEDjNgs7CDpsYmnHG3YPegBCvHs9oYfm8nG9dJa5X4K8AAQzQX4KSN3wcAAAAASUVORK5CYII=); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-yml { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAdxJREFUeNqMUl1rE0EUPbM7m5Y0Zptu21AwWwhYpfSDFh+kvvRd8N0Hf4I/xWdf/Q158F0QoQ+CVsFKaLSQpt/dpmvztTOzzky6cetOpWcZZvbO3MO5514SxzEU3r57/3GpWllM/tP4sL3TarROXuSo/SWJvX71Uu80Cfhlr/T4UdWFAVfdnmsTUtvdP35OUyQKVnJgXDBTcj9icAsTeLax7j/052qM81UjwW1QJXEhMF0qYnN90fdnvdogYmvJPU0/VBApD4hcDrWRcyikfB17srzgW7b9Rh1vEvxDlI4tVytaBSEEtmWh0xsUMwpwnWjqAlcxogiHd1wiQyCu87iI/+sJtf6+NXsgpd7FWCMB50KvkYMGMbLdZgLlfj+K9K4+FnFQ2x7WntIs50AbmiGwLILt+k+EvzvSNIHzdigdJ/AmXQRhiHv5POSwYmG+cqPVo0HqDxj8uTK2vn1Hfa+JmdIkvtZ/4fOPXU3WPDpFeNWVyUKryCiIGMN4zsH98gym3CIcOTwT+XHdXrdQQHAZotE8kBPpSqPNHtBOr48HUmLOcXRJT9dWNMGYJFby91pHOAvaykSaITg+bwefdhrteDRTMSwyrFCgI88E056Hy+4Ah2cXQZL3R4ABALUe7fqXWFN6AAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} + +.ipfs-zip { + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAm9JREFUeNpsk0tv00AUhc+MY6dOmgeFJg1FoVVpUWlFC0s2IFF1jxBbhKj4BSxYdscPYcEmQmIDq0gsERIViy4TpD7VFzF1Ho5je2a4thOqNhlp5Mz4zudzzp0wpRTC8fPrk0/TC6+fDtYicLH97T1Kc2vQDcs+rH3eUAxVznn0fn1DRM8E+iOdv5ct3XmZG6yVlNj6solUbgVTt0q5FGtX6vXqC6VklTE+KAO/OODHSIQPRQpsXC+kkEz2ELA0ystv84tLzyucsbWByisAGf+QAS2CCDRRLMJMmxC+i8C4jdLCm/zM7OOKFGptcO6/BTpJ0yeQB0Y+mfKQuZZG0jQgeRbW8Xdomobs9LN8scc+UPHNy4Dwq8IljotIIQEm59/RoSyM1CKkXKZNBm7kIVgyM6wgAnSgRK9vqQfHPiMFDHqyFVsLR9Cm0o4YzoAASrSjCelQfRPb1Vc4qn0EY5L2W9GEaBLcxQgFHpGbkMIDJ69e+wjJ8VXqRgKid0r7ftQdxkRs9SqA2kgAm14SSIQh9uhuLGPMnKJs/5KquL1x0N0RCsizigoDaLqBdHoMiyvrlBsHVx1wphD4BCewoqxGKKDwAgtOy8JufYuk+5golGGaGZwc1sIGoDz3AOPZSVLaHgVwydoJDM1H4DbQODughB3YpOD44HfoHgnu4e7So0uAi0stHLJ3Aud8B9bpHu6vPoSu9TtDl6tUuoFiIYOgu0+158MKmOxomtyD3Qi/3MTR7i8K0EDG1GHO5DE3X4DvNahZlJOwEkOATvdPc2//hx3mXJ5lFJaF8K8bStd0YGfnOJbMGex21x6c+yfAAOlIPDJzr7cLAAAAAElFTkSuQmCC); + background-repeat:no-repeat; + background-size:contain +} diff --git a/gateway/core/corehttp/gateway/assets/src/style.css b/gateway/core/corehttp/gateway/assets/src/style.css new file mode 100644 index 000000000..3e7b8a734 --- /dev/null +++ b/gateway/core/corehttp/gateway/assets/src/style.css @@ -0,0 +1,212 @@ +body { + color:#34373f; + font-family:"Helvetica Neue", Helvetica, Arial, sans-serif; + font-size:14px; + line-height:1.43; + margin:0; + word-break:break-all; + -webkit-text-size-adjust:100%; + -ms-text-size-adjust:100%; + -webkit-tap-highlight-color:transparent +} + +a { + color:#117eb3; + text-decoration:none +} + +a:hover { + color:#00b0e9; + text-decoration:underline +} + +a:active, +a:visited { + color:#00b0e9 +} + +strong { + font-weight:700 +} + +table { + border-collapse:collapse; + border-spacing:0; + max-width:100%; + width:100% +} + +table:last-child { + border-bottom-left-radius:3px; + border-bottom-right-radius:3px +} + +tr:first-child td { + border-top:0 +} + +tr:nth-of-type(even) { + background-color:#f7f8fa +} + +td { + border-top:1px solid #d9dbe2; + padding:.65em; + vertical-align:top +} + +#page-header { + align-items:center; + background:#0b3a53; + border-bottom:4px solid #69c4cd; + color:#fff; + display:flex; + font-size:1.12em; + font-weight:500; + justify-content:space-between; + padding:0 1em +} + +#page-header a { + color:#69c4cd +} + +#page-header a:active { + color:#9ad4db +} + +#page-header a:hover { + color:#fff +} + +#page-header-logo { + height:2.25em; + margin:.7em .7em .7em 0; + width:7.15em +} + +#page-header-menu { + align-items:center; + display:flex; + margin:.65em 0 +} + +#page-header-menu div { + margin:0 .6em +} + +#page-header-menu div:last-child { + margin:0 0 0 .6em +} + +#page-header-menu svg { + fill:#69c4cd; + height:1.8em; + margin-top:.125em +} + +#page-header-menu svg:hover { + fill:#fff +} + +.menu-item-narrow { + display:none +} + +#content { + border:1px solid #d9dbe2; + border-radius:4px; + margin:1em +} + +#content-header { + background-color:#edf0f4; + border-bottom:1px solid #d9dbe2; + border-top-left-radius:3px; + border-top-right-radius:3px; + padding:.7em 1em +} + +.type-icon, +.type-icon>* { + width:1.15em +} + +.no-linebreak { + white-space:nowrap +} + +.ipfs-hash { + color:#7f8491; + font-family:monospace +} + +@media only screen and (max-width:500px) { + .menu-item-narrow { + display:inline + } + .menu-item-wide { + display:none + } +} + +@media print { + #page-header { + display:none + } + #content-header, + .ipfs-hash, + body { + color:#000 + } + #content-header { + border-bottom:1px solid #000 + } + #content { + border:1px solid #000 + } + a, + a:visited { + color:#000; + text-decoration:underline + } + a[href]:after { + content:" (" attr(href) ")" + } + tr { + page-break-inside:avoid + } + tr:nth-of-type(even) { + background-color:transparent + } + td { + border-top:1px solid #000 + } +} + +@-ms-viewport { + width:device-width +} + +.d-flex { + display:flex +} + +.flex-wrap { + flex-flow:wrap +} + +.flex-shrink-1 { + flex-shrink:1 +} + +.ml-auto { + margin-left:auto +} + +.table-responsive { + display:block; + width:100%; + overflow-x:auto; + -webkit-overflow-scrolling:touch +} diff --git a/gateway/core/corehttp/gateway/assets/test/main.go b/gateway/core/corehttp/gateway/assets/test/main.go new file mode 100644 index 000000000..dc3c8c464 --- /dev/null +++ b/gateway/core/corehttp/gateway/assets/test/main.go @@ -0,0 +1,126 @@ +package main + +import ( + "fmt" + "html/template" + "net/http" + "net/url" + "os" + + "github.com/ipfs/kubo/core/corehttp/gateway/assets" +) + +const ( + directoryTemplateFile = "../directory-index.html" + dagTemplateFile = "../dag-index.html" + + testPath = "/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7/a/b/c" +) + +var directoryTestData = assets.DirectoryTemplateData{ + GatewayURL: "//localhost:3000", + DNSLink: true, + Listing: []assets.DirectoryItem{{ + Size: "25 MiB", + Name: "short-film.mov", + Path: testPath + "/short-film.mov", + Hash: "QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR", + ShortHash: "QmbW\u2026sMnR", + }, { + Size: "23 KiB", + Name: "250pxيوسف_الوزاني_صورة_ملتقطة_بواسطة_مرصد_هابل_الفضائي_توضح_سديم_السرطان،_وهو_بقايا_مستعر_أعظم._.jpg", + Path: testPath + "/250pxيوسف_الوزاني_صورة_ملتقطة_بواسطة_مرصد_هابل_الفضائي_توضح_سديم_السرطان،_وهو_بقايا_مستعر_أعظم._.jpg", + Hash: "QmUwrKrMTrNv8QjWGKMMH5QV9FMPUtRCoQ6zxTdgxATQW6", + ShortHash: "QmUw\u2026TQW6", + }, { + Size: "1 KiB", + Name: "this-piece-of-papers-got-47-words-37-sentences-58-words-we-wanna-know.txt", + Path: testPath + "/this-piece-of-papers-got-47-words-37-sentences-58-words-we-wanna-know.txt", + Hash: "bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi", + ShortHash: "bafy\u2026bzdi", + }}, + Size: "25 MiB", + Path: testPath, + Breadcrumbs: []assets.Breadcrumb{{ + Name: "ipfs", + }, { + Name: "QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7", + Path: testPath + "/../../..", + }, { + Name: "a", + Path: testPath + "/../..", + }, { + Name: "b", + Path: testPath + "/..", + }, { + Name: "c", + Path: testPath, + }}, + BackLink: testPath + "/..", + Hash: "QmFooBazBar2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7", +} + +var dagTestData = assets.DagTemplateData{ + Path: "/ipfs/baguqeerabn4wonmz6icnk7dfckuizcsf4e4igua2ohdboecku225xxmujepa", + CID: "baguqeerabn4wonmz6icnk7dfckuizcsf4e4igua2ohdboecku225xxmujepa", + CodecName: "dag-json", + CodecHex: "0x129", +} + +func main() { + mux := http.NewServeMux() + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/dag": + dagTemplate, err := template.New("dag-index.html").ParseFiles(dagTemplateFile) + if err != nil { + http.Error(w, fmt.Sprintf("failed to parse template file: %s", err), http.StatusInternalServerError) + return + } + err = dagTemplate.Execute(w, &dagTestData) + if err != nil { + http.Error(w, fmt.Sprintf("failed to execute template: %s", err), http.StatusInternalServerError) + return + } + case "/directory": + directoryTemplate, err := template.New("directory-index.html").Funcs(template.FuncMap{ + "iconFromExt": func(name string) string { + return "ipfs-_blank" // place-holder + }, + "urlEscape": func(rawUrl string) string { + pathURL := url.URL{Path: rawUrl} + return pathURL.String() + }, + }).ParseFiles(directoryTemplateFile) + if err != nil { + http.Error(w, fmt.Sprintf("failed to parse template file: %s", err), http.StatusInternalServerError) + return + } + err = directoryTemplate.Execute(w, &directoryTestData) + if err != nil { + http.Error(w, fmt.Sprintf("failed to execute template: %s", err), http.StatusInternalServerError) + return + } + case "/": + html := `

Test paths: DAG, Directory.` + _, _ = w.Write([]byte(html)) + default: + http.Redirect(w, r, "/", http.StatusSeeOther) + } + }) + + if _, err := os.Stat(directoryTemplateFile); err != nil { + wd, _ := os.Getwd() + fmt.Printf("could not open template file %q, relative to %q: %s\n", directoryTemplateFile, wd, err) + os.Exit(1) + } + + if _, err := os.Stat(dagTemplateFile); err != nil { + wd, _ := os.Getwd() + fmt.Printf("could not open template file %q, relative to %q: %s\n", dagTemplateFile, wd, err) + os.Exit(1) + } + + fmt.Printf("listening on localhost:3000\n") + _ = http.ListenAndServe("localhost:3000", mux) +} diff --git a/gateway/core/corehttp/gateway/gateway.go b/gateway/core/corehttp/gateway/gateway.go new file mode 100644 index 000000000..0882d4fb4 --- /dev/null +++ b/gateway/core/corehttp/gateway/gateway.go @@ -0,0 +1,107 @@ +package gateway + +import ( + "context" + "net/http" + "sort" + + coreiface "github.com/ipfs/interface-go-ipfs-core" + path "github.com/ipfs/interface-go-ipfs-core/path" +) + +// Config is the configuration that will be applied when creating a new gateway +// handler. +type Config struct { + Headers map[string][]string + Writable bool +} + +// NodeAPI defines the minimal set of API services required by a gateway handler +type NodeAPI interface { + // Unixfs returns an implementation of Unixfs API + Unixfs() coreiface.UnixfsAPI + + // Block returns an implementation of Block API + Block() coreiface.BlockAPI + + // Dag returns an implementation of Dag API + Dag() coreiface.APIDagService + + // Routing returns an implementation of Routing API. + // Used for returning signed IPNS records, see IPIP-0328 + Routing() coreiface.RoutingAPI + + // ResolvePath resolves the path using Unixfs resolver + ResolvePath(context.Context, path.Path) (path.Resolved, error) +} + +// A helper function to clean up a set of headers: +// 1. Canonicalizes. +// 2. Deduplicates. +// 3. Sorts. +func cleanHeaderSet(headers []string) []string { + // Deduplicate and canonicalize. + m := make(map[string]struct{}, len(headers)) + for _, h := range headers { + m[http.CanonicalHeaderKey(h)] = struct{}{} + } + result := make([]string, 0, len(m)) + for k := range m { + result = append(result, k) + } + + // Sort + sort.Strings(result) + return result +} + +// AddAccessControlHeaders adds default headers used for controlling +// cross-origin requests. This function adds several values to the +// Access-Control-Allow-Headers and Access-Control-Expose-Headers entries. +// If the Access-Control-Allow-Origin entry is missing a value of '*' is +// added, indicating that browsers should allow requesting code from any +// origin to access the resource. +// If the Access-Control-Allow-Methods entry is missing a value of 'GET' is +// added, indicating that browsers may use the GET method when issuing cross +// origin requests. +func AddAccessControlHeaders(headers map[string][]string) { + // Hard-coded headers. + const ACAHeadersName = "Access-Control-Allow-Headers" + const ACEHeadersName = "Access-Control-Expose-Headers" + const ACAOriginName = "Access-Control-Allow-Origin" + const ACAMethodsName = "Access-Control-Allow-Methods" + + if _, ok := headers[ACAOriginName]; !ok { + // Default to *all* + headers[ACAOriginName] = []string{"*"} + } + if _, ok := headers[ACAMethodsName]; !ok { + // Default to GET + headers[ACAMethodsName] = []string{http.MethodGet} + } + + headers[ACAHeadersName] = cleanHeaderSet( + append([]string{ + "Content-Type", + "User-Agent", + "Range", + "X-Requested-With", + }, headers[ACAHeadersName]...)) + + headers[ACEHeadersName] = cleanHeaderSet( + append([]string{ + "Content-Length", + "Content-Range", + "X-Chunked-Output", + "X-Stream-Output", + "X-Ipfs-Path", + "X-Ipfs-Roots", + }, headers[ACEHeadersName]...)) +} + +type RequestContextKey string + +const ( + DNSLinkHostnameKey RequestContextKey = "dnslink-hostname" + GatewayHostnameKey RequestContextKey = "gw-hostname" +) diff --git a/gateway/core/corehttp/gateway_handler.go b/gateway/core/corehttp/gateway/handler.go similarity index 93% rename from gateway/core/corehttp/gateway_handler.go rename to gateway/core/corehttp/gateway/handler.go index c3e8fa0d6..e6354069a 100644 --- a/gateway/core/corehttp/gateway_handler.go +++ b/gateway/core/corehttp/gateway/handler.go @@ -1,4 +1,4 @@ -package corehttp +package gateway import ( "context" @@ -19,6 +19,7 @@ import ( cid "github.com/ipfs/go-cid" ipld "github.com/ipfs/go-ipld-format" "github.com/ipfs/go-libipfs/files" + logging "github.com/ipfs/go-log" dag "github.com/ipfs/go-merkledag" mfs "github.com/ipfs/go-mfs" path "github.com/ipfs/go-path" @@ -28,11 +29,14 @@ import ( routing "github.com/libp2p/go-libp2p/core/routing" mc "github.com/multiformats/go-multicodec" prometheus "github.com/prometheus/client_golang/prometheus" + "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" "go.uber.org/zap" ) +var log = logging.Logger("core/server") + const ( ipfsPathPrefix = "/ipfs/" ipnsPathPrefix = "/ipns/" @@ -64,10 +68,10 @@ type redirectTemplateData struct { ErrorMsg string } -// gatewayHandler is a HTTP handler that serves IPFS objects (accessible by default at /ipfs/) +// handler is a HTTP handler that serves IPFS objects (accessible by default at /ipfs/) // (it serves requests like GET /ipfs/QmVRzPKPzNtSrEzBFm2UZfxmPAgnaLke4DMcerbsGGSaFe/link) -type gatewayHandler struct { - config GatewayConfig +type handler struct { + config Config api NodeAPI offlineAPI NodeAPI @@ -169,7 +173,7 @@ func (w *errRecordingResponseWriter) ReadFrom(r io.Reader) (n int64, err error) return n, err } -func newGatewaySummaryMetric(name string, help string) *prometheus.SummaryVec { +func newSummaryMetric(name string, help string) *prometheus.SummaryVec { summaryMetric := prometheus.NewSummaryVec( prometheus.SummaryOpts{ Namespace: "ipfs", @@ -189,7 +193,7 @@ func newGatewaySummaryMetric(name string, help string) *prometheus.SummaryVec { return summaryMetric } -func newGatewayHistogramMetric(name string, help string) *prometheus.HistogramVec { +func newHistogramMetric(name string, help string) *prometheus.HistogramVec { // We can add buckets as a parameter in the future, but for now using static defaults // suggested in https://github.com/ipfs/kubo/issues/8441 defaultBuckets := []float64{0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10, 30, 60} @@ -213,14 +217,14 @@ func newGatewayHistogramMetric(name string, help string) *prometheus.HistogramVe return histogramMetric } -// NewGatewayHandler returns an http.Handler that can act as a gateway to IPFS content +// NewHandler returns an http.Handler that can act as a gateway to IPFS content // offlineApi is a version of the API that should not make network requests for missing data -func NewGatewayHandler(c GatewayConfig, api NodeAPI, offlineAPI NodeAPI) http.Handler { - return newGatewayHandler(c, api, offlineAPI) +func NewHandler(c Config, api NodeAPI, offlineAPI NodeAPI) http.Handler { + return newHandler(c, api, offlineAPI) } -func newGatewayHandler(c GatewayConfig, api NodeAPI, offlineAPI NodeAPI) *gatewayHandler { - i := &gatewayHandler{ +func newHandler(c Config, api NodeAPI, offlineAPI NodeAPI) *handler { + i := &handler{ config: c, api: api, offlineAPI: offlineAPI, @@ -228,7 +232,7 @@ func newGatewayHandler(c GatewayConfig, api NodeAPI, offlineAPI NodeAPI) *gatewa // ---------------------------- // Time till the first content block (bar in /ipfs/cid/foo/bar) // (format-agnostic, across all response types) - firstContentBlockGetMetric: newGatewayHistogramMetric( + firstContentBlockGetMetric: newHistogramMetric( "gw_first_content_block_get_latency_seconds", "The time till the first content block is received on GET from the gateway.", ), @@ -236,29 +240,29 @@ func newGatewayHandler(c GatewayConfig, api NodeAPI, offlineAPI NodeAPI) *gatewa // Response-type specific metrics // ---------------------------- // UnixFS: time it takes to return a file - unixfsFileGetMetric: newGatewayHistogramMetric( + unixfsFileGetMetric: newHistogramMetric( "gw_unixfs_file_get_duration_seconds", "The time to serve an entire UnixFS file from the gateway.", ), // UnixFS: time it takes to generate static HTML with directory listing - unixfsGenDirGetMetric: newGatewayHistogramMetric( + unixfsGenDirGetMetric: newHistogramMetric( "gw_unixfs_gen_dir_listing_get_duration_seconds", "The time to serve a generated UnixFS HTML directory listing from the gateway.", ), // CAR: time it takes to return requested CAR stream - carStreamGetMetric: newGatewayHistogramMetric( + carStreamGetMetric: newHistogramMetric( "gw_car_stream_get_duration_seconds", "The time to GET an entire CAR stream from the gateway.", ), // Block: time it takes to return requested Block - rawBlockGetMetric: newGatewayHistogramMetric( + rawBlockGetMetric: newHistogramMetric( "gw_raw_block_get_duration_seconds", "The time to GET an entire raw Block from the gateway.", ), // Legacy Metrics // ---------------------------- - unixfsGetMetric: newGatewaySummaryMetric( // TODO: remove? + unixfsGetMetric: newSummaryMetric( // TODO: remove? // (deprecated, use firstContentBlockGetMetric instead) "unixfs_get_latency_seconds", "The time to receive the first UnixFS node on a GET from the gateway.", @@ -287,7 +291,7 @@ func parseIpfsPath(p string) (cid.Cid, string, error) { return rootCid, path.Join(rsegs[2:]), nil } -func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { +func (i *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // the hour is a hard fallback, we don't expect it to happen, but just in case ctx, cancel := context.WithTimeout(r.Context(), time.Hour) defer cancel() @@ -339,7 +343,7 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { http.Error(w, errmsg, status) } -func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request) { +func (i *handler) optionsHandler(w http.ResponseWriter, r *http.Request) { /* OPTIONS is a noop request that is used by the browsers to check if server accepts cross-site XMLHttpRequest (indicated by the presence of CORS headers) @@ -348,7 +352,7 @@ func (i *gatewayHandler) optionsHandler(w http.ResponseWriter, r *http.Request) i.addUserHeaders(w) // return all custom headers (including CORS ones, if set) } -func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) { +func (i *handler) getOrHeadHandler(w http.ResponseWriter, r *http.Request) { begin := time.Now() logger := log.With("from", r.RequestURI) @@ -455,7 +459,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request } } -func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { +func (i *handler) postHandler(w http.ResponseWriter, r *http.Request) { p, err := i.api.Unixfs().Add(r.Context(), files.NewReaderFile(r.Body)) if err != nil { internalWebError(w, err) @@ -468,7 +472,7 @@ func (i *gatewayHandler) postHandler(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, p.String(), http.StatusCreated) } -func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { +func (i *handler) putHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() ds := i.api.Dag() @@ -563,7 +567,7 @@ func (i *gatewayHandler) putHandler(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, redirectURL, http.StatusCreated) } -func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { +func (i *handler) deleteHandler(w http.ResponseWriter, r *http.Request) { ctx := r.Context() // parse the path @@ -639,7 +643,7 @@ func (i *gatewayHandler) deleteHandler(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, redirectURL, http.StatusCreated) } -func (i *gatewayHandler) addUserHeaders(w http.ResponseWriter) { +func (i *handler) addUserHeaders(w http.ResponseWriter) { for k, v := range i.config.Headers { w.Header()[k] = v } @@ -706,7 +710,7 @@ func setContentDispositionHeader(w http.ResponseWriter, filename string, disposi } // Set X-Ipfs-Roots with logical CID array for efficient HTTP cache invalidation. -func (i *gatewayHandler) buildIpfsRootsHeader(contentPath string, r *http.Request) (string, error) { +func (i *handler) buildIpfsRootsHeader(contentPath string, r *http.Request) (string, error) { /* These are logical roots where each CID represent one path segment and resolves to either a directory or the root block of a file. @@ -930,7 +934,7 @@ func debugStr(path string) string { // Resolve the provided contentPath including any special handling related to // the requested responseFormat. Returned ok flag indicates if gateway handler // should continue processing the request. -func (i *gatewayHandler) handlePathResolution(w http.ResponseWriter, r *http.Request, responseFormat string, contentPath ipath.Path, logger *zap.SugaredLogger) (resolvedPath ipath.Resolved, newContentPath ipath.Path, ok bool) { +func (i *handler) handlePathResolution(w http.ResponseWriter, r *http.Request, responseFormat string, contentPath ipath.Path, logger *zap.SugaredLogger) (resolvedPath ipath.Resolved, newContentPath ipath.Path, ok bool) { // Attempt to resolve the provided path. resolvedPath, err := i.api.ResolvePath(r.Context(), contentPath) @@ -972,7 +976,7 @@ func (i *gatewayHandler) handlePathResolution(w http.ResponseWriter, r *http.Req // Detect 'Cache-Control: only-if-cached' in request and return data if it is already in the local datastore. // https://github.com/ipfs/specs/blob/main/http-gateways/PATH_GATEWAY.md#cache-control-request-header -func (i *gatewayHandler) handleOnlyIfCached(w http.ResponseWriter, r *http.Request, contentPath ipath.Path, logger *zap.SugaredLogger) (requestHandled bool) { +func (i *handler) handleOnlyIfCached(w http.ResponseWriter, r *http.Request, contentPath ipath.Path, logger *zap.SugaredLogger) (requestHandled bool) { if r.Header.Get("Cache-Control") == "only-if-cached" { _, err := i.offlineAPI.Block().Stat(r.Context(), contentPath) if err != nil { @@ -1089,7 +1093,7 @@ func handleSuperfluousNamespace(w http.ResponseWriter, r *http.Request, contentP return true } -func (i *gatewayHandler) handleGettingFirstBlock(r *http.Request, begin time.Time, contentPath ipath.Path, resolvedPath ipath.Resolved) *requestError { +func (i *handler) handleGettingFirstBlock(r *http.Request, begin time.Time, contentPath ipath.Path, resolvedPath ipath.Resolved) *requestError { // Update the global metric of the time it takes to read the final root block of the requested resource // NOTE: for legacy reasons this happens before we go into content-type specific code paths _, err := i.api.Block().Get(r.Context(), resolvedPath) @@ -1103,7 +1107,7 @@ func (i *gatewayHandler) handleGettingFirstBlock(r *http.Request, begin time.Tim return nil } -func (i *gatewayHandler) setCommonHeaders(w http.ResponseWriter, r *http.Request, contentPath ipath.Path) *requestError { +func (i *handler) setCommonHeaders(w http.ResponseWriter, r *http.Request, contentPath ipath.Path) *requestError { i.addUserHeaders(w) // ok, _now_ write user's headers. w.Header().Set("X-Ipfs-Path", contentPath.String()) @@ -1115,3 +1119,8 @@ func (i *gatewayHandler) setCommonHeaders(w http.ResponseWriter, r *http.Request return nil } + +// spanTrace starts a new span using the standard IPFS tracing conventions. +func spanTrace(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span) { + return otel.Tracer("go-libipfs").Start(ctx, fmt.Sprintf("%s.%s", " Gateway", spanName), opts...) +} diff --git a/gateway/core/corehttp/gateway_handler_block.go b/gateway/core/corehttp/gateway/handler_block.go similarity index 80% rename from gateway/core/corehttp/gateway_handler_block.go rename to gateway/core/corehttp/gateway/handler_block.go index 3bf7c76be..23a22f447 100644 --- a/gateway/core/corehttp/gateway_handler_block.go +++ b/gateway/core/corehttp/gateway/handler_block.go @@ -1,4 +1,4 @@ -package corehttp +package gateway import ( "bytes" @@ -8,14 +8,13 @@ import ( "time" ipath "github.com/ipfs/interface-go-ipfs-core/path" - "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" ) // serveRawBlock returns bytes behind a raw block -func (i *gatewayHandler) serveRawBlock(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time) { - ctx, span := tracing.Span(ctx, "Gateway", "ServeRawBlock", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) +func (i *handler) serveRawBlock(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time) { + ctx, span := spanTrace(ctx, "ServeRawBlock", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) defer span.End() blockCid := resolvedPath.Cid() blockReader, err := i.api.Block().Get(ctx, resolvedPath) diff --git a/gateway/core/corehttp/gateway_handler_car.go b/gateway/core/corehttp/gateway/handler_car.go similarity index 89% rename from gateway/core/corehttp/gateway_handler_car.go rename to gateway/core/corehttp/gateway/handler_car.go index 9f704d6ca..f58bccfd7 100644 --- a/gateway/core/corehttp/gateway_handler_car.go +++ b/gateway/core/corehttp/gateway/handler_car.go @@ -1,4 +1,4 @@ -package corehttp +package gateway import ( "context" @@ -10,7 +10,6 @@ import ( blocks "github.com/ipfs/go-libipfs/blocks" coreiface "github.com/ipfs/interface-go-ipfs-core" ipath "github.com/ipfs/interface-go-ipfs-core/path" - "github.com/ipfs/kubo/tracing" gocar "github.com/ipld/go-car" selectorparse "github.com/ipld/go-ipld-prime/traversal/selector/parse" "go.opentelemetry.io/otel/attribute" @@ -18,8 +17,8 @@ import ( ) // serveCAR returns a CAR stream for specific DAG+selector -func (i *gatewayHandler) serveCAR(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, carVersion string, begin time.Time) { - ctx, span := tracing.Span(ctx, "Gateway", "ServeCAR", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) +func (i *handler) serveCAR(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, carVersion string, begin time.Time) { + ctx, span := spanTrace(ctx, "ServeCAR", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) defer span.End() ctx, cancel := context.WithCancel(ctx) defer cancel() diff --git a/gateway/core/corehttp/gateway_handler_codec.go b/gateway/core/corehttp/gateway/handler_codec.go similarity index 88% rename from gateway/core/corehttp/gateway_handler_codec.go rename to gateway/core/corehttp/gateway/handler_codec.go index 93e9593b7..ac219f165 100644 --- a/gateway/core/corehttp/gateway_handler_codec.go +++ b/gateway/core/corehttp/gateway/handler_codec.go @@ -1,4 +1,4 @@ -package corehttp +package gateway import ( "bytes" @@ -13,9 +13,7 @@ import ( cid "github.com/ipfs/go-cid" ipldlegacy "github.com/ipfs/go-ipld-legacy" ipath "github.com/ipfs/interface-go-ipfs-core/path" - "github.com/ipfs/kubo/assets" - dih "github.com/ipfs/kubo/assets/dag-index-html" - "github.com/ipfs/kubo/tracing" + "github.com/ipfs/kubo/core/corehttp/gateway/assets" "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/multicodec" mc "github.com/multiformats/go-multicodec" @@ -55,8 +53,8 @@ var contentTypeToExtension = map[string]string{ "application/vnd.ipld.dag-cbor": ".cbor", } -func (i *gatewayHandler) serveCodec(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, requestedContentType string) { - ctx, span := tracing.Span(ctx, "Gateway", "ServeCodec", trace.WithAttributes(attribute.String("path", resolvedPath.String()), attribute.String("requestedContentType", requestedContentType))) +func (i *handler) serveCodec(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, requestedContentType string) { + ctx, span := spanTrace(ctx, "ServeCodec", trace.WithAttributes(attribute.String("path", resolvedPath.String()), attribute.String("requestedContentType", requestedContentType))) defer span.End() cidCodec := mc.Code(resolvedPath.Cid().Prefix().Codec) @@ -134,7 +132,7 @@ func (i *gatewayHandler) serveCodec(ctx context.Context, w http.ResponseWriter, i.serveCodecConverted(ctx, w, r, resolvedPath, contentPath, toCodec, modtime) } -func (i *gatewayHandler) serveCodecHTML(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path) { +func (i *handler) serveCodecHTML(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path) { // A HTML directory index will be presented, be sure to set the correct // type instead of relying on autodetection (which may fail). w.Header().Set("Content-Type", "text/html") @@ -152,7 +150,7 @@ func (i *gatewayHandler) serveCodecHTML(ctx context.Context, w http.ResponseWrit w.Header().Del("Cache-Control") cidCodec := mc.Code(resolvedPath.Cid().Prefix().Codec) - if err := dih.DagIndexTemplate.Execute(w, dih.DagIndexTemplateData{ + if err := assets.DagTemplate.Execute(w, assets.DagTemplateData{ Path: contentPath.String(), CID: resolvedPath.Cid().String(), CodecName: cidCodec.String(), @@ -163,7 +161,7 @@ func (i *gatewayHandler) serveCodecHTML(ctx context.Context, w http.ResponseWrit } // serveCodecRaw returns the raw block without any conversion -func (i *gatewayHandler) serveCodecRaw(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, name string, modtime time.Time) { +func (i *handler) serveCodecRaw(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, name string, modtime time.Time) { blockCid := resolvedPath.Cid() blockReader, err := i.api.Block().Get(ctx, resolvedPath) if err != nil { @@ -183,7 +181,7 @@ func (i *gatewayHandler) serveCodecRaw(ctx context.Context, w http.ResponseWrite } // serveCodecConverted returns payload converted to codec specified in toCodec -func (i *gatewayHandler) serveCodecConverted(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, toCodec mc.Code, modtime time.Time) { +func (i *handler) serveCodecConverted(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, toCodec mc.Code, modtime time.Time) { obj, err := i.api.Dag().Get(ctx, resolvedPath.Cid()) if err != nil { webError(w, "ipfs dag get "+html.EscapeString(resolvedPath.String()), err, http.StatusInternalServerError) diff --git a/gateway/core/corehttp/gateway_handler_ipns_record.go b/gateway/core/corehttp/gateway/handler_ipns_record.go similarity index 89% rename from gateway/core/corehttp/gateway_handler_ipns_record.go rename to gateway/core/corehttp/gateway/handler_ipns_record.go index 16d9663fa..47786c5b7 100644 --- a/gateway/core/corehttp/gateway_handler_ipns_record.go +++ b/gateway/core/corehttp/gateway/handler_ipns_record.go @@ -1,4 +1,4 @@ -package corehttp +package gateway import ( "context" @@ -15,7 +15,7 @@ import ( "go.uber.org/zap" ) -func (i *gatewayHandler) serveIpnsRecord(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, logger *zap.SugaredLogger) { +func (i *handler) serveIpnsRecord(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, logger *zap.SugaredLogger) { if contentPath.Namespace() != "ipns" { err := fmt.Errorf("%s is not an IPNS link", contentPath.String()) webError(w, err.Error(), err, http.StatusBadRequest) diff --git a/gateway/core/corehttp/gateway_handler_tar.go b/gateway/core/corehttp/gateway/handler_tar.go similarity index 88% rename from gateway/core/corehttp/gateway_handler_tar.go rename to gateway/core/corehttp/gateway/handler_tar.go index 14edf4fbf..f5a7a6713 100644 --- a/gateway/core/corehttp/gateway_handler_tar.go +++ b/gateway/core/corehttp/gateway/handler_tar.go @@ -1,4 +1,4 @@ -package corehttp +package gateway import ( "context" @@ -8,7 +8,6 @@ import ( "github.com/ipfs/go-libipfs/files" ipath "github.com/ipfs/interface-go-ipfs-core/path" - "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" "go.uber.org/zap" @@ -16,8 +15,8 @@ import ( var unixEpochTime = time.Unix(0, 0) -func (i *gatewayHandler) serveTAR(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, logger *zap.SugaredLogger) { - ctx, span := tracing.Span(ctx, "Gateway", "ServeTAR", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) +func (i *handler) serveTAR(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, logger *zap.SugaredLogger) { + ctx, span := spanTrace(ctx, "ServeTAR", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) defer span.End() ctx, cancel := context.WithCancel(ctx) diff --git a/gateway/core/corehttp/gateway/handler_test.go b/gateway/core/corehttp/gateway/handler_test.go new file mode 100644 index 000000000..d08dc2953 --- /dev/null +++ b/gateway/core/corehttp/gateway/handler_test.go @@ -0,0 +1,28 @@ +package gateway + +import "testing" + +func TestEtagMatch(t *testing.T) { + for _, test := range []struct { + header string // value in If-None-Match HTTP header + cidEtag string + dirEtag string + expected bool // expected result of etagMatch(header, cidEtag, dirEtag) + }{ + {"", `"etag"`, "", false}, // no If-None-Match + {"", "", `"etag"`, false}, // no If-None-Match + {`"etag"`, `"etag"`, "", true}, // file etag match + {`W/"etag"`, `"etag"`, "", true}, // file etag match + {`"foo", W/"bar", W/"etag"`, `"etag"`, "", true}, // file etag match (array) + {`"foo",W/"bar",W/"etag"`, `"etag"`, "", true}, // file etag match (compact array) + {`"etag"`, "", `W/"etag"`, true}, // dir etag match + {`"etag"`, "", `W/"etag"`, true}, // dir etag match + {`W/"etag"`, "", `W/"etag"`, true}, // dir etag match + {`*`, `"etag"`, "", true}, // wildcard etag match + } { + result := etagMatch(test.header, test.cidEtag, test.dirEtag) + if result != test.expected { + t.Fatalf("unexpected result of etagMatch(%q, %q, %q), got %t, expected %t", test.header, test.cidEtag, test.dirEtag, result, test.expected) + } + } +} diff --git a/gateway/core/corehttp/gateway_handler_unixfs.go b/gateway/core/corehttp/gateway/handler_unixfs.go similarity index 71% rename from gateway/core/corehttp/gateway_handler_unixfs.go rename to gateway/core/corehttp/gateway/handler_unixfs.go index 045c0f81d..9962d468c 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs.go +++ b/gateway/core/corehttp/gateway/handler_unixfs.go @@ -1,4 +1,4 @@ -package corehttp +package gateway import ( "context" @@ -9,14 +9,13 @@ import ( "github.com/ipfs/go-libipfs/files" ipath "github.com/ipfs/interface-go-ipfs-core/path" - "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" "go.uber.org/zap" ) -func (i *gatewayHandler) serveUnixFS(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, logger *zap.SugaredLogger) { - ctx, span := tracing.Span(ctx, "Gateway", "ServeUnixFS", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) +func (i *handler) serveUnixFS(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, begin time.Time, logger *zap.SugaredLogger) { + ctx, span := spanTrace(ctx, "ServeUnixFS", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) defer span.End() // Handling UnixFS diff --git a/gateway/core/corehttp/gateway_handler_unixfs__redirects.go b/gateway/core/corehttp/gateway/handler_unixfs__redirects.go similarity index 87% rename from gateway/core/corehttp/gateway_handler_unixfs__redirects.go rename to gateway/core/corehttp/gateway/handler_unixfs__redirects.go index 6906683a6..98715cb2a 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs__redirects.go +++ b/gateway/core/corehttp/gateway/handler_unixfs__redirects.go @@ -1,4 +1,4 @@ -package corehttp +package gateway import ( "fmt" @@ -36,7 +36,7 @@ import ( // // Note that for security reasons, redirect rules are only processed when the request has origin isolation. // See https://github.com/ipfs/specs/pull/290 for more information. -func (i *gatewayHandler) serveRedirectsIfPresent(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, logger *zap.SugaredLogger) (newResolvedPath ipath.Resolved, newContentPath ipath.Path, continueProcessing bool, hadMatchingRule bool) { +func (i *handler) serveRedirectsIfPresent(w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, logger *zap.SugaredLogger) (newResolvedPath ipath.Resolved, newContentPath ipath.Path, continueProcessing bool, hadMatchingRule bool) { redirectsFile := i.getRedirectsFile(r, contentPath, logger) if redirectsFile != nil { redirectRules, err := i.getRedirectRules(r, redirectsFile) @@ -73,7 +73,7 @@ func (i *gatewayHandler) serveRedirectsIfPresent(w http.ResponseWriter, r *http. return resolvedPath, contentPath, true, false } -func (i *gatewayHandler) handleRedirectsFileRules(w http.ResponseWriter, r *http.Request, contentPath ipath.Path, redirectRules []redirects.Rule) (redirected bool, newContentPath string, err error) { +func (i *handler) handleRedirectsFileRules(w http.ResponseWriter, r *http.Request, contentPath ipath.Path, redirectRules []redirects.Rule) (redirected bool, newContentPath string, err error) { // Attempt to match a rule to the URL path, and perform the corresponding redirect or rewrite pathParts := strings.Split(contentPath.String(), "/") if len(pathParts) > 3 { @@ -118,7 +118,7 @@ func (i *gatewayHandler) handleRedirectsFileRules(w http.ResponseWriter, r *http return false, "", nil } -func (i *gatewayHandler) getRedirectRules(r *http.Request, redirectsFilePath ipath.Resolved) ([]redirects.Rule, error) { +func (i *handler) getRedirectRules(r *http.Request, redirectsFilePath ipath.Resolved) ([]redirects.Rule, error) { // Convert the path into a file node node, err := i.api.Unixfs().Get(r.Context(), redirectsFilePath) if err != nil { @@ -142,7 +142,7 @@ func (i *gatewayHandler) getRedirectRules(r *http.Request, redirectsFilePath ipa } // Returns a resolved path to the _redirects file located in the root CID path of the requested path -func (i *gatewayHandler) getRedirectsFile(r *http.Request, contentPath ipath.Path, logger *zap.SugaredLogger) ipath.Resolved { +func (i *handler) getRedirectsFile(r *http.Request, contentPath ipath.Path, logger *zap.SugaredLogger) ipath.Resolved { // contentPath is the full ipfs path to the requested resource, // regardless of whether path or subdomain resolution is used. rootPath := getRootPath(contentPath) @@ -164,7 +164,7 @@ func getRootPath(path ipath.Path) ipath.Path { return ipath.New(gopath.Join("/", path.Namespace(), parts[2])) } -func (i *gatewayHandler) serve4xx(w http.ResponseWriter, r *http.Request, content4xxPath ipath.Path, status int) error { +func (i *handler) serve4xx(w http.ResponseWriter, r *http.Request, content4xxPath ipath.Path, status int) error { resolved4xxPath, err := i.api.ResolvePath(r.Context(), content4xxPath) if err != nil { return err @@ -196,8 +196,8 @@ func (i *gatewayHandler) serve4xx(w http.ResponseWriter, r *http.Request, conten } func hasOriginIsolation(r *http.Request) bool { - _, gw := r.Context().Value(requestContextKey("gw-hostname")).(string) - _, dnslink := r.Context().Value("dnslink-hostname").(string) + _, gw := r.Context().Value(GatewayHostnameKey).(string) + _, dnslink := r.Context().Value(DNSLinkHostnameKey).(string) if gw || dnslink { return true @@ -214,7 +214,7 @@ func isUnixfsResponseFormat(responseFormat string) bool { // Deprecated: legacy ipfs-404.html files are superseded by _redirects file // This is provided only for backward-compatibility, until websites migrate // to 404s managed via _redirects file (https://github.com/ipfs/specs/pull/290) -func (i *gatewayHandler) serveLegacy404IfPresent(w http.ResponseWriter, r *http.Request, contentPath ipath.Path) bool { +func (i *handler) serveLegacy404IfPresent(w http.ResponseWriter, r *http.Request, contentPath ipath.Path) bool { resolved404Path, ctype, err := i.searchUpTreeFor404(r, contentPath) if err != nil { return false @@ -244,7 +244,7 @@ func (i *gatewayHandler) serveLegacy404IfPresent(w http.ResponseWriter, r *http. return err == nil } -func (i *gatewayHandler) searchUpTreeFor404(r *http.Request, contentPath ipath.Path) (ipath.Resolved, string, error) { +func (i *handler) searchUpTreeFor404(r *http.Request, contentPath ipath.Path) (ipath.Resolved, string, error) { filename404, ctype, err := preferred404Filename(r.Header.Values("Accept")) if err != nil { return nil, "", err diff --git a/gateway/core/corehttp/gateway_handler_unixfs_dir.go b/gateway/core/corehttp/gateway/handler_unixfs_dir.go similarity index 87% rename from gateway/core/corehttp/gateway_handler_unixfs_dir.go rename to gateway/core/corehttp/gateway/handler_unixfs_dir.go index 03d67e1c0..8a66d4ea9 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_dir.go +++ b/gateway/core/corehttp/gateway/handler_unixfs_dir.go @@ -1,4 +1,4 @@ -package corehttp +package gateway import ( "context" @@ -15,8 +15,7 @@ import ( "github.com/ipfs/go-path/resolver" options "github.com/ipfs/interface-go-ipfs-core/options" ipath "github.com/ipfs/interface-go-ipfs-core/path" - "github.com/ipfs/kubo/assets" - "github.com/ipfs/kubo/tracing" + "github.com/ipfs/kubo/core/corehttp/gateway/assets" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" "go.uber.org/zap" @@ -25,8 +24,8 @@ import ( // serveDirectory returns the best representation of UnixFS directory // // It will return index.html if present, or generate directory listing otherwise. -func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, dir files.Directory, begin time.Time, logger *zap.SugaredLogger) { - ctx, span := tracing.Span(ctx, "Gateway", "ServeDirectory", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) +func (i *handler) serveDirectory(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, dir files.Directory, begin time.Time, logger *zap.SugaredLogger) { + ctx, span := spanTrace(ctx, "ServeDirectory", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) defer span.End() // HostnameOption might have constructed an IPNS/IPFS path using the Host header. @@ -118,7 +117,7 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit return } - dirListing := make([]directoryItem, 0, len(results)) + dirListing := make([]assets.DirectoryItem, 0, len(results)) for link := range results { if link.Err != nil { internalWebError(w, err) @@ -126,12 +125,12 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit } hash := link.Cid.String() - di := directoryItem{ + di := assets.DirectoryItem{ Size: humanize.Bytes(uint64(link.Size)), Name: link.Name, Path: gopath.Join(originalURLPath, link.Name), Hash: hash, - ShortHash: shortHash(hash), + ShortHash: assets.ShortHash(hash), } dirListing = append(dirListing, di) } @@ -174,29 +173,29 @@ func (i *gatewayHandler) serveDirectory(ctx context.Context, w http.ResponseWrit var gwURL string // Get gateway hostname and build gateway URL. - if h, ok := r.Context().Value(requestContextKey("gw-hostname")).(string); ok { + if h, ok := r.Context().Value(GatewayHostnameKey).(string); ok { gwURL = "//" + h } else { gwURL = "" } - dnslink := hasDNSLinkOrigin(gwURL, contentPath.String()) + dnslink := assets.HasDNSLinkOrigin(gwURL, contentPath.String()) // See comment above where originalUrlPath is declared. - tplData := listingTemplateData{ + tplData := assets.DirectoryTemplateData{ GatewayURL: gwURL, DNSLink: dnslink, Listing: dirListing, Size: size, Path: contentPath.String(), - Breadcrumbs: breadcrumbs(contentPath.String(), dnslink), + Breadcrumbs: assets.Breadcrumbs(contentPath.String(), dnslink), BackLink: backLink, Hash: hash, } logger.Debugw("request processed", "tplDataDNSLink", dnslink, "tplDataSize", size, "tplDataBackLink", backLink, "tplDataHash", hash) - if err := listingTemplate.Execute(w, tplData); err != nil { + if err := assets.DirectoryTemplate.Execute(w, tplData); err != nil { internalWebError(w, err) return } diff --git a/gateway/core/corehttp/gateway_handler_unixfs_file.go b/gateway/core/corehttp/gateway/handler_unixfs_file.go similarity index 89% rename from gateway/core/corehttp/gateway_handler_unixfs_file.go rename to gateway/core/corehttp/gateway/handler_unixfs_file.go index 1abdc823e..a4f7d4cd9 100644 --- a/gateway/core/corehttp/gateway_handler_unixfs_file.go +++ b/gateway/core/corehttp/gateway/handler_unixfs_file.go @@ -1,4 +1,4 @@ -package corehttp +package gateway import ( "context" @@ -13,15 +13,14 @@ import ( "github.com/gabriel-vasile/mimetype" "github.com/ipfs/go-libipfs/files" ipath "github.com/ipfs/interface-go-ipfs-core/path" - "github.com/ipfs/kubo/tracing" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" ) // serveFile returns data behind a file along with HTTP headers based on // the file itself, its CID and the contentPath used for accessing it. -func (i *gatewayHandler) serveFile(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, file files.File, begin time.Time) { - _, span := tracing.Span(ctx, "Gateway", "ServeFile", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) +func (i *handler) serveFile(ctx context.Context, w http.ResponseWriter, r *http.Request, resolvedPath ipath.Resolved, contentPath ipath.Path, file files.File, begin time.Time) { + _, span := spanTrace(ctx, "ServeFile", trace.WithAttributes(attribute.String("path", resolvedPath.String()))) defer span.End() // Set Cache-Control and read optional Last-Modified time diff --git a/gateway/core/corehttp/lazyseek.go b/gateway/core/corehttp/gateway/lazyseek.go similarity index 98% rename from gateway/core/corehttp/lazyseek.go rename to gateway/core/corehttp/gateway/lazyseek.go index 2a379dc91..0f4920fad 100644 --- a/gateway/core/corehttp/lazyseek.go +++ b/gateway/core/corehttp/gateway/lazyseek.go @@ -1,4 +1,4 @@ -package corehttp +package gateway import ( "fmt" diff --git a/gateway/core/corehttp/lazyseek_test.go b/gateway/core/corehttp/gateway/lazyseek_test.go similarity index 99% rename from gateway/core/corehttp/lazyseek_test.go rename to gateway/core/corehttp/gateway/lazyseek_test.go index 49aca0a0e..09997a797 100644 --- a/gateway/core/corehttp/lazyseek_test.go +++ b/gateway/core/corehttp/gateway/lazyseek_test.go @@ -1,4 +1,4 @@ -package corehttp +package gateway import ( "fmt" diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go index 877ac9739..49fa519fb 100644 --- a/gateway/core/corehttp/gateway_test.go +++ b/gateway/core/corehttp/gateway_test.go @@ -651,28 +651,3 @@ func TestVersion(t *testing.T) { t.Fatalf("response doesn't contain protocol version:\n%s", s) } } - -func TestEtagMatch(t *testing.T) { - for _, test := range []struct { - header string // value in If-None-Match HTTP header - cidEtag string - dirEtag string - expected bool // expected result of etagMatch(header, cidEtag, dirEtag) - }{ - {"", `"etag"`, "", false}, // no If-None-Match - {"", "", `"etag"`, false}, // no If-None-Match - {`"etag"`, `"etag"`, "", true}, // file etag match - {`W/"etag"`, `"etag"`, "", true}, // file etag match - {`"foo", W/"bar", W/"etag"`, `"etag"`, "", true}, // file etag match (array) - {`"foo",W/"bar",W/"etag"`, `"etag"`, "", true}, // file etag match (compact array) - {`"etag"`, "", `W/"etag"`, true}, // dir etag match - {`"etag"`, "", `W/"etag"`, true}, // dir etag match - {`W/"etag"`, "", `W/"etag"`, true}, // dir etag match - {`*`, `"etag"`, "", true}, // wildcard etag match - } { - result := etagMatch(test.header, test.cidEtag, test.dirEtag) - if result != test.expected { - t.Fatalf("unexpected result of etagMatch(%q, %q, %q), got %t, expected %t", test.header, test.cidEtag, test.dirEtag, result, test.expected) - } - } -} diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go index 39e857aad..cb6d7fbc5 100644 --- a/gateway/core/corehttp/hostname.go +++ b/gateway/core/corehttp/hostname.go @@ -13,6 +13,7 @@ import ( namesys "github.com/ipfs/go-namesys" core "github.com/ipfs/kubo/core" coreapi "github.com/ipfs/kubo/core/coreapi" + "github.com/ipfs/kubo/core/corehttp/gateway" "github.com/libp2p/go-libp2p/core/peer" dns "github.com/miekg/dns" @@ -225,7 +226,7 @@ func HostnameOption() ServeOption { if !cfg.Gateway.NoDNSLink && isDNSLinkName(r.Context(), coreAPI, host) { // rewrite path and handle as DNSLink r.URL.Path = "/ipns/" + stripPort(host) + r.URL.Path - ctx := context.WithValue(r.Context(), requestContextKey("dnslink-hostname"), host) + ctx := context.WithValue(r.Context(), gateway.DNSLinkHostnameKey, host) childMux.ServeHTTP(w, withHostnameContext(r.WithContext(ctx), host)) return } @@ -247,8 +248,6 @@ type wildcardHost struct { spec *config.GatewaySpec } -type requestContextKey string - // Extends request context to include hostname of a canonical gateway root // (subdomain root or dnslink fqdn) func withHostnameContext(r *http.Request, hostname string) *http.Request { @@ -257,7 +256,7 @@ func withHostnameContext(r *http.Request, hostname string) *http.Request { // Host header, subdomain gateways have more comples rules (knownSubdomainDetails) // More: https://github.com/ipfs/dir-index-html/issues/42 // nolint: staticcheck // non-backward compatible change - ctx := context.WithValue(r.Context(), requestContextKey("gw-hostname"), hostname) + ctx := context.WithValue(r.Context(), gateway.GatewayHostnameKey, hostname) return r.WithContext(ctx) } From 29da615b8f1411693b2be60da7d531903fcc179b Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 27 Jan 2023 10:50:08 +0100 Subject: [PATCH 672/674] refactor: move gateway to go-libipfs --- .github/CODEOWNERS | 6 + gateway/{core/corehttp/gateway => }/README.md | 4 +- .../corehttp/gateway => }/assets/README.md | 0 .../corehttp/gateway => }/assets/assets.go | 0 .../corehttp/gateway => }/assets/build.sh | 0 .../gateway => }/assets/dag-index.html | 0 .../gateway => }/assets/directory-index.html | 0 .../gateway => }/assets/knownIcons.txt | 0 .../gateway => }/assets/src/dag-index.html | 0 .../assets/src/directory-index.html | 0 .../gateway => }/assets/src/icons.css | 0 .../gateway => }/assets/src/style.css | 0 gateway/assets/test/go.mod | 3 + .../corehttp/gateway => }/assets/test/main.go | 42 +- gateway/core/corehttp/commands.go | 193 --- gateway/core/corehttp/corehttp.go | 141 -- gateway/core/corehttp/gateway.go | 64 - gateway/core/corehttp/gateway_test.go | 653 -------- gateway/core/corehttp/hostname.go | 602 -------- gateway/core/corehttp/hostname_test.go | 307 ---- gateway/core/corehttp/logs.go | 58 - gateway/core/corehttp/metrics.go | 204 --- gateway/core/corehttp/metrics_test.go | 56 - gateway/core/corehttp/mutex_profile.go | 78 - gateway/core/corehttp/option_test.go | 77 - gateway/core/corehttp/p2p_proxy.go | 82 - gateway/core/corehttp/p2p_proxy_test.go | 56 - gateway/core/corehttp/redirect.go | 28 - gateway/core/corehttp/webui.go | 57 - .../{core/corehttp/gateway => }/gateway.go | 0 .../{core/corehttp/gateway => }/handler.go | 0 .../corehttp/gateway => }/handler_block.go | 0 .../corehttp/gateway => }/handler_car.go | 0 .../corehttp/gateway => }/handler_codec.go | 2 +- .../gateway => }/handler_ipns_record.go | 0 .../corehttp/gateway => }/handler_tar.go | 0 .../corehttp/gateway => }/handler_test.go | 0 .../corehttp/gateway => }/handler_unixfs.go | 0 .../gateway => }/handler_unixfs__redirects.go | 0 .../gateway => }/handler_unixfs_dir.go | 2 +- .../gateway => }/handler_unixfs_file.go | 0 .../{core/corehttp/gateway => }/lazyseek.go | 0 .../corehttp/gateway => }/lazyseek_test.go | 0 go.mod | 69 +- go.sum | 1314 ++++++++++++++++- 45 files changed, 1411 insertions(+), 2687 deletions(-) create mode 100644 .github/CODEOWNERS rename gateway/{core/corehttp/gateway => }/README.md (90%) rename gateway/{core/corehttp/gateway => }/assets/README.md (100%) rename gateway/{core/corehttp/gateway => }/assets/assets.go (100%) rename gateway/{core/corehttp/gateway => }/assets/build.sh (100%) rename gateway/{core/corehttp/gateway => }/assets/dag-index.html (100%) rename gateway/{core/corehttp/gateway => }/assets/directory-index.html (100%) rename gateway/{core/corehttp/gateway => }/assets/knownIcons.txt (100%) rename gateway/{core/corehttp/gateway => }/assets/src/dag-index.html (100%) rename gateway/{core/corehttp/gateway => }/assets/src/directory-index.html (100%) rename gateway/{core/corehttp/gateway => }/assets/src/icons.css (100%) rename gateway/{core/corehttp/gateway => }/assets/src/style.css (100%) create mode 100644 gateway/assets/test/go.mod rename gateway/{core/corehttp/gateway => }/assets/test/main.go (85%) delete mode 100644 gateway/core/corehttp/commands.go delete mode 100644 gateway/core/corehttp/corehttp.go delete mode 100644 gateway/core/corehttp/gateway.go delete mode 100644 gateway/core/corehttp/gateway_test.go delete mode 100644 gateway/core/corehttp/hostname.go delete mode 100644 gateway/core/corehttp/hostname_test.go delete mode 100644 gateway/core/corehttp/logs.go delete mode 100644 gateway/core/corehttp/metrics.go delete mode 100644 gateway/core/corehttp/metrics_test.go delete mode 100644 gateway/core/corehttp/mutex_profile.go delete mode 100644 gateway/core/corehttp/option_test.go delete mode 100644 gateway/core/corehttp/p2p_proxy.go delete mode 100644 gateway/core/corehttp/p2p_proxy_test.go delete mode 100644 gateway/core/corehttp/redirect.go delete mode 100644 gateway/core/corehttp/webui.go rename gateway/{core/corehttp/gateway => }/gateway.go (100%) rename gateway/{core/corehttp/gateway => }/handler.go (100%) rename gateway/{core/corehttp/gateway => }/handler_block.go (100%) rename gateway/{core/corehttp/gateway => }/handler_car.go (100%) rename gateway/{core/corehttp/gateway => }/handler_codec.go (99%) rename gateway/{core/corehttp/gateway => }/handler_ipns_record.go (100%) rename gateway/{core/corehttp/gateway => }/handler_tar.go (100%) rename gateway/{core/corehttp/gateway => }/handler_test.go (100%) rename gateway/{core/corehttp/gateway => }/handler_unixfs.go (100%) rename gateway/{core/corehttp/gateway => }/handler_unixfs__redirects.go (100%) rename gateway/{core/corehttp/gateway => }/handler_unixfs_dir.go (99%) rename gateway/{core/corehttp/gateway => }/handler_unixfs_file.go (100%) rename gateway/{core/corehttp/gateway => }/lazyseek.go (100%) rename gateway/{core/corehttp/gateway => }/lazyseek_test.go (100%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..a13f9a535 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,6 @@ +# Code owners are automatically requested for review when someone opens a pull +# request that modifies code that they own. Code owners are not automatically +# requested to review draft pull requests. + +# HTTP Gateway +gateway/ @lidel @hacdias diff --git a/gateway/core/corehttp/gateway/README.md b/gateway/README.md similarity index 90% rename from gateway/core/corehttp/gateway/README.md rename to gateway/README.md index 102121d92..98463086b 100644 --- a/gateway/core/corehttp/gateway/README.md +++ b/gateway/README.md @@ -4,7 +4,7 @@ ## Documentation -* Go Documentation: https://pkg.go.dev/github.com/ipfs/kubo/core/corehttp/gateway +* Go Documentation: https://pkg.go.dev/github.com/ipfs/go-libipfs/gateway ## Example @@ -32,4 +32,4 @@ mux.Handle("/ipns/", gwHandler) // Start the server on :8080 and voilá! You have an IPFS gateway running // in http://localhost:8080. _ = http.ListenAndServe(":8080", mux) -``` \ No newline at end of file +``` diff --git a/gateway/core/corehttp/gateway/assets/README.md b/gateway/assets/README.md similarity index 100% rename from gateway/core/corehttp/gateway/assets/README.md rename to gateway/assets/README.md diff --git a/gateway/core/corehttp/gateway/assets/assets.go b/gateway/assets/assets.go similarity index 100% rename from gateway/core/corehttp/gateway/assets/assets.go rename to gateway/assets/assets.go diff --git a/gateway/core/corehttp/gateway/assets/build.sh b/gateway/assets/build.sh similarity index 100% rename from gateway/core/corehttp/gateway/assets/build.sh rename to gateway/assets/build.sh diff --git a/gateway/core/corehttp/gateway/assets/dag-index.html b/gateway/assets/dag-index.html similarity index 100% rename from gateway/core/corehttp/gateway/assets/dag-index.html rename to gateway/assets/dag-index.html diff --git a/gateway/core/corehttp/gateway/assets/directory-index.html b/gateway/assets/directory-index.html similarity index 100% rename from gateway/core/corehttp/gateway/assets/directory-index.html rename to gateway/assets/directory-index.html diff --git a/gateway/core/corehttp/gateway/assets/knownIcons.txt b/gateway/assets/knownIcons.txt similarity index 100% rename from gateway/core/corehttp/gateway/assets/knownIcons.txt rename to gateway/assets/knownIcons.txt diff --git a/gateway/core/corehttp/gateway/assets/src/dag-index.html b/gateway/assets/src/dag-index.html similarity index 100% rename from gateway/core/corehttp/gateway/assets/src/dag-index.html rename to gateway/assets/src/dag-index.html diff --git a/gateway/core/corehttp/gateway/assets/src/directory-index.html b/gateway/assets/src/directory-index.html similarity index 100% rename from gateway/core/corehttp/gateway/assets/src/directory-index.html rename to gateway/assets/src/directory-index.html diff --git a/gateway/core/corehttp/gateway/assets/src/icons.css b/gateway/assets/src/icons.css similarity index 100% rename from gateway/core/corehttp/gateway/assets/src/icons.css rename to gateway/assets/src/icons.css diff --git a/gateway/core/corehttp/gateway/assets/src/style.css b/gateway/assets/src/style.css similarity index 100% rename from gateway/core/corehttp/gateway/assets/src/style.css rename to gateway/assets/src/style.css diff --git a/gateway/assets/test/go.mod b/gateway/assets/test/go.mod new file mode 100644 index 000000000..8980d9a71 --- /dev/null +++ b/gateway/assets/test/go.mod @@ -0,0 +1,3 @@ +module gateway-test + +go 1.19 diff --git a/gateway/core/corehttp/gateway/assets/test/main.go b/gateway/assets/test/main.go similarity index 85% rename from gateway/core/corehttp/gateway/assets/test/main.go rename to gateway/assets/test/main.go index dc3c8c464..96d940496 100644 --- a/gateway/core/corehttp/gateway/assets/test/main.go +++ b/gateway/assets/test/main.go @@ -6,8 +6,6 @@ import ( "net/http" "net/url" "os" - - "github.com/ipfs/kubo/core/corehttp/gateway/assets" ) const ( @@ -17,10 +15,10 @@ const ( testPath = "/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7/a/b/c" ) -var directoryTestData = assets.DirectoryTemplateData{ +var directoryTestData = DirectoryTemplateData{ GatewayURL: "//localhost:3000", DNSLink: true, - Listing: []assets.DirectoryItem{{ + Listing: []DirectoryItem{{ Size: "25 MiB", Name: "short-film.mov", Path: testPath + "/short-film.mov", @@ -41,7 +39,7 @@ var directoryTestData = assets.DirectoryTemplateData{ }}, Size: "25 MiB", Path: testPath, - Breadcrumbs: []assets.Breadcrumb{{ + Breadcrumbs: []Breadcrumb{{ Name: "ipfs", }, { Name: "QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7", @@ -60,7 +58,7 @@ var directoryTestData = assets.DirectoryTemplateData{ Hash: "QmFooBazBar2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7", } -var dagTestData = assets.DagTemplateData{ +var dagTestData = DagTemplateData{ Path: "/ipfs/baguqeerabn4wonmz6icnk7dfckuizcsf4e4igua2ohdboecku225xxmujepa", CID: "baguqeerabn4wonmz6icnk7dfckuizcsf4e4igua2ohdboecku225xxmujepa", CodecName: "dag-json", @@ -124,3 +122,35 @@ func main() { fmt.Printf("listening on localhost:3000\n") _ = http.ListenAndServe("localhost:3000", mux) } + +// Copied from ../assets.go +type DagTemplateData struct { + Path string + CID string + CodecName string + CodecHex string +} + +type DirectoryTemplateData struct { + GatewayURL string + DNSLink bool + Listing []DirectoryItem + Size string + Path string + Breadcrumbs []Breadcrumb + BackLink string + Hash string +} + +type DirectoryItem struct { + Size string + Name string + Path string + Hash string + ShortHash string +} + +type Breadcrumb struct { + Name string + Path string +} diff --git a/gateway/core/corehttp/commands.go b/gateway/core/corehttp/commands.go deleted file mode 100644 index c0ebf5506..000000000 --- a/gateway/core/corehttp/commands.go +++ /dev/null @@ -1,193 +0,0 @@ -package corehttp - -import ( - "errors" - "fmt" - "net" - "net/http" - "os" - "strconv" - "strings" - - version "github.com/ipfs/kubo" - oldcmds "github.com/ipfs/kubo/commands" - "github.com/ipfs/kubo/core" - corecommands "github.com/ipfs/kubo/core/commands" - - cmds "github.com/ipfs/go-ipfs-cmds" - cmdsHttp "github.com/ipfs/go-ipfs-cmds/http" - path "github.com/ipfs/go-path" - config "github.com/ipfs/kubo/config" -) - -var ( - errAPIVersionMismatch = errors.New("api version mismatch") -) - -const originEnvKey = "API_ORIGIN" -const originEnvKeyDeprecate = `You are using the ` + originEnvKey + `ENV Variable. -This functionality is deprecated, and will be removed in future versions. -Instead, try either adding headers to the config, or passing them via -cli arguments: - - ipfs config API.HTTPHeaders --json '{"Access-Control-Allow-Origin": ["*"]}' - ipfs daemon -` - -// APIPath is the path at which the API is mounted. -const APIPath = "/api/v0" - -var defaultLocalhostOrigins = []string{ - "http://127.0.0.1:", - "https://127.0.0.1:", - "http://[::1]:", - "https://[::1]:", - "http://localhost:", - "https://localhost:", -} - -var companionBrowserExtensionOrigins = []string{ - "chrome-extension://nibjojkomfdiaoajekhjakgkdhaomnch", // ipfs-companion - "chrome-extension://hjoieblefckbooibpepigmacodalfndh", // ipfs-companion-beta -} - -func addCORSFromEnv(c *cmdsHttp.ServerConfig) { - origin := os.Getenv(originEnvKey) - if origin != "" { - log.Warn(originEnvKeyDeprecate) - c.AppendAllowedOrigins(origin) - } -} - -func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) { - log.Info("Using API.HTTPHeaders:", nc.API.HTTPHeaders) - - if acao := nc.API.HTTPHeaders[cmdsHttp.ACAOrigin]; acao != nil { - c.SetAllowedOrigins(acao...) - } - if acam := nc.API.HTTPHeaders[cmdsHttp.ACAMethods]; acam != nil { - c.SetAllowedMethods(acam...) - } - for _, v := range nc.API.HTTPHeaders[cmdsHttp.ACACredentials] { - c.SetAllowCredentials(strings.ToLower(v) == "true") - } - - c.Headers = make(map[string][]string, len(nc.API.HTTPHeaders)+1) - - // Copy these because the config is shared and this function is called - // in multiple places concurrently. Updating these in-place *is* racy. - for h, v := range nc.API.HTTPHeaders { - h = http.CanonicalHeaderKey(h) - switch h { - case cmdsHttp.ACAOrigin, cmdsHttp.ACAMethods, cmdsHttp.ACACredentials: - // these are handled by the CORs library. - default: - c.Headers[h] = v - } - } - c.Headers["Server"] = []string{"kubo/" + version.CurrentVersionNumber} -} - -func addCORSDefaults(c *cmdsHttp.ServerConfig) { - // always safelist certain origins - c.AppendAllowedOrigins(defaultLocalhostOrigins...) - c.AppendAllowedOrigins(companionBrowserExtensionOrigins...) - - // by default, use GET, PUT, POST - if len(c.AllowedMethods()) == 0 { - c.SetAllowedMethods(http.MethodGet, http.MethodPost, http.MethodPut) - } -} - -func patchCORSVars(c *cmdsHttp.ServerConfig, addr net.Addr) { - - // we have to grab the port from an addr, which may be an ip6 addr. - // TODO: this should take multiaddrs and derive port from there. - port := "" - if tcpaddr, ok := addr.(*net.TCPAddr); ok { - port = strconv.Itoa(tcpaddr.Port) - } else if udpaddr, ok := addr.(*net.UDPAddr); ok { - port = strconv.Itoa(udpaddr.Port) - } - - // we're listening on tcp/udp with ports. ("udp!?" you say? yeah... it happens...) - oldOrigins := c.AllowedOrigins() - newOrigins := make([]string, len(oldOrigins)) - for i, o := range oldOrigins { - // TODO: allow replacing . tricky, ip4 and ip6 and hostnames... - if port != "" { - o = strings.Replace(o, "", port, -1) - } - newOrigins[i] = o - } - c.SetAllowedOrigins(newOrigins...) -} - -func commandsOption(cctx oldcmds.Context, command *cmds.Command, allowGet bool) ServeOption { - return func(n *core.IpfsNode, l net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - - cfg := cmdsHttp.NewServerConfig() - cfg.AllowGet = allowGet - corsAllowedMethods := []string{http.MethodPost} - if allowGet { - corsAllowedMethods = append(corsAllowedMethods, http.MethodGet) - } - - cfg.SetAllowedMethods(corsAllowedMethods...) - cfg.APIPath = APIPath - rcfg, err := n.Repo.Config() - if err != nil { - return nil, err - } - - addHeadersFromConfig(cfg, rcfg) - addCORSFromEnv(cfg) - addCORSDefaults(cfg) - patchCORSVars(cfg, l.Addr()) - - cmdHandler := cmdsHttp.NewHandler(&cctx, command, cfg) - mux.Handle(APIPath+"/", cmdHandler) - return mux, nil - } -} - -// CommandsOption constructs a ServerOption for hooking the commands into the -// HTTP server. It will NOT allow GET requests. -func CommandsOption(cctx oldcmds.Context) ServeOption { - return commandsOption(cctx, corecommands.Root, false) -} - -// CommandsROOption constructs a ServerOption for hooking the read-only commands -// into the HTTP server. It will allow GET requests. -func CommandsROOption(cctx oldcmds.Context) ServeOption { - return commandsOption(cctx, corecommands.RootRO, true) -} - -// CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/kubo/` or `/go-ipfs/` -func CheckVersionOption() ServeOption { - daemonVersion := version.ApiVersion - - return ServeOption(func(n *core.IpfsNode, l net.Listener, parent *http.ServeMux) (*http.ServeMux, error) { - mux := http.NewServeMux() - parent.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - if strings.HasPrefix(r.URL.Path, APIPath) { - cmdqry := r.URL.Path[len(APIPath):] - pth := path.SplitList(cmdqry) - - // backwards compatibility to previous version check - if len(pth) >= 2 && pth[1] != "version" { - clientVersion := r.UserAgent() - // skips check if client is not kubo (go-ipfs) - if (strings.Contains(clientVersion, "/go-ipfs/") || strings.Contains(clientVersion, "/kubo/")) && daemonVersion != clientVersion { - http.Error(w, fmt.Sprintf("%s (%s != %s)", errAPIVersionMismatch, daemonVersion, clientVersion), http.StatusBadRequest) - return - } - } - } - - mux.ServeHTTP(w, r) - }) - - return mux, nil - }) -} diff --git a/gateway/core/corehttp/corehttp.go b/gateway/core/corehttp/corehttp.go deleted file mode 100644 index fe9f1b1db..000000000 --- a/gateway/core/corehttp/corehttp.go +++ /dev/null @@ -1,141 +0,0 @@ -/* -Package corehttp provides utilities for the webui, gateways, and other -high-level HTTP interfaces to IPFS. -*/ -package corehttp - -import ( - "context" - "fmt" - "net" - "net/http" - "time" - - logging "github.com/ipfs/go-log" - core "github.com/ipfs/kubo/core" - "github.com/jbenet/goprocess" - periodicproc "github.com/jbenet/goprocess/periodic" - ma "github.com/multiformats/go-multiaddr" - manet "github.com/multiformats/go-multiaddr/net" -) - -var log = logging.Logger("core/server") - -// shutdownTimeout is the timeout after which we'll stop waiting for hung -// commands to return on shutdown. -const shutdownTimeout = 30 * time.Second - -// ServeOption registers any HTTP handlers it provides on the given mux. -// It returns the mux to expose to future options, which may be a new mux if it -// is interested in mediating requests to future options, or the same mux -// initially passed in if not. -type ServeOption func(*core.IpfsNode, net.Listener, *http.ServeMux) (*http.ServeMux, error) - -// makeHandler turns a list of ServeOptions into a http.Handler that implements -// all of the given options, in order. -func makeHandler(n *core.IpfsNode, l net.Listener, options ...ServeOption) (http.Handler, error) { - topMux := http.NewServeMux() - mux := topMux - for _, option := range options { - var err error - mux, err = option(n, l, mux) - if err != nil { - return nil, err - } - } - handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - // ServeMux does not support requests with CONNECT method, - // so we need to handle them separately - // https://golang.org/src/net/http/request.go#L111 - if r.Method == http.MethodConnect { - w.WriteHeader(http.StatusOK) - return - } - topMux.ServeHTTP(w, r) - }) - return handler, nil -} - -// ListenAndServe runs an HTTP server listening at |listeningMultiAddr| with -// the given serve options. The address must be provided in multiaddr format. -// -// TODO intelligently parse address strings in other formats so long as they -// unambiguously map to a valid multiaddr. e.g. for convenience, ":8080" should -// map to "/ip4/0.0.0.0/tcp/8080". -func ListenAndServe(n *core.IpfsNode, listeningMultiAddr string, options ...ServeOption) error { - addr, err := ma.NewMultiaddr(listeningMultiAddr) - if err != nil { - return err - } - - list, err := manet.Listen(addr) - if err != nil { - return err - } - - // we might have listened to /tcp/0 - let's see what we are listing on - addr = list.Multiaddr() - fmt.Printf("API server listening on %s\n", addr) - - return Serve(n, manet.NetListener(list), options...) -} - -// Serve accepts incoming HTTP connections on the listener and pass them -// to ServeOption handlers. -func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error { - // make sure we close this no matter what. - defer lis.Close() - - handler, err := makeHandler(node, lis, options...) - if err != nil { - return err - } - - addr, err := manet.FromNetAddr(lis.Addr()) - if err != nil { - return err - } - - select { - case <-node.Process.Closing(): - return fmt.Errorf("failed to start server, process closing") - default: - } - - server := &http.Server{ - Handler: handler, - } - - var serverError error - serverProc := node.Process.Go(func(p goprocess.Process) { - serverError = server.Serve(lis) - }) - - // wait for server to exit. - select { - case <-serverProc.Closed(): - // if node being closed before server exits, close server - case <-node.Process.Closing(): - log.Infof("server at %s terminating...", addr) - - warnProc := periodicproc.Tick(5*time.Second, func(_ goprocess.Process) { - log.Infof("waiting for server at %s to terminate...", addr) - }) - - // This timeout shouldn't be necessary if all of our commands - // are obeying their contexts but we should have *some* timeout. - ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout) - defer cancel() - err := server.Shutdown(ctx) - - // Should have already closed but we still need to wait for it - // to set the error. - <-serverProc.Closed() - serverError = err - - warnProc.Close() - } - - log.Infof("server at %s terminated", addr) - return serverError -} diff --git a/gateway/core/corehttp/gateway.go b/gateway/core/corehttp/gateway.go deleted file mode 100644 index 7d7674ef0..000000000 --- a/gateway/core/corehttp/gateway.go +++ /dev/null @@ -1,64 +0,0 @@ -package corehttp - -import ( - "fmt" - "net" - "net/http" - - options "github.com/ipfs/interface-go-ipfs-core/options" - version "github.com/ipfs/kubo" - core "github.com/ipfs/kubo/core" - coreapi "github.com/ipfs/kubo/core/coreapi" - "github.com/ipfs/kubo/core/corehttp/gateway" - id "github.com/libp2p/go-libp2p/p2p/protocol/identify" - "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" -) - -func GatewayOption(writable bool, paths ...string) ServeOption { - return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - cfg, err := n.Repo.Config() - if err != nil { - return nil, err - } - - api, err := coreapi.NewCoreAPI(n, options.Api.FetchBlocks(!cfg.Gateway.NoFetch)) - if err != nil { - return nil, err - } - - headers := make(map[string][]string, len(cfg.Gateway.HTTPHeaders)) - for h, v := range cfg.Gateway.HTTPHeaders { - headers[http.CanonicalHeaderKey(h)] = v - } - - gateway.AddAccessControlHeaders(headers) - - offlineAPI, err := api.WithOptions(options.Api.Offline(true)) - if err != nil { - return nil, err - } - - gateway := gateway.NewHandler(gateway.Config{ - Headers: headers, - Writable: writable, - }, api, offlineAPI) - - gateway = otelhttp.NewHandler(gateway, "Gateway.Request") - - for _, p := range paths { - mux.Handle(p+"/", gateway) - } - return mux, nil - } -} - -func VersionOption() ServeOption { - return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, "Commit: %s\n", version.CurrentCommit) - fmt.Fprintf(w, "Client Version: %s\n", version.GetUserAgentVersion()) - fmt.Fprintf(w, "Protocol Version: %s\n", id.DefaultProtocolVersion) - }) - return mux, nil - } -} diff --git a/gateway/core/corehttp/gateway_test.go b/gateway/core/corehttp/gateway_test.go deleted file mode 100644 index 49fa519fb..000000000 --- a/gateway/core/corehttp/gateway_test.go +++ /dev/null @@ -1,653 +0,0 @@ -package corehttp - -import ( - "context" - "errors" - "io" - "net/http" - "net/http/httptest" - "regexp" - "strings" - "testing" - - namesys "github.com/ipfs/go-namesys" - version "github.com/ipfs/kubo" - core "github.com/ipfs/kubo/core" - "github.com/ipfs/kubo/core/coreapi" - repo "github.com/ipfs/kubo/repo" - - datastore "github.com/ipfs/go-datastore" - syncds "github.com/ipfs/go-datastore/sync" - "github.com/ipfs/go-libipfs/files" - path "github.com/ipfs/go-path" - iface "github.com/ipfs/interface-go-ipfs-core" - nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" - ipath "github.com/ipfs/interface-go-ipfs-core/path" - config "github.com/ipfs/kubo/config" - ci "github.com/libp2p/go-libp2p/core/crypto" - id "github.com/libp2p/go-libp2p/p2p/protocol/identify" -) - -// `ipfs object new unixfs-dir` -var emptyDir = "/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" - -type mockNamesys map[string]path.Path - -func (m mockNamesys) Resolve(ctx context.Context, name string, opts ...nsopts.ResolveOpt) (value path.Path, err error) { - cfg := nsopts.DefaultResolveOpts() - for _, o := range opts { - o(&cfg) - } - depth := cfg.Depth - if depth == nsopts.UnlimitedDepth { - // max uint - depth = ^uint(0) - } - for strings.HasPrefix(name, "/ipns/") { - if depth == 0 { - return value, namesys.ErrResolveRecursion - } - depth-- - - var ok bool - value, ok = m[name] - if !ok { - return "", namesys.ErrResolveFailed - } - name = value.String() - } - return value, nil -} - -func (m mockNamesys) ResolveAsync(ctx context.Context, name string, opts ...nsopts.ResolveOpt) <-chan namesys.Result { - out := make(chan namesys.Result, 1) - v, err := m.Resolve(ctx, name, opts...) - out <- namesys.Result{Path: v, Err: err} - close(out) - return out -} - -func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value path.Path, opts ...nsopts.PublishOption) error { - return errors.New("not implemented for mockNamesys") -} - -func (m mockNamesys) GetResolver(subs string) (namesys.Resolver, bool) { - return nil, false -} - -func newNodeWithMockNamesys(ns mockNamesys) (*core.IpfsNode, error) { - c := config.Config{ - Identity: config.Identity{ - PeerID: "QmTFauExutTsy4XP6JbMFcw2Wa9645HJt2bTqL6qYDCKfe", // required by offline node - }, - } - r := &repo.Mock{ - C: c, - D: syncds.MutexWrap(datastore.NewMapDatastore()), - } - n, err := core.NewNode(context.Background(), &core.BuildCfg{Repo: r}) - if err != nil { - return nil, err - } - n.Namesys = ns - return n, nil -} - -type delegatedHandler struct { - http.Handler -} - -func (dh *delegatedHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - dh.Handler.ServeHTTP(w, r) -} - -func doWithoutRedirect(req *http.Request) (*http.Response, error) { - tag := "without-redirect" - c := &http.Client{ - CheckRedirect: func(req *http.Request, via []*http.Request) error { - return errors.New(tag) - }, - } - res, err := c.Do(req) - if err != nil && !strings.Contains(err.Error(), tag) { - return nil, err - } - return res, nil -} - -func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, iface.CoreAPI, context.Context) { - n, err := newNodeWithMockNamesys(ns) - if err != nil { - t.Fatal(err) - } - - // need this variable here since we need to construct handler with - // listener, and server with handler. yay cycles. - dh := &delegatedHandler{} - ts := httptest.NewServer(dh) - t.Cleanup(func() { ts.Close() }) - - dh.Handler, err = makeHandler(n, - ts.Listener, - HostnameOption(), - GatewayOption(false, "/ipfs", "/ipns"), - VersionOption(), - ) - if err != nil { - t.Fatal(err) - } - - api, err := coreapi.NewCoreAPI(n) - if err != nil { - t.Fatal(err) - } - - return ts, api, n.Context() -} - -func matchPathOrBreadcrumbs(s string, expected string) bool { - matched, _ := regexp.MatchString("Index of\n[\t ]*"+regexp.QuoteMeta(expected), s) - return matched -} - -func TestUriQueryRedirect(t *testing.T) { - ts, _, _ := newTestServerAndNode(t, mockNamesys{}) - - cid := "QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR" - for i, test := range []struct { - path string - status int - location string - }{ - // - Browsers will send original URI in URL-escaped form - // - We expect query parameters to be persisted - // - We drop fragments, as those should not be sent by a browser - {"/ipfs/?uri=ipfs%3A%2F%2FQmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco%2Fwiki%2FFoo_%C4%85%C4%99.html%3Ffilename%3Dtest-%C4%99.html%23header-%C4%85", http.StatusMovedPermanently, "/ipfs/QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco/wiki/Foo_%c4%85%c4%99.html?filename=test-%c4%99.html"}, - {"/ipfs/?uri=ipns%3A%2F%2Fexample.com%2Fwiki%2FFoo_%C4%85%C4%99.html%3Ffilename%3Dtest-%C4%99.html", http.StatusMovedPermanently, "/ipns/example.com/wiki/Foo_%c4%85%c4%99.html?filename=test-%c4%99.html"}, - {"/ipfs/?uri=ipfs://" + cid, http.StatusMovedPermanently, "/ipfs/" + cid}, - {"/ipfs?uri=ipfs://" + cid, http.StatusMovedPermanently, "/ipfs/?uri=ipfs://" + cid}, - {"/ipfs/?uri=ipns://" + cid, http.StatusMovedPermanently, "/ipns/" + cid}, - {"/ipns/?uri=ipfs%3A%2F%2FQmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco%2Fwiki%2FFoo_%C4%85%C4%99.html%3Ffilename%3Dtest-%C4%99.html%23header-%C4%85", http.StatusMovedPermanently, "/ipfs/QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco/wiki/Foo_%c4%85%c4%99.html?filename=test-%c4%99.html"}, - {"/ipns/?uri=ipns%3A%2F%2Fexample.com%2Fwiki%2FFoo_%C4%85%C4%99.html%3Ffilename%3Dtest-%C4%99.html", http.StatusMovedPermanently, "/ipns/example.com/wiki/Foo_%c4%85%c4%99.html?filename=test-%c4%99.html"}, - {"/ipns?uri=ipns://" + cid, http.StatusMovedPermanently, "/ipns/?uri=ipns://" + cid}, - {"/ipns/?uri=ipns://" + cid, http.StatusMovedPermanently, "/ipns/" + cid}, - {"/ipns/?uri=ipfs://" + cid, http.StatusMovedPermanently, "/ipfs/" + cid}, - {"/ipfs/?uri=unsupported://" + cid, http.StatusBadRequest, ""}, - {"/ipfs/?uri=invaliduri", http.StatusBadRequest, ""}, - {"/ipfs/?uri=" + cid, http.StatusBadRequest, ""}, - } { - - r, err := http.NewRequest(http.MethodGet, ts.URL+test.path, nil) - if err != nil { - t.Fatal(err) - } - resp, err := doWithoutRedirect(r) - if err != nil { - t.Fatal(err) - } - defer resp.Body.Close() - - if resp.StatusCode != test.status { - t.Errorf("(%d) got %d, expected %d from %s", i, resp.StatusCode, test.status, ts.URL+test.path) - } - - locHdr := resp.Header.Get("Location") - if locHdr != test.location { - t.Errorf("(%d) location header got %s, expected %s from %s", i, locHdr, test.location, ts.URL+test.path) - } - } -} - -func TestGatewayGet(t *testing.T) { - ns := mockNamesys{} - ts, api, ctx := newTestServerAndNode(t, ns) - - k, err := api.Unixfs().Add(ctx, files.NewBytesFile([]byte("fnord"))) - if err != nil { - t.Fatal(err) - } - ns["/ipns/example.com"] = path.FromString(k.String()) - ns["/ipns/working.example.com"] = path.FromString(k.String()) - ns["/ipns/double.example.com"] = path.FromString("/ipns/working.example.com") - ns["/ipns/triple.example.com"] = path.FromString("/ipns/double.example.com") - ns["/ipns/broken.example.com"] = path.FromString("/ipns/" + k.Cid().String()) - // We picked .man because: - // 1. It's a valid TLD. - // 2. Go treats it as the file extension for "man" files (even though - // nobody actually *uses* this extension, AFAIK). - // - // Unfortunately, this may not work on all platforms as file type - // detection is platform dependent. - ns["/ipns/example.man"] = path.FromString(k.String()) - - t.Log(ts.URL) - for i, test := range []struct { - host string - path string - status int - text string - }{ - {"127.0.0.1:8080", "/", http.StatusNotFound, "404 page not found\n"}, - {"127.0.0.1:8080", "/" + k.Cid().String(), http.StatusNotFound, "404 page not found\n"}, - {"127.0.0.1:8080", k.String(), http.StatusOK, "fnord"}, - {"127.0.0.1:8080", "/ipns/nxdomain.example.com", http.StatusBadRequest, "ipfs resolve -r /ipns/nxdomain.example.com: " + namesys.ErrResolveFailed.Error() + "\n"}, - {"127.0.0.1:8080", "/ipns/%0D%0A%0D%0Ahello", http.StatusBadRequest, "ipfs resolve -r /ipns/\\r\\n\\r\\nhello: " + namesys.ErrResolveFailed.Error() + "\n"}, - {"127.0.0.1:8080", "/ipns/example.com", http.StatusOK, "fnord"}, - {"example.com", "/", http.StatusOK, "fnord"}, - - {"working.example.com", "/", http.StatusOK, "fnord"}, - {"double.example.com", "/", http.StatusOK, "fnord"}, - {"triple.example.com", "/", http.StatusOK, "fnord"}, - {"working.example.com", k.String(), http.StatusNotFound, "ipfs resolve -r /ipns/working.example.com" + k.String() + ": no link named \"ipfs\" under " + k.Cid().String() + "\n"}, - {"broken.example.com", "/", http.StatusBadRequest, "ipfs resolve -r /ipns/broken.example.com/: " + namesys.ErrResolveFailed.Error() + "\n"}, - {"broken.example.com", k.String(), http.StatusBadRequest, "ipfs resolve -r /ipns/broken.example.com" + k.String() + ": " + namesys.ErrResolveFailed.Error() + "\n"}, - // This test case ensures we don't treat the TLD as a file extension. - {"example.man", "/", http.StatusOK, "fnord"}, - } { - var c http.Client - r, err := http.NewRequest(http.MethodGet, ts.URL+test.path, nil) - if err != nil { - t.Fatal(err) - } - r.Host = test.host - resp, err := c.Do(r) - - urlstr := "http://" + test.host + test.path - if err != nil { - t.Errorf("error requesting %s: %s", urlstr, err) - continue - } - defer resp.Body.Close() - contentType := resp.Header.Get("Content-Type") - if contentType != "text/plain; charset=utf-8" { - t.Errorf("expected content type to be text/plain, got %s", contentType) - } - body, err := io.ReadAll(resp.Body) - if resp.StatusCode != test.status { - t.Errorf("(%d) got %d, expected %d from %s", i, resp.StatusCode, test.status, urlstr) - t.Errorf("Body: %s", body) - continue - } - if err != nil { - t.Fatalf("error reading response from %s: %s", urlstr, err) - } - if string(body) != test.text { - t.Errorf("unexpected response body from %s: expected %q; got %q", urlstr, test.text, body) - continue - } - } -} - -func TestPretty404(t *testing.T) { - ns := mockNamesys{} - ts, api, ctx := newTestServerAndNode(t, ns) - - f1 := files.NewMapDirectory(map[string]files.Node{ - "ipfs-404.html": files.NewBytesFile([]byte("Custom 404")), - "deeper": files.NewMapDirectory(map[string]files.Node{ - "ipfs-404.html": files.NewBytesFile([]byte("Deep custom 404")), - }), - }) - - k, err := api.Unixfs().Add(ctx, f1) - if err != nil { - t.Fatal(err) - } - - host := "example.net" - ns["/ipns/"+host] = path.FromString(k.String()) - - for _, test := range []struct { - path string - accept string - status int - text string - }{ - {"/ipfs-404.html", "text/html", http.StatusOK, "Custom 404"}, - {"/nope", "text/html", http.StatusNotFound, "Custom 404"}, - {"/nope", "text/*", http.StatusNotFound, "Custom 404"}, - {"/nope", "*/*", http.StatusNotFound, "Custom 404"}, - {"/nope", "application/json", http.StatusNotFound, "ipfs resolve -r /ipns/example.net/nope: no link named \"nope\" under QmcmnF7XG5G34RdqYErYDwCKNFQ6jb8oKVR21WAJgubiaj\n"}, - {"/deeper/nope", "text/html", http.StatusNotFound, "Deep custom 404"}, - {"/deeper/", "text/html", http.StatusOK, ""}, - {"/deeper", "text/html", http.StatusOK, ""}, - {"/nope/nope", "text/html", http.StatusNotFound, "Custom 404"}, - } { - var c http.Client - req, err := http.NewRequest("GET", ts.URL+test.path, nil) - if err != nil { - t.Fatal(err) - } - req.Header.Add("Accept", test.accept) - req.Host = host - resp, err := c.Do(req) - - if err != nil { - t.Fatalf("error requesting %s: %s", test.path, err) - } - - defer resp.Body.Close() - if resp.StatusCode != test.status { - t.Fatalf("got %d, expected %d, from %s", resp.StatusCode, test.status, test.path) - } - body, err := io.ReadAll(resp.Body) - if err != nil { - t.Fatalf("error reading response from %s: %s", test.path, err) - } - - if test.text != "" && string(body) != test.text { - t.Fatalf("unexpected response body from %s: got %q, expected %q", test.path, body, test.text) - } - } -} - -func TestIPNSHostnameRedirect(t *testing.T) { - ns := mockNamesys{} - ts, api, ctx := newTestServerAndNode(t, ns) - t.Logf("test server url: %s", ts.URL) - - // create /ipns/example.net/foo/index.html - - f1 := files.NewMapDirectory(map[string]files.Node{ - "_": files.NewBytesFile([]byte("_")), - "foo": files.NewMapDirectory(map[string]files.Node{ - "index.html": files.NewBytesFile([]byte("_")), - }), - }) - - k, err := api.Unixfs().Add(ctx, f1) - if err != nil { - t.Fatal(err) - } - - t.Logf("k: %s\n", k) - ns["/ipns/example.net"] = path.FromString(k.String()) - - // make request to directory containing index.html - req, err := http.NewRequest(http.MethodGet, ts.URL+"/foo", nil) - if err != nil { - t.Fatal(err) - } - req.Host = "example.net" - - res, err := doWithoutRedirect(req) - if err != nil { - t.Fatal(err) - } - - // expect 301 redirect to same path, but with trailing slash - if res.StatusCode != 301 { - t.Errorf("status is %d, expected 301", res.StatusCode) - } - hdr := res.Header["Location"] - if len(hdr) < 1 { - t.Errorf("location header not present") - } else if hdr[0] != "/foo/" { - t.Errorf("location header is %v, expected /foo/", hdr[0]) - } - - // make request with prefix to directory containing index.html - req, err = http.NewRequest(http.MethodGet, ts.URL+"/foo", nil) - if err != nil { - t.Fatal(err) - } - req.Host = "example.net" - - res, err = doWithoutRedirect(req) - if err != nil { - t.Fatal(err) - } - - // expect 301 redirect to same path, but with prefix and trailing slash - if res.StatusCode != 301 { - t.Errorf("status is %d, expected 301", res.StatusCode) - } - hdr = res.Header["Location"] - if len(hdr) < 1 { - t.Errorf("location header not present") - } else if hdr[0] != "/foo/" { - t.Errorf("location header is %v, expected /foo/", hdr[0]) - } - - // make sure /version isn't exposed - req, err = http.NewRequest(http.MethodGet, ts.URL+"/version", nil) - if err != nil { - t.Fatal(err) - } - req.Host = "example.net" - - res, err = doWithoutRedirect(req) - if err != nil { - t.Fatal(err) - } - - if res.StatusCode != 404 { - t.Fatalf("expected a 404 error, got: %s", res.Status) - } -} - -// Test directory listing on DNSLink website -// (scenario when Host header is the same as URL hostname) -// This is basic regression test: additional end-to-end tests -// can be found in test/sharness/t0115-gateway-dir-listing.sh -func TestIPNSHostnameBacklinks(t *testing.T) { - ns := mockNamesys{} - ts, api, ctx := newTestServerAndNode(t, ns) - t.Logf("test server url: %s", ts.URL) - - f1 := files.NewMapDirectory(map[string]files.Node{ - "file.txt": files.NewBytesFile([]byte("1")), - "foo? #<'": files.NewMapDirectory(map[string]files.Node{ - "file.txt": files.NewBytesFile([]byte("2")), - "bar": files.NewMapDirectory(map[string]files.Node{ - "file.txt": files.NewBytesFile([]byte("3")), - }), - }), - }) - - // create /ipns/example.net/foo/ - k, err := api.Unixfs().Add(ctx, f1) - if err != nil { - t.Fatal(err) - } - - k2, err := api.ResolvePath(ctx, ipath.Join(k, "foo? #<'")) - if err != nil { - t.Fatal(err) - } - - k3, err := api.ResolvePath(ctx, ipath.Join(k, "foo? #<'/bar")) - if err != nil { - t.Fatal(err) - } - - t.Logf("k: %s\n", k) - ns["/ipns/example.net"] = path.FromString(k.String()) - - // make request to directory listing - req, err := http.NewRequest(http.MethodGet, ts.URL+"/foo%3F%20%23%3C%27/", nil) - if err != nil { - t.Fatal(err) - } - req.Host = "example.net" - - res, err := doWithoutRedirect(req) - if err != nil { - t.Fatal(err) - } - - // expect correct links - body, err := io.ReadAll(res.Body) - if err != nil { - t.Fatalf("error reading response: %s", err) - } - s := string(body) - t.Logf("body: %s\n", string(body)) - - if !matchPathOrBreadcrumbs(s, "/ipns/example.net/foo? #<'") { - t.Fatalf("expected a path in directory listing") - } - if !strings.Contains(s, "") { - t.Fatalf("expected backlink in directory listing") - } - if !strings.Contains(s, "") { - t.Fatalf("expected file in directory listing") - } - if !strings.Contains(s, "") { - t.Fatalf("expected no backlink in directory listing of the root CID") - } - if !strings.Contains(s, "") { - t.Fatalf("expected file in directory listing") - } - if !strings.Contains(s, "example.net/foo? #<'/bar") { - t.Fatalf("expected a path in directory listing") - } - if !strings.Contains(s, "") { - t.Fatalf("expected backlink in directory listing") - } - if !strings.Contains(s, "") { - t.Fatalf("expected file in directory listing") - } - if !strings.Contains(s, k3.Cid().String()) { - t.Fatalf("expected hash in directory listing") - } -} - -func TestCacheControlImmutable(t *testing.T) { - ts, _, _ := newTestServerAndNode(t, nil) - t.Logf("test server url: %s", ts.URL) - - req, err := http.NewRequest(http.MethodGet, ts.URL+emptyDir+"/", nil) - if err != nil { - t.Fatal(err) - } - - res, err := doWithoutRedirect(req) - if err != nil { - t.Fatal(err) - } - - // check the immutable tag isn't set - hdrs, ok := res.Header["Cache-Control"] - if ok { - for _, hdr := range hdrs { - if strings.Contains(hdr, "immutable") { - t.Fatalf("unexpected Cache-Control: immutable on directory listing: %s", hdr) - } - } - } -} - -func TestGoGetSupport(t *testing.T) { - ts, _, _ := newTestServerAndNode(t, nil) - t.Logf("test server url: %s", ts.URL) - - // mimic go-get - req, err := http.NewRequest(http.MethodGet, ts.URL+emptyDir+"?go-get=1", nil) - if err != nil { - t.Fatal(err) - } - - res, err := doWithoutRedirect(req) - if err != nil { - t.Fatal(err) - } - - if res.StatusCode != 200 { - t.Errorf("status is %d, expected 200", res.StatusCode) - } -} - -func TestVersion(t *testing.T) { - version.CurrentCommit = "theshortcommithash" - - ns := mockNamesys{} - ts, _, _ := newTestServerAndNode(t, ns) - t.Logf("test server url: %s", ts.URL) - - req, err := http.NewRequest(http.MethodGet, ts.URL+"/version", nil) - if err != nil { - t.Fatal(err) - } - - res, err := doWithoutRedirect(req) - if err != nil { - t.Fatal(err) - } - body, err := io.ReadAll(res.Body) - if err != nil { - t.Fatalf("error reading response: %s", err) - } - s := string(body) - - if !strings.Contains(s, "Commit: theshortcommithash") { - t.Fatalf("response doesn't contain commit:\n%s", s) - } - - if !strings.Contains(s, "Client Version: "+version.GetUserAgentVersion()) { - t.Fatalf("response doesn't contain client version:\n%s", s) - } - - if !strings.Contains(s, "Protocol Version: "+id.DefaultProtocolVersion) { - t.Fatalf("response doesn't contain protocol version:\n%s", s) - } -} diff --git a/gateway/core/corehttp/hostname.go b/gateway/core/corehttp/hostname.go deleted file mode 100644 index cb6d7fbc5..000000000 --- a/gateway/core/corehttp/hostname.go +++ /dev/null @@ -1,602 +0,0 @@ -package corehttp - -import ( - "context" - "fmt" - "net" - "net/http" - "net/url" - "regexp" - "strings" - - cid "github.com/ipfs/go-cid" - namesys "github.com/ipfs/go-namesys" - core "github.com/ipfs/kubo/core" - coreapi "github.com/ipfs/kubo/core/coreapi" - "github.com/ipfs/kubo/core/corehttp/gateway" - "github.com/libp2p/go-libp2p/core/peer" - dns "github.com/miekg/dns" - - mbase "github.com/multiformats/go-multibase" - - iface "github.com/ipfs/interface-go-ipfs-core" - options "github.com/ipfs/interface-go-ipfs-core/options" - nsopts "github.com/ipfs/interface-go-ipfs-core/options/namesys" - config "github.com/ipfs/kubo/config" -) - -var defaultPaths = []string{"/ipfs/", "/ipns/", "/api/", "/p2p/"} - -var subdomainGatewaySpec = &config.GatewaySpec{ - Paths: defaultPaths, - UseSubdomains: true, -} - -var defaultKnownGateways = map[string]*config.GatewaySpec{ - "localhost": subdomainGatewaySpec, -} - -// Label's max length in DNS (https://tools.ietf.org/html/rfc1034#page-7) -const dnsLabelMaxLength int = 63 - -// HostnameOption rewrites an incoming request based on the Host header. -func HostnameOption() ServeOption { - return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - childMux := http.NewServeMux() - - coreAPI, err := coreapi.NewCoreAPI(n) - if err != nil { - return nil, err - } - - cfg, err := n.Repo.Config() - if err != nil { - return nil, err - } - - knownGateways := prepareKnownGateways(cfg.Gateway.PublicGateways) - - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - // Unfortunately, many (well, ipfs.io) gateways use - // DNSLink so if we blindly rewrite with DNSLink, we'll - // break /ipfs links. - // - // We fix this by maintaining a list of known gateways - // and the paths that they serve "gateway" content on. - // That way, we can use DNSLink for everything else. - - // Support X-Forwarded-Host if added by a reverse proxy - // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host - host := r.Host - if xHost := r.Header.Get("X-Forwarded-Host"); xHost != "" { - host = xHost - } - - // HTTP Host & Path check: is this one of our "known gateways"? - if gw, ok := isKnownHostname(host, knownGateways); ok { - // This is a known gateway but request is not using - // the subdomain feature. - - // Does this gateway _handle_ this path? - if hasPrefix(r.URL.Path, gw.Paths...) { - // It does. - - // Should this gateway use subdomains instead of paths? - if gw.UseSubdomains { - // Yes, redirect if applicable - // Example: dweb.link/ipfs/{cid} → {cid}.ipfs.dweb.link - useInlinedDNSLink := gw.InlineDNSLink.WithDefault(config.DefaultInlineDNSLink) - newURL, err := toSubdomainURL(host, r.URL.Path, r, useInlinedDNSLink, coreAPI) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - if newURL != "" { - // Set "Location" header with redirect destination. - // It is ignored by curl in default mode, but will - // be respected by user agents that follow - // redirects by default, namely web browsers - w.Header().Set("Location", newURL) - - // Note: we continue regular gateway processing: - // HTTP Status Code http.StatusMovedPermanently - // will be set later, in statusResponseWriter - } - } - - // Not a subdomain resource, continue with path processing - // Example: 127.0.0.1:8080/ipfs/{CID}, ipfs.io/ipfs/{CID} etc - childMux.ServeHTTP(w, r) - return - } - // Not a whitelisted path - - // Try DNSLink, if it was not explicitly disabled for the hostname - if !gw.NoDNSLink && isDNSLinkName(r.Context(), coreAPI, host) { - // rewrite path and handle as DNSLink - r.URL.Path = "/ipns/" + stripPort(host) + r.URL.Path - childMux.ServeHTTP(w, withHostnameContext(r, host)) - return - } - - // If not, resource does not exist on the hostname, return 404 - http.NotFound(w, r) - return - } - - // HTTP Host check: is this one of our subdomain-based "known gateways"? - // IPFS details extracted from the host: {rootID}.{ns}.{gwHostname} - // /ipfs/ example: {cid}.ipfs.localhost:8080, {cid}.ipfs.dweb.link - // /ipns/ example: {libp2p-key}.ipns.localhost:8080, {inlined-dnslink-fqdn}.ipns.dweb.link - if gw, gwHostname, ns, rootID, ok := knownSubdomainDetails(host, knownGateways); ok { - // Looks like we're using a known gateway in subdomain mode. - - // Assemble original path prefix. - pathPrefix := "/" + ns + "/" + rootID - - // Retrieve whether or not we should inline DNSLink. - useInlinedDNSLink := gw.InlineDNSLink.WithDefault(config.DefaultInlineDNSLink) - - // Does this gateway _handle_ subdomains AND this path? - if !(gw.UseSubdomains && hasPrefix(pathPrefix, gw.Paths...)) { - // If not, resource does not exist, return 404 - http.NotFound(w, r) - return - } - - // Check if rootID is a valid CID - if rootCID, err := cid.Decode(rootID); err == nil { - // Do we need to redirect root CID to a canonical DNS representation? - dnsCID, err := toDNSLabel(rootID, rootCID) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - if !strings.HasPrefix(r.Host, dnsCID) { - dnsPrefix := "/" + ns + "/" + dnsCID - newURL, err := toSubdomainURL(gwHostname, dnsPrefix+r.URL.Path, r, useInlinedDNSLink, coreAPI) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - if newURL != "" { - // Redirect to deterministic CID to ensure CID - // always gets the same Origin on the web - http.Redirect(w, r, newURL, http.StatusMovedPermanently) - return - } - } - - // Do we need to fix multicodec in PeerID represented as CIDv1? - if isPeerIDNamespace(ns) { - if rootCID.Type() != cid.Libp2pKey { - newURL, err := toSubdomainURL(gwHostname, pathPrefix+r.URL.Path, r, useInlinedDNSLink, coreAPI) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - if newURL != "" { - // Redirect to CID fixed inside of toSubdomainURL() - http.Redirect(w, r, newURL, http.StatusMovedPermanently) - return - } - } - } - } else { // rootID is not a CID.. - - // Check if rootID is a single DNS label with an inlined - // DNSLink FQDN a single DNS label. We support this so - // loading DNSLink names over TLS "just works" on public - // HTTP gateways. - // - // Rationale for doing this can be found under "Option C" - // at: https://github.com/ipfs/in-web-browsers/issues/169 - // - // TLDR is: - // https://dweb.link/ipns/my.v-long.example.com - // can be loaded from a subdomain gateway with a wildcard - // TLS cert if represented as a single DNS label: - // https://my-v--long-example-com.ipns.dweb.link - if ns == "ipns" && !strings.Contains(rootID, ".") { - // if there is no TXT recordfor rootID - if !isDNSLinkName(r.Context(), coreAPI, rootID) { - // my-v--long-example-com → my.v-long.example.com - dnslinkFQDN := toDNSLinkFQDN(rootID) - if isDNSLinkName(r.Context(), coreAPI, dnslinkFQDN) { - // update path prefix to use real FQDN with DNSLink - pathPrefix = "/ipns/" + dnslinkFQDN - } - } - } - } - - // Rewrite the path to not use subdomains - r.URL.Path = pathPrefix + r.URL.Path - - // Serve path request - childMux.ServeHTTP(w, withHostnameContext(r, gwHostname)) - return - } - // We don't have a known gateway. Fallback on DNSLink lookup - - // Wildcard HTTP Host check: - // 1. is wildcard DNSLink enabled (Gateway.NoDNSLink=false)? - // 2. does Host header include a fully qualified domain name (FQDN)? - // 3. does DNSLink record exist in DNS? - if !cfg.Gateway.NoDNSLink && isDNSLinkName(r.Context(), coreAPI, host) { - // rewrite path and handle as DNSLink - r.URL.Path = "/ipns/" + stripPort(host) + r.URL.Path - ctx := context.WithValue(r.Context(), gateway.DNSLinkHostnameKey, host) - childMux.ServeHTTP(w, withHostnameContext(r.WithContext(ctx), host)) - return - } - - // else, treat it as an old school gateway, I guess. - childMux.ServeHTTP(w, r) - }) - return childMux, nil - } -} - -type gatewayHosts struct { - exact map[string]*config.GatewaySpec - wildcard []wildcardHost -} - -type wildcardHost struct { - re *regexp.Regexp - spec *config.GatewaySpec -} - -// Extends request context to include hostname of a canonical gateway root -// (subdomain root or dnslink fqdn) -func withHostnameContext(r *http.Request, hostname string) *http.Request { - // This is required for links on directory listing pages to work correctly - // on subdomain and dnslink gateways. While DNSlink could read value from - // Host header, subdomain gateways have more comples rules (knownSubdomainDetails) - // More: https://github.com/ipfs/dir-index-html/issues/42 - // nolint: staticcheck // non-backward compatible change - ctx := context.WithValue(r.Context(), gateway.GatewayHostnameKey, hostname) - return r.WithContext(ctx) -} - -func prepareKnownGateways(publicGateways map[string]*config.GatewaySpec) gatewayHosts { - var hosts gatewayHosts - - hosts.exact = make(map[string]*config.GatewaySpec, len(publicGateways)+len(defaultKnownGateways)) - - // First, implicit defaults such as subdomain gateway on localhost - for hostname, gw := range defaultKnownGateways { - hosts.exact[hostname] = gw - } - - // Then apply values from Gateway.PublicGateways, if present in the config - for hostname, gw := range publicGateways { - if gw == nil { - // Remove any implicit defaults, if present. This is useful when one - // wants to disable subdomain gateway on localhost etc. - delete(hosts.exact, hostname) - continue - } - if strings.Contains(hostname, "*") { - // from *.domain.tld, construct a regexp that match any direct subdomain - // of .domain.tld. - // - // Regexp will be in the form of ^[^.]+\.domain.tld(?::\d+)?$ - - escaped := strings.ReplaceAll(hostname, ".", `\.`) - regexed := strings.ReplaceAll(escaped, "*", "[^.]+") - - re, err := regexp.Compile(fmt.Sprintf(`^%s(?::\d+)?$`, regexed)) - if err != nil { - log.Warn("invalid wildcard gateway hostname \"%s\"", hostname) - } - - hosts.wildcard = append(hosts.wildcard, wildcardHost{re: re, spec: gw}) - } else { - hosts.exact[hostname] = gw - } - } - - return hosts -} - -// isKnownHostname checks Gateway.PublicGateways and returns matching -// GatewaySpec with graceful fallback to version without port -func isKnownHostname(hostname string, knownGateways gatewayHosts) (gw *config.GatewaySpec, ok bool) { - // Try hostname (host+optional port - value from Host header as-is) - if gw, ok := knownGateways.exact[hostname]; ok { - return gw, ok - } - // Also test without port - if gw, ok = knownGateways.exact[stripPort(hostname)]; ok { - return gw, ok - } - - // Wildcard support. Test both with and without port. - for _, host := range knownGateways.wildcard { - if host.re.MatchString(hostname) { - return host.spec, true - } - } - - return nil, false -} - -// Parses Host header and looks for a known gateway matching subdomain host. -// If found, returns GatewaySpec and subdomain components extracted from Host -// header: {rootID}.{ns}.{gwHostname} -// Note: hostname is host + optional port -func knownSubdomainDetails(hostname string, knownGateways gatewayHosts) (gw *config.GatewaySpec, gwHostname, ns, rootID string, ok bool) { - labels := strings.Split(hostname, ".") - // Look for FQDN of a known gateway hostname. - // Example: given "dist.ipfs.tech.ipns.dweb.link": - // 1. Lookup "link" TLD in knownGateways: negative - // 2. Lookup "dweb.link" in knownGateways: positive - // - // Stops when we have 2 or fewer labels left as we need at least a - // rootId and a namespace. - for i := len(labels) - 1; i >= 2; i-- { - fqdn := strings.Join(labels[i:], ".") - gw, ok := isKnownHostname(fqdn, knownGateways) - if !ok { - continue - } - - ns := labels[i-1] - if !isSubdomainNamespace(ns) { - continue - } - - // Merge remaining labels (could be a FQDN with DNSLink) - rootID := strings.Join(labels[:i-1], ".") - return gw, fqdn, ns, rootID, true - } - // no match - return nil, "", "", "", false -} - -// isDomainNameAndNotPeerID returns bool if string looks like a valid DNS name AND is not a PeerID -func isDomainNameAndNotPeerID(hostname string) bool { - if len(hostname) == 0 { - return false - } - if _, err := peer.Decode(hostname); err == nil { - return false - } - _, ok := dns.IsDomainName(hostname) - return ok -} - -// isDNSLinkName returns bool if a valid DNS TXT record exist for provided host -func isDNSLinkName(ctx context.Context, ipfs iface.CoreAPI, host string) bool { - dnslinkName := stripPort(host) - - if !isDomainNameAndNotPeerID(dnslinkName) { - return false - } - - name := "/ipns/" + dnslinkName - // check if DNSLink exists - depth := options.Name.ResolveOption(nsopts.Depth(1)) - _, err := ipfs.Name().Resolve(ctx, name, depth) - return err == nil || err == namesys.ErrResolveRecursion -} - -func isSubdomainNamespace(ns string) bool { - switch ns { - case "ipfs", "ipns", "p2p", "ipld": - return true - default: - return false - } -} - -func isPeerIDNamespace(ns string) bool { - switch ns { - case "ipns", "p2p": - return true - default: - return false - } -} - -// Converts a CID to DNS-safe representation that fits in 63 characters -func toDNSLabel(rootID string, rootCID cid.Cid) (dnsCID string, err error) { - // Return as-is if things fit - if len(rootID) <= dnsLabelMaxLength { - return rootID, nil - } - - // Convert to Base36 and see if that helped - rootID, err = cid.NewCidV1(rootCID.Type(), rootCID.Hash()).StringOfBase(mbase.Base36) - if err != nil { - return "", err - } - if len(rootID) <= dnsLabelMaxLength { - return rootID, nil - } - - // Can't win with DNS at this point, return error - return "", fmt.Errorf("CID incompatible with DNS label length limit of 63: %s", rootID) -} - -// Returns true if HTTP request involves TLS certificate. -// See https://github.com/ipfs/in-web-browsers/issues/169 to understand how it -// impacts DNSLink websites on public gateways. -func isHTTPSRequest(r *http.Request) bool { - // X-Forwarded-Proto if added by a reverse proxy - // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto - xproto := r.Header.Get("X-Forwarded-Proto") - // Is request a native TLS (not used atm, but future-proofing) - // or a proxied HTTPS (eg. go-ipfs behind nginx at a public gw)? - return r.URL.Scheme == "https" || xproto == "https" -} - -// Converts a FQDN to DNS-safe representation that fits in 63 characters: -// my.v-long.example.com → my-v--long-example-com -func toDNSLinkDNSLabel(fqdn string) (dnsLabel string, err error) { - dnsLabel = strings.ReplaceAll(fqdn, "-", "--") - dnsLabel = strings.ReplaceAll(dnsLabel, ".", "-") - if len(dnsLabel) > dnsLabelMaxLength { - return "", fmt.Errorf("DNSLink representation incompatible with DNS label length limit of 63: %s", dnsLabel) - } - return dnsLabel, nil -} - -// Converts a DNS-safe representation of DNSLink FQDN to real FQDN: -// my-v--long-example-com → my.v-long.example.com -func toDNSLinkFQDN(dnsLabel string) (fqdn string) { - fqdn = strings.ReplaceAll(dnsLabel, "--", "@") // @ placeholder is unused in DNS labels - fqdn = strings.ReplaceAll(fqdn, "-", ".") - fqdn = strings.ReplaceAll(fqdn, "@", "-") - return fqdn -} - -// Converts a hostname/path to a subdomain-based URL, if applicable. -func toSubdomainURL(hostname, path string, r *http.Request, inlineDNSLink bool, ipfs iface.CoreAPI) (redirURL string, err error) { - var scheme, ns, rootID, rest string - - query := r.URL.RawQuery - parts := strings.SplitN(path, "/", 4) - isHTTPS := isHTTPSRequest(r) - safeRedirectURL := func(in string) (out string, err error) { - safeURI, err := url.ParseRequestURI(in) - if err != nil { - return "", err - } - return safeURI.String(), nil - } - - if isHTTPS { - scheme = "https:" - } else { - scheme = "http:" - } - - switch len(parts) { - case 4: - rest = parts[3] - fallthrough - case 3: - ns = parts[1] - rootID = parts[2] - default: - return "", nil - } - - if !isSubdomainNamespace(ns) { - return "", nil - } - - // add prefix if query is present - if query != "" { - query = "?" + query - } - - // Normalize problematic PeerIDs (eg. ed25519+identity) to CID representation - if isPeerIDNamespace(ns) && !isDomainNameAndNotPeerID(rootID) { - peerID, err := peer.Decode(rootID) - // Note: PeerID CIDv1 with protobuf multicodec will fail, but we fix it - // in the next block - if err == nil { - rootID = peer.ToCid(peerID).String() - } - } - - // If rootID is a CID, ensure it uses DNS-friendly text representation - if rootCID, err := cid.Decode(rootID); err == nil { - multicodec := rootCID.Type() - var base mbase.Encoding = mbase.Base32 - - // Normalizations specific to /ipns/{libp2p-key} - if isPeerIDNamespace(ns) { - // Using Base36 for /ipns/ for consistency - // Context: https://github.com/ipfs/kubo/pull/7441#discussion_r452372828 - base = mbase.Base36 - - // PeerIDs represented as CIDv1 are expected to have libp2p-key - // multicodec (https://github.com/libp2p/specs/pull/209). - // We ease the transition by fixing multicodec on the fly: - // https://github.com/ipfs/kubo/issues/5287#issuecomment-492163929 - if multicodec != cid.Libp2pKey { - multicodec = cid.Libp2pKey - } - } - - // Ensure CID text representation used in subdomain is compatible - // with the way DNS and URIs are implemented in user agents. - // - // 1. Switch to CIDv1 and enable case-insensitive Base encoding - // to avoid issues when user agent force-lowercases the hostname - // before making the request - // (https://github.com/ipfs/in-web-browsers/issues/89) - rootCID = cid.NewCidV1(multicodec, rootCID.Hash()) - rootID, err = rootCID.StringOfBase(base) - if err != nil { - return "", err - } - // 2. Make sure CID fits in a DNS label, adjust encoding if needed - // (https://github.com/ipfs/kubo/issues/7318) - rootID, err = toDNSLabel(rootID, rootCID) - if err != nil { - return "", err - } - } else { // rootID is not a CID - - // Check if rootID is a FQDN with DNSLink and convert it to TLS-safe - // representation that fits in a single DNS label. We support this so - // loading DNSLink names over TLS "just works" on public HTTP gateways - // that pass 'https' in X-Forwarded-Proto to go-ipfs. - // - // Rationale can be found under "Option C" - // at: https://github.com/ipfs/in-web-browsers/issues/169 - // - // TLDR is: - // /ipns/my.v-long.example.com - // can be loaded from a subdomain gateway with a wildcard TLS cert if - // represented as a single DNS label: - // https://my-v--long-example-com.ipns.dweb.link - if (inlineDNSLink || isHTTPS) && ns == "ipns" && strings.Contains(rootID, ".") { - if isDNSLinkName(r.Context(), ipfs, rootID) { - // my.v-long.example.com → my-v--long-example-com - dnsLabel, err := toDNSLinkDNSLabel(rootID) - if err != nil { - return "", err - } - // update path prefix to use real FQDN with DNSLink - rootID = dnsLabel - } - } - } - - return safeRedirectURL(fmt.Sprintf( - "%s//%s.%s.%s/%s%s", - scheme, - rootID, - ns, - hostname, - rest, - query, - )) -} - -func hasPrefix(path string, prefixes ...string) bool { - for _, prefix := range prefixes { - // Assume people are creative with trailing slashes in Gateway config - p := strings.TrimSuffix(prefix, "/") - // Support for both /version and /ipfs/$cid - if p == path || strings.HasPrefix(path, p+"/") { - return true - } - } - return false -} - -func stripPort(hostname string) string { - host, _, err := net.SplitHostPort(hostname) - if err == nil { - return host - } - return hostname -} diff --git a/gateway/core/corehttp/hostname_test.go b/gateway/core/corehttp/hostname_test.go deleted file mode 100644 index b4a8b8d16..000000000 --- a/gateway/core/corehttp/hostname_test.go +++ /dev/null @@ -1,307 +0,0 @@ -package corehttp - -import ( - "errors" - "net/http" - "net/http/httptest" - "testing" - - cid "github.com/ipfs/go-cid" - "github.com/ipfs/go-libipfs/files" - path "github.com/ipfs/go-path" - config "github.com/ipfs/kubo/config" - coreapi "github.com/ipfs/kubo/core/coreapi" -) - -func TestToSubdomainURL(t *testing.T) { - ns := mockNamesys{} - n, err := newNodeWithMockNamesys(ns) - if err != nil { - t.Fatal(err) - } - coreAPI, err := coreapi.NewCoreAPI(n) - if err != nil { - t.Fatal(err) - } - testCID, err := coreAPI.Unixfs().Add(n.Context(), files.NewBytesFile([]byte("fnord"))) - if err != nil { - t.Fatal(err) - } - ns["/ipns/dnslink.long-name.example.com"] = path.FromString(testCID.String()) - ns["/ipns/dnslink.too-long.f1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5o.example.com"] = path.FromString(testCID.String()) - httpRequest := httptest.NewRequest("GET", "http://127.0.0.1:8080", nil) - httpsRequest := httptest.NewRequest("GET", "https://https-request-stub.example.com", nil) - httpsProxiedRequest := httptest.NewRequest("GET", "http://proxied-https-request-stub.example.com", nil) - httpsProxiedRequest.Header.Set("X-Forwarded-Proto", "https") - - for _, test := range []struct { - // in: - request *http.Request - gwHostname string - inlineDNSLink bool - path string - // out: - url string - err error - }{ - // DNSLink - {httpRequest, "localhost", false, "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost/", nil}, - // Hostname with port - {httpRequest, "localhost:8080", false, "/ipns/dnslink.io", "http://dnslink.io.ipns.localhost:8080/", nil}, - // CIDv0 → CIDv1base32 - {httpRequest, "localhost", false, "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.localhost/", nil}, - // CIDv1 with long sha512 - {httpRequest, "localhost", false, "/ipfs/bafkrgqe3ohjcjplc6n4f3fwunlj6upltggn7xqujbsvnvyw764srszz4u4rshq6ztos4chl4plgg4ffyyxnayrtdi5oc4xb2332g645433aeg", "", errors.New("CID incompatible with DNS label length limit of 63: kf1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5oj")}, - // PeerID as CIDv1 needs to have libp2p-key multicodec - {httpRequest, "localhost", false, "/ipns/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", "http://k2k4r8n0flx3ra0y5dr8fmyvwbzy3eiztmtq6th694k5a3rznayp3e4o.ipns.localhost/", nil}, - {httpRequest, "localhost", false, "/ipns/bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "http://k2k4r8l9ja7hkzynavdqup76ou46tnvuaqegbd04a4o1mpbsey0meucb.ipns.localhost/", nil}, - // PeerID: ed25519+identity multihash → CIDv1Base36 - {httpRequest, "localhost", false, "/ipns/12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", "http://k51qzi5uqu5di608geewp3nqkg0bpujoasmka7ftkyxgcm3fh1aroup0gsdrna.ipns.localhost/", nil}, - {httpRequest, "sub.localhost", false, "/ipfs/QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "http://bafybeif7a7gdklt6hodwdrmwmxnhksctcuav6lfxlcyfz4khzl3qfmvcgu.ipfs.sub.localhost/", nil}, - // HTTPS requires DNSLink name to fit in a single DNS label – see "Option C" from https://github.com/ipfs/in-web-browsers/issues/169 - {httpRequest, "dweb.link", false, "/ipns/dnslink.long-name.example.com", "http://dnslink.long-name.example.com.ipns.dweb.link/", nil}, - {httpsRequest, "dweb.link", false, "/ipns/dnslink.long-name.example.com", "https://dnslink-long--name-example-com.ipns.dweb.link/", nil}, - {httpsProxiedRequest, "dweb.link", false, "/ipns/dnslink.long-name.example.com", "https://dnslink-long--name-example-com.ipns.dweb.link/", nil}, - // HTTP requests can also be converted to fit into a single DNS label - https://github.com/ipfs/kubo/issues/9243 - {httpRequest, "localhost", true, "/ipns/dnslink.long-name.example.com", "http://dnslink-long--name-example-com.ipns.localhost/", nil}, - {httpRequest, "dweb.link", true, "/ipns/dnslink.long-name.example.com", "http://dnslink-long--name-example-com.ipns.dweb.link/", nil}, - } { - url, err := toSubdomainURL(test.gwHostname, test.path, test.request, test.inlineDNSLink, coreAPI) - if url != test.url || !equalError(err, test.err) { - t.Errorf("(%s, %v, %s) returned (%s, %v), expected (%s, %v)", test.gwHostname, test.inlineDNSLink, test.path, url, err, test.url, test.err) - } - } -} - -func TestToDNSLinkDNSLabel(t *testing.T) { - for _, test := range []struct { - in string - out string - err error - }{ - {"dnslink.long-name.example.com", "dnslink-long--name-example-com", nil}, - {"dnslink.too-long.f1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5o.example.com", "", errors.New("DNSLink representation incompatible with DNS label length limit of 63: dnslink-too--long-f1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5o-example-com")}, - } { - out, err := toDNSLinkDNSLabel(test.in) - if out != test.out || !equalError(err, test.err) { - t.Errorf("(%s) returned (%s, %v), expected (%s, %v)", test.in, out, err, test.out, test.err) - } - } -} - -func TestToDNSLinkFQDN(t *testing.T) { - for _, test := range []struct { - in string - out string - }{ - {"singlelabel", "singlelabel"}, - {"docs-ipfs-tech", "docs.ipfs.tech"}, - {"dnslink-long--name-example-com", "dnslink.long-name.example.com"}, - } { - out := toDNSLinkFQDN(test.in) - if out != test.out { - t.Errorf("(%s) returned (%s), expected (%s)", test.in, out, test.out) - } - } -} - -func TestIsHTTPSRequest(t *testing.T) { - httpRequest := httptest.NewRequest("GET", "http://127.0.0.1:8080", nil) - httpsRequest := httptest.NewRequest("GET", "https://https-request-stub.example.com", nil) - httpsProxiedRequest := httptest.NewRequest("GET", "http://proxied-https-request-stub.example.com", nil) - httpsProxiedRequest.Header.Set("X-Forwarded-Proto", "https") - httpProxiedRequest := httptest.NewRequest("GET", "http://proxied-http-request-stub.example.com", nil) - httpProxiedRequest.Header.Set("X-Forwarded-Proto", "http") - oddballRequest := httptest.NewRequest("GET", "foo://127.0.0.1:8080", nil) - for _, test := range []struct { - in *http.Request - out bool - }{ - {httpRequest, false}, - {httpsRequest, true}, - {httpsProxiedRequest, true}, - {httpProxiedRequest, false}, - {oddballRequest, false}, - } { - out := isHTTPSRequest(test.in) - if out != test.out { - t.Errorf("(%+v): returned %t, expected %t", test.in, out, test.out) - } - } -} - -func TestHasPrefix(t *testing.T) { - for _, test := range []struct { - prefixes []string - path string - out bool - }{ - {[]string{"/ipfs"}, "/ipfs/cid", true}, - {[]string{"/ipfs/"}, "/ipfs/cid", true}, - {[]string{"/version/"}, "/version", true}, - {[]string{"/version"}, "/version", true}, - } { - out := hasPrefix(test.path, test.prefixes...) - if out != test.out { - t.Errorf("(%+v, %s) returned '%t', expected '%t'", test.prefixes, test.path, out, test.out) - } - } -} - -func TestIsDomainNameAndNotPeerID(t *testing.T) { - for _, test := range []struct { - hostname string - out bool - }{ - {"", false}, - {"example.com", true}, - {"non-icann.something", true}, - {"..", false}, - {"12D3KooWFB51PRY9BxcXSH6khFXw1BZeszeLDy7C8GciskqCTZn5", false}, // valid peerid - {"k51qzi5uqu5di608geewp3nqkg0bpujoasmka7ftkyxgcm3fh1aroup0gsdrna", false}, // valid peerid - } { - out := isDomainNameAndNotPeerID(test.hostname) - if out != test.out { - t.Errorf("(%s) returned '%t', expected '%t'", test.hostname, out, test.out) - } - } -} - -func TestPortStripping(t *testing.T) { - for _, test := range []struct { - in string - out string - }{ - {"localhost:8080", "localhost"}, - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.localhost:8080", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.localhost"}, - {"example.com:443", "example.com"}, - {"example.com", "example.com"}, - {"foo-dweb.ipfs.pvt.k12.ma.us:8080", "foo-dweb.ipfs.pvt.k12.ma.us"}, - {"localhost", "localhost"}, - {"[::1]:8080", "::1"}, - } { - out := stripPort(test.in) - if out != test.out { - t.Errorf("(%s): returned '%s', expected '%s'", test.in, out, test.out) - } - } -} - -func TestToDNSLabel(t *testing.T) { - for _, test := range []struct { - in string - out string - err error - }{ - // <= 63 - {"QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", "QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n", nil}, - {"bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", "bafybeickencdqw37dpz3ha36ewrh4undfjt2do52chtcky4rxkj447qhdm", nil}, - // > 63 - // PeerID: ed25519+identity multihash → CIDv1Base36 - {"bafzaajaiaejca4syrpdu6gdx4wsdnokxkprgzxf4wrstuc34gxw5k5jrag2so5gk", "k51qzi5uqu5dj16qyiq0tajolkojyl9qdkr254920wxv7ghtuwcz593tp69z9m", nil}, - // CIDv1 with long sha512 → error - {"bafkrgqe3ohjcjplc6n4f3fwunlj6upltggn7xqujbsvnvyw764srszz4u4rshq6ztos4chl4plgg4ffyyxnayrtdi5oc4xb2332g645433aeg", "", errors.New("CID incompatible with DNS label length limit of 63: kf1siqrebi3vir8sab33hu5vcy008djegvay6atmz91ojesyjs8lx350b7y7i1nvyw2haytfukfyu2f2x4tocdrfa0zgij6p4zpl4u5oj")}, - } { - inCID, _ := cid.Decode(test.in) - out, err := toDNSLabel(test.in, inCID) - if out != test.out || !equalError(err, test.err) { - t.Errorf("(%s): returned (%s, %v) expected (%s, %v)", test.in, out, err, test.out, test.err) - } - } - -} - -func TestKnownSubdomainDetails(t *testing.T) { - gwLocalhost := &config.GatewaySpec{Paths: []string{"/ipfs", "/ipns", "/api"}, UseSubdomains: true} - gwDweb := &config.GatewaySpec{Paths: []string{"/ipfs", "/ipns", "/api"}, UseSubdomains: true} - gwLong := &config.GatewaySpec{Paths: []string{"/ipfs", "/ipns", "/api"}, UseSubdomains: true} - gwWildcard1 := &config.GatewaySpec{Paths: []string{"/ipfs", "/ipns", "/api"}, UseSubdomains: true} - gwWildcard2 := &config.GatewaySpec{Paths: []string{"/ipfs", "/ipns", "/api"}, UseSubdomains: true} - - knownGateways := prepareKnownGateways(map[string]*config.GatewaySpec{ - "localhost": gwLocalhost, - "dweb.link": gwDweb, - "devgateway.dweb.link": gwDweb, - "dweb.ipfs.pvt.k12.ma.us": gwLong, // note the sneaky ".ipfs." ;-) - "*.wildcard1.tld": gwWildcard1, - "*.*.wildcard2.tld": gwWildcard2, - }) - - for _, test := range []struct { - // in: - hostHeader string - // out: - gw *config.GatewaySpec - hostname string - ns string - rootID string - ok bool - }{ - // no subdomain - {"127.0.0.1:8080", nil, "", "", "", false}, - {"[::1]:8080", nil, "", "", "", false}, - {"hey.look.example.com", nil, "", "", "", false}, - {"dweb.link", nil, "", "", "", false}, - // malformed Host header - {".....dweb.link", nil, "", "", "", false}, - {"link", nil, "", "", "", false}, - {"8080:dweb.link", nil, "", "", "", false}, - {" ", nil, "", "", "", false}, - {"", nil, "", "", "", false}, - // unknown gateway host - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.unknown.example.com", nil, "", "", "", false}, - // cid in subdomain, known gateway - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.localhost:8080", gwLocalhost, "localhost:8080", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.link", gwDweb, "dweb.link", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.devgateway.dweb.link", gwDweb, "devgateway.dweb.link", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, - // capture everything before .ipfs. - {"foo.bar.boo-buzz.ipfs.dweb.link", gwDweb, "dweb.link", "ipfs", "foo.bar.boo-buzz", true}, - // ipns - {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.localhost:8080", gwLocalhost, "localhost:8080", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, - {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.dweb.link", gwDweb, "dweb.link", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, - // edge case check: public gateway under long TLD (see: https://publicsuffix.org) - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.ipfs.pvt.k12.ma.us", gwLong, "dweb.ipfs.pvt.k12.ma.us", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, - {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.dweb.ipfs.pvt.k12.ma.us", gwLong, "dweb.ipfs.pvt.k12.ma.us", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, - // dnslink in subdomain - {"en.wikipedia-on-ipfs.org.ipns.localhost:8080", gwLocalhost, "localhost:8080", "ipns", "en.wikipedia-on-ipfs.org", true}, - {"en.wikipedia-on-ipfs.org.ipns.localhost", gwLocalhost, "localhost", "ipns", "en.wikipedia-on-ipfs.org", true}, - {"dist.ipfs.tech.ipns.localhost:8080", gwLocalhost, "localhost:8080", "ipns", "dist.ipfs.tech", true}, - {"en.wikipedia-on-ipfs.org.ipns.dweb.link", gwDweb, "dweb.link", "ipns", "en.wikipedia-on-ipfs.org", true}, - // edge case check: public gateway under long TLD (see: https://publicsuffix.org) - {"foo.dweb.ipfs.pvt.k12.ma.us", nil, "", "", "", false}, - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.dweb.ipfs.pvt.k12.ma.us", gwLong, "dweb.ipfs.pvt.k12.ma.us", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, - {"bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju.ipns.dweb.ipfs.pvt.k12.ma.us", gwLong, "dweb.ipfs.pvt.k12.ma.us", "ipns", "bafzbeihe35nmjqar22thmxsnlsgxppd66pseq6tscs4mo25y55juhh6bju", true}, - // other namespaces - {"api.localhost", nil, "", "", "", false}, - {"peerid.p2p.localhost", gwLocalhost, "localhost", "p2p", "peerid", true}, - // wildcards - {"wildcard1.tld", nil, "", "", "", false}, - {".wildcard1.tld", nil, "", "", "", false}, - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.wildcard1.tld", nil, "", "", "", false}, - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.sub.wildcard1.tld", gwWildcard1, "sub.wildcard1.tld", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.sub1.sub2.wildcard1.tld", nil, "", "", "", false}, - {"bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am.ipfs.sub1.sub2.wildcard2.tld", gwWildcard2, "sub1.sub2.wildcard2.tld", "ipfs", "bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am", true}, - } { - gw, hostname, ns, rootID, ok := knownSubdomainDetails(test.hostHeader, knownGateways) - if ok != test.ok { - t.Errorf("knownSubdomainDetails(%s): ok is %t, expected %t", test.hostHeader, ok, test.ok) - } - if rootID != test.rootID { - t.Errorf("knownSubdomainDetails(%s): rootID is '%s', expected '%s'", test.hostHeader, rootID, test.rootID) - } - if ns != test.ns { - t.Errorf("knownSubdomainDetails(%s): ns is '%s', expected '%s'", test.hostHeader, ns, test.ns) - } - if hostname != test.hostname { - t.Errorf("knownSubdomainDetails(%s): hostname is '%s', expected '%s'", test.hostHeader, hostname, test.hostname) - } - if gw != test.gw { - t.Errorf("knownSubdomainDetails(%s): gw is %+v, expected %+v", test.hostHeader, gw, test.gw) - } - } - -} - -func equalError(a, b error) bool { - return (a == nil && b == nil) || (a != nil && b != nil && a.Error() == b.Error()) -} diff --git a/gateway/core/corehttp/logs.go b/gateway/core/corehttp/logs.go deleted file mode 100644 index 944e62c5b..000000000 --- a/gateway/core/corehttp/logs.go +++ /dev/null @@ -1,58 +0,0 @@ -package corehttp - -import ( - "io" - "net" - "net/http" - - lwriter "github.com/ipfs/go-log/writer" - core "github.com/ipfs/kubo/core" -) - -type writeErrNotifier struct { - w io.Writer - errs chan error -} - -func newWriteErrNotifier(w io.Writer) (io.WriteCloser, <-chan error) { - ch := make(chan error, 1) - return &writeErrNotifier{ - w: w, - errs: ch, - }, ch -} - -func (w *writeErrNotifier) Write(b []byte) (int, error) { - n, err := w.w.Write(b) - if err != nil { - select { - case w.errs <- err: - default: - } - } - if f, ok := w.w.(http.Flusher); ok { - f.Flush() - } - return n, err -} - -func (w *writeErrNotifier) Close() error { - select { - case w.errs <- io.EOF: - default: - } - return nil -} - -func LogOption() ServeOption { - return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - mux.HandleFunc("/logs", func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - wnf, errs := newWriteErrNotifier(w) - lwriter.WriterGroup.AddWriter(wnf) - log.Event(n.Context(), "log API client connected") //nolint deprecated - <-errs - }) - return mux, nil - } -} diff --git a/gateway/core/corehttp/metrics.go b/gateway/core/corehttp/metrics.go deleted file mode 100644 index e26be1ca9..000000000 --- a/gateway/core/corehttp/metrics.go +++ /dev/null @@ -1,204 +0,0 @@ -package corehttp - -import ( - "net" - "net/http" - "time" - - core "github.com/ipfs/kubo/core" - "go.opencensus.io/stats/view" - "go.opencensus.io/zpages" - - ocprom "contrib.go.opencensus.io/exporter/prometheus" - prometheus "github.com/prometheus/client_golang/prometheus" - promhttp "github.com/prometheus/client_golang/prometheus/promhttp" -) - -// MetricsScrapingOption adds the scraping endpoint which Prometheus uses to fetch metrics. -func MetricsScrapingOption(path string) ServeOption { - return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - mux.Handle(path, promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{})) - return mux, nil - } -} - -// This adds collection of OpenCensus metrics -func MetricsOpenCensusCollectionOption() ServeOption { - return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - log.Info("Init OpenCensus") - - promRegistry := prometheus.NewRegistry() - pe, err := ocprom.NewExporter(ocprom.Options{ - Namespace: "ipfs_oc", - Registry: promRegistry, - OnError: func(err error) { - log.Errorw("OC ERROR", "error", err) - }, - }) - if err != nil { - return nil, err - } - - // register prometheus with opencensus - view.RegisterExporter(pe) - view.SetReportingPeriod(2 * time.Second) - - // Construct the mux - zpages.Handle(mux, "/debug/metrics/oc/debugz") - mux.Handle("/debug/metrics/oc", pe) - - return mux, nil - } -} - -// MetricsOpenCensusDefaultPrometheusRegistry registers the default prometheus -// registry as an exporter to OpenCensus metrics. This means that OpenCensus -// metrics will show up in the prometheus metrics endpoint -func MetricsOpenCensusDefaultPrometheusRegistry() ServeOption { - return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - log.Info("Init OpenCensus with default prometheus registry") - - pe, err := ocprom.NewExporter(ocprom.Options{ - Registry: prometheus.DefaultRegisterer.(*prometheus.Registry), - OnError: func(err error) { - log.Errorw("OC default registry ERROR", "error", err) - }, - }) - if err != nil { - return nil, err - } - - // register prometheus with opencensus - view.RegisterExporter(pe) - - return mux, nil - } -} - -// MetricsCollectionOption adds collection of net/http-related metrics. -func MetricsCollectionOption(handlerName string) ServeOption { - return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - // Adapted from github.com/prometheus/client_golang/prometheus/http.go - // Work around https://github.com/prometheus/client_golang/pull/311 - opts := prometheus.SummaryOpts{ - Namespace: "ipfs", - Subsystem: "http", - ConstLabels: prometheus.Labels{"handler": handlerName}, - Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, - } - - reqCnt := prometheus.NewCounterVec( - prometheus.CounterOpts{ - Namespace: opts.Namespace, - Subsystem: opts.Subsystem, - Name: "requests_total", - Help: "Total number of HTTP requests made.", - ConstLabels: opts.ConstLabels, - }, - []string{"method", "code"}, - ) - if err := prometheus.Register(reqCnt); err != nil { - if are, ok := err.(prometheus.AlreadyRegisteredError); ok { - reqCnt = are.ExistingCollector.(*prometheus.CounterVec) - } else { - return nil, err - } - } - - opts.Name = "request_duration_seconds" - opts.Help = "The HTTP request latencies in seconds." - reqDur := prometheus.NewSummaryVec(opts, nil) - if err := prometheus.Register(reqDur); err != nil { - if are, ok := err.(prometheus.AlreadyRegisteredError); ok { - reqDur = are.ExistingCollector.(*prometheus.SummaryVec) - } else { - return nil, err - } - } - - opts.Name = "request_size_bytes" - opts.Help = "The HTTP request sizes in bytes." - reqSz := prometheus.NewSummaryVec(opts, nil) - if err := prometheus.Register(reqSz); err != nil { - if are, ok := err.(prometheus.AlreadyRegisteredError); ok { - reqSz = are.ExistingCollector.(*prometheus.SummaryVec) - } else { - return nil, err - } - } - - opts.Name = "response_size_bytes" - opts.Help = "The HTTP response sizes in bytes." - resSz := prometheus.NewSummaryVec(opts, nil) - if err := prometheus.Register(resSz); err != nil { - if are, ok := err.(prometheus.AlreadyRegisteredError); ok { - resSz = are.ExistingCollector.(*prometheus.SummaryVec) - } else { - return nil, err - } - } - - // Construct the mux - childMux := http.NewServeMux() - var promMux http.Handler = childMux - promMux = promhttp.InstrumentHandlerResponseSize(resSz, promMux) - promMux = promhttp.InstrumentHandlerRequestSize(reqSz, promMux) - promMux = promhttp.InstrumentHandlerDuration(reqDur, promMux) - promMux = promhttp.InstrumentHandlerCounter(reqCnt, promMux) - mux.Handle("/", promMux) - - return childMux, nil - } -} - -var ( - peersTotalMetric = prometheus.NewDesc( - prometheus.BuildFQName("ipfs", "p2p", "peers_total"), - "Number of connected peers", - []string{"transport"}, - nil, - ) -) - -type IpfsNodeCollector struct { - Node *core.IpfsNode -} - -func (IpfsNodeCollector) Describe(ch chan<- *prometheus.Desc) { - ch <- peersTotalMetric -} - -func (c IpfsNodeCollector) Collect(ch chan<- prometheus.Metric) { - for tr, val := range c.PeersTotalValues() { - ch <- prometheus.MustNewConstMetric( - peersTotalMetric, - prometheus.GaugeValue, - val, - tr, - ) - } -} - -func (c IpfsNodeCollector) PeersTotalValues() map[string]float64 { - vals := make(map[string]float64) - if c.Node.PeerHost == nil { - return vals - } - for _, peerID := range c.Node.PeerHost.Network().Peers() { - // Each peer may have more than one connection (see for an explanation - // https://github.com/libp2p/go-libp2p-swarm/commit/0538806), so we grab - // only one, the first (an arbitrary and non-deterministic choice), which - // according to ConnsToPeer is the oldest connection in the list - // (https://github.com/libp2p/go-libp2p-swarm/blob/v0.2.6/swarm.go#L362-L364). - conns := c.Node.PeerHost.Network().ConnsToPeer(peerID) - if len(conns) == 0 { - continue - } - tr := "" - for _, proto := range conns[0].RemoteMultiaddr().Protocols() { - tr = tr + "/" + proto.Name - } - vals[tr] = vals[tr] + 1 - } - return vals -} diff --git a/gateway/core/corehttp/metrics_test.go b/gateway/core/corehttp/metrics_test.go deleted file mode 100644 index 267d4ae97..000000000 --- a/gateway/core/corehttp/metrics_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package corehttp - -import ( - "context" - "testing" - "time" - - "github.com/ipfs/kubo/core" - - inet "github.com/libp2p/go-libp2p/core/network" - bhost "github.com/libp2p/go-libp2p/p2p/host/basic" - swarmt "github.com/libp2p/go-libp2p/p2p/net/swarm/testing" -) - -// This test is based on go-libp2p/p2p/net/swarm.TestConnectednessCorrect -// It builds 4 nodes and connects them, one being the sole center. -// Then it checks that the center reports the correct number of peers. -func TestPeersTotal(t *testing.T) { - ctx := context.Background() - - hosts := make([]*bhost.BasicHost, 4) - for i := 0; i < 4; i++ { - var err error - hosts[i], err = bhost.NewHost(swarmt.GenSwarm(t), nil) - if err != nil { - t.Fatal(err) - } - } - - dial := func(a, b inet.Network) { - swarmt.DivulgeAddresses(b, a) - if _, err := a.DialPeer(ctx, b.LocalPeer()); err != nil { - t.Fatalf("Failed to dial: %s", err) - } - } - - dial(hosts[0].Network(), hosts[1].Network()) - dial(hosts[0].Network(), hosts[2].Network()) - dial(hosts[0].Network(), hosts[3].Network()) - - // there's something wrong with dial, i think. it's not finishing - // completely. there must be some async stuff. - <-time.After(100 * time.Millisecond) - - node := &core.IpfsNode{PeerHost: hosts[0]} - collector := IpfsNodeCollector{Node: node} - peersTransport := collector.PeersTotalValues() - if len(peersTransport) > 2 { - t.Fatalf("expected at most 2 peers transport (tcp and upd/quic), got %d, transport map %v", - len(peersTransport), peersTransport) - } - totalPeers := peersTransport["/ip4/tcp"] + peersTransport["/ip4/udp/quic"] - if totalPeers != 3 { - t.Fatalf("expected 3 peers in either tcp or upd/quic transport, got %f", totalPeers) - } -} diff --git a/gateway/core/corehttp/mutex_profile.go b/gateway/core/corehttp/mutex_profile.go deleted file mode 100644 index bbaad5b3a..000000000 --- a/gateway/core/corehttp/mutex_profile.go +++ /dev/null @@ -1,78 +0,0 @@ -package corehttp - -import ( - "net" - "net/http" - "runtime" - "strconv" - - core "github.com/ipfs/kubo/core" -) - -// MutexFractionOption allows to set runtime.SetMutexProfileFraction via HTTP -// using POST request with parameter 'fraction'. -func MutexFractionOption(path string) ServeOption { - return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodPost { - http.Error(w, "only POST allowed", http.StatusMethodNotAllowed) - return - } - if err := r.ParseForm(); err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - asfr := r.Form.Get("fraction") - if len(asfr) == 0 { - http.Error(w, "parameter 'fraction' must be set", http.StatusBadRequest) - return - } - - fr, err := strconv.Atoi(asfr) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - log.Infof("Setting MutexProfileFraction to %d", fr) - runtime.SetMutexProfileFraction(fr) - }) - - return mux, nil - } -} - -// BlockProfileRateOption allows to set runtime.SetBlockProfileRate via HTTP -// using POST request with parameter 'rate'. -// The profiler tries to sample 1 event every nanoseconds. -// If rate == 1, then the profiler samples every blocking event. -// To disable, set rate = 0. -func BlockProfileRateOption(path string) ServeOption { - return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodPost { - http.Error(w, "only POST allowed", http.StatusMethodNotAllowed) - return - } - if err := r.ParseForm(); err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - rateStr := r.Form.Get("rate") - if len(rateStr) == 0 { - http.Error(w, "parameter 'rate' must be set", http.StatusBadRequest) - return - } - - rate, err := strconv.Atoi(rateStr) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - log.Infof("Setting BlockProfileRate to %d", rate) - runtime.SetBlockProfileRate(rate) - }) - return mux, nil - } -} diff --git a/gateway/core/corehttp/option_test.go b/gateway/core/corehttp/option_test.go deleted file mode 100644 index b401be9d5..000000000 --- a/gateway/core/corehttp/option_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package corehttp - -import ( - "fmt" - "io" - "net/http" - "net/http/httptest" - "testing" - - version "github.com/ipfs/kubo" -) - -type testcasecheckversion struct { - userAgent string - uri string - shouldHandle bool - responseBody string - responseCode int -} - -func (tc testcasecheckversion) body() string { - if !tc.shouldHandle && tc.responseBody == "" { - return fmt.Sprintf("%s (%s != %s)\n", errAPIVersionMismatch, version.ApiVersion, tc.userAgent) - } - - return tc.responseBody -} - -func TestCheckVersionOption(t *testing.T) { - tcs := []testcasecheckversion{ - {"/go-ipfs/0.1/", APIPath + "/test/", false, "", http.StatusBadRequest}, - {"/go-ipfs/0.1/", APIPath + "/version", true, "check!", http.StatusOK}, - {version.ApiVersion, APIPath + "/test", true, "check!", http.StatusOK}, - {"Mozilla Firefox/no go-ipfs node", APIPath + "/test", true, "check!", http.StatusOK}, - {"/go-ipfs/0.1/", "/webui", true, "check!", http.StatusOK}, - } - - for _, tc := range tcs { - t.Logf("%#v", tc) - r := httptest.NewRequest(http.MethodPost, tc.uri, nil) - r.Header.Add("User-Agent", tc.userAgent) // old version, should fail - - called := false - root := http.NewServeMux() - mux, err := CheckVersionOption()(nil, nil, root) - if err != nil { - t.Fatal(err) - } - - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - called = true - if !tc.shouldHandle { - t.Error("handler was called even though version didn't match") - } else { - if _, err := io.WriteString(w, "check!"); err != nil { - t.Error(err) - } - } - }) - - w := httptest.NewRecorder() - - root.ServeHTTP(w, r) - - if tc.shouldHandle && !called { - t.Error("handler wasn't called even though it should have") - } - - if w.Code != tc.responseCode { - t.Errorf("expected code %d but got %d", tc.responseCode, w.Code) - } - - if w.Body.String() != tc.body() { - t.Errorf("expected error message %q, got %q", tc.body(), w.Body.String()) - } - } -} diff --git a/gateway/core/corehttp/p2p_proxy.go b/gateway/core/corehttp/p2p_proxy.go deleted file mode 100644 index e239f47cd..000000000 --- a/gateway/core/corehttp/p2p_proxy.go +++ /dev/null @@ -1,82 +0,0 @@ -package corehttp - -import ( - "fmt" - "net" - "net/http" - "net/http/httputil" - "net/url" - "strings" - - core "github.com/ipfs/kubo/core" - peer "github.com/libp2p/go-libp2p/core/peer" - - p2phttp "github.com/libp2p/go-libp2p-http" - protocol "github.com/libp2p/go-libp2p/core/protocol" -) - -// P2PProxyOption is an endpoint for proxying a HTTP request to another ipfs peer -func P2PProxyOption() ServeOption { - return func(ipfsNode *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - mux.HandleFunc("/p2p/", func(w http.ResponseWriter, request *http.Request) { - // parse request - parsedRequest, err := parseRequest(request) - if err != nil { - handleError(w, "failed to parse request", err, 400) - return - } - - request.Host = "" // Let URL's Host take precedence. - request.URL.Path = parsedRequest.httpPath - target, err := url.Parse(fmt.Sprintf("libp2p://%s", parsedRequest.target)) - if err != nil { - handleError(w, "failed to parse url", err, 400) - return - } - - rt := p2phttp.NewTransport(ipfsNode.PeerHost, p2phttp.ProtocolOption(parsedRequest.name)) - proxy := httputil.NewSingleHostReverseProxy(target) - proxy.Transport = rt - proxy.ServeHTTP(w, request) - }) - return mux, nil - } -} - -type proxyRequest struct { - target string - name protocol.ID - httpPath string // path to send to the proxy-host -} - -// from the url path parse the peer-ID, name and http path -// /p2p/$peer_id/http/$http_path -// or -// /p2p/$peer_id/x/$protocol/http/$http_path -func parseRequest(request *http.Request) (*proxyRequest, error) { - path := request.URL.Path - - split := strings.SplitN(path, "/", 5) - if len(split) < 5 { - return nil, fmt.Errorf("invalid request path '%s'", path) - } - - if _, err := peer.Decode(split[2]); err != nil { - return nil, fmt.Errorf("invalid request path '%s'", path) - } - - if split[3] == "http" { - return &proxyRequest{split[2], protocol.ID("/http"), split[4]}, nil - } - - split = strings.SplitN(path, "/", 7) - if len(split) < 7 || split[3] != "x" || split[5] != "http" { - return nil, fmt.Errorf("invalid request path '%s'", path) - } - - return &proxyRequest{split[2], protocol.ID("/x/" + split[4] + "/http"), split[6]}, nil -} - -func handleError(w http.ResponseWriter, msg string, err error, code int) { - http.Error(w, fmt.Sprintf("%s: %s", msg, err), code) -} diff --git a/gateway/core/corehttp/p2p_proxy_test.go b/gateway/core/corehttp/p2p_proxy_test.go deleted file mode 100644 index 969bc31e1..000000000 --- a/gateway/core/corehttp/p2p_proxy_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package corehttp - -import ( - "net/http" - "strings" - "testing" - - "github.com/ipfs/kubo/thirdparty/assert" - - protocol "github.com/libp2p/go-libp2p/core/protocol" -) - -type TestCase struct { - urlprefix string - target string - name string - path string -} - -var validtestCases = []TestCase{ - {"http://localhost:5001", "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", "/http", "path/to/index.txt"}, - {"http://localhost:5001", "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", "/x/custom/http", "path/to/index.txt"}, - {"http://localhost:5001", "QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT", "/x/custom/http", "http/path/to/index.txt"}, -} - -func TestParseRequest(t *testing.T) { - for _, tc := range validtestCases { - url := tc.urlprefix + "/p2p/" + tc.target + tc.name + "/" + tc.path - req, _ := http.NewRequest(http.MethodGet, url, strings.NewReader("")) - - parsed, err := parseRequest(req) - if err != nil { - t.Fatal(err) - } - assert.True(parsed.httpPath == tc.path, t, "proxy request path") - assert.True(parsed.name == protocol.ID(tc.name), t, "proxy request name") - assert.True(parsed.target == tc.target, t, "proxy request peer-id") - } -} - -var invalidtestCases = []string{ - "http://localhost:5001/p2p/http/foobar", - "http://localhost:5001/p2p/QmT8JtU54XSmC38xSb1XHFSMm775VuTeajg7LWWWTAwzxT/x/custom/foobar", -} - -func TestParseRequestInvalidPath(t *testing.T) { - for _, tc := range invalidtestCases { - url := tc - req, _ := http.NewRequest(http.MethodGet, url, strings.NewReader("")) - - _, err := parseRequest(req) - if err == nil { - t.Fail() - } - } -} diff --git a/gateway/core/corehttp/redirect.go b/gateway/core/corehttp/redirect.go deleted file mode 100644 index bcd536d23..000000000 --- a/gateway/core/corehttp/redirect.go +++ /dev/null @@ -1,28 +0,0 @@ -package corehttp - -import ( - "net" - "net/http" - - core "github.com/ipfs/kubo/core" -) - -func RedirectOption(path string, redirect string) ServeOption { - handler := &redirectHandler{redirect} - return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) { - if len(path) > 0 { - mux.Handle("/"+path+"/", handler) - } else { - mux.Handle("/", handler) - } - return mux, nil - } -} - -type redirectHandler struct { - path string -} - -func (i *redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, i.path, http.StatusFound) -} diff --git a/gateway/core/corehttp/webui.go b/gateway/core/corehttp/webui.go deleted file mode 100644 index e8531459d..000000000 --- a/gateway/core/corehttp/webui.go +++ /dev/null @@ -1,57 +0,0 @@ -package corehttp - -// TODO: move to IPNS -const WebUIPath = "/ipfs/bafybeiequgo72mrvuml56j4gk7crewig5bavumrrzhkqbim6b3s2yqi7ty" // v2.21.0 - -// WebUIPaths is a list of all past webUI paths. -var WebUIPaths = []string{ - WebUIPath, - "/ipfs/bafybeibjbq3tmmy7wuihhhwvbladjsd3gx3kfjepxzkq6wylik6wc3whzy", - "/ipfs/bafybeiavrvt53fks6u32n5p2morgblcmck4bh4ymf4rrwu7ah5zsykmqqa", - "/ipfs/bafybeiageaoxg6d7npaof6eyzqbwvbubyler7bq44hayik2hvqcggg7d2y", - "/ipfs/bafybeidb5eryh72zajiokdggzo7yct2d6hhcflncji5im2y5w26uuygdsm", - "/ipfs/bafybeibozpulxtpv5nhfa2ue3dcjx23ndh3gwr5vwllk7ptoyfwnfjjr4q", - "/ipfs/bafybeiednzu62vskme5wpoj4bjjikeg3xovfpp4t7vxk5ty2jxdi4mv4bu", - "/ipfs/bafybeihcyruaeza7uyjd6ugicbcrqumejf6uf353e5etdkhotqffwtguva", - "/ipfs/bafybeiflkjt66aetfgcrgvv75izymd5kc47g6luepqmfq6zsf5w6ueth6y", - "/ipfs/bafybeid26vjplsejg7t3nrh7mxmiaaxriebbm4xxrxxdunlk7o337m5sqq", - "/ipfs/bafybeif4zkmu7qdhkpf3pnhwxipylqleof7rl6ojbe7mq3fzogz6m4xk3i", - "/ipfs/bafybeianwe4vy7sprht5sm3hshvxjeqhwcmvbzq73u55sdhqngmohkjgs4", - "/ipfs/bafybeicitin4p7ggmyjaubqpi3xwnagrwarsy6hiihraafk5rcrxqxju6m", - "/ipfs/bafybeihpetclqvwb4qnmumvcn7nh4pxrtugrlpw4jgjpqicdxsv7opdm6e", - "/ipfs/bafybeibnnxd4etu4tq5fuhu3z5p4rfu3buabfkeyr3o3s4h6wtesvvw6mu", - "/ipfs/bafybeid6luolenf4fcsuaw5rgdwpqbyerce4x3mi3hxfdtp5pwco7h7qyq", - "/ipfs/bafybeigkbbjnltbd4ewfj7elajsbnjwinyk6tiilczkqsibf3o7dcr6nn4", - "/ipfs/bafybeicp23nbcxtt2k2twyfivcbrc6kr3l5lnaiv3ozvwbemtrb7v52r6i", - "/ipfs/bafybeidatpz2hli6fgu3zul5woi27ujesdf5o5a7bu622qj6ugharciwjq", - "/ipfs/QmfQkD8pBSBCBxWEwFSu4XaDVSWK6bjnNuaWZjMyQbyDub", - "/ipfs/QmXc9raDM1M5G5fpBnVyQ71vR4gbnskwnB9iMEzBuLgvoZ", - "/ipfs/QmenEBWcAk3tN94fSKpKFtUMwty1qNwSYw3DMDFV6cPBXA", - "/ipfs/QmUnXcWZC5Ve21gUseouJsH5mLAyz5JPp8aHsg8qVUUK8e", - "/ipfs/QmSDgpiHco5yXdyVTfhKxr3aiJ82ynz8V14QcGKicM3rVh", - "/ipfs/QmRuvWJz1Fc8B9cTsAYANHTXqGmKR9DVfY5nvMD1uA2WQ8", - "/ipfs/QmQLXHs7K98JNQdWrBB2cQLJahPhmupbDjRuH1b9ibmwVa", - "/ipfs/QmXX7YRpU7nNBKfw75VG7Y1c3GwpSAGHRev67XVPgZFv9R", - "/ipfs/QmXdu7HWdV6CUaUabd9q2ZeA4iHZLVyDRj3Gi4dsJsWjbr", - "/ipfs/QmaaqrHyAQm7gALkRW8DcfGX3u8q9rWKnxEMmf7m9z515w", - "/ipfs/QmSHDxWsMPuJQKWmVA1rB5a3NX2Eme5fPqNb63qwaqiqSp", - "/ipfs/QmctngrQAt9fjpQUZr7Bx3BsXUcif52eZGTizWhvcShsjz", - "/ipfs/QmS2HL9v5YeKgQkkWMvs1EMnFtUowTEdFfSSeMT4pos1e6", - "/ipfs/QmR9MzChjp1MdFWik7NjEjqKQMzVmBkdK3dz14A6B5Cupm", - "/ipfs/QmRyWyKWmphamkMRnJVjUTzSFSAAZowYP4rnbgnfMXC9Mr", - "/ipfs/QmU3o9bvfenhTKhxUakbYrLDnZU7HezAVxPM6Ehjw9Xjqy", - "/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ", - "/ipfs/QmQNHd1suZTktPRhP7DD4nKWG46ZRSxkwHocycHVrK3dYW", - "/ipfs/QmNyMYhwJUS1cVvaWoVBhrW8KPj1qmie7rZcWo8f1Bvkhz", - "/ipfs/QmVTiRTQ72qiH4usAGT4c6qVxCMv4hFMUH9fvU6mktaXdP", - "/ipfs/QmYcP4sp1nraBiCYi6i9kqdaKobrK32yyMpTrM5JDA8a2C", - "/ipfs/QmUtMmxgHnDvQq4bpH6Y9MaLN1hpfjJz5LZcq941BEqEXs", - "/ipfs/QmPURAjo3oneGH53ovt68UZEBvsc8nNmEhQZEpsVEQUMZE", - "/ipfs/QmeSXt32frzhvewLKwA1dePTSjkTfGVwTh55ZcsJxrCSnk", - "/ipfs/QmcjeTciMNgEBe4xXvEaA4TQtwTRkXucx7DmKWViXSmX7m", - "/ipfs/QmfNbSskgvTXYhuqP8tb9AKbCkyRcCy3WeiXwD9y5LeoqK", - "/ipfs/QmPkojhjJkJ5LEGBDrAvdftrjAYmi9GU5Cq27mWvZTDieW", - "/ipfs/Qmexhq2sBHnXQbvyP2GfUdbnY7HCagH2Mw5vUNSBn2nxip", -} - -var WebUIOption = RedirectOption("webui", WebUIPath) diff --git a/gateway/core/corehttp/gateway/gateway.go b/gateway/gateway.go similarity index 100% rename from gateway/core/corehttp/gateway/gateway.go rename to gateway/gateway.go diff --git a/gateway/core/corehttp/gateway/handler.go b/gateway/handler.go similarity index 100% rename from gateway/core/corehttp/gateway/handler.go rename to gateway/handler.go diff --git a/gateway/core/corehttp/gateway/handler_block.go b/gateway/handler_block.go similarity index 100% rename from gateway/core/corehttp/gateway/handler_block.go rename to gateway/handler_block.go diff --git a/gateway/core/corehttp/gateway/handler_car.go b/gateway/handler_car.go similarity index 100% rename from gateway/core/corehttp/gateway/handler_car.go rename to gateway/handler_car.go diff --git a/gateway/core/corehttp/gateway/handler_codec.go b/gateway/handler_codec.go similarity index 99% rename from gateway/core/corehttp/gateway/handler_codec.go rename to gateway/handler_codec.go index ac219f165..cd7b11371 100644 --- a/gateway/core/corehttp/gateway/handler_codec.go +++ b/gateway/handler_codec.go @@ -12,8 +12,8 @@ import ( cid "github.com/ipfs/go-cid" ipldlegacy "github.com/ipfs/go-ipld-legacy" + "github.com/ipfs/go-libipfs/gateway/assets" ipath "github.com/ipfs/interface-go-ipfs-core/path" - "github.com/ipfs/kubo/core/corehttp/gateway/assets" "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/multicodec" mc "github.com/multiformats/go-multicodec" diff --git a/gateway/core/corehttp/gateway/handler_ipns_record.go b/gateway/handler_ipns_record.go similarity index 100% rename from gateway/core/corehttp/gateway/handler_ipns_record.go rename to gateway/handler_ipns_record.go diff --git a/gateway/core/corehttp/gateway/handler_tar.go b/gateway/handler_tar.go similarity index 100% rename from gateway/core/corehttp/gateway/handler_tar.go rename to gateway/handler_tar.go diff --git a/gateway/core/corehttp/gateway/handler_test.go b/gateway/handler_test.go similarity index 100% rename from gateway/core/corehttp/gateway/handler_test.go rename to gateway/handler_test.go diff --git a/gateway/core/corehttp/gateway/handler_unixfs.go b/gateway/handler_unixfs.go similarity index 100% rename from gateway/core/corehttp/gateway/handler_unixfs.go rename to gateway/handler_unixfs.go diff --git a/gateway/core/corehttp/gateway/handler_unixfs__redirects.go b/gateway/handler_unixfs__redirects.go similarity index 100% rename from gateway/core/corehttp/gateway/handler_unixfs__redirects.go rename to gateway/handler_unixfs__redirects.go diff --git a/gateway/core/corehttp/gateway/handler_unixfs_dir.go b/gateway/handler_unixfs_dir.go similarity index 99% rename from gateway/core/corehttp/gateway/handler_unixfs_dir.go rename to gateway/handler_unixfs_dir.go index 8a66d4ea9..6d3db7fd5 100644 --- a/gateway/core/corehttp/gateway/handler_unixfs_dir.go +++ b/gateway/handler_unixfs_dir.go @@ -11,11 +11,11 @@ import ( "github.com/dustin/go-humanize" cid "github.com/ipfs/go-cid" "github.com/ipfs/go-libipfs/files" + "github.com/ipfs/go-libipfs/gateway/assets" path "github.com/ipfs/go-path" "github.com/ipfs/go-path/resolver" options "github.com/ipfs/interface-go-ipfs-core/options" ipath "github.com/ipfs/interface-go-ipfs-core/path" - "github.com/ipfs/kubo/core/corehttp/gateway/assets" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" "go.uber.org/zap" diff --git a/gateway/core/corehttp/gateway/handler_unixfs_file.go b/gateway/handler_unixfs_file.go similarity index 100% rename from gateway/core/corehttp/gateway/handler_unixfs_file.go rename to gateway/handler_unixfs_file.go diff --git a/gateway/core/corehttp/gateway/lazyseek.go b/gateway/lazyseek.go similarity index 100% rename from gateway/core/corehttp/gateway/lazyseek.go rename to gateway/lazyseek.go diff --git a/gateway/core/corehttp/gateway/lazyseek_test.go b/gateway/lazyseek_test.go similarity index 100% rename from gateway/core/corehttp/gateway/lazyseek_test.go rename to gateway/lazyseek_test.go diff --git a/go.mod b/go.mod index 946a7c14b..f6e21fe94 100644 --- a/go.mod +++ b/go.mod @@ -4,50 +4,103 @@ go 1.19 require ( github.com/benbjohnson/clock v1.3.0 + github.com/cespare/xxhash v1.1.0 github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 + github.com/dustin/go-humanize v1.0.0 + github.com/gabriel-vasile/mimetype v1.4.1 + github.com/gogo/protobuf v1.3.2 github.com/gorilla/mux v1.8.0 github.com/ipfs/go-cid v0.3.2 + github.com/ipfs/go-ipfs-redirects-file v0.1.1 github.com/ipfs/go-ipfs-util v0.0.2 + github.com/ipfs/go-ipld-format v0.4.0 + github.com/ipfs/go-ipld-legacy v0.1.1 github.com/ipfs/go-ipns v0.3.0 + github.com/ipfs/go-log v1.0.5 github.com/ipfs/go-log/v2 v2.5.1 + github.com/ipfs/go-merkledag v0.9.0 + github.com/ipfs/go-mfs v0.2.1 + github.com/ipfs/go-path v0.3.0 + github.com/ipfs/interface-go-ipfs-core v0.10.0 + github.com/ipld/go-car v0.5.0 + github.com/ipld/go-ipld-prime v0.19.0 github.com/libp2p/go-libp2p v0.23.4 github.com/libp2p/go-libp2p-record v0.2.0 github.com/multiformats/go-multiaddr v0.8.0 github.com/multiformats/go-multibase v0.1.1 + github.com/multiformats/go-multicodec v0.6.0 github.com/multiformats/go-multihash v0.2.1 + github.com/prometheus/client_golang v1.13.0 github.com/samber/lo v1.36.0 github.com/stretchr/testify v1.8.1 go.opencensus.io v0.23.0 + go.opentelemetry.io/otel v1.7.0 + go.opentelemetry.io/otel/trace v1.7.0 + go.uber.org/zap v1.23.0 golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab ) require ( + github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/ipld/go-ipld-prime v0.9.0 // indirect - github.com/klauspost/cpuid/v2 v2.1.1 // indirect + github.com/go-logr/logr v1.2.3 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/ipfs/bbloom v0.0.4 // indirect + github.com/ipfs/go-bitfield v1.0.0 // indirect + github.com/ipfs/go-block-format v0.1.0 // indirect + github.com/ipfs/go-blockservice v0.5.0 // indirect + github.com/ipfs/go-datastore v0.6.0 // indirect + github.com/ipfs/go-fetcher v1.6.1 // indirect + github.com/ipfs/go-ipfs-blockstore v1.2.0 // indirect + github.com/ipfs/go-ipfs-chunker v0.0.1 // indirect + github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect + github.com/ipfs/go-ipfs-exchange-interface v0.2.0 // indirect + github.com/ipfs/go-ipfs-files v0.0.8 // indirect + github.com/ipfs/go-ipfs-posinfo v0.0.1 // indirect + github.com/ipfs/go-ipld-cbor v0.0.6 // indirect + github.com/ipfs/go-metrics-interface v0.0.1 // indirect + github.com/ipfs/go-unixfs v0.3.1 // indirect + github.com/ipfs/go-verifcid v0.0.2 // indirect + github.com/ipld/go-codec-dagpb v1.5.0 // indirect + github.com/jbenet/goprocess v0.1.4 // indirect + github.com/klauspost/cpuid/v2 v2.1.2 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/libp2p/go-openssl v0.1.0 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect github.com/mattn/go-pointer v0.0.1 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/minio/sha256-simd v1.0.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/multiformats/go-base32 v0.1.0 // indirect github.com/multiformats/go-base36 v0.1.0 // indirect - github.com/multiformats/go-multicodec v0.6.0 // indirect - github.com/multiformats/go-varint v0.0.6 // indirect + github.com/multiformats/go-varint v0.0.7 // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1 // indirect + github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/common v0.37.0 // indirect + github.com/prometheus/procfs v0.8.0 // indirect github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/stretchr/objx v0.5.0 // indirect + github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb // indirect + github.com/whyrusleeping/cbor-gen v0.0.0-20221220214510-0333c149dec0 // indirect + github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.8.0 // indirect - go.uber.org/zap v1.23.0 // indirect golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect golang.org/x/exp v0.0.0-20220916125017-b168a2c6b86b // indirect + golang.org/x/net v0.0.0-20220920183852-bf014ff85ad5 // indirect + golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect + golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + google.golang.org/protobuf v1.28.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect lukechampine.com/blake3 v1.1.7 // indirect ) diff --git a/go.sum b/go.sum index ab57d0a12..d535c67b5 100644 --- a/go.sum +++ b/go.sum @@ -1,94 +1,783 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.37.0/go.mod h1:TS1dMSSfndXH133OKGwekG838Om/cQT0BUHV3HcBgoo= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU= +dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= +dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= +git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= +github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= +github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/Kubuxu/go-os-helper v0.0.1/go.mod h1:N8B+I7vPCT80IcP58r50u4+gEEcsZETFUpAzWW2ep1Y= +github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= +github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/Stebalien/go-bitfield v0.0.1 h1:X3kbSSPUaJK60wV2hjOPZwmpljr6VGCqdq4cBLhbQBo= +github.com/Stebalien/go-bitfield v0.0.1/go.mod h1:GNjFpasyUVkHMsfEOk8EFLJ9syQ6SI+XWrX9Wf2XH0s= +github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= +github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= +github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a h1:E/8AP5dFtMhl5KPJz66Kt9G0n+7Sn41Fy1wv9/jHOrc= +github.com/alecthomas/units v0.0.0-20210927113745-59d0afb8317a/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= +github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= +github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= +github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= +github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= +github.com/btcsuite/btcd v0.0.0-20190523000118-16327141da8c/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= +github.com/btcsuite/btcd v0.0.0-20190605094302-a0d1e3e36d50/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= +github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= +github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= +github.com/btcsuite/btcd v0.21.0-beta/go.mod h1:ZSWyehm27aAuS9bvkATT+Xte3hjHZ+MRgMY/8NJ7K94= +github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= +github.com/btcsuite/btcutil v0.0.0-20190207003914-4c204d697803/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= +github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= +github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= +github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= +github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= +github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= 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= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 h1:HVTnpeuvF6Owjd5mniCL8DEXo7uYXdQEmOP4FJbV5tg= github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3/go.mod h1:p1d6YEZWvFzEh4KLyvBcVSnrfNDDvK2zfK/4x2v/4pE= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/cskr/pubsub v1.0.2 h1:vlOzMhl6PFn60gRlTQQsIfVwaPB/B/8MziK8FhEPt/0= +github.com/cskr/pubsub v1.0.2/go.mod h1:/8MzYXk/NJAz782G8RPkFzXTZVu63VotefPnR9TIRis= +github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/davidlazar/go-crypto v0.0.0-20170701192655-dcfb0a7ac018/go.mod h1:rQYf4tfk5sSwFsnDg3qYaBxSjsD9S8+59vW0dKUgme4= +github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= +github.com/dgraph-io/badger v1.5.5-0.20190226225317-8115aed38f8f/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ= +github.com/dgraph-io/badger v1.6.0-rc1/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= +github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= +github.com/dgraph-io/badger v1.6.1/go.mod h1:FRmFw3uxvcpa8zG3Rxs0th+hCLIuaQg8HlNV5bjgnuU= +github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= +github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= +github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= 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= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= +github.com/flynn/noise v1.0.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag= +github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= +github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= +github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/gabriel-vasile/mimetype v1.4.1 h1:TRWk7se+TOjCYgRth7+1/OYLNiRNIotknkFtf/dnN7Q= +github.com/gabriel-vasile/mimetype v1.4.1/go.mod h1:05Vi0w3Y9c/lNvJOdmIwvrrAhX3rYhfQQCaf9VJcv7M= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= +github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= +github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +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-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gopacket v1.1.17/go.mod h1:UdDNZ1OO62aGYVnPhxT1U6aI7ukYtA/kB8vaU0diBUM= +github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= +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/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= +github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= 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/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.4.2/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/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= +github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU= +github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48= +github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= +github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= +github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc= +github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= +github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/ipfs/bbloom v0.0.1/go.mod h1:oqo8CVWsJFMOZqTglBG4wydCE4IQA/G2/SEofB0rjUI= +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/go-bitfield v1.0.0 h1:y/XHm2GEmD9wKngheWNNCNL0pzrWXZwCdQGv1ikXknQ= +github.com/ipfs/go-bitfield v1.0.0/go.mod h1:N/UiujQy+K+ceU1EF5EkVd1TNqevLrCQMIcAEPrdtus= +github.com/ipfs/go-bitswap v0.1.0/go.mod h1:FFJEf18E9izuCqUtHxbWEvq+reg7o4CW5wSAE1wsxj0= +github.com/ipfs/go-bitswap v0.1.2/go.mod h1:qxSWS4NXGs7jQ6zQvoPY3+NmOfHHG47mhkiLzBpJQIs= +github.com/ipfs/go-bitswap v0.5.1/go.mod h1:P+ckC87ri1xFLvk74NlXdP0Kj9RmWAh4+H78sC6Qopo= +github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ= +github.com/ipfs/go-block-format v0.0.1/go.mod h1:DK/YYcsSUIVAFNwo/KZCdIIbpN0ROH/baNLgayt4pFc= +github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY= +github.com/ipfs/go-block-format v0.0.3/go.mod h1:4LmD4ZUw0mhO+JSKdpWwrzATiEfM7WWgQ8H5l6P8MVk= +github.com/ipfs/go-block-format v0.1.0 h1:1DYLENGQUVWVvZ9tMmZX2KVi0ALyPxxyP6jn8NuCxZY= +github.com/ipfs/go-block-format v0.1.0/go.mod h1:+McEIT+g52p+zz5xGAABGSOKrzmrdX97bc0USBdWPUs= +github.com/ipfs/go-blockservice v0.1.0/go.mod h1:hzmMScl1kXHg3M2BjTymbVPjv627N7sYcvYaKbop39M= +github.com/ipfs/go-blockservice v0.2.1/go.mod h1:k6SiwmgyYgs4M/qt+ww6amPeUH9EISLRBnvUurKJhi8= +github.com/ipfs/go-blockservice v0.5.0 h1:B2mwhhhVQl2ntW2EIpaWPwSCxSuqr5fFA93Ms4bYLEY= +github.com/ipfs/go-blockservice v0.5.0/go.mod h1:W6brZ5k20AehbmERplmERn8o2Ni3ZZubvAxaIUeaT6w= +github.com/ipfs/go-cid v0.0.1/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= +github.com/ipfs/go-cid v0.0.2/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= +github.com/ipfs/go-cid v0.0.3/go.mod h1:GHWU/WuQdMPmIosc4Yn1bcCT7dSeX4lBafM7iqUPQvM= github.com/ipfs/go-cid v0.0.4/go.mod h1:4LLaPOQwmk5z9LBgQnpkivrx8BJjUyGwTXCd5Xfj6+M= +github.com/ipfs/go-cid v0.0.5/go.mod h1:plgt+Y5MnOey4vO4UlUazGqdbEXuFYitED67FexhXog= +github.com/ipfs/go-cid v0.0.6/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= +github.com/ipfs/go-cid v0.0.7/go.mod h1:6Ux9z5e+HpkQdckYoX1PG/6xqKspzlEIR5SDmgqgC/I= +github.com/ipfs/go-cid v0.1.0/go.mod h1:rH5/Xv83Rfy8Rw6xG+id3DYAMUVmem1MowoKwdXmN2o= github.com/ipfs/go-cid v0.3.2 h1:OGgOd+JCFM+y1DjWPmVH+2/4POtpDzwcr7VgnB7mZXc= github.com/ipfs/go-cid v0.3.2/go.mod h1:gQ8pKqT/sUxGY+tIwy1RPpAojYu7jAyCp5Tz1svoupw= +github.com/ipfs/go-datastore v0.0.1/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE= +github.com/ipfs/go-datastore v0.0.5/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE= +github.com/ipfs/go-datastore v0.1.0/go.mod h1:d4KVXhMt913cLBEI/PXAy6ko+W7e9AhyAKBGh803qeE= +github.com/ipfs/go-datastore v0.1.1/go.mod h1:w38XXW9kVFNp57Zj5knbKWM2T+KOZCGDRVNdgPHtbHw= +github.com/ipfs/go-datastore v0.3.1/go.mod h1:w38XXW9kVFNp57Zj5knbKWM2T+KOZCGDRVNdgPHtbHw= +github.com/ipfs/go-datastore v0.4.0/go.mod h1:SX/xMIKoCszPqp+z9JhPYCmoOoXTvaa13XEbGtsFUhA= +github.com/ipfs/go-datastore v0.4.1/go.mod h1:SX/xMIKoCszPqp+z9JhPYCmoOoXTvaa13XEbGtsFUhA= +github.com/ipfs/go-datastore v0.4.4/go.mod h1:SX/xMIKoCszPqp+z9JhPYCmoOoXTvaa13XEbGtsFUhA= +github.com/ipfs/go-datastore v0.4.5/go.mod h1:eXTcaaiN6uOlVCLS9GjJUJtlvJfM3xk23w3fyfrmmJs= +github.com/ipfs/go-datastore v0.5.0/go.mod h1:9zhEApYMTl17C8YDp7JmU7sQZi2/wqiYh73hakZ90Bk= +github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0Myk= +github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8= +github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk= +github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps= +github.com/ipfs/go-ds-badger v0.0.2/go.mod h1:Y3QpeSFWQf6MopLTiZD+VT6IC1yZqaGmjvRcKeSGij8= +github.com/ipfs/go-ds-badger v0.0.5/go.mod h1:g5AuuCGmr7efyzQhLL8MzwqcauPojGPUaHzfGTzuE3s= +github.com/ipfs/go-ds-badger v0.2.1/go.mod h1:Tx7l3aTph3FMFrRS838dcSJh+jjA7cX9DrGVwx/NOwE= +github.com/ipfs/go-ds-badger v0.2.3/go.mod h1:pEYw0rgg3FIrywKKnL+Snr+w/LjJZVMTBRn4FS6UHUk= +github.com/ipfs/go-ds-leveldb v0.0.1/go.mod h1:feO8V3kubwsEF22n0YRQCffeb79OOYIykR4L04tMOYc= +github.com/ipfs/go-ds-leveldb v0.4.1/go.mod h1:jpbku/YqBSsBc1qgME8BkWS4AxzF2cEu1Ii2r79Hh9s= +github.com/ipfs/go-ds-leveldb v0.4.2/go.mod h1:jpbku/YqBSsBc1qgME8BkWS4AxzF2cEu1Ii2r79Hh9s= +github.com/ipfs/go-fetcher v1.6.1 h1:UFuRVYX5AIllTiRhi5uK/iZkfhSpBCGX7L70nSZEmK8= +github.com/ipfs/go-fetcher v1.6.1/go.mod h1:27d/xMV8bodjVs9pugh/RCjjK2OZ68UgAMspMdingNo= +github.com/ipfs/go-ipfs-blockstore v0.0.1/go.mod h1:d3WClOmRQKFnJ0Jz/jj/zmksX0ma1gROTlovZKBmN08= +github.com/ipfs/go-ipfs-blockstore v0.1.0/go.mod h1:5aD0AvHPi7mZc6Ci1WCAhiBQu2IsfTduLl+422H6Rqw= +github.com/ipfs/go-ipfs-blockstore v0.2.1/go.mod h1:jGesd8EtCM3/zPgx+qr0/feTXGUeRai6adgwC+Q+JvE= +github.com/ipfs/go-ipfs-blockstore v1.2.0 h1:n3WTeJ4LdICWs/0VSfjHrlqpPpl6MZ+ySd3j8qz0ykw= +github.com/ipfs/go-ipfs-blockstore v1.2.0/go.mod h1:eh8eTFLiINYNSNawfZOC7HOxNTxpB1PFuA5E1m/7exE= +github.com/ipfs/go-ipfs-blocksutil v0.0.1 h1:Eh/H4pc1hsvhzsQoMEP3Bke/aW5P5rVM1IWFJMcGIPQ= +github.com/ipfs/go-ipfs-blocksutil v0.0.1/go.mod h1:Yq4M86uIOmxmGPUHv/uI7uKqZNtLb449gwKqXjIsnRk= +github.com/ipfs/go-ipfs-chunker v0.0.1 h1:cHUUxKFQ99pozdahi+uSC/3Y6HeRpi9oTeUHbE27SEw= +github.com/ipfs/go-ipfs-chunker v0.0.1/go.mod h1:tWewYK0we3+rMbOh7pPFGDyypCtvGcBFymgY4rSDLAw= +github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= +github.com/ipfs/go-ipfs-delay v0.0.1 h1:r/UXYyRcddO6thwOnhiznIAiSvxMECGgtv35Xs1IeRQ= +github.com/ipfs/go-ipfs-delay v0.0.1/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw= +github.com/ipfs/go-ipfs-ds-help v0.0.1/go.mod h1:gtP9xRaZXqIQRh1HRpp595KbBEdgqWFxefeVKOV8sxo= +github.com/ipfs/go-ipfs-ds-help v0.1.1/go.mod h1:SbBafGJuGsPI/QL3j9Fc5YPLeAu+SzOkI0gFwAg+mOs= +github.com/ipfs/go-ipfs-ds-help v1.1.0 h1:yLE2w9RAsl31LtfMt91tRZcrx+e61O5mDxFRR994w4Q= +github.com/ipfs/go-ipfs-ds-help v1.1.0/go.mod h1:YR5+6EaebOhfcqVCyqemItCLthrpVNot+rsOU/5IatU= +github.com/ipfs/go-ipfs-exchange-interface v0.0.1/go.mod h1:c8MwfHjtQjPoDyiy9cFquVtVHkO9b9Ob3FG91qJnWCM= +github.com/ipfs/go-ipfs-exchange-interface v0.1.0/go.mod h1:ych7WPlyHqFvCi/uQI48zLZuAWVP5iTQPXEfVaw5WEI= +github.com/ipfs/go-ipfs-exchange-interface v0.2.0 h1:8lMSJmKogZYNo2jjhUs0izT+dck05pqUw4mWNW9Pw6Y= +github.com/ipfs/go-ipfs-exchange-interface v0.2.0/go.mod h1:z6+RhJuDQbqKguVyslSOuVDhqF9JtTrO3eptSAiW2/Y= +github.com/ipfs/go-ipfs-exchange-offline v0.0.1/go.mod h1:WhHSFCVYX36H/anEKQboAzpUws3x7UeEGkzQc3iNkM0= +github.com/ipfs/go-ipfs-exchange-offline v0.1.1/go.mod h1:vTiBRIbzSwDD0OWm+i3xeT0mO7jG2cbJYatp3HPk5XY= +github.com/ipfs/go-ipfs-exchange-offline v0.3.0 h1:c/Dg8GDPzixGd0MC8Jh6mjOwU57uYokgWRFidfvEkuA= +github.com/ipfs/go-ipfs-files v0.0.3/go.mod h1:INEFm0LL2LWXBhNJ2PMIIb2w45hpXgPjNoE7yA8Y1d4= +github.com/ipfs/go-ipfs-files v0.0.8 h1:8o0oFJkJ8UkO/ABl8T6ac6tKF3+NIpj67aAB6ZpusRg= +github.com/ipfs/go-ipfs-files v0.0.8/go.mod h1:wiN/jSG8FKyk7N0WyctKSvq3ljIa2NNTiZB55kpTdOs= +github.com/ipfs/go-ipfs-posinfo v0.0.1 h1:Esoxj+1JgSjX0+ylc0hUmJCOv6V2vFoZiETLR6OtpRs= +github.com/ipfs/go-ipfs-posinfo v0.0.1/go.mod h1:SwyeVP+jCwiDu0C313l/8jg6ZxM0qqtlt2a0vILTc1A= +github.com/ipfs/go-ipfs-pq v0.0.1/go.mod h1:LWIqQpqfRG3fNc5XsnIhz/wQ2XXGyugQwls7BgUmUfY= +github.com/ipfs/go-ipfs-pq v0.0.2 h1:e1vOOW6MuOwG2lqxcLA+wEn93i/9laCY8sXAw76jFOY= +github.com/ipfs/go-ipfs-pq v0.0.2/go.mod h1:LWIqQpqfRG3fNc5XsnIhz/wQ2XXGyugQwls7BgUmUfY= +github.com/ipfs/go-ipfs-redirects-file v0.1.1 h1:Io++k0Vf/wK+tfnhEh63Yte1oQK5VGT2hIEYpD0Rzx8= +github.com/ipfs/go-ipfs-redirects-file v0.1.1/go.mod h1:tAwRjCV0RjLTjH8DR/AU7VYvfQECg+lpUy2Mdzv7gyk= +github.com/ipfs/go-ipfs-routing v0.1.0/go.mod h1:hYoUkJLyAUKhF58tysKpids8RNDPO42BVMgK5dNsoqY= +github.com/ipfs/go-ipfs-routing v0.2.1/go.mod h1:xiNNiwgjmLqPS1cimvAw6EyB9rkVDbiocA4yY+wRNLM= +github.com/ipfs/go-ipfs-routing v0.3.0 h1:9W/W3N+g+y4ZDeffSgqhgo7BsBSJwPMcyssET9OWevc= +github.com/ipfs/go-ipfs-util v0.0.1/go.mod h1:spsl5z8KUnrve+73pOhSVZND1SIxPW5RyBCNzQxlJBc= github.com/ipfs/go-ipfs-util v0.0.2 h1:59Sswnk1MFaiq+VcaknX7aYEyGyGDAA73ilhEK2POp8= github.com/ipfs/go-ipfs-util v0.0.2/go.mod h1:CbPtkWJzjLdEcezDns2XYaehFVNXG9zrdrtMecczcsQ= +github.com/ipfs/go-ipld-cbor v0.0.2/go.mod h1:wTBtrQZA3SoFKMVkp6cn6HMRteIB1VsmHA0AQFOn7Nc= +github.com/ipfs/go-ipld-cbor v0.0.3/go.mod h1:wTBtrQZA3SoFKMVkp6cn6HMRteIB1VsmHA0AQFOn7Nc= +github.com/ipfs/go-ipld-cbor v0.0.5/go.mod h1:BkCduEx3XBCO6t2Sfo5BaHzuok7hbhdMm9Oh8B2Ftq4= +github.com/ipfs/go-ipld-cbor v0.0.6 h1:pYuWHyvSpIsOOLw4Jy7NbBkCyzLDcl64Bf/LZW7eBQ0= +github.com/ipfs/go-ipld-cbor v0.0.6/go.mod h1:ssdxxaLJPXH7OjF5V4NSjBbcfh+evoR4ukuru0oPXMA= +github.com/ipfs/go-ipld-format v0.0.1/go.mod h1:kyJtbkDALmFHv3QR6et67i35QzO3S0dCDnkOJhcZkms= +github.com/ipfs/go-ipld-format v0.0.2/go.mod h1:4B6+FM2u9OJ9zCV+kSbgFAZlOrv1Hqbf0INGQgiKf9k= +github.com/ipfs/go-ipld-format v0.2.0/go.mod h1:3l3C1uKoadTPbeNfrDi+xMInYKlx2Cvg1BuydPSdzQs= +github.com/ipfs/go-ipld-format v0.3.0/go.mod h1:co/SdBE8h99968X0hViiw1MNlh6fvxxnHpvVLnH7jSM= +github.com/ipfs/go-ipld-format v0.4.0 h1:yqJSaJftjmjc9jEOFYlpkwOLVKv68OD27jFLlSghBlQ= +github.com/ipfs/go-ipld-format v0.4.0/go.mod h1:co/SdBE8h99968X0hViiw1MNlh6fvxxnHpvVLnH7jSM= +github.com/ipfs/go-ipld-legacy v0.1.0/go.mod h1:86f5P/srAmh9GcIcWQR9lfFLZPrIyyXQeVlOWeeWEuI= +github.com/ipfs/go-ipld-legacy v0.1.1 h1:BvD8PEuqwBHLTKqlGFTHSwrwFOMkVESEvwIYwR2cdcc= +github.com/ipfs/go-ipld-legacy v0.1.1/go.mod h1:8AyKFCjgRPsQFf15ZQgDB8Din4DML/fOmKZkkFkrIEg= github.com/ipfs/go-ipns v0.3.0 h1:ai791nTgVo+zTuq2bLvEGmWP1M0A6kGTXUsgv/Yq67A= github.com/ipfs/go-ipns v0.3.0/go.mod h1:3cLT2rbvgPZGkHJoPO1YMJeh6LtkxopCkKFcio/wE24= +github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM= +github.com/ipfs/go-log v1.0.2/go.mod h1:1MNjMxe0u6xvJZgeqbJ8vdo2TKaGwZ1a0Bpza+sr2Sk= +github.com/ipfs/go-log v1.0.3/go.mod h1:OsLySYkwIbiSUR/yBTdv1qPtcE4FW3WPWk/ewz9Ru+A= +github.com/ipfs/go-log v1.0.4/go.mod h1:oDCg2FkjogeFOhqqb+N39l2RpTNPL6F/StPkB3kPgcs= +github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= +github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= +github.com/ipfs/go-log/v2 v2.0.2/go.mod h1:O7P1lJt27vWHhOwQmcFEvlmo49ry2VY2+JfBWFaa9+0= +github.com/ipfs/go-log/v2 v2.0.3/go.mod h1:O7P1lJt27vWHhOwQmcFEvlmo49ry2VY2+JfBWFaa9+0= +github.com/ipfs/go-log/v2 v2.0.5/go.mod h1:eZs4Xt4ZUJQFM3DlanGhy7TkwwawCZcSByscwkWG+dw= +github.com/ipfs/go-log/v2 v2.1.1/go.mod h1:2v2nsGfZsvvAJz13SyFzf9ObaqwHiHxsPLEHntrv9KM= +github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= +github.com/ipfs/go-log/v2 v2.3.0/go.mod h1:QqGoj30OTpnKaG/LKTGTxoP2mmQtjVMEnK72gynbe/g= github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= -github.com/ipld/go-ipld-prime v0.9.0 h1:N2OjJMb+fhyFPwPnVvJcWU/NsumP8etal+d2v3G4eww= -github.com/ipld/go-ipld-prime v0.9.0/go.mod h1:KvBLMr4PX1gWptgkzRjVZCrLmSGcZCb/jioOQwCqZN8= +github.com/ipfs/go-merkledag v0.2.3/go.mod h1:SQiXrtSts3KGNmgOzMICy5c0POOpUNQLvB3ClKnBAlk= +github.com/ipfs/go-merkledag v0.3.2/go.mod h1:fvkZNNZixVW6cKSZ/JfLlON5OlgTXNdRLz0p6QG/I2M= +github.com/ipfs/go-merkledag v0.5.1/go.mod h1:cLMZXx8J08idkp5+id62iVftUQV+HlYJ3PIhDfZsjA4= +github.com/ipfs/go-merkledag v0.9.0 h1:DFC8qZ96Dz1hMT7dtIpcY524eFFDiEWAF8hNJHWW2pk= +github.com/ipfs/go-merkledag v0.9.0/go.mod h1:bPHqkHt5OZ0p1n3iqPeDiw2jIBkjAytRjS3WSBwjq90= +github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= +github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= +github.com/ipfs/go-mfs v0.2.1 h1:5jz8+ukAg/z6jTkollzxGzhkl3yxm022Za9f2nL5ab8= +github.com/ipfs/go-mfs v0.2.1/go.mod h1:Woj80iuw4ajDnIP6+seRaoHpPsc9hmL0pk/nDNDWP88= +github.com/ipfs/go-path v0.2.1/go.mod h1:NOScsVgxfC/eIw4nz6OiGwK42PjaSJ4Y/ZFPn1Xe07I= +github.com/ipfs/go-path v0.3.0 h1:tkjga3MtpXyM5v+3EbRvOHEoo+frwi4oumw5K+KYWyA= +github.com/ipfs/go-path v0.3.0/go.mod h1:NOScsVgxfC/eIw4nz6OiGwK42PjaSJ4Y/ZFPn1Xe07I= +github.com/ipfs/go-peertaskqueue v0.1.0/go.mod h1:Jmk3IyCcfl1W3jTW3YpghSwSEC6IJ3Vzz/jUmWw8Z0U= +github.com/ipfs/go-peertaskqueue v0.7.0/go.mod h1:M/akTIE/z1jGNXMU7kFB4TeSEFvj68ow0Rrb04donIU= +github.com/ipfs/go-peertaskqueue v0.8.0 h1:JyNO144tfu9bx6Hpo119zvbEL9iQ760FHOiJYsUjqaU= +github.com/ipfs/go-unixfs v0.2.4/go.mod h1:SUdisfUjNoSDzzhGVxvCL9QO/nKdwXdr+gbMUdqcbYw= +github.com/ipfs/go-unixfs v0.3.1 h1:LrfED0OGfG98ZEegO4/xiprx2O+yS+krCMQSp7zLVv8= +github.com/ipfs/go-unixfs v0.3.1/go.mod h1:h4qfQYzghiIc8ZNFKiLMFWOTzrWIAtzYQ59W/pCFf1o= +github.com/ipfs/go-unixfsnode v1.1.2 h1:aTsCdhwU0F4dMShMwYGroAj4v4EzSONLdoENebvTRb0= +github.com/ipfs/go-unixfsnode v1.1.2/go.mod h1:5dcE2x03pyjHk4JjamXmunTMzz+VUtqvPwZjIEkfV6s= +github.com/ipfs/go-verifcid v0.0.1/go.mod h1:5Hrva5KBeIog4A+UpqlaIU+DEstipcJYQQZc0g37pY0= +github.com/ipfs/go-verifcid v0.0.2 h1:XPnUv0XmdH+ZIhLGKg6U2vaPaRDXb9urMyNVCE7uvTs= +github.com/ipfs/go-verifcid v0.0.2/go.mod h1:40cD9x1y4OWnFXbLNJYRe7MpNvWlMn3LZAG5Wb4xnPU= +github.com/ipfs/interface-go-ipfs-core v0.10.0 h1:b/psL1oqJcySdQAsIBfW5ZJJkOAsYlhWtC0/Qvr4WiM= +github.com/ipfs/interface-go-ipfs-core v0.10.0/go.mod h1:F3EcmDy53GFkF0H3iEJpfJC320fZ/4G60eftnItrrJ0= +github.com/ipld/go-car v0.5.0 h1:kcCEa3CvYMs0iE5BzD5sV7O2EwMiCIp3uF8tA6APQT8= +github.com/ipld/go-car v0.5.0/go.mod h1:ppiN5GWpjOZU9PgpAZ9HbZd9ZgSpwPMr48fGRJOWmvE= +github.com/ipld/go-codec-dagpb v1.3.0/go.mod h1:ga4JTU3abYApDC3pZ00BC2RSvC3qfBb9MSJkMLSwnhA= +github.com/ipld/go-codec-dagpb v1.5.0 h1:RspDRdsJpLfgCI0ONhTAnbHdySGD4t+LHSPK4X1+R0k= +github.com/ipld/go-codec-dagpb v1.5.0/go.mod h1:0yRIutEFD8o1DGVqw4RSHh+BUTlJA9XWldxaaWR/o4g= +github.com/ipld/go-ipld-prime v0.9.1-0.20210324083106-dc342a9917db/go.mod h1:KvBLMr4PX1gWptgkzRjVZCrLmSGcZCb/jioOQwCqZN8= +github.com/ipld/go-ipld-prime v0.11.0/go.mod h1:+WIAkokurHmZ/KwzDOMUuoeJgaRQktHtEaLglS3ZeV8= +github.com/ipld/go-ipld-prime v0.19.0 h1:5axC7rJmPc17Emw6TelxGwnzALk0PdupZ2oj2roDj04= +github.com/ipld/go-ipld-prime v0.19.0/go.mod h1:Q9j3BaVXwaA3o5JUDNvptDDr/x8+F7FG6XJ8WI3ILg4= +github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA= +github.com/jackpal/go-nat-pmp v1.0.1/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/jbenet/go-cienv v0.0.0-20150120210510-1bb1476777ec/go.mod h1:rGaEvXB4uRSZMmzKNLoXvTu1sfx+1kv/DojUlPrSZGs= +github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= +github.com/jbenet/go-temp-err-catcher v0.0.0-20150120210811-aac704a3f4f2/go.mod h1:8GXXJV31xl8whumTzdZsTt3RnUIiPqzkyf7mxToRCMs= +github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk= +github.com/jbenet/goprocess v0.0.0-20160826012719-b497e2f366b8/go.mod h1:Ly/wlsjFq/qrU3Rar62tu1gASgGw6chQbSh/XgIIXCY= +github.com/jbenet/goprocess v0.1.3/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= +github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o= +github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= +github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= +github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/kami-zh/go-capturer v0.0.0-20171211120116-e492ea43421d/go.mod h1:P2viExyCEfeWGU259JnaQ34Inuec4R38JCyBx2edgD0= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +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/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.1.1 h1:t0wUqjowdm8ezddV5k0tLWVklVuvLJpoHeb4WBdydm0= -github.com/klauspost/cpuid/v2 v2.1.1/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/klauspost/cpuid/v2 v2.1.2 h1:XhdX4fqAJUA0yj+kUwMavO0hHrSPAecYdYf1ZmxHvak= +github.com/klauspost/cpuid/v2 v2.1.2/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/koron/go-ssdp v0.0.0-20180514024734-4a0ed625a78b/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk= +github.com/koron/go-ssdp v0.0.0-20191105050749-2e1c40ed0b5d/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk= +github.com/koron/go-ssdp v0.0.3 h1:JivLMY45N76b4p/vsWGOKewBQu6uf39y8l+AQ7sDKx8= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/libp2p/go-addr-util v0.0.1/go.mod h1:4ac6O7n9rIAKB1dnd+s8IbbMXkt+oBpzX4/+RACcnlQ= +github.com/libp2p/go-addr-util v0.0.2/go.mod h1:Ecd6Fb3yIuLzq4bD7VcywcVSBtefcAwnUISBM3WG15E= +github.com/libp2p/go-buffer-pool v0.0.1/go.mod h1:xtyIz9PMobb13WaxR6Zo1Pd1zXJKYg0a8KiIvDp3TzQ= +github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= +github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38yPW7c= +github.com/libp2p/go-conn-security-multistream v0.1.0/go.mod h1:aw6eD7LOsHEX7+2hJkDxw1MteijaVcI+/eP2/x3J1xc= +github.com/libp2p/go-conn-security-multistream v0.2.0/go.mod h1:hZN4MjlNetKD3Rq5Jb/P5ohUnFLNzEAR4DLSzpn2QLU= +github.com/libp2p/go-conn-security-multistream v0.2.1/go.mod h1:cR1d8gA0Hr59Fj6NhaTpFhJZrjSYuNmhpT2r25zYR70= +github.com/libp2p/go-eventbus v0.1.0/go.mod h1:vROgu5cs5T7cv7POWlWxBaVLxfSegC5UGQf8A2eEmx4= +github.com/libp2p/go-eventbus v0.2.1/go.mod h1:jc2S4SoEVPP48H9Wpzm5aiGwUCBMfGhVhhBjyhhCJs8= +github.com/libp2p/go-flow-metrics v0.0.1/go.mod h1:Iv1GH0sG8DtYN3SVJ2eG221wMiNpZxBdp967ls1g+k8= +github.com/libp2p/go-flow-metrics v0.0.3/go.mod h1:HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs= +github.com/libp2p/go-libp2p v0.1.0/go.mod h1:6D/2OBauqLUoqcADOJpn9WbKqvaM07tDw68qHM0BxUM= +github.com/libp2p/go-libp2p v0.1.1/go.mod h1:I00BRo1UuUSdpuc8Q2mN7yDF/oTUTRAX6JWpTiK9Rp8= +github.com/libp2p/go-libp2p v0.6.1/go.mod h1:CTFnWXogryAHjXAKEbOf1OWY+VeAP3lDMZkfEI5sT54= +github.com/libp2p/go-libp2p v0.7.0/go.mod h1:hZJf8txWeCduQRDC/WSqBGMxaTHCOYHt2xSU1ivxn0k= +github.com/libp2p/go-libp2p v0.7.4/go.mod h1:oXsBlTLF1q7pxr+9w6lqzS1ILpyHsaBPniVO7zIHGMw= +github.com/libp2p/go-libp2p v0.8.1/go.mod h1:QRNH9pwdbEBpx5DTJYg+qxcVaDMAz3Ee/qDKwXujH5o= +github.com/libp2p/go-libp2p v0.14.3/go.mod h1:d12V4PdKbpL0T1/gsUNN8DfgMuRPDX8bS2QxCZlwRH0= github.com/libp2p/go-libp2p v0.23.4 h1:hWi9XHSOVFR1oDWRk7rigfyA4XNMuYL20INNybP9LP8= github.com/libp2p/go-libp2p v0.23.4/go.mod h1:s9DEa5NLR4g+LZS+md5uGU4emjMWFiqkZr6hBTY8UxI= +github.com/libp2p/go-libp2p-asn-util v0.2.0 h1:rg3+Os8jbnO5DxkC7K/Utdi+DkY3q/d1/1q+8WeNAsw= +github.com/libp2p/go-libp2p-autonat v0.1.0/go.mod h1:1tLf2yXxiE/oKGtDwPYWTSYG3PtvYlJmg7NeVtPRqH8= +github.com/libp2p/go-libp2p-autonat v0.1.1/go.mod h1:OXqkeGOY2xJVWKAGV2inNF5aKN/djNA3fdpCWloIudE= +github.com/libp2p/go-libp2p-autonat v0.2.0/go.mod h1:DX+9teU4pEEoZUqR1PiMlqliONQdNbfzE1C718tcViI= +github.com/libp2p/go-libp2p-autonat v0.2.1/go.mod h1:MWtAhV5Ko1l6QBsHQNSuM6b1sRkXrpk0/LqCr+vCVxI= +github.com/libp2p/go-libp2p-autonat v0.2.2/go.mod h1:HsM62HkqZmHR2k1xgX34WuWDzk/nBwNHoeyyT4IWV6A= +github.com/libp2p/go-libp2p-autonat v0.4.2/go.mod h1:YxaJlpr81FhdOv3W3BTconZPfhaYivRdf53g+S2wobk= +github.com/libp2p/go-libp2p-blankhost v0.1.1/go.mod h1:pf2fvdLJPsC1FsVrNP3DUUvMzUts2dsLLBEpo1vW1ro= +github.com/libp2p/go-libp2p-blankhost v0.1.4/go.mod h1:oJF0saYsAXQCSfDq254GMNmLNz6ZTHTOvtF4ZydUvwU= +github.com/libp2p/go-libp2p-blankhost v0.2.0/go.mod h1:eduNKXGTioTuQAUcZ5epXi9vMl+t4d8ugUBRQ4SqaNQ= +github.com/libp2p/go-libp2p-circuit v0.1.0/go.mod h1:Ahq4cY3V9VJcHcn1SBXjr78AbFkZeIRmfunbA7pmFh8= +github.com/libp2p/go-libp2p-circuit v0.1.4/go.mod h1:CY67BrEjKNDhdTk8UgBX1Y/H5c3xkAcs3gnksxY7osU= +github.com/libp2p/go-libp2p-circuit v0.2.1/go.mod h1:BXPwYDN5A8z4OEY9sOfr2DUQMLQvKt/6oku45YUmjIo= +github.com/libp2p/go-libp2p-circuit v0.4.0/go.mod h1:t/ktoFIUzM6uLQ+o1G6NuBl2ANhBKN9Bc8jRIk31MoA= +github.com/libp2p/go-libp2p-core v0.0.1/go.mod h1:g/VxnTZ/1ygHxH3dKok7Vno1VfpvGcGip57wjTU4fco= +github.com/libp2p/go-libp2p-core v0.0.2/go.mod h1:9dAcntw/n46XycV4RnlBq3BpgrmyUi9LuoTNdPrbUco= +github.com/libp2p/go-libp2p-core v0.0.3/go.mod h1:j+YQMNz9WNSkNezXOsahp9kwZBKBvxLpKD316QWSJXE= +github.com/libp2p/go-libp2p-core v0.0.4/go.mod h1:jyuCQP356gzfCFtRKyvAbNkyeuxb7OlyhWZ3nls5d2I= +github.com/libp2p/go-libp2p-core v0.2.0/go.mod h1:X0eyB0Gy93v0DZtSYbEM7RnMChm9Uv3j7yRXjO77xSI= +github.com/libp2p/go-libp2p-core v0.2.2/go.mod h1:8fcwTbsG2B+lTgRJ1ICZtiM5GWCWZVoVrLaDRvIRng0= +github.com/libp2p/go-libp2p-core v0.2.4/go.mod h1:STh4fdfa5vDYr0/SzYYeqnt+E6KfEV5VxfIrm0bcI0g= +github.com/libp2p/go-libp2p-core v0.3.0/go.mod h1:ACp3DmS3/N64c2jDzcV429ukDpicbL6+TrrxANBjPGw= +github.com/libp2p/go-libp2p-core v0.3.1/go.mod h1:thvWy0hvaSBhnVBaW37BvzgVV68OUhgJJLAa6almrII= +github.com/libp2p/go-libp2p-core v0.4.0/go.mod h1:49XGI+kc38oGVwqSBhDEwytaAxgZasHhFfQKibzTls0= +github.com/libp2p/go-libp2p-core v0.5.0/go.mod h1:49XGI+kc38oGVwqSBhDEwytaAxgZasHhFfQKibzTls0= +github.com/libp2p/go-libp2p-core v0.5.1/go.mod h1:uN7L2D4EvPCvzSH5SrhR72UWbnSGpt5/a35Sm4upn4Y= +github.com/libp2p/go-libp2p-core v0.5.4/go.mod h1:uN7L2D4EvPCvzSH5SrhR72UWbnSGpt5/a35Sm4upn4Y= +github.com/libp2p/go-libp2p-core v0.5.5/go.mod h1:vj3awlOr9+GMZJFH9s4mpt9RHHgGqeHCopzbYKZdRjM= +github.com/libp2p/go-libp2p-core v0.5.6/go.mod h1:txwbVEhHEXikXn9gfC7/UDDw7rkxuX0bJvM49Ykaswo= +github.com/libp2p/go-libp2p-core v0.5.7/go.mod h1:txwbVEhHEXikXn9gfC7/UDDw7rkxuX0bJvM49Ykaswo= +github.com/libp2p/go-libp2p-core v0.6.0/go.mod h1:txwbVEhHEXikXn9gfC7/UDDw7rkxuX0bJvM49Ykaswo= +github.com/libp2p/go-libp2p-core v0.7.0/go.mod h1:FfewUH/YpvWbEB+ZY9AQRQ4TAD8sJBt/G1rVvhz5XT8= +github.com/libp2p/go-libp2p-core v0.8.0/go.mod h1:FfewUH/YpvWbEB+ZY9AQRQ4TAD8sJBt/G1rVvhz5XT8= +github.com/libp2p/go-libp2p-core v0.8.1/go.mod h1:FfewUH/YpvWbEB+ZY9AQRQ4TAD8sJBt/G1rVvhz5XT8= +github.com/libp2p/go-libp2p-core v0.8.2/go.mod h1:FfewUH/YpvWbEB+ZY9AQRQ4TAD8sJBt/G1rVvhz5XT8= +github.com/libp2p/go-libp2p-core v0.8.5/go.mod h1:FfewUH/YpvWbEB+ZY9AQRQ4TAD8sJBt/G1rVvhz5XT8= +github.com/libp2p/go-libp2p-crypto v0.1.0/go.mod h1:sPUokVISZiy+nNuTTH/TY+leRSxnFj/2GLjtOTW90hI= +github.com/libp2p/go-libp2p-discovery v0.1.0/go.mod h1:4F/x+aldVHjHDHuX85x1zWoFTGElt8HnoDzwkFZm29g= +github.com/libp2p/go-libp2p-discovery v0.2.0/go.mod h1:s4VGaxYMbw4+4+tsoQTqh7wfxg97AEdo4GYBt6BadWg= +github.com/libp2p/go-libp2p-discovery v0.3.0/go.mod h1:o03drFnz9BVAZdzC/QUQ+NeQOu38Fu7LJGEOK2gQltw= +github.com/libp2p/go-libp2p-discovery v0.5.0/go.mod h1:+srtPIU9gDaBNu//UHvcdliKBIcr4SfDcm0/PfPJLug= +github.com/libp2p/go-libp2p-loggables v0.1.0/go.mod h1:EyumB2Y6PrYjr55Q3/tiJ/o3xoDasoRYM7nOzEpoa90= +github.com/libp2p/go-libp2p-mplex v0.2.0/go.mod h1:Ejl9IyjvXJ0T9iqUTE1jpYATQ9NM3g+OtR+EMMODbKo= +github.com/libp2p/go-libp2p-mplex v0.2.1/go.mod h1:SC99Rxs8Vuzrf/6WhmH41kNn13TiYdAWNYHrwImKLnE= +github.com/libp2p/go-libp2p-mplex v0.2.2/go.mod h1:74S9eum0tVQdAfFiKxAyKzNdSuLqw5oadDq7+L/FELo= +github.com/libp2p/go-libp2p-mplex v0.2.3/go.mod h1:CK3p2+9qH9x+7ER/gWWDYJ3QW5ZxWDkm+dVvjfuG3ek= +github.com/libp2p/go-libp2p-mplex v0.4.0/go.mod h1:yCyWJE2sc6TBTnFpjvLuEJgTSw/u+MamvzILKdX7asw= +github.com/libp2p/go-libp2p-mplex v0.4.1/go.mod h1:cmy+3GfqfM1PceHTLL7zQzAAYaryDu6iPSC+CIb094g= +github.com/libp2p/go-libp2p-nat v0.0.4/go.mod h1:N9Js/zVtAXqaeT99cXgTV9e75KpnWCvVOiGzlcHmBbY= +github.com/libp2p/go-libp2p-nat v0.0.5/go.mod h1:1qubaE5bTZMJE+E/uu2URroMbzdubFz1ChgiN79yKPE= +github.com/libp2p/go-libp2p-nat v0.0.6/go.mod h1:iV59LVhB3IkFvS6S6sauVTSOrNEANnINbI/fkaLimiw= +github.com/libp2p/go-libp2p-netutil v0.1.0/go.mod h1:3Qv/aDqtMLTUyQeundkKsA+YCThNdbQD54k3TqjpbFU= +github.com/libp2p/go-libp2p-noise v0.2.0/go.mod h1:IEbYhBBzGyvdLBoxxULL/SGbJARhUeqlO8lVSREYu2Q= +github.com/libp2p/go-libp2p-peer v0.2.0/go.mod h1:RCffaCvUyW2CJmG2gAWVqwePwW7JMgxjsHm7+J5kjWY= +github.com/libp2p/go-libp2p-peerstore v0.1.0/go.mod h1:2CeHkQsr8svp4fZ+Oi9ykN1HBb6u0MOvdJ7YIsmcwtY= +github.com/libp2p/go-libp2p-peerstore v0.1.3/go.mod h1:BJ9sHlm59/80oSkpWgr1MyY1ciXAXV397W6h1GH/uKI= +github.com/libp2p/go-libp2p-peerstore v0.2.0/go.mod h1:N2l3eVIeAitSg3Pi2ipSrJYnqhVnMNQZo9nkSCuAbnQ= +github.com/libp2p/go-libp2p-peerstore v0.2.1/go.mod h1:NQxhNjWxf1d4w6PihR8btWIRjwRLBr4TYKfNgrUkOPA= +github.com/libp2p/go-libp2p-peerstore v0.2.2/go.mod h1:NQxhNjWxf1d4w6PihR8btWIRjwRLBr4TYKfNgrUkOPA= +github.com/libp2p/go-libp2p-peerstore v0.2.6/go.mod h1:ss/TWTgHZTMpsU/oKVVPQCGuDHItOpf2W8RxAi50P2s= +github.com/libp2p/go-libp2p-peerstore v0.2.7/go.mod h1:ss/TWTgHZTMpsU/oKVVPQCGuDHItOpf2W8RxAi50P2s= +github.com/libp2p/go-libp2p-pnet v0.2.0/go.mod h1:Qqvq6JH/oMZGwqs3N1Fqhv8NVhrdYcO0BW4wssv21LA= +github.com/libp2p/go-libp2p-quic-transport v0.10.0/go.mod h1:RfJbZ8IqXIhxBRm5hqUEJqjiiY8xmEuq3HUDS993MkA= +github.com/libp2p/go-libp2p-record v0.1.0/go.mod h1:ujNc8iuE5dlKWVy6wuL6dd58t0n7xI4hAIl8pE6wu5Q= 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-secio v0.1.0/go.mod h1:tMJo2w7h3+wN4pgU2LSYeiKPrfqBgkOsdiKK77hE7c8= +github.com/libp2p/go-libp2p-secio v0.2.0/go.mod h1:2JdZepB8J5V9mBp79BmwsaPQhRPNN2NrnB2lKQcdy6g= +github.com/libp2p/go-libp2p-secio v0.2.1/go.mod h1:cWtZpILJqkqrSkiYcDBh5lA3wbT2Q+hz3rJQq3iftD8= +github.com/libp2p/go-libp2p-secio v0.2.2/go.mod h1:wP3bS+m5AUnFA+OFO7Er03uO1mncHG0uVwGrwvjYlNY= +github.com/libp2p/go-libp2p-swarm v0.1.0/go.mod h1:wQVsCdjsuZoc730CgOvh5ox6K8evllckjebkdiY5ta4= +github.com/libp2p/go-libp2p-swarm v0.2.2/go.mod h1:fvmtQ0T1nErXym1/aa1uJEyN7JzaTNyBcHImCxRpPKU= +github.com/libp2p/go-libp2p-swarm v0.2.3/go.mod h1:P2VO/EpxRyDxtChXz/VPVXyTnszHvokHKRhfkEgFKNM= +github.com/libp2p/go-libp2p-swarm v0.2.8/go.mod h1:JQKMGSth4SMqonruY0a8yjlPVIkb0mdNSwckW7OYziM= +github.com/libp2p/go-libp2p-swarm v0.3.0/go.mod h1:hdv95GWCTmzkgeJpP+GK/9D9puJegb7H57B5hWQR5Kk= +github.com/libp2p/go-libp2p-swarm v0.5.0/go.mod h1:sU9i6BoHE0Ve5SKz3y9WfKrh8dUat6JknzUehFx8xW4= +github.com/libp2p/go-libp2p-testing v0.0.2/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= +github.com/libp2p/go-libp2p-testing v0.0.3/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= +github.com/libp2p/go-libp2p-testing v0.0.4/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E= +github.com/libp2p/go-libp2p-testing v0.1.0/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0= +github.com/libp2p/go-libp2p-testing v0.1.1/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0= +github.com/libp2p/go-libp2p-testing v0.1.2-0.20200422005655-8775583591d8/go.mod h1:Qy8sAncLKpwXtS2dSnDOP8ktexIAHKu+J+pnZOFZLTc= +github.com/libp2p/go-libp2p-testing v0.3.0/go.mod h1:efZkql4UZ7OVsEfaxNHZPzIehtsBXMrXnCfJIgDti5g= +github.com/libp2p/go-libp2p-testing v0.4.0/go.mod h1:Q+PFXYoiYFN5CAEG2w3gLPEzotlKsNSbKQ/lImlOWF0= +github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA= +github.com/libp2p/go-libp2p-tls v0.1.3/go.mod h1:wZfuewxOndz5RTnCAxFliGjvYSDA40sKitV4c50uI1M= +github.com/libp2p/go-libp2p-transport-upgrader v0.1.1/go.mod h1:IEtA6or8JUbsV07qPW4r01GnTenLW4oi3lOPbUMGJJA= +github.com/libp2p/go-libp2p-transport-upgrader v0.2.0/go.mod h1:mQcrHj4asu6ArfSoMuyojOdjx73Q47cYD7s5+gZOlns= +github.com/libp2p/go-libp2p-transport-upgrader v0.3.0/go.mod h1:i+SKzbRnvXdVbU3D1dwydnTmKRPXiAR/fyvi1dXuL4o= +github.com/libp2p/go-libp2p-transport-upgrader v0.4.2/go.mod h1:NR8ne1VwfreD5VIWIU62Agt/J18ekORFU/j1i2y8zvk= +github.com/libp2p/go-libp2p-yamux v0.2.0/go.mod h1:Db2gU+XfLpm6E4rG5uGCFX6uXA8MEXOxFcRoXUODaK8= +github.com/libp2p/go-libp2p-yamux v0.2.1/go.mod h1:1FBXiHDk1VyRM1C0aez2bCfHQ4vMZKkAQzZbkSQt5fI= +github.com/libp2p/go-libp2p-yamux v0.2.2/go.mod h1:lIohaR0pT6mOt0AZ0L2dFze9hds9Req3OfS+B+dv4qw= +github.com/libp2p/go-libp2p-yamux v0.2.5/go.mod h1:Zpgj6arbyQrmZ3wxSZxfBmbdnWtbZ48OpsfmQVTErwA= +github.com/libp2p/go-libp2p-yamux v0.2.7/go.mod h1:X28ENrBMU/nm4I3Nx4sZ4dgjZ6VhLEn0XhIoZ5viCwU= +github.com/libp2p/go-libp2p-yamux v0.2.8/go.mod h1:/t6tDqeuZf0INZMTgd0WxIRbtK2EzI2h7HbFm9eAKI4= +github.com/libp2p/go-libp2p-yamux v0.4.0/go.mod h1:+DWDjtFMzoAwYLVkNZftoucn7PelNoy5nm3tZ3/Zw30= +github.com/libp2p/go-libp2p-yamux v0.5.0/go.mod h1:AyR8k5EzyM2QN9Bbdg6X1SkVVuqLwTGf0L4DFq9g6po= +github.com/libp2p/go-libp2p-yamux v0.5.4/go.mod h1:tfrXbyaTqqSU654GTvK3ocnSZL3BuHoeTSqhcel1wsE= +github.com/libp2p/go-maddr-filter v0.0.4/go.mod h1:6eT12kSQMA9x2pvFQa+xesMKUBlj9VImZbj3B9FBH/Q= +github.com/libp2p/go-maddr-filter v0.0.5/go.mod h1:Jk+36PMfIqCJhAnaASRH83bdAvfDRp/w6ENFaC9bG+M= +github.com/libp2p/go-maddr-filter v0.1.0/go.mod h1:VzZhTXkMucEGGEOSKddrwGiOv0tUhgnKqNEmIAz/bPU= +github.com/libp2p/go-mplex v0.0.3/go.mod h1:pK5yMLmOoBR1pNCqDlA2GQrdAVTMkqFalaTWe7l4Yd0= +github.com/libp2p/go-mplex v0.1.0/go.mod h1:SXgmdki2kwCUlCCbfGLEgHjC4pFqhTp0ZoV6aiKgxDU= +github.com/libp2p/go-mplex v0.1.1/go.mod h1:Xgz2RDCi3co0LeZfgjm4OgUF15+sVR8SRcu3SFXI1lk= +github.com/libp2p/go-mplex v0.1.2/go.mod h1:Xgz2RDCi3co0LeZfgjm4OgUF15+sVR8SRcu3SFXI1lk= +github.com/libp2p/go-mplex v0.2.0/go.mod h1:0Oy/A9PQlwBytDRp4wSkFnzHYDKcpLot35JQ6msjvYQ= +github.com/libp2p/go-mplex v0.3.0/go.mod h1:0Oy/A9PQlwBytDRp4wSkFnzHYDKcpLot35JQ6msjvYQ= +github.com/libp2p/go-msgio v0.0.2/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ= +github.com/libp2p/go-msgio v0.0.3/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ= +github.com/libp2p/go-msgio v0.0.4/go.mod h1:63lBBgOTDKQL6EWazRMCwXsEeEeK9O2Cd+0+6OOuipQ= +github.com/libp2p/go-msgio v0.0.6/go.mod h1:4ecVB6d9f4BDSL5fqvPiC4A3KivjWn+Venn/1ALLMWA= +github.com/libp2p/go-msgio v0.2.0 h1:W6shmB+FeynDrUVl2dgFQvzfBZcXiyqY4VmpQLu9FqU= +github.com/libp2p/go-nat v0.0.3/go.mod h1:88nUEt0k0JD45Bk93NIwDqjlhiOwOoV36GchpcVc1yI= +github.com/libp2p/go-nat v0.0.4/go.mod h1:Nmw50VAvKuk38jUBcmNh6p9lUJLoODbJRvYAa/+KSDo= +github.com/libp2p/go-nat v0.0.5/go.mod h1:B7NxsVNPZmRLvMOwiEO1scOSyjA56zxYAGv1yQgRkEU= +github.com/libp2p/go-nat v0.1.0 h1:MfVsH6DLcpa04Xr+p8hmVRG4juse0s3J8HyNWYHffXg= +github.com/libp2p/go-netroute v0.1.2/go.mod h1:jZLDV+1PE8y5XxBySEBgbuVAXbhtuHSdmLPL2n9MKbk= +github.com/libp2p/go-netroute v0.1.3/go.mod h1:jZLDV+1PE8y5XxBySEBgbuVAXbhtuHSdmLPL2n9MKbk= +github.com/libp2p/go-netroute v0.1.5/go.mod h1:V1SR3AaECRkEQCoFFzYwVYWvYIEtlxx89+O3qcpCl4A= +github.com/libp2p/go-netroute v0.1.6/go.mod h1:AqhkMh0VuWmfgtxKPp3Oc1LdU5QSWS7wl0QLhSZqXxQ= +github.com/libp2p/go-netroute v0.2.0 h1:0FpsbsvuSnAhXFnCY0VLFbJOzaK0VnP0r1QT/o4nWRE= +github.com/libp2p/go-openssl v0.0.2/go.mod h1:v8Zw2ijCSWBQi8Pq5GAixw6DbFfa9u6VIYDXnvOXkc0= +github.com/libp2p/go-openssl v0.0.3/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc= +github.com/libp2p/go-openssl v0.0.4/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc= +github.com/libp2p/go-openssl v0.0.5/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc= +github.com/libp2p/go-openssl v0.0.7/go.mod h1:unDrJpgy3oFr+rqXsarWifmJuNnJR4chtO1HmaZjggc= github.com/libp2p/go-openssl v0.1.0 h1:LBkKEcUv6vtZIQLVTegAil8jbNpJErQ9AnT+bWV+Ooo= github.com/libp2p/go-openssl v0.1.0/go.mod h1:OiOxwPpL3n4xlenjx2h7AwSGaFSC/KZvf6gNdOBQMtc= +github.com/libp2p/go-reuseport v0.0.1/go.mod h1:jn6RmB1ufnQwl0Q1f+YxAj8isJgDCQzaaxIFYDhcYEA= +github.com/libp2p/go-reuseport v0.0.2/go.mod h1:SPD+5RwGC7rcnzngoYC86GjPzjSywuQyMVAheVBD9nQ= +github.com/libp2p/go-reuseport-transport v0.0.2/go.mod h1:YkbSDrvjUVDL6b8XqriyA20obEtsW9BLkuOUyQAOCbs= +github.com/libp2p/go-reuseport-transport v0.0.3/go.mod h1:Spv+MPft1exxARzP2Sruj2Wb5JSyHNncjf1Oi2dEbzM= +github.com/libp2p/go-reuseport-transport v0.0.4/go.mod h1:trPa7r/7TJK/d+0hdBLOCGvpQQVOU74OXbNCIMkufGw= +github.com/libp2p/go-sockaddr v0.0.2/go.mod h1:syPvOmNs24S3dFVGJA1/mrqdeijPxLV2Le3BRLKd68k= +github.com/libp2p/go-sockaddr v0.1.0/go.mod h1:syPvOmNs24S3dFVGJA1/mrqdeijPxLV2Le3BRLKd68k= +github.com/libp2p/go-sockaddr v0.1.1/go.mod h1:syPvOmNs24S3dFVGJA1/mrqdeijPxLV2Le3BRLKd68k= +github.com/libp2p/go-stream-muxer v0.0.1/go.mod h1:bAo8x7YkSpadMTbtTaxGVHWUQsR/l5MEaHbKaliuT14= +github.com/libp2p/go-stream-muxer-multistream v0.2.0/go.mod h1:j9eyPol/LLRqT+GPLSxvimPhNph4sfYfMoDPd7HkzIc= +github.com/libp2p/go-stream-muxer-multistream v0.3.0/go.mod h1:yDh8abSIzmZtqtOt64gFJUXEryejzNb0lisTt+fAMJA= +github.com/libp2p/go-tcp-transport v0.1.0/go.mod h1:oJ8I5VXryj493DEJ7OsBieu8fcg2nHGctwtInJVpipc= +github.com/libp2p/go-tcp-transport v0.1.1/go.mod h1:3HzGvLbx6etZjnFlERyakbaYPdfjg2pWP97dFZworkY= +github.com/libp2p/go-tcp-transport v0.2.0/go.mod h1:vX2U0CnWimU4h0SGSEsg++AzvBcroCGYw28kh94oLe0= +github.com/libp2p/go-tcp-transport v0.2.3/go.mod h1:9dvr03yqrPyYGIEN6Dy5UvdJZjyPFvl1S/igQ5QD1SU= +github.com/libp2p/go-testutil v0.1.0/go.mod h1:81b2n5HypcVyrCg/MJx4Wgfp/VHojytjVe/gLzZ2Ehc= +github.com/libp2p/go-ws-transport v0.1.0/go.mod h1:rjw1MG1LU9YDC6gzmwObkPd/Sqwhw7yT74kj3raBFuo= +github.com/libp2p/go-ws-transport v0.2.0/go.mod h1:9BHJz/4Q5A9ludYWKoGCFC5gUElzlHoKzu0yY9p/klM= +github.com/libp2p/go-ws-transport v0.3.0/go.mod h1:bpgTJmRZAvVHrgHybCVyqoBmyLQ1fiZuEaBYusP5zsk= +github.com/libp2p/go-ws-transport v0.4.0/go.mod h1:EcIEKqf/7GDjth6ksuS/6p7R49V4CBY6/E7R/iyhYUA= +github.com/libp2p/go-yamux v1.2.2/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= +github.com/libp2p/go-yamux v1.2.3/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= +github.com/libp2p/go-yamux v1.3.0/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= +github.com/libp2p/go-yamux v1.3.3/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= +github.com/libp2p/go-yamux v1.3.5/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= +github.com/libp2p/go-yamux v1.3.7/go.mod h1:fr7aVgmdNGJK+N1g+b6DW6VxzbRCjCOejR/hkmpooHE= +github.com/libp2p/go-yamux v1.4.0/go.mod h1:fr7aVgmdNGJK+N1g+b6DW6VxzbRCjCOejR/hkmpooHE= +github.com/libp2p/go-yamux v1.4.1/go.mod h1:fr7aVgmdNGJK+N1g+b6DW6VxzbRCjCOejR/hkmpooHE= +github.com/libp2p/go-yamux/v2 v2.2.0/go.mod h1:3So6P6TV6r75R9jiBpiIKgU/66lOarCZjqROGxzPpPQ= +github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= +github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= +github.com/lucas-clemente/quic-go v0.19.3/go.mod h1:ADXpNbTQjq1hIzCpB+y/k5iz4n4z4IwqoLb94Kh5Hu8= +github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= +github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/marten-seemann/qpack v0.2.1/go.mod h1:F7Gl5L1jIgN1D11ucXefiuJS9UMVP2opoCp2jDKb7wc= +github.com/marten-seemann/qtls v0.10.0/go.mod h1:UvMd1oaYDACI99/oZUYLzMCkBXQVT0aGm99sJhbT8hs= +github.com/marten-seemann/qtls-go1-15 v0.1.1/go.mod h1:GyFwywLKkRt+6mfU99csTEY1joMZz5vmB1WNZH3P81I= +github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd/go.mod h1:QuCEs1Nt24+FYQEqAAncTDPJIuGs+LxK1MCiFL25pMU= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0= github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc= +github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= +github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/miekg/dns v1.1.12/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/miekg/dns v1.1.28/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= +github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= +github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA= +github.com/mikioh/tcp v0.0.0-20190314235350-803a9b46060c/go.mod h1:0SQS9kMwD2VsyFEB++InYyBJroV/FRmBgcydeSUcJms= +github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b/go.mod h1:lxPUiZwKoFL8DUUmalo2yJJUCxbPKtm8OKfqr2/FTNU= +github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc/go.mod h1:cGKTAVKx4SxOuR/czcZ/E2RSJ3sfHs8FpHhQ5CWMf9s= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= +github.com/minio/sha256-simd v0.0.0-20190131020904-2d45a736cd16/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= +github.com/minio/sha256-simd v0.0.0-20190328051042-05b4dd3047e5/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= +github.com/minio/sha256-simd v0.1.0/go.mod h1:2FMWW+8GMoPweT6+pI63m9YE3Lmw4J71hV56Chs1E/U= github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= +github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= +github.com/mr-tron/base58 v1.1.1/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8= github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= @@ -98,145 +787,703 @@ github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aG github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4= github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM= +github.com/multiformats/go-multiaddr v0.0.1/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= +github.com/multiformats/go-multiaddr v0.0.2/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= +github.com/multiformats/go-multiaddr v0.0.4/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= +github.com/multiformats/go-multiaddr v0.1.0/go.mod h1:xKVEak1K9cS1VdmPZW3LSIb6lgmoS58qz/pzqmAxV44= +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.2.1/go.mod h1:s/Apk6IyxfvMjDafnhJgJ3/46z7tZ04iMk5wP4QMGGE= +github.com/multiformats/go-multiaddr v0.2.2/go.mod h1:NtfXiOtHvghW9KojvtySjH5y0u0xW5UouOmQQrn6a3Y= +github.com/multiformats/go-multiaddr v0.3.0/go.mod h1:dF9kph9wfJ+3VLAaeBqo9Of8x4fJxp6ggJGteB8HQTI= +github.com/multiformats/go-multiaddr v0.3.1/go.mod h1:uPbspcUPd5AfaP6ql3ujFY+QWzmBD8uLLL4bXW0XfGc= +github.com/multiformats/go-multiaddr v0.3.3/go.mod h1:lCKNGP1EQ1eZ35Za2wlqnabm9xQkib3fyB+nZXHLag0= github.com/multiformats/go-multiaddr v0.8.0 h1:aqjksEcqK+iD/Foe1RRFsGZh8+XFiGo7FgUCZlpv3LU= github.com/multiformats/go-multiaddr v0.8.0/go.mod h1:Fs50eBDWvZu+l3/9S6xAE7ZYj6yhxlvaVZjakWN7xRs= +github.com/multiformats/go-multiaddr-dns v0.0.1/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= +github.com/multiformats/go-multiaddr-dns v0.0.2/go.mod h1:9kWcqw/Pj6FwxAwW38n/9403szc57zJPs45fmnznu3Q= +github.com/multiformats/go-multiaddr-dns v0.2.0/go.mod h1:TJ5pr5bBO7Y1B18djPuRsVkduhQH2YqYSbxWJzYGdK0= +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.0.1/go.mod h1:aBYjqL4T/7j4Qx+R73XSv/8JsgnRFlf0w2KGLCmXl3Q= github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E= +github.com/multiformats/go-multiaddr-fmt v0.1.0/go.mod h1:hGtDIW4PU4BqJ50gW2quDuPVjyWNZxToGUh/HwTZYJo= +github.com/multiformats/go-multiaddr-net v0.0.1/go.mod h1:nw6HSxNmCIQH27XPGBuX+d1tnvM7ihcFwHMSstNAVUU= +github.com/multiformats/go-multiaddr-net v0.1.0/go.mod h1:5JNbcfBOP4dnhoZOv10JJVkJO0pCCEf8mTnipAo2UZQ= +github.com/multiformats/go-multiaddr-net v0.1.1/go.mod h1:5JNbcfBOP4dnhoZOv10JJVkJO0pCCEf8mTnipAo2UZQ= +github.com/multiformats/go-multiaddr-net v0.1.2/go.mod h1:QsWt3XK/3hwvNxZJp92iMQKME1qHfpYmyIjFVsSOY6Y= +github.com/multiformats/go-multiaddr-net v0.1.3/go.mod h1:ilNnaM9HbmVFqsb/qcNysjCu4PVONlrBZpHIrw/qQuA= +github.com/multiformats/go-multiaddr-net v0.1.4/go.mod h1:ilNnaM9HbmVFqsb/qcNysjCu4PVONlrBZpHIrw/qQuA= +github.com/multiformats/go-multiaddr-net v0.1.5/go.mod h1:ilNnaM9HbmVFqsb/qcNysjCu4PVONlrBZpHIrw/qQuA= +github.com/multiformats/go-multiaddr-net v0.2.0/go.mod h1:gGdH3UXny6U3cKKYCvpXI5rnK7YaOIEOPVDI9tsJbEA= github.com/multiformats/go-multibase v0.0.1/go.mod h1:bja2MqRZ3ggyXtZSEDKpl0uO/gviWFaSteVbWT51qgs= +github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc= github.com/multiformats/go-multibase v0.1.1 h1:3ASCDsuLX8+j4kx58qnJ4YFq/JWTJpCyDW27ztsVTOI= github.com/multiformats/go-multibase v0.1.1/go.mod h1:ZEjHE+IsUrgp5mhlEAYjMtZwK1k4haNkcaPg9aoe1a8= github.com/multiformats/go-multicodec v0.6.0 h1:KhH2kSuCARyuJraYMFxrNO3DqIaYhOdS039kbhgVwpE= github.com/multiformats/go-multicodec v0.6.0/go.mod h1:GUC8upxSBE4oG+q3kWZRw/+6yC1BqO550bjhWsJbZlw= +github.com/multiformats/go-multihash v0.0.1/go.mod h1:w/5tugSrLEbWqlcgJabL3oHFKTwfvkofsjW2Qa1ct4U= +github.com/multiformats/go-multihash v0.0.5/go.mod h1:lt/HCbqlQwlPBz7lv0sQCdtfcMtlJvakRUn/0Ual8po= +github.com/multiformats/go-multihash v0.0.8/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew= github.com/multiformats/go-multihash v0.0.10/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew= github.com/multiformats/go-multihash v0.0.13/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= +github.com/multiformats/go-multihash v0.0.14/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc= github.com/multiformats/go-multihash v0.0.15/go.mod h1:D6aZrWNLFTV/ynMpKsNtB40mJzmCl4jb1alC0OvHiHg= github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d16Vve9l108= github.com/multiformats/go-multihash v0.2.1/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc= +github.com/multiformats/go-multistream v0.1.0/go.mod h1:fJTiDfXJVmItycydCnNx4+wSzZ5NwG2FEVAI30fiovg= +github.com/multiformats/go-multistream v0.1.1/go.mod h1:KmHZ40hzVxiaiwlj3MEbYgK9JFk2/9UktWZAF54Du38= +github.com/multiformats/go-multistream v0.2.1/go.mod h1:5GZPQZbkWOLOn3J2y4Y99vVW7vOfsAflxARk3x14o6k= +github.com/multiformats/go-multistream v0.2.2/go.mod h1:UIcnm7Zuo8HKG+HkWgfQsGL+/MIEhyTqbODbIUwSXKs= +github.com/multiformats/go-multistream v0.3.3 h1:d5PZpjwRgVlbwfdTDjife7XszfZd8KYWfROYFlGcR8o= +github.com/multiformats/go-varint v0.0.1/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= +github.com/multiformats/go-varint v0.0.2/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= -github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY= github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +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/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= +github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= +github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= +github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= +github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +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/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= +github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= +github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= +github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= +github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= +github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= +github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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= +github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1 h1:CskT+S6Ay54OwxBGB0R3Rsx4Muto6UnEYTyKJbyRIAI= +github.com/polydawn/refmt v0.0.0-20190221155625-df39d6c2d992/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= +github.com/polydawn/refmt v0.0.0-20190408063855-01bf1e26dd14/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= +github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e h1:ZOcivgkkFRnjfoTcGsDq3UQYiBmekwLA+qg0OjyB/ls= +github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e/go.mod h1:uIp+gprXxxrWSjjklXD+mN4wed/tMfjMMmN/9+JsA9o= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.10.0/go.mod h1:WJM3cc3yu7XKBKa/I8WeZm+V3eltZnBwfENSU7mdogU= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.13.0 h1:b71QUfeo5M8gq2+evJdTPfZhYMAU0uKPkyPJ7TPsloU= +github.com/prometheus/client_golang v1.13.0/go.mod h1:vTeo+zgvILHsnnj/39Ou/1fPN5nJFOEMgftOUOmlvYQ= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.18.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= +github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= +github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= +github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samber/lo v1.36.0 h1:4LaOxH1mHnbDGhTVE0i1z8v/lWaQW8AIfOD3HU4mSaw= github.com/samber/lo v1.36.0/go.mod h1:HLeWcJRRyLKp3+/XBJvOrerCQn9mhdKMHyd7IRlgeQ8= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= +github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= +github.com/shurcooL/github_flavored_markdown v0.0.0-20181002035957-2122de532470/go.mod h1:2dOwnU2uBioM+SGy2aZoq1f/Sd1l9OkAeAUvjSyvgU0= +github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= +github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= +github.com/shurcooL/gofontwoff v0.0.0-20180329035133-29b52fc0a18d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw= +github.com/shurcooL/gopherjslib v0.0.0-20160914041154-feb6d3990c2c/go.mod h1:8d3azKNyqcHP1GaQE/c6dDgjkgSx2BZ4IoEi4F1reUI= +github.com/shurcooL/highlight_diff v0.0.0-20170515013008-09bb4053de1b/go.mod h1:ZpfEhSmds4ytuByIcDnOLkTHGUI6KNqRNPDLHDk+mUU= +github.com/shurcooL/highlight_go v0.0.0-20181028180052-98c3abbbae20/go.mod h1:UDKB5a1T23gOMUJrI+uSuH0VRDStOiUVSjBTRDVBVag= +github.com/shurcooL/home v0.0.0-20181020052607-80b7ffcb30f9/go.mod h1:+rgNQw2P9ARFAs37qieuu7ohDNQ3gds9msbT2yn85sg= +github.com/shurcooL/htmlg v0.0.0-20170918183704-d01228ac9e50/go.mod h1:zPn1wHpTIePGnXSHpsVPWEktKXHr6+SS6x/IKRb7cpw= +github.com/shurcooL/httperror v0.0.0-20170206035902-86b7830d14cc/go.mod h1:aYMfkZ6DWSJPJ6c4Wwz3QtW22G7mf/PEgaB9k/ik5+Y= +github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= +github.com/shurcooL/httpgzip v0.0.0-20180522190206-b1c53ac65af9/go.mod h1:919LwcH0M7/W4fcZ0/jy0qGght1GIhqyS/EgWGH2j5Q= +github.com/shurcooL/issues v0.0.0-20181008053335-6292fdc1e191/go.mod h1:e2qWDig5bLteJ4fwvDAc2NHzqFEthkqn7aOZAOpj+PQ= +github.com/shurcooL/issuesapp v0.0.0-20180602232740-048589ce2241/go.mod h1:NPpHK2TI7iSaM0buivtFUc9offApnI0Alt/K8hcHy0I= +github.com/shurcooL/notifications v0.0.0-20181007000457-627ab5aea122/go.mod h1:b5uSkrEVM1jQUspwbixRBhaIjIzL2xazXp6kntxYle0= +github.com/shurcooL/octicon v0.0.0-20181028054416-fa4f57f9efb2/go.mod h1:eWdoE5JD4R5UVWDucdOPg1g2fqQRq78IQa9zlOV1vpQ= +github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1lToEk4d2s07G3XGfz2QrgHXg4RJBvjrOozvoWfk= +github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= +github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v1.0.0 h1:UVQPSSmc3qtTi+zPPkCXvZX9VvW/xT/NsRvKfwY81a8= +github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= +github.com/smartystreets/goconvey v0.0.0-20190222223459-a17d461953aa/go.mod h1:2RVY1rIf+2J2o/IM9+vPq9RzmHDSseB7FoXiSNIUsoU= +github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/smola/gocompat v0.2.0/go.mod h1:1B0MlxbmoZNo3h8guHp8HztB3BSYR5itql9qtVc0ypY= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= +github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= +github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= +github.com/spacemonkeygo/openssl v0.0.0-20181017203307-c2dcc5cca94a/go.mod h1:7AyxJNCJ7SBZ1MfVQCWD6Uqo2oubI2Eq2y2eqf+A5r0= github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 h1:RC6RW7j+1+HkWaX/Yh71Ee5ZHaHYt7ZP4sQgUrm6cDU= github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/src-d/envconfig v1.0.0/go.mod h1:Q9YQZ7BKITldTBnoxsE5gOeB5y66RyPXeue/R4aaNBc= +github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/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 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +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.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= 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 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= +github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M= +github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk= +github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb h1:Ywfo8sUltxogBpFuMOFRrrSifO788kAFxmvVw31PtQQ= +github.com/ucarion/urlpath v0.0.0-20200424170820-7ccc79b76bbb/go.mod h1:ikPs9bRWicNw3S7XpJ8sK/smGwU9WcSVU3dy9qahYBM= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= +github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= +github.com/warpfork/go-testmark v0.10.0 h1:E86YlUMYfwIacEsQGlnTvjk1IgYkyTGjPhF0RnwTCmw= +github.com/warpfork/go-wish v0.0.0-20180510122957-5ad1f5abf436/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= +github.com/warpfork/go-wish v0.0.0-20190328234359-8b3e70f8e830/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a h1:G++j5e0OC488te356JvdhaM8YS6nMsjLAYF7JxCv07w= github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= +github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI= +github.com/whyrusleeping/cbor-gen v0.0.0-20221220214510-0333c149dec0 h1:obKzQ1ey5AJg5NKjgtTo/CKwLImVP4ETLRcsmzFJ4Qw= +github.com/whyrusleeping/cbor-gen v0.0.0-20221220214510-0333c149dec0/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= +github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= +github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= +github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1/go.mod h1:8UvriyWtv5Q5EOgjHaSseUEdkQfvwFv1I/In/O2M9gc= +github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc/go.mod h1:bopw91TMyo8J3tvftk8xmU2kPmlrt4nScJQZU2hE5EM= +github.com/whyrusleeping/go-logging v0.0.1/go.mod h1:lDPYj54zutzG1XYfHAhcc7oNXEburHQBn+Iqd4yS4vE= +github.com/whyrusleeping/go-notifier v0.0.0-20170827234753-097c5d47330f/go.mod h1:cZNvX9cFybI01GriPRMXDtczuvUhgbcYr9iCGaNlRv8= +github.com/whyrusleeping/mafmt v1.2.8/go.mod h1:faQJFPbLSxzD9xpA02ttW/tS9vZykNvXwGvqIpk20FA= +github.com/whyrusleeping/mdns v0.0.0-20180901202407-ef14215e6b30/go.mod h1:j4l84WPFclQPj320J9gp0XwNKBb3U0zt5CBqjPp22G4= +github.com/whyrusleeping/mdns v0.0.0-20190826153040-b9b60ed33aa9/go.mod h1:j4l84WPFclQPj320J9gp0XwNKBb3U0zt5CBqjPp22G4= +github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7/go.mod h1:X2c0RVCI1eSUFI8eLcY3c0423ykwiUdxLJtkDvruhjI= +github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/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= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= +go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= +go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.1/go.mod h1:Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opentelemetry.io/otel v1.7.0 h1:Z2lA3Tdch0iDcrhJXDIlC94XE+bxok1F9B+4Lz/lGsM= +go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= +go.opentelemetry.io/otel/trace v1.7.0 h1:O37Iogk1lEkMRXewVtZ1BBTVn5JEp8GrJvP92bJqC6o= +go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +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.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/goleak v1.0.0/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= +go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= +go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= +go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= +golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= +golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190225124518-7f87c0fbb88b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190618222545-ea8f1a30c443/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +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-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20220916125017-b168a2c6b86b h1:SCE/18RnFsLrjydh/R/s5EVvHoZprqEQUuoxK8q2Pc4= golang.org/x/exp v0.0.0-20220916125017-b168a2c6b86b/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +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= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 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.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 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= +golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181029044818-c44066c5c816/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190227160552-c95aed5357e7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +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-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= 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.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220920183852-bf014ff85ad5 h1:KafLifaRFIuSJ5C+7CyFJOF9haxKNC1CEIDk8GX6X0k= +golang.org/x/net v0.0.0-20220920183852-bf014ff85ad5/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= 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= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/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-20201207232520-09787c993a3a/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.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/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-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190219092855-153ac476189d/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190228124157-a34e9553db1e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190302025703-b6889370fb10/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190524122548-abf6ff778158/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190526052359-791d8a0f4d09/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210317225723-c4fcb01b228e/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-20210603081109-ebe580a85c40/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-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/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-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= 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/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 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.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +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.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +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= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181130052023-1c3d964395ce/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= 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.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= 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= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= +google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= +google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= +google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.28.1/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -246,16 +1493,57 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= 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.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 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-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +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/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/src-d/go-cli.v0 v0.0.0-20181105080154-d492247bbc0d/go.mod h1:z+K8VcOYVYcSwSjGebuDL6176A1XskgbtNl64NSg+n8= +gopkg.in/src-d/go-log.v1 v1.0.1/go.mod h1:GN34hKP0g305ysm2/hctJ0Y8nWP3zxXXJ8GFabTyABE= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/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= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0= lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= +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= From eaea27bed01c59c593b4ed7197672dc476e07c9f Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Mon, 30 Jan 2023 11:39:15 +0100 Subject: [PATCH 673/674] chore: run Kubo gateway sharness if gateway/ is changed --- .github/workflows/gateway-sharness.yml | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/gateway-sharness.yml diff --git a/.github/workflows/gateway-sharness.yml b/.github/workflows/gateway-sharness.yml new file mode 100644 index 000000000..237cb3cee --- /dev/null +++ b/.github/workflows/gateway-sharness.yml @@ -0,0 +1,48 @@ +name: Gateway Sharness + +on: + workflow_dispatch: + pull_request: + paths: ['gateway/**'] + push: + branches: ['main'] + paths: ['gateway/**'] + +jobs: + sharness: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.19.1 + - name: Checkout go-libipfs + uses: actions/checkout@v3 + with: + path: go-libipfs + - name: Checkout Kubo + uses: actions/checkout@v3 + with: + repository: ipfs/kubo + path: kubo + - name: Install Missing Tools + run: sudo apt install -y socat net-tools fish libxml2-utils + - name: Restore Go Cache + uses: protocol/cache-go-action@v1 + with: + name: ${{ github.job }} + - name: Replace go-libipfs in Kubo go.mod + run: | + go mod edit -replace=github.com/ipfs/go-libipfs=../go-libipfs + go mod tidy + cat go.mod + working-directory: kubo + - name: Install sharness dependencies + run: make test_sharness_deps + working-directory: kubo + - name: Run Sharness Tests + run: find . -maxdepth 1 -name "*gateway*.sh" -print0 | xargs -0 -I {} bash -c "echo {}; {}" + working-directory: kubo/test/sharness From 4436ebf2757d4e12e8d194236f9624119d6fe0df Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 31 Jan 2023 00:33:27 +0100 Subject: [PATCH 674/674] docs(gateway): link to specs --- gateway/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gateway/README.md b/gateway/README.md index 98463086b..fdfaa6c30 100644 --- a/gateway/README.md +++ b/gateway/README.md @@ -1,11 +1,12 @@ # IPFS Gateway -> IPFS Gateway HTTP handler. +> A reference implementation of HTTP Gateway Specifications. ## Documentation * Go Documentation: https://pkg.go.dev/github.com/ipfs/go-libipfs/gateway - +* Gateway Specification: https://github.com/ipfs/specs/tree/main/http-gateways#readme +* Types of HTTP Gateways: https://docs.ipfs.tech/how-to/address-ipfs-on-web/#http-gateways ## Example ```go @@ -23,13 +24,13 @@ conf := gateway.Config{ ipfs := ... offlineIPFS := ... -// Create http mux and setup gateway handler. +// Create http mux and setup path gateway handler. mux := http.NewServeMux() gwHandler := gateway.NewHandler(conf, ipfs, offlineIPFS) mux.Handle("/ipfs/", gwHandler) mux.Handle("/ipns/", gwHandler) -// Start the server on :8080 and voilá! You have an IPFS gateway running +// Start the server on :8080 and voilá! You have a basic IPFS gateway running // in http://localhost:8080. _ = http.ListenAndServe(":8080", mux) ```