diff options
author | Kim Alvefur <zash@zash.se> | 2021-09-12 15:47:06 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-09-12 15:47:06 +0200 |
commit | db40eba6557868498685e86216c7dd12294b3434 (patch) | |
tree | 3c6f327bc778854799471038569ac1440c452dd3 /net | |
parent | a9e760fc3b948fcef159faf4e0cb83f8d8c1b9f2 (diff) | |
download | prosody-db40eba6557868498685e86216c7dd12294b3434.tar.gz prosody-db40eba6557868498685e86216c7dd12294b3434.zip |
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.
Diffstat (limited to 'net')
-rw-r--r-- | net/server_epoll.lua | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/net/server_epoll.lua b/net/server_epoll.lua index 2841278d..840e799a 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -272,20 +272,24 @@ end -- 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 |