You've already forked fm-dx-webserver
mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-02-27 06:23:53 +01:00
bugfix for auth
This commit is contained in:
@@ -112,19 +112,22 @@ function connectToXdrd() {
|
|||||||
|
|
||||||
let authFlags = {
|
let authFlags = {
|
||||||
authMsg: false,
|
authMsg: false,
|
||||||
firstClient: false,
|
firstClient: true,
|
||||||
receivedPassword: false
|
receivedSalt: '',
|
||||||
|
receivedPassword: false,
|
||||||
|
messageCount: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const authDataHandler = (data) => {
|
const authDataHandler = (data) => {
|
||||||
|
authFlags.messageCount++
|
||||||
const receivedData = data.toString();
|
const receivedData = data.toString();
|
||||||
const lines = receivedData.split('\n');
|
const lines = receivedData.split('\n');
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (!authFlags.receivedPassword) {
|
if (authFlags.receivedPassword === false) {
|
||||||
authFlags.receivedSalt = line.trim();
|
authFlags.receivedSalt = line.trim();
|
||||||
authenticateWithXdrd(client, authFlags.receivedSalt, xdrd.xdrdPassword);
|
|
||||||
authFlags.receivedPassword = true;
|
authFlags.receivedPassword = true;
|
||||||
|
authenticateWithXdrd(client, authFlags.receivedSalt, xdrd.xdrdPassword);
|
||||||
} else {
|
} else {
|
||||||
if (line.startsWith('a')) {
|
if (line.startsWith('a')) {
|
||||||
authFlags.authMsg = true;
|
authFlags.authMsg = true;
|
||||||
@@ -167,6 +170,11 @@ function connectToXdrd() {
|
|||||||
|
|
||||||
client.on('data', (data) => {
|
client.on('data', (data) => {
|
||||||
helpers.resolveDataBuffer(data, wss);
|
helpers.resolveDataBuffer(data, wss);
|
||||||
|
if (authFlags.authMsg == true && authFlags.messageCount > 1) {
|
||||||
|
// If the limit is reached, remove the 'data' event listener
|
||||||
|
client.off('data', authDataHandler);
|
||||||
|
return;
|
||||||
|
}
|
||||||
authDataHandler(data);
|
authDataHandler(data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user