From 71c1bfde3670d6b961fa19387fada17f00f6eb8f Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 20 Jul 2017 14:36:21 -0700 Subject: [PATCH] Fix protocol multicodecs numbers 1. Swap udt/utp. 2. Fix udp (17 is SHA1) 3. Change them to hex so it's easier to compare them with the official multicodec table. 4. Remove the local protocols.csv table. Fixes #49 Fixes multiformats/multicodec#51 --- protocols.csv | 15 --------------- protocols.go | 37 +++++++++++++++++++------------------ 2 files changed, 19 insertions(+), 33 deletions(-) delete mode 100644 protocols.csv diff --git a/protocols.csv b/protocols.csv deleted file mode 100644 index 996b855..0000000 --- a/protocols.csv +++ /dev/null @@ -1,15 +0,0 @@ -code size name - -4 32 ip4 -6 16 tcp -17 16 udp -33 16 dccp -41 128 ip6 -132 16 sctp -301 0 utp -302 0 udt -400 V unix -421 V ipfs -480 0 http -443 0 https -444 96 onion diff --git a/protocols.go b/protocols.go index 3292be7..75e1349 100644 --- a/protocols.go +++ b/protocols.go @@ -16,25 +16,26 @@ type Protocol struct { Transcoder Transcoder } -// replicating table here to: -// 1. avoid parsing the csv -// 2. ensuring errors in the csv don't screw up code. -// 3. changing a number has to happen in two places. +// You **MUST** register your multicodecs with +// https://github.com/multiformats/multicodec before adding them here. +// +// TODO: Use a single source of truth for all multicodecs instead of +// distributing them like this... const ( - P_IP4 = 4 - P_TCP = 6 - P_UDP = 17 - P_DCCP = 33 - P_IP6 = 41 - P_QUIC = 81 - P_SCTP = 132 - P_UTP = 301 - P_UDT = 302 - P_UNIX = 400 - P_IPFS = 421 - P_HTTP = 480 - P_HTTPS = 443 - P_ONION = 444 + P_IP4 = 0x0004 + P_TCP = 0x0006 + P_UDP = 0x0111 + P_DCCP = 0x0021 + P_IP6 = 0x0029 + P_QUIC = 0x0051 + P_SCTP = 0x0084 + P_UDT = 0x012D + P_UTP = 0x012E + P_UNIX = 0x0190 + P_IPFS = 0x01A5 + P_HTTP = 0x01E0 + P_HTTPS = 0x01BB + P_ONION = 0x01BC ) // These are special sizes