From d46eaf22e5d691ea192dd8f24c2a9101991234e9 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Tue, 3 Apr 2018 15:43:39 +0200 Subject: [PATCH] Added support for HTTP parameters in HTTPS protocol --- src/output/output_http.cpp | 41 +++++++++++++++++++---------- src/output/output_http_internal.cpp | 6 +++++ src/output/output_https.cpp | 33 +++++++++++++++++++++++ 3 files changed, 66 insertions(+), 14 deletions(-) diff --git a/src/output/output_http.cpp b/src/output/output_http.cpp index 304ebd09..2ce2f5b0 100644 --- a/src/output/output_http.cpp +++ b/src/output/output_http.cpp @@ -280,15 +280,18 @@ namespace Mist { IPC::sharedPage serverCfg(SHM_CONF, DEFAULT_CONF_PAGE_SIZE); DTSC::Scan prots = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("config").getMember("protocols"); unsigned int prots_ctr = prots.getSize(); - - for (unsigned int i=0; i < prots_ctr; ++i){ - if (prots.getIndice(i).getMember("connector").asString() == connector) { - id = i; - break; //pick the first protocol in the list that matches the connector + + JSON::Value p;//properties of protocol + if (connector == "HTTP" || connector == "HTTP.exe"){ + //restore from values in the environment, regardless of configged settings + if (getenv("MIST_HTTP_nostreamtext")){ + p["nostreamtext"] = getenv("MIST_HTTP_nostreamtext"); } - } - if (id == -1) { - connector = connector + ".exe"; + if (getenv("MIST_HTTP_pubaddr")){ + p["pubaddr"] = getenv("MIST_HTTP_pubaddr"); + } + }else{ + //find connector in config for (unsigned int i=0; i < prots_ctr; ++i){ if (prots.getIndice(i).getMember("connector").asString() == connector) { id = i; @@ -296,12 +299,23 @@ namespace Mist { } } if (id == -1) { - connector = connector.substr(0, connector.size() - 4); - DEBUG_MSG(DLVL_ERROR, "No connector found for: %s", connector.c_str()); - configLock.post(); - configLock.close(); - return; + connector = connector + ".exe"; + for (unsigned int i=0; i < prots_ctr; ++i){ + if (prots.getIndice(i).getMember("connector").asString() == connector) { + id = i; + break; //pick the first protocol in the list that matches the connector + } + } + if (id == -1) { + connector = connector.substr(0, connector.size() - 4); + DEBUG_MSG(DLVL_ERROR, "No connector found for: %s", connector.c_str()); + configLock.post(); + configLock.close(); + return; + } } + //read options from found connector + p = prots.getIndice(id).asJSON(); } DEBUG_MSG(DLVL_HIGH, "Connector found: %s", connector.c_str()); @@ -311,7 +325,6 @@ namespace Mist { int argnum = 0; argarr[argnum++] = (char*)tmparg.c_str(); - JSON::Value p = prots.getIndice(id).asJSON(); JSON::Value pipedCapa = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("capabilities").getMember("connectors").getMember(connector).asJSON(); configLock.post(); configLock.close(); diff --git a/src/output/output_http_internal.cpp b/src/output/output_http_internal.cpp index c822cfd2..b8cf6144 100644 --- a/src/output/output_http_internal.cpp +++ b/src/output/output_http_internal.cpp @@ -45,6 +45,12 @@ namespace Mist { myConn = Socket::Connection(fileno(stdout),fileno(stdin) ); myConn.setHost(host); } + if (config->getString("nostreamtext").size()){ + setenv("MIST_HTTP_nostreamtext", config->getString("nostreamtext").c_str(), 1); + } + if (config->getString("pubaddr").size()){ + setenv("MIST_HTTP_pubaddr", config->getString("pubaddr").c_str(), 1); + } if (config->getOption("wrappers",true).size() == 0 || config->getString("wrappers") == ""){ JSON::Value & wrappers = config->getOption("wrappers",true); wrappers.shrink(0); diff --git a/src/output/output_https.cpp b/src/output/output_https.cpp index 61600207..08a6bf10 100644 --- a/src/output/output_https.cpp +++ b/src/output/output_https.cpp @@ -24,7 +24,32 @@ namespace Mist{ capa["required"]["key"]["short"] = "K"; capa["required"]["key"]["default"] = ""; capa["required"]["key"]["type"] = "str"; + + capa["optional"]["wrappers"]["name"] = "Active players"; + capa["optional"]["wrappers"]["help"] = "Which players are attempted and in what order."; + capa["optional"]["wrappers"]["default"] = ""; + capa["optional"]["wrappers"]["type"] = "ord_multi_sel"; + capa["optional"]["wrappers"]["allowed"].append("html5"); + capa["optional"]["wrappers"]["allowed"].append("videojs"); + capa["optional"]["wrappers"]["allowed"].append("dashjs"); + capa["optional"]["wrappers"]["allowed"].append("flash_strobe"); + capa["optional"]["wrappers"]["allowed"].append("silverlight"); + capa["optional"]["wrappers"]["allowed"].append("img"); + capa["optional"]["wrappers"]["option"] = "--wrappers"; + capa["optional"]["wrappers"]["short"] = "w"; cfg->addConnectorOptions(4433, capa); + cfg->addOption("nostreamtext", JSON::fromString("{\"arg\":\"string\", \"default\":\"\", \"short\":\"t\",\"long\":\"nostreamtext\",\"help\":\"Text or HTML to display when streams are unavailable.\"}")); + capa["optional"]["nostreamtext"]["name"] = "Stream unavailable text"; + capa["optional"]["nostreamtext"]["help"] = "Text or HTML to display when streams are unavailable."; + capa["optional"]["nostreamtext"]["default"] = ""; + capa["optional"]["nostreamtext"]["type"] = "str"; + capa["optional"]["nostreamtext"]["option"] = "--nostreamtext"; + cfg->addOption("pubaddr", JSON::fromString("{\"arg\":\"string\", \"default\":\"\", \"short\":\"A\",\"long\":\"public-address\",\"help\":\"Full public address this output is available as.\"}")); + capa["optional"]["pubaddr"]["name"] = "Public address"; + capa["optional"]["pubaddr"]["help"] = "Full public address this output is available as, if being proxied"; + capa["optional"]["pubaddr"]["default"] = ""; + capa["optional"]["pubaddr"]["type"] = "str"; + capa["optional"]["pubaddr"]["option"] = "--public-address"; config = cfg; } @@ -78,6 +103,14 @@ namespace Mist{ args.push_back(Util::getMyPath() + "MistOutHTTP"); args.push_back("--ip"); args.push_back(myConn.getHost()); + if (config->getString("nostreamtext").size()){ + args.push_back("--nostreamtext"); + args.push_back(config->getString("nostreamtext")); + } + if (config->getString("pubaddr").size()){ + args.push_back("--public-address"); + args.push_back(config->getString("pubaddr")); + } args.push_back(""); Util::Procs::socketList.insert(fd[0]); pid_t http_proc = Util::Procs::StartPiped(args, &(fd[1]), &(fd[1]), &fderr);