Skip to content

Commit a1e8cc6

Browse files
committed
Allow Update Domain #4
1 parent d77ff62 commit a1e8cc6

File tree

7 files changed

+15
-8
lines changed

7 files changed

+15
-8
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ for https://github.com/KIMB-technologies/Radio-API
88

99
The configuration is done using env variables.
1010

11-
- `SERVER_BIND` *(optional)* The IP address the server binds on, if not set, 0.0.0.0 is used to bind on all interfaces.
12-
- `SERVER_PORT` *(optional)* The port which is used for the DNS server, should always be the default 53 (unless for testing).
13-
- `SERVER_UPSTREAM` *(optional)* The upstream DNS server, where DNS answers are fetched from
11+
- `SERVER_BIND` *(optional, default `0.0.0.0`)* The IP address the server binds on. `0.0.0.0` binds on all interfaces.
12+
- `SERVER_PORT` *(optional, default `53`)* The port which is used for the DNS server, should always be the default `53` (unless for testing).
13+
- `SERVER_UPSTREAM` *(optional, default `8.8.8.8`)* The upstream DNS server, where DNS answers are fetched from
1414
- `RADIO_DOMAIN` *(required, if `RADIO_IP` not set)* The domain where the [Radio-API](https://github.com/KIMB-technologies/Radio-API) can be found.
1515
The DNS server will return the `A` record of this domain for all queries containing `wifiradiofrontier.com`.
1616
- `RADIO_IP` *(required, if `RADIO_DOMAIN` not set)* The ip address where the [Radio-API](https://github.com/KIMB-technologies/Radio-API) can be found.
1717
The DNS server will return this IP for all queries containing `wifiradiofrontier.com`.
1818
If `RADIO_DOMAIN` is set, it will be used. If `RADIO_DOMAIN` is not set, `RADIO_IP` will be used!
19-
- `ALLOWED_DOMAIN` *(optional)* Normally a DNS resolver will answer all queries from all sources. This can be a security risk, so one should only answer the queries from trusted sources. One can give a list (domain names divided by `,`) of domain name here, only queries from the corresponding `A` records will be answered then. **The default value is `all` which means all sources are trusted. E.g. for testing and usage in local networks.** (Normally giving your DynDNS name is right; More domain names lead to a higher response time to queries.)
20-
- `TIME_SERVER` *(optional)* If the DNS server is queried for `time.wifiradiofrontier.com` it will answer with the `A` record of this domain. So one does not have to host an own NTP server at `RADIO_DOMAIN`. Per default some time server is used.
19+
- `ALLOWED_DOMAIN` *(optional, default `all`)* Normally a DNS resolver will answer all queries from all sources. This can be a security risk, so one should only answer the queries from trusted sources. One can give a list (domain names divided by `,`) of domain name here, only queries from the corresponding `A` records will be answered then. **The default value is `all` which means all sources are trusted. E.g. for testing and usage in local networks.** (Normally giving your DynDNS name is right; More domain names lead to a higher response time to queries.)
20+
- `TIME_SERVER` *(optional, default `ntp0.fau.de`)* If the DNS server is queried for `time.wifiradiofrontier.com` it will answer with the `A` record of this domain. So one does not have to host an own NTP server at `RADIO_DOMAIN`. Per default some time server is used.
21+
- `ENABLE_UPDATE` *(optional, default `false`)* Set to `true` to enable responding to DNS queries for `update.wifiradiofrontier.com` with the `A` record of `update.wifiradiofrontier.com` instead of the ip of Radio-API. (This will allow the radio to do updates. Performing updates is a trade-off between risking changes to the API, that may prevent Radio-API from working, and bug fixes and security implications for the radio's software.)
2122

2223
Run using the [**Docker-compose Example**](./docker-compose.yml)!
2324

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
2
22
2.1
3-
2.1.0
3+
2.1.1

dns/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def _load_data(cls):
2323
"UPSTREAM": str(os.getenv("SERVER_UPSTREAM", "8.8.8.8")),
2424
"RADIO": str(os.getenv("RADIO_DOMAIN", os.getenv("RADIO_IP", None))),
2525
"TIME" : str(os.getenv("TIME_SERVER", "ntp0.fau.de")),
26+
"UPDATE" : bool(os.getenv("ENABLE_UPDATE", "false") == "true"),
2627
"ALLOWED" : str(os.getenv("ALLOWED_DOMAIN", "all")),
2728
"DEVMODE" : bool(os.getenv("DEVMODE", "false") == "true")
2829
}

dns/hama.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Hama():
1010

1111
_DOMAIN = "wifiradiofrontier.com."
1212
_TIME_DOMAIN = "time.wifiradiofrontier.com."
13+
_UPDATE_DOMAIN = "update.wifiradiofrontier.com."
1314

1415
def __init__(self):
1516
self.do_lookup = Config["DO_LOOKUP"]
@@ -25,6 +26,8 @@ def match_domain(self, question:DNSQuestion) -> bool:
2526
def fetch_answer(self, question:DNSQuestion) -> Union[RR, None]:
2627
if question.qname.matchSuffix(self._TIME_DOMAIN):
2728
ip_address = DNSClient.resolve_a(Config["TIME"])
29+
elif Config["UPDATE"] and question.qname.matchSuffix(self._UPDATE_DOMAIN):
30+
ip_address = DNSClient.resolve_a(self._UPDATE_DOMAIN)
2831
else:
2932
ip_address = DNSClient.resolve_a(Config["RADIO"]) if self.do_lookup else Config["RADIO"]
3033

docker-compose.dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ services:
1818
- RADIO_IP=192.168.0.41
1919
- ALLOWED_DOMAIN=all
2020
- TIME_SERVER=ntp0.fau.de
21+
- ENABLE_UPDATE=true
2122
restart: always

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ services:
1313
#- RADIO_IP=192.168.0.41 # the place where https://github.com/KIMB-technologies/Radio-API ist hosted (if only available via IP and no domain, comment RADIO_DOMAIN)
1414
- ALLOWED_DOMAIN=home.example.com,home2.example.com # the domains of the home routers (DynDNS) as list divided by ',' or 'all' to allow all sources for the requests
1515
- TIME_SERVER=ntp0.fau.de # the NTP time server used by the radio (may be changed)
16+
- ENABLE_UPDATE=false # set to true to enable dns resolving of update server for radios
1617
restart: unless-stopped

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ FROM alpine
33
ARG H_UID=1000
44
ARG H_GID=1000
55

6-
RUN apk add --no-cache --update -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \
7-
python3 py3-pip libcap libcap2 py3-dnslib
6+
RUN apk add --no-cache --update python3 py3-pip libcap libcap2 \
7+
&& pip3 install --break-system-packages --no-cache-dir dnslib
88

99
# setup system and user
1010
RUN ln -s /usr/bin/python3 /usr/local/bin/python \

0 commit comments

Comments
 (0)