Skip to content

Commit eba2cd3

Browse files
committed
bugfix: 防止恶意端口攻击
1 parent 6ae56b6 commit eba2cd3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/server/swarm.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ class Swarm {
153153
if (!peer) continue
154154
if (isWebRTC && peer.peerId === ownPeerId) continue // don't send peer to itself
155155
if ((isWebRTC && peer.type !== 'ws') || (!isWebRTC && peer.type === 'ws')) continue // send proper peer type
156+
// 如果端口号不是0-65535, continue
157+
if (peer.port > 65535 || peer.port < 0) continue
156158
peers.push(peer)
157159
}
158160
return peers

0 commit comments

Comments
 (0)