1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-11 18:30:43 +00:00

added json parser for multi fake dns pool

This commit is contained in:
Shelikhoo 2021-04-10 00:08:50 +01:00
parent 1ed32e35a6
commit 94ab10fce3
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316

View File

@ -6,12 +6,26 @@ import (
"github.com/v2fly/v2ray-core/v4/app/dns/fakedns"
)
type FakeDNSConfig struct {
type FakeDNSPoolElementConfig struct {
IPPool string `json:"ipPool"`
LruSize int64 `json:"poolSize"`
}
type FakeDNSConfig struct {
IPPool string `json:"ipPool"`
LruSize int64 `json:"poolSize"`
Pools *[]FakeDNSPoolElementConfig `json:"pools,omitempty"`
}
func (f FakeDNSConfig) Build() (proto.Message, error) {
if f.Pools != nil {
fakeDNSPool := &fakedns.FakeDnsPoolMulti{}
for _, v := range *f.Pools {
fakeDNSPool.Pools = append(fakeDNSPool.Pools, &fakedns.FakeDnsPool{IpPool: v.IPPool, LruSize: v.LruSize})
}
return fakeDNSPool, nil
}
return &fakedns.FakeDnsPool{
IpPool: f.IPPool,
LruSize: f.LruSize,