Skip to content

tayloraswift/swift-ip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ip

Tests Deploy Documentation

The swift-ip library is a portable, Foundation-free library for working with IP addresses. It provides tools for parsing and formatting IP addresses, data structures for performing efficient IP address lookups, and shims for compatibility with types from other libraries such as SwiftNIO.

One of the goals of this library is to allow other libraries to exchange strongly-typed values with zero overhead without falling back to raw integer representations or linking against large frameworks.

Requirements

The swift-ip library requires Swift 6.0 or later. This is because IP.V6 uses UInt128.

Platform Status
🐧 Linux Tests
🍏 Darwin Tests
🍏 Darwin (iOS) iOS
🍏 Darwin (tvOS) tvOS
🍏 Darwin (visionOS) visionOS
🍏 Darwin (watchOS) watchOS

Check deployment minimums

Why use swift-ip?

The IP address types defined by the Network framework are Darwin-only, which precludes their use in server-side code.

The swift-nio library provides a multi-platform SocketAddress type, but it is heap-allocated and reference-counted, and requires linking against the entire NIOCore module. This makes it unsuitable as a high-performance currency type for purposes such as firewall implementations or metrics collection.

Who is using swift-ip?

The Swiftinit documentation index currently uses the swift-ip library to verify clients (such as Googlebot and GitHub Webhooks) and combat abuse.

License

The swift-ip library is Apache 2.0 licensed.