Skip to content

Commit

Permalink
Merge pull request libp2p#17 from masylum/feature/remove-v4-to-v6-hack
Browse files Browse the repository at this point in the history
Removed ipv6/ipv4 hack
  • Loading branch information
daviddias committed Nov 2, 2015
2 parents 3b9465d + c39eb4a commit 60028da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"dependencies": {
"async": "^1.3.0",
"ip-address": "^4.0.0",
"ip-address": "^5.0.2",
"ipfs-logger": "^0.1.0",
"multiaddr": "^1.0.0",
"multiplex-stream-muxer": "^0.2.0",
Expand Down
8 changes: 4 additions & 4 deletions src/identify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var Interactive = require('multistream-select').Interactive
var protobufs = require('protocol-buffers-stream')
var fs = require('fs')
var schema = fs.readFileSync(__dirname + '/identify.proto')
var v6 = require('ip-address').v6
var Address6 = require('ip-address').Address6
var Id = require('peer-id')
var multiaddr = require('multiaddr')

Expand Down Expand Up @@ -112,10 +112,10 @@ exports.getHandlerFunction = function (peerInfoSelf, muxedConns) {

function getMultiaddr (socket) {
var mh
if (~socket.remoteAddress.indexOf(':')) {
var addr = new v6.Address(socket.remoteAddress)
if (socket.remoteFamily === 'IPv6') {
var addr = new Address6(socket.remoteAddress)
if (addr.v4) {
var ip4 = socket.remoteAddress.split(':')[3]
var ip4 = addr.to4().correctForm()
mh = multiaddr('/ip4/' + ip4 + '/tcp/' + socket.remotePort)
} else {
mh = multiaddr('/ip6/' + socket.remoteAddress + '/tcp/' + socket.remotePort)
Expand Down

0 comments on commit 60028da

Please sign in to comment.