{"id":15047410,"url":"https://github.com/vladimirshaleev/ipaddress","last_synced_at":"2026-04-01T17:16:44.637Z","repository":{"id":219429986,"uuid":"743040130","full_name":"VladimirShaleev/ipaddress","owner":"VladimirShaleev","description":"A library for working and manipulating IPv4/IPv6 addresses and networks","archived":false,"fork":false,"pushed_at":"2024-03-31T21:48:54.000Z","size":10683,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-03-31T22:35:02.906Z","etag":null,"topics":["constexpr","cpp11","cpp14","cpp17","cpp20","cpp23","header-only","ip","ipaddress","ipv4","ipv4-address","ipv4-network","ipv6","ipv6-address","ipv6-network","networks"],"latest_commit_sha":null,"homepage":"https://vladimirshaleev.github.io/ipaddress/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VladimirShaleev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-01-14T06:01:20.000Z","updated_at":"2024-04-14T21:26:35.666Z","dependencies_parsed_at":"2024-01-29T13:27:04.699Z","dependency_job_id":"2a603b65-f5f2-4cb3-9174-4998093c3b75","html_url":"https://github.com/VladimirShaleev/ipaddress","commit_stats":null,"previous_names":["vladimirshaleev/ipaddress"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VladimirShaleev%2Fipaddress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VladimirShaleev%2Fipaddress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VladimirShaleev%2Fipaddress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VladimirShaleev%2Fipaddress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VladimirShaleev","download_url":"https://codeload.github.com/VladimirShaleev/ipaddress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243475328,"owners_count":20296714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["constexpr","cpp11","cpp14","cpp17","cpp20","cpp23","header-only","ip","ipaddress","ipv4","ipv4-address","ipv4-network","ipv6","ipv6-address","ipv6-network","networks"],"created_at":"2024-09-24T20:57:56.233Z","updated_at":"2025-12-27T21:26:04.473Z","avatar_url":"https://github.com/VladimirShaleev.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ipaddress\n\n[![GitHub Release](https://img.shields.io/github/v/release/vladimirshaleev/ipaddress?sort=semver\u0026display_name=tag)](https://github.com/VladimirShaleev/ipaddress/releases)\n[![Conan Center](https://img.shields.io/conan/v/ipaddress)](https://conan.io/center/recipes/ipaddress)\n[![Vcpkg Version](https://img.shields.io/vcpkg/v/vladimirshaleev-ipaddress)](https://vcpkg.io/en/package/vladimirshaleev-ipaddress)\n[![GitHub License](https://img.shields.io/github/license/vladimirshaleev/ipaddress)](https://github.com/VladimirShaleev/ipaddress/blob/main/LICENSE)\n[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/vladimirshaleev/ipaddress/tests.yml?branch=main\u0026logo=github\u0026label=tests)\n](https://github.com/VladimirShaleev/ipaddress/actions/workflows/tests.yml)\n\nA library for working and manipulating IPv4/IPv6 addresses and networks in modern C++.\n\n## Introduction\n\nThis cross-platfrom **header-only** library (for C++11 and newer) is inspired by the [ipaddress API in Python](https://docs.python.org/3.12/library/ipaddress.html), \nfrom which it derives its name. It aims to be simpler to use due to its familiar interface. However, the C++ implementation takes \na different approach: it uses **static polymorphism** through the strategy pattern instead of dynamic polymorphism to handle \ndifferences between IP versions (IPv4 and IPv6). This design choice eliminates the overhead of dynamic calls and virtual tables. \nFor instance, an instance of the **ipv4_address** class will be represented by 4 bytes.\n\nThe library leverages modern C++ features, ensuring that all IP address and network operations support constant expressions. \n\n![Constexpr](doc/img/constexpr.png \"Errors are known at Compile Time\")\n\n## Compatibility\n\nThe library has been tested on the following compilers:\n\n* Clang 6.0.1 and newer;\n* Apple Clang 13.0.0 and newer;\n* GCC 7.5.0 and newer;\n* MSVC 14.29 (Visual Studio 16.11) and newer\n\n## Installation\n\nYou can install in one of the following ways\n\n### Use package managers\n\n#### Conan\n\nAdd **ipaddress** dependency to `conanfile.txt`:\n\n```ini\n[requires]\nipaddress/1.2.1\n```\n\nMore information and installation options can be found here https://conan.io/center/recipes/ipaddress\n\n#### Vcpkg\n\nYou can install **ipaddress** using [vcpkg](https://github.com/microsoft/vcpkg#getting-started) dependency manager as follows:\n\n```bash\n./vcpkg install vladimirshaleev-ipaddress\n```\n\nor via `vcpkg.json` if your project uses **manifest mode** [[1]](https://learn.microsoft.com/vcpkg/consume/manifest-mode) [[2]](https://learn.microsoft.com/vcpkg/concepts/manifest-mode) [[3]](https://learn.microsoft.com/vcpkg/get_started/get-started#3---add-dependencies-and-project-files):\n\n```json\n{\n  \"name\": \"my-project\",\n  \"dependencies\": [ \"vladimirshaleev-ipaddress\" ]\n}\n```\n\n#### Ubuntu PPA\n\n```bash\nsudo add-apt-repository ppa:vladimirshaleev/ipaddress\nsudo apt update\n\nsudo apt install libipaddress-dev\n```\n\nThen, if you use **CMake** for build, you need to link the target (regardless of how you installed the package):\n\n```cmake\ncmake_minimum_required(VERSION 3.10.0)\n\nproject(my_project LANGUAGES CXX)\n\nfind_package(ipaddress CONFIG REQUIRED)\n\nadd_executable(my_project main.cpp)\ntarget_link_libraries(my_project PRIVATE ipaddress::ipaddress) # add the library to your target\n```\n\n### Use as a Submodule with CMake\n\nGo to your project directory and add a submodule:\n\n```bash\ncd my_project\ngit submodule add https://github.com/VladimirShaleev/ipaddress.git third-party/ipaddress/\n```\nthen in the CMake project add it to the directory:\n\n```cmake\ncmake_minimum_required(VERSION 3.10.0)\n\nproject(my_project LANGUAGES CXX)\n\nadd_subdirectory(third-party/ipaddress)\n\nadd_executable(my_project main.cpp)\ntarget_link_libraries(my_project PRIVATE ipaddress::ipaddress) # add the library to your target\n```\n\n### Use CMake FetchContent\n\n```cmake\ncmake_minimum_required(VERSION 3.10.0)\n\nproject(my_project LANGUAGES CXX)\n\ninclude(FetchContent)\nFetchContent_Declare(\n  ipaddress\n  GIT_REPOSITORY https://github.com/VladimirShaleev/ipaddress\n  GIT_TAG v1.2.1\n)\nFetchContent_MakeAvailable(ipaddress)\n\nadd_executable(my_project main.cpp)\ntarget_link_libraries(my_project PRIVATE ipaddress::ipaddress) # add the library to your target\n```\n\n## Quick Start\n\nThe library provides capabilities for creating, analyzing and managing IPv4 and IPv6 addresses and networks using classes such \nas **ipv4_address**, **ipv6_address**, **ip_address** (any IP version), **ipv4_network**, **ipv6_network** and **ip_network** \n(any IP version). It also offers error handling methods with or without exceptions if for some reason exceptions are not used \nor disabled in your project.\n\nTo start using the library, simply include the header `ipaddress/ipaddress.hpp`, and you’re ready to begin your work!\n\nHere is an example demonstrating some of the library's features (this example can be compiled with C++14 or higher):\n\n```cpp\n#include \u003ciostream\u003e\n\n#include \u003cipaddress/ipaddress.hpp\u003e\n\nusing namespace ipaddress;\n\nvoid parse_sample() {\n    constexpr auto ip = ipv6_address::parse(\"fec0::1ff:fe23:4567:890a%eth2\");\n    constexpr auto is_site_local = ip.is_site_local();\n\n    std::cout \u003c\u003c \"ip \" \u003c\u003c ip \u003c\u003c \" is local: \" \u003c\u003c std::boolalpha \u003c\u003c is_site_local \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"DNS PTR \" \u003c\u003c ip.reverse_pointer() \u003c\u003c std::endl \u003c\u003c std::endl;\n}\n\nvoid teredo_sample() {\n    constexpr auto ip = \"2001:0000:4136:e378:8000:63bf:3fff:fdd2\"_ipv6;\n    auto [server, client] = ip.teredo().value();\n\n    std::cout \u003c\u003c \"server: \" \u003c\u003c server \u003c\u003c \" and client: \" \u003c\u003c client \u003c\u003c \" for \" \u003c\u003c ip \u003c\u003c std::endl \u003c\u003c std::endl;\n}\n\nvoid subnets_sample() {\n    constexpr auto net = ipv4_network::parse(\"192.0.2.0/24\");\n\n    std::cout \u003c\u003c \"subnets for \" \u003c\u003c net \u003c\u003c ':' \u003c\u003c std::endl;\n    for (const auto\u0026 subnet : net.subnets(2)) {\n        std::cout \u003c\u003c \"  \" \u003c\u003c subnet \u003c\u003c std::endl;\n    }\n\n    constexpr auto last_subnet = net.subnets(2).back();\n    std::cout \u003c\u003c \"last subnet \" \u003c\u003c last_subnet \u003c\u003c std::endl;\n}\n\nint main() {\n    parse_sample();\n    teredo_sample();\n    subnets_sample();\n    return 0;\n}\n```\n\n## Documentation\n\nFor more details on setup, usage and code examples can be found in the full [documentation](https://vladimirshaleev.github.io/ipaddress/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladimirshaleev%2Fipaddress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvladimirshaleev%2Fipaddress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladimirshaleev%2Fipaddress/lists"}