From 7991b11a15ed984c37b3631c88d48d898d0b3681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Friedrich=20Scho=CC=88ller?= Date: Fri, 12 May 2017 21:18:38 +0200 Subject: [PATCH] Remove unused code --- src/client.cpp | 2 +- src/server.cpp | 2 +- src/tun.cpp | 9 +-------- src/tun.h | 2 +- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 93fbe86..cdc0a94 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -137,7 +137,7 @@ bool Client::handleEchoData(const TunnelHeader &header, int dataLength, uint32_t clientIp = ip; desiredIp = ip; - tun->setIp(ip, (ip & 0xffffff00) + 1, false); + tun->setIp(ip, (ip & 0xffffff00) + 1); } state = STATE_ESTABLISHED; diff --git a/src/server.cpp b/src/server.cpp index 15ce1e8..62c7c6c 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -39,7 +39,7 @@ Server::Server(int tunnelMtu, const char *deviceName, const char *passphrase, ui this->pollTimeout = pollTimeout; this->latestAssignedIpOffset = FIRST_ASSIGNED_IP_OFFSET - 1; - tun->setIp(this->network + 1, this->network + 2, true); + tun->setIp(this->network + 1, this->network + 2); dropPrivileges(); } diff --git a/src/tun.cpp b/src/tun.cpp index ff3d4bc..03f3315 100644 --- a/src/tun.cpp +++ b/src/tun.cpp @@ -88,7 +88,7 @@ Tun::~Tun() tun_close(fd, device); } -void Tun::setIp(uint32_t ip, uint32_t destIp, bool includeSubnet) +void Tun::setIp(uint32_t ip, uint32_t destIp) { char cmdline[512]; string ips = Utility::formatIp(ip); @@ -109,13 +109,6 @@ void Tun::setIp(uint32_t ip, uint32_t destIp, bool includeSubnet) snprintf(cmdline, sizeof(cmdline), "/sbin/ifconfig %s %s %s netmask 255.255.255.255", device, ips.c_str(), destIps.c_str()); if (system(cmdline) != 0) syslog(LOG_ERR, "could not set tun device ip address"); - - if (includeSubnet) - { - snprintf(cmdline, sizeof(cmdline), "/sbin/route add %s/24 %s", destIps.c_str(), destIps.c_str()); - if (system(cmdline) != 0) - syslog(LOG_ERR, "could not add route"); - } #endif } diff --git a/src/tun.h b/src/tun.h index 814ee36..d7e7a73 100644 --- a/src/tun.h +++ b/src/tun.h @@ -38,7 +38,7 @@ public: void write(const char *buffer, int length); - void setIp(uint32_t ip, uint32_t destIp, bool includeSubnet); + void setIp(uint32_t ip, uint32_t destIp); protected: char device[VTUN_DEV_LEN];