ames: add libnatpmp for automatic port forwarding#593
Conversation
joemfb
left a comment
There was a problem hiding this comment.
I've noted a couple things that could be cleaner with the libuv handle lifetime.
Also, the function signatures should be adjusted in the normal style.
|
|
||
| if ( c3n == sam_u->pir_u->fak_o ) { | ||
| sam_u->nat_u.tim_u.data = sam_u; | ||
| uv_timer_init(u3L, &sam_u->nat_u.tim_u); |
There was a problem hiding this comment.
I would do this initialization unconditionally in u3_ames_io_init().
There was a problem hiding this comment.
Then, you should close both of these new handles in _ames_io_exit().
| sendnewportmappingrequest(&sam_u->nat_u.req_u, NATPMP_PROTOCOL_UDP, por_s, por_s, 7200); | ||
|
|
||
| sam_u->nat_u.pol_u.data = sam_u; | ||
| uv_poll_init(u3L, &sam_u->nat_u.pol_u, sam_u->nat_u.req_u.s); |
|
|
||
| closenatpmp(&sam_u->nat_u.req_u); | ||
| sam_u->nat_u.tim_u.data = sam_u; | ||
| uv_timer_init(u3L, &sam_u->nat_u.tim_u); |
There was a problem hiding this comment.
This initialization is unnecessary
| closenatpmp(&sam_u->nat_u.req_u); | ||
| return; | ||
| } | ||
| uv_poll_stop(handle); |
There was a problem hiding this comment.
You could move this line before the error check and only have one call to stop()
| u3_ames* sam_u = handle->data; | ||
|
|
||
| natpmpresp_t response; | ||
| c3_w r = readnatpmpresponseorretry(&sam_u->nat_u.req_u, &response); |
There was a problem hiding this comment.
This assignment converts a signed int to an unsigned c3_w. You should c3_i (and suffix the variable name with _i).
Reverts #593 This is very likely what is breaking `urbit/urbit` CI.
Same as urbit/urbit#3261 but for vere. From what I can tell this NAT-PMP stuff is fairly well supported by routers, works on my machine at least.
Same as urbit/urbit#3261 but for vere. From what I can tell this NAT-PMP stuff is fairly well supported by routers, works on my machine at least.