MCPcopy Create free account

hub / github.com/oschwald/maxminddb-golang / functions

Functions386 in github.com/oschwald/maxminddb-golang

↓ 66 callersMethodDecode
Decode unmarshals the data from the data section into the value pointed to by v. If v is nil or not a pointer, an error is returned. If the data in th
result.go:31
↓ 57 callersFunctionNew
New creates a [ReflectionDecoder].
internal/decoder/reflection.go:30
↓ 53 callersFunctionOpen
Open takes a string path to a MaxMind DB file and any options. It returns a Reader structure or an error. The database file is opened using a memory m
reader.go:224
↓ 51 callersFunctionNewInvalidDatabaseError
NewInvalidDatabaseError creates an [InvalidDatabaseError] using the provided format and format arguments.
internal/mmdberrors/errors.go:24
↓ 49 callersMethodClose
Close returns the resources used by the database to the system.
reader.go:302
↓ 48 callersMethodDecode
Decode decodes the data value at offset and stores it in the value pointed at by v.
internal/decoder/reflection.go:68
↓ 48 callersMethodLookup
Lookup retrieves the database record for ip and returns a Result, which can be used to decode the data.
reader.go:381
↓ 46 callersFunctiontestFile
(file string)
reader_test.go:1405
↓ 40 callersMethodError
()
internal/mmdberrors/context.go:18
↓ 38 callersMethodErr
Err provides a way to check whether there was an error during the lookup without calling Result.Decode. If there was an error, it will also be returne
result.go:108
↓ 33 callersFunctionNewDataDecoder
NewDataDecoder creates a [DataDecoder].
internal/decoder/data_decoder.go:121
↓ 29 callersMethodwrapError
wrapError wraps an error with context information when an error occurs. Zero allocation on happy path - only allocates when error != nil.
internal/decoder/error_context.go:7
↓ 27 callersFunctionNewDecoder
NewDecoder creates a new Decoder with the given DataDecoder, offset, and options.
internal/decoder/decoder.go:31
↓ 25 callersMethodReadString
ReadString reads the value pointed by the decoder as a string. Returns an error if the database is malformed or if the pointed value is not a string.
internal/decoder/decoder.go:63
↓ 25 callersMethodString
String returns a human-readable name for the Kind.
internal/decoder/data_decoder.go:51
↓ 22 callersMethodError
()
mmap_unix.go:14
↓ 22 callersMethodPrefix
Prefix returns the netip.Prefix representing the network associated with the data record in the database.
result.go:131
↓ 19 callersMethoddecodeCtrlData
decodeCtrlData decodes the control byte and data info at the given offset. Encoding follows the MaxMind DB spec: the control byte's high 3 bits encode
internal/decoder/data_decoder.go:139
↓ 18 callersMethodDecodePath
DecodePath unmarshals a value from data section into v, following the specified path. The v parameter should be a pointer to the value where the deco
result.go:92
↓ 17 callersFunctionNewOffsetError
NewOffsetError creates an [InvalidDatabaseError] indicating that an offset pointed beyond the end of the database.
internal/mmdberrors/errors.go:18
↓ 14 callersMethodFound
Found will return true if the IP was found in the search tree. It will return false if the IP was not found or if there was an error.
result.go:114
↓ 14 callersMethodNetworks
Networks returns an iterator that can be used to traverse the networks in the database. Please note that a MaxMind DB may map IPv4 networks into seve
traverse.go:70
↓ 13 callersMethodReadMap
ReadMap returns an iterator to read the map along with the map size. The size can be used to pre-allocate a map with the correct capacity for better p
internal/decoder/decoder.go:221
↓ 13 callersFunctionnewDecoderFromHex
Helper function to create a Decoder for a given hex string.
internal/decoder/decoder_test.go:15
↓ 13 callersMethodnextValueOffset
NextValueOffset skips ahead to the next value without decoding the one at the offset passed in. The size bits have different meanings for different da
internal/decoder/data_decoder.go:541
↓ 12 callersMethoddecodeCtrlDataAndFollow
(expectedKind Kind)
internal/decoder/decoder.go:413
↓ 12 callersFunctionvalidateDecoding
(t *testing.T, tests map[string]any)
internal/decoder/reflection_test.go:550
↓ 11 callersMethodsetNextOffset
(offset uint)
internal/decoder/decoder.go:402
↓ 10 callersMethoddecodeKey
DecodeKey decodes a map key into []byte slice. We use a []byte so that we can take advantage of https://github.com/golang/go/issues/3512 to avoid copy
internal/decoder/data_decoder.go:467
↓ 10 callersMethodinternAt
internAt returns a string for the data at the given offset and size. Hot offsets are interned and the same backing string is returned on subsequent hi
internal/decoder/string_cache.go:36
↓ 9 callersFunctionNewUnmarshalTypeError
NewUnmarshalTypeError creates an [UnmarshalTypeError] when the value cannot be assigned to a value of rType.
internal/mmdberrors/errors.go:50
↓ 9 callersFunctionOpenBytes
OpenBytes takes a byte slice corresponding to a MaxMind DB file and any options. It returns a Reader structure or an error.
reader.go:313
↓ 9 callersMethodreset
(offset uint)
internal/decoder/decoder.go:396
↓ 8 callersFunctionWrapWithContext
WrapWithContext wraps an error with offset and optional path context. This function is designed to have zero allocation on the happy path - it only al
internal/mmdberrors/context.go:41
↓ 8 callersMethoddecodePointer
DecodePointer decodes a pointer from the given offset.
internal/decoder/data_decoder.go:247
↓ 8 callersMethoddecodeValue
( offset uint, result addressableValue, depth int, )
internal/decoder/reflection.go:258
↓ 8 callersFunctionrandomIPv4Address
(r *rand.Rand, ip []byte)
reader_test.go:1395
↓ 7 callersMethodLookupOffset
LookupOffset returns the Result for the specified offset. Note that netip.Prefix returned by Networks will be invalid when using LookupOffset.
reader.go:412
↓ 7 callersMethodNetworksWithin
NetworksWithin returns an iterator that can be used to traverse the networks in the database which are contained in a given prefix. Please note that
traverse.go:90
↓ 7 callersFunctionnewStringCache
()
internal/decoder/string_cache.go:28
↓ 7 callersFunctiontestError
( field string, expected any, actual any, )
verifier.go:153
↓ 6 callersMethodBuild
Build constructs the full path string.
internal/mmdberrors/context.go:89
↓ 6 callersMethodPrependMap
PrependMap adds a map key to the beginning of the path (for retroactive building).
internal/mmdberrors/context.go:79
↓ 5 callersFunctionNewPathBuilder
NewPathBuilder creates a new path builder.
internal/mmdberrors/context.go:67
↓ 5 callersMethodOffset
Offset returns the offset of the record in the database. This can be passed to (*Reader).LookupOffset. It can also be used as a unique identifier for
result.go:125
↓ 5 callersMethodPeekKind
PeekKind returns the kind of the current value without consuming it. This allows for look-ahead parsing similar to jsontext.Decoder.PeekKind().
internal/decoder/decoder.go:316
↓ 5 callersMethodReadUint32
ReadUint32 reads the value pointed by the decoder as a uint32. Returns an error if the database is malformed or if the pointed value is not a uint32.
internal/decoder/decoder.go:163
↓ 5 callersFunctionSkipEmptyValues
SkipEmptyValues is an option for Networks and NetworksWithin that makes them skip networks whose data is an empty map or empty array. This is useful f
traverse.go:54
↓ 5 callersMethoddecode
(offset uint, result reflect.Value, depth int)
internal/decoder/reflection.go:242
↓ 5 callersFunctionsearchTreeSizeBytes
(nodeCount, recordSize uint)
reader.go:375
↓ 4 callersFunctionNewUnmarshalTypeStrError
NewUnmarshalTypeStrError creates an [UnmarshalTypeError] when the string value cannot be assigned to a value of rType.
internal/mmdberrors/errors.go:41
↓ 4 callersMethodReadSlice
ReadSlice returns an iterator over the values of the slice along with the slice size. The size can be used to pre-allocate a slice with the correct ca
internal/decoder/decoder.go:266
↓ 4 callersMethodVerify
Verify performs comprehensive validation of the MaxMind DB file. This method validates: - Metadata section: format versions, required fields, and val
verifier.go:30
↓ 4 callersFunctioncachedFields
(result reflect.Value)
internal/decoder/reflection.go:1260
↓ 4 callersFunctioncheckNestedDepth
(depth int)
internal/decoder/reflection.go:1060
↓ 4 callersMethoddecodeString
DecodeString decodes a string from the given offset.
internal/decoder/data_decoder.go:295
↓ 4 callersMethoddecodeStructWithFields
( size uint, offset uint, result addressableValue, depth int, fields *fieldsType, )
internal/decoder/reflection.go:864
↓ 4 callersMethoddecodeUint16
DecodeUint16 decodes a 16-bit unsigned integer from the given offset.
internal/decoder/data_decoder.go:306
↓ 4 callersMethoddecodeUint32
DecodeUint32 decodes a 32-bit unsigned integer from the given offset.
internal/decoder/data_decoder.go:328
↓ 4 callersMethoddecodeUint64
DecodeUint64 decodes a 64-bit unsigned integer from the given offset.
internal/decoder/data_decoder.go:350
↓ 4 callersMethoddecodeValueSkipUnmarshaler
decodeValueSkipUnmarshaler is the struct-field fast path: when the destination type was precomputed to not implement Unmarshaler, we skip the reflecti
internal/decoder/reflection.go:269
↓ 4 callersFunctionmakeStructFields
makeStructFields implements json/v2 style field precedence rules.
internal/decoder/reflection.go:1293
↓ 3 callersFunctionIncludeNetworksWithoutData
IncludeNetworksWithoutData is an option for Networks and NetworksWithin that makes them include networks without any data in the iteration.
traverse.go:44
↓ 3 callersMethodIsContainer
IsContainer returns true if the Kind represents a container type (Map or Slice).
internal/decoder/data_decoder.go:91
↓ 3 callersMethodIsEmptyValueAt
IsEmptyValueAt checks if the value at the given offset is an empty map or array. Returns true if the value is a map or array with size 0.
internal/decoder/reflection.go:38
↓ 3 callersMethodIsScalar
IsScalar returns true if the Kind represents a scalar value type.
internal/decoder/data_decoder.go:96
↓ 3 callersMethodReadUint64
ReadUint64 reads the value pointed by the decoder as a uint64. Returns an error if the database is malformed or if the pointed value is not a uint64.
internal/decoder/decoder.go:181
↓ 3 callersMethodSkipValue
SkipValue skips over the current value without decoding it. This is useful in custom decoders when encountering unknown fields. The decoder will be po
internal/decoder/decoder.go:304
↓ 3 callersMethoddecodeBool
DecodeBool decodes a boolean from the given offset.
internal/decoder/data_decoder.go:283
↓ 3 callersMethoddecodeFloat64
DecodeFloat64 decodes a 64-bit float from the given offset.
internal/decoder/data_decoder.go:193
↓ 3 callersFunctiongetAllTestMMDBFiles
getAllTestMMDBFiles returns smaller MMDB files from the test-data directory. Large files are excluded to keep fuzzing fast and prevent timeouts.
fuzz_test.go:365
↓ 3 callersMethodgetBuffer
getBuffer returns the underlying buffer for direct access.
internal/decoder/data_decoder.go:129
↓ 3 callersFunctionhasBufferRange
(bufferLen, offset, size uint)
reader.go:785
↓ 3 callersFunctionisInIPv4Subtree
isInIPv4Subtree returns true if the IP is in the database's IPv4 subtree.
traverse.go:264
↓ 3 callersFunctionmappedIP
(ip netip.Addr)
traverse.go:256
↓ 3 callersFunctionmunmap
(_ []byte)
mmap_stub.go:23
↓ 3 callersMethodtraverseTree
(ip netip.Addr, node uint, stopBit int)
reader.go:528
↓ 3 callersMethodtraverseTree24
(ip netip.Addr, node uint, stopBit int)
reader.go:544
↓ 3 callersMethodtraverseTree28
(ip netip.Addr, node uint, stopBit int)
reader.go:615
↓ 3 callersMethodtraverseTree32
(ip netip.Addr, node uint, stopBit int)
reader.go:712
↓ 3 callersMethodunmarshalUint
( size, offset uint, result addressableValue, uintType uint, )
internal/decoder/reflection.go:658
↓ 3 callersFunctionv6ToV4
Converts an IPv4 address embedded in IPv6 to IPv4.
traverse.go:275
↓ 2 callersMethodBuildTime
BuildTime returns the database build time as a time.Time. This is a convenience method that converts the BuildEpoch field from Unix epoch seconds to a
reader.go:203
↓ 2 callersMethodParseAndExtend
ParseAndExtend parses an existing path and extends this builder with those segments. This is used for retroactive path building during error unwinding
internal/mmdberrors/context.go:98
↓ 2 callersMethodPrependSlice
PrependSlice adds a slice index to the beginning of the path (for retroactive building).
internal/mmdberrors/context.go:84
↓ 2 callersMethodReadBool
ReadBool reads the value pointed by the decoder as a bool. Returns an error if the database is malformed or if the pointed value is not a bool.
internal/decoder/decoder.go:46
↓ 2 callersMethodReadBytes
ReadBytes reads the value pointed by the decoder as bytes. Returns an error if the database is malformed or if the pointed value is not bytes.
internal/decoder/decoder.go:80
↓ 2 callersMethodReadFloat64
ReadFloat64 reads the value pointed by the decoder as a float64. Returns an error if the database is malformed or if the pointed value is not a doubl
internal/decoder/decoder.go:109
↓ 2 callersMethodReadUint128
ReadUint128 reads the value pointed by the decoder as a uint128. Returns an error if the database is malformed or if the pointed value is not a uint1
internal/decoder/decoder.go:199
↓ 2 callersMethodReadUint16
ReadUint16 reads the value pointed by the decoder as a uint16. Returns an error if the database is malformed or if the pointed value is not a uint16.
internal/decoder/decoder.go:145
↓ 2 callersMethodUnmarshalMaxMindDB
(d *Decoder)
mmdbdata/interface.go:6
↓ 2 callersFunctionappend64
(val uint64, b byte)
internal/decoder/data_decoder.go:396
↓ 2 callersFunctioncachedFieldsForTypeWithStack
( resultType reflect.Type, stack map[reflect.Type]bool, )
internal/decoder/reflection.go:1268
↓ 2 callersFunctioncheckIpv4
(t *testing.T, reader *Reader)
reader_test.go:1041
↓ 2 callersFunctioncheckIpv6
(t *testing.T, reader *Reader)
reader_test.go:1082
↓ 2 callersFunctioncheckMetadata
(t *testing.T, reader *Reader, ipVersion, recordSize uint)
reader_test.go:1016
↓ 2 callersFunctioncleanupAllocatedPointers
( allocatedCount int, allocated1, allocated2 reflect.Value, allocatedMore []reflect.Value, )
internal/decoder/reflection.go:1112
↓ 2 callersMethoddecodeFloat32
DecodeFloat32 decodes a 32-bit float from the given offset.
internal/decoder/data_decoder.go:210
↓ 2 callersMethoddecodeInt32
DecodeInt32 decodes a 32-bit signed integer from the given offset.
internal/decoder/data_decoder.go:227
↓ 2 callersMethoddecodeMap
( size uint, offset uint, result addressableValue, depth int, )
internal/decoder/reflection.go:777
next →1–100 of 386, ranked by callers