Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
e27626d087
|
|||
|
6c01df76f5
|
|||
|
db4ac49a49
|
|||
|
1a88e47181
|
|||
|
c1fc005c78
|
|||
| c325d7695a | |||
|
|
0dba6a7209 | ||
| 4cc614a703 |
1
Makefile
1
Makefile
@@ -24,7 +24,6 @@ clean:
|
|||||||
|
|
||||||
setup:
|
setup:
|
||||||
go mod download
|
go mod download
|
||||||
go mod vendor
|
|
||||||
fmt:
|
fmt:
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
test: $(ROUTE_ASSET) $(DOCS_ASSET)
|
test: $(ROUTE_ASSET) $(DOCS_ASSET)
|
||||||
|
|||||||
16266
assets/package-lock.json
generated
16266
assets/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -43,6 +43,11 @@ Config:
|
|||||||
var defaultConfig = `
|
var defaultConfig = `
|
||||||
[http]
|
[http]
|
||||||
listen = ":9010"
|
listen = ":9010"
|
||||||
|
base_url = "https//paste.dn42.us"
|
||||||
|
cors = [
|
||||||
|
"http://localhost",
|
||||||
|
"https://sour.is",
|
||||||
|
]
|
||||||
|
|
||||||
[module.paste]
|
[module.paste]
|
||||||
random = "4096"
|
random = "4096"
|
||||||
@@ -55,7 +60,9 @@ store = "data/artifact"
|
|||||||
store = "data/image"
|
store = "data/image"
|
||||||
|
|
||||||
[module.short]
|
[module.short]
|
||||||
store = "data/meta.db"
|
index = "data/meta"
|
||||||
|
value = "data/meta"
|
||||||
|
|
||||||
`
|
`
|
||||||
|
|
||||||
var args map[string]interface{}
|
var args map[string]interface{}
|
||||||
|
|||||||
14
go.mod
14
go.mod
@@ -5,20 +5,28 @@ go 1.14
|
|||||||
require (
|
require (
|
||||||
github.com/99designs/gqlgen v0.12.2
|
github.com/99designs/gqlgen v0.12.2
|
||||||
github.com/andybalholm/brotli v1.0.0
|
github.com/andybalholm/brotli v1.0.0
|
||||||
github.com/coreos/bbolt v1.3.2
|
github.com/dgraph-io/badger v1.6.2 // indirect
|
||||||
|
github.com/dgraph-io/ristretto v0.0.3 // indirect
|
||||||
|
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
|
||||||
github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815
|
github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815
|
||||||
github.com/go-swagger/go-swagger v0.25.0
|
github.com/go-swagger/go-swagger v0.25.0
|
||||||
github.com/golang/gddo v0.0.0-20200831202555-721e228c7686 // indirect
|
github.com/golang/gddo v0.0.0-20200831202555-721e228c7686 // indirect
|
||||||
|
github.com/golang/protobuf v1.4.3 // indirect
|
||||||
github.com/gomarkdown/markdown v0.0.0-20200824053859-8c8b3816f167
|
github.com/gomarkdown/markdown v0.0.0-20200824053859-8c8b3816f167
|
||||||
github.com/gorilla/mux v1.8.0
|
github.com/gorilla/mux v1.8.0
|
||||||
github.com/h2non/filetype v1.1.0
|
github.com/h2non/filetype v1.1.0
|
||||||
|
github.com/hashicorp/golang-lru v0.5.1
|
||||||
|
github.com/lucasb-eyer/go-colorful v1.0.3
|
||||||
github.com/remyoudompheng/go-liblzma v0.0.0-20190506200333-81bf2d431b96
|
github.com/remyoudompheng/go-liblzma v0.0.0-20190506200333-81bf2d431b96
|
||||||
github.com/sour-is/crypto v0.0.0-20201016232853-f42a24ba5a81
|
github.com/sour-is/crypto v0.0.0-20201016232853-f42a24ba5a81
|
||||||
github.com/sour-is/go-assetfs v1.0.0
|
github.com/sour-is/go-assetfs v1.0.0
|
||||||
github.com/spf13/viper v1.7.1
|
github.com/spf13/viper v1.7.1
|
||||||
|
github.com/timshannon/badgerhold v1.0.0
|
||||||
github.com/tv42/zbase32 v0.0.0-20190604154422-aacc64a8f915
|
github.com/tv42/zbase32 v0.0.0-20190604154422-aacc64a8f915
|
||||||
github.com/vektah/dataloaden v0.3.0
|
github.com/vektah/dataloaden v0.3.0
|
||||||
go.etcd.io/bbolt v1.3.5 // indirect
|
go.uber.org/ratelimit v0.1.0
|
||||||
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a
|
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
|
||||||
|
golang.org/x/net v0.0.0-20201029055024-942e2f445f3c // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20201029080932-201ba4db2418
|
||||||
sour.is/x/toolbox v0.12.17
|
sour.is/x/toolbox v0.12.17
|
||||||
)
|
)
|
||||||
|
|||||||
55
go.sum
55
go.sum
@@ -15,11 +15,15 @@ dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7
|
|||||||
github.com/99designs/gqlgen v0.10.1/go.mod h1:IviubpnyI4gbBcj8IcxSSc/Q/+af5riwCmJmwF0uaPE=
|
github.com/99designs/gqlgen v0.10.1/go.mod h1:IviubpnyI4gbBcj8IcxSSc/Q/+af5riwCmJmwF0uaPE=
|
||||||
github.com/99designs/gqlgen v0.12.2 h1:aOdpsiCycFtCnAv8CAI1exnKrIDHMqtMzQoXeTziY4o=
|
github.com/99designs/gqlgen v0.12.2 h1:aOdpsiCycFtCnAv8CAI1exnKrIDHMqtMzQoXeTziY4o=
|
||||||
github.com/99designs/gqlgen v0.12.2/go.mod h1:7zdGo6ry9u1YBp/qlb2uxSU5Mt2jQKLcBETQiKk+Bxo=
|
github.com/99designs/gqlgen v0.12.2/go.mod h1:7zdGo6ry9u1YBp/qlb2uxSU5Mt2jQKLcBETQiKk+Bxo=
|
||||||
|
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
|
||||||
|
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M=
|
||||||
|
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
|
||||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||||
github.com/Masterminds/squirrel v0.0.0-20190511014652-b4b75d10d7bf/go.mod h1:yaPeOnPG5ZRwL9oKdTsO/prlkPbXWZlRVMQ/gGlzIuA=
|
github.com/Masterminds/squirrel v0.0.0-20190511014652-b4b75d10d7bf/go.mod h1:yaPeOnPG5ZRwL9oKdTsO/prlkPbXWZlRVMQ/gGlzIuA=
|
||||||
|
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
|
||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||||
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
|
||||||
@@ -34,6 +38,7 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy
|
|||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
|
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
|
||||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
||||||
|
github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4=
|
||||||
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||||
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
|
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
|
||||||
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
|
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
|
||||||
@@ -55,6 +60,7 @@ github.com/bouk/monkey v1.0.0 h1:k6z8fLlPhETfn5l9rlWVE7Q6B23DoaqosTdArvNQRdc=
|
|||||||
github.com/bouk/monkey v1.0.0/go.mod h1:PG/63f4XEUlVyW1ttIeOJmJhhe1+t9EC/je3eTjvFhE=
|
github.com/bouk/monkey v1.0.0/go.mod h1:PG/63f4XEUlVyW1ttIeOJmJhhe1+t9EC/je3eTjvFhE=
|
||||||
github.com/bradfitz/gomemcache v0.0.0-20170208213004-1952afaa557d/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
|
github.com/bradfitz/gomemcache v0.0.0-20170208213004-1952afaa557d/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
|
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||||
github.com/cgilling/dbstats v0.0.0-20150427045024-c9db8cf218e6/go.mod h1:fsf3+k/VvGOE9sF2B9d6PBcZOzQIlDJhn2LhBqF/4VY=
|
github.com/cgilling/dbstats v0.0.0-20150427045024-c9db8cf218e6/go.mod h1:fsf3+k/VvGOE9sF2B9d6PBcZOzQIlDJhn2LhBqF/4VY=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
@@ -62,18 +68,33 @@ github.com/coreos/bbolt v1.3.2 h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s=
|
|||||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
|
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||||
github.com/coreos/go-oidc v2.2.1+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc=
|
github.com/coreos/go-oidc v2.2.1+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc=
|
||||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||||
|
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
|
||||||
|
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/dgraph-io/badger v1.6.0 h1:DshxFxZWXUcO0xX476VJC07Xsr6ZCBVRHKZ93Oh7Evo=
|
||||||
|
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
|
||||||
|
github.com/dgraph-io/badger v1.6.2 h1:mNw0qs90GVgGGWylh0umH5iag1j6n/PeJtNvL6KY/x8=
|
||||||
|
github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrVH//y2UQE=
|
||||||
|
github.com/dgraph-io/ristretto v0.0.2 h1:a5WaUrDa0qm0YrAAS1tUykT5El3kt62KNZZeMxQn3po=
|
||||||
|
github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
|
||||||
|
github.com/dgraph-io/ristretto v0.0.3 h1:jh22xisGBjrEVnRZ1DVTpBVQm0Xndu8sMl0CWDzSIBI=
|
||||||
|
github.com/dgraph-io/ristretto v0.0.3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||||
|
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
|
||||||
|
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||||
|
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y=
|
||||||
|
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||||
github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c h1:TUuUh0Xgj97tLMNtWtNvI9mIV6isjEb9lBMNv+77IGM=
|
github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c h1:TUuUh0Xgj97tLMNtWtNvI9mIV6isjEb9lBMNv+77IGM=
|
||||||
github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
|
github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
|
||||||
@@ -81,6 +102,8 @@ github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD
|
|||||||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||||
github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815 h1:HMAfwOa33y82IaQEKQDfUCiwNlxtM1iw7HLM9ru0RNc=
|
github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815 h1:HMAfwOa33y82IaQEKQDfUCiwNlxtM1iw7HLM9ru0RNc=
|
||||||
github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:l7JNRynTRuqe45tpIyItHNqZWTxywYjp87MWTOnU5cg=
|
github.com/docopt/docopt.go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:l7JNRynTRuqe45tpIyItHNqZWTxywYjp87MWTOnU5cg=
|
||||||
|
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||||
|
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||||
@@ -219,7 +242,10 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU
|
|||||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||||
|
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
|
||||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
|
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
||||||
|
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/gomarkdown/markdown v0.0.0-20200824053859-8c8b3816f167 h1:LP/6EfrZ/LyCc+SXvANDrIJ4sP9u2NAtqyv6QknetNQ=
|
github.com/gomarkdown/markdown v0.0.0-20200824053859-8c8b3816f167 h1:LP/6EfrZ/LyCc+SXvANDrIJ4sP9u2NAtqyv6QknetNQ=
|
||||||
@@ -327,6 +353,8 @@ github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtB
|
|||||||
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
|
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
|
||||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||||
|
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
||||||
|
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
github.com/magiconair/properties v1.7.4-0.20170902060319-8d7837e64d3c/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.7.4-0.20170902060319-8d7837e64d3c/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
|
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
|
||||||
@@ -353,6 +381,7 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
|
|||||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
||||||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||||
@@ -411,6 +440,8 @@ github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
|
|||||||
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||||
|
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
|
||||||
|
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||||
@@ -440,6 +471,8 @@ github.com/sour-is/crypto v0.0.0-20201016232853-f42a24ba5a81/go.mod h1:7/Of5cnNo
|
|||||||
github.com/sour-is/go-assetfs v1.0.0 h1:84Fd12qIAdZUOKjYIgsA1J27fcQF/JiSgiflz+2hqEA=
|
github.com/sour-is/go-assetfs v1.0.0 h1:84Fd12qIAdZUOKjYIgsA1J27fcQF/JiSgiflz+2hqEA=
|
||||||
github.com/sour-is/go-assetfs v1.0.0/go.mod h1:y4ShXMTRymi5OMvwbtfT3sxcRE72sx1ycYymT46JbRE=
|
github.com/sour-is/go-assetfs v1.0.0/go.mod h1:y4ShXMTRymi5OMvwbtfT3sxcRE72sx1ycYymT46JbRE=
|
||||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||||
|
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
||||||
|
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||||
github.com/spf13/afero v0.0.0-20170901052352-ee1bd8ee15a1/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
github.com/spf13/afero v0.0.0-20170901052352-ee1bd8ee15a1/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||||
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
|
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
|
||||||
@@ -452,6 +485,7 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
|
|||||||
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
|
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
|
||||||
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||||
|
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||||
github.com/spf13/jwalterweatherman v0.0.0-20170901151539-12bd96e66386/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
github.com/spf13/jwalterweatherman v0.0.0-20170901151539-12bd96e66386/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
|
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
|
||||||
@@ -462,6 +496,7 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
|
|||||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/spf13/viper v1.0.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=
|
github.com/spf13/viper v1.0.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=
|
||||||
|
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||||
github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
|
github.com/spf13/viper v1.4.0 h1:yXHLWeravcrgGyFSyCgdYpXQ9dR9c/WED3pg1RhxqEU=
|
||||||
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
|
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
|
||||||
github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM=
|
github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM=
|
||||||
@@ -483,12 +518,15 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
|
|||||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
||||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||||
|
github.com/timshannon/badgerhold v1.0.0 h1:LtqnDRVP7294FWRiZCIfQa6Tt0bGmlzbO8c364QC2Y8=
|
||||||
|
github.com/timshannon/badgerhold v1.0.0/go.mod h1:Vv2Jj0PAfzqViEpGvJzLP8PY07x1iXLgKRuLY7bqPOE=
|
||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
github.com/toqueteos/webbrowser v1.2.0 h1:tVP/gpK69Fx+qMJKsLE7TD8LuGWPnEV71wBN9rrstGQ=
|
github.com/toqueteos/webbrowser v1.2.0 h1:tVP/gpK69Fx+qMJKsLE7TD8LuGWPnEV71wBN9rrstGQ=
|
||||||
github.com/toqueteos/webbrowser v1.2.0/go.mod h1:XWoZq4cyp9WeUeak7w7LXRUQf1F1ATJMir8RTqb4ayM=
|
github.com/toqueteos/webbrowser v1.2.0/go.mod h1:XWoZq4cyp9WeUeak7w7LXRUQf1F1ATJMir8RTqb4ayM=
|
||||||
github.com/tv42/zbase32 v0.0.0-20190604154422-aacc64a8f915 h1:vX9DBbEHmrebYnVthUTzMO6Zc1vvConJdD2s0uvXrfw=
|
github.com/tv42/zbase32 v0.0.0-20190604154422-aacc64a8f915 h1:vX9DBbEHmrebYnVthUTzMO6Zc1vvConJdD2s0uvXrfw=
|
||||||
github.com/tv42/zbase32 v0.0.0-20190604154422-aacc64a8f915/go.mod h1:Y5DJgF9Eou+hSWetC39Mns8E0PU7DykCLNWiYeOINrE=
|
github.com/tv42/zbase32 v0.0.0-20190604154422-aacc64a8f915/go.mod h1:Y5DJgF9Eou+hSWetC39Mns8E0PU7DykCLNWiYeOINrE=
|
||||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||||
|
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||||
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
|
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
|
||||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||||
github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
|
github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
|
||||||
@@ -511,8 +549,6 @@ github.com/yosssi/gmq v0.0.1 h1:GhlDVaAQoi3Mvjul/qJXXGfL4JBeE0GQwbWp3eIsja8=
|
|||||||
github.com/yosssi/gmq v0.0.1/go.mod h1:mReykazh0U1JabvuWh1PEbzzJftqOQWsjr0Lwg5jL1Y=
|
github.com/yosssi/gmq v0.0.1/go.mod h1:mReykazh0U1JabvuWh1PEbzzJftqOQWsjr0Lwg5jL1Y=
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||||
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
|
|
||||||
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
|
||||||
go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
|
go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
|
||||||
go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
|
go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
|
||||||
go.mongodb.org/mongo-driver v1.3.0/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE=
|
go.mongodb.org/mongo-driver v1.3.0/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE=
|
||||||
@@ -521,12 +557,16 @@ go.mongodb.org/mongo-driver v1.3.5 h1:S0ZOruh4YGHjD7JoN7mIsTrNjnQbOjrmgrx6l6pZN7
|
|||||||
go.mongodb.org/mongo-driver v1.3.5/go.mod h1:Ual6Gkco7ZGQw8wE1t4tLnvBsf6yVSM60qW6TgOeJ5c=
|
go.mongodb.org/mongo-driver v1.3.5/go.mod h1:Ual6Gkco7ZGQw8wE1t4tLnvBsf6yVSM60qW6TgOeJ5c=
|
||||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||||
|
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
|
||||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||||
|
go.uber.org/ratelimit v0.1.0 h1:U2AruXqeTb4Eh9sYQSTrMhH8Cb7M0Ian2ibBOnBcnAw=
|
||||||
|
go.uber.org/ratelimit v0.1.0/go.mod h1:2X8KaoNd1J0lZV+PxJk/5+DGbO/tpwLR1m++a7FnB/Y=
|
||||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||||
golang.org/dl v0.0.0-20190829154251-82a15e2f2ead/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ=
|
golang.org/dl v0.0.0-20190829154251-82a15e2f2ead/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||||
@@ -585,6 +625,8 @@ golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/
|
|||||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
|
golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
|
||||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||||
|
golang.org/x/net v0.0.0-20201029055024-942e2f445f3c h1:rpcgRPA7OvNEOdprt2Wx8/Re2cBTd8NPo/lvo3AyMqk=
|
||||||
|
golang.org/x/net v0.0.0-20201029055024-942e2f445f3c/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/oauth2 v0.0.0-20170912212905-13449ad91cb2/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20170912212905-13449ad91cb2/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
@@ -604,6 +646,7 @@ golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5h
|
|||||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@@ -618,14 +661,15 @@ golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a h1:i47hUS795cOydZI4AwJQCKXOr4BvxzvikwDoDtHhP2Y=
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201029080932-201ba4db2418 h1:HlFl4V6pEMziuLXyRkm5BIYq1y1GAbb02pRlWvI54OM=
|
||||||
|
golang.org/x/sys v0.0.0-20201029080932-201ba4db2418/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||||
@@ -709,6 +753,7 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi
|
|||||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
|
||||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ func publicFavicon16x16Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "public/favicon-16x16.png", size: 445, mode: os.FileMode(0644), modTime: time.Unix(1597590050, 0)}
|
info := bindataFileInfo{name: "public/favicon-16x16.png", size: 445, mode: os.FileMode(0644), modTime: time.Unix(1603755438, 0)}
|
||||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc, 0x68, 0x7c, 0x67, 0x37, 0x47, 0x67, 0x80, 0x51, 0xf, 0x5f, 0x47, 0x4e, 0x83, 0x3b, 0xe4, 0x54, 0x78, 0xa6, 0xba, 0x9d, 0x9, 0x84, 0xd4, 0x2d, 0x9d, 0xf6, 0x13, 0x25, 0xd0, 0x83, 0x8d}}
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc, 0x68, 0x7c, 0x67, 0x37, 0x47, 0x67, 0x80, 0x51, 0xf, 0x5f, 0x47, 0x4e, 0x83, 0x3b, 0xe4, 0x54, 0x78, 0xa6, 0xba, 0x9d, 0x9, 0x84, 0xd4, 0x2d, 0x9d, 0xf6, 0x13, 0x25, 0xd0, 0x83, 0x8d}}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ func publicFavicon32x32Png() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "public/favicon-32x32.png", size: 1141, mode: os.FileMode(0644), modTime: time.Unix(1597590050, 0)}
|
info := bindataFileInfo{name: "public/favicon-32x32.png", size: 1141, mode: os.FileMode(0644), modTime: time.Unix(1603755438, 0)}
|
||||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x16, 0x5, 0x8a, 0x65, 0x62, 0x83, 0x24, 0xec, 0xdb, 0x3d, 0xb9, 0x9e, 0x94, 0x20, 0x89, 0x8b, 0x53, 0x6e, 0x25, 0xf, 0x15, 0x89, 0x4a, 0x4a, 0x7e, 0xd0, 0x5b, 0xaf, 0x16, 0xa9, 0x57, 0xba}}
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x16, 0x5, 0x8a, 0x65, 0x62, 0x83, 0x24, 0xec, 0xdb, 0x3d, 0xb9, 0x9e, 0x94, 0x20, 0x89, 0x8b, 0x53, 0x6e, 0x25, 0xf, 0x15, 0x89, 0x4a, 0x4a, 0x7e, 0xd0, 0x5b, 0xaf, 0x16, 0xa9, 0x57, 0xba}}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ func publicIndexHtml() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "public/index.html", size: 3503, mode: os.FileMode(0644), modTime: time.Unix(1597590050, 0)}
|
info := bindataFileInfo{name: "public/index.html", size: 3503, mode: os.FileMode(0644), modTime: time.Unix(1603755438, 0)}
|
||||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2a, 0x7, 0x6d, 0x5, 0x69, 0x46, 0x56, 0x1e, 0xc4, 0x45, 0x1a, 0xb5, 0x1f, 0xb9, 0xc6, 0x1, 0xfc, 0x42, 0x26, 0x9a, 0xf4, 0xac, 0xae, 0xa9, 0xe9, 0x26, 0x91, 0x76, 0x3e, 0xfb, 0xee, 0xf0}}
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2a, 0x7, 0x6d, 0x5, 0x69, 0x46, 0x56, 0x1e, 0xc4, 0x45, 0x1a, 0xb5, 0x1f, 0xb9, 0xc6, 0x1, 0xfc, 0x42, 0x26, 0x9a, 0xf4, 0xac, 0xae, 0xa9, 0xe9, 0x26, 0x91, 0x76, 0x3e, 0xfb, 0xee, 0xf0}}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ func publicOauth2RedirectHtml() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "public/oauth2-redirect.html", size: 2388, mode: os.FileMode(0644), modTime: time.Unix(1597590050, 0)}
|
info := bindataFileInfo{name: "public/oauth2-redirect.html", size: 2388, mode: os.FileMode(0644), modTime: time.Unix(1603755438, 0)}
|
||||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x9a, 0x53, 0xfa, 0x6e, 0xf1, 0xfe, 0x72, 0x19, 0xa6, 0x82, 0xc8, 0x77, 0x99, 0xb3, 0x9d, 0x52, 0x2e, 0x51, 0xa2, 0x78, 0xd2, 0xa, 0xd4, 0xa8, 0xe9, 0xa8, 0x83, 0x64, 0xbe, 0xe9, 0xc, 0xee}}
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x9a, 0x53, 0xfa, 0x6e, 0xf1, 0xfe, 0x72, 0x19, 0xa6, 0x82, 0xc8, 0x77, 0x99, 0xb3, 0x9d, 0x52, 0x2e, 0x51, 0xa2, 0x78, 0xd2, 0xa, 0xd4, 0xa8, 0xe9, 0xa8, 0x83, 0x64, 0xbe, 0xe9, 0xc, 0xee}}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ func publicSwaggerUiBundleJs() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "public/swagger-ui-bundle.js", size: 1555141, mode: os.FileMode(0644), modTime: time.Unix(1597590050, 0)}
|
info := bindataFileInfo{name: "public/swagger-ui-bundle.js", size: 1555141, mode: os.FileMode(0644), modTime: time.Unix(1603755438, 0)}
|
||||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc7, 0x3b, 0xa0, 0x63, 0x96, 0x6a, 0x32, 0x2e, 0x38, 0x7b, 0x1a, 0x83, 0x36, 0x51, 0xae, 0x7a, 0x6e, 0xa7, 0xe8, 0xa4, 0x7b, 0x8b, 0x1b, 0x75, 0xa1, 0x2a, 0xd3, 0xa1, 0x4b, 0x57, 0x13, 0x35}}
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc7, 0x3b, 0xa0, 0x63, 0x96, 0x6a, 0x32, 0x2e, 0x38, 0x7b, 0x1a, 0x83, 0x36, 0x51, 0xae, 0x7a, 0x6e, 0xa7, 0xe8, 0xa4, 0x7b, 0x8b, 0x1b, 0x75, 0xa1, 0x2a, 0xd3, 0xa1, 0x4b, 0x57, 0x13, 0x35}}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,7 @@ func publicSwaggerUiStandalonePresetJs() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "public/swagger-ui-standalone-preset.js", size: 440915, mode: os.FileMode(0644), modTime: time.Unix(1597590050, 0)}
|
info := bindataFileInfo{name: "public/swagger-ui-standalone-preset.js", size: 440915, mode: os.FileMode(0644), modTime: time.Unix(1603755438, 0)}
|
||||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa9, 0xd0, 0xb, 0x24, 0x4, 0x3b, 0xa, 0x54, 0x83, 0x5c, 0x3, 0x32, 0x6f, 0x41, 0x76, 0x93, 0xe, 0x2c, 0xb0, 0xd1, 0x89, 0xb7, 0xff, 0xc4, 0x71, 0xfc, 0x33, 0x2b, 0x90, 0xe4, 0xd3, 0x79}}
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa9, 0xd0, 0xb, 0x24, 0x4, 0x3b, 0xa, 0x54, 0x83, 0x5c, 0x3, 0x32, 0x6f, 0x41, 0x76, 0x93, 0xe, 0x2c, 0xb0, 0xd1, 0x89, 0xb7, 0xff, 0xc4, 0x71, 0xfc, 0x33, 0x2b, 0x90, 0xe4, 0xd3, 0x79}}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@@ -214,7 +214,7 @@ func publicSwaggerUiCss() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "public/swagger-ui.css", size: 153540, mode: os.FileMode(0644), modTime: time.Unix(1597590050, 0)}
|
info := bindataFileInfo{name: "public/swagger-ui.css", size: 153540, mode: os.FileMode(0644), modTime: time.Unix(1603755438, 0)}
|
||||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x0, 0x44, 0x96, 0x15, 0x88, 0xba, 0xa, 0x54, 0xb7, 0x45, 0x18, 0x63, 0x69, 0x98, 0x6a, 0x19, 0xca, 0x51, 0x11, 0xc8, 0x22, 0x3d, 0x11, 0x31, 0x1b, 0x2c, 0x55, 0xa5, 0xa, 0xb6, 0xab, 0x2a}}
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x0, 0x44, 0x96, 0x15, 0x88, 0xba, 0xa, 0x54, 0xb7, 0x45, 0x18, 0x63, 0x69, 0x98, 0x6a, 0x19, 0xca, 0x51, 0x11, 0xc8, 0x22, 0x3d, 0x11, 0x31, 0x1b, 0x2c, 0x55, 0xa5, 0xa, 0xb6, 0xab, 0x2a}}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@@ -234,7 +234,7 @@ func publicSwaggerUiJs() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "public/swagger-ui.js", size: 361688, mode: os.FileMode(0644), modTime: time.Unix(1597590050, 0)}
|
info := bindataFileInfo{name: "public/swagger-ui.js", size: 361688, mode: os.FileMode(0644), modTime: time.Unix(1603755438, 0)}
|
||||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xce, 0xf9, 0x34, 0xcb, 0xf8, 0xd7, 0xb6, 0xb0, 0xed, 0xf3, 0xb, 0xfc, 0x8d, 0xec, 0x66, 0xa2, 0xe8, 0x8f, 0xcd, 0xcd, 0x8, 0x5b, 0xda, 0xcf, 0x96, 0x7e, 0x21, 0xd2, 0xdf, 0x58, 0x66, 0x29}}
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xce, 0xf9, 0x34, 0xcb, 0xf8, 0xd7, 0xb6, 0xb0, 0xed, 0xf3, 0xb, 0xfc, 0x8d, 0xec, 0x66, 0xa2, 0xe8, 0x8f, 0xcd, 0xcd, 0x8, 0x5b, 0xda, 0xcf, 0x96, 0x7e, 0x21, 0xd2, 0xdf, 0x58, 0x66, 0x29}}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
@@ -254,7 +254,7 @@ func publicSwaggerJson() (*asset, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info := bindataFileInfo{name: "public/swagger.json", size: 4895, mode: os.FileMode(0644), modTime: time.Unix(1599262060, 0)}
|
info := bindataFileInfo{name: "public/swagger.json", size: 4895, mode: os.FileMode(0644), modTime: time.Unix(1603758903, 0)}
|
||||||
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x71, 0xcc, 0xe, 0x5f, 0xc1, 0xe9, 0xd6, 0xa9, 0x46, 0x93, 0xde, 0x3d, 0x71, 0x10, 0x7f, 0xa9, 0x1e, 0x98, 0x11, 0x70, 0xc6, 0xcf, 0x1c, 0xa, 0x57, 0x84, 0xfc, 0x3c, 0xf7, 0x28, 0x3, 0x67}}
|
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x71, 0xcc, 0xe, 0x5f, 0xc1, 0xe9, 0xd6, 0xa9, 0x46, 0x93, 0xde, 0x3d, 0x71, 0x10, 0x7f, 0xa9, 0x1e, 0x98, 0x11, 0x70, 0xc6, 0xcf, 0x1c, 0xa, 0x57, 0x84, 0xfc, 0x3c, 0xf7, 0x28, 0x3, 0x67}}
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|||||||
77
src/pkg/cache/cache.go
vendored
Normal file
77
src/pkg/cache/cache.go
vendored
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
lru "github.com/hashicorp/golang-lru"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Key interface {
|
||||||
|
Key() interface{}
|
||||||
|
}
|
||||||
|
type Value interface {
|
||||||
|
Stale() bool
|
||||||
|
Value() interface{}
|
||||||
|
}
|
||||||
|
type item struct {
|
||||||
|
key interface{}
|
||||||
|
value interface{}
|
||||||
|
expireOn time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewItem(key, value interface{}, expires time.Duration) *item {
|
||||||
|
return &item{
|
||||||
|
key: key,
|
||||||
|
value: value,
|
||||||
|
expireOn: time.Now().Add(expires),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (e *item) Stale() bool {
|
||||||
|
if e == nil || e.value == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return time.Now().After(e.expireOn)
|
||||||
|
}
|
||||||
|
func (s *item) Value() interface{} {
|
||||||
|
return s.value
|
||||||
|
}
|
||||||
|
|
||||||
|
type Cacher interface {
|
||||||
|
Add(Key, Value)
|
||||||
|
Has(Key) bool
|
||||||
|
Get(Key) (Value, bool)
|
||||||
|
Remove(Key)
|
||||||
|
}
|
||||||
|
|
||||||
|
type arcCache struct {
|
||||||
|
cache *lru.ARCCache
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewARC(size int) (Cacher, error) {
|
||||||
|
arc, err := lru.NewARC(size)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &arcCache{cache: arc}, nil
|
||||||
|
}
|
||||||
|
func (c *arcCache) Add(key Key, value Value) {
|
||||||
|
c.cache.Add(key.Key(), value)
|
||||||
|
}
|
||||||
|
func (c *arcCache) Get(key Key) (Value, bool) {
|
||||||
|
if v, ok := c.cache.Get(key.Key()); ok {
|
||||||
|
if value, ok := v.(Value); ok && !value.Stale() {
|
||||||
|
return value, true
|
||||||
|
}
|
||||||
|
c.cache.Remove(key.Key())
|
||||||
|
}
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
func (c *arcCache) Has(key Key) bool {
|
||||||
|
_, ok := c.Get(key)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
func (c *arcCache) Remove(key Key) {
|
||||||
|
c.cache.Remove(key.Key())
|
||||||
|
}
|
||||||
225
src/pkg/promise/promise.go
Normal file
225
src/pkg/promise/promise.go
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
package promise
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"go.uber.org/ratelimit"
|
||||||
|
"sour.is/x/paste/src/pkg/cache"
|
||||||
|
"sour.is/x/toolbox/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Q interface {
|
||||||
|
Key() interface{}
|
||||||
|
Context() context.Context
|
||||||
|
Resolve(interface{})
|
||||||
|
Reject(error)
|
||||||
|
|
||||||
|
Tasker
|
||||||
|
}
|
||||||
|
type Fn func(Q)
|
||||||
|
type Key interface {
|
||||||
|
Key() interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type qTask struct {
|
||||||
|
key Key
|
||||||
|
|
||||||
|
fn Fn
|
||||||
|
ctx context.Context
|
||||||
|
|
||||||
|
cancel func()
|
||||||
|
done chan struct{}
|
||||||
|
|
||||||
|
result interface{}
|
||||||
|
err error
|
||||||
|
|
||||||
|
Tasker
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *qTask) Key() interface{} { return t.key }
|
||||||
|
func (t *qTask) Context() context.Context { return t.ctx }
|
||||||
|
func (t *qTask) Resolve(r interface{}) { t.result = r; t.finish() }
|
||||||
|
func (t *qTask) Reject(err error) { t.err = err; t.finish() }
|
||||||
|
|
||||||
|
func (t *qTask) Await() <-chan struct{} { return t.done }
|
||||||
|
func (t *qTask) Cancel() { t.err = fmt.Errorf("task cancelled"); t.finish() }
|
||||||
|
|
||||||
|
func (t *qTask) Result() interface{} { return t.result }
|
||||||
|
func (t *qTask) Err() error { return t.err }
|
||||||
|
|
||||||
|
func (t *qTask) finish() {
|
||||||
|
if t.done == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
t.cancel()
|
||||||
|
close(t.done)
|
||||||
|
t.done = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type Option interface {
|
||||||
|
Apply(*qTask)
|
||||||
|
}
|
||||||
|
type OptionFn func(*qTask)
|
||||||
|
|
||||||
|
func (fn OptionFn) Apply(t *qTask) { fn(t) }
|
||||||
|
|
||||||
|
type Tasker interface {
|
||||||
|
Run(Key, Fn, ...Option) *qTask
|
||||||
|
}
|
||||||
|
|
||||||
|
type Runner struct {
|
||||||
|
defaultOpts []Option
|
||||||
|
queue map[interface{}]*qTask
|
||||||
|
mu sync.RWMutex
|
||||||
|
ctx context.Context
|
||||||
|
cancel func()
|
||||||
|
pause chan struct{}
|
||||||
|
limiter ratelimit.Limiter
|
||||||
|
}
|
||||||
|
|
||||||
|
type Timeout time.Duration
|
||||||
|
|
||||||
|
func (d Timeout) Apply(task *qTask) {
|
||||||
|
task.ctx, task.cancel = context.WithTimeout(task.ctx, time.Duration(d))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tr *Runner) Run(key Key, fn Fn, opts ...Option) *qTask {
|
||||||
|
tr.mu.RLock()
|
||||||
|
log.Infos("task to run", fmt.Sprintf("%T", key), key.Key())
|
||||||
|
|
||||||
|
if task, ok := tr.queue[key.Key()]; ok {
|
||||||
|
tr.mu.RUnlock()
|
||||||
|
log.Infos("task found running", fmt.Sprintf("%T", key), key.Key())
|
||||||
|
|
||||||
|
return task
|
||||||
|
}
|
||||||
|
tr.mu.RUnlock()
|
||||||
|
|
||||||
|
task := &qTask{
|
||||||
|
key: key,
|
||||||
|
fn: fn,
|
||||||
|
cancel: func() {},
|
||||||
|
ctx: tr.ctx,
|
||||||
|
done: make(chan struct{}),
|
||||||
|
Tasker: tr,
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, opt := range tr.defaultOpts {
|
||||||
|
opt.Apply(task)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt.Apply(task)
|
||||||
|
}
|
||||||
|
|
||||||
|
tr.mu.Lock()
|
||||||
|
tr.queue[key.Key()] = task
|
||||||
|
tr.mu.Unlock()
|
||||||
|
|
||||||
|
log.Debug("Waiting for limiter")
|
||||||
|
tr.limiter.Take()
|
||||||
|
log.Debug("Got tag from limiter")
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
task.err = fmt.Errorf("PANIC: %v", r)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := task.Err(); err == nil {
|
||||||
|
log.Infos("task complete", fmt.Sprintf("%T", task.Key()), task.Key())
|
||||||
|
} else {
|
||||||
|
log.Errors("task Failed", fmt.Sprintf("%T", task.Key()), task.Key(), "err", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
log.Infos("task Running", fmt.Sprintf("%T", task.Key()), task.Key())
|
||||||
|
|
||||||
|
task.fn(task)
|
||||||
|
|
||||||
|
tr.mu.Lock()
|
||||||
|
delete(tr.queue, task.Key())
|
||||||
|
tr.mu.Unlock()
|
||||||
|
}()
|
||||||
|
|
||||||
|
return task
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRunner(ctx context.Context, defaultOpts ...Option) *Runner {
|
||||||
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
|
|
||||||
|
tr := &Runner{
|
||||||
|
defaultOpts: defaultOpts,
|
||||||
|
queue: make(map[interface{}]*qTask),
|
||||||
|
ctx: ctx,
|
||||||
|
cancel: cancel,
|
||||||
|
pause: make(chan struct{}),
|
||||||
|
limiter: ratelimit.New(10),
|
||||||
|
}
|
||||||
|
|
||||||
|
return tr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tr *Runner) List() []*qTask {
|
||||||
|
tr.mu.RLock()
|
||||||
|
defer tr.mu.RUnlock()
|
||||||
|
|
||||||
|
lis := make([]*qTask, 0, len(tr.queue))
|
||||||
|
|
||||||
|
for _, task := range tr.queue {
|
||||||
|
lis = append(lis, task)
|
||||||
|
}
|
||||||
|
|
||||||
|
return lis
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tr *Runner) Stop() {
|
||||||
|
tr.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tr *Runner) Len() int {
|
||||||
|
tr.mu.RLock()
|
||||||
|
defer tr.mu.RUnlock()
|
||||||
|
|
||||||
|
return len(tr.queue)
|
||||||
|
}
|
||||||
|
|
||||||
|
func WithCache(c cache.Cacher, expireAfter time.Duration) OptionFn {
|
||||||
|
return func(task *qTask) {
|
||||||
|
innerFn := task.fn
|
||||||
|
task.fn = func(q Q) {
|
||||||
|
cacheKey, ok := q.Key().(cache.Key)
|
||||||
|
if !ok {
|
||||||
|
log.Infos("not a cache key", fmt.Sprintf("%T", q.Key()), q.Key())
|
||||||
|
innerFn(q)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if v, ok := c.Get(cacheKey); ok {
|
||||||
|
log.Infos("value in cache", fmt.Sprintf("%T", cacheKey), cacheKey.Key())
|
||||||
|
q.Resolve(v.Value())
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Infos("not in cache", fmt.Sprintf("%T", cacheKey), cacheKey.Key())
|
||||||
|
innerFn(q)
|
||||||
|
|
||||||
|
if err := task.Err(); err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result := cache.NewItem(cacheKey, task.Result(), expireAfter)
|
||||||
|
|
||||||
|
log.Infos("result to cache", fmt.Sprintf("%T", cacheKey), cacheKey.Key())
|
||||||
|
c.Add(cacheKey, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
package routes
|
package readutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"compress/bzip2"
|
"compress/bzip2"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/andybalholm/brotli"
|
"github.com/andybalholm/brotli"
|
||||||
@@ -10,6 +11,7 @@ import (
|
|||||||
"sour.is/x/toolbox/log"
|
"sour.is/x/toolbox/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Decompress varius types of compression types
|
||||||
func Decompress(in io.Reader) (io.Reader, error) {
|
func Decompress(in io.Reader) (io.Reader, error) {
|
||||||
rdr := NewPreviewReader(in)
|
rdr := NewPreviewReader(in)
|
||||||
mime, err := ReadMIMEWithSize(rdr, "", 32768)
|
mime, err := ReadMIMEWithSize(rdr, "", 32768)
|
||||||
@@ -30,8 +32,12 @@ func Decompress(in io.Reader) (io.Reader, error) {
|
|||||||
|
|
||||||
case "application/brotli":
|
case "application/brotli":
|
||||||
r = brotli.NewReader(r)
|
r = brotli.NewReader(r)
|
||||||
|
default:
|
||||||
|
return r, ErrUnsupportedType
|
||||||
}
|
}
|
||||||
log.Debugs("Decompress:", "mime", mime)
|
log.Debugs("Decompress:", "mime", mime)
|
||||||
|
|
||||||
return r, err
|
return r, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ErrUnsupportedType = errors.New("Unsupported decompression type")
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package routes
|
package readutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -9,15 +9,18 @@ import (
|
|||||||
"sour.is/x/toolbox/log"
|
"sour.is/x/toolbox/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// PreviewReader allows for seeking into a stream that does not support rewind
|
||||||
type PreviewReader struct {
|
type PreviewReader struct {
|
||||||
r io.Reader
|
r io.Reader
|
||||||
buf bytes.Buffer
|
buf bytes.Buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewPreviewReader wrapps a reader with PreviewReader
|
||||||
func NewPreviewReader(r io.Reader) *PreviewReader {
|
func NewPreviewReader(r io.Reader) *PreviewReader {
|
||||||
return &PreviewReader{r: r}
|
return &PreviewReader{r: r}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ErrReaderDrained if reading from a drained PreviewReader
|
||||||
var ErrReaderDrained = errors.New("io.Reader has been drained")
|
var ErrReaderDrained = errors.New("io.Reader has been drained")
|
||||||
|
|
||||||
func (pr *PreviewReader) Read(p []byte) (n int, err error) {
|
func (pr *PreviewReader) Read(p []byte) (n int, err error) {
|
||||||
@@ -36,6 +39,7 @@ func (pr *PreviewReader) Read(p []byte) (n int, err error) {
|
|||||||
return i, err
|
return i, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Drain returns reader that is reset
|
||||||
func (pr *PreviewReader) Drain() io.Reader {
|
func (pr *PreviewReader) Drain() io.Reader {
|
||||||
dr := &drainReader{r: pr.r, buf: &pr.buf}
|
dr := &drainReader{r: pr.r, buf: &pr.buf}
|
||||||
pr.r = nil
|
pr.r = nil
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
package routes
|
package readutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -23,6 +24,9 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func br(buf []byte) bool {
|
func br(buf []byte) bool {
|
||||||
|
if len(buf) < 32768 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
var r io.Reader = bytes.NewReader(buf)
|
var r io.Reader = bytes.NewReader(buf)
|
||||||
r = NewPreviewReader(r)
|
r = NewPreviewReader(r)
|
||||||
br := brotli.NewReader(r)
|
br := brotli.NewReader(r)
|
||||||
@@ -40,10 +44,12 @@ func br(buf []byte) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadMIME of read stream with default size 32 byte
|
||||||
func ReadMIME(in io.Reader, filename string) (string, error) {
|
func ReadMIME(in io.Reader, filename string) (string, error) {
|
||||||
return ReadMIMEWithSize(in, filename, 32)
|
return ReadMIMEWithSize(in, filename, 512)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadMIMEWithSize and return best guess for mime
|
||||||
func ReadMIMEWithSize(in io.Reader, filename string, n int) (string, error) {
|
func ReadMIMEWithSize(in io.Reader, filename string, n int) (string, error) {
|
||||||
mime := "application/octet-stream"
|
mime := "application/octet-stream"
|
||||||
|
|
||||||
@@ -53,6 +59,11 @@ func ReadMIMEWithSize(in io.Reader, filename string, n int) (string, error) {
|
|||||||
return mime, err
|
return mime, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mime = http.DetectContentType(buf)
|
||||||
|
if mime != "application/octet-stream" {
|
||||||
|
return mime, nil
|
||||||
|
}
|
||||||
|
|
||||||
kind, err := filetype.Match(buf)
|
kind, err := filetype.Match(buf)
|
||||||
|
|
||||||
if kind == types.Unknown {
|
if kind == types.Unknown {
|
||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"archive/tar"
|
"archive/tar"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -13,6 +14,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
"sour.is/x/paste/src/pkg/readutil"
|
||||||
"sour.is/x/toolbox/httpsrv"
|
"sour.is/x/toolbox/httpsrv"
|
||||||
"sour.is/x/toolbox/log"
|
"sour.is/x/toolbox/log"
|
||||||
|
|
||||||
@@ -29,9 +31,11 @@ func init() {
|
|||||||
{Name: "get-path", Method: "GET", Pattern: "/a/{name}/{path:.*}", HandlerFunc: a.get},
|
{Name: "get-path", Method: "GET", Pattern: "/a/{name}/{path:.*}", HandlerFunc: a.get},
|
||||||
{Name: "get", Method: "GET", Pattern: "/a/{name}", HandlerFunc: a.get},
|
{Name: "get", Method: "GET", Pattern: "/a/{name}", HandlerFunc: a.get},
|
||||||
{Name: "put", Method: "PUT", Pattern: "/a", HandlerFunc: a.put},
|
{Name: "put", Method: "PUT", Pattern: "/a", HandlerFunc: a.put},
|
||||||
|
{Name: "get", Method: "GET", Pattern: "/a", HandlerFunc: a.list},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Artifact stores items to disk
|
||||||
type Artifact struct {
|
type Artifact struct {
|
||||||
store string
|
store string
|
||||||
maxSize int64
|
maxSize int64
|
||||||
@@ -87,9 +91,9 @@ func (a *Artifact) get(w http.ResponseWriter, r *http.Request) {
|
|||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
if !hasPath {
|
if !hasPath {
|
||||||
pr := NewPreviewReader(f)
|
pr := readutil.NewPreviewReader(f)
|
||||||
|
|
||||||
mime, err := ReadMIME(pr, name)
|
mime, err := readutil.ReadMIME(pr, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpsrv.WriteError(w, http.StatusInternalServerError, err.Error())
|
httpsrv.WriteError(w, http.StatusInternalServerError, err.Error())
|
||||||
return
|
return
|
||||||
@@ -97,12 +101,12 @@ func (a *Artifact) get(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Content-Type", mime)
|
w.Header().Set("Content-Type", mime)
|
||||||
w.Header().Set("X-Content-Type-Options", "nosniff")
|
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||||
|
|
||||||
io.Copy(w, pr.Drain())
|
_, _ = io.Copy(w, pr.Drain())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
rdr, err := Decompress(f)
|
rdr, err := readutil.Decompress(f)
|
||||||
if err != nil {
|
if err != nil && err != readutil.ErrUnsupportedType {
|
||||||
httpsrv.WriteError(w, http.StatusInternalServerError, err.Error())
|
httpsrv.WriteError(w, http.StatusInternalServerError, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -160,14 +164,14 @@ func (a *Artifact) get(w http.ResponseWriter, r *http.Request) {
|
|||||||
renderer := html.NewRenderer(opts)
|
renderer := html.NewRenderer(opts)
|
||||||
|
|
||||||
b := markdown.ToHTML(md, p, renderer)
|
b := markdown.ToHTML(md, p, renderer)
|
||||||
w.Write(b)
|
_, _ = w.Write(b)
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pr := NewPreviewReader(tr)
|
pr := readutil.NewPreviewReader(tr)
|
||||||
|
|
||||||
mime, err := ReadMIME(pr, hdr.Name)
|
mime, err := readutil.ReadMIME(pr, hdr.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpsrv.WriteError(w, http.StatusInternalServerError, err.Error())
|
httpsrv.WriteError(w, http.StatusInternalServerError, err.Error())
|
||||||
return
|
return
|
||||||
@@ -197,7 +201,7 @@ func (a *Artifact) put(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rdr := io.LimitReader(r.Body, 500*1024*1024)
|
rdr := io.LimitReader(r.Body, 500*1024*1024)
|
||||||
pr := NewPreviewReader(rdr)
|
pr := readutil.NewPreviewReader(rdr)
|
||||||
rdr = pr.Drain()
|
rdr = pr.Drain()
|
||||||
|
|
||||||
s256 := sha256.New()
|
s256 := sha256.New()
|
||||||
@@ -219,7 +223,24 @@ func (a *Artifact) put(w http.ResponseWriter, r *http.Request) {
|
|||||||
fname := filepath.Join(a.store, id)
|
fname := filepath.Join(a.store, id)
|
||||||
|
|
||||||
log.Debugs("Artifact: moving file", "src", tmp.Name(), "dst", fname)
|
log.Debugs("Artifact: moving file", "src", tmp.Name(), "dst", fname)
|
||||||
os.Rename(tmp.Name(), fname)
|
_ = os.Rename(tmp.Name(), fname)
|
||||||
|
|
||||||
httpsrv.WriteText(w, http.StatusCreated, id)
|
httpsrv.WriteText(w, http.StatusCreated, id)
|
||||||
}
|
}
|
||||||
|
func (a *Artifact) list(w http.ResponseWriter, r *http.Request) {
|
||||||
|
err := filepath.Walk(a.store, func(path string, info os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if info.IsDir() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = fmt.Fprintln(w, "FILE: ", info.Name())
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
httpsrv.WriteError(w, http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
698
src/routes/identity.go
Normal file
698
src/routes/identity.go
Normal file
@@ -0,0 +1,698 @@
|
|||||||
|
package routes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"crypto/md5"
|
||||||
|
"crypto/sha1"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"net/mail"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
"text/template"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/lucasb-eyer/go-colorful"
|
||||||
|
"github.com/sour-is/crypto/openpgp"
|
||||||
|
"github.com/tv42/zbase32"
|
||||||
|
"golang.org/x/crypto/openpgp/armor"
|
||||||
|
|
||||||
|
"sour.is/x/paste/src/pkg/cache"
|
||||||
|
"sour.is/x/paste/src/pkg/promise"
|
||||||
|
"sour.is/x/toolbox/httpsrv"
|
||||||
|
"sour.is/x/toolbox/log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var expireAfter = 20 * time.Minute
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cache, err := cache.NewARC(2048)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
tasker := promise.NewRunner(context.TODO(), promise.Timeout(30*time.Second), promise.WithCache(cache, expireAfter))
|
||||||
|
|
||||||
|
s := &identity{
|
||||||
|
cache: cache,
|
||||||
|
tasker: tasker,
|
||||||
|
}
|
||||||
|
|
||||||
|
httpsrv.RegisterModule("identity", s.config)
|
||||||
|
|
||||||
|
httpsrv.HttpRegister("identity", httpsrv.HttpRoutes{
|
||||||
|
{Name: "get", Method: "GET", Pattern: "/id/{id}", HandlerFunc: s.get},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var pixl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="
|
||||||
|
|
||||||
|
var defaultStyle = &Style{
|
||||||
|
Avatar: pixl,
|
||||||
|
Cover: pixl,
|
||||||
|
Background: pixl,
|
||||||
|
Palette: getPalette("#93CCEA"),
|
||||||
|
}
|
||||||
|
|
||||||
|
type identity struct {
|
||||||
|
cache cache.Cacher
|
||||||
|
tasker promise.Tasker
|
||||||
|
}
|
||||||
|
|
||||||
|
type page struct {
|
||||||
|
Entity *Entity
|
||||||
|
Style *Style
|
||||||
|
Proofs *Proofs
|
||||||
|
|
||||||
|
IsComplete bool
|
||||||
|
Err error
|
||||||
|
}
|
||||||
|
type Proofs map[string]*Proof
|
||||||
|
|
||||||
|
func (s *identity) config(config map[string]string) {}
|
||||||
|
|
||||||
|
// func (s *identity) runtoCache()
|
||||||
|
|
||||||
|
func (s *identity) get(w http.ResponseWriter, r *http.Request) {
|
||||||
|
secHeaders(w)
|
||||||
|
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
id := vars["id"]
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(r.Context(), 2*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
task := s.tasker.Run(EntityKey(id), func(q promise.Q) {
|
||||||
|
ctx := q.Context()
|
||||||
|
key := q.Key().(EntityKey)
|
||||||
|
|
||||||
|
log.Infos("start task", fmt.Sprintf("%T", key), key)
|
||||||
|
|
||||||
|
entity, err := s.getOpenPGPkey(ctx, string(key))
|
||||||
|
if err != nil {
|
||||||
|
q.Reject(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Infos("Scheduling Style", "email", entity.Primary.Address)
|
||||||
|
q.Run(StyleKey(entity.Primary.Address), func(q promise.Q) {
|
||||||
|
ctx := q.Context()
|
||||||
|
key := q.Key().(StyleKey)
|
||||||
|
|
||||||
|
log.Infos("start task", fmt.Sprintf("%T", key), key)
|
||||||
|
style, err := s.getStyle(ctx, string(key))
|
||||||
|
if err != nil {
|
||||||
|
q.Reject(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Notice("Resolving Style")
|
||||||
|
q.Resolve(style)
|
||||||
|
})
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
|
||||||
|
log.Infos("Scheduling Proofs", "num", len(entity.Proofs))
|
||||||
|
for i := range entity.Proofs {
|
||||||
|
q.Run(ProofKey(entity.Proofs[i]), func(q promise.Q) {
|
||||||
|
key := q.Key().(ProofKey)
|
||||||
|
proof := NewProof(string(key))
|
||||||
|
proof.Checked = true
|
||||||
|
proof.Verified = true
|
||||||
|
log.Notice("Resolving Proof")
|
||||||
|
q.Resolve(proof)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
log.Notice("Resolving Entity")
|
||||||
|
q.Resolve(entity)
|
||||||
|
})
|
||||||
|
|
||||||
|
page := page{Style: defaultStyle}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-task.Await():
|
||||||
|
log.Info("Tasks Competed")
|
||||||
|
if err := task.Err(); err != nil {
|
||||||
|
page.Err = err
|
||||||
|
page.IsComplete = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
page.Entity = task.Result().(*Entity)
|
||||||
|
|
||||||
|
case <-ctx.Done():
|
||||||
|
log.Info("Deadline Timeout")
|
||||||
|
if e, ok := s.cache.Get(EntityKey(id)); ok {
|
||||||
|
page.Entity = e.Value().(*Entity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if page.Entity != nil {
|
||||||
|
var gotStyle, gotProofs bool
|
||||||
|
|
||||||
|
if s, ok := s.cache.Get(StyleKey(page.Entity.Primary.Address)); ok {
|
||||||
|
page.Style = s.Value().(*Style)
|
||||||
|
gotStyle = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Proofs
|
||||||
|
gotProofs = true
|
||||||
|
if len(page.Entity.Proofs) > 0 {
|
||||||
|
proofs := make(Proofs, len(page.Entity.Proofs))
|
||||||
|
for i := range page.Entity.Proofs {
|
||||||
|
p := page.Entity.Proofs[i]
|
||||||
|
|
||||||
|
proofs[p] = NewProof(p)
|
||||||
|
if s, ok := s.cache.Get(ProofKey(p)); ok {
|
||||||
|
proofs[p] = s.Value().(*Proof)
|
||||||
|
} else {
|
||||||
|
log.Info("Missing proof", p)
|
||||||
|
gotProofs = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
page.Proofs = &proofs
|
||||||
|
}
|
||||||
|
|
||||||
|
page.IsComplete = gotStyle && gotProofs
|
||||||
|
}
|
||||||
|
|
||||||
|
// e := json.NewEncoder(w)
|
||||||
|
// e.SetIndent("", " ")
|
||||||
|
// e.Encode(entity)
|
||||||
|
|
||||||
|
t, err := template.New("identity").Parse(identityTPL)
|
||||||
|
if err != nil {
|
||||||
|
httpsrv.WriteText(w, 500, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = t.Execute(w, page)
|
||||||
|
if err != nil {
|
||||||
|
httpsrv.WriteText(w, 500, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *identity) getOpenPGPkey(ctx context.Context, id string) (entity *Entity, err error) {
|
||||||
|
useArmored := false
|
||||||
|
addr := ""
|
||||||
|
|
||||||
|
if isFingerprint(id) {
|
||||||
|
addr = "https://keys.openpgp.org/vks/v1/by-fingerprint/" + strings.ToUpper(id)
|
||||||
|
useArmored = true
|
||||||
|
} else if email, err := mail.ParseAddress(id); err == nil {
|
||||||
|
addr = getWKDPubKeyAddr(email)
|
||||||
|
useArmored = false
|
||||||
|
} else {
|
||||||
|
return entity, fmt.Errorf("Parse address: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, addr, nil)
|
||||||
|
if err != nil {
|
||||||
|
return entity, err
|
||||||
|
}
|
||||||
|
cl := http.Client{}
|
||||||
|
resp, err := cl.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return entity, fmt.Errorf("Requesting key: %w\nRemote URL: %v", err, addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
return entity, fmt.Errorf("bad response from remote: %s\nRemote URL: %v", resp.Status, addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.Header.Get("Content-Type") == "application/pgp-keys" {
|
||||||
|
useArmored = true
|
||||||
|
}
|
||||||
|
log.Infos("getIdentity", "id", id, "useArmored", useArmored, "status", resp.Status, "addr", addr)
|
||||||
|
|
||||||
|
entity, err = ReadKey(resp.Body, useArmored)
|
||||||
|
|
||||||
|
return entity, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type EntityKey string
|
||||||
|
|
||||||
|
func (k EntityKey) Key() interface{} {
|
||||||
|
return k
|
||||||
|
}
|
||||||
|
|
||||||
|
type Entity struct {
|
||||||
|
Primary *mail.Address
|
||||||
|
Emails []*mail.Address
|
||||||
|
Fingerprint string
|
||||||
|
Proofs []string
|
||||||
|
ArmorText string
|
||||||
|
}
|
||||||
|
|
||||||
|
func getEntity(lis openpgp.EntityList) (*Entity, error) {
|
||||||
|
entity := &Entity{}
|
||||||
|
var err error
|
||||||
|
|
||||||
|
for _, e := range lis {
|
||||||
|
if e == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if e.PrimaryKey == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.Fingerprint = fmt.Sprintf("%X", e.PrimaryKey.Fingerprint)
|
||||||
|
|
||||||
|
for name, ident := range e.Identities {
|
||||||
|
// Pick first identity
|
||||||
|
if entity.Primary == nil {
|
||||||
|
entity.Primary, err = mail.ParseAddress(name)
|
||||||
|
if err != nil {
|
||||||
|
return entity, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If one is marked primary use that
|
||||||
|
if ident.SelfSignature != nil && ident.SelfSignature.IsPrimaryId != nil && *ident.SelfSignature.IsPrimaryId {
|
||||||
|
entity.Primary, err = mail.ParseAddress(name)
|
||||||
|
if err != nil {
|
||||||
|
return entity, err
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
var email *mail.Address
|
||||||
|
if email, err = mail.ParseAddress(name); err != nil {
|
||||||
|
return entity, err
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.Emails = append(entity.Emails, email)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If identity is self signed read notation data.
|
||||||
|
if ident.SelfSignature != nil && ident.SelfSignature.NotationData != nil {
|
||||||
|
// Get proofs and append to list.
|
||||||
|
if proofs, ok := ident.SelfSignature.NotationData["proof@metacode.biz"]; ok {
|
||||||
|
entity.Proofs = append(entity.Proofs, proofs...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if entity.Primary == nil {
|
||||||
|
entity.Primary, _ = mail.ParseAddress("nobody@nodomain.xyz")
|
||||||
|
}
|
||||||
|
|
||||||
|
return entity, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func ReadKey(r io.Reader, useArmored bool) (e *Entity, err error) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
var w io.Writer = &buf
|
||||||
|
|
||||||
|
if !useArmored {
|
||||||
|
var aw io.WriteCloser
|
||||||
|
aw, err = armor.Encode(&buf, "PGP PUBLIC KEY BLOCK", nil)
|
||||||
|
if err != nil {
|
||||||
|
return e, fmt.Errorf("Read key: %w", err)
|
||||||
|
}
|
||||||
|
defer func() { aw.Close(); e.ArmorText = buf.String() }()
|
||||||
|
w = aw
|
||||||
|
} else {
|
||||||
|
defer func() { e.ArmorText = buf.String() }()
|
||||||
|
}
|
||||||
|
|
||||||
|
r = io.TeeReader(r, w)
|
||||||
|
|
||||||
|
var lis openpgp.EntityList
|
||||||
|
|
||||||
|
if useArmored {
|
||||||
|
lis, err = openpgp.ReadArmoredKeyRing(r)
|
||||||
|
} else {
|
||||||
|
lis, err = openpgp.ReadKeyRing(r)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return e, fmt.Errorf("Read key: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
e, err = getEntity(lis)
|
||||||
|
if err != nil {
|
||||||
|
return e, fmt.Errorf("Parse key: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func isFingerprint(s string) bool {
|
||||||
|
for _, r := range s {
|
||||||
|
switch r {
|
||||||
|
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'A', 'B', 'C', 'D', 'E', 'F':
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func getWKDPubKeyAddr(email *mail.Address) string {
|
||||||
|
parts := strings.SplitN(email.Address, "@", 2)
|
||||||
|
|
||||||
|
hash := sha1.Sum([]byte(parts[0]))
|
||||||
|
lp := zbase32.EncodeToString(hash[:])
|
||||||
|
|
||||||
|
return fmt.Sprintf("https://%s/.well-known/openpgpkey/hu/%s", parts[1], lp)
|
||||||
|
}
|
||||||
|
|
||||||
|
type StyleKey string
|
||||||
|
|
||||||
|
func (s StyleKey) Key() interface{} {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
type Style struct {
|
||||||
|
Avatar,
|
||||||
|
Cover,
|
||||||
|
Background string
|
||||||
|
|
||||||
|
Palette []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *identity) getStyle(ctx context.Context, email string) (*Style, error) {
|
||||||
|
avatarHost, styleHost, err := styleSRV(ctx, email)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
log.Infos("getStyle", "avatar", avatarHost, "style", styleHost)
|
||||||
|
|
||||||
|
hash := md5.New()
|
||||||
|
email = strings.TrimSpace(strings.ToLower(email))
|
||||||
|
_, _ = hash.Write([]byte(email))
|
||||||
|
|
||||||
|
id := hash.Sum(nil)
|
||||||
|
|
||||||
|
style := &Style{}
|
||||||
|
|
||||||
|
style.Palette = getPalette(fmt.Sprintf("#%x", id[:3]))
|
||||||
|
style.Avatar = fmt.Sprintf("https://%s/avatar/%x", avatarHost, id)
|
||||||
|
style.Cover = pixl
|
||||||
|
style.Background = "https://lavana.sour.is/bg/52548b3dcb032882675afe1e4bcba0e9"
|
||||||
|
|
||||||
|
if styleHost != "" {
|
||||||
|
style.Cover = fmt.Sprintf("https://%s/cover/%x", styleHost, id)
|
||||||
|
style.Background = fmt.Sprintf("https://%s/bg/%x", styleHost, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
return style, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func styleSRV(ctx context.Context, email string) (avatar string, style string, err error) {
|
||||||
|
|
||||||
|
// Defaults
|
||||||
|
style = ""
|
||||||
|
avatar = "www.gravatar.com"
|
||||||
|
|
||||||
|
parts := strings.SplitN(email, "@", 2)
|
||||||
|
if _, srv, err := net.DefaultResolver.LookupSRV(ctx, "style-sec", "tcp", parts[1]); err == nil {
|
||||||
|
if len(srv) > 0 {
|
||||||
|
style = strings.TrimSuffix(srv[0].Target, ".")
|
||||||
|
avatar = strings.TrimSuffix(srv[0].Target, ".")
|
||||||
|
|
||||||
|
return avatar, style, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, srv, err := net.DefaultResolver.LookupSRV(ctx, "avatars-sec", "tcp", parts[1]); err == nil {
|
||||||
|
if len(srv) > 0 {
|
||||||
|
avatar = strings.TrimSuffix(srv[0].Target, ".")
|
||||||
|
|
||||||
|
return avatar, style, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// getPalette maes a complementary color palette. https://play.golang.org/p/nBXLUocGsU5
|
||||||
|
func getPalette(hex string) []string {
|
||||||
|
reference, _ := colorful.Hex(hex)
|
||||||
|
reference = sat(lum(reference, 0, .5), 0, .5)
|
||||||
|
|
||||||
|
white := colorful.Color{R: 1, G: 1, B: 1}
|
||||||
|
black := colorful.Color{R: 0, G: 0, B: 0}
|
||||||
|
accentA := hue(reference, 60)
|
||||||
|
accentB := hue(reference, -60)
|
||||||
|
accentC := hue(reference, -180)
|
||||||
|
|
||||||
|
return append(
|
||||||
|
[]string{},
|
||||||
|
|
||||||
|
white.Hex(),
|
||||||
|
lum(reference, .4, .6).Hex(),
|
||||||
|
reference.Hex(),
|
||||||
|
lum(reference, .4, 0).Hex(),
|
||||||
|
black.Hex(),
|
||||||
|
|
||||||
|
lum(accentA, .4, .6).Hex(),
|
||||||
|
accentA.Hex(),
|
||||||
|
lum(accentA, .4, 0).Hex(),
|
||||||
|
|
||||||
|
lum(accentB, .4, .6).Hex(),
|
||||||
|
accentB.Hex(),
|
||||||
|
lum(accentB, .4, 0).Hex(),
|
||||||
|
|
||||||
|
lum(accentC, .4, .6).Hex(),
|
||||||
|
accentC.Hex(),
|
||||||
|
lum(accentC, .4, 0).Hex(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
func hue(in colorful.Color, H float64) colorful.Color {
|
||||||
|
h, s, l := in.Hsl()
|
||||||
|
return colorful.Hsl(h+H, s, l)
|
||||||
|
}
|
||||||
|
func sat(in colorful.Color, S, V float64) colorful.Color {
|
||||||
|
h, s, l := in.Hsl()
|
||||||
|
return colorful.Hsl(h, V+s*S, l)
|
||||||
|
}
|
||||||
|
func lum(in colorful.Color, L, V float64) colorful.Color {
|
||||||
|
h, s, l := in.Hsl()
|
||||||
|
return colorful.Hsl(h, s, V+l*L)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProofKey string
|
||||||
|
|
||||||
|
func (k ProofKey) Key() interface{} {
|
||||||
|
return k
|
||||||
|
}
|
||||||
|
|
||||||
|
type Proof struct {
|
||||||
|
Icon string
|
||||||
|
Service string
|
||||||
|
Name string
|
||||||
|
URI string
|
||||||
|
Link string
|
||||||
|
Checked bool
|
||||||
|
Verified bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewProof(uri string) *Proof {
|
||||||
|
p := &Proof{URI: uri}
|
||||||
|
|
||||||
|
u, err := url.Parse(uri)
|
||||||
|
if err != nil {
|
||||||
|
p.Icon = "exclamation-triangle"
|
||||||
|
p.Service = "error"
|
||||||
|
p.Name = err.Error()
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Service = u.Scheme
|
||||||
|
|
||||||
|
switch u.Scheme {
|
||||||
|
case "dns":
|
||||||
|
p.Icon = "fas fa-globe"
|
||||||
|
p.Name = u.Opaque
|
||||||
|
p.Link = fmt.Sprintf("https://%s", u.Hostname())
|
||||||
|
|
||||||
|
case "xmpp":
|
||||||
|
p.Icon = "fas fa-comments"
|
||||||
|
p.Name = u.Opaque
|
||||||
|
|
||||||
|
case "https":
|
||||||
|
p.Icon = "fas fa-atlas"
|
||||||
|
p.Name = u.Hostname()
|
||||||
|
p.Link = fmt.Sprintf("https://%s", u.Hostname())
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case strings.HasPrefix(u.Host, "twitter.com"):
|
||||||
|
p.Icon = "fab fa-twitter"
|
||||||
|
p.Service = "Twitter"
|
||||||
|
case strings.HasPrefix(u.Host, "news.ycombinator.com"):
|
||||||
|
p.Icon = "fab fa-hacker-news"
|
||||||
|
p.Service = "HackerNews"
|
||||||
|
case strings.HasPrefix(u.Host, "dev.to"):
|
||||||
|
p.Icon = "fab fa-dev"
|
||||||
|
p.Service = "dev.to"
|
||||||
|
case strings.HasPrefix(u.Host, "reddit.com"), strings.HasPrefix(u.Host, "www.reddit.com"):
|
||||||
|
p.Icon = "fab fa-reddit"
|
||||||
|
p.Service = "Reddit"
|
||||||
|
case strings.HasPrefix(u.Host, "gist.github.com"):
|
||||||
|
p.Icon = "fab fa-github"
|
||||||
|
p.Service = "GitHub"
|
||||||
|
case strings.HasPrefix(u.Host, "lobste.rs"):
|
||||||
|
p.Icon = "fas fa-list-ul"
|
||||||
|
p.Service = "Lobsters"
|
||||||
|
case strings.HasSuffix(u.Host, "/gitlab_proof/"):
|
||||||
|
p.Icon = "fab fa-gitlab"
|
||||||
|
p.Service = "GetLab"
|
||||||
|
case strings.HasSuffix(u.Host, "/gitea_proof/"):
|
||||||
|
p.Icon = "fas fa-mug-hot"
|
||||||
|
p.Service = "Gitea"
|
||||||
|
default:
|
||||||
|
p.Icon = "fas fa-project-diagram"
|
||||||
|
p.Service = "fediverse"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func secHeaders(w http.ResponseWriter) {
|
||||||
|
w.Header().Set("X-XSS-Protection", "1; mode=block")
|
||||||
|
w.Header().Set("X-Frame-Options", "DENY")
|
||||||
|
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||||
|
// w.Header().Set("Content-Security-Policy", "default-src 'self';")
|
||||||
|
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||||
|
}
|
||||||
|
|
||||||
|
var identityTPL = `
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
{{if not .IsComplete}}<meta http-equiv="refresh" content="1">{{end}}
|
||||||
|
<script src="https://pagecdn.io/lib/font-awesome/5.14.0/js/fontawesome.min.js" crossorigin="anonymous" integrity="sha256-dNZKI9qQEpJG03MLdR2Rg9Dva1o+50fN3zmlDP+3I+Y="></script>
|
||||||
|
|
||||||
|
<link href="https://pagecdn.io/lib/bootstrap/4.5.1/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-VoFZSlmyTXsegReQCNmbXrS4hBBUl/cexZvPmPWoJsY=" >
|
||||||
|
<link href="https://pagecdn.io/lib/font-awesome/5.14.0/css/fontawesome.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-7YMlwkILTJEm0TSengNDszUuNSeZu4KTN3z7XrhUQvc=" >
|
||||||
|
<link href="https://pagecdn.io/lib/font-awesome/5.14.0/css/solid.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-s0DhrAmIsT5gZ3X4f+9wIXUbH52CMiqFAwgqCmdPoec=" >
|
||||||
|
<link href="https://pagecdn.io/lib/font-awesome/5.14.0/css/regular.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-FAKIbnpfWhK6v5Re+NAi9n+5+dXanJvXVFohtH6WAuw=" >
|
||||||
|
<link href="https://pagecdn.io/lib/font-awesome/5.14.0/css/brands.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-xN44ju35FR+kTO/TP/UkqrVbM3LpqUI1VJCWDGbG1ew=" >
|
||||||
|
|
||||||
|
{{ with .Style }}
|
||||||
|
<style>
|
||||||
|
{{range $i, $val := .Palette}}.fg-color-{{$i}} { color: {{$val}}; }
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{range $i, $val := .Palette}}.bg-color-{{$i}} { background-color: {{$val}}; }
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-image: url('{{.Background}}');
|
||||||
|
background-repeat: repeat;
|
||||||
|
background-color: {{index .Palette 7}};
|
||||||
|
padding-top: 1em;
|
||||||
|
}
|
||||||
|
.heading {
|
||||||
|
background-image: url('{{.Cover}}');
|
||||||
|
background-size: cover;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-color: {{index .Palette 3}};
|
||||||
|
}
|
||||||
|
.shade { background-color: {{index .Palette 3}}80; border-radius: .25rem;}
|
||||||
|
.lead { padding:0; margin:0; }
|
||||||
|
|
||||||
|
// (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)
|
||||||
|
@media only screen and (max-width: 576px) {
|
||||||
|
.h1, .h2, .h3, .h4, .h5, h6 { font-size: 50% }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{{end}}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="card">
|
||||||
|
<div class="jumbotron heading">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row shade">
|
||||||
|
|
||||||
|
{{ with .Err }}
|
||||||
|
<div class="col-xs">
|
||||||
|
<i class="fas fa-exclamation-triangle fa-4x fg-color-11"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-lg">
|
||||||
|
<h1 class="display-8 fg-color-8">Something went wrong...</h1>
|
||||||
|
<pre class="fg-color-11">{{.}}</pre>
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
{{ with .Style }}
|
||||||
|
<div class="col-xs">
|
||||||
|
<img src="{{.Avatar}}" class="img-thumbnail" alt="avatar" style="width:88px; height:88px">
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
|
||||||
|
{{with .Entity}}
|
||||||
|
<div class="col-lg">
|
||||||
|
<h1 class="display-8 fg-color-8">{{.Primary.Name}}</h1>
|
||||||
|
<p class="lead fg-color-11"><i class="fas fa-fingerprint"></i> {{.Fingerprint}}</p>
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
<div class="col-lg">
|
||||||
|
<h1 class="display-8 fg-color-8">Loading...</h1>
|
||||||
|
<p class="lead fg-color-11">Reading key from remote service.</p>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
{{ with .Entity }}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Contact</div>
|
||||||
|
<div class="list-group list-group-flush">
|
||||||
|
{{with .Primary}}<a href="mailto:{{.Address}}" class="list-group-item list-group-item-action"><i class="fas fa-envelope"></i> <b>{{.Name}} <{{.Address}}></b> <span class="badge badge-secondary">Primary</span></a>{{end}}
|
||||||
|
{{range .Emails}}<a href="mailto:{{.Address}}" class="list-group-item list-group-item-action"><i class="far fa-envelope"></i> {{.Name}} <{{.Address}}></a>{{end}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{with .Proofs}}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Proofs</div>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
{{range .}}
|
||||||
|
<li class="list-group-item">
|
||||||
|
<i class="{{.Icon}}"></i>
|
||||||
|
<span class="badge badge-secondary">{{.Service}}</span>
|
||||||
|
{{.Name}}
|
||||||
|
{{if .Checked}}
|
||||||
|
{{if .Verified}}Verified{{else}}Invalid{{end}}
|
||||||
|
{{else}}Checking...{{end}}
|
||||||
|
</li>
|
||||||
|
{{end}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
|
{{else}}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">Proofs</div>
|
||||||
|
<div class="card-body">Loading...</div>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-footer text-muted text-center">
|
||||||
|
© 2020 Sour.is
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`
|
||||||
@@ -15,24 +15,27 @@ import (
|
|||||||
"github.com/h2non/filetype"
|
"github.com/h2non/filetype"
|
||||||
"sour.is/x/toolbox/httpsrv"
|
"sour.is/x/toolbox/httpsrv"
|
||||||
"sour.is/x/toolbox/log"
|
"sour.is/x/toolbox/log"
|
||||||
|
|
||||||
|
"sour.is/x/paste/src/pkg/readutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
a := &Image{}
|
a := &image{}
|
||||||
httpsrv.RegisterModule("image", a.config)
|
httpsrv.RegisterModule("image", a.config)
|
||||||
|
|
||||||
httpsrv.HttpRegister("image", httpsrv.HttpRoutes{
|
httpsrv.HttpRegister("image", httpsrv.HttpRoutes{
|
||||||
{Name: "getImage", Method: "GET", Pattern: "/i/{name}", HandlerFunc: a.get},
|
{Name: "getImage", Method: "GET", Pattern: "/i/{name}", HandlerFunc: a.get},
|
||||||
{Name: "putImage", Method: "PUT", Pattern: "/i", HandlerFunc: a.put},
|
{Name: "putImage", Method: "PUT", Pattern: "/i", HandlerFunc: a.put},
|
||||||
|
{Name: "getStyle", Method: "GET", Pattern: "/{style:avatar|bg|cover}/", HandlerFunc: a.getStyle},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type Image struct {
|
type image struct {
|
||||||
store string
|
store string
|
||||||
maxSize int64
|
maxSize int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Image) config(config map[string]string) {
|
func (a *image) config(config map[string]string) {
|
||||||
a.store = "data/"
|
a.store = "data/"
|
||||||
if config["store"] != "" {
|
if config["store"] != "" {
|
||||||
a.store = config["store"]
|
a.store = config["store"]
|
||||||
@@ -52,7 +55,7 @@ func (a *Image) config(config map[string]string) {
|
|||||||
log.Noticef("Image: store max-size set to [%d]", a.maxSize)
|
log.Noticef("Image: store max-size set to [%d]", a.maxSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Image) get(w http.ResponseWriter, r *http.Request) {
|
func (a *image) get(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
|
|
||||||
name := vars["name"]
|
name := vars["name"]
|
||||||
@@ -80,16 +83,16 @@ func (a *Image) get(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
pr := NewPreviewReader(f)
|
pr := readutil.NewPreviewReader(f)
|
||||||
|
|
||||||
mime, err := ReadMIME(pr, name)
|
mime, _ := readutil.ReadMIME(pr, name)
|
||||||
w.Header().Set("Content-Type", mime)
|
w.Header().Set("Content-Type", mime)
|
||||||
w.Header().Set("X-Content-Type-Options", "nosniff")
|
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||||
|
|
||||||
io.Copy(w, pr.Drain())
|
_, _ = io.Copy(w, pr.Drain())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Image) put(w http.ResponseWriter, r *http.Request) {
|
func (a *image) put(w http.ResponseWriter, r *http.Request) {
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
|
|
||||||
if h := r.Header.Get("Content-Length"); h != "" {
|
if h := r.Header.Get("Content-Length"); h != "" {
|
||||||
@@ -104,7 +107,7 @@ func (a *Image) put(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rdr := io.LimitReader(r.Body, a.maxSize)
|
rdr := io.LimitReader(r.Body, a.maxSize)
|
||||||
pr := NewPreviewReader(rdr)
|
pr := readutil.NewPreviewReader(rdr)
|
||||||
if !isImageOrVideo(pr) {
|
if !isImageOrVideo(pr) {
|
||||||
httpsrv.WriteError(w, http.StatusUnsupportedMediaType, "ERR Not Image")
|
httpsrv.WriteError(w, http.StatusUnsupportedMediaType, "ERR Not Image")
|
||||||
return
|
return
|
||||||
@@ -147,3 +150,7 @@ func isImageOrVideo(in io.Reader) bool {
|
|||||||
}
|
}
|
||||||
return filetype.IsImage(buf) || filetype.IsVideo(buf)
|
return filetype.IsImage(buf) || filetype.IsVideo(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *image) getStyle(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
"sour.is/x/paste/src/pkg/readutil"
|
||||||
"sour.is/x/toolbox/httpsrv"
|
"sour.is/x/toolbox/httpsrv"
|
||||||
"sour.is/x/toolbox/log"
|
"sour.is/x/toolbox/log"
|
||||||
)
|
)
|
||||||
@@ -150,7 +151,7 @@ func (p *Paste) getPaste(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
pr := NewPreviewReader(f)
|
pr := readutil.NewPreviewReader(f)
|
||||||
|
|
||||||
keep := true
|
keep := true
|
||||||
scanner := bufio.NewScanner(pr)
|
scanner := bufio.NewScanner(pr)
|
||||||
@@ -191,7 +192,7 @@ func (p *Paste) getPaste(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
io.Copy(w, pr.Drain())
|
_, _ = io.Copy(w, pr.Drain())
|
||||||
|
|
||||||
if !keep {
|
if !keep {
|
||||||
deleteFile(fname)
|
deleteFile(fname)
|
||||||
@@ -216,19 +217,19 @@ func (p *Paste) postPaste(w http.ResponseWriter, r *http.Request) {
|
|||||||
id := base64.RawURLEncoding.EncodeToString(s256.Sum(nil)[12:])
|
id := base64.RawURLEncoding.EncodeToString(s256.Sum(nil)[12:])
|
||||||
fname := filepath.Join(p.store, id)
|
fname := filepath.Join(p.store, id)
|
||||||
|
|
||||||
os.Rename(tmp.Name(), fname)
|
_ = os.Rename(tmp.Name(), fname)
|
||||||
|
|
||||||
httpsrv.WriteText(w, http.StatusCreated, "OK "+id)
|
httpsrv.WriteText(w, http.StatusCreated, "OK "+id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkErr(err error, w http.ResponseWriter) bool {
|
// func checkErr(err error, w http.ResponseWriter) bool {
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
httpsrv.WriteObject(w, http.StatusBadRequest, err)
|
// httpsrv.WriteObject(w, http.StatusBadRequest, err)
|
||||||
return true
|
// return true
|
||||||
}
|
// }
|
||||||
|
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
|
|
||||||
func deleteFile(path string) {
|
func deleteFile(path string) {
|
||||||
_ = ioutil.WriteFile(path, nil, 0644)
|
_ = ioutil.WriteFile(path, nil, 0644)
|
||||||
|
|||||||
@@ -1,195 +0,0 @@
|
|||||||
package routes
|
|
||||||
|
|
||||||
import (
|
|
||||||
"sour.is/x/httpsrv"
|
|
||||||
"os"
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"sour.is/x/ident"
|
|
||||||
"crypto/rand"
|
|
||||||
"encoding/base64"
|
|
||||||
"crypto/sha256"
|
|
||||||
"io/ioutil"
|
|
||||||
"io"
|
|
||||||
"bufio"
|
|
||||||
"github.com/gorilla/mux"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
"strconv"
|
|
||||||
)
|
|
||||||
|
|
||||||
var store string
|
|
||||||
var randBytes int
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
httpsrv.RegisterModule("paste", SetConfig)
|
|
||||||
|
|
||||||
httpsrv.IdentRegister("paste", httpsrv.IdentRoutes{
|
|
||||||
{ "Paste", "GET", "/paste/rng", GetRandom, },
|
|
||||||
{ "Paste", "GET", "/paste/{id}", GetPaste, },
|
|
||||||
{ "Paste", "GET", "/paste/get/{id}", GetPaste, },
|
|
||||||
{ "Paste", "POST", "/paste", PostPaste, },
|
|
||||||
{ "Paste", "DELETE", "/paste/{id}", DeletePaste, },
|
|
||||||
|
|
||||||
{ "Paste", "GET", "/api/rng", GetRandom, },
|
|
||||||
{ "Paste", "GET", "/api/{id}", GetPaste, },
|
|
||||||
{ "Paste", "GET", "/api/get/{id}", GetPaste, },
|
|
||||||
{ "Paste", "POST", "/api", PostPaste, },
|
|
||||||
{ "Paste", "DELETE", "/api/{id}", DeletePaste, },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetConfig (config map[string]string) {
|
|
||||||
|
|
||||||
store = "data/"
|
|
||||||
if config["store"] != "" {
|
|
||||||
store = config["store"]
|
|
||||||
}
|
|
||||||
|
|
||||||
if !chkStore(store) {
|
|
||||||
log.Fatalf("[routes::Paste] Store location [%s] does not exist or is not writable.", store)
|
|
||||||
}
|
|
||||||
|
|
||||||
randBytes = 1024
|
|
||||||
if config["random"] != "" {
|
|
||||||
randBytes, _ = strconv.Atoi(config["random"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func chkStore(path string) bool {
|
|
||||||
file, err := os.Stat(path)
|
|
||||||
if err == nil { return true }
|
|
||||||
if os.IsNotExist(err) { return false }
|
|
||||||
if !file.IsDir() { return false }
|
|
||||||
if unix.Access(path, unix.W_OK & unix.R_OK) != nil { return false }
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func chkFile(path string) bool {
|
|
||||||
file, err := os.Stat(path)
|
|
||||||
if err == nil { return true }
|
|
||||||
if os.IsNotExist(err) { return false }
|
|
||||||
if file.IsDir() { return false }
|
|
||||||
if unix.Access(path, unix.W_OK & unix.R_OK) != nil { return false }
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func chkGone(path string) bool {
|
|
||||||
file, err := os.Stat(path)
|
|
||||||
if err != nil { return true }
|
|
||||||
if file.Size() == 0 { return true }
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetRandom(w http.ResponseWriter, r *http.Request, i ident.Ident) {
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
w.Header().Set("content-type","application/octet-stream")
|
|
||||||
s := make([]byte, randBytes)
|
|
||||||
rand.Read(s)
|
|
||||||
|
|
||||||
w.Write(s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetPaste(w http.ResponseWriter, r *http.Request, i ident.Ident) {
|
|
||||||
vars := mux.Vars(r)
|
|
||||||
id := vars["id"]
|
|
||||||
|
|
||||||
if !chkFile(store + id) {
|
|
||||||
w.WriteHeader(http.StatusNotFound)
|
|
||||||
w.Write([]byte("ERR Not Found"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if chkGone(store + id) {
|
|
||||||
w.WriteHeader(http.StatusGone)
|
|
||||||
w.Write([]byte("ERR Gone"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
head, err := os.Open(store + id)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
defer head.Close()
|
|
||||||
|
|
||||||
keep := true
|
|
||||||
|
|
||||||
scanner := bufio.NewScanner(head)
|
|
||||||
for scanner.Scan() {
|
|
||||||
txt := scanner.Text()
|
|
||||||
log.Println(txt)
|
|
||||||
if (txt == "") {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.HasPrefix(txt, "exp:") {
|
|
||||||
now := time.Now().Unix()
|
|
||||||
exp, err := strconv.ParseInt(strings.TrimSpace(strings.TrimPrefix(txt, "exp:")), 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
log.Print(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if now > exp {
|
|
||||||
log.Printf("%d > %d", now, exp)
|
|
||||||
w.WriteHeader(http.StatusGone)
|
|
||||||
w.Write([]byte("ERR Gone"))
|
|
||||||
|
|
||||||
Delete(store + id)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.HasPrefix(txt, "burn:") {
|
|
||||||
burn := strings.TrimSpace(strings.TrimPrefix(txt, "burn:"))
|
|
||||||
|
|
||||||
if burn == "true" {
|
|
||||||
keep = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
file, _ := os.Open(store + id)
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
|
|
||||||
scanner = bufio.NewScanner(file)
|
|
||||||
for scanner.Scan() {
|
|
||||||
w.Write(scanner.Bytes())
|
|
||||||
w.Write([]byte("\n"))
|
|
||||||
}
|
|
||||||
|
|
||||||
if !keep {
|
|
||||||
Delete(store + id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func PostPaste(w http.ResponseWriter, r *http.Request, i ident.Ident) {
|
|
||||||
body, _ := ioutil.ReadAll(io.LimitReader(r.Body, 1048576))
|
|
||||||
|
|
||||||
s256 := sha256.Sum256(body)
|
|
||||||
id := base64.RawURLEncoding.EncodeToString(s256[12:])
|
|
||||||
|
|
||||||
ioutil.WriteFile(store + id, body, 0644)
|
|
||||||
|
|
||||||
w.WriteHeader(http.StatusCreated)
|
|
||||||
w.Write([]byte("OK " + id))
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeletePaste(w http.ResponseWriter, r *http.Request, i ident.Ident) {
|
|
||||||
vars := mux.Vars(r)
|
|
||||||
id := vars["id"]
|
|
||||||
|
|
||||||
Delete(store + id)
|
|
||||||
|
|
||||||
w.WriteHeader(http.StatusNoContent)
|
|
||||||
w.Write([]byte("OK"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func Delete(path string) {
|
|
||||||
ioutil.WriteFile(path, []byte(""), 0644)
|
|
||||||
}
|
|
||||||
@@ -1,107 +1,131 @@
|
|||||||
package routes
|
package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"crypto/sha1"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/mail"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/coreos/bbolt"
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/sour-is/crypto/openpgp"
|
"github.com/timshannon/badgerhold"
|
||||||
"github.com/tv42/zbase32"
|
|
||||||
|
|
||||||
"sour.is/x/toolbox/httpsrv"
|
"sour.is/x/toolbox/httpsrv"
|
||||||
"sour.is/x/toolbox/log"
|
"sour.is/x/toolbox/log"
|
||||||
"sour.is/x/toolbox/uuid"
|
"sour.is/x/toolbox/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type logger struct{}
|
||||||
|
|
||||||
|
func (logger) Errorf(s string, o ...interface{}) { log.Errorf(s, o...) }
|
||||||
|
func (logger) Warningf(s string, o ...interface{}) { log.Warningf(s, o...) }
|
||||||
|
func (logger) Infof(s string, o ...interface{}) { log.Infof(s, o...) }
|
||||||
|
func (logger) Debugf(s string, o ...interface{}) { log.Debugf(s, o...) }
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
s := &shortDB{}
|
s := &shortDB{}
|
||||||
httpsrv.RegisterModule("short", s.config)
|
httpsrv.RegisterModule("short", s.config)
|
||||||
|
|
||||||
httpsrv.HttpRegister("short", httpsrv.HttpRoutes{
|
httpsrv.HttpRegister("short", httpsrv.HttpRoutes{
|
||||||
{Name: "getShort", Method: "GET", Pattern: "/s/{id}", HandlerFunc: s.getShort},
|
{Name: "get", Method: "GET", Pattern: "/s/{id}", HandlerFunc: s.get},
|
||||||
{Name: "putShort", Method: "PUT", Pattern: "/s/{id}", HandlerFunc: s.putShort},
|
{Name: "put", Method: "PUT", Pattern: "/s/{id}", HandlerFunc: s.put},
|
||||||
{Name: "getIdentity", Method: "GET", Pattern: "/id/{id}", HandlerFunc: s.getIdentity},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type shortDB struct {
|
type shortDB struct {
|
||||||
path string
|
options badgerhold.Options
|
||||||
bucket string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *shortDB) config(config map[string]string) {
|
func (s *shortDB) config(config map[string]string) {
|
||||||
s.bucket = "shortURL"
|
s.options = badgerhold.DefaultOptions
|
||||||
if config["bucket"] != "" {
|
s.options.Options = s.options.WithLogger(logger{})
|
||||||
s.bucket = config["bucket"]
|
|
||||||
|
var ok bool
|
||||||
|
if s.options.Dir, ok = config["index"]; !ok {
|
||||||
|
s.options.Dir = "data"
|
||||||
}
|
}
|
||||||
|
|
||||||
s.path = "data/meta.db"
|
if s.options.ValueDir, ok = config["value"]; !ok {
|
||||||
if config["store"] != "" {
|
s.options.ValueDir = "data"
|
||||||
s.path = config["store"]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db, err := bbolt.Open(s.path, 0666, nil)
|
store, err := badgerhold.Open(s.options)
|
||||||
if err != nil {
|
defer func() {
|
||||||
log.Fatalf("ShortURL: failed to open db at [%s]", s.path)
|
if err = store.Close(); err != nil {
|
||||||
}
|
log.Fatal(err)
|
||||||
defer db.Close()
|
|
||||||
|
|
||||||
db.Update(func(tx *bbolt.Tx) error {
|
|
||||||
_, err := tx.CreateBucketIfNotExists([]byte(s.bucket))
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("ShortURL: create bucket: %s", err)
|
|
||||||
}
|
}
|
||||||
return nil
|
}()
|
||||||
})
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
log.Noticef("ShortURL: opened db at [%s] bucket [%s]", s.path, s.bucket)
|
}
|
||||||
}
|
}
|
||||||
|
func (s *shortDB) get(w http.ResponseWriter, r *http.Request) {
|
||||||
func (s *shortDB) getShort(w http.ResponseWriter, r *http.Request) {
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
|
|
||||||
id := vars["id"]
|
id := vars["id"]
|
||||||
url := s.GetURL(id)
|
|
||||||
|
|
||||||
if url == nil {
|
store, err := badgerhold.Open(s.options)
|
||||||
httpsrv.WriteError(w, 404, "not found")
|
defer func() {
|
||||||
|
if err = store.Close(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if err != nil {
|
||||||
|
httpsrv.WriteText(w, 500, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var url shortURL
|
||||||
|
err = store.Get(id, &url)
|
||||||
|
if err != nil && err != badgerhold.ErrNotFound {
|
||||||
|
httpsrv.WriteText(w, 500, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err == badgerhold.ErrNotFound {
|
||||||
|
httpsrv.WriteText(w, 404, "not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Location", url.URL)
|
w.Header().Set("Location", url.URL)
|
||||||
w.WriteHeader(http.StatusFound)
|
w.WriteHeader(http.StatusFound)
|
||||||
}
|
}
|
||||||
|
func (s *shortDB) put(w http.ResponseWriter, r *http.Request) {
|
||||||
func (s *shortDB) putShort(w http.ResponseWriter, r *http.Request) {
|
|
||||||
defer r.Body.Close()
|
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
|
|
||||||
id := vars["id"]
|
id := vars["id"]
|
||||||
secret := r.FormValue("secret")
|
secret := r.FormValue("secret")
|
||||||
u, err := url.Parse(r.FormValue("url"))
|
u, err := url.Parse(r.FormValue("url"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpsrv.WriteError(w, 400, "bad url")
|
httpsrv.WriteText(w, 400, "bad url")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
short := s.GetURL(id)
|
store, err := badgerhold.Open(s.options)
|
||||||
|
defer func() {
|
||||||
|
if err = store.Close(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if err != nil {
|
||||||
|
httpsrv.WriteText(w, 500, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if short == nil {
|
url := &shortURL{}
|
||||||
short = newshort(id, secret, u.String())
|
err = store.Get(id, url)
|
||||||
|
if err != nil && err != badgerhold.ErrNotFound {
|
||||||
|
httpsrv.WriteText(w, 500, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
s.PutURL(short.ID, short)
|
if err == badgerhold.ErrNotFound {
|
||||||
httpsrv.WriteObject(w, 200, short)
|
url = newShortURL(id, secret, u.String())
|
||||||
|
|
||||||
|
err := store.Insert(url.ID, url)
|
||||||
|
if err != nil {
|
||||||
|
httpsrv.WriteText(w, 500, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
httpsrv.WriteObject(w, 200, url)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,24 +134,27 @@ func (s *shortDB) putShort(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if secret != short.Secret {
|
if secret != url.Secret {
|
||||||
httpsrv.WriteError(w, 403, "forbidden")
|
httpsrv.WriteError(w, 403, "forbidden")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
short.URL = u.String()
|
err = store.Upsert(url.ID, url)
|
||||||
|
if err != nil {
|
||||||
|
httpsrv.WriteText(w, 500, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
s.PutURL(short.ID, short)
|
httpsrv.WriteObject(w, 200, url)
|
||||||
httpsrv.WriteObject(w, 200, short)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type shortURL struct {
|
type shortURL struct {
|
||||||
ID string
|
ID string `badgerhold:"unique"`
|
||||||
URL string
|
URL string
|
||||||
Secret string
|
Secret string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newshort(id, secret, u string) *shortURL {
|
func newShortURL(id, secret, u string) *shortURL {
|
||||||
m, err := regexp.MatchString("[a-z-]{1,64}", id)
|
m, err := regexp.MatchString("[a-z-]{1,64}", id)
|
||||||
if id == "" || !m || err != nil {
|
if id == "" || !m || err != nil {
|
||||||
id = uuid.V4()
|
id = uuid.V4()
|
||||||
@@ -138,162 +165,3 @@ func newshort(id, secret, u string) *shortURL {
|
|||||||
}
|
}
|
||||||
return &shortURL{ID: id, Secret: secret, URL: u}
|
return &shortURL{ID: id, Secret: secret, URL: u}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *shortURL) Bytes() []byte {
|
|
||||||
if s == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var w bytes.Buffer
|
|
||||||
json.NewEncoder(&w).Encode(*s)
|
|
||||||
return w.Bytes()
|
|
||||||
}
|
|
||||||
|
|
||||||
func URLFromBytes(b []byte) *shortURL {
|
|
||||||
if len(b) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
var s shortURL
|
|
||||||
json.Unmarshal(b, &s)
|
|
||||||
|
|
||||||
log.Debug(s)
|
|
||||||
return &s
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *shortDB) GetURL(id string) *shortURL {
|
|
||||||
db, err := bbolt.Open(s.path, 0666, nil)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("ShortURL: failed to open db at [%s]", s.path)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
defer db.Close()
|
|
||||||
|
|
||||||
var url *shortURL
|
|
||||||
|
|
||||||
err = db.View(func(tx *bbolt.Tx) error {
|
|
||||||
b := tx.Bucket([]byte(s.bucket))
|
|
||||||
v := b.Get([]byte(id))
|
|
||||||
|
|
||||||
url = URLFromBytes(v)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("ShortURL: failed to open db at [%s]", s.path)
|
|
||||||
}
|
|
||||||
return url
|
|
||||||
}
|
|
||||||
func (s *shortDB) PutURL(id string, url *shortURL) {
|
|
||||||
db, err := bbolt.Open(s.path, 0666, nil)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("ShortURL: failed to open db at [%s]", s.path)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer db.Close()
|
|
||||||
|
|
||||||
err = db.Update(func(tx *bbolt.Tx) error {
|
|
||||||
b := tx.Bucket([]byte(s.bucket))
|
|
||||||
return b.Put([]byte(id), url.Bytes())
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
log.Errorf("ShortURL: failed to write db at [%s]", s.path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *shortDB) getIdentity(w http.ResponseWriter, r *http.Request) {
|
|
||||||
vars := mux.Vars(r)
|
|
||||||
|
|
||||||
id := vars["id"]
|
|
||||||
|
|
||||||
useArmored := false
|
|
||||||
addr := ""
|
|
||||||
|
|
||||||
if isFingerprint(id) {
|
|
||||||
addr = "https://keys.openpgp.org/vks/v1/by-fingerprint/" + strings.ToUpper(id)
|
|
||||||
useArmored = true
|
|
||||||
} else if email, err := mail.ParseAddress(id); err == nil {
|
|
||||||
addr = getWKDPubKeyAddr(email)
|
|
||||||
useArmored = false
|
|
||||||
} else {
|
|
||||||
httpsrv.WriteError(w, 400, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := http.Get(addr)
|
|
||||||
if err != nil {
|
|
||||||
print(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
if resp.Header.Get("Content-Type") == "application/pgp-keys" {
|
|
||||||
useArmored = true
|
|
||||||
}
|
|
||||||
log.Infos("getIdentity", "id", id, "useArmored", useArmored, "status", resp.Status, "addr", addr)
|
|
||||||
|
|
||||||
var lis openpgp.EntityList
|
|
||||||
if useArmored {
|
|
||||||
lis, err = openpgp.ReadArmoredKeyRing(resp.Body)
|
|
||||||
} else {
|
|
||||||
lis, err = openpgp.ReadKeyRing(resp.Body)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
httpsrv.WriteError(w, 400, "bad decode")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, entity := range lis {
|
|
||||||
entityString(w, entity)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func isFingerprint(s string) bool {
|
|
||||||
for _, r := range s {
|
|
||||||
switch r {
|
|
||||||
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'A', 'B', 'C', 'D', 'E', 'F':
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func entityString(out io.Writer, e *openpgp.Entity) {
|
|
||||||
if e == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if e.Identities != nil {
|
|
||||||
fmt.Fprintln(out, "Identities:")
|
|
||||||
for name, identity := range e.Identities {
|
|
||||||
fmt.Fprintf(out, " %s:\n", name)
|
|
||||||
identityString(out, identity)
|
|
||||||
fmt.Fprintln(out)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func identityString(out io.Writer, i *openpgp.Identity) {
|
|
||||||
if i == nil || i.SelfSignature == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Fprintf(out, "name: %s\n", i.Name)
|
|
||||||
|
|
||||||
for key, valueList := range i.SelfSignature.NotationData {
|
|
||||||
for _, value := range valueList {
|
|
||||||
fmt.Fprintln(out, " ", key, value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getWKDPubKeyAddr(email *mail.Address) string {
|
|
||||||
parts := strings.SplitN(email.Address, "@", 2)
|
|
||||||
|
|
||||||
hash := sha1.Sum([]byte(parts[0]))
|
|
||||||
lp := zbase32.EncodeToString(hash[:])
|
|
||||||
|
|
||||||
return fmt.Sprintf("https://%s/.well-known/openpgpkey/hu/%s", parts[1], lp)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user