Software /
code /
prosody
Changeset
11793:9006ff4838ff
net.server_epoll: Try to make port number related methods sane
Previously it was unclear whether "client port" was the port that the
client connected to, or from. I hereby declare that the client port is
the source port and the server port is the destination port.
Incoming and outgoing connections can be distinguished by looking at
the_server reference, which only incoming connections have.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 12 Sep 2021 15:47:06 +0200 (2021-09-12) |
parents | 11792:fa130e49f19c |
children | 11794:5d925f340ae6 |
files | net/server_epoll.lua |
diffstat | 1 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/net/server_epoll.lua Sun Sep 12 13:45:13 2021 +0200 +++ b/net/server_epoll.lua Sun Sep 12 15:47:06 2021 +0200 @@ -272,20 +272,24 @@ -- Get a port number, doesn't matter which function interface:port() - return self.sockport or self.peerport; + return self.peerport or self.sockport; end --- Get local port number +-- Client-side port (usually a random high port) function interface:clientport() - return self.sockport; + if self._server then + return self.peerport; + else + return self.sockport; + end end --- Get remote port +-- Get port on the server function interface:serverport() - if self.sockport then + if self._server then return self.sockport; - elseif self._server then - self._server:port(); + else + return self.peerport; end end