Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattt/NSEtcHosts
/etc/hosts with NSURLProtocol
https://github.com/mattt/NSEtcHosts
Last synced: about 2 months ago
JSON representation
/etc/hosts with NSURLProtocol
- Host: GitHub
- URL: https://github.com/mattt/NSEtcHosts
- Owner: mattt
- License: mit
- Archived: true
- Created: 2014-04-16T08:08:39.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-07-11T15:37:10.000Z (about 5 years ago)
- Last Synced: 2024-07-27T15:45:12.782Z (about 2 months ago)
- Language: Objective-C
- Size: 52.7 KB
- Stars: 663
- Watchers: 14
- Forks: 78
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# NSEtcHosts
> This project was a proof-of-concept that relied on a combination of factors unique to the time of creation
> that have since been remediated by, among other things,
> the ubiquitous adoption of HTTPS, iOS App Transport Security, and `NSURLSession`.
> Insofar as this approach should ever have been used (it shouldn't)
> the aforementioned improvements to the networking stack render this project inviable.
> Suffice to say, this project is no longer maintained.NSEtcHosts uses `NSURLProtocol` to intercept requests for specified host names,
resolving them instead to a different IP address,
similar to an [`/etc/hosts` file](http://en.wikipedia.org/wiki/Hosts_%28file%29) on a Unix system.
(This does not actually affect the _actual_ hosts file used by iOS,
nor does it affect routing behavior outside of the application process)## Usage
```objective-c
[NSURLProtocol registerClass:[EtcHostsURLProtocol class]];
[EtcHostsURLProtocol configureHostsWithBlock:^(id configuration) {
[configuration resolveHostName:@"google.com" toIPAddress:@"98.138.253.109"];
}];
```## Contact
[Mattt](https://twitter.com/mattt)
## License
NSEtcHosts is available under the MIT license.
See the LICENSE file for more info.