@baltica/raknet 0.0.1 → 0.0.2
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.
package/dist/client/client.d.ts
CHANGED
package/dist/client/client.js
CHANGED
|
@@ -111,12 +111,36 @@ class Client extends utils_1.Emitter {
|
|
|
111
111
|
this.network.frameAndSend(data, priority);
|
|
112
112
|
}
|
|
113
113
|
close() {
|
|
114
|
-
if (this.tickInterval)
|
|
114
|
+
if (this.tickInterval) {
|
|
115
115
|
clearInterval(this.tickInterval);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
this.tickInterval = undefined;
|
|
117
|
+
}
|
|
118
|
+
this.network.status = shared_1.Status.Disconnected;
|
|
119
|
+
this.network.send = () => { };
|
|
120
|
+
this.network.removeAllListeners();
|
|
121
|
+
try {
|
|
122
|
+
if (this.relay) {
|
|
123
|
+
this.relay.close();
|
|
124
|
+
this.relay = undefined;
|
|
125
|
+
}
|
|
126
|
+
else if (this.socket) {
|
|
127
|
+
this.socket.close();
|
|
128
|
+
this.socket = undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch { }
|
|
132
|
+
}
|
|
133
|
+
disconnect() {
|
|
134
|
+
const packet = new shared_1.Disconnect();
|
|
135
|
+
try {
|
|
136
|
+
this.sendReliable(packet.serialize(), shared_1.Priority.High);
|
|
137
|
+
}
|
|
138
|
+
catch { }
|
|
139
|
+
// Give UDP time to actually send the packet before closing
|
|
140
|
+
setTimeout(() => {
|
|
141
|
+
this.close();
|
|
142
|
+
this.emit("disconnect");
|
|
143
|
+
}, 150);
|
|
120
144
|
}
|
|
121
145
|
}
|
|
122
146
|
exports.Client = Client;
|
package/dist/shared/socks5.js
CHANGED
|
@@ -43,17 +43,34 @@ async function createSocks5Relay(proxy, family = "udp4") {
|
|
|
43
43
|
if (messageHandler)
|
|
44
44
|
messageHandler(payload, addr, port);
|
|
45
45
|
});
|
|
46
|
-
|
|
46
|
+
let closed = false;
|
|
47
|
+
tcp.on("close", () => {
|
|
48
|
+
if (closed)
|
|
49
|
+
return;
|
|
50
|
+
closed = true;
|
|
51
|
+
try {
|
|
52
|
+
udp.close();
|
|
53
|
+
}
|
|
54
|
+
catch { }
|
|
55
|
+
});
|
|
47
56
|
return {
|
|
48
57
|
socket: udp,
|
|
49
58
|
tcp,
|
|
50
59
|
send(data, targetAddress, targetPort) {
|
|
60
|
+
if (closed)
|
|
61
|
+
return;
|
|
51
62
|
const header = buildUdpHeader(targetAddress, targetPort);
|
|
52
63
|
const packet = Buffer.concat([header, data]);
|
|
53
64
|
udp.send(packet, relay.port, relay.address);
|
|
54
65
|
},
|
|
55
66
|
close() {
|
|
56
|
-
|
|
67
|
+
if (closed)
|
|
68
|
+
return;
|
|
69
|
+
closed = true;
|
|
70
|
+
try {
|
|
71
|
+
udp.close();
|
|
72
|
+
}
|
|
73
|
+
catch { }
|
|
57
74
|
tcp.destroy();
|
|
58
75
|
},
|
|
59
76
|
onMessage(handler) {
|