NetworkScanner

main

Scan a specific network or the local networks for hosts which satisfy an arbitrary condition.
wadetregaskis/NetworkScanner

NetworkScanner

GitHub code size in bytes GitHub build results

Provides a way to scan a specific network or the local networks for hosts which satisfy an arbitrary condition.

The API and implementation use Swift Structured Concurrency (await/async, Task, etc).

For example, to find all HTTPS servers on the local network that respond successfully to a request for their main page:

import Foundation
import NetworkScanner

let scanner = NetworkScanner(concurrencyLimit: 250) { address in
    guard let URL = URL(string: "https://\(address)") else {
        throw Errors.unableToConstructURL(address: address)
    }
    
    do {
        _ = try await session.data(from: URL)
        return .hit
    } catch {
        return .miss
    }
}

for try await result in scanner {
    print(result) // e.g. "192.168.0.10: Hit"
}

enum Errors: Error {
    case unableToConstructURL(address: String)
}

See the documentation for more details, as well as the included demo application for more probe examples.

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

Last updated: Fri Oct 18 2024 13:34:42 GMT-0900 (Hawaii-Aleutian Daylight Time)