Implement per-network protocol shaping

This commit is contained in:
emanuele-f 2016-11-27 01:48:00 +01:00
parent 9a559438a9
commit d52dc77e36
11 changed files with 649 additions and 269 deletions

View file

@ -2318,13 +2318,13 @@ print [[
end
function jsRedirect(subpage, withoutTag)
function jsUrlChange(subpage, withoutTag)
local url = '"'..ntop.getHttpPrefix()..'/lua/'..subpage..'"'
if not withoutTag then print("<script>") end
print[[
if(history.replaceState) {
// use history facility if available
// use history facility if available - NB: this does not cause a redirect/refresh!
history.replaceState(null, null, ]] print(url) print[[);
} else {
// fallback
@ -2340,11 +2340,14 @@ function jsFormCSRF(formid, withoutTag)
if not withoutTag then html = html .. "<script>" end
html = html .. [[$('#]] .. formid .. [[').submit(function(e) {
$('<input>').attr({
type: "hidden",
name: "csrf",
value: "]] .. (ntop.getRandomCSRFValue()) .. [["
}).appendTo($('#]] .. formid .. [['));
/* avoid repeating in case of aborted form submits */
if ($("#]] .. formid .. [[ input[name='csrf']").length == 0) {
$('<input>').attr({
type: "hidden",
name: "csrf",
value: "]] .. (ntop.getRandomCSRFValue()) .. [["
}).appendTo($('#]] .. formid .. [['));
}
});
]]
if not withoutTag then html = html .. "</script>" end