summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/ChangeLog7
-rw-r--r--i18n.cpp22
-rw-r--r--pages/setup.ecpp10
-rw-r--r--setup.cpp62
-rw-r--r--setup.h14
5 files changed, 110 insertions, 5 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog
index a10b9ee..69bac21 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,10 @@
+2007-06-03 Christian Wieninger <cwieninger at gmx dot de>
+ Setup includes now a local net mask specifying the address range without
+ necessary login (#321)
+
+2007-06-02 Christian Wieninger <cwieninger at gmx dot de>
+ required version of VDR is now >= 1.4.0-2
+
2007-06-01 Sascha Volkenandt <sascha at akv-soft dot de>
The detection of featured plugins was uniformed. The display in the about
diff --git a/i18n.cpp b/i18n.cpp
index c98a363..fa0c759 100644
--- a/i18n.cpp
+++ b/i18n.cpp
@@ -4099,6 +4099,28 @@ const tI18nPhrase Phrases[] = {
"", // Dansk
"", // Czech
},
+ { "Local net (no login required)", // English
+ "Lokales Netz (keine Anmeldung notwendig)", // Deutsch
+ "", // Slovenski
+ "", // Italiano
+ "", // Nederlands
+ "", // Português
+ "", // Français
+ "", // Norsk
+ "", // Finnish
+ "", // Polski
+ "", // Español
+ "", // Greek
+ "", // Svenska
+ "", // Românã
+ "", // Magyar
+ "", // Català
+ "", // Russian
+ "", // Hrvatski
+ "", // Eesti
+ "", // Dansk
+ "", // Czech
+ },
/*
{ "", // English
"", // Deutsch
diff --git a/pages/setup.ecpp b/pages/setup.ecpp
index 1c0393f..7e17774 100644
--- a/pages/setup.ecpp
+++ b/pages/setup.ecpp
@@ -13,6 +13,7 @@ using namespace std;
string pass;
string times;
string startscreen;
+ string localnetmask;
</%args>
<%session scope="global">
bool logged_in(false);
@@ -31,6 +32,7 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
LiveSetup().SetAdminLogin(login);
if (pass != "")
LiveSetup().SetAdminPassword(pass);
+ LiveSetup().SetLocalNetMask(localnetmask);
}
LiveSetup().SetTimes(times);
LiveSetup().SetStartScreen(startscreen);
@@ -44,10 +46,10 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
lastchannel = lexical_cast<std::string, int>(ilastchannel);
login = LiveSetup().GetAdminLogin();
- useauth = LiveSetup().UseAuth();
+ useauth = LiveSetup().GetUseAuth();
times = LiveSetup().GetTimes();
startscreen = LiveSetup().GetStartScreen();
-
+ localnetmask = LiveSetup().GetLocalNetMask();
</%cpp>
<& pageelems.doc_type &>
<html>
@@ -97,6 +99,10 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
<td><$ tr("Admin password") $>:</td>
<td><input type="password" name="pass" value="<$ pass $>" id="pass" /></td>
</tr>
+ <tr>
+ <td><$ tr("Local net (no login required)") $>:</td>
+ <td><input type="text" name="localnetmask" value="<$ localnetmask $>" id="localnetmask" /></td>
+ </tr>
</table>
</div>
</td>
diff --git a/setup.cpp b/setup.cpp
index 74d853a..82de149 100644
--- a/setup.cpp
+++ b/setup.cpp
@@ -5,6 +5,7 @@
#include <functional>
#include <iostream>
#include <sstream>
+#include <bitset>
#include <getopt.h>
#include <stdint.h>
#include <unistd.h>
@@ -15,6 +16,7 @@
#include <vdr/plugin.h>
#include "setup.h"
#include "tools.h"
+#include <netdb.h>
namespace vdrlive {
@@ -75,6 +77,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 return false;
return true;
}
@@ -142,6 +145,64 @@ std::string Setup::GetStartScreenLink() const
return "whats_on.html?type=now";
}
+bool Setup::UseAuth() const
+{
+ return m_useAuth && !GetIsLocalNet();
+}
+
+bool Setup::CheckLocalNet()
+{
+ // 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;
+ string net = parts[0];
+
+ 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, '.' );
+ if (netparts.size() != 4 || addrparts.size() != 4) return false;
+
+ // to binary representation
+ ostringstream bin_netstream;
+ bin_netstream << bitset<8>(lexical_cast<long>(netparts[0]))
+ << bitset<8>(lexical_cast<long>(netparts[1]))
+ << bitset<8>(lexical_cast<long>(netparts[2]))
+ << bitset<8>(lexical_cast<long>(netparts[3]));
+
+ ostringstream bin_addrstream;
+ bin_addrstream << bitset<8>(lexical_cast<long>(addrparts[0]))
+ << bitset<8>(lexical_cast<long>(addrparts[1]))
+ << bitset<8>(lexical_cast<long>(addrparts[2]))
+ << bitset<8>(lexical_cast<long>(addrparts[3]));
+
+ // compare range
+ string bin_net = bin_netstream.str();
+ 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);
+ m_islocalnet = (bin_net_range == addr_net_range);
+
+ return m_islocalnet;
+}
+
bool Setup::SaveSetup()
{
if (!liveplugin) return false;
@@ -151,6 +212,7 @@ bool Setup::SaveSetup()
{
liveplugin->SetupStore("AdminLogin", m_adminLogin.c_str());
liveplugin->SetupStore("AdminPasswordMD5", m_adminPasswordMD5.c_str());
+ liveplugin->SetupStore("LocalNetMask", m_localnetmask.c_str());
}
liveplugin->SetupStore("UserdefTimes", m_times.c_str());
liveplugin->SetupStore("StartPage", m_startscreen.c_str());
diff --git a/setup.h b/setup.h
index 8c35c5c..17ed32d 100644
--- a/setup.h
+++ b/setup.h
@@ -34,10 +34,13 @@ public:
std::string GetAdminLogin() const { return m_adminLogin; }
std::string GetMD5HashAdminPassword() const;
int GetAdminPasswordLength() const;
- bool UseAuth() const { return m_useAuth; }
+ bool GetUseAuth() const { return m_useAuth; }
+ bool UseAuth() const;
std::string GetTimes() const { return m_times; }
std::string GetStartScreen() const { return m_startscreen; }
std::string GetStartScreenLink() const;
+ std::string GetLocalNetMask() const { return m_localnetmask; };
+ bool GetIsLocalNet() const { return m_islocalnet; };
void SetLastChannel(int lastChannel) { m_lastChannel = lastChannel; }
void SetAdminLogin(std::string login) { m_adminLogin = login; }
@@ -46,7 +49,9 @@ 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 SetIsLocalNet(bool islocalnet) { m_islocalnet = islocalnet; }
+
bool SaveSetup();
bool ParseCommandLine( int argc, char* argv[] );
@@ -74,9 +79,12 @@ private:
std::string m_adminPasswordMD5;
std::string m_times;
std::string m_startscreen;
-
+ std::string m_localnetmask;
+ bool m_islocalnet;
+
bool CheckServerPort();
bool CheckServerIps();
+ bool CheckLocalNet();
};
Setup& LiveSetup();