@sanctumterra/raknet 1.4.18 → 1.4.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,YAAY,EAWZ,QAAQ,EAIR,KAAK,KAAK,EAKV,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EACN,KAAK,aAAa,EAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAgB,KAAK,UAAU,EAAe,MAAM,YAAY,CAAC;AAKxE,qBAAa,MAAO,SAAQ,YAAY,CAAC,YAAY,CAAC;IACrD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAiC;IACnE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAO;IACjD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IACjD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAO;IAE3C,OAAO,EAAE,aAAa,CAAC;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,MAAM,CAAmB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,gBAAgB,CAAsB;IAC9C,OAAO,CAAC,cAAc,CAAS;gBAEnB,OAAO,G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C,iBAAiB;IAkCzB,OAAO,CAAC,qBAAqB;IA4B7B,OAAO,CAAC,oBAAoB;IAwCf,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAiF9B,MAAM,IAAI,IAAI;IAkCrB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,OAAO;IAgBR,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IAqFhD,YAAY,CAAC,IAAI,EAAE,MAAM;IAiEzB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,GAAE,QAA0B;IAI5D,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,QAA0B;IAI/D,IAAI,IAAI,IAAI;IAOZ,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAWxB,UAAU,IAAI,IAAI;CAWzB"}
|
package/dist/client/client.js
CHANGED
|
@@ -117,9 +117,7 @@ class Client extends shared_1.EventEmitter {
|
|
|
117
117
|
}
|
|
118
118
|
this.proxySocket = socket;
|
|
119
119
|
this.proxyRelayHost =
|
|
120
|
-
relay.host === "0.0.0.0"
|
|
121
|
-
? (this.resolvedAddress ?? proxy.host)
|
|
122
|
-
: relay.host;
|
|
120
|
+
relay.host === "0.0.0.0" ? proxy.host : relay.host;
|
|
123
121
|
this.proxyRelayPort = relay.port;
|
|
124
122
|
this.proxyReady = true;
|
|
125
123
|
state = "done";
|
|
@@ -131,9 +129,14 @@ class Client extends shared_1.EventEmitter {
|
|
|
131
129
|
reject(new Error("SOCKS5 connection closed unexpectedly"));
|
|
132
130
|
}
|
|
133
131
|
else {
|
|
132
|
+
// TCP control connection closed — per RFC 1928, the UDP association is now dead
|
|
133
|
+
this.proxyReady = false;
|
|
134
134
|
this.proxySocket = null;
|
|
135
135
|
this.proxyRelayHost = null;
|
|
136
136
|
this.proxyRelayPort = null;
|
|
137
|
+
if (!this.isDisconnected) {
|
|
138
|
+
this.handleDisconnect("SOCKS5 control connection closed");
|
|
139
|
+
}
|
|
137
140
|
}
|
|
138
141
|
});
|
|
139
142
|
socket.on("error", (err) => {
|
|
@@ -159,6 +162,16 @@ class Client extends shared_1.EventEmitter {
|
|
|
159
162
|
port: data.readUInt16BE(5 + len),
|
|
160
163
|
};
|
|
161
164
|
}
|
|
165
|
+
if (atyp === 0x04 && data.length >= 22) {
|
|
166
|
+
const parts = [];
|
|
167
|
+
for (let i = 0; i < 8; i++) {
|
|
168
|
+
parts.push(data.readUInt16BE(4 + i * 2).toString(16));
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
host: parts.join(":"),
|
|
172
|
+
port: data.readUInt16BE(20),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
162
175
|
return null;
|
|
163
176
|
}
|
|
164
177
|
createSocks5UdpHeader(host, port) {
|
|
@@ -205,6 +218,18 @@ class Client extends shared_1.EventEmitter {
|
|
|
205
218
|
dataOffset: 7 + domainLen,
|
|
206
219
|
};
|
|
207
220
|
}
|
|
221
|
+
if (atyp === 4 && data.length >= 22) {
|
|
222
|
+
// IPv6: 16 bytes address + 2 bytes port
|
|
223
|
+
const parts = [];
|
|
224
|
+
for (let i = 0; i < 8; i++) {
|
|
225
|
+
parts.push(data.readUInt16BE(4 + i * 2).toString(16));
|
|
226
|
+
}
|
|
227
|
+
return {
|
|
228
|
+
host: parts.join(":"),
|
|
229
|
+
port: data.readUInt16BE(20),
|
|
230
|
+
dataOffset: 22,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
208
233
|
return null;
|
|
209
234
|
}
|
|
210
235
|
async connect() {
|
|
@@ -222,12 +247,24 @@ class Client extends shared_1.EventEmitter {
|
|
|
222
247
|
return new Promise((resolve, reject) => {
|
|
223
248
|
let mtuIndex = 0;
|
|
224
249
|
let retryTimeout = null;
|
|
250
|
+
let settled = false;
|
|
225
251
|
// Use configured MTU or fall back to default values
|
|
226
252
|
const mtuValues = this.options.mtu && this.options.mtu > 0
|
|
227
253
|
? [this.options.mtu]
|
|
228
254
|
: Client.MTU_VALUES;
|
|
255
|
+
const cleanup = () => {
|
|
256
|
+
settled = true;
|
|
257
|
+
if (retryTimeout) {
|
|
258
|
+
clearTimeout(retryTimeout);
|
|
259
|
+
retryTimeout = null;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
229
262
|
const sendRequest = () => {
|
|
263
|
+
// Stop if we already got Reply1 or the connection settled
|
|
264
|
+
if (this.gotReply1 || settled)
|
|
265
|
+
return;
|
|
230
266
|
if (mtuIndex >= mtuValues.length) {
|
|
267
|
+
cleanup();
|
|
231
268
|
reject(new Error("Connection timed out, all MTU values exhausted"));
|
|
232
269
|
return;
|
|
233
270
|
}
|
|
@@ -242,7 +279,7 @@ class Client extends shared_1.EventEmitter {
|
|
|
242
279
|
}
|
|
243
280
|
this.send(request.serialize());
|
|
244
281
|
retryTimeout = setTimeout(() => {
|
|
245
|
-
if (!this.gotReply1) {
|
|
282
|
+
if (!this.gotReply1 && !settled) {
|
|
246
283
|
shared_2.Logger.warn(`No reply for MTU ${mtu}, trying next value...`);
|
|
247
284
|
mtuIndex++;
|
|
248
285
|
sendRequest();
|
|
@@ -250,14 +287,14 @@ class Client extends shared_1.EventEmitter {
|
|
|
250
287
|
}, Client.MTU_RETRY_INTERVAL);
|
|
251
288
|
};
|
|
252
289
|
const timeout = setTimeout(() => {
|
|
253
|
-
if (
|
|
254
|
-
|
|
255
|
-
|
|
290
|
+
if (!settled) {
|
|
291
|
+
cleanup();
|
|
292
|
+
reject(new Error("Connection timed out"));
|
|
293
|
+
}
|
|
256
294
|
}, this.options.timeout);
|
|
257
295
|
this.once("connect", () => {
|
|
258
296
|
clearTimeout(timeout);
|
|
259
|
-
|
|
260
|
-
clearTimeout(retryTimeout);
|
|
297
|
+
cleanup();
|
|
261
298
|
resolve();
|
|
262
299
|
});
|
|
263
300
|
sendRequest();
|
|
@@ -342,10 +379,16 @@ class Client extends shared_1.EventEmitter {
|
|
|
342
379
|
break;
|
|
343
380
|
}
|
|
344
381
|
case shared_1.Packets.OpenConnectionReply1: {
|
|
382
|
+
// Ignore duplicate Reply1s — only process the first one
|
|
383
|
+
if (this.gotReply1)
|
|
384
|
+
break;
|
|
345
385
|
this.gotReply1 = true;
|
|
346
386
|
const reply = new shared_1.OpenConnectionReplyOne(actualData).deserialize();
|
|
347
387
|
const request = new shared_1.OpenConnectionRequestTwo();
|
|
348
|
-
|
|
388
|
+
// When proxied, rinfo is the relay — use the actual target server address
|
|
389
|
+
request.address = this.proxyRelayHost
|
|
390
|
+
? new shared_1.Address(this.resolvedAddress || this.options.address, this.options.port, 4)
|
|
391
|
+
: shared_1.Address.fromIdentifier(rinfo);
|
|
349
392
|
request.mtu = reply.mtu;
|
|
350
393
|
request.guid = this.options.guid;
|
|
351
394
|
request.cookie = reply.cookie;
|
|
@@ -354,6 +397,9 @@ class Client extends shared_1.EventEmitter {
|
|
|
354
397
|
break;
|
|
355
398
|
}
|
|
356
399
|
case shared_1.Packets.OpenConnectionReply2: {
|
|
400
|
+
// Ignore if we're already past the handshake
|
|
401
|
+
if (this.status === shared_1.ConnectionStatus.Connected)
|
|
402
|
+
break;
|
|
357
403
|
const reply2 = new shared_1.OpenConnectionReplyTwo(actualData).deserialize();
|
|
358
404
|
// Update session MTU with the negotiated value from server
|
|
359
405
|
shared_2.Logger.info(`MTU negotiated: ${reply2.mtu} (was ${this.session.mtu})`);
|
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const client_1 = require("../client");
|
|
4
4
|
const client = new client_1.Client({
|
|
5
|
-
|
|
5
|
+
address: "donutsmp.net",
|
|
6
6
|
// address: "127.0.0.1",
|
|
7
|
-
address: "geo.hivebedrock.network",
|
|
7
|
+
// address: "geo.hivebedrock.network",
|
|
8
|
+
proxy: {
|
|
9
|
+
host: "216.185.39.231",
|
|
10
|
+
port: 45849,
|
|
11
|
+
userId: "CV8GK4TW",
|
|
12
|
+
password: "I2F91P8H",
|
|
13
|
+
},
|
|
8
14
|
});
|
|
9
15
|
client.on("unconnectedPong", (packet) => {
|
|
10
16
|
console.log(packet);
|