Documentation ¶
Index ¶
- Variables
- func GetLocalDialerSocketCount() int64
- func IsCloudflareIP(ip IP) (bool, error)
- func MakeLocalDialer(d *net.Dialer) *net.Dialer
- func MakeLocalTransport(idle int, max int, opts *http.Transport) *http.Transport
- func NewTracedConn(conn net.Conn) net.Conn
- func NormalizeOrg(k string) string
- func ResetConn(conn net.Conn)
- func ResetRequestConn(w http.ResponseWriter)
- func SetIPInfoHeaders(headers http.Header, ip string, info IPInfo)
- type CombinedIPInfo
- type CombinedProvider
- type CountryISO
- type Flags
- type GeoLite2ASN
- type GeoLite2ASNBlock
- type GeoLite2Country
- type GeoLite2CountryBlock
- type GeoLite2Location
- type IP
- func (i IP) BitOr(o IP) IP
- func (s IP) Compare(o IP) int64
- func (s IP) Equal(o IP) bool
- func (ip IP) IsLoopback() bool
- func (ip IP) IsPrivate() bool
- func (ip IP) IsPublic() bool
- func (ip IP) IsUnspecified() bool
- func (i IP) IsV4() bool
- func (i IP) IsZero() bool
- func (i IP) MarshalText() ([]byte, error)
- func (i IP) Shr(n uint8) IP
- func (i IP) String() string
- func (i IP) ToAddr() netip.Addr
- func (i IP) ToIP() net.IP
- func (i IP) ToSlice() []byte
- func (i *IP) UnmarshalText(b []byte) error
- type IP2ASN
- type IP2ASNBlock
- type IPInfo
- type IPInfoProvider
- type IPMap
- type IPNet
- type IPPort
- type ListenerInfo
- type LocalDialer
- type MarkerProvider
- type MaxmindProvider
- type NullIPInfo
- type Proxier
- type ProxyTraits
- type PublicIPInfo
- type RemoteFile
- type TracedConn
Constants ¶
This section is empty.
Variables ¶
View Source
var ( HdrASN = http.CanonicalHeaderKey("P-Asn") HdrIP = http.CanonicalHeaderKey("P-Ip") HdrIPGeo = http.CanonicalHeaderKey("P-Ip-Geo") HdrVPN = http.CanonicalHeaderKey("P-Vpn") HdrCF = http.CanonicalHeaderKey("P-Cf") HdrMarked = http.CanonicalHeaderKey("P-Marked") HdrRay = http.CanonicalHeaderKey("X-Ray") )
View Source
var ( IPv4zero = IPv4(0, 0, 0, 0) // all zeros IPv4StandardLoopback = IPv4(127, 0, 0, 1) IPv6loopback = FromIP(net.IP{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}) )
Well-known addresses
View Source
var DebugSocketCount = false
View Source
var LocalH2Transport = &http2.Transport{ DisableCompression: true, DialTLSContext: func(ctx context.Context, network, addr string, cfg *tls.Config) (net.Conn, error) { cfg.InsecureSkipVerify = true tdial := tls.Dialer{ Config: cfg, NetDialer: MakeLocalDialer(nil), } conn, err := tdial.DialContext(ctx, network, addr) if err != nil { return nil, err } return NewTracedConn(conn), nil }, }
View Source
var LocalIPInfoHeaders = http.Header{ HdrIP: []string{"127.0.0.1"}, HdrASN: []string{"AS0 Local"}, HdrIPGeo: []string{"XX"}, }
View Source
var LocalTransport = MakeLocalTransport(16384, 0, &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, ResponseHeaderTimeout: 1 * time.Minute, })
Functions ¶
func GetLocalDialerSocketCount ¶
func GetLocalDialerSocketCount() int64
func IsCloudflareIP ¶
func MakeLocalTransport ¶
func NormalizeOrg ¶
func ResetRequestConn ¶
func ResetRequestConn(w http.ResponseWriter)
Types ¶
type CombinedIPInfo ¶
type CombinedIPInfo struct {
OrgPrimary, GeoPrimary IPInfo
}
func (CombinedIPInfo) ASN ¶
func (c CombinedIPInfo) ASN() uint32
func (CombinedIPInfo) Country ¶
func (c CombinedIPInfo) Country() CountryISO
func (CombinedIPInfo) Desc ¶
func (c CombinedIPInfo) Desc() string
func (CombinedIPInfo) Flags ¶
func (c CombinedIPInfo) Flags() Flags
func (CombinedIPInfo) Unwrap ¶
func (c CombinedIPInfo) Unwrap(v any) bool
type CombinedProvider ¶
type CombinedProvider struct {
OrgPrimary, GeoPrimary IPInfoProvider
}
func (CombinedProvider) LookupContext ¶
func (c CombinedProvider) LookupContext(ctx context.Context, ip IP) IPInfo
type CountryISO ¶
type CountryISO [2]byte
func (CountryISO) IsValid ¶
func (c CountryISO) IsValid() bool
func (CountryISO) String ¶
func (c CountryISO) String() string
func (*CountryISO) UnmarshalText ¶
func (c *CountryISO) UnmarshalText(text []byte) error
type GeoLite2ASN ¶
type GeoLite2ASN struct {
Set IPMap[GeoLite2ASNBlock]
}
func (*GeoLite2ASN) UnmarshalBinary ¶
func (g2 *GeoLite2ASN) UnmarshalBinary(data []byte) (e error)
type GeoLite2ASNBlock ¶
type GeoLite2Country ¶
type GeoLite2Country struct { Locations map[uint32]*GeoLite2Location Set IPMap[GeoLite2CountryBlock] }
func (*GeoLite2Country) UnmarshalBinary ¶
func (g2 *GeoLite2Country) UnmarshalBinary(data []byte) (e error)
type GeoLite2CountryBlock ¶
type GeoLite2CountryBlock struct { Network IPNet `xsv:"network"` LocationID uint32 `xsv:"geoname_id"` RegisteredCountryID uint32 `xsv:"registered_country_geoname_id"` RepresentedCountryID uint32 `xsv:"represented_country_geoname_id"` IsAnonymousProxy bool `xsv:"is_anonymous_proxy"` Location *GeoLite2Location `xsv:"-"` }
type GeoLite2Location ¶
type GeoLite2Location struct { ID uint32 `xsv:"geoname_id"` CountryISOCode CountryISO `xsv:"country_iso_code"` }
type IP ¶
func GetOutboundIP ¶
func GetOutboundIP() (res IP)
func IPFromAddr ¶
func IPFromMask ¶
func IPFromSlice ¶
func IPv4Uint32 ¶ added in v0.2.5
func (IP) IsLoopback ¶
IsLoopback reports whether ip is a loopback address.
func (IP) IsPrivate ¶
IsPrivate reports whether ip is a private address, according to RFC 1918 (IPv4 addresses) and RFC 4193 (IPv6 addresses).
func (IP) IsUnspecified ¶
func (IP) MarshalText ¶
func (*IP) UnmarshalText ¶
type IP2ASNBlock ¶
type IP2ASNBlock struct { IPStart IP `xsv:"ip_start"` IPEnd IP `xsv:"ip_end"` AutonomousSystemNumber uint32 `xsv:"asn"` CountryCode CountryISO `xsv:"country_code"` OrganizationName string `xsv:"asn_description"` }
func (*IP2ASNBlock) ASN ¶
func (i *IP2ASNBlock) ASN() uint32
func (*IP2ASNBlock) Country ¶
func (i *IP2ASNBlock) Country() CountryISO
func (*IP2ASNBlock) Desc ¶
func (i *IP2ASNBlock) Desc() string
func (*IP2ASNBlock) Flags ¶
func (i *IP2ASNBlock) Flags() Flags
func (*IP2ASNBlock) Unwrap ¶
func (i *IP2ASNBlock) Unwrap(v any) bool
type IPInfo ¶
type IPInfo interface { ASN() uint32 Desc() string Country() CountryISO Flags() Flags Unwrap(any) bool }
func CombineIPInfo ¶
type IPInfoProvider ¶
var CloudflareProvider IPInfoProvider = &cloudflareProvider{ newRemoteParsedFile[cfList](cf4URL, config.AsnDir.File("cf-ips-v4.txt")), newRemoteParsedFile[cfList](cf6URL, config.AsnDir.File("cf-ips-v6.txt")), }
var IP2ASNProvider IPInfoProvider = &ip2AsnProvider{ newRemoteParsedFile[IP2ASN](ip2asnURL, config.AsnDir.File("ip2asn-combined.tsv.gz")), }
var NullIPInfoProvider IPInfoProvider = nullIPInfoProvider{}
type IPPort ¶
func FromAddrPort ¶
func FromNetAddr ¶
func ParseIPPort ¶
func (IPPort) MarshalText ¶
func (IPPort) ToAddrPort ¶
func (*IPPort) UnmarshalText ¶
type ListenerInfo ¶
func QueryListener ¶
func QueryListener(lst net.Listener) (info ListenerInfo)
type LocalDialer ¶
func (LocalDialer) DialContext ¶
type MarkerProvider ¶
type MarkerProvider struct {
// contains filtered or unexported fields
}
func NewMarkerProvider ¶
func NewMarkerProvider(inner IPInfoProvider, list []string) *MarkerProvider
func (*MarkerProvider) LookupContext ¶
func (s *MarkerProvider) LookupContext(ctx context.Context, ip IP) (info IPInfo)
type MaxmindProvider ¶
type MaxmindProvider struct {
// contains filtered or unexported fields
}
func NewMaxmindProvider ¶
func NewMaxmindProvider(key string) MaxmindProvider
func (MaxmindProvider) LookupContext ¶
func (m MaxmindProvider) LookupContext(c context.Context, ip IP) IPInfo
type NullIPInfo ¶
type NullIPInfo struct{}
func (NullIPInfo) ASN ¶
func (NullIPInfo) ASN() uint32
func (NullIPInfo) Country ¶
func (NullIPInfo) Country() CountryISO
func (NullIPInfo) Desc ¶
func (NullIPInfo) Desc() string
func (NullIPInfo) Flags ¶
func (NullIPInfo) Flags() Flags
func (NullIPInfo) Unwrap ¶
func (NullIPInfo) Unwrap(any) bool
type ProxyTraits ¶
type ProxyTraits struct { Proxier Proxier // Proxier type Edge IP // Parsed value from http.Request.RemoteAddr Origin IP // Original client CountryHint CountryISO }
func ResolveProxyTraits ¶
func ResolveProxyTraits(request *http.Request) (traits ProxyTraits)
type PublicIPInfo ¶
type PublicIPInfo struct { IP IP `json:"ip"` Country string `json:"country"` Lat float64 `json:"lat"` Lon float64 `json:"lon"` Org string `json:"org"` }
func GetPublicIPInfo ¶
func GetPublicIPInfo(c context.Context) (r PublicIPInfo)
type RemoteFile ¶
type RemoteFile struct {
// contains filtered or unexported fields
}
func NewRemoteFile ¶
func NewRemoteFile(uri string, filePath string) *RemoteFile
func (*RemoteFile) Invalidate ¶
func (r *RemoteFile) Invalidate()
type TracedConn ¶
func (*TracedConn) Close ¶
func (c *TracedConn) Close() error
Click to show internal directories.
Click to hide internal directories.