Ping / circuit latency, break out commands, add typing function for IM, add thinkingTime and charactersPerSecond parameters to typing functions
This commit is contained in:
28
dist/classes/IPAddress.js
vendored
28
dist/classes/IPAddress.js
vendored
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user