option (tty): reenable tty plugin on non cloud instance

This commit is contained in:
Mickael Kerjean 2020-08-03 19:04:04 +10:00
parent fe802d82b7
commit 8fcb721c13
2 changed files with 7 additions and 3 deletions

View file

@ -3,6 +3,7 @@ package plugin
import (
_ "github.com/mickael-kerjean/filestash/server/plugin/plg_starter_tunnel"
_ "github.com/mickael-kerjean/filestash/server/plugin/plg_starter_tor"
_ "github.com/mickael-kerjean/filestash/server/plugin/plg_handler_console"
_ "github.com/mickael-kerjean/filestash/server/plugin/plg_video_transcoder"
_ "github.com/mickael-kerjean/filestash/server/plugin/plg_editor_onlyoffice"
_ "github.com/mickael-kerjean/filestash/server/plugin/plg_handler_syncthing"

View file

@ -42,10 +42,10 @@ func init() {
if console_enable() == false {
return nil
}
r.PathPrefix("/tty/").Handler(
r.PathPrefix("/admin/tty/").Handler(
AuthBasic(
func() (string, string) { return "admin", Config.Get("auth.admin").String() },
TTYHandler("/tty/"),
TTYHandler("/admin/tty/"),
),
)
return nil
@ -62,7 +62,10 @@ var notAuthorised = func(res http.ResponseWriter, req *http.Request) {
func AuthBasic(credentials func() (string, string), fn http.Handler) http.HandlerFunc {
return func(res http.ResponseWriter, req *http.Request) {
if console_enable() == false {
if strings.HasSuffix(Config.Get("general.host").String(), "filestash.app") {
http.NotFoundHandler().ServeHTTP(res, req)
return
} else if console_enable() == false {
http.NotFoundHandler().ServeHTTP(res, req)
return
}