This website has been blocked by your network administrator.
8 |
9 |
--------------------------------------------------------------------------------
/Apps/DefaultRecordsApp/DefaultRecordsApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | true
7 | 3.0
8 | false
9 | Technitium
10 | Technitium DNS Server
11 | Shreyas Zare
12 | DefaultRecordsApp
13 | DefaultRecords
14 | https://technitium.com/dns/
15 | https://github.com/TechnitiumSoftware/DnsServer
16 | Allows setting one or more default records for configured local zones.
17 | false
18 | Library
19 |
20 |
21 |
22 |
23 | false
24 |
25 |
26 |
27 |
28 |
29 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
30 | false
31 |
32 |
33 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
34 | false
35 |
36 |
37 |
38 |
39 |
40 | PreserveNewest
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/Apps/DefaultRecordsApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "enableDefaultRecords": false,
3 | "defaultTtl": 3600,
4 | "zoneSetMap": {
5 | "*": ["set1"],
6 | "*.net": ["set2"],
7 | "example.org": ["set1", "set2"]
8 | },
9 | "sets": [
10 | {
11 | "name": "set1",
12 | "enable": true,
13 | "records": [
14 | "@ 3600 IN MX 10 mail.example.com.",
15 | "@ 3600 IN TXT \"v=spf1 a mx -all\""
16 | ]
17 | },
18 | {
19 | "name": "set2",
20 | "enable": true,
21 | "records": [
22 | "www 3600 IN CNAME @",
23 | "@ 3600 IN A 1.2.3.4"
24 | ]
25 | }
26 | ]
27 | }
--------------------------------------------------------------------------------
/Apps/Dns64App/Dns64App.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | 4.1
7 | false
8 | Technitium
9 | Technitium DNS Server
10 | Shreyas Zare
11 | Dns64App
12 | Dns64
13 | https://technitium.com/dns/
14 | https://github.com/TechnitiumSoftware/DnsServer
15 | Enables DNS64 function for both authoritative and recursive resolver responses for use by IPv6 only clients.\n\nWarning! Installing DNS64 app without having NAT64 in place will cause connectivity issues for some websites.
16 | false
17 | Library
18 |
19 |
20 |
21 |
22 | false
23 |
24 |
25 |
26 |
27 |
28 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
29 | false
30 |
31 |
32 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
33 | false
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Apps/Dns64App/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "appPreference": 30,
3 | "enableDns64": true,
4 | "networkGroupMap": {
5 | "::/0": "everyone"
6 | },
7 | "groups": [
8 | {
9 | "name": "everyone",
10 | "enableDns64": true,
11 | "dns64PrefixMap": {
12 | "0.0.0.0/0": "64:ff9b::/96",
13 | "10.0.0.0/8": null,
14 | "172.16.0.0/12": null,
15 | "192.168.0.0/16": null
16 | },
17 | "excludedIpv6": [
18 | "::ffff:0:0/96"
19 | ]
20 | }
21 | ]
22 | }
--------------------------------------------------------------------------------
/Apps/DnsBlockListApp/DnsBlockListApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | 3.0
7 | false
8 | Technitium
9 | Technitium DNS Server
10 | Shreyas Zare
11 | DnsBlockListApp
12 | DnsBlockList
13 | https://technitium.com/dns/
14 | https://github.com/TechnitiumSoftware/DnsServer
15 | Allows creating APP records in primary and forwarder zones that can return A or TXT records based on the DNS Block Lists (DNSBL) configured. The implementation is based on RFC 5782.
16 | false
17 | Library
18 |
19 |
20 |
21 |
22 | false
23 |
24 |
25 |
26 |
27 |
28 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
29 | false
30 |
31 |
32 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
33 | false
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 | PreserveNewest
43 |
44 |
45 | PreserveNewest
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Apps/DnsBlockListApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "dnsBlockLists": [
3 | {
4 | "name": "ipblocklist1",
5 | "type": "ip",
6 | "enabled": true,
7 | "responseA": "127.0.0.2",
8 | "responseTXT": "https://example.com/dnsbl?ip={ip}",
9 | "blockListFile": "ip-blocklist.txt"
10 | },
11 | {
12 | "name": "domainblocklist1",
13 | "type": "domain",
14 | "enabled": true,
15 | "responseA": "127.0.0.2",
16 | "responseTXT": "https://example.com/dnsbl?domain={domain}",
17 | "blockListFile": "domain-blocklist.txt"
18 | }
19 | ]
20 | }
--------------------------------------------------------------------------------
/Apps/DnsBlockListApp/domain-blocklist.txt:
--------------------------------------------------------------------------------
1 | # DNSBL domain block list
2 | # Format: domain A-response TXT-response
3 | # Seperator: , , or char
4 | #
5 | # A-response & TXT-response are optional but A-response must exists when TXT-response is specified
6 | #
7 | # Examples:
8 | # example.com
9 | # example.net 127.0.0.4
10 | # malware.com 127.0.0.4 malware see: https://example.com/dnsbl?domain={domain}
11 |
--------------------------------------------------------------------------------
/Apps/DnsBlockListApp/ip-blocklist.txt:
--------------------------------------------------------------------------------
1 | # DNSBL IP block list
2 | # Format: ip/network A-response TXT-response
3 | # Seperator: , , or char
4 | #
5 | # A-response & TXT-response are optional but A-response must exists when TXT-response is specified.
6 | # Supports both IPv4 and IPv6 addresses.
7 | #
8 | # Examples:
9 | # 192.168.1.1
10 | # 192.168.0.0/24
11 | # 192.168.2.1 127.0.0.3
12 | # 10.8.1.0/24 127.0.0.3 malware see: https://example.com/dnsbl?ip={ip}
13 | # 2001:db8::/64
14 |
--------------------------------------------------------------------------------
/Apps/DnsRebindingProtectionApp/DnsRebindingProtectionApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | 3.0
7 | false
8 | Technitium
9 | Technitium DNS Server
10 | Shreyas Zare, Rui Fung Yip
11 | DnsRebindingProtectionApp
12 | DnsRebindingProtection
13 | https://technitium.com/dns/
14 | https://github.com/TechnitiumSoftware/DnsServer
15 | Protects from DNS rebinding attacks using configured private domains and networks.\n\nWarning! The app will remove private IP addresses from response for domain names not hosted locally.
16 | false
17 | Library
18 |
19 |
20 |
21 |
22 | false
23 |
24 |
25 |
26 |
27 |
28 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
29 | false
30 |
31 |
32 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
33 | false
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Apps/DnsRebindingProtectionApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "enableProtection": true,
3 | "bypassNetworks": [
4 | ],
5 | "privateNetworks": [
6 | "10.0.0.0/8",
7 | "127.0.0.0/8",
8 | "172.16.0.0/12",
9 | "192.168.0.0/16",
10 | "169.254.0.0/16",
11 | "fc00::/7",
12 | "fe80::/10"
13 | ],
14 | "privateDomains": [
15 | "home.arpa"
16 | ]
17 | }
--------------------------------------------------------------------------------
/Apps/DropRequestsApp/DropRequestsApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | 6.1
7 | false
8 | Technitium
9 | Technitium DNS Server
10 | Shreyas Zare
11 | DropRequestsApp
12 | DropRequests
13 | https://technitium.com/dns/
14 | https://github.com/TechnitiumSoftware/DnsServer
15 | Drops incoming DNS requests that match list of blocked networks or blocked questions.
16 | false
17 | Library
18 |
19 |
20 |
21 |
22 | false
23 |
24 |
25 |
26 |
27 |
28 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
29 | false
30 |
31 |
32 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
33 | false
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Apps/DropRequestsApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "enableBlocking": true,
3 | "dropMalformedRequests": false,
4 | "allowedNetworks": [
5 | "127.0.0.1",
6 | "::1",
7 | "10.0.0.0/8",
8 | "172.16.0.0/12",
9 | "192.168.0.0/16"
10 | ],
11 | "blockedNetworks": [
12 | ],
13 | "blockedQuestions": [
14 | {
15 | "name": "example.com",
16 | "blockZone": true
17 | },
18 | {
19 | "type": "ANY"
20 | },
21 | {
22 | "name": "pizzaseo.com",
23 | "type": "RRSIG"
24 | },
25 | {
26 | "name": "sl",
27 | "type": "ANY"
28 | },
29 | {
30 | "name": "a.a.a.ooooops.space",
31 | "type": "A"
32 | }
33 | ]
34 | }
--------------------------------------------------------------------------------
/Apps/FailoverApp/FailoverApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | 8.0.1
7 | false
8 | Technitium
9 | Technitium DNS Server
10 | Shreyas Zare
11 | FailoverApp
12 | Failover
13 | https://technitium.com/dns/
14 | https://github.com/TechnitiumSoftware/DnsServer
15 | Allows creating APP records in primary and forwarder zones that can return A or AAAA records, or CNAME record based on the health status of the servers. The app supports email alerts and web hooks to relay the health status.
16 | false
17 | Library
18 |
19 |
20 |
21 |
22 | false
23 |
24 |
25 |
26 |
27 |
28 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
29 | false
30 |
31 |
32 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.IO.dll
33 | false
34 |
35 |
36 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
37 | false
38 |
39 |
40 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.Mail.dll
41 | true
42 |
43 |
44 |
45 |
46 |
47 | PreserveNewest
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/Apps/FailoverApp/HealthCheckResponse.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2021 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 |
22 | namespace Failover
23 | {
24 | enum HealthStatus
25 | {
26 | Unknown = 0,
27 | Failed = 1,
28 | Healthy = 2,
29 | Maintenance = 3
30 | }
31 |
32 | class HealthCheckResponse
33 | {
34 | #region variables
35 |
36 | public readonly DateTime DateTime = DateTime.UtcNow;
37 | public readonly HealthStatus Status;
38 | public readonly string FailureReason;
39 | public readonly Exception Exception;
40 |
41 | #endregion
42 |
43 | #region constructor
44 |
45 | public HealthCheckResponse(HealthStatus status, string failureReason = null, Exception exception = null)
46 | {
47 | Status = status;
48 | FailureReason = failureReason;
49 | Exception = exception;
50 | }
51 |
52 | #endregion
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Apps/FailoverApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "healthChecks": [
3 | {
4 | "name": "ping",
5 | "type": "ping",
6 | "interval": 60,
7 | "retries": 3,
8 | "timeout": 10,
9 | "emailAlert": "default",
10 | "webHook": "default"
11 | },
12 | {
13 | "name": "tcp80",
14 | "type": "tcp",
15 | "interval": 60,
16 | "retries": 3,
17 | "timeout": 10,
18 | "port": 80,
19 | "emailAlert": "default",
20 | "webHook": "default"
21 | },
22 | {
23 | "name": "tcp443",
24 | "type": "tcp",
25 | "interval": 60,
26 | "retries": 3,
27 | "timeout": 10,
28 | "port": 443,
29 | "emailAlert": "default",
30 | "webHook": "default"
31 | },
32 | {
33 | "name": "http",
34 | "type": "http",
35 | "interval": 60,
36 | "retries": 3,
37 | "timeout": 10,
38 | "url": null,
39 | "emailAlert": "default",
40 | "webHook": "default"
41 | },
42 | {
43 | "name": "https",
44 | "type": "https",
45 | "interval": 60,
46 | "retries": 3,
47 | "timeout": 10,
48 | "url": null,
49 | "emailAlert": "default",
50 | "webHook": "default"
51 | },
52 | {
53 | "name": "www.example.com",
54 | "type": "https",
55 | "interval": 60,
56 | "retries": 3,
57 | "timeout": 10,
58 | "url": "https://www.example.com",
59 | "emailAlert": "default",
60 | "webHook": "default"
61 | }
62 | ],
63 | "emailAlerts": [
64 | {
65 | "name": "default",
66 | "enabled": false,
67 | "alertTo": [
68 | "admin@example.com"
69 | ],
70 | "smtpServer": "smtp.example.com",
71 | "smtpPort": 465,
72 | "startTls": false,
73 | "smtpOverTls": true,
74 | "username": "alerts@example.com",
75 | "password": "password",
76 | "mailFrom": "alerts@example.com",
77 | "mailFromName": "DNS Server Alert"
78 | }
79 | ],
80 | "webHooks": [
81 | {
82 | "name": "default",
83 | "enabled": false,
84 | "urls": [
85 | "https://webhooks.example.com/default"
86 | ]
87 | }
88 | ],
89 | "underMaintenance": [
90 | {
91 | "network": "192.168.10.2/32",
92 | "enabled": false
93 | },
94 | {
95 | "network": "10.1.1.0/24",
96 | "enabled": false
97 | }
98 | ]
99 | }
--------------------------------------------------------------------------------
/Apps/FilterAaaaApp/FilterAaaaApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | 3.2
7 | false
8 | Technitium
9 | Technitium DNS Server
10 | Shreyas Zare
11 | FilterAaaaApp
12 | FilterAaaa
13 | https://technitium.com/dns/
14 | https://github.com/TechnitiumSoftware/DnsServer
15 | Allows filtering AAAA records by returning NO DATA response when A records for the same domain name are available. This allows clients with dual-stack (IPv4 and IPv6) Internet connection to prefer using IPv4 to connect to websites and use IPv6 only when a website has no IPv4 support.
16 | false
17 | Library
18 |
19 |
20 |
21 |
22 | false
23 |
24 |
25 |
26 |
27 |
28 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
29 | false
30 |
31 |
32 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
33 | false
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Apps/FilterAaaaApp/README.md:
--------------------------------------------------------------------------------
1 | # Filter AAAA
2 |
3 | The `Filter AAAA` app allows filtering `AAAA` records by returning `NODATA` responses when `A` records for the same domain name are available. This allows clients with dual-stack (IPv4 and IPv6) internet connections to prefer using IPv4 to connect to websites and use IPv6 only when a website has no IPv4 support.
4 |
5 | The app is a _post processor_. That means, it modifies a response generated by the DNS server before it is sent to the client.
6 |
7 | ## Configuration
8 |
9 | As any post processor, this app is configured globally in the app settings. Its configuration file is a JSON document which looks like the following:
10 |
11 | ```
12 | {
13 | "enableFilterAaaa": true,
14 | "defaultTtl": 30,
15 | "bypassLocalZones": false,
16 | "bypassNetworks": [
17 | "192.168.1.0/24"
18 | ],
19 | "bypassDomains": [
20 | "example.com"
21 | ],
22 | "filterDomains": [
23 | ]
24 | }
25 | ```
26 |
27 | The individual settings are:
28 |
29 | - `enableFilterAaaa`: when set to `false`, this app is disabled and passes through the original response.
30 |
31 | - `defaultTtl`: The default TTL (seconds) to use for the response. This will be used by clients to cache negative response.
32 |
33 | - `bypassLocalZones`: when set to `true`, authoritative answers are passed through unmodified.
34 |
35 | - `bypassNetworks`: a list of networks. If a request originates from a client in any of the specified networks, the original response is passed through unmodified.
36 |
37 | - `bypassDomains` a list of domain names. If a request is for a domain in this list, the original response is passed through unmodified. This includes subdomains of the domains in `bypassDomains`, i.e. `example.com` also matches `subdomain.example.com`.
38 |
39 | - `filterDomains` a list of domain names. If the list of filtered domain names is specified then the app will filter AAAA responses only for the specified domain names and their subdomain names. When the list is empty then the app will filter AAAA responses for all domain names.
40 |
41 | ## Post-processing
42 |
43 | The app processes any response which matches all of the following criteria:
44 |
45 | - the response has a `NoError` response code
46 | - the query type is `AAAA`
47 | - the response contains at least one `AAAA` record
48 | - the request / response pair is not excluded by any configuration setting
49 | - a lookup for an up `A` record for the same domain is successful and returns an address
50 |
51 | Note that this means that `NXDOMAIN`, `SERVFAIL`, and `NODATA` responses are left unmodified.
52 |
53 | The matching responses are replaced by one which includes all the `CNAME` records from the original response and a `SOA` record, but no `AAAA` record.
54 |
--------------------------------------------------------------------------------
/Apps/FilterAaaaApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "enableFilterAaaa": true,
3 | "defaultTtl": 30,
4 | "bypassLocalZones": false,
5 | "bypassNetworks": [
6 | ],
7 | "bypassDomains": [
8 | "example.com"
9 | ],
10 | "filterDomains": [
11 | ]
12 | }
--------------------------------------------------------------------------------
/Apps/GeoContinentApp/GeoContinentApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | true
7 | 8.1
8 | false
9 | Technitium
10 | Technitium DNS Server
11 | Shreyas Zare
12 | GeoContinentApp
13 | GeoContinent
14 | https://technitium.com/dns/
15 | https://github.com/TechnitiumSoftware/DnsServer
16 | Allows creating APP records in primary and forwarder zones that can return A or AAAA records, or CNAME record based on the continent the client queries from using MaxMind GeoIP2 Country database. Supports EDNS Client Subnet (ECS). This app requires MaxMind GeoIP2 database and includes the GeoLite2 version for trial. \n\nTo update the MaxMind GeoIP2 database for your app, download the GeoIP2-Country.mmdb file from MaxMind and zip it. Use the zip file with the manual Update option. The app optionally also uses MaxMind ISP/ASN database which can be updated the with same method.
17 | false
18 | Library
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | false
28 |
29 |
30 |
31 |
32 |
33 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
34 | false
35 |
36 |
37 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
38 | false
39 |
40 |
41 |
42 |
43 |
44 | PreserveNewest
45 |
46 |
47 | PreserveNewest
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/Apps/GeoContinentApp/ReadMe.txt:
--------------------------------------------------------------------------------
1 | Using MaxMind GeoIP2 Database
2 | =============================
3 |
4 | This app requires MaxMind GeoIP2 database and includes the GeoLite2 version for trial.
5 |
6 | For production usage, it is required that you purchase the GeoIP2 database from MaxMind (https://www.maxmind.com/) and use it.
7 |
8 | To update the MaxMind GeoIP2 database for your app, download the GeoIP2-Country.mmdb file and zip it. Use the zip file with the manual Update option.
9 |
10 | The app optionally also uses MaxMind ISP/ASN database which can be updated the with same method as above.
--------------------------------------------------------------------------------
/Apps/GeoContinentApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | #This app requires no config.
--------------------------------------------------------------------------------
/Apps/GeoCountryApp/GeoCountryApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | true
7 | 8.1
8 | false
9 | Technitium
10 | Technitium DNS Server
11 | Shreyas Zare
12 | GeoCountryApp
13 | GeoCountry
14 | https://technitium.com/dns/
15 | https://github.com/TechnitiumSoftware/DnsServer
16 | Allows creating APP records in primary and forwarder zones that can return A or AAAA records, or CNAME record based on the country the client queries from using MaxMind GeoIP2 Country database. Supports EDNS Client Subnet (ECS). This app requires MaxMind GeoIP2 database and includes the GeoLite2 version for trial. \n\nTo update the MaxMind GeoIP2 database for your app, download the GeoIP2-Country.mmdb file from MaxMind and zip it. Use the zip file with the manual Update option. The app optionally also uses MaxMind ISP/ASN database which can be updated the with same method.
17 | false
18 | Library
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | false
28 |
29 |
30 |
31 |
32 |
33 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
34 | false
35 |
36 |
37 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
38 | false
39 |
40 |
41 |
42 |
43 |
44 | PreserveNewest
45 |
46 |
47 | PreserveNewest
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/Apps/GeoCountryApp/ReadMe.txt:
--------------------------------------------------------------------------------
1 | Using MaxMind GeoIP2 Database
2 | =============================
3 |
4 | This app requires MaxMind GeoIP2 database and includes the GeoLite2 version for trial.
5 |
6 | For production usage, it is required that you purchase the GeoIP2 database from MaxMind (https://www.maxmind.com/) and use it.
7 |
8 | To update the MaxMind GeoIP2 database for your app, download the GeoIP2-Country.mmdb file and zip it. Use the zip file with the manual Update option.
9 |
10 | The app optionally also uses MaxMind ISP/ASN database which can be updated the with same method as above.
--------------------------------------------------------------------------------
/Apps/GeoCountryApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | #This app requires no config.
--------------------------------------------------------------------------------
/Apps/GeoDistanceApp/GeoDistanceApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | true
7 | 8.0
8 | false
9 | Technitium
10 | Technitium DNS Server
11 | Shreyas Zare
12 | GeoDistanceApp
13 | GeoDistance
14 | https://technitium.com/dns/
15 | https://github.com/TechnitiumSoftware/DnsServer
16 | Allows creating APP records in primary and forwarder zones that can return A or AAAA records, or CNAME record of the server located geographically closest to the client using MaxMind GeoIP2 City database. Supports EDNS Client Subnet (ECS). This app requires MaxMind GeoIP2 database and includes the GeoLite2 version for trial. \n\nTo update the MaxMind GeoIP2 database for your app, download the GeoIP2-City.mmdb file from MaxMind and zip it. Use the zip file with the manual Update option. The app optionally also uses MaxMind ISP/ASN database which can be updated the with same method.
17 | false
18 | Library
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | false
28 |
29 |
30 |
31 |
32 |
33 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
34 | false
35 |
36 |
37 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
38 | false
39 |
40 |
41 |
42 |
43 |
44 | PreserveNewest
45 |
46 |
47 | PreserveNewest
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/Apps/GeoDistanceApp/ReadMe.txt:
--------------------------------------------------------------------------------
1 | Using MaxMind GeoIP2 Database
2 | =============================
3 |
4 | WARNING: Latitude and longitude are not precise and should not be used to identify a particular street address or household.
5 |
6 | This app requires MaxMind GeoIP2 database and includes the GeoLite2 version for trial.
7 |
8 | For production usage, it is required that you purchase the GeoIP2 database from MaxMind (https://www.maxmind.com/) and use it.
9 |
10 | To update the MaxMind GeoIP2 database for your app, download the GeoIP2-City.mmdb file and zip it. Use the zip file with the manual Update option.
11 |
12 | The app optionally also uses MaxMind ISP/ASN database which can be updated the with same method as above.
--------------------------------------------------------------------------------
/Apps/GeoDistanceApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | #This app requires no config.
--------------------------------------------------------------------------------
/Apps/LogExporterApp/LogExporterApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | true
7 | 1.0.2
8 | false
9 | Technitium
10 | Technitium DNS Server
11 | Zafer Balkan
12 | LogExporterApp
13 | LogExporter
14 | https://technitium.com/dns/
15 | https://github.com/TechnitiumSoftware/DnsServer
16 | Allows exporting query logs to third party sinks. It supports exporting to File, HTTP endpoint, and Syslog (UDP, TCP, TLS, and Local protocols).
17 | false
18 | Library
19 | enable
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | false
33 |
34 |
35 |
36 |
37 |
38 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
39 | false
40 |
41 |
42 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
43 | false
44 |
45 |
46 |
47 |
48 |
49 | PreserveNewest
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/Apps/LogExporterApp/Strategy/ExportManager.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2025 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.Collections.Concurrent;
22 | using System.Collections.Generic;
23 | using System.Threading;
24 | using System.Threading.Tasks;
25 |
26 | namespace LogExporter.Strategy
27 | {
28 | public sealed class ExportManager : IDisposable
29 | {
30 | #region variables
31 |
32 | readonly ConcurrentDictionary _exportStrategies = new ConcurrentDictionary();
33 |
34 | #endregion
35 |
36 | #region IDisposable
37 |
38 | public void Dispose()
39 | {
40 | foreach (KeyValuePair exportStrategy in _exportStrategies)
41 | exportStrategy.Value.Dispose();
42 | }
43 |
44 | #endregion
45 |
46 | #region public
47 |
48 | public void AddStrategy(IExportStrategy strategy)
49 | {
50 | if (!_exportStrategies.TryAdd(strategy.GetType(), strategy))
51 | throw new InvalidOperationException();
52 | }
53 |
54 | public void RemoveStrategy(Type type)
55 | {
56 | if (_exportStrategies.TryRemove(type, out IExportStrategy? existing))
57 | existing?.Dispose();
58 | }
59 |
60 | public bool HasStrategy()
61 | {
62 | return !_exportStrategies.IsEmpty;
63 | }
64 |
65 | public async Task ImplementStrategyAsync(IReadOnlyList logs)
66 | {
67 | List tasks = new List(_exportStrategies.Count);
68 |
69 | foreach (KeyValuePair strategy in _exportStrategies)
70 | {
71 | tasks.Add(Task.Factory.StartNew(delegate (object? state)
72 | {
73 | return strategy.Value.ExportAsync(logs);
74 | }, null, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Current));
75 | }
76 |
77 | await Task.WhenAll(tasks);
78 | }
79 |
80 | #endregion
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Apps/LogExporterApp/Strategy/FileExportStrategy.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2025 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using Serilog;
21 | using System.Collections.Generic;
22 | using System.Threading.Tasks;
23 |
24 | namespace LogExporter.Strategy
25 | {
26 | public sealed class FileExportStrategy : IExportStrategy
27 | {
28 | #region variables
29 |
30 | readonly Serilog.Core.Logger _sender;
31 |
32 | bool _disposed;
33 |
34 | #endregion
35 |
36 | #region constructor
37 |
38 | public FileExportStrategy(string filePath)
39 | {
40 | _sender = new LoggerConfiguration().WriteTo.File(filePath, outputTemplate: "{Message:lj}{NewLine}{Exception}").CreateLogger();
41 | }
42 |
43 | #endregion
44 |
45 | #region IDisposable
46 |
47 | public void Dispose()
48 | {
49 | if (!_disposed)
50 | {
51 | _sender.Dispose();
52 |
53 | _disposed = true;
54 | }
55 | }
56 |
57 | #endregion
58 |
59 | #region public
60 |
61 | public Task ExportAsync(IReadOnlyList logs)
62 | {
63 | foreach (LogEntry logEntry in logs)
64 | _sender.Information(logEntry.ToString());
65 |
66 | return Task.CompletedTask;
67 | }
68 |
69 | #endregion
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Apps/LogExporterApp/Strategy/IExportStrategy.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2025 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.Collections.Generic;
22 | using System.Threading.Tasks;
23 |
24 | namespace LogExporter.Strategy
25 | {
26 | ///
27 | /// Strategy interface to decide the sinks for exporting the logs.
28 | ///
29 | public interface IExportStrategy: IDisposable
30 | {
31 | Task ExportAsync(IReadOnlyList logs);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Apps/LogExporterApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "maxQueueSize": 1000000,
3 | "file": {
4 | "path": "./dns_logs.json",
5 | "enabled": false
6 | },
7 | "http": {
8 | "endpoint": "http://localhost:5000/logs",
9 | "headers": {
10 | "Authorization": "Bearer abc123"
11 | },
12 | "enabled": false
13 | },
14 | "syslog": {
15 | "address": "127.0.0.1",
16 | "port": 514,
17 | "protocol": "UDP",
18 | "enabled": false
19 | }
20 | }
--------------------------------------------------------------------------------
/Apps/NoDataApp/NoDataApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | 4.0
7 | false
8 | Technitium
9 | Technitium DNS Server
10 | Shreyas Zare
11 | NoDataApp
12 | NoData
13 | https://technitium.com/dns/
14 | https://github.com/TechnitiumSoftware/DnsServer
15 | Allows creating APP records in a conditional forwarder zone that can returns a NO DATA response for requests that match the configured query type (QTYPE) to allow blocking records.
16 | false
17 | Library
18 |
19 |
20 |
21 |
22 | false
23 |
24 |
25 |
26 |
27 |
28 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
29 | false
30 |
31 |
32 |
33 |
34 |
35 | PreserveNewest
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Apps/NoDataApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | #This app requires no config.
--------------------------------------------------------------------------------
/Apps/NxDomainApp/NxDomainApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | 6.1
7 | false
8 | Technitium
9 | Technitium DNS Server
10 | Shreyas Zare
11 | NxDomainApp
12 | NxDomain
13 | https://technitium.com/dns/
14 | https://github.com/TechnitiumSoftware/DnsServer
15 | Blocks configured domain names with a NX Domain response.
16 | false
17 | Library
18 |
19 |
20 |
21 |
22 | false
23 |
24 |
25 |
26 |
27 |
28 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
29 | false
30 |
31 |
32 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
33 | false
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Apps/NxDomainApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "appPreference": 20,
3 | "enableBlocking": true,
4 | "allowTxtBlockingReport": true,
5 | "blocked": [
6 | "use-application-dns.net",
7 | "mask.icloud.com",
8 | "mask-h2.icloud.com"
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/Apps/NxDomainOverrideApp/NxDomainOverrideApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | 2.0
7 | false
8 | Technitium
9 | Technitium DNS Server
10 | Shreyas Zare
11 | NxDomainOverrideApp
12 | NxDomainOverride
13 | https://technitium.com/dns/
14 | https://github.com/TechnitiumSoftware/DnsServer
15 | Overrides NX Domain response with custom A/AAAA record response for configured domain names.
16 | false
17 | Library
18 |
19 |
20 |
21 |
22 | false
23 |
24 |
25 |
26 |
27 |
28 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
29 | false
30 |
31 |
32 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
33 | false
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Apps/NxDomainOverrideApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "enableOverride": true,
3 | "defaultTtl": 300,
4 | "domainSetMap": {
5 | "*": ["set1"],
6 | "example.com": ["set1", "set2"]
7 | },
8 | "sets": [
9 | {
10 | "name": "set1",
11 | "addresses": [
12 | "192.168.10.1"
13 | ]
14 | },
15 | {
16 | "name": "set2",
17 | "addresses": [
18 | "1.2.3.4",
19 | "5.6.7.8"
20 | ]
21 | }
22 | ]
23 | }
24 |
--------------------------------------------------------------------------------
/Apps/QueryLogsMySqlApp/QueryLogsMySqlApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | true
7 | 2.0.1
8 | false
9 | Technitium
10 | Technitium DNS Server
11 | Shreyas Zare
12 | QueryLogsMySqlApp
13 | QueryLogsMySql
14 | https://technitium.com/dns/
15 | https://github.com/TechnitiumSoftware/DnsServer
16 | Logs all incoming DNS requests and their responses in a MySQL/MariaDB database that can be queried from the DNS Server web console.\n\nNote! You will need to create a user and grant all privileges on the database to the user so that the app will be able to access it. To do that run the following commands with the required database name and username on your mysql root prompt:\nCREATE USER 'user'@'%' IDENTIFIED BY 'password';\nGRANT ALL PRIVILEGES ON DatabaseName.* TO 'user'@'%';\n\nOnce the database is configured, edit the app's config to update the database name, connection string, and set enableLogging to true. The app will automatically create the required database schema for you and start logging queries once you save the config.
17 | false
18 | Library
19 | enable
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | false
29 |
30 |
31 |
32 |
33 |
34 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
35 | false
36 |
37 |
38 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
39 | True
40 |
41 |
42 |
43 |
44 |
45 | PreserveNewest
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Apps/QueryLogsMySqlApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "enableLogging": false,
3 | "maxQueueSize": 1000000,
4 | "maxLogDays": 0,
5 | "maxLogRecords": 0,
6 | "databaseName": "DnsQueryLogs",
7 | "connectionString": "Server=192.168.180.128; Port=3306; Uid=username; Pwd=password;"
8 | }
9 |
--------------------------------------------------------------------------------
/Apps/QueryLogsSqlServerApp/QueryLogsSqlServerApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | true
7 | 1.2.2
8 | false
9 | Technitium
10 | Technitium DNS Server
11 | Shreyas Zare
12 | QueryLogsSqlServerApp
13 | QueryLogsSqlServer
14 | https://technitium.com/dns/
15 | https://github.com/TechnitiumSoftware/DnsServer
16 | Logs all incoming DNS requests and their responses in a Microsoft SQL Server database that can be queried from the DNS Server web console.\n\nNote! You will need to create a database user, edit the database user properties and enable 'dbcreator' Server Role so that the app is able to create and initialize the database. Once the database is configured, edit the app's config to update the database name, connection string and set enableLogging to true. The app will automatically create the required database schema for you and start logging queries once you save the config.
17 | false
18 | Library
19 | enable
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | false
30 |
31 |
32 |
33 |
34 |
35 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
36 | false
37 |
38 |
39 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
40 | false
41 |
42 |
43 |
44 |
45 |
46 | PreserveNewest
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/Apps/QueryLogsSqlServerApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "enableLogging": false,
3 | "maxQueueSize": 1000000,
4 | "maxLogDays": 0,
5 | "maxLogRecords": 0,
6 | "databaseName": "DnsQueryLogs",
7 | "connectionString": "Data Source=tcp:192.168.10.101,1433; User ID=username; Password=password; TrustServerCertificate=true;"
8 | }
9 |
--------------------------------------------------------------------------------
/Apps/QueryLogsSqliteApp/QueryLogsSqliteApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | true
7 | 7.1
8 | false
9 | Technitium
10 | Technitium DNS Server
11 | Shreyas Zare
12 | QueryLogsSqliteApp
13 | QueryLogsSqlite
14 | https://technitium.com/dns/
15 | https://github.com/TechnitiumSoftware/DnsServer
16 | Logs all incoming DNS requests and their responses in a Sqlite database that can be queried from the DNS Server web console.\n\nNote! The query logging throughput is limited by the disk throughput on which the Sqlite db file is stored. This app is not recommended to be used with very high throughput (more than 20,000 requests/second).\n\nWarning! When 'enableVacuum' is set to 'true', the app will run 'VACUUM' command after deletion of records which will increase disk IO and may cause the app to not respond for a while. Its recommended to enable this feature periodically, only for a while as needed, to trim the db file size on disk.
17 | false
18 | Library
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | false
28 |
29 |
30 |
31 |
32 |
33 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
34 | false
35 |
36 |
37 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
38 | false
39 |
40 |
41 |
42 |
43 |
44 | PreserveNewest
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/Apps/QueryLogsSqliteApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "enableLogging": true,
3 | "maxQueueSize": 200000,
4 | "maxLogDays": 7,
5 | "maxLogRecords": 10000,
6 | "enableVacuum": false,
7 | "useInMemoryDb": false,
8 | "sqliteDbPath": "querylogs.db",
9 | "connectionString": "Data Source='{sqliteDbPath}'; Cache=Shared;"
10 | }
11 |
--------------------------------------------------------------------------------
/Apps/SplitHorizonApp/SplitHorizonApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | 8.1
7 | false
8 | Technitium
9 | Technitium DNS Server
10 | Shreyas Zare
11 | SplitHorizonApp
12 | SplitHorizon
13 | https://technitium.com/dns/
14 | https://github.com/TechnitiumSoftware/DnsServer
15 | Allows creating APP records in primary and forwarder zones that can return different set of A or AAAA records, or CNAME record for clients querying over public, private, or other specified networks.\n\nEnables Address Translation of IP addresses in a DNS response for A & AAAA type request based on the client's network address and the configured 1:1 translation.
16 | false
17 | Library
18 |
19 |
20 |
21 |
22 | false
23 |
24 |
25 |
26 |
27 |
28 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
29 | false
30 |
31 |
32 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
33 | false
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Apps/SplitHorizonApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "appPreference": 40,
3 | "networks": {
4 | "custom-networks": [
5 | "172.16.1.0/24",
6 | "172.16.10.0/24",
7 | "172.16.2.1"
8 | ]
9 | },
10 | "enableAddressTranslation": false,
11 | "networkGroupMap": {
12 | "10.0.0.0/8": "local1",
13 | "172.16.0.0/12": "local2",
14 | "192.168.0.0/16": "local3"
15 | },
16 | "groups": [
17 | {
18 | "name": "local1",
19 | "enabled": true,
20 | "translateReverseLookups": true,
21 | "externalToInternalTranslation": {
22 | "1.2.3.0/24": "10.0.0.0/24",
23 | "5.6.7.8": "10.0.0.5"
24 | }
25 | },
26 | {
27 | "name": "local2",
28 | "enabled": true,
29 | "translateReverseLookups": true,
30 | "externalToInternalTranslation": {
31 | "1.2.3.4": "172.16.0.4",
32 | "5.6.7.8": "172.16.0.5"
33 | }
34 | },
35 | {
36 | "name": "local3",
37 | "enabled": true,
38 | "translateReverseLookups": true,
39 | "externalToInternalTranslation": {
40 | "1.2.3.4": "192.168.0.4",
41 | "5.6.7.8": "192.168.0.5"
42 | }
43 | }
44 | ]
45 | }
46 |
--------------------------------------------------------------------------------
/Apps/WeightedRoundRobinApp/WeightedRoundRobinApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | 3.0
7 | false
8 | Technitium
9 | Technitium DNS Server
10 | Shreyas Zare
11 | WeightedRoundRobinApp
12 | WeightedRoundRobin
13 | https://technitium.com/dns/
14 | https://github.com/TechnitiumSoftware/DnsServer
15 | Allows creating APP records in primary and forwarder zones that can return A or AAAA records, or CNAME record using weighted round-robin load balancing.
16 | false
17 | Library
18 |
19 |
20 |
21 |
22 | false
23 |
24 |
25 |
26 |
27 |
28 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
29 | false
30 |
31 |
32 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
33 | false
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Apps/WeightedRoundRobinApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | #This app requires no config.
--------------------------------------------------------------------------------
/Apps/WhatIsMyDnsApp/WhatIsMyDnsApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | true
7 | 7.0
8 | false
9 | Technitium
10 | Technitium DNS Server
11 | Shreyas Zare
12 | WhatIsMyDnsApp
13 | WhatIsMyDns
14 | https://technitium.com/dns/
15 | https://github.com/TechnitiumSoftware/DnsServer
16 | Allows creating APP records in primary and forwarder zones that can return the IP address of the user's DNS Server for A, AAAA, and TXT queries.
17 | false
18 | Library
19 |
20 |
21 |
22 |
23 | false
24 |
25 |
26 |
27 |
28 |
29 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
30 | false
31 |
32 |
33 |
34 |
35 |
36 | PreserveNewest
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Apps/WhatIsMyDnsApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | #This app requires no config.
--------------------------------------------------------------------------------
/Apps/WildIpApp/WildIpApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | true
7 | 4.0
8 | false
9 | Technitium
10 | Technitium DNS Server
11 | Shreyas Zare
12 | WildIpApp
13 | WildIp
14 | https://technitium.com/dns/
15 | https://github.com/TechnitiumSoftware/DnsServer
16 | Allows creating APP records in primary and forwarder zones that can return the IP address embedded in the subdomain name for A and AAAA queries. It works similar to sslip.io.
17 | false
18 | Library
19 |
20 |
21 |
22 |
23 | false
24 |
25 |
26 |
27 |
28 |
29 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
30 | false
31 |
32 |
33 |
34 |
35 |
36 | PreserveNewest
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/Apps/WildIpApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | #This app requires no config.
--------------------------------------------------------------------------------
/Apps/ZoneAliasApp/ZoneAliasApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | 3.1
7 | false
8 | Technitium
9 | Technitium DNS Server
10 | Shreyas Zare
11 | ZoneAliasApp
12 | ZoneAlias
13 | https://technitium.com/dns/
14 | https://github.com/TechnitiumSoftware/DnsServer
15 | Allows configuring aliases for any zone (internal or external) such that they all return the same set of records.
16 | false
17 | Library
18 |
19 |
20 |
21 |
22 | false
23 |
24 |
25 |
26 |
27 |
28 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.dll
29 | false
30 |
31 |
32 | ..\..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
33 | false
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Apps/ZoneAliasApp/dnsApp.config:
--------------------------------------------------------------------------------
1 | {
2 | "appPreference": 10,
3 | "enableAliasing": true,
4 | "zoneAliases": {
5 | "example.com": ["example.net", "example.org"]
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/DnsServerApp/DnsServerApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | false
5 | true
6 | Exe
7 | net8.0
8 | logo2.ico
9 | 13.6
10 | false
11 | Technitium
12 | Technitium DNS Server
13 | Shreyas Zare
14 | DnsServerApp
15 | DnsServerApp
16 | DnsServerApp.Program
17 | https://technitium.com/dns/
18 | https://github.com/TechnitiumSoftware/DnsServer
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | PreserveNewest
28 |
29 |
30 | PreserveNewest
31 |
32 |
33 | PreserveNewest
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/DnsServerApp/Properties/PublishProfiles/FolderProfile.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | FileSystem
8 | Release
9 | Any CPU
10 | net8.0
11 | bin\Release\publish\
12 | false
13 | <_IsPortable>true
14 |
15 |
--------------------------------------------------------------------------------
/DnsServerApp/logo2.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerApp/logo2.ico
--------------------------------------------------------------------------------
/DnsServerApp/start.bat:
--------------------------------------------------------------------------------
1 | dotnet DnsServerApp.dll
--------------------------------------------------------------------------------
/DnsServerApp/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | dotnet DnsServerApp.dll
4 |
--------------------------------------------------------------------------------
/DnsServerApp/systemd.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Technitium DNS Server
3 |
4 | [Service]
5 | WorkingDirectory=/opt/technitium/dns
6 | ExecStart=/usr/bin/dotnet /opt/technitium/dns/DnsServerApp.dll /etc/dns
7 | Restart=always
8 | # Restart service after 10 seconds if the dotnet service crashes:
9 | RestartSec=10
10 | KillSignal=SIGINT
11 | SyslogIdentifier=dns-server
12 |
13 | [Install]
14 | WantedBy=multi-user.target
15 |
--------------------------------------------------------------------------------
/DnsServerApp/uninstall.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | dotnetDir="/opt/dotnet"
4 |
5 | if [ -d "/etc/dns/config" ]
6 | then
7 | dnsDir="/etc/dns"
8 | else
9 | dnsDir="/opt/technitium/dns"
10 | fi
11 |
12 | echo ""
13 | echo "================================="
14 | echo "Technitium DNS Server Uninstaller"
15 | echo "================================="
16 | echo ""
17 | echo "Uninstalling Technitium DNS Server..."
18 |
19 | if [ -d $dnsDir ]
20 | then
21 | if [ "$(ps --no-headers -o comm 1 | tr -d '\n')" = "systemd" ]
22 | then
23 | sudo systemctl disable dns.service >/dev/null 2>&1
24 | sudo systemctl stop dns.service >/dev/null 2>&1
25 | rm /etc/systemd/system/dns.service >/dev/null 2>&1
26 |
27 | rm /etc/resolv.conf >/dev/null 2>&1
28 | echo "nameserver 8.8.8.8" >> /etc/resolv.conf
29 | echo "nameserver 1.1.1.1" >> /etc/resolv.conf
30 | fi
31 |
32 | rm -rf $dnsDir >/dev/null 2>&1
33 |
34 | if [ -d $dotnetDir ]
35 | then
36 | echo "Uninstalling .NET Runtime..."
37 | rm /usr/bin/dotnet >/dev/null 2>&1
38 | rm -rf $dotnetDir >/dev/null 2>&1
39 | fi
40 | fi
41 |
42 | echo ""
43 | echo "Thank you for using Technitium DNS Server!"
44 |
--------------------------------------------------------------------------------
/DnsServerCore.ApplicationCommon/DnsServerCore.ApplicationCommon.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | Shreyas Zare
7 | Technitium
8 | Technitium DNS Server
9 | https://technitium.com/dns/
10 | https://github.com/TechnitiumSoftware/DnsServer
11 |
12 |
13 | DnsServerCore.ApplicationCommon
14 | 8.1
15 | false
16 |
17 |
18 |
19 |
20 | ..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
21 | false
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/DnsServerCore.ApplicationCommon/IDnsAppRecordRequestHandler.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2023 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Net;
21 | using System.Threading.Tasks;
22 | using TechnitiumLibrary.Net.Dns;
23 |
24 | namespace DnsServerCore.ApplicationCommon
25 | {
26 | ///
27 | /// Allows a DNS App to handle incoming DNS requests for configured APP records in the DNS server zones.
28 | ///
29 | public interface IDnsAppRecordRequestHandler
30 | {
31 | ///
32 | /// Allows a DNS App to respond to the incoming DNS requests for an APP record in a primary or secondary zone.
33 | ///
34 | /// The incoming DNS request to be processed.
35 | /// The end point (IP address and port) of the client making the request.
36 | /// The protocol using which the request was received.
37 | /// Tells if the DNS server is configured to allow recursion for the client making this request.
38 | /// The name of the application zone that the APP record belongs to.
39 | /// The domain name of the APP record.
40 | /// The TTL value set in the APP record.
41 | /// The record data in the APP record as required for processing the request.
42 | /// The DNS response for the DNS request or null to send NODATA response when QNAME matches APP record name or else NXDOMAIN response with an SOA authority.
43 | Task ProcessRequestAsync(DnsDatagram request, IPEndPoint remoteEP, DnsTransportProtocol protocol, bool isRecursionAllowed, string zoneName, string appRecordName, uint appRecordTtl, string appRecordData);
44 |
45 | ///
46 | /// A template of the record data format that is required by this app. This template is populated in the UI to allow the user to edit in the expected values. The format could be JSON or any other custom text based format which the app is programmed to parse. This property is optional and can return null if no APP record data is required by the app.
47 | ///
48 | string ApplicationRecordDataTemplate { get; }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/DnsServerCore.ApplicationCommon/IDnsApplication.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2021 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.Threading.Tasks;
22 |
23 | namespace DnsServerCore.ApplicationCommon
24 | {
25 | ///
26 | /// Allows an application to initialize itself using the DNS app config.
27 | ///
28 | public interface IDnsApplication : IDisposable
29 | {
30 | ///
31 | /// Allows initializing the DNS application with a config. This function is also called when the config is updated to allow reloading.
32 | ///
33 | /// The DNS server interface object that allows access to DNS server properties.
34 | /// The DNS application config stored in the dnsApp.config file.
35 | Task InitializeAsync(IDnsServer dnsServer, string config);
36 |
37 | ///
38 | /// The description about this app to be shown in the Apps section of the DNS web console.
39 | ///
40 | string Description { get; }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/DnsServerCore.ApplicationCommon/IDnsApplicationPreference.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2025 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | namespace DnsServerCore.ApplicationCommon
21 | {
22 | ///
23 | /// Allows an application to specify a preference value to allow the DNS server to sort all installed apps in user preferred order to be used. If an application does not implement this interface then the default preference of 100 is assumed by the DNS server.
24 | ///
25 | public interface IDnsApplicationPreference
26 | {
27 | ///
28 | /// Returns the preference value configured for the application.
29 | ///
30 | byte Preference { get; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/DnsServerCore.ApplicationCommon/IDnsAuthoritativeRequestHandler.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2021 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Net;
21 | using System.Threading.Tasks;
22 | using TechnitiumLibrary.Net.Dns;
23 |
24 | namespace DnsServerCore.ApplicationCommon
25 | {
26 | ///
27 | /// Lets a DNS App to handle incoming requests for the DNS server's authoritative zone allowing it to act as an authoritative zone by itself and respond to any requests.
28 | ///
29 | public interface IDnsAuthoritativeRequestHandler
30 | {
31 | ///
32 | /// Allows a DNS App to respond to an incoming DNS request for the DNS server's authoritative zone. This method is called by the DNS Server's authoritative zone before querying its built in zone database. Response returned may be further processed to resolve CNAME or ANAME records, or referral response.
33 | ///
34 | /// The incoming DNS request to be processed.
35 | /// The end point (IP address and port) of the client making the request.
36 | /// The protocol using which the request was received.
37 | /// Tells if the DNS server is configured to allow recursion for the client making this request.
38 | /// The DNS response for the DNS request or null to let the DNS server core process the request as usual.
39 | Task ProcessRequestAsync(DnsDatagram request, IPEndPoint remoteEP, DnsTransportProtocol protocol, bool isRecursionAllowed);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/DnsServerCore.ApplicationCommon/IDnsPostProcessor.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2025 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Net;
21 | using System.Threading.Tasks;
22 | using TechnitiumLibrary.Net.Dns;
23 |
24 | namespace DnsServerCore.ApplicationCommon
25 | {
26 | ///
27 | /// Lets a DNS App process a response generated by the DNS server allowing it to make changes to the final response that will be sent to the client.
28 | ///
29 | public interface IDnsPostProcessor
30 | {
31 | ///
32 | /// Allows a DNS App to process the response generated by the DNS server for a given request. This method is called by the DNS Server after a response is generated before being sent to the client. Response returned by this method may be processed by another DNS app performing post processing.
33 | ///
34 | /// The incoming DNS request received by the DNS server.
35 | /// The end point (IP address and port) of the client making the request.
36 | /// The protocol using which the request was received.
37 | /// The DNS response that was generated by the DNS server for the received DNS request or from another DNS app that performed post processing.
38 | /// The DNS response that the DNS server should send to the client or null to drop the DNS request.
39 | Task PostProcessAsync(DnsDatagram request, IPEndPoint remoteEP, DnsTransportProtocol protocol, DnsDatagram response);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/DnsServerCore.ApplicationCommon/IDnsQueryLogger.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2025 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.Net;
22 | using System.Threading.Tasks;
23 | using TechnitiumLibrary.Net.Dns;
24 |
25 | namespace DnsServerCore.ApplicationCommon
26 | {
27 | public enum DnsServerResponseType : byte
28 | {
29 | Authoritative = 1,
30 | Recursive = 2,
31 | Cached = 3,
32 | Blocked = 4,
33 | UpstreamBlocked = 5,
34 | UpstreamBlockedCached = 6,
35 | Dropped = 7
36 | }
37 |
38 | ///
39 | /// Allows a DNS App to log incoming DNS requests and their corresponding responses.
40 | ///
41 | public interface IDnsQueryLogger
42 | {
43 | ///
44 | /// Allows a DNS App to log incoming DNS requests and responses. This method is called by the DNS Server after an incoming request is processed and a response is sent.
45 | ///
46 | /// The time stamp of the log entry.
47 | /// The incoming DNS request that was received.
48 | /// The end point (IP address and port) of the client making the request.
49 | /// The protocol using which the request was received.
50 | /// The DNS response that was sent.
51 | Task InsertLogAsync(DateTime timestamp, DnsDatagram request, IPEndPoint remoteEP, DnsTransportProtocol protocol, DnsDatagram response);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/DnsServerCore.ApplicationCommon/IDnsRequestBlockingHandler.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2023 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Net;
21 | using System.Threading.Tasks;
22 | using TechnitiumLibrary.Net.Dns;
23 |
24 | namespace DnsServerCore.ApplicationCommon
25 | {
26 | ///
27 | /// Lets DNS Apps provide DNS level domain name blocking feature.
28 | ///
29 | public interface IDnsRequestBlockingHandler
30 | {
31 | ///
32 | /// Specifies if the query domain name in the incoming DNS request is allowed to bypass any configured block lists (including for DNS server's built-in blocking feature).
33 | ///
34 | /// The incoming DNS request to be processed.
35 | /// The end point (IP address and port) of the client making the request.
36 | /// Returns true if the query domain name in the incoming DNS request is allowed to bypass blocking.
37 | Task IsAllowedAsync(DnsDatagram request, IPEndPoint remoteEP);
38 |
39 | ///
40 | /// Specifies if the query domain name in the incoming DNS request is blocked based on the app's own configured block lists.
41 | ///
42 | /// The incoming DNS request to be processed.
43 | /// The end point (IP address and port) of the client making the request.
44 | /// The blocked DNS response for the DNS request or null to let the DNS server core process the request as usual.
45 | Task ProcessRequestAsync(DnsDatagram request, IPEndPoint remoteEP);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/DnsServerCore.ApplicationCommon/IDnsRequestController.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2021 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Net;
21 | using System.Threading.Tasks;
22 | using TechnitiumLibrary.Net.Dns;
23 |
24 | namespace DnsServerCore.ApplicationCommon
25 | {
26 | public enum DnsRequestControllerAction
27 | {
28 | ///
29 | /// Allow the request to be processed.
30 | ///
31 | Allow = 0,
32 |
33 | ///
34 | /// Drop the request without any response.
35 | ///
36 | DropSilently = 1,
37 |
38 | ///
39 | /// Drop the request with a Refused response.
40 | ///
41 | DropWithRefused = 2
42 | }
43 |
44 | ///
45 | /// Allows a DNS App to inspect and optionally drop incoming DNS requests before they are processed by the DNS Server core.
46 | ///
47 | public interface IDnsRequestController
48 | {
49 | ///
50 | /// Allows a DNS App to inspect an incoming DNS request and decide whether to allow or drop it. This method is called by the DNS Server before an incoming request is processed.
51 | ///
52 | /// The incoming DNS request.
53 | /// The end point (IP address and port) of the client making the request.
54 | /// The protocol using which the request was received.
55 | /// The action that must be taken by the DNS server i.e. if the request must be allowed or dropped.
56 | Task GetRequestActionAsync(DnsDatagram request, IPEndPoint remoteEP, DnsTransportProtocol protocol);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/DhcpServerException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 |
22 | namespace DnsServerCore.Dhcp
23 | {
24 | public class DhcpServerException : Exception
25 | {
26 | #region constructors
27 |
28 | public DhcpServerException()
29 | : base()
30 | { }
31 |
32 | public DhcpServerException(string message)
33 | : base(message)
34 | { }
35 |
36 | public DhcpServerException(string message, Exception innerException)
37 | : base(message, innerException)
38 | { }
39 |
40 | #endregion
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Exclusion.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2021 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.Net;
22 | using TechnitiumLibrary.Net;
23 |
24 | namespace DnsServerCore.Dhcp
25 | {
26 | public class Exclusion
27 | {
28 | #region variables
29 |
30 | readonly IPAddress _startingAddress;
31 | readonly IPAddress _endingAddress;
32 |
33 | #endregion
34 |
35 | #region constructor
36 |
37 | public Exclusion(IPAddress startingAddress, IPAddress endingAddress)
38 | {
39 | if (startingAddress.ConvertIpToNumber() > endingAddress.ConvertIpToNumber())
40 | throw new ArgumentException("Exclusion ending address must be greater than or equal to starting address.");
41 |
42 | _startingAddress = startingAddress;
43 | _endingAddress = endingAddress;
44 | }
45 |
46 | #endregion
47 |
48 | #region properties
49 |
50 | public IPAddress StartingAddress
51 | { get { return _startingAddress; } }
52 |
53 | public IPAddress EndingAddress
54 | { get { return _endingAddress; } }
55 |
56 | #endregion
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/BroadcastAddressOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.IO;
21 | using System.Net;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace DnsServerCore.Dhcp.Options
25 | {
26 | class BroadcastAddressOption : DhcpOption
27 | {
28 | #region variables
29 |
30 | IPAddress _broadcastAddress;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public BroadcastAddressOption(IPAddress broadcastAddress)
37 | : base(DhcpOptionCode.BroadcastAddress)
38 | {
39 | _broadcastAddress = broadcastAddress;
40 | }
41 |
42 | public BroadcastAddressOption(Stream s)
43 | : base(DhcpOptionCode.BroadcastAddress, s)
44 | { }
45 |
46 | #endregion
47 |
48 | #region protected
49 |
50 | protected override void ParseOptionValue(Stream s)
51 | {
52 | if (s.Length != 4)
53 | throw new InvalidDataException();
54 |
55 | _broadcastAddress = new IPAddress(s.ReadExactly(4));
56 |
57 | }
58 |
59 | protected override void WriteOptionValue(Stream s)
60 | {
61 | s.Write(_broadcastAddress.GetAddressBytes());
62 | }
63 |
64 | #endregion
65 |
66 | #region properties
67 |
68 | public IPAddress BroadcastAddress
69 | { get { return _broadcastAddress; } }
70 |
71 | #endregion
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/CAPWAPAccessControllerOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Collections.Generic;
21 | using System.IO;
22 | using System.Net;
23 | using TechnitiumLibrary.IO;
24 |
25 | namespace DnsServerCore.Dhcp.Options
26 | {
27 | class CAPWAPAccessControllerOption : DhcpOption
28 | {
29 | #region variables
30 |
31 | IReadOnlyCollection _apIpAddresses;
32 |
33 | #endregion
34 |
35 | #region constructor
36 |
37 | public CAPWAPAccessControllerOption(IReadOnlyCollection apIpAddresses)
38 | : base(DhcpOptionCode.CAPWAPAccessControllerAddresses)
39 | {
40 | _apIpAddresses = apIpAddresses;
41 | }
42 |
43 | public CAPWAPAccessControllerOption(Stream s)
44 | : base(DhcpOptionCode.CAPWAPAccessControllerAddresses, s)
45 | { }
46 |
47 | #endregion
48 |
49 | #region protected
50 |
51 | protected override void ParseOptionValue(Stream s)
52 | {
53 | if (s.Length < 1)
54 | throw new InvalidDataException();
55 |
56 | List apIpAddresses = new List();
57 |
58 | while (s.Length > 0)
59 | apIpAddresses.Add(new IPAddress(s.ReadExactly(4)));
60 |
61 | _apIpAddresses = apIpAddresses;
62 | }
63 |
64 | protected override void WriteOptionValue(Stream s)
65 | {
66 | foreach (IPAddress apIpAddress in _apIpAddresses)
67 | s.Write(apIpAddress.GetAddressBytes());
68 | }
69 |
70 | #endregion
71 |
72 | #region properties
73 |
74 | public IReadOnlyCollection ApIpAddresses
75 | { get { return _apIpAddresses; } }
76 |
77 | #endregion
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/DhcpMessageTypeOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2019 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.IO;
21 |
22 | namespace DnsServerCore.Dhcp.Options
23 | {
24 | enum DhcpMessageType : byte
25 | {
26 | Unknown = 0,
27 | Discover = 1,
28 | Offer = 2,
29 | Request = 3,
30 | Decline = 4,
31 | Ack = 5,
32 | Nak = 6,
33 | Release = 7,
34 | Inform = 8
35 | }
36 |
37 | class DhcpMessageTypeOption : DhcpOption
38 | {
39 | #region variables
40 |
41 | DhcpMessageType _type;
42 |
43 | #endregion
44 |
45 | #region constructor
46 |
47 | public DhcpMessageTypeOption(DhcpMessageType type)
48 | : base(DhcpOptionCode.DhcpMessageType)
49 | {
50 | _type = type;
51 | }
52 |
53 | public DhcpMessageTypeOption(Stream s)
54 | : base(DhcpOptionCode.DhcpMessageType, s)
55 | { }
56 |
57 | #endregion
58 |
59 | #region protected
60 |
61 | protected override void ParseOptionValue(Stream s)
62 | {
63 | if (s.Length != 1)
64 | throw new InvalidDataException();
65 |
66 | int type = s.ReadByte();
67 | if (type < 0)
68 | throw new EndOfStreamException();
69 |
70 | _type = (DhcpMessageType)type;
71 | }
72 |
73 | protected override void WriteOptionValue(Stream s)
74 | {
75 | s.WriteByte((byte)_type);
76 | }
77 |
78 | #endregion
79 |
80 | #region string
81 |
82 | public override string ToString()
83 | {
84 | return _type.ToString();
85 | }
86 |
87 | #endregion
88 |
89 | #region properties
90 |
91 | public DhcpMessageType Type
92 | { get { return _type; } }
93 |
94 | #endregion
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/DomainNameOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.IO;
21 | using System.Text;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace DnsServerCore.Dhcp.Options
25 | {
26 | class DomainNameOption : DhcpOption
27 | {
28 | #region variables
29 |
30 | string _domainName;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public DomainNameOption(string domainName)
37 | : base(DhcpOptionCode.DomainName)
38 | {
39 | _domainName = domainName;
40 | }
41 |
42 | public DomainNameOption(Stream s)
43 | : base(DhcpOptionCode.DomainName, s)
44 | { }
45 |
46 | #endregion
47 |
48 | #region protected
49 |
50 | protected override void ParseOptionValue(Stream s)
51 | {
52 | if (s.Length < 1)
53 | throw new InvalidDataException();
54 |
55 | _domainName = Encoding.ASCII.GetString(s.ReadExactly((int)s.Length));
56 | }
57 |
58 | protected override void WriteOptionValue(Stream s)
59 | {
60 | s.Write(Encoding.ASCII.GetBytes(_domainName));
61 | }
62 |
63 | #endregion
64 |
65 | #region properties
66 |
67 | public string DomainName
68 | { get { return _domainName; } }
69 |
70 | #endregion
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/DomainNameServerOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Collections.Generic;
21 | using System.IO;
22 | using System.Net;
23 | using TechnitiumLibrary.IO;
24 |
25 | namespace DnsServerCore.Dhcp.Options
26 | {
27 | class DomainNameServerOption : DhcpOption
28 | {
29 | #region variables
30 |
31 | IReadOnlyCollection _addresses;
32 |
33 | #endregion
34 |
35 | #region constructor
36 |
37 | public DomainNameServerOption(IReadOnlyCollection addresses)
38 | : base(DhcpOptionCode.DomainNameServer)
39 | {
40 | _addresses = addresses;
41 | }
42 |
43 | public DomainNameServerOption(Stream s)
44 | : base(DhcpOptionCode.DomainNameServer, s)
45 | { }
46 |
47 | #endregion
48 |
49 | #region protected
50 |
51 | protected override void ParseOptionValue(Stream s)
52 | {
53 | if ((s.Length % 4 != 0) || (s.Length < 4))
54 | throw new InvalidDataException();
55 |
56 | IPAddress[] addresses = new IPAddress[s.Length / 4];
57 |
58 | for (int i = 0; i < addresses.Length; i++)
59 | addresses[i] = new IPAddress(s.ReadExactly(4));
60 |
61 | _addresses = addresses;
62 | }
63 |
64 | protected override void WriteOptionValue(Stream s)
65 | {
66 | foreach (IPAddress address in _addresses)
67 | s.Write(address.GetAddressBytes());
68 | }
69 |
70 | #endregion
71 |
72 | #region properties
73 |
74 | public IReadOnlyCollection Addresses
75 | { get { return _addresses; } }
76 |
77 | #endregion
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/DomainSearchOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2022 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Collections.Generic;
21 | using System.IO;
22 | using TechnitiumLibrary.Net.Dns;
23 |
24 | namespace DnsServerCore.Dhcp.Options
25 | {
26 | class DomainSearchOption : DhcpOption
27 | {
28 | #region variables
29 |
30 | IReadOnlyCollection _searchStrings;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public DomainSearchOption(IReadOnlyCollection searchStrings)
37 | : base(DhcpOptionCode.DomainSearch)
38 | {
39 | _searchStrings = searchStrings;
40 | }
41 |
42 | public DomainSearchOption(Stream s)
43 | : base(DhcpOptionCode.DomainSearch, s)
44 | { }
45 |
46 | #endregion
47 |
48 | #region protected
49 |
50 | protected override void ParseOptionValue(Stream s)
51 | {
52 | if (s.Length < 1)
53 | throw new InvalidDataException();
54 |
55 | List searchStrings = new List();
56 |
57 | while (s.Length > 0)
58 | searchStrings.Add(DnsDatagram.DeserializeDomainName(s));
59 |
60 | _searchStrings = searchStrings;
61 | }
62 |
63 | protected override void WriteOptionValue(Stream s)
64 | {
65 | List domainEntries = new List(1);
66 |
67 | foreach (string searchString in _searchStrings)
68 | DnsDatagram.SerializeDomainName(searchString, s, domainEntries);
69 | }
70 |
71 | #endregion
72 |
73 | #region properties
74 |
75 | public IReadOnlyCollection SearchStrings
76 | { get { return _searchStrings; } }
77 |
78 | #endregion
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/HostNameOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.IO;
21 | using System.Text;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace DnsServerCore.Dhcp.Options
25 | {
26 | class HostNameOption : DhcpOption
27 | {
28 | #region variables
29 |
30 | string _hostName;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public HostNameOption(string hostName)
37 | : base(DhcpOptionCode.HostName)
38 | {
39 | _hostName = hostName;
40 | }
41 |
42 | public HostNameOption(Stream s)
43 | : base(DhcpOptionCode.HostName, s)
44 | { }
45 |
46 | #endregion
47 |
48 | #region protected
49 |
50 | protected override void ParseOptionValue(Stream s)
51 | {
52 | if (s.Length < 1)
53 | throw new InvalidDataException();
54 |
55 | _hostName = Encoding.ASCII.GetString(s.ReadExactly((int)s.Length));
56 | }
57 |
58 | protected override void WriteOptionValue(Stream s)
59 | {
60 | s.Write(Encoding.ASCII.GetBytes(_hostName));
61 | }
62 |
63 | #endregion
64 |
65 | #region properties
66 |
67 | public string HostName
68 | { get { return _hostName; } }
69 |
70 | #endregion
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/IpAddressLeaseTimeOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.IO;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace DnsServerCore.Dhcp.Options
25 | {
26 | class IpAddressLeaseTimeOption : DhcpOption
27 | {
28 | #region variables
29 |
30 | uint _leaseTime;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public IpAddressLeaseTimeOption(uint leaseTime)
37 | : base(DhcpOptionCode.IpAddressLeaseTime)
38 | {
39 | _leaseTime = leaseTime;
40 | }
41 |
42 | public IpAddressLeaseTimeOption(Stream s)
43 | : base(DhcpOptionCode.IpAddressLeaseTime, s)
44 | { }
45 |
46 | #endregion
47 |
48 | #region protected
49 |
50 | protected override void ParseOptionValue(Stream s)
51 | {
52 | if (s.Length != 4)
53 | throw new InvalidDataException();
54 |
55 | byte[] buffer = s.ReadExactly(4);
56 | Array.Reverse(buffer);
57 | _leaseTime = BitConverter.ToUInt32(buffer, 0);
58 | }
59 |
60 | protected override void WriteOptionValue(Stream s)
61 | {
62 | byte[] buffer = BitConverter.GetBytes(_leaseTime);
63 | Array.Reverse(buffer);
64 | s.Write(buffer);
65 | }
66 |
67 | #endregion
68 |
69 | #region properties
70 |
71 | public uint LeaseTime
72 | { get { return _leaseTime; } }
73 |
74 | #endregion
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/MaximumDhcpMessageSizeOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.IO;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace DnsServerCore.Dhcp.Options
25 | {
26 | class MaximumDhcpMessageSizeOption : DhcpOption
27 | {
28 | #region variables
29 |
30 | ushort _length;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public MaximumDhcpMessageSizeOption(ushort length)
37 | : base(DhcpOptionCode.MaximumDhcpMessageSize)
38 | {
39 | if (length < 576)
40 | throw new ArgumentOutOfRangeException(nameof(length), "Length must be 576 bytes or more.");
41 |
42 | _length = length;
43 | }
44 |
45 | public MaximumDhcpMessageSizeOption(Stream s)
46 | : base(DhcpOptionCode.MaximumDhcpMessageSize, s)
47 | { }
48 |
49 | #endregion
50 |
51 | #region protected
52 |
53 | protected override void ParseOptionValue(Stream s)
54 | {
55 | if (s.Length != 2)
56 | throw new InvalidDataException();
57 |
58 | byte[] buffer = s.ReadExactly(2);
59 | Array.Reverse(buffer);
60 | _length = BitConverter.ToUInt16(buffer, 0);
61 |
62 | if (_length < 576)
63 | _length = 576;
64 | }
65 |
66 | protected override void WriteOptionValue(Stream s)
67 | {
68 | byte[] buffer = BitConverter.GetBytes(_length);
69 | Array.Reverse(buffer);
70 | s.Write(buffer);
71 | }
72 |
73 | #endregion
74 |
75 | #region properties
76 |
77 | public uint Length
78 | { get { return _length; } }
79 |
80 | #endregion
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/NetBiosNameServerOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Collections.Generic;
21 | using System.IO;
22 | using System.Net;
23 | using TechnitiumLibrary.IO;
24 |
25 | namespace DnsServerCore.Dhcp.Options
26 | {
27 | class NetBiosNameServerOption : DhcpOption
28 | {
29 | #region variables
30 |
31 | IReadOnlyCollection _addresses;
32 |
33 | #endregion
34 |
35 | #region constructor
36 |
37 | public NetBiosNameServerOption(IReadOnlyCollection addresses)
38 | : base(DhcpOptionCode.NetBiosOverTcpIpNameServer)
39 | {
40 | _addresses = addresses;
41 | }
42 |
43 | public NetBiosNameServerOption(Stream s)
44 | : base(DhcpOptionCode.NetBiosOverTcpIpNameServer, s)
45 | { }
46 |
47 | #endregion
48 |
49 | #region protected
50 |
51 | protected override void ParseOptionValue(Stream s)
52 | {
53 | if ((s.Length % 4 != 0) || (s.Length < 4))
54 | throw new InvalidDataException();
55 |
56 | IPAddress[] addresses = new IPAddress[s.Length / 4];
57 |
58 | for (int i = 0; i < addresses.Length; i++)
59 | addresses[i] = new IPAddress(s.ReadExactly(4));
60 |
61 | _addresses = addresses;
62 | }
63 |
64 | protected override void WriteOptionValue(Stream s)
65 | {
66 | foreach (IPAddress address in _addresses)
67 | s.Write(address.GetAddressBytes());
68 | }
69 |
70 | #endregion
71 |
72 | #region properties
73 |
74 | public IReadOnlyCollection Addresses
75 | { get { return _addresses; } }
76 |
77 | #endregion
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/NetworkTimeProtocolServersOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Collections.Generic;
21 | using System.IO;
22 | using System.Net;
23 | using TechnitiumLibrary.IO;
24 |
25 | namespace DnsServerCore.Dhcp.Options
26 | {
27 | class NetworkTimeProtocolServersOption : DhcpOption
28 | {
29 | #region variables
30 |
31 | IReadOnlyCollection _addresses;
32 |
33 | #endregion
34 |
35 | #region constructor
36 |
37 | public NetworkTimeProtocolServersOption(IReadOnlyCollection addresses)
38 | : base(DhcpOptionCode.NetworkTimeProtocolServers)
39 | {
40 | _addresses = addresses;
41 | }
42 |
43 | public NetworkTimeProtocolServersOption(Stream s)
44 | : base(DhcpOptionCode.NetworkTimeProtocolServers, s)
45 | { }
46 |
47 | #endregion
48 |
49 | #region protected
50 |
51 | protected override void ParseOptionValue(Stream s)
52 | {
53 | if ((s.Length % 4 != 0) || (s.Length < 4))
54 | throw new InvalidDataException();
55 |
56 | IPAddress[] addresses = new IPAddress[s.Length / 4];
57 |
58 | for (int i = 0; i < addresses.Length; i++)
59 | addresses[i] = new IPAddress(s.ReadExactly(4));
60 |
61 | _addresses = addresses;
62 | }
63 |
64 | protected override void WriteOptionValue(Stream s)
65 | {
66 | foreach (IPAddress address in _addresses)
67 | s.Write(address.GetAddressBytes());
68 | }
69 |
70 | #endregion
71 |
72 | #region properties
73 |
74 | public IReadOnlyCollection Addresses
75 | { get { return _addresses; } }
76 |
77 | #endregion
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/OptionOverloadOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2021 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.IO;
22 |
23 | namespace DnsServerCore.Dhcp.Options
24 | {
25 | [Flags]
26 | enum OptionOverloadValue : byte
27 | {
28 | FileFieldUsed = 1,
29 | SnameFieldUsed = 2,
30 | BothFieldsUsed = 3
31 | }
32 |
33 | class OptionOverloadOption : DhcpOption
34 | {
35 | #region variables
36 |
37 | OptionOverloadValue _value;
38 |
39 | #endregion
40 |
41 | #region constructor
42 |
43 | public OptionOverloadOption(OptionOverloadValue value)
44 | : base(DhcpOptionCode.OptionOverload)
45 | {
46 | _value = value;
47 | }
48 |
49 | public OptionOverloadOption(Stream s)
50 | : base(DhcpOptionCode.OptionOverload, s)
51 | { }
52 |
53 | #endregion
54 |
55 | #region protected
56 |
57 | protected override void ParseOptionValue(Stream s)
58 | {
59 | if (s.Length != 1)
60 | throw new InvalidDataException();
61 |
62 | int value = s.ReadByte();
63 | if (value < 0)
64 | throw new EndOfStreamException();
65 |
66 | _value = (OptionOverloadValue)value;
67 | }
68 |
69 | protected override void WriteOptionValue(Stream s)
70 | {
71 | s.WriteByte((byte)_value);
72 | }
73 |
74 | #endregion
75 |
76 | #region properties
77 |
78 | public OptionOverloadValue Value
79 | { get { return _value; } }
80 |
81 | #endregion
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/ParameterRequestListOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2019 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.IO;
21 |
22 | namespace DnsServerCore.Dhcp.Options
23 | {
24 | class ParameterRequestListOption : DhcpOption
25 | {
26 | #region variables
27 |
28 | DhcpOptionCode[] _optionCodes;
29 |
30 | #endregion
31 |
32 | #region constructor
33 |
34 | public ParameterRequestListOption(DhcpOptionCode[] optionCodes)
35 | : base(DhcpOptionCode.ParameterRequestList)
36 | {
37 | _optionCodes = optionCodes;
38 | }
39 |
40 | public ParameterRequestListOption(Stream s)
41 | : base(DhcpOptionCode.ParameterRequestList, s)
42 | { }
43 |
44 | #endregion
45 |
46 | #region protected
47 |
48 | protected override void ParseOptionValue(Stream s)
49 | {
50 | if (s.Length < 1)
51 | throw new InvalidDataException();
52 |
53 | _optionCodes = new DhcpOptionCode[s.Length];
54 | int optionCode;
55 |
56 | for (int i = 0; i < _optionCodes.Length; i++)
57 | {
58 | optionCode = s.ReadByte();
59 | if (optionCode < 0)
60 | throw new EndOfStreamException();
61 |
62 | _optionCodes[i] = (DhcpOptionCode)optionCode;
63 | }
64 | }
65 |
66 | protected override void WriteOptionValue(Stream s)
67 | {
68 | foreach (DhcpOptionCode optionCode in _optionCodes)
69 | s.WriteByte((byte)optionCode);
70 | }
71 |
72 | #endregion
73 |
74 | #region properties
75 |
76 | public DhcpOptionCode[] OptionCodes
77 | { get { return _optionCodes; } }
78 |
79 | #endregion
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/RebindingTimeValueOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.IO;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace DnsServerCore.Dhcp.Options
25 | {
26 | class RebindingTimeValueOption : DhcpOption
27 | {
28 | #region variables
29 |
30 | uint _t2Interval;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public RebindingTimeValueOption(uint t2Interval)
37 | : base(DhcpOptionCode.RebindingTimeValue)
38 | {
39 | _t2Interval = t2Interval;
40 | }
41 |
42 | public RebindingTimeValueOption(Stream s)
43 | : base(DhcpOptionCode.RebindingTimeValue, s)
44 | { }
45 |
46 | #endregion
47 |
48 | #region protected
49 |
50 | protected override void ParseOptionValue(Stream s)
51 | {
52 | if (s.Length != 4)
53 | throw new InvalidDataException();
54 |
55 | byte[] buffer = s.ReadExactly(4);
56 | Array.Reverse(buffer);
57 | _t2Interval = BitConverter.ToUInt32(buffer, 0);
58 | }
59 |
60 | protected override void WriteOptionValue(Stream s)
61 | {
62 | byte[] buffer = BitConverter.GetBytes(_t2Interval);
63 | Array.Reverse(buffer);
64 | s.Write(buffer);
65 | }
66 |
67 | #endregion
68 |
69 | #region properties
70 |
71 | public uint T2Interval
72 | { get { return _t2Interval; } }
73 |
74 | #endregion
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/RenewalTimeValueOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.IO;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace DnsServerCore.Dhcp.Options
25 | {
26 | class RenewalTimeValueOption : DhcpOption
27 | {
28 | #region variables
29 |
30 | uint _t1Interval;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public RenewalTimeValueOption(uint t1Interval)
37 | : base(DhcpOptionCode.RenewalTimeValue)
38 | {
39 | _t1Interval = t1Interval;
40 | }
41 |
42 | public RenewalTimeValueOption(Stream s)
43 | : base(DhcpOptionCode.RenewalTimeValue, s)
44 | { }
45 |
46 | #endregion
47 |
48 | #region protected
49 |
50 | protected override void ParseOptionValue(Stream s)
51 | {
52 | if (s.Length != 4)
53 | throw new InvalidDataException();
54 |
55 | byte[] buffer = s.ReadExactly(4);
56 | Array.Reverse(buffer);
57 | _t1Interval = BitConverter.ToUInt32(buffer, 0);
58 | }
59 |
60 | protected override void WriteOptionValue(Stream s)
61 | {
62 | byte[] buffer = BitConverter.GetBytes(_t1Interval);
63 | Array.Reverse(buffer);
64 | s.Write(buffer);
65 | }
66 |
67 | #endregion
68 |
69 | #region properties
70 |
71 | public uint T1Interval
72 | { get { return _t1Interval; } }
73 |
74 | #endregion
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/RequestedIpAddressOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.IO;
21 | using System.Net;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace DnsServerCore.Dhcp.Options
25 | {
26 | class RequestedIpAddressOption : DhcpOption
27 | {
28 | #region variables
29 |
30 | IPAddress _address;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public RequestedIpAddressOption(IPAddress address)
37 | : base(DhcpOptionCode.RequestedIpAddress)
38 | {
39 | _address = address;
40 | }
41 |
42 | public RequestedIpAddressOption(Stream s)
43 | : base(DhcpOptionCode.RequestedIpAddress, s)
44 | { }
45 |
46 | #endregion
47 |
48 | #region protected
49 |
50 | protected override void ParseOptionValue(Stream s)
51 | {
52 | if (s.Length != 4)
53 | throw new InvalidDataException();
54 |
55 | _address = new IPAddress(s.ReadExactly(4));
56 | }
57 |
58 | protected override void WriteOptionValue(Stream s)
59 | {
60 | s.Write(_address.GetAddressBytes());
61 | }
62 |
63 | #endregion
64 |
65 | #region properties
66 |
67 | public IPAddress Address
68 | { get { return _address; } }
69 |
70 | #endregion
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/RouterOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.IO;
21 | using System.Net;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace DnsServerCore.Dhcp.Options
25 | {
26 | class RouterOption : DhcpOption
27 | {
28 | #region variables
29 |
30 | IPAddress[] _addresses;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public RouterOption(IPAddress[] addresses)
37 | : base(DhcpOptionCode.Router)
38 | {
39 | _addresses = addresses;
40 | }
41 |
42 | public RouterOption(Stream s)
43 | : base(DhcpOptionCode.Router, s)
44 | { }
45 |
46 | #endregion
47 |
48 | #region protected
49 |
50 | protected override void ParseOptionValue(Stream s)
51 | {
52 | if ((s.Length % 4 != 0) || (s.Length < 4))
53 | throw new InvalidDataException();
54 |
55 | _addresses = new IPAddress[s.Length / 4];
56 |
57 | for (int i = 0; i < _addresses.Length; i++)
58 | _addresses[i] = new IPAddress(s.ReadExactly(4));
59 | }
60 |
61 | protected override void WriteOptionValue(Stream s)
62 | {
63 | foreach (IPAddress address in _addresses)
64 | s.Write(address.GetAddressBytes());
65 | }
66 |
67 | #endregion
68 |
69 | #region properties
70 |
71 | public IPAddress[] Addresses
72 | { get { return _addresses; } }
73 |
74 | #endregion
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/ServerIdentifierOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.IO;
21 | using System.Net;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace DnsServerCore.Dhcp.Options
25 | {
26 | class ServerIdentifierOption : DhcpOption
27 | {
28 | #region variables
29 |
30 | IPAddress _address;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public ServerIdentifierOption(IPAddress address)
37 | : base(DhcpOptionCode.ServerIdentifier)
38 | {
39 | _address = address;
40 | }
41 |
42 | public ServerIdentifierOption(Stream s)
43 | : base(DhcpOptionCode.ServerIdentifier, s)
44 | { }
45 |
46 | #endregion
47 |
48 | #region protected
49 |
50 | protected override void ParseOptionValue(Stream s)
51 | {
52 | if (s.Length != 4)
53 | throw new InvalidDataException();
54 |
55 | _address = new IPAddress(s.ReadExactly(4));
56 | }
57 |
58 | protected override void WriteOptionValue(Stream s)
59 | {
60 | s.Write(_address.GetAddressBytes());
61 | }
62 |
63 | #endregion
64 |
65 | #region properties
66 |
67 | public IPAddress Address
68 | { get { return _address; } }
69 |
70 | #endregion
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/SubnetMaskOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.IO;
21 | using System.Net;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace DnsServerCore.Dhcp.Options
25 | {
26 | class SubnetMaskOption : DhcpOption
27 | {
28 | #region variables
29 |
30 | IPAddress _subnetMask;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public SubnetMaskOption(IPAddress subnetMask)
37 | : base(DhcpOptionCode.SubnetMask)
38 | {
39 | _subnetMask = subnetMask;
40 | }
41 |
42 | public SubnetMaskOption(Stream s)
43 | : base(DhcpOptionCode.SubnetMask, s)
44 | { }
45 |
46 | #endregion
47 |
48 | #region protected
49 |
50 | protected override void ParseOptionValue(Stream s)
51 | {
52 | if (s.Length != 4)
53 | throw new InvalidDataException();
54 |
55 | _subnetMask = new IPAddress(s.ReadExactly(4));
56 | }
57 |
58 | protected override void WriteOptionValue(Stream s)
59 | {
60 | s.Write(_subnetMask.GetAddressBytes());
61 | }
62 |
63 | #endregion
64 |
65 | #region properties
66 |
67 | public IPAddress SubnetMask
68 | { get { return _subnetMask; } }
69 |
70 | #endregion
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/TftpServerAddressOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Collections.Generic;
21 | using System.IO;
22 | using System.Net;
23 | using TechnitiumLibrary.IO;
24 |
25 | namespace DnsServerCore.Dhcp.Options
26 | {
27 | class TftpServerAddressOption : DhcpOption
28 | {
29 | #region variables
30 |
31 | IReadOnlyCollection _addresses;
32 |
33 | #endregion
34 |
35 | #region constructor
36 |
37 | public TftpServerAddressOption(IReadOnlyCollection addresses)
38 | : base(DhcpOptionCode.TftpServerAddress)
39 | {
40 | _addresses = addresses;
41 | }
42 |
43 | public TftpServerAddressOption(Stream s)
44 | : base(DhcpOptionCode.TftpServerAddress, s)
45 | { }
46 |
47 | #endregion
48 |
49 | #region protected
50 |
51 | protected override void ParseOptionValue(Stream s)
52 | {
53 | if ((s.Length % 4 != 0) || (s.Length < 4))
54 | throw new InvalidDataException();
55 |
56 | IPAddress[] addresses = new IPAddress[s.Length / 4];
57 |
58 | for (int i = 0; i < addresses.Length; i++)
59 | addresses[i] = new IPAddress(s.ReadExactly(4));
60 |
61 | _addresses = addresses;
62 | }
63 |
64 | protected override void WriteOptionValue(Stream s)
65 | {
66 | foreach (IPAddress address in _addresses)
67 | s.Write(address.GetAddressBytes());
68 | }
69 |
70 | #endregion
71 |
72 | #region properties
73 |
74 | public IReadOnlyCollection Addresses
75 | { get { return _addresses; } }
76 |
77 | #endregion
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/VendorClassIdentifierOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.IO;
21 | using System.Text;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace DnsServerCore.Dhcp.Options
25 | {
26 | class VendorClassIdentifierOption : DhcpOption
27 | {
28 | #region variables
29 |
30 | string _identifier;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public VendorClassIdentifierOption(string identifier)
37 | : base(DhcpOptionCode.VendorClassIdentifier)
38 | {
39 | _identifier = identifier;
40 | }
41 |
42 | public VendorClassIdentifierOption(Stream s)
43 | : base(DhcpOptionCode.VendorClassIdentifier, s)
44 | { }
45 |
46 | #endregion
47 |
48 | #region protected
49 |
50 | protected override void ParseOptionValue(Stream s)
51 | {
52 | _identifier = Encoding.ASCII.GetString(s.ReadExactly((int)s.Length));
53 | }
54 |
55 | protected override void WriteOptionValue(Stream s)
56 | {
57 | s.Write(Encoding.ASCII.GetBytes(_identifier));
58 | }
59 |
60 | #endregion
61 |
62 | #region properties
63 |
64 | public string Identifier
65 | { get { return _identifier; } }
66 |
67 | #endregion
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/DnsServerCore/Dhcp/Options/VendorSpecificInformationOption.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.IO;
22 | using TechnitiumLibrary;
23 | using TechnitiumLibrary.IO;
24 |
25 | namespace DnsServerCore.Dhcp.Options
26 | {
27 | public class VendorSpecificInformationOption : DhcpOption
28 | {
29 | #region variables
30 |
31 | byte[] _information;
32 |
33 | #endregion
34 |
35 | #region constructor
36 |
37 | public VendorSpecificInformationOption(string hexInfo)
38 | : base(DhcpOptionCode.VendorSpecificInformation)
39 | {
40 | if (hexInfo.Contains(':'))
41 | _information = hexInfo.ParseColonHexString();
42 | else
43 | _information = Convert.FromHexString(hexInfo);
44 | }
45 |
46 | public VendorSpecificInformationOption(byte[] information)
47 | : base(DhcpOptionCode.VendorSpecificInformation)
48 | {
49 | _information = information;
50 | }
51 |
52 | public VendorSpecificInformationOption(Stream s)
53 | : base(DhcpOptionCode.VendorSpecificInformation, s)
54 | { }
55 |
56 | #endregion
57 |
58 | #region protected
59 |
60 | protected override void ParseOptionValue(Stream s)
61 | {
62 | _information = s.ReadExactly((int)s.Length);
63 | }
64 |
65 | protected override void WriteOptionValue(Stream s)
66 | {
67 | s.Write(_information);
68 | }
69 |
70 | #endregion
71 |
72 | #region properties
73 |
74 | public byte[] Information
75 | { get { return _information; } }
76 |
77 | #endregion
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/DnsServerCore/Dns/DnsServerException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 |
22 | namespace DnsServerCore.Dns
23 | {
24 | public class DnsServerException : Exception
25 | {
26 | #region constructors
27 |
28 | public DnsServerException()
29 | : base()
30 | { }
31 |
32 | public DnsServerException(string message)
33 | : base(message)
34 | { }
35 |
36 | public DnsServerException(string message, Exception innerException)
37 | : base(message, innerException)
38 | { }
39 |
40 | #endregion
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/DnsServerCore/Dns/ResolverPrefetchDnsCache.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2025 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Threading.Tasks;
21 | using TechnitiumLibrary.Net.Dns;
22 |
23 | namespace DnsServerCore.Dns
24 | {
25 | class ResolverPrefetchDnsCache : ResolverDnsCache
26 | {
27 | #region variables
28 |
29 | readonly DnsQuestionRecord _prefetchQuestion;
30 |
31 | #endregion
32 |
33 | #region constructor
34 |
35 | public ResolverPrefetchDnsCache(DnsServer dnsServer, bool skipDnsAppAuthoritativeRequestHandlers, DnsQuestionRecord prefetchQuestion)
36 | : base(dnsServer, skipDnsAppAuthoritativeRequestHandlers)
37 | {
38 | _prefetchQuestion = prefetchQuestion;
39 | }
40 |
41 | #endregion
42 |
43 | #region public
44 |
45 | public override Task QueryAsync(DnsDatagram request, bool serveStale = false, bool findClosestNameServers = false, bool resetExpiry = false)
46 | {
47 | if (_prefetchQuestion.Equals(request.Question[0]))
48 | {
49 | //request is for prefetch question
50 |
51 | if (!findClosestNameServers)
52 | return Task.FromResult(null); //dont give answer from cache for prefetch question
53 |
54 | //return closest name servers so that the recursive resolver queries them to refreshes cache instead of returning response from cache
55 | return QueryClosestDelegationAsync(request);
56 | }
57 |
58 | return base.QueryAsync(request, serveStale, findClosestNameServers, resetExpiry);
59 | }
60 |
61 | #endregion
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/DnsServerCore/Dns/ResourceRecords/HistoryRecordInfo.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.IO;
22 | using TechnitiumLibrary.IO;
23 |
24 | namespace DnsServerCore.Dns.ResourceRecords
25 | {
26 | class HistoryRecordInfo : AuthRecordInfo
27 | {
28 | #region variables
29 |
30 | DateTime _deletedOn;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public HistoryRecordInfo()
37 | { }
38 |
39 | public HistoryRecordInfo(BinaryReader bR)
40 | : base(bR)
41 | { }
42 |
43 | #endregion
44 |
45 | #region static
46 |
47 | public static HistoryRecordInfo ReadFrom(BinaryReader bR)
48 | {
49 | return new HistoryRecordInfo(bR);
50 | }
51 |
52 | #endregion
53 |
54 | #region protected
55 |
56 | protected override void ReadRecordInfoFrom(BinaryReader bR)
57 | {
58 | byte version = bR.ReadByte();
59 | switch (version)
60 | {
61 | case 1:
62 | _deletedOn = bR.ReadDateTime();
63 | break;
64 |
65 | default:
66 | throw new InvalidDataException("HistoryRecordInfo format version not supported.");
67 | }
68 | }
69 |
70 | protected override void WriteRecordInfoTo(BinaryWriter bW)
71 | {
72 | bW.Write((byte)1); //version
73 |
74 | bW.Write(_deletedOn);
75 | }
76 |
77 | #endregion
78 |
79 | #region properties
80 |
81 | public DateTime DeletedOn
82 | {
83 | get { return _deletedOn; }
84 | set { _deletedOn = value; }
85 | }
86 |
87 | #endregion
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/DnsServerCore/Dns/ResourceRecords/SVCBRecordInfo.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.IO;
21 |
22 | namespace DnsServerCore.Dns.ResourceRecords
23 | {
24 | class SVCBRecordInfo : GenericRecordInfo
25 | {
26 | #region variables
27 |
28 | bool _autoIpv4Hint;
29 | bool _autoIpv6Hint;
30 |
31 | #endregion
32 |
33 | #region constructor
34 |
35 | public SVCBRecordInfo()
36 | { }
37 |
38 | public SVCBRecordInfo(BinaryReader bR)
39 | : base(bR)
40 | { }
41 |
42 | #endregion
43 |
44 | #region protected
45 |
46 | protected override void ReadExtendedRecordInfoFrom(BinaryReader bR)
47 | {
48 | byte version = bR.ReadByte();
49 | switch (version)
50 | {
51 | case 0: //no extended info
52 | break;
53 |
54 | case 1:
55 | _autoIpv4Hint = bR.ReadBoolean();
56 | _autoIpv6Hint = bR.ReadBoolean();
57 | break;
58 |
59 | default:
60 | throw new InvalidDataException("SVCBRecordInfo format version not supported.");
61 | }
62 | }
63 |
64 | protected override void WriteExtendedRecordInfoTo(BinaryWriter bW)
65 | {
66 | bW.Write((byte)1); //version
67 |
68 | bW.Write(_autoIpv4Hint);
69 | bW.Write(_autoIpv6Hint);
70 | }
71 |
72 | #endregion
73 |
74 | #region properties
75 |
76 | public bool AutoIpv4Hint
77 | {
78 | get { return _autoIpv4Hint; }
79 | set { _autoIpv4Hint = value; }
80 | }
81 |
82 | public bool AutoIpv6Hint
83 | {
84 | get { return _autoIpv6Hint; }
85 | set { _autoIpv6Hint = value; }
86 | }
87 |
88 | #endregion
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/DnsServerCore/Dns/Trees/InvalidDomainNameException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 |
22 | namespace DnsServerCore.Dns.Trees
23 | {
24 | public class InvalidDomainNameException : DnsServerException
25 | {
26 | #region constructors
27 |
28 | public InvalidDomainNameException()
29 | : base()
30 | { }
31 |
32 | public InvalidDomainNameException(string message)
33 | : base(message)
34 | { }
35 |
36 | public InvalidDomainNameException(string message, Exception innerException)
37 | : base(message, innerException)
38 | { }
39 |
40 | #endregion
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/DnsServerCore/Dns/Zones/CatalogSubDomainZone.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Collections.Generic;
21 | using TechnitiumLibrary.Net.Dns.ResourceRecords;
22 |
23 | namespace DnsServerCore.Dns.Zones
24 | {
25 | class CatalogSubDomainZone : ForwarderSubDomainZone
26 | {
27 | #region constructor
28 |
29 | public CatalogSubDomainZone(CatalogZone catalogZone, string name)
30 | : base(catalogZone, name)
31 | { }
32 |
33 | #endregion
34 |
35 | #region public
36 |
37 | public override IReadOnlyList QueryRecords(DnsResourceRecordType type, bool dnssecOk)
38 | {
39 | return []; //catalog zone is not queriable
40 | }
41 |
42 | #endregion
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/DnsServerCore/Dns/Zones/SecondaryCatalogSubDomainZone.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Collections.Generic;
21 | using TechnitiumLibrary.Net.Dns.ResourceRecords;
22 |
23 | namespace DnsServerCore.Dns.Zones
24 | {
25 | class SecondaryCatalogSubDomainZone : SecondarySubDomainZone
26 | {
27 | #region constructor
28 |
29 | public SecondaryCatalogSubDomainZone(SecondaryZone secondaryZone, string name)
30 | : base(secondaryZone, name)
31 | { }
32 |
33 | #endregion
34 |
35 | #region public
36 |
37 | public override IReadOnlyList QueryRecords(DnsResourceRecordType type, bool dnssecOk)
38 | {
39 | return []; //secondary catalog zone is not queriable
40 | }
41 |
42 | #endregion
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/DnsServerCore/Dns/Zones/SecondarySubDomainZone.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 | using System.Collections.Generic;
22 | using TechnitiumLibrary.Net.Dns.ResourceRecords;
23 |
24 | namespace DnsServerCore.Dns.Zones
25 | {
26 | class SecondarySubDomainZone : SubDomainZone
27 | {
28 | #region variables
29 |
30 | readonly SecondaryZone _secondaryZone;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | public SecondarySubDomainZone(SecondaryZone secondaryZone, string name)
37 | : base(secondaryZone, name)
38 | {
39 | _secondaryZone = secondaryZone;
40 | }
41 |
42 | #endregion
43 |
44 | #region public
45 |
46 | public override void SetRecords(DnsResourceRecordType type, IReadOnlyList records)
47 | {
48 | throw new InvalidOperationException("Cannot set records in " + _secondaryZone.GetZoneTypeName() + " zone.");
49 | }
50 |
51 | public override bool AddRecord(DnsResourceRecord record)
52 | {
53 | throw new InvalidOperationException("Cannot add record in " + _secondaryZone.GetZoneTypeName() + " zone.");
54 | }
55 |
56 | public override bool DeleteRecord(DnsResourceRecordType type, DnsResourceRecordData record)
57 | {
58 | throw new InvalidOperationException("Cannot delete record in " + _secondaryZone.GetZoneTypeName() + " zone.");
59 | }
60 |
61 | public override bool DeleteRecords(DnsResourceRecordType type)
62 | {
63 | throw new InvalidOperationException("Cannot delete records in " + _secondaryZone.GetZoneTypeName() + " zone.");
64 | }
65 |
66 | public override void UpdateRecord(DnsResourceRecord oldRecord, DnsResourceRecord newRecord)
67 | {
68 | throw new InvalidOperationException("Cannot update record in " + _secondaryZone.GetZoneTypeName() + " zone.");
69 | }
70 |
71 | #endregion
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/DnsServerCore/Dns/Zones/SubDomainZone.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2025 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using DnsServerCore.Dns.ResourceRecords;
21 | using System.Collections.Generic;
22 | using TechnitiumLibrary.Net.Dns.ResourceRecords;
23 |
24 | namespace DnsServerCore.Dns.Zones
25 | {
26 | abstract class SubDomainZone : AuthZone
27 | {
28 | #region variables
29 |
30 | readonly ApexZone _authoritativeZone;
31 |
32 | #endregion
33 |
34 | #region constructor
35 |
36 | protected SubDomainZone(ApexZone authoritativeZone, string name)
37 | : base(name)
38 | {
39 | _authoritativeZone = authoritativeZone;
40 | }
41 |
42 | #endregion
43 |
44 | #region public
45 |
46 | public void AutoUpdateState()
47 | {
48 | foreach (KeyValuePair> entry in _entries)
49 | {
50 | foreach (DnsResourceRecord record in entry.Value)
51 | {
52 | if (!record.GetAuthGenericRecordInfo().Disabled)
53 | {
54 | Disabled = false;
55 | return;
56 | }
57 | }
58 | }
59 |
60 | Disabled = true;
61 | }
62 |
63 | #endregion
64 |
65 | #region properties
66 |
67 | public ApexZone AuthoritativeZone
68 | { get { return _authoritativeZone; } }
69 |
70 | #endregion
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/DnsServerCore/DnsWebServiceException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 |
22 | namespace DnsServerCore
23 | {
24 | public class DnsWebServiceException : Exception
25 | {
26 | #region constructors
27 |
28 | public DnsWebServiceException()
29 | : base()
30 | { }
31 |
32 | public DnsWebServiceException(string message)
33 | : base(message)
34 | { }
35 |
36 | public DnsWebServiceException(string message, Exception innerException)
37 | : base(message, innerException)
38 | { }
39 |
40 | #endregion
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/DnsServerCore/InvalidTokenWebServiceException.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System;
21 |
22 | namespace DnsServerCore
23 | {
24 | public class InvalidTokenWebServiceException : DnsWebServiceException
25 | {
26 | #region constructors
27 |
28 | public InvalidTokenWebServiceException()
29 | : base()
30 | { }
31 |
32 | public InvalidTokenWebServiceException(string message)
33 | : base(message)
34 | { }
35 |
36 | public InvalidTokenWebServiceException(string message, Exception innerException)
37 | : base(message, innerException)
38 | { }
39 |
40 | #endregion
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/DnsServerCore/dohwww/css/main.css:
--------------------------------------------------------------------------------
1 |
2 | html, body {
3 | height: 100% !important;
4 | }
5 |
6 | body {
7 | margin: 0px !important;
8 | line-height: 1.42857143 !important;
9 | }
10 |
11 | a {
12 | color: #6699ff;
13 | }
14 |
15 | a:hover {
16 | color: #6699ff;
17 | }
18 |
19 | #content {
20 | min-height: 100%;
21 | }
22 |
23 | .container {
24 | margin-left: auto;
25 | margin-right: auto;
26 | padding: 55px 15px 60px 15px;
27 | word-wrap: break-word;
28 | }
29 |
30 | .container .pageLogin {
31 | display: none;
32 | margin: auto;
33 | width: 500px;
34 | padding: 150px 0 0 0;
35 | }
36 |
37 | .container .page {
38 | display: none;
39 | }
40 |
41 | .features {
42 | margin: 80px auto 40px auto;
43 | font-family: Arial;
44 | }
45 |
46 | .features .pull-left {
47 | width: 50%;
48 | }
49 |
50 | .features .pull-right {
51 | width: 50%;
52 | }
53 |
54 | .features h3 {
55 | font-size: 22px;
56 | text-align: center;
57 | }
58 |
59 | .features p {
60 | color: rgb(119, 119, 119);
61 | text-align: center;
62 | }
63 |
64 | .features li {
65 | color: rgb(119, 119, 119);
66 | }
67 |
68 | .shadow-screenshot {
69 | box-shadow: 2px 3px 15px 1px #888888;
70 | }
71 |
72 | .auto-resize-img {
73 | max-width: 100%;
74 | height: auto;
75 | display: block;
76 | margin-right: auto;
77 | margin-left: auto;
78 | }
79 |
80 | @media (min-width: 992px) {
81 | #header .title, .container, #footer .content {
82 | width: 970px;
83 | }
84 | }
85 |
86 | @media (min-width: 1200px) {
87 | #header .title, .container, #footer .content {
88 | width: 1170px;
89 | }
90 |
91 | .stats-panel .stats-item {
92 | padding: 6px !important;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/DnsServerCore/dohwww/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/dohwww/favicon.ico
--------------------------------------------------------------------------------
/DnsServerCore/dohwww/img/firefox-doh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/dohwww/img/firefox-doh.png
--------------------------------------------------------------------------------
/DnsServerCore/dohwww/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/dohwww/img/logo.png
--------------------------------------------------------------------------------
/DnsServerCore/dohwww/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Technitium DNS Server
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
This server supports encrypted DNS protocol (DNS-over-HTTPS) that you can use with your web browser like Mozilla Firefox.
24 |
25 |
The Encrypted DNS Service URL
26 |
27 | Use the following URL to configure your clients for consuming the DNS-over-HTTPS service.
28 |
29 |
30 |
31 |
32 |
33 |
Mozilla Firefox Configuration
34 |
35 | To configure Firefox, go to Settings > Privacy & Security and scroll down to find DNS over HTTPS section. Click on the Max Protection option, select Custom option in the Choose provider drop down box, and enter the encrypted DNS service URL given above.
36 |
37 |
38 |
39 | Note! This will work only for Firefox and all other applications on your computer will keep using the default DNS server configured in your network settings.
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/DnsServerCore/dohwww/js/main.js:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2021 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | $(function () {
21 | var link = "https://" + window.location.hostname + "/dns-query";
22 |
23 | var lnkDoH = $("#lnkDoH");
24 |
25 | lnkDoH.text(link);
26 | lnkDoH.attr("href", link);
27 | });
--------------------------------------------------------------------------------
/DnsServerCore/dohwww/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow: /
3 |
--------------------------------------------------------------------------------
/DnsServerCore/root-anchors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | .
4 |
5 | 19036
6 | 8
7 | 2
8 | 49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5
9 |
10 |
11 | 20326
12 | 8
13 | 2
14 | E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D
15 | AwEAAaz/tAm8yTn4Mfeh5eyI96WSVexTBAvkMgJzkKTOiW1vkIbzxeF3+/4RgWOq7HrxRixHlFlExOLAJr5emLvN7SWXgnLh4+B5xQlNVz8Og8kvArMtNROxVQuCaSnIDdD5LKyWbRd2n9WGe2R8PzgCmr3EgVLrjyBxWezF0jLHwVN8efS3rCj/EWgvIWgb9tarpVUDK/b58Da+sqqls3eNbuv7pr+eoZG+SrDK6nWeL3c6H5Apxz7LjVc1uTIdsIXxuOLYA4/ilBmSVIzuDWfdRUfhHdY6+cn8HFRm+2hM8AnXGXws9555KrUB5qihylGa8subX2Nn6UwNR1AkUTV74bU=
16 | 257
17 |
18 |
19 | 38696
20 | 8
21 | 2
22 | 683D2D0ACB8C9B712A1948B27F741219298D0A450D612C483AF444A4C0FB2B16
23 | AwEAAa96jeuknZlaeSrvyAJj6ZHv28hhOKkx3rLGXVaC6rXTsDc449/cidltpkyGwCJNnOAlFNKF2jBosZBU5eeHspaQWOmOElZsjICMQMC3aeHbGiShvZsx4wMYSjH8e7Vrhbu6irwCzVBApESjbUdpWWmEnhathWu1jo+siFUiRAAxm9qyJNg/wOZqqzL/dL/q8PkcRU5oUKEpUge71M3ej2/7CPqpdVwuMoTvoB+ZOT4YeGyxMvHmbrxlFzGOHOijtzN+u1TQNatX2XBuzZNQ1K+s2CXkPIZo7s6JgZyvaBevYtxPvYLw4z9mR7K2vaF18UYH9Z9GNUUeayffKC73PYc=
24 | 257
25 |
26 |
--------------------------------------------------------------------------------
/DnsServerCore/www/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/favicon.ico
--------------------------------------------------------------------------------
/DnsServerCore/www/fonts/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/fonts/FontAwesome.otf
--------------------------------------------------------------------------------
/DnsServerCore/www/fonts/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/fonts/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/DnsServerCore/www/fonts/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/fonts/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/DnsServerCore/www/fonts/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/fonts/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/DnsServerCore/www/fonts/fontawesome-webfont.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/fonts/fontawesome-webfont.woff2
--------------------------------------------------------------------------------
/DnsServerCore/www/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/DnsServerCore/www/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/DnsServerCore/www/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/DnsServerCore/www/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/DnsServerCore/www/img/loader-small.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/img/loader-small.gif
--------------------------------------------------------------------------------
/DnsServerCore/www/img/loader.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/img/loader.gif
--------------------------------------------------------------------------------
/DnsServerCore/www/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/img/logo.png
--------------------------------------------------------------------------------
/DnsServerCore/www/img/logo25x25.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerCore/www/img/logo25x25.png
--------------------------------------------------------------------------------
/DnsServerCore/www/json/readme.txt:
--------------------------------------------------------------------------------
1 | READ ME
2 | =======
3 |
4 | This folder contains JSON formatted files that are used by the web app to fetch various lists. The JSON files that end with "-builtin" are the ones that are shipped as a part of the software package and are expected to be overwritten when you update the software.
5 |
6 | You can override these built-in lists by creating your own custom lists. To do this, create a new JSON file with the exact same name except, replace "-builtin" with "-custom" in the name. Use the same JSON format as the built-in list in your custom list to add items. When a custom list is available, the web app will always prefer it.
7 |
8 | For example, if you wish to have a custom list of servers listed for DNS Client, copy the "dnsclient-server-list-builtin.json" file as "dnsclient-server-list-custom.json" and edit it to have the desired list of servers.
9 |
10 | Note! Once the custom list file is saved, you will need to refresh the web app so that it loads the updated custom list.
11 |
12 | Warning! Editing the built-in json files will make it look like it works well, but when the software is updated, the built-in json file will be overwritten causing you to lose any custom changes that you made.
13 |
--------------------------------------------------------------------------------
/DnsServerCore/www/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow: /
3 |
--------------------------------------------------------------------------------
/DnsServerSystemTrayApp/DnsServerSystemTrayApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net8.0-windows
6 | false
7 | true
8 | true
9 | true
10 | DnsServerSystemTrayApp
11 | DnsServerSystemTrayApp
12 | Shreyas Zare
13 | logo2.ico
14 | 5.2.3
15 | false
16 | Technitium
17 | Technitium DNS Server
18 |
19 | https://technitium.com/dns/
20 | https://github.com/TechnitiumSoftware/DnsServer
21 |
22 |
23 |
24 |
25 | ..\..\TechnitiumLibrary\bin\TechnitiumLibrary.IO.dll
26 |
27 |
28 | ..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.dll
29 |
30 |
31 |
32 |
33 |
34 | True
35 | Resources.resx
36 | True
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | ResXFileCodeGenerator
52 | Resources.Designer.cs
53 |
54 |
55 |
--------------------------------------------------------------------------------
/DnsServerSystemTrayApp/NotifyIconExtension.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2019 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Reflection;
21 | using System.Windows.Forms;
22 |
23 | namespace DnsServerSystemTrayApp
24 | {
25 | public static class NotifyIconExtension
26 | {
27 | public static void ShowContextMenu(this NotifyIcon notifyIcon)
28 | {
29 | MethodInfo methodInfo = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic);
30 | methodInfo.Invoke(notifyIcon, null);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/DnsServerSystemTrayApp/Properties/PublishProfiles/FolderProfile.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | Release
8 | Any CPU
9 | ..\DnsServerWindowsSetup\publish
10 | FileSystem
11 | net8.0-windows
12 | false
13 |
14 |
--------------------------------------------------------------------------------
/DnsServerSystemTrayApp/frmAbout.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2021 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using System.Diagnostics;
21 | using System.Windows.Forms;
22 |
23 | namespace DnsServerSystemTrayApp
24 | {
25 | public partial class frmAbout : Form
26 | {
27 | public frmAbout()
28 | {
29 | InitializeComponent();
30 |
31 | labVersion.Text = "version " + Application.ProductVersion;
32 | }
33 |
34 | private void lnkContactEmail_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
35 | {
36 | ProcessStartInfo processInfo = new ProcessStartInfo("mailto:" + lnkContactEmail.Text);
37 |
38 | processInfo.UseShellExecute = true;
39 | processInfo.Verb = "open";
40 |
41 | Process.Start(processInfo);
42 | }
43 |
44 | private void lnkWebsite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
45 | {
46 | ProcessStartInfo processInfo = new ProcessStartInfo(@"https://" + lnkWebsite.Text);
47 |
48 | processInfo.UseShellExecute = true;
49 | processInfo.Verb = "open";
50 |
51 | Process.Start(processInfo);
52 | }
53 |
54 | private void lnkTerms_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
55 | {
56 | ProcessStartInfo processInfo = new ProcessStartInfo(@"https://go.technitium.com/?id=24");
57 |
58 | processInfo.UseShellExecute = true;
59 | processInfo.Verb = "open";
60 |
61 | Process.Start(processInfo);
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/DnsServerSystemTrayApp/logo.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerSystemTrayApp/logo.bmp
--------------------------------------------------------------------------------
/DnsServerSystemTrayApp/logo2.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerSystemTrayApp/logo2.ico
--------------------------------------------------------------------------------
/DnsServerWindowsService/DnsServerWindowsService.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | false
6 | true
7 | true
8 | DnsServerWindowsService
9 | DnsService
10 | logo2.ico
11 | 13.6
12 | false
13 | Shreyas Zare
14 | Technitium
15 | Technitium DNS Server
16 |
17 | https://technitium.com/dns/
18 | https://github.com/TechnitiumSoftware/DnsServer
19 | DnsServerWindowsService
20 |
21 |
22 |
23 |
24 | ..\..\TechnitiumLibrary\bin\TechnitiumLibrary.Net.Firewall.dll
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/DnsServerWindowsService/Program.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Technitium DNS Server
3 | Copyright (C) 2021 Shreyas Zare (shreyas@technitium.com)
4 |
5 | This program is free software: you can redistribute it and/or modify
6 | it under the terms of the GNU General Public License as published by
7 | the Free Software Foundation, either version 3 of the License, or
8 | (at your option) any later version.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program. If not, see .
17 |
18 | */
19 |
20 | using Microsoft.Extensions.DependencyInjection;
21 | using Microsoft.Extensions.Hosting;
22 |
23 | namespace DnsServerWindowsService
24 | {
25 | static class Program
26 | {
27 | public static void Main(string[] args)
28 | {
29 | CreateHostBuilder(args).Build().Run();
30 | }
31 |
32 | public static IHostBuilder CreateHostBuilder(string[] args)
33 | {
34 | return Host.CreateDefaultBuilder(args)
35 | .ConfigureServices((hostContext, services) =>
36 | {
37 | services.AddHostedService();
38 | })
39 | .UseWindowsService();
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/DnsServerWindowsService/Properties/PublishProfiles/FolderProfile.pubxml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 | Release
8 | Any CPU
9 | ..\DnsServerWindowsSetup\publish
10 | FileSystem
11 | net8.0
12 | false
13 |
14 |
--------------------------------------------------------------------------------
/DnsServerWindowsService/logo2.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerWindowsService/logo2.ico
--------------------------------------------------------------------------------
/DnsServerWindowsSetup/helper.iss:
--------------------------------------------------------------------------------
1 | [Code]
2 | {
3 | Helper functions
4 | }
5 |
6 | {
7 | Checks to see if the installer is an 'upgrade'
8 | }
9 | function IsUpgrade: Boolean;
10 | var
11 | Value: string;
12 | UninstallKey: string;
13 | begin
14 | UninstallKey := 'Software\Microsoft\Windows\CurrentVersion\Uninstall\' +
15 | ExpandConstant('{#SetupSetting("AppId")}') + '_is1';
16 | Result := (RegQueryStringValue(HKLM, UninstallKey, 'UninstallString', Value) or
17 | RegQueryStringValue(HKCU, UninstallKey, 'UninstallString', Value)) and (Value <> '');
18 | end;
19 |
20 | {
21 | Kills a running program by its filename
22 | }
23 | procedure TaskKill(fileName: String);
24 | var
25 | ResultCode: Integer;
26 | begin
27 | Exec(ExpandConstant('taskkill.exe'), '/f /im ' + '"' + fileName + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
28 | end;
29 |
30 |
31 | {
32 | Executes the MSI Uninstall by GUID functionality
33 | }
34 | function MsiExecUnins(appId: String): Integer;
35 | var
36 | ResultCode: Integer;
37 | begin
38 | ShellExec('', 'msiexec.exe', '/x ' + appId + ' /norestart /qb', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
39 | Result := ResultCode;
40 | end;
41 |
--------------------------------------------------------------------------------
/DnsServerWindowsSetup/legacy.iss:
--------------------------------------------------------------------------------
1 | #define LEGACY_INSTALLER_APPID "{9B86AC7F-53B3-4E31-B245-D4602D16F5C8}"
2 |
3 | [Code]
4 |
5 | {
6 | Legacy Installer Functionality
7 | }
8 |
9 | {
10 | Checks if the MSI Installer is installed
11 | }
12 | function IsLegacyInstallerInstalled: Boolean;
13 | var
14 | Value: string;
15 | UninstallKey1, UninstallKey2: string;
16 | begin
17 | UninstallKey1 := 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#LEGACY_INSTALLER_APPID}';
18 | UninstallKey2 := 'SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{#LEGACY_INSTALLER_APPID}';
19 | Result := (
20 | RegQueryStringValue(HKLM, UninstallKey1, 'UninstallString', Value) or
21 | RegQueryStringValue(HKCU, UninstallKey1, 'UninstallString', Value) or
22 | RegQueryStringValue(HKLM, UninstallKey2, 'UninstallString', Value)
23 | ) and (Value <> '');
24 | end;
25 |
26 | {
27 | Uninstalls Legacy Installer
28 | }
29 | procedure UninstallLegacyInstaller;
30 | var
31 | ResultCode: Integer;
32 | begin
33 | Log('Uninstall MSI installer item');
34 | ResultCode := MsiExecUnins('{#LEGACY_INSTALLER_APPID}');
35 | Log('Result code ' + IntToStr(ResultCode));
36 | end;
37 |
--------------------------------------------------------------------------------
/DnsServerWindowsSetup/logo.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerWindowsSetup/logo.bmp
--------------------------------------------------------------------------------
/DnsServerWindowsSetup/logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/TechnitiumSoftware/DnsServer/3a7636ac3b1c221521f4031bb185277bbc85f068/DnsServerWindowsSetup/logo.ico
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # syntax=docker.io/docker/dockerfile:1
2 |
3 | FROM mcr.microsoft.com/dotnet/aspnet:8.0
4 |
5 | # Add the MS repo to install `libmsquic` to support DNS-over-QUIC:
6 | ADD --link https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb /
7 | RUN < HTTP/3) (TCP => HTTP/1.1 + HTTP/2)
36 | 443/udp 443/tcp \
37 | # DNS-over-HTTP (for when running behind a reverse-proxy that terminates TLS)
38 | 80/tcp 8053/tcp \
39 | # Technitium web console + API (HTTP / HTTPS)
40 | 5380/tcp 53443/tcp \
41 | # DHCP
42 | 67/udp
43 |
44 | # https://specs.opencontainers.org/image-spec/annotations/
45 | # https://github.com/opencontainers/image-spec/blob/main/annotations.md
46 | LABEL org.opencontainers.image.title="Technitium DNS Server"
47 | LABEL org.opencontainers.image.vendor="Technitium"
48 | LABEL org.opencontainers.image.source="https://github.com/TechnitiumSoftware/DnsServer"
49 | LABEL org.opencontainers.image.url="https://technitium.com/dns/"
50 | LABEL org.opencontainers.image.authors="support@technitium.com"
51 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported Versions
4 |
5 | Only the latest available version of Technitium DNS Server is supported for security updates.
6 |
7 | ## Reporting a Vulnerability
8 |
9 | To report a vulnerability send an email to security@technitium.com
10 |
--------------------------------------------------------------------------------