From f3b76ddf96b6efe09b15a3784c45753b97d0c0ec Mon Sep 17 00:00:00 2001 From: Matteo Nastasi Date: Wed, 11 Jan 2017 18:16:53 +0000 Subject: [PATCH] add secure socket as default transport and set the default port based on 'X-Forward-Schema' header value --- web/Obj/transports.phh | 6 +++--- web/briskin5/Obj/briskin5.phh | 2 +- web/briskin5/index.php | 8 ++++++-- web/commons.js | 1 - web/index.php | 5 ++++- web/xynt-streaming.js | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/web/Obj/transports.phh b/web/Obj/transports.phh index 69fe089..3422c23 100644 --- a/web/Obj/transports.phh +++ b/web/Obj/transports.phh @@ -609,8 +609,8 @@ class Transport { static function create($transp) { - if ($transp == 'websocket') { - return new Transport_websocket(); + if ($transp == 'websocket' || $transp == 'websocketsec') { + return new Transport_websocket($transp == 'websocketsec'); } else if ($transp == 'xhr') { return new Transport_xhr(); @@ -632,4 +632,4 @@ class Transport { } } } -?> \ No newline at end of file +?> diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index a058ad0..0b61781 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -1479,7 +1479,7 @@ class Bin5 { case "": case "index.php": ob_start(); - bin5_index_main($transp_type, $header_out, $addr, $get, $post, $cookie); + bin5_index_main($transp_type, $header, $header_out, $addr, $get, $post, $cookie); $content = ob_get_contents(); ob_end_clean(); diff --git a/web/briskin5/index.php b/web/briskin5/index.php index 80bc798..80f7366 100644 --- a/web/briskin5/index.php +++ b/web/briskin5/index.php @@ -46,9 +46,13 @@ $mlang_bin5_index = array( 'aucwin' => array( 'it' => 'Hai vinto l\'asta.
Sc ); -function bin5_index_main($transp_type, &$header_out, $addr, $get, $post, $cookie) +function bin5_index_main($transp_type, $header, &$header_out, $addr, $get, $post, $cookie) { GLOBAL $G_lang, $mlang_bin5_index; + + $transp_port = ((array_key_exists("X-Forwarded-Proto", $header) && + $header["X-Forwarded-Proto"] == "https") ? 443 : 80); + if (($table_idx = gpcs_var('table_idx', $get, $post, $cookie)) === FALSE) unset ($table_idx); if (($laststate = gpcs_var('laststate', $get, $post, $cookie)) === FALSE) @@ -110,7 +114,7 @@ window.onload = function() { preferences_update(); sess = ""; - xstm = new xynt_streaming(window, "", 80, 2, null /* console */, gst, 'table_php', 'sess', sess, $('sandbox'), 'index_rd.php', function(com){eval(com);}); + xstm = new xynt_streaming(window, , 2, null /* console */, gst, 'table_php', 'sess', sess, $('sandbox'), 'index_rd.php', function(com){eval(com);}); xstm.hbit_set(heartbit); window.onbeforeunload = onbeforeunload_cb; diff --git a/web/commons.js b/web/commons.js index 8f3253c..d1d2318 100644 --- a/web/commons.js +++ b/web/commons.js @@ -1393,7 +1393,6 @@ function url_complete(parent, url) } // alert("host: ["+host+"] path: ["+path+"]"); - console.log('URL: ' + url); if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/' || url.substring(0,4) == 'ws:/' || url.substring(0,5) == 'wss:/') { return (url); } diff --git a/web/index.php b/web/index.php index 21adca2..510a184 100644 --- a/web/index.php +++ b/web/index.php @@ -344,6 +344,9 @@ function index_main(&$brisk, $transp_type, $header, &$header_out, $remote_addr_f GLOBAL $G_lang, $G_lng, $mlang_room; GLOBAL $BRISK_SHOWHTML, $BRISK_DEBUG, $_SERVER, $_COOKIE; + $transp_port = ((array_key_exists("X-Forwarded-Proto", $header) && + $header["X-Forwarded-Proto"] == "https") ? 443 : 80); + if (($sess = gpcs_var('sess', $get, $post, $cookie)) === FALSE) $sess = ""; if (($name = gpcs_var('name', $get, $post, $cookie)) === FALSE) @@ -1234,7 +1237,7 @@ cookie_law(null); sidebanners_init($G_sidebanner_idx); ?> sess = ""; -xstm = new xynt_streaming(window, "", 80, 2, null /* console */, gst, 'index_php', 'sess', sess, $('sandbox'), 'index_rd.php', function(com){eval(com);}); +xstm = new xynt_streaming(window, , 2, null /* console */, gst, 'index_php', 'sess', sess, $('sandbox'), 'index_rd.php', function(com){eval(com);}); xstm.hbit_set(heartbit); tra = new train($('room_tit')); window.onunload = onunload_cb; diff --git a/web/xynt-streaming.js b/web/xynt-streaming.js index 3db25a1..47059a4 100644 --- a/web/xynt-streaming.js +++ b/web/xynt-streaming.js @@ -634,7 +634,7 @@ xynt_streaming.prototype = { // DEFAULT TRANSPORT PROTOCOL HERE websocketsec, websocket if (this.transp_fback > 0) { transp_type = "websocketsec"; - transp_port = (this.transp_fback == 2 ? 80 : 8080); + transp_port = (this.transp_fback == 2 ? 443 : 8080); } else { transp_type = this.transp_type; -- 2.17.1