cfg

package
v0.0.0-...-7a044a2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2025 License: AGPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
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"
	// Downloads the HLS stream on the frontend (proxying can be enabled). Requires JS, more stable client-side
	HLSPlayer string = "hls"
	// Disables the song player
	NonePlayer string = "none"
)
View Source
const (
	// Just plays every song in order, one after another
	AutoplayNormal string = "normal"
	// Randomly selects a song to play from the playlist
	AutoplayRandom string = "random"
)
View Source
const (
	// choose best for quality/size (AudioAAC over AudioOpus over AudioMP3)
	AudioBest string = "best"

	// 160kbps m4a AAC audio, rarely available (fallback to AudioMP3 if unavailable)
	AudioAAC string = "aac"

	// 72kbps ogg opus audio, usually available 99% of the time (fallback to AudioMP3 if unavailable)
	AudioOpus string = "opus"

	// 128kbps mp3 audio, always available, good for compatibility
	AudioMP3 string = "mpeg"
)
View Source
const Commit = "unknown"
View Source
const CommitURL = "unknown"
View Source
const Debug = false
View Source
const HLSAACCDN = "playback.media-streaming.soundcloud.cloud"
View Source
const HLSCDN = "cf-hls-media.sndcdn.com"
View Source
const ImageCDN = "i1.sndcdn.com"

seems soundcloud has 4 of these (i1, i2, i3, i4) they point to the same ip from my observations, and they all serve the same files

View Source
const MaxIdleConnDuration = 4 * time.Hour

Note: we don't need DialDualStack for clients, soundcloud has no ipv6 support and operates only over http1.1 :D

View Source
const Repo = "unknown"

Variables

View Source
var Addr = ":4664"

run soundcloak on this address (localhost:4664 by default)

View Source
var ClientIDTTL = 4 * time.Hour

time-to-live for clientid cache larger number will improve performance (no need to recheck everytime) but might make soundcloak briefly unusable for a larger amount of time if the client id is invalidated I went with 4 hours, since those clientids still remain active for quite some time, even after soundcloud updates it

View Source
var CodegenConfig = false

generate code for config (run soundcloakctl config codegen or use docker image - it runs it for you)

View Source
var DNSCacheTTL = 60 * time.Minute

time-to-live for dns cache

View Source
var EmbedFiles = false

use static files embedded in binary

View Source
var False = false
View Source
var GetWebProfiles = true

Retrieve links users set in their profile (social media, website, etc)

View Source
var ImageCacheControl = "max-age=600, public, immutable" // browser-side 10 minutes cache by default, only used for proxied images
View Source
var InstanceInfo = true

enable /_/info endpoint (shows if some settings are enabled/disabled)

View Source
var Network = "tcp4"

where to listen can be tcp4 (bind to ipv4 address), tcp6 (bind to ipv6 address) or unix (bind to unix socket)

View Source
var PlaylistCacheCleanDelay = PlaylistTTL / 4

delay between cleanup of playlist cache

View Source
var PlaylistTTL = 20 * time.Minute

time-to-live for playlist cache

View Source
var Prefork = false

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

View Source
var ProxyImages = false

proxy images (user avatars, track/playlist covers)

View Source
var ProxyStreams = false

proxy streams (hls playlist files and track parts)

View Source
var Restream = false

restream the HLS playlist as just a file, makes soundcloak usable with zero JS If this setting is set to true, ProxyStreams and FullyPreloadTrack will be ignored (you could count this as a replacement for having both as true, also should be a bit more effective) You can also easily download the songs this way (right click => save audio as..., the only downside is that there is no metadata)

View Source
var RestreamCacheControl = "max-age=3600, public, immutable"
View Source
var TrackCacheCleanDelay = TrackTTL / 4

delay between cleanup of track cache

View Source
var TrackTTL = 20 * time.Minute

time-to-live for track cache

View Source
var True = true
View Source
var TrustedProxies = []string{}

list of ips or ip ranges of trusted proxies (check above)

View Source
var TrustedProxyCheck = true

use X-Forwarded-* headers ONLY when ip is in TrustedProxies list when disabled, the X-Forwarded-* headers will be blindly used

View Source
var UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.3"

default fasthttp one was causing connections to be stuck? todo make it cycle browser useragents or just choose random at startup

View Source
var UserCacheCleanDelay = UserTTL / 4

delay between cleanup of user cache

View Source
var UserTTL = 20 * time.Minute

time-to-live for user profile cache

Functions

func B2s

func B2s(b []byte) string

func S2b

func S2b(s string) []byte

Types

type Preferences

type Preferences struct {
	Player       *string
	ProxyStreams *bool

	// fully loads the track on page load
	// this option is here since the stream expires after some time (5 minutes? correct me if im wrong)
	// if the stream isn't fully loaded before it expires - you'll need to reload the page
	FullyPreloadTrack *bool

	ProxyImages *bool

	// Highlight @username, https://example.com and email@example.com in text as clickable links
	ParseDescriptions *bool

	// Automatically play next track in playlists
	AutoplayNextTrack *bool

	// Automatically play next related track
	AutoplayNextRelatedTrack *bool

	DefaultAutoplayMode *string // "normal" or "random"

	// Check above for more info
	// Probably best to keep all at "mpeg" by default for compatibility
	HLSAudio      *string // Please don't use "opus" or "best". hls.js doesn't work with ogg/opus
	RestreamAudio *string // You can actually use anything here
	DownloadAudio *string // "aac" may not play well with some players

	ShowAudio *bool // display audio (aac, opus, mpeg etc) under track player

	SearchSuggestions *bool // load search suggestions on main page

	DynamicLoadComments *bool // dynamic comments loader without leaving track page

	KeepPlayerFocus *bool // keep player element in focus
}
var DefaultPreferences Preferences

Default preferences. You can override those preferences in the config file, otherwise they default to values depending on your config (so, if you have ProxyStreams enabled - it will be enabled for the user by default and etc, or if you enabled Restream, the default player will be RestreamPlayer instead of HLSPlayer)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL