Browse Source

added json parser for multi fake dns pool

Shelikhoo 4 years ago
parent
commit
94ab10fce3
1 changed files with 15 additions and 1 deletions
  1. 15 1
      infra/conf/fakedns.go

+ 15 - 1
infra/conf/fakedns.go

@@ -6,12 +6,26 @@ import (
 	"github.com/v2fly/v2ray-core/v4/app/dns/fakedns"
 	"github.com/v2fly/v2ray-core/v4/app/dns/fakedns"
 )
 )
 
 
-type FakeDNSConfig struct {
+type FakeDNSPoolElementConfig struct {
 	IPPool  string `json:"ipPool"`
 	IPPool  string `json:"ipPool"`
 	LruSize int64  `json:"poolSize"`
 	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) {
 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{
 	return &fakedns.FakeDnsPool{
 		IpPool:  f.IPPool,
 		IpPool:  f.IPPool,
 		LruSize: f.LruSize,
 		LruSize: f.LruSize,