@cryptotaxi247 / kubo / commits / f085d594a

vendoring ipns things

Juan Batiz-Benet committed Oct 1, 2014 at 00:44 UTC f085d594aab6d1e416442821d99e5d2817ceb477
14 files changed +152 -19
Godeps/Godeps.json
+4
@@ -38,6 +38,10 @@
38 "Comment": "null-15",
39 "Rev": "12e4b4183793ac4b061921e7980845e750679fd0"
40 },
41 + {
42 + "ImportPath": "github.com/bren2010/proquint",
43 + "Rev": "5958552242606512f714d2e93513b380f43f9991"
44 + },
45 {
46 "ImportPath": "github.com/camlistore/lock",
47 "Rev": "ae27720f340952636b826119b58130b9c1a847a0"
Godeps/_workspace/src/github.com/bren2010/proquint/README.md new
+6
@@ -0,0 +1,6 @@
1 +Proquint
2 +-------
3 +
4 +Golang implementation of [Proquint Pronounceable Identifiers](https://github.com/deoxxa/proquint).
5 +
6 +
Godeps/_workspace/src/github.com/bren2010/proquint/proquint.go new
+123
@@ -0,0 +1,123 @@
1 +/*
2 +Copyright (c) 2014 Brendan McMillion
3 +
4 +Permission is hereby granted, free of charge, to any person obtaining a copy
5 +of this software and associated documentation files (the "Software"), to deal
6 +in the Software without restriction, including without limitation the rights
7 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 +copies of the Software, and to permit persons to whom the Software is
9 +furnished to do so, subject to the following conditions:
10 +
11 +The above copyright notice and this permission notice shall be included in
12 +all copies or substantial portions of the Software.
13 +
14 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 +THE SOFTWARE.
21 +*/
22 +
23 +package proquint
24 +
25 +import (
26 + "bytes"
27 + "strings"
28 + "regexp"
29 +)
30 +
31 +var (
32 + conse = [...]byte{'b', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n',
33 + 'p', 'r', 's', 't', 'v', 'z'}
34 + vowse = [...]byte{'a', 'i', 'o', 'u'}
35 +
36 + consd = map[byte] uint16 {
37 + 'b' : 0, 'd' : 1, 'f' : 2, 'g' : 3,
38 + 'h' : 4, 'j' : 5, 'k' : 6, 'l' : 7,
39 + 'm' : 8, 'n' : 9, 'p' : 10, 'r' : 11,
40 + 's' : 12, 't' : 13, 'v' : 14, 'z' : 15,
41 + }
42 +
43 + vowsd = map[byte] uint16 {
44 + 'a' : 0, 'i' : 1, 'o' : 2, 'u' : 3,
45 + }
46 +)
47 +
48 +/**
49 +* Tests if a given string is a Proquint identifier
50 +*
51 +* @param {string} str The candidate string.
52 +*
53 +* @return {bool} Whether or not it qualifies.
54 +* @return {error} Error
55 +*/
56 +func IsProquint(str string) (bool, error) {
57 + exp := "^([abdfghijklmnoprstuvz]{5}-)*[abdfghijklmnoprstuvz]{5}$"
58 + ok, err := regexp.MatchString(exp, str)
59 +
60 + return ok, err
61 +}
62 +
63 +/**
64 +* Encodes an arbitrary byte slice into an identifier.
65 +*
66 +* @param {[]byte} buf Slice of bytes to encode.
67 +*
68 +* @return {string} The given byte slice as an identifier.
69 +*/
70 +func Encode(buf []byte) string {
71 + var out bytes.Buffer
72 +
73 + for i := 0; i < len(buf); i = i + 2 {
74 + var n uint16 = (uint16(buf[i]) * 256) + uint16(buf[i + 1])
75 +
76 + var (
77 + c1 = n & 0x0f
78 + v1 = (n >> 4) & 0x03
79 + c2 = (n >> 6) & 0x0f
80 + v2 = (n >> 10) & 0x03
81 + c3 = (n >> 12) & 0x0f
82 + )
83 +
84 + out.WriteByte(conse[c1])
85 + out.WriteByte(vowse[v1])
86 + out.WriteByte(conse[c2])
87 + out.WriteByte(vowse[v2])
88 + out.WriteByte(conse[c3])
89 +
90 + if (i + 2) < len(buf) {
91 + out.WriteByte('-')
92 + }
93 + }
94 +
95 + return out.String()
96 +}
97 +
98 +/**
99 +* Decodes an identifier into its corresponding byte slice.
100 +*
101 +* @param {string} str Identifier to convert.
102 +*
103 +* @return {[]byte} The identifier as a byte slice.
104 +*/
105 +func Decode(str string) []byte {
106 + var (
107 + out bytes.Buffer
108 + bits []string = strings.Split(str, "-")
109 + )
110 +
111 + for i := 0; i < len(bits); i++ {
112 + var x uint16 = consd[bits[i][0]] +
113 + (vowsd[bits[i][1]] << 4) +
114 + (consd[bits[i][2]] << 6) +
115 + (vowsd[bits[i][3]] << 10) +
116 + (consd[bits[i][4]] << 12)
117 +
118 + out.WriteByte(byte(x >> 8))
119 + out.WriteByte(byte(x))
120 + }
121 +
122 + return out.Bytes()
123 +}
blockservice/blockservice.go
+1 -1
@@ -7,7 +7,7 @@ import (
7 context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
8 ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
9 mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
10 - "github.com/op/go-logging"
10 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
11
12 blocks "github.com/jbenet/go-ipfs/blocks"
13 exchange "github.com/jbenet/go-ipfs/exchange"
core/commands/publish.go
+1 -1
@@ -7,7 +7,7 @@ import (
7
8 "github.com/jbenet/go-ipfs/core"
9 u "github.com/jbenet/go-ipfs/util"
10 - "github.com/op/go-logging"
10 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
11
12 nsys "github.com/jbenet/go-ipfs/namesys"
13 )
fuse/ipns/ipns_unix.go
+4 -4
@@ -13,15 +13,15 @@ import (
13
14 "bytes"
15
16 - "bazil.org/fuse"
17 - "bazil.org/fuse/fs"
18 - "code.google.com/p/goprotobuf/proto"
16 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse"
17 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs"
18 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
19 "github.com/jbenet/go-ipfs/core"
20 ci "github.com/jbenet/go-ipfs/crypto"
21 imp "github.com/jbenet/go-ipfs/importer"
22 mdag "github.com/jbenet/go-ipfs/merkledag"
23 u "github.com/jbenet/go-ipfs/util"
24 - "github.com/op/go-logging"
24 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
25 )
26
27 var log = logging.MustGetLogger("ipns")
fuse/readonly/readonly_unix.go
+2 -2
@@ -14,14 +14,14 @@ import (
14 "syscall"
15 "time"
16
17 - "code.google.com/p/goprotobuf/proto"
17 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
18
19 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse"
20 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs"
21 core "github.com/jbenet/go-ipfs/core"
22 mdag "github.com/jbenet/go-ipfs/merkledag"
23 u "github.com/jbenet/go-ipfs/util"
24 - "github.com/op/go-logging"
24 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
25 )
26
27 var log = logging.MustGetLogger("ipfs")
namesys/entry.pb.go
+1 -1
@@ -13,7 +13,7 @@ It has these top-level messages:
13 */
14 package namesys
15
16 -import proto "code.google.com/p/goprotobuf/proto"
16 +import proto "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
17 import math "math"
18
19 // Reference imports to suppress errors if they are not otherwise used.
namesys/proquint.go
+1 -1
@@ -3,7 +3,7 @@ package namesys
3 import (
4 "errors"
5
6 - proquint "github.com/bren2010/proquint"
6 + proquint "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/bren2010/proquint"
7 )
8
9 type ProquintResolver struct{}
namesys/publisher.go
+2 -2
@@ -3,8 +3,8 @@ package namesys
3 import (
4 "time"
5
6 - "code.google.com/p/go.net/context"
7 - "code.google.com/p/goprotobuf/proto"
6 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
7 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
8
9 ci "github.com/jbenet/go-ipfs/crypto"
10 mdag "github.com/jbenet/go-ipfs/merkledag"
namesys/routing.go
+4 -4
@@ -3,15 +3,15 @@ package namesys
3 import (
4 "fmt"
5
6 - "code.google.com/p/go.net/context"
7 - "code.google.com/p/goprotobuf/proto"
6 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
7 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
8
9 ci "github.com/jbenet/go-ipfs/crypto"
10 mdag "github.com/jbenet/go-ipfs/merkledag"
11 "github.com/jbenet/go-ipfs/routing"
12 u "github.com/jbenet/go-ipfs/util"
13 - mh "github.com/jbenet/go-multihash"
14 - "github.com/op/go-logging"
13 + mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
14 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
15 )
16
17 var log = logging.MustGetLogger("namesys")
path/path.go
+1 -1
@@ -8,7 +8,7 @@ import (
8 mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
9 merkledag "github.com/jbenet/go-ipfs/merkledag"
10 u "github.com/jbenet/go-ipfs/util"
11 - "github.com/op/go-logging"
11 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
12 )
13
14 var log = logging.MustGetLogger("path")
routing/dht/dht.go
+1 -1
@@ -13,7 +13,7 @@ import (
13 peer "github.com/jbenet/go-ipfs/peer"
14 kb "github.com/jbenet/go-ipfs/routing/kbucket"
15 u "github.com/jbenet/go-ipfs/util"
16 - "github.com/op/go-logging"
16 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
17
18 context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
19 ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
util/util.go
+1 -1
@@ -11,7 +11,7 @@ import (
11 ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
12 b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
13 mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
14 - "github.com/op/go-logging"
14 + "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/op/go-logging"
15 )
16
17 var format = "%{color}%{time:01-02 15:04:05.9999} %{shortfile} %{level}: %{color:reset}%{message}"