Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

feat: compatibility with go-libp2p-mdns - option 2 #81

Closed
wants to merge 11 commits into from

Commits on Apr 8, 2019

  1. feat: compatibility with go-libp2p-mdns

    This PR adds a compatibility class that allows a js-libp2p node to find a go-libp2p node (and vice versa) over MDNS.
    
    It's implemented as a separate class so the two differing implementations do not get confused.
    
    I've verified this is working correctly by running a go-ipfs and js-ipfs node with no boostrap nodes (and no other discovery methods) and verifying they find each other.
    
    TODO:
    
    * [ ] Add tests!
    
    Some tips if you want to try this out:
    
    * After you've run `ipfs init`, remember to remove the bootstrap nodes from the config file (`~/.ipfs/config`) of each node before you start up
    * Use `ipfs log level mdns debug` for some go-ipfs mdns logs
    * You can use the following script (after `npm link`ing this branch) to start a js-ipfs node with no bootstrap nodes and no discovery modules other than MDNS:
    
    ```js
    const IPFS = require('ipfs')
    const MDNS = require('libp2p-mdns')
    const TCP = require('libp2p-tcp')
    
    const ipfs = new IPFS({
      repo: '/tmp/ipfs-mdns',
      config: {
        Bootstrap: []
      },
      libp2p: {
        modules: {
          peerDiscovery: [MDNS],
          transport: [TCP]
        }
      }
    })
    
    ipfs.on('ready', async () => {
      console.log('ipfs is ready')
      console.log('My Peer ID:', (await ipfs.id()).id)
      setInterval(async () => {
        const peers = await ipfs.swarm.peers()
        console.log(peers.length, 'peers:')
        peers.forEach(p => console.log(p.peer.toB58String()))
      }, 10000)
    })
    ```
    
    License: MIT
    Signed-off-by: Alan Shaw <[email protected]>
    Alan Shaw committed Apr 8, 2019
    Configuration menu
    Copy the full SHA
    f4f1bc9 View commit details
    Browse the repository at this point in the history
  2. chore: appease linter

    License: MIT
    Signed-off-by: Alan Shaw <[email protected]>
    Alan Shaw committed Apr 8, 2019
    Configuration menu
    Copy the full SHA
    6d4d730 View commit details
    Browse the repository at this point in the history
  3. fix: move async to dependencies

    License: MIT
    Signed-off-by: Alan Shaw <[email protected]>
    Alan Shaw committed Apr 8, 2019
    Configuration menu
    Copy the full SHA
    ab9839c View commit details
    Browse the repository at this point in the history

Commits on Apr 9, 2019

  1. fix: typo in comment

    Co-Authored-By: alanshaw <[email protected]>
    vasco-santos and alanshaw authored Apr 9, 2019
    Configuration menu
    Copy the full SHA
    019437f View commit details
    Browse the repository at this point in the history
  2. refactor: pr feedback

    License: MIT
    Signed-off-by: Alan Shaw <[email protected]>
    alanshaw committed Apr 9, 2019
    Configuration menu
    Copy the full SHA
    96ddf65 View commit details
    Browse the repository at this point in the history
  3. fix: respond directly to querier

    License: MIT
    Signed-off-by: Alan Shaw <[email protected]>
    alanshaw committed Apr 9, 2019
    Configuration menu
    Copy the full SHA
    b5949e7 View commit details
    Browse the repository at this point in the history
  4. fix: reemit the peer event from GoMulticastDNS

    License: MIT
    Signed-off-by: Alan Shaw <[email protected]>
    alanshaw committed Apr 9, 2019
    Configuration menu
    Copy the full SHA
    a539f00 View commit details
    Browse the repository at this point in the history
  5. refactor: simply advertise with a go compatible repsonse every 10s

    License: MIT
    Signed-off-by: Alan Shaw <[email protected]>
    alanshaw committed Apr 9, 2019
    Configuration menu
    Copy the full SHA
    1a4fe07 View commit details
    Browse the repository at this point in the history
  6. fix: default options

    License: MIT
    Signed-off-by: Alan Shaw <[email protected]>
    alanshaw committed Apr 9, 2019
    Configuration menu
    Copy the full SHA
    5717bde View commit details
    Browse the repository at this point in the history
  7. refactor: revert unneeded changes

    License: MIT
    Signed-off-by: Alan Shaw <[email protected]>
    alanshaw committed Apr 9, 2019
    Configuration menu
    Copy the full SHA
    35e9233 View commit details
    Browse the repository at this point in the history
  8. refactor: add tag to allow this to be used standalone

    License: MIT
    Signed-off-by: Alan Shaw <[email protected]>
    alanshaw committed Apr 9, 2019
    Configuration menu
    Copy the full SHA
    21795de View commit details
    Browse the repository at this point in the history