aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/api
diff options
context:
space:
mode:
Diffstat (limited to 'swarm/api')
-rw-r--r--swarm/api/api.go446
-rw-r--r--swarm/api/api_test.go58
-rw-r--r--swarm/api/client/client.go141
-rw-r--r--swarm/api/client/client_test.go51
-rw-r--r--swarm/api/config.go119
-rw-r--r--swarm/api/config_test.go20
-rw-r--r--swarm/api/filesystem.go43
-rw-r--r--swarm/api/filesystem_test.go53
-rw-r--r--swarm/api/http/error.go54
-rw-r--r--swarm/api/http/error_templates.go15
-rw-r--r--swarm/api/http/error_test.go12
-rw-r--r--swarm/api/http/roundtripper.go2
-rw-r--r--swarm/api/http/server.go675
-rw-r--r--swarm/api/http/server_test.go419
-rw-r--r--swarm/api/http/templates.go3
-rw-r--r--swarm/api/manifest.go185
-rw-r--r--swarm/api/manifest_test.go35
-rw-r--r--swarm/api/storage.go32
-rw-r--r--swarm/api/storage_test.go14
-rw-r--r--swarm/api/testapi.go32
-rw-r--r--swarm/api/uri.go46
-rw-r--r--swarm/api/uri_test.go47
22 files changed, 1854 insertions, 648 deletions
diff --git a/swarm/api/api.go b/swarm/api/api.go
index 0cf12fdbe..36f19998a 100644
--- a/swarm/api/api.go
+++ b/swarm/api/api.go
@@ -17,13 +17,13 @@
package api
import (
+ "context"
"fmt"
"io"
+ "math/big"
"net/http"
"path"
- "regexp"
"strings"
- "sync"
"bytes"
"mime"
@@ -31,14 +31,15 @@ import (
"time"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/ethereum/go-ethereum/contracts/ens"
+ "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/metrics"
+ "github.com/ethereum/go-ethereum/swarm/log"
+ "github.com/ethereum/go-ethereum/swarm/multihash"
"github.com/ethereum/go-ethereum/swarm/storage"
+ "github.com/ethereum/go-ethereum/swarm/storage/mru"
)
-var hashMatcher = regexp.MustCompile("^[0-9A-Fa-f]{64}")
-
-//setup metrics
var (
apiResolveCount = metrics.NewRegisteredCounter("api.resolve.count", nil)
apiResolveFail = metrics.NewRegisteredCounter("api.resolve.fail", nil)
@@ -46,7 +47,7 @@ var (
apiPutFail = metrics.NewRegisteredCounter("api.put.fail", nil)
apiGetCount = metrics.NewRegisteredCounter("api.get.count", nil)
apiGetNotFound = metrics.NewRegisteredCounter("api.get.notfound", nil)
- apiGetHttp300 = metrics.NewRegisteredCounter("api.get.http.300", nil)
+ apiGetHTTP300 = metrics.NewRegisteredCounter("api.get.http.300", nil)
apiModifyCount = metrics.NewRegisteredCounter("api.modify.count", nil)
apiModifyFail = metrics.NewRegisteredCounter("api.modify.fail", nil)
apiAddFileCount = metrics.NewRegisteredCounter("api.addfile.count", nil)
@@ -55,22 +56,33 @@ var (
apiRmFileFail = metrics.NewRegisteredCounter("api.removefile.fail", nil)
apiAppendFileCount = metrics.NewRegisteredCounter("api.appendfile.count", nil)
apiAppendFileFail = metrics.NewRegisteredCounter("api.appendfile.fail", nil)
+ apiGetInvalid = metrics.NewRegisteredCounter("api.get.invalid", nil)
)
+// Resolver interface resolve a domain name to a hash using ENS
type Resolver interface {
Resolve(string) (common.Hash, error)
}
+// ResolveValidator is used to validate the contained Resolver
+type ResolveValidator interface {
+ Resolver
+ Owner(node [32]byte) (common.Address, error)
+ HeaderByNumber(context.Context, *big.Int) (*types.Header, error)
+}
+
// NoResolverError is returned by MultiResolver.Resolve if no resolver
// can be found for the address.
type NoResolverError struct {
TLD string
}
+// NewNoResolverError creates a NoResolverError for the given top level domain
func NewNoResolverError(tld string) *NoResolverError {
return &NoResolverError{TLD: tld}
}
+// Error NoResolverError implements error
func (e *NoResolverError) Error() string {
if e.TLD == "" {
return "no ENS resolver"
@@ -82,7 +94,8 @@ func (e *NoResolverError) Error() string {
// Each TLD can have multiple resolvers, and the resoluton from the
// first one in the sequence will be returned.
type MultiResolver struct {
- resolvers map[string][]Resolver
+ resolvers map[string][]ResolveValidator
+ nameHash func(string) common.Hash
}
// MultiResolverOption sets options for MultiResolver and is used as
@@ -93,16 +106,24 @@ type MultiResolverOption func(*MultiResolver)
// for a specific TLD. If TLD is an empty string, the resolver will be added
// to the list of default resolver, the ones that will be used for resolution
// of addresses which do not have their TLD resolver specified.
-func MultiResolverOptionWithResolver(r Resolver, tld string) MultiResolverOption {
+func MultiResolverOptionWithResolver(r ResolveValidator, tld string) MultiResolverOption {
return func(m *MultiResolver) {
m.resolvers[tld] = append(m.resolvers[tld], r)
}
}
+// MultiResolverOptionWithNameHash is unused at the time of this writing
+func MultiResolverOptionWithNameHash(nameHash func(string) common.Hash) MultiResolverOption {
+ return func(m *MultiResolver) {
+ m.nameHash = nameHash
+ }
+}
+
// NewMultiResolver creates a new instance of MultiResolver.
func NewMultiResolver(opts ...MultiResolverOption) (m *MultiResolver) {
m = &MultiResolver{
- resolvers: make(map[string][]Resolver),
+ resolvers: make(map[string][]ResolveValidator),
+ nameHash: ens.EnsNode,
}
for _, o := range opts {
o(m)
@@ -114,18 +135,10 @@ func NewMultiResolver(opts ...MultiResolverOption) (m *MultiResolver) {
// If there are more default Resolvers, or for a specific TLD,
// the Hash from the the first one which does not return error
// will be returned.
-func (m MultiResolver) Resolve(addr string) (h common.Hash, err error) {
- rs := m.resolvers[""]
- tld := path.Ext(addr)
- if tld != "" {
- tld = tld[1:]
- rstld, ok := m.resolvers[tld]
- if ok {
- rs = rstld
- }
- }
- if rs == nil {
- return h, NewNoResolverError(tld)
+func (m *MultiResolver) Resolve(addr string) (h common.Hash, err error) {
+ rs, err := m.getResolveValidator(addr)
+ if err != nil {
+ return h, err
}
for _, r := range rs {
h, err = r.Resolve(addr)
@@ -136,104 +149,171 @@ func (m MultiResolver) Resolve(addr string) (h common.Hash, err error) {
return
}
+// ValidateOwner checks the ENS to validate that the owner of the given domain is the given eth address
+func (m *MultiResolver) ValidateOwner(name string, address common.Address) (bool, error) {
+ rs, err := m.getResolveValidator(name)
+ if err != nil {
+ return false, err
+ }
+ var addr common.Address
+ for _, r := range rs {
+ addr, err = r.Owner(m.nameHash(name))
+ // we hide the error if it is not for the last resolver we check
+ if err == nil {
+ return addr == address, nil
+ }
+ }
+ return false, err
+}
+
+// HeaderByNumber uses the validator of the given domainname and retrieves the header for the given block number
+func (m *MultiResolver) HeaderByNumber(ctx context.Context, name string, blockNr *big.Int) (*types.Header, error) {
+ rs, err := m.getResolveValidator(name)
+ if err != nil {
+ return nil, err
+ }
+ for _, r := range rs {
+ var header *types.Header
+ header, err = r.HeaderByNumber(ctx, blockNr)
+ // we hide the error if it is not for the last resolver we check
+ if err == nil {
+ return header, nil
+ }
+ }
+ return nil, err
+}
+
+// getResolveValidator uses the hostname to retrieve the resolver associated with the top level domain
+func (m *MultiResolver) getResolveValidator(name string) ([]ResolveValidator, error) {
+ rs := m.resolvers[""]
+ tld := path.Ext(name)
+ if tld != "" {
+ tld = tld[1:]
+ rstld, ok := m.resolvers[tld]
+ if ok {
+ return rstld, nil
+ }
+ }
+ if len(rs) == 0 {
+ return rs, NewNoResolverError(tld)
+ }
+ return rs, nil
+}
+
+// SetNameHash sets the hasher function that hashes the domain into a name hash that ENS uses
+func (m *MultiResolver) SetNameHash(nameHash func(string) common.Hash) {
+ m.nameHash = nameHash
+}
+
/*
-Api implements webserver/file system related content storage and retrieval
-on top of the dpa
-it is the public interface of the dpa which is included in the ethereum stack
+API implements webserver/file system related content storage and retrieval
+on top of the FileStore
+it is the public interface of the FileStore which is included in the ethereum stack
*/
-type Api struct {
- dpa *storage.DPA
- dns Resolver
+type API struct {
+ resource *mru.Handler
+ fileStore *storage.FileStore
+ dns Resolver
}
-//the api constructor initialises
-func NewApi(dpa *storage.DPA, dns Resolver) (self *Api) {
- self = &Api{
- dpa: dpa,
- dns: dns,
+// NewAPI the api constructor initialises a new API instance.
+func NewAPI(fileStore *storage.FileStore, dns Resolver, resourceHandler *mru.Handler) (self *API) {
+ self = &API{
+ fileStore: fileStore,
+ dns: dns,
+ resource: resourceHandler,
}
return
}
-// to be used only in TEST
-func (self *Api) Upload(uploadDir, index string) (hash string, err error) {
- fs := NewFileSystem(self)
- hash, err = fs.Upload(uploadDir, index)
+// Upload to be used only in TEST
+func (a *API) Upload(uploadDir, index string, toEncrypt bool) (hash string, err error) {
+ fs := NewFileSystem(a)
+ hash, err = fs.Upload(uploadDir, index, toEncrypt)
return hash, err
}
-// DPA reader API
-func (self *Api) Retrieve(key storage.Key) storage.LazySectionReader {
- return self.dpa.Retrieve(key)
+// Retrieve FileStore reader API
+func (a *API) Retrieve(addr storage.Address) (reader storage.LazySectionReader, isEncrypted bool) {
+ return a.fileStore.Retrieve(addr)
}
-func (self *Api) Store(data io.Reader, size int64, wg *sync.WaitGroup) (key storage.Key, err error) {
- return self.dpa.Store(data, size, wg, nil)
+// Store wraps the Store API call of the embedded FileStore
+func (a *API) Store(data io.Reader, size int64, toEncrypt bool) (addr storage.Address, wait func(), err error) {
+ log.Debug("api.store", "size", size)
+ return a.fileStore.Store(data, size, toEncrypt)
}
+// ErrResolve is returned when an URI cannot be resolved from ENS.
type ErrResolve error
-// DNS Resolver
-func (self *Api) Resolve(uri *URI) (storage.Key, error) {
+// Resolve resolves a URI to an Address using the MultiResolver.
+func (a *API) Resolve(uri *URI) (storage.Address, error) {
apiResolveCount.Inc(1)
- log.Trace(fmt.Sprintf("Resolving : %v", uri.Addr))
+ log.Trace("resolving", "uri", uri.Addr)
- // if the URI is immutable, check if the address is a hash
- isHash := hashMatcher.MatchString(uri.Addr)
- if uri.Immutable() || uri.DeprecatedImmutable() {
- if !isHash {
+ // if the URI is immutable, check if the address looks like a hash
+ if uri.Immutable() {
+ key := uri.Address()
+ if key == nil {
return nil, fmt.Errorf("immutable address not a content hash: %q", uri.Addr)
}
- return common.Hex2Bytes(uri.Addr), nil
+ return key, nil
}
// if DNS is not configured, check if the address is a hash
- if self.dns == nil {
- if !isHash {
+ if a.dns == nil {
+ key := uri.Address()
+ if key == nil {
apiResolveFail.Inc(1)
return nil, fmt.Errorf("no DNS to resolve name: %q", uri.Addr)
}
- return common.Hex2Bytes(uri.Addr), nil
+ return key, nil
}
// try and resolve the address
- resolved, err := self.dns.Resolve(uri.Addr)
+ resolved, err := a.dns.Resolve(uri.Addr)
if err == nil {
return resolved[:], nil
- } else if !isHash {
+ }
+
+ key := uri.Address()
+ if key == nil {
apiResolveFail.Inc(1)
return nil, err
}
- return common.Hex2Bytes(uri.Addr), nil
+ return key, nil
}
-// Put provides singleton manifest creation on top of dpa store
-func (self *Api) Put(content, contentType string) (storage.Key, error) {
+// Put provides singleton manifest creation on top of FileStore store
+func (a *API) Put(content, contentType string, toEncrypt bool) (k storage.Address, wait func(), err error) {
apiPutCount.Inc(1)
r := strings.NewReader(content)
- wg := &sync.WaitGroup{}
- key, err := self.dpa.Store(r, int64(len(content)), wg, nil)
+ key, waitContent, err := a.fileStore.Store(r, int64(len(content)), toEncrypt)
if err != nil {
apiPutFail.Inc(1)
- return nil, err
+ return nil, nil, err
}
manifest := fmt.Sprintf(`{"entries":[{"hash":"%v","contentType":"%s"}]}`, key, contentType)
r = strings.NewReader(manifest)
- key, err = self.dpa.Store(r, int64(len(manifest)), wg, nil)
+ key, waitManifest, err := a.fileStore.Store(r, int64(len(manifest)), toEncrypt)
if err != nil {
apiPutFail.Inc(1)
- return nil, err
+ return nil, nil, err
}
- wg.Wait()
- return key, nil
+ return key, func() {
+ waitContent()
+ waitManifest()
+ }, nil
}
// Get uses iterative manifest retrieval and prefix matching
-// to resolve basePath to content using dpa retrieve
-// it returns a section reader, mimeType, status and an error
-func (self *Api) Get(key storage.Key, path string) (reader storage.LazySectionReader, mimeType string, status int, err error) {
+// to resolve basePath to content using FileStore retrieve
+// it returns a section reader, mimeType, status, the key of the actual content and an error
+func (a *API) Get(manifestAddr storage.Address, path string) (reader storage.LazySectionReader, mimeType string, status int, contentAddr storage.Address, err error) {
+ log.Debug("api.get", "key", manifestAddr, "path", path)
apiGetCount.Inc(1)
- trie, err := loadManifest(self.dpa, key, nil)
+ trie, err := loadManifest(a.fileStore, manifestAddr, nil)
if err != nil {
apiGetNotFound.Inc(1)
status = http.StatusNotFound
@@ -241,34 +321,111 @@ func (self *Api) Get(key storage.Key, path string) (reader storage.LazySectionRe
return
}
- log.Trace(fmt.Sprintf("getEntry(%s)", path))
-
+ log.Debug("trie getting entry", "key", manifestAddr, "path", path)
entry, _ := trie.getEntry(path)
if entry != nil {
- key = common.Hex2Bytes(entry.Hash)
+ log.Debug("trie got entry", "key", manifestAddr, "path", path, "entry.Hash", entry.Hash)
+ // we need to do some extra work if this is a mutable resource manifest
+ if entry.ContentType == ResourceContentType {
+
+ // get the resource root chunk key
+ log.Trace("resource type", "key", manifestAddr, "hash", entry.Hash)
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ rsrc, err := a.resource.Load(storage.Address(common.FromHex(entry.Hash)))
+ if err != nil {
+ apiGetNotFound.Inc(1)
+ status = http.StatusNotFound
+ log.Debug(fmt.Sprintf("get resource content error: %v", err))
+ return reader, mimeType, status, nil, err
+ }
+
+ // use this key to retrieve the latest update
+ rsrc, err = a.resource.LookupLatest(ctx, rsrc.NameHash(), true, &mru.LookupParams{})
+ if err != nil {
+ apiGetNotFound.Inc(1)
+ status = http.StatusNotFound
+ log.Debug(fmt.Sprintf("get resource content error: %v", err))
+ return reader, mimeType, status, nil, err
+ }
+
+ // if it's multihash, we will transparently serve the content this multihash points to
+ // \TODO this resolve is rather expensive all in all, review to see if it can be achieved cheaper
+ if rsrc.Multihash {
+
+ // get the data of the update
+ _, rsrcData, err := a.resource.GetContent(rsrc.NameHash().Hex())
+ if err != nil {
+ apiGetNotFound.Inc(1)
+ status = http.StatusNotFound
+ log.Warn(fmt.Sprintf("get resource content error: %v", err))
+ return reader, mimeType, status, nil, err
+ }
+
+ // validate that data as multihash
+ decodedMultihash, err := multihash.FromMultihash(rsrcData)
+ if err != nil {
+ apiGetInvalid.Inc(1)
+ status = http.StatusUnprocessableEntity
+ log.Warn("invalid resource multihash", "err", err)
+ return reader, mimeType, status, nil, err
+ }
+ manifestAddr = storage.Address(decodedMultihash)
+ log.Trace("resource is multihash", "key", manifestAddr)
+
+ // get the manifest the multihash digest points to
+ trie, err := loadManifest(a.fileStore, manifestAddr, nil)
+ if err != nil {
+ apiGetNotFound.Inc(1)
+ status = http.StatusNotFound
+ log.Warn(fmt.Sprintf("loadManifestTrie (resource multihash) error: %v", err))
+ return reader, mimeType, status, nil, err
+ }
+
+ // finally, get the manifest entry
+ // it will always be the entry on path ""
+ entry, _ = trie.getEntry(path)
+ if entry == nil {
+ status = http.StatusNotFound
+ apiGetNotFound.Inc(1)
+ err = fmt.Errorf("manifest (resource multihash) entry for '%s' not found", path)
+ log.Trace("manifest (resource multihash) entry not found", "key", manifestAddr, "path", path)
+ return reader, mimeType, status, nil, err
+ }
+
+ } else {
+ // data is returned verbatim since it's not a multihash
+ return rsrc, "application/octet-stream", http.StatusOK, nil, nil
+ }
+ }
+
+ // regardless of resource update manifests or normal manifests we will converge at this point
+ // get the key the manifest entry points to and serve it if it's unambiguous
+ contentAddr = common.Hex2Bytes(entry.Hash)
status = entry.Status
if status == http.StatusMultipleChoices {
- apiGetHttp300.Inc(1)
- return
- } else {
- mimeType = entry.ContentType
- log.Trace(fmt.Sprintf("content lookup key: '%v' (%v)", key, mimeType))
- reader = self.dpa.Retrieve(key)
+ apiGetHTTP300.Inc(1)
+ return nil, entry.ContentType, status, contentAddr, err
}
+ mimeType = entry.ContentType
+ log.Debug("content lookup key", "key", contentAddr, "mimetype", mimeType)
+ reader, _ = a.fileStore.Retrieve(contentAddr)
} else {
+ // no entry found
status = http.StatusNotFound
apiGetNotFound.Inc(1)
err = fmt.Errorf("manifest entry for '%s' not found", path)
- log.Warn(fmt.Sprintf("%v", err))
+ log.Trace("manifest entry not found", "key", contentAddr, "path", path)
}
return
}
-func (self *Api) Modify(key storage.Key, path, contentHash, contentType string) (storage.Key, error) {
+// Modify loads manifest and checks the content hash before recalculating and storing the manifest.
+func (a *API) Modify(addr storage.Address, path, contentHash, contentType string) (storage.Address, error) {
apiModifyCount.Inc(1)
quitC := make(chan bool)
- trie, err := loadManifest(self.dpa, key, quitC)
+ trie, err := loadManifest(a.fileStore, addr, quitC)
if err != nil {
apiModifyFail.Inc(1)
return nil, err
@@ -288,10 +445,11 @@ func (self *Api) Modify(key storage.Key, path, contentHash, contentType string)
apiModifyFail.Inc(1)
return nil, err
}
- return trie.hash, nil
+ return trie.ref, nil
}
-func (self *Api) AddFile(mhash, path, fname string, content []byte, nameresolver bool) (storage.Key, string, error) {
+// AddFile creates a new manifest entry, adds it to swarm, then adds a file to swarm.
+func (a *API) AddFile(mhash, path, fname string, content []byte, nameresolver bool) (storage.Address, string, error) {
apiAddFileCount.Inc(1)
uri, err := Parse("bzz:/" + mhash)
@@ -299,7 +457,7 @@ func (self *Api) AddFile(mhash, path, fname string, content []byte, nameresolver
apiAddFileFail.Inc(1)
return nil, "", err
}
- mkey, err := self.Resolve(uri)
+ mkey, err := a.Resolve(uri)
if err != nil {
apiAddFileFail.Inc(1)
return nil, "", err
@@ -318,7 +476,7 @@ func (self *Api) AddFile(mhash, path, fname string, content []byte, nameresolver
ModTime: time.Now(),
}
- mw, err := self.NewManifestWriter(mkey, nil)
+ mw, err := a.NewManifestWriter(mkey, nil)
if err != nil {
apiAddFileFail.Inc(1)
return nil, "", err
@@ -341,7 +499,8 @@ func (self *Api) AddFile(mhash, path, fname string, content []byte, nameresolver
}
-func (self *Api) RemoveFile(mhash, path, fname string, nameresolver bool) (string, error) {
+// RemoveFile removes a file entry in a manifest.
+func (a *API) RemoveFile(mhash, path, fname string, nameresolver bool) (string, error) {
apiRmFileCount.Inc(1)
uri, err := Parse("bzz:/" + mhash)
@@ -349,7 +508,7 @@ func (self *Api) RemoveFile(mhash, path, fname string, nameresolver bool) (strin
apiRmFileFail.Inc(1)
return "", err
}
- mkey, err := self.Resolve(uri)
+ mkey, err := a.Resolve(uri)
if err != nil {
apiRmFileFail.Inc(1)
return "", err
@@ -360,7 +519,7 @@ func (self *Api) RemoveFile(mhash, path, fname string, nameresolver bool) (strin
path = path[1:]
}
- mw, err := self.NewManifestWriter(mkey, nil)
+ mw, err := a.NewManifestWriter(mkey, nil)
if err != nil {
apiRmFileFail.Inc(1)
return "", err
@@ -382,7 +541,8 @@ func (self *Api) RemoveFile(mhash, path, fname string, nameresolver bool) (strin
return newMkey.String(), nil
}
-func (self *Api) AppendFile(mhash, path, fname string, existingSize int64, content []byte, oldKey storage.Key, offset int64, addSize int64, nameresolver bool) (storage.Key, string, error) {
+// AppendFile removes old manifest, appends file entry to new manifest and adds it to Swarm.
+func (a *API) AppendFile(mhash, path, fname string, existingSize int64, content []byte, oldAddr storage.Address, offset int64, addSize int64, nameresolver bool) (storage.Address, string, error) {
apiAppendFileCount.Inc(1)
buffSize := offset + addSize
@@ -392,7 +552,7 @@ func (self *Api) AppendFile(mhash, path, fname string, existingSize int64, conte
buf := make([]byte, buffSize)
- oldReader := self.Retrieve(oldKey)
+ oldReader, _ := a.Retrieve(oldAddr)
io.ReadAtLeast(oldReader, buf, int(offset))
newReader := bytes.NewReader(content)
@@ -406,7 +566,7 @@ func (self *Api) AppendFile(mhash, path, fname string, existingSize int64, conte
totalSize := int64(len(buf))
// TODO(jmozah): to append using pyramid chunker when it is ready
- //oldReader := self.Retrieve(oldKey)
+ //oldReader := a.Retrieve(oldKey)
//newReader := bytes.NewReader(content)
//combinedReader := io.MultiReader(oldReader, newReader)
@@ -415,7 +575,7 @@ func (self *Api) AppendFile(mhash, path, fname string, existingSize int64, conte
apiAppendFileFail.Inc(1)
return nil, "", err
}
- mkey, err := self.Resolve(uri)
+ mkey, err := a.Resolve(uri)
if err != nil {
apiAppendFileFail.Inc(1)
return nil, "", err
@@ -426,7 +586,7 @@ func (self *Api) AppendFile(mhash, path, fname string, existingSize int64, conte
path = path[1:]
}
- mw, err := self.NewManifestWriter(mkey, nil)
+ mw, err := a.NewManifestWriter(mkey, nil)
if err != nil {
apiAppendFileFail.Inc(1)
return nil, "", err
@@ -463,21 +623,22 @@ func (self *Api) AppendFile(mhash, path, fname string, existingSize int64, conte
}
-func (self *Api) BuildDirectoryTree(mhash string, nameresolver bool) (key storage.Key, manifestEntryMap map[string]*manifestTrieEntry, err error) {
+// BuildDirectoryTree used by swarmfs_unix
+func (a *API) BuildDirectoryTree(mhash string, nameresolver bool) (addr storage.Address, manifestEntryMap map[string]*manifestTrieEntry, err error) {
uri, err := Parse("bzz:/" + mhash)
if err != nil {
return nil, nil, err
}
- key, err = self.Resolve(uri)
+ addr, err = a.Resolve(uri)
if err != nil {
return nil, nil, err
}
quitC := make(chan bool)
- rootTrie, err := loadManifest(self.dpa, key, quitC)
+ rootTrie, err := loadManifest(a.fileStore, addr, quitC)
if err != nil {
- return nil, nil, fmt.Errorf("can't load manifest %v: %v", key.String(), err)
+ return nil, nil, fmt.Errorf("can't load manifest %v: %v", addr.String(), err)
}
manifestEntryMap = map[string]*manifestTrieEntry{}
@@ -486,7 +647,94 @@ func (self *Api) BuildDirectoryTree(mhash string, nameresolver bool) (key storag
})
if err != nil {
- return nil, nil, fmt.Errorf("list with prefix failed %v: %v", key.String(), err)
+ return nil, nil, fmt.Errorf("list with prefix failed %v: %v", addr.String(), err)
+ }
+ return addr, manifestEntryMap, nil
+}
+
+// ResourceLookup Looks up mutable resource updates at specific periods and versions
+func (a *API) ResourceLookup(ctx context.Context, addr storage.Address, period uint32, version uint32, maxLookup *mru.LookupParams) (string, []byte, error) {
+ var err error
+ rsrc, err := a.resource.Load(addr)
+ if err != nil {
+ return "", nil, err
+ }
+ if version != 0 {
+ if period == 0 {
+ return "", nil, mru.NewError(mru.ErrInvalidValue, "Period can't be 0")
+ }
+ _, err = a.resource.LookupVersion(ctx, rsrc.NameHash(), period, version, true, maxLookup)
+ } else if period != 0 {
+ _, err = a.resource.LookupHistorical(ctx, rsrc.NameHash(), period, true, maxLookup)
+ } else {
+ _, err = a.resource.LookupLatest(ctx, rsrc.NameHash(), true, maxLookup)
+ }
+ if err != nil {
+ return "", nil, err
+ }
+ var data []byte
+ _, data, err = a.resource.GetContent(rsrc.NameHash().Hex())
+ if err != nil {
+ return "", nil, err
+ }
+ return rsrc.Name(), data, nil
+}
+
+// ResourceCreate creates Resource and returns its key
+func (a *API) ResourceCreate(ctx context.Context, name string, frequency uint64) (storage.Address, error) {
+ key, _, err := a.resource.New(ctx, name, frequency)
+ if err != nil {
+ return nil, err
+ }
+ return key, nil
+}
+
+// ResourceUpdateMultihash updates a Mutable Resource and marks the update's content to be of multihash type, which will be recognized upon retrieval.
+// It will fail if the data is not a valid multihash.
+func (a *API) ResourceUpdateMultihash(ctx context.Context, name string, data []byte) (storage.Address, uint32, uint32, error) {
+ return a.resourceUpdate(ctx, name, data, true)
+}
+
+// ResourceUpdate updates a Mutable Resource with arbitrary data.
+// Upon retrieval the update will be retrieved verbatim as bytes.
+func (a *API) ResourceUpdate(ctx context.Context, name string, data []byte) (storage.Address, uint32, uint32, error) {
+ return a.resourceUpdate(ctx, name, data, false)
+}
+
+func (a *API) resourceUpdate(ctx context.Context, name string, data []byte, multihash bool) (storage.Address, uint32, uint32, error) {
+ var addr storage.Address
+ var err error
+ if multihash {
+ addr, err = a.resource.UpdateMultihash(ctx, name, data)
+ } else {
+ addr, err = a.resource.Update(ctx, name, data)
}
- return key, manifestEntryMap, nil
+ period, _ := a.resource.GetLastPeriod(name)
+ version, _ := a.resource.GetVersion(name)
+ return addr, period, version, err
+}
+
+// ResourceHashSize returned the size of the digest produced by the Mutable Resource hashing function
+func (a *API) ResourceHashSize() int {
+ return a.resource.HashSize
+}
+
+// ResourceIsValidated checks if the Mutable Resource has an active content validator.
+func (a *API) ResourceIsValidated() bool {
+ return a.resource.IsValidated()
+}
+
+// ResolveResourceManifest retrieves the Mutable Resource manifest for the given address, and returns the address of the metadata chunk.
+func (a *API) ResolveResourceManifest(addr storage.Address) (storage.Address, error) {
+ trie, err := loadManifest(a.fileStore, addr, nil)
+ if err != nil {
+ return nil, fmt.Errorf("cannot load resource manifest: %v", err)
+ }
+
+ entry, _ := trie.getEntry("")
+ if entry.ContentType != ResourceContentType {
+ return nil, fmt.Errorf("not a resource manifest: %s", addr)
+ }
+
+ return storage.Address(common.FromHex(entry.Hash)), nil
}
diff --git a/swarm/api/api_test.go b/swarm/api/api_test.go
index 4ee26bd8a..e607dd4fc 100644
--- a/swarm/api/api_test.go
+++ b/swarm/api/api_test.go
@@ -17,33 +17,34 @@
package api
import (
+ "context"
"errors"
"fmt"
"io"
"io/ioutil"
+ "math/big"
"os"
"testing"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/swarm/log"
"github.com/ethereum/go-ethereum/swarm/storage"
)
-func testApi(t *testing.T, f func(*Api)) {
+func testAPI(t *testing.T, f func(*API, bool)) {
datadir, err := ioutil.TempDir("", "bzz-test")
if err != nil {
t.Fatalf("unable to create temp dir: %v", err)
}
- os.RemoveAll(datadir)
defer os.RemoveAll(datadir)
- dpa, err := storage.NewLocalDPA(datadir)
+ fileStore, err := storage.NewLocalFileStore(datadir, make([]byte, 32))
if err != nil {
return
}
- api := NewApi(dpa, nil)
- dpa.Start()
- f(api)
- dpa.Stop()
+ api := NewAPI(fileStore, nil, nil)
+ f(api, false)
+ f(api, true)
}
type testResponse struct {
@@ -82,10 +83,9 @@ func expResponse(content string, mimeType string, status int) *Response {
return &Response{mimeType, status, int64(len(content)), content}
}
-// func testGet(t *testing.T, api *Api, bzzhash string) *testResponse {
-func testGet(t *testing.T, api *Api, bzzhash, path string) *testResponse {
- key := storage.Key(common.Hex2Bytes(bzzhash))
- reader, mimeType, status, err := api.Get(key, path)
+func testGet(t *testing.T, api *API, bzzhash, path string) *testResponse {
+ addr := storage.Address(common.Hex2Bytes(bzzhash))
+ reader, mimeType, status, _, err := api.Get(addr, path)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@@ -106,27 +106,28 @@ func testGet(t *testing.T, api *Api, bzzhash, path string) *testResponse {
}
func TestApiPut(t *testing.T) {
- testApi(t, func(api *Api) {
+ testAPI(t, func(api *API, toEncrypt bool) {
content := "hello"
exp := expResponse(content, "text/plain", 0)
// exp := expResponse([]byte(content), "text/plain", 0)
- key, err := api.Put(content, exp.MimeType)
+ addr, wait, err := api.Put(content, exp.MimeType, toEncrypt)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
- resp := testGet(t, api, key.String(), "")
+ wait()
+ resp := testGet(t, api, addr.Hex(), "")
checkResponse(t, resp, exp)
})
}
// testResolver implements the Resolver interface and either returns the given
// hash if it is set, or returns a "name not found" error
-type testResolver struct {
+type testResolveValidator struct {
hash *common.Hash
}
-func newTestResolver(addr string) *testResolver {
- r := &testResolver{}
+func newTestResolveValidator(addr string) *testResolveValidator {
+ r := &testResolveValidator{}
if addr != "" {
hash := common.HexToHash(addr)
r.hash = &hash
@@ -134,21 +135,28 @@ func newTestResolver(addr string) *testResolver {
return r
}
-func (t *testResolver) Resolve(addr string) (common.Hash, error) {
+func (t *testResolveValidator) Resolve(addr string) (common.Hash, error) {
if t.hash == nil {
return common.Hash{}, fmt.Errorf("DNS name not found: %q", addr)
}
return *t.hash, nil
}
+func (t *testResolveValidator) Owner(node [32]byte) (addr common.Address, err error) {
+ return
+}
+func (t *testResolveValidator) HeaderByNumber(context.Context, *big.Int) (header *types.Header, err error) {
+ return
+}
+
// TestAPIResolve tests resolving URIs which can either contain content hashes
// or ENS names
func TestAPIResolve(t *testing.T) {
ensAddr := "swarm.eth"
hashAddr := "1111111111111111111111111111111111111111111111111111111111111111"
resolvedAddr := "2222222222222222222222222222222222222222222222222222222222222222"
- doesResolve := newTestResolver(resolvedAddr)
- doesntResolve := newTestResolver("")
+ doesResolve := newTestResolveValidator(resolvedAddr)
+ doesntResolve := newTestResolveValidator("")
type test struct {
desc string
@@ -213,7 +221,7 @@ func TestAPIResolve(t *testing.T) {
}
for _, x := range tests {
t.Run(x.desc, func(t *testing.T) {
- api := &Api{dns: x.dns}
+ api := &API{dns: x.dns}
uri := &URI{Addr: x.addr, Scheme: "bzz"}
if x.immutable {
uri.Scheme = "bzz-immutable"
@@ -239,15 +247,15 @@ func TestAPIResolve(t *testing.T) {
}
func TestMultiResolver(t *testing.T) {
- doesntResolve := newTestResolver("")
+ doesntResolve := newTestResolveValidator("")
ethAddr := "swarm.eth"
ethHash := "0x2222222222222222222222222222222222222222222222222222222222222222"
- ethResolve := newTestResolver(ethHash)
+ ethResolve := newTestResolveValidator(ethHash)
testAddr := "swarm.test"
testHash := "0x1111111111111111111111111111111111111111111111111111111111111111"
- testResolve := newTestResolver(testHash)
+ testResolve := newTestResolveValidator(testHash)
tests := []struct {
desc string
diff --git a/swarm/api/client/client.go b/swarm/api/client/client.go
index 8165d52d7..ef6222435 100644
--- a/swarm/api/client/client.go
+++ b/swarm/api/client/client.go
@@ -30,6 +30,7 @@ import (
"net/textproto"
"os"
"path/filepath"
+ "regexp"
"strconv"
"strings"
@@ -52,12 +53,17 @@ type Client struct {
Gateway string
}
-// UploadRaw uploads raw data to swarm and returns the resulting hash
-func (c *Client) UploadRaw(r io.Reader, size int64) (string, error) {
+// UploadRaw uploads raw data to swarm and returns the resulting hash. If toEncrypt is true it
+// uploads encrypted data
+func (c *Client) UploadRaw(r io.Reader, size int64, toEncrypt bool) (string, error) {
if size <= 0 {
return "", errors.New("data size must be greater than zero")
}
- req, err := http.NewRequest("POST", c.Gateway+"/bzz-raw:/", r)
+ addr := ""
+ if toEncrypt {
+ addr = "encrypt"
+ }
+ req, err := http.NewRequest("POST", c.Gateway+"/bzz-raw:/"+addr, r)
if err != nil {
return "", err
}
@@ -77,18 +83,20 @@ func (c *Client) UploadRaw(r io.Reader, size int64) (string, error) {
return string(data), nil
}
-// DownloadRaw downloads raw data from swarm
-func (c *Client) DownloadRaw(hash string) (io.ReadCloser, error) {
+// DownloadRaw downloads raw data from swarm and it returns a ReadCloser and a bool whether the
+// content was encrypted
+func (c *Client) DownloadRaw(hash string) (io.ReadCloser, bool, error) {
uri := c.Gateway + "/bzz-raw:/" + hash
res, err := http.DefaultClient.Get(uri)
if err != nil {
- return nil, err
+ return nil, false, err
}
if res.StatusCode != http.StatusOK {
res.Body.Close()
- return nil, fmt.Errorf("unexpected HTTP status: %s", res.Status)
+ return nil, false, fmt.Errorf("unexpected HTTP status: %s", res.Status)
}
- return res.Body, nil
+ isEncrypted := (res.Header.Get("X-Decrypted") == "true")
+ return res.Body, isEncrypted, nil
}
// File represents a file in a swarm manifest and is used for uploading and
@@ -125,11 +133,11 @@ func Open(path string) (*File, error) {
// (if the manifest argument is non-empty) or creates a new manifest containing
// the file, returning the resulting manifest hash (the file will then be
// available at bzz:/<hash>/<path>)
-func (c *Client) Upload(file *File, manifest string) (string, error) {
+func (c *Client) Upload(file *File, manifest string, toEncrypt bool) (string, error) {
if file.Size <= 0 {
return "", errors.New("file size must be greater than zero")
}
- return c.TarUpload(manifest, &FileUploader{file})
+ return c.TarUpload(manifest, &FileUploader{file}, toEncrypt)
}
// Download downloads a file with the given path from the swarm manifest with
@@ -159,14 +167,14 @@ func (c *Client) Download(hash, path string) (*File, error) {
// directory will then be available at bzz:/<hash>/path/to/file), with
// the file specified in defaultPath being uploaded to the root of the manifest
// (i.e. bzz:/<hash>/)
-func (c *Client) UploadDirectory(dir, defaultPath, manifest string) (string, error) {
+func (c *Client) UploadDirectory(dir, defaultPath, manifest string, toEncrypt bool) (string, error) {
stat, err := os.Stat(dir)
if err != nil {
return "", err
} else if !stat.IsDir() {
return "", fmt.Errorf("not a directory: %s", dir)
}
- return c.TarUpload(manifest, &DirectoryUploader{dir, defaultPath})
+ return c.TarUpload(manifest, &DirectoryUploader{dir, defaultPath}, toEncrypt)
}
// DownloadDirectory downloads the files contained in a swarm manifest under
@@ -228,27 +236,109 @@ func (c *Client) DownloadDirectory(hash, path, destDir string) error {
}
}
+// DownloadFile downloads a single file into the destination directory
+// if the manifest entry does not specify a file name - it will fallback
+// to the hash of the file as a filename
+func (c *Client) DownloadFile(hash, path, dest string) error {
+ hasDestinationFilename := false
+ if stat, err := os.Stat(dest); err == nil {
+ hasDestinationFilename = !stat.IsDir()
+ } else {
+ if os.IsNotExist(err) {
+ // does not exist - should be created
+ hasDestinationFilename = true
+ } else {
+ return fmt.Errorf("could not stat path: %v", err)
+ }
+ }
+
+ manifestList, err := c.List(hash, path)
+ if err != nil {
+ return fmt.Errorf("could not list manifest: %v", err)
+ }
+
+ switch len(manifestList.Entries) {
+ case 0:
+ return fmt.Errorf("could not find path requested at manifest address. make sure the path you've specified is correct")
+ case 1:
+ //continue
+ default:
+ return fmt.Errorf("got too many matches for this path")
+ }
+
+ uri := c.Gateway + "/bzz:/" + hash + "/" + path
+ req, err := http.NewRequest("GET", uri, nil)
+ if err != nil {
+ return err
+ }
+ res, err := http.DefaultClient.Do(req)
+ if err != nil {
+ return err
+ }
+ defer res.Body.Close()
+
+ if res.StatusCode != http.StatusOK {
+ return fmt.Errorf("unexpected HTTP status: expected 200 OK, got %d", res.StatusCode)
+ }
+ filename := ""
+ if hasDestinationFilename {
+ filename = dest
+ } else {
+ // try to assert
+ re := regexp.MustCompile("[^/]+$") //everything after last slash
+
+ if results := re.FindAllString(path, -1); len(results) > 0 {
+ filename = results[len(results)-1]
+ } else {
+ if entry := manifestList.Entries[0]; entry.Path != "" && entry.Path != "/" {
+ filename = entry.Path
+ } else {
+ // assume hash as name if there's nothing from the command line
+ filename = hash
+ }
+ }
+ filename = filepath.Join(dest, filename)
+ }
+ filePath, err := filepath.Abs(filename)
+ if err != nil {
+ return err
+ }
+
+ if err := os.MkdirAll(filepath.Dir(filePath), 0777); err != nil {
+ return err
+ }
+
+ dst, err := os.Create(filename)
+ if err != nil {
+ return err
+ }
+ defer dst.Close()
+
+ _, err = io.Copy(dst, res.Body)
+ return err
+}
+
// UploadManifest uploads the given manifest to swarm
-func (c *Client) UploadManifest(m *api.Manifest) (string, error) {
+func (c *Client) UploadManifest(m *api.Manifest, toEncrypt bool) (string, error) {
data, err := json.Marshal(m)
if err != nil {
return "", err
}
- return c.UploadRaw(bytes.NewReader(data), int64(len(data)))
+ return c.UploadRaw(bytes.NewReader(data), int64(len(data)), toEncrypt)
}
// DownloadManifest downloads a swarm manifest
-func (c *Client) DownloadManifest(hash string) (*api.Manifest, error) {
- res, err := c.DownloadRaw(hash)
+func (c *Client) DownloadManifest(hash string) (*api.Manifest, bool, error) {
+ res, isEncrypted, err := c.DownloadRaw(hash)
if err != nil {
- return nil, err
+ return nil, isEncrypted, err
}
defer res.Close()
var manifest api.Manifest
if err := json.NewDecoder(res).Decode(&manifest); err != nil {
- return nil, err
+ return nil, isEncrypted, err
}
- return &manifest, nil
+ return &manifest, isEncrypted, nil
}
// List list files in a swarm manifest which have the given prefix, grouping
@@ -350,10 +440,19 @@ type UploadFn func(file *File) error
// TarUpload uses the given Uploader to upload files to swarm as a tar stream,
// returning the resulting manifest hash
-func (c *Client) TarUpload(hash string, uploader Uploader) (string, error) {
+func (c *Client) TarUpload(hash string, uploader Uploader, toEncrypt bool) (string, error) {
reqR, reqW := io.Pipe()
defer reqR.Close()
- req, err := http.NewRequest("POST", c.Gateway+"/bzz:/"+hash, reqR)
+ addr := hash
+
+ // If there is a hash already (a manifest), then that manifest will determine if the upload has
+ // to be encrypted or not. If there is no manifest then the toEncrypt parameter decides if
+ // there is encryption or not.
+ if hash == "" && toEncrypt {
+ // This is the built-in address for the encrypted upload endpoint
+ addr = "encrypt"
+ }
+ req, err := http.NewRequest("POST", c.Gateway+"/bzz:/"+addr, reqR)
if err != nil {
return "", err
}
diff --git a/swarm/api/client/client_test.go b/swarm/api/client/client_test.go
index c1d144e37..a878bff17 100644
--- a/swarm/api/client/client_test.go
+++ b/swarm/api/client/client_test.go
@@ -26,28 +26,43 @@ import (
"testing"
"github.com/ethereum/go-ethereum/swarm/api"
+ swarmhttp "github.com/ethereum/go-ethereum/swarm/api/http"
"github.com/ethereum/go-ethereum/swarm/testutil"
)
+func serverFunc(api *api.API) testutil.TestServer {
+ return swarmhttp.NewServer(api)
+}
+
// TestClientUploadDownloadRaw test uploading and downloading raw data to swarm
func TestClientUploadDownloadRaw(t *testing.T) {
- srv := testutil.NewTestSwarmServer(t)
+ testClientUploadDownloadRaw(false, t)
+}
+func TestClientUploadDownloadRawEncrypted(t *testing.T) {
+ testClientUploadDownloadRaw(true, t)
+}
+
+func testClientUploadDownloadRaw(toEncrypt bool, t *testing.T) {
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
defer srv.Close()
client := NewClient(srv.URL)
// upload some raw data
data := []byte("foo123")
- hash, err := client.UploadRaw(bytes.NewReader(data), int64(len(data)))
+ hash, err := client.UploadRaw(bytes.NewReader(data), int64(len(data)), toEncrypt)
if err != nil {
t.Fatal(err)
}
// check we can download the same data
- res, err := client.DownloadRaw(hash)
+ res, isEncrypted, err := client.DownloadRaw(hash)
if err != nil {
t.Fatal(err)
}
+ if isEncrypted != toEncrypt {
+ t.Fatalf("Expected encyption status %v got %v", toEncrypt, isEncrypted)
+ }
defer res.Close()
gotData, err := ioutil.ReadAll(res)
if err != nil {
@@ -61,7 +76,15 @@ func TestClientUploadDownloadRaw(t *testing.T) {
// TestClientUploadDownloadFiles test uploading and downloading files to swarm
// manifests
func TestClientUploadDownloadFiles(t *testing.T) {
- srv := testutil.NewTestSwarmServer(t)
+ testClientUploadDownloadFiles(false, t)
+}
+
+func TestClientUploadDownloadFilesEncrypted(t *testing.T) {
+ testClientUploadDownloadFiles(true, t)
+}
+
+func testClientUploadDownloadFiles(toEncrypt bool, t *testing.T) {
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
defer srv.Close()
client := NewClient(srv.URL)
@@ -74,7 +97,7 @@ func TestClientUploadDownloadFiles(t *testing.T) {
Size: int64(len(data)),
},
}
- hash, err := client.Upload(file, manifest)
+ hash, err := client.Upload(file, manifest, toEncrypt)
if err != nil {
t.Fatal(err)
}
@@ -159,7 +182,7 @@ func newTestDirectory(t *testing.T) string {
// TestClientUploadDownloadDirectory tests uploading and downloading a
// directory of files to a swarm manifest
func TestClientUploadDownloadDirectory(t *testing.T) {
- srv := testutil.NewTestSwarmServer(t)
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
defer srv.Close()
dir := newTestDirectory(t)
@@ -168,7 +191,7 @@ func TestClientUploadDownloadDirectory(t *testing.T) {
// upload the directory
client := NewClient(srv.URL)
defaultPath := filepath.Join(dir, testDirFiles[0])
- hash, err := client.UploadDirectory(dir, defaultPath, "")
+ hash, err := client.UploadDirectory(dir, defaultPath, "", false)
if err != nil {
t.Fatalf("error uploading directory: %s", err)
}
@@ -217,14 +240,22 @@ func TestClientUploadDownloadDirectory(t *testing.T) {
// TestClientFileList tests listing files in a swarm manifest
func TestClientFileList(t *testing.T) {
- srv := testutil.NewTestSwarmServer(t)
+ testClientFileList(false, t)
+}
+
+func TestClientFileListEncrypted(t *testing.T) {
+ testClientFileList(true, t)
+}
+
+func testClientFileList(toEncrypt bool, t *testing.T) {
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
defer srv.Close()
dir := newTestDirectory(t)
defer os.RemoveAll(dir)
client := NewClient(srv.URL)
- hash, err := client.UploadDirectory(dir, "", "")
+ hash, err := client.UploadDirectory(dir, "", "", toEncrypt)
if err != nil {
t.Fatalf("error uploading directory: %s", err)
}
@@ -275,7 +306,7 @@ func TestClientFileList(t *testing.T) {
// TestClientMultipartUpload tests uploading files to swarm using a multipart
// upload
func TestClientMultipartUpload(t *testing.T) {
- srv := testutil.NewTestSwarmServer(t)
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
defer srv.Close()
// define an uploader which uploads testDirFiles with some data
diff --git a/swarm/api/config.go b/swarm/api/config.go
index 6b224140a..939285e09 100644
--- a/swarm/api/config.go
+++ b/swarm/api/config.go
@@ -21,13 +21,16 @@ import (
"fmt"
"os"
"path/filepath"
+ "time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/contracts/ens"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
+ "github.com/ethereum/go-ethereum/p2p/discover"
+ "github.com/ethereum/go-ethereum/swarm/log"
"github.com/ethereum/go-ethereum/swarm/network"
+ "github.com/ethereum/go-ethereum/swarm/pss"
"github.com/ethereum/go-ethereum/swarm/services/swap"
"github.com/ethereum/go-ethereum/swarm/storage"
)
@@ -41,47 +44,55 @@ const (
// allow several bzz nodes running in parallel
type Config struct {
// serialised/persisted fields
- *storage.StoreParams
- *storage.ChunkerParams
+ *storage.FileStoreParams
+ *storage.LocalStoreParams
*network.HiveParams
- Swap *swap.SwapParams
- *network.SyncParams
- Contract common.Address
- EnsRoot common.Address
- EnsAPIs []string
- Path string
- ListenAddr string
- Port string
- PublicKey string
- BzzKey string
- NetworkId uint64
- SwapEnabled bool
- SyncEnabled bool
- SwapApi string
- Cors string
- BzzAccount string
- BootNodes string
+ Swap *swap.LocalProfile
+ Pss *pss.PssParams
+ //*network.SyncParams
+ Contract common.Address
+ EnsRoot common.Address
+ EnsAPIs []string
+ Path string
+ ListenAddr string
+ Port string
+ PublicKey string
+ BzzKey string
+ NodeID string
+ NetworkID uint64
+ SwapEnabled bool
+ SyncEnabled bool
+ DeliverySkipCheck bool
+ SyncUpdateDelay time.Duration
+ SwapAPI string
+ Cors string
+ BzzAccount string
+ BootNodes string
+ privateKey *ecdsa.PrivateKey
}
//create a default config with all parameters to set to defaults
-func NewDefaultConfig() (self *Config) {
-
- self = &Config{
- StoreParams: storage.NewDefaultStoreParams(),
- ChunkerParams: storage.NewChunkerParams(),
- HiveParams: network.NewDefaultHiveParams(),
- SyncParams: network.NewDefaultSyncParams(),
- Swap: swap.NewDefaultSwapParams(),
- ListenAddr: DefaultHTTPListenAddr,
- Port: DefaultHTTPPort,
- Path: node.DefaultDataDir(),
- EnsAPIs: nil,
- EnsRoot: ens.TestNetAddress,
- NetworkId: network.NetworkId,
- SwapEnabled: false,
- SyncEnabled: true,
- SwapApi: "",
- BootNodes: "",
+func NewConfig() (c *Config) {
+
+ c = &Config{
+ LocalStoreParams: storage.NewDefaultLocalStoreParams(),
+ FileStoreParams: storage.NewFileStoreParams(),
+ HiveParams: network.NewHiveParams(),
+ //SyncParams: network.NewDefaultSyncParams(),
+ Swap: swap.NewDefaultSwapParams(),
+ Pss: pss.NewPssParams(),
+ ListenAddr: DefaultHTTPListenAddr,
+ Port: DefaultHTTPPort,
+ Path: node.DefaultDataDir(),
+ EnsAPIs: nil,
+ EnsRoot: ens.TestNetAddress,
+ NetworkID: network.DefaultNetworkID,
+ SwapEnabled: false,
+ SyncEnabled: true,
+ DeliverySkipCheck: false,
+ SyncUpdateDelay: 15 * time.Second,
+ SwapAPI: "",
+ BootNodes: "",
}
return
@@ -89,11 +100,11 @@ func NewDefaultConfig() (self *Config) {
//some config params need to be initialized after the complete
//config building phase is completed (e.g. due to overriding flags)
-func (self *Config) Init(prvKey *ecdsa.PrivateKey) {
+func (c *Config) Init(prvKey *ecdsa.PrivateKey) {
address := crypto.PubkeyToAddress(prvKey.PublicKey)
- self.Path = filepath.Join(self.Path, "bzz-"+common.Bytes2Hex(address.Bytes()))
- err := os.MkdirAll(self.Path, os.ModePerm)
+ c.Path = filepath.Join(c.Path, "bzz-"+common.Bytes2Hex(address.Bytes()))
+ err := os.MkdirAll(c.Path, os.ModePerm)
if err != nil {
log.Error(fmt.Sprintf("Error creating root swarm data directory: %v", err))
return
@@ -103,11 +114,25 @@ func (self *Config) Init(prvKey *ecdsa.PrivateKey) {
pubkeyhex := common.ToHex(pubkey)
keyhex := crypto.Keccak256Hash(pubkey).Hex()
- self.PublicKey = pubkeyhex
- self.BzzKey = keyhex
+ c.PublicKey = pubkeyhex
+ c.BzzKey = keyhex
+ c.NodeID = discover.PubkeyID(&prvKey.PublicKey).String()
+
+ if c.SwapEnabled {
+ c.Swap.Init(c.Contract, prvKey)
+ }
+
+ c.privateKey = prvKey
+ c.LocalStoreParams.Init(c.Path)
+ c.LocalStoreParams.BaseKey = common.FromHex(keyhex)
- self.Swap.Init(self.Contract, prvKey)
- self.SyncParams.Init(self.Path)
- self.HiveParams.Init(self.Path)
- self.StoreParams.Init(self.Path)
+ c.Pss = c.Pss.WithPrivateKey(c.privateKey)
+}
+
+func (c *Config) ShiftPrivateKey() (privKey *ecdsa.PrivateKey) {
+ if c.privateKey != nil {
+ privKey = c.privateKey
+ c.privateKey = nil
+ }
+ return privKey
}
diff --git a/swarm/api/config_test.go b/swarm/api/config_test.go
index 5636b6daf..bd7e1d870 100644
--- a/swarm/api/config_test.go
+++ b/swarm/api/config_test.go
@@ -33,9 +33,10 @@ func TestConfig(t *testing.T) {
t.Fatalf("failed to load private key: %v", err)
}
- one := NewDefaultConfig()
- two := NewDefaultConfig()
+ one := NewConfig()
+ two := NewConfig()
+ one.LocalStoreParams = two.LocalStoreParams
if equal := reflect.DeepEqual(one, two); !equal {
t.Fatal("Two default configs are not equal")
}
@@ -49,21 +50,10 @@ func TestConfig(t *testing.T) {
if one.PublicKey == "" {
t.Fatal("Expected PublicKey to be set")
}
-
- //the Init function should append subdirs to the given path
- if one.Swap.PayProfile.Beneficiary == (common.Address{}) {
+ if one.Swap.PayProfile.Beneficiary == (common.Address{}) && one.SwapEnabled {
t.Fatal("Failed to correctly initialize SwapParams")
}
-
- if one.SyncParams.RequestDbPath == one.Path {
- t.Fatal("Failed to correctly initialize SyncParams")
- }
-
- if one.HiveParams.KadDbPath == one.Path {
- t.Fatal("Failed to correctly initialize HiveParams")
- }
-
- if one.StoreParams.ChunkDbPath == one.Path {
+ if one.ChunkDbPath == one.Path {
t.Fatal("Failed to correctly initialize StoreParams")
}
}
diff --git a/swarm/api/filesystem.go b/swarm/api/filesystem.go
index f5dc90e2e..297cbec79 100644
--- a/swarm/api/filesystem.go
+++ b/swarm/api/filesystem.go
@@ -27,26 +27,27 @@ import (
"sync"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/ethereum/go-ethereum/swarm/log"
"github.com/ethereum/go-ethereum/swarm/storage"
)
const maxParallelFiles = 5
type FileSystem struct {
- api *Api
+ api *API
}
-func NewFileSystem(api *Api) *FileSystem {
+func NewFileSystem(api *API) *FileSystem {
return &FileSystem{api}
}
// Upload replicates a local directory as a manifest file and uploads it
-// using dpa store
+// using FileStore store
+// This function waits the chunks to be stored.
// TODO: localpath should point to a manifest
//
// DEPRECATED: Use the HTTP API instead
-func (self *FileSystem) Upload(lpath, index string) (string, error) {
+func (fs *FileSystem) Upload(lpath, index string, toEncrypt bool) (string, error) {
var list []*manifestTrieEntry
localpath, err := filepath.Abs(filepath.Clean(lpath))
if err != nil {
@@ -111,13 +112,13 @@ func (self *FileSystem) Upload(lpath, index string) (string, error) {
f, err := os.Open(entry.Path)
if err == nil {
stat, _ := f.Stat()
- var hash storage.Key
- wg := &sync.WaitGroup{}
- hash, err = self.api.dpa.Store(f, stat.Size(), wg, nil)
+ var hash storage.Address
+ var wait func()
+ hash, wait, err = fs.api.fileStore.Store(f, stat.Size(), toEncrypt)
if hash != nil {
- list[i].Hash = hash.String()
+ list[i].Hash = hash.Hex()
}
- wg.Wait()
+ wait()
awg.Done()
if err == nil {
first512 := make([]byte, 512)
@@ -142,7 +143,7 @@ func (self *FileSystem) Upload(lpath, index string) (string, error) {
}
trie := &manifestTrie{
- dpa: self.api.dpa,
+ fileStore: fs.api.fileStore,
}
quitC := make(chan bool)
for i, entry := range list {
@@ -163,7 +164,7 @@ func (self *FileSystem) Upload(lpath, index string) (string, error) {
err2 := trie.recalcAndStore()
var hs string
if err2 == nil {
- hs = trie.hash.String()
+ hs = trie.ref.Hex()
}
awg.Wait()
return hs, err2
@@ -173,7 +174,7 @@ func (self *FileSystem) Upload(lpath, index string) (string, error) {
// under localpath
//
// DEPRECATED: Use the HTTP API instead
-func (self *FileSystem) Download(bzzpath, localpath string) error {
+func (fs *FileSystem) Download(bzzpath, localpath string) error {
lpath, err := filepath.Abs(filepath.Clean(localpath))
if err != nil {
return err
@@ -188,7 +189,7 @@ func (self *FileSystem) Download(bzzpath, localpath string) error {
if err != nil {
return err
}
- key, err := self.api.Resolve(uri)
+ addr, err := fs.api.Resolve(uri)
if err != nil {
return err
}
@@ -199,14 +200,14 @@ func (self *FileSystem) Download(bzzpath, localpath string) error {
}
quitC := make(chan bool)
- trie, err := loadManifest(self.api.dpa, key, quitC)
+ trie, err := loadManifest(fs.api.fileStore, addr, quitC)
if err != nil {
log.Warn(fmt.Sprintf("fs.Download: loadManifestTrie error: %v", err))
return err
}
type downloadListEntry struct {
- key storage.Key
+ addr storage.Address
path string
}
@@ -217,7 +218,7 @@ func (self *FileSystem) Download(bzzpath, localpath string) error {
err = trie.listWithPrefix(path, quitC, func(entry *manifestTrieEntry, suffix string) {
log.Trace(fmt.Sprintf("fs.Download: %#v", entry))
- key = common.Hex2Bytes(entry.Hash)
+ addr = common.Hex2Bytes(entry.Hash)
path := lpath + "/" + suffix
dir := filepath.Dir(path)
if dir != prevPath {
@@ -225,7 +226,7 @@ func (self *FileSystem) Download(bzzpath, localpath string) error {
prevPath = dir
}
if (mde == nil) && (path != dir+"/") {
- list = append(list, &downloadListEntry{key: key, path: path})
+ list = append(list, &downloadListEntry{addr: addr, path: path})
}
})
if err != nil {
@@ -244,7 +245,7 @@ func (self *FileSystem) Download(bzzpath, localpath string) error {
}
go func(i int, entry *downloadListEntry) {
defer wg.Done()
- err := retrieveToFile(quitC, self.api.dpa, entry.key, entry.path)
+ err := retrieveToFile(quitC, fs.api.fileStore, entry.addr, entry.path)
if err != nil {
select {
case errC <- err:
@@ -267,12 +268,12 @@ func (self *FileSystem) Download(bzzpath, localpath string) error {
}
}
-func retrieveToFile(quitC chan bool, dpa *storage.DPA, key storage.Key, path string) error {
+func retrieveToFile(quitC chan bool, fileStore *storage.FileStore, addr storage.Address, path string) error {
f, err := os.Create(path) // TODO: basePath separators
if err != nil {
return err
}
- reader := dpa.Retrieve(key)
+ reader, _ := fileStore.Retrieve(addr)
writer := bufio.NewWriter(f)
size, err := reader.Size(quitC)
if err != nil {
diff --git a/swarm/api/filesystem_test.go b/swarm/api/filesystem_test.go
index 8a15e735d..915dc4e0b 100644
--- a/swarm/api/filesystem_test.go
+++ b/swarm/api/filesystem_test.go
@@ -21,7 +21,6 @@ import (
"io/ioutil"
"os"
"path/filepath"
- "sync"
"testing"
"github.com/ethereum/go-ethereum/common"
@@ -30,9 +29,9 @@ import (
var testDownloadDir, _ = ioutil.TempDir(os.TempDir(), "bzz-test")
-func testFileSystem(t *testing.T, f func(*FileSystem)) {
- testApi(t, func(api *Api) {
- f(NewFileSystem(api))
+func testFileSystem(t *testing.T, f func(*FileSystem, bool)) {
+ testAPI(t, func(api *API, toEncrypt bool) {
+ f(NewFileSystem(api), toEncrypt)
})
}
@@ -47,9 +46,9 @@ func readPath(t *testing.T, parts ...string) string {
}
func TestApiDirUpload0(t *testing.T) {
- testFileSystem(t, func(fs *FileSystem) {
+ testFileSystem(t, func(fs *FileSystem, toEncrypt bool) {
api := fs.api
- bzzhash, err := fs.Upload(filepath.Join("testdata", "test0"), "")
+ bzzhash, err := fs.Upload(filepath.Join("testdata", "test0"), "", toEncrypt)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
@@ -63,8 +62,8 @@ func TestApiDirUpload0(t *testing.T) {
exp = expResponse(content, "text/css", 0)
checkResponse(t, resp, exp)
- key := storage.Key(common.Hex2Bytes(bzzhash))
- _, _, _, err = api.Get(key, "")
+ addr := storage.Address(common.Hex2Bytes(bzzhash))
+ _, _, _, _, err = api.Get(addr, "")
if err == nil {
t.Fatalf("expected error: %v", err)
}
@@ -75,27 +74,28 @@ func TestApiDirUpload0(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
- newbzzhash, err := fs.Upload(downloadDir, "")
+ newbzzhash, err := fs.Upload(downloadDir, "", toEncrypt)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
- if bzzhash != newbzzhash {
+ // TODO: currently the hash is not deterministic in the encrypted case
+ if !toEncrypt && bzzhash != newbzzhash {
t.Fatalf("download %v reuploaded has incorrect hash, expected %v, got %v", downloadDir, bzzhash, newbzzhash)
}
})
}
func TestApiDirUploadModify(t *testing.T) {
- testFileSystem(t, func(fs *FileSystem) {
+ testFileSystem(t, func(fs *FileSystem, toEncrypt bool) {
api := fs.api
- bzzhash, err := fs.Upload(filepath.Join("testdata", "test0"), "")
+ bzzhash, err := fs.Upload(filepath.Join("testdata", "test0"), "", toEncrypt)
if err != nil {
t.Errorf("unexpected error: %v", err)
return
}
- key := storage.Key(common.Hex2Bytes(bzzhash))
- key, err = api.Modify(key, "index.html", "", "")
+ addr := storage.Address(common.Hex2Bytes(bzzhash))
+ addr, err = api.Modify(addr, "index.html", "", "")
if err != nil {
t.Errorf("unexpected error: %v", err)
return
@@ -105,24 +105,23 @@ func TestApiDirUploadModify(t *testing.T) {
t.Errorf("unexpected error: %v", err)
return
}
- wg := &sync.WaitGroup{}
- hash, err := api.Store(bytes.NewReader(index), int64(len(index)), wg)
- wg.Wait()
+ hash, wait, err := api.Store(bytes.NewReader(index), int64(len(index)), toEncrypt)
+ wait()
if err != nil {
t.Errorf("unexpected error: %v", err)
return
}
- key, err = api.Modify(key, "index2.html", hash.Hex(), "text/html; charset=utf-8")
+ addr, err = api.Modify(addr, "index2.html", hash.Hex(), "text/html; charset=utf-8")
if err != nil {
t.Errorf("unexpected error: %v", err)
return
}
- key, err = api.Modify(key, "img/logo.png", hash.Hex(), "text/html; charset=utf-8")
+ addr, err = api.Modify(addr, "img/logo.png", hash.Hex(), "text/html; charset=utf-8")
if err != nil {
t.Errorf("unexpected error: %v", err)
return
}
- bzzhash = key.String()
+ bzzhash = addr.Hex()
content := readPath(t, "testdata", "test0", "index.html")
resp := testGet(t, api, bzzhash, "index2.html")
@@ -138,7 +137,7 @@ func TestApiDirUploadModify(t *testing.T) {
exp = expResponse(content, "text/css", 0)
checkResponse(t, resp, exp)
- _, _, _, err = api.Get(key, "")
+ _, _, _, _, err = api.Get(addr, "")
if err == nil {
t.Errorf("expected error: %v", err)
}
@@ -146,9 +145,9 @@ func TestApiDirUploadModify(t *testing.T) {
}
func TestApiDirUploadWithRootFile(t *testing.T) {
- testFileSystem(t, func(fs *FileSystem) {
+ testFileSystem(t, func(fs *FileSystem, toEncrypt bool) {
api := fs.api
- bzzhash, err := fs.Upload(filepath.Join("testdata", "test0"), "index.html")
+ bzzhash, err := fs.Upload(filepath.Join("testdata", "test0"), "index.html", toEncrypt)
if err != nil {
t.Errorf("unexpected error: %v", err)
return
@@ -162,9 +161,9 @@ func TestApiDirUploadWithRootFile(t *testing.T) {
}
func TestApiFileUpload(t *testing.T) {
- testFileSystem(t, func(fs *FileSystem) {
+ testFileSystem(t, func(fs *FileSystem, toEncrypt bool) {
api := fs.api
- bzzhash, err := fs.Upload(filepath.Join("testdata", "test0", "index.html"), "")
+ bzzhash, err := fs.Upload(filepath.Join("testdata", "test0", "index.html"), "", toEncrypt)
if err != nil {
t.Errorf("unexpected error: %v", err)
return
@@ -178,9 +177,9 @@ func TestApiFileUpload(t *testing.T) {
}
func TestApiFileUploadWithRootFile(t *testing.T) {
- testFileSystem(t, func(fs *FileSystem) {
+ testFileSystem(t, func(fs *FileSystem, toEncrypt bool) {
api := fs.api
- bzzhash, err := fs.Upload(filepath.Join("testdata", "test0", "index.html"), "index.html")
+ bzzhash, err := fs.Upload(filepath.Join("testdata", "test0", "index.html"), "index.html", toEncrypt)
if err != nil {
t.Errorf("unexpected error: %v", err)
return
diff --git a/swarm/api/http/error.go b/swarm/api/http/error.go
index 9a65412cf..5fff7575e 100644
--- a/swarm/api/http/error.go
+++ b/swarm/api/http/error.go
@@ -31,6 +31,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/swarm/api"
+ l "github.com/ethereum/go-ethereum/swarm/log"
)
//templateMap holds a mapping of an HTTP error code to a template
@@ -44,7 +45,7 @@ var (
)
//parameters needed for formatting the correct HTML page
-type ErrorParams struct {
+type ResponseParams struct {
Msg string
Code int
Timestamp string
@@ -113,45 +114,49 @@ func ValidateCaseErrors(r *Request) string {
//For example, if the user requests bzz:/<hash>/read and that manifest contains entries
//"readme.md" and "readinglist.txt", a HTML page is returned with this two links.
//This only applies if the manifest has no default entry
-func ShowMultipleChoices(w http.ResponseWriter, r *Request, list api.ManifestList) {
+func ShowMultipleChoices(w http.ResponseWriter, req *Request, list api.ManifestList) {
msg := ""
if list.Entries == nil {
- ShowError(w, r, "Could not resolve", http.StatusInternalServerError)
+ Respond(w, req, "Could not resolve", http.StatusInternalServerError)
return
}
//make links relative
//requestURI comes with the prefix of the ambiguous path, e.g. "read" for "readme.md" and "readinglist.txt"
//to get clickable links, need to remove the ambiguous path, i.e. "read"
- idx := strings.LastIndex(r.RequestURI, "/")
+ idx := strings.LastIndex(req.RequestURI, "/")
if idx == -1 {
- ShowError(w, r, "Internal Server Error", http.StatusInternalServerError)
+ Respond(w, req, "Internal Server Error", http.StatusInternalServerError)
return
}
//remove ambiguous part
- base := r.RequestURI[:idx+1]
+ base := req.RequestURI[:idx+1]
for _, e := range list.Entries {
//create clickable link for each entry
msg += "<a href='" + base + e.Path + "'>" + e.Path + "</a><br/>"
}
- respond(w, &r.Request, &ErrorParams{
- Code: http.StatusMultipleChoices,
- Details: template.HTML(msg),
- Timestamp: time.Now().Format(time.RFC1123),
- template: getTemplate(http.StatusMultipleChoices),
- })
+ Respond(w, req, msg, http.StatusMultipleChoices)
}
-//ShowError is used to show an HTML error page to a client.
+//Respond is used to show an HTML page to a client.
//If there is an `Accept` header of `application/json`, JSON will be returned instead
//The function just takes a string message which will be displayed in the error page.
//The code is used to evaluate which template will be displayed
//(and return the correct HTTP status code)
-func ShowError(w http.ResponseWriter, r *Request, msg string, code int) {
- additionalMessage := ValidateCaseErrors(r)
- if code == http.StatusInternalServerError {
- log.Error(msg)
+func Respond(w http.ResponseWriter, req *Request, msg string, code int) {
+ additionalMessage := ValidateCaseErrors(req)
+ switch code {
+ case http.StatusInternalServerError:
+ log.Output(msg, log.LvlError, l.CallDepth, "ruid", req.ruid, "code", code)
+ default:
+ log.Output(msg, log.LvlDebug, l.CallDepth, "ruid", req.ruid, "code", code)
+ }
+
+ if code >= 400 {
+ w.Header().Del("Cache-Control") //avoid sending cache headers for errors!
+ w.Header().Del("ETag")
}
- respond(w, &r.Request, &ErrorParams{
+
+ respond(w, &req.Request, &ResponseParams{
Code: code,
Msg: msg,
Details: template.HTML(additionalMessage),
@@ -161,17 +166,17 @@ func ShowError(w http.ResponseWriter, r *Request, msg string, code int) {
}
//evaluate if client accepts html or json response
-func respond(w http.ResponseWriter, r *http.Request, params *ErrorParams) {
+func respond(w http.ResponseWriter, r *http.Request, params *ResponseParams) {
w.WriteHeader(params.Code)
if r.Header.Get("Accept") == "application/json" {
- respondJson(w, params)
+ respondJSON(w, params)
} else {
- respondHtml(w, params)
+ respondHTML(w, params)
}
}
//return a HTML page
-func respondHtml(w http.ResponseWriter, params *ErrorParams) {
+func respondHTML(w http.ResponseWriter, params *ResponseParams) {
htmlCounter.Inc(1)
err := params.template.Execute(w, params)
if err != nil {
@@ -180,7 +185,7 @@ func respondHtml(w http.ResponseWriter, params *ErrorParams) {
}
//return JSON
-func respondJson(w http.ResponseWriter, params *ErrorParams) {
+func respondJSON(w http.ResponseWriter, params *ResponseParams) {
jsonCounter.Inc(1)
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(params)
@@ -190,7 +195,6 @@ func respondJson(w http.ResponseWriter, params *ErrorParams) {
func getTemplate(code int) *template.Template {
if val, tmpl := templateMap[code]; tmpl {
return val
- } else {
- return templateMap[0]
}
+ return templateMap[0]
}
diff --git a/swarm/api/http/error_templates.go b/swarm/api/http/error_templates.go
index cc9b996ba..f3c643c90 100644
--- a/swarm/api/http/error_templates.go
+++ b/swarm/api/http/error_templates.go
@@ -36,7 +36,6 @@ func GetGenericErrorPage() string {
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" ww="chrome=1">
<meta name="description" content="Ethereum/Swarm error page">
- <meta property="og:url" content="https://swarm-gateways.net/bzz:/theswarm.eth">
<link rel="shortcut icon" type="image/x-icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHsAAAB5CAYAAAAZD150AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAAFzFJREFUeAHtnXuwJFV9x7vnzrKwIC95w/ImYFkxlZgiGswCIiCGxPhHCEIwmIemUqYwJkYrJmXlUZRa+IpAWYYEk4qJD4gJGAmoiBIxMQFRQCkXdhdCeL+fYdk7nc+ne87dvnPn0TPTPdNzmd/W2X6fc76/7/n9zjm/PrcniuYy18BcA3MNzDUw18BcA3MNzDUw18BcA3MNrGYNLERroyMAeNQ0QcbTLPxFUfaOOx4Wbd12ThRHp0TJ4s5RFF8RtVoXg/2BSeOfk12lxtc0fjva1jibItZEDf4li3u3i3sqipOPRIvRp6ssvjPvhc4Tq/y4Ab71pEXS1oqw7hw1mz8XJc2LoiQ6iTJaaTkxth0l69jXwNayOZ10AvubSQ+RrFOl8mKy7EOiRuN3UfjrUfItUaN1SbQt+lqp2m02T4payS9HSfxK8k1IGdEWkln2Xuzldd7keBunrsO1f4r9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: 0.6;
- background-color: #A9F5BF;
+ background-color: #FCEFD3;
}
table {
@@ -193,7 +192,7 @@ func GetGenericErrorPage() string {
<footer>
<p>
Swarm: Serverless Hosting Incentivised Peer-To-Peer Storage And Content Distribution<br/>
- <a href="http://swarm-gateways.net/bzz:/theswarm.eth">Swarm</a>
+ <a href="/bzz:/theswarm.eth">Swarm</a>
</p>
</footer>
@@ -216,7 +215,6 @@ func GetNotFoundErrorPage() string {
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" ww="chrome=1">
<meta name="description" content="Ethereum/Swarm error page">
- <meta property="og:url" content="https://swarm-gateways.net/bzz:/theswarm.eth">
<link rel="shortcut icon" type="image/x-icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHsAAAB5CAYAAAAZD150AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAAFzFJREFUeAHtnXuwJFV9x7vnzrKwIC95w/ImYFkxlZgiGswCIiCGxPhHCEIwmIemUqYwJkYrJmXlUZRa+IpAWYYEk4qJD4gJGAmoiBI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WGYgpyv4SZAdCjZg8dPtgIUvJ5yqdZJtS+drDsknUMA32LdhzJKI8ZVgJA6RvoBpY1xGthiZORD4yYIiE8M4SbIDaX5o7lws4GWcIGacunEDF3yJKflvqP4o+1rGLMtOYPw1ML4cEASeEkfvvl8Qo4Gfj6X7/DdJmQbZAZ9BmRNQxOsIwX4XBVzBhR+Ei6tkG4IyjNxb38fqxwqKzLpOHLTtRRrwqnWmYYpx71WOcaYJmld+roG5BuYamGtgroG5BuYamJoG/h/ff6XOIB4wOAAAAABJRU5ErkJggg=="/>
<style>
@@ -273,7 +271,7 @@ func GetNotFoundErrorPage() string {
max-height: 60vh;
padding: 50px 20px;
opacity: 0.6;
- background-color: #A9F5BF;
+ background-color: #FCEFD3;
}
table {
@@ -373,7 +371,7 @@ func GetNotFoundErrorPage() string {
<footer>
<p>
Swarm: Serverless Hosting Incentivised Peer-To-Peer Storage And Content Distribution<br/>
- <a href="http://swarm-gateways.net/bzz:/theswarm.eth">Swarm</a>
+ <a href="/bzz:/theswarm.eth">Swarm</a>
</p>
</footer>
@@ -398,7 +396,6 @@ func GetMultipleChoicesErrorPage() string {
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" ww="chrome=1">
<meta name="description" content="Ethereum/Swarm multiple options page">
- <meta property="og:url" content="https://swarm-gateways.net/bzz:/theswarm.eth">
<link rel="shortcut icon" type="image/x-icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHsAAAB5CAYAAAAZD150AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW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gZjKQCkQNlWLLb9XWRQOufoffygSWUeUOzeQrlngLG3cjWuhTEOBTZASNz/hTjZWVBKI/srEZ74PY2MEA6ETW4wC7MXXvVdxiytWQV8CVIvpoMeQM1Fdm9jfG1xTEWJpspqG/VUozXgO6BMhGWTbZ1M8/dUMibaPgb2O/neoqQbX7+ZMNVjAr+in0HJkUsitsqE+u0axvj8ewPwDiQbPPjQz/Jl8F4Cfu+Ri0do4VUKUfT151Fte3P7fs6AXDcc57twIT+Me2XL2L/dlIdxV8mOruN0YhkF4w9yZ4oxqrJlhy/VXRstNg4GZs/hmNjukEh3ci2TmuJat2KO7sCm/kmx8MOinhkohIwGngSo3PfHMYVZOcxXtnGWGYgpyv4SZAdCjZg8dPtgIUvJ5yqdZJtS+drDsknUMA32LdhzJKI8ZVgJA6RvoBpY1xGthiZORD4yYIiE8M4SbIDaX5o7lws4GWcIGacunEDF3yJKflvqP4o+1rGLMtOYPw1ML4cEASeEkfvvl8Qo4Gfj6X7/DdJmQbZAZ9BmRNQxOsIwX4XBVzBhR+Ei6tkG4IyjNxb38fqxwqKzLpOHLTtRRrwqnWmYYpx71WOcaYJmld+roG5BuYamGtgroG5BuYamJoG/h/ff6XOIB4wOAAAAABJRU5ErkJggg=="/>
<style>
@@ -455,7 +452,7 @@ func GetMultipleChoicesErrorPage() string {
max-height: 60vh;
padding: 50px 20px;
opacity: 0.6;
- background-color: #A9F5BF;
+ background-color: #FCEFD3;
}
table {
@@ -550,7 +547,7 @@ func GetMultipleChoicesErrorPage() string {
<footer>
<p>
Swarm: Serverless Hosting Incentivised Peer-To-Peer Storage And Content Distribution<br/>
- <a href="http://swarm-gateways.net/bzz:/theswarm.eth">Swarm</a>
+ <a href="/bzz:/theswarm.eth">Swarm</a>
</p>
</footer>
diff --git a/swarm/api/http/error_test.go b/swarm/api/http/error_test.go
index dc545722e..86eff86b2 100644
--- a/swarm/api/http/error_test.go
+++ b/swarm/api/http/error_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-package http_test
+package http
import (
"encoding/json"
@@ -30,7 +30,7 @@ import (
func TestError(t *testing.T) {
- srv := testutil.NewTestSwarmServer(t)
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
defer srv.Close()
var resp *http.Response
@@ -56,7 +56,7 @@ func TestError(t *testing.T) {
}
func Test404Page(t *testing.T) {
- srv := testutil.NewTestSwarmServer(t)
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
defer srv.Close()
var resp *http.Response
@@ -82,7 +82,7 @@ func Test404Page(t *testing.T) {
}
func Test500Page(t *testing.T) {
- srv := testutil.NewTestSwarmServer(t)
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
defer srv.Close()
var resp *http.Response
@@ -107,7 +107,7 @@ func Test500Page(t *testing.T) {
}
}
func Test500PageWith0xHashPrefix(t *testing.T) {
- srv := testutil.NewTestSwarmServer(t)
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
defer srv.Close()
var resp *http.Response
@@ -137,7 +137,7 @@ func Test500PageWith0xHashPrefix(t *testing.T) {
}
func TestJsonResponse(t *testing.T) {
- srv := testutil.NewTestSwarmServer(t)
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
defer srv.Close()
var resp *http.Response
diff --git a/swarm/api/http/roundtripper.go b/swarm/api/http/roundtripper.go
index 019431771..be8ea3985 100644
--- a/swarm/api/http/roundtripper.go
+++ b/swarm/api/http/roundtripper.go
@@ -20,7 +20,7 @@ import (
"fmt"
"net/http"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/ethereum/go-ethereum/swarm/log"
)
/*
diff --git a/swarm/api/http/server.go b/swarm/api/http/server.go
index b8e7436cf..ba8b2b7ba 100644
--- a/swarm/api/http/server.go
+++ b/swarm/api/http/server.go
@@ -21,6 +21,8 @@ package http
import (
"archive/tar"
+ "bufio"
+ "bytes"
"encoding/json"
"errors"
"fmt"
@@ -31,39 +33,44 @@ import (
"net/http"
"os"
"path"
+ "regexp"
"strconv"
"strings"
"time"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/swarm/api"
+ "github.com/ethereum/go-ethereum/swarm/log"
"github.com/ethereum/go-ethereum/swarm/storage"
+ "github.com/ethereum/go-ethereum/swarm/storage/mru"
+ "github.com/pborman/uuid"
"github.com/rs/cors"
)
-//setup metrics
+type resourceResponse struct {
+ Manifest storage.Address `json:"manifest"`
+ Resource string `json:"resource"`
+ Update storage.Address `json:"update"`
+}
+
var (
- postRawCount = metrics.NewRegisteredCounter("api.http.post.raw.count", nil)
- postRawFail = metrics.NewRegisteredCounter("api.http.post.raw.fail", nil)
- postFilesCount = metrics.NewRegisteredCounter("api.http.post.files.count", nil)
- postFilesFail = metrics.NewRegisteredCounter("api.http.post.files.fail", nil)
- deleteCount = metrics.NewRegisteredCounter("api.http.delete.count", nil)
- deleteFail = metrics.NewRegisteredCounter("api.http.delete.fail", nil)
- getCount = metrics.NewRegisteredCounter("api.http.get.count", nil)
- getFail = metrics.NewRegisteredCounter("api.http.get.fail", nil)
- getFileCount = metrics.NewRegisteredCounter("api.http.get.file.count", nil)
- getFileNotFound = metrics.NewRegisteredCounter("api.http.get.file.notfound", nil)
- getFileFail = metrics.NewRegisteredCounter("api.http.get.file.fail", nil)
- getFilesCount = metrics.NewRegisteredCounter("api.http.get.files.count", nil)
- getFilesFail = metrics.NewRegisteredCounter("api.http.get.files.fail", nil)
- getListCount = metrics.NewRegisteredCounter("api.http.get.list.count", nil)
- getListFail = metrics.NewRegisteredCounter("api.http.get.list.fail", nil)
- requestCount = metrics.NewRegisteredCounter("http.request.count", nil)
- htmlRequestCount = metrics.NewRegisteredCounter("http.request.html.count", nil)
- jsonRequestCount = metrics.NewRegisteredCounter("http.request.json.count", nil)
- requestTimer = metrics.NewRegisteredResettingTimer("http.request.time", nil)
+ postRawCount = metrics.NewRegisteredCounter("api.http.post.raw.count", nil)
+ postRawFail = metrics.NewRegisteredCounter("api.http.post.raw.fail", nil)
+ postFilesCount = metrics.NewRegisteredCounter("api.http.post.files.count", nil)
+ postFilesFail = metrics.NewRegisteredCounter("api.http.post.files.fail", nil)
+ deleteCount = metrics.NewRegisteredCounter("api.http.delete.count", nil)
+ deleteFail = metrics.NewRegisteredCounter("api.http.delete.fail", nil)
+ getCount = metrics.NewRegisteredCounter("api.http.get.count", nil)
+ getFail = metrics.NewRegisteredCounter("api.http.get.fail", nil)
+ getFileCount = metrics.NewRegisteredCounter("api.http.get.file.count", nil)
+ getFileNotFound = metrics.NewRegisteredCounter("api.http.get.file.notfound", nil)
+ getFileFail = metrics.NewRegisteredCounter("api.http.get.file.fail", nil)
+ getFilesCount = metrics.NewRegisteredCounter("api.http.get.files.count", nil)
+ getFilesFail = metrics.NewRegisteredCounter("api.http.get.files.fail", nil)
+ getListCount = metrics.NewRegisteredCounter("api.http.get.list.count", nil)
+ getListFail = metrics.NewRegisteredCounter("api.http.get.list.fail", nil)
)
// ServerConfig is the basic configuration needed for the HTTP server and also
@@ -79,7 +86,7 @@ type ServerConfig struct {
// https://github.com/atom/electron/blob/master/docs/api/protocol.md
// starts up http server
-func StartHttpServer(api *api.Api, config *ServerConfig) {
+func StartHTTPServer(api *api.API, config *ServerConfig) {
var allowedOrigins []string
for _, domain := range strings.Split(config.CorsString, ",") {
allowedOrigins = append(allowedOrigins, strings.TrimSpace(domain))
@@ -95,82 +102,106 @@ func StartHttpServer(api *api.Api, config *ServerConfig) {
go http.ListenAndServe(config.Addr, hdlr)
}
-func NewServer(api *api.Api) *Server {
+func NewServer(api *api.API) *Server {
return &Server{api}
}
type Server struct {
- api *api.Api
+ api *api.API
}
// Request wraps http.Request and also includes the parsed bzz URI
type Request struct {
http.Request
- uri *api.URI
+ uri *api.URI
+ ruid string // request unique id
}
// HandlePostRaw handles a POST request to a raw bzz-raw:/ URI, stores the request
-// body in swarm and returns the resulting storage key as a text/plain response
+// body in swarm and returns the resulting storage address as a text/plain response
func (s *Server) HandlePostRaw(w http.ResponseWriter, r *Request) {
+ log.Debug("handle.post.raw", "ruid", r.ruid)
+
postRawCount.Inc(1)
+
+ toEncrypt := false
+ if r.uri.Addr == "encrypt" {
+ toEncrypt = true
+ }
+
if r.uri.Path != "" {
postRawFail.Inc(1)
- s.BadRequest(w, r, "raw POST request cannot contain a path")
+ Respond(w, r, "raw POST request cannot contain a path", http.StatusBadRequest)
return
}
- if r.Header.Get("Content-Length") == "" {
+ if r.uri.Addr != "" && r.uri.Addr != "encrypt" {
postRawFail.Inc(1)
- s.BadRequest(w, r, "missing Content-Length header in request")
+ Respond(w, r, "raw POST request addr can only be empty or \"encrypt\"", http.StatusBadRequest)
return
}
- key, err := s.api.Store(r.Body, r.ContentLength, nil)
+ if r.Header.Get("Content-Length") == "" {
+ postRawFail.Inc(1)
+ Respond(w, r, "missing Content-Length header in request", http.StatusBadRequest)
+ return
+ }
+ addr, _, err := s.api.Store(r.Body, r.ContentLength, toEncrypt)
if err != nil {
postRawFail.Inc(1)
- s.Error(w, r, err)
+ Respond(w, r, err.Error(), http.StatusInternalServerError)
return
}
- s.logDebug("content for %s stored", key.Log())
+
+ log.Debug("stored content", "ruid", r.ruid, "key", addr)
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
- fmt.Fprint(w, key)
+ fmt.Fprint(w, addr)
}
-// HandlePostFiles handles a POST request (or deprecated PUT request) to
+// HandlePostFiles handles a POST request to
// bzz:/<hash>/<path> which contains either a single file or multiple files
// (either a tar archive or multipart form), adds those files either to an
// existing manifest or to a new manifest under <path> and returns the
// resulting manifest hash as a text/plain response
func (s *Server) HandlePostFiles(w http.ResponseWriter, r *Request) {
+ log.Debug("handle.post.files", "ruid", r.ruid)
+
postFilesCount.Inc(1)
contentType, params, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
if err != nil {
postFilesFail.Inc(1)
- s.BadRequest(w, r, err.Error())
+ Respond(w, r, err.Error(), http.StatusBadRequest)
return
}
- var key storage.Key
- if r.uri.Addr != "" {
- key, err = s.api.Resolve(r.uri)
+ toEncrypt := false
+ if r.uri.Addr == "encrypt" {
+ toEncrypt = true
+ }
+
+ var addr storage.Address
+ if r.uri.Addr != "" && r.uri.Addr != "encrypt" {
+ addr, err = s.api.Resolve(r.uri)
if err != nil {
postFilesFail.Inc(1)
- s.Error(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
+ Respond(w, r, fmt.Sprintf("cannot resolve %s: %s", r.uri.Addr, err), http.StatusInternalServerError)
return
}
+ log.Debug("resolved key", "ruid", r.ruid, "key", addr)
} else {
- key, err = s.api.NewManifest()
+ addr, err = s.api.NewManifest(toEncrypt)
if err != nil {
postFilesFail.Inc(1)
- s.Error(w, r, err)
+ Respond(w, r, err.Error(), http.StatusInternalServerError)
return
}
+ log.Debug("new manifest", "ruid", r.ruid, "key", addr)
}
- newKey, err := s.updateManifest(key, func(mw *api.ManifestWriter) error {
+ newAddr, err := s.updateManifest(addr, func(mw *api.ManifestWriter) error {
switch contentType {
case "application/x-tar":
@@ -185,16 +216,19 @@ func (s *Server) HandlePostFiles(w http.ResponseWriter, r *Request) {
})
if err != nil {
postFilesFail.Inc(1)
- s.Error(w, r, fmt.Errorf("error creating manifest: %s", err))
+ Respond(w, r, fmt.Sprintf("cannot create manifest: %s", err), http.StatusInternalServerError)
return
}
+ log.Debug("stored content", "ruid", r.ruid, "key", newAddr)
+
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
- fmt.Fprint(w, newKey)
+ fmt.Fprint(w, newAddr)
}
func (s *Server) handleTarUpload(req *Request, mw *api.ManifestWriter) error {
+ log.Debug("handle.tar.upload", "ruid", req.ruid)
tr := tar.NewReader(req.Body)
for {
hdr, err := tr.Next()
@@ -218,16 +252,17 @@ func (s *Server) handleTarUpload(req *Request, mw *api.ManifestWriter) error {
Size: hdr.Size,
ModTime: hdr.ModTime,
}
- s.logDebug("adding %s (%d bytes) to new manifest", entry.Path, entry.Size)
+ log.Debug("adding path to new manifest", "ruid", req.ruid, "bytes", entry.Size, "path", entry.Path)
contentKey, err := mw.AddEntry(tr, entry)
if err != nil {
return fmt.Errorf("error adding manifest entry from tar stream: %s", err)
}
- s.logDebug("content for %s stored", contentKey.Log())
+ log.Debug("stored content", "ruid", req.ruid, "key", contentKey)
}
}
func (s *Server) handleMultipartUpload(req *Request, boundary string, mw *api.ManifestWriter) error {
+ log.Debug("handle.multipart.upload", "ruid", req.ruid)
mr := multipart.NewReader(req.Body, boundary)
for {
part, err := mr.NextPart()
@@ -275,16 +310,17 @@ func (s *Server) handleMultipartUpload(req *Request, boundary string, mw *api.Ma
Size: size,
ModTime: time.Now(),
}
- s.logDebug("adding %s (%d bytes) to new manifest", entry.Path, entry.Size)
+ log.Debug("adding path to new manifest", "ruid", req.ruid, "bytes", entry.Size, "path", entry.Path)
contentKey, err := mw.AddEntry(reader, entry)
if err != nil {
return fmt.Errorf("error adding manifest entry from multipart form: %s", err)
}
- s.logDebug("content for %s stored", contentKey.Log())
+ log.Debug("stored content", "ruid", req.ruid, "key", contentKey)
}
}
func (s *Server) handleDirectUpload(req *Request, mw *api.ManifestWriter) error {
+ log.Debug("handle.direct.upload", "ruid", req.ruid)
key, err := mw.AddEntry(req.Body, &api.ManifestEntry{
Path: req.uri.Path,
ContentType: req.Header.Get("Content-Type"),
@@ -295,7 +331,7 @@ func (s *Server) handleDirectUpload(req *Request, mw *api.ManifestWriter) error
if err != nil {
return err
}
- s.logDebug("content for %s stored", key.Log())
+ log.Debug("stored content", "ruid", req.ruid, "key", key)
return nil
}
@@ -303,21 +339,23 @@ func (s *Server) handleDirectUpload(req *Request, mw *api.ManifestWriter) error
// <path> from <manifest> and returns the resulting manifest hash as a
// text/plain response
func (s *Server) HandleDelete(w http.ResponseWriter, r *Request) {
+ log.Debug("handle.delete", "ruid", r.ruid)
+
deleteCount.Inc(1)
key, err := s.api.Resolve(r.uri)
if err != nil {
deleteFail.Inc(1)
- s.Error(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
+ Respond(w, r, fmt.Sprintf("cannot resolve %s: %s", r.uri.Addr, err), http.StatusInternalServerError)
return
}
newKey, err := s.updateManifest(key, func(mw *api.ManifestWriter) error {
- s.logDebug("removing %s from manifest %s", r.uri.Path, key.Log())
+ log.Debug(fmt.Sprintf("removing %s from manifest %s", r.uri.Path, key.Log()), "ruid", r.ruid)
return mw.RemoveEntry(r.uri.Path)
})
if err != nil {
deleteFail.Inc(1)
- s.Error(w, r, fmt.Errorf("error updating manifest: %s", err))
+ Respond(w, r, fmt.Sprintf("cannot update manifest: %s", err), http.StatusInternalServerError)
return
}
@@ -326,27 +364,290 @@ func (s *Server) HandleDelete(w http.ResponseWriter, r *Request) {
fmt.Fprint(w, newKey)
}
+// Parses a resource update post url to corresponding action
+// possible combinations:
+// / add multihash update to existing hash
+// /raw add raw update to existing hash
+// /# create new resource with first update as mulitihash
+// /raw/# create new resource with first update raw
+func resourcePostMode(path string) (isRaw bool, frequency uint64, err error) {
+ re, err := regexp.Compile("^(raw)?/?([0-9]+)?$")
+ if err != nil {
+ return isRaw, frequency, err
+ }
+ m := re.FindAllStringSubmatch(path, 2)
+ var freqstr = "0"
+ if len(m) > 0 {
+ if m[0][1] != "" {
+ isRaw = true
+ }
+ if m[0][2] != "" {
+ freqstr = m[0][2]
+ }
+ } else if len(path) > 0 {
+ return isRaw, frequency, fmt.Errorf("invalid path")
+ }
+ frequency, err = strconv.ParseUint(freqstr, 10, 64)
+ return isRaw, frequency, err
+}
+
+// Handles creation of new mutable resources and adding updates to existing mutable resources
+// There are two types of updates available, "raw" and "multihash."
+// If the latter is used, a subsequent bzz:// GET call to the manifest of the resource will return
+// the page that the multihash is pointing to, as if it held a normal swarm content manifest
+//
+// The resource name will be verbatim what is passed as the address part of the url.
+// For example, if a POST is made to /bzz-resource:/foo.eth/raw/13 a new resource with frequency 13
+// and name "foo.eth" will be created
+func (s *Server) HandlePostResource(w http.ResponseWriter, r *Request) {
+ log.Debug("handle.post.resource", "ruid", r.ruid)
+ var err error
+ var addr storage.Address
+ var name string
+ var outdata []byte
+ isRaw, frequency, err := resourcePostMode(r.uri.Path)
+ if err != nil {
+ Respond(w, r, err.Error(), http.StatusBadRequest)
+ return
+ }
+
+ // new mutable resource creation will always have a frequency field larger than 0
+ if frequency > 0 {
+
+ name = r.uri.Addr
+
+ // the key is the content addressed root chunk holding mutable resource metadata information
+ addr, err = s.api.ResourceCreate(r.Context(), name, frequency)
+ if err != nil {
+ code, err2 := s.translateResourceError(w, r, "resource creation fail", err)
+
+ Respond(w, r, err2.Error(), code)
+ return
+ }
+
+ // we create a manifest so we can retrieve the resource with bzz:// later
+ // this manifest has a special "resource type" manifest, and its hash is the key of the mutable resource
+ // root chunk
+ m, err := s.api.NewResourceManifest(addr.Hex())
+ if err != nil {
+ Respond(w, r, fmt.Sprintf("failed to create resource manifest: %v", err), http.StatusInternalServerError)
+ return
+ }
+
+ // the key to the manifest will be passed back to the client
+ // the client can access the root chunk key directly through its Hash member
+ // the manifest key should be set as content in the resolver of the ENS name
+ // \TODO update manifest key automatically in ENS
+ outdata, err = json.Marshal(m)
+ if err != nil {
+ Respond(w, r, fmt.Sprintf("failed to create json response: %s", err), http.StatusInternalServerError)
+ return
+ }
+ } else {
+ // to update the resource through http we need to retrieve the key for the mutable resource root chunk
+ // that means that we retrieve the manifest and inspect its Hash member.
+ manifestAddr := r.uri.Address()
+ if manifestAddr == nil {
+ manifestAddr, err = s.api.Resolve(r.uri)
+ if err != nil {
+ getFail.Inc(1)
+ Respond(w, r, fmt.Sprintf("cannot resolve %s: %s", r.uri.Addr, err), http.StatusNotFound)
+ return
+ }
+ } else {
+ w.Header().Set("Cache-Control", "max-age=2147483648")
+ }
+
+ // get the root chunk key from the manifest
+ addr, err = s.api.ResolveResourceManifest(manifestAddr)
+ if err != nil {
+ getFail.Inc(1)
+ Respond(w, r, fmt.Sprintf("error resolving resource root chunk for %s: %s", r.uri.Addr, err), http.StatusNotFound)
+ return
+ }
+
+ log.Debug("handle.post.resource: resolved", "ruid", r.ruid, "manifestkey", manifestAddr, "rootchunkkey", addr)
+
+ name, _, err = s.api.ResourceLookup(r.Context(), addr, 0, 0, &mru.LookupParams{})
+ if err != nil {
+ Respond(w, r, err.Error(), http.StatusNotFound)
+ return
+ }
+ }
+
+ // Creation and update must send data aswell. This data constitutes the update data itself.
+ data, err := ioutil.ReadAll(r.Body)
+ if err != nil {
+ Respond(w, r, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ // Multihash will be passed as hex-encoded data, so we need to parse this to bytes
+ if isRaw {
+ _, _, _, err = s.api.ResourceUpdate(r.Context(), name, data)
+ if err != nil {
+ Respond(w, r, err.Error(), http.StatusBadRequest)
+ return
+ }
+ } else {
+ bytesdata, err := hexutil.Decode(string(data))
+ if err != nil {
+ Respond(w, r, err.Error(), http.StatusBadRequest)
+ return
+ }
+ _, _, _, err = s.api.ResourceUpdateMultihash(r.Context(), name, bytesdata)
+ if err != nil {
+ Respond(w, r, err.Error(), http.StatusBadRequest)
+ return
+ }
+ }
+
+ // If we have data to return, write this now
+ // \TODO there should always be data to return here
+ if len(outdata) > 0 {
+ w.Header().Add("Content-type", "text/plain")
+ w.WriteHeader(http.StatusOK)
+ fmt.Fprint(w, string(outdata))
+ return
+ }
+ w.WriteHeader(http.StatusOK)
+}
+
+// Retrieve mutable resource updates:
+// bzz-resource://<id> - get latest update
+// bzz-resource://<id>/<n> - get latest update on period n
+// bzz-resource://<id>/<n>/<m> - get update version m of period n
+// <id> = ens name or hash
+func (s *Server) HandleGetResource(w http.ResponseWriter, r *Request) {
+ s.handleGetResource(w, r)
+}
+
+// TODO: Enable pass maxPeriod parameter
+func (s *Server) handleGetResource(w http.ResponseWriter, r *Request) {
+ log.Debug("handle.get.resource", "ruid", r.ruid)
+ var err error
+
+ // resolve the content key.
+ manifestAddr := r.uri.Address()
+ if manifestAddr == nil {
+ manifestAddr, err = s.api.Resolve(r.uri)
+ if err != nil {
+ getFail.Inc(1)
+ Respond(w, r, fmt.Sprintf("cannot resolve %s: %s", r.uri.Addr, err), http.StatusNotFound)
+ return
+ }
+ } else {
+ w.Header().Set("Cache-Control", "max-age=2147483648")
+ }
+
+ // get the root chunk key from the manifest
+ key, err := s.api.ResolveResourceManifest(manifestAddr)
+ if err != nil {
+ getFail.Inc(1)
+ Respond(w, r, fmt.Sprintf("error resolving resource root chunk for %s: %s", r.uri.Addr, err), http.StatusNotFound)
+ return
+ }
+
+ log.Debug("handle.get.resource: resolved", "ruid", r.ruid, "manifestkey", manifestAddr, "rootchunk key", key)
+
+ // determine if the query specifies period and version
+ var params []string
+ if len(r.uri.Path) > 0 {
+ params = strings.Split(r.uri.Path, "/")
+ }
+ var name string
+ var period uint64
+ var version uint64
+ var data []byte
+ now := time.Now()
+
+ switch len(params) {
+ case 0: // latest only
+ name, data, err = s.api.ResourceLookup(r.Context(), key, 0, 0, nil)
+ case 2: // specific period and version
+ version, err = strconv.ParseUint(params[1], 10, 32)
+ if err != nil {
+ break
+ }
+ period, err = strconv.ParseUint(params[0], 10, 32)
+ if err != nil {
+ break
+ }
+ name, data, err = s.api.ResourceLookup(r.Context(), key, uint32(period), uint32(version), nil)
+ case 1: // last version of specific period
+ period, err = strconv.ParseUint(params[0], 10, 32)
+ if err != nil {
+ break
+ }
+ name, data, err = s.api.ResourceLookup(r.Context(), key, uint32(period), uint32(version), nil)
+ default: // bogus
+ err = mru.NewError(storage.ErrInvalidValue, "invalid mutable resource request")
+ }
+
+ // any error from the switch statement will end up here
+ if err != nil {
+ code, err2 := s.translateResourceError(w, r, "mutable resource lookup fail", err)
+ Respond(w, r, err2.Error(), code)
+ return
+ }
+
+ // All ok, serve the retrieved update
+ log.Debug("Found update", "name", name, "ruid", r.ruid)
+ w.Header().Set("Content-Type", "application/octet-stream")
+ http.ServeContent(w, &r.Request, "", now, bytes.NewReader(data))
+}
+
+func (s *Server) translateResourceError(w http.ResponseWriter, r *Request, supErr string, err error) (int, error) {
+ code := 0
+ defaultErr := fmt.Errorf("%s: %v", supErr, err)
+ rsrcErr, ok := err.(*mru.Error)
+ if !ok && rsrcErr != nil {
+ code = rsrcErr.Code()
+ }
+ switch code {
+ case storage.ErrInvalidValue:
+ return http.StatusBadRequest, defaultErr
+ case storage.ErrNotFound, storage.ErrNotSynced, storage.ErrNothingToReturn, storage.ErrInit:
+ return http.StatusNotFound, defaultErr
+ case storage.ErrUnauthorized, storage.ErrInvalidSignature:
+ return http.StatusUnauthorized, defaultErr
+ case storage.ErrDataOverflow:
+ return http.StatusRequestEntityTooLarge, defaultErr
+ }
+
+ return http.StatusInternalServerError, defaultErr
+}
+
// HandleGet handles a GET request to
// - bzz-raw://<key> and responds with the raw content stored at the
// given storage key
// - bzz-hash://<key> and responds with the hash of the content stored
// at the given storage key as a text/plain response
func (s *Server) HandleGet(w http.ResponseWriter, r *Request) {
+ log.Debug("handle.get", "ruid", r.ruid, "uri", r.uri)
getCount.Inc(1)
- key, err := s.api.Resolve(r.uri)
- if err != nil {
- getFail.Inc(1)
- s.NotFound(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
- return
+ var err error
+ addr := r.uri.Address()
+ if addr == nil {
+ addr, err = s.api.Resolve(r.uri)
+ if err != nil {
+ getFail.Inc(1)
+ Respond(w, r, fmt.Sprintf("cannot resolve %s: %s", r.uri.Addr, err), http.StatusNotFound)
+ return
+ }
+ } else {
+ w.Header().Set("Cache-Control", "max-age=2147483648, immutable") // url was of type bzz://<hex key>/path, so we are sure it is immutable.
}
+ log.Debug("handle.get: resolved", "ruid", r.ruid, "key", addr)
+
// if path is set, interpret <key> as a manifest and return the
// raw entry at the given path
if r.uri.Path != "" {
- walker, err := s.api.NewManifestWalker(key, nil)
+ walker, err := s.api.NewManifestWalker(addr, nil)
if err != nil {
getFail.Inc(1)
- s.BadRequest(w, r, fmt.Sprintf("%s is not a manifest", key))
+ Respond(w, r, fmt.Sprintf("%s is not a manifest", addr), http.StatusBadRequest)
return
}
var entry *api.ManifestEntry
@@ -371,26 +672,37 @@ func (s *Server) HandleGet(w http.ResponseWriter, r *Request) {
return nil
}
- return api.SkipManifest
+ return api.ErrSkipManifest
})
if entry == nil {
getFail.Inc(1)
- s.NotFound(w, r, fmt.Errorf("Manifest entry could not be loaded"))
+ Respond(w, r, fmt.Sprintf("manifest entry could not be loaded"), http.StatusNotFound)
+ return
+ }
+ addr = storage.Address(common.Hex2Bytes(entry.Hash))
+ }
+ etag := common.Bytes2Hex(addr)
+ noneMatchEtag := r.Header.Get("If-None-Match")
+ w.Header().Set("ETag", fmt.Sprintf("%q", etag)) // set etag to manifest key or raw entry key.
+ if noneMatchEtag != "" {
+ if bytes.Equal(storage.Address(common.Hex2Bytes(noneMatchEtag)), addr) {
+ Respond(w, r, "Not Modified", http.StatusNotModified)
return
}
- key = storage.Key(common.Hex2Bytes(entry.Hash))
}
// check the root chunk exists by retrieving the file's size
- reader := s.api.Retrieve(key)
+ reader, isEncrypted := s.api.Retrieve(addr)
if _, err := reader.Size(nil); err != nil {
getFail.Inc(1)
- s.NotFound(w, r, fmt.Errorf("Root chunk not found %s: %s", key, err))
+ Respond(w, r, fmt.Sprintf("root chunk not found %s: %s", addr, err), http.StatusNotFound)
return
}
+ w.Header().Set("X-Decrypted", fmt.Sprintf("%v", isEncrypted))
+
switch {
- case r.uri.Raw() || r.uri.DeprecatedRaw():
+ case r.uri.Raw():
// allow the request to overwrite the content type using a query
// parameter
contentType := "application/octet-stream"
@@ -398,12 +710,11 @@ func (s *Server) HandleGet(w http.ResponseWriter, r *Request) {
contentType = typ
}
w.Header().Set("Content-Type", contentType)
-
http.ServeContent(w, &r.Request, "", time.Now(), reader)
case r.uri.Hash():
w.Header().Set("Content-Type", "text/plain")
w.WriteHeader(http.StatusOK)
- fmt.Fprint(w, key)
+ fmt.Fprint(w, addr)
}
}
@@ -411,24 +722,26 @@ func (s *Server) HandleGet(w http.ResponseWriter, r *Request) {
// header of "application/x-tar" and returns a tar stream of all files
// contained in the manifest
func (s *Server) HandleGetFiles(w http.ResponseWriter, r *Request) {
+ log.Debug("handle.get.files", "ruid", r.ruid, "uri", r.uri)
getFilesCount.Inc(1)
if r.uri.Path != "" {
getFilesFail.Inc(1)
- s.BadRequest(w, r, "files request cannot contain a path")
+ Respond(w, r, "files request cannot contain a path", http.StatusBadRequest)
return
}
- key, err := s.api.Resolve(r.uri)
+ addr, err := s.api.Resolve(r.uri)
if err != nil {
getFilesFail.Inc(1)
- s.NotFound(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
+ Respond(w, r, fmt.Sprintf("cannot resolve %s: %s", r.uri.Addr, err), http.StatusNotFound)
return
}
+ log.Debug("handle.get.files: resolved", "ruid", r.ruid, "key", addr)
- walker, err := s.api.NewManifestWalker(key, nil)
+ walker, err := s.api.NewManifestWalker(addr, nil)
if err != nil {
getFilesFail.Inc(1)
- s.Error(w, r, err)
+ Respond(w, r, err.Error(), http.StatusInternalServerError)
return
}
@@ -444,11 +757,12 @@ func (s *Server) HandleGetFiles(w http.ResponseWriter, r *Request) {
}
// retrieve the entry's key and size
- reader := s.api.Retrieve(storage.Key(common.Hex2Bytes(entry.Hash)))
+ reader, isEncrypted := s.api.Retrieve(storage.Address(common.Hex2Bytes(entry.Hash)))
size, err := reader.Size(nil)
if err != nil {
return err
}
+ w.Header().Set("X-Decrypted", fmt.Sprintf("%v", isEncrypted))
// write a tar header for the entry
hdr := &tar.Header{
@@ -476,7 +790,7 @@ func (s *Server) HandleGetFiles(w http.ResponseWriter, r *Request) {
})
if err != nil {
getFilesFail.Inc(1)
- s.logError("error generating tar stream: %s", err)
+ log.Error(fmt.Sprintf("error generating tar stream: %s", err))
}
}
@@ -484,6 +798,7 @@ func (s *Server) HandleGetFiles(w http.ResponseWriter, r *Request) {
// a list of all files contained in <manifest> under <path> grouped into
// common prefixes using "/" as a delimiter
func (s *Server) HandleGetList(w http.ResponseWriter, r *Request) {
+ log.Debug("handle.get.list", "ruid", r.ruid, "uri", r.uri)
getListCount.Inc(1)
// ensure the root path has a trailing slash so that relative URLs work
if r.uri.Path == "" && !strings.HasSuffix(r.URL.Path, "/") {
@@ -491,18 +806,19 @@ func (s *Server) HandleGetList(w http.ResponseWriter, r *Request) {
return
}
- key, err := s.api.Resolve(r.uri)
+ addr, err := s.api.Resolve(r.uri)
if err != nil {
getListFail.Inc(1)
- s.NotFound(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
+ Respond(w, r, fmt.Sprintf("cannot resolve %s: %s", r.uri.Addr, err), http.StatusNotFound)
return
}
+ log.Debug("handle.get.list: resolved", "ruid", r.ruid, "key", addr)
- list, err := s.getManifestList(key, r.uri.Path)
+ list, err := s.getManifestList(addr, r.uri.Path)
if err != nil {
getListFail.Inc(1)
- s.Error(w, r, err)
+ Respond(w, r, err.Error(), http.StatusInternalServerError)
return
}
@@ -520,7 +836,7 @@ func (s *Server) HandleGetList(w http.ResponseWriter, r *Request) {
})
if err != nil {
getListFail.Inc(1)
- s.logError("error rendering list HTML: %s", err)
+ log.Error(fmt.Sprintf("error rendering list HTML: %s", err))
}
return
}
@@ -529,8 +845,8 @@ func (s *Server) HandleGetList(w http.ResponseWriter, r *Request) {
json.NewEncoder(w).Encode(&list)
}
-func (s *Server) getManifestList(key storage.Key, prefix string) (list api.ManifestList, err error) {
- walker, err := s.api.NewManifestWalker(key, nil)
+func (s *Server) getManifestList(addr storage.Address, prefix string) (list api.ManifestList, err error) {
+ walker, err := s.api.NewManifestWalker(addr, nil)
if err != nil {
return
}
@@ -572,14 +888,14 @@ func (s *Server) getManifestList(key storage.Key, prefix string) (list api.Manif
suffix := strings.TrimPrefix(entry.Path, prefix)
if index := strings.Index(suffix, "/"); index > -1 {
list.CommonPrefixes = append(list.CommonPrefixes, prefix+suffix[:index+1])
- return api.SkipManifest
+ return api.ErrSkipManifest
}
return nil
}
// the manifest neither has the prefix or needs recursing in to
// so just skip it
- return api.SkipManifest
+ return api.ErrSkipManifest
})
return list, nil
@@ -588,29 +904,49 @@ func (s *Server) getManifestList(key storage.Key, prefix string) (list api.Manif
// HandleGetFile handles a GET request to bzz://<manifest>/<path> and responds
// with the content of the file at <path> from the given <manifest>
func (s *Server) HandleGetFile(w http.ResponseWriter, r *Request) {
+ log.Debug("handle.get.file", "ruid", r.ruid)
getFileCount.Inc(1)
// ensure the root path has a trailing slash so that relative URLs work
if r.uri.Path == "" && !strings.HasSuffix(r.URL.Path, "/") {
http.Redirect(w, &r.Request, r.URL.Path+"/", http.StatusMovedPermanently)
return
}
+ var err error
+ manifestAddr := r.uri.Address()
- key, err := s.api.Resolve(r.uri)
- if err != nil {
- getFileFail.Inc(1)
- s.NotFound(w, r, fmt.Errorf("error resolving %s: %s", r.uri.Addr, err))
- return
+ if manifestAddr == nil {
+ manifestAddr, err = s.api.Resolve(r.uri)
+ if err != nil {
+ getFileFail.Inc(1)
+ Respond(w, r, fmt.Sprintf("cannot resolve %s: %s", r.uri.Addr, err), http.StatusNotFound)
+ return
+ }
+ } else {
+ w.Header().Set("Cache-Control", "max-age=2147483648, immutable") // url was of type bzz://<hex key>/path, so we are sure it is immutable.
+ }
+
+ log.Debug("handle.get.file: resolved", "ruid", r.ruid, "key", manifestAddr)
+
+ reader, contentType, status, contentKey, err := s.api.Get(manifestAddr, r.uri.Path)
+
+ etag := common.Bytes2Hex(contentKey)
+ noneMatchEtag := r.Header.Get("If-None-Match")
+ w.Header().Set("ETag", fmt.Sprintf("%q", etag)) // set etag to actual content key.
+ if noneMatchEtag != "" {
+ if bytes.Equal(storage.Address(common.Hex2Bytes(noneMatchEtag)), contentKey) {
+ Respond(w, r, "Not Modified", http.StatusNotModified)
+ return
+ }
}
- reader, contentType, status, err := s.api.Get(key, r.uri.Path)
if err != nil {
switch status {
case http.StatusNotFound:
getFileNotFound.Inc(1)
- s.NotFound(w, r, err)
+ Respond(w, r, err.Error(), http.StatusNotFound)
default:
getFileFail.Inc(1)
- s.Error(w, r, err)
+ Respond(w, r, err.Error(), http.StatusInternalServerError)
}
return
}
@@ -618,15 +954,15 @@ func (s *Server) HandleGetFile(w http.ResponseWriter, r *Request) {
//the request results in ambiguous files
//e.g. /read with readme.md and readinglist.txt available in manifest
if status == http.StatusMultipleChoices {
- list, err := s.getManifestList(key, r.uri.Path)
+ list, err := s.getManifestList(manifestAddr, r.uri.Path)
if err != nil {
getFileFail.Inc(1)
- s.Error(w, r, err)
+ Respond(w, r, err.Error(), http.StatusInternalServerError)
return
}
- s.logDebug(fmt.Sprintf("Multiple choices! --> %v", list))
+ log.Debug(fmt.Sprintf("Multiple choices! --> %v", list), "ruid", r.ruid)
//show a nice page links to available entries
ShowMultipleChoices(w, r, list)
return
@@ -635,79 +971,121 @@ func (s *Server) HandleGetFile(w http.ResponseWriter, r *Request) {
// check the root chunk exists by retrieving the file's size
if _, err := reader.Size(nil); err != nil {
getFileNotFound.Inc(1)
- s.NotFound(w, r, fmt.Errorf("File not found %s: %s", r.uri, err))
+ Respond(w, r, fmt.Sprintf("file not found %s: %s", r.uri, err), http.StatusNotFound)
return
}
w.Header().Set("Content-Type", contentType)
+ http.ServeContent(w, &r.Request, "", time.Now(), newBufferedReadSeeker(reader, getFileBufferSize))
+}
- http.ServeContent(w, &r.Request, "", time.Now(), reader)
+// The size of buffer used for bufio.Reader on LazyChunkReader passed to
+// http.ServeContent in HandleGetFile.
+// Warning: This value influences the number of chunk requests and chunker join goroutines
+// per file request.
+// Recommended value is 4 times the io.Copy default buffer value which is 32kB.
+const getFileBufferSize = 4 * 32 * 1024
+
+// bufferedReadSeeker wraps bufio.Reader to expose Seek method
+// from the provied io.ReadSeeker in newBufferedReadSeeker.
+type bufferedReadSeeker struct {
+ r io.Reader
+ s io.Seeker
}
-func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- if metrics.Enabled {
- //The increment for request count and request timer themselves have a flag check
- //for metrics.Enabled. Nevertheless, we introduce the if here because we
- //are looking into the header just to see what request type it is (json/html).
- //So let's take advantage and add all metrics related stuff here
- requestCount.Inc(1)
- defer requestTimer.UpdateSince(time.Now())
- if r.Header.Get("Accept") == "application/json" {
- jsonRequestCount.Inc(1)
- } else {
- htmlRequestCount.Inc(1)
- }
+// newBufferedReadSeeker creates a new instance of bufferedReadSeeker,
+// out of io.ReadSeeker. Argument `size` is the size of the read buffer.
+func newBufferedReadSeeker(readSeeker io.ReadSeeker, size int) bufferedReadSeeker {
+ return bufferedReadSeeker{
+ r: bufio.NewReaderSize(readSeeker, size),
+ s: readSeeker,
}
- s.logDebug("HTTP %s request URL: '%s', Host: '%s', Path: '%s', Referer: '%s', Accept: '%s'", r.Method, r.RequestURI, r.URL.Host, r.URL.Path, r.Referer(), r.Header.Get("Accept"))
+}
+
+func (b bufferedReadSeeker) Read(p []byte) (n int, err error) {
+ return b.r.Read(p)
+}
+
+func (b bufferedReadSeeker) Seek(offset int64, whence int) (int64, error) {
+ return b.s.Seek(offset, whence)
+}
+
+func (s *Server) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
+ defer metrics.GetOrRegisterResettingTimer(fmt.Sprintf("http.request.%s.time", r.Method), nil).UpdateSince(time.Now())
+ req := &Request{Request: *r, ruid: uuid.New()[:8]}
+ metrics.GetOrRegisterCounter(fmt.Sprintf("http.request.%s", r.Method), nil).Inc(1)
+ log.Info("serving request", "ruid", req.ruid, "method", r.Method, "url", r.RequestURI)
+
+ // wrapping the ResponseWriter, so that we get the response code set by http.ServeContent
+ w := newLoggingResponseWriter(rw)
if r.RequestURI == "/" && strings.Contains(r.Header.Get("Accept"), "text/html") {
err := landingPageTemplate.Execute(w, nil)
if err != nil {
- s.logError("error rendering landing page: %s", err)
+ log.Error(fmt.Sprintf("error rendering landing page: %s", err))
}
return
}
+ if r.URL.Path == "/robots.txt" {
+ w.Header().Set("Last-Modified", time.Now().Format(http.TimeFormat))
+ fmt.Fprintf(w, "User-agent: *\nDisallow: /")
+ return
+ }
+
+ if r.RequestURI == "/" && strings.Contains(r.Header.Get("Accept"), "application/json") {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ json.NewEncoder(w).Encode("Welcome to Swarm!")
+ return
+ }
+
uri, err := api.Parse(strings.TrimLeft(r.URL.Path, "/"))
- req := &Request{Request: *r, uri: uri}
if err != nil {
- s.logError("Invalid URI %q: %s", r.URL.Path, err)
- s.BadRequest(w, req, fmt.Sprintf("Invalid URI %q: %s", r.URL.Path, err))
+ Respond(w, req, fmt.Sprintf("invalid URI %q", r.URL.Path), http.StatusBadRequest)
return
}
- s.logDebug("%s request received for %s", r.Method, uri)
+
+ req.uri = uri
+
+ log.Debug("parsed request path", "ruid", req.ruid, "method", req.Method, "uri.Addr", req.uri.Addr, "uri.Path", req.uri.Path, "uri.Scheme", req.uri.Scheme)
switch r.Method {
case "POST":
- if uri.Raw() || uri.DeprecatedRaw() {
+ if uri.Raw() {
+ log.Debug("handlePostRaw")
s.HandlePostRaw(w, req)
+ } else if uri.Resource() {
+ log.Debug("handlePostResource")
+ s.HandlePostResource(w, req)
+ } else if uri.Immutable() || uri.List() || uri.Hash() {
+ log.Debug("POST not allowed on immutable, list or hash")
+ Respond(w, req, fmt.Sprintf("POST method on scheme %s not allowed", uri.Scheme), http.StatusMethodNotAllowed)
} else {
+ log.Debug("handlePostFiles")
s.HandlePostFiles(w, req)
}
case "PUT":
- // DEPRECATED:
- // clients should send a POST request (the request creates a
- // new manifest leaving the existing one intact, so it isn't
- // strictly a traditional PUT request which replaces content
- // at a URI, and POST is more ubiquitous)
- if uri.Raw() || uri.DeprecatedRaw() {
- ShowError(w, req, fmt.Sprintf("No PUT to %s allowed.", uri), http.StatusBadRequest)
- return
- } else {
- s.HandlePostFiles(w, req)
- }
+ Respond(w, req, fmt.Sprintf("PUT method to %s not allowed", uri), http.StatusBadRequest)
+ return
case "DELETE":
- if uri.Raw() || uri.DeprecatedRaw() {
- ShowError(w, req, fmt.Sprintf("No DELETE to %s allowed.", uri), http.StatusBadRequest)
+ if uri.Raw() {
+ Respond(w, req, fmt.Sprintf("DELETE method to %s not allowed", uri), http.StatusBadRequest)
return
}
s.HandleDelete(w, req)
case "GET":
- if uri.Raw() || uri.Hash() || uri.DeprecatedRaw() {
+
+ if uri.Resource() {
+ s.HandleGetResource(w, req)
+ return
+ }
+
+ if uri.Raw() || uri.Hash() {
s.HandleGet(w, req)
return
}
@@ -725,13 +1103,14 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.HandleGetFile(w, req)
default:
- ShowError(w, req, fmt.Sprintf("Method "+r.Method+" is not supported.", uri), http.StatusMethodNotAllowed)
-
+ Respond(w, req, fmt.Sprintf("%s method is not supported", r.Method), http.StatusMethodNotAllowed)
}
+
+ log.Info("served response", "ruid", req.ruid, "code", w.statusCode)
}
-func (s *Server) updateManifest(key storage.Key, update func(mw *api.ManifestWriter) error) (storage.Key, error) {
- mw, err := s.api.NewManifestWriter(key, nil)
+func (s *Server) updateManifest(addr storage.Address, update func(mw *api.ManifestWriter) error) (storage.Address, error) {
+ mw, err := s.api.NewManifestWriter(addr, nil)
if err != nil {
return nil, err
}
@@ -740,30 +1119,24 @@ func (s *Server) updateManifest(key storage.Key, update func(mw *api.ManifestWri
return nil, err
}
- key, err = mw.Store()
+ addr, err = mw.Store()
if err != nil {
return nil, err
}
- s.logDebug("generated manifest %s", key)
- return key, nil
-}
-
-func (s *Server) logDebug(format string, v ...interface{}) {
- log.Debug(fmt.Sprintf("[BZZ] HTTP: "+format, v...))
-}
-
-func (s *Server) logError(format string, v ...interface{}) {
- log.Error(fmt.Sprintf("[BZZ] HTTP: "+format, v...))
+ log.Debug(fmt.Sprintf("generated manifest %s", addr))
+ return addr, nil
}
-func (s *Server) BadRequest(w http.ResponseWriter, r *Request, reason string) {
- ShowError(w, r, fmt.Sprintf("Bad request %s %s: %s", r.Request.Method, r.uri, reason), http.StatusBadRequest)
+type loggingResponseWriter struct {
+ http.ResponseWriter
+ statusCode int
}
-func (s *Server) Error(w http.ResponseWriter, r *Request, err error) {
- ShowError(w, r, fmt.Sprintf("Error serving %s %s: %s", r.Request.Method, r.uri, err), http.StatusInternalServerError)
+func newLoggingResponseWriter(w http.ResponseWriter) *loggingResponseWriter {
+ return &loggingResponseWriter{w, http.StatusOK}
}
-func (s *Server) NotFound(w http.ResponseWriter, r *Request, err error) {
- ShowError(w, r, fmt.Sprintf("NOT FOUND error serving %s %s: %s", r.Request.Method, r.uri, err), http.StatusNotFound)
+func (lrw *loggingResponseWriter) WriteHeader(code int) {
+ lrw.statusCode = code
+ lrw.ResponseWriter.WriteHeader(code)
}
diff --git a/swarm/api/http/server_test.go b/swarm/api/http/server_test.go
index b2efc0ea1..9fb21f7a3 100644
--- a/swarm/api/http/server_test.go
+++ b/swarm/api/http/server_test.go
@@ -14,39 +14,360 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-package http_test
+package http
import (
"bytes"
+ "crypto/rand"
+ "encoding/json"
"errors"
+ "flag"
"fmt"
"io/ioutil"
"net/http"
+ "os"
"strings"
- "sync"
"testing"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/common/hexutil"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/swarm/api"
swarm "github.com/ethereum/go-ethereum/swarm/api/client"
+ "github.com/ethereum/go-ethereum/swarm/multihash"
"github.com/ethereum/go-ethereum/swarm/storage"
"github.com/ethereum/go-ethereum/swarm/testutil"
)
+func init() {
+ loglevel := flag.Int("loglevel", 2, "loglevel")
+ flag.Parse()
+ log.Root().SetHandler(log.CallerFileHandler(log.LvlFilterHandler(log.Lvl(*loglevel), log.StreamHandler(os.Stderr, log.TerminalFormat(true)))))
+}
+
+func TestResourcePostMode(t *testing.T) {
+ path := ""
+ errstr := "resourcePostMode for '%s' should be raw %v frequency %d, was raw %v, frequency %d"
+ r, f, err := resourcePostMode(path)
+ if err != nil {
+ t.Fatal(err)
+ } else if r || f != 0 {
+ t.Fatalf(errstr, path, false, 0, r, f)
+ }
+
+ path = "raw"
+ r, f, err = resourcePostMode(path)
+ if err != nil {
+ t.Fatal(err)
+ } else if !r || f != 0 {
+ t.Fatalf(errstr, path, true, 0, r, f)
+ }
+
+ path = "13"
+ r, f, err = resourcePostMode(path)
+ if err != nil {
+ t.Fatal(err)
+ } else if r || f == 0 {
+ t.Fatalf(errstr, path, false, 13, r, f)
+ }
+
+ path = "raw/13"
+ r, f, err = resourcePostMode(path)
+ if err != nil {
+ t.Fatal(err)
+ } else if !r || f == 0 {
+ t.Fatalf(errstr, path, true, 13, r, f)
+ }
+
+ path = "foo/13"
+ r, f, err = resourcePostMode(path)
+ if err == nil {
+ t.Fatal("resourcePostMode for 'foo/13' should fail, returned error nil")
+ }
+}
+
+func serverFunc(api *api.API) testutil.TestServer {
+ return NewServer(api)
+}
+
+// test the transparent resolving of multihash resource types with bzz:// scheme
+//
+// first upload data, and store the multihash to the resulting manifest in a resource update
+// retrieving the update with the multihash should return the manifest pointing directly to the data
+// and raw retrieve of that hash should return the data
+func TestBzzResourceMultihash(t *testing.T) {
+
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
+ defer srv.Close()
+
+ // add the data our multihash aliased manifest will point to
+ databytes := "bar"
+ url := fmt.Sprintf("%s/bzz:/", srv.URL)
+ resp, err := http.Post(url, "text/plain", bytes.NewReader([]byte(databytes)))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ t.Fatalf("err %s", resp.Status)
+ }
+ b, err := ioutil.ReadAll(resp.Body)
+
+ if err != nil {
+ t.Fatal(err)
+ }
+ s := common.FromHex(string(b))
+ mh := multihash.ToMultihash(s)
+
+ mhHex := hexutil.Encode(mh)
+ log.Info("added data", "manifest", string(b), "data", common.ToHex(mh))
+
+ // our mutable resource "name"
+ keybytes := "foo.eth"
+
+ // create the multihash update
+ url = fmt.Sprintf("%s/bzz-resource:/%s/13", srv.URL, keybytes)
+ resp, err = http.Post(url, "application/octet-stream", bytes.NewReader([]byte(mhHex)))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ t.Fatalf("err %s", resp.Status)
+ }
+ b, err = ioutil.ReadAll(resp.Body)
+ if err != nil {
+ t.Fatal(err)
+ }
+ rsrcResp := &storage.Address{}
+ err = json.Unmarshal(b, rsrcResp)
+ if err != nil {
+ t.Fatalf("data %s could not be unmarshaled: %v", b, err)
+ }
+
+ correctManifestAddrHex := "d689648fb9e00ddc7ebcf474112d5881c5bf7dbc6e394681b1d224b11b59b5e0"
+ if rsrcResp.Hex() != correctManifestAddrHex {
+ t.Fatalf("Response resource key mismatch, expected '%s', got '%s'", correctManifestAddrHex, rsrcResp)
+ }
+
+ // get bzz manifest transparent resource resolve
+ url = fmt.Sprintf("%s/bzz:/%s", srv.URL, rsrcResp)
+ resp, err = http.Get(url)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ t.Fatalf("err %s", resp.Status)
+ }
+ b, err = ioutil.ReadAll(resp.Body)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(b, []byte(databytes)) {
+ t.Fatalf("retrieved data mismatch, expected %x, got %x", databytes, b)
+ }
+}
+
+// Test resource updates using the raw update methods
+func TestBzzResource(t *testing.T) {
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
+ defer srv.Close()
+
+ // our mutable resource "name"
+ keybytes := "foo.eth"
+
+ // data of update 1
+ databytes := make([]byte, 666)
+ _, err := rand.Read(databytes)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // creates resource and sets update 1
+ url := fmt.Sprintf("%s/bzz-resource:/%s/raw/13", srv.URL, []byte(keybytes))
+ resp, err := http.Post(url, "application/octet-stream", bytes.NewReader(databytes))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ t.Fatalf("err %s", resp.Status)
+ }
+ b, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ t.Fatal(err)
+ }
+ rsrcResp := &storage.Address{}
+ err = json.Unmarshal(b, rsrcResp)
+ if err != nil {
+ t.Fatalf("data %s could not be unmarshaled: %v", b, err)
+ }
+
+ correctManifestAddrHex := "d689648fb9e00ddc7ebcf474112d5881c5bf7dbc6e394681b1d224b11b59b5e0"
+ if rsrcResp.Hex() != correctManifestAddrHex {
+ t.Fatalf("Response resource key mismatch, expected '%s', got '%s'", correctManifestAddrHex, rsrcResp.Hex())
+ }
+
+ // get the manifest
+ url = fmt.Sprintf("%s/bzz-raw:/%s", srv.URL, rsrcResp)
+ resp, err = http.Get(url)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ t.Fatalf("err %s", resp.Status)
+ }
+ b, err = ioutil.ReadAll(resp.Body)
+ if err != nil {
+ t.Fatal(err)
+ }
+ manifest := &api.Manifest{}
+ err = json.Unmarshal(b, manifest)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(manifest.Entries) != 1 {
+ t.Fatalf("Manifest has %d entries", len(manifest.Entries))
+ }
+
+ correctRootKeyHex := "f667277e004e8486c7a3631fd226802430e84e9a81b6085d31f512a591ae0065"
+ if manifest.Entries[0].Hash != correctRootKeyHex {
+ t.Fatalf("Expected manifest path '%s', got '%s'", correctRootKeyHex, manifest.Entries[0].Hash)
+ }
+
+ // get bzz manifest transparent resource resolve
+ url = fmt.Sprintf("%s/bzz:/%s", srv.URL, rsrcResp)
+ resp, err = http.Get(url)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ t.Fatalf("err %s", resp.Status)
+ }
+ b, err = ioutil.ReadAll(resp.Body)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // get non-existent name, should fail
+ url = fmt.Sprintf("%s/bzz-resource:/bar", srv.URL)
+ resp, err = http.Get(url)
+ if err != nil {
+ t.Fatal(err)
+ }
+ resp.Body.Close()
+
+ // get latest update (1.1) through resource directly
+ log.Info("get update latest = 1.1", "addr", correctManifestAddrHex)
+ url = fmt.Sprintf("%s/bzz-resource:/%s", srv.URL, correctManifestAddrHex)
+ resp, err = http.Get(url)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ t.Fatalf("err %s", resp.Status)
+ }
+ b, err = ioutil.ReadAll(resp.Body)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(databytes, b) {
+ t.Fatalf("Expected body '%x', got '%x'", databytes, b)
+ }
+
+ // update 2
+ log.Info("update 2")
+ url = fmt.Sprintf("%s/bzz-resource:/%s/raw", srv.URL, correctManifestAddrHex)
+ data := []byte("foo")
+ resp, err = http.Post(url, "application/octet-stream", bytes.NewReader(data))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ t.Fatalf("Update returned %s", resp.Status)
+ }
+
+ // get latest update (1.2) through resource directly
+ log.Info("get update 1.2")
+ url = fmt.Sprintf("%s/bzz-resource:/%s", srv.URL, correctManifestAddrHex)
+ resp, err = http.Get(url)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ t.Fatalf("err %s", resp.Status)
+ }
+ b, err = ioutil.ReadAll(resp.Body)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(data, b) {
+ t.Fatalf("Expected body '%x', got '%x'", data, b)
+ }
+
+ // get latest update (1.2) with specified period
+ log.Info("get update latest = 1.2")
+ url = fmt.Sprintf("%s/bzz-resource:/%s/1", srv.URL, correctManifestAddrHex)
+ resp, err = http.Get(url)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ t.Fatalf("err %s", resp.Status)
+ }
+ b, err = ioutil.ReadAll(resp.Body)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(data, b) {
+ t.Fatalf("Expected body '%x', got '%x'", data, b)
+ }
+
+ // get first update (1.1) with specified period and version
+ log.Info("get first update 1.1")
+ url = fmt.Sprintf("%s/bzz-resource:/%s/1/1", srv.URL, correctManifestAddrHex)
+ resp, err = http.Get(url)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ t.Fatalf("err %s", resp.Status)
+ }
+ b, err = ioutil.ReadAll(resp.Body)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(databytes, b) {
+ t.Fatalf("Expected body '%x', got '%x'", databytes, b)
+ }
+}
+
func TestBzzGetPath(t *testing.T) {
+ testBzzGetPath(false, t)
+ testBzzGetPath(true, t)
+}
+func testBzzGetPath(encrypted bool, t *testing.T) {
var err error
testmanifest := []string{
- `{"entries":[{"path":"a/","hash":"674af7073604ebfc0282a4ab21e5ef1a3c22913866879ebc0816f8a89896b2ed","contentType":"application/bzz-manifest+json","status":0}]}`,
- `{"entries":[{"path":"a","hash":"011b4d03dd8c01f1049143cf9c4c817e4b167f1d1b83e5c6f0f10d89ba1e7bce","contentType":"","status":0},{"path":"b/","hash":"0a87b1c3e4bf013686cdf107ec58590f2004610ee58cc2240f26939f691215f5","contentType":"application/bzz-manifest+json","status":0}]}`,
`{"entries":[{"path":"b","hash":"011b4d03dd8c01f1049143cf9c4c817e4b167f1d1b83e5c6f0f10d89ba1e7bce","contentType":"","status":0},{"path":"c","hash":"011b4d03dd8c01f1049143cf9c4c817e4b167f1d1b83e5c6f0f10d89ba1e7bce","contentType":"","status":0}]}`,
+ `{"entries":[{"path":"a","hash":"011b4d03dd8c01f1049143cf9c4c817e4b167f1d1b83e5c6f0f10d89ba1e7bce","contentType":"","status":0},{"path":"b/","hash":"<key0>","contentType":"application/bzz-manifest+json","status":0}]}`,
+ `{"entries":[{"path":"a/","hash":"<key1>","contentType":"application/bzz-manifest+json","status":0}]}`,
}
testrequests := make(map[string]int)
- testrequests["/"] = 0
+ testrequests["/"] = 2
testrequests["/a/"] = 1
- testrequests["/a/b/"] = 2
+ testrequests["/a/b/"] = 0
testrequests["/x"] = 0
testrequests[""] = 0
@@ -54,23 +375,27 @@ func TestBzzGetPath(t *testing.T) {
reader := [3]*bytes.Reader{}
- key := [3]storage.Key{}
+ addr := [3]storage.Address{}
- srv := testutil.NewTestSwarmServer(t)
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
defer srv.Close()
- wg := &sync.WaitGroup{}
-
for i, mf := range testmanifest {
reader[i] = bytes.NewReader([]byte(mf))
- key[i], err = srv.Dpa.Store(reader[i], int64(len(mf)), wg, nil)
+ var wait func()
+ addr[i], wait, err = srv.FileStore.Store(reader[i], int64(len(mf)), encrypted)
+ for j := i + 1; j < len(testmanifest); j++ {
+ testmanifest[j] = strings.Replace(testmanifest[j], fmt.Sprintf("<key%v>", i), addr[i].Hex(), -1)
+ }
if err != nil {
t.Fatal(err)
}
- wg.Wait()
+ wait()
}
- _, err = http.Get(srv.URL + "/bzz-raw:/" + common.ToHex(key[0])[2:] + "/a")
+ rootRef := addr[2].Hex()
+
+ _, err = http.Get(srv.URL + "/bzz-raw:/" + rootRef + "/a")
if err != nil {
t.Fatalf("Failed to connect to proxy: %v", err)
}
@@ -81,7 +406,7 @@ func TestBzzGetPath(t *testing.T) {
url := srv.URL + "/bzz-raw:/"
if k[:] != "" {
- url += common.ToHex(key[0])[2:] + "/" + k[1:] + "?content_type=text/plain"
+ url += rootRef + "/" + k[1:] + "?content_type=text/plain"
}
resp, err = http.Get(url)
if err != nil {
@@ -110,7 +435,7 @@ func TestBzzGetPath(t *testing.T) {
url := srv.URL + "/bzz-hash:/"
if k[:] != "" {
- url += common.ToHex(key[0])[2:] + "/" + k[1:]
+ url += rootRef + "/" + k[1:]
}
resp, err = http.Get(url)
if err != nil {
@@ -122,7 +447,7 @@ func TestBzzGetPath(t *testing.T) {
t.Fatalf("Read request body: %v", err)
}
- if string(respbody) != key[v].String() {
+ if string(respbody) != addr[v].Hex() {
isexpectedfailrequest := false
for _, r := range expectedfailrequests {
@@ -131,11 +456,13 @@ func TestBzzGetPath(t *testing.T) {
}
}
if !isexpectedfailrequest {
- t.Fatalf("Response body does not match, expected: %v, got %v", key[v], string(respbody))
+ t.Fatalf("Response body does not match, expected: %v, got %v", addr[v], string(respbody))
}
}
}
+ ref := addr[2].Hex()
+
for _, c := range []struct {
path string
json string
@@ -144,17 +471,17 @@ func TestBzzGetPath(t *testing.T) {
{
path: "/",
json: `{"common_prefixes":["a/"]}`,
- html: "<!DOCTYPE html>\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\t\t<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHsAAAB5CAYAAAAZD150AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAAFzFJREFUeAHtnXuwJFV9x7vnzrKwIC95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hy/VXRstNg4GZs/hmNjukEh3ci2TmuJat2KO7sCm/kmx8MOinhkohIwGngSo3PfHMYVZOcxXtnGWGYgpyv4SZAdCjZg8dPtgIUvJ5yqdZJtS+drDsknUMA32LdhzJKI8ZVgJA6RvoBpY1xGthiZORD4yYIiE8M4SbIDaX5o7lws4GWcIGacunEDF3yJKflvqP4o+1rGLMtOYPw1ML4cEASeEkfvvl8Qo4Gfj6X7/DdJmQbZAZ9BmRNQxOsIwX4XBVzBhR+Ei6tkG4IyjNxb38fqxwqKzLpOHLTtRRrwqnWmYYpx71WOcaYJmld+roG5BuYamGtgroG5BuYamJoG/h/ff6XOIB4wOAAAAABJRU5ErkJggg==\"/>\n\t<title>Swarm index of bzz:/262e5c08c03c2789b6daef487dfa14b4d132f5340d781a3ecb1d5122ab65640c/</title>\n</head>\n\n<body>\n <h1>Swarm index of bzz:/262e5c08c03c2789b6daef487dfa14b4d132f5340d781a3ecb1d5122ab65640c/</h1>\n <hr>\n <table>\n <thead>\n <tr>\n\t<th>Path</th>\n\t<th>Type</th>\n\t<th>Size</th>\n </tr>\n </thead>\n\n <tbody>\n \n\t<tr>\n\t <td><a href=\"a/\">a/</a></td>\n\t <td>DIR</td>\n\t <td>-</td>\n\t</tr>\n \n\n \n </table>\n <hr>\n</body>\n",
+ html: fmt.Sprintf("<!DOCTYPE html>\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\t\t<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHsAAAB5CAYAAAAZD150AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgP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KZVjH4Wmx9kAI3kcroVrrVXYwHtzHuz/4IGEcmm2ljvKWNcTNlO8ceWcYle3vBzeapGPfJzFgZjKQCkQNlWLLb9XWRQOufoffygSWUeUOzeQrlngLG3cjWuhTEOBTZASNz/hTjZWVBKI/srEZ74PY2MEA6ETW4wC7MXXvVdxiytWQV8CVIvpoMeQM1Fdm9jfG1xTEWJpspqG/VUozXgO6BMhGWTbZ1M8/dUMibaPgb2O/neoqQbX7+ZMNVjAr+in0HJkUsitsqE+u0axvj8ewPwDiQbPPjQz/Jl8F4Cfu+Ri0do4VUKUfT151Fte3P7fs6AXDcc57twIT+Me2XL2L/dlIdxV8mOruN0YhkF4w9yZ4oxqrJlhy/VXRstNg4GZs/hmNjukEh3ci2TmuJat2KO7sCm/kmx8MOinhkohIwGngSo3PfHMYVZOcxXtnGWGYgpyv4SZAdCjZg8dPtgIUvJ5yqdZJtS+drDsknUMA32LdhzJKI8ZVgJA6RvoBpY1xGthiZORD4yYIiE8M4SbIDaX5o7lws4GWcIGacunEDF3yJKflvqP4o+1rGLMtOYPw1ML4cEASeEkfvvl8Qo4Gfj6X7/DdJmQbZAZ9BmRNQxOsIwX4XBVzBhR+Ei6tkG4IyjNxb38fqxwqKzLpOHLTtRRrwqnWmYYpx71WOcaYJmld+roG5BuYamGtgroG5BuYamJoG/h/ff6XOIB4wOAAAAABJRU5ErkJggg==\"/>\n\t<title>Swarm index of bzz:/%s/</title>\n</head>\n\n<body>\n <h1>Swarm index of bzz:/%s/</h1>\n <hr>\n <table>\n <thead>\n <tr>\n\t<th>Path</th>\n\t<th>Type</th>\n\t<th>Size</th>\n </tr>\n </thead>\n\n <tbody>\n \n\t<tr>\n\t <td><a href=\"a/\">a/</a></td>\n\t <td>DIR</td>\n\t <td>-</td>\n\t</tr>\n \n\n \n </table>\n <hr>\n</body>\n", ref, ref),
},
{
path: "/a/",
json: `{"common_prefixes":["a/b/"],"entries":[{"hash":"011b4d03dd8c01f1049143cf9c4c817e4b167f1d1b83e5c6f0f10d89ba1e7bce","path":"a/a","mod_time":"0001-01-01T00:00:00Z"}]}`,
- html: "<!DOCTYPE html>\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\t\t<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHsAAAB5CAYAAAAZD150AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAAFzFJREFUeAHtnXuwJFV9x7vnzrKwIC95w/ImYFkxlZgiGswCIiCGxPhHCEIwmIemUqYwJkYrJmXlUZRa+IpAWYYEk4qJD4gJGAmoiBIxMQFRQCkXdhdCeL+fYdk7nc+ne87dvnPn0TPTPdNzmd/W2X6fc76/7/n9zjm/PrcniuYy18BcA3MNzDUw18BcA3MNzDUw18BcA3MNrGYNLERroyMAeNQ0QcbTLPxFUfaOOx4Wbd12ThRHp0TJ4s5RFF8RtVoXg/2BSeOfk12lxtc0fjva1jibItZEDf4li3u3i3sqipOPRIvRp6ssvjPvh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KzLpOHLTtRRrwqnWmYYpx71WOcaYJmld+roG5BuYamGtgroG5BuYamJoG/h/ff6XOIB4wOAAAAABJRU5ErkJggg==\"/>\n\t<title>Swarm index of bzz:/262e5c08c03c2789b6daef487dfa14b4d132f5340d781a3ecb1d5122ab65640c/a/</title>\n</head>\n\n<body>\n <h1>Swarm index of bzz:/262e5c08c03c2789b6daef487dfa14b4d132f5340d781a3ecb1d5122ab65640c/a/</h1>\n <hr>\n <table>\n <thead>\n <tr>\n\t<th>Path</th>\n\t<th>Type</th>\n\t<th>Size</th>\n </tr>\n </thead>\n\n <tbody>\n \n\t<tr>\n\t <td><a href=\"b/\">b/</a></td>\n\t <td>DIR</td>\n\t <td>-</td>\n\t</tr>\n \n\n \n\t<tr>\n\t <td><a href=\"a\">a</a></td>\n\t <td></td>\n\t <td>0</td>\n\t</tr>\n \n </table>\n <hr>\n</body>\n",
+ html: fmt.Sprintf("<!DOCTYPE html>\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\t\t<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHsAAAB5CAYAAAAZD150AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dG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TbZ1M8/dUMibaPgb2O/neoqQbX7+ZMNVjAr+in0HJkUsitsqE+u0axvj8ewPwDiQbPPjQz/Jl8F4Cfu+Ri0do4VUKUfT151Fte3P7fs6AXDcc57twIT+Me2XL2L/dlIdxV8mOruN0YhkF4w9yZ4oxqrJlhy/VXRstNg4GZs/hmNjukEh3ci2TmuJat2KO7sCm/kmx8MOinhkohIwGngSo3PfHMYVZOcxXtnGWGYgpyv4SZAdCjZg8dPtgIUvJ5yqdZJtS+drDsknUMA32LdhzJKI8ZVgJA6RvoBpY1xGthiZORD4yYIiE8M4SbIDaX5o7lws4GWcIGacunEDF3yJKflvqP4o+1rGLMtOYPw1ML4cEASeEkfvvl8Qo4Gfj6X7/DdJmQbZAZ9BmRNQxOsIwX4XBVzBhR+Ei6tkG4IyjNxb38fqxwqKzLpOHLTtRRrwqnWmYYpx71WOcaYJmld+roG5BuYamGtgroG5BuYamJoG/h/ff6XOIB4wOAAAAABJRU5ErkJggg==\"/>\n\t<title>Swarm index of bzz:/%s/a/</title>\n</head>\n\n<body>\n <h1>Swarm index of bzz:/%s/a/</h1>\n <hr>\n <table>\n <thead>\n <tr>\n\t<th>Path</th>\n\t<th>Type</th>\n\t<th>Size</th>\n </tr>\n </thead>\n\n <tbody>\n \n\t<tr>\n\t <td><a href=\"b/\">b/</a></td>\n\t <td>DIR</td>\n\t <td>-</td>\n\t</tr>\n \n\n \n\t<tr>\n\t <td><a href=\"a\">a</a></td>\n\t <td></td>\n\t <td>0</td>\n\t</tr>\n \n </table>\n <hr>\n</body>\n", ref, ref),
},
{
path: "/a/b/",
json: `{"entries":[{"hash":"011b4d03dd8c01f1049143cf9c4c817e4b167f1d1b83e5c6f0f10d89ba1e7bce","path":"a/b/b","mod_time":"0001-01-01T00:00:00Z"},{"hash":"011b4d03dd8c01f1049143cf9c4c817e4b167f1d1b83e5c6f0f10d89ba1e7bce","path":"a/b/c","mod_time":"0001-01-01T00:00:00Z"}]}`,
- html: "<!DOCTYPE html>\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\t\t<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHsAAAB5CAYAAAAZD150AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAAFzFJREFUeAHtnXuwJFV9x7vnzrKwIC95w/ImYFkxlZgiGswCIiCGxPhHCEIwmIemUqYwJkYrJmXlUZRa+IpAWYYEk4qJD4gJGAmoiBIxMQFRQCkXdhdCeL+fYdk7nc+ne87dvnPn0TPTPdNzmd/W2X6fc76/7/n9zjm/PrcniuYy18BcA3MNzDUw18BcA3MNzDUw18BcA3MNrGYNLERroyMAeNQ0QcbTLPxFUfaOOx4Wbd12ThRHp0TJ4s5RFF8RtVoXg/2BSeOfk12lxtc0fjva1jibItZEDf4li3u3i3sqipOPRIvRp6ssvjPvhc4Tq/y4Ab71pEXS1oqw7hw1mz8XJc2LoiQ6iTJaaTkxth0l69jXwNayOZ10AvubSQ+RrFOl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RU5ErkJggg==\"/>\n\t<title>Swarm index of bzz:/262e5c08c03c2789b6daef487dfa14b4d132f5340d781a3ecb1d5122ab65640c/a/b/</title>\n</head>\n\n<body>\n <h1>Swarm index of bzz:/262e5c08c03c2789b6daef487dfa14b4d132f5340d781a3ecb1d5122ab65640c/a/b/</h1>\n <hr>\n <table>\n <thead>\n <tr>\n\t<th>Path</th>\n\t<th>Type</th>\n\t<th>Size</th>\n </tr>\n </thead>\n\n <tbody>\n \n\n \n\t<tr>\n\t <td><a href=\"b\">b</a></td>\n\t <td></td>\n\t <td>0</td>\n\t</tr>\n \n\t<tr>\n\t <td><a href=\"c\">c</a></td>\n\t <td></td>\n\t <td>0</td>\n\t</tr>\n \n </table>\n <hr>\n</body>\n",
+ html: fmt.Sprintf("<!DOCTYPE html>\n<html>\n<head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\t\t<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHsAAAB5CAYAAAAZD150AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlv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F4Cfu+Ri0do4VUKUfT151Fte3P7fs6AXDcc57twIT+Me2XL2L/dlIdxV8mOruN0YhkF4w9yZ4oxqrJlhy/VXRstNg4GZs/hmNjukEh3ci2TmuJat2KO7sCm/kmx8MOinhkohIwGngSo3PfHMYVZOcxXtnGWGYgpyv4SZAdCjZg8dPtgIUvJ5yqdZJtS+drDsknUMA32LdhzJKI8ZVgJA6RvoBpY1xGthiZORD4yYIiE8M4SbIDaX5o7lws4GWcIGacunEDF3yJKflvqP4o+1rGLMtOYPw1ML4cEASeEkfvvl8Qo4Gfj6X7/DdJmQbZAZ9BmRNQxOsIwX4XBVzBhR+Ei6tkG4IyjNxb38fqxwqKzLpOHLTtRRrwqnWmYYpx71WOcaYJmld+roG5BuYamGtgroG5BuYamJoG/h/ff6XOIB4wOAAAAABJRU5ErkJggg==\"/>\n\t<title>Swarm index of bzz:/%s/a/b/</title>\n</head>\n\n<body>\n <h1>Swarm index of bzz:/%s/a/b/</h1>\n <hr>\n <table>\n <thead>\n <tr>\n\t<th>Path</th>\n\t<th>Type</th>\n\t<th>Size</th>\n </tr>\n </thead>\n\n <tbody>\n \n\n \n\t<tr>\n\t <td><a href=\"b\">b</a></td>\n\t <td></td>\n\t <td>0</td>\n\t</tr>\n \n\t<tr>\n\t <td><a href=\"c\">c</a></td>\n\t <td></td>\n\t <td>0</td>\n\t</tr>\n \n </table>\n <hr>\n</body>\n", ref, ref),
},
{
path: "/x",
@@ -166,7 +493,7 @@ func TestBzzGetPath(t *testing.T) {
k := c.path
url := srv.URL + "/bzz-list:/"
if k[:] != "" {
- url += common.ToHex(key[0])[2:] + "/" + k[1:]
+ url += rootRef + "/" + k[1:]
}
t.Run("json list "+c.path, func(t *testing.T) {
resp, err := http.Get(url)
@@ -233,11 +560,11 @@ func TestBzzGetPath(t *testing.T) {
}
nonhashresponses := []string{
- "error resolving name: no DNS to resolve name: &#34;name&#34;",
- "error resolving nonhash: immutable address not a content hash: &#34;nonhash&#34;",
- "error resolving nonhash: no DNS to resolve name: &#34;nonhash&#34;",
- "error resolving nonhash: no DNS to resolve name: &#34;nonhash&#34;",
- "error resolving nonhash: no DNS to resolve name: &#34;nonhash&#34;",
+ "cannot resolve name: no DNS to resolve name: &#34;name&#34;",
+ "cannot resolve nonhash: immutable address not a content hash: &#34;nonhash&#34;",
+ "cannot resolve nonhash: no DNS to resolve name: &#34;nonhash&#34;",
+ "cannot resolve nonhash: no DNS to resolve name: &#34;nonhash&#34;",
+ "cannot resolve nonhash: no DNS to resolve name: &#34;nonhash&#34;",
}
for i, url := range nonhashtests {
@@ -258,14 +585,20 @@ func TestBzzGetPath(t *testing.T) {
t.Fatalf("Non-Hash response body does not match, expected: %v, got: %v", nonhashresponses[i], string(respbody))
}
}
-
}
// TestBzzRootRedirect tests that getting the root path of a manifest without
// a trailing slash gets redirected to include the trailing slash so that
// relative URLs work as expected.
func TestBzzRootRedirect(t *testing.T) {
- srv := testutil.NewTestSwarmServer(t)
+ testBzzRootRedirect(false, t)
+}
+func TestBzzRootRedirectEncrypted(t *testing.T) {
+ testBzzRootRedirect(true, t)
+}
+
+func testBzzRootRedirect(toEncrypt bool, t *testing.T) {
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
defer srv.Close()
// create a manifest with some data at the root path
@@ -279,7 +612,7 @@ func TestBzzRootRedirect(t *testing.T) {
Size: int64(len(data)),
},
}
- hash, err := client.Upload(file, "")
+ hash, err := client.Upload(file, "", toEncrypt)
if err != nil {
t.Fatal(err)
}
@@ -318,3 +651,31 @@ func TestBzzRootRedirect(t *testing.T) {
t.Fatalf("expected response to equal %q, got %q", data, gotData)
}
}
+
+func TestMethodsNotAllowed(t *testing.T) {
+ srv := testutil.NewTestSwarmServer(t, serverFunc)
+ defer srv.Close()
+ databytes := "bar"
+ for _, c := range []struct {
+ url string
+ code int
+ }{
+ {
+ url: fmt.Sprintf("%s/bzz-list:/", srv.URL),
+ code: 405,
+ }, {
+ url: fmt.Sprintf("%s/bzz-hash:/", srv.URL),
+ code: 405,
+ },
+ {
+ url: fmt.Sprintf("%s/bzz-immutable:/", srv.URL),
+ code: 405,
+ },
+ } {
+ res, _ := http.Post(c.url, "text/plain", bytes.NewReader([]byte(databytes)))
+ if res.StatusCode != c.code {
+ t.Fatal("should have failed")
+ }
+ }
+
+}
diff --git a/swarm/api/http/templates.go b/swarm/api/http/templates.go
index cd9d21289..ffd816493 100644
--- a/swarm/api/http/templates.go
+++ b/swarm/api/http/templates.go
@@ -78,7 +78,6 @@ var landingPageTemplate = template.Must(template.New("landingPage").Parse(`
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" ww="chrome=1">
<meta name="description" content="Ethereum/Swarm Landing page">
- <meta property="og:url" content="https://swarm-gateways.net/bzz:/theswarm.eth">
<style>
body, div, header, footer {
@@ -206,7 +205,7 @@ var landingPageTemplate = template.Must(template.New("landingPage").Parse(`
<footer>
<p>
Swarm: Serverless Hosting Incentivised Peer-To-Peer Storage And Content Distribution<br/>
- <a href="http://swarm-gateways.net/bzz:/theswarm.eth">Swarm</a>
+ <a href="/bzz:/theswarm.eth">Swarm</a>
</p>
</footer>
diff --git a/swarm/api/manifest.go b/swarm/api/manifest.go
index 685a300fc..28597636e 100644
--- a/swarm/api/manifest.go
+++ b/swarm/api/manifest.go
@@ -24,16 +24,18 @@ import (
"io"
"net/http"
"strings"
- "sync"
"time"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/ethereum/go-ethereum/swarm/log"
"github.com/ethereum/go-ethereum/swarm/storage"
)
const (
- ManifestType = "application/bzz-manifest+json"
+ ManifestType = "application/bzz-manifest+json"
+ ResourceContentType = "application/bzz-resource"
+
+ manifestSizeLimit = 5 * 1024 * 1024
)
// Manifest represents a swarm manifest
@@ -59,38 +61,58 @@ type ManifestList struct {
}
// NewManifest creates and stores a new, empty manifest
-func (a *Api) NewManifest() (storage.Key, error) {
+func (a *API) NewManifest(toEncrypt bool) (storage.Address, error) {
var manifest Manifest
data, err := json.Marshal(&manifest)
if err != nil {
return nil, err
}
- return a.Store(bytes.NewReader(data), int64(len(data)), &sync.WaitGroup{})
+ key, wait, err := a.Store(bytes.NewReader(data), int64(len(data)), toEncrypt)
+ wait()
+ return key, err
+}
+
+// Manifest hack for supporting Mutable Resource Updates from the bzz: scheme
+// see swarm/api/api.go:API.Get() for more information
+func (a *API) NewResourceManifest(resourceAddr string) (storage.Address, error) {
+ var manifest Manifest
+ entry := ManifestEntry{
+ Hash: resourceAddr,
+ ContentType: ResourceContentType,
+ }
+ manifest.Entries = append(manifest.Entries, entry)
+ data, err := json.Marshal(&manifest)
+ if err != nil {
+ return nil, err
+ }
+ key, _, err := a.Store(bytes.NewReader(data), int64(len(data)), false)
+ return key, err
}
// ManifestWriter is used to add and remove entries from an underlying manifest
type ManifestWriter struct {
- api *Api
+ api *API
trie *manifestTrie
quitC chan bool
}
-func (a *Api) NewManifestWriter(key storage.Key, quitC chan bool) (*ManifestWriter, error) {
- trie, err := loadManifest(a.dpa, key, quitC)
+func (a *API) NewManifestWriter(addr storage.Address, quitC chan bool) (*ManifestWriter, error) {
+ trie, err := loadManifest(a.fileStore, addr, quitC)
if err != nil {
- return nil, fmt.Errorf("error loading manifest %s: %s", key, err)
+ return nil, fmt.Errorf("error loading manifest %s: %s", addr, err)
}
return &ManifestWriter{a, trie, quitC}, nil
}
// AddEntry stores the given data and adds the resulting key to the manifest
-func (m *ManifestWriter) AddEntry(data io.Reader, e *ManifestEntry) (storage.Key, error) {
- key, err := m.api.Store(data, e.Size, nil)
+func (m *ManifestWriter) AddEntry(data io.Reader, e *ManifestEntry) (storage.Address, error) {
+
+ key, _, err := m.api.Store(data, e.Size, m.trie.encrypted)
if err != nil {
return nil, err
}
entry := newManifestTrieEntry(e, nil)
- entry.Hash = key.String()
+ entry.Hash = key.Hex()
m.trie.addEntry(entry, m.quitC)
return key, nil
}
@@ -102,29 +124,29 @@ func (m *ManifestWriter) RemoveEntry(path string) error {
}
// Store stores the manifest, returning the resulting storage key
-func (m *ManifestWriter) Store() (storage.Key, error) {
- return m.trie.hash, m.trie.recalcAndStore()
+func (m *ManifestWriter) Store() (storage.Address, error) {
+ return m.trie.ref, m.trie.recalcAndStore()
}
// ManifestWalker is used to recursively walk the entries in the manifest and
// all of its submanifests
type ManifestWalker struct {
- api *Api
+ api *API
trie *manifestTrie
quitC chan bool
}
-func (a *Api) NewManifestWalker(key storage.Key, quitC chan bool) (*ManifestWalker, error) {
- trie, err := loadManifest(a.dpa, key, quitC)
+func (a *API) NewManifestWalker(addr storage.Address, quitC chan bool) (*ManifestWalker, error) {
+ trie, err := loadManifest(a.fileStore, addr, quitC)
if err != nil {
- return nil, fmt.Errorf("error loading manifest %s: %s", key, err)
+ return nil, fmt.Errorf("error loading manifest %s: %s", addr, err)
}
return &ManifestWalker{a, trie, quitC}, nil
}
-// SkipManifest is used as a return value from WalkFn to indicate that the
+// ErrSkipManifest is used as a return value from WalkFn to indicate that the
// manifest should be skipped
-var SkipManifest = errors.New("skip this manifest")
+var ErrSkipManifest = errors.New("skip this manifest")
// WalkFn is the type of function called for each entry visited by a recursive
// manifest walk
@@ -144,7 +166,7 @@ func (m *ManifestWalker) walk(trie *manifestTrie, prefix string, walkFn WalkFn)
entry.Path = prefix + entry.Path
err := walkFn(&entry.ManifestEntry)
if err != nil {
- if entry.ContentType == ManifestType && err == SkipManifest {
+ if entry.ContentType == ManifestType && err == ErrSkipManifest {
continue
}
return err
@@ -163,9 +185,10 @@ func (m *ManifestWalker) walk(trie *manifestTrie, prefix string, walkFn WalkFn)
}
type manifestTrie struct {
- dpa *storage.DPA
- entries [257]*manifestTrieEntry // indexed by first character of basePath, entries[256] is the empty basePath entry
- hash storage.Key // if hash != nil, it is stored
+ fileStore *storage.FileStore
+ entries [257]*manifestTrieEntry // indexed by first character of basePath, entries[256] is the empty basePath entry
+ ref storage.Address // if ref != nil, it is stored
+ encrypted bool
}
func newManifestTrieEntry(entry *ManifestEntry, subtrie *manifestTrie) *manifestTrieEntry {
@@ -181,48 +204,55 @@ type manifestTrieEntry struct {
subtrie *manifestTrie
}
-func loadManifest(dpa *storage.DPA, hash storage.Key, quitC chan bool) (trie *manifestTrie, err error) { // non-recursive, subtrees are downloaded on-demand
-
- log.Trace(fmt.Sprintf("manifest lookup key: '%v'.", hash.Log()))
- // retrieve manifest via DPA
- manifestReader := dpa.Retrieve(hash)
- return readManifest(manifestReader, hash, dpa, quitC)
+func loadManifest(fileStore *storage.FileStore, hash storage.Address, quitC chan bool) (trie *manifestTrie, err error) { // non-recursive, subtrees are downloaded on-demand
+ log.Trace("manifest lookup", "key", hash)
+ // retrieve manifest via FileStore
+ manifestReader, isEncrypted := fileStore.Retrieve(hash)
+ log.Trace("reader retrieved", "key", hash)
+ return readManifest(manifestReader, hash, fileStore, isEncrypted, quitC)
}
-func readManifest(manifestReader storage.LazySectionReader, hash storage.Key, dpa *storage.DPA, quitC chan bool) (trie *manifestTrie, err error) { // non-recursive, subtrees are downloaded on-demand
+func readManifest(manifestReader storage.LazySectionReader, hash storage.Address, fileStore *storage.FileStore, isEncrypted bool, quitC chan bool) (trie *manifestTrie, err error) { // non-recursive, subtrees are downloaded on-demand
// TODO check size for oversized manifests
size, err := manifestReader.Size(quitC)
if err != nil { // size == 0
// can't determine size means we don't have the root chunk
+ log.Trace("manifest not found", "key", hash)
err = fmt.Errorf("Manifest not Found")
return
}
+ if size > manifestSizeLimit {
+ log.Warn("manifest exceeds size limit", "key", hash, "size", size, "limit", manifestSizeLimit)
+ err = fmt.Errorf("Manifest size of %v bytes exceeds the %v byte limit", size, manifestSizeLimit)
+ return
+ }
manifestData := make([]byte, size)
read, err := manifestReader.Read(manifestData)
if int64(read) < size {
- log.Trace(fmt.Sprintf("Manifest %v not found.", hash.Log()))
+ log.Trace("manifest not found", "key", hash)
if err == nil {
err = fmt.Errorf("Manifest retrieval cut short: read %v, expect %v", read, size)
}
return
}
- log.Trace(fmt.Sprintf("Manifest %v retrieved", hash.Log()))
+ log.Debug("manifest retrieved", "key", hash)
var man struct {
Entries []*manifestTrieEntry `json:"entries"`
}
err = json.Unmarshal(manifestData, &man)
if err != nil {
err = fmt.Errorf("Manifest %v is malformed: %v", hash.Log(), err)
- log.Trace(fmt.Sprintf("%v", err))
+ log.Trace("malformed manifest", "key", hash)
return
}
- log.Trace(fmt.Sprintf("Manifest %v has %d entries.", hash.Log(), len(man.Entries)))
+ log.Trace("manifest entries", "key", hash, "len", len(man.Entries))
trie = &manifestTrie{
- dpa: dpa,
+ fileStore: fileStore,
+ encrypted: isEncrypted,
}
for _, entry := range man.Entries {
trie.addEntry(entry, quitC)
@@ -230,18 +260,18 @@ func readManifest(manifestReader storage.LazySectionReader, hash storage.Key, dp
return
}
-func (self *manifestTrie) addEntry(entry *manifestTrieEntry, quitC chan bool) {
- self.hash = nil // trie modified, hash needs to be re-calculated on demand
+func (mt *manifestTrie) addEntry(entry *manifestTrieEntry, quitC chan bool) {
+ mt.ref = nil // trie modified, hash needs to be re-calculated on demand
if len(entry.Path) == 0 {
- self.entries[256] = entry
+ mt.entries[256] = entry
return
}
b := entry.Path[0]
- oldentry := self.entries[b]
+ oldentry := mt.entries[b]
if (oldentry == nil) || (oldentry.Path == entry.Path && oldentry.ContentType != ManifestType) {
- self.entries[b] = entry
+ mt.entries[b] = entry
return
}
@@ -251,7 +281,7 @@ func (self *manifestTrie) addEntry(entry *manifestTrieEntry, quitC chan bool) {
}
if (oldentry.ContentType == ManifestType) && (cpl == len(oldentry.Path)) {
- if self.loadSubTrie(oldentry, quitC) != nil {
+ if mt.loadSubTrie(oldentry, quitC) != nil {
return
}
entry.Path = entry.Path[cpl:]
@@ -263,21 +293,22 @@ func (self *manifestTrie) addEntry(entry *manifestTrieEntry, quitC chan bool) {
commonPrefix := entry.Path[:cpl]
subtrie := &manifestTrie{
- dpa: self.dpa,
+ fileStore: mt.fileStore,
+ encrypted: mt.encrypted,
}
entry.Path = entry.Path[cpl:]
oldentry.Path = oldentry.Path[cpl:]
subtrie.addEntry(entry, quitC)
subtrie.addEntry(oldentry, quitC)
- self.entries[b] = newManifestTrieEntry(&ManifestEntry{
+ mt.entries[b] = newManifestTrieEntry(&ManifestEntry{
Path: commonPrefix,
ContentType: ManifestType,
}, subtrie)
}
-func (self *manifestTrie) getCountLast() (cnt int, entry *manifestTrieEntry) {
- for _, e := range self.entries {
+func (mt *manifestTrie) getCountLast() (cnt int, entry *manifestTrieEntry) {
+ for _, e := range mt.entries {
if e != nil {
cnt++
entry = e
@@ -286,27 +317,27 @@ func (self *manifestTrie) getCountLast() (cnt int, entry *manifestTrieEntry) {
return
}
-func (self *manifestTrie) deleteEntry(path string, quitC chan bool) {
- self.hash = nil // trie modified, hash needs to be re-calculated on demand
+func (mt *manifestTrie) deleteEntry(path string, quitC chan bool) {
+ mt.ref = nil // trie modified, hash needs to be re-calculated on demand
if len(path) == 0 {
- self.entries[256] = nil
+ mt.entries[256] = nil
return
}
b := path[0]
- entry := self.entries[b]
+ entry := mt.entries[b]
if entry == nil {
return
}
if entry.Path == path {
- self.entries[b] = nil
+ mt.entries[b] = nil
return
}
epl := len(entry.Path)
if (entry.ContentType == ManifestType) && (len(path) >= epl) && (path[:epl] == entry.Path) {
- if self.loadSubTrie(entry, quitC) != nil {
+ if mt.loadSubTrie(entry, quitC) != nil {
return
}
entry.subtrie.deleteEntry(path[epl:], quitC)
@@ -317,13 +348,13 @@ func (self *manifestTrie) deleteEntry(path string, quitC chan bool) {
if lastentry != nil {
lastentry.Path = entry.Path + lastentry.Path
}
- self.entries[b] = lastentry
+ mt.entries[b] = lastentry
}
}
}
-func (self *manifestTrie) recalcAndStore() error {
- if self.hash != nil {
+func (mt *manifestTrie) recalcAndStore() error {
+ if mt.ref != nil {
return nil
}
@@ -331,14 +362,14 @@ func (self *manifestTrie) recalcAndStore() error {
buffer.WriteString(`{"entries":[`)
list := &Manifest{}
- for _, entry := range self.entries {
+ for _, entry := range mt.entries {
if entry != nil {
if entry.Hash == "" { // TODO: paralellize
err := entry.subtrie.recalcAndStore()
if err != nil {
return err
}
- entry.Hash = entry.subtrie.hash.String()
+ entry.Hash = entry.subtrie.ref.Hex()
}
list.Entries = append(list.Entries, entry.ManifestEntry)
}
@@ -351,23 +382,22 @@ func (self *manifestTrie) recalcAndStore() error {
}
sr := bytes.NewReader(manifest)
- wg := &sync.WaitGroup{}
- key, err2 := self.dpa.Store(sr, int64(len(manifest)), wg, nil)
- wg.Wait()
- self.hash = key
+ key, wait, err2 := mt.fileStore.Store(sr, int64(len(manifest)), mt.encrypted)
+ wait()
+ mt.ref = key
return err2
}
-func (self *manifestTrie) loadSubTrie(entry *manifestTrieEntry, quitC chan bool) (err error) {
+func (mt *manifestTrie) loadSubTrie(entry *manifestTrieEntry, quitC chan bool) (err error) {
if entry.subtrie == nil {
hash := common.Hex2Bytes(entry.Hash)
- entry.subtrie, err = loadManifest(self.dpa, hash, quitC)
+ entry.subtrie, err = loadManifest(mt.fileStore, hash, quitC)
entry.Hash = "" // might not match, should be recalculated
}
return
}
-func (self *manifestTrie) listWithPrefixInt(prefix, rp string, quitC chan bool, cb func(entry *manifestTrieEntry, suffix string)) error {
+func (mt *manifestTrie) listWithPrefixInt(prefix, rp string, quitC chan bool, cb func(entry *manifestTrieEntry, suffix string)) error {
plen := len(prefix)
var start, stop int
if plen == 0 {
@@ -384,7 +414,7 @@ func (self *manifestTrie) listWithPrefixInt(prefix, rp string, quitC chan bool,
return fmt.Errorf("aborted")
default:
}
- entry := self.entries[i]
+ entry := mt.entries[i]
if entry != nil {
epl := len(entry.Path)
if entry.ContentType == ManifestType {
@@ -393,7 +423,7 @@ func (self *manifestTrie) listWithPrefixInt(prefix, rp string, quitC chan bool,
l = epl
}
if prefix[:l] == entry.Path[:l] {
- err := self.loadSubTrie(entry, quitC)
+ err := mt.loadSubTrie(entry, quitC)
if err != nil {
return err
}
@@ -412,23 +442,22 @@ func (self *manifestTrie) listWithPrefixInt(prefix, rp string, quitC chan bool,
return nil
}
-func (self *manifestTrie) listWithPrefix(prefix string, quitC chan bool, cb func(entry *manifestTrieEntry, suffix string)) (err error) {
- return self.listWithPrefixInt(prefix, "", quitC, cb)
+func (mt *manifestTrie) listWithPrefix(prefix string, quitC chan bool, cb func(entry *manifestTrieEntry, suffix string)) (err error) {
+ return mt.listWithPrefixInt(prefix, "", quitC, cb)
}
-func (self *manifestTrie) findPrefixOf(path string, quitC chan bool) (entry *manifestTrieEntry, pos int) {
-
+func (mt *manifestTrie) findPrefixOf(path string, quitC chan bool) (entry *manifestTrieEntry, pos int) {
log.Trace(fmt.Sprintf("findPrefixOf(%s)", path))
if len(path) == 0 {
- return self.entries[256], 0
+ return mt.entries[256], 0
}
//see if first char is in manifest entries
b := path[0]
- entry = self.entries[b]
+ entry = mt.entries[b]
if entry == nil {
- return self.entries[256], 0
+ return mt.entries[256], 0
}
epl := len(entry.Path)
@@ -436,7 +465,7 @@ func (self *manifestTrie) findPrefixOf(path string, quitC chan bool) (entry *man
if len(path) <= epl {
if entry.Path[:len(path)] == path {
if entry.ContentType == ManifestType {
- err := self.loadSubTrie(entry, quitC)
+ err := mt.loadSubTrie(entry, quitC)
if err == nil && entry.subtrie != nil {
subentries := entry.subtrie.entries
for i := 0; i < len(subentries); i++ {
@@ -457,7 +486,7 @@ func (self *manifestTrie) findPrefixOf(path string, quitC chan bool) (entry *man
log.Trace(fmt.Sprintf("entry.ContentType = %v", entry.ContentType))
//the subentry is a manifest, load subtrie
if entry.ContentType == ManifestType && (strings.Contains(entry.Path, path) || strings.Contains(path, entry.Path)) {
- err := self.loadSubTrie(entry, quitC)
+ err := mt.loadSubTrie(entry, quitC)
if err != nil {
return nil, 0
}
@@ -478,7 +507,7 @@ func (self *manifestTrie) findPrefixOf(path string, quitC chan bool) (entry *man
pos = epl
}
}
- return
+ return nil, 0
}
// file system manifest always contains regularized paths
@@ -495,10 +524,10 @@ func RegularSlashes(path string) (res string) {
return
}
-func (self *manifestTrie) getEntry(spath string) (entry *manifestTrieEntry, fullpath string) {
+func (mt *manifestTrie) getEntry(spath string) (entry *manifestTrieEntry, fullpath string) {
path := RegularSlashes(spath)
var pos int
quitC := make(chan bool)
- entry, pos = self.findPrefixOf(path, quitC)
+ entry, pos = mt.findPrefixOf(path, quitC)
return entry, path[:pos]
}
diff --git a/swarm/api/manifest_test.go b/swarm/api/manifest_test.go
index 7098ca16f..d65f023f8 100644
--- a/swarm/api/manifest_test.go
+++ b/swarm/api/manifest_test.go
@@ -42,7 +42,9 @@ func manifest(paths ...string) (manifestReader storage.LazySectionReader) {
func testGetEntry(t *testing.T, path, match string, multiple bool, paths ...string) *manifestTrie {
quitC := make(chan bool)
- trie, err := readManifest(manifest(paths...), nil, nil, quitC)
+ fileStore := storage.NewFileStore(nil, storage.NewFileStoreParams())
+ ref := make([]byte, fileStore.HashSize())
+ trie, err := readManifest(manifest(paths...), ref, fileStore, false, quitC)
if err != nil {
t.Errorf("unexpected error making manifest: %v", err)
}
@@ -97,7 +99,9 @@ func TestGetEntry(t *testing.T) {
func TestExactMatch(t *testing.T) {
quitC := make(chan bool)
mf := manifest("shouldBeExactMatch.css", "shouldBeExactMatch.css.map")
- trie, err := readManifest(mf, nil, nil, quitC)
+ fileStore := storage.NewFileStore(nil, storage.NewFileStoreParams())
+ ref := make([]byte, fileStore.HashSize())
+ trie, err := readManifest(mf, ref, fileStore, false, quitC)
if err != nil {
t.Errorf("unexpected error making manifest: %v", err)
}
@@ -128,7 +132,9 @@ func TestAddFileWithManifestPath(t *testing.T) {
reader := &storage.LazyTestSectionReader{
SectionReader: io.NewSectionReader(bytes.NewReader(manifest), 0, int64(len(manifest))),
}
- trie, err := readManifest(reader, nil, nil, nil)
+ fileStore := storage.NewFileStore(nil, storage.NewFileStoreParams())
+ ref := make([]byte, fileStore.HashSize())
+ trie, err := readManifest(reader, ref, fileStore, false, nil)
if err != nil {
t.Fatal(err)
}
@@ -144,3 +150,26 @@ func TestAddFileWithManifestPath(t *testing.T) {
checkEntry(t, "ac", "ac", false, trie)
checkEntry(t, "a", "a", false, trie)
}
+
+// TestReadManifestOverSizeLimit creates a manifest reader with data longer then
+// manifestSizeLimit and checks if readManifest function will return the exact error
+// message.
+// The manifest data is not in json-encoded format, preventing possbile
+// successful parsing attempts if limit check fails.
+func TestReadManifestOverSizeLimit(t *testing.T) {
+ manifest := make([]byte, manifestSizeLimit+1)
+ reader := &storage.LazyTestSectionReader{
+ SectionReader: io.NewSectionReader(bytes.NewReader(manifest), 0, int64(len(manifest))),
+ }
+ _, err := readManifest(reader, storage.Address{}, nil, false, nil)
+ if err == nil {
+ t.Fatal("got no error from readManifest")
+ }
+ // Error message is part of the http response body
+ // which justifies exact string validation.
+ got := err.Error()
+ want := fmt.Sprintf("Manifest size of %v bytes exceeds the %v byte limit", len(manifest), manifestSizeLimit)
+ if got != want {
+ t.Fatalf("got error mesage %q, expected %q", got, want)
+ }
+}
diff --git a/swarm/api/storage.go b/swarm/api/storage.go
index 0e3abecfe..6ab4af6c4 100644
--- a/swarm/api/storage.go
+++ b/swarm/api/storage.go
@@ -16,7 +16,11 @@
package api
-import "path"
+import (
+ "path"
+
+ "github.com/ethereum/go-ethereum/swarm/storage"
+)
type Response struct {
MimeType string
@@ -30,10 +34,10 @@ type Response struct {
//
// DEPRECATED: Use the HTTP API instead
type Storage struct {
- api *Api
+ api *API
}
-func NewStorage(api *Api) *Storage {
+func NewStorage(api *API) *Storage {
return &Storage{api}
}
@@ -41,12 +45,8 @@ func NewStorage(api *Api) *Storage {
// its content type
//
// DEPRECATED: Use the HTTP API instead
-func (self *Storage) Put(content, contentType string) (string, error) {
- key, err := self.api.Put(content, contentType)
- if err != nil {
- return "", err
- }
- return key.String(), err
+func (s *Storage) Put(content, contentType string, toEncrypt bool) (storage.Address, func(), error) {
+ return s.api.Put(content, contentType, toEncrypt)
}
// Get retrieves the content from bzzpath and reads the response in full
@@ -57,16 +57,16 @@ func (self *Storage) Put(content, contentType string) (string, error) {
// size is resp.Size
//
// DEPRECATED: Use the HTTP API instead
-func (self *Storage) Get(bzzpath string) (*Response, error) {
+func (s *Storage) Get(bzzpath string) (*Response, error) {
uri, err := Parse(path.Join("bzz:/", bzzpath))
if err != nil {
return nil, err
}
- key, err := self.api.Resolve(uri)
+ addr, err := s.api.Resolve(uri)
if err != nil {
return nil, err
}
- reader, mimeType, status, err := self.api.Get(key, uri.Path)
+ reader, mimeType, status, _, err := s.api.Get(addr, uri.Path)
if err != nil {
return nil, err
}
@@ -87,18 +87,18 @@ func (self *Storage) Get(bzzpath string) (*Response, error) {
// and merge on to it. creating an entry w conentType (mime)
//
// DEPRECATED: Use the HTTP API instead
-func (self *Storage) Modify(rootHash, path, contentHash, contentType string) (newRootHash string, err error) {
+func (s *Storage) Modify(rootHash, path, contentHash, contentType string) (newRootHash string, err error) {
uri, err := Parse("bzz:/" + rootHash)
if err != nil {
return "", err
}
- key, err := self.api.Resolve(uri)
+ addr, err := s.api.Resolve(uri)
if err != nil {
return "", err
}
- key, err = self.api.Modify(key, path, contentHash, contentType)
+ addr, err = s.api.Modify(addr, path, contentHash, contentType)
if err != nil {
return "", err
}
- return key.String(), nil
+ return addr.Hex(), nil
}
diff --git a/swarm/api/storage_test.go b/swarm/api/storage_test.go
index d260dd61d..9d23e8f13 100644
--- a/swarm/api/storage_test.go
+++ b/swarm/api/storage_test.go
@@ -20,22 +20,24 @@ import (
"testing"
)
-func testStorage(t *testing.T, f func(*Storage)) {
- testApi(t, func(api *Api) {
- f(NewStorage(api))
+func testStorage(t *testing.T, f func(*Storage, bool)) {
+ testAPI(t, func(api *API, toEncrypt bool) {
+ f(NewStorage(api), toEncrypt)
})
}
func TestStoragePutGet(t *testing.T) {
- testStorage(t, func(api *Storage) {
+ testStorage(t, func(api *Storage, toEncrypt bool) {
content := "hello"
exp := expResponse(content, "text/plain", 0)
// exp := expResponse([]byte(content), "text/plain", 0)
- bzzhash, err := api.Put(content, exp.MimeType)
+ bzzkey, wait, err := api.Put(content, exp.MimeType, toEncrypt)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
- // to check put against the Api#Get
+ wait()
+ bzzhash := bzzkey.Hex()
+ // to check put against the API#Get
resp0 := testGet(t, api.api, bzzhash, "")
checkResponse(t, resp0, exp)
diff --git a/swarm/api/testapi.go b/swarm/api/testapi.go
index 6631196c1..4c7d0982b 100644
--- a/swarm/api/testapi.go
+++ b/swarm/api/testapi.go
@@ -21,26 +21,26 @@ import (
)
type Control struct {
- api *Api
+ api *API
hive *network.Hive
}
-func NewControl(api *Api, hive *network.Hive) *Control {
+func NewControl(api *API, hive *network.Hive) *Control {
return &Control{api, hive}
}
-func (self *Control) BlockNetworkRead(on bool) {
- self.hive.BlockNetworkRead(on)
-}
-
-func (self *Control) SyncEnabled(on bool) {
- self.hive.SyncEnabled(on)
-}
-
-func (self *Control) SwapEnabled(on bool) {
- self.hive.SwapEnabled(on)
-}
-
-func (self *Control) Hive() string {
- return self.hive.String()
+//func (self *Control) BlockNetworkRead(on bool) {
+// self.hive.BlockNetworkRead(on)
+//}
+//
+//func (self *Control) SyncEnabled(on bool) {
+// self.hive.SyncEnabled(on)
+//}
+//
+//func (self *Control) SwapEnabled(on bool) {
+// self.hive.SwapEnabled(on)
+//}
+//
+func (c *Control) Hive() string {
+ return c.hive.String()
}
diff --git a/swarm/api/uri.go b/swarm/api/uri.go
index d8aafedf4..14965e0d9 100644
--- a/swarm/api/uri.go
+++ b/swarm/api/uri.go
@@ -19,9 +19,17 @@ package api
import (
"fmt"
"net/url"
+ "regexp"
"strings"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/swarm/storage"
)
+//matches hex swarm hashes
+// TODO: this is bad, it should not be hardcoded how long is a hash
+var hashMatcher = regexp.MustCompile("^([0-9A-Fa-f]{64})([0-9A-Fa-f]{64})?$")
+
// URI is a reference to content stored in swarm.
type URI struct {
// Scheme has one of the following values:
@@ -32,18 +40,15 @@ type URI struct {
// (address is not resolved)
// * bzz-list - list of all files contained in a swarm manifest
//
- // Deprecated Schemes:
- // * bzzr - raw swarm content
- // * bzzi - immutable URI of an entry in a swarm manifest
- // (address is not resolved)
- // * bzz-hash - hash of swarm content
- //
Scheme string
- // Addr is either a hexadecimal storage key or it an address which
- // resolves to a storage key
+ // Addr is either a hexadecimal storage address or it an address which
+ // resolves to a storage address
Addr string
+ // addr stores the parsed storage address
+ addr storage.Address
+
// Path is the path to the content within a swarm manifest
Path string
}
@@ -59,7 +64,6 @@ type URI struct {
// * <scheme>://<addr>/<path>
//
// with scheme one of bzz, bzz-raw, bzz-immutable, bzz-list or bzz-hash
-// or deprecated ones bzzr and bzzi
func Parse(rawuri string) (*URI, error) {
u, err := url.Parse(rawuri)
if err != nil {
@@ -69,7 +73,7 @@ func Parse(rawuri string) (*URI, error) {
// check the scheme is valid
switch uri.Scheme {
- case "bzz", "bzz-raw", "bzz-immutable", "bzz-list", "bzz-hash", "bzzr", "bzzi":
+ case "bzz", "bzz-raw", "bzz-immutable", "bzz-list", "bzz-hash", "bzz-resource":
default:
return nil, fmt.Errorf("unknown scheme %q", u.Scheme)
}
@@ -91,6 +95,9 @@ func Parse(rawuri string) (*URI, error) {
}
return uri, nil
}
+func (u *URI) Resource() bool {
+ return u.Scheme == "bzz-resource"
+}
func (u *URI) Raw() bool {
return u.Scheme == "bzz-raw"
@@ -104,14 +111,6 @@ func (u *URI) List() bool {
return u.Scheme == "bzz-list"
}
-func (u *URI) DeprecatedRaw() bool {
- return u.Scheme == "bzzr"
-}
-
-func (u *URI) DeprecatedImmutable() bool {
- return u.Scheme == "bzzi"
-}
-
func (u *URI) Hash() bool {
return u.Scheme == "bzz-hash"
}
@@ -119,3 +118,14 @@ func (u *URI) Hash() bool {
func (u *URI) String() string {
return u.Scheme + ":/" + u.Addr + "/" + u.Path
}
+
+func (u *URI) Address() storage.Address {
+ if u.addr != nil {
+ return u.addr
+ }
+ if hashMatcher.MatchString(u.Addr) {
+ u.addr = common.Hex2Bytes(u.Addr)
+ return u.addr
+ }
+ return nil
+}
diff --git a/swarm/api/uri_test.go b/swarm/api/uri_test.go
index 137b4505d..ea649e273 100644
--- a/swarm/api/uri_test.go
+++ b/swarm/api/uri_test.go
@@ -17,8 +17,11 @@
package api
import (
+ "bytes"
"reflect"
"testing"
+
+ "github.com/ethereum/go-ethereum/swarm/storage"
)
func TestParseURI(t *testing.T) {
@@ -32,6 +35,8 @@ func TestParseURI(t *testing.T) {
expectHash bool
expectDeprecatedRaw bool
expectDeprecatedImmutable bool
+ expectValidKey bool
+ expectAddr storage.Address
}
tests := []test{
{
@@ -120,24 +125,17 @@ func TestParseURI(t *testing.T) {
expectList: true,
},
{
- uri: "bzzr:",
- expectURI: &URI{Scheme: "bzzr"},
- expectDeprecatedRaw: true,
- },
- {
- uri: "bzzr:/",
- expectURI: &URI{Scheme: "bzzr"},
- expectDeprecatedRaw: true,
- },
- {
- uri: "bzzi:",
- expectURI: &URI{Scheme: "bzzi"},
- expectDeprecatedImmutable: true,
- },
- {
- uri: "bzzi:/",
- expectURI: &URI{Scheme: "bzzi"},
- expectDeprecatedImmutable: true,
+ uri: "bzz-raw://4378d19c26590f1a818ed7d6a62c3809e149b0999cab5ce5f26233b3b423bf8c",
+ expectURI: &URI{Scheme: "bzz-raw",
+ Addr: "4378d19c26590f1a818ed7d6a62c3809e149b0999cab5ce5f26233b3b423bf8c",
+ },
+ expectValidKey: true,
+ expectRaw: true,
+ expectAddr: storage.Address{67, 120, 209, 156, 38, 89, 15, 26,
+ 129, 142, 215, 214, 166, 44, 56, 9,
+ 225, 73, 176, 153, 156, 171, 92, 229,
+ 242, 98, 51, 179, 180, 35, 191, 140,
+ },
},
}
for _, x := range tests {
@@ -166,11 +164,14 @@ func TestParseURI(t *testing.T) {
if actual.Hash() != x.expectHash {
t.Fatalf("expected %s hash to be %t, got %t", x.uri, x.expectHash, actual.Hash())
}
- if actual.DeprecatedRaw() != x.expectDeprecatedRaw {
- t.Fatalf("expected %s deprecated raw to be %t, got %t", x.uri, x.expectDeprecatedRaw, actual.DeprecatedRaw())
- }
- if actual.DeprecatedImmutable() != x.expectDeprecatedImmutable {
- t.Fatalf("expected %s deprecated immutable to be %t, got %t", x.uri, x.expectDeprecatedImmutable, actual.DeprecatedImmutable())
+ if x.expectValidKey {
+ if actual.Address() == nil {
+ t.Fatalf("expected %s to return a valid key, got nil", x.uri)
+ } else {
+ if !bytes.Equal(x.expectAddr, actual.Address()) {
+ t.Fatalf("expected %s to be decoded to %v", x.expectURI.Addr, x.expectAddr)
+ }
+ }
}
}
}