diff --git a/binding/python/xdb/__init__.py b/binding/python/xdb/__init__.py new file mode 100644 index 0000000..8f9fe4a --- /dev/null +++ b/binding/python/xdb/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2022 The Ip2Region Authors. All rights reserved. +# Use of this source code is governed by a Apache2.0-style +# license that can be found in the LICENSE file. + +# xdb package \ No newline at end of file diff --git a/binding/python/xdb/util.py b/binding/python/xdb/util.py new file mode 100644 index 0000000..f66b600 --- /dev/null +++ b/binding/python/xdb/util.py @@ -0,0 +1,129 @@ +# Copyright 2022 The Ip2Region Authors. All rights reserved. +# Use of this source code is governed by a Apache2.0-style +# license that can be found in the LICENSE file. + +# xdb utils on 2025/10/29 +# Author Leon + +import io +import struct + +# global constants +XdbStructure20 = 2 +XdbStructure30 = 3 +XdbIPv4Id = 4 +XdbIPv6Id = 6 + +HeaderInfoLength = 256 +VectorIndexRows = 256 +VectorIndexCols = 256 +VectorIndexSize = 8 + +class Header(object): + ''' + header class + ''' + def __init__(self, buff): + self.version = struct.unpack_from("", IPv4) + print("IPv6 ->", IPv6) + print("version_from_name(v4) ->", version_from_name("v4")) + print("version_from_name(v6) ->", version_from_name("v4")) + print("version_from_header() ->", version_from_header(header))