diff options
author | Kim Alvefur <zash@zash.se> | 2019-09-01 01:55:55 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-09-01 01:55:55 +0200 |
commit | 9afa1ac496bac9d9eaaf687edbdde3f0c7fb66e1 (patch) | |
tree | 34d632de89573f0c4aebf7c9282e50aa9105e274 /net/server_event.lua | |
parent | 66fdfe3c005e8e2fda23efa918e85d890bc632c4 (diff) | |
download | prosody-9afa1ac496bac9d9eaaf687edbdde3f0c7fb66e1.tar.gz prosody-9afa1ac496bac9d9eaaf687edbdde3f0c7fb66e1.zip |
net.server: Accept and save an 'extra' field for client connections
This lets code attach some extra data to be attached to client
connections.
Diffstat (limited to 'net/server_event.lua')
-rw-r--r-- | net/server_event.lua | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/net/server_event.lua b/net/server_event.lua index fde79d86..950a7a5c 100644 --- a/net/server_event.lua +++ b/net/server_event.lua @@ -479,7 +479,7 @@ end -- End of client interface methods -local function handleclient( client, ip, port, server, pattern, listener, sslctx ) -- creates an client interface +local function handleclient( client, ip, port, server, pattern, listener, sslctx, extra ) -- creates an client interface --vdebug("creating client interfacce...") local interface = { type = "client"; @@ -515,6 +515,7 @@ local function handleclient( client, ip, port, server, pattern, listener, sslctx _serverport = (server and server:port() or nil), _sslctx = sslctx; -- parameters _usingssl = false; -- client is using ssl; + extra = extra; } if not has_luasec then interface.starttls = false; end interface.id = tostring(interface):match("%x+$"); @@ -749,14 +750,14 @@ local function addserver( addr, port, listener, pattern, sslctx ) -- TODO: chec }); end -local function wrapclient( client, ip, port, listeners, pattern, sslctx ) - local interface = handleclient( client, ip, port, nil, pattern, listeners, sslctx ) +local function wrapclient( client, ip, port, listeners, pattern, sslctx, extra ) + local interface = handleclient( client, ip, port, nil, pattern, listeners, sslctx, extra ) interface:_start_connection(sslctx) return interface, client --function handleclient( client, ip, port, server, pattern, listener, _, sslctx ) -- creates an client interface end -local function addclient( addr, serverport, listener, pattern, sslctx, typ ) +local function addclient( addr, serverport, listener, pattern, sslctx, typ, extra ) if sslctx and not has_luasec then debug "need luasec, but not available" return nil, "luasec not found" @@ -783,7 +784,7 @@ local function addclient( addr, serverport, listener, pattern, sslctx, typ ) local res, err = client:setpeername( addr, serverport ) -- connect if res or ( err == "timeout" ) then local ip, port = client:getsockname( ) - local interface = wrapclient( client, ip, serverport, listener, pattern, sslctx ) + local interface = wrapclient( client, ip, serverport, listener, pattern, sslctx, extra ) debug( "new connection id:", interface.id ) return interface, err else |