https://github.com/bhuga/faraday-restrict-ip-addresses
Restrict outgoing Faraday traffic by IP address
https://github.com/bhuga/faraday-restrict-ip-addresses
Last synced: 17 days ago
JSON representation
Restrict outgoing Faraday traffic by IP address
- Host: GitHub
- URL: https://github.com/bhuga/faraday-restrict-ip-addresses
- Owner: bhuga
- License: unlicense
- Created: 2014-01-24T20:54:01.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-09-30T19:25:30.000Z (8 months ago)
- Last Synced: 2025-05-01T00:05:53.417Z (23 days ago)
- Language: Ruby
- Size: 28.3 KB
- Stars: 12
- Watchers: 4
- Forks: 16
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Faraday::RestrictIPAddresses
============================Prevent Faraday from hitting an arbitrary list of IP addresses, with helpers
for RFC 1918 networks, RFC 6890 networks, and localhost.System DNS facilities are used, so lookups should be cached instead of making
another request. Addresses are invalid if a host has has at least one invalid
DNS entry.Usage
=====```ruby
faraday = Faraday.new do |builder|
builder.request :url_encoded
builder.request :restrict_ip_addresses, deny_rfc6890: true,
allow_localhost: true,
deny: ['8.0.0.0/8',
'224.0.0.0/7'],
allow: ['192.168.0.0/24']
builder.adapter Faraday.default_adapter
endfaraday.get 'http://www.badgerbadgerbadger.com' # 150.0.0.150 or something
# => coolfaraday.get 'http://malicious-callback.com' # 172.0.0.150, maybe a secret internal server? Maybe not?
# => raises Faraday::RestrictIPAddresses::AddressNotAllowed
```Permit/denied order is:
* All addresses are allowed, except
* Addresses that are denied, except
* Addresses that are allowed.#### Author
Dat @bhuga with shoutouts to @mastahyeti's [gist.](https://gist.github.com/mastahyeti/8497793)
#### UNLICENSE
It's right there.