]> git.sesse.net Git - ultimatescore/commitdiff
Make the client talk to the UDP proxy.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 13 Oct 2019 12:44:17 +0000 (14:44 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 13 Oct 2019 12:44:17 +0000 (14:44 +0200)
client/mainwindow.cpp

index 26f684ece2caf52a94e8f35abd5bba06b4040469..39e046c46c666cbd061dd0bca0ac02737038dc51 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <unistd.h>
 
 using namespace std;
 
@@ -396,6 +397,21 @@ void MainWindow::show_nothing_clicked()
        ws->send_command("eval hidetable()");
 }
 
+void udp_thread_nat_func(int sock, int port)
+{
+       sockaddr_in6 saddr6;
+       memset(&saddr6, 0, sizeof(saddr6));
+       saddr6.sin6_family = AF_INET6;
+       inet_pton(AF_INET6, "::ffff:193.35.52.50", &saddr6.sin6_addr);
+       saddr6.sin6_port = htons(port);
+
+       for ( ;; ) {
+               char buf[] = "ping";
+               sendto(sock, buf, 4, 0, (sockaddr *)&saddr6, sizeof(saddr6));
+               sleep(1);
+       }
+}
+
 void MainWindow::udp_thread_func(int port)
 {
        int sock = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
@@ -420,6 +436,8 @@ void MainWindow::udp_thread_func(int port)
                exit(1);
        }
 
+       std::thread(&udp_thread_nat_func, sock, port + 1000).detach();
+
        for ( ;; ) {
                char buf[4096];
                int err = recv(sock, buf, sizeof(buf), 0);