diff options
author | Luca Stauble <gnekoz@gmail.com> | 2012-02-04 01:25:04 +0100 |
---|---|---|
committer | Johannes Schindelin <johannes.schindelin@gmx.de> | 2012-02-03 22:13:11 -0600 |
commit | fe2e2e4b59454f1dcc23715f57b17db331ad36ff (patch) | |
tree | 16d263d20fd2e7784c3ee8c242f33b1c1d8b9f3a /libvncclient/sockets.c | |
parent | 5ea7e51e6bd25f3753a3943271e7410e2cb78f5e (diff) | |
download | libvncserver-fe2e2e4b59454f1dcc23715f57b17db331ad36ff.zip libvncserver-fe2e2e4b59454f1dcc23715f57b17db331ad36ff.tar.gz |
Add an optional parameter to specify the ip address for reverse connections
For security reasons, it can be important to limit which IP addresses a
LibVNCClient-based client should listen for reverse connections. This
commit adds that option.
To preserve binary backwards-compatibility, the field was added to the end
of the rfbclient struct, and the function ListenAtTcpPort retains its
signature (but calls the new ListenAtTcpPortAndAddress).
[jes: shortened the commit subject, added a longer explanation in the
commit body and adjusted style]
Signed-off-by: Luca Stauble <gnekoz@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Diffstat (limited to 'libvncclient/sockets.c')
-rw-r--r-- | libvncclient/sockets.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libvncclient/sockets.c b/libvncclient/sockets.c index 6c8cec1..be9924a 100644 --- a/libvncclient/sockets.c +++ b/libvncclient/sockets.c @@ -480,13 +480,30 @@ FindFreeTcpPort(void) int ListenAtTcpPort(int port) { + return ListenAtTcpPortAndAddress(port, NULL); +} + + + +/* + * ListenAtTcpPortAndAddress starts listening at the given TCP port on + * the given IP address + */ + +int +ListenAtTcpPortAndAddress(int port, const char *address) +{ int sock; struct sockaddr_in addr; int one = 1; addr.sin_family = AF_INET; addr.sin_port = htons(port); - addr.sin_addr.s_addr = htonl(INADDR_ANY); + if (address) { + addr.sin_addr.s_addr = inet_addr(address); + } else { + addr.sin_addr.s_addr = htonl(INADDR_ANY); + } if (!initSockets()) return -1; |