diff --git a/.github/workflows/buildx.yaml b/.github/workflows/buildx.yaml index 50e8601..1938731 100644 --- a/.github/workflows/buildx.yaml +++ b/.github/workflows/buildx.yaml @@ -27,7 +27,7 @@ jobs: --build-arg VERSION=${VERSION} \ --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ --build-arg VCS_REF=${GITHUB_SHA::8} \ - ${TAGS} --file ./test/Dockerfile ./test + ${TAGS} --file Dockerfile . - name: Set up Docker Buildx uses: crazy-max/ghaction-docker-buildx@v3 diff --git a/Dockerfile b/Dockerfile index b5a73bf..e9d61f2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,11 +18,11 @@ ENV SSL_CERT_FILE /etc/ssl/cert.pem COPY static /go/src/github.com/andreimarcu/linx-server/static/ COPY templates /go/src/github.com/andreimarcu/linx-server/templates/ -RUN mkdir -p /data/files && mkdir -p /data/meta && chown -R 65534:65534 /data +RUN mkdir -p /data/files && mkdir -p /data/meta && mkdir -p /data/locks && chown -R 65534:65534 /data -VOLUME ["/data/files", "/data/meta"] +VOLUME ["/data/files", "/data/meta", "/data/locks"] EXPOSE 8080 USER nobody -ENTRYPOINT ["/usr/local/bin/linx-server", "-bind=0.0.0.0:8080", "-filespath=/data/files/", "-metapath=/data/meta/"] +ENTRYPOINT ["/usr/local/bin/linx-server", "-bind=0.0.0.0:8080", "-filespath=/data/files/", "-metapath=/data/meta/", "-lockspath=/data/locks/"] CMD ["-sitename=linx", "-allowhotlink"] diff --git a/README.md b/README.md index ed90db5..6f3b615 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,30 @@ - linx-server ====== -[](https://travis-ci.org/andreimarcu/linx-server) Self-hosted file/media sharing website. +### Is this still active? + +Yes, though the repo may be old, it's still active and I'll try and fix any major issues that occur with my limited time. + ### Demo -You can see what it looks like using the demo: [https://demo.linx-server.net/](https://demo.linx-server.net/) +You can see what it looks like using the demo: [https://put.icu/](https://put.icu/) + + +### Clients +**Official** +- CLI: **linx-client** - [Source](https://github.com/andreimarcu/linx-client) + +**Unofficial** +- Android: **LinxShare** - [Source](https://github.com/iksteen/LinxShare/) | [Google Play](https://play.google.com/store/apps/details?id=org.thegraveyard.linxshare) +- CLI: **golinx** - [Source](https://github.com/mutantmonkey/golinx) ### Features - Display common filetypes (image, video, audio, markdown, pdf) - Display syntax-highlighted code with in-place editing -- Documented API with keys if need to restrict uploads (can use [linx-client](https://github.com/andreimarcu/linx-client) for uploading through command-line) +- Documented API with keys for restricting uploads - Torrent download of files using web seeding - File expiry, deletion key, file access key, and random filename options @@ -45,7 +56,6 @@ services: linx-server: container_name: linx-server image: andreimarcu/linx-server - entrypoint: /usr/local/bin/linx-server command: -config /data/linx-server.conf volumes: - /path/to/files:/data/files @@ -60,8 +70,8 @@ Ideally, you would use a reverse proxy such as nginx or caddy to handle TLS cert #### Using a binary release -1. Grab the latest binary from the [releases](https://github.com/andreimarcu/linx-server/releases) -2. Run ```./linx-server``` +1. Grab the latest binary from the [releases](https://github.com/andreimarcu/linx-server/releases), then run ```go install``` +2. Run ```linx-server -config path/to/linx-server.conf``` Usage @@ -98,6 +108,11 @@ maxexpiry = 86400 | ```nologs = true``` | (optionally) disable request logs in stdout | ```force-random-filename = true``` | (optionally) force the use of random filenames | ```custompagespath = custom_pages/``` | (optionally) specify path to directory containing markdown pages (must end in .md) that will be added to the site navigation (this can be useful for providing contact/support information and so on). For example, custom_pages/My_Page.md will become My Page in the site navigation +| ```extra-footer-text = "..."``` | (optionally) Extra text above the footer for notices. +| ```max-duration-time = 0``` | Time till expiry for files over max-duration-size. (Default is 0 for no-expiry.) +| ```max-duration-size = 4294967296``` | Size of file before max-duration-time is used to determine expiry max time. (Default is 4GB) +| ```disable-access-key = true``` | Disables access key usage. (Default is false.) +| ```default-random-filename = true``` | Makes it so the random filename is not default if set false. (Default is true.) #### Cleaning up expired files diff --git a/backends/localfs/localfs.go b/backends/localfs/localfs.go index aaf487f..9a72891 100644 --- a/backends/localfs/localfs.go +++ b/backends/localfs/localfs.go @@ -2,6 +2,7 @@ package localfs import ( "encoding/json" + "errors" "io" "io/ioutil" "net/http" @@ -16,6 +17,7 @@ import ( type LocalfsBackend struct { metaPath string filesPath string + locksPath string } type MetadataJSON struct { @@ -25,6 +27,7 @@ type MetadataJSON struct { Mimetype string `json:"mimetype"` Size int64 `json:"size"` Expiry int64 `json:"expiry"` + SrcIp string `json:"srcip,omitempty"` ArchiveFiles []string `json:"archive_files,omitempty"` } @@ -106,6 +109,8 @@ func (b LocalfsBackend) writeMetadata(key string, metadata backends.Metadata) er Sha256sum: metadata.Sha256sum, Expiry: metadata.Expiry.Unix(), Size: metadata.Size, + SrcIp: metadata.SrcIp, + } dst, err := os.Create(metaPath) @@ -124,7 +129,42 @@ func (b LocalfsBackend) writeMetadata(key string, metadata backends.Metadata) er return nil } -func (b LocalfsBackend) Put(key string, r io.Reader, expiry time.Time, deleteKey, accessKey string) (m backends.Metadata, err error) { +func (b LocalfsBackend) Lock(filename string) (err error) { + lockPath := path.Join(b.locksPath, filename) + + lock, err := os.Create(lockPath) + if err != nil { + return err + } + + lock.Close() + return +} + +func (b LocalfsBackend) Unlock(filename string) (err error) { + lockPath := path.Join(b.locksPath, filename) + + err = os.Remove(lockPath) + if err != nil { + return err + } + + return +} + +func (b LocalfsBackend) CheckLock(filename string) (locked bool, err error) { + lockPath := path.Join(b.locksPath, filename) + + if _, err := os.Stat(lockPath); errors.Is(err, os.ErrNotExist) { + return false, nil + } else { + return true, nil + } + + return false, err +} + +func (b LocalfsBackend) Put(key string, r io.Reader, expiry time.Time, deleteKey, accessKey string, srcIp string) (m backends.Metadata, err error) { filePath := path.Join(b.filesPath, key) dst, err := os.Create(filePath) @@ -153,6 +193,7 @@ func (b LocalfsBackend) Put(key string, r io.Reader, expiry time.Time, deleteKey m.Expiry = expiry m.DeleteKey = deleteKey m.AccessKey = accessKey + m.SrcIp = srcIp m.ArchiveFiles, _ = helpers.ListArchiveFiles(m.Mimetype, m.Size, dst) err = b.writeMetadata(key, m) @@ -197,9 +238,10 @@ func (b LocalfsBackend) List() ([]string, error) { return output, nil } -func NewLocalfsBackend(metaPath string, filesPath string) LocalfsBackend { +func NewLocalfsBackend(metaPath string, filesPath string, locksPath string) LocalfsBackend { return LocalfsBackend{ metaPath: metaPath, filesPath: filesPath, + locksPath: locksPath, } } diff --git a/backends/meta.go b/backends/meta.go index b22276e..1c5868a 100644 --- a/backends/meta.go +++ b/backends/meta.go @@ -12,6 +12,7 @@ type Metadata struct { Mimetype string Size int64 Expiry time.Time + SrcIp string ArchiveFiles []string } diff --git a/backends/s3/s3.go b/backends/s3/s3.go index a558779..17f6725 100644 --- a/backends/s3/s3.go +++ b/backends/s3/s3.go @@ -3,6 +3,7 @@ package s3 import ( "io" "io/ioutil" + "log" "net/http" "os" "strconv" @@ -125,6 +126,7 @@ func mapMetadata(m backends.Metadata) map[string]*string { "Mimetype": aws.String(m.Mimetype), "Sha256sum": aws.String(m.Sha256sum), "AccessKey": aws.String(m.AccessKey), + "SrcIp": aws.String(m.SrcIp), } } @@ -155,7 +157,22 @@ func unmapMetadata(input map[string]*string) (m backends.Metadata, err error) { return } -func (b S3Backend) Put(key string, r io.Reader, expiry time.Time, deleteKey, accessKey string) (m backends.Metadata, err error) { +func (b S3Backend) Lock(filename string) (err error) { + log.Printf("Locking is not supported on S3") + return +} + +func (b S3Backend) Unlock(filename string) (err error) { + log.Printf("Locking is not supported on S3") + return +} + +func (b S3Backend) CheckLock(filename string) (locked bool, err error) { + log.Printf("Locking is not supported on S3") + return +} + +func (b S3Backend) Put(key string, r io.Reader, expiry time.Time, deleteKey, accessKey string, srcIp string) (m backends.Metadata, err error) { tmpDst, err := ioutil.TempFile("", "linx-server-upload") if err != nil { return m, err diff --git a/backends/storage.go b/backends/storage.go index 864d0a1..02e2a57 100644 --- a/backends/storage.go +++ b/backends/storage.go @@ -12,7 +12,10 @@ type StorageBackend interface { Exists(key string) (bool, error) Head(key string) (Metadata, error) Get(key string) (Metadata, io.ReadCloser, error) - Put(key string, r io.Reader, expiry time.Time, deleteKey, accessKey string) (Metadata, error) + Lock(filename string) (error) + Unlock(filename string) (error) + CheckLock(filename string) (bool, error) + Put(key string, r io.Reader, expiry time.Time, deleteKey, accessKey string, srcIp string) (Metadata, error) PutMetadata(key string, m Metadata) error ServeFile(key string, w http.ResponseWriter, r *http.Request) error Size(key string) (int64, error) diff --git a/cleanup/cleanup.go b/cleanup/cleanup.go index 5920c22..97789d5 100644 --- a/cleanup/cleanup.go +++ b/cleanup/cleanup.go @@ -8,8 +8,8 @@ import ( "github.com/andreimarcu/linx-server/expiry" ) -func Cleanup(filesDir string, metaDir string, noLogs bool) { - fileBackend := localfs.NewLocalfsBackend(metaDir, filesDir) +func Cleanup(filesDir string, metaDir string, locksDir string, noLogs bool) { + fileBackend := localfs.NewLocalfsBackend(metaDir, filesDir, locksDir) files, err := fileBackend.List() if err != nil { @@ -17,6 +17,15 @@ func Cleanup(filesDir string, metaDir string, noLogs bool) { } for _, filename := range files { + locked, err := fileBackend.CheckLock(filename) + if err != nil { + log.Printf("Error checking if %s is locked: %s", filename, err) + } + if locked { + log.Printf("%s is locked, it will be ignored", filename) + continue + } + metadata, err := fileBackend.Head(filename) if err != nil { if !noLogs { @@ -33,10 +42,12 @@ func Cleanup(filesDir string, metaDir string, noLogs bool) { } } -func PeriodicCleanup(minutes time.Duration, filesDir string, metaDir string, noLogs bool) { +func PeriodicCleanup(minutes time.Duration, filesDir string, metaDir string, locksDir string, noLogs bool) { c := time.Tick(minutes) for range c { - Cleanup(filesDir, metaDir, noLogs) + log.Printf("Running periodic cleanup") + Cleanup(filesDir, metaDir, locksDir, noLogs) + log.Printf("Finished periodic cleanup") } } diff --git a/csp_test.go b/csp_test.go index e3dbbdd..b996594 100644 --- a/csp_test.go +++ b/csp_test.go @@ -20,6 +20,7 @@ func TestContentSecurityPolicy(t *testing.T) { Config.siteURL = "http://linx.example.org/" Config.filesDir = path.Join(os.TempDir(), generateBarename()) Config.metaDir = Config.filesDir + "_meta" + Config.locksDir = Config.filesDir + "_locks" Config.maxSize = 1024 * 1024 * 1024 Config.noLogs = true Config.siteName = "linx" diff --git a/delete.go b/delete.go index 38e36e3..3f8e429 100644 --- a/delete.go +++ b/delete.go @@ -10,9 +10,13 @@ import ( func deleteHandler(c web.C, w http.ResponseWriter, r *http.Request) { requestKey := r.Header.Get("Linx-Delete-Key") - + + if len(r.URL.Query().Get("linx-delete-key")) > 0 { + requestKey = r.URL.Query().Get("linx-delete-key") + } + filename := c.URLParams["name"] - + // Ensure that file exists and delete key is correct metadata, err := storageBackend.Head(filename) if err == backends.NotFoundErr { diff --git a/expiry.go b/expiry.go index 63b7757..f17f7cd 100644 --- a/expiry.go +++ b/expiry.go @@ -11,6 +11,10 @@ var defaultExpiryList = []uint64{ 60, 300, 3600, + 7200, + 14400, + 28800, + 43200, 86400, 604800, 2419200, diff --git a/go.mod b/go.mod index f433699..434e9c6 100644 --- a/go.mod +++ b/go.mod @@ -1,19 +1,33 @@ module github.com/andreimarcu/linx-server -go 1.14 +go 1.21 + +toolchain go1.22.4 require ( - github.com/GeertJohan/go.rice v1.0.0 - github.com/aws/aws-sdk-go v1.29.19 - github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5 - github.com/dustin/go-humanize v1.0.0 - github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4 - github.com/gabriel-vasile/mimetype v1.1.1 - github.com/microcosm-cc/bluemonday v1.0.2 - github.com/minio/sha256-simd v0.1.1 - github.com/russross/blackfriday v1.5.1 + github.com/GeertJohan/go.rice v1.0.3 + github.com/aws/aws-sdk-go v1.54.9 + github.com/dchest/uniuri v1.2.0 + github.com/dustin/go-humanize v1.0.1 + github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3 + github.com/gabriel-vasile/mimetype v1.4.4 + github.com/microcosm-cc/bluemonday v1.0.26 + github.com/minio/sha256-simd v1.0.1 + github.com/russross/blackfriday v1.6.0 github.com/vharitonsky/iniflags v0.0.0-20180513140207-a33cd0b5f3de github.com/zeebo/bencode v1.0.0 - github.com/zenazn/goji v0.9.0 - golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 + github.com/zenazn/goji v1.0.1 + golang.org/x/crypto v0.24.0 +) + +require ( + github.com/aymerick/douceur v0.2.0 // indirect + github.com/daaku/go.zipexe v1.0.2 // indirect + github.com/gorilla/css v1.0.1 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/klauspost/cpuid/v2 v2.2.8 // indirect + github.com/kr/text v0.2.0 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sys v0.21.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) diff --git a/go.sum b/go.sum index 99d63bf..d82e16a 100644 --- a/go.sum +++ b/go.sum @@ -1,76 +1,69 @@ github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= -github.com/GeertJohan/go.rice v1.0.0 h1:KkI6O9uMaQU3VEKaj01ulavtF7o1fWT7+pk/4voiMLQ= -github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0= +github.com/GeertJohan/go.rice v1.0.3 h1:k5viR+xGtIhF61125vCE1cmJ5957RQGXG6dmbaWZSmI= +github.com/GeertJohan/go.rice v1.0.3/go.mod h1:XVdrU4pW00M4ikZed5q56tPf1v2KwnIKeIdc9CBYNt4= github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= -github.com/aws/aws-sdk-go v1.29.19 h1:+jifYixffn6kzWygtGWFWQMv0tDGyISZHNwugF9V2sE= -github.com/aws/aws-sdk-go v1.29.19/go.mod h1:1KvfttTE3SPKMpo8g2c6jL3ZKfXtFvKscTgahTma5Xg= -github.com/daaku/go.zipexe v1.0.0 h1:VSOgZtH418pH9L16hC/JrgSNJbbAL26pj7lmD1+CGdY= -github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E= +github.com/aws/aws-sdk-go v1.54.9 h1:e0Czh9AhrCVPuyaIUnibYmih3cYexJKlqlHSJ2eMKbI= +github.com/aws/aws-sdk-go v1.54.9/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= +github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= +github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/daaku/go.zipexe v1.0.2 h1:Zg55YLYTr7M9wjKn8SY/WcpuuEi+kR2u4E8RhvpyXmk= +github.com/daaku/go.zipexe v1.0.2/go.mod h1:5xWogtqlYnfBXkSB1o9xysukNP9GTvaNkqzUZbt3Bw8= 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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5 h1:RAV05c0xOkJ3dZGS0JFybxFKZ2WMLabgx3uXnd7rpGs= -github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5/go.mod h1:GgB8SF9nRG+GqaDtLcwJZsQFhcogVCJ79j4EdT0c2V4= -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/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4 h1:GY1+t5Dr9OKADM64SYnQjw/w99HMYvQ0A8/JoUkxVmc= -github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA= -github.com/gabriel-vasile/mimetype v1.1.1 h1:qbN9MPuRf3bstHu9zkI9jDWNfH//9+9kHxr9oRBBBOA= -github.com/gabriel-vasile/mimetype v1.1.1/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To= -github.com/go-check/check v0.0.0-20180628173108-788fd7840127 h1:0gkP6mzaMqkmpcJYCFOLkIBwI7xFExG03bbkOkCvUPI= -github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= -github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/dchest/uniuri v1.2.0 h1:koIcOUdrTIivZgSLhHQvKgqdWZq5d7KdMEWF1Ud6+5g= +github.com/dchest/uniuri v1.2.0/go.mod h1:fSzm4SLHzNZvWLvWJew423PhAzkpNQYq+uNLq4kxhkY= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3 h1:fmFk0Wt3bBxxwZnu48jqMdaOR/IZ4vdtJFuaFV8MpIE= +github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3/go.mod h1:bJWSKrZyQvfTnb2OudyUjurSG4/edverV7n82+K3JiM= +github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I= +github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s= +github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8= +github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5 h1:rhqTjzJlm7EbkELJDKMTU7udov+Se0xZkWmugr6zGok= -github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= -github.com/juju/loggo v0.0.0-20180524022052-584905176618 h1:MK144iBQF9hTSwBW/9eJm034bVoG30IshVm688T2hi8= -github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= -github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073 h1:WQM1NildKThwdP7qWrNAFGzp4ijNLw8RlgENkaI4MJs= -github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= +github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= -github.com/microcosm-cc/bluemonday v1.0.2 h1:5lPfLTTAvAbtS0VqT+94yOtFnGfUWYyx0+iToC3Os3s= -github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= -github.com/minio/sha256-simd v0.1.1 h1:5QHSlgo3nt5yKOJrC7W8w7X+NFl8cMPZm96iu8kKUJU= -github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= -github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/microcosm-cc/bluemonday v1.0.26 h1:xbqSvqzQMeEHCqMi64VAs4d8uy6Mequs3rQ0k/Khz58= +github.com/microcosm-cc/bluemonday v1.0.26/go.mod h1:JyzOCs9gkyQyjs+6h10UEVSe02CGwkhd72Xdqh78TWs= +github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= +github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nkovacs/streamquote v1.0.0/go.mod h1:BN+NaZ2CmdKqUuTUXUEm9j95B2TRbpOWpxbJYzzgUsc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/russross/blackfriday v1.5.1 h1:B8ZN6pD4PVofmlDCDUdELeYrbsVIDM/bpjW3v3zgcRc= -github.com/russross/blackfriday v1.5.1/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= +github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/vharitonsky/iniflags v0.0.0-20180513140207-a33cd0b5f3de h1:fkw+7JkxF3U1GzQoX9h69Wvtvxajo5Rbzy6+YMMzPIg= github.com/vharitonsky/iniflags v0.0.0-20180513140207-a33cd0b5f3de/go.mod h1:irMhzlTz8+fVFj6CH2AN2i+WI5S6wWFtK3MBCIxIpyI= github.com/zeebo/bencode v1.0.0 h1:zgop0Wu1nu4IexAZeCZ5qbsjU4O1vMrfCrVgUjbHVuA= github.com/zeebo/bencode v1.0.0/go.mod h1:Ct7CkrWIQuLWAy9M3atFHYq4kG9Ao/SsY5cdtCXmp9Y= -github.com/zenazn/goji v0.9.0 h1:RSQQAbXGArQ0dIDEq+PI6WqN6if+5KHu6x2Cx/GXLTQ= -github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM= -golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +github.com/zenazn/goji v1.0.1 h1:4lbD8Mx2h7IvloP7r2C0D6ltZP6Ufip8Hn0wmSK5LR8= +github.com/zenazn/goji v1.0.1/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= +golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce h1:xcEWjVhvbDy+nHP67nPDDpbYrY+ILlfndk4bRioVHaU= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/linx-cleanup/linx-cleanup.go b/linx-cleanup/linx-cleanup.go index 13b3ef1..08d8363 100644 --- a/linx-cleanup/linx-cleanup.go +++ b/linx-cleanup/linx-cleanup.go @@ -9,15 +9,18 @@ import ( func main() { var filesDir string var metaDir string + var locksDir string var noLogs bool flag.StringVar(&filesDir, "filespath", "files/", "path to files directory") flag.StringVar(&metaDir, "metapath", "meta/", "path to metadata directory") + flag.StringVar(&locksDir, "lockspath", "locks/", + "path to locks directory") flag.BoolVar(&noLogs, "nologs", false, "don't log deleted files") flag.Parse() - cleanup.Cleanup(filesDir, metaDir, noLogs) + cleanup.Cleanup(filesDir, metaDir, locksDir, noLogs) } diff --git a/metalog.sh b/metalog.sh new file mode 100755 index 0000000..9c05b88 --- /dev/null +++ b/metalog.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# For setting up cron with a logging function for metadata only. +# Add to crontab with "crontab -e" +# Paste "*/1 * * * * /path/to/metalog.sh /path/to/meta/source/ /path/to/meta-log" +# Change it to source and log directory paths. +# The slash after source/ is important. It means everyhitng *inside* the source directory. +rsync -a ${1} ${2} \ No newline at end of file diff --git a/pages.go b/pages.go index ae8de42..6492651 100644 --- a/pages.go +++ b/pages.go @@ -21,9 +21,10 @@ const ( func indexHandler(c web.C, w http.ResponseWriter, r *http.Request) { err := renderTemplate(Templates["index.html"], pongo2.Context{ - "maxsize": Config.maxSize, - "expirylist": listExpirationTimes(), - "forcerandom": Config.forceRandomFilename, + "maxsize": Config.maxSize, + "expirylist": listExpirationTimes(), + "expirydefault": Config.defaultExpiry, + "forcerandom": Config.forceRandomFilename, }, r, w) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -32,8 +33,9 @@ func indexHandler(c web.C, w http.ResponseWriter, r *http.Request) { func pasteHandler(c web.C, w http.ResponseWriter, r *http.Request) { err := renderTemplate(Templates["paste.html"], pongo2.Context{ - "expirylist": listExpirationTimes(), - "forcerandom": Config.forceRandomFilename, + "expirylist": listExpirationTimes(), + "expirydefault": Config.defaultExpiry, + "forcerandom": Config.forceRandomFilename, }, r, w) if err != nil { oopsHandler(c, w, r, RespHTML, "") diff --git a/put.icu.sxcu b/put.icu.sxcu new file mode 100644 index 0000000..79bd301 --- /dev/null +++ b/put.icu.sxcu @@ -0,0 +1,14 @@ +{ + "Version": "13.1.0", + "DestinationType": "ImageUploader, TextUploader, FileUploader", + "RequestMethod": "PUT", + "RequestURL": "https://put.icu/upload/", + "Headers": { + "Accept": "application/json", + "Linx-Delete-Key": null, + "Linx-Access-Key": null + }, + "Body": "Binary", + "URL": "$json:url$", + "DeletionURL": "https://put.icu/delete/$json:filename$?linx-delete-key=$json:delete_key$" +} \ No newline at end of file diff --git a/server.go b/server.go index 4d06db9..ec66f75 100644 --- a/server.go +++ b/server.go @@ -43,6 +43,7 @@ var Config struct { bind string filesDir string metaDir string + locksDir string siteName string siteURL string sitePath string @@ -56,6 +57,7 @@ var Config struct { xFrameOptions string maxSize int64 maxExpiry uint64 + defaultExpiry uint64 realIp bool noLogs bool allowHotlink bool @@ -74,6 +76,11 @@ var Config struct { accessKeyCookieExpiry uint64 customPagesDir string cleanupEveryMinutes uint64 + extraFooterText string + maxDurationTime uint64 + maxDurationSize int64 + disableAccessKey bool + defaultRandomFilename bool } var Templates = make(map[string]*pongo2.Template) @@ -131,6 +138,11 @@ func setup() *web.Mux { log.Fatal("Could not create metadata directory:", err) } + err = os.MkdirAll(Config.locksDir, 0755) + if err != nil { + log.Fatal("Could not create locks directory:", err) + } + if Config.siteURL != "" { // ensure siteURL ends wth '/' if lastChar := Config.siteURL[len(Config.siteURL)-1:]; lastChar != "/" { @@ -155,9 +167,9 @@ func setup() *web.Mux { if Config.s3Bucket != "" { storageBackend = s3.NewS3Backend(Config.s3Bucket, Config.s3Region, Config.s3Endpoint, Config.s3ForcePathStyle) } else { - storageBackend = localfs.NewLocalfsBackend(Config.metaDir, Config.filesDir) + storageBackend = localfs.NewLocalfsBackend(Config.metaDir, Config.filesDir, Config.locksDir) if Config.cleanupEveryMinutes > 0 { - go cleanup.PeriodicCleanup(time.Duration(Config.cleanupEveryMinutes)*time.Minute, Config.filesDir, Config.metaDir, Config.noLogs) + go cleanup.PeriodicCleanup(time.Duration(Config.cleanupEveryMinutes)*time.Minute, Config.filesDir, Config.metaDir, Config.locksDir, Config.noLogs) } } @@ -211,7 +223,9 @@ func setup() *web.Mux { mux.Put(Config.sitePath+"upload/:name", uploadPutHandler) mux.Delete(Config.sitePath+":name", deleteHandler) - + // Adding new delete path method to make linx-server usable with ShareX. + mux.Get(Config.sitePath+"delete/:name", deleteHandler) + mux.Get(Config.sitePath+"static/*", staticHandler) mux.Get(Config.sitePath+"favicon.ico", staticHandler) mux.Get(Config.sitePath+"robots.txt", staticHandler) @@ -241,6 +255,8 @@ func main() { "path to files directory") flag.StringVar(&Config.metaDir, "metapath", "meta/", "path to metadata directory") + flag.StringVar(&Config.locksDir, "lockspath", "locks/", + "path to locks directory") flag.BoolVar(&Config.basicAuth, "basicauth", false, "allow logging by basic auth password") flag.BoolVar(&Config.noLogs, "nologs", false, @@ -257,6 +273,8 @@ func main() { "maximum upload file size in bytes (default 4GB)") flag.Uint64Var(&Config.maxExpiry, "maxexpiry", 0, "maximum expiration time in seconds (default is 0, which is no expiry)") + flag.Uint64Var(&Config.defaultExpiry, "default-expiry", 86400, + "default expiration time in seconds (default is 86400, which is 1 day)") flag.StringVar(&Config.certFile, "certfile", "", "path to ssl certificate (for https)") flag.StringVar(&Config.keyFile, "keyfile", "", @@ -283,7 +301,7 @@ func main() { flag.StringVar(&Config.fileReferrerPolicy, "filereferrerpolicy", "same-origin", "value of Referrer-Policy header for file access") - flag.StringVar(&Config.xFrameOptions, "xframeoptions", "SAMEORIGIN", + flag.StringVar(&Config.xFrameOptions, "xframeoptions", "", "value of X-Frame-Options header") flag.Var(&Config.addHeaders, "addheader", "Add an arbitrary header to the response. This option can be used multiple times.") @@ -304,7 +322,12 @@ func main() { "path to directory containing .md files to render as custom pages") flag.Uint64Var(&Config.cleanupEveryMinutes, "cleanup-every-minutes", 0, "How often to clean up expired files in minutes (default is 0, which means files will be cleaned up as they are accessed)") - + flag.StringVar(&Config.extraFooterText, "extra-footer-text", "", + "Extra text above the footer for notices.") + flag.Uint64Var(&Config.maxDurationTime, "max-duration-time", 0, "Time till expiry for files over max-duration-size. (Default is 0 for no-expiry.)") + flag.Int64Var(&Config.maxDurationSize, "max-duration-size", 4*1024*1024*1024, "Size of file before max-duration-time is used to determine expiry max time. (Default is 4GB)") + flag.BoolVar(&Config.disableAccessKey, "disable-access-key", false, "Disables access key usage. (Default is false.)") + flag.BoolVar(&Config.defaultRandomFilename, "default-random-filename", true, "Makes it so the random filename is not default if set false. (Default is true.)") iniflags.Parse() mux := setup() diff --git a/server_test.go b/server_test.go index fc225ce..5b5fb76 100644 --- a/server_test.go +++ b/server_test.go @@ -33,6 +33,7 @@ func TestSetup(t *testing.T) { Config.siteURL = "http://linx.example.org/" Config.filesDir = path.Join(os.TempDir(), generateBarename()) Config.metaDir = Config.filesDir + "_meta" + Config.locksDir = Config.filesDir + "_locks" Config.maxSize = 1024 * 1024 * 1024 Config.noLogs = true Config.siteName = "linx" @@ -446,63 +447,6 @@ func TestPostJSONUpload(t *testing.T) { } } -func TestPostJSONUploadMaxExpiry(t *testing.T) { - mux := setup() - Config.maxExpiry = 300 - - // include 0 to test edge case - // https://github.com/andreimarcu/linx-server/issues/111 - testExpiries := []string{"86400", "-150", "0"} - for _, expiry := range testExpiries { - w := httptest.NewRecorder() - - filename := generateBarename() + ".txt" - - var b bytes.Buffer - mw := multipart.NewWriter(&b) - fw, err := mw.CreateFormFile("file", filename) - if err != nil { - t.Fatal(err) - } - - fw.Write([]byte("File content")) - mw.Close() - - req, err := http.NewRequest("POST", "/upload/", &b) - req.Header.Set("Content-Type", mw.FormDataContentType()) - req.Header.Set("Accept", "application/json") - req.Header.Set("Linx-Expiry", expiry) - if err != nil { - t.Fatal(err) - } - - mux.ServeHTTP(w, req) - - if w.Code != 200 { - t.Log(w.Body.String()) - t.Fatalf("Status code is not 200, but %d", w.Code) - } - - var myjson RespOkJSON - err = json.Unmarshal([]byte(w.Body.String()), &myjson) - if err != nil { - t.Fatal(err) - } - - myExp, err := strconv.ParseInt(myjson.Expiry, 10, 64) - if err != nil { - t.Fatal(err) - } - - expected := time.Now().Add(time.Duration(Config.maxExpiry) * time.Second).Unix() - if myExp != expected { - t.Fatalf("File expiry is not %d but %s", expected, myjson.Expiry) - } - } - - Config.maxExpiry = 0 -} - func TestPostExpiresJSONUpload(t *testing.T) { mux := setup() w := httptest.NewRecorder() @@ -1255,6 +1199,7 @@ func TestInferSiteURLHTTPSFastCGI(t *testing.T) { func TestShutdown(t *testing.T) { os.RemoveAll(Config.filesDir) os.RemoveAll(Config.metaDir) + os.RemoveAll(Config.locksDir) } func TestPutAndGetCLI(t *testing.T) { diff --git a/static/mdpages/Sample.md b/static/mdpages/Sample.md new file mode 100644 index 0000000..9b3956a --- /dev/null +++ b/static/mdpages/Sample.md @@ -0,0 +1,3 @@ +A sample custom page for use with the custom pages plugin. + +`custompagespath = /path/to/linx-server/static/mdpages` diff --git a/static/robots.txt b/static/robots.txt index 44ec3ed..ec4a551 100644 --- a/static/robots.txt +++ b/static/robots.txt @@ -1,3 +1,3 @@ User-agent: * Allow: /$ -Disallow: * + diff --git a/templates.go b/templates.go index 7d38b51..458af90 100644 --- a/templates.go +++ b/templates.go @@ -87,6 +87,11 @@ func renderTemplate(tpl *pongo2.Template, context pongo2.Context, r *http.Reques context["sitepath"] = Config.sitePath context["selifpath"] = Config.selifPath context["custom_pages_names"] = customPagesNames + // Add the context for Config.extraFooterText + context["extra_footer_text"] = Config.extraFooterText + // Add the context for Config.disableAccessKey + context["disable_access_key"] = Config.disableAccessKey + context["default_randomize"] = Config.defaultRandomFilename var a string if Config.authFile == "" { diff --git a/templates/base.html b/templates/base.html index 7e4f82d..54fd368 100644 --- a/templates/base.html +++ b/templates/base.html @@ -29,9 +29,8 @@ {% block content %}{% endblock %} -
diff --git a/templates/display/audio.html b/templates/display/audio.html index ba491f0..68d461e 100644 --- a/templates/display/audio.html +++ b/templates/display/audio.html @@ -2,6 +2,7 @@ {% block head %} + {% endblock %} {% block main %} diff --git a/templates/display/image.html b/templates/display/image.html index 985c504..8dcd844 100644 --- a/templates/display/image.html +++ b/templates/display/image.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% block head %} + {% endblock %} @@ -8,4 +9,4 @@