Skip to content

Commit 2347e9f

Browse files
authored
Merge pull request #16 from odisseus/p2p-fix
Added support for the /p2p protocol, which is an alias for /ipfs.
2 parents d28c37f + 1b2044f commit 2347e9f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
language: java
22
jdk:
3-
- oraclejdk8
3+
- openjdk9
4+
- openjdk10
5+
- openjdk11

src/main/java/io/ipfs/multiaddr/Protocol.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enum Type {
2323
UTP(301, 0, "utp"),
2424
UDT(302, 0, "udt"),
2525
UNIX(400, LENGTH_PREFIXED_VAR_SIZE, "unix"),
26+
P2P(421, LENGTH_PREFIXED_VAR_SIZE, "p2p"),
2627
IPFS(421, LENGTH_PREFIXED_VAR_SIZE, "ipfs"),
2728
HTTPS(443, 0, "https"),
2829
ONION(444, 80, "onion"),
@@ -97,6 +98,7 @@ public byte[] addressToBytes(String addr) {
9798
if (x > 65535)
9899
throw new IllegalStateException("Failed to parse "+type.name+" address "+addr + " (> 65535");
99100
return new byte[]{(byte)(x >>8), (byte)x};
101+
case P2P:
100102
case IPFS: {
101103
Multihash hash = Cid.decode(addr);
102104
ByteArrayOutputStream bout = new ByteArrayOutputStream();

src/test/java/io/ipfs/api/MultiAddressTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public void succeeds() {
8181
"/tcp/1234/https",
8282
"/tcp/1234/ws",
8383
"/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234",
84+
"/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234",
8485
"/ip4/127.0.0.1/udp/1234",
8586
"/ip4/127.0.0.1/udp/0",
8687
"/ip4/127.0.0.1/tcp/1234",

0 commit comments

Comments
 (0)