-
Notifications
You must be signed in to change notification settings - Fork 107
/
utils.go
31 lines (27 loc) · 1.04 KB
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"fmt"
"net"
"github.com/spf13/viper"
)
func getTCPAddr(key string) *net.TCPAddr {
addr, addrErr := net.ResolveTCPAddr("tcp", viper.GetString(key))
if addrErr != nil {
panic(fmt.Errorf("error parsing address %s: %s", viper.GetString(key), addrErr))
}
return addr
}
func getDiscoveryData() DiscoveryData {
return DiscoveryData{
FriendlyName: viper.GetString("discovery.device-friendly-name"),
Manufacturer: viper.GetString("discovery.device-manufacturer"),
ModelNumber: viper.GetString("discovery.device-model-number"),
FirmwareName: viper.GetString("discovery.device-firmware-name"),
TunerCount: viper.GetInt("iptv.streams"),
FirmwareVersion: viper.GetString("discovery.device-firmware-version"),
DeviceID: viper.GetString("discovery.device-id"),
DeviceAuth: viper.GetString("discovery.device-auth"),
BaseURL: fmt.Sprintf("http://%s", viper.GetString("web.base-address")),
LineupURL: fmt.Sprintf("http://%s/lineup.json", viper.GetString("web.base-address")),
}
}