• R/O
  • HTTP
  • SSH
  • HTTPS

multi_forward: Commit


Commit MetaInfo

Revisionbc2e87067f2018402bd39aef5ad16d283c249551 (tree)
Zeit2019-10-24 13:30:24
AutorSatoshi Yasuda <7m3tjz@jarl...>
CommiterSatoshi Yasuda

Log Message

modified: forward_in.c
modified: multi_forward.h
modified: multi_forward_utils.c

Ändern Zusammenfassung

Diff

--- a/forward_in.c
+++ b/forward_in.c
@@ -302,6 +302,7 @@ struct MultiConnectTable *multi_table_create(char call[], struct sockaddr_in mul
302302 next->Rp = malloc (sizeof (struct FifoPkt) - 1024);
303303 next->Wp = next->Rp;
304304 next->Rp->next = NULL;
305+ next->hole_punch = FALSE;
305306 MultiConnectTablePnt = next;
306307 return next;
307308 }
@@ -321,6 +322,18 @@ void multi_connect (void)
321322 fflush (log_file);
322323 return; // end
323324 }
325+
326+ next = MultiConnectTablePnt;
327+ while (next)
328+ { if ((next->multi_addr.sin_addr.s_addr == multi_addr.sin_addr.s_addr)
329+ && (next->multi_addr.sin_port == multi_addr.sin_port))
330+ {
331+ if (next->hole_punch) break;
332+ }
333+ next = next->f_chain;
334+ }
335+ if (next == NULL) return;
336+
324337 time (&atime);
325338 if (!memcmp (multi_buff.d_packet.id, "HPCH", 4))
326339 {
--- a/multi_forward.h
+++ b/multi_forward.h
@@ -99,6 +99,7 @@ struct MultiConnectTable
9999 long int gw;
100100 char auth;
101101 char xmit;
102+ char hole_punch;
102103 };
103104
104105 struct MultiConnectTable *MultiConnectTablePnt;
--- a/multi_forward_utils.c
+++ b/multi_forward_utils.c
@@ -255,6 +255,7 @@ void read_hole_punch (char buff[], int length)
255255 int ret;
256256 int len;
257257 time_t atime;
258+ struct MultiConnectTable *pnt;
258259
259260 port = multi_port;
260261 if (length == 10)
@@ -281,15 +282,26 @@ void read_hole_punch (char buff[], int length)
281282 hole_addr.sin_port = htons(port);
282283 hole_addr.sin_addr.s_addr = inet_addr(ip_add);
283284
285+ pnt = MultiConnectTablePnt;
286+ while (pnt)
287+ {
288+ if ((pnt->multi_addr.sin_addr.s_addr == hole_addr.sin_addr.s_addr)
289+ && (pnt->multi_addr.sin_port == hole_addr.sin_port))
290+ {
291+ pnt->hole_punch = TRUE;
292+ break;
293+ }
294+ pnt = pnt->f_chain;
295+ }
296+
284297 ret = sendto (multi_sd, buff, 25, 0,
285298 (struct sockaddr *)&hole_addr, sizeof(hole_addr));
286299 if (ret == -1)
287300 {
288301 time(&atime);
289- fprintf (log_file, "%24.24s mult hole_punch ack error %s\n", ctime(&atime), strerror(errno));
302+ fprintf (log_file, "%24.24s multi hole_punch ack error %s\n", ctime(&atime), strerror(errno));
290303 fflush (log_file);
291304 }
292-
293305 }
294306 }
295307
Show on old repository browser