mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-02 01:07:28 -04:00
26 lines
558 B
Go
26 lines
558 B
Go
// +build json
|
|
|
|
package dns
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
|
)
|
|
|
|
func (this *Config) UnmarshalJSON(data []byte) error {
|
|
type JsonConfig struct {
|
|
Servers []v2net.AddressJson `json:"servers"`
|
|
}
|
|
jsonConfig := new(JsonConfig)
|
|
if err := json.Unmarshal(data, jsonConfig); err != nil {
|
|
return err
|
|
}
|
|
this.NameServers = make([]v2net.Destination, len(jsonConfig.Servers))
|
|
for idx, server := range jsonConfig.Servers {
|
|
this.NameServers[idx] = v2net.UDPDestination(server.Address, v2net.Port(53))
|
|
}
|
|
|
|
return nil
|
|
}
|