summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorMikhail Osipov <mike.osipov@gmail.com>2019-10-18 17:43:38 +0300
committerMikhail Osipov <mike.osipov@gmail.com>2019-10-18 17:43:38 +0300
commit3b00c7be0e8834402ed93eb42b3a93302076c5ff (patch)
treeebf1643f00d2206c80676b1057f6d42d494d5c3a /main.c
parent9c05f1c4187de3c43c027f6102b6e161b2f7441c (diff)
skel
Diffstat (limited to 'main.c')
-rw-r--r--main.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..5a43f51
--- /dev/null
+++ b/main.c
@@ -0,0 +1,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;
+}