Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: allow IPv6 DNS #378

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions vm_supervisor/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,6 @@ def setup(self):
os.makedirs(self.EXECUTION_LOG_DIRECTORY, exist_ok=True)
os.makedirs(self.PERSISTENT_VOLUMES_DIR, exist_ok=True)

if not self.NETWORK_INTERFACE:
self.NETWORK_INTERFACE = get_default_interface()

Comment on lines -311 to -313
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that intender or was this removed by error ?

if self.DNS_NAMESERVERS is None and self.DNS_RESOLUTION:
self.DNS_NAMESERVERS = obtain_dns_ips(
dns_resolver=self.DNS_RESOLUTION,
Expand All @@ -334,6 +331,28 @@ def display(self) -> str:
f"{attribute:<27} = {value}" for attribute, value in attributes.items()
)

def filter_dns_servers(self, ipv4_only: bool) -> Optional[List[str]]:
"""
Filter Dns (ipv4 + ipv6 or only ipv4)

Parameter:
ipv4_only (bool)
Return:
Optional[List[str]]: list of dns filtered

"""
dns_servers = self.DNS_NAMESERVERS
if not dns_servers:
raise ValueError("Invalid configuration: DNS nameservers missing")

# Apply DNS IPv6 here if user configurations allow it
dns_servers = [
server
for server in dns_servers
if not ipaddress.ip_address(server).version == 6 or ipv4_only
]
return dns_servers

class Config:
env_prefix = "ALEPH_VM_"
case_sensitive = False
Expand Down
6 changes: 3 additions & 3 deletions vm_supervisor/vm/firecracker/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import asyncio
import dataclasses
import ipaddress
import logging
import os.path
from asyncio import StreamReader, StreamWriter
Expand Down Expand Up @@ -377,8 +378,7 @@ async def _setup_configuration(
ipv6 = self.get_vm_ipv6()
ipv6_gateway = self.get_vm_ipv6_gateway()

if not settings.DNS_NAMESERVERS:
raise ValueError("Invalid configuration: DNS nameservers missing")
dns_servers = settings.filter_dns_servers(ipv4_only=False) # True to Disable Ipv6 Dns

runtime_config = self.fvm.runtime_config
assert runtime_config
Expand All @@ -394,7 +394,7 @@ async def _setup_configuration(
ipv6=ipv6,
route=route,
ipv6_gateway=ipv6_gateway,
dns_servers=settings.DNS_NAMESERVERS,
dns_servers=dns_servers,
code=code,
encoding=self.resources.code_encoding,
entrypoint=self.resources.code_entrypoint,
Expand Down