diff options
author | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2019-11-25 07:50:30 +0000 |
---|---|---|
committer | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2019-11-25 07:50:30 +0000 |
commit | 907ce8c044159ca8da6ccce3ec5362ac61e7c142 (patch) | |
tree | 4e4b83a3aa041a1826e4ac876b001195fce3f7c2 /Postman/Postman-Connectivity-Test/postman_port_test.js | |
parent | a41b9219a66f4018dc581f561fbe3fedd24e73f2 (diff) | |
download | Post-SMTP-907ce8c044159ca8da6ccce3ec5362ac61e7c142.zip |
deleted by mistake
Diffstat (limited to 'Postman/Postman-Connectivity-Test/postman_port_test.js')
-rw-r--r-- | Postman/Postman-Connectivity-Test/postman_port_test.js | 336 |
1 files changed, 0 insertions, 336 deletions
diff --git a/Postman/Postman-Connectivity-Test/postman_port_test.js b/Postman/Postman-Connectivity-Test/postman_port_test.js deleted file mode 100644 index 8667c06..0000000 --- a/Postman/Postman-Connectivity-Test/postman_port_test.js +++ /dev/null @@ -1,336 +0,0 @@ -postman_begin_test_button_id = 'input#begin-port-test'; - -jQuery(document).ready(function() { - var elHostname = jQuery(postman_begin_test_button_id); - jQuery(postman_hostname_element_name).focus(); - elHostname.click(function() { - valid = jQuery('#port_test_form_id').valid(); - if (!valid) { - return false; - } - - // initialize the view for a new test - elHostname.attr('disabled', 'disabled'); - hide('#conclusion'); - hide('#blocked-port-help'); - jQuery('ol.conclusion').html(''); - showLoaderIcon(); - - var $elTestingTable = jQuery('#connectivity_test_table'); - $elTestingTable.show(); - show('.portquiz'); - - var hostname = jQuery(postman_hostname_element_name).val(); - var data = { - 'action' : 'postman_get_hosts_to_test', - 'hostname' : hostname, - 'security' : jQuery('#security').val(), - }; - - totalPortsTested = 0; - portsToBeTested = 0; - - jQuery.post(ajaxurl, data, function(response) { - if (postmanValidateAjaxResponseWithPopup(response)) { - handleHostsToCheckResponse(response.data); - } - }).fail(function(response) { - ajaxFailed(response); - }); - - // - return false; - }); -}); - -/** - * Handles the response from the server of the list of sockets to check. - * - * @param hostname - * @param response - */ -function handleHostsToCheckResponse(response) { - for ( var x in response.hosts) { - var id = response.hosts[x].id; - var transportSlug = response.hosts[x].transport_id; - var hostname = response.hosts[x].host; - var port = response.hosts[x].port - var cell = 'tr#' + id + " td.socket"; - var testEl = jQuery(cell); - testEl.html('<span>' + hostname + ':' + port + '</span>'); - portQuizTest(response.hosts[x], hostname, port); - } -} - -function portQuizTest(socket, hostname, port) { - resetView(socket.id); - portsToBeTested += 1; - var cell = 'tr#' + socket.id + " td.firewall"; - var testEl = jQuery(cell); - testEl.html('<span style="color:blue">' + postman_port_test.in_progress - + '</span>'); - var data = { - 'action' : 'postman_port_quiz_test', - 'hostname' : hostname, - 'port' : port, - 'security' : jQuery('#security').val(), - }; - jQuery.post( - ajaxurl, - data, - function(response) { - if (postmanValidateAjaxResponseWithPopup(response)) { - if (response.success) { - testEl.html('<span style="color:green">' - + postman_port_test.open + '</span>'); - // start the next test - } else { - testEl.html('<span style="color:red">' - + postman_port_test.closed + '</span>'); - } - firstServiceTest(socket, hostname, port, response.success); - } - }).fail( - function(response) { - totalPortsTested += 1; - testEl.html('<span style="color:red">' - + postman_email_test.ajax_error + "</span>"); - enableButtonCheck(); - }); -} -function firstServiceTest(socket, hostname, port, open) { - var cell = 'tr#' + socket.id + " td.service"; - var testEl = jQuery(cell); - testEl.html('<span style="color:blue">' + postman_port_test.in_progress - + '</span>'); - var data = { - 'action' : 'postman_test_port', - 'hostname' : hostname, - 'port' : port, - 'security' : jQuery('#security').val(), - }; - jQuery - .post( - ajaxurl, - data, - function(response) { - if (postmanValidateAjaxResponseWithPopup(response)) { - if (response.success) { - totalPortsTested += 1; - if (port == 443) { - // API test - testEl - .html('<span style="color:green">🔒 ' - + response.data.protocol - + '</span>'); - var cell = 'tr#' + socket.id - + " td.reported_id"; - var p443El = jQuery(cell); - if (response.data.reported_hostname_domain_only) { - p443El - .html('<span>' - + response.data.reported_hostname_domain_only - + '</span>'); - } - addConclusion(sprintf( - postman_port_test.https_success, - response.data.port, - socket.transport_name), true, - response.data.secure); - } else { - // SMTP test - testEl.html('<span style="color:green">' - + response.data.protocol - + '</span>'); - inspectResponse(socket.id, response.data, - port); - var message = sprintf(postman_port_test.success, - port, hostname); - if (response.data.mitm) { - message += ' <span style="background-color:yellow">' - + sprintf( - postman_port_test.mitm, - response.data.reported_hostname_domain_only, - response.data.hostname_domain_only) - + '</span>'; - } - addConclusion(message, true, - response.data.secure); - } - } else { - if (port == 443) { - // API test - testEl.html('<span style="color:red">' - + postman_port_test.no + '</span>'); - totalPortsTested += 1; - var p443El = jQuery(cell); - addConclusion(sprintf(postman_port_test.try_dif_smtp, - port, hostname), false, - response.data.secure); - } else { - if (response.data.try_smtps) { - // start the SMTPS test - portTest3(socket, hostname, port, open); - } else { - testEl.html('<span style="color:red">' - + postman_port_test.no + '</span>'); - totalPortsTested += 1; - addConclusion(sprintf( - postman_port_test.blocked, port), - false, response.data.secure); - show('#blocked-port-help'); - } - } - } - enableButtonCheck(); - } - }).fail( - function(response) { - totalPortsTested += 1; - testEl.html('<span style="color:red">' - + postman_email_test.ajax_error + "</span>"); - enableButtonCheck(); - }); -} -function portTest3(socket, hostname, port, open) { - var cell = 'tr#' + socket.id + " td.service"; - var testEl = jQuery(cell); - testEl.html('<span style="color:blue">' + postman_port_test.in_progress - + '</span>'); - var data = { - 'action' : 'postman_test_smtps', - 'hostname' : hostname, - 'port' : port, - 'security' : jQuery('#security').val(), - }; - jQuery - .post( - ajaxurl, - data, - function(response) { - if (postmanValidateAjaxResponseWithPopup(response)) { - if (response.success) { - if (response.data.protocol == 'SMTPS') { - testEl - .html('<span style="color:green">🔒 ' - + response.data.protocol - + '</span>'); - } else { - - testEl.html('<span style="color:green">' - + response.data.protocol - + '</span>'); - } - inspectResponse(socket.id, response.data, port); - var message = sprintf(postman_port_test.success, - port, hostname); - if (response.data.mitm) { - message += ' <span style="background-color:yellow">' - + sprintf( - postman_port_test.mitm, - response.data.reported_hostname_domain_only, - response.data.hostname_domain_only - + '</span>'); - } - addConclusion(message, true, - response.data.secure); - } else { - testEl.html('<span style="color:red">' - + postman_port_test.no + '</span>'); - show('#blocked-port-help'); - if (open) { - addConclusion(sprintf(postman_port_test.try_dif_smtp, - port, hostname), false, - response.data.secure); - } else { - addConclusion(sprintf(postman_port_test.blocked, - port), false, response.data.secure); - } - } - totalPortsTested += 1; - enableButtonCheck(); - } - }).fail( - function(response) { - totalPortsTested += 1; - testEl.html('<span style="color:red">' - + postman_email_test.ajax_error + "</span>"); - enableButtonCheck(); - }); -} -function enableButtonCheck() { - if (totalPortsTested >= portsToBeTested) { - enable(postman_begin_test_button_id); - hideLoaderIcon(); - jQuery(postman_hostname_element_name).focus(); - } -} -function inspectResponse(id, response, port) { - var cell = 'tr#' + id + " td.reported_id"; - var testEl = jQuery(cell); - if (response.reported_hostname_domain_only) { - testEl.html('<span>' + response.reported_hostname_domain_only - + '</span>'); - } - var cell = 'tr#' + id + " td.service"; - var testEl = jQuery(cell); - if (response.protocol == 'SMTPS') { - testEl.html('<span style="color:green">🔒 SMTPS</span>'); - } else if (response.start_tls) { - testEl.html('<span style="color:green">🔒 SMTP-STARTTLS</span>'); - } else { - testEl.html('<span style="color:green">SMTP</span>'); - } - var cell = 'tr#' + id + " td.auth_none"; - var testEl = jQuery(cell); - if (response.auth_none) { - testEl.html('<span style="color:green">' + postman_port_test.yes + '</span>'); - } else { - testEl.html('<span>' + postman_port_test.no + '</span>'); - } - var cell = 'tr#' + id + " td.auth_plain"; - var testEl = jQuery(cell); - if (response.auth_plain) { - testEl.html('<span style="color:green">' + postman_port_test.yes + '</span>'); - } else { - testEl.html('<span>' + postman_port_test.no + '</span>'); - } - var cell = 'tr#' + id + " td.auth_login"; - var testEl = jQuery(cell); - if (response.auth_login) { - testEl.html('<span style="color:green">' + postman_port_test.yes + '</span>'); - } else { - testEl.html('<span>' + postman_port_test.no + '</span>'); - } - var cell = 'tr#' + id + " td.auth_crammd5"; - var testEl = jQuery(cell); - if (response.auth_crammd5) { - testEl.html('<span style="color:green">' + postman_port_test.yes + '</span>'); - } else { - testEl.html('<span>' + postman_port_test.no + '</span>'); - } - var cell = 'tr#' + id + " td.auth_xoauth2"; - var testEl = jQuery(cell); - if (response.auth_xoauth) { - testEl.html('<span style="color:green">' + postman_port_test.yes + '</span>'); - } else { - testEl.html('<span>' + postman_port_test.no + '</span>'); - } -} -function resetView(id) { - var testEl = jQuery('tr#' + id + ' td.resettable'); - testEl.html('-'); -} -function addConclusion(message, success, isSecure) { - show('#conclusion'); - var secureIcon = ''; - if (isSecure) { - secureIcon = '🔒 '; - } - if (success) { - message = '✅ ' + secureIcon + message; - } else { - message = '❌ ' + secureIcon + message; - } - jQuery('ol.conclusion').append('<li>' + message + '</li>'); -}
\ No newline at end of file |