Merge branch 'master' into pu/mp

This commit is contained in:
Jacek Jendrzej
2017-09-14 13:54:04 +02:00
61 changed files with 50439 additions and 713 deletions

View File

@@ -11,7 +11,7 @@ mod_auth.no_auth_client=
mod_auth.password=coolstream
mod_auth.username=root
mod_cache.cache_directory=/tmp/.cache
mod_sendfile.mime_types=htm:text/html,html:text/html,xml:text/xml,txt:text/plain,jpg:image/jpeg,jpeg:image/jpeg,gif:image/gif,png:image/png,bmp:image/bmp,css:text/css,js:text/plain,img:application/octet-stream,ico:image/x-icon,m3u:application/octet-stream,tar:application/octet-stream,gz:text/x-gzip,ts:application/octet-stream
mod_sendfile.mime_types=htm:text/html,html:text/html,xml:text/xml,txt:text/plain,jpg:image/jpeg,jpeg:image/jpeg,gif:image/gif,png:image/png,bmp:image/bmp,css:text/css,js:text/plain,yjs:text/plain,img:application/octet-stream,ico:image/x-icon,m3u:application/octet-stream,tar:application/octet-stream,gz:text/x-gzip,ts:video/MP2T,mkv:video/x-matroska,avi:video/avi,mp3:audio/mpeg,ogg:audio/ogg
mod_weblog.log_format=
mod_weblog.logfile=/tmp/yhttpd.log
server.chroot=

View File

@@ -21,5 +21,7 @@ AM_CPPFLAGS += \
noinst_LIBRARIES = libnhttpd_tuxboxapi.a
libnhttpd_tuxboxapi_a_SOURCES = \
neutrinoapi.cpp neutrinoyparser.cpp controlapi.cpp
controlapi.cpp \
neutrinoapi.cpp \
neutrinoyparser.cpp

View File

@@ -153,10 +153,10 @@ public:
CControlAPI(CNeutrinoAPI *_NeutrinoAPI);
// virtual functions for HookHandler/Hook
virtual std::string getHookName(void) {return std::string("mod_ControlAPI");}
virtual std::string getHookVersion(void) {return std::string("$Revision$");}
virtual THandleStatus Hook_SendResponse(CyhookHandler *hh);
virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh);
virtual std::string getHookName(void) {return std::string("controlapi");}
virtual std::string getHookVersion(void) {return std::string("$Revision$");}
virtual THandleStatus Hook_SendResponse(CyhookHandler *hh);
virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh);
};
#endif /* __nhttpd_neutrinocontrolapi_hpp__ */

View File

@@ -101,7 +101,6 @@ const char * _getISO639Description(const char * const iso)
//=============================================================================
// Initialization of static variables
//=============================================================================
std::string CNeutrinoAPI::Dbox_Hersteller[4] = {"none", "Nokia", "Philips", "Sagem"};
std::string CNeutrinoAPI::videooutput_names[5] = {"CVBS", "RGB with CVBS", "S-Video", "YUV with VBS", "YUV with CVBS"};
std::string CNeutrinoAPI::videoformat_names[5] = {"automatic", "4:3", "14:9", "16:9", "20:9"};
std::string CNeutrinoAPI::audiotype_names[5] = {"none", "single channel","dual channel","joint stereo","stereo"};

View File

@@ -49,7 +49,6 @@ public:
//bool standby_mode;
// some constants
static std::string Dbox_Hersteller[4];
static std::string videooutput_names[5];
static std::string videoformat_names[5];
static std::string audiotype_names[5];

View File

@@ -104,26 +104,26 @@ THandleStatus CNeutrinoYParser::Hook_ReadConfig(CConfigFile *Config, CStringList
//=============================================================================
const CNeutrinoYParser::TyFuncCall CNeutrinoYParser::yFuncCallList[]=
{
{"mount-get-list", &CNeutrinoYParser::func_mount_get_list},
{"mount-set-values", &CNeutrinoYParser::func_mount_set_values},
{"get_bouquets_as_dropdown", &CNeutrinoYParser::func_get_bouquets_as_dropdown},
{"get_bouquets_as_templatelist",&CNeutrinoYParser::func_get_bouquets_as_templatelist},
{"get_actual_bouquet_number", &CNeutrinoYParser::func_get_actual_bouquet_number},
{"get_channels_as_dropdown", &CNeutrinoYParser::func_get_channels_as_dropdown},
{"mount-get-list", &CNeutrinoYParser::func_mount_get_list},
{"mount-set-values", &CNeutrinoYParser::func_mount_set_values},
{"get_bouquets_as_dropdown", &CNeutrinoYParser::func_get_bouquets_as_dropdown},
{"get_bouquets_as_templatelist", &CNeutrinoYParser::func_get_bouquets_as_templatelist},
{"get_actual_bouquet_number", &CNeutrinoYParser::func_get_actual_bouquet_number},
{"get_channels_as_dropdown", &CNeutrinoYParser::func_get_channels_as_dropdown},
{"get_bouquets_with_epg", &CNeutrinoYParser::func_get_bouquets_with_epg},
{"get_actual_channel_id", &CNeutrinoYParser::func_get_actual_channel_id},
{"get_logo_name", &CNeutrinoYParser::func_get_logo_name},
{"get_mode", &CNeutrinoYParser::func_get_mode},
{"get_video_pids", &CNeutrinoYParser::func_get_video_pids},
{"get_audio_pid", &CNeutrinoYParser::func_get_radio_pid},
{"get_audio_pids_as_dropdown", &CNeutrinoYParser::func_get_audio_pids_as_dropdown},
{"umount_get_list", &CNeutrinoYParser::func_unmount_get_list},
{"get_logo_name", &CNeutrinoYParser::func_get_logo_name},
{"get_mode", &CNeutrinoYParser::func_get_mode},
{"get_video_pids", &CNeutrinoYParser::func_get_video_pids},
{"get_audio_pid", &CNeutrinoYParser::func_get_radio_pid},
{"get_audio_pids_as_dropdown", &CNeutrinoYParser::func_get_audio_pids_as_dropdown},
{"umount_get_list", &CNeutrinoYParser::func_unmount_get_list},
{"get_partition_list", &CNeutrinoYParser::func_get_partition_list},
{"get_boxtype", &CNeutrinoYParser::func_get_boxtype},
{"get_boxmodel", &CNeutrinoYParser::func_get_boxmodel},
{"get_boxtype", &CNeutrinoYParser::func_get_boxtype},
{"get_boxmodel", &CNeutrinoYParser::func_get_boxmodel},
{"get_current_stream_info", &CNeutrinoYParser::func_get_current_stream_info},
{"get_timer_list", &CNeutrinoYParser::func_get_timer_list},
{"set_timer_form", &CNeutrinoYParser::func_set_timer_form},
{"get_timer_list", &CNeutrinoYParser::func_get_timer_list},
{"set_timer_form", &CNeutrinoYParser::func_set_timer_form},
{"bouquet_editor_main", &CNeutrinoYParser::func_bouquet_editor_main},
{"set_bouquet_edit_form", &CNeutrinoYParser::func_set_bouquet_edit_form},
};

View File

@@ -60,8 +60,9 @@ public:
// virtual functions for BaseClass
virtual std::string YWeb_cgi_func(CyhookHandler *hh, std::string ycmd);
// virtual functions for HookHandler/Hook
virtual std::string getHookName(void) {return std::string("mod_NeutrinoYParser-Coolstream");}
virtual std::string getHookName(void) {return std::string("neutrinoyparser");}
virtual std::string getHookVersion(void) {return std::string("$Revision$");}
virtual THandleStatus Hook_SendResponse(CyhookHandler *hh);
virtual THandleStatus Hook_ReadConfig(CConfigFile *Config, CStringList &ConfigList);

View File

@@ -21,61 +21,59 @@
//-----------------------------------------------------------------------------
// System Choice <configure!> ONE choice
//-----------------------------------------------------------------------------
#ifndef CONFIG_SYSTEM_BY_COMPILER // use Compiler directive to set CONFIG_SYSTEM
//#define CONFIG_SYSTEM_TUXBOX y // Tuxbox project
#define CONFIG_SYSTEM_TUXBOX_COOLSTREAM y // Tuxbox project for coolstream
#ifndef CONFIG_SYSTEM_BY_COMPILER // use Compiler directive to set CONFIG_SYSTEM
#define CONFIG_SYSTEM_TUXBOX y // Tuxbox project
#endif
//-----------------------------------------------------------------------------
// General central Definitions <configure!>
//-----------------------------------------------------------------------------
#define HTTPD_VERSION "3.4.0" // Webserver version (can be overloaded)
#define YHTTPD_VERSION "1.3.2" // Webserver version (Version of yhttpd-core!)
#define IADDR_LOCAL "127.0.0.1" // local IP
#define HTTPD_NAME "yhttpd" // Webserver name (can be overloaded)
#define YHTTPD_NAME "yhttpd_core" // Webserver name (Name of yhttpd-core!)
#define AUTH_NAME_MSG "yhhtpd" // Name in Authentication Dialogue
#define CONF_VERSION 4 // Version of yhttpd-conf file
#define HTTPD_KEEPALIVE_TIMEOUT 500000 // Timeout for Keep-Alive in mircoseconds
#define HTTPD_VERSION "3.4.1" // Webserver version (can be overloaded)
#define YHTTPD_VERSION "1.3.2" // Webserver version (Version of yhttpd-core!)
#define IADDR_LOCAL "127.0.0.1" // local IP
#define HTTPD_NAME "yhttpd" // Webserver name (can be overloaded)
#define YHTTPD_NAME "yhttpd_core" // Webserver name (Name of yhttpd-core!)
#define AUTH_NAME_MSG "yhttpd" // Name in Authentication Dialogue
#define CONF_VERSION 4 // Version of yhttpd-conf file
#define HTTPD_KEEPALIVE_TIMEOUT 500000 // Timeout for Keep-Alive in mircoseconds
//=============================================================================
// Features wanted <configure!>
//=============================================================================
//-----------------------------------------------------------------------------
// modules
//-----------------------------------------------------------------------------
//#define Y_CONFIG_USE_TESTHOOK y // Add mod: "Test-Hook" (hook example)
#define Y_CONFIG_USE_YPARSER y // Add mod: "y-Parsing"
#define Y_CONFIG_USE_AUTHHOOK y // Add mod: "Authentication"
#define Y_CONFIG_USE_WEBLOG y // Add mod: "WebLogging"
#define Y_CONFIG_USE_CACHE y // Add mod: Can cache production pages
#define Y_CONFIG_USE_SENDFILE y // Add mod: can send static files (mandantory)
#define Y_CONFIG_USE_YPARSER y // Add mod: "y-Parsing"
#define Y_CONFIG_USE_AUTHHOOK y // Add mod: "Authentication"
#define Y_CONFIG_USE_WEBLOG y // Add mod: "WebLogging"
#define Y_CONFIG_USE_CACHE y // Add mod: Can cache production pages
#define Y_CONFIG_USE_SENDFILE y // Add mod: can send static files (mandantory)
//-----------------------------------------------------------------------------
// Features & Build
//-----------------------------------------------------------------------------
#define Y_CONFIG_FEATURE_CHECK_PORT_AUTORITY y // System: Port < 1024 need Admin-Privileges-Check
#define Y_CONFIG_HAVE_SENDFILE y // System: Have *IX SendFile
#define Y_CONFIG_FEATURE_UPLOAD y // Add Feature: File Upload POST Command
#define Y_CONFIG_USE_HOSTEDWEB y // Add Feature: Use HOSTED Web
#define Y_CONFIG_FEATURE_SHOW_SERVER_CONFIG y // Add Feature (in yParser): add /y/server-config
//#define Y_CONFIG_USE_OPEN_SSL y // Add Feature: use openSSL
#define Y_CONFIG_FEATURE_CHECK_PORT_AUTORITY y // System: Port < 1024 need Admin-Privileges-Check
#define Y_CONFIG_HAVE_SENDFILE y // System: Have *IX SendFile
#define Y_CONFIG_FEATURE_UPLOAD y // Add Feature: File Upload POST Command
#define Y_CONFIG_USE_HOSTEDWEB y // Add Feature: Use HOSTED Web
#define Y_CONFIG_FEATURE_SHOW_SERVER_CONFIG y // Add Feature (in yParser): add /y/server-config
//#define Y_CONFIG_USE_OPEN_SSL y // Add Feature: use openSSL
//#define Y_CONFIG_FEATURE_KEEP_ALIVE y // Add Feature: Keep-alive //FIXME: does not work correctly now
#define Y_CONFIG_FEATUE_SENDFILE_CAN_ACCESS_ALL y // Add Feature: every file can be accessed (use carefully: security!!)
//#define Y_CONFIG_FEATURE_CHROOT y // Add Feature: Use Change Root for Security
//#define Y_CONFIG_FEATURE_CHROOT y // Add Feature: Use Change Root for Security
//#define Y_CONFIG_FEATURE_HTTPD_USER y // Add Feature: Set User for yhttpd-Process
#define Y_CONFIG_BUILD_AS_DAEMON y // Build as a Daemon
#define Y_CONFIG_FEATURE_THREADING y // Build with possibility for multi threading
#define Y_CONFIG_FEATURE_THREADING y // Build with possibility for multi threading
//-----------------------------------------------------------------------------
// Define/Undefine Features forced by CONFIG_SYSTEM_xxx
// Dependencies
//-----------------------------------------------------------------------------
//#ifdef Y_CONFIG_USE_OPEN_SSL
//#undef Y_CONFIG_HAVE_SENDFILE // Sendfile does not work for SSL, but we'll fallback to send
//#undef Y_CONFIG_HAVE_SENDFILE // Sendfile does not work for SSL, but we'll fallback to send
//#endif
#if defined(CONFIG_SYSTEM_TUXBOX) || defined(CONFIG_SYSTEM_TUXBOX_COOLSTREAM)
#ifdef CONFIG_SYSTEM_TUXBOX
#define Y_CONFIG_FEATURE_UPLOAD y
#define Y_CONFIG_USE_YPARSER y
#define Y_CONFIG_USE_AUTHHOOK y
#endif
#ifdef Y_CONFIG_FEATURE_KEEP_ALIVE
#define HTTP_PROTOCOL "HTTP/1.1"
#else
@@ -85,50 +83,45 @@
// Configurations for systems/OSs <configure!>
//=============================================================================
//-----------------------------------------------------------------------------
// Configurations for LINUX (Tuxbox dbox2, coolstream)
//-----------------------------------------------------------------------,js:text/plain------
// Configurations for LINUX (Tuxbox)
//-----------------------------------------------------------------------------
#undef HTTPD_NAME
#define HTTPD_NAME "nhttpd"
#define HTTPD_STANDARD_PORT 80
#define HTTPD_MAX_CONNECTIONS 10
#define HTTPD_REQUEST_LOG "/tmp/httpd_log"
#define SSL_PEMFILE HTTPD_CONFIGDIR "/server.pem"
#define SSL_CA_FILE HTTPD_CONFIGDIR "/cacert.pem"
#define LOG_FILE "/tmp/yhhtpd.log"
#define LOG_FORMAT ""
#define UPLOAD_TMP_FILE "/tmp/upload.tmp"
#define CACHE_DIR "/tmp/.cache"
#define HTTPD_ERRORPAGE "/Y_ErrorPage.yhtm"
#define HTTPD_SENDFILE_EXT "htm:text/html,html:text/html,xml:text/xml,txt:text/plain,jpg:image/jpeg,jpeg:image/jpeg,gif:image/gif,png:image/png,bmp:image/bmp,css:text/css,js:text/plain,yjs:text/plain,img:application/octet-stream,ico:image/x-icon,m3u:application/octet-stream,tar:application/octet-stream,gz:text/x-gzip,ts:video/MP2T,mkv:video/x-matroska,avi:video/avi,mp3:audio/mpeg,ogg:audio/ogg"
#define HTTPD_SENDFILE_ALL "false"
#define HTTPD_LANGUAGEDIR "languages"
#define HTTPD_DEFAULT_LANGUAGE "English"
#define AUTHUSER "root"
#define HTTPD_NAME "nhttpd"
#define HTTPD_STANDARD_PORT 80
#define HTTPD_FALLBACK_PORT 8080
#define HTTPD_MAX_CONNECTIONS 50
#define HTTPD_REQUEST_LOG "/tmp/httpd_log"
#define LOG_FILE "/tmp/yhttpd.log"
#define LOG_FORMAT ""
#define UPLOAD_TMP_FILE "/tmp/upload.tmp"
#define CACHE_DIR "/tmp/.cache"
#define HTTPD_ERRORPAGE "/Y_ErrorPage.yhtm"
#define HTTPD_SENDFILE_EXT "htm:text/html,html:text/html,xml:text/xml,txt:text/plain,jpg:image/jpeg,jpeg:image/jpeg,gif:image/gif,png:image/png,bmp:image/bmp,css:text/css,js:text/plain,yjs:text/plain,img:application/octet-stream,ico:image/x-icon,m3u:application/octet-stream,tar:application/octet-stream,gz:text/x-gzip,ts:video/MP2T,mkv:video/x-matroska,avi:video/avi,mp3:audio/mpeg,ogg:audio/ogg"
#define HTTPD_SENDFILE_ALL "true"
#define HTTPD_LANGUAGEDIR "languages"
#define HTTPD_DEFAULT_LANGUAGE "English"
#define HTTPD_CONFIGDIR CONFIGDIR
#define HTTPD_CONFIGFILE HTTPD_CONFIGDIR"/nhttpd.conf"
#define YWEB_CONFIGFILE HTTPD_CONFIGDIR"/Y-Web.conf"
#define PUBLICDOCUMENTROOT PUBLIC_HTTPDDIR
#define NEUTRINO_CONFIGFILE CONFIGDIR"/neutrino.conf"
#define MOVIEBROWSER_CONFIGFILE CONFIGDIR"/moviebrowser.conf"
#define HOSTEDDOCUMENTROOT HOSTED_HTTPDDIR
#define HOSTEDDOCUMENTURL "/hosted/"
#define EXTRASDOCUMENTROOT HOSTED_HTTPDDIR"/extras"
#define EXTRASDOCUMENTURL "/hosted/extras"
#define ZAPITXMLPATH CONFIGDIR"/zapit"
#define TUXBOX_LOGOS_URL ICONSDIR"/logo"
#define AUTHUSER "root"
#define AUTHPASSWORD "tuxbox"
// switch for Box differences
#ifdef CONFIG_SYSTEM_TUXBOX
#define AUTHPASSWORD "dbox2"
#define PRIVATEDOCUMENTROOT DATADIR "/neutrino/httpd-y"
#endif
#define HTTPD_CONFIGDIR CONFIGDIR
#define HTTPD_CONFIGFILE HTTPD_CONFIGDIR"/nhttpd.conf"
#define YWEB_CONFIGFILE HTTPD_CONFIGDIR"/Y-Web.conf"
#define NEUTRINO_CONFIGFILE CONFIGDIR"/neutrino.conf"
#define MOVIEBROWSER_CONFIGFILE CONFIGDIR"/moviebrowser.conf"
#ifdef CONFIG_SYSTEM_TUXBOX_COOLSTREAM
#define AUTHPASSWORD "coolstream"
#define PRIVATEDOCUMENTROOT PRIVATE_HTTPDDIR
#undef Y_CONFIG_BUILD_AS_DAEMON // No Daemon
#endif
#define PRIVATEDOCUMENTROOT PRIVATE_HTTPDDIR
#define PUBLICDOCUMENTROOT PUBLIC_HTTPDDIR
#define HOSTEDDOCUMENTROOT HOSTED_HTTPDDIR
#define HOSTEDDOCUMENTURL "/hosted/"
#define EXTRASDOCUMENTROOT HOSTED_HTTPDDIR"/extras"
#define EXTRASDOCUMENTURL "/hosted/extras"
#define ZAPITXMLPATH CONFIGDIR"/zapit"
#define TUXBOX_LOGOS_URL LOGODIR
#define SSL_PEMFILE HTTPD_CONFIGDIR "/server.pem"
#define SSL_CA_FILE HTTPD_CONFIGDIR "/cacert.pem"
//-----------------------------------------------------------------------------
// Aggregated definitions
//-----------------------------------------------------------------------------

View File

@@ -55,54 +55,22 @@ static CmodCache mod_cache; // static instance
#endif
//-----------------------------------------------------------------------------
#if defined(CONFIG_SYSTEM_TUXBOX) || defined(CONFIG_SYSTEM_TUXBOX_COOLSTREAM)
#ifdef CONFIG_SYSTEM_TUXBOX
#include "neutrinoapi.h"
#include <config.h>
static CNeutrinoAPI *NeutrinoAPI;
#endif
//=============================================================================
// Main: Main Entry, Command line passing, Webserver Instance creation & Loop
// Main: Main Entry, Webserver thread
//=============================================================================
volatile sig_atomic_t Cyhttpd::sig_do_shutdown = 0;
//-----------------------------------------------------------------------------
// Signal Handling
//-----------------------------------------------------------------------------
#ifdef Y_CONFIG_BUILD_AS_DAEMON
static void sig_catch(int msignal)
{
aprintf("!!! SIGNAL !!! :%d!\n",msignal);
switch (msignal) {
// case SIGTERM:
// case SIGINT:
case SIGPIPE:
aprintf("got signal PIPE, nice!\n");
break;
case SIGHUP:
case SIGUSR1:
aprintf("got signal HUP/USR1, reading config\n");
if (yhttpd)
yhttpd->ReadConfig();
break;
default:
aprintf("No special SIGNAL-Handler:%d!\n",msignal);
// log_level_printf(1, "Got SIGTERM\n");
Cyhttpd::sig_do_shutdown = 1;
yhttpd->stop_webserver();
delete yhttpd;
exit(EXIT_SUCCESS); //FIXME: return to main() some way...
break;
}
}
#endif
//-----------------------------------------------------------------------------
void yhttpd_reload_config() {
if (yhttpd)
yhttpd->ReadConfig();
}
//-----------------------------------------------------------------------------
// Main Entry
//-----------------------------------------------------------------------------
@@ -117,7 +85,6 @@ void thread_cleanup (void *p)
y = NULL;
}
#ifndef Y_CONFIG_BUILD_AS_DAEMON
void * nhttpd_main_thread(void *) {
set_threadname("yweb:main_thread");
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
@@ -152,98 +119,6 @@ void * nhttpd_main_thread(void *) {
aprintf("Main end\n");
return (void *) EXIT_SUCCESS;
}
#endif
#ifdef Y_CONFIG_BUILD_AS_DAEMON
int main(int argc, char **argv)
{
aprintf("Webserver %s\n", WEBSERVERNAME);
bool do_fork = true;
yhttpd = new Cyhttpd();
if(!yhttpd)
{
aprintf("Error initializing WebServer\n");
return EXIT_FAILURE;
}
for (int i = 1; i < argc; i++)
{
if ((!strncmp(argv[i], "-d", 2)) || (!strncmp(argv[i], "--debug", 7)))
{
CLogging::getInstance()->setDebug(true);
do_fork = false;
}
else if ((!strncmp(argv[i], "-f", 2)) || (!strncmp(argv[i], "--fork", 6)))
{
do_fork = false;
}
else if ((!strncmp(argv[i], "-h", 2)) || (!strncmp(argv[i], "--help", 6)))
{
yhttpd->usage(stdout);
return EXIT_SUCCESS;
}
else if ((!strncmp(argv[i], "-v", 2)) || (!strncmp(argv[i],"--version", 9)))
{
yhttpd->version(stdout);
return EXIT_SUCCESS;
}
else if ((!strncmp(argv[i], "-t", 2)) || (!strncmp(argv[i],"--thread-off", 12)))
{
yhttpd->flag_threading_off = true;
}
else if ((!strncmp(argv[i], "-l", 2)) )
{
if(argv[i][2] >= '0' && argv[i][2] <= '9')
CLogging::getInstance()->LogLevel = (argv[i][2]-'0');
}
else
{
yhttpd->usage(stderr);
return EXIT_FAILURE;
}
}
// setup signal catching (subscribing)
signal(SIGPIPE, sig_catch);
signal(SIGINT, sig_catch);
signal(SIGHUP, sig_catch);
signal(SIGUSR1, sig_catch);
signal(SIGTERM, sig_catch);
signal(SIGCLD, SIG_IGN);
// signal(SIGALRM, sig_catch);
yhttpd->hooks_attach();
yhttpd->ReadConfig();
if(yhttpd->Configure())
{
// Start Webserver: fork ist if not in debug mode
aprintf("Webserver starting...\n");
if (do_fork)
{
log_level_printf(9,"do fork\n");
switch (fork()) {
case -1:
dperror("fork");
return -1;
case 0:
break;
default:
return EXIT_SUCCESS;
}
if (setsid() == -1)
{
dperror("Error setsid");
return EXIT_FAILURE;
}
}
dprintf("Start in Debug-Mode\n"); // non forked debugging loop
yhttpd->run();
}
delete yhttpd;
aprintf("Main end\n");
return EXIT_SUCCESS;
}
#endif
//=============================================================================
// Class yhttpd
//=============================================================================
@@ -354,20 +229,6 @@ void Cyhttpd::version(FILE *dest) {
fprintf(dest, "%s - Webserver v%s\n", HTTPD_NAME, HTTPD_VERSION);
}
//-----------------------------------------------------------------------------
// Show Usage
//-----------------------------------------------------------------------------
void Cyhttpd::usage(FILE *dest) {
version(dest);
fprintf(dest, "command line parameters:\n");
fprintf(dest, "-d, --debug enable debugging code (implies -f)\n");
fprintf(dest, "-f, --fork do not fork\n");
fprintf(dest, "-h, --help display this text and exit\n\n");
fprintf(dest, "-v, --version display version and exit\n");
fprintf(dest, "-l<loglevel>, set loglevel (0 .. 9)\n");
fprintf(dest, "-t, --thread-off set threading off\n");
}
//-----------------------------------------------------------------------------
// Stop WebServer
//-----------------------------------------------------------------------------
@@ -388,12 +249,7 @@ void Cyhttpd::hooks_attach() {
CyhookHandler::attach(auth);
#endif
#ifdef Y_CONFIG_USE_TESTHOOK
testhook = new CTesthook();
CyhookHandler::attach(testhook);
#endif
#if defined(CONFIG_SYSTEM_TUXBOX) || defined(CONFIG_SYSTEM_TUXBOX_COOLSTREAM)
#ifdef CONFIG_SYSTEM_TUXBOX
NeutrinoAPI = new CNeutrinoAPI();
CyhookHandler::attach(NeutrinoAPI->NeutrinoYParser);
CyhookHandler::attach(NeutrinoAPI->ControlAPI);
@@ -426,12 +282,7 @@ void Cyhttpd::hooks_detach() {
delete auth;
#endif
#ifdef Y_CONFIG_USE_TESTHOOK
CyhookHandler::detach(testhook);
delete testhook;
#endif
#if defined(CONFIG_SYSTEM_TUXBOX) || defined(CONFIG_SYSTEM_TUXBOX_COOLSTREAM)
#ifdef CONFIG_SYSTEM_TUXBOX
CyhookHandler::detach(NeutrinoAPI->NeutrinoYParser);
#else
#ifdef Y_CONFIG_USE_YPARSER
@@ -470,29 +321,19 @@ void Cyhttpd::ReadConfig(void) {
CConfigFile OrgConfig = *Config;
Config->clear();
Config->setInt32("server.log.loglevel", OrgConfig.getInt32(
"LogLevel", 0));
Config->setInt32("server.log.loglevel", OrgConfig.getInt32("LogLevel", 0));
Config->setInt32("configfile.version", CONF_VERSION);
Config->setString("webserver.websites", "WebsiteMain");
Config->setBool("webserver.threading", OrgConfig.getBool("THREADS",
true));
Config->setInt32("WebsiteMain.port", OrgConfig.getInt32("Port",
HTTPD_STANDARD_PORT));
Config->setString("WebsiteMain.directory", OrgConfig.getString(
"PrivatDocRoot", PRIVATEDOCUMENTROOT));
Config->setBool("webserver.threading", OrgConfig.getBool("THREADS", true));
Config->setInt32("WebsiteMain.port", OrgConfig.getInt32("Port", HTTPD_STANDARD_PORT));
Config->setString("WebsiteMain.directory", OrgConfig.getString("PrivatDocRoot", PRIVATEDOCUMENTROOT));
if (!OrgConfig.getString("PublicDocRoot", "").empty())
Config->setString("WebsiteMain.override_directory",
OrgConfig.getString("PublicDocRoot",
PRIVATEDOCUMENTROOT));
Config->setString("WebsiteMain.override_directory", OrgConfig.getString("PublicDocRoot", PRIVATEDOCUMENTROOT));
// mod_auth
Config->setString("mod_auth.username", OrgConfig.getString(
"AuthUser", AUTHUSER));
Config->setString("mod_auth.password", OrgConfig.getString(
"AuthPassword", AUTHPASSWORD));
Config->setString("mod_auth.no_auth_client", OrgConfig.getString(
"NoAuthClient", ""));
Config->setString("mod_auth.authenticate", OrgConfig.getString(
"Authenticate", "false"));
Config->setString("mod_auth.username", OrgConfig.getString("AuthUser", AUTHUSER));
Config->setString("mod_auth.password", OrgConfig.getString("AuthPassword", AUTHPASSWORD));
Config->setString("mod_auth.no_auth_client", OrgConfig.getString("NoAuthClient", ""));
Config->setString("mod_auth.authenticate", OrgConfig.getString("Authenticate", "false"));
Config->setString("mod_sendfile.mime_types", HTTPD_SENDFILE_EXT);
@@ -503,7 +344,7 @@ void Cyhttpd::ReadConfig(void) {
if (Config->getInt32("configfile.version") < 2) {
Config->setString("mod_sendfile.mime_types", HTTPD_SENDFILE_EXT);
Config->setInt32("configfile.version", CONF_VERSION);
Config->setString("mod_sendfile.sendAll", "false");
Config->setString("mod_sendfile.sendAll", HTTPD_SENDFILE_ALL);
Config->saveConfig(HTTPD_CONFIGFILE);
}
// Add Defaults for Version 4
@@ -523,29 +364,19 @@ void Cyhttpd::ReadConfig(void) {
CLogging::getInstance()->setDebug(true);
// get variables
webserver->init(Config->getInt32("WebsiteMain.port", HTTPD_STANDARD_PORT),
Config->getBool("webserver.threading", true));
webserver->init(Config->getInt32("WebsiteMain.port", HTTPD_STANDARD_PORT), Config->getBool("webserver.threading", true));
// informational use
ConfigList["WebsiteMain.port"] = itoa(Config->getInt32("WebsiteMain.port",
HTTPD_STANDARD_PORT));
ConfigList["webserver.threading"] = Config->getString(
"webserver.threading", "true");
ConfigList["configfile.version"] = Config->getInt32("configfile.version",
CONF_VERSION);
ConfigList["server.log.loglevel"] = itoa(Config->getInt32(
"server.log.loglevel", 0));
ConfigList["server.no_keep-alive_ips"] = Config->getString(
"server.no_keep-alive_ips", "");
webserver->conf_no_keep_alive_ips = Config->getStringVector(
"server.no_keep-alive_ips");
ConfigList["WebsiteMain.port"] = itoa(Config->getInt32("WebsiteMain.port", HTTPD_STANDARD_PORT));
ConfigList["webserver.threading"] = Config->getString("webserver.threading", "true");
ConfigList["configfile.version"] = Config->getInt32("configfile.version", CONF_VERSION);
ConfigList["server.log.loglevel"] = itoa(Config->getInt32("server.log.loglevel", 0));
ConfigList["server.no_keep-alive_ips"] = Config->getString("server.no_keep-alive_ips", "");
webserver->conf_no_keep_alive_ips = Config->getStringVector("server.no_keep-alive_ips");
// MainSite
ConfigList["WebsiteMain.directory"] = Config->getString(
"WebsiteMain.directory", PRIVATEDOCUMENTROOT);
ConfigList["WebsiteMain.override_directory"] = Config->getString(
"WebsiteMain.override_directory", PUBLICDOCUMENTROOT);
ConfigList["WebsiteMain.hosted_directory"] = Config->getString(
"WebsiteMain.hosted_directory", HOSTEDDOCUMENTROOT);
ConfigList["WebsiteMain.directory"] = Config->getString("WebsiteMain.directory", PRIVATEDOCUMENTROOT);
ConfigList["WebsiteMain.override_directory"] = Config->getString("WebsiteMain.override_directory", PUBLICDOCUMENTROOT);
ConfigList["WebsiteMain.hosted_directory"] = Config->getString("WebsiteMain.hosted_directory", HOSTEDDOCUMENTROOT);
ConfigList["Tuxbox.DisplayLogos"] = Config->getString("Tuxbox.DisplayLogos", "true");
// Check location of logos
@@ -578,15 +409,12 @@ void Cyhttpd::ReadConfig(void) {
CySocket::initSSL();
#endif
ConfigList["server.user_name"] = Config->getString("server.user_name", "");
ConfigList["server.group_name"]
= Config->getString("server.group_name", "");
ConfigList["server.group_name"] = Config->getString("server.group_name", "");
ConfigList["server.chroot"] = Config->getString("server.chroot", "");
// language
ConfigList["Language.directory"] = Config->getString("Language.directory",
HTTPD_LANGUAGEDIR);
ConfigList["Language.selected"] = Config->getString("Language.selected",
HTTPD_DEFAULT_LANGUAGE);
ConfigList["Language.directory"] = Config->getString("Language.directory", HTTPD_LANGUAGEDIR);
ConfigList["Language.selected"] = Config->getString("Language.selected", HTTPD_DEFAULT_LANGUAGE);
yhttpd->ReadLanguage();
// Read App specifig settings by Hook
@@ -604,7 +432,6 @@ void Cyhttpd::ReadConfig(void) {
void Cyhttpd::ReadLanguage(void) {
// Init Class vars
CLanguage *lang = CLanguage::getInstance();
log_level_printf(3, "ReadLanguage:%s\n",
ConfigList["Language.selected"].c_str());
log_level_printf(3, "ReadLanguage:%s\n", ConfigList["Language.selected"].c_str());
lang->setLanguage(ConfigList["Language.selected"]);
}

View File

@@ -39,7 +39,6 @@ public:
bool Configure();
void stop_webserver(); // Remove Hooks, Stop Webserver
static void version(FILE *dest);// Show Webserver Version
static void usage(FILE *dest); // Show command line usage
// Hooks
void hooks_attach(); // Add a Hook-Class to HookList
void hooks_detach(); // Remove a Hook-Class from HookList

View File

@@ -17,6 +17,13 @@ AM_CPPFLAGS += -fno-rtti -fno-exceptions -D_FILE_OFFSET_BITS=64
noinst_LIBRARIES = libyhttpd.a
libyhttpd_a_SOURCES = \
ylogging.cpp helper.cpp ylanguage.cpp\
ywebserver.cpp yconnection.cpp yrequest.cpp yresponse.cpp yhook.cpp ysocket.cpp
helper.cpp \
yconnection.cpp \
yhook.cpp \
ylanguage.cpp\
ylogging.cpp \
yrequest.cpp \
yresponse.cpp \
ysocket.cpp \
ywebserver.cpp

View File

@@ -51,7 +51,7 @@ CWebserver::CWebserver() {
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
#endif
port = 80;
port = HTTPD_STANDARD_PORT;
}
//-----------------------------------------------------------------------------
@@ -118,14 +118,15 @@ CWebserver::~CWebserver() {
bool CWebserver::run(void) {
set_threadname("ywebsrv::run");
if (!listenSocket.listen(port, HTTPD_MAX_CONNECTIONS)) {
if (port != 80) {
fprintf(stderr, "[yhttpd] Socket cannot bind and listen on port %d Abort.\n", port);
if (port != HTTPD_STANDARD_PORT) {
// WebsiteMain.port in nhttpd.conf is changed by user
fprintf(stderr, "[yhttpd] Socket cannot bind and listen on port %d. Abort.\n", port);
return false;
}
fprintf(stderr, "[yhttpd] cannot bind and listen on port 80, retrying on port 8080.\n");
port = 8080;
fprintf(stderr, "[yhttpd] Socket cannot bind and listen on port %d. Retrying port %d.\n", HTTPD_STANDARD_PORT, HTTPD_FALLBACK_PORT);
port = HTTPD_FALLBACK_PORT;
if (!listenSocket.listen(port, HTTPD_MAX_CONNECTIONS)) {
fprintf(stderr, "[yhttpd] Socket cannot bind and listen on port %d Abort.\n", port);
fprintf(stderr, "[yhttpd] Socket cannot bind and listen on port %d. Abort.\n", HTTPD_FALLBACK_PORT);
return false;
}
}

View File

@@ -19,5 +19,9 @@ AM_CPPFLAGS += \
noinst_LIBRARIES = libyhttpdmods.a
libyhttpdmods_a_SOURCES = \
mod_yparser.cpp mod_testhook.cpp mod_auth.cpp mod_cache.cpp mod_sendfile.cpp mod_weblog.cpp
mod_auth.cpp \
mod_cache.cpp \
mod_sendfile.cpp \
mod_weblog.cpp \
mod_yparser.cpp

View File

@@ -1,6 +1,6 @@
//=============================================================================
// YHTTPD
// TestHook
// mod_auth : Authentication
//=============================================================================
#include <cstring>

View File

@@ -17,16 +17,12 @@ public:
}
;
// Hooks
virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh);
virtual std::string getHookName(void) {
return std::string("mod_auth");
}
virtual std::string getHookVersion(void) {
return std::string("$Revision$");
}
virtual THandleStatus Hook_ReadConfig(CConfigFile *Config,
CStringList &ConfigList);
// virtual functions for HookHandler/Hook
virtual std::string getHookName(void) {return std::string("mod_auth");}
virtual std::string getHookVersion(void) {return std::string("$Revision$");}
virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh);
virtual THandleStatus Hook_ReadConfig(CConfigFile *Config, CStringList &ConfigList);
protected:
bool CheckAuth(CyhookHandler *hh);
std::string decodeBase64(const char *b64buffer);

View File

@@ -48,12 +48,12 @@ public:
static void RemoveCategoryFromCache(std::string category);
static void DeleteCache(void);
// Hooks
// virtual functions for HookHandler/Hook
virtual std::string getHookName(void) {return std::string("mod_cache");}
virtual std::string getHookVersion(void) {return std::string("$Revision$");}
virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh);
virtual THandleStatus Hook_SendResponse(CyhookHandler *hh);
virtual std::string getHookVersion(void) {return std::string("$Revision$");}
virtual std::string getHookName(void) {return std::string("mod_cache");}
virtual THandleStatus Hook_ReadConfig(CConfigFile *Config,CStringList &ConfigList);
virtual THandleStatus Hook_ReadConfig(CConfigFile *Config, CStringList &ConfigList);
};
#endif /* __yhttpd_mod_cache_h__ */

View File

@@ -28,11 +28,11 @@ public:
CmodSendfile(){};
~CmodSendfile(void){};
// Hooks
virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh);
// virtual THandleStatus Hook_SendResponse(CyhookHandler *hh);
// virtual functions for HookHandler/Hook
virtual std::string getHookName(void) {return std::string("mod_sendfile");}
virtual std::string getHookVersion(void) {return std::string("$Revision$");}
virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh);
// virtual THandleStatus Hook_SendResponse(CyhookHandler *hh);
virtual THandleStatus Hook_ReadConfig(CConfigFile *Config, CStringList &ConfigList);
};

View File

@@ -1,17 +0,0 @@
//=============================================================================
// YHTTPD
// TestHook
//=============================================================================
#include "mod_testhook.h"
THandleStatus CTesthook::Hook_SendResponse(CyhookHandler *hh)
{
THandleStatus status = HANDLED_NONE;
if(hh->UrlData["filename"] == "test2")
{
hh->yresult = "test it 2222\n";
status = HANDLED_READY;
}
return status;
}

View File

@@ -1,21 +0,0 @@
//=============================================================================
// YHTTPD
// TestHook
//=============================================================================
#ifndef TESTHOOK_H_
#define TESTHOOK_H_
#include <yhook.h>
class CTesthook : public Cyhook
{
public:
THandleStatus Hook_SendResponse(CyhookHandler *hh);
CTesthook(){};
~CTesthook(){};
virtual std::string getHookName(void) {return std::string("Testhook");}
};
#endif /*TESTHOOK_H_*/

View File

@@ -33,10 +33,10 @@ public:
void AddLogEntry_ELF(CyhookHandler *hh);
bool printf(const char *fmt, ...);
// Hooks
virtual THandleStatus Hook_EndConnection(CyhookHandler *hh);
// virtual functions for HookHandler/Hook
virtual std::string getHookName(void) {return std::string("mod_weblog");}
virtual std::string getHookVersion(void) {return std::string("$Revision$");}
virtual THandleStatus Hook_EndConnection(CyhookHandler *hh);
virtual THandleStatus Hook_ReadConfig(CConfigFile *Config, CStringList &ConfigList);
};
#endif // __yhttpd_mod_weblog_h__

View File

@@ -113,9 +113,10 @@ public:
// virtual functions for BaseClass
virtual std::string YWeb_cgi_func(CyhookHandler *hh, std::string ycmd);
// virtual functions for HookHandler/Hook
virtual std::string getHookVersion(void) {return std::string("$Revision$");}
virtual std::string getHookName(void) {return "mod_yparser";}
virtual std::string getHookVersion(void) {return std::string("$Revision$");}
virtual THandleStatus Hook_SendResponse(CyhookHandler *hh);
};