From af1b9543f9f23c5e535b6b0edc2d4fb10a51ea37 Mon Sep 17 00:00:00 2001 From: dmiller Date: Mon, 3 Jun 2024 19:00:31 +0000 Subject: [PATCH] Note and be strict about limits of comm.lua with UDP --- nselib/comm.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nselib/comm.lua b/nselib/comm.lua index 790643dad..48f713d9b 100644 --- a/nselib/comm.lua +++ b/nselib/comm.lua @@ -201,7 +201,7 @@ end -- -- Possible options: -- timeout, connect_timeout, request_timeout: See module documentation --- recv_before: receive data before sending first payload +-- recv_before: receive data before sending first payload (not valid for "udp") -- proto: the protocol to use ("tcp", "udp", or "ssl") -- -- @param host The destination host IP @@ -214,6 +214,11 @@ end -- of the first receive (before sending data) function opencon(host, port, data, opts) opts = opts or {} + local proto = opts.proto or (type(port) == 'table' and port.protocol) + if proto == "udp" then + assert(not opts.recv_before, "opts.recv_before not compatible with UDP.") + assert(data, "opencon with UDP requires a data payload.") + end local status, sd = setup_connect(host, port, opts) if not status then return oops.raise("Failed to connect", false, sd)