@cryptotaxi247 / kubo / commits / 7f3929903

chore(deps:go-multiaddr) update to b90678896b52c

procedure is to execute ``` cd my/github.com/jbenet/go-multiaddr git pull cd my/github.com/jbenet/go-ipfs godep update github.com/jbenet/go-multiaddr ```

Brian Tiger Chow committed Sep 11, 2014 at 11:13 UTC 7f39299033dcdbefb4d6fdd743aaa84dd1abc5dd
5 files changed +30 -14
Godeps/Godeps.json
+2 -2
@@ -55,8 +55,8 @@
55 },
56 {
57 "ImportPath": "github.com/jbenet/go-multiaddr",
58 - "Comment": "0.1.0-1-g99196c0",
59 - "Rev": "99196c0d231f83eea7f6e47cf59cbb5a0b86b358"
58 + "Comment": "0.1.2",
59 + "Rev": "b90678896b52c3e5a4c8176805c6facc3fe3eb82"
60 },
61 {
62 "ImportPath": "github.com/jbenet/go-multihash",
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/codec.go
+10 -6
@@ -8,10 +8,14 @@ import (
8 "strings"
9 )
10
11 -func StringToBytes(s string) ([]byte, error) {
11 +func stringToBytes(s string) ([]byte, error) {
12 b := []byte{}
13 sp := strings.Split(s, "/")
14
15 + if sp[0] != "" {
16 + return nil, fmt.Errorf("invalid multiaddr, must begin with /")
17 + }
18 +
19 // consume first empty elem
20 sp = sp[1:]
21
@@ -22,7 +26,7 @@ func StringToBytes(s string) ([]byte, error) {
26 }
27 b = append(b, byte(p.Code))
28
25 - a := AddressStringToBytes(p, sp[1])
29 + a := addressStringToBytes(p, sp[1])
30 b = append(b, a...)
31
32 sp = sp[2:]
@@ -30,7 +34,7 @@ func StringToBytes(s string) ([]byte, error) {
34 return b, nil
35 }
36
33 -func BytesToString(b []byte) (ret string, err error) {
37 +func bytesToString(b []byte) (ret string, err error) {
38 // panic handler, in case we try accessing bytes incorrectly.
39 defer func() {
40 if e := recover(); e != nil {
@@ -49,7 +53,7 @@ func BytesToString(b []byte) (ret string, err error) {
53 s = strings.Join([]string{s, "/", p.Name}, "")
54 b = b[1:]
55
52 - a := AddressBytesToString(p, b[:(p.Size/8)])
56 + a := addressBytesToString(p, b[:(p.Size/8)])
57 if len(a) > 0 {
58 s = strings.Join([]string{s, "/", a}, "")
59 }
@@ -59,7 +63,7 @@ func BytesToString(b []byte) (ret string, err error) {
63 return s, nil
64 }
65
62 -func AddressStringToBytes(p *Protocol, s string) []byte {
66 +func addressStringToBytes(p *Protocol, s string) []byte {
67 switch p.Code {
68
69 // ipv4,6
@@ -79,7 +83,7 @@ func AddressStringToBytes(p *Protocol, s string) []byte {
83 return []byte{}
84 }
85
82 -func AddressBytesToString(p *Protocol, b []byte) string {
86 +func addressBytesToString(p *Protocol, b []byte) string {
87 switch p.Code {
88
89 // ipv4,6
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/index.go
+12 -3
@@ -5,22 +5,26 @@ import (
5 "strings"
6 )
7
8 +// Multiaddr is the data structure representing a multiaddr
9 type Multiaddr struct {
10 Bytes []byte
11 }
12
13 +// NewMultiaddr parses and validates an input string, returning a *Multiaddr
14 func NewMultiaddr(s string) (*Multiaddr, error) {
13 - b, err := StringToBytes(s)
15 + b, err := stringToBytes(s)
16 if err != nil {
17 return nil, err
18 }
19 return &Multiaddr{Bytes: b}, nil
20 }
21
22 +// String returns the string representation of a Multiaddr
23 func (m *Multiaddr) String() (string, error) {
21 - return BytesToString(m.Bytes)
24 + return bytesToString(m.Bytes)
25 }
26
27 +// Protocols returns the list of protocols this Multiaddr has.
28 func (m *Multiaddr) Protocols() (ret []*Protocol, err error) {
29
30 // panic handler, in case we try accessing bytes incorrectly.
@@ -44,12 +48,14 @@ func (m *Multiaddr) Protocols() (ret []*Protocol, err error) {
48 return ps, nil
49 }
50
51 +// Encapsulate wraps a given Multiaddr, returning the resulting joined Multiaddr
52 func (m *Multiaddr) Encapsulate(o *Multiaddr) *Multiaddr {
53 b := make([]byte, len(m.Bytes)+len(o.Bytes))
54 b = append(m.Bytes, o.Bytes...)
55 return &Multiaddr{Bytes: b}
56 }
57
58 +// Decapsulate unwraps Multiaddr up until the given Multiaddr is found.
59 func (m *Multiaddr) Decapsulate(o *Multiaddr) (*Multiaddr, error) {
60 s1, err := m.String()
61 if err != nil {
@@ -68,9 +74,10 @@ func (m *Multiaddr) Decapsulate(o *Multiaddr) (*Multiaddr, error) {
74 return NewMultiaddr(s1[:i])
75 }
76
77 +// DialArgs is a convenience function returning arguments for use in net.Dial
78 func (m *Multiaddr) DialArgs() (string, string, error) {
79 if !m.IsThinWaist() {
73 - return "", "", fmt.Errorf("%s is not a 'thin waist' address.", m)
80 + return "", "", fmt.Errorf("%s is not a 'thin waist' address", m)
81 }
82
83 str, err := m.String()
@@ -84,6 +91,8 @@ func (m *Multiaddr) DialArgs() (string, string, error) {
91 return network, host, nil
92 }
93
94 +// IsThinWaist returns whether this multiaddr includes "Thin Waist" Protocols.
95 +// This means: /{IP4, IP6}/{TCP, UDP}
96 func (m *Multiaddr) IsThinWaist() bool {
97 p, err := m.Protocols()
98 if err != nil {
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/multiaddr_test.go
+2 -2
@@ -14,7 +14,7 @@ func TestStringToBytes(t *testing.T) {
14 t.Error("failed to decode hex", h)
15 }
16
17 - b2, err := StringToBytes(s)
17 + b2, err := stringToBytes(s)
18 if err != nil {
19 t.Error("failed to convert", s)
20 }
@@ -35,7 +35,7 @@ func TestBytesToString(t *testing.T) {
35 t.Error("failed to decode hex", h)
36 }
37
38 - s2, err := BytesToString(b)
38 + s2, err := bytesToString(b)
39 if err != nil {
40 t.Error("failed to convert", b)
41 }
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/protocols.go
+4 -1
@@ -1,5 +1,6 @@
1 package multiaddr
2
3 +// Protocol is a Multiaddr protocol description structure.
4 type Protocol struct {
5 Code int
6 Size int
@@ -10,7 +11,6 @@ type Protocol struct {
11 // 1. avoid parsing the csv
12 // 2. ensuring errors in the csv don't screw up code.
13 // 3. changing a number has to happen in two places.
13 -
14 const (
15 P_IP4 = 4
16 P_TCP = 6
@@ -20,6 +20,7 @@ const (
20 P_SCTP = 132
21 )
22
23 +// Protocols is the list of multiaddr protocols supported by this module.
24 var Protocols = []*Protocol{
25 &Protocol{P_IP4, 32, "ip4"},
26 &Protocol{P_TCP, 16, "tcp"},
@@ -32,6 +33,7 @@ var Protocols = []*Protocol{
33 // {443, 0, "https"},
34 }
35
36 +// ProtocolWithName returns the Protocol description with given string name.
37 func ProtocolWithName(s string) *Protocol {
38 for _, p := range Protocols {
39 if p.Name == s {
@@ -41,6 +43,7 @@ func ProtocolWithName(s string) *Protocol {
43 return nil
44 }
45
46 +// ProtocolWithCode returns the Protocol description with given protocol code.
47 func ProtocolWithCode(c int) *Protocol {
48 for _, p := range Protocols {
49 if p.Code == c {