mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
546 B
26 lines
546 B
9 years ago
|
// +build json
|
||
|
|
||
9 years ago
|
package dns
|
||
9 years ago
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
|
||
9 years ago
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
||
9 years ago
|
)
|
||
|
|
||
9 years ago
|
func (this *Config) UnmarshalJSON(data []byte) error {
|
||
|
type JsonConfig struct {
|
||
|
Servers []v2net.Address `json:"servers"`
|
||
9 years ago
|
}
|
||
9 years ago
|
jsonConfig := new(JsonConfig)
|
||
|
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
||
|
return err
|
||
9 years ago
|
}
|
||
9 years ago
|
this.NameServers = make([]v2net.Destination, len(jsonConfig.Servers))
|
||
|
for idx, server := range jsonConfig.Servers {
|
||
|
this.NameServers[idx] = v2net.UDPDestination(server, v2net.Port(53))
|
||
9 years ago
|
}
|
||
9 years ago
|
|
||
9 years ago
|
return nil
|
||
|
}
|