+ DNS: add "ipset" configuration setting
Close #1191
Squashed commit of the following:
commit ba14b53f9e3d98ad8127aa3af1def0da4269e8c4
Merge: 362f4c44 6b614295
Author: Simon Zolin <s.zolin@adguard.com>
Date: Wed Sep 2 14:03:19 2020 +0300
Merge remote-tracking branch 'origin/master' into 1191-ipset
commit 362f4c44915cb8946db2e80f9a3f5afd74fe5de1
Author: Simon Zolin <s.zolin@adguard.com>
Date: Wed Sep 2 12:50:56 2020 +0300
minor
commit 28e12459166fe3d13fb0dbe59ac11b7d86adb9b4
Author: Simon Zolin <s.zolin@adguard.com>
Date: Wed Sep 2 12:43:25 2020 +0300
minor
commit bdbd7324501f6111bea1e91eda7d730c7ea57b11
Author: Simon Zolin <s.zolin@adguard.com>
Date: Tue Sep 1 18:40:04 2020 +0300
move code, ipset-v6
commit 77f4d943e74b70b5bc5aea279875ab1e2fab2192
Author: Simon Zolin <s.zolin@adguard.com>
Date: Tue Sep 1 15:53:27 2020 +0300
comment
commit 16401325bbefeba08e447257b12a8424b78c9475
Author: Simon Zolin <s.zolin@adguard.com>
Date: Mon Aug 31 17:43:23 2020 +0300
minor
commit c8410e9a519b87911bc50f504e8b4aaf8dce6e02
Author: Simon Zolin <s.zolin@adguard.com>
Date: Mon Aug 31 15:30:52 2020 +0300
+ DNS: add "ipset" configuration setting
This commit is contained in:
@@ -51,6 +51,8 @@ type Server struct {
|
||||
stats stats.Stats
|
||||
access *accessCtx
|
||||
|
||||
ipset ipsetCtx
|
||||
|
||||
tableHostToIP map[string]net.IP // "hostname -> IP" table for internal addresses (DHCP)
|
||||
tableHostToIPLock sync.Mutex
|
||||
|
||||
@@ -168,7 +170,7 @@ func (s *Server) startInternal() error {
|
||||
|
||||
// Prepare the object
|
||||
func (s *Server) Prepare(config *ServerConfig) error {
|
||||
// 1. Initialize the server configuration
|
||||
// Initialize the server configuration
|
||||
// --
|
||||
if config != nil {
|
||||
s.conf = *config
|
||||
@@ -184,18 +186,22 @@ func (s *Server) Prepare(config *ServerConfig) error {
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Set default values in the case if nothing is configured
|
||||
// Set default values in the case if nothing is configured
|
||||
// --
|
||||
s.initDefaultSettings()
|
||||
|
||||
// 3. Prepare DNS servers settings
|
||||
// Initialize IPSET configuration
|
||||
// --
|
||||
s.ipset.init(s.conf.IPSETList)
|
||||
|
||||
// Prepare DNS servers settings
|
||||
// --
|
||||
err := s.prepareUpstreamSettings()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 3. Create DNS proxy configuration
|
||||
// Create DNS proxy configuration
|
||||
// --
|
||||
var proxyConfig proxy.Config
|
||||
proxyConfig, err = s.createProxyConfig()
|
||||
@@ -203,11 +209,11 @@ func (s *Server) Prepare(config *ServerConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 4. Prepare a DNS proxy instance that we use for internal DNS queries
|
||||
// Prepare a DNS proxy instance that we use for internal DNS queries
|
||||
// --
|
||||
s.prepareIntlProxy()
|
||||
|
||||
// 5. Initialize DNS access module
|
||||
// Initialize DNS access module
|
||||
// --
|
||||
s.access = &accessCtx{}
|
||||
err = s.access.Init(s.conf.AllowedClients, s.conf.DisallowedClients, s.conf.BlockedHosts)
|
||||
@@ -215,14 +221,14 @@ func (s *Server) Prepare(config *ServerConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// 6. Register web handlers if necessary
|
||||
// Register web handlers if necessary
|
||||
// --
|
||||
if !webRegistered && s.conf.HTTPRegister != nil {
|
||||
webRegistered = true
|
||||
s.registerHandlers()
|
||||
}
|
||||
|
||||
// 7. Create the main DNS proxy instance
|
||||
// Create the main DNS proxy instance
|
||||
// --
|
||||
s.dnsProxy = &proxy.Proxy{Config: proxyConfig}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user