Commit Graph

227 Commits

Author SHA1 Message Date
Brad Fitzpatrick 9bafcb9592 pkg/client: remove old debug print
Change-Id: I984b537f71a31eeb184a28713e27a79fdfaa69b6
2019-03-25 15:36:39 -07:00
mpl 0888d28260 all: fix misc bugs found with go test ./...
Change-Id: If5bda860c9cc6bdc14c2977646516c58d17d62de
2018-08-17 02:17:54 +02:00
Euan Kemp 13a8e94895 pkg/client: return error for unindexed attr search
Calling 'GetPermanodesWithAttr', as currently written, will return an
empty list for any unindexed parameters.

Rather than always returning an empty list if the user asks for a
unindexed attribute, error out.

Also add documentation of this potential foot-gun for users of the
client.

Change-Id: Iadc1b5a00aa709584affb89a1397e82aaffb692f
2018-07-25 12:56:40 -07:00
mpl a538874c07 pkg/client: move upload test to pkg/test/integration
In 877eafa49b , pkg/server started
importing pkg/client , since the server has to be able to fetch blobs
from a share claim of another server. This introduced a circular
dependency in tests, as pkg/client/upload_test.go instantiates a server.

As the test uses both a client and a server, and tests uploading between
the two, it seems fitting to move it to pkg/test/integration, which
breaks the circular dep.

Change-Id: I2458ffd72912ff6e9c1a0f67e187d54cc895c2e9
2018-06-27 21:08:46 +02:00
mpl b48e2de0c6 pkg/blobserver: print RemoveBlobs errors
Both on server and client sides. So far we did on neither.

Fixes #1186

Change-Id: I7ff3484d82329b4f83a5f3fa8f150ac7ad7f732c
2018-06-11 19:32:35 +02:00
Brad Fitzpatrick 41ed0359e1 client, serverinit: fix tests from API change in earlier change
I forgot to fix these as part of 8e71a705d.

Fixes #1171

Change-Id: I22402dfad36bc26fc598b760ab4514cee71e1e38
2018-05-18 09:48:17 -07:00
Brad Fitzpatrick f3f38f0c76 perkeepd, serverinit, gce: opaque-ify serverinit.Config, trim camlistored.go
This change has two major parts, which were interwoven enough to do
them in one change:

1) make serverinit.Config fully opaque, in prep for TOML configs #1134

2) shrink the massive server/perkeepd/camlistored.go file. It was out
   of control and had a bunch of code that better belonged
   elsewhere. This change moves a few hundred lines of code from
   camlistored.go into more logical places: internal/osutil/gce for
   GCE stuff, serverinit for config stuff (KeyRingAndId), etc.

I also added a TODO to make it possible to compile perkeepd without
any GCE stuff, which I saw as a possible and worthy goal only after
moving everything away.

Updates #1134

Change-Id: Iea6f84c5aca9c70b97806f4a201ec35e0f630e3b
2018-05-13 15:50:10 -07:00
mpl b76a4f6727 internal/osutil: revert to using "test safe" func for identitySecretRing
And while we're at it, rename said func (CamliConfigDir) to
PerkeepConfigDir.

Fixes #1161

Change-Id: Ia8c9b5826046437b77c8e16ee91912e31ad319a3
2018-05-12 02:12:03 +02:00
Brad Fitzpatrick 789f861964 all: rename some references to .config/camlistore to .config/perkeep
Updates #981

Change-Id: Id76fe17d80380bdb973bc85ec8f54ba9500aff40
2018-05-02 21:36:29 -07:00
Brad Fitzpatrick 46bb719dc5 buildinfo: track Version and Dockerfile separately
And don't hard-code VERSION info in the Dockerfile.

Change-Id: I35cb22fbb56cd634be4f1342c54ca86ce0e79901
2018-05-02 13:36:32 -07:00
Brad Fitzpatrick 12894d4630 all: Windows fixes (don't listen on file descriptors in test.World, etc)
test/integration: don't listen on file descriptors.
make.go: unrelated, but options to make it much faster.
internal/images: t.Skip on HEIC dependency failures

Fixes #1140
Updates golang/go#25210

Change-Id: I8092155411826d6ed1f8d85230b753d1369044af
2018-05-01 21:38:19 -07:00
Brad Fitzpatrick ca76a40bbc Rename camlistored to perkeepd.
Updates #981

Change-Id: I8fe43c240c149074c23128a89ab426af9cbf94b4
2018-04-21 11:06:09 -07:00
mpl ce4658abfc cmd: rename camput to pk-put, and make "pk put" call it
A new "put" mode is added to the pk command, so that the "pk put"
command can be used to create and upload blobs.

What this command does is actually just call the previously named
"camput" executable, which is renamed to "pk-put" in this change.

This involves adding a new way to register a mode in cmdmain, when such
a mode is just meant to call an external binary. To emphasize the
distinction, the existing func (to register a sub-command, or a mode) is
renamed from RegisterCommand to RegisterMode, and RegisterCommand is now
the name of the new func/way.

Updates #981
Updates #1056

Change-Id: Ief954c17aa88a376f551df7de4b4e9fe41ad96d1
2018-04-21 10:26:55 -07:00
Mathieu Lonjaret 1138cc7743 Merge "pkg/client: accept verified certificate on android" 2018-04-09 21:12:50 +00:00
mpl 01693b6a82 pkg/client: check client/server version mismatch
Since the search API changed at
2018-01-13-6e8a5930c9fee81640c6c75a9a549fec98064186, a server built
before that revision is incompatible with a client built at or after
that revision.

This change adds a check that is run when this incompatibility could
manifest by a JSON parsing error, in order to clarify the error message.

As a side note, even if there was not this search API breakage, a server
built before 27bacd3df1 would panic anyway
if a client built at or after 38f10a7bd0
tried uploading to it. Because of the wrong assumption that br.Hash()
is never nil, which can actually happen after sha224 is introduced
(client-side), and the server does not know about sha224.

Fixes #1074

Change-Id: I3dabf25c0200625e177e0f26308465cd35e8c750
2018-04-02 20:29:48 +02:00
Tilman Dilo c1ac581ac7 pkg/client: accept verified certificate on android
The android uploader used to only accept a server TLS certificate when
its fingerprint was specified as trusted in the client configuration. As
a result, certificates obtained by Let's Encrypt (or other CAs, for that
matter) were rejected unless treated as self-signed.

With this change, any connection verified by the standard TLS client
(using the system's root CA pool) is accepted as long as no
additional certificate fingerprint is given.

Closes #974

Change-Id: I499d41e9f48df709dda60724c6f55eca888feeb7
2018-03-27 00:32:48 +02:00
mpl 6dcbe2ee9c cmd/camtool: rename from camtool to pk
Updates #981
Updates #1056

Change-Id: Ib78c47a69fa9816d5ac6cc547586a2af321005e3
2018-03-06 16:20:59 +01:00
Paul Lindner 84b2c6b3e4 all: various lint fixes
- correct logging that logged functions instead of their value
- use ID vs Id naming
- use correct function names in comments

Change-Id: I61562cef7ebac7337ec6c85312cdf7915cb1a84b
2018-02-05 11:59:00 -08:00
mpl e4753aaff5 pkg/client: do not try to config server when OptionUseStorageClient
Fixes #1048

Change-Id: I5e4c6a6a905c774d0ff7b57014c97a6a77beb464
2018-01-31 17:05:25 +01:00
Mathieu Lonjaret 6e8a5930c9 all: make server advertise when it has legacy SHA-1 indexes, use that info
when its wholeref index lines contain any "sha1-" wholeref lines.

Then, have the client use that info when uploading files to also
compute the sha-1 (in addition to the sha-224) and ask the server for
both.

By client, we mean changes to cmd/camput, to pkg/client functions (for
camput and other Go clients, such as the apps), and to the web UI.

Also, add a -sha1 mode to devcam server, as well as the
CAMLI_SHA1_ENABLED env var, to facilitate testing/debugging of the
legacy sha1 mode.  Fix/document unrelated options in devcam server
while we're at it.

Change-Id: I369679d2a4719f6f8b409f78dd4d065e13a3f62f
2018-01-31 01:10:52 +01:00
Paul Lindner 459c75410e all: more renaming of Camlistore to Perkeep
Change-Id: I118e3cbcf20d80afeffc84f001388c4556f21628
2018-01-30 03:02:56 -08:00
mpl 26925d41a7 pkg/client: init http client and gate when noExtConfig
Fixes #1043

Change-Id: I7a7760de546c009de0da71f45f8cfa108f2585ac
2018-01-25 01:17:55 +01:00
Brad Fitzpatrick 66791480b0 cmd/client: remove NewStorageClient, convert to an option
Also fix some docs, rename some Camlistore to Perkeep, and make Close
close idle connections.

Change-Id: Ib903c7f01728d36b87301674094ca8967306cda1
2018-01-24 08:52:07 -08:00
Brad Fitzpatrick d4ff75359c pkg/client: reduce the number of New constructors, return error by default
This removes NewDefault and NewFromParams.

Now the default way to create a client is:

    client.New() -> (*Client, error)

Specifying a server is optional and now requires
client.OptionServer(server).

If the caller really wants to log.Fatal on error, they can use
client.NewOrFail.

Also, some of the boilerplate from GopherJS callers is now promoted to
be the default behavior in the client package.

Change-Id: Icb106cf3e13cc492fe5b2f7f240e1ad4227eaf33
2018-01-24 07:42:04 -08:00
Brad Fitzpatrick 38c2a87ad2 cmd/camtool: add "camtool whoami" subcommand
Also clean up and document the client package.

And misc cleanups.

Change-Id: I385d9948d8735deb37814ac45ac58851d8e58c75
2018-01-23 14:02:32 -08:00
Brad Fitzpatrick 66db09453f blobserver: add context to BlobRemover
Updates #733

Change-Id: I2fffb5cad59aa994441ee82ac5d940270113ee5a
2018-01-19 09:54:46 -08:00
Brad Fitzpatrick 194d4f9443 blobserver, all: add contexts to ReceiveBlob, Fetch & million resulting deps
I had intended for this to be a small change.

I was going to just add context.Context to the BlobReceiver interface,
but then I saw blob.Fetcher could also use one, so I decided to do two
in one CL.

And then it got a bit infectious and ended up touching everything.

I ended up doing SubFetch in the process by necessity.

At a certain point I finally started using context.TODO() in a few
spots, but not too many. But removing context.TODO() will come in the
future. There are more blob storage interfaces lacking context, too,
like RemoveBlobs.

Updates #733

Change-Id: Idf273180b3f8e397ac5929c6d7f520ccc5cdce08
2018-01-18 16:22:16 -08:00
Brad Fitzpatrick 38f10a7bd0 all, testhooks: use sha224 by default, add hook for some tests to use sha-1
Remove the blob.SHA{1,224}From{Bytes,String} constructors too. No
longer used. This adds blob.RefFromBytes which was missing. We had
blob.RefFromString. Now everything uses blob.RefFrom* instead of
specifying a hash function.

Some tests set a flag to force use of SHA-1 because there was too much
golden data to update. We can remove those one-by-one over time as we
fix up tests.

Updates #537

Change-Id: Ibe6428089a6221594c2b751f53f98b03b5a28dc2
2018-01-09 20:03:38 -08:00
Brad Fitzpatrick 0e8980b54b blobserver: change BlobStatter interface, simplify proxycache
This addresses a long-standing TODO in the BlobStatter interface to
clean it up. Just like all new Go programmers, I misused channels in
APIs. I should've cleaned this up years ago.

While here, I also added a context.

The rest should get contexts later.

This also cleans up a few things here & there.

The pkg/client statting no longer does batching, which added a lot of
complexity. There was a comment saying something like "once we have
SPDY, we can delete this". Well, we have HTTP/2 now, so seems
deletable.

All tests pass.

Change-Id: I034ce07d9b70e5cc9e5482213368993e638d4bc8
2018-01-08 16:54:52 -08:00
Brad Fitzpatrick 57648c6b83 all: update copyright holder from Google Inc to The Perkeep Authors
The AUTHORS file is the list of copyright holders.
2018-01-03 16:52:49 -08:00
mpl b5b668b661 pkg/client: force nil transport when on the browser
Calls to net.Dial* are prohibited with GopherJS. This can happen if the
client's transport is set by the user.

This change forces transportForConfig to return nil when the client
package is compiled with gopherjs, in order to make sure that a call to
newClient returns a client with a nil transport.

Change-Id: I577457bd7d924d31710168086dc2b394df3d1ae0
2018-01-03 16:38:47 +01:00
Brad Fitzpatrick c3d05cdce9 Move more packages out of pkg/ and into internal/
Moved hashutil, httputil, osutil, netutil,
images, media, magic, video, and rollsum.
2018-01-02 21:03:30 -08:00
Brad Fitzpatrick d6a0b05df0 Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.

After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.

This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.

Also, this only moves the lru package to internal. More will move to
internal later.

Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.

This updates some docs, but not all.

devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).

Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 16:03:34 -08:00
Brad Fitzpatrick f4b62de003 Merge "pkg/client: set ServerName before DialTLS handshake for android" 2017-12-29 15:52:40 +00:00
mpl 8b2e541731 pkg/client: set ServerName before DialTLS handshake for android
Otherwise, the android app fails to connect with a server that uses
Let's Encrypt (because it relies on SNI, which requires the ServerName
to be set).

Change-Id: I9f25486bea68e83c68584a83817c98bfc84f62b9
2017-12-22 19:02:47 +01:00
Brad Fitzpatrick 8e02a79b5b osutil: add func to report whether the secret-keyring flag is loaded
Then use it in pkg/client and remove the workaround from cmd/pk-devimport.

Change-Id: Iebd380d8c021628ac5e52219d00cfdf8e03f6b7d
2017-12-20 12:53:22 -08:00
Paul Lindner 1383869054 all: lint fixes for "receiver name should be consistent with previous receiver name"
Change-Id: I05275cd20c92349e37365e2cbd29fa9f8d834101
2017-12-13 11:31:25 -08:00
Paul Lindner ba92702834 all: lint fixes for "should omit 2nd value from range"
Change-Id: I7bb19d376f96a39ecae7dbdb4d6808f704bae5fb
2017-12-13 11:31:25 -08:00
Paul Lindner 15feaeb24c all: lint fixes for 'error strings should not be capitalized or end with punctuation or a newline'
Change-Id: I9c3766a51ac8be694ae76befff4b6fa9a85e34eb
2017-12-11 06:13:25 -08:00
Paul Lindner b09cd377d7 Switch to stdlib context from golang.org/x/net/context
This switches most usages of the pre-1.7 context library to use the
standard library.  Remaining usages are in:

  app/publisher/main.go
  pkg/fs/...

Change-Id: Ia74acc39499dcb39892342a2c9a2776537cf49f1
2017-11-26 01:12:26 -08:00
Mathieu Lonjaret 3911a41bd5 Merge "cmd/*: always output on fatal errors" 2017-10-22 15:07:06 +00:00
mpl a6a3cac0df cmd/*: always output on fatal errors
This CL addresses issues #685 and #862.

The general problem is that some critical errors, that lead clients such
as camput to exit with failure, are not displayed when not running in
verbose mode.

The reason that happens is because of code such as:

	if *cmdmain.FlagVerbose {
		log.SetOutput(cmdmain.Stderr)
	} else {
		log.SetOutput(ioutil.Discard)
	}

which means that in non-verbose mode we discard absolutely all log
messages, even those that would be printed during a Fatal* call.

To address that problem, we introduce a logger, as well as the Printf
and Logf functions using it, in pkg/cmdmain. These two functions only
output when *cmdmain.FlagVerbose is true.

Commands such as camput or camtool should now always:
1) log.SetOutput(cmdmain.Stderr) in init().
2) use log.Printf for messages that should always be printed.
3) use cmdmain.Printf/Logf for messages that should only be printed when
*cmdmain.FlagVerbose is true.
4) use log.Fatal for critical errors.
5) optionally, set the Verbose and Logger of the client(s) they are
using.

Also, camput and camtool are now relying on the global -verbose flag
from cmdmain, instead of having to define one for each subcommand.

fixes #685
fixes #862

Change-Id: I088032fd28184a201076097bf878894b22a8a120
2017-10-19 02:22:44 +02:00
Paul Lindner fa46c3935d Correct various misspelled words
Change-Id: I236e880526e4c2b0bd318da041983d557e0aa885
2017-09-11 08:33:31 -07:00
mpl 7832801040 server/camlistored/ui: on zooming/panning on map aspect, do new search
This change makes zooming and panning on the map aspect send a new
"MapSort" search query, so that the (1000, by default) most relevant
results for the currently displayed area always appear as markers
after a zoom/pan.

This required completely "lifting up" (in React lingo) the currentSearch
state out of the Header class, and into the Index class, which should
have already been done in a56372830a. This
is necessary because we need the expression in the search box to be mutable
both by the user('s input) and by the map aspect, which represents the
zoom level as a trailing "locrect" predicate in the search expression.

Fixes #938

Change-Id: I0004c9ff09f03b4f1d95a35e54605689eebf0c1a
2017-08-16 21:39:46 +02:00
mpl b41e1403e7 vendor: update go4.org/readerutil
To rev 169ea6cabe2a4888dba958edaecc9e9751adc711

Also get rid of pkg/readerutil now that it's all moved to
go4.org/readerutil

go4.org/readerutil/singlereader not vendored in as we don't actually use
it.

Fixes #678

Change-Id: I46f14acde1d3023e94c8e99e8267ce951f1bbb61
2017-04-12 19:25:04 +02:00
mpl 77dfe8046d server/camlistored/ui: add "Share" feature
To share a file or directory through Camlistore's sharing
mechanism (https://camlistore.org/doc/sharing).

Only single-item sharing supported for now.

On success, the share URL is displayed in a dialog.
If the item is a file, it can be fetched with any HTTP client through
that URL. If the item is a dir, the share URL is of the claim, so one
must follow the transitive chain of sharing to get the directory's
children, i.e. use camget -shared.

Fixes #880

Change-Id: I324a684dec10225e5b8314dda7f1b77a0de6f727
2017-03-23 00:44:18 +01:00
mpl 5a24ffd854 new app: scanning cabinet
WARNING: this app is still experimental, and even its data schema might
change. Do not use in production.

This change adds a Camlistore-based port of the scanning cabinet app
originally created by Brad Fitzpatrick:
https://github.com/bradfitz/scanningcabinet

Some of it is inspired from the App Engine Go port of Patrick Borgeest:
https://bitbucket.org/pborgeest/nometicland

The data schema is roughly as follows:

-a scan is a permanode, with the node type: "scanningcabinet:scan".
-a scan's camliContent attribute is set to the actual image file.
-a scan also holds the "dateCreated" attribute, as well as the
"document" attribute, which references the document this scan is a part
of (if any).

-a document is a permanode, with the node type: "scanningcabinet:doc".
-a document page, is modeled by the "camliPath:sha1-xxx" = "pageNumber"
relation, where sha1-xxx is the blobRef of a scan.
-a document can also hold the following attributes: "dateCreated",
"tag", "locationText", "title", "startDate", and "paymentDueDate".

Known caveats, in decreasing order of concern:
-the data schema might still change.
-the scancab tool, to actually create and upload the files from physical
documents, is practically untested (since I do not own a scanner).
-some parts, in particular related to searches, are probably
sub-optimized.
-the usual unavoidable bugs.

Change-Id: If6afc509e13f7c21164a3abd276fec075a3813bb
2017-02-15 17:14:45 +01:00
mpl bfce01e7b2 cmd/camput: print share URL
After successfully issueing a shared blob.

Fixes #330

Change-Id: I51d4fa8434e8df471a29922bfdb5e9a7f22aec1a
2016-11-15 17:33:26 +01:00
mpl 6f5a718ad1 cmd/camget: update client share chain when getting blobs from cache
When fetching shared blobs, we rely on the share chain to verify if a
blob can be reached. This chain is updated whenever we fetch an
additional link of the chain, by updating the Client.via map. However,
when some blobs of the chain are already cached in camget's DiskCache,
because we get them from the cache, we don't fetch them with
Client.FetchVia, which means the Client.via map isn't updated. And thus
the chain is broken.

This change adds Client.UpdateShareChain, and sets it as a hook to be
called by the CachingFetcher in the event of a cache hit. That way, we
ensure that the share chain is updated even when we get blobs from the
cache (instead of from the Client).

We also add a mutex to guard Client.via, because it is accessed by
concurrent smartFetch calls in case of a static-set.

As FetchVia was undocumented and not used by anyone, I made it
unexported. We can always export it again later when needed.

Fixes #856

Change-Id: I767cbec4b6f382cbccc25c0b97782b2a7472deb8
2016-09-26 19:03:04 +02:00
mpl 48213c84a6 pkg/client: fail properly when no SearchRoot
When the discovery SearchRoot is empty (because e.g. the server has no
indexer), the root.Parse(disco.SearchRoot) call during doDiscovery will
not fail. This is fine, and is actually what we want, because we don't
want discovery to fail just because there's no SearchRoot.

However, we do want func (c *Client) SearchRoot() to return
ErrNoSearchRoot in that case, which is why c.searchRoot should be set to
"" empty as well.

Change-Id: I88cbfa4a1476ba1533ccd61511a72c35de6d7516
2016-06-01 01:15:14 +02:00