Socket
Socket
Sign inDemoInstall

@bryopsida/eureka

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bryopsida/eureka

A library for securely discovering other processes in a multicast network


Version published
Weekly downloads
14
decreased by-36.36%
Maintainers
0
Weekly downloads
 
Created
Source

Eureka

This is intended to be a minimal, zero dependency library that can be used in other things for peer discovery when multicasting is available.

How do I use it?

You can either extend or wrap the Eureka class.

For example:

import { randomBytes, randomUUID } from 'node:crypto'
import { Eureka } from '@bryopsida/eureka'

const password = randomBytes(32).toString('utf8')
const salt = randomBytes(16).toString('utf8')
const id = randomUUID()
const algorithm = 'aes-256-gcm' // or 'chacha20-poly1305'
const kdfFunction = 'pbkdf2' // or 'scrypt'
const chunkSize = 1500 // amount of data passed to send at one time including header, decrease if you encounter EMSGSIZE errors
const chunkSpacing = 25 // milliseconds in between chunk send calls

const eureka = new Eureka({
    logger: console,
    crypto: {
        salt,
        password,
        algorithm,
        kdfFunction,
        chunkSize,
        chunkSpacing
    },
    messageData: {
        id,
        extraData: [{
            something: 1
        }]
    },
    server: {
        port: 41515
    }
}).on('error', (err) => {
    console.error(err)
}).on('ready', () => {
    console.log('eureka ready')
}).on('message', (msg) => {
    console.log('other processes message: ', msg)
})

process.on('SIGINT', () => {
    eureka?.close()
})

How does the discovery process work?

UDP multicasting is used to send messages to all hosts in the same network segment.

You can adjust the multicast group by setting opts.server.multicastGroups[] to the set of multicast groups you would like to use. The default set is ['224.0.0.1'] on port 515151.

To provide security the messages are encrypted with ChaCha20-poly1305 using the IP:PORT of the sender as the additional authentication data.

Hosted JSDoc page

You can find a hosted JSDoc page of the latest release here

FAQs

Package last updated on 02 Sep 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc