From: Steinar H. Gunderson Date: Sun, 13 Oct 2019 12:44:17 +0000 (+0200) Subject: Make the client talk to the UDP proxy. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=60f3a748a498395320247a117a0cbd9a08fecbb4;p=ultimatescore Make the client talk to the UDP proxy. --- 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);