//1// Copyright (c) 2006-2025 Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56/**7* beef.net.connection - wraps Mozilla's Network Information API8* https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation9* https://developer.mozilla.org/en-US/docs/Web/API/Navigator/connection10* @namespace beef.net.connection11*/12beef.net.connection = {1314/**15* Returns the connection type. https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/type16* @example beef.net.connection.type()17* @return {String} connection type or 'unknown'.18*/19type: function () {20try {21var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;22var type = connection.type;23if (/^[a-z]+$/.test(type)) return type; else return 'unknown';24} catch(e) {25beef.debug("Error retrieving connection type: " + e.message);26return 'unknown';27}28},2930/**31* Returns the maximum downlink speed of the connection. https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation/downlinkMax32* @example beef.net.connection.downlinkMax()33* @return {String} downlink max or 'unknown'.34*/35downlinkMax: function () {36try {37var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;38var max = connection.downlinkMax;39if (max) return max; else return 'unknown';40} catch(e) {41beef.debug("Error retrieving connection downlink max: " + e.message);42return 'unknown';43}44}4546};4748beef.regCmp('beef.net.connection');49505152