summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Wieninger <cwieninger (at) gmx (dot) de>2007-06-03 12:13:00 +0000
committerChristian Wieninger <cwieninger (at) gmx (dot) de>2007-06-03 12:13:00 +0000
commit815f8be1b17b7f903b5da9221e733d1fa782eafa (patch)
tree904deb274a1641ad99310fe46a5cd1236e91170b
parent0c31823eaf26a6464320a6f3b157077c80f7185a (diff)
downloadvdr-plugin-live-815f8be1b17b7f903b5da9221e733d1fa782eafa.tar.gz
vdr-plugin-live-815f8be1b17b7f903b5da9221e733d1fa782eafa.tar.bz2
- bug fix for local net mask
-rw-r--r--pages/login.ecpp2
-rw-r--r--pages/setup.ecpp1
-rw-r--r--setup.cpp26
-rw-r--r--setup.h5
4 files changed, 10 insertions, 24 deletions
diff --git a/pages/login.ecpp b/pages/login.ecpp
index e517963..c3863ff 100644
--- a/pages/login.ecpp
+++ b/pages/login.ecpp
@@ -28,6 +28,8 @@ if (action == "login") {
logged_in = false;
}
+LiveSetup().CheckLocalNet(request.getPeerIp());
+
if (logged_in || !LiveSetup().UseAuth()) return reply.redirect(LiveSetup().GetStartScreenLink());
}>
diff --git a/pages/setup.ecpp b/pages/setup.ecpp
index 7e17774..b099c0f 100644
--- a/pages/setup.ecpp
+++ b/pages/setup.ecpp
@@ -33,6 +33,7 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
if (pass != "")
LiveSetup().SetAdminPassword(pass);
LiveSetup().SetLocalNetMask(localnetmask);
+ LiveSetup().CheckLocalNet(request.getPeerIp());
}
LiveSetup().SetTimes(times);
LiveSetup().SetStartScreen(startscreen);
diff --git a/setup.cpp b/setup.cpp
index 82de149..5c60a36 100644
--- a/setup.cpp
+++ b/setup.cpp
@@ -16,7 +16,6 @@
#include <vdr/plugin.h>
#include "setup.h"
#include "tools.h"
-#include <netdb.h>
namespace vdrlive {
@@ -77,7 +76,7 @@ bool Setup::ParseSetupEntry( char const* name, char const* value )
else if ( strcmp( name, "AdminPasswordMD5" ) == 0 ) m_adminPasswordMD5 = value;
else if ( strcmp( name, "UserdefTimes" ) == 0 ) m_times = value;
else if ( strcmp( name, "StartPage" ) == 0 ) m_startscreen = value;
- else if ( strcmp( name, "LocalNetMask" ) == 0 ) { m_localnetmask = value; CheckLocalNet(); }
+ else if ( strcmp( name, "LocalNetMask" ) == 0 ) { m_localnetmask = value; }
else return false;
return true;
}
@@ -150,25 +149,8 @@ bool Setup::UseAuth() const
return m_useAuth && !GetIsLocalNet();
}
-bool Setup::CheckLocalNet()
+bool Setup::CheckLocalNet(const std::string& ip)
{
- // get local ip
- m_islocalnet = false;
- char ac[80];
- if (gethostname(ac, sizeof(ac)) != 0) {
- esyslog("Error: getting local host name.");
- return false;
- }
-
- struct hostent *phe = gethostbyname(ac);
- if (phe == 0) {
- esyslog("Error: bad host lookup.");
- return false;
- }
-
- char * szLocalIP;
- szLocalIP = inet_ntoa (*(struct in_addr *)*phe->h_addr_list);
-
// split local net mask in net and range
vector< string > parts = StringSplit( m_localnetmask, '/' );
if (parts.size() != 2) return false;
@@ -177,7 +159,7 @@ bool Setup::CheckLocalNet()
int range = lexical_cast< int >(parts[1]);
// split net and ip addr in its 4 subcomponents
vector< string > netparts = StringSplit( net, '.' );
- vector< string > addrparts = StringSplit( szLocalIP, '.' );
+ vector< string > addrparts = StringSplit( ip, '.' );
if (netparts.size() != 4 || addrparts.size() != 4) return false;
// to binary representation
@@ -198,6 +180,8 @@ bool Setup::CheckLocalNet()
string bin_addr = bin_addrstream.str();
string bin_net_range(bin_net.begin(), bin_net.begin() + range);
string addr_net_range(bin_addr.begin(), bin_addr.begin() + range);
+ cout << bin_net_range << endl;
+ cout << addr_net_range << endl;
m_islocalnet = (bin_net_range == addr_net_range);
return m_islocalnet;
diff --git a/setup.h b/setup.h
index 17ed32d..9f4b8b5 100644
--- a/setup.h
+++ b/setup.h
@@ -49,7 +49,7 @@ public:
void SetScrenshotInterval(int interval) { m_screenshotInterval = interval; }
void SetTimes(std::string times) { m_times = times; }
void SetStartScreen(std::string startscreen) { m_startscreen = startscreen; }
- void SetLocalNetMask(std::string localnetmask) { m_localnetmask = localnetmask; CheckLocalNet(); }
+ void SetLocalNetMask(std::string localnetmask) { m_localnetmask = localnetmask; }
void SetIsLocalNet(bool islocalnet) { m_islocalnet = islocalnet; }
bool SaveSetup();
@@ -58,7 +58,7 @@ public:
char const* CommandLineHelp() const;
bool ParseSetupEntry( char const* name, char const* value );
-
+ bool CheckLocalNet(const std::string& ip);
private:
Setup();
Setup( Setup const& );
@@ -84,7 +84,6 @@ private:
bool CheckServerPort();
bool CheckServerIps();
- bool CheckLocalNet();
};
Setup& LiveSetup();