dCast, dVoice, dSSH, and P2P Communications Over dSwarm

As described in the previous post, dSwarm’s DHT can be used to announce and lookup dWeb network addresses or for connecting with peers that announce themselves under previously announced network addresses. Once connected, peers can truly exchange anything, whether its a message or some other data structure. dWeb 3.0 features many new tools that showcase dWeb’s ability to power everything from voice calling to SSH connections. Below, we will explore many newcomers in dWeb’s 3.0 toolkit.

==== DCAST & THE E2E ENCRYPTED INTERNET PIPE

The all-new `dcast` module allows two peers to exchange encrypted messages over a dWeb network address-based pipe using NOISE-based encryption. This is a powerful and secure way for two peers to exchange a keypair for future encryption purposes or some other secret message. You can create a “cast” programmatically like so:

```

const DCast = require(‘dcast’)

const cast = new DCast(‘let freedom stream’)

// Create a messenger app

process.stdin.pipe(cast).pipe(process.stdout)

```

dCast also ships with a CLI, which can be used like so via the command line:

```

// Install dCast on two different machines

npm install -g dcast

// On one machine run:

echo ‘let freedom stream’ | dcast ‘let-freedom-stream’

// Then on another machine run:

dcast ‘let-freedom-stream’

// This will print “let freedom stream”

```

dCast will soon help power encrypted messaging within the dMessenger app, that will rollout as apart of the dSocial ALPHA release.

For more on dCast’s API, see https://npmjs.com/package/dcast

==== DVOICE & P2P VOICE CALLING

Recently I hinted that we were working on a way to handle peer-to-peer voice calls over the dWeb, and today, we’re debuting an all-new command line-based voice calling tool that showcases that ability, which will soon be integrated into the dMessenger app as well.

Like a cast, voice calls are made over a dWeb network address. To test it out for yourself, do the following:

```

// Install dVoice and Sox on two different machines:

npm install -g dvoice

// On Mac

brew install sox

// On Linux

sudo apt-get install sox

// On your computer (any string will work here, as it is used to derive a dWeb network address)

dphone “d2148888888”

// On your friend’s computer

dphone “d2148888888”

```

Now you and your friend should be having a pretty awesome and distributed conversation. While this example requires SOX, audio can be streamed between two or more peers using a dDatabase and the dDatabase Protocol (https://npmjs.com/package/@ddatabase/protocol) or some other data structure that still utilizes websockets for streaming data. This is how we’re able to integrate voice calling into an app like dMessenger.

==== SSH OVER DWEB

Yes, it’s true! You can run SSH over dWeb. All it takes is the `dwebssh` CLI. To test it out, do the following:

```

// First install dwebssh on a server and your laptop

npm install -g dwebssh

// On a server that has “ssh-server” running, run the following:

dwebssh-server

// This will print out the ssh fingerprint and start announcing the server on dSwarm’s DHT under this fingerprint

// On another computer, you can SSH into the server by passing the fingerprint and the user you want to connect

// as, to the `dwebssh` CLI

dwebssh <fingerprint> jared

```

Using dWebSSH, the SSH fingerprint is forwarded to the client so that the connection is safe from man-in-the-middle attacks. As an added plus, since dSwarm enables UDP holepunching, your server can be made available over SSH even if its behind a firewall.

To learn more about dWebSSH, go to https://npmjs.com/package/dwebssh

==== PEERSOCKETS & ENCRYPTED MESSAGING

PeerSockets (https://npmjs.com/package/dweb-peersockets) allows two or more peers to subscribe to and exchange encrypted messages over a dWeb network address. An example of doing this programmatically is below:

```

// Using the @basestore/networker module for networking

const networker = require(‘@basestore/networker’)

const Peersockets = require(‘dweb-peersockets’)

const sockets = new Peersockets(networker)

const friendPeer = networker.peers[0]

const handle = sockets.join(‘maga-chat-room’, {

onmessage: (msg, peer) => {

console.log(`I got message ${msg} from ${peer.remotePublicKey.toString(‘hex’)}`)

}

})

// If your friend is subscribed to the network address, that derives from “maga-chat-room”

// they will receive this message:

handle.send(‘Sleepy Joe just fell!’, friendPeer)

```

This is just a quick example of how dWeb 3.0 can be used to handle high-level forms of encrypted communications and should give you a good idea of how dSocial will separate itself from other “decentralized” social networks. Especially since dSocial will be capable of running on a completely blockchain-less basis. By using dWeb and dSwarm’s various modules as a bunch of legos, you can begin building your own distributed telecommunication services quite easily.

====

WHAT’S NEXT?

We’re introducing the all-new dHub toolset, along with many other new CLI tools that are changing how developers build on the dWeb.

====

The creators of the #dweb and the world’s first decentralized and censorship-resistant social network. We’re about to #DecentralizeEverything.