mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-06 08:22:24 +01:00
feature (license): update from agpl license
This commit is contained in:
parent
1a97bbf431
commit
dee4108fbc
2 changed files with 54 additions and 0 deletions
|
|
@ -32,6 +32,7 @@ import (
|
|||
_ "github.com/mickael-kerjean/filestash/server/plugin/plg_handler_mcp"
|
||||
_ "github.com/mickael-kerjean/filestash/server/plugin/plg_image_ascii"
|
||||
_ "github.com/mickael-kerjean/filestash/server/plugin/plg_image_c"
|
||||
_ "github.com/mickael-kerjean/filestash/server/plugin/plg_license"
|
||||
_ "github.com/mickael-kerjean/filestash/server/plugin/plg_search_stateless"
|
||||
_ "github.com/mickael-kerjean/filestash/server/plugin/plg_security_scanner"
|
||||
_ "github.com/mickael-kerjean/filestash/server/plugin/plg_security_svg"
|
||||
|
|
|
|||
53
server/plugin/plg_license/index.go
Normal file
53
server/plugin/plg_license/index.go
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
package plg_license
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
. "github.com/mickael-kerjean/filestash/server/common"
|
||||
)
|
||||
|
||||
type license struct {
|
||||
Expiry time.Time `json:"expiry"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
Hooks.Register.Onload(func() {
|
||||
if LICENSE != "agpl" {
|
||||
return
|
||||
}
|
||||
data, err := DecryptString(fmt.Sprintf("%-16s", "filestash"), Config.Get("general.license").Schema(func(f *FormElement) *FormElement {
|
||||
if f == nil {
|
||||
f = &FormElement{}
|
||||
}
|
||||
f.Name = "license"
|
||||
f.Type = "text"
|
||||
f.Placeholder = "License Key"
|
||||
f.Description = "Reach out to support@filestash.app to get your license"
|
||||
lenv := os.Getenv("LICENSE")
|
||||
if lenv != "" {
|
||||
f.Value = os.Getenv("LICENSE")
|
||||
f.ReadOnly = true
|
||||
}
|
||||
return f
|
||||
}).String())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var lic license
|
||||
if err := json.Unmarshal([]byte(data), &lic); err != nil {
|
||||
return
|
||||
}
|
||||
if time.Now().After(lic.Expiry) {
|
||||
Log.Error("License expired. expiry=%s name=%s", lic.Expiry, lic.Name)
|
||||
Log.Error("Contact support at support@filestash.app")
|
||||
os.Exit(1)
|
||||
return
|
||||
}
|
||||
LICENSE = lic.Name
|
||||
Log.Info("You are running Filestash \"%s\"", LICENSE)
|
||||
})
|
||||
}
|
||||
Loading…
Reference in a new issue