mirror of
https://github.com/skidoodle/ipinfo.git
synced 2026-04-28 17:37:37 +02:00
26 lines
384 B
Go
26 lines
384 B
Go
package common
|
|
|
|
import (
|
|
"net"
|
|
|
|
"ipinfo/utils"
|
|
)
|
|
|
|
// ToPtr converts a string to a pointer, returning nil for empty strings.
|
|
func ToPtr(s string) *string {
|
|
if s == "" {
|
|
return nil
|
|
}
|
|
return &s
|
|
}
|
|
|
|
// IsBogon checks if the IP is a bogon IP.
|
|
func IsBogon(ip net.IP) bool {
|
|
for _, network := range utils.BogonNets {
|
|
if network.Contains(ip) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|