Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
udp-discovery
Advanced tools
This module provides discovery services using UDP multicast. udp-discovery implements the zero-configuration UDP multicast discovery and works only between nodes on the same subnet as typically, broadcast packets don't route.
npm install udp-discovery
var Discovery = require('udp-discovery').Discovery;
var discover = new Discovery();
var name = 'test';
var interval = 500;
var available = true;
var serv = {
port: 80,
proto: 'tcp',
addrFamily: 'IPv4',
bonus: {
name: 'Edmond',
day: 2233,
week: [ 'monday', 'tuesday', 'wednesday', 'thursday', 'friday' ]
}
};
discover.announce(name, serv, interval, available);
discover.on('MessageBus', function(event, data) {
console.log('event:',event);
console.log('data:',data);
});
var Discovery = require('udp-discovery').Discovery;
var discover = new Discovery();
discover.on('available', function(name, data, reason) {
console.log('available ',name);
console.log('data',data);
console.log('reason',reason);
var obj = {a: 1, b: '2', c: true, d: {e: 333}};
discover.sendEvent('Hello', obj);
console.log(name,':','available:',reason);
console.log(data);
});
discover.on('unavailable', function(name, data, reason) {
console.log(name,':','unavailable:',reason);
console.log(data);
});
Invokes the constructor to create an instance of Discovery to receive discovery events. The config options object is optional, but if included, the following options are available:
port
- The port to listen upon for service announcements. Default:
44201.bindAddr
- The address to bind to. Default: listens to all
interfaces.dgramType
- Either 'udp4' or 'udp6'. Default: 'udp4'.Starts announcing the service at the specified interval. The parameter,
serviceObject
, is an object describing the service that udp-discoveryy
announces.
name
The name of the service being announced. It must be unique, or
it will collide with another.interval
The duration between announcements in milliseconds.userData
Any data that can be serialized into JSON.available
Optional parameter to set availability of the service.
If not specified, the default is 'true', meaning available.Any property with a default can be left out and the code supplies the default value. The name and data are required.
name
The name of the service.Halts announcements.
name
name of the service.interval
] optional interval between announcements in ms.Resumes the announcements at the time interval.
name
name of the service.Returns the service object, which can be modified. For example, if you need to
alter the userData
, you can. You cannot, however, alter the name (it's a
constant property).
Updates the existing service.
name
The name of the service being announced. It must be unique, or
it will collide with another.userData
Any data that can be serialized into JSON.interval
] Optional duration between announcements in milliseconds.available
] Optional parameter to set availability of the service.
If not specified, the default is 'true', meaning available.Has the following parameters:
name
name of the service.data
user-defined object describing the service.reason
why this event was sent: 'new', 'availabilityChange',
'timedOut'.This event can happen when:
Has the following parameters:
name
name of the service.data
user-defined object describing the service.reason
why this event was sent: 'new', 'availabilityChange',
'timedOut'.This event can happen when:
Copyright (c) 2014 Edmond Meinfelder
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Provides zero-config discovery service using broadcast UDP.
We found that udp-discovery demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.