From 3d1a55a20fcd39d98773520e4a72dd202f062eea Mon Sep 17 00:00:00 2001 From: isaced Date: Thu, 21 Dec 2023 19:53:48 +0800 Subject: [PATCH] Update README.md --- README.md | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1e0b4db..191d06e 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,17 @@ # SwiftWhois -SwiftWhois is a Swift library for retrieving WHOIS information of domains. +SwiftWhois is a Swift package that provides a straightforward mechanism for querying Whois information using Apple's Network framework via [NWConnection](https://developer.apple.com/documentation/network/nwconnection). The package aims to abstract the complexity of network communication and parsing to give developers an easy way to implement Whois lookup functionality. ## Features - [x] Automatically select WHOIS server, no need to specify the WHOIS server - [x] Structured WHOIS data, easy to use - [x] Async/await support +- [x] Support for custom WHOIS server ## Requirements -iOS 13.0+ / macOS 10.15+ / tvOS 12.0+ / watchOS 7.0+ +iOS 13.0+ / macOS 10.15+ ## Installation @@ -22,6 +23,8 @@ iOS 13.0+ / macOS 10.15+ / tvOS 12.0+ / watchOS 7.0+ ## Usage +### Basic + ```swift import SwiftWhois @@ -32,9 +35,41 @@ print(result.nameServers) // ["ns1.google.com", "ns2.google.com", "ns3.google.co print(result.creationDate) // 1997-09-15T00:00:00Z print(result.expirationDate) // 2028-09-14T00:00:00Z print(result.updatedDate) // 2021-08-17T17:32:39Z +print(result.domainStatus) // ["clientDeleteProhibited", "clientTransferProhibited", ...] print(result.raw) // Raw WHOIS data ``` +### Custom WHOIS server + +Usually, you don't need to specify the WHOIS server, SwiftWhois will automatically select the WHOIS server for you. But if you want to specify the WHOIS server, you can do it like this: + +```swift +SwiftWhois.lookup(domain: "google.com", server: "whois.verisign-grs.com") +``` + +## Principle + +SwiftWhois leverages NWConnection to perform network operations for Whois protocol interactions. It simplifies the process of fetching and interpreting Whois data, encapsulating the logic required to manage network connectivity and data handling. + +### How it works + +1. Server Discovery: Determines the appropriate Whois server for a given domain or IP address by querying `whois.iana.org` by default, unless an alternative Whois server is specified. +2. Connection: Initiates an NWConnection to the determined Whois server, typically on port 43. + Query Assembly: Creates a properly formatted Whois query for the given domain or IP address based on the server's requirements. +3. Dispatch: Sends the assembled query asynchronously to the Whois server and awaits a response. +4. Reception & Parsing: Receives the server's response, which is a textual Whois record, and parses it to extract meaningful data into a structured representation. +5. Closure: Completes the operation by delivering the parsed Whois information or an error, if encountered, then terminates the network connection. + +## TODO + +- [ ] WHOIS server cache (in-memory, for speed up) +- [ ] More TLDs (Top-Level Domains) test and support + +## Contributing & Support + +- Any TLDs (Top-Level Domains) that are not supported, please open an [issue](https://github.com/isaced/SwiftWhois/issues/new) or [PR](https://github.com/isaced/SwiftWhois/pulls). +- Any bugs or feature requests, please open an [issue](https://github.com/isaced/SwiftWhois/issues/new). + ## License MIT