summaryrefslogtreecommitdiff
path: root/main.c
blob: 5a43f51fd3da376a24c65ef597f664435c1fc052 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <err.h>

#include "tunnel.h"
#include "macro.h"

int main(int argc __unused, char *argv[] __unused)
{
#if 0
	if (geteuid() != 0)
		errx(EXIT_FAILURE, "running as root required");
#endif

	int sock = tunnel_client();
	if (sock < 0)
		errx(EXIT_FAILURE, "tunnel_connect failed");

	char buf[512];

	int n = read(sock, buf, sizeof(buf));
	if (n < 0)
		err(EXIT_FAILURE, "read");

	printf("%.*s\n", n, buf);

	close(sock);

	return 0;
}