Skip to content
This repository was archived by the owner on Dec 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Swift library for checking your public IP address

Supports macOS, iOS, tvOS, watchOS and Linux.

Uses [icanhazip](https://icanhazip.com), [ipv6test](https://v4v6.ipv6-test.com/api/myip.php), [seeip](https://ip.seeip.org), [whatismyipaddress](https://bot.whatismyipaddress.com), [ident](https://ident.me/) and etc.
Uses [icanhazip](https://icanhazip.com), [ipify](https://www.ipify.org), [ifconfig.me](https://ifconfig.me), [my-ip.io](https://www.my-ip.io), [ident.me](https://ident.me/), [AWS checkip](https://checkip.amazonaws.com), and [ipinfo.io](https://ipinfo.io).

## Usage

Expand Down
25 changes: 10 additions & 15 deletions Sources/PublicIPAPIURLs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,27 @@ public enum PublicIPAPIURLs {

public enum Hybrid: String, CaseIterable {
case icanhazip = "https://icanhazip.com"
case ipv6test = "https://v4v6.ipv6-test.com/api/myip.php"
case seeip = "https://ip.seeip.org"
case whatismyipaddress = "https://bot.whatismyipaddress.com"
case ipify = "https://api.ipify.org"
case ifconfigMe = "https://ifconfig.me/ip"
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The enum case name "ifconfigMe" uses an inconsistent naming convention. The other enum cases in this file use all lowercase names (icanhazip, ipify, ident, amazonaws, ipinfo), but this one uses camelCase with a capital 'M'. For consistency with the rest of the codebase, consider renaming this to "ifconfigme" (all lowercase).

Copilot uses AI. Check for mistakes.
case myip = "https://api.my-ip.io/v2/ip.txt"
case ident = "https://ident.me/"
}

public enum IPv4: String, CaseIterable {
case icanhazip = "https://ipv4.icanhazip.com"
case ipv6test = "https://v4.ipv6-test.com/api/myip.php"
case seeip = "https://ip4.seeip.org"
case whatismyipaddress = "https://ipv4bot.whatismyipaddress.com"
case ident = "https://v4.ident.me/"

case ipify = "https://api.ipify.org"

case ifconfigMe = "https://ipv4.ifconfig.me/ip"
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The enum case name "ifconfigMe" uses an inconsistent naming convention. The other enum cases in this file use all lowercase names (icanhazip, ipify, ident, amazonaws, ipinfo), but this one uses camelCase with a capital 'M'. For consistency with the rest of the codebase, consider renaming this to "ifconfigme" (all lowercase).

Copilot uses AI. Check for mistakes.
case myip = "https://api4.my-ip.io/v2/ip.txt"
case ident = "https://v4.ident.me/"
case amazonaws = "https://checkip.amazonaws.com"
case ipecho = "https://ipecho.net/plain"
case ipinfo = "https://ipinfo.io/ip"
}

public enum IPv6: String, CaseIterable {
case icanhazip = "https://ipv6.icanhazip.com"
case ipv6test = "https://v6.ipv6-test.com/api/myip.php"
case seeip = "https://ip6.seeip.org"
case whatismyipaddress = "https://ipv6bot.whatismyipaddress.com"
case ident = "https://v6.ident.me/"

case ipify = "https://api6.ipify.org"
case ifconfigMe = "https://ipv6.ifconfig.me/ip"
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The enum case name "ifconfigMe" uses an inconsistent naming convention. The other enum cases in this file use all lowercase names (icanhazip, ipify, ident, amazonaws, ipinfo), but this one uses camelCase with a capital 'M'. For consistency with the rest of the codebase, consider renaming this to "ifconfigme" (all lowercase).

Copilot uses AI. Check for mistakes.
case myip = "https://api6.my-ip.io/v2/ip.txt"
case ident = "https://v6.ident.me/"
}
}
79 changes: 31 additions & 48 deletions Tests/SwiftPublicIPTests/SwiftPublicIPTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ class SwiftPublicIPTests: XCTestCase {
waitForExpectations(timeout: 40, handler: nil)
}

func test_hybrid_ipv6test() {
func test_hybrid_ipify() {
let exp = expectation(description: "\(#function)\(#line)")
testPublicIP(PublicIPAPIURLs.Hybrid.ipv6test.rawValue, exp)
testPublicIP(PublicIPAPIURLs.Hybrid.ipify.rawValue, exp)
waitForExpectations(timeout: 40, handler: nil)
}

func test_hybrid_seeip() {
func test_hybrid_ifconfigMe() {
let exp = expectation(description: "\(#function)\(#line)")
testPublicIP(PublicIPAPIURLs.Hybrid.seeip.rawValue, exp)
testPublicIP(PublicIPAPIURLs.Hybrid.ifconfigMe.rawValue, exp)
waitForExpectations(timeout: 40, handler: nil)
Comment on lines +40 to 43
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test function name "test_hybrid_ifconfigMe" should match the naming convention of other test functions. If the enum case is renamed to "ifconfigme" (all lowercase) for consistency, this test function name should be updated to "test_hybrid_ifconfigme" to match.

Copilot uses AI. Check for mistakes.
}

func test_hybrid_whatismyipaddress() {
func test_hybrid_myip() {
let exp = expectation(description: "\(#function)\(#line)")
testPublicIP(PublicIPAPIURLs.Hybrid.whatismyipaddress.rawValue, exp)
testPublicIP(PublicIPAPIURLs.Hybrid.myip.rawValue, exp)
waitForExpectations(timeout: 40, handler: nil)
}

Expand All @@ -63,21 +63,21 @@ class SwiftPublicIPTests: XCTestCase {
waitForExpectations(timeout: 40, handler: nil)
}

func test_ipv4_ipv6test() {
func test_ipv4_ipify() {
let exp = expectation(description: "\(#function)\(#line)")
testPublicIP(PublicIPAPIURLs.IPv4.ipv6test.rawValue, exp)
testPublicIP(PublicIPAPIURLs.IPv4.ipify.rawValue, exp)
waitForExpectations(timeout: 40, handler: nil)
}

func test_ipv4_seeip() {
func test_ipv4_ifconfigMe() {
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test function name "test_ipv4_ifconfigMe" should match the naming convention of other test functions. If the enum case is renamed to "ifconfigme" (all lowercase) for consistency, this test function name should be updated to "test_ipv4_ifconfigme" to match.

Suggested change
func test_ipv4_ifconfigMe() {
func test_ipv4_ifconfigme() {

Copilot uses AI. Check for mistakes.
let exp = expectation(description: "\(#function)\(#line)")
testPublicIP(PublicIPAPIURLs.IPv4.seeip.rawValue, exp)
testPublicIP(PublicIPAPIURLs.IPv4.ifconfigMe.rawValue, exp)
waitForExpectations(timeout: 40, handler: nil)
}

func test_ipv4_whatismyipaddress() {
func test_ipv4_myip() {
let exp = expectation(description: "\(#function)\(#line)")
testPublicIP(PublicIPAPIURLs.IPv4.whatismyipaddress.rawValue, exp)
testPublicIP(PublicIPAPIURLs.IPv4.myip.rawValue, exp)
waitForExpectations(timeout: 40, handler: nil)
}

Expand All @@ -87,21 +87,15 @@ class SwiftPublicIPTests: XCTestCase {
waitForExpectations(timeout: 40, handler: nil)
}

func test_ipv4_ipify() {
let exp = expectation(description: "\(#function)\(#line)")
testPublicIP(PublicIPAPIURLs.IPv4.ipify.rawValue, exp)
waitForExpectations(timeout: 40, handler: nil)
}

func test_ipv4_amazonaws() {
let exp = expectation(description: "\(#function)\(#line)")
testPublicIP(PublicIPAPIURLs.IPv4.amazonaws.rawValue, exp)
waitForExpectations(timeout: 40, handler: nil)
}

func test_ipv4_ipecho() {
func test_ipv4_ipinfo() {
let exp = expectation(description: "\(#function)\(#line)")
testPublicIP(PublicIPAPIURLs.IPv4.ipecho.rawValue, exp)
testPublicIP(PublicIPAPIURLs.IPv4.ipinfo.rawValue, exp)
waitForExpectations(timeout: 40, handler: nil)
}

Expand All @@ -113,21 +107,21 @@ class SwiftPublicIPTests: XCTestCase {
waitForExpectations(timeout: 40, handler: nil)
}

func test_ipv6_ipv6test() {
func test_ipv6_ipify() {
let exp = expectation(description: "\(#function)\(#line)")
testPublicIP(PublicIPAPIURLs.IPv6.ipv6test.rawValue, exp)
testPublicIP(PublicIPAPIURLs.IPv6.ipify.rawValue, exp)
waitForExpectations(timeout: 40, handler: nil)
}

func test_ipv6_seeip() {
func test_ipv6_ifconfigMe() {
let exp = expectation(description: "\(#function)\(#line)")
testPublicIP(PublicIPAPIURLs.IPv6.seeip.rawValue, exp)
testPublicIP(PublicIPAPIURLs.IPv6.ifconfigMe.rawValue, exp)
waitForExpectations(timeout: 40, handler: nil)
Comment on lines +116 to 119
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test function name "test_ipv6_ifconfigMe" should match the naming convention of other test functions. If the enum case is renamed to "ifconfigme" (all lowercase) for consistency, this test function name should be updated to "test_ipv6_ifconfigme" to match.

Copilot uses AI. Check for mistakes.
}

func test_ipv6_whatismyipaddress() {
func test_ipv6_myip() {
let exp = expectation(description: "\(#function)\(#line)")
testPublicIP(PublicIPAPIURLs.IPv6.whatismyipaddress.rawValue, exp)
testPublicIP(PublicIPAPIURLs.IPv6.myip.rawValue, exp)
waitForExpectations(timeout: 40, handler: nil)
}

Expand All @@ -137,39 +131,28 @@ class SwiftPublicIPTests: XCTestCase {
waitForExpectations(timeout: 40, handler: nil)
}

func test_ipv6_ipify() {
let exp = expectation(description: "\(#function)\(#line)")
testPublicIP(PublicIPAPIURLs.IPv6.ipify.rawValue, exp)
waitForExpectations(timeout: 40, handler: nil)
}

static var allTests = [
// Hybrid
("test_hybrid_icanhazip", test_hybrid_icanhazip),
("test_hybrid_ipv6test", test_hybrid_ipv6test),
("test_hybrid_seeip", test_hybrid_seeip),
("test_hybrid_whatismyipaddress", test_hybrid_whatismyipaddress),
("test_hybrid_ipify", test_hybrid_ipify),
("test_hybrid_ifconfigMe", test_hybrid_ifconfigMe),
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test entry string "test_hybrid_ifconfigMe" should match the naming convention of other test entries. If the enum case and test function are renamed to use all lowercase "ifconfigme", this entry should be updated to ("test_hybrid_ifconfigme", test_hybrid_ifconfigme) to match.

Suggested change
("test_hybrid_ifconfigMe", test_hybrid_ifconfigMe),
("test_hybrid_ifconfigme", test_hybrid_ifconfigMe),

Copilot uses AI. Check for mistakes.
("test_hybrid_myip", test_hybrid_myip),
("test_hybrid_ident", test_hybrid_ident),

// IPv4
("test_ipv4_icanhazip", test_ipv4_icanhazip),
("test_ipv4_ipv6test", test_ipv4_ipv6test),
("test_ipv4_seeip", test_ipv4_seeip),
("test_ipv4_whatismyipaddress", test_ipv4_whatismyipaddress),
("test_ipv4_ident", test_ipv4_ident),

("test_ipv4_ipify", test_ipv4_ipify),

("test_ipv4_ifconfigMe", test_ipv4_ifconfigMe),
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test entry string "test_ipv4_ifconfigMe" should match the naming convention of other test entries. If the enum case and test function are renamed to use all lowercase "ifconfigme", this entry should be updated to ("test_ipv4_ifconfigme", test_ipv4_ifconfigme) to match.

Copilot uses AI. Check for mistakes.
("test_ipv4_myip", test_ipv4_myip),
("test_ipv4_ident", test_ipv4_ident),
("test_ipv4_amazonaws", test_ipv4_amazonaws),
("test_ipv4_ipecho", test_ipv4_ipecho),
("test_ipv4_ipinfo", test_ipv4_ipinfo),

// IPv6
("test_ipv6_icanhazip", test_ipv6_icanhazip),
("test_ipv6_ipv6test", test_ipv6_ipv6test),
("test_ipv6_seeip", test_ipv6_seeip),
("test_ipv6_whatismyipaddress", test_ipv6_whatismyipaddress),
("test_ipv6_ident", test_ipv6_ident),

("test_ipv6_ipify", test_ipv6_ipify)
("test_ipv6_ipify", test_ipv6_ipify),
("test_ipv6_ifconfigMe", test_ipv6_ifconfigMe),
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test entry string "test_ipv6_ifconfigMe" should match the naming convention of other test entries. If the enum case and test function are renamed to use all lowercase "ifconfigme", this entry should be updated to ("test_ipv6_ifconfigme", test_ipv6_ifconfigme) to match.

Copilot uses AI. Check for mistakes.
("test_ipv6_myip", test_ipv6_myip),
("test_ipv6_ident", test_ipv6_ident)
]
}
Loading