without dependencies
const IPRange = require('ip-range-middleware')
Allow only 127.0.0.1
app.use(IPRange([
[127], [0], [0], [1]
]))
Allow only the range from 192.168.178.1 to 192.168.178.128
app.use(IPRange([
[192], [168], [178], [1, 128]
]))
Allow only two addresses
app.use(IPRange([
[[192], [168], [178], [2]],
[[127], [0], [0], [1]]
]))
Allow only ::1
app.use(IPRange([], { allow: ['::1'] }))