AdguardTeam / AdguardTeam/dnsproxy

[feat] mark host ipv6 empty

Abierto
#517 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Go
Estrellas
3.3k
Forks
343
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

# 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 ...
...
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.