1package storage
2
3import (
4 "context"
5 "database/sql"
6 "net/netip"
7
8 "tug/internal/platform/origin"
9)
10
11func auditAddress(ctx context.Context, explicit netip.Addr) netip.Addr {
12 a := explicit
13 if !a.IsValid() {
14 a = origin.Of(ctx).Addr
15 }
16 if !a.IsValid() {
17 return netip.Addr{}
18 }
19 return a.Unmap().WithZone("")
20}
21
22func scanAddress(s sql.NullString) netip.Addr {
23 if !s.Valid {
24 return netip.Addr{}
25 }
26 a, err := netip.ParseAddr(s.String)
27 if err != nil {
28 return netip.Addr{}
29 }
30 return a
31}