ADDED:
* The ability to show both IPv4 and IPv6 addresses (if the client has
  dual-stack and either the server does as well or a separate ClientInfo
  is running on the "other" net family).
This commit is contained in:
brent saner
2025-12-13 04:19:05 -05:00
parent eb5c44e1c3
commit 9f97fcaf81
12 changed files with 244 additions and 93 deletions

View File

@@ -4,6 +4,48 @@ import (
`fmt`
)
func (p *Page) AltURL() (altUrl string) {
if !p.HasAltURL() {
return
}
if p.Info.IP.Is4() {
altUrl = p.srv.v6Url.String()
} else if p.Info.IP.Is6() {
altUrl = p.srv.v4Url.String()
}
return
}
func (p *Page) AltVer() (altVer string) {
if !p.HasAltURL() {
return
}
if p.Info.IP.Is4() {
altVer = "v6"
} else if p.Info.IP.Is6() {
altVer = "v4"
}
return
}
func (p *Page) HasAltURL() (hasAlt bool) {
if p.Info == nil {
return
}
hasAlt = (p.Info.IP.Is4() && p.srv.v6Url != nil) ||
(p.Info.IP.Is6() && p.srv.v4Url != nil)
return
}
func (p *Page) RenderIP(indent uint) (s string) {
s = fmt.Sprintf("<a href=\"https://ipinfo.io/%s\">%s</a>", p.Info.IP.String(), p.Info.IP.String())