From 95a11c88d528be534514ccc843faafeb01718694 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Sat, 25 Aug 2012 22:07:05 +0200 Subject: [PATCH] Add host overwriting functionality to Socket::Connection. --- lib/socket.cpp | 6 ++++++ lib/socket.h | 1 + 2 files changed, 7 insertions(+) diff --git a/lib/socket.cpp b/lib/socket.cpp index 1e4458f7..89bf05d1 100644 --- a/lib/socket.cpp +++ b/lib/socket.cpp @@ -442,6 +442,12 @@ std::string Socket::Connection::getHost(){ return remotehost; } +/// Sets hostname for connection manually. +/// Overwrites the detected host, thus possibily making it incorrect. +void setHost(std::string host){ + remotehost = host; +} + /// Returns true if these sockets are the same socket. /// Does not check the internal stats - only the socket itself. bool Socket::Connection::operator== (const Connection &B) const{ diff --git a/lib/socket.h b/lib/socket.h index 0d33573b..2a4f0418 100644 --- a/lib/socket.h +++ b/lib/socket.h @@ -54,6 +54,7 @@ namespace Socket{ void Send(std::string data); ///< Appends data to the upbuffer. void close(); ///< Close connection. std::string getHost(); ///< Gets hostname for connection, if available. + void setHost(std::string host); ///< Sets hostname for connection manually. int getSocket(); ///< Returns internal socket number. std::string getError(); ///< Returns a string describing the last error that occured. unsigned int dataUp(); ///< Returns total amount of bytes sent.