summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/config.go b/config.go
index a4f2805..e187827 100644
--- a/config.go
+++ b/config.go
@@ -3,15 +3,34 @@ package main
import (
"encoding/json"
"io"
+ "net"
"os"
"path/filepath"
)
const configPathRelative = `.config/soundbox/config.json`
+type MacAddress net.HardwareAddr
+
+func (m *MacAddress) UnmarshalJSON(data []byte) error {
+ var macStr string
+ err := json.Unmarshal(data, &macStr)
+ if err != nil {
+ return err
+ }
+
+ hwAddr, err := net.ParseMAC(macStr)
+ if err != nil {
+ return err
+ }
+
+ *m = MacAddress(hwAddr)
+ return nil
+}
+
type SoundboxConfig struct {
- Name string `json:"name"`
- Mac string `json:"mac"`
+ Name string `json:"name"`
+ Mac MacAddress `json:"mac"`
}
type URLConfig struct {