1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-01 08:16:00 -04:00
v2fly/app/dns/internal/config_json.go

26 lines
551 B
Go
Raw Normal View History

2016-01-15 09:23:12 -05:00
// +build json
2016-01-31 11:01:28 -05:00
package internal
2016-01-15 09:23:12 -05:00
import (
"encoding/json"
2016-05-16 02:09:28 -04:00
v2net "github.com/v2ray/v2ray-core/common/net"
2016-01-15 09:23:12 -05:00
)
2016-05-16 02:09:28 -04:00
func (this *Config) UnmarshalJSON(data []byte) error {
type JsonConfig struct {
Servers []v2net.Address `json:"servers"`
2016-01-15 09:23:12 -05:00
}
2016-05-16 02:09:28 -04:00
jsonConfig := new(JsonConfig)
if err := json.Unmarshal(data, jsonConfig); err != nil {
return err
2016-01-15 09:23:12 -05:00
}
2016-05-16 02:09:28 -04:00
this.NameServers = make([]v2net.Destination, len(jsonConfig.Servers))
for idx, server := range jsonConfig.Servers {
this.NameServers[idx] = v2net.UDPDestination(server, v2net.Port(53))
2016-01-15 09:23:12 -05:00
}
2016-05-16 02:09:28 -04:00
2016-01-15 09:23:12 -05:00
return nil
}