Skip to content

Commit

Permalink
Merge pull request #16 from odisseus/p2p-fix
Browse files Browse the repository at this point in the history
Added support for the /p2p protocol, which is an alias for /ipfs.
  • Loading branch information
ianopolous authored Jun 19, 2020
2 parents d28c37f + 1b2044f commit 2347e9f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
language: java
jdk:
- oraclejdk8
- openjdk9
- openjdk10
- openjdk11
2 changes: 2 additions & 0 deletions src/main/java/io/ipfs/multiaddr/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum Type {
UTP(301, 0, "utp"),
UDT(302, 0, "udt"),
UNIX(400, LENGTH_PREFIXED_VAR_SIZE, "unix"),
P2P(421, LENGTH_PREFIXED_VAR_SIZE, "p2p"),
IPFS(421, LENGTH_PREFIXED_VAR_SIZE, "ipfs"),
HTTPS(443, 0, "https"),
ONION(444, 80, "onion"),
Expand Down Expand Up @@ -97,6 +98,7 @@ public byte[] addressToBytes(String addr) {
if (x > 65535)
throw new IllegalStateException("Failed to parse "+type.name+" address "+addr + " (> 65535");
return new byte[]{(byte)(x >>8), (byte)x};
case P2P:
case IPFS: {
Multihash hash = Cid.decode(addr);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
Expand Down
1 change: 1 addition & 0 deletions src/test/java/io/ipfs/api/MultiAddressTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void succeeds() {
"/tcp/1234/https",
"/tcp/1234/ws",
"/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234",
"/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234",
"/ip4/127.0.0.1/udp/1234",
"/ip4/127.0.0.1/udp/0",
"/ip4/127.0.0.1/tcp/1234",
Expand Down

0 comments on commit 2347e9f

Please sign in to comment.