summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGDR! <gdr@gdr.name>2016-05-05 19:41:07 +0200
committerGDR! <gdr@gdr.name>2016-05-05 19:41:07 +0200
commit40d02a986e93253dcc689338b7febb59fba0ebc1 (patch)
tree7672ffb38c2ff3b91e154619d7c32722b5734120
parentcc633e9ad431850d298638dbcdcbf1e8a4dfdeb1 (diff)
parent981501cf1e19d07a11e28cff99b9cd7c7b1d0b1d (diff)
Merge branch 'master' of github.com:gjedeer/tuntox
-rw-r--r--.gitignore4
-rw-r--r--BUILD.md15
-rw-r--r--Makefile.mac28
-rw-r--r--README.md4
-rw-r--r--client.c6
-rw-r--r--mach.c22
-rw-r--r--mach.h14
-rw-r--r--main.c6
8 files changed, 96 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index edf6645..8b6eea7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,3 +27,7 @@
27*.i*86 27*.i*86
28*.x86_64 28*.x86_64
29*.hex 29*.hex
30
31# tuntox related, not needed in repo
32tuntox
33gitversion.h
diff --git a/BUILD.md b/BUILD.md
index c0d340c..5de078c 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -4,4 +4,17 @@
4* cd tuntox 4* cd tuntox
5* make 5* make
6 6
7The makefile creates a static binary by default. If you're not a fan of static binaries, remove "-static" from LDFLAGS. One reason to do so may be if you'd like to resolve hostnames on the tuntox server (invoke client with -L 80:reddit.com:80 instead of -L 80:198.41.208.138:80). Static linking breaks hostname resolution, but IMHO the pros overweight the cons. 7The makefile creates a static binary by default. If you're not a fan of static binaries, remove `-static` from `LDFLAGS`.
8
9One reason to do so may be if you'd like to resolve hostnames on the tuntox server (invoke client with `-L 80:reddit.com:80` instead of `-L 80:198.41.208.138:80`).
10
11Static linking breaks hostname resolution, but IMHO the pros overweight the cons.
12
13## MacOS build
14Basically the same as above but:
15
16* static compiling is removed - you can't do this on MacOS platform (no, just don't)
17* because of removed `-static` you can't resolve hostnames (you can always put it into `hosts` file in your system)
18
19If you'd like to build on Mac do: `make -f Makefile.mac`
20
diff --git a/Makefile.mac b/Makefile.mac
new file mode 100644
index 0000000..ee41cda
--- /dev/null
+++ b/Makefile.mac
@@ -0,0 +1,28 @@
1SOURCES = $(wildcard *.c)
2DEPS=libtoxcore
3CC=gcc
4CFLAGS=-g #-std=c99
5CFLAGS += $(shell pkg-config --cflags $(DEPS))
6LDFLAGS=-g -lm
7LDFLAGS += $(shell pkg-config --libs $(DEPS))
8OBJECTS=$(SOURCES:.c=.o)
9INCLUDES = $(wildcard *.h)
10
11all: cscope.out tuntox
12
13gitversion.h: .git/HEAD .git/index
14 echo "#define GITVERSION \"$(shell git rev-parse HEAD)\"" > $@
15
16gitversion.c: gitversion.h
17
18.c.o: $(INCLUDES)
19 $(CC) $(CFLAGS) $< -c -o $@
20
21tuntox: $(OBJECTS) $(INCLUDES)
22 $(CC) -o $@ $(OBJECTS) -ltoxcore $(LDFLAGS) /usr/local/lib/libsodium.a /usr/local/lib/libtoxcore.a
23
24cscope.out:
25 cscope -bv ./*.[ch]
26
27clean:
28 rm -rf *.o tuntox gitversion.h
diff --git a/README.md b/README.md
index 05a98b8..75278ec 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,8 @@ Tuntox is a single binary which may run in client mode or server mode. As a rule
8 8
9If you don't know what Tox is - it's an instant messenger protocol which is fully P2P, supports audio/video calls and file transfers. Unlike Skype it's fully open and unlike, say, XMPP - the calls and file transfers actually work. Go download a client from http://utox.org/ or read more at https://tox.im/ 9If you don't know what Tox is - it's an instant messenger protocol which is fully P2P, supports audio/video calls and file transfers. Unlike Skype it's fully open and unlike, say, XMPP - the calls and file transfers actually work. Go download a client from http://utox.org/ or read more at https://tox.im/
10 10
11[![Coverity Scan Build Status](https://scan.coverity.com/projects/5690/badge.svg)](https://scan.coverity.com/projects/5690)
12
11## Binary 13## Binary
12 14
13Get the binaries from Releases tab on github. Just download the correct file for your architecture, execute chmod +x and you're done. The binaries are signed with my PGP key, [11C1 B15A 5D5D D662 E469 928A EBDA 6B97 4ED3 D2B7](https://keybase.io/gdr). 15Get the binaries from Releases tab on github. Just download the correct file for your architecture, execute chmod +x and you're done. The binaries are signed with my PGP key, [11C1 B15A 5D5D D662 E469 928A EBDA 6B97 4ED3 D2B7](https://keybase.io/gdr).
@@ -68,6 +70,6 @@ Tuntox is piggybacking on the Tox protocol, which itself has not been audited by
68 70
69Sorry about GPLv3 - both toxcore and utox (from which I borrowed some code) are GPLv3. 71Sorry about GPLv3 - both toxcore and utox (from which I borrowed some code) are GPLv3.
70 72
71Thank you to the toxcore and utox developers without whom this program would never exist. [Donate to Tox](https://donate.tox.im/) so they can get a proper audit. 73Thank you to the toxcore and utox developers without whom this program would never exist.
72 74
73Thank you Mr_4551 for your help and motivation. 75Thank you Mr_4551 for your help and motivation.
diff --git a/client.c b/client.c
index fff4620..bfcab14 100644
--- a/client.c
+++ b/client.c
@@ -1,4 +1,10 @@
1#include <time.h> 1#include <time.h>
2
3/* MacOS related */
4#ifdef __MACH__
5#include "mach.h"
6#endif
7
2#include "log.h" 8#include "log.h"
3#include "main.h" 9#include "main.h"
4#include "client.h" 10#include "client.h"
diff --git a/mach.c b/mach.c
new file mode 100644
index 0000000..a9095f6
--- /dev/null
+++ b/mach.c
@@ -0,0 +1,22 @@
1#ifdef __MACH__
2#include "mach.h"
3
4/* there is no clock_gettime on MacOS platform */
5int clock_gettime(int clk_id, struct timespec *t)
6{
7 mach_timebase_info_data_t timebase;
8 mach_timebase_info(&timebase);
9
10 uint64_t time;
11
12 time = mach_absolute_time();
13
14 double nseconds = ((double)time * (double)timebase.numer) / ((double)timebase.denom);
15 double seconds = ((double)time * (double)timebase.numer) / ((double)timebase.denom * 1e9);
16
17 t->tv_sec = seconds;
18 t->tv_nsec = nseconds;
19
20 return 0;
21}
22#endif
diff --git a/mach.h b/mach.h
new file mode 100644
index 0000000..5ac9a4e
--- /dev/null
+++ b/mach.h
@@ -0,0 +1,14 @@
1#ifndef _MACH_H
2#define _MACH_H
3
4#include <time.h>
5#include <mach/mach_time.h>
6
7// there is no CLOCK_REALTIME or CLOCK_MONOTONIC on MacOS platform
8#define CLOCK_REALTIME 0
9#define CLOCK_MONOTONIC 0
10
11// MacOS doesn't support the flag MSG_NOSIGNAL
12#define MSG_NOSIGNAL SO_NOSIGPIPE
13
14#endif \ No newline at end of file
diff --git a/main.c b/main.c
index 24c8df6..0535e67 100644
--- a/main.c
+++ b/main.c
@@ -3,6 +3,10 @@
3#include "tox_bootstrap.h" 3#include "tox_bootstrap.h"
4#include "log.h" 4#include "log.h"
5 5
6#ifdef __MACH__
7 #include "mach.h"
8#endif
9
6static struct Tox_Options tox_options; 10static struct Tox_Options tox_options;
7Tox *tox; 11Tox *tox;
8int client_socket = 0; 12int client_socket = 0;
@@ -1135,7 +1139,7 @@ int main(int argc, char *argv[])
1135 do_daemonize(); 1139 do_daemonize();
1136 } 1140 }
1137 1141
1138 on_exit(cleanup, NULL); 1142 atexit(cleanup);
1139 1143
1140 print_version(); 1144 print_version();
1141 1145