webtorrent: Error: invalid argument when connecting to uTP peers via IPv6

What version of this package are you using? v1.0.2 What operating system, Node.js, and npm version? Windows 10 LTSC 1809, electron 13.1.2, node 14.16.0 What happened? Adding/connecting to a peer which uses IPv6 string throws an error:

path\node_modules\utp-native\lib\connection.js:197
  binding.utp_napi_connect(this._utp._handle, this._handle, port, ip)
          ^

Error: invalid argument
    at Connection._connect (path\node_modules\utp-native\lib\connection.js:197:11)
    at path\node_modules\utp-native\lib\connection.js:189:10
    at processTicksAndRejections (internal/process/task_queues.js:81:21) {
  code: 'EINVAL'

code used:

      const peers = [{ type: 'utpOutgoing', addr: '[2001:5b0:4ec0:c848:4985:2d28:bde4:40e2]:39214' }]
      for (const peer of peers) {
        if (peer.type === 'webSeed') {
          this.torrent.addWebSeed(peer.addr)
        } else if (peer.type !== 'webrtc') {
          this.torrent.addPeer(peer.addr)
        }
      }

this also occurs when naturally connecting to uTP peers via trackers this doesnt occur for webSeeds/tcp peers

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 16 (6 by maintainers)

Most upvoted comments

Yea utp only has ipv4 atm