mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
Send up to 10 stun requests, once per second
This commit is contained in:
parent
7d970d8f92
commit
e5f5256aaa
@ -70,6 +70,7 @@ struct subscriber{
|
||||
|
||||
// if reachable&REACHABLE_UNICAST send packets to this address, else use the interface broadcast address
|
||||
struct sockaddr_in address;
|
||||
time_ms_t last_stun_request;
|
||||
time_ms_t last_probe;
|
||||
time_ms_t last_rx;
|
||||
time_ms_t last_tx;
|
||||
|
@ -494,6 +494,12 @@ int overlay_send_stun_request(struct subscriber *server, struct subscriber *requ
|
||||
if (subscriber_is_reachable(request)&REACHABLE_DIRECT)
|
||||
return -1;
|
||||
|
||||
time_ms_t now = gettime_ms();
|
||||
if (request->last_stun_request +1000 > now)
|
||||
return -1;
|
||||
|
||||
request->last_stun_request=now;
|
||||
|
||||
overlay_mdp_frame mdp;
|
||||
bzero(&mdp, sizeof(mdp));
|
||||
mdp.packetTypeAndFlags=MDP_TX;
|
||||
|
8
vomp.c
8
vomp.c
@ -472,6 +472,12 @@ static void prepare_vomp_header(struct vomp_call_state *call, overlay_mdp_frame
|
||||
mdp->out.payload[4]=(call->remote.session>>0)&0xff;
|
||||
mdp->out.payload[5]=(call->remote.state<<4)|call->local.state;
|
||||
mdp->out.payload_length=6;
|
||||
|
||||
// keep trying to punch a NAT tunnel for 10s
|
||||
// note that requests are rate limited internally to one packet per second
|
||||
time_ms_t now = gettime_ms();
|
||||
if (call->local.state < VOMP_STATE_CALLENDED && call->create_time + 10000 >now)
|
||||
overlay_send_stun_request(directory_service, call->remote.subscriber);
|
||||
}
|
||||
|
||||
/* send updated call status to end-point and to any interested listeners as
|
||||
@ -510,8 +516,6 @@ static int vomp_send_status_remote(struct vomp_call_state *call)
|
||||
|
||||
if (config.debug.vomp)
|
||||
DEBUGF("mdp frame with codec list is %d bytes", mdp.out.payload_length);
|
||||
|
||||
overlay_send_stun_request(directory_service, call->remote.subscriber);
|
||||
}
|
||||
|
||||
call->local.sequence++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user