introduce mac generator

This commit is contained in:
nativemad
2018-12-01 18:51:36 +01:00
parent d57893514d
commit e4c3b52cd5
2 changed files with 43 additions and 2 deletions
+31
View File
@@ -215,3 +215,34 @@ function createimg(){
}
});
}
function genmac(field){
freemacfound = "no";
while (freemacfound == "no"){
var text = "";
var possible = "abcdef0123456789";
for (j=0; j < 4; j++){
text += ":";
for (var i = 0; i < 2; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
var newmac = "52:54:00"+ text;
freemacfound = checkmac(newmac, field);
}
}
function checkmac(newmac,field){
$.ajax({
type: 'POST',
url: "?rand="+ makeid(),
data: "checkmac="+ newmac,
success: function(response){
if (response == "mac is free"){
$('#'+ field).val(newmac);
return newmac;
} else {
return "no";
}
}
});
}