ADDED:
* netx.IsPub
* encodingx/hexx

Rest are mostly small corrections and docs
This commit is contained in:
brent saner
2026-06-22 18:51:13 -04:00
parent c6fc692f5e
commit 58556d7281
35 changed files with 5492 additions and 2486 deletions
+1
View File
@@ -0,0 +1 @@
This is mostly just for generating some reference. It's not really intended for public consumption.
+20
View File
@@ -0,0 +1,20 @@
module r00t2.io/goutils/netx/internal
go 1.26.4
require github.com/olekukonko/tablewriter v1.1.4
require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/clipperhouse/displaywidth v0.11.0 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/fatih/color v1.19.0 // indirect
github.com/goccy/go-json v0.10.6 // indirect
github.com/mattn/go-colorable v0.1.15 // indirect
github.com/mattn/go-isatty v0.0.22 // indirect
github.com/mattn/go-runewidth v0.0.24 // indirect
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
github.com/olekukonko/errors v1.3.0 // indirect
github.com/olekukonko/ll v0.1.8 // indirect
golang.org/x/sys v0.46.0 // indirect
)
+45
View File
@@ -0,0 +1,45 @@
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/clipperhouse/displaywidth v0.10.0 h1:GhBG8WuerxjFQQYeuZAeVTuyxuX+UraiZGD4HJQ3Y8g=
github.com/clipperhouse/displaywidth v0.10.0/go.mod h1:XqJajYsaiEwkxOj4bowCTMcT1SgvHo9flfF3jQasdbs=
github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8=
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
github.com/clipperhouse/uax29/v2 v2.6.0 h1:z0cDbUV+aPASdFb2/ndFnS9ts/WNXgTNNGFoKXuhpos=
github.com/clipperhouse/uax29/v2 v2.6.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w=
github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE=
github.com/goccy/go-json v0.10.6 h1:p8HrPJzOakx/mn/bQtjgNjdTcN+/S6FcG2CTtQOrHVU=
github.com/goccy/go-json v0.10.6/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY=
github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/mattn/go-runewidth v0.0.24 h1:cpokDiIn0MGnhdHwuWnJBITySJ20QyNGnY2kR/ay2DU=
github.com/mattn/go-runewidth v0.0.24/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 h1:zrbMGy9YXpIeTnGj4EljqMiZsIcE09mmF8XsD5AYOJc=
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6/go.mod h1:rEKTHC9roVVicUIfZK7DYrdIoM0EOr8mK1Hj5s3JjH0=
github.com/olekukonko/errors v1.2.0 h1:10Zcn4GeV59t/EGqJc8fUjtFT/FuUh5bTMzZ1XwmCRo=
github.com/olekukonko/errors v1.2.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y=
github.com/olekukonko/errors v1.3.0 h1:teJvgLGUEqMzBUms+Dj3/3szNqCG/Jdw9iDbum8fR6U=
github.com/olekukonko/errors v1.3.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y=
github.com/olekukonko/ll v0.1.6 h1:lGVTHO+Qc4Qm+fce/2h2m5y9LvqaW+DCN7xW9hsU3uA=
github.com/olekukonko/ll v0.1.6/go.mod h1:NVUmjBb/aCtUpjKk75BhWrOlARz3dqsM+OtszpY4o88=
github.com/olekukonko/ll v0.1.8 h1:ysHCJRGHYKzmBSdz9w5AySztx7lG8SQY+naTGYUbsz8=
github.com/olekukonko/ll v0.1.8/go.mod h1:RPRC6UcscfFZgjo1nulkfMH5IM0QAYim0LfnMvUuozw=
github.com/olekukonko/tablewriter v1.1.4 h1:ORUMI3dXbMnRlRggJX3+q7OzQFDdvgbN9nVWj1drm6I=
github.com/olekukonko/tablewriter v1.1.4/go.mod h1:+kedxuyTtgoZLwif3P1Em4hARJs+mVnzKxmsCL/C5RY=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
+295
View File
@@ -0,0 +1,295 @@
package main
import (
"bytes"
"fmt"
"log"
"net/netip"
"strconv"
"strings"
"github.com/olekukonko/tablewriter"
"github.com/olekukonko/tablewriter/tw"
)
const (
sectBordChar string = "#"
sectBordWdth int = 2
sectSpcPad int = 1
sectSidePad int = sectBordWdth + sectSpcPad
sectBothPad int = sectSidePad * 2
)
type (
IpInfo struct {
// Desc string
Index int
// IP netip.Addr
Is4 bool
Is4In6 bool
Is6 bool
IsGlobalUnicast bool
IsLinkLocalUnicast bool
IsInterfaceLocalMulticast bool
IsLinkLocalMulticast bool
IsMulticast bool
IsLoopback bool
IsPrivate bool
IsUnspecified bool
IsValid bool
}
)
var (
datHdrsFunc []string = []string{
"-",
".Is4", ".Is4In6()", ".Is6()",
".IsGlobalUnicast()", ".IsLinkLocalUnicast()",
".IsInterfaceLocalMulticast()", ".IsLinkLocalMulticast()", ".IsMulticast()",
".IsLoopback()",
".IsPrivate()",
".IsUnspecified()", ".IsValid()",
}
datHdrsKey []string = []string{
"Address Index (See Fig. 3)",
"IPv4", "4-in-6", "IPv6",
"Global Unicast", "Link-Local Unicast",
"Interface Local Multicast", "Link-Local Multicast", "Multicast",
"Loopback",
"Private/LAN",
"\"Unspecified\" Address", "Valid Address",
}
datHdrsShort = []string{
"IDX",
"4", "6(4)", "6",
"GU", "LLU",
"ILM", "LLM", "M",
"LO",
"P",
"U", "V",
}
exampleAddrs [][2]string = [][2]string{
[2]string{"IPv4", "203.0.113.10"}, // RFC 5737 address (https://datatracker.ietf.org/doc/html/rfc5737)
[2]string{"IPv4 Unspecified", "0.0.0.0"}, // Generally used to represent all of IPv4 address space
[2]string{"IPv4 Global Unicast", "173.230.132.76"}, // r00t2.io
[2]string{"IPv4 Multicast (All) (RFC 1112 § 4)", "224.0.0.1"}, // Should encompass all the multicast below. 224.0.0.0 is reserved.
[2]string{"IPv4 Multicast (Reserved) (RFC 1112 § 4)", "224.0.0.0"}, // Reserved per RFC but it should still report multicast.
[2]string{"IPv4 Multicast (Link-Local Multicast/Local Network Control Block) (RFC 5771 § 4)", "224.0.0.18"}, // https://datatracker.ietf.org/doc/html/rfc5771#section-4 (VRRP multicast addr)
[2]string{"IPv4 Multicast (Internetwork Control Block) (RFC 5771 § 5)", "224.0.1.68"}, // https://datatracker.ietf.org/doc/html/rfc5771#section-5 (mdhcpdiscover, RFC 2730)
[2]string{"IPv4 Multicast (AD-HOC I) (RFC 5771 § 6)", "224.0.2.10"}, // https://datatracker.ietf.org/doc/html/rfc5771#section-6
[2]string{"IPv4 Multicast (SDP/SAP) (RFC 5771 § 7)", "224.2.0.10"}, // https://datatracker.ietf.org/doc/html/rfc5771#section-7
[2]string{"IPv4 Multicast (AD-HOC II) (RFC 5771 § 6)", "224.3.0.10"}, // (above)
[2]string{"IPv4 Multicast (Source-Specific) (RFC 5771 § 8)", "232.0.0.10"}, // https://datatracker.ietf.org/doc/html/rfc5771#section-8
[2]string{"IPv4 Multicast (GLOP) (RFC 5771 § 9)", "233.0.0.10"}, // https://datatracker.ietf.org/doc/html/rfc5771#section-9
[2]string{"IPv4 Multicast (AD-HOC III) (RFC 5771 § 6)", "233.252.0.10"}, // (above)
[2]string{"IPv4 Multicast (Administrative) (RFC 5771 § 10)", "239.0.0.10"}, // https://datatracker.ietf.org/doc/html/rfc5771#section-10
[2]string{"IPv4 Link-Local Unicast (RFC 3927 § 2.1)", "169.254.1.10"}, // https://datatracker.ietf.org/doc/html/rfc3927#section-2.1
[2]string{"IPv4 Loopback", "127.0.1.10"}, // It's actually 127/8. Cannot believe how many people do not know this.
[2]string{"IPv4 Private (RFC 1918)", "10.0.0.10"}, // https://datatracker.ietf.org/doc/html/rfc1918
[2]string{"4-in-6 (RFC 4291 § 2.5.5.1)", "::203.0.113.10"}, // https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.5.1
[2]string{"4-in-6 (RFC 4291 § 2.5.5.1) (Native)", "::cb00:710a"}, // ""
[2]string{"4-in-6 (RFC 4291 § 2.5.5.2)", "::ffff:203.0.113.10"}, // https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.5.2
[2]string{"4-in-6 (RFC 4291 § 2.5.5.2) (Native)", "::ffff:cb00:710a"}, // ""
[2]string{"IPv6", "2001:db8::cb00:710a"}, // RFC 3849 (https://datatracker.ietf.org/doc/html/rfc3849) / RFC 9637 (https://datatracker.ietf.org/doc/html/rfc9637) address
[2]string{"IPv6 Unspecified", "::"}, // Generally used to represent all of IPv6 address space
[2]string{"IPv6 Global Unicast", "2600:3c02::f03c:91ff:fe93:c0a7"}, // r00t2.io
[2]string{"IPv6 Multicast (RFC 4291 § 2.7.1) (Reserved Net)", "ff00::"}, // https://datatracker.ietf.org/doc/html/rfc4291#section-2.7.1
[2]string{"IPv6 Multicast (RFC 4291 § 2.7.1) (Reserved)", "ff00::1"}, // ""
[2]string{"IPv6 Multicast (RFC 4291 § 2.7.1) (All Nodes) (Interface-Local)", "ff01::1"}, // ""
[2]string{"IPv6 Multicast (RFC 4291 § 2.7.1) (All Nodes) (Link-Local)", "ff02::1"}, // ""
[2]string{"IPv6 Multicast (RFC 4291 § 2.7.1) (All Routers) (Interface-Local)", "ff01::2"}, // ""
[2]string{"IPv6 Multicast (RFC 4291 § 2.7.1) (All Routers) (Link-Local)", "ff02::2"}, // ""
[2]string{"IPv6 Multicast (RFC 4291 § 2.7.1) (All Routers) (Admin-Local)", "ff04::2"}, // ""
[2]string{"IPv6 Multicast (RFC 4291 § 2.7.1) (All Routers) (Site-Local)", "ff05::2"}, // ""
[2]string{"IPv6 Multicast (RFC 4291 § 2.7.1) (All Routers) (Org-Local)", "ff08::2"}, // ""
[2]string{"IPv6 Multicast (RFC 4291 § 2.7.1) (All Routers) (Internet/Global)", "ff0e::2"}, // ""
[2]string{"IPv6 Multicast (RFC 4291 § 2.7.1) (Solicited Node)", "ff02::1:ff00:10"}, // ""
[2]string{"IPv6 Link-Local Unicast (RFC 4291 § 2.5.6)", "fe80::cb00:710a"}, // https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.6
[2]string{"IPv6 Loopback", "::1"}, // It's explicitly always a /128 with the address ::1 per RFC 4291 § 2.5.3.
[2]string{"IPv6 Private (Unique-Local Addresses) (RFC 4193) (Reserved)", "fc00::10"}, // https://datatracker.ietf.org/doc/html/rfc4193
[2]string{"IPv6 Private (Unique-Local Addresses) (RFC 4193) (Valid)", "fd00::10"}, // ""
}
descs []string = make([]string, len(exampleAddrs))
ips []netip.Addr = make([]netip.Addr, len(exampleAddrs))
sectSep string = "\n" + strings.Repeat("-", 80) + "\n"
)
func genHdr(sectNm string) (s string) {
// Wish I finished stringsx.Banner at time of writing this...
var fillLen int = sectBothPad + len(sectNm)
s = fmt.Sprintf(
"%s\n"+ // top border
// begin title line
"%-*s"+ // left-justify/right-pad
"%s"+ // sectNm text
"%[2]*[3]s\n"+ // one-indexed; repeat pad num and pad str from left border as right border
// end title line
"%[1]s\n", // bottom border
strings.Repeat(sectBordChar, fillLen), // top and bottom (bottom uses index)
sectSidePad, strings.Repeat(sectBordChar, sectBordWdth), // title left and right borders (right uses index)
sectNm, // title text
)
return
}
func main() {
var err error
var idx int
var s string
var desc string
var pair [2]string
var buf *bytes.Buffer = new(bytes.Buffer)
var tbl *tablewriter.Table = tablewriter.NewTable(
buf,
tablewriter.WithConfig(
tablewriter.Config{
Header: tw.CellConfig{
Formatting: tw.CellFormatting{
AutoFormat: tw.Off,
},
},
},
),
// requires .Batch(), and the autoheader forces all caps.
// https://github.com/olekukonko/tablewriter/issues/143
// https://github.com/olekukonko/tablewriter/issues/190
/*
tablewriter.WithBehavior(
tw.Behavior{
Structs: tw.Struct{
AutoHeader: tw.On,
},
},
),
*/
tablewriter.WithRendition(
tw.Rendition{
Settings: tw.Settings{
Separators: tw.Separators{BetweenRows: tw.On},
},
},
),
)
defer func() {
var tErr error
if tbl != nil {
if tErr = tbl.Close(); tErr != nil {
log.Printf("Error closing table: %v", tErr)
}
}
}()
buf.WriteString(genHdr("Fig. 1: Address Evaluations"))
buf.WriteString("(See Fig. 2 for a key of header symbols to names)\n\n")
tbl.Header(datHdrsShort)
for idx, pair = range exampleAddrs {
desc, s = pair[0], pair[1]
descs[idx] = desc
if ips[idx], err = netip.ParseAddr(s); err != nil {
log.Panicln(err)
}
// Currently no way to skip cols etc. https://github.com/olekukonko/tablewriter/issues/317
// rows[idx] = IpInfo{
if err = tbl.Append(
IpInfo{
// Desc: desc,
Index: idx,
// IP: ip,
Is4: ips[idx].Is4(),
Is4In6: ips[idx].Is4In6(),
Is6: ips[idx].Is6(),
IsGlobalUnicast: ips[idx].IsGlobalUnicast(),
IsLinkLocalUnicast: ips[idx].IsLinkLocalUnicast(),
IsInterfaceLocalMulticast: ips[idx].IsInterfaceLocalMulticast(),
IsLinkLocalMulticast: ips[idx].IsLinkLocalMulticast(),
IsMulticast: ips[idx].IsMulticast(),
IsLoopback: ips[idx].IsLoopback(),
IsPrivate: ips[idx].IsPrivate(),
IsUnspecified: ips[idx].IsUnspecified(),
IsValid: ips[idx].IsValid(),
},
); err != nil {
log.Panicln(err)
}
}
/*
if err = tbl.Bulk(rows); err != nil {
log.Panicln(err)
}
*/
if err = tbl.Render(); err != nil {
log.Panicln(err)
}
buf.WriteString(sectSep)
buf.WriteString(genHdr("Fig. 2: Headers Key for Fig. 1"))
tbl.Reset()
tbl.Header("Symbol", "Description", "net/netip.Addr Method")
for idx = range datHdrsKey {
if err = tbl.Append(
[]string{
datHdrsShort[idx],
datHdrsKey[idx],
datHdrsFunc[idx],
},
); err != nil {
log.Panicln(err)
}
}
if err = tbl.Render(); err != nil {
log.Panicln(err)
}
buf.WriteString(sectSep)
buf.WriteString(genHdr("Fig. 3: Test/Example IP Address Reference/Lookup for Fig. 1"))
buf.WriteString("(See Fig. 4 for Descriptions/Detailed Information)\n\n")
tbl.Reset()
tbl.Header("Index", "Address (Raw)", "Address (Parsed)")
for idx = range exampleAddrs {
if err = tbl.Append(
[]string{
strconv.Itoa(idx),
exampleAddrs[idx][1],
ips[idx].String(),
},
); err != nil {
log.Panicln(err)
}
}
if err = tbl.Render(); err != nil {
log.Panicln(err)
}
buf.WriteString(sectSep)
buf.WriteString(genHdr("Fig. 4: Extended Information for Fig. 3"))
tbl.Reset()
tbl.Header("Index", "Description")
for idx = range exampleAddrs {
if err = tbl.Append(
[]string{
strconv.Itoa(idx),
descs[idx],
},
); err != nil {
log.Panicln(err)
}
}
if err = tbl.Render(); err != nil {
log.Panicln(err)
}
fmt.Println(buf.String())
}
+147
View File
@@ -0,0 +1,147 @@
package main
import (
"log"
"maps"
"net/netip"
`os`
"slices"
"github.com/olekukonko/tablewriter"
`github.com/olekukonko/tablewriter/tw`
)
type (
IpInfo struct {
Desc string `r:"-"`
IP netip.Addr `r:"-"`
Is4 bool
Is4In6 bool
Is6 bool
IsGlobalUnicast bool
IsInterfaceLocalMulticast bool
IsLinkLocalMulticast bool
IsLinkLocalUnicast bool
IsLoopback bool
IsMulticast bool
IsPrivate bool
IsUnspecified bool
IsValid bool
}
)
func main() {
var err error
var s string
var idx int
var desc string
var ip netip.Addr
var rows []IpInfo
/*
var typ reflect.Type
var val reflect.Value
var fieldVal reflect.Value
var field reflect.StructField
*/
var exampleAddrs map[string]string
var tbl *tablewriter.Table = tablewriter.NewTable(
os.Stdout,
tablewriter.WithBehavior(
tw.Behavior{
Structs: tw.Struct{
AutoHeader: tw.On,
},
},
),
tablewriter.WithRendition(
tw.Rendition{
Settings: tw.Settings{
Separators: tw.Separators{BetweenRows: tw.On},
},
},
),
)
defer func() {
var tErr error
if tbl != nil {
if tErr = tbl.Close(); tErr != nil {
log.Printf("Error closing table: %v", tErr)
}
}
}()
exampleAddrs = map[string]string{
"IPv4": "203.0.113.10", // RFC 5737 address (https://datatracker.ietf.org/doc/html/rfc5737)
"IPv4 Unspecified": "0.0.0.0",
"IPv4 Global Unicast": "173.230.132.76", // r00t2.io
"IPv4 Multicast (All) (RFC 1112 § 4)": "224.0.0.1", // Should encompass all the multicast below. 224.0.0.0 is reserved.
"IPv4 Multicast (Reserved) (RFC 1112 § 4)": "224.0.0.0", // Reserved per RFC but it should still report multicast.
"IPv4 Multicast (Link-Local Multicast/Local Network Control Block) (RFC 5771 § 4)": "224.0.0.18", // https://datatracker.ietf.org/doc/html/rfc5771#section-4 (VRRP multicast addr)
"IPv4 Multicast (Internetwork Control Block) (RFC 5771 § 5)": "224.0.1.68", // https://datatracker.ietf.org/doc/html/rfc5771#section-5 (mdhcpdiscover, RFC 2730)
"IPv4 Multicast (AD-HOC I) (RFC 5771 § 6)": "224.0.2.10", // https://datatracker.ietf.org/doc/html/rfc5771#section-6
"IPv4 Multicast (SDP/SAP) (RFC 5771 § 7)": "224.2.0.10", // https://datatracker.ietf.org/doc/html/rfc5771#section-7
"IPv4 Multicast (AD-HOC II) (RFC 5771 § 6)": "224.3.0.10", // (above)
"IPv4 Multicast (Source-Specific) (RFC 5771 § 8)": "232.0.0.10", // https://datatracker.ietf.org/doc/html/rfc5771#section-8
"IPv4 Multicast (GLOP) (RFC 5771 § 9)": "233.0.0.10", // https://datatracker.ietf.org/doc/html/rfc5771#section-9
"IPv4 Multicast (AD-HOC III) (RFC 5771 § 6)": "233.252.0.10", // (above)
"IPv4 Multicast (Administrative) (RFC 5771 § 10)": "239.0.0.10", // https://datatracker.ietf.org/doc/html/rfc5771#section-10
"IPv4 Link-Local Unicast (RFC 3927 § 2.1)": "169.254.1.10", // https://datatracker.ietf.org/doc/html/rfc3927#section-2.1
"IPv4 Loopback": "127.0.1.10", // It's actually 127/8. Cannot believe how many people do not know this.
"IPv4 Private (RFC 1918)": "10.0.0.10", // https://datatracker.ietf.org/doc/html/rfc1918
"4-in-6 (RFC 4291 § 2.5.5.1)": "::203.0.113.10", // https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.5.1
"4-in-6 (RFC 4291 § 2.5.5.1) (Native)": "::cb00:710a", // ""
"4-in-6 (RFC 4291 § 2.5.5.2)": "::ffff:203.0.113.10", // https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.5.2
"4-in-6 (RFC 4291 § 2.5.5.2) (Native)": "::ffff:cb00:710a", // ""
"IPv6": "2001:db8::cb00:710a", // RFC 3849 (https://datatracker.ietf.org/doc/html/rfc3849) / RFC 9637 (https://datatracker.ietf.org/doc/html/rfc9637) address
"IPv6 Unspecified": "::",
"IPv6 Global Unicast": "2600:3c02::f03c:91ff:fe93:c0a7", // r00t2.io
"IPv6 Multicast (RFC 4291 § 2.7.1) (Reserved Net)": "ff00::", // https://datatracker.ietf.org/doc/html/rfc4291#section-2.7.1
"IPv6 Multicast (RFC 4291 § 2.7.1) (Reserved)": "ff00::1", // ""
"IPv6 Multicast (RFC 4291 § 2.7.1) (All Nodes) (Interface-Local)": "ff01::1", // ""
"IPv6 Multicast (RFC 4291 § 2.7.1) (All Nodes) (Link-Local)": "ff02::1", // ""
"IPv6 Multicast (RFC 4291 § 2.7.1) (All Routers) (Interface-Local)": "ff01::2", // ""
"IPv6 Multicast (RFC 4291 § 2.7.1) (All Routers) (Link-Local)": "ff02::2", // ""
"IPv6 Multicast (RFC 4291 § 2.7.1) (All Routers) (Admin-Local)": "ff04::2", // ""
"IPv6 Multicast (RFC 4291 § 2.7.1) (All Routers) (Site-Local)": "ff05::2", // ""
"IPv6 Multicast (RFC 4291 § 2.7.1) (All Routers) (Org-Local)": "ff08::2", // ""
"IPv6 Multicast (RFC 4291 § 2.7.1) (All Routers) (Internet/Global)": "ff0e::2", // ""
"IPv6 Multicast (RFC 4291 § 2.7.1) (Solicited Node)": "ff02::1:ff00:10", // ""
"IPv6 Link-Local Unicast (RFC 4291 § 2.5.6)": "fe80::cb00:710a", // https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.6
"IPv6 Loopback": "::1", // It's explicitly always a /128 with the address ::1 per RFC 4291 § 2.5.3.
"IPv6 Private (Unique-Local Addresses) (RFC 4193) (Reserved)": "fc00::10", // https://datatracker.ietf.org/doc/html/rfc4193
"IPv6 Private (Unique-Local Addresses) (RFC 4193) (Valid)": "fd00::10", // ""
}
rows = make([]IpInfo, len(exampleAddrs))
for idx, desc = range slices.Sorted(maps.Keys(exampleAddrs)) {
s = exampleAddrs[desc]
if ip, err = netip.ParseAddr(s); err != nil {
log.Panicln(err)
}
// Currently no way to skip cols etc. https://github.com/olekukonko/tablewriter/issues/317
rows[idx] = IpInfo{
Desc: desc,
IP: ip,
Is4: ip.Is4(),
Is4In6: ip.Is4In6(),
Is6: ip.Is6(),
IsGlobalUnicast: ip.IsGlobalUnicast(),
IsInterfaceLocalMulticast: ip.IsInterfaceLocalMulticast(),
IsLinkLocalMulticast: ip.IsLinkLocalMulticast(),
IsLinkLocalUnicast: ip.IsLinkLocalUnicast(),
IsLoopback: ip.IsLoopback(),
IsMulticast: ip.IsMulticast(),
IsPrivate: ip.IsPrivate(),
IsUnspecified: ip.IsUnspecified(),
IsValid: ip.IsValid(),
}
}
if err = tbl.Bulk(rows); err != nil {
log.Panicln(err)
}
if err = tbl.Render(); err != nil {
log.Panicln(err)
}
}