-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_cfg.go
48 lines (44 loc) · 1.62 KB
/
server_cfg.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package yuppie
// Config represents the configuration of the UPnP server
type Config struct {
// Interfaces contain the names of the network interfaces to be used. If
// Interfaces is empty, all available interfaces will be used
Interfaces []string
// Port is the port where the server listens
Port int
// MaxAge is the validity time period of the SSDP advertisement in seconds
MaxAge int
// ProductName is the product name used for the server string
ProductName string
// ProductVersion is the product version for the server string
ProductVersion string
// StatusFile is the path to the JSON file that persists data such as
// state variables
StatusFile string
// IconRootDir is the root directory for device icons. I.e. if the icon url
// in the device description is someDir/icon.png, for example, the icon
// must be located in IconRootDir/someDir/icon.png
IconRootDir string
}
// defaultCfg is the default configuration which is used if the server is created
// with an empty configuration
var defaultCfg = Config{
Interfaces: nil,
Port: 8008,
MaxAge: 86400,
ProductName: "yuppie server",
ProductVersion: "1.0",
StatusFile: "./status.json",
}
// equal returns true if two config structures are equal, otherwise false is returned
func (a Config) equal(b Config) bool {
if len(a.Interfaces) != len(b.Interfaces) {
return false
}
for i := 0; i < len(a.Interfaces); i++ {
if a.Interfaces[i] != b.Interfaces[i] {
return false
}
}
return (a.Port == b.Port && a.MaxAge == b.MaxAge && a.ProductName == b.ProductName && a.ProductVersion == b.ProductVersion && a.StatusFile == b.StatusFile)
}