Add YTDLP_SITE_SECURE variable for use with https
This commit is contained in:
14
config.go
14
config.go
@@ -3,8 +3,11 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var GitSHA string
|
||||||
|
|
||||||
func getDataDir() string {
|
func getDataDir() string {
|
||||||
value, exists := os.LookupEnv("YTDLP_SITE_DATA_DIR")
|
value, exists := os.LookupEnv("YTDLP_SITE_DATA_DIR")
|
||||||
if exists {
|
if exists {
|
||||||
@@ -39,7 +42,16 @@ func getSessionAuthKey() ([]byte, error) {
|
|||||||
return []byte{}, fmt.Errorf("please set %s", key)
|
return []byte{}, fmt.Errorf("please set %s", key)
|
||||||
}
|
}
|
||||||
|
|
||||||
var GitSHA string
|
func getSecure() bool {
|
||||||
|
key := "YTDLP_SITE_SECURE"
|
||||||
|
if value, exists := os.LookupEnv(key); exists {
|
||||||
|
lower := strings.ToLower(value)
|
||||||
|
if lower == "on" || lower == "1" || lower == "true" || lower == "yes" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func getGitSHA() string {
|
func getGitSHA() string {
|
||||||
|
|
||||||
|
4
main.go
4
main.go
@@ -110,11 +110,13 @@ func main() {
|
|||||||
staticGroup.Static("/", getDataDir())
|
staticGroup.Static("/", getDataDir())
|
||||||
e.GET("/temp/:token", tempHandler)
|
e.GET("/temp/:token", tempHandler)
|
||||||
|
|
||||||
|
secure := getSecure()
|
||||||
|
|
||||||
store.Options = &sessions.Options{
|
store.Options = &sessions.Options{
|
||||||
Path: "/",
|
Path: "/",
|
||||||
MaxAge: 30 * 24 * 60 * 60, // seconds
|
MaxAge: 30 * 24 * 60 * 60, // seconds
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
Secure: false, // needed for session to work over http
|
Secure: secure,
|
||||||
}
|
}
|
||||||
|
|
||||||
// start the transcode worker
|
// start the transcode worker
|
||||||
|
Reference in New Issue
Block a user