oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package egress
2
3import (
4 "net/netip"
5 "testing"
6)
7
8// PublicAddress is the predicate Research's fetcher shares with the relay.
9func TestPublicAddressExported(t *testing.T) {
10 for ip, want := range map[string]bool{
11 "8.8.8.8": true, "2606:4700:4700::1111": true, "::ffff:8.8.8.8": true,
12 "127.0.0.1": false, "10.0.0.1": false, "172.16.0.1": false, "192.168.1.1": false,
13 "100.64.0.1": false, "100.127.255.254": false, "169.254.169.254": false, "0.0.0.0": false,
14 "::ffff:10.0.0.1": false, "::ffff:127.0.0.1": false, "::1": false, "fe80::1": false, "fc00::1": false,
15 "fd7a:115c:a1e0::1": false, "2002:a00:1::1": false, "2001::1": false, "2001:db8::1": false,
16 "224.0.0.1": false, "255.255.255.255": false, "198.18.0.1": false, "192.0.2.1": false, "::": false,
17 } {
18 if got := PublicAddress(netip.MustParseAddr(ip)); got != want {
19 t.Errorf("PublicAddress(%s) = %v, want %v", ip, got, want)
20 }
21 }
22 if PublicAddress(netip.Addr{}) {
23 t.Error("zero address is public")
24 }
25}
26