Use interface-based MakyuuIchaival
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DataHoarder 2022-06-04 20:02:29 +02:00
parent d3b5f5ac01
commit 74f619319e
4 changed files with 15 additions and 15 deletions

View file

@ -5,7 +5,7 @@ name: default
steps:
- name: backend
image: golang:1.18-rc-bullseye
image: golang:1.18-bullseye
commands:
- GOAMD64=v2 go build -v -o orbeat .

View file

@ -166,7 +166,7 @@ func GetMimeTypeFromExtension(ext string) string {
return "application/octet-stream"
}
func handleQueryRequest(ctx *httputils.RequestContext, identifier cid.Cid, extraArguments []string) {
func handleQueryRequest(ctx httputils.RequestContext, identifier cid.Cid, extraArguments []string) {
cTime := time.Now()
var cacheEntry = tryGetCacheEntryForIdentifier(identifier)
@ -242,7 +242,7 @@ func handleQueryRequest(ctx *httputils.RequestContext, identifier cid.Cid, extra
ctx.ServeFile(cacheEntry.Entry.Path)
}
func setOtherHeaders(ctx *httputils.RequestContext) {
func setOtherHeaders(ctx httputils.RequestContext) {
ctx.SetResponseHeader("Server", "OrbitalBeat")
ctx.SetResponseHeader("Vary", "Content-Encoding")
ctx.SetResponseHeader("X-Content-Type-Options", "nosniff")
@ -252,7 +252,7 @@ func setOtherHeaders(ctx *httputils.RequestContext) {
ctx.SetResponseHeader(k, v)
}
}
func setCORSHeaders(ctx *httputils.RequestContext) {
func setCORSHeaders(ctx httputils.RequestContext) {
ctx.SetResponseHeader("Access-Control-Allow-Credentials", "true")
ctx.SetResponseHeader("Access-Control-Max-Age", "7200") //Firefox caps this to 86400, Chrome to 7200. Default is 5 seconds (!!!)
ctx.SetResponseHeader("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS")
@ -327,14 +327,14 @@ func IsTrustedPublicKey(key ed25519.PublicKey) bool {
return false
}
func handle(ctx *httputils.RequestContext) {
func handle(ctx httputils.RequestContext) {
if len(ctx.GetRequestHeader("Host")) > 0 && ctx.GetRequestHeader("Host") == ctx.GetTLSServerName() { //Prevents rebinding / DNS stuff
ctx.SetResponseCode(http.StatusNotFound)
return
}
cTime := time.Now()
if ctx.IsFastHttp() {
if _, ok := ctx.(*httputils.FastHTTPContext); ok {
ctx.AddTiming("c", "Connection", ctx.GetRequestTime().Sub(ctx.GetConnectionTime()))
}
ctx.AddTiming("r", "Request Handler", cTime.Sub(ctx.GetRequestTime()))

6
go.mod
View file

@ -3,7 +3,7 @@ module git.gammaspectra.live/S.O.N.G/OrbitalBeat
go 1.18
require (
git.gammaspectra.live/S.O.N.G/MakyuuIchaival v0.0.0-20220531073006-dc0db04fcaac
git.gammaspectra.live/S.O.N.G/MakyuuIchaival v0.0.0-20220604175317-0feb1f4f31ae
github.com/cloudflare/circl v1.1.0
github.com/ipfs/go-cid v0.2.0
github.com/lib/pq v1.10.6
@ -16,7 +16,7 @@ require (
github.com/dgrr/http2 v0.3.5 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
github.com/klauspost/compress v1.15.5 // indirect
github.com/klauspost/compress v1.15.6 // indirect
github.com/klauspost/cpuid/v2 v2.0.12 // indirect
github.com/lucas-clemente/quic-go v0.27.1 // indirect
github.com/marten-seemann/qpack v0.2.1 // indirect
@ -38,7 +38,7 @@ require (
github.com/valyala/fastrand v1.1.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/net v0.0.0-20220526153639-5463443f8c37 // indirect
golang.org/x/net v0.0.0-20220531201128-c960675eff93 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.10 // indirect

12
go.sum
View file

@ -7,8 +7,8 @@ dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBr
dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4=
dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU=
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
git.gammaspectra.live/S.O.N.G/MakyuuIchaival v0.0.0-20220531073006-dc0db04fcaac h1:wAXYrT17ver91I1LPHr1e8sTSgmbISkiEPRGAfA5tsU=
git.gammaspectra.live/S.O.N.G/MakyuuIchaival v0.0.0-20220531073006-dc0db04fcaac/go.mod h1:h0vDSQpfuNGOclNiJ4ircFrmPwTzxgZU5+SyPo763GY=
git.gammaspectra.live/S.O.N.G/MakyuuIchaival v0.0.0-20220604175317-0feb1f4f31ae h1:b+txwYGXmIyqtyCLgXNnZqpnakngKBGJPgFcqkhVOO8=
git.gammaspectra.live/S.O.N.G/MakyuuIchaival v0.0.0-20220604175317-0feb1f4f31ae/go.mod h1:7Ph6dqDRHnU6JR8idBqu7MJKu7Gs6vpMlo/sB4ziNdg=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
@ -83,8 +83,8 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.5 h1:qyCLMz2JCrKADihKOh9FxnW3houKeNsp2h5OEz0QSEA=
github.com/klauspost/compress v1.15.5/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/klauspost/compress v1.15.6 h1:6D9PcO8QWu0JyaQ2zUMmu16T1T+zjjEpP91guRsvDfY=
github.com/klauspost/compress v1.15.6/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.0.12 h1:p9dKCg8i4gmOxtv35DvrYoWqYzQrvEVdjQ762Y0OqZE=
@ -245,8 +245,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220526153639-5463443f8c37 h1:lUkvobShwKsOesNfWWlCS5q7fnbG1MEliIzwu886fn8=
golang.org/x/net v0.0.0-20220526153639-5463443f8c37/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.0.0-20220531201128-c960675eff93 h1:MYimHLfoXEpOhqd/zgoA/uoXzHB86AEky4LAx5ij9xA=
golang.org/x/net v0.0.0-20220531201128-c960675eff93/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=