2018-12-26 21:32:39 +00:00
|
|
|
|
const IPV4_EX = new RegExp("")
|
|
|
|
|
const regex = RegExp("^((25[0–5]|2[0–4][0–9]|[01]?[0–9][0–9]?).(25[0–5]|2[0–4][0–9]|[01]?[0–9][0–9]?).(25[0–5]|2[0–4][0–9]|[01]?[0–9][0–9]?).(25[0–5]|2[0–4][0–9]|[01]?[0–9][0–9]?))|((([0–9A-Fa-f]{1,4}:){7}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){6}:[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){5}:([0–9A-Fa-f]{1,4}:)?[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){4}:([0–9A-Fa-f]{1,4}:){0,2}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){3}:([0–9A-Fa-f]{1,4}:){0,3}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){2}:([0–9A-Fa-f]{1,4}:){0,4}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){6}((b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b).){3}(b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b))|(([0–9A-Fa-f]{1,4}:){0,5}:((b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b).){3}(b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b))|(::([0–9A-Fa-f]{1,4}:){0,5}((b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b).){3}(b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b))|([0–9A-Fa-f]{1,4}::([0–9A-Fa-f]{1,4}:){0,5}[0–9A-Fa-f]{1,4})|(::([0–9A-Fa-f]{1,4}:){0,6}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){1,7}:))$")
|
2018-12-26 12:29:13 +00:00
|
|
|
|
|
2018-12-26 21:32:39 +00:00
|
|
|
|
var addresses = []
|
|
|
|
|
var date = []
|
|
|
|
|
var ipv4_v6 = []
|
|
|
|
|
|
|
|
|
|
function Ip4OrIp6(ipAddress){
|
|
|
|
|
console.log(ipAddress)
|
|
|
|
|
console.log(regex.test(ipAddress));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Refactor getStudents and getScores to return Promise for their response bodies
|
|
|
|
|
function getData(){
|
|
|
|
|
return fetch(`address.json`, {
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
'Accept': 'application/json'
|
|
|
|
|
}
|
|
|
|
|
}).then((response) => response.json())
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
getData().then((data)=>{
|
2018-12-26 12:29:13 +00:00
|
|
|
|
data.forEach(element => {
|
|
|
|
|
date.push(element.date)
|
2018-12-26 21:32:39 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log(date);
|
|
|
|
|
|
|
|
|
|
data.forEach(element => {
|
|
|
|
|
Ip4OrIp6(element.ip)
|
2018-12-26 12:29:13 +00:00
|
|
|
|
})
|
2018-12-26 21:32:39 +00:00
|
|
|
|
console.log(ipv4_v6)
|
|
|
|
|
var ctx = document.getElementById("myChart").getContext('2d');
|
|
|
|
|
var chart = new Chart(ctx, {
|
|
|
|
|
type: 'line',
|
|
|
|
|
data: {
|
|
|
|
|
labels:date ,
|
|
|
|
|
datasets: [{
|
|
|
|
|
label: "Statistics for IPV4 and IPV6",
|
|
|
|
|
data: ipv4_v6,
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
options: {
|
|
|
|
|
legend: { display: false },
|
|
|
|
|
title: {
|
|
|
|
|
display: true,
|
|
|
|
|
text: 'Statistics for IPV4 and IPV6'
|
2018-12-26 09:21:29 +00:00
|
|
|
|
}
|
2018-12-26 12:29:13 +00:00
|
|
|
|
}
|
2018-12-26 21:32:39 +00:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
//Fetch call to get data from addresses json file
|
|
|
|
|
// async function retrieveIpAdresses(){
|
|
|
|
|
// await fetch('./address.json').then(response => {
|
|
|
|
|
// response.json();
|
|
|
|
|
// }).then(data => {
|
|
|
|
|
// data.forEach(element=>{
|
|
|
|
|
// console.log(element)
|
|
|
|
|
// date.push(element.date)
|
|
|
|
|
// })
|
|
|
|
|
// }).catch(err => {
|
|
|
|
|
// err = err
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|