diff --git a/src/client.cpp b/src/client.cpp index 67771e0..423b208 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "network/Socket.h" #include "network/http/HttpRequest.h" @@ -100,6 +102,19 @@ IpAddressInfo get_ip_address_info(Address* addr) { return info; } +string get_os_info(int fd) { + struct tcp_info ti; + socklen_t tisize = sizeof(ti); + getsockopt(fd, IPPROTO_TCP, TCP_INFO, &ti, &tisize); + int winsize = ti.tcpi_rcv_wscale; + + int ttl; + socklen_t ttlsize = sizeof(ttl); + getsockopt(fd, IPPROTO_TCP, IP_TTL, &ttl, &ttlsize); + + return "win_size=" + to_string(winsize) + ", ttl=" + to_string(ttl); +} + string getETag(string filename) { ifstream etags = ifstream("/var/necronda/ETags"); @@ -526,6 +541,7 @@ void client_handler(Socket *socket, long id, bool ssl) { char const *col1; char const *col2 = "\x1B[0m"; IpAddressInfo info = get_ip_address_info(socket->getPeerAddress()); + auto os = get_os_info(socket->getFd()); { auto group = (int) (id % 6); if (group == 0) { @@ -551,6 +567,7 @@ void client_handler(Socket *socket, long id, bool ssl) { log(prefix, "Connection established"); log(prefix, string("Host: ") + info.host + " (" + socket->getPeerAddress()->toString() + ")"); + log(prefix, string("OS: ") + os); log(prefix, string("Location: ") + info.cc + "/" + info.country + ", " + info.prov + "/" + info.provname + ", " + info.city); log(prefix, string("Local Date: ") + info.localdate + " (" + info.timezone + ")"); diff --git a/src/network/Socket.cpp b/src/network/Socket.cpp index 26d7a7b..91425fe 100644 --- a/src/network/Socket.cpp +++ b/src/network/Socket.cpp @@ -109,6 +109,10 @@ Socket::Socket() { servers = false; } +int Socket::getFd() { + return fd; +} + void Socket::setSocketOption(int option, bool value = true) { int val = value ? 1 : 0; diff --git a/src/network/Socket.h b/src/network/Socket.h index 7987441..645b2fa 100644 --- a/src/network/Socket.h +++ b/src/network/Socket.h @@ -91,6 +91,8 @@ public: void close(); + int getFd(); + long getDuration(); Address *getSocketAddress() const;