Skip to content

Commit

Permalink
Better nameservers configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Sep 17, 2019
1 parent 34245e9 commit f95cbb8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@
| ----- | ----- | ----- |
| **STS** | `int` | Defines the strict transport security header value (in seconds) for the reverse proxy, in case the value is zero the strict transport security is disabled (defaults to `0`). |

#### DNS

| Name | Type | Description |
| ----- | ----- | ----- |
| **NAMESERVERS** | `sttr` | The sequence of DNS servers to be used for forward of resolution requests (defaults to `[]`). |
| **NAMESERVERS_IP4** | `str` | Same as `NAMESERVERS` but just for IPv4 resolution (defaults to `[]`). |
| **NAMESERVERS_IP6** | `str` | Same as `NAMESERVERS` but just for IPv6 resolution (defaults to `[]`). |

#### Blacklist Middleware

| Name | Type | Description |
Expand Down
10 changes: 10 additions & 0 deletions src/netius/clients/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ class DNSProtocol(netius.DatagramProtocol):

@classmethod
def ns_system(cls, type = "ip4"):
ns = cls.ns_conf(type = type)
if ns: return ns[0]
ns = cls.ns_file(type = type)
if ns: return ns[0]
ns = cls.ns_google(type = type)
Expand All @@ -320,6 +322,14 @@ def ns_system(cls, type = "ip4"):
if ns: return ns[0]
return None

@classmethod
def ns_conf(cls, type = "ip4", force = False):
ns = netius.conf("NAMESERVERS_%s" % type.upper(), [], cast = list)
if ns: return ns
ns = netius.conf("NAMESERVERS", [], cast = list)
if ns: return ns
return []

@classmethod
def ns_file(cls, type = "ip4", force = False):
# verifies if the list value for the file based name server
Expand Down

0 comments on commit f95cbb8

Please sign in to comment.