schlagmichdoch/PairDrop

[Bug] Uncaught exception on openwrt arm64

9thChasingWindGirl opened this issue · 8 comments

pairdrop@1.10.8 start
node server/index.js

PairDrop is running on port 60126
----- Uncaught exception -----
TypeError: Cannot read properties of undefined (reading 'substring')
at Peer._setIP (file:///mnt/mmcblk0p27/PairDrop/server/peer.js:54:21)
at new Peer (file:///mnt/mmcblk0p27/PairDrop/server/peer.js:15:14)
at WebSocketServer. (file:///mnt/mmcblk0p27/PairDrop/server/ws-server.js:18:76)
at WebSocketServer.emit (node:events:517:28)
at WebSocketServer.completeUpgrade (/mnt/mmcblk0p27/PairDrop/node_modules/ws/lib/websocket-server.js:436:5)
at WebSocketServer.handleUpgrade (/mnt/mmcblk0p27/PairDrop/node_modules/ws/lib/websocket-server.js:344:10)
at Server.upgrade (/mnt/mmcblk0p27/PairDrop/node_modules/ws/lib/websocket-server.js:119:16)
at Server.emit (node:events:517:28)
at onParserExecuteCommon (node:_http_server:938:14)
at onParserExecute (node:_http_server:824:3)
----- Exception origin -----
uncaughtException

What node and openwrt version are you running?

What node and openwrt version are you running?

DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='SNAPSHOT'
DISTRIB_REVISION='02.06.2024'
DISTRIB_TARGET='qualcommax/ipq60xx'
DISTRIB_ARCH='aarch64_cortex-a53'

and node ver is v18.20.3

In fact, all functions are normal at present, just in case, I noticed this log, so I submitted issue.

Is there luci for openwrt? Running paridrop manually is not easy to manage.

luci for openwrt

What do you mean?

There is no luci PairDrop package but maybe ypu can install docker compose and start PairDrop that way:
https://pkgs.staging.openwrt.org/package/master/packages/aarch64_cortex-a53/docker-compose

luci for openwrt

What do you mean?

There is no luci PairDrop package but maybe ypu can install docker compose and start PairDrop that way: https://pkgs.staging.openwrt.org/package/master/packages/aarch64_cortex-a53/docker-compose

luci-app-pairdrop maybe like this

I can reproduce this on my Ubuntu testing machine as well. Apparently, in some cases request.connection.remoteAddress can be undefined when a socket is closed immediately after opening which results in this error because the code assumes it to be a String. This is not critical though, as the socket is then closed anyway.

PairDrop/server/peer.js

Lines 45 to 55 in e6f2c77

if (request.headers['cf-connecting-ip']) {
this.ip = request.headers['cf-connecting-ip'].split(/\s*,\s*/)[0];
} else if (request.headers['x-forwarded-for']) {
this.ip = request.headers['x-forwarded-for'].split(/\s*,\s*/)[0];
} else {
this.ip = request.connection.remoteAddress;
}
// remove the prefix used for IPv4-translated addresses
if (this.ip.substring(0,7) === "::ffff:")
this.ip = this.ip.substring(7);

Apparently, request.connection is also deprecated and should be replaced by request.socket.
Line 50 will then simply change to:

            this.ip = request.socket.remoteAddress ?? '';

I'll add this fix in the next version. Thanks for reporting!

luci-app-pairdrop maybe like this

Although I like the idea of having an app for openwrt, I'll not prioritize that for now as this would probably include porting the node.js express server to C. If anyone is willing to create a wrapper for that, I'd gladly assist.

I can reproduce this on my Ubuntu testing machine as well. Apparently, in some cases request.connection.remoteAddress can be undefined when a socket is closed immediately after opening which results in this error because the code assumes it to be a String. This is not critical though, as the socket is then closed anyway.

PairDrop/server/peer.js

Lines 45 to 55 in e6f2c77

if (request.headers['cf-connecting-ip']) {
this.ip = request.headers['cf-connecting-ip'].split(/\s*,\s*/)[0];
} else if (request.headers['x-forwarded-for']) {
this.ip = request.headers['x-forwarded-for'].split(/\s*,\s*/)[0];
} else {
this.ip = request.connection.remoteAddress;
}
// remove the prefix used for IPv4-translated addresses
if (this.ip.substring(0,7) === "::ffff:")
this.ip = this.ip.substring(7);

Apparently, request.connection is also deprecated and should be replaced by request.socket.
Line 50 will then simply change to:

            this.ip = request.socket.remoteAddress ?? '';

I'll add this fix in the next version. Thanks for reporting!

luci-app-pairdrop maybe like this

Although I like the idea of having an app for openwrt, I'll not prioritize that for now as this would probably include porting the node.js express server to C. If anyone is willing to create a wrapper for that, I'd gladly assist.

The project is running well on OpenWRT, looking forward to your next improvement or update