Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Method Transport#filter() doesn't matches unix sockets #132

Closed
@rumkin

Description

@rumkin

According to the source code, TCP transport method Transport#filter() relies on mafmt's TCP matcher function (mafmt /src/index.js:18) which doesn't match unix sockets: src/index.js:135. So it's impossible to listen unix sockets. And attempts to provide unix path to Transport fails:

import path from 'path'

import Libp2p from 'libp2p'
import Tcp from 'libp2p-tcp'
import Mplex from 'libp2p-mplex'
import PeerId from 'peer-id'
import PeerInfo from 'peer-info'
import Plaintext from 'libp2p/src/insecure/plaintext.js'



const serverPeer = await PeerId.create()
const serverInfo = new PeerInfo(serverPeer)

serverInfo.multiaddrs.add(
  path.join('/unix', path.resolve('unix.sock'))
)

const node = await Libp2p.create({
    peerInfo: serverInfo,
    modules: {
      transport: [Tcp],
      connEncryption: [Plaintext],
      streamMuxer: [Mplex],
    },
})

The code throws ERR_NO_VALID_ADDRESSES. I'm not sure if it the TCP or mafmt package error. I'm not sure if it the TCP or mafmt package error, but while it's hard to understand which protocol is unix port listening I think it relates to this package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: Good to have, but can wait until someone steps upexp/noviceSomeone with a little familiarity can pick upkind/bugA bug in existing code (including security flaws)releasedstatus/readyReady to be worked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions