Commit Graph

50 Commits

Author SHA1 Message Date
mpl 1e69b9f784 vendor: update cloud.google.com/go/logging to V2 API
In addition to API changes, the V2 logging API uses
google.golang.org/grpc, which does not rely directly on net/http. This
is a problem for us because, among other things, when needed (on
CoreOS), we insert the system Root CAs in the TLSConfig of the
default http client through httputil.InstallCerts, which has no effect
on google.golang.org/grpc calls. Therefore, we switch to
github.com/bradfitz/grpc-go instead, which does rely on net/http.

And since GRPC requires HTTP/2, we also now need to manually configure
the default transport (since we're already modifying it) to be HTTP/2
enabled.

Related dependencies updated/added:

updated:

cloud.google.com/go/logging
a64eb5d53f434cc548fd6b2898b5a3e8a0c31b78

github.com/golang/protobuf
8ee79997227bf9b34611aee7946ae64735e6fd93

added:

github.com/bradfitz/grpc-go
188a132adcfba339f1f2d5da52498451341f9ee8
as a replacement for google.golang.org/grpc

github.com/googleapis/gax-go
da06d194a00e19ce00d9011a13931c3f6f6887c7

google.golang.org/genproto/googleapis/logging
08f135d1a31b6ba454287638a3ce23a55adace6f

google.golang.org/genproto/googleapis/datastore
08f135d1a31b6ba454287638a3ce23a55adace6f

google.golang.org/api/support/bundler
e4c04685e5d7db47ff294aa9e514b3a638c431c9

google.golang.org/genproto/googleapis/rpc/status
08f135d1a31b6ba454287638a3ce23a55adace6f

Fixes #873

Change-Id: I3ba14c94122dd9f1b88ef61c2dc26430690d28a9
2017-02-06 19:59:24 +01:00
mpl 5445e983ae pkg/httputil: fix checkSystemRoots for Go1.6
Something changed in x509 in Go1.6 so that when verifying an empty Cert,
one now gets the errNotParsed (x509: missing ASN.1 contents; use
ParseCertificate) error, instead of the SystemRootsError.

Since we rely on getting the SystemRootsError to find out that we're on
CoreOS, we now need to verify a non empty cert, when performing this
check.

Fixes issue #705

Change-Id: I40a4f9aa4ef49bbdd3b7b15b127f890e26f31de4
2016-04-05 00:18:16 +02:00
Will Norris 77ed42edf8 add canonical import paths
The import path was added to the go file that included the package
documentation if one existed.  Otherwise, I used what seemed to be the
primary file for the package.

Fixes #689

Change-Id: If51be0e86529fd6f179e80af6781e639f8550fd2
2016-03-13 19:57:14 -07:00
mpl 8d5d761ff5 vendor/future/mime/multipart: remove
revert changes afe28ebf90 and
666d525530 because Go 1.6 is out.

Issues #642 and #644

Change-Id: Ide422b5164576c77d72061bb05ea0984c68d55e4
2016-02-24 18:11:20 +01:00
mpl e0d719ba21 pkg/types: remove
Most of it replaced with vendor/go4.org/types and
vendor/go4.org/readerutil

u32 went where needed in pkg/blobserver/*
invertedBool went in pkg/types/serverconfig
atomics64 went in pkg/fs

Change-Id: I230426cda35be4b45ed67e869f14e6fdae89be22
2016-02-05 18:28:47 +01:00
Brad Fitzpatrick 4086789731 pkg/httputil: also track protocol versions of HTTP response in StatsTransport 2015-12-29 13:36:50 -08:00
mpl cea5e332ce vendor: go4.org/legal
At rev c3c16077b235db4c6b2a2a6121c2d429707f4ed4

And use it in new package pkg/camlegal

And remove pkg/legal

Change-Id: I5e398aa5f145a02a04d33719276fd2f8b82ab12b
2015-12-16 18:50:49 +01:00
mpl 40c0d80b07 vendor: go4.org/wkfs
Previously pkg/wkfs

Copied from go4.org at rev 3970dd22c0e7e2397304ad626a20b72f8db41b58

Note that pkg/wkfs/gcs has not been moved yet (for dependencies
reasons).

Change-Id: I737e88a360bccfc643e1fa43541f65f2384c3157
2015-11-27 00:23:03 +01:00
Brad Fitzpatrick 9868aa0f8d Remove httputil.CloseBody relic. 2015-11-23 19:02:10 -08:00
mpl e52149992a pkg/httputil: allow local connections from root
Context:
https://groups.google.com/d/msg/camlistore/RtpjveY4FVM/P5xldD88CQAJ

Change-Id: Ibc4a1052d94129a40a390390f91d90e6d3236ccd
2015-10-15 23:12:18 +02:00
mpl 666d525530 blobserver, server: use httputil.MultipartReader for vendored multipart Reader
We redefine a MultipartReader(*http.Request) function to use instead of
req.MultipartReader, so we can get a (bugfixed) multipart Reader from
our vendored mime/multipart, instead of the buggy one from the stdlib's.

Fixes issue #642

Change-Id: I6a205bff915632d4ee77547e6e26bc0af99665e9
2015-10-14 19:22:10 +02:00
Brad Fitzpatrick af36d78bd7 env: add IsDev and use it everywhere
Change-Id: I5547ce989c05f1f48774f24abee41c489326baa0
2015-04-02 05:55:01 -07:00
mpl e02ac6b36c deploy/gce: on success, show SHA-1 of certificate too
Also small TODO, template cleanup, and further cosmetics.

Change-Id: I9171e8e1389abaae216068c9fded518786e1a3a0
2015-02-04 19:54:27 +01:00
Brad Fitzpatrick ab9cd80301 httputil: use a random serial number in self-signed certs, not 0
Change-Id: Ifdba7c3efb9bd08e09da883eecdf3ba36dfa3f12
2015-01-16 16:46:15 -08:00
mpl 99fe925efc pkg/deploy/gce: lib + tool to deploy on Google Cloud
http://camlistore.org/issue/531

Change-Id: I69ffe0544341d380bb844aef1dcca8a1ae441ea7
2014-11-26 22:50:27 +01:00
Salmān Aljammāz 4e39af1086 Generate self-signed certs with the correct hostname.
This change makes gce/create.go generate a self-signed certificate
with the hostname from the -hostname argument and upload it to GCS
before creating a new camlistore instance.

It also makes camlistored use baseURL to figure out the hostname
when generating its self-signed certificate.

Change-Id: I64f85853dab34a7ce95e5d5997e58f2e5da43496
2014-11-13 15:53:40 +00:00
Brad Fitzpatrick 919390aac8 httputil: rename conn to rw, per current conventions
Change-Id: Ifc39915396f5ababdc2fb21c2a95156bbbf729c8
2014-10-21 15:13:12 +02:00
Brad Fitzpatrick 8897cdc3f8 httputil: don't set Content-Type until we're sure
Fixes Issue 182

Change-Id: I1a687c51b60caca5ddc7b4cd21d4f7efa6342248
2014-10-21 15:11:51 +02:00
Gina White f9a2388cec Pinboard importer: add test, fix bug
Add test that imports three posts.  Fix bug the test uncovered.  We need
to make a copy of the post in the importBatch loop before handing it off
to asynchronous importPost call.

Change-Id: Id8dea72b03dd3666dde97e977c921a8955e67392
2014-10-18 08:20:45 -07:00
Brad Fitzpatrick c71b122e12 httputil: simplify the SystemCARootsAvailable function
Change-Id: I88d36cdc2384634a6baa49b0d663d87a5d7fcb52
2014-08-15 17:43:22 -07:00
Brad Fitzpatrick 2ee36e4f1a Embed Mozilla's Root CA set for use in Docker environments without CA files.
Thanks to Adam Langley and Kelsey Hightower for pointers:

https://github.com/kelseyhightower/contributors/blob/master/certs.go
https://medium.com/@kelseyhightower/optimizing-docker-images-for-static-binaries-b5696e26eb07
https://github.com/agl/extract-nss-root-certs

Change-Id: I440cedf476446da852c409958a877fbcdb464340
2014-08-15 17:15:09 -07:00
mpl 1fd526b999 test/transport.go: move to httputil, so we can use it without linking testing
Change-Id: I889d167a78ef0fba5ef2e9e3e884f594e151e940
2014-07-14 18:33:10 +02:00
mpl a8f8fd57cf httputil: allow full error serving when with devcam
When hacking on e.g. importers, I sometimes want to use devcam with
-hostname, to test with a non local context. In which case, when hitting
an error httputil.ServeError would not print the full error, which
makes it harder to debug.

Change-Id: I2fb8c97748d4f077404fbf12010addd6e7af3572
2014-04-23 15:19:55 +02:00
Brad Fitzpatrick c179081ab7 httputil: add IsWebsocketUpgrade, fix BadRequestError inconsistency
Change-Id: I85e34fe4e87c2402fe6ab002bcd374ef0fd41141
2014-02-03 20:24:45 -05:00
Brad Fitzpatrick 2fde1c3632 httputil: make CloseBody more robust
Change-Id: If46c60a5088f57ada45b8aa91ae29c8f512604c7
2014-01-29 11:31:52 +01:00
Brad Fitzpatrick 7c3afd2711 httputil: add test for CloseBody
Change-Id: I6049de69279aef7bb0c013935ae4d37b8eaff853
2014-01-28 23:14:02 -08:00
Brad Fitzpatrick eb27581da7 httputil: add DecodeJSON and CloseBody helpers, then use them everywhere
httputil.CloseBody closes a http.Response.Body nicely, such that it's
more likely to be re-used.

httputil.DecodeJSON parses JSON from a Response.Body and closes the
body. It also keeps a temporary copy of the input, for error messages.

Then use them everywhere, to improve HTTP TCP connection re-use.

And misc other clean-ups.

Change-Id: I5dc44be0165b13659459ed29ce5ab44c17d9739f
2014-01-28 22:00:52 -08:00
Brad Fitzpatrick 60685a1194 auth: warn when local connection uid doesn't match
Change-Id: Icdcef55c4831b4f77f7df34e58c87a6985401a04
2013-12-16 17:19:31 -08:00
Mathieu Lonjaret f8348c5875 Merge "buildbot/master: add Basic Auth support." 2013-11-22 15:29:06 +00:00
Bill Thiede 738783ebf4 buildbot/master: add Basic Auth support.
Moved BasicAuth parsing and localhost detection code from pkg/auth ->
pkg/httputil for use by buildbot master.

Added user config file for remote access.  The file's name is
"masterbot-config.json" and is located in osutil.CamliConfigDir(),
which on Unix will resolve to $XDG_CONFIG_HOME/camlistore/, if
XDG_CONFIG_HOME set, or ~/.config/camlistore/.  On Windows it will be
under %APPDATA%\Camlistore\.  The expected format is a json object
with usernames as the keys and sha1 sums of the password as the
values, i.e.:

    {
        "user1": "1234567890abcdef12341234567890abcdef1234",
        "user2": "1234abcdef12345678901234abcdef1234567890"
    }

This file is polled at a 1 minute interval and reparsed if the file's
modification time is more recent then the previous parse attempt.  It
is ok for the file to go missing, it will zero out the remote user
list. A malformed file will result in the master exiting.

New commandline flags, -tlsCertFile & -tlsKeyFile, added.  Specifying
both will enable TLS on the listener specified by -host.  The go
source contains generate_cert.go in crypto/tls that can be used to
generate self-signed cert.pem and key.pem for testing.

Added -skiptlscheck commandline option to builder.  This allows the
builder to report to https:// addresses with self-signed certs as we
don't currently have a way to specify the cert chains to be used
for TLS verification.  This is a stop-gap solution.

When launching a master that listens for secure connections, we
currently need tell the builders to skip certificate validation. Add
'-builderopts="-skiptlscheck"' to the master's commandline to skip
cerfication verification.

Change-Id: I0750b5c9fa8f4def67fc05a841087b50abded2f7
2013-11-21 21:22:12 -08:00
Robert Obryk 68d6af1e82 httputil: set the headers before writing them
Change-Id: Ibb7db1ca06744b64ec29664059364fe7a1e8e837
2013-11-08 02:06:27 +01:00
Brad Fitzpatrick 128f56887b Handle GET and HEAD the same in more (all?) places.
Change-Id: I486a95f0a6fc127d17dcf0abeb94eab292980156
2013-09-15 20:12:26 +01:00
Brad Fitzpatrick 0bdf20884b all: delete pkg/blobref; convert all from *blobref.BlobRef to new blob.Ref
Change-Id: Id2dfb7f19452bedf4f3c9310b36227fd8117b225
2013-08-03 19:54:30 -07:00
Brad Fitzpatrick 4a404a3c60 search: clean up describe handler and DescribeRequest
Change-Id: I4e6184765b6139de3bdc153d27a12d3cb205a55e
2013-07-11 10:35:06 +10:00
Brad Fitzpatrick cf0d9aca6e More docs
Change-Id: I5c21f240c85bcf91fb67487cc172bf3faeb49fff
2013-07-07 18:52:14 -07:00
Brad Fitzpatrick d832b6a06f Document PrefixHandler and clean up users with accessor functions.
Change-Id: Ib0b23ff3cc548a35c35eae1cdc59a8673dc19638
2013-06-12 11:17:30 +02:00
Brad Fitzpatrick 4c7e985c14 uploadhelper: use a type for JSON response, not maps.
Change-Id: I642af4daf97829a813bf7dad61cc7683ec780e69
2013-02-11 20:33:53 -08:00
Brad Fitzpatrick 7300184066 httputil, search: more HTTP util usage, deleting code.
Change-Id: I90e51a3e8b3fdd868b26a40446f9715aaa7f89c0
2013-02-08 22:21:09 -08:00
Brad Fitzpatrick e624e24c46 httputil/handler: start of more formal approach to input validation and HTTP error handling
Change-Id: I219a6263e1ba2d0e64819c01a885078dbf1c8b4c
2013-02-08 19:04:24 -08:00
Brad Fitzpatrick c408e19ec4 httputil: more Transport timing stats
Change-Id: I536d8f549e6cdbc0778c44943e770e4f0665c868
2013-01-06 09:03:47 -08:00
Brad Fitzpatrick 056d1efb26 httputil: more Transport debugging
Change-Id: If3ea30237abf8614d41bb340c24a65f7725234c2
2013-01-05 17:17:56 -08:00
Brad Fitzpatrick 9f6776dddb camget, httputil: more verbose HTTP debugging
Change-Id: I2fc1a1fe0fff99202245d391a8a76e9fab07adc2
2013-01-05 16:44:34 -08:00
mpl 39218e3cd5 Merge "Changed auth to take into account not only the credentials, but the requested operation/action too." 2013-01-04 21:09:37 +00:00
mpl 12213c058e Changed auth to take into account not only the credentials,
but the requested operation/action too.

This allows to restrict vivify credentials to only upload
(as well as get and stat, because they're needed) to the
blobserver.

Change-Id: Idaed60d1f0d679cb9795ba9a11f094f964774335
2013-01-04 22:17:12 +01:00
Brad Fitzpatrick fe13c7c712 move camput's statsTransport to httputil.StatsTransport, use it in camget too.
Change-Id: Iab48e32ccb8a99b8ec6b058061cff9a5b99e8712
2013-01-02 20:32:13 -08:00
Maxime Lavigne 3ec58472db Modifications allowing /setup to be view on Windows
When you go to /setup on Windows, it currently checks
the "localhostAuthorized" function that checks your
UserID with os.Getuid() and than check with the local
and remote address to see if you are allow. In Windows
os.Getuid will always equals -1 and the function default
to unallowed. On darwin, it does check for uid but
afterward only cares if the local and remote addresses
are loopback addresses.

So, I changed this function so that when the os.Getuid
is not avalaible on the platform and returns -1, it does
the same check as in darwin.

I also modified the "isLocalhost" function to use the
helper function "net.IsLoopback" instead of string matching.

Since, I already had parsed addresses and had to call
AddPairUserId, I checked if it wouldn't be simpler to
pass net.Addr directly instead of strings and reconvert
them afterward. It seemed after looking at all the code
that called this function that it simplified calls quite
a bit to do so.

Finally, I modified "netutil.Localhost" for it to return
the first IP it finds instead of the string representation
of the first IP enclosed in square brackets. Since the square
brackets around the IP are only necessary in a TCPAddr, it
would be simplier and more robust for the user to directly
print TCPAddr instead of appending this string to a post.

Change-Id: Id79de6bebd6380f877074211c0d260782058765f
2012-11-18 20:20:25 -05:00
Brad Fitzpatrick 546e2fc14d Send Content-Length on JSON responses
Change-Id: I7e8034b0aea8031011607527f237e24d63b88502
2012-11-04 13:50:35 +01:00
mpl 844551d0b2 If baseURL was not user defined, this change makes sure it is
dynamically defined from incoming requests.
The listen flag has moved from pkg/webserver to server/camlistored
and is not using runsit anymore.
httputil.ServerError now only outputs the full error if we're
in internal/debug mode.
http://code.google.com/p/camlistore/issues/detail?id=53

Change-Id: I55a1c6d43a549d9ee2022742a83aa142dc19e02a
2012-10-15 16:26:50 +02:00
Brad Fitzpatrick 8c293e34b6 Per Go initialism style, rename Json to JSON 2012-07-28 15:42:56 -07:00
Brad Fitzpatrick 0714a463c9 Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.

The directory tree has been rearranged now too.  Go libraries are now
under "pkg".  Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".

The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.

For now, put the camlistore root under $GOPATH/src.  Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.

Then you can:

$ go build ./server/camlistored

... etc

The build.pl script is currently disabled.  It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).

Many things are certainly broken.

Many things are disabled.  (MySQL, all indexing, etc).

Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.

The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.

Help wanted.

Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-18 21:53:06 -08:00