work around hetzner's bs hopefully

This commit is contained in:
Cynthia Foxwell 2025-10-09 18:12:06 -06:00
parent ae47f775a6
commit 20dc6cbda2
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -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();