1
0

Removed configuration file.

This commit is contained in:
Alexander Andreev 2023-08-06 03:19:26 +04:00
parent 7518420289
commit 1df162445e
Signed by: Arav
GPG Key ID: D22A817D95815393
3 changed files with 0 additions and 68 deletions

View File

@ -1,12 +0,0 @@
# Sets network type (could be tcp{,4,6}, unix)
# and address:port or /path/to/unix.sock to
# listen on.
listen_on: "tcp 127.0.0.1:16387"
icecast:
# URL to Icecast's status-json.xsl
url: "http://radio.arav.home.arpa/status-json.xsl"
playlist_path: "playlist.log"
filelist_path: "/srv/radio/filelist.html"
most_listened_song_file_path: "/mnt/data/appdata/mostlistenedsong"
# How much songs to list on a page
list_last_n_songs: 10

View File

@ -1,12 +0,0 @@
# Sets network type (could be tcp{,4,6}, unix)
# and address:port or /path/to/unix.sock to
# listen on.
listen_on: "unix /var/run/dwelling-radio/sock"
icecast:
# URL to Icecast's status-json.xsl
url: "http://radio.arav.home.arpa/status-json.xsl"
playlist_path: "/var/log/icecast/playlist.log"
filelist_path: "/srv/radio/filelist.html"
most_listened_song_file_path: "/mnt/data/appdata/mostlistenedsong"
# How much songs to list on a page
list_last_n_songs: 10

View File

@ -1,44 +0,0 @@
package configuration
import (
"os"
"strings"
"github.com/pkg/errors"
"gopkg.in/yaml.v3"
)
type Configuration struct {
ListenOn string `yaml:"listen_on"`
Icecast struct {
URL string `yaml:"url"`
Playlist string `yaml:"playlist_path"`
} `yaml:"icecast"`
FilelistPath string `yaml:"filelist_path"`
MostListenedSongPath string `yaml:"most_listened_song_file_path"`
ListLastNSongs int `yaml:"list_last_n_songs"`
}
// Load reads a YAML file that stores configuration of a service.
func Load(path string) (*Configuration, error) {
configFile, err := os.Open(path)
if err != nil {
return nil, errors.Wrap(err, "failed to open configuration file")
}
defer configFile.Close()
config := &Configuration{}
if err := yaml.NewDecoder(configFile).Decode(config); err != nil {
return nil, errors.Wrap(err, "failed to parse configuration file")
}
return config, nil
}
// SplitNetworkAddress splits ListenOn option into network type (e.g. tcp, unix,
// udp) and address:port or /path/to/service.socket to listen on.
func (c *Configuration) SplitNetworkAddress() (string, string) {
s := strings.Split(c.ListenOn, " ")
return s[0], s[1]
}