Ping / circuit latency, break out commands, add typing function for IM, add thinkingTime and charactersPerSecond parameters to typing functions

This commit is contained in:
Casper Warden
2017-12-13 19:55:08 +00:00
parent af71aa597e
commit 4e8feb181f
96 changed files with 2151 additions and 935 deletions

View File

@@ -5,19 +5,29 @@ class IPAddress {
constructor(buf, pos) {
this.ip = null;
this.toString = () => {
return this.ip.toString();
};
if (buf !== undefined && buf instanceof Buffer) {
if (pos !== undefined) {
const bytes = buf.slice(pos, 4);
this.ip = ipaddr.fromByteArray(bytes);
try {
return this.ip.toString();
}
else {
if (ipaddr.isValid(buf)) {
this.ip = ipaddr.parse(buf);
catch (ignore) {
return '';
}
};
try {
if (buf !== undefined && buf instanceof Buffer) {
if (pos !== undefined) {
const bytes = buf.slice(pos, 4);
this.ip = ipaddr.fromByteArray(bytes);
}
else {
if (ipaddr.isValid(buf)) {
this.ip = ipaddr.parse(buf);
}
}
}
}
catch (ignore) {
this.ip = ipaddr.parse('0.0.0.0');
}
}
static zero() {
return new IPAddress('0.0.0.0');