mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-12-18 19:42:27 -05:00
13 lines
290 B
JavaScript
13 lines
290 B
JavaScript
|
const net = require('net')
|
||
|
|
||
|
const getPort = () => new Promise(resolve => {
|
||
|
const server = net.createServer()
|
||
|
server.listen(0, '127.0.0.1')
|
||
|
server.on('listening', () => {
|
||
|
const { port } = server.address()
|
||
|
server.close(() => resolve(port))
|
||
|
})
|
||
|
})
|
||
|
|
||
|
module.exports = { getPort }
|