mirror of
https://git.maid.zone/stuff/soundcloak.git
synced 2026-03-22 08:38:11 +05:00
improve unix socket support, always embed commit
This commit is contained in:
@@ -79,6 +79,9 @@ var Network = "tcp4"
|
||||
// run soundcloak on this address (localhost:4664 by default)
|
||||
var Addr = ":4664"
|
||||
|
||||
// unix socket perms wow
|
||||
var UnixSocketPerms os.FileMode = 0775
|
||||
|
||||
// run multiple instances of soundcloak locally to be able to handle more requests
|
||||
// each one will be a separate process, so they will have separate cache
|
||||
var Prefork = false
|
||||
@@ -394,6 +397,16 @@ func fromEnv() error {
|
||||
Addr = env
|
||||
}
|
||||
|
||||
env = os.Getenv("UNIX_SOCKET_PERMS")
|
||||
if env != "" {
|
||||
p, err := strconv.ParseUint(env, 0, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
UnixSocketPerms = os.FileMode(p)
|
||||
}
|
||||
|
||||
env = os.Getenv("PREFORK")
|
||||
if env != "" {
|
||||
Prefork = boolean(env)
|
||||
@@ -469,6 +482,7 @@ func init() {
|
||||
DNSCacheTTL *time.Duration
|
||||
Network *string
|
||||
Addr *string
|
||||
UnixSocketPerms *string
|
||||
Prefork *bool
|
||||
TrustedProxyCheck *bool
|
||||
TrustedProxies *[]string
|
||||
@@ -539,6 +553,14 @@ func init() {
|
||||
if config.Addr != nil {
|
||||
Addr = *config.Addr
|
||||
}
|
||||
if config.UnixSocketPerms != nil {
|
||||
p, err := strconv.ParseUint(*config.UnixSocketPerms, 0, 32)
|
||||
if err != nil {
|
||||
log.Println("failed to parse UnixSocketPerms:", err)
|
||||
} else {
|
||||
UnixSocketPerms = os.FileMode(p)
|
||||
}
|
||||
}
|
||||
if config.Prefork != nil {
|
||||
Prefork = *config.Prefork
|
||||
}
|
||||
@@ -563,6 +585,3 @@ func init() {
|
||||
}
|
||||
|
||||
const Debug = false
|
||||
const Commit = "unknown"
|
||||
const Repo = "unknown"
|
||||
const CommitURL = "unknown"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cfg
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
)
|
||||
@@ -17,6 +18,13 @@ const MaxIdleConnDuration = 4 * time.Hour
|
||||
var True = true
|
||||
var False = false
|
||||
|
||||
// embedded at buildtime
|
||||
var Commit = "unknown"
|
||||
var Repo = "unknown"
|
||||
|
||||
// generated at runtime
|
||||
var CommitURL = "unknown"
|
||||
|
||||
const (
|
||||
// Downloads the HLS stream on the backend, and restreams it to frontend as a file. Requires no JS, but less stable client-side
|
||||
RestreamPlayer string = "restream"
|
||||
@@ -91,3 +99,18 @@ func B2s(b []byte) string {
|
||||
func S2b(s string) []byte {
|
||||
return unsafe.Slice(unsafe.StringData(s), len(s))
|
||||
}
|
||||
|
||||
func init() {
|
||||
if Repo != "unknown" {
|
||||
if strings.HasPrefix(Repo, "http") {
|
||||
CommitURL = strings.TrimSuffix(Repo, "/")
|
||||
CommitURL = strings.TrimSuffix(CommitURL, ".git")
|
||||
} else {
|
||||
s := strings.Split(Repo, "@")
|
||||
s = strings.Split(s[1], ":")
|
||||
CommitURL = "https://" + s[0] + "/" + s[1]
|
||||
}
|
||||
|
||||
CommitURL += "/commit/" + Commit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package misc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"git.maid.zone/stuff/soundcloak/lib/cfg"
|
||||
@@ -41,7 +41,7 @@ func (pr *ProxyReader) Close() error {
|
||||
|
||||
func Log(what ...any) {
|
||||
if cfg.Debug {
|
||||
fmt.Println(what...)
|
||||
log.Println(what...)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user