diff --git a/CMakeLists.txt b/CMakeLists.txt index 10767a23..ba606239 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,10 @@ endif() if (DEFINED UDP_API_PORT ) add_definitions(-DUDP_API_PORT=${UDP_API_PORT}) endif() +if (NOT DEFINED APPNAME ) + set(APPNAME "MistServer") +endif() +add_definitions(-DAPPNAME="${APPNAME}") ######################################## # Build Variables - Thread Names # diff --git a/lib/defines.h b/lib/defines.h index 4096cbea..850ac0c6 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -21,6 +21,7 @@ #define PRETTY_ARG_MSTIME(t) PRETTY_ARG_TIME(t / 1000), (int)(t % 1000) #if DEBUG > -1 +#define APPIDENT APPNAME "/" PACKAGE_VERSION #define __STDC_FORMAT_MACROS 1 #include "config.h" #include diff --git a/lib/downloader.cpp b/lib/downloader.cpp index a1001a89..3bf260b4 100644 --- a/lib/downloader.cpp +++ b/lib/downloader.cpp @@ -117,7 +117,11 @@ namespace HTTP{ } if (method.size()){H.method = method;} - H.SetHeader("User-Agent", "MistServer " PACKAGE_VERSION); + if (link.host.find("mistserver") != std::string::npos){ + H.SetHeader("User-Agent", "MistServer" PACKAGE_VERSION); + }else{ + H.SetHeader("User-Agent", APPIDENT); + } H.SetHeader("X-Version", PACKAGE_VERSION); H.SetHeader("Accept", "*/*"); if (authStr.size() && (link.user.size() || link.pass.size())){ diff --git a/lib/sdp_media.cpp b/lib/sdp_media.cpp index 3da14a2d..1e35d9d1 100644 --- a/lib/sdp_media.cpp +++ b/lib/sdp_media.cpp @@ -840,7 +840,7 @@ namespace SDP{ M.setCodec(tid, codecRTP2Mist(answerVideoFormat.encodingName)); if (M.getCodec(tid).empty()){ - FAIL_MSG("Failed to convert the format codec into one that MistServer understands. %s.", + FAIL_MSG("Failed to convert the format codec into one that " APPNAME " understands. %s.", answerVideoFormat.encodingName.c_str()); return false; } @@ -859,7 +859,7 @@ namespace SDP{ M.setCodec(tid, codecRTP2Mist(answerAudioFormat.encodingName)); if (M.getCodec(tid).empty()){ - FAIL_MSG("Failed to convert the format codec into one that MistServer understands. %s.", + FAIL_MSG("Failed to convert the format codec into one that " APPNAME " understands. %s.", answerAudioFormat.encodingName.c_str()); return false; } diff --git a/lib/ts_packet.cpp b/lib/ts_packet.cpp index 608a03de..e93040ee 100644 --- a/lib/ts_packet.cpp +++ b/lib/ts_packet.cpp @@ -1515,9 +1515,10 @@ namespace TS{ entry.setFreeCAM(true); // Not conditional access std::string sdti; sdti += (char)0x48; - sdti += (char)(15 + streamName.size()); // length + sdti += (char)(4 + strlen(APPNAME) + streamName.size()); // length sdti += (char)1; // digital television service - sdti.append("\012MistServer"); + sdti += (char)strlen(APPNAME); + sdti.append(APPNAME); sdti += (char)streamName.size(); sdti.append(streamName); entry.setESInfo(sdti); diff --git a/src/controller/controller.cpp b/src/controller/controller.cpp index 9ec6fd3d..7de1210f 100644 --- a/src/controller/controller.cpp +++ b/src/controller/controller.cpp @@ -212,7 +212,7 @@ int main_loop(int argc, char **argv){ strftime(buffer, 25, "%c", timeinfo); std::cerr << std::endl << std::endl - << "!----MistServer Started at " << buffer << " ----!" << std::endl; + << "!----" APPNAME " Started at " << buffer << " ----!" << std::endl; } } // reload config from config file diff --git a/src/controller/controller_api.cpp b/src/controller/controller_api.cpp index 827d94c7..e9155fe5 100644 --- a/src/controller/controller_api.cpp +++ b/src/controller/controller_api.cpp @@ -344,7 +344,7 @@ int Controller::handleAPIConnection(Socket::Connection &conn){ if (!authorized){ H.Clean(); H.body = "Please login first or provide a valid token authentication."; - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.SetHeader("WWW-Authenticate", "json " + req["authorize"].toString()); H.SendResponse("403", "Not authorized", conn); H.Clean(); @@ -358,7 +358,7 @@ int Controller::handleAPIConnection(Socket::Connection &conn){ if (!authorized){ H.Clean(); H.body = "Please login first or provide a valid token authentication."; - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.SendResponse("403", "Not authorized", conn); H.Clean(); continue; @@ -388,7 +388,7 @@ int Controller::handleAPIConnection(Socket::Connection &conn){ H.Clean(); H.SetHeader("Content-Type", "text/html"); H.SetHeader("X-Info", "To force an API response, request the file /api"); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.SetHeader("Content-Length", server_html_len); H.SetHeader("X-UA-Compatible", "IE=edge;chrome=1"); H.SendResponse("200", "OK", conn); diff --git a/src/controller/controller_capabilities.cpp b/src/controller/controller_capabilities.cpp index a58dba6f..dbd8d4c6 100644 --- a/src/controller/controller_capabilities.cpp +++ b/src/controller/controller_capabilities.cpp @@ -16,13 +16,13 @@ namespace Controller{ /// Generate list of available triggers, storing in global 'capabilities' JSON::Value. void checkAvailTriggers(){ JSON::Value &trgs = capabilities["triggers"]; - trgs["SYSTEM_START"]["when"] = "After MistServer boot"; + trgs["SYSTEM_START"]["when"] = "After " APPNAME " boot"; trgs["SYSTEM_START"]["stream_specific"] = false; trgs["SYSTEM_START"]["payload"] = ""; trgs["SYSTEM_START"]["response"] = "always"; trgs["SYSTEM_START"]["response_action"] = "If false, shuts down the server."; - trgs["SYSTEM_STOP"]["when"] = "Before MistServer shuts down"; + trgs["SYSTEM_STOP"]["when"] = "Before " APPNAME " shuts down"; trgs["SYSTEM_STOP"]["stream_specific"] = false; trgs["SYSTEM_STOP"]["payload"] = "shutdown reason (string)"; trgs["SYSTEM_STOP"]["response"] = "always"; diff --git a/src/controller/controller_statistics.cpp b/src/controller/controller_statistics.cpp index 25a0714a..480c0081 100644 --- a/src/controller/controller_statistics.cpp +++ b/src/controller/controller_statistics.cpp @@ -1474,7 +1474,7 @@ void Controller::handlePrometheus(HTTP::Parser &H, Socket::Connection &conn, int if (H.GetVar("jsonp") != ""){jsonp = H.GetVar("jsonp");} break; } - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.StartResponse("200", "OK", H, conn, true); // Collect core server stats diff --git a/src/input/input.cpp b/src/input/input.cpp index 189824e7..faf8a3b2 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -1110,8 +1110,7 @@ namespace Mist{ "" "5.0.0.2smooth" - "MistServer " RELEASE "_" PACKAGE_VERSION ""; + "DRMType>" APPIDENT ""; soap << config->getString("buydrm"); soap << ""; soap << formatGUID(contentID); diff --git a/src/input/input_dtsc.cpp b/src/input/input_dtsc.cpp index 2f35d74a..864ed909 100644 --- a/src/input/input_dtsc.cpp +++ b/src/input/input_dtsc.cpp @@ -16,8 +16,8 @@ namespace Mist{ inputDTSC::inputDTSC(Util::Config *cfg) : Input(cfg){ capa["name"] = "DTSC"; capa["desc"] = "Load DTSC files as Video on Demand sources, or dtsc:// URLs from other " - "MistServer instances for live sources. This is the optimal method to pull live " - "sources from other MistServer (or compatible) instances."; + "instances for live sources. This is the optimal method to pull live " + "sources from MistServer compatible instances."; capa["priority"] = 9; capa["source_match"].append("/*.dtsc"); capa["source_match"].append("dtsc://*"); @@ -193,7 +193,7 @@ namespace Mist{ if (!srcConn.connected()){return false;} JSON::Value prep; prep["cmd"] = "play"; - prep["version"] = "MistServer " PACKAGE_VERSION; + prep["version"] = APPIDENT; prep["stream"] = streamName; srcConn.SendNow("DTCM"); char sSize[4] ={0, 0, 0, 0}; diff --git a/src/input/input_rtsp.cpp b/src/input/input_rtsp.cpp index 0412d52e..2d69b487 100644 --- a/src/input/input_rtsp.cpp +++ b/src/input/input_rtsp.cpp @@ -100,7 +100,7 @@ namespace Mist{ if ((username.size() || password.size()) && authRequest.size()){ sndH.auth(username, password, authRequest); } - sndH.SetHeader("User-Agent", "MistServer " PACKAGE_VERSION); + sndH.SetHeader("User-Agent", APPIDENT); sndH.SetHeader("CSeq", JSON::Value(cSeq).asString()); if (session.size()){sndH.SetHeader("Session", session);} if (extraHeaders && extraHeaders->size()){ diff --git a/src/output/output_dtsc.cpp b/src/output/output_dtsc.cpp index 0eaff95c..50ff28e3 100644 --- a/src/output/output_dtsc.cpp +++ b/src/output/output_dtsc.cpp @@ -13,7 +13,7 @@ namespace Mist{ setBlocking(true); JSON::Value prep; prep["cmd"] = "hi"; - prep["version"] = "MistServer " PACKAGE_VERSION; + prep["version"] = APPIDENT; prep["pack_method"] = 2; salt = Secure::md5("mehstuff" + JSON::Value((uint64_t)time(0)).asString()); prep["salt"] = salt; @@ -55,8 +55,7 @@ namespace Mist{ Output::init(cfg); capa["name"] = "DTSC"; capa["friendly"] = "DTSC"; - capa["desc"] = "Real time streaming over DTSC (MistServer proprietary protocol, for efficient " - "inter-server streaming)"; + capa["desc"] = "Real time streaming over DTSC (proprietary protocol for efficient inter-server streaming)"; capa["deps"] = ""; capa["codecs"][0u][0u].append("+*"); cfg->addConnectorOptions(4200, capa); diff --git a/src/output/output_ebml.cpp b/src/output/output_ebml.cpp index b88b68d3..bfa5ca92 100644 --- a/src/output/output_ebml.cpp +++ b/src/output/output_ebml.cpp @@ -335,7 +335,7 @@ namespace Mist{ EBML::sendElemSeek(myConn, EBML::EID_CUES, seekheadSize + infoSize + tracksSize); } // Info - EBML::sendElemInfo(myConn, "MistServer " PACKAGE_VERSION, duration); + EBML::sendElemInfo(myConn, APPIDENT, duration); // Tracks size_t trackSizes = 0; for (std::map::iterator it = userSelect.begin(); it != userSelect.end(); it++){ @@ -497,7 +497,7 @@ namespace Mist{ // Segment contains SeekHead, Info, Tracks, Cues (in that order) // Howeveer, SeekHead is dependent on Info/Tracks sizes, so we calculate those first. // Calculating Info size - infoSize = EBML::sizeElemInfo("MistServer " PACKAGE_VERSION, duration); + infoSize = EBML::sizeElemInfo(APPIDENT, duration); // Calculating Tracks size tracksSize = 0; for (std::map::iterator it = userSelect.begin(); it != userSelect.end(); it++){ diff --git a/src/output/output_hls.cpp b/src/output/output_hls.cpp index 466f074b..e16e6d8b 100644 --- a/src/output/output_hls.cpp +++ b/src/output/output_hls.cpp @@ -226,7 +226,7 @@ namespace Mist{ if (H.url == "/crossdomain.xml"){ H.Clean(); H.SetHeader("Content-Type", "text/xml"); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); if (method == "OPTIONS" || method == "HEAD"){ H.SendResponse("200", "OK", myConn); @@ -415,7 +415,7 @@ namespace Mist{ return; } H.Clean(); // make sure no parts of old requests are left in any buffers - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); H.SetHeader("Content-Type", "application/vnd.apple.mpegurl"); H.SetHeader("Cache-Control", "no-cache"); diff --git a/src/output/output_http.cpp b/src/output/output_http.cpp index c4026bd7..48bcab41 100644 --- a/src/output/output_http.cpp +++ b/src/output/output_http.cpp @@ -58,7 +58,7 @@ namespace Mist{ INFO_MSG("Failing '%s': %s", H.url.c_str(), msg.c_str()); if (!webSock && !isRecording()){ H.Clean(); // make sure no parts of old requests are left in any buffers - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); H.SetBody("Could not retrieve stream: " + msg); H.SendResponse("404", "Error opening stream", myConn); @@ -208,7 +208,7 @@ namespace Mist{ H.GetVar("stream").c_str()); if (!handler.size()){ H.Clean(); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); H.SetBody("Unsupported Media " "Type

Unsupported Media Type

The server isn't quite " diff --git a/src/output/output_http_internal.cpp b/src/output/output_http_internal.cpp index df178534..34361b64 100644 --- a/src/output/output_http_internal.cpp +++ b/src/output/output_http_internal.cpp @@ -375,7 +375,7 @@ namespace Mist{ H.Clean(); H.SetHeader("Content-Type", "text/html"); H.SetHeader("X-UA-Compatible", "IE=edge"); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); if (method == "OPTIONS" || method == "HEAD"){ H.SendResponse("200", "OK", myConn); @@ -599,7 +599,7 @@ namespace Mist{ if (it->asStringRef().substr(0, cbToken.size() + 1) == cbToken + ":"){ H.Clean(); H.SetHeader("Content-Type", "text/plain"); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); H.SetBody(it->asStringRef().substr(cbToken.size() + 1)); H.SendResponse("200", "OK", myConn); @@ -609,7 +609,7 @@ namespace Mist{ } H.Clean(); H.SetHeader("Content-Type", "text/plain"); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); H.SetBody("No matching validation found for token '" + cbToken + "'"); H.SendResponse("404", "Not found", myConn); @@ -620,7 +620,7 @@ namespace Mist{ if (H.url == "/crossdomain.xml"){ H.Clean(); H.SetHeader("Content-Type", "text/xml"); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); if (method == "OPTIONS" || method == "HEAD"){ H.SendResponse("200", "OK", myConn); @@ -639,7 +639,7 @@ namespace Mist{ if (H.url == "/clientaccesspolicy.xml"){ H.Clean(); H.SetHeader("Content-Type", "text/xml"); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); if (method == "OPTIONS" || method == "HEAD"){ H.SendResponse("200", "OK", myConn); @@ -660,7 +660,7 @@ namespace Mist{ if (H.url == "/flashplayer.swf"){ H.Clean(); H.SetHeader("Content-Type", "application/x-shockwave-flash"); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.SetBody((const char *)FlashMediaPlayback_101_swf, FlashMediaPlayback_101_swf_len); H.SendResponse("200", "OK", myConn); return; @@ -668,7 +668,7 @@ namespace Mist{ if (H.url == "/oldflashplayer.swf"){ H.Clean(); H.SetHeader("Content-Type", "application/x-shockwave-flash"); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.SetBody((const char *)FlashMediaPlayback_swf, FlashMediaPlayback_swf_len); H.SendResponse("200", "OK", myConn); return; @@ -723,7 +723,7 @@ namespace Mist{ H.Clean(); H.SetHeader("Content-Type", "application/smil"); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); if (method == "OPTIONS" || method == "HEAD"){ H.SendResponse("200", "OK", myConn); @@ -747,7 +747,7 @@ namespace Mist{ std::string rURL = H.url; if (method != "OPTIONS" && method != "HEAD"){initialize();} H.Clean(); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); if (rURL.substr(0, 6) != "/json_"){ H.SetHeader("Content-Type", "application/javascript"); @@ -787,7 +787,7 @@ namespace Mist{ std::string response; std::string rURL = H.url; H.Clean(); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); H.SetHeader("Content-Type", "application/javascript; charset=utf-8"); if (method == "OPTIONS" || method == "HEAD"){ @@ -860,7 +860,7 @@ namespace Mist{ std::string response; std::string url = H.url; H.Clean(); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); H.SetHeader("Content-Type", "text/css"); if (method == "OPTIONS" || method == "HEAD"){ @@ -893,7 +893,7 @@ namespace Mist{ if (H.url == "/videojs.js"){ std::string response; H.Clean(); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); H.SetHeader("Content-Type", "application/javascript"); if (method == "OPTIONS" || method == "HEAD"){ @@ -913,7 +913,7 @@ namespace Mist{ if (H.url == "/dashjs.js"){ std::string response; H.Clean(); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); H.SetHeader("Content-Type", "application/javascript"); if (method == "OPTIONS" || method == "HEAD"){ @@ -935,7 +935,7 @@ namespace Mist{ if (H.url == "/webrtc.js"){ std::string response; H.Clean(); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); H.SetHeader("Content-Type", "application/javascript"); if (method == "OPTIONS" || method == "HEAD"){ @@ -979,7 +979,7 @@ namespace Mist{ /*LTS-START*/ if (H.GetVar("s").size() && H.GetVar("s") == SUPER_SECRET){ H.Clean(); - H.SetHeader("Server", "mistserver/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); if (method == "OPTIONS" || method == "HEAD"){ H.SendResponse("200", "OK", myConn); @@ -995,7 +995,7 @@ namespace Mist{ H.Clean(); #include "../icon.h" H.SetHeader("Content-Type", "image/x-icon"); - H.SetHeader("Server", "MistServer/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.SetHeader("Content-Length", icon_len); H.setCORSHeaders(); if (method == "OPTIONS" || method == "HEAD"){ diff --git a/src/output/output_http_minimalserver.cpp b/src/output/output_http_minimalserver.cpp index dd44c33e..5de040fd 100644 --- a/src/output/output_http_minimalserver.cpp +++ b/src/output/output_http_minimalserver.cpp @@ -48,7 +48,7 @@ namespace Mist{ WARN_MSG("URL %s is not inside webroot %s: %s", H.url.c_str(), resolved_path.c_str(), path.c_str()); } H.Clean(); - H.SetHeader("Server", "mistserver/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.setCORSHeaders(); if (method == "OPTIONS" || method == "HEAD"){ H.SendResponse("200", "OK", myConn); @@ -65,7 +65,7 @@ namespace Mist{ unsigned long long filesize = inFile.tellg(); inFile.seekg(0, std::ios_base::beg); H.Clean(); - H.SetHeader("Server", "mistserver/" PACKAGE_VERSION); + H.SetHeader("Server", APPIDENT); H.SetHeader("Content-Length", filesize); H.setCORSHeaders(); if (method == "OPTIONS" || method == "HEAD"){ diff --git a/src/output/output_https.cpp b/src/output/output_https.cpp index f06b5454..59fa0bfd 100644 --- a/src/output/output_https.cpp +++ b/src/output/output_https.cpp @@ -223,7 +223,7 @@ namespace Mist{ // seed the rng if ((ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, - (const unsigned char *)"MistServer", 10)) != 0){ + (const unsigned char *)APPNAME, strlen(APPNAME))) != 0){ FAIL_MSG("Could not seed the random number generator!"); } diff --git a/src/output/output_rtmp.cpp b/src/output/output_rtmp.cpp index 24f0983a..b38cecf9 100644 --- a/src/output/output_rtmp.cpp +++ b/src/output/output_rtmp.cpp @@ -138,7 +138,7 @@ namespace Mist{ amfReply.getContentP(2)->addContent(AMF::Object("app", app + args)); amfReply.getContentP(2)->addContent(AMF::Object("type", "nonprivate")); amfReply.getContentP(2)->addContent( - AMF::Object("flashVer", "FMLE/3.0 (compatible; MistServer/" PACKAGE_VERSION "/" RELEASE ")")); + AMF::Object("flashVer", "FMLE/3.0 (compatible; " APPNAME ")")); amfReply.getContentP(2)->addContent(AMF::Object("tcUrl", pushHost + app + args)); sendCommand(amfReply, 20, 0); diff --git a/src/output/output_rtsp.cpp b/src/output/output_rtsp.cpp index 83697557..2d1bd91d 100644 --- a/src/output/output_rtsp.cpp +++ b/src/output/output_rtsp.cpp @@ -189,7 +189,7 @@ namespace Mist{ << reqUrl << "\r\n" "t=0 0\r\n" - "a=tool:MistServer\r\n" + "a=tool:" APPIDENT "\r\n" "a=type:broadcast\r\n" "a=control:*\r\n" << "a=range:npt=" << ((double)startTime()) / 1000.0 << "-" @@ -327,7 +327,7 @@ namespace Mist{ << reqUrl << "\r\n" "t=0 0\r\n" - "a=tool:MistServer\r\n" + "a=tool:" APPIDENT "\r\n" "a=type:broadcast\r\n" "a=control:*\r\n" << "a=range:npt=" << ((double)startTime()) / 1000.0 << "-"