Swiftpack.co - riley-williams/PiholeNetworking as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by riley-williams.
riley-williams/PiholeNetworking 2.0.0
Networking library for interfacing with Pi-hole instances
⭐️ 2
🕓 2 years ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/riley-williams/PiholeNetworking.git", from: "2.0.0")

PiholeNetworking

Swift codecov

Open source networking library for interacting with Pi-hole DNS blocker instances

If you'd rather use Combine, check out version 1.0.0

Getting Started

// Add PHInstance conformance to your existing Pi-hole model type

struct MyPiholeModel {
    var ip: String
    var port: Int
    var password: String?
}

extension MyPiholeModel: PHInstance { }
// Create a shared provider object and a model instance

let provider = PHProvider()

var pihole = MyPiholeModel(ip: "192.168.1.10", port: 80, password: nil)
// Make a request

let summary = try await provider.getSummary(pihole)
    
print("Queries today: \(summary.queryCount)")
print("Queries blocked today: \(summary.blockedQueryCount)")

// Queries today: 49216
// Queries blocked today: 3872
// Many queries require authentication
pihole.password = "MyWebPassword"

// Disable the Pi-hole for 15 seconds
let state = try await provider.disable(pihole, for: 15)

print("Pi-hole is now \(state)")

// Pi-hole is now disabled

GitHub

link
Stars: 2
Last commit: 45 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Async/await
2 years ago

Refactors to use async/await - compatible with Xcode 13 beta

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics