Merge branch 'development' into LTS_development

# Conflicts:
#	src/output/output_http_internal.cpp
This commit is contained in:
Thulinma 2018-04-04 16:31:36 +02:00
commit da5e15621e

View file

@ -8,6 +8,33 @@
#include <mist/websocket.h>
namespace Mist {
/// Helper function to find the protocol entry for a given port number
std::string getProtocolForPort(uint16_t portNo){
std::string ret;
IPC::semaphore configLock(SEM_CONF, O_CREAT | O_RDWR, ACCESSPERMS, 1);
configLock.wait();
IPC::sharedPage serverCfg(SHM_CONF, DEFAULT_CONF_PAGE_SIZE);
DTSC::Scan prtcls = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("config").getMember("protocols");
unsigned int pro_cnt = prtcls.getSize();
for (unsigned int i = 0; i < pro_cnt; ++i){
DTSC::Scan capa = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("capabilities").getMember("connectors").getMember(prtcls.getIndice(i).getMember("connector").asString());
uint16_t port = prtcls.getIndice(i).getMember("port").asInt();
//get the default port if none is set
if (!port){
port = capa.getMember("optional").getMember("port").getMember("default").asInt();
}
if (port == portNo){
ret = capa.getMember("protocol").asString();
break;
}
}
configLock.post();
if (ret.find(':') != std::string::npos){
ret.erase(ret.find(':'));
}
return ret;
}
OutHTTP::OutHTTP(Socket::Connection & conn) : HTTPOutput(conn){
stayConnected = false;
if (myConn.getPureSocket() >= 0){
@ -272,6 +299,9 @@ namespace Mist {
void OutHTTP::HTMLResponse(){
std::string method = H.method;
HTTP::URL fullURL(H.GetHeader("Host"));
if (!fullURL.protocol.size()){
fullURL.protocol = getProtocolForPort(fullURL.getPort());
}
/*LTS-START*/
if (config->getString("pubaddr") != ""){
HTTP::URL altURL(config->getString("pubaddr"));
@ -456,7 +486,6 @@ namespace Mist {
return json_resp;
}
void OutHTTP::onHTTP(){
std::string method = H.method;
@ -624,6 +653,9 @@ namespace Mist {
if (H.url == "/player.js"){
HTTP::URL fullURL(H.GetHeader("Host"));
if (!fullURL.protocol.size()){
fullURL.protocol = getProtocolForPort(fullURL.getPort());
}
/*LTS-START*/
if (config->getString("pubaddr") != ""){
HTTP::URL altURL(config->getString("pubaddr"));