pranomostro / ratox

[wip] fifo based tox client
http://ratox.2f30.org/
ISC License
20 stars 2 forks source link

ratox only works locally #20

Closed pranomostro closed 7 years ago

pranomostro commented 7 years ago

Have to find out which one of these causes the problem. Maybe it's an optimization that it reads fifos not line, but buffer-wise.

pranomostro commented 7 years ago

The issue seems to go deeper than I initially thought. It looks like ratox can handle friend requests at the moment, but it can't send/receive messages/status/name.

Note that this only holds true when ratox is run over a network, not when run locally. However, it looks like the non-local behaviour is visible locally when ratox is compiled with -O2 (I think).

z3bra commented 7 years ago

This is an endianness problem, and is related to https://github.com/TokTok/c-toxcore/issues/205.

Please note that I was having troubles getting correct friend requests between two Little Endian machines (ratox / cyanide). With two local ratox instance, there was no issue.

The following patch helped me fix the friend request issue, but it is platform dependent (depends on endianness), and might break other features that were previously working (I had to rename the shutdown() function to avoid collisions in arpa/inet.h).

diff --git a/ratox.c b/ratox.c
index 961543b..3c14b11 100644
--- a/ratox.c
+++ b/ratox.c
@@ -1,4 +1,6 @@
 /* See LICENSE file for copyright and license details. */
+#include <arpa/inet.h>
+
 #include <sys/select.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -223,7 +225,7 @@ static void friendload(void);
 static void frienddestroy(struct friend *);
 static void loop(void);
 static void initshutdown(int);
-static void shutdown(void);
+static void toxshutdown(void);
 static void usage(void);

 #define FD_APPEND(fd) do { \
@@ -1603,7 +1605,7 @@ setnospam(void *data)
        }
    }

-   nsval = strtoul((char *)nospam, NULL, 16);
+   nsval = htonl(strtoul((char *)nospam, NULL, 16));
    tox_self_set_nospam(tox, nsval);
    datasave();
    logmsg("Nospam > %08X\n", nsval);
@@ -1909,7 +1911,7 @@ initshutdown(int sig)
 }

 static void
-shutdown(void)
+toxshutdown(void)
 {
    struct friend *f, *ftmp;
    struct request *r, *rtmp;
@@ -2016,6 +2018,6 @@ main(int argc, char *argv[])
    localinit();
    friendload();
    loop();
-   shutdown();
+   toxshutdown();
    return 0;
 }
pranomostro commented 7 years ago

Okay, great! I think we'll go with your version until something breaks.

pranomostro commented 7 years ago

I will just have to apply your patch tomorrow.