Skip to content
Snippets Groups Projects
Commit b882d100 authored by Zsombor Welker's avatar Zsombor Welker
Browse files

Add fallback options for systemd releases before 247

Which don't contain SetLinkDNSEx
parent 207d2f02
No related branches found
No related tags found
No related merge requests found
name: Build Packages
on: [ push ]
jobs:
build-deb:
name: Build DEB package
build-deb-20-04:
name: Build DEB package (Ubuntu 20.04)
runs-on: ubuntu-20.04
steps:
- name: Install fpm
run: |
sudo apt-get update
sudo apt-get install -y ruby ruby-dev rubygems build-essential python3-simplejson python3-pkg-resources python3-setuptools
sudo gem install fpm
- name: Check out repository code
uses: actions/checkout@v3
- name: Build package
run: >
fpm --input-type python \
--output-type deb \
--python-bin=python3 \
--python-install-bin /usr/bin \
--python-install-lib $(python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())') \
--deb-systemd debian/systemd-resolved-docker.service \
--no-auto-depends \
--depends python3-docker \
--depends python3-dnslib \
--depends python3-dbus \
--depends python3-pyroute2 \
--depends python3-systemd \
--depends systemd \
setup.py
- name: Save artifact
uses: actions/upload-artifact@v3
with:
name: DEB package (Ubuntu 20.04)
path: |
*.deb
build-deb-22-04:
name: Build DEB package (Ubuntu 22.04)
runs-on: ubuntu-22.04
steps:
- name: Install fpm
......@@ -17,6 +51,7 @@ jobs:
fpm --input-type python \
--output-type deb \
--python-bin=python3 \
--python-install-bin /usr/bin \
--deb-systemd debian/systemd-resolved-docker.service \
--no-auto-depends \
--depends python3-docker \
......@@ -29,7 +64,7 @@ jobs:
- name: Save artifact
uses: actions/upload-artifact@v3
with:
name: DEB package
name: DEB package (Ubuntu 22.04)
path: |
*.deb
......@@ -69,18 +104,39 @@ jobs:
- name: Run tests
run: sudo python3 -m unittest
test-deb:
name: Test DEB package
test-deb-20-04:
name: Test DEB package (Ubuntu 20.04)
runs-on: ubuntu-20.04
needs:
- build-deb-20-04
steps:
- name: Download DEB package
uses: actions/download-artifact@master
with:
name: DEB package (Ubuntu 20.04)
path: /tmp
- name: Install package
run: sudo apt install /tmp/python-systemd-resolved-docker_*.deb
- name: Start service
run: sudo systemctl start systemd-resolved-docker || (journalctl -xe && false)
- name: Start continaer
run: docker run --detach --interactive --hostname test-container alpine
- name: resolvectl status
run: resolvectl status
- name: Test Query
run: resolvectl query test-container.docker
test-deb-22-04:
name: Test DEB package (Ubuntu 22.04)
runs-on: ubuntu-22.04
needs:
- build-deb
- build-deb-22-04
steps:
- name: Download DEB package
uses: actions/download-artifact@master
with:
name: DEB package
name: DEB package (Ubuntu 22.04)
path: /tmp
- run: ls -lash /tmp
- name: Install package
run: sudo apt install /tmp/python-systemd-resolved-docker_*.deb
- name: Start service
......
......@@ -7,7 +7,7 @@ BindsTo=docker.service systemd-resolved.service
[Service]
Type=notify
Environment=PYTHONUNBUFFERED=1
ExecStart=/usr/local/bin/systemd-resolved-docker
ExecStart=/usr/bin/systemd-resolved-docker
Restart=on-failure
[Install]
......
......@@ -40,6 +40,8 @@ class SystemdResolvedConnector:
self.interface, self.dns_domains, ", ".join(map(lambda x: str(x), self.listen_addresses))))
domains = [[domain.strip("."), True] for domain in self.dns_domains]
try:
ips = [
[
AF_INET if isinstance(ip_port.ip, ipaddress.IPv4Address) else AF_INET6,
......@@ -54,6 +56,19 @@ class SystemdResolvedConnector:
manager.SetLinkDNSEx(self.ifindex, ips)
manager.SetLinkDNSSEC(self.ifindex, "no")
manager.SetLinkDomains(self.ifindex, domains)
except Exception as ex:
ips = [
[
AF_INET if isinstance(ip_port.ip, ipaddress.IPv4Address) else AF_INET6,
ip_port.ip.packed
]
for ip_port in self.listen_addresses
]
manager = self.if_manager()
manager.SetLinkDNS(self.ifindex, ips)
manager.SetLinkDNSSEC(self.ifindex, "no")
manager.SetLinkDomains(self.ifindex, domains)
def unregister(self):
self.handler.log("Unregistering with systemd-resolved: %s" % self.interface)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment