Skip to content

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

License

Notifications You must be signed in to change notification settings

wadetregaskis/NetworkScanner

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages