forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: support blocklist for net.Server
PR-URL: nodejs#56079 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]>
- Loading branch information
1 parent
5878196
commit 78e7906
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const net = require('net'); | ||
|
||
const blockList = new net.BlockList(); | ||
blockList.addAddress(common.localhostIPv4); | ||
|
||
const server = net.createServer({ blockList }, common.mustNotCall()); | ||
server.listen(0, common.localhostIPv4, common.mustCall(() => { | ||
const adddress = server.address(); | ||
const socket = net.connect({ | ||
localAddress: common.localhostIPv4, | ||
host: adddress.address, | ||
port: adddress.port | ||
}); | ||
socket.on('close', common.mustCall(() => { | ||
server.close(); | ||
})); | ||
})); |