work around hetzner's bs hopefully
This commit is contained in:
parent
ae47f775a6
commit
20dc6cbda2
1 changed files with 8 additions and 4 deletions
|
@ -11,11 +11,15 @@ module.exports = class SourceQuery {
|
||||||
constructor(ip, port) {
|
constructor(ip, port) {
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.client = dgram.createSocket("udp4");
|
|
||||||
this.rulePackets = [];
|
this.rulePackets = [];
|
||||||
this.chunks = -1;
|
this.chunks = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_createSocket() {
|
||||||
|
this.client = dgram.createSocket("udp4");
|
||||||
|
this.client.bind(27020);
|
||||||
|
}
|
||||||
|
|
||||||
_handlerInfo(message, resolve, reject, wrapper) {
|
_handlerInfo(message, resolve, reject, wrapper) {
|
||||||
clearTimeout(this.timeout);
|
clearTimeout(this.timeout);
|
||||||
const msg = new DataView(message.buffer);
|
const msg = new DataView(message.buffer);
|
||||||
|
@ -161,7 +165,7 @@ module.exports = class SourceQuery {
|
||||||
|
|
||||||
getInfo() {
|
getInfo() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.client = dgram.createSocket("udp4");
|
this._createSocket();
|
||||||
this.client.send(Buffer.from(REQUEST_INFO), this.port, this.ip, function (err) {
|
this.client.send(Buffer.from(REQUEST_INFO), this.port, this.ip, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.client.close();
|
this.client.close();
|
||||||
|
@ -235,7 +239,7 @@ module.exports = class SourceQuery {
|
||||||
|
|
||||||
getPlayers() {
|
getPlayers() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.client = dgram.createSocket("udp4");
|
this._createSocket();
|
||||||
this.client.send(Buffer.from([...REQUEST_PLAYER, 0xff, 0xff, 0xff, 0xff]), this.port, this.ip, function (err) {
|
this.client.send(Buffer.from([...REQUEST_PLAYER, 0xff, 0xff, 0xff, 0xff]), this.port, this.ip, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.client.close();
|
this.client.close();
|
||||||
|
@ -337,7 +341,7 @@ module.exports = class SourceQuery {
|
||||||
|
|
||||||
getRules() {
|
getRules() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.client = dgram.createSocket("udp4");
|
this._createSocket();
|
||||||
this.client.send(Buffer.from([...REQUEST_RULES, 0xff, 0xff, 0xff, 0xff]), this.port, this.ip, function (err) {
|
this.client.send(Buffer.from([...REQUEST_RULES, 0xff, 0xff, 0xff, 0xff]), this.port, this.ip, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.client.close();
|
this.client.close();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue