1.0.0 • Published 21 days ago

@landmineaknpm/debitis-ratione-reprehenderit v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
21 days ago

@landmineaknpm/debitis-ratione-reprehenderit

Get an available TCP or UDP port for the given IP address.

$ npm install @landmineaknpm/debitis-ratione-reprehenderit

Usage

import { pickPort } from '@landmineaknpm/debitis-ratione-reprehenderit';

Get a random UDP port in IP 0.0.0.0:

const port = await pickPort({ type: 'udp' });

Get a TCP port in a specific IP and port range:

const port = await pickPort({
	type: 'tcp',
	ip: '192.168.10.111',
	minPort: 8000,
	maxPort: 9000,
});

API

async pickPort({ type, ip, minPort, maxPort, reserveTimeout }): Promise

Resolves with an available port or rejects with an error otherwise.

OptionTypeDescriptionRequiredDefault
typeString'udp' or 'tcp'.Yes
ipStringIPv4 or IPv6 address for which a free port is requested.No'0.0.0.0'
minPortNumberMinimum port.No10000
maxPortNumberMaximum port.No20000
reserveTimeoutNumberTimeout in seconds during which a returned port will be internally reserved and prevented of being returned on a future call before the timeout has elapsed.No5
  • @returns {Number} A free port.

The reserveTimeout option provides the application with the required time to bind the free port before it is given again on a future call to this library.

Authors

License

ISC

cryptlrufullweakmaptakeTypedArrayspinnersproxyupmatchBigInt64ArrayviewvalidatelimitRFC-6455Object.isparsermkdirjQuerylinktslibmomentURLdescriptores5objswfkinesiscloudsearchcloudfronteslint.envfind-upsyntaxshimloggingdirses256elbsigintfolderlinewrapeslint-plugincloudformationsignalsArray.prototype.includesES2019shamtyped arrayWebSocketdependency manageri18nopentypedarrayspecbrowserslistcallbindparentspromisesindicatordirectoryes2016haspostcssfullwidthUnderscorestarterintrinsicclassnametapeeventEmitterJSONa11yhandlerstestingWeakSetECMAScript 5definePropertyStyleSheetestreeObject.valuesxhrratelimitcallbackjsxschemacompilerimportnamebind__proto__util.inspectpasswordyamlkeyconfiglockfilemetadatapluginObservablesObject.definePropertypackagesgenericspreserve-symlinksmkdirpES2023symbolcharactersequalityformswatcherperformancesameValueZeroweaksetString.prototype.matchAllschemesetPrototypeOfsymbolsfilterxtermlinttypanionloadbalancingwhatwgcjkairbnbquerytrimEndrateargparseautoprefixerdroppropertyvestclassesisConcatSpreadablehttpstaskESnextfluxemojiparentvalidationbreakiamArray.prototype.findLastIndexRegExp.prototype.flagsnpmajvSetinterruptsstatusarraysregexansierrorcolourassertionfindLastIndexhotstreams2figletECMAScript 2021promisees7escapereuseimmutabletrimRighttoArrayrapidgraphqlcolorinternal slotArrayBufferkeysresolvegetrmflagsYAMLbootstrap csspackage managerES2018speedbddserializervaluesimmerES5sinatralengthconcurrencypolyfilltypecacheless compilerreplayreal-timeconsoleiteratorECMAScript 2018Object.entriesscheme-validationstylingessharedfastutilnamesless.jsdynamodbminimalstylesasyncObservablepackagejwtfindupes6iterationmruFloat64Arrayjasmineobjectes-shimsglobtsmulti-packageprivate datawatchFilematchAllnodecliargsURLSearchParamsfixed-widthchanneldescriptorsexit-codecss-in-jslibphonenumberterminalprotocol-buffersreactelasticachees2018dom-testing-libraryemitredactentriescheckec2corsurltimebrowserinstallerprefixslicelimitedjsonpathrdsqueuepositivetrimfast-copyrandomoutputdeep-copyform-validationappregexpwebtypedreducecommand-linesettingsbrowserlistwatchingincludeseast-asian-widthonceeslintconfigcolumnString.prototype.trimfindLasthashflatMapfromdotenvpyyamltddjoimake dirStreamlistenersbundlersortedlinuxexitArrayfpstypescriptdescriptionelectronutilityuuidpipeECMAScript 2023getintrinsichelperstoobjectmonorepostringifierstreamvpcendpointgetterapolloCSStoSortednodejscommandsimpledbtypeerrorArray.prototype.flatgetOwnPropertyDescriptortelephonetapcurlfull-widthshebangInt8Arrayenvironment[[Prototype]]es-shim APIreact-hooksrm -rfguidtoStringTagpersistentdataViewfastcopymatchesinspectfastclonetesteraccessorcore-jsPromisecallJSON-SchematoolkitUint32ArraymoduleES2016Function.prototype.nameparsinglessbuffersvisualcompile lessprunestringstreamsObject.assignebsmimeformassertsphonemixinsequaltc39readablestreamquerystringReflect.getPrototypeOfnegative zeroyuptermoperating-systemMappreprocessorcoerciblesometrimLeftpnpm9asteslintpluginES2015quotequeueMicrotaskreadablerequestglacierlook-upArray.prototype.flatMapsearchES6Array.prototype.findLastformattingtypeoflivezerodayjswordwrapsetforEacheventDispatcherECMAScript 2016typedarraysmergeunicodeauthenticationoffsetjestwatchhas-ownArray.prototype.flattenclassnamesinbusy-0hasOwncolumnsfast-cloneES3error-handlingregularidleRxoptionless mixinsjapaneseawsmakesharedarraybufferReactiveExtensionsSymbol.toStringTages-abstractcall-bindwgetarraybufferbcryptUint8Arraytestoptimistdeepclonekoreandependenciesparsejsondeep-cloneprotorobustBigUint64Arraymobilesequencecodesprogressvariablesstringifyprototypewrapcollection.es6removeWeakMapmkdirsl10n
1.0.0

21 days ago