https://github.com/montyanderson/tor-c
Connecting through Tor in C.
https://github.com/montyanderson/tor-c
Last synced: 3 months ago
JSON representation
Connecting through Tor in C.
- Host: GitHub
- URL: https://github.com/montyanderson/tor-c
- Owner: montyanderson
- License: mit
- Created: 2016-12-01T22:27:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-02T11:28:54.000Z (over 8 years ago)
- Last Synced: 2025-01-18T00:33:54.007Z (5 months ago)
- Language: C
- Size: 4.88 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tor-c
C library to connect through Tor.## Example
``` C
#include
#include
#include
#include
#include "tor_connect.h"int main() {
int sock;
ssize_t i, recv_res;
char request[] = "GET http://google.com/\n\n";
char buffer[500];sock = tor_connect(9050, "google.com", 80);
if(sock < 0) {
printf("Failed to connect to socket!\n");
return 1;
}if(send(sock, request, strlen(request), 0) < 0) {
printf("Failed to send!\n");
return 1;
}while(1) {
recv_res = recv(sock, &buffer, sizeof(buffer), 0);if(recv_res < 0) {
break;
}buffer[recv_res] = 0x00; // append null character to string
printf("%s", buffer);
}
}
``````
$ ./a.out
HTTP/1.0 302 Found
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Location: http://www.google.de/?gfe_rd=cr&ei=yVpBWKO4C8LG8AeW2oRw
Content-Length: 256
Date: Fri, 02 Dec 2016 11:28:09 GMT302 Moved
302 Moved
The document has moved
here.```