stream-lua-nginx-module
stream-lua-nginx-module copied to clipboard
Add getpeercred operation on unix request socket
SO_PEERCRED is afaik available on Linux only, and so far only on unix sockets. This command will not be compiled on other platforms.
syntax: local client = assert(ngx.req.socket(true)) uid, gid, pid = client:getpeercred() if not uid then ... end
@bjne Should we reuse the existing getoption()
method instead? There are just too many getsockopt()
possibilities.
Also, I think we should add a feature test for the SO_PEERCRED
thing directly in the config
file instead of assuming all linux versions do support this thing.
For such things without I/O, it might indeed be more flexible to expose the fd from the cosocket object.
@agentzh
getpeercred
is inspired by luasocket's getpeername
, but I have no strong opinions here, so just tell me what to do. sock:getoption("peercred")
?
Agree with feature testing, will look into it.
so you are suggesting exposing sock:fd()
?