diff --git a/client/assets/icons/404.svg b/client/assets/icons/404.svg
deleted file mode 100644
index cf4f9b1a..00000000
--- a/client/assets/icons/404.svg
+++ /dev/null
@@ -1,3019 +0,0 @@
-
-
-
diff --git a/go.mod b/go.mod
index f55c7d21..7edd9693 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module github.com/mickael-kerjean/filestash
-go 1.13
+go 1.16
require (
github.com/aws/aws-sdk-go v1.40.41
diff --git a/server/ctrl/static.go b/server/ctrl/static.go
index 7be7488d..92e65a58 100644
--- a/server/ctrl/static.go
+++ b/server/ctrl/static.go
@@ -1,6 +1,7 @@
package ctrl
import (
+ _ "embed"
"fmt"
. "github.com/mickael-kerjean/filestash/server/common"
"io"
@@ -8,10 +9,14 @@ import (
URL "net/url"
"os"
"path/filepath"
+ "regexp"
"strings"
"text/template"
)
+//go:embed static/404.html
+var HtmlPage404 []byte
+
func StaticHandler(_path string) func(App, http.ResponseWriter, *http.Request) {
return func(ctx App, res http.ResponseWriter, req *http.Request) {
var base string = GetAbsolutePath(_path)
@@ -65,20 +70,40 @@ func IndexHandler(_path string) func(App, http.ResponseWriter, *http.Request) {
func NotFoundHandler(ctx App, res http.ResponseWriter, req *http.Request) {
res.WriteHeader(http.StatusNotFound)
- res.Write([]byte(Page(`
`)))
+ res.Write(HtmlPage404)
+}
+
+var listOfPlugins map[string][]string = map[string][]string{
+ "oss": []string{},
+ "enterprise": []string{},
+ "custom": []string{},
}
func AboutHandler(ctx App, res http.ResponseWriter, req *http.Request) {
t, _ := template.New("about").Parse(Page(`
{{index .App 0}}
- | Commit hash | {{ index .App 1}} |
+ | Commit hash | {{ index .App 1}} |
| Binary hash | {{ index .App 2}} |
| Config hash | {{ index .App 3}} |
+
+ | Plugins |
+
+ {{ $oss := (index .App 4) }}
+ {{ $enterprise := (index .App 5) }}
+ {{ $custom := (index .App 6) }}
+ STANDARD[{{ if eq $oss "" }}N/A{{ else }}{{ $oss }}{{ end }}]
+ EXTENDED[{{ if eq $enterprise "" }}N/A{{ else }}{{ $enterprise }}{{ end }}]
+ CUSTOM[{{ if eq $custom "" }}N/A{{ else }}{{ $custom }}{{ end }}]
+ |
+
+
`))
t.Execute(res, struct {
@@ -88,9 +113,43 @@ func AboutHandler(ctx App, res http.ResponseWriter, req *http.Request) {
BUILD_REF,
hashFileContent(filepath.Join(GetCurrentDir(), "/filestash"), 0),
hashFileContent(filepath.Join(GetCurrentDir(), CONFIG_PATH, "config.json"), 0),
+ strings.Join(listOfPlugins["oss"], " "),
+ strings.Join(listOfPlugins["enterprise"], " "),
+ strings.Join(listOfPlugins["custom"], " "),
}})
}
+func InitPluginList(code []byte) {
+ listOfPackages := regexp.MustCompile(`github.com/mickael-kerjean/([^\"]+)`).FindAllString(string(code), -1)
+ for _, packageName := range listOfPackages {
+ if packageName == "github.com/mickael-kerjean/filestash/server/common" {
+ continue
+ }
+
+ if strings.HasPrefix(packageName, "github.com/mickael-kerjean/filestash/server/plugin/") {
+ listOfPlugins["oss"] = append(
+ listOfPlugins["oss"],
+ strings.TrimPrefix(packageName, "github.com/mickael-kerjean/filestash/server/plugin/"),
+ )
+ } else if strings.HasPrefix(packageName, "github.com/mickael-kerjean/filestash/filestash-enterprise/plugins/") {
+ listOfPlugins["enterprise"] = append(
+ listOfPlugins["enterprise"],
+ strings.TrimPrefix(packageName, "github.com/mickael-kerjean/filestash/filestash-enterprise/plugins/"),
+ )
+ } else if strings.HasPrefix(packageName, "github.com/mickael-kerjean/filestash/filestash-enterprise/customers/") {
+ listOfPlugins["custom"] = append(
+ listOfPlugins["custom"],
+ strings.TrimPrefix(packageName, "github.com/mickael-kerjean/filestash/filestash-enterprise/customers/"),
+ )
+ } else {
+ listOfPlugins["custom"] = append(
+ listOfPlugins["custom"],
+ packageName,
+ )
+ }
+ }
+}
+
func CustomCssHandler(ctx App, res http.ResponseWriter, req *http.Request) {
res.Header().Set("Content-Type", "text/css")
io.WriteString(res, Config.Get("general.custom_css").String())
diff --git a/server/ctrl/static/404.html b/server/ctrl/static/404.html
new file mode 100644
index 00000000..3375f705
--- /dev/null
+++ b/server/ctrl/static/404.html
@@ -0,0 +1,214 @@
+
+
+
+
+
+404
+
+
+
diff --git a/server/main.go b/server/main.go
index 76fe9399..cde57897 100644
--- a/server/main.go
+++ b/server/main.go
@@ -1,6 +1,7 @@
package main
import (
+ _ "embed"
"fmt"
"github.com/gorilla/mux"
. "github.com/mickael-kerjean/filestash/server/common"
@@ -15,6 +16,9 @@ import (
"strconv"
)
+//go:embed plugin/index.go
+var EmbedPluginList []byte
+
func main() {
app := App{}
Init(&app)
@@ -125,6 +129,10 @@ func Init(a *App) {
Log.Warning("No starter plugin available")
return
}
+
+ go func() {
+ InitPluginList(EmbedPluginList)
+ }()
select {}
}
diff --git a/server/middleware/http.go b/server/middleware/http.go
index 52d363e2..bb989845 100644
--- a/server/middleware/http.go
+++ b/server/middleware/http.go
@@ -39,7 +39,8 @@ func IndexHeaders(fn func(App, http.ResponseWriter, *http.Request)) func(ctx App
cspHeader += "style-src 'self' 'unsafe-inline'; "
cspHeader += "font-src 'self' data:; "
cspHeader += "manifest-src 'self'; "
- cspHeader += "script-src 'self' 'sha256-JNAde5CZQqXtYRLUk8CGgyJXo6C7Zs1lXPPClLM1YM4=' 'sha256-9/gQeQaAmVkFStl6tfCbHXn8mr6PgtxlH+hEp685lzY=' 'sha256-ER9LZCe8unYk8AJJ2qopE+rFh7OUv8QG5q3h6jZeoSk='; "
+ cspHeader += "script-src 'self' 'sha256-JNAde5CZQqXtYRLUk8CGgyJXo6C7Zs1lXPPClLM1YM4=' 'sha256-9/gQeQaAmVkFStl6tfCbHXn8mr6PgtxlH+hEp685lzY=' 'sha256-ER9LZCe8unYk8AJJ2qopE+rFh7OUv8QG5q3h6jZeoSk='"
+ cspHeader += " 'sha256-a4rv66tC4bqKBcGxkR+KAqedm+64tAs13VGNGmN3B6g=' 'sha256-H+2cw33TxgqSZEshY66vGwg6/W03IB9JKTmFV36CKz0=';" // animated 404 static page
cspHeader += "img-src 'self' blob: data: https://maps.wikimedia.org; "
cspHeader += "connect-src 'self'; "
cspHeader += "object-src 'self'; "
diff --git a/vendor/modules.txt b/vendor/modules.txt
index b7dba2ee..74956cc1 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -1,6 +1,7 @@
# cloud.google.com/go v0.38.0
cloud.google.com/go/compute/metadata
# github.com/aws/aws-sdk-go v1.40.41
+## explicit
github.com/aws/aws-sdk-go/aws
github.com/aws/aws-sdk-go/aws/arn
github.com/aws/aws-sdk-go/aws/awserr
@@ -55,12 +56,15 @@ github.com/aws/aws-sdk-go/service/sts/stsiface
# github.com/creack/pty v1.1.9
github.com/creack/pty
# github.com/cretz/bine v0.1.0
+## explicit
github.com/cretz/bine/control
github.com/cretz/bine/process
github.com/cretz/bine/tor
github.com/cretz/bine/torutil
github.com/cretz/bine/torutil/ed25519
github.com/cretz/bine/torutil/ed25519/internal/edwards25519
+# github.com/crewjam/saml v0.4.6
+## explicit
# github.com/davecgh/go-spew v1.1.1
github.com/davecgh/go-spew/spew
# github.com/emirpasic/gods v1.12.0
@@ -71,6 +75,7 @@ github.com/emirpasic/gods/trees
github.com/emirpasic/gods/trees/binaryheap
github.com/emirpasic/gods/utils
# github.com/go-sql-driver/mysql v1.5.0
+## explicit
github.com/go-sql-driver/mysql
# github.com/golang/protobuf v1.3.1
github.com/golang/protobuf/proto
@@ -81,14 +86,18 @@ github.com/golang/protobuf/ptypes/timestamp
# github.com/googleapis/gax-go/v2 v2.0.5
github.com/googleapis/gax-go/v2
# github.com/gorilla/mux v1.7.3
+## explicit
github.com/gorilla/mux
# github.com/gorilla/websocket v1.4.1
+## explicit
github.com/gorilla/websocket
# github.com/h2non/bimg v1.1.5
+## explicit
github.com/h2non/bimg
# github.com/hashicorp/golang-lru v0.5.1
github.com/hashicorp/golang-lru/simplelru
# github.com/hirochachacha/go-smb2 v1.0.2
+## explicit
github.com/hirochachacha/go-smb2
github.com/hirochachacha/go-smb2/internal/crypto/ccm
github.com/hirochachacha/go-smb2/internal/crypto/cmac
@@ -107,26 +116,35 @@ github.com/kevinburke/ssh_config
# github.com/kr/fs v0.1.0
github.com/kr/fs
# github.com/kr/pty v1.1.8
+## explicit
github.com/kr/pty
# github.com/mattn/go-sqlite3 v2.0.2+incompatible
+## explicit
github.com/mattn/go-sqlite3
# github.com/mickael-kerjean/net v0.0.0-20191120063050-2457c043ba06
+## explicit
github.com/mickael-kerjean/net/webdav
github.com/mickael-kerjean/net/webdav/internal/xml
# github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/go-homedir
# github.com/mitchellh/hashstructure v1.0.0
+## explicit
github.com/mitchellh/hashstructure
# github.com/patrickmn/go-cache v2.1.0+incompatible
+## explicit
github.com/patrickmn/go-cache
# github.com/pkg/errors v0.9.1
github.com/pkg/errors
# github.com/pkg/sftp v1.11.0
+## explicit
github.com/pkg/sftp
# github.com/pmezard/go-difflib v1.0.0
github.com/pmezard/go-difflib/difflib
# github.com/prasad83/goftp v0.0.0-20210325080443-f57aaed46a32
+## explicit
github.com/prasad83/goftp
+# github.com/secsy/goftp v0.0.0-20200609142545-aa2de14babf4
+## explicit
# github.com/sergi/go-diff v1.0.0
github.com/sergi/go-diff/diffmatchpatch
# github.com/src-d/gcfg v1.4.0
@@ -135,14 +153,17 @@ github.com/src-d/gcfg/scanner
github.com/src-d/gcfg/token
github.com/src-d/gcfg/types
# github.com/stretchr/testify v1.7.0
+## explicit
github.com/stretchr/testify/assert
# github.com/tidwall/gjson v1.13.0
+## explicit
github.com/tidwall/gjson
# github.com/tidwall/match v1.1.1
github.com/tidwall/match
# github.com/tidwall/pretty v1.2.0
github.com/tidwall/pretty
# github.com/tidwall/sjson v1.0.4
+## explicit
github.com/tidwall/sjson
# github.com/xanzy/ssh-agent v0.2.1
github.com/xanzy/ssh-agent
@@ -164,6 +185,7 @@ go.opencensus.io/trace/internal
go.opencensus.io/trace/propagation
go.opencensus.io/trace/tracestate
# golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871
+## explicit
golang.org/x/crypto/acme
golang.org/x/crypto/acme/autocert
golang.org/x/crypto/bcrypt
@@ -189,9 +211,11 @@ golang.org/x/crypto/ssh/agent
golang.org/x/crypto/ssh/internal/bcrypt_pbkdf
golang.org/x/crypto/ssh/knownhosts
# golang.org/x/image v0.0.0-20210622092929-e6eecd499c2c
+## explicit
golang.org/x/image/draw
golang.org/x/image/math/f64
# golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2
+## explicit
golang.org/x/net/context
golang.org/x/net/context/ctxhttp
golang.org/x/net/http/httpguts
@@ -203,12 +227,14 @@ golang.org/x/net/internal/timeseries
golang.org/x/net/proxy
golang.org/x/net/trace
# golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
+## explicit
golang.org/x/oauth2
golang.org/x/oauth2/google
golang.org/x/oauth2/internal
golang.org/x/oauth2/jws
golang.org/x/oauth2/jwt
# golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
+## explicit
golang.org/x/sync/semaphore
# golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1
golang.org/x/sys/cpu
@@ -221,6 +247,7 @@ golang.org/x/text/transform
golang.org/x/text/unicode/bidi
golang.org/x/text/unicode/norm
# google.golang.org/api v0.15.0
+## explicit
google.golang.org/api/drive/v3
google.golang.org/api/googleapi
google.golang.org/api/googleapi/transport
@@ -277,12 +304,17 @@ google.golang.org/grpc/stats
google.golang.org/grpc/status
google.golang.org/grpc/tap
# gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc
+## explicit
gopkg.in/alexcesaro/quotedprintable.v3
# gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d
gopkg.in/asn1-ber.v1
# gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
+## explicit
gopkg.in/gomail.v2
+# gopkg.in/ldap.v2 v2.5.1
+## explicit
# gopkg.in/ldap.v3 v3.1.0
+## explicit
gopkg.in/ldap.v3
# gopkg.in/src-d/go-billy.v4 v4.3.2
gopkg.in/src-d/go-billy.v4
@@ -291,6 +323,7 @@ gopkg.in/src-d/go-billy.v4/helper/polyfill
gopkg.in/src-d/go-billy.v4/osfs
gopkg.in/src-d/go-billy.v4/util
# gopkg.in/src-d/go-git.v4 v4.13.1
+## explicit
gopkg.in/src-d/go-git.v4
gopkg.in/src-d/go-git.v4/config
gopkg.in/src-d/go-git.v4/internal/revision