Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aerth/tgun
Go TCP/HTTP Library, Easy headers, proxy, auth and user agent. Now also a libcurl replacement for C programs.
https://github.com/aerth/tgun
api-client client headers http network proxy
Last synced: 2 months ago
JSON representation
Go TCP/HTTP Library, Easy headers, proxy, auth and user agent. Now also a libcurl replacement for C programs.
- Host: GitHub
- URL: https://github.com/aerth/tgun
- Owner: aerth
- License: bsd-3-clause
- Created: 2017-12-04T20:00:56.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-28T15:18:02.000Z (over 1 year ago)
- Last Synced: 2024-08-05T09:11:44.622Z (6 months ago)
- Topics: api-client, client, headers, http, network, proxy
- Language: Go
- Homepage:
- Size: 41 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tgun
### a http and tcp client with common options
* Use **Proxy** (http, socks4, socks5, tor)
* Use custom **UserAgent** (even during redirects)
* Set **headers**
* Use **simple authentication**
* Custom timeout```
// set headers if necessary
headers := map[string]string{
"API_KEY": "12345"
"API_SECRET": "12345"
}// set user agent and proxy in the initialization
dialer := tgun.Client{
Proxy: "socks5://localhost:1080",
UserAgent: "MyCrawler/0.1 (https://github.com/user/repo)",
Headers: headers,
}// get bytes
b, err := dialer.GetBytes("https://example.org")```
See [tgun_test.go](tgun_test.go) for more examples.
### c usage
harness tgun in your c application!
first `make` in plugin directory, creating `tgun.a tgun.so tgun.h` and an example `tgun` curl-like application.
```
#includeint main(){
// set user-agent
easy_ua("libtgun/1.0");
// set proxy url, or alias 'tor' (9050 or 9150 depending on platform) or 'socks' (127.0.0.1:1080)
easy_proxy("tor");
char* b = get_url("http://example.org");// if any errors, NULL is returned and an error is waiting
if (!b) {
fprintf(stderr, "error: %s\n", tgunerr());
} else {
// normal string, do something with it, then free().
printf("%s", b);
free(b);
}
}```
see [plugin](plugin) directory for c usage example