https://github.com/hakobe/paranoidhttp
Paranoidhttp provides a pre-configured http.Client that protects you from harm.
https://github.com/hakobe/paranoidhttp
go http
Last synced: 3 months ago
JSON representation
Paranoidhttp provides a pre-configured http.Client that protects you from harm.
- Host: GitHub
- URL: https://github.com/hakobe/paranoidhttp
- Owner: hakobe
- License: mit
- Created: 2015-08-03T14:16:26.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-07-11T10:38:08.000Z (over 2 years ago)
- Last Synced: 2025-03-24T05:35:02.626Z (10 months ago)
- Topics: go, http
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 37
- Watchers: 5
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Paranoidhttp
[](https://github.com/hakobe/paranoidhttp/actions/workflows/test.yml)
[][coveralls]
[][license]
[][godoc]
[travis]: https://travis-ci.org/hakobe/paranoidhttp
[coveralls]: https://coveralls.io/r/hakobe/paranoidhttp?branch=master
[license]: https://github.com/hakobe/paranoidhttp/blob/master/LICENSE
[godoc]: https://pkg.go.dev/github.com/hakobe/paranoidhttp
Paranoidhttp provides a pre-configured http.Client that protects you from harm.
## Description
Paranoidhttp is a factory of http.Client that is paranoid againt attackers.
This is useful when you create an HTTP request using inputs from possibly malicious users.
The created http.Client protects you from connecting to internal IP ranges
even though redirects or DNS tricks are used.
## Synopsis
```go
// use the default client for ease
res, err := paranoidhttp.DefaultClient.Get("http://www.hatena.ne.jp")
// or customize the client for yourself
client, transport, dialer := paranoidhttp.NewClient()
client.Timeout = 10 * time.Second
transport.DisableCompression = true
dialer.KeepAlive = 60 * time.Second
// Add an permitted ipnets with functional option
ipNet, _ := net.ParseCIDR("127.0.0.1/32")
client, _, _ := paranoidhttp.New(
paranoidhttp.PermittedIPNets(ipNet))
```
## Acknowledgement
I want to thank [LWPx::ParanoidAgent](https://metacpan.org/pod/LWPx::ParanoidAgent).
## License
[MIT](./LICENSE)
## Author
[hakobe](http://github.com/hakobe)