AdguardTeam / AdguardTeam/dnsproxy

[feat] mark host ipv6 empty

Open
#517 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
3.3k
Forks
343
PR merge metrics
No merged PRs in 30d

Description

# feat

mark host ipv6 empty

## background

https://gitlab.archlinux.org/archlinux/infrastructure/-/work_items/858

There is scenario that ipv4 works, but ipv6 not work.

## problem

This could be workarouond by

- adding unreachable ipv6 above reachable ipv4

```hosts
::1 archive.archlinux.org

49.12.124.107 archive.archlinux.org
2a01:4f8:242:5614::2 archive.archlinux.org
```

```console
$ curl -vfsSL https://archive.archlinux.org
...
* IPv6: ::1, 2a01:4f8:242:5614::2
* IPv4: 49.12.124.107
...
```

But this is not perfect.

`curl` will

- try unreachable `::1` port 443 first

- wait failure

- then try reachable ipv4 port 443

For better performance, first two steps should always avoid.

Would be nice to mark host ipv6 empty.

So, `curl` will directly try reachable ipv4 port 443

```console
$ curl -vfsSL https://archive.archlinux.org
...
* IPv6: (none)
* IPv4: 49.12.124.107
```

## workaround

adding unreachable ipv6 above reachable ipv4

```bash
dnsproxy \
--config-path /path/to/custom/config \
--hosts-file-enabled \
--hosts-files /path/to/custom/hosts
```

`/path/to/custom/hosts`

```hosts
::1 archive.archlinux.org

49.12.124.107 archive.archlinux.org
2a01:4f8:242:5614::2 archive.archlinux.org
```

On system prefer ipv6, curl will

- try ipv6 `::1`, ipv6 failed as expected
- try ipv4 `49.12.124.107`, ipv4 ok as expected

```console
$ curl -vfsSL https://archive.archlinux.org
* Host archive.archlinux.org:443 was resolved.
* IPv6: ::1, 2a01:4f8:242:5614::2
* IPv4: 49.12.124.107
* Trying [::1]:443...
* connect to ::1 port 443 from ::1 port 52220 failed: Connection refused
* Trying 49.12.124.107:443...
* Trying [2a01:4f8:242:5614::2]:443...
...
* Established connection to archive.archlinux.org (49.12.124.107 port 443) from ...
...
```

## suggest

mark host ipv6 empty

```bash
dnsproxy \
--config-path /path/to/custom/config
```

`/path/to/custom/config`

```yaml
hosts-file-enabled: true
hosts-files: /path/to/custom/hosts
hosts-empty:
ipv6:
- archive.archlinux.org
```

`/path/to/custom/hosts`

```hosts
49.12.124.107 archive.archlinux.org
2a01:4f8:242:5614::2 archive.archlinux.org
```

```console
$ curl -vfsSL https://archive.archlinux.org
* Host archive.archlinux.org:443 was resolved.
* IPv6: (none)
* IPv4: 49.12.124.107
* Trying 49.12.124.107:443...
...
* Established connection to archive.archlinux.org (49.12.124.107 port 443) from ...
...
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Use the provided startup command (`dnsproxy --config-path ...`) and custom hosts files as the entry points. Trace config parsing and hosts-file loading, then inspect where IPv4/IPv6 answer sets are built for queries. Add handling for `hosts-empty.ipv6` so listed hosts skip AAAA output while A output remains, then validate with the curl examples in the issue (`IPv6: (none)` and successful IPv4 connect). Add or update tests around config decoding and resolver output to confirm no regression.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.