TsgcSTUNServer › 事件 › OnSTUNRequestError
在服务器发送 STUN 错误响应之前触发;允许处理程序检查或抑制回复。
property OnSTUNRequestError: TsgcSTUNRequestErrorEvent;
// TsgcSTUNRequestErrorEvent = procedure(Sender: TObject; const aSocket: TsgcSocketConnection; const aRequest: TsgcSTUN_Message; const aResponse: TsgcSTUN_Message; var Accept: Boolean) of object
—
当服务器已构建绑定错误响应(例如 400 Bad Request、401 Unauthorized、420 Unknown Attribute 或 438 Stale Nonce)并即将将其发回客户端时触发。检查 aRequest/aResponse(特别是 aResponse 的 ERROR-CODE 属性)以记录失败原因。将 Accept := False 设置为丢弃数据报并让客户端没有回复,这在来自同一来源的重复无效请求到达时有助于避免放大攻击。处理程序在监听器线程上运行,除非 NotifyEvents 选择了其他模式。
procedure TForm1.OnSTUNRequestError(Sender: TObject;
const aSocket: TsgcSocketConnection; const aRequest: TsgcSTUN_Message;
const aResponse: TsgcSTUN_Message; var Accept: Boolean);
begin
Memo1.Lines.Add('STUN error for ' + aSocket.PeerIP);
Accept := True;
end;