12345678910111213141516171819202122232425262728293031 |
- package configs
- import (
- "gopkg.in/ini.v1"
- )
- const ipconffile = "/etc/asterisk/dev_ip.conf"
- type NetworkInterface struct {
- Key string `json:"key"`
- Value string `json:"value"`
- Name string `json:"name"`
- }
- func GetNetworkInterface() []NetworkInterface {
- interfaces := make([]NetworkInterface, 0)
- cfg, err := ini.Load(ipconffile)
- if err != nil {
- return interfaces
- }
- keys := cfg.Section("interface").Keys()
- for _, key := range keys {
- if key.Name() == "eth0" {
- interfaces = append(interfaces, NetworkInterface{Key: key.Name(), Value: key.Value(), Name: "WAN"})
- } else {
- interfaces = append(interfaces, NetworkInterface{Key: key.Name(), Value: key.Value(), Name: "LAN"})
- }
- }
- return interfaces
- }
|