Git Product home page Git Product logo

signal's Introduction

@dxos/signal

DxOS signal server.

Build Status Coverage Status npm (scoped) js-semistandard-style standard-readme compliant

Install

$ npm install -g @dxos/signal

Usage

$ signal --help

signal [topic]

start a signal server

Options:
  --version        Show version number                                 [boolean]
  --help           Show help                                           [boolean]
  --topic          topic to find other signal servers[string] [default: "#dxos"]
  --port, -p       defines a port to listening                   [default: 4000]
  --bootstrap, -b  defines a list of bootstrap nodes                     [array]
  --asBootstrap    enable the signal as a bootstrap node
                                                      [boolean] [default: false]
  --repl, -r       start a repl console with your signal               [boolean]
  --logLevel, -l   defines the log level
                   [choices: "debug", "info", "warn", "error"] [default: "info"]
  --logFormat      defines the log format
                  [choices: "full", "short", "simple", "json"] [default: "full"]
  --logDir         defines a log directory                              [string]
const { createBroker } = require('@dxos/signal')

const topic = randomBytes(32)

createBroker(topic, opts).start()

API

...

Contributing

PRs accepted.

License

GPL-3.0 © dxos

DxOS Signal Server

signal's People

Contributors

tinchoz49 avatar telackey avatar richburdon avatar github-actions[bot] avatar chriswaclawek avatar egorgripasov avatar

Stargazers

Alexandre Nicastro avatar

Watchers

 avatar Mark Belinsky avatar Olaf Kreitz avatar James Cloos avatar  avatar David Boreham avatar  avatar  avatar Paweł Szon avatar

Forkers

ethworks nytyn

signal's Issues

Don't broadcast a command if we are directly connected to the target

If we have a direct connection to the target node (meta.target) rather than broadcasting it to all peers, we should send it directly.

Here is the broadcast code:

  send (topic, data) {
    if (!this._swarm || this._messenger.closed || this._messenger.closing || this._messenger.peers.length === 0) return Promise.resolve();

    return this._messenger.broadcast({ topic, data });
  }

We would need to do something like:

if (meta.target && this._messenger.hasPeer(meta.target) {
   this._messenger.getPeer(meta.target).send(...)
}

Broadcasts are currently on channel '0'. We could use channel '1' for direct messages:

  send (buf) {
    if (this._socket.destroyed) return;
    this._protocol.extension(0, 0, buf);
  }

Memory leak

There is a memory leak in signal:

root@xbox:~# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0   4624    68 pts/0    Ss+  Apr23   0:00 /bin/sh -c /opt/xbox/scripts/run.sh
root         6  0.0  0.0  18504  1340 pts/0    S+   Apr23   0:00 /bin/bash /opt/xbox/scripts/run.sh
root        25  0.0  0.0  72296  1856 ?        Ss   Apr23   0:00 /usr/sbin/sshd
root        50  0.0  0.0  95084  6616 ?        Ss   Apr23   0:02 /usr/sbin/apache2 -k start
www-data    54  0.0  0.0 2023224 6180 ?        Sl   Apr23   0:14 /usr/sbin/apache2 -k start
www-data    55  0.0  0.0 2023128 7756 ?        Sl   Apr23   0:10 /usr/sbin/apache2 -k start
root       120  0.1  0.3 618296 52960 ?        Ssl  Apr23   0:51 PM2 v4.3.1: God Daemon (/root/.pm2)
root       131  0.7  0.6 1319864 98008 ?       Ssl  Apr23   6:00 /usr/local/bin/ipfs daemon --writable
root       208  0.0  0.0  18372  2616 pts/0    S+   Apr23   0:00 /bin/bash /opt/xbox/scripts/ipfs_swarm_connect.sh xbox1.bozemanpass.ne
root       237  0.0  0.0 726508 11276 ?        Ssl  Apr23   0:30 /usr/bin/turnserver -c /etc/turnserver.conf -o -v
root       316  0.3  0.3 1019632 50548 pts/0   Sl+  Apr23   2:44 wnsd-lite start --gql-port 9473 --gql-playground-api-base /dxos/wns --
root       329 17.9 23.0 5642528 3753868 ?     Ssl  Apr23 144:19 node /usr/local/bin/dxos-signal --asBootstrap --bootstrap xbox2.bozema
root       347  0.0  0.3 592728 49968 ?        Ssl  Apr23   0:00 node /usr/local/bin/wire-app-server 5999 http://127.0.0.1:8888/ipfs/ h
root       361  0.0  0.1 563848 27536 ?        Ssl  Apr23   0:00 node /usr/local/bin/dxos-dashboard
root       368  0.2  0.5 655088 85064 ?        Sl   Apr23   2:23 node /usr/local/bin/npx next start
root       379  0.0  0.0   4564    60 pts/0    S+   Apr23   0:02 tail -f /var/log/apache2/error.log
root      4830  0.0  0.0  18500  1480 pts/1    Ss+  Apr23   0:00 /bin/bash
root     10400  0.0  0.0  97188  6744 ?        Rs   03:04   0:00 sshd: root@pts/2
root     10420  0.0  0.0  18504  3476 pts/2    Ss   03:04   0:00 -bash
root     11733  0.0  0.0   4528   880 pts/0    S+   03:11   0:00 sleep 300
root     11971  0.0  0.0  34400  2772 pts/2    R+   03:12   0:00 ps aux

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.