Skip to content

Instantly share code, notes, and snippets.

@icetee
Last active August 26, 2018 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icetee/f5fc99c2b75d7fd0fc8dd60339e84f2a to your computer and use it in GitHub Desktop.
Save icetee/f5fc99c2b75d7fd0fc8dd60339e84f2a to your computer and use it in GitHub Desktop.
Random port generator for FTP Active [PORT], Passive [PASV] server
const getRandomPort = (min, max) => {
const port = Math.round(Math.random() * (max - min) + min);
return {
port: port,
p1: parseInt(port / 256, 10),
p2: port % 256,
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment