From 60f3a748a498395320247a117a0cbd9a08fecbb4 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 13 Oct 2019 14:44:17 +0200 Subject: [PATCH] Make the client talk to the UDP proxy. --- client/mainwindow.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index 26f684e..39e046c 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -8,6 +8,7 @@ #include #include #include +#include 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); -- 2.39.2