MCPcopy Create free account
hub / github.com/ValveSoftware/GameNetworkingSockets / _handle_refresh_request

Function _handle_refresh_request

tests/stun_server.py:282–305  ·  view source on GitHub ↗
(sock, data, addr)

Source from the content-addressed store, hash-verified

280
281
282def _handle_refresh_request(sock, data, addr):
283 tid = data[8:20]
284 key = (addr[0], addr[1])
285 attrs = _parse_attrs(data)
286
287 if not _check_turn_auth(sock, data, attrs, tid, addr, MSG_REFRESH_ERROR):
288 return
289
290 alloc = _allocations.get(key)
291 if alloc is None or alloc.is_expired():
292 err = _build_error_attr(437, b'No Allocation')
293 sock.sendto(_build_response(MSG_REFRESH_ERROR, tid, err), addr)
294 return
295
296 lf_bytes = _get_attr(attrs, ATTR_LIFETIME)
297 lifetime = struct.unpack('!I', lf_bytes)[0] if lf_bytes else TURN_DEFAULT_LIFETIME
298
299 if lifetime == 0:
300 print("Explicit deallocation from %s:%d" % addr, flush=True)
301 _delete_allocation(key)
302 else:
303 alloc.refresh(lifetime)
304
305 sock.sendto(_build_response(MSG_REFRESH_SUCCESS, tid, _build_lifetime_attr(lifetime)), addr)
306
307
308def _handle_create_permission_request(sock, data, addr):

Callers 1

_handle_packetFunction · 0.85

Calls 9

_parse_attrsFunction · 0.85
_check_turn_authFunction · 0.85
_build_error_attrFunction · 0.85
_build_responseFunction · 0.85
_get_attrFunction · 0.85
_delete_allocationFunction · 0.85
_build_lifetime_attrFunction · 0.85
is_expiredMethod · 0.80
refreshMethod · 0.80

Tested by

no test coverage detected