@cryptotaxi247 / kubo / commits / e79e1d31e

remove a ton of unused godeps

License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>

Jeromy committed Apr 13, 2016 at 11:04 UTC e79e1d31e9e0f318542746e81b9509673c20e433
463 files changed +5 -50680
Godeps/Readme deleted
-5
@@ -1,5 +0,0 @@
1 -This directory tree is generated automatically by godep.
2 -
3 -Please do not edit.
4 -
5 -See https://github.com/tools/godep for more information.
Godeps/_workspace/.gitignore deleted
-2
@@ -1,2 +0,0 @@
1 -/pkg
2 -/bin
Godeps/_workspace/src/bitbucket.org/ww/goautoneg/Makefile deleted
-13
@@ -1,13 +0,0 @@
1 -include $(GOROOT)/src/Make.inc
2 -
3 -TARG=bitbucket.org/ww/goautoneg
4 -GOFILES=autoneg.go
5 -
6 -include $(GOROOT)/src/Make.pkg
7 -
8 -format:
9 - gofmt -w *.go
10 -
11 -docs:
12 - gomake clean
13 - godoc ${TARG} > README.txt
Godeps/_workspace/src/bitbucket.org/ww/goautoneg/README.txt deleted
-67
@@ -1,67 +0,0 @@
1 -PACKAGE
2 -
3 -package goautoneg
4 -import "bitbucket.org/ww/goautoneg"
5 -
6 -HTTP Content-Type Autonegotiation.
7 -
8 -The functions in this package implement the behaviour specified in
9 -http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
10 -
11 -Copyright (c) 2011, Open Knowledge Foundation Ltd.
12 -All rights reserved.
13 -
14 -Redistribution and use in source and binary forms, with or without
15 -modification, are permitted provided that the following conditions are
16 -met:
17 -
18 - Redistributions of source code must retain the above copyright
19 - notice, this list of conditions and the following disclaimer.
20 -
21 - Redistributions in binary form must reproduce the above copyright
22 - notice, this list of conditions and the following disclaimer in
23 - the documentation and/or other materials provided with the
24 - distribution.
25 -
26 - Neither the name of the Open Knowledge Foundation Ltd. nor the
27 - names of its contributors may be used to endorse or promote
28 - products derived from this software without specific prior written
29 - permission.
30 -
31 -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36 -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38 -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39 -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41 -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 -
43 -
44 -FUNCTIONS
45 -
46 -func Negotiate(header string, alternatives []string) (content_type string)
47 -Negotiate the most appropriate content_type given the accept header
48 -and a list of alternatives.
49 -
50 -func ParseAccept(header string) (accept []Accept)
51 -Parse an Accept Header string returning a sorted list
52 -of clauses
53 -
54 -
55 -TYPES
56 -
57 -type Accept struct {
58 - Type, SubType string
59 - Q float32
60 - Params map[string]string
61 -}
62 -Structure to represent a clause in an HTTP Accept Header
63 -
64 -
65 -SUBDIRECTORIES
66 -
67 - .hg
Godeps/_workspace/src/bitbucket.org/ww/goautoneg/autoneg.go deleted
-162
@@ -1,162 +0,0 @@
1 -/*
2 -HTTP Content-Type Autonegotiation.
3 -
4 -The functions in this package implement the behaviour specified in
5 -http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
6 -
7 -Copyright (c) 2011, Open Knowledge Foundation Ltd.
8 -All rights reserved.
9 -
10 -Redistribution and use in source and binary forms, with or without
11 -modification, are permitted provided that the following conditions are
12 -met:
13 -
14 - Redistributions of source code must retain the above copyright
15 - notice, this list of conditions and the following disclaimer.
16 -
17 - Redistributions in binary form must reproduce the above copyright
18 - notice, this list of conditions and the following disclaimer in
19 - the documentation and/or other materials provided with the
20 - distribution.
21 -
22 - Neither the name of the Open Knowledge Foundation Ltd. nor the
23 - names of its contributors may be used to endorse or promote
24 - products derived from this software without specific prior written
25 - permission.
26 -
27 -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 -
39 -
40 -*/
41 -package goautoneg
42 -
43 -import (
44 - "sort"
45 - "strconv"
46 - "strings"
47 -)
48 -
49 -// Structure to represent a clause in an HTTP Accept Header
50 -type Accept struct {
51 - Type, SubType string
52 - Q float64
53 - Params map[string]string
54 -}
55 -
56 -// For internal use, so that we can use the sort interface
57 -type accept_slice []Accept
58 -
59 -func (accept accept_slice) Len() int {
60 - slice := []Accept(accept)
61 - return len(slice)
62 -}
63 -
64 -func (accept accept_slice) Less(i, j int) bool {
65 - slice := []Accept(accept)
66 - ai, aj := slice[i], slice[j]
67 - if ai.Q > aj.Q {
68 - return true
69 - }
70 - if ai.Type != "*" && aj.Type == "*" {
71 - return true
72 - }
73 - if ai.SubType != "*" && aj.SubType == "*" {
74 - return true
75 - }
76 - return false
77 -}
78 -
79 -func (accept accept_slice) Swap(i, j int) {
80 - slice := []Accept(accept)
81 - slice[i], slice[j] = slice[j], slice[i]
82 -}
83 -
84 -// Parse an Accept Header string returning a sorted list
85 -// of clauses
86 -func ParseAccept(header string) (accept []Accept) {
87 - parts := strings.Split(header, ",")
88 - accept = make([]Accept, 0, len(parts))
89 - for _, part := range parts {
90 - part := strings.Trim(part, " ")
91 -
92 - a := Accept{}
93 - a.Params = make(map[string]string)
94 - a.Q = 1.0
95 -
96 - mrp := strings.Split(part, ";")
97 -
98 - media_range := mrp[0]
99 - sp := strings.Split(media_range, "/")
100 - a.Type = strings.Trim(sp[0], " ")
101 -
102 - switch {
103 - case len(sp) == 1 && a.Type == "*":
104 - a.SubType = "*"
105 - case len(sp) == 2:
106 - a.SubType = strings.Trim(sp[1], " ")
107 - default:
108 - continue
109 - }
110 -
111 - if len(mrp) == 1 {
112 - accept = append(accept, a)
113 - continue
114 - }
115 -
116 - for _, param := range mrp[1:] {
117 - sp := strings.SplitN(param, "=", 2)
118 - if len(sp) != 2 {
119 - continue
120 - }
121 - token := strings.Trim(sp[0], " ")
122 - if token == "q" {
123 - a.Q, _ = strconv.ParseFloat(sp[1], 32)
124 - } else {
125 - a.Params[token] = strings.Trim(sp[1], " ")
126 - }
127 - }
128 -
129 - accept = append(accept, a)
130 - }
131 -
132 - slice := accept_slice(accept)
133 - sort.Sort(slice)
134 -
135 - return
136 -}
137 -
138 -// Negotiate the most appropriate content_type given the accept header
139 -// and a list of alternatives.
140 -func Negotiate(header string, alternatives []string) (content_type string) {
141 - asp := make([][]string, 0, len(alternatives))
142 - for _, ctype := range alternatives {
143 - asp = append(asp, strings.SplitN(ctype, "/", 2))
144 - }
145 - for _, clause := range ParseAccept(header) {
146 - for i, ctsp := range asp {
147 - if clause.Type == ctsp[0] && clause.SubType == ctsp[1] {
148 - content_type = alternatives[i]
149 - return
150 - }
151 - if clause.Type == ctsp[0] && clause.SubType == "*" {
152 - content_type = alternatives[i]
153 - return
154 - }
155 - if clause.Type == "*" && clause.SubType == "*" {
156 - content_type = alternatives[i]
157 - return
158 - }
159 - }
160 - }
161 - return
162 -}
Godeps/_workspace/src/bitbucket.org/ww/goautoneg/autoneg_test.go deleted
-33
@@ -1,33 +0,0 @@
1 -package goautoneg
2 -
3 -import (
4 - "testing"
5 -)
6 -
7 -var chrome = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
8 -
9 -func TestParseAccept(t *testing.T) {
10 - alternatives := []string{"text/html", "image/png"}
11 - content_type := Negotiate(chrome, alternatives)
12 - if content_type != "image/png" {
13 - t.Errorf("got %s expected image/png", content_type)
14 - }
15 -
16 - alternatives = []string{"text/html", "text/plain", "text/n3"}
17 - content_type = Negotiate(chrome, alternatives)
18 - if content_type != "text/html" {
19 - t.Errorf("got %s expected text/html", content_type)
20 - }
21 -
22 - alternatives = []string{"text/n3", "text/plain"}
23 - content_type = Negotiate(chrome, alternatives)
24 - if content_type != "text/plain" {
25 - t.Errorf("got %s expected text/plain", content_type)
26 - }
27 -
28 - alternatives = []string{"text/n3", "application/rdf+xml"}
29 - content_type = Negotiate(chrome, alternatives)
30 - if content_type != "text/n3" {
31 - t.Errorf("got %s expected text/n3", content_type)
32 - }
33 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/.travis.yml deleted
-4
@@ -1,4 +0,0 @@
1 -sudo: false
2 -language: go
3 -install: go get -t -v ./...
4 -go: 1.2
Godeps/_workspace/src/github.com/alecthomas/kingpin/COPYING deleted
-19
@@ -1,19 +0,0 @@
1 -Copyright (C) 2014 Alec Thomas
2 -
3 -Permission is hereby granted, free of charge, to any person obtaining a copy of
4 -this software and associated documentation files (the "Software"), to deal in
5 -the Software without restriction, including without limitation the rights to
6 -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 -of the Software, and to permit persons to whom the Software is furnished to do
8 -so, subject to the following conditions:
9 -
10 -The above copyright notice and this permission notice shall be included in all
11 -copies or substantial portions of the Software.
12 -
13 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 -SOFTWARE.
Godeps/_workspace/src/github.com/alecthomas/kingpin/README.md deleted
-555
@@ -1,555 +0,0 @@
1 -# Kingpin - A Go (golang) command line and flag parser [![Build Status](https://travis-ci.org/alecthomas/kingpin.png)](https://travis-ci.org/alecthomas/kingpin)
2 -
3 -<!-- MarkdownTOC -->
4 -
5 -- [Overview](#overview)
6 -- [Features](#features)
7 -- [User-visible changes between v1 and v2](#user-visible-changes-between-v1-and-v2)
8 - - [Flags can be used at any point after their definition.](#flags-can-be-used-at-any-point-after-their-definition)
9 - - [Short flags can be combined with their parameters](#short-flags-can-be-combined-with-their-parameters)
10 -- [API changes between v1 and v2](#api-changes-between-v1-and-v2)
11 -- [Versions](#versions)
12 - - [V2 is the current stable version](#v2-is-the-current-stable-version)
13 - - [V1 is the OLD stable version](#v1-is-the-old-stable-version)
14 -- [Change History](#change-history)
15 -- [Examples](#examples)
16 - - [Simple Example](#simple-example)
17 - - [Complex Example](#complex-example)
18 -- [Reference Documentation](#reference-documentation)
19 - - [Displaying errors and usage information](#displaying-errors-and-usage-information)
20 - - [Sub-commands](#sub-commands)
21 - - [Custom Parsers](#custom-parsers)
22 - - [Default Values](#default-values)
23 - - [Place-holders in Help](#place-holders-in-help)
24 - - [Consuming all remaining arguments](#consuming-all-remaining-arguments)
25 - - [Custom help](#custom-help)
26 -
27 -<!-- /MarkdownTOC -->
28 -
29 -## Overview
30 -
31 -Kingpin is a [fluent-style](http://en.wikipedia.org/wiki/Fluent_interface),
32 -type-safe command-line parser. It supports flags, nested commands, and
33 -positional arguments.
34 -
35 -Install it with:
36 -
37 - $ go get gopkg.in/alecthomas/kingpin.v2
38 -
39 -It looks like this:
40 -
41 -```go
42 -var (
43 - verbose = kingpin.Flag("verbose", "Verbose mode.").Short('v').Bool()
44 - name = kingpin.Arg("name", "Name of user.").Required().String()
45 -)
46 -
47 -func main() {
48 - kingpin.Parse()
49 - fmt.Printf("%v, %s\n", *verbose, *name)
50 -}
51 -```
52 -
53 -More [examples](https://github.com/alecthomas/kingpin/tree/master/examples) are available.
54 -
55 -Second to parsing, providing the user with useful help is probably the most
56 -important thing a command-line parser does. Kingpin tries to provide detailed
57 -contextual help if `--help` is encountered at any point in the command line
58 -(excluding after `--`).
59 -
60 -## Features
61 -
62 -- Help output that isn't as ugly as sin.
63 -- Fully [customisable help](#custom-help), via Go templates.
64 -- Parsed, type-safe flags (`kingpin.Flag("f", "help").Int()`)
65 -- Parsed, type-safe positional arguments (`kingpin.Arg("a", "help").Int()`).
66 -- Parsed, type-safe, arbitrarily deep commands (`kingpin.Command("c", "help")`).
67 -- Support for required flags and required positional arguments (`kingpin.Flag("f", "").Required().Int()`).
68 -- Support for arbitrarily nested default commands (`command.Default()`).
69 -- Callbacks per command, flag and argument (`kingpin.Command("c", "").Action(myAction)`).
70 -- POSIX-style short flag combining (`-a -b` -> `-ab`).
71 -- Short-flag+parameter combining (`-a parm` -> `-aparm`).
72 -- Read command-line from files (`@<file>`).
73 -- Automatically generate man pages (`--man-page`).
74 -
75 -## User-visible changes between v1 and v2
76 -
77 -### Flags can be used at any point after their definition.
78 -
79 -Flags can be specified at any point after their definition, not just
80 -*immediately after their associated command*. From the chat example below, the
81 -following used to be required:
82 -
83 -```
84 -$ chat --server=chat.server.com:8080 post --image=~/Downloads/owls.jpg pics
85 -```
86 -
87 -But the following will now work:
88 -
89 -```
90 -$ chat post --server=chat.server.com:8080 --image=~/Downloads/owls.jpg pics
91 -```
92 -
93 -### Short flags can be combined with their parameters
94 -
95 -Previously, if a short flag was used, any argument to that flag would have to
96 -be separated by a space. That is no longer the case.
97 -
98 -## API changes between v1 and v2
99 -
100 -- `ParseWithFileExpansion()` is gone. The new parser directly supports expanding `@<file>`.
101 -- Added `FatalUsage()` and `FatalUsageContext()` for displaying an error + usage and terminating.
102 -- `Dispatch()` renamed to `Action()`.
103 -- Added `ParseContext()` for parsing a command line into its intermediate context form without executing.
104 -- Added `Terminate()` function to override the termination function.
105 -- Added `UsageForContextWithTemplate()` for printing usage via a custom template.
106 -- Added `UsageTemplate()` for overriding the default template to use. Two templates are included:
107 - 1. `DefaultUsageTemplate` - default template.
108 - 2. `CompactUsageTemplate` - compact command template for larger applications.
109 -
110 -## Versions
111 -
112 -Kingpin uses [gopkg.in](https://gopkg.in/alecthomas/kingpin) for versioning.
113 -
114 -The current stable version is [gopkg.in/alecthomas/kingpin.v2](https://gopkg.in/alecthomas/kingpin.v2). The previous version, [gopkg.in/alecthomas/kingpin.v1](https://gopkg.in/alecthomas/kingpin.v1), is deprecated and in maintenance mode.
115 -
116 -### [V2](https://gopkg.in/alecthomas/kingpin.v2) is the current stable version
117 -
118 -Installation:
119 -
120 -```sh
121 -$ go get gopkg.in/alecthomas/kingpin.v2
122 -```
123 -
124 -### [V1](https://gopkg.in/alecthomas/kingpin.v1) is the OLD stable version
125 -
126 -Installation:
127 -
128 -```sh
129 -$ go get gopkg.in/alecthomas/kingpin.v1
130 -```
131 -
132 -## Change History
133 -
134 -- *2015-09-19* -- Stable v2.1.0 release.
135 - - Added `command.Default()` to specify a default command to use if no other
136 - command matches. This allows for convenient user shortcuts.
137 - - Exposed `HelpFlag` and `VersionFlag` for further cusomisation.
138 - - `Action()` and `PreAction()` added and both now support an arbitrary
139 - number of callbacks.
140 - - `kingpin.SeparateOptionalFlagsUsageTemplate`.
141 - - `--help-long` and `--help-man` (hidden by default) flags.
142 - - Flags are "interspersed" by default, but can be disabled with `app.Interspersed(false)`.
143 - - Added flags for all simple builtin types (int8, uint16, etc.) and slice variants.
144 - - Use `app.Writer(os.Writer)` to specify the default writer for all output functions.
145 - - Dropped `os.Writer` prefix from all printf-like functions.
146 -
147 -- *2015-05-22* -- Stable v2.0.0 release.
148 - - Initial stable release of v2.0.0.
149 - - Fully supports interspersed flags, commands and arguments.
150 - - Flags can be present at any point after their logical definition.
151 - - Application.Parse() terminates if commands are present and a command is not parsed.
152 - - Dispatch() -> Action().
153 - - Actions are dispatched after all values are populated.
154 - - Override termination function (defaults to os.Exit).
155 - - Override output stream (defaults to os.Stderr).
156 - - Templatised usage help, with default and compact templates.
157 - - Make error/usage functions more consistent.
158 - - Support argument expansion from files by default (with @<file>).
159 - - Fully public data model is available via .Model().
160 - - Parser has been completely refactored.
161 - - Parsing and execution has been split into distinct stages.
162 - - Use `go generate` to generate repeated flags.
163 - - Support combined short-flag+argument: -fARG.
164 -
165 -- *2015-01-23* -- Stable v1.3.4 release.
166 - - Support "--" for separating flags from positional arguments.
167 - - Support loading flags from files (ParseWithFileExpansion()). Use @FILE as an argument.
168 - - Add post-app and post-cmd validation hooks. This allows arbitrary validation to be added.
169 - - A bunch of improvements to help usage and formatting.
170 - - Support arbitrarily nested sub-commands.
171 -
172 -- *2014-07-08* -- Stable v1.2.0 release.
173 - - Pass any value through to `Strings()` when final argument.
174 - Allows for values that look like flags to be processed.
175 - - Allow `--help` to be used with commands.
176 - - Support `Hidden()` flags.
177 - - Parser for [units.Base2Bytes](https://github.com/alecthomas/units)
178 - type. Allows for flags like `--ram=512MB` or `--ram=1GB`.
179 - - Add an `Enum()` value, allowing only one of a set of values
180 - to be selected. eg. `Flag(...).Enum("debug", "info", "warning")`.
181 -
182 -- *2014-06-27* -- Stable v1.1.0 release.
183 - - Bug fixes.
184 - - Always return an error (rather than panicing) when misconfigured.
185 - - `OpenFile(flag, perm)` value type added, for finer control over opening files.
186 - - Significantly improved usage formatting.
187 -
188 -- *2014-06-19* -- Stable v1.0.0 release.
189 - - Support [cumulative positional](#consuming-all-remaining-arguments) arguments.
190 - - Return error rather than panic when there are fatal errors not caught by
191 - the type system. eg. when a default value is invalid.
192 - - Use gokpg.in.
193 -
194 -- *2014-06-10* -- Place-holder streamlining.
195 - - Renamed `MetaVar` to `PlaceHolder`.
196 - - Removed `MetaVarFromDefault`. Kingpin now uses [heuristics](#place-holders-in-help)
197 - to determine what to display.
198 -
199 -## Examples
200 -
201 -### Simple Example
202 -
203 -Kingpin can be used for simple flag+arg applications like so:
204 -
205 -```
206 -$ ping --help
207 -usage: ping [<flags>] <ip> [<count>]
208 -
209 -Flags:
210 - --debug Enable debug mode.
211 - --help Show help.
212 - -t, --timeout=5s Timeout waiting for ping.
213 -
214 -Args:
215 - <ip> IP address to ping.
216 - [<count>] Number of packets to send
217 -$ ping 1.2.3.4 5
218 -Would ping: 1.2.3.4 with timeout 5s and count 0
219 -```
220 -
221 -From the following source:
222 -
223 -```go
224 -package main
225 -
226 -import (
227 - "fmt"
228 -
229 - "gopkg.in/alecthomas/kingpin.v2"
230 -)
231 -
232 -var (
233 - debug = kingpin.Flag("debug", "Enable debug mode.").Bool()
234 - timeout = kingpin.Flag("timeout", "Timeout waiting for ping.").Default("5s").OverrideDefaultFromEnvar("PING_TIMEOUT").Short('t').Duration()
235 - ip = kingpin.Arg("ip", "IP address to ping.").Required().IP()
236 - count = kingpin.Arg("count", "Number of packets to send").Int()
237 -)
238 -
239 -func main() {
240 - kingpin.Version("0.0.1")
241 - kingpin.Parse()
242 - fmt.Printf("Would ping: %s with timeout %s and count %d", *ip, *timeout, *count)
243 -}
244 -```
245 -
246 -### Complex Example
247 -
248 -Kingpin can also produce complex command-line applications with global flags,
249 -subcommands, and per-subcommand flags, like this:
250 -
251 -```
252 -$ chat --help
253 -usage: chat [<flags>] <command> [<flags>] [<args> ...]
254 -
255 -A command-line chat application.
256 -
257 -Flags:
258 - --help Show help.
259 - --debug Enable debug mode.
260 - --server=127.0.0.1 Server address.
261 -
262 -Commands:
263 - help [<command>]
264 - Show help for a command.
265 -
266 - register <nick> <name>
267 - Register a new user.
268 -
269 - post [<flags>] <channel> [<text>]
270 - Post a message to a channel.
271 -
272 -$ chat help post
273 -usage: chat [<flags>] post [<flags>] <channel> [<text>]
274 -
275 -Post a message to a channel.
276 -
277 -Flags:
278 - --image=IMAGE Image to post.
279 -
280 -Args:
281 - <channel> Channel to post to.
282 - [<text>] Text to post.
283 -
284 -$ chat post --image=~/Downloads/owls.jpg pics
285 -...
286 -```
287 -
288 -From this code:
289 -
290 -```go
291 -package main
292 -
293 -import (
294 - "os"
295 - "strings"
296 - "gopkg.in/alecthomas/kingpin.v2"
297 -)
298 -
299 -var (
300 - app = kingpin.New("chat", "A command-line chat application.")
301 - debug = app.Flag("debug", "Enable debug mode.").Bool()
302 - serverIP = app.Flag("server", "Server address.").Default("127.0.0.1").IP()
303 -
304 - register = app.Command("register", "Register a new user.")
305 - registerNick = register.Arg("nick", "Nickname for user.").Required().String()
306 - registerName = register.Arg("name", "Name of user.").Required().String()
307 -
308 - post = app.Command("post", "Post a message to a channel.")
309 - postImage = post.Flag("image", "Image to post.").File()
310 - postChannel = post.Arg("channel", "Channel to post to.").Required().String()
311 - postText = post.Arg("text", "Text to post.").Strings()
312 -)
313 -
314 -func main() {
315 - switch kingpin.MustParse(app.Parse(os.Args[1:])) {
316 - // Register user
317 - case register.FullCommand():
318 - println(*registerNick)
319 -
320 - // Post message
321 - case post.FullCommand():
322 - if *postImage != nil {
323 - }
324 - text := strings.Join(*postText, " ")
325 - println("Post:", text)
326 - }
327 -}
328 -```
329 -
330 -## Reference Documentation
331 -
332 -### Displaying errors and usage information
333 -
334 -Kingpin exports a set of functions to provide consistent errors and usage
335 -information to the user.
336 -
337 -Error messages look something like this:
338 -
339 - <app>: error: <message>
340 -
341 -The functions on `Application` are:
342 -
343 -Function | Purpose
344 ----------|--------------
345 -`Errorf(format, args)` | Display a printf formatted error to the user.
346 -`Fatalf(format, args)` | As with Errorf, but also call the termination handler.
347 -`FatalUsage(format, args)` | As with Fatalf, but also print contextual usage information.
348 -`FatalUsageContext(context, format, args)` | As with Fatalf, but also print contextual usage information from a `ParseContext`.
349 -`FatalIfError(err, format, args)` | Conditionally print an error prefixed with format+args, then call the termination handler
350 -
351 -There are equivalent global functions in the kingpin namespace for the default
352 -`kingpin.CommandLine` instance.
353 -
354 -### Sub-commands
355 -
356 -Kingpin supports nested sub-commands, with separate flag and positional
357 -arguments per sub-command. Note that positional arguments may only occur after
358 -sub-commands.
359 -
360 -For example:
361 -
362 -```go
363 -var (
364 - deleteCommand = kingpin.Command("delete", "Delete an object.")
365 - deleteUserCommand = deleteCommand.Command("user", "Delete a user.")
366 - deleteUserUIDFlag = deleteUserCommand.Flag("uid", "Delete user by UID rather than username.")
367 - deleteUserUsername = deleteUserCommand.Arg("username", "Username to delete.")
368 - deletePostCommand = deleteCommand.Command("post", "Delete a post.")
369 -)
370 -
371 -func main() {
372 - switch kingpin.Parse() {
373 - case "delete user":
374 - case "delete post":
375 - }
376 -}
377 -```
378 -
379 -### Custom Parsers
380 -
381 -Kingpin supports both flag and positional argument parsers for converting to
382 -Go types. For example, some included parsers are `Int()`, `Float()`,
383 -`Duration()` and `ExistingFile()`.
384 -
385 -Parsers conform to Go's [`flag.Value`](http://godoc.org/flag#Value)
386 -interface, so any existing implementations will work.
387 -
388 -For example, a parser for accumulating HTTP header values might look like this:
389 -
390 -```go
391 -type HTTPHeaderValue http.Header
392 -
393 -func (h *HTTPHeaderValue) Set(value string) error {
394 - parts := strings.SplitN(value, ":", 2)
395 - if len(parts) != 2 {
396 - return fmt.Errorf("expected HEADER:VALUE got '%s'", value)
397 - }
398 - (*http.Header)(h).Add(parts[0], parts[1])
399 - return nil
400 -}
401 -
402 -func (h *HTTPHeaderValue) String() string {
403 - return ""
404 -}
405 -```
406 -
407 -As a convenience, I would recommend something like this:
408 -
409 -```go
410 -func HTTPHeader(s Settings) (target *http.Header) {
411 - target = new(http.Header)
412 - s.SetValue((*HTTPHeaderValue)(target))
413 - return
414 -}
415 -```
416 -
417 -You would use it like so:
418 -
419 -```go
420 -headers = HTTPHeader(kingpin.Flag("header", "Add a HTTP header to the request.").Short('H'))
421 -```
422 -
423 -### Default Values
424 -
425 -The default value is the zero value for a type. This can be overridden with
426 -the `Default(value)` function on flags and arguments. This function accepts a
427 -string, which is parsed by the value itself, so it *must* be compliant with
428 -the format expected.
429 -
430 -### Place-holders in Help
431 -
432 -The place-holder value for a flag is the value used in the help to describe
433 -the value of a non-boolean flag.
434 -
435 -The value provided to PlaceHolder() is used if provided, then the value
436 -provided by Default() if provided, then finally the capitalised flag name is
437 -used.
438 -
439 -Here are some examples of flags with various permutations:
440 -
441 - --name=NAME // Flag(...).String()
442 - --name="Harry" // Flag(...).Default("Harry").String()
443 - --name=FULL-NAME // flag(...).PlaceHolder("FULL-NAME").Default("Harry").String()
444 -
445 -### Consuming all remaining arguments
446 -
447 -A common command-line idiom is to use all remaining arguments for some
448 -purpose. eg. The following command accepts an arbitrary number of
449 -IP addresses as positional arguments:
450 -
451 - ./cmd ping 10.1.1.1 192.168.1.1
452 -
453 -Kingpin supports this by having `Value` provide a `IsCumulative() bool`
454 -function. If this function exists and returns true, the value parser will be
455 -called repeatedly for every remaining argument.
456 -
457 -Examples of this are the `Strings()` and `StringMap()` values.
458 -
459 -To implement the above example we might do something like this:
460 -
461 -```go
462 -type ipList []net.IP
463 -
464 -func (i *ipList) Set(value string) error {
465 - if ip := net.ParseIP(value); ip == nil {
466 - return fmt.Errorf("'%s' is not an IP address", value)
467 - } else {
468 - *i = append(*i, ip)
469 - return nil
470 - }
471 -}
472 -
473 -func (i *ipList) String() string {
474 - return ""
475 -}
476 -
477 -func (i *ipList) IsCumulative() bool {
478 - return true
479 -}
480 -
481 -func IPList(s Settings) (target *[]net.IP) {
482 - target = new([]net.IP)
483 - s.SetValue((*ipList)(target))
484 - return
485 -}
486 -```
487 -
488 -And use it like so:
489 -
490 -```go
491 -ips := IPList(kingpin.Arg("ips", "IP addresses to ping."))
492 -```
493 -
494 -### Custom help
495 -
496 -Kingpin v2 supports templatised help using the text/template library (actually, [a fork](https://github.com/alecthomas/template)).
497 -
498 -You can specify the template to use with the [Application.UsageTemplate()](http://godoc.org/gopkg.in/alecthomas/kingpin.v2#Application.UsageTemplate) function.
499 -
500 -There are four included templates: `kingpin.DefaultUsageTemplate` is the default,
501 -`kingpin.CompactUsageTemplate` provides a more compact representation for more complex command-line structures,
502 -`kingpin.SeparateOptionalFlagsUsageTemplate` looks like the default template, but splits required
503 -and optional command flags into separate lists, and `kingpin.ManPageTemplate` is used to generate man pages.
504 -
505 -See the above templates for examples of usage, and the the function [UsageForContextWithTemplate()](https://github.com/alecthomas/kingpin/blob/master/usage.go#L198) method for details on the context.
506 -
507 -#### Default help template
508 -
509 -```
510 -$ go run ./examples/curl/curl.go --help
511 -usage: curl [<flags>] <command> [<args> ...]
512 -
513 -An example implementation of curl.
514 -
515 -Flags:
516 - --help Show help.
517 - -t, --timeout=5s Set connection timeout.
518 - -H, --headers=HEADER=VALUE
519 - Add HTTP headers to the request.
520 -
521 -Commands:
522 - help [<command>...]
523 - Show help.
524 -
525 - get url <url>
526 - Retrieve a URL.
527 -
528 - get file <file>
529 - Retrieve a file.
530 -
531 - post [<flags>] <url>
532 - POST a resource.
533 -```
534 -
535 -#### Compact help template
536 -
537 -```
538 -$ go run ./examples/curl/curl.go --help
539 -usage: curl [<flags>] <command> [<args> ...]
540 -
541 -An example implementation of curl.
542 -
543 -Flags:
544 - --help Show help.
545 - -t, --timeout=5s Set connection timeout.
546 - -H, --headers=HEADER=VALUE
547 - Add HTTP headers to the request.
548 -
549 -Commands:
550 - help [<command>...]
551 - get [<flags>]
552 - url <url>
553 - file <file>
554 - post [<flags>] <url>
555 -```
Godeps/_workspace/src/github.com/alecthomas/kingpin/actions.go deleted
-42
@@ -1,42 +0,0 @@
1 -package kingpin
2 -
3 -// Action callback executed at various stages after all values are populated.
4 -// The application, commands, arguments and flags all have corresponding
5 -// actions.
6 -type Action func(*ParseContext) error
7 -
8 -type actionMixin struct {
9 - actions []Action
10 - preActions []Action
11 -}
12 -
13 -type actionApplier interface {
14 - applyActions(*ParseContext) error
15 - applyPreActions(*ParseContext) error
16 -}
17 -
18 -func (a *actionMixin) addAction(action Action) {
19 - a.actions = append(a.actions, action)
20 -}
21 -
22 -func (a *actionMixin) addPreAction(action Action) {
23 - a.preActions = append(a.preActions, action)
24 -}
25 -
26 -func (a *actionMixin) applyActions(context *ParseContext) error {
27 - for _, action := range a.actions {
28 - if err := action(context); err != nil {
29 - return err
30 - }
31 - }
32 - return nil
33 -}
34 -
35 -func (a *actionMixin) applyPreActions(context *ParseContext) error {
36 - for _, preAction := range a.preActions {
37 - if err := preAction(context); err != nil {
38 - return err
39 - }
40 - }
41 - return nil
42 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/app.go deleted
-544
@@ -1,544 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "fmt"
5 - "io"
6 - "os"
7 - "strings"
8 -)
9 -
10 -var (
11 - ErrCommandNotSpecified = fmt.Errorf("command not specified")
12 -)
13 -
14 -type ApplicationValidator func(*Application) error
15 -
16 -// An Application contains the definitions of flags, arguments and commands
17 -// for an application.
18 -type Application struct {
19 - *flagGroup
20 - *argGroup
21 - *cmdGroup
22 - actionMixin
23 - initialized bool
24 - Name string
25 - Help string
26 - author string
27 - version string
28 - writer io.Writer // Destination for usage and errors.
29 - usageTemplate string
30 - validator ApplicationValidator
31 - terminate func(status int) // See Terminate()
32 - noInterspersed bool // can flags be interspersed with args (or must they come first)
33 -}
34 -
35 -var (
36 - // Global help flag. Exposed for user customisation.
37 - HelpFlag *FlagClause
38 - // Top-level help command. Exposed for user customisation. May be nil.
39 - HelpCommand *CmdClause
40 - // Global version flag. Exposed for user customisation. May be nil.
41 - VersionFlag *FlagClause
42 -)
43 -
44 -// New creates a new Kingpin application instance.
45 -func New(name, help string) *Application {
46 - a := &Application{
47 - flagGroup: newFlagGroup(),
48 - argGroup: newArgGroup(),
49 - Name: name,
50 - Help: help,
51 - writer: os.Stderr,
52 - usageTemplate: DefaultUsageTemplate,
53 - terminate: os.Exit,
54 - }
55 - a.cmdGroup = newCmdGroup(a)
56 - HelpFlag = a.Flag("help", "Show context-sensitive help (also try --help-long and --help-man).")
57 - HelpFlag.Bool()
58 - a.Flag("help-long", "Generate long help.").Hidden().PreAction(a.generateLongHelp).Bool()
59 - a.Flag("help-man", "Generate a man page.").Hidden().PreAction(a.generateManPage).Bool()
60 - return a
61 -}
62 -
63 -func (a *Application) generateLongHelp(c *ParseContext) error {
64 - a.Writer(os.Stdout)
65 - if err := a.UsageForContextWithTemplate(c, 2, LongHelpTemplate); err != nil {
66 - return err
67 - }
68 - a.terminate(0)
69 - return nil
70 -}
71 -
72 -func (a *Application) generateManPage(c *ParseContext) error {
73 - a.Writer(os.Stdout)
74 - if err := a.UsageForContextWithTemplate(c, 2, ManPageTemplate); err != nil {
75 - return err
76 - }
77 - a.terminate(0)
78 - return nil
79 -}
80 -
81 -// Terminate specifies the termination handler. Defaults to os.Exit(status).
82 -// If nil is passed, a no-op function will be used.
83 -func (a *Application) Terminate(terminate func(int)) *Application {
84 - if terminate == nil {
85 - terminate = func(int) {}
86 - }
87 - a.terminate = terminate
88 - return a
89 -}
90 -
91 -// Specify the writer to use for usage and errors. Defaults to os.Stderr.
92 -func (a *Application) Writer(w io.Writer) *Application {
93 - a.writer = w
94 - return a
95 -}
96 -
97 -// UsageTemplate specifies the text template to use when displaying usage
98 -// information. The default is UsageTemplate.
99 -func (a *Application) UsageTemplate(template string) *Application {
100 - a.usageTemplate = template
101 - return a
102 -}
103 -
104 -// Validate sets a validation function to run when parsing.
105 -func (a *Application) Validate(validator ApplicationValidator) *Application {
106 - a.validator = validator
107 - return a
108 -}
109 -
110 -// ParseContext parses the given command line and returns the fully populated
111 -// ParseContext.
112 -func (a *Application) ParseContext(args []string) (*ParseContext, error) {
113 - if err := a.init(); err != nil {
114 - return nil, err
115 - }
116 - context := tokenize(args)
117 - err := parse(context, a)
118 - return context, err
119 -}
120 -
121 -// Parse parses command-line arguments. It returns the selected command and an
122 -// error. The selected command will be a space separated subcommand, if
123 -// subcommands have been configured.
124 -//
125 -// This will populate all flag and argument values, call all callbacks, and so
126 -// on.
127 -func (a *Application) Parse(args []string) (command string, err error) {
128 - context, err := a.ParseContext(args)
129 - if err != nil {
130 - if a.hasHelp(args) {
131 - a.writeUsage(context, err)
132 - }
133 - return "", err
134 - }
135 - a.maybeHelp(context)
136 - if !context.EOL() {
137 - return "", fmt.Errorf("unexpected argument '%s'", context.Peek())
138 - }
139 - command, err = a.execute(context)
140 - if err == ErrCommandNotSpecified {
141 - a.writeUsage(context, nil)
142 - }
143 - return command, err
144 -}
145 -
146 -func (a *Application) writeUsage(context *ParseContext, err error) {
147 - if err != nil {
148 - a.Errorf("%s", err)
149 - }
150 - if err := a.UsageForContext(context); err != nil {
151 - panic(err)
152 - }
153 - a.terminate(1)
154 -}
155 -
156 -func (a *Application) hasHelp(args []string) bool {
157 - for _, arg := range args {
158 - if arg == "--help" {
159 - return true
160 - }
161 - }
162 - return false
163 -}
164 -
165 -func (a *Application) maybeHelp(context *ParseContext) {
166 - for _, element := range context.Elements {
167 - if flag, ok := element.Clause.(*FlagClause); ok && flag == HelpFlag {
168 - a.writeUsage(context, nil)
169 - }
170 - }
171 -}
172 -
173 -// findCommandFromArgs finds a command (if any) from the given command line arguments.
174 -func (a *Application) findCommandFromArgs(args []string) (command string, err error) {
175 - if err := a.init(); err != nil {
176 - return "", err
177 - }
178 - context := tokenize(args)
179 - if _, err := a.parse(context); err != nil {
180 - return "", err
181 - }
182 - return a.findCommandFromContext(context), nil
183 -}
184 -
185 -// findCommandFromContext finds a command (if any) from a parsed context.
186 -func (a *Application) findCommandFromContext(context *ParseContext) string {
187 - commands := []string{}
188 - for _, element := range context.Elements {
189 - if c, ok := element.Clause.(*CmdClause); ok {
190 - commands = append(commands, c.name)
191 - }
192 - }
193 - return strings.Join(commands, " ")
194 -}
195 -
196 -// Version adds a --version flag for displaying the application version.
197 -func (a *Application) Version(version string) *Application {
198 - a.version = version
199 - VersionFlag = a.Flag("version", "Show application version.").PreAction(func(*ParseContext) error {
200 - fmt.Fprintln(a.writer, version)
201 - a.terminate(0)
202 - return nil
203 - })
204 - VersionFlag.Bool()
205 - return a
206 -}
207 -
208 -func (a *Application) Author(author string) *Application {
209 - a.author = author
210 - return a
211 -}
212 -
213 -// Action callback to call when all values are populated and parsing is
214 -// complete, but before any command, flag or argument actions.
215 -//
216 -// All Action() callbacks are called in the order they are encountered on the
217 -// command line.
218 -func (a *Application) Action(action Action) *Application {
219 - a.addAction(action)
220 - return a
221 -}
222 -
223 -// Action called after parsing completes but before validation and execution.
224 -func (a *Application) PreAction(action Action) *Application {
225 - a.addPreAction(action)
226 - return a
227 -}
228 -
229 -// Command adds a new top-level command.
230 -func (a *Application) Command(name, help string) *CmdClause {
231 - return a.addCommand(name, help)
232 -}
233 -
234 -// Interspersed control if flags can be interspersed with positional arguments
235 -//
236 -// true (the default) means that they can, false means that all the flags must appear before the first positional arguments.
237 -func (a *Application) Interspersed(interspersed bool) *Application {
238 - a.noInterspersed = !interspersed
239 - return a
240 -}
241 -
242 -func (a *Application) init() error {
243 - if a.initialized {
244 - return nil
245 - }
246 - if a.cmdGroup.have() && a.argGroup.have() {
247 - return fmt.Errorf("can't mix top-level Arg()s with Command()s")
248 - }
249 -
250 - // If we have subcommands, add a help command at the top-level.
251 - if a.cmdGroup.have() {
252 - var command []string
253 - HelpCommand = a.Command("help", "Show help.").Action(func(c *ParseContext) error {
254 - a.UsageForContext(c)
255 - a.terminate(0)
256 - return nil
257 - })
258 - HelpCommand.Arg("command", "Show help on command.").StringsVar(&command)
259 - // Make help first command.
260 - l := len(a.commandOrder)
261 - a.commandOrder = append(a.commandOrder[l-1:l], a.commandOrder[:l-1]...)
262 - }
263 -
264 - if err := a.flagGroup.init(); err != nil {
265 - return err
266 - }
267 - if err := a.cmdGroup.init(); err != nil {
268 - return err
269 - }
270 - if err := a.argGroup.init(); err != nil {
271 - return err
272 - }
273 - for _, cmd := range a.commands {
274 - if err := cmd.init(); err != nil {
275 - return err
276 - }
277 - }
278 - flagGroups := []*flagGroup{a.flagGroup}
279 - for _, cmd := range a.commandOrder {
280 - if err := checkDuplicateFlags(cmd, flagGroups); err != nil {
281 - return err
282 - }
283 - }
284 - a.initialized = true
285 - return nil
286 -}
287 -
288 -// Recursively check commands for duplicate flags.
289 -func checkDuplicateFlags(current *CmdClause, flagGroups []*flagGroup) error {
290 - // Check for duplicates.
291 - for _, flags := range flagGroups {
292 - for _, flag := range current.flagOrder {
293 - if flag.shorthand != 0 {
294 - if _, ok := flags.short[string(flag.shorthand)]; ok {
295 - return fmt.Errorf("duplicate short flag -%c", flag.shorthand)
296 - }
297 - }
298 - if _, ok := flags.long[flag.name]; ok {
299 - return fmt.Errorf("duplicate long flag --%s", flag.name)
300 - }
301 - }
302 - }
303 - flagGroups = append(flagGroups, current.flagGroup)
304 - // Check subcommands.
305 - for _, subcmd := range current.commandOrder {
306 - if err := checkDuplicateFlags(subcmd, flagGroups); err != nil {
307 - return err
308 - }
309 - }
310 - return nil
311 -}
312 -
313 -func (a *Application) execute(context *ParseContext) (string, error) {
314 - var err error
315 - selected := []string{}
316 -
317 - if err = a.setDefaults(context); err != nil {
318 - return "", err
319 - }
320 -
321 - selected, err = a.setValues(context)
322 - if err != nil {
323 - return "", err
324 - }
325 -
326 - if err = a.applyPreActions(context); err != nil {
327 - return "", err
328 - }
329 -
330 - if err = a.validateRequired(context); err != nil {
331 - return "", err
332 - }
333 -
334 - if err = a.applyValidators(context); err != nil {
335 - return "", err
336 - }
337 -
338 - if err = a.applyActions(context); err != nil {
339 - return "", err
340 - }
341 -
342 - command := strings.Join(selected, " ")
343 - if command == "" && a.cmdGroup.have() {
344 - return "", ErrCommandNotSpecified
345 - }
346 - return command, err
347 -}
348 -
349 -func (a *Application) setDefaults(context *ParseContext) error {
350 - flagElements := map[string]*ParseElement{}
351 - for _, element := range context.Elements {
352 - if flag, ok := element.Clause.(*FlagClause); ok {
353 - flagElements[flag.name] = element
354 - }
355 - }
356 -
357 - argElements := map[string]*ParseElement{}
358 - for _, element := range context.Elements {
359 - if arg, ok := element.Clause.(*ArgClause); ok {
360 - argElements[arg.name] = element
361 - }
362 - }
363 -
364 - // Check required flags and set defaults.
365 - for _, flag := range context.flags.long {
366 - if flagElements[flag.name] == nil {
367 - // Set defaults, if any.
368 - if flag.defaultValue != "" {
369 - if err := flag.value.Set(flag.defaultValue); err != nil {
370 - return err
371 - }
372 - }
373 - }
374 - }
375 -
376 - for _, arg := range context.arguments.args {
377 - if argElements[arg.name] == nil {
378 - // Set defaults, if any.
379 - if arg.defaultValue != "" {
380 - if err := arg.value.Set(arg.defaultValue); err != nil {
381 - return err
382 - }
383 - }
384 - }
385 - }
386 -
387 - return nil
388 -}
389 -
390 -func (a *Application) validateRequired(context *ParseContext) error {
391 - flagElements := map[string]*ParseElement{}
392 - for _, element := range context.Elements {
393 - if flag, ok := element.Clause.(*FlagClause); ok {
394 - flagElements[flag.name] = element
395 - }
396 - }
397 -
398 - argElements := map[string]*ParseElement{}
399 - for _, element := range context.Elements {
400 - if arg, ok := element.Clause.(*ArgClause); ok {
401 - argElements[arg.name] = element
402 - }
403 - }
404 -
405 - // Check required flags and set defaults.
406 - for _, flag := range context.flags.long {
407 - if flagElements[flag.name] == nil {
408 - // Check required flags were provided.
409 - if flag.needsValue() {
410 - return fmt.Errorf("required flag --%s not provided", flag.name)
411 - }
412 - }
413 - }
414 -
415 - for _, arg := range context.arguments.args {
416 - if argElements[arg.name] == nil {
417 - if arg.required {
418 - return fmt.Errorf("required argument '%s' not provided", arg.name)
419 - }
420 - }
421 - }
422 - return nil
423 -}
424 -
425 -func (a *Application) setValues(context *ParseContext) (selected []string, err error) {
426 - // Set all arg and flag values.
427 - var lastCmd *CmdClause
428 - for _, element := range context.Elements {
429 - switch clause := element.Clause.(type) {
430 - case *FlagClause:
431 - if err = clause.value.Set(*element.Value); err != nil {
432 - return
433 - }
434 -
435 - case *ArgClause:
436 - if err = clause.value.Set(*element.Value); err != nil {
437 - return
438 - }
439 -
440 - case *CmdClause:
441 - if clause.validator != nil {
442 - if err = clause.validator(clause); err != nil {
443 - return
444 - }
445 - }
446 - selected = append(selected, clause.name)
447 - lastCmd = clause
448 - }
449 - }
450 -
451 - if lastCmd != nil && len(lastCmd.commands) > 0 {
452 - return nil, fmt.Errorf("must select a subcommand of '%s'", lastCmd.FullCommand())
453 - }
454 -
455 - return
456 -}
457 -
458 -func (a *Application) applyValidators(context *ParseContext) (err error) {
459 - // Call command validation functions.
460 - for _, element := range context.Elements {
461 - if cmd, ok := element.Clause.(*CmdClause); ok && cmd.validator != nil {
462 - if err = cmd.validator(cmd); err != nil {
463 - return err
464 - }
465 - }
466 - }
467 -
468 - if a.validator != nil {
469 - err = a.validator(a)
470 - }
471 - return err
472 -}
473 -
474 -func (a *Application) applyPreActions(context *ParseContext) error {
475 - if err := a.actionMixin.applyPreActions(context); err != nil {
476 - return err
477 - }
478 - // Dispatch to actions.
479 - for _, element := range context.Elements {
480 - if applier, ok := element.Clause.(actionApplier); ok {
481 - if err := applier.applyPreActions(context); err != nil {
482 - return err
483 - }
484 - }
485 - }
486 - return nil
487 -}
488 -
489 -func (a *Application) applyActions(context *ParseContext) error {
490 - if err := a.actionMixin.applyActions(context); err != nil {
491 - return err
492 - }
493 - // Dispatch to actions.
494 - for _, element := range context.Elements {
495 - if applier, ok := element.Clause.(actionApplier); ok {
496 - if err := applier.applyActions(context); err != nil {
497 - return err
498 - }
499 - }
500 - }
501 - return nil
502 -}
503 -
504 -// Errorf prints an error message to w in the format "<appname>: error: <message>".
505 -func (a *Application) Errorf(format string, args ...interface{}) {
506 - fmt.Fprintf(a.writer, a.Name+": error: "+format+"\n", args...)
507 -}
508 -
509 -// Fatalf writes a formatted error to w then terminates with exit status 1.
510 -func (a *Application) Fatalf(format string, args ...interface{}) {
511 - a.Errorf(format, args...)
512 - a.terminate(1)
513 -}
514 -
515 -// FatalUsage prints an error message followed by usage information, then
516 -// exits with a non-zero status.
517 -func (a *Application) FatalUsage(format string, args ...interface{}) {
518 - a.Errorf(format, args...)
519 - a.Usage([]string{})
520 - a.terminate(1)
521 -}
522 -
523 -// FatalUsageContext writes a printf formatted error message to w, then usage
524 -// information for the given ParseContext, before exiting.
525 -func (a *Application) FatalUsageContext(context *ParseContext, format string, args ...interface{}) {
526 - a.Errorf(format, args...)
527 - if err := a.UsageForContext(context); err != nil {
528 - panic(err)
529 - }
530 - a.terminate(1)
531 -}
532 -
533 -// FatalIfError prints an error and exits if err is not nil. The error is printed
534 -// with the given formatted string, if any.
535 -func (a *Application) FatalIfError(err error, format string, args ...interface{}) {
536 - if err != nil {
537 - prefix := ""
538 - if format != "" {
539 - prefix = fmt.Sprintf(format, args...) + ": "
540 - }
541 - a.Errorf(prefix+"%s", err)
542 - a.terminate(1)
543 - }
544 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/app_test.go deleted
-197
@@ -1,197 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "io/ioutil"
5 -
6 - "gx/ipfs/QmZwjfAKWe7vWZ8f48u7AGA1xYfzR1iCD9A2XSCYFRBWot/testify/assert"
7 -
8 - "testing"
9 - "time"
10 -)
11 -
12 -func TestCommander(t *testing.T) {
13 - c := New("test", "test")
14 - ping := c.Command("ping", "Ping an IP address.")
15 - pingTTL := ping.Flag("ttl", "TTL for ICMP packets").Short('t').Default("5s").Duration()
16 -
17 - selected, err := c.Parse([]string{"ping"})
18 - assert.NoError(t, err)
19 - assert.Equal(t, "ping", selected)
20 - assert.Equal(t, 5*time.Second, *pingTTL)
21 -
22 - selected, err = c.Parse([]string{"ping", "--ttl=10s"})
23 - assert.NoError(t, err)
24 - assert.Equal(t, "ping", selected)
25 - assert.Equal(t, 10*time.Second, *pingTTL)
26 -}
27 -
28 -func TestRequiredFlags(t *testing.T) {
29 - c := New("test", "test")
30 - c.Flag("a", "a").String()
31 - c.Flag("b", "b").Required().String()
32 -
33 - _, err := c.Parse([]string{"--a=foo"})
34 - assert.Error(t, err)
35 - _, err = c.Parse([]string{"--b=foo"})
36 - assert.NoError(t, err)
37 -}
38 -
39 -func TestInvalidDefaultFlagValueErrors(t *testing.T) {
40 - c := New("test", "test")
41 - c.Flag("foo", "foo").Default("a").Int()
42 - _, err := c.Parse([]string{})
43 - assert.Error(t, err)
44 -}
45 -
46 -func TestInvalidDefaultArgValueErrors(t *testing.T) {
47 - c := New("test", "test")
48 - cmd := c.Command("cmd", "cmd")
49 - cmd.Arg("arg", "arg").Default("one").Int()
50 - _, err := c.Parse([]string{"cmd"})
51 - assert.Error(t, err)
52 -}
53 -
54 -func TestArgsRequiredAfterNonRequiredErrors(t *testing.T) {
55 - c := New("test", "test")
56 - cmd := c.Command("cmd", "")
57 - cmd.Arg("a", "a").String()
58 - cmd.Arg("b", "b").Required().String()
59 - _, err := c.Parse([]string{"cmd"})
60 - assert.Error(t, err)
61 -}
62 -
63 -func TestArgsMultipleRequiredThenNonRequired(t *testing.T) {
64 - c := New("test", "test").Terminate(nil).Writer(ioutil.Discard)
65 - cmd := c.Command("cmd", "")
66 - cmd.Arg("a", "a").Required().String()
67 - cmd.Arg("b", "b").Required().String()
68 - cmd.Arg("c", "c").String()
69 - cmd.Arg("d", "d").String()
70 - _, err := c.Parse([]string{"cmd", "a", "b"})
71 - assert.NoError(t, err)
72 - _, err = c.Parse([]string{})
73 - assert.Error(t, err)
74 -}
75 -
76 -func TestDispatchCallbackIsCalled(t *testing.T) {
77 - dispatched := false
78 - c := New("test", "")
79 - c.Command("cmd", "").Action(func(*ParseContext) error {
80 - dispatched = true
81 - return nil
82 - })
83 -
84 - _, err := c.Parse([]string{"cmd"})
85 - assert.NoError(t, err)
86 - assert.True(t, dispatched)
87 -}
88 -
89 -func TestTopLevelArgWorks(t *testing.T) {
90 - c := New("test", "test")
91 - s := c.Arg("arg", "help").String()
92 - _, err := c.Parse([]string{"foo"})
93 - assert.NoError(t, err)
94 - assert.Equal(t, "foo", *s)
95 -}
96 -
97 -func TestTopLevelArgCantBeUsedWithCommands(t *testing.T) {
98 - c := New("test", "test")
99 - c.Arg("arg", "help").String()
100 - c.Command("cmd", "help")
101 - _, err := c.Parse([]string{})
102 - assert.Error(t, err)
103 -}
104 -
105 -func TestTooManyArgs(t *testing.T) {
106 - a := New("test", "test")
107 - a.Arg("a", "").String()
108 - _, err := a.Parse([]string{"a", "b"})
109 - assert.Error(t, err)
110 -}
111 -
112 -func TestTooManyArgsAfterCommand(t *testing.T) {
113 - a := New("test", "test")
114 - a.Command("a", "")
115 - assert.NoError(t, a.init())
116 - _, err := a.Parse([]string{"a", "b"})
117 - assert.Error(t, err)
118 -}
119 -
120 -func TestArgsLooksLikeFlagsWithConsumeRemainder(t *testing.T) {
121 - a := New("test", "")
122 - a.Arg("opts", "").Required().Strings()
123 - _, err := a.Parse([]string{"hello", "-world"})
124 - assert.Error(t, err)
125 -}
126 -
127 -func TestCommandParseDoesNotResetFlagsToDefault(t *testing.T) {
128 - app := New("test", "")
129 - flag := app.Flag("flag", "").Default("default").String()
130 - app.Command("cmd", "")
131 -
132 - _, err := app.Parse([]string{"--flag=123", "cmd"})
133 - assert.NoError(t, err)
134 - assert.Equal(t, "123", *flag)
135 -}
136 -
137 -func TestCommandParseDoesNotFailRequired(t *testing.T) {
138 - app := New("test", "")
139 - flag := app.Flag("flag", "").Required().String()
140 - app.Command("cmd", "")
141 -
142 - _, err := app.Parse([]string{"cmd", "--flag=123"})
143 - assert.NoError(t, err)
144 - assert.Equal(t, "123", *flag)
145 -}
146 -
147 -func TestSelectedCommand(t *testing.T) {
148 - app := New("test", "help")
149 - c0 := app.Command("c0", "")
150 - c0.Command("c1", "")
151 - s, err := app.Parse([]string{"c0", "c1"})
152 - assert.NoError(t, err)
153 - assert.Equal(t, "c0 c1", s)
154 -}
155 -
156 -func TestSubCommandRequired(t *testing.T) {
157 - app := New("test", "help")
158 - c0 := app.Command("c0", "")
159 - c0.Command("c1", "")
160 - _, err := app.Parse([]string{"c0"})
161 - assert.Error(t, err)
162 -}
163 -
164 -func TestInterspersedFalse(t *testing.T) {
165 - app := New("test", "help").Interspersed(false)
166 - a1 := app.Arg("a1", "").String()
167 - a2 := app.Arg("a2", "").String()
168 - f1 := app.Flag("flag", "").String()
169 -
170 - _, err := app.Parse([]string{"a1", "--flag=flag"})
171 - assert.NoError(t, err)
172 - assert.Equal(t, "a1", *a1)
173 - assert.Equal(t, "--flag=flag", *a2)
174 - assert.Equal(t, "", *f1)
175 -}
176 -
177 -func TestInterspersedTrue(t *testing.T) {
178 - // test once with the default value and once with explicit true
179 - for i := 0; i < 2; i++ {
180 - app := New("test", "help")
181 - if i != 0 {
182 - t.Log("Setting explicit")
183 - app.Interspersed(true)
184 - } else {
185 - t.Log("Using default")
186 - }
187 - a1 := app.Arg("a1", "").String()
188 - a2 := app.Arg("a2", "").String()
189 - f1 := app.Flag("flag", "").String()
190 -
191 - _, err := app.Parse([]string{"a1", "--flag=flag"})
192 - assert.NoError(t, err)
193 - assert.Equal(t, "a1", *a1)
194 - assert.Equal(t, "", *a2)
195 - assert.Equal(t, "flag", *f1)
196 - }
197 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/args.go deleted
-105
@@ -1,105 +0,0 @@
1 -package kingpin
2 -
3 -import "fmt"
4 -
5 -type argGroup struct {
6 - args []*ArgClause
7 -}
8 -
9 -func newArgGroup() *argGroup {
10 - return &argGroup{}
11 -}
12 -
13 -func (a *argGroup) have() bool {
14 - return len(a.args) > 0
15 -}
16 -
17 -func (a *argGroup) Arg(name, help string) *ArgClause {
18 - arg := newArg(name, help)
19 - a.args = append(a.args, arg)
20 - return arg
21 -}
22 -
23 -func (a *argGroup) init() error {
24 - required := 0
25 - seen := map[string]struct{}{}
26 - previousArgMustBeLast := false
27 - for i, arg := range a.args {
28 - if previousArgMustBeLast {
29 - return fmt.Errorf("Args() can't be followed by another argument '%s'", arg.name)
30 - }
31 - if arg.consumesRemainder() {
32 - previousArgMustBeLast = true
33 - }
34 - if _, ok := seen[arg.name]; ok {
35 - return fmt.Errorf("duplicate argument '%s'", arg.name)
36 - }
37 - seen[arg.name] = struct{}{}
38 - if arg.required && required != i {
39 - return fmt.Errorf("required arguments found after non-required")
40 - }
41 - if arg.required {
42 - required++
43 - }
44 - if err := arg.init(); err != nil {
45 - return err
46 - }
47 - }
48 - return nil
49 -}
50 -
51 -type ArgClause struct {
52 - actionMixin
53 - parserMixin
54 - name string
55 - help string
56 - defaultValue string
57 - required bool
58 -}
59 -
60 -func newArg(name, help string) *ArgClause {
61 - a := &ArgClause{
62 - name: name,
63 - help: help,
64 - }
65 - return a
66 -}
67 -
68 -func (a *ArgClause) consumesRemainder() bool {
69 - if r, ok := a.value.(remainderArg); ok {
70 - return r.IsCumulative()
71 - }
72 - return false
73 -}
74 -
75 -// Required arguments must be input by the user. They can not have a Default() value provided.
76 -func (a *ArgClause) Required() *ArgClause {
77 - a.required = true
78 - return a
79 -}
80 -
81 -// Default value for this argument. It *must* be parseable by the value of the argument.
82 -func (a *ArgClause) Default(value string) *ArgClause {
83 - a.defaultValue = value
84 - return a
85 -}
86 -
87 -func (a *ArgClause) Action(action Action) *ArgClause {
88 - a.addAction(action)
89 - return a
90 -}
91 -
92 -func (a *ArgClause) PreAction(action Action) *ArgClause {
93 - a.addPreAction(action)
94 - return a
95 -}
96 -
97 -func (a *ArgClause) init() error {
98 - if a.required && a.defaultValue != "" {
99 - return fmt.Errorf("required argument '%s' with unusable default value", a.name)
100 - }
101 - if a.value == nil {
102 - return fmt.Errorf("no parser defined for arg '%s'", a.name)
103 - }
104 - return nil
105 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/args_test.go deleted
-49
@@ -1,49 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "io/ioutil"
5 - "testing"
6 -
7 - "gx/ipfs/QmZwjfAKWe7vWZ8f48u7AGA1xYfzR1iCD9A2XSCYFRBWot/testify/assert"
8 -)
9 -
10 -func TestArgRemainder(t *testing.T) {
11 - app := New("test", "")
12 - v := app.Arg("test", "").Strings()
13 - args := []string{"hello", "world"}
14 - _, err := app.Parse(args)
15 - assert.NoError(t, err)
16 - assert.Equal(t, args, *v)
17 -}
18 -
19 -func TestArgRemainderErrorsWhenNotLast(t *testing.T) {
20 - a := newArgGroup()
21 - a.Arg("test", "").Strings()
22 - a.Arg("test2", "").String()
23 - assert.Error(t, a.init())
24 -}
25 -
26 -func TestArgMultipleRequired(t *testing.T) {
27 - terminated := false
28 - app := New("test", "")
29 - app.Version("0.0.0").Writer(ioutil.Discard)
30 - app.Arg("a", "").Required().String()
31 - app.Arg("b", "").Required().String()
32 - app.Terminate(func(int) { terminated = true })
33 -
34 - _, err := app.Parse([]string{})
35 - assert.Error(t, err)
36 - _, err = app.Parse([]string{"A"})
37 - assert.Error(t, err)
38 - _, err = app.Parse([]string{"A", "B"})
39 - assert.NoError(t, err)
40 - _, err = app.Parse([]string{"--version"})
41 - assert.True(t, terminated)
42 -}
43 -
44 -func TestInvalidArgsDefaultCanBeOverridden(t *testing.T) {
45 - app := New("test", "")
46 - app.Arg("a", "").Default("invalid").Bool()
47 - _, err := app.Parse([]string{})
48 - assert.Error(t, err)
49 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/cmd.go deleted
-161
@@ -1,161 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "fmt"
5 - "strings"
6 -)
7 -
8 -type cmdGroup struct {
9 - app *Application
10 - parent *CmdClause
11 - commands map[string]*CmdClause
12 - commandOrder []*CmdClause
13 -}
14 -
15 -func (c *cmdGroup) defaultSubcommand() *CmdClause {
16 - for _, cmd := range c.commandOrder {
17 - if cmd.isDefault {
18 - return cmd
19 - }
20 - }
21 - return nil
22 -}
23 -
24 -func newCmdGroup(app *Application) *cmdGroup {
25 - return &cmdGroup{
26 - app: app,
27 - commands: make(map[string]*CmdClause),
28 - }
29 -}
30 -
31 -func (c *cmdGroup) flattenedCommands() (out []*CmdClause) {
32 - for _, cmd := range c.commandOrder {
33 - if len(cmd.commands) == 0 {
34 - out = append(out, cmd)
35 - }
36 - out = append(out, cmd.flattenedCommands()...)
37 - }
38 - return
39 -}
40 -
41 -func (c *cmdGroup) addCommand(name, help string) *CmdClause {
42 - cmd := newCommand(c.app, name, help)
43 - c.commands[name] = cmd
44 - c.commandOrder = append(c.commandOrder, cmd)
45 - return cmd
46 -}
47 -
48 -func (c *cmdGroup) init() error {
49 - seen := map[string]bool{}
50 - if c.defaultSubcommand() != nil && !c.have() {
51 - return fmt.Errorf("default subcommand %q provided but no subcommands defined", c.defaultSubcommand().name)
52 - }
53 - defaults := []string{}
54 - for _, cmd := range c.commandOrder {
55 - if cmd.isDefault {
56 - defaults = append(defaults, cmd.name)
57 - }
58 - if seen[cmd.name] {
59 - return fmt.Errorf("duplicate command %q", cmd.name)
60 - }
61 - seen[cmd.name] = true
62 - if err := cmd.init(); err != nil {
63 - return err
64 - }
65 - }
66 - if len(defaults) > 1 {
67 - return fmt.Errorf("more than one default subcommand exists: %s", strings.Join(defaults, ", "))
68 - }
69 - return nil
70 -}
71 -
72 -func (c *cmdGroup) have() bool {
73 - return len(c.commands) > 0
74 -}
75 -
76 -type CmdClauseValidator func(*CmdClause) error
77 -
78 -// A CmdClause is a single top-level command. It encapsulates a set of flags
79 -// and either subcommands or positional arguments.
80 -type CmdClause struct {
81 - actionMixin
82 - *flagGroup
83 - *argGroup
84 - *cmdGroup
85 - app *Application
86 - name string
87 - help string
88 - isDefault bool
89 - validator CmdClauseValidator
90 - hidden bool
91 -}
92 -
93 -func newCommand(app *Application, name, help string) *CmdClause {
94 - c := &CmdClause{
95 - flagGroup: newFlagGroup(),
96 - argGroup: newArgGroup(),
97 - cmdGroup: newCmdGroup(app),
98 - app: app,
99 - name: name,
100 - help: help,
101 - }
102 - return c
103 -}
104 -
105 -// Validate sets a validation function to run when parsing.
106 -func (c *CmdClause) Validate(validator CmdClauseValidator) *CmdClause {
107 - c.validator = validator
108 - return c
109 -}
110 -
111 -func (c *CmdClause) FullCommand() string {
112 - out := []string{c.name}
113 - for p := c.parent; p != nil; p = p.parent {
114 - out = append([]string{p.name}, out...)
115 - }
116 - return strings.Join(out, " ")
117 -}
118 -
119 -// Command adds a new sub-command.
120 -func (c *CmdClause) Command(name, help string) *CmdClause {
121 - cmd := c.addCommand(name, help)
122 - cmd.parent = c
123 - return cmd
124 -}
125 -
126 -// Default makes this command the default if commands don't match.
127 -func (c *CmdClause) Default() *CmdClause {
128 - c.isDefault = true
129 - return c
130 -}
131 -
132 -func (c *CmdClause) Action(action Action) *CmdClause {
133 - c.addAction(action)
134 - return c
135 -}
136 -
137 -func (c *CmdClause) PreAction(action Action) *CmdClause {
138 - c.addPreAction(action)
139 - return c
140 -}
141 -
142 -func (c *CmdClause) init() error {
143 - if err := c.flagGroup.init(); err != nil {
144 - return err
145 - }
146 - if c.argGroup.have() && c.cmdGroup.have() {
147 - return fmt.Errorf("can't mix Arg()s with Command()s")
148 - }
149 - if err := c.argGroup.init(); err != nil {
150 - return err
151 - }
152 - if err := c.cmdGroup.init(); err != nil {
153 - return err
154 - }
155 - return nil
156 -}
157 -
158 -func (c *CmdClause) Hidden() *CmdClause {
159 - c.hidden = true
160 - return c
161 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/cmd/genvalues/main.go deleted
-121
@@ -1,121 +0,0 @@
1 -package main
2 -
3 -import (
4 - "encoding/json"
5 - "os/exec"
6 - "strings"
7 - "text/template"
8 -
9 - "os"
10 -)
11 -
12 -const (
13 - tmpl = `package kingpin
14 -
15 -// This file is autogenerated by "go generate .". Do not modify.
16 -
17 -{{range .}}
18 -{{if not .NoValueParser}}
19 -// -- {{.Type}} Value
20 -type {{.Type}}Value {{.Type}}
21 -
22 -func new{{.|Name}}Value(p *{{.Type}}) *{{.Type}}Value {
23 - return (*{{.Type}}Value)(p)
24 -}
25 -
26 -func (f *{{.Type}}Value) Set(s string) error {
27 - v, err := {{.Parser}}
28 - *f = {{.Type}}Value(v)
29 - return err
30 -}
31 -
32 -func (f *{{.Type}}Value) Get() interface{} { return {{.Type}}(*f) }
33 -
34 -func (f *{{.Type}}Value) String() string { return {{.|Format}} }
35 -
36 -// {{.|Name}} parses the next command-line value as {{.Type}}.
37 -func (p *parserMixin) {{.|Name}}() (target *{{.Type}}) {
38 - target = new({{.Type}})
39 - p.{{.|Name}}Var(target)
40 - return
41 -}
42 -
43 -func (p *parserMixin) {{.|Name}}Var(target *{{.Type}}) {
44 - p.SetValue(new{{.|Name}}Value(target))
45 -}
46 -
47 -{{end}}
48 -// {{.|Plural}} accumulates {{.Type}} values into a slice.
49 -func (p *parserMixin) {{.|Plural}}() (target *[]{{.Type}}) {
50 - target = new([]{{.Type}})
51 - p.{{.|Plural}}Var(target)
52 - return
53 -}
54 -
55 -func (p *parserMixin) {{.|Plural}}Var(target *[]{{.Type}}) {
56 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return new{{.|Name}}Value(v.(*{{.Type}})) }))
57 -}
58 -
59 -{{end}}
60 -`
61 -)
62 -
63 -type Value struct {
64 - Name string `json:"name"`
65 - NoValueParser bool `json:"no_value_parser"`
66 - Type string `json:"type"`
67 - Parser string `json:"parser"`
68 - Format string `json:"format"`
69 - Plural string `json:"plural"`
70 -}
71 -
72 -func fatalIfError(err error) {
73 - if err != nil {
74 - panic(err)
75 - }
76 -}
77 -
78 -func main() {
79 - r, err := os.Open("values.json")
80 - fatalIfError(err)
81 - defer r.Close()
82 -
83 - v := []Value{}
84 - err = json.NewDecoder(r).Decode(&v)
85 - fatalIfError(err)
86 -
87 - valueName := func(v *Value) string {
88 - if v.Name != "" {
89 - return v.Name
90 - }
91 - return strings.Title(v.Type)
92 - }
93 -
94 - t, err := template.New("genvalues").Funcs(template.FuncMap{
95 - "Lower": strings.ToLower,
96 - "Format": func(v *Value) string {
97 - if v.Format != "" {
98 - return v.Format
99 - }
100 - return "fmt.Sprintf(\"%v\", *f)"
101 - },
102 - "Name": valueName,
103 - "Plural": func(v *Value) string {
104 - if v.Plural != "" {
105 - return v.Plural
106 - }
107 - return valueName(v) + "List"
108 - },
109 - }).Parse(tmpl)
110 - fatalIfError(err)
111 -
112 - w, err := os.Create("values_generated.go")
113 - fatalIfError(err)
114 - defer w.Close()
115 -
116 - err = t.Execute(w, v)
117 - fatalIfError(err)
118 -
119 - err = exec.Command("goimports", "-w", "values_generated.go").Run()
120 - fatalIfError(err)
121 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/cmd_test.go deleted
-157
@@ -1,157 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "strings"
5 -
6 - "gx/ipfs/QmZwjfAKWe7vWZ8f48u7AGA1xYfzR1iCD9A2XSCYFRBWot/testify/assert"
7 -
8 - "testing"
9 -)
10 -
11 -func parseAndExecute(app *Application, context *ParseContext) (string, error) {
12 - if err := parse(context, app); err != nil {
13 - return "", err
14 - }
15 - return app.execute(context)
16 -}
17 -
18 -func TestNestedCommands(t *testing.T) {
19 - app := New("app", "")
20 - sub1 := app.Command("sub1", "")
21 - sub1.Flag("sub1", "")
22 - subsub1 := sub1.Command("sub1sub1", "")
23 - subsub1.Command("sub1sub1end", "")
24 -
25 - sub2 := app.Command("sub2", "")
26 - sub2.Flag("sub2", "")
27 - sub2.Command("sub2sub1", "")
28 -
29 - context := tokenize([]string{"sub1", "sub1sub1", "sub1sub1end"})
30 - selected, err := parseAndExecute(app, context)
31 - assert.NoError(t, err)
32 - assert.True(t, context.EOL())
33 - assert.Equal(t, "sub1 sub1sub1 sub1sub1end", selected)
34 -}
35 -
36 -func TestNestedCommandsWithArgs(t *testing.T) {
37 - app := New("app", "")
38 - cmd := app.Command("a", "").Command("b", "")
39 - a := cmd.Arg("a", "").String()
40 - b := cmd.Arg("b", "").String()
41 - context := tokenize([]string{"a", "b", "c", "d"})
42 - selected, err := parseAndExecute(app, context)
43 - assert.NoError(t, err)
44 - assert.True(t, context.EOL())
45 - assert.Equal(t, "a b", selected)
46 - assert.Equal(t, "c", *a)
47 - assert.Equal(t, "d", *b)
48 -}
49 -
50 -func TestNestedCommandsWithFlags(t *testing.T) {
51 - app := New("app", "")
52 - cmd := app.Command("a", "").Command("b", "")
53 - a := cmd.Flag("aaa", "").Short('a').String()
54 - b := cmd.Flag("bbb", "").Short('b').String()
55 - err := app.init()
56 - assert.NoError(t, err)
57 - context := tokenize(strings.Split("a b --aaa x -b x", " "))
58 - selected, err := parseAndExecute(app, context)
59 - assert.NoError(t, err)
60 - assert.True(t, context.EOL())
61 - assert.Equal(t, "a b", selected)
62 - assert.Equal(t, "x", *a)
63 - assert.Equal(t, "x", *b)
64 -}
65 -
66 -func TestNestedCommandWithMergedFlags(t *testing.T) {
67 - app := New("app", "")
68 - cmd0 := app.Command("a", "")
69 - cmd0f0 := cmd0.Flag("aflag", "").Bool()
70 - // cmd1 := app.Command("b", "")
71 - // cmd1f0 := cmd0.Flag("bflag", "").Bool()
72 - cmd00 := cmd0.Command("aa", "")
73 - cmd00f0 := cmd00.Flag("aaflag", "").Bool()
74 - err := app.init()
75 - assert.NoError(t, err)
76 - context := tokenize(strings.Split("a aa --aflag --aaflag", " "))
77 - selected, err := parseAndExecute(app, context)
78 - assert.NoError(t, err)
79 - assert.True(t, *cmd0f0)
80 - assert.True(t, *cmd00f0)
81 - assert.Equal(t, "a aa", selected)
82 -}
83 -
84 -func TestNestedCommandWithDuplicateFlagErrors(t *testing.T) {
85 - app := New("app", "")
86 - app.Flag("test", "").Bool()
87 - app.Command("cmd0", "").Flag("test", "").Bool()
88 - err := app.init()
89 - assert.Error(t, err)
90 -}
91 -
92 -func TestNestedCommandWithArgAndMergedFlags(t *testing.T) {
93 - app := New("app", "")
94 - cmd0 := app.Command("a", "")
95 - cmd0f0 := cmd0.Flag("aflag", "").Bool()
96 - // cmd1 := app.Command("b", "")
97 - // cmd1f0 := cmd0.Flag("bflag", "").Bool()
98 - cmd00 := cmd0.Command("aa", "")
99 - cmd00a0 := cmd00.Arg("arg", "").String()
100 - cmd00f0 := cmd00.Flag("aaflag", "").Bool()
101 - err := app.init()
102 - assert.NoError(t, err)
103 - context := tokenize(strings.Split("a aa hello --aflag --aaflag", " "))
104 - selected, err := parseAndExecute(app, context)
105 - assert.NoError(t, err)
106 - assert.True(t, *cmd0f0)
107 - assert.True(t, *cmd00f0)
108 - assert.Equal(t, "a aa", selected)
109 - assert.Equal(t, "hello", *cmd00a0)
110 -}
111 -
112 -func TestDefaultSubcommandEOL(t *testing.T) {
113 - app := New("app", "").Terminate(nil)
114 - c0 := app.Command("c0", "").Default()
115 - c0.Command("c01", "").Default()
116 - c0.Command("c02", "")
117 -
118 - cmd, err := app.Parse([]string{"c0"})
119 - assert.NoError(t, err)
120 - assert.Equal(t, "c0 c01", cmd)
121 -}
122 -
123 -func TestDefaultSubcommandWithArg(t *testing.T) {
124 - app := New("app", "").Terminate(nil)
125 - c0 := app.Command("c0", "").Default()
126 - c01 := c0.Command("c01", "").Default()
127 - c012 := c01.Command("c012", "").Default()
128 - a0 := c012.Arg("a0", "").String()
129 - c0.Command("c02", "")
130 -
131 - cmd, err := app.Parse([]string{"c0", "hello"})
132 - assert.NoError(t, err)
133 - assert.Equal(t, "c0 c01 c012", cmd)
134 - assert.Equal(t, "hello", *a0)
135 -}
136 -
137 -func TestDefaultSubcommandWithFlags(t *testing.T) {
138 - app := New("app", "").Terminate(nil)
139 - c0 := app.Command("c0", "").Default()
140 - _ = c0.Flag("f0", "").Int()
141 - c0c1 := c0.Command("c1", "").Default()
142 - c0c1f1 := c0c1.Flag("f1", "").Int()
143 - selected, err := app.Parse([]string{"--f1=2"})
144 - assert.NoError(t, err)
145 - assert.Equal(t, "c0 c1", selected)
146 - assert.Equal(t, 2, *c0c1f1)
147 - _, err = app.Parse([]string{"--f2"})
148 - assert.Error(t, err)
149 -}
150 -
151 -func TestMultipleDefaultCommands(t *testing.T) {
152 - app := New("app", "").Terminate(nil)
153 - app.Command("c0", "").Default()
154 - app.Command("c1", "").Default()
155 - _, err := app.Parse([]string{})
156 - assert.Error(t, err)
157 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/doc.go deleted
-68
@@ -1,68 +0,0 @@
1 -// Package kingpin provides command line interfaces like this:
2 -//
3 -// $ chat
4 -// usage: chat [<flags>] <command> [<flags>] [<args> ...]
5 -//
6 -// Flags:
7 -// --debug enable debug mode
8 -// --help Show help.
9 -// --server=127.0.0.1 server address
10 -//
11 -// Commands:
12 -// help <command>
13 -// Show help for a command.
14 -//
15 -// post [<flags>] <channel>
16 -// Post a message to a channel.
17 -//
18 -// register <nick> <name>
19 -// Register a new user.
20 -//
21 -// $ chat help post
22 -// usage: chat [<flags>] post [<flags>] <channel> [<text>]
23 -//
24 -// Post a message to a channel.
25 -//
26 -// Flags:
27 -// --image=IMAGE image to post
28 -//
29 -// Args:
30 -// <channel> channel to post to
31 -// [<text>] text to post
32 -// $ chat post --image=~/Downloads/owls.jpg pics
33 -//
34 -// From code like this:
35 -//
36 -// package main
37 -//
38 -// import "gopkg.in/alecthomas/kingpin.v1"
39 -//
40 -// var (
41 -// debug = kingpin.Flag("debug", "enable debug mode").Default("false").Bool()
42 -// serverIP = kingpin.Flag("server", "server address").Default("127.0.0.1").IP()
43 -//
44 -// register = kingpin.Command("register", "Register a new user.")
45 -// registerNick = register.Arg("nick", "nickname for user").Required().String()
46 -// registerName = register.Arg("name", "name of user").Required().String()
47 -//
48 -// post = kingpin.Command("post", "Post a message to a channel.")
49 -// postImage = post.Flag("image", "image to post").ExistingFile()
50 -// postChannel = post.Arg("channel", "channel to post to").Required().String()
51 -// postText = post.Arg("text", "text to post").String()
52 -// )
53 -//
54 -// func main() {
55 -// switch kingpin.Parse() {
56 -// // Register user
57 -// case "register":
58 -// println(*registerNick)
59 -//
60 -// // Post message
61 -// case "post":
62 -// if *postImage != nil {
63 -// }
64 -// if *postText != "" {
65 -// }
66 -// }
67 -// }
68 -package kingpin
Godeps/_workspace/src/github.com/alecthomas/kingpin/examples/chat1/main.go deleted
-20
@@ -1,20 +0,0 @@
1 -package main
2 -
3 -import (
4 - "fmt"
5 -
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/kingpin"
7 -)
8 -
9 -var (
10 - debug = kingpin.Flag("debug", "Enable debug mode.").Bool()
11 - timeout = kingpin.Flag("timeout", "Timeout waiting for ping.").Default("5s").OverrideDefaultFromEnvar("PING_TIMEOUT").Short('t').Duration()
12 - ip = kingpin.Arg("ip", "IP address to ping.").Required().IP()
13 - count = kingpin.Arg("count", "Number of packets to send").Int()
14 -)
15 -
16 -func main() {
17 - kingpin.Version("0.0.1")
18 - kingpin.Parse()
19 - fmt.Printf("Would ping: %s with timeout %s and count %d", *ip, *timeout, *count)
20 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/examples/chat2/main.go deleted
-38
@@ -1,38 +0,0 @@
1 -package main
2 -
3 -import (
4 - "os"
5 - "strings"
6 -
7 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/kingpin"
8 -)
9 -
10 -var (
11 - app = kingpin.New("chat", "A command-line chat application.")
12 - debug = app.Flag("debug", "Enable debug mode.").Bool()
13 - serverIP = app.Flag("server", "Server address.").Default("127.0.0.1").IP()
14 -
15 - register = app.Command("register", "Register a new user.")
16 - registerNick = register.Arg("nick", "Nickname for user.").Required().String()
17 - registerName = register.Arg("name", "Name of user.").Required().String()
18 -
19 - post = app.Command("post", "Post a message to a channel.")
20 - postImage = post.Flag("image", "Image to post.").File()
21 - postChannel = post.Arg("channel", "Channel to post to.").Required().String()
22 - postText = post.Arg("text", "Text to post.").Strings()
23 -)
24 -
25 -func main() {
26 - switch kingpin.MustParse(app.Parse(os.Args[1:])) {
27 - // Register user
28 - case register.FullCommand():
29 - println(*registerNick)
30 -
31 - // Post message
32 - case post.FullCommand():
33 - if *postImage != nil {
34 - }
35 - text := strings.Join(*postText, " ")
36 - println("Post:", text)
37 - }
38 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/examples/curl/main.go deleted
-105
@@ -1,105 +0,0 @@
1 -// A curl-like HTTP command-line client.
2 -package main
3 -
4 -import (
5 - "errors"
6 - "fmt"
7 - "io"
8 - "net/http"
9 - "os"
10 - "strings"
11 -
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/kingpin"
13 -)
14 -
15 -var (
16 - timeout = kingpin.Flag("timeout", "Set connection timeout.").Short('t').Default("5s").Duration()
17 - headers = HTTPHeader(kingpin.Flag("headers", "Add HTTP headers to the request.").Short('H').PlaceHolder("HEADER=VALUE"))
18 -
19 - get = kingpin.Command("get", "GET a resource.").Default()
20 - getFlag = get.Flag("test", "Test flag").Bool()
21 - getURL = get.Command("url", "Retrieve a URL.").Default()
22 - getURLURL = getURL.Arg("url", "URL to GET.").Required().URL()
23 - getFile = get.Command("file", "Retrieve a file.")
24 - getFileFile = getFile.Arg("file", "File to retrieve.").Required().ExistingFile()
25 -
26 - post = kingpin.Command("post", "POST a resource.")
27 - postData = post.Flag("data", "Key-value data to POST").Short('d').PlaceHolder("KEY:VALUE").StringMap()
28 - postBinaryFile = post.Flag("data-binary", "File with binary data to POST.").File()
29 - postURL = post.Arg("url", "URL to POST to.").Required().URL()
30 -)
31 -
32 -type HTTPHeaderValue http.Header
33 -
34 -func (h HTTPHeaderValue) Set(value string) error {
35 - parts := strings.SplitN(value, "=", 2)
36 - if len(parts) != 2 {
37 - return fmt.Errorf("expected HEADER=VALUE got '%s'", value)
38 - }
39 - (http.Header)(h).Add(parts[0], parts[1])
40 - return nil
41 -}
42 -
43 -func (h HTTPHeaderValue) String() string {
44 - return ""
45 -}
46 -
47 -func HTTPHeader(s kingpin.Settings) (target *http.Header) {
48 - target = &http.Header{}
49 - s.SetValue((*HTTPHeaderValue)(target))
50 - return
51 -}
52 -
53 -func applyRequest(req *http.Request) error {
54 - req.Header = *headers
55 - resp, err := http.DefaultClient.Do(req)
56 - if err != nil {
57 - return err
58 - }
59 - defer resp.Body.Close()
60 - if resp.StatusCode < 200 || resp.StatusCode > 299 {
61 - return fmt.Errorf("HTTP request failed: %s", resp.Status)
62 - }
63 - _, err = io.Copy(os.Stdout, resp.Body)
64 - return err
65 -}
66 -
67 -func apply(method string, url string) error {
68 - req, err := http.NewRequest(method, url, nil)
69 - if err != nil {
70 - return err
71 - }
72 - return applyRequest(req)
73 -}
74 -
75 -func applyPOST() error {
76 - req, err := http.NewRequest("POST", (*postURL).String(), nil)
77 - if err != nil {
78 - return err
79 - }
80 - if len(*postData) > 0 {
81 - for key, value := range *postData {
82 - req.Form.Set(key, value)
83 - }
84 - } else if postBinaryFile != nil {
85 - if headers.Get("Content-Type") != "" {
86 - headers.Set("Content-Type", "application/octet-stream")
87 - }
88 - req.Body = *postBinaryFile
89 - } else {
90 - return errors.New("--data or --data-binary must be provided to POST")
91 - }
92 - return applyRequest(req)
93 -}
94 -
95 -func main() {
96 - kingpin.UsageTemplate(kingpin.CompactUsageTemplate).Version("1.0").Author("Alec Thomas")
97 - kingpin.CommandLine.Help = "An example implementation of curl."
98 - switch kingpin.Parse() {
99 - case "get url":
100 - kingpin.FatalIfError(apply("GET", (*getURLURL).String()), "GET failed")
101 -
102 - case "post":
103 - kingpin.FatalIfError(applyPOST(), "POST failed")
104 - }
105 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/examples/modular/main.go deleted
-30
@@ -1,30 +0,0 @@
1 -package main
2 -
3 -import (
4 - "fmt"
5 - "os"
6 -
7 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/kingpin"
8 -)
9 -
10 -// Context for "ls" command
11 -type LsCommand struct {
12 - All bool
13 -}
14 -
15 -func (l *LsCommand) run(c *kingpin.ParseContext) error {
16 - fmt.Printf("all=%v\n", l.All)
17 - return nil
18 -}
19 -
20 -func configureLsCommand(app *kingpin.Application) {
21 - c := &LsCommand{}
22 - ls := app.Command("ls", "List files.").Action(c.run)
23 - ls.Flag("all", "List all files.").Short('a').BoolVar(&c.All)
24 -}
25 -
26 -func main() {
27 - app := kingpin.New("modular", "My modular application.")
28 - configureLsCommand(app)
29 - kingpin.MustParse(app.Parse(os.Args[1:]))
30 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/examples/ping/main.go deleted
-20
@@ -1,20 +0,0 @@
1 -package main
2 -
3 -import (
4 - "fmt"
5 -
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/kingpin"
7 -)
8 -
9 -var (
10 - debug = kingpin.Flag("debug", "Enable debug mode.").Bool()
11 - timeout = kingpin.Flag("timeout", "Timeout waiting for ping.").OverrideDefaultFromEnvar("PING_TIMEOUT").Required().Short('t').Duration()
12 - ip = kingpin.Arg("ip", "IP address to ping.").Required().IP()
13 - count = kingpin.Arg("count", "Number of packets to send").Int()
14 -)
15 -
16 -func main() {
17 - kingpin.Version("0.0.1")
18 - kingpin.Parse()
19 - fmt.Printf("Would ping: %s with timeout %s and count %d", *ip, *timeout, *count)
20 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/examples_test.go deleted
-42
@@ -1,42 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "fmt"
5 - "net/http"
6 - "strings"
7 -)
8 -
9 -type HTTPHeaderValue http.Header
10 -
11 -func (h *HTTPHeaderValue) Set(value string) error {
12 - parts := strings.SplitN(value, ":", 2)
13 - if len(parts) != 2 {
14 - return fmt.Errorf("expected HEADER:VALUE got '%s'", value)
15 - }
16 - (*http.Header)(h).Add(parts[0], parts[1])
17 - return nil
18 -}
19 -
20 -func (h *HTTPHeaderValue) String() string {
21 - return ""
22 -}
23 -
24 -func HTTPHeader(s Settings) (target *http.Header) {
25 - target = new(http.Header)
26 - s.SetValue((*HTTPHeaderValue)(target))
27 - return
28 -}
29 -
30 -// This example ilustrates how to define custom parsers. HTTPHeader
31 -// cumulatively parses each encountered --header flag into a http.Header struct.
32 -func ExampleValue() {
33 - var (
34 - curl = New("curl", "transfer a URL")
35 - headers = HTTPHeader(curl.Flag("headers", "Add HTTP headers to the request.").Short('H').PlaceHolder("HEADER:VALUE"))
36 - )
37 -
38 - curl.Parse([]string{"-H Content-Type:application/octet-stream"})
39 - for key, value := range *headers {
40 - fmt.Printf("%s = %s\n", key, value)
41 - }
42 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/flags.go deleted
-237
@@ -1,237 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "fmt"
5 - "os"
6 - "strings"
7 -)
8 -
9 -type flagGroup struct {
10 - short map[string]*FlagClause
11 - long map[string]*FlagClause
12 - flagOrder []*FlagClause
13 -}
14 -
15 -func newFlagGroup() *flagGroup {
16 - return &flagGroup{
17 - short: make(map[string]*FlagClause),
18 - long: make(map[string]*FlagClause),
19 - }
20 -}
21 -
22 -func (f *flagGroup) merge(o *flagGroup) {
23 - for _, flag := range o.flagOrder {
24 - if flag.shorthand != 0 {
25 - f.short[string(flag.shorthand)] = flag
26 - }
27 - f.long[flag.name] = flag
28 - f.flagOrder = append(f.flagOrder, flag)
29 - }
30 -}
31 -
32 -// Flag defines a new flag with the given long name and help.
33 -func (f *flagGroup) Flag(name, help string) *FlagClause {
34 - flag := newFlag(name, help)
35 - f.long[name] = flag
36 - f.flagOrder = append(f.flagOrder, flag)
37 - return flag
38 -}
39 -
40 -func (f *flagGroup) init() error {
41 - for _, flag := range f.long {
42 - if err := flag.init(); err != nil {
43 - return err
44 - }
45 - if flag.shorthand != 0 {
46 - f.short[string(flag.shorthand)] = flag
47 - }
48 - }
49 - return nil
50 -}
51 -
52 -func (f *flagGroup) parse(context *ParseContext) (*FlagClause, error) {
53 - var token *Token
54 -
55 -loop:
56 - for {
57 - token = context.Peek()
58 - switch token.Type {
59 - case TokenEOL:
60 - break loop
61 -
62 - case TokenLong, TokenShort:
63 - flagToken := token
64 - defaultValue := ""
65 - var flag *FlagClause
66 - var ok bool
67 - invert := false
68 -
69 - name := token.Value
70 - if token.Type == TokenLong {
71 - if strings.HasPrefix(name, "no-") {
72 - name = name[3:]
73 - invert = true
74 - }
75 - flag, ok = f.long[name]
76 - if !ok {
77 - return nil, fmt.Errorf("unknown long flag '%s'", flagToken)
78 - }
79 - } else {
80 - flag, ok = f.short[name]
81 - if !ok {
82 - return nil, fmt.Errorf("unknown short flag '%s'", flagToken)
83 - }
84 - }
85 -
86 - context.Next()
87 -
88 - fb, ok := flag.value.(boolFlag)
89 - if ok && fb.IsBoolFlag() {
90 - if invert {
91 - defaultValue = "false"
92 - } else {
93 - defaultValue = "true"
94 - }
95 - } else {
96 - if invert {
97 - context.Push(token)
98 - return nil, fmt.Errorf("unknown long flag '%s'", flagToken)
99 - }
100 - token = context.Peek()
101 - if token.Type != TokenArg {
102 - context.Push(token)
103 - return nil, fmt.Errorf("expected argument for flag '%s'", flagToken)
104 - }
105 - context.Next()
106 - defaultValue = token.Value
107 - }
108 -
109 - context.matchedFlag(flag, defaultValue)
110 - return flag, nil
111 -
112 - default:
113 - break loop
114 - }
115 - }
116 - return nil, nil
117 -}
118 -
119 -func (f *flagGroup) visibleFlags() int {
120 - count := 0
121 - for _, flag := range f.long {
122 - if !flag.hidden {
123 - count++
124 - }
125 - }
126 - return count
127 -}
128 -
129 -// FlagClause is a fluid interface used to build flags.
130 -type FlagClause struct {
131 - parserMixin
132 - actionMixin
133 - name string
134 - shorthand byte
135 - help string
136 - envar string
137 - defaultValue string
138 - placeholder string
139 - hidden bool
140 -}
141 -
142 -func newFlag(name, help string) *FlagClause {
143 - f := &FlagClause{
144 - name: name,
145 - help: help,
146 - }
147 - return f
148 -}
149 -
150 -func (f *FlagClause) needsValue() bool {
151 - return f.required && f.defaultValue == ""
152 -}
153 -
154 -func (f *FlagClause) formatPlaceHolder() string {
155 - if f.placeholder != "" {
156 - return f.placeholder
157 - }
158 - if f.defaultValue != "" {
159 - if _, ok := f.value.(*stringValue); ok {
160 - return fmt.Sprintf("%q", f.defaultValue)
161 - }
162 - return f.defaultValue
163 - }
164 - return strings.ToUpper(f.name)
165 -}
166 -
167 -func (f *FlagClause) init() error {
168 - if f.required && f.defaultValue != "" {
169 - return fmt.Errorf("required flag '--%s' with default value that will never be used", f.name)
170 - }
171 - if f.value == nil {
172 - return fmt.Errorf("no type defined for --%s (eg. .String())", f.name)
173 - }
174 - if f.envar != "" {
175 - if v := os.Getenv(f.envar); v != "" {
176 - f.defaultValue = v
177 - }
178 - }
179 - return nil
180 -}
181 -
182 -// Dispatch to the given function after the flag is parsed and validated.
183 -func (f *FlagClause) Action(action Action) *FlagClause {
184 - f.addAction(action)
185 - return f
186 -}
187 -
188 -func (f *FlagClause) PreAction(action Action) *FlagClause {
189 - f.addPreAction(action)
190 - return f
191 -}
192 -
193 -// Default value for this flag. It *must* be parseable by the value of the flag.
194 -func (f *FlagClause) Default(value string) *FlagClause {
195 - f.defaultValue = value
196 - return f
197 -}
198 -
199 -// OverrideDefaultFromEnvar overrides the default value for a flag from an
200 -// environment variable, if available.
201 -func (f *FlagClause) OverrideDefaultFromEnvar(envar string) *FlagClause {
202 - f.envar = envar
203 - return f
204 -}
205 -
206 -// PlaceHolder sets the place-holder string used for flag values in the help. The
207 -// default behaviour is to use the value provided by Default() if provided,
208 -// then fall back on the capitalized flag name.
209 -func (f *FlagClause) PlaceHolder(placeholder string) *FlagClause {
210 - f.placeholder = placeholder
211 - return f
212 -}
213 -
214 -// Hidden hides a flag from usage but still allows it to be used.
215 -func (f *FlagClause) Hidden() *FlagClause {
216 - f.hidden = true
217 - return f
218 -}
219 -
220 -// Required makes the flag required. You can not provide a Default() value to a Required() flag.
221 -func (f *FlagClause) Required() *FlagClause {
222 - f.required = true
223 - return f
224 -}
225 -
226 -// Short sets the short flag name.
227 -func (f *FlagClause) Short(name byte) *FlagClause {
228 - f.shorthand = name
229 - return f
230 -}
231 -
232 -// Bool makes this flag a boolean flag.
233 -func (f *FlagClause) Bool() (target *bool) {
234 - target = new(bool)
235 - f.SetValue(newBoolValue(target))
236 - return
237 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/flags_test.go deleted
-109
@@ -1,109 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "io/ioutil"
5 - "os"
6 -
7 - "gx/ipfs/QmZwjfAKWe7vWZ8f48u7AGA1xYfzR1iCD9A2XSCYFRBWot/testify/assert"
8 -
9 - "testing"
10 -)
11 -
12 -func TestBool(t *testing.T) {
13 - app := New("test", "")
14 - b := app.Flag("b", "").Bool()
15 - _, err := app.Parse([]string{"--b"})
16 - assert.NoError(t, err)
17 - assert.True(t, *b)
18 -}
19 -
20 -func TestNoBool(t *testing.T) {
21 - fg := newFlagGroup()
22 - f := fg.Flag("b", "").Default("true")
23 - b := f.Bool()
24 - fg.init()
25 - tokens := tokenize([]string{"--no-b"})
26 - _, err := fg.parse(tokens)
27 - assert.NoError(t, err)
28 - assert.False(t, *b)
29 -}
30 -
31 -func TestNegateNonBool(t *testing.T) {
32 - fg := newFlagGroup()
33 - f := fg.Flag("b", "")
34 - f.Int()
35 - fg.init()
36 - tokens := tokenize([]string{"--no-b"})
37 - _, err := fg.parse(tokens)
38 - assert.Error(t, err)
39 -}
40 -
41 -func TestInvalidFlagDefaultCanBeOverridden(t *testing.T) {
42 - app := New("test", "")
43 - app.Flag("a", "").Default("invalid").Bool()
44 - _, err := app.Parse([]string{})
45 - assert.Error(t, err)
46 -}
47 -
48 -func TestRequiredFlag(t *testing.T) {
49 - app := New("test", "")
50 - app.Version("0.0.0").Writer(ioutil.Discard)
51 - exits := 0
52 - app.Terminate(func(int) { exits++ })
53 - app.Flag("a", "").Required().Bool()
54 - _, err := app.Parse([]string{"--a"})
55 - assert.NoError(t, err)
56 - _, err = app.Parse([]string{})
57 - assert.Error(t, err)
58 - _, err = app.Parse([]string{"--version"})
59 - assert.Equal(t, 1, exits)
60 -}
61 -
62 -func TestShortFlag(t *testing.T) {
63 - app := New("test", "")
64 - f := app.Flag("long", "").Short('s').Bool()
65 - _, err := app.Parse([]string{"-s"})
66 - assert.NoError(t, err)
67 - assert.True(t, *f)
68 -}
69 -
70 -func TestCombinedShortFlags(t *testing.T) {
71 - app := New("test", "")
72 - a := app.Flag("short0", "").Short('0').Bool()
73 - b := app.Flag("short1", "").Short('1').Bool()
74 - c := app.Flag("short2", "").Short('2').Bool()
75 - _, err := app.Parse([]string{"-01"})
76 - assert.NoError(t, err)
77 - assert.True(t, *a)
78 - assert.True(t, *b)
79 - assert.False(t, *c)
80 -}
81 -
82 -func TestCombinedShortFlagArg(t *testing.T) {
83 - a := New("test", "")
84 - n := a.Flag("short", "").Short('s').Int()
85 - _, err := a.Parse([]string{"-s10"})
86 - assert.NoError(t, err)
87 - assert.Equal(t, 10, *n)
88 -}
89 -
90 -func TestEmptyShortFlagIsAnError(t *testing.T) {
91 - _, err := New("test", "").Parse([]string{"-"})
92 - assert.Error(t, err)
93 -}
94 -
95 -func TestRequiredWithEnvarMissingErrors(t *testing.T) {
96 - app := New("test", "")
97 - app.Flag("t", "").OverrideDefaultFromEnvar("TEST_ENVAR").Required().Int()
98 - _, err := app.Parse([]string{})
99 - assert.Error(t, err)
100 -}
101 -
102 -func TestRequiredWithEnvar(t *testing.T) {
103 - os.Setenv("TEST_ENVAR", "123")
104 - app := New("test", "")
105 - flag := app.Flag("t", "").OverrideDefaultFromEnvar("TEST_ENVAR").Required().Int()
106 - _, err := app.Parse([]string{})
107 - assert.NoError(t, err)
108 - assert.Equal(t, 123, *flag)
109 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/global.go deleted
-88
@@ -1,88 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "os"
5 - "path/filepath"
6 -)
7 -
8 -var (
9 - // CommandLine is the default Kingpin parser.
10 - CommandLine = New(filepath.Base(os.Args[0]), "")
11 -)
12 -
13 -// Command adds a new command to the default parser.
14 -func Command(name, help string) *CmdClause {
15 - return CommandLine.Command(name, help)
16 -}
17 -
18 -// Flag adds a new flag to the default parser.
19 -func Flag(name, help string) *FlagClause {
20 - return CommandLine.Flag(name, help)
21 -}
22 -
23 -// Arg adds a new argument to the top-level of the default parser.
24 -func Arg(name, help string) *ArgClause {
25 - return CommandLine.Arg(name, help)
26 -}
27 -
28 -// Parse and return the selected command. Will call the termination handler if
29 -// an error is encountered.
30 -func Parse() string {
31 - selected := MustParse(CommandLine.Parse(os.Args[1:]))
32 - if selected == "" && CommandLine.cmdGroup.have() {
33 - Usage()
34 - CommandLine.terminate(0)
35 - }
36 - return selected
37 -}
38 -
39 -// Errorf prints an error message to stderr.
40 -func Errorf(format string, args ...interface{}) {
41 - CommandLine.Errorf(format, args...)
42 -}
43 -
44 -// Fatalf prints an error message to stderr and exits.
45 -func Fatalf(format string, args ...interface{}) {
46 - CommandLine.Fatalf(format, args...)
47 -}
48 -
49 -// FatalIfError prints an error and exits if err is not nil. The error is printed
50 -// with the given prefix.
51 -func FatalIfError(err error, format string, args ...interface{}) {
52 - CommandLine.FatalIfError(err, format, args...)
53 -}
54 -
55 -// FatalUsage prints an error message followed by usage information, then
56 -// exits with a non-zero status.
57 -func FatalUsage(format string, args ...interface{}) {
58 - CommandLine.FatalUsage(format, args...)
59 -}
60 -
61 -// FatalUsageContext writes a printf formatted error message to stderr, then
62 -// usage information for the given ParseContext, before exiting.
63 -func FatalUsageContext(context *ParseContext, format string, args ...interface{}) {
64 - CommandLine.FatalUsageContext(context, format, args...)
65 -}
66 -
67 -// Usage prints usage to stderr.
68 -func Usage() {
69 - CommandLine.Usage(os.Args[1:])
70 -}
71 -
72 -// Set global usage template to use (defaults to DefaultUsageTemplate).
73 -func UsageTemplate(template string) *Application {
74 - return CommandLine.UsageTemplate(template)
75 -}
76 -
77 -// MustParse can be used with app.Parse(args) to exit with an error if parsing fails.
78 -func MustParse(command string, err error) string {
79 - if err != nil {
80 - Fatalf("%s, try --help", err)
81 - }
82 - return command
83 -}
84 -
85 -// Version adds a flag for displaying the application version number.
86 -func Version(version string) *Application {
87 - return CommandLine.Version(version)
88 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/guesswidth.go deleted
-9
@@ -1,9 +0,0 @@
1 -// +build !linux,!freebsd,!darwin,!dragonfly,!netbsd,!openbsd
2 -
3 -package kingpin
4 -
5 -import "io"
6 -
7 -func guessWidth(w io.Writer) int {
8 - return 80
9 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/guesswidth_unix.go deleted
-38
@@ -1,38 +0,0 @@
1 -// +build linux freebsd darwin dragonfly netbsd openbsd
2 -
3 -package kingpin
4 -
5 -import (
6 - "io"
7 - "os"
8 - "strconv"
9 - "syscall"
10 - "unsafe"
11 -)
12 -
13 -func guessWidth(w io.Writer) int {
14 - // check if COLUMNS env is set to comply with
15 - // http://pubs.opengroup.org/onlinepubs/009604499/basedefs/xbd_chap08.html
16 - colsStr := os.Getenv("COLUMNS")
17 - if colsStr != "" {
18 - if cols, err := strconv.Atoi(colsStr); err == nil {
19 - return cols
20 - }
21 - }
22 -
23 - if t, ok := w.(*os.File); ok {
24 - fd := t.Fd()
25 - var dimensions [4]uint16
26 -
27 - if _, _, err := syscall.Syscall6(
28 - syscall.SYS_IOCTL,
29 - uintptr(fd),
30 - uintptr(syscall.TIOCGWINSZ),
31 - uintptr(unsafe.Pointer(&dimensions)),
32 - 0, 0, 0,
33 - ); err == 0 {
34 - return int(dimensions[1])
35 - }
36 - }
37 - return 80
38 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/model.go deleted
-219
@@ -1,219 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "fmt"
5 - "strconv"
6 - "strings"
7 -)
8 -
9 -// Data model for Kingpin command-line structure.
10 -
11 -type FlagGroupModel struct {
12 - Flags []*FlagModel
13 -}
14 -
15 -func (f *FlagGroupModel) FlagSummary() string {
16 - out := []string{}
17 - count := 0
18 - for _, flag := range f.Flags {
19 - if flag.Name != "help" {
20 - count++
21 - }
22 - if flag.Required {
23 - if flag.IsBoolFlag() {
24 - out = append(out, fmt.Sprintf("--[no-]%s", flag.Name))
25 - } else {
26 - out = append(out, fmt.Sprintf("--%s=%s", flag.Name, flag.FormatPlaceHolder()))
27 - }
28 - }
29 - }
30 - if count != len(out) {
31 - out = append(out, "[<flags>]")
32 - }
33 - return strings.Join(out, " ")
34 -}
35 -
36 -type FlagModel struct {
37 - Name string
38 - Help string
39 - Short rune
40 - Default string
41 - Envar string
42 - PlaceHolder string
43 - Required bool
44 - Hidden bool
45 - Value Value
46 -}
47 -
48 -func (f *FlagModel) String() string {
49 - return f.Value.String()
50 -}
51 -
52 -func (f *FlagModel) IsBoolFlag() bool {
53 - if fl, ok := f.Value.(boolFlag); ok {
54 - return fl.IsBoolFlag()
55 - }
56 - return false
57 -}
58 -
59 -func (f *FlagModel) FormatPlaceHolder() string {
60 - if f.PlaceHolder != "" {
61 - return f.PlaceHolder
62 - }
63 - if f.Default != "" {
64 - if _, ok := f.Value.(*stringValue); ok {
65 - return strconv.Quote(f.Default)
66 - }
67 - return f.Default
68 - }
69 - return strings.ToUpper(f.Name)
70 -}
71 -
72 -type ArgGroupModel struct {
73 - Args []*ArgModel
74 -}
75 -
76 -func (a *ArgGroupModel) ArgSummary() string {
77 - depth := 0
78 - out := []string{}
79 - for _, arg := range a.Args {
80 - h := "<" + arg.Name + ">"
81 - if !arg.Required {
82 - h = "[" + h
83 - depth++
84 - }
85 - out = append(out, h)
86 - }
87 - out[len(out)-1] = out[len(out)-1] + strings.Repeat("]", depth)
88 - return strings.Join(out, " ")
89 -}
90 -
91 -type ArgModel struct {
92 - Name string
93 - Help string
94 - Default string
95 - Required bool
96 - Value Value
97 -}
98 -
99 -func (a *ArgModel) String() string {
100 - return a.Value.String()
101 -}
102 -
103 -type CmdGroupModel struct {
104 - Commands []*CmdModel
105 -}
106 -
107 -func (c *CmdGroupModel) FlattenedCommands() (out []*CmdModel) {
108 - for _, cmd := range c.Commands {
109 - if len(cmd.Commands) == 0 {
110 - out = append(out, cmd)
111 - }
112 - out = append(out, cmd.FlattenedCommands()...)
113 - }
114 - return
115 -}
116 -
117 -type CmdModel struct {
118 - Name string
119 - Help string
120 - FullCommand string
121 - Depth int
122 - Hidden bool
123 - Default bool
124 - *FlagGroupModel
125 - *ArgGroupModel
126 - *CmdGroupModel
127 -}
128 -
129 -func (c *CmdModel) String() string {
130 - return c.FullCommand
131 -}
132 -
133 -type ApplicationModel struct {
134 - Name string
135 - Help string
136 - Version string
137 - Author string
138 - *ArgGroupModel
139 - *CmdGroupModel
140 - *FlagGroupModel
141 -}
142 -
143 -func (a *Application) Model() *ApplicationModel {
144 - return &ApplicationModel{
145 - Name: a.Name,
146 - Help: a.Help,
147 - Version: a.version,
148 - Author: a.author,
149 - FlagGroupModel: a.flagGroup.Model(),
150 - ArgGroupModel: a.argGroup.Model(),
151 - CmdGroupModel: a.cmdGroup.Model(),
152 - }
153 -}
154 -
155 -func (a *argGroup) Model() *ArgGroupModel {
156 - m := &ArgGroupModel{}
157 - for _, arg := range a.args {
158 - m.Args = append(m.Args, arg.Model())
159 - }
160 - return m
161 -}
162 -
163 -func (a *ArgClause) Model() *ArgModel {
164 - return &ArgModel{
165 - Name: a.name,
166 - Help: a.help,
167 - Default: a.defaultValue,
168 - Required: a.required,
169 - Value: a.value,
170 - }
171 -}
172 -
173 -func (f *flagGroup) Model() *FlagGroupModel {
174 - m := &FlagGroupModel{}
175 - for _, fl := range f.flagOrder {
176 - m.Flags = append(m.Flags, fl.Model())
177 - }
178 - return m
179 -}
180 -
181 -func (f *FlagClause) Model() *FlagModel {
182 - return &FlagModel{
183 - Name: f.name,
184 - Help: f.help,
185 - Short: rune(f.shorthand),
186 - Default: f.defaultValue,
187 - Envar: f.envar,
188 - PlaceHolder: f.placeholder,
189 - Required: f.required,
190 - Hidden: f.hidden,
191 - Value: f.value,
192 - }
193 -}
194 -
195 -func (c *cmdGroup) Model() *CmdGroupModel {
196 - m := &CmdGroupModel{}
197 - for _, cm := range c.commandOrder {
198 - m.Commands = append(m.Commands, cm.Model())
199 - }
200 - return m
201 -}
202 -
203 -func (c *CmdClause) Model() *CmdModel {
204 - depth := 0
205 - for i := c; i != nil; i = i.parent {
206 - depth++
207 - }
208 - return &CmdModel{
209 - Name: c.name,
210 - Help: c.help,
211 - Depth: depth,
212 - Hidden: c.hidden,
213 - Default: c.isDefault,
214 - FullCommand: c.FullCommand(),
215 - FlagGroupModel: c.flagGroup.Model(),
216 - ArgGroupModel: c.argGroup.Model(),
217 - CmdGroupModel: c.cmdGroup.Model(),
218 - }
219 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/parser.go deleted
-372
@@ -1,372 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "bufio"
5 - "fmt"
6 - "os"
7 - "strings"
8 -)
9 -
10 -type TokenType int
11 -
12 -// Token types.
13 -const (
14 - TokenShort TokenType = iota
15 - TokenLong
16 - TokenArg
17 - TokenError
18 - TokenEOL
19 -)
20 -
21 -func (t TokenType) String() string {
22 - switch t {
23 - case TokenShort:
24 - return "short flag"
25 - case TokenLong:
26 - return "long flag"
27 - case TokenArg:
28 - return "argument"
29 - case TokenError:
30 - return "error"
31 - case TokenEOL:
32 - return "<EOL>"
33 - }
34 - return "?"
35 -}
36 -
37 -var (
38 - TokenEOLMarker = Token{-1, TokenEOL, ""}
39 -)
40 -
41 -type Token struct {
42 - Index int
43 - Type TokenType
44 - Value string
45 -}
46 -
47 -func (t *Token) Equal(o *Token) bool {
48 - return t.Index == o.Index
49 -}
50 -
51 -func (t *Token) IsFlag() bool {
52 - return t.Type == TokenShort || t.Type == TokenLong
53 -}
54 -
55 -func (t *Token) IsEOF() bool {
56 - return t.Type == TokenEOL
57 -}
58 -
59 -func (t *Token) String() string {
60 - switch t.Type {
61 - case TokenShort:
62 - return "-" + t.Value
63 - case TokenLong:
64 - return "--" + t.Value
65 - case TokenArg:
66 - return t.Value
67 - case TokenError:
68 - return "error: " + t.Value
69 - case TokenEOL:
70 - return "<EOL>"
71 - default:
72 - panic("unhandled type")
73 - }
74 -}
75 -
76 -// A union of possible elements in a parse stack.
77 -type ParseElement struct {
78 - // Clause is either *CmdClause, *ArgClause or *FlagClause.
79 - Clause interface{}
80 - // Value is corresponding value for an ArgClause or FlagClause (if any).
81 - Value *string
82 -}
83 -
84 -// ParseContext holds the current context of the parser. When passed to
85 -// Action() callbacks Elements will be fully populated with *FlagClause,
86 -// *ArgClause and *CmdClause values and their corresponding arguments (if
87 -// any).
88 -type ParseContext struct {
89 - SelectedCommand *CmdClause
90 - argsOnly bool
91 - peek []*Token
92 - argi int // Index of current command-line arg we're processing.
93 - args []string
94 - flags *flagGroup
95 - arguments *argGroup
96 - argumenti int // Cursor into arguments
97 - // Flags, arguments and commands encountered and collected during parse.
98 - Elements []*ParseElement
99 -}
100 -
101 -func (p *ParseContext) nextArg() *ArgClause {
102 - if p.argumenti >= len(p.arguments.args) {
103 - return nil
104 - }
105 - arg := p.arguments.args[p.argumenti]
106 - if !arg.consumesRemainder() {
107 - p.argumenti++
108 - }
109 - return arg
110 -}
111 -
112 -func (p *ParseContext) next() {
113 - p.argi++
114 - p.args = p.args[1:]
115 -}
116 -
117 -// HasTrailingArgs returns true if there are unparsed command-line arguments.
118 -// This can occur if the parser can not match remaining arguments.
119 -func (p *ParseContext) HasTrailingArgs() bool {
120 - return len(p.args) > 0
121 -}
122 -
123 -func tokenize(args []string) *ParseContext {
124 - return &ParseContext{
125 - args: args,
126 - flags: newFlagGroup(),
127 - arguments: newArgGroup(),
128 - }
129 -}
130 -
131 -func (p *ParseContext) mergeFlags(flags *flagGroup) {
132 - for _, flag := range flags.flagOrder {
133 - if flag.shorthand != 0 {
134 - p.flags.short[string(flag.shorthand)] = flag
135 - }
136 - p.flags.long[flag.name] = flag
137 - p.flags.flagOrder = append(p.flags.flagOrder, flag)
138 - }
139 -}
140 -
141 -func (p *ParseContext) mergeArgs(args *argGroup) {
142 - for _, arg := range args.args {
143 - p.arguments.args = append(p.arguments.args, arg)
144 - }
145 -}
146 -
147 -func (p *ParseContext) EOL() bool {
148 - return p.Peek().Type == TokenEOL
149 -}
150 -
151 -// Next token in the parse context.
152 -func (p *ParseContext) Next() *Token {
153 - if len(p.peek) > 0 {
154 - return p.pop()
155 - }
156 -
157 - // End of tokens.
158 - if len(p.args) == 0 {
159 - return &Token{Index: p.argi, Type: TokenEOL}
160 - }
161 -
162 - arg := p.args[0]
163 - p.next()
164 -
165 - if p.argsOnly {
166 - return &Token{p.argi, TokenArg, arg}
167 - }
168 -
169 - // All remaining args are passed directly.
170 - if arg == "--" {
171 - p.argsOnly = true
172 - return p.Next()
173 - }
174 -
175 - if strings.HasPrefix(arg, "--") {
176 - parts := strings.SplitN(arg[2:], "=", 2)
177 - token := &Token{p.argi, TokenLong, parts[0]}
178 - if len(parts) == 2 {
179 - p.Push(&Token{p.argi, TokenArg, parts[1]})
180 - }
181 - return token
182 - }
183 -
184 - if strings.HasPrefix(arg, "-") {
185 - if len(arg) == 1 {
186 - return &Token{Index: p.argi, Type: TokenShort}
187 - }
188 - short := arg[1:2]
189 - flag, ok := p.flags.short[short]
190 - // Not a known short flag, we'll just return it anyway.
191 - if !ok {
192 - } else if fb, ok := flag.value.(boolFlag); ok && fb.IsBoolFlag() {
193 - // Bool short flag.
194 - } else {
195 - // Short flag with combined argument: -fARG
196 - token := &Token{p.argi, TokenShort, short}
197 - if len(arg) > 2 {
198 - p.Push(&Token{p.argi, TokenArg, arg[2:]})
199 - }
200 - return token
201 - }
202 -
203 - if len(arg) > 2 {
204 - p.args = append([]string{"-" + arg[2:]}, p.args...)
205 - }
206 - return &Token{p.argi, TokenShort, short}
207 - } else if strings.HasPrefix(arg, "@") {
208 - expanded, err := ExpandArgsFromFile(arg[1:])
209 - if err != nil {
210 - return &Token{p.argi, TokenError, err.Error()}
211 - }
212 - if p.argi >= len(p.args) {
213 - p.args = append(p.args[:p.argi-1], expanded...)
214 - } else {
215 - p.args = append(p.args[:p.argi-1], append(expanded, p.args[p.argi+1:]...)...)
216 - }
217 - return p.Next()
218 - }
219 -
220 - return &Token{p.argi, TokenArg, arg}
221 -}
222 -
223 -func (p *ParseContext) Peek() *Token {
224 - if len(p.peek) == 0 {
225 - return p.Push(p.Next())
226 - }
227 - return p.peek[len(p.peek)-1]
228 -}
229 -
230 -func (p *ParseContext) Push(token *Token) *Token {
231 - p.peek = append(p.peek, token)
232 - return token
233 -}
234 -
235 -func (p *ParseContext) pop() *Token {
236 - end := len(p.peek) - 1
237 - token := p.peek[end]
238 - p.peek = p.peek[0:end]
239 - return token
240 -}
241 -
242 -func (p *ParseContext) String() string {
243 - return p.SelectedCommand.FullCommand()
244 -}
245 -
246 -func (p *ParseContext) matchedFlag(flag *FlagClause, value string) {
247 - p.Elements = append(p.Elements, &ParseElement{Clause: flag, Value: &value})
248 -}
249 -
250 -func (p *ParseContext) matchedArg(arg *ArgClause, value string) {
251 - p.Elements = append(p.Elements, &ParseElement{Clause: arg, Value: &value})
252 -}
253 -
254 -func (p *ParseContext) matchedCmd(cmd *CmdClause) {
255 - p.Elements = append(p.Elements, &ParseElement{Clause: cmd})
256 - p.mergeFlags(cmd.flagGroup)
257 - p.mergeArgs(cmd.argGroup)
258 - p.SelectedCommand = cmd
259 -}
260 -
261 -// Expand arguments from a file. Lines starting with # will be treated as comments.
262 -func ExpandArgsFromFile(filename string) (out []string, err error) {
263 - r, err := os.Open(filename)
264 - if err != nil {
265 - return nil, err
266 - }
267 - defer r.Close()
268 - scanner := bufio.NewScanner(r)
269 - for scanner.Scan() {
270 - line := scanner.Text()
271 - if strings.HasPrefix(line, "#") {
272 - continue
273 - }
274 - out = append(out, line)
275 - }
276 - err = scanner.Err()
277 - return
278 -}
279 -
280 -func parse(context *ParseContext, app *Application) (err error) {
281 - context.mergeFlags(app.flagGroup)
282 - context.mergeArgs(app.argGroup)
283 -
284 - cmds := app.cmdGroup
285 - help := false
286 -
287 -loop:
288 - for !context.EOL() {
289 - token := context.Peek()
290 -
291 - switch token.Type {
292 - case TokenLong, TokenShort:
293 - if flag, err := context.flags.parse(context); err != nil {
294 - if !help {
295 - if cmd := cmds.defaultSubcommand(); cmd != nil {
296 - context.matchedCmd(cmd)
297 - cmds = cmd.cmdGroup
298 - break
299 - }
300 - }
301 - return err
302 - } else if flag == HelpFlag {
303 - help = true
304 - }
305 -
306 - case TokenArg:
307 - if cmds.have() {
308 - selectedDefault := false
309 - cmd, ok := cmds.commands[token.String()]
310 - if !ok {
311 - if !help {
312 - if cmd = cmds.defaultSubcommand(); cmd != nil {
313 - selectedDefault = true
314 - }
315 - }
316 - if cmd == nil {
317 - return fmt.Errorf("expected command but got %q", token)
318 - }
319 - }
320 - if cmd == HelpCommand {
321 - help = true
322 - }
323 - context.matchedCmd(cmd)
324 - cmds = cmd.cmdGroup
325 - if !selectedDefault {
326 - context.Next()
327 - }
328 - } else if context.arguments.have() {
329 - if app.noInterspersed {
330 - // no more flags
331 - context.argsOnly = true
332 - }
333 - arg := context.nextArg()
334 - if arg == nil {
335 - break loop
336 - }
337 - context.matchedArg(arg, token.String())
338 - context.Next()
339 - } else {
340 - break loop
341 - }
342 -
343 - case TokenEOL:
344 - break loop
345 - }
346 - }
347 -
348 - // Move to innermost default command.
349 - for !help {
350 - if cmd := cmds.defaultSubcommand(); cmd != nil {
351 - context.matchedCmd(cmd)
352 - cmds = cmd.cmdGroup
353 - } else {
354 - break
355 - }
356 - }
357 -
358 - if !context.EOL() {
359 - return fmt.Errorf("unexpected %s", context.Peek())
360 - }
361 -
362 - // Set defaults for all remaining args.
363 - for arg := context.nextArg(); arg != nil && !arg.consumesRemainder(); arg = context.nextArg() {
364 - if arg.defaultValue != "" {
365 - if err := arg.value.Set(arg.defaultValue); err != nil {
366 - return fmt.Errorf("invalid default value '%s' for argument '%s'", arg.defaultValue, arg.name)
367 - }
368 - }
369 - }
370 -
371 - return
372 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/parser_test.go deleted
-42
@@ -1,42 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "io/ioutil"
5 - "os"
6 - "testing"
7 -
8 - "gx/ipfs/QmZwjfAKWe7vWZ8f48u7AGA1xYfzR1iCD9A2XSCYFRBWot/testify/assert"
9 -)
10 -
11 -func TestParserExpandFromFile(t *testing.T) {
12 - f, err := ioutil.TempFile("", "")
13 - assert.NoError(t, err)
14 - defer os.Remove(f.Name())
15 - f.WriteString("hello\nworld\n")
16 - f.Close()
17 -
18 - app := New("test", "")
19 - arg0 := app.Arg("arg0", "").String()
20 - arg1 := app.Arg("arg1", "").String()
21 -
22 - _, err = app.Parse([]string{"@" + f.Name()})
23 - assert.NoError(t, err)
24 - assert.Equal(t, "hello", *arg0)
25 - assert.Equal(t, "world", *arg1)
26 -}
27 -
28 -func TestParseContextPush(t *testing.T) {
29 - app := New("test", "")
30 - app.Command("foo", "").Command("bar", "")
31 - c := tokenize([]string{"foo", "bar"})
32 - a := c.Next()
33 - assert.Equal(t, TokenArg, a.Type)
34 - b := c.Next()
35 - assert.Equal(t, TokenArg, b.Type)
36 - c.Push(b)
37 - c.Push(a)
38 - a = c.Next()
39 - assert.Equal(t, "foo", a.Value)
40 - b = c.Next()
41 - assert.Equal(t, "bar", b.Value)
42 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/parsers.go deleted
-201
@@ -1,201 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "net"
5 - "net/url"
6 - "os"
7 - "time"
8 -
9 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/units"
10 -)
11 -
12 -type Settings interface {
13 - SetValue(value Value)
14 -}
15 -
16 -type parserMixin struct {
17 - value Value
18 - required bool
19 -}
20 -
21 -func (p *parserMixin) SetValue(value Value) {
22 - p.value = value
23 -}
24 -
25 -// StringMap provides key=value parsing into a map.
26 -func (p *parserMixin) StringMap() (target *map[string]string) {
27 - target = &(map[string]string{})
28 - p.StringMapVar(target)
29 - return
30 -}
31 -
32 -// Duration sets the parser to a time.Duration parser.
33 -func (p *parserMixin) Duration() (target *time.Duration) {
34 - target = new(time.Duration)
35 - p.DurationVar(target)
36 - return
37 -}
38 -
39 -// Bytes parses numeric byte units. eg. 1.5KB
40 -func (p *parserMixin) Bytes() (target *units.Base2Bytes) {
41 - target = new(units.Base2Bytes)
42 - p.BytesVar(target)
43 - return
44 -}
45 -
46 -// IP sets the parser to a net.IP parser.
47 -func (p *parserMixin) IP() (target *net.IP) {
48 - target = new(net.IP)
49 - p.IPVar(target)
50 - return
51 -}
52 -
53 -// TCP (host:port) address.
54 -func (p *parserMixin) TCP() (target **net.TCPAddr) {
55 - target = new(*net.TCPAddr)
56 - p.TCPVar(target)
57 - return
58 -}
59 -
60 -// TCPVar (host:port) address.
61 -func (p *parserMixin) TCPVar(target **net.TCPAddr) {
62 - p.SetValue(newTCPAddrValue(target))
63 -}
64 -
65 -// ExistingFile sets the parser to one that requires and returns an existing file.
66 -func (p *parserMixin) ExistingFile() (target *string) {
67 - target = new(string)
68 - p.ExistingFileVar(target)
69 - return
70 -}
71 -
72 -// ExistingDir sets the parser to one that requires and returns an existing directory.
73 -func (p *parserMixin) ExistingDir() (target *string) {
74 - target = new(string)
75 - p.ExistingDirVar(target)
76 - return
77 -}
78 -
79 -// ExistingFileOrDir sets the parser to one that requires and returns an existing file OR directory.
80 -func (p *parserMixin) ExistingFileOrDir() (target *string) {
81 - target = new(string)
82 - p.ExistingFileOrDirVar(target)
83 - return
84 -}
85 -
86 -// File returns an os.File against an existing file.
87 -func (p *parserMixin) File() (target **os.File) {
88 - target = new(*os.File)
89 - p.FileVar(target)
90 - return
91 -}
92 -
93 -// File attempts to open a File with os.OpenFile(flag, perm).
94 -func (p *parserMixin) OpenFile(flag int, perm os.FileMode) (target **os.File) {
95 - target = new(*os.File)
96 - p.OpenFileVar(target, flag, perm)
97 - return
98 -}
99 -
100 -// URL provides a valid, parsed url.URL.
101 -func (p *parserMixin) URL() (target **url.URL) {
102 - target = new(*url.URL)
103 - p.URLVar(target)
104 - return
105 -}
106 -
107 -// StringMap provides key=value parsing into a map.
108 -func (p *parserMixin) StringMapVar(target *map[string]string) {
109 - p.SetValue(newStringMapValue(target))
110 -}
111 -
112 -// Float sets the parser to a float64 parser.
113 -func (p *parserMixin) Float() (target *float64) {
114 - return p.Float64()
115 -}
116 -
117 -// Float sets the parser to a float64 parser.
118 -func (p *parserMixin) FloatVar(target *float64) {
119 - p.Float64Var(target)
120 -}
121 -
122 -// Duration sets the parser to a time.Duration parser.
123 -func (p *parserMixin) DurationVar(target *time.Duration) {
124 - p.SetValue(newDurationValue(target))
125 -}
126 -
127 -// BytesVar parses numeric byte units. eg. 1.5KB
128 -func (p *parserMixin) BytesVar(target *units.Base2Bytes) {
129 - p.SetValue(newBytesValue(target))
130 -}
131 -
132 -// IP sets the parser to a net.IP parser.
133 -func (p *parserMixin) IPVar(target *net.IP) {
134 - p.SetValue(newIPValue(target))
135 -}
136 -
137 -// ExistingFile sets the parser to one that requires and returns an existing file.
138 -func (p *parserMixin) ExistingFileVar(target *string) {
139 - p.SetValue(newExistingFileValue(target))
140 -}
141 -
142 -// ExistingDir sets the parser to one that requires and returns an existing directory.
143 -func (p *parserMixin) ExistingDirVar(target *string) {
144 - p.SetValue(newExistingDirValue(target))
145 -}
146 -
147 -// ExistingDir sets the parser to one that requires and returns an existing directory.
148 -func (p *parserMixin) ExistingFileOrDirVar(target *string) {
149 - p.SetValue(newExistingFileOrDirValue(target))
150 -}
151 -
152 -// FileVar opens an existing file.
153 -func (p *parserMixin) FileVar(target **os.File) {
154 - p.SetValue(newFileValue(target, os.O_RDONLY, 0))
155 -}
156 -
157 -// OpenFileVar calls os.OpenFile(flag, perm)
158 -func (p *parserMixin) OpenFileVar(target **os.File, flag int, perm os.FileMode) {
159 - p.SetValue(newFileValue(target, flag, perm))
160 -}
161 -
162 -// URL provides a valid, parsed url.URL.
163 -func (p *parserMixin) URLVar(target **url.URL) {
164 - p.SetValue(newURLValue(target))
165 -}
166 -
167 -// URLList provides a parsed list of url.URL values.
168 -func (p *parserMixin) URLList() (target *[]*url.URL) {
169 - target = new([]*url.URL)
170 - p.URLListVar(target)
171 - return
172 -}
173 -
174 -// URLListVar provides a parsed list of url.URL values.
175 -func (p *parserMixin) URLListVar(target *[]*url.URL) {
176 - p.SetValue(newURLListValue(target))
177 -}
178 -
179 -// Enum allows a value from a set of options.
180 -func (p *parserMixin) Enum(options ...string) (target *string) {
181 - target = new(string)
182 - p.EnumVar(target, options...)
183 - return
184 -}
185 -
186 -// EnumVar allows a value from a set of options.
187 -func (p *parserMixin) EnumVar(target *string, options ...string) {
188 - p.SetValue(newEnumFlag(target, options...))
189 -}
190 -
191 -// Enums allows a set of values from a set of options.
192 -func (p *parserMixin) Enums(options ...string) (target *[]string) {
193 - target = new([]string)
194 - p.EnumsVar(target, options...)
195 - return
196 -}
197 -
198 -// EnumVar allows a value from a set of options.
199 -func (p *parserMixin) EnumsVar(target *[]string, options ...string) {
200 - p.SetValue(newEnumsFlag(target, options...))
201 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/parsers_test.go deleted
-98
@@ -1,98 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "io/ioutil"
5 - "net"
6 - "net/url"
7 - "os"
8 -
9 - "gx/ipfs/QmZwjfAKWe7vWZ8f48u7AGA1xYfzR1iCD9A2XSCYFRBWot/testify/assert"
10 -
11 - "testing"
12 -)
13 -
14 -func TestParseStrings(t *testing.T) {
15 - p := parserMixin{}
16 - v := p.Strings()
17 - p.value.Set("a")
18 - p.value.Set("b")
19 - assert.Equal(t, []string{"a", "b"}, *v)
20 -}
21 -
22 -func TestStringsStringer(t *testing.T) {
23 - target := []string{}
24 - v := newAccumulator(&target, func(v interface{}) Value { return newStringValue(v.(*string)) })
25 - v.Set("hello")
26 - v.Set("world")
27 - assert.Equal(t, "hello,world", v.String())
28 -}
29 -
30 -func TestParseStringMap(t *testing.T) {
31 - p := parserMixin{}
32 - v := p.StringMap()
33 - p.value.Set("a:b")
34 - p.value.Set("b:c")
35 - assert.Equal(t, map[string]string{"a": "b", "b": "c"}, *v)
36 -}
37 -
38 -func TestParseIP(t *testing.T) {
39 - p := parserMixin{}
40 - v := p.IP()
41 - p.value.Set("10.1.1.2")
42 - ip := net.ParseIP("10.1.1.2")
43 - assert.Equal(t, ip, *v)
44 -}
45 -
46 -func TestParseURL(t *testing.T) {
47 - p := parserMixin{}
48 - v := p.URL()
49 - p.value.Set("http://w3.org")
50 - u, err := url.Parse("http://w3.org")
51 - assert.NoError(t, err)
52 - assert.Equal(t, *u, **v)
53 -}
54 -
55 -func TestParseExistingFile(t *testing.T) {
56 - f, err := ioutil.TempFile("", "")
57 - if err != nil {
58 - t.Fatal(err)
59 - }
60 - defer f.Close()
61 - defer os.Remove(f.Name())
62 -
63 - p := parserMixin{}
64 - v := p.ExistingFile()
65 - err = p.value.Set(f.Name())
66 - assert.NoError(t, err)
67 - assert.Equal(t, f.Name(), *v)
68 - err = p.value.Set("/etc/hostsDEFINITELYMISSING")
69 - assert.Error(t, err)
70 -}
71 -
72 -func TestParseTCPAddr(t *testing.T) {
73 - p := parserMixin{}
74 - v := p.TCP()
75 - err := p.value.Set("127.0.0.1:1234")
76 - assert.NoError(t, err)
77 - expected, err := net.ResolveTCPAddr("tcp", "127.0.0.1:1234")
78 - assert.NoError(t, err)
79 - assert.Equal(t, *expected, **v)
80 -}
81 -
82 -func TestParseTCPAddrList(t *testing.T) {
83 - p := parserMixin{}
84 - _ = p.TCPList()
85 - err := p.value.Set("127.0.0.1:1234")
86 - assert.NoError(t, err)
87 - err = p.value.Set("127.0.0.1:1235")
88 - assert.NoError(t, err)
89 - assert.Equal(t, "127.0.0.1:1234,127.0.0.1:1235", p.value.String())
90 -}
91 -
92 -func TestFloat32(t *testing.T) {
93 - p := parserMixin{}
94 - v := p.Float32()
95 - err := p.value.Set("123.45")
96 - assert.NoError(t, err)
97 - assert.InEpsilon(t, 123.45, *v, 0.001)
98 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/templates.go deleted
-233
@@ -1,233 +0,0 @@
1 -package kingpin
2 -
3 -// Default usage template.
4 -var DefaultUsageTemplate = `{{define "FormatCommand"}}\
5 -{{if .FlagSummary}} {{.FlagSummary}}{{end}}\
6 -{{range .Args}} {{if not .Required}}[{{end}}<{{.Name}}>{{if .Value|IsCumulative}}...{{end}}{{if not .Required}}]{{end}}{{end}}\
7 -{{end}}\
8 -
9 -{{define "FormatCommands"}}\
10 -{{range .FlattenedCommands}}\
11 -{{if not .Hidden}}\
12 - {{.FullCommand}}{{if .Default}}*{{end}}{{template "FormatCommand" .}}
13 -{{.Help|Wrap 4}}
14 -{{end}}\
15 -{{end}}\
16 -{{end}}\
17 -
18 -{{define "FormatUsage"}}\
19 -{{template "FormatCommand" .}}{{if .Commands}} <command> [<args> ...]{{end}}
20 -{{if .Help}}
21 -{{.Help|Wrap 0}}\
22 -{{end}}\
23 -
24 -{{end}}\
25 -
26 -{{if .Context.SelectedCommand}}\
27 -usage: {{.App.Name}} {{.Context.SelectedCommand}}{{template "FormatUsage" .Context.SelectedCommand}}
28 -{{else}}\
29 -usage: {{.App.Name}}{{template "FormatUsage" .App}}
30 -{{end}}\
31 -{{if .Context.Flags}}\
32 -Flags:
33 -{{.Context.Flags|FlagsToTwoColumns|FormatTwoColumns}}
34 -{{end}}\
35 -{{if .Context.Args}}\
36 -Args:
37 -{{.Context.Args|ArgsToTwoColumns|FormatTwoColumns}}
38 -{{end}}\
39 -{{if .Context.SelectedCommand}}\
40 -Subcommands:
41 -{{if .Context.SelectedCommand.Commands}}\
42 -{{template "FormatCommands" .Context.SelectedCommand}}
43 -{{end}}\
44 -{{else if .App.Commands}}\
45 -Commands:
46 -{{template "FormatCommands" .App}}
47 -{{end}}\
48 -`
49 -
50 -// Usage template where command's optional flags are listed separately
51 -var SeparateOptionalFlagsUsageTemplate = `{{define "FormatCommand"}}\
52 -{{if .FlagSummary}} {{.FlagSummary}}{{end}}\
53 -{{range .Args}} {{if not .Required}}[{{end}}<{{.Name}}>{{if .Value|IsCumulative}}...{{end}}{{if not .Required}}]{{end}}{{end}}\
54 -{{end}}\
55 -
56 -{{define "FormatCommands"}}\
57 -{{range .FlattenedCommands}}\
58 -{{if not .Hidden}}\
59 - {{.FullCommand}}{{if .Default}}*{{end}}{{template "FormatCommand" .}}
60 -{{.Help|Wrap 4}}
61 -{{end}}\
62 -{{end}}\
63 -{{end}}\
64 -
65 -{{define "FormatUsage"}}\
66 -{{template "FormatCommand" .}}{{if .Commands}} <command> [<args> ...]{{end}}
67 -{{if .Help}}
68 -{{.Help|Wrap 0}}\
69 -{{end}}\
70 -
71 -{{end}}\
72 -{{if .Context.SelectedCommand}}\
73 -usage: {{.App.Name}} {{.Context.SelectedCommand}}{{template "FormatUsage" .Context.SelectedCommand}}
74 -{{else}}\
75 -usage: {{.App.Name}}{{template "FormatUsage" .App}}
76 -{{end}}\
77 -
78 -{{if .Context.Flags|RequiredFlags}}\
79 -Required flags:
80 -{{.Context.Flags|RequiredFlags|FlagsToTwoColumns|FormatTwoColumns}}
81 -{{end}}\
82 -{{if .Context.Flags|OptionalFlags}}\
83 -Optional flags:
84 -{{.Context.Flags|OptionalFlags|FlagsToTwoColumns|FormatTwoColumns}}
85 -{{end}}\
86 -{{if .Context.Args}}\
87 -Args:
88 -{{.Context.Args|ArgsToTwoColumns|FormatTwoColumns}}
89 -{{end}}\
90 -{{if .Context.SelectedCommand}}\
91 -Subcommands:
92 -{{if .Context.SelectedCommand.Commands}}\
93 -{{template "FormatCommands" .Context.SelectedCommand}}
94 -{{end}}\
95 -{{else if .App.Commands}}\
96 -Commands:
97 -{{template "FormatCommands" .App}}
98 -{{end}}\
99 -`
100 -
101 -// Usage template with compactly formatted commands.
102 -var CompactUsageTemplate = `{{define "FormatCommand"}}\
103 -{{if .FlagSummary}} {{.FlagSummary}}{{end}}\
104 -{{range .Args}} {{if not .Required}}[{{end}}<{{.Name}}>{{if .Value|IsCumulative}}...{{end}}{{if not .Required}}]{{end}}{{end}}\
105 -{{end}}\
106 -
107 -{{define "FormatCommandList"}}\
108 -{{range .}}\
109 -{{if not .Hidden}}\
110 -{{.Depth|Indent}}{{.Name}}{{if .Default}}*{{end}}{{template "FormatCommand" .}}
111 -{{end}}\
112 -{{template "FormatCommandList" .Commands}}\
113 -{{end}}\
114 -{{end}}\
115 -
116 -{{define "FormatUsage"}}\
117 -{{template "FormatCommand" .}}{{if .Commands}} <command> [<args> ...]{{end}}
118 -{{if .Help}}
119 -{{.Help|Wrap 0}}\
120 -{{end}}\
121 -
122 -{{end}}\
123 -
124 -{{if .Context.SelectedCommand}}\
125 -usage: {{.App.Name}} {{.Context.SelectedCommand}}{{template "FormatUsage" .Context.SelectedCommand}}
126 -{{else}}\
127 -usage: {{.App.Name}}{{template "FormatUsage" .App}}
128 -{{end}}\
129 -{{if .Context.Flags}}\
130 -Flags:
131 -{{.Context.Flags|FlagsToTwoColumns|FormatTwoColumns}}
132 -{{end}}\
133 -{{if .Context.Args}}\
134 -Args:
135 -{{.Context.Args|ArgsToTwoColumns|FormatTwoColumns}}
136 -{{end}}\
137 -{{if .Context.SelectedCommand}}\
138 -{{if .Context.SelectedCommand.Commands}}\
139 -Commands:
140 - {{.Context.SelectedCommand}}
141 -{{template "FormatCommandList" .Context.SelectedCommand.Commands}}
142 -{{end}}\
143 -{{else if .App.Commands}}\
144 -Commands:
145 -{{template "FormatCommandList" .App.Commands}}
146 -{{end}}\
147 -`
148 -
149 -var ManPageTemplate = `{{define "FormatFlags"}}\
150 -{{range .Flags}}\
151 -{{if not .Hidden}}\
152 -.TP
153 -\fB{{if .Short}}-{{.Short|Char}}, {{end}}--{{.Name}}{{if not .IsBoolFlag}}={{.FormatPlaceHolder}}{{end}}\\fR
154 -{{.Help}}
155 -{{end}}\
156 -{{end}}\
157 -{{end}}\
158 -
159 -{{define "FormatCommand"}}\
160 -{{if .FlagSummary}} {{.FlagSummary}}{{end}}\
161 -{{range .Args}} {{if not .Required}}[{{end}}<{{.Name}}{{if .Default}}*{{end}}>{{if .Value|IsCumulative}}...{{end}}{{if not .Required}}]{{end}}{{end}}\
162 -{{end}}\
163 -
164 -{{define "FormatCommands"}}\
165 -{{range .FlattenedCommands}}\
166 -{{if not .Hidden}}\
167 -.SS
168 -\fB{{.FullCommand}}{{template "FormatCommand" .}}\\fR
169 -.PP
170 -{{.Help}}
171 -{{template "FormatFlags" .}}\
172 -{{end}}\
173 -{{end}}\
174 -{{end}}\
175 -
176 -{{define "FormatUsage"}}\
177 -{{template "FormatCommand" .}}{{if .Commands}} <command> [<args> ...]{{end}}\\fR
178 -{{end}}\
179 -
180 -.TH {{.App.Name}} 1 {{.App.Version}} "{{.App.Author}}"
181 -.SH "NAME"
182 -{{.App.Name}}
183 -.SH "SYNOPSIS"
184 -.TP
185 -\fB{{.App.Name}}{{template "FormatUsage" .App}}
186 -.SH "DESCRIPTION"
187 -{{.App.Help}}
188 -.SH "OPTIONS"
189 -{{template "FormatFlags" .App}}\
190 -{{if .App.Commands}}\
191 -.SH "COMMANDS"
192 -{{template "FormatCommands" .App}}\
193 -{{end}}\
194 -`
195 -
196 -// Default usage template.
197 -var LongHelpTemplate = `{{define "FormatCommand"}}\
198 -{{if .FlagSummary}} {{.FlagSummary}}{{end}}\
199 -{{range .Args}} {{if not .Required}}[{{end}}<{{.Name}}>{{if .Value|IsCumulative}}...{{end}}{{if not .Required}}]{{end}}{{end}}\
200 -{{end}}\
201 -
202 -{{define "FormatCommands"}}\
203 -{{range .FlattenedCommands}}\
204 -{{if not .Hidden}}\
205 - {{.FullCommand}}{{template "FormatCommand" .}}
206 -{{.Help|Wrap 4}}
207 -{{with .Flags|FlagsToTwoColumns}}{{FormatTwoColumnsWithIndent . 4 2}}{{end}}
208 -{{end}}\
209 -{{end}}\
210 -{{end}}\
211 -
212 -{{define "FormatUsage"}}\
213 -{{template "FormatCommand" .}}{{if .Commands}} <command> [<args> ...]{{end}}
214 -{{if .Help}}
215 -{{.Help|Wrap 0}}\
216 -{{end}}\
217 -
218 -{{end}}\
219 -
220 -usage: {{.App.Name}}{{template "FormatUsage" .App}}
221 -{{if .Context.Flags}}\
222 -Flags:
223 -{{.Context.Flags|FlagsToTwoColumns|FormatTwoColumns}}
224 -{{end}}\
225 -{{if .Context.Args}}\
226 -Args:
227 -{{.Context.Args|ArgsToTwoColumns|FormatTwoColumns}}
228 -{{end}}\
229 -{{if .App.Commands}}\
230 -Commands:
231 -{{template "FormatCommands" .App}}
232 -{{end}}\
233 -`
Godeps/_workspace/src/github.com/alecthomas/kingpin/usage.go deleted
-208
@@ -1,208 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "bytes"
5 - "fmt"
6 - "go/doc"
7 - "io"
8 - "strings"
9 -
10 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/template"
11 -)
12 -
13 -var (
14 - preIndent = " "
15 -)
16 -
17 -func formatTwoColumns(w io.Writer, indent, padding, width int, rows [][2]string) {
18 - // Find size of first column.
19 - s := 0
20 - for _, row := range rows {
21 - if c := len(row[0]); c > s && c < 30 {
22 - s = c
23 - }
24 - }
25 -
26 - indentStr := strings.Repeat(" ", indent)
27 - offsetStr := strings.Repeat(" ", s+padding)
28 -
29 - for _, row := range rows {
30 - buf := bytes.NewBuffer(nil)
31 - doc.ToText(buf, row[1], "", preIndent, width-s-padding-indent)
32 - lines := strings.Split(strings.TrimRight(buf.String(), "\n"), "\n")
33 - fmt.Fprintf(w, "%s%-*s%*s", indentStr, s, row[0], padding, "")
34 - if len(row[0]) >= 30 {
35 - fmt.Fprintf(w, "\n%s%s", indentStr, offsetStr)
36 - }
37 - fmt.Fprintf(w, "%s\n", lines[0])
38 - for _, line := range lines[1:] {
39 - fmt.Fprintf(w, "%s%s%s\n", indentStr, offsetStr, line)
40 - }
41 - }
42 -}
43 -
44 -// Usage writes application usage to w. It parses args to determine
45 -// appropriate help context, such as which command to show help for.
46 -func (a *Application) Usage(args []string) {
47 - context, err := a.ParseContext(args)
48 - a.FatalIfError(err, "")
49 - if err := a.UsageForContextWithTemplate(context, 2, a.usageTemplate); err != nil {
50 - panic(err)
51 - }
52 -}
53 -
54 -func formatAppUsage(app *ApplicationModel) string {
55 - s := []string{app.Name}
56 - if len(app.Flags) > 0 {
57 - s = append(s, app.FlagSummary())
58 - }
59 - if len(app.Args) > 0 {
60 - s = append(s, app.ArgSummary())
61 - }
62 - return strings.Join(s, " ")
63 -}
64 -
65 -func formatCmdUsage(app *ApplicationModel, cmd *CmdModel) string {
66 - s := []string{app.Name, cmd.String()}
67 - if len(app.Flags) > 0 {
68 - s = append(s, app.FlagSummary())
69 - }
70 - if len(app.Args) > 0 {
71 - s = append(s, app.ArgSummary())
72 - }
73 - return strings.Join(s, " ")
74 -}
75 -
76 -func formatFlag(haveShort bool, flag *FlagModel) string {
77 - flagString := ""
78 - if flag.Short != 0 {
79 - flagString += fmt.Sprintf("-%c, --%s", flag.Short, flag.Name)
80 - } else {
81 - if haveShort {
82 - flagString += fmt.Sprintf(" --%s", flag.Name)
83 - } else {
84 - flagString += fmt.Sprintf("--%s", flag.Name)
85 - }
86 - }
87 - if !flag.IsBoolFlag() {
88 - flagString += fmt.Sprintf("=%s", flag.FormatPlaceHolder())
89 - }
90 - return flagString
91 -}
92 -
93 -type templateParseContext struct {
94 - SelectedCommand *CmdModel
95 - *FlagGroupModel
96 - *ArgGroupModel
97 -}
98 -
99 -type templateContext struct {
100 - App *ApplicationModel
101 - Width int
102 - Context *templateParseContext
103 -}
104 -
105 -// UsageForContext displays usage information from a ParseContext (obtained from
106 -// Application.ParseContext() or Action(f) callbacks).
107 -func (a *Application) UsageForContext(context *ParseContext) error {
108 - return a.UsageForContextWithTemplate(context, 2, a.usageTemplate)
109 -}
110 -
111 -// UsageForContextWithTemplate is the base usage function. You generally don't need to use this.
112 -func (a *Application) UsageForContextWithTemplate(context *ParseContext, indent int, tmpl string) error {
113 - width := guessWidth(a.writer)
114 - funcs := template.FuncMap{
115 - "Indent": func(level int) string {
116 - return strings.Repeat(" ", level*indent)
117 - },
118 - "Wrap": func(indent int, s string) string {
119 - buf := bytes.NewBuffer(nil)
120 - indentText := strings.Repeat(" ", indent)
121 - doc.ToText(buf, s, indentText, indentText, width)
122 - return buf.String()
123 - },
124 - "FormatFlag": formatFlag,
125 - "FlagsToTwoColumns": func(f []*FlagModel) [][2]string {
126 - rows := [][2]string{}
127 - haveShort := false
128 - for _, flag := range f {
129 - if flag.Short != 0 {
130 - haveShort = true
131 - break
132 - }
133 - }
134 - for _, flag := range f {
135 - if !flag.Hidden {
136 - rows = append(rows, [2]string{formatFlag(haveShort, flag), flag.Help})
137 - }
138 - }
139 - return rows
140 - },
141 - "RequiredFlags": func(f []*FlagModel) []*FlagModel {
142 - requiredFlags := []*FlagModel{}
143 - for _, flag := range f {
144 - if flag.Required == true {
145 - requiredFlags = append(requiredFlags, flag)
146 - }
147 - }
148 - return requiredFlags
149 - },
150 - "OptionalFlags": func(f []*FlagModel) []*FlagModel {
151 - optionalFlags := []*FlagModel{}
152 - for _, flag := range f {
153 - if flag.Required == false {
154 - optionalFlags = append(optionalFlags, flag)
155 - }
156 - }
157 - return optionalFlags
158 - },
159 - "ArgsToTwoColumns": func(a []*ArgModel) [][2]string {
160 - rows := [][2]string{}
161 - for _, arg := range a {
162 - s := "<" + arg.Name + ">"
163 - if !arg.Required {
164 - s = "[" + s + "]"
165 - }
166 - rows = append(rows, [2]string{s, arg.Help})
167 - }
168 - return rows
169 - },
170 - "FormatTwoColumns": func(rows [][2]string) string {
171 - buf := bytes.NewBuffer(nil)
172 - formatTwoColumns(buf, indent, indent, width, rows)
173 - return buf.String()
174 - },
175 - "FormatTwoColumnsWithIndent": func(rows [][2]string, indent, padding int) string {
176 - buf := bytes.NewBuffer(nil)
177 - formatTwoColumns(buf, indent, padding, width, rows)
178 - return buf.String()
179 - },
180 - "FormatAppUsage": formatAppUsage,
181 - "FormatCommandUsage": formatCmdUsage,
182 - "IsCumulative": func(value Value) bool {
183 - _, ok := value.(remainderArg)
184 - return ok
185 - },
186 - "Char": func(c rune) string {
187 - return string(c)
188 - },
189 - }
190 - t, err := template.New("usage").Funcs(funcs).Parse(tmpl)
191 - if err != nil {
192 - return err
193 - }
194 - var selectedCommand *CmdModel
195 - if context.SelectedCommand != nil {
196 - selectedCommand = context.SelectedCommand.Model()
197 - }
198 - ctx := templateContext{
199 - App: a.Model(),
200 - Width: width,
201 - Context: &templateParseContext{
202 - SelectedCommand: selectedCommand,
203 - FlagGroupModel: context.flags.Model(),
204 - ArgGroupModel: context.arguments.Model(),
205 - },
206 - }
207 - return t.Execute(a.writer, ctx)
208 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/usage_test.go deleted
-65
@@ -1,65 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "bytes"
5 - "strings"
6 - "testing"
7 -
8 - "gx/ipfs/QmZwjfAKWe7vWZ8f48u7AGA1xYfzR1iCD9A2XSCYFRBWot/testify/assert"
9 -)
10 -
11 -func TestFormatTwoColumns(t *testing.T) {
12 - buf := bytes.NewBuffer(nil)
13 - formatTwoColumns(buf, 2, 2, 20, [][2]string{
14 - {"--hello", "Hello world help with something that is cool."},
15 - })
16 - expected := ` --hello Hello
17 - world
18 - help with
19 - something
20 - that is
21 - cool.
22 -`
23 - assert.Equal(t, expected, buf.String())
24 -}
25 -
26 -func TestFormatTwoColumnsWide(t *testing.T) {
27 - samples := [][2]string{
28 - {strings.Repeat("x", 29), "29 chars"},
29 - {strings.Repeat("x", 30), "30 chars"}}
30 - buf := bytes.NewBuffer(nil)
31 - formatTwoColumns(buf, 0, 0, 200, samples)
32 - expected := `xxxxxxxxxxxxxxxxxxxxxxxxxxxxx29 chars
33 -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
34 - 30 chars
35 -`
36 - assert.Equal(t, expected, buf.String())
37 -}
38 -
39 -func TestHiddenCommand(t *testing.T) {
40 - templates := []struct{ name, template string }{
41 - {"default", DefaultUsageTemplate},
42 - {"Compact", CompactUsageTemplate},
43 - {"Long", LongHelpTemplate},
44 - {"Man", ManPageTemplate},
45 - }
46 -
47 - var buf bytes.Buffer
48 - t.Log("1")
49 -
50 - a := New("test", "Test").Writer(&buf).Terminate(nil)
51 - a.Command("visible", "visible")
52 - a.Command("hidden", "hidden").Hidden()
53 -
54 - for _, tp := range templates {
55 - buf.Reset()
56 - a.UsageTemplate(tp.template)
57 - a.Parse(nil)
58 - // a.Parse([]string{"--help"})
59 - usage := buf.String()
60 - t.Logf("Usage for %s is:\n%s\n", tp.name, usage)
61 -
62 - assert.NotContains(t, usage, "hidden")
63 - assert.Contains(t, usage, "visible")
64 - }
65 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/values.go deleted
-391
@@ -1,391 +0,0 @@
1 -package kingpin
2 -
3 -//go:generate go run ./cmd/genvalues/main.go
4 -
5 -import (
6 - "fmt"
7 - "net"
8 - "net/url"
9 - "os"
10 - "reflect"
11 - "regexp"
12 - "strings"
13 - "time"
14 -
15 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/units"
16 -)
17 -
18 -// NOTE: Most of the base type values were lifted from:
19 -// http://golang.org/src/pkg/flag/flag.go?s=20146:20222
20 -
21 -// Value is the interface to the dynamic value stored in a flag.
22 -// (The default value is represented as a string.)
23 -//
24 -// If a Value has an IsBoolFlag() bool method returning true, the command-line
25 -// parser makes --name equivalent to -name=true rather than using the next
26 -// command-line argument, and adds a --no-name counterpart for negating the
27 -// flag.
28 -type Value interface {
29 - String() string
30 - Set(string) error
31 -}
32 -
33 -// Getter is an interface that allows the contents of a Value to be retrieved.
34 -// It wraps the Value interface, rather than being part of it, because it
35 -// appeared after Go 1 and its compatibility rules. All Value types provided
36 -// by this package satisfy the Getter interface.
37 -type Getter interface {
38 - Value
39 - Get() interface{}
40 -}
41 -
42 -// Optional interface to indicate boolean flags that don't accept a value, and
43 -// implicitly have a --no-<x> negation counterpart.
44 -type boolFlag interface {
45 - Value
46 - IsBoolFlag() bool
47 -}
48 -
49 -// Optional interface for arguments that cumulatively consume all remaining
50 -// input.
51 -type remainderArg interface {
52 - Value
53 - IsCumulative() bool
54 -}
55 -
56 -type accumulator struct {
57 - element func(value interface{}) Value
58 - typ reflect.Type
59 - slice reflect.Value
60 -}
61 -
62 -// Use reflection to accumulate values into a slice.
63 -//
64 -// target := []string{}
65 -// newAccumulator(&target, func (value interface{}) Value {
66 -// return newStringValue(value.(*string))
67 -// })
68 -func newAccumulator(slice interface{}, element func(value interface{}) Value) *accumulator {
69 - typ := reflect.TypeOf(slice)
70 - if typ.Kind() != reflect.Ptr || typ.Elem().Kind() != reflect.Slice {
71 - panic("expected a pointer to a slice")
72 - }
73 - return &accumulator{
74 - element: element,
75 - typ: typ.Elem().Elem(),
76 - slice: reflect.ValueOf(slice),
77 - }
78 -}
79 -
80 -func (a *accumulator) String() string {
81 - out := []string{}
82 - s := a.slice.Elem()
83 - for i := 0; i < s.Len(); i++ {
84 - out = append(out, a.element(s.Index(i).Addr().Interface()).String())
85 - }
86 - return strings.Join(out, ",")
87 -}
88 -
89 -func (a *accumulator) Set(value string) error {
90 - e := reflect.New(a.typ)
91 - if err := a.element(e.Interface()).Set(value); err != nil {
92 - return err
93 - }
94 - slice := reflect.Append(a.slice.Elem(), e.Elem())
95 - a.slice.Elem().Set(slice)
96 - return nil
97 -}
98 -
99 -func (a *accumulator) IsCumulative() bool {
100 - return true
101 -}
102 -
103 -func (b *boolValue) IsBoolFlag() bool { return true }
104 -
105 -// -- time.Duration Value
106 -type durationValue time.Duration
107 -
108 -func newDurationValue(p *time.Duration) *durationValue {
109 - return (*durationValue)(p)
110 -}
111 -
112 -func (d *durationValue) Set(s string) error {
113 - v, err := time.ParseDuration(s)
114 - *d = durationValue(v)
115 - return err
116 -}
117 -
118 -func (d *durationValue) Get() interface{} { return time.Duration(*d) }
119 -
120 -func (d *durationValue) String() string { return (*time.Duration)(d).String() }
121 -
122 -// -- map[string]string Value
123 -type stringMapValue map[string]string
124 -
125 -func newStringMapValue(p *map[string]string) *stringMapValue {
126 - return (*stringMapValue)(p)
127 -}
128 -
129 -var stringMapRegex = regexp.MustCompile("[:=]")
130 -
131 -func (s *stringMapValue) Set(value string) error {
132 - parts := stringMapRegex.Split(value, 2)
133 - if len(parts) != 2 {
134 - return fmt.Errorf("expected KEY=VALUE got '%s'", value)
135 - }
136 - (*s)[parts[0]] = parts[1]
137 - return nil
138 -}
139 -func (s *stringMapValue) String() string {
140 - return fmt.Sprintf("%s", map[string]string(*s))
141 -}
142 -
143 -func (s *stringMapValue) IsCumulative() bool {
144 - return true
145 -}
146 -
147 -// -- net.IP Value
148 -type ipValue net.IP
149 -
150 -func newIPValue(p *net.IP) *ipValue {
151 - return (*ipValue)(p)
152 -}
153 -
154 -func (i *ipValue) Set(value string) error {
155 - if ip := net.ParseIP(value); ip == nil {
156 - return fmt.Errorf("'%s' is not an IP address", value)
157 - } else {
158 - *i = *(*ipValue)(&ip)
159 - return nil
160 - }
161 -}
162 -
163 -func (i *ipValue) String() string {
164 - return (*net.IP)(i).String()
165 -}
166 -
167 -// -- *net.TCPAddr Value
168 -type tcpAddrValue struct {
169 - addr **net.TCPAddr
170 -}
171 -
172 -func newTCPAddrValue(p **net.TCPAddr) *tcpAddrValue {
173 - return &tcpAddrValue{p}
174 -}
175 -
176 -func (i *tcpAddrValue) Set(value string) error {
177 - if addr, err := net.ResolveTCPAddr("tcp", value); err != nil {
178 - return fmt.Errorf("'%s' is not a valid TCP address: %s", value, err)
179 - } else {
180 - *i.addr = addr
181 - return nil
182 - }
183 -}
184 -
185 -func (i *tcpAddrValue) String() string {
186 - return (*i.addr).String()
187 -}
188 -
189 -// -- existingFile Value
190 -
191 -type fileStatValue struct {
192 - path *string
193 - predicate func(os.FileInfo) error
194 -}
195 -
196 -func newFileStatValue(p *string, predicate func(os.FileInfo) error) *fileStatValue {
197 - return &fileStatValue{
198 - path: p,
199 - predicate: predicate,
200 - }
201 -}
202 -
203 -func (e *fileStatValue) Set(value string) error {
204 - if s, err := os.Stat(value); os.IsNotExist(err) {
205 - return fmt.Errorf("path '%s' does not exist", value)
206 - } else if err != nil {
207 - return err
208 - } else if err := e.predicate(s); err != nil {
209 - return err
210 - }
211 - *e.path = value
212 - return nil
213 -}
214 -
215 -func (e *fileStatValue) String() string {
216 - return *e.path
217 -}
218 -
219 -// -- os.File value
220 -
221 -type fileValue struct {
222 - f **os.File
223 - flag int
224 - perm os.FileMode
225 -}
226 -
227 -func newFileValue(p **os.File, flag int, perm os.FileMode) *fileValue {
228 - return &fileValue{p, flag, perm}
229 -}
230 -
231 -func (f *fileValue) Set(value string) error {
232 - if fd, err := os.OpenFile(value, f.flag, f.perm); err != nil {
233 - return err
234 - } else {
235 - *f.f = fd
236 - return nil
237 - }
238 -}
239 -
240 -func (f *fileValue) String() string {
241 - if *f.f == nil {
242 - return "<nil>"
243 - }
244 - return (*f.f).Name()
245 -}
246 -
247 -// -- url.URL Value
248 -type urlValue struct {
249 - u **url.URL
250 -}
251 -
252 -func newURLValue(p **url.URL) *urlValue {
253 - return &urlValue{p}
254 -}
255 -
256 -func (u *urlValue) Set(value string) error {
257 - if url, err := url.Parse(value); err != nil {
258 - return fmt.Errorf("invalid URL: %s", err)
259 - } else {
260 - *u.u = url
261 - return nil
262 - }
263 -}
264 -
265 -func (u *urlValue) String() string {
266 - if *u.u == nil {
267 - return "<nil>"
268 - }
269 - return (*u.u).String()
270 -}
271 -
272 -// -- []*url.URL Value
273 -type urlListValue []*url.URL
274 -
275 -func newURLListValue(p *[]*url.URL) *urlListValue {
276 - return (*urlListValue)(p)
277 -}
278 -
279 -func (u *urlListValue) Set(value string) error {
280 - if url, err := url.Parse(value); err != nil {
281 - return fmt.Errorf("invalid URL: %s", err)
282 - } else {
283 - *u = append(*u, url)
284 - return nil
285 - }
286 -}
287 -
288 -func (u *urlListValue) String() string {
289 - out := []string{}
290 - for _, url := range *u {
291 - out = append(out, url.String())
292 - }
293 - return strings.Join(out, ",")
294 -}
295 -
296 -// A flag whose value must be in a set of options.
297 -type enumValue struct {
298 - value *string
299 - options []string
300 -}
301 -
302 -func newEnumFlag(target *string, options ...string) *enumValue {
303 - return &enumValue{
304 - value: target,
305 - options: options,
306 - }
307 -}
308 -
309 -func (a *enumValue) String() string {
310 - return *a.value
311 -}
312 -
313 -func (a *enumValue) Set(value string) error {
314 - for _, v := range a.options {
315 - if v == value {
316 - *a.value = value
317 - return nil
318 - }
319 - }
320 - return fmt.Errorf("enum value must be one of %s, got '%s'", strings.Join(a.options, ","), value)
321 -}
322 -
323 -// -- []string Enum Value
324 -type enumsValue struct {
325 - value *[]string
326 - options []string
327 -}
328 -
329 -func newEnumsFlag(target *[]string, options ...string) *enumsValue {
330 - return &enumsValue{
331 - value: target,
332 - options: options,
333 - }
334 -}
335 -
336 -func (s *enumsValue) Set(value string) error {
337 - for _, v := range s.options {
338 - if v == value {
339 - *s.value = append(*s.value, value)
340 - return nil
341 - }
342 - }
343 - return fmt.Errorf("enum value must be one of %s, got '%s'", strings.Join(s.options, ","), value)
344 -}
345 -
346 -func (s *enumsValue) String() string {
347 - return strings.Join(*s.value, ",")
348 -}
349 -
350 -func (s *enumsValue) IsCumulative() bool {
351 - return true
352 -}
353 -
354 -// -- units.Base2Bytes Value
355 -type bytesValue units.Base2Bytes
356 -
357 -func newBytesValue(p *units.Base2Bytes) *bytesValue {
358 - return (*bytesValue)(p)
359 -}
360 -
361 -func (d *bytesValue) Set(s string) error {
362 - v, err := units.ParseBase2Bytes(s)
363 - *d = bytesValue(v)
364 - return err
365 -}
366 -
367 -func (d *bytesValue) Get() interface{} { return units.Base2Bytes(*d) }
368 -
369 -func (d *bytesValue) String() string { return (*units.Base2Bytes)(d).String() }
370 -
371 -func newExistingFileValue(target *string) *fileStatValue {
372 - return newFileStatValue(target, func(s os.FileInfo) error {
373 - if s.IsDir() {
374 - return fmt.Errorf("'%s' is a directory", s.Name())
375 - }
376 - return nil
377 - })
378 -}
379 -
380 -func newExistingDirValue(target *string) *fileStatValue {
381 - return newFileStatValue(target, func(s os.FileInfo) error {
382 - if !s.IsDir() {
383 - return fmt.Errorf("'%s' is a file", s.Name())
384 - }
385 - return nil
386 - })
387 -}
388 -
389 -func newExistingFileOrDirValue(target *string) *fileStatValue {
390 - return newFileStatValue(target, func(s os.FileInfo) error { return nil })
391 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/values.json deleted
-22
@@ -1,22 +0,0 @@
1 -[
2 - {"type": "bool", "parser": "strconv.ParseBool(s)"},
3 - {"type": "string", "parser": "s, error(nil)", "format": "string(*f)", "plural": "Strings"},
4 - {"type": "uint", "parser": "strconv.ParseUint(s, 0, 64)", "plural": "Uints"},
5 - {"type": "uint8", "parser": "strconv.ParseUint(s, 0, 8)"},
6 - {"type": "uint16", "parser": "strconv.ParseUint(s, 0, 16)"},
7 - {"type": "uint32", "parser": "strconv.ParseUint(s, 0, 32)"},
8 - {"type": "uint64", "parser": "strconv.ParseUint(s, 0, 64)"},
9 - {"type": "int", "parser": "strconv.ParseFloat(s, 64)", "plural": "Ints"},
10 - {"type": "int8", "parser": "strconv.ParseInt(s, 0, 8)"},
11 - {"type": "int16", "parser": "strconv.ParseInt(s, 0, 16)"},
12 - {"type": "int32", "parser": "strconv.ParseInt(s, 0, 32)"},
13 - {"type": "int64", "parser": "strconv.ParseInt(s, 0, 64)"},
14 - {"type": "float64", "parser": "strconv.ParseFloat(s, 64)"},
15 - {"type": "float32", "parser": "strconv.ParseFloat(s, 32)"},
16 - {"name": "Duration", "type": "time.Duration", "no_value_parser": true},
17 - {"name": "IP", "type": "net.IP", "no_value_parser": true},
18 - {"name": "TCPAddr", "Type": "*net.TCPAddr", "plural": "TCPList", "no_value_parser": true},
19 - {"name": "ExistingFile", "Type": "string", "plural": "ExistingFiles", "no_value_parser": true},
20 - {"name": "ExistingDir", "Type": "string", "plural": "ExistingDirs", "no_value_parser": true},
21 - {"name": "ExistingFileOrDir", "Type": "string", "plural": "ExistingFilesOrDirs", "no_value_parser": true}
22 -]
Godeps/_workspace/src/github.com/alecthomas/kingpin/values_generated.go deleted
-622
@@ -1,622 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "fmt"
5 - "net"
6 - "strconv"
7 - "time"
8 -)
9 -
10 -// This file is autogenerated by "go generate .". Do not modify.
11 -
12 -// -- bool Value
13 -type boolValue bool
14 -
15 -func newBoolValue(p *bool) *boolValue {
16 - return (*boolValue)(p)
17 -}
18 -
19 -func (f *boolValue) Set(s string) error {
20 - v, err := strconv.ParseBool(s)
21 - *f = boolValue(v)
22 - return err
23 -}
24 -
25 -func (f *boolValue) Get() interface{} { return bool(*f) }
26 -
27 -func (f *boolValue) String() string { return fmt.Sprintf("%v", *f) }
28 -
29 -// Bool parses the next command-line value as bool.
30 -func (p *parserMixin) Bool() (target *bool) {
31 - target = new(bool)
32 - p.BoolVar(target)
33 - return
34 -}
35 -
36 -func (p *parserMixin) BoolVar(target *bool) {
37 - p.SetValue(newBoolValue(target))
38 -}
39 -
40 -// BoolList accumulates bool values into a slice.
41 -func (p *parserMixin) BoolList() (target *[]bool) {
42 - target = new([]bool)
43 - p.BoolListVar(target)
44 - return
45 -}
46 -
47 -func (p *parserMixin) BoolListVar(target *[]bool) {
48 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newBoolValue(v.(*bool)) }))
49 -}
50 -
51 -// -- string Value
52 -type stringValue string
53 -
54 -func newStringValue(p *string) *stringValue {
55 - return (*stringValue)(p)
56 -}
57 -
58 -func (f *stringValue) Set(s string) error {
59 - v, err := s, error(nil)
60 - *f = stringValue(v)
61 - return err
62 -}
63 -
64 -func (f *stringValue) Get() interface{} { return string(*f) }
65 -
66 -func (f *stringValue) String() string { return string(*f) }
67 -
68 -// String parses the next command-line value as string.
69 -func (p *parserMixin) String() (target *string) {
70 - target = new(string)
71 - p.StringVar(target)
72 - return
73 -}
74 -
75 -func (p *parserMixin) StringVar(target *string) {
76 - p.SetValue(newStringValue(target))
77 -}
78 -
79 -// Strings accumulates string values into a slice.
80 -func (p *parserMixin) Strings() (target *[]string) {
81 - target = new([]string)
82 - p.StringsVar(target)
83 - return
84 -}
85 -
86 -func (p *parserMixin) StringsVar(target *[]string) {
87 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newStringValue(v.(*string)) }))
88 -}
89 -
90 -// -- uint Value
91 -type uintValue uint
92 -
93 -func newUintValue(p *uint) *uintValue {
94 - return (*uintValue)(p)
95 -}
96 -
97 -func (f *uintValue) Set(s string) error {
98 - v, err := strconv.ParseUint(s, 0, 64)
99 - *f = uintValue(v)
100 - return err
101 -}
102 -
103 -func (f *uintValue) Get() interface{} { return uint(*f) }
104 -
105 -func (f *uintValue) String() string { return fmt.Sprintf("%v", *f) }
106 -
107 -// Uint parses the next command-line value as uint.
108 -func (p *parserMixin) Uint() (target *uint) {
109 - target = new(uint)
110 - p.UintVar(target)
111 - return
112 -}
113 -
114 -func (p *parserMixin) UintVar(target *uint) {
115 - p.SetValue(newUintValue(target))
116 -}
117 -
118 -// Uints accumulates uint values into a slice.
119 -func (p *parserMixin) Uints() (target *[]uint) {
120 - target = new([]uint)
121 - p.UintsVar(target)
122 - return
123 -}
124 -
125 -func (p *parserMixin) UintsVar(target *[]uint) {
126 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newUintValue(v.(*uint)) }))
127 -}
128 -
129 -// -- uint8 Value
130 -type uint8Value uint8
131 -
132 -func newUint8Value(p *uint8) *uint8Value {
133 - return (*uint8Value)(p)
134 -}
135 -
136 -func (f *uint8Value) Set(s string) error {
137 - v, err := strconv.ParseUint(s, 0, 8)
138 - *f = uint8Value(v)
139 - return err
140 -}
141 -
142 -func (f *uint8Value) Get() interface{} { return uint8(*f) }
143 -
144 -func (f *uint8Value) String() string { return fmt.Sprintf("%v", *f) }
145 -
146 -// Uint8 parses the next command-line value as uint8.
147 -func (p *parserMixin) Uint8() (target *uint8) {
148 - target = new(uint8)
149 - p.Uint8Var(target)
150 - return
151 -}
152 -
153 -func (p *parserMixin) Uint8Var(target *uint8) {
154 - p.SetValue(newUint8Value(target))
155 -}
156 -
157 -// Uint8List accumulates uint8 values into a slice.
158 -func (p *parserMixin) Uint8List() (target *[]uint8) {
159 - target = new([]uint8)
160 - p.Uint8ListVar(target)
161 - return
162 -}
163 -
164 -func (p *parserMixin) Uint8ListVar(target *[]uint8) {
165 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newUint8Value(v.(*uint8)) }))
166 -}
167 -
168 -// -- uint16 Value
169 -type uint16Value uint16
170 -
171 -func newUint16Value(p *uint16) *uint16Value {
172 - return (*uint16Value)(p)
173 -}
174 -
175 -func (f *uint16Value) Set(s string) error {
176 - v, err := strconv.ParseUint(s, 0, 16)
177 - *f = uint16Value(v)
178 - return err
179 -}
180 -
181 -func (f *uint16Value) Get() interface{} { return uint16(*f) }
182 -
183 -func (f *uint16Value) String() string { return fmt.Sprintf("%v", *f) }
184 -
185 -// Uint16 parses the next command-line value as uint16.
186 -func (p *parserMixin) Uint16() (target *uint16) {
187 - target = new(uint16)
188 - p.Uint16Var(target)
189 - return
190 -}
191 -
192 -func (p *parserMixin) Uint16Var(target *uint16) {
193 - p.SetValue(newUint16Value(target))
194 -}
195 -
196 -// Uint16List accumulates uint16 values into a slice.
197 -func (p *parserMixin) Uint16List() (target *[]uint16) {
198 - target = new([]uint16)
199 - p.Uint16ListVar(target)
200 - return
201 -}
202 -
203 -func (p *parserMixin) Uint16ListVar(target *[]uint16) {
204 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newUint16Value(v.(*uint16)) }))
205 -}
206 -
207 -// -- uint32 Value
208 -type uint32Value uint32
209 -
210 -func newUint32Value(p *uint32) *uint32Value {
211 - return (*uint32Value)(p)
212 -}
213 -
214 -func (f *uint32Value) Set(s string) error {
215 - v, err := strconv.ParseUint(s, 0, 32)
216 - *f = uint32Value(v)
217 - return err
218 -}
219 -
220 -func (f *uint32Value) Get() interface{} { return uint32(*f) }
221 -
222 -func (f *uint32Value) String() string { return fmt.Sprintf("%v", *f) }
223 -
224 -// Uint32 parses the next command-line value as uint32.
225 -func (p *parserMixin) Uint32() (target *uint32) {
226 - target = new(uint32)
227 - p.Uint32Var(target)
228 - return
229 -}
230 -
231 -func (p *parserMixin) Uint32Var(target *uint32) {
232 - p.SetValue(newUint32Value(target))
233 -}
234 -
235 -// Uint32List accumulates uint32 values into a slice.
236 -func (p *parserMixin) Uint32List() (target *[]uint32) {
237 - target = new([]uint32)
238 - p.Uint32ListVar(target)
239 - return
240 -}
241 -
242 -func (p *parserMixin) Uint32ListVar(target *[]uint32) {
243 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newUint32Value(v.(*uint32)) }))
244 -}
245 -
246 -// -- uint64 Value
247 -type uint64Value uint64
248 -
249 -func newUint64Value(p *uint64) *uint64Value {
250 - return (*uint64Value)(p)
251 -}
252 -
253 -func (f *uint64Value) Set(s string) error {
254 - v, err := strconv.ParseUint(s, 0, 64)
255 - *f = uint64Value(v)
256 - return err
257 -}
258 -
259 -func (f *uint64Value) Get() interface{} { return uint64(*f) }
260 -
261 -func (f *uint64Value) String() string { return fmt.Sprintf("%v", *f) }
262 -
263 -// Uint64 parses the next command-line value as uint64.
264 -func (p *parserMixin) Uint64() (target *uint64) {
265 - target = new(uint64)
266 - p.Uint64Var(target)
267 - return
268 -}
269 -
270 -func (p *parserMixin) Uint64Var(target *uint64) {
271 - p.SetValue(newUint64Value(target))
272 -}
273 -
274 -// Uint64List accumulates uint64 values into a slice.
275 -func (p *parserMixin) Uint64List() (target *[]uint64) {
276 - target = new([]uint64)
277 - p.Uint64ListVar(target)
278 - return
279 -}
280 -
281 -func (p *parserMixin) Uint64ListVar(target *[]uint64) {
282 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newUint64Value(v.(*uint64)) }))
283 -}
284 -
285 -// -- int Value
286 -type intValue int
287 -
288 -func newIntValue(p *int) *intValue {
289 - return (*intValue)(p)
290 -}
291 -
292 -func (f *intValue) Set(s string) error {
293 - v, err := strconv.ParseFloat(s, 64)
294 - *f = intValue(v)
295 - return err
296 -}
297 -
298 -func (f *intValue) Get() interface{} { return int(*f) }
299 -
300 -func (f *intValue) String() string { return fmt.Sprintf("%v", *f) }
301 -
302 -// Int parses the next command-line value as int.
303 -func (p *parserMixin) Int() (target *int) {
304 - target = new(int)
305 - p.IntVar(target)
306 - return
307 -}
308 -
309 -func (p *parserMixin) IntVar(target *int) {
310 - p.SetValue(newIntValue(target))
311 -}
312 -
313 -// Ints accumulates int values into a slice.
314 -func (p *parserMixin) Ints() (target *[]int) {
315 - target = new([]int)
316 - p.IntsVar(target)
317 - return
318 -}
319 -
320 -func (p *parserMixin) IntsVar(target *[]int) {
321 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newIntValue(v.(*int)) }))
322 -}
323 -
324 -// -- int8 Value
325 -type int8Value int8
326 -
327 -func newInt8Value(p *int8) *int8Value {
328 - return (*int8Value)(p)
329 -}
330 -
331 -func (f *int8Value) Set(s string) error {
332 - v, err := strconv.ParseInt(s, 0, 8)
333 - *f = int8Value(v)
334 - return err
335 -}
336 -
337 -func (f *int8Value) Get() interface{} { return int8(*f) }
338 -
339 -func (f *int8Value) String() string { return fmt.Sprintf("%v", *f) }
340 -
341 -// Int8 parses the next command-line value as int8.
342 -func (p *parserMixin) Int8() (target *int8) {
343 - target = new(int8)
344 - p.Int8Var(target)
345 - return
346 -}
347 -
348 -func (p *parserMixin) Int8Var(target *int8) {
349 - p.SetValue(newInt8Value(target))
350 -}
351 -
352 -// Int8List accumulates int8 values into a slice.
353 -func (p *parserMixin) Int8List() (target *[]int8) {
354 - target = new([]int8)
355 - p.Int8ListVar(target)
356 - return
357 -}
358 -
359 -func (p *parserMixin) Int8ListVar(target *[]int8) {
360 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newInt8Value(v.(*int8)) }))
361 -}
362 -
363 -// -- int16 Value
364 -type int16Value int16
365 -
366 -func newInt16Value(p *int16) *int16Value {
367 - return (*int16Value)(p)
368 -}
369 -
370 -func (f *int16Value) Set(s string) error {
371 - v, err := strconv.ParseInt(s, 0, 16)
372 - *f = int16Value(v)
373 - return err
374 -}
375 -
376 -func (f *int16Value) Get() interface{} { return int16(*f) }
377 -
378 -func (f *int16Value) String() string { return fmt.Sprintf("%v", *f) }
379 -
380 -// Int16 parses the next command-line value as int16.
381 -func (p *parserMixin) Int16() (target *int16) {
382 - target = new(int16)
383 - p.Int16Var(target)
384 - return
385 -}
386 -
387 -func (p *parserMixin) Int16Var(target *int16) {
388 - p.SetValue(newInt16Value(target))
389 -}
390 -
391 -// Int16List accumulates int16 values into a slice.
392 -func (p *parserMixin) Int16List() (target *[]int16) {
393 - target = new([]int16)
394 - p.Int16ListVar(target)
395 - return
396 -}
397 -
398 -func (p *parserMixin) Int16ListVar(target *[]int16) {
399 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newInt16Value(v.(*int16)) }))
400 -}
401 -
402 -// -- int32 Value
403 -type int32Value int32
404 -
405 -func newInt32Value(p *int32) *int32Value {
406 - return (*int32Value)(p)
407 -}
408 -
409 -func (f *int32Value) Set(s string) error {
410 - v, err := strconv.ParseInt(s, 0, 32)
411 - *f = int32Value(v)
412 - return err
413 -}
414 -
415 -func (f *int32Value) Get() interface{} { return int32(*f) }
416 -
417 -func (f *int32Value) String() string { return fmt.Sprintf("%v", *f) }
418 -
419 -// Int32 parses the next command-line value as int32.
420 -func (p *parserMixin) Int32() (target *int32) {
421 - target = new(int32)
422 - p.Int32Var(target)
423 - return
424 -}
425 -
426 -func (p *parserMixin) Int32Var(target *int32) {
427 - p.SetValue(newInt32Value(target))
428 -}
429 -
430 -// Int32List accumulates int32 values into a slice.
431 -func (p *parserMixin) Int32List() (target *[]int32) {
432 - target = new([]int32)
433 - p.Int32ListVar(target)
434 - return
435 -}
436 -
437 -func (p *parserMixin) Int32ListVar(target *[]int32) {
438 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newInt32Value(v.(*int32)) }))
439 -}
440 -
441 -// -- int64 Value
442 -type int64Value int64
443 -
444 -func newInt64Value(p *int64) *int64Value {
445 - return (*int64Value)(p)
446 -}
447 -
448 -func (f *int64Value) Set(s string) error {
449 - v, err := strconv.ParseInt(s, 0, 64)
450 - *f = int64Value(v)
451 - return err
452 -}
453 -
454 -func (f *int64Value) Get() interface{} { return int64(*f) }
455 -
456 -func (f *int64Value) String() string { return fmt.Sprintf("%v", *f) }
457 -
458 -// Int64 parses the next command-line value as int64.
459 -func (p *parserMixin) Int64() (target *int64) {
460 - target = new(int64)
461 - p.Int64Var(target)
462 - return
463 -}
464 -
465 -func (p *parserMixin) Int64Var(target *int64) {
466 - p.SetValue(newInt64Value(target))
467 -}
468 -
469 -// Int64List accumulates int64 values into a slice.
470 -func (p *parserMixin) Int64List() (target *[]int64) {
471 - target = new([]int64)
472 - p.Int64ListVar(target)
473 - return
474 -}
475 -
476 -func (p *parserMixin) Int64ListVar(target *[]int64) {
477 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newInt64Value(v.(*int64)) }))
478 -}
479 -
480 -// -- float64 Value
481 -type float64Value float64
482 -
483 -func newFloat64Value(p *float64) *float64Value {
484 - return (*float64Value)(p)
485 -}
486 -
487 -func (f *float64Value) Set(s string) error {
488 - v, err := strconv.ParseFloat(s, 64)
489 - *f = float64Value(v)
490 - return err
491 -}
492 -
493 -func (f *float64Value) Get() interface{} { return float64(*f) }
494 -
495 -func (f *float64Value) String() string { return fmt.Sprintf("%v", *f) }
496 -
497 -// Float64 parses the next command-line value as float64.
498 -func (p *parserMixin) Float64() (target *float64) {
499 - target = new(float64)
500 - p.Float64Var(target)
501 - return
502 -}
503 -
504 -func (p *parserMixin) Float64Var(target *float64) {
505 - p.SetValue(newFloat64Value(target))
506 -}
507 -
508 -// Float64List accumulates float64 values into a slice.
509 -func (p *parserMixin) Float64List() (target *[]float64) {
510 - target = new([]float64)
511 - p.Float64ListVar(target)
512 - return
513 -}
514 -
515 -func (p *parserMixin) Float64ListVar(target *[]float64) {
516 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newFloat64Value(v.(*float64)) }))
517 -}
518 -
519 -// -- float32 Value
520 -type float32Value float32
521 -
522 -func newFloat32Value(p *float32) *float32Value {
523 - return (*float32Value)(p)
524 -}
525 -
526 -func (f *float32Value) Set(s string) error {
527 - v, err := strconv.ParseFloat(s, 32)
528 - *f = float32Value(v)
529 - return err
530 -}
531 -
532 -func (f *float32Value) Get() interface{} { return float32(*f) }
533 -
534 -func (f *float32Value) String() string { return fmt.Sprintf("%v", *f) }
535 -
536 -// Float32 parses the next command-line value as float32.
537 -func (p *parserMixin) Float32() (target *float32) {
538 - target = new(float32)
539 - p.Float32Var(target)
540 - return
541 -}
542 -
543 -func (p *parserMixin) Float32Var(target *float32) {
544 - p.SetValue(newFloat32Value(target))
545 -}
546 -
547 -// Float32List accumulates float32 values into a slice.
548 -func (p *parserMixin) Float32List() (target *[]float32) {
549 - target = new([]float32)
550 - p.Float32ListVar(target)
551 - return
552 -}
553 -
554 -func (p *parserMixin) Float32ListVar(target *[]float32) {
555 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newFloat32Value(v.(*float32)) }))
556 -}
557 -
558 -// DurationList accumulates time.Duration values into a slice.
559 -func (p *parserMixin) DurationList() (target *[]time.Duration) {
560 - target = new([]time.Duration)
561 - p.DurationListVar(target)
562 - return
563 -}
564 -
565 -func (p *parserMixin) DurationListVar(target *[]time.Duration) {
566 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newDurationValue(v.(*time.Duration)) }))
567 -}
568 -
569 -// IPList accumulates net.IP values into a slice.
570 -func (p *parserMixin) IPList() (target *[]net.IP) {
571 - target = new([]net.IP)
572 - p.IPListVar(target)
573 - return
574 -}
575 -
576 -func (p *parserMixin) IPListVar(target *[]net.IP) {
577 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newIPValue(v.(*net.IP)) }))
578 -}
579 -
580 -// TCPList accumulates *net.TCPAddr values into a slice.
581 -func (p *parserMixin) TCPList() (target *[]*net.TCPAddr) {
582 - target = new([]*net.TCPAddr)
583 - p.TCPListVar(target)
584 - return
585 -}
586 -
587 -func (p *parserMixin) TCPListVar(target *[]*net.TCPAddr) {
588 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newTCPAddrValue(v.(**net.TCPAddr)) }))
589 -}
590 -
591 -// ExistingFiles accumulates string values into a slice.
592 -func (p *parserMixin) ExistingFiles() (target *[]string) {
593 - target = new([]string)
594 - p.ExistingFilesVar(target)
595 - return
596 -}
597 -
598 -func (p *parserMixin) ExistingFilesVar(target *[]string) {
599 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newExistingFileValue(v.(*string)) }))
600 -}
601 -
602 -// ExistingDirs accumulates string values into a slice.
603 -func (p *parserMixin) ExistingDirs() (target *[]string) {
604 - target = new([]string)
605 - p.ExistingDirsVar(target)
606 - return
607 -}
608 -
609 -func (p *parserMixin) ExistingDirsVar(target *[]string) {
610 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newExistingDirValue(v.(*string)) }))
611 -}
612 -
613 -// ExistingFilesOrDirs accumulates string values into a slice.
614 -func (p *parserMixin) ExistingFilesOrDirs() (target *[]string) {
615 - target = new([]string)
616 - p.ExistingFilesOrDirsVar(target)
617 - return
618 -}
619 -
620 -func (p *parserMixin) ExistingFilesOrDirsVar(target *[]string) {
621 - p.SetValue(newAccumulator(target, func(v interface{}) Value { return newExistingFileOrDirValue(v.(*string)) }))
622 -}
Godeps/_workspace/src/github.com/alecthomas/kingpin/values_test.go deleted
-46
@@ -1,46 +0,0 @@
1 -package kingpin
2 -
3 -import (
4 - "gx/ipfs/QmZwjfAKWe7vWZ8f48u7AGA1xYfzR1iCD9A2XSCYFRBWot/testify/assert"
5 -
6 - "testing"
7 -)
8 -
9 -func TestAccumulatorStrings(t *testing.T) {
10 - target := []string{}
11 - acc := newAccumulator(&target, func(v interface{}) Value { return newStringValue(v.(*string)) })
12 - acc.Set("a")
13 - assert.Equal(t, []string{"a"}, target)
14 - acc.Set("b")
15 - assert.Equal(t, []string{"a", "b"}, target)
16 -}
17 -
18 -func TestStrings(t *testing.T) {
19 - app := New("", "")
20 - app.Arg("a", "").Required().String()
21 - app.Arg("b", "").Required().String()
22 - c := app.Arg("c", "").Required().Strings()
23 - app.Parse([]string{"a", "b", "a", "b"})
24 - assert.Equal(t, []string{"a", "b"}, *c)
25 -}
26 -
27 -func TestEnum(t *testing.T) {
28 - app := New("", "")
29 - a := app.Arg("a", "").Enum("one", "two", "three")
30 - _, err := app.Parse([]string{"moo"})
31 - assert.Error(t, err)
32 - _, err = app.Parse([]string{"one"})
33 - assert.NoError(t, err)
34 - assert.Equal(t, "one", *a)
35 -}
36 -
37 -func TestEnumVar(t *testing.T) {
38 - app := New("", "")
39 - var a string
40 - app.Arg("a", "").EnumVar(&a, "one", "two", "three")
41 - _, err := app.Parse([]string{"moo"})
42 - assert.Error(t, err)
43 - _, err = app.Parse([]string{"one"})
44 - assert.NoError(t, err)
45 - assert.Equal(t, "one", a)
46 -}
Godeps/_workspace/src/github.com/alecthomas/template/README.md deleted
-25
@@ -1,25 +0,0 @@
1 -# Go's `text/template` package with newline elision
2 -
3 -This is a fork of Go 1.4's [text/template](http://golang.org/pkg/text/template/) package with one addition: a backslash immediately after a closing delimiter will delete all subsequent newlines until a non-newline.
4 -
5 -eg.
6 -
7 -```
8 -{{if true}}\
9 -hello
10 -{{end}}\
11 -```
12 -
13 -Will result in:
14 -
15 -```
16 -hello\n
17 -```
18 -
19 -Rather than:
20 -
21 -```
22 -\n
23 -hello\n
24 -\n
25 -```
Godeps/_workspace/src/github.com/alecthomas/template/doc.go deleted
-406
@@ -1,406 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -/*
6 -Package template implements data-driven templates for generating textual output.
7 -
8 -To generate HTML output, see package html/template, which has the same interface
9 -as this package but automatically secures HTML output against certain attacks.
10 -
11 -Templates are executed by applying them to a data structure. Annotations in the
12 -template refer to elements of the data structure (typically a field of a struct
13 -or a key in a map) to control execution and derive values to be displayed.
14 -Execution of the template walks the structure and sets the cursor, represented
15 -by a period '.' and called "dot", to the value at the current location in the
16 -structure as execution proceeds.
17 -
18 -The input text for a template is UTF-8-encoded text in any format.
19 -"Actions"--data evaluations or control structures--are delimited by
20 -"{{" and "}}"; all text outside actions is copied to the output unchanged.
21 -Actions may not span newlines, although comments can.
22 -
23 -Once parsed, a template may be executed safely in parallel.
24 -
25 -Here is a trivial example that prints "17 items are made of wool".
26 -
27 - type Inventory struct {
28 - Material string
29 - Count uint
30 - }
31 - sweaters := Inventory{"wool", 17}
32 - tmpl, err := template.New("test").Parse("{{.Count}} items are made of {{.Material}}")
33 - if err != nil { panic(err) }
34 - err = tmpl.Execute(os.Stdout, sweaters)
35 - if err != nil { panic(err) }
36 -
37 -More intricate examples appear below.
38 -
39 -Actions
40 -
41 -Here is the list of actions. "Arguments" and "pipelines" are evaluations of
42 -data, defined in detail below.
43 -
44 -*/
45 -// {{/* a comment */}}
46 -// A comment; discarded. May contain newlines.
47 -// Comments do not nest and must start and end at the
48 -// delimiters, as shown here.
49 -/*
50 -
51 - {{pipeline}}
52 - The default textual representation of the value of the pipeline
53 - is copied to the output.
54 -
55 - {{if pipeline}} T1 {{end}}
56 - If the value of the pipeline is empty, no output is generated;
57 - otherwise, T1 is executed. The empty values are false, 0, any
58 - nil pointer or interface value, and any array, slice, map, or
59 - string of length zero.
60 - Dot is unaffected.
61 -
62 - {{if pipeline}} T1 {{else}} T0 {{end}}
63 - If the value of the pipeline is empty, T0 is executed;
64 - otherwise, T1 is executed. Dot is unaffected.
65 -
66 - {{if pipeline}} T1 {{else if pipeline}} T0 {{end}}
67 - To simplify the appearance of if-else chains, the else action
68 - of an if may include another if directly; the effect is exactly
69 - the same as writing
70 - {{if pipeline}} T1 {{else}}{{if pipeline}} T0 {{end}}{{end}}
71 -
72 - {{range pipeline}} T1 {{end}}
73 - The value of the pipeline must be an array, slice, map, or channel.
74 - If the value of the pipeline has length zero, nothing is output;
75 - otherwise, dot is set to the successive elements of the array,
76 - slice, or map and T1 is executed. If the value is a map and the
77 - keys are of basic type with a defined order ("comparable"), the
78 - elements will be visited in sorted key order.
79 -
80 - {{range pipeline}} T1 {{else}} T0 {{end}}
81 - The value of the pipeline must be an array, slice, map, or channel.
82 - If the value of the pipeline has length zero, dot is unaffected and
83 - T0 is executed; otherwise, dot is set to the successive elements
84 - of the array, slice, or map and T1 is executed.
85 -
86 - {{template "name"}}
87 - The template with the specified name is executed with nil data.
88 -
89 - {{template "name" pipeline}}
90 - The template with the specified name is executed with dot set
91 - to the value of the pipeline.
92 -
93 - {{with pipeline}} T1 {{end}}
94 - If the value of the pipeline is empty, no output is generated;
95 - otherwise, dot is set to the value of the pipeline and T1 is
96 - executed.
97 -
98 - {{with pipeline}} T1 {{else}} T0 {{end}}
99 - If the value of the pipeline is empty, dot is unaffected and T0
100 - is executed; otherwise, dot is set to the value of the pipeline
101 - and T1 is executed.
102 -
103 -Arguments
104 -
105 -An argument is a simple value, denoted by one of the following.
106 -
107 - - A boolean, string, character, integer, floating-point, imaginary
108 - or complex constant in Go syntax. These behave like Go's untyped
109 - constants, although raw strings may not span newlines.
110 - - The keyword nil, representing an untyped Go nil.
111 - - The character '.' (period):
112 - .
113 - The result is the value of dot.
114 - - A variable name, which is a (possibly empty) alphanumeric string
115 - preceded by a dollar sign, such as
116 - $piOver2
117 - or
118 - $
119 - The result is the value of the variable.
120 - Variables are described below.
121 - - The name of a field of the data, which must be a struct, preceded
122 - by a period, such as
123 - .Field
124 - The result is the value of the field. Field invocations may be
125 - chained:
126 - .Field1.Field2
127 - Fields can also be evaluated on variables, including chaining:
128 - $x.Field1.Field2
129 - - The name of a key of the data, which must be a map, preceded
130 - by a period, such as
131 - .Key
132 - The result is the map element value indexed by the key.
133 - Key invocations may be chained and combined with fields to any
134 - depth:
135 - .Field1.Key1.Field2.Key2
136 - Although the key must be an alphanumeric identifier, unlike with
137 - field names they do not need to start with an upper case letter.
138 - Keys can also be evaluated on variables, including chaining:
139 - $x.key1.key2
140 - - The name of a niladic method of the data, preceded by a period,
141 - such as
142 - .Method
143 - The result is the value of invoking the method with dot as the
144 - receiver, dot.Method(). Such a method must have one return value (of
145 - any type) or two return values, the second of which is an error.
146 - If it has two and the returned error is non-nil, execution terminates
147 - and an error is returned to the caller as the value of Execute.
148 - Method invocations may be chained and combined with fields and keys
149 - to any depth:
150 - .Field1.Key1.Method1.Field2.Key2.Method2
151 - Methods can also be evaluated on variables, including chaining:
152 - $x.Method1.Field
153 - - The name of a niladic function, such as
154 - fun
155 - The result is the value of invoking the function, fun(). The return
156 - types and values behave as in methods. Functions and function
157 - names are described below.
158 - - A parenthesized instance of one the above, for grouping. The result
159 - may be accessed by a field or map key invocation.
160 - print (.F1 arg1) (.F2 arg2)
161 - (.StructValuedMethod "arg").Field
162 -
163 -Arguments may evaluate to any type; if they are pointers the implementation
164 -automatically indirects to the base type when required.
165 -If an evaluation yields a function value, such as a function-valued
166 -field of a struct, the function is not invoked automatically, but it
167 -can be used as a truth value for an if action and the like. To invoke
168 -it, use the call function, defined below.
169 -
170 -A pipeline is a possibly chained sequence of "commands". A command is a simple
171 -value (argument) or a function or method call, possibly with multiple arguments:
172 -
173 - Argument
174 - The result is the value of evaluating the argument.
175 - .Method [Argument...]
176 - The method can be alone or the last element of a chain but,
177 - unlike methods in the middle of a chain, it can take arguments.
178 - The result is the value of calling the method with the
179 - arguments:
180 - dot.Method(Argument1, etc.)
181 - functionName [Argument...]
182 - The result is the value of calling the function associated
183 - with the name:
184 - function(Argument1, etc.)
185 - Functions and function names are described below.
186 -
187 -Pipelines
188 -
189 -A pipeline may be "chained" by separating a sequence of commands with pipeline
190 -characters '|'. In a chained pipeline, the result of the each command is
191 -passed as the last argument of the following command. The output of the final
192 -command in the pipeline is the value of the pipeline.
193 -
194 -The output of a command will be either one value or two values, the second of
195 -which has type error. If that second value is present and evaluates to
196 -non-nil, execution terminates and the error is returned to the caller of
197 -Execute.
198 -
199 -Variables
200 -
201 -A pipeline inside an action may initialize a variable to capture the result.
202 -The initialization has syntax
203 -
204 - $variable := pipeline
205 -
206 -where $variable is the name of the variable. An action that declares a
207 -variable produces no output.
208 -
209 -If a "range" action initializes a variable, the variable is set to the
210 -successive elements of the iteration. Also, a "range" may declare two
211 -variables, separated by a comma:
212 -
213 - range $index, $element := pipeline
214 -
215 -in which case $index and $element are set to the successive values of the
216 -array/slice index or map key and element, respectively. Note that if there is
217 -only one variable, it is assigned the element; this is opposite to the
218 -convention in Go range clauses.
219 -
220 -A variable's scope extends to the "end" action of the control structure ("if",
221 -"with", or "range") in which it is declared, or to the end of the template if
222 -there is no such control structure. A template invocation does not inherit
223 -variables from the point of its invocation.
224 -
225 -When execution begins, $ is set to the data argument passed to Execute, that is,
226 -to the starting value of dot.
227 -
228 -Examples
229 -
230 -Here are some example one-line templates demonstrating pipelines and variables.
231 -All produce the quoted word "output":
232 -
233 - {{"\"output\""}}
234 - A string constant.
235 - {{`"output"`}}
236 - A raw string constant.
237 - {{printf "%q" "output"}}
238 - A function call.
239 - {{"output" | printf "%q"}}
240 - A function call whose final argument comes from the previous
241 - command.
242 - {{printf "%q" (print "out" "put")}}
243 - A parenthesized argument.
244 - {{"put" | printf "%s%s" "out" | printf "%q"}}
245 - A more elaborate call.
246 - {{"output" | printf "%s" | printf "%q"}}
247 - A longer chain.
248 - {{with "output"}}{{printf "%q" .}}{{end}}
249 - A with action using dot.
250 - {{with $x := "output" | printf "%q"}}{{$x}}{{end}}
251 - A with action that creates and uses a variable.
252 - {{with $x := "output"}}{{printf "%q" $x}}{{end}}
253 - A with action that uses the variable in another action.
254 - {{with $x := "output"}}{{$x | printf "%q"}}{{end}}
255 - The same, but pipelined.
256 -
257 -Functions
258 -
259 -During execution functions are found in two function maps: first in the
260 -template, then in the global function map. By default, no functions are defined
261 -in the template but the Funcs method can be used to add them.
262 -
263 -Predefined global functions are named as follows.
264 -
265 - and
266 - Returns the boolean AND of its arguments by returning the
267 - first empty argument or the last argument, that is,
268 - "and x y" behaves as "if x then y else x". All the
269 - arguments are evaluated.
270 - call
271 - Returns the result of calling the first argument, which
272 - must be a function, with the remaining arguments as parameters.
273 - Thus "call .X.Y 1 2" is, in Go notation, dot.X.Y(1, 2) where
274 - Y is a func-valued field, map entry, or the like.
275 - The first argument must be the result of an evaluation
276 - that yields a value of function type (as distinct from
277 - a predefined function such as print). The function must
278 - return either one or two result values, the second of which
279 - is of type error. If the arguments don't match the function
280 - or the returned error value is non-nil, execution stops.
281 - html
282 - Returns the escaped HTML equivalent of the textual
283 - representation of its arguments.
284 - index
285 - Returns the result of indexing its first argument by the
286 - following arguments. Thus "index x 1 2 3" is, in Go syntax,
287 - x[1][2][3]. Each indexed item must be a map, slice, or array.
288 - js
289 - Returns the escaped JavaScript equivalent of the textual
290 - representation of its arguments.
291 - len
292 - Returns the integer length of its argument.
293 - not
294 - Returns the boolean negation of its single argument.
295 - or
296 - Returns the boolean OR of its arguments by returning the
297 - first non-empty argument or the last argument, that is,
298 - "or x y" behaves as "if x then x else y". All the
299 - arguments are evaluated.
300 - print
301 - An alias for fmt.Sprint
302 - printf
303 - An alias for fmt.Sprintf
304 - println
305 - An alias for fmt.Sprintln
306 - urlquery
307 - Returns the escaped value of the textual representation of
308 - its arguments in a form suitable for embedding in a URL query.
309 -
310 -The boolean functions take any zero value to be false and a non-zero
311 -value to be true.
312 -
313 -There is also a set of binary comparison operators defined as
314 -functions:
315 -
316 - eq
317 - Returns the boolean truth of arg1 == arg2
318 - ne
319 - Returns the boolean truth of arg1 != arg2
320 - lt
321 - Returns the boolean truth of arg1 < arg2
322 - le
323 - Returns the boolean truth of arg1 <= arg2
324 - gt
325 - Returns the boolean truth of arg1 > arg2
326 - ge
327 - Returns the boolean truth of arg1 >= arg2
328 -
329 -For simpler multi-way equality tests, eq (only) accepts two or more
330 -arguments and compares the second and subsequent to the first,
331 -returning in effect
332 -
333 - arg1==arg2 || arg1==arg3 || arg1==arg4 ...
334 -
335 -(Unlike with || in Go, however, eq is a function call and all the
336 -arguments will be evaluated.)
337 -
338 -The comparison functions work on basic types only (or named basic
339 -types, such as "type Celsius float32"). They implement the Go rules
340 -for comparison of values, except that size and exact type are
341 -ignored, so any integer value, signed or unsigned, may be compared
342 -with any other integer value. (The arithmetic value is compared,
343 -not the bit pattern, so all negative integers are less than all
344 -unsigned integers.) However, as usual, one may not compare an int
345 -with a float32 and so on.
346 -
347 -Associated templates
348 -
349 -Each template is named by a string specified when it is created. Also, each
350 -template is associated with zero or more other templates that it may invoke by
351 -name; such associations are transitive and form a name space of templates.
352 -
353 -A template may use a template invocation to instantiate another associated
354 -template; see the explanation of the "template" action above. The name must be
355 -that of a template associated with the template that contains the invocation.
356 -
357 -Nested template definitions
358 -
359 -When parsing a template, another template may be defined and associated with the
360 -template being parsed. Template definitions must appear at the top level of the
361 -template, much like global variables in a Go program.
362 -
363 -The syntax of such definitions is to surround each template declaration with a
364 -"define" and "end" action.
365 -
366 -The define action names the template being created by providing a string
367 -constant. Here is a simple example:
368 -
369 - `{{define "T1"}}ONE{{end}}
370 - {{define "T2"}}TWO{{end}}
371 - {{define "T3"}}{{template "T1"}} {{template "T2"}}{{end}}
372 - {{template "T3"}}`
373 -
374 -This defines two templates, T1 and T2, and a third T3 that invokes the other two
375 -when it is executed. Finally it invokes T3. If executed this template will
376 -produce the text
377 -
378 - ONE TWO
379 -
380 -By construction, a template may reside in only one association. If it's
381 -necessary to have a template addressable from multiple associations, the
382 -template definition must be parsed multiple times to create distinct *Template
383 -values, or must be copied with the Clone or AddParseTree method.
384 -
385 -Parse may be called multiple times to assemble the various associated templates;
386 -see the ParseFiles and ParseGlob functions and methods for simple ways to parse
387 -related templates stored in files.
388 -
389 -A template may be executed directly or through ExecuteTemplate, which executes
390 -an associated template identified by name. To invoke our example above, we
391 -might write,
392 -
393 - err := tmpl.Execute(os.Stdout, "no data needed")
394 - if err != nil {
395 - log.Fatalf("execution failed: %s", err)
396 - }
397 -
398 -or to invoke a particular template explicitly by name,
399 -
400 - err := tmpl.ExecuteTemplate(os.Stdout, "T2", "no data needed")
401 - if err != nil {
402 - log.Fatalf("execution failed: %s", err)
403 - }
404 -
405 -*/
406 -package template
Godeps/_workspace/src/github.com/alecthomas/template/example_test.go deleted
-71
@@ -1,71 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package template_test
6 -
7 -import (
8 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/template" // Define a template.
9 - "log"
10 - "os"
11 -)
12 -
13 -func ExampleTemplate() {
14 -
15 - const letter = `
16 -Dear {{.Name}},
17 -{{if .Attended}}
18 -It was a pleasure to see you at the wedding.{{else}}
19 -It is a shame you couldn't make it to the wedding.{{end}}
20 -{{with .Gift}}Thank you for the lovely {{.}}.
21 -{{end}}
22 -Best wishes,
23 -Josie
24 -`
25 -
26 - // Prepare some data to insert into the template.
27 - type Recipient struct {
28 - Name, Gift string
29 - Attended bool
30 - }
31 - var recipients = []Recipient{
32 - {"Aunt Mildred", "bone china tea set", true},
33 - {"Uncle John", "moleskin pants", false},
34 - {"Cousin Rodney", "", false},
35 - }
36 -
37 - // Create a new template and parse the letter into it.
38 - t := template.Must(template.New("letter").Parse(letter))
39 -
40 - // Execute the template for each recipient.
41 - for _, r := range recipients {
42 - err := t.Execute(os.Stdout, r)
43 - if err != nil {
44 - log.Println("executing template:", err)
45 - }
46 - }
47 -
48 - // Output:
49 - // Dear Aunt Mildred,
50 - //
51 - // It was a pleasure to see you at the wedding.
52 - // Thank you for the lovely bone china tea set.
53 - //
54 - // Best wishes,
55 - // Josie
56 - //
57 - // Dear Uncle John,
58 - //
59 - // It is a shame you couldn't make it to the wedding.
60 - // Thank you for the lovely moleskin pants.
61 - //
62 - // Best wishes,
63 - // Josie
64 - //
65 - // Dear Cousin Rodney,
66 - //
67 - // It is a shame you couldn't make it to the wedding.
68 - //
69 - // Best wishes,
70 - // Josie
71 -}
Godeps/_workspace/src/github.com/alecthomas/template/examplefiles_test.go deleted
-181
@@ -1,181 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package template_test
6 -
7 -import (
8 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/template" // templateFile defines the contents of a template to be stored in a file, for testing.
9 - "io"
10 - "io/ioutil"
11 - "log"
12 - "os"
13 - "path/filepath"
14 -)
15 -
16 -type templateFile struct {
17 - name string
18 - contents string
19 -}
20 -
21 -func createTestDir(files []templateFile) string {
22 - dir, err := ioutil.TempDir("", "template")
23 - if err != nil {
24 - log.Fatal(err)
25 - }
26 - for _, file := range files {
27 - f, err := os.Create(filepath.Join(dir, file.name))
28 - if err != nil {
29 - log.Fatal(err)
30 - }
31 - defer f.Close()
32 - _, err = io.WriteString(f, file.contents)
33 - if err != nil {
34 - log.Fatal(err)
35 - }
36 - }
37 - return dir
38 -}
39 -
40 -// Here we demonstrate loading a set of templates from a directory.
41 -func ExampleTemplate_glob() {
42 - // Here we create a temporary directory and populate it with our sample
43 - // template definition files; usually the template files would already
44 - // exist in some location known to the program.
45 - dir := createTestDir([]templateFile{
46 - // T0.tmpl is a plain template file that just invokes T1.
47 - {"T0.tmpl", `T0 invokes T1: ({{template "T1"}})`},
48 - // T1.tmpl defines a template, T1 that invokes T2.
49 - {"T1.tmpl", `{{define "T1"}}T1 invokes T2: ({{template "T2"}}){{end}}`},
50 - // T2.tmpl defines a template T2.
51 - {"T2.tmpl", `{{define "T2"}}This is T2{{end}}`},
52 - })
53 - // Clean up after the test; another quirk of running as an example.
54 - defer os.RemoveAll(dir)
55 -
56 - // pattern is the glob pattern used to find all the template files.
57 - pattern := filepath.Join(dir, "*.tmpl")
58 -
59 - // Here starts the example proper.
60 - // T0.tmpl is the first name matched, so it becomes the starting template,
61 - // the value returned by ParseGlob.
62 - tmpl := template.Must(template.ParseGlob(pattern))
63 -
64 - err := tmpl.Execute(os.Stdout, nil)
65 - if err != nil {
66 - log.Fatalf("template execution: %s", err)
67 - }
68 - // Output:
69 - // T0 invokes T1: (T1 invokes T2: (This is T2))
70 -}
71 -
72 -// This example demonstrates one way to share some templates
73 -// and use them in different contexts. In this variant we add multiple driver
74 -// templates by hand to an existing bundle of templates.
75 -func ExampleTemplate_helpers() {
76 - // Here we create a temporary directory and populate it with our sample
77 - // template definition files; usually the template files would already
78 - // exist in some location known to the program.
79 - dir := createTestDir([]templateFile{
80 - // T1.tmpl defines a template, T1 that invokes T2.
81 - {"T1.tmpl", `{{define "T1"}}T1 invokes T2: ({{template "T2"}}){{end}}`},
82 - // T2.tmpl defines a template T2.
83 - {"T2.tmpl", `{{define "T2"}}This is T2{{end}}`},
84 - })
85 - // Clean up after the test; another quirk of running as an example.
86 - defer os.RemoveAll(dir)
87 -
88 - // pattern is the glob pattern used to find all the template files.
89 - pattern := filepath.Join(dir, "*.tmpl")
90 -
91 - // Here starts the example proper.
92 - // Load the helpers.
93 - templates := template.Must(template.ParseGlob(pattern))
94 - // Add one driver template to the bunch; we do this with an explicit template definition.
95 - _, err := templates.Parse("{{define `driver1`}}Driver 1 calls T1: ({{template `T1`}})\n{{end}}")
96 - if err != nil {
97 - log.Fatal("parsing driver1: ", err)
98 - }
99 - // Add another driver template.
100 - _, err = templates.Parse("{{define `driver2`}}Driver 2 calls T2: ({{template `T2`}})\n{{end}}")
101 - if err != nil {
102 - log.Fatal("parsing driver2: ", err)
103 - }
104 - // We load all the templates before execution. This package does not require
105 - // that behavior but html/template's escaping does, so it's a good habit.
106 - err = templates.ExecuteTemplate(os.Stdout, "driver1", nil)
107 - if err != nil {
108 - log.Fatalf("driver1 execution: %s", err)
109 - }
110 - err = templates.ExecuteTemplate(os.Stdout, "driver2", nil)
111 - if err != nil {
112 - log.Fatalf("driver2 execution: %s", err)
113 - }
114 - // Output:
115 - // Driver 1 calls T1: (T1 invokes T2: (This is T2))
116 - // Driver 2 calls T2: (This is T2)
117 -}
118 -
119 -// This example demonstrates how to use one group of driver
120 -// templates with distinct sets of helper templates.
121 -func ExampleTemplate_share() {
122 - // Here we create a temporary directory and populate it with our sample
123 - // template definition files; usually the template files would already
124 - // exist in some location known to the program.
125 - dir := createTestDir([]templateFile{
126 - // T0.tmpl is a plain template file that just invokes T1.
127 - {"T0.tmpl", "T0 ({{.}} version) invokes T1: ({{template `T1`}})\n"},
128 - // T1.tmpl defines a template, T1 that invokes T2. Note T2 is not defined
129 - {"T1.tmpl", `{{define "T1"}}T1 invokes T2: ({{template "T2"}}){{end}}`},
130 - })
131 - // Clean up after the test; another quirk of running as an example.
132 - defer os.RemoveAll(dir)
133 -
134 - // pattern is the glob pattern used to find all the template files.
135 - pattern := filepath.Join(dir, "*.tmpl")
136 -
137 - // Here starts the example proper.
138 - // Load the drivers.
139 - drivers := template.Must(template.ParseGlob(pattern))
140 -
141 - // We must define an implementation of the T2 template. First we clone
142 - // the drivers, then add a definition of T2 to the template name space.
143 -
144 - // 1. Clone the helper set to create a new name space from which to run them.
145 - first, err := drivers.Clone()
146 - if err != nil {
147 - log.Fatal("cloning helpers: ", err)
148 - }
149 - // 2. Define T2, version A, and parse it.
150 - _, err = first.Parse("{{define `T2`}}T2, version A{{end}}")
151 - if err != nil {
152 - log.Fatal("parsing T2: ", err)
153 - }
154 -
155 - // Now repeat the whole thing, using a different version of T2.
156 - // 1. Clone the drivers.
157 - second, err := drivers.Clone()
158 - if err != nil {
159 - log.Fatal("cloning drivers: ", err)
160 - }
161 - // 2. Define T2, version B, and parse it.
162 - _, err = second.Parse("{{define `T2`}}T2, version B{{end}}")
163 - if err != nil {
164 - log.Fatal("parsing T2: ", err)
165 - }
166 -
167 - // Execute the templates in the reverse order to verify the
168 - // first is unaffected by the second.
169 - err = second.ExecuteTemplate(os.Stdout, "T0.tmpl", "second")
170 - if err != nil {
171 - log.Fatalf("second execution: %s", err)
172 - }
173 - err = first.ExecuteTemplate(os.Stdout, "T0.tmpl", "first")
174 - if err != nil {
175 - log.Fatalf("first: execution: %s", err)
176 - }
177 -
178 - // Output:
179 - // T0 (second version) invokes T1: (T1 invokes T2: (T2, version B))
180 - // T0 (first version) invokes T1: (T1 invokes T2: (T2, version A))
181 -}
Godeps/_workspace/src/github.com/alecthomas/template/examplefunc_test.go deleted
-54
@@ -1,54 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package template_test
6 -
7 -import (
8 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/template"
9 - "log"
10 - "os"
11 - "strings"
12 -)
13 -
14 -// This example demonstrates a custom function to process template text.
15 -// It installs the strings.Title function and uses it to
16 -// Make Title Text Look Good In Our Template's Output.
17 -func ExampleTemplate_func() {
18 - // First we create a FuncMap with which to register the function.
19 - funcMap := template.FuncMap{
20 - // The name "title" is what the function will be called in the template text.
21 - "title": strings.Title,
22 - }
23 -
24 - // A simple template definition to test our function.
25 - // We print the input text several ways:
26 - // - the original
27 - // - title-cased
28 - // - title-cased and then printed with %q
29 - // - printed with %q and then title-cased.
30 - const templateText = `
31 -Input: {{printf "%q" .}}
32 -Output 0: {{title .}}
33 -Output 1: {{title . | printf "%q"}}
34 -Output 2: {{printf "%q" . | title}}
35 -`
36 -
37 - // Create a template, add the function map, and parse the text.
38 - tmpl, err := template.New("titleTest").Funcs(funcMap).Parse(templateText)
39 - if err != nil {
40 - log.Fatalf("parsing: %s", err)
41 - }
42 -
43 - // Run the template to verify the output.
44 - err = tmpl.Execute(os.Stdout, "the go programming language")
45 - if err != nil {
46 - log.Fatalf("execution: %s", err)
47 - }
48 -
49 - // Output:
50 - // Input: "the go programming language"
51 - // Output 0: The Go Programming Language
52 - // Output 1: "The Go Programming Language"
53 - // Output 2: "The Go Programming Language"
54 -}
Godeps/_workspace/src/github.com/alecthomas/template/exec.go deleted
-844
@@ -1,844 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package template
6 -
7 -import (
8 - "bytes"
9 - "fmt"
10 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/template/parse"
11 - "io"
12 - "reflect"
13 - "runtime"
14 - "sort"
15 - "strings"
16 -)
17 -
18 -// state represents the state of an execution. It's not part of the
19 -// template so that multiple executions of the same template
20 -// can execute in parallel.
21 -type state struct {
22 - tmpl *Template
23 - wr io.Writer
24 - node parse.Node // current node, for errors
25 - vars []variable // push-down stack of variable values.
26 -}
27 -
28 -// variable holds the dynamic value of a variable such as $, $x etc.
29 -type variable struct {
30 - name string
31 - value reflect.Value
32 -}
33 -
34 -// push pushes a new variable on the stack.
35 -func (s *state) push(name string, value reflect.Value) {
36 - s.vars = append(s.vars, variable{name, value})
37 -}
38 -
39 -// mark returns the length of the variable stack.
40 -func (s *state) mark() int {
41 - return len(s.vars)
42 -}
43 -
44 -// pop pops the variable stack up to the mark.
45 -func (s *state) pop(mark int) {
46 - s.vars = s.vars[0:mark]
47 -}
48 -
49 -// setVar overwrites the top-nth variable on the stack. Used by range iterations.
50 -func (s *state) setVar(n int, value reflect.Value) {
51 - s.vars[len(s.vars)-n].value = value
52 -}
53 -
54 -// varValue returns the value of the named variable.
55 -func (s *state) varValue(name string) reflect.Value {
56 - for i := s.mark() - 1; i >= 0; i-- {
57 - if s.vars[i].name == name {
58 - return s.vars[i].value
59 - }
60 - }
61 - s.errorf("undefined variable: %s", name)
62 - return zero
63 -}
64 -
65 -var zero reflect.Value
66 -
67 -// at marks the state to be on node n, for error reporting.
68 -func (s *state) at(node parse.Node) {
69 - s.node = node
70 -}
71 -
72 -// doublePercent returns the string with %'s replaced by %%, if necessary,
73 -// so it can be used safely inside a Printf format string.
74 -func doublePercent(str string) string {
75 - if strings.Contains(str, "%") {
76 - str = strings.Replace(str, "%", "%%", -1)
77 - }
78 - return str
79 -}
80 -
81 -// errorf formats the error and terminates processing.
82 -func (s *state) errorf(format string, args ...interface{}) {
83 - name := doublePercent(s.tmpl.Name())
84 - if s.node == nil {
85 - format = fmt.Sprintf("template: %s: %s", name, format)
86 - } else {
87 - location, context := s.tmpl.ErrorContext(s.node)
88 - format = fmt.Sprintf("template: %s: executing %q at <%s>: %s", location, name, doublePercent(context), format)
89 - }
90 - panic(fmt.Errorf(format, args...))
91 -}
92 -
93 -// errRecover is the handler that turns panics into returns from the top
94 -// level of Parse.
95 -func errRecover(errp *error) {
96 - e := recover()
97 - if e != nil {
98 - switch err := e.(type) {
99 - case runtime.Error:
100 - panic(e)
101 - case error:
102 - *errp = err
103 - default:
104 - panic(e)
105 - }
106 - }
107 -}
108 -
109 -// ExecuteTemplate applies the template associated with t that has the given name
110 -// to the specified data object and writes the output to wr.
111 -// If an error occurs executing the template or writing its output,
112 -// execution stops, but partial results may already have been written to
113 -// the output writer.
114 -// A template may be executed safely in parallel.
115 -func (t *Template) ExecuteTemplate(wr io.Writer, name string, data interface{}) error {
116 - tmpl := t.tmpl[name]
117 - if tmpl == nil {
118 - return fmt.Errorf("template: no template %q associated with template %q", name, t.name)
119 - }
120 - return tmpl.Execute(wr, data)
121 -}
122 -
123 -// Execute applies a parsed template to the specified data object,
124 -// and writes the output to wr.
125 -// If an error occurs executing the template or writing its output,
126 -// execution stops, but partial results may already have been written to
127 -// the output writer.
128 -// A template may be executed safely in parallel.
129 -func (t *Template) Execute(wr io.Writer, data interface{}) (err error) {
130 - defer errRecover(&err)
131 - value := reflect.ValueOf(data)
132 - state := &state{
133 - tmpl: t,
134 - wr: wr,
135 - vars: []variable{{"$", value}},
136 - }
137 - t.init()
138 - if t.Tree == nil || t.Root == nil {
139 - var b bytes.Buffer
140 - for name, tmpl := range t.tmpl {
141 - if tmpl.Tree == nil || tmpl.Root == nil {
142 - continue
143 - }
144 - if b.Len() > 0 {
145 - b.WriteString(", ")
146 - }
147 - fmt.Fprintf(&b, "%q", name)
148 - }
149 - var s string
150 - if b.Len() > 0 {
151 - s = "; defined templates are: " + b.String()
152 - }
153 - state.errorf("%q is an incomplete or empty template%s", t.Name(), s)
154 - }
155 - state.walk(value, t.Root)
156 - return
157 -}
158 -
159 -// Walk functions step through the major pieces of the template structure,
160 -// generating output as they go.
161 -func (s *state) walk(dot reflect.Value, node parse.Node) {
162 - s.at(node)
163 - switch node := node.(type) {
164 - case *parse.ActionNode:
165 - // Do not pop variables so they persist until next end.
166 - // Also, if the action declares variables, don't print the result.
167 - val := s.evalPipeline(dot, node.Pipe)
168 - if len(node.Pipe.Decl) == 0 {
169 - s.printValue(node, val)
170 - }
171 - case *parse.IfNode:
172 - s.walkIfOrWith(parse.NodeIf, dot, node.Pipe, node.List, node.ElseList)
173 - case *parse.ListNode:
174 - for _, node := range node.Nodes {
175 - s.walk(dot, node)
176 - }
177 - case *parse.RangeNode:
178 - s.walkRange(dot, node)
179 - case *parse.TemplateNode:
180 - s.walkTemplate(dot, node)
181 - case *parse.TextNode:
182 - if _, err := s.wr.Write(node.Text); err != nil {
183 - s.errorf("%s", err)
184 - }
185 - case *parse.WithNode:
186 - s.walkIfOrWith(parse.NodeWith, dot, node.Pipe, node.List, node.ElseList)
187 - default:
188 - s.errorf("unknown node: %s", node)
189 - }
190 -}
191 -
192 -// walkIfOrWith walks an 'if' or 'with' node. The two control structures
193 -// are identical in behavior except that 'with' sets dot.
194 -func (s *state) walkIfOrWith(typ parse.NodeType, dot reflect.Value, pipe *parse.PipeNode, list, elseList *parse.ListNode) {
195 - defer s.pop(s.mark())
196 - val := s.evalPipeline(dot, pipe)
197 - truth, ok := isTrue(val)
198 - if !ok {
199 - s.errorf("if/with can't use %v", val)
200 - }
201 - if truth {
202 - if typ == parse.NodeWith {
203 - s.walk(val, list)
204 - } else {
205 - s.walk(dot, list)
206 - }
207 - } else if elseList != nil {
208 - s.walk(dot, elseList)
209 - }
210 -}
211 -
212 -// isTrue reports whether the value is 'true', in the sense of not the zero of its type,
213 -// and whether the value has a meaningful truth value.
214 -func isTrue(val reflect.Value) (truth, ok bool) {
215 - if !val.IsValid() {
216 - // Something like var x interface{}, never set. It's a form of nil.
217 - return false, true
218 - }
219 - switch val.Kind() {
220 - case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
221 - truth = val.Len() > 0
222 - case reflect.Bool:
223 - truth = val.Bool()
224 - case reflect.Complex64, reflect.Complex128:
225 - truth = val.Complex() != 0
226 - case reflect.Chan, reflect.Func, reflect.Ptr, reflect.Interface:
227 - truth = !val.IsNil()
228 - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
229 - truth = val.Int() != 0
230 - case reflect.Float32, reflect.Float64:
231 - truth = val.Float() != 0
232 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
233 - truth = val.Uint() != 0
234 - case reflect.Struct:
235 - truth = true // Struct values are always true.
236 - default:
237 - return
238 - }
239 - return truth, true
240 -}
241 -
242 -func (s *state) walkRange(dot reflect.Value, r *parse.RangeNode) {
243 - s.at(r)
244 - defer s.pop(s.mark())
245 - val, _ := indirect(s.evalPipeline(dot, r.Pipe))
246 - // mark top of stack before any variables in the body are pushed.
247 - mark := s.mark()
248 - oneIteration := func(index, elem reflect.Value) {
249 - // Set top var (lexically the second if there are two) to the element.
250 - if len(r.Pipe.Decl) > 0 {
251 - s.setVar(1, elem)
252 - }
253 - // Set next var (lexically the first if there are two) to the index.
254 - if len(r.Pipe.Decl) > 1 {
255 - s.setVar(2, index)
256 - }
257 - s.walk(elem, r.List)
258 - s.pop(mark)
259 - }
260 - switch val.Kind() {
261 - case reflect.Array, reflect.Slice:
262 - if val.Len() == 0 {
263 - break
264 - }
265 - for i := 0; i < val.Len(); i++ {
266 - oneIteration(reflect.ValueOf(i), val.Index(i))
267 - }
268 - return
269 - case reflect.Map:
270 - if val.Len() == 0 {
271 - break
272 - }
273 - for _, key := range sortKeys(val.MapKeys()) {
274 - oneIteration(key, val.MapIndex(key))
275 - }
276 - return
277 - case reflect.Chan:
278 - if val.IsNil() {
279 - break
280 - }
281 - i := 0
282 - for ; ; i++ {
283 - elem, ok := val.Recv()
284 - if !ok {
285 - break
286 - }
287 - oneIteration(reflect.ValueOf(i), elem)
288 - }
289 - if i == 0 {
290 - break
291 - }
292 - return
293 - case reflect.Invalid:
294 - break // An invalid value is likely a nil map, etc. and acts like an empty map.
295 - default:
296 - s.errorf("range can't iterate over %v", val)
297 - }
298 - if r.ElseList != nil {
299 - s.walk(dot, r.ElseList)
300 - }
301 -}
302 -
303 -func (s *state) walkTemplate(dot reflect.Value, t *parse.TemplateNode) {
304 - s.at(t)
305 - tmpl := s.tmpl.tmpl[t.Name]
306 - if tmpl == nil {
307 - s.errorf("template %q not defined", t.Name)
308 - }
309 - // Variables declared by the pipeline persist.
310 - dot = s.evalPipeline(dot, t.Pipe)
311 - newState := *s
312 - newState.tmpl = tmpl
313 - // No dynamic scoping: template invocations inherit no variables.
314 - newState.vars = []variable{{"$", dot}}
315 - newState.walk(dot, tmpl.Root)
316 -}
317 -
318 -// Eval functions evaluate pipelines, commands, and their elements and extract
319 -// values from the data structure by examining fields, calling methods, and so on.
320 -// The printing of those values happens only through walk functions.
321 -
322 -// evalPipeline returns the value acquired by evaluating a pipeline. If the
323 -// pipeline has a variable declaration, the variable will be pushed on the
324 -// stack. Callers should therefore pop the stack after they are finished
325 -// executing commands depending on the pipeline value.
326 -func (s *state) evalPipeline(dot reflect.Value, pipe *parse.PipeNode) (value reflect.Value) {
327 - if pipe == nil {
328 - return
329 - }
330 - s.at(pipe)
331 - for _, cmd := range pipe.Cmds {
332 - value = s.evalCommand(dot, cmd, value) // previous value is this one's final arg.
333 - // If the object has type interface{}, dig down one level to the thing inside.
334 - if value.Kind() == reflect.Interface && value.Type().NumMethod() == 0 {
335 - value = reflect.ValueOf(value.Interface()) // lovely!
336 - }
337 - }
338 - for _, variable := range pipe.Decl {
339 - s.push(variable.Ident[0], value)
340 - }
341 - return value
342 -}
343 -
344 -func (s *state) notAFunction(args []parse.Node, final reflect.Value) {
345 - if len(args) > 1 || final.IsValid() {
346 - s.errorf("can't give argument to non-function %s", args[0])
347 - }
348 -}
349 -
350 -func (s *state) evalCommand(dot reflect.Value, cmd *parse.CommandNode, final reflect.Value) reflect.Value {
351 - firstWord := cmd.Args[0]
352 - switch n := firstWord.(type) {
353 - case *parse.FieldNode:
354 - return s.evalFieldNode(dot, n, cmd.Args, final)
355 - case *parse.ChainNode:
356 - return s.evalChainNode(dot, n, cmd.Args, final)
357 - case *parse.IdentifierNode:
358 - // Must be a function.
359 - return s.evalFunction(dot, n, cmd, cmd.Args, final)
360 - case *parse.PipeNode:
361 - // Parenthesized pipeline. The arguments are all inside the pipeline; final is ignored.
362 - return s.evalPipeline(dot, n)
363 - case *parse.VariableNode:
364 - return s.evalVariableNode(dot, n, cmd.Args, final)
365 - }
366 - s.at(firstWord)
367 - s.notAFunction(cmd.Args, final)
368 - switch word := firstWord.(type) {
369 - case *parse.BoolNode:
370 - return reflect.ValueOf(word.True)
371 - case *parse.DotNode:
372 - return dot
373 - case *parse.NilNode:
374 - s.errorf("nil is not a command")
375 - case *parse.NumberNode:
376 - return s.idealConstant(word)
377 - case *parse.StringNode:
378 - return reflect.ValueOf(word.Text)
379 - }
380 - s.errorf("can't evaluate command %q", firstWord)
381 - panic("not reached")
382 -}
383 -
384 -// idealConstant is called to return the value of a number in a context where
385 -// we don't know the type. In that case, the syntax of the number tells us
386 -// its type, and we use Go rules to resolve. Note there is no such thing as
387 -// a uint ideal constant in this situation - the value must be of int type.
388 -func (s *state) idealConstant(constant *parse.NumberNode) reflect.Value {
389 - // These are ideal constants but we don't know the type
390 - // and we have no context. (If it was a method argument,
391 - // we'd know what we need.) The syntax guides us to some extent.
392 - s.at(constant)
393 - switch {
394 - case constant.IsComplex:
395 - return reflect.ValueOf(constant.Complex128) // incontrovertible.
396 - case constant.IsFloat && !isHexConstant(constant.Text) && strings.IndexAny(constant.Text, ".eE") >= 0:
397 - return reflect.ValueOf(constant.Float64)
398 - case constant.IsInt:
399 - n := int(constant.Int64)
400 - if int64(n) != constant.Int64 {
401 - s.errorf("%s overflows int", constant.Text)
402 - }
403 - return reflect.ValueOf(n)
404 - case constant.IsUint:
405 - s.errorf("%s overflows int", constant.Text)
406 - }
407 - return zero
408 -}
409 -
410 -func isHexConstant(s string) bool {
411 - return len(s) > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')
412 -}
413 -
414 -func (s *state) evalFieldNode(dot reflect.Value, field *parse.FieldNode, args []parse.Node, final reflect.Value) reflect.Value {
415 - s.at(field)
416 - return s.evalFieldChain(dot, dot, field, field.Ident, args, final)
417 -}
418 -
419 -func (s *state) evalChainNode(dot reflect.Value, chain *parse.ChainNode, args []parse.Node, final reflect.Value) reflect.Value {
420 - s.at(chain)
421 - // (pipe).Field1.Field2 has pipe as .Node, fields as .Field. Eval the pipeline, then the fields.
422 - pipe := s.evalArg(dot, nil, chain.Node)
423 - if len(chain.Field) == 0 {
424 - s.errorf("internal error: no fields in evalChainNode")
425 - }
426 - return s.evalFieldChain(dot, pipe, chain, chain.Field, args, final)
427 -}
428 -
429 -func (s *state) evalVariableNode(dot reflect.Value, variable *parse.VariableNode, args []parse.Node, final reflect.Value) reflect.Value {
430 - // $x.Field has $x as the first ident, Field as the second. Eval the var, then the fields.
431 - s.at(variable)
432 - value := s.varValue(variable.Ident[0])
433 - if len(variable.Ident) == 1 {
434 - s.notAFunction(args, final)
435 - return value
436 - }
437 - return s.evalFieldChain(dot, value, variable, variable.Ident[1:], args, final)
438 -}
439 -
440 -// evalFieldChain evaluates .X.Y.Z possibly followed by arguments.
441 -// dot is the environment in which to evaluate arguments, while
442 -// receiver is the value being walked along the chain.
443 -func (s *state) evalFieldChain(dot, receiver reflect.Value, node parse.Node, ident []string, args []parse.Node, final reflect.Value) reflect.Value {
444 - n := len(ident)
445 - for i := 0; i < n-1; i++ {
446 - receiver = s.evalField(dot, ident[i], node, nil, zero, receiver)
447 - }
448 - // Now if it's a method, it gets the arguments.
449 - return s.evalField(dot, ident[n-1], node, args, final, receiver)
450 -}
451 -
452 -func (s *state) evalFunction(dot reflect.Value, node *parse.IdentifierNode, cmd parse.Node, args []parse.Node, final reflect.Value) reflect.Value {
453 - s.at(node)
454 - name := node.Ident
455 - function, ok := findFunction(name, s.tmpl)
456 - if !ok {
457 - s.errorf("%q is not a defined function", name)
458 - }
459 - return s.evalCall(dot, function, cmd, name, args, final)
460 -}
461 -
462 -// evalField evaluates an expression like (.Field) or (.Field arg1 arg2).
463 -// The 'final' argument represents the return value from the preceding
464 -// value of the pipeline, if any.
465 -func (s *state) evalField(dot reflect.Value, fieldName string, node parse.Node, args []parse.Node, final, receiver reflect.Value) reflect.Value {
466 - if !receiver.IsValid() {
467 - return zero
468 - }
469 - typ := receiver.Type()
470 - receiver, _ = indirect(receiver)
471 - // Unless it's an interface, need to get to a value of type *T to guarantee
472 - // we see all methods of T and *T.
473 - ptr := receiver
474 - if ptr.Kind() != reflect.Interface && ptr.CanAddr() {
475 - ptr = ptr.Addr()
476 - }
477 - if method := ptr.MethodByName(fieldName); method.IsValid() {
478 - return s.evalCall(dot, method, node, fieldName, args, final)
479 - }
480 - hasArgs := len(args) > 1 || final.IsValid()
481 - // It's not a method; must be a field of a struct or an element of a map. The receiver must not be nil.
482 - receiver, isNil := indirect(receiver)
483 - if isNil {
484 - s.errorf("nil pointer evaluating %s.%s", typ, fieldName)
485 - }
486 - switch receiver.Kind() {
487 - case reflect.Struct:
488 - tField, ok := receiver.Type().FieldByName(fieldName)
489 - if ok {
490 - field := receiver.FieldByIndex(tField.Index)
491 - if tField.PkgPath != "" { // field is unexported
492 - s.errorf("%s is an unexported field of struct type %s", fieldName, typ)
493 - }
494 - // If it's a function, we must call it.
495 - if hasArgs {
496 - s.errorf("%s has arguments but cannot be invoked as function", fieldName)
497 - }
498 - return field
499 - }
500 - s.errorf("%s is not a field of struct type %s", fieldName, typ)
501 - case reflect.Map:
502 - // If it's a map, attempt to use the field name as a key.
503 - nameVal := reflect.ValueOf(fieldName)
504 - if nameVal.Type().AssignableTo(receiver.Type().Key()) {
505 - if hasArgs {
506 - s.errorf("%s is not a method but has arguments", fieldName)
507 - }
508 - return receiver.MapIndex(nameVal)
509 - }
510 - }
511 - s.errorf("can't evaluate field %s in type %s", fieldName, typ)
512 - panic("not reached")
513 -}
514 -
515 -var (
516 - errorType = reflect.TypeOf((*error)(nil)).Elem()
517 - fmtStringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem()
518 -)
519 -
520 -// evalCall executes a function or method call. If it's a method, fun already has the receiver bound, so
521 -// it looks just like a function call. The arg list, if non-nil, includes (in the manner of the shell), arg[0]
522 -// as the function itself.
523 -func (s *state) evalCall(dot, fun reflect.Value, node parse.Node, name string, args []parse.Node, final reflect.Value) reflect.Value {
524 - if args != nil {
525 - args = args[1:] // Zeroth arg is function name/node; not passed to function.
526 - }
527 - typ := fun.Type()
528 - numIn := len(args)
529 - if final.IsValid() {
530 - numIn++
531 - }
532 - numFixed := len(args)
533 - if typ.IsVariadic() {
534 - numFixed = typ.NumIn() - 1 // last arg is the variadic one.
535 - if numIn < numFixed {
536 - s.errorf("wrong number of args for %s: want at least %d got %d", name, typ.NumIn()-1, len(args))
537 - }
538 - } else if numIn < typ.NumIn()-1 || !typ.IsVariadic() && numIn != typ.NumIn() {
539 - s.errorf("wrong number of args for %s: want %d got %d", name, typ.NumIn(), len(args))
540 - }
541 - if !goodFunc(typ) {
542 - // TODO: This could still be a confusing error; maybe goodFunc should provide info.
543 - s.errorf("can't call method/function %q with %d results", name, typ.NumOut())
544 - }
545 - // Build the arg list.
546 - argv := make([]reflect.Value, numIn)
547 - // Args must be evaluated. Fixed args first.
548 - i := 0
549 - for ; i < numFixed && i < len(args); i++ {
550 - argv[i] = s.evalArg(dot, typ.In(i), args[i])
551 - }
552 - // Now the ... args.
553 - if typ.IsVariadic() {
554 - argType := typ.In(typ.NumIn() - 1).Elem() // Argument is a slice.
555 - for ; i < len(args); i++ {
556 - argv[i] = s.evalArg(dot, argType, args[i])
557 - }
558 - }
559 - // Add final value if necessary.
560 - if final.IsValid() {
561 - t := typ.In(typ.NumIn() - 1)
562 - if typ.IsVariadic() {
563 - t = t.Elem()
564 - }
565 - argv[i] = s.validateType(final, t)
566 - }
567 - result := fun.Call(argv)
568 - // If we have an error that is not nil, stop execution and return that error to the caller.
569 - if len(result) == 2 && !result[1].IsNil() {
570 - s.at(node)
571 - s.errorf("error calling %s: %s", name, result[1].Interface().(error))
572 - }
573 - return result[0]
574 -}
575 -
576 -// canBeNil reports whether an untyped nil can be assigned to the type. See reflect.Zero.
577 -func canBeNil(typ reflect.Type) bool {
578 - switch typ.Kind() {
579 - case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
580 - return true
581 - }
582 - return false
583 -}
584 -
585 -// validateType guarantees that the value is valid and assignable to the type.
586 -func (s *state) validateType(value reflect.Value, typ reflect.Type) reflect.Value {
587 - if !value.IsValid() {
588 - if typ == nil || canBeNil(typ) {
589 - // An untyped nil interface{}. Accept as a proper nil value.
590 - return reflect.Zero(typ)
591 - }
592 - s.errorf("invalid value; expected %s", typ)
593 - }
594 - if typ != nil && !value.Type().AssignableTo(typ) {
595 - if value.Kind() == reflect.Interface && !value.IsNil() {
596 - value = value.Elem()
597 - if value.Type().AssignableTo(typ) {
598 - return value
599 - }
600 - // fallthrough
601 - }
602 - // Does one dereference or indirection work? We could do more, as we
603 - // do with method receivers, but that gets messy and method receivers
604 - // are much more constrained, so it makes more sense there than here.
605 - // Besides, one is almost always all you need.
606 - switch {
607 - case value.Kind() == reflect.Ptr && value.Type().Elem().AssignableTo(typ):
608 - value = value.Elem()
609 - if !value.IsValid() {
610 - s.errorf("dereference of nil pointer of type %s", typ)
611 - }
612 - case reflect.PtrTo(value.Type()).AssignableTo(typ) && value.CanAddr():
613 - value = value.Addr()
614 - default:
615 - s.errorf("wrong type for value; expected %s; got %s", typ, value.Type())
616 - }
617 - }
618 - return value
619 -}
620 -
621 -func (s *state) evalArg(dot reflect.Value, typ reflect.Type, n parse.Node) reflect.Value {
622 - s.at(n)
623 - switch arg := n.(type) {
624 - case *parse.DotNode:
625 - return s.validateType(dot, typ)
626 - case *parse.NilNode:
627 - if canBeNil(typ) {
628 - return reflect.Zero(typ)
629 - }
630 - s.errorf("cannot assign nil to %s", typ)
631 - case *parse.FieldNode:
632 - return s.validateType(s.evalFieldNode(dot, arg, []parse.Node{n}, zero), typ)
633 - case *parse.VariableNode:
634 - return s.validateType(s.evalVariableNode(dot, arg, nil, zero), typ)
635 - case *parse.PipeNode:
636 - return s.validateType(s.evalPipeline(dot, arg), typ)
637 - case *parse.IdentifierNode:
638 - return s.evalFunction(dot, arg, arg, nil, zero)
639 - case *parse.ChainNode:
640 - return s.validateType(s.evalChainNode(dot, arg, nil, zero), typ)
641 - }
642 - switch typ.Kind() {
643 - case reflect.Bool:
644 - return s.evalBool(typ, n)
645 - case reflect.Complex64, reflect.Complex128:
646 - return s.evalComplex(typ, n)
647 - case reflect.Float32, reflect.Float64:
648 - return s.evalFloat(typ, n)
649 - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
650 - return s.evalInteger(typ, n)
651 - case reflect.Interface:
652 - if typ.NumMethod() == 0 {
653 - return s.evalEmptyInterface(dot, n)
654 - }
655 - case reflect.String:
656 - return s.evalString(typ, n)
657 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
658 - return s.evalUnsignedInteger(typ, n)
659 - }
660 - s.errorf("can't handle %s for arg of type %s", n, typ)
661 - panic("not reached")
662 -}
663 -
664 -func (s *state) evalBool(typ reflect.Type, n parse.Node) reflect.Value {
665 - s.at(n)
666 - if n, ok := n.(*parse.BoolNode); ok {
667 - value := reflect.New(typ).Elem()
668 - value.SetBool(n.True)
669 - return value
670 - }
671 - s.errorf("expected bool; found %s", n)
672 - panic("not reached")
673 -}
674 -
675 -func (s *state) evalString(typ reflect.Type, n parse.Node) reflect.Value {
676 - s.at(n)
677 - if n, ok := n.(*parse.StringNode); ok {
678 - value := reflect.New(typ).Elem()
679 - value.SetString(n.Text)
680 - return value
681 - }
682 - s.errorf("expected string; found %s", n)
683 - panic("not reached")
684 -}
685 -
686 -func (s *state) evalInteger(typ reflect.Type, n parse.Node) reflect.Value {
687 - s.at(n)
688 - if n, ok := n.(*parse.NumberNode); ok && n.IsInt {
689 - value := reflect.New(typ).Elem()
690 - value.SetInt(n.Int64)
691 - return value
692 - }
693 - s.errorf("expected integer; found %s", n)
694 - panic("not reached")
695 -}
696 -
697 -func (s *state) evalUnsignedInteger(typ reflect.Type, n parse.Node) reflect.Value {
698 - s.at(n)
699 - if n, ok := n.(*parse.NumberNode); ok && n.IsUint {
700 - value := reflect.New(typ).Elem()
701 - value.SetUint(n.Uint64)
702 - return value
703 - }
704 - s.errorf("expected unsigned integer; found %s", n)
705 - panic("not reached")
706 -}
707 -
708 -func (s *state) evalFloat(typ reflect.Type, n parse.Node) reflect.Value {
709 - s.at(n)
710 - if n, ok := n.(*parse.NumberNode); ok && n.IsFloat {
711 - value := reflect.New(typ).Elem()
712 - value.SetFloat(n.Float64)
713 - return value
714 - }
715 - s.errorf("expected float; found %s", n)
716 - panic("not reached")
717 -}
718 -
719 -func (s *state) evalComplex(typ reflect.Type, n parse.Node) reflect.Value {
720 - if n, ok := n.(*parse.NumberNode); ok && n.IsComplex {
721 - value := reflect.New(typ).Elem()
722 - value.SetComplex(n.Complex128)
723 - return value
724 - }
725 - s.errorf("expected complex; found %s", n)
726 - panic("not reached")
727 -}
728 -
729 -func (s *state) evalEmptyInterface(dot reflect.Value, n parse.Node) reflect.Value {
730 - s.at(n)
731 - switch n := n.(type) {
732 - case *parse.BoolNode:
733 - return reflect.ValueOf(n.True)
734 - case *parse.DotNode:
735 - return dot
736 - case *parse.FieldNode:
737 - return s.evalFieldNode(dot, n, nil, zero)
738 - case *parse.IdentifierNode:
739 - return s.evalFunction(dot, n, n, nil, zero)
740 - case *parse.NilNode:
741 - // NilNode is handled in evalArg, the only place that calls here.
742 - s.errorf("evalEmptyInterface: nil (can't happen)")
743 - case *parse.NumberNode:
744 - return s.idealConstant(n)
745 - case *parse.StringNode:
746 - return reflect.ValueOf(n.Text)
747 - case *parse.VariableNode:
748 - return s.evalVariableNode(dot, n, nil, zero)
749 - case *parse.PipeNode:
750 - return s.evalPipeline(dot, n)
751 - }
752 - s.errorf("can't handle assignment of %s to empty interface argument", n)
753 - panic("not reached")
754 -}
755 -
756 -// indirect returns the item at the end of indirection, and a bool to indicate if it's nil.
757 -// We indirect through pointers and empty interfaces (only) because
758 -// non-empty interfaces have methods we might need.
759 -func indirect(v reflect.Value) (rv reflect.Value, isNil bool) {
760 - for ; v.Kind() == reflect.Ptr || v.Kind() == reflect.Interface; v = v.Elem() {
761 - if v.IsNil() {
762 - return v, true
763 - }
764 - if v.Kind() == reflect.Interface && v.NumMethod() > 0 {
765 - break
766 - }
767 - }
768 - return v, false
769 -}
770 -
771 -// printValue writes the textual representation of the value to the output of
772 -// the template.
773 -func (s *state) printValue(n parse.Node, v reflect.Value) {
774 - s.at(n)
775 - iface, ok := printableValue(v)
776 - if !ok {
777 - s.errorf("can't print %s of type %s", n, v.Type())
778 - }
779 - fmt.Fprint(s.wr, iface)
780 -}
781 -
782 -// printableValue returns the, possibly indirected, interface value inside v that
783 -// is best for a call to formatted printer.
784 -func printableValue(v reflect.Value) (interface{}, bool) {
785 - if v.Kind() == reflect.Ptr {
786 - v, _ = indirect(v) // fmt.Fprint handles nil.
787 - }
788 - if !v.IsValid() {
789 - return "<no value>", true
790 - }
791 -
792 - if !v.Type().Implements(errorType) && !v.Type().Implements(fmtStringerType) {
793 - if v.CanAddr() && (reflect.PtrTo(v.Type()).Implements(errorType) || reflect.PtrTo(v.Type()).Implements(fmtStringerType)) {
794 - v = v.Addr()
795 - } else {
796 - switch v.Kind() {
797 - case reflect.Chan, reflect.Func:
798 - return nil, false
799 - }
800 - }
801 - }
802 - return v.Interface(), true
803 -}
804 -
805 -// Types to help sort the keys in a map for reproducible output.
806 -
807 -type rvs []reflect.Value
808 -
809 -func (x rvs) Len() int { return len(x) }
810 -func (x rvs) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
811 -
812 -type rvInts struct{ rvs }
813 -
814 -func (x rvInts) Less(i, j int) bool { return x.rvs[i].Int() < x.rvs[j].Int() }
815 -
816 -type rvUints struct{ rvs }
817 -
818 -func (x rvUints) Less(i, j int) bool { return x.rvs[i].Uint() < x.rvs[j].Uint() }
819 -
820 -type rvFloats struct{ rvs }
821 -
822 -func (x rvFloats) Less(i, j int) bool { return x.rvs[i].Float() < x.rvs[j].Float() }
823 -
824 -type rvStrings struct{ rvs }
825 -
826 -func (x rvStrings) Less(i, j int) bool { return x.rvs[i].String() < x.rvs[j].String() }
827 -
828 -// sortKeys sorts (if it can) the slice of reflect.Values, which is a slice of map keys.
829 -func sortKeys(v []reflect.Value) []reflect.Value {
830 - if len(v) <= 1 {
831 - return v
832 - }
833 - switch v[0].Kind() {
834 - case reflect.Float32, reflect.Float64:
835 - sort.Sort(rvFloats{v})
836 - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
837 - sort.Sort(rvInts{v})
838 - case reflect.String:
839 - sort.Sort(rvStrings{v})
840 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
841 - sort.Sort(rvUints{v})
842 - }
843 - return v
844 -}
Godeps/_workspace/src/github.com/alecthomas/template/exec_test.go deleted
-1044
@@ -1,1044 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package template
6 -
7 -import (
8 - "bytes"
9 - "errors"
10 - "flag"
11 - "fmt"
12 - "reflect"
13 - "strings"
14 - "testing"
15 -)
16 -
17 -var debug = flag.Bool("debug", false, "show the errors produced by the tests")
18 -
19 -// T has lots of interesting pieces to use to test execution.
20 -type T struct {
21 - // Basics
22 - True bool
23 - I int
24 - U16 uint16
25 - X string
26 - FloatZero float64
27 - ComplexZero complex128
28 - // Nested structs.
29 - U *U
30 - // Struct with String method.
31 - V0 V
32 - V1, V2 *V
33 - // Struct with Error method.
34 - W0 W
35 - W1, W2 *W
36 - // Slices
37 - SI []int
38 - SIEmpty []int
39 - SB []bool
40 - // Maps
41 - MSI map[string]int
42 - MSIone map[string]int // one element, for deterministic output
43 - MSIEmpty map[string]int
44 - MXI map[interface{}]int
45 - MII map[int]int
46 - SMSI []map[string]int
47 - // Empty interfaces; used to see if we can dig inside one.
48 - Empty0 interface{} // nil
49 - Empty1 interface{}
50 - Empty2 interface{}
51 - Empty3 interface{}
52 - Empty4 interface{}
53 - // Non-empty interface.
54 - NonEmptyInterface I
55 - // Stringer.
56 - Str fmt.Stringer
57 - Err error
58 - // Pointers
59 - PI *int
60 - PS *string
61 - PSI *[]int
62 - NIL *int
63 - // Function (not method)
64 - BinaryFunc func(string, string) string
65 - VariadicFunc func(...string) string
66 - VariadicFuncInt func(int, ...string) string
67 - NilOKFunc func(*int) bool
68 - ErrFunc func() (string, error)
69 - // Template to test evaluation of templates.
70 - Tmpl *Template
71 - // Unexported field; cannot be accessed by template.
72 - unexported int
73 -}
74 -
75 -type U struct {
76 - V string
77 -}
78 -
79 -type V struct {
80 - j int
81 -}
82 -
83 -func (v *V) String() string {
84 - if v == nil {
85 - return "nilV"
86 - }
87 - return fmt.Sprintf("<%d>", v.j)
88 -}
89 -
90 -type W struct {
91 - k int
92 -}
93 -
94 -func (w *W) Error() string {
95 - if w == nil {
96 - return "nilW"
97 - }
98 - return fmt.Sprintf("[%d]", w.k)
99 -}
100 -
101 -var tVal = &T{
102 - True: true,
103 - I: 17,
104 - U16: 16,
105 - X: "x",
106 - U: &U{"v"},
107 - V0: V{6666},
108 - V1: &V{7777}, // leave V2 as nil
109 - W0: W{888},
110 - W1: &W{999}, // leave W2 as nil
111 - SI: []int{3, 4, 5},
112 - SB: []bool{true, false},
113 - MSI: map[string]int{"one": 1, "two": 2, "three": 3},
114 - MSIone: map[string]int{"one": 1},
115 - MXI: map[interface{}]int{"one": 1},
116 - MII: map[int]int{1: 1},
117 - SMSI: []map[string]int{
118 - {"one": 1, "two": 2},
119 - {"eleven": 11, "twelve": 12},
120 - },
121 - Empty1: 3,
122 - Empty2: "empty2",
123 - Empty3: []int{7, 8},
124 - Empty4: &U{"UinEmpty"},
125 - NonEmptyInterface: new(T),
126 - Str: bytes.NewBuffer([]byte("foozle")),
127 - Err: errors.New("erroozle"),
128 - PI: newInt(23),
129 - PS: newString("a string"),
130 - PSI: newIntSlice(21, 22, 23),
131 - BinaryFunc: func(a, b string) string { return fmt.Sprintf("[%s=%s]", a, b) },
132 - VariadicFunc: func(s ...string) string { return fmt.Sprint("<", strings.Join(s, "+"), ">") },
133 - VariadicFuncInt: func(a int, s ...string) string { return fmt.Sprint(a, "=<", strings.Join(s, "+"), ">") },
134 - NilOKFunc: func(s *int) bool { return s == nil },
135 - ErrFunc: func() (string, error) { return "bla", nil },
136 - Tmpl: Must(New("x").Parse("test template")), // "x" is the value of .X
137 -}
138 -
139 -// A non-empty interface.
140 -type I interface {
141 - Method0() string
142 -}
143 -
144 -var iVal I = tVal
145 -
146 -// Helpers for creation.
147 -func newInt(n int) *int {
148 - return &n
149 -}
150 -
151 -func newString(s string) *string {
152 - return &s
153 -}
154 -
155 -func newIntSlice(n ...int) *[]int {
156 - p := new([]int)
157 - *p = make([]int, len(n))
158 - copy(*p, n)
159 - return p
160 -}
161 -
162 -// Simple methods with and without arguments.
163 -func (t *T) Method0() string {
164 - return "M0"
165 -}
166 -
167 -func (t *T) Method1(a int) int {
168 - return a
169 -}
170 -
171 -func (t *T) Method2(a uint16, b string) string {
172 - return fmt.Sprintf("Method2: %d %s", a, b)
173 -}
174 -
175 -func (t *T) Method3(v interface{}) string {
176 - return fmt.Sprintf("Method3: %v", v)
177 -}
178 -
179 -func (t *T) Copy() *T {
180 - n := new(T)
181 - *n = *t
182 - return n
183 -}
184 -
185 -func (t *T) MAdd(a int, b []int) []int {
186 - v := make([]int, len(b))
187 - for i, x := range b {
188 - v[i] = x + a
189 - }
190 - return v
191 -}
192 -
193 -var myError = errors.New("my error")
194 -
195 -// MyError returns a value and an error according to its argument.
196 -func (t *T) MyError(error bool) (bool, error) {
197 - if error {
198 - return true, myError
199 - }
200 - return false, nil
201 -}
202 -
203 -// A few methods to test chaining.
204 -func (t *T) GetU() *U {
205 - return t.U
206 -}
207 -
208 -func (u *U) TrueFalse(b bool) string {
209 - if b {
210 - return "true"
211 - }
212 - return ""
213 -}
214 -
215 -func typeOf(arg interface{}) string {
216 - return fmt.Sprintf("%T", arg)
217 -}
218 -
219 -type execTest struct {
220 - name string
221 - input string
222 - output string
223 - data interface{}
224 - ok bool
225 -}
226 -
227 -// bigInt and bigUint are hex string representing numbers either side
228 -// of the max int boundary.
229 -// We do it this way so the test doesn't depend on ints being 32 bits.
230 -var (
231 - bigInt = fmt.Sprintf("0x%x", int(1<<uint(reflect.TypeOf(0).Bits()-1)-1))
232 - bigUint = fmt.Sprintf("0x%x", uint(1<<uint(reflect.TypeOf(0).Bits()-1)))
233 -)
234 -
235 -var execTests = []execTest{
236 - // Trivial cases.
237 - {"empty", "", "", nil, true},
238 - {"text", "some text", "some text", nil, true},
239 - {"nil action", "{{nil}}", "", nil, false},
240 -
241 - // Ideal constants.
242 - {"ideal int", "{{typeOf 3}}", "int", 0, true},
243 - {"ideal float", "{{typeOf 1.0}}", "float64", 0, true},
244 - {"ideal exp float", "{{typeOf 1e1}}", "float64", 0, true},
245 - {"ideal complex", "{{typeOf 1i}}", "complex128", 0, true},
246 - {"ideal int", "{{typeOf " + bigInt + "}}", "int", 0, true},
247 - {"ideal too big", "{{typeOf " + bigUint + "}}", "", 0, false},
248 - {"ideal nil without type", "{{nil}}", "", 0, false},
249 -
250 - // Fields of structs.
251 - {".X", "-{{.X}}-", "-x-", tVal, true},
252 - {".U.V", "-{{.U.V}}-", "-v-", tVal, true},
253 - {".unexported", "{{.unexported}}", "", tVal, false},
254 -
255 - // Fields on maps.
256 - {"map .one", "{{.MSI.one}}", "1", tVal, true},
257 - {"map .two", "{{.MSI.two}}", "2", tVal, true},
258 - {"map .NO", "{{.MSI.NO}}", "<no value>", tVal, true},
259 - {"map .one interface", "{{.MXI.one}}", "1", tVal, true},
260 - {"map .WRONG args", "{{.MSI.one 1}}", "", tVal, false},
261 - {"map .WRONG type", "{{.MII.one}}", "", tVal, false},
262 -
263 - // Dots of all kinds to test basic evaluation.
264 - {"dot int", "<{{.}}>", "<13>", 13, true},
265 - {"dot uint", "<{{.}}>", "<14>", uint(14), true},
266 - {"dot float", "<{{.}}>", "<15.1>", 15.1, true},
267 - {"dot bool", "<{{.}}>", "<true>", true, true},
268 - {"dot complex", "<{{.}}>", "<(16.2-17i)>", 16.2 - 17i, true},
269 - {"dot string", "<{{.}}>", "<hello>", "hello", true},
270 - {"dot slice", "<{{.}}>", "<[-1 -2 -3]>", []int{-1, -2, -3}, true},
271 - {"dot map", "<{{.}}>", "<map[two:22]>", map[string]int{"two": 22}, true},
272 - {"dot struct", "<{{.}}>", "<{7 seven}>", struct {
273 - a int
274 - b string
275 - }{7, "seven"}, true},
276 -
277 - // Variables.
278 - {"$ int", "{{$}}", "123", 123, true},
279 - {"$.I", "{{$.I}}", "17", tVal, true},
280 - {"$.U.V", "{{$.U.V}}", "v", tVal, true},
281 - {"declare in action", "{{$x := $.U.V}}{{$x}}", "v", tVal, true},
282 -
283 - // Type with String method.
284 - {"V{6666}.String()", "-{{.V0}}-", "-<6666>-", tVal, true},
285 - {"&V{7777}.String()", "-{{.V1}}-", "-<7777>-", tVal, true},
286 - {"(*V)(nil).String()", "-{{.V2}}-", "-nilV-", tVal, true},
287 -
288 - // Type with Error method.
289 - {"W{888}.Error()", "-{{.W0}}-", "-[888]-", tVal, true},
290 - {"&W{999}.Error()", "-{{.W1}}-", "-[999]-", tVal, true},
291 - {"(*W)(nil).Error()", "-{{.W2}}-", "-nilW-", tVal, true},
292 -
293 - // Pointers.
294 - {"*int", "{{.PI}}", "23", tVal, true},
295 - {"*string", "{{.PS}}", "a string", tVal, true},
296 - {"*[]int", "{{.PSI}}", "[21 22 23]", tVal, true},
297 - {"*[]int[1]", "{{index .PSI 1}}", "22", tVal, true},
298 - {"NIL", "{{.NIL}}", "<nil>", tVal, true},
299 -
300 - // Empty interfaces holding values.
301 - {"empty nil", "{{.Empty0}}", "<no value>", tVal, true},
302 - {"empty with int", "{{.Empty1}}", "3", tVal, true},
303 - {"empty with string", "{{.Empty2}}", "empty2", tVal, true},
304 - {"empty with slice", "{{.Empty3}}", "[7 8]", tVal, true},
305 - {"empty with struct", "{{.Empty4}}", "{UinEmpty}", tVal, true},
306 - {"empty with struct, field", "{{.Empty4.V}}", "UinEmpty", tVal, true},
307 -
308 - // Method calls.
309 - {".Method0", "-{{.Method0}}-", "-M0-", tVal, true},
310 - {".Method1(1234)", "-{{.Method1 1234}}-", "-1234-", tVal, true},
311 - {".Method1(.I)", "-{{.Method1 .I}}-", "-17-", tVal, true},
312 - {".Method2(3, .X)", "-{{.Method2 3 .X}}-", "-Method2: 3 x-", tVal, true},
313 - {".Method2(.U16, `str`)", "-{{.Method2 .U16 `str`}}-", "-Method2: 16 str-", tVal, true},
314 - {".Method2(.U16, $x)", "{{if $x := .X}}-{{.Method2 .U16 $x}}{{end}}-", "-Method2: 16 x-", tVal, true},
315 - {".Method3(nil constant)", "-{{.Method3 nil}}-", "-Method3: <nil>-", tVal, true},
316 - {".Method3(nil value)", "-{{.Method3 .MXI.unset}}-", "-Method3: <nil>-", tVal, true},
317 - {"method on var", "{{if $x := .}}-{{$x.Method2 .U16 $x.X}}{{end}}-", "-Method2: 16 x-", tVal, true},
318 - {"method on chained var",
319 - "{{range .MSIone}}{{if $.U.TrueFalse $.True}}{{$.U.TrueFalse $.True}}{{else}}WRONG{{end}}{{end}}",
320 - "true", tVal, true},
321 - {"chained method",
322 - "{{range .MSIone}}{{if $.GetU.TrueFalse $.True}}{{$.U.TrueFalse $.True}}{{else}}WRONG{{end}}{{end}}",
323 - "true", tVal, true},
324 - {"chained method on variable",
325 - "{{with $x := .}}{{with .SI}}{{$.GetU.TrueFalse $.True}}{{end}}{{end}}",
326 - "true", tVal, true},
327 - {".NilOKFunc not nil", "{{call .NilOKFunc .PI}}", "false", tVal, true},
328 - {".NilOKFunc nil", "{{call .NilOKFunc nil}}", "true", tVal, true},
329 -
330 - // Function call builtin.
331 - {".BinaryFunc", "{{call .BinaryFunc `1` `2`}}", "[1=2]", tVal, true},
332 - {".VariadicFunc0", "{{call .VariadicFunc}}", "<>", tVal, true},
333 - {".VariadicFunc2", "{{call .VariadicFunc `he` `llo`}}", "<he+llo>", tVal, true},
334 - {".VariadicFuncInt", "{{call .VariadicFuncInt 33 `he` `llo`}}", "33=<he+llo>", tVal, true},
335 - {"if .BinaryFunc call", "{{ if .BinaryFunc}}{{call .BinaryFunc `1` `2`}}{{end}}", "[1=2]", tVal, true},
336 - {"if not .BinaryFunc call", "{{ if not .BinaryFunc}}{{call .BinaryFunc `1` `2`}}{{else}}No{{end}}", "No", tVal, true},
337 - {"Interface Call", `{{stringer .S}}`, "foozle", map[string]interface{}{"S": bytes.NewBufferString("foozle")}, true},
338 - {".ErrFunc", "{{call .ErrFunc}}", "bla", tVal, true},
339 -
340 - // Erroneous function calls (check args).
341 - {".BinaryFuncTooFew", "{{call .BinaryFunc `1`}}", "", tVal, false},
342 - {".BinaryFuncTooMany", "{{call .BinaryFunc `1` `2` `3`}}", "", tVal, false},
343 - {".BinaryFuncBad0", "{{call .BinaryFunc 1 3}}", "", tVal, false},
344 - {".BinaryFuncBad1", "{{call .BinaryFunc `1` 3}}", "", tVal, false},
345 - {".VariadicFuncBad0", "{{call .VariadicFunc 3}}", "", tVal, false},
346 - {".VariadicFuncIntBad0", "{{call .VariadicFuncInt}}", "", tVal, false},
347 - {".VariadicFuncIntBad`", "{{call .VariadicFuncInt `x`}}", "", tVal, false},
348 - {".VariadicFuncNilBad", "{{call .VariadicFunc nil}}", "", tVal, false},
349 -
350 - // Pipelines.
351 - {"pipeline", "-{{.Method0 | .Method2 .U16}}-", "-Method2: 16 M0-", tVal, true},
352 - {"pipeline func", "-{{call .VariadicFunc `llo` | call .VariadicFunc `he` }}-", "-<he+<llo>>-", tVal, true},
353 -
354 - // Parenthesized expressions
355 - {"parens in pipeline", "{{printf `%d %d %d` (1) (2 | add 3) (add 4 (add 5 6))}}", "1 5 15", tVal, true},
356 -
357 - // Parenthesized expressions with field accesses
358 - {"parens: $ in paren", "{{($).X}}", "x", tVal, true},
359 - {"parens: $.GetU in paren", "{{($.GetU).V}}", "v", tVal, true},
360 - {"parens: $ in paren in pipe", "{{($ | echo).X}}", "x", tVal, true},
361 - {"parens: spaces and args", `{{(makemap "up" "down" "left" "right").left}}`, "right", tVal, true},
362 -
363 - // If.
364 - {"if true", "{{if true}}TRUE{{end}}", "TRUE", tVal, true},
365 - {"if false", "{{if false}}TRUE{{else}}FALSE{{end}}", "FALSE", tVal, true},
366 - {"if nil", "{{if nil}}TRUE{{end}}", "", tVal, false},
367 - {"if 1", "{{if 1}}NON-ZERO{{else}}ZERO{{end}}", "NON-ZERO", tVal, true},
368 - {"if 0", "{{if 0}}NON-ZERO{{else}}ZERO{{end}}", "ZERO", tVal, true},
369 - {"if 1.5", "{{if 1.5}}NON-ZERO{{else}}ZERO{{end}}", "NON-ZERO", tVal, true},
370 - {"if 0.0", "{{if .FloatZero}}NON-ZERO{{else}}ZERO{{end}}", "ZERO", tVal, true},
371 - {"if 1.5i", "{{if 1.5i}}NON-ZERO{{else}}ZERO{{end}}", "NON-ZERO", tVal, true},
372 - {"if 0.0i", "{{if .ComplexZero}}NON-ZERO{{else}}ZERO{{end}}", "ZERO", tVal, true},
373 - {"if emptystring", "{{if ``}}NON-EMPTY{{else}}EMPTY{{end}}", "EMPTY", tVal, true},
374 - {"if string", "{{if `notempty`}}NON-EMPTY{{else}}EMPTY{{end}}", "NON-EMPTY", tVal, true},
375 - {"if emptyslice", "{{if .SIEmpty}}NON-EMPTY{{else}}EMPTY{{end}}", "EMPTY", tVal, true},
376 - {"if slice", "{{if .SI}}NON-EMPTY{{else}}EMPTY{{end}}", "NON-EMPTY", tVal, true},
377 - {"if emptymap", "{{if .MSIEmpty}}NON-EMPTY{{else}}EMPTY{{end}}", "EMPTY", tVal, true},
378 - {"if map", "{{if .MSI}}NON-EMPTY{{else}}EMPTY{{end}}", "NON-EMPTY", tVal, true},
379 - {"if map unset", "{{if .MXI.none}}NON-ZERO{{else}}ZERO{{end}}", "ZERO", tVal, true},
380 - {"if map not unset", "{{if not .MXI.none}}ZERO{{else}}NON-ZERO{{end}}", "ZERO", tVal, true},
381 - {"if $x with $y int", "{{if $x := true}}{{with $y := .I}}{{$x}},{{$y}}{{end}}{{end}}", "true,17", tVal, true},
382 - {"if $x with $x int", "{{if $x := true}}{{with $x := .I}}{{$x}},{{end}}{{$x}}{{end}}", "17,true", tVal, true},
383 - {"if else if", "{{if false}}FALSE{{else if true}}TRUE{{end}}", "TRUE", tVal, true},
384 - {"if else chain", "{{if eq 1 3}}1{{else if eq 2 3}}2{{else if eq 3 3}}3{{end}}", "3", tVal, true},
385 -
386 - // Print etc.
387 - {"print", `{{print "hello, print"}}`, "hello, print", tVal, true},
388 - {"print 123", `{{print 1 2 3}}`, "1 2 3", tVal, true},
389 - {"print nil", `{{print nil}}`, "<nil>", tVal, true},
390 - {"println", `{{println 1 2 3}}`, "1 2 3\n", tVal, true},
391 - {"printf int", `{{printf "%04x" 127}}`, "007f", tVal, true},
392 - {"printf float", `{{printf "%g" 3.5}}`, "3.5", tVal, true},
393 - {"printf complex", `{{printf "%g" 1+7i}}`, "(1+7i)", tVal, true},
394 - {"printf string", `{{printf "%s" "hello"}}`, "hello", tVal, true},
395 - {"printf function", `{{printf "%#q" zeroArgs}}`, "`zeroArgs`", tVal, true},
396 - {"printf field", `{{printf "%s" .U.V}}`, "v", tVal, true},
397 - {"printf method", `{{printf "%s" .Method0}}`, "M0", tVal, true},
398 - {"printf dot", `{{with .I}}{{printf "%d" .}}{{end}}`, "17", tVal, true},
399 - {"printf var", `{{with $x := .I}}{{printf "%d" $x}}{{end}}`, "17", tVal, true},
400 - {"printf lots", `{{printf "%d %s %g %s" 127 "hello" 7-3i .Method0}}`, "127 hello (7-3i) M0", tVal, true},
401 -
402 - // HTML.
403 - {"html", `{{html "<script>alert(\"XSS\");</script>"}}`,
404 - "&lt;script&gt;alert(&#34;XSS&#34;);&lt;/script&gt;", nil, true},
405 - {"html pipeline", `{{printf "<script>alert(\"XSS\");</script>" | html}}`,
406 - "&lt;script&gt;alert(&#34;XSS&#34;);&lt;/script&gt;", nil, true},
407 - {"html", `{{html .PS}}`, "a string", tVal, true},
408 -
409 - // JavaScript.
410 - {"js", `{{js .}}`, `It\'d be nice.`, `It'd be nice.`, true},
411 -
412 - // URL query.
413 - {"urlquery", `{{"http://www.example.org/"|urlquery}}`, "http%3A%2F%2Fwww.example.org%2F", nil, true},
414 -
415 - // Booleans
416 - {"not", "{{not true}} {{not false}}", "false true", nil, true},
417 - {"and", "{{and false 0}} {{and 1 0}} {{and 0 true}} {{and 1 1}}", "false 0 0 1", nil, true},
418 - {"or", "{{or 0 0}} {{or 1 0}} {{or 0 true}} {{or 1 1}}", "0 1 true 1", nil, true},
419 - {"boolean if", "{{if and true 1 `hi`}}TRUE{{else}}FALSE{{end}}", "TRUE", tVal, true},
420 - {"boolean if not", "{{if and true 1 `hi` | not}}TRUE{{else}}FALSE{{end}}", "FALSE", nil, true},
421 -
422 - // Indexing.
423 - {"slice[0]", "{{index .SI 0}}", "3", tVal, true},
424 - {"slice[1]", "{{index .SI 1}}", "4", tVal, true},
425 - {"slice[HUGE]", "{{index .SI 10}}", "", tVal, false},
426 - {"slice[WRONG]", "{{index .SI `hello`}}", "", tVal, false},
427 - {"map[one]", "{{index .MSI `one`}}", "1", tVal, true},
428 - {"map[two]", "{{index .MSI `two`}}", "2", tVal, true},
429 - {"map[NO]", "{{index .MSI `XXX`}}", "0", tVal, true},
430 - {"map[nil]", "{{index .MSI nil}}", "0", tVal, true},
431 - {"map[WRONG]", "{{index .MSI 10}}", "", tVal, false},
432 - {"double index", "{{index .SMSI 1 `eleven`}}", "11", tVal, true},
433 -
434 - // Len.
435 - {"slice", "{{len .SI}}", "3", tVal, true},
436 - {"map", "{{len .MSI }}", "3", tVal, true},
437 - {"len of int", "{{len 3}}", "", tVal, false},
438 - {"len of nothing", "{{len .Empty0}}", "", tVal, false},
439 -
440 - // With.
441 - {"with true", "{{with true}}{{.}}{{end}}", "true", tVal, true},
442 - {"with false", "{{with false}}{{.}}{{else}}FALSE{{end}}", "FALSE", tVal, true},
443 - {"with 1", "{{with 1}}{{.}}{{else}}ZERO{{end}}", "1", tVal, true},
444 - {"with 0", "{{with 0}}{{.}}{{else}}ZERO{{end}}", "ZERO", tVal, true},
445 - {"with 1.5", "{{with 1.5}}{{.}}{{else}}ZERO{{end}}", "1.5", tVal, true},
446 - {"with 0.0", "{{with .FloatZero}}{{.}}{{else}}ZERO{{end}}", "ZERO", tVal, true},
447 - {"with 1.5i", "{{with 1.5i}}{{.}}{{else}}ZERO{{end}}", "(0+1.5i)", tVal, true},
448 - {"with 0.0i", "{{with .ComplexZero}}{{.}}{{else}}ZERO{{end}}", "ZERO", tVal, true},
449 - {"with emptystring", "{{with ``}}{{.}}{{else}}EMPTY{{end}}", "EMPTY", tVal, true},
450 - {"with string", "{{with `notempty`}}{{.}}{{else}}EMPTY{{end}}", "notempty", tVal, true},
451 - {"with emptyslice", "{{with .SIEmpty}}{{.}}{{else}}EMPTY{{end}}", "EMPTY", tVal, true},
452 - {"with slice", "{{with .SI}}{{.}}{{else}}EMPTY{{end}}", "[3 4 5]", tVal, true},
453 - {"with emptymap", "{{with .MSIEmpty}}{{.}}{{else}}EMPTY{{end}}", "EMPTY", tVal, true},
454 - {"with map", "{{with .MSIone}}{{.}}{{else}}EMPTY{{end}}", "map[one:1]", tVal, true},
455 - {"with empty interface, struct field", "{{with .Empty4}}{{.V}}{{end}}", "UinEmpty", tVal, true},
456 - {"with $x int", "{{with $x := .I}}{{$x}}{{end}}", "17", tVal, true},
457 - {"with $x struct.U.V", "{{with $x := $}}{{$x.U.V}}{{end}}", "v", tVal, true},
458 - {"with variable and action", "{{with $x := $}}{{$y := $.U.V}}{{$y}}{{end}}", "v", tVal, true},
459 -
460 - // Range.
461 - {"range []int", "{{range .SI}}-{{.}}-{{end}}", "-3--4--5-", tVal, true},
462 - {"range empty no else", "{{range .SIEmpty}}-{{.}}-{{end}}", "", tVal, true},
463 - {"range []int else", "{{range .SI}}-{{.}}-{{else}}EMPTY{{end}}", "-3--4--5-", tVal, true},
464 - {"range empty else", "{{range .SIEmpty}}-{{.}}-{{else}}EMPTY{{end}}", "EMPTY", tVal, true},
465 - {"range []bool", "{{range .SB}}-{{.}}-{{end}}", "-true--false-", tVal, true},
466 - {"range []int method", "{{range .SI | .MAdd .I}}-{{.}}-{{end}}", "-20--21--22-", tVal, true},
467 - {"range map", "{{range .MSI}}-{{.}}-{{end}}", "-1--3--2-", tVal, true},
468 - {"range empty map no else", "{{range .MSIEmpty}}-{{.}}-{{end}}", "", tVal, true},
469 - {"range map else", "{{range .MSI}}-{{.}}-{{else}}EMPTY{{end}}", "-1--3--2-", tVal, true},
470 - {"range empty map else", "{{range .MSIEmpty}}-{{.}}-{{else}}EMPTY{{end}}", "EMPTY", tVal, true},
471 - {"range empty interface", "{{range .Empty3}}-{{.}}-{{else}}EMPTY{{end}}", "-7--8-", tVal, true},
472 - {"range empty nil", "{{range .Empty0}}-{{.}}-{{end}}", "", tVal, true},
473 - {"range $x SI", "{{range $x := .SI}}<{{$x}}>{{end}}", "<3><4><5>", tVal, true},
474 - {"range $x $y SI", "{{range $x, $y := .SI}}<{{$x}}={{$y}}>{{end}}", "<0=3><1=4><2=5>", tVal, true},
475 - {"range $x MSIone", "{{range $x := .MSIone}}<{{$x}}>{{end}}", "<1>", tVal, true},
476 - {"range $x $y MSIone", "{{range $x, $y := .MSIone}}<{{$x}}={{$y}}>{{end}}", "<one=1>", tVal, true},
477 - {"range $x PSI", "{{range $x := .PSI}}<{{$x}}>{{end}}", "<21><22><23>", tVal, true},
478 - {"declare in range", "{{range $x := .PSI}}<{{$foo:=$x}}{{$x}}>{{end}}", "<21><22><23>", tVal, true},
479 - {"range count", `{{range $i, $x := count 5}}[{{$i}}]{{$x}}{{end}}`, "[0]a[1]b[2]c[3]d[4]e", tVal, true},
480 - {"range nil count", `{{range $i, $x := count 0}}{{else}}empty{{end}}`, "empty", tVal, true},
481 -
482 - // Cute examples.
483 - {"or as if true", `{{or .SI "slice is empty"}}`, "[3 4 5]", tVal, true},
484 - {"or as if false", `{{or .SIEmpty "slice is empty"}}`, "slice is empty", tVal, true},
485 -
486 - // Error handling.
487 - {"error method, error", "{{.MyError true}}", "", tVal, false},
488 - {"error method, no error", "{{.MyError false}}", "false", tVal, true},
489 -
490 - // Fixed bugs.
491 - // Must separate dot and receiver; otherwise args are evaluated with dot set to variable.
492 - {"bug0", "{{range .MSIone}}{{if $.Method1 .}}X{{end}}{{end}}", "X", tVal, true},
493 - // Do not loop endlessly in indirect for non-empty interfaces.
494 - // The bug appears with *interface only; looped forever.
495 - {"bug1", "{{.Method0}}", "M0", &iVal, true},
496 - // Was taking address of interface field, so method set was empty.
497 - {"bug2", "{{$.NonEmptyInterface.Method0}}", "M0", tVal, true},
498 - // Struct values were not legal in with - mere oversight.
499 - {"bug3", "{{with $}}{{.Method0}}{{end}}", "M0", tVal, true},
500 - // Nil interface values in if.
501 - {"bug4", "{{if .Empty0}}non-nil{{else}}nil{{end}}", "nil", tVal, true},
502 - // Stringer.
503 - {"bug5", "{{.Str}}", "foozle", tVal, true},
504 - {"bug5a", "{{.Err}}", "erroozle", tVal, true},
505 - // Args need to be indirected and dereferenced sometimes.
506 - {"bug6a", "{{vfunc .V0 .V1}}", "vfunc", tVal, true},
507 - {"bug6b", "{{vfunc .V0 .V0}}", "vfunc", tVal, true},
508 - {"bug6c", "{{vfunc .V1 .V0}}", "vfunc", tVal, true},
509 - {"bug6d", "{{vfunc .V1 .V1}}", "vfunc", tVal, true},
510 - // Legal parse but illegal execution: non-function should have no arguments.
511 - {"bug7a", "{{3 2}}", "", tVal, false},
512 - {"bug7b", "{{$x := 1}}{{$x 2}}", "", tVal, false},
513 - {"bug7c", "{{$x := 1}}{{3 | $x}}", "", tVal, false},
514 - // Pipelined arg was not being type-checked.
515 - {"bug8a", "{{3|oneArg}}", "", tVal, false},
516 - {"bug8b", "{{4|dddArg 3}}", "", tVal, false},
517 - // A bug was introduced that broke map lookups for lower-case names.
518 - {"bug9", "{{.cause}}", "neglect", map[string]string{"cause": "neglect"}, true},
519 - // Field chain starting with function did not work.
520 - {"bug10", "{{mapOfThree.three}}-{{(mapOfThree).three}}", "3-3", 0, true},
521 - // Dereferencing nil pointer while evaluating function arguments should not panic. Issue 7333.
522 - {"bug11", "{{valueString .PS}}", "", T{}, false},
523 - // 0xef gave constant type float64. Issue 8622.
524 - {"bug12xe", "{{printf `%T` 0xef}}", "int", T{}, true},
525 - {"bug12xE", "{{printf `%T` 0xEE}}", "int", T{}, true},
526 - {"bug12Xe", "{{printf `%T` 0Xef}}", "int", T{}, true},
527 - {"bug12XE", "{{printf `%T` 0XEE}}", "int", T{}, true},
528 - // Chained nodes did not work as arguments. Issue 8473.
529 - {"bug13", "{{print (.Copy).I}}", "17", tVal, true},
530 -}
531 -
532 -func zeroArgs() string {
533 - return "zeroArgs"
534 -}
535 -
536 -func oneArg(a string) string {
537 - return "oneArg=" + a
538 -}
539 -
540 -func dddArg(a int, b ...string) string {
541 - return fmt.Sprintln(a, b)
542 -}
543 -
544 -// count returns a channel that will deliver n sequential 1-letter strings starting at "a"
545 -func count(n int) chan string {
546 - if n == 0 {
547 - return nil
548 - }
549 - c := make(chan string)
550 - go func() {
551 - for i := 0; i < n; i++ {
552 - c <- "abcdefghijklmnop"[i : i+1]
553 - }
554 - close(c)
555 - }()
556 - return c
557 -}
558 -
559 -// vfunc takes a *V and a V
560 -func vfunc(V, *V) string {
561 - return "vfunc"
562 -}
563 -
564 -// valueString takes a string, not a pointer.
565 -func valueString(v string) string {
566 - return "value is ignored"
567 -}
568 -
569 -func add(args ...int) int {
570 - sum := 0
571 - for _, x := range args {
572 - sum += x
573 - }
574 - return sum
575 -}
576 -
577 -func echo(arg interface{}) interface{} {
578 - return arg
579 -}
580 -
581 -func makemap(arg ...string) map[string]string {
582 - if len(arg)%2 != 0 {
583 - panic("bad makemap")
584 - }
585 - m := make(map[string]string)
586 - for i := 0; i < len(arg); i += 2 {
587 - m[arg[i]] = arg[i+1]
588 - }
589 - return m
590 -}
591 -
592 -func stringer(s fmt.Stringer) string {
593 - return s.String()
594 -}
595 -
596 -func mapOfThree() interface{} {
597 - return map[string]int{"three": 3}
598 -}
599 -
600 -func testExecute(execTests []execTest, template *Template, t *testing.T) {
601 - b := new(bytes.Buffer)
602 - funcs := FuncMap{
603 - "add": add,
604 - "count": count,
605 - "dddArg": dddArg,
606 - "echo": echo,
607 - "makemap": makemap,
608 - "mapOfThree": mapOfThree,
609 - "oneArg": oneArg,
610 - "stringer": stringer,
611 - "typeOf": typeOf,
612 - "valueString": valueString,
613 - "vfunc": vfunc,
614 - "zeroArgs": zeroArgs,
615 - }
616 - for _, test := range execTests {
617 - var tmpl *Template
618 - var err error
619 - if template == nil {
620 - tmpl, err = New(test.name).Funcs(funcs).Parse(test.input)
621 - } else {
622 - tmpl, err = template.New(test.name).Funcs(funcs).Parse(test.input)
623 - }
624 - if err != nil {
625 - t.Errorf("%s: parse error: %s", test.name, err)
626 - continue
627 - }
628 - b.Reset()
629 - err = tmpl.Execute(b, test.data)
630 - switch {
631 - case !test.ok && err == nil:
632 - t.Errorf("%s: expected error; got none", test.name)
633 - continue
634 - case test.ok && err != nil:
635 - t.Errorf("%s: unexpected execute error: %s", test.name, err)
636 - continue
637 - case !test.ok && err != nil:
638 - // expected error, got one
639 - if *debug {
640 - fmt.Printf("%s: %s\n\t%s\n", test.name, test.input, err)
641 - }
642 - }
643 - result := b.String()
644 - if result != test.output {
645 - t.Errorf("%s: expected\n\t%q\ngot\n\t%q", test.name, test.output, result)
646 - }
647 - }
648 -}
649 -
650 -func TestExecute(t *testing.T) {
651 - testExecute(execTests, nil, t)
652 -}
653 -
654 -var delimPairs = []string{
655 - "", "", // default
656 - "{{", "}}", // same as default
657 - "<<", ">>", // distinct
658 - "|", "|", // same
659 - "(日)", "(本)", // peculiar
660 -}
661 -
662 -func TestDelims(t *testing.T) {
663 - const hello = "Hello, world"
664 - var value = struct{ Str string }{hello}
665 - for i := 0; i < len(delimPairs); i += 2 {
666 - text := ".Str"
667 - left := delimPairs[i+0]
668 - trueLeft := left
669 - right := delimPairs[i+1]
670 - trueRight := right
671 - if left == "" { // default case
672 - trueLeft = "{{"
673 - }
674 - if right == "" { // default case
675 - trueRight = "}}"
676 - }
677 - text = trueLeft + text + trueRight
678 - // Now add a comment
679 - text += trueLeft + "/*comment*/" + trueRight
680 - // Now add an action containing a string.
681 - text += trueLeft + `"` + trueLeft + `"` + trueRight
682 - // At this point text looks like `{{.Str}}{{/*comment*/}}{{"{{"}}`.
683 - tmpl, err := New("delims").Delims(left, right).Parse(text)
684 - if err != nil {
685 - t.Fatalf("delim %q text %q parse err %s", left, text, err)
686 - }
687 - var b = new(bytes.Buffer)
688 - err = tmpl.Execute(b, value)
689 - if err != nil {
690 - t.Fatalf("delim %q exec err %s", left, err)
691 - }
692 - if b.String() != hello+trueLeft {
693 - t.Errorf("expected %q got %q", hello+trueLeft, b.String())
694 - }
695 - }
696 -}
697 -
698 -// Check that an error from a method flows back to the top.
699 -func TestExecuteError(t *testing.T) {
700 - b := new(bytes.Buffer)
701 - tmpl := New("error")
702 - _, err := tmpl.Parse("{{.MyError true}}")
703 - if err != nil {
704 - t.Fatalf("parse error: %s", err)
705 - }
706 - err = tmpl.Execute(b, tVal)
707 - if err == nil {
708 - t.Errorf("expected error; got none")
709 - } else if !strings.Contains(err.Error(), myError.Error()) {
710 - if *debug {
711 - fmt.Printf("test execute error: %s\n", err)
712 - }
713 - t.Errorf("expected myError; got %s", err)
714 - }
715 -}
716 -
717 -const execErrorText = `line 1
718 -line 2
719 -line 3
720 -{{template "one" .}}
721 -{{define "one"}}{{template "two" .}}{{end}}
722 -{{define "two"}}{{template "three" .}}{{end}}
723 -{{define "three"}}{{index "hi" $}}{{end}}`
724 -
725 -// Check that an error from a nested template contains all the relevant information.
726 -func TestExecError(t *testing.T) {
727 - tmpl, err := New("top").Parse(execErrorText)
728 - if err != nil {
729 - t.Fatal("parse error:", err)
730 - }
731 - var b bytes.Buffer
732 - err = tmpl.Execute(&b, 5) // 5 is out of range indexing "hi"
733 - if err == nil {
734 - t.Fatal("expected error")
735 - }
736 - const want = `template: top:7:20: executing "three" at <index "hi" $>: error calling index: index out of range: 5`
737 - got := err.Error()
738 - if got != want {
739 - t.Errorf("expected\n%q\ngot\n%q", want, got)
740 - }
741 -}
742 -
743 -func TestJSEscaping(t *testing.T) {
744 - testCases := []struct {
745 - in, exp string
746 - }{
747 - {`a`, `a`},
748 - {`'foo`, `\'foo`},
749 - {`Go "jump" \`, `Go \"jump\" \\`},
750 - {`Yukihiro says "今日は世界"`, `Yukihiro says \"今日は世界\"`},
751 - {"unprintable \uFDFF", `unprintable \uFDFF`},
752 - {`<html>`, `\x3Chtml\x3E`},
753 - }
754 - for _, tc := range testCases {
755 - s := JSEscapeString(tc.in)
756 - if s != tc.exp {
757 - t.Errorf("JS escaping [%s] got [%s] want [%s]", tc.in, s, tc.exp)
758 - }
759 - }
760 -}
761 -
762 -// A nice example: walk a binary tree.
763 -
764 -type Tree struct {
765 - Val int
766 - Left, Right *Tree
767 -}
768 -
769 -// Use different delimiters to test Set.Delims.
770 -const treeTemplate = `
771 - (define "tree")
772 - [
773 - (.Val)
774 - (with .Left)
775 - (template "tree" .)
776 - (end)
777 - (with .Right)
778 - (template "tree" .)
779 - (end)
780 - ]
781 - (end)
782 -`
783 -
784 -func TestTree(t *testing.T) {
785 - var tree = &Tree{
786 - 1,
787 - &Tree{
788 - 2, &Tree{
789 - 3,
790 - &Tree{
791 - 4, nil, nil,
792 - },
793 - nil,
794 - },
795 - &Tree{
796 - 5,
797 - &Tree{
798 - 6, nil, nil,
799 - },
800 - nil,
801 - },
802 - },
803 - &Tree{
804 - 7,
805 - &Tree{
806 - 8,
807 - &Tree{
808 - 9, nil, nil,
809 - },
810 - nil,
811 - },
812 - &Tree{
813 - 10,
814 - &Tree{
815 - 11, nil, nil,
816 - },
817 - nil,
818 - },
819 - },
820 - }
821 - tmpl, err := New("root").Delims("(", ")").Parse(treeTemplate)
822 - if err != nil {
823 - t.Fatal("parse error:", err)
824 - }
825 - var b bytes.Buffer
826 - stripSpace := func(r rune) rune {
827 - if r == '\t' || r == '\n' {
828 - return -1
829 - }
830 - return r
831 - }
832 - const expect = "[1[2[3[4]][5[6]]][7[8[9]][10[11]]]]"
833 - // First by looking up the template.
834 - err = tmpl.Lookup("tree").Execute(&b, tree)
835 - if err != nil {
836 - t.Fatal("exec error:", err)
837 - }
838 - result := strings.Map(stripSpace, b.String())
839 - if result != expect {
840 - t.Errorf("expected %q got %q", expect, result)
841 - }
842 - // Then direct to execution.
843 - b.Reset()
844 - err = tmpl.ExecuteTemplate(&b, "tree", tree)
845 - if err != nil {
846 - t.Fatal("exec error:", err)
847 - }
848 - result = strings.Map(stripSpace, b.String())
849 - if result != expect {
850 - t.Errorf("expected %q got %q", expect, result)
851 - }
852 -}
853 -
854 -func TestExecuteOnNewTemplate(t *testing.T) {
855 - // This is issue 3872.
856 - _ = New("Name").Templates()
857 -}
858 -
859 -const testTemplates = `{{define "one"}}one{{end}}{{define "two"}}two{{end}}`
860 -
861 -func TestMessageForExecuteEmpty(t *testing.T) {
862 - // Test a truly empty template.
863 - tmpl := New("empty")
864 - var b bytes.Buffer
865 - err := tmpl.Execute(&b, 0)
866 - if err == nil {
867 - t.Fatal("expected initial error")
868 - }
869 - got := err.Error()
870 - want := `template: empty: "empty" is an incomplete or empty template`
871 - if got != want {
872 - t.Errorf("expected error %s got %s", want, got)
873 - }
874 - // Add a non-empty template to check that the error is helpful.
875 - tests, err := New("").Parse(testTemplates)
876 - if err != nil {
877 - t.Fatal(err)
878 - }
879 - tmpl.AddParseTree("secondary", tests.Tree)
880 - err = tmpl.Execute(&b, 0)
881 - if err == nil {
882 - t.Fatal("expected second error")
883 - }
884 - got = err.Error()
885 - want = `template: empty: "empty" is an incomplete or empty template; defined templates are: "secondary"`
886 - if got != want {
887 - t.Errorf("expected error %s got %s", want, got)
888 - }
889 - // Make sure we can execute the secondary.
890 - err = tmpl.ExecuteTemplate(&b, "secondary", 0)
891 - if err != nil {
892 - t.Fatal(err)
893 - }
894 -}
895 -
896 -func TestFinalForPrintf(t *testing.T) {
897 - tmpl, err := New("").Parse(`{{"x" | printf}}`)
898 - if err != nil {
899 - t.Fatal(err)
900 - }
901 - var b bytes.Buffer
902 - err = tmpl.Execute(&b, 0)
903 - if err != nil {
904 - t.Fatal(err)
905 - }
906 -}
907 -
908 -type cmpTest struct {
909 - expr string
910 - truth string
911 - ok bool
912 -}
913 -
914 -var cmpTests = []cmpTest{
915 - {"eq true true", "true", true},
916 - {"eq true false", "false", true},
917 - {"eq 1+2i 1+2i", "true", true},
918 - {"eq 1+2i 1+3i", "false", true},
919 - {"eq 1.5 1.5", "true", true},
920 - {"eq 1.5 2.5", "false", true},
921 - {"eq 1 1", "true", true},
922 - {"eq 1 2", "false", true},
923 - {"eq `xy` `xy`", "true", true},
924 - {"eq `xy` `xyz`", "false", true},
925 - {"eq .Uthree .Uthree", "true", true},
926 - {"eq .Uthree .Ufour", "false", true},
927 - {"eq 3 4 5 6 3", "true", true},
928 - {"eq 3 4 5 6 7", "false", true},
929 - {"ne true true", "false", true},
930 - {"ne true false", "true", true},
931 - {"ne 1+2i 1+2i", "false", true},
932 - {"ne 1+2i 1+3i", "true", true},
933 - {"ne 1.5 1.5", "false", true},
934 - {"ne 1.5 2.5", "true", true},
935 - {"ne 1 1", "false", true},
936 - {"ne 1 2", "true", true},
937 - {"ne `xy` `xy`", "false", true},
938 - {"ne `xy` `xyz`", "true", true},
939 - {"ne .Uthree .Uthree", "false", true},
940 - {"ne .Uthree .Ufour", "true", true},
941 - {"lt 1.5 1.5", "false", true},
942 - {"lt 1.5 2.5", "true", true},
943 - {"lt 1 1", "false", true},
944 - {"lt 1 2", "true", true},
945 - {"lt `xy` `xy`", "false", true},
946 - {"lt `xy` `xyz`", "true", true},
947 - {"lt .Uthree .Uthree", "false", true},
948 - {"lt .Uthree .Ufour", "true", true},
949 - {"le 1.5 1.5", "true", true},
950 - {"le 1.5 2.5", "true", true},
951 - {"le 2.5 1.5", "false", true},
952 - {"le 1 1", "true", true},
953 - {"le 1 2", "true", true},
954 - {"le 2 1", "false", true},
955 - {"le `xy` `xy`", "true", true},
956 - {"le `xy` `xyz`", "true", true},
957 - {"le `xyz` `xy`", "false", true},
958 - {"le .Uthree .Uthree", "true", true},
959 - {"le .Uthree .Ufour", "true", true},
960 - {"le .Ufour .Uthree", "false", true},
961 - {"gt 1.5 1.5", "false", true},
962 - {"gt 1.5 2.5", "false", true},
963 - {"gt 1 1", "false", true},
964 - {"gt 2 1", "true", true},
965 - {"gt 1 2", "false", true},
966 - {"gt `xy` `xy`", "false", true},
967 - {"gt `xy` `xyz`", "false", true},
968 - {"gt .Uthree .Uthree", "false", true},
969 - {"gt .Uthree .Ufour", "false", true},
970 - {"gt .Ufour .Uthree", "true", true},
971 - {"ge 1.5 1.5", "true", true},
972 - {"ge 1.5 2.5", "false", true},
973 - {"ge 2.5 1.5", "true", true},
974 - {"ge 1 1", "true", true},
975 - {"ge 1 2", "false", true},
976 - {"ge 2 1", "true", true},
977 - {"ge `xy` `xy`", "true", true},
978 - {"ge `xy` `xyz`", "false", true},
979 - {"ge `xyz` `xy`", "true", true},
980 - {"ge .Uthree .Uthree", "true", true},
981 - {"ge .Uthree .Ufour", "false", true},
982 - {"ge .Ufour .Uthree", "true", true},
983 - // Mixing signed and unsigned integers.
984 - {"eq .Uthree .Three", "true", true},
985 - {"eq .Three .Uthree", "true", true},
986 - {"le .Uthree .Three", "true", true},
987 - {"le .Three .Uthree", "true", true},
988 - {"ge .Uthree .Three", "true", true},
989 - {"ge .Three .Uthree", "true", true},
990 - {"lt .Uthree .Three", "false", true},
991 - {"lt .Three .Uthree", "false", true},
992 - {"gt .Uthree .Three", "false", true},
993 - {"gt .Three .Uthree", "false", true},
994 - {"eq .Ufour .Three", "false", true},
995 - {"lt .Ufour .Three", "false", true},
996 - {"gt .Ufour .Three", "true", true},
997 - {"eq .NegOne .Uthree", "false", true},
998 - {"eq .Uthree .NegOne", "false", true},
999 - {"ne .NegOne .Uthree", "true", true},
1000 - {"ne .Uthree .NegOne", "true", true},
1001 - {"lt .NegOne .Uthree", "true", true},
1002 - {"lt .Uthree .NegOne", "false", true},
1003 - {"le .NegOne .Uthree", "true", true},
1004 - {"le .Uthree .NegOne", "false", true},
1005 - {"gt .NegOne .Uthree", "false", true},
1006 - {"gt .Uthree .NegOne", "true", true},
1007 - {"ge .NegOne .Uthree", "false", true},
1008 - {"ge .Uthree .NegOne", "true", true},
1009 - {"eq (index `x` 0) 'x'", "true", true}, // The example that triggered this rule.
1010 - {"eq (index `x` 0) 'y'", "false", true},
1011 - // Errors
1012 - {"eq `xy` 1", "", false}, // Different types.
1013 - {"eq 2 2.0", "", false}, // Different types.
1014 - {"lt true true", "", false}, // Unordered types.
1015 - {"lt 1+0i 1+0i", "", false}, // Unordered types.
1016 -}
1017 -
1018 -func TestComparison(t *testing.T) {
1019 - b := new(bytes.Buffer)
1020 - var cmpStruct = struct {
1021 - Uthree, Ufour uint
1022 - NegOne, Three int
1023 - }{3, 4, -1, 3}
1024 - for _, test := range cmpTests {
1025 - text := fmt.Sprintf("{{if %s}}true{{else}}false{{end}}", test.expr)
1026 - tmpl, err := New("empty").Parse(text)
1027 - if err != nil {
1028 - t.Fatalf("%q: %s", test.expr, err)
1029 - }
1030 - b.Reset()
1031 - err = tmpl.Execute(b, &cmpStruct)
1032 - if test.ok && err != nil {
1033 - t.Errorf("%s errored incorrectly: %s", test.expr, err)
1034 - continue
1035 - }
1036 - if !test.ok && err == nil {
1037 - t.Errorf("%s did not error", test.expr)
1038 - continue
1039 - }
1040 - if b.String() != test.truth {
1041 - t.Errorf("%s: want %s; got %s", test.expr, test.truth, b.String())
1042 - }
1043 - }
1044 -}
Godeps/_workspace/src/github.com/alecthomas/template/funcs.go deleted
-598
@@ -1,598 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package template
6 -
7 -import (
8 - "bytes"
9 - "errors"
10 - "fmt"
11 - "io"
12 - "net/url"
13 - "reflect"
14 - "strings"
15 - "unicode"
16 - "unicode/utf8"
17 -)
18 -
19 -// FuncMap is the type of the map defining the mapping from names to functions.
20 -// Each function must have either a single return value, or two return values of
21 -// which the second has type error. In that case, if the second (error)
22 -// return value evaluates to non-nil during execution, execution terminates and
23 -// Execute returns that error.
24 -type FuncMap map[string]interface{}
25 -
26 -var builtins = FuncMap{
27 - "and": and,
28 - "call": call,
29 - "html": HTMLEscaper,
30 - "index": index,
31 - "js": JSEscaper,
32 - "len": length,
33 - "not": not,
34 - "or": or,
35 - "print": fmt.Sprint,
36 - "printf": fmt.Sprintf,
37 - "println": fmt.Sprintln,
38 - "urlquery": URLQueryEscaper,
39 -
40 - // Comparisons
41 - "eq": eq, // ==
42 - "ge": ge, // >=
43 - "gt": gt, // >
44 - "le": le, // <=
45 - "lt": lt, // <
46 - "ne": ne, // !=
47 -}
48 -
49 -var builtinFuncs = createValueFuncs(builtins)
50 -
51 -// createValueFuncs turns a FuncMap into a map[string]reflect.Value
52 -func createValueFuncs(funcMap FuncMap) map[string]reflect.Value {
53 - m := make(map[string]reflect.Value)
54 - addValueFuncs(m, funcMap)
55 - return m
56 -}
57 -
58 -// addValueFuncs adds to values the functions in funcs, converting them to reflect.Values.
59 -func addValueFuncs(out map[string]reflect.Value, in FuncMap) {
60 - for name, fn := range in {
61 - v := reflect.ValueOf(fn)
62 - if v.Kind() != reflect.Func {
63 - panic("value for " + name + " not a function")
64 - }
65 - if !goodFunc(v.Type()) {
66 - panic(fmt.Errorf("can't install method/function %q with %d results", name, v.Type().NumOut()))
67 - }
68 - out[name] = v
69 - }
70 -}
71 -
72 -// addFuncs adds to values the functions in funcs. It does no checking of the input -
73 -// call addValueFuncs first.
74 -func addFuncs(out, in FuncMap) {
75 - for name, fn := range in {
76 - out[name] = fn
77 - }
78 -}
79 -
80 -// goodFunc checks that the function or method has the right result signature.
81 -func goodFunc(typ reflect.Type) bool {
82 - // We allow functions with 1 result or 2 results where the second is an error.
83 - switch {
84 - case typ.NumOut() == 1:
85 - return true
86 - case typ.NumOut() == 2 && typ.Out(1) == errorType:
87 - return true
88 - }
89 - return false
90 -}
91 -
92 -// findFunction looks for a function in the template, and global map.
93 -func findFunction(name string, tmpl *Template) (reflect.Value, bool) {
94 - if tmpl != nil && tmpl.common != nil {
95 - if fn := tmpl.execFuncs[name]; fn.IsValid() {
96 - return fn, true
97 - }
98 - }
99 - if fn := builtinFuncs[name]; fn.IsValid() {
100 - return fn, true
101 - }
102 - return reflect.Value{}, false
103 -}
104 -
105 -// Indexing.
106 -
107 -// index returns the result of indexing its first argument by the following
108 -// arguments. Thus "index x 1 2 3" is, in Go syntax, x[1][2][3]. Each
109 -// indexed item must be a map, slice, or array.
110 -func index(item interface{}, indices ...interface{}) (interface{}, error) {
111 - v := reflect.ValueOf(item)
112 - for _, i := range indices {
113 - index := reflect.ValueOf(i)
114 - var isNil bool
115 - if v, isNil = indirect(v); isNil {
116 - return nil, fmt.Errorf("index of nil pointer")
117 - }
118 - switch v.Kind() {
119 - case reflect.Array, reflect.Slice, reflect.String:
120 - var x int64
121 - switch index.Kind() {
122 - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
123 - x = index.Int()
124 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
125 - x = int64(index.Uint())
126 - default:
127 - return nil, fmt.Errorf("cannot index slice/array with type %s", index.Type())
128 - }
129 - if x < 0 || x >= int64(v.Len()) {
130 - return nil, fmt.Errorf("index out of range: %d", x)
131 - }
132 - v = v.Index(int(x))
133 - case reflect.Map:
134 - if !index.IsValid() {
135 - index = reflect.Zero(v.Type().Key())
136 - }
137 - if !index.Type().AssignableTo(v.Type().Key()) {
138 - return nil, fmt.Errorf("%s is not index type for %s", index.Type(), v.Type())
139 - }
140 - if x := v.MapIndex(index); x.IsValid() {
141 - v = x
142 - } else {
143 - v = reflect.Zero(v.Type().Elem())
144 - }
145 - default:
146 - return nil, fmt.Errorf("can't index item of type %s", v.Type())
147 - }
148 - }
149 - return v.Interface(), nil
150 -}
151 -
152 -// Length
153 -
154 -// length returns the length of the item, with an error if it has no defined length.
155 -func length(item interface{}) (int, error) {
156 - v, isNil := indirect(reflect.ValueOf(item))
157 - if isNil {
158 - return 0, fmt.Errorf("len of nil pointer")
159 - }
160 - switch v.Kind() {
161 - case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice, reflect.String:
162 - return v.Len(), nil
163 - }
164 - return 0, fmt.Errorf("len of type %s", v.Type())
165 -}
166 -
167 -// Function invocation
168 -
169 -// call returns the result of evaluating the first argument as a function.
170 -// The function must return 1 result, or 2 results, the second of which is an error.
171 -func call(fn interface{}, args ...interface{}) (interface{}, error) {
172 - v := reflect.ValueOf(fn)
173 - typ := v.Type()
174 - if typ.Kind() != reflect.Func {
175 - return nil, fmt.Errorf("non-function of type %s", typ)
176 - }
177 - if !goodFunc(typ) {
178 - return nil, fmt.Errorf("function called with %d args; should be 1 or 2", typ.NumOut())
179 - }
180 - numIn := typ.NumIn()
181 - var dddType reflect.Type
182 - if typ.IsVariadic() {
183 - if len(args) < numIn-1 {
184 - return nil, fmt.Errorf("wrong number of args: got %d want at least %d", len(args), numIn-1)
185 - }
186 - dddType = typ.In(numIn - 1).Elem()
187 - } else {
188 - if len(args) != numIn {
189 - return nil, fmt.Errorf("wrong number of args: got %d want %d", len(args), numIn)
190 - }
191 - }
192 - argv := make([]reflect.Value, len(args))
193 - for i, arg := range args {
194 - value := reflect.ValueOf(arg)
195 - // Compute the expected type. Clumsy because of variadics.
196 - var argType reflect.Type
197 - if !typ.IsVariadic() || i < numIn-1 {
198 - argType = typ.In(i)
199 - } else {
200 - argType = dddType
201 - }
202 - if !value.IsValid() && canBeNil(argType) {
203 - value = reflect.Zero(argType)
204 - }
205 - if !value.Type().AssignableTo(argType) {
206 - return nil, fmt.Errorf("arg %d has type %s; should be %s", i, value.Type(), argType)
207 - }
208 - argv[i] = value
209 - }
210 - result := v.Call(argv)
211 - if len(result) == 2 && !result[1].IsNil() {
212 - return result[0].Interface(), result[1].Interface().(error)
213 - }
214 - return result[0].Interface(), nil
215 -}
216 -
217 -// Boolean logic.
218 -
219 -func truth(a interface{}) bool {
220 - t, _ := isTrue(reflect.ValueOf(a))
221 - return t
222 -}
223 -
224 -// and computes the Boolean AND of its arguments, returning
225 -// the first false argument it encounters, or the last argument.
226 -func and(arg0 interface{}, args ...interface{}) interface{} {
227 - if !truth(arg0) {
228 - return arg0
229 - }
230 - for i := range args {
231 - arg0 = args[i]
232 - if !truth(arg0) {
233 - break
234 - }
235 - }
236 - return arg0
237 -}
238 -
239 -// or computes the Boolean OR of its arguments, returning
240 -// the first true argument it encounters, or the last argument.
241 -func or(arg0 interface{}, args ...interface{}) interface{} {
242 - if truth(arg0) {
243 - return arg0
244 - }
245 - for i := range args {
246 - arg0 = args[i]
247 - if truth(arg0) {
248 - break
249 - }
250 - }
251 - return arg0
252 -}
253 -
254 -// not returns the Boolean negation of its argument.
255 -func not(arg interface{}) (truth bool) {
256 - truth, _ = isTrue(reflect.ValueOf(arg))
257 - return !truth
258 -}
259 -
260 -// Comparison.
261 -
262 -// TODO: Perhaps allow comparison between signed and unsigned integers.
263 -
264 -var (
265 - errBadComparisonType = errors.New("invalid type for comparison")
266 - errBadComparison = errors.New("incompatible types for comparison")
267 - errNoComparison = errors.New("missing argument for comparison")
268 -)
269 -
270 -type kind int
271 -
272 -const (
273 - invalidKind kind = iota
274 - boolKind
275 - complexKind
276 - intKind
277 - floatKind
278 - integerKind
279 - stringKind
280 - uintKind
281 -)
282 -
283 -func basicKind(v reflect.Value) (kind, error) {
284 - switch v.Kind() {
285 - case reflect.Bool:
286 - return boolKind, nil
287 - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
288 - return intKind, nil
289 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
290 - return uintKind, nil
291 - case reflect.Float32, reflect.Float64:
292 - return floatKind, nil
293 - case reflect.Complex64, reflect.Complex128:
294 - return complexKind, nil
295 - case reflect.String:
296 - return stringKind, nil
297 - }
298 - return invalidKind, errBadComparisonType
299 -}
300 -
301 -// eq evaluates the comparison a == b || a == c || ...
302 -func eq(arg1 interface{}, arg2 ...interface{}) (bool, error) {
303 - v1 := reflect.ValueOf(arg1)
304 - k1, err := basicKind(v1)
305 - if err != nil {
306 - return false, err
307 - }
308 - if len(arg2) == 0 {
309 - return false, errNoComparison
310 - }
311 - for _, arg := range arg2 {
312 - v2 := reflect.ValueOf(arg)
313 - k2, err := basicKind(v2)
314 - if err != nil {
315 - return false, err
316 - }
317 - truth := false
318 - if k1 != k2 {
319 - // Special case: Can compare integer values regardless of type's sign.
320 - switch {
321 - case k1 == intKind && k2 == uintKind:
322 - truth = v1.Int() >= 0 && uint64(v1.Int()) == v2.Uint()
323 - case k1 == uintKind && k2 == intKind:
324 - truth = v2.Int() >= 0 && v1.Uint() == uint64(v2.Int())
325 - default:
326 - return false, errBadComparison
327 - }
328 - } else {
329 - switch k1 {
330 - case boolKind:
331 - truth = v1.Bool() == v2.Bool()
332 - case complexKind:
333 - truth = v1.Complex() == v2.Complex()
334 - case floatKind:
335 - truth = v1.Float() == v2.Float()
336 - case intKind:
337 - truth = v1.Int() == v2.Int()
338 - case stringKind:
339 - truth = v1.String() == v2.String()
340 - case uintKind:
341 - truth = v1.Uint() == v2.Uint()
342 - default:
343 - panic("invalid kind")
344 - }
345 - }
346 - if truth {
347 - return true, nil
348 - }
349 - }
350 - return false, nil
351 -}
352 -
353 -// ne evaluates the comparison a != b.
354 -func ne(arg1, arg2 interface{}) (bool, error) {
355 - // != is the inverse of ==.
356 - equal, err := eq(arg1, arg2)
357 - return !equal, err
358 -}
359 -
360 -// lt evaluates the comparison a < b.
361 -func lt(arg1, arg2 interface{}) (bool, error) {
362 - v1 := reflect.ValueOf(arg1)
363 - k1, err := basicKind(v1)
364 - if err != nil {
365 - return false, err
366 - }
367 - v2 := reflect.ValueOf(arg2)
368 - k2, err := basicKind(v2)
369 - if err != nil {
370 - return false, err
371 - }
372 - truth := false
373 - if k1 != k2 {
374 - // Special case: Can compare integer values regardless of type's sign.
375 - switch {
376 - case k1 == intKind && k2 == uintKind:
377 - truth = v1.Int() < 0 || uint64(v1.Int()) < v2.Uint()
378 - case k1 == uintKind && k2 == intKind:
379 - truth = v2.Int() >= 0 && v1.Uint() < uint64(v2.Int())
380 - default:
381 - return false, errBadComparison
382 - }
383 - } else {
384 - switch k1 {
385 - case boolKind, complexKind:
386 - return false, errBadComparisonType
387 - case floatKind:
388 - truth = v1.Float() < v2.Float()
389 - case intKind:
390 - truth = v1.Int() < v2.Int()
391 - case stringKind:
392 - truth = v1.String() < v2.String()
393 - case uintKind:
394 - truth = v1.Uint() < v2.Uint()
395 - default:
396 - panic("invalid kind")
397 - }
398 - }
399 - return truth, nil
400 -}
401 -
402 -// le evaluates the comparison <= b.
403 -func le(arg1, arg2 interface{}) (bool, error) {
404 - // <= is < or ==.
405 - lessThan, err := lt(arg1, arg2)
406 - if lessThan || err != nil {
407 - return lessThan, err
408 - }
409 - return eq(arg1, arg2)
410 -}
411 -
412 -// gt evaluates the comparison a > b.
413 -func gt(arg1, arg2 interface{}) (bool, error) {
414 - // > is the inverse of <=.
415 - lessOrEqual, err := le(arg1, arg2)
416 - if err != nil {
417 - return false, err
418 - }
419 - return !lessOrEqual, nil
420 -}
421 -
422 -// ge evaluates the comparison a >= b.
423 -func ge(arg1, arg2 interface{}) (bool, error) {
424 - // >= is the inverse of <.
425 - lessThan, err := lt(arg1, arg2)
426 - if err != nil {
427 - return false, err
428 - }
429 - return !lessThan, nil
430 -}
431 -
432 -// HTML escaping.
433 -
434 -var (
435 - htmlQuot = []byte("&#34;") // shorter than "&quot;"
436 - htmlApos = []byte("&#39;") // shorter than "&apos;" and apos was not in HTML until HTML5
437 - htmlAmp = []byte("&amp;")
438 - htmlLt = []byte("&lt;")
439 - htmlGt = []byte("&gt;")
440 -)
441 -
442 -// HTMLEscape writes to w the escaped HTML equivalent of the plain text data b.
443 -func HTMLEscape(w io.Writer, b []byte) {
444 - last := 0
445 - for i, c := range b {
446 - var html []byte
447 - switch c {
448 - case '"':
449 - html = htmlQuot
450 - case '\'':
451 - html = htmlApos
452 - case '&':
453 - html = htmlAmp
454 - case '<':
455 - html = htmlLt
456 - case '>':
457 - html = htmlGt
458 - default:
459 - continue
460 - }
461 - w.Write(b[last:i])
462 - w.Write(html)
463 - last = i + 1
464 - }
465 - w.Write(b[last:])
466 -}
467 -
468 -// HTMLEscapeString returns the escaped HTML equivalent of the plain text data s.
469 -func HTMLEscapeString(s string) string {
470 - // Avoid allocation if we can.
471 - if strings.IndexAny(s, `'"&<>`) < 0 {
472 - return s
473 - }
474 - var b bytes.Buffer
475 - HTMLEscape(&b, []byte(s))
476 - return b.String()
477 -}
478 -
479 -// HTMLEscaper returns the escaped HTML equivalent of the textual
480 -// representation of its arguments.
481 -func HTMLEscaper(args ...interface{}) string {
482 - return HTMLEscapeString(evalArgs(args))
483 -}
484 -
485 -// JavaScript escaping.
486 -
487 -var (
488 - jsLowUni = []byte(`\u00`)
489 - hex = []byte("0123456789ABCDEF")
490 -
491 - jsBackslash = []byte(`\\`)
492 - jsApos = []byte(`\'`)
493 - jsQuot = []byte(`\"`)
494 - jsLt = []byte(`\x3C`)
495 - jsGt = []byte(`\x3E`)
496 -)
497 -
498 -// JSEscape writes to w the escaped JavaScript equivalent of the plain text data b.
499 -func JSEscape(w io.Writer, b []byte) {
500 - last := 0
501 - for i := 0; i < len(b); i++ {
502 - c := b[i]
503 -
504 - if !jsIsSpecial(rune(c)) {
505 - // fast path: nothing to do
506 - continue
507 - }
508 - w.Write(b[last:i])
509 -
510 - if c < utf8.RuneSelf {
511 - // Quotes, slashes and angle brackets get quoted.
512 - // Control characters get written as \u00XX.
513 - switch c {
514 - case '\\':
515 - w.Write(jsBackslash)
516 - case '\'':
517 - w.Write(jsApos)
518 - case '"':
519 - w.Write(jsQuot)
520 - case '<':
521 - w.Write(jsLt)
522 - case '>':
523 - w.Write(jsGt)
524 - default:
525 - w.Write(jsLowUni)
526 - t, b := c>>4, c&0x0f
527 - w.Write(hex[t : t+1])
528 - w.Write(hex[b : b+1])
529 - }
530 - } else {
531 - // Unicode rune.
532 - r, size := utf8.DecodeRune(b[i:])
533 - if unicode.IsPrint(r) {
534 - w.Write(b[i : i+size])
535 - } else {
536 - fmt.Fprintf(w, "\\u%04X", r)
537 - }
538 - i += size - 1
539 - }
540 - last = i + 1
541 - }
542 - w.Write(b[last:])
543 -}
544 -
545 -// JSEscapeString returns the escaped JavaScript equivalent of the plain text data s.
546 -func JSEscapeString(s string) string {
547 - // Avoid allocation if we can.
548 - if strings.IndexFunc(s, jsIsSpecial) < 0 {
549 - return s
550 - }
551 - var b bytes.Buffer
552 - JSEscape(&b, []byte(s))
553 - return b.String()
554 -}
555 -
556 -func jsIsSpecial(r rune) bool {
557 - switch r {
558 - case '\\', '\'', '"', '<', '>':
559 - return true
560 - }
561 - return r < ' ' || utf8.RuneSelf <= r
562 -}
563 -
564 -// JSEscaper returns the escaped JavaScript equivalent of the textual
565 -// representation of its arguments.
566 -func JSEscaper(args ...interface{}) string {
567 - return JSEscapeString(evalArgs(args))
568 -}
569 -
570 -// URLQueryEscaper returns the escaped value of the textual representation of
571 -// its arguments in a form suitable for embedding in a URL query.
572 -func URLQueryEscaper(args ...interface{}) string {
573 - return url.QueryEscape(evalArgs(args))
574 -}
575 -
576 -// evalArgs formats the list of arguments into a string. It is therefore equivalent to
577 -// fmt.Sprint(args...)
578 -// except that each argument is indirected (if a pointer), as required,
579 -// using the same rules as the default string evaluation during template
580 -// execution.
581 -func evalArgs(args []interface{}) string {
582 - ok := false
583 - var s string
584 - // Fast path for simple common case.
585 - if len(args) == 1 {
586 - s, ok = args[0].(string)
587 - }
588 - if !ok {
589 - for i, arg := range args {
590 - a, ok := printableValue(reflect.ValueOf(arg))
591 - if ok {
592 - args[i] = a
593 - } // else left fmt do its thing
594 - }
595 - s = fmt.Sprint(args...)
596 - }
597 - return s
598 -}
Godeps/_workspace/src/github.com/alecthomas/template/helper.go deleted
-108
@@ -1,108 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// Helper functions to make constructing templates easier.
6 -
7 -package template
8 -
9 -import (
10 - "fmt"
11 - "io/ioutil"
12 - "path/filepath"
13 -)
14 -
15 -// Functions and methods to parse templates.
16 -
17 -// Must is a helper that wraps a call to a function returning (*Template, error)
18 -// and panics if the error is non-nil. It is intended for use in variable
19 -// initializations such as
20 -// var t = template.Must(template.New("name").Parse("text"))
21 -func Must(t *Template, err error) *Template {
22 - if err != nil {
23 - panic(err)
24 - }
25 - return t
26 -}
27 -
28 -// ParseFiles creates a new Template and parses the template definitions from
29 -// the named files. The returned template's name will have the (base) name and
30 -// (parsed) contents of the first file. There must be at least one file.
31 -// If an error occurs, parsing stops and the returned *Template is nil.
32 -func ParseFiles(filenames ...string) (*Template, error) {
33 - return parseFiles(nil, filenames...)
34 -}
35 -
36 -// ParseFiles parses the named files and associates the resulting templates with
37 -// t. If an error occurs, parsing stops and the returned template is nil;
38 -// otherwise it is t. There must be at least one file.
39 -func (t *Template) ParseFiles(filenames ...string) (*Template, error) {
40 - return parseFiles(t, filenames...)
41 -}
42 -
43 -// parseFiles is the helper for the method and function. If the argument
44 -// template is nil, it is created from the first file.
45 -func parseFiles(t *Template, filenames ...string) (*Template, error) {
46 - if len(filenames) == 0 {
47 - // Not really a problem, but be consistent.
48 - return nil, fmt.Errorf("template: no files named in call to ParseFiles")
49 - }
50 - for _, filename := range filenames {
51 - b, err := ioutil.ReadFile(filename)
52 - if err != nil {
53 - return nil, err
54 - }
55 - s := string(b)
56 - name := filepath.Base(filename)
57 - // First template becomes return value if not already defined,
58 - // and we use that one for subsequent New calls to associate
59 - // all the templates together. Also, if this file has the same name
60 - // as t, this file becomes the contents of t, so
61 - // t, err := New(name).Funcs(xxx).ParseFiles(name)
62 - // works. Otherwise we create a new template associated with t.
63 - var tmpl *Template
64 - if t == nil {
65 - t = New(name)
66 - }
67 - if name == t.Name() {
68 - tmpl = t
69 - } else {
70 - tmpl = t.New(name)
71 - }
72 - _, err = tmpl.Parse(s)
73 - if err != nil {
74 - return nil, err
75 - }
76 - }
77 - return t, nil
78 -}
79 -
80 -// ParseGlob creates a new Template and parses the template definitions from the
81 -// files identified by the pattern, which must match at least one file. The
82 -// returned template will have the (base) name and (parsed) contents of the
83 -// first file matched by the pattern. ParseGlob is equivalent to calling
84 -// ParseFiles with the list of files matched by the pattern.
85 -func ParseGlob(pattern string) (*Template, error) {
86 - return parseGlob(nil, pattern)
87 -}
88 -
89 -// ParseGlob parses the template definitions in the files identified by the
90 -// pattern and associates the resulting templates with t. The pattern is
91 -// processed by filepath.Glob and must match at least one file. ParseGlob is
92 -// equivalent to calling t.ParseFiles with the list of files matched by the
93 -// pattern.
94 -func (t *Template) ParseGlob(pattern string) (*Template, error) {
95 - return parseGlob(t, pattern)
96 -}
97 -
98 -// parseGlob is the implementation of the function and method ParseGlob.
99 -func parseGlob(t *Template, pattern string) (*Template, error) {
100 - filenames, err := filepath.Glob(pattern)
101 - if err != nil {
102 - return nil, err
103 - }
104 - if len(filenames) == 0 {
105 - return nil, fmt.Errorf("template: pattern matches no files: %#q", pattern)
106 - }
107 - return parseFiles(t, filenames...)
108 -}
Godeps/_workspace/src/github.com/alecthomas/template/multi_test.go deleted
-292
@@ -1,292 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package template
6 -
7 -// Tests for mulitple-template parsing and execution.
8 -
9 -import (
10 - "bytes"
11 - "fmt"
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/template/parse"
13 - "strings"
14 - "testing"
15 -)
16 -
17 -const (
18 - noError = true
19 - hasError = false
20 -)
21 -
22 -type multiParseTest struct {
23 - name string
24 - input string
25 - ok bool
26 - names []string
27 - results []string
28 -}
29 -
30 -var multiParseTests = []multiParseTest{
31 - {"empty", "", noError,
32 - nil,
33 - nil},
34 - {"one", `{{define "foo"}} FOO {{end}}`, noError,
35 - []string{"foo"},
36 - []string{" FOO "}},
37 - {"two", `{{define "foo"}} FOO {{end}}{{define "bar"}} BAR {{end}}`, noError,
38 - []string{"foo", "bar"},
39 - []string{" FOO ", " BAR "}},
40 - // errors
41 - {"missing end", `{{define "foo"}} FOO `, hasError,
42 - nil,
43 - nil},
44 - {"malformed name", `{{define "foo}} FOO `, hasError,
45 - nil,
46 - nil},
47 -}
48 -
49 -func TestMultiParse(t *testing.T) {
50 - for _, test := range multiParseTests {
51 - template, err := New("root").Parse(test.input)
52 - switch {
53 - case err == nil && !test.ok:
54 - t.Errorf("%q: expected error; got none", test.name)
55 - continue
56 - case err != nil && test.ok:
57 - t.Errorf("%q: unexpected error: %v", test.name, err)
58 - continue
59 - case err != nil && !test.ok:
60 - // expected error, got one
61 - if *debug {
62 - fmt.Printf("%s: %s\n\t%s\n", test.name, test.input, err)
63 - }
64 - continue
65 - }
66 - if template == nil {
67 - continue
68 - }
69 - if len(template.tmpl) != len(test.names)+1 { // +1 for root
70 - t.Errorf("%s: wrong number of templates; wanted %d got %d", test.name, len(test.names), len(template.tmpl))
71 - continue
72 - }
73 - for i, name := range test.names {
74 - tmpl, ok := template.tmpl[name]
75 - if !ok {
76 - t.Errorf("%s: can't find template %q", test.name, name)
77 - continue
78 - }
79 - result := tmpl.Root.String()
80 - if result != test.results[i] {
81 - t.Errorf("%s=(%q): got\n\t%v\nexpected\n\t%v", test.name, test.input, result, test.results[i])
82 - }
83 - }
84 - }
85 -}
86 -
87 -var multiExecTests = []execTest{
88 - {"empty", "", "", nil, true},
89 - {"text", "some text", "some text", nil, true},
90 - {"invoke x", `{{template "x" .SI}}`, "TEXT", tVal, true},
91 - {"invoke x no args", `{{template "x"}}`, "TEXT", tVal, true},
92 - {"invoke dot int", `{{template "dot" .I}}`, "17", tVal, true},
93 - {"invoke dot []int", `{{template "dot" .SI}}`, "[3 4 5]", tVal, true},
94 - {"invoke dotV", `{{template "dotV" .U}}`, "v", tVal, true},
95 - {"invoke nested int", `{{template "nested" .I}}`, "17", tVal, true},
96 - {"variable declared by template", `{{template "nested" $x:=.SI}},{{index $x 1}}`, "[3 4 5],4", tVal, true},
97 -
98 - // User-defined function: test argument evaluator.
99 - {"testFunc literal", `{{oneArg "joe"}}`, "oneArg=joe", tVal, true},
100 - {"testFunc .", `{{oneArg .}}`, "oneArg=joe", "joe", true},
101 -}
102 -
103 -// These strings are also in testdata/*.
104 -const multiText1 = `
105 - {{define "x"}}TEXT{{end}}
106 - {{define "dotV"}}{{.V}}{{end}}
107 -`
108 -
109 -const multiText2 = `
110 - {{define "dot"}}{{.}}{{end}}
111 - {{define "nested"}}{{template "dot" .}}{{end}}
112 -`
113 -
114 -func TestMultiExecute(t *testing.T) {
115 - // Declare a couple of templates first.
116 - template, err := New("root").Parse(multiText1)
117 - if err != nil {
118 - t.Fatalf("parse error for 1: %s", err)
119 - }
120 - _, err = template.Parse(multiText2)
121 - if err != nil {
122 - t.Fatalf("parse error for 2: %s", err)
123 - }
124 - testExecute(multiExecTests, template, t)
125 -}
126 -
127 -func TestParseFiles(t *testing.T) {
128 - _, err := ParseFiles("DOES NOT EXIST")
129 - if err == nil {
130 - t.Error("expected error for non-existent file; got none")
131 - }
132 - template := New("root")
133 - _, err = template.ParseFiles("testdata/file1.tmpl", "testdata/file2.tmpl")
134 - if err != nil {
135 - t.Fatalf("error parsing files: %v", err)
136 - }
137 - testExecute(multiExecTests, template, t)
138 -}
139 -
140 -func TestParseGlob(t *testing.T) {
141 - _, err := ParseGlob("DOES NOT EXIST")
142 - if err == nil {
143 - t.Error("expected error for non-existent file; got none")
144 - }
145 - _, err = New("error").ParseGlob("[x")
146 - if err == nil {
147 - t.Error("expected error for bad pattern; got none")
148 - }
149 - template := New("root")
150 - _, err = template.ParseGlob("testdata/file*.tmpl")
151 - if err != nil {
152 - t.Fatalf("error parsing files: %v", err)
153 - }
154 - testExecute(multiExecTests, template, t)
155 -}
156 -
157 -// In these tests, actual content (not just template definitions) comes from the parsed files.
158 -
159 -var templateFileExecTests = []execTest{
160 - {"test", `{{template "tmpl1.tmpl"}}{{template "tmpl2.tmpl"}}`, "template1\n\ny\ntemplate2\n\nx\n", 0, true},
161 -}
162 -
163 -func TestParseFilesWithData(t *testing.T) {
164 - template, err := New("root").ParseFiles("testdata/tmpl1.tmpl", "testdata/tmpl2.tmpl")
165 - if err != nil {
166 - t.Fatalf("error parsing files: %v", err)
167 - }
168 - testExecute(templateFileExecTests, template, t)
169 -}
170 -
171 -func TestParseGlobWithData(t *testing.T) {
172 - template, err := New("root").ParseGlob("testdata/tmpl*.tmpl")
173 - if err != nil {
174 - t.Fatalf("error parsing files: %v", err)
175 - }
176 - testExecute(templateFileExecTests, template, t)
177 -}
178 -
179 -const (
180 - cloneText1 = `{{define "a"}}{{template "b"}}{{template "c"}}{{end}}`
181 - cloneText2 = `{{define "b"}}b{{end}}`
182 - cloneText3 = `{{define "c"}}root{{end}}`
183 - cloneText4 = `{{define "c"}}clone{{end}}`
184 -)
185 -
186 -func TestClone(t *testing.T) {
187 - // Create some templates and clone the root.
188 - root, err := New("root").Parse(cloneText1)
189 - if err != nil {
190 - t.Fatal(err)
191 - }
192 - _, err = root.Parse(cloneText2)
193 - if err != nil {
194 - t.Fatal(err)
195 - }
196 - clone := Must(root.Clone())
197 - // Add variants to both.
198 - _, err = root.Parse(cloneText3)
199 - if err != nil {
200 - t.Fatal(err)
201 - }
202 - _, err = clone.Parse(cloneText4)
203 - if err != nil {
204 - t.Fatal(err)
205 - }
206 - // Verify that the clone is self-consistent.
207 - for k, v := range clone.tmpl {
208 - if k == clone.name && v.tmpl[k] != clone {
209 - t.Error("clone does not contain root")
210 - }
211 - if v != v.tmpl[v.name] {
212 - t.Errorf("clone does not contain self for %q", k)
213 - }
214 - }
215 - // Execute root.
216 - var b bytes.Buffer
217 - err = root.ExecuteTemplate(&b, "a", 0)
218 - if err != nil {
219 - t.Fatal(err)
220 - }
221 - if b.String() != "broot" {
222 - t.Errorf("expected %q got %q", "broot", b.String())
223 - }
224 - // Execute copy.
225 - b.Reset()
226 - err = clone.ExecuteTemplate(&b, "a", 0)
227 - if err != nil {
228 - t.Fatal(err)
229 - }
230 - if b.String() != "bclone" {
231 - t.Errorf("expected %q got %q", "bclone", b.String())
232 - }
233 -}
234 -
235 -func TestAddParseTree(t *testing.T) {
236 - // Create some templates.
237 - root, err := New("root").Parse(cloneText1)
238 - if err != nil {
239 - t.Fatal(err)
240 - }
241 - _, err = root.Parse(cloneText2)
242 - if err != nil {
243 - t.Fatal(err)
244 - }
245 - // Add a new parse tree.
246 - tree, err := parse.Parse("cloneText3", cloneText3, "", "", nil, builtins)
247 - if err != nil {
248 - t.Fatal(err)
249 - }
250 - added, err := root.AddParseTree("c", tree["c"])
251 - // Execute.
252 - var b bytes.Buffer
253 - err = added.ExecuteTemplate(&b, "a", 0)
254 - if err != nil {
255 - t.Fatal(err)
256 - }
257 - if b.String() != "broot" {
258 - t.Errorf("expected %q got %q", "broot", b.String())
259 - }
260 -}
261 -
262 -// Issue 7032
263 -func TestAddParseTreeToUnparsedTemplate(t *testing.T) {
264 - master := "{{define \"master\"}}{{end}}"
265 - tmpl := New("master")
266 - tree, err := parse.Parse("master", master, "", "", nil)
267 - if err != nil {
268 - t.Fatalf("unexpected parse err: %v", err)
269 - }
270 - masterTree := tree["master"]
271 - tmpl.AddParseTree("master", masterTree) // used to panic
272 -}
273 -
274 -func TestRedefinition(t *testing.T) {
275 - var tmpl *Template
276 - var err error
277 - if tmpl, err = New("tmpl1").Parse(`{{define "test"}}foo{{end}}`); err != nil {
278 - t.Fatalf("parse 1: %v", err)
279 - }
280 - if _, err = tmpl.Parse(`{{define "test"}}bar{{end}}`); err == nil {
281 - t.Fatal("expected error")
282 - }
283 - if !strings.Contains(err.Error(), "redefinition") {
284 - t.Fatalf("expected redefinition error; got %v", err)
285 - }
286 - if _, err = tmpl.New("tmpl2").Parse(`{{define "test"}}bar{{end}}`); err == nil {
287 - t.Fatal("expected error")
288 - }
289 - if !strings.Contains(err.Error(), "redefinition") {
290 - t.Fatalf("expected redefinition error; got %v", err)
291 - }
292 -}
Godeps/_workspace/src/github.com/alecthomas/template/parse/lex.go deleted
-556
@@ -1,556 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package parse
6 -
7 -import (
8 - "fmt"
9 - "strings"
10 - "unicode"
11 - "unicode/utf8"
12 -)
13 -
14 -// item represents a token or text string returned from the scanner.
15 -type item struct {
16 - typ itemType // The type of this item.
17 - pos Pos // The starting position, in bytes, of this item in the input string.
18 - val string // The value of this item.
19 -}
20 -
21 -func (i item) String() string {
22 - switch {
23 - case i.typ == itemEOF:
24 - return "EOF"
25 - case i.typ == itemError:
26 - return i.val
27 - case i.typ > itemKeyword:
28 - return fmt.Sprintf("<%s>", i.val)
29 - case len(i.val) > 10:
30 - return fmt.Sprintf("%.10q...", i.val)
31 - }
32 - return fmt.Sprintf("%q", i.val)
33 -}
34 -
35 -// itemType identifies the type of lex items.
36 -type itemType int
37 -
38 -const (
39 - itemError itemType = iota // error occurred; value is text of error
40 - itemBool // boolean constant
41 - itemChar // printable ASCII character; grab bag for comma etc.
42 - itemCharConstant // character constant
43 - itemComplex // complex constant (1+2i); imaginary is just a number
44 - itemColonEquals // colon-equals (':=') introducing a declaration
45 - itemEOF
46 - itemField // alphanumeric identifier starting with '.'
47 - itemIdentifier // alphanumeric identifier not starting with '.'
48 - itemLeftDelim // left action delimiter
49 - itemLeftParen // '(' inside action
50 - itemNumber // simple number, including imaginary
51 - itemPipe // pipe symbol
52 - itemRawString // raw quoted string (includes quotes)
53 - itemRightDelim // right action delimiter
54 - itemElideNewline // elide newline after right delim
55 - itemRightParen // ')' inside action
56 - itemSpace // run of spaces separating arguments
57 - itemString // quoted string (includes quotes)
58 - itemText // plain text
59 - itemVariable // variable starting with '$', such as '$' or '$1' or '$hello'
60 - // Keywords appear after all the rest.
61 - itemKeyword // used only to delimit the keywords
62 - itemDot // the cursor, spelled '.'
63 - itemDefine // define keyword
64 - itemElse // else keyword
65 - itemEnd // end keyword
66 - itemIf // if keyword
67 - itemNil // the untyped nil constant, easiest to treat as a keyword
68 - itemRange // range keyword
69 - itemTemplate // template keyword
70 - itemWith // with keyword
71 -)
72 -
73 -var key = map[string]itemType{
74 - ".": itemDot,
75 - "define": itemDefine,
76 - "else": itemElse,
77 - "end": itemEnd,
78 - "if": itemIf,
79 - "range": itemRange,
80 - "nil": itemNil,
81 - "template": itemTemplate,
82 - "with": itemWith,
83 -}
84 -
85 -const eof = -1
86 -
87 -// stateFn represents the state of the scanner as a function that returns the next state.
88 -type stateFn func(*lexer) stateFn
89 -
90 -// lexer holds the state of the scanner.
91 -type lexer struct {
92 - name string // the name of the input; used only for error reports
93 - input string // the string being scanned
94 - leftDelim string // start of action
95 - rightDelim string // end of action
96 - state stateFn // the next lexing function to enter
97 - pos Pos // current position in the input
98 - start Pos // start position of this item
99 - width Pos // width of last rune read from input
100 - lastPos Pos // position of most recent item returned by nextItem
101 - items chan item // channel of scanned items
102 - parenDepth int // nesting depth of ( ) exprs
103 -}
104 -
105 -// next returns the next rune in the input.
106 -func (l *lexer) next() rune {
107 - if int(l.pos) >= len(l.input) {
108 - l.width = 0
109 - return eof
110 - }
111 - r, w := utf8.DecodeRuneInString(l.input[l.pos:])
112 - l.width = Pos(w)
113 - l.pos += l.width
114 - return r
115 -}
116 -
117 -// peek returns but does not consume the next rune in the input.
118 -func (l *lexer) peek() rune {
119 - r := l.next()
120 - l.backup()
121 - return r
122 -}
123 -
124 -// backup steps back one rune. Can only be called once per call of next.
125 -func (l *lexer) backup() {
126 - l.pos -= l.width
127 -}
128 -
129 -// emit passes an item back to the client.
130 -func (l *lexer) emit(t itemType) {
131 - l.items <- item{t, l.start, l.input[l.start:l.pos]}
132 - l.start = l.pos
133 -}
134 -
135 -// ignore skips over the pending input before this point.
136 -func (l *lexer) ignore() {
137 - l.start = l.pos
138 -}
139 -
140 -// accept consumes the next rune if it's from the valid set.
141 -func (l *lexer) accept(valid string) bool {
142 - if strings.IndexRune(valid, l.next()) >= 0 {
143 - return true
144 - }
145 - l.backup()
146 - return false
147 -}
148 -
149 -// acceptRun consumes a run of runes from the valid set.
150 -func (l *lexer) acceptRun(valid string) {
151 - for strings.IndexRune(valid, l.next()) >= 0 {
152 - }
153 - l.backup()
154 -}
155 -
156 -// lineNumber reports which line we're on, based on the position of
157 -// the previous item returned by nextItem. Doing it this way
158 -// means we don't have to worry about peek double counting.
159 -func (l *lexer) lineNumber() int {
160 - return 1 + strings.Count(l.input[:l.lastPos], "\n")
161 -}
162 -
163 -// errorf returns an error token and terminates the scan by passing
164 -// back a nil pointer that will be the next state, terminating l.nextItem.
165 -func (l *lexer) errorf(format string, args ...interface{}) stateFn {
166 - l.items <- item{itemError, l.start, fmt.Sprintf(format, args...)}
167 - return nil
168 -}
169 -
170 -// nextItem returns the next item from the input.
171 -func (l *lexer) nextItem() item {
172 - item := <-l.items
173 - l.lastPos = item.pos
174 - return item
175 -}
176 -
177 -// lex creates a new scanner for the input string.
178 -func lex(name, input, left, right string) *lexer {
179 - if left == "" {
180 - left = leftDelim
181 - }
182 - if right == "" {
183 - right = rightDelim
184 - }
185 - l := &lexer{
186 - name: name,
187 - input: input,
188 - leftDelim: left,
189 - rightDelim: right,
190 - items: make(chan item),
191 - }
192 - go l.run()
193 - return l
194 -}
195 -
196 -// run runs the state machine for the lexer.
197 -func (l *lexer) run() {
198 - for l.state = lexText; l.state != nil; {
199 - l.state = l.state(l)
200 - }
201 -}
202 -
203 -// state functions
204 -
205 -const (
206 - leftDelim = "{{"
207 - rightDelim = "}}"
208 - leftComment = "/*"
209 - rightComment = "*/"
210 -)
211 -
212 -// lexText scans until an opening action delimiter, "{{".
213 -func lexText(l *lexer) stateFn {
214 - for {
215 - if strings.HasPrefix(l.input[l.pos:], l.leftDelim) {
216 - if l.pos > l.start {
217 - l.emit(itemText)
218 - }
219 - return lexLeftDelim
220 - }
221 - if l.next() == eof {
222 - break
223 - }
224 - }
225 - // Correctly reached EOF.
226 - if l.pos > l.start {
227 - l.emit(itemText)
228 - }
229 - l.emit(itemEOF)
230 - return nil
231 -}
232 -
233 -// lexLeftDelim scans the left delimiter, which is known to be present.
234 -func lexLeftDelim(l *lexer) stateFn {
235 - l.pos += Pos(len(l.leftDelim))
236 - if strings.HasPrefix(l.input[l.pos:], leftComment) {
237 - return lexComment
238 - }
239 - l.emit(itemLeftDelim)
240 - l.parenDepth = 0
241 - return lexInsideAction
242 -}
243 -
244 -// lexComment scans a comment. The left comment marker is known to be present.
245 -func lexComment(l *lexer) stateFn {
246 - l.pos += Pos(len(leftComment))
247 - i := strings.Index(l.input[l.pos:], rightComment)
248 - if i < 0 {
249 - return l.errorf("unclosed comment")
250 - }
251 - l.pos += Pos(i + len(rightComment))
252 - if !strings.HasPrefix(l.input[l.pos:], l.rightDelim) {
253 - return l.errorf("comment ends before closing delimiter")
254 -
255 - }
256 - l.pos += Pos(len(l.rightDelim))
257 - l.ignore()
258 - return lexText
259 -}
260 -
261 -// lexRightDelim scans the right delimiter, which is known to be present.
262 -func lexRightDelim(l *lexer) stateFn {
263 - l.pos += Pos(len(l.rightDelim))
264 - l.emit(itemRightDelim)
265 - if l.peek() == '\\' {
266 - l.pos++
267 - l.emit(itemElideNewline)
268 - }
269 - return lexText
270 -}
271 -
272 -// lexInsideAction scans the elements inside action delimiters.
273 -func lexInsideAction(l *lexer) stateFn {
274 - // Either number, quoted string, or identifier.
275 - // Spaces separate arguments; runs of spaces turn into itemSpace.
276 - // Pipe symbols separate and are emitted.
277 - if strings.HasPrefix(l.input[l.pos:], l.rightDelim+"\\") || strings.HasPrefix(l.input[l.pos:], l.rightDelim) {
278 - if l.parenDepth == 0 {
279 - return lexRightDelim
280 - }
281 - return l.errorf("unclosed left paren")
282 - }
283 - switch r := l.next(); {
284 - case r == eof || isEndOfLine(r):
285 - return l.errorf("unclosed action")
286 - case isSpace(r):
287 - return lexSpace
288 - case r == ':':
289 - if l.next() != '=' {
290 - return l.errorf("expected :=")
291 - }
292 - l.emit(itemColonEquals)
293 - case r == '|':
294 - l.emit(itemPipe)
295 - case r == '"':
296 - return lexQuote
297 - case r == '`':
298 - return lexRawQuote
299 - case r == '$':
300 - return lexVariable
301 - case r == '\'':
302 - return lexChar
303 - case r == '.':
304 - // special look-ahead for ".field" so we don't break l.backup().
305 - if l.pos < Pos(len(l.input)) {
306 - r := l.input[l.pos]
307 - if r < '0' || '9' < r {
308 - return lexField
309 - }
310 - }
311 - fallthrough // '.' can start a number.
312 - case r == '+' || r == '-' || ('0' <= r && r <= '9'):
313 - l.backup()
314 - return lexNumber
315 - case isAlphaNumeric(r):
316 - l.backup()
317 - return lexIdentifier
318 - case r == '(':
319 - l.emit(itemLeftParen)
320 - l.parenDepth++
321 - return lexInsideAction
322 - case r == ')':
323 - l.emit(itemRightParen)
324 - l.parenDepth--
325 - if l.parenDepth < 0 {
326 - return l.errorf("unexpected right paren %#U", r)
327 - }
328 - return lexInsideAction
329 - case r <= unicode.MaxASCII && unicode.IsPrint(r):
330 - l.emit(itemChar)
331 - return lexInsideAction
332 - default:
333 - return l.errorf("unrecognized character in action: %#U", r)
334 - }
335 - return lexInsideAction
336 -}
337 -
338 -// lexSpace scans a run of space characters.
339 -// One space has already been seen.
340 -func lexSpace(l *lexer) stateFn {
341 - for isSpace(l.peek()) {
342 - l.next()
343 - }
344 - l.emit(itemSpace)
345 - return lexInsideAction
346 -}
347 -
348 -// lexIdentifier scans an alphanumeric.
349 -func lexIdentifier(l *lexer) stateFn {
350 -Loop:
351 - for {
352 - switch r := l.next(); {
353 - case isAlphaNumeric(r):
354 - // absorb.
355 - default:
356 - l.backup()
357 - word := l.input[l.start:l.pos]
358 - if !l.atTerminator() {
359 - return l.errorf("bad character %#U", r)
360 - }
361 - switch {
362 - case key[word] > itemKeyword:
363 - l.emit(key[word])
364 - case word[0] == '.':
365 - l.emit(itemField)
366 - case word == "true", word == "false":
367 - l.emit(itemBool)
368 - default:
369 - l.emit(itemIdentifier)
370 - }
371 - break Loop
372 - }
373 - }
374 - return lexInsideAction
375 -}
376 -
377 -// lexField scans a field: .Alphanumeric.
378 -// The . has been scanned.
379 -func lexField(l *lexer) stateFn {
380 - return lexFieldOrVariable(l, itemField)
381 -}
382 -
383 -// lexVariable scans a Variable: $Alphanumeric.
384 -// The $ has been scanned.
385 -func lexVariable(l *lexer) stateFn {
386 - if l.atTerminator() { // Nothing interesting follows -> "$".
387 - l.emit(itemVariable)
388 - return lexInsideAction
389 - }
390 - return lexFieldOrVariable(l, itemVariable)
391 -}
392 -
393 -// lexVariable scans a field or variable: [.$]Alphanumeric.
394 -// The . or $ has been scanned.
395 -func lexFieldOrVariable(l *lexer, typ itemType) stateFn {
396 - if l.atTerminator() { // Nothing interesting follows -> "." or "$".
397 - if typ == itemVariable {
398 - l.emit(itemVariable)
399 - } else {
400 - l.emit(itemDot)
401 - }
402 - return lexInsideAction
403 - }
404 - var r rune
405 - for {
406 - r = l.next()
407 - if !isAlphaNumeric(r) {
408 - l.backup()
409 - break
410 - }
411 - }
412 - if !l.atTerminator() {
413 - return l.errorf("bad character %#U", r)
414 - }
415 - l.emit(typ)
416 - return lexInsideAction
417 -}
418 -
419 -// atTerminator reports whether the input is at valid termination character to
420 -// appear after an identifier. Breaks .X.Y into two pieces. Also catches cases
421 -// like "$x+2" not being acceptable without a space, in case we decide one
422 -// day to implement arithmetic.
423 -func (l *lexer) atTerminator() bool {
424 - r := l.peek()
425 - if isSpace(r) || isEndOfLine(r) {
426 - return true
427 - }
428 - switch r {
429 - case eof, '.', ',', '|', ':', ')', '(':
430 - return true
431 - }
432 - // Does r start the delimiter? This can be ambiguous (with delim=="//", $x/2 will
433 - // succeed but should fail) but only in extremely rare cases caused by willfully
434 - // bad choice of delimiter.
435 - if rd, _ := utf8.DecodeRuneInString(l.rightDelim); rd == r {
436 - return true
437 - }
438 - return false
439 -}
440 -
441 -// lexChar scans a character constant. The initial quote is already
442 -// scanned. Syntax checking is done by the parser.
443 -func lexChar(l *lexer) stateFn {
444 -Loop:
445 - for {
446 - switch l.next() {
447 - case '\\':
448 - if r := l.next(); r != eof && r != '\n' {
449 - break
450 - }
451 - fallthrough
452 - case eof, '\n':
453 - return l.errorf("unterminated character constant")
454 - case '\'':
455 - break Loop
456 - }
457 - }
458 - l.emit(itemCharConstant)
459 - return lexInsideAction
460 -}
461 -
462 -// lexNumber scans a number: decimal, octal, hex, float, or imaginary. This
463 -// isn't a perfect number scanner - for instance it accepts "." and "0x0.2"
464 -// and "089" - but when it's wrong the input is invalid and the parser (via
465 -// strconv) will notice.
466 -func lexNumber(l *lexer) stateFn {
467 - if !l.scanNumber() {
468 - return l.errorf("bad number syntax: %q", l.input[l.start:l.pos])
469 - }
470 - if sign := l.peek(); sign == '+' || sign == '-' {
471 - // Complex: 1+2i. No spaces, must end in 'i'.
472 - if !l.scanNumber() || l.input[l.pos-1] != 'i' {
473 - return l.errorf("bad number syntax: %q", l.input[l.start:l.pos])
474 - }
475 - l.emit(itemComplex)
476 - } else {
477 - l.emit(itemNumber)
478 - }
479 - return lexInsideAction
480 -}
481 -
482 -func (l *lexer) scanNumber() bool {
483 - // Optional leading sign.
484 - l.accept("+-")
485 - // Is it hex?
486 - digits := "0123456789"
487 - if l.accept("0") && l.accept("xX") {
488 - digits = "0123456789abcdefABCDEF"
489 - }
490 - l.acceptRun(digits)
491 - if l.accept(".") {
492 - l.acceptRun(digits)
493 - }
494 - if l.accept("eE") {
495 - l.accept("+-")
496 - l.acceptRun("0123456789")
497 - }
498 - // Is it imaginary?
499 - l.accept("i")
500 - // Next thing mustn't be alphanumeric.
501 - if isAlphaNumeric(l.peek()) {
502 - l.next()
503 - return false
504 - }
505 - return true
506 -}
507 -
508 -// lexQuote scans a quoted string.
509 -func lexQuote(l *lexer) stateFn {
510 -Loop:
511 - for {
512 - switch l.next() {
513 - case '\\':
514 - if r := l.next(); r != eof && r != '\n' {
515 - break
516 - }
517 - fallthrough
518 - case eof, '\n':
519 - return l.errorf("unterminated quoted string")
520 - case '"':
521 - break Loop
522 - }
523 - }
524 - l.emit(itemString)
525 - return lexInsideAction
526 -}
527 -
528 -// lexRawQuote scans a raw quoted string.
529 -func lexRawQuote(l *lexer) stateFn {
530 -Loop:
531 - for {
532 - switch l.next() {
533 - case eof, '\n':
534 - return l.errorf("unterminated raw quoted string")
535 - case '`':
536 - break Loop
537 - }
538 - }
539 - l.emit(itemRawString)
540 - return lexInsideAction
541 -}
542 -
543 -// isSpace reports whether r is a space character.
544 -func isSpace(r rune) bool {
545 - return r == ' ' || r == '\t'
546 -}
547 -
548 -// isEndOfLine reports whether r is an end-of-line character.
549 -func isEndOfLine(r rune) bool {
550 - return r == '\r' || r == '\n'
551 -}
552 -
553 -// isAlphaNumeric reports whether r is an alphabetic, digit, or underscore.
554 -func isAlphaNumeric(r rune) bool {
555 - return r == '_' || unicode.IsLetter(r) || unicode.IsDigit(r)
556 -}
Godeps/_workspace/src/github.com/alecthomas/template/parse/lex_test.go deleted
-468
@@ -1,468 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package parse
6 -
7 -import (
8 - "fmt"
9 - "testing"
10 -)
11 -
12 -// Make the types prettyprint.
13 -var itemName = map[itemType]string{
14 - itemError: "error",
15 - itemBool: "bool",
16 - itemChar: "char",
17 - itemCharConstant: "charconst",
18 - itemComplex: "complex",
19 - itemColonEquals: ":=",
20 - itemEOF: "EOF",
21 - itemField: "field",
22 - itemIdentifier: "identifier",
23 - itemLeftDelim: "left delim",
24 - itemLeftParen: "(",
25 - itemNumber: "number",
26 - itemPipe: "pipe",
27 - itemRawString: "raw string",
28 - itemRightDelim: "right delim",
29 - itemElideNewline: "elide newline",
30 - itemRightParen: ")",
31 - itemSpace: "space",
32 - itemString: "string",
33 - itemVariable: "variable",
34 -
35 - // keywords
36 - itemDot: ".",
37 - itemDefine: "define",
38 - itemElse: "else",
39 - itemIf: "if",
40 - itemEnd: "end",
41 - itemNil: "nil",
42 - itemRange: "range",
43 - itemTemplate: "template",
44 - itemWith: "with",
45 -}
46 -
47 -func (i itemType) String() string {
48 - s := itemName[i]
49 - if s == "" {
50 - return fmt.Sprintf("item%d", int(i))
51 - }
52 - return s
53 -}
54 -
55 -type lexTest struct {
56 - name string
57 - input string
58 - items []item
59 -}
60 -
61 -var (
62 - tEOF = item{itemEOF, 0, ""}
63 - tFor = item{itemIdentifier, 0, "for"}
64 - tLeft = item{itemLeftDelim, 0, "{{"}
65 - tLpar = item{itemLeftParen, 0, "("}
66 - tPipe = item{itemPipe, 0, "|"}
67 - tQuote = item{itemString, 0, `"abc \n\t\" "`}
68 - tRange = item{itemRange, 0, "range"}
69 - tRight = item{itemRightDelim, 0, "}}"}
70 - tElideNewline = item{itemElideNewline, 0, "\\"}
71 - tRpar = item{itemRightParen, 0, ")"}
72 - tSpace = item{itemSpace, 0, " "}
73 - raw = "`" + `abc\n\t\" ` + "`"
74 - tRawQuote = item{itemRawString, 0, raw}
75 -)
76 -
77 -var lexTests = []lexTest{
78 - {"empty", "", []item{tEOF}},
79 - {"spaces", " \t\n", []item{{itemText, 0, " \t\n"}, tEOF}},
80 - {"text", `now is the time`, []item{{itemText, 0, "now is the time"}, tEOF}},
81 - {"elide newline", "{{}}\\", []item{tLeft, tRight, tElideNewline, tEOF}},
82 - {"text with comment", "hello-{{/* this is a comment */}}-world", []item{
83 - {itemText, 0, "hello-"},
84 - {itemText, 0, "-world"},
85 - tEOF,
86 - }},
87 - {"punctuation", "{{,@% }}", []item{
88 - tLeft,
89 - {itemChar, 0, ","},
90 - {itemChar, 0, "@"},
91 - {itemChar, 0, "%"},
92 - tSpace,
93 - tRight,
94 - tEOF,
95 - }},
96 - {"parens", "{{((3))}}", []item{
97 - tLeft,
98 - tLpar,
99 - tLpar,
100 - {itemNumber, 0, "3"},
101 - tRpar,
102 - tRpar,
103 - tRight,
104 - tEOF,
105 - }},
106 - {"empty action", `{{}}`, []item{tLeft, tRight, tEOF}},
107 - {"for", `{{for}}`, []item{tLeft, tFor, tRight, tEOF}},
108 - {"quote", `{{"abc \n\t\" "}}`, []item{tLeft, tQuote, tRight, tEOF}},
109 - {"raw quote", "{{" + raw + "}}", []item{tLeft, tRawQuote, tRight, tEOF}},
110 - {"numbers", "{{1 02 0x14 -7.2i 1e3 +1.2e-4 4.2i 1+2i}}", []item{
111 - tLeft,
112 - {itemNumber, 0, "1"},
113 - tSpace,
114 - {itemNumber, 0, "02"},
115 - tSpace,
116 - {itemNumber, 0, "0x14"},
117 - tSpace,
118 - {itemNumber, 0, "-7.2i"},
119 - tSpace,
120 - {itemNumber, 0, "1e3"},
121 - tSpace,
122 - {itemNumber, 0, "+1.2e-4"},
123 - tSpace,
124 - {itemNumber, 0, "4.2i"},
125 - tSpace,
126 - {itemComplex, 0, "1+2i"},
127 - tRight,
128 - tEOF,
129 - }},
130 - {"characters", `{{'a' '\n' '\'' '\\' '\u00FF' '\xFF' '本'}}`, []item{
131 - tLeft,
132 - {itemCharConstant, 0, `'a'`},
133 - tSpace,
134 - {itemCharConstant, 0, `'\n'`},
135 - tSpace,
136 - {itemCharConstant, 0, `'\''`},
137 - tSpace,
138 - {itemCharConstant, 0, `'\\'`},
139 - tSpace,
140 - {itemCharConstant, 0, `'\u00FF'`},
141 - tSpace,
142 - {itemCharConstant, 0, `'\xFF'`},
143 - tSpace,
144 - {itemCharConstant, 0, `'本'`},
145 - tRight,
146 - tEOF,
147 - }},
148 - {"bools", "{{true false}}", []item{
149 - tLeft,
150 - {itemBool, 0, "true"},
151 - tSpace,
152 - {itemBool, 0, "false"},
153 - tRight,
154 - tEOF,
155 - }},
156 - {"dot", "{{.}}", []item{
157 - tLeft,
158 - {itemDot, 0, "."},
159 - tRight,
160 - tEOF,
161 - }},
162 - {"nil", "{{nil}}", []item{
163 - tLeft,
164 - {itemNil, 0, "nil"},
165 - tRight,
166 - tEOF,
167 - }},
168 - {"dots", "{{.x . .2 .x.y.z}}", []item{
169 - tLeft,
170 - {itemField, 0, ".x"},
171 - tSpace,
172 - {itemDot, 0, "."},
173 - tSpace,
174 - {itemNumber, 0, ".2"},
175 - tSpace,
176 - {itemField, 0, ".x"},
177 - {itemField, 0, ".y"},
178 - {itemField, 0, ".z"},
179 - tRight,
180 - tEOF,
181 - }},
182 - {"keywords", "{{range if else end with}}", []item{
183 - tLeft,
184 - {itemRange, 0, "range"},
185 - tSpace,
186 - {itemIf, 0, "if"},
187 - tSpace,
188 - {itemElse, 0, "else"},
189 - tSpace,
190 - {itemEnd, 0, "end"},
191 - tSpace,
192 - {itemWith, 0, "with"},
193 - tRight,
194 - tEOF,
195 - }},
196 - {"variables", "{{$c := printf $ $hello $23 $ $var.Field .Method}}", []item{
197 - tLeft,
198 - {itemVariable, 0, "$c"},
199 - tSpace,
200 - {itemColonEquals, 0, ":="},
201 - tSpace,
202 - {itemIdentifier, 0, "printf"},
203 - tSpace,
204 - {itemVariable, 0, "$"},
205 - tSpace,
206 - {itemVariable, 0, "$hello"},
207 - tSpace,
208 - {itemVariable, 0, "$23"},
209 - tSpace,
210 - {itemVariable, 0, "$"},
211 - tSpace,
212 - {itemVariable, 0, "$var"},
213 - {itemField, 0, ".Field"},
214 - tSpace,
215 - {itemField, 0, ".Method"},
216 - tRight,
217 - tEOF,
218 - }},
219 - {"variable invocation", "{{$x 23}}", []item{
220 - tLeft,
221 - {itemVariable, 0, "$x"},
222 - tSpace,
223 - {itemNumber, 0, "23"},
224 - tRight,
225 - tEOF,
226 - }},
227 - {"pipeline", `intro {{echo hi 1.2 |noargs|args 1 "hi"}} outro`, []item{
228 - {itemText, 0, "intro "},
229 - tLeft,
230 - {itemIdentifier, 0, "echo"},
231 - tSpace,
232 - {itemIdentifier, 0, "hi"},
233 - tSpace,
234 - {itemNumber, 0, "1.2"},
235 - tSpace,
236 - tPipe,
237 - {itemIdentifier, 0, "noargs"},
238 - tPipe,
239 - {itemIdentifier, 0, "args"},
240 - tSpace,
241 - {itemNumber, 0, "1"},
242 - tSpace,
243 - {itemString, 0, `"hi"`},
244 - tRight,
245 - {itemText, 0, " outro"},
246 - tEOF,
247 - }},
248 - {"declaration", "{{$v := 3}}", []item{
249 - tLeft,
250 - {itemVariable, 0, "$v"},
251 - tSpace,
252 - {itemColonEquals, 0, ":="},
253 - tSpace,
254 - {itemNumber, 0, "3"},
255 - tRight,
256 - tEOF,
257 - }},
258 - {"2 declarations", "{{$v , $w := 3}}", []item{
259 - tLeft,
260 - {itemVariable, 0, "$v"},
261 - tSpace,
262 - {itemChar, 0, ","},
263 - tSpace,
264 - {itemVariable, 0, "$w"},
265 - tSpace,
266 - {itemColonEquals, 0, ":="},
267 - tSpace,
268 - {itemNumber, 0, "3"},
269 - tRight,
270 - tEOF,
271 - }},
272 - {"field of parenthesized expression", "{{(.X).Y}}", []item{
273 - tLeft,
274 - tLpar,
275 - {itemField, 0, ".X"},
276 - tRpar,
277 - {itemField, 0, ".Y"},
278 - tRight,
279 - tEOF,
280 - }},
281 - // errors
282 - {"badchar", "#{{\x01}}", []item{
283 - {itemText, 0, "#"},
284 - tLeft,
285 - {itemError, 0, "unrecognized character in action: U+0001"},
286 - }},
287 - {"unclosed action", "{{\n}}", []item{
288 - tLeft,
289 - {itemError, 0, "unclosed action"},
290 - }},
291 - {"EOF in action", "{{range", []item{
292 - tLeft,
293 - tRange,
294 - {itemError, 0, "unclosed action"},
295 - }},
296 - {"unclosed quote", "{{\"\n\"}}", []item{
297 - tLeft,
298 - {itemError, 0, "unterminated quoted string"},
299 - }},
300 - {"unclosed raw quote", "{{`xx\n`}}", []item{
301 - tLeft,
302 - {itemError, 0, "unterminated raw quoted string"},
303 - }},
304 - {"unclosed char constant", "{{'\n}}", []item{
305 - tLeft,
306 - {itemError, 0, "unterminated character constant"},
307 - }},
308 - {"bad number", "{{3k}}", []item{
309 - tLeft,
310 - {itemError, 0, `bad number syntax: "3k"`},
311 - }},
312 - {"unclosed paren", "{{(3}}", []item{
313 - tLeft,
314 - tLpar,
315 - {itemNumber, 0, "3"},
316 - {itemError, 0, `unclosed left paren`},
317 - }},
318 - {"extra right paren", "{{3)}}", []item{
319 - tLeft,
320 - {itemNumber, 0, "3"},
321 - tRpar,
322 - {itemError, 0, `unexpected right paren U+0029 ')'`},
323 - }},
324 -
325 - // Fixed bugs
326 - // Many elements in an action blew the lookahead until
327 - // we made lexInsideAction not loop.
328 - {"long pipeline deadlock", "{{|||||}}", []item{
329 - tLeft,
330 - tPipe,
331 - tPipe,
332 - tPipe,
333 - tPipe,
334 - tPipe,
335 - tRight,
336 - tEOF,
337 - }},
338 - {"text with bad comment", "hello-{{/*/}}-world", []item{
339 - {itemText, 0, "hello-"},
340 - {itemError, 0, `unclosed comment`},
341 - }},
342 - {"text with comment close separted from delim", "hello-{{/* */ }}-world", []item{
343 - {itemText, 0, "hello-"},
344 - {itemError, 0, `comment ends before closing delimiter`},
345 - }},
346 - // This one is an error that we can't catch because it breaks templates with
347 - // minimized JavaScript. Should have fixed it before Go 1.1.
348 - {"unmatched right delimiter", "hello-{.}}-world", []item{
349 - {itemText, 0, "hello-{.}}-world"},
350 - tEOF,
351 - }},
352 -}
353 -
354 -// collect gathers the emitted items into a slice.
355 -func collect(t *lexTest, left, right string) (items []item) {
356 - l := lex(t.name, t.input, left, right)
357 - for {
358 - item := l.nextItem()
359 - items = append(items, item)
360 - if item.typ == itemEOF || item.typ == itemError {
361 - break
362 - }
363 - }
364 - return
365 -}
366 -
367 -func equal(i1, i2 []item, checkPos bool) bool {
368 - if len(i1) != len(i2) {
369 - return false
370 - }
371 - for k := range i1 {
372 - if i1[k].typ != i2[k].typ {
373 - return false
374 - }
375 - if i1[k].val != i2[k].val {
376 - return false
377 - }
378 - if checkPos && i1[k].pos != i2[k].pos {
379 - return false
380 - }
381 - }
382 - return true
383 -}
384 -
385 -func TestLex(t *testing.T) {
386 - for _, test := range lexTests {
387 - items := collect(&test, "", "")
388 - if !equal(items, test.items, false) {
389 - t.Errorf("%s: got\n\t%+v\nexpected\n\t%v", test.name, items, test.items)
390 - }
391 - }
392 -}
393 -
394 -// Some easy cases from above, but with delimiters $$ and @@
395 -var lexDelimTests = []lexTest{
396 - {"punctuation", "$$,@%{{}}@@", []item{
397 - tLeftDelim,
398 - {itemChar, 0, ","},
399 - {itemChar, 0, "@"},
400 - {itemChar, 0, "%"},
401 - {itemChar, 0, "{"},
402 - {itemChar, 0, "{"},
403 - {itemChar, 0, "}"},
404 - {itemChar, 0, "}"},
405 - tRightDelim,
406 - tEOF,
407 - }},
408 - {"empty action", `$$@@`, []item{tLeftDelim, tRightDelim, tEOF}},
409 - {"for", `$$for@@`, []item{tLeftDelim, tFor, tRightDelim, tEOF}},
410 - {"quote", `$$"abc \n\t\" "@@`, []item{tLeftDelim, tQuote, tRightDelim, tEOF}},
411 - {"raw quote", "$$" + raw + "@@", []item{tLeftDelim, tRawQuote, tRightDelim, tEOF}},
412 -}
413 -
414 -var (
415 - tLeftDelim = item{itemLeftDelim, 0, "$$"}
416 - tRightDelim = item{itemRightDelim, 0, "@@"}
417 -)
418 -
419 -func TestDelims(t *testing.T) {
420 - for _, test := range lexDelimTests {
421 - items := collect(&test, "$$", "@@")
422 - if !equal(items, test.items, false) {
423 - t.Errorf("%s: got\n\t%v\nexpected\n\t%v", test.name, items, test.items)
424 - }
425 - }
426 -}
427 -
428 -var lexPosTests = []lexTest{
429 - {"empty", "", []item{tEOF}},
430 - {"punctuation", "{{,@%#}}", []item{
431 - {itemLeftDelim, 0, "{{"},
432 - {itemChar, 2, ","},
433 - {itemChar, 3, "@"},
434 - {itemChar, 4, "%"},
435 - {itemChar, 5, "#"},
436 - {itemRightDelim, 6, "}}"},
437 - {itemEOF, 8, ""},
438 - }},
439 - {"sample", "0123{{hello}}xyz", []item{
440 - {itemText, 0, "0123"},
441 - {itemLeftDelim, 4, "{{"},
442 - {itemIdentifier, 6, "hello"},
443 - {itemRightDelim, 11, "}}"},
444 - {itemText, 13, "xyz"},
445 - {itemEOF, 16, ""},
446 - }},
447 -}
448 -
449 -// The other tests don't check position, to make the test cases easier to construct.
450 -// This one does.
451 -func TestPos(t *testing.T) {
452 - for _, test := range lexPosTests {
453 - items := collect(&test, "", "")
454 - if !equal(items, test.items, true) {
455 - t.Errorf("%s: got\n\t%v\nexpected\n\t%v", test.name, items, test.items)
456 - if len(items) == len(test.items) {
457 - // Detailed print; avoid item.String() to expose the position value.
458 - for i := range items {
459 - if !equal(items[i:i+1], test.items[i:i+1], true) {
460 - i1 := items[i]
461 - i2 := test.items[i]
462 - t.Errorf("\t#%d: got {%v %d %q} expected {%v %d %q}", i, i1.typ, i1.pos, i1.val, i2.typ, i2.pos, i2.val)
463 - }
464 - }
465 - }
466 - }
467 - }
468 -}
Godeps/_workspace/src/github.com/alecthomas/template/parse/node.go deleted
-834
@@ -1,834 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// Parse nodes.
6 -
7 -package parse
8 -
9 -import (
10 - "bytes"
11 - "fmt"
12 - "strconv"
13 - "strings"
14 -)
15 -
16 -var textFormat = "%s" // Changed to "%q" in tests for better error messages.
17 -
18 -// A Node is an element in the parse tree. The interface is trivial.
19 -// The interface contains an unexported method so that only
20 -// types local to this package can satisfy it.
21 -type Node interface {
22 - Type() NodeType
23 - String() string
24 - // Copy does a deep copy of the Node and all its components.
25 - // To avoid type assertions, some XxxNodes also have specialized
26 - // CopyXxx methods that return *XxxNode.
27 - Copy() Node
28 - Position() Pos // byte position of start of node in full original input string
29 - // tree returns the containing *Tree.
30 - // It is unexported so all implementations of Node are in this package.
31 - tree() *Tree
32 -}
33 -
34 -// NodeType identifies the type of a parse tree node.
35 -type NodeType int
36 -
37 -// Pos represents a byte position in the original input text from which
38 -// this template was parsed.
39 -type Pos int
40 -
41 -func (p Pos) Position() Pos {
42 - return p
43 -}
44 -
45 -// Type returns itself and provides an easy default implementation
46 -// for embedding in a Node. Embedded in all non-trivial Nodes.
47 -func (t NodeType) Type() NodeType {
48 - return t
49 -}
50 -
51 -const (
52 - NodeText NodeType = iota // Plain text.
53 - NodeAction // A non-control action such as a field evaluation.
54 - NodeBool // A boolean constant.
55 - NodeChain // A sequence of field accesses.
56 - NodeCommand // An element of a pipeline.
57 - NodeDot // The cursor, dot.
58 - nodeElse // An else action. Not added to tree.
59 - nodeEnd // An end action. Not added to tree.
60 - NodeField // A field or method name.
61 - NodeIdentifier // An identifier; always a function name.
62 - NodeIf // An if action.
63 - NodeList // A list of Nodes.
64 - NodeNil // An untyped nil constant.
65 - NodeNumber // A numerical constant.
66 - NodePipe // A pipeline of commands.
67 - NodeRange // A range action.
68 - NodeString // A string constant.
69 - NodeTemplate // A template invocation action.
70 - NodeVariable // A $ variable.
71 - NodeWith // A with action.
72 -)
73 -
74 -// Nodes.
75 -
76 -// ListNode holds a sequence of nodes.
77 -type ListNode struct {
78 - NodeType
79 - Pos
80 - tr *Tree
81 - Nodes []Node // The element nodes in lexical order.
82 -}
83 -
84 -func (t *Tree) newList(pos Pos) *ListNode {
85 - return &ListNode{tr: t, NodeType: NodeList, Pos: pos}
86 -}
87 -
88 -func (l *ListNode) append(n Node) {
89 - l.Nodes = append(l.Nodes, n)
90 -}
91 -
92 -func (l *ListNode) tree() *Tree {
93 - return l.tr
94 -}
95 -
96 -func (l *ListNode) String() string {
97 - b := new(bytes.Buffer)
98 - for _, n := range l.Nodes {
99 - fmt.Fprint(b, n)
100 - }
101 - return b.String()
102 -}
103 -
104 -func (l *ListNode) CopyList() *ListNode {
105 - if l == nil {
106 - return l
107 - }
108 - n := l.tr.newList(l.Pos)
109 - for _, elem := range l.Nodes {
110 - n.append(elem.Copy())
111 - }
112 - return n
113 -}
114 -
115 -func (l *ListNode) Copy() Node {
116 - return l.CopyList()
117 -}
118 -
119 -// TextNode holds plain text.
120 -type TextNode struct {
121 - NodeType
122 - Pos
123 - tr *Tree
124 - Text []byte // The text; may span newlines.
125 -}
126 -
127 -func (t *Tree) newText(pos Pos, text string) *TextNode {
128 - return &TextNode{tr: t, NodeType: NodeText, Pos: pos, Text: []byte(text)}
129 -}
130 -
131 -func (t *TextNode) String() string {
132 - return fmt.Sprintf(textFormat, t.Text)
133 -}
134 -
135 -func (t *TextNode) tree() *Tree {
136 - return t.tr
137 -}
138 -
139 -func (t *TextNode) Copy() Node {
140 - return &TextNode{tr: t.tr, NodeType: NodeText, Pos: t.Pos, Text: append([]byte{}, t.Text...)}
141 -}
142 -
143 -// PipeNode holds a pipeline with optional declaration
144 -type PipeNode struct {
145 - NodeType
146 - Pos
147 - tr *Tree
148 - Line int // The line number in the input (deprecated; kept for compatibility)
149 - Decl []*VariableNode // Variable declarations in lexical order.
150 - Cmds []*CommandNode // The commands in lexical order.
151 -}
152 -
153 -func (t *Tree) newPipeline(pos Pos, line int, decl []*VariableNode) *PipeNode {
154 - return &PipeNode{tr: t, NodeType: NodePipe, Pos: pos, Line: line, Decl: decl}
155 -}
156 -
157 -func (p *PipeNode) append(command *CommandNode) {
158 - p.Cmds = append(p.Cmds, command)
159 -}
160 -
161 -func (p *PipeNode) String() string {
162 - s := ""
163 - if len(p.Decl) > 0 {
164 - for i, v := range p.Decl {
165 - if i > 0 {
166 - s += ", "
167 - }
168 - s += v.String()
169 - }
170 - s += " := "
171 - }
172 - for i, c := range p.Cmds {
173 - if i > 0 {
174 - s += " | "
175 - }
176 - s += c.String()
177 - }
178 - return s
179 -}
180 -
181 -func (p *PipeNode) tree() *Tree {
182 - return p.tr
183 -}
184 -
185 -func (p *PipeNode) CopyPipe() *PipeNode {
186 - if p == nil {
187 - return p
188 - }
189 - var decl []*VariableNode
190 - for _, d := range p.Decl {
191 - decl = append(decl, d.Copy().(*VariableNode))
192 - }
193 - n := p.tr.newPipeline(p.Pos, p.Line, decl)
194 - for _, c := range p.Cmds {
195 - n.append(c.Copy().(*CommandNode))
196 - }
197 - return n
198 -}
199 -
200 -func (p *PipeNode) Copy() Node {
201 - return p.CopyPipe()
202 -}
203 -
204 -// ActionNode holds an action (something bounded by delimiters).
205 -// Control actions have their own nodes; ActionNode represents simple
206 -// ones such as field evaluations and parenthesized pipelines.
207 -type ActionNode struct {
208 - NodeType
209 - Pos
210 - tr *Tree
211 - Line int // The line number in the input (deprecated; kept for compatibility)
212 - Pipe *PipeNode // The pipeline in the action.
213 -}
214 -
215 -func (t *Tree) newAction(pos Pos, line int, pipe *PipeNode) *ActionNode {
216 - return &ActionNode{tr: t, NodeType: NodeAction, Pos: pos, Line: line, Pipe: pipe}
217 -}
218 -
219 -func (a *ActionNode) String() string {
220 - return fmt.Sprintf("{{%s}}", a.Pipe)
221 -
222 -}
223 -
224 -func (a *ActionNode) tree() *Tree {
225 - return a.tr
226 -}
227 -
228 -func (a *ActionNode) Copy() Node {
229 - return a.tr.newAction(a.Pos, a.Line, a.Pipe.CopyPipe())
230 -
231 -}
232 -
233 -// CommandNode holds a command (a pipeline inside an evaluating action).
234 -type CommandNode struct {
235 - NodeType
236 - Pos
237 - tr *Tree
238 - Args []Node // Arguments in lexical order: Identifier, field, or constant.
239 -}
240 -
241 -func (t *Tree) newCommand(pos Pos) *CommandNode {
242 - return &CommandNode{tr: t, NodeType: NodeCommand, Pos: pos}
243 -}
244 -
245 -func (c *CommandNode) append(arg Node) {
246 - c.Args = append(c.Args, arg)
247 -}
248 -
249 -func (c *CommandNode) String() string {
250 - s := ""
251 - for i, arg := range c.Args {
252 - if i > 0 {
253 - s += " "
254 - }
255 - if arg, ok := arg.(*PipeNode); ok {
256 - s += "(" + arg.String() + ")"
257 - continue
258 - }
259 - s += arg.String()
260 - }
261 - return s
262 -}
263 -
264 -func (c *CommandNode) tree() *Tree {
265 - return c.tr
266 -}
267 -
268 -func (c *CommandNode) Copy() Node {
269 - if c == nil {
270 - return c
271 - }
272 - n := c.tr.newCommand(c.Pos)
273 - for _, c := range c.Args {
274 - n.append(c.Copy())
275 - }
276 - return n
277 -}
278 -
279 -// IdentifierNode holds an identifier.
280 -type IdentifierNode struct {
281 - NodeType
282 - Pos
283 - tr *Tree
284 - Ident string // The identifier's name.
285 -}
286 -
287 -// NewIdentifier returns a new IdentifierNode with the given identifier name.
288 -func NewIdentifier(ident string) *IdentifierNode {
289 - return &IdentifierNode{NodeType: NodeIdentifier, Ident: ident}
290 -}
291 -
292 -// SetPos sets the position. NewIdentifier is a public method so we can't modify its signature.
293 -// Chained for convenience.
294 -// TODO: fix one day?
295 -func (i *IdentifierNode) SetPos(pos Pos) *IdentifierNode {
296 - i.Pos = pos
297 - return i
298 -}
299 -
300 -// SetTree sets the parent tree for the node. NewIdentifier is a public method so we can't modify its signature.
301 -// Chained for convenience.
302 -// TODO: fix one day?
303 -func (i *IdentifierNode) SetTree(t *Tree) *IdentifierNode {
304 - i.tr = t
305 - return i
306 -}
307 -
308 -func (i *IdentifierNode) String() string {
309 - return i.Ident
310 -}
311 -
312 -func (i *IdentifierNode) tree() *Tree {
313 - return i.tr
314 -}
315 -
316 -func (i *IdentifierNode) Copy() Node {
317 - return NewIdentifier(i.Ident).SetTree(i.tr).SetPos(i.Pos)
318 -}
319 -
320 -// VariableNode holds a list of variable names, possibly with chained field
321 -// accesses. The dollar sign is part of the (first) name.
322 -type VariableNode struct {
323 - NodeType
324 - Pos
325 - tr *Tree
326 - Ident []string // Variable name and fields in lexical order.
327 -}
328 -
329 -func (t *Tree) newVariable(pos Pos, ident string) *VariableNode {
330 - return &VariableNode{tr: t, NodeType: NodeVariable, Pos: pos, Ident: strings.Split(ident, ".")}
331 -}
332 -
333 -func (v *VariableNode) String() string {
334 - s := ""
335 - for i, id := range v.Ident {
336 - if i > 0 {
337 - s += "."
338 - }
339 - s += id
340 - }
341 - return s
342 -}
343 -
344 -func (v *VariableNode) tree() *Tree {
345 - return v.tr
346 -}
347 -
348 -func (v *VariableNode) Copy() Node {
349 - return &VariableNode{tr: v.tr, NodeType: NodeVariable, Pos: v.Pos, Ident: append([]string{}, v.Ident...)}
350 -}
351 -
352 -// DotNode holds the special identifier '.'.
353 -type DotNode struct {
354 - NodeType
355 - Pos
356 - tr *Tree
357 -}
358 -
359 -func (t *Tree) newDot(pos Pos) *DotNode {
360 - return &DotNode{tr: t, NodeType: NodeDot, Pos: pos}
361 -}
362 -
363 -func (d *DotNode) Type() NodeType {
364 - // Override method on embedded NodeType for API compatibility.
365 - // TODO: Not really a problem; could change API without effect but
366 - // api tool complains.
367 - return NodeDot
368 -}
369 -
370 -func (d *DotNode) String() string {
371 - return "."
372 -}
373 -
374 -func (d *DotNode) tree() *Tree {
375 - return d.tr
376 -}
377 -
378 -func (d *DotNode) Copy() Node {
379 - return d.tr.newDot(d.Pos)
380 -}
381 -
382 -// NilNode holds the special identifier 'nil' representing an untyped nil constant.
383 -type NilNode struct {
384 - NodeType
385 - Pos
386 - tr *Tree
387 -}
388 -
389 -func (t *Tree) newNil(pos Pos) *NilNode {
390 - return &NilNode{tr: t, NodeType: NodeNil, Pos: pos}
391 -}
392 -
393 -func (n *NilNode) Type() NodeType {
394 - // Override method on embedded NodeType for API compatibility.
395 - // TODO: Not really a problem; could change API without effect but
396 - // api tool complains.
397 - return NodeNil
398 -}
399 -
400 -func (n *NilNode) String() string {
401 - return "nil"
402 -}
403 -
404 -func (n *NilNode) tree() *Tree {
405 - return n.tr
406 -}
407 -
408 -func (n *NilNode) Copy() Node {
409 - return n.tr.newNil(n.Pos)
410 -}
411 -
412 -// FieldNode holds a field (identifier starting with '.').
413 -// The names may be chained ('.x.y').
414 -// The period is dropped from each ident.
415 -type FieldNode struct {
416 - NodeType
417 - Pos
418 - tr *Tree
419 - Ident []string // The identifiers in lexical order.
420 -}
421 -
422 -func (t *Tree) newField(pos Pos, ident string) *FieldNode {
423 - return &FieldNode{tr: t, NodeType: NodeField, Pos: pos, Ident: strings.Split(ident[1:], ".")} // [1:] to drop leading period
424 -}
425 -
426 -func (f *FieldNode) String() string {
427 - s := ""
428 - for _, id := range f.Ident {
429 - s += "." + id
430 - }
431 - return s
432 -}
433 -
434 -func (f *FieldNode) tree() *Tree {
435 - return f.tr
436 -}
437 -
438 -func (f *FieldNode) Copy() Node {
439 - return &FieldNode{tr: f.tr, NodeType: NodeField, Pos: f.Pos, Ident: append([]string{}, f.Ident...)}
440 -}
441 -
442 -// ChainNode holds a term followed by a chain of field accesses (identifier starting with '.').
443 -// The names may be chained ('.x.y').
444 -// The periods are dropped from each ident.
445 -type ChainNode struct {
446 - NodeType
447 - Pos
448 - tr *Tree
449 - Node Node
450 - Field []string // The identifiers in lexical order.
451 -}
452 -
453 -func (t *Tree) newChain(pos Pos, node Node) *ChainNode {
454 - return &ChainNode{tr: t, NodeType: NodeChain, Pos: pos, Node: node}
455 -}
456 -
457 -// Add adds the named field (which should start with a period) to the end of the chain.
458 -func (c *ChainNode) Add(field string) {
459 - if len(field) == 0 || field[0] != '.' {
460 - panic("no dot in field")
461 - }
462 - field = field[1:] // Remove leading dot.
463 - if field == "" {
464 - panic("empty field")
465 - }
466 - c.Field = append(c.Field, field)
467 -}
468 -
469 -func (c *ChainNode) String() string {
470 - s := c.Node.String()
471 - if _, ok := c.Node.(*PipeNode); ok {
472 - s = "(" + s + ")"
473 - }
474 - for _, field := range c.Field {
475 - s += "." + field
476 - }
477 - return s
478 -}
479 -
480 -func (c *ChainNode) tree() *Tree {
481 - return c.tr
482 -}
483 -
484 -func (c *ChainNode) Copy() Node {
485 - return &ChainNode{tr: c.tr, NodeType: NodeChain, Pos: c.Pos, Node: c.Node, Field: append([]string{}, c.Field...)}
486 -}
487 -
488 -// BoolNode holds a boolean constant.
489 -type BoolNode struct {
490 - NodeType
491 - Pos
492 - tr *Tree
493 - True bool // The value of the boolean constant.
494 -}
495 -
496 -func (t *Tree) newBool(pos Pos, true bool) *BoolNode {
497 - return &BoolNode{tr: t, NodeType: NodeBool, Pos: pos, True: true}
498 -}
499 -
500 -func (b *BoolNode) String() string {
501 - if b.True {
502 - return "true"
503 - }
504 - return "false"
505 -}
506 -
507 -func (b *BoolNode) tree() *Tree {
508 - return b.tr
509 -}
510 -
511 -func (b *BoolNode) Copy() Node {
512 - return b.tr.newBool(b.Pos, b.True)
513 -}
514 -
515 -// NumberNode holds a number: signed or unsigned integer, float, or complex.
516 -// The value is parsed and stored under all the types that can represent the value.
517 -// This simulates in a small amount of code the behavior of Go's ideal constants.
518 -type NumberNode struct {
519 - NodeType
520 - Pos
521 - tr *Tree
522 - IsInt bool // Number has an integral value.
523 - IsUint bool // Number has an unsigned integral value.
524 - IsFloat bool // Number has a floating-point value.
525 - IsComplex bool // Number is complex.
526 - Int64 int64 // The signed integer value.
527 - Uint64 uint64 // The unsigned integer value.
528 - Float64 float64 // The floating-point value.
529 - Complex128 complex128 // The complex value.
530 - Text string // The original textual representation from the input.
531 -}
532 -
533 -func (t *Tree) newNumber(pos Pos, text string, typ itemType) (*NumberNode, error) {
534 - n := &NumberNode{tr: t, NodeType: NodeNumber, Pos: pos, Text: text}
535 - switch typ {
536 - case itemCharConstant:
537 - rune, _, tail, err := strconv.UnquoteChar(text[1:], text[0])
538 - if err != nil {
539 - return nil, err
540 - }
541 - if tail != "'" {
542 - return nil, fmt.Errorf("malformed character constant: %s", text)
543 - }
544 - n.Int64 = int64(rune)
545 - n.IsInt = true
546 - n.Uint64 = uint64(rune)
547 - n.IsUint = true
548 - n.Float64 = float64(rune) // odd but those are the rules.
549 - n.IsFloat = true
550 - return n, nil
551 - case itemComplex:
552 - // fmt.Sscan can parse the pair, so let it do the work.
553 - if _, err := fmt.Sscan(text, &n.Complex128); err != nil {
554 - return nil, err
555 - }
556 - n.IsComplex = true
557 - n.simplifyComplex()
558 - return n, nil
559 - }
560 - // Imaginary constants can only be complex unless they are zero.
561 - if len(text) > 0 && text[len(text)-1] == 'i' {
562 - f, err := strconv.ParseFloat(text[:len(text)-1], 64)
563 - if err == nil {
564 - n.IsComplex = true
565 - n.Complex128 = complex(0, f)
566 - n.simplifyComplex()
567 - return n, nil
568 - }
569 - }
570 - // Do integer test first so we get 0x123 etc.
571 - u, err := strconv.ParseUint(text, 0, 64) // will fail for -0; fixed below.
572 - if err == nil {
573 - n.IsUint = true
574 - n.Uint64 = u
575 - }
576 - i, err := strconv.ParseInt(text, 0, 64)
577 - if err == nil {
578 - n.IsInt = true
579 - n.Int64 = i
580 - if i == 0 {
581 - n.IsUint = true // in case of -0.
582 - n.Uint64 = u
583 - }
584 - }
585 - // If an integer extraction succeeded, promote the float.
586 - if n.IsInt {
587 - n.IsFloat = true
588 - n.Float64 = float64(n.Int64)
589 - } else if n.IsUint {
590 - n.IsFloat = true
591 - n.Float64 = float64(n.Uint64)
592 - } else {
593 - f, err := strconv.ParseFloat(text, 64)
594 - if err == nil {
595 - n.IsFloat = true
596 - n.Float64 = f
597 - // If a floating-point extraction succeeded, extract the int if needed.
598 - if !n.IsInt && float64(int64(f)) == f {
599 - n.IsInt = true
600 - n.Int64 = int64(f)
601 - }
602 - if !n.IsUint && float64(uint64(f)) == f {
603 - n.IsUint = true
604 - n.Uint64 = uint64(f)
605 - }
606 - }
607 - }
608 - if !n.IsInt && !n.IsUint && !n.IsFloat {
609 - return nil, fmt.Errorf("illegal number syntax: %q", text)
610 - }
611 - return n, nil
612 -}
613 -
614 -// simplifyComplex pulls out any other types that are represented by the complex number.
615 -// These all require that the imaginary part be zero.
616 -func (n *NumberNode) simplifyComplex() {
617 - n.IsFloat = imag(n.Complex128) == 0
618 - if n.IsFloat {
619 - n.Float64 = real(n.Complex128)
620 - n.IsInt = float64(int64(n.Float64)) == n.Float64
621 - if n.IsInt {
622 - n.Int64 = int64(n.Float64)
623 - }
624 - n.IsUint = float64(uint64(n.Float64)) == n.Float64
625 - if n.IsUint {
626 - n.Uint64 = uint64(n.Float64)
627 - }
628 - }
629 -}
630 -
631 -func (n *NumberNode) String() string {
632 - return n.Text
633 -}
634 -
635 -func (n *NumberNode) tree() *Tree {
636 - return n.tr
637 -}
638 -
639 -func (n *NumberNode) Copy() Node {
640 - nn := new(NumberNode)
641 - *nn = *n // Easy, fast, correct.
642 - return nn
643 -}
644 -
645 -// StringNode holds a string constant. The value has been "unquoted".
646 -type StringNode struct {
647 - NodeType
648 - Pos
649 - tr *Tree
650 - Quoted string // The original text of the string, with quotes.
651 - Text string // The string, after quote processing.
652 -}
653 -
654 -func (t *Tree) newString(pos Pos, orig, text string) *StringNode {
655 - return &StringNode{tr: t, NodeType: NodeString, Pos: pos, Quoted: orig, Text: text}
656 -}
657 -
658 -func (s *StringNode) String() string {
659 - return s.Quoted
660 -}
661 -
662 -func (s *StringNode) tree() *Tree {
663 - return s.tr
664 -}
665 -
666 -func (s *StringNode) Copy() Node {
667 - return s.tr.newString(s.Pos, s.Quoted, s.Text)
668 -}
669 -
670 -// endNode represents an {{end}} action.
671 -// It does not appear in the final parse tree.
672 -type endNode struct {
673 - NodeType
674 - Pos
675 - tr *Tree
676 -}
677 -
678 -func (t *Tree) newEnd(pos Pos) *endNode {
679 - return &endNode{tr: t, NodeType: nodeEnd, Pos: pos}
680 -}
681 -
682 -func (e *endNode) String() string {
683 - return "{{end}}"
684 -}
685 -
686 -func (e *endNode) tree() *Tree {
687 - return e.tr
688 -}
689 -
690 -func (e *endNode) Copy() Node {
691 - return e.tr.newEnd(e.Pos)
692 -}
693 -
694 -// elseNode represents an {{else}} action. Does not appear in the final tree.
695 -type elseNode struct {
696 - NodeType
697 - Pos
698 - tr *Tree
699 - Line int // The line number in the input (deprecated; kept for compatibility)
700 -}
701 -
702 -func (t *Tree) newElse(pos Pos, line int) *elseNode {
703 - return &elseNode{tr: t, NodeType: nodeElse, Pos: pos, Line: line}
704 -}
705 -
706 -func (e *elseNode) Type() NodeType {
707 - return nodeElse
708 -}
709 -
710 -func (e *elseNode) String() string {
711 - return "{{else}}"
712 -}
713 -
714 -func (e *elseNode) tree() *Tree {
715 - return e.tr
716 -}
717 -
718 -func (e *elseNode) Copy() Node {
719 - return e.tr.newElse(e.Pos, e.Line)
720 -}
721 -
722 -// BranchNode is the common representation of if, range, and with.
723 -type BranchNode struct {
724 - NodeType
725 - Pos
726 - tr *Tree
727 - Line int // The line number in the input (deprecated; kept for compatibility)
728 - Pipe *PipeNode // The pipeline to be evaluated.
729 - List *ListNode // What to execute if the value is non-empty.
730 - ElseList *ListNode // What to execute if the value is empty (nil if absent).
731 -}
732 -
733 -func (b *BranchNode) String() string {
734 - name := ""
735 - switch b.NodeType {
736 - case NodeIf:
737 - name = "if"
738 - case NodeRange:
739 - name = "range"
740 - case NodeWith:
741 - name = "with"
742 - default:
743 - panic("unknown branch type")
744 - }
745 - if b.ElseList != nil {
746 - return fmt.Sprintf("{{%s %s}}%s{{else}}%s{{end}}", name, b.Pipe, b.List, b.ElseList)
747 - }
748 - return fmt.Sprintf("{{%s %s}}%s{{end}}", name, b.Pipe, b.List)
749 -}
750 -
751 -func (b *BranchNode) tree() *Tree {
752 - return b.tr
753 -}
754 -
755 -func (b *BranchNode) Copy() Node {
756 - switch b.NodeType {
757 - case NodeIf:
758 - return b.tr.newIf(b.Pos, b.Line, b.Pipe, b.List, b.ElseList)
759 - case NodeRange:
760 - return b.tr.newRange(b.Pos, b.Line, b.Pipe, b.List, b.ElseList)
761 - case NodeWith:
762 - return b.tr.newWith(b.Pos, b.Line, b.Pipe, b.List, b.ElseList)
763 - default:
764 - panic("unknown branch type")
765 - }
766 -}
767 -
768 -// IfNode represents an {{if}} action and its commands.
769 -type IfNode struct {
770 - BranchNode
771 -}
772 -
773 -func (t *Tree) newIf(pos Pos, line int, pipe *PipeNode, list, elseList *ListNode) *IfNode {
774 - return &IfNode{BranchNode{tr: t, NodeType: NodeIf, Pos: pos, Line: line, Pipe: pipe, List: list, ElseList: elseList}}
775 -}
776 -
777 -func (i *IfNode) Copy() Node {
778 - return i.tr.newIf(i.Pos, i.Line, i.Pipe.CopyPipe(), i.List.CopyList(), i.ElseList.CopyList())
779 -}
780 -
781 -// RangeNode represents a {{range}} action and its commands.
782 -type RangeNode struct {
783 - BranchNode
784 -}
785 -
786 -func (t *Tree) newRange(pos Pos, line int, pipe *PipeNode, list, elseList *ListNode) *RangeNode {
787 - return &RangeNode{BranchNode{tr: t, NodeType: NodeRange, Pos: pos, Line: line, Pipe: pipe, List: list, ElseList: elseList}}
788 -}
789 -
790 -func (r *RangeNode) Copy() Node {
791 - return r.tr.newRange(r.Pos, r.Line, r.Pipe.CopyPipe(), r.List.CopyList(), r.ElseList.CopyList())
792 -}
793 -
794 -// WithNode represents a {{with}} action and its commands.
795 -type WithNode struct {
796 - BranchNode
797 -}
798 -
799 -func (t *Tree) newWith(pos Pos, line int, pipe *PipeNode, list, elseList *ListNode) *WithNode {
800 - return &WithNode{BranchNode{tr: t, NodeType: NodeWith, Pos: pos, Line: line, Pipe: pipe, List: list, ElseList: elseList}}
801 -}
802 -
803 -func (w *WithNode) Copy() Node {
804 - return w.tr.newWith(w.Pos, w.Line, w.Pipe.CopyPipe(), w.List.CopyList(), w.ElseList.CopyList())
805 -}
806 -
807 -// TemplateNode represents a {{template}} action.
808 -type TemplateNode struct {
809 - NodeType
810 - Pos
811 - tr *Tree
812 - Line int // The line number in the input (deprecated; kept for compatibility)
813 - Name string // The name of the template (unquoted).
814 - Pipe *PipeNode // The command to evaluate as dot for the template.
815 -}
816 -
817 -func (t *Tree) newTemplate(pos Pos, line int, name string, pipe *PipeNode) *TemplateNode {
818 - return &TemplateNode{tr: t, NodeType: NodeTemplate, Pos: pos, Line: line, Name: name, Pipe: pipe}
819 -}
820 -
821 -func (t *TemplateNode) String() string {
822 - if t.Pipe == nil {
823 - return fmt.Sprintf("{{template %q}}", t.Name)
824 - }
825 - return fmt.Sprintf("{{template %q %s}}", t.Name, t.Pipe)
826 -}
827 -
828 -func (t *TemplateNode) tree() *Tree {
829 - return t.tr
830 -}
831 -
832 -func (t *TemplateNode) Copy() Node {
833 - return t.tr.newTemplate(t.Pos, t.Line, t.Name, t.Pipe.CopyPipe())
834 -}
Godeps/_workspace/src/github.com/alecthomas/template/parse/parse.go deleted
-700
@@ -1,700 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// Package parse builds parse trees for templates as defined by text/template
6 -// and html/template. Clients should use those packages to construct templates
7 -// rather than this one, which provides shared internal data structures not
8 -// intended for general use.
9 -package parse
10 -
11 -import (
12 - "bytes"
13 - "fmt"
14 - "runtime"
15 - "strconv"
16 - "strings"
17 -)
18 -
19 -// Tree is the representation of a single parsed template.
20 -type Tree struct {
21 - Name string // name of the template represented by the tree.
22 - ParseName string // name of the top-level template during parsing, for error messages.
23 - Root *ListNode // top-level root of the tree.
24 - text string // text parsed to create the template (or its parent)
25 - // Parsing only; cleared after parse.
26 - funcs []map[string]interface{}
27 - lex *lexer
28 - token [3]item // three-token lookahead for parser.
29 - peekCount int
30 - vars []string // variables defined at the moment.
31 -}
32 -
33 -// Copy returns a copy of the Tree. Any parsing state is discarded.
34 -func (t *Tree) Copy() *Tree {
35 - if t == nil {
36 - return nil
37 - }
38 - return &Tree{
39 - Name: t.Name,
40 - ParseName: t.ParseName,
41 - Root: t.Root.CopyList(),
42 - text: t.text,
43 - }
44 -}
45 -
46 -// Parse returns a map from template name to parse.Tree, created by parsing the
47 -// templates described in the argument string. The top-level template will be
48 -// given the specified name. If an error is encountered, parsing stops and an
49 -// empty map is returned with the error.
50 -func Parse(name, text, leftDelim, rightDelim string, funcs ...map[string]interface{}) (treeSet map[string]*Tree, err error) {
51 - treeSet = make(map[string]*Tree)
52 - t := New(name)
53 - t.text = text
54 - _, err = t.Parse(text, leftDelim, rightDelim, treeSet, funcs...)
55 - return
56 -}
57 -
58 -// next returns the next token.
59 -func (t *Tree) next() item {
60 - if t.peekCount > 0 {
61 - t.peekCount--
62 - } else {
63 - t.token[0] = t.lex.nextItem()
64 - }
65 - return t.token[t.peekCount]
66 -}
67 -
68 -// backup backs the input stream up one token.
69 -func (t *Tree) backup() {
70 - t.peekCount++
71 -}
72 -
73 -// backup2 backs the input stream up two tokens.
74 -// The zeroth token is already there.
75 -func (t *Tree) backup2(t1 item) {
76 - t.token[1] = t1
77 - t.peekCount = 2
78 -}
79 -
80 -// backup3 backs the input stream up three tokens
81 -// The zeroth token is already there.
82 -func (t *Tree) backup3(t2, t1 item) { // Reverse order: we're pushing back.
83 - t.token[1] = t1
84 - t.token[2] = t2
85 - t.peekCount = 3
86 -}
87 -
88 -// peek returns but does not consume the next token.
89 -func (t *Tree) peek() item {
90 - if t.peekCount > 0 {
91 - return t.token[t.peekCount-1]
92 - }
93 - t.peekCount = 1
94 - t.token[0] = t.lex.nextItem()
95 - return t.token[0]
96 -}
97 -
98 -// nextNonSpace returns the next non-space token.
99 -func (t *Tree) nextNonSpace() (token item) {
100 - for {
101 - token = t.next()
102 - if token.typ != itemSpace {
103 - break
104 - }
105 - }
106 - return token
107 -}
108 -
109 -// peekNonSpace returns but does not consume the next non-space token.
110 -func (t *Tree) peekNonSpace() (token item) {
111 - for {
112 - token = t.next()
113 - if token.typ != itemSpace {
114 - break
115 - }
116 - }
117 - t.backup()
118 - return token
119 -}
120 -
121 -// Parsing.
122 -
123 -// New allocates a new parse tree with the given name.
124 -func New(name string, funcs ...map[string]interface{}) *Tree {
125 - return &Tree{
126 - Name: name,
127 - funcs: funcs,
128 - }
129 -}
130 -
131 -// ErrorContext returns a textual representation of the location of the node in the input text.
132 -// The receiver is only used when the node does not have a pointer to the tree inside,
133 -// which can occur in old code.
134 -func (t *Tree) ErrorContext(n Node) (location, context string) {
135 - pos := int(n.Position())
136 - tree := n.tree()
137 - if tree == nil {
138 - tree = t
139 - }
140 - text := tree.text[:pos]
141 - byteNum := strings.LastIndex(text, "\n")
142 - if byteNum == -1 {
143 - byteNum = pos // On first line.
144 - } else {
145 - byteNum++ // After the newline.
146 - byteNum = pos - byteNum
147 - }
148 - lineNum := 1 + strings.Count(text, "\n")
149 - context = n.String()
150 - if len(context) > 20 {
151 - context = fmt.Sprintf("%.20s...", context)
152 - }
153 - return fmt.Sprintf("%s:%d:%d", tree.ParseName, lineNum, byteNum), context
154 -}
155 -
156 -// errorf formats the error and terminates processing.
157 -func (t *Tree) errorf(format string, args ...interface{}) {
158 - t.Root = nil
159 - format = fmt.Sprintf("template: %s:%d: %s", t.ParseName, t.lex.lineNumber(), format)
160 - panic(fmt.Errorf(format, args...))
161 -}
162 -
163 -// error terminates processing.
164 -func (t *Tree) error(err error) {
165 - t.errorf("%s", err)
166 -}
167 -
168 -// expect consumes the next token and guarantees it has the required type.
169 -func (t *Tree) expect(expected itemType, context string) item {
170 - token := t.nextNonSpace()
171 - if token.typ != expected {
172 - t.unexpected(token, context)
173 - }
174 - return token
175 -}
176 -
177 -// expectOneOf consumes the next token and guarantees it has one of the required types.
178 -func (t *Tree) expectOneOf(expected1, expected2 itemType, context string) item {
179 - token := t.nextNonSpace()
180 - if token.typ != expected1 && token.typ != expected2 {
181 - t.unexpected(token, context)
182 - }
183 - return token
184 -}
185 -
186 -// unexpected complains about the token and terminates processing.
187 -func (t *Tree) unexpected(token item, context string) {
188 - t.errorf("unexpected %s in %s", token, context)
189 -}
190 -
191 -// recover is the handler that turns panics into returns from the top level of Parse.
192 -func (t *Tree) recover(errp *error) {
193 - e := recover()
194 - if e != nil {
195 - if _, ok := e.(runtime.Error); ok {
196 - panic(e)
197 - }
198 - if t != nil {
199 - t.stopParse()
200 - }
201 - *errp = e.(error)
202 - }
203 - return
204 -}
205 -
206 -// startParse initializes the parser, using the lexer.
207 -func (t *Tree) startParse(funcs []map[string]interface{}, lex *lexer) {
208 - t.Root = nil
209 - t.lex = lex
210 - t.vars = []string{"$"}
211 - t.funcs = funcs
212 -}
213 -
214 -// stopParse terminates parsing.
215 -func (t *Tree) stopParse() {
216 - t.lex = nil
217 - t.vars = nil
218 - t.funcs = nil
219 -}
220 -
221 -// Parse parses the template definition string to construct a representation of
222 -// the template for execution. If either action delimiter string is empty, the
223 -// default ("{{" or "}}") is used. Embedded template definitions are added to
224 -// the treeSet map.
225 -func (t *Tree) Parse(text, leftDelim, rightDelim string, treeSet map[string]*Tree, funcs ...map[string]interface{}) (tree *Tree, err error) {
226 - defer t.recover(&err)
227 - t.ParseName = t.Name
228 - t.startParse(funcs, lex(t.Name, text, leftDelim, rightDelim))
229 - t.text = text
230 - t.parse(treeSet)
231 - t.add(treeSet)
232 - t.stopParse()
233 - return t, nil
234 -}
235 -
236 -// add adds tree to the treeSet.
237 -func (t *Tree) add(treeSet map[string]*Tree) {
238 - tree := treeSet[t.Name]
239 - if tree == nil || IsEmptyTree(tree.Root) {
240 - treeSet[t.Name] = t
241 - return
242 - }
243 - if !IsEmptyTree(t.Root) {
244 - t.errorf("template: multiple definition of template %q", t.Name)
245 - }
246 -}
247 -
248 -// IsEmptyTree reports whether this tree (node) is empty of everything but space.
249 -func IsEmptyTree(n Node) bool {
250 - switch n := n.(type) {
251 - case nil:
252 - return true
253 - case *ActionNode:
254 - case *IfNode:
255 - case *ListNode:
256 - for _, node := range n.Nodes {
257 - if !IsEmptyTree(node) {
258 - return false
259 - }
260 - }
261 - return true
262 - case *RangeNode:
263 - case *TemplateNode:
264 - case *TextNode:
265 - return len(bytes.TrimSpace(n.Text)) == 0
266 - case *WithNode:
267 - default:
268 - panic("unknown node: " + n.String())
269 - }
270 - return false
271 -}
272 -
273 -// parse is the top-level parser for a template, essentially the same
274 -// as itemList except it also parses {{define}} actions.
275 -// It runs to EOF.
276 -func (t *Tree) parse(treeSet map[string]*Tree) (next Node) {
277 - t.Root = t.newList(t.peek().pos)
278 - for t.peek().typ != itemEOF {
279 - if t.peek().typ == itemLeftDelim {
280 - delim := t.next()
281 - if t.nextNonSpace().typ == itemDefine {
282 - newT := New("definition") // name will be updated once we know it.
283 - newT.text = t.text
284 - newT.ParseName = t.ParseName
285 - newT.startParse(t.funcs, t.lex)
286 - newT.parseDefinition(treeSet)
287 - continue
288 - }
289 - t.backup2(delim)
290 - }
291 - n := t.textOrAction()
292 - if n.Type() == nodeEnd {
293 - t.errorf("unexpected %s", n)
294 - }
295 - t.Root.append(n)
296 - }
297 - return nil
298 -}
299 -
300 -// parseDefinition parses a {{define}} ... {{end}} template definition and
301 -// installs the definition in the treeSet map. The "define" keyword has already
302 -// been scanned.
303 -func (t *Tree) parseDefinition(treeSet map[string]*Tree) {
304 - const context = "define clause"
305 - name := t.expectOneOf(itemString, itemRawString, context)
306 - var err error
307 - t.Name, err = strconv.Unquote(name.val)
308 - if err != nil {
309 - t.error(err)
310 - }
311 - t.expect(itemRightDelim, context)
312 - var end Node
313 - t.Root, end = t.itemList()
314 - if end.Type() != nodeEnd {
315 - t.errorf("unexpected %s in %s", end, context)
316 - }
317 - t.add(treeSet)
318 - t.stopParse()
319 -}
320 -
321 -// itemList:
322 -// textOrAction*
323 -// Terminates at {{end}} or {{else}}, returned separately.
324 -func (t *Tree) itemList() (list *ListNode, next Node) {
325 - list = t.newList(t.peekNonSpace().pos)
326 - for t.peekNonSpace().typ != itemEOF {
327 - n := t.textOrAction()
328 - switch n.Type() {
329 - case nodeEnd, nodeElse:
330 - return list, n
331 - }
332 - list.append(n)
333 - }
334 - t.errorf("unexpected EOF")
335 - return
336 -}
337 -
338 -// textOrAction:
339 -// text | action
340 -func (t *Tree) textOrAction() Node {
341 - switch token := t.nextNonSpace(); token.typ {
342 - case itemElideNewline:
343 - return t.elideNewline()
344 - case itemText:
345 - return t.newText(token.pos, token.val)
346 - case itemLeftDelim:
347 - return t.action()
348 - default:
349 - t.unexpected(token, "input")
350 - }
351 - return nil
352 -}
353 -
354 -// elideNewline:
355 -// Remove newlines trailing rightDelim if \\ is present.
356 -func (t *Tree) elideNewline() Node {
357 - token := t.peek()
358 - if token.typ != itemText {
359 - t.unexpected(token, "input")
360 - return nil
361 - }
362 -
363 - t.next()
364 - stripped := strings.TrimLeft(token.val, "\n\r")
365 - diff := len(token.val) - len(stripped)
366 - if diff > 0 {
367 - // This is a bit nasty. We mutate the token in-place to remove
368 - // preceding newlines.
369 - token.pos += Pos(diff)
370 - token.val = stripped
371 - }
372 - return t.newText(token.pos, token.val)
373 -}
374 -
375 -// Action:
376 -// control
377 -// command ("|" command)*
378 -// Left delim is past. Now get actions.
379 -// First word could be a keyword such as range.
380 -func (t *Tree) action() (n Node) {
381 - switch token := t.nextNonSpace(); token.typ {
382 - case itemElse:
383 - return t.elseControl()
384 - case itemEnd:
385 - return t.endControl()
386 - case itemIf:
387 - return t.ifControl()
388 - case itemRange:
389 - return t.rangeControl()
390 - case itemTemplate:
391 - return t.templateControl()
392 - case itemWith:
393 - return t.withControl()
394 - }
395 - t.backup()
396 - // Do not pop variables; they persist until "end".
397 - return t.newAction(t.peek().pos, t.lex.lineNumber(), t.pipeline("command"))
398 -}
399 -
400 -// Pipeline:
401 -// declarations? command ('|' command)*
402 -func (t *Tree) pipeline(context string) (pipe *PipeNode) {
403 - var decl []*VariableNode
404 - pos := t.peekNonSpace().pos
405 - // Are there declarations?
406 - for {
407 - if v := t.peekNonSpace(); v.typ == itemVariable {
408 - t.next()
409 - // Since space is a token, we need 3-token look-ahead here in the worst case:
410 - // in "$x foo" we need to read "foo" (as opposed to ":=") to know that $x is an
411 - // argument variable rather than a declaration. So remember the token
412 - // adjacent to the variable so we can push it back if necessary.
413 - tokenAfterVariable := t.peek()
414 - if next := t.peekNonSpace(); next.typ == itemColonEquals || (next.typ == itemChar && next.val == ",") {
415 - t.nextNonSpace()
416 - variable := t.newVariable(v.pos, v.val)
417 - decl = append(decl, variable)
418 - t.vars = append(t.vars, v.val)
419 - if next.typ == itemChar && next.val == "," {
420 - if context == "range" && len(decl) < 2 {
421 - continue
422 - }
423 - t.errorf("too many declarations in %s", context)
424 - }
425 - } else if tokenAfterVariable.typ == itemSpace {
426 - t.backup3(v, tokenAfterVariable)
427 - } else {
428 - t.backup2(v)
429 - }
430 - }
431 - break
432 - }
433 - pipe = t.newPipeline(pos, t.lex.lineNumber(), decl)
434 - for {
435 - switch token := t.nextNonSpace(); token.typ {
436 - case itemRightDelim, itemRightParen:
437 - if len(pipe.Cmds) == 0 {
438 - t.errorf("missing value for %s", context)
439 - }
440 - if token.typ == itemRightParen {
441 - t.backup()
442 - }
443 - return
444 - case itemBool, itemCharConstant, itemComplex, itemDot, itemField, itemIdentifier,
445 - itemNumber, itemNil, itemRawString, itemString, itemVariable, itemLeftParen:
446 - t.backup()
447 - pipe.append(t.command())
448 - default:
449 - t.unexpected(token, context)
450 - }
451 - }
452 -}
453 -
454 -func (t *Tree) parseControl(allowElseIf bool, context string) (pos Pos, line int, pipe *PipeNode, list, elseList *ListNode) {
455 - defer t.popVars(len(t.vars))
456 - line = t.lex.lineNumber()
457 - pipe = t.pipeline(context)
458 - var next Node
459 - list, next = t.itemList()
460 - switch next.Type() {
461 - case nodeEnd: //done
462 - case nodeElse:
463 - if allowElseIf {
464 - // Special case for "else if". If the "else" is followed immediately by an "if",
465 - // the elseControl will have left the "if" token pending. Treat
466 - // {{if a}}_{{else if b}}_{{end}}
467 - // as
468 - // {{if a}}_{{else}}{{if b}}_{{end}}{{end}}.
469 - // To do this, parse the if as usual and stop at it {{end}}; the subsequent{{end}}
470 - // is assumed. This technique works even for long if-else-if chains.
471 - // TODO: Should we allow else-if in with and range?
472 - if t.peek().typ == itemIf {
473 - t.next() // Consume the "if" token.
474 - elseList = t.newList(next.Position())
475 - elseList.append(t.ifControl())
476 - // Do not consume the next item - only one {{end}} required.
477 - break
478 - }
479 - }
480 - elseList, next = t.itemList()
481 - if next.Type() != nodeEnd {
482 - t.errorf("expected end; found %s", next)
483 - }
484 - }
485 - return pipe.Position(), line, pipe, list, elseList
486 -}
487 -
488 -// If:
489 -// {{if pipeline}} itemList {{end}}
490 -// {{if pipeline}} itemList {{else}} itemList {{end}}
491 -// If keyword is past.
492 -func (t *Tree) ifControl() Node {
493 - return t.newIf(t.parseControl(true, "if"))
494 -}
495 -
496 -// Range:
497 -// {{range pipeline}} itemList {{end}}
498 -// {{range pipeline}} itemList {{else}} itemList {{end}}
499 -// Range keyword is past.
500 -func (t *Tree) rangeControl() Node {
501 - return t.newRange(t.parseControl(false, "range"))
502 -}
503 -
504 -// With:
505 -// {{with pipeline}} itemList {{end}}
506 -// {{with pipeline}} itemList {{else}} itemList {{end}}
507 -// If keyword is past.
508 -func (t *Tree) withControl() Node {
509 - return t.newWith(t.parseControl(false, "with"))
510 -}
511 -
512 -// End:
513 -// {{end}}
514 -// End keyword is past.
515 -func (t *Tree) endControl() Node {
516 - return t.newEnd(t.expect(itemRightDelim, "end").pos)
517 -}
518 -
519 -// Else:
520 -// {{else}}
521 -// Else keyword is past.
522 -func (t *Tree) elseControl() Node {
523 - // Special case for "else if".
524 - peek := t.peekNonSpace()
525 - if peek.typ == itemIf {
526 - // We see "{{else if ... " but in effect rewrite it to {{else}}{{if ... ".
527 - return t.newElse(peek.pos, t.lex.lineNumber())
528 - }
529 - return t.newElse(t.expect(itemRightDelim, "else").pos, t.lex.lineNumber())
530 -}
531 -
532 -// Template:
533 -// {{template stringValue pipeline}}
534 -// Template keyword is past. The name must be something that can evaluate
535 -// to a string.
536 -func (t *Tree) templateControl() Node {
537 - var name string
538 - token := t.nextNonSpace()
539 - switch token.typ {
540 - case itemString, itemRawString:
541 - s, err := strconv.Unquote(token.val)
542 - if err != nil {
543 - t.error(err)
544 - }
545 - name = s
546 - default:
547 - t.unexpected(token, "template invocation")
548 - }
549 - var pipe *PipeNode
550 - if t.nextNonSpace().typ != itemRightDelim {
551 - t.backup()
552 - // Do not pop variables; they persist until "end".
553 - pipe = t.pipeline("template")
554 - }
555 - return t.newTemplate(token.pos, t.lex.lineNumber(), name, pipe)
556 -}
557 -
558 -// command:
559 -// operand (space operand)*
560 -// space-separated arguments up to a pipeline character or right delimiter.
561 -// we consume the pipe character but leave the right delim to terminate the action.
562 -func (t *Tree) command() *CommandNode {
563 - cmd := t.newCommand(t.peekNonSpace().pos)
564 - for {
565 - t.peekNonSpace() // skip leading spaces.
566 - operand := t.operand()
567 - if operand != nil {
568 - cmd.append(operand)
569 - }
570 - switch token := t.next(); token.typ {
571 - case itemSpace:
572 - continue
573 - case itemError:
574 - t.errorf("%s", token.val)
575 - case itemRightDelim, itemRightParen:
576 - t.backup()
577 - case itemPipe:
578 - default:
579 - t.errorf("unexpected %s in operand; missing space?", token)
580 - }
581 - break
582 - }
583 - if len(cmd.Args) == 0 {
584 - t.errorf("empty command")
585 - }
586 - return cmd
587 -}
588 -
589 -// operand:
590 -// term .Field*
591 -// An operand is a space-separated component of a command,
592 -// a term possibly followed by field accesses.
593 -// A nil return means the next item is not an operand.
594 -func (t *Tree) operand() Node {
595 - node := t.term()
596 - if node == nil {
597 - return nil
598 - }
599 - if t.peek().typ == itemField {
600 - chain := t.newChain(t.peek().pos, node)
601 - for t.peek().typ == itemField {
602 - chain.Add(t.next().val)
603 - }
604 - // Compatibility with original API: If the term is of type NodeField
605 - // or NodeVariable, just put more fields on the original.
606 - // Otherwise, keep the Chain node.
607 - // TODO: Switch to Chains always when we can.
608 - switch node.Type() {
609 - case NodeField:
610 - node = t.newField(chain.Position(), chain.String())
611 - case NodeVariable:
612 - node = t.newVariable(chain.Position(), chain.String())
613 - default:
614 - node = chain
615 - }
616 - }
617 - return node
618 -}
619 -
620 -// term:
621 -// literal (number, string, nil, boolean)
622 -// function (identifier)
623 -// .
624 -// .Field
625 -// $
626 -// '(' pipeline ')'
627 -// A term is a simple "expression".
628 -// A nil return means the next item is not a term.
629 -func (t *Tree) term() Node {
630 - switch token := t.nextNonSpace(); token.typ {
631 - case itemError:
632 - t.errorf("%s", token.val)
633 - case itemIdentifier:
634 - if !t.hasFunction(token.val) {
635 - t.errorf("function %q not defined", token.val)
636 - }
637 - return NewIdentifier(token.val).SetTree(t).SetPos(token.pos)
638 - case itemDot:
639 - return t.newDot(token.pos)
640 - case itemNil:
641 - return t.newNil(token.pos)
642 - case itemVariable:
643 - return t.useVar(token.pos, token.val)
644 - case itemField:
645 - return t.newField(token.pos, token.val)
646 - case itemBool:
647 - return t.newBool(token.pos, token.val == "true")
648 - case itemCharConstant, itemComplex, itemNumber:
649 - number, err := t.newNumber(token.pos, token.val, token.typ)
650 - if err != nil {
651 - t.error(err)
652 - }
653 - return number
654 - case itemLeftParen:
655 - pipe := t.pipeline("parenthesized pipeline")
656 - if token := t.next(); token.typ != itemRightParen {
657 - t.errorf("unclosed right paren: unexpected %s", token)
658 - }
659 - return pipe
660 - case itemString, itemRawString:
661 - s, err := strconv.Unquote(token.val)
662 - if err != nil {
663 - t.error(err)
664 - }
665 - return t.newString(token.pos, token.val, s)
666 - }
667 - t.backup()
668 - return nil
669 -}
670 -
671 -// hasFunction reports if a function name exists in the Tree's maps.
672 -func (t *Tree) hasFunction(name string) bool {
673 - for _, funcMap := range t.funcs {
674 - if funcMap == nil {
675 - continue
676 - }
677 - if funcMap[name] != nil {
678 - return true
679 - }
680 - }
681 - return false
682 -}
683 -
684 -// popVars trims the variable list to the specified length
685 -func (t *Tree) popVars(n int) {
686 - t.vars = t.vars[:n]
687 -}
688 -
689 -// useVar returns a node for a variable reference. It errors if the
690 -// variable is not defined.
691 -func (t *Tree) useVar(pos Pos, name string) Node {
692 - v := t.newVariable(pos, name)
693 - for _, varName := range t.vars {
694 - if varName == v.Ident[0] {
695 - return v
696 - }
697 - }
698 - t.errorf("undefined variable %q", v.Ident[0])
699 - return nil
700 -}
Godeps/_workspace/src/github.com/alecthomas/template/parse/parse_test.go deleted
-426
@@ -1,426 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package parse
6 -
7 -import (
8 - "flag"
9 - "fmt"
10 - "strings"
11 - "testing"
12 -)
13 -
14 -var debug = flag.Bool("debug", false, "show the errors produced by the main tests")
15 -
16 -type numberTest struct {
17 - text string
18 - isInt bool
19 - isUint bool
20 - isFloat bool
21 - isComplex bool
22 - int64
23 - uint64
24 - float64
25 - complex128
26 -}
27 -
28 -var numberTests = []numberTest{
29 - // basics
30 - {"0", true, true, true, false, 0, 0, 0, 0},
31 - {"-0", true, true, true, false, 0, 0, 0, 0}, // check that -0 is a uint.
32 - {"73", true, true, true, false, 73, 73, 73, 0},
33 - {"073", true, true, true, false, 073, 073, 073, 0},
34 - {"0x73", true, true, true, false, 0x73, 0x73, 0x73, 0},
35 - {"-73", true, false, true, false, -73, 0, -73, 0},
36 - {"+73", true, false, true, false, 73, 0, 73, 0},
37 - {"100", true, true, true, false, 100, 100, 100, 0},
38 - {"1e9", true, true, true, false, 1e9, 1e9, 1e9, 0},
39 - {"-1e9", true, false, true, false, -1e9, 0, -1e9, 0},
40 - {"-1.2", false, false, true, false, 0, 0, -1.2, 0},
41 - {"1e19", false, true, true, false, 0, 1e19, 1e19, 0},
42 - {"-1e19", false, false, true, false, 0, 0, -1e19, 0},
43 - {"4i", false, false, false, true, 0, 0, 0, 4i},
44 - {"-1.2+4.2i", false, false, false, true, 0, 0, 0, -1.2 + 4.2i},
45 - {"073i", false, false, false, true, 0, 0, 0, 73i}, // not octal!
46 - // complex with 0 imaginary are float (and maybe integer)
47 - {"0i", true, true, true, true, 0, 0, 0, 0},
48 - {"-1.2+0i", false, false, true, true, 0, 0, -1.2, -1.2},
49 - {"-12+0i", true, false, true, true, -12, 0, -12, -12},
50 - {"13+0i", true, true, true, true, 13, 13, 13, 13},
51 - // funny bases
52 - {"0123", true, true, true, false, 0123, 0123, 0123, 0},
53 - {"-0x0", true, true, true, false, 0, 0, 0, 0},
54 - {"0xdeadbeef", true, true, true, false, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0},
55 - // character constants
56 - {`'a'`, true, true, true, false, 'a', 'a', 'a', 0},
57 - {`'\n'`, true, true, true, false, '\n', '\n', '\n', 0},
58 - {`'\\'`, true, true, true, false, '\\', '\\', '\\', 0},
59 - {`'\''`, true, true, true, false, '\'', '\'', '\'', 0},
60 - {`'\xFF'`, true, true, true, false, 0xFF, 0xFF, 0xFF, 0},
61 - {`'パ'`, true, true, true, false, 0x30d1, 0x30d1, 0x30d1, 0},
62 - {`'\u30d1'`, true, true, true, false, 0x30d1, 0x30d1, 0x30d1, 0},
63 - {`'\U000030d1'`, true, true, true, false, 0x30d1, 0x30d1, 0x30d1, 0},
64 - // some broken syntax
65 - {text: "+-2"},
66 - {text: "0x123."},
67 - {text: "1e."},
68 - {text: "0xi."},
69 - {text: "1+2."},
70 - {text: "'x"},
71 - {text: "'xx'"},
72 - // Issue 8622 - 0xe parsed as floating point. Very embarrassing.
73 - {"0xef", true, true, true, false, 0xef, 0xef, 0xef, 0},
74 -}
75 -
76 -func TestNumberParse(t *testing.T) {
77 - for _, test := range numberTests {
78 - // If fmt.Sscan thinks it's complex, it's complex. We can't trust the output
79 - // because imaginary comes out as a number.
80 - var c complex128
81 - typ := itemNumber
82 - var tree *Tree
83 - if test.text[0] == '\'' {
84 - typ = itemCharConstant
85 - } else {
86 - _, err := fmt.Sscan(test.text, &c)
87 - if err == nil {
88 - typ = itemComplex
89 - }
90 - }
91 - n, err := tree.newNumber(0, test.text, typ)
92 - ok := test.isInt || test.isUint || test.isFloat || test.isComplex
93 - if ok && err != nil {
94 - t.Errorf("unexpected error for %q: %s", test.text, err)
95 - continue
96 - }
97 - if !ok && err == nil {
98 - t.Errorf("expected error for %q", test.text)
99 - continue
100 - }
101 - if !ok {
102 - if *debug {
103 - fmt.Printf("%s\n\t%s\n", test.text, err)
104 - }
105 - continue
106 - }
107 - if n.IsComplex != test.isComplex {
108 - t.Errorf("complex incorrect for %q; should be %t", test.text, test.isComplex)
109 - }
110 - if test.isInt {
111 - if !n.IsInt {
112 - t.Errorf("expected integer for %q", test.text)
113 - }
114 - if n.Int64 != test.int64 {
115 - t.Errorf("int64 for %q should be %d Is %d", test.text, test.int64, n.Int64)
116 - }
117 - } else if n.IsInt {
118 - t.Errorf("did not expect integer for %q", test.text)
119 - }
120 - if test.isUint {
121 - if !n.IsUint {
122 - t.Errorf("expected unsigned integer for %q", test.text)
123 - }
124 - if n.Uint64 != test.uint64 {
125 - t.Errorf("uint64 for %q should be %d Is %d", test.text, test.uint64, n.Uint64)
126 - }
127 - } else if n.IsUint {
128 - t.Errorf("did not expect unsigned integer for %q", test.text)
129 - }
130 - if test.isFloat {
131 - if !n.IsFloat {
132 - t.Errorf("expected float for %q", test.text)
133 - }
134 - if n.Float64 != test.float64 {
135 - t.Errorf("float64 for %q should be %g Is %g", test.text, test.float64, n.Float64)
136 - }
137 - } else if n.IsFloat {
138 - t.Errorf("did not expect float for %q", test.text)
139 - }
140 - if test.isComplex {
141 - if !n.IsComplex {
142 - t.Errorf("expected complex for %q", test.text)
143 - }
144 - if n.Complex128 != test.complex128 {
145 - t.Errorf("complex128 for %q should be %g Is %g", test.text, test.complex128, n.Complex128)
146 - }
147 - } else if n.IsComplex {
148 - t.Errorf("did not expect complex for %q", test.text)
149 - }
150 - }
151 -}
152 -
153 -type parseTest struct {
154 - name string
155 - input string
156 - ok bool
157 - result string // what the user would see in an error message.
158 -}
159 -
160 -const (
161 - noError = true
162 - hasError = false
163 -)
164 -
165 -var parseTests = []parseTest{
166 - {"empty", "", noError,
167 - ``},
168 - {"comment", "{{/*\n\n\n*/}}", noError,
169 - ``},
170 - {"spaces", " \t\n", noError,
171 - `" \t\n"`},
172 - {"text", "some text", noError,
173 - `"some text"`},
174 - {"emptyAction", "{{}}", hasError,
175 - `{{}}`},
176 - {"field", "{{.X}}", noError,
177 - `{{.X}}`},
178 - {"simple command", "{{printf}}", noError,
179 - `{{printf}}`},
180 - {"$ invocation", "{{$}}", noError,
181 - "{{$}}"},
182 - {"variable invocation", "{{with $x := 3}}{{$x 23}}{{end}}", noError,
183 - "{{with $x := 3}}{{$x 23}}{{end}}"},
184 - {"variable with fields", "{{$.I}}", noError,
185 - "{{$.I}}"},
186 - {"multi-word command", "{{printf `%d` 23}}", noError,
187 - "{{printf `%d` 23}}"},
188 - {"pipeline", "{{.X|.Y}}", noError,
189 - `{{.X | .Y}}`},
190 - {"pipeline with decl", "{{$x := .X|.Y}}", noError,
191 - `{{$x := .X | .Y}}`},
192 - {"nested pipeline", "{{.X (.Y .Z) (.A | .B .C) (.E)}}", noError,
193 - `{{.X (.Y .Z) (.A | .B .C) (.E)}}`},
194 - {"field applied to parentheses", "{{(.Y .Z).Field}}", noError,
195 - `{{(.Y .Z).Field}}`},
196 - {"simple if", "{{if .X}}hello{{end}}", noError,
197 - `{{if .X}}"hello"{{end}}`},
198 - {"if with else", "{{if .X}}true{{else}}false{{end}}", noError,
199 - `{{if .X}}"true"{{else}}"false"{{end}}`},
200 - {"if with else if", "{{if .X}}true{{else if .Y}}false{{end}}", noError,
201 - `{{if .X}}"true"{{else}}{{if .Y}}"false"{{end}}{{end}}`},
202 - {"if else chain", "+{{if .X}}X{{else if .Y}}Y{{else if .Z}}Z{{end}}+", noError,
203 - `"+"{{if .X}}"X"{{else}}{{if .Y}}"Y"{{else}}{{if .Z}}"Z"{{end}}{{end}}{{end}}"+"`},
204 - {"simple range", "{{range .X}}hello{{end}}", noError,
205 - `{{range .X}}"hello"{{end}}`},
206 - {"chained field range", "{{range .X.Y.Z}}hello{{end}}", noError,
207 - `{{range .X.Y.Z}}"hello"{{end}}`},
208 - {"nested range", "{{range .X}}hello{{range .Y}}goodbye{{end}}{{end}}", noError,
209 - `{{range .X}}"hello"{{range .Y}}"goodbye"{{end}}{{end}}`},
210 - {"range with else", "{{range .X}}true{{else}}false{{end}}", noError,
211 - `{{range .X}}"true"{{else}}"false"{{end}}`},
212 - {"range over pipeline", "{{range .X|.M}}true{{else}}false{{end}}", noError,
213 - `{{range .X | .M}}"true"{{else}}"false"{{end}}`},
214 - {"range []int", "{{range .SI}}{{.}}{{end}}", noError,
215 - `{{range .SI}}{{.}}{{end}}`},
216 - {"range 1 var", "{{range $x := .SI}}{{.}}{{end}}", noError,
217 - `{{range $x := .SI}}{{.}}{{end}}`},
218 - {"range 2 vars", "{{range $x, $y := .SI}}{{.}}{{end}}", noError,
219 - `{{range $x, $y := .SI}}{{.}}{{end}}`},
220 - {"constants", "{{range .SI 1 -3.2i true false 'a' nil}}{{end}}", noError,
221 - `{{range .SI 1 -3.2i true false 'a' nil}}{{end}}`},
222 - {"template", "{{template `x`}}", noError,
223 - `{{template "x"}}`},
224 - {"template with arg", "{{template `x` .Y}}", noError,
225 - `{{template "x" .Y}}`},
226 - {"with", "{{with .X}}hello{{end}}", noError,
227 - `{{with .X}}"hello"{{end}}`},
228 - {"with with else", "{{with .X}}hello{{else}}goodbye{{end}}", noError,
229 - `{{with .X}}"hello"{{else}}"goodbye"{{end}}`},
230 - {"elide newline", "{{true}}\\\n ", noError,
231 - `{{true}}" "`},
232 - // Errors.
233 - {"unclosed action", "hello{{range", hasError, ""},
234 - {"unmatched end", "{{end}}", hasError, ""},
235 - {"missing end", "hello{{range .x}}", hasError, ""},
236 - {"missing end after else", "hello{{range .x}}{{else}}", hasError, ""},
237 - {"undefined function", "hello{{undefined}}", hasError, ""},
238 - {"undefined variable", "{{$x}}", hasError, ""},
239 - {"variable undefined after end", "{{with $x := 4}}{{end}}{{$x}}", hasError, ""},
240 - {"variable undefined in template", "{{template $v}}", hasError, ""},
241 - {"declare with field", "{{with $x.Y := 4}}{{end}}", hasError, ""},
242 - {"template with field ref", "{{template .X}}", hasError, ""},
243 - {"template with var", "{{template $v}}", hasError, ""},
244 - {"invalid punctuation", "{{printf 3, 4}}", hasError, ""},
245 - {"multidecl outside range", "{{with $v, $u := 3}}{{end}}", hasError, ""},
246 - {"too many decls in range", "{{range $u, $v, $w := 3}}{{end}}", hasError, ""},
247 - {"dot applied to parentheses", "{{printf (printf .).}}", hasError, ""},
248 - {"adjacent args", "{{printf 3`x`}}", hasError, ""},
249 - {"adjacent args with .", "{{printf `x`.}}", hasError, ""},
250 - {"extra end after if", "{{if .X}}a{{else if .Y}}b{{end}}{{end}}", hasError, ""},
251 - {"invalid newline elision", "{{true}}\\{{true}}", hasError, ""},
252 - // Equals (and other chars) do not assignments make (yet).
253 - {"bug0a", "{{$x := 0}}{{$x}}", noError, "{{$x := 0}}{{$x}}"},
254 - {"bug0b", "{{$x = 1}}{{$x}}", hasError, ""},
255 - {"bug0c", "{{$x ! 2}}{{$x}}", hasError, ""},
256 - {"bug0d", "{{$x % 3}}{{$x}}", hasError, ""},
257 - // Check the parse fails for := rather than comma.
258 - {"bug0e", "{{range $x := $y := 3}}{{end}}", hasError, ""},
259 - // Another bug: variable read must ignore following punctuation.
260 - {"bug1a", "{{$x:=.}}{{$x!2}}", hasError, ""}, // ! is just illegal here.
261 - {"bug1b", "{{$x:=.}}{{$x+2}}", hasError, ""}, // $x+2 should not parse as ($x) (+2).
262 - {"bug1c", "{{$x:=.}}{{$x +2}}", noError, "{{$x := .}}{{$x +2}}"}, // It's OK with a space.
263 -}
264 -
265 -var builtins = map[string]interface{}{
266 - "printf": fmt.Sprintf,
267 -}
268 -
269 -func testParse(doCopy bool, t *testing.T) {
270 - textFormat = "%q"
271 - defer func() { textFormat = "%s" }()
272 - for _, test := range parseTests {
273 - tmpl, err := New(test.name).Parse(test.input, "", "", make(map[string]*Tree), builtins)
274 - switch {
275 - case err == nil && !test.ok:
276 - t.Errorf("%q: expected error; got none", test.name)
277 - continue
278 - case err != nil && test.ok:
279 - t.Errorf("%q: unexpected error: %v", test.name, err)
280 - continue
281 - case err != nil && !test.ok:
282 - // expected error, got one
283 - if *debug {
284 - fmt.Printf("%s: %s\n\t%s\n", test.name, test.input, err)
285 - }
286 - continue
287 - }
288 - var result string
289 - if doCopy {
290 - result = tmpl.Root.Copy().String()
291 - } else {
292 - result = tmpl.Root.String()
293 - }
294 - if result != test.result {
295 - t.Errorf("%s=(%q): got\n\t%v\nexpected\n\t%v", test.name, test.input, result, test.result)
296 - }
297 - }
298 -}
299 -
300 -func TestParse(t *testing.T) {
301 - testParse(false, t)
302 -}
303 -
304 -// Same as TestParse, but we copy the node first
305 -func TestParseCopy(t *testing.T) {
306 - testParse(true, t)
307 -}
308 -
309 -type isEmptyTest struct {
310 - name string
311 - input string
312 - empty bool
313 -}
314 -
315 -var isEmptyTests = []isEmptyTest{
316 - {"empty", ``, true},
317 - {"nonempty", `hello`, false},
318 - {"spaces only", " \t\n \t\n", true},
319 - {"definition", `{{define "x"}}something{{end}}`, true},
320 - {"definitions and space", "{{define `x`}}something{{end}}\n\n{{define `y`}}something{{end}}\n\n", true},
321 - {"definitions and text", "{{define `x`}}something{{end}}\nx\n{{define `y`}}something{{end}}\ny\n", false},
322 - {"definition and action", "{{define `x`}}something{{end}}{{if 3}}foo{{end}}", false},
323 -}
324 -
325 -func TestIsEmpty(t *testing.T) {
326 - if !IsEmptyTree(nil) {
327 - t.Errorf("nil tree is not empty")
328 - }
329 - for _, test := range isEmptyTests {
330 - tree, err := New("root").Parse(test.input, "", "", make(map[string]*Tree), nil)
331 - if err != nil {
332 - t.Errorf("%q: unexpected error: %v", test.name, err)
333 - continue
334 - }
335 - if empty := IsEmptyTree(tree.Root); empty != test.empty {
336 - t.Errorf("%q: expected %t got %t", test.name, test.empty, empty)
337 - }
338 - }
339 -}
340 -
341 -func TestErrorContextWithTreeCopy(t *testing.T) {
342 - tree, err := New("root").Parse("{{if true}}{{end}}", "", "", make(map[string]*Tree), nil)
343 - if err != nil {
344 - t.Fatalf("unexpected tree parse failure: %v", err)
345 - }
346 - treeCopy := tree.Copy()
347 - wantLocation, wantContext := tree.ErrorContext(tree.Root.Nodes[0])
348 - gotLocation, gotContext := treeCopy.ErrorContext(treeCopy.Root.Nodes[0])
349 - if wantLocation != gotLocation {
350 - t.Errorf("wrong error location want %q got %q", wantLocation, gotLocation)
351 - }
352 - if wantContext != gotContext {
353 - t.Errorf("wrong error location want %q got %q", wantContext, gotContext)
354 - }
355 -}
356 -
357 -// All failures, and the result is a string that must appear in the error message.
358 -var errorTests = []parseTest{
359 - // Check line numbers are accurate.
360 - {"unclosed1",
361 - "line1\n{{",
362 - hasError, `unclosed1:2: unexpected unclosed action in command`},
363 - {"unclosed2",
364 - "line1\n{{define `x`}}line2\n{{",
365 - hasError, `unclosed2:3: unexpected unclosed action in command`},
366 - // Specific errors.
367 - {"function",
368 - "{{foo}}",
369 - hasError, `function "foo" not defined`},
370 - {"comment",
371 - "{{/*}}",
372 - hasError, `unclosed comment`},
373 - {"lparen",
374 - "{{.X (1 2 3}}",
375 - hasError, `unclosed left paren`},
376 - {"rparen",
377 - "{{.X 1 2 3)}}",
378 - hasError, `unexpected ")"`},
379 - {"space",
380 - "{{`x`3}}",
381 - hasError, `missing space?`},
382 - {"idchar",
383 - "{{a#}}",
384 - hasError, `'#'`},
385 - {"charconst",
386 - "{{'a}}",
387 - hasError, `unterminated character constant`},
388 - {"stringconst",
389 - `{{"a}}`,
390 - hasError, `unterminated quoted string`},
391 - {"rawstringconst",
392 - "{{`a}}",
393 - hasError, `unterminated raw quoted string`},
394 - {"number",
395 - "{{0xi}}",
396 - hasError, `number syntax`},
397 - {"multidefine",
398 - "{{define `a`}}a{{end}}{{define `a`}}b{{end}}",
399 - hasError, `multiple definition of template`},
400 - {"eof",
401 - "{{range .X}}",
402 - hasError, `unexpected EOF`},
403 - {"variable",
404 - // Declare $x so it's defined, to avoid that error, and then check we don't parse a declaration.
405 - "{{$x := 23}}{{with $x.y := 3}}{{$x 23}}{{end}}",
406 - hasError, `unexpected ":="`},
407 - {"multidecl",
408 - "{{$a,$b,$c := 23}}",
409 - hasError, `too many declarations`},
410 - {"undefvar",
411 - "{{$a}}",
412 - hasError, `undefined variable`},
413 -}
414 -
415 -func TestErrors(t *testing.T) {
416 - for _, test := range errorTests {
417 - _, err := New(test.name).Parse(test.input, "", "", make(map[string]*Tree))
418 - if err == nil {
419 - t.Errorf("%q: expected error", test.name)
420 - continue
421 - }
422 - if !strings.Contains(err.Error(), test.result) {
423 - t.Errorf("%q: error %q does not contain %q", test.name, err, test.result)
424 - }
425 - }
426 -}
Godeps/_workspace/src/github.com/alecthomas/template/template.go deleted
-216
@@ -1,216 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package template
6 -
7 -import (
8 - "fmt"
9 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/alecthomas/template/parse" // common holds the information shared by related templates.
10 - "reflect"
11 -)
12 -
13 -type common struct {
14 - tmpl map[string]*Template
15 - // We use two maps, one for parsing and one for execution.
16 - // This separation makes the API cleaner since it doesn't
17 - // expose reflection to the client.
18 - parseFuncs FuncMap
19 - execFuncs map[string]reflect.Value
20 -}
21 -
22 -// Template is the representation of a parsed template. The *parse.Tree
23 -// field is exported only for use by html/template and should be treated
24 -// as unexported by all other clients.
25 -type Template struct {
26 - name string
27 - *parse.Tree
28 - *common
29 - leftDelim string
30 - rightDelim string
31 -}
32 -
33 -// New allocates a new template with the given name.
34 -func New(name string) *Template {
35 - return &Template{
36 - name: name,
37 - }
38 -}
39 -
40 -// Name returns the name of the template.
41 -func (t *Template) Name() string {
42 - return t.name
43 -}
44 -
45 -// New allocates a new template associated with the given one and with the same
46 -// delimiters. The association, which is transitive, allows one template to
47 -// invoke another with a {{template}} action.
48 -func (t *Template) New(name string) *Template {
49 - t.init()
50 - return &Template{
51 - name: name,
52 - common: t.common,
53 - leftDelim: t.leftDelim,
54 - rightDelim: t.rightDelim,
55 - }
56 -}
57 -
58 -func (t *Template) init() {
59 - if t.common == nil {
60 - t.common = new(common)
61 - t.tmpl = make(map[string]*Template)
62 - t.parseFuncs = make(FuncMap)
63 - t.execFuncs = make(map[string]reflect.Value)
64 - }
65 -}
66 -
67 -// Clone returns a duplicate of the template, including all associated
68 -// templates. The actual representation is not copied, but the name space of
69 -// associated templates is, so further calls to Parse in the copy will add
70 -// templates to the copy but not to the original. Clone can be used to prepare
71 -// common templates and use them with variant definitions for other templates
72 -// by adding the variants after the clone is made.
73 -func (t *Template) Clone() (*Template, error) {
74 - nt := t.copy(nil)
75 - nt.init()
76 - nt.tmpl[t.name] = nt
77 - for k, v := range t.tmpl {
78 - if k == t.name { // Already installed.
79 - continue
80 - }
81 - // The associated templates share nt's common structure.
82 - tmpl := v.copy(nt.common)
83 - nt.tmpl[k] = tmpl
84 - }
85 - for k, v := range t.parseFuncs {
86 - nt.parseFuncs[k] = v
87 - }
88 - for k, v := range t.execFuncs {
89 - nt.execFuncs[k] = v
90 - }
91 - return nt, nil
92 -}
93 -
94 -// copy returns a shallow copy of t, with common set to the argument.
95 -func (t *Template) copy(c *common) *Template {
96 - nt := New(t.name)
97 - nt.Tree = t.Tree
98 - nt.common = c
99 - nt.leftDelim = t.leftDelim
100 - nt.rightDelim = t.rightDelim
101 - return nt
102 -}
103 -
104 -// AddParseTree creates a new template with the name and parse tree
105 -// and associates it with t.
106 -func (t *Template) AddParseTree(name string, tree *parse.Tree) (*Template, error) {
107 - if t.common != nil && t.tmpl[name] != nil {
108 - return nil, fmt.Errorf("template: redefinition of template %q", name)
109 - }
110 - nt := t.New(name)
111 - nt.Tree = tree
112 - t.tmpl[name] = nt
113 - return nt, nil
114 -}
115 -
116 -// Templates returns a slice of the templates associated with t, including t
117 -// itself.
118 -func (t *Template) Templates() []*Template {
119 - if t.common == nil {
120 - return nil
121 - }
122 - // Return a slice so we don't expose the map.
123 - m := make([]*Template, 0, len(t.tmpl))
124 - for _, v := range t.tmpl {
125 - m = append(m, v)
126 - }
127 - return m
128 -}
129 -
130 -// Delims sets the action delimiters to the specified strings, to be used in
131 -// subsequent calls to Parse, ParseFiles, or ParseGlob. Nested template
132 -// definitions will inherit the settings. An empty delimiter stands for the
133 -// corresponding default: {{ or }}.
134 -// The return value is the template, so calls can be chained.
135 -func (t *Template) Delims(left, right string) *Template {
136 - t.leftDelim = left
137 - t.rightDelim = right
138 - return t
139 -}
140 -
141 -// Funcs adds the elements of the argument map to the template's function map.
142 -// It panics if a value in the map is not a function with appropriate return
143 -// type. However, it is legal to overwrite elements of the map. The return
144 -// value is the template, so calls can be chained.
145 -func (t *Template) Funcs(funcMap FuncMap) *Template {
146 - t.init()
147 - addValueFuncs(t.execFuncs, funcMap)
148 - addFuncs(t.parseFuncs, funcMap)
149 - return t
150 -}
151 -
152 -// Lookup returns the template with the given name that is associated with t,
153 -// or nil if there is no such template.
154 -func (t *Template) Lookup(name string) *Template {
155 - if t.common == nil {
156 - return nil
157 - }
158 - return t.tmpl[name]
159 -}
160 -
161 -// Parse parses a string into a template. Nested template definitions will be
162 -// associated with the top-level template t. Parse may be called multiple times
163 -// to parse definitions of templates to associate with t. It is an error if a
164 -// resulting template is non-empty (contains content other than template
165 -// definitions) and would replace a non-empty template with the same name.
166 -// (In multiple calls to Parse with the same receiver template, only one call
167 -// can contain text other than space, comments, and template definitions.)
168 -func (t *Template) Parse(text string) (*Template, error) {
169 - t.init()
170 - trees, err := parse.Parse(t.name, text, t.leftDelim, t.rightDelim, t.parseFuncs, builtins)
171 - if err != nil {
172 - return nil, err
173 - }
174 - // Add the newly parsed trees, including the one for t, into our common structure.
175 - for name, tree := range trees {
176 - // If the name we parsed is the name of this template, overwrite this template.
177 - // The associate method checks it's not a redefinition.
178 - tmpl := t
179 - if name != t.name {
180 - tmpl = t.New(name)
181 - }
182 - // Even if t == tmpl, we need to install it in the common.tmpl map.
183 - if replace, err := t.associate(tmpl, tree); err != nil {
184 - return nil, err
185 - } else if replace {
186 - tmpl.Tree = tree
187 - }
188 - tmpl.leftDelim = t.leftDelim
189 - tmpl.rightDelim = t.rightDelim
190 - }
191 - return t, nil
192 -}
193 -
194 -// associate installs the new template into the group of templates associated
195 -// with t. It is an error to reuse a name except to overwrite an empty
196 -// template. The two are already known to share the common structure.
197 -// The boolean return value reports wither to store this tree as t.Tree.
198 -func (t *Template) associate(new *Template, tree *parse.Tree) (bool, error) {
199 - if new.common != t.common {
200 - panic("internal error: associate not common")
201 - }
202 - name := new.name
203 - if old := t.tmpl[name]; old != nil {
204 - oldIsEmpty := parse.IsEmptyTree(old.Root)
205 - newIsEmpty := parse.IsEmptyTree(tree.Root)
206 - if newIsEmpty {
207 - // Whether old is empty or not, new is empty; no reason to replace old.
208 - return false, nil
209 - }
210 - if !oldIsEmpty {
211 - return false, fmt.Errorf("template: redefinition of template %q", name)
212 - }
213 - }
214 - t.tmpl[name] = new
215 - return true, nil
216 -}
Godeps/_workspace/src/github.com/alecthomas/template/testdata/file1.tmpl deleted
-2
@@ -1,2 +0,0 @@
1 -{{define "x"}}TEXT{{end}}
2 -{{define "dotV"}}{{.V}}{{end}}
Godeps/_workspace/src/github.com/alecthomas/template/testdata/file2.tmpl deleted
-2
@@ -1,2 +0,0 @@
1 -{{define "dot"}}{{.}}{{end}}
2 -{{define "nested"}}{{template "dot" .}}{{end}}
Godeps/_workspace/src/github.com/alecthomas/template/testdata/tmpl1.tmpl deleted
-3
@@ -1,3 +0,0 @@
1 -template1
2 -{{define "x"}}x{{end}}
3 -{{template "y"}}
Godeps/_workspace/src/github.com/alecthomas/template/testdata/tmpl2.tmpl deleted
-3
@@ -1,3 +0,0 @@
1 -template2
2 -{{define "y"}}y{{end}}
3 -{{template "x"}}
Godeps/_workspace/src/github.com/alecthomas/units/COPYING deleted
-19
@@ -1,19 +0,0 @@
1 -Copyright (C) 2014 Alec Thomas
2 -
3 -Permission is hereby granted, free of charge, to any person obtaining a copy of
4 -this software and associated documentation files (the "Software"), to deal in
5 -the Software without restriction, including without limitation the rights to
6 -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 -of the Software, and to permit persons to whom the Software is furnished to do
8 -so, subject to the following conditions:
9 -
10 -The above copyright notice and this permission notice shall be included in all
11 -copies or substantial portions of the Software.
12 -
13 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 -SOFTWARE.
Godeps/_workspace/src/github.com/alecthomas/units/README.md deleted
-11
@@ -1,11 +0,0 @@
1 -# Units - Helpful unit multipliers and functions for Go
2 -
3 -The goal of this package is to have functionality similar to the [time](http://golang.org/pkg/time/) package.
4 -
5 -It allows for code like this:
6 -
7 -```go
8 -n, err := ParseBase2Bytes("1KB")
9 -// n == 1024
10 -n = units.Mebibyte * 512
11 -```
Godeps/_workspace/src/github.com/alecthomas/units/bytes.go deleted
-83
@@ -1,83 +0,0 @@
1 -package units
2 -
3 -// Base2Bytes is the old non-SI power-of-2 byte scale (1024 bytes in a kilobyte,
4 -// etc.).
5 -type Base2Bytes int64
6 -
7 -// Base-2 byte units.
8 -const (
9 - Kibibyte Base2Bytes = 1024
10 - KiB = Kibibyte
11 - Mebibyte = Kibibyte * 1024
12 - MiB = Mebibyte
13 - Gibibyte = Mebibyte * 1024
14 - GiB = Gibibyte
15 - Tebibyte = Gibibyte * 1024
16 - TiB = Tebibyte
17 - Pebibyte = Tebibyte * 1024
18 - PiB = Pebibyte
19 - Exbibyte = Pebibyte * 1024
20 - EiB = Exbibyte
21 -)
22 -
23 -var (
24 - bytesUnitMap = MakeUnitMap("iB", "B", 1024)
25 - oldBytesUnitMap = MakeUnitMap("B", "B", 1024)
26 -)
27 -
28 -// ParseBase2Bytes supports both iB and B in base-2 multipliers. That is, KB
29 -// and KiB are both 1024.
30 -func ParseBase2Bytes(s string) (Base2Bytes, error) {
31 - n, err := ParseUnit(s, bytesUnitMap)
32 - if err != nil {
33 - n, err = ParseUnit(s, oldBytesUnitMap)
34 - }
35 - return Base2Bytes(n), err
36 -}
37 -
38 -func (b Base2Bytes) String() string {
39 - return ToString(int64(b), 1024, "iB", "B")
40 -}
41 -
42 -var (
43 - metricBytesUnitMap = MakeUnitMap("B", "B", 1000)
44 -)
45 -
46 -// MetricBytes are SI byte units (1000 bytes in a kilobyte).
47 -type MetricBytes SI
48 -
49 -// SI base-10 byte units.
50 -const (
51 - Kilobyte MetricBytes = 1000
52 - KB = Kilobyte
53 - Megabyte = Kilobyte * 1000
54 - MB = Megabyte
55 - Gigabyte = Megabyte * 1000
56 - GB = Gigabyte
57 - Terabyte = Gigabyte * 1000
58 - TB = Terabyte
59 - Petabyte = Terabyte * 1000
60 - PB = Petabyte
61 - Exabyte = Petabyte * 1000
62 - EB = Exabyte
63 -)
64 -
65 -// ParseMetricBytes parses base-10 metric byte units. That is, KB is 1000 bytes.
66 -func ParseMetricBytes(s string) (MetricBytes, error) {
67 - n, err := ParseUnit(s, metricBytesUnitMap)
68 - return MetricBytes(n), err
69 -}
70 -
71 -func (m MetricBytes) String() string {
72 - return ToString(int64(m), 1000, "B", "B")
73 -}
74 -
75 -// ParseStrictBytes supports both iB and B suffixes for base 2 and metric,
76 -// respectively. That is, KiB represents 1024 and KB represents 1000.
77 -func ParseStrictBytes(s string) (int64, error) {
78 - n, err := ParseUnit(s, bytesUnitMap)
79 - if err != nil {
80 - n, err = ParseUnit(s, metricBytesUnitMap)
81 - }
82 - return int64(n), err
83 -}
Godeps/_workspace/src/github.com/alecthomas/units/bytes_test.go deleted
-49
@@ -1,49 +0,0 @@
1 -package units
2 -
3 -import (
4 - "testing"
5 -
6 - "gx/ipfs/QmZwjfAKWe7vWZ8f48u7AGA1xYfzR1iCD9A2XSCYFRBWot/testify/assert"
7 -)
8 -
9 -func TestBase2BytesString(t *testing.T) {
10 - assert.Equal(t, Base2Bytes(0).String(), "0B")
11 - assert.Equal(t, Base2Bytes(1025).String(), "1KiB1B")
12 - assert.Equal(t, Base2Bytes(1048577).String(), "1MiB1B")
13 -}
14 -
15 -func TestParseBase2Bytes(t *testing.T) {
16 - n, err := ParseBase2Bytes("0B")
17 - assert.NoError(t, err)
18 - assert.Equal(t, 0, n)
19 - n, err = ParseBase2Bytes("1KB")
20 - assert.NoError(t, err)
21 - assert.Equal(t, 1024, n)
22 - n, err = ParseBase2Bytes("1MB1KB25B")
23 - assert.NoError(t, err)
24 - assert.Equal(t, 1049625, n)
25 - n, err = ParseBase2Bytes("1.5MB")
26 - assert.NoError(t, err)
27 - assert.Equal(t, 1572864, n)
28 -}
29 -
30 -func TestMetricBytesString(t *testing.T) {
31 - assert.Equal(t, MetricBytes(0).String(), "0B")
32 - assert.Equal(t, MetricBytes(1001).String(), "1KB1B")
33 - assert.Equal(t, MetricBytes(1001025).String(), "1MB1KB25B")
34 -}
35 -
36 -func TestParseMetricBytes(t *testing.T) {
37 - n, err := ParseMetricBytes("0B")
38 - assert.NoError(t, err)
39 - assert.Equal(t, 0, n)
40 - n, err = ParseMetricBytes("1KB1B")
41 - assert.NoError(t, err)
42 - assert.Equal(t, 1001, n)
43 - n, err = ParseMetricBytes("1MB1KB25B")
44 - assert.NoError(t, err)
45 - assert.Equal(t, 1001025, n)
46 - n, err = ParseMetricBytes("1.5MB")
47 - assert.NoError(t, err)
48 - assert.Equal(t, 1500000, n)
49 -}
Godeps/_workspace/src/github.com/alecthomas/units/doc.go deleted
-13
@@ -1,13 +0,0 @@
1 -// Package units provides helpful unit multipliers and functions for Go.
2 -//
3 -// The goal of this package is to have functionality similar to the time [1] package.
4 -//
5 -//
6 -// [1] http://golang.org/pkg/time/
7 -//
8 -// It allows for code like this:
9 -//
10 -// n, err := ParseBase2Bytes("1KB")
11 -// // n == 1024
12 -// n = units.Mebibyte * 512
13 -package units
Godeps/_workspace/src/github.com/alecthomas/units/si.go deleted
-26
@@ -1,26 +0,0 @@
1 -package units
2 -
3 -// SI units.
4 -type SI int64
5 -
6 -// SI unit multiples.
7 -const (
8 - Kilo SI = 1000
9 - Mega = Kilo * 1000
10 - Giga = Mega * 1000
11 - Tera = Giga * 1000
12 - Peta = Tera * 1000
13 - Exa = Peta * 1000
14 -)
15 -
16 -func MakeUnitMap(suffix, shortSuffix string, scale int64) map[string]float64 {
17 - return map[string]float64{
18 - shortSuffix: 1,
19 - "K" + suffix: float64(scale),
20 - "M" + suffix: float64(scale * scale),
21 - "G" + suffix: float64(scale * scale * scale),
22 - "T" + suffix: float64(scale * scale * scale * scale),
23 - "P" + suffix: float64(scale * scale * scale * scale * scale),
24 - "E" + suffix: float64(scale * scale * scale * scale * scale * scale),
25 - }
26 -}
Godeps/_workspace/src/github.com/alecthomas/units/util.go deleted
-138
@@ -1,138 +0,0 @@
1 -package units
2 -
3 -import (
4 - "errors"
5 - "fmt"
6 - "strings"
7 -)
8 -
9 -var (
10 - siUnits = []string{"", "K", "M", "G", "T", "P", "E"}
11 -)
12 -
13 -func ToString(n int64, scale int64, suffix, baseSuffix string) string {
14 - mn := len(siUnits)
15 - out := make([]string, mn)
16 - for i, m := range siUnits {
17 - if n%scale != 0 || i == 0 && n == 0 {
18 - s := suffix
19 - if i == 0 {
20 - s = baseSuffix
21 - }
22 - out[mn-1-i] = fmt.Sprintf("%d%s%s", n%scale, m, s)
23 - }
24 - n /= scale
25 - if n == 0 {
26 - break
27 - }
28 - }
29 - return strings.Join(out, "")
30 -}
31 -
32 -// Below code ripped straight from http://golang.org/src/pkg/time/format.go?s=33392:33438#L1123
33 -var errLeadingInt = errors.New("units: bad [0-9]*") // never printed
34 -
35 -// leadingInt consumes the leading [0-9]* from s.
36 -func leadingInt(s string) (x int64, rem string, err error) {
37 - i := 0
38 - for ; i < len(s); i++ {
39 - c := s[i]
40 - if c < '0' || c > '9' {
41 - break
42 - }
43 - if x >= (1<<63-10)/10 {
44 - // overflow
45 - return 0, "", errLeadingInt
46 - }
47 - x = x*10 + int64(c) - '0'
48 - }
49 - return x, s[i:], nil
50 -}
51 -
52 -func ParseUnit(s string, unitMap map[string]float64) (int64, error) {
53 - // [-+]?([0-9]*(\.[0-9]*)?[a-z]+)+
54 - orig := s
55 - f := float64(0)
56 - neg := false
57 -
58 - // Consume [-+]?
59 - if s != "" {
60 - c := s[0]
61 - if c == '-' || c == '+' {
62 - neg = c == '-'
63 - s = s[1:]
64 - }
65 - }
66 - // Special case: if all that is left is "0", this is zero.
67 - if s == "0" {
68 - return 0, nil
69 - }
70 - if s == "" {
71 - return 0, errors.New("units: invalid " + orig)
72 - }
73 - for s != "" {
74 - g := float64(0) // this element of the sequence
75 -
76 - var x int64
77 - var err error
78 -
79 - // The next character must be [0-9.]
80 - if !(s[0] == '.' || ('0' <= s[0] && s[0] <= '9')) {
81 - return 0, errors.New("units: invalid " + orig)
82 - }
83 - // Consume [0-9]*
84 - pl := len(s)
85 - x, s, err = leadingInt(s)
86 - if err != nil {
87 - return 0, errors.New("units: invalid " + orig)
88 - }
89 - g = float64(x)
90 - pre := pl != len(s) // whether we consumed anything before a period
91 -
92 - // Consume (\.[0-9]*)?
93 - post := false
94 - if s != "" && s[0] == '.' {
95 - s = s[1:]
96 - pl := len(s)
97 - x, s, err = leadingInt(s)
98 - if err != nil {
99 - return 0, errors.New("units: invalid " + orig)
100 - }
101 - scale := 1.0
102 - for n := pl - len(s); n > 0; n-- {
103 - scale *= 10
104 - }
105 - g += float64(x) / scale
106 - post = pl != len(s)
107 - }
108 - if !pre && !post {
109 - // no digits (e.g. ".s" or "-.s")
110 - return 0, errors.New("units: invalid " + orig)
111 - }
112 -
113 - // Consume unit.
114 - i := 0
115 - for ; i < len(s); i++ {
116 - c := s[i]
117 - if c == '.' || ('0' <= c && c <= '9') {
118 - break
119 - }
120 - }
121 - u := s[:i]
122 - s = s[i:]
123 - unit, ok := unitMap[u]
124 - if !ok {
125 - return 0, errors.New("units: unknown unit " + u + " in " + orig)
126 - }
127 -
128 - f += g * unit
129 - }
130 -
131 - if neg {
132 - f = -f
133 - }
134 - if f < float64(-1<<63) || f > float64(1<<63-1) {
135 - return 0, errors.New("units: overflow parsing unit")
136 - }
137 - return int64(f), nil
138 -}
Godeps/_workspace/src/github.com/bradfitz/iter/.gitignore deleted
-1
@@ -1 +0,0 @@
1 -*~
Godeps/_workspace/src/github.com/bradfitz/iter/README.txt deleted
-1
@@ -1 +0,0 @@
1 -See http://godoc.org/github.com/bradfitz/iter
Godeps/_workspace/src/github.com/bradfitz/iter/iter.go deleted
-17
@@ -1,17 +0,0 @@
1 -// Package iter provides a syntantically different way to iterate over integers. That's it.
2 -package iter
3 -
4 -// N returns a slice of n 0-sized elements, suitable for ranging over.
5 -//
6 -// For example:
7 -//
8 -// for i := range iter.N(10) {
9 -// fmt.Println(i)
10 -// }
11 -//
12 -// ... will print 0 to 9, inclusive.
13 -//
14 -// It does not cause any allocations.
15 -func N(n int) []struct{} {
16 - return make([]struct{}, n)
17 -}
Godeps/_workspace/src/github.com/bradfitz/iter/iter_test.go deleted
-29
@@ -1,29 +0,0 @@
1 -package iter_test
2 -
3 -import (
4 - "fmt"
5 - "testing"
6 -
7 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/bradfitz/iter"
8 -)
9 -
10 -func ExampleN() {
11 - for i := range iter.N(4) {
12 - fmt.Println(i)
13 - }
14 - // Output:
15 - // 0
16 - // 1
17 - // 2
18 - // 3
19 -}
20 -
21 -func TestAllocs(t *testing.T) {
22 - var x []struct{}
23 - allocs := testing.AllocsPerRun(500, func() {
24 - x = iter.N(1e9)
25 - })
26 - if allocs > 0.1 {
27 - t.Errorf("allocs = %v", allocs)
28 - }
29 -}
Godeps/_workspace/src/github.com/braintree/manners/LICENSE deleted
-19
@@ -1,19 +0,0 @@
1 -Copyright (c) 2014 Braintree, a division of PayPal, Inc.
2 -
3 -Permission is hereby granted, free of charge, to any person obtaining a copy
4 -of this software and associated documentation files (the "Software"), to deal
5 -in the Software without restriction, including without limitation the rights
6 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 -copies of the Software, and to permit persons to whom the Software is
8 -furnished to do so, subject to the following conditions:
9 -
10 -The above copyright notice and this permission notice shall be included in
11 -all copies or substantial portions of the Software.
12 -
13 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 -THE SOFTWARE.
Godeps/_workspace/src/github.com/braintree/manners/README.md deleted
-33
@@ -1,33 +0,0 @@
1 -# Manners
2 -
3 -A *polite* webserver for Go.
4 -
5 -Manners allows you to shut your Go webserver down gracefully, without dropping any requests. It can act as a drop-in replacement for the standard library's http.ListenAndServe function:
6 -
7 -```go
8 -func main() {
9 - handler := MyHTTPHandler()
10 - server := manners.NewServer()
11 - server.ListenAndServe(":7000", handler)
12 -}
13 -```
14 -
15 -Then, when you want to shut the server down:
16 -
17 -```go
18 -server.Shutdown <- true
19 -```
20 -
21 -(Note that this does not block until all the requests are finished. Rather, the call to server.ListenAndServe will stop blocking when all the requests are finished.)
22 -
23 -Manners ensures that all requests are served by incrementing a WaitGroup when a request comes in and decrementing it when the request finishes.
24 -
25 -If your request handler spawns Goroutines that are not guaranteed to finish with the request, you can ensure they are also completed with the `StartRoutine` and `FinishRoutine` functions on the server.
26 -
27 -### Compatability
28 -
29 -Manners 0.3.0 and above uses standard library functionality introduced in Go 1.3.
30 -
31 -### Installation
32 -
33 -`go get github.com/braintree/manners`
Godeps/_workspace/src/github.com/braintree/manners/helper_test.go deleted
-34
@@ -1,34 +0,0 @@
1 -package manners
2 -
3 -import (
4 - "net/http"
5 - "time"
6 -)
7 -
8 -// A response handler that blocks until it receives a signal; simulates an
9 -// arbitrarily long web request. The "ready" channel is to prevent a race
10 -// condition in the test where the test moves on before the server is ready
11 -// to handle the request.
12 -func newBlockingHandler(ready, done chan bool) *blockingHandler {
13 - return &blockingHandler{ready, done}
14 -}
15 -
16 -type blockingHandler struct {
17 - ready chan bool
18 - done chan bool
19 -}
20 -
21 -func (h *blockingHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
22 - h.ready <- true
23 - time.Sleep(1e2)
24 - h.done <- true
25 -}
26 -
27 -// A response handler that does nothing.
28 -func newTestHandler() testHandler {
29 - return testHandler{}
30 -}
31 -
32 -type testHandler struct{}
33 -
34 -func (h testHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {}
Godeps/_workspace/src/github.com/braintree/manners/listener.go deleted
-49
@@ -1,49 +0,0 @@
1 -package manners
2 -
3 -import (
4 - "net"
5 - "sync"
6 -)
7 -
8 -func NewListener(l net.Listener, s *GracefulServer) *GracefulListener {
9 - return &GracefulListener{l, true, s, sync.RWMutex{}}
10 -}
11 -
12 -// A GracefulListener differs from a standard net.Listener in one way: if
13 -// Accept() is called after it is gracefully closed, it returns a
14 -// listenerAlreadyClosed error. The GracefulServer will ignore this
15 -// error.
16 -type GracefulListener struct {
17 - net.Listener
18 - open bool
19 - server *GracefulServer
20 - rw sync.RWMutex
21 -}
22 -
23 -func (l *GracefulListener) Accept() (net.Conn, error) {
24 - conn, err := l.Listener.Accept()
25 - if err != nil {
26 - l.rw.RLock()
27 - defer l.rw.RUnlock()
28 - if !l.open {
29 - err = listenerAlreadyClosed{err}
30 - }
31 - return nil, err
32 - }
33 - return conn, nil
34 -}
35 -
36 -func (l *GracefulListener) Close() error {
37 - l.rw.Lock()
38 - defer l.rw.Unlock()
39 - if !l.open {
40 - return nil
41 - }
42 - l.open = false
43 - err := l.Listener.Close()
44 - return err
45 -}
46 -
47 -type listenerAlreadyClosed struct {
48 - error
49 -}
Godeps/_workspace/src/github.com/braintree/manners/server.go deleted
-83
@@ -1,83 +0,0 @@
1 -package manners
2 -
3 -import (
4 - "net"
5 - "net/http"
6 - "sync"
7 -)
8 -
9 -// Creates a new GracefulServer. The server will begin shutting down when
10 -// a value is passed to the Shutdown channel.
11 -func NewServer() *GracefulServer {
12 - return &GracefulServer{
13 - Shutdown: make(chan bool),
14 - }
15 -}
16 -
17 -// A GracefulServer maintains a WaitGroup that counts how many in-flight
18 -// requests the server is handling. When it receives a shutdown signal,
19 -// it stops accepting new requests but does not actually shut down until
20 -// all in-flight requests terminate.
21 -type GracefulServer struct {
22 - Shutdown chan bool
23 - wg sync.WaitGroup
24 - shutdownHandler func()
25 - InnerServer http.Server
26 -}
27 -
28 -// A helper function that emulates the functionality of http.ListenAndServe.
29 -func (s *GracefulServer) ListenAndServe(addr string, handler http.Handler) error {
30 - oldListener, err := net.Listen("tcp", addr)
31 - if err != nil {
32 - return err
33 - }
34 -
35 - listener := NewListener(oldListener, s)
36 - err = s.Serve(listener, handler)
37 - return err
38 -}
39 -
40 -// Similar to http.Serve. The listener passed must wrap a GracefulListener.
41 -func (s *GracefulServer) Serve(listener net.Listener, handler http.Handler) error {
42 - s.shutdownHandler = func() { listener.Close() }
43 - s.listenForShutdown()
44 - s.InnerServer.Handler = handler
45 - s.InnerServer.ConnState = func(conn net.Conn, newState http.ConnState) {
46 - switch newState {
47 - case http.StateNew:
48 - s.StartRoutine()
49 - case http.StateClosed, http.StateHijacked:
50 - s.FinishRoutine()
51 - }
52 - }
53 - err := s.InnerServer.Serve(listener)
54 -
55 - // This block is reached when the server has received a shut down command.
56 - if err == nil {
57 - s.wg.Wait()
58 - return nil
59 - } else if _, ok := err.(listenerAlreadyClosed); ok {
60 - s.wg.Wait()
61 - return nil
62 - }
63 - return err
64 -}
65 -
66 -// Increments the server's WaitGroup. Use this if a web request starts more
67 -// goroutines and these goroutines are not guaranteed to finish before the
68 -// request.
69 -func (s *GracefulServer) StartRoutine() {
70 - s.wg.Add(1)
71 -}
72 -
73 -// Decrement the server's WaitGroup. Used this to complement StartRoutine().
74 -func (s *GracefulServer) FinishRoutine() {
75 - s.wg.Done()
76 -}
77 -
78 -func (s *GracefulServer) listenForShutdown() {
79 - go func() {
80 - <-s.Shutdown
81 - s.shutdownHandler()
82 - }()
83 -}
Godeps/_workspace/src/github.com/braintree/manners/server_test.go deleted
-71
@@ -1,71 +0,0 @@
1 -package manners
2 -
3 -import (
4 - "net/http"
5 - "testing"
6 -)
7 -
8 -// Tests that the server allows in-flight requests to complete before shutting
9 -// down.
10 -func TestGracefulness(t *testing.T) {
11 - ready := make(chan bool)
12 - done := make(chan bool)
13 -
14 - exited := false
15 -
16 - handler := newBlockingHandler(ready, done)
17 - server := NewServer()
18 -
19 - go func() {
20 - err := server.ListenAndServe(":7000", handler)
21 - if err != nil {
22 - t.Error(err)
23 - }
24 -
25 - exited = true
26 - }()
27 -
28 - go func() {
29 - _, err := http.Get("http://localhost:7000")
30 - if err != nil {
31 - t.Error(err)
32 - }
33 - }()
34 -
35 - // This will block until the server is inside the handler function.
36 - <-ready
37 -
38 - server.Shutdown <- true
39 - <-done
40 -
41 - if exited {
42 - t.Fatal("The request did not complete before server exited")
43 - } else {
44 - // The handler is being allowed to run to completion; test passes.
45 - }
46 -}
47 -
48 -// Tests that the server begins to shut down when told to and does not accept
49 -// new requests
50 -func TestShutdown(t *testing.T) {
51 - handler := newTestHandler()
52 - server := NewServer()
53 - exited := make(chan bool)
54 -
55 - go func() {
56 - err := server.ListenAndServe(":7100", handler)
57 - if err != nil {
58 - t.Error(err)
59 - }
60 - exited <- true
61 - }()
62 -
63 - server.Shutdown <- true
64 -
65 - <-exited
66 - _, err := http.Get("http://localhost:7100")
67 -
68 - if err == nil {
69 - t.Fatal("Did not receive an error when trying to connect to server.")
70 - }
71 -}
Godeps/_workspace/src/github.com/chriscool/go-sleep/.gitignore deleted
-1
@@ -1 +0,0 @@
1 -go-sleep
Godeps/_workspace/src/github.com/cryptix/mdns/.gitignore deleted
-23
@@ -1,23 +0,0 @@
1 -# Compiled Object files, Static and Dynamic libs (Shared Objects)
2 -*.o
3 -*.a
4 -*.so
5 -
6 -# Folders
7 -_obj
8 -_test
9 -
10 -# Architecture specific extensions/prefixes
11 -*.[568vq]
12 -[568vq].out
13 -
14 -*.cgo1.go
15 -*.cgo2.c
16 -_cgo_defun.c
17 -_cgo_gotypes.go
18 -_cgo_export.*
19 -
20 -_testmain.go
21 -
22 -*.exe
23 -*.test
Godeps/_workspace/src/github.com/cryptix/mdns/LICENSE deleted
-20
@@ -1,20 +0,0 @@
1 -The MIT License (MIT)
2 -
3 -Copyright (c) 2014 Armon Dadgar
4 -
5 -Permission is hereby granted, free of charge, to any person obtaining a copy of
6 -this software and associated documentation files (the "Software"), to deal in
7 -the Software without restriction, including without limitation the rights to
8 -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 -the Software, and to permit persons to whom the Software is furnished to do so,
10 -subject to the following conditions:
11 -
12 -The above copyright notice and this permission notice shall be included in all
13 -copies or substantial portions of the Software.
14 -
15 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Godeps/_workspace/src/github.com/cryptix/mdns/README.md deleted
-37
@@ -1,37 +0,0 @@
1 -mdns
2 -====
3 -
4 -Simple mDNS client/server library in Golang. mDNS or Multicast DNS can be
5 -used to discover services on the local network without the use of an authoritative
6 -DNS server. This enables peer-to-peer discovery. It is important to note that many
7 -networks restrict the use of multicasting, which prevents mDNS from functioning.
8 -Notably, multicast cannot be used in any sort of cloud, or shared infrastructure
9 -environment. However it works well in most office, home, or private infrastructure
10 -environments.
11 -
12 -Using the library is very simple, here is an example of publishing a service entry:
13 -
14 - // Setup our service export
15 - host, _ := os.Hostname()
16 - info := []string{"My awesome service"},
17 - service, _ := NewMDNSService(host, "_foobar._tcp", "", "", 8000, nil, info)
18 -
19 - // Create the mDNS server, defer shutdown
20 - server, _ := mdns.NewServer(&mdns.Config{Zone: service})
21 - defer server.Shutdown()
22 -
23 -
24 -Doing a lookup for service providers is also very simple:
25 -
26 - // Make a channel for results and start listening
27 - entriesCh := make(chan *mdns.ServiceEntry, 4)
28 - go func() {
29 - for entry := range entriesCh {
30 - fmt.Printf("Got new entry: %v\n", entry)
31 - }
32 - }()
33 -
34 - // Start the lookup
35 - mdns.Lookup("_foobar._tcp", entriesCh)
36 - close(entriesCh)
37 -
Godeps/_workspace/src/github.com/cryptix/mdns/client.go deleted
-362
@@ -1,362 +0,0 @@
1 -package mdns
2 -
3 -import (
4 - "fmt"
5 - "log"
6 - "net"
7 - "strings"
8 - "sync"
9 - "time"
10 -
11 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/miekg/dns"
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv4"
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv6"
14 -)
15 -
16 -// ServiceEntry is returned after we query for a service
17 -type ServiceEntry struct {
18 - Name string
19 - Host string
20 - AddrV4 net.IP
21 - AddrV6 net.IP
22 - Port int
23 - Info string
24 -
25 - Addr net.IP // @Deprecated
26 -
27 - hasTXT bool
28 - sent bool
29 -}
30 -
31 -// complete is used to check if we have all the info we need
32 -func (s *ServiceEntry) complete() bool {
33 - return (s.AddrV4 != nil || s.AddrV6 != nil || s.Addr != nil) && s.Port != 0 && s.hasTXT
34 -}
35 -
36 -// QueryParam is used to customize how a Lookup is performed
37 -type QueryParam struct {
38 - Service string // Service to lookup
39 - Domain string // Lookup domain, default "local"
40 - Timeout time.Duration // Lookup timeout, default 1 second
41 - Interface *net.Interface // Multicast interface to use
42 - Entries chan<- *ServiceEntry // Entries Channel
43 - WantUnicastResponse bool // Unicast response desired, as per 5.4 in RFC
44 -}
45 -
46 -// DefaultParams is used to return a default set of QueryParam's
47 -func DefaultParams(service string) *QueryParam {
48 - return &QueryParam{
49 - Service: service,
50 - Domain: "local",
51 - Timeout: time.Second,
52 - Entries: make(chan *ServiceEntry),
53 - WantUnicastResponse: false, // TODO(reddaly): Change this default.
54 - }
55 -}
56 -
57 -// Query looks up a given service, in a domain, waiting at most
58 -// for a timeout before finishing the query. The results are streamed
59 -// to a channel. Sends will not block, so clients should make sure to
60 -// either read or buffer.
61 -func Query(params *QueryParam) error {
62 - // Create a new client
63 - client, err := newClient()
64 - if err != nil {
65 - return err
66 - }
67 - defer client.Close()
68 -
69 - // Set the multicast interface
70 - if params.Interface != nil {
71 - if err := client.setInterface(params.Interface); err != nil {
72 - return err
73 - }
74 - }
75 -
76 - // Ensure defaults are set
77 - if params.Domain == "" {
78 - params.Domain = "local"
79 - }
80 - if params.Timeout == 0 {
81 - params.Timeout = time.Second
82 - }
83 -
84 - // Run the query
85 - return client.query(params)
86 -}
87 -
88 -// Lookup is the same as Query, however it uses all the default parameters
89 -func Lookup(service string, entries chan<- *ServiceEntry) error {
90 - params := DefaultParams(service)
91 - params.Entries = entries
92 - return Query(params)
93 -}
94 -
95 -// Client provides a query interface that can be used to
96 -// search for service providers using mDNS
97 -type client struct {
98 - ipv4UnicastConn *net.UDPConn
99 - ipv6UnicastConn *net.UDPConn
100 -
101 - ipv4MulticastConn *net.UDPConn
102 - ipv6MulticastConn *net.UDPConn
103 -
104 - closed bool
105 - closedCh chan struct{} // TODO(reddaly): This doesn't appear to be used.
106 - closeLock sync.Mutex
107 -}
108 -
109 -// NewClient creates a new mdns Client that can be used to query
110 -// for records
111 -func newClient() (*client, error) {
112 - // TODO(reddaly): At least attempt to bind to the port required in the spec.
113 - // Create a IPv4 listener
114 - uconn4, err := net.ListenUDP("udp4", &net.UDPAddr{IP: net.IPv4zero, Port: 0})
115 - if err != nil {
116 - log.Printf("[ERR] mdns: Failed to bind to udp4 port: %v", err)
117 - }
118 - uconn6, err := net.ListenUDP("udp6", &net.UDPAddr{IP: net.IPv6zero, Port: 0})
119 - if err != nil {
120 - log.Printf("[ERR] mdns: Failed to bind to udp6 port: %v", err)
121 - }
122 -
123 - if uconn4 == nil && uconn6 == nil {
124 - return nil, fmt.Errorf("failed to bind to any unicast udp port")
125 - }
126 -
127 - mconn4, err := net.ListenMulticastUDP("udp4", nil, ipv4Addr)
128 - if err != nil {
129 - log.Printf("[ERR] mdns: Failed to bind to udp4 port: %v", err)
130 - }
131 - mconn6, err := net.ListenMulticastUDP("udp6", nil, ipv6Addr)
132 - if err != nil {
133 - log.Printf("[ERR] mdns: Failed to bind to udp6 port: %v", err)
134 - }
135 -
136 - if mconn4 == nil && mconn6 == nil {
137 - return nil, fmt.Errorf("failed to bind to any multicast udp port")
138 - }
139 -
140 - c := &client{
141 - ipv4MulticastConn: mconn4,
142 - ipv6MulticastConn: mconn6,
143 - ipv4UnicastConn: uconn4,
144 - ipv6UnicastConn: uconn6,
145 - closedCh: make(chan struct{}),
146 - }
147 - return c, nil
148 -}
149 -
150 -// Close is used to cleanup the client
151 -func (c *client) Close() error {
152 - c.closeLock.Lock()
153 - defer c.closeLock.Unlock()
154 -
155 - if c.closed {
156 - return nil
157 - }
158 - c.closed = true
159 -
160 - log.Printf("[INFO] mdns: Closing client %v", *c)
161 - close(c.closedCh)
162 -
163 - if c.ipv4UnicastConn != nil {
164 - c.ipv4UnicastConn.Close()
165 - }
166 - if c.ipv6UnicastConn != nil {
167 - c.ipv6UnicastConn.Close()
168 - }
169 - if c.ipv4MulticastConn != nil {
170 - c.ipv4MulticastConn.Close()
171 - }
172 - if c.ipv6MulticastConn != nil {
173 - c.ipv6MulticastConn.Close()
174 - }
175 -
176 - return nil
177 -}
178 -
179 -// setInterface is used to set the query interface, uses sytem
180 -// default if not provided
181 -func (c *client) setInterface(iface *net.Interface) error {
182 - p := ipv4.NewPacketConn(c.ipv4UnicastConn)
183 - if err := p.SetMulticastInterface(iface); err != nil {
184 - return err
185 - }
186 - p2 := ipv6.NewPacketConn(c.ipv6UnicastConn)
187 - if err := p2.SetMulticastInterface(iface); err != nil {
188 - return err
189 - }
190 - p = ipv4.NewPacketConn(c.ipv4MulticastConn)
191 - if err := p.SetMulticastInterface(iface); err != nil {
192 - return err
193 - }
194 - p2 = ipv6.NewPacketConn(c.ipv6MulticastConn)
195 - if err := p2.SetMulticastInterface(iface); err != nil {
196 - return err
197 - }
198 - return nil
199 -}
200 -
201 -// query is used to perform a lookup and stream results
202 -func (c *client) query(params *QueryParam) error {
203 - // Create the service name
204 - serviceAddr := fmt.Sprintf("%s.%s.", trimDot(params.Service), trimDot(params.Domain))
205 -
206 - // Start listening for response packets
207 - msgCh := make(chan *dns.Msg, 32)
208 - go c.recv(c.ipv4UnicastConn, msgCh)
209 - go c.recv(c.ipv6UnicastConn, msgCh)
210 - go c.recv(c.ipv4MulticastConn, msgCh)
211 - go c.recv(c.ipv6MulticastConn, msgCh)
212 -
213 - // Send the query
214 - m := new(dns.Msg)
215 - m.SetQuestion(serviceAddr, dns.TypePTR)
216 - // RFC 6762, section 18.12. Repurposing of Top Bit of qclass in Question
217 - // Section
218 - //
219 - // In the Question Section of a Multicast DNS query, the top bit of the qclass
220 - // field is used to indicate that unicast responses are preferred for this
221 - // particular question. (See Section 5.4.)
222 - if params.WantUnicastResponse {
223 - m.Question[0].Qclass |= 1 << 15
224 - }
225 - m.RecursionDesired = false
226 - if err := c.sendQuery(m); err != nil {
227 - return err
228 - }
229 -
230 - // Map the in-progress responses
231 - inprogress := make(map[string]*ServiceEntry)
232 -
233 - // Listen until we reach the timeout
234 - finish := time.After(params.Timeout)
235 - for {
236 - select {
237 - case resp := <-msgCh:
238 - var inp *ServiceEntry
239 - for _, answer := range append(resp.Answer, resp.Extra...) {
240 - // TODO(reddaly): Check that response corresponds to serviceAddr?
241 - switch rr := answer.(type) {
242 - case *dns.PTR:
243 - // Create new entry for this
244 - inp = ensureName(inprogress, rr.Ptr)
245 -
246 - case *dns.SRV:
247 - // Check for a target mismatch
248 - if rr.Target != rr.Hdr.Name {
249 - alias(inprogress, rr.Hdr.Name, rr.Target)
250 - }
251 -
252 - // Get the port
253 - inp = ensureName(inprogress, rr.Hdr.Name)
254 - inp.Host = rr.Target
255 - inp.Port = int(rr.Port)
256 -
257 - case *dns.TXT:
258 - // Pull out the txt
259 - inp = ensureName(inprogress, rr.Hdr.Name)
260 - inp.Info = strings.Join(rr.Txt, "|")
261 - inp.hasTXT = true
262 -
263 - case *dns.A:
264 - // Pull out the IP
265 - inp = ensureName(inprogress, rr.Hdr.Name)
266 - inp.Addr = rr.A // @Deprecated
267 - inp.AddrV4 = rr.A
268 -
269 - case *dns.AAAA:
270 - // Pull out the IP
271 - inp = ensureName(inprogress, rr.Hdr.Name)
272 - inp.Addr = rr.AAAA // @Deprecated
273 - inp.AddrV6 = rr.AAAA
274 - }
275 - }
276 -
277 - if inp == nil {
278 - continue
279 - }
280 -
281 - // Check if this entry is complete
282 - if inp.complete() {
283 - if inp.sent {
284 - continue
285 - }
286 - inp.sent = true
287 - select {
288 - case params.Entries <- inp:
289 - default:
290 - }
291 - } else {
292 - // Fire off a node specific query
293 - m := new(dns.Msg)
294 - m.SetQuestion(inp.Name, dns.TypePTR)
295 - m.RecursionDesired = false
296 - if err := c.sendQuery(m); err != nil {
297 - log.Printf("[ERR] mdns: Failed to query instance %s: %v", inp.Name, err)
298 - }
299 - }
300 - case <-finish:
301 - return nil
302 - }
303 - }
304 -}
305 -
306 -// sendQuery is used to multicast a query out
307 -func (c *client) sendQuery(q *dns.Msg) error {
308 - buf, err := q.Pack()
309 - if err != nil {
310 - return err
311 - }
312 - if c.ipv4UnicastConn != nil {
313 - c.ipv4UnicastConn.WriteToUDP(buf, ipv4Addr)
314 - }
315 - if c.ipv6UnicastConn != nil {
316 - c.ipv6UnicastConn.WriteToUDP(buf, ipv6Addr)
317 - }
318 - return nil
319 -}
320 -
321 -// recv is used to receive until we get a shutdown
322 -func (c *client) recv(l *net.UDPConn, msgCh chan *dns.Msg) {
323 - if l == nil {
324 - return
325 - }
326 - buf := make([]byte, 65536)
327 - for !c.closed {
328 - n, err := l.Read(buf)
329 - if err != nil {
330 - log.Printf("[ERR] mdns: Failed to read packet: %v", err)
331 - continue
332 - }
333 - msg := new(dns.Msg)
334 - if err := msg.Unpack(buf[:n]); err != nil {
335 - log.Printf("[ERR] mdns: Failed to unpack packet: %v", err)
336 - continue
337 - }
338 - select {
339 - case msgCh <- msg:
340 - case <-c.closedCh:
341 - return
342 - }
343 - }
344 -}
345 -
346 -// ensureName is used to ensure the named node is in progress
347 -func ensureName(inprogress map[string]*ServiceEntry, name string) *ServiceEntry {
348 - if inp, ok := inprogress[name]; ok {
349 - return inp
350 - }
351 - inp := &ServiceEntry{
352 - Name: name,
353 - }
354 - inprogress[name] = inp
355 - return inp
356 -}
357 -
358 -// alias is used to setup an alias between two entries
359 -func alias(inprogress map[string]*ServiceEntry, src, dst string) {
360 - srcEntry := ensureName(inprogress, src)
361 - inprogress[dst] = srcEntry
362 -}
Godeps/_workspace/src/github.com/cryptix/mdns/server.go deleted
-286
@@ -1,286 +0,0 @@
1 -package mdns
2 -
3 -import (
4 - "fmt"
5 - "log"
6 - "net"
7 - "strings"
8 - "sync"
9 -
10 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/miekg/dns"
11 -)
12 -
13 -const (
14 - ipv4mdns = "224.0.0.251"
15 - ipv6mdns = "ff02::fb"
16 - mdnsPort = 5353
17 - forceUnicastResponses = false
18 -)
19 -
20 -var (
21 - ipv4Addr = &net.UDPAddr{
22 - IP: net.ParseIP(ipv4mdns),
23 - Port: mdnsPort,
24 - }
25 - ipv6Addr = &net.UDPAddr{
26 - IP: net.ParseIP(ipv6mdns),
27 - Port: mdnsPort,
28 - }
29 -)
30 -
31 -// Config is used to configure the mDNS server
32 -type Config struct {
33 - // Zone must be provided to support responding to queries
34 - Zone Zone
35 -
36 - // Iface if provided binds the multicast listener to the given
37 - // interface. If not provided, the system default multicase interface
38 - // is used.
39 - Iface *net.Interface
40 -}
41 -
42 -// mDNS server is used to listen for mDNS queries and respond if we
43 -// have a matching local record
44 -type Server struct {
45 - config *Config
46 -
47 - ipv4List *net.UDPConn
48 - ipv6List *net.UDPConn
49 -
50 - shutdown bool
51 - shutdownCh chan struct{}
52 - shutdownLock sync.Mutex
53 -}
54 -
55 -// NewServer is used to create a new mDNS server from a config
56 -func NewServer(config *Config) (*Server, error) {
57 - // Create the listeners
58 - ipv4List, _ := net.ListenMulticastUDP("udp4", config.Iface, ipv4Addr)
59 - ipv6List, _ := net.ListenMulticastUDP("udp6", config.Iface, ipv6Addr)
60 -
61 - // Check if we have any listener
62 - if ipv4List == nil && ipv6List == nil {
63 - return nil, fmt.Errorf("No multicast listeners could be started")
64 - }
65 -
66 - s := &Server{
67 - config: config,
68 - ipv4List: ipv4List,
69 - ipv6List: ipv6List,
70 - shutdownCh: make(chan struct{}),
71 - }
72 -
73 - if ipv4List != nil {
74 - go s.recv(s.ipv4List)
75 - }
76 -
77 - if ipv6List != nil {
78 - go s.recv(s.ipv6List)
79 - }
80 -
81 - return s, nil
82 -}
83 -
84 -// Shutdown is used to shutdown the listener
85 -func (s *Server) Shutdown() error {
86 - s.shutdownLock.Lock()
87 - defer s.shutdownLock.Unlock()
88 -
89 - if s.shutdown {
90 - return nil
91 - }
92 - s.shutdown = true
93 - close(s.shutdownCh)
94 -
95 - if s.ipv4List != nil {
96 - s.ipv4List.Close()
97 - }
98 - if s.ipv6List != nil {
99 - s.ipv6List.Close()
100 - }
101 - return nil
102 -}
103 -
104 -// recv is a long running routine to receive packets from an interface
105 -func (s *Server) recv(c *net.UDPConn) {
106 - if c == nil {
107 - return
108 - }
109 - buf := make([]byte, 65536)
110 - for !s.shutdown {
111 - n, from, err := c.ReadFrom(buf)
112 - if err != nil {
113 - continue
114 - }
115 - if err := s.parsePacket(buf[:n], from); err != nil {
116 - log.Printf("[ERR] mdns: Failed to handle query: %v", err)
117 - }
118 - }
119 -}
120 -
121 -// parsePacket is used to parse an incoming packet
122 -func (s *Server) parsePacket(packet []byte, from net.Addr) error {
123 - var msg dns.Msg
124 - if err := msg.Unpack(packet); err != nil {
125 - log.Printf("[ERR] mdns: Failed to unpack packet: %v", err)
126 - return err
127 - }
128 - return s.handleQuery(&msg, from)
129 -}
130 -
131 -// handleQuery is used to handle an incoming query
132 -func (s *Server) handleQuery(query *dns.Msg, from net.Addr) error {
133 - if query.Opcode != dns.OpcodeQuery {
134 - // "In both multicast query and multicast response messages, the OPCODE MUST
135 - // be zero on transmission (only standard queries are currently supported
136 - // over multicast). Multicast DNS messages received with an OPCODE other
137 - // than zero MUST be silently ignored." Note: OpcodeQuery == 0
138 - return fmt.Errorf("mdns: received query with non-zero Opcode %v: %v", query.Opcode, *query)
139 - }
140 - if query.Rcode != 0 {
141 - // "In both multicast query and multicast response messages, the Response
142 - // Code MUST be zero on transmission. Multicast DNS messages received with
143 - // non-zero Response Codes MUST be silently ignored."
144 - return fmt.Errorf("mdns: received query with non-zero Rcode %v: %v", query.Rcode, *query)
145 - }
146 -
147 - // TODO(reddaly): Handle "TC (Truncated) Bit":
148 - // In query messages, if the TC bit is set, it means that additional
149 - // Known-Answer records may be following shortly. A responder SHOULD
150 - // record this fact, and wait for those additional Known-Answer records,
151 - // before deciding whether to respond. If the TC bit is clear, it means
152 - // that the querying host has no additional Known Answers.
153 - if query.Truncated {
154 - return fmt.Errorf("[ERR] mdns: support for DNS requests with high truncated bit not implemented: %v", *query)
155 - }
156 -
157 - var unicastAnswer, multicastAnswer []dns.RR
158 -
159 - // Handle each question
160 - for _, q := range query.Question {
161 - mrecs, urecs := s.handleQuestion(q)
162 - multicastAnswer = append(multicastAnswer, mrecs...)
163 - unicastAnswer = append(unicastAnswer, urecs...)
164 - }
165 -
166 - // See section 18 of RFC 6762 for rules about DNS headers.
167 - resp := func(unicast bool) *dns.Msg {
168 - // 18.1: ID (Query Identifier)
169 - // 0 for multicast response, query.Id for unicast response
170 - id := uint16(0)
171 - if unicast {
172 - id = query.Id
173 - }
174 -
175 - var answer []dns.RR
176 - if unicast {
177 - answer = unicastAnswer
178 - } else {
179 - answer = multicastAnswer
180 - }
181 - if len(answer) == 0 {
182 - return nil
183 - }
184 -
185 - return &dns.Msg{
186 - MsgHdr: dns.MsgHdr{
187 - Id: id,
188 -
189 - // 18.2: QR (Query/Response) Bit - must be set to 1 in response.
190 - Response: true,
191 -
192 - // 18.3: OPCODE - must be zero in response (OpcodeQuery == 0)
193 - Opcode: dns.OpcodeQuery,
194 -
195 - // 18.4: AA (Authoritative Answer) Bit - must be set to 1
196 - Authoritative: true,
197 -
198 - // The following fields must all be set to 0:
199 - // 18.5: TC (TRUNCATED) Bit
200 - // 18.6: RD (Recursion Desired) Bit
201 - // 18.7: RA (Recursion Available) Bit
202 - // 18.8: Z (Zero) Bit
203 - // 18.9: AD (Authentic Data) Bit
204 - // 18.10: CD (Checking Disabled) Bit
205 - // 18.11: RCODE (Response Code)
206 - },
207 - // 18.12 pertains to questions (handled by handleQuestion)
208 - // 18.13 pertains to resource records (handled by handleQuestion)
209 -
210 - // 18.14: Name Compression - responses should be compressed (though see
211 - // caveats in the RFC), so set the Compress bit (part of the dns library
212 - // API, not part of the DNS packet) to true.
213 - Compress: true,
214 -
215 - Answer: answer,
216 - }
217 - }
218 -
219 - if len(multicastAnswer) == 0 && len(unicastAnswer) == 0 {
220 - questions := make([]string, len(query.Question))
221 - for i, q := range query.Question {
222 - questions[i] = q.Name
223 - }
224 - log.Printf("no responses for query with questions: %s", strings.Join(questions, ", "))
225 - }
226 -
227 - if mresp := resp(false); mresp != nil {
228 - if err := s.sendResponse(mresp, from, false); err != nil {
229 - return fmt.Errorf("mdns: error sending multicast response: %v", err)
230 - }
231 - }
232 - if uresp := resp(true); uresp != nil {
233 - if err := s.sendResponse(uresp, from, true); err != nil {
234 - return fmt.Errorf("mdns: error sending unicast response: %v", err)
235 - }
236 - }
237 - return nil
238 -}
239 -
240 -// handleQuestion is used to handle an incoming question
241 -//
242 -// The response to a question may be transmitted over multicast, unicast, or
243 -// both. The return values are DNS records for each transmission type.
244 -func (s *Server) handleQuestion(q dns.Question) (multicastRecs, unicastRecs []dns.RR) {
245 - records := s.config.Zone.Records(q)
246 -
247 - if len(records) == 0 {
248 - return nil, nil
249 - }
250 -
251 - // Handle unicast and multicast responses.
252 - // TODO(reddaly): The decision about sending over unicast vs. multicast is not
253 - // yet fully compliant with RFC 6762. For example, the unicast bit should be
254 - // ignored if the records in question are close to TTL expiration. For now,
255 - // we just use the unicast bit to make the decision, as per the spec:
256 - // RFC 6762, section 18.12. Repurposing of Top Bit of qclass in Question
257 - // Section
258 - //
259 - // In the Question Section of a Multicast DNS query, the top bit of the
260 - // qclass field is used to indicate that unicast responses are preferred
261 - // for this particular question. (See Section 5.4.)
262 - if q.Qclass&(1<<15) != 0 || forceUnicastResponses {
263 - return nil, records
264 - }
265 - return records, nil
266 -}
267 -
268 -// sendResponse is used to send a response packet
269 -func (s *Server) sendResponse(resp *dns.Msg, from net.Addr, unicast bool) error {
270 - // TODO(reddaly): Respect the unicast argument, and allow sending responses
271 - // over multicast.
272 - buf, err := resp.Pack()
273 - if err != nil {
274 - return err
275 - }
276 -
277 - // Determine the socket to send from
278 - addr := from.(*net.UDPAddr)
279 - if addr.IP.To4() != nil {
280 - _, err = s.ipv4List.WriteToUDP(buf, addr)
281 - return err
282 - } else {
283 - _, err = s.ipv6List.WriteToUDP(buf, addr)
284 - return err
285 - }
286 -}
Godeps/_workspace/src/github.com/cryptix/mdns/server_test.go deleted
-58
@@ -1,58 +0,0 @@
1 -package mdns
2 -
3 -import (
4 - "testing"
5 - "time"
6 -)
7 -
8 -func TestServer_StartStop(t *testing.T) {
9 - s := makeService(t)
10 - serv, err := NewServer(&Config{Zone: s})
11 - if err != nil {
12 - t.Fatalf("err: %v", err)
13 - }
14 - defer serv.Shutdown()
15 -}
16 -
17 -func TestServer_Lookup(t *testing.T) {
18 - serv, err := NewServer(&Config{Zone: makeServiceWithServiceName(t, "_foobar._tcp")})
19 - if err != nil {
20 - t.Fatalf("err: %v", err)
21 - }
22 - defer serv.Shutdown()
23 -
24 - entries := make(chan *ServiceEntry, 1)
25 - found := false
26 - go func() {
27 - select {
28 - case e := <-entries:
29 - if e.Name != "hostname._foobar._tcp.local." {
30 - t.Fatalf("bad: %v", e)
31 - }
32 - if e.Port != 80 {
33 - t.Fatalf("bad: %v", e)
34 - }
35 - if e.Info != "Local web server" {
36 - t.Fatalf("bad: %v", e)
37 - }
38 - found = true
39 -
40 - case <-time.After(80 * time.Millisecond):
41 - t.Fatalf("timeout")
42 - }
43 - }()
44 -
45 - params := &QueryParam{
46 - Service: "_foobar._tcp",
47 - Domain: "local",
48 - Timeout: 50 * time.Millisecond,
49 - Entries: entries,
50 - }
51 - err = Query(params)
52 - if err != nil {
53 - t.Fatalf("err: %v", err)
54 - }
55 - if !found {
56 - t.Fatalf("record not found")
57 - }
58 -}
Godeps/_workspace/src/github.com/cryptix/mdns/zone.go deleted
-307
@@ -1,307 +0,0 @@
1 -package mdns
2 -
3 -import (
4 - "fmt"
5 - "net"
6 - "os"
7 - "strings"
8 -
9 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/miekg/dns"
10 -)
11 -
12 -const (
13 - // defaultTTL is the default TTL value in returned DNS records in seconds.
14 - defaultTTL = 120
15 -)
16 -
17 -// Zone is the interface used to integrate with the server and
18 -// to serve records dynamically
19 -type Zone interface {
20 - // Records returns DNS records in response to a DNS question.
21 - Records(q dns.Question) []dns.RR
22 -}
23 -
24 -// MDNSService is used to export a named service by implementing a Zone
25 -type MDNSService struct {
26 - Instance string // Instance name (e.g. "hostService name")
27 - Service string // Service name (e.g. "_http._tcp.")
28 - Domain string // If blank, assumes "local"
29 - HostName string // Host machine DNS name (e.g. "mymachine.net.")
30 - Port int // Service Port
31 - IPs []net.IP // IP addresses for the service's host
32 - TXT []string // Service TXT records
33 -
34 - serviceAddr string // Fully qualified service address
35 - instanceAddr string // Fully qualified instance address
36 - enumAddr string // _services._dns-sd._udp.<domain>
37 -}
38 -
39 -// validateFQDN returns an error if the passed string is not a fully qualified
40 -// hdomain name (more specifically, a hostname).
41 -func validateFQDN(s string) error {
42 - if len(s) == 0 {
43 - return fmt.Errorf("FQDN must not be blank")
44 - }
45 - if s[len(s)-1] != '.' {
46 - return fmt.Errorf("FQDN must end in period: %s", s)
47 - }
48 - // TODO(reddaly): Perform full validation.
49 -
50 - return nil
51 -}
52 -
53 -// NewMDNSService returns a new instance of MDNSService.
54 -//
55 -// If domain, hostName, or ips is set to the zero value, then a default value
56 -// will be inferred from the operating system.
57 -//
58 -// TODO(reddaly): This interface may need to change to account for "unique
59 -// record" conflict rules of the mDNS protocol. Upon startup, the server should
60 -// check to ensure that the instance name does not conflict with other instance
61 -// names, and, if required, select a new name. There may also be conflicting
62 -// hostName A/AAAA records.
63 -func NewMDNSService(instance, service, domain, hostName string, port int, ips []net.IP, txt []string) (*MDNSService, error) {
64 - // Sanity check inputs
65 - if instance == "" {
66 - return nil, fmt.Errorf("missing service instance name")
67 - }
68 - if service == "" {
69 - return nil, fmt.Errorf("missing service name")
70 - }
71 - if port == 0 {
72 - return nil, fmt.Errorf("missing service port")
73 - }
74 -
75 - // Set default domain
76 - if domain == "" {
77 - domain = "local."
78 - }
79 - if err := validateFQDN(domain); err != nil {
80 - return nil, fmt.Errorf("domain %q is not a fully-qualified domain name: %v", domain, err)
81 - }
82 -
83 - // Get host information if no host is specified.
84 - if hostName == "" {
85 - var err error
86 - hostName, err = os.Hostname()
87 - if err != nil {
88 - return nil, fmt.Errorf("could not determine host: %v", err)
89 - }
90 - hostName = fmt.Sprintf("%s.", hostName)
91 - }
92 - if err := validateFQDN(hostName); err != nil {
93 - return nil, fmt.Errorf("hostName %q is not a fully-qualified domain name: %v", hostName, err)
94 - }
95 -
96 - if len(ips) == 0 {
97 - var err error
98 - ips, err = net.LookupIP(hostName)
99 - if err != nil {
100 - // Try appending the host domain suffix and lookup again
101 - // (required for Linux-based hosts)
102 - tmpHostName := fmt.Sprintf("%s%s", hostName, domain)
103 -
104 - ips, err = net.LookupIP(tmpHostName)
105 -
106 - if err != nil {
107 - return nil, fmt.Errorf("could not determine host IP addresses for %s", hostName)
108 - }
109 - }
110 - }
111 - for _, ip := range ips {
112 - if ip.To4() == nil && ip.To16() == nil {
113 - return nil, fmt.Errorf("invalid IP address in IPs list: %v", ip)
114 - }
115 - }
116 -
117 - return &MDNSService{
118 - Instance: instance,
119 - Service: service,
120 - Domain: domain,
121 - HostName: hostName,
122 - Port: port,
123 - IPs: ips,
124 - TXT: txt,
125 - serviceAddr: fmt.Sprintf("%s.%s.", trimDot(service), trimDot(domain)),
126 - instanceAddr: fmt.Sprintf("%s.%s.%s.", instance, trimDot(service), trimDot(domain)),
127 - enumAddr: fmt.Sprintf("_services._dns-sd._udp.%s.", trimDot(domain)),
128 - }, nil
129 -}
130 -
131 -// trimDot is used to trim the dots from the start or end of a string
132 -func trimDot(s string) string {
133 - return strings.Trim(s, ".")
134 -}
135 -
136 -// Records returns DNS records in response to a DNS question.
137 -func (m *MDNSService) Records(q dns.Question) []dns.RR {
138 - switch q.Name {
139 - case m.enumAddr:
140 - return m.serviceEnum(q)
141 - case m.serviceAddr:
142 - return m.serviceRecords(q)
143 - case m.instanceAddr:
144 - return m.instanceRecords(q)
145 - case m.HostName:
146 - if q.Qtype == dns.TypeA || q.Qtype == dns.TypeAAAA {
147 - return m.instanceRecords(q)
148 - }
149 - fallthrough
150 - default:
151 - return nil
152 - }
153 -}
154 -
155 -func (m *MDNSService) serviceEnum(q dns.Question) []dns.RR {
156 - switch q.Qtype {
157 - case dns.TypeANY:
158 - fallthrough
159 - case dns.TypePTR:
160 - rr := &dns.PTR{
161 - Hdr: dns.RR_Header{
162 - Name: q.Name,
163 - Rrtype: dns.TypePTR,
164 - Class: dns.ClassINET,
165 - Ttl: defaultTTL,
166 - },
167 - Ptr: m.serviceAddr,
168 - }
169 - return []dns.RR{rr}
170 - default:
171 - return nil
172 - }
173 -}
174 -
175 -// serviceRecords is called when the query matches the service name
176 -func (m *MDNSService) serviceRecords(q dns.Question) []dns.RR {
177 - switch q.Qtype {
178 - case dns.TypeANY:
179 - fallthrough
180 - case dns.TypePTR:
181 - // Build a PTR response for the service
182 - rr := &dns.PTR{
183 - Hdr: dns.RR_Header{
184 - Name: q.Name,
185 - Rrtype: dns.TypePTR,
186 - Class: dns.ClassINET,
187 - Ttl: defaultTTL,
188 - },
189 - Ptr: m.instanceAddr,
190 - }
191 - servRec := []dns.RR{rr}
192 -
193 - // Get the instance records
194 - instRecs := m.instanceRecords(dns.Question{
195 - Name: m.instanceAddr,
196 - Qtype: dns.TypeANY,
197 - })
198 -
199 - // Return the service record with the instance records
200 - return append(servRec, instRecs...)
201 - default:
202 - return nil
203 - }
204 -}
205 -
206 -// serviceRecords is called when the query matches the instance name
207 -func (m *MDNSService) instanceRecords(q dns.Question) []dns.RR {
208 - switch q.Qtype {
209 - case dns.TypeANY:
210 - // Get the SRV, which includes A and AAAA
211 - recs := m.instanceRecords(dns.Question{
212 - Name: m.instanceAddr,
213 - Qtype: dns.TypeSRV,
214 - })
215 -
216 - // Add the TXT record
217 - recs = append(recs, m.instanceRecords(dns.Question{
218 - Name: m.instanceAddr,
219 - Qtype: dns.TypeTXT,
220 - })...)
221 - return recs
222 -
223 - case dns.TypeA:
224 - var rr []dns.RR
225 - for _, ip := range m.IPs {
226 - if ip4 := ip.To4(); ip4 != nil {
227 - rr = append(rr, &dns.A{
228 - Hdr: dns.RR_Header{
229 - Name: m.HostName,
230 - Rrtype: dns.TypeA,
231 - Class: dns.ClassINET,
232 - Ttl: defaultTTL,
233 - },
234 - A: ip4,
235 - })
236 - }
237 - }
238 - return rr
239 -
240 - case dns.TypeAAAA:
241 - var rr []dns.RR
242 - for _, ip := range m.IPs {
243 - if ip.To4() != nil {
244 - // TODO(reddaly): IPv4 addresses could be encoded in IPv6 format and
245 - // putinto AAAA records, but the current logic puts ipv4-encodable
246 - // addresses into the A records exclusively. Perhaps this should be
247 - // configurable?
248 - continue
249 - }
250 -
251 - if ip16 := ip.To16(); ip16 != nil {
252 - rr = append(rr, &dns.AAAA{
253 - Hdr: dns.RR_Header{
254 - Name: m.HostName,
255 - Rrtype: dns.TypeAAAA,
256 - Class: dns.ClassINET,
257 - Ttl: defaultTTL,
258 - },
259 - AAAA: ip16,
260 - })
261 - }
262 - }
263 - return rr
264 -
265 - case dns.TypeSRV:
266 - // Create the SRV Record
267 - srv := &dns.SRV{
268 - Hdr: dns.RR_Header{
269 - Name: q.Name,
270 - Rrtype: dns.TypeSRV,
271 - Class: dns.ClassINET,
272 - Ttl: defaultTTL,
273 - },
274 - Priority: 10,
275 - Weight: 1,
276 - Port: uint16(m.Port),
277 - Target: m.HostName,
278 - }
279 - recs := []dns.RR{srv}
280 -
281 - // Add the A record
282 - recs = append(recs, m.instanceRecords(dns.Question{
283 - Name: m.instanceAddr,
284 - Qtype: dns.TypeA,
285 - })...)
286 -
287 - // Add the AAAA record
288 - recs = append(recs, m.instanceRecords(dns.Question{
289 - Name: m.instanceAddr,
290 - Qtype: dns.TypeAAAA,
291 - })...)
292 - return recs
293 -
294 - case dns.TypeTXT:
295 - txt := &dns.TXT{
296 - Hdr: dns.RR_Header{
297 - Name: q.Name,
298 - Rrtype: dns.TypeTXT,
299 - Class: dns.ClassINET,
300 - Ttl: defaultTTL,
301 - },
302 - Txt: m.TXT,
303 - }
304 - return []dns.RR{txt}
305 - }
306 - return nil
307 -}
Godeps/_workspace/src/github.com/cryptix/mdns/zone_test.go deleted
-275
@@ -1,275 +0,0 @@
1 -package mdns
2 -
3 -import (
4 - "bytes"
5 - "net"
6 - "reflect"
7 - "testing"
8 -
9 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/miekg/dns"
10 -)
11 -
12 -func makeService(t *testing.T) *MDNSService {
13 - return makeServiceWithServiceName(t, "_http._tcp")
14 -}
15 -
16 -func makeServiceWithServiceName(t *testing.T, service string) *MDNSService {
17 - m, err := NewMDNSService(
18 - "hostname",
19 - service,
20 - "local.",
21 - "testhost.",
22 - 80, // port
23 - []net.IP{net.IP([]byte{192, 168, 0, 42}), net.ParseIP("2620:0:1000:1900:b0c2:d0b2:c411:18bc")},
24 - []string{"Local web server"}) // TXT
25 -
26 - if err != nil {
27 - t.Fatalf("err: %v", err)
28 - }
29 -
30 - return m
31 -}
32 -
33 -func TestNewMDNSService_BadParams(t *testing.T) {
34 - for _, test := range []struct {
35 - testName string
36 - hostName string
37 - domain string
38 - }{
39 - {
40 - "NewMDNSService should fail when passed hostName that is not a legal fully-qualified domain name",
41 - "hostname", // not legal FQDN - should be "hostname." or "hostname.local.", etc.
42 - "local.", // legal
43 - },
44 - {
45 - "NewMDNSService should fail when passed domain that is not a legal fully-qualified domain name",
46 - "hostname.", // legal
47 - "local", // should be "local."
48 - },
49 - } {
50 - _, err := NewMDNSService(
51 - "instance name",
52 - "_http._tcp",
53 - test.domain,
54 - test.hostName,
55 - 80, // port
56 - []net.IP{net.IP([]byte{192, 168, 0, 42})},
57 - []string{"Local web server"}) // TXT
58 - if err == nil {
59 - t.Fatalf("%s: error expected, but got none", test.testName)
60 - }
61 - }
62 -}
63 -
64 -func TestMDNSService_BadAddr(t *testing.T) {
65 - s := makeService(t)
66 - q := dns.Question{
67 - Name: "random",
68 - Qtype: dns.TypeANY,
69 - }
70 - recs := s.Records(q)
71 - if len(recs) != 0 {
72 - t.Fatalf("bad: %v", recs)
73 - }
74 -}
75 -
76 -func TestMDNSService_ServiceAddr(t *testing.T) {
77 - s := makeService(t)
78 - q := dns.Question{
79 - Name: "_http._tcp.local.",
80 - Qtype: dns.TypeANY,
81 - }
82 - recs := s.Records(q)
83 - if got, want := len(recs), 5; got != want {
84 - t.Fatalf("got %d records, want %d: %v", got, want, recs)
85 - }
86 -
87 - if ptr, ok := recs[0].(*dns.PTR); !ok {
88 - t.Errorf("recs[0] should be PTR record, got: %v, all records: %v", recs[0], recs)
89 - } else if got, want := ptr.Ptr, "hostname._http._tcp.local."; got != want {
90 - t.Fatalf("bad PTR record %v: got %v, want %v", ptr, got, want)
91 - }
92 -
93 - if _, ok := recs[1].(*dns.SRV); !ok {
94 - t.Errorf("recs[1] should be SRV record, got: %v, all reccords: %v", recs[1], recs)
95 - }
96 - if _, ok := recs[2].(*dns.A); !ok {
97 - t.Errorf("recs[2] should be A record, got: %v, all records: %v", recs[2], recs)
98 - }
99 - if _, ok := recs[3].(*dns.AAAA); !ok {
100 - t.Errorf("recs[3] should be AAAA record, got: %v, all records: %v", recs[3], recs)
101 - }
102 - if _, ok := recs[4].(*dns.TXT); !ok {
103 - t.Errorf("recs[4] should be TXT record, got: %v, all records: %v", recs[4], recs)
104 - }
105 -
106 - q.Qtype = dns.TypePTR
107 - if recs2 := s.Records(q); !reflect.DeepEqual(recs, recs2) {
108 - t.Fatalf("PTR question should return same result as ANY question: ANY => %v, PTR => %v", recs, recs2)
109 - }
110 -}
111 -
112 -func TestMDNSService_InstanceAddr_ANY(t *testing.T) {
113 - s := makeService(t)
114 - q := dns.Question{
115 - Name: "hostname._http._tcp.local.",
116 - Qtype: dns.TypeANY,
117 - }
118 - recs := s.Records(q)
119 - if len(recs) != 4 {
120 - t.Fatalf("bad: %v", recs)
121 - }
122 - if _, ok := recs[0].(*dns.SRV); !ok {
123 - t.Fatalf("bad: %v", recs[0])
124 - }
125 - if _, ok := recs[1].(*dns.A); !ok {
126 - t.Fatalf("bad: %v", recs[1])
127 - }
128 - if _, ok := recs[2].(*dns.AAAA); !ok {
129 - t.Fatalf("bad: %v", recs[2])
130 - }
131 - if _, ok := recs[3].(*dns.TXT); !ok {
132 - t.Fatalf("bad: %v", recs[3])
133 - }
134 -}
135 -
136 -func TestMDNSService_InstanceAddr_SRV(t *testing.T) {
137 - s := makeService(t)
138 - q := dns.Question{
139 - Name: "hostname._http._tcp.local.",
140 - Qtype: dns.TypeSRV,
141 - }
142 - recs := s.Records(q)
143 - if len(recs) != 3 {
144 - t.Fatalf("bad: %v", recs)
145 - }
146 - srv, ok := recs[0].(*dns.SRV)
147 - if !ok {
148 - t.Fatalf("bad: %v", recs[0])
149 - }
150 - if _, ok := recs[1].(*dns.A); !ok {
151 - t.Fatalf("bad: %v", recs[1])
152 - }
153 - if _, ok := recs[2].(*dns.AAAA); !ok {
154 - t.Fatalf("bad: %v", recs[2])
155 - }
156 -
157 - if srv.Port != uint16(s.Port) {
158 - t.Fatalf("bad: %v", recs[0])
159 - }
160 -}
161 -
162 -func TestMDNSService_InstanceAddr_A(t *testing.T) {
163 - s := makeService(t)
164 - q := dns.Question{
165 - Name: "hostname._http._tcp.local.",
166 - Qtype: dns.TypeA,
167 - }
168 - recs := s.Records(q)
169 - if len(recs) != 1 {
170 - t.Fatalf("bad: %v", recs)
171 - }
172 - a, ok := recs[0].(*dns.A)
173 - if !ok {
174 - t.Fatalf("bad: %v", recs[0])
175 - }
176 - if !bytes.Equal(a.A, []byte{192, 168, 0, 42}) {
177 - t.Fatalf("bad: %v", recs[0])
178 - }
179 -}
180 -
181 -func TestMDNSService_InstanceAddr_AAAA(t *testing.T) {
182 - s := makeService(t)
183 - q := dns.Question{
184 - Name: "hostname._http._tcp.local.",
185 - Qtype: dns.TypeAAAA,
186 - }
187 - recs := s.Records(q)
188 - if len(recs) != 1 {
189 - t.Fatalf("bad: %v", recs)
190 - }
191 - a4, ok := recs[0].(*dns.AAAA)
192 - if !ok {
193 - t.Fatalf("bad: %v", recs[0])
194 - }
195 - ip6 := net.ParseIP("2620:0:1000:1900:b0c2:d0b2:c411:18bc")
196 - if got := len(ip6); got != net.IPv6len {
197 - t.Fatalf("test IP failed to parse (len = %d, want %d)", got, net.IPv6len)
198 - }
199 - if !bytes.Equal(a4.AAAA, ip6) {
200 - t.Fatalf("bad: %v", recs[0])
201 - }
202 -}
203 -
204 -func TestMDNSService_InstanceAddr_TXT(t *testing.T) {
205 - s := makeService(t)
206 - q := dns.Question{
207 - Name: "hostname._http._tcp.local.",
208 - Qtype: dns.TypeTXT,
209 - }
210 - recs := s.Records(q)
211 - if len(recs) != 1 {
212 - t.Fatalf("bad: %v", recs)
213 - }
214 - txt, ok := recs[0].(*dns.TXT)
215 - if !ok {
216 - t.Fatalf("bad: %v", recs[0])
217 - }
218 - if got, want := txt.Txt, s.TXT; !reflect.DeepEqual(got, want) {
219 - t.Fatalf("TXT record mismatch for %v: got %v, want %v", recs[0], got, want)
220 - }
221 -}
222 -
223 -func TestMDNSService_HostNameQuery(t *testing.T) {
224 - s := makeService(t)
225 - for _, test := range []struct {
226 - q dns.Question
227 - want []dns.RR
228 - }{
229 - {
230 - dns.Question{Name: "testhost.", Qtype: dns.TypeA},
231 - []dns.RR{&dns.A{
232 - Hdr: dns.RR_Header{
233 - Name: "testhost.",
234 - Rrtype: dns.TypeA,
235 - Class: dns.ClassINET,
236 - Ttl: 120,
237 - },
238 - A: net.IP([]byte{192, 168, 0, 42}),
239 - }},
240 - },
241 - {
242 - dns.Question{Name: "testhost.", Qtype: dns.TypeAAAA},
243 - []dns.RR{&dns.AAAA{
244 - Hdr: dns.RR_Header{
245 - Name: "testhost.",
246 - Rrtype: dns.TypeAAAA,
247 - Class: dns.ClassINET,
248 - Ttl: 120,
249 - },
250 - AAAA: net.ParseIP("2620:0:1000:1900:b0c2:d0b2:c411:18bc"),
251 - }},
252 - },
253 - } {
254 - if got := s.Records(test.q); !reflect.DeepEqual(got, test.want) {
255 - t.Errorf("hostname query failed: s.Records(%v) = %v, want %v", test.q, got, test.want)
256 - }
257 - }
258 -}
259 -
260 -func TestMDNSService_serviceEnum_PTR(t *testing.T) {
261 - s := makeService(t)
262 - q := dns.Question{
263 - Name: "_services._dns-sd._udp.local.",
264 - Qtype: dns.TypePTR,
265 - }
266 - recs := s.Records(q)
267 - if len(recs) != 1 {
268 - t.Fatalf("bad: %v", recs)
269 - }
270 - if ptr, ok := recs[0].(*dns.PTR); !ok {
271 - t.Errorf("recs[0] should be PTR record, got: %v, all records: %v", recs[0], recs)
272 - } else if got, want := ptr.Ptr, "_http._tcp.local."; got != want {
273 - t.Fatalf("bad PTR record %v: got %v, want %v", ptr, got, want)
274 - }
275 -}
Godeps/_workspace/src/github.com/docker/spdystream/CONTRIBUTING.md deleted
-13
@@ -1,13 +0,0 @@
1 -# Contributing to SpdyStream
2 -
3 -Want to hack on spdystream? Awesome! Here are instructions to get you
4 -started.
5 -
6 -SpdyStream is a part of the [Docker](https://docker.io) project, and follows
7 -the same rules and principles. If you're already familiar with the way
8 -Docker does things, you'll feel right at home.
9 -
10 -Otherwise, go read
11 -[Docker's contributions guidelines](https://github.com/dotcloud/docker/blob/master/CONTRIBUTING.md).
12 -
13 -Happy hacking!
Godeps/_workspace/src/github.com/docker/spdystream/LICENSE deleted
-191
@@ -1,191 +0,0 @@
1 -
2 - Apache License
3 - Version 2.0, January 2004
4 - http://www.apache.org/licenses/
5 -
6 - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 -
8 - 1. Definitions.
9 -
10 - "License" shall mean the terms and conditions for use, reproduction,
11 - and distribution as defined by Sections 1 through 9 of this document.
12 -
13 - "Licensor" shall mean the copyright owner or entity authorized by
14 - the copyright owner that is granting the License.
15 -
16 - "Legal Entity" shall mean the union of the acting entity and all
17 - other entities that control, are controlled by, or are under common
18 - control with that entity. For the purposes of this definition,
19 - "control" means (i) the power, direct or indirect, to cause the
20 - direction or management of such entity, whether by contract or
21 - otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 - outstanding shares, or (iii) beneficial ownership of such entity.
23 -
24 - "You" (or "Your") shall mean an individual or Legal Entity
25 - exercising permissions granted by this License.
26 -
27 - "Source" form shall mean the preferred form for making modifications,
28 - including but not limited to software source code, documentation
29 - source, and configuration files.
30 -
31 - "Object" form shall mean any form resulting from mechanical
32 - transformation or translation of a Source form, including but
33 - not limited to compiled object code, generated documentation,
34 - and conversions to other media types.
35 -
36 - "Work" shall mean the work of authorship, whether in Source or
37 - Object form, made available under the License, as indicated by a
38 - copyright notice that is included in or attached to the work
39 - (an example is provided in the Appendix below).
40 -
41 - "Derivative Works" shall mean any work, whether in Source or Object
42 - form, that is based on (or derived from) the Work and for which the
43 - editorial revisions, annotations, elaborations, or other modifications
44 - represent, as a whole, an original work of authorship. For the purposes
45 - of this License, Derivative Works shall not include works that remain
46 - separable from, or merely link (or bind by name) to the interfaces of,
47 - the Work and Derivative Works thereof.
48 -
49 - "Contribution" shall mean any work of authorship, including
50 - the original version of the Work and any modifications or additions
51 - to that Work or Derivative Works thereof, that is intentionally
52 - submitted to Licensor for inclusion in the Work by the copyright owner
53 - or by an individual or Legal Entity authorized to submit on behalf of
54 - the copyright owner. For the purposes of this definition, "submitted"
55 - means any form of electronic, verbal, or written communication sent
56 - to the Licensor or its representatives, including but not limited to
57 - communication on electronic mailing lists, source code control systems,
58 - and issue tracking systems that are managed by, or on behalf of, the
59 - Licensor for the purpose of discussing and improving the Work, but
60 - excluding communication that is conspicuously marked or otherwise
61 - designated in writing by the copyright owner as "Not a Contribution."
62 -
63 - "Contributor" shall mean Licensor and any individual or Legal Entity
64 - on behalf of whom a Contribution has been received by Licensor and
65 - subsequently incorporated within the Work.
66 -
67 - 2. Grant of Copyright License. Subject to the terms and conditions of
68 - this License, each Contributor hereby grants to You a perpetual,
69 - worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 - copyright license to reproduce, prepare Derivative Works of,
71 - publicly display, publicly perform, sublicense, and distribute the
72 - Work and such Derivative Works in Source or Object form.
73 -
74 - 3. Grant of Patent License. Subject to the terms and conditions of
75 - this License, each Contributor hereby grants to You a perpetual,
76 - worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 - (except as stated in this section) patent license to make, have made,
78 - use, offer to sell, sell, import, and otherwise transfer the Work,
79 - where such license applies only to those patent claims licensable
80 - by such Contributor that are necessarily infringed by their
81 - Contribution(s) alone or by combination of their Contribution(s)
82 - with the Work to which such Contribution(s) was submitted. If You
83 - institute patent litigation against any entity (including a
84 - cross-claim or counterclaim in a lawsuit) alleging that the Work
85 - or a Contribution incorporated within the Work constitutes direct
86 - or contributory patent infringement, then any patent licenses
87 - granted to You under this License for that Work shall terminate
88 - as of the date such litigation is filed.
89 -
90 - 4. Redistribution. You may reproduce and distribute copies of the
91 - Work or Derivative Works thereof in any medium, with or without
92 - modifications, and in Source or Object form, provided that You
93 - meet the following conditions:
94 -
95 - (a) You must give any other recipients of the Work or
96 - Derivative Works a copy of this License; and
97 -
98 - (b) You must cause any modified files to carry prominent notices
99 - stating that You changed the files; and
100 -
101 - (c) You must retain, in the Source form of any Derivative Works
102 - that You distribute, all copyright, patent, trademark, and
103 - attribution notices from the Source form of the Work,
104 - excluding those notices that do not pertain to any part of
105 - the Derivative Works; and
106 -
107 - (d) If the Work includes a "NOTICE" text file as part of its
108 - distribution, then any Derivative Works that You distribute must
109 - include a readable copy of the attribution notices contained
110 - within such NOTICE file, excluding those notices that do not
111 - pertain to any part of the Derivative Works, in at least one
112 - of the following places: within a NOTICE text file distributed
113 - as part of the Derivative Works; within the Source form or
114 - documentation, if provided along with the Derivative Works; or,
115 - within a display generated by the Derivative Works, if and
116 - wherever such third-party notices normally appear. The contents
117 - of the NOTICE file are for informational purposes only and
118 - do not modify the License. You may add Your own attribution
119 - notices within Derivative Works that You distribute, alongside
120 - or as an addendum to the NOTICE text from the Work, provided
121 - that such additional attribution notices cannot be construed
122 - as modifying the License.
123 -
124 - You may add Your own copyright statement to Your modifications and
125 - may provide additional or different license terms and conditions
126 - for use, reproduction, or distribution of Your modifications, or
127 - for any such Derivative Works as a whole, provided Your use,
128 - reproduction, and distribution of the Work otherwise complies with
129 - the conditions stated in this License.
130 -
131 - 5. Submission of Contributions. Unless You explicitly state otherwise,
132 - any Contribution intentionally submitted for inclusion in the Work
133 - by You to the Licensor shall be under the terms and conditions of
134 - this License, without any additional terms or conditions.
135 - Notwithstanding the above, nothing herein shall supersede or modify
136 - the terms of any separate license agreement you may have executed
137 - with Licensor regarding such Contributions.
138 -
139 - 6. Trademarks. This License does not grant permission to use the trade
140 - names, trademarks, service marks, or product names of the Licensor,
141 - except as required for reasonable and customary use in describing the
142 - origin of the Work and reproducing the content of the NOTICE file.
143 -
144 - 7. Disclaimer of Warranty. Unless required by applicable law or
145 - agreed to in writing, Licensor provides the Work (and each
146 - Contributor provides its Contributions) on an "AS IS" BASIS,
147 - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 - implied, including, without limitation, any warranties or conditions
149 - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 - PARTICULAR PURPOSE. You are solely responsible for determining the
151 - appropriateness of using or redistributing the Work and assume any
152 - risks associated with Your exercise of permissions under this License.
153 -
154 - 8. Limitation of Liability. In no event and under no legal theory,
155 - whether in tort (including negligence), contract, or otherwise,
156 - unless required by applicable law (such as deliberate and grossly
157 - negligent acts) or agreed to in writing, shall any Contributor be
158 - liable to You for damages, including any direct, indirect, special,
159 - incidental, or consequential damages of any character arising as a
160 - result of this License or out of the use or inability to use the
161 - Work (including but not limited to damages for loss of goodwill,
162 - work stoppage, computer failure or malfunction, or any and all
163 - other commercial damages or losses), even if such Contributor
164 - has been advised of the possibility of such damages.
165 -
166 - 9. Accepting Warranty or Additional Liability. While redistributing
167 - the Work or Derivative Works thereof, You may choose to offer,
168 - and charge a fee for, acceptance of support, warranty, indemnity,
169 - or other liability obligations and/or rights consistent with this
170 - License. However, in accepting such obligations, You may act only
171 - on Your own behalf and on Your sole responsibility, not on behalf
172 - of any other Contributor, and only if You agree to indemnify,
173 - defend, and hold each Contributor harmless for any liability
174 - incurred by, or claims asserted against, such Contributor by reason
175 - of your accepting any such warranty or additional liability.
176 -
177 - END OF TERMS AND CONDITIONS
178 -
179 - Copyright 2014 Docker, Inc.
180 -
181 - Licensed under the Apache License, Version 2.0 (the "License");
182 - you may not use this file except in compliance with the License.
183 - You may obtain a copy of the License at
184 -
185 - http://www.apache.org/licenses/LICENSE-2.0
186 -
187 - Unless required by applicable law or agreed to in writing, software
188 - distributed under the License is distributed on an "AS IS" BASIS,
189 - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190 - See the License for the specific language governing permissions and
191 - limitations under the License.
Godeps/_workspace/src/github.com/docker/spdystream/MAINTAINERS deleted
-1
@@ -1 +0,0 @@
1 -Derek McGowan <derek@docker.com> (@dmcg)
Godeps/_workspace/src/github.com/docker/spdystream/README.md deleted
-78
@@ -1,78 +0,0 @@
1 -# SpdyStream
2 -
3 -A multiplexed stream library using spdy
4 -
5 -## Usage
6 -
7 -Client example (connecting to mirroring server without auth)
8 -
9 -```go
10 -package main
11 -
12 -import (
13 - "fmt"
14 - "github.com/docker/spdystream"
15 - "net"
16 - "net/http"
17 -)
18 -
19 -func main() {
20 - conn, err := net.Dial("tcp", "localhost:8080")
21 - if err != nil {
22 - panic(err)
23 - }
24 - spdyConn, err := spdystream.NewConnection(conn, false)
25 - if err != nil {
26 - panic(err)
27 - }
28 - go spdyConn.Serve(spdystream.NoOpStreamHandler)
29 - stream, err := spdyConn.CreateStream(http.Header{}, nil, false)
30 - if err != nil {
31 - panic(err)
32 - }
33 -
34 - stream.Wait()
35 -
36 - fmt.Fprint(stream, "Writing to stream")
37 -
38 - buf := make([]byte, 25)
39 - stream.Read(buf)
40 - fmt.Println(string(buf))
41 -
42 - stream.Close()
43 -}
44 -```
45 -
46 -Server example (mirroring server without auth)
47 -
48 -```go
49 -package main
50 -
51 -import (
52 - "github.com/docker/spdystream"
53 - "net"
54 -)
55 -
56 -func main() {
57 - listener, err := net.Listen("tcp", "localhost:8080")
58 - if err != nil {
59 - panic(err)
60 - }
61 - for {
62 - conn, err := listener.Accept()
63 - if err != nil {
64 - panic(err)
65 - }
66 - spdyConn, err := spdystream.NewConnection(conn, true)
67 - if err != nil {
68 - panic(err)
69 - }
70 - go spdyConn.Serve(spdystream.MirrorStreamHandler)
71 - }
72 -}
73 -```
74 -
75 -## Copyright and license
76 -
77 -Code and documentation copyright 2013-2014 Docker, inc. Code released under the Apache 2.0 license.
78 -Docs released under Creative commons.
Godeps/_workspace/src/github.com/docker/spdystream/connection.go deleted
-902
@@ -1,902 +0,0 @@
1 -package spdystream
2 -
3 -import (
4 - "errors"
5 - "fmt"
6 - "io"
7 - "net"
8 - "net/http"
9 - "sync"
10 - "time"
11 -
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/docker/spdystream/spdy"
13 -)
14 -
15 -var (
16 - ErrInvalidStreamId = errors.New("Invalid stream id")
17 - ErrTimeout = errors.New("Timeout occured")
18 - ErrReset = errors.New("Stream reset")
19 - ErrWriteClosedStream = errors.New("Write on closed stream")
20 -)
21 -
22 -const (
23 - FRAME_WORKERS = 5
24 - QUEUE_SIZE = 50
25 -)
26 -
27 -type StreamHandler func(stream *Stream)
28 -
29 -type AuthHandler func(header http.Header, slot uint8, parent uint32) bool
30 -
31 -type idleAwareFramer struct {
32 - f *spdy.Framer
33 - conn *Connection
34 - writeLock sync.Mutex
35 - resetChan chan struct{}
36 - setTimeoutChan chan time.Duration
37 - timeout time.Duration
38 -}
39 -
40 -func newIdleAwareFramer(framer *spdy.Framer) *idleAwareFramer {
41 - iaf := &idleAwareFramer{
42 - f: framer,
43 - resetChan: make(chan struct{}, 2),
44 - setTimeoutChan: make(chan time.Duration),
45 - }
46 - return iaf
47 -}
48 -
49 -func (i *idleAwareFramer) monitor() {
50 - var (
51 - timer *time.Timer
52 - expired <-chan time.Time
53 - resetChan = i.resetChan
54 - )
55 -Loop:
56 - for {
57 - select {
58 - case timeout := <-i.setTimeoutChan:
59 - i.timeout = timeout
60 - if timeout == 0 {
61 - if timer != nil {
62 - timer.Stop()
63 - }
64 - } else {
65 - if timer == nil {
66 - timer = time.NewTimer(timeout)
67 - expired = timer.C
68 - } else {
69 - timer.Reset(timeout)
70 - }
71 - }
72 - case <-resetChan:
73 - if timer != nil && i.timeout > 0 {
74 - timer.Reset(i.timeout)
75 - }
76 - case <-expired:
77 - i.conn.streamCond.L.Lock()
78 - streams := i.conn.streams
79 - i.conn.streams = make(map[spdy.StreamId]*Stream)
80 - i.conn.streamCond.Broadcast()
81 - i.conn.streamCond.L.Unlock()
82 - go func() {
83 - for _, stream := range streams {
84 - stream.resetStream()
85 - }
86 - i.conn.Close()
87 - }()
88 - case <-i.conn.closeChan:
89 - if timer != nil {
90 - timer.Stop()
91 - }
92 -
93 - // Start a goroutine to drain resetChan. This is needed because we've seen
94 - // some unit tests with large numbers of goroutines get into a situation
95 - // where resetChan fills up, at least 1 call to Write() is still trying to
96 - // send to resetChan, the connection gets closed, and this case statement
97 - // attempts to grab the write lock that Write() already has, causing a
98 - // deadlock.
99 - //
100 - // See https://github.com/docker/spdystream/issues/49 for more details.
101 - go func() {
102 - for _ = range resetChan {
103 - }
104 - }()
105 -
106 - i.writeLock.Lock()
107 - close(resetChan)
108 - i.resetChan = nil
109 - i.writeLock.Unlock()
110 -
111 - break Loop
112 - }
113 - }
114 -
115 - // Drain resetChan
116 - for _ = range resetChan {
117 - }
118 -}
119 -
120 -func (i *idleAwareFramer) WriteFrame(frame spdy.Frame) error {
121 - i.writeLock.Lock()
122 - defer i.writeLock.Unlock()
123 - if i.resetChan == nil {
124 - return io.EOF
125 - }
126 - err := i.f.WriteFrame(frame)
127 - if err != nil {
128 - return err
129 - }
130 -
131 - i.resetChan <- struct{}{}
132 -
133 - return nil
134 -}
135 -
136 -func (i *idleAwareFramer) ReadFrame() (spdy.Frame, error) {
137 - frame, err := i.f.ReadFrame()
138 - if err != nil {
139 - return nil, err
140 - }
141 -
142 - // resetChan should never be closed since it is only closed
143 - // when the connection has closed its closeChan. This closure
144 - // only occurs after all Reads have finished
145 - // TODO (dmcgowan): refactor relationship into connection
146 - i.resetChan <- struct{}{}
147 -
148 - return frame, nil
149 -}
150 -
151 -type Connection struct {
152 - conn net.Conn
153 - framer *idleAwareFramer
154 -
155 - closeChan chan bool
156 - goneAway bool
157 - lastStreamChan chan<- *Stream
158 - goAwayTimeout time.Duration
159 - closeTimeout time.Duration
160 -
161 - streamLock *sync.RWMutex
162 - streamCond *sync.Cond
163 - streams map[spdy.StreamId]*Stream
164 -
165 - nextIdLock sync.Mutex
166 - receiveIdLock sync.Mutex
167 - nextStreamId spdy.StreamId
168 - receivedStreamId spdy.StreamId
169 -
170 - pingIdLock sync.Mutex
171 - pingId uint32
172 - pingChans map[uint32]chan error
173 -
174 - shutdownLock sync.Mutex
175 - shutdownChan chan error
176 - hasShutdown bool
177 -}
178 -
179 -// NewConnection creates a new spdy connection from an existing
180 -// network connection.
181 -func NewConnection(conn net.Conn, server bool) (*Connection, error) {
182 - framer, framerErr := spdy.NewFramer(conn, conn)
183 - if framerErr != nil {
184 - return nil, framerErr
185 - }
186 - idleAwareFramer := newIdleAwareFramer(framer)
187 - var sid spdy.StreamId
188 - var rid spdy.StreamId
189 - var pid uint32
190 - if server {
191 - sid = 2
192 - rid = 1
193 - pid = 2
194 - } else {
195 - sid = 1
196 - rid = 2
197 - pid = 1
198 - }
199 -
200 - streamLock := new(sync.RWMutex)
201 - streamCond := sync.NewCond(streamLock)
202 -
203 - session := &Connection{
204 - conn: conn,
205 - framer: idleAwareFramer,
206 -
207 - closeChan: make(chan bool),
208 - goAwayTimeout: time.Duration(0),
209 - closeTimeout: time.Duration(0),
210 -
211 - streamLock: streamLock,
212 - streamCond: streamCond,
213 - streams: make(map[spdy.StreamId]*Stream),
214 - nextStreamId: sid,
215 - receivedStreamId: rid,
216 -
217 - pingId: pid,
218 - pingChans: make(map[uint32]chan error),
219 -
220 - shutdownChan: make(chan error),
221 - }
222 - idleAwareFramer.conn = session
223 - go idleAwareFramer.monitor()
224 -
225 - return session, nil
226 -}
227 -
228 -// Ping sends a ping frame across the connection and
229 -// returns the response time
230 -func (s *Connection) Ping() (time.Duration, error) {
231 - pid := s.pingId
232 - s.pingIdLock.Lock()
233 - if s.pingId > 0x7ffffffe {
234 - s.pingId = s.pingId - 0x7ffffffe
235 - } else {
236 - s.pingId = s.pingId + 2
237 - }
238 - s.pingIdLock.Unlock()
239 - pingChan := make(chan error)
240 - s.pingChans[pid] = pingChan
241 - defer delete(s.pingChans, pid)
242 -
243 - frame := &spdy.PingFrame{Id: pid}
244 - startTime := time.Now()
245 - writeErr := s.framer.WriteFrame(frame)
246 - if writeErr != nil {
247 - return time.Duration(0), writeErr
248 - }
249 - select {
250 - case <-s.closeChan:
251 - return time.Duration(0), errors.New("connection closed")
252 - case err, ok := <-pingChan:
253 - if ok && err != nil {
254 - return time.Duration(0), err
255 - }
256 - break
257 - }
258 - return time.Now().Sub(startTime), nil
259 -}
260 -
261 -// Serve handles frames sent from the server, including reply frames
262 -// which are needed to fully initiate connections. Both clients and servers
263 -// should call Serve in a separate goroutine before creating streams.
264 -func (s *Connection) Serve(newHandler StreamHandler) {
265 - // Parition queues to ensure stream frames are handled
266 - // by the same worker, ensuring order is maintained
267 - frameQueues := make([]*PriorityFrameQueue, FRAME_WORKERS)
268 - for i := 0; i < FRAME_WORKERS; i++ {
269 - frameQueues[i] = NewPriorityFrameQueue(QUEUE_SIZE)
270 - // Ensure frame queue is drained when connection is closed
271 - go func(frameQueue *PriorityFrameQueue) {
272 - <-s.closeChan
273 - frameQueue.Drain()
274 - }(frameQueues[i])
275 -
276 - go s.frameHandler(frameQueues[i], newHandler)
277 - }
278 -
279 - var partitionRoundRobin int
280 - for {
281 - readFrame, err := s.framer.ReadFrame()
282 - if err != nil {
283 - if err != io.EOF {
284 - fmt.Errorf("frame read error: %s", err)
285 - } else {
286 - debugMessage("EOF received")
287 - }
288 - break
289 - }
290 - var priority uint8
291 - var partition int
292 - switch frame := readFrame.(type) {
293 - case *spdy.SynStreamFrame:
294 - if s.checkStreamFrame(frame) {
295 - priority = frame.Priority
296 - partition = int(frame.StreamId % FRAME_WORKERS)
297 - debugMessage("(%p) Add stream frame: %d ", s, frame.StreamId)
298 - s.addStreamFrame(frame)
299 - } else {
300 - debugMessage("(%p) Rejected stream frame: %d ", s, frame.StreamId)
301 - continue
302 - }
303 - case *spdy.SynReplyFrame:
304 - priority = s.getStreamPriority(frame.StreamId)
305 - partition = int(frame.StreamId % FRAME_WORKERS)
306 - case *spdy.DataFrame:
307 - priority = s.getStreamPriority(frame.StreamId)
308 - partition = int(frame.StreamId % FRAME_WORKERS)
309 - case *spdy.RstStreamFrame:
310 - priority = s.getStreamPriority(frame.StreamId)
311 - partition = int(frame.StreamId % FRAME_WORKERS)
312 - case *spdy.HeadersFrame:
313 - priority = s.getStreamPriority(frame.StreamId)
314 - partition = int(frame.StreamId % FRAME_WORKERS)
315 - case *spdy.PingFrame:
316 - priority = 0
317 - partition = partitionRoundRobin
318 - partitionRoundRobin = (partitionRoundRobin + 1) % FRAME_WORKERS
319 - case *spdy.GoAwayFrame:
320 - priority = 0
321 - partition = partitionRoundRobin
322 - partitionRoundRobin = (partitionRoundRobin + 1) % FRAME_WORKERS
323 - default:
324 - priority = 7
325 - partition = partitionRoundRobin
326 - partitionRoundRobin = (partitionRoundRobin + 1) % FRAME_WORKERS
327 - }
328 - frameQueues[partition].Push(readFrame, priority)
329 - }
330 - close(s.closeChan)
331 -
332 - s.streamCond.L.Lock()
333 - // notify streams that they're now closed, which will
334 - // unblock any stream Read() calls
335 - for _, stream := range s.streams {
336 - stream.closeRemoteChannels()
337 - }
338 - s.streams = make(map[spdy.StreamId]*Stream)
339 - s.streamCond.Broadcast()
340 - s.streamCond.L.Unlock()
341 -}
342 -
343 -func (s *Connection) frameHandler(frameQueue *PriorityFrameQueue, newHandler StreamHandler) {
344 - for {
345 - popFrame := frameQueue.Pop()
346 - if popFrame == nil {
347 - return
348 - }
349 -
350 - var frameErr error
351 - switch frame := popFrame.(type) {
352 - case *spdy.SynStreamFrame:
353 - frameErr = s.handleStreamFrame(frame, newHandler)
354 - case *spdy.SynReplyFrame:
355 - frameErr = s.handleReplyFrame(frame)
356 - case *spdy.DataFrame:
357 - frameErr = s.handleDataFrame(frame)
358 - case *spdy.RstStreamFrame:
359 - frameErr = s.handleResetFrame(frame)
360 - case *spdy.HeadersFrame:
361 - frameErr = s.handleHeaderFrame(frame)
362 - case *spdy.PingFrame:
363 - frameErr = s.handlePingFrame(frame)
364 - case *spdy.GoAwayFrame:
365 - frameErr = s.handleGoAwayFrame(frame)
366 - default:
367 - frameErr = fmt.Errorf("unhandled frame type: %T", frame)
368 - }
369 -
370 - if frameErr != nil {
371 - fmt.Errorf("frame handling error: %s", frameErr)
372 - }
373 - }
374 -}
375 -
376 -func (s *Connection) getStreamPriority(streamId spdy.StreamId) uint8 {
377 - stream, streamOk := s.getStream(streamId)
378 - if !streamOk {
379 - return 7
380 - }
381 - return stream.priority
382 -}
383 -
384 -func (s *Connection) addStreamFrame(frame *spdy.SynStreamFrame) {
385 - var parent *Stream
386 - if frame.AssociatedToStreamId != spdy.StreamId(0) {
387 - parent, _ = s.getStream(frame.AssociatedToStreamId)
388 - }
389 -
390 - stream := &Stream{
391 - streamId: frame.StreamId,
392 - parent: parent,
393 - conn: s,
394 - startChan: make(chan error),
395 - headers: frame.Headers,
396 - finished: (frame.CFHeader.Flags & spdy.ControlFlagUnidirectional) != 0x00,
397 - replyCond: sync.NewCond(new(sync.Mutex)),
398 - dataChan: make(chan []byte),
399 - headerChan: make(chan http.Header),
400 - closeChan: make(chan bool),
401 - }
402 - if frame.CFHeader.Flags&spdy.ControlFlagFin != 0x00 {
403 - stream.closeRemoteChannels()
404 - }
405 -
406 - s.addStream(stream)
407 -}
408 -
409 -// checkStreamFrame checks to see if a stream frame is allowed.
410 -// If the stream is invalid, then a reset frame with protocol error
411 -// will be returned.
412 -func (s *Connection) checkStreamFrame(frame *spdy.SynStreamFrame) bool {
413 - s.receiveIdLock.Lock()
414 - defer s.receiveIdLock.Unlock()
415 - if s.goneAway {
416 - return false
417 - }
418 - validationErr := s.validateStreamId(frame.StreamId)
419 - if validationErr != nil {
420 - go func() {
421 - resetErr := s.sendResetFrame(spdy.ProtocolError, frame.StreamId)
422 - if resetErr != nil {
423 - fmt.Errorf("reset error: %s", resetErr)
424 - }
425 - }()
426 - return false
427 - }
428 - return true
429 -}
430 -
431 -func (s *Connection) handleStreamFrame(frame *spdy.SynStreamFrame, newHandler StreamHandler) error {
432 - stream, ok := s.getStream(frame.StreamId)
433 - if !ok {
434 - return fmt.Errorf("Missing stream: %d", frame.StreamId)
435 - }
436 -
437 - newHandler(stream)
438 -
439 - return nil
440 -}
441 -
442 -func (s *Connection) handleReplyFrame(frame *spdy.SynReplyFrame) error {
443 - debugMessage("(%p) Reply frame received for %d", s, frame.StreamId)
444 - stream, streamOk := s.getStream(frame.StreamId)
445 - if !streamOk {
446 - debugMessage("Reply frame gone away for %d", frame.StreamId)
447 - // Stream has already gone away
448 - return nil
449 - }
450 - if stream.replied {
451 - // Stream has already received reply
452 - return nil
453 - }
454 - stream.replied = true
455 -
456 - // TODO Check for error
457 - if (frame.CFHeader.Flags & spdy.ControlFlagFin) != 0x00 {
458 - s.remoteStreamFinish(stream)
459 - }
460 -
461 - close(stream.startChan)
462 -
463 - return nil
464 -}
465 -
466 -func (s *Connection) handleResetFrame(frame *spdy.RstStreamFrame) error {
467 - stream, streamOk := s.getStream(frame.StreamId)
468 - if !streamOk {
469 - // Stream has already been removed
470 - return nil
471 - }
472 - s.removeStream(stream)
473 - stream.closeRemoteChannels()
474 -
475 - if !stream.replied {
476 - stream.replied = true
477 - stream.startChan <- ErrReset
478 - close(stream.startChan)
479 - }
480 -
481 - stream.finishLock.Lock()
482 - stream.finished = true
483 - stream.finishLock.Unlock()
484 -
485 - return nil
486 -}
487 -
488 -func (s *Connection) handleHeaderFrame(frame *spdy.HeadersFrame) error {
489 - stream, streamOk := s.getStream(frame.StreamId)
490 - if !streamOk {
491 - // Stream has already gone away
492 - return nil
493 - }
494 - if !stream.replied {
495 - // No reply received...Protocol error?
496 - return nil
497 - }
498 -
499 - // TODO limit headers while not blocking (use buffered chan or goroutine?)
500 - select {
501 - case <-stream.closeChan:
502 - return nil
503 - case stream.headerChan <- frame.Headers:
504 - }
505 -
506 - if (frame.CFHeader.Flags & spdy.ControlFlagFin) != 0x00 {
507 - s.remoteStreamFinish(stream)
508 - }
509 -
510 - return nil
511 -}
512 -
513 -func (s *Connection) handleDataFrame(frame *spdy.DataFrame) error {
514 - debugMessage("(%p) Data frame received for %d", s, frame.StreamId)
515 - stream, streamOk := s.getStream(frame.StreamId)
516 - if !streamOk {
517 - debugMessage("Data frame gone away for %d", frame.StreamId)
518 - // Stream has already gone away
519 - return nil
520 - }
521 - if !stream.replied {
522 - debugMessage("Data frame not replied %d", frame.StreamId)
523 - // No reply received...Protocol error?
524 - return nil
525 - }
526 -
527 - debugMessage("(%p) (%d) Data frame handling", stream, stream.streamId)
528 - if len(frame.Data) > 0 {
529 - stream.dataLock.RLock()
530 - select {
531 - case <-stream.closeChan:
532 - debugMessage("(%p) (%d) Data frame not sent (stream shut down)", stream, stream.streamId)
533 - case stream.dataChan <- frame.Data:
534 - debugMessage("(%p) (%d) Data frame sent", stream, stream.streamId)
535 - }
536 - stream.dataLock.RUnlock()
537 - }
538 - if (frame.Flags & spdy.DataFlagFin) != 0x00 {
539 - s.remoteStreamFinish(stream)
540 - }
541 - return nil
542 -}
543 -
544 -func (s *Connection) handlePingFrame(frame *spdy.PingFrame) error {
545 - if s.pingId&0x01 != frame.Id&0x01 {
546 - return s.framer.WriteFrame(frame)
547 - }
548 - pingChan, pingOk := s.pingChans[frame.Id]
549 - if pingOk {
550 - close(pingChan)
551 - }
552 - return nil
553 -}
554 -
555 -func (s *Connection) handleGoAwayFrame(frame *spdy.GoAwayFrame) error {
556 - debugMessage("(%p) Go away received", s)
557 - s.receiveIdLock.Lock()
558 - if s.goneAway {
559 - s.receiveIdLock.Unlock()
560 - return nil
561 - }
562 - s.goneAway = true
563 - s.receiveIdLock.Unlock()
564 -
565 - if s.lastStreamChan != nil {
566 - stream, _ := s.getStream(frame.LastGoodStreamId)
567 - go func() {
568 - s.lastStreamChan <- stream
569 - }()
570 - }
571 -
572 - // Do not block frame handler waiting for closure
573 - go s.shutdown(s.goAwayTimeout)
574 -
575 - return nil
576 -}
577 -
578 -func (s *Connection) remoteStreamFinish(stream *Stream) {
579 - stream.closeRemoteChannels()
580 -
581 - stream.finishLock.Lock()
582 - if stream.finished {
583 - // Stream is fully closed, cleanup
584 - s.removeStream(stream)
585 - }
586 - stream.finishLock.Unlock()
587 -}
588 -
589 -// CreateStream creates a new spdy stream using the parameters for
590 -// creating the stream frame. The stream frame will be sent upon
591 -// calling this function, however this function does not wait for
592 -// the reply frame. If waiting for the reply is desired, use
593 -// the stream Wait or WaitTimeout function on the stream returned
594 -// by this function.
595 -func (s *Connection) CreateStream(headers http.Header, parent *Stream, fin bool) (*Stream, error) {
596 - streamId := s.getNextStreamId()
597 - if streamId == 0 {
598 - return nil, fmt.Errorf("Unable to get new stream id")
599 - }
600 -
601 - stream := &Stream{
602 - streamId: streamId,
603 - parent: parent,
604 - conn: s,
605 - startChan: make(chan error),
606 - headers: headers,
607 - dataChan: make(chan []byte),
608 - headerChan: make(chan http.Header),
609 - closeChan: make(chan bool),
610 - }
611 -
612 - debugMessage("(%p) (%p) Create stream", s, stream)
613 -
614 - s.addStream(stream)
615 -
616 - return stream, s.sendStream(stream, fin)
617 -}
618 -
619 -func (s *Connection) shutdown(closeTimeout time.Duration) {
620 - // TODO Ensure this isn't called multiple times
621 - s.shutdownLock.Lock()
622 - if s.hasShutdown {
623 - s.shutdownLock.Unlock()
624 - return
625 - }
626 - s.hasShutdown = true
627 - s.shutdownLock.Unlock()
628 -
629 - var timeout <-chan time.Time
630 - if closeTimeout > time.Duration(0) {
631 - timeout = time.After(closeTimeout)
632 - }
633 - streamsClosed := make(chan bool)
634 -
635 - go func() {
636 - s.streamCond.L.Lock()
637 - for len(s.streams) > 0 {
638 - debugMessage("Streams opened: %d, %#v", len(s.streams), s.streams)
639 - s.streamCond.Wait()
640 - }
641 - s.streamCond.L.Unlock()
642 - close(streamsClosed)
643 - }()
644 -
645 - var err error
646 - select {
647 - case <-streamsClosed:
648 - // No active streams, close should be safe
649 - err = s.conn.Close()
650 - case <-timeout:
651 - // Force ungraceful close
652 - err = s.conn.Close()
653 - // Wait for cleanup to clear active streams
654 - <-streamsClosed
655 - }
656 -
657 - if err != nil {
658 - duration := 10 * time.Minute
659 - time.AfterFunc(duration, func() {
660 - select {
661 - case err, ok := <-s.shutdownChan:
662 - if ok {
663 - fmt.Errorf("Unhandled close error after %s: %s", duration, err)
664 - }
665 - default:
666 - }
667 - })
668 - s.shutdownChan <- err
669 - }
670 - close(s.shutdownChan)
671 -
672 - return
673 -}
674 -
675 -// Closes spdy connection by sending GoAway frame and initiating shutdown
676 -func (s *Connection) Close() error {
677 - s.receiveIdLock.Lock()
678 - if s.goneAway {
679 - s.receiveIdLock.Unlock()
680 - return nil
681 - }
682 - s.goneAway = true
683 - s.receiveIdLock.Unlock()
684 -
685 - var lastStreamId spdy.StreamId
686 - if s.receivedStreamId > 2 {
687 - lastStreamId = s.receivedStreamId - 2
688 - }
689 -
690 - goAwayFrame := &spdy.GoAwayFrame{
691 - LastGoodStreamId: lastStreamId,
692 - Status: spdy.GoAwayOK,
693 - }
694 -
695 - err := s.framer.WriteFrame(goAwayFrame)
696 - if err != nil {
697 - return err
698 - }
699 -
700 - go s.shutdown(s.closeTimeout)
701 -
702 - return nil
703 -}
704 -
705 -// CloseWait closes the connection and waits for shutdown
706 -// to finish. Note the underlying network Connection
707 -// is not closed until the end of shutdown.
708 -func (s *Connection) CloseWait() error {
709 - closeErr := s.Close()
710 - if closeErr != nil {
711 - return closeErr
712 - }
713 - shutdownErr, ok := <-s.shutdownChan
714 - if ok {
715 - return shutdownErr
716 - }
717 - return nil
718 -}
719 -
720 -// Wait waits for the connection to finish shutdown or for
721 -// the wait timeout duration to expire. This needs to be
722 -// called either after Close has been called or the GOAWAYFRAME
723 -// has been received. If the wait timeout is 0, this function
724 -// will block until shutdown finishes. If wait is never called
725 -// and a shutdown error occurs, that error will be logged as an
726 -// unhandled error.
727 -func (s *Connection) Wait(waitTimeout time.Duration) error {
728 - var timeout <-chan time.Time
729 - if waitTimeout > time.Duration(0) {
730 - timeout = time.After(waitTimeout)
731 - }
732 -
733 - select {
734 - case err, ok := <-s.shutdownChan:
735 - if ok {
736 - return err
737 - }
738 - case <-timeout:
739 - return ErrTimeout
740 - }
741 - return nil
742 -}
743 -
744 -// NotifyClose registers a channel to be called when the remote
745 -// peer inidicates connection closure. The last stream to be
746 -// received by the remote will be sent on the channel. The notify
747 -// timeout will determine the duration between go away received
748 -// and the connection being closed.
749 -func (s *Connection) NotifyClose(c chan<- *Stream, timeout time.Duration) {
750 - s.goAwayTimeout = timeout
751 - s.lastStreamChan = c
752 -}
753 -
754 -// SetCloseTimeout sets the amount of time close will wait for
755 -// streams to finish before terminating the underlying network
756 -// connection. Setting the timeout to 0 will cause close to
757 -// wait forever, which is the default.
758 -func (s *Connection) SetCloseTimeout(timeout time.Duration) {
759 - s.closeTimeout = timeout
760 -}
761 -
762 -// SetIdleTimeout sets the amount of time the connection may sit idle before
763 -// it is forcefully terminated.
764 -func (s *Connection) SetIdleTimeout(timeout time.Duration) {
765 - s.framer.setTimeoutChan <- timeout
766 -}
767 -
768 -func (s *Connection) sendHeaders(headers http.Header, stream *Stream, fin bool) error {
769 - var flags spdy.ControlFlags
770 - if fin {
771 - flags = spdy.ControlFlagFin
772 - }
773 -
774 - headerFrame := &spdy.HeadersFrame{
775 - StreamId: stream.streamId,
776 - Headers: headers,
777 - CFHeader: spdy.ControlFrameHeader{Flags: flags},
778 - }
779 -
780 - return s.framer.WriteFrame(headerFrame)
781 -}
782 -
783 -func (s *Connection) sendReply(headers http.Header, stream *Stream, fin bool) error {
784 - var flags spdy.ControlFlags
785 - if fin {
786 - flags = spdy.ControlFlagFin
787 - }
788 -
789 - replyFrame := &spdy.SynReplyFrame{
790 - StreamId: stream.streamId,
791 - Headers: headers,
792 - CFHeader: spdy.ControlFrameHeader{Flags: flags},
793 - }
794 -
795 - return s.framer.WriteFrame(replyFrame)
796 -}
797 -
798 -func (s *Connection) sendResetFrame(status spdy.RstStreamStatus, streamId spdy.StreamId) error {
799 - resetFrame := &spdy.RstStreamFrame{
800 - StreamId: streamId,
801 - Status: status,
802 - }
803 -
804 - return s.framer.WriteFrame(resetFrame)
805 -}
806 -
807 -func (s *Connection) sendReset(status spdy.RstStreamStatus, stream *Stream) error {
808 - return s.sendResetFrame(status, stream.streamId)
809 -}
810 -
811 -func (s *Connection) sendStream(stream *Stream, fin bool) error {
812 - var flags spdy.ControlFlags
813 - if fin {
814 - flags = spdy.ControlFlagFin
815 - stream.finished = true
816 - }
817 -
818 - var parentId spdy.StreamId
819 - if stream.parent != nil {
820 - parentId = stream.parent.streamId
821 - }
822 -
823 - streamFrame := &spdy.SynStreamFrame{
824 - StreamId: spdy.StreamId(stream.streamId),
825 - AssociatedToStreamId: spdy.StreamId(parentId),
826 - Headers: stream.headers,
827 - CFHeader: spdy.ControlFrameHeader{Flags: flags},
828 - }
829 -
830 - return s.framer.WriteFrame(streamFrame)
831 -}
832 -
833 -// getNextStreamId returns the next sequential id
834 -// every call should produce a unique value or an error
835 -func (s *Connection) getNextStreamId() spdy.StreamId {
836 - s.nextIdLock.Lock()
837 - defer s.nextIdLock.Unlock()
838 - sid := s.nextStreamId
839 - if sid > 0x7fffffff {
840 - return 0
841 - }
842 - s.nextStreamId = s.nextStreamId + 2
843 - return sid
844 -}
845 -
846 -// PeekNextStreamId returns the next sequential id and keeps the next id untouched
847 -func (s *Connection) PeekNextStreamId() spdy.StreamId {
848 - sid := s.nextStreamId
849 - return sid
850 -}
851 -
852 -func (s *Connection) validateStreamId(rid spdy.StreamId) error {
853 - if rid > 0x7fffffff || rid < s.receivedStreamId {
854 - return ErrInvalidStreamId
855 - }
856 - s.receivedStreamId = rid + 2
857 - return nil
858 -}
859 -
860 -func (s *Connection) addStream(stream *Stream) {
861 - s.streamCond.L.Lock()
862 - s.streams[stream.streamId] = stream
863 - debugMessage("(%p) (%p) Stream added, broadcasting: %d", s, stream, stream.streamId)
864 - s.streamCond.Broadcast()
865 - s.streamCond.L.Unlock()
866 -}
867 -
868 -func (s *Connection) removeStream(stream *Stream) {
869 - s.streamCond.L.Lock()
870 - delete(s.streams, stream.streamId)
871 - debugMessage("Stream removed, broadcasting: %d", stream.streamId)
872 - s.streamCond.Broadcast()
873 - s.streamCond.L.Unlock()
874 -}
875 -
876 -func (s *Connection) getStream(streamId spdy.StreamId) (stream *Stream, ok bool) {
877 - s.streamLock.RLock()
878 - stream, ok = s.streams[streamId]
879 - s.streamLock.RUnlock()
880 - return
881 -}
882 -
883 -// FindStream looks up the given stream id and either waits for the
884 -// stream to be found or returns nil if the stream id is no longer
885 -// valid.
886 -func (s *Connection) FindStream(streamId uint32) *Stream {
887 - var stream *Stream
888 - var ok bool
889 - s.streamCond.L.Lock()
890 - stream, ok = s.streams[spdy.StreamId(streamId)]
891 - debugMessage("(%p) Found stream %d? %t", s, spdy.StreamId(streamId), ok)
892 - for !ok && streamId >= uint32(s.receivedStreamId) {
893 - s.streamCond.Wait()
894 - stream, ok = s.streams[spdy.StreamId(streamId)]
895 - }
896 - s.streamCond.L.Unlock()
897 - return stream
898 -}
899 -
900 -func (s *Connection) CloseChan() <-chan bool {
901 - return s.closeChan
902 -}
Godeps/_workspace/src/github.com/docker/spdystream/handlers.go deleted
-38
@@ -1,38 +0,0 @@
1 -package spdystream
2 -
3 -import (
4 - "io"
5 - "net/http"
6 -)
7 -
8 -// MirrorStreamHandler mirrors all streams.
9 -func MirrorStreamHandler(stream *Stream) {
10 - replyErr := stream.SendReply(http.Header{}, false)
11 - if replyErr != nil {
12 - return
13 - }
14 -
15 - go func() {
16 - io.Copy(stream, stream)
17 - stream.Close()
18 - }()
19 - go func() {
20 - for {
21 - header, receiveErr := stream.ReceiveHeader()
22 - if receiveErr != nil {
23 - return
24 - }
25 - sendErr := stream.SendHeader(header, false)
26 - if sendErr != nil {
27 - return
28 - }
29 - }
30 - }()
31 -}
32 -
33 -// NoopStreamHandler does nothing when stream connects, most
34 -// likely used with RejectAuthHandler which will not allow any
35 -// streams to make it to the stream handler.
36 -func NoOpStreamHandler(stream *Stream) {
37 - stream.SendReply(http.Header{}, false)
38 -}
Godeps/_workspace/src/github.com/docker/spdystream/priority.go deleted
-98
@@ -1,98 +0,0 @@
1 -package spdystream
2 -
3 -import (
4 - "container/heap"
5 - "sync"
6 -
7 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/docker/spdystream/spdy"
8 -)
9 -
10 -type prioritizedFrame struct {
11 - frame spdy.Frame
12 - priority uint8
13 - insertId uint64
14 -}
15 -
16 -type frameQueue []*prioritizedFrame
17 -
18 -func (fq frameQueue) Len() int {
19 - return len(fq)
20 -}
21 -
22 -func (fq frameQueue) Less(i, j int) bool {
23 - if fq[i].priority == fq[j].priority {
24 - return fq[i].insertId < fq[j].insertId
25 - }
26 - return fq[i].priority < fq[j].priority
27 -}
28 -
29 -func (fq frameQueue) Swap(i, j int) {
30 - fq[i], fq[j] = fq[j], fq[i]
31 -}
32 -
33 -func (fq *frameQueue) Push(x interface{}) {
34 - *fq = append(*fq, x.(*prioritizedFrame))
35 -}
36 -
37 -func (fq *frameQueue) Pop() interface{} {
38 - old := *fq
39 - n := len(old)
40 - *fq = old[0 : n-1]
41 - return old[n-1]
42 -}
43 -
44 -type PriorityFrameQueue struct {
45 - queue *frameQueue
46 - c *sync.Cond
47 - size int
48 - nextInsertId uint64
49 - drain bool
50 -}
51 -
52 -func NewPriorityFrameQueue(size int) *PriorityFrameQueue {
53 - queue := make(frameQueue, 0, size)
54 - heap.Init(&queue)
55 -
56 - return &PriorityFrameQueue{
57 - queue: &queue,
58 - size: size,
59 - c: sync.NewCond(&sync.Mutex{}),
60 - }
61 -}
62 -
63 -func (q *PriorityFrameQueue) Push(frame spdy.Frame, priority uint8) {
64 - q.c.L.Lock()
65 - defer q.c.L.Unlock()
66 - for q.queue.Len() >= q.size {
67 - q.c.Wait()
68 - }
69 - pFrame := &prioritizedFrame{
70 - frame: frame,
71 - priority: priority,
72 - insertId: q.nextInsertId,
73 - }
74 - q.nextInsertId = q.nextInsertId + 1
75 - heap.Push(q.queue, pFrame)
76 - q.c.Signal()
77 -}
78 -
79 -func (q *PriorityFrameQueue) Pop() spdy.Frame {
80 - q.c.L.Lock()
81 - defer q.c.L.Unlock()
82 - for q.queue.Len() == 0 {
83 - if q.drain {
84 - return nil
85 - }
86 - q.c.Wait()
87 - }
88 - frame := heap.Pop(q.queue).(*prioritizedFrame).frame
89 - q.c.Signal()
90 - return frame
91 -}
92 -
93 -func (q *PriorityFrameQueue) Drain() {
94 - q.c.L.Lock()
95 - defer q.c.L.Unlock()
96 - q.drain = true
97 - q.c.Broadcast()
98 -}
Godeps/_workspace/src/github.com/docker/spdystream/priority_test.go deleted
-108
@@ -1,108 +0,0 @@
1 -package spdystream
2 -
3 -import (
4 - "sync"
5 - "testing"
6 - "time"
7 -
8 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/docker/spdystream/spdy"
9 -)
10 -
11 -func TestPriorityQueueOrdering(t *testing.T) {
12 - queue := NewPriorityFrameQueue(150)
13 - data1 := &spdy.DataFrame{}
14 - data2 := &spdy.DataFrame{}
15 - data3 := &spdy.DataFrame{}
16 - data4 := &spdy.DataFrame{}
17 - queue.Push(data1, 2)
18 - queue.Push(data2, 1)
19 - queue.Push(data3, 1)
20 - queue.Push(data4, 0)
21 -
22 - if queue.Pop() != data4 {
23 - t.Fatalf("Wrong order, expected data4 first")
24 - }
25 - if queue.Pop() != data2 {
26 - t.Fatalf("Wrong order, expected data2 second")
27 - }
28 - if queue.Pop() != data3 {
29 - t.Fatalf("Wrong order, expected data3 third")
30 - }
31 - if queue.Pop() != data1 {
32 - t.Fatalf("Wrong order, expected data1 fourth")
33 - }
34 -
35 - // Insert 50 Medium priority frames
36 - for i := spdy.StreamId(50); i < 100; i++ {
37 - queue.Push(&spdy.DataFrame{StreamId: i}, 1)
38 - }
39 - // Insert 50 low priority frames
40 - for i := spdy.StreamId(100); i < 150; i++ {
41 - queue.Push(&spdy.DataFrame{StreamId: i}, 2)
42 - }
43 - // Insert 50 high priority frames
44 - for i := spdy.StreamId(0); i < 50; i++ {
45 - queue.Push(&spdy.DataFrame{StreamId: i}, 0)
46 - }
47 -
48 - for i := spdy.StreamId(0); i < 150; i++ {
49 - frame := queue.Pop()
50 - if frame.(*spdy.DataFrame).StreamId != i {
51 - t.Fatalf("Wrong frame\nActual: %d\nExpecting: %d", frame.(*spdy.DataFrame).StreamId, i)
52 - }
53 - }
54 -}
55 -
56 -func TestPriorityQueueSync(t *testing.T) {
57 - queue := NewPriorityFrameQueue(150)
58 - var wg sync.WaitGroup
59 - insertRange := func(start, stop spdy.StreamId, priority uint8) {
60 - for i := start; i < stop; i++ {
61 - queue.Push(&spdy.DataFrame{StreamId: i}, priority)
62 - }
63 - wg.Done()
64 - }
65 - wg.Add(3)
66 - go insertRange(spdy.StreamId(100), spdy.StreamId(150), 2)
67 - go insertRange(spdy.StreamId(0), spdy.StreamId(50), 0)
68 - go insertRange(spdy.StreamId(50), spdy.StreamId(100), 1)
69 -
70 - wg.Wait()
71 - for i := spdy.StreamId(0); i < 150; i++ {
72 - frame := queue.Pop()
73 - if frame.(*spdy.DataFrame).StreamId != i {
74 - t.Fatalf("Wrong frame\nActual: %d\nExpecting: %d", frame.(*spdy.DataFrame).StreamId, i)
75 - }
76 - }
77 -}
78 -
79 -func TestPriorityQueueBlocking(t *testing.T) {
80 - queue := NewPriorityFrameQueue(15)
81 - for i := 0; i < 15; i++ {
82 - queue.Push(&spdy.DataFrame{}, 2)
83 - }
84 - doneChan := make(chan bool)
85 - go func() {
86 - queue.Push(&spdy.DataFrame{}, 2)
87 - close(doneChan)
88 - }()
89 - select {
90 - case <-doneChan:
91 - t.Fatalf("Push succeeded, expected to block")
92 - case <-time.After(time.Millisecond):
93 - break
94 - }
95 -
96 - queue.Pop()
97 -
98 - select {
99 - case <-doneChan:
100 - break
101 - case <-time.After(time.Millisecond):
102 - t.Fatalf("Push should have succeeded, but timeout reached")
103 - }
104 -
105 - for i := 0; i < 15; i++ {
106 - queue.Pop()
107 - }
108 -}
Godeps/_workspace/src/github.com/docker/spdystream/spdy/dictionary.go deleted
-187
@@ -1,187 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package spdy
6 -
7 -// headerDictionary is the dictionary sent to the zlib compressor/decompressor.
8 -var headerDictionary = []byte{
9 - 0x00, 0x00, 0x00, 0x07, 0x6f, 0x70, 0x74, 0x69,
10 - 0x6f, 0x6e, 0x73, 0x00, 0x00, 0x00, 0x04, 0x68,
11 - 0x65, 0x61, 0x64, 0x00, 0x00, 0x00, 0x04, 0x70,
12 - 0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x03, 0x70,
13 - 0x75, 0x74, 0x00, 0x00, 0x00, 0x06, 0x64, 0x65,
14 - 0x6c, 0x65, 0x74, 0x65, 0x00, 0x00, 0x00, 0x05,
15 - 0x74, 0x72, 0x61, 0x63, 0x65, 0x00, 0x00, 0x00,
16 - 0x06, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x00,
17 - 0x00, 0x00, 0x0e, 0x61, 0x63, 0x63, 0x65, 0x70,
18 - 0x74, 0x2d, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65,
19 - 0x74, 0x00, 0x00, 0x00, 0x0f, 0x61, 0x63, 0x63,
20 - 0x65, 0x70, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f,
21 - 0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x0f,
22 - 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x6c,
23 - 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x00,
24 - 0x00, 0x00, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x70,
25 - 0x74, 0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73,
26 - 0x00, 0x00, 0x00, 0x03, 0x61, 0x67, 0x65, 0x00,
27 - 0x00, 0x00, 0x05, 0x61, 0x6c, 0x6c, 0x6f, 0x77,
28 - 0x00, 0x00, 0x00, 0x0d, 0x61, 0x75, 0x74, 0x68,
29 - 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f,
30 - 0x6e, 0x00, 0x00, 0x00, 0x0d, 0x63, 0x61, 0x63,
31 - 0x68, 0x65, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72,
32 - 0x6f, 0x6c, 0x00, 0x00, 0x00, 0x0a, 0x63, 0x6f,
33 - 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
34 - 0x00, 0x00, 0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74,
35 - 0x65, 0x6e, 0x74, 0x2d, 0x62, 0x61, 0x73, 0x65,
36 - 0x00, 0x00, 0x00, 0x10, 0x63, 0x6f, 0x6e, 0x74,
37 - 0x65, 0x6e, 0x74, 0x2d, 0x65, 0x6e, 0x63, 0x6f,
38 - 0x64, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x10,
39 - 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d,
40 - 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65,
41 - 0x00, 0x00, 0x00, 0x0e, 0x63, 0x6f, 0x6e, 0x74,
42 - 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x65, 0x6e, 0x67,
43 - 0x74, 0x68, 0x00, 0x00, 0x00, 0x10, 0x63, 0x6f,
44 - 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x6f,
45 - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00,
46 - 0x00, 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
47 - 0x74, 0x2d, 0x6d, 0x64, 0x35, 0x00, 0x00, 0x00,
48 - 0x0d, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
49 - 0x2d, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00,
50 - 0x00, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
51 - 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x00, 0x00,
52 - 0x00, 0x04, 0x64, 0x61, 0x74, 0x65, 0x00, 0x00,
53 - 0x00, 0x04, 0x65, 0x74, 0x61, 0x67, 0x00, 0x00,
54 - 0x00, 0x06, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74,
55 - 0x00, 0x00, 0x00, 0x07, 0x65, 0x78, 0x70, 0x69,
56 - 0x72, 0x65, 0x73, 0x00, 0x00, 0x00, 0x04, 0x66,
57 - 0x72, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x04, 0x68,
58 - 0x6f, 0x73, 0x74, 0x00, 0x00, 0x00, 0x08, 0x69,
59 - 0x66, 0x2d, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x00,
60 - 0x00, 0x00, 0x11, 0x69, 0x66, 0x2d, 0x6d, 0x6f,
61 - 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x2d, 0x73,
62 - 0x69, 0x6e, 0x63, 0x65, 0x00, 0x00, 0x00, 0x0d,
63 - 0x69, 0x66, 0x2d, 0x6e, 0x6f, 0x6e, 0x65, 0x2d,
64 - 0x6d, 0x61, 0x74, 0x63, 0x68, 0x00, 0x00, 0x00,
65 - 0x08, 0x69, 0x66, 0x2d, 0x72, 0x61, 0x6e, 0x67,
66 - 0x65, 0x00, 0x00, 0x00, 0x13, 0x69, 0x66, 0x2d,
67 - 0x75, 0x6e, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69,
68 - 0x65, 0x64, 0x2d, 0x73, 0x69, 0x6e, 0x63, 0x65,
69 - 0x00, 0x00, 0x00, 0x0d, 0x6c, 0x61, 0x73, 0x74,
70 - 0x2d, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65,
71 - 0x64, 0x00, 0x00, 0x00, 0x08, 0x6c, 0x6f, 0x63,
72 - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00,
73 - 0x0c, 0x6d, 0x61, 0x78, 0x2d, 0x66, 0x6f, 0x72,
74 - 0x77, 0x61, 0x72, 0x64, 0x73, 0x00, 0x00, 0x00,
75 - 0x06, 0x70, 0x72, 0x61, 0x67, 0x6d, 0x61, 0x00,
76 - 0x00, 0x00, 0x12, 0x70, 0x72, 0x6f, 0x78, 0x79,
77 - 0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74,
78 - 0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00,
79 - 0x13, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2d, 0x61,
80 - 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61,
81 - 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x05,
82 - 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x00, 0x00,
83 - 0x07, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72,
84 - 0x00, 0x00, 0x00, 0x0b, 0x72, 0x65, 0x74, 0x72,
85 - 0x79, 0x2d, 0x61, 0x66, 0x74, 0x65, 0x72, 0x00,
86 - 0x00, 0x00, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65,
87 - 0x72, 0x00, 0x00, 0x00, 0x02, 0x74, 0x65, 0x00,
88 - 0x00, 0x00, 0x07, 0x74, 0x72, 0x61, 0x69, 0x6c,
89 - 0x65, 0x72, 0x00, 0x00, 0x00, 0x11, 0x74, 0x72,
90 - 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x2d, 0x65,
91 - 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x00,
92 - 0x00, 0x00, 0x07, 0x75, 0x70, 0x67, 0x72, 0x61,
93 - 0x64, 0x65, 0x00, 0x00, 0x00, 0x0a, 0x75, 0x73,
94 - 0x65, 0x72, 0x2d, 0x61, 0x67, 0x65, 0x6e, 0x74,
95 - 0x00, 0x00, 0x00, 0x04, 0x76, 0x61, 0x72, 0x79,
96 - 0x00, 0x00, 0x00, 0x03, 0x76, 0x69, 0x61, 0x00,
97 - 0x00, 0x00, 0x07, 0x77, 0x61, 0x72, 0x6e, 0x69,
98 - 0x6e, 0x67, 0x00, 0x00, 0x00, 0x10, 0x77, 0x77,
99 - 0x77, 0x2d, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e,
100 - 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x00, 0x00,
101 - 0x00, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64,
102 - 0x00, 0x00, 0x00, 0x03, 0x67, 0x65, 0x74, 0x00,
103 - 0x00, 0x00, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75,
104 - 0x73, 0x00, 0x00, 0x00, 0x06, 0x32, 0x30, 0x30,
105 - 0x20, 0x4f, 0x4b, 0x00, 0x00, 0x00, 0x07, 0x76,
106 - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x00, 0x00,
107 - 0x00, 0x08, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31,
108 - 0x2e, 0x31, 0x00, 0x00, 0x00, 0x03, 0x75, 0x72,
109 - 0x6c, 0x00, 0x00, 0x00, 0x06, 0x70, 0x75, 0x62,
110 - 0x6c, 0x69, 0x63, 0x00, 0x00, 0x00, 0x0a, 0x73,
111 - 0x65, 0x74, 0x2d, 0x63, 0x6f, 0x6f, 0x6b, 0x69,
112 - 0x65, 0x00, 0x00, 0x00, 0x0a, 0x6b, 0x65, 0x65,
113 - 0x70, 0x2d, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x00,
114 - 0x00, 0x00, 0x06, 0x6f, 0x72, 0x69, 0x67, 0x69,
115 - 0x6e, 0x31, 0x30, 0x30, 0x31, 0x30, 0x31, 0x32,
116 - 0x30, 0x31, 0x32, 0x30, 0x32, 0x32, 0x30, 0x35,
117 - 0x32, 0x30, 0x36, 0x33, 0x30, 0x30, 0x33, 0x30,
118 - 0x32, 0x33, 0x30, 0x33, 0x33, 0x30, 0x34, 0x33,
119 - 0x30, 0x35, 0x33, 0x30, 0x36, 0x33, 0x30, 0x37,
120 - 0x34, 0x30, 0x32, 0x34, 0x30, 0x35, 0x34, 0x30,
121 - 0x36, 0x34, 0x30, 0x37, 0x34, 0x30, 0x38, 0x34,
122 - 0x30, 0x39, 0x34, 0x31, 0x30, 0x34, 0x31, 0x31,
123 - 0x34, 0x31, 0x32, 0x34, 0x31, 0x33, 0x34, 0x31,
124 - 0x34, 0x34, 0x31, 0x35, 0x34, 0x31, 0x36, 0x34,
125 - 0x31, 0x37, 0x35, 0x30, 0x32, 0x35, 0x30, 0x34,
126 - 0x35, 0x30, 0x35, 0x32, 0x30, 0x33, 0x20, 0x4e,
127 - 0x6f, 0x6e, 0x2d, 0x41, 0x75, 0x74, 0x68, 0x6f,
128 - 0x72, 0x69, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65,
129 - 0x20, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61,
130 - 0x74, 0x69, 0x6f, 0x6e, 0x32, 0x30, 0x34, 0x20,
131 - 0x4e, 0x6f, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x65,
132 - 0x6e, 0x74, 0x33, 0x30, 0x31, 0x20, 0x4d, 0x6f,
133 - 0x76, 0x65, 0x64, 0x20, 0x50, 0x65, 0x72, 0x6d,
134 - 0x61, 0x6e, 0x65, 0x6e, 0x74, 0x6c, 0x79, 0x34,
135 - 0x30, 0x30, 0x20, 0x42, 0x61, 0x64, 0x20, 0x52,
136 - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x34, 0x30,
137 - 0x31, 0x20, 0x55, 0x6e, 0x61, 0x75, 0x74, 0x68,
138 - 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x34, 0x30,
139 - 0x33, 0x20, 0x46, 0x6f, 0x72, 0x62, 0x69, 0x64,
140 - 0x64, 0x65, 0x6e, 0x34, 0x30, 0x34, 0x20, 0x4e,
141 - 0x6f, 0x74, 0x20, 0x46, 0x6f, 0x75, 0x6e, 0x64,
142 - 0x35, 0x30, 0x30, 0x20, 0x49, 0x6e, 0x74, 0x65,
143 - 0x72, 0x6e, 0x61, 0x6c, 0x20, 0x53, 0x65, 0x72,
144 - 0x76, 0x65, 0x72, 0x20, 0x45, 0x72, 0x72, 0x6f,
145 - 0x72, 0x35, 0x30, 0x31, 0x20, 0x4e, 0x6f, 0x74,
146 - 0x20, 0x49, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65,
147 - 0x6e, 0x74, 0x65, 0x64, 0x35, 0x30, 0x33, 0x20,
148 - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x20,
149 - 0x55, 0x6e, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61,
150 - 0x62, 0x6c, 0x65, 0x4a, 0x61, 0x6e, 0x20, 0x46,
151 - 0x65, 0x62, 0x20, 0x4d, 0x61, 0x72, 0x20, 0x41,
152 - 0x70, 0x72, 0x20, 0x4d, 0x61, 0x79, 0x20, 0x4a,
153 - 0x75, 0x6e, 0x20, 0x4a, 0x75, 0x6c, 0x20, 0x41,
154 - 0x75, 0x67, 0x20, 0x53, 0x65, 0x70, 0x74, 0x20,
155 - 0x4f, 0x63, 0x74, 0x20, 0x4e, 0x6f, 0x76, 0x20,
156 - 0x44, 0x65, 0x63, 0x20, 0x30, 0x30, 0x3a, 0x30,
157 - 0x30, 0x3a, 0x30, 0x30, 0x20, 0x4d, 0x6f, 0x6e,
158 - 0x2c, 0x20, 0x54, 0x75, 0x65, 0x2c, 0x20, 0x57,
159 - 0x65, 0x64, 0x2c, 0x20, 0x54, 0x68, 0x75, 0x2c,
160 - 0x20, 0x46, 0x72, 0x69, 0x2c, 0x20, 0x53, 0x61,
161 - 0x74, 0x2c, 0x20, 0x53, 0x75, 0x6e, 0x2c, 0x20,
162 - 0x47, 0x4d, 0x54, 0x63, 0x68, 0x75, 0x6e, 0x6b,
163 - 0x65, 0x64, 0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f,
164 - 0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x69, 0x6d, 0x61,
165 - 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0x2c, 0x69,
166 - 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x67,
167 - 0x2c, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67,
168 - 0x69, 0x66, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69,
169 - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78,
170 - 0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69,
171 - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78,
172 - 0x68, 0x74, 0x6d, 0x6c, 0x2b, 0x78, 0x6d, 0x6c,
173 - 0x2c, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c,
174 - 0x61, 0x69, 0x6e, 0x2c, 0x74, 0x65, 0x78, 0x74,
175 - 0x2f, 0x6a, 0x61, 0x76, 0x61, 0x73, 0x63, 0x72,
176 - 0x69, 0x70, 0x74, 0x2c, 0x70, 0x75, 0x62, 0x6c,
177 - 0x69, 0x63, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74,
178 - 0x65, 0x6d, 0x61, 0x78, 0x2d, 0x61, 0x67, 0x65,
179 - 0x3d, 0x67, 0x7a, 0x69, 0x70, 0x2c, 0x64, 0x65,
180 - 0x66, 0x6c, 0x61, 0x74, 0x65, 0x2c, 0x73, 0x64,
181 - 0x63, 0x68, 0x63, 0x68, 0x61, 0x72, 0x73, 0x65,
182 - 0x74, 0x3d, 0x75, 0x74, 0x66, 0x2d, 0x38, 0x63,
183 - 0x68, 0x61, 0x72, 0x73, 0x65, 0x74, 0x3d, 0x69,
184 - 0x73, 0x6f, 0x2d, 0x38, 0x38, 0x35, 0x39, 0x2d,
185 - 0x31, 0x2c, 0x75, 0x74, 0x66, 0x2d, 0x2c, 0x2a,
186 - 0x2c, 0x65, 0x6e, 0x71, 0x3d, 0x30, 0x2e,
187 -}
Godeps/_workspace/src/github.com/docker/spdystream/spdy/read.go deleted
-348
@@ -1,348 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package spdy
6 -
7 -import (
8 - "compress/zlib"
9 - "encoding/binary"
10 - "io"
11 - "net/http"
12 - "strings"
13 -)
14 -
15 -func (frame *SynStreamFrame) read(h ControlFrameHeader, f *Framer) error {
16 - return f.readSynStreamFrame(h, frame)
17 -}
18 -
19 -func (frame *SynReplyFrame) read(h ControlFrameHeader, f *Framer) error {
20 - return f.readSynReplyFrame(h, frame)
21 -}
22 -
23 -func (frame *RstStreamFrame) read(h ControlFrameHeader, f *Framer) error {
24 - frame.CFHeader = h
25 - if err := binary.Read(f.r, binary.BigEndian, &frame.StreamId); err != nil {
26 - return err
27 - }
28 - if err := binary.Read(f.r, binary.BigEndian, &frame.Status); err != nil {
29 - return err
30 - }
31 - if frame.Status == 0 {
32 - return &Error{InvalidControlFrame, frame.StreamId}
33 - }
34 - if frame.StreamId == 0 {
35 - return &Error{ZeroStreamId, 0}
36 - }
37 - return nil
38 -}
39 -
40 -func (frame *SettingsFrame) read(h ControlFrameHeader, f *Framer) error {
41 - frame.CFHeader = h
42 - var numSettings uint32
43 - if err := binary.Read(f.r, binary.BigEndian, &numSettings); err != nil {
44 - return err
45 - }
46 - frame.FlagIdValues = make([]SettingsFlagIdValue, numSettings)
47 - for i := uint32(0); i < numSettings; i++ {
48 - if err := binary.Read(f.r, binary.BigEndian, &frame.FlagIdValues[i].Id); err != nil {
49 - return err
50 - }
51 - frame.FlagIdValues[i].Flag = SettingsFlag((frame.FlagIdValues[i].Id & 0xff000000) >> 24)
52 - frame.FlagIdValues[i].Id &= 0xffffff
53 - if err := binary.Read(f.r, binary.BigEndian, &frame.FlagIdValues[i].Value); err != nil {
54 - return err
55 - }
56 - }
57 - return nil
58 -}
59 -
60 -func (frame *PingFrame) read(h ControlFrameHeader, f *Framer) error {
61 - frame.CFHeader = h
62 - if err := binary.Read(f.r, binary.BigEndian, &frame.Id); err != nil {
63 - return err
64 - }
65 - if frame.Id == 0 {
66 - return &Error{ZeroStreamId, 0}
67 - }
68 - if frame.CFHeader.Flags != 0 {
69 - return &Error{InvalidControlFrame, StreamId(frame.Id)}
70 - }
71 - return nil
72 -}
73 -
74 -func (frame *GoAwayFrame) read(h ControlFrameHeader, f *Framer) error {
75 - frame.CFHeader = h
76 - if err := binary.Read(f.r, binary.BigEndian, &frame.LastGoodStreamId); err != nil {
77 - return err
78 - }
79 - if frame.CFHeader.Flags != 0 {
80 - return &Error{InvalidControlFrame, frame.LastGoodStreamId}
81 - }
82 - if frame.CFHeader.length != 8 {
83 - return &Error{InvalidControlFrame, frame.LastGoodStreamId}
84 - }
85 - if err := binary.Read(f.r, binary.BigEndian, &frame.Status); err != nil {
86 - return err
87 - }
88 - return nil
89 -}
90 -
91 -func (frame *HeadersFrame) read(h ControlFrameHeader, f *Framer) error {
92 - return f.readHeadersFrame(h, frame)
93 -}
94 -
95 -func (frame *WindowUpdateFrame) read(h ControlFrameHeader, f *Framer) error {
96 - frame.CFHeader = h
97 - if err := binary.Read(f.r, binary.BigEndian, &frame.StreamId); err != nil {
98 - return err
99 - }
100 - if frame.CFHeader.Flags != 0 {
101 - return &Error{InvalidControlFrame, frame.StreamId}
102 - }
103 - if frame.CFHeader.length != 8 {
104 - return &Error{InvalidControlFrame, frame.StreamId}
105 - }
106 - if err := binary.Read(f.r, binary.BigEndian, &frame.DeltaWindowSize); err != nil {
107 - return err
108 - }
109 - return nil
110 -}
111 -
112 -func newControlFrame(frameType ControlFrameType) (controlFrame, error) {
113 - ctor, ok := cframeCtor[frameType]
114 - if !ok {
115 - return nil, &Error{Err: InvalidControlFrame}
116 - }
117 - return ctor(), nil
118 -}
119 -
120 -var cframeCtor = map[ControlFrameType]func() controlFrame{
121 - TypeSynStream: func() controlFrame { return new(SynStreamFrame) },
122 - TypeSynReply: func() controlFrame { return new(SynReplyFrame) },
123 - TypeRstStream: func() controlFrame { return new(RstStreamFrame) },
124 - TypeSettings: func() controlFrame { return new(SettingsFrame) },
125 - TypePing: func() controlFrame { return new(PingFrame) },
126 - TypeGoAway: func() controlFrame { return new(GoAwayFrame) },
127 - TypeHeaders: func() controlFrame { return new(HeadersFrame) },
128 - TypeWindowUpdate: func() controlFrame { return new(WindowUpdateFrame) },
129 -}
130 -
131 -func (f *Framer) uncorkHeaderDecompressor(payloadSize int64) error {
132 - if f.headerDecompressor != nil {
133 - f.headerReader.N = payloadSize
134 - return nil
135 - }
136 - f.headerReader = io.LimitedReader{R: f.r, N: payloadSize}
137 - decompressor, err := zlib.NewReaderDict(&f.headerReader, []byte(headerDictionary))
138 - if err != nil {
139 - return err
140 - }
141 - f.headerDecompressor = decompressor
142 - return nil
143 -}
144 -
145 -// ReadFrame reads SPDY encoded data and returns a decompressed Frame.
146 -func (f *Framer) ReadFrame() (Frame, error) {
147 - var firstWord uint32
148 - if err := binary.Read(f.r, binary.BigEndian, &firstWord); err != nil {
149 - return nil, err
150 - }
151 - if firstWord&0x80000000 != 0 {
152 - frameType := ControlFrameType(firstWord & 0xffff)
153 - version := uint16(firstWord >> 16 & 0x7fff)
154 - return f.parseControlFrame(version, frameType)
155 - }
156 - return f.parseDataFrame(StreamId(firstWord & 0x7fffffff))
157 -}
158 -
159 -func (f *Framer) parseControlFrame(version uint16, frameType ControlFrameType) (Frame, error) {
160 - var length uint32
161 - if err := binary.Read(f.r, binary.BigEndian, &length); err != nil {
162 - return nil, err
163 - }
164 - flags := ControlFlags((length & 0xff000000) >> 24)
165 - length &= 0xffffff
166 - header := ControlFrameHeader{version, frameType, flags, length}
167 - cframe, err := newControlFrame(frameType)
168 - if err != nil {
169 - return nil, err
170 - }
171 - if err = cframe.read(header, f); err != nil {
172 - return nil, err
173 - }
174 - return cframe, nil
175 -}
176 -
177 -func parseHeaderValueBlock(r io.Reader, streamId StreamId) (http.Header, error) {
178 - var numHeaders uint32
179 - if err := binary.Read(r, binary.BigEndian, &numHeaders); err != nil {
180 - return nil, err
181 - }
182 - var e error
183 - h := make(http.Header, int(numHeaders))
184 - for i := 0; i < int(numHeaders); i++ {
185 - var length uint32
186 - if err := binary.Read(r, binary.BigEndian, &length); err != nil {
187 - return nil, err
188 - }
189 - nameBytes := make([]byte, length)
190 - if _, err := io.ReadFull(r, nameBytes); err != nil {
191 - return nil, err
192 - }
193 - name := string(nameBytes)
194 - if name != strings.ToLower(name) {
195 - e = &Error{UnlowercasedHeaderName, streamId}
196 - name = strings.ToLower(name)
197 - }
198 - if h[name] != nil {
199 - e = &Error{DuplicateHeaders, streamId}
200 - }
201 - if err := binary.Read(r, binary.BigEndian, &length); err != nil {
202 - return nil, err
203 - }
204 - value := make([]byte, length)
205 - if _, err := io.ReadFull(r, value); err != nil {
206 - return nil, err
207 - }
208 - valueList := strings.Split(string(value), headerValueSeparator)
209 - for _, v := range valueList {
210 - h.Add(name, v)
211 - }
212 - }
213 - if e != nil {
214 - return h, e
215 - }
216 - return h, nil
217 -}
218 -
219 -func (f *Framer) readSynStreamFrame(h ControlFrameHeader, frame *SynStreamFrame) error {
220 - frame.CFHeader = h
221 - var err error
222 - if err = binary.Read(f.r, binary.BigEndian, &frame.StreamId); err != nil {
223 - return err
224 - }
225 - if err = binary.Read(f.r, binary.BigEndian, &frame.AssociatedToStreamId); err != nil {
226 - return err
227 - }
228 - if err = binary.Read(f.r, binary.BigEndian, &frame.Priority); err != nil {
229 - return err
230 - }
231 - frame.Priority >>= 5
232 - if err = binary.Read(f.r, binary.BigEndian, &frame.Slot); err != nil {
233 - return err
234 - }
235 - reader := f.r
236 - if !f.headerCompressionDisabled {
237 - err := f.uncorkHeaderDecompressor(int64(h.length - 10))
238 - if err != nil {
239 - return err
240 - }
241 - reader = f.headerDecompressor
242 - }
243 - frame.Headers, err = parseHeaderValueBlock(reader, frame.StreamId)
244 - if !f.headerCompressionDisabled && (err == io.EOF && f.headerReader.N == 0 || f.headerReader.N != 0) {
245 - err = &Error{WrongCompressedPayloadSize, 0}
246 - }
247 - if err != nil {
248 - return err
249 - }
250 - for h := range frame.Headers {
251 - if invalidReqHeaders[h] {
252 - return &Error{InvalidHeaderPresent, frame.StreamId}
253 - }
254 - }
255 - if frame.StreamId == 0 {
256 - return &Error{ZeroStreamId, 0}
257 - }
258 - return nil
259 -}
260 -
261 -func (f *Framer) readSynReplyFrame(h ControlFrameHeader, frame *SynReplyFrame) error {
262 - frame.CFHeader = h
263 - var err error
264 - if err = binary.Read(f.r, binary.BigEndian, &frame.StreamId); err != nil {
265 - return err
266 - }
267 - reader := f.r
268 - if !f.headerCompressionDisabled {
269 - err := f.uncorkHeaderDecompressor(int64(h.length - 4))
270 - if err != nil {
271 - return err
272 - }
273 - reader = f.headerDecompressor
274 - }
275 - frame.Headers, err = parseHeaderValueBlock(reader, frame.StreamId)
276 - if !f.headerCompressionDisabled && (err == io.EOF && f.headerReader.N == 0 || f.headerReader.N != 0) {
277 - err = &Error{WrongCompressedPayloadSize, 0}
278 - }
279 - if err != nil {
280 - return err
281 - }
282 - for h := range frame.Headers {
283 - if invalidRespHeaders[h] {
284 - return &Error{InvalidHeaderPresent, frame.StreamId}
285 - }
286 - }
287 - if frame.StreamId == 0 {
288 - return &Error{ZeroStreamId, 0}
289 - }
290 - return nil
291 -}
292 -
293 -func (f *Framer) readHeadersFrame(h ControlFrameHeader, frame *HeadersFrame) error {
294 - frame.CFHeader = h
295 - var err error
296 - if err = binary.Read(f.r, binary.BigEndian, &frame.StreamId); err != nil {
297 - return err
298 - }
299 - reader := f.r
300 - if !f.headerCompressionDisabled {
301 - err := f.uncorkHeaderDecompressor(int64(h.length - 4))
302 - if err != nil {
303 - return err
304 - }
305 - reader = f.headerDecompressor
306 - }
307 - frame.Headers, err = parseHeaderValueBlock(reader, frame.StreamId)
308 - if !f.headerCompressionDisabled && (err == io.EOF && f.headerReader.N == 0 || f.headerReader.N != 0) {
309 - err = &Error{WrongCompressedPayloadSize, 0}
310 - }
311 - if err != nil {
312 - return err
313 - }
314 - var invalidHeaders map[string]bool
315 - if frame.StreamId%2 == 0 {
316 - invalidHeaders = invalidReqHeaders
317 - } else {
318 - invalidHeaders = invalidRespHeaders
319 - }
320 - for h := range frame.Headers {
321 - if invalidHeaders[h] {
322 - return &Error{InvalidHeaderPresent, frame.StreamId}
323 - }
324 - }
325 - if frame.StreamId == 0 {
326 - return &Error{ZeroStreamId, 0}
327 - }
328 - return nil
329 -}
330 -
331 -func (f *Framer) parseDataFrame(streamId StreamId) (*DataFrame, error) {
332 - var length uint32
333 - if err := binary.Read(f.r, binary.BigEndian, &length); err != nil {
334 - return nil, err
335 - }
336 - var frame DataFrame
337 - frame.StreamId = streamId
338 - frame.Flags = DataFlags(length >> 24)
339 - length &= 0xffffff
340 - frame.Data = make([]byte, length)
341 - if _, err := io.ReadFull(f.r, frame.Data); err != nil {
342 - return nil, err
343 - }
344 - if frame.StreamId == 0 {
345 - return nil, &Error{ZeroStreamId, 0}
346 - }
347 - return &frame, nil
348 -}
Godeps/_workspace/src/github.com/docker/spdystream/spdy/spdy_test.go deleted
-644
@@ -1,644 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package spdy
6 -
7 -import (
8 - "bytes"
9 - "compress/zlib"
10 - "encoding/base64"
11 - "io"
12 - "io/ioutil"
13 - "net/http"
14 - "reflect"
15 - "testing"
16 -)
17 -
18 -var HeadersFixture = http.Header{
19 - "Url": []string{"http://www.google.com/"},
20 - "Method": []string{"get"},
21 - "Version": []string{"http/1.1"},
22 -}
23 -
24 -func TestHeaderParsing(t *testing.T) {
25 - var headerValueBlockBuf bytes.Buffer
26 - writeHeaderValueBlock(&headerValueBlockBuf, HeadersFixture)
27 - const bogusStreamId = 1
28 - newHeaders, err := parseHeaderValueBlock(&headerValueBlockBuf, bogusStreamId)
29 - if err != nil {
30 - t.Fatal("parseHeaderValueBlock:", err)
31 - }
32 - if !reflect.DeepEqual(HeadersFixture, newHeaders) {
33 - t.Fatal("got: ", newHeaders, "\nwant: ", HeadersFixture)
34 - }
35 -}
36 -
37 -func TestCreateParseSynStreamFrameCompressionDisable(t *testing.T) {
38 - buffer := new(bytes.Buffer)
39 - // Fixture framer for no compression test.
40 - framer := &Framer{
41 - headerCompressionDisabled: true,
42 - w: buffer,
43 - headerBuf: new(bytes.Buffer),
44 - r: buffer,
45 - }
46 - synStreamFrame := SynStreamFrame{
47 - CFHeader: ControlFrameHeader{
48 - version: Version,
49 - frameType: TypeSynStream,
50 - },
51 - StreamId: 2,
52 - Headers: HeadersFixture,
53 - }
54 - if err := framer.WriteFrame(&synStreamFrame); err != nil {
55 - t.Fatal("WriteFrame without compression:", err)
56 - }
57 - frame, err := framer.ReadFrame()
58 - if err != nil {
59 - t.Fatal("ReadFrame without compression:", err)
60 - }
61 - parsedSynStreamFrame, ok := frame.(*SynStreamFrame)
62 - if !ok {
63 - t.Fatal("Parsed incorrect frame type:", frame)
64 - }
65 - if !reflect.DeepEqual(synStreamFrame, *parsedSynStreamFrame) {
66 - t.Fatal("got: ", *parsedSynStreamFrame, "\nwant: ", synStreamFrame)
67 - }
68 -}
69 -
70 -func TestCreateParseSynStreamFrameCompressionEnable(t *testing.T) {
71 - buffer := new(bytes.Buffer)
72 - framer, err := NewFramer(buffer, buffer)
73 - synStreamFrame := SynStreamFrame{
74 - CFHeader: ControlFrameHeader{
75 - version: Version,
76 - frameType: TypeSynStream,
77 - },
78 - StreamId: 2,
79 - Headers: HeadersFixture,
80 - }
81 - if err != nil {
82 - t.Fatal("Failed to create new framer:", err)
83 - }
84 - if err := framer.WriteFrame(&synStreamFrame); err != nil {
85 - t.Fatal("WriteFrame with compression:", err)
86 - }
87 - frame, err := framer.ReadFrame()
88 - if err != nil {
89 - t.Fatal("ReadFrame with compression:", err)
90 - }
91 - parsedSynStreamFrame, ok := frame.(*SynStreamFrame)
92 - if !ok {
93 - t.Fatal("Parsed incorrect frame type:", frame)
94 - }
95 - if !reflect.DeepEqual(synStreamFrame, *parsedSynStreamFrame) {
96 - t.Fatal("got: ", *parsedSynStreamFrame, "\nwant: ", synStreamFrame)
97 - }
98 -}
99 -
100 -func TestCreateParseSynReplyFrameCompressionDisable(t *testing.T) {
101 - buffer := new(bytes.Buffer)
102 - framer := &Framer{
103 - headerCompressionDisabled: true,
104 - w: buffer,
105 - headerBuf: new(bytes.Buffer),
106 - r: buffer,
107 - }
108 - synReplyFrame := SynReplyFrame{
109 - CFHeader: ControlFrameHeader{
110 - version: Version,
111 - frameType: TypeSynReply,
112 - },
113 - StreamId: 2,
114 - Headers: HeadersFixture,
115 - }
116 - if err := framer.WriteFrame(&synReplyFrame); err != nil {
117 - t.Fatal("WriteFrame without compression:", err)
118 - }
119 - frame, err := framer.ReadFrame()
120 - if err != nil {
121 - t.Fatal("ReadFrame without compression:", err)
122 - }
123 - parsedSynReplyFrame, ok := frame.(*SynReplyFrame)
124 - if !ok {
125 - t.Fatal("Parsed incorrect frame type:", frame)
126 - }
127 - if !reflect.DeepEqual(synReplyFrame, *parsedSynReplyFrame) {
128 - t.Fatal("got: ", *parsedSynReplyFrame, "\nwant: ", synReplyFrame)
129 - }
130 -}
131 -
132 -func TestCreateParseSynReplyFrameCompressionEnable(t *testing.T) {
133 - buffer := new(bytes.Buffer)
134 - framer, err := NewFramer(buffer, buffer)
135 - synReplyFrame := SynReplyFrame{
136 - CFHeader: ControlFrameHeader{
137 - version: Version,
138 - frameType: TypeSynReply,
139 - },
140 - StreamId: 2,
141 - Headers: HeadersFixture,
142 - }
143 - if err != nil {
144 - t.Fatal("Failed to create new framer:", err)
145 - }
146 - if err := framer.WriteFrame(&synReplyFrame); err != nil {
147 - t.Fatal("WriteFrame with compression:", err)
148 - }
149 - frame, err := framer.ReadFrame()
150 - if err != nil {
151 - t.Fatal("ReadFrame with compression:", err)
152 - }
153 - parsedSynReplyFrame, ok := frame.(*SynReplyFrame)
154 - if !ok {
155 - t.Fatal("Parsed incorrect frame type:", frame)
156 - }
157 - if !reflect.DeepEqual(synReplyFrame, *parsedSynReplyFrame) {
158 - t.Fatal("got: ", *parsedSynReplyFrame, "\nwant: ", synReplyFrame)
159 - }
160 -}
161 -
162 -func TestCreateParseRstStream(t *testing.T) {
163 - buffer := new(bytes.Buffer)
164 - framer, err := NewFramer(buffer, buffer)
165 - if err != nil {
166 - t.Fatal("Failed to create new framer:", err)
167 - }
168 - rstStreamFrame := RstStreamFrame{
169 - CFHeader: ControlFrameHeader{
170 - version: Version,
171 - frameType: TypeRstStream,
172 - },
173 - StreamId: 1,
174 - Status: InvalidStream,
175 - }
176 - if err := framer.WriteFrame(&rstStreamFrame); err != nil {
177 - t.Fatal("WriteFrame:", err)
178 - }
179 - frame, err := framer.ReadFrame()
180 - if err != nil {
181 - t.Fatal("ReadFrame:", err)
182 - }
183 - parsedRstStreamFrame, ok := frame.(*RstStreamFrame)
184 - if !ok {
185 - t.Fatal("Parsed incorrect frame type:", frame)
186 - }
187 - if !reflect.DeepEqual(rstStreamFrame, *parsedRstStreamFrame) {
188 - t.Fatal("got: ", *parsedRstStreamFrame, "\nwant: ", rstStreamFrame)
189 - }
190 -}
191 -
192 -func TestCreateParseSettings(t *testing.T) {
193 - buffer := new(bytes.Buffer)
194 - framer, err := NewFramer(buffer, buffer)
195 - if err != nil {
196 - t.Fatal("Failed to create new framer:", err)
197 - }
198 - settingsFrame := SettingsFrame{
199 - CFHeader: ControlFrameHeader{
200 - version: Version,
201 - frameType: TypeSettings,
202 - },
203 - FlagIdValues: []SettingsFlagIdValue{
204 - {FlagSettingsPersistValue, SettingsCurrentCwnd, 10},
205 - {FlagSettingsPersisted, SettingsUploadBandwidth, 1},
206 - },
207 - }
208 - if err := framer.WriteFrame(&settingsFrame); err != nil {
209 - t.Fatal("WriteFrame:", err)
210 - }
211 - frame, err := framer.ReadFrame()
212 - if err != nil {
213 - t.Fatal("ReadFrame:", err)
214 - }
215 - parsedSettingsFrame, ok := frame.(*SettingsFrame)
216 - if !ok {
217 - t.Fatal("Parsed incorrect frame type:", frame)
218 - }
219 - if !reflect.DeepEqual(settingsFrame, *parsedSettingsFrame) {
220 - t.Fatal("got: ", *parsedSettingsFrame, "\nwant: ", settingsFrame)
221 - }
222 -}
223 -
224 -func TestCreateParsePing(t *testing.T) {
225 - buffer := new(bytes.Buffer)
226 - framer, err := NewFramer(buffer, buffer)
227 - if err != nil {
228 - t.Fatal("Failed to create new framer:", err)
229 - }
230 - pingFrame := PingFrame{
231 - CFHeader: ControlFrameHeader{
232 - version: Version,
233 - frameType: TypePing,
234 - },
235 - Id: 31337,
236 - }
237 - if err := framer.WriteFrame(&pingFrame); err != nil {
238 - t.Fatal("WriteFrame:", err)
239 - }
240 - if pingFrame.CFHeader.Flags != 0 {
241 - t.Fatal("Incorrect frame type:", pingFrame)
242 - }
243 - frame, err := framer.ReadFrame()
244 - if err != nil {
245 - t.Fatal("ReadFrame:", err)
246 - }
247 - parsedPingFrame, ok := frame.(*PingFrame)
248 - if !ok {
249 - t.Fatal("Parsed incorrect frame type:", frame)
250 - }
251 - if parsedPingFrame.CFHeader.Flags != 0 {
252 - t.Fatal("Parsed incorrect frame type:", parsedPingFrame)
253 - }
254 - if !reflect.DeepEqual(pingFrame, *parsedPingFrame) {
255 - t.Fatal("got: ", *parsedPingFrame, "\nwant: ", pingFrame)
256 - }
257 -}
258 -
259 -func TestCreateParseGoAway(t *testing.T) {
260 - buffer := new(bytes.Buffer)
261 - framer, err := NewFramer(buffer, buffer)
262 - if err != nil {
263 - t.Fatal("Failed to create new framer:", err)
264 - }
265 - goAwayFrame := GoAwayFrame{
266 - CFHeader: ControlFrameHeader{
267 - version: Version,
268 - frameType: TypeGoAway,
269 - },
270 - LastGoodStreamId: 31337,
271 - Status: 1,
272 - }
273 - if err := framer.WriteFrame(&goAwayFrame); err != nil {
274 - t.Fatal("WriteFrame:", err)
275 - }
276 - if goAwayFrame.CFHeader.Flags != 0 {
277 - t.Fatal("Incorrect frame type:", goAwayFrame)
278 - }
279 - if goAwayFrame.CFHeader.length != 8 {
280 - t.Fatal("Incorrect frame type:", goAwayFrame)
281 - }
282 - frame, err := framer.ReadFrame()
283 - if err != nil {
284 - t.Fatal("ReadFrame:", err)
285 - }
286 - parsedGoAwayFrame, ok := frame.(*GoAwayFrame)
287 - if !ok {
288 - t.Fatal("Parsed incorrect frame type:", frame)
289 - }
290 - if parsedGoAwayFrame.CFHeader.Flags != 0 {
291 - t.Fatal("Incorrect frame type:", parsedGoAwayFrame)
292 - }
293 - if parsedGoAwayFrame.CFHeader.length != 8 {
294 - t.Fatal("Incorrect frame type:", parsedGoAwayFrame)
295 - }
296 - if !reflect.DeepEqual(goAwayFrame, *parsedGoAwayFrame) {
297 - t.Fatal("got: ", *parsedGoAwayFrame, "\nwant: ", goAwayFrame)
298 - }
299 -}
300 -
301 -func TestCreateParseHeadersFrame(t *testing.T) {
302 - buffer := new(bytes.Buffer)
303 - framer := &Framer{
304 - headerCompressionDisabled: true,
305 - w: buffer,
306 - headerBuf: new(bytes.Buffer),
307 - r: buffer,
308 - }
309 - headersFrame := HeadersFrame{
310 - CFHeader: ControlFrameHeader{
311 - version: Version,
312 - frameType: TypeHeaders,
313 - },
314 - StreamId: 2,
315 - }
316 - headersFrame.Headers = HeadersFixture
317 - if err := framer.WriteFrame(&headersFrame); err != nil {
318 - t.Fatal("WriteFrame without compression:", err)
319 - }
320 - frame, err := framer.ReadFrame()
321 - if err != nil {
322 - t.Fatal("ReadFrame without compression:", err)
323 - }
324 - parsedHeadersFrame, ok := frame.(*HeadersFrame)
325 - if !ok {
326 - t.Fatal("Parsed incorrect frame type:", frame)
327 - }
328 - if !reflect.DeepEqual(headersFrame, *parsedHeadersFrame) {
329 - t.Fatal("got: ", *parsedHeadersFrame, "\nwant: ", headersFrame)
330 - }
331 -}
332 -
333 -func TestCreateParseHeadersFrameCompressionEnable(t *testing.T) {
334 - buffer := new(bytes.Buffer)
335 - headersFrame := HeadersFrame{
336 - CFHeader: ControlFrameHeader{
337 - version: Version,
338 - frameType: TypeHeaders,
339 - },
340 - StreamId: 2,
341 - }
342 - headersFrame.Headers = HeadersFixture
343 -
344 - framer, err := NewFramer(buffer, buffer)
345 - if err := framer.WriteFrame(&headersFrame); err != nil {
346 - t.Fatal("WriteFrame with compression:", err)
347 - }
348 - frame, err := framer.ReadFrame()
349 - if err != nil {
350 - t.Fatal("ReadFrame with compression:", err)
351 - }
352 - parsedHeadersFrame, ok := frame.(*HeadersFrame)
353 - if !ok {
354 - t.Fatal("Parsed incorrect frame type:", frame)
355 - }
356 - if !reflect.DeepEqual(headersFrame, *parsedHeadersFrame) {
357 - t.Fatal("got: ", *parsedHeadersFrame, "\nwant: ", headersFrame)
358 - }
359 -}
360 -
361 -func TestCreateParseWindowUpdateFrame(t *testing.T) {
362 - buffer := new(bytes.Buffer)
363 - framer, err := NewFramer(buffer, buffer)
364 - if err != nil {
365 - t.Fatal("Failed to create new framer:", err)
366 - }
367 - windowUpdateFrame := WindowUpdateFrame{
368 - CFHeader: ControlFrameHeader{
369 - version: Version,
370 - frameType: TypeWindowUpdate,
371 - },
372 - StreamId: 31337,
373 - DeltaWindowSize: 1,
374 - }
375 - if err := framer.WriteFrame(&windowUpdateFrame); err != nil {
376 - t.Fatal("WriteFrame:", err)
377 - }
378 - if windowUpdateFrame.CFHeader.Flags != 0 {
379 - t.Fatal("Incorrect frame type:", windowUpdateFrame)
380 - }
381 - if windowUpdateFrame.CFHeader.length != 8 {
382 - t.Fatal("Incorrect frame type:", windowUpdateFrame)
383 - }
384 - frame, err := framer.ReadFrame()
385 - if err != nil {
386 - t.Fatal("ReadFrame:", err)
387 - }
388 - parsedWindowUpdateFrame, ok := frame.(*WindowUpdateFrame)
389 - if !ok {
390 - t.Fatal("Parsed incorrect frame type:", frame)
391 - }
392 - if parsedWindowUpdateFrame.CFHeader.Flags != 0 {
393 - t.Fatal("Incorrect frame type:", parsedWindowUpdateFrame)
394 - }
395 - if parsedWindowUpdateFrame.CFHeader.length != 8 {
396 - t.Fatal("Incorrect frame type:", parsedWindowUpdateFrame)
397 - }
398 - if !reflect.DeepEqual(windowUpdateFrame, *parsedWindowUpdateFrame) {
399 - t.Fatal("got: ", *parsedWindowUpdateFrame, "\nwant: ", windowUpdateFrame)
400 - }
401 -}
402 -
403 -func TestCreateParseDataFrame(t *testing.T) {
404 - buffer := new(bytes.Buffer)
405 - framer, err := NewFramer(buffer, buffer)
406 - if err != nil {
407 - t.Fatal("Failed to create new framer:", err)
408 - }
409 - dataFrame := DataFrame{
410 - StreamId: 1,
411 - Data: []byte{'h', 'e', 'l', 'l', 'o'},
412 - }
413 - if err := framer.WriteFrame(&dataFrame); err != nil {
414 - t.Fatal("WriteFrame:", err)
415 - }
416 - frame, err := framer.ReadFrame()
417 - if err != nil {
418 - t.Fatal("ReadFrame:", err)
419 - }
420 - parsedDataFrame, ok := frame.(*DataFrame)
421 - if !ok {
422 - t.Fatal("Parsed incorrect frame type:", frame)
423 - }
424 - if !reflect.DeepEqual(dataFrame, *parsedDataFrame) {
425 - t.Fatal("got: ", *parsedDataFrame, "\nwant: ", dataFrame)
426 - }
427 -}
428 -
429 -func TestCompressionContextAcrossFrames(t *testing.T) {
430 - buffer := new(bytes.Buffer)
431 - framer, err := NewFramer(buffer, buffer)
432 - if err != nil {
433 - t.Fatal("Failed to create new framer:", err)
434 - }
435 - headersFrame := HeadersFrame{
436 - CFHeader: ControlFrameHeader{
437 - version: Version,
438 - frameType: TypeHeaders,
439 - },
440 - StreamId: 2,
441 - Headers: HeadersFixture,
442 - }
443 - if err := framer.WriteFrame(&headersFrame); err != nil {
444 - t.Fatal("WriteFrame (HEADERS):", err)
445 - }
446 - synStreamFrame := SynStreamFrame{
447 - ControlFrameHeader{
448 - Version,
449 - TypeSynStream,
450 - 0, // Flags
451 - 0, // length
452 - },
453 - 2, // StreamId
454 - 0, // AssociatedTOStreamID
455 - 0, // Priority
456 - 1, // Slot
457 - nil, // Headers
458 - }
459 - synStreamFrame.Headers = HeadersFixture
460 -
461 - if err := framer.WriteFrame(&synStreamFrame); err != nil {
462 - t.Fatal("WriteFrame (SYN_STREAM):", err)
463 - }
464 - frame, err := framer.ReadFrame()
465 - if err != nil {
466 - t.Fatal("ReadFrame (HEADERS):", err, buffer.Bytes())
467 - }
468 - parsedHeadersFrame, ok := frame.(*HeadersFrame)
469 - if !ok {
470 - t.Fatalf("expected HeadersFrame; got %T %v", frame, frame)
471 - }
472 - if !reflect.DeepEqual(headersFrame, *parsedHeadersFrame) {
473 - t.Fatal("got: ", *parsedHeadersFrame, "\nwant: ", headersFrame)
474 - }
475 - frame, err = framer.ReadFrame()
476 - if err != nil {
477 - t.Fatal("ReadFrame (SYN_STREAM):", err, buffer.Bytes())
478 - }
479 - parsedSynStreamFrame, ok := frame.(*SynStreamFrame)
480 - if !ok {
481 - t.Fatalf("expected SynStreamFrame; got %T %v", frame, frame)
482 - }
483 - if !reflect.DeepEqual(synStreamFrame, *parsedSynStreamFrame) {
484 - t.Fatal("got: ", *parsedSynStreamFrame, "\nwant: ", synStreamFrame)
485 - }
486 -}
487 -
488 -func TestMultipleSPDYFrames(t *testing.T) {
489 - // Initialize the framers.
490 - pr1, pw1 := io.Pipe()
491 - pr2, pw2 := io.Pipe()
492 - writer, err := NewFramer(pw1, pr2)
493 - if err != nil {
494 - t.Fatal("Failed to create writer:", err)
495 - }
496 - reader, err := NewFramer(pw2, pr1)
497 - if err != nil {
498 - t.Fatal("Failed to create reader:", err)
499 - }
500 -
501 - // Set up the frames we're actually transferring.
502 - headersFrame := HeadersFrame{
503 - CFHeader: ControlFrameHeader{
504 - version: Version,
505 - frameType: TypeHeaders,
506 - },
507 - StreamId: 2,
508 - Headers: HeadersFixture,
509 - }
510 - synStreamFrame := SynStreamFrame{
511 - CFHeader: ControlFrameHeader{
512 - version: Version,
513 - frameType: TypeSynStream,
514 - },
515 - StreamId: 2,
516 - Headers: HeadersFixture,
517 - }
518 -
519 - // Start the goroutines to write the frames.
520 - go func() {
521 - if err := writer.WriteFrame(&headersFrame); err != nil {
522 - t.Fatal("WriteFrame (HEADERS): ", err)
523 - }
524 - if err := writer.WriteFrame(&synStreamFrame); err != nil {
525 - t.Fatal("WriteFrame (SYN_STREAM): ", err)
526 - }
527 - }()
528 -
529 - // Read the frames and verify they look as expected.
530 - frame, err := reader.ReadFrame()
531 - if err != nil {
532 - t.Fatal("ReadFrame (HEADERS): ", err)
533 - }
534 - parsedHeadersFrame, ok := frame.(*HeadersFrame)
535 - if !ok {
536 - t.Fatal("Parsed incorrect frame type:", frame)
537 - }
538 - if !reflect.DeepEqual(headersFrame, *parsedHeadersFrame) {
539 - t.Fatal("got: ", *parsedHeadersFrame, "\nwant: ", headersFrame)
540 - }
541 - frame, err = reader.ReadFrame()
542 - if err != nil {
543 - t.Fatal("ReadFrame (SYN_STREAM):", err)
544 - }
545 - parsedSynStreamFrame, ok := frame.(*SynStreamFrame)
546 - if !ok {
547 - t.Fatal("Parsed incorrect frame type.")
548 - }
549 - if !reflect.DeepEqual(synStreamFrame, *parsedSynStreamFrame) {
550 - t.Fatal("got: ", *parsedSynStreamFrame, "\nwant: ", synStreamFrame)
551 - }
552 -}
553 -
554 -func TestReadMalformedZlibHeader(t *testing.T) {
555 - // These were constructed by corrupting the first byte of the zlib
556 - // header after writing.
557 - malformedStructs := map[string]string{
558 - "SynStreamFrame": "gAIAAQAAABgAAAACAAAAAAAAF/nfolGyYmAAAAAA//8=",
559 - "SynReplyFrame": "gAIAAgAAABQAAAACAAAX+d+iUbJiYAAAAAD//w==",
560 - "HeadersFrame": "gAIACAAAABQAAAACAAAX+d+iUbJiYAAAAAD//w==",
561 - }
562 - for name, bad := range malformedStructs {
563 - b, err := base64.StdEncoding.DecodeString(bad)
564 - if err != nil {
565 - t.Errorf("Unable to decode base64 encoded frame %s: %v", name, err)
566 - }
567 - buf := bytes.NewBuffer(b)
568 - reader, err := NewFramer(buf, buf)
569 - if err != nil {
570 - t.Fatalf("NewFramer: %v", err)
571 - }
572 - _, err = reader.ReadFrame()
573 - if err != zlib.ErrHeader {
574 - t.Errorf("Frame %s, expected: %#v, actual: %#v", name, zlib.ErrHeader, err)
575 - }
576 - }
577 -}
578 -
579 -// TODO: these tests are too weak for updating SPDY spec. Fix me.
580 -
581 -type zeroStream struct {
582 - frame Frame
583 - encoded string
584 -}
585 -
586 -var streamIdZeroFrames = map[string]zeroStream{
587 - "SynStreamFrame": {
588 - &SynStreamFrame{StreamId: 0},
589 - "gAIAAQAAABgAAAAAAAAAAAAAePnfolGyYmAAAAAA//8=",
590 - },
591 - "SynReplyFrame": {
592 - &SynReplyFrame{StreamId: 0},
593 - "gAIAAgAAABQAAAAAAAB4+d+iUbJiYAAAAAD//w==",
594 - },
595 - "RstStreamFrame": {
596 - &RstStreamFrame{StreamId: 0},
597 - "gAIAAwAAAAgAAAAAAAAAAA==",
598 - },
599 - "HeadersFrame": {
600 - &HeadersFrame{StreamId: 0},
601 - "gAIACAAAABQAAAAAAAB4+d+iUbJiYAAAAAD//w==",
602 - },
603 - "DataFrame": {
604 - &DataFrame{StreamId: 0},
605 - "AAAAAAAAAAA=",
606 - },
607 - "PingFrame": {
608 - &PingFrame{Id: 0},
609 - "gAIABgAAAAQAAAAA",
610 - },
611 -}
612 -
613 -func TestNoZeroStreamId(t *testing.T) {
614 - t.Log("skipping") // TODO: update to work with SPDY3
615 - return
616 -
617 - for name, f := range streamIdZeroFrames {
618 - b, err := base64.StdEncoding.DecodeString(f.encoded)
619 - if err != nil {
620 - t.Errorf("Unable to decode base64 encoded frame %s: %v", f, err)
621 - continue
622 - }
623 - framer, err := NewFramer(ioutil.Discard, bytes.NewReader(b))
624 - if err != nil {
625 - t.Fatalf("NewFramer: %v", err)
626 - }
627 - err = framer.WriteFrame(f.frame)
628 - checkZeroStreamId(t, name, "WriteFrame", err)
629 -
630 - _, err = framer.ReadFrame()
631 - checkZeroStreamId(t, name, "ReadFrame", err)
632 - }
633 -}
634 -
635 -func checkZeroStreamId(t *testing.T, frame string, method string, err error) {
636 - if err == nil {
637 - t.Errorf("%s ZeroStreamId, no error on %s", method, frame)
638 - return
639 - }
640 - eerr, ok := err.(*Error)
641 - if !ok || eerr.Err != ZeroStreamId {
642 - t.Errorf("%s ZeroStreamId, incorrect error %#v, frame %s", method, eerr, frame)
643 - }
644 -}
Godeps/_workspace/src/github.com/docker/spdystream/spdy/types.go deleted
-275
@@ -1,275 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// Package spdy implements the SPDY protocol (currently SPDY/3), described in
6 -// http://www.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3.
7 -package spdy
8 -
9 -import (
10 - "bytes"
11 - "compress/zlib"
12 - "io"
13 - "net/http"
14 -)
15 -
16 -// Version is the protocol version number that this package implements.
17 -const Version = 3
18 -
19 -// ControlFrameType stores the type field in a control frame header.
20 -type ControlFrameType uint16
21 -
22 -const (
23 - TypeSynStream ControlFrameType = 0x0001
24 - TypeSynReply = 0x0002
25 - TypeRstStream = 0x0003
26 - TypeSettings = 0x0004
27 - TypePing = 0x0006
28 - TypeGoAway = 0x0007
29 - TypeHeaders = 0x0008
30 - TypeWindowUpdate = 0x0009
31 -)
32 -
33 -// ControlFlags are the flags that can be set on a control frame.
34 -type ControlFlags uint8
35 -
36 -const (
37 - ControlFlagFin ControlFlags = 0x01
38 - ControlFlagUnidirectional = 0x02
39 - ControlFlagSettingsClearSettings = 0x01
40 -)
41 -
42 -// DataFlags are the flags that can be set on a data frame.
43 -type DataFlags uint8
44 -
45 -const (
46 - DataFlagFin DataFlags = 0x01
47 -)
48 -
49 -// MaxDataLength is the maximum number of bytes that can be stored in one frame.
50 -const MaxDataLength = 1<<24 - 1
51 -
52 -// headerValueSepator separates multiple header values.
53 -const headerValueSeparator = "\x00"
54 -
55 -// Frame is a single SPDY frame in its unpacked in-memory representation. Use
56 -// Framer to read and write it.
57 -type Frame interface {
58 - write(f *Framer) error
59 -}
60 -
61 -// ControlFrameHeader contains all the fields in a control frame header,
62 -// in its unpacked in-memory representation.
63 -type ControlFrameHeader struct {
64 - // Note, high bit is the "Control" bit.
65 - version uint16 // spdy version number
66 - frameType ControlFrameType
67 - Flags ControlFlags
68 - length uint32 // length of data field
69 -}
70 -
71 -type controlFrame interface {
72 - Frame
73 - read(h ControlFrameHeader, f *Framer) error
74 -}
75 -
76 -// StreamId represents a 31-bit value identifying the stream.
77 -type StreamId uint32
78 -
79 -// SynStreamFrame is the unpacked, in-memory representation of a SYN_STREAM
80 -// frame.
81 -type SynStreamFrame struct {
82 - CFHeader ControlFrameHeader
83 - StreamId StreamId
84 - AssociatedToStreamId StreamId // stream id for a stream which this stream is associated to
85 - Priority uint8 // priority of this frame (3-bit)
86 - Slot uint8 // index in the server's credential vector of the client certificate
87 - Headers http.Header
88 -}
89 -
90 -// SynReplyFrame is the unpacked, in-memory representation of a SYN_REPLY frame.
91 -type SynReplyFrame struct {
92 - CFHeader ControlFrameHeader
93 - StreamId StreamId
94 - Headers http.Header
95 -}
96 -
97 -// RstStreamStatus represents the status that led to a RST_STREAM.
98 -type RstStreamStatus uint32
99 -
100 -const (
101 - ProtocolError RstStreamStatus = iota + 1
102 - InvalidStream
103 - RefusedStream
104 - UnsupportedVersion
105 - Cancel
106 - InternalError
107 - FlowControlError
108 - StreamInUse
109 - StreamAlreadyClosed
110 - InvalidCredentials
111 - FrameTooLarge
112 -)
113 -
114 -// RstStreamFrame is the unpacked, in-memory representation of a RST_STREAM
115 -// frame.
116 -type RstStreamFrame struct {
117 - CFHeader ControlFrameHeader
118 - StreamId StreamId
119 - Status RstStreamStatus
120 -}
121 -
122 -// SettingsFlag represents a flag in a SETTINGS frame.
123 -type SettingsFlag uint8
124 -
125 -const (
126 - FlagSettingsPersistValue SettingsFlag = 0x1
127 - FlagSettingsPersisted = 0x2
128 -)
129 -
130 -// SettingsFlag represents the id of an id/value pair in a SETTINGS frame.
131 -type SettingsId uint32
132 -
133 -const (
134 - SettingsUploadBandwidth SettingsId = iota + 1
135 - SettingsDownloadBandwidth
136 - SettingsRoundTripTime
137 - SettingsMaxConcurrentStreams
138 - SettingsCurrentCwnd
139 - SettingsDownloadRetransRate
140 - SettingsInitialWindowSize
141 - SettingsClientCretificateVectorSize
142 -)
143 -
144 -// SettingsFlagIdValue is the unpacked, in-memory representation of the
145 -// combined flag/id/value for a setting in a SETTINGS frame.
146 -type SettingsFlagIdValue struct {
147 - Flag SettingsFlag
148 - Id SettingsId
149 - Value uint32
150 -}
151 -
152 -// SettingsFrame is the unpacked, in-memory representation of a SPDY
153 -// SETTINGS frame.
154 -type SettingsFrame struct {
155 - CFHeader ControlFrameHeader
156 - FlagIdValues []SettingsFlagIdValue
157 -}
158 -
159 -// PingFrame is the unpacked, in-memory representation of a PING frame.
160 -type PingFrame struct {
161 - CFHeader ControlFrameHeader
162 - Id uint32 // unique id for this ping, from server is even, from client is odd.
163 -}
164 -
165 -// GoAwayStatus represents the status in a GoAwayFrame.
166 -type GoAwayStatus uint32
167 -
168 -const (
169 - GoAwayOK GoAwayStatus = iota
170 - GoAwayProtocolError
171 - GoAwayInternalError
172 -)
173 -
174 -// GoAwayFrame is the unpacked, in-memory representation of a GOAWAY frame.
175 -type GoAwayFrame struct {
176 - CFHeader ControlFrameHeader
177 - LastGoodStreamId StreamId // last stream id which was accepted by sender
178 - Status GoAwayStatus
179 -}
180 -
181 -// HeadersFrame is the unpacked, in-memory representation of a HEADERS frame.
182 -type HeadersFrame struct {
183 - CFHeader ControlFrameHeader
184 - StreamId StreamId
185 - Headers http.Header
186 -}
187 -
188 -// WindowUpdateFrame is the unpacked, in-memory representation of a
189 -// WINDOW_UPDATE frame.
190 -type WindowUpdateFrame struct {
191 - CFHeader ControlFrameHeader
192 - StreamId StreamId
193 - DeltaWindowSize uint32 // additional number of bytes to existing window size
194 -}
195 -
196 -// TODO: Implement credential frame and related methods.
197 -
198 -// DataFrame is the unpacked, in-memory representation of a DATA frame.
199 -type DataFrame struct {
200 - // Note, high bit is the "Control" bit. Should be 0 for data frames.
201 - StreamId StreamId
202 - Flags DataFlags
203 - Data []byte // payload data of this frame
204 -}
205 -
206 -// A SPDY specific error.
207 -type ErrorCode string
208 -
209 -const (
210 - UnlowercasedHeaderName ErrorCode = "header was not lowercased"
211 - DuplicateHeaders = "multiple headers with same name"
212 - WrongCompressedPayloadSize = "compressed payload size was incorrect"
213 - UnknownFrameType = "unknown frame type"
214 - InvalidControlFrame = "invalid control frame"
215 - InvalidDataFrame = "invalid data frame"
216 - InvalidHeaderPresent = "frame contained invalid header"
217 - ZeroStreamId = "stream id zero is disallowed"
218 -)
219 -
220 -// Error contains both the type of error and additional values. StreamId is 0
221 -// if Error is not associated with a stream.
222 -type Error struct {
223 - Err ErrorCode
224 - StreamId StreamId
225 -}
226 -
227 -func (e *Error) Error() string {
228 - return string(e.Err)
229 -}
230 -
231 -var invalidReqHeaders = map[string]bool{
232 - "Connection": true,
233 - "Host": true,
234 - "Keep-Alive": true,
235 - "Proxy-Connection": true,
236 - "Transfer-Encoding": true,
237 -}
238 -
239 -var invalidRespHeaders = map[string]bool{
240 - "Connection": true,
241 - "Keep-Alive": true,
242 - "Proxy-Connection": true,
243 - "Transfer-Encoding": true,
244 -}
245 -
246 -// Framer handles serializing/deserializing SPDY frames, including compressing/
247 -// decompressing payloads.
248 -type Framer struct {
249 - headerCompressionDisabled bool
250 - w io.Writer
251 - headerBuf *bytes.Buffer
252 - headerCompressor *zlib.Writer
253 - r io.Reader
254 - headerReader io.LimitedReader
255 - headerDecompressor io.ReadCloser
256 -}
257 -
258 -// NewFramer allocates a new Framer for a given SPDY connection, represented by
259 -// a io.Writer and io.Reader. Note that Framer will read and write individual fields
260 -// from/to the Reader and Writer, so the caller should pass in an appropriately
261 -// buffered implementation to optimize performance.
262 -func NewFramer(w io.Writer, r io.Reader) (*Framer, error) {
263 - compressBuf := new(bytes.Buffer)
264 - compressor, err := zlib.NewWriterLevelDict(compressBuf, zlib.BestCompression, []byte(headerDictionary))
265 - if err != nil {
266 - return nil, err
267 - }
268 - framer := &Framer{
269 - w: w,
270 - headerBuf: compressBuf,
271 - headerCompressor: compressor,
272 - r: r,
273 - }
274 - return framer, nil
275 -}
Godeps/_workspace/src/github.com/docker/spdystream/spdy/write.go deleted
-318
@@ -1,318 +0,0 @@
1 -// Copyright 2011 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package spdy
6 -
7 -import (
8 - "encoding/binary"
9 - "io"
10 - "net/http"
11 - "strings"
12 -)
13 -
14 -func (frame *SynStreamFrame) write(f *Framer) error {
15 - return f.writeSynStreamFrame(frame)
16 -}
17 -
18 -func (frame *SynReplyFrame) write(f *Framer) error {
19 - return f.writeSynReplyFrame(frame)
20 -}
21 -
22 -func (frame *RstStreamFrame) write(f *Framer) (err error) {
23 - if frame.StreamId == 0 {
24 - return &Error{ZeroStreamId, 0}
25 - }
26 - frame.CFHeader.version = Version
27 - frame.CFHeader.frameType = TypeRstStream
28 - frame.CFHeader.Flags = 0
29 - frame.CFHeader.length = 8
30 -
31 - // Serialize frame to Writer.
32 - if err = writeControlFrameHeader(f.w, frame.CFHeader); err != nil {
33 - return
34 - }
35 - if err = binary.Write(f.w, binary.BigEndian, frame.StreamId); err != nil {
36 - return
37 - }
38 - if frame.Status == 0 {
39 - return &Error{InvalidControlFrame, frame.StreamId}
40 - }
41 - if err = binary.Write(f.w, binary.BigEndian, frame.Status); err != nil {
42 - return
43 - }
44 - return
45 -}
46 -
47 -func (frame *SettingsFrame) write(f *Framer) (err error) {
48 - frame.CFHeader.version = Version
49 - frame.CFHeader.frameType = TypeSettings
50 - frame.CFHeader.length = uint32(len(frame.FlagIdValues)*8 + 4)
51 -
52 - // Serialize frame to Writer.
53 - if err = writeControlFrameHeader(f.w, frame.CFHeader); err != nil {
54 - return
55 - }
56 - if err = binary.Write(f.w, binary.BigEndian, uint32(len(frame.FlagIdValues))); err != nil {
57 - return
58 - }
59 - for _, flagIdValue := range frame.FlagIdValues {
60 - flagId := uint32(flagIdValue.Flag)<<24 | uint32(flagIdValue.Id)
61 - if err = binary.Write(f.w, binary.BigEndian, flagId); err != nil {
62 - return
63 - }
64 - if err = binary.Write(f.w, binary.BigEndian, flagIdValue.Value); err != nil {
65 - return
66 - }
67 - }
68 - return
69 -}
70 -
71 -func (frame *PingFrame) write(f *Framer) (err error) {
72 - if frame.Id == 0 {
73 - return &Error{ZeroStreamId, 0}
74 - }
75 - frame.CFHeader.version = Version
76 - frame.CFHeader.frameType = TypePing
77 - frame.CFHeader.Flags = 0
78 - frame.CFHeader.length = 4
79 -
80 - // Serialize frame to Writer.
81 - if err = writeControlFrameHeader(f.w, frame.CFHeader); err != nil {
82 - return
83 - }
84 - if err = binary.Write(f.w, binary.BigEndian, frame.Id); err != nil {
85 - return
86 - }
87 - return
88 -}
89 -
90 -func (frame *GoAwayFrame) write(f *Framer) (err error) {
91 - frame.CFHeader.version = Version
92 - frame.CFHeader.frameType = TypeGoAway
93 - frame.CFHeader.Flags = 0
94 - frame.CFHeader.length = 8
95 -
96 - // Serialize frame to Writer.
97 - if err = writeControlFrameHeader(f.w, frame.CFHeader); err != nil {
98 - return
99 - }
100 - if err = binary.Write(f.w, binary.BigEndian, frame.LastGoodStreamId); err != nil {
101 - return
102 - }
103 - if err = binary.Write(f.w, binary.BigEndian, frame.Status); err != nil {
104 - return
105 - }
106 - return nil
107 -}
108 -
109 -func (frame *HeadersFrame) write(f *Framer) error {
110 - return f.writeHeadersFrame(frame)
111 -}
112 -
113 -func (frame *WindowUpdateFrame) write(f *Framer) (err error) {
114 - frame.CFHeader.version = Version
115 - frame.CFHeader.frameType = TypeWindowUpdate
116 - frame.CFHeader.Flags = 0
117 - frame.CFHeader.length = 8
118 -
119 - // Serialize frame to Writer.
120 - if err = writeControlFrameHeader(f.w, frame.CFHeader); err != nil {
121 - return
122 - }
123 - if err = binary.Write(f.w, binary.BigEndian, frame.StreamId); err != nil {
124 - return
125 - }
126 - if err = binary.Write(f.w, binary.BigEndian, frame.DeltaWindowSize); err != nil {
127 - return
128 - }
129 - return nil
130 -}
131 -
132 -func (frame *DataFrame) write(f *Framer) error {
133 - return f.writeDataFrame(frame)
134 -}
135 -
136 -// WriteFrame writes a frame.
137 -func (f *Framer) WriteFrame(frame Frame) error {
138 - return frame.write(f)
139 -}
140 -
141 -func writeControlFrameHeader(w io.Writer, h ControlFrameHeader) error {
142 - if err := binary.Write(w, binary.BigEndian, 0x8000|h.version); err != nil {
143 - return err
144 - }
145 - if err := binary.Write(w, binary.BigEndian, h.frameType); err != nil {
146 - return err
147 - }
148 - flagsAndLength := uint32(h.Flags)<<24 | h.length
149 - if err := binary.Write(w, binary.BigEndian, flagsAndLength); err != nil {
150 - return err
151 - }
152 - return nil
153 -}
154 -
155 -func writeHeaderValueBlock(w io.Writer, h http.Header) (n int, err error) {
156 - n = 0
157 - if err = binary.Write(w, binary.BigEndian, uint32(len(h))); err != nil {
158 - return
159 - }
160 - n += 2
161 - for name, values := range h {
162 - if err = binary.Write(w, binary.BigEndian, uint32(len(name))); err != nil {
163 - return
164 - }
165 - n += 2
166 - name = strings.ToLower(name)
167 - if _, err = io.WriteString(w, name); err != nil {
168 - return
169 - }
170 - n += len(name)
171 - v := strings.Join(values, headerValueSeparator)
172 - if err = binary.Write(w, binary.BigEndian, uint32(len(v))); err != nil {
173 - return
174 - }
175 - n += 2
176 - if _, err = io.WriteString(w, v); err != nil {
177 - return
178 - }
179 - n += len(v)
180 - }
181 - return
182 -}
183 -
184 -func (f *Framer) writeSynStreamFrame(frame *SynStreamFrame) (err error) {
185 - if frame.StreamId == 0 {
186 - return &Error{ZeroStreamId, 0}
187 - }
188 - // Marshal the headers.
189 - var writer io.Writer = f.headerBuf
190 - if !f.headerCompressionDisabled {
191 - writer = f.headerCompressor
192 - }
193 - if _, err = writeHeaderValueBlock(writer, frame.Headers); err != nil {
194 - return
195 - }
196 - if !f.headerCompressionDisabled {
197 - f.headerCompressor.Flush()
198 - }
199 -
200 - // Set ControlFrameHeader.
201 - frame.CFHeader.version = Version
202 - frame.CFHeader.frameType = TypeSynStream
203 - frame.CFHeader.length = uint32(len(f.headerBuf.Bytes()) + 10)
204 -
205 - // Serialize frame to Writer.
206 - if err = writeControlFrameHeader(f.w, frame.CFHeader); err != nil {
207 - return err
208 - }
209 - if err = binary.Write(f.w, binary.BigEndian, frame.StreamId); err != nil {
210 - return err
211 - }
212 - if err = binary.Write(f.w, binary.BigEndian, frame.AssociatedToStreamId); err != nil {
213 - return err
214 - }
215 - if err = binary.Write(f.w, binary.BigEndian, frame.Priority<<5); err != nil {
216 - return err
217 - }
218 - if err = binary.Write(f.w, binary.BigEndian, frame.Slot); err != nil {
219 - return err
220 - }
221 - if _, err = f.w.Write(f.headerBuf.Bytes()); err != nil {
222 - return err
223 - }
224 - f.headerBuf.Reset()
225 - return nil
226 -}
227 -
228 -func (f *Framer) writeSynReplyFrame(frame *SynReplyFrame) (err error) {
229 - if frame.StreamId == 0 {
230 - return &Error{ZeroStreamId, 0}
231 - }
232 - // Marshal the headers.
233 - var writer io.Writer = f.headerBuf
234 - if !f.headerCompressionDisabled {
235 - writer = f.headerCompressor
236 - }
237 - if _, err = writeHeaderValueBlock(writer, frame.Headers); err != nil {
238 - return
239 - }
240 - if !f.headerCompressionDisabled {
241 - f.headerCompressor.Flush()
242 - }
243 -
244 - // Set ControlFrameHeader.
245 - frame.CFHeader.version = Version
246 - frame.CFHeader.frameType = TypeSynReply
247 - frame.CFHeader.length = uint32(len(f.headerBuf.Bytes()) + 4)
248 -
249 - // Serialize frame to Writer.
250 - if err = writeControlFrameHeader(f.w, frame.CFHeader); err != nil {
251 - return
252 - }
253 - if err = binary.Write(f.w, binary.BigEndian, frame.StreamId); err != nil {
254 - return
255 - }
256 - if _, err = f.w.Write(f.headerBuf.Bytes()); err != nil {
257 - return
258 - }
259 - f.headerBuf.Reset()
260 - return
261 -}
262 -
263 -func (f *Framer) writeHeadersFrame(frame *HeadersFrame) (err error) {
264 - if frame.StreamId == 0 {
265 - return &Error{ZeroStreamId, 0}
266 - }
267 - // Marshal the headers.
268 - var writer io.Writer = f.headerBuf
269 - if !f.headerCompressionDisabled {
270 - writer = f.headerCompressor
271 - }
272 - if _, err = writeHeaderValueBlock(writer, frame.Headers); err != nil {
273 - return
274 - }
275 - if !f.headerCompressionDisabled {
276 - f.headerCompressor.Flush()
277 - }
278 -
279 - // Set ControlFrameHeader.
280 - frame.CFHeader.version = Version
281 - frame.CFHeader.frameType = TypeHeaders
282 - frame.CFHeader.length = uint32(len(f.headerBuf.Bytes()) + 4)
283 -
284 - // Serialize frame to Writer.
285 - if err = writeControlFrameHeader(f.w, frame.CFHeader); err != nil {
286 - return
287 - }
288 - if err = binary.Write(f.w, binary.BigEndian, frame.StreamId); err != nil {
289 - return
290 - }
291 - if _, err = f.w.Write(f.headerBuf.Bytes()); err != nil {
292 - return
293 - }
294 - f.headerBuf.Reset()
295 - return
296 -}
297 -
298 -func (f *Framer) writeDataFrame(frame *DataFrame) (err error) {
299 - if frame.StreamId == 0 {
300 - return &Error{ZeroStreamId, 0}
301 - }
302 - if frame.StreamId&0x80000000 != 0 || len(frame.Data) > MaxDataLength {
303 - return &Error{InvalidDataFrame, frame.StreamId}
304 - }
305 -
306 - // Serialize frame to Writer.
307 - if err = binary.Write(f.w, binary.BigEndian, frame.StreamId); err != nil {
308 - return
309 - }
310 - flagsAndLength := uint32(frame.Flags)<<24 | uint32(len(frame.Data))
311 - if err = binary.Write(f.w, binary.BigEndian, flagsAndLength); err != nil {
312 - return
313 - }
314 - if _, err = f.w.Write(frame.Data); err != nil {
315 - return
316 - }
317 - return nil
318 -}
Godeps/_workspace/src/github.com/docker/spdystream/spdy_bench_test.go deleted
-113
@@ -1,113 +0,0 @@
1 -package spdystream
2 -
3 -import (
4 - "fmt"
5 - "io"
6 - "net"
7 - "net/http"
8 - "sync"
9 - "testing"
10 -)
11 -
12 -func configureServer() (io.Closer, string, *sync.WaitGroup) {
13 - authenticated = true
14 - wg := &sync.WaitGroup{}
15 - server, listen, serverErr := runServer(wg)
16 -
17 - if serverErr != nil {
18 - panic(serverErr)
19 - }
20 -
21 - return server, listen, wg
22 -}
23 -
24 -func BenchmarkDial10000(b *testing.B) {
25 - server, addr, wg := configureServer()
26 -
27 - defer func() {
28 - server.Close()
29 - wg.Wait()
30 - }()
31 -
32 - for i := 0; i < b.N; i++ {
33 - conn, dialErr := net.Dial("tcp", addr)
34 - if dialErr != nil {
35 - panic(fmt.Sprintf("Error dialing server: %s", dialErr))
36 - }
37 - conn.Close()
38 - }
39 -}
40 -
41 -func BenchmarkDialWithSPDYStream10000(b *testing.B) {
42 - server, addr, wg := configureServer()
43 -
44 - defer func() {
45 - server.Close()
46 - wg.Wait()
47 - }()
48 -
49 - for i := 0; i < b.N; i++ {
50 - conn, dialErr := net.Dial("tcp", addr)
51 - if dialErr != nil {
52 - b.Fatalf("Error dialing server: %s", dialErr)
53 - }
54 -
55 - spdyConn, spdyErr := NewConnection(conn, false)
56 - if spdyErr != nil {
57 - b.Fatalf("Error creating spdy connection: %s", spdyErr)
58 - }
59 - go spdyConn.Serve(NoOpStreamHandler)
60 -
61 - closeErr := spdyConn.Close()
62 - if closeErr != nil {
63 - b.Fatalf("Error closing connection: %s, closeErr")
64 - }
65 - }
66 -}
67 -
68 -func benchmarkStreamWithDataAndSize(size uint64, b *testing.B) {
69 - server, addr, wg := configureServer()
70 -
71 - defer func() {
72 - server.Close()
73 - wg.Wait()
74 - }()
75 -
76 - for i := 0; i < b.N; i++ {
77 - conn, dialErr := net.Dial("tcp", addr)
78 - if dialErr != nil {
79 - b.Fatalf("Error dialing server: %s", dialErr)
80 - }
81 -
82 - spdyConn, spdyErr := NewConnection(conn, false)
83 - if spdyErr != nil {
84 - b.Fatalf("Error creating spdy connection: %s", spdyErr)
85 - }
86 -
87 - go spdyConn.Serve(MirrorStreamHandler)
88 -
89 - stream, err := spdyConn.CreateStream(http.Header{}, nil, false)
90 -
91 - writer := make([]byte, size)
92 -
93 - stream.Write(writer)
94 -
95 - if err != nil {
96 - panic(err)
97 - }
98 -
99 - reader := make([]byte, size)
100 - stream.Read(reader)
101 -
102 - stream.Close()
103 -
104 - closeErr := spdyConn.Close()
105 - if closeErr != nil {
106 - b.Fatalf("Error closing connection: %s, closeErr")
107 - }
108 - }
109 -}
110 -
111 -func BenchmarkStreamWith1Byte10000(b *testing.B) { benchmarkStreamWithDataAndSize(1, b) }
112 -func BenchmarkStreamWith1KiloByte10000(b *testing.B) { benchmarkStreamWithDataAndSize(1024, b) }
113 -func BenchmarkStreamWith1Megabyte10000(b *testing.B) { benchmarkStreamWithDataAndSize(1024*1024, b) }
Godeps/_workspace/src/github.com/docker/spdystream/spdy_test.go deleted
-909
@@ -1,909 +0,0 @@
1 -package spdystream
2 -
3 -import (
4 - "bufio"
5 - "bytes"
6 - "io"
7 - "net"
8 - "net/http"
9 - "net/http/httptest"
10 - "sync"
11 - "testing"
12 - "time"
13 -)
14 -
15 -func TestSpdyStreams(t *testing.T) {
16 - var wg sync.WaitGroup
17 - server, listen, serverErr := runServer(&wg)
18 - if serverErr != nil {
19 - t.Fatalf("Error initializing server: %s", serverErr)
20 - }
21 -
22 - conn, dialErr := net.Dial("tcp", listen)
23 - if dialErr != nil {
24 - t.Fatalf("Error dialing server: %s", dialErr)
25 - }
26 -
27 - spdyConn, spdyErr := NewConnection(conn, false)
28 - if spdyErr != nil {
29 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
30 - }
31 - go spdyConn.Serve(NoOpStreamHandler)
32 -
33 - authenticated = true
34 - stream, streamErr := spdyConn.CreateStream(http.Header{}, nil, false)
35 - if streamErr != nil {
36 - t.Fatalf("Error creating stream: %s", streamErr)
37 - }
38 -
39 - waitErr := stream.Wait()
40 - if waitErr != nil {
41 - t.Fatalf("Error waiting for stream: %s", waitErr)
42 - }
43 -
44 - message := []byte("hello")
45 - writeErr := stream.WriteData(message, false)
46 - if writeErr != nil {
47 - t.Fatalf("Error writing data")
48 - }
49 -
50 - buf := make([]byte, 10)
51 - n, readErr := stream.Read(buf)
52 - if readErr != nil {
53 - t.Fatalf("Error reading data from stream: %s", readErr)
54 - }
55 - if n != 5 {
56 - t.Fatalf("Unexpected number of bytes read:\nActual: %d\nExpected: 5", n)
57 - }
58 - if bytes.Compare(buf[:n], message) != 0 {
59 - t.Fatalf("Did not receive expected message:\nActual: %s\nExpectd: %s", buf, message)
60 - }
61 -
62 - headers := http.Header{
63 - "TestKey": []string{"TestVal"},
64 - }
65 - sendErr := stream.SendHeader(headers, false)
66 - if sendErr != nil {
67 - t.Fatalf("Error sending headers: %s", sendErr)
68 - }
69 - receiveHeaders, receiveErr := stream.ReceiveHeader()
70 - if receiveErr != nil {
71 - t.Fatalf("Error receiving headers: %s", receiveErr)
72 - }
73 - if len(receiveHeaders) != 1 {
74 - t.Fatalf("Unexpected number of headers:\nActual: %d\nExpecting:%d", len(receiveHeaders), 1)
75 - }
76 - testVal := receiveHeaders.Get("TestKey")
77 - if testVal != "TestVal" {
78 - t.Fatalf("Wrong test value:\nActual: %q\nExpecting: %q", testVal, "TestVal")
79 - }
80 -
81 - writeErr = stream.WriteData(message, true)
82 - if writeErr != nil {
83 - t.Fatalf("Error writing data")
84 - }
85 -
86 - smallBuf := make([]byte, 3)
87 - n, readErr = stream.Read(smallBuf)
88 - if readErr != nil {
89 - t.Fatalf("Error reading data from stream: %s", readErr)
90 - }
91 - if n != 3 {
92 - t.Fatalf("Unexpected number of bytes read:\nActual: %d\nExpected: 3", n)
93 - }
94 - if bytes.Compare(smallBuf[:n], []byte("hel")) != 0 {
95 - t.Fatalf("Did not receive expected message:\nActual: %s\nExpectd: %s", smallBuf[:n], message)
96 - }
97 - n, readErr = stream.Read(smallBuf)
98 - if readErr != nil {
99 - t.Fatalf("Error reading data from stream: %s", readErr)
100 - }
101 - if n != 2 {
102 - t.Fatalf("Unexpected number of bytes read:\nActual: %d\nExpected: 2", n)
103 - }
104 - if bytes.Compare(smallBuf[:n], []byte("lo")) != 0 {
105 - t.Fatalf("Did not receive expected message:\nActual: %s\nExpected: lo", smallBuf[:n])
106 - }
107 -
108 - n, readErr = stream.Read(buf)
109 - if readErr != io.EOF {
110 - t.Fatalf("Expected EOF reading from finished stream, read %d bytes", n)
111 - }
112 -
113 - // Closing again should return error since stream is already closed
114 - streamCloseErr := stream.Close()
115 - if streamCloseErr == nil {
116 - t.Fatalf("No error closing finished stream")
117 - }
118 - if streamCloseErr != ErrWriteClosedStream {
119 - t.Fatalf("Unexpected error closing stream: %s", streamCloseErr)
120 - }
121 -
122 - streamResetErr := stream.Reset()
123 - if streamResetErr != nil {
124 - t.Fatalf("Error reseting stream: %s", streamResetErr)
125 - }
126 -
127 - authenticated = false
128 - badStream, badStreamErr := spdyConn.CreateStream(http.Header{}, nil, false)
129 - if badStreamErr != nil {
130 - t.Fatalf("Error creating stream: %s", badStreamErr)
131 - }
132 -
133 - waitErr = badStream.Wait()
134 - if waitErr == nil {
135 - t.Fatalf("Did not receive error creating stream")
136 - }
137 - if waitErr != ErrReset {
138 - t.Fatalf("Unexpected error creating stream: %s", waitErr)
139 - }
140 - streamCloseErr = badStream.Close()
141 - if streamCloseErr == nil {
142 - t.Fatalf("No error closing bad stream")
143 - }
144 -
145 - spdyCloseErr := spdyConn.Close()
146 - if spdyCloseErr != nil {
147 - t.Fatalf("Error closing spdy connection: %s", spdyCloseErr)
148 - }
149 -
150 - closeErr := server.Close()
151 - if closeErr != nil {
152 - t.Fatalf("Error shutting down server: %s", closeErr)
153 - }
154 - wg.Wait()
155 -}
156 -
157 -func TestPing(t *testing.T) {
158 - var wg sync.WaitGroup
159 - server, listen, serverErr := runServer(&wg)
160 - if serverErr != nil {
161 - t.Fatalf("Error initializing server: %s", serverErr)
162 - }
163 -
164 - conn, dialErr := net.Dial("tcp", listen)
165 - if dialErr != nil {
166 - t.Fatalf("Error dialing server: %s", dialErr)
167 - }
168 -
169 - spdyConn, spdyErr := NewConnection(conn, false)
170 - if spdyErr != nil {
171 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
172 - }
173 - go spdyConn.Serve(NoOpStreamHandler)
174 -
175 - pingTime, pingErr := spdyConn.Ping()
176 - if pingErr != nil {
177 - t.Fatalf("Error pinging server: %s", pingErr)
178 - }
179 - if pingTime == time.Duration(0) {
180 - t.Fatalf("Expecting non-zero ping time")
181 - }
182 -
183 - closeErr := server.Close()
184 - if closeErr != nil {
185 - t.Fatalf("Error shutting down server: %s", closeErr)
186 - }
187 - wg.Wait()
188 -}
189 -
190 -func TestHalfClose(t *testing.T) {
191 - var wg sync.WaitGroup
192 - server, listen, serverErr := runServer(&wg)
193 - if serverErr != nil {
194 - t.Fatalf("Error initializing server: %s", serverErr)
195 - }
196 -
197 - conn, dialErr := net.Dial("tcp", listen)
198 - if dialErr != nil {
199 - t.Fatalf("Error dialing server: %s", dialErr)
200 - }
201 -
202 - spdyConn, spdyErr := NewConnection(conn, false)
203 - if spdyErr != nil {
204 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
205 - }
206 - go spdyConn.Serve(NoOpStreamHandler)
207 -
208 - authenticated = true
209 - stream, streamErr := spdyConn.CreateStream(http.Header{}, nil, false)
210 - if streamErr != nil {
211 - t.Fatalf("Error creating stream: %s", streamErr)
212 - }
213 -
214 - waitErr := stream.Wait()
215 - if waitErr != nil {
216 - t.Fatalf("Error waiting for stream: %s", waitErr)
217 - }
218 -
219 - message := []byte("hello and will read after close")
220 - writeErr := stream.WriteData(message, false)
221 - if writeErr != nil {
222 - t.Fatalf("Error writing data")
223 - }
224 -
225 - streamCloseErr := stream.Close()
226 - if streamCloseErr != nil {
227 - t.Fatalf("Error closing stream: %s", streamCloseErr)
228 - }
229 -
230 - buf := make([]byte, 40)
231 - n, readErr := stream.Read(buf)
232 - if readErr != nil {
233 - t.Fatalf("Error reading data from stream: %s", readErr)
234 - }
235 - if n != 31 {
236 - t.Fatalf("Unexpected number of bytes read:\nActual: %d\nExpected: 5", n)
237 - }
238 - if bytes.Compare(buf[:n], message) != 0 {
239 - t.Fatalf("Did not receive expected message:\nActual: %s\nExpectd: %s", buf, message)
240 - }
241 -
242 - spdyCloseErr := spdyConn.Close()
243 - if spdyCloseErr != nil {
244 - t.Fatalf("Error closing spdy connection: %s", spdyCloseErr)
245 - }
246 -
247 - closeErr := server.Close()
248 - if closeErr != nil {
249 - t.Fatalf("Error shutting down server: %s", closeErr)
250 - }
251 - wg.Wait()
252 -}
253 -
254 -func TestUnexpectedRemoteConnectionClosed(t *testing.T) {
255 - tt := []struct {
256 - closeReceiver bool
257 - closeSender bool
258 - }{
259 - {closeReceiver: true, closeSender: false},
260 - {closeReceiver: false, closeSender: true},
261 - {closeReceiver: false, closeSender: false},
262 - }
263 - for tix, tc := range tt {
264 - listener, listenErr := net.Listen("tcp", "localhost:0")
265 - if listenErr != nil {
266 - t.Fatalf("Error listening: %v", listenErr)
267 - }
268 -
269 - var serverConn net.Conn
270 - var connErr error
271 - go func() {
272 - serverConn, connErr = listener.Accept()
273 - if connErr != nil {
274 - t.Fatalf("Error accepting: %v", connErr)
275 - }
276 -
277 - serverSpdyConn, _ := NewConnection(serverConn, true)
278 - go serverSpdyConn.Serve(func(stream *Stream) {
279 - stream.SendReply(http.Header{}, tc.closeSender)
280 - })
281 - }()
282 -
283 - conn, dialErr := net.Dial("tcp", listener.Addr().String())
284 - if dialErr != nil {
285 - t.Fatalf("Error dialing server: %s", dialErr)
286 - }
287 -
288 - spdyConn, spdyErr := NewConnection(conn, false)
289 - if spdyErr != nil {
290 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
291 - }
292 - go spdyConn.Serve(NoOpStreamHandler)
293 -
294 - authenticated = true
295 - stream, streamErr := spdyConn.CreateStream(http.Header{}, nil, false)
296 - if streamErr != nil {
297 - t.Fatalf("Error creating stream: %s", streamErr)
298 - }
299 -
300 - waitErr := stream.Wait()
301 - if waitErr != nil {
302 - t.Fatalf("Error waiting for stream: %s", waitErr)
303 - }
304 -
305 - if tc.closeReceiver {
306 - // make stream half closed, receive only
307 - stream.Close()
308 - }
309 -
310 - streamch := make(chan error, 1)
311 - go func() {
312 - b := make([]byte, 1)
313 - _, err := stream.Read(b)
314 - streamch <- err
315 - }()
316 -
317 - closeErr := serverConn.Close()
318 - if closeErr != nil {
319 - t.Fatalf("Error shutting down server: %s", closeErr)
320 - }
321 -
322 - select {
323 - case e := <-streamch:
324 - if e == nil || e != io.EOF {
325 - t.Fatalf("(%d) Expected to get an EOF stream error", tix)
326 - }
327 - }
328 -
329 - closeErr = conn.Close()
330 - if closeErr != nil {
331 - t.Fatalf("Error closing client connection: %s", closeErr)
332 - }
333 -
334 - listenErr = listener.Close()
335 - if listenErr != nil {
336 - t.Fatalf("Error closing listener: %s", listenErr)
337 - }
338 - }
339 -}
340 -
341 -func TestCloseNotification(t *testing.T) {
342 - listener, listenErr := net.Listen("tcp", "localhost:0")
343 - if listenErr != nil {
344 - t.Fatalf("Error listening: %v", listenErr)
345 - }
346 - listen := listener.Addr().String()
347 -
348 - serverConnChan := make(chan net.Conn)
349 - go func() {
350 - serverConn, err := listener.Accept()
351 - if err != nil {
352 - t.Fatalf("Error accepting: %v", err)
353 - }
354 -
355 - serverSpdyConn, err := NewConnection(serverConn, true)
356 - if err != nil {
357 - t.Fatalf("Error creating server connection: %v", err)
358 - }
359 - go serverSpdyConn.Serve(NoOpStreamHandler)
360 - <-serverSpdyConn.CloseChan()
361 - serverConnChan <- serverConn
362 - }()
363 -
364 - conn, dialErr := net.Dial("tcp", listen)
365 - if dialErr != nil {
366 - t.Fatalf("Error dialing server: %s", dialErr)
367 - }
368 -
369 - spdyConn, spdyErr := NewConnection(conn, false)
370 - if spdyErr != nil {
371 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
372 - }
373 - go spdyConn.Serve(NoOpStreamHandler)
374 -
375 - // close client conn
376 - err := conn.Close()
377 - if err != nil {
378 - t.Fatalf("Error closing client connection: %v", err)
379 - }
380 -
381 - var serverConn net.Conn
382 - select {
383 - case serverConn = <-serverConnChan:
384 - }
385 -
386 - err = serverConn.Close()
387 - if err != nil {
388 - t.Fatalf("Error closing serverConn: %v", err)
389 - }
390 -
391 - listenErr = listener.Close()
392 - if listenErr != nil {
393 - t.Fatalf("Error closing listener: %s", listenErr)
394 - }
395 -}
396 -
397 -func TestIdleShutdownRace(t *testing.T) {
398 - var wg sync.WaitGroup
399 - server, listen, serverErr := runServer(&wg)
400 - if serverErr != nil {
401 - t.Fatalf("Error initializing server: %s", serverErr)
402 - }
403 -
404 - conn, dialErr := net.Dial("tcp", listen)
405 - if dialErr != nil {
406 - t.Fatalf("Error dialing server: %s", dialErr)
407 - }
408 -
409 - spdyConn, spdyErr := NewConnection(conn, false)
410 - if spdyErr != nil {
411 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
412 - }
413 - go spdyConn.Serve(NoOpStreamHandler)
414 -
415 - authenticated = true
416 - stream, err := spdyConn.CreateStream(http.Header{}, nil, false)
417 - if err != nil {
418 - t.Fatalf("Error creating stream: %v", err)
419 - }
420 -
421 - spdyConn.SetIdleTimeout(5 * time.Millisecond)
422 - go func() {
423 - time.Sleep(5 * time.Millisecond)
424 - stream.Reset()
425 - }()
426 -
427 - select {
428 - case <-spdyConn.CloseChan():
429 - case <-time.After(20 * time.Millisecond):
430 - t.Fatal("Timed out waiting for idle connection closure")
431 - }
432 -
433 - closeErr := server.Close()
434 - if closeErr != nil {
435 - t.Fatalf("Error shutting down server: %s", closeErr)
436 - }
437 - wg.Wait()
438 -}
439 -
440 -func TestIdleNoTimeoutSet(t *testing.T) {
441 - var wg sync.WaitGroup
442 - server, listen, serverErr := runServer(&wg)
443 - if serverErr != nil {
444 - t.Fatalf("Error initializing server: %s", serverErr)
445 - }
446 -
447 - conn, dialErr := net.Dial("tcp", listen)
448 - if dialErr != nil {
449 - t.Fatalf("Error dialing server: %s", dialErr)
450 - }
451 -
452 - spdyConn, spdyErr := NewConnection(conn, false)
453 - if spdyErr != nil {
454 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
455 - }
456 - go spdyConn.Serve(NoOpStreamHandler)
457 -
458 - select {
459 - case <-spdyConn.CloseChan():
460 - t.Fatal("Unexpected connection closure")
461 - case <-time.After(10 * time.Millisecond):
462 - }
463 -
464 - closeErr := server.Close()
465 - if closeErr != nil {
466 - t.Fatalf("Error shutting down server: %s", closeErr)
467 - }
468 - wg.Wait()
469 -}
470 -
471 -func TestIdleClearTimeout(t *testing.T) {
472 - var wg sync.WaitGroup
473 - server, listen, serverErr := runServer(&wg)
474 - if serverErr != nil {
475 - t.Fatalf("Error initializing server: %s", serverErr)
476 - }
477 -
478 - conn, dialErr := net.Dial("tcp", listen)
479 - if dialErr != nil {
480 - t.Fatalf("Error dialing server: %s", dialErr)
481 - }
482 -
483 - spdyConn, spdyErr := NewConnection(conn, false)
484 - if spdyErr != nil {
485 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
486 - }
487 - go spdyConn.Serve(NoOpStreamHandler)
488 -
489 - spdyConn.SetIdleTimeout(10 * time.Millisecond)
490 - spdyConn.SetIdleTimeout(0)
491 - select {
492 - case <-spdyConn.CloseChan():
493 - t.Fatal("Unexpected connection closure")
494 - case <-time.After(20 * time.Millisecond):
495 - }
496 -
497 - closeErr := server.Close()
498 - if closeErr != nil {
499 - t.Fatalf("Error shutting down server: %s", closeErr)
500 - }
501 - wg.Wait()
502 -}
503 -
504 -func TestIdleNoData(t *testing.T) {
505 - var wg sync.WaitGroup
506 - server, listen, serverErr := runServer(&wg)
507 - if serverErr != nil {
508 - t.Fatalf("Error initializing server: %s", serverErr)
509 - }
510 -
511 - conn, dialErr := net.Dial("tcp", listen)
512 - if dialErr != nil {
513 - t.Fatalf("Error dialing server: %s", dialErr)
514 - }
515 -
516 - spdyConn, spdyErr := NewConnection(conn, false)
517 - if spdyErr != nil {
518 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
519 - }
520 - go spdyConn.Serve(NoOpStreamHandler)
521 -
522 - spdyConn.SetIdleTimeout(10 * time.Millisecond)
523 - <-spdyConn.CloseChan()
524 -
525 - closeErr := server.Close()
526 - if closeErr != nil {
527 - t.Fatalf("Error shutting down server: %s", closeErr)
528 - }
529 - wg.Wait()
530 -}
531 -
532 -func TestIdleWithData(t *testing.T) {
533 - var wg sync.WaitGroup
534 - server, listen, serverErr := runServer(&wg)
535 - if serverErr != nil {
536 - t.Fatalf("Error initializing server: %s", serverErr)
537 - }
538 -
539 - conn, dialErr := net.Dial("tcp", listen)
540 - if dialErr != nil {
541 - t.Fatalf("Error dialing server: %s", dialErr)
542 - }
543 -
544 - spdyConn, spdyErr := NewConnection(conn, false)
545 - if spdyErr != nil {
546 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
547 - }
548 - go spdyConn.Serve(NoOpStreamHandler)
549 -
550 - spdyConn.SetIdleTimeout(25 * time.Millisecond)
551 -
552 - authenticated = true
553 - stream, err := spdyConn.CreateStream(http.Header{}, nil, false)
554 - if err != nil {
555 - t.Fatalf("Error creating stream: %v", err)
556 - }
557 -
558 - writeCh := make(chan struct{})
559 -
560 - go func() {
561 - b := []byte{1, 2, 3, 4, 5}
562 - for i := 0; i < 10; i++ {
563 - _, err = stream.Write(b)
564 - if err != nil {
565 - t.Fatalf("Error writing to stream: %v", err)
566 - }
567 - time.Sleep(10 * time.Millisecond)
568 - }
569 - close(writeCh)
570 - }()
571 -
572 - writesFinished := false
573 -
574 -Loop:
575 - for {
576 - select {
577 - case <-writeCh:
578 - writesFinished = true
579 - case <-spdyConn.CloseChan():
580 - if !writesFinished {
581 - t.Fatal("Connection closed before all writes finished")
582 - }
583 - break Loop
584 - }
585 - }
586 -
587 - closeErr := server.Close()
588 - if closeErr != nil {
589 - t.Fatalf("Error shutting down server: %s", closeErr)
590 - }
591 - wg.Wait()
592 -}
593 -
594 -func TestIdleRace(t *testing.T) {
595 - var wg sync.WaitGroup
596 - server, listen, serverErr := runServer(&wg)
597 - if serverErr != nil {
598 - t.Fatalf("Error initializing server: %s", serverErr)
599 - }
600 -
601 - conn, dialErr := net.Dial("tcp", listen)
602 - if dialErr != nil {
603 - t.Fatalf("Error dialing server: %s", dialErr)
604 - }
605 -
606 - spdyConn, spdyErr := NewConnection(conn, false)
607 - if spdyErr != nil {
608 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
609 - }
610 - go spdyConn.Serve(NoOpStreamHandler)
611 -
612 - spdyConn.SetIdleTimeout(10 * time.Millisecond)
613 -
614 - authenticated = true
615 -
616 - for i := 0; i < 10; i++ {
617 - _, err := spdyConn.CreateStream(http.Header{}, nil, false)
618 - if err != nil {
619 - t.Fatalf("Error creating stream: %v", err)
620 - }
621 - }
622 -
623 - <-spdyConn.CloseChan()
624 -
625 - closeErr := server.Close()
626 - if closeErr != nil {
627 - t.Fatalf("Error shutting down server: %s", closeErr)
628 - }
629 - wg.Wait()
630 -}
631 -
632 -func TestHalfClosedIdleTimeout(t *testing.T) {
633 - listener, listenErr := net.Listen("tcp", "localhost:0")
634 - if listenErr != nil {
635 - t.Fatalf("Error listening: %v", listenErr)
636 - }
637 - listen := listener.Addr().String()
638 -
639 - go func() {
640 - serverConn, err := listener.Accept()
641 - if err != nil {
642 - t.Fatalf("Error accepting: %v", err)
643 - }
644 -
645 - serverSpdyConn, err := NewConnection(serverConn, true)
646 - if err != nil {
647 - t.Fatalf("Error creating server connection: %v", err)
648 - }
649 - go serverSpdyConn.Serve(func(s *Stream) {
650 - s.SendReply(http.Header{}, true)
651 - })
652 - serverSpdyConn.SetIdleTimeout(10 * time.Millisecond)
653 - }()
654 -
655 - conn, dialErr := net.Dial("tcp", listen)
656 - if dialErr != nil {
657 - t.Fatalf("Error dialing server: %s", dialErr)
658 - }
659 -
660 - spdyConn, spdyErr := NewConnection(conn, false)
661 - if spdyErr != nil {
662 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
663 - }
664 - go spdyConn.Serve(NoOpStreamHandler)
665 -
666 - stream, err := spdyConn.CreateStream(http.Header{}, nil, false)
667 - if err != nil {
668 - t.Fatalf("Error creating stream: %v", err)
669 - }
670 -
671 - time.Sleep(20 * time.Millisecond)
672 -
673 - stream.Reset()
674 -
675 - err = spdyConn.Close()
676 - if err != nil {
677 - t.Fatalf("Error closing client spdy conn: %v", err)
678 - }
679 -}
680 -
681 -func TestStreamReset(t *testing.T) {
682 - var wg sync.WaitGroup
683 - server, listen, serverErr := runServer(&wg)
684 - if serverErr != nil {
685 - t.Fatalf("Error initializing server: %s", serverErr)
686 - }
687 -
688 - conn, dialErr := net.Dial("tcp", listen)
689 - if dialErr != nil {
690 - t.Fatalf("Error dialing server: %s", dialErr)
691 - }
692 -
693 - spdyConn, spdyErr := NewConnection(conn, false)
694 - if spdyErr != nil {
695 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
696 - }
697 - go spdyConn.Serve(NoOpStreamHandler)
698 -
699 - authenticated = true
700 - stream, streamErr := spdyConn.CreateStream(http.Header{}, nil, false)
701 - if streamErr != nil {
702 - t.Fatalf("Error creating stream: %s", streamErr)
703 - }
704 -
705 - buf := []byte("dskjahfkdusahfkdsahfkdsafdkas")
706 - for i := 0; i < 10; i++ {
707 - if _, err := stream.Write(buf); err != nil {
708 - t.Fatalf("Error writing to stream: %s", err)
709 - }
710 - }
711 - for i := 0; i < 10; i++ {
712 - if _, err := stream.Read(buf); err != nil {
713 - t.Fatalf("Error reading from stream: %s", err)
714 - }
715 - }
716 -
717 - // fmt.Printf("Resetting...\n")
718 - if err := stream.Reset(); err != nil {
719 - t.Fatalf("Error reseting stream: %s", err)
720 - }
721 -
722 - closeErr := server.Close()
723 - if closeErr != nil {
724 - t.Fatalf("Error shutting down server: %s", closeErr)
725 - }
726 - wg.Wait()
727 -}
728 -
729 -func TestStreamResetWithDataRemaining(t *testing.T) {
730 - var wg sync.WaitGroup
731 - server, listen, serverErr := runServer(&wg)
732 - if serverErr != nil {
733 - t.Fatalf("Error initializing server: %s", serverErr)
734 - }
735 -
736 - conn, dialErr := net.Dial("tcp", listen)
737 - if dialErr != nil {
738 - t.Fatalf("Error dialing server: %s", dialErr)
739 - }
740 -
741 - spdyConn, spdyErr := NewConnection(conn, false)
742 - if spdyErr != nil {
743 - t.Fatalf("Error creating spdy connection: %s", spdyErr)
744 - }
745 - go spdyConn.Serve(NoOpStreamHandler)
746 -
747 - authenticated = true
748 - stream, streamErr := spdyConn.CreateStream(http.Header{}, nil, false)
749 - if streamErr != nil {
750 - t.Fatalf("Error creating stream: %s", streamErr)
751 - }
752 -
753 - buf := []byte("dskjahfkdusahfkdsahfkdsafdkas")
754 - for i := 0; i < 10; i++ {
755 - if _, err := stream.Write(buf); err != nil {
756 - t.Fatalf("Error writing to stream: %s", err)
757 - }
758 - }
759 -
760 - // read a bit to make sure a goroutine gets to <-dataChan
761 - if _, err := stream.Read(buf); err != nil {
762 - t.Fatalf("Error reading from stream: %s", err)
763 - }
764 -
765 - // fmt.Printf("Resetting...\n")
766 - if err := stream.Reset(); err != nil {
767 - t.Fatalf("Error reseting stream: %s", err)
768 - }
769 -
770 - closeErr := server.Close()
771 - if closeErr != nil {
772 - t.Fatalf("Error shutting down server: %s", closeErr)
773 - }
774 - wg.Wait()
775 -}
776 -
777 -type roundTripper struct {
778 - conn net.Conn
779 -}
780 -
781 -func (s *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
782 - r := *req
783 - req = &r
784 -
785 - conn, err := net.Dial("tcp", req.URL.Host)
786 - if err != nil {
787 - return nil, err
788 - }
789 -
790 - err = req.Write(conn)
791 - if err != nil {
792 - return nil, err
793 - }
794 -
795 - resp, err := http.ReadResponse(bufio.NewReader(conn), req)
796 - if err != nil {
797 - return nil, err
798 - }
799 -
800 - s.conn = conn
801 -
802 - return resp, nil
803 -}
804 -
805 -// see https://github.com/GoogleCloudPlatform/kubernetes/issues/4882
806 -func TestFramingAfterRemoteConnectionClosed(t *testing.T) {
807 - server := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
808 - streamCh := make(chan *Stream)
809 -
810 - w.WriteHeader(http.StatusSwitchingProtocols)
811 -
812 - netconn, _, _ := w.(http.Hijacker).Hijack()
813 - conn, _ := NewConnection(netconn, true)
814 - go conn.Serve(func(s *Stream) {
815 - s.SendReply(http.Header{}, false)
816 - streamCh <- s
817 - })
818 -
819 - stream := <-streamCh
820 - io.Copy(stream, stream)
821 -
822 - closeChan := make(chan struct{})
823 - go func() {
824 - stream.Reset()
825 - conn.Close()
826 - close(closeChan)
827 - }()
828 -
829 - <-closeChan
830 - }))
831 -
832 - server.Start()
833 - defer server.Close()
834 -
835 - req, err := http.NewRequest("GET", server.URL, nil)
836 - if err != nil {
837 - t.Fatalf("Error creating request: %s", err)
838 - }
839 -
840 - rt := &roundTripper{}
841 - client := &http.Client{Transport: rt}
842 -
843 - _, err = client.Do(req)
844 - if err != nil {
845 - t.Fatalf("unexpected error from client.Do: %s", err)
846 - }
847 -
848 - conn, err := NewConnection(rt.conn, false)
849 - go conn.Serve(NoOpStreamHandler)
850 -
851 - stream, err := conn.CreateStream(http.Header{}, nil, false)
852 - if err != nil {
853 - t.Fatalf("error creating client stream: %s", err)
854 - }
855 -
856 - n, err := stream.Write([]byte("hello"))
857 - if err != nil {
858 - t.Fatalf("error writing to stream: %s", err)
859 - }
860 - if n != 5 {
861 - t.Fatalf("Expected to write 5 bytes, but actually wrote %d", n)
862 - }
863 -
864 - b := make([]byte, 5)
865 - n, err = stream.Read(b)
866 - if err != nil {
867 - t.Fatalf("error reading from stream: %s", err)
868 - }
869 - if n != 5 {
870 - t.Fatalf("Expected to read 5 bytes, but actually read %d", n)
871 - }
872 - if e, a := "hello", string(b[0:n]); e != a {
873 - t.Fatalf("expected '%s', got '%s'", e, a)
874 - }
875 -
876 - stream.Reset()
877 - conn.Close()
878 -}
879 -
880 -var authenticated bool
881 -
882 -func authStreamHandler(stream *Stream) {
883 - if !authenticated {
884 - stream.Refuse()
885 - }
886 - MirrorStreamHandler(stream)
887 -}
888 -
889 -func runServer(wg *sync.WaitGroup) (io.Closer, string, error) {
890 - listener, listenErr := net.Listen("tcp", "localhost:0")
891 - if listenErr != nil {
892 - return nil, "", listenErr
893 - }
894 - wg.Add(1)
895 - go func() {
896 - for {
897 - conn, connErr := listener.Accept()
898 - if connErr != nil {
899 - break
900 - }
901 -
902 - spdyConn, _ := NewConnection(conn, true)
903 - go spdyConn.Serve(authStreamHandler)
904 -
905 - }
906 - wg.Done()
907 - }()
908 - return listener, listener.Addr().String(), nil
909 -}
Godeps/_workspace/src/github.com/docker/spdystream/stream.go deleted
-327
@@ -1,327 +0,0 @@
1 -package spdystream
2 -
3 -import (
4 - "errors"
5 - "fmt"
6 - "io"
7 - "net"
8 - "net/http"
9 - "sync"
10 - "time"
11 -
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/docker/spdystream/spdy"
13 -)
14 -
15 -var (
16 - ErrUnreadPartialData = errors.New("unread partial data")
17 -)
18 -
19 -type Stream struct {
20 - streamId spdy.StreamId
21 - parent *Stream
22 - conn *Connection
23 - startChan chan error
24 -
25 - dataLock sync.RWMutex
26 - dataChan chan []byte
27 - unread []byte
28 -
29 - priority uint8
30 - headers http.Header
31 - headerChan chan http.Header
32 - finishLock sync.Mutex
33 - finished bool
34 - replyCond *sync.Cond
35 - replied bool
36 - closeLock sync.Mutex
37 - closeChan chan bool
38 -}
39 -
40 -// WriteData writes data to stream, sending a dataframe per call
41 -func (s *Stream) WriteData(data []byte, fin bool) error {
42 - s.waitWriteReply()
43 - var flags spdy.DataFlags
44 -
45 - if fin {
46 - flags = spdy.DataFlagFin
47 - s.finishLock.Lock()
48 - if s.finished {
49 - s.finishLock.Unlock()
50 - return ErrWriteClosedStream
51 - }
52 - s.finished = true
53 - s.finishLock.Unlock()
54 - }
55 -
56 - dataFrame := &spdy.DataFrame{
57 - StreamId: s.streamId,
58 - Flags: flags,
59 - Data: data,
60 - }
61 -
62 - debugMessage("(%p) (%d) Writing data frame", s, s.streamId)
63 - return s.conn.framer.WriteFrame(dataFrame)
64 -}
65 -
66 -// Write writes bytes to a stream, calling write data for each call.
67 -func (s *Stream) Write(data []byte) (n int, err error) {
68 - err = s.WriteData(data, false)
69 - if err == nil {
70 - n = len(data)
71 - }
72 - return
73 -}
74 -
75 -// Read reads bytes from a stream, a single read will never get more
76 -// than what is sent on a single data frame, but a multiple calls to
77 -// read may get data from the same data frame.
78 -func (s *Stream) Read(p []byte) (n int, err error) {
79 - if s.unread == nil {
80 - select {
81 - case <-s.closeChan:
82 - return 0, io.EOF
83 - case read, ok := <-s.dataChan:
84 - if !ok {
85 - return 0, io.EOF
86 - }
87 - s.unread = read
88 - }
89 - }
90 - n = copy(p, s.unread)
91 - if n < len(s.unread) {
92 - s.unread = s.unread[n:]
93 - } else {
94 - s.unread = nil
95 - }
96 - return
97 -}
98 -
99 -// ReadData reads an entire data frame and returns the byte array
100 -// from the data frame. If there is unread data from the result
101 -// of a Read call, this function will return an ErrUnreadPartialData.
102 -func (s *Stream) ReadData() ([]byte, error) {
103 - debugMessage("(%p) Reading data from %d", s, s.streamId)
104 - if s.unread != nil {
105 - return nil, ErrUnreadPartialData
106 - }
107 - select {
108 - case <-s.closeChan:
109 - return nil, io.EOF
110 - case read, ok := <-s.dataChan:
111 - if !ok {
112 - return nil, io.EOF
113 - }
114 - return read, nil
115 - }
116 -}
117 -
118 -func (s *Stream) waitWriteReply() {
119 - if s.replyCond != nil {
120 - s.replyCond.L.Lock()
121 - for !s.replied {
122 - s.replyCond.Wait()
123 - }
124 - s.replyCond.L.Unlock()
125 - }
126 -}
127 -
128 -// Wait waits for the stream to receive a reply.
129 -func (s *Stream) Wait() error {
130 - return s.WaitTimeout(time.Duration(0))
131 -}
132 -
133 -// WaitTimeout waits for the stream to receive a reply or for timeout.
134 -// When the timeout is reached, ErrTimeout will be returned.
135 -func (s *Stream) WaitTimeout(timeout time.Duration) error {
136 - var timeoutChan <-chan time.Time
137 - if timeout > time.Duration(0) {
138 - timeoutChan = time.After(timeout)
139 - }
140 -
141 - select {
142 - case err := <-s.startChan:
143 - if err != nil {
144 - return err
145 - }
146 - break
147 - case <-timeoutChan:
148 - return ErrTimeout
149 - }
150 - return nil
151 -}
152 -
153 -// Close closes the stream by sending an empty data frame with the
154 -// finish flag set, indicating this side is finished with the stream.
155 -func (s *Stream) Close() error {
156 - select {
157 - case <-s.closeChan:
158 - // Stream is now fully closed
159 - s.conn.removeStream(s)
160 - default:
161 - break
162 - }
163 - return s.WriteData([]byte{}, true)
164 -}
165 -
166 -// Reset sends a reset frame, putting the stream into the fully closed state.
167 -func (s *Stream) Reset() error {
168 - s.conn.removeStream(s)
169 - return s.resetStream()
170 -}
171 -
172 -func (s *Stream) resetStream() error {
173 - s.finishLock.Lock()
174 - if s.finished {
175 - s.finishLock.Unlock()
176 - return nil
177 - }
178 - s.finished = true
179 - s.finishLock.Unlock()
180 -
181 - s.closeRemoteChannels()
182 -
183 - resetFrame := &spdy.RstStreamFrame{
184 - StreamId: s.streamId,
185 - Status: spdy.Cancel,
186 - }
187 - return s.conn.framer.WriteFrame(resetFrame)
188 -}
189 -
190 -// CreateSubStream creates a stream using the current as the parent
191 -func (s *Stream) CreateSubStream(headers http.Header, fin bool) (*Stream, error) {
192 - return s.conn.CreateStream(headers, s, fin)
193 -}
194 -
195 -// SetPriority sets the stream priority, does not affect the
196 -// remote priority of this stream after Open has been called.
197 -// Valid values are 0 through 7, 0 being the highest priority
198 -// and 7 the lowest.
199 -func (s *Stream) SetPriority(priority uint8) {
200 - s.priority = priority
201 -}
202 -
203 -// SendHeader sends a header frame across the stream
204 -func (s *Stream) SendHeader(headers http.Header, fin bool) error {
205 - return s.conn.sendHeaders(headers, s, fin)
206 -}
207 -
208 -// SendReply sends a reply on a stream, only valid to be called once
209 -// when handling a new stream
210 -func (s *Stream) SendReply(headers http.Header, fin bool) error {
211 - if s.replyCond == nil {
212 - return errors.New("cannot reply on initiated stream")
213 - }
214 - s.replyCond.L.Lock()
215 - defer s.replyCond.L.Unlock()
216 - if s.replied {
217 - return nil
218 - }
219 -
220 - err := s.conn.sendReply(headers, s, fin)
221 - if err != nil {
222 - return err
223 - }
224 -
225 - s.replied = true
226 - s.replyCond.Broadcast()
227 - return nil
228 -}
229 -
230 -// Refuse sends a reset frame with the status refuse, only
231 -// valid to be called once when handling a new stream. This
232 -// may be used to indicate that a stream is not allowed
233 -// when http status codes are not being used.
234 -func (s *Stream) Refuse() error {
235 - if s.replied {
236 - return nil
237 - }
238 - s.replied = true
239 - return s.conn.sendReset(spdy.RefusedStream, s)
240 -}
241 -
242 -// Cancel sends a reset frame with the status canceled. This
243 -// can be used at any time by the creator of the Stream to
244 -// indicate the stream is no longer needed.
245 -func (s *Stream) Cancel() error {
246 - return s.conn.sendReset(spdy.Cancel, s)
247 -}
248 -
249 -// ReceiveHeader receives a header sent on the other side
250 -// of the stream. This function will block until a header
251 -// is received or stream is closed.
252 -func (s *Stream) ReceiveHeader() (http.Header, error) {
253 - select {
254 - case <-s.closeChan:
255 - break
256 - case header, ok := <-s.headerChan:
257 - if !ok {
258 - return nil, fmt.Errorf("header chan closed")
259 - }
260 - return header, nil
261 - }
262 - return nil, fmt.Errorf("stream closed")
263 -}
264 -
265 -// Parent returns the parent stream
266 -func (s *Stream) Parent() *Stream {
267 - return s.parent
268 -}
269 -
270 -// Headers returns the headers used to create the stream
271 -func (s *Stream) Headers() http.Header {
272 - return s.headers
273 -}
274 -
275 -// String returns the string version of stream using the
276 -// streamId to uniquely identify the stream
277 -func (s *Stream) String() string {
278 - return fmt.Sprintf("stream:%d", s.streamId)
279 -}
280 -
281 -// Identifier returns a 32 bit identifier for the stream
282 -func (s *Stream) Identifier() uint32 {
283 - return uint32(s.streamId)
284 -}
285 -
286 -// IsFinished returns whether the stream has finished
287 -// sending data
288 -func (s *Stream) IsFinished() bool {
289 - return s.finished
290 -}
291 -
292 -// Implement net.Conn interface
293 -
294 -func (s *Stream) LocalAddr() net.Addr {
295 - return s.conn.conn.LocalAddr()
296 -}
297 -
298 -func (s *Stream) RemoteAddr() net.Addr {
299 - return s.conn.conn.RemoteAddr()
300 -}
301 -
302 -// TODO set per stream values instead of connection-wide
303 -
304 -func (s *Stream) SetDeadline(t time.Time) error {
305 - return s.conn.conn.SetDeadline(t)
306 -}
307 -
308 -func (s *Stream) SetReadDeadline(t time.Time) error {
309 - return s.conn.conn.SetReadDeadline(t)
310 -}
311 -
312 -func (s *Stream) SetWriteDeadline(t time.Time) error {
313 - return s.conn.conn.SetWriteDeadline(t)
314 -}
315 -
316 -func (s *Stream) closeRemoteChannels() {
317 - s.closeLock.Lock()
318 - defer s.closeLock.Unlock()
319 - select {
320 - case <-s.closeChan:
321 - default:
322 - close(s.closeChan)
323 - s.dataLock.Lock()
324 - defer s.dataLock.Unlock()
325 - close(s.dataChan)
326 - }
327 -}
Godeps/_workspace/src/github.com/docker/spdystream/utils.go deleted
-16
@@ -1,16 +0,0 @@
1 -package spdystream
2 -
3 -import (
4 - "log"
5 - "os"
6 -)
7 -
8 -var (
9 - DEBUG = os.Getenv("DEBUG")
10 -)
11 -
12 -func debugMessage(fmt string, args ...interface{}) {
13 - if DEBUG != "" {
14 - log.Printf(fmt, args...)
15 - }
16 -}
Godeps/_workspace/src/github.com/docker/spdystream/ws/connection.go deleted
-65
@@ -1,65 +0,0 @@
1 -package ws
2 -
3 -import (
4 - "gx/ipfs/QmUe1Ljrtwz5NSKqJRw5mgjthSSfW7g94hkGRqiQs5aJna/websocket"
5 - "io"
6 - "log"
7 - "time"
8 -)
9 -
10 -// Wrap an HTTP2 connection over WebSockets and
11 -// use the underlying WebSocket framing for proxy
12 -// compatibility.
13 -type Conn struct {
14 - *websocket.Conn
15 - reader io.Reader
16 -}
17 -
18 -func NewConnection(w *websocket.Conn) *Conn {
19 - return &Conn{Conn: w}
20 -}
21 -
22 -func (c Conn) Write(b []byte) (int, error) {
23 - err := c.WriteMessage(websocket.BinaryMessage, b)
24 - if err != nil {
25 - return 0, err
26 - }
27 - return len(b), nil
28 -}
29 -
30 -func (c Conn) Read(b []byte) (int, error) {
31 - if c.reader == nil {
32 - t, r, err := c.NextReader()
33 - if err != nil {
34 - return 0, err
35 - }
36 - if t != websocket.BinaryMessage {
37 - log.Printf("ws: ignored non-binary message in stream")
38 - return 0, nil
39 - }
40 - c.reader = r
41 - }
42 - n, err := c.reader.Read(b)
43 - if err != nil {
44 - if err == io.EOF {
45 - c.reader = nil
46 - }
47 - return n, err
48 - }
49 - return n, nil
50 -}
51 -
52 -func (c Conn) SetDeadline(t time.Time) error {
53 - if err := c.Conn.SetReadDeadline(t); err != nil {
54 - return err
55 - }
56 - if err := c.Conn.SetWriteDeadline(t); err != nil {
57 - return err
58 - }
59 - return nil
60 -}
61 -
62 -func (c Conn) Close() error {
63 - err := c.Conn.Close()
64 - return err
65 -}
Godeps/_workspace/src/github.com/docker/spdystream/ws/ws_test.go deleted
-175
@@ -1,175 +0,0 @@
1 -package ws
2 -
3 -import (
4 - "bytes"
5 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/docker/spdystream"
6 - "gx/ipfs/QmUe1Ljrtwz5NSKqJRw5mgjthSSfW7g94hkGRqiQs5aJna/websocket"
7 - "io"
8 - "log"
9 - "net/http"
10 - "net/http/httptest"
11 - "strings"
12 - "testing"
13 -)
14 -
15 -var upgrader = websocket.Upgrader{
16 - ReadBufferSize: 1024,
17 - WriteBufferSize: 1024,
18 -}
19 -
20 -var serverSpdyConn *spdystream.Connection
21 -
22 -// Connect to the Websocket endpoint at ws://localhost
23 -// using SPDY over Websockets framing.
24 -func ExampleConn() {
25 - wsconn, _, _ := websocket.DefaultDialer.Dial("ws://localhost/", http.Header{"Origin": {"http://localhost/"}})
26 - conn, _ := spdystream.NewConnection(NewConnection(wsconn), false)
27 - go conn.Serve(spdystream.NoOpStreamHandler, spdystream.NoAuthHandler)
28 - stream, _ := conn.CreateStream(http.Header{}, nil, false)
29 - stream.Wait()
30 -}
31 -
32 -func serveWs(w http.ResponseWriter, r *http.Request) {
33 - if r.Method != "GET" {
34 - http.Error(w, "Method not allowed", 405)
35 - return
36 - }
37 -
38 - ws, err := upgrader.Upgrade(w, r, nil)
39 - if err != nil {
40 - if _, ok := err.(websocket.HandshakeError); !ok {
41 - log.Println(err)
42 - }
43 - return
44 - }
45 -
46 - wrap := NewConnection(ws)
47 - spdyConn, err := spdystream.NewConnection(wrap, true)
48 - if err != nil {
49 - log.Fatal(err)
50 - return
51 - }
52 - serverSpdyConn = spdyConn
53 - go spdyConn.Serve(spdystream.MirrorStreamHandler, authStreamHandler)
54 -}
55 -
56 -func TestSpdyStreamOverWs(t *testing.T) {
57 - server := httptest.NewServer(http.HandlerFunc(serveWs))
58 - defer server.Close()
59 - defer func() {
60 - if serverSpdyConn != nil {
61 - serverSpdyConn.Close()
62 - }
63 - }()
64 -
65 - wsconn, _, err := websocket.DefaultDialer.Dial(strings.Replace(server.URL, "http://", "ws://", 1), http.Header{"Origin": {server.URL}})
66 - if err != nil {
67 - t.Fatal(err)
68 - }
69 -
70 - wrap := NewConnection(wsconn)
71 - spdyConn, err := spdystream.NewConnection(wrap, false)
72 - if err != nil {
73 - defer wsconn.Close()
74 - t.Fatal(err)
75 - }
76 - defer spdyConn.Close()
77 - authenticated = true
78 - go spdyConn.Serve(spdystream.NoOpStreamHandler, spdystream.RejectAuthHandler)
79 -
80 - stream, streamErr := spdyConn.CreateStream(http.Header{}, nil, false)
81 - if streamErr != nil {
82 - t.Fatalf("Error creating stream: %s", streamErr)
83 - }
84 -
85 - waitErr := stream.Wait()
86 - if waitErr != nil {
87 - t.Fatalf("Error waiting for stream: %s", waitErr)
88 - }
89 -
90 - message := []byte("hello")
91 - writeErr := stream.WriteData(message, false)
92 - if writeErr != nil {
93 - t.Fatalf("Error writing data")
94 - }
95 -
96 - buf := make([]byte, 10)
97 - n, readErr := stream.Read(buf)
98 - if readErr != nil {
99 - t.Fatalf("Error reading data from stream: %s", readErr)
100 - }
101 - if n != 5 {
102 - t.Fatalf("Unexpected number of bytes read:\nActual: %d\nExpected: 5", n)
103 - }
104 - if bytes.Compare(buf[:n], message) != 0 {
105 - t.Fatalf("Did not receive expected message:\nActual: %s\nExpectd: %s", buf, message)
106 - }
107 -
108 - writeErr = stream.WriteData(message, true)
109 - if writeErr != nil {
110 - t.Fatalf("Error writing data")
111 - }
112 -
113 - smallBuf := make([]byte, 3)
114 - n, readErr = stream.Read(smallBuf)
115 - if readErr != nil {
116 - t.Fatalf("Error reading data from stream: %s", readErr)
117 - }
118 - if n != 3 {
119 - t.Fatalf("Unexpected number of bytes read:\nActual: %d\nExpected: 3", n)
120 - }
121 - if bytes.Compare(smallBuf[:n], []byte("hel")) != 0 {
122 - t.Fatalf("Did not receive expected message:\nActual: %s\nExpectd: %s", smallBuf[:n], message)
123 - }
124 - n, readErr = stream.Read(smallBuf)
125 - if readErr != nil {
126 - t.Fatalf("Error reading data from stream: %s", readErr)
127 - }
128 - if n != 2 {
129 - t.Fatalf("Unexpected number of bytes read:\nActual: %d\nExpected: 2", n)
130 - }
131 - if bytes.Compare(smallBuf[:n], []byte("lo")) != 0 {
132 - t.Fatalf("Did not receive expected message:\nActual: %s\nExpected: lo", smallBuf[:n])
133 - }
134 -
135 - n, readErr = stream.Read(buf)
136 - if readErr != io.EOF {
137 - t.Fatalf("Expected EOF reading from finished stream, read %d bytes", n)
138 - }
139 -
140 - streamCloseErr := stream.Close()
141 - if streamCloseErr != nil {
142 - t.Fatalf("Error closing stream: %s", streamCloseErr)
143 - }
144 -
145 - // Closing again should return nil
146 - streamCloseErr = stream.Close()
147 - if streamCloseErr != nil {
148 - t.Fatalf("Error closing stream: %s", streamCloseErr)
149 - }
150 -
151 - authenticated = false
152 - badStream, badStreamErr := spdyConn.CreateStream(http.Header{}, nil, false)
153 - if badStreamErr != nil {
154 - t.Fatalf("Error creating stream: %s", badStreamErr)
155 - }
156 -
157 - waitErr = badStream.Wait()
158 - if waitErr == nil {
159 - t.Fatalf("Did not receive error creating stream")
160 - }
161 - if waitErr != spdystream.ErrReset {
162 - t.Fatalf("Unexpected error creating stream: %s", waitErr)
163 - }
164 -
165 - spdyCloseErr := spdyConn.Close()
166 - if spdyCloseErr != nil {
167 - t.Fatalf("Error closing spdy connection: %s", spdyCloseErr)
168 - }
169 -}
170 -
171 -var authenticated bool
172 -
173 -func authStreamHandler(header http.Header, slot uint8, parent uint32) bool {
174 - return authenticated
175 -}
Godeps/_workspace/src/github.com/jbenet/go-base58/LICENSE deleted
-13
@@ -1,13 +0,0 @@
1 -Copyright (c) 2013 Conformal Systems LLC.
2 -
3 -Permission to use, copy, modify, and distribute this software for any
4 -purpose with or without fee is hereby granted, provided that the above
5 -copyright notice and this permission notice appear in all copies.
6 -
7 -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
\ No newline at end of file
Godeps/_workspace/src/github.com/jbenet/go-base58/README.md deleted
-66
@@ -1,66 +0,0 @@
1 -# go-base58
2 -
3 -I extracted this package from https://github.com/conformal/btcutil to provide a simple base58 package that
4 -- defaults to base58-check (btc)
5 -- and allows using different alphabets.
6 -
7 -## Usage
8 -
9 -```go
10 -package main
11 -
12 -import (
13 - "fmt"
14 - b58 "github.com/jbenet/go-base58"
15 -)
16 -
17 -func main() {
18 - buf := []byte{255, 254, 253, 252}
19 - fmt.Printf("buffer: %v\n", buf)
20 -
21 - str := b58.Encode(buf)
22 - fmt.Printf("encoded: %s\n", str)
23 -
24 - buf2 := b58.Decode(str)
25 - fmt.Printf("decoded: %v\n", buf2)
26 -}
27 -```
28 -
29 -### Another alphabet
30 -
31 -```go
32 -package main
33 -
34 -import (
35 - "fmt"
36 - b58 "github.com/jbenet/go-base58"
37 -)
38 -
39 -const BogusAlphabet = "ZYXWVUTSRQPNMLKJHGFEDCBAzyxwvutsrqponmkjihgfedcba987654321"
40 -
41 -
42 -func encdec(alphabet string) {
43 - fmt.Printf("using: %s\n", alphabet)
44 -
45 - buf := []byte{255, 254, 253, 252}
46 - fmt.Printf("buffer: %v\n", buf)
47 -
48 - str := b58.EncodeAlphabet(buf, alphabet)
49 - fmt.Printf("encoded: %s\n", str)
50 -
51 - buf2 := b58.DecodeAlphabet(str, alphabet)
52 - fmt.Printf("decoded: %v\n\n", buf2)
53 -}
54 -
55 -
56 -func main() {
57 - encdec(b58.BTCAlphabet)
58 - encdec(b58.FlickrAlphabet)
59 - encdec(BogusAlphabet)
60 -}
61 -```
62 -
63 -
64 -## License
65 -
66 -Package base58 (and the original btcutil) are licensed under the ISC License.
Godeps/_workspace/src/github.com/jbenet/go-base58/base58.go deleted
-90
@@ -1,90 +0,0 @@
1 -// Copyright (c) 2013-2014 Conformal Systems LLC.
2 -// Use of this source code is governed by an ISC
3 -// license that can be found in the LICENSE file.
4 -// Modified by Juan Benet (juan@benet.ai)
5 -
6 -package base58
7 -
8 -import (
9 - "math/big"
10 - "strings"
11 -)
12 -
13 -// alphabet is the modified base58 alphabet used by Bitcoin.
14 -const BTCAlphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
15 -const FlickrAlphabet = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
16 -
17 -var bigRadix = big.NewInt(58)
18 -var bigZero = big.NewInt(0)
19 -
20 -// Decode decodes a modified base58 string to a byte slice, using BTCAlphabet
21 -func Decode(b string) []byte {
22 - return DecodeAlphabet(b, BTCAlphabet)
23 -}
24 -
25 -// Encode encodes a byte slice to a modified base58 string, using BTCAlphabet
26 -func Encode(b []byte) string {
27 - return EncodeAlphabet(b, BTCAlphabet)
28 -}
29 -
30 -// DecodeAlphabet decodes a modified base58 string to a byte slice, using alphabet.
31 -func DecodeAlphabet(b, alphabet string) []byte {
32 - answer := big.NewInt(0)
33 - j := big.NewInt(1)
34 -
35 - for i := len(b) - 1; i >= 0; i-- {
36 - tmp := strings.IndexAny(alphabet, string(b[i]))
37 - if tmp == -1 {
38 - return []byte("")
39 - }
40 - idx := big.NewInt(int64(tmp))
41 - tmp1 := big.NewInt(0)
42 - tmp1.Mul(j, idx)
43 -
44 - answer.Add(answer, tmp1)
45 - j.Mul(j, bigRadix)
46 - }
47 -
48 - tmpval := answer.Bytes()
49 -
50 - var numZeros int
51 - for numZeros = 0; numZeros < len(b); numZeros++ {
52 - if b[numZeros] != alphabet[0] {
53 - break
54 - }
55 - }
56 - flen := numZeros + len(tmpval)
57 - val := make([]byte, flen, flen)
58 - copy(val[numZeros:], tmpval)
59 -
60 - return val
61 -}
62 -
63 -// Encode encodes a byte slice to a modified base58 string, using alphabet
64 -func EncodeAlphabet(b []byte, alphabet string) string {
65 - x := new(big.Int)
66 - x.SetBytes(b)
67 -
68 - answer := make([]byte, 0, len(b)*136/100)
69 - for x.Cmp(bigZero) > 0 {
70 - mod := new(big.Int)
71 - x.DivMod(x, bigRadix, mod)
72 - answer = append(answer, alphabet[mod.Int64()])
73 - }
74 -
75 - // leading zero bytes
76 - for _, i := range b {
77 - if i != 0 {
78 - break
79 - }
80 - answer = append(answer, alphabet[0])
81 - }
82 -
83 - // reverse
84 - alen := len(answer)
85 - for i := 0; i < alen/2; i++ {
86 - answer[i], answer[alen-1-i] = answer[alen-1-i], answer[i]
87 - }
88 -
89 - return string(answer)
90 -}
Godeps/_workspace/src/github.com/jbenet/go-base58/base58_test.go deleted
-130
@@ -1,130 +0,0 @@
1 -// Copyright (c) 2013-2014 Conformal Systems LLC.
2 -// Use of this source code is governed by an ISC
3 -// license that can be found in the LICENSE file.
4 -
5 -package base58
6 -
7 -import (
8 - "bytes"
9 - "encoding/hex"
10 - "testing"
11 -)
12 -
13 -var stringTests = []struct {
14 - in string
15 - out string
16 -}{
17 - {"", ""},
18 - {" ", "Z"},
19 - {"-", "n"},
20 - {"0", "q"},
21 - {"1", "r"},
22 - {"-1", "4SU"},
23 - {"11", "4k8"},
24 - {"abc", "ZiCa"},
25 - {"1234598760", "3mJr7AoUXx2Wqd"},
26 - {"abcdefghijklmnopqrstuvwxyz", "3yxU3u1igY8WkgtjK92fbJQCd4BZiiT1v25f"},
27 - {"00000000000000000000000000000000000000000000000000000000000000", "3sN2THZeE9Eh9eYrwkvZqNstbHGvrxSAM7gXUXvyFQP8XvQLUqNCS27icwUeDT7ckHm4FUHM2mTVh1vbLmk7y"},
28 -}
29 -
30 -var invalidStringTests = []struct {
31 - in string
32 - out string
33 -}{
34 - {"0", ""},
35 - {"O", ""},
36 - {"I", ""},
37 - {"l", ""},
38 - {"3mJr0", ""},
39 - {"O3yxU", ""},
40 - {"3sNI", ""},
41 - {"4kl8", ""},
42 - {"0OIl", ""},
43 - {"!@#$%^&*()-_=+~`", ""},
44 -}
45 -
46 -var hexTests = []struct {
47 - in string
48 - out string
49 -}{
50 - {"61", "2g"},
51 - {"626262", "a3gV"},
52 - {"636363", "aPEr"},
53 - {"73696d706c792061206c6f6e6720737472696e67", "2cFupjhnEsSn59qHXstmK2ffpLv2"},
54 - {"00eb15231dfceb60925886b67d065299925915aeb172c06647", "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"},
55 - {"516b6fcd0f", "ABnLTmg"},
56 - {"bf4f89001e670274dd", "3SEo3LWLoPntC"},
57 - {"572e4794", "3EFU7m"},
58 - {"ecac89cad93923c02321", "EJDM8drfXA6uyA"},
59 - {"10c8511e", "Rt5zm"},
60 - {"00000000000000000000", "1111111111"},
61 -}
62 -
63 -func TestBase58(t *testing.T) {
64 - // Base58Encode tests
65 - for x, test := range stringTests {
66 - tmp := []byte(test.in)
67 - if res := Encode(tmp); res != test.out {
68 - t.Errorf("Base58Encode test #%d failed: got: %s want: %s",
69 - x, res, test.out)
70 - continue
71 - }
72 - }
73 -
74 - // Base58Decode tests
75 - for x, test := range hexTests {
76 - b, err := hex.DecodeString(test.in)
77 - if err != nil {
78 - t.Errorf("hex.DecodeString failed failed #%d: got: %s", x, test.in)
79 - continue
80 - }
81 - if res := Decode(test.out); bytes.Equal(res, b) != true {
82 - t.Errorf("Base58Decode test #%d failed: got: %q want: %q",
83 - x, res, test.in)
84 - continue
85 - }
86 - }
87 -
88 - // Base58Decode with invalid input
89 - for x, test := range invalidStringTests {
90 - if res := Decode(test.in); string(res) != test.out {
91 - t.Errorf("Base58Decode invalidString test #%d failed: got: %q want: %q",
92 - x, res, test.out)
93 - continue
94 - }
95 - }
96 -}
97 -
98 -func BenchmarkDecodeShort(b *testing.B) {
99 - const in = "1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"
100 - b.ReportAllocs()
101 - for i := 0; i < b.N; i++ {
102 - _ = Decode(in)
103 - }
104 -}
105 -
106 -func BenchmarkEncodeShort(b *testing.B) {
107 - var in = []byte("00eb15231dfceb60925886b67d065299925915aeb172c06647")
108 - b.ReportAllocs()
109 - for i := 0; i < b.N; i++ {
110 - _ = Encode(in)
111 - }
112 -}
113 -
114 -func BenchmarkDecodeOneKilo(b *testing.B) {
115 - const in = "3GimCffBLAHhXMCeNxX2nST6dBem9pbUi3KVKykW73LmewcFtMk9oh9eNPdNR2eSzNqp7Z3E21vrWUkGHzJ7w2yqDUDJ4LKo1w5D6aafZ4SUoNQyrSVxyVG3pwgoZkKXMZVixRyiPZVUpekrsTvZuUoW7mB6BQgDTXbDuMMSRoNR7yiUTKpgwTD61DLmhNZopNxfFjn4avpYPgzsTB94iWueq1yU3EoruWCUMvp6fc1CEbDrZY3pkx9oUbUaSMC37rruBKSSGHh1ZE3XK3kQXBCFraMmUQf8dagofMEg5aTnDiLAZjLyWJMdnQwW1FqKKztP8KAQS2JX8GCCfc68KB4VGf2CfEGXtaapnsNWFrHuWi7Wo5vqyuHd21zGm1u5rsiR6tKNCsFC4nzf3WUNxJNoZrDSdF9KERqhTWWmmcM4qdKRCtBWKTrs1DJD2oiK6BK9BgwoW2dfQdKuxojFyFvmxqPKDDAEZPPpJ51wHoFzBFMM1tUBBkN15cT2GpNwKzDcjHPKJAQ6FNRgppfQytzqpq76sSeZaWAB8hhULMJCQGU57ZUjvP7xYAQwtACBnYrjdxA91XwXFbq5AsQJwAmLw6euKVWNyv11BuHrejVmnNViWg5kuZBrtgL6NtzRWHtdxngHDMtuyky3brqGXaGQhUyXrkSpeknkkHL6NLThHH5NPnfFMVPwn2xf5UM5R51X2nTBzADSVcpi4cT7i44dT7o3yRKWtKfUzZiuNyTcSSrfH8KVdLap5ZKLmdPuXM65M2Z5wJVh3Uc4iv6iZKk44RKikM7zs1hqC4sBxRwLZjxhKvvMXDjDcYFkzyUkues4y7fjdCnVTxc4vTYUqcbY2k2WMssyj9SDseVc7dVrEvWCLQtYy79mJFoz1Hmsfk5ynE28ipznzQ3yTBugLHA6j6qW3S74eY4pJ6iynFEuXT4RqqkLGFcMh3goqS7CkphUMzP4wuJyGnzqa5tCno4U3dJ2jUL7Povg8voRqYAfiHyXC8zuhn225EdmRcSnu2pAuutQVV9hN3bkjfzAFUhUWKki8SwXtFSjy6NJyrYUiaze4p7ApsjHQBCgg2zAoBaGCwVN8991Jny31B5vPyYHy1oRSE4xTVZ7tTw9FyQ7w9p1NSEF4sziCxZHh5rFWZKAajc5c7KaMNDvHPNV6S62MTFGTyuKPQNbv9yHRGN4eH6SnZGW6snvEVdYCspWZ1U3Nbxo6vCmBK95UyYpcxHgg1CCGdU4s3edju2NDQkMifyPkJdkabzzHVDhJJbChAJc1ACQfNW74VXXwrBZmeZyA2R28MBctDyXuSuffiwueys2LVowLu9wiTHUox7KQjtHK2c9howk9czzx2mpnYzkVYH42CYsWa5514EM4CJEXPJSSbXSgJJ"
116 - b.SetBytes(int64(len(in))) // 1024
117 - b.ReportAllocs()
118 - for i := 0; i < b.N; i++ {
119 - _ = Decode(in)
120 - }
121 -}
122 -
123 -func BenchmarkEncodeOneKilo(b *testing.B) {
124 - var in = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x00\x00\x04\xff\xfb\x63\xc9\x7e\x5f\x97\x68\xe5\x10\x08\xe5\xa5\x9a\x7c\x24\x75\x35\xbe\xaf\x37\x0b\xc3\xf4\x18\x62\x4a\xb7\x18\xd0\x10\x0b\x6b\x62\xe1\x36\x0f\x62\xa6\xeb\x78\xa5\xf3\x33\x52\xbc\xdf\x04\xcb\x37\xcf\x3d\x97\x5c\xb8\x75\x09\x1f\x18\x9f\xfc\xa9\xda\x1e\x59\x77\x09\x9c\x5d\xb6\xf2\x9e\x45\xb7\x5e\x5d\x11\xf1\x20\x14\x85\xf8\x54\x87\x8c\x1e\x2c\x2e\x15\x57\x89\xe7\x5d\x49\xb6\xae\x24\x3a\x20\x50\x0e\xa7\x5b\x10\xbf\x0a\xb4\x01\x42\xed\xce\x2d\x45\x21\xb6\xe8\x64\x73\x4e\x7e\x0a\x36\x1d\x57\x0a\x5e\x1c\x21\xc2\xb8\xe7\x89\x82\xe4\x04\x7e\x50\xff\xda\x4f\xfe\x11\x95\xfb\x35\xf9\x6d\x32\xce\xef\x8f\x3d\x1b\xdb\x38\xfa\xcd\x26\x36\x12\x93\xa0\x96\xea\x42\xbe\xd6\x85\x86\xc1\xc1\xe2\x55\x41\xd1\x7f\x8d\x0e\x00\x81\x58\xb4\x10\xbb\x64\x92\x05\x07\xa9\xd5\xd9\x40\x28\x8b\x9b\x4c\x8d\x8e\x4e\x69\xf9\xc9\x35\xea\xda\x2f\x61\x87\x35\x2d\x6b\x25\x32\xf0\x7e\x89\x1a\xcb\xc0\xea\x66\x88\x99\x39\xe0\x3b\x24\x3b\x05\x74\xd3\x72\xf6\x48\x15\xdc\x02\x0a\xbf\xc8\x49\x42\x10\x22\xeb\xe9\x44\x71\x55\xaf\x67\x67\xe6\x2a\x40\x31\x81\xb9\x6f\x65\x86\x0f\x0f\x9d\x58\x4c\x51\xc1\x2e\x4e\x60\x7e\xe8\x93\x39\x90\xda\xe5\xbe\xec\xe4\xdd\xbc\x1d\xba\x40\xa6\x85\xd9\xb2\xec\xb4\x26\x74\xee\xc1\xec\xe3\x40\xb9\x49\xa3\xe1\x26\x76\x8a\xeb\x95\xc8\x72\xb0\x85\x36\x19\x3f\x55\x06\x7b\xcd\x3e\xd0\xdf\x7e\x8d\x2a\xea\xa6\x24\xc6\xf6\xfb\xda\xe0\x45\xcf\x32\x0e\xbc\xf4\x41\x7d\x71\x3d\x86\xf9\xb4\xaf\x07\xa0\xd1\x34\x8a\x02\x28\x56\xd4\xcc\x36\x44\x98\x44\xcb\x9d\xc5\xfc\x45\x2d\xc4\x5c\xfe\xce\xaa\x44\xda\x66\x52\x2d\x32\x6e\x13\x32\xac\xaf\x13\x72\x87\x79\xd2\x92\x54\x9f\xc7\xb9\xf3\x21\xae\xdd\x69\x44\xe9\x46\x94\x1c\x62\x84\x03\xe0\xbf\x66\xfb\xe0\x79\xf9\x57\x9e\x22\x9e\x23\x2d\x2a\x73\xeb\x74\x38\xf0\xea\x5d\xb3\x8f\x87\x26\x3e\x3c\x54\x11\xb7\x98\xbd\x7f\x78\x64\xa3\xf1\x8f\xa9\x5e\x4f\x18\x3f\xa7\x1f\x3a\x29\x27\x27\xb7\x49\x40\x16\x18\x1f\xd3\xed\x86\x61\xbd\xc3\x4e\x4a\x53\x37\x78\x5c\x00\xd3\x50\x45\x1c\x55\xc0\x9b\xd7\x62\x29\x88\x2e\xa4\x0d\x6a\x15\x6c\x33\x3c\xe7\x31\xfa\xc1\xaf\xdf\x7a\x3e\x37\x3e\xe5\xbc\xfd\xfb\x9b\x72\x10\x35\x90\x25\x6e\x87\x0d\x74\x1c\xfd\xe3\x0b\xee\xf5\x92\x28\x8d\x22\x8a\x49\x7b\xcd\xbb\xd8\x24\x6b\x5e\x58\x40\xec\x1b\x6c\xed\x8e\xcb\x56\x62\xa6\xb4\x42\x3d\x7d\xa2\xef\x27\x27\x46\x50\xbc\x5e\x37\x9b\x27\x72\xf0\xea\xa7\xe7\x4d\xf4\xae\x7e\x95\x8f\x91\x2e\x58\xc4\x6a\x06\xda\x7a\x06\x5c\x8d\xfe\xef\xf5\xb3\x0f\xb4\x0a\x20\x53\xd8\x35\x80\x02\xca\x97\x81\xb6\x1c\x4b\x8f\xb7\xee\xd0\xc3\x88\x6c\x76\x3e\xb0\x28\xce\xa1\x9f\x76\x5f\xaa\xc3\x53\x44\x09\x70\xa3\x95\xd9\x8c\x54\xba\x8a\x9a\x6b\xce\xc3\x07\xdf\x13\x6d\xea\x0f\x51\x9c\xe2\x81\x87\xf6\x82\x7a\x70\xd8\xfa\xe2\xa8\x32\xc1\x5e\x53\xc2\x85\xe9\x61\x8a\x17\x82\x12\xab\x92\x79\x2b\xed\x07\xca\x1e\x93\x23\x9c\x4b\xd2\x89\x86\xac\x55\xf9\x50\x23\x8f\x9e\xd3\xab\x22\x57\x91\x5a\x0b\x48\xd7\xa2\xb8\x06\xbb\x74\xae\xe9\xca\x06\x41\x8d\x6a\x00\x42\xc4\x40\xa9\xfe\xae\x88\x42\xc2\x83\xe0\x8a\xd8\x5c\xbb\x5a\xb5\x9c\x1d\xa5\xbe\x67\x50\xb1\x4e\xec\x96\x65\xaa\x87\x5b\xb0\x76\x88\xe3\x1b\xcb\x38\x21\x02\x8e\xc9\xe7\xf5\xc7\xe1\x1d\xe8\xeb\x54\x0e\x0b\xea\xd1\x2e\xad\xbb\xec\x22\x21\xb3\x64\x36\x29\x34\x5e\x3a\x22\xe8\x03\x4b\x86\xb1\x67\x7d\x4f\x48\x6d\xfb\x4b\xde\xe6\x4c\xb0\xaf\x40\x66\xab\xe9\x1a\x4e\xae\x1a\x7e\x05\xc5\x67\x2a\x95\x6d\xc2\x61\x35\x20\xfe\x33\xc3\x2c\x7f\x9b\xbe\x9f\x9a\xd5\xf0\x63\x28\xa1\x94\xb1\x5c\xc1\x18\x6b\x5b\x33\xb4\x4d\xcf\xbe\xf7\xb2\x94\x58\xaa\xcf\xad\xc8\x75\x93\x1a\x08\xf4\xd2\xd9\xf6\x95\x03\x3b\xf3\x4e\xfb\x15\xe4\x28\xed\xd5\x79\xd9\xbf\xb7\x8f\xb2\x70\x16\x4c\x2d\x65\xf6\xec\x33\x1e\xaf\xea\x46\x69\xc6\x9a\x6b\xdd\xf3\x57\xe0\x1d\x28\xcd\xf8\x83\x3d\x94\x4c\x2f\x6e\xfd\x51\x3d\xa8\xff\xcb\x33\xad\x32\x42\x0e\xd3\x00\x0a\xe5\x71\x76\x3b\x83\xc9\x2a\x67\x50\xc3\xa5\xeb\x4d\x8d\x67\xd6\xd9\x1b\x9a\x5a\xbe\xdd\xc5\x15\x00\xcf\x97\x0f\x47\x44\x34\x1d\x4e\xb6\x6f\x91\x31\xf3\x45\x0f\x59\x48\x10\x23\x53\x40\x49\x83\xe6\xc8\xdf\x51\x6c\xa8\x9f\x3a\x43\x3d\xb9\xd4\xea\x30\x4d\xe0\xd2\xb8\x44\xf3\x91\x20\x79\xdb\x7b\xe6\x50\xf9\x0f\xfb\x4c\xac\x79\x93\xf6\xf8\x96\x0d\x55\x7c\x41\x9b\x1a\x86\xad\x4b\xd1\xf9\x5d\xed\x3a\x4f\xc9\x64\x72\xd4\x22\x53\x59\x2f\x01\x00\x00\xff\xff\xc6\xfd\xa0\x37\x00\x04\x00\x00")
125 - b.SetBytes(int64(len(in))) // 1024
126 - b.ReportAllocs()
127 - for i := 0; i < b.N; i++ {
128 - _ = Encode(in)
129 - }
130 -}
Godeps/_workspace/src/github.com/jbenet/go-base58/doc.go deleted
-20
@@ -1,20 +0,0 @@
1 -// Copyright (c) 2013-2014 Conformal Systems LLC.
2 -// Use of this source code is governed by an ISC
3 -// license that can be found in the LICENSE file.
4 -
5 -/*
6 -Package base58 provides base58-check encoding.
7 -The alphabet is modifyiable for
8 -
9 -Base58 Usage
10 -
11 -To decode a base58 string:
12 -
13 - rawData := base58.Base58Decode(encodedData)
14 -
15 -Similarly, to encode the same data:
16 -
17 - encodedData := base58.Base58Encode(rawData)
18 -
19 -*/
20 -package base58
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/README.md deleted
-45
@@ -1,45 +0,0 @@
1 -# go-fuse-version
2 -
3 -Simple package to get the user's FUSE libraries information.
4 -
5 -- Godoc: https://godoc.org/github.com/jbenet/go-fuse-version
6 -
7 -**Warning** Currently only supports OSXFUSE. if you want more, add them, it's really trivial now.
8 -
9 -## Example
10 -
11 -```Go
12 -package main
13 -
14 -import (
15 - "fmt"
16 - "os"
17 -
18 - fuseversion "github.com/jbenet/go-fuse-version"
19 -)
20 -
21 -func main() {
22 - sys, err := fuseversion.LocalFuseSystems()
23 - if err != nil {
24 - fmt.Fprintf(os.Stderr, "%s\n", err)
25 - os.Exit(1)
26 - }
27 -
28 - fmt.Printf("FuseVersion, AgentVersion, Agent\n")
29 - for _, s := range *sys {
30 - fmt.Printf("%s, %s, %s\n", s.FuseVersion, s.AgentVersion, s.AgentName)
31 - }
32 -}
33 -```
34 -
35 -## fuse-print
36 -
37 -If you dont use Go, you can also install the example as the silly util `fuse-version`:
38 -
39 -```
40 -> go get github.com/jbenet/go-fuse-version/fuse-version
41 -> go install github.com/jbenet/go-fuse-version/fuse-version
42 -> fuse-version
43 -FuseVersion, AgentVersion, Agent
44 -27, 2.7.2, OSXFUSE
45 -```
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuse-version/.gitignore deleted
-1
@@ -1 +0,0 @@
1 -fuse-version
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuse-version/README.md deleted
-1
@@ -1 +0,0 @@
1 -../README.md
\ No newline at end of file
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/fuse-version/index.go deleted
-106
@@ -1,106 +0,0 @@
1 -package main
2 -
3 -import (
4 - "bytes"
5 - "flag"
6 - "fmt"
7 - "os"
8 -
9 - fuseversion "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-fuse-version"
10 -)
11 -
12 -// flags
13 -var (
14 - flagSystem string
15 - flagOnly string
16 - flagQuiet bool
17 -)
18 -
19 -var usage = `usage: %s [flags]
20 -print fuse and fuse agent versions
21 -`
22 -
23 -func init() {
24 - flag.Usage = func() {
25 - fmt.Fprintf(os.Stderr, usage, os.Args[0])
26 - flag.PrintDefaults()
27 - }
28 -
29 - flag.StringVar(&flagSystem, "s", "", "show only one system (e.g. OSXFUSE)")
30 - flag.StringVar(&flagOnly, "only", "", "show one of {fuse, agent, agent-name}")
31 - flag.BoolVar(&flagQuiet, "q", false, "quiet output, no newline (use with --only)")
32 -}
33 -
34 -func main() {
35 - flag.Parse()
36 - sys, err := fuseversion.LocalFuseSystems()
37 - if err != nil {
38 - fmt.Fprintf(os.Stderr, "%s\n", err)
39 - os.Exit(1)
40 - }
41 -
42 - all := flagSystem == ""
43 -
44 - // if user specified a system and we dont have it, error out.
45 - if !all {
46 - checkExists(sys, flagSystem)
47 - }
48 -
49 - var buf bytes.Buffer
50 - for name, s := range sys {
51 - if !all && flagSystem != name {
52 - continue
53 - }
54 -
55 - switch flagOnly {
56 - case "fuse":
57 - fmt.Fprintf(&buf, PartString(name, "FuseVersion", s.FuseVersion))
58 - case "agent":
59 - fmt.Fprintf(&buf, PartString(name, "AgentVersion", s.AgentVersion))
60 - case "agent-name":
61 - fmt.Fprintf(&buf, PartString(name, "AgentName", s.AgentName))
62 - default:
63 - fmt.Fprintf(&buf, SystemString(name, s))
64 - }
65 -
66 - if all && flagQuiet { // if all & quiet, need to break between systems
67 - fmt.Fprintf(&buf, "\n")
68 - }
69 - }
70 -
71 - out := buf.Bytes()
72 - if flagQuiet {
73 - out = bytes.TrimSpace(out)
74 - }
75 - os.Stdout.Write(out)
76 -}
77 -
78 -func checkExists(all fuseversion.Systems, name string) {
79 -
80 - if _, found := all[name]; found {
81 - return
82 - }
83 -
84 - if !flagQuiet {
85 - fmt.Fprintf(os.Stderr, "error: %s system not found.\nHave: ")
86 - for name := range all {
87 - fmt.Fprintf(os.Stderr, "%s ", name)
88 - }
89 - fmt.Fprintf(os.Stderr, "\n")
90 - }
91 - os.Exit(1)
92 -}
93 -
94 -func SystemString(name string, sys fuseversion.FuseSystem) (s string) {
95 - s += PartString(name, "FuseVersion", sys.FuseVersion)
96 - s += PartString(name, "AgentVersion", sys.AgentVersion)
97 - s += PartString(name, "AgentName", sys.AgentName)
98 - return s
99 -}
100 -
101 -func PartString(sysname, partname, part string) string {
102 - if !flagQuiet {
103 - return fmt.Sprintf("%s.%s: %s\n", sysname, partname, part)
104 - }
105 - return part + "\t"
106 -}
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version.go deleted
-37
@@ -1,37 +0,0 @@
1 -// package fuseversion simply exposes the version of FUSE installed
2 -// in the user's machine. For reasoning, see:
3 -// - https://github.com/jbenet/go-ipfs/issues/177
4 -// - https://github.com/jbenet/go-ipfs/issues/202
5 -// - https://github.com/osxfuse/osxfuse/issues/175#issuecomment-61888505
6 -package fuseversion
7 -
8 -type Systems map[string]FuseSystem
9 -
10 -type FuseSystem struct {
11 - // FuseVersion is the version of the FUSE protocol
12 - FuseVersion string
13 -
14 - // AgentName identifies the system implementing FUSE, or Agent
15 - AgentName string
16 -
17 - // AgentVersion is the version of the Agent program
18 - // (it fights for the user! Sometimes it fights the user...)
19 - AgentVersion string
20 -}
21 -
22 -// LocalFuseSystems returns a map of FuseSystems, keyed by name.
23 -// For example:
24 -//
25 -// systems := fuseversion.LocalFuseSystems()
26 -// for n, sys := range systems {
27 -// fmt.Printf("%s, %s, %s", n, sys.FuseVersion, sys.AgentVersion)
28 -// }
29 -// // Outputs:
30 -// // OSXFUSE, , 2.7.2
31 -//
32 -func LocalFuseSystems() (Systems, error) {
33 - return getLocalFuseSystems() // implemented by each platform
34 -}
35 -
36 -var notImplYet = `Error: not implemented for %s yet. :(
37 -Please do it: https://github.com/jbenet/go-fuse-version`
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_bsd.go deleted
-12
@@ -1,12 +0,0 @@
1 -// +build dragonfly freebsd netbsd openbsd
2 -
3 -package fuseversion
4 -
5 -import (
6 - "fmt"
7 - "runtime"
8 -)
9 -
10 -func getLocalFuseSystems() (Systems, error) {
11 - return nil, fmt.Errorf(notImplYet, runtime.GOARCH)
12 -}
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_darwin.go deleted
-24
@@ -1,24 +0,0 @@
1 -package fuseversion
2 -
3 -// #cgo CFLAGS: -I /usr/local/include/osxfuse/ -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=25
4 -// #cgo LDFLAGS: /usr/local/lib/libosxfuse.dylib
5 -//
6 -// #include <fuse/fuse.h>
7 -// #include <fuse/fuse_common.h>
8 -// #include <fuse/fuse_darwin.h>
9 -import "C"
10 -import "fmt"
11 -
12 -func getLocalFuseSystems() (Systems, error) {
13 - sys := make(Systems)
14 - sys["OSXFUSE"] = getOSXFUSE()
15 - return sys, nil
16 -}
17 -
18 -func getOSXFUSE() FuseSystem {
19 - return FuseSystem{
20 - FuseVersion: fmt.Sprintf("%d", int(C.fuse_version())),
21 - AgentName: "OSXFUSE",
22 - AgentVersion: C.GoString(C.osxfuse_version()),
23 - }
24 -}
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_linux.go deleted
-10
@@ -1,10 +0,0 @@
1 -package fuseversion
2 -
3 -import (
4 - "fmt"
5 - "runtime"
6 -)
7 -
8 -func getLocalFuseSystems() (Systems, error) {
9 - return nil, fmt.Errorf(notImplYet, runtime.GOARCH)
10 -}
Godeps/_workspace/src/github.com/jbenet/go-fuse-version/version_windows.go deleted
-10
@@ -1,10 +0,0 @@
1 -package fuseversion
2 -
3 -import (
4 - "fmt"
5 - "runtime"
6 -)
7 -
8 -func getLocalFuseSystems() (Systems, error) {
9 - return nil, fmt.Errorf(notImplYet, runtime.GOARCH)
10 -}
Godeps/_workspace/src/github.com/jbenet/go-msgio/.travis.yml deleted
-9
@@ -1,9 +0,0 @@
1 -language: go
2 -
3 -go:
4 - - 1.3
5 - - 1.4
6 - - release
7 -
8 -script:
9 - - go test -race -cpu=5 -v ./...
Godeps/_workspace/src/github.com/jbenet/go-msgio/README.md deleted
-78
@@ -1,78 +0,0 @@
1 -# go-msgio - Message IO
2 -
3 -This is a simple package that helps read and write length-delimited slices. It's helpful for building wire protocols.
4 -
5 -## Usage
6 -
7 -### Reading
8 -
9 -```go
10 -import "github.com/jbenet/msgio"
11 -rdr := ... // some reader from a wire
12 -mrdr := msgio.NewReader(rdr)
13 -
14 -for {
15 - msg, err := mrdr.ReadMsg()
16 - if err != nil {
17 - return err
18 - }
19 -
20 - doSomething(msg)
21 -}
22 -```
23 -
24 -### Writing
25 -
26 -```go
27 -import "github.com/jbenet/msgio"
28 -wtr := genReader()
29 -mwtr := msgio.NewWriter(wtr)
30 -
31 -for {
32 - msg := genMessage()
33 - err := mwtr.WriteMsg(msg)
34 - if err != nil {
35 - return err
36 - }
37 -}
38 -```
39 -
40 -### Duplex
41 -
42 -```go
43 -import "github.com/jbenet/msgio"
44 -rw := genReadWriter()
45 -mrw := msgio.NewReadWriter(rw)
46 -
47 -for {
48 - msg, err := mrdr.ReadMsg()
49 - if err != nil {
50 - return err
51 - }
52 -
53 - // echo it back :)
54 - err = mwtr.WriteMsg(msg)
55 - if err != nil {
56 - return err
57 - }
58 -}
59 -```
60 -
61 -### Channels
62 -
63 -```go
64 -import "github.com/jbenet/msgio"
65 -rw := genReadWriter()
66 -rch := msgio.NewReadChannel(rw)
67 -wch := msgio.NewWriteChannel(rw)
68 -
69 -for {
70 - msg, err := <-rch
71 - if err != nil {
72 - return err
73 - }
74 -
75 - // echo it back :)
76 - wch<- rw
77 -}
78 -```
Godeps/_workspace/src/github.com/jbenet/go-msgio/chan.go deleted
-114
@@ -1,114 +0,0 @@
1 -package msgio
2 -
3 -import (
4 - "io"
5 -
6 - mpool "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-msgio/mpool"
7 -)
8 -
9 -// Chan is a msgio duplex channel. It is used to have a channel interface
10 -// around a msgio.Reader or Writer.
11 -type Chan struct {
12 - MsgChan chan []byte
13 - ErrChan chan error
14 - CloseChan chan bool
15 -}
16 -
17 -// NewChan constructs a Chan with a given buffer size.
18 -func NewChan(chanSize int) *Chan {
19 - return &Chan{
20 - MsgChan: make(chan []byte, chanSize),
21 - ErrChan: make(chan error, 1),
22 - CloseChan: make(chan bool, 2),
23 - }
24 -}
25 -
26 -// ReadFrom wraps the given io.Reader with a msgio.Reader, reads all
27 -// messages, ands sends them down the channel.
28 -func (s *Chan) ReadFrom(r io.Reader) {
29 - s.readFrom(NewReader(r))
30 -}
31 -
32 -// ReadFromWithPool wraps the given io.Reader with a msgio.Reader, reads all
33 -// messages, ands sends them down the channel. Uses given Pool
34 -func (s *Chan) ReadFromWithPool(r io.Reader, p *mpool.Pool) {
35 - s.readFrom(NewReaderWithPool(r, p))
36 -}
37 -
38 -// ReadFrom wraps the given io.Reader with a msgio.Reader, reads all
39 -// messages, ands sends them down the channel.
40 -func (s *Chan) readFrom(mr Reader) {
41 - // single reader, no need for Mutex
42 - mr.(*reader).lock = new(nullLocker)
43 -
44 -Loop:
45 - for {
46 - buf, err := mr.ReadMsg()
47 - if err != nil {
48 - if err == io.EOF {
49 - break Loop // done
50 - }
51 -
52 - // unexpected error. tell the client.
53 - s.ErrChan <- err
54 - break Loop
55 - }
56 -
57 - select {
58 - case <-s.CloseChan:
59 - break Loop // told we're done
60 - case s.MsgChan <- buf:
61 - // ok seems fine. send it away
62 - }
63 - }
64 -
65 - close(s.MsgChan)
66 - // signal we're done
67 - s.CloseChan <- true
68 -}
69 -
70 -// WriteTo wraps the given io.Writer with a msgio.Writer, listens on the
71 -// channel and writes all messages to the writer.
72 -func (s *Chan) WriteTo(w io.Writer) {
73 - // new buffer per message
74 - // if bottleneck, cycle around a set of buffers
75 - mw := NewWriter(w)
76 -
77 - // single writer, no need for Mutex
78 - mw.(*writer).lock = new(nullLocker)
79 -Loop:
80 - for {
81 - select {
82 - case <-s.CloseChan:
83 - break Loop // told we're done
84 -
85 - case msg, ok := <-s.MsgChan:
86 - if !ok { // chan closed
87 - break Loop
88 - }
89 -
90 - if err := mw.WriteMsg(msg); err != nil {
91 - if err != io.EOF {
92 - // unexpected error. tell the client.
93 - s.ErrChan <- err
94 - }
95 -
96 - break Loop
97 - }
98 - }
99 - }
100 -
101 - // signal we're done
102 - s.CloseChan <- true
103 -}
104 -
105 -// Close the Chan
106 -func (s *Chan) Close() {
107 - s.CloseChan <- true
108 -}
109 -
110 -// nullLocker conforms to the sync.Locker interface but does nothing.
111 -type nullLocker struct{}
112 -
113 -func (l *nullLocker) Lock() {}
114 -func (l *nullLocker) Unlock() {}
Godeps/_workspace/src/github.com/jbenet/go-msgio/chan_test.go deleted
-108
@@ -1,108 +0,0 @@
1 -package msgio
2 -
3 -import (
4 - "bytes"
5 - randbuf "gx/ipfs/QmYNGtJHgaGZkpzq8yG6Wxqm6EQTKqgpBfnyyGBKbZeDUi/go-randbuf"
6 - "io"
7 - "math/rand"
8 - "testing"
9 - "time"
10 -)
11 -
12 -func TestReadChan(t *testing.T) {
13 - buf := bytes.NewBuffer(nil)
14 - writer := NewWriter(buf)
15 - rchan := NewChan(10)
16 - msgs := [1000][]byte{}
17 -
18 - r := rand.New(rand.NewSource(time.Now().UnixNano()))
19 - for i := range msgs {
20 - msgs[i] = randbuf.RandBuf(r, r.Intn(1000))
21 - err := writer.WriteMsg(msgs[i])
22 - if err != nil {
23 - t.Fatal(err)
24 - }
25 - }
26 -
27 - if err := writer.Close(); err != nil {
28 - t.Fatal(err)
29 - }
30 -
31 - go rchan.ReadFrom(buf)
32 - defer rchan.Close()
33 -
34 -Loop:
35 - for i := 0; ; i++ {
36 - select {
37 - case err := <-rchan.ErrChan:
38 - if err != nil {
39 - t.Fatal("unexpected error", err)
40 - }
41 -
42 - case msg2, ok := <-rchan.MsgChan:
43 - if !ok {
44 - if i < len(msg2) {
45 - t.Error("failed to read all messages", len(msgs), i)
46 - }
47 - break Loop
48 - }
49 -
50 - msg1 := msgs[i]
51 - if !bytes.Equal(msg1, msg2) {
52 - t.Fatal("message retrieved not equal\n", msg1, "\n\n", msg2)
53 - }
54 - }
55 - }
56 -}
57 -
58 -func TestWriteChan(t *testing.T) {
59 - buf := bytes.NewBuffer(nil)
60 - reader := NewReader(buf)
61 - wchan := NewChan(10)
62 - msgs := [1000][]byte{}
63 -
64 - go wchan.WriteTo(buf)
65 -
66 - r := rand.New(rand.NewSource(time.Now().UnixNano()))
67 - for i := range msgs {
68 - msgs[i] = randbuf.RandBuf(r, r.Intn(1000))
69 -
70 - select {
71 - case err := <-wchan.ErrChan:
72 - if err != nil {
73 - t.Fatal("unexpected error", err)
74 - }
75 -
76 - case wchan.MsgChan <- msgs[i]:
77 - }
78 - }
79 -
80 - // tell chan we're done.
81 - close(wchan.MsgChan)
82 - // wait for writing to end
83 - <-wchan.CloseChan
84 -
85 - defer wchan.Close()
86 -
87 - for i := 0; ; i++ {
88 - msg2, err := reader.ReadMsg()
89 - if err != nil {
90 - if err == io.EOF {
91 - if i < len(msg2) {
92 - t.Error("failed to read all messages", len(msgs), i)
93 - }
94 - break
95 - }
96 - t.Error("unexpected error", err)
97 - }
98 -
99 - msg1 := msgs[i]
100 - if !bytes.Equal(msg1, msg2) {
101 - t.Fatal("message retrieved not equal\n", msg1, "\n\n", msg2)
102 - }
103 - }
104 -
105 - if err := reader.Close(); err != nil {
106 - t.Error(err)
107 - }
108 -}
Godeps/_workspace/src/github.com/jbenet/go-msgio/fuzz.go deleted
-23
@@ -1,23 +0,0 @@
1 -// +build gofuzz
2 -
3 -package msgio
4 -
5 -import "bytes"
6 -
7 -// get the go-fuzz tools and build a fuzzer
8 -// $ go get -u github.com/dvyukov/go-fuzz/...
9 -// $ go-fuzz-build github.com/jbenet/go-msgio
10 -
11 -// put a corpus of random (even better if actual, structured) data in a corpus directry
12 -// $ go-fuzz -bin ./msgio-fuzz -corpus corpus -workdir=wdir -timeout=15
13 -
14 -func Fuzz(data []byte) int {
15 - rc := NewReader(bytes.NewReader(data))
16 - // rc := NewVarintReader(bytes.NewReader(data))
17 -
18 - if _, err := rc.ReadMsg(); err != nil {
19 - return 0
20 - }
21 -
22 - return 1
23 -}
Godeps/_workspace/src/github.com/jbenet/go-msgio/fuzz_test.go deleted
-24
@@ -1,24 +0,0 @@
1 -package msgio
2 -
3 -import (
4 - "strings"
5 - "testing"
6 -)
7 -
8 -func TestReader_CrashOne(t *testing.T) {
9 - rc := NewReader(strings.NewReader("\x83000"))
10 - _, err := rc.ReadMsg()
11 - if err != ErrMsgTooLarge {
12 - t.Error("should get ErrMsgTooLarge")
13 - t.Log(err)
14 - }
15 -}
16 -
17 -func TestVarintReader_CrashOne(t *testing.T) {
18 - rc := NewVarintReader(strings.NewReader("\x9a\xf1\xed\x9a0"))
19 - _, err := rc.ReadMsg()
20 - if err != ErrMsgTooLarge {
21 - t.Error("should get ErrMsgTooLarge")
22 - t.Log(err)
23 - }
24 -}
Godeps/_workspace/src/github.com/jbenet/go-msgio/limit.go deleted
-45
@@ -1,45 +0,0 @@
1 -package msgio
2 -
3 -import (
4 - "bytes"
5 - "io"
6 - "sync"
7 -)
8 -
9 -// LimitedReader wraps an io.Reader with a msgio framed reader. The LimitedReader
10 -// will return a reader which will io.EOF when the msg length is done.
11 -func LimitedReader(r io.Reader) (io.Reader, error) {
12 - l, err := ReadLen(r, nil)
13 - return io.LimitReader(r, int64(l)), err
14 -}
15 -
16 -// LimitedWriter wraps an io.Writer with a msgio framed writer. It is the inverse
17 -// of LimitedReader: it will buffer all writes until "Flush" is called. When Flush
18 -// is called, it will write the size of the buffer first, flush the buffer, reset
19 -// the buffer, and begin accept more incoming writes.
20 -func NewLimitedWriter(w io.Writer) *LimitedWriter {
21 - return &LimitedWriter{W: w}
22 -}
23 -
24 -type LimitedWriter struct {
25 - W io.Writer
26 - B bytes.Buffer
27 - M sync.Mutex
28 -}
29 -
30 -func (w *LimitedWriter) Write(buf []byte) (n int, err error) {
31 - w.M.Lock()
32 - n, err = w.B.Write(buf)
33 - w.M.Unlock()
34 - return n, err
35 -}
36 -
37 -func (w *LimitedWriter) Flush() error {
38 - w.M.Lock()
39 - defer w.M.Unlock()
40 - if err := WriteLen(w.W, w.B.Len()); err != nil {
41 - return err
42 - }
43 - _, err := w.B.WriteTo(w.W)
44 - return err
45 -}
Godeps/_workspace/src/github.com/jbenet/go-msgio/mpool/pool.go deleted
-125
@@ -1,125 +0,0 @@
1 -// Package mpool provides a sync.Pool equivalent that buckets incoming
2 -// requests to one of 32 sub-pools, one for each power of 2, 0-32.
3 -//
4 -// import "github.com/jbenet/go-msgio/mpool"
5 -// var p mpool.Pool
6 -//
7 -// small := make([]byte, 1024)
8 -// large := make([]byte, 4194304)
9 -// p.Put(1024, small)
10 -// p.Put(4194304, large)
11 -//
12 -// small2 := p.Get(1024).([]byte)
13 -// large2 := p.Get(4194304).([]byte)
14 -// fmt.Println("small2 len:", len(small2))
15 -// fmt.Println("large2 len:", len(large2))
16 -//
17 -// // Output:
18 -// // small2 len: 1024
19 -// // large2 len: 4194304
20 -//
21 -package mpool
22 -
23 -import (
24 - "fmt"
25 - "sync"
26 -)
27 -
28 -// ByteSlicePool is a static Pool for reusing byteslices of various sizes.
29 -var ByteSlicePool Pool
30 -
31 -func init() {
32 - ByteSlicePool.New = func(length int) interface{} {
33 - return make([]byte, length)
34 - }
35 -}
36 -
37 -// MaxLength is the maximum length of an element that can be added to the Pool.
38 -const MaxLength = 1 << 32
39 -
40 -// Pool is a pool to handle cases of reusing elements of varying sizes.
41 -// It maintains up to 32 internal pools, for each power of 2 in 0-32.
42 -type Pool struct {
43 - small int // the size of the first pool
44 - pools [32]*sync.Pool // a list of singlePools
45 - sync.Mutex // protecting list
46 -
47 - // New is a function that constructs a new element in the pool, with given len
48 - New func(len int) interface{}
49 -}
50 -
51 -func (p *Pool) getPool(idx uint32) *sync.Pool {
52 - if idx > uint32(len(p.pools)) {
53 - panic(fmt.Errorf("index too large: %d", idx))
54 - }
55 -
56 - p.Lock()
57 - defer p.Unlock()
58 -
59 - sp := p.pools[idx]
60 - if sp == nil {
61 - sp = new(sync.Pool)
62 - p.pools[idx] = sp
63 - }
64 - return sp
65 -}
66 -
67 -// Get selects an arbitrary item from the Pool, removes it from the Pool,
68 -// and returns it to the caller. Get may choose to ignore the pool and
69 -// treat it as empty. Callers should not assume any relation between values
70 -// passed to Put and the values returned by Get.
71 -//
72 -// If Get would otherwise return nil and p.New is non-nil, Get returns the
73 -// result of calling p.New.
74 -func (p *Pool) Get(length uint32) interface{} {
75 - idx := nextPowerOfTwo(length)
76 - sp := p.getPool(idx)
77 - // fmt.Printf("Get(%d) idx(%d)\n", length, idx)
78 - val := sp.Get()
79 - if val == nil && p.New != nil {
80 - val = p.New(0x1 << idx)
81 - }
82 - return val
83 -}
84 -
85 -// Put adds x to the pool.
86 -func (p *Pool) Put(length uint32, val interface{}) {
87 - idx := prevPowerOfTwo(length)
88 - // fmt.Printf("Put(%d, -) idx(%d)\n", length, idx)
89 - sp := p.getPool(idx)
90 - sp.Put(val)
91 -}
92 -
93 -func nextPowerOfTwo(v uint32) uint32 {
94 - // fmt.Printf("nextPowerOfTwo(%d) ", v)
95 - v--
96 - v |= v >> 1
97 - v |= v >> 2
98 - v |= v >> 4
99 - v |= v >> 8
100 - v |= v >> 16
101 - v++
102 -
103 - // fmt.Printf("-> %d", v)
104 -
105 - i := uint32(0)
106 - for i = 0; v > 1; i++ {
107 - v = v >> 1
108 - }
109 -
110 - // fmt.Printf("-> %d\n", i)
111 - return i
112 -}
113 -
114 -func prevPowerOfTwo(num uint32) uint32 {
115 - next := nextPowerOfTwo(num)
116 - // fmt.Printf("prevPowerOfTwo(%d) next: %d", num, next)
117 - switch {
118 - case num == (1 << next): // num is a power of 2
119 - case next == 0:
120 - default:
121 - next = next - 1 // smaller
122 - }
123 - // fmt.Printf(" = %d\n", next)
124 - return next
125 -}
Godeps/_workspace/src/github.com/jbenet/go-msgio/mpool/pool_test.go deleted
-254
@@ -1,254 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// Pool is no-op under race detector, so all these tests do not work.
6 -// +build !race
7 -
8 -package mpool
9 -
10 -import (
11 - "fmt"
12 - "math/rand"
13 - "runtime"
14 - "runtime/debug"
15 - "sync/atomic"
16 - "testing"
17 - "time"
18 -)
19 -
20 -func TestPool(t *testing.T) {
21 - // disable GC so we can control when it happens.
22 - defer debug.SetGCPercent(debug.SetGCPercent(-1))
23 - var p Pool
24 - if p.Get(10) != nil {
25 - t.Fatal("expected empty")
26 - }
27 - p.Put(16, "a")
28 - p.Put(2048, "b")
29 - if g := p.Get(16); g != "a" {
30 - t.Fatalf("got %#v; want a", g)
31 - }
32 - if g := p.Get(2048); g != "b" {
33 - t.Fatalf("got %#v; want b", g)
34 - }
35 - if g := p.Get(16); g != nil {
36 - t.Fatalf("got %#v; want nil", g)
37 - }
38 - if g := p.Get(2048); g != nil {
39 - t.Fatalf("got %#v; want nil", g)
40 - }
41 - if g := p.Get(1); g != nil {
42 - t.Fatalf("got %#v; want nil", g)
43 - }
44 - p.Put(1023, "d")
45 - if g := p.Get(1024); g != nil {
46 - t.Fatalf("got %#v; want nil", g)
47 - }
48 - if g := p.Get(512); g != "d" {
49 - t.Fatalf("got %#v; want d", g)
50 - }
51 -
52 - debug.SetGCPercent(100) // to allow following GC to actually run
53 - runtime.GC()
54 - if g := p.Get(10); g != nil {
55 - t.Fatalf("got %#v; want nil after GC", g)
56 - }
57 -}
58 -
59 -func TestPoolNew(t *testing.T) {
60 - // disable GC so we can control when it happens.
61 - defer debug.SetGCPercent(debug.SetGCPercent(-1))
62 -
63 - s := [32]int{}
64 - p := Pool{
65 - New: func(length int) interface{} {
66 - idx := nextPowerOfTwo(uint32(length))
67 - s[idx]++
68 - return s[idx]
69 - },
70 - }
71 - if v := p.Get(1 << 5); v != 1 {
72 - t.Fatalf("got %v; want 1", v)
73 - }
74 - if v := p.Get(1 << 2); v != 1 {
75 - t.Fatalf("got %v; want 1", v)
76 - }
77 - if v := p.Get(1 << 2); v != 2 {
78 - t.Fatalf("got %v; want 2", v)
79 - }
80 - if v := p.Get(1 << 5); v != 2 {
81 - t.Fatalf("got %v; want 2", v)
82 - }
83 - p.Put(1<<2, 42)
84 - p.Put(1<<5, 42)
85 - if v := p.Get(1 << 2); v != 42 {
86 - t.Fatalf("got %v; want 42", v)
87 - }
88 - if v := p.Get(1 << 2); v != 3 {
89 - t.Fatalf("got %v; want 3", v)
90 - }
91 - if v := p.Get(1 << 5); v != 42 {
92 - t.Fatalf("got %v; want 42", v)
93 - }
94 - if v := p.Get(1 << 5); v != 3 {
95 - t.Fatalf("got %v; want 3", v)
96 - }
97 -}
98 -
99 -// Test that Pool does not hold pointers to previously cached
100 -// resources
101 -func TestPoolGC(t *testing.T) {
102 - var p Pool
103 - var fin uint32
104 - const N = 100
105 - for i := 0; i < N; i++ {
106 - v := new(string)
107 - runtime.SetFinalizer(v, func(vv *string) {
108 - atomic.AddUint32(&fin, 1)
109 - })
110 - p.Put(uint32(i), v)
111 - }
112 - for i := 0; i < N; i++ {
113 - p.Get(uint32(i))
114 - }
115 - for i := 0; i < 5; i++ {
116 - runtime.GC()
117 - time.Sleep(time.Duration(i*100+10) * time.Millisecond)
118 - // 1 pointer can remain on stack or elsewhere
119 - if atomic.LoadUint32(&fin) >= N-1 {
120 - return
121 - }
122 - }
123 - t.Fatalf("only %v out of %v resources are finalized",
124 - atomic.LoadUint32(&fin), N)
125 -}
126 -
127 -func TestPoolStress(t *testing.T) {
128 - const P = 10
129 - N := int(1e6)
130 - if testing.Short() {
131 - N /= 100
132 - }
133 - var p Pool
134 - done := make(chan bool)
135 - for i := 0; i < P; i++ {
136 - go func() {
137 - var v interface{} = 0
138 - for j := 0; j < N; j++ {
139 - if v == nil {
140 - v = 0
141 - }
142 - p.Put(uint32(j), v)
143 - v = p.Get(uint32(j))
144 - if v != nil && v.(int) != 0 {
145 - t.Fatalf("expect 0, got %v", v)
146 - }
147 - }
148 - done <- true
149 - }()
150 - }
151 - for i := 0; i < P; i++ {
152 - // fmt.Printf("%d/%d\n", i, P)
153 - <-done
154 - }
155 -}
156 -
157 -func TestPoolStressByteSlicePool(t *testing.T) {
158 - const P = 10
159 - chs := 10
160 - maxSize := uint32(1 << 16)
161 - N := int(1e4)
162 - if testing.Short() {
163 - N /= 100
164 - }
165 - p := ByteSlicePool
166 - done := make(chan bool)
167 - errs := make(chan error)
168 - for i := 0; i < P; i++ {
169 - go func() {
170 - ch := make(chan []byte, chs+1)
171 -
172 - for i := 0; i < chs; i++ {
173 - j := rand.Uint32() % maxSize
174 - ch <- p.Get(j).([]byte)
175 - }
176 -
177 - for j := 0; j < N; j++ {
178 - r := uint32(0)
179 - for i := 0; i < chs; i++ {
180 - v := <-ch
181 - p.Put(uint32(cap(v)), v)
182 - r = rand.Uint32() % maxSize
183 - v = p.Get(r).([]byte)
184 - if uint32(len(v)) < r {
185 - errs <- fmt.Errorf("expect len(v) >= %d, got %d", j, len(v))
186 - }
187 - ch <- v
188 - }
189 -
190 - if r%1000 == 0 {
191 - runtime.GC()
192 - }
193 - }
194 - done <- true
195 - }()
196 - }
197 -
198 - for i := 0; i < P; {
199 - select {
200 - case <-done:
201 - i++
202 - // fmt.Printf("%d/%d\n", i, P)
203 - case err := <-errs:
204 - t.Error(err)
205 - }
206 - }
207 -}
208 -
209 -func BenchmarkPool(b *testing.B) {
210 - var p Pool
211 - b.RunParallel(func(pb *testing.PB) {
212 - i := 0
213 - for pb.Next() {
214 - i = i << 1
215 - p.Put(uint32(i), 1)
216 - p.Get(uint32(i))
217 - }
218 - })
219 -}
220 -
221 -func BenchmarkPoolOverlflow(b *testing.B) {
222 - var p Pool
223 - b.RunParallel(func(pb *testing.PB) {
224 - for pb.Next() {
225 - for pow := uint32(0); pow < 32; pow++ {
226 - for b := 0; b < 100; b++ {
227 - p.Put(uint32(1<<pow), 1)
228 - }
229 - }
230 - for pow := uint32(0); pow < 32; pow++ {
231 - for b := 0; b < 100; b++ {
232 - p.Get(uint32(1 << pow))
233 - }
234 - }
235 - }
236 - })
237 -}
238 -
239 -func ExamplePool() {
240 - var p Pool
241 -
242 - small := make([]byte, 1024)
243 - large := make([]byte, 4194304)
244 - p.Put(uint32(len(small)), small)
245 - p.Put(uint32(len(large)), large)
246 -
247 - small2 := p.Get(uint32(len(small))).([]byte)
248 - large2 := p.Get(uint32(len(large))).([]byte)
249 - fmt.Println("small2 len:", len(small2))
250 - fmt.Println("large2 len:", len(large2))
251 - // Output:
252 - // small2 len: 1024
253 - // large2 len: 4194304
254 -}
Godeps/_workspace/src/github.com/jbenet/go-msgio/msgio.go deleted
-291
@@ -1,291 +0,0 @@
1 -package msgio
2 -
3 -import (
4 - "bufio"
5 - "errors"
6 - "io"
7 - "sync"
8 -
9 - mpool "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-msgio/mpool"
10 -)
11 -
12 -// ErrMsgTooLarge is returned when the message length is exessive
13 -var ErrMsgTooLarge = errors.New("message too large")
14 -
15 -const (
16 - lengthSize = 4
17 - defaultMaxSize = 8 * 1024 * 1024 // 8mb
18 -)
19 -
20 -// Writer is the msgio Writer interface. It writes len-framed messages.
21 -type Writer interface {
22 -
23 - // Write writes passed in buffer as a single message.
24 - Write([]byte) (int, error)
25 -
26 - // WriteMsg writes the msg in the passed in buffer.
27 - WriteMsg([]byte) error
28 -}
29 -
30 -// WriteCloser is a Writer + Closer interface. Like in `golang/pkg/io`
31 -type WriteCloser interface {
32 - Writer
33 - io.Closer
34 -}
35 -
36 -// Reader is the msgio Reader interface. It reads len-framed messages.
37 -type Reader interface {
38 -
39 - // Read reads the next message from the Reader.
40 - // The client must pass a buffer large enough, or io.ErrShortBuffer will be
41 - // returned.
42 - Read([]byte) (int, error)
43 -
44 - // ReadMsg reads the next message from the Reader.
45 - // Uses a mpool.Pool internally to reuse buffers. io.ErrShortBuffer will
46 - // be returned if the Pool.Get(...) returns nil.
47 - // User may call ReleaseMsg(msg) to signal a buffer can be reused.
48 - ReadMsg() ([]byte, error)
49 -
50 - // ReleaseMsg signals a buffer can be reused.
51 - ReleaseMsg([]byte)
52 -
53 - // NextMsgLen returns the length of the next (peeked) message. Does
54 - // not destroy the message or have other adverse effects
55 - NextMsgLen() (int, error)
56 -}
57 -
58 -// ReadCloser combines a Reader and Closer.
59 -type ReadCloser interface {
60 - Reader
61 - io.Closer
62 -}
63 -
64 -// ReadWriter combines a Reader and Writer.
65 -type ReadWriter interface {
66 - Reader
67 - Writer
68 -}
69 -
70 -// ReadWriteCloser combines a Reader, a Writer, and Closer.
71 -type ReadWriteCloser interface {
72 - Reader
73 - Writer
74 - io.Closer
75 -}
76 -
77 -// writer is the underlying type that implements the Writer interface.
78 -type writer struct {
79 - W io.Writer
80 - buf *bufio.Writer
81 -
82 - lock sync.Locker
83 -}
84 -
85 -// NewWriter wraps an io.Writer with a msgio framed writer. The msgio.Writer
86 -// will write the length prefix of every message written.
87 -func NewWriter(w io.Writer) WriteCloser {
88 - return &writer{W: w, buf: bufio.NewWriter(w), lock: new(sync.Mutex)}
89 -}
90 -
91 -func (s *writer) Write(msg []byte) (int, error) {
92 - err := s.WriteMsg(msg)
93 - if err != nil {
94 - return 0, err
95 - }
96 - return len(msg), nil
97 -}
98 -
99 -func (s *writer) WriteMsg(msg []byte) (err error) {
100 - s.lock.Lock()
101 - defer s.lock.Unlock()
102 - if err := WriteLen(s.W, len(msg)); err != nil {
103 - return err
104 - }
105 -
106 - _, err = s.buf.Write(msg)
107 - if err != nil {
108 - return err
109 - }
110 -
111 - return s.buf.Flush()
112 -}
113 -
114 -func (s *writer) Close() error {
115 - s.lock.Lock()
116 - defer s.lock.Unlock()
117 -
118 - if c, ok := s.W.(io.Closer); ok {
119 - return c.Close()
120 - }
121 - return nil
122 -}
123 -
124 -// reader is the underlying type that implements the Reader interface.
125 -type reader struct {
126 - R io.Reader
127 -
128 - lbuf []byte
129 - next int
130 - pool *mpool.Pool
131 - lock sync.Locker
132 - max int // the maximal message size (in bytes) this reader handles
133 -}
134 -
135 -// NewReader wraps an io.Reader with a msgio framed reader. The msgio.Reader
136 -// will read whole messages at a time (using the length). Assumes an equivalent
137 -// writer on the other side.
138 -func NewReader(r io.Reader) ReadCloser {
139 - return NewReaderWithPool(r, &mpool.ByteSlicePool)
140 -}
141 -
142 -// NewReaderWithPool wraps an io.Reader with a msgio framed reader. The msgio.Reader
143 -// will read whole messages at a time (using the length). Assumes an equivalent
144 -// writer on the other side. It uses a given mpool.Pool
145 -func NewReaderWithPool(r io.Reader, p *mpool.Pool) ReadCloser {
146 - if p == nil {
147 - panic("nil pool")
148 - }
149 - return &reader{
150 - R: r,
151 - lbuf: make([]byte, lengthSize),
152 - next: -1,
153 - pool: p,
154 - lock: new(sync.Mutex),
155 - max: defaultMaxSize,
156 - }
157 -}
158 -
159 -// NextMsgLen reads the length of the next msg into s.lbuf, and returns it.
160 -// WARNING: like Read, NextMsgLen is destructive. It reads from the internal
161 -// reader.
162 -func (s *reader) NextMsgLen() (int, error) {
163 - s.lock.Lock()
164 - defer s.lock.Unlock()
165 - return s.nextMsgLen()
166 -}
167 -
168 -func (s *reader) nextMsgLen() (int, error) {
169 - if s.next == -1 {
170 - n, err := ReadLen(s.R, s.lbuf)
171 - if err != nil {
172 - return 0, err
173 - }
174 -
175 - s.next = n
176 - }
177 - return s.next, nil
178 -}
179 -
180 -func (s *reader) Read(msg []byte) (int, error) {
181 - s.lock.Lock()
182 - defer s.lock.Unlock()
183 -
184 - length, err := s.nextMsgLen()
185 - if err != nil {
186 - return 0, err
187 - }
188 -
189 - if length > len(msg) {
190 - return 0, io.ErrShortBuffer
191 - }
192 -
193 - _, err = io.ReadFull(s.R, msg[:length])
194 - s.next = -1 // signal we've consumed this msg
195 - return length, err
196 -}
197 -
198 -func (s *reader) ReadMsg() ([]byte, error) {
199 - s.lock.Lock()
200 - defer s.lock.Unlock()
201 -
202 - length, err := s.nextMsgLen()
203 - if err != nil {
204 - return nil, err
205 - }
206 -
207 - if length > s.max || length < 0 {
208 - return nil, ErrMsgTooLarge
209 - }
210 -
211 - msgb := s.pool.Get(uint32(length))
212 - if msgb == nil {
213 - return nil, io.ErrShortBuffer
214 - }
215 - msg := msgb.([]byte)[:length]
216 - _, err = io.ReadFull(s.R, msg)
217 - s.next = -1 // signal we've consumed this msg
218 - return msg, err
219 -}
220 -
221 -func (s *reader) ReleaseMsg(msg []byte) {
222 - s.pool.Put(uint32(cap(msg)), msg)
223 -}
224 -
225 -func (s *reader) Close() error {
226 - s.lock.Lock()
227 - defer s.lock.Unlock()
228 -
229 - if c, ok := s.R.(io.Closer); ok {
230 - return c.Close()
231 - }
232 - return nil
233 -}
234 -
235 -// readWriter is the underlying type that implements a ReadWriter.
236 -type readWriter struct {
237 - Reader
238 - Writer
239 -}
240 -
241 -// NewReadWriter wraps an io.ReadWriter with a msgio.ReadWriter. Writing
242 -// and Reading will be appropriately framed.
243 -func NewReadWriter(rw io.ReadWriter) ReadWriteCloser {
244 - return &readWriter{
245 - Reader: NewReader(rw),
246 - Writer: NewWriter(rw),
247 - }
248 -}
249 -
250 -// Combine wraps a pair of msgio.Writer and msgio.Reader with a msgio.ReadWriter.
251 -func Combine(w Writer, r Reader) ReadWriteCloser {
252 - return &readWriter{Reader: r, Writer: w}
253 -}
254 -
255 -func (rw *readWriter) Close() error {
256 - var errs []error
257 -
258 - if w, ok := rw.Writer.(WriteCloser); ok {
259 - if err := w.Close(); err != nil {
260 - errs = append(errs, err)
261 - }
262 - }
263 - if r, ok := rw.Reader.(ReadCloser); ok {
264 - if err := r.Close(); err != nil {
265 - errs = append(errs, err)
266 - }
267 - }
268 -
269 - if len(errs) > 0 {
270 - return multiErr(errs)
271 - }
272 - return nil
273 -}
274 -
275 -// multiErr is a util to return multiple errors
276 -type multiErr []error
277 -
278 -func (m multiErr) Error() string {
279 - if len(m) == 0 {
280 - return "no errors"
281 - }
282 -
283 - s := "Multiple errors: "
284 - for i, e := range m {
285 - if i != 0 {
286 - s += ", "
287 - }
288 - s += e.Error()
289 - }
290 - return s
291 -}
Godeps/_workspace/src/github.com/jbenet/go-msgio/msgio/.gitignore deleted
-1
@@ -1 +0,0 @@
1 -msgio
Godeps/_workspace/src/github.com/jbenet/go-msgio/msgio/README.md deleted
-24
@@ -1,24 +0,0 @@
1 -# msgio headers tool
2 -
3 -Conveniently output msgio headers.
4 -
5 -## Install
6 -
7 -```
8 -go get github.com/jbenet/go-msgio/msgio
9 -```
10 -
11 -## Usage
12 -
13 -```
14 -> msgio -h
15 -msgio - tool to wrap messages with msgio header
16 -
17 -Usage
18 - msgio header 1020 >header
19 - cat file | msgio wrap >wrapped
20 -
21 -Commands
22 - header <size> output a msgio header of given size
23 - wrap wrap incoming stream with msgio
24 -```
Godeps/_workspace/src/github.com/jbenet/go-msgio/msgio/msgio.go deleted
-108
@@ -1,108 +0,0 @@
1 -package main
2 -
3 -import (
4 - "flag"
5 - "fmt"
6 - "io"
7 - "io/ioutil"
8 - "os"
9 - "strconv"
10 - "strings"
11 -
12 - msgio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-msgio"
13 -)
14 -
15 -var Args ArgType
16 -
17 -type ArgType struct {
18 - Command string
19 - Args []string
20 -}
21 -
22 -func (a *ArgType) Arg(i int) string {
23 - n := i + 1
24 - if len(a.Args) < n {
25 - die(fmt.Sprintf("expected %d argument(s)", n))
26 - }
27 - return a.Args[i]
28 -}
29 -
30 -var usageStr = `
31 -msgio - tool to wrap messages with msgio header
32 -
33 -Usage
34 - msgio header 1020 >header
35 - cat file | msgio wrap >wrapped
36 -
37 -Commands
38 - header <size> output a msgio header of given size
39 - wrap wrap incoming stream with msgio
40 -`
41 -
42 -func usage() {
43 - fmt.Println(strings.TrimSpace(usageStr))
44 - os.Exit(0)
45 -}
46 -
47 -func die(err string) {
48 - fmt.Fprintf(os.Stderr, "error: %s\n", err)
49 - os.Exit(-1)
50 -}
51 -
52 -func main() {
53 - if err := run(); err != nil {
54 - die(err.Error())
55 - }
56 -}
57 -
58 -func argParse() {
59 - flag.Usage = usage
60 - flag.Parse()
61 -
62 - args := flag.Args()
63 - if l := len(args); l < 1 || l > 2 {
64 - usage()
65 - }
66 -
67 - Args.Command = flag.Args()[0]
68 - Args.Args = flag.Args()[1:]
69 -}
70 -
71 -func run() error {
72 - argParse()
73 -
74 - w := os.Stdout
75 - r := os.Stdin
76 -
77 - switch Args.Command {
78 - case "header":
79 - size, err := strconv.Atoi(Args.Arg(0))
80 - if err != nil {
81 - return err
82 - }
83 - return header(w, size)
84 - case "wrap":
85 - return wrap(w, r)
86 - default:
87 - usage()
88 - return nil
89 - }
90 -}
91 -
92 -func header(w io.Writer, size int) error {
93 - return msgio.WriteLen(w, size)
94 -}
95 -
96 -func wrap(w io.Writer, r io.Reader) error {
97 - buf, err := ioutil.ReadAll(r)
98 - if err != nil {
99 - return err
100 - }
101 -
102 - if err := msgio.WriteLen(w, len(buf)); err != nil {
103 - return err
104 - }
105 -
106 - _, err = w.Write(buf)
107 - return err
108 -}
Godeps/_workspace/src/github.com/jbenet/go-msgio/msgio_test.go deleted
-197
@@ -1,197 +0,0 @@
1 -package msgio
2 -
3 -import (
4 - "bytes"
5 - "fmt"
6 - randbuf "gx/ipfs/QmYNGtJHgaGZkpzq8yG6Wxqm6EQTKqgpBfnyyGBKbZeDUi/go-randbuf"
7 - "io"
8 - "math/rand"
9 - "sync"
10 - "testing"
11 - "time"
12 -)
13 -
14 -func TestReadWrite(t *testing.T) {
15 - buf := bytes.NewBuffer(nil)
16 - writer := NewWriter(buf)
17 - reader := NewReader(buf)
18 - SubtestReadWrite(t, writer, reader)
19 -}
20 -
21 -func TestReadWriteMsg(t *testing.T) {
22 - buf := bytes.NewBuffer(nil)
23 - writer := NewWriter(buf)
24 - reader := NewReader(buf)
25 - SubtestReadWriteMsg(t, writer, reader)
26 -}
27 -
28 -func TestReadWriteMsgSync(t *testing.T) {
29 - buf := bytes.NewBuffer(nil)
30 - writer := NewWriter(buf)
31 - reader := NewReader(buf)
32 - SubtestReadWriteMsgSync(t, writer, reader)
33 -}
34 -
35 -func SubtestReadWrite(t *testing.T, writer WriteCloser, reader ReadCloser) {
36 - msgs := [1000][]byte{}
37 -
38 - r := rand.New(rand.NewSource(time.Now().UnixNano()))
39 - for i := range msgs {
40 - msgs[i] = randbuf.RandBuf(r, r.Intn(1000))
41 - n, err := writer.Write(msgs[i])
42 - if err != nil {
43 - t.Fatal(err)
44 - }
45 - if n != len(msgs[i]) {
46 - t.Fatal("wrong length:", n, len(msgs[i]))
47 - }
48 - }
49 -
50 - if err := writer.Close(); err != nil {
51 - t.Fatal(err)
52 - }
53 -
54 - for i := 0; ; i++ {
55 - msg2 := make([]byte, 1000)
56 - n, err := reader.Read(msg2)
57 - if err != nil {
58 - if err == io.EOF {
59 - if i < len(msg2) {
60 - t.Error("failed to read all messages", len(msgs), i)
61 - }
62 - break
63 - }
64 - t.Error("unexpected error", err)
65 - }
66 -
67 - msg1 := msgs[i]
68 - msg2 = msg2[:n]
69 - if !bytes.Equal(msg1, msg2) {
70 - t.Fatal("message retrieved not equal\n", msg1, "\n\n", msg2)
71 - }
72 - }
73 -
74 - if err := reader.Close(); err != nil {
75 - t.Error(err)
76 - }
77 -}
78 -
79 -func SubtestReadWriteMsg(t *testing.T, writer WriteCloser, reader ReadCloser) {
80 - msgs := [1000][]byte{}
81 -
82 - r := rand.New(rand.NewSource(time.Now().UnixNano()))
83 - for i := range msgs {
84 - msgs[i] = randbuf.RandBuf(r, r.Intn(1000))
85 - err := writer.WriteMsg(msgs[i])
86 - if err != nil {
87 - t.Fatal(err)
88 - }
89 - }
90 -
91 - if err := writer.Close(); err != nil {
92 - t.Fatal(err)
93 - }
94 -
95 - for i := 0; ; i++ {
96 - msg2, err := reader.ReadMsg()
97 - if err != nil {
98 - if err == io.EOF {
99 - if i < len(msg2) {
100 - t.Error("failed to read all messages", len(msgs), i)
101 - }
102 - break
103 - }
104 - t.Error("unexpected error", err)
105 - }
106 -
107 - msg1 := msgs[i]
108 - if !bytes.Equal(msg1, msg2) {
109 - t.Fatal("message retrieved not equal\n", msg1, "\n\n", msg2)
110 - }
111 - }
112 -
113 - if err := reader.Close(); err != nil {
114 - t.Error(err)
115 - }
116 -}
117 -
118 -func SubtestReadWriteMsgSync(t *testing.T, writer WriteCloser, reader ReadCloser) {
119 - msgs := [1000][]byte{}
120 -
121 - r := rand.New(rand.NewSource(time.Now().UnixNano()))
122 - for i := range msgs {
123 - msgs[i] = randbuf.RandBuf(r, r.Intn(1000)+4)
124 - NBO.PutUint32(msgs[i][:4], uint32(i))
125 - }
126 -
127 - var wg1 sync.WaitGroup
128 - var wg2 sync.WaitGroup
129 -
130 - errs := make(chan error, 10000)
131 - for i := range msgs {
132 - wg1.Add(1)
133 - go func(i int) {
134 - defer wg1.Done()
135 -
136 - err := writer.WriteMsg(msgs[i])
137 - if err != nil {
138 - errs <- err
139 - }
140 - }(i)
141 - }
142 -
143 - wg1.Wait()
144 - if err := writer.Close(); err != nil {
145 - t.Fatal(err)
146 - }
147 -
148 - for i := 0; i < len(msgs)+1; i++ {
149 - wg2.Add(1)
150 - go func(i int) {
151 - defer wg2.Done()
152 -
153 - msg2, err := reader.ReadMsg()
154 - if err != nil {
155 - if err == io.EOF {
156 - if i < len(msg2) {
157 - errs <- fmt.Errorf("failed to read all messages", len(msgs), i)
158 - }
159 - return
160 - }
161 - errs <- fmt.Errorf("unexpected error", err)
162 - }
163 -
164 - mi := NBO.Uint32(msg2[:4])
165 - msg1 := msgs[mi]
166 - if !bytes.Equal(msg1, msg2) {
167 - errs <- fmt.Errorf("message retrieved not equal\n", msg1, "\n\n", msg2)
168 - }
169 - }(i)
170 - }
171 -
172 - wg2.Wait()
173 - close(errs)
174 -
175 - if err := reader.Close(); err != nil {
176 - t.Error(err)
177 - }
178 -
179 - for e := range errs {
180 - t.Error(e)
181 - }
182 -}
183 -
184 -func TestBadSizes(t *testing.T) {
185 - data := make([]byte, 4)
186 -
187 - // on a 64 bit system, this will fail because its too large
188 - // on a 32 bit system, this will fail because its too small
189 - NBO.PutUint32(data, 4000000000)
190 - buf := bytes.NewReader(data)
191 - read := NewReader(buf)
192 - msg, err := read.ReadMsg()
193 - if err == nil {
194 - t.Fatal(err)
195 - }
196 - _ = msg
197 -}
Godeps/_workspace/src/github.com/jbenet/go-msgio/num.go deleted
-33
@@ -1,33 +0,0 @@
1 -package msgio
2 -
3 -import (
4 - "encoding/binary"
5 - "io"
6 -)
7 -
8 -// NBO is NetworkByteOrder
9 -var NBO = binary.BigEndian
10 -
11 -// WriteLen writes a length to the given writer.
12 -func WriteLen(w io.Writer, l int) error {
13 - ul := uint32(l)
14 - return binary.Write(w, NBO, &ul)
15 -}
16 -
17 -// ReadLen reads a length from the given reader.
18 -// if buf is non-nil, it reuses the buffer. Ex:
19 -// l, err := ReadLen(r, nil)
20 -// _, err := ReadLen(r, buf)
21 -func ReadLen(r io.Reader, buf []byte) (int, error) {
22 - if len(buf) < 4 {
23 - buf = make([]byte, 4)
24 - }
25 - buf = buf[:4]
26 -
27 - if _, err := io.ReadFull(r, buf); err != nil {
28 - return 0, err
29 - }
30 -
31 - n := int(NBO.Uint32(buf))
32 - return n, nil
33 -}
Godeps/_workspace/src/github.com/jbenet/go-msgio/varint.go deleted
-188
@@ -1,188 +0,0 @@
1 -package msgio
2 -
3 -import (
4 - "encoding/binary"
5 - "io"
6 - "sync"
7 -
8 - mpool "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-msgio/mpool"
9 -)
10 -
11 -// varintWriter is the underlying type that implements the Writer interface.
12 -type varintWriter struct {
13 - W io.Writer
14 -
15 - lbuf []byte // for encoding varints
16 - lock sync.Locker // for threadsafe writes
17 -}
18 -
19 -// NewVarintWriter wraps an io.Writer with a varint msgio framed writer.
20 -// The msgio.Writer will write the length prefix of every message written
21 -// as a varint, using https://golang.org/pkg/encoding/binary/#PutUvarint
22 -func NewVarintWriter(w io.Writer) WriteCloser {
23 - return &varintWriter{
24 - W: w,
25 - lbuf: make([]byte, binary.MaxVarintLen64),
26 - lock: new(sync.Mutex),
27 - }
28 -}
29 -
30 -func (s *varintWriter) Write(msg []byte) (int, error) {
31 - err := s.WriteMsg(msg)
32 - if err != nil {
33 - return 0, err
34 - }
35 - return len(msg), nil
36 -}
37 -
38 -func (s *varintWriter) WriteMsg(msg []byte) error {
39 - s.lock.Lock()
40 - defer s.lock.Unlock()
41 -
42 - length := uint64(len(msg))
43 - n := binary.PutUvarint(s.lbuf, length)
44 - if _, err := s.W.Write(s.lbuf[:n]); err != nil {
45 - return err
46 - }
47 - _, err := s.W.Write(msg)
48 - return err
49 -}
50 -
51 -func (s *varintWriter) Close() error {
52 - s.lock.Lock()
53 - defer s.lock.Unlock()
54 -
55 - if c, ok := s.W.(io.Closer); ok {
56 - return c.Close()
57 - }
58 - return nil
59 -}
60 -
61 -// varintReader is the underlying type that implements the Reader interface.
62 -type varintReader struct {
63 - R io.Reader
64 - br io.ByteReader // for reading varints.
65 -
66 - lbuf []byte
67 - next int
68 - pool *mpool.Pool
69 - lock sync.Locker
70 - max int // the maximal message size (in bytes) this reader handles
71 -}
72 -
73 -// NewVarintReader wraps an io.Reader with a varint msgio framed reader.
74 -// The msgio.Reader will read whole messages at a time (using the length).
75 -// Varints read according to https://golang.org/pkg/encoding/binary/#ReadUvarint
76 -// Assumes an equivalent writer on the other side.
77 -func NewVarintReader(r io.Reader) ReadCloser {
78 - return NewVarintReaderWithPool(r, &mpool.ByteSlicePool)
79 -}
80 -
81 -// NewVarintReaderWithPool wraps an io.Reader with a varint msgio framed reader.
82 -// The msgio.Reader will read whole messages at a time (using the length).
83 -// Varints read according to https://golang.org/pkg/encoding/binary/#ReadUvarint
84 -// Assumes an equivalent writer on the other side. It uses a given mpool.Pool
85 -func NewVarintReaderWithPool(r io.Reader, p *mpool.Pool) ReadCloser {
86 - if p == nil {
87 - panic("nil pool")
88 - }
89 - return &varintReader{
90 - R: r,
91 - br: &simpleByteReader{R: r},
92 - lbuf: make([]byte, binary.MaxVarintLen64),
93 - next: -1,
94 - pool: p,
95 - lock: new(sync.Mutex),
96 - max: defaultMaxSize,
97 - }
98 -}
99 -
100 -// NextMsgLen reads the length of the next msg into s.lbuf, and returns it.
101 -// WARNING: like Read, NextMsgLen is destructive. It reads from the internal
102 -// reader.
103 -func (s *varintReader) NextMsgLen() (int, error) {
104 - s.lock.Lock()
105 - defer s.lock.Unlock()
106 - return s.nextMsgLen()
107 -}
108 -
109 -func (s *varintReader) nextMsgLen() (int, error) {
110 - if s.next == -1 {
111 - length, err := binary.ReadUvarint(s.br)
112 - if err != nil {
113 - return 0, err
114 - }
115 - s.next = int(length)
116 - }
117 - return s.next, nil
118 -}
119 -
120 -func (s *varintReader) Read(msg []byte) (int, error) {
121 - s.lock.Lock()
122 - defer s.lock.Unlock()
123 -
124 - length, err := s.nextMsgLen()
125 - if err != nil {
126 - return 0, err
127 - }
128 -
129 - if length > len(msg) {
130 - return 0, io.ErrShortBuffer
131 - }
132 - _, err = io.ReadFull(s.R, msg[:length])
133 - s.next = -1 // signal we've consumed this msg
134 - return length, err
135 -}
136 -
137 -func (s *varintReader) ReadMsg() ([]byte, error) {
138 - s.lock.Lock()
139 - defer s.lock.Unlock()
140 -
141 - length, err := s.nextMsgLen()
142 - if err != nil {
143 - return nil, err
144 - }
145 -
146 - if length > s.max {
147 - return nil, ErrMsgTooLarge
148 - }
149 -
150 - msgb := s.pool.Get(uint32(length))
151 - if msgb == nil {
152 - return nil, io.ErrShortBuffer
153 - }
154 - msg := msgb.([]byte)[:length]
155 - _, err = io.ReadFull(s.R, msg)
156 - s.next = -1 // signal we've consumed this msg
157 - return msg, err
158 -}
159 -
160 -func (s *varintReader) ReleaseMsg(msg []byte) {
161 - s.pool.Put(uint32(cap(msg)), msg)
162 -}
163 -
164 -func (s *varintReader) Close() error {
165 - s.lock.Lock()
166 - defer s.lock.Unlock()
167 -
168 - if c, ok := s.R.(io.Closer); ok {
169 - return c.Close()
170 - }
171 - return nil
172 -}
173 -
174 -type simpleByteReader struct {
175 - R io.Reader
176 - buf []byte
177 -}
178 -
179 -func (r *simpleByteReader) ReadByte() (c byte, err error) {
180 - if r.buf == nil {
181 - r.buf = make([]byte, 1)
182 - }
183 -
184 - if _, err := io.ReadFull(r.R, r.buf); err != nil {
185 - return 0, err
186 - }
187 - return r.buf[0], nil
188 -}
Godeps/_workspace/src/github.com/jbenet/go-msgio/varint_test.go deleted
-66
@@ -1,66 +0,0 @@
1 -package msgio
2 -
3 -import (
4 - "bytes"
5 - "encoding/binary"
6 - "testing"
7 -)
8 -
9 -func TestVarintReadWrite(t *testing.T) {
10 - buf := bytes.NewBuffer(nil)
11 - writer := NewVarintWriter(buf)
12 - reader := NewVarintReader(buf)
13 - SubtestReadWrite(t, writer, reader)
14 -}
15 -
16 -func TestVarintReadWriteMsg(t *testing.T) {
17 - buf := bytes.NewBuffer(nil)
18 - writer := NewVarintWriter(buf)
19 - reader := NewVarintReader(buf)
20 - SubtestReadWriteMsg(t, writer, reader)
21 -}
22 -
23 -func TestVarintReadWriteMsgSync(t *testing.T) {
24 - buf := bytes.NewBuffer(nil)
25 - writer := NewVarintWriter(buf)
26 - reader := NewVarintReader(buf)
27 - SubtestReadWriteMsgSync(t, writer, reader)
28 -}
29 -
30 -func TestVarintWrite(t *testing.T) {
31 - SubtestVarintWrite(t, []byte("hello world"))
32 - SubtestVarintWrite(t, []byte("hello world hello world hello world"))
33 - SubtestVarintWrite(t, make([]byte, 1<<20))
34 - SubtestVarintWrite(t, []byte(""))
35 -}
36 -
37 -func SubtestVarintWrite(t *testing.T, msg []byte) {
38 - buf := bytes.NewBuffer(nil)
39 - writer := NewVarintWriter(buf)
40 -
41 - if err := writer.WriteMsg(msg); err != nil {
42 - t.Fatal(err)
43 - }
44 -
45 - bb := buf.Bytes()
46 -
47 - sbr := simpleByteReader{R: buf}
48 - length, err := binary.ReadUvarint(&sbr)
49 - if err != nil {
50 - t.Fatal(err)
51 - }
52 -
53 - t.Logf("checking varint is %d", len(msg))
54 - if int(length) != len(msg) {
55 - t.Fatalf("incorrect varint: %d != %d", length, len(msg))
56 - }
57 -
58 - lbuf := make([]byte, binary.MaxVarintLen64)
59 - n := binary.PutUvarint(lbuf, length)
60 -
61 - bblen := int(length) + n
62 - t.Logf("checking wrote (%d + %d) bytes", length, n)
63 - if len(bb) != bblen {
64 - t.Fatalf("wrote incorrect number of bytes: %d != %d", len(bb), bblen)
65 - }
66 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/.travis.yml deleted
-11
@@ -1,11 +0,0 @@
1 -language: go
2 -
3 -go:
4 - - 1.3
5 - - release
6 - - tip
7 -
8 -script:
9 - - make test
10 -
11 -env: TEST_VERBOSE=1
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/Godeps/Godeps.json deleted
-43
@@ -1,43 +0,0 @@
1 -{
2 - "ImportPath": "github.com/jbenet/go-multiaddr-net",
3 - "GoVersion": "go1.4.2",
4 - "Packages": [
5 - "./..."
6 - ],
7 - "Deps": [
8 - {
9 - "ImportPath": "github.com/anacrolix/jitter",
10 - "Rev": "2ea5c18645100745b24e9f5cfc9b3f6f7eac51ef"
11 - },
12 - {
13 - "ImportPath": "github.com/anacrolix/missinggo",
14 - "Rev": "4e1ca5963308863b56c31863f60c394a7365ec29"
15 - },
16 - {
17 - "ImportPath": "github.com/anacrolix/utp",
18 - "Rev": "0bb24de92c268452fb9106ca4fb9302442ca0dee"
19 - },
20 - {
21 - "ImportPath": "github.com/bradfitz/iter",
22 - "Rev": "454541ec3da2a73fc34fd049b19ee5777bf19345"
23 - },
24 - {
25 - "ImportPath": "github.com/jbenet/go-base58",
26 - "Rev": "568a28d73fd97651d3442392036a658b6976eed5"
27 - },
28 - {
29 - "ImportPath": "github.com/jbenet/go-multiaddr",
30 - "Comment": "0.1.2-38-gc13f11b",
31 - "Rev": "c13f11bbfe6439771f4df7bfb330f686826144e8"
32 - },
33 - {
34 - "ImportPath": "github.com/jbenet/go-multihash",
35 - "Comment": "0.1.0-36-g87e53a9",
36 - "Rev": "87e53a9d2875a18a7863b351d22f912545e6b3a3"
37 - },
38 - {
39 - "ImportPath": "golang.org/x/crypto/sha3",
40 - "Rev": "1351f936d976c60a0a48d728281922cf63eafb8d"
41 - }
42 - ]
43 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/Godeps/Readme deleted
-5
@@ -1,5 +0,0 @@
1 -This directory tree is generated automatically by godep.
2 -
3 -Please do not edit.
4 -
5 -See https://github.com/tools/godep for more information.
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/LICENSE deleted
-21
@@ -1,21 +0,0 @@
1 -The MIT License (MIT)
2 -
3 -Copyright (c) 2014 Juan Batiz-Benet
4 -
5 -Permission is hereby granted, free of charge, to any person obtaining a copy
6 -of this software and associated documentation files (the "Software"), to deal
7 -in the Software without restriction, including without limitation the rights
8 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 -copies of the Software, and to permit persons to whom the Software is
10 -furnished to do so, subject to the following conditions:
11 -
12 -The above copyright notice and this permission notice shall be included in
13 -all copies or substantial portions of the Software.
14 -
15 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 -THE SOFTWARE.
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/Makefile deleted
-19
@@ -1,19 +0,0 @@
1 -all: install
2 -
3 -godep:
4 - go get github.com/tools/godep
5 -
6 -# saves/vendors third-party dependencies to Godeps/_workspace
7 -# -r flag rewrites import paths to use the vendored path
8 -# ./... performs operation on all packages in tree
9 -vendor: godep
10 - godep save -r ./...
11 -
12 -install: dep
13 - cd multiaddr && go install
14 -
15 -test:
16 - go test -race -cpu=5 -v ./...
17 -
18 -dep:
19 - cd multiaddr && go get ./...
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/README.md deleted
-11
@@ -1,11 +0,0 @@
1 -# multiaddr/net - Multiaddr friendly net
2 -
3 -Package multiaddr/net provides [Multiaddr](http://github.com/jbenet/go-multiaddr) specific versions of common
4 -functions in stdlib's net package. This means wrappers of
5 -standard net symbols like net.Dial and net.Listen, as well
6 -as conversion to/from net.Addr.
7 -
8 -Docs:
9 -
10 -- `multiaddr/net`: https://godoc.org/github.com/jbenet/go-multiaddr-net
11 -- `multiaddr`: https://godoc.org/github.com/jbenet/go-multiaddr
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/convert.go deleted
-172
@@ -1,172 +0,0 @@
1 -package manet
2 -
3 -import (
4 - "fmt"
5 - "net"
6 - "strings"
7 -
8 - utp "gx/ipfs/QmQB7mNP3QE7b4zP2MQmsyJDqG5hzYE2CL8k1VyLWky2Ed/go-multiaddr-net/utp"
9 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
10 -)
11 -
12 -var errIncorrectNetAddr = fmt.Errorf("incorrect network addr conversion")
13 -
14 -// FromNetAddr converts a net.Addr type to a Multiaddr.
15 -func FromNetAddr(a net.Addr) (ma.Multiaddr, error) {
16 - if a == nil {
17 - return nil, fmt.Errorf("nil multiaddr")
18 - }
19 -
20 - switch a.Network() {
21 - case "tcp", "tcp4", "tcp6":
22 - ac, ok := a.(*net.TCPAddr)
23 - if !ok {
24 - return nil, errIncorrectNetAddr
25 - }
26 -
27 - // Get IP Addr
28 - ipm, err := FromIP(ac.IP)
29 - if err != nil {
30 - return nil, errIncorrectNetAddr
31 - }
32 -
33 - // Get TCP Addr
34 - tcpm, err := ma.NewMultiaddr(fmt.Sprintf("/tcp/%d", ac.Port))
35 - if err != nil {
36 - return nil, errIncorrectNetAddr
37 - }
38 -
39 - // Encapsulate
40 - return ipm.Encapsulate(tcpm), nil
41 -
42 - case "udp", "upd4", "udp6":
43 - ac, ok := a.(*net.UDPAddr)
44 - if !ok {
45 - return nil, errIncorrectNetAddr
46 - }
47 -
48 - // Get IP Addr
49 - ipm, err := FromIP(ac.IP)
50 - if err != nil {
51 - return nil, errIncorrectNetAddr
52 - }
53 -
54 - // Get UDP Addr
55 - udpm, err := ma.NewMultiaddr(fmt.Sprintf("/udp/%d", ac.Port))
56 - if err != nil {
57 - return nil, errIncorrectNetAddr
58 - }
59 -
60 - // Encapsulate
61 - return ipm.Encapsulate(udpm), nil
62 -
63 - case "utp", "utp4", "utp6":
64 - acc, ok := a.(*utp.Addr)
65 - if !ok {
66 - return nil, errIncorrectNetAddr
67 - }
68 -
69 - // Get UDP Addr
70 - ac, ok := acc.Child().(*net.UDPAddr)
71 - if !ok {
72 - return nil, errIncorrectNetAddr
73 - }
74 -
75 - // Get IP Addr
76 - ipm, err := FromIP(ac.IP)
77 - if err != nil {
78 - return nil, errIncorrectNetAddr
79 - }
80 -
81 - // Get UDP Addr
82 - utpm, err := ma.NewMultiaddr(fmt.Sprintf("/udp/%d/utp", ac.Port))
83 - if err != nil {
84 - return nil, errIncorrectNetAddr
85 - }
86 -
87 - // Encapsulate
88 - return ipm.Encapsulate(utpm), nil
89 -
90 - case "ip", "ip4", "ip6":
91 - ac, ok := a.(*net.IPAddr)
92 - if !ok {
93 - return nil, errIncorrectNetAddr
94 - }
95 - return FromIP(ac.IP)
96 -
97 - case "ip+net":
98 - ac, ok := a.(*net.IPNet)
99 - if !ok {
100 - return nil, errIncorrectNetAddr
101 - }
102 - return FromIP(ac.IP)
103 -
104 - default:
105 - return nil, fmt.Errorf("unknown network %v", a.Network())
106 - }
107 -}
108 -
109 -// ToNetAddr converts a Multiaddr to a net.Addr
110 -// Must be ThinWaist. acceptable protocol stacks are:
111 -// /ip{4,6}/{tcp, udp}
112 -func ToNetAddr(maddr ma.Multiaddr) (net.Addr, error) {
113 - network, host, err := DialArgs(maddr)
114 - if err != nil {
115 - return nil, err
116 - }
117 -
118 - switch network {
119 - case "tcp", "tcp4", "tcp6":
120 - return net.ResolveTCPAddr(network, host)
121 - case "udp", "udp4", "udp6":
122 - return net.ResolveUDPAddr(network, host)
123 - case "utp", "utp4", "utp6":
124 - return utp.ResolveAddr(network, host)
125 - case "ip", "ip4", "ip6":
126 - return net.ResolveIPAddr(network, host)
127 - }
128 -
129 - return nil, fmt.Errorf("network not supported: %s", network)
130 -}
131 -
132 -// FromIP converts a net.IP type to a Multiaddr.
133 -func FromIP(ip net.IP) (ma.Multiaddr, error) {
134 - switch {
135 - case ip.To4() != nil:
136 - return ma.NewMultiaddr("/ip4/" + ip.String())
137 - case ip.To16() != nil:
138 - return ma.NewMultiaddr("/ip6/" + ip.String())
139 - default:
140 - return nil, errIncorrectNetAddr
141 - }
142 -}
143 -
144 -// DialArgs is a convenience function returning arguments for use in net.Dial
145 -func DialArgs(m ma.Multiaddr) (string, string, error) {
146 - if !IsThinWaist(m) {
147 - return "", "", fmt.Errorf("%s is not a 'thin waist' address", m)
148 - }
149 -
150 - str := m.String()
151 - parts := strings.Split(str, "/")[1:]
152 -
153 - if len(parts) == 2 { // only IP
154 - return parts[0], parts[1], nil
155 - }
156 -
157 - network := parts[2]
158 - if parts[2] == "udp" && len(parts) > 4 && parts[4] == "utp" {
159 - network = parts[4]
160 - }
161 -
162 - var host string
163 - switch parts[0] {
164 - case "ip4":
165 - network = network + "4"
166 - host = strings.Join([]string{parts[1], parts[3]}, ":")
167 - case "ip6":
168 - network = network + "6"
169 - host = fmt.Sprintf("[%s]:%s", parts[1], parts[3])
170 - }
171 - return network, host, nil
172 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/convert_test.go deleted
-157
@@ -1,157 +0,0 @@
1 -package manet
2 -
3 -import (
4 - "net"
5 - "testing"
6 -
7 - mautp "gx/ipfs/QmQB7mNP3QE7b4zP2MQmsyJDqG5hzYE2CL8k1VyLWky2Ed/go-multiaddr-net/utp"
8 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
9 -)
10 -
11 -type GenFunc func() (ma.Multiaddr, error)
12 -
13 -func testConvert(t *testing.T, s string, gen GenFunc) {
14 - m, err := gen()
15 - if err != nil {
16 - t.Fatal("failed to generate.")
17 - }
18 -
19 - if s2 := m.String(); err != nil || s2 != s {
20 - t.Fatal("failed to convert: " + s + " != " + s2)
21 - }
22 -}
23 -
24 -func testToNetAddr(t *testing.T, maddr, ntwk, addr string) {
25 - m, err := ma.NewMultiaddr(maddr)
26 - if err != nil {
27 - t.Fatal("failed to generate.")
28 - }
29 -
30 - naddr, err := ToNetAddr(m)
31 - if addr == "" { // should fail
32 - if err == nil {
33 - t.Fatalf("failed to error: %s", m)
34 - }
35 - return
36 - }
37 -
38 - // shouldn't fail
39 - if err != nil {
40 - t.Fatalf("failed to convert to net addr: %s", m)
41 - }
42 -
43 - if naddr.String() != addr {
44 - t.Fatalf("naddr.Address() == %s != %s", naddr, addr)
45 - }
46 -
47 - if naddr.Network() != ntwk {
48 - t.Fatalf("naddr.Network() == %s != %s", naddr.Network(), ntwk)
49 - }
50 -
51 - // should convert properly
52 - switch ntwk {
53 - case "tcp":
54 - _ = naddr.(*net.TCPAddr)
55 - case "udp":
56 - _ = naddr.(*net.UDPAddr)
57 - case "ip":
58 - _ = naddr.(*net.IPAddr)
59 - }
60 -}
61 -
62 -func TestFromIP4(t *testing.T) {
63 - testConvert(t, "/ip4/10.20.30.40", func() (ma.Multiaddr, error) {
64 - return FromIP(net.ParseIP("10.20.30.40"))
65 - })
66 -}
67 -
68 -func TestFromIP6(t *testing.T) {
69 - testConvert(t, "/ip6/2001:4860:0:2001::68", func() (ma.Multiaddr, error) {
70 - return FromIP(net.ParseIP("2001:4860:0:2001::68"))
71 - })
72 -}
73 -
74 -func TestFromTCP(t *testing.T) {
75 - testConvert(t, "/ip4/10.20.30.40/tcp/1234", func() (ma.Multiaddr, error) {
76 - return FromNetAddr(&net.TCPAddr{
77 - IP: net.ParseIP("10.20.30.40"),
78 - Port: 1234,
79 - })
80 - })
81 -}
82 -
83 -func TestFromUDP(t *testing.T) {
84 - testConvert(t, "/ip4/10.20.30.40/udp/1234", func() (ma.Multiaddr, error) {
85 - return FromNetAddr(&net.UDPAddr{
86 - IP: net.ParseIP("10.20.30.40"),
87 - Port: 1234,
88 - })
89 - })
90 -}
91 -
92 -func TestFromUTP(t *testing.T) {
93 - a := &net.UDPAddr{IP: net.ParseIP("10.20.30.40"), Port: 1234}
94 - testConvert(t, "/ip4/10.20.30.40/udp/1234/utp", func() (ma.Multiaddr, error) {
95 - return FromNetAddr(mautp.MakeAddr(a))
96 - })
97 -}
98 -
99 -func TestThinWaist(t *testing.T) {
100 - addrs := map[string]bool{
101 - "/ip4/127.0.0.1/udp/1234": true,
102 - "/ip4/127.0.0.1/tcp/1234": true,
103 - "/ip4/127.0.0.1/udp/1234/utp": true,
104 - "/ip4/127.0.0.1/udp/1234/tcp/1234": true,
105 - "/ip4/127.0.0.1/tcp/12345/ip4/1.2.3.4": true,
106 - "/ip6/::1/tcp/80": true,
107 - "/ip6/::1/udp/80": true,
108 - "/ip6/::1": true,
109 - "/ip6/::1/utp": false,
110 - "/tcp/1234/ip4/1.2.3.4": false,
111 - "/tcp/1234": false,
112 - "/tcp/1234/utp": false,
113 - "/tcp/1234/udp/1234": false,
114 - "/ip4/1.2.3.4/ip4/2.3.4.5": true,
115 - "/ip6/::1/ip4/2.3.4.5": true,
116 - }
117 -
118 - for a, res := range addrs {
119 - m, err := ma.NewMultiaddr(a)
120 - if err != nil {
121 - t.Fatalf("failed to construct Multiaddr: %s", a)
122 - }
123 -
124 - if IsThinWaist(m) != res {
125 - t.Fatalf("IsThinWaist(%s) != %v", a, res)
126 - }
127 - }
128 -}
129 -
130 -func TestDialArgs(t *testing.T) {
131 - test := func(e_maddr, e_nw, e_host string) {
132 - m, err := ma.NewMultiaddr(e_maddr)
133 - if err != nil {
134 - t.Fatal("failed to construct", "/ip4/127.0.0.1/udp/1234", e_maddr)
135 - }
136 -
137 - nw, host, err := DialArgs(m)
138 - if err != nil {
139 - t.Fatal("failed to get dial args", e_maddr, m, err)
140 - }
141 -
142 - if nw != e_nw {
143 - t.Error("failed to get udp network Dial Arg", e_nw, nw)
144 - }
145 -
146 - if host != e_host {
147 - t.Error("failed to get host:port Dial Arg", e_host, host)
148 - }
149 - }
150 -
151 - test("/ip4/127.0.0.1/udp/1234", "udp4", "127.0.0.1:1234")
152 - test("/ip4/127.0.0.1/tcp/4321", "tcp4", "127.0.0.1:4321")
153 - test("/ip4/127.0.0.1/udp/1234/utp", "utp4", "127.0.0.1:1234")
154 - test("/ip6/::1/udp/1234", "udp6", "[::1]:1234")
155 - test("/ip6/::1/tcp/4321", "tcp6", "[::1]:4321")
156 - test("/ip6/::1/udp/1234/utp", "utp6", "[::1]:1234")
157 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/doc.go deleted
-5
@@ -1,5 +0,0 @@
1 -// Package manet provides Multiaddr specific versions of common
2 -// functions in stdlib's net package. This means wrappers of
3 -// standard net symbols like net.Dial and net.Listen, as well
4 -// as conversion to/from net.Addr.
5 -package manet
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/ip.go deleted
-85
@@ -1,85 +0,0 @@
1 -package manet
2 -
3 -import (
4 - "bytes"
5 -
6 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
7 -)
8 -
9 -// Loopback Addresses
10 -var (
11 - // IP4Loopback is the ip4 loopback multiaddr
12 - IP4Loopback = ma.StringCast("/ip4/127.0.0.1")
13 -
14 - // IP6Loopback is the ip6 loopback multiaddr
15 - IP6Loopback = ma.StringCast("/ip6/::1")
16 -
17 - // IP6LinkLocalLoopback is the ip6 link-local loopback multiaddr
18 - IP6LinkLocalLoopback = ma.StringCast("/ip6/fe80::1")
19 -)
20 -
21 -// Unspecified Addresses (used for )
22 -var (
23 - IP4Unspecified = ma.StringCast("/ip4/0.0.0.0")
24 - IP6Unspecified = ma.StringCast("/ip6/::")
25 -)
26 -
27 -// IsThinWaist returns whether a Multiaddr starts with "Thin Waist" Protocols.
28 -// This means: /{IP4, IP6}[/{TCP, UDP}]
29 -func IsThinWaist(m ma.Multiaddr) bool {
30 - p := m.Protocols()
31 -
32 - // nothing? not even a waist.
33 - if len(p) == 0 {
34 - return false
35 - }
36 -
37 - if p[0].Code != ma.P_IP4 && p[0].Code != ma.P_IP6 {
38 - return false
39 - }
40 -
41 - // only IP? still counts.
42 - if len(p) == 1 {
43 - return true
44 - }
45 -
46 - switch p[1].Code {
47 - case ma.P_TCP, ma.P_UDP, ma.P_IP4, ma.P_IP6:
48 - return true
49 - default:
50 - return false
51 - }
52 -}
53 -
54 -// IsIPLoopback returns whether a Multiaddr is a "Loopback" IP address
55 -// This means either /ip4/127.0.0.1 or /ip6/::1
56 -// TODO: differentiate IsIPLoopback and OverIPLoopback
57 -func IsIPLoopback(m ma.Multiaddr) bool {
58 - b := m.Bytes()
59 -
60 - // /ip4/127 prefix (_entire_ /8 is loopback...)
61 - if bytes.HasPrefix(b, []byte{ma.P_IP4, 127}) {
62 - return true
63 - }
64 -
65 - // /ip6/::1
66 - if IP6Loopback.Equal(m) || IP6LinkLocalLoopback.Equal(m) {
67 - return true
68 - }
69 -
70 - return false
71 -}
72 -
73 -// IP6 Link Local addresses are non routable. The prefix is technically
74 -// fe80::/10, but we test fe80::/16 for simplicity (no need to mask).
75 -// So far, no hardware interfaces exist long enough to use those 2 bits.
76 -// Send a PR if there is.
77 -func IsIP6LinkLocal(m ma.Multiaddr) bool {
78 - return bytes.HasPrefix(m.Bytes(), []byte{ma.P_IP6, 0xfe, 0x80})
79 -}
80 -
81 -// IsIPUnspecified returns whether a Multiaddr is am Unspecified IP address
82 -// This means either /ip4/0.0.0.0 or /ip6/::
83 -func IsIPUnspecified(m ma.Multiaddr) bool {
84 - return IP4Unspecified.Equal(m) || IP6Unspecified.Equal(m)
85 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/multiaddr/.gitignore deleted
-1
@@ -1 +0,0 @@
1 -multiaddr
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/multiaddr/multiaddr.go deleted
-96
@@ -1,96 +0,0 @@
1 -package main
2 -
3 -import (
4 - "encoding/hex"
5 - "flag"
6 - "fmt"
7 - "os"
8 -
9 - manet "gx/ipfs/QmQB7mNP3QE7b4zP2MQmsyJDqG5hzYE2CL8k1VyLWky2Ed/go-multiaddr-net"
10 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
11 -)
12 -
13 -// flags
14 -var formats = []string{"string", "bytes", "hex", "slice"}
15 -var format string
16 -var hideLoopback bool
17 -
18 -func init() {
19 - flag.Usage = func() {
20 - fmt.Fprintf(os.Stderr, "usage: %s [<multiaddr>]\n\nFlags:\n", os.Args[0])
21 - flag.PrintDefaults()
22 - }
23 -
24 - usage := fmt.Sprintf("output format, one of: %v", formats)
25 - flag.StringVar(&format, "format", "string", usage)
26 - flag.StringVar(&format, "f", "string", usage+" (shorthand)")
27 - flag.BoolVar(&hideLoopback, "hide-loopback", false, "do not display loopback addresses")
28 -}
29 -
30 -func main() {
31 - flag.Parse()
32 - args := flag.Args()
33 - if len(args) == 0 {
34 - output(localAddresses()...)
35 - } else {
36 - output(address(args[0]))
37 - }
38 -}
39 -
40 -func localAddresses() []ma.Multiaddr {
41 - maddrs, err := manet.InterfaceMultiaddrs()
42 - if err != nil {
43 - die(err)
44 - }
45 -
46 - if !hideLoopback {
47 - return maddrs
48 - }
49 -
50 - var maddrs2 []ma.Multiaddr
51 - for _, a := range maddrs {
52 - if !manet.IsIPLoopback(a) {
53 - maddrs2 = append(maddrs2, a)
54 - }
55 - }
56 -
57 - return maddrs2
58 -}
59 -
60 -func address(addr string) ma.Multiaddr {
61 - m, err := ma.NewMultiaddr(addr)
62 - if err != nil {
63 - die(err)
64 - }
65 -
66 - return m
67 -}
68 -
69 -func output(ms ...ma.Multiaddr) {
70 - for _, m := range ms {
71 - fmt.Println(outfmt(m))
72 - }
73 -}
74 -
75 -func outfmt(m ma.Multiaddr) string {
76 - switch format {
77 - case "string":
78 - return m.String()
79 - case "slice":
80 - return fmt.Sprintf("%v", m.Bytes())
81 - case "bytes":
82 - return string(m.Bytes())
83 - case "hex":
84 - return "0x" + hex.EncodeToString(m.Bytes())
85 - }
86 -
87 - die("error: invalid format", format)
88 - return ""
89 -}
90 -
91 -func die(v ...interface{}) {
92 - fmt.Fprint(os.Stderr, v...)
93 - fmt.Fprint(os.Stderr, "\n")
94 - flag.Usage()
95 - os.Exit(-1)
96 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/net.go deleted
-298
@@ -1,298 +0,0 @@
1 -package manet
2 -
3 -import (
4 - "fmt"
5 - "net"
6 -
7 - mautp "gx/ipfs/QmQB7mNP3QE7b4zP2MQmsyJDqG5hzYE2CL8k1VyLWky2Ed/go-multiaddr-net/utp"
8 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
9 -)
10 -
11 -// Conn is the equivalent of a net.Conn object. It is the
12 -// result of calling the Dial or Listen functions in this
13 -// package, with associated local and remote Multiaddrs.
14 -type Conn interface {
15 - net.Conn
16 -
17 - // LocalMultiaddr returns the local Multiaddr associated
18 - // with this connection
19 - LocalMultiaddr() ma.Multiaddr
20 -
21 - // RemoteMultiaddr returns the remote Multiaddr associated
22 - // with this connection
23 - RemoteMultiaddr() ma.Multiaddr
24 -}
25 -
26 -// WrapNetConn wraps a net.Conn object with a Multiaddr
27 -// friendly Conn.
28 -func WrapNetConn(nconn net.Conn) (Conn, error) {
29 - if nconn == nil {
30 - return nil, fmt.Errorf("failed to convert nconn.LocalAddr: nil")
31 - }
32 -
33 - laddr, err := FromNetAddr(nconn.LocalAddr())
34 - if err != nil {
35 - return nil, fmt.Errorf("failed to convert nconn.LocalAddr: %s", err)
36 - }
37 -
38 - raddr, err := FromNetAddr(nconn.RemoteAddr())
39 - if err != nil {
40 - return nil, fmt.Errorf("failed to convert nconn.RemoteAddr: %s", err)
41 - }
42 -
43 - return &maConn{
44 - Conn: nconn,
45 - laddr: laddr,
46 - raddr: raddr,
47 - }, nil
48 -}
49 -
50 -// maConn implements the Conn interface. It's a thin wrapper
51 -// around a net.Conn
52 -type maConn struct {
53 - net.Conn
54 - laddr ma.Multiaddr
55 - raddr ma.Multiaddr
56 -}
57 -
58 -// LocalMultiaddr returns the local address associated with
59 -// this connection
60 -func (c *maConn) LocalMultiaddr() ma.Multiaddr {
61 - return c.laddr
62 -}
63 -
64 -// RemoteMultiaddr returns the remote address associated with
65 -// this connection
66 -func (c *maConn) RemoteMultiaddr() ma.Multiaddr {
67 - return c.raddr
68 -}
69 -
70 -// Dialer contains options for connecting to an address. It
71 -// is effectively the same as net.Dialer, but its LocalAddr
72 -// and RemoteAddr options are Multiaddrs, instead of net.Addrs.
73 -type Dialer struct {
74 -
75 - // Dialer is just an embedded net.Dialer, with all its options.
76 - net.Dialer
77 -
78 - // LocalAddr is the local address to use when dialing an
79 - // address. The address must be of a compatible type for the
80 - // network being dialed.
81 - // If nil, a local address is automatically chosen.
82 - LocalAddr ma.Multiaddr
83 -}
84 -
85 -// Dial connects to a remote address, using the options of the
86 -// Dialer. Dialer uses an underlying net.Dialer to Dial a
87 -// net.Conn, then wraps that in a Conn object (with local and
88 -// remote Multiaddrs).
89 -func (d *Dialer) Dial(remote ma.Multiaddr) (Conn, error) {
90 -
91 - // if a LocalAddr is specified, use it on the embedded dialer.
92 - if d.LocalAddr != nil {
93 - // convert our multiaddr to net.Addr friendly
94 - naddr, err := ToNetAddr(d.LocalAddr)
95 - if err != nil {
96 - return nil, err
97 - }
98 -
99 - // set the dialer's LocalAddr as naddr
100 - d.Dialer.LocalAddr = naddr
101 - }
102 -
103 - // get the net.Dial friendly arguments from the remote addr
104 - rnet, rnaddr, err := DialArgs(remote)
105 - if err != nil {
106 - return nil, err
107 - }
108 -
109 - // ok, Dial!
110 - var nconn net.Conn
111 - switch rnet {
112 - case "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6":
113 - nconn, err = d.Dialer.Dial(rnet, rnaddr)
114 - if err != nil {
115 - return nil, err
116 - }
117 - case "utp", "utp4", "utp6":
118 - utpd := mautp.Dialer{
119 - Timeout: d.Timeout,
120 - LocalAddr: d.Dialer.LocalAddr,
121 - }
122 - // construct utp dialer, with options on our net.Dialer
123 - nconn, err = utpd.Dial(rnet, rnaddr)
124 - if err != nil {
125 - return nil, err
126 - }
127 - }
128 -
129 - // get local address (pre-specified or assigned within net.Conn)
130 - local := d.LocalAddr
131 - if local == nil {
132 - local, err = FromNetAddr(nconn.LocalAddr())
133 - if err != nil {
134 - return nil, err
135 - }
136 - }
137 -
138 - return &maConn{
139 - Conn: nconn,
140 - laddr: local,
141 - raddr: remote,
142 - }, nil
143 -}
144 -
145 -// Dial connects to a remote address. It uses an underlying net.Conn,
146 -// then wraps it in a Conn object (with local and remote Multiaddrs).
147 -func Dial(remote ma.Multiaddr) (Conn, error) {
148 - return (&Dialer{}).Dial(remote)
149 -}
150 -
151 -// A Listener is a generic network listener for stream-oriented protocols.
152 -// it uses an embedded net.Listener, overriding net.Listener.Accept to
153 -// return a Conn and providing Multiaddr.
154 -type Listener interface {
155 -
156 - // NetListener returns the embedded net.Listener. Use with caution.
157 - NetListener() net.Listener
158 -
159 - // Accept waits for and returns the next connection to the listener.
160 - // Returns a Multiaddr friendly Conn
161 - Accept() (Conn, error)
162 -
163 - // Close closes the listener.
164 - // Any blocked Accept operations will be unblocked and return errors.
165 - Close() error
166 -
167 - // Multiaddr returns the listener's (local) Multiaddr.
168 - Multiaddr() ma.Multiaddr
169 -
170 - // Addr returns the net.Listener's network address.
171 - Addr() net.Addr
172 -}
173 -
174 -// maListener implements Listener
175 -type maListener struct {
176 - net.Listener
177 - laddr ma.Multiaddr
178 -}
179 -
180 -// NetListener returns the embedded net.Listener. Use with caution.
181 -func (l *maListener) NetListener() net.Listener {
182 - return l.Listener
183 -}
184 -
185 -// Accept waits for and returns the next connection to the listener.
186 -// Returns a Multiaddr friendly Conn
187 -func (l *maListener) Accept() (Conn, error) {
188 - nconn, err := l.Listener.Accept()
189 - if err != nil {
190 - return nil, err
191 - }
192 -
193 - raddr, err := FromNetAddr(nconn.RemoteAddr())
194 - if err != nil {
195 - return nil, fmt.Errorf("failed to convert connn.RemoteAddr: %s", err)
196 - }
197 -
198 - return &maConn{
199 - Conn: nconn,
200 - laddr: l.laddr,
201 - raddr: raddr,
202 - }, nil
203 -}
204 -
205 -// Multiaddr returns the listener's (local) Multiaddr.
206 -func (l *maListener) Multiaddr() ma.Multiaddr {
207 - return l.laddr
208 -}
209 -
210 -// Addr returns the listener's network address.
211 -func (l *maListener) Addr() net.Addr {
212 - return l.Listener.Addr()
213 -}
214 -
215 -// Listen announces on the local network address laddr.
216 -// The Multiaddr must be a "ThinWaist" stream-oriented network:
217 -// ip4/tcp, ip6/tcp, (TODO: unix, unixpacket)
218 -// See Dial for the syntax of laddr.
219 -func Listen(laddr ma.Multiaddr) (Listener, error) {
220 -
221 - // get the net.Listen friendly arguments from the remote addr
222 - lnet, lnaddr, err := DialArgs(laddr)
223 - if err != nil {
224 - return nil, err
225 - }
226 -
227 - var nl net.Listener
228 - switch lnet {
229 - case "utp", "utp4", "utp6":
230 - nl, err = mautp.Listen(lnet, lnaddr)
231 - default:
232 - nl, err = net.Listen(lnet, lnaddr)
233 - }
234 - if err != nil {
235 - return nil, err
236 - }
237 -
238 - // we want to fetch the new multiaddr from the listener, as it may
239 - // have resolved to some other value. WrapNetListener does it for us.
240 - return WrapNetListener(nl)
241 -}
242 -
243 -// WrapNetListener wraps a net.Listener with a manet.Listener.
244 -func WrapNetListener(nl net.Listener) (Listener, error) {
245 - laddr, err := FromNetAddr(nl.Addr())
246 - if err != nil {
247 - return nil, err
248 - }
249 -
250 - return &maListener{
251 - Listener: nl,
252 - laddr: laddr,
253 - }, nil
254 -}
255 -
256 -// InterfaceMultiaddrs will return the addresses matching net.InterfaceAddrs
257 -func InterfaceMultiaddrs() ([]ma.Multiaddr, error) {
258 - addrs, err := net.InterfaceAddrs()
259 - if err != nil {
260 - return nil, err
261 - }
262 -
263 - maddrs := make([]ma.Multiaddr, len(addrs))
264 - for i, a := range addrs {
265 - maddrs[i], err = FromNetAddr(a)
266 - if err != nil {
267 - return nil, err
268 - }
269 - }
270 - return maddrs, nil
271 -}
272 -
273 -// AddrMatch returns the Multiaddrs that match the protocol stack on addr
274 -func AddrMatch(match ma.Multiaddr, addrs []ma.Multiaddr) []ma.Multiaddr {
275 -
276 - // we should match transports entirely.
277 - p1s := match.Protocols()
278 -
279 - out := make([]ma.Multiaddr, 0, len(addrs))
280 - for _, a := range addrs {
281 - p2s := a.Protocols()
282 - if len(p1s) != len(p2s) {
283 - continue
284 - }
285 -
286 - match := true
287 - for i, p2 := range p2s {
288 - if p1s[i].Code != p2.Code {
289 - match = false
290 - break
291 - }
292 - }
293 - if match {
294 - out = append(out, a)
295 - }
296 - }
297 - return out
298 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/net_test.go deleted
-507
@@ -1,507 +0,0 @@
1 -package manet
2 -
3 -import (
4 - "bytes"
5 - "fmt"
6 - "net"
7 - "sync"
8 - "testing"
9 -
10 - ma "gx/ipfs/QmcobAGsCjYt5DXoq9et9L8yR8er7o7Cu3DTvpaq12jYSz/go-multiaddr"
11 -)
12 -
13 -func newMultiaddr(t *testing.T, m string) ma.Multiaddr {
14 - maddr, err := ma.NewMultiaddr(m)
15 - if err != nil {
16 - t.Fatal("failed to construct multiaddr:", m, err)
17 - }
18 - return maddr
19 -}
20 -
21 -func TestDial(t *testing.T) {
22 -
23 - listener, err := net.Listen("tcp", "127.0.0.1:4321")
24 - if err != nil {
25 - t.Fatal("failed to listen")
26 - }
27 -
28 - var wg sync.WaitGroup
29 - wg.Add(1)
30 - go func() {
31 -
32 - cB, err := listener.Accept()
33 - if err != nil {
34 - t.Fatal("failed to accept")
35 - }
36 -
37 - // echo out
38 - buf := make([]byte, 1024)
39 - for {
40 - _, err := cB.Read(buf)
41 - if err != nil {
42 - break
43 - }
44 - cB.Write(buf)
45 - }
46 -
47 - wg.Done()
48 - }()
49 -
50 - maddr := newMultiaddr(t, "/ip4/127.0.0.1/tcp/4321")
51 - cA, err := Dial(maddr)
52 - if err != nil {
53 - t.Fatal("failed to dial")
54 - }
55 -
56 - buf := make([]byte, 1024)
57 - if _, err := cA.Write([]byte("beep boop")); err != nil {
58 - t.Fatal("failed to write:", err)
59 - }
60 -
61 - if _, err := cA.Read(buf); err != nil {
62 - t.Fatal("failed to read:", buf, err)
63 - }
64 -
65 - if !bytes.Equal(buf[:9], []byte("beep boop")) {
66 - t.Fatal("failed to echo:", buf)
67 - }
68 -
69 - maddr2 := cA.RemoteMultiaddr()
70 - if !maddr2.Equal(maddr) {
71 - t.Fatal("remote multiaddr not equal:", maddr, maddr2)
72 - }
73 -
74 - cA.Close()
75 - wg.Wait()
76 -}
77 -
78 -func TestListen(t *testing.T) {
79 -
80 - maddr := newMultiaddr(t, "/ip4/127.0.0.1/tcp/4322")
81 - listener, err := Listen(maddr)
82 - if err != nil {
83 - t.Fatal("failed to listen")
84 - }
85 -
86 - var wg sync.WaitGroup
87 - wg.Add(1)
88 - go func() {
89 -
90 - cB, err := listener.Accept()
91 - if err != nil {
92 - t.Fatal("failed to accept")
93 - }
94 -
95 - if !cB.LocalMultiaddr().Equal(maddr) {
96 - t.Fatal("local multiaddr not equal:", maddr, cB.LocalMultiaddr())
97 - }
98 -
99 - // echo out
100 - buf := make([]byte, 1024)
101 - for {
102 - _, err := cB.Read(buf)
103 - if err != nil {
104 - break
105 - }
106 - cB.Write(buf)
107 - }
108 -
109 - wg.Done()
110 - }()
111 -
112 - cA, err := net.Dial("tcp", "127.0.0.1:4322")
113 - if err != nil {
114 - t.Fatal("failed to dial")
115 - }
116 -
117 - buf := make([]byte, 1024)
118 - if _, err := cA.Write([]byte("beep boop")); err != nil {
119 - t.Fatal("failed to write:", err)
120 - }
121 -
122 - if _, err := cA.Read(buf); err != nil {
123 - t.Fatal("failed to read:", buf, err)
124 - }
125 -
126 - if !bytes.Equal(buf[:9], []byte("beep boop")) {
127 - t.Fatal("failed to echo:", buf)
128 - }
129 -
130 - maddr2, err := FromNetAddr(cA.RemoteAddr())
131 - if err != nil {
132 - t.Fatal("failed to convert", err)
133 - }
134 - if !maddr2.Equal(maddr) {
135 - t.Fatal("remote multiaddr not equal:", maddr, maddr2)
136 - }
137 -
138 - cA.Close()
139 - wg.Wait()
140 -}
141 -
142 -func TestListenAddrs(t *testing.T) {
143 -
144 - test := func(addr, resaddr string, succeed bool) {
145 - if resaddr == "" {
146 - resaddr = addr
147 - }
148 -
149 - maddr := newMultiaddr(t, addr)
150 - l, err := Listen(maddr)
151 - if !succeed {
152 - if err == nil {
153 - t.Fatal("succeeded in listening", addr)
154 - }
155 - return
156 - }
157 - if succeed && err != nil {
158 - t.Error("failed to listen", addr, err)
159 - }
160 - if l == nil {
161 - t.Error("failed to listen", addr, succeed, err)
162 - }
163 - if l.Multiaddr().String() != resaddr {
164 - t.Error("listen addr did not resolve properly", l.Multiaddr().String(), resaddr, succeed, err)
165 - }
166 -
167 - if err = l.Close(); err != nil {
168 - t.Fatal("failed to close listener", addr, err)
169 - }
170 - }
171 -
172 - test("/ip4/127.0.0.1/tcp/4324", "", true)
173 - test("/ip4/127.0.0.1/udp/4325", "", false)
174 - test("/ip4/127.0.0.1/udp/4326/udt", "", false)
175 - test("/ip4/0.0.0.0/tcp/4324", "", true)
176 - test("/ip4/0.0.0.0/udp/4325", "", false)
177 - test("/ip4/0.0.0.0/udp/4326/udt", "", false)
178 - test("/ip6/::1/tcp/4324", "", true)
179 - test("/ip6/::1/udp/4325", "", false)
180 - test("/ip6/::1/udp/4326/udt", "", false)
181 - test("/ip6/::/tcp/4324", "", true)
182 - test("/ip6/::/udp/4325", "", false)
183 - test("/ip6/::/udp/4326/udt", "", false)
184 - // test("/ip4/127.0.0.1/udp/4326/utp", true)
185 -}
186 -
187 -func TestListenAndDial(t *testing.T) {
188 -
189 - maddr := newMultiaddr(t, "/ip4/127.0.0.1/tcp/4323")
190 - listener, err := Listen(maddr)
191 - if err != nil {
192 - t.Fatal("failed to listen")
193 - }
194 -
195 - var wg sync.WaitGroup
196 - wg.Add(1)
197 - go func() {
198 -
199 - cB, err := listener.Accept()
200 - if err != nil {
201 - t.Fatal("failed to accept")
202 - }
203 -
204 - if !cB.LocalMultiaddr().Equal(maddr) {
205 - t.Fatal("local multiaddr not equal:", maddr, cB.LocalMultiaddr())
206 - }
207 -
208 - // echo out
209 - buf := make([]byte, 1024)
210 - for {
211 - _, err := cB.Read(buf)
212 - if err != nil {
213 - break
214 - }
215 - cB.Write(buf)
216 - }
217 -
218 - wg.Done()
219 - }()
220 -
221 - cA, err := Dial(newMultiaddr(t, "/ip4/127.0.0.1/tcp/4323"))
222 - if err != nil {
223 - t.Fatal("failed to dial")
224 - }
225 -
226 - buf := make([]byte, 1024)
227 - if _, err := cA.Write([]byte("beep boop")); err != nil {
228 - t.Fatal("failed to write:", err)
229 - }
230 -
231 - if _, err := cA.Read(buf); err != nil {
232 - t.Fatal("failed to read:", buf, err)
233 - }
234 -
235 - if !bytes.Equal(buf[:9], []byte("beep boop")) {
236 - t.Fatal("failed to echo:", buf)
237 - }
238 -
239 - maddr2 := cA.RemoteMultiaddr()
240 - if !maddr2.Equal(maddr) {
241 - t.Fatal("remote multiaddr not equal:", maddr, maddr2)
242 - }
243 -
244 - cA.Close()
245 - wg.Wait()
246 -}
247 -
248 -func TestListenAndDialUTP(t *testing.T) {
249 - maddr := newMultiaddr(t, "/ip4/127.0.0.1/udp/4323/utp")
250 - listener, err := Listen(maddr)
251 - if err != nil {
252 - t.Fatal("failed to listen: ", err)
253 - }
254 -
255 - var wg sync.WaitGroup
256 - wg.Add(1)
257 - go func() {
258 -
259 - cB, err := listener.Accept()
260 - if err != nil {
261 - t.Fatal("failed to accept")
262 - }
263 -
264 - if !cB.LocalMultiaddr().Equal(maddr) {
265 - t.Fatal("local multiaddr not equal:", maddr, cB.LocalMultiaddr())
266 - }
267 -
268 - defer cB.Close()
269 -
270 - // echo out
271 - buf := make([]byte, 1024)
272 - for {
273 - _, err := cB.Read(buf)
274 - if err != nil {
275 - break
276 - }
277 - cB.Write(buf)
278 - }
279 -
280 - wg.Done()
281 - }()
282 -
283 - cA, err := Dial(newMultiaddr(t, "/ip4/127.0.0.1/udp/4323/utp"))
284 - if err != nil {
285 - t.Fatal("failed to dial", err)
286 - }
287 -
288 - buf := make([]byte, 1024)
289 - if _, err := cA.Write([]byte("beep boop")); err != nil {
290 - t.Fatal("failed to write:", err)
291 - }
292 -
293 - if _, err := cA.Read(buf); err != nil {
294 - t.Fatal("failed to read:", buf, err)
295 - }
296 -
297 - if !bytes.Equal(buf[:9], []byte("beep boop")) {
298 - t.Fatal("failed to echo:", buf)
299 - }
300 -
301 - maddr2 := cA.RemoteMultiaddr()
302 - if !maddr2.Equal(maddr) {
303 - t.Fatal("remote multiaddr not equal:", maddr, maddr2)
304 - }
305 -
306 - cA.Close()
307 - wg.Wait()
308 -}
309 -
310 -func TestIPLoopback(t *testing.T) {
311 - if IP4Loopback.String() != "/ip4/127.0.0.1" {
312 - t.Error("IP4Loopback incorrect:", IP4Loopback)
313 - }
314 -
315 - if IP6Loopback.String() != "/ip6/::1" {
316 - t.Error("IP6Loopback incorrect:", IP6Loopback)
317 - }
318 -
319 - if IP6LinkLocalLoopback.String() != "/ip6/fe80::1" {
320 - t.Error("IP6LinkLocalLoopback incorrect:", IP6Loopback)
321 - }
322 -
323 - if !IsIPLoopback(IP4Loopback) {
324 - t.Error("IsIPLoopback failed (IP4Loopback)")
325 - }
326 -
327 - if !IsIPLoopback(IP6Loopback) {
328 - t.Error("IsIPLoopback failed (IP6Loopback)")
329 - }
330 -
331 - if !IsIPLoopback(IP6LinkLocalLoopback) {
332 - t.Error("IsIPLoopback failed (IP6LinkLocalLoopback)")
333 - }
334 -}
335 -
336 -func TestIPUnspecified(t *testing.T) {
337 - if IP4Unspecified.String() != "/ip4/0.0.0.0" {
338 - t.Error("IP4Unspecified incorrect:", IP4Unspecified)
339 - }
340 -
341 - if IP6Unspecified.String() != "/ip6/::" {
342 - t.Error("IP6Unspecified incorrect:", IP6Unspecified)
343 - }
344 -
345 - if !IsIPUnspecified(IP4Unspecified) {
346 - t.Error("IsIPUnspecified failed (IP4Unspecified)")
347 - }
348 -
349 - if !IsIPUnspecified(IP6Unspecified) {
350 - t.Error("IsIPUnspecified failed (IP6Unspecified)")
351 - }
352 -}
353 -
354 -func TestIP6LinkLocal(t *testing.T) {
355 - if !IsIP6LinkLocal(IP6LinkLocalLoopback) {
356 - t.Error("IsIP6LinkLocal failed (IP6LinkLocalLoopback)")
357 - }
358 -
359 - for a := 0; a < 65536; a++ {
360 - isLinkLocal := (a == 0xfe80)
361 - m := newMultiaddr(t, fmt.Sprintf("/ip6/%x::1", a))
362 - if IsIP6LinkLocal(m) != isLinkLocal {
363 - t.Error("IsIP6LinkLocal failed (%s != %v)", m, isLinkLocal)
364 - }
365 - }
366 -}
367 -
368 -func TestConvertNetAddr(t *testing.T) {
369 - m1 := newMultiaddr(t, "/ip4/1.2.3.4/tcp/4001")
370 -
371 - n1, err := ToNetAddr(m1)
372 - if err != nil {
373 - t.Fatal(err)
374 - }
375 -
376 - m2, err := FromNetAddr(n1)
377 - if err != nil {
378 - t.Fatal(err)
379 - }
380 -
381 - if m1.String() != m2.String() {
382 - t.Fatal("ToNetAddr + FromNetAddr did not work")
383 - }
384 -}
385 -
386 -func TestWrapNetConn(t *testing.T) {
387 - // test WrapNetConn nil
388 - if _, err := WrapNetConn(nil); err == nil {
389 - t.Error("WrapNetConn(nil) should return an error")
390 - }
391 -
392 - checkErr := func(err error, s string) {
393 - if err != nil {
394 - t.Fatal(s, err)
395 - }
396 - }
397 -
398 - listener, err := net.Listen("tcp", "127.0.0.1:0")
399 - checkErr(err, "failed to listen")
400 -
401 - var wg sync.WaitGroup
402 - defer wg.Wait()
403 - wg.Add(1)
404 - go func() {
405 - defer wg.Done()
406 - cB, err := listener.Accept()
407 - checkErr(err, "failed to accept")
408 - cB.Close()
409 - }()
410 -
411 - cA, err := net.Dial("tcp", listener.Addr().String())
412 - checkErr(err, "failed to dial")
413 - defer cA.Close()
414 -
415 - lmaddr, err := FromNetAddr(cA.LocalAddr())
416 - checkErr(err, "failed to get local addr")
417 - rmaddr, err := FromNetAddr(cA.RemoteAddr())
418 - checkErr(err, "failed to get remote addr")
419 -
420 - mcA, err := WrapNetConn(cA)
421 - checkErr(err, "failed to wrap conn")
422 -
423 - if mcA.LocalAddr().String() != cA.LocalAddr().String() {
424 - t.Error("wrapped conn local addr differs")
425 - }
426 - if mcA.RemoteAddr().String() != cA.RemoteAddr().String() {
427 - t.Error("wrapped conn remote addr differs")
428 - }
429 - if mcA.LocalMultiaddr().String() != lmaddr.String() {
430 - t.Error("wrapped conn local maddr differs")
431 - }
432 - if mcA.RemoteMultiaddr().String() != rmaddr.String() {
433 - t.Error("wrapped conn remote maddr differs")
434 - }
435 -}
436 -
437 -func TestAddrMatch(t *testing.T) {
438 -
439 - test := func(m ma.Multiaddr, input, expect []ma.Multiaddr) {
440 - actual := AddrMatch(m, input)
441 - testSliceEqual(t, expect, actual)
442 - }
443 -
444 - a := []ma.Multiaddr{
445 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234"),
446 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/2345"),
447 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234/tcp/2345"),
448 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234/tcp/2345"),
449 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234/udp/1234"),
450 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234/udp/1234"),
451 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234/ip6/::1"),
452 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234/ip6/::1"),
453 - newMultiaddr(t, "/ip6/::1/tcp/1234"),
454 - newMultiaddr(t, "/ip6/::1/tcp/2345"),
455 - newMultiaddr(t, "/ip6/::1/tcp/1234/tcp/2345"),
456 - newMultiaddr(t, "/ip6/::1/tcp/1234/tcp/2345"),
457 - newMultiaddr(t, "/ip6/::1/tcp/1234/udp/1234"),
458 - newMultiaddr(t, "/ip6/::1/tcp/1234/udp/1234"),
459 - newMultiaddr(t, "/ip6/::1/tcp/1234/ip6/::1"),
460 - newMultiaddr(t, "/ip6/::1/tcp/1234/ip6/::1"),
461 - }
462 -
463 - test(a[0], a, []ma.Multiaddr{
464 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234"),
465 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/2345"),
466 - })
467 - test(a[2], a, []ma.Multiaddr{
468 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234/tcp/2345"),
469 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234/tcp/2345"),
470 - })
471 - test(a[4], a, []ma.Multiaddr{
472 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234/udp/1234"),
473 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234/udp/1234"),
474 - })
475 - test(a[6], a, []ma.Multiaddr{
476 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234/ip6/::1"),
477 - newMultiaddr(t, "/ip4/1.2.3.4/tcp/1234/ip6/::1"),
478 - })
479 - test(a[8], a, []ma.Multiaddr{
480 - newMultiaddr(t, "/ip6/::1/tcp/1234"),
481 - newMultiaddr(t, "/ip6/::1/tcp/2345"),
482 - })
483 - test(a[10], a, []ma.Multiaddr{
484 - newMultiaddr(t, "/ip6/::1/tcp/1234/tcp/2345"),
485 - newMultiaddr(t, "/ip6/::1/tcp/1234/tcp/2345"),
486 - })
487 - test(a[12], a, []ma.Multiaddr{
488 - newMultiaddr(t, "/ip6/::1/tcp/1234/udp/1234"),
489 - newMultiaddr(t, "/ip6/::1/tcp/1234/udp/1234"),
490 - })
491 - test(a[14], a, []ma.Multiaddr{
492 - newMultiaddr(t, "/ip6/::1/tcp/1234/ip6/::1"),
493 - newMultiaddr(t, "/ip6/::1/tcp/1234/ip6/::1"),
494 - })
495 -
496 -}
497 -
498 -func testSliceEqual(t *testing.T, a, b []ma.Multiaddr) {
499 - if len(a) != len(b) {
500 - t.Error("differ", a, b)
501 - }
502 - for i, addrA := range a {
503 - if !addrA.Equal(b[i]) {
504 - t.Error("differ", a, b)
505 - }
506 - }
507 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net/utp/utp_util.go deleted
-105
@@ -1,105 +0,0 @@
1 -package utp
2 -
3 -import (
4 - "errors"
5 - "net"
6 - "time"
7 -
8 - utp "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/anacrolix/utp"
9 -)
10 -
11 -type Listener struct {
12 - *utp.Socket
13 -}
14 -
15 -type Conn struct {
16 - net.Conn
17 -}
18 -
19 -type Addr struct {
20 - net string
21 - child net.Addr
22 -}
23 -
24 -func (ca *Addr) Network() string {
25 - return ca.net
26 -}
27 -
28 -func (ca *Addr) String() string {
29 - return ca.child.String()
30 -}
31 -
32 -func (ca *Addr) Child() net.Addr {
33 - return ca.child
34 -}
35 -
36 -func MakeAddr(a net.Addr) net.Addr {
37 - return &Addr{
38 - net: "utp",
39 - child: a,
40 - }
41 -}
42 -
43 -func ResolveAddr(network string, host string) (net.Addr, error) {
44 - a, err := net.ResolveUDPAddr("udp"+network[3:], host)
45 - if err != nil {
46 - return nil, err
47 - }
48 -
49 - return MakeAddr(a), nil
50 -}
51 -
52 -func (u *Conn) LocalAddr() net.Addr {
53 - return MakeAddr(u.Conn.LocalAddr())
54 -}
55 -
56 -func (u *Conn) RemoteAddr() net.Addr {
57 - return MakeAddr(u.Conn.RemoteAddr())
58 -}
59 -
60 -func Listen(network string, laddr string) (net.Listener, error) {
61 - switch network {
62 - case "utp", "utp4", "utp6":
63 - s, err := utp.NewSocket("udp"+network[3:], laddr)
64 - if err != nil {
65 - return nil, err
66 - }
67 -
68 - return &Listener{s}, nil
69 -
70 - default:
71 - return nil, errors.New("unrecognized network: " + network)
72 - }
73 -}
74 -
75 -func (u *Listener) Accept() (net.Conn, error) {
76 - c, err := u.Socket.Accept()
77 - if err != nil {
78 - return nil, err
79 - }
80 -
81 - return &Conn{c}, nil
82 -}
83 -
84 -func (u *Listener) Addr() net.Addr {
85 - return MakeAddr(u.Socket.Addr())
86 -}
87 -
88 -type Dialer struct {
89 - Timeout time.Duration
90 - LocalAddr net.Addr
91 -}
92 -
93 -func (d *Dialer) Dial(rnet string, raddr string) (net.Conn, error) {
94 - if d.LocalAddr != nil {
95 - s, err := utp.NewSocket(d.LocalAddr.Network(), d.LocalAddr.String())
96 - if err != nil {
97 - return nil, err
98 - }
99 -
100 - // zero timeout is the same as calling s.Dial()
101 - return s.DialTimeout(raddr, d.Timeout)
102 - }
103 -
104 - return utp.DialTimeout(raddr, d.Timeout)
105 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/.travis.yml deleted
-9
@@ -1,9 +0,0 @@
1 -language: go
2 -
3 -go:
4 - - 1.3
5 - - release
6 - - tip
7 -
8 -script:
9 - - go test -race -cpu=5 -v ./...
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/LICENSE deleted
-21
@@ -1,21 +0,0 @@
1 -The MIT License (MIT)
2 -
3 -Copyright (c) 2014 Juan Batiz-Benet
4 -
5 -Permission is hereby granted, free of charge, to any person obtaining a copy
6 -of this software and associated documentation files (the "Software"), to deal
7 -in the Software without restriction, including without limitation the rights
8 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 -copies of the Software, and to permit persons to whom the Software is
10 -furnished to do so, subject to the following conditions:
11 -
12 -The above copyright notice and this permission notice shall be included in
13 -all copies or substantial portions of the Software.
14 -
15 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 -THE SOFTWARE.
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/README.md deleted
-58
@@ -1,58 +0,0 @@
1 -# go-multiaddr
2 -
3 -[multiaddr](https://github.com/jbenet/multiaddr) implementation in Go.
4 -
5 -## Example
6 -
7 -### Simple
8 -
9 -```go
10 -import ma "github.com/jbenet/go-multiaddr"
11 -
12 -// construct from a string (err signals parse failure)
13 -m1, err := ma.NewMultiaddr("/ip4/127.0.0.1/udp/1234")
14 -
15 -// construct from bytes (err signals parse failure)
16 -m2, err := ma.NewMultiaddrBytes(m1.Bytes())
17 -
18 -// true
19 -strings.Equal(m1.String(), "/ip4/127.0.0.1/udp/1234")
20 -strings.Equal(m1.String(), m2.String())
21 -bytes.Equal(m1.Bytes(), m2.Bytes())
22 -m1.Equal(m2)
23 -m2.Equal(m1)
24 -```
25 -
26 -### Protocols
27 -
28 -```go
29 -// get the multiaddr protocol description objects
30 -addr.Protocols()
31 -// []Protocol{
32 -// Protocol{ Code: 4, Name: 'ip4', Size: 32},
33 -// Protocol{ Code: 17, Name: 'udp', Size: 16},
34 -// }
35 -```
36 -
37 -### En/decapsulate
38 -
39 -```go
40 -m.Encapsulate(ma.NewMultiaddr("/sctp/5678"))
41 -// <Multiaddr /ip4/127.0.0.1/udp/1234/sctp/5678>
42 -m.Decapsulate(ma.NewMultiaddr("/udp")) // up to + inc last occurrence of subaddr
43 -// <Multiaddr /ip4/127.0.0.1>
44 -```
45 -
46 -### Tunneling
47 -
48 -Multiaddr allows expressing tunnels very nicely.
49 -
50 -```js
51 -printer, _ := ma.NewMultiaddr("/ip4/192.168.0.13/tcp/80")
52 -proxy, _ := ma.NewMultiaddr("/ip4/10.20.30.40/tcp/443")
53 -printerOverProxy := proxy.Encapsulate(printer)
54 -// /ip4/10.20.30.40/tcp/443/ip4/192.168.0.13/tcp/80
55 -
56 -proxyAgain := printerOverProxy.Decapsulate(printer)
57 -// /ip4/10.20.30.40/tcp/443
58 -```
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/codec.go deleted
-209
@@ -1,209 +0,0 @@
1 -package multiaddr
2 -
3 -import (
4 - "encoding/binary"
5 - "errors"
6 - "fmt"
7 - "net"
8 - "strconv"
9 - "strings"
10 -
11 - mh "gx/ipfs/QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku/go-multihash"
12 -)
13 -
14 -func stringToBytes(s string) ([]byte, error) {
15 -
16 - // consume trailing slashes
17 - s = strings.TrimRight(s, "/")
18 -
19 - b := []byte{}
20 - sp := strings.Split(s, "/")
21 -
22 - if sp[0] != "" {
23 - return nil, fmt.Errorf("invalid multiaddr, must begin with /")
24 - }
25 -
26 - // consume first empty elem
27 - sp = sp[1:]
28 -
29 - for len(sp) > 0 {
30 - p := ProtocolWithName(sp[0])
31 - if p.Code == 0 {
32 - return nil, fmt.Errorf("no protocol with name %s", sp[0])
33 - }
34 - b = append(b, CodeToVarint(p.Code)...)
35 - sp = sp[1:]
36 -
37 - if p.Size == 0 { // no length.
38 - continue
39 - }
40 -
41 - if len(sp) < 1 {
42 - return nil, fmt.Errorf("protocol requires address, none given: %s", p.Name)
43 - }
44 - a, err := addressStringToBytes(p, sp[0])
45 - if err != nil {
46 - return nil, fmt.Errorf("failed to parse %s: %s %s", p.Name, sp[0], err)
47 - }
48 - b = append(b, a...)
49 - sp = sp[1:]
50 - }
51 - return b, nil
52 -}
53 -
54 -func bytesToString(b []byte) (ret string, err error) {
55 - // panic handler, in case we try accessing bytes incorrectly.
56 - defer func() {
57 - if e := recover(); e != nil {
58 - ret = ""
59 - switch e := e.(type) {
60 - case error:
61 - err = e
62 - case string:
63 - err = errors.New(e)
64 - default:
65 - err = fmt.Errorf("%v", e)
66 - }
67 - }
68 - }()
69 -
70 - s := ""
71 -
72 - for len(b) > 0 {
73 -
74 - code, n := ReadVarintCode(b)
75 - b = b[n:]
76 - p := ProtocolWithCode(code)
77 - if p.Code == 0 {
78 - return "", fmt.Errorf("no protocol with code %d", code)
79 - }
80 - s += "/" + p.Name
81 -
82 - if p.Size == 0 {
83 - continue
84 - }
85 -
86 - size := sizeForAddr(p, b)
87 - a, err := addressBytesToString(p, b[:size])
88 - if err != nil {
89 - return "", err
90 - }
91 - if len(a) > 0 {
92 - s += "/" + a
93 - }
94 - b = b[size:]
95 - }
96 -
97 - return s, nil
98 -}
99 -
100 -func sizeForAddr(p Protocol, b []byte) int {
101 - switch {
102 - case p.Size > 0:
103 - return (p.Size / 8)
104 - case p.Size == 0:
105 - return 0
106 - default:
107 - size, n := ReadVarintCode(b)
108 - return size + n
109 - }
110 -}
111 -
112 -func bytesSplit(b []byte) (ret [][]byte, err error) {
113 - // panic handler, in case we try accessing bytes incorrectly.
114 - defer func() {
115 - if e := recover(); e != nil {
116 - ret = [][]byte{}
117 - err = e.(error)
118 - }
119 - }()
120 -
121 - ret = [][]byte{}
122 - for len(b) > 0 {
123 - code, n := ReadVarintCode(b)
124 - p := ProtocolWithCode(code)
125 - if p.Code == 0 {
126 - return [][]byte{}, fmt.Errorf("no protocol with code %d", b[0])
127 - }
128 -
129 - size := sizeForAddr(p, b[n:])
130 - length := n + size
131 - ret = append(ret, b[:length])
132 - b = b[length:]
133 - }
134 -
135 - return ret, nil
136 -}
137 -
138 -func addressStringToBytes(p Protocol, s string) ([]byte, error) {
139 - switch p.Code {
140 -
141 - case P_IP4: // ipv4
142 - i := net.ParseIP(s).To4()
143 - if i == nil {
144 - return nil, fmt.Errorf("failed to parse ip4 addr: %s", s)
145 - }
146 - return i, nil
147 -
148 - case P_IP6: // ipv6
149 - i := net.ParseIP(s).To16()
150 - if i == nil {
151 - return nil, fmt.Errorf("failed to parse ip6 addr: %s", s)
152 - }
153 - return i, nil
154 -
155 - // tcp udp dccp sctp
156 - case P_TCP, P_UDP, P_DCCP, P_SCTP:
157 - i, err := strconv.Atoi(s)
158 - if err != nil {
159 - return nil, fmt.Errorf("failed to parse %s addr: %s", p.Name, err)
160 - }
161 - if i >= 65536 {
162 - return nil, fmt.Errorf("failed to parse %s addr: %s", p.Name, "greater than 65536")
163 - }
164 - b := make([]byte, 2)
165 - binary.BigEndian.PutUint16(b, uint16(i))
166 - return b, nil
167 -
168 - case P_IPFS: // ipfs
169 - // the address is a varint prefixed multihash string representation
170 - m, err := mh.FromB58String(s)
171 - if err != nil {
172 - return nil, fmt.Errorf("failed to parse ipfs addr: %s %s", s, err)
173 - }
174 - size := CodeToVarint(len(m))
175 - b := append(size, m...)
176 - return b, nil
177 - }
178 -
179 - return []byte{}, fmt.Errorf("failed to parse %s addr: unknown", p.Name)
180 -}
181 -
182 -func addressBytesToString(p Protocol, b []byte) (string, error) {
183 - switch p.Code {
184 -
185 - // ipv4,6
186 - case P_IP4, P_IP6:
187 - return net.IP(b).String(), nil
188 -
189 - // tcp udp dccp sctp
190 - case P_TCP, P_UDP, P_DCCP, P_SCTP:
191 - i := binary.BigEndian.Uint16(b)
192 - return strconv.Itoa(int(i)), nil
193 -
194 - case P_IPFS: // ipfs
195 - // the address is a varint-prefixed multihash string representation
196 - size, n := ReadVarintCode(b)
197 - b = b[n:]
198 - if len(b) != size {
199 - panic("inconsistent lengths")
200 - }
201 - m, err := mh.Cast(b)
202 - if err != nil {
203 - return "", err
204 - }
205 - return m.B58String(), nil
206 - }
207 -
208 - return "", fmt.Errorf("unknown protocol")
209 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/doc.go deleted
-36
@@ -1,36 +0,0 @@
1 -/*
2 -Package multiaddr provides an implementation of the Multiaddr network
3 -address format. Multiaddr emphasizes explicitness, self-description, and
4 -portability. It allows applications to treat addresses as opaque tokens,
5 -and to avoid making assumptions about the address representation (e.g. length).
6 -Learn more at https://github.com/jbenet/multiaddr
7 -
8 -Basic Use:
9 -
10 - import (
11 - "bytes"
12 - "strings"
13 - ma "github.com/jbenet/go-multiaddr"
14 - )
15 -
16 - // construct from a string (err signals parse failure)
17 - m1, err := ma.NewMultiaddr("/ip4/127.0.0.1/udp/1234")
18 -
19 - // construct from bytes (err signals parse failure)
20 - m2, err := ma.NewMultiaddrBytes(m1.Bytes())
21 -
22 - // true
23 - strings.Equal(m1.String(), "/ip4/127.0.0.1/udp/1234")
24 - strings.Equal(m1.String(), m2.String())
25 - bytes.Equal(m1.Bytes(), m2.Bytes())
26 - m1.Equal(m2)
27 - m2.Equal(m1)
28 -
29 - // tunneling (en/decap)
30 - printer, _ := ma.NewMultiaddr("/ip4/192.168.0.13/tcp/80")
31 - proxy, _ := ma.NewMultiaddr("/ip4/10.20.30.40/tcp/443")
32 - printerOverProxy := proxy.Encapsulate(printer)
33 - proxyAgain := printerOverProxy.Decapsulate(printer)
34 -
35 -*/
36 -package multiaddr
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/interface.go deleted
-42
@@ -1,42 +0,0 @@
1 -package multiaddr
2 -
3 -/*
4 -Multiaddr is a cross-protocol, cross-platform format for representing
5 -internet addresses. It emphasizes explicitness and self-description.
6 -Learn more here: https://github.com/jbenet/multiaddr
7 -
8 -Multiaddrs have both a binary and string representation.
9 -
10 - import ma "github.com/jbenet/go-multiaddr"
11 -
12 - addr, err := ma.NewMultiaddr("/ip4/1.2.3.4/tcp/80")
13 - // err non-nil when parsing failed.
14 -
15 -*/
16 -type Multiaddr interface {
17 - // Equal returns whether two Multiaddrs are exactly equal
18 - Equal(Multiaddr) bool
19 -
20 - // Bytes returns the []byte representation of this Multiaddr
21 - Bytes() []byte
22 -
23 - // String returns the string representation of this Multiaddr
24 - // (may panic if internal state is corrupted)
25 - String() string
26 -
27 - // Protocols returns the list of Protocols this Multiaddr includes
28 - // will panic if protocol code incorrect (and bytes accessed incorrectly)
29 - Protocols() []Protocol
30 -
31 - // Encapsulate wraps this Multiaddr around another. For example:
32 - //
33 - // /ip4/1.2.3.4 encapsulate /tcp/80 = /ip4/1.2.3.4/tcp/80
34 - //
35 - Encapsulate(Multiaddr) Multiaddr
36 -
37 - // Decapsultate removes a Multiaddr wrapping. For example:
38 - //
39 - // /ip4/1.2.3.4/tcp/80 decapsulate /ip4/1.2.3.4 = /tcp/80
40 - //
41 - Decapsulate(Multiaddr) Multiaddr
42 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/multiaddr.go deleted
-115
@@ -1,115 +0,0 @@
1 -package multiaddr
2 -
3 -import (
4 - "bytes"
5 - "fmt"
6 - "strings"
7 -)
8 -
9 -// multiaddr is the data structure representing a Multiaddr
10 -type multiaddr struct {
11 - bytes []byte
12 -}
13 -
14 -// NewMultiaddr parses and validates an input string, returning a *Multiaddr
15 -func NewMultiaddr(s string) (Multiaddr, error) {
16 - b, err := stringToBytes(s)
17 - if err != nil {
18 - return nil, err
19 - }
20 - return &multiaddr{bytes: b}, nil
21 -}
22 -
23 -// NewMultiaddrBytes initializes a Multiaddr from a byte representation.
24 -// It validates it as an input string.
25 -func NewMultiaddrBytes(b []byte) (Multiaddr, error) {
26 - s, err := bytesToString(b)
27 - if err != nil {
28 - return nil, err
29 - }
30 - return NewMultiaddr(s)
31 -}
32 -
33 -// Equal tests whether two multiaddrs are equal
34 -func (m *multiaddr) Equal(m2 Multiaddr) bool {
35 - return bytes.Equal(m.bytes, m2.Bytes())
36 -}
37 -
38 -// Bytes returns the []byte representation of this Multiaddr
39 -func (m *multiaddr) Bytes() []byte {
40 - // consider returning copy to prevent changing underneath us?
41 - cpy := make([]byte, len(m.bytes))
42 - copy(cpy, m.bytes)
43 - return cpy
44 -}
45 -
46 -// String returns the string representation of a Multiaddr
47 -func (m *multiaddr) String() string {
48 - s, err := bytesToString(m.bytes)
49 - if err != nil {
50 - panic("multiaddr failed to convert back to string. corrupted?")
51 - }
52 - return s
53 -}
54 -
55 -// Protocols returns the list of protocols this Multiaddr has.
56 -// will panic in case we access bytes incorrectly.
57 -func (m *multiaddr) Protocols() []Protocol {
58 -
59 - // panic handler, in case we try accessing bytes incorrectly.
60 - defer func() {
61 - if e := recover(); e != nil {
62 - err := e.(error)
63 - panic("Multiaddr.Protocols error: " + err.Error())
64 - }
65 - }()
66 -
67 - size := 0
68 - ps := []Protocol{}
69 - b := m.bytes[:]
70 - for len(b) > 0 {
71 - code, n := ReadVarintCode(b)
72 - p := ProtocolWithCode(code)
73 - if p.Code == 0 {
74 - // this is a panic (and not returning err) because this should've been
75 - // caught on constructing the Multiaddr
76 - panic(fmt.Errorf("no protocol with code %d", b[0]))
77 - }
78 - ps = append(ps, p)
79 - b = b[n:]
80 -
81 - size = sizeForAddr(p, b)
82 - b = b[size:]
83 - }
84 - return ps
85 -}
86 -
87 -// Encapsulate wraps a given Multiaddr, returning the resulting joined Multiaddr
88 -func (m *multiaddr) Encapsulate(o Multiaddr) Multiaddr {
89 - mb := m.bytes
90 - ob := o.Bytes()
91 -
92 - b := make([]byte, len(mb)+len(ob))
93 - copy(b, mb)
94 - copy(b[len(mb):], ob)
95 - return &multiaddr{bytes: b}
96 -}
97 -
98 -// Decapsulate unwraps Multiaddr up until the given Multiaddr is found.
99 -func (m *multiaddr) Decapsulate(o Multiaddr) Multiaddr {
100 - s1 := m.String()
101 - s2 := o.String()
102 - i := strings.LastIndex(s1, s2)
103 - if i < 0 {
104 - // if multiaddr not contained, returns a copy.
105 - cpy := make([]byte, len(m.bytes))
106 - copy(cpy, m.bytes)
107 - return &multiaddr{bytes: cpy}
108 - }
109 -
110 - ma, err := NewMultiaddr(s1[:i])
111 - if err != nil {
112 - panic("Multiaddr.Decapsulate incorrect byte boundaries.")
113 - }
114 - return ma
115 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/multiaddr_test.go deleted
-294
@@ -1,294 +0,0 @@
1 -package multiaddr
2 -
3 -import (
4 - "bytes"
5 - "encoding/hex"
6 - "testing"
7 -)
8 -
9 -func newMultiaddr(t *testing.T, a string) Multiaddr {
10 - m, err := NewMultiaddr(a)
11 - if err != nil {
12 - t.Error(err)
13 - }
14 - return m
15 -}
16 -
17 -func TestConstructFails(t *testing.T) {
18 - cases := []string{
19 - "/ip4",
20 - "/ip4/::1",
21 - "/ip4/fdpsofodsajfdoisa",
22 - "/ip6",
23 - "/udp",
24 - "/tcp",
25 - "/sctp",
26 - "/udp/65536",
27 - "/tcp/65536",
28 - "/udp/1234/sctp",
29 - "/udp/1234/udt/1234",
30 - "/udp/1234/utp/1234",
31 - "/ip4/127.0.0.1/udp/jfodsajfidosajfoidsa",
32 - "/ip4/127.0.0.1/udp",
33 - "/ip4/127.0.0.1/tcp/jfodsajfidosajfoidsa",
34 - "/ip4/127.0.0.1/tcp",
35 - "/ip4/127.0.0.1/ipfs",
36 - "/ip4/127.0.0.1/ipfs/tcp",
37 - }
38 -
39 - for _, a := range cases {
40 - if _, err := NewMultiaddr(a); err == nil {
41 - t.Errorf("should have failed: %s - %s", a, err)
42 - }
43 - }
44 -}
45 -
46 -func TestConstructSucceeds(t *testing.T) {
47 - cases := []string{
48 - "/ip4/1.2.3.4",
49 - "/ip4/0.0.0.0",
50 - "/ip6/::1",
51 - "/ip6/2601:9:4f81:9700:803e:ca65:66e8:c21",
52 - "/udp/0",
53 - "/tcp/0",
54 - "/sctp/0",
55 - "/udp/1234",
56 - "/tcp/1234",
57 - "/sctp/1234",
58 - "/udp/65535",
59 - "/tcp/65535",
60 - "/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC",
61 - "/udp/1234/sctp/1234",
62 - "/udp/1234/udt",
63 - "/udp/1234/utp",
64 - "/tcp/1234/http",
65 - "/tcp/1234/https",
66 - "/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234",
67 - "/ip4/127.0.0.1/udp/1234",
68 - "/ip4/127.0.0.1/udp/0",
69 - "/ip4/127.0.0.1/tcp/1234",
70 - "/ip4/127.0.0.1/tcp/1234/",
71 - "/ip4/127.0.0.1/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC",
72 - "/ip4/127.0.0.1/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/tcp/1234",
73 - }
74 -
75 - for _, a := range cases {
76 - if _, err := NewMultiaddr(a); err != nil {
77 - t.Errorf("should have succeeded: %s -- %s", a, err)
78 - }
79 - }
80 -}
81 -
82 -func TestEqual(t *testing.T) {
83 - m1 := newMultiaddr(t, "/ip4/127.0.0.1/udp/1234")
84 - m2 := newMultiaddr(t, "/ip4/127.0.0.1/tcp/1234")
85 - m3 := newMultiaddr(t, "/ip4/127.0.0.1/tcp/1234")
86 - m4 := newMultiaddr(t, "/ip4/127.0.0.1/tcp/1234/")
87 -
88 - if m1.Equal(m2) {
89 - t.Error("should not be equal")
90 - }
91 -
92 - if m2.Equal(m1) {
93 - t.Error("should not be equal")
94 - }
95 -
96 - if !m2.Equal(m3) {
97 - t.Error("should be equal")
98 - }
99 -
100 - if !m3.Equal(m2) {
101 - t.Error("should be equal")
102 - }
103 -
104 - if !m1.Equal(m1) {
105 - t.Error("should be equal")
106 - }
107 -
108 - if !m2.Equal(m4) {
109 - t.Error("should be equal")
110 - }
111 -
112 - if !m4.Equal(m3) {
113 - t.Error("should be equal")
114 - }
115 -}
116 -
117 -func TestStringToBytes(t *testing.T) {
118 -
119 - testString := func(s string, h string) {
120 - b1, err := hex.DecodeString(h)
121 - if err != nil {
122 - t.Error("failed to decode hex", h)
123 - }
124 -
125 - b2, err := stringToBytes(s)
126 - if err != nil {
127 - t.Error("failed to convert", s)
128 - }
129 -
130 - if !bytes.Equal(b1, b2) {
131 - t.Error("failed to convert", s, "to", b1, "got", b2)
132 - }
133 - }
134 -
135 - testString("/ip4/127.0.0.1/udp/1234", "047f0000011104d2")
136 - testString("/ip4/127.0.0.1/tcp/4321", "047f0000010610e1")
137 - testString("/ip4/127.0.0.1/udp/1234/ip4/127.0.0.1/tcp/4321", "047f0000011104d2047f0000010610e1")
138 -}
139 -
140 -func TestBytesToString(t *testing.T) {
141 -
142 - testString := func(s1 string, h string) {
143 - b, err := hex.DecodeString(h)
144 - if err != nil {
145 - t.Error("failed to decode hex", h)
146 - }
147 -
148 - s2, err := bytesToString(b)
149 - if err != nil {
150 - t.Error("failed to convert", b)
151 - }
152 -
153 - if s1 != s2 {
154 - t.Error("failed to convert", b, "to", s1, "got", s2)
155 - }
156 - }
157 -
158 - testString("/ip4/127.0.0.1/udp/1234", "047f0000011104d2")
159 - testString("/ip4/127.0.0.1/tcp/4321", "047f0000010610e1")
160 - testString("/ip4/127.0.0.1/udp/1234/ip4/127.0.0.1/tcp/4321", "047f0000011104d2047f0000010610e1")
161 -}
162 -
163 -func TestBytesSplitAndJoin(t *testing.T) {
164 -
165 - testString := func(s string, res []string) {
166 - m, err := NewMultiaddr(s)
167 - if err != nil {
168 - t.Fatal("failed to convert", s, err)
169 - }
170 -
171 - split := Split(m)
172 - if len(split) != len(res) {
173 - t.Error("not enough split components", split)
174 - return
175 - }
176 -
177 - for i, a := range split {
178 - if a.String() != res[i] {
179 - t.Errorf("split component failed: %s != %s", a, res[i])
180 - }
181 - }
182 -
183 - joined := Join(split...)
184 - if !m.Equal(joined) {
185 - t.Errorf("joined components failed: %s != %s", m, joined)
186 - }
187 -
188 - // modifying underlying bytes is fine.
189 - m2 := m.(*multiaddr)
190 - for i := range m2.bytes {
191 - m2.bytes[i] = 0
192 - }
193 -
194 - for i, a := range split {
195 - if a.String() != res[i] {
196 - t.Errorf("split component failed: %s != %s", a, res[i])
197 - }
198 - }
199 - }
200 -
201 - testString("/ip4/1.2.3.4/udp/1234", []string{"/ip4/1.2.3.4", "/udp/1234"})
202 - testString("/ip4/1.2.3.4/tcp/1/ip4/2.3.4.5/udp/2",
203 - []string{"/ip4/1.2.3.4", "/tcp/1", "/ip4/2.3.4.5", "/udp/2"})
204 - testString("/ip4/1.2.3.4/utp/ip4/2.3.4.5/udp/2/udt",
205 - []string{"/ip4/1.2.3.4", "/utp", "/ip4/2.3.4.5", "/udp/2", "/udt"})
206 -}
207 -
208 -func TestProtocols(t *testing.T) {
209 - m, err := NewMultiaddr("/ip4/127.0.0.1/udp/1234")
210 - if err != nil {
211 - t.Error("failed to construct", "/ip4/127.0.0.1/udp/1234")
212 - }
213 -
214 - ps := m.Protocols()
215 - if ps[0].Code != ProtocolWithName("ip4").Code {
216 - t.Error(ps[0], ProtocolWithName("ip4"))
217 - t.Error("failed to get ip4 protocol")
218 - }
219 -
220 - if ps[1].Code != ProtocolWithName("udp").Code {
221 - t.Error(ps[1], ProtocolWithName("udp"))
222 - t.Error("failed to get udp protocol")
223 - }
224 -
225 -}
226 -
227 -func TestProtocolsWithString(t *testing.T) {
228 - pwn := ProtocolWithName
229 - good := map[string][]Protocol{
230 - "/ip4": []Protocol{pwn("ip4")},
231 - "/ip4/tcp": []Protocol{pwn("ip4"), pwn("tcp")},
232 - "ip4/tcp/udp/ip6": []Protocol{pwn("ip4"), pwn("tcp"), pwn("udp"), pwn("ip6")},
233 - "////////ip4/tcp": []Protocol{pwn("ip4"), pwn("tcp")},
234 - "ip4/udp/////////": []Protocol{pwn("ip4"), pwn("udp")},
235 - "////////ip4/tcp////////": []Protocol{pwn("ip4"), pwn("tcp")},
236 - }
237 -
238 - for s, ps1 := range good {
239 - ps2, err := ProtocolsWithString(s)
240 - if err != nil {
241 - t.Error("ProtocolsWithString(%s) should have succeeded", s)
242 - }
243 -
244 - for i, ps1p := range ps1 {
245 - ps2p := ps2[i]
246 - if ps1p.Code != ps2p.Code {
247 - t.Errorf("mismatch: %s != %s, %s", ps1p.Name, ps2p.Name, s)
248 - }
249 - }
250 - }
251 -
252 - bad := []string{
253 - "dsijafd", // bogus proto
254 - "/ip4/tcp/fidosafoidsa", // bogus proto
255 - "////////ip4/tcp/21432141/////////", // bogus proto
256 - "////////ip4///////tcp/////////", // empty protos in between
257 - }
258 -
259 - for _, s := range bad {
260 - if _, err := ProtocolsWithString(s); err == nil {
261 - t.Error("ProtocolsWithString(%s) should have failed", s)
262 - }
263 - }
264 -
265 -}
266 -
267 -func TestEncapsulate(t *testing.T) {
268 - m, err := NewMultiaddr("/ip4/127.0.0.1/udp/1234")
269 - if err != nil {
270 - t.Error(err)
271 - }
272 -
273 - m2, err := NewMultiaddr("/udp/5678")
274 - if err != nil {
275 - t.Error(err)
276 - }
277 -
278 - b := m.Encapsulate(m2)
279 - if s := b.String(); s != "/ip4/127.0.0.1/udp/1234/udp/5678" {
280 - t.Error("encapsulate /ip4/127.0.0.1/udp/1234/udp/5678 failed.", s)
281 - }
282 -
283 - m3, _ := NewMultiaddr("/udp/5678")
284 - c := b.Decapsulate(m3)
285 - if s := c.String(); s != "/ip4/127.0.0.1/udp/1234" {
286 - t.Error("decapsulate /udp failed.", "/ip4/127.0.0.1/udp/1234", s)
287 - }
288 -
289 - m4, _ := NewMultiaddr("/ip4/127.0.0.1")
290 - d := c.Decapsulate(m4)
291 - if s := d.String(); s != "" {
292 - t.Error("decapsulate /ip4 failed.", "/", s)
293 - }
294 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/protocols.csv deleted
-12
@@ -1,12 +0,0 @@
1 -code size name
2 -4 32 ip4
3 -6 16 tcp
4 -17 16 udp
5 -33 16 dccp
6 -41 128 ip6
7 -132 16 sctp
8 -301 0 udt
9 -302 0 utp
10 -421 V ipfs
11 -480 0 http
12 -443 0 https
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/protocols.go deleted
-116
@@ -1,116 +0,0 @@
1 -package multiaddr
2 -
3 -import (
4 - "encoding/binary"
5 - "fmt"
6 - "strings"
7 -)
8 -
9 -// Protocol is a Multiaddr protocol description structure.
10 -type Protocol struct {
11 - Code int
12 - Size int // a size of -1 indicates a length-prefixed variable size
13 - Name string
14 - VCode []byte
15 -}
16 -
17 -// replicating table here to:
18 -// 1. avoid parsing the csv
19 -// 2. ensuring errors in the csv don't screw up code.
20 -// 3. changing a number has to happen in two places.
21 -const (
22 - P_IP4 = 4
23 - P_TCP = 6
24 - P_UDP = 17
25 - P_DCCP = 33
26 - P_IP6 = 41
27 - P_SCTP = 132
28 - P_UTP = 301
29 - P_UDT = 302
30 - P_IPFS = 421
31 - P_HTTP = 480
32 - P_HTTPS = 443
33 -)
34 -
35 -// These are special sizes
36 -const (
37 - LengthPrefixedVarSize = -1
38 -)
39 -
40 -// Protocols is the list of multiaddr protocols supported by this module.
41 -var Protocols = []Protocol{
42 - Protocol{P_IP4, 32, "ip4", CodeToVarint(P_IP4)},
43 - Protocol{P_TCP, 16, "tcp", CodeToVarint(P_TCP)},
44 - Protocol{P_UDP, 16, "udp", CodeToVarint(P_UDP)},
45 - Protocol{P_DCCP, 16, "dccp", CodeToVarint(P_DCCP)},
46 - Protocol{P_IP6, 128, "ip6", CodeToVarint(P_IP6)},
47 - // these require varint:
48 - Protocol{P_SCTP, 16, "sctp", CodeToVarint(P_SCTP)},
49 - Protocol{P_UTP, 0, "utp", CodeToVarint(P_UTP)},
50 - Protocol{P_UDT, 0, "udt", CodeToVarint(P_UDT)},
51 - Protocol{P_HTTP, 0, "http", CodeToVarint(P_HTTP)},
52 - Protocol{P_HTTPS, 0, "https", CodeToVarint(P_HTTPS)},
53 - Protocol{P_IPFS, LengthPrefixedVarSize, "ipfs", CodeToVarint(P_IPFS)},
54 -}
55 -
56 -// ProtocolWithName returns the Protocol description with given string name.
57 -func ProtocolWithName(s string) Protocol {
58 - for _, p := range Protocols {
59 - if p.Name == s {
60 - return p
61 - }
62 - }
63 - return Protocol{}
64 -}
65 -
66 -// ProtocolWithCode returns the Protocol description with given protocol code.
67 -func ProtocolWithCode(c int) Protocol {
68 - for _, p := range Protocols {
69 - if p.Code == c {
70 - return p
71 - }
72 - }
73 - return Protocol{}
74 -}
75 -
76 -// ProtocolsWithString returns a slice of protocols matching given string.
77 -func ProtocolsWithString(s string) ([]Protocol, error) {
78 - s = strings.Trim(s, "/")
79 - sp := strings.Split(s, "/")
80 - if len(sp) == 0 {
81 - return nil, nil
82 - }
83 -
84 - t := make([]Protocol, len(sp))
85 - for i, name := range sp {
86 - p := ProtocolWithName(name)
87 - if p.Code == 0 {
88 - return nil, fmt.Errorf("no protocol with name: %s", name)
89 - }
90 - t[i] = p
91 - }
92 - return t, nil
93 -}
94 -
95 -// CodeToVarint converts an integer to a varint-encoded []byte
96 -func CodeToVarint(num int) []byte {
97 - buf := make([]byte, (num/7)+1) // varint package is uint64
98 - n := binary.PutUvarint(buf, uint64(num))
99 - return buf[:n]
100 -}
101 -
102 -// VarintToCode converts a varint-encoded []byte to an integer protocol code
103 -func VarintToCode(buf []byte) int {
104 - num, _ := ReadVarintCode(buf)
105 - return num
106 -}
107 -
108 -// ReadVarintCode reads a varint code from the beginning of buf.
109 -// returns the code, and the number of bytes read.
110 -func ReadVarintCode(buf []byte) (int, int) {
111 - num, n := binary.Uvarint(buf)
112 - if n < 0 {
113 - panic("varints larger than uint64 not yet supported")
114 - }
115 - return int(num), n
116 -}
Godeps/_workspace/src/github.com/jbenet/go-multiaddr/util.go deleted
-56
@@ -1,56 +0,0 @@
1 -package multiaddr
2 -
3 -import "fmt"
4 -
5 -// Split returns the sub-address portions of a multiaddr.
6 -func Split(m Multiaddr) []Multiaddr {
7 - split, err := bytesSplit(m.Bytes())
8 - if err != nil {
9 - panic(fmt.Errorf("invalid multiaddr %s", m.String()))
10 - }
11 -
12 - addrs := make([]Multiaddr, len(split))
13 - for i, addr := range split {
14 - addrs[i] = &multiaddr{bytes: addr}
15 - }
16 - return addrs
17 -}
18 -
19 -// Join returns a combination of addresses.
20 -func Join(ms ...Multiaddr) Multiaddr {
21 -
22 - length := 0
23 - bs := make([][]byte, len(ms))
24 - for i, m := range ms {
25 - bs[i] = m.Bytes()
26 - length += len(bs[i])
27 - }
28 -
29 - bidx := 0
30 - b := make([]byte, length)
31 - for _, mb := range bs {
32 - for i := range mb {
33 - b[bidx] = mb[i]
34 - bidx++
35 - }
36 - }
37 - return &multiaddr{bytes: b}
38 -}
39 -
40 -// Cast re-casts a byte slice as a multiaddr. will panic if it fails to parse.
41 -func Cast(b []byte) Multiaddr {
42 - _, err := bytesToString(b)
43 - if err != nil {
44 - panic(fmt.Errorf("multiaddr failed to parse: %s", err))
45 - }
46 - return &multiaddr{bytes: b}
47 -}
48 -
49 -// StringCast like Cast, but parses a string. Will also panic if it fails to parse.
50 -func StringCast(s string) Multiaddr {
51 - m, err := NewMultiaddr(s)
52 - if err != nil {
53 - panic(fmt.Errorf("multiaddr failed to parse: %s", err))
54 - }
55 - return m
56 -}
Godeps/_workspace/src/github.com/jbenet/go-multihash/.travis.yml deleted
-11
@@ -1,11 +0,0 @@
1 -language: go
2 -
3 -go:
4 - - 1.3
5 - - release
6 - - tip
7 -
8 -script:
9 - - make test
10 -
11 -env: TEST_VERBOSE=1
Godeps/_workspace/src/github.com/jbenet/go-multihash/LICENSE deleted
-21
@@ -1,21 +0,0 @@
1 -The MIT License (MIT)
2 -
3 -Copyright (c) 2014 Juan Batiz-Benet
4 -
5 -Permission is hereby granted, free of charge, to any person obtaining a copy
6 -of this software and associated documentation files (the "Software"), to deal
7 -in the Software without restriction, including without limitation the rights
8 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 -copies of the Software, and to permit persons to whom the Software is
10 -furnished to do so, subject to the following conditions:
11 -
12 -The above copyright notice and this permission notice shall be included in
13 -all copies or substantial portions of the Software.
14 -
15 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 -THE SOFTWARE.
Godeps/_workspace/src/github.com/jbenet/go-multihash/Makefile deleted
-11
@@ -1,11 +0,0 @@
1 -test: go_test other_tests
2 -
3 -other_tests:
4 - cd test && make test
5 -
6 -go_test: go_deps
7 - go test -race -cpu=5 -v ./...
8 -
9 -go_deps:
10 - go get golang.org/x/crypto/sha3
11 - go get github.com/jbenet/go-base58
Godeps/_workspace/src/github.com/jbenet/go-multihash/README.md deleted
-45
@@ -1,45 +0,0 @@
1 -# go-multihash
2 -
3 -![travis](https://travis-ci.org/jbenet/go-multihash.svg)
4 -
5 -[multihash](//github.com/jbenet/multihash) implementation in Go.
6 -
7 -## Example
8 -
9 -```go
10 -package main
11 -
12 -import (
13 - "encoding/hex"
14 - "fmt"
15 - "github.com/jbenet/go-multihash"
16 -)
17 -
18 -func main() {
19 - // ignores errors for simplicity.
20 - // don't do that at home.
21 -
22 - buf, _ := hex.DecodeString("0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33")
23 - mhbuf, _ := multihash.EncodeName(buf, "sha1");
24 - mhhex := hex.EncodeToString(mhbuf)
25 - fmt.Printf("hex: %v\n", mhhex);
26 -
27 - o, _ := multihash.Decode(mhbuf);
28 - mhhex = hex.EncodeToString(o.Digest);
29 - fmt.Printf("obj: %v 0x%x %d %s\n", o.Name, o.Code, o.Length, mhhex);
30 -}
31 -```
32 -
33 -Run [test/foo.go](test/foo.go)
34 -
35 -```
36 -> cd test/
37 -> go build
38 -> ./test
39 -hex: 11140beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33
40 -obj: sha1 0x11 20 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33
41 -```
42 -
43 -## License
44 -
45 -MIT
Godeps/_workspace/src/github.com/jbenet/go-multihash/io.go deleted
-79
@@ -1,79 +0,0 @@
1 -package multihash
2 -
3 -import (
4 - "fmt"
5 - "io"
6 -)
7 -
8 -// Reader is an io.Reader wrapper that exposes a function
9 -// to read a whole multihash, parse it, and return it.
10 -type Reader interface {
11 - io.Reader
12 -
13 - ReadMultihash() (Multihash, error)
14 -}
15 -
16 -// Writer is an io.Writer wrapper that exposes a function
17 -// to write a whole multihash.
18 -type Writer interface {
19 - io.Writer
20 -
21 - WriteMultihash(Multihash) error
22 -}
23 -
24 -// NewReader wraps an io.Reader with a multihash.Reader
25 -func NewReader(r io.Reader) Reader {
26 - return &mhReader{r}
27 -}
28 -
29 -// NewWriter wraps an io.Writer with a multihash.Writer
30 -func NewWriter(w io.Writer) Writer {
31 - return &mhWriter{w}
32 -}
33 -
34 -type mhReader struct {
35 - r io.Reader
36 -}
37 -
38 -func (r *mhReader) Read(buf []byte) (n int, err error) {
39 - return r.r.Read(buf)
40 -}
41 -
42 -func (r *mhReader) ReadMultihash() (Multihash, error) {
43 - mhhdr := make([]byte, 2)
44 - if _, err := io.ReadFull(r.r, mhhdr); err != nil {
45 - return nil, err
46 - }
47 -
48 - // first byte is the algo, the second is the length.
49 -
50 - // (varints someday...)
51 - length := uint(mhhdr[1])
52 -
53 - if length > 127 {
54 - return nil, fmt.Errorf("varints not yet supported (length is %d)", length)
55 - }
56 -
57 - buf := make([]byte, length+2)
58 - buf[0] = mhhdr[0]
59 - buf[1] = mhhdr[1]
60 -
61 - if _, err := io.ReadFull(r.r, buf[2:]); err != nil {
62 - return nil, err
63 - }
64 -
65 - return Cast(buf)
66 -}
67 -
68 -type mhWriter struct {
69 - w io.Writer
70 -}
71 -
72 -func (w *mhWriter) Write(buf []byte) (n int, err error) {
73 - return w.w.Write(buf)
74 -}
75 -
76 -func (w *mhWriter) WriteMultihash(m Multihash) error {
77 - _, err := w.w.Write([]byte(m))
78 - return err
79 -}
Godeps/_workspace/src/github.com/jbenet/go-multihash/io_test.go deleted
-69
@@ -1,69 +0,0 @@
1 -package multihash
2 -
3 -import (
4 - "bytes"
5 - "io"
6 - "testing"
7 -)
8 -
9 -func TestReader(t *testing.T) {
10 -
11 - var buf bytes.Buffer
12 -
13 - for _, tc := range testCases {
14 - m, err := tc.Multihash()
15 - if err != nil {
16 - t.Fatal(err)
17 - }
18 -
19 - buf.Write([]byte(m))
20 - }
21 -
22 - r := NewReader(&buf)
23 -
24 - for _, tc := range testCases {
25 - h, err := tc.Multihash()
26 - if err != nil {
27 - t.Fatal(err)
28 - }
29 -
30 - h2, err := r.ReadMultihash()
31 - if err != nil {
32 - t.Error(err)
33 - continue
34 - }
35 -
36 - if !bytes.Equal(h, h2) {
37 - t.Error("h and h2 should be equal")
38 - }
39 - }
40 -}
41 -
42 -func TestWriter(t *testing.T) {
43 -
44 - var buf bytes.Buffer
45 - w := NewWriter(&buf)
46 -
47 - for _, tc := range testCases {
48 - m, err := tc.Multihash()
49 - if err != nil {
50 - t.Error(err)
51 - continue
52 - }
53 -
54 - if err := w.WriteMultihash(m); err != nil {
55 - t.Error(err)
56 - continue
57 - }
58 -
59 - buf2 := make([]byte, len(m))
60 - if _, err := io.ReadFull(&buf, buf2); err != nil {
61 - t.Error(err)
62 - continue
63 - }
64 -
65 - if !bytes.Equal(m, buf2) {
66 - t.Error("m and buf2 should be equal")
67 - }
68 - }
69 -}
Godeps/_workspace/src/github.com/jbenet/go-multihash/multihash.go deleted
-188
@@ -1,188 +0,0 @@
1 -package multihash
2 -
3 -import (
4 - "encoding/hex"
5 - "errors"
6 - "fmt"
7 -
8 - b58 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
9 -)
10 -
11 -// errors
12 -var (
13 - ErrUnknownCode = errors.New("unknown multihash code")
14 - ErrTooShort = errors.New("multihash too short. must be > 3 bytes")
15 - ErrTooLong = errors.New("multihash too long. must be < 129 bytes")
16 - ErrLenNotSupported = errors.New("multihash does not yet support digests longer than 127 bytes")
17 -)
18 -
19 -// ErrInconsistentLen is returned when a decoded multihash has an inconsistent length
20 -type ErrInconsistentLen struct {
21 - dm *DecodedMultihash
22 -}
23 -
24 -func (e ErrInconsistentLen) Error() string {
25 - return fmt.Sprintf("multihash length inconsistent: %v", e.dm)
26 -}
27 -
28 -// constants
29 -const (
30 - SHA1 = 0x11
31 - SHA2_256 = 0x12
32 - SHA2_512 = 0x13
33 - SHA3 = 0x14
34 - BLAKE2B = 0x40
35 - BLAKE2S = 0x41
36 -)
37 -
38 -// Names maps the name of a hash to the code
39 -var Names = map[string]int{
40 - "sha1": SHA1,
41 - "sha2-256": SHA2_256,
42 - "sha2-512": SHA2_512,
43 - "sha3": SHA3,
44 - "blake2b": BLAKE2B,
45 - "blake2s": BLAKE2S,
46 -}
47 -
48 -// Codes maps a hash code to it's name
49 -var Codes = map[int]string{
50 - SHA1: "sha1",
51 - SHA2_256: "sha2-256",
52 - SHA2_512: "sha2-512",
53 - SHA3: "sha3",
54 - BLAKE2B: "blake2b",
55 - BLAKE2S: "blake2s",
56 -}
57 -
58 -// DefaultLengths maps a hash code to it's default length
59 -var DefaultLengths = map[int]int{
60 - SHA1: 20,
61 - SHA2_256: 32,
62 - SHA2_512: 64,
63 - SHA3: 64,
64 - BLAKE2B: 64,
65 - BLAKE2S: 32,
66 -}
67 -
68 -type DecodedMultihash struct {
69 - Code int
70 - Name string
71 - Length int
72 - Digest []byte
73 -}
74 -
75 -type Multihash []byte
76 -
77 -func (m *Multihash) HexString() string {
78 - return hex.EncodeToString([]byte(*m))
79 -}
80 -
81 -func (m *Multihash) String() string {
82 - return m.HexString()
83 -}
84 -
85 -func FromHexString(s string) (Multihash, error) {
86 - b, err := hex.DecodeString(s)
87 - if err != nil {
88 - return Multihash{}, err
89 - }
90 -
91 - return Cast(b)
92 -}
93 -
94 -func (m Multihash) B58String() string {
95 - return b58.Encode([]byte(m))
96 -}
97 -
98 -func FromB58String(s string) (m Multihash, err error) {
99 - // panic handler, in case we try accessing bytes incorrectly.
100 - defer func() {
101 - if e := recover(); e != nil {
102 - m = Multihash{}
103 - err = e.(error)
104 - }
105 - }()
106 -
107 - //b58 smells like it can panic...
108 - b := b58.Decode(s)
109 - return Cast(b)
110 -}
111 -
112 -func Cast(buf []byte) (Multihash, error) {
113 - dm, err := Decode(buf)
114 - if err != nil {
115 - return Multihash{}, err
116 - }
117 -
118 - if !ValidCode(dm.Code) {
119 - return Multihash{}, ErrUnknownCode
120 - }
121 -
122 - return Multihash(buf), nil
123 -}
124 -
125 -// Decode a hash from the given Multihash.
126 -func Decode(buf []byte) (*DecodedMultihash, error) {
127 -
128 - if len(buf) < 3 {
129 - return nil, ErrTooShort
130 - }
131 -
132 - if len(buf) > 129 {
133 - return nil, ErrTooLong
134 - }
135 -
136 - dm := &DecodedMultihash{
137 - Code: int(uint8(buf[0])),
138 - Name: Codes[int(uint8(buf[0]))],
139 - Length: int(uint8(buf[1])),
140 - Digest: buf[2:],
141 - }
142 -
143 - if len(dm.Digest) != dm.Length {
144 - return nil, ErrInconsistentLen{dm}
145 - }
146 -
147 - return dm, nil
148 -}
149 -
150 -// Encode a hash digest along with the specified function code.
151 -// Note: the length is derived from the length of the digest itself.
152 -func Encode(buf []byte, code int) ([]byte, error) {
153 -
154 - if !ValidCode(code) {
155 - return nil, ErrUnknownCode
156 - }
157 -
158 - if len(buf) > 127 {
159 - return nil, ErrLenNotSupported
160 - }
161 -
162 - pre := make([]byte, 2)
163 - pre[0] = byte(uint8(code))
164 - pre[1] = byte(uint8(len(buf)))
165 - return append(pre, buf...), nil
166 -}
167 -
168 -func EncodeName(buf []byte, name string) ([]byte, error) {
169 - return Encode(buf, Names[name])
170 -}
171 -
172 -// ValidCode checks whether a multihash code is valid.
173 -func ValidCode(code int) bool {
174 - if AppCode(code) {
175 - return true
176 - }
177 -
178 - if _, ok := Codes[code]; ok {
179 - return true
180 - }
181 -
182 - return false
183 -}
184 -
185 -// AppCode checks whether a multihash code is part of the App range.
186 -func AppCode(code int) bool {
187 - return code >= 0 && code < 0x10
188 -}
Godeps/_workspace/src/github.com/jbenet/go-multihash/multihash/.gitignore deleted
-1
@@ -1 +0,0 @@
1 -multihash
Godeps/_workspace/src/github.com/jbenet/go-multihash/multihash/.gobuilder.yml deleted
-5
@@ -1,5 +0,0 @@
1 ----
2 -artifacts:
3 - - LICENSE
4 - - README.md
5 - - install.dist.sh
Godeps/_workspace/src/github.com/jbenet/go-multihash/multihash/LICENSE deleted
-21
@@ -1,21 +0,0 @@
1 -The MIT License (MIT)
2 -
3 -Copyright (c) 2014 Juan Batiz-Benet
4 -
5 -Permission is hereby granted, free of charge, to any person obtaining a copy
6 -of this software and associated documentation files (the "Software"), to deal
7 -in the Software without restriction, including without limitation the rights
8 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 -copies of the Software, and to permit persons to whom the Software is
10 -furnished to do so, subject to the following conditions:
11 -
12 -The above copyright notice and this permission notice shall be included in
13 -all copies or substantial portions of the Software.
14 -
15 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 -THE SOFTWARE.
Godeps/_workspace/src/github.com/jbenet/go-multihash/multihash/README.md deleted
-118
@@ -1,118 +0,0 @@
1 -# multihash tool
2 -
3 -The `multihash` tool uses `go-multihash` to hash things much like `shasum`.
4 -
5 -Warning: this is a **multihash** tool! Its digests follow the [multihash](https://github.com/jbenet/multihash) format.
6 -
7 -### Install
8 -
9 -- From Source:
10 - ```
11 - go get github.com/jbenet/go-multihash/multihash
12 - ```
13 -- Precompiled Binaries: https://gobuilder.me/github.com/jbenet/go-multihash/multihash
14 -
15 -### Usage
16 -
17 -```sh
18 -> multihash -h
19 -usage: ./multihash [options] [FILE]
20 -Print or check multihash checksums.
21 -With no FILE, or when FILE is -, read standard input.
22 -
23 -Options:
24 - -a="sha2-256": one of: sha1, sha2-256, sha2-512, sha3 (shorthand)
25 - -algorithm="sha2-256": one of: sha1, sha2-256, sha2-512, sha3
26 - -c="": check checksum matches (shorthand)
27 - -check="": check checksum matches
28 - -e="base58": one of: raw, hex, base58, base64 (shorthand)
29 - -encoding="base58": one of: raw, hex, base58, base64
30 - -l=-1: checksums length in bits (truncate). -1 is default (shorthand)
31 - -length=-1: checksums length in bits (truncate). -1 is default
32 -```
33 -
34 -### Examples
35 -
36 -#### Input
37 -
38 -```sh
39 -# from stdin
40 -> multihash < main.go
41 -QmRZxt2b1FVZPNqd8hsiykDL3TdBDeTSPX9Kv46HmX4Gx8
42 -
43 -# from file
44 -> ./multihash main.go
45 -QmRZxt2b1FVZPNqd8hsiykDL3TdBDeTSPX9Kv46HmX4Gx8
46 -
47 -# from stdin "filename"
48 -> multihash - < main.go
49 -QmRZxt2b1FVZPNqd8hsiykDL3TdBDeTSPX9Kv46HmX4Gx8
50 -```
51 -
52 -#### Algorithms
53 -
54 -```sh
55 -> multihash -a ?
56 -error: algorithm '?' not one of: sha1, sha2-256, sha2-512, sha3
57 -
58 -> multihash -a sha1 < main.go
59 -5drkbcqJUo6fZVvcZJeVEVWAgndvLm
60 -
61 -> multihash -a sha2-256 < main.go
62 -QmcK3s36goo9v2HYcfTrDKKwxaxmJJ59etodQQFYsL5T5N
63 -
64 -> multihash -a sha2-512 < main.go
65 -8VuDcW4CooyPQA8Cc4eYpwjhyDJZqu5m5ZMDFzWULYsVS8d119JaGeNWsZbZ2ZG2kPtbrMx31MidokCigaD65yUPAs
66 -
67 -> multihash -a sha3 < main.go
68 -8tWDCTfAX24DYmzNixTj2ARJkqwRG736VHx5aJppmqRjhW9QT1EuTgKUmu9Pmunzq292jzPKxb2VxSsTXmjFY1HD3B
69 -```
70 -
71 -#### Encodings
72 -
73 -```sh
74 -> multihash -e raw < main.go
75 - Ϛ�����I�5 S��WG>���_��]g�����u
76 -
77 -> multihash -e hex < main.go
78 -1220cf9aa2b8a38b9b49d135095390059a57473e97aceb5fcae25d67a8b6feb58275
79 -
80 -> multihash -e base64 < main.go
81 -EiDPmqK4o4ubSdE1CVOQBZpXRz6XrOtfyuJdZ6i2/rWCdQ==
82 -
83 -> multihash -e base58 < main.go
84 -Qmf1QjEXDmqBm7RqHKqFGNUyhzUjnX7cmgKMrGzzPceZDQ
85 -```
86 -
87 -#### Digest Length
88 -
89 -```sh
90 -# we're outputing hex (good byte alignment) to show the codes changing
91 -# notice the multihash code (first 2 chars) differs!
92 -> multihash -e hex -a sha2-256 -l 256 < main.go
93 -1220cf9aa2b8a38b9b49d135095390059a57473e97aceb5fcae25d67a8b6feb58275
94 -> multihash -e hex -a sha2-512 -l 256 < main.go
95 -132047a4b6c629f5545f529b0ff461dc09119969f3593186277a1cc7a8ea3560a6f1
96 -> multihash -e hex -a sha3 -l 256 < main.go
97 -14206b9222a1a47939e665261bd2b5573e55e7988675223adde73c1011066ad66335
98 -
99 -# notice the multihash length (next 2 chars) differs!
100 -> multihash -e hex -a sha2-256 -l 256 < main.go
101 -1220cf9aa2b8a38b9b49d135095390059a57473e97aceb5fcae25d67a8b6feb58275
102 -> multihash -e hex -a sha2-256 -l 200 < main.go
103 -1219cf9aa2b8a38b9b49d135095390059a57473e97aceb5fcae25d
104 -```
105 -
106 -#### Verify Checksum
107 -
108 -```sh
109 -> multihash -c QmRZxt2b1FVZPNqd8hsiykDL3TdBDeTSPX9Kv46HmX4Gx8 < main.go
110 -OK checksums match (-q for no output)
111 -
112 -> multihash -c QmcKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa < main.go
113 -error: computed checksum did not match (-q for no output)
114 -
115 -# works with other arguments too
116 -> multihash -e hex -l 128 -c "12102ffc284a1e82bf51e567c75b2ae6edb9" < main.go
117 -OK checksums match (-q for no output)
118 -```
Godeps/_workspace/src/github.com/jbenet/go-multihash/multihash/install.dist.sh deleted
-21
@@ -1,21 +0,0 @@
1 -#!/bin/sh
2 -
3 -bin=multihash
4 -
5 -# this script is currently brain dead.
6 -# it merely tries two locations.
7 -# in the future maybe use value of $PATH.
8 -
9 -binpath=/usr/local/bin
10 -if [ -d "$binpath" ]; then
11 - mv "$bin" "$binpath/$bin"
12 - echo "installed $binpath/$bin"
13 - exit 0
14 -fi
15 -
16 -binpath=/usr/bin
17 -if [ -d "$binpath" ]; then
18 - mv "$bin" "$binpath/$bin"
19 - echo "installed $binpath/$bin"
20 - exit 0
21 -fi
Godeps/_workspace/src/github.com/jbenet/go-multihash/multihash/main.go deleted
-132
@@ -1,132 +0,0 @@
1 -package main
2 -
3 -import (
4 - "flag"
5 - "fmt"
6 - "io"
7 - "os"
8 -
9 - mh "gx/ipfs/QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku/go-multihash"
10 - mhopts "gx/ipfs/QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku/go-multihash/opts"
11 -)
12 -
13 -var usage = `usage: %s [options] [FILE]
14 -Print or check multihash checksums.
15 -With no FILE, or when FILE is -, read standard input.
16 -
17 -Options:
18 -`
19 -
20 -// flags
21 -var opts *mhopts.Options
22 -var checkRaw string
23 -var checkMh mh.Multihash
24 -var inputFilename string
25 -var quiet bool
26 -
27 -func init() {
28 - flag.Usage = func() {
29 - fmt.Fprintf(os.Stderr, usage, os.Args[0])
30 - flag.PrintDefaults()
31 - }
32 -
33 - opts = mhopts.SetupFlags(flag.CommandLine)
34 -
35 - checkStr := "check checksum matches"
36 - flag.StringVar(&checkRaw, "check", "", checkStr)
37 - flag.StringVar(&checkRaw, "c", "", checkStr+" (shorthand)")
38 -
39 - quietStr := "quiet output (no newline on checksum, no error text)"
40 - flag.BoolVar(&quiet, "quiet", false, quietStr)
41 - flag.BoolVar(&quiet, "q", false, quietStr+" (shorthand)")
42 -}
43 -
44 -func parseFlags(o *mhopts.Options) error {
45 - flag.Parse()
46 - if err := o.ParseError(); err != nil {
47 - return err
48 - }
49 -
50 - if checkRaw != "" {
51 - var err error
52 - checkMh, err = mhopts.Decode(o.Encoding, checkRaw)
53 - if err != nil {
54 - return fmt.Errorf("fail to decode check '%s': %s", checkRaw, err)
55 - }
56 - }
57 -
58 - return nil
59 -}
60 -
61 -func getInput() (io.ReadCloser, error) {
62 - args := flag.Args()
63 -
64 - switch {
65 - case len(args) < 1:
66 - inputFilename = "-"
67 - return os.Stdin, nil
68 - case args[0] == "-":
69 - inputFilename = "-"
70 - return os.Stdin, nil
71 - default:
72 - inputFilename = args[0]
73 - f, err := os.Open(args[0])
74 - if err != nil {
75 - return nil, fmt.Errorf("failed to open '%s': %s", args[0], err)
76 - }
77 - return f, nil
78 - }
79 -}
80 -func printHash(o *mhopts.Options, r io.Reader) error {
81 - h, err := o.Multihash(r)
82 - if err != nil {
83 - return err
84 - }
85 -
86 - s, err := mhopts.Encode(o.Encoding, h)
87 - if err != nil {
88 - return err
89 - }
90 -
91 - if quiet {
92 - fmt.Print(s)
93 - } else {
94 - fmt.Println(s)
95 - }
96 - return nil
97 -}
98 -
99 -func main() {
100 - checkErr := func(err error) {
101 - if err != nil {
102 - die("error: ", err)
103 - }
104 - }
105 -
106 - err := parseFlags(opts)
107 - checkErr(err)
108 -
109 - inp, err := getInput()
110 - checkErr(err)
111 -
112 - if checkMh != nil {
113 - err = opts.Check(inp, checkMh)
114 - checkErr(err)
115 - if !quiet {
116 - fmt.Println("OK checksums match (-q for no output)")
117 - }
118 - } else {
119 - err = printHash(opts, inp)
120 - checkErr(err)
121 - }
122 - inp.Close()
123 -}
124 -
125 -func die(v ...interface{}) {
126 - if !quiet {
127 - fmt.Fprint(os.Stderr, v...)
128 - fmt.Fprint(os.Stderr, "\n")
129 - }
130 - // flag.Usage()
131 - os.Exit(1)
132 -}
Godeps/_workspace/src/github.com/jbenet/go-multihash/multihash_test.go deleted
-270
@@ -1,270 +0,0 @@
1 -package multihash
2 -
3 -import (
4 - "bytes"
5 - "encoding/hex"
6 - "fmt"
7 - "testing"
8 -)
9 -
10 -// maybe silly, but makes it so changing
11 -// the table accidentally has to happen twice.
12 -var tCodes = map[int]string{
13 - 0x11: "sha1",
14 - 0x12: "sha2-256",
15 - 0x13: "sha2-512",
16 - 0x14: "sha3",
17 - 0x40: "blake2b",
18 - 0x41: "blake2s",
19 -}
20 -
21 -type TestCase struct {
22 - hex string
23 - code int
24 - name string
25 -}
26 -
27 -var testCases = []TestCase{
28 - TestCase{"0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33", 0x11, "sha1"},
29 - TestCase{"0beec7b5", 0x11, "sha1"},
30 - TestCase{"2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae", 0x12, "sha2-256"},
31 - TestCase{"2c26b46b", 0x12, "sha2-256"},
32 - TestCase{"0beec7b5ea3f0fdbc9", 0x40, "blake2b"},
33 -}
34 -
35 -func (tc TestCase) Multihash() (Multihash, error) {
36 - ob, err := hex.DecodeString(tc.hex)
37 - if err != nil {
38 - return nil, err
39 - }
40 -
41 - b := make([]byte, 2+len(ob))
42 - b[0] = byte(uint8(tc.code))
43 - b[1] = byte(uint8(len(ob)))
44 - copy(b[2:], ob)
45 - return Cast(b)
46 -}
47 -
48 -func TestEncode(t *testing.T) {
49 - for _, tc := range testCases {
50 - ob, err := hex.DecodeString(tc.hex)
51 - if err != nil {
52 - t.Error(err)
53 - continue
54 - }
55 -
56 - pre := make([]byte, 2)
57 - pre[0] = byte(uint8(tc.code))
58 - pre[1] = byte(uint8(len(ob)))
59 - nb := append(pre, ob...)
60 -
61 - encC, err := Encode(ob, tc.code)
62 - if err != nil {
63 - t.Error(err)
64 - continue
65 - }
66 -
67 - if !bytes.Equal(encC, nb) {
68 - t.Error("encoded byte mismatch: ", encC, nb)
69 - }
70 -
71 - encN, err := EncodeName(ob, tc.name)
72 - if err != nil {
73 - t.Error(err)
74 - continue
75 - }
76 -
77 - if !bytes.Equal(encN, nb) {
78 - t.Error("encoded byte mismatch: ", encN, nb)
79 - }
80 -
81 - h, err := tc.Multihash()
82 - if err != nil {
83 - t.Error(err)
84 - }
85 - if !bytes.Equal(h, nb) {
86 - t.Error("Multihash func mismatch.")
87 - }
88 - }
89 -}
90 -
91 -func ExampleEncodeName() {
92 - // ignores errors for simplicity - don't do that at home.
93 - buf, _ := hex.DecodeString("0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33")
94 - mhbuf, _ := EncodeName(buf, "sha1")
95 - mhhex := hex.EncodeToString(mhbuf)
96 - fmt.Printf("hex: %v\n", mhhex)
97 -
98 - // Output:
99 - // hex: 11140beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33
100 -}
101 -
102 -func TestDecode(t *testing.T) {
103 - for _, tc := range testCases {
104 - ob, err := hex.DecodeString(tc.hex)
105 - if err != nil {
106 - t.Error(err)
107 - continue
108 - }
109 -
110 - pre := make([]byte, 2)
111 - pre[0] = byte(uint8(tc.code))
112 - pre[1] = byte(uint8(len(ob)))
113 - nb := append(pre, ob...)
114 -
115 - dec, err := Decode(nb)
116 - if err != nil {
117 - t.Error(err)
118 - continue
119 - }
120 -
121 - if dec.Code != tc.code {
122 - t.Error("decoded code mismatch: ", dec.Code, tc.code)
123 - }
124 -
125 - if dec.Name != tc.name {
126 - t.Error("decoded name mismatch: ", dec.Name, tc.name)
127 - }
128 -
129 - if dec.Length != len(ob) {
130 - t.Error("decoded length mismatch: ", dec.Length, len(ob))
131 - }
132 -
133 - if !bytes.Equal(dec.Digest, ob) {
134 - t.Error("decoded byte mismatch: ", dec.Digest, ob)
135 - }
136 - }
137 -}
138 -
139 -func TestTable(t *testing.T) {
140 - for k, v := range tCodes {
141 - if Codes[k] != v {
142 - t.Error("Table mismatch: ", Codes[k], v)
143 - }
144 - if Names[v] != k {
145 - t.Error("Table mismatch: ", Names[v], k)
146 - }
147 - }
148 -}
149 -
150 -func ExampleDecode() {
151 - // ignores errors for simplicity - don't do that at home.
152 - buf, _ := hex.DecodeString("0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33")
153 - mhbuf, _ := EncodeName(buf, "sha1")
154 - o, _ := Decode(mhbuf)
155 - mhhex := hex.EncodeToString(o.Digest)
156 - fmt.Printf("obj: %v 0x%x %d %s\n", o.Name, o.Code, o.Length, mhhex)
157 -
158 - // Output:
159 - // obj: sha1 0x11 20 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33
160 -}
161 -
162 -func TestValidCode(t *testing.T) {
163 - for i := 0; i < 0xff; i++ {
164 - _, ok := tCodes[i]
165 - b := AppCode(i) || ok
166 -
167 - if ValidCode(i) != b {
168 - t.Error("ValidCode incorrect for: ", i)
169 - }
170 - }
171 -}
172 -
173 -func TestAppCode(t *testing.T) {
174 - for i := 0; i < 0xff; i++ {
175 - b := i >= 0 && i < 0x10
176 - if AppCode(i) != b {
177 - t.Error("AppCode incorrect for: ", i)
178 - }
179 - }
180 -}
181 -
182 -func TestCast(t *testing.T) {
183 - for _, tc := range testCases {
184 - ob, err := hex.DecodeString(tc.hex)
185 - if err != nil {
186 - t.Error(err)
187 - continue
188 - }
189 -
190 - pre := make([]byte, 2)
191 - pre[0] = byte(uint8(tc.code))
192 - pre[1] = byte(uint8(len(ob)))
193 - nb := append(pre, ob...)
194 -
195 - if _, err := Cast(nb); err != nil {
196 - t.Error(err)
197 - continue
198 - }
199 -
200 - if _, err = Cast(ob); err == nil {
201 - t.Error("cast failed to detect non-multihash")
202 - continue
203 - }
204 - }
205 -}
206 -
207 -func TestHex(t *testing.T) {
208 - for _, tc := range testCases {
209 - ob, err := hex.DecodeString(tc.hex)
210 - if err != nil {
211 - t.Error(err)
212 - continue
213 - }
214 -
215 - pre := make([]byte, 2)
216 - pre[0] = byte(uint8(tc.code))
217 - pre[1] = byte(uint8(len(ob)))
218 - nb := append(pre, ob...)
219 -
220 - hs := hex.EncodeToString(nb)
221 - mh, err := FromHexString(hs)
222 - if err != nil {
223 - t.Error(err)
224 - continue
225 - }
226 -
227 - if !bytes.Equal(mh, nb) {
228 - t.Error("FromHexString failed", nb, mh)
229 - continue
230 - }
231 -
232 - if mh.HexString() != hs {
233 - t.Error("Multihash.HexString failed", hs, mh.HexString)
234 - continue
235 - }
236 - }
237 -}
238 -
239 -func BenchmarkEncode(b *testing.B) {
240 - tc := testCases[0]
241 - ob, err := hex.DecodeString(tc.hex)
242 - if err != nil {
243 - b.Error(err)
244 - return
245 - }
246 -
247 - b.ResetTimer()
248 - for i := 0; i < b.N; i++ {
249 - Encode(ob, tc.code)
250 - }
251 -}
252 -
253 -func BenchmarkDecode(b *testing.B) {
254 - tc := testCases[0]
255 - ob, err := hex.DecodeString(tc.hex)
256 - if err != nil {
257 - b.Error(err)
258 - return
259 - }
260 -
261 - pre := make([]byte, 2)
262 - pre[0] = byte(uint8(tc.code))
263 - pre[1] = byte(uint8(len(ob)))
264 - nb := append(pre, ob...)
265 -
266 - b.ResetTimer()
267 - for i := 0; i < b.N; i++ {
268 - Decode(nb)
269 - }
270 -}
Godeps/_workspace/src/github.com/jbenet/go-multihash/opts/README.md deleted
-9
@@ -1,9 +0,0 @@
1 -# mhopts - multihash options for writing commands
2 -
3 -`mhopts` is a small package that helps to write commands which
4 -may take multihash options. Check it out in action:
5 -
6 -- [multihash](../multihash)
7 -- [hashpipe](https://github.com/jbenet/go-hashpipe)
8 -
9 -Godoc: [https://godoc.org/github.com/jbenet/go-multihash/opts](https://godoc.org/github.com/jbenet/go-multihash/opts)
Godeps/_workspace/src/github.com/jbenet/go-multihash/opts/coding.go deleted
-40
@@ -1,40 +0,0 @@
1 -package opts
2 -
3 -import (
4 - "encoding/base64"
5 - "encoding/hex"
6 - "fmt"
7 -
8 - base58 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
9 - mh "gx/ipfs/QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku/go-multihash"
10 -)
11 -
12 -func Decode(encoding, digest string) (mh.Multihash, error) {
13 - switch encoding {
14 - case "raw":
15 - return mh.Cast([]byte(digest))
16 - case "hex":
17 - return hex.DecodeString(digest)
18 - case "base58":
19 - return base58.Decode(digest), nil
20 - case "base64":
21 - return base64.StdEncoding.DecodeString(digest)
22 - default:
23 - return nil, fmt.Errorf("unknown encoding: %s", encoding)
24 - }
25 -}
26 -
27 -func Encode(encoding string, hash mh.Multihash) (string, error) {
28 - switch encoding {
29 - case "raw":
30 - return string(hash), nil
31 - case "hex":
32 - return hex.EncodeToString(hash), nil
33 - case "base58":
34 - return base58.Encode(hash), nil
35 - case "base64":
36 - return base64.StdEncoding.EncodeToString(hash), nil
37 - default:
38 - return "", fmt.Errorf("unknown encoding: %s", encoding)
39 - }
40 -}
Godeps/_workspace/src/github.com/jbenet/go-multihash/opts/opts.go deleted
-131
@@ -1,131 +0,0 @@
1 -// Package opts helps to write commands which may take multihash
2 -// options.
3 -package opts
4 -
5 -import (
6 - "bytes"
7 - "errors"
8 - "flag"
9 - "fmt"
10 - "io"
11 - "io/ioutil"
12 - "strings"
13 -
14 - mh "gx/ipfs/QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku/go-multihash"
15 -)
16 -
17 -// package errors
18 -var (
19 - ErrMatch = errors.New("multihash checksums did not match")
20 -)
21 -
22 -// Options is a struct used to parse cli flags.
23 -type Options struct {
24 - Encoding string
25 - Algorithm string
26 - AlgorithmCode int
27 - Length int
28 -
29 - fs *flag.FlagSet
30 -}
31 -
32 -// FlagValues are the values the various option flags can take.
33 -var FlagValues = struct {
34 - Encodings []string
35 - Algorithms []string
36 -}{
37 - Encodings: []string{"raw", "hex", "base58", "base64"},
38 - Algorithms: []string{"sha1", "sha2-256", "sha2-512", "sha3"},
39 -}
40 -
41 -// SetupFlags adds multihash related options to given flagset.
42 -func SetupFlags(f *flag.FlagSet) *Options {
43 - // TODO: add arg for adding opt prefix and/or overriding opts
44 -
45 - o := new(Options)
46 - algoStr := "one of: " + strings.Join(FlagValues.Algorithms, ", ")
47 - f.StringVar(&o.Algorithm, "algorithm", "sha2-256", algoStr)
48 - f.StringVar(&o.Algorithm, "a", "sha2-256", algoStr+" (shorthand)")
49 -
50 - encStr := "one of: " + strings.Join(FlagValues.Encodings, ", ")
51 - f.StringVar(&o.Encoding, "encoding", "base58", encStr)
52 - f.StringVar(&o.Encoding, "e", "base58", encStr+" (shorthand)")
53 -
54 - lengthStr := "checksums length in bits (truncate). -1 is default"
55 - f.IntVar(&o.Length, "length", -1, lengthStr)
56 - f.IntVar(&o.Length, "l", -1, lengthStr+" (shorthand)")
57 - return o
58 -}
59 -
60 -// Parse parses the values of flags from given argument slice.
61 -// It is equivalent to flags.Parse(args)
62 -func (o *Options) Parse(args []string) error {
63 - if err := o.fs.Parse(args); err != nil {
64 - return err
65 - }
66 - return o.ParseError()
67 -}
68 -
69 -// ParseError checks the parsed options for errors.
70 -func (o *Options) ParseError() error {
71 - if !strIn(o.Encoding, FlagValues.Encodings) {
72 - return fmt.Errorf("encoding '%s' not %s", o.Encoding, FlagValues.Encodings)
73 - }
74 -
75 - if !strIn(o.Algorithm, FlagValues.Algorithms) {
76 - return fmt.Errorf("algorithm '%s' not %s", o.Algorithm, FlagValues.Algorithms)
77 - }
78 -
79 - var found bool
80 - o.AlgorithmCode, found = mh.Names[o.Algorithm]
81 - if !found {
82 - return fmt.Errorf("algorithm '%s' not found (lib error, pls report).", o.Algorithm)
83 - }
84 -
85 - if o.Length >= 0 {
86 - if o.Length%8 != 0 {
87 - return fmt.Errorf("length must be multiple of 8")
88 - }
89 - o.Length = o.Length / 8
90 -
91 - if o.Length > mh.DefaultLengths[o.AlgorithmCode] {
92 - o.Length = mh.DefaultLengths[o.AlgorithmCode]
93 - }
94 - }
95 - return nil
96 -}
97 -
98 -// strIn checks wither string a is in set.
99 -func strIn(a string, set []string) bool {
100 - for _, s := range set {
101 - if s == a {
102 - return true
103 - }
104 - }
105 - return false
106 -}
107 -
108 -// Check reads all the data in r, calculates its multihash,
109 -// and checks it matches h1
110 -func (o *Options) Check(r io.Reader, h1 mh.Multihash) error {
111 - h2, err := o.Multihash(r)
112 - if err != nil {
113 - return err
114 - }
115 -
116 - if !bytes.Equal(h1, h2) {
117 - return fmt.Errorf("computed checksum did not match")
118 - }
119 -
120 - return nil
121 -}
122 -
123 -// Multihash reads all the data in r and calculates its multihash.
124 -func (o *Options) Multihash(r io.Reader) (mh.Multihash, error) {
125 - b, err := ioutil.ReadAll(r)
126 - if err != nil {
127 - return nil, err
128 - }
129 -
130 - return mh.Sum(b, o.AlgorithmCode, o.Length)
131 -}
Godeps/_workspace/src/github.com/jbenet/go-multihash/sum.go deleted
-72
@@ -1,72 +0,0 @@
1 -package multihash
2 -
3 -import (
4 - "crypto/sha1"
5 - "crypto/sha256"
6 - "crypto/sha512"
7 - "errors"
8 - "fmt"
9 -
10 - sha3 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/crypto/sha3"
11 -)
12 -
13 -var ErrSumNotSupported = errors.New("Function not implemented. Complain to lib maintainer.")
14 -
15 -func Sum(data []byte, code int, length int) (Multihash, error) {
16 - m := Multihash{}
17 - err := error(nil)
18 - if !ValidCode(code) {
19 - return m, fmt.Errorf("invalid multihash code %d", code)
20 - }
21 -
22 - var d []byte
23 - switch code {
24 - case SHA1:
25 - d = sumSHA1(data)
26 - case SHA2_256:
27 - d = sumSHA256(data)
28 - case SHA2_512:
29 - d = sumSHA512(data)
30 - case SHA3:
31 - d, err = sumSHA3(data)
32 - default:
33 - return m, ErrSumNotSupported
34 - }
35 -
36 - if err != nil {
37 - return m, err
38 - }
39 -
40 - if length < 0 {
41 - var ok bool
42 - length, ok = DefaultLengths[code]
43 - if !ok {
44 - return m, fmt.Errorf("no default length for code %d", code)
45 - }
46 - }
47 -
48 - return Encode(d[0:length], code)
49 -}
50 -
51 -func sumSHA1(data []byte) []byte {
52 - a := sha1.Sum(data)
53 - return a[0:20]
54 -}
55 -
56 -func sumSHA256(data []byte) []byte {
57 - a := sha256.Sum256(data)
58 - return a[0:32]
59 -}
60 -
61 -func sumSHA512(data []byte) []byte {
62 - a := sha512.Sum512(data)
63 - return a[0:64]
64 -}
65 -
66 -func sumSHA3(data []byte) ([]byte, error) {
67 - h := sha3.New512()
68 - if _, err := h.Write(data); err != nil {
69 - return nil, err
70 - }
71 - return h.Sum(nil), nil
72 -}
Godeps/_workspace/src/github.com/jbenet/go-multihash/sum_test.go deleted
-66
@@ -1,66 +0,0 @@
1 -package multihash
2 -
3 -import (
4 - "bytes"
5 - "testing"
6 -)
7 -
8 -type SumTestCase struct {
9 - code int
10 - length int
11 - input string
12 - hex string
13 -}
14 -
15 -var sumTestCases = []SumTestCase{
16 - SumTestCase{SHA1, -1, "foo", "11140beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"},
17 - SumTestCase{SHA1, 10, "foo", "110a0beec7b5ea3f0fdbc95d"},
18 - SumTestCase{SHA2_256, -1, "foo", "12202c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae"},
19 - SumTestCase{SHA2_256, 16, "foo", "12102c26b46b68ffc68ff99b453c1d304134"},
20 - SumTestCase{SHA2_512, -1, "foo", "1340f7fbba6e0636f890e56fbbf3283e524c6fa3204ae298382d624741d0dc6638326e282c41be5e4254d8820772c5518a2c5a8c0c7f7eda19594a7eb539453e1ed7"},
21 - SumTestCase{SHA2_512, 32, "foo", "1320f7fbba6e0636f890e56fbbf3283e524c6fa3204ae298382d624741d0dc663832"},
22 -}
23 -
24 -func TestSum(t *testing.T) {
25 -
26 - for _, tc := range sumTestCases {
27 -
28 - m1, err := FromHexString(tc.hex)
29 - if err != nil {
30 - t.Error(err)
31 - continue
32 - }
33 -
34 - m2, err := Sum([]byte(tc.input), tc.code, tc.length)
35 - if err != nil {
36 - t.Error(tc.code, "sum failed.", err)
37 - continue
38 - }
39 -
40 - if !bytes.Equal(m1, m2) {
41 - t.Error(tc.code, "sum failed.", m1, m2)
42 - }
43 -
44 - s1 := m1.HexString()
45 - if s1 != tc.hex {
46 - t.Error("hex strings not the same")
47 - }
48 -
49 - s2 := m1.B58String()
50 - m3, err := FromB58String(s2)
51 - if err != nil {
52 - t.Error("failed to decode b58")
53 - } else if !bytes.Equal(m3, m1) {
54 - t.Error("b58 failing bytes")
55 - } else if s2 != m3.B58String() {
56 - t.Error("b58 failing string")
57 - }
58 - }
59 -}
60 -
61 -func BenchmarkSum(b *testing.B) {
62 - tc := sumTestCases[0]
63 - for i := 0; i < b.N; i++ {
64 - Sum([]byte(tc.input), tc.code, tc.length)
65 - }
66 -}
Godeps/_workspace/src/github.com/jbenet/go-multihash/test/.gitignore deleted
-1
@@ -1 +0,0 @@
1 -bin/multihash
Godeps/_workspace/src/github.com/jbenet/go-multihash/test/Makefile deleted
-25
@@ -1,25 +0,0 @@
1 -BINS = bin/multihash
2 -MULTIHASH_ROOT = ../
3 -MULTIHASH_CMD = ../multihash
4 -
5 -all: deps
6 -
7 -deps: bins
8 -
9 -clean:
10 - rm $(BINS)
11 -
12 -bins: $(BINS)
13 -
14 -bin/multihash: $(MULTIHASH_ROOT)/**/*.go
15 - go build -o bin/multihash $(MULTIHASH_CMD)
16 -
17 -test: test_expensive
18 -
19 -test_expensive:
20 - cd sharness && make TEST_EXPENSIVE=1
21 -
22 -test_cheap:
23 - cd sharness && make
24 -
25 -.PHONY: all clean
Godeps/_workspace/src/github.com/jbenet/go-multihash/test/sharness/.gitignore deleted
-3
@@ -1,3 +0,0 @@
1 -lib/sharness/
2 -test-results/
3 -trash directory.*.sh/
Godeps/_workspace/src/github.com/jbenet/go-multihash/test/sharness/Makefile deleted
-37
@@ -1,37 +0,0 @@
1 -# Run tests
2 -#
3 -# Copyright (c) 2014 Christian Couder
4 -# MIT Licensed; see the LICENSE file in this repository.
5 -#
6 -
7 -# NOTE: run with TEST_VERBOSE=1 for verbose sharness tests.
8 -
9 -T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
10 -BINS = bin/multihash
11 -SHARNESS = lib/sharness/sharness.sh
12 -
13 -all: clean deps $(T) aggregate
14 -
15 -clean:
16 - @echo "*** $@ ***"
17 - -rm -rf test-results
18 -
19 -$(T):
20 - @echo "*** $@ ***"
21 - ./$@
22 -
23 -aggregate:
24 - @echo "*** $@ ***"
25 - lib/test-aggregate-results.sh
26 -
27 -deps: $(SHARNESS) $(BINS)
28 -
29 -$(SHARNESS):
30 - @echo "*** installing $@ ***"
31 - lib/install-sharness.sh
32 -
33 -bin/%:
34 - @echo "*** installing $@ ***"
35 - cd .. && make $@
36 -
37 -.PHONY: all clean $(T) aggregate
Godeps/_workspace/src/github.com/jbenet/go-multihash/test/sharness/bin deleted
-1
@@ -1 +0,0 @@
1 -../bin
\ No newline at end of file
Godeps/_workspace/src/github.com/jbenet/go-multihash/test/sharness/lib/install-sharness.sh deleted
-26
@@ -1,26 +0,0 @@
1 -#!/bin/sh
2 -# install sharness.sh
3 -#
4 -# Copyright (c) 2014 Juan Batiz-Benet
5 -# MIT Licensed; see the LICENSE file in this repository.
6 -#
7 -
8 -# settings
9 -version=50229a79ba22b2f13ccd82451d86570fecbd194c
10 -urlprefix=https://github.com/mlafeldt/sharness.git
11 -clonedir=lib
12 -sharnessdir=sharness
13 -
14 -die() {
15 - echo >&2 "$@"
16 - exit 1
17 -}
18 -
19 -mkdir -p "$clonedir" || die "Could not create '$clonedir' directory"
20 -cd "$clonedir" || die "Could not cd into '$clonedir' directory"
21 -
22 -git clone "$urlprefix" || die "Could not clone '$urlprefix'"
23 -cd "$sharnessdir" || die "Could not cd into '$sharnessdir' directory"
24 -git checkout "$version" || die "Could not checkout '$version'"
25 -
26 -exit 0
Godeps/_workspace/src/github.com/jbenet/go-multihash/test/sharness/lib/test-aggregate-results.sh deleted
-17
@@ -1,17 +0,0 @@
1 -#!/bin/sh
2 -#
3 -# Script to aggregate results using Sharness
4 -#
5 -# Copyright (c) 2014 Christian Couder
6 -# MIT Licensed; see the LICENSE file in this repository.
7 -#
8 -
9 -SHARNESS_AGGREGATE="lib/sharness/aggregate-results.sh"
10 -
11 -test -f "$SHARNESS_AGGREGATE" || {
12 - echo >&2 "Cannot find: $SHARNESS_AGGREGATE"
13 - echo >&2 "Please check Sharness installation."
14 - exit 1
15 -}
16 -
17 -ls test-results/t*-*.sh.*.counts | "$SHARNESS_AGGREGATE"
Godeps/_workspace/src/github.com/jbenet/go-multihash/test/sharness/lib/test-lib.sh deleted
-43
@@ -1,43 +0,0 @@
1 -# Test framework for go-ipfs
2 -#
3 -# Copyright (c) 2014 Christian Couder
4 -# MIT Licensed; see the LICENSE file in this repository.
5 -#
6 -# We are using sharness (https://github.com/mlafeldt/sharness)
7 -# which was extracted from the Git test framework.
8 -
9 -# Use the multihash tool to test against
10 -
11 -# Add current directory to path, for multihash tool.
12 -PATH=$(pwd)/bin:${PATH}
13 -
14 -# Set sharness verbosity. we set the env var directly as
15 -# it's too late to pass in --verbose, and --verbose is harder
16 -# to pass through in some cases.
17 -test "$TEST_VERBOSE" = 1 && verbose=t
18 -
19 -# assert the `multihash` we're using is the right one.
20 -if test `which multihash` != $(pwd)/bin/multihash; then
21 - echo >&2 "Cannot find the tests' local multihash tool."
22 - echo >&2 "Please check test and multihash tool installation."
23 - exit 1
24 -fi
25 -
26 -SHARNESS_LIB="lib/sharness/sharness.sh"
27 -
28 -. "$SHARNESS_LIB" || {
29 - echo >&2 "Cannot source: $SHARNESS_LIB"
30 - echo >&2 "Please check Sharness installation."
31 - exit 1
32 -}
33 -
34 -# Please put go-multihash specific shell functions below
35 -
36 -for hashbin in sha1sum shasum; do
37 - if type "$hashbin"; then
38 - export SHASUMBIN="$hashbin" &&
39 - test_set_prereq SHASUM &&
40 - break
41 - fi
42 -done
43 -
Godeps/_workspace/src/github.com/jbenet/go-multihash/test/sharness/t0010-basics.sh deleted
-25
@@ -1,25 +0,0 @@
1 -#!/bin/sh
2 -#
3 -# Copyright (c) 2015 Christian Couder
4 -# MIT Licensed; see the LICENSE file in this repository.
5 -#
6 -
7 -test_description="Basic tests"
8 -
9 -. lib/test-lib.sh
10 -
11 -test_expect_success "current dir is writable" '
12 - echo "It works!" >test.txt
13 -'
14 -
15 -test_expect_success "multihash is available" '
16 - type multihash
17 -'
18 -
19 -test_expect_success "multihash help output looks good" '
20 - test_must_fail multihash -h 2>help.txt &&
21 - cat help.txt | egrep -i "^usage:" >/dev/null &&
22 - cat help.txt | egrep -i "multihash .*options.*file" >/dev/null
23 -'
24 -
25 -test_done
Godeps/_workspace/src/github.com/jbenet/go-multihash/test/sharness/t0020-sha1.sh deleted
-31
@@ -1,31 +0,0 @@
1 -#!/bin/sh
2 -#
3 -# Copyright (c) 2015 Christian Couder
4 -# MIT Licensed; see the LICENSE file in this repository.
5 -#
6 -
7 -test_description="sha1 tests"
8 -
9 -. lib/test-lib.sh
10 -
11 -test_expect_success "setup sha1 tests" '
12 - echo "Hash me!" >hash_me.txt &&
13 - SHA1=bc6f2c3cd945bc754789e50b2f68deee2f421810 &&
14 - echo "1114$SHA1" >actual
15 -'
16 -
17 -test_expect_success "'multihash -a=sha1 -e=hex' works" '
18 - multihash -a=sha1 -e=hex hash_me.txt >expected
19 -'
20 -
21 -test_expect_success "'multihash -a=sha1 -e=hex' output looks good" '
22 - test_cmp expected actual
23 -'
24 -
25 -test_expect_success SHASUM "check hash using shasum" '
26 - echo "$SHA1 hash_me.txt" >actual &&
27 - $SHASUMBIN hash_me.txt >expected &&
28 - test_cmp expected actual
29 -'
30 -
31 -test_done
Godeps/_workspace/src/github.com/matttproud/golang_protobuf_extensions/pbutil/all_test.go deleted
-320
@@ -1,320 +0,0 @@
1 -// Copyright 2013 Matt T. Proud
2 -//
3 -// Licensed under the Apache License, Version 2.0 (the "License");
4 -// you may not use this file except in compliance with the License.
5 -// You may obtain a copy of the License at
6 -//
7 -// http://www.apache.org/licenses/LICENSE-2.0
8 -//
9 -// Unless required by applicable law or agreed to in writing, software
10 -// distributed under the License is distributed on an "AS IS" BASIS,
11 -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 -// See the License for the specific language governing permissions and
13 -// limitations under the License.
14 -
15 -package pbutil
16 -
17 -import (
18 - "bytes"
19 - "math/rand"
20 - "reflect"
21 - "testing"
22 - "testing/quick"
23 -
24 - "github.com/matttproud/golang_protobuf_extensions/pbtest"
25 -
26 - . "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/golang/protobuf/proto"
27 - . "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/golang/protobuf/proto/testdata"
28 -)
29 -
30 -func TestWriteDelimited(t *testing.T) {
31 - for _, test := range []struct {
32 - msg Message
33 - buf []byte
34 - n int
35 - err error
36 - }{
37 - {
38 - msg: &Empty{},
39 - n: 1,
40 - buf: []byte{0},
41 - },
42 - {
43 - msg: &GoEnum{Foo: FOO_FOO1.Enum()},
44 - n: 3,
45 - buf: []byte{2, 8, 1},
46 - },
47 - {
48 - msg: &Strings{
49 - StringField: String(`This is my gigantic, unhappy string. It exceeds
50 -the encoding size of a single byte varint. We are using it to fuzz test the
51 -correctness of the header decoding mechanisms, which may prove problematic.
52 -I expect it may. Let's hope you enjoy testing as much as we do.`),
53 - },
54 - n: 271,
55 - buf: []byte{141, 2, 10, 138, 2, 84, 104, 105, 115, 32, 105, 115, 32, 109,
56 - 121, 32, 103, 105, 103, 97, 110, 116, 105, 99, 44, 32, 117, 110, 104,
57 - 97, 112, 112, 121, 32, 115, 116, 114, 105, 110, 103, 46, 32, 32, 73,
58 - 116, 32, 101, 120, 99, 101, 101, 100, 115, 10, 116, 104, 101, 32, 101,
59 - 110, 99, 111, 100, 105, 110, 103, 32, 115, 105, 122, 101, 32, 111, 102,
60 - 32, 97, 32, 115, 105, 110, 103, 108, 101, 32, 98, 121, 116, 101, 32,
61 - 118, 97, 114, 105, 110, 116, 46, 32, 32, 87, 101, 32, 97, 114, 101, 32,
62 - 117, 115, 105, 110, 103, 32, 105, 116, 32, 116, 111, 32, 102, 117, 122,
63 - 122, 32, 116, 101, 115, 116, 32, 116, 104, 101, 10, 99, 111, 114, 114,
64 - 101, 99, 116, 110, 101, 115, 115, 32, 111, 102, 32, 116, 104, 101, 32,
65 - 104, 101, 97, 100, 101, 114, 32, 100, 101, 99, 111, 100, 105, 110, 103,
66 - 32, 109, 101, 99, 104, 97, 110, 105, 115, 109, 115, 44, 32, 119, 104,
67 - 105, 99, 104, 32, 109, 97, 121, 32, 112, 114, 111, 118, 101, 32, 112,
68 - 114, 111, 98, 108, 101, 109, 97, 116, 105, 99, 46, 10, 73, 32, 101, 120,
69 - 112, 101, 99, 116, 32, 105, 116, 32, 109, 97, 121, 46, 32, 32, 76, 101,
70 - 116, 39, 115, 32, 104, 111, 112, 101, 32, 121, 111, 117, 32, 101, 110,
71 - 106, 111, 121, 32, 116, 101, 115, 116, 105, 110, 103, 32, 97, 115, 32,
72 - 109, 117, 99, 104, 32, 97, 115, 32, 119, 101, 32, 100, 111, 46},
73 - },
74 - } {
75 - var buf bytes.Buffer
76 - if n, err := WriteDelimited(&buf, test.msg); n != test.n || err != test.err {
77 - t.Fatalf("WriteDelimited(buf, %#v) = %v, %v; want %v, %v", test.msg, n, err, test.n, test.err)
78 - }
79 - if out := buf.Bytes(); !bytes.Equal(out, test.buf) {
80 - t.Fatalf("WriteDelimited(buf, %#v); buf = %v; want %v", test.msg, out, test.buf)
81 - }
82 - }
83 -}
84 -
85 -func TestReadDelimited(t *testing.T) {
86 - for _, test := range []struct {
87 - buf []byte
88 - msg Message
89 - n int
90 - err error
91 - }{
92 - {
93 - buf: []byte{0},
94 - msg: &Empty{},
95 - n: 1,
96 - },
97 - {
98 - n: 3,
99 - buf: []byte{2, 8, 1},
100 - msg: &GoEnum{Foo: FOO_FOO1.Enum()},
101 - },
102 - {
103 - buf: []byte{141, 2, 10, 138, 2, 84, 104, 105, 115, 32, 105, 115, 32, 109,
104 - 121, 32, 103, 105, 103, 97, 110, 116, 105, 99, 44, 32, 117, 110, 104,
105 - 97, 112, 112, 121, 32, 115, 116, 114, 105, 110, 103, 46, 32, 32, 73,
106 - 116, 32, 101, 120, 99, 101, 101, 100, 115, 10, 116, 104, 101, 32, 101,
107 - 110, 99, 111, 100, 105, 110, 103, 32, 115, 105, 122, 101, 32, 111, 102,
108 - 32, 97, 32, 115, 105, 110, 103, 108, 101, 32, 98, 121, 116, 101, 32,
109 - 118, 97, 114, 105, 110, 116, 46, 32, 32, 87, 101, 32, 97, 114, 101, 32,
110 - 117, 115, 105, 110, 103, 32, 105, 116, 32, 116, 111, 32, 102, 117, 122,
111 - 122, 32, 116, 101, 115, 116, 32, 116, 104, 101, 10, 99, 111, 114, 114,
112 - 101, 99, 116, 110, 101, 115, 115, 32, 111, 102, 32, 116, 104, 101, 32,
113 - 104, 101, 97, 100, 101, 114, 32, 100, 101, 99, 111, 100, 105, 110, 103,
114 - 32, 109, 101, 99, 104, 97, 110, 105, 115, 109, 115, 44, 32, 119, 104,
115 - 105, 99, 104, 32, 109, 97, 121, 32, 112, 114, 111, 118, 101, 32, 112,
116 - 114, 111, 98, 108, 101, 109, 97, 116, 105, 99, 46, 10, 73, 32, 101, 120,
117 - 112, 101, 99, 116, 32, 105, 116, 32, 109, 97, 121, 46, 32, 32, 76, 101,
118 - 116, 39, 115, 32, 104, 111, 112, 101, 32, 121, 111, 117, 32, 101, 110,
119 - 106, 111, 121, 32, 116, 101, 115, 116, 105, 110, 103, 32, 97, 115, 32,
120 - 109, 117, 99, 104, 32, 97, 115, 32, 119, 101, 32, 100, 111, 46},
121 - msg: &Strings{
122 - StringField: String(`This is my gigantic, unhappy string. It exceeds
123 -the encoding size of a single byte varint. We are using it to fuzz test the
124 -correctness of the header decoding mechanisms, which may prove problematic.
125 -I expect it may. Let's hope you enjoy testing as much as we do.`),
126 - },
127 - n: 271,
128 - },
129 - } {
130 - msg := Clone(test.msg)
131 - msg.Reset()
132 - if n, err := ReadDelimited(bytes.NewBuffer(test.buf), msg); n != test.n || err != test.err {
133 - t.Fatalf("ReadDelimited(%v, msg) = %v, %v; want %v, %v", test.buf, n, err, test.n, test.err)
134 - }
135 - if !Equal(msg, test.msg) {
136 - t.Fatalf("ReadDelimited(%v, msg); msg = %v; want %v", test.buf, msg, test.msg)
137 - }
138 - }
139 -}
140 -
141 -func TestEndToEndValid(t *testing.T) {
142 - for _, test := range [][]Message{
143 - {&Empty{}},
144 - {&GoEnum{Foo: FOO_FOO1.Enum()}, &Empty{}, &GoEnum{Foo: FOO_FOO1.Enum()}},
145 - {&GoEnum{Foo: FOO_FOO1.Enum()}},
146 - {&Strings{
147 - StringField: String(`This is my gigantic, unhappy string. It exceeds
148 -the encoding size of a single byte varint. We are using it to fuzz test the
149 -correctness of the header decoding mechanisms, which may prove problematic.
150 -I expect it may. Let's hope you enjoy testing as much as we do.`),
151 - }},
152 - } {
153 - var buf bytes.Buffer
154 - var written int
155 - for i, msg := range test {
156 - n, err := WriteDelimited(&buf, msg)
157 - if err != nil {
158 - // Assumption: TestReadDelimited and TestWriteDelimited are sufficient
159 - // and inputs for this test are explicitly exercised there.
160 - t.Fatalf("WriteDelimited(buf, %v[%d]) = ?, %v; wanted ?, nil", test, i, err)
161 - }
162 - written += n
163 - }
164 - var read int
165 - for i, msg := range test {
166 - out := Clone(msg)
167 - out.Reset()
168 - n, _ := ReadDelimited(&buf, out)
169 - // Decide to do EOF checking?
170 - read += n
171 - if !Equal(out, msg) {
172 - t.Fatalf("out = %v; want %v[%d] = %#v", out, test, i, msg)
173 - }
174 - }
175 - if read != written {
176 - t.Fatalf("%v read = %d; want %d", test, read, written)
177 - }
178 - }
179 -}
180 -
181 -// rndMessage generates a random valid Protocol Buffer message.
182 -func rndMessage(r *rand.Rand) Message {
183 - var t reflect.Type
184 - switch v := rand.Intn(23); v {
185 - // TODO(br): Uncomment the elements below once fix is incorporated, except
186 - // for the elements marked as patently incompatible.
187 - // case 0:
188 - // t = reflect.TypeOf(&GoEnum{})
189 - // break
190 - // case 1:
191 - // t = reflect.TypeOf(&GoTestField{})
192 - // break
193 - case 2:
194 - t = reflect.TypeOf(&GoTest{})
195 - break
196 - // case 3:
197 - // t = reflect.TypeOf(&GoSkipTest{})
198 - // break
199 - // case 4:
200 - // t = reflect.TypeOf(&NonPackedTest{})
201 - // break
202 - // case 5:
203 - // t = reflect.TypeOf(&PackedTest{})
204 - // break
205 - case 6:
206 - t = reflect.TypeOf(&MaxTag{})
207 - break
208 - case 7:
209 - t = reflect.TypeOf(&OldMessage{})
210 - break
211 - case 8:
212 - t = reflect.TypeOf(&NewMessage{})
213 - break
214 - case 9:
215 - t = reflect.TypeOf(&InnerMessage{})
216 - break
217 - case 10:
218 - t = reflect.TypeOf(&OtherMessage{})
219 - break
220 - case 11:
221 - // PATENTLY INVALID FOR FUZZ GENERATION
222 - // t = reflect.TypeOf(&MyMessage{})
223 - break
224 - // case 12:
225 - // t = reflect.TypeOf(&Ext{})
226 - // break
227 - case 13:
228 - // PATENTLY INVALID FOR FUZZ GENERATION
229 - // t = reflect.TypeOf(&MyMessageSet{})
230 - break
231 - // case 14:
232 - // t = reflect.TypeOf(&Empty{})
233 - // break
234 - // case 15:
235 - // t = reflect.TypeOf(&MessageList{})
236 - // break
237 - // case 16:
238 - // t = reflect.TypeOf(&Strings{})
239 - // break
240 - // case 17:
241 - // t = reflect.TypeOf(&Defaults{})
242 - // break
243 - // case 17:
244 - // t = reflect.TypeOf(&SubDefaults{})
245 - // break
246 - // case 18:
247 - // t = reflect.TypeOf(&RepeatedEnum{})
248 - // break
249 - case 19:
250 - t = reflect.TypeOf(&MoreRepeated{})
251 - break
252 - // case 20:
253 - // t = reflect.TypeOf(&GroupOld{})
254 - // break
255 - // case 21:
256 - // t = reflect.TypeOf(&GroupNew{})
257 - // break
258 - case 22:
259 - t = reflect.TypeOf(&FloatingPoint{})
260 - break
261 - default:
262 - // TODO(br): Replace with an unreachable once fixed.
263 - t = reflect.TypeOf(&GoTest{})
264 - break
265 - }
266 - if t == nil {
267 - t = reflect.TypeOf(&GoTest{})
268 - }
269 - v, ok := quick.Value(t, r)
270 - if !ok {
271 - panic("attempt to generate illegal item; consult item 11")
272 - }
273 - if err := pbtest.SanitizeGenerated(v.Interface().(Message)); err != nil {
274 - panic(err)
275 - }
276 - return v.Interface().(Message)
277 -}
278 -
279 -// rndMessages generates several random Protocol Buffer messages.
280 -func rndMessages(r *rand.Rand) []Message {
281 - n := r.Intn(128)
282 - out := make([]Message, 0, n)
283 - for i := 0; i < n; i++ {
284 - out = append(out, rndMessage(r))
285 - }
286 - return out
287 -}
288 -
289 -func TestFuzz(t *testing.T) {
290 - rnd := rand.New(rand.NewSource(42))
291 - check := func() bool {
292 - messages := rndMessages(rnd)
293 - var buf bytes.Buffer
294 - var written int
295 - for i, msg := range messages {
296 - n, err := WriteDelimited(&buf, msg)
297 - if err != nil {
298 - t.Fatalf("WriteDelimited(buf, %v[%d]) = ?, %v; wanted ?, nil", messages, i, err)
299 - }
300 - written += n
301 - }
302 - var read int
303 - for i, msg := range messages {
304 - out := Clone(msg)
305 - out.Reset()
306 - n, _ := ReadDelimited(&buf, out)
307 - read += n
308 - if !Equal(out, msg) {
309 - t.Fatalf("out = %v; want %v[%d] = %#v", out, messages, i, msg)
310 - }
311 - }
312 - if read != written {
313 - t.Fatalf("%v read = %d; want %d", messages, read, written)
314 - }
315 - return true
316 - }
317 - if err := quick.Check(check, nil); err != nil {
318 - t.Fatal(err)
319 - }
320 -}
Godeps/_workspace/src/github.com/matttproud/golang_protobuf_extensions/pbutil/decode.go deleted
-75
@@ -1,75 +0,0 @@
1 -// Copyright 2013 Matt T. Proud
2 -//
3 -// Licensed under the Apache License, Version 2.0 (the "License");
4 -// you may not use this file except in compliance with the License.
5 -// You may obtain a copy of the License at
6 -//
7 -// http://www.apache.org/licenses/LICENSE-2.0
8 -//
9 -// Unless required by applicable law or agreed to in writing, software
10 -// distributed under the License is distributed on an "AS IS" BASIS,
11 -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 -// See the License for the specific language governing permissions and
13 -// limitations under the License.
14 -
15 -package pbutil
16 -
17 -import (
18 - "encoding/binary"
19 - "errors"
20 - "io"
21 -
22 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/golang/protobuf/proto"
23 -)
24 -
25 -var errInvalidVarint = errors.New("invalid varint32 encountered")
26 -
27 -// ReadDelimited decodes a message from the provided length-delimited stream,
28 -// where the length is encoded as 32-bit varint prefix to the message body.
29 -// It returns the total number of bytes read and any applicable error. This is
30 -// roughly equivalent to the companion Java API's
31 -// MessageLite#parseDelimitedFrom. As per the reader contract, this function
32 -// calls r.Read repeatedly as required until exactly one message including its
33 -// prefix is read and decoded (or an error has occurred). The function never
34 -// reads more bytes from the stream than required. The function never returns
35 -// an error if a message has been read and decoded correctly, even if the end
36 -// of the stream has been reached in doing so. In that case, any subsequent
37 -// calls return (0, io.EOF).
38 -func ReadDelimited(r io.Reader, m proto.Message) (n int, err error) {
39 - // Per AbstractParser#parsePartialDelimitedFrom with
40 - // CodedInputStream#readRawVarint32.
41 - headerBuf := make([]byte, binary.MaxVarintLen32)
42 - var bytesRead, varIntBytes int
43 - var messageLength uint64
44 - for varIntBytes == 0 { // i.e. no varint has been decoded yet.
45 - if bytesRead >= len(headerBuf) {
46 - return bytesRead, errInvalidVarint
47 - }
48 - // We have to read byte by byte here to avoid reading more bytes
49 - // than required. Each read byte is appended to what we have
50 - // read before.
51 - newBytesRead, err := r.Read(headerBuf[bytesRead : bytesRead+1])
52 - if newBytesRead == 0 {
53 - if err != nil {
54 - return bytesRead, err
55 - }
56 - // A Reader should not return (0, nil), but if it does,
57 - // it should be treated as no-op (according to the
58 - // Reader contract). So let's go on...
59 - continue
60 - }
61 - bytesRead += newBytesRead
62 - // Now present everything read so far to the varint decoder and
63 - // see if a varint can be decoded already.
64 - messageLength, varIntBytes = proto.DecodeVarint(headerBuf[:bytesRead])
65 - }
66 -
67 - messageBuf := make([]byte, messageLength)
68 - newBytesRead, err := io.ReadFull(r, messageBuf)
69 - bytesRead += newBytesRead
70 - if err != nil {
71 - return bytesRead, err
72 - }
73 -
74 - return bytesRead, proto.Unmarshal(messageBuf, m)
75 -}
Godeps/_workspace/src/github.com/matttproud/golang_protobuf_extensions/pbutil/doc.go deleted
-16
@@ -1,16 +0,0 @@
1 -// Copyright 2013 Matt T. Proud
2 -//
3 -// Licensed under the Apache License, Version 2.0 (the "License");
4 -// you may not use this file except in compliance with the License.
5 -// You may obtain a copy of the License at
6 -//
7 -// http://www.apache.org/licenses/LICENSE-2.0
8 -//
9 -// Unless required by applicable law or agreed to in writing, software
10 -// distributed under the License is distributed on an "AS IS" BASIS,
11 -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 -// See the License for the specific language governing permissions and
13 -// limitations under the License.
14 -
15 -// Package pbutil provides record length-delimited Protocol Buffer streaming.
16 -package pbutil
Godeps/_workspace/src/github.com/matttproud/golang_protobuf_extensions/pbutil/encode.go deleted
-46
@@ -1,46 +0,0 @@
1 -// Copyright 2013 Matt T. Proud
2 -//
3 -// Licensed under the Apache License, Version 2.0 (the "License");
4 -// you may not use this file except in compliance with the License.
5 -// You may obtain a copy of the License at
6 -//
7 -// http://www.apache.org/licenses/LICENSE-2.0
8 -//
9 -// Unless required by applicable law or agreed to in writing, software
10 -// distributed under the License is distributed on an "AS IS" BASIS,
11 -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 -// See the License for the specific language governing permissions and
13 -// limitations under the License.
14 -
15 -package pbutil
16 -
17 -import (
18 - "encoding/binary"
19 - "io"
20 -
21 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/golang/protobuf/proto"
22 -)
23 -
24 -// WriteDelimited encodes and dumps a message to the provided writer prefixed
25 -// with a 32-bit varint indicating the length of the encoded message, producing
26 -// a length-delimited record stream, which can be used to chain together
27 -// encoded messages of the same type together in a file. It returns the total
28 -// number of bytes written and any applicable error. This is roughly
29 -// equivalent to the companion Java API's MessageLite#writeDelimitedTo.
30 -func WriteDelimited(w io.Writer, m proto.Message) (n int, err error) {
31 - buffer, err := proto.Marshal(m)
32 - if err != nil {
33 - return 0, err
34 - }
35 -
36 - buf := make([]byte, binary.MaxVarintLen32)
37 - encodedLength := binary.PutUvarint(buf, uint64(len(buffer)))
38 -
39 - sync, err := w.Write(buf[:encodedLength])
40 - if err != nil {
41 - return sync, err
42 - }
43 -
44 - n, err = w.Write(buffer)
45 - return n + sync, err
46 -}
Godeps/_workspace/src/github.com/matttproud/golang_protobuf_extensions/pbutil/fixtures_test.go deleted
-103
@@ -1,103 +0,0 @@
1 -// Copyright 2010 The Go Authors. All rights reserved.
2 -// http://github.com/golang/protobuf/
3 -//
4 -// Redistribution and use in source and binary forms, with or without
5 -// modification, are permitted provided that the following conditions are
6 -// met:
7 -//
8 -// * Redistributions of source code must retain the above copyright
9 -// notice, this list of conditions and the following disclaimer.
10 -// * Redistributions in binary form must reproduce the above
11 -// copyright notice, this list of conditions and the following disclaimer
12 -// in the documentation and/or other materials provided with the
13 -// distribution.
14 -// * Neither the name of Google Inc. nor the names of its
15 -// contributors may be used to endorse or promote products derived from
16 -// this software without specific prior written permission.
17 -//
18 -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 -
30 -package pbutil
31 -
32 -import (
33 - . "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/golang/protobuf/proto"
34 - . "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/golang/protobuf/proto/testdata"
35 -)
36 -
37 -// FROM https://github.com/golang/protobuf/blob/master/proto/all_test.go.
38 -
39 -func initGoTestField() *GoTestField {
40 - f := new(GoTestField)
41 - f.Label = String("label")
42 - f.Type = String("type")
43 - return f
44 -}
45 -
46 -// These are all structurally equivalent but the tag numbers differ.
47 -// (It's remarkable that required, optional, and repeated all have
48 -// 8 letters.)
49 -func initGoTest_RequiredGroup() *GoTest_RequiredGroup {
50 - return &GoTest_RequiredGroup{
51 - RequiredField: String("required"),
52 - }
53 -}
54 -
55 -func initGoTest_OptionalGroup() *GoTest_OptionalGroup {
56 - return &GoTest_OptionalGroup{
57 - RequiredField: String("optional"),
58 - }
59 -}
60 -
61 -func initGoTest_RepeatedGroup() *GoTest_RepeatedGroup {
62 - return &GoTest_RepeatedGroup{
63 - RequiredField: String("repeated"),
64 - }
65 -}
66 -
67 -func initGoTest(setdefaults bool) *GoTest {
68 - pb := new(GoTest)
69 - if setdefaults {
70 - pb.F_BoolDefaulted = Bool(Default_GoTest_F_BoolDefaulted)
71 - pb.F_Int32Defaulted = Int32(Default_GoTest_F_Int32Defaulted)
72 - pb.F_Int64Defaulted = Int64(Default_GoTest_F_Int64Defaulted)
73 - pb.F_Fixed32Defaulted = Uint32(Default_GoTest_F_Fixed32Defaulted)
74 - pb.F_Fixed64Defaulted = Uint64(Default_GoTest_F_Fixed64Defaulted)
75 - pb.F_Uint32Defaulted = Uint32(Default_GoTest_F_Uint32Defaulted)
76 - pb.F_Uint64Defaulted = Uint64(Default_GoTest_F_Uint64Defaulted)
77 - pb.F_FloatDefaulted = Float32(Default_GoTest_F_FloatDefaulted)
78 - pb.F_DoubleDefaulted = Float64(Default_GoTest_F_DoubleDefaulted)
79 - pb.F_StringDefaulted = String(Default_GoTest_F_StringDefaulted)
80 - pb.F_BytesDefaulted = Default_GoTest_F_BytesDefaulted
81 - pb.F_Sint32Defaulted = Int32(Default_GoTest_F_Sint32Defaulted)
82 - pb.F_Sint64Defaulted = Int64(Default_GoTest_F_Sint64Defaulted)
83 - }
84 -
85 - pb.Kind = GoTest_TIME.Enum()
86 - pb.RequiredField = initGoTestField()
87 - pb.F_BoolRequired = Bool(true)
88 - pb.F_Int32Required = Int32(3)
89 - pb.F_Int64Required = Int64(6)
90 - pb.F_Fixed32Required = Uint32(32)
91 - pb.F_Fixed64Required = Uint64(64)
92 - pb.F_Uint32Required = Uint32(3232)
93 - pb.F_Uint64Required = Uint64(6464)
94 - pb.F_FloatRequired = Float32(3232)
95 - pb.F_DoubleRequired = Float64(6464)
96 - pb.F_StringRequired = String("string")
97 - pb.F_BytesRequired = []byte("bytes")
98 - pb.F_Sint32Required = Int32(-32)
99 - pb.F_Sint64Required = Int64(-64)
100 - pb.Requiredgroup = initGoTest_RequiredGroup()
101 -
102 - return pb
103 -}
Godeps/_workspace/src/github.com/olekukonko/ts/.travis.yml deleted
-6
@@ -1,6 +0,0 @@
1 -language: go
2 -
3 -go:
4 - - 1.1
5 - - 1.2
6 - - tip
\ No newline at end of file
Godeps/_workspace/src/github.com/olekukonko/ts/LICENCE deleted
-19
@@ -1,19 +0,0 @@
1 -Copyright (C) 2014 by Oleku Konko
2 -
3 -Permission is hereby granted, free of charge, to any person obtaining a copy
4 -of this software and associated documentation files (the "Software"), to deal
5 -in the Software without restriction, including without limitation the rights
6 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 -copies of the Software, and to permit persons to whom the Software is
8 -furnished to do so, subject to the following conditions:
9 -
10 -The above copyright notice and this permission notice shall be included in
11 -all copies or substantial portions of the Software.
12 -
13 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 -THE SOFTWARE.
\ No newline at end of file
Godeps/_workspace/src/github.com/olekukonko/ts/README.md deleted
-28
@@ -1,28 +0,0 @@
1 -ts (Terminal Size)
2 -==
3 -
4 -[![Build Status](https://travis-ci.org/olekukonko/ts.png?branch=master)](https://travis-ci.org/olekukonko/ts) [![Total views](https://sourcegraph.com/api/repos/github.com/olekukonko/ts/counters/views.png)](https://sourcegraph.com/github.com/olekukonko/ts)
5 -
6 -Simple go Application to get Terminal Size. So Many Implementations do not support windows but `ts` has full windows support.
7 -Run `go get github.com/olekukonko/ts` to download and install
8 -
9 -#### Example
10 -
11 -```go
12 -package main
13 -
14 -import (
15 - "fmt"
16 - "github.com/olekukonko/ts"
17 -)
18 -
19 -func main() {
20 - size, _ := ts.GetSize()
21 - fmt.Println(size.Col()) // Get Width
22 - fmt.Println(size.Row()) // Get Height
23 - fmt.Println(size.PosX()) // Get X position
24 - fmt.Println(size.PosY()) // Get Y position
25 -}
26 -```
27 -
28 -[See Documentation](http://godoc.org/github.com/olekukonko/ts)
Godeps/_workspace/src/github.com/olekukonko/ts/doc.go deleted
-36
@@ -1,36 +0,0 @@
1 -// Copyright 2014 Oleku Konko All rights reserved.
2 -// Use of this source code is governed by a MIT
3 -// license that can be found in the LICENSE file.
4 -
5 -// This module is a Terminal API for the Go Programming Language.
6 -// The protocols were written in pure Go and works on windows and unix systems
7 -
8 -/**
9 -
10 -Simple go Application to get Terminal Size. So Many Implementations do not support windows but `ts` has full windows support.
11 -Run `go get github.com/olekukonko/ts` to download and install
12 -
13 -Installation
14 -
15 -Minimum requirements are Go 1.1+ with fill Windows support
16 -
17 -Example
18 -
19 - package main
20 -
21 - import (
22 - "fmt"
23 - "github.com/olekukonko/ts"
24 - )
25 -
26 - func main() {
27 - size, _ := ts.GetSize()
28 - fmt.Println(size.Col()) // Get Width
29 - fmt.Println(size.Row()) // Get Height
30 - fmt.Println(size.PosX()) // Get X position
31 - fmt.Println(size.PosY()) // Get Y position
32 - }
33 -
34 -**/
35 -
36 -package ts
Godeps/_workspace/src/github.com/olekukonko/ts/ts.go deleted
-36
@@ -1,36 +0,0 @@
1 -// Copyright 2014 Oleku Konko All rights reserved.
2 -// Use of this source code is governed by a MIT
3 -// license that can be found in the LICENSE file.
4 -
5 -// This module is a Terminal API for the Go Programming Language.
6 -// The protocols were written in pure Go and works on windows and unix systems
7 -
8 -package ts
9 -
10 -// Return System Size
11 -type Size struct {
12 - row uint16
13 - col uint16
14 - posX uint16
15 - posY uint16
16 -}
17 -
18 -// Get Terminal Width
19 -func (w Size) Col() int {
20 - return int(w.col)
21 -}
22 -
23 -// Get Terminal Height
24 -func (w Size) Row() int {
25 - return int(w.row)
26 -}
27 -
28 -// Get Position X
29 -func (w Size) PosX() int {
30 - return int(w.posX)
31 -}
32 -
33 -// Get Position Y
34 -func (w Size) PosY() int {
35 - return int(w.posY)
36 -}
Godeps/_workspace/src/github.com/olekukonko/ts/ts_darwin.go deleted
-14
@@ -1,14 +0,0 @@
1 -// +build darwin
2 -
3 -// Copyright 2014 Oleku Konko All rights reserved.
4 -// Use of this source code is governed by a MIT
5 -// license that can be found in the LICENSE file.
6 -
7 -// This module is a Terminal API for the Go Programming Language.
8 -// The protocols were written in pure Go and works on windows and unix systems
9 -
10 -package ts
11 -
12 -const (
13 - TIOCGWINSZ = 0x40087468
14 -)
Godeps/_workspace/src/github.com/olekukonko/ts/ts_linux.go deleted
-13
@@ -1,13 +0,0 @@
1 -// +build linux
2 -
3 -// Copyright 2014 Oleku Konko All rights reserved.
4 -// Use of this source code is governed by a MIT
5 -// license that can be found in the LICENSE file.
6 -
7 -// This module is a Terminal API for the Go Programming Language.
8 -// The protocols were written in pure Go and works on windows and unix systems
9 -package ts
10 -
11 -const (
12 - TIOCGWINSZ = 0x5413
13 -)
Godeps/_workspace/src/github.com/olekukonko/ts/ts_other.go deleted
-14
@@ -1,14 +0,0 @@
1 -// +build !windows,!darwin,!freebsd,!netbsd,!openbsd,!linux
2 -
3 -// Copyright 2014 Oleku Konko All rights reserved.
4 -// Use of this source code is governed by a MIT
5 -// license that can be found in the LICENSE file.
6 -
7 -// This module is a Terminal API for the Go Programming Language.
8 -// The protocols were written in pure Go and works on windows and unix systems
9 -
10 -package ts
11 -
12 -const (
13 - TIOCGWINSZ = 0
14 -)
Godeps/_workspace/src/github.com/olekukonko/ts/ts_test.go deleted
-32
@@ -1,32 +0,0 @@
1 -// Copyright 2014 Oleku Konko All rights reserved.
2 -// Use of this source code is governed by a MIT
3 -// license that can be found in the LICENSE file.
4 -
5 -// This module is a Terminal API for the Go Programming Language.
6 -// The protocols were written in pure Go and works on windows and unix systems
7 -
8 -package ts
9 -
10 -import (
11 - "fmt"
12 - "testing"
13 -)
14 -
15 -func ExampleGetSize() {
16 - size, _ := GetSize()
17 - fmt.Println(size.Col()) // Get Width
18 - fmt.Println(size.Row()) // Get Height
19 - fmt.Println(size.PosX()) // Get X position
20 - fmt.Println(size.PosY()) // Get Y position
21 -}
22 -
23 -func TestSize(t *testing.T) {
24 - size, err := GetSize()
25 -
26 - if err != nil {
27 - t.Fatal(err)
28 - }
29 - if size.Col() == 0 || size.Row() == 0 {
30 - t.Fatalf("Screen Size Failed")
31 - }
32 -}
Godeps/_workspace/src/github.com/olekukonko/ts/ts_unix.go deleted
-14
@@ -1,14 +0,0 @@
1 -// +build freebsd netbsd openbsd
2 -
3 -// Copyright 2014 Oleku Konko All rights reserved.
4 -// Use of this source code is governed by a MIT
5 -// license that can be found in the LICENSE file.
6 -
7 -// This module is a Terminal API for the Go Programming Language.
8 -// The protocols were written in pure Go and works on windows and unix systems
9 -
10 -package ts
11 -
12 -const (
13 - TIOCGWINSZ = 0x40087468
14 -)
Godeps/_workspace/src/github.com/olekukonko/ts/ts_windows.go deleted
-64
@@ -1,64 +0,0 @@
1 -// +build windows
2 -
3 -// Copyright 2014 Oleku Konko All rights reserved.
4 -// Use of this source code is governed by a MIT
5 -// license that can be found in the LICENSE file.
6 -
7 -// This module is a Terminal API for the Go Programming Language.
8 -// The protocols were written in pure Go and works on windows and unix systems
9 -
10 -package ts
11 -
12 -import (
13 - "syscall"
14 - "unsafe"
15 -)
16 -
17 -var (
18 - kernel32 = syscall.NewLazyDLL("kernel32.dll")
19 -
20 - // Retrieves information about the specified console screen buffer.
21 - // See http://msdn.microsoft.com/en-us/library/windows/desktop/ms683171(v=vs.85).aspx
22 - screenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
23 -)
24 -
25 -// Contains information about a console screen buffer.
26 -// http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx
27 -type CONSOLE_SCREEN_BUFFER_INFO struct {
28 - DwSize COORD
29 - DwCursorPosition COORD
30 - WAttributes uint16
31 - SrWindow SMALL_RECT
32 - DwMaximumWindowSize COORD
33 -}
34 -
35 -// Defines the coordinates of a character cell in a console screen buffer.
36 -// The origin of the coordinate system (0,0) is at the top, left cell of the buffer.
37 -// See http://msdn.microsoft.com/en-us/library/windows/desktop/ms682119(v=vs.85).aspx
38 -type COORD struct {
39 - X, Y uint16
40 -}
41 -
42 -// Defines the coordinates of the upper left and lower right corners of a rectangle.
43 -// See http://msdn.microsoft.com/en-us/library/windows/desktop/ms686311(v=vs.85).aspx
44 -type SMALL_RECT struct {
45 - Left, Top, Right, Bottom uint16
46 -}
47 -
48 -func GetSize() (ws Size, err error) {
49 - var info CONSOLE_SCREEN_BUFFER_INFO
50 - rc, _, err := screenBufferInfo.Call(
51 - uintptr(syscall.Stdout),
52 - uintptr(unsafe.Pointer(&info)))
53 -
54 - if rc == 0 {
55 - return ws, err
56 - }
57 -
58 - ws = Size{info.SrWindow.Bottom,
59 - info.SrWindow.Right,
60 - info.DwCursorPosition.X,
61 - info.DwCursorPosition.Y}
62 -
63 - return ws, nil
64 -}
Godeps/_workspace/src/github.com/olekukonko/ts/ts_x.go deleted
-46
@@ -1,46 +0,0 @@
1 -// +build !windows
2 -
3 -// Copyright 2014 Oleku Konko All rights reserved.
4 -// Use of this source code is governed by a MIT
5 -// license that can be found in the LICENSE file.
6 -
7 -// This module is a Terminal API for the Go Programming Language.
8 -// The protocols were written in pure Go and works on windows and unix systems
9 -
10 -package ts
11 -
12 -import (
13 - "syscall"
14 - "unsafe"
15 -)
16 -
17 -// Get Windows Size
18 -func GetSize() (ws Size, err error) {
19 - _, _, ec := syscall.Syscall(syscall.SYS_IOCTL,
20 - uintptr(syscall.Stdout),
21 - uintptr(TIOCGWINSZ),
22 - uintptr(unsafe.Pointer(&ws)))
23 -
24 - err = getError(ec)
25 -
26 - if TIOCGWINSZ == 0 && err != nil {
27 - ws = Size{80, 25, 0, 0}
28 - }
29 - return ws, err
30 -}
31 -
32 -func getError(ec interface{}) (err error) {
33 - switch v := ec.(type) {
34 -
35 - case syscall.Errno: // Some implementation return syscall.Errno number
36 - if v != 0 {
37 - err = syscall.Errno(v)
38 - }
39 -
40 - case error: // Some implementation return error
41 - err = ec.(error)
42 - default:
43 - err = nil
44 - }
45 - return
46 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/.travis.yml deleted
-6
@@ -1,6 +0,0 @@
1 -language: go
2 -
3 -go:
4 - - 1.0
5 - - 1.1
6 - - tip
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/CONTRIBUTORS deleted
-5
@@ -1,5 +0,0 @@
1 -Alec Thomas <alec@swapoff.org>
2 -Guilhem Lettron <guilhem.lettron@optiflows.com>
3 -Ivan Daniluk <ivan.daniluk@gmail.com>
4 -Nimi Wariboko Jr <nimi@channelmeter.com>
5 -Róbert Selvek <robert.selvek@gmail.com>
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/LICENSE deleted
-27
@@ -1,27 +0,0 @@
1 -Copyright (c) 2013 Örjan Persson. All rights reserved.
2 -
3 -Redistribution and use in source and binary forms, with or without
4 -modification, are permitted provided that the following conditions are
5 -met:
6 -
7 - * Redistributions of source code must retain the above copyright
8 -notice, this list of conditions and the following disclaimer.
9 - * Redistributions in binary form must reproduce the above
10 -copyright notice, this list of conditions and the following disclaimer
11 -in the documentation and/or other materials provided with the
12 -distribution.
13 - * Neither the name of Google Inc. nor the names of its
14 -contributors may be used to endorse or promote products derived from
15 -this software without specific prior written permission.
16 -
17 -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/README.md deleted
-89
@@ -1,89 +0,0 @@
1 -## Golang logging library
2 -
3 -[![godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/op/go-logging) [![build](https://img.shields.io/travis/op/go-logging.svg?style=flat)](https://travis-ci.org/op/go-logging)
4 -
5 -Package logging implements a logging infrastructure for Go. Its output format
6 -is customizable and supports different logging backends like syslog, file and
7 -memory. Multiple backends can be utilized with different log levels per backend
8 -and logger.
9 -
10 -## Example
11 -
12 -Let's have a look at an [example](examples/example.go) which demonstrates most
13 -of the features found in this library.
14 -
15 -[![Example Output](examples/example.png)](examples/example.go)
16 -
17 -```go
18 -package main
19 -
20 -import (
21 - "os"
22 -
23 - "github.com/op/go-logging"
24 -)
25 -
26 -var log = logging.MustGetLogger("example")
27 -
28 -// Example format string. Everything except the message has a custom color
29 -// which is dependent on the log level. Many fields have a custom output
30 -// formatting too, eg. the time returns the hour down to the milli second.
31 -var format = logging.MustStringFormatter(
32 - "%{color}%{time:15:04:05.000} %{shortfunc} ▶ %{level:.4s} %{id:03x}%{color:reset} %{message}",
33 -)
34 -
35 -// Password is just an example type implementing the Redactor interface. Any
36 -// time this is logged, the Redacted() function will be called.
37 -type Password string
38 -
39 -func (p Password) Redacted() interface{} {
40 - return logging.Redact(string(p))
41 -}
42 -
43 -func main() {
44 - // For demo purposes, create two backend for os.Stderr.
45 - backend1 := logging.NewLogBackend(os.Stderr, "", 0)
46 - backend2 := logging.NewLogBackend(os.Stderr, "", 0)
47 -
48 - // For messages written to backend2 we want to add some additional
49 - // information to the output, including the used log level and the name of
50 - // the function.
51 - backend2Formatter := logging.NewBackendFormatter(backend2, format)
52 -
53 - // Only errors and more severe messages should be sent to backend1
54 - backend1Leveled := logging.AddModuleLevel(backend1)
55 - backend1Leveled.SetLevel(logging.ERROR, "")
56 -
57 - // Set the backends to be used.
58 - logging.SetBackend(backend1Leveled, backend2Formatter)
59 -
60 - log.Debug("debug %s", Password("secret"))
61 - log.Info("info")
62 - log.Notice("notice")
63 - log.Warning("warning")
64 - log.Error("err")
65 - log.Critical("crit")
66 -}
67 -```
68 -
69 -## Installing
70 -
71 -### Using *go get*
72 -
73 - $ go get github.com/op/go-logging
74 -
75 -After this command *go-logging* is ready to use. Its source will be in:
76 -
77 - $GOROOT/src/pkg/github.com/op/go-logging
78 -
79 -You can use `go get -u` to update the package.
80 -
81 -## Documentation
82 -
83 -For docs, see http://godoc.org/github.com/op/go-logging or run:
84 -
85 - $ godoc github.com/op/go-logging
86 -
87 -## Additional resources
88 -
89 -* [wslog](https://godoc.org/github.com/cryptix/go/logging/wslog) -- exposes log messages through a WebSocket.
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/backend.go deleted
-39
@@ -1,39 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package logging
6 -
7 -// defaultBackend is the backend used for all logging calls.
8 -var defaultBackend LeveledBackend
9 -
10 -// Backend is the interface which a log backend need to implement to be able to
11 -// be used as a logging backend.
12 -type Backend interface {
13 - Log(Level, int, *Record) error
14 -}
15 -
16 -// Set backend replaces the backend currently set with the given new logging
17 -// backend.
18 -func SetBackend(backends ...Backend) LeveledBackend {
19 - var backend Backend
20 - if len(backends) == 1 {
21 - backend = backends[0]
22 - } else {
23 - backend = MultiLogger(backends...)
24 - }
25 -
26 - defaultBackend = AddModuleLevel(backend)
27 - return defaultBackend
28 -}
29 -
30 -// SetLevel sets the logging level for the specified module. The module
31 -// corresponds to the string specified in GetLogger.
32 -func SetLevel(level Level, module string) {
33 - defaultBackend.SetLevel(level, module)
34 -}
35 -
36 -// GetLevel returns the logging level for the specified module.
37 -func GetLevel(module string) Level {
38 - return defaultBackend.GetLevel(module)
39 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/example_test.go deleted
-40
@@ -1,40 +0,0 @@
1 -package logging
2 -
3 -import "os"
4 -
5 -func Example() {
6 - // This call is for testing purposes and will set the time to unix epoch.
7 - InitForTesting(DEBUG)
8 -
9 - var log = MustGetLogger("example")
10 -
11 - // For demo purposes, create two backend for os.Stdout.
12 - //
13 - // os.Stderr should most likely be used in the real world but then the
14 - // "Output:" check in this example would not work.
15 - backend1 := NewLogBackend(os.Stdout, "", 0)
16 - backend2 := NewLogBackend(os.Stdout, "", 0)
17 -
18 - // For messages written to backend2 we want to add some additional
19 - // information to the output, including the used log level and the name of
20 - // the function.
21 - var format = MustStringFormatter(
22 - "%{time:15:04:05.000} %{shortfunc} %{level:.1s} %{message}",
23 - )
24 - backend2Formatter := NewBackendFormatter(backend2, format)
25 -
26 - // Only errors and more severe messages should be sent to backend2
27 - backend2Leveled := AddModuleLevel(backend2Formatter)
28 - backend2Leveled.SetLevel(ERROR, "")
29 -
30 - // Set the backends to be used and the default level.
31 - SetBackend(backend1, backend2Leveled)
32 -
33 - log.Debug("debug %s", "arg")
34 - log.Error("error")
35 -
36 - // Output:
37 - // debug arg
38 - // error
39 - // 00:00:00.000 Example E error
40 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/examples/example.go deleted
-49
@@ -1,49 +0,0 @@
1 -package main
2 -
3 -import (
4 - "os"
5 -
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/whyrusleeping/go-logging"
7 -)
8 -
9 -var log = logging.MustGetLogger("example")
10 -
11 -// Example format string. Everything except the message has a custom color
12 -// which is dependent on the log level. Many fields have a custom output
13 -// formatting too, eg. the time returns the hour down to the milli second.
14 -var format = logging.MustStringFormatter(
15 - "%{color}%{time:15:04:05.000} %{shortfunc} ▶ %{level:.4s} %{id:03x}%{color:reset} %{message}",
16 -)
17 -
18 -// Password is just an example type implementing the Redactor interface. Any
19 -// time this is logged, the Redacted() function will be called.
20 -type Password string
21 -
22 -func (p Password) Redacted() interface{} {
23 - return logging.Redact(string(p))
24 -}
25 -
26 -func main() {
27 - // For demo purposes, create two backend for os.Stderr.
28 - backend1 := logging.NewLogBackend(os.Stderr, "", 0)
29 - backend2 := logging.NewLogBackend(os.Stderr, "", 0)
30 -
31 - // For messages written to backend2 we want to add some additional
32 - // information to the output, including the used log level and the name of
33 - // the function.
34 - backend2Formatter := logging.NewBackendFormatter(backend2, format)
35 -
36 - // Only errors and more severe messages should be sent to backend1
37 - backend1Leveled := logging.AddModuleLevel(backend1)
38 - backend1Leveled.SetLevel(logging.ERROR, "")
39 -
40 - // Set the backends to be used.
41 - logging.SetBackend(backend1Leveled, backend2Formatter)
42 -
43 - log.Debug("debug %s", Password("secret"))
44 - log.Info("info")
45 - log.Notice("notice")
46 - log.Warning("warning")
47 - log.Error("err")
48 - log.Critical("crit")
49 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/examples/example.png
Binary files a/Godeps/_workspace/src/github.com/whyrusleeping/go-logging/examples/example.png and /dev/null differ
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/format.go deleted
-368
@@ -1,368 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package logging
6 -
7 -import (
8 - "bytes"
9 - "errors"
10 - "fmt"
11 - "io"
12 - "os"
13 - "path"
14 - "path/filepath"
15 - "regexp"
16 - "runtime"
17 - "strings"
18 - "sync"
19 - "time"
20 -)
21 -
22 -// TODO see Formatter interface in fmt/print.go
23 -// TODO try text/template, maybe it have enough performance
24 -// TODO other template systems?
25 -// TODO make it possible to specify formats per backend?
26 -type fmtVerb int
27 -
28 -const (
29 - fmtVerbTime fmtVerb = iota
30 - fmtVerbLevel
31 - fmtVerbId
32 - fmtVerbPid
33 - fmtVerbProgram
34 - fmtVerbModule
35 - fmtVerbMessage
36 - fmtVerbLongfile
37 - fmtVerbShortfile
38 - fmtVerbLongpkg
39 - fmtVerbShortpkg
40 - fmtVerbLongfunc
41 - fmtVerbShortfunc
42 - fmtVerbLevelColor
43 -
44 - // Keep last, there are no match for these below.
45 - fmtVerbUnknown
46 - fmtVerbStatic
47 -)
48 -
49 -var fmtVerbs = []string{
50 - "time",
51 - "level",
52 - "id",
53 - "pid",
54 - "program",
55 - "module",
56 - "message",
57 - "longfile",
58 - "shortfile",
59 - "longpkg",
60 - "shortpkg",
61 - "longfunc",
62 - "shortfunc",
63 - "color",
64 -}
65 -
66 -const rfc3339Milli = "2006-01-02T15:04:05.999Z07:00"
67 -
68 -var defaultVerbsLayout = []string{
69 - rfc3339Milli,
70 - "s",
71 - "d",
72 - "d",
73 - "s",
74 - "s",
75 - "s",
76 - "s",
77 - "s",
78 - "s",
79 - "s",
80 - "s",
81 - "s",
82 - "",
83 -}
84 -
85 -var (
86 - pid = os.Getpid()
87 - program = filepath.Base(os.Args[0])
88 -)
89 -
90 -func getFmtVerbByName(name string) fmtVerb {
91 - for i, verb := range fmtVerbs {
92 - if name == verb {
93 - return fmtVerb(i)
94 - }
95 - }
96 - return fmtVerbUnknown
97 -}
98 -
99 -// Formatter is the required interface for a custom log record formatter.
100 -type Formatter interface {
101 - Format(calldepth int, r *Record, w io.Writer) error
102 -}
103 -
104 -// formatter is used by all backends unless otherwise overriden.
105 -var formatter struct {
106 - sync.RWMutex
107 - def Formatter
108 -}
109 -
110 -func getFormatter() Formatter {
111 - formatter.RLock()
112 - defer formatter.RUnlock()
113 - return formatter.def
114 -}
115 -
116 -var (
117 - // DefaultFormatter is the default formatter used and is only the message.
118 - DefaultFormatter Formatter = MustStringFormatter("%{message}")
119 -
120 - // Glog format
121 - GlogFormatter Formatter = MustStringFormatter("%{level:.1s}%{time:0102 15:04:05.999999} %{pid} %{shortfile}] %{message}")
122 -)
123 -
124 -// SetFormatter sets the default formatter for all new backends. A backend will
125 -// fetch this value once it is needed to format a record. Note that backends
126 -// will cache the formatter after the first point. For now, make sure to set
127 -// the formatter before logging.
128 -func SetFormatter(f Formatter) {
129 - formatter.Lock()
130 - defer formatter.Unlock()
131 - formatter.def = f
132 -}
133 -
134 -var formatRe *regexp.Regexp = regexp.MustCompile(`%{([a-z]+)(?::(.*?[^\\]))?}`)
135 -
136 -type part struct {
137 - verb fmtVerb
138 - layout string
139 -}
140 -
141 -// stringFormatter contains a list of parts which explains how to build the
142 -// formatted string passed on to the logging backend.
143 -type stringFormatter struct {
144 - parts []part
145 -}
146 -
147 -// NewStringFormatter returns a new Formatter which outputs the log record as a
148 -// string based on the 'verbs' specified in the format string.
149 -//
150 -// The verbs:
151 -//
152 -// General:
153 -// %{id} Sequence number for log message (uint64).
154 -// %{pid} Process id (int)
155 -// %{time} Time when log occurred (time.Time)
156 -// %{level} Log level (Level)
157 -// %{module} Module (string)
158 -// %{program} Basename of os.Args[0] (string)
159 -// %{message} Message (string)
160 -// %{longfile} Full file name and line number: /a/b/c/d.go:23
161 -// %{shortfile} Final file name element and line number: d.go:23
162 -// %{color} ANSI color based on log level
163 -//
164 -// For normal types, the output can be customized by using the 'verbs' defined
165 -// in the fmt package, eg. '%{id:04d}' to make the id output be '%04d' as the
166 -// format string.
167 -//
168 -// For time.Time, use the same layout as time.Format to change the time format
169 -// when output, eg "2006-01-02T15:04:05.999Z-07:00".
170 -//
171 -// For the 'color' verb, the output can be adjusted to either use bold colors,
172 -// i.e., '%{color:bold}' or to reset the ANSI attributes, i.e.,
173 -// '%{color:reset}' Note that if you use the color verb explicitly, be sure to
174 -// reset it or else the color state will persist past your log message. e.g.,
175 -// "%{color:bold}%{time:15:04:05} %{level:-8s}%{color:reset} %{message}" will
176 -// just colorize the time and level, leaving the message uncolored.
177 -//
178 -// There's also a couple of experimental 'verbs'. These are exposed to get
179 -// feedback and needs a bit of tinkering. Hence, they might change in the
180 -// future.
181 -//
182 -// Experimental:
183 -// %{longpkg} Full package path, eg. github.com/go-logging
184 -// %{shortpkg} Base package path, eg. go-logging
185 -// %{longfunc} Full function name, eg. littleEndian.PutUint32
186 -// %{shortfunc} Base function name, eg. PutUint32
187 -func NewStringFormatter(format string) (*stringFormatter, error) {
188 - var fmter = &stringFormatter{}
189 -
190 - // Find the boundaries of all %{vars}
191 - matches := formatRe.FindAllStringSubmatchIndex(format, -1)
192 - if matches == nil {
193 - return nil, errors.New("logger: invalid log format: " + format)
194 - }
195 -
196 - // Collect all variables and static text for the format
197 - prev := 0
198 - for _, m := range matches {
199 - start, end := m[0], m[1]
200 - if start > prev {
201 - fmter.add(fmtVerbStatic, format[prev:start])
202 - }
203 -
204 - name := format[m[2]:m[3]]
205 - verb := getFmtVerbByName(name)
206 - if verb == fmtVerbUnknown {
207 - return nil, errors.New("logger: unknown variable: " + name)
208 - }
209 -
210 - // Handle layout customizations or use the default. If this is not for the
211 - // time or color formatting, we need to prefix with %.
212 - layout := defaultVerbsLayout[verb]
213 - if m[4] != -1 {
214 - layout = format[m[4]:m[5]]
215 - }
216 - if verb != fmtVerbTime && verb != fmtVerbLevelColor {
217 - layout = "%" + layout
218 - }
219 -
220 - fmter.add(verb, layout)
221 - prev = end
222 - }
223 - end := format[prev:]
224 - if end != "" {
225 - fmter.add(fmtVerbStatic, end)
226 - }
227 -
228 - // Make a test run to make sure we can format it correctly.
229 - t, err := time.Parse(time.RFC3339, "2010-02-04T21:00:57-08:00")
230 - if err != nil {
231 - panic(err)
232 - }
233 - r := &Record{
234 - Id: 12345,
235 - Time: t,
236 - Module: "logger",
237 - fmt: "hello %s",
238 - args: []interface{}{"go"},
239 - }
240 - if err := fmter.Format(0, r, &bytes.Buffer{}); err != nil {
241 - return nil, err
242 - }
243 -
244 - return fmter, nil
245 -}
246 -
247 -// MustStringFormatter is equivalent to NewStringFormatter with a call to panic
248 -// on error.
249 -func MustStringFormatter(format string) *stringFormatter {
250 - f, err := NewStringFormatter(format)
251 - if err != nil {
252 - panic("Failed to initialized string formatter: " + err.Error())
253 - }
254 - return f
255 -}
256 -
257 -func (f *stringFormatter) add(verb fmtVerb, layout string) {
258 - f.parts = append(f.parts, part{verb, layout})
259 -}
260 -
261 -func (f *stringFormatter) Format(calldepth int, r *Record, output io.Writer) error {
262 - for _, part := range f.parts {
263 - if part.verb == fmtVerbStatic {
264 - output.Write([]byte(part.layout))
265 - } else if part.verb == fmtVerbTime {
266 - output.Write([]byte(r.Time.Format(part.layout)))
267 - } else if part.verb == fmtVerbLevelColor {
268 - if part.layout == "bold" {
269 - output.Write([]byte(boldcolors[r.Level]))
270 - } else if part.layout == "reset" {
271 - output.Write([]byte("\033[0m"))
272 - } else {
273 - output.Write([]byte(colors[r.Level]))
274 - }
275 - } else {
276 - var v interface{}
277 - switch part.verb {
278 - case fmtVerbLevel:
279 - v = r.Level
280 - break
281 - case fmtVerbId:
282 - v = r.Id
283 - break
284 - case fmtVerbPid:
285 - v = pid
286 - break
287 - case fmtVerbProgram:
288 - v = program
289 - break
290 - case fmtVerbModule:
291 - v = r.Module
292 - break
293 - case fmtVerbMessage:
294 - v = r.Message()
295 - break
296 - case fmtVerbLongfile, fmtVerbShortfile:
297 - _, file, line, ok := runtime.Caller(calldepth + 1)
298 - if !ok {
299 - file = "???"
300 - line = 0
301 - } else if part.verb == fmtVerbShortfile {
302 - file = filepath.Base(file)
303 - }
304 - v = fmt.Sprintf("%s:%d", file, line)
305 - case fmtVerbLongfunc, fmtVerbShortfunc,
306 - fmtVerbLongpkg, fmtVerbShortpkg:
307 - // TODO cache pc
308 - v = "???"
309 - if pc, _, _, ok := runtime.Caller(calldepth + 1); ok {
310 - if f := runtime.FuncForPC(pc); f != nil {
311 - v = formatFuncName(part.verb, f.Name())
312 - }
313 - }
314 - default:
315 - panic("unhandled format part")
316 - }
317 - fmt.Fprintf(output, part.layout, v)
318 - }
319 - }
320 - return nil
321 -}
322 -
323 -// formatFuncName tries to extract certain part of the runtime formatted
324 -// function name to some pre-defined variation.
325 -//
326 -// This function is known to not work properly if the package path or name
327 -// contains a dot.
328 -func formatFuncName(v fmtVerb, f string) string {
329 - i := strings.LastIndex(f, "/")
330 - j := strings.Index(f[i+1:], ".")
331 - if j < 1 {
332 - return "???"
333 - }
334 - pkg, fun := f[:i+j+1], f[i+j+2:]
335 - switch v {
336 - case fmtVerbLongpkg:
337 - return pkg
338 - case fmtVerbShortpkg:
339 - return path.Base(pkg)
340 - case fmtVerbLongfunc:
341 - return fun
342 - case fmtVerbShortfunc:
343 - i = strings.LastIndex(fun, ".")
344 - return fun[i+1:]
345 - }
346 - panic("unexpected func formatter")
347 -}
348 -
349 -// backendFormatter combines a backend with a specific formatter making it
350 -// possible to have different log formats for different backends.
351 -type backendFormatter struct {
352 - b Backend
353 - f Formatter
354 -}
355 -
356 -// NewBackendFormatter creates a new backend which makes all records that
357 -// passes through it beeing formatted by the specific formatter.
358 -func NewBackendFormatter(b Backend, f Formatter) *backendFormatter {
359 - return &backendFormatter{b, f}
360 -}
361 -
362 -// Log implements the Log function required by the Backend interface.
363 -func (bf *backendFormatter) Log(level Level, calldepth int, r *Record) error {
364 - // Make a shallow copy of the record and replace any formatter
365 - r2 := *r
366 - r2.formatter = bf.f
367 - return bf.b.Log(level, calldepth+1, &r2)
368 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/format_test.go deleted
-184
@@ -1,184 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package logging
6 -
7 -import (
8 - "bytes"
9 - "testing"
10 -)
11 -
12 -func TestFormat(t *testing.T) {
13 - backend := InitForTesting(DEBUG)
14 -
15 - f, err := NewStringFormatter("%{shortfile} %{time:2006-01-02T15:04:05} %{level:.1s} %{id:04d} %{module} %{message}")
16 - if err != nil {
17 - t.Fatalf("failed to set format: %s", err)
18 - }
19 - SetFormatter(f)
20 -
21 - log := MustGetLogger("module")
22 - log.Debug("hello")
23 -
24 - line := MemoryRecordN(backend, 0).Formatted(0)
25 - if "format_test.go:24 1970-01-01T00:00:00 D 0001 module hello" != line {
26 - t.Errorf("Unexpected format: %s", line)
27 - }
28 -}
29 -
30 -func logAndGetLine(backend *MemoryBackend) string {
31 - MustGetLogger("foo").Debug("hello")
32 - return MemoryRecordN(backend, 0).Formatted(1)
33 -}
34 -
35 -func getLastLine(backend *MemoryBackend) string {
36 - return MemoryRecordN(backend, 0).Formatted(1)
37 -}
38 -
39 -func realFunc(backend *MemoryBackend) string {
40 - return logAndGetLine(backend)
41 -}
42 -
43 -type structFunc struct{}
44 -
45 -func (structFunc) Log(backend *MemoryBackend) string {
46 - return logAndGetLine(backend)
47 -}
48 -
49 -func TestRealFuncFormat(t *testing.T) {
50 - backend := InitForTesting(DEBUG)
51 - SetFormatter(MustStringFormatter("%{shortfunc}"))
52 -
53 - line := realFunc(backend)
54 - if "realFunc" != line {
55 - t.Errorf("Unexpected format: %s", line)
56 - }
57 -}
58 -
59 -func TestStructFuncFormat(t *testing.T) {
60 - backend := InitForTesting(DEBUG)
61 - SetFormatter(MustStringFormatter("%{longfunc}"))
62 -
63 - var x structFunc
64 - line := x.Log(backend)
65 - if "structFunc.Log" != line {
66 - t.Errorf("Unexpected format: %s", line)
67 - }
68 -}
69 -
70 -func TestVarFuncFormat(t *testing.T) {
71 - backend := InitForTesting(DEBUG)
72 - SetFormatter(MustStringFormatter("%{shortfunc}"))
73 -
74 - var varFunc = func() string {
75 - return logAndGetLine(backend)
76 - }
77 -
78 - line := varFunc()
79 - if "???" == line || "TestVarFuncFormat" == line || "varFunc" == line {
80 - t.Errorf("Unexpected format: %s", line)
81 - }
82 -}
83 -
84 -func TestFormatFuncName(t *testing.T) {
85 - var tests = []struct {
86 - filename string
87 - longpkg string
88 - shortpkg string
89 - longfunc string
90 - shortfunc string
91 - }{
92 - {"",
93 - "???",
94 - "???",
95 - "???",
96 - "???"},
97 - {"main",
98 - "???",
99 - "???",
100 - "???",
101 - "???"},
102 - {"main.",
103 - "main",
104 - "main",
105 - "",
106 - ""},
107 - {"main.main",
108 - "main",
109 - "main",
110 - "main",
111 - "main"},
112 - {"github.com/op/go-logging.func·001",
113 - "github.com/op/go-logging",
114 - "go-logging",
115 - "func·001",
116 - "func·001"},
117 - {"github.com/op/go-logging.stringFormatter.Format",
118 - "github.com/op/go-logging",
119 - "go-logging",
120 - "stringFormatter.Format",
121 - "Format"},
122 - }
123 -
124 - var v string
125 - for _, test := range tests {
126 - v = formatFuncName(fmtVerbLongpkg, test.filename)
127 - if test.longpkg != v {
128 - t.Errorf("%s != %s", test.longpkg, v)
129 - }
130 - v = formatFuncName(fmtVerbShortpkg, test.filename)
131 - if test.shortpkg != v {
132 - t.Errorf("%s != %s", test.shortpkg, v)
133 - }
134 - v = formatFuncName(fmtVerbLongfunc, test.filename)
135 - if test.longfunc != v {
136 - t.Errorf("%s != %s", test.longfunc, v)
137 - }
138 - v = formatFuncName(fmtVerbShortfunc, test.filename)
139 - if test.shortfunc != v {
140 - t.Errorf("%s != %s", test.shortfunc, v)
141 - }
142 - }
143 -}
144 -
145 -func TestBackendFormatter(t *testing.T) {
146 - InitForTesting(DEBUG)
147 -
148 - // Create two backends and wrap one of the with a backend formatter
149 - b1 := NewMemoryBackend(1)
150 - b2 := NewMemoryBackend(1)
151 -
152 - f := MustStringFormatter("%{level} %{message}")
153 - bf := NewBackendFormatter(b2, f)
154 -
155 - SetBackend(b1, bf)
156 -
157 - log := MustGetLogger("module")
158 - log.Info("foo")
159 - if "foo" != getLastLine(b1) {
160 - t.Errorf("Unexpected line: %s", getLastLine(b1))
161 - }
162 - if "INFO foo" != getLastLine(b2) {
163 - t.Errorf("Unexpected line: %s", getLastLine(b2))
164 - }
165 -}
166 -
167 -func BenchmarkStringFormatter(b *testing.B) {
168 - fmt := "%{time:2006-01-02T15:04:05} %{level:.1s} %{id:04d} %{module} %{message}"
169 - f := MustStringFormatter(fmt)
170 -
171 - backend := InitForTesting(DEBUG)
172 - buf := &bytes.Buffer{}
173 - log := MustGetLogger("module")
174 - log.Debug("")
175 - record := MemoryRecordN(backend, 0)
176 -
177 - b.ResetTimer()
178 - for i := 0; i < b.N; i++ {
179 - if err := f.Format(1, record, buf); err != nil {
180 - b.Fatal(err)
181 - buf.Truncate(0)
182 - }
183 - }
184 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/level.go deleted
-124
@@ -1,124 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package logging
6 -
7 -import (
8 - "errors"
9 - "strings"
10 - "sync"
11 -)
12 -
13 -var ErrInvalidLogLevel = errors.New("logger: invalid log level")
14 -
15 -// Level defines all available log levels for log messages.
16 -type Level int
17 -
18 -const (
19 - CRITICAL Level = iota
20 - ERROR
21 - WARNING
22 - NOTICE
23 - INFO
24 - DEBUG
25 -)
26 -
27 -var levelNames = []string{
28 - "CRITICAL",
29 - "ERROR",
30 - "WARNING",
31 - "NOTICE",
32 - "INFO",
33 - "DEBUG",
34 -}
35 -
36 -// String returns the string representation of a logging level.
37 -func (p Level) String() string {
38 - return levelNames[p]
39 -}
40 -
41 -// LogLevel returns the log level from a string representation.
42 -func LogLevel(level string) (Level, error) {
43 - for i, name := range levelNames {
44 - if strings.EqualFold(name, level) {
45 - return Level(i), nil
46 - }
47 - }
48 - return ERROR, ErrInvalidLogLevel
49 -}
50 -
51 -type Leveled interface {
52 - GetLevel(string) Level
53 - SetLevel(Level, string)
54 - IsEnabledFor(Level, string) bool
55 -}
56 -
57 -// LeveledBackend is a log backend with additional knobs for setting levels on
58 -// individual modules to different levels.
59 -type LeveledBackend interface {
60 - Backend
61 - Leveled
62 -}
63 -
64 -type moduleLeveled struct {
65 - levels map[string]Level
66 - backend Backend
67 - formatter Formatter
68 - once sync.Once
69 -}
70 -
71 -// AddModuleLevel wraps a log backend with knobs to have different log levels
72 -// for different modules.
73 -func AddModuleLevel(backend Backend) LeveledBackend {
74 - var leveled LeveledBackend
75 - var ok bool
76 - if leveled, ok = backend.(LeveledBackend); !ok {
77 - leveled = &moduleLeveled{
78 - levels: make(map[string]Level),
79 - backend: backend,
80 - }
81 - }
82 - return leveled
83 -}
84 -
85 -// GetLevel returns the log level for the given module.
86 -func (l *moduleLeveled) GetLevel(module string) Level {
87 - level, exists := l.levels[module]
88 - if exists == false {
89 - level, exists = l.levels[""]
90 - // no configuration exists, default to debug
91 - if exists == false {
92 - level = DEBUG
93 - }
94 - }
95 - return level
96 -}
97 -
98 -// SetLevel sets the log level for the given module.
99 -func (l *moduleLeveled) SetLevel(level Level, module string) {
100 - l.levels[module] = level
101 -}
102 -
103 -// IsEnabledFor will return true if logging is enabled for the given module.
104 -func (l *moduleLeveled) IsEnabledFor(level Level, module string) bool {
105 - return level <= l.GetLevel(module)
106 -}
107 -
108 -func (l *moduleLeveled) Log(level Level, calldepth int, rec *Record) (err error) {
109 - if l.IsEnabledFor(level, rec.Module) {
110 - // TODO get rid of traces of formatter here. BackendFormatter should be used.
111 - rec.formatter = l.getFormatterAndCacheCurrent()
112 - err = l.backend.Log(level, calldepth+1, rec)
113 - }
114 - return
115 -}
116 -
117 -func (l *moduleLeveled) getFormatterAndCacheCurrent() Formatter {
118 - l.once.Do(func() {
119 - if l.formatter == nil {
120 - l.formatter = getFormatter()
121 - }
122 - })
123 - return l.formatter
124 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/level_test.go deleted
-76
@@ -1,76 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package logging
6 -
7 -import "testing"
8 -
9 -func TestLevelString(t *testing.T) {
10 - // Make sure all levels can be converted from string -> constant -> string
11 - for _, name := range levelNames {
12 - level, err := LogLevel(name)
13 - if err != nil {
14 - t.Errorf("failed to get level: %v", err)
15 - continue
16 - }
17 -
18 - if level.String() != name {
19 - t.Errorf("invalid level conversion: %v != %v", level, name)
20 - }
21 - }
22 -}
23 -
24 -func TestLevelLogLevel(t *testing.T) {
25 - tests := []struct {
26 - expected Level
27 - level string
28 - }{
29 - {-1, "bla"},
30 - {INFO, "iNfO"},
31 - {ERROR, "error"},
32 - {WARNING, "warninG"},
33 - }
34 -
35 - for _, test := range tests {
36 - level, err := LogLevel(test.level)
37 - if err != nil {
38 - if test.expected == -1 {
39 - continue
40 - } else {
41 - t.Errorf("failed to convert %s: %s", test.level, err)
42 - }
43 - }
44 - if test.expected != level {
45 - t.Errorf("failed to convert %s to level: %s != %s", test.level, test.expected, level)
46 - }
47 - }
48 -}
49 -
50 -func TestLevelModuleLevel(t *testing.T) {
51 - backend := NewMemoryBackend(128)
52 -
53 - leveled := AddModuleLevel(backend)
54 - leveled.SetLevel(NOTICE, "")
55 - leveled.SetLevel(ERROR, "foo")
56 - leveled.SetLevel(INFO, "foo.bar")
57 - leveled.SetLevel(WARNING, "bar")
58 -
59 - expected := []struct {
60 - level Level
61 - module string
62 - }{
63 - {NOTICE, ""},
64 - {NOTICE, "something"},
65 - {ERROR, "foo"},
66 - {INFO, "foo.bar"},
67 - {WARNING, "bar"},
68 - }
69 -
70 - for _, e := range expected {
71 - actual := leveled.GetLevel(e.module)
72 - if e.level != actual {
73 - t.Errorf("unexpected level in %s: %s != %s", e.module, e.level, actual)
74 - }
75 - }
76 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/log.go deleted
-80
@@ -1,80 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package logging
6 -
7 -import (
8 - "bytes"
9 - "fmt"
10 - "io"
11 - "log"
12 -)
13 -
14 -// TODO initialize here
15 -var colors []string
16 -var boldcolors []string
17 -
18 -type color int
19 -
20 -const (
21 - colorBlack = (iota + 30)
22 - colorRed
23 - colorGreen
24 - colorYellow
25 - colorBlue
26 - colorMagenta
27 - colorCyan
28 - colorWhite
29 -)
30 -
31 -// LogBackend utilizes the standard log module.
32 -type LogBackend struct {
33 - Logger *log.Logger
34 - Color bool
35 -}
36 -
37 -// NewLogBackend creates a new LogBackend.
38 -func NewLogBackend(out io.Writer, prefix string, flag int) *LogBackend {
39 - return &LogBackend{Logger: log.New(out, prefix, flag)}
40 -}
41 -
42 -func (b *LogBackend) Log(level Level, calldepth int, rec *Record) error {
43 - if b.Color {
44 - buf := &bytes.Buffer{}
45 - buf.Write([]byte(colors[level]))
46 - buf.Write([]byte(rec.Formatted(calldepth + 1)))
47 - buf.Write([]byte("\033[0m"))
48 - // For some reason, the Go logger arbitrarily decided "2" was the correct
49 - // call depth...
50 - return b.Logger.Output(calldepth+2, buf.String())
51 - } else {
52 - return b.Logger.Output(calldepth+2, rec.Formatted(calldepth+1))
53 - }
54 - panic("should not be reached")
55 -}
56 -
57 -func colorSeq(color color) string {
58 - return fmt.Sprintf("\033[%dm", int(color))
59 -}
60 -
61 -func colorSeqBold(color color) string {
62 - return fmt.Sprintf("\033[%d;1m", int(color))
63 -}
64 -
65 -func init() {
66 - colors = []string{
67 - CRITICAL: colorSeq(colorMagenta),
68 - ERROR: colorSeq(colorRed),
69 - WARNING: colorSeq(colorYellow),
70 - NOTICE: colorSeq(colorGreen),
71 - DEBUG: colorSeq(colorCyan),
72 - }
73 - boldcolors = []string{
74 - CRITICAL: colorSeqBold(colorMagenta),
75 - ERROR: colorSeqBold(colorRed),
76 - WARNING: colorSeqBold(colorYellow),
77 - NOTICE: colorSeqBold(colorGreen),
78 - DEBUG: colorSeqBold(colorCyan),
79 - }
80 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/log_test.go deleted
-118
@@ -1,118 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package logging
6 -
7 -import (
8 - "bytes"
9 - "io/ioutil"
10 - "log"
11 - "strings"
12 - "testing"
13 -)
14 -
15 -func TestLogCalldepth(t *testing.T) {
16 - buf := &bytes.Buffer{}
17 - SetBackend(NewLogBackend(buf, "", log.Lshortfile))
18 - SetFormatter(MustStringFormatter("%{shortfile} %{level} %{message}"))
19 -
20 - log := MustGetLogger("test")
21 - log.Info("test filename")
22 -
23 - parts := strings.SplitN(buf.String(), " ", 2)
24 -
25 - // Verify that the correct filename is registered by the stdlib logger
26 - if !strings.HasPrefix(parts[0], "log_test.go:") {
27 - t.Errorf("incorrect filename: %s", parts[0])
28 - }
29 - // Verify that the correct filename is registered by go-logging
30 - if !strings.HasPrefix(parts[1], "log_test.go:") {
31 - t.Errorf("incorrect filename: %s", parts[1])
32 - }
33 -}
34 -
35 -func BenchmarkLogMemoryBackendIgnored(b *testing.B) {
36 - backend := SetBackend(NewMemoryBackend(1024))
37 - backend.SetLevel(INFO, "")
38 - RunLogBenchmark(b)
39 -}
40 -
41 -func BenchmarkLogMemoryBackend(b *testing.B) {
42 - backend := SetBackend(NewMemoryBackend(1024))
43 - backend.SetLevel(DEBUG, "")
44 - RunLogBenchmark(b)
45 -}
46 -
47 -func BenchmarkLogChannelMemoryBackend(b *testing.B) {
48 - channelBackend := NewChannelMemoryBackend(1024)
49 - backend := SetBackend(channelBackend)
50 - backend.SetLevel(DEBUG, "")
51 - RunLogBenchmark(b)
52 - channelBackend.Flush()
53 -}
54 -
55 -func BenchmarkLogLeveled(b *testing.B) {
56 - backend := SetBackend(NewLogBackend(ioutil.Discard, "", 0))
57 - backend.SetLevel(INFO, "")
58 -
59 - RunLogBenchmark(b)
60 -}
61 -
62 -func BenchmarkLogLogBackend(b *testing.B) {
63 - backend := SetBackend(NewLogBackend(ioutil.Discard, "", 0))
64 - backend.SetLevel(DEBUG, "")
65 - RunLogBenchmark(b)
66 -}
67 -
68 -func BenchmarkLogLogBackendColor(b *testing.B) {
69 - colorizer := NewLogBackend(ioutil.Discard, "", 0)
70 - colorizer.Color = true
71 - backend := SetBackend(colorizer)
72 - backend.SetLevel(DEBUG, "")
73 - RunLogBenchmark(b)
74 -}
75 -
76 -func BenchmarkLogLogBackendStdFlags(b *testing.B) {
77 - backend := SetBackend(NewLogBackend(ioutil.Discard, "", log.LstdFlags))
78 - backend.SetLevel(DEBUG, "")
79 - RunLogBenchmark(b)
80 -}
81 -
82 -func BenchmarkLogLogBackendLongFileFlag(b *testing.B) {
83 - backend := SetBackend(NewLogBackend(ioutil.Discard, "", log.Llongfile))
84 - backend.SetLevel(DEBUG, "")
85 - RunLogBenchmark(b)
86 -}
87 -
88 -func RunLogBenchmark(b *testing.B) {
89 - password := Password("foo")
90 - log := MustGetLogger("test")
91 -
92 - b.ResetTimer()
93 - for i := 0; i < b.N; i++ {
94 - log.Debug("log line for %d and this is rectified: %s", i, password)
95 - }
96 -}
97 -
98 -func BenchmarkLogFixed(b *testing.B) {
99 - backend := SetBackend(NewLogBackend(ioutil.Discard, "", 0))
100 - backend.SetLevel(DEBUG, "")
101 -
102 - RunLogBenchmarkFixedString(b)
103 -}
104 -
105 -func BenchmarkLogFixedIgnored(b *testing.B) {
106 - backend := SetBackend(NewLogBackend(ioutil.Discard, "", 0))
107 - backend.SetLevel(INFO, "")
108 - RunLogBenchmarkFixedString(b)
109 -}
110 -
111 -func RunLogBenchmarkFixedString(b *testing.B) {
112 - log := MustGetLogger("test")
113 -
114 - b.ResetTimer()
115 - for i := 0; i < b.N; i++ {
116 - log.Debug("some random fixed text")
117 - }
118 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/logger.go deleted
-277
@@ -1,277 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// Package logging implements a logging infrastructure for Go. It supports
6 -// different logging backends like syslog, file and memory. Multiple backends
7 -// can be utilized with different log levels per backend and logger.
8 -package logging
9 -
10 -import (
11 - "bytes"
12 - "fmt"
13 - "log"
14 - "os"
15 - "strings"
16 - "sync/atomic"
17 - "time"
18 -)
19 -
20 -// Redactor is an interface for types that may contain sensitive information
21 -// (like passwords), which shouldn't be printed to the log. The idea was found
22 -// in relog as part of the vitness project.
23 -type Redactor interface {
24 - Redacted() interface{}
25 -}
26 -
27 -// Redact returns a string of * having the same length as s.
28 -func Redact(s string) string {
29 - return strings.Repeat("*", len(s))
30 -}
31 -
32 -var (
33 - // Sequence number is incremented and utilized for all log records created.
34 - sequenceNo uint64
35 -
36 - // timeNow is a customizable for testing purposes.
37 - timeNow = time.Now
38 -)
39 -
40 -// Record represents a log record and contains the timestamp when the record
41 -// was created, an increasing id, filename and line and finally the actual
42 -// formatted log line.
43 -type Record struct {
44 - Id uint64
45 - Time time.Time
46 - Module string
47 - Level Level
48 -
49 - // message is kept as a pointer to have shallow copies update this once
50 - // needed.
51 - message *string
52 - args []interface{}
53 - fmt string
54 - formatter Formatter
55 - formatted string
56 -}
57 -
58 -// Formatted returns the string-formatted version of a record.
59 -func (r *Record) Formatted(calldepth int) string {
60 - if r.formatted == "" {
61 - var buf bytes.Buffer
62 - r.formatter.Format(calldepth+1, r, &buf)
63 - r.formatted = buf.String()
64 - }
65 - return r.formatted
66 -}
67 -
68 -// Message returns a string message for outputting. Redacts any record args
69 -// that implement the Redactor interface
70 -func (r *Record) Message() string {
71 - if r.message == nil {
72 - // Redact the arguments that implements the Redactor interface
73 - for i, arg := range r.args {
74 - if redactor, ok := arg.(Redactor); ok == true {
75 - r.args[i] = redactor.Redacted()
76 - }
77 - }
78 - msg := fmt.Sprintf(r.fmt, r.args...)
79 - r.message = &msg
80 - }
81 - return *r.message
82 -}
83 -
84 -// Logger is a logging unit. It controls the flow of messages to a given
85 -// (swappable) backend.
86 -type Logger struct {
87 - Module string
88 - backend LeveledBackend
89 - haveBackend bool
90 -
91 - // ExtraCallDepth can be used to add additional call depth when getting the
92 - // calling function. This is normally used when wrapping a logger.
93 - ExtraCalldepth int
94 -}
95 -
96 -// SetBackend changes the backend of the logger.
97 -func (l *Logger) SetBackend(backend LeveledBackend) {
98 - l.backend = backend
99 - l.haveBackend = true
100 -}
101 -
102 -// GetLogger creates and returns a Logger object based on the module name.
103 -// TODO call NewLogger and remove MustGetLogger?
104 -func GetLogger(module string) (*Logger, error) {
105 - return &Logger{Module: module}, nil
106 -}
107 -
108 -// MustGetLogger is like GetLogger but panics if the logger can't be created.
109 -// It simplifies safe initialization of a global logger for eg. a package.
110 -func MustGetLogger(module string) *Logger {
111 - logger, err := GetLogger(module)
112 - if err != nil {
113 - panic("logger: " + module + ": " + err.Error())
114 - }
115 - return logger
116 -}
117 -
118 -// Reset restores the internal state of the logging library.
119 -func Reset() {
120 - // TODO make a global Init() method to be less magic? or make it such that
121 - // if there's no backends at all configured, we could use some tricks to
122 - // automatically setup backends based if we have a TTY or not.
123 - sequenceNo = 0
124 - b := SetBackend(NewLogBackend(os.Stderr, "", log.LstdFlags))
125 - b.SetLevel(DEBUG, "")
126 - SetFormatter(DefaultFormatter)
127 - timeNow = time.Now
128 -}
129 -
130 -// InitForTesting is a convenient method when using logging in a test. Once
131 -// called, the time will be frozen to January 1, 1970 UTC.
132 -func InitForTesting(level Level) *MemoryBackend {
133 - Reset()
134 -
135 - memoryBackend := NewMemoryBackend(10240)
136 -
137 - leveledBackend := AddModuleLevel(memoryBackend)
138 - leveledBackend.SetLevel(level, "")
139 - SetBackend(leveledBackend)
140 -
141 - timeNow = func() time.Time {
142 - return time.Unix(0, 0).UTC()
143 - }
144 - return memoryBackend
145 -}
146 -
147 -// IsEnabledFor returns true if the logger is enabled for the given level.
148 -func (l *Logger) IsEnabledFor(level Level) bool {
149 - return defaultBackend.IsEnabledFor(level, l.Module)
150 -}
151 -
152 -func (l *Logger) log(lvl Level, format string, args ...interface{}) {
153 - if !l.IsEnabledFor(lvl) {
154 - return
155 - }
156 -
157 - // Create the logging record and pass it in to the backend
158 - record := &Record{
159 - Id: atomic.AddUint64(&sequenceNo, 1),
160 - Time: timeNow(),
161 - Module: l.Module,
162 - Level: lvl,
163 - fmt: format,
164 - args: args,
165 - }
166 -
167 - // TODO use channels to fan out the records to all backends?
168 - // TODO in case of errors, do something (tricky)
169 -
170 - // calldepth=2 brings the stack up to the caller of the level
171 - // methods, Info(), Fatal(), etc.
172 - // ExtraCallDepth allows this to be extended further up the stack in case we
173 - // are wrapping these methods, eg. to expose them package level
174 - if l.haveBackend {
175 - l.backend.Log(lvl, 2+l.ExtraCalldepth, record)
176 - return
177 - }
178 -
179 - defaultBackend.Log(lvl, 2+l.ExtraCalldepth, record)
180 -}
181 -
182 -// Fatal is equivalent to l.Critical(fmt.Sprint()) followed by a call to os.Exit(1).
183 -func (l *Logger) Fatal(args ...interface{}) {
184 - s := fmt.Sprint(args...)
185 - l.log(CRITICAL, "%s", s)
186 - os.Exit(1)
187 -}
188 -
189 -// Fatalf is equivalent to l.Critical followed by a call to os.Exit(1).
190 -func (l *Logger) Fatalf(format string, args ...interface{}) {
191 - l.log(CRITICAL, format, args...)
192 - os.Exit(1)
193 -}
194 -
195 -// Panic is equivalent to l.Critical(fmt.Sprint()) followed by a call to panic().
196 -func (l *Logger) Panic(args ...interface{}) {
197 - s := fmt.Sprint(args...)
198 - l.log(CRITICAL, "%s", s)
199 - panic(s)
200 -}
201 -
202 -// Panicf is equivalent to l.Critical followed by a call to panic().
203 -func (l *Logger) Panicf(format string, args ...interface{}) {
204 - s := fmt.Sprintf(format, args...)
205 - l.log(CRITICAL, "%s", s)
206 - panic(s)
207 -}
208 -
209 -// Critical logs a message using CRITICAL as log level. (fmt.Sprint())
210 -func (l *Logger) Critical(args ...interface{}) {
211 - s := fmt.Sprint(args...)
212 - l.log(CRITICAL, "%s", s)
213 -}
214 -
215 -// Criticalf logs a message using CRITICAL as log level.
216 -func (l *Logger) Criticalf(format string, args ...interface{}) {
217 - l.log(CRITICAL, format, args...)
218 -}
219 -
220 -// Error logs a message using ERROR as log level. (fmt.Sprint())
221 -func (l *Logger) Error(args ...interface{}) {
222 - s := fmt.Sprint(args...)
223 - l.log(ERROR, "%s", s)
224 -}
225 -
226 -// Errorf logs a message using ERROR as log level.
227 -func (l *Logger) Errorf(format string, args ...interface{}) {
228 - l.log(ERROR, format, args...)
229 -}
230 -
231 -// Warning logs a message using WARNING as log level.
232 -func (l *Logger) Warning(args ...interface{}) {
233 - s := fmt.Sprint(args...)
234 - l.log(WARNING, "%s", s)
235 -}
236 -
237 -// Warningf logs a message using WARNING as log level.
238 -func (l *Logger) Warningf(format string, args ...interface{}) {
239 - l.log(WARNING, format, args...)
240 -}
241 -
242 -// Notice logs a message using NOTICE as log level.
243 -func (l *Logger) Notice(args ...interface{}) {
244 - s := fmt.Sprint(args...)
245 - l.log(NOTICE, "%s", s)
246 -}
247 -
248 -// Noticef logs a message using NOTICE as log level.
249 -func (l *Logger) Noticef(format string, args ...interface{}) {
250 - l.log(NOTICE, format, args...)
251 -}
252 -
253 -// Info logs a message using INFO as log level.
254 -func (l *Logger) Info(args ...interface{}) {
255 - s := fmt.Sprint(args...)
256 - l.log(INFO, "%s", s)
257 -}
258 -
259 -// Infof logs a message using INFO as log level.
260 -func (l *Logger) Infof(format string, args ...interface{}) {
261 - l.log(INFO, format, args...)
262 -}
263 -
264 -// Debug logs a message using DEBUG as log level.
265 -func (l *Logger) Debug(args ...interface{}) {
266 - s := fmt.Sprint(args...)
267 - l.log(DEBUG, "%s", s)
268 -}
269 -
270 -// Debugf logs a message using DEBUG as log level.
271 -func (l *Logger) Debugf(format string, args ...interface{}) {
272 - l.log(DEBUG, format, args...)
273 -}
274 -
275 -func init() {
276 - Reset()
277 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/logger_test.go deleted
-53
@@ -1,53 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package logging
6 -
7 -import "testing"
8 -
9 -type Password string
10 -
11 -func (p Password) Redacted() interface{} {
12 - return Redact(string(p))
13 -}
14 -
15 -func TestSequenceNoOverflow(t *testing.T) {
16 - // Forcefully set the next sequence number to the maximum
17 - backend := InitForTesting(DEBUG)
18 - sequenceNo = ^uint64(0)
19 -
20 - log := MustGetLogger("test")
21 - log.Debug("test")
22 -
23 - if MemoryRecordN(backend, 0).Id != 0 {
24 - t.Errorf("Unexpected sequence no: %v", MemoryRecordN(backend, 0).Id)
25 - }
26 -}
27 -
28 -func TestRedact(t *testing.T) {
29 - backend := InitForTesting(DEBUG)
30 - password := Password("123456")
31 - log := MustGetLogger("test")
32 - log.Debugf("foo %s", password)
33 - if "foo ******" != MemoryRecordN(backend, 0).Formatted(0) {
34 - t.Errorf("redacted line: %v", MemoryRecordN(backend, 0))
35 - }
36 -}
37 -
38 -func TestPrivateBackend(t *testing.T) {
39 - stdBackend := InitForTesting(DEBUG)
40 - log := MustGetLogger("test")
41 - privateBackend := NewMemoryBackend(10240)
42 - lvlBackend := AddModuleLevel(privateBackend)
43 - lvlBackend.SetLevel(DEBUG, "")
44 - log.SetBackend(lvlBackend)
45 - log.Debug("to private backend")
46 - if stdBackend.size > 0 {
47 - t.Errorf("something in stdBackend, size of backend: %d", stdBackend.size)
48 - }
49 - if "to private baсkend" == MemoryRecordN(privateBackend, 0).Formatted(0) {
50 - t.Errorf("logged to defaultBackend: %s", MemoryRecordN(privateBackend, 0))
51 - }
52 -
53 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/memory.go deleted
-217
@@ -1,217 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package logging
6 -
7 -import (
8 - "sync"
9 - "sync/atomic"
10 - "unsafe"
11 -)
12 -
13 -// TODO pick one of the memory backends and stick with it or share interface.
14 -
15 -// Node is a record node pointing to an optional next node.
16 -type node struct {
17 - next *node
18 - Record *Record
19 -}
20 -
21 -// Next returns the next record node. If there's no node available, it will
22 -// return nil.
23 -func (n *node) Next() *node {
24 - return n.next
25 -}
26 -
27 -// MemoryBackend is a simple memory based logging backend that will not produce
28 -// any output but merly keep records, up to the given size, in memory.
29 -type MemoryBackend struct {
30 - size int32
31 - maxSize int32
32 - head, tail unsafe.Pointer
33 -}
34 -
35 -// NewMemoryBackend creates a simple in-memory logging backend.
36 -func NewMemoryBackend(size int) *MemoryBackend {
37 - return &MemoryBackend{maxSize: int32(size)}
38 -}
39 -
40 -// Log implements the Log method required by Backend.
41 -func (b *MemoryBackend) Log(level Level, calldepth int, rec *Record) error {
42 - var size int32
43 -
44 - n := &node{Record: rec}
45 - np := unsafe.Pointer(n)
46 -
47 - // Add the record to the tail. If there's no records available, tail and
48 - // head will both be nil. When we successfully set the tail and the previous
49 - // value was nil, it's safe to set the head to the current value too.
50 - for {
51 - tailp := b.tail
52 - swapped := atomic.CompareAndSwapPointer(
53 - &b.tail,
54 - tailp,
55 - np,
56 - )
57 - if swapped == true {
58 - if tailp == nil {
59 - b.head = np
60 - } else {
61 - (*node)(tailp).next = n
62 - }
63 - size = atomic.AddInt32(&b.size, 1)
64 - break
65 - }
66 - }
67 -
68 - // Since one record was added, we might have overflowed the list. Remove
69 - // a record if that is the case. The size will fluctate a bit, but
70 - // eventual consistent.
71 - if b.maxSize > 0 && size > b.maxSize {
72 - for {
73 - headp := b.head
74 - head := (*node)(b.head)
75 - if head.next == nil {
76 - break
77 - }
78 - swapped := atomic.CompareAndSwapPointer(
79 - &b.head,
80 - headp,
81 - unsafe.Pointer(head.next),
82 - )
83 - if swapped == true {
84 - atomic.AddInt32(&b.size, -1)
85 - break
86 - }
87 - }
88 - }
89 - return nil
90 -}
91 -
92 -// Head returns the oldest record node kept in memory. It can be used to
93 -// iterate over records, one by one, up to the last record.
94 -//
95 -// Note: new records can get added while iterating. Hence the number of records
96 -// iterated over might be larger than the maximum size.
97 -func (b *MemoryBackend) Head() *node {
98 - return (*node)(b.head)
99 -}
100 -
101 -type event int
102 -
103 -const (
104 - eventFlush event = iota
105 - eventStop
106 -)
107 -
108 -// ChannelMemoryBackend is very similar to the MemoryBackend, except that it
109 -// internally utilizes a channel.
110 -type ChannelMemoryBackend struct {
111 - maxSize int
112 - size int
113 - incoming chan *Record
114 - events chan event
115 - mu sync.Mutex
116 - running bool
117 - flushWg sync.WaitGroup
118 - stopWg sync.WaitGroup
119 - head, tail *node
120 -}
121 -
122 -// NewChannelMemoryBackend creates a simple in-memory logging backend which
123 -// utilizes a go channel for communication.
124 -//
125 -// Start will automatically be called by this function.
126 -func NewChannelMemoryBackend(size int) *ChannelMemoryBackend {
127 - backend := &ChannelMemoryBackend{
128 - maxSize: size,
129 - incoming: make(chan *Record, 1024),
130 - events: make(chan event),
131 - }
132 - backend.Start()
133 - return backend
134 -}
135 -
136 -// Start launches the internal goroutine which starts processing data from the
137 -// input channel.
138 -func (b *ChannelMemoryBackend) Start() {
139 - b.mu.Lock()
140 - defer b.mu.Unlock()
141 -
142 - // Launch the goroutine unless it's already running.
143 - if b.running != true {
144 - b.running = true
145 - b.stopWg.Add(1)
146 - go b.process()
147 - }
148 -}
149 -
150 -func (b *ChannelMemoryBackend) process() {
151 - defer b.stopWg.Done()
152 - for {
153 - select {
154 - case rec := <-b.incoming:
155 - b.insertRecord(rec)
156 - case e := <-b.events:
157 - switch e {
158 - case eventStop:
159 - return
160 - case eventFlush:
161 - for len(b.incoming) > 0 {
162 - b.insertRecord(<-b.incoming)
163 - }
164 - b.flushWg.Done()
165 - }
166 - }
167 - }
168 -}
169 -
170 -func (b *ChannelMemoryBackend) insertRecord(rec *Record) {
171 - prev := b.tail
172 - b.tail = &node{Record: rec}
173 - if prev == nil {
174 - b.head = b.tail
175 - } else {
176 - prev.next = b.tail
177 - }
178 -
179 - if b.maxSize > 0 && b.size >= b.maxSize {
180 - b.head = b.head.next
181 - } else {
182 - b.size += 1
183 - }
184 -}
185 -
186 -// Flush waits until all records in the buffered channel have been processed.
187 -func (b *ChannelMemoryBackend) Flush() {
188 - b.flushWg.Add(1)
189 - b.events <- eventFlush
190 - b.flushWg.Wait()
191 -}
192 -
193 -// Stop signals the internal goroutine to exit and waits until it have.
194 -func (b *ChannelMemoryBackend) Stop() {
195 - b.mu.Lock()
196 - if b.running == true {
197 - b.running = false
198 - b.events <- eventStop
199 - }
200 - b.mu.Unlock()
201 - b.stopWg.Wait()
202 -}
203 -
204 -// Log implements the Log method required by Backend.
205 -func (b *ChannelMemoryBackend) Log(level Level, calldepth int, rec *Record) error {
206 - b.incoming <- rec
207 - return nil
208 -}
209 -
210 -// Head returns the oldest record node kept in memory. It can be used to
211 -// iterate over records, one by one, up to the last record.
212 -//
213 -// Note: new records can get added while iterating. Hence the number of records
214 -// iterated over might be larger than the maximum size.
215 -func (b *ChannelMemoryBackend) Head() *node {
216 - return b.head
217 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/memory_test.go deleted
-117
@@ -1,117 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package logging
6 -
7 -import (
8 - "strconv"
9 - "testing"
10 -)
11 -
12 -// TODO share more code between these tests
13 -func MemoryRecordN(b *MemoryBackend, n int) *Record {
14 - node := b.Head()
15 - for i := 0; i < n; i++ {
16 - if node == nil {
17 - break
18 - }
19 - node = node.Next()
20 - }
21 - if node == nil {
22 - return nil
23 - }
24 - return node.Record
25 -}
26 -
27 -func ChannelMemoryRecordN(b *ChannelMemoryBackend, n int) *Record {
28 - b.Flush()
29 - node := b.Head()
30 - for i := 0; i < n; i++ {
31 - if node == nil {
32 - break
33 - }
34 - node = node.Next()
35 - }
36 - if node == nil {
37 - return nil
38 - }
39 - return node.Record
40 -}
41 -
42 -func TestMemoryBackend(t *testing.T) {
43 - backend := NewMemoryBackend(8)
44 - SetBackend(backend)
45 -
46 - log := MustGetLogger("test")
47 -
48 - if nil != MemoryRecordN(backend, 0) || 0 != backend.size {
49 - t.Errorf("memory level: %d", backend.size)
50 - }
51 -
52 - // Run 13 times, the resulting vector should be [5..12]
53 - for i := 0; i < 13; i++ {
54 - log.Infof("%d", i)
55 - }
56 -
57 - if 8 != backend.size {
58 - t.Errorf("record length: %d", backend.size)
59 - }
60 - record := MemoryRecordN(backend, 0)
61 - if "5" != record.Formatted(0) {
62 - t.Errorf("unexpected start: %s", record.Formatted(0))
63 - }
64 - for i := 0; i < 8; i++ {
65 - record = MemoryRecordN(backend, i)
66 - if strconv.Itoa(i+5) != record.Formatted(0) {
67 - t.Errorf("unexpected record: %v", record.Formatted(0))
68 - }
69 - }
70 - record = MemoryRecordN(backend, 7)
71 - if "12" != record.Formatted(0) {
72 - t.Errorf("unexpected end: %s", record.Formatted(0))
73 - }
74 - record = MemoryRecordN(backend, 8)
75 - if nil != record {
76 - t.Errorf("unexpected eof: %s", record.Formatted(0))
77 - }
78 -}
79 -
80 -func TestChannelMemoryBackend(t *testing.T) {
81 - backend := NewChannelMemoryBackend(8)
82 - SetBackend(backend)
83 -
84 - log := MustGetLogger("test")
85 -
86 - if nil != ChannelMemoryRecordN(backend, 0) || 0 != backend.size {
87 - t.Errorf("memory level: %d", backend.size)
88 - }
89 -
90 - // Run 13 times, the resulting vector should be [5..12]
91 - for i := 0; i < 13; i++ {
92 - log.Infof("%d", i)
93 - }
94 - backend.Flush()
95 -
96 - if 8 != backend.size {
97 - t.Errorf("record length: %d", backend.size)
98 - }
99 - record := ChannelMemoryRecordN(backend, 0)
100 - if "5" != record.Formatted(0) {
101 - t.Errorf("unexpected start: %s", record.Formatted(0))
102 - }
103 - for i := 0; i < 8; i++ {
104 - record = ChannelMemoryRecordN(backend, i)
105 - if strconv.Itoa(i+5) != record.Formatted(0) {
106 - t.Errorf("unexpected record: %v", record.Formatted(0))
107 - }
108 - }
109 - record = ChannelMemoryRecordN(backend, 7)
110 - if "12" != record.Formatted(0) {
111 - t.Errorf("unexpected end: %s", record.Formatted(0))
112 - }
113 - record = ChannelMemoryRecordN(backend, 8)
114 - if nil != record {
115 - t.Errorf("unexpected eof: %s", record.Formatted(0))
116 - }
117 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/multi.go deleted
-65
@@ -1,65 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package logging
6 -
7 -// TODO remove Level stuff from the multi logger. Do one thing.
8 -
9 -// multiLogger is a log multiplexer which can be used to utilize multiple log
10 -// backends at once.
11 -type multiLogger struct {
12 - backends []LeveledBackend
13 -}
14 -
15 -// MultiLogger creates a logger which contain multiple loggers.
16 -func MultiLogger(backends ...Backend) LeveledBackend {
17 - var leveledBackends []LeveledBackend
18 - for _, backend := range backends {
19 - leveledBackends = append(leveledBackends, AddModuleLevel(backend))
20 - }
21 - return &multiLogger{leveledBackends}
22 -}
23 -
24 -// Log passes the log record to all backends.
25 -func (b *multiLogger) Log(level Level, calldepth int, rec *Record) (err error) {
26 - for _, backend := range b.backends {
27 - if backend.IsEnabledFor(level, rec.Module) {
28 - // Shallow copy of the record for the formatted cache on Record and get the
29 - // record formatter from the backend.
30 - r2 := *rec
31 - if e := backend.Log(level, calldepth+1, &r2); e != nil {
32 - err = e
33 - }
34 - }
35 - }
36 - return
37 -}
38 -
39 -// GetLevel returns the highest level enabled by all backends.
40 -func (b *multiLogger) GetLevel(module string) Level {
41 - var level Level
42 - for _, backend := range b.backends {
43 - if backendLevel := backend.GetLevel(module); backendLevel > level {
44 - level = backendLevel
45 - }
46 - }
47 - return level
48 -}
49 -
50 -// SetLevel propagates the same level to all backends.
51 -func (b *multiLogger) SetLevel(level Level, module string) {
52 - for _, backend := range b.backends {
53 - backend.SetLevel(level, module)
54 - }
55 -}
56 -
57 -// IsEnabledFor returns true if any of the backends are enabled for it.
58 -func (b *multiLogger) IsEnabledFor(level Level, module string) bool {
59 - for _, backend := range b.backends {
60 - if backend.IsEnabledFor(level, module) {
61 - return true
62 - }
63 - }
64 - return false
65 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/multi_test.go deleted
-51
@@ -1,51 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package logging
6 -
7 -import "testing"
8 -
9 -func TestMultiLogger(t *testing.T) {
10 - log1 := NewMemoryBackend(8)
11 - log2 := NewMemoryBackend(8)
12 - SetBackend(MultiLogger(log1, log2))
13 -
14 - log := MustGetLogger("test")
15 - log.Debug("log")
16 -
17 - if "log" != MemoryRecordN(log1, 0).Formatted(0) {
18 - t.Errorf("log1: %v", MemoryRecordN(log1, 0).Formatted(0))
19 - }
20 - if "log" != MemoryRecordN(log2, 0).Formatted(0) {
21 - t.Errorf("log2: %v", MemoryRecordN(log2, 0).Formatted(0))
22 - }
23 -}
24 -
25 -func TestMultiLoggerLevel(t *testing.T) {
26 - log1 := NewMemoryBackend(8)
27 - log2 := NewMemoryBackend(8)
28 -
29 - leveled1 := AddModuleLevel(log1)
30 - leveled2 := AddModuleLevel(log2)
31 -
32 - multi := MultiLogger(leveled1, leveled2)
33 - multi.SetLevel(ERROR, "test")
34 - SetBackend(multi)
35 -
36 - log := MustGetLogger("test")
37 - log.Notice("log")
38 -
39 - if nil != MemoryRecordN(log1, 0) || nil != MemoryRecordN(log2, 0) {
40 - t.Errorf("unexpected log record")
41 - }
42 -
43 - leveled1.SetLevel(DEBUG, "test")
44 - log.Notice("log")
45 - if "log" != MemoryRecordN(log1, 0).Formatted(0) {
46 - t.Errorf("log1 not received")
47 - }
48 - if nil != MemoryRecordN(log2, 0) {
49 - t.Errorf("log2 received")
50 - }
51 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-logging/syslog.go deleted
-52
@@ -1,52 +0,0 @@
1 -// Copyright 2013, Örjan Persson. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -//+build !windows,!plan9
6 -
7 -package logging
8 -
9 -import "log/syslog"
10 -
11 -// SyslogBackend is a simple logger to syslog backend. It automatically maps
12 -// the internal log levels to appropriate syslog log levels.
13 -type SyslogBackend struct {
14 - Writer *syslog.Writer
15 -}
16 -
17 -// NewSyslogBackend connects to the syslog daemon using UNIX sockets with the
18 -// given prefix. If prefix is not given, the prefix will be derived from the
19 -// launched command.
20 -func NewSyslogBackend(prefix string) (b *SyslogBackend, err error) {
21 - var w *syslog.Writer
22 - w, err = syslog.New(syslog.LOG_CRIT, prefix)
23 - return &SyslogBackend{w}, err
24 -}
25 -
26 -// NewSyslogBackendPriority is the same as NewSyslogBackend, but with custom
27 -// syslog priority, like syslog.LOG_LOCAL3|syslog.LOG_DEBUG etc.
28 -func NewSyslogBackendPriority(prefix string, priority syslog.Priority) (b *SyslogBackend, err error) {
29 - var w *syslog.Writer
30 - w, err = syslog.New(priority, prefix)
31 - return &SyslogBackend{w}, err
32 -}
33 -
34 -func (b *SyslogBackend) Log(level Level, calldepth int, rec *Record) error {
35 - line := rec.Formatted(calldepth + 1)
36 - switch level {
37 - case CRITICAL:
38 - return b.Writer.Crit(line)
39 - case ERROR:
40 - return b.Writer.Err(line)
41 - case WARNING:
42 - return b.Writer.Warning(line)
43 - case NOTICE:
44 - return b.Writer.Notice(line)
45 - case INFO:
46 - return b.Writer.Info(line)
47 - case DEBUG:
48 - return b.Writer.Debug(line)
49 - default:
50 - }
51 - panic("unhandled log level")
52 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/.gitignore deleted
-9
@@ -1,9 +0,0 @@
1 -*.[68]
2 -*.a
3 -*.out
4 -*.swp
5 -_obj
6 -_testmain.go
7 -cmd/metrics-bench/metrics-bench
8 -cmd/metrics-example/metrics-example
9 -cmd/never-read/never-read
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/LICENSE deleted
-29
@@ -1,29 +0,0 @@
1 -Copyright 2012 Richard Crowley. All rights reserved.
2 -
3 -Redistribution and use in source and binary forms, with or without
4 -modification, are permitted provided that the following conditions are
5 -met:
6 -
7 - 1. Redistributions of source code must retain the above copyright
8 - notice, this list of conditions and the following disclaimer.
9 -
10 - 2. Redistributions in binary form must reproduce the above
11 - copyright notice, this list of conditions and the following
12 - disclaimer in the documentation and/or other materials provided
13 - with the distribution.
14 -
15 -THIS SOFTWARE IS PROVIDED BY RICHARD CROWLEY ``AS IS'' AND ANY EXPRESS
16 -OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 -DISCLAIMED. IN NO EVENT SHALL RICHARD CROWLEY OR CONTRIBUTORS BE LIABLE
19 -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
25 -THE POSSIBILITY OF SUCH DAMAGE.
26 -
27 -The views and conclusions contained in the software and documentation
28 -are those of the authors and should not be interpreted as representing
29 -official policies, either expressed or implied, of Richard Crowley.
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/README.md deleted
-104
@@ -1,104 +0,0 @@
1 -go-metrics
2 -==========
3 -
4 -Go port of Coda Hale's Metrics library: <https://github.com/codahale/metrics>.
5 -
6 -Documentation: <http://godoc.org/github.com/rcrowley/go-metrics>.
7 -
8 -Usage
9 ------
10 -
11 -Create and update metrics:
12 -
13 -```go
14 -c := metrics.NewCounter()
15 -metrics.Register("foo", c)
16 -c.Inc(47)
17 -
18 -g := metrics.NewGauge()
19 -metrics.Register("bar", g)
20 -g.Update(47)
21 -
22 -s := metrics.NewExpDecaySample(1028, 0.015) // or metrics.NewUniformSample(1028)
23 -h := metrics.NewHistogram(s)
24 -metrics.Register("baz", h)
25 -h.Update(47)
26 -
27 -m := metrics.NewMeter()
28 -metrics.Register("quux", m)
29 -m.Mark(47)
30 -
31 -t := metrics.NewTimer()
32 -metrics.Register("bang", t)
33 -t.Time(func() {})
34 -t.Update(47)
35 -```
36 -
37 -Periodically log every metric in human-readable form to standard error:
38 -
39 -```go
40 -go metrics.Log(metrics.DefaultRegistry, 60e9, log.New(os.Stderr, "metrics: ", log.Lmicroseconds))
41 -```
42 -
43 -Periodically log every metric in slightly-more-parseable form to syslog:
44 -
45 -```go
46 -w, _ := syslog.Dial("unixgram", "/dev/log", syslog.LOG_INFO, "metrics")
47 -go metrics.Syslog(metrics.DefaultRegistry, 60e9, w)
48 -```
49 -
50 -Periodically emit every metric to Graphite:
51 -
52 -```go
53 -addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:2003")
54 -go metrics.Graphite(metrics.DefaultRegistry, 10e9, "metrics", addr)
55 -```
56 -
57 -Periodically emit every metric into InfluxDB:
58 -
59 -```go
60 -import "github.com/rcrowley/go-metrics/influxdb"
61 -
62 -go influxdb.Influxdb(metrics.DefaultRegistry, 10e9, &influxdb.Config{
63 - Host: "127.0.0.1:8086",
64 - Database: "metrics",
65 - Username: "test",
66 - Password: "test",
67 -})
68 -```
69 -
70 -Periodically upload every metric to Librato:
71 -
72 -```go
73 -import "github.com/rcrowley/go-metrics/librato"
74 -
75 -go librato.Librato(metrics.DefaultRegistry,
76 - 10e9, // interval
77 - "example@example.com", // account owner email address
78 - "token", // Librato API token
79 - "hostname", // source
80 - []float64{0.95}, // precentiles to send
81 - time.Millisecond, // time unit
82 -)
83 -```
84 -
85 -Periodically emit every metric to StatHat:
86 -
87 -```go
88 -import "github.com/rcrowley/go-metrics/stathat"
89 -
90 -go stathat.Stathat(metrics.DefaultRegistry, 10e9, "example@example.com")
91 -```
92 -
93 -Installation
94 -------------
95 -
96 -```sh
97 -go get github.com/rcrowley/go-metrics
98 -```
99 -
100 -StatHat support additionally requires their Go client:
101 -
102 -```sh
103 -go get github.com/stathat/go
104 -```
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/cmd/metrics-bench/metrics-bench.go deleted
-20
@@ -1,20 +0,0 @@
1 -package main
2 -
3 -import (
4 - "fmt"
5 - "github.com/rcrowley/go-metrics"
6 - "time"
7 -)
8 -
9 -func main() {
10 - r := metrics.NewRegistry()
11 - for i := 0; i < 10000; i++ {
12 - r.Register(fmt.Sprintf("counter-%d", i), metrics.NewCounter())
13 - r.Register(fmt.Sprintf("gauge-%d", i), metrics.NewGauge())
14 - r.Register(fmt.Sprintf("gaugefloat64-%d", i), metrics.NewGaugeFloat64())
15 - r.Register(fmt.Sprintf("histogram-uniform-%d", i), metrics.NewHistogram(metrics.NewUniformSample(1028)))
16 - r.Register(fmt.Sprintf("histogram-exp-%d", i), metrics.NewHistogram(metrics.NewExpDecaySample(1028, 0.015)))
17 - r.Register(fmt.Sprintf("meter-%d", i), metrics.NewMeter())
18 - }
19 - time.Sleep(600e9)
20 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/cmd/metrics-example/metrics-example.go deleted
-154
@@ -1,154 +0,0 @@
1 -package main
2 -
3 -import (
4 - "errors"
5 - "github.com/rcrowley/go-metrics"
6 - // "github.com/rcrowley/go-metrics/stathat"
7 - "log"
8 - "math/rand"
9 - "os"
10 - // "syslog"
11 - "time"
12 -)
13 -
14 -const fanout = 10
15 -
16 -func main() {
17 -
18 - r := metrics.NewRegistry()
19 -
20 - c := metrics.NewCounter()
21 - r.Register("foo", c)
22 - for i := 0; i < fanout; i++ {
23 - go func() {
24 - for {
25 - c.Dec(19)
26 - time.Sleep(300e6)
27 - }
28 - }()
29 - go func() {
30 - for {
31 - c.Inc(47)
32 - time.Sleep(400e6)
33 - }
34 - }()
35 - }
36 -
37 - g := metrics.NewGauge()
38 - r.Register("bar", g)
39 - for i := 0; i < fanout; i++ {
40 - go func() {
41 - for {
42 - g.Update(19)
43 - time.Sleep(300e6)
44 - }
45 - }()
46 - go func() {
47 - for {
48 - g.Update(47)
49 - time.Sleep(400e6)
50 - }
51 - }()
52 - }
53 -
54 - gf := metrics.NewGaugeFloat64()
55 - r.Register("barfloat64", gf)
56 - for i := 0; i < fanout; i++ {
57 - go func() {
58 - for {
59 - g.Update(19.0)
60 - time.Sleep(300e6)
61 - }
62 - }()
63 - go func() {
64 - for {
65 - g.Update(47.0)
66 - time.Sleep(400e6)
67 - }
68 - }()
69 - }
70 -
71 - hc := metrics.NewHealthcheck(func(h metrics.Healthcheck) {
72 - if 0 < rand.Intn(2) {
73 - h.Healthy()
74 - } else {
75 - h.Unhealthy(errors.New("baz"))
76 - }
77 - })
78 - r.Register("baz", hc)
79 -
80 - s := metrics.NewExpDecaySample(1028, 0.015)
81 - //s := metrics.NewUniformSample(1028)
82 - h := metrics.NewHistogram(s)
83 - r.Register("bang", h)
84 - for i := 0; i < fanout; i++ {
85 - go func() {
86 - for {
87 - h.Update(19)
88 - time.Sleep(300e6)
89 - }
90 - }()
91 - go func() {
92 - for {
93 - h.Update(47)
94 - time.Sleep(400e6)
95 - }
96 - }()
97 - }
98 -
99 - m := metrics.NewMeter()
100 - r.Register("quux", m)
101 - for i := 0; i < fanout; i++ {
102 - go func() {
103 - for {
104 - m.Mark(19)
105 - time.Sleep(300e6)
106 - }
107 - }()
108 - go func() {
109 - for {
110 - m.Mark(47)
111 - time.Sleep(400e6)
112 - }
113 - }()
114 - }
115 -
116 - t := metrics.NewTimer()
117 - r.Register("hooah", t)
118 - for i := 0; i < fanout; i++ {
119 - go func() {
120 - for {
121 - t.Time(func() { time.Sleep(300e6) })
122 - }
123 - }()
124 - go func() {
125 - for {
126 - t.Time(func() { time.Sleep(400e6) })
127 - }
128 - }()
129 - }
130 -
131 - metrics.RegisterDebugGCStats(r)
132 - go metrics.CaptureDebugGCStats(r, 5e9)
133 -
134 - metrics.RegisterRuntimeMemStats(r)
135 - go metrics.CaptureRuntimeMemStats(r, 5e9)
136 -
137 - metrics.Log(r, 60e9, log.New(os.Stderr, "metrics: ", log.Lmicroseconds))
138 -
139 - /*
140 - w, err := syslog.Dial("unixgram", "/dev/log", syslog.LOG_INFO, "metrics")
141 - if nil != err { log.Fatalln(err) }
142 - metrics.Syslog(r, 60e9, w)
143 - */
144 -
145 - /*
146 - addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:2003")
147 - metrics.Graphite(r, 10e9, "metrics", addr)
148 - */
149 -
150 - /*
151 - stathat.Stathat(r, 10e9, "example@example.com")
152 - */
153 -
154 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/cmd/never-read/never-read.go deleted
-22
@@ -1,22 +0,0 @@
1 -package main
2 -
3 -import (
4 - "log"
5 - "net"
6 -)
7 -
8 -func main() {
9 - addr, _ := net.ResolveTCPAddr("tcp", "127.0.0.1:2003")
10 - l, err := net.ListenTCP("tcp", addr)
11 - if nil != err {
12 - log.Fatalln(err)
13 - }
14 - log.Println("listening", l.Addr())
15 - for {
16 - c, err := l.AcceptTCP()
17 - if nil != err {
18 - log.Fatalln(err)
19 - }
20 - log.Println("accepted", c.RemoteAddr())
21 - }
22 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/counter.go deleted
-112
@@ -1,112 +0,0 @@
1 -package metrics
2 -
3 -import "sync/atomic"
4 -
5 -// Counters hold an int64 value that can be incremented and decremented.
6 -type Counter interface {
7 - Clear()
8 - Count() int64
9 - Dec(int64)
10 - Inc(int64)
11 - Snapshot() Counter
12 -}
13 -
14 -// GetOrRegisterCounter returns an existing Counter or constructs and registers
15 -// a new StandardCounter.
16 -func GetOrRegisterCounter(name string, r Registry) Counter {
17 - if nil == r {
18 - r = DefaultRegistry
19 - }
20 - return r.GetOrRegister(name, NewCounter).(Counter)
21 -}
22 -
23 -// NewCounter constructs a new StandardCounter.
24 -func NewCounter() Counter {
25 - if UseNilMetrics {
26 - return NilCounter{}
27 - }
28 - return &StandardCounter{0}
29 -}
30 -
31 -// NewRegisteredCounter constructs and registers a new StandardCounter.
32 -func NewRegisteredCounter(name string, r Registry) Counter {
33 - c := NewCounter()
34 - if nil == r {
35 - r = DefaultRegistry
36 - }
37 - r.Register(name, c)
38 - return c
39 -}
40 -
41 -// CounterSnapshot is a read-only copy of another Counter.
42 -type CounterSnapshot int64
43 -
44 -// Clear panics.
45 -func (CounterSnapshot) Clear() {
46 - panic("Clear called on a CounterSnapshot")
47 -}
48 -
49 -// Count returns the count at the time the snapshot was taken.
50 -func (c CounterSnapshot) Count() int64 { return int64(c) }
51 -
52 -// Dec panics.
53 -func (CounterSnapshot) Dec(int64) {
54 - panic("Dec called on a CounterSnapshot")
55 -}
56 -
57 -// Inc panics.
58 -func (CounterSnapshot) Inc(int64) {
59 - panic("Inc called on a CounterSnapshot")
60 -}
61 -
62 -// Snapshot returns the snapshot.
63 -func (c CounterSnapshot) Snapshot() Counter { return c }
64 -
65 -// NilCounter is a no-op Counter.
66 -type NilCounter struct{}
67 -
68 -// Clear is a no-op.
69 -func (NilCounter) Clear() {}
70 -
71 -// Count is a no-op.
72 -func (NilCounter) Count() int64 { return 0 }
73 -
74 -// Dec is a no-op.
75 -func (NilCounter) Dec(i int64) {}
76 -
77 -// Inc is a no-op.
78 -func (NilCounter) Inc(i int64) {}
79 -
80 -// Snapshot is a no-op.
81 -func (NilCounter) Snapshot() Counter { return NilCounter{} }
82 -
83 -// StandardCounter is the standard implementation of a Counter and uses the
84 -// sync/atomic package to manage a single int64 value.
85 -type StandardCounter struct {
86 - count int64
87 -}
88 -
89 -// Clear sets the counter to zero.
90 -func (c *StandardCounter) Clear() {
91 - atomic.StoreInt64(&c.count, 0)
92 -}
93 -
94 -// Count returns the current count.
95 -func (c *StandardCounter) Count() int64 {
96 - return atomic.LoadInt64(&c.count)
97 -}
98 -
99 -// Dec decrements the counter by the given amount.
100 -func (c *StandardCounter) Dec(i int64) {
101 - atomic.AddInt64(&c.count, -i)
102 -}
103 -
104 -// Inc increments the counter by the given amount.
105 -func (c *StandardCounter) Inc(i int64) {
106 - atomic.AddInt64(&c.count, i)
107 -}
108 -
109 -// Snapshot returns a read-only copy of the counter.
110 -func (c *StandardCounter) Snapshot() Counter {
111 - return CounterSnapshot(c.Count())
112 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/counter_test.go deleted
-77
@@ -1,77 +0,0 @@
1 -package metrics
2 -
3 -import "testing"
4 -
5 -func BenchmarkCounter(b *testing.B) {
6 - c := NewCounter()
7 - b.ResetTimer()
8 - for i := 0; i < b.N; i++ {
9 - c.Inc(1)
10 - }
11 -}
12 -
13 -func TestCounterClear(t *testing.T) {
14 - c := NewCounter()
15 - c.Inc(1)
16 - c.Clear()
17 - if count := c.Count(); 0 != count {
18 - t.Errorf("c.Count(): 0 != %v\n", count)
19 - }
20 -}
21 -
22 -func TestCounterDec1(t *testing.T) {
23 - c := NewCounter()
24 - c.Dec(1)
25 - if count := c.Count(); -1 != count {
26 - t.Errorf("c.Count(): -1 != %v\n", count)
27 - }
28 -}
29 -
30 -func TestCounterDec2(t *testing.T) {
31 - c := NewCounter()
32 - c.Dec(2)
33 - if count := c.Count(); -2 != count {
34 - t.Errorf("c.Count(): -2 != %v\n", count)
35 - }
36 -}
37 -
38 -func TestCounterInc1(t *testing.T) {
39 - c := NewCounter()
40 - c.Inc(1)
41 - if count := c.Count(); 1 != count {
42 - t.Errorf("c.Count(): 1 != %v\n", count)
43 - }
44 -}
45 -
46 -func TestCounterInc2(t *testing.T) {
47 - c := NewCounter()
48 - c.Inc(2)
49 - if count := c.Count(); 2 != count {
50 - t.Errorf("c.Count(): 2 != %v\n", count)
51 - }
52 -}
53 -
54 -func TestCounterSnapshot(t *testing.T) {
55 - c := NewCounter()
56 - c.Inc(1)
57 - snapshot := c.Snapshot()
58 - c.Inc(1)
59 - if count := snapshot.Count(); 1 != count {
60 - t.Errorf("c.Count(): 1 != %v\n", count)
61 - }
62 -}
63 -
64 -func TestCounterZero(t *testing.T) {
65 - c := NewCounter()
66 - if count := c.Count(); 0 != count {
67 - t.Errorf("c.Count(): 0 != %v\n", count)
68 - }
69 -}
70 -
71 -func TestGetOrRegisterCounter(t *testing.T) {
72 - r := NewRegistry()
73 - NewRegisteredCounter("foo", r).Inc(47)
74 - if c := GetOrRegisterCounter("foo", r); 47 != c.Count() {
75 - t.Fatal(c)
76 - }
77 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/debug.go deleted
-76
@@ -1,76 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "runtime/debug"
5 - "time"
6 -)
7 -
8 -var (
9 - debugMetrics struct {
10 - GCStats struct {
11 - LastGC Gauge
12 - NumGC Gauge
13 - Pause Histogram
14 - //PauseQuantiles Histogram
15 - PauseTotal Gauge
16 - }
17 - ReadGCStats Timer
18 - }
19 - gcStats debug.GCStats
20 -)
21 -
22 -// Capture new values for the Go garbage collector statistics exported in
23 -// debug.GCStats. This is designed to be called as a goroutine.
24 -func CaptureDebugGCStats(r Registry, d time.Duration) {
25 - for _ = range time.Tick(d) {
26 - CaptureDebugGCStatsOnce(r)
27 - }
28 -}
29 -
30 -// Capture new values for the Go garbage collector statistics exported in
31 -// debug.GCStats. This is designed to be called in a background goroutine.
32 -// Giving a registry which has not been given to RegisterDebugGCStats will
33 -// panic.
34 -//
35 -// Be careful (but much less so) with this because debug.ReadGCStats calls
36 -// the C function runtime·lock(runtime·mheap) which, while not a stop-the-world
37 -// operation, isn't something you want to be doing all the time.
38 -func CaptureDebugGCStatsOnce(r Registry) {
39 - lastGC := gcStats.LastGC
40 - t := time.Now()
41 - debug.ReadGCStats(&gcStats)
42 - debugMetrics.ReadGCStats.UpdateSince(t)
43 -
44 - debugMetrics.GCStats.LastGC.Update(int64(gcStats.LastGC.UnixNano()))
45 - debugMetrics.GCStats.NumGC.Update(int64(gcStats.NumGC))
46 - if lastGC != gcStats.LastGC && 0 < len(gcStats.Pause) {
47 - debugMetrics.GCStats.Pause.Update(int64(gcStats.Pause[0]))
48 - }
49 - //debugMetrics.GCStats.PauseQuantiles.Update(gcStats.PauseQuantiles)
50 - debugMetrics.GCStats.PauseTotal.Update(int64(gcStats.PauseTotal))
51 -}
52 -
53 -// Register metrics for the Go garbage collector statistics exported in
54 -// debug.GCStats. The metrics are named by their fully-qualified Go symbols,
55 -// i.e. debug.GCStats.PauseTotal.
56 -func RegisterDebugGCStats(r Registry) {
57 - debugMetrics.GCStats.LastGC = NewGauge()
58 - debugMetrics.GCStats.NumGC = NewGauge()
59 - debugMetrics.GCStats.Pause = NewHistogram(NewExpDecaySample(1028, 0.015))
60 - //debugMetrics.GCStats.PauseQuantiles = NewHistogram(NewExpDecaySample(1028, 0.015))
61 - debugMetrics.GCStats.PauseTotal = NewGauge()
62 - debugMetrics.ReadGCStats = NewTimer()
63 -
64 - r.Register("debug.GCStats.LastGC", debugMetrics.GCStats.LastGC)
65 - r.Register("debug.GCStats.NumGC", debugMetrics.GCStats.NumGC)
66 - r.Register("debug.GCStats.Pause", debugMetrics.GCStats.Pause)
67 - //r.Register("debug.GCStats.PauseQuantiles", debugMetrics.GCStats.PauseQuantiles)
68 - r.Register("debug.GCStats.PauseTotal", debugMetrics.GCStats.PauseTotal)
69 - r.Register("debug.ReadGCStats", debugMetrics.ReadGCStats)
70 -}
71 -
72 -// Allocate an initial slice for gcStats.Pause to avoid allocations during
73 -// normal operation.
74 -func init() {
75 - gcStats.Pause = make([]time.Duration, 11)
76 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/debug_test.go deleted
-48
@@ -1,48 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "runtime"
5 - "runtime/debug"
6 - "testing"
7 - "time"
8 -)
9 -
10 -func BenchmarkDebugGCStats(b *testing.B) {
11 - r := NewRegistry()
12 - RegisterDebugGCStats(r)
13 - b.ResetTimer()
14 - for i := 0; i < b.N; i++ {
15 - CaptureDebugGCStatsOnce(r)
16 - }
17 -}
18 -
19 -func TestDebugGCStatsBlocking(t *testing.T) {
20 - if g := runtime.GOMAXPROCS(0); g < 2 {
21 - t.Skipf("skipping TestDebugGCMemStatsBlocking with GOMAXPROCS=%d\n", g)
22 - return
23 - }
24 - ch := make(chan int)
25 - go testDebugGCStatsBlocking(ch)
26 - var gcStats debug.GCStats
27 - t0 := time.Now()
28 - debug.ReadGCStats(&gcStats)
29 - t1 := time.Now()
30 - t.Log("i++ during debug.ReadGCStats:", <-ch)
31 - go testDebugGCStatsBlocking(ch)
32 - d := t1.Sub(t0)
33 - t.Log(d)
34 - time.Sleep(d)
35 - t.Log("i++ during time.Sleep:", <-ch)
36 -}
37 -
38 -func testDebugGCStatsBlocking(ch chan int) {
39 - i := 0
40 - for {
41 - select {
42 - case ch <- i:
43 - return
44 - default:
45 - i++
46 - }
47 - }
48 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/ewma.go deleted
-123
@@ -1,123 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "math"
5 - "sync"
6 - "sync/atomic"
7 -)
8 -
9 -// EWMAs continuously calculate an exponentially-weighted moving average
10 -// based on an outside source of clock ticks.
11 -type EWMA interface {
12 - Rate() float64
13 - Snapshot() EWMA
14 - Tick()
15 - Update(int64)
16 -}
17 -
18 -// NewEWMA constructs a new EWMA with the given alpha.
19 -func NewEWMA(alpha float64) EWMA {
20 - if UseNilMetrics {
21 - return NilEWMA{}
22 - }
23 - return &StandardEWMA{alpha: alpha}
24 -}
25 -
26 -// NewEWMAFine constructs a new EWMA for a one-second moving average.
27 -func NewEWMAFine() EWMA {
28 - return NewEWMA(1 - math.Exp(-1.0))
29 -}
30 -
31 -// NewEWMA1 constructs a new EWMA for a one-minute moving average.
32 -func NewEWMA1() EWMA {
33 - return NewEWMA(1 - math.Exp(-5.0/60.0/1))
34 -}
35 -
36 -// NewEWMA5 constructs a new EWMA for a five-minute moving average.
37 -func NewEWMA5() EWMA {
38 - return NewEWMA(1 - math.Exp(-5.0/60.0/5))
39 -}
40 -
41 -// NewEWMA15 constructs a new EWMA for a fifteen-minute moving average.
42 -func NewEWMA15() EWMA {
43 - return NewEWMA(1 - math.Exp(-5.0/60.0/15))
44 -}
45 -
46 -// EWMASnapshot is a read-only copy of another EWMA.
47 -type EWMASnapshot float64
48 -
49 -// Rate returns the rate of events per second at the time the snapshot was
50 -// taken.
51 -func (a EWMASnapshot) Rate() float64 { return float64(a) }
52 -
53 -// Snapshot returns the snapshot.
54 -func (a EWMASnapshot) Snapshot() EWMA { return a }
55 -
56 -// Tick panics.
57 -func (EWMASnapshot) Tick() {
58 - panic("Tick called on an EWMASnapshot")
59 -}
60 -
61 -// Update panics.
62 -func (EWMASnapshot) Update(int64) {
63 - panic("Update called on an EWMASnapshot")
64 -}
65 -
66 -// NilEWMA is a no-op EWMA.
67 -type NilEWMA struct{}
68 -
69 -// Rate is a no-op.
70 -func (NilEWMA) Rate() float64 { return 0.0 }
71 -
72 -// Snapshot is a no-op.
73 -func (NilEWMA) Snapshot() EWMA { return NilEWMA{} }
74 -
75 -// Tick is a no-op.
76 -func (NilEWMA) Tick() {}
77 -
78 -// Update is a no-op.
79 -func (NilEWMA) Update(n int64) {}
80 -
81 -// StandardEWMA is the standard implementation of an EWMA and tracks the number
82 -// of uncounted events and processes them on each tick. It uses the
83 -// sync/atomic package to manage uncounted events.
84 -type StandardEWMA struct {
85 - uncounted int64 // /!\ this should be the first member to ensure 64-bit alignment
86 - alpha float64
87 - rate float64
88 - init bool
89 - mutex sync.Mutex
90 -}
91 -
92 -// Rate returns the moving average rate of events per second.
93 -func (a *StandardEWMA) Rate() float64 {
94 - a.mutex.Lock()
95 - defer a.mutex.Unlock()
96 - return a.rate * float64(1e9)
97 -}
98 -
99 -// Snapshot returns a read-only copy of the EWMA.
100 -func (a *StandardEWMA) Snapshot() EWMA {
101 - return EWMASnapshot(a.Rate())
102 -}
103 -
104 -// Tick ticks the clock to update the moving average. It assumes it is called
105 -// every five seconds.
106 -func (a *StandardEWMA) Tick() {
107 - count := atomic.LoadInt64(&a.uncounted)
108 - atomic.AddInt64(&a.uncounted, -count)
109 - instantRate := float64(count) / float64(5e9)
110 - a.mutex.Lock()
111 - defer a.mutex.Unlock()
112 - if a.init {
113 - a.rate += a.alpha * (instantRate - a.rate)
114 - } else {
115 - a.init = true
116 - a.rate = instantRate
117 - }
118 -}
119 -
120 -// Update adds n uncounted events.
121 -func (a *StandardEWMA) Update(n int64) {
122 - atomic.AddInt64(&a.uncounted, n)
123 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/ewma_test.go deleted
-225
@@ -1,225 +0,0 @@
1 -package metrics
2 -
3 -import "testing"
4 -
5 -func BenchmarkEWMA(b *testing.B) {
6 - a := NewEWMA1()
7 - b.ResetTimer()
8 - for i := 0; i < b.N; i++ {
9 - a.Update(1)
10 - a.Tick()
11 - }
12 -}
13 -
14 -func TestEWMA1(t *testing.T) {
15 - a := NewEWMA1()
16 - a.Update(3)
17 - a.Tick()
18 - if rate := a.Rate(); 0.6 != rate {
19 - t.Errorf("initial a.Rate(): 0.6 != %v\n", rate)
20 - }
21 - elapseMinute(a)
22 - if rate := a.Rate(); 0.22072766470286553 != rate {
23 - t.Errorf("1 minute a.Rate(): 0.22072766470286553 != %v\n", rate)
24 - }
25 - elapseMinute(a)
26 - if rate := a.Rate(); 0.08120116994196772 != rate {
27 - t.Errorf("2 minute a.Rate(): 0.08120116994196772 != %v\n", rate)
28 - }
29 - elapseMinute(a)
30 - if rate := a.Rate(); 0.029872241020718428 != rate {
31 - t.Errorf("3 minute a.Rate(): 0.029872241020718428 != %v\n", rate)
32 - }
33 - elapseMinute(a)
34 - if rate := a.Rate(); 0.01098938333324054 != rate {
35 - t.Errorf("4 minute a.Rate(): 0.01098938333324054 != %v\n", rate)
36 - }
37 - elapseMinute(a)
38 - if rate := a.Rate(); 0.004042768199451294 != rate {
39 - t.Errorf("5 minute a.Rate(): 0.004042768199451294 != %v\n", rate)
40 - }
41 - elapseMinute(a)
42 - if rate := a.Rate(); 0.0014872513059998212 != rate {
43 - t.Errorf("6 minute a.Rate(): 0.0014872513059998212 != %v\n", rate)
44 - }
45 - elapseMinute(a)
46 - if rate := a.Rate(); 0.0005471291793327122 != rate {
47 - t.Errorf("7 minute a.Rate(): 0.0005471291793327122 != %v\n", rate)
48 - }
49 - elapseMinute(a)
50 - if rate := a.Rate(); 0.00020127757674150815 != rate {
51 - t.Errorf("8 minute a.Rate(): 0.00020127757674150815 != %v\n", rate)
52 - }
53 - elapseMinute(a)
54 - if rate := a.Rate(); 7.404588245200814e-05 != rate {
55 - t.Errorf("9 minute a.Rate(): 7.404588245200814e-05 != %v\n", rate)
56 - }
57 - elapseMinute(a)
58 - if rate := a.Rate(); 2.7239957857491083e-05 != rate {
59 - t.Errorf("10 minute a.Rate(): 2.7239957857491083e-05 != %v\n", rate)
60 - }
61 - elapseMinute(a)
62 - if rate := a.Rate(); 1.0021020474147462e-05 != rate {
63 - t.Errorf("11 minute a.Rate(): 1.0021020474147462e-05 != %v\n", rate)
64 - }
65 - elapseMinute(a)
66 - if rate := a.Rate(); 3.6865274119969525e-06 != rate {
67 - t.Errorf("12 minute a.Rate(): 3.6865274119969525e-06 != %v\n", rate)
68 - }
69 - elapseMinute(a)
70 - if rate := a.Rate(); 1.3561976441886433e-06 != rate {
71 - t.Errorf("13 minute a.Rate(): 1.3561976441886433e-06 != %v\n", rate)
72 - }
73 - elapseMinute(a)
74 - if rate := a.Rate(); 4.989172314621449e-07 != rate {
75 - t.Errorf("14 minute a.Rate(): 4.989172314621449e-07 != %v\n", rate)
76 - }
77 - elapseMinute(a)
78 - if rate := a.Rate(); 1.8354139230109722e-07 != rate {
79 - t.Errorf("15 minute a.Rate(): 1.8354139230109722e-07 != %v\n", rate)
80 - }
81 -}
82 -
83 -func TestEWMA5(t *testing.T) {
84 - a := NewEWMA5()
85 - a.Update(3)
86 - a.Tick()
87 - if rate := a.Rate(); 0.6 != rate {
88 - t.Errorf("initial a.Rate(): 0.6 != %v\n", rate)
89 - }
90 - elapseMinute(a)
91 - if rate := a.Rate(); 0.49123845184678905 != rate {
92 - t.Errorf("1 minute a.Rate(): 0.49123845184678905 != %v\n", rate)
93 - }
94 - elapseMinute(a)
95 - if rate := a.Rate(); 0.4021920276213837 != rate {
96 - t.Errorf("2 minute a.Rate(): 0.4021920276213837 != %v\n", rate)
97 - }
98 - elapseMinute(a)
99 - if rate := a.Rate(); 0.32928698165641596 != rate {
100 - t.Errorf("3 minute a.Rate(): 0.32928698165641596 != %v\n", rate)
101 - }
102 - elapseMinute(a)
103 - if rate := a.Rate(); 0.269597378470333 != rate {
104 - t.Errorf("4 minute a.Rate(): 0.269597378470333 != %v\n", rate)
105 - }
106 - elapseMinute(a)
107 - if rate := a.Rate(); 0.2207276647028654 != rate {
108 - t.Errorf("5 minute a.Rate(): 0.2207276647028654 != %v\n", rate)
109 - }
110 - elapseMinute(a)
111 - if rate := a.Rate(); 0.18071652714732128 != rate {
112 - t.Errorf("6 minute a.Rate(): 0.18071652714732128 != %v\n", rate)
113 - }
114 - elapseMinute(a)
115 - if rate := a.Rate(); 0.14795817836496392 != rate {
116 - t.Errorf("7 minute a.Rate(): 0.14795817836496392 != %v\n", rate)
117 - }
118 - elapseMinute(a)
119 - if rate := a.Rate(); 0.12113791079679326 != rate {
120 - t.Errorf("8 minute a.Rate(): 0.12113791079679326 != %v\n", rate)
121 - }
122 - elapseMinute(a)
123 - if rate := a.Rate(); 0.09917933293295193 != rate {
124 - t.Errorf("9 minute a.Rate(): 0.09917933293295193 != %v\n", rate)
125 - }
126 - elapseMinute(a)
127 - if rate := a.Rate(); 0.08120116994196763 != rate {
128 - t.Errorf("10 minute a.Rate(): 0.08120116994196763 != %v\n", rate)
129 - }
130 - elapseMinute(a)
131 - if rate := a.Rate(); 0.06648189501740036 != rate {
132 - t.Errorf("11 minute a.Rate(): 0.06648189501740036 != %v\n", rate)
133 - }
134 - elapseMinute(a)
135 - if rate := a.Rate(); 0.05443077197364752 != rate {
136 - t.Errorf("12 minute a.Rate(): 0.05443077197364752 != %v\n", rate)
137 - }
138 - elapseMinute(a)
139 - if rate := a.Rate(); 0.04456414692860035 != rate {
140 - t.Errorf("13 minute a.Rate(): 0.04456414692860035 != %v\n", rate)
141 - }
142 - elapseMinute(a)
143 - if rate := a.Rate(); 0.03648603757513079 != rate {
144 - t.Errorf("14 minute a.Rate(): 0.03648603757513079 != %v\n", rate)
145 - }
146 - elapseMinute(a)
147 - if rate := a.Rate(); 0.0298722410207183831020718428 != rate {
148 - t.Errorf("15 minute a.Rate(): 0.0298722410207183831020718428 != %v\n", rate)
149 - }
150 -}
151 -
152 -func TestEWMA15(t *testing.T) {
153 - a := NewEWMA15()
154 - a.Update(3)
155 - a.Tick()
156 - if rate := a.Rate(); 0.6 != rate {
157 - t.Errorf("initial a.Rate(): 0.6 != %v\n", rate)
158 - }
159 - elapseMinute(a)
160 - if rate := a.Rate(); 0.5613041910189706 != rate {
161 - t.Errorf("1 minute a.Rate(): 0.5613041910189706 != %v\n", rate)
162 - }
163 - elapseMinute(a)
164 - if rate := a.Rate(); 0.5251039914257684 != rate {
165 - t.Errorf("2 minute a.Rate(): 0.5251039914257684 != %v\n", rate)
166 - }
167 - elapseMinute(a)
168 - if rate := a.Rate(); 0.4912384518467888184678905 != rate {
169 - t.Errorf("3 minute a.Rate(): 0.4912384518467888184678905 != %v\n", rate)
170 - }
171 - elapseMinute(a)
172 - if rate := a.Rate(); 0.459557003018789 != rate {
173 - t.Errorf("4 minute a.Rate(): 0.459557003018789 != %v\n", rate)
174 - }
175 - elapseMinute(a)
176 - if rate := a.Rate(); 0.4299187863442732 != rate {
177 - t.Errorf("5 minute a.Rate(): 0.4299187863442732 != %v\n", rate)
178 - }
179 - elapseMinute(a)
180 - if rate := a.Rate(); 0.4021920276213831 != rate {
181 - t.Errorf("6 minute a.Rate(): 0.4021920276213831 != %v\n", rate)
182 - }
183 - elapseMinute(a)
184 - if rate := a.Rate(); 0.37625345116383313 != rate {
185 - t.Errorf("7 minute a.Rate(): 0.37625345116383313 != %v\n", rate)
186 - }
187 - elapseMinute(a)
188 - if rate := a.Rate(); 0.3519877317060185 != rate {
189 - t.Errorf("8 minute a.Rate(): 0.3519877317060185 != %v\n", rate)
190 - }
191 - elapseMinute(a)
192 - if rate := a.Rate(); 0.3292869816564153165641596 != rate {
193 - t.Errorf("9 minute a.Rate(): 0.3292869816564153165641596 != %v\n", rate)
194 - }
195 - elapseMinute(a)
196 - if rate := a.Rate(); 0.3080502714195546 != rate {
197 - t.Errorf("10 minute a.Rate(): 0.3080502714195546 != %v\n", rate)
198 - }
199 - elapseMinute(a)
200 - if rate := a.Rate(); 0.2881831806538789 != rate {
201 - t.Errorf("11 minute a.Rate(): 0.2881831806538789 != %v\n", rate)
202 - }
203 - elapseMinute(a)
204 - if rate := a.Rate(); 0.26959737847033216 != rate {
205 - t.Errorf("12 minute a.Rate(): 0.26959737847033216 != %v\n", rate)
206 - }
207 - elapseMinute(a)
208 - if rate := a.Rate(); 0.2522102307052083 != rate {
209 - t.Errorf("13 minute a.Rate(): 0.2522102307052083 != %v\n", rate)
210 - }
211 - elapseMinute(a)
212 - if rate := a.Rate(); 0.23594443252115815 != rate {
213 - t.Errorf("14 minute a.Rate(): 0.23594443252115815 != %v\n", rate)
214 - }
215 - elapseMinute(a)
216 - if rate := a.Rate(); 0.2207276647028646247028654470286553 != rate {
217 - t.Errorf("15 minute a.Rate(): 0.2207276647028646247028654470286553 != %v\n", rate)
218 - }
219 -}
220 -
221 -func elapseMinute(a EWMA) {
222 - for i := 0; i < 12; i++ {
223 - a.Tick()
224 - }
225 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/gauge.go deleted
-84
@@ -1,84 +0,0 @@
1 -package metrics
2 -
3 -import "sync/atomic"
4 -
5 -// Gauges hold an int64 value that can be set arbitrarily.
6 -type Gauge interface {
7 - Snapshot() Gauge
8 - Update(int64)
9 - Value() int64
10 -}
11 -
12 -// GetOrRegisterGauge returns an existing Gauge or constructs and registers a
13 -// new StandardGauge.
14 -func GetOrRegisterGauge(name string, r Registry) Gauge {
15 - if nil == r {
16 - r = DefaultRegistry
17 - }
18 - return r.GetOrRegister(name, NewGauge).(Gauge)
19 -}
20 -
21 -// NewGauge constructs a new StandardGauge.
22 -func NewGauge() Gauge {
23 - if UseNilMetrics {
24 - return NilGauge{}
25 - }
26 - return &StandardGauge{0}
27 -}
28 -
29 -// NewRegisteredGauge constructs and registers a new StandardGauge.
30 -func NewRegisteredGauge(name string, r Registry) Gauge {
31 - c := NewGauge()
32 - if nil == r {
33 - r = DefaultRegistry
34 - }
35 - r.Register(name, c)
36 - return c
37 -}
38 -
39 -// GaugeSnapshot is a read-only copy of another Gauge.
40 -type GaugeSnapshot int64
41 -
42 -// Snapshot returns the snapshot.
43 -func (g GaugeSnapshot) Snapshot() Gauge { return g }
44 -
45 -// Update panics.
46 -func (GaugeSnapshot) Update(int64) {
47 - panic("Update called on a GaugeSnapshot")
48 -}
49 -
50 -// Value returns the value at the time the snapshot was taken.
51 -func (g GaugeSnapshot) Value() int64 { return int64(g) }
52 -
53 -// NilGauge is a no-op Gauge.
54 -type NilGauge struct{}
55 -
56 -// Snapshot is a no-op.
57 -func (NilGauge) Snapshot() Gauge { return NilGauge{} }
58 -
59 -// Update is a no-op.
60 -func (NilGauge) Update(v int64) {}
61 -
62 -// Value is a no-op.
63 -func (NilGauge) Value() int64 { return 0 }
64 -
65 -// StandardGauge is the standard implementation of a Gauge and uses the
66 -// sync/atomic package to manage a single int64 value.
67 -type StandardGauge struct {
68 - value int64
69 -}
70 -
71 -// Snapshot returns a read-only copy of the gauge.
72 -func (g *StandardGauge) Snapshot() Gauge {
73 - return GaugeSnapshot(g.Value())
74 -}
75 -
76 -// Update updates the gauge's value.
77 -func (g *StandardGauge) Update(v int64) {
78 - atomic.StoreInt64(&g.value, v)
79 -}
80 -
81 -// Value returns the gauge's current value.
82 -func (g *StandardGauge) Value() int64 {
83 - return atomic.LoadInt64(&g.value)
84 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/gauge_float64.go deleted
-91
@@ -1,91 +0,0 @@
1 -package metrics
2 -
3 -import "sync"
4 -
5 -// GaugeFloat64s hold a float64 value that can be set arbitrarily.
6 -type GaugeFloat64 interface {
7 - Snapshot() GaugeFloat64
8 - Update(float64)
9 - Value() float64
10 -}
11 -
12 -// GetOrRegisterGaugeFloat64 returns an existing GaugeFloat64 or constructs and registers a
13 -// new StandardGaugeFloat64.
14 -func GetOrRegisterGaugeFloat64(name string, r Registry) GaugeFloat64 {
15 - if nil == r {
16 - r = DefaultRegistry
17 - }
18 - return r.GetOrRegister(name, NewGaugeFloat64()).(GaugeFloat64)
19 -}
20 -
21 -// NewGaugeFloat64 constructs a new StandardGaugeFloat64.
22 -func NewGaugeFloat64() GaugeFloat64 {
23 - if UseNilMetrics {
24 - return NilGaugeFloat64{}
25 - }
26 - return &StandardGaugeFloat64{
27 - value: 0.0,
28 - }
29 -}
30 -
31 -// NewRegisteredGaugeFloat64 constructs and registers a new StandardGaugeFloat64.
32 -func NewRegisteredGaugeFloat64(name string, r Registry) GaugeFloat64 {
33 - c := NewGaugeFloat64()
34 - if nil == r {
35 - r = DefaultRegistry
36 - }
37 - r.Register(name, c)
38 - return c
39 -}
40 -
41 -// GaugeFloat64Snapshot is a read-only copy of another GaugeFloat64.
42 -type GaugeFloat64Snapshot float64
43 -
44 -// Snapshot returns the snapshot.
45 -func (g GaugeFloat64Snapshot) Snapshot() GaugeFloat64 { return g }
46 -
47 -// Update panics.
48 -func (GaugeFloat64Snapshot) Update(float64) {
49 - panic("Update called on a GaugeFloat64Snapshot")
50 -}
51 -
52 -// Value returns the value at the time the snapshot was taken.
53 -func (g GaugeFloat64Snapshot) Value() float64 { return float64(g) }
54 -
55 -// NilGauge is a no-op Gauge.
56 -type NilGaugeFloat64 struct{}
57 -
58 -// Snapshot is a no-op.
59 -func (NilGaugeFloat64) Snapshot() GaugeFloat64 { return NilGaugeFloat64{} }
60 -
61 -// Update is a no-op.
62 -func (NilGaugeFloat64) Update(v float64) {}
63 -
64 -// Value is a no-op.
65 -func (NilGaugeFloat64) Value() float64 { return 0.0 }
66 -
67 -// StandardGaugeFloat64 is the standard implementation of a GaugeFloat64 and uses
68 -// sync.Mutex to manage a single float64 value.
69 -type StandardGaugeFloat64 struct {
70 - mutex sync.Mutex
71 - value float64
72 -}
73 -
74 -// Snapshot returns a read-only copy of the gauge.
75 -func (g *StandardGaugeFloat64) Snapshot() GaugeFloat64 {
76 - return GaugeFloat64Snapshot(g.Value())
77 -}
78 -
79 -// Update updates the gauge's value.
80 -func (g *StandardGaugeFloat64) Update(v float64) {
81 - g.mutex.Lock()
82 - defer g.mutex.Unlock()
83 - g.value = v
84 -}
85 -
86 -// Value returns the gauge's current value.
87 -func (g *StandardGaugeFloat64) Value() float64 {
88 - g.mutex.Lock()
89 - defer g.mutex.Unlock()
90 - return g.value
91 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/gauge_float64_test.go deleted
-38
@@ -1,38 +0,0 @@
1 -package metrics
2 -
3 -import "testing"
4 -
5 -func BenchmarkGuageFloat64(b *testing.B) {
6 - g := NewGaugeFloat64()
7 - b.ResetTimer()
8 - for i := 0; i < b.N; i++ {
9 - g.Update(float64(i))
10 - }
11 -}
12 -
13 -func TestGaugeFloat64(t *testing.T) {
14 - g := NewGaugeFloat64()
15 - g.Update(float64(47.0))
16 - if v := g.Value(); float64(47.0) != v {
17 - t.Errorf("g.Value(): 47.0 != %v\n", v)
18 - }
19 -}
20 -
21 -func TestGaugeFloat64Snapshot(t *testing.T) {
22 - g := NewGaugeFloat64()
23 - g.Update(float64(47.0))
24 - snapshot := g.Snapshot()
25 - g.Update(float64(0))
26 - if v := snapshot.Value(); float64(47.0) != v {
27 - t.Errorf("g.Value(): 47.0 != %v\n", v)
28 - }
29 -}
30 -
31 -func TestGetOrRegisterGaugeFloat64(t *testing.T) {
32 - r := NewRegistry()
33 - NewRegisteredGaugeFloat64("foo", r).Update(float64(47.0))
34 - t.Logf("registry: %v", r)
35 - if g := GetOrRegisterGaugeFloat64("foo", r); float64(47.0) != g.Value() {
36 - t.Fatal(g)
37 - }
38 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/gauge_test.go deleted
-37
@@ -1,37 +0,0 @@
1 -package metrics
2 -
3 -import "testing"
4 -
5 -func BenchmarkGuage(b *testing.B) {
6 - g := NewGauge()
7 - b.ResetTimer()
8 - for i := 0; i < b.N; i++ {
9 - g.Update(int64(i))
10 - }
11 -}
12 -
13 -func TestGauge(t *testing.T) {
14 - g := NewGauge()
15 - g.Update(int64(47))
16 - if v := g.Value(); 47 != v {
17 - t.Errorf("g.Value(): 47 != %v\n", v)
18 - }
19 -}
20 -
21 -func TestGaugeSnapshot(t *testing.T) {
22 - g := NewGauge()
23 - g.Update(int64(47))
24 - snapshot := g.Snapshot()
25 - g.Update(int64(0))
26 - if v := snapshot.Value(); 47 != v {
27 - t.Errorf("g.Value(): 47 != %v\n", v)
28 - }
29 -}
30 -
31 -func TestGetOrRegisterGauge(t *testing.T) {
32 - r := NewRegistry()
33 - NewRegisteredGauge("foo", r).Update(47)
34 - if g := GetOrRegisterGauge("foo", r); 47 != g.Value() {
35 - t.Fatal(g)
36 - }
37 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/graphite.go deleted
-111
@@ -1,111 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "bufio"
5 - "fmt"
6 - "log"
7 - "net"
8 - "strconv"
9 - "strings"
10 - "time"
11 -)
12 -
13 -// GraphiteConfig provides a container with configuration parameters for
14 -// the Graphite exporter
15 -type GraphiteConfig struct {
16 - Addr *net.TCPAddr // Network address to connect to
17 - Registry Registry // Registry to be exported
18 - FlushInterval time.Duration // Flush interval
19 - DurationUnit time.Duration // Time conversion unit for durations
20 - Prefix string // Prefix to be prepended to metric names
21 - Percentiles []float64 // Percentiles to export from timers and histograms
22 -}
23 -
24 -// Graphite is a blocking exporter function which reports metrics in r
25 -// to a graphite server located at addr, flushing them every d duration
26 -// and prepending metric names with prefix.
27 -func Graphite(r Registry, d time.Duration, prefix string, addr *net.TCPAddr) {
28 - GraphiteWithConfig(GraphiteConfig{
29 - Addr: addr,
30 - Registry: r,
31 - FlushInterval: d,
32 - DurationUnit: time.Nanosecond,
33 - Prefix: prefix,
34 - Percentiles: []float64{0.5, 0.75, 0.95, 0.99, 0.999},
35 - })
36 -}
37 -
38 -// GraphiteWithConfig is a blocking exporter function just like Graphite,
39 -// but it takes a GraphiteConfig instead.
40 -func GraphiteWithConfig(c GraphiteConfig) {
41 - for _ = range time.Tick(c.FlushInterval) {
42 - if err := graphite(&c); nil != err {
43 - log.Println(err)
44 - }
45 - }
46 -}
47 -
48 -// GraphiteOnce performs a single submission to Graphite, returning a
49 -// non-nil error on failed connections. This can be used in a loop
50 -// similar to GraphiteWithConfig for custom error handling.
51 -func GraphiteOnce(c GraphiteConfig) error {
52 - return graphite(&c)
53 -}
54 -
55 -func graphite(c *GraphiteConfig) error {
56 - now := time.Now().Unix()
57 - du := float64(c.DurationUnit)
58 - conn, err := net.DialTCP("tcp", nil, c.Addr)
59 - if nil != err {
60 - return err
61 - }
62 - defer conn.Close()
63 - w := bufio.NewWriter(conn)
64 - c.Registry.Each(func(name string, i interface{}) {
65 - switch metric := i.(type) {
66 - case Counter:
67 - fmt.Fprintf(w, "%s.%s.count %d %d\n", c.Prefix, name, metric.Count(), now)
68 - case Gauge:
69 - fmt.Fprintf(w, "%s.%s.value %d %d\n", c.Prefix, name, metric.Value(), now)
70 - case GaugeFloat64:
71 - fmt.Fprintf(w, "%s.%s.value %f %d\n", c.Prefix, name, metric.Value(), now)
72 - case Histogram:
73 - h := metric.Snapshot()
74 - ps := h.Percentiles(c.Percentiles)
75 - fmt.Fprintf(w, "%s.%s.count %d %d\n", c.Prefix, name, h.Count(), now)
76 - fmt.Fprintf(w, "%s.%s.min %d %d\n", c.Prefix, name, h.Min(), now)
77 - fmt.Fprintf(w, "%s.%s.max %d %d\n", c.Prefix, name, h.Max(), now)
78 - fmt.Fprintf(w, "%s.%s.mean %.2f %d\n", c.Prefix, name, h.Mean(), now)
79 - fmt.Fprintf(w, "%s.%s.std-dev %.2f %d\n", c.Prefix, name, h.StdDev(), now)
80 - for psIdx, psKey := range c.Percentiles {
81 - key := strings.Replace(strconv.FormatFloat(psKey*100.0, 'f', -1, 64), ".", "", 1)
82 - fmt.Fprintf(w, "%s.%s.%s-percentile %.2f %d\n", c.Prefix, name, key, ps[psIdx], now)
83 - }
84 - case Meter:
85 - m := metric.Snapshot()
86 - fmt.Fprintf(w, "%s.%s.count %d %d\n", c.Prefix, name, m.Count(), now)
87 - fmt.Fprintf(w, "%s.%s.one-minute %.2f %d\n", c.Prefix, name, m.Rate1(), now)
88 - fmt.Fprintf(w, "%s.%s.five-minute %.2f %d\n", c.Prefix, name, m.Rate5(), now)
89 - fmt.Fprintf(w, "%s.%s.fifteen-minute %.2f %d\n", c.Prefix, name, m.Rate15(), now)
90 - fmt.Fprintf(w, "%s.%s.mean %.2f %d\n", c.Prefix, name, m.RateMean(), now)
91 - case Timer:
92 - t := metric.Snapshot()
93 - ps := t.Percentiles(c.Percentiles)
94 - fmt.Fprintf(w, "%s.%s.count %d %d\n", c.Prefix, name, t.Count(), now)
95 - fmt.Fprintf(w, "%s.%s.min %d %d\n", c.Prefix, name, t.Min()/int64(du), now)
96 - fmt.Fprintf(w, "%s.%s.max %d %d\n", c.Prefix, name, t.Max()/int64(du), now)
97 - fmt.Fprintf(w, "%s.%s.mean %.2f %d\n", c.Prefix, name, t.Mean()/du, now)
98 - fmt.Fprintf(w, "%s.%s.std-dev %.2f %d\n", c.Prefix, name, t.StdDev()/du, now)
99 - for psIdx, psKey := range c.Percentiles {
100 - key := strings.Replace(strconv.FormatFloat(psKey*100.0, 'f', -1, 64), ".", "", 1)
101 - fmt.Fprintf(w, "%s.%s.%s-percentile %.2f %d\n", c.Prefix, name, key, ps[psIdx], now)
102 - }
103 - fmt.Fprintf(w, "%s.%s.one-minute %.2f %d\n", c.Prefix, name, t.Rate1(), now)
104 - fmt.Fprintf(w, "%s.%s.five-minute %.2f %d\n", c.Prefix, name, t.Rate5(), now)
105 - fmt.Fprintf(w, "%s.%s.fifteen-minute %.2f %d\n", c.Prefix, name, t.Rate15(), now)
106 - fmt.Fprintf(w, "%s.%s.mean-rate %.2f %d\n", c.Prefix, name, t.RateMean(), now)
107 - }
108 - w.Flush()
109 - })
110 - return nil
111 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/graphite_test.go deleted
-22
@@ -1,22 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "net"
5 - "time"
6 -)
7 -
8 -func ExampleGraphite() {
9 - addr, _ := net.ResolveTCPAddr("net", ":2003")
10 - go Graphite(DefaultRegistry, 1*time.Second, "some.prefix", addr)
11 -}
12 -
13 -func ExampleGraphiteWithConfig() {
14 - addr, _ := net.ResolveTCPAddr("net", ":2003")
15 - go GraphiteWithConfig(GraphiteConfig{
16 - Addr: addr,
17 - Registry: DefaultRegistry,
18 - FlushInterval: 1 * time.Second,
19 - DurationUnit: time.Millisecond,
20 - Percentiles: []float64{ 0.5, 0.75, 0.99, 0.999 },
21 - })
22 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/healthcheck.go deleted
-61
@@ -1,61 +0,0 @@
1 -package metrics
2 -
3 -// Healthchecks hold an error value describing an arbitrary up/down status.
4 -type Healthcheck interface {
5 - Check()
6 - Error() error
7 - Healthy()
8 - Unhealthy(error)
9 -}
10 -
11 -// NewHealthcheck constructs a new Healthcheck which will use the given
12 -// function to update its status.
13 -func NewHealthcheck(f func(Healthcheck)) Healthcheck {
14 - if UseNilMetrics {
15 - return NilHealthcheck{}
16 - }
17 - return &StandardHealthcheck{nil, f}
18 -}
19 -
20 -// NilHealthcheck is a no-op.
21 -type NilHealthcheck struct{}
22 -
23 -// Check is a no-op.
24 -func (NilHealthcheck) Check() {}
25 -
26 -// Error is a no-op.
27 -func (NilHealthcheck) Error() error { return nil }
28 -
29 -// Healthy is a no-op.
30 -func (NilHealthcheck) Healthy() {}
31 -
32 -// Unhealthy is a no-op.
33 -func (NilHealthcheck) Unhealthy(error) {}
34 -
35 -// StandardHealthcheck is the standard implementation of a Healthcheck and
36 -// stores the status and a function to call to update the status.
37 -type StandardHealthcheck struct {
38 - err error
39 - f func(Healthcheck)
40 -}
41 -
42 -// Check runs the healthcheck function to update the healthcheck's status.
43 -func (h *StandardHealthcheck) Check() {
44 - h.f(h)
45 -}
46 -
47 -// Error returns the healthcheck's status, which will be nil if it is healthy.
48 -func (h *StandardHealthcheck) Error() error {
49 - return h.err
50 -}
51 -
52 -// Healthy marks the healthcheck as healthy.
53 -func (h *StandardHealthcheck) Healthy() {
54 - h.err = nil
55 -}
56 -
57 -// Unhealthy marks the healthcheck as unhealthy. The error is stored and
58 -// may be retrieved by the Error method.
59 -func (h *StandardHealthcheck) Unhealthy(err error) {
60 - h.err = err
61 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/histogram.go deleted
-202
@@ -1,202 +0,0 @@
1 -package metrics
2 -
3 -// Histograms calculate distribution statistics from a series of int64 values.
4 -type Histogram interface {
5 - Clear()
6 - Count() int64
7 - Max() int64
8 - Mean() float64
9 - Min() int64
10 - Percentile(float64) float64
11 - Percentiles([]float64) []float64
12 - Sample() Sample
13 - Snapshot() Histogram
14 - StdDev() float64
15 - Sum() int64
16 - Update(int64)
17 - Variance() float64
18 -}
19 -
20 -// GetOrRegisterHistogram returns an existing Histogram or constructs and
21 -// registers a new StandardHistogram.
22 -func GetOrRegisterHistogram(name string, r Registry, s Sample) Histogram {
23 - if nil == r {
24 - r = DefaultRegistry
25 - }
26 - return r.GetOrRegister(name, func() Histogram { return NewHistogram(s) }).(Histogram)
27 -}
28 -
29 -// NewHistogram constructs a new StandardHistogram from a Sample.
30 -func NewHistogram(s Sample) Histogram {
31 - if UseNilMetrics {
32 - return NilHistogram{}
33 - }
34 - return &StandardHistogram{sample: s}
35 -}
36 -
37 -// NewRegisteredHistogram constructs and registers a new StandardHistogram from
38 -// a Sample.
39 -func NewRegisteredHistogram(name string, r Registry, s Sample) Histogram {
40 - c := NewHistogram(s)
41 - if nil == r {
42 - r = DefaultRegistry
43 - }
44 - r.Register(name, c)
45 - return c
46 -}
47 -
48 -// HistogramSnapshot is a read-only copy of another Histogram.
49 -type HistogramSnapshot struct {
50 - sample *SampleSnapshot
51 -}
52 -
53 -// Clear panics.
54 -func (*HistogramSnapshot) Clear() {
55 - panic("Clear called on a HistogramSnapshot")
56 -}
57 -
58 -// Count returns the number of samples recorded at the time the snapshot was
59 -// taken.
60 -func (h *HistogramSnapshot) Count() int64 { return h.sample.Count() }
61 -
62 -// Max returns the maximum value in the sample at the time the snapshot was
63 -// taken.
64 -func (h *HistogramSnapshot) Max() int64 { return h.sample.Max() }
65 -
66 -// Mean returns the mean of the values in the sample at the time the snapshot
67 -// was taken.
68 -func (h *HistogramSnapshot) Mean() float64 { return h.sample.Mean() }
69 -
70 -// Min returns the minimum value in the sample at the time the snapshot was
71 -// taken.
72 -func (h *HistogramSnapshot) Min() int64 { return h.sample.Min() }
73 -
74 -// Percentile returns an arbitrary percentile of values in the sample at the
75 -// time the snapshot was taken.
76 -func (h *HistogramSnapshot) Percentile(p float64) float64 {
77 - return h.sample.Percentile(p)
78 -}
79 -
80 -// Percentiles returns a slice of arbitrary percentiles of values in the sample
81 -// at the time the snapshot was taken.
82 -func (h *HistogramSnapshot) Percentiles(ps []float64) []float64 {
83 - return h.sample.Percentiles(ps)
84 -}
85 -
86 -// Sample returns the Sample underlying the histogram.
87 -func (h *HistogramSnapshot) Sample() Sample { return h.sample }
88 -
89 -// Snapshot returns the snapshot.
90 -func (h *HistogramSnapshot) Snapshot() Histogram { return h }
91 -
92 -// StdDev returns the standard deviation of the values in the sample at the
93 -// time the snapshot was taken.
94 -func (h *HistogramSnapshot) StdDev() float64 { return h.sample.StdDev() }
95 -
96 -// Sum returns the sum in the sample at the time the snapshot was taken.
97 -func (h *HistogramSnapshot) Sum() int64 { return h.sample.Sum() }
98 -
99 -// Update panics.
100 -func (*HistogramSnapshot) Update(int64) {
101 - panic("Update called on a HistogramSnapshot")
102 -}
103 -
104 -// Variance returns the variance of inputs at the time the snapshot was taken.
105 -func (h *HistogramSnapshot) Variance() float64 { return h.sample.Variance() }
106 -
107 -// NilHistogram is a no-op Histogram.
108 -type NilHistogram struct{}
109 -
110 -// Clear is a no-op.
111 -func (NilHistogram) Clear() {}
112 -
113 -// Count is a no-op.
114 -func (NilHistogram) Count() int64 { return 0 }
115 -
116 -// Max is a no-op.
117 -func (NilHistogram) Max() int64 { return 0 }
118 -
119 -// Mean is a no-op.
120 -func (NilHistogram) Mean() float64 { return 0.0 }
121 -
122 -// Min is a no-op.
123 -func (NilHistogram) Min() int64 { return 0 }
124 -
125 -// Percentile is a no-op.
126 -func (NilHistogram) Percentile(p float64) float64 { return 0.0 }
127 -
128 -// Percentiles is a no-op.
129 -func (NilHistogram) Percentiles(ps []float64) []float64 {
130 - return make([]float64, len(ps))
131 -}
132 -
133 -// Sample is a no-op.
134 -func (NilHistogram) Sample() Sample { return NilSample{} }
135 -
136 -// Snapshot is a no-op.
137 -func (NilHistogram) Snapshot() Histogram { return NilHistogram{} }
138 -
139 -// StdDev is a no-op.
140 -func (NilHistogram) StdDev() float64 { return 0.0 }
141 -
142 -// Sum is a no-op.
143 -func (NilHistogram) Sum() int64 { return 0 }
144 -
145 -// Update is a no-op.
146 -func (NilHistogram) Update(v int64) {}
147 -
148 -// Variance is a no-op.
149 -func (NilHistogram) Variance() float64 { return 0.0 }
150 -
151 -// StandardHistogram is the standard implementation of a Histogram and uses a
152 -// Sample to bound its memory use.
153 -type StandardHistogram struct {
154 - sample Sample
155 -}
156 -
157 -// Clear clears the histogram and its sample.
158 -func (h *StandardHistogram) Clear() { h.sample.Clear() }
159 -
160 -// Count returns the number of samples recorded since the histogram was last
161 -// cleared.
162 -func (h *StandardHistogram) Count() int64 { return h.sample.Count() }
163 -
164 -// Max returns the maximum value in the sample.
165 -func (h *StandardHistogram) Max() int64 { return h.sample.Max() }
166 -
167 -// Mean returns the mean of the values in the sample.
168 -func (h *StandardHistogram) Mean() float64 { return h.sample.Mean() }
169 -
170 -// Min returns the minimum value in the sample.
171 -func (h *StandardHistogram) Min() int64 { return h.sample.Min() }
172 -
173 -// Percentile returns an arbitrary percentile of the values in the sample.
174 -func (h *StandardHistogram) Percentile(p float64) float64 {
175 - return h.sample.Percentile(p)
176 -}
177 -
178 -// Percentiles returns a slice of arbitrary percentiles of the values in the
179 -// sample.
180 -func (h *StandardHistogram) Percentiles(ps []float64) []float64 {
181 - return h.sample.Percentiles(ps)
182 -}
183 -
184 -// Sample returns the Sample underlying the histogram.
185 -func (h *StandardHistogram) Sample() Sample { return h.sample }
186 -
187 -// Snapshot returns a read-only copy of the histogram.
188 -func (h *StandardHistogram) Snapshot() Histogram {
189 - return &HistogramSnapshot{sample: h.sample.Snapshot().(*SampleSnapshot)}
190 -}
191 -
192 -// StdDev returns the standard deviation of the values in the sample.
193 -func (h *StandardHistogram) StdDev() float64 { return h.sample.StdDev() }
194 -
195 -// Sum returns the sum in the sample.
196 -func (h *StandardHistogram) Sum() int64 { return h.sample.Sum() }
197 -
198 -// Update samples a new value.
199 -func (h *StandardHistogram) Update(v int64) { h.sample.Update(v) }
200 -
201 -// Variance returns the variance of the values in the sample.
202 -func (h *StandardHistogram) Variance() float64 { return h.sample.Variance() }
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/histogram_test.go deleted
-95
@@ -1,95 +0,0 @@
1 -package metrics
2 -
3 -import "testing"
4 -
5 -func BenchmarkHistogram(b *testing.B) {
6 - h := NewHistogram(NewUniformSample(100))
7 - b.ResetTimer()
8 - for i := 0; i < b.N; i++ {
9 - h.Update(int64(i))
10 - }
11 -}
12 -
13 -func TestGetOrRegisterHistogram(t *testing.T) {
14 - r := NewRegistry()
15 - s := NewUniformSample(100)
16 - NewRegisteredHistogram("foo", r, s).Update(47)
17 - if h := GetOrRegisterHistogram("foo", r, s); 1 != h.Count() {
18 - t.Fatal(h)
19 - }
20 -}
21 -
22 -func TestHistogram10000(t *testing.T) {
23 - h := NewHistogram(NewUniformSample(100000))
24 - for i := 1; i <= 10000; i++ {
25 - h.Update(int64(i))
26 - }
27 - testHistogram10000(t, h)
28 -}
29 -
30 -func TestHistogramEmpty(t *testing.T) {
31 - h := NewHistogram(NewUniformSample(100))
32 - if count := h.Count(); 0 != count {
33 - t.Errorf("h.Count(): 0 != %v\n", count)
34 - }
35 - if min := h.Min(); 0 != min {
36 - t.Errorf("h.Min(): 0 != %v\n", min)
37 - }
38 - if max := h.Max(); 0 != max {
39 - t.Errorf("h.Max(): 0 != %v\n", max)
40 - }
41 - if mean := h.Mean(); 0.0 != mean {
42 - t.Errorf("h.Mean(): 0.0 != %v\n", mean)
43 - }
44 - if stdDev := h.StdDev(); 0.0 != stdDev {
45 - t.Errorf("h.StdDev(): 0.0 != %v\n", stdDev)
46 - }
47 - ps := h.Percentiles([]float64{0.5, 0.75, 0.99})
48 - if 0.0 != ps[0] {
49 - t.Errorf("median: 0.0 != %v\n", ps[0])
50 - }
51 - if 0.0 != ps[1] {
52 - t.Errorf("75th percentile: 0.0 != %v\n", ps[1])
53 - }
54 - if 0.0 != ps[2] {
55 - t.Errorf("99th percentile: 0.0 != %v\n", ps[2])
56 - }
57 -}
58 -
59 -func TestHistogramSnapshot(t *testing.T) {
60 - h := NewHistogram(NewUniformSample(100000))
61 - for i := 1; i <= 10000; i++ {
62 - h.Update(int64(i))
63 - }
64 - snapshot := h.Snapshot()
65 - h.Update(0)
66 - testHistogram10000(t, snapshot)
67 -}
68 -
69 -func testHistogram10000(t *testing.T, h Histogram) {
70 - if count := h.Count(); 10000 != count {
71 - t.Errorf("h.Count(): 10000 != %v\n", count)
72 - }
73 - if min := h.Min(); 1 != min {
74 - t.Errorf("h.Min(): 1 != %v\n", min)
75 - }
76 - if max := h.Max(); 10000 != max {
77 - t.Errorf("h.Max(): 10000 != %v\n", max)
78 - }
79 - if mean := h.Mean(); 5000.5 != mean {
80 - t.Errorf("h.Mean(): 5000.5 != %v\n", mean)
81 - }
82 - if stdDev := h.StdDev(); 2886.751331514372 != stdDev {
83 - t.Errorf("h.StdDev(): 2886.751331514372 != %v\n", stdDev)
84 - }
85 - ps := h.Percentiles([]float64{0.5, 0.75, 0.99})
86 - if 5000.5 != ps[0] {
87 - t.Errorf("median: 5000.5 != %v\n", ps[0])
88 - }
89 - if 7500.75 != ps[1] {
90 - t.Errorf("75th percentile: 7500.75 != %v\n", ps[1])
91 - }
92 - if 9900.99 != ps[2] {
93 - t.Errorf("99th percentile: 9900.99 != %v\n", ps[2])
94 - }
95 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/influxdb/influxdb.go deleted
-114
@@ -1,114 +0,0 @@
1 -package influxdb
2 -
3 -import (
4 - "fmt"
5 - influxClient "github.com/influxdb/influxdb/client"
6 - "github.com/rcrowley/go-metrics"
7 - "log"
8 - "time"
9 -)
10 -
11 -type Config struct {
12 - Host string
13 - Database string
14 - Username string
15 - Password string
16 -}
17 -
18 -func Influxdb(r metrics.Registry, d time.Duration, config *Config) {
19 - client, err := influxClient.NewClient(&influxClient.ClientConfig{
20 - Host: config.Host,
21 - Database: config.Database,
22 - Username: config.Username,
23 - Password: config.Password,
24 - })
25 - if err != nil {
26 - log.Println(err)
27 - return
28 - }
29 -
30 - for _ = range time.Tick(d) {
31 - if err := send(r, client); err != nil {
32 - log.Println(err)
33 - }
34 - }
35 -}
36 -
37 -func send(r metrics.Registry, client *influxClient.Client) error {
38 - series := []*influxClient.Series{}
39 -
40 - r.Each(func(name string, i interface{}) {
41 - now := getCurrentTime()
42 - switch metric := i.(type) {
43 - case metrics.Counter:
44 - series = append(series, &influxClient.Series{
45 - Name: fmt.Sprintf("%s.count", name),
46 - Columns: []string{"time", "count"},
47 - Points: [][]interface{}{
48 - {now, metric.Count()},
49 - },
50 - })
51 - case metrics.Gauge:
52 - series = append(series, &influxClient.Series{
53 - Name: fmt.Sprintf("%s.value", name),
54 - Columns: []string{"time", "value"},
55 - Points: [][]interface{}{
56 - {now, metric.Value()},
57 - },
58 - })
59 - case metrics.GaugeFloat64:
60 - series = append(series, &influxClient.Series{
61 - Name: fmt.Sprintf("%s.value", name),
62 - Columns: []string{"time", "value"},
63 - Points: [][]interface{}{
64 - {now, metric.Value()},
65 - },
66 - })
67 - case metrics.Histogram:
68 - h := metric.Snapshot()
69 - ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
70 - series = append(series, &influxClient.Series{
71 - Name: fmt.Sprintf("%s.histogram", name),
72 - Columns: []string{"time", "count", "min", "max", "mean", "std-dev",
73 - "50-percentile", "75-percentile", "95-percentile",
74 - "99-percentile", "999-percentile"},
75 - Points: [][]interface{}{
76 - {now, h.Count(), h.Min(), h.Max(), h.Mean(), h.StdDev(),
77 - ps[0], ps[1], ps[2], ps[3], ps[4]},
78 - },
79 - })
80 - case metrics.Meter:
81 - m := metric.Snapshot()
82 - series = append(series, &influxClient.Series{
83 - Name: fmt.Sprintf("%s.meter", name),
84 - Columns: []string{"count", "one-minute",
85 - "five-minute", "fifteen-minute", "mean"},
86 - Points: [][]interface{}{
87 - {m.Count(), m.Rate1(), m.Rate5(), m.Rate15(), m.RateMean()},
88 - },
89 - })
90 - case metrics.Timer:
91 - h := metric.Snapshot()
92 - ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
93 - series = append(series, &influxClient.Series{
94 - Name: fmt.Sprintf("%s.timer", name),
95 - Columns: []string{"count", "min", "max", "mean", "std-dev",
96 - "50-percentile", "75-percentile", "95-percentile",
97 - "99-percentile", "999-percentile", "one-minute", "five-minute", "fifteen-minute", "mean-rate"},
98 - Points: [][]interface{}{
99 - {h.Count(), h.Min(), h.Max(), h.Mean(), h.StdDev(),
100 - ps[0], ps[1], ps[2], ps[3], ps[4],
101 - h.Rate1(), h.Rate5(), h.Rate15(), h.RateMean()},
102 - },
103 - })
104 - }
105 - })
106 - if err := client.WriteSeries(series); err != nil {
107 - log.Println(err)
108 - }
109 - return nil
110 -}
111 -
112 -func getCurrentTime() int64 {
113 - return time.Now().UnixNano() / 1000000
114 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/json.go deleted
-83
@@ -1,83 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "encoding/json"
5 - "io"
6 - "time"
7 -)
8 -
9 -// MarshalJSON returns a byte slice containing a JSON representation of all
10 -// the metrics in the Registry.
11 -func (r StandardRegistry) MarshalJSON() ([]byte, error) {
12 - data := make(map[string]map[string]interface{})
13 - r.Each(func(name string, i interface{}) {
14 - values := make(map[string]interface{})
15 - switch metric := i.(type) {
16 - case Counter:
17 - values["count"] = metric.Count()
18 - case Gauge:
19 - values["value"] = metric.Value()
20 - case GaugeFloat64:
21 - values["value"] = metric.Value()
22 - case Healthcheck:
23 - values["error"] = nil
24 - metric.Check()
25 - if err := metric.Error(); nil != err {
26 - values["error"] = metric.Error().Error()
27 - }
28 - case Histogram:
29 - h := metric.Snapshot()
30 - ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
31 - values["count"] = h.Count()
32 - values["min"] = h.Min()
33 - values["max"] = h.Max()
34 - values["mean"] = h.Mean()
35 - values["stddev"] = h.StdDev()
36 - values["median"] = ps[0]
37 - values["75%"] = ps[1]
38 - values["95%"] = ps[2]
39 - values["99%"] = ps[3]
40 - values["99.9%"] = ps[4]
41 - case Meter:
42 - m := metric.Snapshot()
43 - values["count"] = m.Count()
44 - values["1m.rate"] = m.Rate1()
45 - values["5m.rate"] = m.Rate5()
46 - values["15m.rate"] = m.Rate15()
47 - values["mean.rate"] = m.RateMean()
48 - case Timer:
49 - t := metric.Snapshot()
50 - ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
51 - values["count"] = t.Count()
52 - values["min"] = t.Min()
53 - values["max"] = t.Max()
54 - values["mean"] = t.Mean()
55 - values["stddev"] = t.StdDev()
56 - values["median"] = ps[0]
57 - values["75%"] = ps[1]
58 - values["95%"] = ps[2]
59 - values["99%"] = ps[3]
60 - values["99.9%"] = ps[4]
61 - values["1m.rate"] = t.Rate1()
62 - values["5m.rate"] = t.Rate5()
63 - values["15m.rate"] = t.Rate15()
64 - values["mean.rate"] = t.RateMean()
65 - }
66 - data[name] = values
67 - })
68 - return json.Marshal(data)
69 -}
70 -
71 -// WriteJSON writes metrics from the given registry periodically to the
72 -// specified io.Writer as JSON.
73 -func WriteJSON(r Registry, d time.Duration, w io.Writer) {
74 - for _ = range time.Tick(d) {
75 - WriteJSONOnce(r, w)
76 - }
77 -}
78 -
79 -// WriteJSONOnce writes metrics from the given registry to the specified
80 -// io.Writer as JSON.
81 -func WriteJSONOnce(r Registry, w io.Writer) {
82 - json.NewEncoder(w).Encode(r)
83 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/json_test.go deleted
-28
@@ -1,28 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "bytes"
5 - "encoding/json"
6 - "testing"
7 -)
8 -
9 -func TestRegistryMarshallJSON(t *testing.T) {
10 - b := &bytes.Buffer{}
11 - enc := json.NewEncoder(b)
12 - r := NewRegistry()
13 - r.Register("counter", NewCounter())
14 - enc.Encode(r)
15 - if s := b.String(); "{\"counter\":{\"count\":0}}\n" != s {
16 - t.Fatalf(s)
17 - }
18 -}
19 -
20 -func TestRegistryWriteJSONOnce(t *testing.T) {
21 - r := NewRegistry()
22 - r.Register("counter", NewCounter())
23 - b := &bytes.Buffer{}
24 - WriteJSONOnce(r, b)
25 - if s := b.String(); s != "{\"counter\":{\"count\":0}}\n" {
26 - t.Fail()
27 - }
28 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/librato/client.go deleted
-102
@@ -1,102 +0,0 @@
1 -package librato
2 -
3 -import (
4 - "bytes"
5 - "encoding/json"
6 - "fmt"
7 - "io/ioutil"
8 - "net/http"
9 -)
10 -
11 -const Operations = "operations"
12 -const OperationsShort = "ops"
13 -
14 -type LibratoClient struct {
15 - Email, Token string
16 -}
17 -
18 -// property strings
19 -const (
20 - // display attributes
21 - Color = "color"
22 - DisplayMax = "display_max"
23 - DisplayMin = "display_min"
24 - DisplayUnitsLong = "display_units_long"
25 - DisplayUnitsShort = "display_units_short"
26 - DisplayStacked = "display_stacked"
27 - DisplayTransform = "display_transform"
28 - // special gauge display attributes
29 - SummarizeFunction = "summarize_function"
30 - Aggregate = "aggregate"
31 -
32 - // metric keys
33 - Name = "name"
34 - Period = "period"
35 - Description = "description"
36 - DisplayName = "display_name"
37 - Attributes = "attributes"
38 -
39 - // measurement keys
40 - MeasureTime = "measure_time"
41 - Source = "source"
42 - Value = "value"
43 -
44 - // special gauge keys
45 - Count = "count"
46 - Sum = "sum"
47 - Max = "max"
48 - Min = "min"
49 - SumSquares = "sum_squares"
50 -
51 - // batch keys
52 - Counters = "counters"
53 - Gauges = "gauges"
54 -
55 - MetricsPostUrl = "https://metrics-api.librato.com/v1/metrics"
56 -)
57 -
58 -type Measurement map[string]interface{}
59 -type Metric map[string]interface{}
60 -
61 -type Batch struct {
62 - Gauges []Measurement `json:"gauges,omitempty"`
63 - Counters []Measurement `json:"counters,omitempty"`
64 - MeasureTime int64 `json:"measure_time"`
65 - Source string `json:"source"`
66 -}
67 -
68 -func (self *LibratoClient) PostMetrics(batch Batch) (err error) {
69 - var (
70 - js []byte
71 - req *http.Request
72 - resp *http.Response
73 - )
74 -
75 - if len(batch.Counters) == 0 && len(batch.Gauges) == 0 {
76 - return nil
77 - }
78 -
79 - if js, err = json.Marshal(batch); err != nil {
80 - return
81 - }
82 -
83 - if req, err = http.NewRequest("POST", MetricsPostUrl, bytes.NewBuffer(js)); err != nil {
84 - return
85 - }
86 -
87 - req.Header.Set("Content-Type", "application/json")
88 - req.SetBasicAuth(self.Email, self.Token)
89 -
90 - if resp, err = http.DefaultClient.Do(req); err != nil {
91 - return
92 - }
93 -
94 - if resp.StatusCode != http.StatusOK {
95 - var body []byte
96 - if body, err = ioutil.ReadAll(resp.Body); err != nil {
97 - body = []byte(fmt.Sprintf("(could not fetch response body for error: %s)", err))
98 - }
99 - err = fmt.Errorf("Unable to post to Librato: %d %s %s", resp.StatusCode, resp.Status, string(body))
100 - }
101 - return
102 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/librato/librato.go deleted
-230
@@ -1,230 +0,0 @@
1 -package librato
2 -
3 -import (
4 - "fmt"
5 - "log"
6 - "math"
7 - "regexp"
8 - "time"
9 -
10 - "github.com/rcrowley/go-metrics"
11 -)
12 -
13 -// a regexp for extracting the unit from time.Duration.String
14 -var unitRegexp = regexp.MustCompile("[^\\d]+$")
15 -
16 -// a helper that turns a time.Duration into librato display attributes for timer metrics
17 -func translateTimerAttributes(d time.Duration) (attrs map[string]interface{}) {
18 - attrs = make(map[string]interface{})
19 - attrs[DisplayTransform] = fmt.Sprintf("x/%d", int64(d))
20 - attrs[DisplayUnitsShort] = string(unitRegexp.Find([]byte(d.String())))
21 - return
22 -}
23 -
24 -type Reporter struct {
25 - Email, Token string
26 - Source string
27 - Interval time.Duration
28 - Registry metrics.Registry
29 - Percentiles []float64 // percentiles to report on histogram metrics
30 - TimerAttributes map[string]interface{} // units in which timers will be displayed
31 - intervalSec int64
32 -}
33 -
34 -func NewReporter(r metrics.Registry, d time.Duration, e string, t string, s string, p []float64, u time.Duration) *Reporter {
35 - return &Reporter{e, t, s, d, r, p, translateTimerAttributes(u), int64(d / time.Second)}
36 -}
37 -
38 -func Librato(r metrics.Registry, d time.Duration, e string, t string, s string, p []float64, u time.Duration) {
39 - NewReporter(r, d, e, t, s, p, u).Run()
40 -}
41 -
42 -func (self *Reporter) Run() {
43 - ticker := time.Tick(self.Interval)
44 - metricsApi := &LibratoClient{self.Email, self.Token}
45 - for now := range ticker {
46 - var metrics Batch
47 - var err error
48 - if metrics, err = self.BuildRequest(now, self.Registry); err != nil {
49 - log.Printf("ERROR constructing librato request body %s", err)
50 - continue
51 - }
52 - if err := metricsApi.PostMetrics(metrics); err != nil {
53 - log.Printf("ERROR sending metrics to librato %s", err)
54 - continue
55 - }
56 - }
57 -}
58 -
59 -// calculate sum of squares from data provided by metrics.Histogram
60 -// see http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods
61 -func sumSquares(s metrics.Sample) float64 {
62 - count := float64(s.Count())
63 - sumSquared := math.Pow(count*s.Mean(), 2)
64 - sumSquares := math.Pow(count*s.StdDev(), 2) + sumSquared/count
65 - if math.IsNaN(sumSquares) {
66 - return 0.0
67 - }
68 - return sumSquares
69 -}
70 -func sumSquaresTimer(t metrics.Timer) float64 {
71 - count := float64(t.Count())
72 - sumSquared := math.Pow(count*t.Mean(), 2)
73 - sumSquares := math.Pow(count*t.StdDev(), 2) + sumSquared/count
74 - if math.IsNaN(sumSquares) {
75 - return 0.0
76 - }
77 - return sumSquares
78 -}
79 -
80 -func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot Batch, err error) {
81 - snapshot = Batch{
82 - // coerce timestamps to a stepping fn so that they line up in Librato graphs
83 - MeasureTime: (now.Unix() / self.intervalSec) * self.intervalSec,
84 - Source: self.Source,
85 - }
86 - snapshot.Gauges = make([]Measurement, 0)
87 - snapshot.Counters = make([]Measurement, 0)
88 - histogramGaugeCount := 1 + len(self.Percentiles)
89 - r.Each(func(name string, metric interface{}) {
90 - measurement := Measurement{}
91 - measurement[Period] = self.Interval.Seconds()
92 - switch m := metric.(type) {
93 - case metrics.Counter:
94 - if m.Count() > 0 {
95 - measurement[Name] = fmt.Sprintf("%s.%s", name, "count")
96 - measurement[Value] = float64(m.Count())
97 - measurement[Attributes] = map[string]interface{}{
98 - DisplayUnitsLong: Operations,
99 - DisplayUnitsShort: OperationsShort,
100 - DisplayMin: "0",
101 - }
102 - snapshot.Counters = append(snapshot.Counters, measurement)
103 - }
104 - case metrics.Gauge:
105 - measurement[Name] = name
106 - measurement[Value] = float64(m.Value())
107 - snapshot.Gauges = append(snapshot.Gauges, measurement)
108 - case metrics.GaugeFloat64:
109 - measurement[Name] = name
110 - measurement[Value] = float64(m.Value())
111 - snapshot.Gauges = append(snapshot.Gauges, measurement)
112 - case metrics.Histogram:
113 - if m.Count() > 0 {
114 - gauges := make([]Measurement, histogramGaugeCount, histogramGaugeCount)
115 - s := m.Sample()
116 - measurement[Name] = fmt.Sprintf("%s.%s", name, "hist")
117 - measurement[Count] = uint64(s.Count())
118 - measurement[Max] = float64(s.Max())
119 - measurement[Min] = float64(s.Min())
120 - measurement[Sum] = float64(s.Sum())
121 - measurement[SumSquares] = sumSquares(s)
122 - gauges[0] = measurement
123 - for i, p := range self.Percentiles {
124 - gauges[i+1] = Measurement{
125 - Name: fmt.Sprintf("%s.%.2f", measurement[Name], p),
126 - Value: s.Percentile(p),
127 - Period: measurement[Period],
128 - }
129 - }
130 - snapshot.Gauges = append(snapshot.Gauges, gauges...)
131 - }
132 - case metrics.Meter:
133 - measurement[Name] = name
134 - measurement[Value] = float64(m.Count())
135 - snapshot.Counters = append(snapshot.Counters, measurement)
136 - snapshot.Gauges = append(snapshot.Gauges,
137 - Measurement{
138 - Name: fmt.Sprintf("%s.%s", name, "1min"),
139 - Value: m.Rate1(),
140 - Period: int64(self.Interval.Seconds()),
141 - Attributes: map[string]interface{}{
142 - DisplayUnitsLong: Operations,
143 - DisplayUnitsShort: OperationsShort,
144 - DisplayMin: "0",
145 - },
146 - },
147 - Measurement{
148 - Name: fmt.Sprintf("%s.%s", name, "5min"),
149 - Value: m.Rate5(),
150 - Period: int64(self.Interval.Seconds()),
151 - Attributes: map[string]interface{}{
152 - DisplayUnitsLong: Operations,
153 - DisplayUnitsShort: OperationsShort,
154 - DisplayMin: "0",
155 - },
156 - },
157 - Measurement{
158 - Name: fmt.Sprintf("%s.%s", name, "15min"),
159 - Value: m.Rate15(),
160 - Period: int64(self.Interval.Seconds()),
161 - Attributes: map[string]interface{}{
162 - DisplayUnitsLong: Operations,
163 - DisplayUnitsShort: OperationsShort,
164 - DisplayMin: "0",
165 - },
166 - },
167 - )
168 - case metrics.Timer:
169 - measurement[Name] = name
170 - measurement[Value] = float64(m.Count())
171 - snapshot.Counters = append(snapshot.Counters, measurement)
172 - if m.Count() > 0 {
173 - libratoName := fmt.Sprintf("%s.%s", name, "timer.mean")
174 - gauges := make([]Measurement, histogramGaugeCount, histogramGaugeCount)
175 - gauges[0] = Measurement{
176 - Name: libratoName,
177 - Count: uint64(m.Count()),
178 - Sum: m.Mean() * float64(m.Count()),
179 - Max: float64(m.Max()),
180 - Min: float64(m.Min()),
181 - SumSquares: sumSquaresTimer(m),
182 - Period: int64(self.Interval.Seconds()),
183 - Attributes: self.TimerAttributes,
184 - }
185 - for i, p := range self.Percentiles {
186 - gauges[i+1] = Measurement{
187 - Name: fmt.Sprintf("%s.timer.%2.0f", name, p*100),
188 - Value: m.Percentile(p),
189 - Period: int64(self.Interval.Seconds()),
190 - Attributes: self.TimerAttributes,
191 - }
192 - }
193 - snapshot.Gauges = append(snapshot.Gauges, gauges...)
194 - snapshot.Gauges = append(snapshot.Gauges,
195 - Measurement{
196 - Name: fmt.Sprintf("%s.%s", name, "rate.1min"),
197 - Value: m.Rate1(),
198 - Period: int64(self.Interval.Seconds()),
199 - Attributes: map[string]interface{}{
200 - DisplayUnitsLong: Operations,
201 - DisplayUnitsShort: OperationsShort,
202 - DisplayMin: "0",
203 - },
204 - },
205 - Measurement{
206 - Name: fmt.Sprintf("%s.%s", name, "rate.5min"),
207 - Value: m.Rate5(),
208 - Period: int64(self.Interval.Seconds()),
209 - Attributes: map[string]interface{}{
210 - DisplayUnitsLong: Operations,
211 - DisplayUnitsShort: OperationsShort,
212 - DisplayMin: "0",
213 - },
214 - },
215 - Measurement{
216 - Name: fmt.Sprintf("%s.%s", name, "rate.15min"),
217 - Value: m.Rate15(),
218 - Period: int64(self.Interval.Seconds()),
219 - Attributes: map[string]interface{}{
220 - DisplayUnitsLong: Operations,
221 - DisplayUnitsShort: OperationsShort,
222 - DisplayMin: "0",
223 - },
224 - },
225 - )
226 - }
227 - }
228 - })
229 - return
230 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/log.go deleted
-70
@@ -1,70 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "log"
5 - "time"
6 -)
7 -
8 -// Output each metric in the given registry periodically using the given
9 -// logger.
10 -func Log(r Registry, d time.Duration, l *log.Logger) {
11 - for _ = range time.Tick(d) {
12 - r.Each(func(name string, i interface{}) {
13 - switch metric := i.(type) {
14 - case Counter:
15 - l.Printf("counter %s\n", name)
16 - l.Printf(" count: %9d\n", metric.Count())
17 - case Gauge:
18 - l.Printf("gauge %s\n", name)
19 - l.Printf(" value: %9d\n", metric.Value())
20 - case GaugeFloat64:
21 - l.Printf("gauge %s\n", name)
22 - l.Printf(" value: %f\n", metric.Value())
23 - case Healthcheck:
24 - metric.Check()
25 - l.Printf("healthcheck %s\n", name)
26 - l.Printf(" error: %v\n", metric.Error())
27 - case Histogram:
28 - h := metric.Snapshot()
29 - ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
30 - l.Printf("histogram %s\n", name)
31 - l.Printf(" count: %9d\n", h.Count())
32 - l.Printf(" min: %9d\n", h.Min())
33 - l.Printf(" max: %9d\n", h.Max())
34 - l.Printf(" mean: %12.2f\n", h.Mean())
35 - l.Printf(" stddev: %12.2f\n", h.StdDev())
36 - l.Printf(" median: %12.2f\n", ps[0])
37 - l.Printf(" 75%%: %12.2f\n", ps[1])
38 - l.Printf(" 95%%: %12.2f\n", ps[2])
39 - l.Printf(" 99%%: %12.2f\n", ps[3])
40 - l.Printf(" 99.9%%: %12.2f\n", ps[4])
41 - case Meter:
42 - m := metric.Snapshot()
43 - l.Printf("meter %s\n", name)
44 - l.Printf(" count: %9d\n", m.Count())
45 - l.Printf(" 1-min rate: %12.2f\n", m.Rate1())
46 - l.Printf(" 5-min rate: %12.2f\n", m.Rate5())
47 - l.Printf(" 15-min rate: %12.2f\n", m.Rate15())
48 - l.Printf(" mean rate: %12.2f\n", m.RateMean())
49 - case Timer:
50 - t := metric.Snapshot()
51 - ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
52 - l.Printf("timer %s\n", name)
53 - l.Printf(" count: %9d\n", t.Count())
54 - l.Printf(" min: %9d\n", t.Min())
55 - l.Printf(" max: %9d\n", t.Max())
56 - l.Printf(" mean: %12.2f\n", t.Mean())
57 - l.Printf(" stddev: %12.2f\n", t.StdDev())
58 - l.Printf(" median: %12.2f\n", ps[0])
59 - l.Printf(" 75%%: %12.2f\n", ps[1])
60 - l.Printf(" 95%%: %12.2f\n", ps[2])
61 - l.Printf(" 99%%: %12.2f\n", ps[3])
62 - l.Printf(" 99.9%%: %12.2f\n", ps[4])
63 - l.Printf(" 1-min rate: %12.2f\n", t.Rate1())
64 - l.Printf(" 5-min rate: %12.2f\n", t.Rate5())
65 - l.Printf(" 15-min rate: %12.2f\n", t.Rate15())
66 - l.Printf(" mean rate: %12.2f\n", t.RateMean())
67 - }
68 - })
69 - }
70 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/memory.md deleted
-285
@@ -1,285 +0,0 @@
1 -Memory usage
2 -============
3 -
4 -(Highly unscientific.)
5 -
6 -Command used to gather static memory usage:
7 -
8 -```sh
9 -grep ^Vm "/proc/$(ps fax | grep [m]etrics-bench | awk '{print $1}')/status"
10 -```
11 -
12 -Program used to gather baseline memory usage:
13 -
14 -```go
15 -package main
16 -
17 -import "time"
18 -
19 -func main() {
20 - time.Sleep(600e9)
21 -}
22 -```
23 -
24 -Baseline
25 ---------
26 -
27 -```
28 -VmPeak: 42604 kB
29 -VmSize: 42604 kB
30 -VmLck: 0 kB
31 -VmHWM: 1120 kB
32 -VmRSS: 1120 kB
33 -VmData: 35460 kB
34 -VmStk: 136 kB
35 -VmExe: 1020 kB
36 -VmLib: 1848 kB
37 -VmPTE: 36 kB
38 -VmSwap: 0 kB
39 -```
40 -
41 -Program used to gather metric memory usage (with other metrics being similar):
42 -
43 -```go
44 -package main
45 -
46 -import (
47 - "fmt"
48 - "metrics"
49 - "time"
50 -)
51 -
52 -func main() {
53 - fmt.Sprintf("foo")
54 - metrics.NewRegistry()
55 - time.Sleep(600e9)
56 -}
57 -```
58 -
59 -1000 counters registered
60 -------------------------
61 -
62 -```
63 -VmPeak: 44016 kB
64 -VmSize: 44016 kB
65 -VmLck: 0 kB
66 -VmHWM: 1928 kB
67 -VmRSS: 1928 kB
68 -VmData: 36868 kB
69 -VmStk: 136 kB
70 -VmExe: 1024 kB
71 -VmLib: 1848 kB
72 -VmPTE: 40 kB
73 -VmSwap: 0 kB
74 -```
75 -
76 -**1.412 kB virtual, TODO 0.808 kB resident per counter.**
77 -
78 -100000 counters registered
79 ---------------------------
80 -
81 -```
82 -VmPeak: 55024 kB
83 -VmSize: 55024 kB
84 -VmLck: 0 kB
85 -VmHWM: 12440 kB
86 -VmRSS: 12440 kB
87 -VmData: 47876 kB
88 -VmStk: 136 kB
89 -VmExe: 1024 kB
90 -VmLib: 1848 kB
91 -VmPTE: 64 kB
92 -VmSwap: 0 kB
93 -```
94 -
95 -**0.1242 kB virtual, 0.1132 kB resident per counter.**
96 -
97 -1000 gauges registered
98 -----------------------
99 -
100 -```
101 -VmPeak: 44012 kB
102 -VmSize: 44012 kB
103 -VmLck: 0 kB
104 -VmHWM: 1928 kB
105 -VmRSS: 1928 kB
106 -VmData: 36868 kB
107 -VmStk: 136 kB
108 -VmExe: 1020 kB
109 -VmLib: 1848 kB
110 -VmPTE: 40 kB
111 -VmSwap: 0 kB
112 -```
113 -
114 -**1.408 kB virtual, 0.808 kB resident per counter.**
115 -
116 -100000 gauges registered
117 -------------------------
118 -
119 -```
120 -VmPeak: 55020 kB
121 -VmSize: 55020 kB
122 -VmLck: 0 kB
123 -VmHWM: 12432 kB
124 -VmRSS: 12432 kB
125 -VmData: 47876 kB
126 -VmStk: 136 kB
127 -VmExe: 1020 kB
128 -VmLib: 1848 kB
129 -VmPTE: 60 kB
130 -VmSwap: 0 kB
131 -```
132 -
133 -**0.12416 kB virtual, 0.11312 resident per gauge.**
134 -
135 -1000 histograms with a uniform sample size of 1028
136 ---------------------------------------------------
137 -
138 -```
139 -VmPeak: 72272 kB
140 -VmSize: 72272 kB
141 -VmLck: 0 kB
142 -VmHWM: 16204 kB
143 -VmRSS: 16204 kB
144 -VmData: 65100 kB
145 -VmStk: 136 kB
146 -VmExe: 1048 kB
147 -VmLib: 1848 kB
148 -VmPTE: 80 kB
149 -VmSwap: 0 kB
150 -```
151 -
152 -**29.668 kB virtual, TODO 15.084 resident per histogram.**
153 -
154 -10000 histograms with a uniform sample size of 1028
155 ----------------------------------------------------
156 -
157 -```
158 -VmPeak: 256912 kB
159 -VmSize: 256912 kB
160 -VmLck: 0 kB
161 -VmHWM: 146204 kB
162 -VmRSS: 146204 kB
163 -VmData: 249740 kB
164 -VmStk: 136 kB
165 -VmExe: 1048 kB
166 -VmLib: 1848 kB
167 -VmPTE: 448 kB
168 -VmSwap: 0 kB
169 -```
170 -
171 -**21.4308 kB virtual, 14.5084 kB resident per histogram.**
172 -
173 -50000 histograms with a uniform sample size of 1028
174 ----------------------------------------------------
175 -
176 -```
177 -VmPeak: 908112 kB
178 -VmSize: 908112 kB
179 -VmLck: 0 kB
180 -VmHWM: 645832 kB
181 -VmRSS: 645588 kB
182 -VmData: 900940 kB
183 -VmStk: 136 kB
184 -VmExe: 1048 kB
185 -VmLib: 1848 kB
186 -VmPTE: 1716 kB
187 -VmSwap: 1544 kB
188 -```
189 -
190 -**17.31016 kB virtual, 12.88936 kB resident per histogram.**
191 -
192 -1000 histograms with an exponentially-decaying sample size of 1028 and alpha of 0.015
193 --------------------------------------------------------------------------------------
194 -
195 -```
196 -VmPeak: 62480 kB
197 -VmSize: 62480 kB
198 -VmLck: 0 kB
199 -VmHWM: 11572 kB
200 -VmRSS: 11572 kB
201 -VmData: 55308 kB
202 -VmStk: 136 kB
203 -VmExe: 1048 kB
204 -VmLib: 1848 kB
205 -VmPTE: 64 kB
206 -VmSwap: 0 kB
207 -```
208 -
209 -**19.876 kB virtual, 10.452 kB resident per histogram.**
210 -
211 -10000 histograms with an exponentially-decaying sample size of 1028 and alpha of 0.015
212 ---------------------------------------------------------------------------------------
213 -
214 -```
215 -VmPeak: 153296 kB
216 -VmSize: 153296 kB
217 -VmLck: 0 kB
218 -VmHWM: 101176 kB
219 -VmRSS: 101176 kB
220 -VmData: 146124 kB
221 -VmStk: 136 kB
222 -VmExe: 1048 kB
223 -VmLib: 1848 kB
224 -VmPTE: 240 kB
225 -VmSwap: 0 kB
226 -```
227 -
228 -**11.0692 kB virtual, 10.0056 kB resident per histogram.**
229 -
230 -50000 histograms with an exponentially-decaying sample size of 1028 and alpha of 0.015
231 ---------------------------------------------------------------------------------------
232 -
233 -```
234 -VmPeak: 557264 kB
235 -VmSize: 557264 kB
236 -VmLck: 0 kB
237 -VmHWM: 501056 kB
238 -VmRSS: 501056 kB
239 -VmData: 550092 kB
240 -VmStk: 136 kB
241 -VmExe: 1048 kB
242 -VmLib: 1848 kB
243 -VmPTE: 1032 kB
244 -VmSwap: 0 kB
245 -```
246 -
247 -**10.2932 kB virtual, 9.99872 kB resident per histogram.**
248 -
249 -1000 meters
250 ------------
251 -
252 -```
253 -VmPeak: 74504 kB
254 -VmSize: 74504 kB
255 -VmLck: 0 kB
256 -VmHWM: 24124 kB
257 -VmRSS: 24124 kB
258 -VmData: 67340 kB
259 -VmStk: 136 kB
260 -VmExe: 1040 kB
261 -VmLib: 1848 kB
262 -VmPTE: 92 kB
263 -VmSwap: 0 kB
264 -```
265 -
266 -**31.9 kB virtual, 23.004 kB resident per meter.**
267 -
268 -10000 meters
269 -------------
270 -
271 -```
272 -VmPeak: 278920 kB
273 -VmSize: 278920 kB
274 -VmLck: 0 kB
275 -VmHWM: 227300 kB
276 -VmRSS: 227300 kB
277 -VmData: 271756 kB
278 -VmStk: 136 kB
279 -VmExe: 1040 kB
280 -VmLib: 1848 kB
281 -VmPTE: 488 kB
282 -VmSwap: 0 kB
283 -```
284 -
285 -**23.6316 kB virtual, 22.618 kB resident per meter.**
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/meter.go deleted
-255
@@ -1,255 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "sync"
5 - "time"
6 -)
7 -
8 -// Meters count events to produce exponentially-weighted moving average rates
9 -// at one-, five-, and fifteen-minutes and a mean rate.
10 -type Meter interface {
11 - Count() int64
12 - Mark(int64)
13 - RateFine() float64
14 - Rate1() float64
15 - Rate5() float64
16 - Rate15() float64
17 - RateMean() float64
18 - Snapshot() Meter
19 -}
20 -
21 -// GetOrRegisterMeter returns an existing Meter or constructs and registers a
22 -// new StandardMeter.
23 -func GetOrRegisterMeter(name string, r Registry) Meter {
24 - if nil == r {
25 - r = DefaultRegistry
26 - }
27 - return r.GetOrRegister(name, NewMeter).(Meter)
28 -}
29 -
30 -// NewMeter constructs a new StandardMeter and launches a goroutine.
31 -func NewMeter() Meter {
32 - if UseNilMetrics {
33 - return NilMeter{}
34 - }
35 - m := newStandardMeter()
36 - arbiter.Lock()
37 - defer arbiter.Unlock()
38 - arbiter.meters = append(arbiter.meters, m)
39 - if !arbiter.started {
40 - arbiter.started = true
41 - go arbiter.tick()
42 - }
43 - return m
44 -}
45 -
46 -// NewMeter constructs and registers a new StandardMeter and launches a
47 -// goroutine.
48 -func NewRegisteredMeter(name string, r Registry) Meter {
49 - c := NewMeter()
50 - if nil == r {
51 - r = DefaultRegistry
52 - }
53 - r.Register(name, c)
54 - return c
55 -}
56 -
57 -// MeterSnapshot is a read-only copy of another Meter.
58 -type MeterSnapshot struct {
59 - count int64
60 - rateFine float64
61 - rate1, rate5, rate15, rateMean float64
62 -}
63 -
64 -// Count returns the count of events at the time the snapshot was taken.
65 -func (m *MeterSnapshot) Count() int64 { return m.count }
66 -
67 -// Mark panics.
68 -func (*MeterSnapshot) Mark(n int64) {
69 - panic("Mark called on a MeterSnapshot")
70 -}
71 -
72 -// RateFine returns the one-second moving average rate of events per second at the
73 -// time the snapshot was taken.
74 -func (m *MeterSnapshot) RateFine() float64 { return m.rateFine }
75 -
76 -// Rate1 returns the one-minute moving average rate of events per second at the
77 -// time the snapshot was taken.
78 -func (m *MeterSnapshot) Rate1() float64 { return m.rate1 }
79 -
80 -// Rate5 returns the five-minute moving average rate of events per second at
81 -// the time the snapshot was taken.
82 -func (m *MeterSnapshot) Rate5() float64 { return m.rate5 }
83 -
84 -// Rate15 returns the fifteen-minute moving average rate of events per second
85 -// at the time the snapshot was taken.
86 -func (m *MeterSnapshot) Rate15() float64 { return m.rate15 }
87 -
88 -// RateMean returns the meter's mean rate of events per second at the time the
89 -// snapshot was taken.
90 -func (m *MeterSnapshot) RateMean() float64 { return m.rateMean }
91 -
92 -// Snapshot returns the snapshot.
93 -func (m *MeterSnapshot) Snapshot() Meter { return m }
94 -
95 -// NilMeter is a no-op Meter.
96 -type NilMeter struct{}
97 -
98 -// Count is a no-op.
99 -func (NilMeter) Count() int64 { return 0 }
100 -
101 -// Mark is a no-op.
102 -func (NilMeter) Mark(n int64) {}
103 -
104 -// RateFine is a no-op.
105 -func (NilMeter) RateFine() float64 { return 0.0 }
106 -
107 -// Rate1 is a no-op.
108 -func (NilMeter) Rate1() float64 { return 0.0 }
109 -
110 -// Rate5 is a no-op.
111 -func (NilMeter) Rate5() float64 { return 0.0 }
112 -
113 -// Rate15is a no-op.
114 -func (NilMeter) Rate15() float64 { return 0.0 }
115 -
116 -// RateMean is a no-op.
117 -func (NilMeter) RateMean() float64 { return 0.0 }
118 -
119 -// Snapshot is a no-op.
120 -func (NilMeter) Snapshot() Meter { return NilMeter{} }
121 -
122 -// StandardMeter is the standard implementation of a Meter.
123 -type StandardMeter struct {
124 - lock sync.RWMutex
125 - snapshot *MeterSnapshot
126 - aFine EWMA
127 - a1, a5, a15 EWMA
128 - startTime time.Time
129 -}
130 -
131 -func newStandardMeter() *StandardMeter {
132 - return &StandardMeter{
133 - snapshot: &MeterSnapshot{},
134 - aFine: NewEWMAFine(),
135 - a1: NewEWMA1(),
136 - a5: NewEWMA5(),
137 - a15: NewEWMA15(),
138 - startTime: time.Now(),
139 - }
140 -}
141 -
142 -// Count returns the number of events recorded.
143 -func (m *StandardMeter) Count() int64 {
144 - m.lock.RLock()
145 - count := m.snapshot.count
146 - m.lock.RUnlock()
147 - return count
148 -}
149 -
150 -// Mark records the occurance of n events.
151 -func (m *StandardMeter) Mark(n int64) {
152 - m.lock.Lock()
153 - defer m.lock.Unlock()
154 - m.snapshot.count += n
155 - m.aFine.Update(n)
156 - m.a1.Update(n)
157 - m.a5.Update(n)
158 - m.a15.Update(n)
159 - m.updateSnapshot()
160 -}
161 -
162 -// Rate1 returns the one-minute moving average rate of events per second.
163 -func (m *StandardMeter) RateFine() float64 {
164 - m.lock.RLock()
165 - rateFine := m.snapshot.rateFine
166 - m.lock.RUnlock()
167 - return rateFine
168 -}
169 -
170 -// Rate1 returns the one-minute moving average rate of events per second.
171 -func (m *StandardMeter) Rate1() float64 {
172 - m.lock.RLock()
173 - rate1 := m.snapshot.rate1
174 - m.lock.RUnlock()
175 - return rate1
176 -}
177 -
178 -// Rate5 returns the five-minute moving average rate of events per second.
179 -func (m *StandardMeter) Rate5() float64 {
180 - m.lock.RLock()
181 - rate5 := m.snapshot.rate5
182 - m.lock.RUnlock()
183 - return rate5
184 -}
185 -
186 -// Rate15 returns the fifteen-minute moving average rate of events per second.
187 -func (m *StandardMeter) Rate15() float64 {
188 - m.lock.RLock()
189 - rate15 := m.snapshot.rate15
190 - m.lock.RUnlock()
191 - return rate15
192 -}
193 -
194 -// RateMean returns the meter's mean rate of events per second.
195 -func (m *StandardMeter) RateMean() float64 {
196 - m.lock.RLock()
197 - rateMean := m.snapshot.rateMean
198 - m.lock.RUnlock()
199 - return rateMean
200 -}
201 -
202 -// Snapshot returns a read-only copy of the meter.
203 -func (m *StandardMeter) Snapshot() Meter {
204 - m.lock.RLock()
205 - snapshot := *m.snapshot
206 - m.lock.RUnlock()
207 - return &snapshot
208 -}
209 -
210 -func (m *StandardMeter) updateSnapshot() {
211 - // should run with write lock held on m.lock
212 - snapshot := m.snapshot
213 - snapshot.rateFine = m.aFine.Rate()
214 - snapshot.rate1 = m.a1.Rate()
215 - snapshot.rate5 = m.a5.Rate()
216 - snapshot.rate15 = m.a15.Rate()
217 - snapshot.rateMean = float64(snapshot.count) / time.Since(m.startTime).Seconds()
218 -}
219 -
220 -func (m *StandardMeter) tick() {
221 - m.lock.Lock()
222 - defer m.lock.Unlock()
223 - m.aFine.Tick()
224 - m.a1.Tick()
225 - m.a5.Tick()
226 - m.a15.Tick()
227 - m.updateSnapshot()
228 -}
229 -
230 -type meterArbiter struct {
231 - sync.RWMutex
232 - started bool
233 - meters []*StandardMeter
234 - ticker *time.Ticker
235 -}
236 -
237 -var arbiter = meterArbiter{ticker: time.NewTicker(time.Second)}
238 -
239 -// Ticks meters on the scheduled interval
240 -func (ma *meterArbiter) tick() {
241 - for {
242 - select {
243 - case <-ma.ticker.C:
244 - ma.tickMeters()
245 - }
246 - }
247 -}
248 -
249 -func (ma *meterArbiter) tickMeters() {
250 - ma.RLock()
251 - defer ma.RUnlock()
252 - for _, meter := range ma.meters {
253 - meter.tick()
254 - }
255 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/meter_test.go deleted
-60
@@ -1,60 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "testing"
5 - "time"
6 -)
7 -
8 -func BenchmarkMeter(b *testing.B) {
9 - m := NewMeter()
10 - b.ResetTimer()
11 - for i := 0; i < b.N; i++ {
12 - m.Mark(1)
13 - }
14 -}
15 -
16 -func TestGetOrRegisterMeter(t *testing.T) {
17 - r := NewRegistry()
18 - NewRegisteredMeter("foo", r).Mark(47)
19 - if m := GetOrRegisterMeter("foo", r); 47 != m.Count() {
20 - t.Fatal(m)
21 - }
22 -}
23 -
24 -func TestMeterDecay(t *testing.T) {
25 - ma := meterArbiter{
26 - ticker: time.NewTicker(1),
27 - }
28 - m := newStandardMeter()
29 - ma.meters = append(ma.meters, m)
30 - go ma.tick()
31 - m.Mark(1)
32 - rateMean := m.RateMean()
33 - time.Sleep(1)
34 - if m.RateMean() >= rateMean {
35 - t.Error("m.RateMean() didn't decrease")
36 - }
37 -}
38 -
39 -func TestMeterNonzero(t *testing.T) {
40 - m := NewMeter()
41 - m.Mark(3)
42 - if count := m.Count(); 3 != count {
43 - t.Errorf("m.Count(): 3 != %v\n", count)
44 - }
45 -}
46 -
47 -func TestMeterSnapshot(t *testing.T) {
48 - m := NewMeter()
49 - m.Mark(1)
50 - if snapshot := m.Snapshot(); m.RateMean() != snapshot.RateMean() {
51 - t.Fatal(snapshot)
52 - }
53 -}
54 -
55 -func TestMeterZero(t *testing.T) {
56 - m := NewMeter()
57 - if count := m.Count(); 0 != count {
58 - t.Errorf("m.Count(): 0 != %v\n", count)
59 - }
60 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/metrics.go deleted
-13
@@ -1,13 +0,0 @@
1 -// Go port of Coda Hale's Metrics library
2 -//
3 -// <https://github.com/rcrowley/go-metrics>
4 -//
5 -// Coda Hale's original work: <https://github.com/codahale/metrics>
6 -package metrics
7 -
8 -// UseNilMetrics is checked by the constructor functions for all of the
9 -// standard metrics. If it is true, the metric returned is a stub.
10 -//
11 -// This global kill-switch helps quantify the observer effect and makes
12 -// for less cluttered pprof profiles.
13 -var UseNilMetrics bool = false
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/metrics_test.go deleted
-107
@@ -1,107 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "io/ioutil"
5 - "log"
6 - "sync"
7 - "testing"
8 -)
9 -
10 -const FANOUT = 128
11 -
12 -// Stop the compiler from complaining during debugging.
13 -var (
14 - _ = ioutil.Discard
15 - _ = log.LstdFlags
16 -)
17 -
18 -func BenchmarkMetrics(b *testing.B) {
19 - r := NewRegistry()
20 - c := NewRegisteredCounter("counter", r)
21 - g := NewRegisteredGauge("gauge", r)
22 - gf := NewRegisteredGaugeFloat64("gaugefloat64", r)
23 - h := NewRegisteredHistogram("histogram", r, NewUniformSample(100))
24 - m := NewRegisteredMeter("meter", r)
25 - t := NewRegisteredTimer("timer", r)
26 - RegisterDebugGCStats(r)
27 - RegisterRuntimeMemStats(r)
28 - b.ResetTimer()
29 - ch := make(chan bool)
30 -
31 - wgD := &sync.WaitGroup{}
32 - /*
33 - wgD.Add(1)
34 - go func() {
35 - defer wgD.Done()
36 - //log.Println("go CaptureDebugGCStats")
37 - for {
38 - select {
39 - case <-ch:
40 - //log.Println("done CaptureDebugGCStats")
41 - return
42 - default:
43 - CaptureDebugGCStatsOnce(r)
44 - }
45 - }
46 - }()
47 - //*/
48 -
49 - wgR := &sync.WaitGroup{}
50 - //*
51 - wgR.Add(1)
52 - go func() {
53 - defer wgR.Done()
54 - //log.Println("go CaptureRuntimeMemStats")
55 - for {
56 - select {
57 - case <-ch:
58 - //log.Println("done CaptureRuntimeMemStats")
59 - return
60 - default:
61 - CaptureRuntimeMemStatsOnce(r)
62 - }
63 - }
64 - }()
65 - //*/
66 -
67 - wgW := &sync.WaitGroup{}
68 - /*
69 - wgW.Add(1)
70 - go func() {
71 - defer wgW.Done()
72 - //log.Println("go Write")
73 - for {
74 - select {
75 - case <-ch:
76 - //log.Println("done Write")
77 - return
78 - default:
79 - WriteOnce(r, ioutil.Discard)
80 - }
81 - }
82 - }()
83 - //*/
84 -
85 - wg := &sync.WaitGroup{}
86 - wg.Add(FANOUT)
87 - for i := 0; i < FANOUT; i++ {
88 - go func(i int) {
89 - defer wg.Done()
90 - //log.Println("go", i)
91 - for i := 0; i < b.N; i++ {
92 - c.Inc(1)
93 - g.Update(int64(i))
94 - gf.Update(float64(i))
95 - h.Update(int64(i))
96 - m.Mark(1)
97 - t.Update(1)
98 - }
99 - //log.Println("done", i)
100 - }(i)
101 - }
102 - wg.Wait()
103 - close(ch)
104 - wgD.Wait()
105 - wgR.Wait()
106 - wgW.Wait()
107 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/opentsdb.go deleted
-119
@@ -1,119 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "bufio"
5 - "fmt"
6 - "log"
7 - "net"
8 - "os"
9 - "strings"
10 - "time"
11 -)
12 -
13 -var shortHostName string = ""
14 -
15 -// OpenTSDBConfig provides a container with configuration parameters for
16 -// the OpenTSDB exporter
17 -type OpenTSDBConfig struct {
18 - Addr *net.TCPAddr // Network address to connect to
19 - Registry Registry // Registry to be exported
20 - FlushInterval time.Duration // Flush interval
21 - DurationUnit time.Duration // Time conversion unit for durations
22 - Prefix string // Prefix to be prepended to metric names
23 -}
24 -
25 -// OpenTSDB is a blocking exporter function which reports metrics in r
26 -// to a TSDB server located at addr, flushing them every d duration
27 -// and prepending metric names with prefix.
28 -func OpenTSDB(r Registry, d time.Duration, prefix string, addr *net.TCPAddr) {
29 - OpenTSDBWithConfig(OpenTSDBConfig{
30 - Addr: addr,
31 - Registry: r,
32 - FlushInterval: d,
33 - DurationUnit: time.Nanosecond,
34 - Prefix: prefix,
35 - })
36 -}
37 -
38 -// OpenTSDBWithConfig is a blocking exporter function just like OpenTSDB,
39 -// but it takes a OpenTSDBConfig instead.
40 -func OpenTSDBWithConfig(c OpenTSDBConfig) {
41 - for _ = range time.Tick(c.FlushInterval) {
42 - if err := openTSDB(&c); nil != err {
43 - log.Println(err)
44 - }
45 - }
46 -}
47 -
48 -func getShortHostname() string {
49 - if shortHostName == "" {
50 - host, _ := os.Hostname()
51 - if index := strings.Index(host, "."); index > 0 {
52 - shortHostName = host[:index]
53 - } else {
54 - shortHostName = host
55 - }
56 - }
57 - return shortHostName
58 -}
59 -
60 -func openTSDB(c *OpenTSDBConfig) error {
61 - shortHostname := getShortHostname()
62 - now := time.Now().Unix()
63 - du := float64(c.DurationUnit)
64 - conn, err := net.DialTCP("tcp", nil, c.Addr)
65 - if nil != err {
66 - return err
67 - }
68 - defer conn.Close()
69 - w := bufio.NewWriter(conn)
70 - c.Registry.Each(func(name string, i interface{}) {
71 - switch metric := i.(type) {
72 - case Counter:
73 - fmt.Fprintf(w, "put %s.%s.count %d %d host=%s\n", c.Prefix, name, now, metric.Count(), shortHostname)
74 - case Gauge:
75 - fmt.Fprintf(w, "put %s.%s.value %d %d host=%s\n", c.Prefix, name, now, metric.Value(), shortHostname)
76 - case GaugeFloat64:
77 - fmt.Fprintf(w, "put %s.%s.value %d %f host=%s\n", c.Prefix, name, now, metric.Value(), shortHostname)
78 - case Histogram:
79 - h := metric.Snapshot()
80 - ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
81 - fmt.Fprintf(w, "put %s.%s.count %d %d host=%s\n", c.Prefix, name, now, h.Count(), shortHostname)
82 - fmt.Fprintf(w, "put %s.%s.min %d %d host=%s\n", c.Prefix, name, now, h.Min(), shortHostname)
83 - fmt.Fprintf(w, "put %s.%s.max %d %d host=%s\n", c.Prefix, name, now, h.Max(), shortHostname)
84 - fmt.Fprintf(w, "put %s.%s.mean %d %.2f host=%s\n", c.Prefix, name, now, h.Mean(), shortHostname)
85 - fmt.Fprintf(w, "put %s.%s.std-dev %d %.2f host=%s\n", c.Prefix, name, now, h.StdDev(), shortHostname)
86 - fmt.Fprintf(w, "put %s.%s.50-percentile %d %.2f host=%s\n", c.Prefix, name, now, ps[0], shortHostname)
87 - fmt.Fprintf(w, "put %s.%s.75-percentile %d %.2f host=%s\n", c.Prefix, name, now, ps[1], shortHostname)
88 - fmt.Fprintf(w, "put %s.%s.95-percentile %d %.2f host=%s\n", c.Prefix, name, now, ps[2], shortHostname)
89 - fmt.Fprintf(w, "put %s.%s.99-percentile %d %.2f host=%s\n", c.Prefix, name, now, ps[3], shortHostname)
90 - fmt.Fprintf(w, "put %s.%s.999-percentile %d %.2f host=%s\n", c.Prefix, name, now, ps[4], shortHostname)
91 - case Meter:
92 - m := metric.Snapshot()
93 - fmt.Fprintf(w, "put %s.%s.count %d %d host=%s\n", c.Prefix, name, now, m.Count(), shortHostname)
94 - fmt.Fprintf(w, "put %s.%s.one-minute %d %.2f host=%s\n", c.Prefix, name, now, m.Rate1(), shortHostname)
95 - fmt.Fprintf(w, "put %s.%s.five-minute %d %.2f host=%s\n", c.Prefix, name, now, m.Rate5(), shortHostname)
96 - fmt.Fprintf(w, "put %s.%s.fifteen-minute %d %.2f host=%s\n", c.Prefix, name, now, m.Rate15(), shortHostname)
97 - fmt.Fprintf(w, "put %s.%s.mean %d %.2f host=%s\n", c.Prefix, name, now, m.RateMean(), shortHostname)
98 - case Timer:
99 - t := metric.Snapshot()
100 - ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
101 - fmt.Fprintf(w, "put %s.%s.count %d %d host=%s\n", c.Prefix, name, now, t.Count(), shortHostname)
102 - fmt.Fprintf(w, "put %s.%s.min %d %d host=%s\n", c.Prefix, name, now, t.Min()/int64(du), shortHostname)
103 - fmt.Fprintf(w, "put %s.%s.max %d %d host=%s\n", c.Prefix, name, now, t.Max()/int64(du), shortHostname)
104 - fmt.Fprintf(w, "put %s.%s.mean %d %.2f host=%s\n", c.Prefix, name, now, t.Mean()/du, shortHostname)
105 - fmt.Fprintf(w, "put %s.%s.std-dev %d %.2f host=%s\n", c.Prefix, name, now, t.StdDev()/du, shortHostname)
106 - fmt.Fprintf(w, "put %s.%s.50-percentile %d %.2f host=%s\n", c.Prefix, name, now, ps[0]/du, shortHostname)
107 - fmt.Fprintf(w, "put %s.%s.75-percentile %d %.2f host=%s\n", c.Prefix, name, now, ps[1]/du, shortHostname)
108 - fmt.Fprintf(w, "put %s.%s.95-percentile %d %.2f host=%s\n", c.Prefix, name, now, ps[2]/du, shortHostname)
109 - fmt.Fprintf(w, "put %s.%s.99-percentile %d %.2f host=%s\n", c.Prefix, name, now, ps[3]/du, shortHostname)
110 - fmt.Fprintf(w, "put %s.%s.999-percentile %d %.2f host=%s\n", c.Prefix, name, now, ps[4]/du, shortHostname)
111 - fmt.Fprintf(w, "put %s.%s.one-minute %d %.2f host=%s\n", c.Prefix, name, now, t.Rate1(), shortHostname)
112 - fmt.Fprintf(w, "put %s.%s.five-minute %d %.2f host=%s\n", c.Prefix, name, now, t.Rate5(), shortHostname)
113 - fmt.Fprintf(w, "put %s.%s.fifteen-minute %d %.2f host=%s\n", c.Prefix, name, now, t.Rate15(), shortHostname)
114 - fmt.Fprintf(w, "put %s.%s.mean-rate %d %.2f host=%s\n", c.Prefix, name, now, t.RateMean(), shortHostname)
115 - }
116 - w.Flush()
117 - })
118 - return nil
119 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/opentsdb_test.go deleted
-22
@@ -1,22 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "net"
5 - "time"
6 -)
7 -
8 -func ExampleOpenTSDB() {
9 - addr, _ := net.ResolveTCPAddr("net", ":2003")
10 - go OpenTSDB(DefaultRegistry, 1*time.Second, "some.prefix", addr)
11 -}
12 -
13 -func ExampleOpenTSDBWithConfig() {
14 - addr, _ := net.ResolveTCPAddr("net", ":2003")
15 - go OpenTSDBWithConfig(OpenTSDBConfig{
16 - Addr: addr,
17 - Registry: DefaultRegistry,
18 - FlushInterval: 1 * time.Second,
19 - DurationUnit: time.Millisecond,
20 - })
21 -}
22 -
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/registry.go deleted
-180
@@ -1,180 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "fmt"
5 - "reflect"
6 - "sync"
7 -)
8 -
9 -// DuplicateMetric is the error returned by Registry.Register when a metric
10 -// already exists. If you mean to Register that metric you must first
11 -// Unregister the existing metric.
12 -type DuplicateMetric string
13 -
14 -func (err DuplicateMetric) Error() string {
15 - return fmt.Sprintf("duplicate metric: %s", string(err))
16 -}
17 -
18 -// A Registry holds references to a set of metrics by name and can iterate
19 -// over them, calling callback functions provided by the user.
20 -//
21 -// This is an interface so as to encourage other structs to implement
22 -// the Registry API as appropriate.
23 -type Registry interface {
24 -
25 - // Call the given function for each registered metric.
26 - Each(func(string, interface{}))
27 -
28 - // Get the metric by the given name or nil if none is registered.
29 - Get(string) interface{}
30 -
31 - // Gets an existing metric or registers the given one.
32 - // The interface can be the metric to register if not found in registry,
33 - // or a function returning the metric for lazy instantiation.
34 - GetOrRegister(string, interface{}) interface{}
35 -
36 - // Register the given metric under the given name.
37 - Register(string, interface{}) error
38 -
39 - // Run all registered healthchecks.
40 - RunHealthchecks()
41 -
42 - // Unregister the metric with the given name.
43 - Unregister(string)
44 -
45 - // Unregister all metrics. (Mostly for testing.)
46 - UnregisterAll()
47 -}
48 -
49 -// The standard implementation of a Registry is a mutex-protected map
50 -// of names to metrics.
51 -type StandardRegistry struct {
52 - metrics map[string]interface{}
53 - mutex sync.Mutex
54 -}
55 -
56 -// Create a new registry.
57 -func NewRegistry() Registry {
58 - return &StandardRegistry{metrics: make(map[string]interface{})}
59 -}
60 -
61 -// Call the given function for each registered metric.
62 -func (r *StandardRegistry) Each(f func(string, interface{})) {
63 - for name, i := range r.registered() {
64 - f(name, i)
65 - }
66 -}
67 -
68 -// Get the metric by the given name or nil if none is registered.
69 -func (r *StandardRegistry) Get(name string) interface{} {
70 - r.mutex.Lock()
71 - defer r.mutex.Unlock()
72 - return r.metrics[name]
73 -}
74 -
75 -// Gets an existing metric or creates and registers a new one. Threadsafe
76 -// alternative to calling Get and Register on failure.
77 -// The interface can be the metric to register if not found in registry,
78 -// or a function returning the metric for lazy instantiation.
79 -func (r *StandardRegistry) GetOrRegister(name string, i interface{}) interface{} {
80 - r.mutex.Lock()
81 - defer r.mutex.Unlock()
82 - if metric, ok := r.metrics[name]; ok {
83 - return metric
84 - }
85 - if v := reflect.ValueOf(i); v.Kind() == reflect.Func {
86 - i = v.Call(nil)[0].Interface()
87 - }
88 - r.register(name, i)
89 - return i
90 -}
91 -
92 -// Register the given metric under the given name. Returns a DuplicateMetric
93 -// if a metric by the given name is already registered.
94 -func (r *StandardRegistry) Register(name string, i interface{}) error {
95 - r.mutex.Lock()
96 - defer r.mutex.Unlock()
97 - return r.register(name, i)
98 -}
99 -
100 -// Run all registered healthchecks.
101 -func (r *StandardRegistry) RunHealthchecks() {
102 - r.mutex.Lock()
103 - defer r.mutex.Unlock()
104 - for _, i := range r.metrics {
105 - if h, ok := i.(Healthcheck); ok {
106 - h.Check()
107 - }
108 - }
109 -}
110 -
111 -// Unregister the metric with the given name.
112 -func (r *StandardRegistry) Unregister(name string) {
113 - r.mutex.Lock()
114 - defer r.mutex.Unlock()
115 - delete(r.metrics, name)
116 -}
117 -
118 -// Unregister all metrics. (Mostly for testing.)
119 -func (r *StandardRegistry) UnregisterAll() {
120 - r.mutex.Lock()
121 - defer r.mutex.Unlock()
122 - for name, _ := range r.metrics {
123 - delete(r.metrics, name)
124 - }
125 -}
126 -
127 -func (r *StandardRegistry) register(name string, i interface{}) error {
128 - if _, ok := r.metrics[name]; ok {
129 - return DuplicateMetric(name)
130 - }
131 - switch i.(type) {
132 - case Counter, Gauge, GaugeFloat64, Healthcheck, Histogram, Meter, Timer:
133 - r.metrics[name] = i
134 - }
135 - return nil
136 -}
137 -
138 -func (r *StandardRegistry) registered() map[string]interface{} {
139 - metrics := make(map[string]interface{}, len(r.metrics))
140 - r.mutex.Lock()
141 - defer r.mutex.Unlock()
142 - for name, i := range r.metrics {
143 - metrics[name] = i
144 - }
145 - return metrics
146 -}
147 -
148 -var DefaultRegistry Registry = NewRegistry()
149 -
150 -// Call the given function for each registered metric.
151 -func Each(f func(string, interface{})) {
152 - DefaultRegistry.Each(f)
153 -}
154 -
155 -// Get the metric by the given name or nil if none is registered.
156 -func Get(name string) interface{} {
157 - return DefaultRegistry.Get(name)
158 -}
159 -
160 -// Gets an existing metric or creates and registers a new one. Threadsafe
161 -// alternative to calling Get and Register on failure.
162 -func GetOrRegister(name string, i interface{}) interface{} {
163 - return DefaultRegistry.GetOrRegister(name, i)
164 -}
165 -
166 -// Register the given metric under the given name. Returns a DuplicateMetric
167 -// if a metric by the given name is already registered.
168 -func Register(name string, i interface{}) error {
169 - return DefaultRegistry.Register(name, i)
170 -}
171 -
172 -// Run all registered healthchecks.
173 -func RunHealthchecks() {
174 - DefaultRegistry.RunHealthchecks()
175 -}
176 -
177 -// Unregister the metric with the given name.
178 -func Unregister(name string) {
179 - DefaultRegistry.Unregister(name)
180 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/registry_test.go deleted
-118
@@ -1,118 +0,0 @@
1 -package metrics
2 -
3 -import "testing"
4 -
5 -func BenchmarkRegistry(b *testing.B) {
6 - r := NewRegistry()
7 - r.Register("foo", NewCounter())
8 - b.ResetTimer()
9 - for i := 0; i < b.N; i++ {
10 - r.Each(func(string, interface{}) {})
11 - }
12 -}
13 -
14 -func TestRegistry(t *testing.T) {
15 - r := NewRegistry()
16 - r.Register("foo", NewCounter())
17 - i := 0
18 - r.Each(func(name string, iface interface{}) {
19 - i++
20 - if "foo" != name {
21 - t.Fatal(name)
22 - }
23 - if _, ok := iface.(Counter); !ok {
24 - t.Fatal(iface)
25 - }
26 - })
27 - if 1 != i {
28 - t.Fatal(i)
29 - }
30 - r.Unregister("foo")
31 - i = 0
32 - r.Each(func(string, interface{}) { i++ })
33 - if 0 != i {
34 - t.Fatal(i)
35 - }
36 -}
37 -
38 -func TestRegistryDuplicate(t *testing.T) {
39 - r := NewRegistry()
40 - if err := r.Register("foo", NewCounter()); nil != err {
41 - t.Fatal(err)
42 - }
43 - if err := r.Register("foo", NewGauge()); nil == err {
44 - t.Fatal(err)
45 - }
46 - i := 0
47 - r.Each(func(name string, iface interface{}) {
48 - i++
49 - if _, ok := iface.(Counter); !ok {
50 - t.Fatal(iface)
51 - }
52 - })
53 - if 1 != i {
54 - t.Fatal(i)
55 - }
56 -}
57 -
58 -func TestRegistryGet(t *testing.T) {
59 - r := NewRegistry()
60 - r.Register("foo", NewCounter())
61 - if count := r.Get("foo").(Counter).Count(); 0 != count {
62 - t.Fatal(count)
63 - }
64 - r.Get("foo").(Counter).Inc(1)
65 - if count := r.Get("foo").(Counter).Count(); 1 != count {
66 - t.Fatal(count)
67 - }
68 -}
69 -
70 -func TestRegistryGetOrRegister(t *testing.T) {
71 - r := NewRegistry()
72 -
73 - // First metric wins with GetOrRegister
74 - _ = r.GetOrRegister("foo", NewCounter())
75 - m := r.GetOrRegister("foo", NewGauge())
76 - if _, ok := m.(Counter); !ok {
77 - t.Fatal(m)
78 - }
79 -
80 - i := 0
81 - r.Each(func(name string, iface interface{}) {
82 - i++
83 - if name != "foo" {
84 - t.Fatal(name)
85 - }
86 - if _, ok := iface.(Counter); !ok {
87 - t.Fatal(iface)
88 - }
89 - })
90 - if i != 1 {
91 - t.Fatal(i)
92 - }
93 -}
94 -
95 -func TestRegistryGetOrRegisterWithLazyInstantiation(t *testing.T) {
96 - r := NewRegistry()
97 -
98 - // First metric wins with GetOrRegister
99 - _ = r.GetOrRegister("foo", NewCounter)
100 - m := r.GetOrRegister("foo", NewGauge)
101 - if _, ok := m.(Counter); !ok {
102 - t.Fatal(m)
103 - }
104 -
105 - i := 0
106 - r.Each(func(name string, iface interface{}) {
107 - i++
108 - if name != "foo" {
109 - t.Fatal(name)
110 - }
111 - if _, ok := iface.(Counter); !ok {
112 - t.Fatal(iface)
113 - }
114 - })
115 - if i != 1 {
116 - t.Fatal(i)
117 - }
118 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/runtime.go deleted
-200
@@ -1,200 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "runtime"
5 - "time"
6 -)
7 -
8 -var (
9 - memStats runtime.MemStats
10 - runtimeMetrics struct {
11 - MemStats struct {
12 - Alloc Gauge
13 - BuckHashSys Gauge
14 - DebugGC Gauge
15 - EnableGC Gauge
16 - Frees Gauge
17 - HeapAlloc Gauge
18 - HeapIdle Gauge
19 - HeapInuse Gauge
20 - HeapObjects Gauge
21 - HeapReleased Gauge
22 - HeapSys Gauge
23 - LastGC Gauge
24 - Lookups Gauge
25 - Mallocs Gauge
26 - MCacheInuse Gauge
27 - MCacheSys Gauge
28 - MSpanInuse Gauge
29 - MSpanSys Gauge
30 - NextGC Gauge
31 - NumGC Gauge
32 - PauseNs Histogram
33 - PauseTotalNs Gauge
34 - StackInuse Gauge
35 - StackSys Gauge
36 - Sys Gauge
37 - TotalAlloc Gauge
38 - }
39 - NumCgoCall Gauge
40 - NumGoroutine Gauge
41 - ReadMemStats Timer
42 - }
43 - frees uint64
44 - lookups uint64
45 - mallocs uint64
46 - numGC uint32
47 - numCgoCalls int64
48 -)
49 -
50 -// Capture new values for the Go runtime statistics exported in
51 -// runtime.MemStats. This is designed to be called as a goroutine.
52 -func CaptureRuntimeMemStats(r Registry, d time.Duration) {
53 - for _ = range time.Tick(d) {
54 - CaptureRuntimeMemStatsOnce(r)
55 - }
56 -}
57 -
58 -// Capture new values for the Go runtime statistics exported in
59 -// runtime.MemStats. This is designed to be called in a background
60 -// goroutine. Giving a registry which has not been given to
61 -// RegisterRuntimeMemStats will panic.
62 -//
63 -// Be very careful with this because runtime.ReadMemStats calls the C
64 -// functions runtime·semacquire(&runtime·worldsema) and runtime·stoptheworld()
65 -// and that last one does what it says on the tin.
66 -func CaptureRuntimeMemStatsOnce(r Registry) {
67 - t := time.Now()
68 - runtime.ReadMemStats(&memStats) // This takes 50-200us.
69 - runtimeMetrics.ReadMemStats.UpdateSince(t)
70 -
71 - runtimeMetrics.MemStats.Alloc.Update(int64(memStats.Alloc))
72 - runtimeMetrics.MemStats.BuckHashSys.Update(int64(memStats.BuckHashSys))
73 - if memStats.DebugGC {
74 - runtimeMetrics.MemStats.DebugGC.Update(1)
75 - } else {
76 - runtimeMetrics.MemStats.DebugGC.Update(0)
77 - }
78 - if memStats.EnableGC {
79 - runtimeMetrics.MemStats.EnableGC.Update(1)
80 - } else {
81 - runtimeMetrics.MemStats.EnableGC.Update(0)
82 - }
83 -
84 - runtimeMetrics.MemStats.Frees.Update(int64(memStats.Frees - frees))
85 - runtimeMetrics.MemStats.HeapAlloc.Update(int64(memStats.HeapAlloc))
86 - runtimeMetrics.MemStats.HeapIdle.Update(int64(memStats.HeapIdle))
87 - runtimeMetrics.MemStats.HeapInuse.Update(int64(memStats.HeapInuse))
88 - runtimeMetrics.MemStats.HeapObjects.Update(int64(memStats.HeapObjects))
89 - runtimeMetrics.MemStats.HeapReleased.Update(int64(memStats.HeapReleased))
90 - runtimeMetrics.MemStats.HeapSys.Update(int64(memStats.HeapSys))
91 - runtimeMetrics.MemStats.LastGC.Update(int64(memStats.LastGC))
92 - runtimeMetrics.MemStats.Lookups.Update(int64(memStats.Lookups - lookups))
93 - runtimeMetrics.MemStats.Mallocs.Update(int64(memStats.Mallocs - mallocs))
94 - runtimeMetrics.MemStats.MCacheInuse.Update(int64(memStats.MCacheInuse))
95 - runtimeMetrics.MemStats.MCacheSys.Update(int64(memStats.MCacheSys))
96 - runtimeMetrics.MemStats.MSpanInuse.Update(int64(memStats.MSpanInuse))
97 - runtimeMetrics.MemStats.MSpanSys.Update(int64(memStats.MSpanSys))
98 - runtimeMetrics.MemStats.NextGC.Update(int64(memStats.NextGC))
99 - runtimeMetrics.MemStats.NumGC.Update(int64(memStats.NumGC - numGC))
100 -
101 - // <https://code.google.com/p/go/source/browse/src/pkg/runtime/mgc0.c>
102 - i := numGC % uint32(len(memStats.PauseNs))
103 - ii := memStats.NumGC % uint32(len(memStats.PauseNs))
104 - if memStats.NumGC-numGC >= uint32(len(memStats.PauseNs)) {
105 - for i = 0; i < uint32(len(memStats.PauseNs)); i++ {
106 - runtimeMetrics.MemStats.PauseNs.Update(int64(memStats.PauseNs[i]))
107 - }
108 - } else {
109 - if i > ii {
110 - for ; i < uint32(len(memStats.PauseNs)); i++ {
111 - runtimeMetrics.MemStats.PauseNs.Update(int64(memStats.PauseNs[i]))
112 - }
113 - i = 0
114 - }
115 - for ; i < ii; i++ {
116 - runtimeMetrics.MemStats.PauseNs.Update(int64(memStats.PauseNs[i]))
117 - }
118 - }
119 - frees = memStats.Frees
120 - lookups = memStats.Lookups
121 - mallocs = memStats.Mallocs
122 - numGC = memStats.NumGC
123 -
124 - runtimeMetrics.MemStats.PauseTotalNs.Update(int64(memStats.PauseTotalNs))
125 - runtimeMetrics.MemStats.StackInuse.Update(int64(memStats.StackInuse))
126 - runtimeMetrics.MemStats.StackSys.Update(int64(memStats.StackSys))
127 - runtimeMetrics.MemStats.Sys.Update(int64(memStats.Sys))
128 - runtimeMetrics.MemStats.TotalAlloc.Update(int64(memStats.TotalAlloc))
129 -
130 - currentNumCgoCalls := numCgoCall()
131 - runtimeMetrics.NumCgoCall.Update(currentNumCgoCalls - numCgoCalls)
132 - numCgoCalls = currentNumCgoCalls
133 -
134 - runtimeMetrics.NumGoroutine.Update(int64(runtime.NumGoroutine()))
135 -}
136 -
137 -// Register runtimeMetrics for the Go runtime statistics exported in runtime and
138 -// specifically runtime.MemStats. The runtimeMetrics are named by their
139 -// fully-qualified Go symbols, i.e. runtime.MemStats.Alloc.
140 -func RegisterRuntimeMemStats(r Registry) {
141 - runtimeMetrics.MemStats.Alloc = NewGauge()
142 - runtimeMetrics.MemStats.BuckHashSys = NewGauge()
143 - runtimeMetrics.MemStats.DebugGC = NewGauge()
144 - runtimeMetrics.MemStats.EnableGC = NewGauge()
145 - runtimeMetrics.MemStats.Frees = NewGauge()
146 - runtimeMetrics.MemStats.HeapAlloc = NewGauge()
147 - runtimeMetrics.MemStats.HeapIdle = NewGauge()
148 - runtimeMetrics.MemStats.HeapInuse = NewGauge()
149 - runtimeMetrics.MemStats.HeapObjects = NewGauge()
150 - runtimeMetrics.MemStats.HeapReleased = NewGauge()
151 - runtimeMetrics.MemStats.HeapSys = NewGauge()
152 - runtimeMetrics.MemStats.LastGC = NewGauge()
153 - runtimeMetrics.MemStats.Lookups = NewGauge()
154 - runtimeMetrics.MemStats.Mallocs = NewGauge()
155 - runtimeMetrics.MemStats.MCacheInuse = NewGauge()
156 - runtimeMetrics.MemStats.MCacheSys = NewGauge()
157 - runtimeMetrics.MemStats.MSpanInuse = NewGauge()
158 - runtimeMetrics.MemStats.MSpanSys = NewGauge()
159 - runtimeMetrics.MemStats.NextGC = NewGauge()
160 - runtimeMetrics.MemStats.NumGC = NewGauge()
161 - runtimeMetrics.MemStats.PauseNs = NewHistogram(NewExpDecaySample(1028, 0.015))
162 - runtimeMetrics.MemStats.PauseTotalNs = NewGauge()
163 - runtimeMetrics.MemStats.StackInuse = NewGauge()
164 - runtimeMetrics.MemStats.StackSys = NewGauge()
165 - runtimeMetrics.MemStats.Sys = NewGauge()
166 - runtimeMetrics.MemStats.TotalAlloc = NewGauge()
167 - runtimeMetrics.NumCgoCall = NewGauge()
168 - runtimeMetrics.NumGoroutine = NewGauge()
169 - runtimeMetrics.ReadMemStats = NewTimer()
170 -
171 - r.Register("runtime.MemStats.Alloc", runtimeMetrics.MemStats.Alloc)
172 - r.Register("runtime.MemStats.BuckHashSys", runtimeMetrics.MemStats.BuckHashSys)
173 - r.Register("runtime.MemStats.DebugGC", runtimeMetrics.MemStats.DebugGC)
174 - r.Register("runtime.MemStats.EnableGC", runtimeMetrics.MemStats.EnableGC)
175 - r.Register("runtime.MemStats.Frees", runtimeMetrics.MemStats.Frees)
176 - r.Register("runtime.MemStats.HeapAlloc", runtimeMetrics.MemStats.HeapAlloc)
177 - r.Register("runtime.MemStats.HeapIdle", runtimeMetrics.MemStats.HeapIdle)
178 - r.Register("runtime.MemStats.HeapInuse", runtimeMetrics.MemStats.HeapInuse)
179 - r.Register("runtime.MemStats.HeapObjects", runtimeMetrics.MemStats.HeapObjects)
180 - r.Register("runtime.MemStats.HeapReleased", runtimeMetrics.MemStats.HeapReleased)
181 - r.Register("runtime.MemStats.HeapSys", runtimeMetrics.MemStats.HeapSys)
182 - r.Register("runtime.MemStats.LastGC", runtimeMetrics.MemStats.LastGC)
183 - r.Register("runtime.MemStats.Lookups", runtimeMetrics.MemStats.Lookups)
184 - r.Register("runtime.MemStats.Mallocs", runtimeMetrics.MemStats.Mallocs)
185 - r.Register("runtime.MemStats.MCacheInuse", runtimeMetrics.MemStats.MCacheInuse)
186 - r.Register("runtime.MemStats.MCacheSys", runtimeMetrics.MemStats.MCacheSys)
187 - r.Register("runtime.MemStats.MSpanInuse", runtimeMetrics.MemStats.MSpanInuse)
188 - r.Register("runtime.MemStats.MSpanSys", runtimeMetrics.MemStats.MSpanSys)
189 - r.Register("runtime.MemStats.NextGC", runtimeMetrics.MemStats.NextGC)
190 - r.Register("runtime.MemStats.NumGC", runtimeMetrics.MemStats.NumGC)
191 - r.Register("runtime.MemStats.PauseNs", runtimeMetrics.MemStats.PauseNs)
192 - r.Register("runtime.MemStats.PauseTotalNs", runtimeMetrics.MemStats.PauseTotalNs)
193 - r.Register("runtime.MemStats.StackInuse", runtimeMetrics.MemStats.StackInuse)
194 - r.Register("runtime.MemStats.StackSys", runtimeMetrics.MemStats.StackSys)
195 - r.Register("runtime.MemStats.Sys", runtimeMetrics.MemStats.Sys)
196 - r.Register("runtime.MemStats.TotalAlloc", runtimeMetrics.MemStats.TotalAlloc)
197 - r.Register("runtime.NumCgoCall", runtimeMetrics.NumCgoCall)
198 - r.Register("runtime.NumGoroutine", runtimeMetrics.NumGoroutine)
199 - r.Register("runtime.ReadMemStats", runtimeMetrics.ReadMemStats)
200 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/runtime_cgo.go deleted
-10
@@ -1,10 +0,0 @@
1 -// +build cgo
2 -// +build !appengine
3 -
4 -package metrics
5 -
6 -import "runtime"
7 -
8 -func numCgoCall() int64 {
9 - return runtime.NumCgoCall()
10 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/runtime_no_cgo.go deleted
-7
@@ -1,7 +0,0 @@
1 -// +build !cgo appengine
2 -
3 -package metrics
4 -
5 -func numCgoCall() int64 {
6 - return 0
7 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/runtime_test.go deleted
-78
@@ -1,78 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "runtime"
5 - "testing"
6 - "time"
7 -)
8 -
9 -func BenchmarkRuntimeMemStats(b *testing.B) {
10 - r := NewRegistry()
11 - RegisterRuntimeMemStats(r)
12 - b.ResetTimer()
13 - for i := 0; i < b.N; i++ {
14 - CaptureRuntimeMemStatsOnce(r)
15 - }
16 -}
17 -
18 -func TestRuntimeMemStats(t *testing.T) {
19 - r := NewRegistry()
20 - RegisterRuntimeMemStats(r)
21 - CaptureRuntimeMemStatsOnce(r)
22 - zero := runtimeMetrics.MemStats.PauseNs.Count() // Get a "zero" since GC may have run before these tests.
23 - runtime.GC()
24 - CaptureRuntimeMemStatsOnce(r)
25 - if count := runtimeMetrics.MemStats.PauseNs.Count(); 1 != count-zero {
26 - t.Fatal(count - zero)
27 - }
28 - runtime.GC()
29 - runtime.GC()
30 - CaptureRuntimeMemStatsOnce(r)
31 - if count := runtimeMetrics.MemStats.PauseNs.Count(); 3 != count-zero {
32 - t.Fatal(count - zero)
33 - }
34 - for i := 0; i < 256; i++ {
35 - runtime.GC()
36 - }
37 - CaptureRuntimeMemStatsOnce(r)
38 - if count := runtimeMetrics.MemStats.PauseNs.Count(); 259 != count-zero {
39 - t.Fatal(count - zero)
40 - }
41 - for i := 0; i < 257; i++ {
42 - runtime.GC()
43 - }
44 - CaptureRuntimeMemStatsOnce(r)
45 - if count := runtimeMetrics.MemStats.PauseNs.Count(); 515 != count-zero { // We lost one because there were too many GCs between captures.
46 - t.Fatal(count - zero)
47 - }
48 -}
49 -
50 -func TestRuntimeMemStatsBlocking(t *testing.T) {
51 - if g := runtime.GOMAXPROCS(0); g < 2 {
52 - t.Skipf("skipping TestRuntimeMemStatsBlocking with GOMAXPROCS=%d\n", g)
53 - }
54 - ch := make(chan int)
55 - go testRuntimeMemStatsBlocking(ch)
56 - var memStats runtime.MemStats
57 - t0 := time.Now()
58 - runtime.ReadMemStats(&memStats)
59 - t1 := time.Now()
60 - t.Log("i++ during runtime.ReadMemStats:", <-ch)
61 - go testRuntimeMemStatsBlocking(ch)
62 - d := t1.Sub(t0)
63 - t.Log(d)
64 - time.Sleep(d)
65 - t.Log("i++ during time.Sleep:", <-ch)
66 -}
67 -
68 -func testRuntimeMemStatsBlocking(ch chan int) {
69 - i := 0
70 - for {
71 - select {
72 - case ch <- i:
73 - return
74 - default:
75 - i++
76 - }
77 - }
78 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/sample.go deleted
-602
@@ -1,602 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "math"
5 - "math/rand"
6 - "sort"
7 - "sync"
8 - "time"
9 -)
10 -
11 -const rescaleThreshold = time.Hour
12 -
13 -// Samples maintain a statistically-significant selection of values from
14 -// a stream.
15 -type Sample interface {
16 - Clear()
17 - Count() int64
18 - Max() int64
19 - Mean() float64
20 - Min() int64
21 - Percentile(float64) float64
22 - Percentiles([]float64) []float64
23 - Size() int
24 - Snapshot() Sample
25 - StdDev() float64
26 - Sum() int64
27 - Update(int64)
28 - Values() []int64
29 - Variance() float64
30 -}
31 -
32 -// ExpDecaySample is an exponentially-decaying sample using a forward-decaying
33 -// priority reservoir. See Cormode et al's "Forward Decay: A Practical Time
34 -// Decay Model for Streaming Systems".
35 -//
36 -// <http://www.research.att.com/people/Cormode_Graham/library/publications/CormodeShkapenyukSrivastavaXu09.pdf>
37 -type ExpDecaySample struct {
38 - alpha float64
39 - count int64
40 - mutex sync.Mutex
41 - reservoirSize int
42 - t0, t1 time.Time
43 - values *expDecaySampleHeap
44 -}
45 -
46 -// NewExpDecaySample constructs a new exponentially-decaying sample with the
47 -// given reservoir size and alpha.
48 -func NewExpDecaySample(reservoirSize int, alpha float64) Sample {
49 - if UseNilMetrics {
50 - return NilSample{}
51 - }
52 - s := &ExpDecaySample{
53 - alpha: alpha,
54 - reservoirSize: reservoirSize,
55 - t0: time.Now(),
56 - values: newExpDecaySampleHeap(reservoirSize),
57 - }
58 - s.t1 = time.Now().Add(rescaleThreshold)
59 - return s
60 -}
61 -
62 -// Clear clears all samples.
63 -func (s *ExpDecaySample) Clear() {
64 - s.mutex.Lock()
65 - defer s.mutex.Unlock()
66 - s.count = 0
67 - s.t0 = time.Now()
68 - s.t1 = s.t0.Add(rescaleThreshold)
69 - s.values = newExpDecaySampleHeap(s.reservoirSize)
70 -}
71 -
72 -// Count returns the number of samples recorded, which may exceed the
73 -// reservoir size.
74 -func (s *ExpDecaySample) Count() int64 {
75 - s.mutex.Lock()
76 - defer s.mutex.Unlock()
77 - return s.count
78 -}
79 -
80 -// Max returns the maximum value in the sample, which may not be the maximum
81 -// value ever to be part of the sample.
82 -func (s *ExpDecaySample) Max() int64 {
83 - return SampleMax(s.Values())
84 -}
85 -
86 -// Mean returns the mean of the values in the sample.
87 -func (s *ExpDecaySample) Mean() float64 {
88 - return SampleMean(s.Values())
89 -}
90 -
91 -// Min returns the minimum value in the sample, which may not be the minimum
92 -// value ever to be part of the sample.
93 -func (s *ExpDecaySample) Min() int64 {
94 - return SampleMin(s.Values())
95 -}
96 -
97 -// Percentile returns an arbitrary percentile of values in the sample.
98 -func (s *ExpDecaySample) Percentile(p float64) float64 {
99 - return SamplePercentile(s.Values(), p)
100 -}
101 -
102 -// Percentiles returns a slice of arbitrary percentiles of values in the
103 -// sample.
104 -func (s *ExpDecaySample) Percentiles(ps []float64) []float64 {
105 - return SamplePercentiles(s.Values(), ps)
106 -}
107 -
108 -// Size returns the size of the sample, which is at most the reservoir size.
109 -func (s *ExpDecaySample) Size() int {
110 - s.mutex.Lock()
111 - defer s.mutex.Unlock()
112 - return s.values.Size()
113 -}
114 -
115 -// Snapshot returns a read-only copy of the sample.
116 -func (s *ExpDecaySample) Snapshot() Sample {
117 - s.mutex.Lock()
118 - defer s.mutex.Unlock()
119 - vals := s.values.Values()
120 - values := make([]int64, len(vals))
121 - for i, v := range vals {
122 - values[i] = v.v
123 - }
124 - return &SampleSnapshot{
125 - count: s.count,
126 - values: values,
127 - }
128 -}
129 -
130 -// StdDev returns the standard deviation of the values in the sample.
131 -func (s *ExpDecaySample) StdDev() float64 {
132 - return SampleStdDev(s.Values())
133 -}
134 -
135 -// Sum returns the sum of the values in the sample.
136 -func (s *ExpDecaySample) Sum() int64 {
137 - return SampleSum(s.Values())
138 -}
139 -
140 -// Update samples a new value.
141 -func (s *ExpDecaySample) Update(v int64) {
142 - s.update(time.Now(), v)
143 -}
144 -
145 -// Values returns a copy of the values in the sample.
146 -func (s *ExpDecaySample) Values() []int64 {
147 - s.mutex.Lock()
148 - defer s.mutex.Unlock()
149 - vals := s.values.Values()
150 - values := make([]int64, len(vals))
151 - for i, v := range vals {
152 - values[i] = v.v
153 - }
154 - return values
155 -}
156 -
157 -// Variance returns the variance of the values in the sample.
158 -func (s *ExpDecaySample) Variance() float64 {
159 - return SampleVariance(s.Values())
160 -}
161 -
162 -// update samples a new value at a particular timestamp. This is a method all
163 -// its own to facilitate testing.
164 -func (s *ExpDecaySample) update(t time.Time, v int64) {
165 - s.mutex.Lock()
166 - defer s.mutex.Unlock()
167 - s.count++
168 - if s.values.Size() == s.reservoirSize {
169 - s.values.Pop()
170 - }
171 - s.values.Push(expDecaySample{
172 - k: math.Exp(t.Sub(s.t0).Seconds()*s.alpha) / rand.Float64(),
173 - v: v,
174 - })
175 - if t.After(s.t1) {
176 - values := s.values.Values()
177 - t0 := s.t0
178 - s.values = newExpDecaySampleHeap(s.reservoirSize)
179 - s.t0 = t
180 - s.t1 = s.t0.Add(rescaleThreshold)
181 - for _, v := range values {
182 - v.k = v.k * math.Exp(-s.alpha*float64(s.t0.Sub(t0)))
183 - s.values.Push(v)
184 - }
185 - }
186 -}
187 -
188 -// NilSample is a no-op Sample.
189 -type NilSample struct{}
190 -
191 -// Clear is a no-op.
192 -func (NilSample) Clear() {}
193 -
194 -// Count is a no-op.
195 -func (NilSample) Count() int64 { return 0 }
196 -
197 -// Max is a no-op.
198 -func (NilSample) Max() int64 { return 0 }
199 -
200 -// Mean is a no-op.
201 -func (NilSample) Mean() float64 { return 0.0 }
202 -
203 -// Min is a no-op.
204 -func (NilSample) Min() int64 { return 0 }
205 -
206 -// Percentile is a no-op.
207 -func (NilSample) Percentile(p float64) float64 { return 0.0 }
208 -
209 -// Percentiles is a no-op.
210 -func (NilSample) Percentiles(ps []float64) []float64 {
211 - return make([]float64, len(ps))
212 -}
213 -
214 -// Size is a no-op.
215 -func (NilSample) Size() int { return 0 }
216 -
217 -// Sample is a no-op.
218 -func (NilSample) Snapshot() Sample { return NilSample{} }
219 -
220 -// StdDev is a no-op.
221 -func (NilSample) StdDev() float64 { return 0.0 }
222 -
223 -// Sum is a no-op.
224 -func (NilSample) Sum() int64 { return 0 }
225 -
226 -// Update is a no-op.
227 -func (NilSample) Update(v int64) {}
228 -
229 -// Values is a no-op.
230 -func (NilSample) Values() []int64 { return []int64{} }
231 -
232 -// Variance is a no-op.
233 -func (NilSample) Variance() float64 { return 0.0 }
234 -
235 -// SampleMax returns the maximum value of the slice of int64.
236 -func SampleMax(values []int64) int64 {
237 - if 0 == len(values) {
238 - return 0
239 - }
240 - var max int64 = math.MinInt64
241 - for _, v := range values {
242 - if max < v {
243 - max = v
244 - }
245 - }
246 - return max
247 -}
248 -
249 -// SampleMean returns the mean value of the slice of int64.
250 -func SampleMean(values []int64) float64 {
251 - if 0 == len(values) {
252 - return 0.0
253 - }
254 - return float64(SampleSum(values)) / float64(len(values))
255 -}
256 -
257 -// SampleMin returns the minimum value of the slice of int64.
258 -func SampleMin(values []int64) int64 {
259 - if 0 == len(values) {
260 - return 0
261 - }
262 - var min int64 = math.MaxInt64
263 - for _, v := range values {
264 - if min > v {
265 - min = v
266 - }
267 - }
268 - return min
269 -}
270 -
271 -// SamplePercentiles returns an arbitrary percentile of the slice of int64.
272 -func SamplePercentile(values int64Slice, p float64) float64 {
273 - return SamplePercentiles(values, []float64{p})[0]
274 -}
275 -
276 -// SamplePercentiles returns a slice of arbitrary percentiles of the slice of
277 -// int64.
278 -func SamplePercentiles(values int64Slice, ps []float64) []float64 {
279 - scores := make([]float64, len(ps))
280 - size := len(values)
281 - if size > 0 {
282 - sort.Sort(values)
283 - for i, p := range ps {
284 - pos := p * float64(size+1)
285 - if pos < 1.0 {
286 - scores[i] = float64(values[0])
287 - } else if pos >= float64(size) {
288 - scores[i] = float64(values[size-1])
289 - } else {
290 - lower := float64(values[int(pos)-1])
291 - upper := float64(values[int(pos)])
292 - scores[i] = lower + (pos-math.Floor(pos))*(upper-lower)
293 - }
294 - }
295 - }
296 - return scores
297 -}
298 -
299 -// SampleSnapshot is a read-only copy of another Sample.
300 -type SampleSnapshot struct {
301 - count int64
302 - values []int64
303 -}
304 -
305 -// Clear panics.
306 -func (*SampleSnapshot) Clear() {
307 - panic("Clear called on a SampleSnapshot")
308 -}
309 -
310 -// Count returns the count of inputs at the time the snapshot was taken.
311 -func (s *SampleSnapshot) Count() int64 { return s.count }
312 -
313 -// Max returns the maximal value at the time the snapshot was taken.
314 -func (s *SampleSnapshot) Max() int64 { return SampleMax(s.values) }
315 -
316 -// Mean returns the mean value at the time the snapshot was taken.
317 -func (s *SampleSnapshot) Mean() float64 { return SampleMean(s.values) }
318 -
319 -// Min returns the minimal value at the time the snapshot was taken.
320 -func (s *SampleSnapshot) Min() int64 { return SampleMin(s.values) }
321 -
322 -// Percentile returns an arbitrary percentile of values at the time the
323 -// snapshot was taken.
324 -func (s *SampleSnapshot) Percentile(p float64) float64 {
325 - return SamplePercentile(s.values, p)
326 -}
327 -
328 -// Percentiles returns a slice of arbitrary percentiles of values at the time
329 -// the snapshot was taken.
330 -func (s *SampleSnapshot) Percentiles(ps []float64) []float64 {
331 - return SamplePercentiles(s.values, ps)
332 -}
333 -
334 -// Size returns the size of the sample at the time the snapshot was taken.
335 -func (s *SampleSnapshot) Size() int { return len(s.values) }
336 -
337 -// Snapshot returns the snapshot.
338 -func (s *SampleSnapshot) Snapshot() Sample { return s }
339 -
340 -// StdDev returns the standard deviation of values at the time the snapshot was
341 -// taken.
342 -func (s *SampleSnapshot) StdDev() float64 { return SampleStdDev(s.values) }
343 -
344 -// Sum returns the sum of values at the time the snapshot was taken.
345 -func (s *SampleSnapshot) Sum() int64 { return SampleSum(s.values) }
346 -
347 -// Update panics.
348 -func (*SampleSnapshot) Update(int64) {
349 - panic("Update called on a SampleSnapshot")
350 -}
351 -
352 -// Values returns a copy of the values in the sample.
353 -func (s *SampleSnapshot) Values() []int64 {
354 - values := make([]int64, len(s.values))
355 - copy(values, s.values)
356 - return values
357 -}
358 -
359 -// Variance returns the variance of values at the time the snapshot was taken.
360 -func (s *SampleSnapshot) Variance() float64 { return SampleVariance(s.values) }
361 -
362 -// SampleStdDev returns the standard deviation of the slice of int64.
363 -func SampleStdDev(values []int64) float64 {
364 - return math.Sqrt(SampleVariance(values))
365 -}
366 -
367 -// SampleSum returns the sum of the slice of int64.
368 -func SampleSum(values []int64) int64 {
369 - var sum int64
370 - for _, v := range values {
371 - sum += v
372 - }
373 - return sum
374 -}
375 -
376 -// SampleVariance returns the variance of the slice of int64.
377 -func SampleVariance(values []int64) float64 {
378 - if 0 == len(values) {
379 - return 0.0
380 - }
381 - m := SampleMean(values)
382 - var sum float64
383 - for _, v := range values {
384 - d := float64(v) - m
385 - sum += d * d
386 - }
387 - return sum / float64(len(values))
388 -}
389 -
390 -// A uniform sample using Vitter's Algorithm R.
391 -//
392 -// <http://www.cs.umd.edu/~samir/498/vitter.pdf>
393 -type UniformSample struct {
394 - count int64
395 - mutex sync.Mutex
396 - reservoirSize int
397 - values []int64
398 -}
399 -
400 -// NewUniformSample constructs a new uniform sample with the given reservoir
401 -// size.
402 -func NewUniformSample(reservoirSize int) Sample {
403 - if UseNilMetrics {
404 - return NilSample{}
405 - }
406 - return &UniformSample{
407 - reservoirSize: reservoirSize,
408 - values: make([]int64, 0, reservoirSize),
409 - }
410 -}
411 -
412 -// Clear clears all samples.
413 -func (s *UniformSample) Clear() {
414 - s.mutex.Lock()
415 - defer s.mutex.Unlock()
416 - s.count = 0
417 - s.values = make([]int64, 0, s.reservoirSize)
418 -}
419 -
420 -// Count returns the number of samples recorded, which may exceed the
421 -// reservoir size.
422 -func (s *UniformSample) Count() int64 {
423 - s.mutex.Lock()
424 - defer s.mutex.Unlock()
425 - return s.count
426 -}
427 -
428 -// Max returns the maximum value in the sample, which may not be the maximum
429 -// value ever to be part of the sample.
430 -func (s *UniformSample) Max() int64 {
431 - s.mutex.Lock()
432 - defer s.mutex.Unlock()
433 - return SampleMax(s.values)
434 -}
435 -
436 -// Mean returns the mean of the values in the sample.
437 -func (s *UniformSample) Mean() float64 {
438 - s.mutex.Lock()
439 - defer s.mutex.Unlock()
440 - return SampleMean(s.values)
441 -}
442 -
443 -// Min returns the minimum value in the sample, which may not be the minimum
444 -// value ever to be part of the sample.
445 -func (s *UniformSample) Min() int64 {
446 - s.mutex.Lock()
447 - defer s.mutex.Unlock()
448 - return SampleMin(s.values)
449 -}
450 -
451 -// Percentile returns an arbitrary percentile of values in the sample.
452 -func (s *UniformSample) Percentile(p float64) float64 {
453 - s.mutex.Lock()
454 - defer s.mutex.Unlock()
455 - return SamplePercentile(s.values, p)
456 -}
457 -
458 -// Percentiles returns a slice of arbitrary percentiles of values in the
459 -// sample.
460 -func (s *UniformSample) Percentiles(ps []float64) []float64 {
461 - s.mutex.Lock()
462 - defer s.mutex.Unlock()
463 - return SamplePercentiles(s.values, ps)
464 -}
465 -
466 -// Size returns the size of the sample, which is at most the reservoir size.
467 -func (s *UniformSample) Size() int {
468 - s.mutex.Lock()
469 - defer s.mutex.Unlock()
470 - return len(s.values)
471 -}
472 -
473 -// Snapshot returns a read-only copy of the sample.
474 -func (s *UniformSample) Snapshot() Sample {
475 - s.mutex.Lock()
476 - defer s.mutex.Unlock()
477 - values := make([]int64, len(s.values))
478 - copy(values, s.values)
479 - return &SampleSnapshot{
480 - count: s.count,
481 - values: values,
482 - }
483 -}
484 -
485 -// StdDev returns the standard deviation of the values in the sample.
486 -func (s *UniformSample) StdDev() float64 {
487 - s.mutex.Lock()
488 - defer s.mutex.Unlock()
489 - return SampleStdDev(s.values)
490 -}
491 -
492 -// Sum returns the sum of the values in the sample.
493 -func (s *UniformSample) Sum() int64 {
494 - s.mutex.Lock()
495 - defer s.mutex.Unlock()
496 - return SampleSum(s.values)
497 -}
498 -
499 -// Update samples a new value.
500 -func (s *UniformSample) Update(v int64) {
501 - s.mutex.Lock()
502 - defer s.mutex.Unlock()
503 - s.count++
504 - if len(s.values) < s.reservoirSize {
505 - s.values = append(s.values, v)
506 - } else {
507 - s.values[rand.Intn(s.reservoirSize)] = v
508 - }
509 -}
510 -
511 -// Values returns a copy of the values in the sample.
512 -func (s *UniformSample) Values() []int64 {
513 - s.mutex.Lock()
514 - defer s.mutex.Unlock()
515 - values := make([]int64, len(s.values))
516 - copy(values, s.values)
517 - return values
518 -}
519 -
520 -// Variance returns the variance of the values in the sample.
521 -func (s *UniformSample) Variance() float64 {
522 - s.mutex.Lock()
523 - defer s.mutex.Unlock()
524 - return SampleVariance(s.values)
525 -}
526 -
527 -// expDecaySample represents an individual sample in a heap.
528 -type expDecaySample struct {
529 - k float64
530 - v int64
531 -}
532 -
533 -func newExpDecaySampleHeap(reservoirSize int) *expDecaySampleHeap {
534 - return &expDecaySampleHeap{make([]expDecaySample, 0, reservoirSize)}
535 -}
536 -
537 -// expDecaySampleHeap is a min-heap of expDecaySamples.
538 -// The internal implementation is copied from the standard library's container/heap
539 -type expDecaySampleHeap struct {
540 - s []expDecaySample
541 -}
542 -
543 -func (h *expDecaySampleHeap) Push(s expDecaySample) {
544 - n := len(h.s)
545 - h.s = h.s[0 : n+1]
546 - h.s[n] = s
547 - h.up(n)
548 -}
549 -
550 -func (h *expDecaySampleHeap) Pop() expDecaySample {
551 - n := len(h.s) - 1
552 - h.s[0], h.s[n] = h.s[n], h.s[0]
553 - h.down(0, n)
554 -
555 - n = len(h.s)
556 - s := h.s[n-1]
557 - h.s = h.s[0 : n-1]
558 - return s
559 -}
560 -
561 -func (h *expDecaySampleHeap) Size() int {
562 - return len(h.s)
563 -}
564 -
565 -func (h *expDecaySampleHeap) Values() []expDecaySample {
566 - return h.s
567 -}
568 -
569 -func (h *expDecaySampleHeap) up(j int) {
570 - for {
571 - i := (j - 1) / 2 // parent
572 - if i == j || !(h.s[j].k < h.s[i].k) {
573 - break
574 - }
575 - h.s[i], h.s[j] = h.s[j], h.s[i]
576 - j = i
577 - }
578 -}
579 -
580 -func (h *expDecaySampleHeap) down(i, n int) {
581 - for {
582 - j1 := 2*i + 1
583 - if j1 >= n || j1 < 0 { // j1 < 0 after int overflow
584 - break
585 - }
586 - j := j1 // left child
587 - if j2 := j1 + 1; j2 < n && !(h.s[j1].k < h.s[j2].k) {
588 - j = j2 // = 2*i + 2 // right child
589 - }
590 - if !(h.s[j].k < h.s[i].k) {
591 - break
592 - }
593 - h.s[i], h.s[j] = h.s[j], h.s[i]
594 - i = j
595 - }
596 -}
597 -
598 -type int64Slice []int64
599 -
600 -func (p int64Slice) Len() int { return len(p) }
601 -func (p int64Slice) Less(i, j int) bool { return p[i] < p[j] }
602 -func (p int64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/sample_test.go deleted
-352
@@ -1,352 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "math/rand"
5 - "runtime"
6 - "testing"
7 - "time"
8 -)
9 -
10 -// Benchmark{Compute,Copy}{1000,1000000} demonstrate that, even for relatively
11 -// expensive computations like Variance, the cost of copying the Sample, as
12 -// approximated by a make and copy, is much greater than the cost of the
13 -// computation for small samples and only slightly less for large samples.
14 -func BenchmarkCompute1000(b *testing.B) {
15 - s := make([]int64, 1000)
16 - for i := 0; i < len(s); i++ {
17 - s[i] = int64(i)
18 - }
19 - b.ResetTimer()
20 - for i := 0; i < b.N; i++ {
21 - SampleVariance(s)
22 - }
23 -}
24 -func BenchmarkCompute1000000(b *testing.B) {
25 - s := make([]int64, 1000000)
26 - for i := 0; i < len(s); i++ {
27 - s[i] = int64(i)
28 - }
29 - b.ResetTimer()
30 - for i := 0; i < b.N; i++ {
31 - SampleVariance(s)
32 - }
33 -}
34 -func BenchmarkCopy1000(b *testing.B) {
35 - s := make([]int64, 1000)
36 - for i := 0; i < len(s); i++ {
37 - s[i] = int64(i)
38 - }
39 - b.ResetTimer()
40 - for i := 0; i < b.N; i++ {
41 - sCopy := make([]int64, len(s))
42 - copy(sCopy, s)
43 - }
44 -}
45 -func BenchmarkCopy1000000(b *testing.B) {
46 - s := make([]int64, 1000000)
47 - for i := 0; i < len(s); i++ {
48 - s[i] = int64(i)
49 - }
50 - b.ResetTimer()
51 - for i := 0; i < b.N; i++ {
52 - sCopy := make([]int64, len(s))
53 - copy(sCopy, s)
54 - }
55 -}
56 -
57 -func BenchmarkExpDecaySample257(b *testing.B) {
58 - benchmarkSample(b, NewExpDecaySample(257, 0.015))
59 -}
60 -
61 -func BenchmarkExpDecaySample514(b *testing.B) {
62 - benchmarkSample(b, NewExpDecaySample(514, 0.015))
63 -}
64 -
65 -func BenchmarkExpDecaySample1028(b *testing.B) {
66 - benchmarkSample(b, NewExpDecaySample(1028, 0.015))
67 -}
68 -
69 -func BenchmarkUniformSample257(b *testing.B) {
70 - benchmarkSample(b, NewUniformSample(257))
71 -}
72 -
73 -func BenchmarkUniformSample514(b *testing.B) {
74 - benchmarkSample(b, NewUniformSample(514))
75 -}
76 -
77 -func BenchmarkUniformSample1028(b *testing.B) {
78 - benchmarkSample(b, NewUniformSample(1028))
79 -}
80 -
81 -func TestExpDecaySample10(t *testing.T) {
82 - rand.Seed(1)
83 - s := NewExpDecaySample(100, 0.99)
84 - for i := 0; i < 10; i++ {
85 - s.Update(int64(i))
86 - }
87 - if size := s.Count(); 10 != size {
88 - t.Errorf("s.Count(): 10 != %v\n", size)
89 - }
90 - if size := s.Size(); 10 != size {
91 - t.Errorf("s.Size(): 10 != %v\n", size)
92 - }
93 - if l := len(s.Values()); 10 != l {
94 - t.Errorf("len(s.Values()): 10 != %v\n", l)
95 - }
96 - for _, v := range s.Values() {
97 - if v > 10 || v < 0 {
98 - t.Errorf("out of range [0, 10): %v\n", v)
99 - }
100 - }
101 -}
102 -
103 -func TestExpDecaySample100(t *testing.T) {
104 - rand.Seed(1)
105 - s := NewExpDecaySample(1000, 0.01)
106 - for i := 0; i < 100; i++ {
107 - s.Update(int64(i))
108 - }
109 - if size := s.Count(); 100 != size {
110 - t.Errorf("s.Count(): 100 != %v\n", size)
111 - }
112 - if size := s.Size(); 100 != size {
113 - t.Errorf("s.Size(): 100 != %v\n", size)
114 - }
115 - if l := len(s.Values()); 100 != l {
116 - t.Errorf("len(s.Values()): 100 != %v\n", l)
117 - }
118 - for _, v := range s.Values() {
119 - if v > 100 || v < 0 {
120 - t.Errorf("out of range [0, 100): %v\n", v)
121 - }
122 - }
123 -}
124 -
125 -func TestExpDecaySample1000(t *testing.T) {
126 - rand.Seed(1)
127 - s := NewExpDecaySample(100, 0.99)
128 - for i := 0; i < 1000; i++ {
129 - s.Update(int64(i))
130 - }
131 - if size := s.Count(); 1000 != size {
132 - t.Errorf("s.Count(): 1000 != %v\n", size)
133 - }
134 - if size := s.Size(); 100 != size {
135 - t.Errorf("s.Size(): 100 != %v\n", size)
136 - }
137 - if l := len(s.Values()); 100 != l {
138 - t.Errorf("len(s.Values()): 100 != %v\n", l)
139 - }
140 - for _, v := range s.Values() {
141 - if v > 1000 || v < 0 {
142 - t.Errorf("out of range [0, 1000): %v\n", v)
143 - }
144 - }
145 -}
146 -
147 -// This test makes sure that the sample's priority is not amplified by using
148 -// nanosecond duration since start rather than second duration since start.
149 -// The priority becomes +Inf quickly after starting if this is done,
150 -// effectively freezing the set of samples until a rescale step happens.
151 -func TestExpDecaySampleNanosecondRegression(t *testing.T) {
152 - rand.Seed(1)
153 - s := NewExpDecaySample(100, 0.99)
154 - for i := 0; i < 100; i++ {
155 - s.Update(10)
156 - }
157 - time.Sleep(1 * time.Millisecond)
158 - for i := 0; i < 100; i++ {
159 - s.Update(20)
160 - }
161 - v := s.Values()
162 - avg := float64(0)
163 - for i := 0; i < len(v); i++ {
164 - avg += float64(v[i])
165 - }
166 - avg /= float64(len(v))
167 - if avg > 16 || avg < 14 {
168 - t.Errorf("out of range [14, 16]: %v\n", avg)
169 - }
170 -}
171 -
172 -func TestExpDecaySampleSnapshot(t *testing.T) {
173 - now := time.Now()
174 - rand.Seed(1)
175 - s := NewExpDecaySample(100, 0.99)
176 - for i := 1; i <= 10000; i++ {
177 - s.(*ExpDecaySample).update(now.Add(time.Duration(i)), int64(i))
178 - }
179 - snapshot := s.Snapshot()
180 - s.Update(1)
181 - testExpDecaySampleStatistics(t, snapshot)
182 -}
183 -
184 -func TestExpDecaySampleStatistics(t *testing.T) {
185 - now := time.Now()
186 - rand.Seed(1)
187 - s := NewExpDecaySample(100, 0.99)
188 - for i := 1; i <= 10000; i++ {
189 - s.(*ExpDecaySample).update(now.Add(time.Duration(i)), int64(i))
190 - }
191 - testExpDecaySampleStatistics(t, s)
192 -}
193 -
194 -func TestUniformSample(t *testing.T) {
195 - rand.Seed(1)
196 - s := NewUniformSample(100)
197 - for i := 0; i < 1000; i++ {
198 - s.Update(int64(i))
199 - }
200 - if size := s.Count(); 1000 != size {
201 - t.Errorf("s.Count(): 1000 != %v\n", size)
202 - }
203 - if size := s.Size(); 100 != size {
204 - t.Errorf("s.Size(): 100 != %v\n", size)
205 - }
206 - if l := len(s.Values()); 100 != l {
207 - t.Errorf("len(s.Values()): 100 != %v\n", l)
208 - }
209 - for _, v := range s.Values() {
210 - if v > 1000 || v < 0 {
211 - t.Errorf("out of range [0, 100): %v\n", v)
212 - }
213 - }
214 -}
215 -
216 -func TestUniformSampleIncludesTail(t *testing.T) {
217 - rand.Seed(1)
218 - s := NewUniformSample(100)
219 - max := 100
220 - for i := 0; i < max; i++ {
221 - s.Update(int64(i))
222 - }
223 - v := s.Values()
224 - sum := 0
225 - exp := (max - 1) * max / 2
226 - for i := 0; i < len(v); i++ {
227 - sum += int(v[i])
228 - }
229 - if exp != sum {
230 - t.Errorf("sum: %v != %v\n", exp, sum)
231 - }
232 -}
233 -
234 -func TestUniformSampleSnapshot(t *testing.T) {
235 - s := NewUniformSample(100)
236 - for i := 1; i <= 10000; i++ {
237 - s.Update(int64(i))
238 - }
239 - snapshot := s.Snapshot()
240 - s.Update(1)
241 - testUniformSampleStatistics(t, snapshot)
242 -}
243 -
244 -func TestUniformSampleStatistics(t *testing.T) {
245 - rand.Seed(1)
246 - s := NewUniformSample(100)
247 - for i := 1; i <= 10000; i++ {
248 - s.Update(int64(i))
249 - }
250 - testUniformSampleStatistics(t, s)
251 -}
252 -
253 -func benchmarkSample(b *testing.B, s Sample) {
254 - var memStats runtime.MemStats
255 - runtime.ReadMemStats(&memStats)
256 - pauseTotalNs := memStats.PauseTotalNs
257 - b.ResetTimer()
258 - for i := 0; i < b.N; i++ {
259 - s.Update(1)
260 - }
261 - b.StopTimer()
262 - runtime.GC()
263 - runtime.ReadMemStats(&memStats)
264 - b.Logf("GC cost: %d ns/op", int(memStats.PauseTotalNs-pauseTotalNs)/b.N)
265 -}
266 -
267 -func testExpDecaySampleStatistics(t *testing.T, s Sample) {
268 - if count := s.Count(); 10000 != count {
269 - t.Errorf("s.Count(): 10000 != %v\n", count)
270 - }
271 - if min := s.Min(); 107 != min {
272 - t.Errorf("s.Min(): 107 != %v\n", min)
273 - }
274 - if max := s.Max(); 10000 != max {
275 - t.Errorf("s.Max(): 10000 != %v\n", max)
276 - }
277 - if mean := s.Mean(); 4965.98 != mean {
278 - t.Errorf("s.Mean(): 4965.98 != %v\n", mean)
279 - }
280 - if stdDev := s.StdDev(); 2959.825156930727 != stdDev {
281 - t.Errorf("s.StdDev(): 2959.825156930727 != %v\n", stdDev)
282 - }
283 - ps := s.Percentiles([]float64{0.5, 0.75, 0.99})
284 - if 4615 != ps[0] {
285 - t.Errorf("median: 4615 != %v\n", ps[0])
286 - }
287 - if 7672 != ps[1] {
288 - t.Errorf("75th percentile: 7672 != %v\n", ps[1])
289 - }
290 - if 9998.99 != ps[2] {
291 - t.Errorf("99th percentile: 9998.99 != %v\n", ps[2])
292 - }
293 -}
294 -
295 -func testUniformSampleStatistics(t *testing.T, s Sample) {
296 - if count := s.Count(); 10000 != count {
297 - t.Errorf("s.Count(): 10000 != %v\n", count)
298 - }
299 - if min := s.Min(); 9412 != min {
300 - t.Errorf("s.Min(): 9412 != %v\n", min)
301 - }
302 - if max := s.Max(); 10000 != max {
303 - t.Errorf("s.Max(): 10000 != %v\n", max)
304 - }
305 - if mean := s.Mean(); 9902.26 != mean {
306 - t.Errorf("s.Mean(): 9902.26 != %v\n", mean)
307 - }
308 - if stdDev := s.StdDev(); 101.8667384380201 != stdDev {
309 - t.Errorf("s.StdDev(): 101.8667384380201 != %v\n", stdDev)
310 - }
311 - ps := s.Percentiles([]float64{0.5, 0.75, 0.99})
312 - if 9930.5 != ps[0] {
313 - t.Errorf("median: 9930.5 != %v\n", ps[0])
314 - }
315 - if 9973.75 != ps[1] {
316 - t.Errorf("75th percentile: 9973.75 != %v\n", ps[1])
317 - }
318 - if 9999.99 != ps[2] {
319 - t.Errorf("99th percentile: 9999.99 != %v\n", ps[2])
320 - }
321 -}
322 -
323 -// TestUniformSampleConcurrentUpdateCount would expose data race problems with
324 -// concurrent Update and Count calls on Sample when test is called with -race
325 -// argument
326 -func TestUniformSampleConcurrentUpdateCount(t *testing.T) {
327 - if testing.Short() {
328 - t.Skip("skipping in short mode")
329 - }
330 - s := NewUniformSample(100)
331 - for i := 0; i < 100; i++ {
332 - s.Update(int64(i))
333 - }
334 - quit := make(chan struct{})
335 - go func() {
336 - t := time.NewTicker(10 * time.Millisecond)
337 - for {
338 - select {
339 - case <-t.C:
340 - s.Update(rand.Int63())
341 - case <-quit:
342 - t.Stop()
343 - return
344 - }
345 - }
346 - }()
347 - for i := 0; i < 1000; i++ {
348 - s.Count()
349 - time.Sleep(5 * time.Millisecond)
350 - }
351 - quit <- struct{}{}
352 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/stathat/stathat.go deleted
-69
@@ -1,69 +0,0 @@
1 -// Metrics output to StatHat.
2 -package stathat
3 -
4 -import (
5 - "github.com/rcrowley/go-metrics"
6 - "github.com/stathat/go"
7 - "log"
8 - "time"
9 -)
10 -
11 -func Stathat(r metrics.Registry, d time.Duration, userkey string) {
12 - for {
13 - if err := sh(r, userkey); nil != err {
14 - log.Println(err)
15 - }
16 - time.Sleep(d)
17 - }
18 -}
19 -
20 -func sh(r metrics.Registry, userkey string) error {
21 - r.Each(func(name string, i interface{}) {
22 - switch metric := i.(type) {
23 - case metrics.Counter:
24 - stathat.PostEZCount(name, userkey, int(metric.Count()))
25 - case metrics.Gauge:
26 - stathat.PostEZValue(name, userkey, float64(metric.Value()))
27 - case metrics.GaugeFloat64:
28 - stathat.PostEZValue(name, userkey, float64(metric.Value()))
29 - case metrics.Histogram:
30 - h := metric.Snapshot()
31 - ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
32 - stathat.PostEZCount(name+".count", userkey, int(h.Count()))
33 - stathat.PostEZValue(name+".min", userkey, float64(h.Min()))
34 - stathat.PostEZValue(name+".max", userkey, float64(h.Max()))
35 - stathat.PostEZValue(name+".mean", userkey, float64(h.Mean()))
36 - stathat.PostEZValue(name+".std-dev", userkey, float64(h.StdDev()))
37 - stathat.PostEZValue(name+".50-percentile", userkey, float64(ps[0]))
38 - stathat.PostEZValue(name+".75-percentile", userkey, float64(ps[1]))
39 - stathat.PostEZValue(name+".95-percentile", userkey, float64(ps[2]))
40 - stathat.PostEZValue(name+".99-percentile", userkey, float64(ps[3]))
41 - stathat.PostEZValue(name+".999-percentile", userkey, float64(ps[4]))
42 - case metrics.Meter:
43 - m := metric.Snapshot()
44 - stathat.PostEZCount(name+".count", userkey, int(m.Count()))
45 - stathat.PostEZValue(name+".one-minute", userkey, float64(m.Rate1()))
46 - stathat.PostEZValue(name+".five-minute", userkey, float64(m.Rate5()))
47 - stathat.PostEZValue(name+".fifteen-minute", userkey, float64(m.Rate15()))
48 - stathat.PostEZValue(name+".mean", userkey, float64(m.RateMean()))
49 - case metrics.Timer:
50 - t := metric.Snapshot()
51 - ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
52 - stathat.PostEZCount(name+".count", userkey, int(t.Count()))
53 - stathat.PostEZValue(name+".min", userkey, float64(t.Min()))
54 - stathat.PostEZValue(name+".max", userkey, float64(t.Max()))
55 - stathat.PostEZValue(name+".mean", userkey, float64(t.Mean()))
56 - stathat.PostEZValue(name+".std-dev", userkey, float64(t.StdDev()))
57 - stathat.PostEZValue(name+".50-percentile", userkey, float64(ps[0]))
58 - stathat.PostEZValue(name+".75-percentile", userkey, float64(ps[1]))
59 - stathat.PostEZValue(name+".95-percentile", userkey, float64(ps[2]))
60 - stathat.PostEZValue(name+".99-percentile", userkey, float64(ps[3]))
61 - stathat.PostEZValue(name+".999-percentile", userkey, float64(ps[4]))
62 - stathat.PostEZValue(name+".one-minute", userkey, float64(t.Rate1()))
63 - stathat.PostEZValue(name+".five-minute", userkey, float64(t.Rate5()))
64 - stathat.PostEZValue(name+".fifteen-minute", userkey, float64(t.Rate15()))
65 - stathat.PostEZValue(name+".mean-rate", userkey, float64(t.RateMean()))
66 - }
67 - })
68 - return nil
69 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/syslog.go deleted
-78
@@ -1,78 +0,0 @@
1 -// +build !windows
2 -
3 -package metrics
4 -
5 -import (
6 - "fmt"
7 - "log/syslog"
8 - "time"
9 -)
10 -
11 -// Output each metric in the given registry to syslog periodically using
12 -// the given syslogger.
13 -func Syslog(r Registry, d time.Duration, w *syslog.Writer) {
14 - for _ = range time.Tick(d) {
15 - r.Each(func(name string, i interface{}) {
16 - switch metric := i.(type) {
17 - case Counter:
18 - w.Info(fmt.Sprintf("counter %s: count: %d", name, metric.Count()))
19 - case Gauge:
20 - w.Info(fmt.Sprintf("gauge %s: value: %d", name, metric.Value()))
21 - case GaugeFloat64:
22 - w.Info(fmt.Sprintf("gauge %s: value: %f", name, metric.Value()))
23 - case Healthcheck:
24 - metric.Check()
25 - w.Info(fmt.Sprintf("healthcheck %s: error: %v", name, metric.Error()))
26 - case Histogram:
27 - h := metric.Snapshot()
28 - ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
29 - w.Info(fmt.Sprintf(
30 - "histogram %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f",
31 - name,
32 - h.Count(),
33 - h.Min(),
34 - h.Max(),
35 - h.Mean(),
36 - h.StdDev(),
37 - ps[0],
38 - ps[1],
39 - ps[2],
40 - ps[3],
41 - ps[4],
42 - ))
43 - case Meter:
44 - m := metric.Snapshot()
45 - w.Info(fmt.Sprintf(
46 - "meter %s: count: %d 1-min: %.2f 5-min: %.2f 15-min: %.2f mean: %.2f",
47 - name,
48 - m.Count(),
49 - m.Rate1(),
50 - m.Rate5(),
51 - m.Rate15(),
52 - m.RateMean(),
53 - ))
54 - case Timer:
55 - t := metric.Snapshot()
56 - ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
57 - w.Info(fmt.Sprintf(
58 - "timer %s: count: %d min: %d max: %d mean: %.2f stddev: %.2f median: %.2f 75%%: %.2f 95%%: %.2f 99%%: %.2f 99.9%%: %.2f 1-min: %.2f 5-min: %.2f 15-min: %.2f mean-rate: %.2f",
59 - name,
60 - t.Count(),
61 - t.Min(),
62 - t.Max(),
63 - t.Mean(),
64 - t.StdDev(),
65 - ps[0],
66 - ps[1],
67 - ps[2],
68 - ps[3],
69 - ps[4],
70 - t.Rate1(),
71 - t.Rate5(),
72 - t.Rate15(),
73 - t.RateMean(),
74 - ))
75 - }
76 - })
77 - }
78 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/timer.go deleted
-311
@@ -1,311 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "sync"
5 - "time"
6 -)
7 -
8 -// Timers capture the duration and rate of events.
9 -type Timer interface {
10 - Count() int64
11 - Max() int64
12 - Mean() float64
13 - Min() int64
14 - Percentile(float64) float64
15 - Percentiles([]float64) []float64
16 - Rate1() float64
17 - Rate5() float64
18 - Rate15() float64
19 - RateMean() float64
20 - Snapshot() Timer
21 - StdDev() float64
22 - Sum() int64
23 - Time(func())
24 - Update(time.Duration)
25 - UpdateSince(time.Time)
26 - Variance() float64
27 -}
28 -
29 -// GetOrRegisterTimer returns an existing Timer or constructs and registers a
30 -// new StandardTimer.
31 -func GetOrRegisterTimer(name string, r Registry) Timer {
32 - if nil == r {
33 - r = DefaultRegistry
34 - }
35 - return r.GetOrRegister(name, NewTimer).(Timer)
36 -}
37 -
38 -// NewCustomTimer constructs a new StandardTimer from a Histogram and a Meter.
39 -func NewCustomTimer(h Histogram, m Meter) Timer {
40 - if UseNilMetrics {
41 - return NilTimer{}
42 - }
43 - return &StandardTimer{
44 - histogram: h,
45 - meter: m,
46 - }
47 -}
48 -
49 -// NewRegisteredTimer constructs and registers a new StandardTimer.
50 -func NewRegisteredTimer(name string, r Registry) Timer {
51 - c := NewTimer()
52 - if nil == r {
53 - r = DefaultRegistry
54 - }
55 - r.Register(name, c)
56 - return c
57 -}
58 -
59 -// NewTimer constructs a new StandardTimer using an exponentially-decaying
60 -// sample with the same reservoir size and alpha as UNIX load averages.
61 -func NewTimer() Timer {
62 - if UseNilMetrics {
63 - return NilTimer{}
64 - }
65 - return &StandardTimer{
66 - histogram: NewHistogram(NewExpDecaySample(1028, 0.015)),
67 - meter: NewMeter(),
68 - }
69 -}
70 -
71 -// NilTimer is a no-op Timer.
72 -type NilTimer struct {
73 - h Histogram
74 - m Meter
75 -}
76 -
77 -// Count is a no-op.
78 -func (NilTimer) Count() int64 { return 0 }
79 -
80 -// Max is a no-op.
81 -func (NilTimer) Max() int64 { return 0 }
82 -
83 -// Mean is a no-op.
84 -func (NilTimer) Mean() float64 { return 0.0 }
85 -
86 -// Min is a no-op.
87 -func (NilTimer) Min() int64 { return 0 }
88 -
89 -// Percentile is a no-op.
90 -func (NilTimer) Percentile(p float64) float64 { return 0.0 }
91 -
92 -// Percentiles is a no-op.
93 -func (NilTimer) Percentiles(ps []float64) []float64 {
94 - return make([]float64, len(ps))
95 -}
96 -
97 -// Rate1 is a no-op.
98 -func (NilTimer) Rate1() float64 { return 0.0 }
99 -
100 -// Rate5 is a no-op.
101 -func (NilTimer) Rate5() float64 { return 0.0 }
102 -
103 -// Rate15 is a no-op.
104 -func (NilTimer) Rate15() float64 { return 0.0 }
105 -
106 -// RateMean is a no-op.
107 -func (NilTimer) RateMean() float64 { return 0.0 }
108 -
109 -// Snapshot is a no-op.
110 -func (NilTimer) Snapshot() Timer { return NilTimer{} }
111 -
112 -// StdDev is a no-op.
113 -func (NilTimer) StdDev() float64 { return 0.0 }
114 -
115 -// Sum is a no-op.
116 -func (NilTimer) Sum() int64 { return 0 }
117 -
118 -// Time is a no-op.
119 -func (NilTimer) Time(func()) {}
120 -
121 -// Update is a no-op.
122 -func (NilTimer) Update(time.Duration) {}
123 -
124 -// UpdateSince is a no-op.
125 -func (NilTimer) UpdateSince(time.Time) {}
126 -
127 -// Variance is a no-op.
128 -func (NilTimer) Variance() float64 { return 0.0 }
129 -
130 -// StandardTimer is the standard implementation of a Timer and uses a Histogram
131 -// and Meter.
132 -type StandardTimer struct {
133 - histogram Histogram
134 - meter Meter
135 - mutex sync.Mutex
136 -}
137 -
138 -// Count returns the number of events recorded.
139 -func (t *StandardTimer) Count() int64 {
140 - return t.histogram.Count()
141 -}
142 -
143 -// Max returns the maximum value in the sample.
144 -func (t *StandardTimer) Max() int64 {
145 - return t.histogram.Max()
146 -}
147 -
148 -// Mean returns the mean of the values in the sample.
149 -func (t *StandardTimer) Mean() float64 {
150 - return t.histogram.Mean()
151 -}
152 -
153 -// Min returns the minimum value in the sample.
154 -func (t *StandardTimer) Min() int64 {
155 - return t.histogram.Min()
156 -}
157 -
158 -// Percentile returns an arbitrary percentile of the values in the sample.
159 -func (t *StandardTimer) Percentile(p float64) float64 {
160 - return t.histogram.Percentile(p)
161 -}
162 -
163 -// Percentiles returns a slice of arbitrary percentiles of the values in the
164 -// sample.
165 -func (t *StandardTimer) Percentiles(ps []float64) []float64 {
166 - return t.histogram.Percentiles(ps)
167 -}
168 -
169 -// Rate1 returns the one-minute moving average rate of events per second.
170 -func (t *StandardTimer) Rate1() float64 {
171 - return t.meter.Rate1()
172 -}
173 -
174 -// Rate5 returns the five-minute moving average rate of events per second.
175 -func (t *StandardTimer) Rate5() float64 {
176 - return t.meter.Rate5()
177 -}
178 -
179 -// Rate15 returns the fifteen-minute moving average rate of events per second.
180 -func (t *StandardTimer) Rate15() float64 {
181 - return t.meter.Rate15()
182 -}
183 -
184 -// RateMean returns the meter's mean rate of events per second.
185 -func (t *StandardTimer) RateMean() float64 {
186 - return t.meter.RateMean()
187 -}
188 -
189 -// Snapshot returns a read-only copy of the timer.
190 -func (t *StandardTimer) Snapshot() Timer {
191 - t.mutex.Lock()
192 - defer t.mutex.Unlock()
193 - return &TimerSnapshot{
194 - histogram: t.histogram.Snapshot().(*HistogramSnapshot),
195 - meter: t.meter.Snapshot().(*MeterSnapshot),
196 - }
197 -}
198 -
199 -// StdDev returns the standard deviation of the values in the sample.
200 -func (t *StandardTimer) StdDev() float64 {
201 - return t.histogram.StdDev()
202 -}
203 -
204 -// Sum returns the sum in the sample.
205 -func (t *StandardTimer) Sum() int64 {
206 - return t.histogram.Sum()
207 -}
208 -
209 -// Record the duration of the execution of the given function.
210 -func (t *StandardTimer) Time(f func()) {
211 - ts := time.Now()
212 - f()
213 - t.Update(time.Since(ts))
214 -}
215 -
216 -// Record the duration of an event.
217 -func (t *StandardTimer) Update(d time.Duration) {
218 - t.mutex.Lock()
219 - defer t.mutex.Unlock()
220 - t.histogram.Update(int64(d))
221 - t.meter.Mark(1)
222 -}
223 -
224 -// Record the duration of an event that started at a time and ends now.
225 -func (t *StandardTimer) UpdateSince(ts time.Time) {
226 - t.mutex.Lock()
227 - defer t.mutex.Unlock()
228 - t.histogram.Update(int64(time.Since(ts)))
229 - t.meter.Mark(1)
230 -}
231 -
232 -// Variance returns the variance of the values in the sample.
233 -func (t *StandardTimer) Variance() float64 {
234 - return t.histogram.Variance()
235 -}
236 -
237 -// TimerSnapshot is a read-only copy of another Timer.
238 -type TimerSnapshot struct {
239 - histogram *HistogramSnapshot
240 - meter *MeterSnapshot
241 -}
242 -
243 -// Count returns the number of events recorded at the time the snapshot was
244 -// taken.
245 -func (t *TimerSnapshot) Count() int64 { return t.histogram.Count() }
246 -
247 -// Max returns the maximum value at the time the snapshot was taken.
248 -func (t *TimerSnapshot) Max() int64 { return t.histogram.Max() }
249 -
250 -// Mean returns the mean value at the time the snapshot was taken.
251 -func (t *TimerSnapshot) Mean() float64 { return t.histogram.Mean() }
252 -
253 -// Min returns the minimum value at the time the snapshot was taken.
254 -func (t *TimerSnapshot) Min() int64 { return t.histogram.Min() }
255 -
256 -// Percentile returns an arbitrary percentile of sampled values at the time the
257 -// snapshot was taken.
258 -func (t *TimerSnapshot) Percentile(p float64) float64 {
259 - return t.histogram.Percentile(p)
260 -}
261 -
262 -// Percentiles returns a slice of arbitrary percentiles of sampled values at
263 -// the time the snapshot was taken.
264 -func (t *TimerSnapshot) Percentiles(ps []float64) []float64 {
265 - return t.histogram.Percentiles(ps)
266 -}
267 -
268 -// Rate1 returns the one-minute moving average rate of events per second at the
269 -// time the snapshot was taken.
270 -func (t *TimerSnapshot) Rate1() float64 { return t.meter.Rate1() }
271 -
272 -// Rate5 returns the five-minute moving average rate of events per second at
273 -// the time the snapshot was taken.
274 -func (t *TimerSnapshot) Rate5() float64 { return t.meter.Rate5() }
275 -
276 -// Rate15 returns the fifteen-minute moving average rate of events per second
277 -// at the time the snapshot was taken.
278 -func (t *TimerSnapshot) Rate15() float64 { return t.meter.Rate15() }
279 -
280 -// RateMean returns the meter's mean rate of events per second at the time the
281 -// snapshot was taken.
282 -func (t *TimerSnapshot) RateMean() float64 { return t.meter.RateMean() }
283 -
284 -// Snapshot returns the snapshot.
285 -func (t *TimerSnapshot) Snapshot() Timer { return t }
286 -
287 -// StdDev returns the standard deviation of the values at the time the snapshot
288 -// was taken.
289 -func (t *TimerSnapshot) StdDev() float64 { return t.histogram.StdDev() }
290 -
291 -// Sum returns the sum at the time the snapshot was taken.
292 -func (t *TimerSnapshot) Sum() int64 { return t.histogram.Sum() }
293 -
294 -// Time panics.
295 -func (*TimerSnapshot) Time(func()) {
296 - panic("Time called on a TimerSnapshot")
297 -}
298 -
299 -// Update panics.
300 -func (*TimerSnapshot) Update(time.Duration) {
301 - panic("Update called on a TimerSnapshot")
302 -}
303 -
304 -// UpdateSince panics.
305 -func (*TimerSnapshot) UpdateSince(time.Time) {
306 - panic("UpdateSince called on a TimerSnapshot")
307 -}
308 -
309 -// Variance returns the variance of the values at the time the snapshot was
310 -// taken.
311 -func (t *TimerSnapshot) Variance() float64 { return t.histogram.Variance() }
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/timer_test.go deleted
-81
@@ -1,81 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "math"
5 - "testing"
6 - "time"
7 -)
8 -
9 -func BenchmarkTimer(b *testing.B) {
10 - tm := NewTimer()
11 - b.ResetTimer()
12 - for i := 0; i < b.N; i++ {
13 - tm.Update(1)
14 - }
15 -}
16 -
17 -func TestGetOrRegisterTimer(t *testing.T) {
18 - r := NewRegistry()
19 - NewRegisteredTimer("foo", r).Update(47)
20 - if tm := GetOrRegisterTimer("foo", r); 1 != tm.Count() {
21 - t.Fatal(tm)
22 - }
23 -}
24 -
25 -func TestTimerExtremes(t *testing.T) {
26 - tm := NewTimer()
27 - tm.Update(math.MaxInt64)
28 - tm.Update(0)
29 - if stdDev := tm.StdDev(); 4.611686018427388e+18 != stdDev {
30 - t.Errorf("tm.StdDev(): 4.611686018427388e+18 != %v\n", stdDev)
31 - }
32 -}
33 -
34 -func TestTimerFunc(t *testing.T) {
35 - tm := NewTimer()
36 - tm.Time(func() { time.Sleep(50e6) })
37 - if max := tm.Max(); 45e6 > max || max > 55e6 {
38 - t.Errorf("tm.Max(): 45e6 > %v || %v > 55e6\n", max, max)
39 - }
40 -}
41 -
42 -func TestTimerZero(t *testing.T) {
43 - tm := NewTimer()
44 - if count := tm.Count(); 0 != count {
45 - t.Errorf("tm.Count(): 0 != %v\n", count)
46 - }
47 - if min := tm.Min(); 0 != min {
48 - t.Errorf("tm.Min(): 0 != %v\n", min)
49 - }
50 - if max := tm.Max(); 0 != max {
51 - t.Errorf("tm.Max(): 0 != %v\n", max)
52 - }
53 - if mean := tm.Mean(); 0.0 != mean {
54 - t.Errorf("tm.Mean(): 0.0 != %v\n", mean)
55 - }
56 - if stdDev := tm.StdDev(); 0.0 != stdDev {
57 - t.Errorf("tm.StdDev(): 0.0 != %v\n", stdDev)
58 - }
59 - ps := tm.Percentiles([]float64{0.5, 0.75, 0.99})
60 - if 0.0 != ps[0] {
61 - t.Errorf("median: 0.0 != %v\n", ps[0])
62 - }
63 - if 0.0 != ps[1] {
64 - t.Errorf("75th percentile: 0.0 != %v\n", ps[1])
65 - }
66 - if 0.0 != ps[2] {
67 - t.Errorf("99th percentile: 0.0 != %v\n", ps[2])
68 - }
69 - if rate1 := tm.Rate1(); 0.0 != rate1 {
70 - t.Errorf("tm.Rate1(): 0.0 != %v\n", rate1)
71 - }
72 - if rate5 := tm.Rate5(); 0.0 != rate5 {
73 - t.Errorf("tm.Rate5(): 0.0 != %v\n", rate5)
74 - }
75 - if rate15 := tm.Rate15(); 0.0 != rate15 {
76 - t.Errorf("tm.Rate15(): 0.0 != %v\n", rate15)
77 - }
78 - if rateMean := tm.RateMean(); 0.0 != rateMean {
79 - t.Errorf("tm.RateMean(): 0.0 != %v\n", rateMean)
80 - }
81 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/writer.go deleted
-100
@@ -1,100 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "fmt"
5 - "io"
6 - "sort"
7 - "time"
8 -)
9 -
10 -// Write sorts writes each metric in the given registry periodically to the
11 -// given io.Writer.
12 -func Write(r Registry, d time.Duration, w io.Writer) {
13 - for _ = range time.Tick(d) {
14 - WriteOnce(r, w)
15 - }
16 -}
17 -
18 -// WriteOnce sorts and writes metrics in the given registry to the given
19 -// io.Writer.
20 -func WriteOnce(r Registry, w io.Writer) {
21 - var namedMetrics namedMetricSlice
22 - r.Each(func(name string, i interface{}) {
23 - namedMetrics = append(namedMetrics, namedMetric{name, i})
24 - })
25 -
26 - sort.Sort(namedMetrics)
27 - for _, namedMetric := range namedMetrics {
28 - switch metric := namedMetric.m.(type) {
29 - case Counter:
30 - fmt.Fprintf(w, "counter %s\n", namedMetric.name)
31 - fmt.Fprintf(w, " count: %9d\n", metric.Count())
32 - case Gauge:
33 - fmt.Fprintf(w, "gauge %s\n", namedMetric.name)
34 - fmt.Fprintf(w, " value: %9d\n", metric.Value())
35 - case GaugeFloat64:
36 - fmt.Fprintf(w, "gauge %s\n", namedMetric.name)
37 - fmt.Fprintf(w, " value: %f\n", metric.Value())
38 - case Healthcheck:
39 - metric.Check()
40 - fmt.Fprintf(w, "healthcheck %s\n", namedMetric.name)
41 - fmt.Fprintf(w, " error: %v\n", metric.Error())
42 - case Histogram:
43 - h := metric.Snapshot()
44 - ps := h.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
45 - fmt.Fprintf(w, "histogram %s\n", namedMetric.name)
46 - fmt.Fprintf(w, " count: %9d\n", h.Count())
47 - fmt.Fprintf(w, " min: %9d\n", h.Min())
48 - fmt.Fprintf(w, " max: %9d\n", h.Max())
49 - fmt.Fprintf(w, " mean: %12.2f\n", h.Mean())
50 - fmt.Fprintf(w, " stddev: %12.2f\n", h.StdDev())
51 - fmt.Fprintf(w, " median: %12.2f\n", ps[0])
52 - fmt.Fprintf(w, " 75%%: %12.2f\n", ps[1])
53 - fmt.Fprintf(w, " 95%%: %12.2f\n", ps[2])
54 - fmt.Fprintf(w, " 99%%: %12.2f\n", ps[3])
55 - fmt.Fprintf(w, " 99.9%%: %12.2f\n", ps[4])
56 - case Meter:
57 - m := metric.Snapshot()
58 - fmt.Fprintf(w, "meter %s\n", namedMetric.name)
59 - fmt.Fprintf(w, " count: %9d\n", m.Count())
60 - fmt.Fprintf(w, " 1-min rate: %12.2f\n", m.Rate1())
61 - fmt.Fprintf(w, " 5-min rate: %12.2f\n", m.Rate5())
62 - fmt.Fprintf(w, " 15-min rate: %12.2f\n", m.Rate15())
63 - fmt.Fprintf(w, " mean rate: %12.2f\n", m.RateMean())
64 - case Timer:
65 - t := metric.Snapshot()
66 - ps := t.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999})
67 - fmt.Fprintf(w, "timer %s\n", namedMetric.name)
68 - fmt.Fprintf(w, " count: %9d\n", t.Count())
69 - fmt.Fprintf(w, " min: %9d\n", t.Min())
70 - fmt.Fprintf(w, " max: %9d\n", t.Max())
71 - fmt.Fprintf(w, " mean: %12.2f\n", t.Mean())
72 - fmt.Fprintf(w, " stddev: %12.2f\n", t.StdDev())
73 - fmt.Fprintf(w, " median: %12.2f\n", ps[0])
74 - fmt.Fprintf(w, " 75%%: %12.2f\n", ps[1])
75 - fmt.Fprintf(w, " 95%%: %12.2f\n", ps[2])
76 - fmt.Fprintf(w, " 99%%: %12.2f\n", ps[3])
77 - fmt.Fprintf(w, " 99.9%%: %12.2f\n", ps[4])
78 - fmt.Fprintf(w, " 1-min rate: %12.2f\n", t.Rate1())
79 - fmt.Fprintf(w, " 5-min rate: %12.2f\n", t.Rate5())
80 - fmt.Fprintf(w, " 15-min rate: %12.2f\n", t.Rate15())
81 - fmt.Fprintf(w, " mean rate: %12.2f\n", t.RateMean())
82 - }
83 - }
84 -}
85 -
86 -type namedMetric struct {
87 - name string
88 - m interface{}
89 -}
90 -
91 -// namedMetricSlice is a slice of namedMetrics that implements sort.Interface.
92 -type namedMetricSlice []namedMetric
93 -
94 -func (nms namedMetricSlice) Len() int { return len(nms) }
95 -
96 -func (nms namedMetricSlice) Swap(i, j int) { nms[i], nms[j] = nms[j], nms[i] }
97 -
98 -func (nms namedMetricSlice) Less(i, j int) bool {
99 - return nms[i].name < nms[j].name
100 -}
Godeps/_workspace/src/github.com/whyrusleeping/go-metrics/writer_test.go deleted
-22
@@ -1,22 +0,0 @@
1 -package metrics
2 -
3 -import (
4 - "sort"
5 - "testing"
6 -)
7 -
8 -func TestMetricsSorting(t *testing.T) {
9 - var namedMetrics = namedMetricSlice{
10 - {name: "zzz"},
11 - {name: "bbb"},
12 - {name: "fff"},
13 - {name: "ggg"},
14 - }
15 -
16 - sort.Sort(namedMetrics)
17 - for i, name := range []string{"bbb", "fff", "ggg", "zzz"} {
18 - if namedMetrics[i].name != name {
19 - t.Fail()
20 - }
21 - }
22 -}
Godeps/_workspace/src/golang.org/x/crypto/blowfish/block.go deleted
-159
@@ -1,159 +0,0 @@
1 -// Copyright 2010 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package blowfish
6 -
7 -// getNextWord returns the next big-endian uint32 value from the byte slice
8 -// at the given position in a circular manner, updating the position.
9 -func getNextWord(b []byte, pos *int) uint32 {
10 - var w uint32
11 - j := *pos
12 - for i := 0; i < 4; i++ {
13 - w = w<<8 | uint32(b[j])
14 - j++
15 - if j >= len(b) {
16 - j = 0
17 - }
18 - }
19 - *pos = j
20 - return w
21 -}
22 -
23 -// ExpandKey performs a key expansion on the given *Cipher. Specifically, it
24 -// performs the Blowfish algorithm's key schedule which sets up the *Cipher's
25 -// pi and substitution tables for calls to Encrypt. This is used, primarily,
26 -// by the bcrypt package to reuse the Blowfish key schedule during its
27 -// set up. It's unlikely that you need to use this directly.
28 -func ExpandKey(key []byte, c *Cipher) {
29 - j := 0
30 - for i := 0; i < 18; i++ {
31 - // Using inlined getNextWord for performance.
32 - var d uint32
33 - for k := 0; k < 4; k++ {
34 - d = d<<8 | uint32(key[j])
35 - j++
36 - if j >= len(key) {
37 - j = 0
38 - }
39 - }
40 - c.p[i] ^= d
41 - }
42 -
43 - var l, r uint32
44 - for i := 0; i < 18; i += 2 {
45 - l, r = encryptBlock(l, r, c)
46 - c.p[i], c.p[i+1] = l, r
47 - }
48 -
49 - for i := 0; i < 256; i += 2 {
50 - l, r = encryptBlock(l, r, c)
51 - c.s0[i], c.s0[i+1] = l, r
52 - }
53 - for i := 0; i < 256; i += 2 {
54 - l, r = encryptBlock(l, r, c)
55 - c.s1[i], c.s1[i+1] = l, r
56 - }
57 - for i := 0; i < 256; i += 2 {
58 - l, r = encryptBlock(l, r, c)
59 - c.s2[i], c.s2[i+1] = l, r
60 - }
61 - for i := 0; i < 256; i += 2 {
62 - l, r = encryptBlock(l, r, c)
63 - c.s3[i], c.s3[i+1] = l, r
64 - }
65 -}
66 -
67 -// This is similar to ExpandKey, but folds the salt during the key
68 -// schedule. While ExpandKey is essentially expandKeyWithSalt with an all-zero
69 -// salt passed in, reusing ExpandKey turns out to be a place of inefficiency
70 -// and specializing it here is useful.
71 -func expandKeyWithSalt(key []byte, salt []byte, c *Cipher) {
72 - j := 0
73 - for i := 0; i < 18; i++ {
74 - c.p[i] ^= getNextWord(key, &j)
75 - }
76 -
77 - j = 0
78 - var l, r uint32
79 - for i := 0; i < 18; i += 2 {
80 - l ^= getNextWord(salt, &j)
81 - r ^= getNextWord(salt, &j)
82 - l, r = encryptBlock(l, r, c)
83 - c.p[i], c.p[i+1] = l, r
84 - }
85 -
86 - for i := 0; i < 256; i += 2 {
87 - l ^= getNextWord(salt, &j)
88 - r ^= getNextWord(salt, &j)
89 - l, r = encryptBlock(l, r, c)
90 - c.s0[i], c.s0[i+1] = l, r
91 - }
92 -
93 - for i := 0; i < 256; i += 2 {
94 - l ^= getNextWord(salt, &j)
95 - r ^= getNextWord(salt, &j)
96 - l, r = encryptBlock(l, r, c)
97 - c.s1[i], c.s1[i+1] = l, r
98 - }
99 -
100 - for i := 0; i < 256; i += 2 {
101 - l ^= getNextWord(salt, &j)
102 - r ^= getNextWord(salt, &j)
103 - l, r = encryptBlock(l, r, c)
104 - c.s2[i], c.s2[i+1] = l, r
105 - }
106 -
107 - for i := 0; i < 256; i += 2 {
108 - l ^= getNextWord(salt, &j)
109 - r ^= getNextWord(salt, &j)
110 - l, r = encryptBlock(l, r, c)
111 - c.s3[i], c.s3[i+1] = l, r
112 - }
113 -}
114 -
115 -func encryptBlock(l, r uint32, c *Cipher) (uint32, uint32) {
116 - xl, xr := l, r
117 - xl ^= c.p[0]
118 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[1]
119 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[2]
120 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[3]
121 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[4]
122 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[5]
123 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[6]
124 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[7]
125 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[8]
126 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[9]
127 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[10]
128 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[11]
129 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[12]
130 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[13]
131 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[14]
132 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[15]
133 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[16]
134 - xr ^= c.p[17]
135 - return xr, xl
136 -}
137 -
138 -func decryptBlock(l, r uint32, c *Cipher) (uint32, uint32) {
139 - xl, xr := l, r
140 - xl ^= c.p[17]
141 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[16]
142 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[15]
143 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[14]
144 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[13]
145 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[12]
146 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[11]
147 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[10]
148 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[9]
149 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[8]
150 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[7]
151 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[6]
152 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[5]
153 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[4]
154 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[3]
155 - xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[2]
156 - xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[1]
157 - xr ^= c.p[0]
158 - return xr, xl
159 -}
Godeps/_workspace/src/golang.org/x/crypto/blowfish/blowfish_test.go deleted
-274
@@ -1,274 +0,0 @@
1 -// Copyright 2010 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package blowfish
6 -
7 -import "testing"
8 -
9 -type CryptTest struct {
10 - key []byte
11 - in []byte
12 - out []byte
13 -}
14 -
15 -// Test vector values are from http://www.schneier.com/code/vectors.txt.
16 -var encryptTests = []CryptTest{
17 - {
18 - []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
19 - []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
20 - []byte{0x4E, 0xF9, 0x97, 0x45, 0x61, 0x98, 0xDD, 0x78}},
21 - {
22 - []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
23 - []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
24 - []byte{0x51, 0x86, 0x6F, 0xD5, 0xB8, 0x5E, 0xCB, 0x8A}},
25 - {
26 - []byte{0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
27 - []byte{0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
28 - []byte{0x7D, 0x85, 0x6F, 0x9A, 0x61, 0x30, 0x63, 0xF2}},
29 - {
30 - []byte{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
31 - []byte{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
32 - []byte{0x24, 0x66, 0xDD, 0x87, 0x8B, 0x96, 0x3C, 0x9D}},
33 -
34 - {
35 - []byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
36 - []byte{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
37 - []byte{0x61, 0xF9, 0xC3, 0x80, 0x22, 0x81, 0xB0, 0x96}},
38 - {
39 - []byte{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11},
40 - []byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
41 - []byte{0x7D, 0x0C, 0xC6, 0x30, 0xAF, 0xDA, 0x1E, 0xC7}},
42 - {
43 - []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
44 - []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
45 - []byte{0x4E, 0xF9, 0x97, 0x45, 0x61, 0x98, 0xDD, 0x78}},
46 - {
47 - []byte{0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10},
48 - []byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
49 - []byte{0x0A, 0xCE, 0xAB, 0x0F, 0xC6, 0xA0, 0xA2, 0x8D}},
50 - {
51 - []byte{0x7C, 0xA1, 0x10, 0x45, 0x4A, 0x1A, 0x6E, 0x57},
52 - []byte{0x01, 0xA1, 0xD6, 0xD0, 0x39, 0x77, 0x67, 0x42},
53 - []byte{0x59, 0xC6, 0x82, 0x45, 0xEB, 0x05, 0x28, 0x2B}},
54 - {
55 - []byte{0x01, 0x31, 0xD9, 0x61, 0x9D, 0xC1, 0x37, 0x6E},
56 - []byte{0x5C, 0xD5, 0x4C, 0xA8, 0x3D, 0xEF, 0x57, 0xDA},
57 - []byte{0xB1, 0xB8, 0xCC, 0x0B, 0x25, 0x0F, 0x09, 0xA0}},
58 - {
59 - []byte{0x07, 0xA1, 0x13, 0x3E, 0x4A, 0x0B, 0x26, 0x86},
60 - []byte{0x02, 0x48, 0xD4, 0x38, 0x06, 0xF6, 0x71, 0x72},
61 - []byte{0x17, 0x30, 0xE5, 0x77, 0x8B, 0xEA, 0x1D, 0xA4}},
62 - {
63 - []byte{0x38, 0x49, 0x67, 0x4C, 0x26, 0x02, 0x31, 0x9E},
64 - []byte{0x51, 0x45, 0x4B, 0x58, 0x2D, 0xDF, 0x44, 0x0A},
65 - []byte{0xA2, 0x5E, 0x78, 0x56, 0xCF, 0x26, 0x51, 0xEB}},
66 - {
67 - []byte{0x04, 0xB9, 0x15, 0xBA, 0x43, 0xFE, 0xB5, 0xB6},
68 - []byte{0x42, 0xFD, 0x44, 0x30, 0x59, 0x57, 0x7F, 0xA2},
69 - []byte{0x35, 0x38, 0x82, 0xB1, 0x09, 0xCE, 0x8F, 0x1A}},
70 - {
71 - []byte{0x01, 0x13, 0xB9, 0x70, 0xFD, 0x34, 0xF2, 0xCE},
72 - []byte{0x05, 0x9B, 0x5E, 0x08, 0x51, 0xCF, 0x14, 0x3A},
73 - []byte{0x48, 0xF4, 0xD0, 0x88, 0x4C, 0x37, 0x99, 0x18}},
74 - {
75 - []byte{0x01, 0x70, 0xF1, 0x75, 0x46, 0x8F, 0xB5, 0xE6},
76 - []byte{0x07, 0x56, 0xD8, 0xE0, 0x77, 0x47, 0x61, 0xD2},
77 - []byte{0x43, 0x21, 0x93, 0xB7, 0x89, 0x51, 0xFC, 0x98}},
78 - {
79 - []byte{0x43, 0x29, 0x7F, 0xAD, 0x38, 0xE3, 0x73, 0xFE},
80 - []byte{0x76, 0x25, 0x14, 0xB8, 0x29, 0xBF, 0x48, 0x6A},
81 - []byte{0x13, 0xF0, 0x41, 0x54, 0xD6, 0x9D, 0x1A, 0xE5}},
82 - {
83 - []byte{0x07, 0xA7, 0x13, 0x70, 0x45, 0xDA, 0x2A, 0x16},
84 - []byte{0x3B, 0xDD, 0x11, 0x90, 0x49, 0x37, 0x28, 0x02},
85 - []byte{0x2E, 0xED, 0xDA, 0x93, 0xFF, 0xD3, 0x9C, 0x79}},
86 - {
87 - []byte{0x04, 0x68, 0x91, 0x04, 0xC2, 0xFD, 0x3B, 0x2F},
88 - []byte{0x26, 0x95, 0x5F, 0x68, 0x35, 0xAF, 0x60, 0x9A},
89 - []byte{0xD8, 0x87, 0xE0, 0x39, 0x3C, 0x2D, 0xA6, 0xE3}},
90 - {
91 - []byte{0x37, 0xD0, 0x6B, 0xB5, 0x16, 0xCB, 0x75, 0x46},
92 - []byte{0x16, 0x4D, 0x5E, 0x40, 0x4F, 0x27, 0x52, 0x32},
93 - []byte{0x5F, 0x99, 0xD0, 0x4F, 0x5B, 0x16, 0x39, 0x69}},
94 - {
95 - []byte{0x1F, 0x08, 0x26, 0x0D, 0x1A, 0xC2, 0x46, 0x5E},
96 - []byte{0x6B, 0x05, 0x6E, 0x18, 0x75, 0x9F, 0x5C, 0xCA},
97 - []byte{0x4A, 0x05, 0x7A, 0x3B, 0x24, 0xD3, 0x97, 0x7B}},
98 - {
99 - []byte{0x58, 0x40, 0x23, 0x64, 0x1A, 0xBA, 0x61, 0x76},
100 - []byte{0x00, 0x4B, 0xD6, 0xEF, 0x09, 0x17, 0x60, 0x62},
101 - []byte{0x45, 0x20, 0x31, 0xC1, 0xE4, 0xFA, 0xDA, 0x8E}},
102 - {
103 - []byte{0x02, 0x58, 0x16, 0x16, 0x46, 0x29, 0xB0, 0x07},
104 - []byte{0x48, 0x0D, 0x39, 0x00, 0x6E, 0xE7, 0x62, 0xF2},
105 - []byte{0x75, 0x55, 0xAE, 0x39, 0xF5, 0x9B, 0x87, 0xBD}},
106 - {
107 - []byte{0x49, 0x79, 0x3E, 0xBC, 0x79, 0xB3, 0x25, 0x8F},
108 - []byte{0x43, 0x75, 0x40, 0xC8, 0x69, 0x8F, 0x3C, 0xFA},
109 - []byte{0x53, 0xC5, 0x5F, 0x9C, 0xB4, 0x9F, 0xC0, 0x19}},
110 - {
111 - []byte{0x4F, 0xB0, 0x5E, 0x15, 0x15, 0xAB, 0x73, 0xA7},
112 - []byte{0x07, 0x2D, 0x43, 0xA0, 0x77, 0x07, 0x52, 0x92},
113 - []byte{0x7A, 0x8E, 0x7B, 0xFA, 0x93, 0x7E, 0x89, 0xA3}},
114 - {
115 - []byte{0x49, 0xE9, 0x5D, 0x6D, 0x4C, 0xA2, 0x29, 0xBF},
116 - []byte{0x02, 0xFE, 0x55, 0x77, 0x81, 0x17, 0xF1, 0x2A},
117 - []byte{0xCF, 0x9C, 0x5D, 0x7A, 0x49, 0x86, 0xAD, 0xB5}},
118 - {
119 - []byte{0x01, 0x83, 0x10, 0xDC, 0x40, 0x9B, 0x26, 0xD6},
120 - []byte{0x1D, 0x9D, 0x5C, 0x50, 0x18, 0xF7, 0x28, 0xC2},
121 - []byte{0xD1, 0xAB, 0xB2, 0x90, 0x65, 0x8B, 0xC7, 0x78}},
122 - {
123 - []byte{0x1C, 0x58, 0x7F, 0x1C, 0x13, 0x92, 0x4F, 0xEF},
124 - []byte{0x30, 0x55, 0x32, 0x28, 0x6D, 0x6F, 0x29, 0x5A},
125 - []byte{0x55, 0xCB, 0x37, 0x74, 0xD1, 0x3E, 0xF2, 0x01}},
126 - {
127 - []byte{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
128 - []byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
129 - []byte{0xFA, 0x34, 0xEC, 0x48, 0x47, 0xB2, 0x68, 0xB2}},
130 - {
131 - []byte{0x1F, 0x1F, 0x1F, 0x1F, 0x0E, 0x0E, 0x0E, 0x0E},
132 - []byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
133 - []byte{0xA7, 0x90, 0x79, 0x51, 0x08, 0xEA, 0x3C, 0xAE}},
134 - {
135 - []byte{0xE0, 0xFE, 0xE0, 0xFE, 0xF1, 0xFE, 0xF1, 0xFE},
136 - []byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
137 - []byte{0xC3, 0x9E, 0x07, 0x2D, 0x9F, 0xAC, 0x63, 0x1D}},
138 - {
139 - []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
140 - []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
141 - []byte{0x01, 0x49, 0x33, 0xE0, 0xCD, 0xAF, 0xF6, 0xE4}},
142 - {
143 - []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
144 - []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
145 - []byte{0xF2, 0x1E, 0x9A, 0x77, 0xB7, 0x1C, 0x49, 0xBC}},
146 - {
147 - []byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF},
148 - []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
149 - []byte{0x24, 0x59, 0x46, 0x88, 0x57, 0x54, 0x36, 0x9A}},
150 - {
151 - []byte{0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10},
152 - []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF},
153 - []byte{0x6B, 0x5C, 0x5A, 0x9C, 0x5D, 0x9E, 0x0A, 0x5A}},
154 -}
155 -
156 -func TestCipherEncrypt(t *testing.T) {
157 - for i, tt := range encryptTests {
158 - c, err := NewCipher(tt.key)
159 - if err != nil {
160 - t.Errorf("NewCipher(%d bytes) = %s", len(tt.key), err)
161 - continue
162 - }
163 - ct := make([]byte, len(tt.out))
164 - c.Encrypt(ct, tt.in)
165 - for j, v := range ct {
166 - if v != tt.out[j] {
167 - t.Errorf("Cipher.Encrypt, test vector #%d: cipher-text[%d] = %#x, expected %#x", i, j, v, tt.out[j])
168 - break
169 - }
170 - }
171 - }
172 -}
173 -
174 -func TestCipherDecrypt(t *testing.T) {
175 - for i, tt := range encryptTests {
176 - c, err := NewCipher(tt.key)
177 - if err != nil {
178 - t.Errorf("NewCipher(%d bytes) = %s", len(tt.key), err)
179 - continue
180 - }
181 - pt := make([]byte, len(tt.in))
182 - c.Decrypt(pt, tt.out)
183 - for j, v := range pt {
184 - if v != tt.in[j] {
185 - t.Errorf("Cipher.Decrypt, test vector #%d: plain-text[%d] = %#x, expected %#x", i, j, v, tt.in[j])
186 - break
187 - }
188 - }
189 - }
190 -}
191 -
192 -func TestSaltedCipherKeyLength(t *testing.T) {
193 - if _, err := NewSaltedCipher(nil, []byte{'a'}); err != KeySizeError(0) {
194 - t.Errorf("NewSaltedCipher with short key, gave error %#v, expected %#v", err, KeySizeError(0))
195 - }
196 -
197 - // A 57-byte key. One over the typical blowfish restriction.
198 - key := []byte("012345678901234567890123456789012345678901234567890123456")
199 - if _, err := NewSaltedCipher(key, []byte{'a'}); err != nil {
200 - t.Errorf("NewSaltedCipher with long key, gave error %#v", err)
201 - }
202 -}
203 -
204 -// Test vectors generated with Blowfish from OpenSSH.
205 -var saltedVectors = [][8]byte{
206 - {0x0c, 0x82, 0x3b, 0x7b, 0x8d, 0x01, 0x4b, 0x7e},
207 - {0xd1, 0xe1, 0x93, 0xf0, 0x70, 0xa6, 0xdb, 0x12},
208 - {0xfc, 0x5e, 0xba, 0xde, 0xcb, 0xf8, 0x59, 0xad},
209 - {0x8a, 0x0c, 0x76, 0xe7, 0xdd, 0x2c, 0xd3, 0xa8},
210 - {0x2c, 0xcb, 0x7b, 0xee, 0xac, 0x7b, 0x7f, 0xf8},
211 - {0xbb, 0xf6, 0x30, 0x6f, 0xe1, 0x5d, 0x62, 0xbf},
212 - {0x97, 0x1e, 0xc1, 0x3d, 0x3d, 0xe0, 0x11, 0xe9},
213 - {0x06, 0xd7, 0x4d, 0xb1, 0x80, 0xa3, 0xb1, 0x38},
214 - {0x67, 0xa1, 0xa9, 0x75, 0x0e, 0x5b, 0xc6, 0xb4},
215 - {0x51, 0x0f, 0x33, 0x0e, 0x4f, 0x67, 0xd2, 0x0c},
216 - {0xf1, 0x73, 0x7e, 0xd8, 0x44, 0xea, 0xdb, 0xe5},
217 - {0x14, 0x0e, 0x16, 0xce, 0x7f, 0x4a, 0x9c, 0x7b},
218 - {0x4b, 0xfe, 0x43, 0xfd, 0xbf, 0x36, 0x04, 0x47},
219 - {0xb1, 0xeb, 0x3e, 0x15, 0x36, 0xa7, 0xbb, 0xe2},
220 - {0x6d, 0x0b, 0x41, 0xdd, 0x00, 0x98, 0x0b, 0x19},
221 - {0xd3, 0xce, 0x45, 0xce, 0x1d, 0x56, 0xb7, 0xfc},
222 - {0xd9, 0xf0, 0xfd, 0xda, 0xc0, 0x23, 0xb7, 0x93},
223 - {0x4c, 0x6f, 0xa1, 0xe4, 0x0c, 0xa8, 0xca, 0x57},
224 - {0xe6, 0x2f, 0x28, 0xa7, 0x0c, 0x94, 0x0d, 0x08},
225 - {0x8f, 0xe3, 0xf0, 0xb6, 0x29, 0xe3, 0x44, 0x03},
226 - {0xff, 0x98, 0xdd, 0x04, 0x45, 0xb4, 0x6d, 0x1f},
227 - {0x9e, 0x45, 0x4d, 0x18, 0x40, 0x53, 0xdb, 0xef},
228 - {0xb7, 0x3b, 0xef, 0x29, 0xbe, 0xa8, 0x13, 0x71},
229 - {0x02, 0x54, 0x55, 0x41, 0x8e, 0x04, 0xfc, 0xad},
230 - {0x6a, 0x0a, 0xee, 0x7c, 0x10, 0xd9, 0x19, 0xfe},
231 - {0x0a, 0x22, 0xd9, 0x41, 0xcc, 0x23, 0x87, 0x13},
232 - {0x6e, 0xff, 0x1f, 0xff, 0x36, 0x17, 0x9c, 0xbe},
233 - {0x79, 0xad, 0xb7, 0x40, 0xf4, 0x9f, 0x51, 0xa6},
234 - {0x97, 0x81, 0x99, 0xa4, 0xde, 0x9e, 0x9f, 0xb6},
235 - {0x12, 0x19, 0x7a, 0x28, 0xd0, 0xdc, 0xcc, 0x92},
236 - {0x81, 0xda, 0x60, 0x1e, 0x0e, 0xdd, 0x65, 0x56},
237 - {0x7d, 0x76, 0x20, 0xb2, 0x73, 0xc9, 0x9e, 0xee},
238 -}
239 -
240 -func TestSaltedCipher(t *testing.T) {
241 - var key, salt [32]byte
242 - for i := range key {
243 - key[i] = byte(i)
244 - salt[i] = byte(i + 32)
245 - }
246 - for i, v := range saltedVectors {
247 - c, err := NewSaltedCipher(key[:], salt[:i])
248 - if err != nil {
249 - t.Fatal(err)
250 - }
251 - var buf [8]byte
252 - c.Encrypt(buf[:], buf[:])
253 - if v != buf {
254 - t.Errorf("%d: expected %x, got %x", i, v, buf)
255 - }
256 - }
257 -}
258 -
259 -func BenchmarkExpandKeyWithSalt(b *testing.B) {
260 - key := make([]byte, 32)
261 - salt := make([]byte, 16)
262 - c, _ := NewCipher(key)
263 - for i := 0; i < b.N; i++ {
264 - expandKeyWithSalt(key, salt, c)
265 - }
266 -}
267 -
268 -func BenchmarkExpandKey(b *testing.B) {
269 - key := make([]byte, 32)
270 - c, _ := NewCipher(key)
271 - for i := 0; i < b.N; i++ {
272 - ExpandKey(key, c)
273 - }
274 -}
Godeps/_workspace/src/golang.org/x/crypto/blowfish/cipher.go deleted
-91
@@ -1,91 +0,0 @@
1 -// Copyright 2010 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
6 -package blowfish
7 -
8 -// The code is a port of Bruce Schneier's C implementation.
9 -// See http://www.schneier.com/blowfish.html.
10 -
11 -import "strconv"
12 -
13 -// The Blowfish block size in bytes.
14 -const BlockSize = 8
15 -
16 -// A Cipher is an instance of Blowfish encryption using a particular key.
17 -type Cipher struct {
18 - p [18]uint32
19 - s0, s1, s2, s3 [256]uint32
20 -}
21 -
22 -type KeySizeError int
23 -
24 -func (k KeySizeError) Error() string {
25 - return "crypto/blowfish: invalid key size " + strconv.Itoa(int(k))
26 -}
27 -
28 -// NewCipher creates and returns a Cipher.
29 -// The key argument should be the Blowfish key, from 1 to 56 bytes.
30 -func NewCipher(key []byte) (*Cipher, error) {
31 - var result Cipher
32 - if k := len(key); k < 1 || k > 56 {
33 - return nil, KeySizeError(k)
34 - }
35 - initCipher(&result)
36 - ExpandKey(key, &result)
37 - return &result, nil
38 -}
39 -
40 -// NewSaltedCipher creates a returns a Cipher that folds a salt into its key
41 -// schedule. For most purposes, NewCipher, instead of NewSaltedCipher, is
42 -// sufficient and desirable. For bcrypt compatiblity, the key can be over 56
43 -// bytes.
44 -func NewSaltedCipher(key, salt []byte) (*Cipher, error) {
45 - if len(salt) == 0 {
46 - return NewCipher(key)
47 - }
48 - var result Cipher
49 - if k := len(key); k < 1 {
50 - return nil, KeySizeError(k)
51 - }
52 - initCipher(&result)
53 - expandKeyWithSalt(key, salt, &result)
54 - return &result, nil
55 -}
56 -
57 -// BlockSize returns the Blowfish block size, 8 bytes.
58 -// It is necessary to satisfy the Block interface in the
59 -// package "crypto/cipher".
60 -func (c *Cipher) BlockSize() int { return BlockSize }
61 -
62 -// Encrypt encrypts the 8-byte buffer src using the key k
63 -// and stores the result in dst.
64 -// Note that for amounts of data larger than a block,
65 -// it is not safe to just call Encrypt on successive blocks;
66 -// instead, use an encryption mode like CBC (see crypto/cipher/cbc.go).
67 -func (c *Cipher) Encrypt(dst, src []byte) {
68 - l := uint32(src[0])<<24 | uint32(src[1])<<16 | uint32(src[2])<<8 | uint32(src[3])
69 - r := uint32(src[4])<<24 | uint32(src[5])<<16 | uint32(src[6])<<8 | uint32(src[7])
70 - l, r = encryptBlock(l, r, c)
71 - dst[0], dst[1], dst[2], dst[3] = byte(l>>24), byte(l>>16), byte(l>>8), byte(l)
72 - dst[4], dst[5], dst[6], dst[7] = byte(r>>24), byte(r>>16), byte(r>>8), byte(r)
73 -}
74 -
75 -// Decrypt decrypts the 8-byte buffer src using the key k
76 -// and stores the result in dst.
77 -func (c *Cipher) Decrypt(dst, src []byte) {
78 - l := uint32(src[0])<<24 | uint32(src[1])<<16 | uint32(src[2])<<8 | uint32(src[3])
79 - r := uint32(src[4])<<24 | uint32(src[5])<<16 | uint32(src[6])<<8 | uint32(src[7])
80 - l, r = decryptBlock(l, r, c)
81 - dst[0], dst[1], dst[2], dst[3] = byte(l>>24), byte(l>>16), byte(l>>8), byte(l)
82 - dst[4], dst[5], dst[6], dst[7] = byte(r>>24), byte(r>>16), byte(r>>8), byte(r)
83 -}
84 -
85 -func initCipher(c *Cipher) {
86 - copy(c.p[0:], p[0:])
87 - copy(c.s0[0:], s0[0:])
88 - copy(c.s1[0:], s1[0:])
89 - copy(c.s2[0:], s2[0:])
90 - copy(c.s3[0:], s3[0:])
91 -}
Godeps/_workspace/src/golang.org/x/crypto/blowfish/const.go deleted
-199
@@ -1,199 +0,0 @@
1 -// Copyright 2010 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// The startup permutation array and substitution boxes.
6 -// They are the hexadecimal digits of PI; see:
7 -// http://www.schneier.com/code/constants.txt.
8 -
9 -package blowfish
10 -
11 -var s0 = [256]uint32{
12 - 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96,
13 - 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
14 - 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658,
15 - 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
16 - 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e,
17 - 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
18 - 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6,
19 - 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
20 - 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c,
21 - 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
22 - 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, 0xef845d5d, 0xe98575b1,
23 - 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
24 - 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a,
25 - 0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
26 - 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, 0xa1f1651d, 0x39af0176,
27 - 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
28 - 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706,
29 - 0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
30 - 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a, 0xb6794c3b,
31 - 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
32 - 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c,
33 - 0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
34 - 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a,
35 - 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
36 - 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760,
37 - 0x53317b48, 0x3e00df82, 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
38 - 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8,
39 - 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
40 - 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33,
41 - 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
42 - 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0,
43 - 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
44 - 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777,
45 - 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
46 - 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, 0x165fa266, 0x80957705,
47 - 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
48 - 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e,
49 - 0x226800bb, 0x57b8e0af, 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
50 - 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376, 0x6295cfa9,
51 - 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
52 - 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f,
53 - 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
54 - 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a,
55 -}
56 -
57 -var s1 = [256]uint32{
58 - 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d,
59 - 0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
60 - 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65,
61 - 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
62 - 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9,
63 - 0x3c971814, 0x6b6a70a1, 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
64 - 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d,
65 - 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
66 - 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc,
67 - 0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
68 - 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908,
69 - 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
70 - 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124,
71 - 0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
72 - 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908,
73 - 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
74 - 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b,
75 - 0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
76 - 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa,
77 - 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
78 - 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d,
79 - 0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
80 - 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5,
81 - 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
82 - 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96,
83 - 0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
84 - 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca,
85 - 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
86 - 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77,
87 - 0x11ed935f, 0x16681281, 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
88 - 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054,
89 - 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
90 - 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea,
91 - 0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
92 - 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646,
93 - 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
94 - 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea,
95 - 0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
96 - 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e,
97 - 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
98 - 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd,
99 - 0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
100 - 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7,
101 -}
102 -
103 -var s2 = [256]uint32{
104 - 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7,
105 - 0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
106 - 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af,
107 - 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
108 - 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4,
109 - 0x0a2c86da, 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
110 - 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec,
111 - 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
112 - 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332,
113 - 0x6841e7f7, 0xca7820fb, 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
114 - 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58,
115 - 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
116 - 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22,
117 - 0x48c1133f, 0xc70f86dc, 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
118 - 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60,
119 - 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
120 - 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99,
121 - 0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
122 - 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74,
123 - 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
124 - 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3,
125 - 0xb5390f92, 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
126 - 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, 0x37392eb3, 0xcc115979,
127 - 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
128 - 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa,
129 - 0x3d25bdd8, 0xe2e1c3c9, 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
130 - 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086,
131 - 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
132 - 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24,
133 - 0x55464299, 0xbf582e61, 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
134 - 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84,
135 - 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
136 - 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09,
137 - 0x662d09a1, 0xc4324633, 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
138 - 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe,
139 - 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
140 - 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0,
141 - 0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
142 - 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188,
143 - 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
144 - 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8,
145 - 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
146 - 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0,
147 -}
148 -
149 -var s3 = [256]uint32{
150 - 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742,
151 - 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
152 - 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, 0x5748ab2f, 0xbc946e79,
153 - 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
154 - 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a,
155 - 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
156 - 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, 0x2826a2f9, 0xa73a3ae1,
157 - 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
158 - 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797,
159 - 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
160 - 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71, 0xe019a5e6,
161 - 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
162 - 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba,
163 - 0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
164 - 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, 0x7533d928, 0xb155fdf5,
165 - 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
166 - 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce,
167 - 0x5121ce64, 0x774fbe32, 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
168 - 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd,
169 - 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
170 - 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb,
171 - 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
172 - 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc,
173 - 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
174 - 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc,
175 - 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
176 - 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, 0x1a908749, 0xd44fbd9a,
177 - 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
178 - 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a,
179 - 0x0f91fc71, 0x9b941525, 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
180 - 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e, 0x1698db3b,
181 - 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
182 - 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e,
183 - 0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
184 - 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623,
185 - 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
186 - 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a,
187 - 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
188 - 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, 0x53113ec0, 0x1640e3d3,
189 - 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
190 - 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c,
191 - 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
192 - 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6,
193 -}
194 -
195 -var p = [18]uint32{
196 - 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0,
197 - 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
198 - 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b,
199 -}
Godeps/_workspace/src/golang.org/x/crypto/sha3/doc.go deleted
-66
@@ -1,66 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// Package sha3 implements the SHA-3 fixed-output-length hash functions and
6 -// the SHAKE variable-output-length hash functions defined by FIPS-202.
7 -//
8 -// Both types of hash function use the "sponge" construction and the Keccak
9 -// permutation. For a detailed specification see http://keccak.noekeon.org/
10 -//
11 -//
12 -// Guidance
13 -//
14 -// If you aren't sure what function you need, use SHAKE256 with at least 64
15 -// bytes of output. The SHAKE instances are faster than the SHA3 instances;
16 -// the latter have to allocate memory to conform to the hash.Hash interface.
17 -//
18 -// If you need a secret-key MAC (message authentication code), prepend the
19 -// secret key to the input, hash with SHAKE256 and read at least 32 bytes of
20 -// output.
21 -//
22 -//
23 -// Security strengths
24 -//
25 -// The SHA3-x (x equals 224, 256, 384, or 512) functions have a security
26 -// strength against preimage attacks of x bits. Since they only produce "x"
27 -// bits of output, their collision-resistance is only "x/2" bits.
28 -//
29 -// The SHAKE-256 and -128 functions have a generic security strength of 256 and
30 -// 128 bits against all attacks, provided that at least 2x bits of their output
31 -// is used. Requesting more than 64 or 32 bytes of output, respectively, does
32 -// not increase the collision-resistance of the SHAKE functions.
33 -//
34 -//
35 -// The sponge construction
36 -//
37 -// A sponge builds a pseudo-random function from a public pseudo-random
38 -// permutation, by applying the permutation to a state of "rate + capacity"
39 -// bytes, but hiding "capacity" of the bytes.
40 -//
41 -// A sponge starts out with a zero state. To hash an input using a sponge, up
42 -// to "rate" bytes of the input are XORed into the sponge's state. The sponge
43 -// is then "full" and the permutation is applied to "empty" it. This process is
44 -// repeated until all the input has been "absorbed". The input is then padded.
45 -// The digest is "squeezed" from the sponge in the same way, except that output
46 -// output is copied out instead of input being XORed in.
47 -//
48 -// A sponge is parameterized by its generic security strength, which is equal
49 -// to half its capacity; capacity + rate is equal to the permutation's width.
50 -// Since the KeccakF-1600 permutation is 1600 bits (200 bytes) wide, this means
51 -// that the security strength of a sponge instance is equal to (1600 - bitrate) / 2.
52 -//
53 -//
54 -// Recommendations
55 -//
56 -// The SHAKE functions are recommended for most new uses. They can produce
57 -// output of arbitrary length. SHAKE256, with an output length of at least
58 -// 64 bytes, provides 256-bit security against all attacks. The Keccak team
59 -// recommends it for most applications upgrading from SHA2-512. (NIST chose a
60 -// much stronger, but much slower, sponge instance for SHA3-512.)
61 -//
62 -// The SHA-3 functions are "drop-in" replacements for the SHA-2 functions.
63 -// They produce output of the same length, with the same security strengths
64 -// against all attacks. This means, in particular, that SHA3-256 only has
65 -// 128-bit collision resistance, because its output length is 32 bytes.
66 -package sha3
Godeps/_workspace/src/golang.org/x/crypto/sha3/hashes.go deleted
-65
@@ -1,65 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package sha3
6 -
7 -// This file provides functions for creating instances of the SHA-3
8 -// and SHAKE hash functions, as well as utility functions for hashing
9 -// bytes.
10 -
11 -import (
12 - "hash"
13 -)
14 -
15 -// New224 creates a new SHA3-224 hash.
16 -// Its generic security strength is 224 bits against preimage attacks,
17 -// and 112 bits against collision attacks.
18 -func New224() hash.Hash { return &state{rate: 144, outputLen: 28, dsbyte: 0x06} }
19 -
20 -// New256 creates a new SHA3-256 hash.
21 -// Its generic security strength is 256 bits against preimage attacks,
22 -// and 128 bits against collision attacks.
23 -func New256() hash.Hash { return &state{rate: 136, outputLen: 32, dsbyte: 0x06} }
24 -
25 -// New384 creates a new SHA3-384 hash.
26 -// Its generic security strength is 384 bits against preimage attacks,
27 -// and 192 bits against collision attacks.
28 -func New384() hash.Hash { return &state{rate: 104, outputLen: 48, dsbyte: 0x06} }
29 -
30 -// New512 creates a new SHA3-512 hash.
31 -// Its generic security strength is 512 bits against preimage attacks,
32 -// and 256 bits against collision attacks.
33 -func New512() hash.Hash { return &state{rate: 72, outputLen: 64, dsbyte: 0x06} }
34 -
35 -// Sum224 returns the SHA3-224 digest of the data.
36 -func Sum224(data []byte) (digest [28]byte) {
37 - h := New224()
38 - h.Write(data)
39 - h.Sum(digest[:0])
40 - return
41 -}
42 -
43 -// Sum256 returns the SHA3-256 digest of the data.
44 -func Sum256(data []byte) (digest [32]byte) {
45 - h := New256()
46 - h.Write(data)
47 - h.Sum(digest[:0])
48 - return
49 -}
50 -
51 -// Sum384 returns the SHA3-384 digest of the data.
52 -func Sum384(data []byte) (digest [48]byte) {
53 - h := New384()
54 - h.Write(data)
55 - h.Sum(digest[:0])
56 - return
57 -}
58 -
59 -// Sum512 returns the SHA3-512 digest of the data.
60 -func Sum512(data []byte) (digest [64]byte) {
61 - h := New512()
62 - h.Write(data)
63 - h.Sum(digest[:0])
64 - return
65 -}
Godeps/_workspace/src/golang.org/x/crypto/sha3/keccakf.go deleted
-410
@@ -1,410 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package sha3
6 -
7 -// rc stores the round constants for use in the ι step.
8 -var rc = [24]uint64{
9 - 0x0000000000000001,
10 - 0x0000000000008082,
11 - 0x800000000000808A,
12 - 0x8000000080008000,
13 - 0x000000000000808B,
14 - 0x0000000080000001,
15 - 0x8000000080008081,
16 - 0x8000000000008009,
17 - 0x000000000000008A,
18 - 0x0000000000000088,
19 - 0x0000000080008009,
20 - 0x000000008000000A,
21 - 0x000000008000808B,
22 - 0x800000000000008B,
23 - 0x8000000000008089,
24 - 0x8000000000008003,
25 - 0x8000000000008002,
26 - 0x8000000000000080,
27 - 0x000000000000800A,
28 - 0x800000008000000A,
29 - 0x8000000080008081,
30 - 0x8000000000008080,
31 - 0x0000000080000001,
32 - 0x8000000080008008,
33 -}
34 -
35 -// keccakF1600 applies the Keccak permutation to a 1600b-wide
36 -// state represented as a slice of 25 uint64s.
37 -func keccakF1600(a *[25]uint64) {
38 - // Implementation translated from Keccak-inplace.c
39 - // in the keccak reference code.
40 - var t, bc0, bc1, bc2, bc3, bc4, d0, d1, d2, d3, d4 uint64
41 -
42 - for i := 0; i < 24; i += 4 {
43 - // Combines the 5 steps in each round into 2 steps.
44 - // Unrolls 4 rounds per loop and spreads some steps across rounds.
45 -
46 - // Round 1
47 - bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20]
48 - bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21]
49 - bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22]
50 - bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23]
51 - bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24]
52 - d0 = bc4 ^ (bc1<<1 | bc1>>63)
53 - d1 = bc0 ^ (bc2<<1 | bc2>>63)
54 - d2 = bc1 ^ (bc3<<1 | bc3>>63)
55 - d3 = bc2 ^ (bc4<<1 | bc4>>63)
56 - d4 = bc3 ^ (bc0<<1 | bc0>>63)
57 -
58 - bc0 = a[0] ^ d0
59 - t = a[6] ^ d1
60 - bc1 = t<<44 | t>>(64-44)
61 - t = a[12] ^ d2
62 - bc2 = t<<43 | t>>(64-43)
63 - t = a[18] ^ d3
64 - bc3 = t<<21 | t>>(64-21)
65 - t = a[24] ^ d4
66 - bc4 = t<<14 | t>>(64-14)
67 - a[0] = bc0 ^ (bc2 &^ bc1) ^ rc[i]
68 - a[6] = bc1 ^ (bc3 &^ bc2)
69 - a[12] = bc2 ^ (bc4 &^ bc3)
70 - a[18] = bc3 ^ (bc0 &^ bc4)
71 - a[24] = bc4 ^ (bc1 &^ bc0)
72 -
73 - t = a[10] ^ d0
74 - bc2 = t<<3 | t>>(64-3)
75 - t = a[16] ^ d1
76 - bc3 = t<<45 | t>>(64-45)
77 - t = a[22] ^ d2
78 - bc4 = t<<61 | t>>(64-61)
79 - t = a[3] ^ d3
80 - bc0 = t<<28 | t>>(64-28)
81 - t = a[9] ^ d4
82 - bc1 = t<<20 | t>>(64-20)
83 - a[10] = bc0 ^ (bc2 &^ bc1)
84 - a[16] = bc1 ^ (bc3 &^ bc2)
85 - a[22] = bc2 ^ (bc4 &^ bc3)
86 - a[3] = bc3 ^ (bc0 &^ bc4)
87 - a[9] = bc4 ^ (bc1 &^ bc0)
88 -
89 - t = a[20] ^ d0
90 - bc4 = t<<18 | t>>(64-18)
91 - t = a[1] ^ d1
92 - bc0 = t<<1 | t>>(64-1)
93 - t = a[7] ^ d2
94 - bc1 = t<<6 | t>>(64-6)
95 - t = a[13] ^ d3
96 - bc2 = t<<25 | t>>(64-25)
97 - t = a[19] ^ d4
98 - bc3 = t<<8 | t>>(64-8)
99 - a[20] = bc0 ^ (bc2 &^ bc1)
100 - a[1] = bc1 ^ (bc3 &^ bc2)
101 - a[7] = bc2 ^ (bc4 &^ bc3)
102 - a[13] = bc3 ^ (bc0 &^ bc4)
103 - a[19] = bc4 ^ (bc1 &^ bc0)
104 -
105 - t = a[5] ^ d0
106 - bc1 = t<<36 | t>>(64-36)
107 - t = a[11] ^ d1
108 - bc2 = t<<10 | t>>(64-10)
109 - t = a[17] ^ d2
110 - bc3 = t<<15 | t>>(64-15)
111 - t = a[23] ^ d3
112 - bc4 = t<<56 | t>>(64-56)
113 - t = a[4] ^ d4
114 - bc0 = t<<27 | t>>(64-27)
115 - a[5] = bc0 ^ (bc2 &^ bc1)
116 - a[11] = bc1 ^ (bc3 &^ bc2)
117 - a[17] = bc2 ^ (bc4 &^ bc3)
118 - a[23] = bc3 ^ (bc0 &^ bc4)
119 - a[4] = bc4 ^ (bc1 &^ bc0)
120 -
121 - t = a[15] ^ d0
122 - bc3 = t<<41 | t>>(64-41)
123 - t = a[21] ^ d1
124 - bc4 = t<<2 | t>>(64-2)
125 - t = a[2] ^ d2
126 - bc0 = t<<62 | t>>(64-62)
127 - t = a[8] ^ d3
128 - bc1 = t<<55 | t>>(64-55)
129 - t = a[14] ^ d4
130 - bc2 = t<<39 | t>>(64-39)
131 - a[15] = bc0 ^ (bc2 &^ bc1)
132 - a[21] = bc1 ^ (bc3 &^ bc2)
133 - a[2] = bc2 ^ (bc4 &^ bc3)
134 - a[8] = bc3 ^ (bc0 &^ bc4)
135 - a[14] = bc4 ^ (bc1 &^ bc0)
136 -
137 - // Round 2
138 - bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20]
139 - bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21]
140 - bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22]
141 - bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23]
142 - bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24]
143 - d0 = bc4 ^ (bc1<<1 | bc1>>63)
144 - d1 = bc0 ^ (bc2<<1 | bc2>>63)
145 - d2 = bc1 ^ (bc3<<1 | bc3>>63)
146 - d3 = bc2 ^ (bc4<<1 | bc4>>63)
147 - d4 = bc3 ^ (bc0<<1 | bc0>>63)
148 -
149 - bc0 = a[0] ^ d0
150 - t = a[16] ^ d1
151 - bc1 = t<<44 | t>>(64-44)
152 - t = a[7] ^ d2
153 - bc2 = t<<43 | t>>(64-43)
154 - t = a[23] ^ d3
155 - bc3 = t<<21 | t>>(64-21)
156 - t = a[14] ^ d4
157 - bc4 = t<<14 | t>>(64-14)
158 - a[0] = bc0 ^ (bc2 &^ bc1) ^ rc[i+1]
159 - a[16] = bc1 ^ (bc3 &^ bc2)
160 - a[7] = bc2 ^ (bc4 &^ bc3)
161 - a[23] = bc3 ^ (bc0 &^ bc4)
162 - a[14] = bc4 ^ (bc1 &^ bc0)
163 -
164 - t = a[20] ^ d0
165 - bc2 = t<<3 | t>>(64-3)
166 - t = a[11] ^ d1
167 - bc3 = t<<45 | t>>(64-45)
168 - t = a[2] ^ d2
169 - bc4 = t<<61 | t>>(64-61)
170 - t = a[18] ^ d3
171 - bc0 = t<<28 | t>>(64-28)
172 - t = a[9] ^ d4
173 - bc1 = t<<20 | t>>(64-20)
174 - a[20] = bc0 ^ (bc2 &^ bc1)
175 - a[11] = bc1 ^ (bc3 &^ bc2)
176 - a[2] = bc2 ^ (bc4 &^ bc3)
177 - a[18] = bc3 ^ (bc0 &^ bc4)
178 - a[9] = bc4 ^ (bc1 &^ bc0)
179 -
180 - t = a[15] ^ d0
181 - bc4 = t<<18 | t>>(64-18)
182 - t = a[6] ^ d1
183 - bc0 = t<<1 | t>>(64-1)
184 - t = a[22] ^ d2
185 - bc1 = t<<6 | t>>(64-6)
186 - t = a[13] ^ d3
187 - bc2 = t<<25 | t>>(64-25)
188 - t = a[4] ^ d4
189 - bc3 = t<<8 | t>>(64-8)
190 - a[15] = bc0 ^ (bc2 &^ bc1)
191 - a[6] = bc1 ^ (bc3 &^ bc2)
192 - a[22] = bc2 ^ (bc4 &^ bc3)
193 - a[13] = bc3 ^ (bc0 &^ bc4)
194 - a[4] = bc4 ^ (bc1 &^ bc0)
195 -
196 - t = a[10] ^ d0
197 - bc1 = t<<36 | t>>(64-36)
198 - t = a[1] ^ d1
199 - bc2 = t<<10 | t>>(64-10)
200 - t = a[17] ^ d2
201 - bc3 = t<<15 | t>>(64-15)
202 - t = a[8] ^ d3
203 - bc4 = t<<56 | t>>(64-56)
204 - t = a[24] ^ d4
205 - bc0 = t<<27 | t>>(64-27)
206 - a[10] = bc0 ^ (bc2 &^ bc1)
207 - a[1] = bc1 ^ (bc3 &^ bc2)
208 - a[17] = bc2 ^ (bc4 &^ bc3)
209 - a[8] = bc3 ^ (bc0 &^ bc4)
210 - a[24] = bc4 ^ (bc1 &^ bc0)
211 -
212 - t = a[5] ^ d0
213 - bc3 = t<<41 | t>>(64-41)
214 - t = a[21] ^ d1
215 - bc4 = t<<2 | t>>(64-2)
216 - t = a[12] ^ d2
217 - bc0 = t<<62 | t>>(64-62)
218 - t = a[3] ^ d3
219 - bc1 = t<<55 | t>>(64-55)
220 - t = a[19] ^ d4
221 - bc2 = t<<39 | t>>(64-39)
222 - a[5] = bc0 ^ (bc2 &^ bc1)
223 - a[21] = bc1 ^ (bc3 &^ bc2)
224 - a[12] = bc2 ^ (bc4 &^ bc3)
225 - a[3] = bc3 ^ (bc0 &^ bc4)
226 - a[19] = bc4 ^ (bc1 &^ bc0)
227 -
228 - // Round 3
229 - bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20]
230 - bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21]
231 - bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22]
232 - bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23]
233 - bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24]
234 - d0 = bc4 ^ (bc1<<1 | bc1>>63)
235 - d1 = bc0 ^ (bc2<<1 | bc2>>63)
236 - d2 = bc1 ^ (bc3<<1 | bc3>>63)
237 - d3 = bc2 ^ (bc4<<1 | bc4>>63)
238 - d4 = bc3 ^ (bc0<<1 | bc0>>63)
239 -
240 - bc0 = a[0] ^ d0
241 - t = a[11] ^ d1
242 - bc1 = t<<44 | t>>(64-44)
243 - t = a[22] ^ d2
244 - bc2 = t<<43 | t>>(64-43)
245 - t = a[8] ^ d3
246 - bc3 = t<<21 | t>>(64-21)
247 - t = a[19] ^ d4
248 - bc4 = t<<14 | t>>(64-14)
249 - a[0] = bc0 ^ (bc2 &^ bc1) ^ rc[i+2]
250 - a[11] = bc1 ^ (bc3 &^ bc2)
251 - a[22] = bc2 ^ (bc4 &^ bc3)
252 - a[8] = bc3 ^ (bc0 &^ bc4)
253 - a[19] = bc4 ^ (bc1 &^ bc0)
254 -
255 - t = a[15] ^ d0
256 - bc2 = t<<3 | t>>(64-3)
257 - t = a[1] ^ d1
258 - bc3 = t<<45 | t>>(64-45)
259 - t = a[12] ^ d2
260 - bc4 = t<<61 | t>>(64-61)
261 - t = a[23] ^ d3
262 - bc0 = t<<28 | t>>(64-28)
263 - t = a[9] ^ d4
264 - bc1 = t<<20 | t>>(64-20)
265 - a[15] = bc0 ^ (bc2 &^ bc1)
266 - a[1] = bc1 ^ (bc3 &^ bc2)
267 - a[12] = bc2 ^ (bc4 &^ bc3)
268 - a[23] = bc3 ^ (bc0 &^ bc4)
269 - a[9] = bc4 ^ (bc1 &^ bc0)
270 -
271 - t = a[5] ^ d0
272 - bc4 = t<<18 | t>>(64-18)
273 - t = a[16] ^ d1
274 - bc0 = t<<1 | t>>(64-1)
275 - t = a[2] ^ d2
276 - bc1 = t<<6 | t>>(64-6)
277 - t = a[13] ^ d3
278 - bc2 = t<<25 | t>>(64-25)
279 - t = a[24] ^ d4
280 - bc3 = t<<8 | t>>(64-8)
281 - a[5] = bc0 ^ (bc2 &^ bc1)
282 - a[16] = bc1 ^ (bc3 &^ bc2)
283 - a[2] = bc2 ^ (bc4 &^ bc3)
284 - a[13] = bc3 ^ (bc0 &^ bc4)
285 - a[24] = bc4 ^ (bc1 &^ bc0)
286 -
287 - t = a[20] ^ d0
288 - bc1 = t<<36 | t>>(64-36)
289 - t = a[6] ^ d1
290 - bc2 = t<<10 | t>>(64-10)
291 - t = a[17] ^ d2
292 - bc3 = t<<15 | t>>(64-15)
293 - t = a[3] ^ d3
294 - bc4 = t<<56 | t>>(64-56)
295 - t = a[14] ^ d4
296 - bc0 = t<<27 | t>>(64-27)
297 - a[20] = bc0 ^ (bc2 &^ bc1)
298 - a[6] = bc1 ^ (bc3 &^ bc2)
299 - a[17] = bc2 ^ (bc4 &^ bc3)
300 - a[3] = bc3 ^ (bc0 &^ bc4)
301 - a[14] = bc4 ^ (bc1 &^ bc0)
302 -
303 - t = a[10] ^ d0
304 - bc3 = t<<41 | t>>(64-41)
305 - t = a[21] ^ d1
306 - bc4 = t<<2 | t>>(64-2)
307 - t = a[7] ^ d2
308 - bc0 = t<<62 | t>>(64-62)
309 - t = a[18] ^ d3
310 - bc1 = t<<55 | t>>(64-55)
311 - t = a[4] ^ d4
312 - bc2 = t<<39 | t>>(64-39)
313 - a[10] = bc0 ^ (bc2 &^ bc1)
314 - a[21] = bc1 ^ (bc3 &^ bc2)
315 - a[7] = bc2 ^ (bc4 &^ bc3)
316 - a[18] = bc3 ^ (bc0 &^ bc4)
317 - a[4] = bc4 ^ (bc1 &^ bc0)
318 -
319 - // Round 4
320 - bc0 = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20]
321 - bc1 = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21]
322 - bc2 = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22]
323 - bc3 = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23]
324 - bc4 = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24]
325 - d0 = bc4 ^ (bc1<<1 | bc1>>63)
326 - d1 = bc0 ^ (bc2<<1 | bc2>>63)
327 - d2 = bc1 ^ (bc3<<1 | bc3>>63)
328 - d3 = bc2 ^ (bc4<<1 | bc4>>63)
329 - d4 = bc3 ^ (bc0<<1 | bc0>>63)
330 -
331 - bc0 = a[0] ^ d0
332 - t = a[1] ^ d1
333 - bc1 = t<<44 | t>>(64-44)
334 - t = a[2] ^ d2
335 - bc2 = t<<43 | t>>(64-43)
336 - t = a[3] ^ d3
337 - bc3 = t<<21 | t>>(64-21)
338 - t = a[4] ^ d4
339 - bc4 = t<<14 | t>>(64-14)
340 - a[0] = bc0 ^ (bc2 &^ bc1) ^ rc[i+3]
341 - a[1] = bc1 ^ (bc3 &^ bc2)
342 - a[2] = bc2 ^ (bc4 &^ bc3)
343 - a[3] = bc3 ^ (bc0 &^ bc4)
344 - a[4] = bc4 ^ (bc1 &^ bc0)
345 -
346 - t = a[5] ^ d0
347 - bc2 = t<<3 | t>>(64-3)
348 - t = a[6] ^ d1
349 - bc3 = t<<45 | t>>(64-45)
350 - t = a[7] ^ d2
351 - bc4 = t<<61 | t>>(64-61)
352 - t = a[8] ^ d3
353 - bc0 = t<<28 | t>>(64-28)
354 - t = a[9] ^ d4
355 - bc1 = t<<20 | t>>(64-20)
356 - a[5] = bc0 ^ (bc2 &^ bc1)
357 - a[6] = bc1 ^ (bc3 &^ bc2)
358 - a[7] = bc2 ^ (bc4 &^ bc3)
359 - a[8] = bc3 ^ (bc0 &^ bc4)
360 - a[9] = bc4 ^ (bc1 &^ bc0)
361 -
362 - t = a[10] ^ d0
363 - bc4 = t<<18 | t>>(64-18)
364 - t = a[11] ^ d1
365 - bc0 = t<<1 | t>>(64-1)
366 - t = a[12] ^ d2
367 - bc1 = t<<6 | t>>(64-6)
368 - t = a[13] ^ d3
369 - bc2 = t<<25 | t>>(64-25)
370 - t = a[14] ^ d4
371 - bc3 = t<<8 | t>>(64-8)
372 - a[10] = bc0 ^ (bc2 &^ bc1)
373 - a[11] = bc1 ^ (bc3 &^ bc2)
374 - a[12] = bc2 ^ (bc4 &^ bc3)
375 - a[13] = bc3 ^ (bc0 &^ bc4)
376 - a[14] = bc4 ^ (bc1 &^ bc0)
377 -
378 - t = a[15] ^ d0
379 - bc1 = t<<36 | t>>(64-36)
380 - t = a[16] ^ d1
381 - bc2 = t<<10 | t>>(64-10)
382 - t = a[17] ^ d2
383 - bc3 = t<<15 | t>>(64-15)
384 - t = a[18] ^ d3
385 - bc4 = t<<56 | t>>(64-56)
386 - t = a[19] ^ d4
387 - bc0 = t<<27 | t>>(64-27)
388 - a[15] = bc0 ^ (bc2 &^ bc1)
389 - a[16] = bc1 ^ (bc3 &^ bc2)
390 - a[17] = bc2 ^ (bc4 &^ bc3)
391 - a[18] = bc3 ^ (bc0 &^ bc4)
392 - a[19] = bc4 ^ (bc1 &^ bc0)
393 -
394 - t = a[20] ^ d0
395 - bc3 = t<<41 | t>>(64-41)
396 - t = a[21] ^ d1
397 - bc4 = t<<2 | t>>(64-2)
398 - t = a[22] ^ d2
399 - bc0 = t<<62 | t>>(64-62)
400 - t = a[23] ^ d3
401 - bc1 = t<<55 | t>>(64-55)
402 - t = a[24] ^ d4
403 - bc2 = t<<39 | t>>(64-39)
404 - a[20] = bc0 ^ (bc2 &^ bc1)
405 - a[21] = bc1 ^ (bc3 &^ bc2)
406 - a[22] = bc2 ^ (bc4 &^ bc3)
407 - a[23] = bc3 ^ (bc0 &^ bc4)
408 - a[24] = bc4 ^ (bc1 &^ bc0)
409 - }
410 -}
Godeps/_workspace/src/golang.org/x/crypto/sha3/register.go deleted
-18
@@ -1,18 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build go1.4
6 -
7 -package sha3
8 -
9 -import (
10 - "crypto"
11 -)
12 -
13 -func init() {
14 - crypto.RegisterHash(crypto.SHA3_224, New224)
15 - crypto.RegisterHash(crypto.SHA3_256, New256)
16 - crypto.RegisterHash(crypto.SHA3_384, New384)
17 - crypto.RegisterHash(crypto.SHA3_512, New512)
18 -}
Godeps/_workspace/src/golang.org/x/crypto/sha3/sha3.go deleted
-193
@@ -1,193 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package sha3
6 -
7 -// spongeDirection indicates the direction bytes are flowing through the sponge.
8 -type spongeDirection int
9 -
10 -const (
11 - // spongeAbsorbing indicates that the sponge is absorbing input.
12 - spongeAbsorbing spongeDirection = iota
13 - // spongeSqueezing indicates that the sponge is being squeezed.
14 - spongeSqueezing
15 -)
16 -
17 -const (
18 - // maxRate is the maximum size of the internal buffer. SHAKE-256
19 - // currently needs the largest buffer.
20 - maxRate = 168
21 -)
22 -
23 -type state struct {
24 - // Generic sponge components.
25 - a [25]uint64 // main state of the hash
26 - buf []byte // points into storage
27 - rate int // the number of bytes of state to use
28 -
29 - // dsbyte contains the "domain separation" bits and the first bit of
30 - // the padding. Sections 6.1 and 6.2 of [1] separate the outputs of the
31 - // SHA-3 and SHAKE functions by appending bitstrings to the message.
32 - // Using a little-endian bit-ordering convention, these are "01" for SHA-3
33 - // and "1111" for SHAKE, or 00000010b and 00001111b, respectively. Then the
34 - // padding rule from section 5.1 is applied to pad the message to a multiple
35 - // of the rate, which involves adding a "1" bit, zero or more "0" bits, and
36 - // a final "1" bit. We merge the first "1" bit from the padding into dsbyte,
37 - // giving 00000110b (0x06) and 00011111b (0x1f).
38 - // [1] http://csrc.nist.gov/publications/drafts/fips-202/fips_202_draft.pdf
39 - // "Draft FIPS 202: SHA-3 Standard: Permutation-Based Hash and
40 - // Extendable-Output Functions (May 2014)"
41 - dsbyte byte
42 - storage [maxRate]byte
43 -
44 - // Specific to SHA-3 and SHAKE.
45 - fixedOutput bool // whether this is a fixed-ouput-length instance
46 - outputLen int // the default output size in bytes
47 - state spongeDirection // whether the sponge is absorbing or squeezing
48 -}
49 -
50 -// BlockSize returns the rate of sponge underlying this hash function.
51 -func (d *state) BlockSize() int { return d.rate }
52 -
53 -// Size returns the output size of the hash function in bytes.
54 -func (d *state) Size() int { return d.outputLen }
55 -
56 -// Reset clears the internal state by zeroing the sponge state and
57 -// the byte buffer, and setting Sponge.state to absorbing.
58 -func (d *state) Reset() {
59 - // Zero the permutation's state.
60 - for i := range d.a {
61 - d.a[i] = 0
62 - }
63 - d.state = spongeAbsorbing
64 - d.buf = d.storage[:0]
65 -}
66 -
67 -func (d *state) clone() *state {
68 - ret := *d
69 - if ret.state == spongeAbsorbing {
70 - ret.buf = ret.storage[:len(ret.buf)]
71 - } else {
72 - ret.buf = ret.storage[d.rate-cap(d.buf) : d.rate]
73 - }
74 -
75 - return &ret
76 -}
77 -
78 -// permute applies the KeccakF-1600 permutation. It handles
79 -// any input-output buffering.
80 -func (d *state) permute() {
81 - switch d.state {
82 - case spongeAbsorbing:
83 - // If we're absorbing, we need to xor the input into the state
84 - // before applying the permutation.
85 - xorIn(d, d.buf)
86 - d.buf = d.storage[:0]
87 - keccakF1600(&d.a)
88 - case spongeSqueezing:
89 - // If we're squeezing, we need to apply the permutatin before
90 - // copying more output.
91 - keccakF1600(&d.a)
92 - d.buf = d.storage[:d.rate]
93 - copyOut(d, d.buf)
94 - }
95 -}
96 -
97 -// pads appends the domain separation bits in dsbyte, applies
98 -// the multi-bitrate 10..1 padding rule, and permutes the state.
99 -func (d *state) padAndPermute(dsbyte byte) {
100 - if d.buf == nil {
101 - d.buf = d.storage[:0]
102 - }
103 - // Pad with this instance's domain-separator bits. We know that there's
104 - // at least one byte of space in d.buf because, if it were full,
105 - // permute would have been called to empty it. dsbyte also contains the
106 - // first one bit for the padding. See the comment in the state struct.
107 - d.buf = append(d.buf, dsbyte)
108 - zerosStart := len(d.buf)
109 - d.buf = d.storage[:d.rate]
110 - for i := zerosStart; i < d.rate; i++ {
111 - d.buf[i] = 0
112 - }
113 - // This adds the final one bit for the padding. Because of the way that
114 - // bits are numbered from the LSB upwards, the final bit is the MSB of
115 - // the last byte.
116 - d.buf[d.rate-1] ^= 0x80
117 - // Apply the permutation
118 - d.permute()
119 - d.state = spongeSqueezing
120 - d.buf = d.storage[:d.rate]
121 - copyOut(d, d.buf)
122 -}
123 -
124 -// Write absorbs more data into the hash's state. It produces an error
125 -// if more data is written to the ShakeHash after writing
126 -func (d *state) Write(p []byte) (written int, err error) {
127 - if d.state != spongeAbsorbing {
128 - panic("sha3: write to sponge after read")
129 - }
130 - if d.buf == nil {
131 - d.buf = d.storage[:0]
132 - }
133 - written = len(p)
134 -
135 - for len(p) > 0 {
136 - if len(d.buf) == 0 && len(p) >= d.rate {
137 - // The fast path; absorb a full "rate" bytes of input and apply the permutation.
138 - xorIn(d, p[:d.rate])
139 - p = p[d.rate:]
140 - keccakF1600(&d.a)
141 - } else {
142 - // The slow path; buffer the input until we can fill the sponge, and then xor it in.
143 - todo := d.rate - len(d.buf)
144 - if todo > len(p) {
145 - todo = len(p)
146 - }
147 - d.buf = append(d.buf, p[:todo]...)
148 - p = p[todo:]
149 -
150 - // If the sponge is full, apply the permutation.
151 - if len(d.buf) == d.rate {
152 - d.permute()
153 - }
154 - }
155 - }
156 -
157 - return
158 -}
159 -
160 -// Read squeezes an arbitrary number of bytes from the sponge.
161 -func (d *state) Read(out []byte) (n int, err error) {
162 - // If we're still absorbing, pad and apply the permutation.
163 - if d.state == spongeAbsorbing {
164 - d.padAndPermute(d.dsbyte)
165 - }
166 -
167 - n = len(out)
168 -
169 - // Now, do the squeezing.
170 - for len(out) > 0 {
171 - n := copy(out, d.buf)
172 - d.buf = d.buf[n:]
173 - out = out[n:]
174 -
175 - // Apply the permutation if we've squeezed the sponge dry.
176 - if len(d.buf) == 0 {
177 - d.permute()
178 - }
179 - }
180 -
181 - return
182 -}
183 -
184 -// Sum applies padding to the hash state and then squeezes out the desired
185 -// number of output bytes.
186 -func (d *state) Sum(in []byte) []byte {
187 - // Make a copy of the original hash so that caller can keep writing
188 - // and summing.
189 - dup := d.clone()
190 - hash := make([]byte, dup.outputLen)
191 - dup.Read(hash)
192 - return append(in, hash...)
193 -}
Godeps/_workspace/src/golang.org/x/crypto/sha3/sha3_test.go deleted
-306
@@ -1,306 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package sha3
6 -
7 -// Tests include all the ShortMsgKATs provided by the Keccak team at
8 -// https://github.com/gvanas/KeccakCodePackage
9 -//
10 -// They only include the zero-bit case of the bitwise testvectors
11 -// published by NIST in the draft of FIPS-202.
12 -
13 -import (
14 - "bytes"
15 - "compress/flate"
16 - "encoding/hex"
17 - "encoding/json"
18 - "hash"
19 - "os"
20 - "strings"
21 - "testing"
22 -)
23 -
24 -const (
25 - testString = "brekeccakkeccak koax koax"
26 - katFilename = "testdata/keccakKats.json.deflate"
27 -)
28 -
29 -// Internal-use instances of SHAKE used to test against KATs.
30 -func newHashShake128() hash.Hash {
31 - return &state{rate: 168, dsbyte: 0x1f, outputLen: 512}
32 -}
33 -func newHashShake256() hash.Hash {
34 - return &state{rate: 136, dsbyte: 0x1f, outputLen: 512}
35 -}
36 -
37 -// testDigests contains functions returning hash.Hash instances
38 -// with output-length equal to the KAT length for both SHA-3 and
39 -// SHAKE instances.
40 -var testDigests = map[string]func() hash.Hash{
41 - "SHA3-224": New224,
42 - "SHA3-256": New256,
43 - "SHA3-384": New384,
44 - "SHA3-512": New512,
45 - "SHAKE128": newHashShake128,
46 - "SHAKE256": newHashShake256,
47 -}
48 -
49 -// testShakes contains functions that return ShakeHash instances for
50 -// testing the ShakeHash-specific interface.
51 -var testShakes = map[string]func() ShakeHash{
52 - "SHAKE128": NewShake128,
53 - "SHAKE256": NewShake256,
54 -}
55 -
56 -// decodeHex converts a hex-encoded string into a raw byte string.
57 -func decodeHex(s string) []byte {
58 - b, err := hex.DecodeString(s)
59 - if err != nil {
60 - panic(err)
61 - }
62 - return b
63 -}
64 -
65 -// structs used to marshal JSON test-cases.
66 -type KeccakKats struct {
67 - Kats map[string][]struct {
68 - Digest string `json:"digest"`
69 - Length int64 `json:"length"`
70 - Message string `json:"message"`
71 - }
72 -}
73 -
74 -func testUnalignedAndGeneric(t *testing.T, testf func(impl string)) {
75 - xorInOrig, copyOutOrig := xorIn, copyOut
76 - xorIn, copyOut = xorInGeneric, copyOutGeneric
77 - testf("generic")
78 - if xorImplementationUnaligned != "generic" {
79 - xorIn, copyOut = xorInUnaligned, copyOutUnaligned
80 - testf("unaligned")
81 - }
82 - xorIn, copyOut = xorInOrig, copyOutOrig
83 -}
84 -
85 -// TestKeccakKats tests the SHA-3 and Shake implementations against all the
86 -// ShortMsgKATs from https://github.com/gvanas/KeccakCodePackage
87 -// (The testvectors are stored in keccakKats.json.deflate due to their length.)
88 -func TestKeccakKats(t *testing.T) {
89 - testUnalignedAndGeneric(t, func(impl string) {
90 - // Read the KATs.
91 - deflated, err := os.Open(katFilename)
92 - if err != nil {
93 - t.Errorf("error opening %s: %s", katFilename, err)
94 - }
95 - file := flate.NewReader(deflated)
96 - dec := json.NewDecoder(file)
97 - var katSet KeccakKats
98 - err = dec.Decode(&katSet)
99 - if err != nil {
100 - t.Errorf("error decoding KATs: %s", err)
101 - }
102 -
103 - // Do the KATs.
104 - for functionName, kats := range katSet.Kats {
105 - d := testDigests[functionName]()
106 - for _, kat := range kats {
107 - d.Reset()
108 - in, err := hex.DecodeString(kat.Message)
109 - if err != nil {
110 - t.Errorf("error decoding KAT: %s", err)
111 - }
112 - d.Write(in[:kat.Length/8])
113 - got := strings.ToUpper(hex.EncodeToString(d.Sum(nil)))
114 - if got != kat.Digest {
115 - t.Errorf("function=%s, implementation=%s, length=%d\nmessage:\n %s\ngot:\n %s\nwanted:\n %s",
116 - functionName, impl, kat.Length, kat.Message, got, kat.Digest)
117 - t.Logf("wanted %+v", kat)
118 - t.FailNow()
119 - }
120 - continue
121 - }
122 - }
123 - })
124 -}
125 -
126 -// TestUnalignedWrite tests that writing data in an arbitrary pattern with
127 -// small input buffers.
128 -func testUnalignedWrite(t *testing.T) {
129 - testUnalignedAndGeneric(t, func(impl string) {
130 - buf := sequentialBytes(0x10000)
131 - for alg, df := range testDigests {
132 - d := df()
133 - d.Reset()
134 - d.Write(buf)
135 - want := d.Sum(nil)
136 - d.Reset()
137 - for i := 0; i < len(buf); {
138 - // Cycle through offsets which make a 137 byte sequence.
139 - // Because 137 is prime this sequence should exercise all corner cases.
140 - offsets := [17]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1}
141 - for _, j := range offsets {
142 - if v := len(buf) - i; v < j {
143 - j = v
144 - }
145 - d.Write(buf[i : i+j])
146 - i += j
147 - }
148 - }
149 - got := d.Sum(nil)
150 - if !bytes.Equal(got, want) {
151 - t.Errorf("Unaligned writes, implementation=%s, alg=%s\ngot %q, want %q", impl, alg, got, want)
152 - }
153 - }
154 - })
155 -}
156 -
157 -// TestAppend checks that appending works when reallocation is necessary.
158 -func TestAppend(t *testing.T) {
159 - testUnalignedAndGeneric(t, func(impl string) {
160 - d := New224()
161 -
162 - for capacity := 2; capacity <= 66; capacity += 64 {
163 - // The first time around the loop, Sum will have to reallocate.
164 - // The second time, it will not.
165 - buf := make([]byte, 2, capacity)
166 - d.Reset()
167 - d.Write([]byte{0xcc})
168 - buf = d.Sum(buf)
169 - expected := "0000DF70ADC49B2E76EEE3A6931B93FA41841C3AF2CDF5B32A18B5478C39"
170 - if got := strings.ToUpper(hex.EncodeToString(buf)); got != expected {
171 - t.Errorf("got %s, want %s", got, expected)
172 - }
173 - }
174 - })
175 -}
176 -
177 -// TestAppendNoRealloc tests that appending works when no reallocation is necessary.
178 -func TestAppendNoRealloc(t *testing.T) {
179 - testUnalignedAndGeneric(t, func(impl string) {
180 - buf := make([]byte, 1, 200)
181 - d := New224()
182 - d.Write([]byte{0xcc})
183 - buf = d.Sum(buf)
184 - expected := "00DF70ADC49B2E76EEE3A6931B93FA41841C3AF2CDF5B32A18B5478C39"
185 - if got := strings.ToUpper(hex.EncodeToString(buf)); got != expected {
186 - t.Errorf("%s: got %s, want %s", impl, got, expected)
187 - }
188 - })
189 -}
190 -
191 -// TestSqueezing checks that squeezing the full output a single time produces
192 -// the same output as repeatedly squeezing the instance.
193 -func TestSqueezing(t *testing.T) {
194 - testUnalignedAndGeneric(t, func(impl string) {
195 - for functionName, newShakeHash := range testShakes {
196 - d0 := newShakeHash()
197 - d0.Write([]byte(testString))
198 - ref := make([]byte, 32)
199 - d0.Read(ref)
200 -
201 - d1 := newShakeHash()
202 - d1.Write([]byte(testString))
203 - var multiple []byte
204 - for _ = range ref {
205 - one := make([]byte, 1)
206 - d1.Read(one)
207 - multiple = append(multiple, one...)
208 - }
209 - if !bytes.Equal(ref, multiple) {
210 - t.Errorf("%s (%s): squeezing %d bytes one at a time failed", functionName, impl, len(ref))
211 - }
212 - }
213 - })
214 -}
215 -
216 -// sequentialBytes produces a buffer of size consecutive bytes 0x00, 0x01, ..., used for testing.
217 -func sequentialBytes(size int) []byte {
218 - result := make([]byte, size)
219 - for i := range result {
220 - result[i] = byte(i)
221 - }
222 - return result
223 -}
224 -
225 -// BenchmarkPermutationFunction measures the speed of the permutation function
226 -// with no input data.
227 -func BenchmarkPermutationFunction(b *testing.B) {
228 - b.SetBytes(int64(200))
229 - var lanes [25]uint64
230 - for i := 0; i < b.N; i++ {
231 - keccakF1600(&lanes)
232 - }
233 -}
234 -
235 -// benchmarkHash tests the speed to hash num buffers of buflen each.
236 -func benchmarkHash(b *testing.B, h hash.Hash, size, num int) {
237 - b.StopTimer()
238 - h.Reset()
239 - data := sequentialBytes(size)
240 - b.SetBytes(int64(size * num))
241 - b.StartTimer()
242 -
243 - var state []byte
244 - for i := 0; i < b.N; i++ {
245 - for j := 0; j < num; j++ {
246 - h.Write(data)
247 - }
248 - state = h.Sum(state[:0])
249 - }
250 - b.StopTimer()
251 - h.Reset()
252 -}
253 -
254 -// benchmarkShake is specialized to the Shake instances, which don't
255 -// require a copy on reading output.
256 -func benchmarkShake(b *testing.B, h ShakeHash, size, num int) {
257 - b.StopTimer()
258 - h.Reset()
259 - data := sequentialBytes(size)
260 - d := make([]byte, 32)
261 -
262 - b.SetBytes(int64(size * num))
263 - b.StartTimer()
264 -
265 - for i := 0; i < b.N; i++ {
266 - h.Reset()
267 - for j := 0; j < num; j++ {
268 - h.Write(data)
269 - }
270 - h.Read(d)
271 - }
272 -}
273 -
274 -func BenchmarkSha3_512_MTU(b *testing.B) { benchmarkHash(b, New512(), 1350, 1) }
275 -func BenchmarkSha3_384_MTU(b *testing.B) { benchmarkHash(b, New384(), 1350, 1) }
276 -func BenchmarkSha3_256_MTU(b *testing.B) { benchmarkHash(b, New256(), 1350, 1) }
277 -func BenchmarkSha3_224_MTU(b *testing.B) { benchmarkHash(b, New224(), 1350, 1) }
278 -
279 -func BenchmarkShake128_MTU(b *testing.B) { benchmarkShake(b, NewShake128(), 1350, 1) }
280 -func BenchmarkShake256_MTU(b *testing.B) { benchmarkShake(b, NewShake256(), 1350, 1) }
281 -func BenchmarkShake256_16x(b *testing.B) { benchmarkShake(b, NewShake256(), 16, 1024) }
282 -func BenchmarkShake256_1MiB(b *testing.B) { benchmarkShake(b, NewShake256(), 1024, 1024) }
283 -
284 -func BenchmarkSha3_512_1MiB(b *testing.B) { benchmarkHash(b, New512(), 1024, 1024) }
285 -
286 -func Example_sum() {
287 - buf := []byte("some data to hash")
288 - // A hash needs to be 64 bytes long to have 256-bit collision resistance.
289 - h := make([]byte, 64)
290 - // Compute a 64-byte hash of buf and put it in h.
291 - ShakeSum256(h, buf)
292 -}
293 -
294 -func Example_mac() {
295 - k := []byte("this is a secret key; you should generate a strong random key that's at least 32 bytes long")
296 - buf := []byte("and this is some data to authenticate")
297 - // A MAC with 32 bytes of output has 256-bit security strength -- if you use at least a 32-byte-long key.
298 - h := make([]byte, 32)
299 - d := NewShake256()
300 - // Write the key into the hash.
301 - d.Write(k)
302 - // Now write the data.
303 - d.Write(buf)
304 - // Read 32 bytes of output from the hash into h.
305 - d.Read(h)
306 -}
Godeps/_workspace/src/golang.org/x/crypto/sha3/shake.go deleted
-60
@@ -1,60 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package sha3
6 -
7 -// This file defines the ShakeHash interface, and provides
8 -// functions for creating SHAKE instances, as well as utility
9 -// functions for hashing bytes to arbitrary-length output.
10 -
11 -import (
12 - "io"
13 -)
14 -
15 -// ShakeHash defines the interface to hash functions that
16 -// support arbitrary-length output.
17 -type ShakeHash interface {
18 - // Write absorbs more data into the hash's state. It panics if input is
19 - // written to it after output has been read from it.
20 - io.Writer
21 -
22 - // Read reads more output from the hash; reading affects the hash's
23 - // state. (ShakeHash.Read is thus very different from Hash.Sum)
24 - // It never returns an error.
25 - io.Reader
26 -
27 - // Clone returns a copy of the ShakeHash in its current state.
28 - Clone() ShakeHash
29 -
30 - // Reset resets the ShakeHash to its initial state.
31 - Reset()
32 -}
33 -
34 -func (d *state) Clone() ShakeHash {
35 - return d.clone()
36 -}
37 -
38 -// NewShake128 creates a new SHAKE128 variable-output-length ShakeHash.
39 -// Its generic security strength is 128 bits against all attacks if at
40 -// least 32 bytes of its output are used.
41 -func NewShake128() ShakeHash { return &state{rate: 168, dsbyte: 0x1f} }
42 -
43 -// NewShake256 creates a new SHAKE128 variable-output-length ShakeHash.
44 -// Its generic security strength is 256 bits against all attacks if
45 -// at least 64 bytes of its output are used.
46 -func NewShake256() ShakeHash { return &state{rate: 136, dsbyte: 0x1f} }
47 -
48 -// ShakeSum128 writes an arbitrary-length digest of data into hash.
49 -func ShakeSum128(hash, data []byte) {
50 - h := NewShake128()
51 - h.Write(data)
52 - h.Read(hash)
53 -}
54 -
55 -// ShakeSum256 writes an arbitrary-length digest of data into hash.
56 -func ShakeSum256(hash, data []byte) {
57 - h := NewShake256()
58 - h.Write(data)
59 - h.Read(hash)
60 -}
Godeps/_workspace/src/golang.org/x/crypto/sha3/testdata/keccakKats.json.deflate
Binary files a/Godeps/_workspace/src/golang.org/x/crypto/sha3/testdata/keccakKats.json.deflate and /dev/null differ
Godeps/_workspace/src/golang.org/x/crypto/sha3/xor.go deleted
-16
@@ -1,16 +0,0 @@
1 -// Copyright 2015 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build !amd64,!386 appengine
6 -
7 -package sha3
8 -
9 -var (
10 - xorIn = xorInGeneric
11 - copyOut = copyOutGeneric
12 - xorInUnaligned = xorInGeneric
13 - copyOutUnaligned = copyOutGeneric
14 -)
15 -
16 -const xorImplementationUnaligned = "generic"
Godeps/_workspace/src/golang.org/x/crypto/sha3/xor_generic.go deleted
-28
@@ -1,28 +0,0 @@
1 -// Copyright 2015 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package sha3
6 -
7 -import "encoding/binary"
8 -
9 -// xorInGeneric xors the bytes in buf into the state; it
10 -// makes no non-portable assumptions about memory layout
11 -// or alignment.
12 -func xorInGeneric(d *state, buf []byte) {
13 - n := len(buf) / 8
14 -
15 - for i := 0; i < n; i++ {
16 - a := binary.LittleEndian.Uint64(buf)
17 - d.a[i] ^= a
18 - buf = buf[8:]
19 - }
20 -}
21 -
22 -// copyOutGeneric copies ulint64s to a byte buffer.
23 -func copyOutGeneric(d *state, b []byte) {
24 - for i := 0; len(b) >= 8; i++ {
25 - binary.LittleEndian.PutUint64(b, d.a[i])
26 - b = b[8:]
27 - }
28 -}
Godeps/_workspace/src/golang.org/x/crypto/sha3/xor_unaligned.go deleted
-58
@@ -1,58 +0,0 @@
1 -// Copyright 2015 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build amd64 386
6 -// +build !appengine
7 -
8 -package sha3
9 -
10 -import "unsafe"
11 -
12 -func xorInUnaligned(d *state, buf []byte) {
13 - bw := (*[maxRate / 8]uint64)(unsafe.Pointer(&buf[0]))
14 - n := len(buf)
15 - if n >= 72 {
16 - d.a[0] ^= bw[0]
17 - d.a[1] ^= bw[1]
18 - d.a[2] ^= bw[2]
19 - d.a[3] ^= bw[3]
20 - d.a[4] ^= bw[4]
21 - d.a[5] ^= bw[5]
22 - d.a[6] ^= bw[6]
23 - d.a[7] ^= bw[7]
24 - d.a[8] ^= bw[8]
25 - }
26 - if n >= 104 {
27 - d.a[9] ^= bw[9]
28 - d.a[10] ^= bw[10]
29 - d.a[11] ^= bw[11]
30 - d.a[12] ^= bw[12]
31 - }
32 - if n >= 136 {
33 - d.a[13] ^= bw[13]
34 - d.a[14] ^= bw[14]
35 - d.a[15] ^= bw[15]
36 - d.a[16] ^= bw[16]
37 - }
38 - if n >= 144 {
39 - d.a[17] ^= bw[17]
40 - }
41 - if n >= 168 {
42 - d.a[18] ^= bw[18]
43 - d.a[19] ^= bw[19]
44 - d.a[20] ^= bw[20]
45 - }
46 -}
47 -
48 -func copyOutUnaligned(d *state, buf []byte) {
49 - ab := (*[maxRate]uint8)(unsafe.Pointer(&d.a[0]))
50 - copy(buf, ab[:])
51 -}
52 -
53 -var (
54 - xorIn = xorInUnaligned
55 - copyOut = copyOutUnaligned
56 -)
57 -
58 -const xorImplementationUnaligned = "unaligned"
Godeps/_workspace/src/golang.org/x/net/internal/iana/const.go deleted
-182
@@ -1,182 +0,0 @@
1 -// go generate gen.go
2 -// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
3 -
4 -// Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).
5 -package iana
6 -
7 -// Differentiated Services Field Codepoints (DSCP), Updated: 2013-06-25
8 -const (
9 - DiffServCS0 = 0x0 // CS0
10 - DiffServCS1 = 0x20 // CS1
11 - DiffServCS2 = 0x40 // CS2
12 - DiffServCS3 = 0x60 // CS3
13 - DiffServCS4 = 0x80 // CS4
14 - DiffServCS5 = 0xa0 // CS5
15 - DiffServCS6 = 0xc0 // CS6
16 - DiffServCS7 = 0xe0 // CS7
17 - DiffServAF11 = 0x28 // AF11
18 - DiffServAF12 = 0x30 // AF12
19 - DiffServAF13 = 0x38 // AF13
20 - DiffServAF21 = 0x48 // AF21
21 - DiffServAF22 = 0x50 // AF22
22 - DiffServAF23 = 0x58 // AF23
23 - DiffServAF31 = 0x68 // AF31
24 - DiffServAF32 = 0x70 // AF32
25 - DiffServAF33 = 0x78 // AF33
26 - DiffServAF41 = 0x88 // AF41
27 - DiffServAF42 = 0x90 // AF42
28 - DiffServAF43 = 0x98 // AF43
29 - DiffServEFPHB = 0xb8 // EF PHB
30 - DiffServVOICEADMIT = 0xb0 // VOICE-ADMIT
31 -)
32 -
33 -// IPv4 TOS Byte and IPv6 Traffic Class Octet, Updated: 2001-09-06
34 -const (
35 - NotECNTransport = 0x0 // Not-ECT (Not ECN-Capable Transport)
36 - ECNTransport1 = 0x1 // ECT(1) (ECN-Capable Transport(1))
37 - ECNTransport0 = 0x2 // ECT(0) (ECN-Capable Transport(0))
38 - CongestionExperienced = 0x3 // CE (Congestion Experienced)
39 -)
40 -
41 -// Protocol Numbers, Updated: 2015-01-06
42 -const (
43 - ProtocolIP = 0 // IPv4 encapsulation, pseudo protocol number
44 - ProtocolHOPOPT = 0 // IPv6 Hop-by-Hop Option
45 - ProtocolICMP = 1 // Internet Control Message
46 - ProtocolIGMP = 2 // Internet Group Management
47 - ProtocolGGP = 3 // Gateway-to-Gateway
48 - ProtocolIPv4 = 4 // IPv4 encapsulation
49 - ProtocolST = 5 // Stream
50 - ProtocolTCP = 6 // Transmission Control
51 - ProtocolCBT = 7 // CBT
52 - ProtocolEGP = 8 // Exterior Gateway Protocol
53 - ProtocolIGP = 9 // any private interior gateway (used by Cisco for their IGRP)
54 - ProtocolBBNRCCMON = 10 // BBN RCC Monitoring
55 - ProtocolNVPII = 11 // Network Voice Protocol
56 - ProtocolPUP = 12 // PUP
57 - ProtocolARGUS = 13 // ARGUS
58 - ProtocolEMCON = 14 // EMCON
59 - ProtocolXNET = 15 // Cross Net Debugger
60 - ProtocolCHAOS = 16 // Chaos
61 - ProtocolUDP = 17 // User Datagram
62 - ProtocolMUX = 18 // Multiplexing
63 - ProtocolDCNMEAS = 19 // DCN Measurement Subsystems
64 - ProtocolHMP = 20 // Host Monitoring
65 - ProtocolPRM = 21 // Packet Radio Measurement
66 - ProtocolXNSIDP = 22 // XEROX NS IDP
67 - ProtocolTRUNK1 = 23 // Trunk-1
68 - ProtocolTRUNK2 = 24 // Trunk-2
69 - ProtocolLEAF1 = 25 // Leaf-1
70 - ProtocolLEAF2 = 26 // Leaf-2
71 - ProtocolRDP = 27 // Reliable Data Protocol
72 - ProtocolIRTP = 28 // Internet Reliable Transaction
73 - ProtocolISOTP4 = 29 // ISO Transport Protocol Class 4
74 - ProtocolNETBLT = 30 // Bulk Data Transfer Protocol
75 - ProtocolMFENSP = 31 // MFE Network Services Protocol
76 - ProtocolMERITINP = 32 // MERIT Internodal Protocol
77 - ProtocolDCCP = 33 // Datagram Congestion Control Protocol
78 - Protocol3PC = 34 // Third Party Connect Protocol
79 - ProtocolIDPR = 35 // Inter-Domain Policy Routing Protocol
80 - ProtocolXTP = 36 // XTP
81 - ProtocolDDP = 37 // Datagram Delivery Protocol
82 - ProtocolIDPRCMTP = 38 // IDPR Control Message Transport Proto
83 - ProtocolTPPP = 39 // TP++ Transport Protocol
84 - ProtocolIL = 40 // IL Transport Protocol
85 - ProtocolIPv6 = 41 // IPv6 encapsulation
86 - ProtocolSDRP = 42 // Source Demand Routing Protocol
87 - ProtocolIPv6Route = 43 // Routing Header for IPv6
88 - ProtocolIPv6Frag = 44 // Fragment Header for IPv6
89 - ProtocolIDRP = 45 // Inter-Domain Routing Protocol
90 - ProtocolRSVP = 46 // Reservation Protocol
91 - ProtocolGRE = 47 // Generic Routing Encapsulation
92 - ProtocolDSR = 48 // Dynamic Source Routing Protocol
93 - ProtocolBNA = 49 // BNA
94 - ProtocolESP = 50 // Encap Security Payload
95 - ProtocolAH = 51 // Authentication Header
96 - ProtocolINLSP = 52 // Integrated Net Layer Security TUBA
97 - ProtocolNARP = 54 // NBMA Address Resolution Protocol
98 - ProtocolMOBILE = 55 // IP Mobility
99 - ProtocolTLSP = 56 // Transport Layer Security Protocol using Kryptonet key management
100 - ProtocolSKIP = 57 // SKIP
101 - ProtocolIPv6ICMP = 58 // ICMP for IPv6
102 - ProtocolIPv6NoNxt = 59 // No Next Header for IPv6
103 - ProtocolIPv6Opts = 60 // Destination Options for IPv6
104 - ProtocolCFTP = 62 // CFTP
105 - ProtocolSATEXPAK = 64 // SATNET and Backroom EXPAK
106 - ProtocolKRYPTOLAN = 65 // Kryptolan
107 - ProtocolRVD = 66 // MIT Remote Virtual Disk Protocol
108 - ProtocolIPPC = 67 // Internet Pluribus Packet Core
109 - ProtocolSATMON = 69 // SATNET Monitoring
110 - ProtocolVISA = 70 // VISA Protocol
111 - ProtocolIPCV = 71 // Internet Packet Core Utility
112 - ProtocolCPNX = 72 // Computer Protocol Network Executive
113 - ProtocolCPHB = 73 // Computer Protocol Heart Beat
114 - ProtocolWSN = 74 // Wang Span Network
115 - ProtocolPVP = 75 // Packet Video Protocol
116 - ProtocolBRSATMON = 76 // Backroom SATNET Monitoring
117 - ProtocolSUNND = 77 // SUN ND PROTOCOL-Temporary
118 - ProtocolWBMON = 78 // WIDEBAND Monitoring
119 - ProtocolWBEXPAK = 79 // WIDEBAND EXPAK
120 - ProtocolISOIP = 80 // ISO Internet Protocol
121 - ProtocolVMTP = 81 // VMTP
122 - ProtocolSECUREVMTP = 82 // SECURE-VMTP
123 - ProtocolVINES = 83 // VINES
124 - ProtocolTTP = 84 // Transaction Transport Protocol
125 - ProtocolIPTM = 84 // Internet Protocol Traffic Manager
126 - ProtocolNSFNETIGP = 85 // NSFNET-IGP
127 - ProtocolDGP = 86 // Dissimilar Gateway Protocol
128 - ProtocolTCF = 87 // TCF
129 - ProtocolEIGRP = 88 // EIGRP
130 - ProtocolOSPFIGP = 89 // OSPFIGP
131 - ProtocolSpriteRPC = 90 // Sprite RPC Protocol
132 - ProtocolLARP = 91 // Locus Address Resolution Protocol
133 - ProtocolMTP = 92 // Multicast Transport Protocol
134 - ProtocolAX25 = 93 // AX.25 Frames
135 - ProtocolIPIP = 94 // IP-within-IP Encapsulation Protocol
136 - ProtocolSCCSP = 96 // Semaphore Communications Sec. Pro.
137 - ProtocolETHERIP = 97 // Ethernet-within-IP Encapsulation
138 - ProtocolENCAP = 98 // Encapsulation Header
139 - ProtocolGMTP = 100 // GMTP
140 - ProtocolIFMP = 101 // Ipsilon Flow Management Protocol
141 - ProtocolPNNI = 102 // PNNI over IP
142 - ProtocolPIM = 103 // Protocol Independent Multicast
143 - ProtocolARIS = 104 // ARIS
144 - ProtocolSCPS = 105 // SCPS
145 - ProtocolQNX = 106 // QNX
146 - ProtocolAN = 107 // Active Networks
147 - ProtocolIPComp = 108 // IP Payload Compression Protocol
148 - ProtocolSNP = 109 // Sitara Networks Protocol
149 - ProtocolCompaqPeer = 110 // Compaq Peer Protocol
150 - ProtocolIPXinIP = 111 // IPX in IP
151 - ProtocolVRRP = 112 // Virtual Router Redundancy Protocol
152 - ProtocolPGM = 113 // PGM Reliable Transport Protocol
153 - ProtocolL2TP = 115 // Layer Two Tunneling Protocol
154 - ProtocolDDX = 116 // D-II Data Exchange (DDX)
155 - ProtocolIATP = 117 // Interactive Agent Transfer Protocol
156 - ProtocolSTP = 118 // Schedule Transfer Protocol
157 - ProtocolSRP = 119 // SpectraLink Radio Protocol
158 - ProtocolUTI = 120 // UTI
159 - ProtocolSMP = 121 // Simple Message Protocol
160 - ProtocolSM = 122 // Simple Multicast Protocol
161 - ProtocolPTP = 123 // Performance Transparency Protocol
162 - ProtocolISIS = 124 // ISIS over IPv4
163 - ProtocolFIRE = 125 // FIRE
164 - ProtocolCRTP = 126 // Combat Radio Transport Protocol
165 - ProtocolCRUDP = 127 // Combat Radio User Datagram
166 - ProtocolSSCOPMCE = 128 // SSCOPMCE
167 - ProtocolIPLT = 129 // IPLT
168 - ProtocolSPS = 130 // Secure Packet Shield
169 - ProtocolPIPE = 131 // Private IP Encapsulation within IP
170 - ProtocolSCTP = 132 // Stream Control Transmission Protocol
171 - ProtocolFC = 133 // Fibre Channel
172 - ProtocolRSVPE2EIGNORE = 134 // RSVP-E2E-IGNORE
173 - ProtocolMobilityHeader = 135 // Mobility Header
174 - ProtocolUDPLite = 136 // UDPLite
175 - ProtocolMPLSinIP = 137 // MPLS-in-IP
176 - ProtocolMANET = 138 // MANET Protocols
177 - ProtocolHIP = 139 // Host Identity Protocol
178 - ProtocolShim6 = 140 // Shim6 Protocol
179 - ProtocolWESP = 141 // Wrapped Encapsulating Security Payload
180 - ProtocolROHC = 142 // Robust Header Compression
181 - ProtocolReserved = 255 // Reserved
182 -)
Godeps/_workspace/src/golang.org/x/net/internal/iana/gen.go deleted
-293
@@ -1,293 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -//go:generate go run gen.go
8 -
9 -// This program generates internet protocol constants and tables by
10 -// reading IANA protocol registries.
11 -package main
12 -
13 -import (
14 - "bytes"
15 - "encoding/xml"
16 - "fmt"
17 - "go/format"
18 - "io"
19 - "io/ioutil"
20 - "net/http"
21 - "os"
22 - "strconv"
23 - "strings"
24 -)
25 -
26 -var registries = []struct {
27 - url string
28 - parse func(io.Writer, io.Reader) error
29 -}{
30 - {
31 - "http://www.iana.org/assignments/dscp-registry/dscp-registry.xml",
32 - parseDSCPRegistry,
33 - },
34 - {
35 - "http://www.iana.org/assignments/ipv4-tos-byte/ipv4-tos-byte.xml",
36 - parseTOSTCByte,
37 - },
38 - {
39 - "http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml",
40 - parseProtocolNumbers,
41 - },
42 -}
43 -
44 -func main() {
45 - var bb bytes.Buffer
46 - fmt.Fprintf(&bb, "// go generate gen.go\n")
47 - fmt.Fprintf(&bb, "// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n")
48 - fmt.Fprintf(&bb, "// Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).\n")
49 - fmt.Fprintf(&bb, `package iana // import "golang.org/x/net/internal/iana"`+"\n\n")
50 - for _, r := range registries {
51 - resp, err := http.Get(r.url)
52 - if err != nil {
53 - fmt.Fprintln(os.Stderr, err)
54 - os.Exit(1)
55 - }
56 - defer resp.Body.Close()
57 - if resp.StatusCode != http.StatusOK {
58 - fmt.Fprintf(os.Stderr, "got HTTP status code %v for %v\n", resp.StatusCode, r.url)
59 - os.Exit(1)
60 - }
61 - if err := r.parse(&bb, resp.Body); err != nil {
62 - fmt.Fprintln(os.Stderr, err)
63 - os.Exit(1)
64 - }
65 - fmt.Fprintf(&bb, "\n")
66 - }
67 - b, err := format.Source(bb.Bytes())
68 - if err != nil {
69 - fmt.Fprintln(os.Stderr, err)
70 - os.Exit(1)
71 - }
72 - if err := ioutil.WriteFile("const.go", b, 0644); err != nil {
73 - fmt.Fprintln(os.Stderr, err)
74 - os.Exit(1)
75 - }
76 -}
77 -
78 -func parseDSCPRegistry(w io.Writer, r io.Reader) error {
79 - dec := xml.NewDecoder(r)
80 - var dr dscpRegistry
81 - if err := dec.Decode(&dr); err != nil {
82 - return err
83 - }
84 - drs := dr.escape()
85 - fmt.Fprintf(w, "// %s, Updated: %s\n", dr.Title, dr.Updated)
86 - fmt.Fprintf(w, "const (\n")
87 - for _, dr := range drs {
88 - fmt.Fprintf(w, "DiffServ%s = %#x", dr.Name, dr.Value)
89 - fmt.Fprintf(w, "// %s\n", dr.OrigName)
90 - }
91 - fmt.Fprintf(w, ")\n")
92 - return nil
93 -}
94 -
95 -type dscpRegistry struct {
96 - XMLName xml.Name `xml:"registry"`
97 - Title string `xml:"title"`
98 - Updated string `xml:"updated"`
99 - Note string `xml:"note"`
100 - RegTitle string `xml:"registry>title"`
101 - PoolRecords []struct {
102 - Name string `xml:"name"`
103 - Space string `xml:"space"`
104 - } `xml:"registry>record"`
105 - Records []struct {
106 - Name string `xml:"name"`
107 - Space string `xml:"space"`
108 - } `xml:"registry>registry>record"`
109 -}
110 -
111 -type canonDSCPRecord struct {
112 - OrigName string
113 - Name string
114 - Value int
115 -}
116 -
117 -func (drr *dscpRegistry) escape() []canonDSCPRecord {
118 - drs := make([]canonDSCPRecord, len(drr.Records))
119 - sr := strings.NewReplacer(
120 - "+", "",
121 - "-", "",
122 - "/", "",
123 - ".", "",
124 - " ", "",
125 - )
126 - for i, dr := range drr.Records {
127 - s := strings.TrimSpace(dr.Name)
128 - drs[i].OrigName = s
129 - drs[i].Name = sr.Replace(s)
130 - n, err := strconv.ParseUint(dr.Space, 2, 8)
131 - if err != nil {
132 - continue
133 - }
134 - drs[i].Value = int(n) << 2
135 - }
136 - return drs
137 -}
138 -
139 -func parseTOSTCByte(w io.Writer, r io.Reader) error {
140 - dec := xml.NewDecoder(r)
141 - var ttb tosTCByte
142 - if err := dec.Decode(&ttb); err != nil {
143 - return err
144 - }
145 - trs := ttb.escape()
146 - fmt.Fprintf(w, "// %s, Updated: %s\n", ttb.Title, ttb.Updated)
147 - fmt.Fprintf(w, "const (\n")
148 - for _, tr := range trs {
149 - fmt.Fprintf(w, "%s = %#x", tr.Keyword, tr.Value)
150 - fmt.Fprintf(w, "// %s\n", tr.OrigKeyword)
151 - }
152 - fmt.Fprintf(w, ")\n")
153 - return nil
154 -}
155 -
156 -type tosTCByte struct {
157 - XMLName xml.Name `xml:"registry"`
158 - Title string `xml:"title"`
159 - Updated string `xml:"updated"`
160 - Note string `xml:"note"`
161 - RegTitle string `xml:"registry>title"`
162 - Records []struct {
163 - Binary string `xml:"binary"`
164 - Keyword string `xml:"keyword"`
165 - } `xml:"registry>record"`
166 -}
167 -
168 -type canonTOSTCByteRecord struct {
169 - OrigKeyword string
170 - Keyword string
171 - Value int
172 -}
173 -
174 -func (ttb *tosTCByte) escape() []canonTOSTCByteRecord {
175 - trs := make([]canonTOSTCByteRecord, len(ttb.Records))
176 - sr := strings.NewReplacer(
177 - "Capable", "",
178 - "(", "",
179 - ")", "",
180 - "+", "",
181 - "-", "",
182 - "/", "",
183 - ".", "",
184 - " ", "",
185 - )
186 - for i, tr := range ttb.Records {
187 - s := strings.TrimSpace(tr.Keyword)
188 - trs[i].OrigKeyword = s
189 - ss := strings.Split(s, " ")
190 - if len(ss) > 1 {
191 - trs[i].Keyword = strings.Join(ss[1:], " ")
192 - } else {
193 - trs[i].Keyword = ss[0]
194 - }
195 - trs[i].Keyword = sr.Replace(trs[i].Keyword)
196 - n, err := strconv.ParseUint(tr.Binary, 2, 8)
197 - if err != nil {
198 - continue
199 - }
200 - trs[i].Value = int(n)
201 - }
202 - return trs
203 -}
204 -
205 -func parseProtocolNumbers(w io.Writer, r io.Reader) error {
206 - dec := xml.NewDecoder(r)
207 - var pn protocolNumbers
208 - if err := dec.Decode(&pn); err != nil {
209 - return err
210 - }
211 - prs := pn.escape()
212 - prs = append([]canonProtocolRecord{{
213 - Name: "IP",
214 - Descr: "IPv4 encapsulation, pseudo protocol number",
215 - Value: 0,
216 - }}, prs...)
217 - fmt.Fprintf(w, "// %s, Updated: %s\n", pn.Title, pn.Updated)
218 - fmt.Fprintf(w, "const (\n")
219 - for _, pr := range prs {
220 - if pr.Name == "" {
221 - continue
222 - }
223 - fmt.Fprintf(w, "Protocol%s = %d", pr.Name, pr.Value)
224 - s := pr.Descr
225 - if s == "" {
226 - s = pr.OrigName
227 - }
228 - fmt.Fprintf(w, "// %s\n", s)
229 - }
230 - fmt.Fprintf(w, ")\n")
231 - return nil
232 -}
233 -
234 -type protocolNumbers struct {
235 - XMLName xml.Name `xml:"registry"`
236 - Title string `xml:"title"`
237 - Updated string `xml:"updated"`
238 - RegTitle string `xml:"registry>title"`
239 - Note string `xml:"registry>note"`
240 - Records []struct {
241 - Value string `xml:"value"`
242 - Name string `xml:"name"`
243 - Descr string `xml:"description"`
244 - } `xml:"registry>record"`
245 -}
246 -
247 -type canonProtocolRecord struct {
248 - OrigName string
249 - Name string
250 - Descr string
251 - Value int
252 -}
253 -
254 -func (pn *protocolNumbers) escape() []canonProtocolRecord {
255 - prs := make([]canonProtocolRecord, len(pn.Records))
256 - sr := strings.NewReplacer(
257 - "-in-", "in",
258 - "-within-", "within",
259 - "-over-", "over",
260 - "+", "P",
261 - "-", "",
262 - "/", "",
263 - ".", "",
264 - " ", "",
265 - )
266 - for i, pr := range pn.Records {
267 - if strings.Contains(pr.Name, "Deprecated") ||
268 - strings.Contains(pr.Name, "deprecated") {
269 - continue
270 - }
271 - prs[i].OrigName = pr.Name
272 - s := strings.TrimSpace(pr.Name)
273 - switch pr.Name {
274 - case "ISIS over IPv4":
275 - prs[i].Name = "ISIS"
276 - case "manet":
277 - prs[i].Name = "MANET"
278 - default:
279 - prs[i].Name = sr.Replace(s)
280 - }
281 - ss := strings.Split(pr.Descr, "\n")
282 - for i := range ss {
283 - ss[i] = strings.TrimSpace(ss[i])
284 - }
285 - if len(ss) > 1 {
286 - prs[i].Descr = strings.Join(ss, " ")
287 - } else {
288 - prs[i].Descr = ss[0]
289 - }
290 - prs[i].Value, _ = strconv.Atoi(pr.Value)
291 - }
292 - return prs
293 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/control.go deleted
-70
@@ -1,70 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "fmt"
9 - "net"
10 - "sync"
11 -)
12 -
13 -type rawOpt struct {
14 - sync.RWMutex
15 - cflags ControlFlags
16 -}
17 -
18 -func (c *rawOpt) set(f ControlFlags) { c.cflags |= f }
19 -func (c *rawOpt) clear(f ControlFlags) { c.cflags &^= f }
20 -func (c *rawOpt) isset(f ControlFlags) bool { return c.cflags&f != 0 }
21 -
22 -type ControlFlags uint
23 -
24 -const (
25 - FlagTTL ControlFlags = 1 << iota // pass the TTL on the received packet
26 - FlagSrc // pass the source address on the received packet
27 - FlagDst // pass the destination address on the received packet
28 - FlagInterface // pass the interface index on the received packet
29 -)
30 -
31 -// A ControlMessage represents per packet basis IP-level socket options.
32 -type ControlMessage struct {
33 - // Receiving socket options: SetControlMessage allows to
34 - // receive the options from the protocol stack using ReadFrom
35 - // method of PacketConn or RawConn.
36 - //
37 - // Specifying socket options: ControlMessage for WriteTo
38 - // method of PacketConn or RawConn allows to send the options
39 - // to the protocol stack.
40 - //
41 - TTL int // time-to-live, receiving only
42 - Src net.IP // source address, specifying only
43 - Dst net.IP // destination address, receiving only
44 - IfIndex int // interface index, must be 1 <= value when specifying
45 -}
46 -
47 -func (cm *ControlMessage) String() string {
48 - if cm == nil {
49 - return "<nil>"
50 - }
51 - return fmt.Sprintf("ttl: %v, src: %v, dst: %v, ifindex: %v", cm.TTL, cm.Src, cm.Dst, cm.IfIndex)
52 -}
53 -
54 -// Ancillary data socket options
55 -const (
56 - ctlTTL = iota // header field
57 - ctlSrc // header field
58 - ctlDst // header field
59 - ctlInterface // inbound or outbound interface
60 - ctlPacketInfo // inbound or outbound packet path
61 - ctlMax
62 -)
63 -
64 -// A ctlOpt represents a binding for ancillary data socket option.
65 -type ctlOpt struct {
66 - name int // option name, must be equal or greater than 1
67 - length int // option length
68 - marshal func([]byte, *ControlMessage) []byte
69 - parse func(*ControlMessage, []byte)
70 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/control_bsd.go deleted
-40
@@ -1,40 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd netbsd openbsd
6 -
7 -package ipv4
8 -
9 -import (
10 - "net"
11 - "syscall"
12 - "unsafe"
13 -
14 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
15 -)
16 -
17 -func marshalDst(b []byte, cm *ControlMessage) []byte {
18 - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
19 - m.Level = iana.ProtocolIP
20 - m.Type = sysIP_RECVDSTADDR
21 - m.SetLen(syscall.CmsgLen(net.IPv4len))
22 - return b[syscall.CmsgSpace(net.IPv4len):]
23 -}
24 -
25 -func parseDst(cm *ControlMessage, b []byte) {
26 - cm.Dst = b[:net.IPv4len]
27 -}
28 -
29 -func marshalInterface(b []byte, cm *ControlMessage) []byte {
30 - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
31 - m.Level = iana.ProtocolIP
32 - m.Type = sysIP_RECVIF
33 - m.SetLen(syscall.CmsgLen(syscall.SizeofSockaddrDatalink))
34 - return b[syscall.CmsgSpace(syscall.SizeofSockaddrDatalink):]
35 -}
36 -
37 -func parseInterface(cm *ControlMessage, b []byte) {
38 - sadl := (*syscall.SockaddrDatalink)(unsafe.Pointer(&b[0]))
39 - cm.IfIndex = int(sadl.Index)
40 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/control_pktinfo.go deleted
-37
@@ -1,37 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin linux
6 -
7 -package ipv4
8 -
9 -import (
10 - "syscall"
11 - "unsafe"
12 -
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
14 -)
15 -
16 -func marshalPacketInfo(b []byte, cm *ControlMessage) []byte {
17 - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
18 - m.Level = iana.ProtocolIP
19 - m.Type = sysIP_PKTINFO
20 - m.SetLen(syscall.CmsgLen(sysSizeofInetPktinfo))
21 - if cm != nil {
22 - pi := (*sysInetPktinfo)(unsafe.Pointer(&b[syscall.CmsgLen(0)]))
23 - if ip := cm.Src.To4(); ip != nil {
24 - copy(pi.Spec_dst[:], ip)
25 - }
26 - if cm.IfIndex > 0 {
27 - pi.setIfindex(cm.IfIndex)
28 - }
29 - }
30 - return b[syscall.CmsgSpace(sysSizeofInetPktinfo):]
31 -}
32 -
33 -func parsePacketInfo(cm *ControlMessage, b []byte) {
34 - pi := (*sysInetPktinfo)(unsafe.Pointer(&b[0]))
35 - cm.IfIndex = int(pi.Ifindex)
36 - cm.Dst = pi.Addr[:]
37 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/control_stub.go deleted
-23
@@ -1,23 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9 solaris
6 -
7 -package ipv4
8 -
9 -func setControlMessage(fd int, opt *rawOpt, cf ControlFlags, on bool) error {
10 - return errOpNoSupport
11 -}
12 -
13 -func newControlMessage(opt *rawOpt) []byte {
14 - return nil
15 -}
16 -
17 -func parseControlMessage(b []byte) (*ControlMessage, error) {
18 - return nil, errOpNoSupport
19 -}
20 -
21 -func marshalControlMessage(cm *ControlMessage) []byte {
22 - return nil
23 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/control_unix.go deleted
-164
@@ -1,164 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux netbsd openbsd
6 -
7 -package ipv4
8 -
9 -import (
10 - "os"
11 - "syscall"
12 - "unsafe"
13 -
14 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
15 -)
16 -
17 -func setControlMessage(fd int, opt *rawOpt, cf ControlFlags, on bool) error {
18 - opt.Lock()
19 - defer opt.Unlock()
20 - if cf&FlagTTL != 0 && sockOpts[ssoReceiveTTL].name > 0 {
21 - if err := setInt(fd, &sockOpts[ssoReceiveTTL], boolint(on)); err != nil {
22 - return err
23 - }
24 - if on {
25 - opt.set(FlagTTL)
26 - } else {
27 - opt.clear(FlagTTL)
28 - }
29 - }
30 - if sockOpts[ssoPacketInfo].name > 0 {
31 - if cf&(FlagSrc|FlagDst|FlagInterface) != 0 {
32 - if err := setInt(fd, &sockOpts[ssoPacketInfo], boolint(on)); err != nil {
33 - return err
34 - }
35 - if on {
36 - opt.set(cf & (FlagSrc | FlagDst | FlagInterface))
37 - } else {
38 - opt.clear(cf & (FlagSrc | FlagDst | FlagInterface))
39 - }
40 - }
41 - } else {
42 - if cf&FlagDst != 0 && sockOpts[ssoReceiveDst].name > 0 {
43 - if err := setInt(fd, &sockOpts[ssoReceiveDst], boolint(on)); err != nil {
44 - return err
45 - }
46 - if on {
47 - opt.set(FlagDst)
48 - } else {
49 - opt.clear(FlagDst)
50 - }
51 - }
52 - if cf&FlagInterface != 0 && sockOpts[ssoReceiveInterface].name > 0 {
53 - if err := setInt(fd, &sockOpts[ssoReceiveInterface], boolint(on)); err != nil {
54 - return err
55 - }
56 - if on {
57 - opt.set(FlagInterface)
58 - } else {
59 - opt.clear(FlagInterface)
60 - }
61 - }
62 - }
63 - return nil
64 -}
65 -
66 -func newControlMessage(opt *rawOpt) (oob []byte) {
67 - opt.RLock()
68 - var l int
69 - if opt.isset(FlagTTL) && ctlOpts[ctlTTL].name > 0 {
70 - l += syscall.CmsgSpace(ctlOpts[ctlTTL].length)
71 - }
72 - if ctlOpts[ctlPacketInfo].name > 0 {
73 - if opt.isset(FlagSrc | FlagDst | FlagInterface) {
74 - l += syscall.CmsgSpace(ctlOpts[ctlPacketInfo].length)
75 - }
76 - } else {
77 - if opt.isset(FlagDst) && ctlOpts[ctlDst].name > 0 {
78 - l += syscall.CmsgSpace(ctlOpts[ctlDst].length)
79 - }
80 - if opt.isset(FlagInterface) && ctlOpts[ctlInterface].name > 0 {
81 - l += syscall.CmsgSpace(ctlOpts[ctlInterface].length)
82 - }
83 - }
84 - if l > 0 {
85 - oob = make([]byte, l)
86 - b := oob
87 - if opt.isset(FlagTTL) && ctlOpts[ctlTTL].name > 0 {
88 - b = ctlOpts[ctlTTL].marshal(b, nil)
89 - }
90 - if ctlOpts[ctlPacketInfo].name > 0 {
91 - if opt.isset(FlagSrc | FlagDst | FlagInterface) {
92 - b = ctlOpts[ctlPacketInfo].marshal(b, nil)
93 - }
94 - } else {
95 - if opt.isset(FlagDst) && ctlOpts[ctlDst].name > 0 {
96 - b = ctlOpts[ctlDst].marshal(b, nil)
97 - }
98 - if opt.isset(FlagInterface) && ctlOpts[ctlInterface].name > 0 {
99 - b = ctlOpts[ctlInterface].marshal(b, nil)
100 - }
101 - }
102 - }
103 - opt.RUnlock()
104 - return
105 -}
106 -
107 -func parseControlMessage(b []byte) (*ControlMessage, error) {
108 - if len(b) == 0 {
109 - return nil, nil
110 - }
111 - cmsgs, err := syscall.ParseSocketControlMessage(b)
112 - if err != nil {
113 - return nil, os.NewSyscallError("parse socket control message", err)
114 - }
115 - cm := &ControlMessage{}
116 - for _, m := range cmsgs {
117 - if m.Header.Level != iana.ProtocolIP {
118 - continue
119 - }
120 - switch int(m.Header.Type) {
121 - case ctlOpts[ctlTTL].name:
122 - ctlOpts[ctlTTL].parse(cm, m.Data[:])
123 - case ctlOpts[ctlDst].name:
124 - ctlOpts[ctlDst].parse(cm, m.Data[:])
125 - case ctlOpts[ctlInterface].name:
126 - ctlOpts[ctlInterface].parse(cm, m.Data[:])
127 - case ctlOpts[ctlPacketInfo].name:
128 - ctlOpts[ctlPacketInfo].parse(cm, m.Data[:])
129 - }
130 - }
131 - return cm, nil
132 -}
133 -
134 -func marshalControlMessage(cm *ControlMessage) (oob []byte) {
135 - if cm == nil {
136 - return nil
137 - }
138 - var l int
139 - pktinfo := false
140 - if ctlOpts[ctlPacketInfo].name > 0 && (cm.Src.To4() != nil || cm.IfIndex > 0) {
141 - pktinfo = true
142 - l += syscall.CmsgSpace(ctlOpts[ctlPacketInfo].length)
143 - }
144 - if l > 0 {
145 - oob = make([]byte, l)
146 - b := oob
147 - if pktinfo {
148 - b = ctlOpts[ctlPacketInfo].marshal(b, cm)
149 - }
150 - }
151 - return
152 -}
153 -
154 -func marshalTTL(b []byte, cm *ControlMessage) []byte {
155 - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
156 - m.Level = iana.ProtocolIP
157 - m.Type = sysIP_RECVTTL
158 - m.SetLen(syscall.CmsgLen(1))
159 - return b[syscall.CmsgSpace(1):]
160 -}
161 -
162 -func parseTTL(cm *ControlMessage, b []byte) {
163 - cm.TTL = int(*(*byte)(unsafe.Pointer(&b[:1][0])))
164 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/control_windows.go deleted
-27
@@ -1,27 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import "syscall"
8 -
9 -func setControlMessage(fd syscall.Handle, opt *rawOpt, cf ControlFlags, on bool) error {
10 - // TODO(mikio): implement this
11 - return syscall.EWINDOWS
12 -}
13 -
14 -func newControlMessage(opt *rawOpt) []byte {
15 - // TODO(mikio): implement this
16 - return nil
17 -}
18 -
19 -func parseControlMessage(b []byte) (*ControlMessage, error) {
20 - // TODO(mikio): implement this
21 - return nil, syscall.EWINDOWS
22 -}
23 -
24 -func marshalControlMessage(cm *ControlMessage) []byte {
25 - // TODO(mikio): implement this
26 - return nil
27 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/defs_darwin.go deleted
-77
@@ -1,77 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in_addr [4]byte /* in_addr */
8 -
9 -package ipv4
10 -
11 -/*
12 -#include <sys/socket.h>
13 -
14 -#include <netinet/in.h>
15 -*/
16 -import "C"
17 -
18 -const (
19 - sysIP_OPTIONS = C.IP_OPTIONS
20 - sysIP_HDRINCL = C.IP_HDRINCL
21 - sysIP_TOS = C.IP_TOS
22 - sysIP_TTL = C.IP_TTL
23 - sysIP_RECVOPTS = C.IP_RECVOPTS
24 - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS
25 - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR
26 - sysIP_RETOPTS = C.IP_RETOPTS
27 - sysIP_RECVIF = C.IP_RECVIF
28 - sysIP_STRIPHDR = C.IP_STRIPHDR
29 - sysIP_RECVTTL = C.IP_RECVTTL
30 - sysIP_BOUND_IF = C.IP_BOUND_IF
31 - sysIP_PKTINFO = C.IP_PKTINFO
32 - sysIP_RECVPKTINFO = C.IP_RECVPKTINFO
33 -
34 - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF
35 - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL
36 - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP
37 - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP
38 - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP
39 - sysIP_MULTICAST_VIF = C.IP_MULTICAST_VIF
40 - sysIP_MULTICAST_IFINDEX = C.IP_MULTICAST_IFINDEX
41 - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP
42 - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP
43 - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE
44 - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE
45 - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP
46 - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP
47 - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP
48 - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP
49 - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE
50 - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE
51 -
52 - sysSizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage
53 - sysSizeofSockaddrInet = C.sizeof_struct_sockaddr_in
54 - sysSizeofInetPktinfo = C.sizeof_struct_in_pktinfo
55 -
56 - sysSizeofIPMreq = C.sizeof_struct_ip_mreq
57 - sysSizeofIPMreqn = C.sizeof_struct_ip_mreqn
58 - sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source
59 - sysSizeofGroupReq = C.sizeof_struct_group_req
60 - sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req
61 -)
62 -
63 -type sysSockaddrStorage C.struct_sockaddr_storage
64 -
65 -type sysSockaddrInet C.struct_sockaddr_in
66 -
67 -type sysInetPktinfo C.struct_in_pktinfo
68 -
69 -type sysIPMreq C.struct_ip_mreq
70 -
71 -type sysIPMreqn C.struct_ip_mreqn
72 -
73 -type sysIPMreqSource C.struct_ip_mreq_source
74 -
75 -type sysGroupReq C.struct_group_req
76 -
77 -type sysGroupSourceReq C.struct_group_source_req
Godeps/_workspace/src/golang.org/x/net/ipv4/defs_dragonfly.go deleted
-38
@@ -1,38 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in_addr [4]byte /* in_addr */
8 -
9 -package ipv4
10 -
11 -/*
12 -#include <netinet/in.h>
13 -*/
14 -import "C"
15 -
16 -const (
17 - sysIP_OPTIONS = C.IP_OPTIONS
18 - sysIP_HDRINCL = C.IP_HDRINCL
19 - sysIP_TOS = C.IP_TOS
20 - sysIP_TTL = C.IP_TTL
21 - sysIP_RECVOPTS = C.IP_RECVOPTS
22 - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS
23 - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR
24 - sysIP_RETOPTS = C.IP_RETOPTS
25 - sysIP_RECVIF = C.IP_RECVIF
26 - sysIP_RECVTTL = C.IP_RECVTTL
27 -
28 - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF
29 - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL
30 - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP
31 - sysIP_MULTICAST_VIF = C.IP_MULTICAST_VIF
32 - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP
33 - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP
34 -
35 - sysSizeofIPMreq = C.sizeof_struct_ip_mreq
36 -)
37 -
38 -type sysIPMreq C.struct_ip_mreq
Godeps/_workspace/src/golang.org/x/net/ipv4/defs_freebsd.go deleted
-75
@@ -1,75 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in_addr [4]byte /* in_addr */
8 -
9 -package ipv4
10 -
11 -/*
12 -#include <sys/socket.h>
13 -
14 -#include <netinet/in.h>
15 -*/
16 -import "C"
17 -
18 -const (
19 - sysIP_OPTIONS = C.IP_OPTIONS
20 - sysIP_HDRINCL = C.IP_HDRINCL
21 - sysIP_TOS = C.IP_TOS
22 - sysIP_TTL = C.IP_TTL
23 - sysIP_RECVOPTS = C.IP_RECVOPTS
24 - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS
25 - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR
26 - sysIP_SENDSRCADDR = C.IP_SENDSRCADDR
27 - sysIP_RETOPTS = C.IP_RETOPTS
28 - sysIP_RECVIF = C.IP_RECVIF
29 - sysIP_ONESBCAST = C.IP_ONESBCAST
30 - sysIP_BINDANY = C.IP_BINDANY
31 - sysIP_RECVTTL = C.IP_RECVTTL
32 - sysIP_MINTTL = C.IP_MINTTL
33 - sysIP_DONTFRAG = C.IP_DONTFRAG
34 - sysIP_RECVTOS = C.IP_RECVTOS
35 -
36 - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF
37 - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL
38 - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP
39 - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP
40 - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP
41 - sysIP_MULTICAST_VIF = C.IP_MULTICAST_VIF
42 - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP
43 - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP
44 - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE
45 - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE
46 - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP
47 - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP
48 - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP
49 - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP
50 - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE
51 - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE
52 -
53 - sysSizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage
54 - sysSizeofSockaddrInet = C.sizeof_struct_sockaddr_in
55 -
56 - sysSizeofIPMreq = C.sizeof_struct_ip_mreq
57 - sysSizeofIPMreqn = C.sizeof_struct_ip_mreqn
58 - sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source
59 - sysSizeofGroupReq = C.sizeof_struct_group_req
60 - sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req
61 -)
62 -
63 -type sysSockaddrStorage C.struct_sockaddr_storage
64 -
65 -type sysSockaddrInet C.struct_sockaddr_in
66 -
67 -type sysIPMreq C.struct_ip_mreq
68 -
69 -type sysIPMreqn C.struct_ip_mreqn
70 -
71 -type sysIPMreqSource C.struct_ip_mreq_source
72 -
73 -type sysGroupReq C.struct_group_req
74 -
75 -type sysGroupSourceReq C.struct_group_source_req
Godeps/_workspace/src/golang.org/x/net/ipv4/defs_linux.go deleted
-111
@@ -1,111 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in_addr [4]byte /* in_addr */
8 -
9 -package ipv4
10 -
11 -/*
12 -#include <time.h>
13 -
14 -#include <linux/errqueue.h>
15 -#include <linux/icmp.h>
16 -#include <linux/in.h>
17 -*/
18 -import "C"
19 -
20 -const (
21 - sysIP_TOS = C.IP_TOS
22 - sysIP_TTL = C.IP_TTL
23 - sysIP_HDRINCL = C.IP_HDRINCL
24 - sysIP_OPTIONS = C.IP_OPTIONS
25 - sysIP_ROUTER_ALERT = C.IP_ROUTER_ALERT
26 - sysIP_RECVOPTS = C.IP_RECVOPTS
27 - sysIP_RETOPTS = C.IP_RETOPTS
28 - sysIP_PKTINFO = C.IP_PKTINFO
29 - sysIP_PKTOPTIONS = C.IP_PKTOPTIONS
30 - sysIP_MTU_DISCOVER = C.IP_MTU_DISCOVER
31 - sysIP_RECVERR = C.IP_RECVERR
32 - sysIP_RECVTTL = C.IP_RECVTTL
33 - sysIP_RECVTOS = C.IP_RECVTOS
34 - sysIP_MTU = C.IP_MTU
35 - sysIP_FREEBIND = C.IP_FREEBIND
36 - sysIP_TRANSPARENT = C.IP_TRANSPARENT
37 - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS
38 - sysIP_ORIGDSTADDR = C.IP_ORIGDSTADDR
39 - sysIP_RECVORIGDSTADDR = C.IP_RECVORIGDSTADDR
40 - sysIP_MINTTL = C.IP_MINTTL
41 - sysIP_NODEFRAG = C.IP_NODEFRAG
42 - sysIP_UNICAST_IF = C.IP_UNICAST_IF
43 -
44 - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF
45 - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL
46 - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP
47 - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP
48 - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP
49 - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE
50 - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE
51 - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP
52 - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP
53 - sysIP_MSFILTER = C.IP_MSFILTER
54 - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP
55 - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP
56 - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP
57 - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP
58 - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE
59 - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE
60 - sysMCAST_MSFILTER = C.MCAST_MSFILTER
61 - sysIP_MULTICAST_ALL = C.IP_MULTICAST_ALL
62 -
63 - //sysIP_PMTUDISC_DONT = C.IP_PMTUDISC_DONT
64 - //sysIP_PMTUDISC_WANT = C.IP_PMTUDISC_WANT
65 - //sysIP_PMTUDISC_DO = C.IP_PMTUDISC_DO
66 - //sysIP_PMTUDISC_PROBE = C.IP_PMTUDISC_PROBE
67 - //sysIP_PMTUDISC_INTERFACE = C.IP_PMTUDISC_INTERFACE
68 - //sysIP_PMTUDISC_OMIT = C.IP_PMTUDISC_OMIT
69 -
70 - sysICMP_FILTER = C.ICMP_FILTER
71 -
72 - sysSO_EE_ORIGIN_NONE = C.SO_EE_ORIGIN_NONE
73 - sysSO_EE_ORIGIN_LOCAL = C.SO_EE_ORIGIN_LOCAL
74 - sysSO_EE_ORIGIN_ICMP = C.SO_EE_ORIGIN_ICMP
75 - sysSO_EE_ORIGIN_ICMP6 = C.SO_EE_ORIGIN_ICMP6
76 - sysSO_EE_ORIGIN_TXSTATUS = C.SO_EE_ORIGIN_TXSTATUS
77 - sysSO_EE_ORIGIN_TIMESTAMPING = C.SO_EE_ORIGIN_TIMESTAMPING
78 -
79 - sysSizeofKernelSockaddrStorage = C.sizeof_struct___kernel_sockaddr_storage
80 - sysSizeofSockaddrInet = C.sizeof_struct_sockaddr_in
81 - sysSizeofInetPktinfo = C.sizeof_struct_in_pktinfo
82 - sysSizeofSockExtendedErr = C.sizeof_struct_sock_extended_err
83 -
84 - sysSizeofIPMreq = C.sizeof_struct_ip_mreq
85 - sysSizeofIPMreqn = C.sizeof_struct_ip_mreqn
86 - sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source
87 - sysSizeofGroupReq = C.sizeof_struct_group_req
88 - sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req
89 -
90 - sysSizeofICMPFilter = C.sizeof_struct_icmp_filter
91 -)
92 -
93 -type sysKernelSockaddrStorage C.struct___kernel_sockaddr_storage
94 -
95 -type sysSockaddrInet C.struct_sockaddr_in
96 -
97 -type sysInetPktinfo C.struct_in_pktinfo
98 -
99 -type sysSockExtendedErr C.struct_sock_extended_err
100 -
101 -type sysIPMreq C.struct_ip_mreq
102 -
103 -type sysIPMreqn C.struct_ip_mreqn
104 -
105 -type sysIPMreqSource C.struct_ip_mreq_source
106 -
107 -type sysGroupReq C.struct_group_req
108 -
109 -type sysGroupSourceReq C.struct_group_source_req
110 -
111 -type sysICMPFilter C.struct_icmp_filter
Godeps/_workspace/src/golang.org/x/net/ipv4/defs_netbsd.go deleted
-37
@@ -1,37 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in_addr [4]byte /* in_addr */
8 -
9 -package ipv4
10 -
11 -/*
12 -#include <netinet/in.h>
13 -*/
14 -import "C"
15 -
16 -const (
17 - sysIP_OPTIONS = C.IP_OPTIONS
18 - sysIP_HDRINCL = C.IP_HDRINCL
19 - sysIP_TOS = C.IP_TOS
20 - sysIP_TTL = C.IP_TTL
21 - sysIP_RECVOPTS = C.IP_RECVOPTS
22 - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS
23 - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR
24 - sysIP_RETOPTS = C.IP_RETOPTS
25 - sysIP_RECVIF = C.IP_RECVIF
26 - sysIP_RECVTTL = C.IP_RECVTTL
27 -
28 - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF
29 - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL
30 - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP
31 - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP
32 - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP
33 -
34 - sysSizeofIPMreq = C.sizeof_struct_ip_mreq
35 -)
36 -
37 -type sysIPMreq C.struct_ip_mreq
Godeps/_workspace/src/golang.org/x/net/ipv4/defs_openbsd.go deleted
-37
@@ -1,37 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in_addr [4]byte /* in_addr */
8 -
9 -package ipv4
10 -
11 -/*
12 -#include <netinet/in.h>
13 -*/
14 -import "C"
15 -
16 -const (
17 - sysIP_OPTIONS = C.IP_OPTIONS
18 - sysIP_HDRINCL = C.IP_HDRINCL
19 - sysIP_TOS = C.IP_TOS
20 - sysIP_TTL = C.IP_TTL
21 - sysIP_RECVOPTS = C.IP_RECVOPTS
22 - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS
23 - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR
24 - sysIP_RETOPTS = C.IP_RETOPTS
25 - sysIP_RECVIF = C.IP_RECVIF
26 - sysIP_RECVTTL = C.IP_RECVTTL
27 -
28 - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF
29 - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL
30 - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP
31 - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP
32 - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP
33 -
34 - sysSizeofIPMreq = C.sizeof_struct_ip_mreq
35 -)
36 -
37 -type sysIPMreq C.struct_ip_mreq
Godeps/_workspace/src/golang.org/x/net/ipv4/defs_solaris.go deleted
-57
@@ -1,57 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in_addr [4]byte /* in_addr */
8 -
9 -package ipv4
10 -
11 -/*
12 -#include <netinet/in.h>
13 -*/
14 -import "C"
15 -
16 -const (
17 - sysIP_OPTIONS = C.IP_OPTIONS
18 - sysIP_HDRINCL = C.IP_HDRINCL
19 - sysIP_TOS = C.IP_TOS
20 - sysIP_TTL = C.IP_TTL
21 - sysIP_RECVOPTS = C.IP_RECVOPTS
22 - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS
23 - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR
24 - sysIP_RETOPTS = C.IP_RETOPTS
25 - sysIP_RECVIF = C.IP_RECVIF
26 - sysIP_RECVSLLA = C.IP_RECVSLLA
27 - sysIP_RECVTTL = C.IP_RECVTTL
28 - sysIP_NEXTHOP = C.IP_NEXTHOP
29 - sysIP_PKTINFO = C.IP_PKTINFO
30 - sysIP_RECVPKTINFO = C.IP_RECVPKTINFO
31 - sysIP_DONTFRAG = C.IP_DONTFRAG
32 - sysIP_BOUND_IF = C.IP_BOUND_IF
33 - sysIP_UNSPEC_SRC = C.IP_UNSPEC_SRC
34 - sysIP_BROADCAST_TTL = C.IP_BROADCAST_TTL
35 - sysIP_DHCPINIT_IF = C.IP_DHCPINIT_IF
36 -
37 - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF
38 - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL
39 - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP
40 - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP
41 - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP
42 - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE
43 - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE
44 - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP
45 - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP
46 -
47 - sysSizeofInetPktinfo = C.sizeof_struct_in_pktinfo
48 -
49 - sysSizeofIPMreq = C.sizeof_struct_ip_mreq
50 - sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source
51 -)
52 -
53 -type sysInetPktinfo C.struct_in_pktinfo
54 -
55 -type sysIPMreq C.struct_ip_mreq
56 -
57 -type sysIPMreqSource C.struct_ip_mreq_source
Godeps/_workspace/src/golang.org/x/net/ipv4/dgramopt_posix.go deleted
-251
@@ -1,251 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux netbsd openbsd windows
6 -
7 -package ipv4
8 -
9 -import (
10 - "net"
11 - "syscall"
12 -)
13 -
14 -// MulticastTTL returns the time-to-live field value for outgoing
15 -// multicast packets.
16 -func (c *dgramOpt) MulticastTTL() (int, error) {
17 - if !c.ok() {
18 - return 0, syscall.EINVAL
19 - }
20 - fd, err := c.sysfd()
21 - if err != nil {
22 - return 0, err
23 - }
24 - return getInt(fd, &sockOpts[ssoMulticastTTL])
25 -}
26 -
27 -// SetMulticastTTL sets the time-to-live field value for future
28 -// outgoing multicast packets.
29 -func (c *dgramOpt) SetMulticastTTL(ttl int) error {
30 - if !c.ok() {
31 - return syscall.EINVAL
32 - }
33 - fd, err := c.sysfd()
34 - if err != nil {
35 - return err
36 - }
37 - return setInt(fd, &sockOpts[ssoMulticastTTL], ttl)
38 -}
39 -
40 -// MulticastInterface returns the default interface for multicast
41 -// packet transmissions.
42 -func (c *dgramOpt) MulticastInterface() (*net.Interface, error) {
43 - if !c.ok() {
44 - return nil, syscall.EINVAL
45 - }
46 - fd, err := c.sysfd()
47 - if err != nil {
48 - return nil, err
49 - }
50 - return getInterface(fd, &sockOpts[ssoMulticastInterface])
51 -}
52 -
53 -// SetMulticastInterface sets the default interface for future
54 -// multicast packet transmissions.
55 -func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error {
56 - if !c.ok() {
57 - return syscall.EINVAL
58 - }
59 - fd, err := c.sysfd()
60 - if err != nil {
61 - return err
62 - }
63 - return setInterface(fd, &sockOpts[ssoMulticastInterface], ifi)
64 -}
65 -
66 -// MulticastLoopback reports whether transmitted multicast packets
67 -// should be copied and send back to the originator.
68 -func (c *dgramOpt) MulticastLoopback() (bool, error) {
69 - if !c.ok() {
70 - return false, syscall.EINVAL
71 - }
72 - fd, err := c.sysfd()
73 - if err != nil {
74 - return false, err
75 - }
76 - on, err := getInt(fd, &sockOpts[ssoMulticastLoopback])
77 - if err != nil {
78 - return false, err
79 - }
80 - return on == 1, nil
81 -}
82 -
83 -// SetMulticastLoopback sets whether transmitted multicast packets
84 -// should be copied and send back to the originator.
85 -func (c *dgramOpt) SetMulticastLoopback(on bool) error {
86 - if !c.ok() {
87 - return syscall.EINVAL
88 - }
89 - fd, err := c.sysfd()
90 - if err != nil {
91 - return err
92 - }
93 - return setInt(fd, &sockOpts[ssoMulticastLoopback], boolint(on))
94 -}
95 -
96 -// JoinGroup joins the group address group on the interface ifi.
97 -// By default all sources that can cast data to group are accepted.
98 -// It's possible to mute and unmute data transmission from a specific
99 -// source by using ExcludeSourceSpecificGroup and
100 -// IncludeSourceSpecificGroup.
101 -// JoinGroup uses the system assigned multicast interface when ifi is
102 -// nil, although this is not recommended because the assignment
103 -// depends on platforms and sometimes it might require routing
104 -// configuration.
105 -func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error {
106 - if !c.ok() {
107 - return syscall.EINVAL
108 - }
109 - fd, err := c.sysfd()
110 - if err != nil {
111 - return err
112 - }
113 - grp := netAddrToIP4(group)
114 - if grp == nil {
115 - return errMissingAddress
116 - }
117 - return setGroup(fd, &sockOpts[ssoJoinGroup], ifi, grp)
118 -}
119 -
120 -// LeaveGroup leaves the group address group on the interface ifi
121 -// regardless of whether the group is any-source group or
122 -// source-specific group.
123 -func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error {
124 - if !c.ok() {
125 - return syscall.EINVAL
126 - }
127 - fd, err := c.sysfd()
128 - if err != nil {
129 - return err
130 - }
131 - grp := netAddrToIP4(group)
132 - if grp == nil {
133 - return errMissingAddress
134 - }
135 - return setGroup(fd, &sockOpts[ssoLeaveGroup], ifi, grp)
136 -}
137 -
138 -// JoinSourceSpecificGroup joins the source-specific group comprising
139 -// group and source on the interface ifi.
140 -// JoinSourceSpecificGroup uses the system assigned multicast
141 -// interface when ifi is nil, although this is not recommended because
142 -// the assignment depends on platforms and sometimes it might require
143 -// routing configuration.
144 -func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
145 - if !c.ok() {
146 - return syscall.EINVAL
147 - }
148 - fd, err := c.sysfd()
149 - if err != nil {
150 - return err
151 - }
152 - grp := netAddrToIP4(group)
153 - if grp == nil {
154 - return errMissingAddress
155 - }
156 - src := netAddrToIP4(source)
157 - if src == nil {
158 - return errMissingAddress
159 - }
160 - return setSourceGroup(fd, &sockOpts[ssoJoinSourceGroup], ifi, grp, src)
161 -}
162 -
163 -// LeaveSourceSpecificGroup leaves the source-specific group on the
164 -// interface ifi.
165 -func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
166 - if !c.ok() {
167 - return syscall.EINVAL
168 - }
169 - fd, err := c.sysfd()
170 - if err != nil {
171 - return err
172 - }
173 - grp := netAddrToIP4(group)
174 - if grp == nil {
175 - return errMissingAddress
176 - }
177 - src := netAddrToIP4(source)
178 - if src == nil {
179 - return errMissingAddress
180 - }
181 - return setSourceGroup(fd, &sockOpts[ssoLeaveSourceGroup], ifi, grp, src)
182 -}
183 -
184 -// ExcludeSourceSpecificGroup excludes the source-specific group from
185 -// the already joined any-source groups by JoinGroup on the interface
186 -// ifi.
187 -func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
188 - if !c.ok() {
189 - return syscall.EINVAL
190 - }
191 - fd, err := c.sysfd()
192 - if err != nil {
193 - return err
194 - }
195 - grp := netAddrToIP4(group)
196 - if grp == nil {
197 - return errMissingAddress
198 - }
199 - src := netAddrToIP4(source)
200 - if src == nil {
201 - return errMissingAddress
202 - }
203 - return setSourceGroup(fd, &sockOpts[ssoBlockSourceGroup], ifi, grp, src)
204 -}
205 -
206 -// IncludeSourceSpecificGroup includes the excluded source-specific
207 -// group by ExcludeSourceSpecificGroup again on the interface ifi.
208 -func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
209 - if !c.ok() {
210 - return syscall.EINVAL
211 - }
212 - fd, err := c.sysfd()
213 - if err != nil {
214 - return err
215 - }
216 - grp := netAddrToIP4(group)
217 - if grp == nil {
218 - return errMissingAddress
219 - }
220 - src := netAddrToIP4(source)
221 - if src == nil {
222 - return errMissingAddress
223 - }
224 - return setSourceGroup(fd, &sockOpts[ssoUnblockSourceGroup], ifi, grp, src)
225 -}
226 -
227 -// ICMPFilter returns an ICMP filter.
228 -// Currently only Linux supports this.
229 -func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) {
230 - if !c.ok() {
231 - return nil, syscall.EINVAL
232 - }
233 - fd, err := c.sysfd()
234 - if err != nil {
235 - return nil, err
236 - }
237 - return getICMPFilter(fd, &sockOpts[ssoICMPFilter])
238 -}
239 -
240 -// SetICMPFilter deploys the ICMP filter.
241 -// Currently only Linux supports this.
242 -func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error {
243 - if !c.ok() {
244 - return syscall.EINVAL
245 - }
246 - fd, err := c.sysfd()
247 - if err != nil {
248 - return err
249 - }
250 - return setICMPFilter(fd, &sockOpts[ssoICMPFilter], f)
251 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/dgramopt_stub.go deleted
-106
@@ -1,106 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9 solaris
6 -
7 -package ipv4
8 -
9 -import "net"
10 -
11 -// MulticastTTL returns the time-to-live field value for outgoing
12 -// multicast packets.
13 -func (c *dgramOpt) MulticastTTL() (int, error) {
14 - return 0, errOpNoSupport
15 -}
16 -
17 -// SetMulticastTTL sets the time-to-live field value for future
18 -// outgoing multicast packets.
19 -func (c *dgramOpt) SetMulticastTTL(ttl int) error {
20 - return errOpNoSupport
21 -}
22 -
23 -// MulticastInterface returns the default interface for multicast
24 -// packet transmissions.
25 -func (c *dgramOpt) MulticastInterface() (*net.Interface, error) {
26 - return nil, errOpNoSupport
27 -}
28 -
29 -// SetMulticastInterface sets the default interface for future
30 -// multicast packet transmissions.
31 -func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error {
32 - return errOpNoSupport
33 -}
34 -
35 -// MulticastLoopback reports whether transmitted multicast packets
36 -// should be copied and send back to the originator.
37 -func (c *dgramOpt) MulticastLoopback() (bool, error) {
38 - return false, errOpNoSupport
39 -}
40 -
41 -// SetMulticastLoopback sets whether transmitted multicast packets
42 -// should be copied and send back to the originator.
43 -func (c *dgramOpt) SetMulticastLoopback(on bool) error {
44 - return errOpNoSupport
45 -}
46 -
47 -// JoinGroup joins the group address group on the interface ifi.
48 -// By default all sources that can cast data to group are accepted.
49 -// It's possible to mute and unmute data transmission from a specific
50 -// source by using ExcludeSourceSpecificGroup and
51 -// IncludeSourceSpecificGroup.
52 -// JoinGroup uses the system assigned multicast interface when ifi is
53 -// nil, although this is not recommended because the assignment
54 -// depends on platforms and sometimes it might require routing
55 -// configuration.
56 -func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error {
57 - return errOpNoSupport
58 -}
59 -
60 -// LeaveGroup leaves the group address group on the interface ifi
61 -// regardless of whether the group is any-source group or
62 -// source-specific group.
63 -func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error {
64 - return errOpNoSupport
65 -}
66 -
67 -// JoinSourceSpecificGroup joins the source-specific group comprising
68 -// group and source on the interface ifi.
69 -// JoinSourceSpecificGroup uses the system assigned multicast
70 -// interface when ifi is nil, although this is not recommended because
71 -// the assignment depends on platforms and sometimes it might require
72 -// routing configuration.
73 -func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
74 - return errOpNoSupport
75 -}
76 -
77 -// LeaveSourceSpecificGroup leaves the source-specific group on the
78 -// interface ifi.
79 -func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
80 - return errOpNoSupport
81 -}
82 -
83 -// ExcludeSourceSpecificGroup excludes the source-specific group from
84 -// the already joined any-source groups by JoinGroup on the interface
85 -// ifi.
86 -func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
87 - return errOpNoSupport
88 -}
89 -
90 -// IncludeSourceSpecificGroup includes the excluded source-specific
91 -// group by ExcludeSourceSpecificGroup again on the interface ifi.
92 -func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
93 - return errOpNoSupport
94 -}
95 -
96 -// ICMPFilter returns an ICMP filter.
97 -// Currently only Linux supports this.
98 -func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) {
99 - return nil, errOpNoSupport
100 -}
101 -
102 -// SetICMPFilter deploys the ICMP filter.
103 -// Currently only Linux supports this.
104 -func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error {
105 - return errOpNoSupport
106 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/doc.go deleted
-242
@@ -1,242 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// Package ipv4 implements IP-level socket options for the Internet
6 -// Protocol version 4.
7 -//
8 -// The package provides IP-level socket options that allow
9 -// manipulation of IPv4 facilities.
10 -//
11 -// The IPv4 protocol and basic host requirements for IPv4 are defined
12 -// in RFC 791 and RFC 1122.
13 -// Host extensions for multicasting and socket interface extensions
14 -// for multicast source filters are defined in RFC 1112 and RFC 3678.
15 -// IGMPv1, IGMPv2 and IGMPv3 are defined in RFC 1112, RFC 2236 and RFC
16 -// 3376.
17 -// Source-specific multicast is defined in RFC 4607.
18 -//
19 -//
20 -// Unicasting
21 -//
22 -// The options for unicasting are available for net.TCPConn,
23 -// net.UDPConn and net.IPConn which are created as network connections
24 -// that use the IPv4 transport. When a single TCP connection carrying
25 -// a data flow of multiple packets needs to indicate the flow is
26 -// important, ipv4.Conn is used to set the type-of-service field on
27 -// the IPv4 header for each packet.
28 -//
29 -// ln, err := net.Listen("tcp4", "0.0.0.0:1024")
30 -// if err != nil {
31 -// // error handling
32 -// }
33 -// defer ln.Close()
34 -// for {
35 -// c, err := ln.Accept()
36 -// if err != nil {
37 -// // error handling
38 -// }
39 -// go func(c net.Conn) {
40 -// defer c.Close()
41 -//
42 -// The outgoing packets will be labeled DiffServ assured forwarding
43 -// class 1 low drop precedence, known as AF11 packets.
44 -//
45 -// if err := ipv4.NewConn(c).SetTOS(DiffServAF11); err != nil {
46 -// // error handling
47 -// }
48 -// if _, err := c.Write(data); err != nil {
49 -// // error handling
50 -// }
51 -// }(c)
52 -// }
53 -//
54 -//
55 -// Multicasting
56 -//
57 -// The options for multicasting are available for net.UDPConn and
58 -// net.IPconn which are created as network connections that use the
59 -// IPv4 transport. A few network facilities must be prepared before
60 -// you begin multicasting, at a minimum joining network interfaces and
61 -// multicast groups.
62 -//
63 -// en0, err := net.InterfaceByName("en0")
64 -// if err != nil {
65 -// // error handling
66 -// }
67 -// en1, err := net.InterfaceByIndex(911)
68 -// if err != nil {
69 -// // error handling
70 -// }
71 -// group := net.IPv4(224, 0, 0, 250)
72 -//
73 -// First, an application listens to an appropriate address with an
74 -// appropriate service port.
75 -//
76 -// c, err := net.ListenPacket("udp4", "0.0.0.0:1024")
77 -// if err != nil {
78 -// // error handling
79 -// }
80 -// defer c.Close()
81 -//
82 -// Second, the application joins multicast groups, starts listening to
83 -// the groups on the specified network interfaces. Note that the
84 -// service port for transport layer protocol does not matter with this
85 -// operation as joining groups affects only network and link layer
86 -// protocols, such as IPv4 and Ethernet.
87 -//
88 -// p := ipv4.NewPacketConn(c)
89 -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: group}); err != nil {
90 -// // error handling
91 -// }
92 -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: group}); err != nil {
93 -// // error handling
94 -// }
95 -//
96 -// The application might set per packet control message transmissions
97 -// between the protocol stack within the kernel. When the application
98 -// needs a destination address on an incoming packet,
99 -// SetControlMessage of ipv4.PacketConn is used to enable control
100 -// message transmissons.
101 -//
102 -// if err := p.SetControlMessage(ipv4.FlagDst, true); err != nil {
103 -// // error handling
104 -// }
105 -//
106 -// The application could identify whether the received packets are
107 -// of interest by using the control message that contains the
108 -// destination address of the received packet.
109 -//
110 -// b := make([]byte, 1500)
111 -// for {
112 -// n, cm, src, err := p.ReadFrom(b)
113 -// if err != nil {
114 -// // error handling
115 -// }
116 -// if cm.Dst.IsMulticast() {
117 -// if cm.Dst.Equal(group)
118 -// // joined group, do something
119 -// } else {
120 -// // unknown group, discard
121 -// continue
122 -// }
123 -// }
124 -//
125 -// The application can also send both unicast and multicast packets.
126 -//
127 -// p.SetTOS(DiffServCS0)
128 -// p.SetTTL(16)
129 -// if _, err := p.WriteTo(data, nil, src); err != nil {
130 -// // error handling
131 -// }
132 -// dst := &net.UDPAddr{IP: group, Port: 1024}
133 -// for _, ifi := range []*net.Interface{en0, en1} {
134 -// if err := p.SetMulticastInterface(ifi); err != nil {
135 -// // error handling
136 -// }
137 -// p.SetMulticastTTL(2)
138 -// if _, err := p.WriteTo(data, nil, dst); err != nil {
139 -// // error handling
140 -// }
141 -// }
142 -// }
143 -//
144 -//
145 -// More multicasting
146 -//
147 -// An application that uses PacketConn or RawConn may join multiple
148 -// multicast groups. For example, a UDP listener with port 1024 might
149 -// join two different groups across over two different network
150 -// interfaces by using:
151 -//
152 -// c, err := net.ListenPacket("udp4", "0.0.0.0:1024")
153 -// if err != nil {
154 -// // error handling
155 -// }
156 -// defer c.Close()
157 -// p := ipv4.NewPacketConn(c)
158 -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil {
159 -// // error handling
160 -// }
161 -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}); err != nil {
162 -// // error handling
163 -// }
164 -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}); err != nil {
165 -// // error handling
166 -// }
167 -//
168 -// It is possible for multiple UDP listeners that listen on the same
169 -// UDP port to join the same multicast group. The net package will
170 -// provide a socket that listens to a wildcard address with reusable
171 -// UDP port when an appropriate multicast address prefix is passed to
172 -// the net.ListenPacket or net.ListenUDP.
173 -//
174 -// c1, err := net.ListenPacket("udp4", "224.0.0.0:1024")
175 -// if err != nil {
176 -// // error handling
177 -// }
178 -// defer c1.Close()
179 -// c2, err := net.ListenPacket("udp4", "224.0.0.0:1024")
180 -// if err != nil {
181 -// // error handling
182 -// }
183 -// defer c2.Close()
184 -// p1 := ipv4.NewPacketConn(c1)
185 -// if err := p1.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil {
186 -// // error handling
187 -// }
188 -// p2 := ipv4.NewPacketConn(c2)
189 -// if err := p2.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil {
190 -// // error handling
191 -// }
192 -//
193 -// Also it is possible for the application to leave or rejoin a
194 -// multicast group on the network interface.
195 -//
196 -// if err := p.LeaveGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil {
197 -// // error handling
198 -// }
199 -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 250)}); err != nil {
200 -// // error handling
201 -// }
202 -//
203 -//
204 -// Source-specific multicasting
205 -//
206 -// An application that uses PacketConn or RawConn on IGMPv3 supported
207 -// platform is able to join source-specific multicast groups.
208 -// The application may use JoinSourceSpecificGroup and
209 -// LeaveSourceSpecificGroup for the operation known as "include" mode,
210 -//
211 -// ssmgroup := net.UDPAddr{IP: net.IPv4(232, 7, 8, 9)}
212 -// ssmsource := net.UDPAddr{IP: net.IPv4(192, 168, 0, 1)})
213 -// if err := p.JoinSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil {
214 -// // error handling
215 -// }
216 -// if err := p.LeaveSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil {
217 -// // error handling
218 -// }
219 -//
220 -// or JoinGroup, ExcludeSourceSpecificGroup,
221 -// IncludeSourceSpecificGroup and LeaveGroup for the operation known
222 -// as "exclude" mode.
223 -//
224 -// exclsource := net.UDPAddr{IP: net.IPv4(192, 168, 0, 254)}
225 -// if err := p.JoinGroup(en0, &ssmgroup); err != nil {
226 -// // error handling
227 -// }
228 -// if err := p.ExcludeSourceSpecificGroup(en0, &ssmgroup, &exclsource); err != nil {
229 -// // error handling
230 -// }
231 -// if err := p.LeaveGroup(en0, &ssmgroup); err != nil {
232 -// // error handling
233 -// }
234 -//
235 -// Note that it depends on each platform implementation what happens
236 -// when an application which runs on IGMPv3 unsupported platform uses
237 -// JoinSourceSpecificGroup and LeaveSourceSpecificGroup.
238 -// In general the platform tries to fall back to conversations using
239 -// IGMPv1 or IGMPv2 and starts to listen to multicast traffic.
240 -// In the fallback case, ExcludeSourceSpecificGroup and
241 -// IncludeSourceSpecificGroup may return an error.
242 -package ipv4
Godeps/_workspace/src/golang.org/x/net/ipv4/endpoint.go deleted
-187
@@ -1,187 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "net"
9 - "syscall"
10 - "time"
11 -)
12 -
13 -// A Conn represents a network endpoint that uses the IPv4 transport.
14 -// It is used to control basic IP-level socket options such as TOS and
15 -// TTL.
16 -type Conn struct {
17 - genericOpt
18 -}
19 -
20 -type genericOpt struct {
21 - net.Conn
22 -}
23 -
24 -func (c *genericOpt) ok() bool { return c != nil && c.Conn != nil }
25 -
26 -// NewConn returns a new Conn.
27 -func NewConn(c net.Conn) *Conn {
28 - return &Conn{
29 - genericOpt: genericOpt{Conn: c},
30 - }
31 -}
32 -
33 -// A PacketConn represents a packet network endpoint that uses the
34 -// IPv4 transport. It is used to control several IP-level socket
35 -// options including multicasting. It also provides datagram based
36 -// network I/O methods specific to the IPv4 and higher layer protocols
37 -// such as UDP.
38 -type PacketConn struct {
39 - genericOpt
40 - dgramOpt
41 - payloadHandler
42 -}
43 -
44 -type dgramOpt struct {
45 - net.PacketConn
46 -}
47 -
48 -func (c *dgramOpt) ok() bool { return c != nil && c.PacketConn != nil }
49 -
50 -// SetControlMessage sets the per packet IP-level socket options.
51 -func (c *PacketConn) SetControlMessage(cf ControlFlags, on bool) error {
52 - if !c.payloadHandler.ok() {
53 - return syscall.EINVAL
54 - }
55 - fd, err := c.payloadHandler.sysfd()
56 - if err != nil {
57 - return err
58 - }
59 - return setControlMessage(fd, &c.payloadHandler.rawOpt, cf, on)
60 -}
61 -
62 -// SetDeadline sets the read and write deadlines associated with the
63 -// endpoint.
64 -func (c *PacketConn) SetDeadline(t time.Time) error {
65 - if !c.payloadHandler.ok() {
66 - return syscall.EINVAL
67 - }
68 - return c.payloadHandler.PacketConn.SetDeadline(t)
69 -}
70 -
71 -// SetReadDeadline sets the read deadline associated with the
72 -// endpoint.
73 -func (c *PacketConn) SetReadDeadline(t time.Time) error {
74 - if !c.payloadHandler.ok() {
75 - return syscall.EINVAL
76 - }
77 - return c.payloadHandler.PacketConn.SetReadDeadline(t)
78 -}
79 -
80 -// SetWriteDeadline sets the write deadline associated with the
81 -// endpoint.
82 -func (c *PacketConn) SetWriteDeadline(t time.Time) error {
83 - if !c.payloadHandler.ok() {
84 - return syscall.EINVAL
85 - }
86 - return c.payloadHandler.PacketConn.SetWriteDeadline(t)
87 -}
88 -
89 -// Close closes the endpoint.
90 -func (c *PacketConn) Close() error {
91 - if !c.payloadHandler.ok() {
92 - return syscall.EINVAL
93 - }
94 - return c.payloadHandler.PacketConn.Close()
95 -}
96 -
97 -// NewPacketConn returns a new PacketConn using c as its underlying
98 -// transport.
99 -func NewPacketConn(c net.PacketConn) *PacketConn {
100 - p := &PacketConn{
101 - genericOpt: genericOpt{Conn: c.(net.Conn)},
102 - dgramOpt: dgramOpt{PacketConn: c},
103 - payloadHandler: payloadHandler{PacketConn: c},
104 - }
105 - if _, ok := c.(*net.IPConn); ok && sockOpts[ssoStripHeader].name > 0 {
106 - if fd, err := p.payloadHandler.sysfd(); err == nil {
107 - setInt(fd, &sockOpts[ssoStripHeader], boolint(true))
108 - }
109 - }
110 - return p
111 -}
112 -
113 -// A RawConn represents a packet network endpoint that uses the IPv4
114 -// transport. It is used to control several IP-level socket options
115 -// including IPv4 header manipulation. It also provides datagram
116 -// based network I/O methods specific to the IPv4 and higher layer
117 -// protocols that handle IPv4 datagram directly such as OSPF, GRE.
118 -type RawConn struct {
119 - genericOpt
120 - dgramOpt
121 - packetHandler
122 -}
123 -
124 -// SetControlMessage sets the per packet IP-level socket options.
125 -func (c *RawConn) SetControlMessage(cf ControlFlags, on bool) error {
126 - if !c.packetHandler.ok() {
127 - return syscall.EINVAL
128 - }
129 - fd, err := c.packetHandler.sysfd()
130 - if err != nil {
131 - return err
132 - }
133 - return setControlMessage(fd, &c.packetHandler.rawOpt, cf, on)
134 -}
135 -
136 -// SetDeadline sets the read and write deadlines associated with the
137 -// endpoint.
138 -func (c *RawConn) SetDeadline(t time.Time) error {
139 - if !c.packetHandler.ok() {
140 - return syscall.EINVAL
141 - }
142 - return c.packetHandler.c.SetDeadline(t)
143 -}
144 -
145 -// SetReadDeadline sets the read deadline associated with the
146 -// endpoint.
147 -func (c *RawConn) SetReadDeadline(t time.Time) error {
148 - if !c.packetHandler.ok() {
149 - return syscall.EINVAL
150 - }
151 - return c.packetHandler.c.SetReadDeadline(t)
152 -}
153 -
154 -// SetWriteDeadline sets the write deadline associated with the
155 -// endpoint.
156 -func (c *RawConn) SetWriteDeadline(t time.Time) error {
157 - if !c.packetHandler.ok() {
158 - return syscall.EINVAL
159 - }
160 - return c.packetHandler.c.SetWriteDeadline(t)
161 -}
162 -
163 -// Close closes the endpoint.
164 -func (c *RawConn) Close() error {
165 - if !c.packetHandler.ok() {
166 - return syscall.EINVAL
167 - }
168 - return c.packetHandler.c.Close()
169 -}
170 -
171 -// NewRawConn returns a new RawConn using c as its underlying
172 -// transport.
173 -func NewRawConn(c net.PacketConn) (*RawConn, error) {
174 - r := &RawConn{
175 - genericOpt: genericOpt{Conn: c.(net.Conn)},
176 - dgramOpt: dgramOpt{PacketConn: c},
177 - packetHandler: packetHandler{c: c.(*net.IPConn)},
178 - }
179 - fd, err := r.packetHandler.sysfd()
180 - if err != nil {
181 - return nil, err
182 - }
183 - if err := setInt(fd, &sockOpts[ssoHeaderPrepend], boolint(true)); err != nil {
184 - return nil, err
185 - }
186 - return r, nil
187 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/example_test.go deleted
-223
@@ -1,223 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4_test
6 -
7 -import (
8 - "fmt"
9 - "log"
10 - "net"
11 - "os"
12 - "runtime"
13 - "time"
14 -
15 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
16 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv4"
17 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/icmp"
18 -)
19 -
20 -func ExampleConn_markingTCP() {
21 - ln, err := net.Listen("tcp4", "0.0.0.0:1024")
22 - if err != nil {
23 - log.Fatal(err)
24 - }
25 - defer ln.Close()
26 -
27 - for {
28 - c, err := ln.Accept()
29 - if err != nil {
30 - log.Fatal(err)
31 - }
32 - go func(c net.Conn) {
33 - defer c.Close()
34 - p := ipv4.NewConn(c)
35 - if err := p.SetTOS(iana.DiffServAF11); err != nil {
36 - log.Fatal(err)
37 - }
38 - if err := p.SetTTL(128); err != nil {
39 - log.Fatal(err)
40 - }
41 - if _, err := c.Write([]byte("HELLO-R-U-THERE-ACK")); err != nil {
42 - log.Fatal(err)
43 - }
44 - }(c)
45 - }
46 -}
47 -
48 -func ExamplePacketConn_servingOneShotMulticastDNS() {
49 - c, err := net.ListenPacket("udp4", "0.0.0.0:5353") // mDNS over UDP
50 - if err != nil {
51 - log.Fatal(err)
52 - }
53 - defer c.Close()
54 - p := ipv4.NewPacketConn(c)
55 -
56 - en0, err := net.InterfaceByName("en0")
57 - if err != nil {
58 - log.Fatal(err)
59 - }
60 - mDNSLinkLocal := net.UDPAddr{IP: net.IPv4(224, 0, 0, 251)}
61 - if err := p.JoinGroup(en0, &mDNSLinkLocal); err != nil {
62 - log.Fatal(err)
63 - }
64 - defer p.LeaveGroup(en0, &mDNSLinkLocal)
65 - if err := p.SetControlMessage(ipv4.FlagDst, true); err != nil {
66 - log.Fatal(err)
67 - }
68 -
69 - b := make([]byte, 1500)
70 - for {
71 - _, cm, peer, err := p.ReadFrom(b)
72 - if err != nil {
73 - log.Fatal(err)
74 - }
75 - if !cm.Dst.IsMulticast() || !cm.Dst.Equal(mDNSLinkLocal.IP) {
76 - continue
77 - }
78 - answers := []byte("FAKE-MDNS-ANSWERS") // fake mDNS answers, you need to implement this
79 - if _, err := p.WriteTo(answers, nil, peer); err != nil {
80 - log.Fatal(err)
81 - }
82 - }
83 -}
84 -
85 -func ExamplePacketConn_tracingIPPacketRoute() {
86 - // Tracing an IP packet route to www.google.com.
87 -
88 - const host = "www.google.com"
89 - ips, err := net.LookupIP(host)
90 - if err != nil {
91 - log.Fatal(err)
92 - }
93 - var dst net.IPAddr
94 - for _, ip := range ips {
95 - if ip.To4() != nil {
96 - dst.IP = ip
97 - fmt.Printf("using %v for tracing an IP packet route to %s\n", dst.IP, host)
98 - break
99 - }
100 - }
101 - if dst.IP == nil {
102 - log.Fatal("no A record found")
103 - }
104 -
105 - c, err := net.ListenPacket(fmt.Sprintf("ip4:%d", iana.ProtocolICMP), "0.0.0.0") // ICMP for IPv4
106 - if err != nil {
107 - log.Fatal(err)
108 - }
109 - defer c.Close()
110 - p := ipv4.NewPacketConn(c)
111 -
112 - if err := p.SetControlMessage(ipv4.FlagTTL|ipv4.FlagSrc|ipv4.FlagDst|ipv4.FlagInterface, true); err != nil {
113 - log.Fatal(err)
114 - }
115 - wm := icmp.Message{
116 - Type: ipv4.ICMPTypeEcho, Code: 0,
117 - Body: &icmp.Echo{
118 - ID: os.Getpid() & 0xffff,
119 - Data: []byte("HELLO-R-U-THERE"),
120 - },
121 - }
122 -
123 - rb := make([]byte, 1500)
124 - for i := 1; i <= 64; i++ { // up to 64 hops
125 - wm.Body.(*icmp.Echo).Seq = i
126 - wb, err := wm.Marshal(nil)
127 - if err != nil {
128 - log.Fatal(err)
129 - }
130 - if err := p.SetTTL(i); err != nil {
131 - log.Fatal(err)
132 - }
133 -
134 - // In the real world usually there are several
135 - // multiple traffic-engineered paths for each hop.
136 - // You may need to probe a few times to each hop.
137 - begin := time.Now()
138 - if _, err := p.WriteTo(wb, nil, &dst); err != nil {
139 - log.Fatal(err)
140 - }
141 - if err := p.SetReadDeadline(time.Now().Add(3 * time.Second)); err != nil {
142 - log.Fatal(err)
143 - }
144 - n, cm, peer, err := p.ReadFrom(rb)
145 - if err != nil {
146 - if err, ok := err.(net.Error); ok && err.Timeout() {
147 - fmt.Printf("%v\t*\n", i)
148 - continue
149 - }
150 - log.Fatal(err)
151 - }
152 - rm, err := icmp.ParseMessage(iana.ProtocolICMP, rb[:n])
153 - if err != nil {
154 - log.Fatal(err)
155 - }
156 - rtt := time.Since(begin)
157 -
158 - // In the real world you need to determine whether the
159 - // received message is yours using ControlMessage.Src,
160 - // ControlMessage.Dst, icmp.Echo.ID and icmp.Echo.Seq.
161 - switch rm.Type {
162 - case ipv4.ICMPTypeTimeExceeded:
163 - names, _ := net.LookupAddr(peer.String())
164 - fmt.Printf("%d\t%v %+v %v\n\t%+v\n", i, peer, names, rtt, cm)
165 - case ipv4.ICMPTypeEchoReply:
166 - names, _ := net.LookupAddr(peer.String())
167 - fmt.Printf("%d\t%v %+v %v\n\t%+v\n", i, peer, names, rtt, cm)
168 - return
169 - default:
170 - log.Printf("unknown ICMP message: %+v\n", rm)
171 - }
172 - }
173 -}
174 -
175 -func ExampleRawConn_advertisingOSPFHello() {
176 - c, err := net.ListenPacket(fmt.Sprintf("ip4:%d", iana.ProtocolOSPFIGP), "0.0.0.0") // OSPF for IPv4
177 - if err != nil {
178 - log.Fatal(err)
179 - }
180 - defer c.Close()
181 - r, err := ipv4.NewRawConn(c)
182 - if err != nil {
183 - log.Fatal(err)
184 - }
185 -
186 - en0, err := net.InterfaceByName("en0")
187 - if err != nil {
188 - log.Fatal(err)
189 - }
190 - allSPFRouters := net.IPAddr{IP: net.IPv4(224, 0, 0, 5)}
191 - if err := r.JoinGroup(en0, &allSPFRouters); err != nil {
192 - log.Fatal(err)
193 - }
194 - defer r.LeaveGroup(en0, &allSPFRouters)
195 -
196 - hello := make([]byte, 24) // fake hello data, you need to implement this
197 - ospf := make([]byte, 24) // fake ospf header, you need to implement this
198 - ospf[0] = 2 // version 2
199 - ospf[1] = 1 // hello packet
200 - ospf = append(ospf, hello...)
201 - iph := &ipv4.Header{
202 - Version: ipv4.Version,
203 - Len: ipv4.HeaderLen,
204 - TOS: iana.DiffServCS6,
205 - TotalLen: ipv4.HeaderLen + len(ospf),
206 - TTL: 1,
207 - Protocol: iana.ProtocolOSPFIGP,
208 - Dst: allSPFRouters.IP.To4(),
209 - }
210 -
211 - var cm *ipv4.ControlMessage
212 - switch runtime.GOOS {
213 - case "darwin", "linux":
214 - cm = &ipv4.ControlMessage{IfIndex: en0.Index}
215 - default:
216 - if err := r.SetMulticastInterface(en0); err != nil {
217 - log.Fatal(err)
218 - }
219 - }
220 - if err := r.WriteTo(iph, ospf, cm); err != nil {
221 - log.Fatal(err)
222 - }
223 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/gen.go deleted
-208
@@ -1,208 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -//go:generate go run gen.go
8 -
9 -// This program generates system adaptation constants and types,
10 -// internet protocol constants and tables by reading template files
11 -// and IANA protocol registries.
12 -package main
13 -
14 -import (
15 - "bytes"
16 - "encoding/xml"
17 - "fmt"
18 - "go/format"
19 - "io"
20 - "io/ioutil"
21 - "net/http"
22 - "os"
23 - "os/exec"
24 - "runtime"
25 - "strconv"
26 - "strings"
27 -)
28 -
29 -func main() {
30 - if err := genzsys(); err != nil {
31 - fmt.Fprintln(os.Stderr, err)
32 - os.Exit(1)
33 - }
34 - if err := geniana(); err != nil {
35 - fmt.Fprintln(os.Stderr, err)
36 - os.Exit(1)
37 - }
38 -}
39 -
40 -func genzsys() error {
41 - defs := "defs_" + runtime.GOOS + ".go"
42 - f, err := os.Open(defs)
43 - if err != nil {
44 - if os.IsNotExist(err) {
45 - return nil
46 - }
47 - return err
48 - }
49 - f.Close()
50 - cmd := exec.Command("go", "tool", "cgo", "-godefs", defs)
51 - b, err := cmd.Output()
52 - if err != nil {
53 - return err
54 - }
55 - // The ipv4 pacakge still supports go1.2, and so we need to
56 - // take care of additional platforms in go1.3 and above for
57 - // working with go1.2.
58 - switch {
59 - case runtime.GOOS == "dragonfly" || runtime.GOOS == "solaris":
60 - b = bytes.Replace(b, []byte("package ipv4\n"), []byte("// +build "+runtime.GOOS+"\n\npackage ipv4\n"), 1)
61 - case runtime.GOOS == "linux" && (runtime.GOARCH == "arm64" || runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le"):
62 - b = bytes.Replace(b, []byte("package ipv4\n"), []byte("// +build "+runtime.GOOS+","+runtime.GOARCH+"\n\npackage ipv4\n"), 1)
63 - }
64 - b, err = format.Source(b)
65 - if err != nil {
66 - return err
67 - }
68 - zsys := "zsys_" + runtime.GOOS + ".go"
69 - switch runtime.GOOS {
70 - case "freebsd", "linux":
71 - zsys = "zsys_" + runtime.GOOS + "_" + runtime.GOARCH + ".go"
72 - }
73 - if err := ioutil.WriteFile(zsys, b, 0644); err != nil {
74 - return err
75 - }
76 - return nil
77 -}
78 -
79 -var registries = []struct {
80 - url string
81 - parse func(io.Writer, io.Reader) error
82 -}{
83 - {
84 - "http://www.iana.org/assignments/icmp-parameters/icmp-parameters.xml",
85 - parseICMPv4Parameters,
86 - },
87 -}
88 -
89 -func geniana() error {
90 - var bb bytes.Buffer
91 - fmt.Fprintf(&bb, "// go generate gen.go\n")
92 - fmt.Fprintf(&bb, "// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n")
93 - fmt.Fprintf(&bb, "package ipv4\n\n")
94 - for _, r := range registries {
95 - resp, err := http.Get(r.url)
96 - if err != nil {
97 - return err
98 - }
99 - defer resp.Body.Close()
100 - if resp.StatusCode != http.StatusOK {
101 - return fmt.Errorf("got HTTP status code %v for %v\n", resp.StatusCode, r.url)
102 - }
103 - if err := r.parse(&bb, resp.Body); err != nil {
104 - return err
105 - }
106 - fmt.Fprintf(&bb, "\n")
107 - }
108 - b, err := format.Source(bb.Bytes())
109 - if err != nil {
110 - return err
111 - }
112 - if err := ioutil.WriteFile("iana.go", b, 0644); err != nil {
113 - return err
114 - }
115 - return nil
116 -}
117 -
118 -func parseICMPv4Parameters(w io.Writer, r io.Reader) error {
119 - dec := xml.NewDecoder(r)
120 - var icp icmpv4Parameters
121 - if err := dec.Decode(&icp); err != nil {
122 - return err
123 - }
124 - prs := icp.escape()
125 - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated)
126 - fmt.Fprintf(w, "const (\n")
127 - for _, pr := range prs {
128 - if pr.Descr == "" {
129 - continue
130 - }
131 - fmt.Fprintf(w, "ICMPType%s ICMPType = %d", pr.Descr, pr.Value)
132 - fmt.Fprintf(w, "// %s\n", pr.OrigDescr)
133 - }
134 - fmt.Fprintf(w, ")\n\n")
135 - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated)
136 - fmt.Fprintf(w, "var icmpTypes = map[ICMPType]string{\n")
137 - for _, pr := range prs {
138 - if pr.Descr == "" {
139 - continue
140 - }
141 - fmt.Fprintf(w, "%d: %q,\n", pr.Value, strings.ToLower(pr.OrigDescr))
142 - }
143 - fmt.Fprintf(w, "}\n")
144 - return nil
145 -}
146 -
147 -type icmpv4Parameters struct {
148 - XMLName xml.Name `xml:"registry"`
149 - Title string `xml:"title"`
150 - Updated string `xml:"updated"`
151 - Registries []struct {
152 - Title string `xml:"title"`
153 - Records []struct {
154 - Value string `xml:"value"`
155 - Descr string `xml:"description"`
156 - } `xml:"record"`
157 - } `xml:"registry"`
158 -}
159 -
160 -type canonICMPv4ParamRecord struct {
161 - OrigDescr string
162 - Descr string
163 - Value int
164 -}
165 -
166 -func (icp *icmpv4Parameters) escape() []canonICMPv4ParamRecord {
167 - id := -1
168 - for i, r := range icp.Registries {
169 - if strings.Contains(r.Title, "Type") || strings.Contains(r.Title, "type") {
170 - id = i
171 - break
172 - }
173 - }
174 - if id < 0 {
175 - return nil
176 - }
177 - prs := make([]canonICMPv4ParamRecord, len(icp.Registries[id].Records))
178 - sr := strings.NewReplacer(
179 - "Messages", "",
180 - "Message", "",
181 - "ICMP", "",
182 - "+", "P",
183 - "-", "",
184 - "/", "",
185 - ".", "",
186 - " ", "",
187 - )
188 - for i, pr := range icp.Registries[id].Records {
189 - if strings.Contains(pr.Descr, "Reserved") ||
190 - strings.Contains(pr.Descr, "Unassigned") ||
191 - strings.Contains(pr.Descr, "Deprecated") ||
192 - strings.Contains(pr.Descr, "Experiment") ||
193 - strings.Contains(pr.Descr, "experiment") {
194 - continue
195 - }
196 - ss := strings.Split(pr.Descr, "\n")
197 - if len(ss) > 1 {
198 - prs[i].Descr = strings.Join(ss, " ")
199 - } else {
200 - prs[i].Descr = ss[0]
201 - }
202 - s := strings.TrimSpace(prs[i].Descr)
203 - prs[i].OrigDescr = s
204 - prs[i].Descr = sr.Replace(s)
205 - prs[i].Value, _ = strconv.Atoi(pr.Value)
206 - }
207 - return prs
208 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/genericopt_posix.go deleted
-59
@@ -1,59 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux netbsd openbsd windows
6 -
7 -package ipv4
8 -
9 -import "syscall"
10 -
11 -// TOS returns the type-of-service field value for outgoing packets.
12 -func (c *genericOpt) TOS() (int, error) {
13 - if !c.ok() {
14 - return 0, syscall.EINVAL
15 - }
16 - fd, err := c.sysfd()
17 - if err != nil {
18 - return 0, err
19 - }
20 - return getInt(fd, &sockOpts[ssoTOS])
21 -}
22 -
23 -// SetTOS sets the type-of-service field value for future outgoing
24 -// packets.
25 -func (c *genericOpt) SetTOS(tos int) error {
26 - if !c.ok() {
27 - return syscall.EINVAL
28 - }
29 - fd, err := c.sysfd()
30 - if err != nil {
31 - return err
32 - }
33 - return setInt(fd, &sockOpts[ssoTOS], tos)
34 -}
35 -
36 -// TTL returns the time-to-live field value for outgoing packets.
37 -func (c *genericOpt) TTL() (int, error) {
38 - if !c.ok() {
39 - return 0, syscall.EINVAL
40 - }
41 - fd, err := c.sysfd()
42 - if err != nil {
43 - return 0, err
44 - }
45 - return getInt(fd, &sockOpts[ssoTTL])
46 -}
47 -
48 -// SetTTL sets the time-to-live field value for future outgoing
49 -// packets.
50 -func (c *genericOpt) SetTTL(ttl int) error {
51 - if !c.ok() {
52 - return syscall.EINVAL
53 - }
54 - fd, err := c.sysfd()
55 - if err != nil {
56 - return err
57 - }
58 - return setInt(fd, &sockOpts[ssoTTL], ttl)
59 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/genericopt_stub.go deleted
-29
@@ -1,29 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9 solaris
6 -
7 -package ipv4
8 -
9 -// TOS returns the type-of-service field value for outgoing packets.
10 -func (c *genericOpt) TOS() (int, error) {
11 - return 0, errOpNoSupport
12 -}
13 -
14 -// SetTOS sets the type-of-service field value for future outgoing
15 -// packets.
16 -func (c *genericOpt) SetTOS(tos int) error {
17 - return errOpNoSupport
18 -}
19 -
20 -// TTL returns the time-to-live field value for outgoing packets.
21 -func (c *genericOpt) TTL() (int, error) {
22 - return 0, errOpNoSupport
23 -}
24 -
25 -// SetTTL sets the time-to-live field value for future outgoing
26 -// packets.
27 -func (c *genericOpt) SetTTL(ttl int) error {
28 - return errOpNoSupport
29 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/header.go deleted
-149
@@ -1,149 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "errors"
9 - "fmt"
10 - "net"
11 - "runtime"
12 - "syscall"
13 - "unsafe"
14 -)
15 -
16 -var (
17 - errMissingAddress = errors.New("missing address")
18 - errMissingHeader = errors.New("missing header")
19 - errHeaderTooShort = errors.New("header too short")
20 - errBufferTooShort = errors.New("buffer too short")
21 - errInvalidConnType = errors.New("invalid conn type")
22 -)
23 -
24 -const (
25 - Version = 4 // protocol version
26 - HeaderLen = 20 // header length without extension headers
27 - maxHeaderLen = 60 // sensible default, revisit if later RFCs define new usage of version and header length fields
28 -)
29 -
30 -type HeaderFlags int
31 -
32 -const (
33 - MoreFragments HeaderFlags = 1 << iota // more fragments flag
34 - DontFragment // don't fragment flag
35 -)
36 -
37 -// A Header represents an IPv4 header.
38 -type Header struct {
39 - Version int // protocol version
40 - Len int // header length
41 - TOS int // type-of-service
42 - TotalLen int // packet total length
43 - ID int // identification
44 - Flags HeaderFlags // flags
45 - FragOff int // fragment offset
46 - TTL int // time-to-live
47 - Protocol int // next protocol
48 - Checksum int // checksum
49 - Src net.IP // source address
50 - Dst net.IP // destination address
51 - Options []byte // options, extension headers
52 -}
53 -
54 -func (h *Header) String() string {
55 - if h == nil {
56 - return "<nil>"
57 - }
58 - return fmt.Sprintf("ver: %v, hdrlen: %v, tos: %#x, totallen: %v, id: %#x, flags: %#x, fragoff: %#x, ttl: %v, proto: %v, cksum: %#x, src: %v, dst: %v", h.Version, h.Len, h.TOS, h.TotalLen, h.ID, h.Flags, h.FragOff, h.TTL, h.Protocol, h.Checksum, h.Src, h.Dst)
59 -}
60 -
61 -// Marshal returns the binary encoding of the IPv4 header h.
62 -func (h *Header) Marshal() ([]byte, error) {
63 - if h == nil {
64 - return nil, syscall.EINVAL
65 - }
66 - if h.Len < HeaderLen {
67 - return nil, errHeaderTooShort
68 - }
69 - hdrlen := HeaderLen + len(h.Options)
70 - b := make([]byte, hdrlen)
71 - b[0] = byte(Version<<4 | (hdrlen >> 2 & 0x0f))
72 - b[1] = byte(h.TOS)
73 - flagsAndFragOff := (h.FragOff & 0x1fff) | int(h.Flags<<13)
74 - switch runtime.GOOS {
75 - case "darwin", "dragonfly", "freebsd", "netbsd":
76 - // TODO(mikio): fix potential misaligned memory access
77 - *(*uint16)(unsafe.Pointer(&b[2:3][0])) = uint16(h.TotalLen)
78 - *(*uint16)(unsafe.Pointer(&b[6:7][0])) = uint16(flagsAndFragOff)
79 - default:
80 - b[2], b[3] = byte(h.TotalLen>>8), byte(h.TotalLen)
81 - b[6], b[7] = byte(flagsAndFragOff>>8), byte(flagsAndFragOff)
82 - }
83 - b[4], b[5] = byte(h.ID>>8), byte(h.ID)
84 - b[8] = byte(h.TTL)
85 - b[9] = byte(h.Protocol)
86 - b[10], b[11] = byte(h.Checksum>>8), byte(h.Checksum)
87 - if ip := h.Src.To4(); ip != nil {
88 - copy(b[12:16], ip[:net.IPv4len])
89 - }
90 - if ip := h.Dst.To4(); ip != nil {
91 - copy(b[16:20], ip[:net.IPv4len])
92 - } else {
93 - return nil, errMissingAddress
94 - }
95 - if len(h.Options) > 0 {
96 - copy(b[HeaderLen:], h.Options)
97 - }
98 - return b, nil
99 -}
100 -
101 -// See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html.
102 -var freebsdVersion uint32
103 -
104 -// ParseHeader parses b as an IPv4 header.
105 -func ParseHeader(b []byte) (*Header, error) {
106 - if len(b) < HeaderLen {
107 - return nil, errHeaderTooShort
108 - }
109 - hdrlen := int(b[0]&0x0f) << 2
110 - if hdrlen > len(b) {
111 - return nil, errBufferTooShort
112 - }
113 - h := &Header{
114 - Version: int(b[0] >> 4),
115 - Len: hdrlen,
116 - TOS: int(b[1]),
117 - ID: int(b[4])<<8 | int(b[5]),
118 - TTL: int(b[8]),
119 - Protocol: int(b[9]),
120 - Checksum: int(b[10])<<8 | int(b[11]),
121 - Src: net.IPv4(b[12], b[13], b[14], b[15]),
122 - Dst: net.IPv4(b[16], b[17], b[18], b[19]),
123 - }
124 - switch runtime.GOOS {
125 - case "darwin", "dragonfly", "netbsd":
126 - // TODO(mikio): fix potential misaligned memory access
127 - h.TotalLen = int(*(*uint16)(unsafe.Pointer(&b[2:3][0]))) + hdrlen
128 - // TODO(mikio): fix potential misaligned memory access
129 - h.FragOff = int(*(*uint16)(unsafe.Pointer(&b[6:7][0])))
130 - case "freebsd":
131 - // TODO(mikio): fix potential misaligned memory access
132 - h.TotalLen = int(*(*uint16)(unsafe.Pointer(&b[2:3][0])))
133 - if freebsdVersion < 1000000 {
134 - h.TotalLen += hdrlen
135 - }
136 - // TODO(mikio): fix potential misaligned memory access
137 - h.FragOff = int(*(*uint16)(unsafe.Pointer(&b[6:7][0])))
138 - default:
139 - h.TotalLen = int(b[2])<<8 | int(b[3])
140 - h.FragOff = int(b[6])<<8 | int(b[7])
141 - }
142 - h.Flags = HeaderFlags(h.FragOff&0xe000) >> 13
143 - h.FragOff = h.FragOff & 0x1fff
144 - if hdrlen-HeaderLen > 0 {
145 - h.Options = make([]byte, hdrlen-HeaderLen)
146 - copy(h.Options, b[HeaderLen:])
147 - }
148 - return h, nil
149 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/header_test.go deleted
-114
@@ -1,114 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "bytes"
9 - "net"
10 - "reflect"
11 - "runtime"
12 - "testing"
13 -)
14 -
15 -var (
16 - wireHeaderFromKernel = [HeaderLen]byte{
17 - 0x45, 0x01, 0xbe, 0xef,
18 - 0xca, 0xfe, 0x45, 0xdc,
19 - 0xff, 0x01, 0xde, 0xad,
20 - 172, 16, 254, 254,
21 - 192, 168, 0, 1,
22 - }
23 - wireHeaderToKernel = [HeaderLen]byte{
24 - 0x45, 0x01, 0xbe, 0xef,
25 - 0xca, 0xfe, 0x45, 0xdc,
26 - 0xff, 0x01, 0xde, 0xad,
27 - 172, 16, 254, 254,
28 - 192, 168, 0, 1,
29 - }
30 - wireHeaderFromTradBSDKernel = [HeaderLen]byte{
31 - 0x45, 0x01, 0xdb, 0xbe,
32 - 0xca, 0xfe, 0xdc, 0x45,
33 - 0xff, 0x01, 0xde, 0xad,
34 - 172, 16, 254, 254,
35 - 192, 168, 0, 1,
36 - }
37 - wireHeaderFromFreeBSD10Kernel = [HeaderLen]byte{
38 - 0x45, 0x01, 0xef, 0xbe,
39 - 0xca, 0xfe, 0xdc, 0x45,
40 - 0xff, 0x01, 0xde, 0xad,
41 - 172, 16, 254, 254,
42 - 192, 168, 0, 1,
43 - }
44 - wireHeaderToTradBSDKernel = [HeaderLen]byte{
45 - 0x45, 0x01, 0xef, 0xbe,
46 - 0xca, 0xfe, 0xdc, 0x45,
47 - 0xff, 0x01, 0xde, 0xad,
48 - 172, 16, 254, 254,
49 - 192, 168, 0, 1,
50 - }
51 - // TODO(mikio): Add platform dependent wire header formats when
52 - // we support new platforms.
53 -
54 - testHeader = &Header{
55 - Version: Version,
56 - Len: HeaderLen,
57 - TOS: 1,
58 - TotalLen: 0xbeef,
59 - ID: 0xcafe,
60 - Flags: DontFragment,
61 - FragOff: 1500,
62 - TTL: 255,
63 - Protocol: 1,
64 - Checksum: 0xdead,
65 - Src: net.IPv4(172, 16, 254, 254),
66 - Dst: net.IPv4(192, 168, 0, 1),
67 - }
68 -)
69 -
70 -func TestMarshalHeader(t *testing.T) {
71 - b, err := testHeader.Marshal()
72 - if err != nil {
73 - t.Fatal(err)
74 - }
75 - var wh []byte
76 - switch runtime.GOOS {
77 - case "darwin", "dragonfly", "netbsd":
78 - wh = wireHeaderToTradBSDKernel[:]
79 - case "freebsd":
80 - if freebsdVersion < 1000000 {
81 - wh = wireHeaderToTradBSDKernel[:]
82 - } else {
83 - wh = wireHeaderFromFreeBSD10Kernel[:]
84 - }
85 - default:
86 - wh = wireHeaderToKernel[:]
87 - }
88 - if !bytes.Equal(b, wh) {
89 - t.Fatalf("got %#v; want %#v", b, wh)
90 - }
91 -}
92 -
93 -func TestParseHeader(t *testing.T) {
94 - var wh []byte
95 - switch runtime.GOOS {
96 - case "darwin", "dragonfly", "netbsd":
97 - wh = wireHeaderFromTradBSDKernel[:]
98 - case "freebsd":
99 - if freebsdVersion < 1000000 {
100 - wh = wireHeaderFromTradBSDKernel[:]
101 - } else {
102 - wh = wireHeaderFromFreeBSD10Kernel[:]
103 - }
104 - default:
105 - wh = wireHeaderFromKernel[:]
106 - }
107 - h, err := ParseHeader(wh)
108 - if err != nil {
109 - t.Fatal(err)
110 - }
111 - if !reflect.DeepEqual(h, testHeader) {
112 - t.Fatalf("got %#v; want %#v", h, testHeader)
113 - }
114 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/helper.go deleted
-37
@@ -1,37 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "errors"
9 - "net"
10 -)
11 -
12 -var (
13 - errOpNoSupport = errors.New("operation not supported")
14 - errNoSuchInterface = errors.New("no such interface")
15 - errNoSuchMulticastInterface = errors.New("no such multicast interface")
16 -)
17 -
18 -func boolint(b bool) int {
19 - if b {
20 - return 1
21 - }
22 - return 0
23 -}
24 -
25 -func netAddrToIP4(a net.Addr) net.IP {
26 - switch v := a.(type) {
27 - case *net.UDPAddr:
28 - if ip := v.IP.To4(); ip != nil {
29 - return ip
30 - }
31 - case *net.IPAddr:
32 - if ip := v.IP.To4(); ip != nil {
33 - return ip
34 - }
35 - }
36 - return nil
37 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/helper_stub.go deleted
-23
@@ -1,23 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9 solaris
6 -
7 -package ipv4
8 -
9 -func (c *genericOpt) sysfd() (int, error) {
10 - return 0, errOpNoSupport
11 -}
12 -
13 -func (c *dgramOpt) sysfd() (int, error) {
14 - return 0, errOpNoSupport
15 -}
16 -
17 -func (c *payloadHandler) sysfd() (int, error) {
18 - return 0, errOpNoSupport
19 -}
20 -
21 -func (c *packetHandler) sysfd() (int, error) {
22 - return 0, errOpNoSupport
23 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/helper_unix.go deleted
-50
@@ -1,50 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux netbsd openbsd
6 -
7 -package ipv4
8 -
9 -import (
10 - "net"
11 - "reflect"
12 -)
13 -
14 -func (c *genericOpt) sysfd() (int, error) {
15 - switch p := c.Conn.(type) {
16 - case *net.TCPConn, *net.UDPConn, *net.IPConn:
17 - return sysfd(p)
18 - }
19 - return 0, errInvalidConnType
20 -}
21 -
22 -func (c *dgramOpt) sysfd() (int, error) {
23 - switch p := c.PacketConn.(type) {
24 - case *net.UDPConn, *net.IPConn:
25 - return sysfd(p.(net.Conn))
26 - }
27 - return 0, errInvalidConnType
28 -}
29 -
30 -func (c *payloadHandler) sysfd() (int, error) {
31 - return sysfd(c.PacketConn.(net.Conn))
32 -}
33 -
34 -func (c *packetHandler) sysfd() (int, error) {
35 - return sysfd(c.c)
36 -}
37 -
38 -func sysfd(c net.Conn) (int, error) {
39 - cv := reflect.ValueOf(c)
40 - switch ce := cv.Elem(); ce.Kind() {
41 - case reflect.Struct:
42 - netfd := ce.FieldByName("conn").FieldByName("fd")
43 - switch fe := netfd.Elem(); fe.Kind() {
44 - case reflect.Struct:
45 - fd := fe.FieldByName("sysfd")
46 - return int(fd.Int()), nil
47 - }
48 - }
49 - return 0, errInvalidConnType
50 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/helper_windows.go deleted
-49
@@ -1,49 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "net"
9 - "reflect"
10 - "syscall"
11 -)
12 -
13 -func (c *genericOpt) sysfd() (syscall.Handle, error) {
14 - switch p := c.Conn.(type) {
15 - case *net.TCPConn, *net.UDPConn, *net.IPConn:
16 - return sysfd(p)
17 - }
18 - return syscall.InvalidHandle, errInvalidConnType
19 -}
20 -
21 -func (c *dgramOpt) sysfd() (syscall.Handle, error) {
22 - switch p := c.PacketConn.(type) {
23 - case *net.UDPConn, *net.IPConn:
24 - return sysfd(p.(net.Conn))
25 - }
26 - return syscall.InvalidHandle, errInvalidConnType
27 -}
28 -
29 -func (c *payloadHandler) sysfd() (syscall.Handle, error) {
30 - return sysfd(c.PacketConn.(net.Conn))
31 -}
32 -
33 -func (c *packetHandler) sysfd() (syscall.Handle, error) {
34 - return sysfd(c.c)
35 -}
36 -
37 -func sysfd(c net.Conn) (syscall.Handle, error) {
38 - cv := reflect.ValueOf(c)
39 - switch ce := cv.Elem(); ce.Kind() {
40 - case reflect.Struct:
41 - netfd := ce.FieldByName("conn").FieldByName("fd")
42 - switch fe := netfd.Elem(); fe.Kind() {
43 - case reflect.Struct:
44 - fd := fe.FieldByName("sysfd")
45 - return syscall.Handle(fd.Uint()), nil
46 - }
47 - }
48 - return syscall.InvalidHandle, errInvalidConnType
49 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/iana.go deleted
-34
@@ -1,34 +0,0 @@
1 -// go generate gen.go
2 -// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
3 -
4 -package ipv4
5 -
6 -// Internet Control Message Protocol (ICMP) Parameters, Updated: 2013-04-19
7 -const (
8 - ICMPTypeEchoReply ICMPType = 0 // Echo Reply
9 - ICMPTypeDestinationUnreachable ICMPType = 3 // Destination Unreachable
10 - ICMPTypeRedirect ICMPType = 5 // Redirect
11 - ICMPTypeEcho ICMPType = 8 // Echo
12 - ICMPTypeRouterAdvertisement ICMPType = 9 // Router Advertisement
13 - ICMPTypeRouterSolicitation ICMPType = 10 // Router Solicitation
14 - ICMPTypeTimeExceeded ICMPType = 11 // Time Exceeded
15 - ICMPTypeParameterProblem ICMPType = 12 // Parameter Problem
16 - ICMPTypeTimestamp ICMPType = 13 // Timestamp
17 - ICMPTypeTimestampReply ICMPType = 14 // Timestamp Reply
18 - ICMPTypePhoturis ICMPType = 40 // Photuris
19 -)
20 -
21 -// Internet Control Message Protocol (ICMP) Parameters, Updated: 2013-04-19
22 -var icmpTypes = map[ICMPType]string{
23 - 0: "echo reply",
24 - 3: "destination unreachable",
25 - 5: "redirect",
26 - 8: "echo",
27 - 9: "router advertisement",
28 - 10: "router solicitation",
29 - 11: "time exceeded",
30 - 12: "parameter problem",
31 - 13: "timestamp",
32 - 14: "timestamp reply",
33 - 40: "photuris",
34 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/icmp.go deleted
-57
@@ -1,57 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
8 -
9 -// An ICMPType represents a type of ICMP message.
10 -type ICMPType int
11 -
12 -func (typ ICMPType) String() string {
13 - s, ok := icmpTypes[typ]
14 - if !ok {
15 - return "<nil>"
16 - }
17 - return s
18 -}
19 -
20 -// Protocol returns the ICMPv4 protocol number.
21 -func (typ ICMPType) Protocol() int {
22 - return iana.ProtocolICMP
23 -}
24 -
25 -// An ICMPFilter represents an ICMP message filter for incoming
26 -// packets. The filter belongs to a packet delivery path on a host and
27 -// it cannot interact with forwarding packets or tunnel-outer packets.
28 -//
29 -// Note: RFC 2460 defines a reasonable role model and it works not
30 -// only for IPv6 but IPv4. A node means a device that implements IP.
31 -// A router means a node that forwards IP packets not explicitly
32 -// addressed to itself, and a host means a node that is not a router.
33 -type ICMPFilter struct {
34 - sysICMPFilter
35 -}
36 -
37 -// Accept accepts incoming ICMP packets including the type field value
38 -// typ.
39 -func (f *ICMPFilter) Accept(typ ICMPType) {
40 - f.accept(typ)
41 -}
42 -
43 -// Block blocks incoming ICMP packets including the type field value
44 -// typ.
45 -func (f *ICMPFilter) Block(typ ICMPType) {
46 - f.block(typ)
47 -}
48 -
49 -// SetAll sets the filter action to the filter.
50 -func (f *ICMPFilter) SetAll(block bool) {
51 - f.setAll(block)
52 -}
53 -
54 -// WillBlock reports whether the ICMP type will be blocked.
55 -func (f *ICMPFilter) WillBlock(typ ICMPType) bool {
56 - return f.willBlock(typ)
57 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/icmp_linux.go deleted
-25
@@ -1,25 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -func (f *sysICMPFilter) accept(typ ICMPType) {
8 - f.Data &^= 1 << (uint32(typ) & 31)
9 -}
10 -
11 -func (f *sysICMPFilter) block(typ ICMPType) {
12 - f.Data |= 1 << (uint32(typ) & 31)
13 -}
14 -
15 -func (f *sysICMPFilter) setAll(block bool) {
16 - if block {
17 - f.Data = 1<<32 - 1
18 - } else {
19 - f.Data = 0
20 - }
21 -}
22 -
23 -func (f *sysICMPFilter) willBlock(typ ICMPType) bool {
24 - return f.Data&(1<<(uint32(typ)&31)) != 0
25 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/icmp_stub.go deleted
-25
@@ -1,25 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build !linux
6 -
7 -package ipv4
8 -
9 -const sysSizeofICMPFilter = 0x0
10 -
11 -type sysICMPFilter struct {
12 -}
13 -
14 -func (f *sysICMPFilter) accept(typ ICMPType) {
15 -}
16 -
17 -func (f *sysICMPFilter) block(typ ICMPType) {
18 -}
19 -
20 -func (f *sysICMPFilter) setAll(block bool) {
21 -}
22 -
23 -func (f *sysICMPFilter) willBlock(typ ICMPType) bool {
24 - return false
25 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/icmp_test.go deleted
-95
@@ -1,95 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4_test
6 -
7 -import (
8 - "net"
9 - "reflect"
10 - "runtime"
11 - "testing"
12 -
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv4"
14 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
15 -)
16 -
17 -var icmpStringTests = []struct {
18 - in ipv4.ICMPType
19 - out string
20 -}{
21 - {ipv4.ICMPTypeDestinationUnreachable, "destination unreachable"},
22 -
23 - {256, "<nil>"},
24 -}
25 -
26 -func TestICMPString(t *testing.T) {
27 - for _, tt := range icmpStringTests {
28 - s := tt.in.String()
29 - if s != tt.out {
30 - t.Errorf("got %s; want %s", s, tt.out)
31 - }
32 - }
33 -}
34 -
35 -func TestICMPFilter(t *testing.T) {
36 - switch runtime.GOOS {
37 - case "linux":
38 - default:
39 - t.Skipf("not supported on %s", runtime.GOOS)
40 - }
41 -
42 - var f ipv4.ICMPFilter
43 - for _, toggle := range []bool{false, true} {
44 - f.SetAll(toggle)
45 - for _, typ := range []ipv4.ICMPType{
46 - ipv4.ICMPTypeDestinationUnreachable,
47 - ipv4.ICMPTypeEchoReply,
48 - ipv4.ICMPTypeTimeExceeded,
49 - ipv4.ICMPTypeParameterProblem,
50 - } {
51 - f.Accept(typ)
52 - if f.WillBlock(typ) {
53 - t.Errorf("ipv4.ICMPFilter.Set(%v, false) failed", typ)
54 - }
55 - f.Block(typ)
56 - if !f.WillBlock(typ) {
57 - t.Errorf("ipv4.ICMPFilter.Set(%v, true) failed", typ)
58 - }
59 - }
60 - }
61 -}
62 -
63 -func TestSetICMPFilter(t *testing.T) {
64 - switch runtime.GOOS {
65 - case "linux":
66 - default:
67 - t.Skipf("not supported on %s", runtime.GOOS)
68 - }
69 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
70 - t.Skip(m)
71 - }
72 -
73 - c, err := net.ListenPacket("ip4:icmp", "127.0.0.1")
74 - if err != nil {
75 - t.Fatal(err)
76 - }
77 - defer c.Close()
78 -
79 - p := ipv4.NewPacketConn(c)
80 -
81 - var f ipv4.ICMPFilter
82 - f.SetAll(true)
83 - f.Accept(ipv4.ICMPTypeEcho)
84 - f.Accept(ipv4.ICMPTypeEchoReply)
85 - if err := p.SetICMPFilter(&f); err != nil {
86 - t.Fatal(err)
87 - }
88 - kf, err := p.ICMPFilter()
89 - if err != nil {
90 - t.Fatal(err)
91 - }
92 - if !reflect.DeepEqual(kf, &f) {
93 - t.Fatalf("got %#v; want %#v", kf, f)
94 - }
95 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/mocktransponder_test.go deleted
-21
@@ -1,21 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4_test
6 -
7 -import (
8 - "net"
9 - "testing"
10 -)
11 -
12 -func acceptor(t *testing.T, ln net.Listener, done chan<- bool) {
13 - defer func() { done <- true }()
14 -
15 - c, err := ln.Accept()
16 - if err != nil {
17 - t.Error(err)
18 - return
19 - }
20 - c.Close()
21 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/multicast_test.go deleted
-334
@@ -1,334 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4_test
6 -
7 -import (
8 - "bytes"
9 - "net"
10 - "os"
11 - "runtime"
12 - "testing"
13 - "time"
14 -
15 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
16 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv4"
17 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/icmp"
18 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
19 -)
20 -
21 -var packetConnReadWriteMulticastUDPTests = []struct {
22 - addr string
23 - grp, src *net.UDPAddr
24 -}{
25 - {"224.0.0.0:0", &net.UDPAddr{IP: net.IPv4(224, 0, 0, 254)}, nil}, // see RFC 4727
26 -
27 - {"232.0.1.0:0", &net.UDPAddr{IP: net.IPv4(232, 0, 1, 254)}, &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771
28 -}
29 -
30 -func TestPacketConnReadWriteMulticastUDP(t *testing.T) {
31 - switch runtime.GOOS {
32 - case "nacl", "plan9", "solaris", "windows":
33 - t.Skipf("not supported on %s", runtime.GOOS)
34 - }
35 - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback)
36 - if ifi == nil {
37 - t.Skipf("not available on %s", runtime.GOOS)
38 - }
39 -
40 - for _, tt := range packetConnReadWriteMulticastUDPTests {
41 - c, err := net.ListenPacket("udp4", tt.addr)
42 - if err != nil {
43 - t.Fatal(err)
44 - }
45 - defer c.Close()
46 -
47 - grp := *tt.grp
48 - grp.Port = c.LocalAddr().(*net.UDPAddr).Port
49 - p := ipv4.NewPacketConn(c)
50 - defer p.Close()
51 - if tt.src == nil {
52 - if err := p.JoinGroup(ifi, &grp); err != nil {
53 - t.Fatal(err)
54 - }
55 - defer p.LeaveGroup(ifi, &grp)
56 - } else {
57 - if err := p.JoinSourceSpecificGroup(ifi, &grp, tt.src); err != nil {
58 - switch runtime.GOOS {
59 - case "freebsd", "linux":
60 - default: // platforms that don't support IGMPv2/3 fail here
61 - t.Logf("not supported on %s", runtime.GOOS)
62 - continue
63 - }
64 - t.Fatal(err)
65 - }
66 - defer p.LeaveSourceSpecificGroup(ifi, &grp, tt.src)
67 - }
68 - if err := p.SetMulticastInterface(ifi); err != nil {
69 - t.Fatal(err)
70 - }
71 - if _, err := p.MulticastInterface(); err != nil {
72 - t.Fatal(err)
73 - }
74 - if err := p.SetMulticastLoopback(true); err != nil {
75 - t.Fatal(err)
76 - }
77 - if _, err := p.MulticastLoopback(); err != nil {
78 - t.Fatal(err)
79 - }
80 - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface
81 - wb := []byte("HELLO-R-U-THERE")
82 -
83 - for i, toggle := range []bool{true, false, true} {
84 - if err := p.SetControlMessage(cf, toggle); err != nil {
85 - if nettest.ProtocolNotSupported(err) {
86 - t.Logf("not supported on %s", runtime.GOOS)
87 - continue
88 - }
89 - t.Fatal(err)
90 - }
91 - if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil {
92 - t.Fatal(err)
93 - }
94 - p.SetMulticastTTL(i + 1)
95 - if n, err := p.WriteTo(wb, nil, &grp); err != nil {
96 - t.Fatal(err)
97 - } else if n != len(wb) {
98 - t.Fatalf("got %v; want %v", n, len(wb))
99 - }
100 - rb := make([]byte, 128)
101 - if n, cm, _, err := p.ReadFrom(rb); err != nil {
102 - t.Fatal(err)
103 - } else if !bytes.Equal(rb[:n], wb) {
104 - t.Fatalf("got %v; want %v", rb[:n], wb)
105 - } else {
106 - t.Logf("rcvd cmsg: %v", cm)
107 - }
108 - }
109 - }
110 -}
111 -
112 -var packetConnReadWriteMulticastICMPTests = []struct {
113 - grp, src *net.IPAddr
114 -}{
115 - {&net.IPAddr{IP: net.IPv4(224, 0, 0, 254)}, nil}, // see RFC 4727
116 -
117 - {&net.IPAddr{IP: net.IPv4(232, 0, 1, 254)}, &net.IPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771
118 -}
119 -
120 -func TestPacketConnReadWriteMulticastICMP(t *testing.T) {
121 - switch runtime.GOOS {
122 - case "nacl", "plan9", "solaris", "windows":
123 - t.Skipf("not supported on %s", runtime.GOOS)
124 - }
125 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
126 - t.Skip(m)
127 - }
128 - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback)
129 - if ifi == nil {
130 - t.Skipf("not available on %s", runtime.GOOS)
131 - }
132 -
133 - for _, tt := range packetConnReadWriteMulticastICMPTests {
134 - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0")
135 - if err != nil {
136 - t.Fatal(err)
137 - }
138 - defer c.Close()
139 -
140 - p := ipv4.NewPacketConn(c)
141 - defer p.Close()
142 - if tt.src == nil {
143 - if err := p.JoinGroup(ifi, tt.grp); err != nil {
144 - t.Fatal(err)
145 - }
146 - defer p.LeaveGroup(ifi, tt.grp)
147 - } else {
148 - if err := p.JoinSourceSpecificGroup(ifi, tt.grp, tt.src); err != nil {
149 - switch runtime.GOOS {
150 - case "freebsd", "linux":
151 - default: // platforms that don't support IGMPv2/3 fail here
152 - t.Logf("not supported on %s", runtime.GOOS)
153 - continue
154 - }
155 - t.Fatal(err)
156 - }
157 - defer p.LeaveSourceSpecificGroup(ifi, tt.grp, tt.src)
158 - }
159 - if err := p.SetMulticastInterface(ifi); err != nil {
160 - t.Fatal(err)
161 - }
162 - if _, err := p.MulticastInterface(); err != nil {
163 - t.Fatal(err)
164 - }
165 - if err := p.SetMulticastLoopback(true); err != nil {
166 - t.Fatal(err)
167 - }
168 - if _, err := p.MulticastLoopback(); err != nil {
169 - t.Fatal(err)
170 - }
171 - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface
172 -
173 - for i, toggle := range []bool{true, false, true} {
174 - wb, err := (&icmp.Message{
175 - Type: ipv4.ICMPTypeEcho, Code: 0,
176 - Body: &icmp.Echo{
177 - ID: os.Getpid() & 0xffff, Seq: i + 1,
178 - Data: []byte("HELLO-R-U-THERE"),
179 - },
180 - }).Marshal(nil)
181 - if err != nil {
182 - t.Fatal(err)
183 - }
184 - if err := p.SetControlMessage(cf, toggle); err != nil {
185 - if nettest.ProtocolNotSupported(err) {
186 - t.Logf("not supported on %s", runtime.GOOS)
187 - continue
188 - }
189 - t.Fatal(err)
190 - }
191 - if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil {
192 - t.Fatal(err)
193 - }
194 - p.SetMulticastTTL(i + 1)
195 - if n, err := p.WriteTo(wb, nil, tt.grp); err != nil {
196 - t.Fatal(err)
197 - } else if n != len(wb) {
198 - t.Fatalf("got %v; want %v", n, len(wb))
199 - }
200 - rb := make([]byte, 128)
201 - if n, cm, _, err := p.ReadFrom(rb); err != nil {
202 - t.Fatal(err)
203 - } else {
204 - t.Logf("rcvd cmsg: %v", cm)
205 - m, err := icmp.ParseMessage(iana.ProtocolICMP, rb[:n])
206 - if err != nil {
207 - t.Fatal(err)
208 - }
209 - switch {
210 - case m.Type == ipv4.ICMPTypeEchoReply && m.Code == 0: // net.inet.icmp.bmcastecho=1
211 - case m.Type == ipv4.ICMPTypeEcho && m.Code == 0: // net.inet.icmp.bmcastecho=0
212 - default:
213 - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv4.ICMPTypeEchoReply, 0)
214 - }
215 - }
216 - }
217 - }
218 -}
219 -
220 -var rawConnReadWriteMulticastICMPTests = []struct {
221 - grp, src *net.IPAddr
222 -}{
223 - {&net.IPAddr{IP: net.IPv4(224, 0, 0, 254)}, nil}, // see RFC 4727
224 -
225 - {&net.IPAddr{IP: net.IPv4(232, 0, 1, 254)}, &net.IPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771
226 -}
227 -
228 -func TestRawConnReadWriteMulticastICMP(t *testing.T) {
229 - if testing.Short() {
230 - t.Skip("to avoid external network")
231 - }
232 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
233 - t.Skip(m)
234 - }
235 - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback)
236 - if ifi == nil {
237 - t.Skipf("not available on %s", runtime.GOOS)
238 - }
239 -
240 - for _, tt := range rawConnReadWriteMulticastICMPTests {
241 - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0")
242 - if err != nil {
243 - t.Fatal(err)
244 - }
245 - defer c.Close()
246 -
247 - r, err := ipv4.NewRawConn(c)
248 - if err != nil {
249 - t.Fatal(err)
250 - }
251 - defer r.Close()
252 - if tt.src == nil {
253 - if err := r.JoinGroup(ifi, tt.grp); err != nil {
254 - t.Fatal(err)
255 - }
256 - defer r.LeaveGroup(ifi, tt.grp)
257 - } else {
258 - if err := r.JoinSourceSpecificGroup(ifi, tt.grp, tt.src); err != nil {
259 - switch runtime.GOOS {
260 - case "freebsd", "linux":
261 - default: // platforms that don't support IGMPv2/3 fail here
262 - t.Logf("not supported on %s", runtime.GOOS)
263 - continue
264 - }
265 - t.Fatal(err)
266 - }
267 - defer r.LeaveSourceSpecificGroup(ifi, tt.grp, tt.src)
268 - }
269 - if err := r.SetMulticastInterface(ifi); err != nil {
270 - t.Fatal(err)
271 - }
272 - if _, err := r.MulticastInterface(); err != nil {
273 - t.Fatal(err)
274 - }
275 - if err := r.SetMulticastLoopback(true); err != nil {
276 - t.Fatal(err)
277 - }
278 - if _, err := r.MulticastLoopback(); err != nil {
279 - t.Fatal(err)
280 - }
281 - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface
282 -
283 - for i, toggle := range []bool{true, false, true} {
284 - wb, err := (&icmp.Message{
285 - Type: ipv4.ICMPTypeEcho, Code: 0,
286 - Body: &icmp.Echo{
287 - ID: os.Getpid() & 0xffff, Seq: i + 1,
288 - Data: []byte("HELLO-R-U-THERE"),
289 - },
290 - }).Marshal(nil)
291 - if err != nil {
292 - t.Fatal(err)
293 - }
294 - wh := &ipv4.Header{
295 - Version: ipv4.Version,
296 - Len: ipv4.HeaderLen,
297 - TOS: i + 1,
298 - TotalLen: ipv4.HeaderLen + len(wb),
299 - Protocol: 1,
300 - Dst: tt.grp.IP,
301 - }
302 - if err := r.SetControlMessage(cf, toggle); err != nil {
303 - if nettest.ProtocolNotSupported(err) {
304 - t.Logf("not supported on %s", runtime.GOOS)
305 - continue
306 - }
307 - t.Fatal(err)
308 - }
309 - if err := r.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil {
310 - t.Fatal(err)
311 - }
312 - r.SetMulticastTTL(i + 1)
313 - if err := r.WriteTo(wh, wb, nil); err != nil {
314 - t.Fatal(err)
315 - }
316 - rb := make([]byte, ipv4.HeaderLen+128)
317 - if rh, b, cm, err := r.ReadFrom(rb); err != nil {
318 - t.Fatal(err)
319 - } else {
320 - t.Logf("rcvd cmsg: %v", cm)
321 - m, err := icmp.ParseMessage(iana.ProtocolICMP, b)
322 - if err != nil {
323 - t.Fatal(err)
324 - }
325 - switch {
326 - case (rh.Dst.IsLoopback() || rh.Dst.IsLinkLocalUnicast() || rh.Dst.IsGlobalUnicast()) && m.Type == ipv4.ICMPTypeEchoReply && m.Code == 0: // net.inet.icmp.bmcastecho=1
327 - case rh.Dst.IsMulticast() && m.Type == ipv4.ICMPTypeEcho && m.Code == 0: // net.inet.icmp.bmcastecho=0
328 - default:
329 - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv4.ICMPTypeEchoReply, 0)
330 - }
331 - }
332 - }
333 - }
334 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/multicastlistener_test.go deleted
-249
@@ -1,249 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4_test
6 -
7 -import (
8 - "net"
9 - "runtime"
10 - "testing"
11 -
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv4"
13 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
14 -)
15 -
16 -var udpMultipleGroupListenerTests = []net.Addr{
17 - &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}, // see RFC 4727
18 - &net.UDPAddr{IP: net.IPv4(224, 0, 0, 250)},
19 - &net.UDPAddr{IP: net.IPv4(224, 0, 0, 254)},
20 -}
21 -
22 -func TestUDPSinglePacketConnWithMultipleGroupListeners(t *testing.T) {
23 - switch runtime.GOOS {
24 - case "nacl", "plan9", "solaris", "windows":
25 - t.Skipf("not supported on %s", runtime.GOOS)
26 - }
27 - if testing.Short() {
28 - t.Skip("to avoid external network")
29 - }
30 -
31 - for _, gaddr := range udpMultipleGroupListenerTests {
32 - c, err := net.ListenPacket("udp4", "0.0.0.0:0") // wildcard address with no reusable port
33 - if err != nil {
34 - t.Fatal(err)
35 - }
36 - defer c.Close()
37 -
38 - p := ipv4.NewPacketConn(c)
39 - var mift []*net.Interface
40 -
41 - ift, err := net.Interfaces()
42 - if err != nil {
43 - t.Fatal(err)
44 - }
45 - for i, ifi := range ift {
46 - if _, ok := nettest.IsMulticastCapable("ip4", &ifi); !ok {
47 - continue
48 - }
49 - if err := p.JoinGroup(&ifi, gaddr); err != nil {
50 - t.Fatal(err)
51 - }
52 - mift = append(mift, &ift[i])
53 - }
54 - for _, ifi := range mift {
55 - if err := p.LeaveGroup(ifi, gaddr); err != nil {
56 - t.Fatal(err)
57 - }
58 - }
59 - }
60 -}
61 -
62 -func TestUDPMultiplePacketConnWithMultipleGroupListeners(t *testing.T) {
63 - switch runtime.GOOS {
64 - case "nacl", "plan9", "solaris", "windows":
65 - t.Skipf("not supported on %s", runtime.GOOS)
66 - }
67 - if testing.Short() {
68 - t.Skip("to avoid external network")
69 - }
70 -
71 - for _, gaddr := range udpMultipleGroupListenerTests {
72 - c1, err := net.ListenPacket("udp4", "224.0.0.0:1024") // wildcard address with reusable port
73 - if err != nil {
74 - t.Fatal(err)
75 - }
76 - defer c1.Close()
77 -
78 - c2, err := net.ListenPacket("udp4", "224.0.0.0:1024") // wildcard address with reusable port
79 - if err != nil {
80 - t.Fatal(err)
81 - }
82 - defer c2.Close()
83 -
84 - var ps [2]*ipv4.PacketConn
85 - ps[0] = ipv4.NewPacketConn(c1)
86 - ps[1] = ipv4.NewPacketConn(c2)
87 - var mift []*net.Interface
88 -
89 - ift, err := net.Interfaces()
90 - if err != nil {
91 - t.Fatal(err)
92 - }
93 - for i, ifi := range ift {
94 - if _, ok := nettest.IsMulticastCapable("ip4", &ifi); !ok {
95 - continue
96 - }
97 - for _, p := range ps {
98 - if err := p.JoinGroup(&ifi, gaddr); err != nil {
99 - t.Fatal(err)
100 - }
101 - }
102 - mift = append(mift, &ift[i])
103 - }
104 - for _, ifi := range mift {
105 - for _, p := range ps {
106 - if err := p.LeaveGroup(ifi, gaddr); err != nil {
107 - t.Fatal(err)
108 - }
109 - }
110 - }
111 - }
112 -}
113 -
114 -func TestUDPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) {
115 - switch runtime.GOOS {
116 - case "nacl", "plan9", "solaris", "windows":
117 - t.Skipf("not supported on %s", runtime.GOOS)
118 - }
119 - if testing.Short() {
120 - t.Skip("to avoid external network")
121 - }
122 -
123 - gaddr := net.IPAddr{IP: net.IPv4(224, 0, 0, 254)} // see RFC 4727
124 - type ml struct {
125 - c *ipv4.PacketConn
126 - ifi *net.Interface
127 - }
128 - var mlt []*ml
129 -
130 - ift, err := net.Interfaces()
131 - if err != nil {
132 - t.Fatal(err)
133 - }
134 - for i, ifi := range ift {
135 - ip, ok := nettest.IsMulticastCapable("ip4", &ifi)
136 - if !ok {
137 - continue
138 - }
139 - c, err := net.ListenPacket("udp4", ip.String()+":"+"1024") // unicast address with non-reusable port
140 - if err != nil {
141 - t.Fatal(err)
142 - }
143 - defer c.Close()
144 - p := ipv4.NewPacketConn(c)
145 - if err := p.JoinGroup(&ifi, &gaddr); err != nil {
146 - t.Fatal(err)
147 - }
148 - mlt = append(mlt, &ml{p, &ift[i]})
149 - }
150 - for _, m := range mlt {
151 - if err := m.c.LeaveGroup(m.ifi, &gaddr); err != nil {
152 - t.Fatal(err)
153 - }
154 - }
155 -}
156 -
157 -func TestIPSingleRawConnWithSingleGroupListener(t *testing.T) {
158 - switch runtime.GOOS {
159 - case "nacl", "plan9", "solaris", "windows":
160 - t.Skipf("not supported on %s", runtime.GOOS)
161 - }
162 - if testing.Short() {
163 - t.Skip("to avoid external network")
164 - }
165 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
166 - t.Skip(m)
167 - }
168 -
169 - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") // wildcard address
170 - if err != nil {
171 - t.Fatal(err)
172 - }
173 - defer c.Close()
174 -
175 - r, err := ipv4.NewRawConn(c)
176 - if err != nil {
177 - t.Fatal(err)
178 - }
179 - gaddr := net.IPAddr{IP: net.IPv4(224, 0, 0, 254)} // see RFC 4727
180 - var mift []*net.Interface
181 -
182 - ift, err := net.Interfaces()
183 - if err != nil {
184 - t.Fatal(err)
185 - }
186 - for i, ifi := range ift {
187 - if _, ok := nettest.IsMulticastCapable("ip4", &ifi); !ok {
188 - continue
189 - }
190 - if err := r.JoinGroup(&ifi, &gaddr); err != nil {
191 - t.Fatal(err)
192 - }
193 - mift = append(mift, &ift[i])
194 - }
195 - for _, ifi := range mift {
196 - if err := r.LeaveGroup(ifi, &gaddr); err != nil {
197 - t.Fatal(err)
198 - }
199 - }
200 -}
201 -
202 -func TestIPPerInterfaceSingleRawConnWithSingleGroupListener(t *testing.T) {
203 - switch runtime.GOOS {
204 - case "nacl", "plan9", "solaris", "windows":
205 - t.Skipf("not supported on %s", runtime.GOOS)
206 - }
207 - if testing.Short() {
208 - t.Skip("to avoid external network")
209 - }
210 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
211 - t.Skip(m)
212 - }
213 -
214 - gaddr := net.IPAddr{IP: net.IPv4(224, 0, 0, 254)} // see RFC 4727
215 - type ml struct {
216 - c *ipv4.RawConn
217 - ifi *net.Interface
218 - }
219 - var mlt []*ml
220 -
221 - ift, err := net.Interfaces()
222 - if err != nil {
223 - t.Fatal(err)
224 - }
225 - for i, ifi := range ift {
226 - ip, ok := nettest.IsMulticastCapable("ip4", &ifi)
227 - if !ok {
228 - continue
229 - }
230 - c, err := net.ListenPacket("ip4:253", ip.String()) // unicast address
231 - if err != nil {
232 - t.Fatal(err)
233 - }
234 - defer c.Close()
235 - r, err := ipv4.NewRawConn(c)
236 - if err != nil {
237 - t.Fatal(err)
238 - }
239 - if err := r.JoinGroup(&ifi, &gaddr); err != nil {
240 - t.Fatal(err)
241 - }
242 - mlt = append(mlt, &ml{r, &ift[i]})
243 - }
244 - for _, m := range mlt {
245 - if err := m.c.LeaveGroup(m.ifi, &gaddr); err != nil {
246 - t.Fatal(err)
247 - }
248 - }
249 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/multicastsockopt_test.go deleted
-195
@@ -1,195 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4_test
6 -
7 -import (
8 - "net"
9 - "runtime"
10 - "testing"
11 -
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv4"
13 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
14 -)
15 -
16 -var packetConnMulticastSocketOptionTests = []struct {
17 - net, proto, addr string
18 - grp, src net.Addr
19 -}{
20 - {"udp4", "", "224.0.0.0:0", &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}, nil}, // see RFC 4727
21 - {"ip4", ":icmp", "0.0.0.0", &net.IPAddr{IP: net.IPv4(224, 0, 0, 250)}, nil}, // see RFC 4727
22 -
23 - {"udp4", "", "232.0.0.0:0", &net.UDPAddr{IP: net.IPv4(232, 0, 1, 249)}, &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771
24 - {"ip4", ":icmp", "0.0.0.0", &net.IPAddr{IP: net.IPv4(232, 0, 1, 250)}, &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771
25 -}
26 -
27 -func TestPacketConnMulticastSocketOptions(t *testing.T) {
28 - switch runtime.GOOS {
29 - case "nacl", "plan9", "solaris":
30 - t.Skipf("not supported on %s", runtime.GOOS)
31 - }
32 - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback)
33 - if ifi == nil {
34 - t.Skipf("not available on %s", runtime.GOOS)
35 - }
36 -
37 - m, ok := nettest.SupportsRawIPSocket()
38 - for _, tt := range packetConnMulticastSocketOptionTests {
39 - if tt.net == "ip4" && !ok {
40 - t.Log(m)
41 - continue
42 - }
43 - c, err := net.ListenPacket(tt.net+tt.proto, tt.addr)
44 - if err != nil {
45 - t.Fatal(err)
46 - }
47 - defer c.Close()
48 - p := ipv4.NewPacketConn(c)
49 - defer p.Close()
50 -
51 - if tt.src == nil {
52 - testMulticastSocketOptions(t, p, ifi, tt.grp)
53 - } else {
54 - testSourceSpecificMulticastSocketOptions(t, p, ifi, tt.grp, tt.src)
55 - }
56 - }
57 -}
58 -
59 -var rawConnMulticastSocketOptionTests = []struct {
60 - grp, src net.Addr
61 -}{
62 - {&net.IPAddr{IP: net.IPv4(224, 0, 0, 250)}, nil}, // see RFC 4727
63 -
64 - {&net.IPAddr{IP: net.IPv4(232, 0, 1, 250)}, &net.IPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771
65 -}
66 -
67 -func TestRawConnMulticastSocketOptions(t *testing.T) {
68 - switch runtime.GOOS {
69 - case "nacl", "plan9", "solaris":
70 - t.Skipf("not supported on %s", runtime.GOOS)
71 - }
72 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
73 - t.Skip(m)
74 - }
75 - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback)
76 - if ifi == nil {
77 - t.Skipf("not available on %s", runtime.GOOS)
78 - }
79 -
80 - for _, tt := range rawConnMulticastSocketOptionTests {
81 - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0")
82 - if err != nil {
83 - t.Fatal(err)
84 - }
85 - defer c.Close()
86 - r, err := ipv4.NewRawConn(c)
87 - if err != nil {
88 - t.Fatal(err)
89 - }
90 - defer r.Close()
91 -
92 - if tt.src == nil {
93 - testMulticastSocketOptions(t, r, ifi, tt.grp)
94 - } else {
95 - testSourceSpecificMulticastSocketOptions(t, r, ifi, tt.grp, tt.src)
96 - }
97 - }
98 -}
99 -
100 -type testIPv4MulticastConn interface {
101 - MulticastTTL() (int, error)
102 - SetMulticastTTL(ttl int) error
103 - MulticastLoopback() (bool, error)
104 - SetMulticastLoopback(bool) error
105 - JoinGroup(*net.Interface, net.Addr) error
106 - LeaveGroup(*net.Interface, net.Addr) error
107 - JoinSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error
108 - LeaveSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error
109 - ExcludeSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error
110 - IncludeSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error
111 -}
112 -
113 -func testMulticastSocketOptions(t *testing.T, c testIPv4MulticastConn, ifi *net.Interface, grp net.Addr) {
114 - const ttl = 255
115 - if err := c.SetMulticastTTL(ttl); err != nil {
116 - t.Error(err)
117 - return
118 - }
119 - if v, err := c.MulticastTTL(); err != nil {
120 - t.Error(err)
121 - return
122 - } else if v != ttl {
123 - t.Errorf("got %v; want %v", v, ttl)
124 - return
125 - }
126 -
127 - for _, toggle := range []bool{true, false} {
128 - if err := c.SetMulticastLoopback(toggle); err != nil {
129 - t.Error(err)
130 - return
131 - }
132 - if v, err := c.MulticastLoopback(); err != nil {
133 - t.Error(err)
134 - return
135 - } else if v != toggle {
136 - t.Errorf("got %v; want %v", v, toggle)
137 - return
138 - }
139 - }
140 -
141 - if err := c.JoinGroup(ifi, grp); err != nil {
142 - t.Error(err)
143 - return
144 - }
145 - if err := c.LeaveGroup(ifi, grp); err != nil {
146 - t.Error(err)
147 - return
148 - }
149 -}
150 -
151 -func testSourceSpecificMulticastSocketOptions(t *testing.T, c testIPv4MulticastConn, ifi *net.Interface, grp, src net.Addr) {
152 - // MCAST_JOIN_GROUP -> MCAST_BLOCK_SOURCE -> MCAST_UNBLOCK_SOURCE -> MCAST_LEAVE_GROUP
153 - if err := c.JoinGroup(ifi, grp); err != nil {
154 - t.Error(err)
155 - return
156 - }
157 - if err := c.ExcludeSourceSpecificGroup(ifi, grp, src); err != nil {
158 - switch runtime.GOOS {
159 - case "freebsd", "linux":
160 - default: // platforms that don't support IGMPv2/3 fail here
161 - t.Logf("not supported on %s", runtime.GOOS)
162 - return
163 - }
164 - t.Error(err)
165 - return
166 - }
167 - if err := c.IncludeSourceSpecificGroup(ifi, grp, src); err != nil {
168 - t.Error(err)
169 - return
170 - }
171 - if err := c.LeaveGroup(ifi, grp); err != nil {
172 - t.Error(err)
173 - return
174 - }
175 -
176 - // MCAST_JOIN_SOURCE_GROUP -> MCAST_LEAVE_SOURCE_GROUP
177 - if err := c.JoinSourceSpecificGroup(ifi, grp, src); err != nil {
178 - t.Error(err)
179 - return
180 - }
181 - if err := c.LeaveSourceSpecificGroup(ifi, grp, src); err != nil {
182 - t.Error(err)
183 - return
184 - }
185 -
186 - // MCAST_JOIN_SOURCE_GROUP -> MCAST_LEAVE_GROUP
187 - if err := c.JoinSourceSpecificGroup(ifi, grp, src); err != nil {
188 - t.Error(err)
189 - return
190 - }
191 - if err := c.LeaveGroup(ifi, grp); err != nil {
192 - t.Error(err)
193 - return
194 - }
195 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/packet.go deleted
-97
@@ -1,97 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "net"
9 - "syscall"
10 -)
11 -
12 -// A packetHandler represents the IPv4 datagram handler.
13 -type packetHandler struct {
14 - c *net.IPConn
15 - rawOpt
16 -}
17 -
18 -func (c *packetHandler) ok() bool { return c != nil && c.c != nil }
19 -
20 -// ReadFrom reads an IPv4 datagram from the endpoint c, copying the
21 -// datagram into b. It returns the received datagram as the IPv4
22 -// header h, the payload p and the control message cm.
23 -func (c *packetHandler) ReadFrom(b []byte) (h *Header, p []byte, cm *ControlMessage, err error) {
24 - if !c.ok() {
25 - return nil, nil, nil, syscall.EINVAL
26 - }
27 - oob := newControlMessage(&c.rawOpt)
28 - n, oobn, _, src, err := c.c.ReadMsgIP(b, oob)
29 - if err != nil {
30 - return nil, nil, nil, err
31 - }
32 - var hs []byte
33 - if hs, p, err = slicePacket(b[:n]); err != nil {
34 - return nil, nil, nil, err
35 - }
36 - if h, err = ParseHeader(hs); err != nil {
37 - return nil, nil, nil, err
38 - }
39 - if cm, err = parseControlMessage(oob[:oobn]); err != nil {
40 - return nil, nil, nil, err
41 - }
42 - if src != nil && cm != nil {
43 - cm.Src = src.IP
44 - }
45 - return
46 -}
47 -
48 -func slicePacket(b []byte) (h, p []byte, err error) {
49 - if len(b) < HeaderLen {
50 - return nil, nil, errHeaderTooShort
51 - }
52 - hdrlen := int(b[0]&0x0f) << 2
53 - return b[:hdrlen], b[hdrlen:], nil
54 -}
55 -
56 -// WriteTo writes an IPv4 datagram through the endpoint c, copying the
57 -// datagram from the IPv4 header h and the payload p. The control
58 -// message cm allows the datagram path and the outgoing interface to be
59 -// specified. Currently only Darwin and Linux support this. The cm
60 -// may be nil if control of the outgoing datagram is not required.
61 -//
62 -// The IPv4 header h must contain appropriate fields that include:
63 -//
64 -// Version = ipv4.Version
65 -// Len = <must be specified>
66 -// TOS = <must be specified>
67 -// TotalLen = <must be specified>
68 -// ID = platform sets an appropriate value if ID is zero
69 -// FragOff = <must be specified>
70 -// TTL = <must be specified>
71 -// Protocol = <must be specified>
72 -// Checksum = platform sets an appropriate value if Checksum is zero
73 -// Src = platform sets an appropriate value if Src is nil
74 -// Dst = <must be specified>
75 -// Options = optional
76 -func (c *packetHandler) WriteTo(h *Header, p []byte, cm *ControlMessage) error {
77 - if !c.ok() {
78 - return syscall.EINVAL
79 - }
80 - oob := marshalControlMessage(cm)
81 - wh, err := h.Marshal()
82 - if err != nil {
83 - return err
84 - }
85 - dst := &net.IPAddr{}
86 - if cm != nil {
87 - if ip := cm.Dst.To4(); ip != nil {
88 - dst.IP = ip
89 - }
90 - }
91 - if dst.IP == nil {
92 - dst.IP = h.Dst
93 - }
94 - wh = append(wh, p...)
95 - _, _, err = c.c.WriteMsgIP(wh, oob, dst)
96 - return err
97 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/payload.go deleted
-15
@@ -1,15 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import "net"
8 -
9 -// A payloadHandler represents the IPv4 datagram payload handler.
10 -type payloadHandler struct {
11 - net.PacketConn
12 - rawOpt
13 -}
14 -
15 -func (c *payloadHandler) ok() bool { return c != nil && c.PacketConn != nil }
Godeps/_workspace/src/golang.org/x/net/ipv4/payload_cmsg.go deleted
-81
@@ -1,81 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build !plan9,!solaris,!windows
6 -
7 -package ipv4
8 -
9 -import (
10 - "net"
11 - "syscall"
12 -)
13 -
14 -// ReadFrom reads a payload of the received IPv4 datagram, from the
15 -// endpoint c, copying the payload into b. It returns the number of
16 -// bytes copied into b, the control message cm and the source address
17 -// src of the received datagram.
18 -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) {
19 - if !c.ok() {
20 - return 0, nil, nil, syscall.EINVAL
21 - }
22 - oob := newControlMessage(&c.rawOpt)
23 - var oobn int
24 - switch c := c.PacketConn.(type) {
25 - case *net.UDPConn:
26 - if n, oobn, _, src, err = c.ReadMsgUDP(b, oob); err != nil {
27 - return 0, nil, nil, err
28 - }
29 - case *net.IPConn:
30 - if sockOpts[ssoStripHeader].name > 0 {
31 - if n, oobn, _, src, err = c.ReadMsgIP(b, oob); err != nil {
32 - return 0, nil, nil, err
33 - }
34 - } else {
35 - nb := make([]byte, maxHeaderLen+len(b))
36 - if n, oobn, _, src, err = c.ReadMsgIP(nb, oob); err != nil {
37 - return 0, nil, nil, err
38 - }
39 - hdrlen := int(nb[0]&0x0f) << 2
40 - copy(b, nb[hdrlen:])
41 - n -= hdrlen
42 - }
43 - default:
44 - return 0, nil, nil, errInvalidConnType
45 - }
46 - if cm, err = parseControlMessage(oob[:oobn]); err != nil {
47 - return 0, nil, nil, err
48 - }
49 - if cm != nil {
50 - cm.Src = netAddrToIP4(src)
51 - }
52 - return
53 -}
54 -
55 -// WriteTo writes a payload of the IPv4 datagram, to the destination
56 -// address dst through the endpoint c, copying the payload from b. It
57 -// returns the number of bytes written. The control message cm allows
58 -// the datagram path and the outgoing interface to be specified.
59 -// Currently only Darwin and Linux support this. The cm may be nil if
60 -// control of the outgoing datagram is not required.
61 -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) {
62 - if !c.ok() {
63 - return 0, syscall.EINVAL
64 - }
65 - oob := marshalControlMessage(cm)
66 - if dst == nil {
67 - return 0, errMissingAddress
68 - }
69 - switch c := c.PacketConn.(type) {
70 - case *net.UDPConn:
71 - n, _, err = c.WriteMsgUDP(b, oob, dst.(*net.UDPAddr))
72 - case *net.IPConn:
73 - n, _, err = c.WriteMsgIP(b, oob, dst.(*net.IPAddr))
74 - default:
75 - return 0, errInvalidConnType
76 - }
77 - if err != nil {
78 - return 0, err
79 - }
80 - return
81 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/payload_nocmsg.go deleted
-42
@@ -1,42 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build plan9 solaris windows
6 -
7 -package ipv4
8 -
9 -import (
10 - "net"
11 - "syscall"
12 -)
13 -
14 -// ReadFrom reads a payload of the received IPv4 datagram, from the
15 -// endpoint c, copying the payload into b. It returns the number of
16 -// bytes copied into b, the control message cm and the source address
17 -// src of the received datagram.
18 -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) {
19 - if !c.ok() {
20 - return 0, nil, nil, syscall.EINVAL
21 - }
22 - if n, src, err = c.PacketConn.ReadFrom(b); err != nil {
23 - return 0, nil, nil, err
24 - }
25 - return
26 -}
27 -
28 -// WriteTo writes a payload of the IPv4 datagram, to the destination
29 -// address dst through the endpoint c, copying the payload from b. It
30 -// returns the number of bytes written. The control message cm allows
31 -// the datagram path and the outgoing interface to be specified.
32 -// Currently only Darwin and Linux support this. The cm may be nil if
33 -// control of the outgoing datagram is not required.
34 -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) {
35 - if !c.ok() {
36 - return 0, syscall.EINVAL
37 - }
38 - if dst == nil {
39 - return 0, errMissingAddress
40 - }
41 - return c.PacketConn.WriteTo(b, dst)
42 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/readwrite_test.go deleted
-170
@@ -1,170 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4_test
6 -
7 -import (
8 - "bytes"
9 - "net"
10 - "runtime"
11 - "sync"
12 - "testing"
13 -
14 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv4"
15 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
16 -)
17 -
18 -func benchmarkUDPListener() (net.PacketConn, net.Addr, error) {
19 - c, err := net.ListenPacket("udp4", "127.0.0.1:0")
20 - if err != nil {
21 - return nil, nil, err
22 - }
23 - dst, err := net.ResolveUDPAddr("udp4", c.LocalAddr().String())
24 - if err != nil {
25 - c.Close()
26 - return nil, nil, err
27 - }
28 - return c, dst, nil
29 -}
30 -
31 -func BenchmarkReadWriteNetUDP(b *testing.B) {
32 - c, dst, err := benchmarkUDPListener()
33 - if err != nil {
34 - b.Fatal(err)
35 - }
36 - defer c.Close()
37 -
38 - wb, rb := []byte("HELLO-R-U-THERE"), make([]byte, 128)
39 - b.ResetTimer()
40 - for i := 0; i < b.N; i++ {
41 - benchmarkReadWriteNetUDP(b, c, wb, rb, dst)
42 - }
43 -}
44 -
45 -func benchmarkReadWriteNetUDP(b *testing.B, c net.PacketConn, wb, rb []byte, dst net.Addr) {
46 - if _, err := c.WriteTo(wb, dst); err != nil {
47 - b.Fatal(err)
48 - }
49 - if _, _, err := c.ReadFrom(rb); err != nil {
50 - b.Fatal(err)
51 - }
52 -}
53 -
54 -func BenchmarkReadWriteIPv4UDP(b *testing.B) {
55 - c, dst, err := benchmarkUDPListener()
56 - if err != nil {
57 - b.Fatal(err)
58 - }
59 - defer c.Close()
60 -
61 - p := ipv4.NewPacketConn(c)
62 - defer p.Close()
63 - cf := ipv4.FlagTTL | ipv4.FlagInterface
64 - if err := p.SetControlMessage(cf, true); err != nil {
65 - b.Fatal(err)
66 - }
67 - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback)
68 -
69 - wb, rb := []byte("HELLO-R-U-THERE"), make([]byte, 128)
70 - b.ResetTimer()
71 - for i := 0; i < b.N; i++ {
72 - benchmarkReadWriteIPv4UDP(b, p, wb, rb, dst, ifi)
73 - }
74 -}
75 -
76 -func benchmarkReadWriteIPv4UDP(b *testing.B, p *ipv4.PacketConn, wb, rb []byte, dst net.Addr, ifi *net.Interface) {
77 - cm := ipv4.ControlMessage{TTL: 1}
78 - if ifi != nil {
79 - cm.IfIndex = ifi.Index
80 - }
81 - if n, err := p.WriteTo(wb, &cm, dst); err != nil {
82 - b.Fatal(err)
83 - } else if n != len(wb) {
84 - b.Fatalf("got %v; want %v", n, len(wb))
85 - }
86 - if _, _, _, err := p.ReadFrom(rb); err != nil {
87 - b.Fatal(err)
88 - }
89 -}
90 -
91 -func TestPacketConnConcurrentReadWriteUnicastUDP(t *testing.T) {
92 - switch runtime.GOOS {
93 - case "nacl", "plan9", "solaris", "windows":
94 - t.Skipf("not supported on %s", runtime.GOOS)
95 - }
96 -
97 - c, err := net.ListenPacket("udp4", "127.0.0.1:0")
98 - if err != nil {
99 - t.Fatal(err)
100 - }
101 - defer c.Close()
102 - p := ipv4.NewPacketConn(c)
103 - defer p.Close()
104 -
105 - dst, err := net.ResolveUDPAddr("udp4", c.LocalAddr().String())
106 - if err != nil {
107 - t.Fatal(err)
108 - }
109 -
110 - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback)
111 - cf := ipv4.FlagTTL | ipv4.FlagSrc | ipv4.FlagDst | ipv4.FlagInterface
112 - wb := []byte("HELLO-R-U-THERE")
113 -
114 - if err := p.SetControlMessage(cf, true); err != nil { // probe before test
115 - if nettest.ProtocolNotSupported(err) {
116 - t.Skipf("not supported on %s", runtime.GOOS)
117 - }
118 - t.Fatal(err)
119 - }
120 -
121 - var wg sync.WaitGroup
122 - reader := func() {
123 - defer wg.Done()
124 - rb := make([]byte, 128)
125 - if n, cm, _, err := p.ReadFrom(rb); err != nil {
126 - t.Error(err)
127 - return
128 - } else if !bytes.Equal(rb[:n], wb) {
129 - t.Errorf("got %v; want %v", rb[:n], wb)
130 - return
131 - } else {
132 - t.Logf("rcvd cmsg: %v", cm)
133 - }
134 - }
135 - writer := func(toggle bool) {
136 - defer wg.Done()
137 - cm := ipv4.ControlMessage{
138 - Src: net.IPv4(127, 0, 0, 1),
139 - }
140 - if ifi != nil {
141 - cm.IfIndex = ifi.Index
142 - }
143 - if err := p.SetControlMessage(cf, toggle); err != nil {
144 - t.Error(err)
145 - return
146 - }
147 - if n, err := p.WriteTo(wb, &cm, dst); err != nil {
148 - t.Error(err)
149 - return
150 - } else if n != len(wb) {
151 - t.Errorf("short write: %v", n)
152 - return
153 - }
154 - }
155 -
156 - const N = 10
157 - wg.Add(N)
158 - for i := 0; i < N; i++ {
159 - go reader()
160 - }
161 - wg.Add(2 * N)
162 - for i := 0; i < 2*N; i++ {
163 - go writer(i%2 != 0)
164 - }
165 - wg.Add(N)
166 - for i := 0; i < N; i++ {
167 - go reader()
168 - }
169 - wg.Wait()
170 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sockopt.go deleted
-46
@@ -1,46 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -// Sticky socket options
8 -const (
9 - ssoTOS = iota // header field for unicast packet
10 - ssoTTL // header field for unicast packet
11 - ssoMulticastTTL // header field for multicast packet
12 - ssoMulticastInterface // outbound interface for multicast packet
13 - ssoMulticastLoopback // loopback for multicast packet
14 - ssoReceiveTTL // header field on received packet
15 - ssoReceiveDst // header field on received packet
16 - ssoReceiveInterface // inbound interface on received packet
17 - ssoPacketInfo // incbound or outbound packet path
18 - ssoHeaderPrepend // ipv4 header prepend
19 - ssoStripHeader // strip ipv4 header
20 - ssoICMPFilter // icmp filter
21 - ssoJoinGroup // any-source multicast
22 - ssoLeaveGroup // any-source multicast
23 - ssoJoinSourceGroup // source-specific multicast
24 - ssoLeaveSourceGroup // source-specific multicast
25 - ssoBlockSourceGroup // any-source or source-specific multicast
26 - ssoUnblockSourceGroup // any-source or source-specific multicast
27 - ssoMax
28 -)
29 -
30 -// Sticky socket option value types
31 -const (
32 - ssoTypeByte = iota + 1
33 - ssoTypeInt
34 - ssoTypeInterface
35 - ssoTypeICMPFilter
36 - ssoTypeIPMreq
37 - ssoTypeIPMreqn
38 - ssoTypeGroupReq
39 - ssoTypeGroupSourceReq
40 -)
41 -
42 -// A sockOpt represents a binding for sticky socket option.
43 -type sockOpt struct {
44 - name int // option name, must be equal or greater than 1
45 - typ int // option value type, must be equal or greater than 1
46 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sockopt_asmreq.go deleted
-83
@@ -1,83 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd netbsd openbsd windows
6 -
7 -package ipv4
8 -
9 -import "net"
10 -
11 -func setIPMreqInterface(mreq *sysIPMreq, ifi *net.Interface) error {
12 - if ifi == nil {
13 - return nil
14 - }
15 - ifat, err := ifi.Addrs()
16 - if err != nil {
17 - return err
18 - }
19 - for _, ifa := range ifat {
20 - switch ifa := ifa.(type) {
21 - case *net.IPAddr:
22 - if ip := ifa.IP.To4(); ip != nil {
23 - copy(mreq.Interface[:], ip)
24 - return nil
25 - }
26 - case *net.IPNet:
27 - if ip := ifa.IP.To4(); ip != nil {
28 - copy(mreq.Interface[:], ip)
29 - return nil
30 - }
31 - }
32 - }
33 - return errNoSuchInterface
34 -}
35 -
36 -func netIP4ToInterface(ip net.IP) (*net.Interface, error) {
37 - ift, err := net.Interfaces()
38 - if err != nil {
39 - return nil, err
40 - }
41 - for _, ifi := range ift {
42 - ifat, err := ifi.Addrs()
43 - if err != nil {
44 - return nil, err
45 - }
46 - for _, ifa := range ifat {
47 - switch ifa := ifa.(type) {
48 - case *net.IPAddr:
49 - if ip.Equal(ifa.IP) {
50 - return &ifi, nil
51 - }
52 - case *net.IPNet:
53 - if ip.Equal(ifa.IP) {
54 - return &ifi, nil
55 - }
56 - }
57 - }
58 - }
59 - return nil, errNoSuchInterface
60 -}
61 -
62 -func netInterfaceToIP4(ifi *net.Interface) (net.IP, error) {
63 - if ifi == nil {
64 - return net.IPv4zero.To4(), nil
65 - }
66 - ifat, err := ifi.Addrs()
67 - if err != nil {
68 - return nil, err
69 - }
70 - for _, ifa := range ifat {
71 - switch ifa := ifa.(type) {
72 - case *net.IPAddr:
73 - if ip := ifa.IP.To4(); ip != nil {
74 - return ip, nil
75 - }
76 - case *net.IPNet:
77 - if ip := ifa.IP.To4(); ip != nil {
78 - return ip, nil
79 - }
80 - }
81 - }
82 - return nil, errNoSuchInterface
83 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sockopt_asmreq_stub.go deleted
-21
@@ -1,21 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build !darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!windows
6 -
7 -package ipv4
8 -
9 -import "net"
10 -
11 -func setsockoptIPMreq(fd, name int, ifi *net.Interface, grp net.IP) error {
12 - return errOpNoSupport
13 -}
14 -
15 -func getsockoptInterface(fd, name int) (*net.Interface, error) {
16 - return nil, errOpNoSupport
17 -}
18 -
19 -func setsockoptInterface(fd, name int, ifi *net.Interface) error {
20 - return errOpNoSupport
21 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sockopt_asmreq_unix.go deleted
-46
@@ -1,46 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd netbsd openbsd
6 -
7 -package ipv4
8 -
9 -import (
10 - "net"
11 - "os"
12 - "unsafe"
13 -
14 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
15 -)
16 -
17 -func setsockoptIPMreq(fd, name int, ifi *net.Interface, grp net.IP) error {
18 - mreq := sysIPMreq{Multiaddr: [4]byte{grp[0], grp[1], grp[2], grp[3]}}
19 - if err := setIPMreqInterface(&mreq, ifi); err != nil {
20 - return err
21 - }
22 - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&mreq), sysSizeofIPMreq))
23 -}
24 -
25 -func getsockoptInterface(fd, name int) (*net.Interface, error) {
26 - var b [4]byte
27 - l := sysSockoptLen(4)
28 - if err := getsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&b[0]), &l); err != nil {
29 - return nil, os.NewSyscallError("getsockopt", err)
30 - }
31 - ifi, err := netIP4ToInterface(net.IPv4(b[0], b[1], b[2], b[3]))
32 - if err != nil {
33 - return nil, err
34 - }
35 - return ifi, nil
36 -}
37 -
38 -func setsockoptInterface(fd, name int, ifi *net.Interface) error {
39 - ip, err := netInterfaceToIP4(ifi)
40 - if err != nil {
41 - return err
42 - }
43 - var b [4]byte
44 - copy(b[:], ip)
45 - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&b[0]), sysSockoptLen(4)))
46 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sockopt_asmreq_windows.go deleted
-45
@@ -1,45 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "net"
9 - "os"
10 - "syscall"
11 - "unsafe"
12 -
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
14 -)
15 -
16 -func setsockoptIPMreq(fd syscall.Handle, name int, ifi *net.Interface, grp net.IP) error {
17 - mreq := sysIPMreq{Multiaddr: [4]byte{grp[0], grp[1], grp[2], grp[3]}}
18 - if err := setIPMreqInterface(&mreq, ifi); err != nil {
19 - return err
20 - }
21 - return os.NewSyscallError("setsockopt", syscall.Setsockopt(fd, iana.ProtocolIP, int32(name), (*byte)(unsafe.Pointer(&mreq)), int32(sysSizeofIPMreq)))
22 -}
23 -
24 -func getsockoptInterface(fd syscall.Handle, name int) (*net.Interface, error) {
25 - var b [4]byte
26 - l := int32(4)
27 - if err := syscall.Getsockopt(fd, iana.ProtocolIP, int32(name), (*byte)(unsafe.Pointer(&b[0])), &l); err != nil {
28 - return nil, os.NewSyscallError("getsockopt", err)
29 - }
30 - ifi, err := netIP4ToInterface(net.IPv4(b[0], b[1], b[2], b[3]))
31 - if err != nil {
32 - return nil, err
33 - }
34 - return ifi, nil
35 -}
36 -
37 -func setsockoptInterface(fd syscall.Handle, name int, ifi *net.Interface) error {
38 - ip, err := netInterfaceToIP4(ifi)
39 - if err != nil {
40 - return err
41 - }
42 - var b [4]byte
43 - copy(b[:], ip)
44 - return os.NewSyscallError("setsockopt", syscall.Setsockopt(fd, iana.ProtocolIP, int32(name), (*byte)(unsafe.Pointer(&b[0])), 4))
45 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sockopt_asmreqn_stub.go deleted
-17
@@ -1,17 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build !darwin,!freebsd,!linux,!windows
6 -
7 -package ipv4
8 -
9 -import "net"
10 -
11 -func getsockoptIPMreqn(fd, name int) (*net.Interface, error) {
12 - return nil, errOpNoSupport
13 -}
14 -
15 -func setsockoptIPMreqn(fd, name int, ifi *net.Interface, grp net.IP) error {
16 - return errOpNoSupport
17 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sockopt_asmreqn_unix.go deleted
-42
@@ -1,42 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin freebsd linux
6 -
7 -package ipv4
8 -
9 -import (
10 - "net"
11 - "os"
12 - "unsafe"
13 -
14 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
15 -)
16 -
17 -func getsockoptIPMreqn(fd, name int) (*net.Interface, error) {
18 - var mreqn sysIPMreqn
19 - l := sysSockoptLen(sysSizeofIPMreqn)
20 - if err := getsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&mreqn), &l); err != nil {
21 - return nil, os.NewSyscallError("getsockopt", err)
22 - }
23 - if mreqn.Ifindex == 0 {
24 - return nil, nil
25 - }
26 - ifi, err := net.InterfaceByIndex(int(mreqn.Ifindex))
27 - if err != nil {
28 - return nil, err
29 - }
30 - return ifi, nil
31 -}
32 -
33 -func setsockoptIPMreqn(fd, name int, ifi *net.Interface, grp net.IP) error {
34 - var mreqn sysIPMreqn
35 - if ifi != nil {
36 - mreqn.Ifindex = int32(ifi.Index)
37 - }
38 - if grp != nil {
39 - mreqn.Multiaddr = [4]byte{grp[0], grp[1], grp[2], grp[3]}
40 - }
41 - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&mreqn), sysSizeofIPMreqn))
42 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sockopt_ssmreq_stub.go deleted
-17
@@ -1,17 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build !darwin,!freebsd,!linux
6 -
7 -package ipv4
8 -
9 -import "net"
10 -
11 -func setsockoptGroupReq(fd, name int, ifi *net.Interface, grp net.IP) error {
12 - return errOpNoSupport
13 -}
14 -
15 -func setsockoptGroupSourceReq(fd, name int, ifi *net.Interface, grp, src net.IP) error {
16 - return errOpNoSupport
17 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sockopt_ssmreq_unix.go deleted
-33
@@ -1,33 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin freebsd linux
6 -
7 -package ipv4
8 -
9 -import (
10 - "net"
11 - "os"
12 - "unsafe"
13 -
14 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
15 -)
16 -
17 -func setsockoptGroupReq(fd, name int, ifi *net.Interface, grp net.IP) error {
18 - var gr sysGroupReq
19 - if ifi != nil {
20 - gr.Interface = uint32(ifi.Index)
21 - }
22 - gr.setGroup(grp)
23 - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&gr), sysSizeofGroupReq))
24 -}
25 -
26 -func setsockoptGroupSourceReq(fd, name int, ifi *net.Interface, grp, src net.IP) error {
27 - var gsr sysGroupSourceReq
28 - if ifi != nil {
29 - gsr.Interface = uint32(ifi.Index)
30 - }
31 - gsr.setSourceGroup(grp, src)
32 - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&gsr), sysSizeofGroupSourceReq))
33 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sockopt_stub.go deleted
-11
@@ -1,11 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9 solaris
6 -
7 -package ipv4
8 -
9 -func setInt(fd int, opt *sockOpt, v int) error {
10 - return errOpNoSupport
11 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sockopt_unix.go deleted
-122
@@ -1,122 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux netbsd openbsd
6 -
7 -package ipv4
8 -
9 -import (
10 - "net"
11 - "os"
12 - "unsafe"
13 -
14 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
15 -)
16 -
17 -func getInt(fd int, opt *sockOpt) (int, error) {
18 - if opt.name < 1 || (opt.typ != ssoTypeByte && opt.typ != ssoTypeInt) {
19 - return 0, errOpNoSupport
20 - }
21 - var i int32
22 - var b byte
23 - p := unsafe.Pointer(&i)
24 - l := sysSockoptLen(4)
25 - if opt.typ == ssoTypeByte {
26 - p = unsafe.Pointer(&b)
27 - l = sysSockoptLen(1)
28 - }
29 - if err := getsockopt(fd, iana.ProtocolIP, opt.name, p, &l); err != nil {
30 - return 0, os.NewSyscallError("getsockopt", err)
31 - }
32 - if opt.typ == ssoTypeByte {
33 - return int(b), nil
34 - }
35 - return int(i), nil
36 -}
37 -
38 -func setInt(fd int, opt *sockOpt, v int) error {
39 - if opt.name < 1 || (opt.typ != ssoTypeByte && opt.typ != ssoTypeInt) {
40 - return errOpNoSupport
41 - }
42 - i := int32(v)
43 - var b byte
44 - p := unsafe.Pointer(&i)
45 - l := sysSockoptLen(4)
46 - if opt.typ == ssoTypeByte {
47 - b = byte(v)
48 - p = unsafe.Pointer(&b)
49 - l = sysSockoptLen(1)
50 - }
51 - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, opt.name, p, l))
52 -}
53 -
54 -func getInterface(fd int, opt *sockOpt) (*net.Interface, error) {
55 - if opt.name < 1 {
56 - return nil, errOpNoSupport
57 - }
58 - switch opt.typ {
59 - case ssoTypeInterface:
60 - return getsockoptInterface(fd, opt.name)
61 - case ssoTypeIPMreqn:
62 - return getsockoptIPMreqn(fd, opt.name)
63 - default:
64 - return nil, errOpNoSupport
65 - }
66 -}
67 -
68 -func setInterface(fd int, opt *sockOpt, ifi *net.Interface) error {
69 - if opt.name < 1 {
70 - return errOpNoSupport
71 - }
72 - switch opt.typ {
73 - case ssoTypeInterface:
74 - return setsockoptInterface(fd, opt.name, ifi)
75 - case ssoTypeIPMreqn:
76 - return setsockoptIPMreqn(fd, opt.name, ifi, nil)
77 - default:
78 - return errOpNoSupport
79 - }
80 -}
81 -
82 -func getICMPFilter(fd int, opt *sockOpt) (*ICMPFilter, error) {
83 - if opt.name < 1 || opt.typ != ssoTypeICMPFilter {
84 - return nil, errOpNoSupport
85 - }
86 - var f ICMPFilter
87 - l := sysSockoptLen(sysSizeofICMPFilter)
88 - if err := getsockopt(fd, iana.ProtocolReserved, opt.name, unsafe.Pointer(&f.sysICMPFilter), &l); err != nil {
89 - return nil, os.NewSyscallError("getsockopt", err)
90 - }
91 - return &f, nil
92 -}
93 -
94 -func setICMPFilter(fd int, opt *sockOpt, f *ICMPFilter) error {
95 - if opt.name < 1 || opt.typ != ssoTypeICMPFilter {
96 - return errOpNoSupport
97 - }
98 - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolReserved, opt.name, unsafe.Pointer(&f.sysICMPFilter), sysSizeofICMPFilter))
99 -}
100 -
101 -func setGroup(fd int, opt *sockOpt, ifi *net.Interface, grp net.IP) error {
102 - if opt.name < 1 {
103 - return errOpNoSupport
104 - }
105 - switch opt.typ {
106 - case ssoTypeIPMreq:
107 - return setsockoptIPMreq(fd, opt.name, ifi, grp)
108 - case ssoTypeIPMreqn:
109 - return setsockoptIPMreqn(fd, opt.name, ifi, grp)
110 - case ssoTypeGroupReq:
111 - return setsockoptGroupReq(fd, opt.name, ifi, grp)
112 - default:
113 - return errOpNoSupport
114 - }
115 -}
116 -
117 -func setSourceGroup(fd int, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error {
118 - if opt.name < 1 || opt.typ != ssoTypeGroupSourceReq {
119 - return errOpNoSupport
120 - }
121 - return setsockoptGroupSourceReq(fd, opt.name, ifi, grp, src)
122 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sockopt_windows.go deleted
-68
@@ -1,68 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "net"
9 - "os"
10 - "syscall"
11 - "unsafe"
12 -
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
14 -)
15 -
16 -func getInt(fd syscall.Handle, opt *sockOpt) (int, error) {
17 - if opt.name < 1 || opt.typ != ssoTypeInt {
18 - return 0, errOpNoSupport
19 - }
20 - var i int32
21 - l := int32(4)
22 - if err := syscall.Getsockopt(fd, iana.ProtocolIP, int32(opt.name), (*byte)(unsafe.Pointer(&i)), &l); err != nil {
23 - return 0, os.NewSyscallError("getsockopt", err)
24 - }
25 - return int(i), nil
26 -}
27 -
28 -func setInt(fd syscall.Handle, opt *sockOpt, v int) error {
29 - if opt.name < 1 || opt.typ != ssoTypeInt {
30 - return errOpNoSupport
31 - }
32 - i := int32(v)
33 - return os.NewSyscallError("setsockopt", syscall.Setsockopt(fd, iana.ProtocolIP, int32(opt.name), (*byte)(unsafe.Pointer(&i)), 4))
34 -}
35 -
36 -func getInterface(fd syscall.Handle, opt *sockOpt) (*net.Interface, error) {
37 - if opt.name < 1 || opt.typ != ssoTypeInterface {
38 - return nil, errOpNoSupport
39 - }
40 - return getsockoptInterface(fd, opt.name)
41 -}
42 -
43 -func setInterface(fd syscall.Handle, opt *sockOpt, ifi *net.Interface) error {
44 - if opt.name < 1 || opt.typ != ssoTypeInterface {
45 - return errOpNoSupport
46 - }
47 - return setsockoptInterface(fd, opt.name, ifi)
48 -}
49 -
50 -func getICMPFilter(fd syscall.Handle, opt *sockOpt) (*ICMPFilter, error) {
51 - return nil, errOpNoSupport
52 -}
53 -
54 -func setICMPFilter(fd syscall.Handle, opt *sockOpt, f *ICMPFilter) error {
55 - return errOpNoSupport
56 -}
57 -
58 -func setGroup(fd syscall.Handle, opt *sockOpt, ifi *net.Interface, grp net.IP) error {
59 - if opt.name < 1 || opt.typ != ssoTypeIPMreq {
60 - return errOpNoSupport
61 - }
62 - return setsockoptIPMreq(fd, opt.name, ifi, grp)
63 -}
64 -
65 -func setSourceGroup(fd syscall.Handle, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error {
66 - // TODO(mikio): implement this
67 - return errOpNoSupport
68 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sys_bsd.go deleted
-36
@@ -1,36 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build dragonfly netbsd
6 -
7 -package ipv4
8 -
9 -import (
10 - "net"
11 - "syscall"
12 -)
13 -
14 -type sysSockoptLen int32
15 -
16 -var (
17 - ctlOpts = [ctlMax]ctlOpt{
18 - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL},
19 - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst},
20 - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface},
21 - }
22 -
23 - sockOpts = [ssoMax]sockOpt{
24 - ssoTOS: {sysIP_TOS, ssoTypeInt},
25 - ssoTTL: {sysIP_TTL, ssoTypeInt},
26 - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte},
27 - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface},
28 - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt},
29 - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt},
30 - ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt},
31 - ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt},
32 - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt},
33 - ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq},
34 - ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq},
35 - }
36 -)
Godeps/_workspace/src/golang.org/x/net/ipv4/sys_darwin.go deleted
-98
@@ -1,98 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "net"
9 - "syscall"
10 - "unsafe"
11 -)
12 -
13 -type sysSockoptLen int32
14 -
15 -var (
16 - ctlOpts = [ctlMax]ctlOpt{
17 - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL},
18 - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst},
19 - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface},
20 - }
21 -
22 - sockOpts = [ssoMax]sockOpt{
23 - ssoTOS: {sysIP_TOS, ssoTypeInt},
24 - ssoTTL: {sysIP_TTL, ssoTypeInt},
25 - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte},
26 - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface},
27 - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt},
28 - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt},
29 - ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt},
30 - ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt},
31 - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt},
32 - ssoStripHeader: {sysIP_STRIPHDR, ssoTypeInt},
33 - ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq},
34 - ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq},
35 - }
36 -)
37 -
38 -func init() {
39 - // Seems like kern.osreldate is veiled on latest OS X. We use
40 - // kern.osrelease instead.
41 - osver, err := syscall.Sysctl("kern.osrelease")
42 - if err != nil {
43 - return
44 - }
45 - var i int
46 - for i = range osver {
47 - if osver[i] == '.' {
48 - break
49 - }
50 - }
51 - // The IP_PKTINFO and protocol-independent multicast API were
52 - // introduced in OS X 10.7 (Darwin 11.0.0). But it looks like
53 - // those features require OS X 10.8 (Darwin 12.0.0) and above.
54 - // See http://support.apple.com/kb/HT1633.
55 - if i > 2 || i == 2 && osver[0] >= '1' && osver[1] >= '2' {
56 - ctlOpts[ctlPacketInfo].name = sysIP_PKTINFO
57 - ctlOpts[ctlPacketInfo].length = sysSizeofInetPktinfo
58 - ctlOpts[ctlPacketInfo].marshal = marshalPacketInfo
59 - ctlOpts[ctlPacketInfo].parse = parsePacketInfo
60 - sockOpts[ssoPacketInfo].name = sysIP_RECVPKTINFO
61 - sockOpts[ssoPacketInfo].typ = ssoTypeInt
62 - sockOpts[ssoMulticastInterface].typ = ssoTypeIPMreqn
63 - sockOpts[ssoJoinGroup].name = sysMCAST_JOIN_GROUP
64 - sockOpts[ssoJoinGroup].typ = ssoTypeGroupReq
65 - sockOpts[ssoLeaveGroup].name = sysMCAST_LEAVE_GROUP
66 - sockOpts[ssoLeaveGroup].typ = ssoTypeGroupReq
67 - sockOpts[ssoJoinSourceGroup].name = sysMCAST_JOIN_SOURCE_GROUP
68 - sockOpts[ssoJoinSourceGroup].typ = ssoTypeGroupSourceReq
69 - sockOpts[ssoLeaveSourceGroup].name = sysMCAST_LEAVE_SOURCE_GROUP
70 - sockOpts[ssoLeaveSourceGroup].typ = ssoTypeGroupSourceReq
71 - sockOpts[ssoBlockSourceGroup].name = sysMCAST_BLOCK_SOURCE
72 - sockOpts[ssoBlockSourceGroup].typ = ssoTypeGroupSourceReq
73 - sockOpts[ssoUnblockSourceGroup].name = sysMCAST_UNBLOCK_SOURCE
74 - sockOpts[ssoUnblockSourceGroup].typ = ssoTypeGroupSourceReq
75 - }
76 -}
77 -
78 -func (pi *sysInetPktinfo) setIfindex(i int) {
79 - pi.Ifindex = uint32(i)
80 -}
81 -
82 -func (gr *sysGroupReq) setGroup(grp net.IP) {
83 - sa := (*sysSockaddrInet)(unsafe.Pointer(&gr.Pad_cgo_0[0]))
84 - sa.Len = sysSizeofSockaddrInet
85 - sa.Family = syscall.AF_INET
86 - copy(sa.Addr[:], grp)
87 -}
88 -
89 -func (gsr *sysGroupSourceReq) setSourceGroup(grp, src net.IP) {
90 - sa := (*sysSockaddrInet)(unsafe.Pointer(&gsr.Pad_cgo_0[0]))
91 - sa.Len = sysSizeofSockaddrInet
92 - sa.Family = syscall.AF_INET
93 - copy(sa.Addr[:], grp)
94 - sa = (*sysSockaddrInet)(unsafe.Pointer(&gsr.Pad_cgo_1[0]))
95 - sa.Len = sysSizeofSockaddrInet
96 - sa.Family = syscall.AF_INET
97 - copy(sa.Addr[:], src)
98 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sys_freebsd.go deleted
-64
@@ -1,64 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "net"
9 - "syscall"
10 - "unsafe"
11 -)
12 -
13 -type sysSockoptLen int32
14 -
15 -var (
16 - ctlOpts = [ctlMax]ctlOpt{
17 - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL},
18 - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst},
19 - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface},
20 - }
21 -
22 - sockOpts = [ssoMax]sockOpt{
23 - ssoTOS: {sysIP_TOS, ssoTypeInt},
24 - ssoTTL: {sysIP_TTL, ssoTypeInt},
25 - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte},
26 - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface},
27 - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt},
28 - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt},
29 - ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt},
30 - ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt},
31 - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt},
32 - ssoJoinGroup: {sysMCAST_JOIN_GROUP, ssoTypeGroupReq},
33 - ssoLeaveGroup: {sysMCAST_LEAVE_GROUP, ssoTypeGroupReq},
34 - ssoJoinSourceGroup: {sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq},
35 - ssoLeaveSourceGroup: {sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq},
36 - ssoBlockSourceGroup: {sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq},
37 - ssoUnblockSourceGroup: {sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq},
38 - }
39 -)
40 -
41 -func init() {
42 - freebsdVersion, _ = syscall.SysctlUint32("kern.osreldate")
43 - if freebsdVersion >= 1000000 {
44 - sockOpts[ssoMulticastInterface].typ = ssoTypeIPMreqn
45 - }
46 -}
47 -
48 -func (gr *sysGroupReq) setGroup(grp net.IP) {
49 - sa := (*sysSockaddrInet)(unsafe.Pointer(&gr.Group))
50 - sa.Len = sysSizeofSockaddrInet
51 - sa.Family = syscall.AF_INET
52 - copy(sa.Addr[:], grp)
53 -}
54 -
55 -func (gsr *sysGroupSourceReq) setSourceGroup(grp, src net.IP) {
56 - sa := (*sysSockaddrInet)(unsafe.Pointer(&gsr.Group))
57 - sa.Len = sysSizeofSockaddrInet
58 - sa.Family = syscall.AF_INET
59 - copy(sa.Addr[:], grp)
60 - sa = (*sysSockaddrInet)(unsafe.Pointer(&gsr.Source))
61 - sa.Len = sysSizeofSockaddrInet
62 - sa.Family = syscall.AF_INET
63 - copy(sa.Addr[:], src)
64 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sys_linux.go deleted
-57
@@ -1,57 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "net"
9 - "syscall"
10 - "unsafe"
11 -)
12 -
13 -type sysSockoptLen int32
14 -
15 -var (
16 - ctlOpts = [ctlMax]ctlOpt{
17 - ctlTTL: {sysIP_TTL, 1, marshalTTL, parseTTL},
18 - ctlPacketInfo: {sysIP_PKTINFO, sysSizeofInetPktinfo, marshalPacketInfo, parsePacketInfo},
19 - }
20 -
21 - sockOpts = [ssoMax]sockOpt{
22 - ssoTOS: {sysIP_TOS, ssoTypeInt},
23 - ssoTTL: {sysIP_TTL, ssoTypeInt},
24 - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeInt},
25 - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeIPMreqn},
26 - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt},
27 - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt},
28 - ssoPacketInfo: {sysIP_PKTINFO, ssoTypeInt},
29 - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt},
30 - ssoICMPFilter: {sysICMP_FILTER, ssoTypeICMPFilter},
31 - ssoJoinGroup: {sysMCAST_JOIN_GROUP, ssoTypeGroupReq},
32 - ssoLeaveGroup: {sysMCAST_LEAVE_GROUP, ssoTypeGroupReq},
33 - ssoJoinSourceGroup: {sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq},
34 - ssoLeaveSourceGroup: {sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq},
35 - ssoBlockSourceGroup: {sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq},
36 - ssoUnblockSourceGroup: {sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq},
37 - }
38 -)
39 -
40 -func (pi *sysInetPktinfo) setIfindex(i int) {
41 - pi.Ifindex = int32(i)
42 -}
43 -
44 -func (gr *sysGroupReq) setGroup(grp net.IP) {
45 - sa := (*sysSockaddrInet)(unsafe.Pointer(&gr.Group))
46 - sa.Family = syscall.AF_INET
47 - copy(sa.Addr[:], grp)
48 -}
49 -
50 -func (gsr *sysGroupSourceReq) setSourceGroup(grp, src net.IP) {
51 - sa := (*sysSockaddrInet)(unsafe.Pointer(&gsr.Group))
52 - sa.Family = syscall.AF_INET
53 - copy(sa.Addr[:], grp)
54 - sa = (*sysSockaddrInet)(unsafe.Pointer(&gsr.Source))
55 - sa.Family = syscall.AF_INET
56 - copy(sa.Addr[:], src)
57 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/sys_openbsd.go deleted
-34
@@ -1,34 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "net"
9 - "syscall"
10 -)
11 -
12 -type sysSockoptLen int32
13 -
14 -var (
15 - ctlOpts = [ctlMax]ctlOpt{
16 - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL},
17 - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst},
18 - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface},
19 - }
20 -
21 - sockOpts = [ssoMax]sockOpt{
22 - ssoTOS: {sysIP_TOS, ssoTypeInt},
23 - ssoTTL: {sysIP_TTL, ssoTypeInt},
24 - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte},
25 - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface},
26 - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeByte},
27 - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt},
28 - ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt},
29 - ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt},
30 - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt},
31 - ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq},
32 - ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq},
33 - }
34 -)
Godeps/_workspace/src/golang.org/x/net/ipv4/sys_stub.go deleted
-15
@@ -1,15 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9 solaris
6 -
7 -package ipv4
8 -
9 -type sysSockoptLen int32
10 -
11 -var (
12 - ctlOpts = [ctlMax]ctlOpt{}
13 -
14 - sockOpts = [ssoMax]sockOpt{}
15 -)
Godeps/_workspace/src/golang.org/x/net/ipv4/sys_windows.go deleted
-61
@@ -1,61 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -const (
8 - // See ws2tcpip.h.
9 - sysIP_OPTIONS = 0x1
10 - sysIP_HDRINCL = 0x2
11 - sysIP_TOS = 0x3
12 - sysIP_TTL = 0x4
13 - sysIP_MULTICAST_IF = 0x9
14 - sysIP_MULTICAST_TTL = 0xa
15 - sysIP_MULTICAST_LOOP = 0xb
16 - sysIP_ADD_MEMBERSHIP = 0xc
17 - sysIP_DROP_MEMBERSHIP = 0xd
18 - sysIP_DONTFRAGMENT = 0xe
19 - sysIP_ADD_SOURCE_MEMBERSHIP = 0xf
20 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x10
21 - sysIP_PKTINFO = 0x13
22 -
23 - sysSizeofInetPktinfo = 0x8
24 - sysSizeofIPMreq = 0x8
25 - sysSizeofIPMreqSource = 0xc
26 -)
27 -
28 -type sysInetPktinfo struct {
29 - Addr [4]byte
30 - Ifindex int32
31 -}
32 -
33 -type sysIPMreq struct {
34 - Multiaddr [4]byte
35 - Interface [4]byte
36 -}
37 -
38 -type sysIPMreqSource struct {
39 - Multiaddr [4]byte
40 - Sourceaddr [4]byte
41 - Interface [4]byte
42 -}
43 -
44 -// See http://msdn.microsoft.com/en-us/library/windows/desktop/ms738586(v=vs.85).aspx
45 -var (
46 - ctlOpts = [ctlMax]ctlOpt{}
47 -
48 - sockOpts = [ssoMax]sockOpt{
49 - ssoTOS: {sysIP_TOS, ssoTypeInt},
50 - ssoTTL: {sysIP_TTL, ssoTypeInt},
51 - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeInt},
52 - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface},
53 - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt},
54 - ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq},
55 - ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq},
56 - }
57 -)
58 -
59 -func (pi *sysInetPktinfo) setIfindex(i int) {
60 - pi.Ifindex = int32(i)
61 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/syscall_linux_386.go deleted
-31
@@ -1,31 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4
6 -
7 -import (
8 - "syscall"
9 - "unsafe"
10 -)
11 -
12 -const (
13 - sysGETSOCKOPT = 0xf
14 - sysSETSOCKOPT = 0xe
15 -)
16 -
17 -func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno)
18 -
19 -func getsockopt(fd, level, name int, v unsafe.Pointer, l *sysSockoptLen) error {
20 - if _, errno := socketcall(sysGETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 {
21 - return error(errno)
22 - }
23 - return nil
24 -}
25 -
26 -func setsockopt(fd, level, name int, v unsafe.Pointer, l sysSockoptLen) error {
27 - if _, errno := socketcall(sysSETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 {
28 - return error(errno)
29 - }
30 - return nil
31 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/syscall_unix.go deleted
-26
@@ -1,26 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux,amd64 linux,arm linux,ppc64 linux,ppc64le netbsd openbsd
6 -
7 -package ipv4
8 -
9 -import (
10 - "syscall"
11 - "unsafe"
12 -)
13 -
14 -func getsockopt(fd, level, name int, v unsafe.Pointer, l *sysSockoptLen) error {
15 - if _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 {
16 - return error(errno)
17 - }
18 - return nil
19 -}
20 -
21 -func setsockopt(fd, level, name int, v unsafe.Pointer, l sysSockoptLen) error {
22 - if _, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 {
23 - return error(errno)
24 - }
25 - return nil
26 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/thunk_linux_386.s deleted
-8
@@ -1,8 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build go1.2
6 -
7 -TEXT ·socketcall(SB),4,$0-36
8 - JMP syscall·socketcall(SB)
Godeps/_workspace/src/golang.org/x/net/ipv4/unicast_test.go deleted
-250
@@ -1,250 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4_test
6 -
7 -import (
8 - "bytes"
9 - "net"
10 - "os"
11 - "runtime"
12 - "testing"
13 - "time"
14 -
15 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
16 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv4"
17 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/icmp"
18 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
19 -)
20 -
21 -func TestPacketConnReadWriteUnicastUDP(t *testing.T) {
22 - switch runtime.GOOS {
23 - case "nacl", "plan9", "solaris", "windows":
24 - t.Skipf("not supported on %s", runtime.GOOS)
25 - }
26 - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback)
27 - if ifi == nil {
28 - t.Skipf("not available on %s", runtime.GOOS)
29 - }
30 -
31 - c, err := net.ListenPacket("udp4", "127.0.0.1:0")
32 - if err != nil {
33 - t.Fatal(err)
34 - }
35 - defer c.Close()
36 -
37 - dst, err := net.ResolveUDPAddr("udp4", c.LocalAddr().String())
38 - if err != nil {
39 - t.Fatal(err)
40 - }
41 - p := ipv4.NewPacketConn(c)
42 - defer p.Close()
43 - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface
44 - wb := []byte("HELLO-R-U-THERE")
45 -
46 - for i, toggle := range []bool{true, false, true} {
47 - if err := p.SetControlMessage(cf, toggle); err != nil {
48 - if nettest.ProtocolNotSupported(err) {
49 - t.Logf("not supported on %s", runtime.GOOS)
50 - continue
51 - }
52 - t.Fatal(err)
53 - }
54 - p.SetTTL(i + 1)
55 - if err := p.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
56 - t.Fatal(err)
57 - }
58 - if n, err := p.WriteTo(wb, nil, dst); err != nil {
59 - t.Fatal(err)
60 - } else if n != len(wb) {
61 - t.Fatalf("got %v; want %v", n, len(wb))
62 - }
63 - rb := make([]byte, 128)
64 - if err := p.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
65 - t.Fatal(err)
66 - }
67 - if n, cm, _, err := p.ReadFrom(rb); err != nil {
68 - t.Fatal(err)
69 - } else if !bytes.Equal(rb[:n], wb) {
70 - t.Fatalf("got %v; want %v", rb[:n], wb)
71 - } else {
72 - t.Logf("rcvd cmsg: %v", cm)
73 - }
74 - }
75 -}
76 -
77 -func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
78 - switch runtime.GOOS {
79 - case "nacl", "plan9", "solaris", "windows":
80 - t.Skipf("not supported on %s", runtime.GOOS)
81 - }
82 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
83 - t.Skip(m)
84 - }
85 - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback)
86 - if ifi == nil {
87 - t.Skipf("not available on %s", runtime.GOOS)
88 - }
89 -
90 - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0")
91 - if err != nil {
92 - t.Fatal(err)
93 - }
94 - defer c.Close()
95 -
96 - dst, err := net.ResolveIPAddr("ip4", "127.0.0.1")
97 - if err != nil {
98 - t.Fatal(err)
99 - }
100 - p := ipv4.NewPacketConn(c)
101 - defer p.Close()
102 - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface
103 -
104 - for i, toggle := range []bool{true, false, true} {
105 - wb, err := (&icmp.Message{
106 - Type: ipv4.ICMPTypeEcho, Code: 0,
107 - Body: &icmp.Echo{
108 - ID: os.Getpid() & 0xffff, Seq: i + 1,
109 - Data: []byte("HELLO-R-U-THERE"),
110 - },
111 - }).Marshal(nil)
112 - if err != nil {
113 - t.Fatal(err)
114 - }
115 - if err := p.SetControlMessage(cf, toggle); err != nil {
116 - if nettest.ProtocolNotSupported(err) {
117 - t.Logf("not supported on %s", runtime.GOOS)
118 - continue
119 - }
120 - t.Fatal(err)
121 - }
122 - p.SetTTL(i + 1)
123 - if err := p.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
124 - t.Fatal(err)
125 - }
126 - if n, err := p.WriteTo(wb, nil, dst); err != nil {
127 - t.Fatal(err)
128 - } else if n != len(wb) {
129 - t.Fatalf("got %v; want %v", n, len(wb))
130 - }
131 - rb := make([]byte, 128)
132 - loop:
133 - if err := p.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
134 - t.Fatal(err)
135 - }
136 - if n, cm, _, err := p.ReadFrom(rb); err != nil {
137 - switch runtime.GOOS {
138 - case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket
139 - t.Logf("not supported on %s", runtime.GOOS)
140 - continue
141 - }
142 - t.Fatal(err)
143 - } else {
144 - t.Logf("rcvd cmsg: %v", cm)
145 - m, err := icmp.ParseMessage(iana.ProtocolICMP, rb[:n])
146 - if err != nil {
147 - t.Fatal(err)
148 - }
149 - if runtime.GOOS == "linux" && m.Type == ipv4.ICMPTypeEcho {
150 - // On Linux we must handle own sent packets.
151 - goto loop
152 - }
153 - if m.Type != ipv4.ICMPTypeEchoReply || m.Code != 0 {
154 - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv4.ICMPTypeEchoReply, 0)
155 - }
156 - }
157 - }
158 -}
159 -
160 -func TestRawConnReadWriteUnicastICMP(t *testing.T) {
161 - switch runtime.GOOS {
162 - case "nacl", "plan9", "solaris", "windows":
163 - t.Skipf("not supported on %s", runtime.GOOS)
164 - }
165 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
166 - t.Skip(m)
167 - }
168 - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback)
169 - if ifi == nil {
170 - t.Skipf("not available on %s", runtime.GOOS)
171 - }
172 -
173 - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0")
174 - if err != nil {
175 - t.Fatal(err)
176 - }
177 - defer c.Close()
178 -
179 - dst, err := net.ResolveIPAddr("ip4", "127.0.0.1")
180 - if err != nil {
181 - t.Fatal(err)
182 - }
183 - r, err := ipv4.NewRawConn(c)
184 - if err != nil {
185 - t.Fatal(err)
186 - }
187 - defer r.Close()
188 - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface
189 -
190 - for i, toggle := range []bool{true, false, true} {
191 - wb, err := (&icmp.Message{
192 - Type: ipv4.ICMPTypeEcho, Code: 0,
193 - Body: &icmp.Echo{
194 - ID: os.Getpid() & 0xffff, Seq: i + 1,
195 - Data: []byte("HELLO-R-U-THERE"),
196 - },
197 - }).Marshal(nil)
198 - if err != nil {
199 - t.Fatal(err)
200 - }
201 - wh := &ipv4.Header{
202 - Version: ipv4.Version,
203 - Len: ipv4.HeaderLen,
204 - TOS: i + 1,
205 - TotalLen: ipv4.HeaderLen + len(wb),
206 - TTL: i + 1,
207 - Protocol: 1,
208 - Dst: dst.IP,
209 - }
210 - if err := r.SetControlMessage(cf, toggle); err != nil {
211 - if nettest.ProtocolNotSupported(err) {
212 - t.Logf("not supported on %s", runtime.GOOS)
213 - continue
214 - }
215 - t.Fatal(err)
216 - }
217 - if err := r.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
218 - t.Fatal(err)
219 - }
220 - if err := r.WriteTo(wh, wb, nil); err != nil {
221 - t.Fatal(err)
222 - }
223 - rb := make([]byte, ipv4.HeaderLen+128)
224 - loop:
225 - if err := r.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
226 - t.Fatal(err)
227 - }
228 - if _, b, cm, err := r.ReadFrom(rb); err != nil {
229 - switch runtime.GOOS {
230 - case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket
231 - t.Logf("not supported on %s", runtime.GOOS)
232 - continue
233 - }
234 - t.Fatal(err)
235 - } else {
236 - t.Logf("rcvd cmsg: %v", cm)
237 - m, err := icmp.ParseMessage(iana.ProtocolICMP, b)
238 - if err != nil {
239 - t.Fatal(err)
240 - }
241 - if runtime.GOOS == "linux" && m.Type == ipv4.ICMPTypeEcho {
242 - // On Linux we must handle own sent packets.
243 - goto loop
244 - }
245 - if m.Type != ipv4.ICMPTypeEchoReply || m.Code != 0 {
246 - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv4.ICMPTypeEchoReply, 0)
247 - }
248 - }
249 - }
250 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/unicastsockopt_test.go deleted
-139
@@ -1,139 +0,0 @@
1 -// Copyright 2012 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv4_test
6 -
7 -import (
8 - "net"
9 - "runtime"
10 - "testing"
11 -
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv4"
14 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
15 -)
16 -
17 -func TestConnUnicastSocketOptions(t *testing.T) {
18 - switch runtime.GOOS {
19 - case "nacl", "plan9", "solaris":
20 - t.Skipf("not supported on %s", runtime.GOOS)
21 - }
22 - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback)
23 - if ifi == nil {
24 - t.Skipf("not available on %s", runtime.GOOS)
25 - }
26 -
27 - ln, err := net.Listen("tcp4", "127.0.0.1:0")
28 - if err != nil {
29 - t.Fatal(err)
30 - }
31 - defer ln.Close()
32 -
33 - done := make(chan bool)
34 - go acceptor(t, ln, done)
35 -
36 - c, err := net.Dial("tcp4", ln.Addr().String())
37 - if err != nil {
38 - t.Fatal(err)
39 - }
40 - defer c.Close()
41 -
42 - testUnicastSocketOptions(t, ipv4.NewConn(c))
43 -
44 - <-done
45 -}
46 -
47 -var packetConnUnicastSocketOptionTests = []struct {
48 - net, proto, addr string
49 -}{
50 - {"udp4", "", "127.0.0.1:0"},
51 - {"ip4", ":icmp", "127.0.0.1"},
52 -}
53 -
54 -func TestPacketConnUnicastSocketOptions(t *testing.T) {
55 - switch runtime.GOOS {
56 - case "nacl", "plan9", "solaris":
57 - t.Skipf("not supported on %s", runtime.GOOS)
58 - }
59 - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback)
60 - if ifi == nil {
61 - t.Skipf("not available on %s", runtime.GOOS)
62 - }
63 -
64 - m, ok := nettest.SupportsRawIPSocket()
65 - for _, tt := range packetConnUnicastSocketOptionTests {
66 - if tt.net == "ip4" && !ok {
67 - t.Log(m)
68 - continue
69 - }
70 - c, err := net.ListenPacket(tt.net+tt.proto, tt.addr)
71 - if err != nil {
72 - t.Fatal(err)
73 - }
74 - defer c.Close()
75 -
76 - testUnicastSocketOptions(t, ipv4.NewPacketConn(c))
77 - }
78 -}
79 -
80 -func TestRawConnUnicastSocketOptions(t *testing.T) {
81 - switch runtime.GOOS {
82 - case "nacl", "plan9", "solaris":
83 - t.Skipf("not supported on %s", runtime.GOOS)
84 - }
85 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
86 - t.Skip(m)
87 - }
88 - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback)
89 - if ifi == nil {
90 - t.Skipf("not available on %s", runtime.GOOS)
91 - }
92 -
93 - c, err := net.ListenPacket("ip4:icmp", "127.0.0.1")
94 - if err != nil {
95 - t.Fatal(err)
96 - }
97 - defer c.Close()
98 -
99 - r, err := ipv4.NewRawConn(c)
100 - if err != nil {
101 - t.Fatal(err)
102 - }
103 -
104 - testUnicastSocketOptions(t, r)
105 -}
106 -
107 -type testIPv4UnicastConn interface {
108 - TOS() (int, error)
109 - SetTOS(int) error
110 - TTL() (int, error)
111 - SetTTL(int) error
112 -}
113 -
114 -func testUnicastSocketOptions(t *testing.T, c testIPv4UnicastConn) {
115 - tos := iana.DiffServCS0 | iana.NotECNTransport
116 - switch runtime.GOOS {
117 - case "windows":
118 - // IP_TOS option is supported on Windows 8 and beyond.
119 - t.Skipf("not supported on %s", runtime.GOOS)
120 - }
121 -
122 - if err := c.SetTOS(tos); err != nil {
123 - t.Fatal(err)
124 - }
125 - if v, err := c.TOS(); err != nil {
126 - t.Fatal(err)
127 - } else if v != tos {
128 - t.Fatalf("got %v; want %v", v, tos)
129 - }
130 - const ttl = 255
131 - if err := c.SetTTL(ttl); err != nil {
132 - t.Fatal(err)
133 - }
134 - if v, err := c.TTL(); err != nil {
135 - t.Fatal(err)
136 - } else if v != ttl {
137 - t.Fatalf("got %v; want %v", v, ttl)
138 - }
139 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_darwin.go deleted
-99
@@ -1,99 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_darwin.go
3 -
4 -package ipv4
5 -
6 -const (
7 - sysIP_OPTIONS = 0x1
8 - sysIP_HDRINCL = 0x2
9 - sysIP_TOS = 0x3
10 - sysIP_TTL = 0x4
11 - sysIP_RECVOPTS = 0x5
12 - sysIP_RECVRETOPTS = 0x6
13 - sysIP_RECVDSTADDR = 0x7
14 - sysIP_RETOPTS = 0x8
15 - sysIP_RECVIF = 0x14
16 - sysIP_STRIPHDR = 0x17
17 - sysIP_RECVTTL = 0x18
18 - sysIP_BOUND_IF = 0x19
19 - sysIP_PKTINFO = 0x1a
20 - sysIP_RECVPKTINFO = 0x1a
21 -
22 - sysIP_MULTICAST_IF = 0x9
23 - sysIP_MULTICAST_TTL = 0xa
24 - sysIP_MULTICAST_LOOP = 0xb
25 - sysIP_ADD_MEMBERSHIP = 0xc
26 - sysIP_DROP_MEMBERSHIP = 0xd
27 - sysIP_MULTICAST_VIF = 0xe
28 - sysIP_MULTICAST_IFINDEX = 0x42
29 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46
30 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47
31 - sysIP_BLOCK_SOURCE = 0x48
32 - sysIP_UNBLOCK_SOURCE = 0x49
33 - sysMCAST_JOIN_GROUP = 0x50
34 - sysMCAST_LEAVE_GROUP = 0x51
35 - sysMCAST_JOIN_SOURCE_GROUP = 0x52
36 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53
37 - sysMCAST_BLOCK_SOURCE = 0x54
38 - sysMCAST_UNBLOCK_SOURCE = 0x55
39 -
40 - sysSizeofSockaddrStorage = 0x80
41 - sysSizeofSockaddrInet = 0x10
42 - sysSizeofInetPktinfo = 0xc
43 -
44 - sysSizeofIPMreq = 0x8
45 - sysSizeofIPMreqn = 0xc
46 - sysSizeofIPMreqSource = 0xc
47 - sysSizeofGroupReq = 0x84
48 - sysSizeofGroupSourceReq = 0x104
49 -)
50 -
51 -type sysSockaddrStorage struct {
52 - Len uint8
53 - Family uint8
54 - X__ss_pad1 [6]int8
55 - X__ss_align int64
56 - X__ss_pad2 [112]int8
57 -}
58 -
59 -type sysSockaddrInet struct {
60 - Len uint8
61 - Family uint8
62 - Port uint16
63 - Addr [4]byte /* in_addr */
64 - Zero [8]int8
65 -}
66 -
67 -type sysInetPktinfo struct {
68 - Ifindex uint32
69 - Spec_dst [4]byte /* in_addr */
70 - Addr [4]byte /* in_addr */
71 -}
72 -
73 -type sysIPMreq struct {
74 - Multiaddr [4]byte /* in_addr */
75 - Interface [4]byte /* in_addr */
76 -}
77 -
78 -type sysIPMreqn struct {
79 - Multiaddr [4]byte /* in_addr */
80 - Address [4]byte /* in_addr */
81 - Ifindex int32
82 -}
83 -
84 -type sysIPMreqSource struct {
85 - Multiaddr [4]byte /* in_addr */
86 - Sourceaddr [4]byte /* in_addr */
87 - Interface [4]byte /* in_addr */
88 -}
89 -
90 -type sysGroupReq struct {
91 - Interface uint32
92 - Pad_cgo_0 [128]byte
93 -}
94 -
95 -type sysGroupSourceReq struct {
96 - Interface uint32
97 - Pad_cgo_0 [128]byte
98 - Pad_cgo_1 [128]byte
99 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_dragonfly.go deleted
-33
@@ -1,33 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_dragonfly.go
3 -
4 -// +build dragonfly
5 -
6 -package ipv4
7 -
8 -const (
9 - sysIP_OPTIONS = 0x1
10 - sysIP_HDRINCL = 0x2
11 - sysIP_TOS = 0x3
12 - sysIP_TTL = 0x4
13 - sysIP_RECVOPTS = 0x5
14 - sysIP_RECVRETOPTS = 0x6
15 - sysIP_RECVDSTADDR = 0x7
16 - sysIP_RETOPTS = 0x8
17 - sysIP_RECVIF = 0x14
18 - sysIP_RECVTTL = 0x41
19 -
20 - sysIP_MULTICAST_IF = 0x9
21 - sysIP_MULTICAST_TTL = 0xa
22 - sysIP_MULTICAST_LOOP = 0xb
23 - sysIP_MULTICAST_VIF = 0xe
24 - sysIP_ADD_MEMBERSHIP = 0xc
25 - sysIP_DROP_MEMBERSHIP = 0xd
26 -
27 - sysSizeofIPMreq = 0x8
28 -)
29 -
30 -type sysIPMreq struct {
31 - Multiaddr [4]byte /* in_addr */
32 - Interface [4]byte /* in_addr */
33 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_freebsd_386.go deleted
-93
@@ -1,93 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_freebsd.go
3 -
4 -package ipv4
5 -
6 -const (
7 - sysIP_OPTIONS = 0x1
8 - sysIP_HDRINCL = 0x2
9 - sysIP_TOS = 0x3
10 - sysIP_TTL = 0x4
11 - sysIP_RECVOPTS = 0x5
12 - sysIP_RECVRETOPTS = 0x6
13 - sysIP_RECVDSTADDR = 0x7
14 - sysIP_SENDSRCADDR = 0x7
15 - sysIP_RETOPTS = 0x8
16 - sysIP_RECVIF = 0x14
17 - sysIP_ONESBCAST = 0x17
18 - sysIP_BINDANY = 0x18
19 - sysIP_RECVTTL = 0x41
20 - sysIP_MINTTL = 0x42
21 - sysIP_DONTFRAG = 0x43
22 - sysIP_RECVTOS = 0x44
23 -
24 - sysIP_MULTICAST_IF = 0x9
25 - sysIP_MULTICAST_TTL = 0xa
26 - sysIP_MULTICAST_LOOP = 0xb
27 - sysIP_ADD_MEMBERSHIP = 0xc
28 - sysIP_DROP_MEMBERSHIP = 0xd
29 - sysIP_MULTICAST_VIF = 0xe
30 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46
31 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47
32 - sysIP_BLOCK_SOURCE = 0x48
33 - sysIP_UNBLOCK_SOURCE = 0x49
34 - sysMCAST_JOIN_GROUP = 0x50
35 - sysMCAST_LEAVE_GROUP = 0x51
36 - sysMCAST_JOIN_SOURCE_GROUP = 0x52
37 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53
38 - sysMCAST_BLOCK_SOURCE = 0x54
39 - sysMCAST_UNBLOCK_SOURCE = 0x55
40 -
41 - sysSizeofSockaddrStorage = 0x80
42 - sysSizeofSockaddrInet = 0x10
43 -
44 - sysSizeofIPMreq = 0x8
45 - sysSizeofIPMreqn = 0xc
46 - sysSizeofIPMreqSource = 0xc
47 - sysSizeofGroupReq = 0x84
48 - sysSizeofGroupSourceReq = 0x104
49 -)
50 -
51 -type sysSockaddrStorage struct {
52 - Len uint8
53 - Family uint8
54 - X__ss_pad1 [6]int8
55 - X__ss_align int64
56 - X__ss_pad2 [112]int8
57 -}
58 -
59 -type sysSockaddrInet struct {
60 - Len uint8
61 - Family uint8
62 - Port uint16
63 - Addr [4]byte /* in_addr */
64 - Zero [8]int8
65 -}
66 -
67 -type sysIPMreq struct {
68 - Multiaddr [4]byte /* in_addr */
69 - Interface [4]byte /* in_addr */
70 -}
71 -
72 -type sysIPMreqn struct {
73 - Multiaddr [4]byte /* in_addr */
74 - Address [4]byte /* in_addr */
75 - Ifindex int32
76 -}
77 -
78 -type sysIPMreqSource struct {
79 - Multiaddr [4]byte /* in_addr */
80 - Sourceaddr [4]byte /* in_addr */
81 - Interface [4]byte /* in_addr */
82 -}
83 -
84 -type sysGroupReq struct {
85 - Interface uint32
86 - Group sysSockaddrStorage
87 -}
88 -
89 -type sysGroupSourceReq struct {
90 - Interface uint32
91 - Group sysSockaddrStorage
92 - Source sysSockaddrStorage
93 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_freebsd_amd64.go deleted
-95
@@ -1,95 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_freebsd.go
3 -
4 -package ipv4
5 -
6 -const (
7 - sysIP_OPTIONS = 0x1
8 - sysIP_HDRINCL = 0x2
9 - sysIP_TOS = 0x3
10 - sysIP_TTL = 0x4
11 - sysIP_RECVOPTS = 0x5
12 - sysIP_RECVRETOPTS = 0x6
13 - sysIP_RECVDSTADDR = 0x7
14 - sysIP_SENDSRCADDR = 0x7
15 - sysIP_RETOPTS = 0x8
16 - sysIP_RECVIF = 0x14
17 - sysIP_ONESBCAST = 0x17
18 - sysIP_BINDANY = 0x18
19 - sysIP_RECVTTL = 0x41
20 - sysIP_MINTTL = 0x42
21 - sysIP_DONTFRAG = 0x43
22 - sysIP_RECVTOS = 0x44
23 -
24 - sysIP_MULTICAST_IF = 0x9
25 - sysIP_MULTICAST_TTL = 0xa
26 - sysIP_MULTICAST_LOOP = 0xb
27 - sysIP_ADD_MEMBERSHIP = 0xc
28 - sysIP_DROP_MEMBERSHIP = 0xd
29 - sysIP_MULTICAST_VIF = 0xe
30 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46
31 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47
32 - sysIP_BLOCK_SOURCE = 0x48
33 - sysIP_UNBLOCK_SOURCE = 0x49
34 - sysMCAST_JOIN_GROUP = 0x50
35 - sysMCAST_LEAVE_GROUP = 0x51
36 - sysMCAST_JOIN_SOURCE_GROUP = 0x52
37 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53
38 - sysMCAST_BLOCK_SOURCE = 0x54
39 - sysMCAST_UNBLOCK_SOURCE = 0x55
40 -
41 - sysSizeofSockaddrStorage = 0x80
42 - sysSizeofSockaddrInet = 0x10
43 -
44 - sysSizeofIPMreq = 0x8
45 - sysSizeofIPMreqn = 0xc
46 - sysSizeofIPMreqSource = 0xc
47 - sysSizeofGroupReq = 0x88
48 - sysSizeofGroupSourceReq = 0x108
49 -)
50 -
51 -type sysSockaddrStorage struct {
52 - Len uint8
53 - Family uint8
54 - X__ss_pad1 [6]int8
55 - X__ss_align int64
56 - X__ss_pad2 [112]int8
57 -}
58 -
59 -type sysSockaddrInet struct {
60 - Len uint8
61 - Family uint8
62 - Port uint16
63 - Addr [4]byte /* in_addr */
64 - Zero [8]int8
65 -}
66 -
67 -type sysIPMreq struct {
68 - Multiaddr [4]byte /* in_addr */
69 - Interface [4]byte /* in_addr */
70 -}
71 -
72 -type sysIPMreqn struct {
73 - Multiaddr [4]byte /* in_addr */
74 - Address [4]byte /* in_addr */
75 - Ifindex int32
76 -}
77 -
78 -type sysIPMreqSource struct {
79 - Multiaddr [4]byte /* in_addr */
80 - Sourceaddr [4]byte /* in_addr */
81 - Interface [4]byte /* in_addr */
82 -}
83 -
84 -type sysGroupReq struct {
85 - Interface uint32
86 - Pad_cgo_0 [4]byte
87 - Group sysSockaddrStorage
88 -}
89 -
90 -type sysGroupSourceReq struct {
91 - Interface uint32
92 - Pad_cgo_0 [4]byte
93 - Group sysSockaddrStorage
94 - Source sysSockaddrStorage
95 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_freebsd_arm.go deleted
-93
@@ -1,93 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_freebsd.go
3 -
4 -package ipv4
5 -
6 -const (
7 - sysIP_OPTIONS = 0x1
8 - sysIP_HDRINCL = 0x2
9 - sysIP_TOS = 0x3
10 - sysIP_TTL = 0x4
11 - sysIP_RECVOPTS = 0x5
12 - sysIP_RECVRETOPTS = 0x6
13 - sysIP_RECVDSTADDR = 0x7
14 - sysIP_SENDSRCADDR = 0x7
15 - sysIP_RETOPTS = 0x8
16 - sysIP_RECVIF = 0x14
17 - sysIP_ONESBCAST = 0x17
18 - sysIP_BINDANY = 0x18
19 - sysIP_RECVTTL = 0x41
20 - sysIP_MINTTL = 0x42
21 - sysIP_DONTFRAG = 0x43
22 - sysIP_RECVTOS = 0x44
23 -
24 - sysIP_MULTICAST_IF = 0x9
25 - sysIP_MULTICAST_TTL = 0xa
26 - sysIP_MULTICAST_LOOP = 0xb
27 - sysIP_ADD_MEMBERSHIP = 0xc
28 - sysIP_DROP_MEMBERSHIP = 0xd
29 - sysIP_MULTICAST_VIF = 0xe
30 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46
31 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47
32 - sysIP_BLOCK_SOURCE = 0x48
33 - sysIP_UNBLOCK_SOURCE = 0x49
34 - sysMCAST_JOIN_GROUP = 0x50
35 - sysMCAST_LEAVE_GROUP = 0x51
36 - sysMCAST_JOIN_SOURCE_GROUP = 0x52
37 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53
38 - sysMCAST_BLOCK_SOURCE = 0x54
39 - sysMCAST_UNBLOCK_SOURCE = 0x55
40 -
41 - sysSizeofSockaddrStorage = 0x80
42 - sysSizeofSockaddrInet = 0x10
43 -
44 - sysSizeofIPMreq = 0x8
45 - sysSizeofIPMreqn = 0xc
46 - sysSizeofIPMreqSource = 0xc
47 - sysSizeofGroupReq = 0x84
48 - sysSizeofGroupSourceReq = 0x104
49 -)
50 -
51 -type sysSockaddrStorage struct {
52 - Len uint8
53 - Family uint8
54 - X__ss_pad1 [6]int8
55 - X__ss_align int64
56 - X__ss_pad2 [112]int8
57 -}
58 -
59 -type sysSockaddrInet struct {
60 - Len uint8
61 - Family uint8
62 - Port uint16
63 - Addr [4]byte /* in_addr */
64 - Zero [8]int8
65 -}
66 -
67 -type sysIPMreq struct {
68 - Multiaddr [4]byte /* in_addr */
69 - Interface [4]byte /* in_addr */
70 -}
71 -
72 -type sysIPMreqn struct {
73 - Multiaddr [4]byte /* in_addr */
74 - Address [4]byte /* in_addr */
75 - Ifindex int32
76 -}
77 -
78 -type sysIPMreqSource struct {
79 - Multiaddr [4]byte /* in_addr */
80 - Sourceaddr [4]byte /* in_addr */
81 - Interface [4]byte /* in_addr */
82 -}
83 -
84 -type sysGroupReq struct {
85 - Interface uint32
86 - Group sysSockaddrStorage
87 -}
88 -
89 -type sysGroupSourceReq struct {
90 - Interface uint32
91 - Group sysSockaddrStorage
92 - Source sysSockaddrStorage
93 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_linux_386.go deleted
-130
@@ -1,130 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_linux.go
3 -
4 -package ipv4
5 -
6 -const (
7 - sysIP_TOS = 0x1
8 - sysIP_TTL = 0x2
9 - sysIP_HDRINCL = 0x3
10 - sysIP_OPTIONS = 0x4
11 - sysIP_ROUTER_ALERT = 0x5
12 - sysIP_RECVOPTS = 0x6
13 - sysIP_RETOPTS = 0x7
14 - sysIP_PKTINFO = 0x8
15 - sysIP_PKTOPTIONS = 0x9
16 - sysIP_MTU_DISCOVER = 0xa
17 - sysIP_RECVERR = 0xb
18 - sysIP_RECVTTL = 0xc
19 - sysIP_RECVTOS = 0xd
20 - sysIP_MTU = 0xe
21 - sysIP_FREEBIND = 0xf
22 - sysIP_TRANSPARENT = 0x13
23 - sysIP_RECVRETOPTS = 0x7
24 - sysIP_ORIGDSTADDR = 0x14
25 - sysIP_RECVORIGDSTADDR = 0x14
26 - sysIP_MINTTL = 0x15
27 - sysIP_NODEFRAG = 0x16
28 - sysIP_UNICAST_IF = 0x32
29 -
30 - sysIP_MULTICAST_IF = 0x20
31 - sysIP_MULTICAST_TTL = 0x21
32 - sysIP_MULTICAST_LOOP = 0x22
33 - sysIP_ADD_MEMBERSHIP = 0x23
34 - sysIP_DROP_MEMBERSHIP = 0x24
35 - sysIP_UNBLOCK_SOURCE = 0x25
36 - sysIP_BLOCK_SOURCE = 0x26
37 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27
38 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28
39 - sysIP_MSFILTER = 0x29
40 - sysMCAST_JOIN_GROUP = 0x2a
41 - sysMCAST_LEAVE_GROUP = 0x2d
42 - sysMCAST_JOIN_SOURCE_GROUP = 0x2e
43 - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f
44 - sysMCAST_BLOCK_SOURCE = 0x2b
45 - sysMCAST_UNBLOCK_SOURCE = 0x2c
46 - sysMCAST_MSFILTER = 0x30
47 - sysIP_MULTICAST_ALL = 0x31
48 -
49 - sysICMP_FILTER = 0x1
50 -
51 - sysSO_EE_ORIGIN_NONE = 0x0
52 - sysSO_EE_ORIGIN_LOCAL = 0x1
53 - sysSO_EE_ORIGIN_ICMP = 0x2
54 - sysSO_EE_ORIGIN_ICMP6 = 0x3
55 - sysSO_EE_ORIGIN_TXSTATUS = 0x4
56 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
57 -
58 - sysSizeofKernelSockaddrStorage = 0x80
59 - sysSizeofSockaddrInet = 0x10
60 - sysSizeofInetPktinfo = 0xc
61 - sysSizeofSockExtendedErr = 0x10
62 -
63 - sysSizeofIPMreq = 0x8
64 - sysSizeofIPMreqn = 0xc
65 - sysSizeofIPMreqSource = 0xc
66 - sysSizeofGroupReq = 0x84
67 - sysSizeofGroupSourceReq = 0x104
68 -
69 - sysSizeofICMPFilter = 0x4
70 -)
71 -
72 -type sysKernelSockaddrStorage struct {
73 - Family uint16
74 - X__data [126]int8
75 -}
76 -
77 -type sysSockaddrInet struct {
78 - Family uint16
79 - Port uint16
80 - Addr [4]byte /* in_addr */
81 - X__pad [8]uint8
82 -}
83 -
84 -type sysInetPktinfo struct {
85 - Ifindex int32
86 - Spec_dst [4]byte /* in_addr */
87 - Addr [4]byte /* in_addr */
88 -}
89 -
90 -type sysSockExtendedErr struct {
91 - Errno uint32
92 - Origin uint8
93 - Type uint8
94 - Code uint8
95 - Pad uint8
96 - Info uint32
97 - Data uint32
98 -}
99 -
100 -type sysIPMreq struct {
101 - Multiaddr [4]byte /* in_addr */
102 - Interface [4]byte /* in_addr */
103 -}
104 -
105 -type sysIPMreqn struct {
106 - Multiaddr [4]byte /* in_addr */
107 - Address [4]byte /* in_addr */
108 - Ifindex int32
109 -}
110 -
111 -type sysIPMreqSource struct {
112 - Multiaddr uint32
113 - Interface uint32
114 - Sourceaddr uint32
115 -}
116 -
117 -type sysGroupReq struct {
118 - Interface uint32
119 - Group sysKernelSockaddrStorage
120 -}
121 -
122 -type sysGroupSourceReq struct {
123 - Interface uint32
124 - Group sysKernelSockaddrStorage
125 - Source sysKernelSockaddrStorage
126 -}
127 -
128 -type sysICMPFilter struct {
129 - Data uint32
130 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_linux_amd64.go deleted
-132
@@ -1,132 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_linux.go
3 -
4 -package ipv4
5 -
6 -const (
7 - sysIP_TOS = 0x1
8 - sysIP_TTL = 0x2
9 - sysIP_HDRINCL = 0x3
10 - sysIP_OPTIONS = 0x4
11 - sysIP_ROUTER_ALERT = 0x5
12 - sysIP_RECVOPTS = 0x6
13 - sysIP_RETOPTS = 0x7
14 - sysIP_PKTINFO = 0x8
15 - sysIP_PKTOPTIONS = 0x9
16 - sysIP_MTU_DISCOVER = 0xa
17 - sysIP_RECVERR = 0xb
18 - sysIP_RECVTTL = 0xc
19 - sysIP_RECVTOS = 0xd
20 - sysIP_MTU = 0xe
21 - sysIP_FREEBIND = 0xf
22 - sysIP_TRANSPARENT = 0x13
23 - sysIP_RECVRETOPTS = 0x7
24 - sysIP_ORIGDSTADDR = 0x14
25 - sysIP_RECVORIGDSTADDR = 0x14
26 - sysIP_MINTTL = 0x15
27 - sysIP_NODEFRAG = 0x16
28 - sysIP_UNICAST_IF = 0x32
29 -
30 - sysIP_MULTICAST_IF = 0x20
31 - sysIP_MULTICAST_TTL = 0x21
32 - sysIP_MULTICAST_LOOP = 0x22
33 - sysIP_ADD_MEMBERSHIP = 0x23
34 - sysIP_DROP_MEMBERSHIP = 0x24
35 - sysIP_UNBLOCK_SOURCE = 0x25
36 - sysIP_BLOCK_SOURCE = 0x26
37 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27
38 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28
39 - sysIP_MSFILTER = 0x29
40 - sysMCAST_JOIN_GROUP = 0x2a
41 - sysMCAST_LEAVE_GROUP = 0x2d
42 - sysMCAST_JOIN_SOURCE_GROUP = 0x2e
43 - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f
44 - sysMCAST_BLOCK_SOURCE = 0x2b
45 - sysMCAST_UNBLOCK_SOURCE = 0x2c
46 - sysMCAST_MSFILTER = 0x30
47 - sysIP_MULTICAST_ALL = 0x31
48 -
49 - sysICMP_FILTER = 0x1
50 -
51 - sysSO_EE_ORIGIN_NONE = 0x0
52 - sysSO_EE_ORIGIN_LOCAL = 0x1
53 - sysSO_EE_ORIGIN_ICMP = 0x2
54 - sysSO_EE_ORIGIN_ICMP6 = 0x3
55 - sysSO_EE_ORIGIN_TXSTATUS = 0x4
56 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
57 -
58 - sysSizeofKernelSockaddrStorage = 0x80
59 - sysSizeofSockaddrInet = 0x10
60 - sysSizeofInetPktinfo = 0xc
61 - sysSizeofSockExtendedErr = 0x10
62 -
63 - sysSizeofIPMreq = 0x8
64 - sysSizeofIPMreqn = 0xc
65 - sysSizeofIPMreqSource = 0xc
66 - sysSizeofGroupReq = 0x88
67 - sysSizeofGroupSourceReq = 0x108
68 -
69 - sysSizeofICMPFilter = 0x4
70 -)
71 -
72 -type sysKernelSockaddrStorage struct {
73 - Family uint16
74 - X__data [126]int8
75 -}
76 -
77 -type sysSockaddrInet struct {
78 - Family uint16
79 - Port uint16
80 - Addr [4]byte /* in_addr */
81 - X__pad [8]uint8
82 -}
83 -
84 -type sysInetPktinfo struct {
85 - Ifindex int32
86 - Spec_dst [4]byte /* in_addr */
87 - Addr [4]byte /* in_addr */
88 -}
89 -
90 -type sysSockExtendedErr struct {
91 - Errno uint32
92 - Origin uint8
93 - Type uint8
94 - Code uint8
95 - Pad uint8
96 - Info uint32
97 - Data uint32
98 -}
99 -
100 -type sysIPMreq struct {
101 - Multiaddr [4]byte /* in_addr */
102 - Interface [4]byte /* in_addr */
103 -}
104 -
105 -type sysIPMreqn struct {
106 - Multiaddr [4]byte /* in_addr */
107 - Address [4]byte /* in_addr */
108 - Ifindex int32
109 -}
110 -
111 -type sysIPMreqSource struct {
112 - Multiaddr uint32
113 - Interface uint32
114 - Sourceaddr uint32
115 -}
116 -
117 -type sysGroupReq struct {
118 - Interface uint32
119 - Pad_cgo_0 [4]byte
120 - Group sysKernelSockaddrStorage
121 -}
122 -
123 -type sysGroupSourceReq struct {
124 - Interface uint32
125 - Pad_cgo_0 [4]byte
126 - Group sysKernelSockaddrStorage
127 - Source sysKernelSockaddrStorage
128 -}
129 -
130 -type sysICMPFilter struct {
131 - Data uint32
132 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_linux_arm.go deleted
-130
@@ -1,130 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_linux.go
3 -
4 -package ipv4
5 -
6 -const (
7 - sysIP_TOS = 0x1
8 - sysIP_TTL = 0x2
9 - sysIP_HDRINCL = 0x3
10 - sysIP_OPTIONS = 0x4
11 - sysIP_ROUTER_ALERT = 0x5
12 - sysIP_RECVOPTS = 0x6
13 - sysIP_RETOPTS = 0x7
14 - sysIP_PKTINFO = 0x8
15 - sysIP_PKTOPTIONS = 0x9
16 - sysIP_MTU_DISCOVER = 0xa
17 - sysIP_RECVERR = 0xb
18 - sysIP_RECVTTL = 0xc
19 - sysIP_RECVTOS = 0xd
20 - sysIP_MTU = 0xe
21 - sysIP_FREEBIND = 0xf
22 - sysIP_TRANSPARENT = 0x13
23 - sysIP_RECVRETOPTS = 0x7
24 - sysIP_ORIGDSTADDR = 0x14
25 - sysIP_RECVORIGDSTADDR = 0x14
26 - sysIP_MINTTL = 0x15
27 - sysIP_NODEFRAG = 0x16
28 - sysIP_UNICAST_IF = 0x32
29 -
30 - sysIP_MULTICAST_IF = 0x20
31 - sysIP_MULTICAST_TTL = 0x21
32 - sysIP_MULTICAST_LOOP = 0x22
33 - sysIP_ADD_MEMBERSHIP = 0x23
34 - sysIP_DROP_MEMBERSHIP = 0x24
35 - sysIP_UNBLOCK_SOURCE = 0x25
36 - sysIP_BLOCK_SOURCE = 0x26
37 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27
38 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28
39 - sysIP_MSFILTER = 0x29
40 - sysMCAST_JOIN_GROUP = 0x2a
41 - sysMCAST_LEAVE_GROUP = 0x2d
42 - sysMCAST_JOIN_SOURCE_GROUP = 0x2e
43 - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f
44 - sysMCAST_BLOCK_SOURCE = 0x2b
45 - sysMCAST_UNBLOCK_SOURCE = 0x2c
46 - sysMCAST_MSFILTER = 0x30
47 - sysIP_MULTICAST_ALL = 0x31
48 -
49 - sysICMP_FILTER = 0x1
50 -
51 - sysSO_EE_ORIGIN_NONE = 0x0
52 - sysSO_EE_ORIGIN_LOCAL = 0x1
53 - sysSO_EE_ORIGIN_ICMP = 0x2
54 - sysSO_EE_ORIGIN_ICMP6 = 0x3
55 - sysSO_EE_ORIGIN_TXSTATUS = 0x4
56 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
57 -
58 - sysSizeofKernelSockaddrStorage = 0x80
59 - sysSizeofSockaddrInet = 0x10
60 - sysSizeofInetPktinfo = 0xc
61 - sysSizeofSockExtendedErr = 0x10
62 -
63 - sysSizeofIPMreq = 0x8
64 - sysSizeofIPMreqn = 0xc
65 - sysSizeofIPMreqSource = 0xc
66 - sysSizeofGroupReq = 0x84
67 - sysSizeofGroupSourceReq = 0x104
68 -
69 - sysSizeofICMPFilter = 0x4
70 -)
71 -
72 -type sysKernelSockaddrStorage struct {
73 - Family uint16
74 - X__data [126]int8
75 -}
76 -
77 -type sysSockaddrInet struct {
78 - Family uint16
79 - Port uint16
80 - Addr [4]byte /* in_addr */
81 - X__pad [8]uint8
82 -}
83 -
84 -type sysInetPktinfo struct {
85 - Ifindex int32
86 - Spec_dst [4]byte /* in_addr */
87 - Addr [4]byte /* in_addr */
88 -}
89 -
90 -type sysSockExtendedErr struct {
91 - Errno uint32
92 - Origin uint8
93 - Type uint8
94 - Code uint8
95 - Pad uint8
96 - Info uint32
97 - Data uint32
98 -}
99 -
100 -type sysIPMreq struct {
101 - Multiaddr [4]byte /* in_addr */
102 - Interface [4]byte /* in_addr */
103 -}
104 -
105 -type sysIPMreqn struct {
106 - Multiaddr [4]byte /* in_addr */
107 - Address [4]byte /* in_addr */
108 - Ifindex int32
109 -}
110 -
111 -type sysIPMreqSource struct {
112 - Multiaddr uint32
113 - Interface uint32
114 - Sourceaddr uint32
115 -}
116 -
117 -type sysGroupReq struct {
118 - Interface uint32
119 - Group sysKernelSockaddrStorage
120 -}
121 -
122 -type sysGroupSourceReq struct {
123 - Interface uint32
124 - Group sysKernelSockaddrStorage
125 - Source sysKernelSockaddrStorage
126 -}
127 -
128 -type sysICMPFilter struct {
129 - Data uint32
130 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_linux_arm64.go deleted
-134
@@ -1,134 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_linux.go
3 -
4 -// +build linux,arm64
5 -
6 -package ipv4
7 -
8 -const (
9 - sysIP_TOS = 0x1
10 - sysIP_TTL = 0x2
11 - sysIP_HDRINCL = 0x3
12 - sysIP_OPTIONS = 0x4
13 - sysIP_ROUTER_ALERT = 0x5
14 - sysIP_RECVOPTS = 0x6
15 - sysIP_RETOPTS = 0x7
16 - sysIP_PKTINFO = 0x8
17 - sysIP_PKTOPTIONS = 0x9
18 - sysIP_MTU_DISCOVER = 0xa
19 - sysIP_RECVERR = 0xb
20 - sysIP_RECVTTL = 0xc
21 - sysIP_RECVTOS = 0xd
22 - sysIP_MTU = 0xe
23 - sysIP_FREEBIND = 0xf
24 - sysIP_TRANSPARENT = 0x13
25 - sysIP_RECVRETOPTS = 0x7
26 - sysIP_ORIGDSTADDR = 0x14
27 - sysIP_RECVORIGDSTADDR = 0x14
28 - sysIP_MINTTL = 0x15
29 - sysIP_NODEFRAG = 0x16
30 - sysIP_UNICAST_IF = 0x32
31 -
32 - sysIP_MULTICAST_IF = 0x20
33 - sysIP_MULTICAST_TTL = 0x21
34 - sysIP_MULTICAST_LOOP = 0x22
35 - sysIP_ADD_MEMBERSHIP = 0x23
36 - sysIP_DROP_MEMBERSHIP = 0x24
37 - sysIP_UNBLOCK_SOURCE = 0x25
38 - sysIP_BLOCK_SOURCE = 0x26
39 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27
40 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28
41 - sysIP_MSFILTER = 0x29
42 - sysMCAST_JOIN_GROUP = 0x2a
43 - sysMCAST_LEAVE_GROUP = 0x2d
44 - sysMCAST_JOIN_SOURCE_GROUP = 0x2e
45 - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f
46 - sysMCAST_BLOCK_SOURCE = 0x2b
47 - sysMCAST_UNBLOCK_SOURCE = 0x2c
48 - sysMCAST_MSFILTER = 0x30
49 - sysIP_MULTICAST_ALL = 0x31
50 -
51 - sysICMP_FILTER = 0x1
52 -
53 - sysSO_EE_ORIGIN_NONE = 0x0
54 - sysSO_EE_ORIGIN_LOCAL = 0x1
55 - sysSO_EE_ORIGIN_ICMP = 0x2
56 - sysSO_EE_ORIGIN_ICMP6 = 0x3
57 - sysSO_EE_ORIGIN_TXSTATUS = 0x4
58 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
59 -
60 - sysSizeofKernelSockaddrStorage = 0x80
61 - sysSizeofSockaddrInet = 0x10
62 - sysSizeofInetPktinfo = 0xc
63 - sysSizeofSockExtendedErr = 0x10
64 -
65 - sysSizeofIPMreq = 0x8
66 - sysSizeofIPMreqn = 0xc
67 - sysSizeofIPMreqSource = 0xc
68 - sysSizeofGroupReq = 0x88
69 - sysSizeofGroupSourceReq = 0x108
70 -
71 - sysSizeofICMPFilter = 0x4
72 -)
73 -
74 -type sysKernelSockaddrStorage struct {
75 - Family uint16
76 - X__data [126]int8
77 -}
78 -
79 -type sysSockaddrInet struct {
80 - Family uint16
81 - Port uint16
82 - Addr [4]byte /* in_addr */
83 - X__pad [8]uint8
84 -}
85 -
86 -type sysInetPktinfo struct {
87 - Ifindex int32
88 - Spec_dst [4]byte /* in_addr */
89 - Addr [4]byte /* in_addr */
90 -}
91 -
92 -type sysSockExtendedErr struct {
93 - Errno uint32
94 - Origin uint8
95 - Type uint8
96 - Code uint8
97 - Pad uint8
98 - Info uint32
99 - Data uint32
100 -}
101 -
102 -type sysIPMreq struct {
103 - Multiaddr [4]byte /* in_addr */
104 - Interface [4]byte /* in_addr */
105 -}
106 -
107 -type sysIPMreqn struct {
108 - Multiaddr [4]byte /* in_addr */
109 - Address [4]byte /* in_addr */
110 - Ifindex int32
111 -}
112 -
113 -type sysIPMreqSource struct {
114 - Multiaddr uint32
115 - Interface uint32
116 - Sourceaddr uint32
117 -}
118 -
119 -type sysGroupReq struct {
120 - Interface uint32
121 - Pad_cgo_0 [4]byte
122 - Group sysKernelSockaddrStorage
123 -}
124 -
125 -type sysGroupSourceReq struct {
126 - Interface uint32
127 - Pad_cgo_0 [4]byte
128 - Group sysKernelSockaddrStorage
129 - Source sysKernelSockaddrStorage
130 -}
131 -
132 -type sysICMPFilter struct {
133 - Data uint32
134 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_linux_ppc64.go deleted
-134
@@ -1,134 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_linux.go
3 -
4 -// +build linux,ppc64
5 -
6 -package ipv4
7 -
8 -const (
9 - sysIP_TOS = 0x1
10 - sysIP_TTL = 0x2
11 - sysIP_HDRINCL = 0x3
12 - sysIP_OPTIONS = 0x4
13 - sysIP_ROUTER_ALERT = 0x5
14 - sysIP_RECVOPTS = 0x6
15 - sysIP_RETOPTS = 0x7
16 - sysIP_PKTINFO = 0x8
17 - sysIP_PKTOPTIONS = 0x9
18 - sysIP_MTU_DISCOVER = 0xa
19 - sysIP_RECVERR = 0xb
20 - sysIP_RECVTTL = 0xc
21 - sysIP_RECVTOS = 0xd
22 - sysIP_MTU = 0xe
23 - sysIP_FREEBIND = 0xf
24 - sysIP_TRANSPARENT = 0x13
25 - sysIP_RECVRETOPTS = 0x7
26 - sysIP_ORIGDSTADDR = 0x14
27 - sysIP_RECVORIGDSTADDR = 0x14
28 - sysIP_MINTTL = 0x15
29 - sysIP_NODEFRAG = 0x16
30 - sysIP_UNICAST_IF = 0x32
31 -
32 - sysIP_MULTICAST_IF = 0x20
33 - sysIP_MULTICAST_TTL = 0x21
34 - sysIP_MULTICAST_LOOP = 0x22
35 - sysIP_ADD_MEMBERSHIP = 0x23
36 - sysIP_DROP_MEMBERSHIP = 0x24
37 - sysIP_UNBLOCK_SOURCE = 0x25
38 - sysIP_BLOCK_SOURCE = 0x26
39 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27
40 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28
41 - sysIP_MSFILTER = 0x29
42 - sysMCAST_JOIN_GROUP = 0x2a
43 - sysMCAST_LEAVE_GROUP = 0x2d
44 - sysMCAST_JOIN_SOURCE_GROUP = 0x2e
45 - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f
46 - sysMCAST_BLOCK_SOURCE = 0x2b
47 - sysMCAST_UNBLOCK_SOURCE = 0x2c
48 - sysMCAST_MSFILTER = 0x30
49 - sysIP_MULTICAST_ALL = 0x31
50 -
51 - sysICMP_FILTER = 0x1
52 -
53 - sysSO_EE_ORIGIN_NONE = 0x0
54 - sysSO_EE_ORIGIN_LOCAL = 0x1
55 - sysSO_EE_ORIGIN_ICMP = 0x2
56 - sysSO_EE_ORIGIN_ICMP6 = 0x3
57 - sysSO_EE_ORIGIN_TXSTATUS = 0x4
58 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
59 -
60 - sysSizeofKernelSockaddrStorage = 0x80
61 - sysSizeofSockaddrInet = 0x10
62 - sysSizeofInetPktinfo = 0xc
63 - sysSizeofSockExtendedErr = 0x10
64 -
65 - sysSizeofIPMreq = 0x8
66 - sysSizeofIPMreqn = 0xc
67 - sysSizeofIPMreqSource = 0xc
68 - sysSizeofGroupReq = 0x88
69 - sysSizeofGroupSourceReq = 0x108
70 -
71 - sysSizeofICMPFilter = 0x4
72 -)
73 -
74 -type sysKernelSockaddrStorage struct {
75 - Family uint16
76 - X__data [126]int8
77 -}
78 -
79 -type sysSockaddrInet struct {
80 - Family uint16
81 - Port uint16
82 - Addr [4]byte /* in_addr */
83 - X__pad [8]uint8
84 -}
85 -
86 -type sysInetPktinfo struct {
87 - Ifindex int32
88 - Spec_dst [4]byte /* in_addr */
89 - Addr [4]byte /* in_addr */
90 -}
91 -
92 -type sysSockExtendedErr struct {
93 - Errno uint32
94 - Origin uint8
95 - Type uint8
96 - Code uint8
97 - Pad uint8
98 - Info uint32
99 - Data uint32
100 -}
101 -
102 -type sysIPMreq struct {
103 - Multiaddr [4]byte /* in_addr */
104 - Interface [4]byte /* in_addr */
105 -}
106 -
107 -type sysIPMreqn struct {
108 - Multiaddr [4]byte /* in_addr */
109 - Address [4]byte /* in_addr */
110 - Ifindex int32
111 -}
112 -
113 -type sysIPMreqSource struct {
114 - Multiaddr uint32
115 - Interface uint32
116 - Sourceaddr uint32
117 -}
118 -
119 -type sysGroupReq struct {
120 - Interface uint32
121 - Pad_cgo_0 [4]byte
122 - Group sysKernelSockaddrStorage
123 -}
124 -
125 -type sysGroupSourceReq struct {
126 - Interface uint32
127 - Pad_cgo_0 [4]byte
128 - Group sysKernelSockaddrStorage
129 - Source sysKernelSockaddrStorage
130 -}
131 -
132 -type sysICMPFilter struct {
133 - Data uint32
134 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_linux_ppc64le.go deleted
-134
@@ -1,134 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_linux.go
3 -
4 -// +build linux,ppc64le
5 -
6 -package ipv4
7 -
8 -const (
9 - sysIP_TOS = 0x1
10 - sysIP_TTL = 0x2
11 - sysIP_HDRINCL = 0x3
12 - sysIP_OPTIONS = 0x4
13 - sysIP_ROUTER_ALERT = 0x5
14 - sysIP_RECVOPTS = 0x6
15 - sysIP_RETOPTS = 0x7
16 - sysIP_PKTINFO = 0x8
17 - sysIP_PKTOPTIONS = 0x9
18 - sysIP_MTU_DISCOVER = 0xa
19 - sysIP_RECVERR = 0xb
20 - sysIP_RECVTTL = 0xc
21 - sysIP_RECVTOS = 0xd
22 - sysIP_MTU = 0xe
23 - sysIP_FREEBIND = 0xf
24 - sysIP_TRANSPARENT = 0x13
25 - sysIP_RECVRETOPTS = 0x7
26 - sysIP_ORIGDSTADDR = 0x14
27 - sysIP_RECVORIGDSTADDR = 0x14
28 - sysIP_MINTTL = 0x15
29 - sysIP_NODEFRAG = 0x16
30 - sysIP_UNICAST_IF = 0x32
31 -
32 - sysIP_MULTICAST_IF = 0x20
33 - sysIP_MULTICAST_TTL = 0x21
34 - sysIP_MULTICAST_LOOP = 0x22
35 - sysIP_ADD_MEMBERSHIP = 0x23
36 - sysIP_DROP_MEMBERSHIP = 0x24
37 - sysIP_UNBLOCK_SOURCE = 0x25
38 - sysIP_BLOCK_SOURCE = 0x26
39 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27
40 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28
41 - sysIP_MSFILTER = 0x29
42 - sysMCAST_JOIN_GROUP = 0x2a
43 - sysMCAST_LEAVE_GROUP = 0x2d
44 - sysMCAST_JOIN_SOURCE_GROUP = 0x2e
45 - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f
46 - sysMCAST_BLOCK_SOURCE = 0x2b
47 - sysMCAST_UNBLOCK_SOURCE = 0x2c
48 - sysMCAST_MSFILTER = 0x30
49 - sysIP_MULTICAST_ALL = 0x31
50 -
51 - sysICMP_FILTER = 0x1
52 -
53 - sysSO_EE_ORIGIN_NONE = 0x0
54 - sysSO_EE_ORIGIN_LOCAL = 0x1
55 - sysSO_EE_ORIGIN_ICMP = 0x2
56 - sysSO_EE_ORIGIN_ICMP6 = 0x3
57 - sysSO_EE_ORIGIN_TXSTATUS = 0x4
58 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4
59 -
60 - sysSizeofKernelSockaddrStorage = 0x80
61 - sysSizeofSockaddrInet = 0x10
62 - sysSizeofInetPktinfo = 0xc
63 - sysSizeofSockExtendedErr = 0x10
64 -
65 - sysSizeofIPMreq = 0x8
66 - sysSizeofIPMreqn = 0xc
67 - sysSizeofIPMreqSource = 0xc
68 - sysSizeofGroupReq = 0x88
69 - sysSizeofGroupSourceReq = 0x108
70 -
71 - sysSizeofICMPFilter = 0x4
72 -)
73 -
74 -type sysKernelSockaddrStorage struct {
75 - Family uint16
76 - X__data [126]int8
77 -}
78 -
79 -type sysSockaddrInet struct {
80 - Family uint16
81 - Port uint16
82 - Addr [4]byte /* in_addr */
83 - X__pad [8]uint8
84 -}
85 -
86 -type sysInetPktinfo struct {
87 - Ifindex int32
88 - Spec_dst [4]byte /* in_addr */
89 - Addr [4]byte /* in_addr */
90 -}
91 -
92 -type sysSockExtendedErr struct {
93 - Errno uint32
94 - Origin uint8
95 - Type uint8
96 - Code uint8
97 - Pad uint8
98 - Info uint32
99 - Data uint32
100 -}
101 -
102 -type sysIPMreq struct {
103 - Multiaddr [4]byte /* in_addr */
104 - Interface [4]byte /* in_addr */
105 -}
106 -
107 -type sysIPMreqn struct {
108 - Multiaddr [4]byte /* in_addr */
109 - Address [4]byte /* in_addr */
110 - Ifindex int32
111 -}
112 -
113 -type sysIPMreqSource struct {
114 - Multiaddr uint32
115 - Interface uint32
116 - Sourceaddr uint32
117 -}
118 -
119 -type sysGroupReq struct {
120 - Interface uint32
121 - Pad_cgo_0 [4]byte
122 - Group sysKernelSockaddrStorage
123 -}
124 -
125 -type sysGroupSourceReq struct {
126 - Interface uint32
127 - Pad_cgo_0 [4]byte
128 - Group sysKernelSockaddrStorage
129 - Source sysKernelSockaddrStorage
130 -}
131 -
132 -type sysICMPFilter struct {
133 - Data uint32
134 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_netbsd.go deleted
-30
@@ -1,30 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_netbsd.go
3 -
4 -package ipv4
5 -
6 -const (
7 - sysIP_OPTIONS = 0x1
8 - sysIP_HDRINCL = 0x2
9 - sysIP_TOS = 0x3
10 - sysIP_TTL = 0x4
11 - sysIP_RECVOPTS = 0x5
12 - sysIP_RECVRETOPTS = 0x6
13 - sysIP_RECVDSTADDR = 0x7
14 - sysIP_RETOPTS = 0x8
15 - sysIP_RECVIF = 0x14
16 - sysIP_RECVTTL = 0x17
17 -
18 - sysIP_MULTICAST_IF = 0x9
19 - sysIP_MULTICAST_TTL = 0xa
20 - sysIP_MULTICAST_LOOP = 0xb
21 - sysIP_ADD_MEMBERSHIP = 0xc
22 - sysIP_DROP_MEMBERSHIP = 0xd
23 -
24 - sysSizeofIPMreq = 0x8
25 -)
26 -
27 -type sysIPMreq struct {
28 - Multiaddr [4]byte /* in_addr */
29 - Interface [4]byte /* in_addr */
30 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_openbsd.go deleted
-30
@@ -1,30 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_openbsd.go
3 -
4 -package ipv4
5 -
6 -const (
7 - sysIP_OPTIONS = 0x1
8 - sysIP_HDRINCL = 0x2
9 - sysIP_TOS = 0x3
10 - sysIP_TTL = 0x4
11 - sysIP_RECVOPTS = 0x5
12 - sysIP_RECVRETOPTS = 0x6
13 - sysIP_RECVDSTADDR = 0x7
14 - sysIP_RETOPTS = 0x8
15 - sysIP_RECVIF = 0x1e
16 - sysIP_RECVTTL = 0x1f
17 -
18 - sysIP_MULTICAST_IF = 0x9
19 - sysIP_MULTICAST_TTL = 0xa
20 - sysIP_MULTICAST_LOOP = 0xb
21 - sysIP_ADD_MEMBERSHIP = 0xc
22 - sysIP_DROP_MEMBERSHIP = 0xd
23 -
24 - sysSizeofIPMreq = 0x8
25 -)
26 -
27 -type sysIPMreq struct {
28 - Multiaddr [4]byte /* in_addr */
29 - Interface [4]byte /* in_addr */
30 -}
Godeps/_workspace/src/golang.org/x/net/ipv4/zsys_solaris.go deleted
-60
@@ -1,60 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_solaris.go
3 -
4 -// +build solaris
5 -
6 -package ipv4
7 -
8 -const (
9 - sysIP_OPTIONS = 0x1
10 - sysIP_HDRINCL = 0x2
11 - sysIP_TOS = 0x3
12 - sysIP_TTL = 0x4
13 - sysIP_RECVOPTS = 0x5
14 - sysIP_RECVRETOPTS = 0x6
15 - sysIP_RECVDSTADDR = 0x7
16 - sysIP_RETOPTS = 0x8
17 - sysIP_RECVIF = 0x9
18 - sysIP_RECVSLLA = 0xa
19 - sysIP_RECVTTL = 0xb
20 - sysIP_NEXTHOP = 0x19
21 - sysIP_PKTINFO = 0x1a
22 - sysIP_RECVPKTINFO = 0x1a
23 - sysIP_DONTFRAG = 0x1b
24 - sysIP_BOUND_IF = 0x41
25 - sysIP_UNSPEC_SRC = 0x42
26 - sysIP_BROADCAST_TTL = 0x43
27 - sysIP_DHCPINIT_IF = 0x45
28 -
29 - sysIP_MULTICAST_IF = 0x10
30 - sysIP_MULTICAST_TTL = 0x11
31 - sysIP_MULTICAST_LOOP = 0x12
32 - sysIP_ADD_MEMBERSHIP = 0x13
33 - sysIP_DROP_MEMBERSHIP = 0x14
34 - sysIP_BLOCK_SOURCE = 0x15
35 - sysIP_UNBLOCK_SOURCE = 0x16
36 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x17
37 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x18
38 -
39 - sysSizeofInetPktinfo = 0xc
40 -
41 - sysSizeofIPMreq = 0x8
42 - sysSizeofIPMreqSource = 0xc
43 -)
44 -
45 -type sysInetPktinfo struct {
46 - Ifindex uint32
47 - Spec_dst [4]byte /* in_addr */
48 - Addr [4]byte /* in_addr */
49 -}
50 -
51 -type sysIPMreq struct {
52 - Multiaddr [4]byte /* in_addr */
53 - Interface [4]byte /* in_addr */
54 -}
55 -
56 -type sysIPMreqSource struct {
57 - Multiaddr [4]byte /* in_addr */
58 - Sourceaddr [4]byte /* in_addr */
59 - Interface [4]byte /* in_addr */
60 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/control.go deleted
-92
@@ -1,92 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import (
8 - "errors"
9 - "fmt"
10 - "net"
11 - "sync"
12 -)
13 -
14 -var (
15 - errMissingAddress = errors.New("missing address")
16 - errInvalidConnType = errors.New("invalid conn type")
17 - errNoSuchInterface = errors.New("no such interface")
18 -)
19 -
20 -// Note that RFC 3542 obsoletes RFC 2292 but OS X Snow Leopard and the
21 -// former still support RFC 2292 only. Please be aware that almost
22 -// all protocol implementations prohibit using a combination of RFC
23 -// 2292 and RFC 3542 for some practical reasons.
24 -
25 -type rawOpt struct {
26 - sync.RWMutex
27 - cflags ControlFlags
28 -}
29 -
30 -func (c *rawOpt) set(f ControlFlags) { c.cflags |= f }
31 -func (c *rawOpt) clear(f ControlFlags) { c.cflags &^= f }
32 -func (c *rawOpt) isset(f ControlFlags) bool { return c.cflags&f != 0 }
33 -
34 -// A ControlFlags represents per packet basis IP-level socket option
35 -// control flags.
36 -type ControlFlags uint
37 -
38 -const (
39 - FlagTrafficClass ControlFlags = 1 << iota // pass the traffic class on the received packet
40 - FlagHopLimit // pass the hop limit on the received packet
41 - FlagSrc // pass the source address on the received packet
42 - FlagDst // pass the destination address on the received packet
43 - FlagInterface // pass the interface index on the received packet
44 - FlagPathMTU // pass the path MTU on the received packet path
45 -)
46 -
47 -const flagPacketInfo = FlagDst | FlagInterface
48 -
49 -// A ControlMessage represents per packet basis IP-level socket
50 -// options.
51 -type ControlMessage struct {
52 - // Receiving socket options: SetControlMessage allows to
53 - // receive the options from the protocol stack using ReadFrom
54 - // method of PacketConn.
55 - //
56 - // Specifying socket options: ControlMessage for WriteTo
57 - // method of PacketConn allows to send the options to the
58 - // protocol stack.
59 - //
60 - TrafficClass int // traffic class, must be 1 <= value <= 255 when specifying
61 - HopLimit int // hop limit, must be 1 <= value <= 255 when specifying
62 - Src net.IP // source address, specifying only
63 - Dst net.IP // destination address, receiving only
64 - IfIndex int // interface index, must be 1 <= value when specifying
65 - NextHop net.IP // next hop address, specifying only
66 - MTU int // path MTU, receiving only
67 -}
68 -
69 -func (cm *ControlMessage) String() string {
70 - if cm == nil {
71 - return "<nil>"
72 - }
73 - return fmt.Sprintf("tclass: %#x, hoplim: %v, src: %v, dst: %v, ifindex: %v, nexthop: %v, mtu: %v", cm.TrafficClass, cm.HopLimit, cm.Src, cm.Dst, cm.IfIndex, cm.NextHop, cm.MTU)
74 -}
75 -
76 -// Ancillary data socket options
77 -const (
78 - ctlTrafficClass = iota // header field
79 - ctlHopLimit // header field
80 - ctlPacketInfo // inbound or outbound packet path
81 - ctlNextHop // nexthop
82 - ctlPathMTU // path mtu
83 - ctlMax
84 -)
85 -
86 -// A ctlOpt represents a binding for ancillary data socket option.
87 -type ctlOpt struct {
88 - name int // option name, must be equal or greater than 1
89 - length int // option length
90 - marshal func([]byte, *ControlMessage) []byte
91 - parse func(*ControlMessage, []byte)
92 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/control_rfc2292_unix.go deleted
-56
@@ -1,56 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin
6 -
7 -package ipv6
8 -
9 -import (
10 - "syscall"
11 - "unsafe"
12 -
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
14 -)
15 -
16 -func marshal2292HopLimit(b []byte, cm *ControlMessage) []byte {
17 - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
18 - m.Level = iana.ProtocolIPv6
19 - m.Type = sysIPV6_2292HOPLIMIT
20 - m.SetLen(syscall.CmsgLen(4))
21 - if cm != nil {
22 - data := b[syscall.CmsgLen(0):]
23 - // TODO(mikio): fix potential misaligned memory access
24 - *(*int32)(unsafe.Pointer(&data[:4][0])) = int32(cm.HopLimit)
25 - }
26 - return b[syscall.CmsgSpace(4):]
27 -}
28 -
29 -func marshal2292PacketInfo(b []byte, cm *ControlMessage) []byte {
30 - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
31 - m.Level = iana.ProtocolIPv6
32 - m.Type = sysIPV6_2292PKTINFO
33 - m.SetLen(syscall.CmsgLen(sysSizeofInet6Pktinfo))
34 - if cm != nil {
35 - pi := (*sysInet6Pktinfo)(unsafe.Pointer(&b[syscall.CmsgLen(0)]))
36 - if ip := cm.Src.To16(); ip != nil && ip.To4() == nil {
37 - copy(pi.Addr[:], ip)
38 - }
39 - if cm.IfIndex > 0 {
40 - pi.setIfindex(cm.IfIndex)
41 - }
42 - }
43 - return b[syscall.CmsgSpace(sysSizeofInet6Pktinfo):]
44 -}
45 -
46 -func marshal2292NextHop(b []byte, cm *ControlMessage) []byte {
47 - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
48 - m.Level = iana.ProtocolIPv6
49 - m.Type = sysIPV6_2292NEXTHOP
50 - m.SetLen(syscall.CmsgLen(sysSizeofSockaddrInet6))
51 - if cm != nil {
52 - sa := (*sysSockaddrInet6)(unsafe.Pointer(&b[syscall.CmsgLen(0)]))
53 - sa.setSockaddr(cm.NextHop, cm.IfIndex)
54 - }
55 - return b[syscall.CmsgSpace(sysSizeofSockaddrInet6):]
56 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/control_rfc3542_unix.go deleted
-103
@@ -1,103 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux netbsd openbsd
6 -
7 -package ipv6
8 -
9 -import (
10 - "syscall"
11 - "unsafe"
12 -
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
14 -)
15 -
16 -func marshalTrafficClass(b []byte, cm *ControlMessage) []byte {
17 - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
18 - m.Level = iana.ProtocolIPv6
19 - m.Type = sysIPV6_TCLASS
20 - m.SetLen(syscall.CmsgLen(4))
21 - if cm != nil {
22 - data := b[syscall.CmsgLen(0):]
23 - // TODO(mikio): fix potential misaligned memory access
24 - *(*int32)(unsafe.Pointer(&data[:4][0])) = int32(cm.TrafficClass)
25 - }
26 - return b[syscall.CmsgSpace(4):]
27 -}
28 -
29 -func parseTrafficClass(cm *ControlMessage, b []byte) {
30 - // TODO(mikio): fix potential misaligned memory access
31 - cm.TrafficClass = int(*(*int32)(unsafe.Pointer(&b[:4][0])))
32 -}
33 -
34 -func marshalHopLimit(b []byte, cm *ControlMessage) []byte {
35 - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
36 - m.Level = iana.ProtocolIPv6
37 - m.Type = sysIPV6_HOPLIMIT
38 - m.SetLen(syscall.CmsgLen(4))
39 - if cm != nil {
40 - data := b[syscall.CmsgLen(0):]
41 - // TODO(mikio): fix potential misaligned memory access
42 - *(*int32)(unsafe.Pointer(&data[:4][0])) = int32(cm.HopLimit)
43 - }
44 - return b[syscall.CmsgSpace(4):]
45 -}
46 -
47 -func parseHopLimit(cm *ControlMessage, b []byte) {
48 - // TODO(mikio): fix potential misaligned memory access
49 - cm.HopLimit = int(*(*int32)(unsafe.Pointer(&b[:4][0])))
50 -}
51 -
52 -func marshalPacketInfo(b []byte, cm *ControlMessage) []byte {
53 - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
54 - m.Level = iana.ProtocolIPv6
55 - m.Type = sysIPV6_PKTINFO
56 - m.SetLen(syscall.CmsgLen(sysSizeofInet6Pktinfo))
57 - if cm != nil {
58 - pi := (*sysInet6Pktinfo)(unsafe.Pointer(&b[syscall.CmsgLen(0)]))
59 - if ip := cm.Src.To16(); ip != nil && ip.To4() == nil {
60 - copy(pi.Addr[:], ip)
61 - }
62 - if cm.IfIndex > 0 {
63 - pi.setIfindex(cm.IfIndex)
64 - }
65 - }
66 - return b[syscall.CmsgSpace(sysSizeofInet6Pktinfo):]
67 -}
68 -
69 -func parsePacketInfo(cm *ControlMessage, b []byte) {
70 - pi := (*sysInet6Pktinfo)(unsafe.Pointer(&b[0]))
71 - cm.Dst = pi.Addr[:]
72 - cm.IfIndex = int(pi.Ifindex)
73 -}
74 -
75 -func marshalNextHop(b []byte, cm *ControlMessage) []byte {
76 - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
77 - m.Level = iana.ProtocolIPv6
78 - m.Type = sysIPV6_NEXTHOP
79 - m.SetLen(syscall.CmsgLen(sysSizeofSockaddrInet6))
80 - if cm != nil {
81 - sa := (*sysSockaddrInet6)(unsafe.Pointer(&b[syscall.CmsgLen(0)]))
82 - sa.setSockaddr(cm.NextHop, cm.IfIndex)
83 - }
84 - return b[syscall.CmsgSpace(sysSizeofSockaddrInet6):]
85 -}
86 -
87 -func parseNextHop(cm *ControlMessage, b []byte) {
88 -}
89 -
90 -func marshalPathMTU(b []byte, cm *ControlMessage) []byte {
91 - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0]))
92 - m.Level = iana.ProtocolIPv6
93 - m.Type = sysIPV6_PATHMTU
94 - m.SetLen(syscall.CmsgLen(sysSizeofIPv6Mtuinfo))
95 - return b[syscall.CmsgSpace(sysSizeofIPv6Mtuinfo):]
96 -}
97 -
98 -func parsePathMTU(cm *ControlMessage, b []byte) {
99 - mi := (*sysIPv6Mtuinfo)(unsafe.Pointer(&b[0]))
100 - cm.Dst = mi.Addr.Addr[:]
101 - cm.IfIndex = int(mi.Addr.Scope_id)
102 - cm.MTU = int(mi.Mtu)
103 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/control_stub.go deleted
-23
@@ -1,23 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9 solaris
6 -
7 -package ipv6
8 -
9 -func setControlMessage(fd int, opt *rawOpt, cf ControlFlags, on bool) error {
10 - return errOpNoSupport
11 -}
12 -
13 -func newControlMessage(opt *rawOpt) (oob []byte) {
14 - return nil
15 -}
16 -
17 -func parseControlMessage(b []byte) (*ControlMessage, error) {
18 - return nil, errOpNoSupport
19 -}
20 -
21 -func marshalControlMessage(cm *ControlMessage) (oob []byte) {
22 - return nil
23 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/control_unix.go deleted
-166
@@ -1,166 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux netbsd openbsd
6 -
7 -package ipv6
8 -
9 -import (
10 - "os"
11 - "syscall"
12 -
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
14 -)
15 -
16 -func setControlMessage(fd int, opt *rawOpt, cf ControlFlags, on bool) error {
17 - opt.Lock()
18 - defer opt.Unlock()
19 - if cf&FlagTrafficClass != 0 && sockOpts[ssoReceiveTrafficClass].name > 0 {
20 - if err := setInt(fd, &sockOpts[ssoReceiveTrafficClass], boolint(on)); err != nil {
21 - return err
22 - }
23 - if on {
24 - opt.set(FlagTrafficClass)
25 - } else {
26 - opt.clear(FlagTrafficClass)
27 - }
28 - }
29 - if cf&FlagHopLimit != 0 && sockOpts[ssoReceiveHopLimit].name > 0 {
30 - if err := setInt(fd, &sockOpts[ssoReceiveHopLimit], boolint(on)); err != nil {
31 - return err
32 - }
33 - if on {
34 - opt.set(FlagHopLimit)
35 - } else {
36 - opt.clear(FlagHopLimit)
37 - }
38 - }
39 - if cf&flagPacketInfo != 0 && sockOpts[ssoReceivePacketInfo].name > 0 {
40 - if err := setInt(fd, &sockOpts[ssoReceivePacketInfo], boolint(on)); err != nil {
41 - return err
42 - }
43 - if on {
44 - opt.set(cf & flagPacketInfo)
45 - } else {
46 - opt.clear(cf & flagPacketInfo)
47 - }
48 - }
49 - if cf&FlagPathMTU != 0 && sockOpts[ssoReceivePathMTU].name > 0 {
50 - if err := setInt(fd, &sockOpts[ssoReceivePathMTU], boolint(on)); err != nil {
51 - return err
52 - }
53 - if on {
54 - opt.set(FlagPathMTU)
55 - } else {
56 - opt.clear(FlagPathMTU)
57 - }
58 - }
59 - return nil
60 -}
61 -
62 -func newControlMessage(opt *rawOpt) (oob []byte) {
63 - opt.RLock()
64 - var l int
65 - if opt.isset(FlagTrafficClass) && ctlOpts[ctlTrafficClass].name > 0 {
66 - l += syscall.CmsgSpace(ctlOpts[ctlTrafficClass].length)
67 - }
68 - if opt.isset(FlagHopLimit) && ctlOpts[ctlHopLimit].name > 0 {
69 - l += syscall.CmsgSpace(ctlOpts[ctlHopLimit].length)
70 - }
71 - if opt.isset(flagPacketInfo) && ctlOpts[ctlPacketInfo].name > 0 {
72 - l += syscall.CmsgSpace(ctlOpts[ctlPacketInfo].length)
73 - }
74 - if opt.isset(FlagPathMTU) && ctlOpts[ctlPathMTU].name > 0 {
75 - l += syscall.CmsgSpace(ctlOpts[ctlPathMTU].length)
76 - }
77 - if l > 0 {
78 - oob = make([]byte, l)
79 - b := oob
80 - if opt.isset(FlagTrafficClass) && ctlOpts[ctlTrafficClass].name > 0 {
81 - b = ctlOpts[ctlTrafficClass].marshal(b, nil)
82 - }
83 - if opt.isset(FlagHopLimit) && ctlOpts[ctlHopLimit].name > 0 {
84 - b = ctlOpts[ctlHopLimit].marshal(b, nil)
85 - }
86 - if opt.isset(flagPacketInfo) && ctlOpts[ctlPacketInfo].name > 0 {
87 - b = ctlOpts[ctlPacketInfo].marshal(b, nil)
88 - }
89 - if opt.isset(FlagPathMTU) && ctlOpts[ctlPathMTU].name > 0 {
90 - b = ctlOpts[ctlPathMTU].marshal(b, nil)
91 - }
92 - }
93 - opt.RUnlock()
94 - return
95 -}
96 -
97 -func parseControlMessage(b []byte) (*ControlMessage, error) {
98 - if len(b) == 0 {
99 - return nil, nil
100 - }
101 - cmsgs, err := syscall.ParseSocketControlMessage(b)
102 - if err != nil {
103 - return nil, os.NewSyscallError("parse socket control message", err)
104 - }
105 - cm := &ControlMessage{}
106 - for _, m := range cmsgs {
107 - if m.Header.Level != iana.ProtocolIPv6 {
108 - continue
109 - }
110 - switch int(m.Header.Type) {
111 - case ctlOpts[ctlTrafficClass].name:
112 - ctlOpts[ctlTrafficClass].parse(cm, m.Data[:])
113 - case ctlOpts[ctlHopLimit].name:
114 - ctlOpts[ctlHopLimit].parse(cm, m.Data[:])
115 - case ctlOpts[ctlPacketInfo].name:
116 - ctlOpts[ctlPacketInfo].parse(cm, m.Data[:])
117 - case ctlOpts[ctlPathMTU].name:
118 - ctlOpts[ctlPathMTU].parse(cm, m.Data[:])
119 - }
120 - }
121 - return cm, nil
122 -}
123 -
124 -func marshalControlMessage(cm *ControlMessage) (oob []byte) {
125 - if cm == nil {
126 - return
127 - }
128 - var l int
129 - tclass := false
130 - if ctlOpts[ctlTrafficClass].name > 0 && cm.TrafficClass > 0 {
131 - tclass = true
132 - l += syscall.CmsgSpace(ctlOpts[ctlTrafficClass].length)
133 - }
134 - hoplimit := false
135 - if ctlOpts[ctlHopLimit].name > 0 && cm.HopLimit > 0 {
136 - hoplimit = true
137 - l += syscall.CmsgSpace(ctlOpts[ctlHopLimit].length)
138 - }
139 - pktinfo := false
140 - if ctlOpts[ctlPacketInfo].name > 0 && (cm.Src.To16() != nil && cm.Src.To4() == nil || cm.IfIndex > 0) {
141 - pktinfo = true
142 - l += syscall.CmsgSpace(ctlOpts[ctlPacketInfo].length)
143 - }
144 - nexthop := false
145 - if ctlOpts[ctlNextHop].name > 0 && cm.NextHop.To16() != nil && cm.NextHop.To4() == nil {
146 - nexthop = true
147 - l += syscall.CmsgSpace(ctlOpts[ctlNextHop].length)
148 - }
149 - if l > 0 {
150 - oob = make([]byte, l)
151 - b := oob
152 - if tclass {
153 - b = ctlOpts[ctlTrafficClass].marshal(b, cm)
154 - }
155 - if hoplimit {
156 - b = ctlOpts[ctlHopLimit].marshal(b, cm)
157 - }
158 - if pktinfo {
159 - b = ctlOpts[ctlPacketInfo].marshal(b, cm)
160 - }
161 - if nexthop {
162 - b = ctlOpts[ctlNextHop].marshal(b, cm)
163 - }
164 - }
165 - return
166 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/control_windows.go deleted
-27
@@ -1,27 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import "syscall"
8 -
9 -func setControlMessage(fd syscall.Handle, opt *rawOpt, cf ControlFlags, on bool) error {
10 - // TODO(mikio): implement this
11 - return syscall.EWINDOWS
12 -}
13 -
14 -func newControlMessage(opt *rawOpt) (oob []byte) {
15 - // TODO(mikio): implement this
16 - return nil
17 -}
18 -
19 -func parseControlMessage(b []byte) (*ControlMessage, error) {
20 - // TODO(mikio): implement this
21 - return nil, syscall.EWINDOWS
22 -}
23 -
24 -func marshalControlMessage(cm *ControlMessage) (oob []byte) {
25 - // TODO(mikio): implement this
26 - return nil
27 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/defs_darwin.go deleted
-112
@@ -1,112 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in6_addr [16]byte /* in6_addr */
8 -
9 -package ipv6
10 -
11 -/*
12 -#define __APPLE_USE_RFC_3542
13 -#include <netinet/in.h>
14 -#include <netinet/icmp6.h>
15 -*/
16 -import "C"
17 -
18 -const (
19 - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS
20 - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF
21 - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS
22 - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP
23 - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP
24 - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP
25 -
26 - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE
27 - sysICMP6_FILTER = C.ICMP6_FILTER
28 - sysIPV6_2292PKTINFO = C.IPV6_2292PKTINFO
29 - sysIPV6_2292HOPLIMIT = C.IPV6_2292HOPLIMIT
30 - sysIPV6_2292NEXTHOP = C.IPV6_2292NEXTHOP
31 - sysIPV6_2292HOPOPTS = C.IPV6_2292HOPOPTS
32 - sysIPV6_2292DSTOPTS = C.IPV6_2292DSTOPTS
33 - sysIPV6_2292RTHDR = C.IPV6_2292RTHDR
34 -
35 - sysIPV6_2292PKTOPTIONS = C.IPV6_2292PKTOPTIONS
36 -
37 - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM
38 - sysIPV6_V6ONLY = C.IPV6_V6ONLY
39 -
40 - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY
41 -
42 - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS
43 - sysIPV6_TCLASS = C.IPV6_TCLASS
44 -
45 - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS
46 -
47 - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO
48 -
49 - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT
50 - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR
51 - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS
52 - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS
53 -
54 - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU
55 - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU
56 -
57 - sysIPV6_PATHMTU = C.IPV6_PATHMTU
58 -
59 - sysIPV6_PKTINFO = C.IPV6_PKTINFO
60 - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT
61 - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP
62 - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS
63 - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS
64 - sysIPV6_RTHDR = C.IPV6_RTHDR
65 -
66 - sysIPV6_AUTOFLOWLABEL = C.IPV6_AUTOFLOWLABEL
67 -
68 - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG
69 -
70 - sysIPV6_PREFER_TEMPADDR = C.IPV6_PREFER_TEMPADDR
71 -
72 - sysIPV6_MSFILTER = C.IPV6_MSFILTER
73 - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP
74 - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP
75 - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP
76 - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP
77 - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE
78 - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE
79 -
80 - sysIPV6_BOUND_IF = C.IPV6_BOUND_IF
81 -
82 - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT
83 - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH
84 - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW
85 -
86 - sysSizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage
87 - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
88 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
89 - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo
90 -
91 - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
92 - sysSizeofGroupReq = C.sizeof_struct_group_req
93 - sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req
94 -
95 - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
96 -)
97 -
98 -type sysSockaddrStorage C.struct_sockaddr_storage
99 -
100 -type sysSockaddrInet6 C.struct_sockaddr_in6
101 -
102 -type sysInet6Pktinfo C.struct_in6_pktinfo
103 -
104 -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo
105 -
106 -type sysIPv6Mreq C.struct_ipv6_mreq
107 -
108 -type sysICMPv6Filter C.struct_icmp6_filter
109 -
110 -type sysGroupReq C.struct_group_req
111 -
112 -type sysGroupSourceReq C.struct_group_source_req
Godeps/_workspace/src/golang.org/x/net/ipv6/defs_dragonfly.go deleted
-84
@@ -1,84 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in6_addr [16]byte /* in6_addr */
8 -
9 -package ipv6
10 -
11 -/*
12 -#include <sys/param.h>
13 -#include <sys/socket.h>
14 -
15 -#include <netinet/in.h>
16 -#include <netinet/icmp6.h>
17 -*/
18 -import "C"
19 -
20 -const (
21 - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS
22 - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF
23 - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS
24 - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP
25 - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP
26 - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP
27 - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE
28 - sysICMP6_FILTER = C.ICMP6_FILTER
29 -
30 - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM
31 - sysIPV6_V6ONLY = C.IPV6_V6ONLY
32 -
33 - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY
34 -
35 - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS
36 - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO
37 - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT
38 - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR
39 - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS
40 - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS
41 -
42 - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU
43 - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU
44 -
45 - sysIPV6_PATHMTU = C.IPV6_PATHMTU
46 -
47 - sysIPV6_PKTINFO = C.IPV6_PKTINFO
48 - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT
49 - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP
50 - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS
51 - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS
52 - sysIPV6_RTHDR = C.IPV6_RTHDR
53 -
54 - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS
55 -
56 - sysIPV6_AUTOFLOWLABEL = C.IPV6_AUTOFLOWLABEL
57 -
58 - sysIPV6_TCLASS = C.IPV6_TCLASS
59 - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG
60 -
61 - sysIPV6_PREFER_TEMPADDR = C.IPV6_PREFER_TEMPADDR
62 -
63 - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT
64 - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH
65 - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW
66 -
67 - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
68 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
69 - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo
70 -
71 - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
72 -
73 - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
74 -)
75 -
76 -type sysSockaddrInet6 C.struct_sockaddr_in6
77 -
78 -type sysInet6Pktinfo C.struct_in6_pktinfo
79 -
80 -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo
81 -
82 -type sysIPv6Mreq C.struct_ipv6_mreq
83 -
84 -type sysICMPv6Filter C.struct_icmp6_filter
Godeps/_workspace/src/golang.org/x/net/ipv6/defs_freebsd.go deleted
-105
@@ -1,105 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in6_addr [16]byte /* in6_addr */
8 -
9 -package ipv6
10 -
11 -/*
12 -#include <sys/param.h>
13 -#include <sys/socket.h>
14 -
15 -#include <netinet/in.h>
16 -#include <netinet/icmp6.h>
17 -*/
18 -import "C"
19 -
20 -const (
21 - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS
22 - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF
23 - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS
24 - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP
25 - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP
26 - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP
27 - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE
28 - sysICMP6_FILTER = C.ICMP6_FILTER
29 -
30 - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM
31 - sysIPV6_V6ONLY = C.IPV6_V6ONLY
32 -
33 - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY
34 -
35 - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS
36 -
37 - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO
38 - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT
39 - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR
40 - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS
41 - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS
42 -
43 - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU
44 - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU
45 -
46 - sysIPV6_PATHMTU = C.IPV6_PATHMTU
47 -
48 - sysIPV6_PKTINFO = C.IPV6_PKTINFO
49 - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT
50 - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP
51 - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS
52 - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS
53 - sysIPV6_RTHDR = C.IPV6_RTHDR
54 -
55 - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS
56 -
57 - sysIPV6_AUTOFLOWLABEL = C.IPV6_AUTOFLOWLABEL
58 -
59 - sysIPV6_TCLASS = C.IPV6_TCLASS
60 - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG
61 -
62 - sysIPV6_PREFER_TEMPADDR = C.IPV6_PREFER_TEMPADDR
63 -
64 - sysIPV6_BINDANY = C.IPV6_BINDANY
65 -
66 - sysIPV6_MSFILTER = C.IPV6_MSFILTER
67 -
68 - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP
69 - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP
70 - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP
71 - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP
72 - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE
73 - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE
74 -
75 - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT
76 - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH
77 - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW
78 -
79 - sysSizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage
80 - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
81 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
82 - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo
83 -
84 - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
85 - sysSizeofGroupReq = C.sizeof_struct_group_req
86 - sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req
87 -
88 - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
89 -)
90 -
91 -type sysSockaddrStorage C.struct_sockaddr_storage
92 -
93 -type sysSockaddrInet6 C.struct_sockaddr_in6
94 -
95 -type sysInet6Pktinfo C.struct_in6_pktinfo
96 -
97 -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo
98 -
99 -type sysIPv6Mreq C.struct_ipv6_mreq
100 -
101 -type sysGroupReq C.struct_group_req
102 -
103 -type sysGroupSourceReq C.struct_group_source_req
104 -
105 -type sysICMPv6Filter C.struct_icmp6_filter
Godeps/_workspace/src/golang.org/x/net/ipv6/defs_linux.go deleted
-136
@@ -1,136 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in6_addr [16]byte /* in6_addr */
8 -
9 -package ipv6
10 -
11 -/*
12 -#include <linux/in.h>
13 -#include <linux/in6.h>
14 -#include <linux/ipv6.h>
15 -#include <linux/icmpv6.h>
16 -*/
17 -import "C"
18 -
19 -const (
20 - sysIPV6_ADDRFORM = C.IPV6_ADDRFORM
21 - sysIPV6_2292PKTINFO = C.IPV6_2292PKTINFO
22 - sysIPV6_2292HOPOPTS = C.IPV6_2292HOPOPTS
23 - sysIPV6_2292DSTOPTS = C.IPV6_2292DSTOPTS
24 - sysIPV6_2292RTHDR = C.IPV6_2292RTHDR
25 - sysIPV6_2292PKTOPTIONS = C.IPV6_2292PKTOPTIONS
26 - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM
27 - sysIPV6_2292HOPLIMIT = C.IPV6_2292HOPLIMIT
28 - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP
29 - sysIPV6_FLOWINFO = C.IPV6_FLOWINFO
30 -
31 - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS
32 - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF
33 - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS
34 - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP
35 - sysIPV6_ADD_MEMBERSHIP = C.IPV6_ADD_MEMBERSHIP
36 - sysIPV6_DROP_MEMBERSHIP = C.IPV6_DROP_MEMBERSHIP
37 - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP
38 - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP
39 - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP
40 - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP
41 - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE
42 - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE
43 - sysMCAST_MSFILTER = C.MCAST_MSFILTER
44 - sysIPV6_ROUTER_ALERT = C.IPV6_ROUTER_ALERT
45 - sysIPV6_MTU_DISCOVER = C.IPV6_MTU_DISCOVER
46 - sysIPV6_MTU = C.IPV6_MTU
47 - sysIPV6_RECVERR = C.IPV6_RECVERR
48 - sysIPV6_V6ONLY = C.IPV6_V6ONLY
49 - sysIPV6_JOIN_ANYCAST = C.IPV6_JOIN_ANYCAST
50 - sysIPV6_LEAVE_ANYCAST = C.IPV6_LEAVE_ANYCAST
51 -
52 - //sysIPV6_PMTUDISC_DONT = C.IPV6_PMTUDISC_DONT
53 - //sysIPV6_PMTUDISC_WANT = C.IPV6_PMTUDISC_WANT
54 - //sysIPV6_PMTUDISC_DO = C.IPV6_PMTUDISC_DO
55 - //sysIPV6_PMTUDISC_PROBE = C.IPV6_PMTUDISC_PROBE
56 - //sysIPV6_PMTUDISC_INTERFACE = C.IPV6_PMTUDISC_INTERFACE
57 - //sysIPV6_PMTUDISC_OMIT = C.IPV6_PMTUDISC_OMIT
58 -
59 - sysIPV6_FLOWLABEL_MGR = C.IPV6_FLOWLABEL_MGR
60 - sysIPV6_FLOWINFO_SEND = C.IPV6_FLOWINFO_SEND
61 -
62 - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY
63 - sysIPV6_XFRM_POLICY = C.IPV6_XFRM_POLICY
64 -
65 - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO
66 - sysIPV6_PKTINFO = C.IPV6_PKTINFO
67 - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT
68 - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT
69 - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS
70 - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS
71 - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS
72 - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR
73 - sysIPV6_RTHDR = C.IPV6_RTHDR
74 - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS
75 - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS
76 - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU
77 - sysIPV6_PATHMTU = C.IPV6_PATHMTU
78 - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG
79 -
80 - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS
81 - sysIPV6_TCLASS = C.IPV6_TCLASS
82 -
83 - sysIPV6_ADDR_PREFERENCES = C.IPV6_ADDR_PREFERENCES
84 -
85 - sysIPV6_PREFER_SRC_TMP = C.IPV6_PREFER_SRC_TMP
86 - sysIPV6_PREFER_SRC_PUBLIC = C.IPV6_PREFER_SRC_PUBLIC
87 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = C.IPV6_PREFER_SRC_PUBTMP_DEFAULT
88 - sysIPV6_PREFER_SRC_COA = C.IPV6_PREFER_SRC_COA
89 - sysIPV6_PREFER_SRC_HOME = C.IPV6_PREFER_SRC_HOME
90 - sysIPV6_PREFER_SRC_CGA = C.IPV6_PREFER_SRC_CGA
91 - sysIPV6_PREFER_SRC_NONCGA = C.IPV6_PREFER_SRC_NONCGA
92 -
93 - sysIPV6_MINHOPCOUNT = C.IPV6_MINHOPCOUNT
94 -
95 - sysIPV6_ORIGDSTADDR = C.IPV6_ORIGDSTADDR
96 - sysIPV6_RECVORIGDSTADDR = C.IPV6_RECVORIGDSTADDR
97 - sysIPV6_TRANSPARENT = C.IPV6_TRANSPARENT
98 - sysIPV6_UNICAST_IF = C.IPV6_UNICAST_IF
99 -
100 - sysICMPV6_FILTER = C.ICMPV6_FILTER
101 -
102 - sysICMPV6_FILTER_BLOCK = C.ICMPV6_FILTER_BLOCK
103 - sysICMPV6_FILTER_PASS = C.ICMPV6_FILTER_PASS
104 - sysICMPV6_FILTER_BLOCKOTHERS = C.ICMPV6_FILTER_BLOCKOTHERS
105 - sysICMPV6_FILTER_PASSONLY = C.ICMPV6_FILTER_PASSONLY
106 -
107 - sysSizeofKernelSockaddrStorage = C.sizeof_struct___kernel_sockaddr_storage
108 - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
109 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
110 - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo
111 - sysSizeofIPv6FlowlabelReq = C.sizeof_struct_in6_flowlabel_req
112 -
113 - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
114 - sysSizeofGroupReq = C.sizeof_struct_group_req
115 - sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req
116 -
117 - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
118 -)
119 -
120 -type sysKernelSockaddrStorage C.struct___kernel_sockaddr_storage
121 -
122 -type sysSockaddrInet6 C.struct_sockaddr_in6
123 -
124 -type sysInet6Pktinfo C.struct_in6_pktinfo
125 -
126 -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo
127 -
128 -type sysIPv6FlowlabelReq C.struct_in6_flowlabel_req
129 -
130 -type sysIPv6Mreq C.struct_ipv6_mreq
131 -
132 -type sysGroupReq C.struct_group_req
133 -
134 -type sysGroupSourceReq C.struct_group_source_req
135 -
136 -type sysICMPv6Filter C.struct_icmp6_filter
Godeps/_workspace/src/golang.org/x/net/ipv6/defs_netbsd.go deleted
-80
@@ -1,80 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in6_addr [16]byte /* in6_addr */
8 -
9 -package ipv6
10 -
11 -/*
12 -#include <sys/param.h>
13 -#include <sys/socket.h>
14 -
15 -#include <netinet/in.h>
16 -#include <netinet/icmp6.h>
17 -*/
18 -import "C"
19 -
20 -const (
21 - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS
22 - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF
23 - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS
24 - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP
25 - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP
26 - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP
27 - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE
28 - sysICMP6_FILTER = C.ICMP6_FILTER
29 -
30 - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM
31 - sysIPV6_V6ONLY = C.IPV6_V6ONLY
32 -
33 - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY
34 -
35 - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS
36 -
37 - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO
38 - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT
39 - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR
40 - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS
41 - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS
42 -
43 - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU
44 - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU
45 - sysIPV6_PATHMTU = C.IPV6_PATHMTU
46 -
47 - sysIPV6_PKTINFO = C.IPV6_PKTINFO
48 - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT
49 - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP
50 - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS
51 - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS
52 - sysIPV6_RTHDR = C.IPV6_RTHDR
53 -
54 - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS
55 -
56 - sysIPV6_TCLASS = C.IPV6_TCLASS
57 - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG
58 -
59 - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT
60 - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH
61 - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW
62 -
63 - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
64 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
65 - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo
66 -
67 - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
68 -
69 - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
70 -)
71 -
72 -type sysSockaddrInet6 C.struct_sockaddr_in6
73 -
74 -type sysInet6Pktinfo C.struct_in6_pktinfo
75 -
76 -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo
77 -
78 -type sysIPv6Mreq C.struct_ipv6_mreq
79 -
80 -type sysICMPv6Filter C.struct_icmp6_filter
Godeps/_workspace/src/golang.org/x/net/ipv6/defs_openbsd.go deleted
-89
@@ -1,89 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in6_addr [16]byte /* in6_addr */
8 -
9 -package ipv6
10 -
11 -/*
12 -#include <sys/param.h>
13 -#include <sys/socket.h>
14 -
15 -#include <netinet/in.h>
16 -#include <netinet/icmp6.h>
17 -*/
18 -import "C"
19 -
20 -const (
21 - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS
22 - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF
23 - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS
24 - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP
25 - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP
26 - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP
27 - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE
28 - sysICMP6_FILTER = C.ICMP6_FILTER
29 -
30 - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM
31 - sysIPV6_V6ONLY = C.IPV6_V6ONLY
32 -
33 - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS
34 -
35 - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO
36 - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT
37 - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR
38 - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS
39 - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS
40 -
41 - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU
42 - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU
43 -
44 - sysIPV6_PATHMTU = C.IPV6_PATHMTU
45 -
46 - sysIPV6_PKTINFO = C.IPV6_PKTINFO
47 - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT
48 - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP
49 - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS
50 - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS
51 - sysIPV6_RTHDR = C.IPV6_RTHDR
52 -
53 - sysIPV6_AUTH_LEVEL = C.IPV6_AUTH_LEVEL
54 - sysIPV6_ESP_TRANS_LEVEL = C.IPV6_ESP_TRANS_LEVEL
55 - sysIPV6_ESP_NETWORK_LEVEL = C.IPV6_ESP_NETWORK_LEVEL
56 - sysIPSEC6_OUTSA = C.IPSEC6_OUTSA
57 - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS
58 -
59 - sysIPV6_AUTOFLOWLABEL = C.IPV6_AUTOFLOWLABEL
60 - sysIPV6_IPCOMP_LEVEL = C.IPV6_IPCOMP_LEVEL
61 -
62 - sysIPV6_TCLASS = C.IPV6_TCLASS
63 - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG
64 - sysIPV6_PIPEX = C.IPV6_PIPEX
65 -
66 - sysIPV6_RTABLE = C.IPV6_RTABLE
67 -
68 - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT
69 - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH
70 - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW
71 -
72 - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
73 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
74 - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo
75 -
76 - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
77 -
78 - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
79 -)
80 -
81 -type sysSockaddrInet6 C.struct_sockaddr_in6
82 -
83 -type sysInet6Pktinfo C.struct_in6_pktinfo
84 -
85 -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo
86 -
87 -type sysIPv6Mreq C.struct_ipv6_mreq
88 -
89 -type sysICMPv6Filter C.struct_icmp6_filter
Godeps/_workspace/src/golang.org/x/net/ipv6/defs_solaris.go deleted
-96
@@ -1,96 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -// +godefs map struct_in6_addr [16]byte /* in6_addr */
8 -
9 -package ipv6
10 -
11 -/*
12 -#include <netinet/in.h>
13 -#include <netinet/icmp6.h>
14 -*/
15 -import "C"
16 -
17 -const (
18 - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS
19 - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF
20 - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS
21 - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP
22 - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP
23 - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP
24 -
25 - sysIPV6_PKTINFO = C.IPV6_PKTINFO
26 -
27 - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT
28 - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP
29 - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS
30 - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS
31 -
32 - sysIPV6_RTHDR = C.IPV6_RTHDR
33 - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS
34 -
35 - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO
36 - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT
37 - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS
38 -
39 - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR
40 -
41 - sysIPV6_RECVRTHDRDSTOPTS = C.IPV6_RECVRTHDRDSTOPTS
42 -
43 - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM
44 - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS
45 - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU
46 - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG
47 - sysIPV6_SEC_OPT = C.IPV6_SEC_OPT
48 - sysIPV6_SRC_PREFERENCES = C.IPV6_SRC_PREFERENCES
49 - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU
50 - sysIPV6_PATHMTU = C.IPV6_PATHMTU
51 - sysIPV6_TCLASS = C.IPV6_TCLASS
52 - sysIPV6_V6ONLY = C.IPV6_V6ONLY
53 -
54 - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS
55 -
56 - sysIPV6_PREFER_SRC_HOME = C.IPV6_PREFER_SRC_HOME
57 - sysIPV6_PREFER_SRC_COA = C.IPV6_PREFER_SRC_COA
58 - sysIPV6_PREFER_SRC_PUBLIC = C.IPV6_PREFER_SRC_PUBLIC
59 - sysIPV6_PREFER_SRC_TMP = C.IPV6_PREFER_SRC_TMP
60 - sysIPV6_PREFER_SRC_NONCGA = C.IPV6_PREFER_SRC_NONCGA
61 - sysIPV6_PREFER_SRC_CGA = C.IPV6_PREFER_SRC_CGA
62 -
63 - sysIPV6_PREFER_SRC_MIPMASK = C.IPV6_PREFER_SRC_MIPMASK
64 - sysIPV6_PREFER_SRC_MIPDEFAULT = C.IPV6_PREFER_SRC_MIPDEFAULT
65 - sysIPV6_PREFER_SRC_TMPMASK = C.IPV6_PREFER_SRC_TMPMASK
66 - sysIPV6_PREFER_SRC_TMPDEFAULT = C.IPV6_PREFER_SRC_TMPDEFAULT
67 - sysIPV6_PREFER_SRC_CGAMASK = C.IPV6_PREFER_SRC_CGAMASK
68 - sysIPV6_PREFER_SRC_CGADEFAULT = C.IPV6_PREFER_SRC_CGADEFAULT
69 -
70 - sysIPV6_PREFER_SRC_MASK = C.IPV6_PREFER_SRC_MASK
71 -
72 - sysIPV6_PREFER_SRC_DEFAULT = C.IPV6_PREFER_SRC_DEFAULT
73 -
74 - sysIPV6_BOUND_IF = C.IPV6_BOUND_IF
75 - sysIPV6_UNSPEC_SRC = C.IPV6_UNSPEC_SRC
76 -
77 - sysICMP6_FILTER = C.ICMP6_FILTER
78 -
79 - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6
80 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo
81 - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo
82 -
83 - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq
84 -
85 - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter
86 -)
87 -
88 -type sysSockaddrInet6 C.struct_sockaddr_in6
89 -
90 -type sysInet6Pktinfo C.struct_in6_pktinfo
91 -
92 -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo
93 -
94 -type sysIPv6Mreq C.struct_ipv6_mreq
95 -
96 -type sysICMPv6Filter C.struct_icmp6_filter
Godeps/_workspace/src/golang.org/x/net/ipv6/dgramopt_posix.go deleted
-288
@@ -1,288 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux netbsd openbsd windows
6 -
7 -package ipv6
8 -
9 -import (
10 - "net"
11 - "syscall"
12 -)
13 -
14 -// MulticastHopLimit returns the hop limit field value for outgoing
15 -// multicast packets.
16 -func (c *dgramOpt) MulticastHopLimit() (int, error) {
17 - if !c.ok() {
18 - return 0, syscall.EINVAL
19 - }
20 - fd, err := c.sysfd()
21 - if err != nil {
22 - return 0, err
23 - }
24 - return getInt(fd, &sockOpts[ssoMulticastHopLimit])
25 -}
26 -
27 -// SetMulticastHopLimit sets the hop limit field value for future
28 -// outgoing multicast packets.
29 -func (c *dgramOpt) SetMulticastHopLimit(hoplim int) error {
30 - if !c.ok() {
31 - return syscall.EINVAL
32 - }
33 - fd, err := c.sysfd()
34 - if err != nil {
35 - return err
36 - }
37 - return setInt(fd, &sockOpts[ssoMulticastHopLimit], hoplim)
38 -}
39 -
40 -// MulticastInterface returns the default interface for multicast
41 -// packet transmissions.
42 -func (c *dgramOpt) MulticastInterface() (*net.Interface, error) {
43 - if !c.ok() {
44 - return nil, syscall.EINVAL
45 - }
46 - fd, err := c.sysfd()
47 - if err != nil {
48 - return nil, err
49 - }
50 - return getInterface(fd, &sockOpts[ssoMulticastInterface])
51 -}
52 -
53 -// SetMulticastInterface sets the default interface for future
54 -// multicast packet transmissions.
55 -func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error {
56 - if !c.ok() {
57 - return syscall.EINVAL
58 - }
59 - fd, err := c.sysfd()
60 - if err != nil {
61 - return err
62 - }
63 - return setInterface(fd, &sockOpts[ssoMulticastInterface], ifi)
64 -}
65 -
66 -// MulticastLoopback reports whether transmitted multicast packets
67 -// should be copied and send back to the originator.
68 -func (c *dgramOpt) MulticastLoopback() (bool, error) {
69 - if !c.ok() {
70 - return false, syscall.EINVAL
71 - }
72 - fd, err := c.sysfd()
73 - if err != nil {
74 - return false, err
75 - }
76 - on, err := getInt(fd, &sockOpts[ssoMulticastLoopback])
77 - if err != nil {
78 - return false, err
79 - }
80 - return on == 1, nil
81 -}
82 -
83 -// SetMulticastLoopback sets whether transmitted multicast packets
84 -// should be copied and send back to the originator.
85 -func (c *dgramOpt) SetMulticastLoopback(on bool) error {
86 - if !c.ok() {
87 - return syscall.EINVAL
88 - }
89 - fd, err := c.sysfd()
90 - if err != nil {
91 - return err
92 - }
93 - return setInt(fd, &sockOpts[ssoMulticastLoopback], boolint(on))
94 -}
95 -
96 -// JoinGroup joins the group address group on the interface ifi.
97 -// By default all sources that can cast data to group are accepted.
98 -// It's possible to mute and unmute data transmission from a specific
99 -// source by using ExcludeSourceSpecificGroup and
100 -// IncludeSourceSpecificGroup.
101 -// JoinGroup uses the system assigned multicast interface when ifi is
102 -// nil, although this is not recommended because the assignment
103 -// depends on platforms and sometimes it might require routing
104 -// configuration.
105 -func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error {
106 - if !c.ok() {
107 - return syscall.EINVAL
108 - }
109 - fd, err := c.sysfd()
110 - if err != nil {
111 - return err
112 - }
113 - grp := netAddrToIP16(group)
114 - if grp == nil {
115 - return errMissingAddress
116 - }
117 - return setGroup(fd, &sockOpts[ssoJoinGroup], ifi, grp)
118 -}
119 -
120 -// LeaveGroup leaves the group address group on the interface ifi
121 -// regardless of whether the group is any-source group or
122 -// source-specific group.
123 -func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error {
124 - if !c.ok() {
125 - return syscall.EINVAL
126 - }
127 - fd, err := c.sysfd()
128 - if err != nil {
129 - return err
130 - }
131 - grp := netAddrToIP16(group)
132 - if grp == nil {
133 - return errMissingAddress
134 - }
135 - return setGroup(fd, &sockOpts[ssoLeaveGroup], ifi, grp)
136 -}
137 -
138 -// JoinSourceSpecificGroup joins the source-specific group comprising
139 -// group and source on the interface ifi.
140 -// JoinSourceSpecificGroup uses the system assigned multicast
141 -// interface when ifi is nil, although this is not recommended because
142 -// the assignment depends on platforms and sometimes it might require
143 -// routing configuration.
144 -func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
145 - if !c.ok() {
146 - return syscall.EINVAL
147 - }
148 - fd, err := c.sysfd()
149 - if err != nil {
150 - return err
151 - }
152 - grp := netAddrToIP16(group)
153 - if grp == nil {
154 - return errMissingAddress
155 - }
156 - src := netAddrToIP16(source)
157 - if src == nil {
158 - return errMissingAddress
159 - }
160 - return setSourceGroup(fd, &sockOpts[ssoJoinSourceGroup], ifi, grp, src)
161 -}
162 -
163 -// LeaveSourceSpecificGroup leaves the source-specific group on the
164 -// interface ifi.
165 -func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
166 - if !c.ok() {
167 - return syscall.EINVAL
168 - }
169 - fd, err := c.sysfd()
170 - if err != nil {
171 - return err
172 - }
173 - grp := netAddrToIP16(group)
174 - if grp == nil {
175 - return errMissingAddress
176 - }
177 - src := netAddrToIP16(source)
178 - if src == nil {
179 - return errMissingAddress
180 - }
181 - return setSourceGroup(fd, &sockOpts[ssoLeaveSourceGroup], ifi, grp, src)
182 -}
183 -
184 -// ExcludeSourceSpecificGroup excludes the source-specific group from
185 -// the already joined any-source groups by JoinGroup on the interface
186 -// ifi.
187 -func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
188 - if !c.ok() {
189 - return syscall.EINVAL
190 - }
191 - fd, err := c.sysfd()
192 - if err != nil {
193 - return err
194 - }
195 - grp := netAddrToIP16(group)
196 - if grp == nil {
197 - return errMissingAddress
198 - }
199 - src := netAddrToIP16(source)
200 - if src == nil {
201 - return errMissingAddress
202 - }
203 - return setSourceGroup(fd, &sockOpts[ssoBlockSourceGroup], ifi, grp, src)
204 -}
205 -
206 -// IncludeSourceSpecificGroup includes the excluded source-specific
207 -// group by ExcludeSourceSpecificGroup again on the interface ifi.
208 -func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
209 - if !c.ok() {
210 - return syscall.EINVAL
211 - }
212 - fd, err := c.sysfd()
213 - if err != nil {
214 - return err
215 - }
216 - grp := netAddrToIP16(group)
217 - if grp == nil {
218 - return errMissingAddress
219 - }
220 - src := netAddrToIP16(source)
221 - if src == nil {
222 - return errMissingAddress
223 - }
224 - return setSourceGroup(fd, &sockOpts[ssoUnblockSourceGroup], ifi, grp, src)
225 -}
226 -
227 -// Checksum reports whether the kernel will compute, store or verify a
228 -// checksum for both incoming and outgoing packets. If on is true, it
229 -// returns an offset in bytes into the data of where the checksum
230 -// field is located.
231 -func (c *dgramOpt) Checksum() (on bool, offset int, err error) {
232 - if !c.ok() {
233 - return false, 0, syscall.EINVAL
234 - }
235 - fd, err := c.sysfd()
236 - if err != nil {
237 - return false, 0, err
238 - }
239 - offset, err = getInt(fd, &sockOpts[ssoChecksum])
240 - if err != nil {
241 - return false, 0, err
242 - }
243 - if offset < 0 {
244 - return false, 0, nil
245 - }
246 - return true, offset, nil
247 -}
248 -
249 -// SetChecksum enables the kernel checksum processing. If on is ture,
250 -// the offset should be an offset in bytes into the data of where the
251 -// checksum field is located.
252 -func (c *dgramOpt) SetChecksum(on bool, offset int) error {
253 - if !c.ok() {
254 - return syscall.EINVAL
255 - }
256 - fd, err := c.sysfd()
257 - if err != nil {
258 - return err
259 - }
260 - if !on {
261 - offset = -1
262 - }
263 - return setInt(fd, &sockOpts[ssoChecksum], offset)
264 -}
265 -
266 -// ICMPFilter returns an ICMP filter.
267 -func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) {
268 - if !c.ok() {
269 - return nil, syscall.EINVAL
270 - }
271 - fd, err := c.sysfd()
272 - if err != nil {
273 - return nil, err
274 - }
275 - return getICMPFilter(fd, &sockOpts[ssoICMPFilter])
276 -}
277 -
278 -// SetICMPFilter deploys the ICMP filter.
279 -func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error {
280 - if !c.ok() {
281 - return syscall.EINVAL
282 - }
283 - fd, err := c.sysfd()
284 - if err != nil {
285 - return err
286 - }
287 - return setICMPFilter(fd, &sockOpts[ssoICMPFilter], f)
288 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/dgramopt_stub.go deleted
-119
@@ -1,119 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9 solaris
6 -
7 -package ipv6
8 -
9 -import "net"
10 -
11 -// MulticastHopLimit returns the hop limit field value for outgoing
12 -// multicast packets.
13 -func (c *dgramOpt) MulticastHopLimit() (int, error) {
14 - return 0, errOpNoSupport
15 -}
16 -
17 -// SetMulticastHopLimit sets the hop limit field value for future
18 -// outgoing multicast packets.
19 -func (c *dgramOpt) SetMulticastHopLimit(hoplim int) error {
20 - return errOpNoSupport
21 -}
22 -
23 -// MulticastInterface returns the default interface for multicast
24 -// packet transmissions.
25 -func (c *dgramOpt) MulticastInterface() (*net.Interface, error) {
26 - return nil, errOpNoSupport
27 -}
28 -
29 -// SetMulticastInterface sets the default interface for future
30 -// multicast packet transmissions.
31 -func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error {
32 - return errOpNoSupport
33 -}
34 -
35 -// MulticastLoopback reports whether transmitted multicast packets
36 -// should be copied and send back to the originator.
37 -func (c *dgramOpt) MulticastLoopback() (bool, error) {
38 - return false, errOpNoSupport
39 -}
40 -
41 -// SetMulticastLoopback sets whether transmitted multicast packets
42 -// should be copied and send back to the originator.
43 -func (c *dgramOpt) SetMulticastLoopback(on bool) error {
44 - return errOpNoSupport
45 -}
46 -
47 -// JoinGroup joins the group address group on the interface ifi.
48 -// By default all sources that can cast data to group are accepted.
49 -// It's possible to mute and unmute data transmission from a specific
50 -// source by using ExcludeSourceSpecificGroup and
51 -// IncludeSourceSpecificGroup.
52 -// JoinGroup uses the system assigned multicast interface when ifi is
53 -// nil, although this is not recommended because the assignment
54 -// depends on platforms and sometimes it might require routing
55 -// configuration.
56 -func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error {
57 - return errOpNoSupport
58 -}
59 -
60 -// LeaveGroup leaves the group address group on the interface ifi
61 -// regardless of whether the group is any-source group or
62 -// source-specific group.
63 -func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error {
64 - return errOpNoSupport
65 -}
66 -
67 -// JoinSourceSpecificGroup joins the source-specific group comprising
68 -// group and source on the interface ifi.
69 -// JoinSourceSpecificGroup uses the system assigned multicast
70 -// interface when ifi is nil, although this is not recommended because
71 -// the assignment depends on platforms and sometimes it might require
72 -// routing configuration.
73 -func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
74 - return errOpNoSupport
75 -}
76 -
77 -// LeaveSourceSpecificGroup leaves the source-specific group on the
78 -// interface ifi.
79 -func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
80 - return errOpNoSupport
81 -}
82 -
83 -// ExcludeSourceSpecificGroup excludes the source-specific group from
84 -// the already joined any-source groups by JoinGroup on the interface
85 -// ifi.
86 -func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
87 - return errOpNoSupport
88 -}
89 -
90 -// IncludeSourceSpecificGroup includes the excluded source-specific
91 -// group by ExcludeSourceSpecificGroup again on the interface ifi.
92 -func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error {
93 - return errOpNoSupport
94 -}
95 -
96 -// Checksum reports whether the kernel will compute, store or verify a
97 -// checksum for both incoming and outgoing packets. If on is true, it
98 -// returns an offset in bytes into the data of where the checksum
99 -// field is located.
100 -func (c *dgramOpt) Checksum() (on bool, offset int, err error) {
101 - return false, 0, errOpNoSupport
102 -}
103 -
104 -// SetChecksum enables the kernel checksum processing. If on is ture,
105 -// the offset should be an offset in bytes into the data of where the
106 -// checksum field is located.
107 -func (c *dgramOpt) SetChecksum(on bool, offset int) error {
108 - return errOpNoSupport
109 -}
110 -
111 -// ICMPFilter returns an ICMP filter.
112 -func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) {
113 - return nil, errOpNoSupport
114 -}
115 -
116 -// SetICMPFilter deploys the ICMP filter.
117 -func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error {
118 - return errOpNoSupport
119 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/doc.go deleted
-240
@@ -1,240 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// Package ipv6 implements IP-level socket options for the Internet
6 -// Protocol version 6.
7 -//
8 -// The package provides IP-level socket options that allow
9 -// manipulation of IPv6 facilities.
10 -//
11 -// The IPv6 protocol is defined in RFC 2460.
12 -// Basic and advanced socket interface extensions are defined in RFC
13 -// 3493 and RFC 3542.
14 -// Socket interface extensions for multicast source filters are
15 -// defined in RFC 3678.
16 -// MLDv1 and MLDv2 are defined in RFC 2710 and RFC 3810.
17 -// Source-specific multicast is defined in RFC 4607.
18 -//
19 -//
20 -// Unicasting
21 -//
22 -// The options for unicasting are available for net.TCPConn,
23 -// net.UDPConn and net.IPConn which are created as network connections
24 -// that use the IPv6 transport. When a single TCP connection carrying
25 -// a data flow of multiple packets needs to indicate the flow is
26 -// important, ipv6.Conn is used to set the traffic class field on the
27 -// IPv6 header for each packet.
28 -//
29 -// ln, err := net.Listen("tcp6", "[::]:1024")
30 -// if err != nil {
31 -// // error handling
32 -// }
33 -// defer ln.Close()
34 -// for {
35 -// c, err := ln.Accept()
36 -// if err != nil {
37 -// // error handling
38 -// }
39 -// go func(c net.Conn) {
40 -// defer c.Close()
41 -//
42 -// The outgoing packets will be labeled DiffServ assured forwarding
43 -// class 1 low drop precedence, known as AF11 packets.
44 -//
45 -// if err := ipv6.NewConn(c).SetTrafficClass(DiffServAF11); err != nil {
46 -// // error handling
47 -// }
48 -// if _, err := c.Write(data); err != nil {
49 -// // error handling
50 -// }
51 -// }(c)
52 -// }
53 -//
54 -//
55 -// Multicasting
56 -//
57 -// The options for multicasting are available for net.UDPConn and
58 -// net.IPconn which are created as network connections that use the
59 -// IPv6 transport. A few network facilities must be prepared before
60 -// you begin multicasting, at a minimum joining network interfaces and
61 -// multicast groups.
62 -//
63 -// en0, err := net.InterfaceByName("en0")
64 -// if err != nil {
65 -// // error handling
66 -// }
67 -// en1, err := net.InterfaceByIndex(911)
68 -// if err != nil {
69 -// // error handling
70 -// }
71 -// group := net.ParseIP("ff02::114")
72 -//
73 -// First, an application listens to an appropriate address with an
74 -// appropriate service port.
75 -//
76 -// c, err := net.ListenPacket("udp6", "[::]:1024")
77 -// if err != nil {
78 -// // error handling
79 -// }
80 -// defer c.Close()
81 -//
82 -// Second, the application joins multicast groups, starts listening to
83 -// the groups on the specified network interfaces. Note that the
84 -// service port for transport layer protocol does not matter with this
85 -// operation as joining groups affects only network and link layer
86 -// protocols, such as IPv6 and Ethernet.
87 -//
88 -// p := ipv6.NewPacketConn(c)
89 -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: group}); err != nil {
90 -// // error handling
91 -// }
92 -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: group}); err != nil {
93 -// // error handling
94 -// }
95 -//
96 -// The application might set per packet control message transmissions
97 -// between the protocol stack within the kernel. When the application
98 -// needs a destination address on an incoming packet,
99 -// SetControlMessage of ipv6.PacketConn is used to enable control
100 -// message transmissons.
101 -//
102 -// if err := p.SetControlMessage(ipv6.FlagDst, true); err != nil {
103 -// // error handling
104 -// }
105 -//
106 -// The application could identify whether the received packets are
107 -// of interest by using the control message that contains the
108 -// destination address of the received packet.
109 -//
110 -// b := make([]byte, 1500)
111 -// for {
112 -// n, rcm, src, err := p.ReadFrom(b)
113 -// if err != nil {
114 -// // error handling
115 -// }
116 -// if rcm.Dst.IsMulticast() {
117 -// if rcm.Dst.Equal(group)
118 -// // joined group, do something
119 -// } else {
120 -// // unknown group, discard
121 -// continue
122 -// }
123 -// }
124 -//
125 -// The application can also send both unicast and multicast packets.
126 -//
127 -// p.SetTrafficClass(DiffServCS0)
128 -// p.SetHopLimit(16)
129 -// if _, err := p.WriteTo(data[:n], nil, src); err != nil {
130 -// // error handling
131 -// }
132 -// dst := &net.UDPAddr{IP: group, Port: 1024}
133 -// wcm := ipv6.ControlMessage{TrafficClass: DiffServCS7, HopLimit: 1}
134 -// for _, ifi := range []*net.Interface{en0, en1} {
135 -// wcm.IfIndex = ifi.Index
136 -// if _, err := p.WriteTo(data[:n], &wcm, dst); err != nil {
137 -// // error handling
138 -// }
139 -// }
140 -// }
141 -//
142 -//
143 -// More multicasting
144 -//
145 -// An application that uses PacketConn may join multiple multicast
146 -// groups. For example, a UDP listener with port 1024 might join two
147 -// different groups across over two different network interfaces by
148 -// using:
149 -//
150 -// c, err := net.ListenPacket("udp6", "[::]:1024")
151 -// if err != nil {
152 -// // error handling
153 -// }
154 -// defer c.Close()
155 -// p := ipv6.NewPacketConn(c)
156 -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::1:114")}); err != nil {
157 -// // error handling
158 -// }
159 -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::2:114")}); err != nil {
160 -// // error handling
161 -// }
162 -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: net.ParseIP("ff02::2:114")}); err != nil {
163 -// // error handling
164 -// }
165 -//
166 -// It is possible for multiple UDP listeners that listen on the same
167 -// UDP port to join the same multicast group. The net package will
168 -// provide a socket that listens to a wildcard address with reusable
169 -// UDP port when an appropriate multicast address prefix is passed to
170 -// the net.ListenPacket or net.ListenUDP.
171 -//
172 -// c1, err := net.ListenPacket("udp6", "[ff02::]:1024")
173 -// if err != nil {
174 -// // error handling
175 -// }
176 -// defer c1.Close()
177 -// c2, err := net.ListenPacket("udp6", "[ff02::]:1024")
178 -// if err != nil {
179 -// // error handling
180 -// }
181 -// defer c2.Close()
182 -// p1 := ipv6.NewPacketConn(c1)
183 -// if err := p1.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::114")}); err != nil {
184 -// // error handling
185 -// }
186 -// p2 := ipv6.NewPacketConn(c2)
187 -// if err := p2.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::114")}); err != nil {
188 -// // error handling
189 -// }
190 -//
191 -// Also it is possible for the application to leave or rejoin a
192 -// multicast group on the network interface.
193 -//
194 -// if err := p.LeaveGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::114")}); err != nil {
195 -// // error handling
196 -// }
197 -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff01::114")}); err != nil {
198 -// // error handling
199 -// }
200 -//
201 -//
202 -// Source-specific multicasting
203 -//
204 -// An application that uses PacketConn on MLDv2 supported platform is
205 -// able to join source-specific multicast groups.
206 -// The application may use JoinSourceSpecificGroup and
207 -// LeaveSourceSpecificGroup for the operation known as "include" mode,
208 -//
209 -// ssmgroup := net.UDPAddr{IP: net.ParseIP("ff32::8000:9")}
210 -// ssmsource := net.UDPAddr{IP: net.ParseIP("fe80::cafe")}
211 -// if err := p.JoinSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil {
212 -// // error handling
213 -// }
214 -// if err := p.LeaveSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil {
215 -// // error handling
216 -// }
217 -//
218 -// or JoinGroup, ExcludeSourceSpecificGroup,
219 -// IncludeSourceSpecificGroup and LeaveGroup for the operation known
220 -// as "exclude" mode.
221 -//
222 -// exclsource := net.UDPAddr{IP: net.ParseIP("fe80::dead")}
223 -// if err := p.JoinGroup(en0, &ssmgroup); err != nil {
224 -// // error handling
225 -// }
226 -// if err := p.ExcludeSourceSpecificGroup(en0, &ssmgroup, &exclsource); err != nil {
227 -// // error handling
228 -// }
229 -// if err := p.LeaveGroup(en0, &ssmgroup); err != nil {
230 -// // error handling
231 -// }
232 -//
233 -// Note that it depends on each platform implementation what happens
234 -// when an application which runs on MLDv2 unsupported platform uses
235 -// JoinSourceSpecificGroup and LeaveSourceSpecificGroup.
236 -// In general the platform tries to fall back to conversations using
237 -// MLDv1 and starts to listen to multicast traffic.
238 -// In the fallback case, ExcludeSourceSpecificGroup and
239 -// IncludeSourceSpecificGroup may return an error.
240 -package ipv6
Godeps/_workspace/src/golang.org/x/net/ipv6/endpoint.go deleted
-123
@@ -1,123 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import (
8 - "net"
9 - "syscall"
10 - "time"
11 -)
12 -
13 -// A Conn represents a network endpoint that uses IPv6 transport.
14 -// It allows to set basic IP-level socket options such as traffic
15 -// class and hop limit.
16 -type Conn struct {
17 - genericOpt
18 -}
19 -
20 -type genericOpt struct {
21 - net.Conn
22 -}
23 -
24 -func (c *genericOpt) ok() bool { return c != nil && c.Conn != nil }
25 -
26 -// PathMTU returns a path MTU value for the destination associated
27 -// with the endpoint.
28 -func (c *Conn) PathMTU() (int, error) {
29 - if !c.genericOpt.ok() {
30 - return 0, syscall.EINVAL
31 - }
32 - fd, err := c.genericOpt.sysfd()
33 - if err != nil {
34 - return 0, err
35 - }
36 - _, mtu, err := getMTUInfo(fd, &sockOpts[ssoPathMTU])
37 - if err != nil {
38 - return 0, err
39 - }
40 - return mtu, nil
41 -}
42 -
43 -// NewConn returns a new Conn.
44 -func NewConn(c net.Conn) *Conn {
45 - return &Conn{
46 - genericOpt: genericOpt{Conn: c},
47 - }
48 -}
49 -
50 -// A PacketConn represents a packet network endpoint that uses IPv6
51 -// transport. It is used to control several IP-level socket options
52 -// including IPv6 header manipulation. It also provides datagram
53 -// based network I/O methods specific to the IPv6 and higher layer
54 -// protocols such as OSPF, GRE, and UDP.
55 -type PacketConn struct {
56 - genericOpt
57 - dgramOpt
58 - payloadHandler
59 -}
60 -
61 -type dgramOpt struct {
62 - net.PacketConn
63 -}
64 -
65 -func (c *dgramOpt) ok() bool { return c != nil && c.PacketConn != nil }
66 -
67 -// SetControlMessage allows to receive the per packet basis IP-level
68 -// socket options.
69 -func (c *PacketConn) SetControlMessage(cf ControlFlags, on bool) error {
70 - if !c.payloadHandler.ok() {
71 - return syscall.EINVAL
72 - }
73 - fd, err := c.payloadHandler.sysfd()
74 - if err != nil {
75 - return err
76 - }
77 - return setControlMessage(fd, &c.payloadHandler.rawOpt, cf, on)
78 -}
79 -
80 -// SetDeadline sets the read and write deadlines associated with the
81 -// endpoint.
82 -func (c *PacketConn) SetDeadline(t time.Time) error {
83 - if !c.payloadHandler.ok() {
84 - return syscall.EINVAL
85 - }
86 - return c.payloadHandler.SetDeadline(t)
87 -}
88 -
89 -// SetReadDeadline sets the read deadline associated with the
90 -// endpoint.
91 -func (c *PacketConn) SetReadDeadline(t time.Time) error {
92 - if !c.payloadHandler.ok() {
93 - return syscall.EINVAL
94 - }
95 - return c.payloadHandler.SetReadDeadline(t)
96 -}
97 -
98 -// SetWriteDeadline sets the write deadline associated with the
99 -// endpoint.
100 -func (c *PacketConn) SetWriteDeadline(t time.Time) error {
101 - if !c.payloadHandler.ok() {
102 - return syscall.EINVAL
103 - }
104 - return c.payloadHandler.SetWriteDeadline(t)
105 -}
106 -
107 -// Close closes the endpoint.
108 -func (c *PacketConn) Close() error {
109 - if !c.payloadHandler.ok() {
110 - return syscall.EINVAL
111 - }
112 - return c.payloadHandler.Close()
113 -}
114 -
115 -// NewPacketConn returns a new PacketConn using c as its underlying
116 -// transport.
117 -func NewPacketConn(c net.PacketConn) *PacketConn {
118 - return &PacketConn{
119 - genericOpt: genericOpt{Conn: c.(net.Conn)},
120 - dgramOpt: dgramOpt{PacketConn: c},
121 - payloadHandler: payloadHandler{PacketConn: c},
122 - }
123 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/example_test.go deleted
-215
@@ -1,215 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6_test
6 -
7 -import (
8 - "fmt"
9 - "log"
10 - "net"
11 - "os"
12 - "time"
13 -
14 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
15 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv6"
16 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/icmp"
17 -)
18 -
19 -func ExampleConn_markingTCP() {
20 - ln, err := net.Listen("tcp6", "[::]:1024")
21 - if err != nil {
22 - log.Fatal(err)
23 - }
24 - defer ln.Close()
25 -
26 - for {
27 - c, err := ln.Accept()
28 - if err != nil {
29 - log.Fatal(err)
30 - }
31 - go func(c net.Conn) {
32 - defer c.Close()
33 - p := ipv6.NewConn(c)
34 - if err := p.SetTrafficClass(iana.DiffServAF11); err != nil {
35 - log.Fatal(err)
36 - }
37 - if err := p.SetHopLimit(128); err != nil {
38 - log.Fatal(err)
39 - }
40 - if _, err := c.Write([]byte("HELLO-R-U-THERE-ACK")); err != nil {
41 - log.Fatal(err)
42 - }
43 - }(c)
44 - }
45 -}
46 -
47 -func ExamplePacketConn_servingOneShotMulticastDNS() {
48 - c, err := net.ListenPacket("udp6", "[::]:5353") // mDNS over UDP
49 - if err != nil {
50 - log.Fatal(err)
51 - }
52 - defer c.Close()
53 - p := ipv6.NewPacketConn(c)
54 -
55 - en0, err := net.InterfaceByName("en0")
56 - if err != nil {
57 - log.Fatal(err)
58 - }
59 - mDNSLinkLocal := net.UDPAddr{IP: net.ParseIP("ff02::fb")}
60 - if err := p.JoinGroup(en0, &mDNSLinkLocal); err != nil {
61 - log.Fatal(err)
62 - }
63 - defer p.LeaveGroup(en0, &mDNSLinkLocal)
64 - if err := p.SetControlMessage(ipv6.FlagDst|ipv6.FlagInterface, true); err != nil {
65 - log.Fatal(err)
66 - }
67 -
68 - var wcm ipv6.ControlMessage
69 - b := make([]byte, 1500)
70 - for {
71 - _, rcm, peer, err := p.ReadFrom(b)
72 - if err != nil {
73 - log.Fatal(err)
74 - }
75 - if !rcm.Dst.IsMulticast() || !rcm.Dst.Equal(mDNSLinkLocal.IP) {
76 - continue
77 - }
78 - wcm.IfIndex = rcm.IfIndex
79 - answers := []byte("FAKE-MDNS-ANSWERS") // fake mDNS answers, you need to implement this
80 - if _, err := p.WriteTo(answers, &wcm, peer); err != nil {
81 - log.Fatal(err)
82 - }
83 - }
84 -}
85 -
86 -func ExamplePacketConn_tracingIPPacketRoute() {
87 - // Tracing an IP packet route to www.google.com.
88 -
89 - const host = "www.google.com"
90 - ips, err := net.LookupIP(host)
91 - if err != nil {
92 - log.Fatal(err)
93 - }
94 - var dst net.IPAddr
95 - for _, ip := range ips {
96 - if ip.To16() != nil && ip.To4() == nil {
97 - dst.IP = ip
98 - fmt.Printf("using %v for tracing an IP packet route to %s\n", dst.IP, host)
99 - break
100 - }
101 - }
102 - if dst.IP == nil {
103 - log.Fatal("no AAAA record found")
104 - }
105 -
106 - c, err := net.ListenPacket(fmt.Sprintf("ip6:%d", iana.ProtocolIPv6ICMP), "::") // ICMP for IPv6
107 - if err != nil {
108 - log.Fatal(err)
109 - }
110 - defer c.Close()
111 - p := ipv6.NewPacketConn(c)
112 -
113 - if err := p.SetControlMessage(ipv6.FlagHopLimit|ipv6.FlagSrc|ipv6.FlagDst|ipv6.FlagInterface, true); err != nil {
114 - log.Fatal(err)
115 - }
116 - wm := icmp.Message{
117 - Type: ipv6.ICMPTypeEchoRequest, Code: 0,
118 - Body: &icmp.Echo{
119 - ID: os.Getpid() & 0xffff,
120 - Data: []byte("HELLO-R-U-THERE"),
121 - },
122 - }
123 - var f ipv6.ICMPFilter
124 - f.SetAll(true)
125 - f.Accept(ipv6.ICMPTypeTimeExceeded)
126 - f.Accept(ipv6.ICMPTypeEchoReply)
127 - if err := p.SetICMPFilter(&f); err != nil {
128 - log.Fatal(err)
129 - }
130 -
131 - var wcm ipv6.ControlMessage
132 - rb := make([]byte, 1500)
133 - for i := 1; i <= 64; i++ { // up to 64 hops
134 - wm.Body.(*icmp.Echo).Seq = i
135 - wb, err := wm.Marshal(nil)
136 - if err != nil {
137 - log.Fatal(err)
138 - }
139 -
140 - // In the real world usually there are several
141 - // multiple traffic-engineered paths for each hop.
142 - // You may need to probe a few times to each hop.
143 - begin := time.Now()
144 - wcm.HopLimit = i
145 - if _, err := p.WriteTo(wb, &wcm, &dst); err != nil {
146 - log.Fatal(err)
147 - }
148 - if err := p.SetReadDeadline(time.Now().Add(3 * time.Second)); err != nil {
149 - log.Fatal(err)
150 - }
151 - n, rcm, peer, err := p.ReadFrom(rb)
152 - if err != nil {
153 - if err, ok := err.(net.Error); ok && err.Timeout() {
154 - fmt.Printf("%v\t*\n", i)
155 - continue
156 - }
157 - log.Fatal(err)
158 - }
159 - rm, err := icmp.ParseMessage(iana.ProtocolIPv6ICMP, rb[:n])
160 - if err != nil {
161 - log.Fatal(err)
162 - }
163 - rtt := time.Since(begin)
164 -
165 - // In the real world you need to determine whether the
166 - // received message is yours using ControlMessage.Src,
167 - // ControlMesage.Dst, icmp.Echo.ID and icmp.Echo.Seq.
168 - switch rm.Type {
169 - case ipv6.ICMPTypeTimeExceeded:
170 - names, _ := net.LookupAddr(peer.String())
171 - fmt.Printf("%d\t%v %+v %v\n\t%+v\n", i, peer, names, rtt, rcm)
172 - case ipv6.ICMPTypeEchoReply:
173 - names, _ := net.LookupAddr(peer.String())
174 - fmt.Printf("%d\t%v %+v %v\n\t%+v\n", i, peer, names, rtt, rcm)
175 - return
176 - }
177 - }
178 -}
179 -
180 -func ExamplePacketConn_advertisingOSPFHello() {
181 - c, err := net.ListenPacket(fmt.Sprintf("ip6:%d", iana.ProtocolOSPFIGP), "::") // OSPF for IPv6
182 - if err != nil {
183 - log.Fatal(err)
184 - }
185 - defer c.Close()
186 - p := ipv6.NewPacketConn(c)
187 -
188 - en0, err := net.InterfaceByName("en0")
189 - if err != nil {
190 - log.Fatal(err)
191 - }
192 - allSPFRouters := net.IPAddr{IP: net.ParseIP("ff02::5")}
193 - if err := p.JoinGroup(en0, &allSPFRouters); err != nil {
194 - log.Fatal(err)
195 - }
196 - defer p.LeaveGroup(en0, &allSPFRouters)
197 -
198 - hello := make([]byte, 24) // fake hello data, you need to implement this
199 - ospf := make([]byte, 16) // fake ospf header, you need to implement this
200 - ospf[0] = 3 // version 3
201 - ospf[1] = 1 // hello packet
202 - ospf = append(ospf, hello...)
203 - if err := p.SetChecksum(true, 12); err != nil {
204 - log.Fatal(err)
205 - }
206 -
207 - cm := ipv6.ControlMessage{
208 - TrafficClass: iana.DiffServCS6,
209 - HopLimit: 1,
210 - IfIndex: en0.Index,
211 - }
212 - if _, err := p.WriteTo(ospf, &cm, &allSPFRouters); err != nil {
213 - log.Fatal(err)
214 - }
215 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/gen.go deleted
-208
@@ -1,208 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build ignore
6 -
7 -//go:generate go run gen.go
8 -
9 -// This program generates system adaptation constants and types,
10 -// internet protocol constants and tables by reading template files
11 -// and IANA protocol registries.
12 -package main
13 -
14 -import (
15 - "bytes"
16 - "encoding/xml"
17 - "fmt"
18 - "go/format"
19 - "io"
20 - "io/ioutil"
21 - "net/http"
22 - "os"
23 - "os/exec"
24 - "runtime"
25 - "strconv"
26 - "strings"
27 -)
28 -
29 -func main() {
30 - if err := genzsys(); err != nil {
31 - fmt.Fprintln(os.Stderr, err)
32 - os.Exit(1)
33 - }
34 - if err := geniana(); err != nil {
35 - fmt.Fprintln(os.Stderr, err)
36 - os.Exit(1)
37 - }
38 -}
39 -
40 -func genzsys() error {
41 - defs := "defs_" + runtime.GOOS + ".go"
42 - f, err := os.Open(defs)
43 - if err != nil {
44 - if os.IsNotExist(err) {
45 - return nil
46 - }
47 - return err
48 - }
49 - f.Close()
50 - cmd := exec.Command("go", "tool", "cgo", "-godefs", defs)
51 - b, err := cmd.Output()
52 - if err != nil {
53 - return err
54 - }
55 - // The ipv6 pacakge still supports go1.2, and so we need to
56 - // take care of additional platforms in go1.3 and above for
57 - // working with go1.2.
58 - switch {
59 - case runtime.GOOS == "dragonfly" || runtime.GOOS == "solaris":
60 - b = bytes.Replace(b, []byte("package ipv6\n"), []byte("// +build "+runtime.GOOS+"\n\npackage ipv6\n"), 1)
61 - case runtime.GOOS == "linux" && (runtime.GOARCH == "arm64" || runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le"):
62 - b = bytes.Replace(b, []byte("package ipv6\n"), []byte("// +build "+runtime.GOOS+","+runtime.GOARCH+"\n\npackage ipv6\n"), 1)
63 - }
64 - b, err = format.Source(b)
65 - if err != nil {
66 - return err
67 - }
68 - zsys := "zsys_" + runtime.GOOS + ".go"
69 - switch runtime.GOOS {
70 - case "freebsd", "linux":
71 - zsys = "zsys_" + runtime.GOOS + "_" + runtime.GOARCH + ".go"
72 - }
73 - if err := ioutil.WriteFile(zsys, b, 0644); err != nil {
74 - return err
75 - }
76 - return nil
77 -}
78 -
79 -var registries = []struct {
80 - url string
81 - parse func(io.Writer, io.Reader) error
82 -}{
83 - {
84 - "http://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xml",
85 - parseICMPv6Parameters,
86 - },
87 -}
88 -
89 -func geniana() error {
90 - var bb bytes.Buffer
91 - fmt.Fprintf(&bb, "// go generate gen.go\n")
92 - fmt.Fprintf(&bb, "// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n")
93 - fmt.Fprintf(&bb, "package ipv6\n\n")
94 - for _, r := range registries {
95 - resp, err := http.Get(r.url)
96 - if err != nil {
97 - return err
98 - }
99 - defer resp.Body.Close()
100 - if resp.StatusCode != http.StatusOK {
101 - return fmt.Errorf("got HTTP status code %v for %v\n", resp.StatusCode, r.url)
102 - }
103 - if err := r.parse(&bb, resp.Body); err != nil {
104 - return err
105 - }
106 - fmt.Fprintf(&bb, "\n")
107 - }
108 - b, err := format.Source(bb.Bytes())
109 - if err != nil {
110 - return err
111 - }
112 - if err := ioutil.WriteFile("iana.go", b, 0644); err != nil {
113 - return err
114 - }
115 - return nil
116 -}
117 -
118 -func parseICMPv6Parameters(w io.Writer, r io.Reader) error {
119 - dec := xml.NewDecoder(r)
120 - var icp icmpv6Parameters
121 - if err := dec.Decode(&icp); err != nil {
122 - return err
123 - }
124 - prs := icp.escape()
125 - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated)
126 - fmt.Fprintf(w, "const (\n")
127 - for _, pr := range prs {
128 - if pr.Name == "" {
129 - continue
130 - }
131 - fmt.Fprintf(w, "ICMPType%s ICMPType = %d", pr.Name, pr.Value)
132 - fmt.Fprintf(w, "// %s\n", pr.OrigName)
133 - }
134 - fmt.Fprintf(w, ")\n\n")
135 - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated)
136 - fmt.Fprintf(w, "var icmpTypes = map[ICMPType]string{\n")
137 - for _, pr := range prs {
138 - if pr.Name == "" {
139 - continue
140 - }
141 - fmt.Fprintf(w, "%d: %q,\n", pr.Value, strings.ToLower(pr.OrigName))
142 - }
143 - fmt.Fprintf(w, "}\n")
144 - return nil
145 -}
146 -
147 -type icmpv6Parameters struct {
148 - XMLName xml.Name `xml:"registry"`
149 - Title string `xml:"title"`
150 - Updated string `xml:"updated"`
151 - Registries []struct {
152 - Title string `xml:"title"`
153 - Records []struct {
154 - Value string `xml:"value"`
155 - Name string `xml:"name"`
156 - } `xml:"record"`
157 - } `xml:"registry"`
158 -}
159 -
160 -type canonICMPv6ParamRecord struct {
161 - OrigName string
162 - Name string
163 - Value int
164 -}
165 -
166 -func (icp *icmpv6Parameters) escape() []canonICMPv6ParamRecord {
167 - id := -1
168 - for i, r := range icp.Registries {
169 - if strings.Contains(r.Title, "Type") || strings.Contains(r.Title, "type") {
170 - id = i
171 - break
172 - }
173 - }
174 - if id < 0 {
175 - return nil
176 - }
177 - prs := make([]canonICMPv6ParamRecord, len(icp.Registries[id].Records))
178 - sr := strings.NewReplacer(
179 - "Messages", "",
180 - "Message", "",
181 - "ICMP", "",
182 - "+", "P",
183 - "-", "",
184 - "/", "",
185 - ".", "",
186 - " ", "",
187 - )
188 - for i, pr := range icp.Registries[id].Records {
189 - if strings.Contains(pr.Name, "Reserved") ||
190 - strings.Contains(pr.Name, "Unassigned") ||
191 - strings.Contains(pr.Name, "Deprecated") ||
192 - strings.Contains(pr.Name, "Experiment") ||
193 - strings.Contains(pr.Name, "experiment") {
194 - continue
195 - }
196 - ss := strings.Split(pr.Name, "\n")
197 - if len(ss) > 1 {
198 - prs[i].Name = strings.Join(ss, " ")
199 - } else {
200 - prs[i].Name = ss[0]
201 - }
202 - s := strings.TrimSpace(prs[i].Name)
203 - prs[i].OrigName = s
204 - prs[i].Name = sr.Replace(s)
205 - prs[i].Value, _ = strconv.Atoi(pr.Value)
206 - }
207 - return prs
208 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/genericopt_posix.go deleted
-60
@@ -1,60 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux netbsd openbsd windows
6 -
7 -package ipv6
8 -
9 -import "syscall"
10 -
11 -// TrafficClass returns the traffic class field value for outgoing
12 -// packets.
13 -func (c *genericOpt) TrafficClass() (int, error) {
14 - if !c.ok() {
15 - return 0, syscall.EINVAL
16 - }
17 - fd, err := c.sysfd()
18 - if err != nil {
19 - return 0, err
20 - }
21 - return getInt(fd, &sockOpts[ssoTrafficClass])
22 -}
23 -
24 -// SetTrafficClass sets the traffic class field value for future
25 -// outgoing packets.
26 -func (c *genericOpt) SetTrafficClass(tclass int) error {
27 - if !c.ok() {
28 - return syscall.EINVAL
29 - }
30 - fd, err := c.sysfd()
31 - if err != nil {
32 - return err
33 - }
34 - return setInt(fd, &sockOpts[ssoTrafficClass], tclass)
35 -}
36 -
37 -// HopLimit returns the hop limit field value for outgoing packets.
38 -func (c *genericOpt) HopLimit() (int, error) {
39 - if !c.ok() {
40 - return 0, syscall.EINVAL
41 - }
42 - fd, err := c.sysfd()
43 - if err != nil {
44 - return 0, err
45 - }
46 - return getInt(fd, &sockOpts[ssoHopLimit])
47 -}
48 -
49 -// SetHopLimit sets the hop limit field value for future outgoing
50 -// packets.
51 -func (c *genericOpt) SetHopLimit(hoplim int) error {
52 - if !c.ok() {
53 - return syscall.EINVAL
54 - }
55 - fd, err := c.sysfd()
56 - if err != nil {
57 - return err
58 - }
59 - return setInt(fd, &sockOpts[ssoHopLimit], hoplim)
60 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/genericopt_stub.go deleted
-30
@@ -1,30 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9 solaris
6 -
7 -package ipv6
8 -
9 -// TrafficClass returns the traffic class field value for outgoing
10 -// packets.
11 -func (c *genericOpt) TrafficClass() (int, error) {
12 - return 0, errOpNoSupport
13 -}
14 -
15 -// SetTrafficClass sets the traffic class field value for future
16 -// outgoing packets.
17 -func (c *genericOpt) SetTrafficClass(tclass int) error {
18 - return errOpNoSupport
19 -}
20 -
21 -// HopLimit returns the hop limit field value for outgoing packets.
22 -func (c *genericOpt) HopLimit() (int, error) {
23 - return 0, errOpNoSupport
24 -}
25 -
26 -// SetHopLimit sets the hop limit field value for future outgoing
27 -// packets.
28 -func (c *genericOpt) SetHopLimit(hoplim int) error {
29 - return errOpNoSupport
30 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/header.go deleted
-55
@@ -1,55 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import (
8 - "errors"
9 - "fmt"
10 - "net"
11 -)
12 -
13 -const (
14 - Version = 6 // protocol version
15 - HeaderLen = 40 // header length
16 -)
17 -
18 -// A Header represents an IPv6 base header.
19 -type Header struct {
20 - Version int // protocol version
21 - TrafficClass int // traffic class
22 - FlowLabel int // flow label
23 - PayloadLen int // payload length
24 - NextHeader int // next header
25 - HopLimit int // hop limit
26 - Src net.IP // source address
27 - Dst net.IP // destination address
28 -}
29 -
30 -func (h *Header) String() string {
31 - if h == nil {
32 - return "<nil>"
33 - }
34 - return fmt.Sprintf("ver: %v, tclass: %#x, flowlbl: %#x, payloadlen: %v, nxthdr: %v, hoplim: %v, src: %v, dst: %v", h.Version, h.TrafficClass, h.FlowLabel, h.PayloadLen, h.NextHeader, h.HopLimit, h.Src, h.Dst)
35 -}
36 -
37 -// ParseHeader parses b as an IPv6 base header.
38 -func ParseHeader(b []byte) (*Header, error) {
39 - if len(b) < HeaderLen {
40 - return nil, errors.New("header too short")
41 - }
42 - h := &Header{
43 - Version: int(b[0]) >> 4,
44 - TrafficClass: int(b[0]&0x0f)<<4 | int(b[1])>>4,
45 - FlowLabel: int(b[1]&0x0f)<<16 | int(b[2])<<8 | int(b[3]),
46 - PayloadLen: int(b[4])<<8 | int(b[5]),
47 - NextHeader: int(b[6]),
48 - HopLimit: int(b[7]),
49 - }
50 - h.Src = make(net.IP, net.IPv6len)
51 - copy(h.Src, b[8:24])
52 - h.Dst = make(net.IP, net.IPv6len)
53 - copy(h.Dst, b[24:40])
54 - return h, nil
55 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/header_test.go deleted
-50
@@ -1,50 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6_test
6 -
7 -import (
8 - "net"
9 - "reflect"
10 - "testing"
11 -
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv6"
14 -)
15 -
16 -var (
17 - wireHeaderFromKernel = [ipv6.HeaderLen]byte{
18 - 0x69, 0x8b, 0xee, 0xf1,
19 - 0xca, 0xfe, 0x2c, 0x01,
20 - 0x20, 0x01, 0x0d, 0xb8,
21 - 0x00, 0x01, 0x00, 0x00,
22 - 0x00, 0x00, 0x00, 0x00,
23 - 0x00, 0x00, 0x00, 0x01,
24 - 0x20, 0x01, 0x0d, 0xb8,
25 - 0x00, 0x02, 0x00, 0x00,
26 - 0x00, 0x00, 0x00, 0x00,
27 - 0x00, 0x00, 0x00, 0x01,
28 - }
29 -
30 - testHeader = &ipv6.Header{
31 - Version: ipv6.Version,
32 - TrafficClass: iana.DiffServAF43,
33 - FlowLabel: 0xbeef1,
34 - PayloadLen: 0xcafe,
35 - NextHeader: iana.ProtocolIPv6Frag,
36 - HopLimit: 1,
37 - Src: net.ParseIP("2001:db8:1::1"),
38 - Dst: net.ParseIP("2001:db8:2::1"),
39 - }
40 -)
41 -
42 -func TestParseHeader(t *testing.T) {
43 - h, err := ipv6.ParseHeader(wireHeaderFromKernel[:])
44 - if err != nil {
45 - t.Fatal(err)
46 - }
47 - if !reflect.DeepEqual(h, testHeader) {
48 - t.Fatalf("got %#v; want %#v", h, testHeader)
49 - }
50 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/helper.go deleted
-33
@@ -1,33 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import (
8 - "errors"
9 - "net"
10 -)
11 -
12 -var errOpNoSupport = errors.New("operation not supported")
13 -
14 -func boolint(b bool) int {
15 - if b {
16 - return 1
17 - }
18 - return 0
19 -}
20 -
21 -func netAddrToIP16(a net.Addr) net.IP {
22 - switch v := a.(type) {
23 - case *net.UDPAddr:
24 - if ip := v.IP.To16(); ip != nil && ip.To4() == nil {
25 - return ip
26 - }
27 - case *net.IPAddr:
28 - if ip := v.IP.To16(); ip != nil && ip.To4() == nil {
29 - return ip
30 - }
31 - }
32 - return nil
33 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/helper_stub.go deleted
-19
@@ -1,19 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9 solaris
6 -
7 -package ipv6
8 -
9 -func (c *genericOpt) sysfd() (int, error) {
10 - return 0, errOpNoSupport
11 -}
12 -
13 -func (c *dgramOpt) sysfd() (int, error) {
14 - return 0, errOpNoSupport
15 -}
16 -
17 -func (c *payloadHandler) sysfd() (int, error) {
18 - return 0, errOpNoSupport
19 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/helper_unix.go deleted
-46
@@ -1,46 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux netbsd openbsd
6 -
7 -package ipv6
8 -
9 -import (
10 - "net"
11 - "reflect"
12 -)
13 -
14 -func (c *genericOpt) sysfd() (int, error) {
15 - switch p := c.Conn.(type) {
16 - case *net.TCPConn, *net.UDPConn, *net.IPConn:
17 - return sysfd(p)
18 - }
19 - return 0, errInvalidConnType
20 -}
21 -
22 -func (c *dgramOpt) sysfd() (int, error) {
23 - switch p := c.PacketConn.(type) {
24 - case *net.UDPConn, *net.IPConn:
25 - return sysfd(p.(net.Conn))
26 - }
27 - return 0, errInvalidConnType
28 -}
29 -
30 -func (c *payloadHandler) sysfd() (int, error) {
31 - return sysfd(c.PacketConn.(net.Conn))
32 -}
33 -
34 -func sysfd(c net.Conn) (int, error) {
35 - cv := reflect.ValueOf(c)
36 - switch ce := cv.Elem(); ce.Kind() {
37 - case reflect.Struct:
38 - nfd := ce.FieldByName("conn").FieldByName("fd")
39 - switch fe := nfd.Elem(); fe.Kind() {
40 - case reflect.Struct:
41 - fd := fe.FieldByName("sysfd")
42 - return int(fd.Int()), nil
43 - }
44 - }
45 - return 0, errInvalidConnType
46 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/helper_windows.go deleted
-45
@@ -1,45 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import (
8 - "net"
9 - "reflect"
10 - "syscall"
11 -)
12 -
13 -func (c *genericOpt) sysfd() (syscall.Handle, error) {
14 - switch p := c.Conn.(type) {
15 - case *net.TCPConn, *net.UDPConn, *net.IPConn:
16 - return sysfd(p)
17 - }
18 - return syscall.InvalidHandle, errInvalidConnType
19 -}
20 -
21 -func (c *dgramOpt) sysfd() (syscall.Handle, error) {
22 - switch p := c.PacketConn.(type) {
23 - case *net.UDPConn, *net.IPConn:
24 - return sysfd(p.(net.Conn))
25 - }
26 - return syscall.InvalidHandle, errInvalidConnType
27 -}
28 -
29 -func (c *payloadHandler) sysfd() (syscall.Handle, error) {
30 - return sysfd(c.PacketConn.(net.Conn))
31 -}
32 -
33 -func sysfd(c net.Conn) (syscall.Handle, error) {
34 - cv := reflect.ValueOf(c)
35 - switch ce := cv.Elem(); ce.Kind() {
36 - case reflect.Struct:
37 - netfd := ce.FieldByName("conn").FieldByName("fd")
38 - switch fe := netfd.Elem(); fe.Kind() {
39 - case reflect.Struct:
40 - fd := fe.FieldByName("sysfd")
41 - return syscall.Handle(fd.Uint()), nil
42 - }
43 - }
44 - return syscall.InvalidHandle, errInvalidConnType
45 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/iana.go deleted
-80
@@ -1,80 +0,0 @@
1 -// go generate gen.go
2 -// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
3 -
4 -package ipv6
5 -
6 -// Internet Control Message Protocol version 6 (ICMPv6) Parameters, Updated: 2014-09-22
7 -const (
8 - ICMPTypeDestinationUnreachable ICMPType = 1 // Destination Unreachable
9 - ICMPTypePacketTooBig ICMPType = 2 // Packet Too Big
10 - ICMPTypeTimeExceeded ICMPType = 3 // Time Exceeded
11 - ICMPTypeParameterProblem ICMPType = 4 // Parameter Problem
12 - ICMPTypeEchoRequest ICMPType = 128 // Echo Request
13 - ICMPTypeEchoReply ICMPType = 129 // Echo Reply
14 - ICMPTypeMulticastListenerQuery ICMPType = 130 // Multicast Listener Query
15 - ICMPTypeMulticastListenerReport ICMPType = 131 // Multicast Listener Report
16 - ICMPTypeMulticastListenerDone ICMPType = 132 // Multicast Listener Done
17 - ICMPTypeRouterSolicitation ICMPType = 133 // Router Solicitation
18 - ICMPTypeRouterAdvertisement ICMPType = 134 // Router Advertisement
19 - ICMPTypeNeighborSolicitation ICMPType = 135 // Neighbor Solicitation
20 - ICMPTypeNeighborAdvertisement ICMPType = 136 // Neighbor Advertisement
21 - ICMPTypeRedirect ICMPType = 137 // Redirect Message
22 - ICMPTypeRouterRenumbering ICMPType = 138 // Router Renumbering
23 - ICMPTypeNodeInformationQuery ICMPType = 139 // ICMP Node Information Query
24 - ICMPTypeNodeInformationResponse ICMPType = 140 // ICMP Node Information Response
25 - ICMPTypeInverseNeighborDiscoverySolicitation ICMPType = 141 // Inverse Neighbor Discovery Solicitation Message
26 - ICMPTypeInverseNeighborDiscoveryAdvertisement ICMPType = 142 // Inverse Neighbor Discovery Advertisement Message
27 - ICMPTypeVersion2MulticastListenerReport ICMPType = 143 // Version 2 Multicast Listener Report
28 - ICMPTypeHomeAgentAddressDiscoveryRequest ICMPType = 144 // Home Agent Address Discovery Request Message
29 - ICMPTypeHomeAgentAddressDiscoveryReply ICMPType = 145 // Home Agent Address Discovery Reply Message
30 - ICMPTypeMobilePrefixSolicitation ICMPType = 146 // Mobile Prefix Solicitation
31 - ICMPTypeMobilePrefixAdvertisement ICMPType = 147 // Mobile Prefix Advertisement
32 - ICMPTypeCertificationPathSolicitation ICMPType = 148 // Certification Path Solicitation Message
33 - ICMPTypeCertificationPathAdvertisement ICMPType = 149 // Certification Path Advertisement Message
34 - ICMPTypeMulticastRouterAdvertisement ICMPType = 151 // Multicast Router Advertisement
35 - ICMPTypeMulticastRouterSolicitation ICMPType = 152 // Multicast Router Solicitation
36 - ICMPTypeMulticastRouterTermination ICMPType = 153 // Multicast Router Termination
37 - ICMPTypeFMIPv6 ICMPType = 154 // FMIPv6 Messages
38 - ICMPTypeRPLControl ICMPType = 155 // RPL Control Message
39 - ICMPTypeILNPv6LocatorUpdate ICMPType = 156 // ILNPv6 Locator Update Message
40 - ICMPTypeDuplicateAddressRequest ICMPType = 157 // Duplicate Address Request
41 - ICMPTypeDuplicateAddressConfirmation ICMPType = 158 // Duplicate Address Confirmation
42 -)
43 -
44 -// Internet Control Message Protocol version 6 (ICMPv6) Parameters, Updated: 2014-09-22
45 -var icmpTypes = map[ICMPType]string{
46 - 1: "destination unreachable",
47 - 2: "packet too big",
48 - 3: "time exceeded",
49 - 4: "parameter problem",
50 - 128: "echo request",
51 - 129: "echo reply",
52 - 130: "multicast listener query",
53 - 131: "multicast listener report",
54 - 132: "multicast listener done",
55 - 133: "router solicitation",
56 - 134: "router advertisement",
57 - 135: "neighbor solicitation",
58 - 136: "neighbor advertisement",
59 - 137: "redirect message",
60 - 138: "router renumbering",
61 - 139: "icmp node information query",
62 - 140: "icmp node information response",
63 - 141: "inverse neighbor discovery solicitation message",
64 - 142: "inverse neighbor discovery advertisement message",
65 - 143: "version 2 multicast listener report",
66 - 144: "home agent address discovery request message",
67 - 145: "home agent address discovery reply message",
68 - 146: "mobile prefix solicitation",
69 - 147: "mobile prefix advertisement",
70 - 148: "certification path solicitation message",
71 - 149: "certification path advertisement message",
72 - 151: "multicast router advertisement",
73 - 152: "multicast router solicitation",
74 - 153: "multicast router termination",
75 - 154: "fmipv6 messages",
76 - 155: "rpl control message",
77 - 156: "ilnpv6 locator update message",
78 - 157: "duplicate address request",
79 - 158: "duplicate address confirmation",
80 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/icmp.go deleted
-57
@@ -1,57 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
8 -
9 -// An ICMPType represents a type of ICMP message.
10 -type ICMPType int
11 -
12 -func (typ ICMPType) String() string {
13 - s, ok := icmpTypes[typ]
14 - if !ok {
15 - return "<nil>"
16 - }
17 - return s
18 -}
19 -
20 -// Protocol returns the ICMPv6 protocol number.
21 -func (typ ICMPType) Protocol() int {
22 - return iana.ProtocolIPv6ICMP
23 -}
24 -
25 -// An ICMPFilter represents an ICMP message filter for incoming
26 -// packets. The filter belongs to a packet delivery path on a host and
27 -// it cannot interact with forwarding packets or tunnel-outer packets.
28 -//
29 -// Note: RFC 2460 defines a reasonable role model. A node means a
30 -// device that implements IP. A router means a node that forwards IP
31 -// packets not explicitly addressed to itself, and a host means a node
32 -// that is not a router.
33 -type ICMPFilter struct {
34 - sysICMPv6Filter
35 -}
36 -
37 -// Accept accepts incoming ICMP packets including the type field value
38 -// typ.
39 -func (f *ICMPFilter) Accept(typ ICMPType) {
40 - f.accept(typ)
41 -}
42 -
43 -// Block blocks incoming ICMP packets including the type field value
44 -// typ.
45 -func (f *ICMPFilter) Block(typ ICMPType) {
46 - f.block(typ)
47 -}
48 -
49 -// SetAll sets the filter action to the filter.
50 -func (f *ICMPFilter) SetAll(block bool) {
51 - f.setAll(block)
52 -}
53 -
54 -// WillBlock reports whether the ICMP type will be blocked.
55 -func (f *ICMPFilter) WillBlock(typ ICMPType) bool {
56 - return f.willBlock(typ)
57 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/icmp_bsd.go deleted
-29
@@ -1,29 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd netbsd openbsd
6 -
7 -package ipv6
8 -
9 -func (f *sysICMPv6Filter) accept(typ ICMPType) {
10 - f.Filt[typ>>5] |= 1 << (uint32(typ) & 31)
11 -}
12 -
13 -func (f *sysICMPv6Filter) block(typ ICMPType) {
14 - f.Filt[typ>>5] &^= 1 << (uint32(typ) & 31)
15 -}
16 -
17 -func (f *sysICMPv6Filter) setAll(block bool) {
18 - for i := range f.Filt {
19 - if block {
20 - f.Filt[i] = 0
21 - } else {
22 - f.Filt[i] = 1<<32 - 1
23 - }
24 - }
25 -}
26 -
27 -func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
28 - return f.Filt[typ>>5]&(1<<(uint32(typ)&31)) == 0
29 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/icmp_linux.go deleted
-27
@@ -1,27 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -func (f *sysICMPv6Filter) accept(typ ICMPType) {
8 - f.Data[typ>>5] &^= 1 << (uint32(typ) & 31)
9 -}
10 -
11 -func (f *sysICMPv6Filter) block(typ ICMPType) {
12 - f.Data[typ>>5] |= 1 << (uint32(typ) & 31)
13 -}
14 -
15 -func (f *sysICMPv6Filter) setAll(block bool) {
16 - for i := range f.Data {
17 - if block {
18 - f.Data[i] = 1<<32 - 1
19 - } else {
20 - f.Data[i] = 0
21 - }
22 - }
23 -}
24 -
25 -func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
26 - return f.Data[typ>>5]&(1<<(uint32(typ)&31)) != 0
27 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/icmp_solaris.go deleted
-24
@@ -1,24 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build solaris
6 -
7 -package ipv6
8 -
9 -func (f *sysICMPv6Filter) accept(typ ICMPType) {
10 - // TODO(mikio): implement this
11 -}
12 -
13 -func (f *sysICMPv6Filter) block(typ ICMPType) {
14 - // TODO(mikio): implement this
15 -}
16 -
17 -func (f *sysICMPv6Filter) setAll(block bool) {
18 - // TODO(mikio): implement this
19 -}
20 -
21 -func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
22 - // TODO(mikio): implement this
23 - return false
24 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/icmp_stub.go deleted
-23
@@ -1,23 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9
6 -
7 -package ipv6
8 -
9 -type sysICMPv6Filter struct {
10 -}
11 -
12 -func (f *sysICMPv6Filter) accept(typ ICMPType) {
13 -}
14 -
15 -func (f *sysICMPv6Filter) block(typ ICMPType) {
16 -}
17 -
18 -func (f *sysICMPv6Filter) setAll(block bool) {
19 -}
20 -
21 -func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
22 - return false
23 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/icmp_test.go deleted
-96
@@ -1,96 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6_test
6 -
7 -import (
8 - "net"
9 - "reflect"
10 - "runtime"
11 - "testing"
12 -
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv6"
14 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
15 -)
16 -
17 -var icmpStringTests = []struct {
18 - in ipv6.ICMPType
19 - out string
20 -}{
21 - {ipv6.ICMPTypeDestinationUnreachable, "destination unreachable"},
22 -
23 - {256, "<nil>"},
24 -}
25 -
26 -func TestICMPString(t *testing.T) {
27 - for _, tt := range icmpStringTests {
28 - s := tt.in.String()
29 - if s != tt.out {
30 - t.Errorf("got %s; want %s", s, tt.out)
31 - }
32 - }
33 -}
34 -
35 -func TestICMPFilter(t *testing.T) {
36 - switch runtime.GOOS {
37 - case "nacl", "plan9", "solaris", "windows":
38 - t.Skipf("not supported on %s", runtime.GOOS)
39 - }
40 -
41 - var f ipv6.ICMPFilter
42 - for _, toggle := range []bool{false, true} {
43 - f.SetAll(toggle)
44 - for _, typ := range []ipv6.ICMPType{
45 - ipv6.ICMPTypeDestinationUnreachable,
46 - ipv6.ICMPTypeEchoReply,
47 - ipv6.ICMPTypeNeighborSolicitation,
48 - ipv6.ICMPTypeDuplicateAddressConfirmation,
49 - } {
50 - f.Accept(typ)
51 - if f.WillBlock(typ) {
52 - t.Errorf("ipv6.ICMPFilter.Set(%v, false) failed", typ)
53 - }
54 - f.Block(typ)
55 - if !f.WillBlock(typ) {
56 - t.Errorf("ipv6.ICMPFilter.Set(%v, true) failed", typ)
57 - }
58 - }
59 - }
60 -}
61 -
62 -func TestSetICMPFilter(t *testing.T) {
63 - switch runtime.GOOS {
64 - case "nacl", "plan9", "solaris", "windows":
65 - t.Skipf("not supported on %s", runtime.GOOS)
66 - }
67 - if !supportsIPv6 {
68 - t.Skip("ipv6 is not supported")
69 - }
70 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
71 - t.Skip(m)
72 - }
73 -
74 - c, err := net.ListenPacket("ip6:ipv6-icmp", "::1")
75 - if err != nil {
76 - t.Fatal(err)
77 - }
78 - defer c.Close()
79 -
80 - p := ipv6.NewPacketConn(c)
81 -
82 - var f ipv6.ICMPFilter
83 - f.SetAll(true)
84 - f.Accept(ipv6.ICMPTypeEchoRequest)
85 - f.Accept(ipv6.ICMPTypeEchoReply)
86 - if err := p.SetICMPFilter(&f); err != nil {
87 - t.Fatal(err)
88 - }
89 - kf, err := p.ICMPFilter()
90 - if err != nil {
91 - t.Fatal(err)
92 - }
93 - if !reflect.DeepEqual(kf, &f) {
94 - t.Fatalf("got %#v; want %#v", kf, f)
95 - }
96 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/icmp_windows.go deleted
-26
@@ -1,26 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -type sysICMPv6Filter struct {
8 - // TODO(mikio): implement this
9 -}
10 -
11 -func (f *sysICMPv6Filter) accept(typ ICMPType) {
12 - // TODO(mikio): implement this
13 -}
14 -
15 -func (f *sysICMPv6Filter) block(typ ICMPType) {
16 - // TODO(mikio): implement this
17 -}
18 -
19 -func (f *sysICMPv6Filter) setAll(block bool) {
20 - // TODO(mikio): implement this
21 -}
22 -
23 -func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool {
24 - // TODO(mikio): implement this
25 - return false
26 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/mocktransponder_test.go deleted
-32
@@ -1,32 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6_test
6 -
7 -import (
8 - "net"
9 - "testing"
10 -)
11 -
12 -func connector(t *testing.T, network, addr string, done chan<- bool) {
13 - defer func() { done <- true }()
14 -
15 - c, err := net.Dial(network, addr)
16 - if err != nil {
17 - t.Error(err)
18 - return
19 - }
20 - c.Close()
21 -}
22 -
23 -func acceptor(t *testing.T, ln net.Listener, done chan<- bool) {
24 - defer func() { done <- true }()
25 -
26 - c, err := ln.Accept()
27 - if err != nil {
28 - t.Error(err)
29 - return
30 - }
31 - c.Close()
32 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/multicast_test.go deleted
-263
@@ -1,263 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6_test
6 -
7 -import (
8 - "bytes"
9 - "net"
10 - "os"
11 - "runtime"
12 - "testing"
13 - "time"
14 -
15 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
16 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv6"
17 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/icmp"
18 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
19 -)
20 -
21 -var packetConnReadWriteMulticastUDPTests = []struct {
22 - addr string
23 - grp, src *net.UDPAddr
24 -}{
25 - {"[ff02::]:0", &net.UDPAddr{IP: net.ParseIP("ff02::114")}, nil}, // see RFC 4727
26 -
27 - {"[ff30::8000:0]:0", &net.UDPAddr{IP: net.ParseIP("ff30::8000:1")}, &net.UDPAddr{IP: net.IPv6loopback}}, // see RFC 5771
28 -}
29 -
30 -func TestPacketConnReadWriteMulticastUDP(t *testing.T) {
31 - switch runtime.GOOS {
32 - case "freebsd": // due to a bug on loopback marking
33 - // See http://www.freebsd.org/cgi/query-pr.cgi?pr=180065.
34 - t.Skipf("not supported on %s", runtime.GOOS)
35 - case "nacl", "plan9", "solaris", "windows":
36 - t.Skipf("not supported on %s", runtime.GOOS)
37 - }
38 - if !supportsIPv6 {
39 - t.Skip("ipv6 is not supported")
40 - }
41 - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagMulticast|net.FlagLoopback)
42 - if ifi == nil {
43 - t.Skipf("not available on %s", runtime.GOOS)
44 - }
45 -
46 - for _, tt := range packetConnReadWriteMulticastUDPTests {
47 - c, err := net.ListenPacket("udp6", tt.addr)
48 - if err != nil {
49 - t.Fatal(err)
50 - }
51 - defer c.Close()
52 -
53 - grp := *tt.grp
54 - grp.Port = c.LocalAddr().(*net.UDPAddr).Port
55 - p := ipv6.NewPacketConn(c)
56 - defer p.Close()
57 - if tt.src == nil {
58 - if err := p.JoinGroup(ifi, &grp); err != nil {
59 - t.Fatal(err)
60 - }
61 - defer p.LeaveGroup(ifi, &grp)
62 - } else {
63 - if err := p.JoinSourceSpecificGroup(ifi, &grp, tt.src); err != nil {
64 - switch runtime.GOOS {
65 - case "freebsd", "linux":
66 - default: // platforms that don't support MLDv2 fail here
67 - t.Logf("not supported on %s", runtime.GOOS)
68 - continue
69 - }
70 - t.Fatal(err)
71 - }
72 - defer p.LeaveSourceSpecificGroup(ifi, &grp, tt.src)
73 - }
74 - if err := p.SetMulticastInterface(ifi); err != nil {
75 - t.Fatal(err)
76 - }
77 - if _, err := p.MulticastInterface(); err != nil {
78 - t.Fatal(err)
79 - }
80 - if err := p.SetMulticastLoopback(true); err != nil {
81 - t.Fatal(err)
82 - }
83 - if _, err := p.MulticastLoopback(); err != nil {
84 - t.Fatal(err)
85 - }
86 -
87 - cm := ipv6.ControlMessage{
88 - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced,
89 - Src: net.IPv6loopback,
90 - IfIndex: ifi.Index,
91 - }
92 - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU
93 - wb := []byte("HELLO-R-U-THERE")
94 -
95 - for i, toggle := range []bool{true, false, true} {
96 - if err := p.SetControlMessage(cf, toggle); err != nil {
97 - if nettest.ProtocolNotSupported(err) {
98 - t.Logf("not supported on %s", runtime.GOOS)
99 - continue
100 - }
101 - t.Fatal(err)
102 - }
103 - if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil {
104 - t.Fatal(err)
105 - }
106 - cm.HopLimit = i + 1
107 - if n, err := p.WriteTo(wb, &cm, &grp); err != nil {
108 - t.Fatal(err)
109 - } else if n != len(wb) {
110 - t.Fatal(err)
111 - }
112 - rb := make([]byte, 128)
113 - if n, cm, _, err := p.ReadFrom(rb); err != nil {
114 - t.Fatal(err)
115 - } else if !bytes.Equal(rb[:n], wb) {
116 - t.Fatalf("got %v; want %v", rb[:n], wb)
117 - } else {
118 - t.Logf("rcvd cmsg: %v", cm)
119 - }
120 - }
121 - }
122 -}
123 -
124 -var packetConnReadWriteMulticastICMPTests = []struct {
125 - grp, src *net.IPAddr
126 -}{
127 - {&net.IPAddr{IP: net.ParseIP("ff02::114")}, nil}, // see RFC 4727
128 -
129 - {&net.IPAddr{IP: net.ParseIP("ff30::8000:1")}, &net.IPAddr{IP: net.IPv6loopback}}, // see RFC 5771
130 -}
131 -
132 -func TestPacketConnReadWriteMulticastICMP(t *testing.T) {
133 - switch runtime.GOOS {
134 - case "freebsd": // due to a bug on loopback marking
135 - // See http://www.freebsd.org/cgi/query-pr.cgi?pr=180065.
136 - t.Skipf("not supported on %s", runtime.GOOS)
137 - case "nacl", "plan9", "solaris", "windows":
138 - t.Skipf("not supported on %s", runtime.GOOS)
139 - }
140 - if !supportsIPv6 {
141 - t.Skip("ipv6 is not supported")
142 - }
143 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
144 - t.Skip(m)
145 - }
146 - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagMulticast|net.FlagLoopback)
147 - if ifi == nil {
148 - t.Skipf("not available on %s", runtime.GOOS)
149 - }
150 -
151 - for _, tt := range packetConnReadWriteMulticastICMPTests {
152 - c, err := net.ListenPacket("ip6:ipv6-icmp", "::")
153 - if err != nil {
154 - t.Fatal(err)
155 - }
156 - defer c.Close()
157 -
158 - pshicmp := icmp.IPv6PseudoHeader(c.LocalAddr().(*net.IPAddr).IP, tt.grp.IP)
159 - p := ipv6.NewPacketConn(c)
160 - defer p.Close()
161 - if tt.src == nil {
162 - if err := p.JoinGroup(ifi, tt.grp); err != nil {
163 - t.Fatal(err)
164 - }
165 - defer p.LeaveGroup(ifi, tt.grp)
166 - } else {
167 - if err := p.JoinSourceSpecificGroup(ifi, tt.grp, tt.src); err != nil {
168 - switch runtime.GOOS {
169 - case "freebsd", "linux":
170 - default: // platforms that don't support MLDv2 fail here
171 - t.Logf("not supported on %s", runtime.GOOS)
172 - continue
173 - }
174 - t.Fatal(err)
175 - }
176 - defer p.LeaveSourceSpecificGroup(ifi, tt.grp, tt.src)
177 - }
178 - if err := p.SetMulticastInterface(ifi); err != nil {
179 - t.Fatal(err)
180 - }
181 - if _, err := p.MulticastInterface(); err != nil {
182 - t.Fatal(err)
183 - }
184 - if err := p.SetMulticastLoopback(true); err != nil {
185 - t.Fatal(err)
186 - }
187 - if _, err := p.MulticastLoopback(); err != nil {
188 - t.Fatal(err)
189 - }
190 -
191 - cm := ipv6.ControlMessage{
192 - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced,
193 - Src: net.IPv6loopback,
194 - IfIndex: ifi.Index,
195 - }
196 - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU
197 -
198 - var f ipv6.ICMPFilter
199 - f.SetAll(true)
200 - f.Accept(ipv6.ICMPTypeEchoReply)
201 - if err := p.SetICMPFilter(&f); err != nil {
202 - t.Fatal(err)
203 - }
204 -
205 - var psh []byte
206 - for i, toggle := range []bool{true, false, true} {
207 - if toggle {
208 - psh = nil
209 - if err := p.SetChecksum(true, 2); err != nil {
210 - t.Fatal(err)
211 - }
212 - } else {
213 - psh = pshicmp
214 - // Some platforms never allow to
215 - // disable the kernel checksum
216 - // processing.
217 - p.SetChecksum(false, -1)
218 - }
219 - wb, err := (&icmp.Message{
220 - Type: ipv6.ICMPTypeEchoRequest, Code: 0,
221 - Body: &icmp.Echo{
222 - ID: os.Getpid() & 0xffff, Seq: i + 1,
223 - Data: []byte("HELLO-R-U-THERE"),
224 - },
225 - }).Marshal(psh)
226 - if err != nil {
227 - t.Fatal(err)
228 - }
229 - if err := p.SetControlMessage(cf, toggle); err != nil {
230 - if nettest.ProtocolNotSupported(err) {
231 - t.Logf("not supported on %s", runtime.GOOS)
232 - continue
233 - }
234 - t.Fatal(err)
235 - }
236 - if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil {
237 - t.Fatal(err)
238 - }
239 - cm.HopLimit = i + 1
240 - if n, err := p.WriteTo(wb, &cm, tt.grp); err != nil {
241 - t.Fatal(err)
242 - } else if n != len(wb) {
243 - t.Fatalf("got %v; want %v", n, len(wb))
244 - }
245 - rb := make([]byte, 128)
246 - if n, cm, _, err := p.ReadFrom(rb); err != nil {
247 - switch runtime.GOOS {
248 - case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket
249 - t.Logf("not supported on %s", runtime.GOOS)
250 - continue
251 - }
252 - t.Fatal(err)
253 - } else {
254 - t.Logf("rcvd cmsg: %v", cm)
255 - if m, err := icmp.ParseMessage(iana.ProtocolIPv6ICMP, rb[:n]); err != nil {
256 - t.Fatal(err)
257 - } else if m.Type != ipv6.ICMPTypeEchoReply || m.Code != 0 {
258 - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv6.ICMPTypeEchoReply, 0)
259 - }
260 - }
261 - }
262 - }
263 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/multicastlistener_test.go deleted
-246
@@ -1,246 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6_test
6 -
7 -import (
8 - "fmt"
9 - "net"
10 - "runtime"
11 - "testing"
12 -
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv6"
14 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
15 -)
16 -
17 -var udpMultipleGroupListenerTests = []net.Addr{
18 - &net.UDPAddr{IP: net.ParseIP("ff02::114")}, // see RFC 4727
19 - &net.UDPAddr{IP: net.ParseIP("ff02::1:114")},
20 - &net.UDPAddr{IP: net.ParseIP("ff02::2:114")},
21 -}
22 -
23 -func TestUDPSinglePacketConnWithMultipleGroupListeners(t *testing.T) {
24 - switch runtime.GOOS {
25 - case "nacl", "plan9", "solaris", "windows":
26 - t.Skipf("not supported on %s", runtime.GOOS)
27 - }
28 - if !supportsIPv6 {
29 - t.Skip("ipv6 is not supported")
30 - }
31 -
32 - for _, gaddr := range udpMultipleGroupListenerTests {
33 - c, err := net.ListenPacket("udp6", "[::]:0") // wildcard address with non-reusable port
34 - if err != nil {
35 - t.Fatal(err)
36 - }
37 - defer c.Close()
38 -
39 - p := ipv6.NewPacketConn(c)
40 - var mift []*net.Interface
41 -
42 - ift, err := net.Interfaces()
43 - if err != nil {
44 - t.Fatal(err)
45 - }
46 - for i, ifi := range ift {
47 - if _, ok := nettest.IsMulticastCapable("ip6", &ifi); !ok {
48 - continue
49 - }
50 - if err := p.JoinGroup(&ifi, gaddr); err != nil {
51 - t.Fatal(err)
52 - }
53 - mift = append(mift, &ift[i])
54 - }
55 - for _, ifi := range mift {
56 - if err := p.LeaveGroup(ifi, gaddr); err != nil {
57 - t.Fatal(err)
58 - }
59 - }
60 - }
61 -}
62 -
63 -func TestUDPMultiplePacketConnWithMultipleGroupListeners(t *testing.T) {
64 - switch runtime.GOOS {
65 - case "nacl", "plan9", "solaris", "windows":
66 - t.Skipf("not supported on %s", runtime.GOOS)
67 - }
68 - if !supportsIPv6 {
69 - t.Skip("ipv6 is not supported")
70 - }
71 -
72 - for _, gaddr := range udpMultipleGroupListenerTests {
73 - c1, err := net.ListenPacket("udp6", "[ff02::]:1024") // wildcard address with reusable port
74 - if err != nil {
75 - t.Fatal(err)
76 - }
77 - defer c1.Close()
78 -
79 - c2, err := net.ListenPacket("udp6", "[ff02::]:1024") // wildcard address with reusable port
80 - if err != nil {
81 - t.Fatal(err)
82 - }
83 - defer c2.Close()
84 -
85 - var ps [2]*ipv6.PacketConn
86 - ps[0] = ipv6.NewPacketConn(c1)
87 - ps[1] = ipv6.NewPacketConn(c2)
88 - var mift []*net.Interface
89 -
90 - ift, err := net.Interfaces()
91 - if err != nil {
92 - t.Fatal(err)
93 - }
94 - for i, ifi := range ift {
95 - if _, ok := nettest.IsMulticastCapable("ip6", &ifi); !ok {
96 - continue
97 - }
98 - for _, p := range ps {
99 - if err := p.JoinGroup(&ifi, gaddr); err != nil {
100 - t.Fatal(err)
101 - }
102 - }
103 - mift = append(mift, &ift[i])
104 - }
105 - for _, ifi := range mift {
106 - for _, p := range ps {
107 - if err := p.LeaveGroup(ifi, gaddr); err != nil {
108 - t.Fatal(err)
109 - }
110 - }
111 - }
112 - }
113 -}
114 -
115 -func TestUDPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) {
116 - switch runtime.GOOS {
117 - case "nacl", "plan9", "solaris", "windows":
118 - t.Skipf("not supported on %s", runtime.GOOS)
119 - }
120 - if !supportsIPv6 {
121 - t.Skip("ipv6 is not supported")
122 - }
123 -
124 - gaddr := net.IPAddr{IP: net.ParseIP("ff02::114")} // see RFC 4727
125 - type ml struct {
126 - c *ipv6.PacketConn
127 - ifi *net.Interface
128 - }
129 - var mlt []*ml
130 -
131 - ift, err := net.Interfaces()
132 - if err != nil {
133 - t.Fatal(err)
134 - }
135 - for i, ifi := range ift {
136 - ip, ok := nettest.IsMulticastCapable("ip6", &ifi)
137 - if !ok {
138 - continue
139 - }
140 - c, err := net.ListenPacket("udp6", fmt.Sprintf("[%s%%%s]:1024", ip.String(), ifi.Name)) // unicast address with non-reusable port
141 - if err != nil {
142 - t.Fatal(err)
143 - }
144 - defer c.Close()
145 - p := ipv6.NewPacketConn(c)
146 - if err := p.JoinGroup(&ifi, &gaddr); err != nil {
147 - t.Fatal(err)
148 - }
149 - mlt = append(mlt, &ml{p, &ift[i]})
150 - }
151 - for _, m := range mlt {
152 - if err := m.c.LeaveGroup(m.ifi, &gaddr); err != nil {
153 - t.Fatal(err)
154 - }
155 - }
156 -}
157 -
158 -func TestIPSinglePacketConnWithSingleGroupListener(t *testing.T) {
159 - switch runtime.GOOS {
160 - case "nacl", "plan9", "solaris", "windows":
161 - t.Skipf("not supported on %s", runtime.GOOS)
162 - }
163 - if !supportsIPv6 {
164 - t.Skip("ipv6 is not supported")
165 - }
166 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
167 - t.Skip(m)
168 - }
169 -
170 - c, err := net.ListenPacket("ip6:ipv6-icmp", "::") // wildcard address
171 - if err != nil {
172 - t.Fatal(err)
173 - }
174 - defer c.Close()
175 -
176 - p := ipv6.NewPacketConn(c)
177 - gaddr := net.IPAddr{IP: net.ParseIP("ff02::114")} // see RFC 4727
178 - var mift []*net.Interface
179 -
180 - ift, err := net.Interfaces()
181 - if err != nil {
182 - t.Fatal(err)
183 - }
184 - for i, ifi := range ift {
185 - if _, ok := nettest.IsMulticastCapable("ip6", &ifi); !ok {
186 - continue
187 - }
188 - if err := p.JoinGroup(&ifi, &gaddr); err != nil {
189 - t.Fatal(err)
190 - }
191 - mift = append(mift, &ift[i])
192 - }
193 - for _, ifi := range mift {
194 - if err := p.LeaveGroup(ifi, &gaddr); err != nil {
195 - t.Fatal(err)
196 - }
197 - }
198 -}
199 -
200 -func TestIPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) {
201 - switch runtime.GOOS {
202 - case "darwin", "dragonfly", "openbsd": // platforms that return fe80::1%lo0: bind: can't assign requested address
203 - t.Skipf("not supported on %s", runtime.GOOS)
204 - case "nacl", "plan9", "solaris", "windows":
205 - t.Skipf("not supported on %s", runtime.GOOS)
206 - }
207 - if !supportsIPv6 {
208 - t.Skip("ipv6 is not supported")
209 - }
210 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
211 - t.Skip(m)
212 - }
213 -
214 - gaddr := net.IPAddr{IP: net.ParseIP("ff02::114")} // see RFC 4727
215 - type ml struct {
216 - c *ipv6.PacketConn
217 - ifi *net.Interface
218 - }
219 - var mlt []*ml
220 -
221 - ift, err := net.Interfaces()
222 - if err != nil {
223 - t.Fatal(err)
224 - }
225 - for i, ifi := range ift {
226 - ip, ok := nettest.IsMulticastCapable("ip6", &ifi)
227 - if !ok {
228 - continue
229 - }
230 - c, err := net.ListenPacket("ip6:ipv6-icmp", fmt.Sprintf("%s%%%s", ip.String(), ifi.Name)) // unicast address
231 - if err != nil {
232 - t.Fatal(err)
233 - }
234 - defer c.Close()
235 - p := ipv6.NewPacketConn(c)
236 - if err := p.JoinGroup(&ifi, &gaddr); err != nil {
237 - t.Fatal(err)
238 - }
239 - mlt = append(mlt, &ml{p, &ift[i]})
240 - }
241 - for _, m := range mlt {
242 - if err := m.c.LeaveGroup(m.ifi, &gaddr); err != nil {
243 - t.Fatal(err)
244 - }
245 - }
246 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/multicastsockopt_test.go deleted
-157
@@ -1,157 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6_test
6 -
7 -import (
8 - "net"
9 - "runtime"
10 - "testing"
11 -
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv6"
13 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
14 -)
15 -
16 -var packetConnMulticastSocketOptionTests = []struct {
17 - net, proto, addr string
18 - grp, src net.Addr
19 -}{
20 - {"udp6", "", "[ff02::]:0", &net.UDPAddr{IP: net.ParseIP("ff02::114")}, nil}, // see RFC 4727
21 - {"ip6", ":ipv6-icmp", "::", &net.IPAddr{IP: net.ParseIP("ff02::115")}, nil}, // see RFC 4727
22 -
23 - {"udp6", "", "[ff30::8000:0]:0", &net.UDPAddr{IP: net.ParseIP("ff30::8000:1")}, &net.UDPAddr{IP: net.IPv6loopback}}, // see RFC 5771
24 - {"ip6", ":ipv6-icmp", "::", &net.IPAddr{IP: net.ParseIP("ff30::8000:2")}, &net.IPAddr{IP: net.IPv6loopback}}, // see RFC 5771
25 -}
26 -
27 -func TestPacketConnMulticastSocketOptions(t *testing.T) {
28 - switch runtime.GOOS {
29 - case "nacl", "plan9", "solaris", "windows":
30 - t.Skipf("not supported on %s", runtime.GOOS)
31 - }
32 - if !supportsIPv6 {
33 - t.Skip("ipv6 is not supported")
34 - }
35 - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagMulticast|net.FlagLoopback)
36 - if ifi == nil {
37 - t.Skipf("not available on %s", runtime.GOOS)
38 - }
39 -
40 - m, ok := nettest.SupportsRawIPSocket()
41 - for _, tt := range packetConnMulticastSocketOptionTests {
42 - if tt.net == "ip6" && !ok {
43 - t.Log(m)
44 - continue
45 - }
46 - c, err := net.ListenPacket(tt.net+tt.proto, tt.addr)
47 - if err != nil {
48 - t.Fatal(err)
49 - }
50 - defer c.Close()
51 - p := ipv6.NewPacketConn(c)
52 - defer p.Close()
53 -
54 - if tt.src == nil {
55 - testMulticastSocketOptions(t, p, ifi, tt.grp)
56 - } else {
57 - testSourceSpecificMulticastSocketOptions(t, p, ifi, tt.grp, tt.src)
58 - }
59 - }
60 -}
61 -
62 -type testIPv6MulticastConn interface {
63 - MulticastHopLimit() (int, error)
64 - SetMulticastHopLimit(ttl int) error
65 - MulticastLoopback() (bool, error)
66 - SetMulticastLoopback(bool) error
67 - JoinGroup(*net.Interface, net.Addr) error
68 - LeaveGroup(*net.Interface, net.Addr) error
69 - JoinSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error
70 - LeaveSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error
71 - ExcludeSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error
72 - IncludeSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error
73 -}
74 -
75 -func testMulticastSocketOptions(t *testing.T, c testIPv6MulticastConn, ifi *net.Interface, grp net.Addr) {
76 - const hoplim = 255
77 - if err := c.SetMulticastHopLimit(hoplim); err != nil {
78 - t.Error(err)
79 - return
80 - }
81 - if v, err := c.MulticastHopLimit(); err != nil {
82 - t.Error(err)
83 - return
84 - } else if v != hoplim {
85 - t.Errorf("got %v; want %v", v, hoplim)
86 - return
87 - }
88 -
89 - for _, toggle := range []bool{true, false} {
90 - if err := c.SetMulticastLoopback(toggle); err != nil {
91 - t.Error(err)
92 - return
93 - }
94 - if v, err := c.MulticastLoopback(); err != nil {
95 - t.Error(err)
96 - return
97 - } else if v != toggle {
98 - t.Errorf("got %v; want %v", v, toggle)
99 - return
100 - }
101 - }
102 -
103 - if err := c.JoinGroup(ifi, grp); err != nil {
104 - t.Error(err)
105 - return
106 - }
107 - if err := c.LeaveGroup(ifi, grp); err != nil {
108 - t.Error(err)
109 - return
110 - }
111 -}
112 -
113 -func testSourceSpecificMulticastSocketOptions(t *testing.T, c testIPv6MulticastConn, ifi *net.Interface, grp, src net.Addr) {
114 - // MCAST_JOIN_GROUP -> MCAST_BLOCK_SOURCE -> MCAST_UNBLOCK_SOURCE -> MCAST_LEAVE_GROUP
115 - if err := c.JoinGroup(ifi, grp); err != nil {
116 - t.Error(err)
117 - return
118 - }
119 - if err := c.ExcludeSourceSpecificGroup(ifi, grp, src); err != nil {
120 - switch runtime.GOOS {
121 - case "freebsd", "linux":
122 - default: // platforms that don't support MLDv2 fail here
123 - t.Logf("not supported on %s", runtime.GOOS)
124 - return
125 - }
126 - t.Error(err)
127 - return
128 - }
129 - if err := c.IncludeSourceSpecificGroup(ifi, grp, src); err != nil {
130 - t.Error(err)
131 - return
132 - }
133 - if err := c.LeaveGroup(ifi, grp); err != nil {
134 - t.Error(err)
135 - return
136 - }
137 -
138 - // MCAST_JOIN_SOURCE_GROUP -> MCAST_LEAVE_SOURCE_GROUP
139 - if err := c.JoinSourceSpecificGroup(ifi, grp, src); err != nil {
140 - t.Error(err)
141 - return
142 - }
143 - if err := c.LeaveSourceSpecificGroup(ifi, grp, src); err != nil {
144 - t.Error(err)
145 - return
146 - }
147 -
148 - // MCAST_JOIN_SOURCE_GROUP -> MCAST_LEAVE_GROUP
149 - if err := c.JoinSourceSpecificGroup(ifi, grp, src); err != nil {
150 - t.Error(err)
151 - return
152 - }
153 - if err := c.LeaveGroup(ifi, grp); err != nil {
154 - t.Error(err)
155 - return
156 - }
157 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/payload.go deleted
-15
@@ -1,15 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import "net"
8 -
9 -// A payloadHandler represents the IPv6 datagram payload handler.
10 -type payloadHandler struct {
11 - net.PacketConn
12 - rawOpt
13 -}
14 -
15 -func (c *payloadHandler) ok() bool { return c != nil && c.PacketConn != nil }
Godeps/_workspace/src/golang.org/x/net/ipv6/payload_cmsg.go deleted
-70
@@ -1,70 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build !nacl,!plan9,!windows
6 -
7 -package ipv6
8 -
9 -import (
10 - "net"
11 - "syscall"
12 -)
13 -
14 -// ReadFrom reads a payload of the received IPv6 datagram, from the
15 -// endpoint c, copying the payload into b. It returns the number of
16 -// bytes copied into b, the control message cm and the source address
17 -// src of the received datagram.
18 -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) {
19 - if !c.ok() {
20 - return 0, nil, nil, syscall.EINVAL
21 - }
22 - oob := newControlMessage(&c.rawOpt)
23 - var oobn int
24 - switch c := c.PacketConn.(type) {
25 - case *net.UDPConn:
26 - if n, oobn, _, src, err = c.ReadMsgUDP(b, oob); err != nil {
27 - return 0, nil, nil, err
28 - }
29 - case *net.IPConn:
30 - if n, oobn, _, src, err = c.ReadMsgIP(b, oob); err != nil {
31 - return 0, nil, nil, err
32 - }
33 - default:
34 - return 0, nil, nil, errInvalidConnType
35 - }
36 - if cm, err = parseControlMessage(oob[:oobn]); err != nil {
37 - return 0, nil, nil, err
38 - }
39 - if cm != nil {
40 - cm.Src = netAddrToIP16(src)
41 - }
42 - return
43 -}
44 -
45 -// WriteTo writes a payload of the IPv6 datagram, to the destination
46 -// address dst through the endpoint c, copying the payload from b. It
47 -// returns the number of bytes written. The control message cm allows
48 -// the IPv6 header fields and the datagram path to be specified. The
49 -// cm may be nil if control of the outgoing datagram is not required.
50 -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) {
51 - if !c.ok() {
52 - return 0, syscall.EINVAL
53 - }
54 - oob := marshalControlMessage(cm)
55 - if dst == nil {
56 - return 0, errMissingAddress
57 - }
58 - switch c := c.PacketConn.(type) {
59 - case *net.UDPConn:
60 - n, _, err = c.WriteMsgUDP(b, oob, dst.(*net.UDPAddr))
61 - case *net.IPConn:
62 - n, _, err = c.WriteMsgIP(b, oob, dst.(*net.IPAddr))
63 - default:
64 - return 0, errInvalidConnType
65 - }
66 - if err != nil {
67 - return 0, err
68 - }
69 - return
70 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/payload_nocmsg.go deleted
-41
@@ -1,41 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9 windows
6 -
7 -package ipv6
8 -
9 -import (
10 - "net"
11 - "syscall"
12 -)
13 -
14 -// ReadFrom reads a payload of the received IPv6 datagram, from the
15 -// endpoint c, copying the payload into b. It returns the number of
16 -// bytes copied into b, the control message cm and the source address
17 -// src of the received datagram.
18 -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) {
19 - if !c.ok() {
20 - return 0, nil, nil, syscall.EINVAL
21 - }
22 - if n, src, err = c.PacketConn.ReadFrom(b); err != nil {
23 - return 0, nil, nil, err
24 - }
25 - return
26 -}
27 -
28 -// WriteTo writes a payload of the IPv6 datagram, to the destination
29 -// address dst through the endpoint c, copying the payload from b. It
30 -// returns the number of bytes written. The control message cm allows
31 -// the IPv6 header fields and the datagram path to be specified. The
32 -// cm may be nil if control of the outgoing datagram is not required.
33 -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) {
34 - if !c.ok() {
35 - return 0, syscall.EINVAL
36 - }
37 - if dst == nil {
38 - return 0, errMissingAddress
39 - }
40 - return c.PacketConn.WriteTo(b, dst)
41 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/readwrite_test.go deleted
-185
@@ -1,185 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6_test
6 -
7 -import (
8 - "bytes"
9 - "net"
10 - "runtime"
11 - "sync"
12 - "testing"
13 -
14 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
15 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv6"
16 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
17 -)
18 -
19 -func benchmarkUDPListener() (net.PacketConn, net.Addr, error) {
20 - c, err := net.ListenPacket("udp6", "[::1]:0")
21 - if err != nil {
22 - return nil, nil, err
23 - }
24 - dst, err := net.ResolveUDPAddr("udp6", c.LocalAddr().String())
25 - if err != nil {
26 - c.Close()
27 - return nil, nil, err
28 - }
29 - return c, dst, nil
30 -}
31 -
32 -func BenchmarkReadWriteNetUDP(b *testing.B) {
33 - if !supportsIPv6 {
34 - b.Skip("ipv6 is not supported")
35 - }
36 -
37 - c, dst, err := benchmarkUDPListener()
38 - if err != nil {
39 - b.Fatal(err)
40 - }
41 - defer c.Close()
42 -
43 - wb, rb := []byte("HELLO-R-U-THERE"), make([]byte, 128)
44 - b.ResetTimer()
45 - for i := 0; i < b.N; i++ {
46 - benchmarkReadWriteNetUDP(b, c, wb, rb, dst)
47 - }
48 -}
49 -
50 -func benchmarkReadWriteNetUDP(b *testing.B, c net.PacketConn, wb, rb []byte, dst net.Addr) {
51 - if _, err := c.WriteTo(wb, dst); err != nil {
52 - b.Fatal(err)
53 - }
54 - if _, _, err := c.ReadFrom(rb); err != nil {
55 - b.Fatal(err)
56 - }
57 -}
58 -
59 -func BenchmarkReadWriteIPv6UDP(b *testing.B) {
60 - if !supportsIPv6 {
61 - b.Skip("ipv6 is not supported")
62 - }
63 -
64 - c, dst, err := benchmarkUDPListener()
65 - if err != nil {
66 - b.Fatal(err)
67 - }
68 - defer c.Close()
69 -
70 - p := ipv6.NewPacketConn(c)
71 - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU
72 - if err := p.SetControlMessage(cf, true); err != nil {
73 - b.Fatal(err)
74 - }
75 - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagLoopback)
76 -
77 - wb, rb := []byte("HELLO-R-U-THERE"), make([]byte, 128)
78 - b.ResetTimer()
79 - for i := 0; i < b.N; i++ {
80 - benchmarkReadWriteIPv6UDP(b, p, wb, rb, dst, ifi)
81 - }
82 -}
83 -
84 -func benchmarkReadWriteIPv6UDP(b *testing.B, p *ipv6.PacketConn, wb, rb []byte, dst net.Addr, ifi *net.Interface) {
85 - cm := ipv6.ControlMessage{
86 - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced,
87 - HopLimit: 1,
88 - }
89 - if ifi != nil {
90 - cm.IfIndex = ifi.Index
91 - }
92 - if n, err := p.WriteTo(wb, &cm, dst); err != nil {
93 - b.Fatal(err)
94 - } else if n != len(wb) {
95 - b.Fatalf("got %v; want %v", n, len(wb))
96 - }
97 - if _, _, _, err := p.ReadFrom(rb); err != nil {
98 - b.Fatal(err)
99 - }
100 -}
101 -
102 -func TestPacketConnConcurrentReadWriteUnicastUDP(t *testing.T) {
103 - switch runtime.GOOS {
104 - case "nacl", "plan9", "solaris", "windows":
105 - t.Skipf("not supported on %s", runtime.GOOS)
106 - }
107 - if !supportsIPv6 {
108 - t.Skip("ipv6 is not supported")
109 - }
110 -
111 - c, err := net.ListenPacket("udp6", "[::1]:0")
112 - if err != nil {
113 - t.Fatal(err)
114 - }
115 - defer c.Close()
116 - p := ipv6.NewPacketConn(c)
117 - defer p.Close()
118 -
119 - dst, err := net.ResolveUDPAddr("udp6", c.LocalAddr().String())
120 - if err != nil {
121 - t.Fatal(err)
122 - }
123 -
124 - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagLoopback)
125 - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU
126 - wb := []byte("HELLO-R-U-THERE")
127 -
128 - if err := p.SetControlMessage(cf, true); err != nil { // probe before test
129 - if nettest.ProtocolNotSupported(err) {
130 - t.Skipf("not supported on %s", runtime.GOOS)
131 - }
132 - t.Fatal(err)
133 - }
134 -
135 - var wg sync.WaitGroup
136 - reader := func() {
137 - defer wg.Done()
138 - rb := make([]byte, 128)
139 - if n, cm, _, err := p.ReadFrom(rb); err != nil {
140 - t.Error(err)
141 - return
142 - } else if !bytes.Equal(rb[:n], wb) {
143 - t.Errorf("got %v; want %v", rb[:n], wb)
144 - return
145 - } else {
146 - t.Logf("rcvd cmsg: %v", cm)
147 - }
148 - }
149 - writer := func(toggle bool) {
150 - defer wg.Done()
151 - cm := ipv6.ControlMessage{
152 - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced,
153 - Src: net.IPv6loopback,
154 - }
155 - if ifi != nil {
156 - cm.IfIndex = ifi.Index
157 - }
158 - if err := p.SetControlMessage(cf, toggle); err != nil {
159 - t.Error(err)
160 - return
161 - }
162 - if n, err := p.WriteTo(wb, &cm, dst); err != nil {
163 - t.Error(err)
164 - return
165 - } else if n != len(wb) {
166 - t.Errorf("got %v; want %v", n, len(wb))
167 - return
168 - }
169 - }
170 -
171 - const N = 10
172 - wg.Add(N)
173 - for i := 0; i < N; i++ {
174 - go reader()
175 - }
176 - wg.Add(2 * N)
177 - for i := 0; i < 2*N; i++ {
178 - go writer(i%2 != 0)
179 - }
180 - wg.Add(N)
181 - for i := 0; i < N; i++ {
182 - go reader()
183 - }
184 - wg.Wait()
185 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sockopt.go deleted
-46
@@ -1,46 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -// Sticky socket options
8 -const (
9 - ssoTrafficClass = iota // header field for unicast packet, RFC 3542
10 - ssoHopLimit // header field for unicast packet, RFC 3493
11 - ssoMulticastInterface // outbound interface for multicast packet, RFC 3493
12 - ssoMulticastHopLimit // header field for multicast packet, RFC 3493
13 - ssoMulticastLoopback // loopback for multicast packet, RFC 3493
14 - ssoReceiveTrafficClass // header field on received packet, RFC 3542
15 - ssoReceiveHopLimit // header field on received packet, RFC 2292 or 3542
16 - ssoReceivePacketInfo // incbound or outbound packet path, RFC 2292 or 3542
17 - ssoReceivePathMTU // path mtu, RFC 3542
18 - ssoPathMTU // path mtu, RFC 3542
19 - ssoChecksum // packet checksum, RFC 2292 or 3542
20 - ssoICMPFilter // icmp filter, RFC 2292 or 3542
21 - ssoJoinGroup // any-source multicast, RFC 3493
22 - ssoLeaveGroup // any-source multicast, RFC 3493
23 - ssoJoinSourceGroup // source-specific multicast
24 - ssoLeaveSourceGroup // source-specific multicast
25 - ssoBlockSourceGroup // any-source or source-specific multicast
26 - ssoUnblockSourceGroup // any-source or source-specific multicast
27 - ssoMax
28 -)
29 -
30 -// Sticky socket option value types
31 -const (
32 - ssoTypeInt = iota + 1
33 - ssoTypeInterface
34 - ssoTypeICMPFilter
35 - ssoTypeMTUInfo
36 - ssoTypeIPMreq
37 - ssoTypeGroupReq
38 - ssoTypeGroupSourceReq
39 -)
40 -
41 -// A sockOpt represents a binding for sticky socket option.
42 -type sockOpt struct {
43 - level int // option level
44 - name int // option name, must be equal or greater than 1
45 - typ int // option value type, must be equal or greater than 1
46 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sockopt_asmreq_unix.go deleted
-22
@@ -1,22 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux netbsd openbsd
6 -
7 -package ipv6
8 -
9 -import (
10 - "net"
11 - "os"
12 - "unsafe"
13 -)
14 -
15 -func setsockoptIPMreq(fd int, opt *sockOpt, ifi *net.Interface, grp net.IP) error {
16 - var mreq sysIPv6Mreq
17 - copy(mreq.Multiaddr[:], grp)
18 - if ifi != nil {
19 - mreq.setIfindex(ifi.Index)
20 - }
21 - return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, unsafe.Pointer(&mreq), sysSizeofIPv6Mreq))
22 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sockopt_asmreq_windows.go deleted
-21
@@ -1,21 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import (
8 - "net"
9 - "os"
10 - "syscall"
11 - "unsafe"
12 -)
13 -
14 -func setsockoptIPMreq(fd syscall.Handle, opt *sockOpt, ifi *net.Interface, grp net.IP) error {
15 - var mreq sysIPv6Mreq
16 - copy(mreq.Multiaddr[:], grp)
17 - if ifi != nil {
18 - mreq.setIfindex(ifi.Index)
19 - }
20 - return os.NewSyscallError("setsockopt", syscall.Setsockopt(fd, int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&mreq)), sysSizeofIPv6Mreq))
21 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sockopt_ssmreq_stub.go deleted
-17
@@ -1,17 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build !darwin,!freebsd,!linux
6 -
7 -package ipv6
8 -
9 -import "net"
10 -
11 -func setsockoptGroupReq(fd int, opt *sockOpt, ifi *net.Interface, grp net.IP) error {
12 - return errOpNoSupport
13 -}
14 -
15 -func setsockoptGroupSourceReq(fd int, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error {
16 - return errOpNoSupport
17 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sockopt_ssmreq_unix.go deleted
-31
@@ -1,31 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin freebsd linux
6 -
7 -package ipv6
8 -
9 -import (
10 - "net"
11 - "os"
12 - "unsafe"
13 -)
14 -
15 -func setsockoptGroupReq(fd int, opt *sockOpt, ifi *net.Interface, grp net.IP) error {
16 - var gr sysGroupReq
17 - if ifi != nil {
18 - gr.Interface = uint32(ifi.Index)
19 - }
20 - gr.setGroup(grp)
21 - return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, unsafe.Pointer(&gr), sysSizeofGroupReq))
22 -}
23 -
24 -func setsockoptGroupSourceReq(fd int, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error {
25 - var gsr sysGroupSourceReq
26 - if ifi != nil {
27 - gsr.Interface = uint32(ifi.Index)
28 - }
29 - gsr.setSourceGroup(grp, src)
30 - return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, unsafe.Pointer(&gsr), sysSizeofGroupSourceReq))
31 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sockopt_stub.go deleted
-13
@@ -1,13 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9 solaris
6 -
7 -package ipv6
8 -
9 -import "net"
10 -
11 -func getMTUInfo(fd int, opt *sockOpt) (*net.Interface, int, error) {
12 - return nil, 0, errOpNoSupport
13 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sockopt_test.go deleted
-133
@@ -1,133 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6_test
6 -
7 -import (
8 - "fmt"
9 - "net"
10 - "runtime"
11 - "testing"
12 -
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
14 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv6"
15 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
16 -)
17 -
18 -var supportsIPv6 bool = nettest.SupportsIPv6()
19 -
20 -func TestConnInitiatorPathMTU(t *testing.T) {
21 - switch runtime.GOOS {
22 - case "nacl", "plan9", "solaris", "windows":
23 - t.Skipf("not supported on %s", runtime.GOOS)
24 - }
25 - if !supportsIPv6 {
26 - t.Skip("ipv6 is not supported")
27 - }
28 -
29 - ln, err := net.Listen("tcp6", "[::1]:0")
30 - if err != nil {
31 - t.Fatal(err)
32 - }
33 - defer ln.Close()
34 -
35 - done := make(chan bool)
36 - go acceptor(t, ln, done)
37 -
38 - c, err := net.Dial("tcp6", ln.Addr().String())
39 - if err != nil {
40 - t.Fatal(err)
41 - }
42 - defer c.Close()
43 -
44 - if pmtu, err := ipv6.NewConn(c).PathMTU(); err != nil {
45 - switch runtime.GOOS {
46 - case "darwin": // older darwin kernels don't support IPV6_PATHMTU option
47 - t.Logf("not supported on %s", runtime.GOOS)
48 - default:
49 - t.Fatal(err)
50 - }
51 - } else {
52 - t.Logf("path mtu for %v: %v", c.RemoteAddr(), pmtu)
53 - }
54 -
55 - <-done
56 -}
57 -
58 -func TestConnResponderPathMTU(t *testing.T) {
59 - switch runtime.GOOS {
60 - case "nacl", "plan9", "solaris", "windows":
61 - t.Skipf("not supported on %s", runtime.GOOS)
62 - }
63 - if !supportsIPv6 {
64 - t.Skip("ipv6 is not supported")
65 - }
66 -
67 - ln, err := net.Listen("tcp6", "[::1]:0")
68 - if err != nil {
69 - t.Fatal(err)
70 - }
71 - defer ln.Close()
72 -
73 - done := make(chan bool)
74 - go connector(t, "tcp6", ln.Addr().String(), done)
75 -
76 - c, err := ln.Accept()
77 - if err != nil {
78 - t.Fatal(err)
79 - }
80 - defer c.Close()
81 -
82 - if pmtu, err := ipv6.NewConn(c).PathMTU(); err != nil {
83 - switch runtime.GOOS {
84 - case "darwin": // older darwin kernels don't support IPV6_PATHMTU option
85 - t.Logf("not supported on %s", runtime.GOOS)
86 - default:
87 - t.Fatal(err)
88 - }
89 - } else {
90 - t.Logf("path mtu for %v: %v", c.RemoteAddr(), pmtu)
91 - }
92 -
93 - <-done
94 -}
95 -
96 -func TestPacketConnChecksum(t *testing.T) {
97 - switch runtime.GOOS {
98 - case "nacl", "plan9", "solaris", "windows":
99 - t.Skipf("not supported on %s", runtime.GOOS)
100 - }
101 - if !supportsIPv6 {
102 - t.Skip("ipv6 is not supported")
103 - }
104 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
105 - t.Skip(m)
106 - }
107 -
108 - c, err := net.ListenPacket(fmt.Sprintf("ip6:%d", iana.ProtocolOSPFIGP), "::") // OSPF for IPv6
109 - if err != nil {
110 - t.Fatal(err)
111 - }
112 - defer c.Close()
113 -
114 - p := ipv6.NewPacketConn(c)
115 - offset := 12 // see RFC 5340
116 -
117 - for _, toggle := range []bool{false, true} {
118 - if err := p.SetChecksum(toggle, offset); err != nil {
119 - if toggle {
120 - t.Fatalf("ipv6.PacketConn.SetChecksum(%v, %v) failed: %v", toggle, offset, err)
121 - } else {
122 - // Some platforms never allow to disable the kernel
123 - // checksum processing.
124 - t.Logf("ipv6.PacketConn.SetChecksum(%v, %v) failed: %v", toggle, offset, err)
125 - }
126 - }
127 - if on, offset, err := p.Checksum(); err != nil {
128 - t.Fatal(err)
129 - } else {
130 - t.Logf("kernel checksum processing enabled=%v, offset=%v", on, offset)
131 - }
132 - }
133 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sockopt_unix.go deleted
-122
@@ -1,122 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux netbsd openbsd
6 -
7 -package ipv6
8 -
9 -import (
10 - "net"
11 - "os"
12 - "unsafe"
13 -)
14 -
15 -func getInt(fd int, opt *sockOpt) (int, error) {
16 - if opt.name < 1 || opt.typ != ssoTypeInt {
17 - return 0, errOpNoSupport
18 - }
19 - var i int32
20 - l := sysSockoptLen(4)
21 - if err := getsockopt(fd, opt.level, opt.name, unsafe.Pointer(&i), &l); err != nil {
22 - return 0, os.NewSyscallError("getsockopt", err)
23 - }
24 - return int(i), nil
25 -}
26 -
27 -func setInt(fd int, opt *sockOpt, v int) error {
28 - if opt.name < 1 || opt.typ != ssoTypeInt {
29 - return errOpNoSupport
30 - }
31 - i := int32(v)
32 - return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, unsafe.Pointer(&i), sysSockoptLen(4)))
33 -}
34 -
35 -func getInterface(fd int, opt *sockOpt) (*net.Interface, error) {
36 - if opt.name < 1 || opt.typ != ssoTypeInterface {
37 - return nil, errOpNoSupport
38 - }
39 - var i int32
40 - l := sysSockoptLen(4)
41 - if err := getsockopt(fd, opt.level, opt.name, unsafe.Pointer(&i), &l); err != nil {
42 - return nil, os.NewSyscallError("getsockopt", err)
43 - }
44 - if i == 0 {
45 - return nil, nil
46 - }
47 - ifi, err := net.InterfaceByIndex(int(i))
48 - if err != nil {
49 - return nil, err
50 - }
51 - return ifi, nil
52 -}
53 -
54 -func setInterface(fd int, opt *sockOpt, ifi *net.Interface) error {
55 - if opt.name < 1 || opt.typ != ssoTypeInterface {
56 - return errOpNoSupport
57 - }
58 - var i int32
59 - if ifi != nil {
60 - i = int32(ifi.Index)
61 - }
62 - return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, unsafe.Pointer(&i), sysSockoptLen(4)))
63 -}
64 -
65 -func getICMPFilter(fd int, opt *sockOpt) (*ICMPFilter, error) {
66 - if opt.name < 1 || opt.typ != ssoTypeICMPFilter {
67 - return nil, errOpNoSupport
68 - }
69 - var f ICMPFilter
70 - l := sysSockoptLen(sysSizeofICMPv6Filter)
71 - if err := getsockopt(fd, opt.level, opt.name, unsafe.Pointer(&f.sysICMPv6Filter), &l); err != nil {
72 - return nil, os.NewSyscallError("getsockopt", err)
73 - }
74 - return &f, nil
75 -}
76 -
77 -func setICMPFilter(fd int, opt *sockOpt, f *ICMPFilter) error {
78 - if opt.name < 1 || opt.typ != ssoTypeICMPFilter {
79 - return errOpNoSupport
80 - }
81 - return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, unsafe.Pointer(&f.sysICMPv6Filter), sysSizeofICMPv6Filter))
82 -}
83 -
84 -func getMTUInfo(fd int, opt *sockOpt) (*net.Interface, int, error) {
85 - if opt.name < 1 || opt.typ != ssoTypeMTUInfo {
86 - return nil, 0, errOpNoSupport
87 - }
88 - var mi sysIPv6Mtuinfo
89 - l := sysSockoptLen(sysSizeofIPv6Mtuinfo)
90 - if err := getsockopt(fd, opt.level, opt.name, unsafe.Pointer(&mi), &l); err != nil {
91 - return nil, 0, os.NewSyscallError("getsockopt", err)
92 - }
93 - if mi.Addr.Scope_id == 0 {
94 - return nil, int(mi.Mtu), nil
95 - }
96 - ifi, err := net.InterfaceByIndex(int(mi.Addr.Scope_id))
97 - if err != nil {
98 - return nil, 0, err
99 - }
100 - return ifi, int(mi.Mtu), nil
101 -}
102 -
103 -func setGroup(fd int, opt *sockOpt, ifi *net.Interface, grp net.IP) error {
104 - if opt.name < 1 {
105 - return errOpNoSupport
106 - }
107 - switch opt.typ {
108 - case ssoTypeIPMreq:
109 - return setsockoptIPMreq(fd, opt, ifi, grp)
110 - case ssoTypeGroupReq:
111 - return setsockoptGroupReq(fd, opt, ifi, grp)
112 - default:
113 - return errOpNoSupport
114 - }
115 -}
116 -
117 -func setSourceGroup(fd int, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error {
118 - if opt.name < 1 || opt.typ != ssoTypeGroupSourceReq {
119 - return errOpNoSupport
120 - }
121 - return setsockoptGroupSourceReq(fd, opt, ifi, grp, src)
122 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sockopt_windows.go deleted
-86
@@ -1,86 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import (
8 - "net"
9 - "os"
10 - "syscall"
11 - "unsafe"
12 -)
13 -
14 -func getInt(fd syscall.Handle, opt *sockOpt) (int, error) {
15 - if opt.name < 1 || opt.typ != ssoTypeInt {
16 - return 0, errOpNoSupport
17 - }
18 - var i int32
19 - l := int32(4)
20 - if err := syscall.Getsockopt(fd, int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&i)), &l); err != nil {
21 - return 0, os.NewSyscallError("getsockopt", err)
22 - }
23 - return int(i), nil
24 -}
25 -
26 -func setInt(fd syscall.Handle, opt *sockOpt, v int) error {
27 - if opt.name < 1 || opt.typ != ssoTypeInt {
28 - return errOpNoSupport
29 - }
30 - i := int32(v)
31 - return os.NewSyscallError("setsockopt", syscall.Setsockopt(fd, int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&i)), 4))
32 -}
33 -
34 -func getInterface(fd syscall.Handle, opt *sockOpt) (*net.Interface, error) {
35 - if opt.name < 1 || opt.typ != ssoTypeInterface {
36 - return nil, errOpNoSupport
37 - }
38 - var i int32
39 - l := int32(4)
40 - if err := syscall.Getsockopt(fd, int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&i)), &l); err != nil {
41 - return nil, os.NewSyscallError("getsockopt", err)
42 - }
43 - if i == 0 {
44 - return nil, nil
45 - }
46 - ifi, err := net.InterfaceByIndex(int(i))
47 - if err != nil {
48 - return nil, err
49 - }
50 - return ifi, nil
51 -}
52 -
53 -func setInterface(fd syscall.Handle, opt *sockOpt, ifi *net.Interface) error {
54 - if opt.name < 1 || opt.typ != ssoTypeInterface {
55 - return errOpNoSupport
56 - }
57 - var i int32
58 - if ifi != nil {
59 - i = int32(ifi.Index)
60 - }
61 - return os.NewSyscallError("setsockopt", syscall.Setsockopt(fd, int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&i)), 4))
62 -}
63 -
64 -func getICMPFilter(fd syscall.Handle, opt *sockOpt) (*ICMPFilter, error) {
65 - return nil, errOpNoSupport
66 -}
67 -
68 -func setICMPFilter(fd syscall.Handle, opt *sockOpt, f *ICMPFilter) error {
69 - return errOpNoSupport
70 -}
71 -
72 -func getMTUInfo(fd syscall.Handle, opt *sockOpt) (*net.Interface, int, error) {
73 - return nil, 0, errOpNoSupport
74 -}
75 -
76 -func setGroup(fd syscall.Handle, opt *sockOpt, ifi *net.Interface, grp net.IP) error {
77 - if opt.name < 1 || opt.typ != ssoTypeIPMreq {
78 - return errOpNoSupport
79 - }
80 - return setsockoptIPMreq(fd, opt, ifi, grp)
81 -}
82 -
83 -func setSourceGroup(fd syscall.Handle, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error {
84 - // TODO(mikio): implement this
85 - return errOpNoSupport
86 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sys_bsd.go deleted
-58
@@ -1,58 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build dragonfly netbsd openbsd
6 -
7 -package ipv6
8 -
9 -import (
10 - "net"
11 - "syscall"
12 -
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
14 -)
15 -
16 -type sysSockoptLen int32
17 -
18 -var (
19 - ctlOpts = [ctlMax]ctlOpt{
20 - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass},
21 - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit},
22 - ctlPacketInfo: {sysIPV6_PKTINFO, sysSizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo},
23 - ctlNextHop: {sysIPV6_NEXTHOP, sysSizeofSockaddrInet6, marshalNextHop, parseNextHop},
24 - ctlPathMTU: {sysIPV6_PATHMTU, sysSizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU},
25 - }
26 -
27 - sockOpts = [ssoMax]sockOpt{
28 - ssoTrafficClass: {iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt},
29 - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
30 - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
31 - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
32 - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
33 - ssoReceiveTrafficClass: {iana.ProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt},
34 - ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt},
35 - ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt},
36 - ssoReceivePathMTU: {iana.ProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt},
37 - ssoPathMTU: {iana.ProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo},
38 - ssoChecksum: {iana.ProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt},
39 - ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter},
40 - ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq},
41 - ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq},
42 - }
43 -)
44 -
45 -func (sa *sysSockaddrInet6) setSockaddr(ip net.IP, i int) {
46 - sa.Len = sysSizeofSockaddrInet6
47 - sa.Family = syscall.AF_INET6
48 - copy(sa.Addr[:], ip)
49 - sa.Scope_id = uint32(i)
50 -}
51 -
52 -func (pi *sysInet6Pktinfo) setIfindex(i int) {
53 - pi.Ifindex = uint32(i)
54 -}
55 -
56 -func (mreq *sysIPv6Mreq) setIfindex(i int) {
57 - mreq.Interface = uint32(i)
58 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sys_darwin.go deleted
-135
@@ -1,135 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import (
8 - "net"
9 - "syscall"
10 - "unsafe"
11 -
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
13 -)
14 -
15 -type sysSockoptLen int32
16 -
17 -var (
18 - ctlOpts = [ctlMax]ctlOpt{
19 - ctlHopLimit: {sysIPV6_2292HOPLIMIT, 4, marshal2292HopLimit, parseHopLimit},
20 - ctlPacketInfo: {sysIPV6_2292PKTINFO, sysSizeofInet6Pktinfo, marshal2292PacketInfo, parsePacketInfo},
21 - }
22 -
23 - sockOpts = [ssoMax]sockOpt{
24 - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
25 - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
26 - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
27 - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
28 - ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_2292HOPLIMIT, ssoTypeInt},
29 - ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_2292PKTINFO, ssoTypeInt},
30 - ssoChecksum: {iana.ProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt},
31 - ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter},
32 - ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq},
33 - ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq},
34 - }
35 -)
36 -
37 -func init() {
38 - // Seems like kern.osreldate is veiled on latest OS X. We use
39 - // kern.osrelease instead.
40 - osver, err := syscall.Sysctl("kern.osrelease")
41 - if err != nil {
42 - return
43 - }
44 - var i int
45 - for i = range osver {
46 - if osver[i] == '.' {
47 - break
48 - }
49 - }
50 - // The IP_PKTINFO and protocol-independent multicast API were
51 - // introduced in OS X 10.7 (Darwin 11.0.0). But it looks like
52 - // those features require OS X 10.8 (Darwin 12.0.0) and above.
53 - // See http://support.apple.com/kb/HT1633.
54 - if i > 2 || i == 2 && osver[0] >= '1' && osver[1] >= '2' {
55 - ctlOpts[ctlTrafficClass].name = sysIPV6_TCLASS
56 - ctlOpts[ctlTrafficClass].length = 4
57 - ctlOpts[ctlTrafficClass].marshal = marshalTrafficClass
58 - ctlOpts[ctlTrafficClass].parse = parseTrafficClass
59 - ctlOpts[ctlHopLimit].name = sysIPV6_HOPLIMIT
60 - ctlOpts[ctlHopLimit].marshal = marshalHopLimit
61 - ctlOpts[ctlPacketInfo].name = sysIPV6_PKTINFO
62 - ctlOpts[ctlPacketInfo].marshal = marshalPacketInfo
63 - ctlOpts[ctlNextHop].name = sysIPV6_NEXTHOP
64 - ctlOpts[ctlNextHop].length = sysSizeofSockaddrInet6
65 - ctlOpts[ctlNextHop].marshal = marshalNextHop
66 - ctlOpts[ctlNextHop].parse = parseNextHop
67 - ctlOpts[ctlPathMTU].name = sysIPV6_PATHMTU
68 - ctlOpts[ctlPathMTU].length = sysSizeofIPv6Mtuinfo
69 - ctlOpts[ctlPathMTU].marshal = marshalPathMTU
70 - ctlOpts[ctlPathMTU].parse = parsePathMTU
71 - sockOpts[ssoTrafficClass].level = iana.ProtocolIPv6
72 - sockOpts[ssoTrafficClass].name = sysIPV6_TCLASS
73 - sockOpts[ssoTrafficClass].typ = ssoTypeInt
74 - sockOpts[ssoReceiveTrafficClass].level = iana.ProtocolIPv6
75 - sockOpts[ssoReceiveTrafficClass].name = sysIPV6_RECVTCLASS
76 - sockOpts[ssoReceiveTrafficClass].typ = ssoTypeInt
77 - sockOpts[ssoReceiveHopLimit].name = sysIPV6_RECVHOPLIMIT
78 - sockOpts[ssoReceivePacketInfo].name = sysIPV6_RECVPKTINFO
79 - sockOpts[ssoReceivePathMTU].level = iana.ProtocolIPv6
80 - sockOpts[ssoReceivePathMTU].name = sysIPV6_RECVPATHMTU
81 - sockOpts[ssoReceivePathMTU].typ = ssoTypeInt
82 - sockOpts[ssoPathMTU].level = iana.ProtocolIPv6
83 - sockOpts[ssoPathMTU].name = sysIPV6_PATHMTU
84 - sockOpts[ssoPathMTU].typ = ssoTypeMTUInfo
85 - sockOpts[ssoJoinGroup].name = sysMCAST_JOIN_GROUP
86 - sockOpts[ssoJoinGroup].typ = ssoTypeGroupReq
87 - sockOpts[ssoLeaveGroup].name = sysMCAST_LEAVE_GROUP
88 - sockOpts[ssoLeaveGroup].typ = ssoTypeGroupReq
89 - sockOpts[ssoJoinSourceGroup].level = iana.ProtocolIPv6
90 - sockOpts[ssoJoinSourceGroup].name = sysMCAST_JOIN_SOURCE_GROUP
91 - sockOpts[ssoJoinSourceGroup].typ = ssoTypeGroupSourceReq
92 - sockOpts[ssoLeaveSourceGroup].level = iana.ProtocolIPv6
93 - sockOpts[ssoLeaveSourceGroup].name = sysMCAST_LEAVE_SOURCE_GROUP
94 - sockOpts[ssoLeaveSourceGroup].typ = ssoTypeGroupSourceReq
95 - sockOpts[ssoBlockSourceGroup].level = iana.ProtocolIPv6
96 - sockOpts[ssoBlockSourceGroup].name = sysMCAST_BLOCK_SOURCE
97 - sockOpts[ssoBlockSourceGroup].typ = ssoTypeGroupSourceReq
98 - sockOpts[ssoUnblockSourceGroup].level = iana.ProtocolIPv6
99 - sockOpts[ssoUnblockSourceGroup].name = sysMCAST_UNBLOCK_SOURCE
100 - sockOpts[ssoUnblockSourceGroup].typ = ssoTypeGroupSourceReq
101 - }
102 -}
103 -
104 -func (sa *sysSockaddrInet6) setSockaddr(ip net.IP, i int) {
105 - sa.Len = sysSizeofSockaddrInet6
106 - sa.Family = syscall.AF_INET6
107 - copy(sa.Addr[:], ip)
108 - sa.Scope_id = uint32(i)
109 -}
110 -
111 -func (pi *sysInet6Pktinfo) setIfindex(i int) {
112 - pi.Ifindex = uint32(i)
113 -}
114 -
115 -func (mreq *sysIPv6Mreq) setIfindex(i int) {
116 - mreq.Interface = uint32(i)
117 -}
118 -
119 -func (gr *sysGroupReq) setGroup(grp net.IP) {
120 - sa := (*sysSockaddrInet6)(unsafe.Pointer(&gr.Pad_cgo_0[0]))
121 - sa.Len = sysSizeofSockaddrInet6
122 - sa.Family = syscall.AF_INET6
123 - copy(sa.Addr[:], grp)
124 -}
125 -
126 -func (gsr *sysGroupSourceReq) setSourceGroup(grp, src net.IP) {
127 - sa := (*sysSockaddrInet6)(unsafe.Pointer(&gsr.Pad_cgo_0[0]))
128 - sa.Len = sysSizeofSockaddrInet6
129 - sa.Family = syscall.AF_INET6
130 - copy(sa.Addr[:], grp)
131 - sa = (*sysSockaddrInet6)(unsafe.Pointer(&gsr.Pad_cgo_1[0]))
132 - sa.Len = sysSizeofSockaddrInet6
133 - sa.Family = syscall.AF_INET6
134 - copy(sa.Addr[:], src)
135 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sys_freebsd.go deleted
-79
@@ -1,79 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import (
8 - "net"
9 - "syscall"
10 - "unsafe"
11 -
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
13 -)
14 -
15 -type sysSockoptLen int32
16 -
17 -var (
18 - ctlOpts = [ctlMax]ctlOpt{
19 - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass},
20 - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit},
21 - ctlPacketInfo: {sysIPV6_PKTINFO, sysSizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo},
22 - ctlNextHop: {sysIPV6_NEXTHOP, sysSizeofSockaddrInet6, marshalNextHop, parseNextHop},
23 - ctlPathMTU: {sysIPV6_PATHMTU, sysSizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU},
24 - }
25 -
26 - sockOpts = [ssoMax]sockOpt{
27 - ssoTrafficClass: {iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt},
28 - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
29 - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
30 - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
31 - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
32 - ssoReceiveTrafficClass: {iana.ProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt},
33 - ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt},
34 - ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt},
35 - ssoReceivePathMTU: {iana.ProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt},
36 - ssoPathMTU: {iana.ProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo},
37 - ssoChecksum: {iana.ProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt},
38 - ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter},
39 - ssoJoinGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_GROUP, ssoTypeGroupReq},
40 - ssoLeaveGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_GROUP, ssoTypeGroupReq},
41 - ssoJoinSourceGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq},
42 - ssoLeaveSourceGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq},
43 - ssoBlockSourceGroup: {iana.ProtocolIPv6, sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq},
44 - ssoUnblockSourceGroup: {iana.ProtocolIPv6, sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq},
45 - }
46 -)
47 -
48 -func (sa *sysSockaddrInet6) setSockaddr(ip net.IP, i int) {
49 - sa.Len = sysSizeofSockaddrInet6
50 - sa.Family = syscall.AF_INET6
51 - copy(sa.Addr[:], ip)
52 - sa.Scope_id = uint32(i)
53 -}
54 -
55 -func (pi *sysInet6Pktinfo) setIfindex(i int) {
56 - pi.Ifindex = uint32(i)
57 -}
58 -
59 -func (mreq *sysIPv6Mreq) setIfindex(i int) {
60 - mreq.Interface = uint32(i)
61 -}
62 -
63 -func (gr *sysGroupReq) setGroup(grp net.IP) {
64 - sa := (*sysSockaddrInet6)(unsafe.Pointer(&gr.Group))
65 - sa.Len = sysSizeofSockaddrInet6
66 - sa.Family = syscall.AF_INET6
67 - copy(sa.Addr[:], grp)
68 -}
69 -
70 -func (gsr *sysGroupSourceReq) setSourceGroup(grp, src net.IP) {
71 - sa := (*sysSockaddrInet6)(unsafe.Pointer(&gsr.Group))
72 - sa.Len = sysSizeofSockaddrInet6
73 - sa.Family = syscall.AF_INET6
74 - copy(sa.Addr[:], grp)
75 - sa = (*sysSockaddrInet6)(unsafe.Pointer(&gsr.Source))
76 - sa.Len = sysSizeofSockaddrInet6
77 - sa.Family = syscall.AF_INET6
78 - copy(sa.Addr[:], src)
79 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sys_linux.go deleted
-74
@@ -1,74 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import (
8 - "net"
9 - "syscall"
10 - "unsafe"
11 -
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
13 -)
14 -
15 -type sysSockoptLen int32
16 -
17 -var (
18 - ctlOpts = [ctlMax]ctlOpt{
19 - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass},
20 - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit},
21 - ctlPacketInfo: {sysIPV6_PKTINFO, sysSizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo},
22 - ctlPathMTU: {sysIPV6_PATHMTU, sysSizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU},
23 - }
24 -
25 - sockOpts = [ssoMax]sockOpt{
26 - ssoTrafficClass: {iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt},
27 - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
28 - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
29 - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
30 - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
31 - ssoReceiveTrafficClass: {iana.ProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt},
32 - ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt},
33 - ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt},
34 - ssoReceivePathMTU: {iana.ProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt},
35 - ssoPathMTU: {iana.ProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo},
36 - ssoChecksum: {iana.ProtocolReserved, sysIPV6_CHECKSUM, ssoTypeInt},
37 - ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMPV6_FILTER, ssoTypeICMPFilter},
38 - ssoJoinGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_GROUP, ssoTypeGroupReq},
39 - ssoLeaveGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_GROUP, ssoTypeGroupReq},
40 - ssoJoinSourceGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq},
41 - ssoLeaveSourceGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq},
42 - ssoBlockSourceGroup: {iana.ProtocolIPv6, sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq},
43 - ssoUnblockSourceGroup: {iana.ProtocolIPv6, sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq},
44 - }
45 -)
46 -
47 -func (sa *sysSockaddrInet6) setSockaddr(ip net.IP, i int) {
48 - sa.Family = syscall.AF_INET6
49 - copy(sa.Addr[:], ip)
50 - sa.Scope_id = uint32(i)
51 -}
52 -
53 -func (pi *sysInet6Pktinfo) setIfindex(i int) {
54 - pi.Ifindex = int32(i)
55 -}
56 -
57 -func (mreq *sysIPv6Mreq) setIfindex(i int) {
58 - mreq.Ifindex = int32(i)
59 -}
60 -
61 -func (gr *sysGroupReq) setGroup(grp net.IP) {
62 - sa := (*sysSockaddrInet6)(unsafe.Pointer(&gr.Group))
63 - sa.Family = syscall.AF_INET6
64 - copy(sa.Addr[:], grp)
65 -}
66 -
67 -func (gsr *sysGroupSourceReq) setSourceGroup(grp, src net.IP) {
68 - sa := (*sysSockaddrInet6)(unsafe.Pointer(&gsr.Group))
69 - sa.Family = syscall.AF_INET6
70 - copy(sa.Addr[:], grp)
71 - sa = (*sysSockaddrInet6)(unsafe.Pointer(&gsr.Source))
72 - sa.Family = syscall.AF_INET6
73 - copy(sa.Addr[:], src)
74 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/sys_stub.go deleted
-15
@@ -1,15 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build nacl plan9 solaris
6 -
7 -package ipv6
8 -
9 -type sysSockoptLen int32
10 -
11 -var (
12 - ctlOpts = [ctlMax]ctlOpt{}
13 -
14 - sockOpts = [ssoMax]sockOpt{}
15 -)
Godeps/_workspace/src/golang.org/x/net/ipv6/sys_windows.go deleted
-63
@@ -1,63 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import (
8 - "net"
9 - "syscall"
10 -
11 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
12 -)
13 -
14 -const (
15 - // See ws2tcpip.h.
16 - sysIPV6_UNICAST_HOPS = 0x4
17 - sysIPV6_MULTICAST_IF = 0x9
18 - sysIPV6_MULTICAST_HOPS = 0xa
19 - sysIPV6_MULTICAST_LOOP = 0xb
20 - sysIPV6_JOIN_GROUP = 0xc
21 - sysIPV6_LEAVE_GROUP = 0xd
22 - sysIPV6_PKTINFO = 0x13
23 -
24 - sysSizeofSockaddrInet6 = 0x1c
25 -
26 - sysSizeofIPv6Mreq = 0x14
27 -)
28 -
29 -type sysSockaddrInet6 struct {
30 - Family uint16
31 - Port uint16
32 - Flowinfo uint32
33 - Addr [16]byte /* in6_addr */
34 - Scope_id uint32
35 -}
36 -
37 -type sysIPv6Mreq struct {
38 - Multiaddr [16]byte /* in6_addr */
39 - Interface uint32
40 -}
41 -
42 -var (
43 - ctlOpts = [ctlMax]ctlOpt{}
44 -
45 - sockOpts = [ssoMax]sockOpt{
46 - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt},
47 - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface},
48 - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt},
49 - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt},
50 - ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq},
51 - ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq},
52 - }
53 -)
54 -
55 -func (sa *sysSockaddrInet6) setSockaddr(ip net.IP, i int) {
56 - sa.Family = syscall.AF_INET6
57 - copy(sa.Addr[:], ip)
58 - sa.Scope_id = uint32(i)
59 -}
60 -
61 -func (mreq *sysIPv6Mreq) setIfindex(i int) {
62 - mreq.Interface = uint32(i)
63 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/syscall_linux_386.go deleted
-31
@@ -1,31 +0,0 @@
1 -// Copyright 2009 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6
6 -
7 -import (
8 - "syscall"
9 - "unsafe"
10 -)
11 -
12 -const (
13 - sysGETSOCKOPT = 0xf
14 - sysSETSOCKOPT = 0xe
15 -)
16 -
17 -func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno)
18 -
19 -func getsockopt(fd, level, name int, v unsafe.Pointer, l *sysSockoptLen) error {
20 - if _, errno := socketcall(sysGETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 {
21 - return error(errno)
22 - }
23 - return nil
24 -}
25 -
26 -func setsockopt(fd, level, name int, v unsafe.Pointer, l sysSockoptLen) error {
27 - if _, errno := socketcall(sysSETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 {
28 - return error(errno)
29 - }
30 - return nil
31 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/syscall_unix.go deleted
-26
@@ -1,26 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build darwin dragonfly freebsd linux,amd64 linux,arm linux,ppc64 linux,ppc64le netbsd openbsd
6 -
7 -package ipv6
8 -
9 -import (
10 - "syscall"
11 - "unsafe"
12 -)
13 -
14 -func getsockopt(fd, level, name int, v unsafe.Pointer, l *sysSockoptLen) error {
15 - if _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 {
16 - return error(errno)
17 - }
18 - return nil
19 -}
20 -
21 -func setsockopt(fd, level, name int, v unsafe.Pointer, l sysSockoptLen) error {
22 - if _, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 {
23 - return error(errno)
24 - }
25 - return nil
26 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/thunk_linux_386.s deleted
-8
@@ -1,8 +0,0 @@
1 -// Copyright 2014 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -// +build go1.2
6 -
7 -TEXT ·socketcall(SB),4,$0-36
8 - JMP syscall·socketcall(SB)
Godeps/_workspace/src/golang.org/x/net/ipv6/unicast_test.go deleted
-185
@@ -1,185 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6_test
6 -
7 -import (
8 - "bytes"
9 - "net"
10 - "os"
11 - "runtime"
12 - "testing"
13 - "time"
14 -
15 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
16 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv6"
17 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/icmp"
18 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
19 -)
20 -
21 -func TestPacketConnReadWriteUnicastUDP(t *testing.T) {
22 - switch runtime.GOOS {
23 - case "nacl", "plan9", "solaris", "windows":
24 - t.Skipf("not supported on %s", runtime.GOOS)
25 - }
26 - if !supportsIPv6 {
27 - t.Skip("ipv6 is not supported")
28 - }
29 -
30 - c, err := net.ListenPacket("udp6", "[::1]:0")
31 - if err != nil {
32 - t.Fatal(err)
33 - }
34 - defer c.Close()
35 - p := ipv6.NewPacketConn(c)
36 - defer p.Close()
37 -
38 - dst, err := net.ResolveUDPAddr("udp6", c.LocalAddr().String())
39 - if err != nil {
40 - t.Fatal(err)
41 - }
42 -
43 - cm := ipv6.ControlMessage{
44 - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced,
45 - Src: net.IPv6loopback,
46 - }
47 - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU
48 - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagLoopback)
49 - if ifi != nil {
50 - cm.IfIndex = ifi.Index
51 - }
52 - wb := []byte("HELLO-R-U-THERE")
53 -
54 - for i, toggle := range []bool{true, false, true} {
55 - if err := p.SetControlMessage(cf, toggle); err != nil {
56 - if nettest.ProtocolNotSupported(err) {
57 - t.Skipf("not supported on %s", runtime.GOOS)
58 - }
59 - t.Fatal(err)
60 - }
61 - cm.HopLimit = i + 1
62 - if err := p.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
63 - t.Fatal(err)
64 - }
65 - if n, err := p.WriteTo(wb, &cm, dst); err != nil {
66 - t.Fatal(err)
67 - } else if n != len(wb) {
68 - t.Fatalf("got %v; want %v", n, len(wb))
69 - }
70 - rb := make([]byte, 128)
71 - if err := p.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
72 - t.Fatal(err)
73 - }
74 - if n, cm, _, err := p.ReadFrom(rb); err != nil {
75 - t.Fatal(err)
76 - } else if !bytes.Equal(rb[:n], wb) {
77 - t.Fatalf("got %v; want %v", rb[:n], wb)
78 - } else {
79 - t.Logf("rcvd cmsg: %v", cm)
80 - }
81 - }
82 -}
83 -
84 -func TestPacketConnReadWriteUnicastICMP(t *testing.T) {
85 - switch runtime.GOOS {
86 - case "nacl", "plan9", "solaris", "windows":
87 - t.Skipf("not supported on %s", runtime.GOOS)
88 - }
89 - if !supportsIPv6 {
90 - t.Skip("ipv6 is not supported")
91 - }
92 - if m, ok := nettest.SupportsRawIPSocket(); !ok {
93 - t.Skip(m)
94 - }
95 -
96 - c, err := net.ListenPacket("ip6:ipv6-icmp", "::1")
97 - if err != nil {
98 - t.Fatal(err)
99 - }
100 - defer c.Close()
101 - p := ipv6.NewPacketConn(c)
102 - defer p.Close()
103 -
104 - dst, err := net.ResolveIPAddr("ip6", "::1")
105 - if err != nil {
106 - t.Fatal(err)
107 - }
108 -
109 - pshicmp := icmp.IPv6PseudoHeader(c.LocalAddr().(*net.IPAddr).IP, dst.IP)
110 - cm := ipv6.ControlMessage{
111 - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced,
112 - Src: net.IPv6loopback,
113 - }
114 - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU
115 - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagLoopback)
116 - if ifi != nil {
117 - cm.IfIndex = ifi.Index
118 - }
119 -
120 - var f ipv6.ICMPFilter
121 - f.SetAll(true)
122 - f.Accept(ipv6.ICMPTypeEchoReply)
123 - if err := p.SetICMPFilter(&f); err != nil {
124 - t.Fatal(err)
125 - }
126 -
127 - var psh []byte
128 - for i, toggle := range []bool{true, false, true} {
129 - if toggle {
130 - psh = nil
131 - if err := p.SetChecksum(true, 2); err != nil {
132 - t.Fatal(err)
133 - }
134 - } else {
135 - psh = pshicmp
136 - // Some platforms never allow to disable the
137 - // kernel checksum processing.
138 - p.SetChecksum(false, -1)
139 - }
140 - wb, err := (&icmp.Message{
141 - Type: ipv6.ICMPTypeEchoRequest, Code: 0,
142 - Body: &icmp.Echo{
143 - ID: os.Getpid() & 0xffff, Seq: i + 1,
144 - Data: []byte("HELLO-R-U-THERE"),
145 - },
146 - }).Marshal(psh)
147 - if err != nil {
148 - t.Fatal(err)
149 - }
150 - if err := p.SetControlMessage(cf, toggle); err != nil {
151 - if nettest.ProtocolNotSupported(err) {
152 - t.Skipf("not supported on %s", runtime.GOOS)
153 - }
154 - t.Fatal(err)
155 - }
156 - cm.HopLimit = i + 1
157 - if err := p.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
158 - t.Fatal(err)
159 - }
160 - if n, err := p.WriteTo(wb, &cm, dst); err != nil {
161 - t.Fatal(err)
162 - } else if n != len(wb) {
163 - t.Fatalf("got %v; want %v", n, len(wb))
164 - }
165 - rb := make([]byte, 128)
166 - if err := p.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil {
167 - t.Fatal(err)
168 - }
169 - if n, cm, _, err := p.ReadFrom(rb); err != nil {
170 - switch runtime.GOOS {
171 - case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket
172 - t.Logf("not supported on %s", runtime.GOOS)
173 - continue
174 - }
175 - t.Fatal(err)
176 - } else {
177 - t.Logf("rcvd cmsg: %v", cm)
178 - if m, err := icmp.ParseMessage(iana.ProtocolIPv6ICMP, rb[:n]); err != nil {
179 - t.Fatal(err)
180 - } else if m.Type != ipv6.ICMPTypeEchoReply || m.Code != 0 {
181 - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv6.ICMPTypeEchoReply, 0)
182 - }
183 - }
184 - }
185 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/unicastsockopt_test.go deleted
-111
@@ -1,111 +0,0 @@
1 -// Copyright 2013 The Go Authors. All rights reserved.
2 -// Use of this source code is governed by a BSD-style
3 -// license that can be found in the LICENSE file.
4 -
5 -package ipv6_test
6 -
7 -import (
8 - "net"
9 - "runtime"
10 - "testing"
11 -
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/internal/iana"
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/ipv6"
14 - "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/internal/nettest"
15 -)
16 -
17 -func TestConnUnicastSocketOptions(t *testing.T) {
18 - switch runtime.GOOS {
19 - case "nacl", "plan9", "solaris", "windows":
20 - t.Skipf("not supported on %s", runtime.GOOS)
21 - }
22 - if !supportsIPv6 {
23 - t.Skip("ipv6 is not supported")
24 - }
25 -
26 - ln, err := net.Listen("tcp6", "[::1]:0")
27 - if err != nil {
28 - t.Fatal(err)
29 - }
30 - defer ln.Close()
31 -
32 - done := make(chan bool)
33 - go acceptor(t, ln, done)
34 -
35 - c, err := net.Dial("tcp6", ln.Addr().String())
36 - if err != nil {
37 - t.Fatal(err)
38 - }
39 - defer c.Close()
40 -
41 - testUnicastSocketOptions(t, ipv6.NewConn(c))
42 -
43 - <-done
44 -}
45 -
46 -var packetConnUnicastSocketOptionTests = []struct {
47 - net, proto, addr string
48 -}{
49 - {"udp6", "", "[::1]:0"},
50 - {"ip6", ":ipv6-icmp", "::1"},
51 -}
52 -
53 -func TestPacketConnUnicastSocketOptions(t *testing.T) {
54 - switch runtime.GOOS {
55 - case "nacl", "plan9", "solaris", "windows":
56 - t.Skipf("not supported on %s", runtime.GOOS)
57 - }
58 - if !supportsIPv6 {
59 - t.Skip("ipv6 is not supported")
60 - }
61 -
62 - m, ok := nettest.SupportsRawIPSocket()
63 - for _, tt := range packetConnUnicastSocketOptionTests {
64 - if tt.net == "ip6" && !ok {
65 - t.Log(m)
66 - continue
67 - }
68 - c, err := net.ListenPacket(tt.net+tt.proto, tt.addr)
69 - if err != nil {
70 - t.Fatal(err)
71 - }
72 - defer c.Close()
73 -
74 - testUnicastSocketOptions(t, ipv6.NewPacketConn(c))
75 - }
76 -}
77 -
78 -type testIPv6UnicastConn interface {
79 - TrafficClass() (int, error)
80 - SetTrafficClass(int) error
81 - HopLimit() (int, error)
82 - SetHopLimit(int) error
83 -}
84 -
85 -func testUnicastSocketOptions(t *testing.T, c testIPv6UnicastConn) {
86 - tclass := iana.DiffServCS0 | iana.NotECNTransport
87 - if err := c.SetTrafficClass(tclass); err != nil {
88 - switch runtime.GOOS {
89 - case "darwin": // older darwin kernels don't support IPV6_TCLASS option
90 - t.Logf("not supported on %s", runtime.GOOS)
91 - goto next
92 - }
93 - t.Fatal(err)
94 - }
95 - if v, err := c.TrafficClass(); err != nil {
96 - t.Fatal(err)
97 - } else if v != tclass {
98 - t.Fatalf("got %v; want %v", v, tclass)
99 - }
100 -
101 -next:
102 - hoplim := 255
103 - if err := c.SetHopLimit(hoplim); err != nil {
104 - t.Fatal(err)
105 - }
106 - if v, err := c.HopLimit(); err != nil {
107 - t.Fatal(err)
108 - } else if v != hoplim {
109 - t.Fatalf("got %v; want %v", v, hoplim)
110 - }
111 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_darwin.go deleted
-131
@@ -1,131 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_darwin.go
3 -
4 -package ipv6
5 -
6 -const (
7 - sysIPV6_UNICAST_HOPS = 0x4
8 - sysIPV6_MULTICAST_IF = 0x9
9 - sysIPV6_MULTICAST_HOPS = 0xa
10 - sysIPV6_MULTICAST_LOOP = 0xb
11 - sysIPV6_JOIN_GROUP = 0xc
12 - sysIPV6_LEAVE_GROUP = 0xd
13 -
14 - sysIPV6_PORTRANGE = 0xe
15 - sysICMP6_FILTER = 0x12
16 - sysIPV6_2292PKTINFO = 0x13
17 - sysIPV6_2292HOPLIMIT = 0x14
18 - sysIPV6_2292NEXTHOP = 0x15
19 - sysIPV6_2292HOPOPTS = 0x16
20 - sysIPV6_2292DSTOPTS = 0x17
21 - sysIPV6_2292RTHDR = 0x18
22 -
23 - sysIPV6_2292PKTOPTIONS = 0x19
24 -
25 - sysIPV6_CHECKSUM = 0x1a
26 - sysIPV6_V6ONLY = 0x1b
27 -
28 - sysIPV6_IPSEC_POLICY = 0x1c
29 -
30 - sysIPV6_RECVTCLASS = 0x23
31 - sysIPV6_TCLASS = 0x24
32 -
33 - sysIPV6_RTHDRDSTOPTS = 0x39
34 -
35 - sysIPV6_RECVPKTINFO = 0x3d
36 -
37 - sysIPV6_RECVHOPLIMIT = 0x25
38 - sysIPV6_RECVRTHDR = 0x26
39 - sysIPV6_RECVHOPOPTS = 0x27
40 - sysIPV6_RECVDSTOPTS = 0x28
41 -
42 - sysIPV6_USE_MIN_MTU = 0x2a
43 - sysIPV6_RECVPATHMTU = 0x2b
44 -
45 - sysIPV6_PATHMTU = 0x2c
46 -
47 - sysIPV6_PKTINFO = 0x2e
48 - sysIPV6_HOPLIMIT = 0x2f
49 - sysIPV6_NEXTHOP = 0x30
50 - sysIPV6_HOPOPTS = 0x31
51 - sysIPV6_DSTOPTS = 0x32
52 - sysIPV6_RTHDR = 0x33
53 -
54 - sysIPV6_AUTOFLOWLABEL = 0x3b
55 -
56 - sysIPV6_DONTFRAG = 0x3e
57 -
58 - sysIPV6_PREFER_TEMPADDR = 0x3f
59 -
60 - sysIPV6_MSFILTER = 0x4a
61 - sysMCAST_JOIN_GROUP = 0x50
62 - sysMCAST_LEAVE_GROUP = 0x51
63 - sysMCAST_JOIN_SOURCE_GROUP = 0x52
64 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53
65 - sysMCAST_BLOCK_SOURCE = 0x54
66 - sysMCAST_UNBLOCK_SOURCE = 0x55
67 -
68 - sysIPV6_BOUND_IF = 0x7d
69 -
70 - sysIPV6_PORTRANGE_DEFAULT = 0x0
71 - sysIPV6_PORTRANGE_HIGH = 0x1
72 - sysIPV6_PORTRANGE_LOW = 0x2
73 -
74 - sysSizeofSockaddrStorage = 0x80
75 - sysSizeofSockaddrInet6 = 0x1c
76 - sysSizeofInet6Pktinfo = 0x14
77 - sysSizeofIPv6Mtuinfo = 0x20
78 -
79 - sysSizeofIPv6Mreq = 0x14
80 - sysSizeofGroupReq = 0x84
81 - sysSizeofGroupSourceReq = 0x104
82 -
83 - sysSizeofICMPv6Filter = 0x20
84 -)
85 -
86 -type sysSockaddrStorage struct {
87 - Len uint8
88 - Family uint8
89 - X__ss_pad1 [6]int8
90 - X__ss_align int64
91 - X__ss_pad2 [112]int8
92 -}
93 -
94 -type sysSockaddrInet6 struct {
95 - Len uint8
96 - Family uint8
97 - Port uint16
98 - Flowinfo uint32
99 - Addr [16]byte /* in6_addr */
100 - Scope_id uint32
101 -}
102 -
103 -type sysInet6Pktinfo struct {
104 - Addr [16]byte /* in6_addr */
105 - Ifindex uint32
106 -}
107 -
108 -type sysIPv6Mtuinfo struct {
109 - Addr sysSockaddrInet6
110 - Mtu uint32
111 -}
112 -
113 -type sysIPv6Mreq struct {
114 - Multiaddr [16]byte /* in6_addr */
115 - Interface uint32
116 -}
117 -
118 -type sysICMPv6Filter struct {
119 - Filt [8]uint32
120 -}
121 -
122 -type sysGroupReq struct {
123 - Interface uint32
124 - Pad_cgo_0 [128]byte
125 -}
126 -
127 -type sysGroupSourceReq struct {
128 - Interface uint32
129 - Pad_cgo_0 [128]byte
130 - Pad_cgo_1 [128]byte
131 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_dragonfly.go deleted
-90
@@ -1,90 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_dragonfly.go
3 -
4 -// +build dragonfly
5 -
6 -package ipv6
7 -
8 -const (
9 - sysIPV6_UNICAST_HOPS = 0x4
10 - sysIPV6_MULTICAST_IF = 0x9
11 - sysIPV6_MULTICAST_HOPS = 0xa
12 - sysIPV6_MULTICAST_LOOP = 0xb
13 - sysIPV6_JOIN_GROUP = 0xc
14 - sysIPV6_LEAVE_GROUP = 0xd
15 - sysIPV6_PORTRANGE = 0xe
16 - sysICMP6_FILTER = 0x12
17 -
18 - sysIPV6_CHECKSUM = 0x1a
19 - sysIPV6_V6ONLY = 0x1b
20 -
21 - sysIPV6_IPSEC_POLICY = 0x1c
22 -
23 - sysIPV6_RTHDRDSTOPTS = 0x23
24 - sysIPV6_RECVPKTINFO = 0x24
25 - sysIPV6_RECVHOPLIMIT = 0x25
26 - sysIPV6_RECVRTHDR = 0x26
27 - sysIPV6_RECVHOPOPTS = 0x27
28 - sysIPV6_RECVDSTOPTS = 0x28
29 -
30 - sysIPV6_USE_MIN_MTU = 0x2a
31 - sysIPV6_RECVPATHMTU = 0x2b
32 -
33 - sysIPV6_PATHMTU = 0x2c
34 -
35 - sysIPV6_PKTINFO = 0x2e
36 - sysIPV6_HOPLIMIT = 0x2f
37 - sysIPV6_NEXTHOP = 0x30
38 - sysIPV6_HOPOPTS = 0x31
39 - sysIPV6_DSTOPTS = 0x32
40 - sysIPV6_RTHDR = 0x33
41 -
42 - sysIPV6_RECVTCLASS = 0x39
43 -
44 - sysIPV6_AUTOFLOWLABEL = 0x3b
45 -
46 - sysIPV6_TCLASS = 0x3d
47 - sysIPV6_DONTFRAG = 0x3e
48 -
49 - sysIPV6_PREFER_TEMPADDR = 0x3f
50 -
51 - sysIPV6_PORTRANGE_DEFAULT = 0x0
52 - sysIPV6_PORTRANGE_HIGH = 0x1
53 - sysIPV6_PORTRANGE_LOW = 0x2
54 -
55 - sysSizeofSockaddrInet6 = 0x1c
56 - sysSizeofInet6Pktinfo = 0x14
57 - sysSizeofIPv6Mtuinfo = 0x20
58 -
59 - sysSizeofIPv6Mreq = 0x14
60 -
61 - sysSizeofICMPv6Filter = 0x20
62 -)
63 -
64 -type sysSockaddrInet6 struct {
65 - Len uint8
66 - Family uint8
67 - Port uint16
68 - Flowinfo uint32
69 - Addr [16]byte /* in6_addr */
70 - Scope_id uint32
71 -}
72 -
73 -type sysInet6Pktinfo struct {
74 - Addr [16]byte /* in6_addr */
75 - Ifindex uint32
76 -}
77 -
78 -type sysIPv6Mtuinfo struct {
79 - Addr sysSockaddrInet6
80 - Mtu uint32
81 -}
82 -
83 -type sysIPv6Mreq struct {
84 - Multiaddr [16]byte /* in6_addr */
85 - Interface uint32
86 -}
87 -
88 -type sysICMPv6Filter struct {
89 - Filt [8]uint32
90 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_freebsd_386.go deleted
-122
@@ -1,122 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_freebsd.go
3 -
4 -package ipv6
5 -
6 -const (
7 - sysIPV6_UNICAST_HOPS = 0x4
8 - sysIPV6_MULTICAST_IF = 0x9
9 - sysIPV6_MULTICAST_HOPS = 0xa
10 - sysIPV6_MULTICAST_LOOP = 0xb
11 - sysIPV6_JOIN_GROUP = 0xc
12 - sysIPV6_LEAVE_GROUP = 0xd
13 - sysIPV6_PORTRANGE = 0xe
14 - sysICMP6_FILTER = 0x12
15 -
16 - sysIPV6_CHECKSUM = 0x1a
17 - sysIPV6_V6ONLY = 0x1b
18 -
19 - sysIPV6_IPSEC_POLICY = 0x1c
20 -
21 - sysIPV6_RTHDRDSTOPTS = 0x23
22 -
23 - sysIPV6_RECVPKTINFO = 0x24
24 - sysIPV6_RECVHOPLIMIT = 0x25
25 - sysIPV6_RECVRTHDR = 0x26
26 - sysIPV6_RECVHOPOPTS = 0x27
27 - sysIPV6_RECVDSTOPTS = 0x28
28 -
29 - sysIPV6_USE_MIN_MTU = 0x2a
30 - sysIPV6_RECVPATHMTU = 0x2b
31 -
32 - sysIPV6_PATHMTU = 0x2c
33 -
34 - sysIPV6_PKTINFO = 0x2e
35 - sysIPV6_HOPLIMIT = 0x2f
36 - sysIPV6_NEXTHOP = 0x30
37 - sysIPV6_HOPOPTS = 0x31
38 - sysIPV6_DSTOPTS = 0x32
39 - sysIPV6_RTHDR = 0x33
40 -
41 - sysIPV6_RECVTCLASS = 0x39
42 -
43 - sysIPV6_AUTOFLOWLABEL = 0x3b
44 -
45 - sysIPV6_TCLASS = 0x3d
46 - sysIPV6_DONTFRAG = 0x3e
47 -
48 - sysIPV6_PREFER_TEMPADDR = 0x3f
49 -
50 - sysIPV6_BINDANY = 0x40
51 -
52 - sysIPV6_MSFILTER = 0x4a
53 -
54 - sysMCAST_JOIN_GROUP = 0x50
55 - sysMCAST_LEAVE_GROUP = 0x51
56 - sysMCAST_JOIN_SOURCE_GROUP = 0x52
57 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53
58 - sysMCAST_BLOCK_SOURCE = 0x54
59 - sysMCAST_UNBLOCK_SOURCE = 0x55
60 -
61 - sysIPV6_PORTRANGE_DEFAULT = 0x0
62 - sysIPV6_PORTRANGE_HIGH = 0x1
63 - sysIPV6_PORTRANGE_LOW = 0x2
64 -
65 - sysSizeofSockaddrStorage = 0x80
66 - sysSizeofSockaddrInet6 = 0x1c
67 - sysSizeofInet6Pktinfo = 0x14
68 - sysSizeofIPv6Mtuinfo = 0x20
69 -
70 - sysSizeofIPv6Mreq = 0x14
71 - sysSizeofGroupReq = 0x84
72 - sysSizeofGroupSourceReq = 0x104
73 -
74 - sysSizeofICMPv6Filter = 0x20
75 -)
76 -
77 -type sysSockaddrStorage struct {
78 - Len uint8
79 - Family uint8
80 - X__ss_pad1 [6]int8
81 - X__ss_align int64
82 - X__ss_pad2 [112]int8
83 -}
84 -
85 -type sysSockaddrInet6 struct {
86 - Len uint8
87 - Family uint8
88 - Port uint16
89 - Flowinfo uint32
90 - Addr [16]byte /* in6_addr */
91 - Scope_id uint32
92 -}
93 -
94 -type sysInet6Pktinfo struct {
95 - Addr [16]byte /* in6_addr */
96 - Ifindex uint32
97 -}
98 -
99 -type sysIPv6Mtuinfo struct {
100 - Addr sysSockaddrInet6
101 - Mtu uint32
102 -}
103 -
104 -type sysIPv6Mreq struct {
105 - Multiaddr [16]byte /* in6_addr */
106 - Interface uint32
107 -}
108 -
109 -type sysGroupReq struct {
110 - Interface uint32
111 - Group sysSockaddrStorage
112 -}
113 -
114 -type sysGroupSourceReq struct {
115 - Interface uint32
116 - Group sysSockaddrStorage
117 - Source sysSockaddrStorage
118 -}
119 -
120 -type sysICMPv6Filter struct {
121 - Filt [8]uint32
122 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_freebsd_amd64.go deleted
-124
@@ -1,124 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_freebsd.go
3 -
4 -package ipv6
5 -
6 -const (
7 - sysIPV6_UNICAST_HOPS = 0x4
8 - sysIPV6_MULTICAST_IF = 0x9
9 - sysIPV6_MULTICAST_HOPS = 0xa
10 - sysIPV6_MULTICAST_LOOP = 0xb
11 - sysIPV6_JOIN_GROUP = 0xc
12 - sysIPV6_LEAVE_GROUP = 0xd
13 - sysIPV6_PORTRANGE = 0xe
14 - sysICMP6_FILTER = 0x12
15 -
16 - sysIPV6_CHECKSUM = 0x1a
17 - sysIPV6_V6ONLY = 0x1b
18 -
19 - sysIPV6_IPSEC_POLICY = 0x1c
20 -
21 - sysIPV6_RTHDRDSTOPTS = 0x23
22 -
23 - sysIPV6_RECVPKTINFO = 0x24
24 - sysIPV6_RECVHOPLIMIT = 0x25
25 - sysIPV6_RECVRTHDR = 0x26
26 - sysIPV6_RECVHOPOPTS = 0x27
27 - sysIPV6_RECVDSTOPTS = 0x28
28 -
29 - sysIPV6_USE_MIN_MTU = 0x2a
30 - sysIPV6_RECVPATHMTU = 0x2b
31 -
32 - sysIPV6_PATHMTU = 0x2c
33 -
34 - sysIPV6_PKTINFO = 0x2e
35 - sysIPV6_HOPLIMIT = 0x2f
36 - sysIPV6_NEXTHOP = 0x30
37 - sysIPV6_HOPOPTS = 0x31
38 - sysIPV6_DSTOPTS = 0x32
39 - sysIPV6_RTHDR = 0x33
40 -
41 - sysIPV6_RECVTCLASS = 0x39
42 -
43 - sysIPV6_AUTOFLOWLABEL = 0x3b
44 -
45 - sysIPV6_TCLASS = 0x3d
46 - sysIPV6_DONTFRAG = 0x3e
47 -
48 - sysIPV6_PREFER_TEMPADDR = 0x3f
49 -
50 - sysIPV6_BINDANY = 0x40
51 -
52 - sysIPV6_MSFILTER = 0x4a
53 -
54 - sysMCAST_JOIN_GROUP = 0x50
55 - sysMCAST_LEAVE_GROUP = 0x51
56 - sysMCAST_JOIN_SOURCE_GROUP = 0x52
57 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53
58 - sysMCAST_BLOCK_SOURCE = 0x54
59 - sysMCAST_UNBLOCK_SOURCE = 0x55
60 -
61 - sysIPV6_PORTRANGE_DEFAULT = 0x0
62 - sysIPV6_PORTRANGE_HIGH = 0x1
63 - sysIPV6_PORTRANGE_LOW = 0x2
64 -
65 - sysSizeofSockaddrStorage = 0x80
66 - sysSizeofSockaddrInet6 = 0x1c
67 - sysSizeofInet6Pktinfo = 0x14
68 - sysSizeofIPv6Mtuinfo = 0x20
69 -
70 - sysSizeofIPv6Mreq = 0x14
71 - sysSizeofGroupReq = 0x88
72 - sysSizeofGroupSourceReq = 0x108
73 -
74 - sysSizeofICMPv6Filter = 0x20
75 -)
76 -
77 -type sysSockaddrStorage struct {
78 - Len uint8
79 - Family uint8
80 - X__ss_pad1 [6]int8
81 - X__ss_align int64
82 - X__ss_pad2 [112]int8
83 -}
84 -
85 -type sysSockaddrInet6 struct {
86 - Len uint8
87 - Family uint8
88 - Port uint16
89 - Flowinfo uint32
90 - Addr [16]byte /* in6_addr */
91 - Scope_id uint32
92 -}
93 -
94 -type sysInet6Pktinfo struct {
95 - Addr [16]byte /* in6_addr */
96 - Ifindex uint32
97 -}
98 -
99 -type sysIPv6Mtuinfo struct {
100 - Addr sysSockaddrInet6
101 - Mtu uint32
102 -}
103 -
104 -type sysIPv6Mreq struct {
105 - Multiaddr [16]byte /* in6_addr */
106 - Interface uint32
107 -}
108 -
109 -type sysGroupReq struct {
110 - Interface uint32
111 - Pad_cgo_0 [4]byte
112 - Group sysSockaddrStorage
113 -}
114 -
115 -type sysGroupSourceReq struct {
116 - Interface uint32
117 - Pad_cgo_0 [4]byte
118 - Group sysSockaddrStorage
119 - Source sysSockaddrStorage
120 -}
121 -
122 -type sysICMPv6Filter struct {
123 - Filt [8]uint32
124 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_freebsd_arm.go deleted
-122
@@ -1,122 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_freebsd.go
3 -
4 -package ipv6
5 -
6 -const (
7 - sysIPV6_UNICAST_HOPS = 0x4
8 - sysIPV6_MULTICAST_IF = 0x9
9 - sysIPV6_MULTICAST_HOPS = 0xa
10 - sysIPV6_MULTICAST_LOOP = 0xb
11 - sysIPV6_JOIN_GROUP = 0xc
12 - sysIPV6_LEAVE_GROUP = 0xd
13 - sysIPV6_PORTRANGE = 0xe
14 - sysICMP6_FILTER = 0x12
15 -
16 - sysIPV6_CHECKSUM = 0x1a
17 - sysIPV6_V6ONLY = 0x1b
18 -
19 - sysIPV6_IPSEC_POLICY = 0x1c
20 -
21 - sysIPV6_RTHDRDSTOPTS = 0x23
22 -
23 - sysIPV6_RECVPKTINFO = 0x24
24 - sysIPV6_RECVHOPLIMIT = 0x25
25 - sysIPV6_RECVRTHDR = 0x26
26 - sysIPV6_RECVHOPOPTS = 0x27
27 - sysIPV6_RECVDSTOPTS = 0x28
28 -
29 - sysIPV6_USE_MIN_MTU = 0x2a
30 - sysIPV6_RECVPATHMTU = 0x2b
31 -
32 - sysIPV6_PATHMTU = 0x2c
33 -
34 - sysIPV6_PKTINFO = 0x2e
35 - sysIPV6_HOPLIMIT = 0x2f
36 - sysIPV6_NEXTHOP = 0x30
37 - sysIPV6_HOPOPTS = 0x31
38 - sysIPV6_DSTOPTS = 0x32
39 - sysIPV6_RTHDR = 0x33
40 -
41 - sysIPV6_RECVTCLASS = 0x39
42 -
43 - sysIPV6_AUTOFLOWLABEL = 0x3b
44 -
45 - sysIPV6_TCLASS = 0x3d
46 - sysIPV6_DONTFRAG = 0x3e
47 -
48 - sysIPV6_PREFER_TEMPADDR = 0x3f
49 -
50 - sysIPV6_BINDANY = 0x40
51 -
52 - sysIPV6_MSFILTER = 0x4a
53 -
54 - sysMCAST_JOIN_GROUP = 0x50
55 - sysMCAST_LEAVE_GROUP = 0x51
56 - sysMCAST_JOIN_SOURCE_GROUP = 0x52
57 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53
58 - sysMCAST_BLOCK_SOURCE = 0x54
59 - sysMCAST_UNBLOCK_SOURCE = 0x55
60 -
61 - sysIPV6_PORTRANGE_DEFAULT = 0x0
62 - sysIPV6_PORTRANGE_HIGH = 0x1
63 - sysIPV6_PORTRANGE_LOW = 0x2
64 -
65 - sysSizeofSockaddrStorage = 0x80
66 - sysSizeofSockaddrInet6 = 0x1c
67 - sysSizeofInet6Pktinfo = 0x14
68 - sysSizeofIPv6Mtuinfo = 0x20
69 -
70 - sysSizeofIPv6Mreq = 0x14
71 - sysSizeofGroupReq = 0x84
72 - sysSizeofGroupSourceReq = 0x104
73 -
74 - sysSizeofICMPv6Filter = 0x20
75 -)
76 -
77 -type sysSockaddrStorage struct {
78 - Len uint8
79 - Family uint8
80 - X__ss_pad1 [6]int8
81 - X__ss_align int64
82 - X__ss_pad2 [112]int8
83 -}
84 -
85 -type sysSockaddrInet6 struct {
86 - Len uint8
87 - Family uint8
88 - Port uint16
89 - Flowinfo uint32
90 - Addr [16]byte /* in6_addr */
91 - Scope_id uint32
92 -}
93 -
94 -type sysInet6Pktinfo struct {
95 - Addr [16]byte /* in6_addr */
96 - Ifindex uint32
97 -}
98 -
99 -type sysIPv6Mtuinfo struct {
100 - Addr sysSockaddrInet6
101 - Mtu uint32
102 -}
103 -
104 -type sysIPv6Mreq struct {
105 - Multiaddr [16]byte /* in6_addr */
106 - Interface uint32
107 -}
108 -
109 -type sysGroupReq struct {
110 - Interface uint32
111 - Group sysSockaddrStorage
112 -}
113 -
114 -type sysGroupSourceReq struct {
115 - Interface uint32
116 - Group sysSockaddrStorage
117 - Source sysSockaddrStorage
118 -}
119 -
120 -type sysICMPv6Filter struct {
121 - Filt [8]uint32
122 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_linux_386.go deleted
-152
@@ -1,152 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_linux.go
3 -
4 -package ipv6
5 -
6 -const (
7 - sysIPV6_ADDRFORM = 0x1
8 - sysIPV6_2292PKTINFO = 0x2
9 - sysIPV6_2292HOPOPTS = 0x3
10 - sysIPV6_2292DSTOPTS = 0x4
11 - sysIPV6_2292RTHDR = 0x5
12 - sysIPV6_2292PKTOPTIONS = 0x6
13 - sysIPV6_CHECKSUM = 0x7
14 - sysIPV6_2292HOPLIMIT = 0x8
15 - sysIPV6_NEXTHOP = 0x9
16 - sysIPV6_FLOWINFO = 0xb
17 -
18 - sysIPV6_UNICAST_HOPS = 0x10
19 - sysIPV6_MULTICAST_IF = 0x11
20 - sysIPV6_MULTICAST_HOPS = 0x12
21 - sysIPV6_MULTICAST_LOOP = 0x13
22 - sysIPV6_ADD_MEMBERSHIP = 0x14
23 - sysIPV6_DROP_MEMBERSHIP = 0x15
24 - sysMCAST_JOIN_GROUP = 0x2a
25 - sysMCAST_LEAVE_GROUP = 0x2d
26 - sysMCAST_JOIN_SOURCE_GROUP = 0x2e
27 - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f
28 - sysMCAST_BLOCK_SOURCE = 0x2b
29 - sysMCAST_UNBLOCK_SOURCE = 0x2c
30 - sysMCAST_MSFILTER = 0x30
31 - sysIPV6_ROUTER_ALERT = 0x16
32 - sysIPV6_MTU_DISCOVER = 0x17
33 - sysIPV6_MTU = 0x18
34 - sysIPV6_RECVERR = 0x19
35 - sysIPV6_V6ONLY = 0x1a
36 - sysIPV6_JOIN_ANYCAST = 0x1b
37 - sysIPV6_LEAVE_ANYCAST = 0x1c
38 -
39 - sysIPV6_FLOWLABEL_MGR = 0x20
40 - sysIPV6_FLOWINFO_SEND = 0x21
41 -
42 - sysIPV6_IPSEC_POLICY = 0x22
43 - sysIPV6_XFRM_POLICY = 0x23
44 -
45 - sysIPV6_RECVPKTINFO = 0x31
46 - sysIPV6_PKTINFO = 0x32
47 - sysIPV6_RECVHOPLIMIT = 0x33
48 - sysIPV6_HOPLIMIT = 0x34
49 - sysIPV6_RECVHOPOPTS = 0x35
50 - sysIPV6_HOPOPTS = 0x36
51 - sysIPV6_RTHDRDSTOPTS = 0x37
52 - sysIPV6_RECVRTHDR = 0x38
53 - sysIPV6_RTHDR = 0x39
54 - sysIPV6_RECVDSTOPTS = 0x3a
55 - sysIPV6_DSTOPTS = 0x3b
56 - sysIPV6_RECVPATHMTU = 0x3c
57 - sysIPV6_PATHMTU = 0x3d
58 - sysIPV6_DONTFRAG = 0x3e
59 -
60 - sysIPV6_RECVTCLASS = 0x42
61 - sysIPV6_TCLASS = 0x43
62 -
63 - sysIPV6_ADDR_PREFERENCES = 0x48
64 -
65 - sysIPV6_PREFER_SRC_TMP = 0x1
66 - sysIPV6_PREFER_SRC_PUBLIC = 0x2
67 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100
68 - sysIPV6_PREFER_SRC_COA = 0x4
69 - sysIPV6_PREFER_SRC_HOME = 0x400
70 - sysIPV6_PREFER_SRC_CGA = 0x8
71 - sysIPV6_PREFER_SRC_NONCGA = 0x800
72 -
73 - sysIPV6_MINHOPCOUNT = 0x49
74 -
75 - sysIPV6_ORIGDSTADDR = 0x4a
76 - sysIPV6_RECVORIGDSTADDR = 0x4a
77 - sysIPV6_TRANSPARENT = 0x4b
78 - sysIPV6_UNICAST_IF = 0x4c
79 -
80 - sysICMPV6_FILTER = 0x1
81 -
82 - sysICMPV6_FILTER_BLOCK = 0x1
83 - sysICMPV6_FILTER_PASS = 0x2
84 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3
85 - sysICMPV6_FILTER_PASSONLY = 0x4
86 -
87 - sysSizeofKernelSockaddrStorage = 0x80
88 - sysSizeofSockaddrInet6 = 0x1c
89 - sysSizeofInet6Pktinfo = 0x14
90 - sysSizeofIPv6Mtuinfo = 0x20
91 - sysSizeofIPv6FlowlabelReq = 0x20
92 -
93 - sysSizeofIPv6Mreq = 0x14
94 - sysSizeofGroupReq = 0x84
95 - sysSizeofGroupSourceReq = 0x104
96 -
97 - sysSizeofICMPv6Filter = 0x20
98 -)
99 -
100 -type sysKernelSockaddrStorage struct {
101 - Family uint16
102 - X__data [126]int8
103 -}
104 -
105 -type sysSockaddrInet6 struct {
106 - Family uint16
107 - Port uint16
108 - Flowinfo uint32
109 - Addr [16]byte /* in6_addr */
110 - Scope_id uint32
111 -}
112 -
113 -type sysInet6Pktinfo struct {
114 - Addr [16]byte /* in6_addr */
115 - Ifindex int32
116 -}
117 -
118 -type sysIPv6Mtuinfo struct {
119 - Addr sysSockaddrInet6
120 - Mtu uint32
121 -}
122 -
123 -type sysIPv6FlowlabelReq struct {
124 - Dst [16]byte /* in6_addr */
125 - Label uint32
126 - Action uint8
127 - Share uint8
128 - Flags uint16
129 - Expires uint16
130 - Linger uint16
131 - X__flr_pad uint32
132 -}
133 -
134 -type sysIPv6Mreq struct {
135 - Multiaddr [16]byte /* in6_addr */
136 - Ifindex int32
137 -}
138 -
139 -type sysGroupReq struct {
140 - Interface uint32
141 - Group sysKernelSockaddrStorage
142 -}
143 -
144 -type sysGroupSourceReq struct {
145 - Interface uint32
146 - Group sysKernelSockaddrStorage
147 - Source sysKernelSockaddrStorage
148 -}
149 -
150 -type sysICMPv6Filter struct {
151 - Data [8]uint32
152 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_linux_amd64.go deleted
-154
@@ -1,154 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_linux.go
3 -
4 -package ipv6
5 -
6 -const (
7 - sysIPV6_ADDRFORM = 0x1
8 - sysIPV6_2292PKTINFO = 0x2
9 - sysIPV6_2292HOPOPTS = 0x3
10 - sysIPV6_2292DSTOPTS = 0x4
11 - sysIPV6_2292RTHDR = 0x5
12 - sysIPV6_2292PKTOPTIONS = 0x6
13 - sysIPV6_CHECKSUM = 0x7
14 - sysIPV6_2292HOPLIMIT = 0x8
15 - sysIPV6_NEXTHOP = 0x9
16 - sysIPV6_FLOWINFO = 0xb
17 -
18 - sysIPV6_UNICAST_HOPS = 0x10
19 - sysIPV6_MULTICAST_IF = 0x11
20 - sysIPV6_MULTICAST_HOPS = 0x12
21 - sysIPV6_MULTICAST_LOOP = 0x13
22 - sysIPV6_ADD_MEMBERSHIP = 0x14
23 - sysIPV6_DROP_MEMBERSHIP = 0x15
24 - sysMCAST_JOIN_GROUP = 0x2a
25 - sysMCAST_LEAVE_GROUP = 0x2d
26 - sysMCAST_JOIN_SOURCE_GROUP = 0x2e
27 - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f
28 - sysMCAST_BLOCK_SOURCE = 0x2b
29 - sysMCAST_UNBLOCK_SOURCE = 0x2c
30 - sysMCAST_MSFILTER = 0x30
31 - sysIPV6_ROUTER_ALERT = 0x16
32 - sysIPV6_MTU_DISCOVER = 0x17
33 - sysIPV6_MTU = 0x18
34 - sysIPV6_RECVERR = 0x19
35 - sysIPV6_V6ONLY = 0x1a
36 - sysIPV6_JOIN_ANYCAST = 0x1b
37 - sysIPV6_LEAVE_ANYCAST = 0x1c
38 -
39 - sysIPV6_FLOWLABEL_MGR = 0x20
40 - sysIPV6_FLOWINFO_SEND = 0x21
41 -
42 - sysIPV6_IPSEC_POLICY = 0x22
43 - sysIPV6_XFRM_POLICY = 0x23
44 -
45 - sysIPV6_RECVPKTINFO = 0x31
46 - sysIPV6_PKTINFO = 0x32
47 - sysIPV6_RECVHOPLIMIT = 0x33
48 - sysIPV6_HOPLIMIT = 0x34
49 - sysIPV6_RECVHOPOPTS = 0x35
50 - sysIPV6_HOPOPTS = 0x36
51 - sysIPV6_RTHDRDSTOPTS = 0x37
52 - sysIPV6_RECVRTHDR = 0x38
53 - sysIPV6_RTHDR = 0x39
54 - sysIPV6_RECVDSTOPTS = 0x3a
55 - sysIPV6_DSTOPTS = 0x3b
56 - sysIPV6_RECVPATHMTU = 0x3c
57 - sysIPV6_PATHMTU = 0x3d
58 - sysIPV6_DONTFRAG = 0x3e
59 -
60 - sysIPV6_RECVTCLASS = 0x42
61 - sysIPV6_TCLASS = 0x43
62 -
63 - sysIPV6_ADDR_PREFERENCES = 0x48
64 -
65 - sysIPV6_PREFER_SRC_TMP = 0x1
66 - sysIPV6_PREFER_SRC_PUBLIC = 0x2
67 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100
68 - sysIPV6_PREFER_SRC_COA = 0x4
69 - sysIPV6_PREFER_SRC_HOME = 0x400
70 - sysIPV6_PREFER_SRC_CGA = 0x8
71 - sysIPV6_PREFER_SRC_NONCGA = 0x800
72 -
73 - sysIPV6_MINHOPCOUNT = 0x49
74 -
75 - sysIPV6_ORIGDSTADDR = 0x4a
76 - sysIPV6_RECVORIGDSTADDR = 0x4a
77 - sysIPV6_TRANSPARENT = 0x4b
78 - sysIPV6_UNICAST_IF = 0x4c
79 -
80 - sysICMPV6_FILTER = 0x1
81 -
82 - sysICMPV6_FILTER_BLOCK = 0x1
83 - sysICMPV6_FILTER_PASS = 0x2
84 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3
85 - sysICMPV6_FILTER_PASSONLY = 0x4
86 -
87 - sysSizeofKernelSockaddrStorage = 0x80
88 - sysSizeofSockaddrInet6 = 0x1c
89 - sysSizeofInet6Pktinfo = 0x14
90 - sysSizeofIPv6Mtuinfo = 0x20
91 - sysSizeofIPv6FlowlabelReq = 0x20
92 -
93 - sysSizeofIPv6Mreq = 0x14
94 - sysSizeofGroupReq = 0x88
95 - sysSizeofGroupSourceReq = 0x108
96 -
97 - sysSizeofICMPv6Filter = 0x20
98 -)
99 -
100 -type sysKernelSockaddrStorage struct {
101 - Family uint16
102 - X__data [126]int8
103 -}
104 -
105 -type sysSockaddrInet6 struct {
106 - Family uint16
107 - Port uint16
108 - Flowinfo uint32
109 - Addr [16]byte /* in6_addr */
110 - Scope_id uint32
111 -}
112 -
113 -type sysInet6Pktinfo struct {
114 - Addr [16]byte /* in6_addr */
115 - Ifindex int32
116 -}
117 -
118 -type sysIPv6Mtuinfo struct {
119 - Addr sysSockaddrInet6
120 - Mtu uint32
121 -}
122 -
123 -type sysIPv6FlowlabelReq struct {
124 - Dst [16]byte /* in6_addr */
125 - Label uint32
126 - Action uint8
127 - Share uint8
128 - Flags uint16
129 - Expires uint16
130 - Linger uint16
131 - X__flr_pad uint32
132 -}
133 -
134 -type sysIPv6Mreq struct {
135 - Multiaddr [16]byte /* in6_addr */
136 - Ifindex int32
137 -}
138 -
139 -type sysGroupReq struct {
140 - Interface uint32
141 - Pad_cgo_0 [4]byte
142 - Group sysKernelSockaddrStorage
143 -}
144 -
145 -type sysGroupSourceReq struct {
146 - Interface uint32
147 - Pad_cgo_0 [4]byte
148 - Group sysKernelSockaddrStorage
149 - Source sysKernelSockaddrStorage
150 -}
151 -
152 -type sysICMPv6Filter struct {
153 - Data [8]uint32
154 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_linux_arm.go deleted
-152
@@ -1,152 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_linux.go
3 -
4 -package ipv6
5 -
6 -const (
7 - sysIPV6_ADDRFORM = 0x1
8 - sysIPV6_2292PKTINFO = 0x2
9 - sysIPV6_2292HOPOPTS = 0x3
10 - sysIPV6_2292DSTOPTS = 0x4
11 - sysIPV6_2292RTHDR = 0x5
12 - sysIPV6_2292PKTOPTIONS = 0x6
13 - sysIPV6_CHECKSUM = 0x7
14 - sysIPV6_2292HOPLIMIT = 0x8
15 - sysIPV6_NEXTHOP = 0x9
16 - sysIPV6_FLOWINFO = 0xb
17 -
18 - sysIPV6_UNICAST_HOPS = 0x10
19 - sysIPV6_MULTICAST_IF = 0x11
20 - sysIPV6_MULTICAST_HOPS = 0x12
21 - sysIPV6_MULTICAST_LOOP = 0x13
22 - sysIPV6_ADD_MEMBERSHIP = 0x14
23 - sysIPV6_DROP_MEMBERSHIP = 0x15
24 - sysMCAST_JOIN_GROUP = 0x2a
25 - sysMCAST_LEAVE_GROUP = 0x2d
26 - sysMCAST_JOIN_SOURCE_GROUP = 0x2e
27 - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f
28 - sysMCAST_BLOCK_SOURCE = 0x2b
29 - sysMCAST_UNBLOCK_SOURCE = 0x2c
30 - sysMCAST_MSFILTER = 0x30
31 - sysIPV6_ROUTER_ALERT = 0x16
32 - sysIPV6_MTU_DISCOVER = 0x17
33 - sysIPV6_MTU = 0x18
34 - sysIPV6_RECVERR = 0x19
35 - sysIPV6_V6ONLY = 0x1a
36 - sysIPV6_JOIN_ANYCAST = 0x1b
37 - sysIPV6_LEAVE_ANYCAST = 0x1c
38 -
39 - sysIPV6_FLOWLABEL_MGR = 0x20
40 - sysIPV6_FLOWINFO_SEND = 0x21
41 -
42 - sysIPV6_IPSEC_POLICY = 0x22
43 - sysIPV6_XFRM_POLICY = 0x23
44 -
45 - sysIPV6_RECVPKTINFO = 0x31
46 - sysIPV6_PKTINFO = 0x32
47 - sysIPV6_RECVHOPLIMIT = 0x33
48 - sysIPV6_HOPLIMIT = 0x34
49 - sysIPV6_RECVHOPOPTS = 0x35
50 - sysIPV6_HOPOPTS = 0x36
51 - sysIPV6_RTHDRDSTOPTS = 0x37
52 - sysIPV6_RECVRTHDR = 0x38
53 - sysIPV6_RTHDR = 0x39
54 - sysIPV6_RECVDSTOPTS = 0x3a
55 - sysIPV6_DSTOPTS = 0x3b
56 - sysIPV6_RECVPATHMTU = 0x3c
57 - sysIPV6_PATHMTU = 0x3d
58 - sysIPV6_DONTFRAG = 0x3e
59 -
60 - sysIPV6_RECVTCLASS = 0x42
61 - sysIPV6_TCLASS = 0x43
62 -
63 - sysIPV6_ADDR_PREFERENCES = 0x48
64 -
65 - sysIPV6_PREFER_SRC_TMP = 0x1
66 - sysIPV6_PREFER_SRC_PUBLIC = 0x2
67 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100
68 - sysIPV6_PREFER_SRC_COA = 0x4
69 - sysIPV6_PREFER_SRC_HOME = 0x400
70 - sysIPV6_PREFER_SRC_CGA = 0x8
71 - sysIPV6_PREFER_SRC_NONCGA = 0x800
72 -
73 - sysIPV6_MINHOPCOUNT = 0x49
74 -
75 - sysIPV6_ORIGDSTADDR = 0x4a
76 - sysIPV6_RECVORIGDSTADDR = 0x4a
77 - sysIPV6_TRANSPARENT = 0x4b
78 - sysIPV6_UNICAST_IF = 0x4c
79 -
80 - sysICMPV6_FILTER = 0x1
81 -
82 - sysICMPV6_FILTER_BLOCK = 0x1
83 - sysICMPV6_FILTER_PASS = 0x2
84 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3
85 - sysICMPV6_FILTER_PASSONLY = 0x4
86 -
87 - sysSizeofKernelSockaddrStorage = 0x80
88 - sysSizeofSockaddrInet6 = 0x1c
89 - sysSizeofInet6Pktinfo = 0x14
90 - sysSizeofIPv6Mtuinfo = 0x20
91 - sysSizeofIPv6FlowlabelReq = 0x20
92 -
93 - sysSizeofIPv6Mreq = 0x14
94 - sysSizeofGroupReq = 0x84
95 - sysSizeofGroupSourceReq = 0x104
96 -
97 - sysSizeofICMPv6Filter = 0x20
98 -)
99 -
100 -type sysKernelSockaddrStorage struct {
101 - Family uint16
102 - X__data [126]int8
103 -}
104 -
105 -type sysSockaddrInet6 struct {
106 - Family uint16
107 - Port uint16
108 - Flowinfo uint32
109 - Addr [16]byte /* in6_addr */
110 - Scope_id uint32
111 -}
112 -
113 -type sysInet6Pktinfo struct {
114 - Addr [16]byte /* in6_addr */
115 - Ifindex int32
116 -}
117 -
118 -type sysIPv6Mtuinfo struct {
119 - Addr sysSockaddrInet6
120 - Mtu uint32
121 -}
122 -
123 -type sysIPv6FlowlabelReq struct {
124 - Dst [16]byte /* in6_addr */
125 - Label uint32
126 - Action uint8
127 - Share uint8
128 - Flags uint16
129 - Expires uint16
130 - Linger uint16
131 - X__flr_pad uint32
132 -}
133 -
134 -type sysIPv6Mreq struct {
135 - Multiaddr [16]byte /* in6_addr */
136 - Ifindex int32
137 -}
138 -
139 -type sysGroupReq struct {
140 - Interface uint32
141 - Group sysKernelSockaddrStorage
142 -}
143 -
144 -type sysGroupSourceReq struct {
145 - Interface uint32
146 - Group sysKernelSockaddrStorage
147 - Source sysKernelSockaddrStorage
148 -}
149 -
150 -type sysICMPv6Filter struct {
151 - Data [8]uint32
152 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_linux_arm64.go deleted
-156
@@ -1,156 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_linux.go
3 -
4 -// +build linux,arm64
5 -
6 -package ipv6
7 -
8 -const (
9 - sysIPV6_ADDRFORM = 0x1
10 - sysIPV6_2292PKTINFO = 0x2
11 - sysIPV6_2292HOPOPTS = 0x3
12 - sysIPV6_2292DSTOPTS = 0x4
13 - sysIPV6_2292RTHDR = 0x5
14 - sysIPV6_2292PKTOPTIONS = 0x6
15 - sysIPV6_CHECKSUM = 0x7
16 - sysIPV6_2292HOPLIMIT = 0x8
17 - sysIPV6_NEXTHOP = 0x9
18 - sysIPV6_FLOWINFO = 0xb
19 -
20 - sysIPV6_UNICAST_HOPS = 0x10
21 - sysIPV6_MULTICAST_IF = 0x11
22 - sysIPV6_MULTICAST_HOPS = 0x12
23 - sysIPV6_MULTICAST_LOOP = 0x13
24 - sysIPV6_ADD_MEMBERSHIP = 0x14
25 - sysIPV6_DROP_MEMBERSHIP = 0x15
26 - sysMCAST_JOIN_GROUP = 0x2a
27 - sysMCAST_LEAVE_GROUP = 0x2d
28 - sysMCAST_JOIN_SOURCE_GROUP = 0x2e
29 - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f
30 - sysMCAST_BLOCK_SOURCE = 0x2b
31 - sysMCAST_UNBLOCK_SOURCE = 0x2c
32 - sysMCAST_MSFILTER = 0x30
33 - sysIPV6_ROUTER_ALERT = 0x16
34 - sysIPV6_MTU_DISCOVER = 0x17
35 - sysIPV6_MTU = 0x18
36 - sysIPV6_RECVERR = 0x19
37 - sysIPV6_V6ONLY = 0x1a
38 - sysIPV6_JOIN_ANYCAST = 0x1b
39 - sysIPV6_LEAVE_ANYCAST = 0x1c
40 -
41 - sysIPV6_FLOWLABEL_MGR = 0x20
42 - sysIPV6_FLOWINFO_SEND = 0x21
43 -
44 - sysIPV6_IPSEC_POLICY = 0x22
45 - sysIPV6_XFRM_POLICY = 0x23
46 -
47 - sysIPV6_RECVPKTINFO = 0x31
48 - sysIPV6_PKTINFO = 0x32
49 - sysIPV6_RECVHOPLIMIT = 0x33
50 - sysIPV6_HOPLIMIT = 0x34
51 - sysIPV6_RECVHOPOPTS = 0x35
52 - sysIPV6_HOPOPTS = 0x36
53 - sysIPV6_RTHDRDSTOPTS = 0x37
54 - sysIPV6_RECVRTHDR = 0x38
55 - sysIPV6_RTHDR = 0x39
56 - sysIPV6_RECVDSTOPTS = 0x3a
57 - sysIPV6_DSTOPTS = 0x3b
58 - sysIPV6_RECVPATHMTU = 0x3c
59 - sysIPV6_PATHMTU = 0x3d
60 - sysIPV6_DONTFRAG = 0x3e
61 -
62 - sysIPV6_RECVTCLASS = 0x42
63 - sysIPV6_TCLASS = 0x43
64 -
65 - sysIPV6_ADDR_PREFERENCES = 0x48
66 -
67 - sysIPV6_PREFER_SRC_TMP = 0x1
68 - sysIPV6_PREFER_SRC_PUBLIC = 0x2
69 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100
70 - sysIPV6_PREFER_SRC_COA = 0x4
71 - sysIPV6_PREFER_SRC_HOME = 0x400
72 - sysIPV6_PREFER_SRC_CGA = 0x8
73 - sysIPV6_PREFER_SRC_NONCGA = 0x800
74 -
75 - sysIPV6_MINHOPCOUNT = 0x49
76 -
77 - sysIPV6_ORIGDSTADDR = 0x4a
78 - sysIPV6_RECVORIGDSTADDR = 0x4a
79 - sysIPV6_TRANSPARENT = 0x4b
80 - sysIPV6_UNICAST_IF = 0x4c
81 -
82 - sysICMPV6_FILTER = 0x1
83 -
84 - sysICMPV6_FILTER_BLOCK = 0x1
85 - sysICMPV6_FILTER_PASS = 0x2
86 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3
87 - sysICMPV6_FILTER_PASSONLY = 0x4
88 -
89 - sysSizeofKernelSockaddrStorage = 0x80
90 - sysSizeofSockaddrInet6 = 0x1c
91 - sysSizeofInet6Pktinfo = 0x14
92 - sysSizeofIPv6Mtuinfo = 0x20
93 - sysSizeofIPv6FlowlabelReq = 0x20
94 -
95 - sysSizeofIPv6Mreq = 0x14
96 - sysSizeofGroupReq = 0x88
97 - sysSizeofGroupSourceReq = 0x108
98 -
99 - sysSizeofICMPv6Filter = 0x20
100 -)
101 -
102 -type sysKernelSockaddrStorage struct {
103 - Family uint16
104 - X__data [126]int8
105 -}
106 -
107 -type sysSockaddrInet6 struct {
108 - Family uint16
109 - Port uint16
110 - Flowinfo uint32
111 - Addr [16]byte /* in6_addr */
112 - Scope_id uint32
113 -}
114 -
115 -type sysInet6Pktinfo struct {
116 - Addr [16]byte /* in6_addr */
117 - Ifindex int32
118 -}
119 -
120 -type sysIPv6Mtuinfo struct {
121 - Addr sysSockaddrInet6
122 - Mtu uint32
123 -}
124 -
125 -type sysIPv6FlowlabelReq struct {
126 - Dst [16]byte /* in6_addr */
127 - Label uint32
128 - Action uint8
129 - Share uint8
130 - Flags uint16
131 - Expires uint16
132 - Linger uint16
133 - X__flr_pad uint32
134 -}
135 -
136 -type sysIPv6Mreq struct {
137 - Multiaddr [16]byte /* in6_addr */
138 - Ifindex int32
139 -}
140 -
141 -type sysGroupReq struct {
142 - Interface uint32
143 - Pad_cgo_0 [4]byte
144 - Group sysKernelSockaddrStorage
145 -}
146 -
147 -type sysGroupSourceReq struct {
148 - Interface uint32
149 - Pad_cgo_0 [4]byte
150 - Group sysKernelSockaddrStorage
151 - Source sysKernelSockaddrStorage
152 -}
153 -
154 -type sysICMPv6Filter struct {
155 - Data [8]uint32
156 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_linux_ppc64.go deleted
-156
@@ -1,156 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_linux.go
3 -
4 -// +build linux,ppc64
5 -
6 -package ipv6
7 -
8 -const (
9 - sysIPV6_ADDRFORM = 0x1
10 - sysIPV6_2292PKTINFO = 0x2
11 - sysIPV6_2292HOPOPTS = 0x3
12 - sysIPV6_2292DSTOPTS = 0x4
13 - sysIPV6_2292RTHDR = 0x5
14 - sysIPV6_2292PKTOPTIONS = 0x6
15 - sysIPV6_CHECKSUM = 0x7
16 - sysIPV6_2292HOPLIMIT = 0x8
17 - sysIPV6_NEXTHOP = 0x9
18 - sysIPV6_FLOWINFO = 0xb
19 -
20 - sysIPV6_UNICAST_HOPS = 0x10
21 - sysIPV6_MULTICAST_IF = 0x11
22 - sysIPV6_MULTICAST_HOPS = 0x12
23 - sysIPV6_MULTICAST_LOOP = 0x13
24 - sysIPV6_ADD_MEMBERSHIP = 0x14
25 - sysIPV6_DROP_MEMBERSHIP = 0x15
26 - sysMCAST_JOIN_GROUP = 0x2a
27 - sysMCAST_LEAVE_GROUP = 0x2d
28 - sysMCAST_JOIN_SOURCE_GROUP = 0x2e
29 - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f
30 - sysMCAST_BLOCK_SOURCE = 0x2b
31 - sysMCAST_UNBLOCK_SOURCE = 0x2c
32 - sysMCAST_MSFILTER = 0x30
33 - sysIPV6_ROUTER_ALERT = 0x16
34 - sysIPV6_MTU_DISCOVER = 0x17
35 - sysIPV6_MTU = 0x18
36 - sysIPV6_RECVERR = 0x19
37 - sysIPV6_V6ONLY = 0x1a
38 - sysIPV6_JOIN_ANYCAST = 0x1b
39 - sysIPV6_LEAVE_ANYCAST = 0x1c
40 -
41 - sysIPV6_FLOWLABEL_MGR = 0x20
42 - sysIPV6_FLOWINFO_SEND = 0x21
43 -
44 - sysIPV6_IPSEC_POLICY = 0x22
45 - sysIPV6_XFRM_POLICY = 0x23
46 -
47 - sysIPV6_RECVPKTINFO = 0x31
48 - sysIPV6_PKTINFO = 0x32
49 - sysIPV6_RECVHOPLIMIT = 0x33
50 - sysIPV6_HOPLIMIT = 0x34
51 - sysIPV6_RECVHOPOPTS = 0x35
52 - sysIPV6_HOPOPTS = 0x36
53 - sysIPV6_RTHDRDSTOPTS = 0x37
54 - sysIPV6_RECVRTHDR = 0x38
55 - sysIPV6_RTHDR = 0x39
56 - sysIPV6_RECVDSTOPTS = 0x3a
57 - sysIPV6_DSTOPTS = 0x3b
58 - sysIPV6_RECVPATHMTU = 0x3c
59 - sysIPV6_PATHMTU = 0x3d
60 - sysIPV6_DONTFRAG = 0x3e
61 -
62 - sysIPV6_RECVTCLASS = 0x42
63 - sysIPV6_TCLASS = 0x43
64 -
65 - sysIPV6_ADDR_PREFERENCES = 0x48
66 -
67 - sysIPV6_PREFER_SRC_TMP = 0x1
68 - sysIPV6_PREFER_SRC_PUBLIC = 0x2
69 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100
70 - sysIPV6_PREFER_SRC_COA = 0x4
71 - sysIPV6_PREFER_SRC_HOME = 0x400
72 - sysIPV6_PREFER_SRC_CGA = 0x8
73 - sysIPV6_PREFER_SRC_NONCGA = 0x800
74 -
75 - sysIPV6_MINHOPCOUNT = 0x49
76 -
77 - sysIPV6_ORIGDSTADDR = 0x4a
78 - sysIPV6_RECVORIGDSTADDR = 0x4a
79 - sysIPV6_TRANSPARENT = 0x4b
80 - sysIPV6_UNICAST_IF = 0x4c
81 -
82 - sysICMPV6_FILTER = 0x1
83 -
84 - sysICMPV6_FILTER_BLOCK = 0x1
85 - sysICMPV6_FILTER_PASS = 0x2
86 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3
87 - sysICMPV6_FILTER_PASSONLY = 0x4
88 -
89 - sysSizeofKernelSockaddrStorage = 0x80
90 - sysSizeofSockaddrInet6 = 0x1c
91 - sysSizeofInet6Pktinfo = 0x14
92 - sysSizeofIPv6Mtuinfo = 0x20
93 - sysSizeofIPv6FlowlabelReq = 0x20
94 -
95 - sysSizeofIPv6Mreq = 0x14
96 - sysSizeofGroupReq = 0x88
97 - sysSizeofGroupSourceReq = 0x108
98 -
99 - sysSizeofICMPv6Filter = 0x20
100 -)
101 -
102 -type sysKernelSockaddrStorage struct {
103 - Family uint16
104 - X__data [126]int8
105 -}
106 -
107 -type sysSockaddrInet6 struct {
108 - Family uint16
109 - Port uint16
110 - Flowinfo uint32
111 - Addr [16]byte /* in6_addr */
112 - Scope_id uint32
113 -}
114 -
115 -type sysInet6Pktinfo struct {
116 - Addr [16]byte /* in6_addr */
117 - Ifindex int32
118 -}
119 -
120 -type sysIPv6Mtuinfo struct {
121 - Addr sysSockaddrInet6
122 - Mtu uint32
123 -}
124 -
125 -type sysIPv6FlowlabelReq struct {
126 - Dst [16]byte /* in6_addr */
127 - Label uint32
128 - Action uint8
129 - Share uint8
130 - Flags uint16
131 - Expires uint16
132 - Linger uint16
133 - X__flr_pad uint32
134 -}
135 -
136 -type sysIPv6Mreq struct {
137 - Multiaddr [16]byte /* in6_addr */
138 - Ifindex int32
139 -}
140 -
141 -type sysGroupReq struct {
142 - Interface uint32
143 - Pad_cgo_0 [4]byte
144 - Group sysKernelSockaddrStorage
145 -}
146 -
147 -type sysGroupSourceReq struct {
148 - Interface uint32
149 - Pad_cgo_0 [4]byte
150 - Group sysKernelSockaddrStorage
151 - Source sysKernelSockaddrStorage
152 -}
153 -
154 -type sysICMPv6Filter struct {
155 - Data [8]uint32
156 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_linux_ppc64le.go deleted
-156
@@ -1,156 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_linux.go
3 -
4 -// +build linux,ppc64le
5 -
6 -package ipv6
7 -
8 -const (
9 - sysIPV6_ADDRFORM = 0x1
10 - sysIPV6_2292PKTINFO = 0x2
11 - sysIPV6_2292HOPOPTS = 0x3
12 - sysIPV6_2292DSTOPTS = 0x4
13 - sysIPV6_2292RTHDR = 0x5
14 - sysIPV6_2292PKTOPTIONS = 0x6
15 - sysIPV6_CHECKSUM = 0x7
16 - sysIPV6_2292HOPLIMIT = 0x8
17 - sysIPV6_NEXTHOP = 0x9
18 - sysIPV6_FLOWINFO = 0xb
19 -
20 - sysIPV6_UNICAST_HOPS = 0x10
21 - sysIPV6_MULTICAST_IF = 0x11
22 - sysIPV6_MULTICAST_HOPS = 0x12
23 - sysIPV6_MULTICAST_LOOP = 0x13
24 - sysIPV6_ADD_MEMBERSHIP = 0x14
25 - sysIPV6_DROP_MEMBERSHIP = 0x15
26 - sysMCAST_JOIN_GROUP = 0x2a
27 - sysMCAST_LEAVE_GROUP = 0x2d
28 - sysMCAST_JOIN_SOURCE_GROUP = 0x2e
29 - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f
30 - sysMCAST_BLOCK_SOURCE = 0x2b
31 - sysMCAST_UNBLOCK_SOURCE = 0x2c
32 - sysMCAST_MSFILTER = 0x30
33 - sysIPV6_ROUTER_ALERT = 0x16
34 - sysIPV6_MTU_DISCOVER = 0x17
35 - sysIPV6_MTU = 0x18
36 - sysIPV6_RECVERR = 0x19
37 - sysIPV6_V6ONLY = 0x1a
38 - sysIPV6_JOIN_ANYCAST = 0x1b
39 - sysIPV6_LEAVE_ANYCAST = 0x1c
40 -
41 - sysIPV6_FLOWLABEL_MGR = 0x20
42 - sysIPV6_FLOWINFO_SEND = 0x21
43 -
44 - sysIPV6_IPSEC_POLICY = 0x22
45 - sysIPV6_XFRM_POLICY = 0x23
46 -
47 - sysIPV6_RECVPKTINFO = 0x31
48 - sysIPV6_PKTINFO = 0x32
49 - sysIPV6_RECVHOPLIMIT = 0x33
50 - sysIPV6_HOPLIMIT = 0x34
51 - sysIPV6_RECVHOPOPTS = 0x35
52 - sysIPV6_HOPOPTS = 0x36
53 - sysIPV6_RTHDRDSTOPTS = 0x37
54 - sysIPV6_RECVRTHDR = 0x38
55 - sysIPV6_RTHDR = 0x39
56 - sysIPV6_RECVDSTOPTS = 0x3a
57 - sysIPV6_DSTOPTS = 0x3b
58 - sysIPV6_RECVPATHMTU = 0x3c
59 - sysIPV6_PATHMTU = 0x3d
60 - sysIPV6_DONTFRAG = 0x3e
61 -
62 - sysIPV6_RECVTCLASS = 0x42
63 - sysIPV6_TCLASS = 0x43
64 -
65 - sysIPV6_ADDR_PREFERENCES = 0x48
66 -
67 - sysIPV6_PREFER_SRC_TMP = 0x1
68 - sysIPV6_PREFER_SRC_PUBLIC = 0x2
69 - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = 0x100
70 - sysIPV6_PREFER_SRC_COA = 0x4
71 - sysIPV6_PREFER_SRC_HOME = 0x400
72 - sysIPV6_PREFER_SRC_CGA = 0x8
73 - sysIPV6_PREFER_SRC_NONCGA = 0x800
74 -
75 - sysIPV6_MINHOPCOUNT = 0x49
76 -
77 - sysIPV6_ORIGDSTADDR = 0x4a
78 - sysIPV6_RECVORIGDSTADDR = 0x4a
79 - sysIPV6_TRANSPARENT = 0x4b
80 - sysIPV6_UNICAST_IF = 0x4c
81 -
82 - sysICMPV6_FILTER = 0x1
83 -
84 - sysICMPV6_FILTER_BLOCK = 0x1
85 - sysICMPV6_FILTER_PASS = 0x2
86 - sysICMPV6_FILTER_BLOCKOTHERS = 0x3
87 - sysICMPV6_FILTER_PASSONLY = 0x4
88 -
89 - sysSizeofKernelSockaddrStorage = 0x80
90 - sysSizeofSockaddrInet6 = 0x1c
91 - sysSizeofInet6Pktinfo = 0x14
92 - sysSizeofIPv6Mtuinfo = 0x20
93 - sysSizeofIPv6FlowlabelReq = 0x20
94 -
95 - sysSizeofIPv6Mreq = 0x14
96 - sysSizeofGroupReq = 0x88
97 - sysSizeofGroupSourceReq = 0x108
98 -
99 - sysSizeofICMPv6Filter = 0x20
100 -)
101 -
102 -type sysKernelSockaddrStorage struct {
103 - Family uint16
104 - X__data [126]int8
105 -}
106 -
107 -type sysSockaddrInet6 struct {
108 - Family uint16
109 - Port uint16
110 - Flowinfo uint32
111 - Addr [16]byte /* in6_addr */
112 - Scope_id uint32
113 -}
114 -
115 -type sysInet6Pktinfo struct {
116 - Addr [16]byte /* in6_addr */
117 - Ifindex int32
118 -}
119 -
120 -type sysIPv6Mtuinfo struct {
121 - Addr sysSockaddrInet6
122 - Mtu uint32
123 -}
124 -
125 -type sysIPv6FlowlabelReq struct {
126 - Dst [16]byte /* in6_addr */
127 - Label uint32
128 - Action uint8
129 - Share uint8
130 - Flags uint16
131 - Expires uint16
132 - Linger uint16
133 - X__flr_pad uint32
134 -}
135 -
136 -type sysIPv6Mreq struct {
137 - Multiaddr [16]byte /* in6_addr */
138 - Ifindex int32
139 -}
140 -
141 -type sysGroupReq struct {
142 - Interface uint32
143 - Pad_cgo_0 [4]byte
144 - Group sysKernelSockaddrStorage
145 -}
146 -
147 -type sysGroupSourceReq struct {
148 - Interface uint32
149 - Pad_cgo_0 [4]byte
150 - Group sysKernelSockaddrStorage
151 - Source sysKernelSockaddrStorage
152 -}
153 -
154 -type sysICMPv6Filter struct {
155 - Data [8]uint32
156 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_netbsd.go deleted
-84
@@ -1,84 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_netbsd.go
3 -
4 -package ipv6
5 -
6 -const (
7 - sysIPV6_UNICAST_HOPS = 0x4
8 - sysIPV6_MULTICAST_IF = 0x9
9 - sysIPV6_MULTICAST_HOPS = 0xa
10 - sysIPV6_MULTICAST_LOOP = 0xb
11 - sysIPV6_JOIN_GROUP = 0xc
12 - sysIPV6_LEAVE_GROUP = 0xd
13 - sysIPV6_PORTRANGE = 0xe
14 - sysICMP6_FILTER = 0x12
15 -
16 - sysIPV6_CHECKSUM = 0x1a
17 - sysIPV6_V6ONLY = 0x1b
18 -
19 - sysIPV6_IPSEC_POLICY = 0x1c
20 -
21 - sysIPV6_RTHDRDSTOPTS = 0x23
22 -
23 - sysIPV6_RECVPKTINFO = 0x24
24 - sysIPV6_RECVHOPLIMIT = 0x25
25 - sysIPV6_RECVRTHDR = 0x26
26 - sysIPV6_RECVHOPOPTS = 0x27
27 - sysIPV6_RECVDSTOPTS = 0x28
28 -
29 - sysIPV6_USE_MIN_MTU = 0x2a
30 - sysIPV6_RECVPATHMTU = 0x2b
31 - sysIPV6_PATHMTU = 0x2c
32 -
33 - sysIPV6_PKTINFO = 0x2e
34 - sysIPV6_HOPLIMIT = 0x2f
35 - sysIPV6_NEXTHOP = 0x30
36 - sysIPV6_HOPOPTS = 0x31
37 - sysIPV6_DSTOPTS = 0x32
38 - sysIPV6_RTHDR = 0x33
39 -
40 - sysIPV6_RECVTCLASS = 0x39
41 -
42 - sysIPV6_TCLASS = 0x3d
43 - sysIPV6_DONTFRAG = 0x3e
44 -
45 - sysIPV6_PORTRANGE_DEFAULT = 0x0
46 - sysIPV6_PORTRANGE_HIGH = 0x1
47 - sysIPV6_PORTRANGE_LOW = 0x2
48 -
49 - sysSizeofSockaddrInet6 = 0x1c
50 - sysSizeofInet6Pktinfo = 0x14
51 - sysSizeofIPv6Mtuinfo = 0x20
52 -
53 - sysSizeofIPv6Mreq = 0x14
54 -
55 - sysSizeofICMPv6Filter = 0x20
56 -)
57 -
58 -type sysSockaddrInet6 struct {
59 - Len uint8
60 - Family uint8
61 - Port uint16
62 - Flowinfo uint32
63 - Addr [16]byte /* in6_addr */
64 - Scope_id uint32
65 -}
66 -
67 -type sysInet6Pktinfo struct {
68 - Addr [16]byte /* in6_addr */
69 - Ifindex uint32
70 -}
71 -
72 -type sysIPv6Mtuinfo struct {
73 - Addr sysSockaddrInet6
74 - Mtu uint32
75 -}
76 -
77 -type sysIPv6Mreq struct {
78 - Multiaddr [16]byte /* in6_addr */
79 - Interface uint32
80 -}
81 -
82 -type sysICMPv6Filter struct {
83 - Filt [8]uint32
84 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_openbsd.go deleted
-93
@@ -1,93 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_openbsd.go
3 -
4 -package ipv6
5 -
6 -const (
7 - sysIPV6_UNICAST_HOPS = 0x4
8 - sysIPV6_MULTICAST_IF = 0x9
9 - sysIPV6_MULTICAST_HOPS = 0xa
10 - sysIPV6_MULTICAST_LOOP = 0xb
11 - sysIPV6_JOIN_GROUP = 0xc
12 - sysIPV6_LEAVE_GROUP = 0xd
13 - sysIPV6_PORTRANGE = 0xe
14 - sysICMP6_FILTER = 0x12
15 -
16 - sysIPV6_CHECKSUM = 0x1a
17 - sysIPV6_V6ONLY = 0x1b
18 -
19 - sysIPV6_RTHDRDSTOPTS = 0x23
20 -
21 - sysIPV6_RECVPKTINFO = 0x24
22 - sysIPV6_RECVHOPLIMIT = 0x25
23 - sysIPV6_RECVRTHDR = 0x26
24 - sysIPV6_RECVHOPOPTS = 0x27
25 - sysIPV6_RECVDSTOPTS = 0x28
26 -
27 - sysIPV6_USE_MIN_MTU = 0x2a
28 - sysIPV6_RECVPATHMTU = 0x2b
29 -
30 - sysIPV6_PATHMTU = 0x2c
31 -
32 - sysIPV6_PKTINFO = 0x2e
33 - sysIPV6_HOPLIMIT = 0x2f
34 - sysIPV6_NEXTHOP = 0x30
35 - sysIPV6_HOPOPTS = 0x31
36 - sysIPV6_DSTOPTS = 0x32
37 - sysIPV6_RTHDR = 0x33
38 -
39 - sysIPV6_AUTH_LEVEL = 0x35
40 - sysIPV6_ESP_TRANS_LEVEL = 0x36
41 - sysIPV6_ESP_NETWORK_LEVEL = 0x37
42 - sysIPSEC6_OUTSA = 0x38
43 - sysIPV6_RECVTCLASS = 0x39
44 -
45 - sysIPV6_AUTOFLOWLABEL = 0x3b
46 - sysIPV6_IPCOMP_LEVEL = 0x3c
47 -
48 - sysIPV6_TCLASS = 0x3d
49 - sysIPV6_DONTFRAG = 0x3e
50 - sysIPV6_PIPEX = 0x3f
51 -
52 - sysIPV6_RTABLE = 0x1021
53 -
54 - sysIPV6_PORTRANGE_DEFAULT = 0x0
55 - sysIPV6_PORTRANGE_HIGH = 0x1
56 - sysIPV6_PORTRANGE_LOW = 0x2
57 -
58 - sysSizeofSockaddrInet6 = 0x1c
59 - sysSizeofInet6Pktinfo = 0x14
60 - sysSizeofIPv6Mtuinfo = 0x20
61 -
62 - sysSizeofIPv6Mreq = 0x14
63 -
64 - sysSizeofICMPv6Filter = 0x20
65 -)
66 -
67 -type sysSockaddrInet6 struct {
68 - Len uint8
69 - Family uint8
70 - Port uint16
71 - Flowinfo uint32
72 - Addr [16]byte /* in6_addr */
73 - Scope_id uint32
74 -}
75 -
76 -type sysInet6Pktinfo struct {
77 - Addr [16]byte /* in6_addr */
78 - Ifindex uint32
79 -}
80 -
81 -type sysIPv6Mtuinfo struct {
82 - Addr sysSockaddrInet6
83 - Mtu uint32
84 -}
85 -
86 -type sysIPv6Mreq struct {
87 - Multiaddr [16]byte /* in6_addr */
88 - Interface uint32
89 -}
90 -
91 -type sysICMPv6Filter struct {
92 - Filt [8]uint32
93 -}
Godeps/_workspace/src/golang.org/x/net/ipv6/zsys_solaris.go deleted
-105
@@ -1,105 +0,0 @@
1 -// Created by cgo -godefs - DO NOT EDIT
2 -// cgo -godefs defs_solaris.go
3 -
4 -// +build solaris
5 -
6 -package ipv6
7 -
8 -const (
9 - sysIPV6_UNICAST_HOPS = 0x5
10 - sysIPV6_MULTICAST_IF = 0x6
11 - sysIPV6_MULTICAST_HOPS = 0x7
12 - sysIPV6_MULTICAST_LOOP = 0x8
13 - sysIPV6_JOIN_GROUP = 0x9
14 - sysIPV6_LEAVE_GROUP = 0xa
15 -
16 - sysIPV6_PKTINFO = 0xb
17 -
18 - sysIPV6_HOPLIMIT = 0xc
19 - sysIPV6_NEXTHOP = 0xd
20 - sysIPV6_HOPOPTS = 0xe
21 - sysIPV6_DSTOPTS = 0xf
22 -
23 - sysIPV6_RTHDR = 0x10
24 - sysIPV6_RTHDRDSTOPTS = 0x11
25 -
26 - sysIPV6_RECVPKTINFO = 0x12
27 - sysIPV6_RECVHOPLIMIT = 0x13
28 - sysIPV6_RECVHOPOPTS = 0x14
29 -
30 - sysIPV6_RECVRTHDR = 0x16
31 -
32 - sysIPV6_RECVRTHDRDSTOPTS = 0x17
33 -
34 - sysIPV6_CHECKSUM = 0x18
35 - sysIPV6_RECVTCLASS = 0x19
36 - sysIPV6_USE_MIN_MTU = 0x20
37 - sysIPV6_DONTFRAG = 0x21
38 - sysIPV6_SEC_OPT = 0x22
39 - sysIPV6_SRC_PREFERENCES = 0x23
40 - sysIPV6_RECVPATHMTU = 0x24
41 - sysIPV6_PATHMTU = 0x25
42 - sysIPV6_TCLASS = 0x26
43 - sysIPV6_V6ONLY = 0x27
44 -
45 - sysIPV6_RECVDSTOPTS = 0x28
46 -
47 - sysIPV6_PREFER_SRC_HOME = 0x1
48 - sysIPV6_PREFER_SRC_COA = 0x2
49 - sysIPV6_PREFER_SRC_PUBLIC = 0x4
50 - sysIPV6_PREFER_SRC_TMP = 0x8
51 - sysIPV6_PREFER_SRC_NONCGA = 0x10
52 - sysIPV6_PREFER_SRC_CGA = 0x20
53 -
54 - sysIPV6_PREFER_SRC_MIPMASK = 0x3
55 - sysIPV6_PREFER_SRC_MIPDEFAULT = 0x1
56 - sysIPV6_PREFER_SRC_TMPMASK = 0xc
57 - sysIPV6_PREFER_SRC_TMPDEFAULT = 0x4
58 - sysIPV6_PREFER_SRC_CGAMASK = 0x30
59 - sysIPV6_PREFER_SRC_CGADEFAULT = 0x10
60 -
61 - sysIPV6_PREFER_SRC_MASK = 0x3f
62 -
63 - sysIPV6_PREFER_SRC_DEFAULT = 0x15
64 -
65 - sysIPV6_BOUND_IF = 0x41
66 - sysIPV6_UNSPEC_SRC = 0x42
67 -
68 - sysICMP6_FILTER = 0x1
69 -
70 - sysSizeofSockaddrInet6 = 0x20
71 - sysSizeofInet6Pktinfo = 0x14
72 - sysSizeofIPv6Mtuinfo = 0x24
73 -
74 - sysSizeofIPv6Mreq = 0x14
75 -
76 - sysSizeofICMPv6Filter = 0x20
77 -)
78 -
79 -type sysSockaddrInet6 struct {
80 - Family uint16
81 - Port uint16
82 - Flowinfo uint32
83 - Addr [16]byte /* in6_addr */
84 - Scope_id uint32
85 - X__sin6_src_id uint32
86 -}
87 -
88 -type sysInet6Pktinfo struct {
89 - Addr [16]byte /* in6_addr */
90 - Ifindex uint32
91 -}
92 -
93 -type sysIPv6Mtuinfo struct {
94 - Addr sysSockaddrInet6
95 - Mtu uint32
96 -}
97 -
98 -type sysIPv6Mreq struct {
99 - Multiaddr [16]byte /* in6_addr */
100 - Interface uint32
101 -}
102 -
103 -type sysICMPv6Filter struct {
104 - X__icmp6_filt [8]uint32
105 -}
blocks/key/key.go
+1 -1
@@ -5,7 +5,7 @@ import (
5 "fmt"
6
7 ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
8 - b58 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
8 + b58 "gx/ipfs/QmT8rehPR3F6bmwL6zjUN8XpiDBFFpMP2myPdC6ApsWfJf/go-base58"
9 mh "gx/ipfs/QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku/go-multihash"
10 )
11
core/commands/id.go
+1 -1
@@ -8,7 +8,7 @@ import (
8 "io"
9 "strings"
10
11 - b58 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
11 + b58 "gx/ipfs/QmT8rehPR3F6bmwL6zjUN8XpiDBFFpMP2myPdC6ApsWfJf/go-base58"
12
13 cmds "github.com/ipfs/go-ipfs/commands"
14 core "github.com/ipfs/go-ipfs/core"
core/core.go
+1 -1
@@ -17,10 +17,10 @@ import (
17 "time"
18
19 ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
20 - b58 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
20 diag "github.com/ipfs/go-ipfs/diagnostics"
21 mamask "gx/ipfs/QmPwfFAHUmvWDucLHRS9Xz2Kb1TNX2cY4LJ7pQjg9kVcae/multiaddr-filter"
22 goprocess "gx/ipfs/QmQopLATEYMNg7dVqZRNDfeE2S1yKy8zrRh5xnYiuqeZBn/goprocess"
23 + b58 "gx/ipfs/QmT8rehPR3F6bmwL6zjUN8XpiDBFFpMP2myPdC6ApsWfJf/go-base58"
24 context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
25 logging "gx/ipfs/Qmazh5oNUVsDZTs2g59rq8aYQqwpss8tcUWQzor5sCCEuH/go-log"
26 ic "gx/ipfs/QmccGfZs3rzku8Bv6sTPH3bMUKD1EVod8srgRjt5csdmva/go-libp2p/p2p/crypto"
path/path.go
+1 -1
@@ -7,7 +7,7 @@ import (
7
8 key "github.com/ipfs/go-ipfs/blocks/key"
9
10 - b58 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
10 + b58 "gx/ipfs/QmT8rehPR3F6bmwL6zjUN8XpiDBFFpMP2myPdC6ApsWfJf/go-base58"
11 mh "gx/ipfs/QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku/go-multihash"
12 )
13
test/Makefile
+1 -1
@@ -4,7 +4,7 @@ IPFS_ROOT = ../
4 IPFS_CMD = ../cmd/ipfs
5 RANDOM_SRC = ../Godeps/_workspace/src/github.com/jbenet/go-random
6 RANDOM_FILES_SRC = ../Godeps/_workspace/src/github.com/jbenet/go-random-files
7 -MULTIHASH_SRC = ../Godeps/_workspace/src/github.com/jbenet/go-multihash
7 +MULTIHASH_SRC = ../../../../gx/ipfs/QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku/go-multihash
8 IPTB_SRC = ./dependencies/iptb
9 POLLENDPOINT_SRC= ../thirdparty/pollEndpoint
10 GOSLEEP_SRC = ./dependencies/go-sleep
vendor/dir-index-html-v1.0.0/README.md deleted
-6
@@ -1,6 +0,0 @@
1 -# dir-index-html
2 -
3 -directory listing html for go-ipfs gateways.
4 -
5 -![](http://gateway.ipfs.io/ipfs/Qmf82jUC9ZuoSTCNY55hyx3HmiDed3WnhFD5PC7CTSPmC2/cap.png)
6 -
vendor/dir-index-html-v1.0.0/dir-index-uncat.html deleted
-62
@@ -1,62 +0,0 @@
1 -<!DOCTYPE html>
2 -<html>
3 -<head>
4 - <meta charset="utf-8" />
5 - <!-- TODO: seed these - maybe like the starter ex or the webui? -->
6 - <link rel="stylesheet" href="/ipfs/QmXB7PLRWH6bCiwrGh2MrBBjNkLv3mY3JdYXCikYZSwLED/bootstrap.min.css"/>
7 - <!-- helper to construct this is here: https://github.com/cryptix/exp/blob/master/imgesToCSSData/convert.go -->
8 - <link rel="stylesheet" href="/ipfs/QmXB7PLRWH6bCiwrGh2MrBBjNkLv3mY3JdYXCikYZSwLED/icons.css">
9 - <style>
10 - .narrow {width: 0px;}
11 - .padding { margin: 100px;}
12 - #header {
13 - background: #000;
14 - }
15 - #logo {
16 - height: 25px;
17 - margin: 10px;
18 - }
19 - .ipfs-icon {
20 - width:16px;
21 - }
22 - </style>
23 - <title>{{ .Path }}</title>
24 -</head>
25 -<body>
26 - <div id="header" class="row">
27 - <div class="col-xs-2">
28 - <div id="logo" class="ipfs-logo">&nbsp;</div>
29 - </div>
30 - </div>
31 - <br/>
32 - <div class="col-xs-12">
33 - <div class="panel panel-default">
34 - <div class="panel-heading">
35 - <strong>Index of {{ .Path }}</strong>
36 - </div>
37 - <table class="table table-striped">
38 - <tr>
39 - <td class="narrow">
40 - <div class="ipfs-icon ipfs-_blank">&nbsp;</div>
41 - </td>
42 - <td class="padding">
43 - <a href="{{.BackLink}}">..</a>
44 - </td>
45 - <td></td>
46 - </tr>
47 - {{ range .Listing }}
48 - <tr>
49 - <td>
50 - <div class="ipfs-icon {{iconFromExt .Name}}">&nbsp;</div>
51 - </td>
52 - <td>
53 - <a href="{{ .Path }}">{{ .Name }}</a>
54 - </td>
55 - <td>{{ .Size }}</td>
56 - </tr>
57 - {{ end }}
58 - </table>
59 - </div>
60 - </div>
61 -</body>
62 -</html>
vendor/dir-index-html-v1.0.0/dir-index.html deleted
-60
@@ -1,60 +0,0 @@
1 -<!DOCTYPE html>
2 -<html>
3 -<head>
4 - <meta charset="utf-8" />
5 - <!-- helper to construct this is here: https://github.com/cryptix/exp/blob/master/imgesToCSSData/convert.go -->
6 - <style>
7 - html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}a{background-color:transparent}a:active,a:hover{outline:0}strong{font-weight:700}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}table{border-spacing:0;border-collapse:collapse}td{padding:0}/*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */@media print{*,:after,:before{color:#000!important;text-shadow:none!important;background:0 0!important;-webkit-box-shadow:none!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}tr{page-break-inside:avoid}.table{border-collapse:collapse!important}.table td{background-color:#fff!important}}@font-face{font-family:'Glyphicons Halflings';src:url(../fonts/glyphicons-halflings-regular.eot);src:url(../fonts/glyphicons-halflings-regular.eot?#iefix) format('embedded-opentype'),url(../fonts/glyphicons-halflings-regular.woff2) format('woff2'),url(../fonts/glyphicons-halflings-regular.woff) format('woff'),url(../fonts/glyphicons-halflings-regular.ttf) format('truetype'),url(../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular) format('svg')}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}:after,:before{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:10px;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.42857143;color:#333;background-color:#fff}a{color:#337ab7;text-decoration:none}a:focus,a:hover{color:#23527c;text-decoration:underline}a:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.row{margin-right:-15px;margin-left:-15px}.col-xs-12,.col-xs-2{position:relative;min-height:1px;padding-right:15px;padding-left:15px}.col-xs-12,.col-xs-2{float:left}.col-xs-12{width:100%}.col-xs-2{width:16.66666667%}table{background-color:transparent}.table{width:100%;max-width:100%;margin-bottom:20px}.table>tbody>tr>td{padding:8px;line-height:1.42857143;vertical-align:top;border-top:1px solid #ddd}.table-striped>tbody>tr:nth-of-type(odd){background-color:#f9f9f9}.form-control::-moz-placeholder{color:#999;opacity:1}.form-control:-ms-input-placeholder{color:#999}.panel{margin-bottom:20px;background-color:#fff;border:1px solid transparent;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05)}.panel-heading{padding:10px 15px;border-bottom:1px solid transparent;border-top-left-radius:3px;border-top-right-radius:3px}.panel>.table{margin-bottom:0}.panel>.table:last-child{border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel>.table:last-child>tbody:last-child>tr:last-child{border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel>.table:last-child>tbody:last-child>tr:last-child td:first-child{border-bottom-left-radius:3px}.panel>.table:last-child>tbody:last-child>tr:last-child td:last-child{border-bottom-right-radius:3px}.panel>.table>tbody:first-child>tr:first-child td{border-top:0}.panel-default{border-color:#ddd}.panel-default>.panel-heading{color:#333;background-color:#f5f5f5;border-color:#ddd}.row:after,.row:before{display:table;content:" "}.row:after{clear:both}@-ms-viewport{width:device-width}.ipfs-_blank{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAWBJREFUeNqEUj1LxEAQnd1MVA4lyIEWx6UIKEGUExGsbC3tLfwJ/hT/g7VlCnubqxXBwg/Q4hQP/LhKL5nZuBsvuGfW5MGyuzM7jzdvVuR5DgYnZ+f99ai7Vt5t9K9unu4HLweI3qWYxI6PDosdy0fhcntxO44CcOBzPA7mfEyuHwf7ntQk4jcnywOxIlfxOCNYaLVgb6cXbkTdhJXq2SIlNMC0xIqhHczDbi8OVzpLSUa0WebRfmigLHqj1EcPZnwf7gbDIrYVRyEinurj6jTBHyI7pqVrFQqEbt6TEmZ9v1NRAJNC1xTYxIQh/MmRUlmFQE3qWOW1nqB2TWk1/3tgJV0waVvkFIEeZbHq4ElyKzAmEXOx6gnEVJuWBzmkRJBRPYGZBDsVaOlpSgVJE2yVaAe/0kx/3azBRO0VsbMFZE3CDSZKweZfYIVg+DZ6v7h9GDVOwZPw/PoxKu/fAgwALbDAXf7DdQkAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-_page{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmhJREFUeNpsUztv01AYPfdhOy/XTZ80VV1VoCqlA2zQqUgwMEErWBALv4GJDfEDmOEHsFTqVCTExAiiSI2QEKJKESVFFBWo04TESRzfy2c7LY/kLtf2d8+555zvM9NaI1ora5svby9OnbUEBxgDlIKiWjXQeLy19/X17sEtcPY2rtHS96/Hu0RvXXLz+cUzM87zShsI29DpHCYt4E6Box4IZzTnbDx7V74GjhOSfwgE0H2638K9h08A3iHGVbjTw7g6YmAyw/BgecHNGGJjvfQhIfmfIFDAXJpjuugi7djIFVI4P0plctgJQ0xnFe5eOO02OwEp2VkhSCnC8WOCdqgwnzFx4/IyppwRVN+XYXsecqZA1pB48ekAnw9/4GZx3L04N/GoTwEjX4cNH5vlPfjtAIYp8cWrQutxrC5Mod3VsXVTMFSqtaE+gl9dhaUxE2tXZiF7nYiiatJ3v5s8R/1yOCNLOuwjkELiTbmC9dJHpIaGASsDkoFQGJQwHWMcHWJYOmUj1OjvQotuytt5nHMLEGkCyx6QU384jwkUAd2sxJbS/QShZtg/8rHzzQOzSaFhxQrA6YgQMQHojCUlgnCAAvKFBoXXaHfArSCZDE0gyWJgFIKmvUFKO4MUNIk2a4+hODtDUVuJ/J732AKS6ZtImdTyAQQB3bZN8l9t75IFh0JMUdVKsohsUPqRgnka0tYgggYpCHkKGTsHI5NOMojB4iTICCepvX53AIEfQta1iUCmoTiBmdEri2RgddKFhuJoqb/af/yw/d3zTNM6UkaOfis62aUgddAbnz+rXuPY+Vnzjt9/CzAAbmLjCrfBiRgAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-aac{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnhJREFUeNp0Uk1PE0EYftruVlvAUkhVEPoBcsEoLRJBY01MPHjCs3cvogcT/4qJJN5NvHhoohcOnPw4YEGIkCh+oLGBKm3Z7nZ3dme2vjOhTcjiJJvZzPvOM8/HG2q325Dr3kLp7Y1ibpIxjs4KhQBZfvV6s7K5Vb0bjeof5ZlcGysP1a51mifODybvzE8mzCbrAoTDIThMoGXZiZ4YSiurf+Z1XeuCqJ7Oj+sK3jQcNAmg8xkGQ71mYejcAB49vpmeuzJccl0+dUj6KIAvfHCPg3N+uAv4vg9BOxcCmfEzuP/genpmeqhEMgude10Jwm+DuUIyUdTlqu2byoMfX/dRermBeExHsTiWNi3+lMpzRwDki8zxCIATmzbevfmClukiP5NFhJgwkjeRTeLShdOoVJqnAgwkgCAZ6+UdLC9twjQZ8pdzioFkZBHY3q6B3l4dJEEEPOCeD4cYVH7Xsf15F+FImC775INAJBJSkVoWo0QY9YqgiR4ZZzRaGBkdwK3bFxGLRZUfB3Rm2x4x9CGtsUxH9QYkKICDFuLxKAozGZwdTqBRs2FbLlXbiPdECMCHadj/AaDXZNFqedCIvnRcS4UpRo7+hC5zUmw8Ope9wUFinvpmZ7NKt2RTmB4hKZo6n8qP4Oq1HBkKlVYAQBrUlziB0XQSif4YmQhksgNIJk9iaLhPaV9b/Um+uJSCdzyDbGZQRSkvjo+n4JNxubGUSsCj+ZCpODYjkGMAND2k7exUsfhkCd+29yguB88Wl7FW/o6tT7/gcXqAgGv7hhx1LWBireHVn79YP6ChQ3njb/eFlfWqGqT3H3ZlGIhGI2i2UO/U/wkwAAmoalcxlNA1AAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-ai{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAk5JREFUeNpsU01vElEUPTPzZqBAQaSFQiJYUmlKYhoTF41L3Tbu/Q/+AvsX3Bp/gPsuWLrqyqQ7TUxMtAvF1tYGoXwNw7wv7zwYgtKX3Lw379575p5z77O01ohW+/DVh8zj7aYKhflGdG9ZsGwLNydffgVfr19YHvsEa+Zu/nxndob5StQK+dyzvZzyw/gKlmMj7IygFM+xvNcanp4/t5dAomXHBy2UUBOO2MAl/B9/cPb6PULuoHx0WM0e3GvpUOxD3wZAJWutZqYUYmqpSg5OMgH3YQObL59W0/ullpryR3HegkKEqiWBSGV4R3vQ7sIhScTZFTpHx3A215B5sluVY/WWMg7+ATB/lcLsKpTonHzD+OMFEuTz8ikkt9Kwt9YJZB38cpBdoQAZJdLvCGByfoPB6Xdk90pYy6Xg3c/DaWwArg09DaG5lCsUFN0pckZAojdC8m4auBqaALuSgez7VB1RtDSUWOQvUaBLFUzJBMJ2DwmPgd1Jwm0WoSgJfjDvrTKxtwAIyEkAOQ5hU//Zdg5uowDlUNMnwZLW0sSuUuACYhwQRwFvJxupCjEYUUccOkoaKmdOlZnY1TkgAcXAhxhOwLsDsHoN3u4O5JTDfVCH6I9nfjId3gIgSUATFJk/hVevGtOMwS0XwQ3AzB/FrlKg8Q27I2javVoZrFgwD4qVipAEyMlnaFArzaj/D0DiMXlJAFQyK2r8fnMMRZp4lQ1MaSL5tU/1kqAkMCh2tYI+7+kh70cjPbr4bEZ51jZr8TJnB9PJXpz3V4ABAPOQVJn2Q60GAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-aiff{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAohJREFUeNpkU9tqE1EUXZmZpE3aTBLbJFPTtFURtSCthr7UCyKKFJ/9An3og6Ag/oXfoUj7og9asCBYKT6UIPHaWtpq7NU2aZK5z5wZ9xxMpMwZDuewz9prr32ZiO/7CNaDx3OLt6fOjBqGg/aKRCIInp8+KzfKH7fudnVF58nE16el+/yU2mBFSWZKpWJKVc0OgUBo02K4NDmU6o75Mx+Wdu9IUXFeiOA/pn1xHeYaugVDdzpbp91qGlAKGTx8dC19/Wpxhjnsxj/RRwk85hGJC9d1O6fneWAuoztDYSSLe9OT6SuXB2ccx73Z9uukwDwfls1g0xZIY/Ad/Gnyt/XVfbyYrSDRE8PExHB6/8B6QuaxIwRBFMt0iIAiMx+LCys8jfGJEUik2WpZOD2SQf9oDtVqQwopCAiY66FS/om3b75CVS2MlU7AJ2WiJBCZjZ2dJuRkDJZFwFAR7UCBja3fNfxY2YEoCtRCj9em3Tpds6FpJseGCBxS0GgYGBzqw62p84gnYnAI2CSbSbPhEpFAaE2zODaUAlWWwDoS5DheGqbWpVE/0CmqCY9qkEyINBceb2uADRNQ8bSWAVVzIFKomCQim+0luS4yKYlsHlRyZo7EsSEC23K5vAsXh/H92zZkuRvxeBS5nEx2yp2KqhxPoV5TYS/8CtdApylM9sZQKKSQzyeRTseRV2QoAzIYY8jme5DN9fI0dQoUIjANGydP9VM7PZw9p/AiBpNYrdbw/t0yTJqRtdU9UrfJCUMpSJIgbWzsYe51BcViHzLHeqCRqhZ1YX1tFwNfZBxS9O3NWkAcHqR606k/n/3coKAoV/Y7vQ/OYCZevlrmv3c0GsFh06u3/f4KMABvSWfDHmbK2gAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-avi{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAm1JREFUeNpsU8tu00AUPXZcN0nzTpq2KQ3pAwkIAnWHqCoeexBb+AQ+ABZ8A2s+AIkdm266QUJIFWKBkHg1KpRHi5omJGkbJ3bGHj+4M1EQrTvSyGPPueeec++1EgQBxHp+/9mbyuriRZdxjJaiKBD3W+u1+p9a856max+gDO8ebT+WT20Ezi9NZi/crqadvn2MQBAGfpCOpqNru2937vxPIpY6Onjccx3Twck9MBiSU0ncfHirXFmZX3Md9wqCUwiEVN/zaQfHt0vfbBe5uQyuPVgpl5Zn11ybL4/i/lkICOw5niQRGQShoiqI6Bo43W2ub8n3hRtLZT7gTynk6gkCX9gAOxpAnxhHZDwC1/aI1EViJolu/QhKRMHZ1UX0Gr1USIEn5FPWHy+/wTokkrQOq2vBaHZBN4hmY9Jwfr4An/teiEB45ZZDwDiMhoExT0N+sYDCuUkkplLIlXP4/XEXdo+RUhdhBSSfUwtVTUG8MIHK9QVqI7D/uY6vr2pwmCPrkz+Tk9gwARWQ9WxppbXZhNnpw+ya4A5HZi6L4lIR8WyCcL6sTZiAWjWgAmpxkn5+kqTamK6WkCwmERmLDLvjB0ML9ikWXPLFuozYOap3L8HYN6DHdbS/d5CeTVBndBz87FCBLYkNTyIjBQemnIEsSY5lYrK1+UoWcToLMjEHAyIQ2BCBSx/NVh+ZUhrqmEqBebS3WyhdLg0zt/ugAaIklsSGLHCLa6zDMGhZ2HjyGsnpFPqNHnY2fmHv3R5SMymYbROszSQ2ROAY9qHiofvlxSc5xsKKqqnY3diRE9h4X5d/pzg7lnM4ivsrwADe9Wg/CQJgFAAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-bmp{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmZJREFUeNp0U+1rUlEY/13v9YV0vq2wttI5CdpL9aEGBZUDv0df668I6n+or0UQ/RuuD0EgVDAZrsKF4AR1a6COKW5qXvXec27PuVeda3bgcF6e8/ye5/d7niMZhgExnK9fbTrm5pbBGMZDkgCyq+VyhTUaT6Eo2ZHJePPWXJXRhez3B1yxmM/QdctXUSCgtV4Py4CvY3cky4e1x5DlLCaGbbzjXDcousG5OQe5HPRSCQPK4PpsEM/XH4WvhS4noeu3JwHGGRiULhsMoKZS4I0GtEIB9mgULJGA0+9DPBpBT7sffvf1W/Lg6OgJufw8C0CRGEXWazUwiiyFQjA8bsjVKjaJzovMD/Q5gxyJhG2cvyeXe2cAuADQNGBmBvLaGuTFRaDfh31lBTWi9pumjbK0B4JQul3vOQpM8JdskOLrdCvDcDjAsjtg5TIkoiKLaokMNR2cnZbqNAMycqG7XbHKR2fMzwO/dsxSwu0BiBJsNsv2LwAJAJCI5ux2gXYbqNetcz5PoORI1cDS0n8AxGW7A+zvEYBKZ2ZlcsEtJLbedMjePBaCTQMghx45ulyWkzxMVUQ2RMQhLfFO16YAqCrixPnm6iqKrRb2W23EfF4cUNSrHg90cr7hDyB33MTnSmUKALVs4uIlROjxg+AsPhGVl3fuIl2tIOB0Ya91gkOi9mxhAal0ekork1ic/kGLBORMxy2K1qS9V1ZQbNThIj2EGh+2tsyOnSai8r1UxMNIBB+LRTTULr4Uds0K1tU/uOLxIrmbNz8XXSrnASSpubG9fbKRyVh1n/zSw29t9oC1b47MfwUYAAUsLiWr4QUJAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-c{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAcxJREFUeNqEUk1rE0EYfmZnkgoJCaGNCehuJTalhJZSUZB66a0HwXsP/Qn+FM+9+hty0LNYCr2I7UVLIW0Fc0hpQpSS7O7MrO9MspuvVV8YMnk/nn2e5x0WRRFMvP/w6WSz5jbi/9NxfP693Wp3DrJCnMW5d28P7a+IE15lufR8o1ZEStwPhkWHsWbrZ+eNEPxsuubEF6m0TBv2Q4liPofXuzveulttSqW2UwH+GjqC0horpSL2njU89+FyMwjlTlxOJMTa9ZQHzDQIjgwdom9zLzfXPc75kbnOAswBJTlC2XrqQRMLxhi442DgB4UFBhgPpm3B5pgBHNUUxQKAHs8pHf3TEuFMetM9IKr/i2mWMwC0SnuSFTG2YKyppwKYVdGO7TFhzBqGIenVeLCUtfURgErucx5ECKREKBU4d3B718PHz6cICGT/1Qs8qpQtGOdyhtGEARWDQFqQJSeDL98u4VbLaKw9IRAJPwjtoJGlVAoDQ800+fRFTTYXcjlcXN2g++s36p5Lzzlve1iEROa8BGH1EbrSAeqrjxEqicHQt8/YSDHMpaNs7wJAp9vvfb287idboAVkRAa5fBYXP9rxO4Mgf0xvPPdHgAEA8OoGd40i1j0AAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-cpp{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAfJJREFUeNqEUs9PE0EU/mZ2WgqpXX+QIDFdalVslh8NlAOQaOKFAwfvHvwT/FM8e/U/MOnBmwcj8WD0ACEGghIkbU0baaEthe3OTJ0ZWV26q37JZt68ee/b9733yGAwgMbL12/fz+azbnAPY2Nrt7Zfqz9JMrYZ+J4/e2pOFjiciRvXlgp5GzHonXk2o6S8V6k/TjBrM/xGA4MLyeOSPZ8jkx7D+uqCU3Amy1yIYizB36AlCSkwfjWDR4uu40yMl/s+XwjeWThQQ4Z6QNSnSkYykcDXasP4lmfvOZTSF9q8TDBEFPbN5bOqCglCCCxK0TvvZyIV4CIxbgpC+4gm/PUmFCIE8iJPyME/e8Lon9j4HvyHYLjKSwRCSEUgf9+15mFbx8QS6CZJMzJ9SlBCwX3fJDLG4PX7ykcwkmQmJtpEhWa7g1dvNlSwjwelebz7tAXLolh0p/Fxe9fErK2WDFGEgKjxfNjegX0lDTc/heNuF99/HGEslcKXwyoazWNDdlCr6+DoJgrBzdI0T9rYO6yg2zszMlaKM3Dv5OBzbuyZuzm1B16U4Nzz2f3cFOx0Gq12F9cztpExncsqYoaHpSIKtx0zJdVIFpHQ6py29muNk1uTN829o/6SHEnh80HFaE6NjmLnWxUJy1LyTltB3k8BBgBeEeQTiWRskAAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-css{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAk1JREFUeNpsUktvUlEQ/u5DoCLl/RAKKKUvWmIxjYntQtcu3LvwJ/hTXLt16coFC2PsojEaMKZtCqFaTdGmjbS0CG3By+vei3OOBSGXSU7uzNyZ78z3zRF6vR6YvXzzPrMUCyf68bB9zO+VfpROn5hkOdfPPX/2lH/lfiLidztX5mN2jLGG0rKLENIE8liWpdzwP7HvqJqujmvudFU4bFY8Wk1FZsOBtKppd8YCDNu77CZevd3gflfTUFcUhP0ePLibiIR9rjSBpgwAfe4dVcV6dhtep4PH5msylGYLrzeybErcT85FYiH/CyPAf74gObC2vMhzsiRhPhpC6eQUM+EA1pJzILEnjRSuJsju7MJqsUCSRei6Dp3yXqcdGlHZ/rLPazQWGCn8+6YW4pAkEW0SjzUzanWlCa/LgcR0lNfovTEi6lcIkzesnM/R8RlN0INGp3h4DHoDsE5YRvQyiKiRSMzikRAOS2WoqoZWu41K7RwzlOOAVDMMMHhIGvFlRxJFrKYW0ep0IYgC3SDh4b1lTJjNfENsrazOAMAw680mPuW+8lFno1P4XDigRhOiwQAyJK7TbsNS/PaA7giAIAhYz2yRgBIfsVA8wIetPG6FAqhdNrC5u0f+TUyHgyMTDDToEt/ftQsEvW4EPG5OZcrvw0mlimarTXkPfpXPcNlQoGtjACgpryQXsPNtH/nvRXqBJpoKHMzGNkNB0Odls7LNyAYKpUq1dt1iuvB7fRDp9kr9D1xOFwkpoksXusmXaZWFn0coV89r/b6/AgwAkUENaQaRxswAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-dat{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAfVJREFUeNqMU01PE1EUPe/Na0uptmlASg3MoiZgCA3hQ8PHAjbqwsS9C3+CP8W1W/+BSReyYUPwI4QAVkAgUEgIbVIg1FZb2pl5b3zv2cHBjsaTTOa+e989OffcGeK6LhTevFv+OJoZHPHOfrz/sl86KpWfhxnLe7lXL1/oN/MSZqonOXU/k0AA6lfNhEFIrlAsP2PMyPtr1AscLpyg5pbtIHErhqez4+awmc45nI8FEvwNaiQuBHqTcSxMjJhmX0/Osp1xr878FxWEzwMinxAzEA4xFIpnOjedHTKpYbxW4U2CP4j8uWxmUKsghMCgFI2mFe9QgHZj0Ba4yhFF+KvGJToIRLuPC/efnjD6+26wB1Lq/xgbSCBXKeWJG/OTdky8cWTdT3C9RmWSGk2XCLlWo4xTNbfN5qh7PpXM72GjZeHt0gpq9QbmH4whGb+NpU/reDQ7hcWVVXxvXOHxzCQopQEKXKEbL6o1ZIcy+LC5g62DY2zsHeC0fA4zndIrHOjvg2XbAQRSfsuy9XxC2qzi/H5B6/68W0AsGkW0KyJPBLbDO0fg3JX/CUM81i0bD6WKe6j9qOPJ3EMcF0tSNsFA6g6alqW+VtZBUL78Vtk+Oqne7U9rs5qOQCjSheJFBeFIFOfVujSUYu3rIc4uqxWv76cAAwCwbvRb3SgYxQAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-dmg{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAn9JREFUeNpsU01rE1EUPe9lkk47yWTStCmtNhFSWxos2EXVhSsRcasuxYV05V8Qf4DgD/AvCK5EV1oFI7iUBqmCNdDvppq2mWSSzEzy3vPOpFFq+uDNfR/3nnvueXeYUgrBWH1/9/NE7k5BKRnuRcfF2qdnmJq9DeF9tQ+2isuMsxXGWHh/a1mEVsPJSI5fSU3OPEj291IIlN49RXz0KqzEQjIeZS/L5Y/3wPGhDxIM/i/A7fZWgVG0t5EaG0ZUa0JGM8gvPrZmLt58QYwv91mfAqCIE0sAqgumBFITGQzpUYhuF0KfRa7waDyXXXolpVrsh/0tgSLDr5I+wUZo1UHCSkAficPzY6juFSmbRPrC/azjq+fkcO00gAqoU7B0ETKkfWbuCTjTYeq5oESAauexcTScX+ZACWFm0YQSLZKhHdr67+/wW0e0dgjYo3sCEXXybYtBDVSHLp2es3IpsILS24c42lkBg6DzRjgRzCDZ/xr0GNRJwwYiWgzt+hYMawleu0V3wbkT+kUirOc7IGJAz68R/Qak1BAlx3hqASPGBJRXpXOv58dkz3eAgQoOm4hyj57NgZm0MHvpBmK6QdUdg/DAg9cRkhicBSDaKJdeo1bdxmR2DtWDDUxl51HZ+QHTysD3XdQO95Gfv06aeGcAdBrY3Chi8lwO3768QWX7J5q1XWyVSxgajiOXLyBG2hzurRKV9lmt7ISNkkjo6HhNyjoK+2gXRsKE57ZIE2ot10Z1fz0Ue4ABVw3NMjnW14rInh8jTYywoTg3EOFpOM4mXNfH9PQUfGlrAwBOs3I8ljbtuMWhRWzIIPrkn+GcYcgIWEowbZ+0qB334/4IMADESjqbnHbH0gAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-doc{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAppJREFUeNpsU79PFEEU/mZ39vZu77g7DokcP04BBSUmiEKCSCxs7Ei00JAYO2NlTKyMrX+CJhaGwopSQ0dMtFEsbDRBgiZEQIF4IHcg+2t2Z8eZ5QDlnM1mZ9+8973vfe8NEUJArfSNhzPG0VIfeIiDRSDkw1cWVt3N8rhG6SdSO2Gvn8dfuueqZwuNZqk3Jxg7iNcIfBbgXD6ZC8u5qffzX8eoYeyDxC77uygKhcouovgVUQj1H4YB2ovNuD9+tTTU0zMVBmG/+C8AIYh8F361DL/yE5HnADKYlVdg6MDAmW7cuz5WGuw+PsWDYGAvbL8ECFUt4K7/AHd/I9c7BLaxinD2Ld5Zo7g78RLuRhlBS2cpWbGfStfhfwCEpK0nUjCbWuGsLciSOELPhkq/YgdY3l6HsLfRcLYf+pHNbH0JigEPkLAyMsiEJ7NrqQzM1i7wyhoMZqOhvQs6Z0ovXgdAJACRoulEg5HOwrOroKk0zOY2BDtVpTF0CU6kLkQJXa+BNEoG0lMSsBBKQXWNQktmoGcaYeSaQCIVWOvUYQAiWZFQtk5mSMoSzEILtBrTfEcviC5bwVwQmoh96wA0ic5dB57ngeoaTIPCdb34zDITYNLOOIeVSsW+dQC+7+NSWx6jJ4tY/rWNV7PfcGv0tBoPTM7M4eKJVgx2FTE9u4QPS6x+kHzfw/mOAjarW2hJG3hy8zIceweuY+PRtREMdzbjzcd5WBqPB6xeRGUMGRzHjWvMmxQ7tiOF1JBN6FiTd6Sy9RuFbHpX7MMMqOD088Ii+op5OUAO7jyeRGfBwrF8Cg8mXuDL4neMXzgFwhwZz+hf7a9d5yu3Z6DTPjVQIY9k7erO7Y63Lvc8ErEeyq6JaM6efjai4v4IMABI0DEPqPKkigAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-dotx{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAndJREFUeNpsU01rE1EUPTPzJk0y+WhMStW2qdVWxUVEQUF0I+4ELQiC7lz4N9z0T+hG9wrdZKUgLqulhrbSag1CKpT0g7RpYjqZmffle5NEKdMHlzfvvXvPPffcO4aUEno9f3Vt4dTp+BXOe+fB0u/NbVpv7h89NU1j1TCM8H7+xY9wJwPHZMbOjRadLAvE/2gToJTiTPx89k+OlVd/LT+0TPIPpO/SzyQk40xCMxBSZ9Z3CoAx5DOjeHT7SbE0XSpzwa8OWB9jINELolQg8AR0EgUKn1PIlIWpkUt4cPNxkTOU12trs8p95RiAXpqaztqou8q6SKQJJmZSqGwsodFsIJk1kcyLYv7IeafcLx4HUNkFF4jFTExMZ0B9DrfD4HUEusYhWs4GPEJg5wly/tBYRIOeDhpEwlS34xcyajdQr3UwOT2MlJOEBRuGNHWp9AQRVXDfQiFV/U5GBSiQ5p6ngBEa5z3fiIhC6g6IMDBwOdoHPkYnHPVyhN0tF7E4QSpr94CEOKELffq+y9Bq+DCJ7rWBoQQBVbPR2O6G4OlsLASJMtCZfQqm0NP5IVWnamdAkUxbyuIYtD7wWegb0YAzAVMkkI6NwPM9xEwHloyDGAmk7AKS9rAS0FKOdugbYeAHPu7OPEM+MY7q3hIKqTFQHmC3XcONc/fxdfMDrk/ew/edzyhvvTmBAddocVRqH3Frahau56qpZDho7+PnTgXffi/gbHYmLEvPSIQBp5JU62sYz13G609zKBXvoOMdYn2zgm7Xg2MVML/4Eu3uPgxhk2gXmNl8v/i2pcXTP8tKdTEcbWLZqDQXwu/l6pfwbEnSGsT9FWAA4mdHv2/9YJ4AAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-dwg{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAoFJREFUeNpsU0tPE2EUPfOg006hD4rQh8WgbCSwkKgbF2owujaCiQsXxpX+D6MmbtXEsHCLmIAbE6NLo8YlGIxREIshIqVl+mQ6j8/zFVCb4UtuZua795577rl3FCEE5Bl79vPd5LHYiOP7cH1AUWi85ytmvlas1bJ9E5ryBntH3BpuP/X9i7ovkluuiE8N9SDepaLpCcRCCqa/VDCaMuIjSWP25Upl6n+QDoCz6Yh7KKzh3sI2LuUimPtRRyaqodj0MDloYiITSTi+mH29Wu0AUf9CsZPJoW5czJl48LmCc5kIKo5Al67B9gUGYxrun+5NnMlFZ+GKiQADj2a7AquseLIvjMv5KMaSBu4sWVir+3i8VIVKYSby0UTdFU8Znu8AYBHQgVOJEN5uOXi4UsdawwU0FSf6TaSoyw6DRvukPkgGWpDKy4F8a3jImCrqFDFn6rhKPR4VGnhvOTAY3WLcjifcQAsqRfhUc/Gq1MKNbBh9nIAMDjEppocxs9HCMktfGTCwP/oOBkUKNk/qF3pDYC6Ktk8RfWzyaaoKrqdDaBDwya8W1m0/CPCR3kFy7CcnmWQRUJqcRJFUKtTnPCeR71LwoeYF92CYyVnCFZpCTrRtCv5to2St8SOrKxiPqEEA4fkYT+mI0rdoeUiH1XZVuQPpsIKqw2QmfifTsnOABiWySlH9uU0Hh2MqjsZV5LtpPSoGeN9rKnhBX7ehoOSLIIPfnGONXGMMWN7xUfVldYDbjM3mrh5HCDgS17DhHgDQcIU+XbBxnDTn1x1UuQcJ9iv7l5Q5e1zLGri92EDJFnoAgHtcfr6wbbVXUqq193+0z97n3UJt1+d51n7aHwEGAAHXJoAuZNlzAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-dxf{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAo5JREFUeNpsU0trE1EYPfNMmtdoH2kDNmJbaVFcaBVFpAsREQpFwY0bu3HjQnTj1mVd+ANcuC3qQixmry6E0kWFVIQ+bKy2tbFJm3emyXTujGca+4DkwsedfLnn3POd77uS67rw1vC79ek7fZEzpu3AYUqS9tKQGZPLpa3VXP0uFCmJ/8t9OLC3q/uJbcs5bkIybvdHoMsSbLKENRmvU2WcNnTjRFD7ML1WGSPJHI6sA4KRWMAWVDPxLYex3iCmfpuIh1QsFSyMxQO4GvXHHwOJ6XWSyIck8v6HQsnjAxFc7vTj2VwBg4aG78VdBHQFCk+dbVcxMdwev9gTSEC455sIBOu2KLsoJFzqasP9vjCeDBlYqzn4VXXwarGKZN7Crd5QfLDT/7KpBM84c9fFUFjFp2wdk6smflRsKKqMa7EgfJJ3Ac2OKlit2pEmBTQfngdpnupoU7BUtRGiiTe7fXiRqmK+KuDn6TpvYogmBRJcrOwIJLIWxmM+dOsyLKryQAaJpjJ1/AxrGO3SqdZt7kKZJrzJWBg5piHENuY8vV6e0UOye1TyftvC5l+gZB8SHJTwpSx4q4JeTUKaxhXoR57h7Rn+3iFolJ3xvPhab6HgJG/pJ7jsNP4sUX+jZiCgEsWd/DjH5IrSYpBUAr0yHpzSoXKOP25a6OBhndh0zcX1qIYM2RIbu6i0KiHD5B/GTMHG03kTGpEL7H80wHFOWwhqDZ+SpkBOtCDYJDhZE4gRcKNbYynAqbCMbXpwpVPFbEng0aKJGbYzK1p4wIegLlcEPmdt+DjXbzcsxFlCynRwwVAwW6hjqeg0Zt521SYCWCJvbe0Un29UDx7Hgrs3IEitHXkw3jOv2fl92D8BBgAJeyqBh90ENQAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-eps{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmlJREFUeNp0U01vElEUPfMFCEVArdoSqEA0KV246UJdUJM2Lo2JK/9FjXu3utJqTNz4D9worrsQExbFpAFT0TYp0CZ8pIAiyMfMvBnvm2Foa9uX3Lw7c98979x77hNM0wRf7ufPsq7Z2SQYw2QJAkDxQalUZa3WI8hy3gmZr15bu+z8kILBkCeRCJi6bufKMji0NhwiCQR6iitdatTvQ5LyOLLEiWcYukm3m4Zhmbq1BX13FyoxuH7xAlbvpqKRK1fT0PWbRwEmDEyiy1QVg/V1GO02tO1tKLEY2PIy3KEAlmJRDLXb0TeZL+n9g4MHlLJ5HIBuYnSzXq+DlcsQLk/D9Hoh1WrIUjlPcpsYGQzS3LWoaBhvKeXWMQCDA1D9pt8PaXERUjwOjEZQFhZQp9L2yERiqYRCkPt/z58ogTGqHQLE1BLgUmC6XGD5AlipBIFKkbhanKHGYLBDqQ4ZED0OAbfLlo8OIxwGvhVgyTHlA3xkomjH/gegBgDURMv6faDbBZpN+/tHkUApkdTA/PwZAPxntwdUyjYA/+ZMqJHjLgM9iv/6zRt2GgMaIE21aVIjnSm0DGPfmhzyde0UAE2Dj+p7urKCPvkZku9eJILOSMUnkvVhIo7GYIB3xSKYdhoA1erXGVKXpvFxZwdBonnD68PQ7YEwM4O4xwMPxc8RYE87g4FIcz+kvfmnA0YzIJIy77/m0OCqsTkkCTysKPjJG3viLei63Gm3kCO6UWqcMejjxecMPmxsoFKtYop6UNirYL9Wtc5OHqzznIXHq1na7OfMJROcK8a6O7MjW7nfzZdrd7jzT4ABACh3NGsh3GcdAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-exe{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAo1JREFUeNp0k8tPE1EUxr+ZzvRJO62lUAQaKIQ0FVJFjBBdoIkrDDHuXJi4NnHtX+HCjW408Q/QmHTRaCRRohIJifgiiBICTQu29mHfnc7MHc+MlECKdxZz595zf+c737nD6boOYzxJLC6Nhwej7e/24HkO779s7G6mMjcEwfKZ21+/d+em+RbagaFev28qEpZwzKg3ZckqCPH1nfS8hScIdyhBe6JqTG3PfyTTeLrwFhvbKdy9/xi5QglXL0yGJsKDccZY7LDIAwWHpSferWBh+RN8ni4UylVER8MY6PHj0uSpUK0hxzfTmWsUtnoEwO3rer64jEyxim6/Hy67DXaHExvJX3jw7CX8XjfORUdDlOohhU4fAVjILCPbm9V1yIqK2FgYt+ZmsZcv4lH8Nb5upXD7+hVMjIRQa8qeDg8UTYPU5cTcxSk4nS709XTD53ZhpD+IYMAPj+TBz93fZiz5oHV4AP1fGdlyHZIkIZkrI7GyhnK9CZXy+Aig6p1+HQAY003AcF8AVtGGfLWG9XTO4MLZ5cL0WAixoT4zVmPHADSiMo3hzHA/xgeDWFjbNg8H3A7kKnX0koEcPdTu/ylgRGZgOjNv38zoSXC8BZJDRKOlwGEV0VJVGM0y4joAPO1spXbx6sNHeD1uRIYGUCxVSRlDt1fC8rfvcDnsmJ+dOaLgoAs6AVLZPJJ7WdhEkUyT8GJpBflSBcVKDTvpDBw2GzQqQT1OgaZqUOhtFQUTUKnVTVWNpgy51YLVKph7sqKYkA4A1ScEfT66vm5kC3+ofh6Xz59FQ5bpkvE4QW3M5Apoyorhl9ABIKnFgNdTOh2NkJG6WSf9eRBJtmFwLDJmriUzeaOkYvvcXwEGAIVNH6cDA1DkAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-flv{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmtJREFUeNpsUl1PE0EUPbssLYUCXdpaC9gWoSTgAyFigiRGY+KjvuuTr/4A44MP/gx/gMYfwIsan0RjIjGiJIZgSIGFIoXSD0t3Z3dnd70zpITazuZmJzP3nnvumaMEQQCx3jx69SV3a3KWMxetpSgKxP3m242Do43SQy2k/YRydvds67n8a63k+FRSn7l/bdg5tdsAuM3he/5weDC8vLdqPLgIIpba2niux52mg//DqlsYSg3iztO7mczN3DJ3+ByCLgCBH4hOFEF7cDpzPCRyOpaeLGXSc2PL3HbnW3XaRQCPEgWI2MsRVAVqrwbX9bHxbhOKpiJ/bzpDOr2k68V2BtRNzMtqDEqPejY/4zSGjb54BM0mQ8k4xsDoIMauXxnqYOD7PmwScP31d0SS/eAuh1lrolFpIBQNQw2pqJdqsAlIceB1AJCIkkE/FZskXDQVRXw6IYHiE0nBEcaPXSSvJnGwWkQXAE4acAhbxPMJpOdHweoMhc9b2F8zwKizbdlyPLVH7QLg+JKBYzoorxzjz3oRzUoToaEw9KyO8XQW5AE5jrFT6AbAYVVNxCZ0Ka3So+DSTAoDiej5ywTySbls1OEDobhFlMcXxrHw+AbINEjNXgb7y6BndLhk8cRkHHbD7g4gEhiJFxsdhrDqaamBaDKKerGGSKwPI9kR9EZCaNA5ubE7A5s8IFhsrxQkgJhZoa/06xC5xRz2v+3BOjFlbqcGlquxsondT9vY+2pAJdeZR6fI355CgQCN2A4O1w7gkQ7cdLUOAKdhV6uFSv3kd/n8mT68eC8dKWLnY4FsfeZQh7nVVt0/AQYAsf5g+SvepeQAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-gif{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmVJREFUeNp0U0tPE1EU/trplAqlL0laiw40xASByEJIZFGVnSvj1j+gWxNXJq7VrbrwF7h10cSNhMRHojEuACVBKmH6SJQyJeXRxzzv9dyZPiCtN5lMe8853znf953xcc4hztDzZ1+C6fQMHAfd4/MBFG+p6h/n4OAeAoGNToi/eOm+A50LKRaLh6amoty2vVpZdotNXccMEK3LwZxa2bsDSdrAqePv/mLM5tSdMwYBYqyvw9zdhUn/L59P4OGtG8qlZCoH254/DdCdQBCxqZu+ugqnWoW9swN5ehp2NotgIo6bGQWGtaS8+vQ5V9a0u5S+1gfABEilAqdUgm98HDwUQkDT8JXoPPq+BoM5kCYmFT9jryn1+hkAt7heBx8dhbSwACmTAUwTgdlZ/CVKJaLnI1GD8TikZiPSR8Gxib8chH95mZTxgwWHwH7+gFMswqcokIRbjMO2HDCnZ1VvArpjEmnKZc8+cZJJYGsLsMiZ8AgwEqaY6Mb6RQR33JFhGECzCRyfAFXNu9v+RVNRZWIMuDJNuYMAaDycUFGhCOgtuAtFVDA83G5A8TrFDw+F5QMAxAKJJxz2xnW3RPJGbm+rCyjotZetH4DGzaSSeDA3h4Zl4R0JOEZWTpIzF4n/m995bNdqZwB6m0gFft3Ak6vz+KYWwFsGlqIxXItEcDt1ARMEtKdVgZb+fwA0G2C2hXM0ZTZNRcSf0b1pmXi7uYnjI+Lfanm5fRQsK8BIxKcrK7i/uIgP+Tw+FlREqHN5fx/vyU4uHBE6UO4gDWqk/JFaLuMxcXeFk6TuJ90V0HOk1in7J8AAjmgkPfjU+isAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-h{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAbRJREFUeNqMUk1Lw0AQnf0woK0ttVqp0hwqVCl+UBERT94F7x78Cf4Uz179DT14F8WbYHtRkBYRLNqDtdaPZLObuLs1NGlXcWDJZGbey+x7QUEQgIqT07PL5WKhHL5H46J+22q22vsWpbWwdnR4oJ80LNiz2czGUjENhvj4ctIE4Wrj8XmPUlKL9nCYcOFzE9j1OKSTCdjdrtiLdr7KhVgzEvwW6krC92E6k4Kd9bJt57JV5vFK2KfRQRV+RAMkzxglYI1RaDy2dW1rpWRjQo5VGicYIorWVooFvQVCCAjG8Omw1MgG8AM0uSBUDSnCfk/IGCHwf3DCD/7UhOLBrFkDuep/hDUSSCv1iYo4rIfqGwmUSNJjfYbBcQKhZw0aBMA4B48LwBhBt/cON80HmM9NQ6fXg/Wlku4TwmNWDzaQqzHG+0PSKod5cH5Vh2RiAhYKc8DlV1UPSyuFMGygVlMg1/P6BC6DqXQK8jNZDXAYA1f21V34wMXYFaiyVw0rJyzLgs3VMkxOjGtix/V0XWChZ0cI2i/dzvXdfTd0Qf91BMPrhyNzgKfOmxaWypqaDXHfAgwAtCL8XOfF47gAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-hpp{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAehJREFUeNqEUk1v00AUHK/XKf1yZdESVRBXjRSRFqMQVBA5Ic5I3DnwE/gpnLnyG3LgXglx4UDDLZS0RWkDLiRxSusk9u6GXSembmLgWZbX7+2bnZl92mg0goo3b3ffO/ncdvyfjHef6q2Dlvs8Q2ktzr16+SL60jhhZ69bO8X8ClLC7w9XdKJVG8fuM0r1WrJG4gXjgqU1D0MGc2kBTytl+7a9XmWcl1IB/hZKEhccq5aJJ/e3bTu7Wg1CVo7rNLlRhUh4oMnXoDoyhoHGyWmUe+QUbELIa7W8CjAFlMzdzeckCwFN06ATAn8QmDMMMGlMuwWucpoCHNe4jBkAMenjYvRPTyi53JvuwX8AplleAeBcRFrH6rXIxLim9I/pi3QA1RhKaYxdjkN8IwalCMIwWs9ljMkh0wzk+9M7w179C3LZNXxve2h+c3Hu91HeKmD/6zHOLnw83ilB1/V0CeqU3Q81LC/O41b2Btx2N2JVP2riR8eTUxmi0TzBwrKZMsqMoz8MsDh/DWuWhUBKURLKxQIeOMWoptYPnS1c+INZBkwISomOSsmBZS7B+3WOzZvrKGzkMAiGqNy7g+LmRkRfekBnANy2163PZXrSbrQ6vch19Xz8fPDHyL39QzkHBKedXjfu+y3AAGU37INBJto1AAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-html{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmBJREFUeNqEUktPE1EU/mY605a+hhZTBNKRDApNrWIRA4nEBUZdmCgLNi4MK5f+FNdu3bFv1J1EXODCR1JJSMTwpqUP6NiCpe10Zjz3hj5Mm3iSybl37jnf+c53jmDbNpi9eb+6Ftcisea909bWNzNb6dwzSXKkhIt/r14+515qBqmDA8HpqKagh53XaopblpIbe+knDpFAhPab2Dw0TKvRK7lmNODzePBgZlK9oUWSpmVNdpIU8T+jaMsyMaD4MDcZVa+NhJMN00w0n6V2nN3yQgdHWZag+LzYPTomIAtT0THVtPGanmb/BbjwLFkvn2IttYGYplKyDzsHh7gdmyAWfh5zVq0Guhg4RAHFUhmfvq3j134aXo8bd+ITnMFOOovU5jbGRoZwNxFn1cxuAIcDW/sZDjA/c4u+BNxOJyxqaenpI3z88gMfPn9Hv98HQZS6RazW6kjExvFi8TGdDSy/W0Emf4LS6R8sv11BmfzSwkPcm74Jo9Ei0GZgmkw8QCOao8OXcaz/5vSZnPdnp3ApqBBLkWJE0Ci7ASzbIhCLLQ1E0iOkBDh9NpUgiUejo8oNuJwyn0YPABtn51UYFFivG3yBGCNZkuDtc/MW+ZQI3OrYpBaARCKufk3B5XIiWyhiL5ODp8+FfFHH+KiKSqWKUL8fC/NznGlPBmz+24dZjKnD0CJDcMoyW0SqXuMtHBFw7rhIAD1ErNUNafxKBNevapwu65NpEQ4FqXIA+RMd6VwBP3cPSERb6gLIFIq61+UqGWaFdcrVt/lmAuWjAi2aiMFwmOYuIJ/N6M28vwIMAMoNDyg4rcU9AAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-ics{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAhRJREFUeNqEUkFPE0EU/mZ2dra7bLNpi2AxQFKalkJrohICiYkXPagXrx78Df4K48GDBzmQePLMhUODNxQ5ciEkJVqDtJGmMWrCATRbd2ecoS5u3aovmezsvu9973vfPiKlhI4XL7c2r5YL81LIELEghLA3u/udxmHnPmfGW/Wuv+LpwwdneRYBx7PeWK0wOYYhcXxyckGV1fdbnbuMsXcklqPRJQxFMKz4RxDCtVO4s3xlRjWoB0FYjlQPEEBieChwKCRGMx5uLtaKs1P5ei8IKlGa/YkXMXYtlTEDlsnw/mMXhBJcqxSK6vlcpa4PEpCooUyIqs5M6hG1o2CUwqA091cFcYLf/sjzcX75EiQIojI9779CTYR4jwTBf+r7GAwh0AxCiL6JMT/04vQ79u8aI2O/7Jzg69o6Go8ewycUahtBpADhHKLnK/eVbkMdtROWIv80NQ2sPhncA9Htwn+9hZG0rY6DzFwJl+7dhs0ZstUy8rduwPS/wd/ehmi3kwq4zTHiWUgXp+EuL8FvNvFl5Rn4xAS86iyI2kY3n0Mv48ByrOQmancdi8I0Kcj3U5iuA29xAelKCUHrEIayzltagG2E4IwkFaQgSC6lYI09iN0d8It5uNV5nG5sgJdKYC0G8WoTOZvBISFNEBxnsuzD3GX4vfDsszzqAu0jkJQDedCGbB6AWg54pYbPo+NGVPdTgAEAqQq70PytIL0AAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-iso{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAjlJREFUeNp0kstrU0EUxr/k5qbJzdPYpGkpsUJoA2q1oLjTdiGiIC5cuXHlxv9BEOrStTvBnQvRrSAIsejCrlqpsURq2hCJNQ+TNLm5uc/x3MmzJh34mDNnvvnNzOE4GGOwx8+t9XQkfn0VE0Y5/7Z+kHm+dvOhtd3P9c/xwNZh7nWaMYtNUmX/Fct/vlN7/8J5aRRgyzm8xzpRDjGE2aVH4VTqdnoUYg/XkEhmy+Cx3DhA5tMzdFolvg5Mx3Fx9SmH0JIg79Zo3j4GADMIokJTKtjbfAKXU4Y/2NvSfyH75TFOxa9Cmr0XnlPFl5ReOQ6wNMDsoFX6AElqQlNV1KsOuNwS/AGFjEUIDhmn5+/DMM16/9igBowAzFKIswPJr6MjlxFP3sV04gaP7RzMPe6xvWM1gNUBM2UKYlBau3QghGphg29J3gDlLLilWNdD3gkvIIDRhD9yGe2mCV0V4HFXuCxT5Dlv8Dz3sIkAs03FalDxBMQSt9BRBMhNncuO7dyU28c9tnf8C/Q0ZtR4GImeQSj8APLRH772BWcgiFODffCv/t8H9tO0v3RjV7VqkeeXLlzDfvYjj88uXhl4JwIsrYxmLY/M1gYclIvGE9jZfNPrSCD3/QgLyeWTADV6wW9AryIcCkB0u1Aq/oCPumlufoF72vIheaLDr4wCLIOqrYnULA14PSoqpSJEAUilZrD77Sv3LK+cI0+Be8cAbbmAOrob0agtD491LYfkoqvnyZLsWRkA/gkwABL4S3L78XYyAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-java{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAjxJREFUeNp8U01v00AUnNiOEyepQyhQobRBSlVIoRCBEPTAjQsSEneE+An8FM5cuXLNoQduIAE3qopKNJAIIppA2jrOR93aa6/N8yZuUxyxkrXr3ffmzczbTQRBgHC83nj3ca28dD36nx6fvnzrNNrdp4oibyUmey9fPBezEgWVFuYLdyvlPGaMY4fl1aRS+9pqP5ElAkmcnknRwuO+Nyt5u/ETYfyj9WrpZnmpxn2/Ok1Swn/GvtnH5k4TLue4kNfxoFoprRQv1TzOb8cAIu3+ZD7oD/Hm7XuxzqRUNDtdkuLiTmW5tFxceBXlnXgQTAORSMt2oGezUJJJrK9dFWdEH7Ik4dB29LiESeUEJXd7/dAT3L+1ivlCHr8NEzutXTBvbJPPSdO/AH5wysChwM/1HzCGlmAzOrKxu2eCud6Z2Jke2MwThpUXL6Nn2ZAVFTlNw70bK0iRnGAq9qwHtOmTRpsx1NsHyKRVnNPnoMoK9kc2BjbD4vk5JGV5NkBoEPM4FFnCteJFWOS4ntHEfphQyKaFTWFLw704AJ26ZFx/ZEEi3YyY0O1Dmr4EKTUHA8hUnS6siI0DEHLYog+b28RCRuNXR/iQUpPUEQ+NVht6Lodnjx+GXYgDSFRnq97Ed2pXSlXhUSeGhxYc5sKlNXM5DGLR2TMwfZVPAIi+otGNWy1fEZUKeo4qc4ysI+F8VksLIJfYcD9QYgB/DNPMptWBlsnBIS86xmDMTBo/PWd0LB6VZfdEbJT3V4ABAA5HIzlv9dtdAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-jpg{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmlJREFUeNpsU8luUlEY/s4dmMpkWxRopGJNNbiwhk1tItbGtXHr0hcwmvgOdWld6Bu4coXumtREE3ZKu8FgOlC1kIoXtC3jPfdc/8PUIpzkBM7wf+f/hsts24YczuerGUc0moBlYTAYA+i8sbdXtAzjITRtq39kr73s/Gr9DTUYPOeamwvYnHdrdR0SnDebuCbswJGqpX+Uf92Hqm7hzFAG/4TgNr1uCwEJ0trcBC8U0Kb1/PQkHt9JxSLnL6TB+Y2zAIMOJBGLXmtsbEAYBsx8HnqCGKVScAX8uHf5EpqmGXv18VO6VDEe0PXsKABN8+AAgiabmYFNNJTDQ2RUFc8+Z9G0OPR4PKYwvKari0MAgiY/OQGCAajhMNR4nDZMaInrKBGl70SPMScck1NQG3X/CAWLE3/dAWV5hRRVIJxOWNksrP19sFgMqqAebUGYHMI6teq0A9oTVAhqu2sfbYYjsL7lCZ3683gA70T3TK7/B4BNoO020GwB9TpwfAz8LgMtWn/NkV8EHgoB81c7nYwCyBZlEVkHcqMTKFnkmehJTOPvEfCnKi0fAyADJKfXC/h83TaZTJjaa5lANLpOFqAXtlEAorAwO9u5syT5UxLfU0e3o1FMu1x4u7ODYq02BKAMAVSrSNLrK1MhLPj8mNF0vFm+C1ZvwKBwXXE4AGn1WAASazESwUW3BzUSMeJ2o1Aq4sPurvQYSRLwlhRR6mSaYyi0WlpAJrFRx3ouh5/lMt5lv8BLwXp0M4lSpYL17e2uK5wP6lj/c2ZPn2RI+YT8fDvqoyegVLyfG5kBKaQQOfvF2pLc+ifAABiQH3PEc1i/AAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-js{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RUQ5ODY5Q0NGMTE4MTFFMTlDRjlDN0VBQTY3QTk0MTEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RUQ5ODY5Q0RGMTE4MTFFMTlDRjlDN0VBQTY3QTk0MTEiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpFRDk4NjlDQUYxMTgxMUUxOUNGOUM3RUFBNjdBOTQxMSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpFRDk4NjlDQkYxMTgxMUUxOUNGOUM3RUFBNjdBOTQxMSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PoT8zQ8AAAJdSURBVHjadFNbTxNREP52t7S0bktbKFAvTUVaw60YqkExUTD6oD74qC/yD/wp/gh885XEEI0RAyYQUiMpIBGMkYR6o23abi+73e2uc04v1LROMtnZPTPffvPNHMGyLDB7sbJ2ciUSli3U35smkK9t7x9v7n2dD/g8KUkUwWqeP3vKz23NxJGzgwOx0RC6mSgIo+WKuvP56MeUzy2nJEk8PWsGJVVTuhWbpgmHw47FB7d98Wg4mVWK52o1sxOg3Va3PmFp+Q2PdUquaFUM9/vw+O6cP3bxwm46Xwh1ALR3/vL1e+hGjcc9koScUsTSq3coVDQsXJ3wzo5HEs3clgZNMTVdx1T0Ep7cn6//QRQwMhzA6uZHLD5cIFEFSKIU+G8LK+tb0KsGZKcTJoEyP08AbpcLy6sbPKdQrigdAGaDwWxsDH1uGbliCYIgcM8WFPg8Mq5Pjzdyu4jYbCE44EepXMHuwXe+A8x3KKYxYsjvbUzmlPGpBmYdgI1oYjSMbL4Ao1YXMkcM2Dd2xnbAamPQAqg1GORLZdycmYTdJqFKk2DPR3fmwI4zBDrg9RADqxPAbPBif2WTSB584/3/TGegEOit+DRcvQ4OZJi1LgwIQKVCg2i6nb1I7H3Br3QWqT9pBAP9uDY5xjdSM3RqxeoUkfVnEOW8UkLykERTNXjkM7h3Iw6NNvHw6JjuhAhVrba0+QeALozcI9nQR0VvNxJc/ZmxCNGvIBQcpDG6udA22kyW29HC72wu8yG579ZoiSYuR/ly2+y9CA4NceWLmo717T1i5ULqJNtapL8CDACskxPFZRxLwQAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-key{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAlZJREFUeNpsU11PE0EUPbM7u/2AtJUWU6qiiSYYo5EmmPDCD9AH46sx8cEnja/+CB989z+Y+MKPgMiDsYQACcbaWBBogYD92t2Zud7ZlQZsbzKZ3bl3zj3n3IwgItjYeDO3MlWme0bjUth8e8/fO2tHzx3XqUEk50uft+Ndnhdmc3SlfNPkVZT8Cy600DoIISvVfKYtlvfX1p66XmoIYsMZdjJQWvEFbbsC/S5g2QhSkKUK7rx6OzvzqLpsovAhaAxA3DUBQn2TUFsl7KwTfm4Z9DoO5LW7uPXi9Wxpfn7ZKF09vyPxX2iWcNRkKGZz0mQWKoNs8AVB6x1yRY2pYnc2LLofuXTxMgAlmlXIfngCxNxEzM+DPv6NQa2BygLgZyX6JT83ngHTN5GAL0WSoUQkSQnXkyBh/k0GegTAaldM20sTKvet+yyhIZApECamL0jUSe3oFChx3TopM4TeEQP2gc6BgGIwb4KGNXRhCkMGxgg2kJeybRiZM45D8W61qEAknSmpHStBhywu0nFVupSCTAcM4ECwqapv+NQ6LS9JGALoMIIoPYDjZiEL1xHtbyO39AQUDaA7R1AH23DSeSA4hv5RG/VAhxomPYP8sw9A4TaC9iHkjUWmrtGvbyC18BLe3GP0m3WW4I5hEBEnPIStXzyuFIxb4EkMEJ79Qa/xHbKxCdM7xeCwzUZOjgEwnuzt7qLz6T3cySmQP43uzjeIiTJM6io6W19B/NLCKMVGCzkCoLR/0lrfOI2fNy/huKC1FTsK/rbGNeMRC8dHpHByfu+vAAMAL/0jvAVZQl0AAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-less{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RjZERjZENTJGMTE4MTFFMUIwOEVERjQ5MTZEMkVBREUiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RjZERjZENTNGMTE4MTFFMUIwOEVERjQ5MTZEMkVBREUiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpGNkRGNkQ1MEYxMTgxMUUxQjA4RURGNDkxNkQyRUFERSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpGNkRGNkQ1MUYxMTgxMUUxQjA4RURGNDkxNkQyRUFERSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pl1w97IAAAJhSURBVHjahJNLbxJRFMf/wPAIMIxMkUI7tS0VYqlGDLGhjdKkqyZ24cJFN925de+XcONHaHRj4k7TND6SGo1VWwmp2kSLhlqMDbQ87gzPYcY7k4GgoJ6bmdw598zvnvM/95pUVYVma+svcovx8yMnFZHAMJPJBJfDzq5vpX6+/vD5qo/z7DOMBdo/d26t6jFMJ3iY51jBz4M+LP6wxEw40Gy23qYzB3HO7fpmpZCOmfEfa7Xb4NxOrC4lvbPToe2yKE3K1PdPwNOtHdx79ESfq4qKkijB5/XgevIyHxEC24USmewDqD2ABxubaLRkfW6zMqjWGlh7/ByyAtxYnOPnL0Q2+gGGmKRaw8zUBJaTiS5QOO1FJnuIAM8hciaIWHgi8NcSNt+loVDY8JBXh2ojJAR1HbTSNFMUpV8Dxcjg0nSYBrtBxdLbqI1iheCUh9XXNGurAwCdEkb9QyBSFam9TDfoPZ1LUg1BH28IiwEARTVAQOzcFKRaHZpLoa9avY6L1Gfs0c32t4PU6W2lWsV8LAorw0Cs1nXftYWE3qZGqwWHzYp2zzlgetuolVFvtiDLbRRKFTAWCxx2G/KlMtXFhWPqOzsWHJwBx7rxKv2R7mwFz3lw9/5DLC/M4Us2RwV0g3U58XJnF7dvrsBOoX0Abbej/DFKRMKI30fTVGC32WA2m5H9cQQvhYi0vE/7Wdgczn6ARA9QPBrBszcp/XvpyqxebzQ0Tlsq6llxLhe9bD4cFMr9XdjLHpLv+SLGBYHAYiVu1kNOpAaRTWbCejgiw0zGhFGSK1aw+zXbvfK/BBgAPwADAs5GpGsAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-logo{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAEACAYAAAAjlcdmAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAABCZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICAgICAgICAgIHhtbG5zOmV4aWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vZXhpZi8xLjAvIgogICAgICAgICAgICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iCiAgICAgICAgICAgIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyI+CiAgICAgICAgIDx0aWZmOlJlc29sdXRpb25Vbml0PjI8L3RpZmY6UmVzb2x1dGlvblVuaXQ+CiAgICAgICAgIDx0aWZmOkNvbXByZXNzaW9uPjU8L3RpZmY6Q29tcHJlc3Npb24+CiAgICAgICAgIDx0aWZmOlhSZXNvbHV0aW9uPjcyPC90aWZmOlhSZXNvbHV0aW9uPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICAgICA8dGlmZjpZUmVzb2x1dGlvbj43MjwvdGlmZjpZUmVzb2x1dGlvbj4KICAgICAgICAgPGV4aWY6UGl4ZWxYRGltZW5zaW9uPjY0MDwvZXhpZjpQaXhlbFhEaW1lbnNpb24+CiAgICAgICAgIDxleGlmOkNvbG9yU3BhY2U+MTwvZXhpZjpDb2xvclNwYWNlPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgICAgPGRjOnN1YmplY3Q+CiAgICAgICAgICAgIDxyZGY6QmFnLz4KICAgICAgICAgPC9kYzpzdWJqZWN0PgogICAgICAgICA8eG1wOk1vZGlmeURhdGU+MjAxNTowMjoxNiAwMDowMjo4ODwveG1wOk1vZGlmeURhdGU+CiAgICAgICAgIDx4bXA6Q3JlYXRvclRvb2w+UGl4ZWxtYXRvciAzLjMuMTwveG1wOkNyZWF0b3JUb29sPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KqqO/2AAAQABJREFUeAHtnQecXFXZ/+/W2dmd7Uk2mx469sJfQJHXKKCiiA2UEl+KRiyI8NrA8oIVeVVQEAERUQRRwAIIhmIihBAg1JhGetmS7X1nZ2d2/7/f3b2whE323LlT7sz8Dp+Hu5m559xzv/fO3N+c85znybNUcpLAWauePqpr544HRqLRorzR0ZP+fsYnHspJEDppERABERABEchBAnk5eM45fcpL1q2r3/3E6uuLSoIfiEaG8gmjoDgwOtCy57G6N7z2tFsXLdqd04B08iIgAiIgAiKQAwQkAHPgIvMUl6xeXdqyZdvFI9GRr+QV5JdEw2FrdGTEPvu8/HyrsKTEGhmORsNdHTcuPPrI/7nhiCMGcgSNTlMEREAEREAEco6ABGAOXPJP3P2Pk/vaO64vKiuto/DDtO+kZ51fWGgLwXBXV/fo4MCFSy84/7eT7qgXRUAEREAEREAEMpqABGBGX779d/6c5zcc2vTUqlsDlRVvgfDLGxke3n+F8Xfzi4qswkDA6mtu3lw6ve7Uu0/7+LNGFbWTCIiACIiACIhARhCQAMyIy+Suk+euXVvT8NiqnxaVlS3Oy8sriA0NWaOjo64aQT2rACIQ08Qjvbt33z9v0bH//fsjj2x31Yh2FgEREAEREAER8CUBCUBfXpb4OgU/v6LmDVu+NBIbvrSgpCQUGxy0oN/ia2y8Vj78AwuCQWu4r28o3Nl15UHvOuY78A80G0r0dGRVFgEREAEREAERSBYBCcBkkU1xu6c9tPz4ru1bfxOoqJwbxYif6XSvaTedaeGB1pZ2a9T64gNf/NztpnW1nwiIgAiIgAiIgL8ISAD663q47s2StWvn7Vz5xB8ClZXHjEQieTH6+bmc7jU+KKeF4R9IMdjb2PCf0LSaj9+9ePFG4/raUQREQAREQAREwBcEJAB9cRncd+KMVasq2tdu+GFRcfGSvMLCItvPz+N0r2kvGDbG9g+MDsf6W1r/XP+Oo8679aijekzraz8REAEREAEREIH0EpAATC//uI7+kdvvOCMSDl9dWFpabfv5xWJxteO1Un5Bge0fGOnp6Y90tH/z4a995ede21R9ERABERABERCB5BOQAEw+44Qd4VMrn3rznv+8cGtJZeXhsUgk4X5+8XaUU8IFxcUMG7O7qDiw+J+f+8zyeNtSPREQAREQAREQgeQTkABMPmPPR/j0mjV1u1c99euSUOgDsZGRfPj6uQ7r4rkTUzTAsDH5EIFYNTza07D78eqF8z/xl499TGnlpuCmt0VABERABEQgHQQkANNB3fCYZ23bVtL80CNfLygq+EZhSeAV6dsMm0j5bk5aueH+wWhvY+OvDzzzExfdvHBhOOUd0QFFQAREQAREQAT2SUACcJ9o0vvGR+74y8nhru7ri8vL62IRhHXZR/q2VPTSHt1Dmjh7hbHhAZlWrqA4YA12dHRHerv/Z/nXv/obw6raTQREQAREQAREIMkEJACTDNht82c9u+7gpiceu72kpubNI0NDeTEKP8OwLhRcpbU1tlCD8GIWD7eHf9X+hQgCHZpZbwXKy63Bzk6rf0+zRf9Do8KwMRCCnBru3d2wpShUfurSz57zjFFd7SQCIiACIiACIpA0AhKASUPrruHPvfBC9eZHHvt5oLLq9PyC/AKKLFMBl19QaAWn1VpldTPt8Cw8cqSv1xpoabGGenrcLxaBcCuC8AvWTkO70yyO5jmFo5H9zc3WYFu7NRKDODUodtgYiMCRaGyke8f2B+a86fWL/3jSSW0GVbWLCIiACIiACIhAEghIACYBqpsm37VsWWFw244v51l5lyJ3b1ksHIawMgzrAqFWUlVthWbNsopKSyc9bBTtDXV3WQjVYkUHwxgdxOgdRxRRd2LJY0gXrOZFH6yS6hqrOBSy+Nq+yvDAgNXX2GiFuzqNRyjtsDElJexLpG9P8y8K3nH0xcsXLTJTkfvqiF4XAREQAREQARFwTeCVKsB1dVXwQuCUfyw9vmfXrt+UVFfNdRvWhYIvVD8LYq36VWJuX31iejja6CRTyhzlo+1P9L2qXbQTxrRwX1OjRUFoWpywMf179rSPRqNffPiiC5RWzhSe9hMBERABERCBBBCQAEwARLdNnPfcxtnbVi6/vaS29h0QZK7St1E8lc2YYZXOqHvF1KzbPiRyfy5QGWjZY/Vjytk4BzH9A3EuFJ09O3euDZaWf/S+Ly55MZH9UlsiIAIiIAIiIAKTE5AAnJxLUl49Z8WG8oYXll9RWBY6t6CouIj+dKZ+fvSjK4U/XmldnVVYEkxK/7w2Gg0PWgN79lgDbW2uzouLV2JD4ZHeXTv/PveI48669USllfN6LVRfBERABERABPZHQAJwf3QS917eib+7ZcnIcOzHxaGySqzuNffzQx8CFRX2dG8xtplQ6G/IaWEuQDEt9A/MDwTgU9gzONje8qNHv3nx91EXzooqIiACIiACIiACiSYgAZhoonu1d9pDy4/u3LLpFqzuPZBx9IynSNFOIRZM2H5+NTUWRwAzqXBkM4xQNBSCXIhiWmz/QEwNI9zMntFo7NMP/8+X7zWtq/1EQAREQAREQATMCEgAmnFyvddZT66d2bBq2c3B6TNOgBjKs2PnTbL4YrKG6RdXBh+/Uvj6URBlcqHgZTiafvgIGgezpn8gwsZA9I52b9n8dKBy+qkPnP+ZbZnMQX0XAREQAREQAT8RkABM8NVYsnp16c7VT19aECy9AH5+xW7i+THjBkOwhOrrrcJ9hHVJcHdT1lyUYWOamrBqGAGqDYWwEz8wOhSO9e3aeethJ77/czcccYT5cuOUnZ0OJAIiIAIiIAKZRUACMIHX66SbbzktGo1ejRh6tXZYFxfp24pD5Yjnh4wblVUJ7JH/mmJMwr7GJjtQtWnvOCLKEcFwR2f/QEvztx699DtXmdbVfiIgAiIgAiIgAq8mIAH4aiauX1n8+OOHNz25+k9Yofv6keFoHH5+9VZJTW3G+fm5BjVeYcw/sN0eEXTrH5hfhLAx27bvyCuwzlj2ta89Fm8fVE8EREAEREAEcpmABKCHq79k48Zp25Y+dC3y9n4MmTXy6e9mGtaFo1qM5VeGsC78OxcLfQIRDNqOIWjqH8hpYfpFYhqZ/oGPVB9y0Ol3n3ZaYy7y0zmLgAiIgAiIQLwEJADjIHf+ffcFXtzV8LXCQMnFsCB81IyFH1OwBZG9g6t7s83PLw6UdpUx/8BGaxBZRew0dQYNUQiCvRUZ6B9G/MBfv/ltR1x09YknDhlU1S4iIAIiIAIikPMEJABd3gIn3/ank4Z6em8IVFfNjA1FsLJ12LiF4rKQVVY/087fu3cuXuNGsnVHppVDXuH+pmYr0t9nfJb5hUVWQaCYK427w+1tX4F/4I3GlbWjCIiACIiACOQoAQlAwwv/6ec3LNz56LI7g9Onv3kkgvRtFH6Gq1m5gKFs5kxk8pjuLteuYd+yabfRWAyZRFqt/uZmyw6dY3JyDBsDIWj7B+7YsTUvr+CUf33twmdMqmofERABERABEchFAhKAU1z1Jau3VG57fOnPiysrzoTIKHAT1oXZLYIQfRR/FIEq5gTImSJwEGJwBKLQpDhhY2LDkZHubdsfqK4/cPE9nz29zaSu9hEBERABERCBXCIgAbiPq33ppaP5T9Tf+CUrP/97xeUVoZjL9G0lVVW2n19RKLSPI+hlEwLDfX12NpFwV5fJ7vY+FN4FSCs31NU51NfYeNVx+f97yaWX5o0YN6AdRUAEREAERCDLCUgATnKBT7rttmPCHd1/wJTtfIwmuQrrUlRWZoUw4seAzvLzmwRuPC/RPxABpPswIjjc32/cwlhauWKrt2F3W39r83lPXH75XcaVtaMIiIAIiIAIZDEBCcAJF3fJunX1m5Y+dFvZ9On/BTB5zN3rys+vDn5+0+XnNwFpQv+0/QNb4R+4x6V/4FjYGKtr29Y1RYGiU5Z9/esbE9oxNSYCIiACIiACGUZAAhAXjOnbtqxcdUWgvGIJQosUxSJDxmFd6HcWRBBnpm8rKCnJsMufmd2NhcN2EOnBjnZX16mgOGBFBwdGunZs/+u0+XPPvvvcc3szk4B6LQIiIAIiIALeCBR4q575tY//+TWLe/e0PlhaO+1YjPbZizxMR/0CFRVW5fwF9iKPXA3mnI47gKxLEEsRKfcwPR+x6J85ZcE0MoNNY1o4L1RX/5pwd+8Fta95TbTh8ZXKJjIlPO0gAiIgAiKQbQRydgTwlAcffH3H2o13lM2YfihXmTKLh2kpxEgfV/YGa6flTPo2Uzap3o+ZVwbb2+wVw67TymGxSPeOnU2Rwd7Fj3/3uw+nuu86ngiIgAiIgAiki0DOCcDFzz8/o/Hh5TeVTp/xfis/jvRt02eMpW+DX5mKfwhQwNtp5Vpb7JE+k569lFZuZHS0c9OLq/OCxZ9ccfHFW03qah8REAEREAERyGQCOSMA4edXtO2xVZcVlZdfhBG8QCzCvL2G8eUQaBj5frG6t17p23x+t9tp5ZqbrHBHB2byR416m5ePsDHFRdbwwECsa8uWP7z+Yx/+zA1HHGE+JGx0FO0kAiIgAiIgAv4hkBMC8H3X/OojsdHR6xCUeQZHilylb4OfWWjWbCtQWemfq6aeTElgqLvb6mtssCKII2hamFaOoWNQr7d/186Ln7jqZ780rav9REAEREAERCCTCGS1ADzz6acPavj3o3eUz6x/0wh8xWw/P8NRIdvPb0adhdRv8vPLpDt6Ql9t/0CGjWnZYxn7B2K0lyIwH6u7O7du2R6NRs54/NJLV05oVn+KgAiIgAiIQMYTyEoBeO7atTXb7n/gV2XTZ3w8r6gw3136tkKrdAbStyGmH4WASuYTGPMPbLYGWphWLmp0Qk5auZHh6GjHpo2PlNRUnfGviy5qMKqsnURABERABETA5wSyLAzMaN67r6r9eri17e5gbe2bsLrXOJhzHkZ+gvDzq1ywAPl7sboXK0RVsoMAr2WgohJWYTGYNOMITlnGw8bk5eflIcbjAux/fs1hh09vWLnin5Z12ZTVtYMIiIAIiIAI+JlA1owAvu9XN7w3OjT0m9K6utmM92ZP9xqSZzy5MizwKKmuQo2sQWJ49rm2G9PKdSFsTJM7/0BOCyP+YO+unV3IL3zhU1f97OZcI6fzFQEREAERyB4CGa92zl6zZu72pQ/+OVQ/60hcljxO95oGci4oLrbj+SHnr0b8sueeNjoTO61cG/wDkV/YvmdMamGUmPcM76/OzZtehFfpJ1ZeeulzJlW1jwiIgAiIgAj4iUDGCsBTVq4Mtjy68qpQXd05SPFV6CZ9Wz6mBDnNSz+/gkDAT9dDfUkxAWYRYW7hwbY2+AcahgXCAhGmlYuFB0da16+/LzIcXvzcVVd1pbjrOpwIiIAIiIAIxE0gIx3d3vXTqz4ba29fCgH3dozG2Is8TEf9SqqqrIoFCy0Egran9OImp4pZQYDTuoHKKqu4HP6B0WGz1cLj/oGom1c+e84hxSUlX64+9LBA06rHl2UFFJ2ECIiACIhA1hPIqBHAD/7ud0eHu7pvDU6rW8ggzm78/AqDQQvTxPZCDwtTeSoi8CoCEHaDCCDd19RoRQcHX/X2vl7ganEGk+7dvaNtoLlpyZNXXvnXfe2r10VABERABETADwQyQgl9es2auq1LH7qtrK5uEQK05Y0wi8foiBE/288PU72c8uVoj4oITEWAi4g4JcypYVP/wLy8fCsf2UQsTCN3bt68ZnRk+JTHvv/9jVMdS++LgAiIgAiIQDoI+HoK+JS1a4tnzFlwOUb9bi+pqT0IU3R5fDjDC39KVozjVgrRV4npXk778t8qImBCgPcKV4YHcN8gX+DYtDBGB/dfRu0QM/xFVVo3s64oWPq56gMOPrz+/e+9v2n5cqWV2z88vSsCIiACIpBiAr4VgO/5yZVnDO1qeDg0a9Z7MGVbwJEY09yuAfhzVSyYPxbMWaN+Kb6lsudwHDEuqaq2ikJlFkedudBoqsJ7lD9SMPKcXzFv3usKorELaw8+ONr45BOPTVVX74uACIiACIhAqgj4bgr45D//7TW9u7beFZo567ARPkyRu9d0gQfTt4UYz6+2ViN+qbqDcuQ4TCsXbm+3+hA/0HVaOficdm3b0tTX3HrmM9dc9a8cQabTFAEREAER8DEB3wjAL6xfX7vmrr/8unz23JPzMXpC4ceHrkkpgBN+KXL2liJ3r9K3mRDTPvES4H05gNzCA8gxHOOPE4PCKWXelxjFHm1du2ZVdHTktGd/+tMdBlW1iwiIgAiIgAgkhUDaBeApf/5zQeumbT8orZv+5cLSsgAfsG7isZVUV9ure7nKV0UEUkWAq4S5Wjjc2Wn8Q4XxJykEw50d0faNG2+2wgOff/qGG8xUZKpOTMcRAREQARHICQJp9QF8z49//PGBgcFl5XPmnmDlFyCYs7mfX3Go3KqcvwDir16jfjlxq/rrJCnkSqprrKKyMis2FDFaLez4BxaWluZXzp//FtzzF9YcsHCw6emnV/nr7NQbERABERCBbCeQlhHAT/zjH4c0Pf+fOyvnzXs9AdtTaVOushy7FMzcEZrJsC5I36aVvdl+f2bE+dFVYRBp5fqYVg6ZRYwK/ALpusDSvmHjrkhX26dWX3PNcvsF/U8EREAEREAEkkwgpQLwrGefrdp239Jfl82q/yhSabny8xtL3zbdFn/wEUwyFjUvAu4JjGAEmyKQYtCNGwNHE6ORodGOtWtXRoeHTn/65z/f6f7oqiECIiACIiAC5gRSNgV8zPd/+I1IR9fdZfX1b7RGRvPcrO6lnx+ne7nQIw9+VCoi4EcCvDcDlZUWwxCNxKJmq4Ux8j2K4NEFBQV55XPnzisOlp1fPn9BffPqp+7z4zmqTyIgAiIgAtlBIOkjgMf9389OjlmjvwrNml3PqTJb+Bmyo38VffwYi03p2wyhaTd/EICwC3d1YqFIkzXc32/cJ44G0rWhe9vWnv7dDd94+rpf/sq4snYUAREQAREQAUMCSROAn/z3v+c2Pb7qbxVz4OyOo3B6zDSQM/38ypC+jZk8NOJneCW1my8JcHRvwEkrZ+gfmAf/QNvNAclH2jeu2963p/mTL9xwwxO+PEF1SgREQAREICMJJFwALlm9unT9/UuvR0Dm0zCCN5bBwzCeHwkWIZxL9cEHWwWBkowEqk6LwGQEuMK9H6OBA60txj+EOBLIXNaRvr7RtvVrl0faWj/5wi23tEzWvl4TAREQgWwjgEEjrpQLwSgICmH0AeOWr/Nv5oZlKC1uY+NbrsTrww9phdgCiP2VhArAd/7gRxeWVFR+L1hbW8Z0WGN5e/d3+Fe/F6ypsaoOPOjVb+gVEcgCAgO7d1ndEIJuClPS0QZaWiJtGzdc+9yvfnmhm/raVwREQAT8SAACj+JuOqweNhd2IGwWbNq4wf/LqoCVwij48seNf1O/MFvERKMQDMO6YR2wVlgbrB22FcYFdo2wVgjELmxzuiREAB500klvmX30MX+pXLBgPlc/uvHz25u+BODeRPTvbCIwiAwiXdu3xXVK9A/kavj2jRs6Nt/z97P2PPPMPXE1pEoiIAIikGICEHsUb/Nhh8DeMm6vxZYCsBwWgCW7UCD2wCgOd8H+A3sGtha2FaKQQjFnCodSPZfaw17zVMW8+fmMgWbq5+f5oGpABDKQgJfPB39YjWJkvebgQ2sWvPu4v0MA8ot0cwZiyJgu43oxxdC3YHNgHGnwa2HfIuPGKTA+6HphdBngCAhHO/jQ2wNrx4OO02UqIpBUAvj8UNi9AfZu2HtgFHwc3UtXoeapGTdONS4a78ggts3o73psGZh/JewFfE44gpi1JSECsOaQQ/Pp42RZ8Fr3XBIyKOm5F2pABJJCwDDg+b6OTQHJz1rNoYfxg1K2r/38/DrOgX3nQ6EC5kZUcQSBX9TP44s5Vf499DU6FcaHRSYXCsIBGKfGGnENOB22CfYMbANsB5hy6iwjCvo/Dx3laJKb+ycjzs1DJ/n52IPr+KKHNjxXxbXh9OzbYPzcnADjZ6cY5ufCH3oLx+1EbPkDaTfO5TFsH4Q9Aq78zGRVSYgAZHiXvIJEiD98mqOp+l7Pquuok8kAApG+XjtItPeuInbg2MKqxHzovHfIbQsUVQxvcwTMzTlQOPJL+FhYKhfDGKZ3Qa/8W/hdT8FNo6/VkTCndOKPnXjYcaX5Q7An8LDb6bzp0+3Z6Nc3YW7uH5+eSsK6xc/HzbAlCWvRRUO4f+qw+4dhn4AdDcvklZwUsfPH7XRs23B+j2L7V9iD+Hw0Y5vxJSECMJEUIr29iIG2zULAaKuwJJPvn0RSUVuZTICuEf3NWAGMcDDjwi2TTydRfed3D4Wg25IKPyG3fcr0/eloT3sjjOKhZVwM/g1//xMPu0Zs/Vb4gI7n/vHbeSS6PykfxR0XfotxIrx3Dk70CfmkPU5bf2Tc+GPpbvz9B9iT+Hxk7I8Q3wlAgMWDstUKd3dZZTNmWKUz6uwVkACtIgIZRcCOAYhFH/17kCPYdpHIqO4nu7Pxfmlqyi/ZV8ayZuAQJ43bLnwnc7HRrXjQrUz+oY2PEO/9Y3yADN2Rfp8pKbgvuIL307DPw7JV+E3Gch5e/CLsXNiD4MDZjIfw+aCbRUYV+gz4stDhvbehwWrfsN4abNfIiS8vkjo1OQFmAenssDpe3Gj17Nop8Tc5Jb2aGQQ4XcwH/MN40N0J+6/M6HbO9rIvFWeO+4BuGP+AXQnLJfE3ES/9Bj8Eu5cGJidMfDMT/vatAHTgRQcHra6tW63OTS9akW76L6uIgH8JMO1b5+ZNsM0M4OzfjqpnIuCOAP1xPgZ7YFwIvtVdde2dIgL9yTwOrn0l7Aoc458wikCVsfiE7wWIf4DNn2CvyxQovpsC3he4oZ4ei/6BCDIN/8BZ8g/cFyi9nhYCdqYP+PkNws+PsTBVRCBLCRTjvCgEj8OD7ufYXo2pL4aZUfEHgaQJQFzvg3CK18He449T9V0vqKe48nkd7D++690kHfL9CODEPuMGtB3pOzAtTKd6+lipiEA6CfAe7N+zx3ZV4FbiL51XQ8dOIYFKHOs7sKX4Xn5nCo+rQ+2fwOD+347vXVzjd6MmR/0k/vaPcABvc2o8I4pvBCB+RRoDi8E/sGfXLtvHKtzZiXryBzaGpx0TRmAILgm2n9/OHRZX+poW3utu7nfTdrWfCKSBADM63A2B8FmY+Zd4GjqaI4dMuADEdT0R7O6AHZgjDL2c5mpUfsFLA6ms65spYD4QC5DmagTxzWgmhT5WkS2brZKqKiuEaeGisoyMi2tyqtrHRwSiAwNWH/L5cqEHvhyNe+YIP9ZxU8/4ANpRBNJDoAqH5UrIw3Fffw33ObMCqKSeAL+MEjoFjOvJEb+bYcyeka7C+4kjazSutOXUH43nWwSjjuGWVgpLZ/y4v2bS/e8bAUjRx4ciRWB+fr4Vw9Sa0UMSdTgKGIGPYHDadKusrs4qCChUGD4EKgkmwJXpDOkygNAuI0jJZloc4cf9TX/cmLat/UTAJwQ4+ncBrADf2xfhnldE/9RfGIqihAlAXMcj0d4fYNNTcCo9OMZO2BbYtvG/d2PL1IVMY8jzcgQgR4icUSLOYk4UgBwFYn9njm9nYMuRywWw2bA6GP1Yk1E4HXl/MhpOVpu+EYA8QQq+KB6sFIAUgvy3IwynAkDfKz6cOSpTVjfTKp0+HdlJCqaqpvdFYEoCDN4c7mi3R/2i4fCU+0/cwRF/vJdpKiKQ5QQYHy2Ce/3ruPfNfyVlOZQUnR4F4GAijoXrV4t2roVRSCWjUMytgT0Oe3T8b6axoxBMeMH5cFSQfqv1sMNgb4FxJfuhsFmwRLgvrEA7m2AZU3wlAB1qFH20iUKQI4ImhasxGXuNQjA0a5YVqOTshIoIxEeAoYf6mhqtIaxAd1MmCj+N+rkhl3X77sAZcfQiEQ+YqeDwFy+/02kcCQnB0jEdchGOy/P+BUwltQQ8j7xCLPE++hGMIinRhbmn74b9HbYB35PuflHH2Zvx4/BYHFF8Dnb7+HlytPBw2FGwd8LeBKNIjKf8BcdxRibjqZ/yOr4UgA4FRwhyNLCwsNAWhaYPU/oHdm7aNBY2ZibSygUZs1FFBMwIcKSvH8JvsL3d1cidhJ8Z3xzZiw+Dz8Eeg6VCAPIYnBLjA5y+UMz7Ow22YNw42sGH3QEwisNklsvwgH0Gn4cVyTxInG1zlIbTdWSVTaUHJ0PzWk5BA5/22she9Zfh3xxRvB/3BH8Qpb2gHxxVah63ZbhfL8ffHA1kHuPjYf8FOwRm8tltwn4PwzKqpFwA8gFZXF5u8QFrmh6Lo3+s59Y/EBfUDhsT7uqyU8oxtVx+Ef1EVURgcgL07Rto2WP1t7RY9PkzLbw/aSymP1KctvPg8lBaU2PHtuTiEtPRbqe+tr4mMID7IhEP5YScJL4Ty9HQbNjbYcxc8A7YHFiiC6dersHxjsf5tya6cY/tfQ31l3psw2/V+eVDHxNPI2q4Xrxul8BMRA92m7Ksxx7fhd2F+8D8C3XKZhO/A/pHfg2wO2njLI7E3yfD+Fk5ELavsgz1d+3rTb++nlIBWBgoscrnzLZKqmusKMJm2CMsHVhJieneqQouRvz+gXio9zU2jE0LYzSwBA9bPnRVROAlAri/uJiI073DWOXrpuCDb4s/3qM0NyWAH0OhWbOt4goO1sA7OVRu9ezeZUWQUcRtW26Oq31TRsBXXzS4V+nLsGHcbsI9xumuD8DOhB0LS9SDH01Zb4R9GfZN/sNHZRgcEuIr56NzSlRXzkFDr09AY/wi/DXsW2Dttx8ARqeHfndhR/5QYKzLWmw5KngGbBGMLhZOoYC5y/lHJm1T8uXEVbnls2dbtYcdBvEFjnhgFpaUWJULD7BqDj7ECow//EzAcXSFC0VYnBFBk3rcx04rt208rVyvb36Um3Zf+yWJgO0uwPRtWza7En/4grD9VNkt3pduBFtRSdCqXrjQqjn0sJfEH9sphCDka5Xz5ln5cHtQEYFkEsA93AS7Ecfgw+3DsOWwRBbGB3xtIhtMQFuJFLkJ6I4/mhj/MXB+AnrDX9Bfgp2Heysjxd/eDHAe7bDb8fqHYPyh9AsYp49ZdsIesf/KsP8l/QlTBN+7mkMOtfKLiydFw5GPajz0wkih1YfsHqarLJ1pYS4UcesfqLRyk16KnHsxNhTGPddsp28zGYV2AOGLIO7p3kL8GCpDOsMgVqrn7Uvg4Z4Ozqiz3Rci4z92nGNrKwLJIIB7mtNzDOj8T2w5CsRRu0RMDXPk5Kto9xwcY+qpHuyskjYCnOpc4PHoFH+fx7X+ncd2fFkd58WRzWdouKeZCvECWB9eb8M240rSBWABRvr2Jf4cWoBnBRG2JVBViVAuLYizBv8rgwcfLoDtL8X6zmgghSFfn6pwnwGIzjBWeYbwMObxNeIyFbXseJ/31mBbK9IJNlvMKuOm8F6j8f4xuc+ctnlvMTRRGYRdAX4MTXWHjo5iRNGprK0IpIgA7u0IDnUd7u1/Y3st7F0wr+XjaOBq2NNeG1L95BDA9eYIzSc9tk6Bz/A/WSn+9maD89yK1y4Au6TrqL2Pnah/+6rj+UXF8BGcAx/B6rHQG1i8YfKQ5T57xw80daSnoz99rgYR5y1UD/9A+CdyilolOwkwPFBfozc/PzeLPCgWA3tlqpGwy857K5vOCvftenyvfgTn9EvY6R7Pjf5SZ8MkAD2CTGL1t6JtLnjwUm5GZd4vOVXwWRnzScvAs/aVAHT4MaVb9UEHW0NdnVYvH9ZwiDcpfDDT4gkbQ8f/zi1bkFau3SpDWrniULKjJJickfZJFAHeQ1zgwRXh+FVh3CwFHI0/MtwIPx6A93E5Y1FWVRsfTzuKgF8I4L7vwn3/WfSHo0McxfNSPoS2vo82Hb8pL22pbuIJMN9viYdmORr2TVxf8y9XDwdT1cQQ8KUAdE6ND87i8gpM1WK6bs8eK4aVwybFi38gBQJ9BIPTptlTw5zCVslcArEIVps377HvoVHDYOI8W4o+Gotb4cdFT0xJWIrUhMpGYyPU/zKUAD4DfRBun0f3D4C9xcNpzEXdd8Nu89CGqiaBAK4vdcAxHpv+Ce4ViXuPEFNd3dcCkDD4AGVqN04L80FO3y2mfZuq4KZ+hX8gH+Z8kPP1qQoXBAwgDtwQwoLw2PIPnIqY/97nNeS9wkUepj8cnLPgwiIW3ism98tL9XCv2vmoZ9LPL+C8rK0IZDQBfHe24nPAcC73wbxMjXCUSQLQf3cDF/swQHi8ZSMq3h5vZdVLHwHfC0AHDR+oFQiNEaytwVRekx2zzXlvf1s+wOP1D+QCgZf8AzGVZ/sH7u9ges8XBOg60NfUbEX6el31hz8SaG6FHw/CHyj0IS0q8/J8dNVd7SwCKSOAz8Wj+Fz8HgfkaGC85Ui0UYu22uNtQPWSQuANaLXOQ8t34pp2eqivqmkikDEC0OHDByz9A8MIIO0maC9H/2hx+wdu3mwLQPp0FZaWOt3R1kcEovDjtP38MHJLEWdaKPporON2urcI90IIPqMMLq4iAllOgLHPPgFjaJd4yjxUOgT2eDyVVSdpBF7voWX6Zd3job6qppFAxglAhxUfuIFKhI3BVC1TdyU7rRyPyxWkEfoHTp82Fs4Dvl4q6SfAldycsu/HfWASPsjpsSP8+G+KPzeikaFcShHShekF5efnENU2mwng87IRnxFmRoh3VTAXkzA7iASgv24U+nfGW7agIjPLqGQggYwVgGTNBy+n3YIQgxz5GWxvT35auVjUjh8X7oB/IHy95Oifvruefn72SDADiA+6y+zkiD+3wo8pBIMI5MxRPy72UBGBHCPwZ5wv48WNOcq6P/nXua+iGskigO8/Xsf5Htp/Ad+l3R7qq2oaCWS0AHS48UFcuWAhhGCtLQS5itekONPCdPrn1DDFgGn8QK4u7dm50xYgIeQXDsAHTCV1BDgSS9Fveq2dnk0Ufm6ne5mykMLPydvrtKmtCOQQAcby42rPWXGe88H4nsXHUOFC4uSX6GoVaHC2h0Y3eairqmkmkBUC0GHIB3MN0soNjgf7NR0VcoRgPP6Bdh5Z5JAtQciakPwDnUuRtC2vaT9G/OzR3hT5+RUinSGvbVBBwpN2XdVwxhBoQk/XwuIVgDNRl07UZsFdsaNKUgmUo3UvK9cY/08lQwlklQC0rwGc+TkSGKhgWrlm2zfM1C/MiR9IIchRQf6bo4JTFe5D0TnU22P7BpbCLyy/qGiqanrfBQFeQ/p6Mh6k6fV0mo87rAvTt+FaMhSQ0gQ6NLXNZQIYuYvh+24dGBwfJ4cq1KuESQDGCTDB1eiXSYu3ILK+SqYSyD4BOH4l+MAunz3HHrXpw4gRfcVMxVy8YWMoTHobG8bTyo2tDKXPmIoXAqO4dgzr4i19m8m1d3rJaWIuMuLUvlZ8O1S0FYGXCNDxP97CtHA0FX8QoPiL15mZoyMS8v64jnH1ImsFoEODD/CqAw60hmqn2SIi0msWG87LtHA0HLa6tm21Am1t9tShfMacq+Fu+1L6NoR1cVMo4GgUfW79/IrhQkA/P64wVxEBEZiUAKeB4y1BVKSp+IOAlxFACsBhf5yGehEPgawXgA4UPtD5cB+EKOPUMEWaSXGmhTmNWIhRRUcYmtTllHDkxV571WgZR5PgS6YyNQFm7rCn71tbjVZ1Oy16EX6FSPlnZ31BCkCN2jpEtRWBSQl4GfUpQIs0FX8QoAaId5qK9ZQr1R/XMa5e5IwAJB0+2OnTZaeVo38gBIaJPxlHkhwhGI9/4ABEJ3MM2/lhETtO/mST36vM1ctrYud9xiprN8WTn9/06WN+fvLbdINc++YugQGcOvNxxiPkmGA7p547Pr9NOIIXhcU7DazwFz6/wPvrXk5+ELlAo3zOXPh5IWwMfPbChlOMFIKe/AMbxo5lZ45g2BhMU6qMEeA16IefX6Tf3eDCxFE/N35+PKqdvm3WbIvZPFREQASMCVD8Tb06bvLmWG9k8rf0ahoIOAIw3kMviLei6qWfQE4KQAc7H/xpSSvHsDHKHWtfhmGmb3Mhwp1rN1H4ufXzU/o2h6K2IhAXAY78xfvrleKPAlLFHwQ4mkuL1+n5Tf44DfUiHgI5LQAdYE5auYFWpBNDmBG3aeUc/0DTsDE8Lke8hrq7rdLx6cdcyyoxEonYrAfazKbhnWvlCD/+263wY/o2exp+utK3OTy1FYE4CDDGVbx+YxKAcQBPYhWusKPVx3mMt2DmpQbfyx1x1le1NBKQAByHz7RyXKhRgmC/TqDhEfikTVX29g/kvylMTKYjmcqMgpNisGzmzJxIK8dzHuxox3Qv0rcZLsRxroEj/sjWhK9TLx/XlunbeH1zTWg7DLQVgQQS4Gq2eEcAI6irlaMJvBgem+pD/RbYa+Js5wDUezvs3jjrq1oaCUgA7gWfAqFi/gKrhGFjMDXJUTqTQkESr38gRxzttHLIZVyG3MYUodlYhrq7EIqnyTINxeMwmCj83I76cfV3CH5+xSEvwe6dnmgrAiIAAl4+TJxudOfoK+RJI4Dv1hE8uzbiAO+K8yAcCT4HbdzHtuJsQ9XSREACcB/gKRhqDj7EHp1zE4SYAoUWV1o5LICIbB73D8yixQlM30bhx5E/DN3tg/irX/Yi/F7y89Nim1eD1Ssi4I0A88fGWyj+KAJV/ENgNbryWQ/deR/qLoI97KENVU0DAQnA/UEfzwjBQM5MQzbQ0mLFhs1mL+ING8PucEqYo2Sl0xieBGFj4LuWiWUErMisH+xMwu045+gIP/7b7YhfAVZ4M9RPqcLtODi1FYFEE6jz0CAFoEYAPQBMQtXn0SYD48Yb048uAd/HKOBqfHebTZkl4STUpHsCEoAGzBi3j9OInJrlSFYYI1mc8p2qcB9OC1PQcESQ/6agMalLwWSnsEOOYfqu0YeNfoqZUOjnx9R7HDlNlZ8fGTOsTwhT6Aq4nQl3ifqYwQTmeuh7M+q6C/Lp4WCqakRgHfZaD3uz0d6T73QUXr4cz7Yv4rt4auf5ydvQqykmIAHoAjiFRdUBByCtXK29UGSop8eotiMEuVqYQtCZJjapHEVWjO4d2+3p03L6smE00s+FI5cUfqa+k865UMDRHJHsvG6yDYAJRbLSt5nQ0j4iED8BfD75K/Sg+FuwduFzPvWvZw8HUFV3BHA9+nFdH0ItLwKQBz0P1oa2/hdtyh+QRHxeJADjuEAUGhQdg1i04WaUyxF+cfkHQlh1vLhxPH7gLIs5jv1UONLX39yMVHtI32YwOur0naKPxjpup3uZvo1BtTk6qqDaDlFtRSCpBGag9QM9HGGbh7qqmjwCf0XT58PinQZ2evYt/FGJ7/NL8L3OFcYqPiYgARjvxYFoCSJvLMUgfdwGkcIs2f6BFEmDmFrlyGMZfNzo68asJsaFIgtTy1x1bPvkOUIN58JpbsbJs9PU4d+mhe0wfdsAUuuZnr/Tdrzp2+jnF2T8RPr5uTl/58DaioAIxEvgjag4O97KqMcVpyr+I/AUuvRv2HsT0DUKycPwvLoIIvA/CWhPTSSJgASgR7B2WrnZc6wg08ph6pO+bxRqUxXus3fYGDf+gb0IUcNVtXZauZoaO8/xvo45jNXFnJKN9PZYXJHL+Ib005tYmCeZ8fI4zV1cXmEL26Kysom7vPJv9D8M/8Q+jPqxfTdl4qifCSunbdZj0G6es/z8HCraikBKCZyIo8UbBLoXdV9MaW91MCMC+G6N4rv4eux8HCwRzubHo51laPP/sP012mewaRWfEZAATNAFGfMPPNAasvMLM6et2ei3My0cl38gpl27tm21AuNCsLi8/OWzgUAb6um2V+FyxHBvwffyjmN/8f0YDSt3uT/FLKe5OcoYqKh8xRTrcF/fWPo2wxiJzrEmCj+3073FZSEsxJllBaqqnOa0FQERSCEBPMyn4XAUgPGW3ahIU/EngX+gWw/C3peg7vF++THsdNw7V2P7VzwDlDEkQXAT0YwEYCIoTmiDAoVCbLC9zfaJ4yIOk+KM/jlp5RxhaFLXHt2DaAsibEwIGUWQJ8Pqa+AIYfyfNXslb1eXFYYFOeqGUU4KOGYuYcq8qQTlxH57EX6FCMzNLClBBObOlFXQE89df4tAFhH4AM7Fi//fc/guUJgQn94QuDYRCLUfoHvHwhLpZE63gRthX0H7f8D2b7B1ON7UU2XYUSV5BCQAk8CWQoVx6AJV1WPxA+EjZ/vcTXEsfDisifEDKZwcYThFVXvamcKM07IsJsebqk3nfcfvkAstGNvPTYnXz4++iMyTTI70TVQRARFIHwF8N3FxwGc89kCBgj0CTHZ1PHNW4FpfheNckoRjHYY2vw/7Bmw5jnMvto/ANuG4UWxVUkxAAjCJwClcyufMHYsfCJ+9MKdMIfKmKhSCe/sHUhialEQKv4nHc9suxSuN50IzLqhTMp6+bb8+iMYNakcREIEEEPgw2jjaQzsc+XvcQ31VTR0BTtseA+NIYDIKUwl+cNzoK/UcnhErsF0JWwPbLUEICikoEoApgEwhU420ckOYTuXiDdNFE840cDxhY1JwWpMeYqLwY//dFHJirEP5+bmhpn1FILkE8HBmcnKOCMW7+IMdfAKmBSAk4fOC7/AeXPMl6OZ9sAOS3F2KQYpNGgsXi/wHx38S21WwF2A70CczXyrsrGJOQALQnJXnPR3/QCc9GsOxmBRnWtjxD+S/8QExqZqyfRzhxwO6FX4cKXXC2sjPL2WXTAcSAVMCl2HH15vuvI/9/oTvCE3z7QOO317GtdqIZ8zZ6NedsOkp7F81jvXOceNhuXJ8wwRB+Dz+vQX9Uz5p0vFYJAA9AnRbnQKnDOnKSqqr7VRvDCZtsqCCgs8Rgm7Tyrnto9v9HfHHPtJMC0PPMIhzCFk8ChDUWUUERMBfBPB55kjQeR57tQv1/+mxDVVPMQF8rz+C638GDnsLzEv+Zy89Z2iL/zduX8B2ELYZ/eIIIV0KnoXRh5BCUcUlAQlAl8AStTsFT+WChbYAYn5h09RpFFiOfyBHBE19AxPV773bYR/YJ7ejfgygzby9jDmoIgIi4D8C4w//n6FnXp8Tf8ADutF/Z6geTUUA1+1B3AefxH6/hS2Yav8UvB/EMTgaTTsXxqnh7ejjU9hyyvgZ2Ab0m1PJKlMQ8PrBnqJ5vT0VAQqgGoSNCXd02rH3hgfMRrbdCq6p+hHv+277UYQUdmPBqznSnxfvYVVPBEQgSQTwMOVz4cuw78G8Ds23oI3fwFQylADE1HLcEyei+9fDOD3rpxJAZw4dtzOxZZiKBvR3Nbb0O+V2HawV52E+PYUKuVAkAH1xlccyXBQj8PIA0srRR9BtWjVfnMZ+OsH0bQwqzbAudrq5/eyrt0RABNJDAA/O1+LI34V9NEE9+C0evFsS1JaaSRMBXMP1uDdOxuG/D2M4oKI0dWWqw7JfC8bt49jGYHtgz6D/HCG0VxrjfNrwd84XCUAf3QIURiGsgi0ZzyYSRoYP3LQ+6qH7ruCDZp8Ps3gUys/PPUDVEIEUEMD3zCE4DKfUzoExg0MiyiY0cmUiGkpwG5n9pZpgGKbN4buc06pfwL3yILY/gL3GtG4a9yvAsWeN2wexpSDkCCHF4MOw5bDNODd3IStQKRuKBKAPryKFUtUBB1hDtTVIuYa0cki9lomlODSevq2yKhO7rz6LQFYTwEMwhBM8CkYfL47uJEr4oSmkI8JoER6sHH3xWykbP3eKg0wv9KMZBOeUhUnBsf4Gfo/huBfAPgtL5H2D5pJaeM3njdup2PbAHsf53IvtfTi3rdjmTJEA9PGlDkA40UdwsI1p5Zos07Ry6T6lsfRt9UhNh/RtWCSiIgIikH4CeMjx4ceQHm+CHQc7HvY6WDI+pLej3T/C/Fh+gU79EJaM8071+fKa/gTGXLspKxBKrTjYt3BP/QlbCkG6DNCxO9MKVyG+d9z+F+dzP/7mfbsc58gVx1ldJAB9fnkpoOg7V4Icw/3wDWS6N7dZOVJ1imPp22Ygpt8MKx+x/VREQARsp/SUYsBDjN/rAVgtbDZsLoyi7y2wN8IY0iOZK7DWo/2v4AFKh3w/Fp4/LVtK2oQXrvEaQPw07rkrsV0CoxCcA8vEwpHMxTAuJuGo4HXY3oNz7MI2K4sEYIZcVgqq8jlzbCHYvXWLNTyUshF/I0JFgYBVecCBVhGmfVVEQARsAhRZ38CDZOc4D/oZ0eiHNHHrvL73ltOozmv8e6KxbUfo8dcWBR99LSgGaBQ49H0qg9ExPlWlAwf6PB6ajak6oI5j3yNpxYDrvRYduAD3+o+x/TCMbgWM3+d1FTmaSHnhZ+vt4/bCuLj9M87RLERHyrsb/wElAONnl5aaFFjFCBvjNwHIPkn8peWW0EH9S4APkg/4t3sJ71kfWlyCB+XyhLesBjOCwLjwvxai6QZ0+K0w3v/vhTFuXxCWaeUN6PBvYRzl/BHO7x+ZdgL76282+EDs7/yy8r0RH64M9mOfsvLi66REwJ8EKP6+gAfkXf7snnqVSgK4D6KwJ2DfwXHfOW4XYXs3bBcs09ICvgN9/jtE4K9h8/F3VhSNAGbFZdRJiIAIiEDaCOzGkT+Dh/0/09YDHdi3BHBfRNC5p8ftSggo+qYeDuMUMada3wabBfO7HuGCm0/DjsM5XILz+iP+zujid+AZDVedFwEREIEsJ/AUzu+zeBg+m+XnqdNLEAHcK+1oasW4OYKQMQUpBI+GURj6WRAuQP9+DxHIhVWX4Xwy1jdQAhBXMNMK8+/6rfixT35jpP6IQBYR4BTeNTDG+uMDXUUE4iIwfv88iso0Jj/gCCEF4ZEwRxDW428/6RX25WuwQ9HfczP1M+AnoGCpYkKgACtu/Vb82Ce/MVJ/RCBLCDCLAoVfVjnEZ8m1yfjTmEQQMjzLZIKQU7LpLiejA+UQgf+Nfu9Od2fcHl8C0C0xH+xfFCq3cLP5Jk0c+8I+qYiACGQ1gQ04u5/BbsNnvj+rz1Qn5xsCuNfa0JlHxo3Pven4e29BOBOvpUsQvhvHvg39+hj62oq/M6ZIAGbMpXq5o4XBoB1oOeaTWICMUcg+qYiACGQdAcYhXAm7CcaguHwYq4hA2giMi6x/owM0CsIZ2EwUhEfg36kWhFzpfAP6shj944r4jCgSgBlxmV7ZSWbcCFRUICuIP35ssC/sk4oIiEDWENiGM1kKuwv2KB5qQ1lzZtl3IqkM9O07erg3W9Ap2nIIMMbe5Ajha2FcYXwsjIKwBpbswgDYl8K+kuwDJap9PbUTRTLF7ZRU1/hGALIvKiIgAhlNIIzeb4I9BrsPthIP1mxd3PE3nN9mWLqmDHHohBWew4qEtZbhDeGeZbYcRxAugyC8HP+eC2Mcvw/A3gPjiGGyyhdwTOYRvjdZB0hkuxKAiaSZwraKkRGkqKzMGu5PrysO+8C+qIiACGQMAaai64Ftgf0H9jjsSdgmPLjS+4WCTqSg/Arn+UAKjqNDpJkArjPv9e3jdivEGYM4vw92OuwYWKJDajD13RU4zpM4NoWor4sEoK8vz747l1dQYIVm1ltdyAuMm23fOybxHdzgdh/YFxUREIFXEaD/3G9gHEljbl7m6OVwOcNcVMHoOMsl/fwe5oeIxiksr4UhWmgRWBdsF2w3rAHGkS8u5qD424PPcC5O7TJ3skoOEsD9vgOnfT2emb/F9r9gn4N9CJbIhxiDXLPdy2C+LhKAvr48++9coLraClRVWeHOzv3vmKR3eWz2QUUERGCfBG7GQ4eLKOyCBw+/cylAOFJQBuPy+dLxv7l1jO9xHxr3p00UiBR3wzBnSyFHsUfrhfXBOMpH8dmHPnBfFREQARDA54GfmwfxeXwI2+NhF8PeBUtUOQ9t/wHH4Q8t3xYJQN9emqk7hpvLqpg7z4oODlrRMF14UlcKS0rsY7MPKiIgAvsk8Iqgnfi8OKNzA6jRsc9aekMERCDpBPB55PTZAxBrK7D9POxbsEqY18JVyGfD2J5vS6Lnv317otnaMQZgrly40MovSt1CMB6Lx1Tw52y9q3ReIiACIpA7BCAEB2A/wRlzOnhjgs78FAhLX6+QlABM0JVOZzPFCMJcdcABKRGBFH88Fo+pIgIiIAIiIALZQgAi8BGcC7N7rEnAOR2CNk5IQDtJa0ICMGloU9twoKLSqj7gwKSOynHEj8fgsVREQAREQAREINsIQARyBPB0GBdPeS0Uk74tEoC+vTTuO1aMgMw1Bx9iBcoTPzrHNtk2j6EiAiIgAiIgAtlKACKQ4ZHOh3FxlZdyJKaBkxl30EvfEh4Dx1NnVNk7AaZkq4ZQq5g3zyoofoX/eVyNsw22xTaV7i0uhKokAiIgAiKQYQQgAv+OLv/OY7fnof6bPbaRtOoaAUwa2vQ1zLh8ZXUzrdrDD7dKpzErTnyldNo0uw22pVh/8TFULREQAREQgYwlcAV63uKh9wzddISH+kmtKgGYVLzpbbyguNgqnT6dMY9cd4R1gqjLNlREQAREQAREINcI4DnIOH63ejzvN3isn7TqEoBJQ+v/hvPz8y2aigiIgAiIgAiIwKQEbserjNsZbzkUfoAM7O67oqe/7y5JYjuUniRxiT0HtSYCIiACIiACaSLwHI77godjcxFI/L5YHg48VVUJwKkI6X0REAEREAEREIGcJIBpYKaNe8TDyTNumi9jp0kAeriqqioCIiACIiACIpD1BJ7ycIbM5z3HQ/2kVZUATBpaNSwCIiACIiACIpAFBDbjHOL1A6TOkgDMgptApyACIiACIiACIpBbBNpxup0eTjnkoW7SqmoEMGlo1bAIiIAIiIAIiEAWEOjBOdDiLbXxVkxmPQnAZNJV2yIgAiIgAiIgAplOgAtBaPGWafFWTGY9CcBk0lXbIiACIiACIiACmU5gBCcQ83ASrO+7IgHou0uiDomACIiACIiACPiIALUS07rFW/bEWzGZ9SQAk0lXbYuACIiACIiACGQ6gSKcAC3ewkUkvisSgL67JOqQCIiACIiACIiAjwgE0JdiD/2JN4SMh0NOXVUCcGpG2kMEREAEREAERCB3CVTg1L1k8/Cygjhp1CUAk4ZWDYuACIiACIiACGQBgSqcA0VgPIWrh3fFUzHZdSQAk01Y7YuACIiACIiACGQygdnoPKeB4yldqNQST8Vk15EATDZhtS8CIiACIiACIpDJBF7vofPMINLhoX7SqkoAJg2tGhYBERABERABEcgCAm/2cA6tqNvroX7SqkoAJg2tGhYBERABERABEchkAqOjo0zj9gYP57AxLy8v6qF+0qpKACYNrRoWAREQAREQARHIcAJvQf8P8HAOT3qom9SqEoBJxavGRUAEREAEREAEMpjAieh7vFlAhlD3Ob+euwSgX6+M+iUCIiACIiACIpA2Apj+nYmDf8RDBxj+ZbOH+kmtKgGYVLxqXAREQAREQAREIEMJfAz9nu+h70/B/8+XK4B5ThKAHq6sqoqACIiACIiACGQfAYz+TcdZne/xzP7msX5Sq0sAJhWvGhcBERABERCBzCAA0ZMHky4Yu1xfxuZQD1duJ+o+4qF+0qvqQicdsQ4gAiIgAiIgAhlB4BD08u8QgYth5RnR4yR0Euf+HjTrdfRvGaZ/m5PQvYQ1KQGYMJRqSAREQAREQAQymsD70fsPwn4PexRC6AJYXUafkcvO43znoco1MC8CmKt/b4b5ukgA+vryqHO5SiDP4n8qIiACIpAaAhA+xTjSRycc7Y34+yrY43jvCthbYfGGQ5nQrH//xPnVo3e3wg7z2MuHUH+FxzaSXj3pAjA2NGSNDA8n/UR0ABHIJgKxobA1Eotl0ynpXBmX9xkAAByGSURBVERABPxNgILviEm6uBCvfRX2KOyfEEnnwBgeJasKzulAnNCfYMd4PDF+cV/j1+wfE8+tcOI/kvH38MCA1b5xgxWaOdMK1k6zrDyNaySDs9rMDgKj0WFrYM8eq7+11Yrph1N2XFSdhQhkBoEPo5vB/XSV7x03bjsgmDjK9Q/YCogd5rvN2IJz4XldCzs4ASdxP9r4VwLaSXoTSReAPIPo4KDVtW2bFe7stMrnzLUKg/u7x5J+zjqACPiSQKSnx+rZtdPijyYVERABEUgVAQgg+rud5OJ4jI137rhtR32ODlIMctsEQTiKre8L+j0DnfwK7HOwUAI6zJh/38b5RxLQVtKbSIkAdM4i3NVlP9zK58wZGw103tBWBHKcwGBjo9XT3KRp3xy/D3T6IpAmAkfjuIfHeewFqEdbDGuCrYGwegzbFbAXIIbasPVVQf8Y4+80GIWfV3+/ief2E5zvcxNf8PPfKRWABBGLRKzu7dut0diIVTqD4ltFBHKYwOio1bd7l9WHaV98KeUwCJ26CIhAGgkw40Ui9AAXUdBOgPELjVPFL2D7PIzb/8A4QtiNbUoL+sGpxzfBmNqNdhAskWUZGrs6kQ0mu61EXHDXfRwdGbGnunATWMHpFOIqIpB7BOgN29fQIPGXe5deZywCviEAYcQwL+9NQof4Fbdg3D403n4ftrtwzE3YboTtgG0b39KPsB8WhjbwtAIO7XOBayWMo0wUfVzYcSSMC1242jnRZSsaPA/95vllTEmLACQdisDunTusgkCxVVzB66QiArlFINzWBvHXrJG/3LrsOlsR8BuBRejQ/BR1in52nGree7p5EK9xqpjWBQHXhW07jKKQ2zBsCEbfOm5pFIlFsBJYAFYF44gSVyjPhTGe3ywYj5nM0onGz4X4ezGZB0lG22kTgDyZsZHAXVbNoWVWfmFau5IMtmpTBPZJIBYOW92Y+h3BDyEVERABEUgHAQgtjtKdko5j73VMTs9StNEyqXDE7wsQf8szqdNOX5MeB9A50L62XPHYj1EQFRHIGQLw9ett2K0wLzlzwXWiIuBbAlwAcbxve+fvjnHF71kQf3/0dzf33bu0C0B2baClxQ4Vs+9u6h0RyB4Ckb5eOyRS9pyRzkQERCBDCXAq9YkM7Xs6u92Eg58O8XdXOjvh9di+EIAj0ag12JbRcSS9XgfVzyEC4c4u+f3l0PXWqYqAXwlAwHDxwgdhn4I949d++qxfDHHzQbBb6rN+ue6OLwQge80YgRSCKiKQzQR4jw91079ZRQREQATSTwBCZgh2C3rybthnYE+mv1e+7AEXnVwD+xB4ZYVY9o0AjMIpPtLb68urrk6JQKII8B7nva4iAiIgAn4iAFHTDbsRfaIQ/Cjs7zCGZVEZi194GvicD6PvX1YU3whA0pQAzIp7SiexHwK6x/cDR2+JgAiknQAETj/sr7APozPHwn4AWwvLxZAFFHuXwd4NHndgm1XFV7FXomGGAlIRgewloHs8e6+tzkwEso0ARA+nOp9BuJgrsD0a9iEYVw0fCPPVABL6k8jCeIR3wq4BA4rfrCy+EoBMEzcai1l5BQVZCVsnldsEeG/zHlcRAREQgUwiABHUg/5y0cNSiMEabN8KY7q398AOhiU72DIOkZKyHUe5DfY7nHPGBXZ2SyghAjAvnz8EGE+Sqf88FMRHw81lt+ShFVUVAV8S4L2NGzwBfcuzxj5zGf1RKYoTBOvxyyaVJd6+8osxm0dJUnkN9j6Wl1ECXZO9abr4N4QRp0UfpOE7jVk4mNWDadbeBaMwnA1jYOdMKQxBsgz2V9hynF/OBCZOiABs37h+tO5Nb80bGcYIXkIecJly36ifIpBaAvhysvKLiq09z62hkhxI7dETdjT2/XkYV9XRTAsf3Lthw6YVErAf+/c0jCMgbvpKkUqfKS35BoQklJ1ok9fFTegI54cDBYxKAgjg+4gr2p4dt+vw/Gde10Nhbx63N2C7EFYNC8D8ULiwZTuM8Q8fhT2C89iKbc6VhAjAtnVr3xasmXZn5YIF80cwzTUyHO/3s/P5zLnroBPOGQLx3+P5RUVWPtwj2jdu6Njx8ENnA9mmTMSGL1t+QZyNh0VcMFA/EcOoRuhwLD4sTo+nr6nsp9HJZNFOYHsDrsmv4zklXZd4qJnVAdtu7MkwMnYoGVwjjtTWw+bCFsKYeWT+uDFPL/P3crSwFJbokVn+YGNoEfrzbYGth62DPQPbgL7ys53TJa4v4H0Re+cPfnRhSUXl94K1tWWMd+Y2rl9BcbE17TWvxQhHvDMu++pZ7r4e6euzOjasn3RkNt+euscwxST5aPHhsGoOO8wqDpXnLrwEnzl/GOHHkms/QObJpiFjTqRt44Zrn/vVLy9McNfUnAiIgAiklADEIUcLOTJIEUi/wtpx42sVMPoVUhg6ApHCgIKSRrE4NG4chaRzNfPytsP2wDiN6/zdOC5M8ZLKRAIJFYBseMnq1aXr7196fWhm/WlFZWUF9sKOSQTGxE5M/Lt0+nQrNGu2RTGo4p2ABKB3hologZ+DvsYGa6DVPOMN/fz4OcA1HG1bv3Z5pK31ky/ccktLIvqjNkRABERABHKbQMIFoIPzk//+99zGFSvvKp87/4j8/Ly8GKeFDf0DCwIBKzRzphWcNt1xdnea1dYlAQlAl8ASvPsofvwwzWFfc7MVG+IPVoOC0dcCjIKPxEYwertu60Bn+2nPX3edPaViUFu7iIAIiIAIiMCUBJImAJ0jL/rB5R/ILwncVFY/a4Zb/8DiUMgK1c+yAlUcKU56V50uZ9VWAjBdl3PUGurqtvqaGjmCZ9wJx8+vZ+eO3s4NG772/M03XWdcWTuKgAiIgAiIgCEBzqUntWz/10Ob/nvp0T/bcE9vLK+g8OiiUKgwDyOBmP+f8ricNgt3dljRwUGrIFCsaeEpib16BzIcbKMP7KsL/fxYJrsWfC84bRqY+2Xh1qv779dXhvv7rN5du+wpX/I3KVzckY+R76GurmjLM0/fFAg8duwTV/1Vo34m8LSPCIiACIiAawIpHVY769lnqzbfe/9vKmbP+TAEXT6d4jlFZlL4gKR/YFndTCtf/oEmyOx9NAJojMrzjiMQe/17mm0/P452mxT6+XHULzoUGW1bu2ZVNDxw2rO//OUOk7raRwREQAREQATiJZBSAeh08iO3/+Xwrt3b/lJeP/uwEYwE2mFjDEYEWb8QoyRl8g90UE65lQCcEpHnHRw/v374+UVd+PnZ070Yae3curmpb3fT4mev/+XDnjujBkRABERABETAgEBaBKDTr3f9+CdnFAZLf1E6rbZmJIr4gVGGBzMrDE8SmgX/wEr6B6rsi4AE4L7IJOb1oW74+TXSz4/hpsxKfiHi+RUWcGHIQNfmTZc9c+01V5jV1F4iIAIiIAIikBgCaRWAPAWEjSnatPTBH5TMqLsAYWOKORroZvqspLraXihSGGSoIJW9CUgA7k0kMf+mXyoXeIQ7O125MXDUL9LbG+tYv+722EDfkqdvuCFTs3kkBqRaEQEREAERSAuBtAtA56whBKe9+NCym0Oz6t+PxSKu/AMZMoP+gaUz6hRE2gE6vpUA3AuIx3/yB8pAyx7bz88ObWTQnuPnNxKLjnasX/+0BT+/x6+8crNBVe0iAiIgAiIgAkkh4BsB6JzdB2+5/Y39zQ1/Lp81+xDbP9BwFSXrF5aUIH5gvVVSW6v4geNAJQCdO8vbln5+4fZ2TNs2WdEwA8+bFS5YQhhMq3PL5ub+5pazn7n2F/80q6m9REAEREAERCB5BHwnAJ1TffePf7K4sLT05yXTplXb08JILWdaAuUVVtmseitQIf9ACUDTu2bf+w31dFv9jU3WUG/Pvnfa6x07fRtGpvubmgbh5/fdp6+95vK9dtE/RUAEREAERCBtBHwrAEnkrGXLSnY8/dxP4Oe3pCgYLGKYjcny1k5Gj9NuyEkM/8B6xBAsmWyXnHhNAjD+yxwbCsPPr8kaxMifcbgihnXBqN9wf/9Ix6ZNdxdasU89dsUV5itE4u+uaoqACIiACIiAMQFfC0DnLD69Zk3dlvv/+SdkEzk2L78gbySC+IGjZvEDmUuVYWNKp8/IyWlhCUDnLjLfUuwNtLZYDOtiGsg5L4/Cr8gajUWtzk0vroV4PGXVFVesNz+q9hQBERABERCB1BHICAHo4Hj/jTe+Y6in99ayuvr5fEjb8QOdN6fYMq0cg0hz1bA1ngFjiipZ8bYEoIvLiFiUXNXLYM7kZlq4spcjzj07t7f3Nzact/rqq+80rav9REAEREAERCAdBDJKADqAjr38ii8Eq6ouD1RVh+xpYRf+gSVVVXbYGKSkc5rL6q0EoNnlHYbgs8O6dHWZVcBetp8fRpjDbW2R1g3rf/bsNb+42LiydhQBERABERCBNBLISAFIXuesWFG+7cmnrg7W1J5RWFxSGIsMmftpIa0c89xyRLAAmUWyuUgA7v/qxpC5gyN+zJfsJv4kcyQjbdsIVvc+VDgSO/PRH/2odf9H0rsiIAIiIAIi4B8CGSsAHYRnr1kzd/v9D9xZNmv2/8uzRvPs2GyGaeVywT9QAtC5U165jcfPj64DjDnJ26tz84ubR0aipz7+ve89+8qW9S8REAEREAER8D+BjBeADuITrr32/daIdVOwdvrMGFLKufUPDM2anZVp5SQAnTvk5e1Y+rYG135+BUjh1tfU0NO9c/uFq6+66qaXW9RfIiACIiACIpBZBLJGABL7u5YtKyx8fs03ikpDlxSVh4K2f2AsZnRF8jC6U1JTY4eNQX5iozqZsJME4MtXKTo4YId1CXd0YBQPw3gGJR/uAgzrMtTVFe3etvXGkve/9/zlixaZB6U0OIZ2EQEREAEREIFUE8gqAejAO3ft2pot9y29PjRjxkfzCt2llaNjP0PGlNVlR1o5CUDLHg3u38P0bS3WiOGCoZfSt0WRvm3jxhWBytDpy7/+9d3OPaatCIiACIiACGQygawUgM4FOX3VqoObVqy8E2nl3sAA0va0sOHID9PKMX5gsHZaRscPzGUBSD+/wfY2O56fcfo2jAQzrEs+wrp0bH5xZ3Q4cvqq733vMeee0lYEREAEREAEsoFAVgtA5wKdcM2vPplXUPDLQFVVzchwFKNAw85bU26Ly8vtsDGBysxMK5erAtD282tqtCK95kk48uHjl19UaA22tvZ379j+7Sd/+n9XTnmDaAcREAEREAERyEACOSEAeV3O37QpsO7u+74bqK78cmFJsJgZHjhCZFLoH8iRQI4IFgaDJlV8s0+uCcDo4KA94seRP1M/P073ckX48EB/rPPFTbcf9v4TPn3zokVh31xEdUQEREAEREAEEkwgZwSgw23x88/P2P3Aw78rq69/L4Qd0spBCBpOCzMESOmMOtgMOwiw06aft7kiAOnbN9DSAttj2aGADC4KhT0XeOD6j3Zu3PjMaHHBJ1Z++9tbDKpqFxEQAREQARHIaAI5JwCdq3XKPfe8rXvH7ttKamsPpHhwEzamqLQUo4H1WDVcjdBw+U6TvtxmuwBkTuhwB9K3NTdhBG/A+BrYfn5Y8NPXsLsl0tdz7opLL73XuLJ2FAEREAEREIEMJ5CzAtC5bidce/0ShPq4oriisnJkOGK8SpT1AxWVVmjWLIt+gn4t2SwA6d/X19hoDfV0G+O307cVIX1bR3u4Z9fOy1dd/sPLjCtrRxEQAREQARHIEgI5LwB5HZesbizd/MgdPw1UV51bFCgpcuUfCP+x0mnTMSJYh7RyJb67LbJRAMaGwhjxQ1iXtlZzP07Hz29wYKRry9Z7qmYe+qn7v3Rmj+8umDokAiIgAiIgAikgIAE4AfKSdevqtyx98M+ldfXvQGJY92nlkFu4dPp0CyuOJ7Sa3j+zSQCOIqj3QGurnbuXIt2owM+PvpuI5WN1bdm8rqAw72PLL7lkg1Fd7SQCIiACIiACWUpAAnCSC3vyrX86brCz46bgtGlzuaDAlX9gWZkdNqakqgqiI/14s0IAYpFOuKsLWTwareH+/kmu2OQv0c+P4q+voaED2T++9NgPvnvr5HvqVREQAREQARHILQL+GaryEfeNf7lz6+K33fvzHfmP9iCA9DHFZWVcKmq0Wphicaiz0xpG2rFCTAkzvEg6C0fKBtvaJu0CV8GyTLYKmu9BAKP/gUnrpupFCr6enTusfog/01E/pm9jIO9IT0+ka/OmKxdFLz7hlu+9+4VU9VnHEQEREAEREAG/E0j/EJXPCS1ZvaVyyyP3XoPVwqdhNKnAjX8ghUiQ/oFIK1cQSI+QytQRwNjQEKZ690C8tmI23jCf87ifXzQSGe3esuWhiunzzrj/S+e0+vwWU/dEQAREQAREIOUEJAANkZ/z1AsH7Fr16F3IE/xGZBPJizGbiGn8QIwCMog0F4uk2j8w0wSg7ecH0dff3Gw84sep9gJm8SgssLp37tiWN5J3yrKLv/K04aXVbiIgAiIgAiKQcwQkAF1e8pN+e8uHI0Ph6+DjVxeLwD/QTVq5spCFANRWKv0DM0YAjvv59Tc1WZH+PuOrwvRtBcVFDALdgxRuX13xvUtvMK6sHUVABERABEQgRwn4O4qxDy/KPWcv/tsh82bPxyKRSyH+woXBUiwwNcNIYdO5ZbPVtXWLq6DFPsSQ0C4xgDOZkI2p+CNzskdImGjb+rXXHXbQwhkSfwm9LGpMBERABEQgiwloBNDDxT1706bpDUsfuqmkuuZELKTI52igaX5hBiRmyJgyhI7hatVkFT+PAHLBTP+eZju0C7OxmBQKP476Ydp3tGf7ticC9TNOfeCcc3aZ1NU+IiACIiACIiACYwQkABNwJ5z56BNvbHnhuduRGu4wt2nluFKY/oFccWs6kuimy34UgBTJXJlMP78ogjqblpfStzU2Nlgjo5/611cv/JdpXe0nAiIgAiIgAiLwMgEJwJdZeP7rA7++6cyR0ZFfIK1cNVcLm45q8cBMJxeCf2CgEvEDE1j8JgCHuhnPD35+SONmWjhaynA6SN820N/U/G1M9f7MtK72EwEREAEREAEReDUBCcBXM/H0ypLVq0t3PPHUdwtD5V+CaCliOBPTaWHG3iupqbFCM+utwtJST/1wKvtFAEbh59fX3AQR1zFp3EGnvxO3HBFl+BwwjPVs33r74R/8wJIbjjhiYOI++lsEREAEREAERMA9AQlA98yManzquedmN69cdUtJVfW74B+YZwcxNgwbwxGvshl1ViniB/JvLyXdApCjoAOI59ffssd8RJRhXTDiB0E82rNr5wtFleWnPHjeeZu8cFBdERABERABERCBlwlIAL7MIil/nXrfA+/o2bHt94GqmgMYO9BVWjmscrXDxmBU0Mna4baT6RKAzC7C0T6GdWFWFNNip2/DIo/+5qYWjPwtWfaNr/7dtK72EwEREAEREAERMCMgAWjGyeteee+78befQyM/Ki4LVYxEhoyzW/DA9AukfyD9BN2WdAhA+vfRz4/+fqaFWVPykXYu3N0VHtjT/OMV//vty1B31LS+9hMBERABERABETAnIAFozsrznues2FC++/nlPw1UVZ2dl5dfGIMQNPYPhD9cKVYKlyJsDPPcmpZUCsBoOIzpXoR1wQpfN+fFfMOjsehI17Zt98487G2fuuPU47tNz0/7iYAIiIAIiIAIuCcgAeiemeca57z44gEND/7rDyW1046KDUfy7NXChv6ByEds5xYuhY+gSVq5VAhAO30bfPyYuzeG2H5GBX5+9upeTPf27NqxIThr5qn3nXnmGqO62kkEREAEREAERMATAQlAT/i8Vf74HXe/v7+n8zfFobL62BDDxhiKJxy2CKuEQ/WzrJLqagZF3mdHhvv6rPYN6yddeev4FdJfb+/C92oOO9wqDoX2fuvlf9PPr7MT072NrjKb2OnbAsXWYGdnV7Sj+0v/uuQrt7zcqP4SAREQAREQARFINoF9K4dkH1nt2wTOWraspHVHw/9AcH2zIFAc5DSq6fQphR9WGVuhWbNsQTgZ0qGuLqtz86ZJBeBk+7/0GgXgQQdbmK5+6aWJfzB9W19joxXu6oSn3qsF5MR9nb/t9G2Yvh4eGBzGaOGvFh51xNdvXrTIPBK005C2IiACIiACIiACnghIAHrCl7jKTCvX+PC/rg5UVJ6CIb18ho0xFYKcSg3W1iKjSL0dPoW9Yl2Kvz4kzRgeHIyro0XBIMTlbFsEOllK2C+s0LUG29uNw7rY8fwQ1mUUSrFnx/ZltW9+05l/ed/7muLqlCqJgAiIgAiIgAh4JiAB6BlhYhs4+5lnXtOw6qlbg9Nq34hp4Tw3YWMYNLkMsQMLse1vacEq3MSspQhUViIu4QykbRsa8/PD1rTYYV2K6ee3a1tJZfnp93/mM6tM62o/ERABERABERCB5BCQAEwOV8+tnvzHP38k0tt3XXFl5YwY8uW6SStH/73J/Pq8dMptm/YCD+Q5Dre19mCa+Kv//ubFN3g5vuqKgAiIgAiIgAgkjoAEYOJYJrylU1auDA5u3PQdzOtemF9UGKAQNJ0WTnhnDBscS99WYmGqODrQ1PD7acce88U73v72+OagDY+p3URABERABERABNwRkAB0xyste5+1du3MxkdX/iZYUfG+kZHRfISOMV54kbIOY9SxoAjp2/KRvm33rifLF8w79Z5TT92ZsuPrQCIgAiIgAiIgAsYEJACNUaV/x9MfffSt7Rs23hqsrD6U/nhu/AOT2Xv6+dHvsHdPU0N+nvXfD37xiw8n83hqWwREQAREQAREwBsBCUBv/FJfe3Q076Q/3blkNBy+vCAYrIohbMxILJb6fuCITN9WwLAuvb0DA91dP1x+0Zd/iNA0ZjFh0tJjHVQEREAEREAERIAEJAAz9D44Y9Wqis71G3+EtHBL8kbzCqMu0sp5PWU7nh/Tt43GRnoaG/4y+53HnHvrUUf1eG1X9UVABERABERABFJDQAIwNZyTdpSznl13cPMTj/0uUF19FKaE8+xUbIaBmV13yvbzK7JTuPU17F5fVj/3k3ef/vEXXLejCiIgAiIgAiIgAmklIAGYVvyJO/ip997/3t6mhhuLK6vnxJLgH2jH84Of32DLno6RyPD5D110wW2J671aEgEREAEREAERSCUBCcBU0k7ysZasXl3U+J8NF46OjnynMFhaFg0Peg4bY0/3lgSt4b7eyEBb2y8OOW7RJTcccYR50uIkn7OaFwEREAEREAERcE9AAtA9M9/XOHft2prGx578ZXFF+SmjsVhBjP6BLqeFGfi5AH5+Vn7+aO+uXQ/P/H9vPu2Pixa1+f7k1UEREAEREAEREIEpCUgATokoc3dY/Pzzr2t54qlbSiqr30QRaBo2Zix9W8Dqa2rcWjyt+oz7zzxT6dsy9zZQz0VABERABETgVQQkAF+FJPte+Ohdfzt9qLf3F4XBYK3tHxiNTnqSY+nbAtZQT09ftK/3kocuvODqSXfUiyIgAiIgAiIgAhlNQAIwoy+feedPWbY2FN75zLes/KIv5xcWBKIT0srZfn7I24sVxNHBlqbf17z1fRfcsei1feata08REAEREAEREIFMIiABmElXKwF9XbJuXf3Oxx6/KVBeeQJEYD6bLAiUjPY17n6y9uADT73jpJOUvi0BnNWECIiACIiACPiZgASgn69OEvt2+qOPHzfQ3Hg3FokUxqKxT9x75ml/TeLh1LQIiIAIiIAIiICPCPx/9LZZ0UZyLiQAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-mid{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnhJREFUeNpsU01PE1EUPdOZKWUotKUKFLEWkQ1EASGGxGBi4sIVrt27IixN/Cn+CxfVnQsXJiz8IAoqRBGEaMUUWzofnXkz781436QDkjKTyXuZe96595x3rxJFEeTzaKW6dmdpfIoxjuRRFECGn7/4Utvarj/syWgflU5s891qvGoJePJasfBgeSpnW+yEIJVS4DEBx3FzGT2qfvh0tJxOE4mCU0yy8X3BLdODRQTJZ5oMzYaD0UuDePzkbnnx1mjV9/lMp+izBKEIwQMOzvnJGoYhhBDgFKtMjmBl9XZ54WapSjLnknMnEkQYgflCVhKXLt+/dRMy2d5OHdVnPoxeHUtLV8u2w5/S78UzBJwLMC8gAsosIqy9/ga37WNmvgKVKmEkb7JSwI3pIdRq1kBXBZJAUKkb6wd49fIzbJthdn6cIhE0XUWbyP4cmshmdZAE0eUBD6gCN0DtZwM7Xw+RUlVEJCui7CmyPaS94zC06ZMedREERNA6djBWHsS9+9fRS3p9AraOXbhELMlUQju2G2O7JAQENk0XhpHG3MIVlEZzaDbdOKO8jWy/TraGsMmL4L8KTgnIfcfy4JBWeQNp0j10MQtB4EJOg6qFMI/bEH3pGNtF4LOAjHMxO1dGvW4jXzDi7Iw60TB0jJRyONhv4MdunbDneMA6BMPDA6iMFzExcQH9AxkUiwby+QzevtnF2OU8lBT1i8fOa2UO1/FwdGTHE2STHM/14+vlPOz0RxibKPfn9AHXZHBzYx866ZdTKkuVndhHuqenS1h/v4ffvxqyvbUuAtPizZ0Dp7X1fTs+FA9cMnWd4ZG90NOjomVFzeTcPwEGACDGeYddZX86AAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-mp3{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnxJREFUeNp0U89PE0EU/ra7XWxpSsFYIbVQf9REFBHkYBRIPJh4wrN3DsZ4MPGP8b/wUCIHEw5EY0w04o9ILcREGmwVgaXbbXdnd2bXNxPahGyczebtzrz3ve99740WRRHkWn5cebu4cH6SMY7e0jRAHr9c3WxsVvcemmbys9yT6+uHJ8oaPefypdPDD5Ymh5w26wMkEho8JtDtuEOZFCrvN/4uJZNGH0T59D58X/C27aFNAL3Xthmsww5GCyN4+uzu+OLtQsUPxPQx6ZMAoQjBAw7O+bEVCMMQgqygs+LFs1h+dGd8bna0QmXO9OL6JYgwAvOFZKKoy3V44CgNfv7Yx8oLH+lUEgvzF8Ydhz+n41snAGRG5gUEwClzhHdvttFxfNyYK0EnJozKK5eGcf1qHo1GOxtjwI+pfvm4g/W1qtJgerYE2SXJSIL9+W0jk0mCShAxDXgQKgbNXxZq35vQKCiKQkSUXdc1+gcch1FHGPmKuIgBCdc66qJQHMG9+1NIpUylxxHtuW6gEiTIu+N4yjdWgty0yTmdNjFzcwKjY0MU7MLt+IjoSad16FoIx3b/A0DZ7FYXnsdpAjUMDOjI5zPgfoBsRodhhGhZHfBBU/nGAGRtxWIOg5lT2NtrI5dL0SB5KJzLodloqXaOEatPGztKq5gG3S5DNjuAK5NjKJfPYKI0okBkSdemCiSgS/rkQNLSePtxBj4LSCwfFtE0krqqX7ZVMnu9XlMXy2l7ME0dzA3iANQyY6vWxC61UY41zTyNcYh6/QCNXQvzi5dR39nHVq1BUyuMGAARsF6tbbe4iKD1r7Om5iFBdmW1SsDflLiuB6sX90+AAQDHAW7dW0YnzgAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-mp4{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnBJREFUeNpsk99r01AUx79psrTrujVtbceabnZs4DYRHSoMh6Dgq77rn+AfoA/+If4Bok+C0CfxVRDBh+I2NqZzrpS1DVvbtU3SJPcm8SSlsJlecsn9dT73nO85V/B9H0H78OLdt/LDlQ1uMYybIAgI9n99OWxoe83nkiz9hDDae330JvxL48O51Xxm/enNtKPbVwAh0Ec6kYpXat9Pnl2GBC02HrjM5Y7h4P8+7FtIFVJ49OrxUnl7ucIdfhv+BIDv+fBcj7p/tXMPrs2RXVTw4OX2UnFTrXCbbY7tpMsA13FDSDAOQ4gJEGUJLs0PPh9CkESsPrmxxEz2lra3rnpAt3G6adgdQhBpmeLkFodNmsjpOPoXBrQTDcmFFNS7i3MRDzzPCw/vva8ikU+COQxm14BBhvJcHLGpGPTOAJxxeLbrRgAkYujBdH4G5oWJWXUW19YL4XqunAMFhnq1BqWYgaY1MAHASQOiU96zKzkU76mwehaOvx6h9uMv7KFN3RopL4oTAI4HRh4wSl399xla+00YbR3yrIzM9SzSqgJJnoKcklGrH08CcJjnBtLLCsSEGGpSWJvHtDKNoFippsJ0ulIsDDUCCATMlBQkNuahEyiZTcLsmFBKaQxaOk53TlHeKkM70AjAooCghBOk9sKtIvqtPqS4FBaRnJSRX8tj2DOh3lFB5Qw2ZNFK5LRo6w4sKt2ggAzywidAMN/9uIPSZglBLDO5FF3mRD3wHE9qVRvoHrUpfn+UEQK0/7ShtwboHJ6jdH8RZxSC57hSVETb7e5/2u0FxqPHJow+8iZ4lYY2QGu3idhIxO7Y7p8AAwALCGZKEPBGCgAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-mpg{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnxJREFUeNpsU0tPE1EU/ubRdlqmnUBboa0UeUQDiUGCC1+JmrhxoXt/gBvXJi74If4AV0Y3sNKF0YUaICqoIfjgVShEiGF4tDOdO/fOeOaSKtie5GZu7pzz3e/c7ztKGIaI4vn9p+/P3h4e4a6Pv6EoQBDiy7P5rc1P1Xt6XP8M5ejXo6UJ+dWbuemeTGdpvNdiNe9YvQLe4Bi4PmTpRmyq8m71rp74BxKF2twIHvAo+f/l1T2Yp0zceHizfOZa/xRnfBRhG4CQqAYioBWeXDyA8Di6ei1ceXC1XBwrTXHPH2vW6ccBBBMI6BsSUEQzakGL6xB0tvjyBxRNxdCtc2Xf8R9TyaWTDOg2TjfVdw6hqIoE9B2GxkEDWlLH7s4ette2kSp0oDRezrQwCIIA3oGHr0/mKMmE53qo23W4+w5S+Q5ohob9X3tgHgO8ULQACC7gMx9mKQP30EW6mEHpYi8xcJEdzMucjfkKcrTfmqmiFYBxCF/Id+gayKJwoQjHdrA5v4HK7Cq44KjZNWpagaqp7QACks0H9znW365ia24DzoEDozOJbH8eVtGShXHTwNracnsG7q6LzsEuaAlNPm9h7DSSVjLyCMkppDI+GS2StQWA1RlKo0X56n2X+6QHkmkDakxF9WMVqWyK+s/BrthYfvWz1Ug+zUDcjMPMm0h3pxEjFma3CbIuCud7oMc0LL1ZgmElpGJtW3B+15HIGNITrMYIlOH7i0U41NrInREylYbu4R5qQbQBaAh95fVKZCnpQCnb9DrWZyrRERS6NDeUw+yHaXh7rt4C4B8y+9vkwn7kwKNRpDoa9aiFKBYnF+RcREqQ2e1m3R8BBgAy9kz9ysCE6QAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-odf{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAi5JREFUeNp0UktrU0EU/mbu3FfE1KRRUpWYheALNBURUVy7cy9UkO6KW/+Lbt0IPsFui4gLBbUqFaUuXETUKCYa0jS5yZ2ZO557b5MmTXpgmDPnfOc7jznMGINYPi0de5UvmpORxpjE/kbNqW005DVu8TWw1H758ZfkFgNgJmtyxSPRjJIj0QTW/RDiYGXGb7Dl32/eXrVsd0gSCx9miqC0ooCdp69g5Q/h6OLN0ty5ynIkwzMwUwh2FwMdcbDiCZQXlkqFCpEoPT/wih1YjLInANcD+/Ua9bu3wJlGvrBZCmet2+S6ME5g4oGlZ9A/I70XCDhhDexPNTFmswJBwcnuXkF86VSNZxVu0ukLSGnBcqlnN4HoCQIaIuIv7LUooMOgQ7q75LAAb59B9gCBHSKgqemRr94mMKmD24CfM8nb7THYGQNLpAkUkcb66JyGBFFEWRVL57gFEH5qj8Lxwca2qS3EZaugmzAw24dR/XQgwtsCSBjPIdWbUoE2UJLBnV8Ac/ciWHsK9/glWLnD6K2vgPszsOdOQdfeQ1c/ThKoTgDn9A3KUED/52d45xchZsvorD6Bf/Z60riV3Q9Z/0bbGU1uopYGkfERSQ3VbsMwl0qlqoIARmSoPYXWy0dor79LfBMEEd8jGs/uQ3Yl7PJFNFbuEXiV2riCf88fovXhBbo/vqP3t02/ZYmJFqTkzY160Go9uEMbFK8hR/NrdXtFuUVmnmySVGgO4v4LMAAjRgmO+SJJiQAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-ods{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAetJREFUeNqMUj1IHEEU/i7u7Z23e8tGgneGQPw3hZDkkhQiSuwMQREba4uUgpVlCrvEQhurkCoWqcQQ0oTAaYKNqJygGEwgHCSB6Knn7eXcdX/GmdHVPWYFP3gw78173/vmvYkQQsAwNvckq96UnyIEh7/d4t7uUd/8y+85P+bXSX4grkhI6nJYPW7LrXpBK2YxiSoShhu4Buq1NPofDeqdrZ3Z4cl7D4J3UtA5VyVAlmJoru9Af2ZAp1lcCQ3nqgiuKmbY3l/BH+MnHM9GVLP0Ww3KNA33CQoQQnL834Fj74PUGkANEIkCSSsa8gQqgYTIcB0PVsXB318GInRiCVWCkpRFAs+j5gKlA4t29Ggh4d0t04FKt9PQqF4UFgumSEA8ApeaElilWbYRVy/lsns/N1QBkxtENF4jxPxcgcB1CZVOrvMteK5IQDtJJIGh++PcX9iYwWjXK37+vP0WdYk0Ht99jtX8JywWFkQChw4tc+cZcvlF7rMze+ubbxN40fMalRMDP/6twaiUeK7wlZ0TD0a5hLTWxo2d45KKprqHKJslTsy209s2wnMFBTYNZjc/oLt9gPvLOx+hxVJIKS2YW5pCbSyJTGMK775O8VyBwDJd2LTDl/X5i8v3S7NVw9vJb51tITDEUwEGANCx2/rXEEFFAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-odt{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAepJREFUeNqMkz1II1EQx/+7Ca6JkqyYiJ8cKEpAQbBQFDm0sVOsFBS9wt5KOTgEG5twxVlZ+XEnKNiIghYKxx5nwEpIIXaiSAgKGmMi0d23u8+3T7OaZJEMLG9mmPnN/w1vBUopLPNNhRWXHOyDg0nx82TiJtZPlPVoNpftc2cTotcHtxx06kdXpSQ/BvzKESZzIDmAz6y+NojOjpDMZiqRPIgNoFyWM8DrKUV7axO+gcp4g7AzmquAdVNqOgL2z2I4id1B0wgeygOyt/rLL5buLwAIDgA9dY+L+DkuDQOCrkMgBsRglcMOqAGwIstMg8AkGsuZMNUMRMkLqE+QGloglvlA7uIOAKvZajR0qJkUj/XHe0BTIclVKKlrfKsj9qA8gA6wqSJzPaXlr7ky//tdLEUfawsBjExUFGVWbT7AxSa42H2LMfODmvd3wKb7RAMLYwM8nts8xJ/pEe7/3PmP2eGv3D+9usb35W0bINoA7RmjXSHsH0f5Z/mUSZ0Ir2JmsBtD80s8/rGyzWsLFTD5yUQCbfUBHl9d38LvkdDTXIuHVBo0k+bbt06qO+yAPGXwe/cA4wO9PN44jKDG70GougIzi2tQ00ms7/3lpwnBBgjZ37Kkd1Shht5XzBIFl/ufFtniT/lFgAEAU//g6kvdGBMAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-otp{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAcJJREFUeNqMkssvA1EUxr+ZjkdbrfFKVD12ErYSRELY2fkH+BMsLcQaSwsrSzZi47EjJEQkEhYkFlhYSVtFpdqOqpk717l3jKZmiC+5mZlzv/s795wzCuccQncz3YeRBj4KHz0/RrOZe2NsZPP20o255zQ3EAxzEAC+6uzTw13G4TFQAakA/CWtIYbY0KBOrx7IvwDQqlHV1o3YxKTOvyAUvfQCfqmA3e4ikyS/zRAKvOot7eoSHEgZIHrCfQAfBqBaKQQDKScQAExd8emBANg+2U2CvNMkkgSqBmrCxFB8mujeoJBWwEqARcssKTAJEGrmaGrjqK1zvNknH4BtyxKl2VUpRxmj5W+x73q9AEaZrR/ND1EJluIpS3i9JQiA+a+hSq8HwJjTsLrRaWitPTCOlhEZn5N75sM1qigmlN+dB3u++Qao5W4TtbEXXIsiszGL4PA00itTsu6XnQWo0TjMTAJqfMDx/ryBJcaVzSNSH4fW0Q+rkIf5rsjRiid7yyN7uoXS3Zn0egE0NiORAN9bQ017D1Lri7CLlP2EDr3Rf7C/itzV2bfXA/igLDaRixfngFhSCooH2xVPCWBlwKcAAwBX1suA6te+hAAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-ots{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAfZJREFUeNqMUk1rE1EUPS8zmabJdDKB2glEwY9ExJYiBUEQpV25qgtBXfgbpEtXuujKf+AfEKRddOdOGHClbYVCvyKWaijT2mhjphk7Sd7Me76ZONp0EsiBYWbOvfe88+69hHOOAE9f3zTVnDKNHvhlsfqPw/rM0ovyWsRFdXJEpDIyRnSlVz0KSkmvabaJeXSJBEhgAJzTDNybmtUnS5Pmg/lrN07H5NM/f13FoMgpXDSuhiIiK3Qi6LUugX7FAbaPPsJqfIHHKCStqRsXVFPQuZgD9BBxjikSiRq41AAkgCQBzVf0+BWEBX7GBm0xgHHUqk1UbBuEcIydzyCZlOI9YEGuDxwduCCitS3Xh3viCZ4jrcq4PJ6DLHd67tjtuAAXib54dCPVEfQ5XIcik/0/2iDeOYz3ceCxrisMi904y0XiMQFfkB7lg6xFHwFxEqUMV0anUNBLWKm8xd3i4zBWOzmASx0UsiW831mA59Xjm+h7HCOygduXHqJatzA7Poey9QnXjTuoVD/j/sRcmDOWLgqnLC5A2wwST+Pn8T629lahSCo291bwu9XA7vcy3m2+gTaUR14thrk9BXasbdiOjSe3nmPpwys0xSi/HpbDd3bIQC6dx/q3ZbRb/j8BEi3Po5cTJpHI9CBNDEa++GyDBN9/BBgAwfDlCVUQaNAAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-ott{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAdFJREFUeNqMU89r02AYfpJ0iVm7EqhVOxw7dDBEdpiCE1RoEZRddvUgbIex/Rs7eehppyF4LOzQu4MxwYp0HgShIuwwUVSCVtl0s13afl+SzzcpyZYmyF74eN583/s+PO+PSEIIeJZdrtQVI19Cgmk/Ph39bpllXq82g7sgLxVcyKNZpIx8Uj5u5zSjc9Gov8ZihCRC8D+7On4JczevGeTGSEIC4ctKJtB1DTPXi1iCCEkIm1EFlC2Em0iwtWfinXkIzjiO0jljtDC5TtflGIGUQMB+mfja/oPv2Rx9MMjpMdJxOXyXTwkcwIkewfqQ1QtQNB385zcI14FrtQexsSb6SRysZ4Fbf+F6eHwATc9gJGNAm5iCTL5n/LCVRGADNoeaGoHqyaXj5gqQlTODovcwNk5Aj6wXqV8eCo7EDhMonEHpW+dZC7gUG98D3geo7vkb01h9cAvPdt76OGy1xntUd3bjUxAk3+l2sHJ/FgtrT0MUJNfDSm0bjQ/72Hzxxo+NK+h3B7XRNO4UrwymQtMIkdTBU0m+sBOayLsn8Ka78mQDjx/e87HXPkb1+UsfP37+AmZ1fP/suknBb6nefVQXjl06TxMlJfWKNWr+Kv8TYAAkUueexJF47QAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-pdf{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmhJREFUeNp0U0trU0EYPTP35qYxaW6TlDapNKWGbgo2FkF8rARB6rboXusf0F/hyq2U4krFqugqSBeuAyL4SERBstHa0iR9JKZJ7mvu+M0tqZGkH3x8987jzDnnm2FSSqh4ns0VU1ybFzj674Wa3uWiWbfsFQb+jrGj8Xvbm0HlvYVRxhJprpmTlGmum+OMm5uNPZNbtjk3l82ey8++8oW4Jv/H/wdA456g2kvH99FyHNiuAz2dwflbN8YW8zMK5Go/CMfQkAhpGsyQgRCtlpE4jIULyC9fHzu7MPPEl/5ib6WOE0JJNRiHHg6j86mMjw/2gG4bkbY4PW4Yj2j64skA5FTHdaEMPiAJszt1sK0d4suJmY4k0+IDDGRfqmh0u5gejQc+fG8eYCIahRQCEfgQnIuhEkgtONE+dGxYxEDj1DhiEycZ+1YXdUpHCqTMJIYyEES5aXXQsi2kYlGEia5GtHVKn+amPBeCutPgfLALPuVu+xDVPw2EQyFEjHDghbpYNm1yKVVnYjTOerepn4E6XQmLGSPkPkOXWATMSDcjQEkAaqOu6+i/rccALtFL53LI3r0Nq1ZD4/MXZJaWYFer+PXiJc6s3IEgY3+uPYZHTAcAHM+DTE8gnM1CSyaCulv+GrRy8uYyElcu4XfhLVpkpNtn/DGA5Uu0abFH36WnzzCayWAkmYJvWeCkfb9SwY+NDbSoOx4bYqJF8rZqVRRXV/HhzWtUSmWwmWl0RmN4v76OUqGASrmMOkntSHF8MOs954dT08W248wzYsJDOujRBAaqqikTpRo/qqd0/dv97c3Lat9fAQYA4z8bX9nTsb8AAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-php{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAhNJREFUeNqMkltrE0EUx//ZbDaXNrvZzdIkbYOXGgxYQlCK2IIY6EufxGdB8Av44AdR8AP44JOPBR+Ego0PClUKTTXQSmkTYtOkmubSJrQ1e3H2yJSEJNIDs3PmP+f89pyZcdm2DcdWvn7LzkxFHmCIra7nm9ulg8yLZ09yXON55Dgjt1PM2iPs0+aW/frdh8bzV2/SvQBnCLiEqcFxLKSSodlrU9leiGPihWePBkgeEZO6ShC2dCAZNuf6ADb+ldQ5PUPx4BCFcgXfdwq4Ph1Dtd5CZi4Nw7SQiMdCXkl6yVIy/QBWgcU+yx/XsLK2cdHndqlK/lZxH/OpJO7fnsWY3z/YAq+g0TmHpoUH2vB5PXi8RD9Fo10aAmDJTgWyIuOupmK38rsPcOvqJO33XWEvwLJsmKxHRVEwf/MKWl/yUMf8mIloWN8rw+sP0D6PHQmYuzGNgCRiMZVA17IQV4OIaTI8buH/AJMFd02Tkp05PO4jnWvc57EDAINt7u1X8Pb9KgI+Lxbv3cFR8xjx6AQ+b+Txs/qL9KePlih2CMBCq92hg2qzt1AoV7H5YxdhdqhHzRbgcpFeqdUplpvQW4FhmAixZ/sws4BoWCM/qmsE5XqE3dDQCrqGAYWdejqZgK6GUD8+IV9VghBFN1RZJv3sT5diBwC15gncggCPJKF0WCPN8dun55jQdVpz3Ynl9leAAQAJhiGatD9AOgAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-png{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmtJREFUeNpsU9tOE1EUXXPp0CAUWmJbC04xBANNTF+kKhG8fID6aqL/gPEj9E0lIf6Dj30HL03wxQtVIC0QKrWxNG1Dk9Z2Oj1zxn1m0oIZTnIyZ8/ee+211z5Hsm0bYg29fLGpxWIJWBYGS5IA8ncKhT9Wvf4Yqprtu+w3q85X7f9QxseD/pmZMZsxN9fnc5JNw0ACGGv6tPSvyvEDKEoWZ5Y8OHHObKpucw4B0t3agnl4CJPs2YkQVu4s61ORaBqMJc8CDBiIRhhVM9bXYdVqYAcH8M3NgS0tQQsFcfdKHEbvlr6WyaR/V6uPKPy7B4DT7lUq4MUipMlJ2MPDUKtVfKZ2nn/5BoNbkONxXeb8LYXe/A9AJLNWCxgdhZJagDI9DZg9qIkEytRSkdqTSFQtGILSbgc8LViM+tc0yPfukzIyOJ359k9YR0eQdB2KmBbpwXoM3Dod1SkD+scpEapCI5DdpsJhIJcjajQZagcjI+5oLe4VkeQnyiZgdIH2X6BJ7dSqQLfrggjw0AQwP+/GegCIHppNoFAgEMO1RZKo7BQgRi3yN05cnwdA0BQMAgF3C6pnbuNg92M9AFT1diSCh6kb+FGvo2MxnBB9ocZxp4Mns1cde213B81e7xwAcl4jkaa0IUSjUdLJwkL0Ej6VSvArCt7l81iku6GrKnYEU89VJlSJRmR0Dax+fI9suYxSo4HlWIw6M3FBlnD9YhiXabyOsOeIqG7TzDeIYo6EDGp+ZPb2kKKqH8h+mkxiI5/D1/19J3bwYPvPWXq2skkiJVxesqt0XzghpKM8nRVV2Lv2q9eLIvSfAAMAaacnllcFBmYAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-ppt{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAkhJREFUeNpsU11rE0EUPTM7ySZpmzT9DNamWAtFfSiCigr+AxF9zKtv/hvf/Aki+FEi6ov4ItWHPGiwiBUKoUqqTUJImmR3M7Mz3t0kNe1m4LIwc+65595zlxljEJzdR5uf5nLmsvZx6gSvtd9W9bjhF7jg5dH9nRc/wq8YXaTSJptb0xklx7IZoKUEz1zJ2DUU69/37vFYrDxegJ9U0lC+AoIIVGg9CL+vIObP48KDQn7x0sWiVnJrnEDg7KGk+i/Ac4iUM/R7BsmrSSxtXMfa3X7el8+Kjf3KfUJ+iRJQw4w0Tc8BRyWGRAZY3rBR/VlC+XED2ayDhZyXl03+hNA3TxNQshlGLAnE44zCIL1goXZwiMNvB1i6zbC0KuAsxNITWwgNMYPeLVJiFEO9ArjHAivrAjNzBr4f4vwIgdGD4YUACsZCE8AtYGWT5jCsGQw5wEYJzP/pj5RwYTA1b07eQmfZ8P0sgdaM2FlYwWkMgMpl6NQAO33GKM0wsQWflkh1uqGVmVWblsiDkQyqxwfag35SqcktaEWTUTHYNx4iGU/C29+BvX4Lpu/C7zYgFjegSY63WySsHyXwpYHU00ieu0bAOuJbBTArBkiXKiaAmTzcvRJUV9E8rOgqBwqlY8ASs/AadbRLb8CzeTjVClqft6FdB17tL7yeCbFRBYoLr6vR/PiSEl5BZJaBD0/R2nkOZqfQ2fsKt+0SEQ+GLSIEUvJm+6jbah2+pS2aon+4g/afd4SYJVuA7vvXdC/IHQtSoTnK+yfAAIEaId1m+vudAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-psd{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAqxJREFUeNpsU01ME0EYfbtdKKWGtoItRWgJHApCBE2I0YuoiSaaeDJeOJh41YN3TfTixcRwMfEk8eDJGA+Eg0YTTRRMg02KKFooCBbTlkJLS7f7P+u3K9Xo8iWT3Zn55s173/uGM00TVlwZfzJztD92iKO5ouvQGQPHcQDN380vlDPr65fdLj4Oa41i9sFt+ytgN7o7woGOrqgvvpLBaF8vWj1NUAwGTVNRM3mf5vU/zaU+XySQuTqIFXz9hxmGLkoS7r+YxvVnrzGzlgXPDOzUZPT4m3Dt/KlIuH9oUjXYEHZZ/wOgGQZi4TZcGI5hLb+FO++TSOSKcLtcMA0dI0EPrp4+HtnfG5skiUecDGwQE2MjAwiGWlFVNDz+tIyCokJhPKYSX7Gdz2I01hOJdnY9rJ/7UwPGTEiqjtbmJtw4MYx78S/4Wa3h5UoOYwPdIOp2Xi/t18rlFgcDw6o+ydiWVRwOBnCpL0oOAMmNEhLZIgSeoxwGSWcERon/M9DoBknTIdNQNAMnO4PIVGpIFXcwndlA2OtGc4MAxml27p4AIulWSIa9QVadiYSoJxhqBJivKgh5ad3k9gaw6JdlDaqq7q5wINY4F22HaLHSDZQkBW72O9cBYFEviBIURQH7a7MN0uDisUW12ZZcaGlmdq4DwCqeTo1zNtZuW7hUqGIw7MNqSUS2ImNsKEpSdEwt5lGhfQdAkQBEoub3NNrDJfAIeBuRrcrY5xGQ2RFJAjl00I8PCckJUCB9q1URBnk38XEJEuk41tmGwZAf66s1VOh2keqwoUnYpFxHH4iKIixkN3HzVQKP3iQR/5GDKMuYmE3h+fx3MHqh1sMafztHLuiCg0FAk0uFdLqcpGY5QEXbTC/j7mIaVjc18DxufUtBJ/vcggs+3ijVz/0SYABsJHPUtu/OYwAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-py{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAlVJREFUeNpsUktvEmEUPTPzTUFmgJK2UqXQFG3pA6OBLrQxamJcaYwuu3Dp0l9iXLvVtRuDpgt3JIYaTVSaxtRHsJq2xEJBHgXmifebMhECXzKZme+ee+65516h2+2Cn2cb2VwyHl12//vP2/zOQaF4uD7GWN69e/LogfNm7kUsPBFaXYwHMeK0OlpQEJApHJTuykzK98dE98O0bLM/UNgr4v32Dj1fwSQRt9dSsfmZcMa0rIv9ODaqYrPVxuPnL1Cu1aEbJu7fvIZUIo4bqeVYRzcyv/8c3SPYpwECt/dmu4ON3Ed4TymI+hQc1ZqoE+F+uQLDsnHlwkKMscJTgl4eJOi9fxZLePNhGx6ZQRRFqH4VjZaGSv0Y6cQcJLpra0ZguIWegqDiw7lYBBZV6xiGk9DQDLzK5bEyF4Hi9VLMsoYI7J6Es5PjeHjnOl5ubqHaaJGBEkzbxplQAKIgDmBHekDTgI+qKKqKLvNApgmEgyquLs1CoFn2Y4cIeLJpkjoCLkWnUSIF3JxISIUsCjAoxhWNJLBIJs3YeXj/08oYZkOKY65HllE/bkMmY504YUd40HUq2JSSyW6iVPmLiXE/ZMYQCU+hXK3h1toqdNN0sEObyKtqtDQ6kXDwcadDS2TBryp4nX2HxXjsJK6bDnZIAZem6Tp5YMMmicn5OC4lztNWtvB9cg+hQABtWjKL2jH/T3GgBcYDXEE6mcDM6SlaJAGMWkivLBC54ZgniZaDHSI4rNSqn7/t1vgkGJPwZXffSeCjk2iUWz9+nSTQN8e6ef8EGAClUi/qoiOc3wAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-qt{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnVJREFUeNpsU8tu00AUPU5sp41NkzRxpfSZqi0VIIQqEEJUZYXECvbwCWxYsuBD+ABUFrDrCnWBQEJdIWigBSr6pqRJ1ebhxrE9M7aZmSrQ4o505fHMnXPPPWdGiaIIYrx89GKpNDdxmXkU3aEoCsT+z8W1Sm21+jCpJctQTvaerj+TX7WbnJ+0cpfuX8mQtn8GgJ4AZtIFY2Hz3foDVRcgyt+cRHcS0IARh+D/8G0PpmVi7smd0dLs+AIjwTVEiANEYYQwCHlEZyJgIQKfoX84g9uPZ0cHZ4YWmE9nuufU0wABCSSImMsWEgqSuoqA/39/swZFTWLy7vQo7dDnfPvWWQa8GuOV3IYLJXmyzDzG2/ChZ3pwbHdQ267BKJoYuj7SF2MQhiF8LuDK/Gf0DKTBKINz1IbTbEMzU1ANDW7LAfEIQKIgBsBFlAx6LYOz6MAcvoDCtAVGGPKlAiIu/F55F33FDA6W93EOAOMaMOl7biKPwRtD8Foetj5sYPfTDtxjl1f3Ubo5jkQieQ4ACSUD2iE4XDpAdbUiW9D7UsiN9WNkZgxajwbd0LGzt3keAJPUc1N5SVeENT0Ao2BKV6QzwlZeRBSKAYhe3aYHcZWn7l1EfjyPypcK9LQGa8qCvW9j9+MvaasQOHaRhGWdhsNLR8hwodYWf6B4tYjDjSOovRqq32rSYq/lytw4A77o1V2ERiAtzY5kkUrrsH+3QF2KY87ArTtQuQ6nAf4x6FCV1D001+vYersBM2vA4y1Rm2D7/Rac/TZIw4d/6MrcGAPf9htN0miJh7Lyuoyvr8rQeP9iVJcrSKgJ+TrFcyYebXTP/RFgAFQobmIOBxbsAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-rar{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnpJREFUeNpsUktPE1EU/u68OgylZXi0hZACQU1LEKKCMcat7jTRnQsXxsQtv4E/4M74P1iriUaNCw1FgxpjCJQKKAU60+m8mJnrmSll4XCTc8+959zz3e88GOcc8aq9evChOHl/lvMoubvWX/z4+BwTlbvw7bXdg8b7h6LE1gGW+O88CRMt4XTlR6/rYxce5Xv3jlHH19fPkBu+gWy5mlcFb3Wn/umeKOEMJF5C7xCFbtA9dRXjFoYKGiTRAlPGUV1aKU9O3VwNQ74A8DQAIZxqAuAhBPIMFYpQVAVB4CPSZjEzv1weH5tbDQN+JQ2Abu488mnzIbAAA3o/VK2PwDJo7r5Fy7ZRuvi4PFS6+qIXdVYD8Jg6BUcuOD8BozSLlRWyicgVKkTMQWwUlFF0Ooe5FIPk57BD7G0SiywyjD8bCDyHsOkeeeR3SUxEkROmU6BfQYFJMHfhWXV8efkUrb13VPMTsrcTQSzxZ/+n0GVA6EGbSGdgG9vo15fg2nFgbO8k70SRdd+mahDT81vUxTZRlJBRMsjq89C0EXCvSf7TIBZ136YZUJEiE7LgJ2dN01BZuE0dkIhxE7KcQTK1QUj+cwAEyrPZ+IydzRoyah+mLy2isbWBweESJEnB9q+1RM9Ub9GQOWkABg8HjRr2d9Yh0hTlBlRsfn+D4vg0BvUC9rZqECUJuk7Tzr1zahCYlB6HJAREPwfbbMBzLBzsbUKVI0qBgQkc+SxgWUYaIAqOpKwKXJ6bgGlaaDV/YvHaFNrtDsKTfVSrJeqIg/bRNwjclFIALeP3saybhu8SC4VBHwnhBXXIKocYRXD9QzBi4Xgchmkd9+L+CTAAMqwy+ZzluBgAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-rb{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAixJREFUeNqEUktvElEU/mag5f2yJhXLwxIt0kiqsVEXujP+A925cu1Pce3WtXVtYuJCF7KtTY0NrVQIpRVKeXTkMcO9F8+9ZVooJJ5kcmbmfOe733fO1YbDIWS8+/g1dycVX7W/xyO3vdsuVKqvnE7HZ230783rlyo7bVBicSGyfjsVwozomVbIPe/c+FmsPHfoRKJd1HT7hXHBZjVbA4aA14NnD9bC2VR8gwuxPi5Sx39Cp+M0XUP0ahhP1jLhW7HFD4zze3b93ILtXYyyVKlR8/5hFbnvO9gtlrGSjOF+OpXkYviWyo8mCS4R6bqO4p86vm3v4fC4DrPfw4unj1XN6JvBaQtjChzUXK43sVU4wNFJA43Tv/B73edQwTmfIhAjCVL6UdPAj1IVFSKhCdAcAI9rnjBiAjtBYEu3GEeh1sKJ0YXR68sVIujzIhzwY8DEBHZqiLRKkicQDfvABxaiQTc4Y/C65pCOXwcjcmlvJgHtlwi4epYifiQWgmoLZwPW6HQG07LgcOgKO0UglAKOTt/E+09fwAiUWU7QAE9xUK3jbvomsispZVHMVEDSZdHo9rCZ/4VIMKAu0XGjpU7d2S8hk0pCELHEzrjKnCQOYJoD+Dxu1RyiwUm5LaMDo9NFt2cqDLvY4oQFp/QpfT/MrmI5FkWebt+NpWto0j2QmQkOjZ9hpwhqjXZzM/+7LU+cc7lRrjXh8/lVLRK5ovLWXglOsiOxdt8/AQYAzv8qbmu6vgEAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-rtf{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAe5JREFUeNqEU01PE0EYfnZmd5FSvgLYFuwWt9EgHyEaox68eDJevHvwJ/hTPHv1N/QgZ2NC4g3kUAQKFKGhjVKqRrvbnRlnht262FHfy+y8877PPM8z71pCCKh4/ebt+rJfXEz26Vjf2mnsN5rPKKWbVpx7+eK5Xu2kyMtNTd5d8MdhiJ9BOO7atFI9ajy1UyAqSPIRMR6ZmoNehNHMMB7fX/UWvEKFMbYKE8DfQnAhwRmmJkbx6M6S5+WmK2Evup2c9yUk2nnKA0XVcSiGXAe1k5beP1i+4RFCXqnPywB/AKVzK34RjHNYlgVKCH50w7EBBogbTa/AVM5SgBdn0gc2AMDjPsbFPz2xye9asweS6n+NTbG8BCCfUtLjff2WoVnVpAH6z6hMUtJE3EykYfpF4vUiL3QNS7FMeSAQRBHW3r1Hq91B+VoBQRji4+ExFsvz6Hz7jm7Yw5OH92AcJKW9G4SoHhzhy/lXbB98Qmm2oCXN5WawsV2TACEoJXqwTKOsb3BtR2ucmZxANpPB8JUhyPnHWDaDpfJ1eZFALzJJ4MKO5MEtv4TSXB7V/br8iQLMz+almRZWbvoo5q9qRlxwewCgeXbe3qrVO5ZkUD/9jJGRLPaOm6COi92TU1DbxYe9umRD0DrrtJO+XwIMABWp9nS+FgaoAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-sass{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MDNDMTBBM0JGMTE5MTFFMTg3N0NFOTIyMTQ2QzhBNkQiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MDNDMTBBM0NGMTE5MTFFMTg3N0NFOTIyMTQ2QzhBNkQiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDowM0MxMEEzOUYxMTkxMUUxODc3Q0U5MjIxNDZDOEE2RCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDowM0MxMEEzQUYxMTkxMUUxODc3Q0U5MjIxNDZDOEE2RCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Po72XUcAAAJcSURBVHjahFJdTxNBFD1bykc/ttvdtttWGgI0bYrUgDZoNYqRJ014kMRXHvwB/hQTH/wFhMREJfFBQxBjhMRIFEQSCAlQxKYGggiU3e3HbnfX2bFt1EU9k9m9mblz5p4zlzFNExYmpue/jmTSZw5PZAl1MAwDT0c7O72wvPdudeNakPNtOZ0tsM7cvzdOc5yN5LDAsTFRAJks/kC2PxFRVe39Si6f4byez62EpAEH/gNN18F53Ri/Ocxf7OtdLMpKT42s/ZPg1cISJp/P0tg0TBzLCoK8D7eHh4RkLLJ4cCz12AjMXwgez8yhqtVo3NbqRKlcxcSL16gZwJ2Ry8KVc8kZO0HdTKlURn+8G6PD2SZhLMQj96WAiMAh2RXFYKI78lcJcx9WYBCycICnpNbojUWpD5Y0C4Zh2D0w6hWc70uQZC+IWfQZrXF0IsHvY+meBd08haAhoVMMQFJKWF7PNZM+klhRyogGhbqxOIXAMOtEwGAqDqVcgbVkkE+5UsEAWavf0az2t0ZqvK2qabh6IU3joizDwTgwej1LdVfJXkdbK8mt2QkayO99A0/0trQ46I1lVcX+UREhnsP34yLp1AD1xibBMuntpzU8mJyi3Tc1O4+l9U06n7x8Q/8PHz1DrrALt8tlr0CrkbJMHTop9Sk5sLa1g8L+ARJdnShKClY3tunN69t5iGLYTlCtakjFY7gxNABdN3B37BaqqoYT8pyX0in4ORbRkIA46YlDRbUTbBZ2Jb/Pw4qiKFnapcpPo9pdbrg8DjAOBsFgELJmsGs7eWkkc5bu/xBgAHkWC6UPADTOAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-scss{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RkM4QjYyNDVGMTE4MTFFMTlBREZCNDNEM0ExMTk0MUIiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RkM4QjYyNDZGMTE4MTFFMTlBREZCNDNEM0ExMTk0MUIiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpGQzhCNjI0M0YxMTgxMUUxOUFERkI0M0QzQTExOTQxQiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpGQzhCNjI0NEYxMTgxMUUxOUFERkI0M0QzQTExOTQxQiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pkf1yeMAAAJbSURBVHjahFNdTxNBFD0tLULpB91uodVWPmorUIxo0VSiNSExMYYHE33l0Ud/in+C+OSjYgjRGDBRCKJIUkIEWi0WKlja0ul22+5219lJ26gLeiezuXvn7rnnnrlrUFUVms3Mvd2bjIyezRVLBA0zGAzo6jhjm1te+7EU37rFO+w7JlMbtG+ePJ5mOaZmci/nsPl6ONBtw18WDQc9tZq0sp7YjTisXV/NFKRpRvzHpHodDqsF03djzuvDg6vHJWFAprF/Arxe/oins6+YryoqCiUBvNOO+7FrXMjnWc0WyIAOQP0N4Nn8IqqSzPx2swllsYqZl28gK8DDyRvcxKXQvB6gISYpiwgH+jEVi7YAfW4nEqk0PJwDofNejAX7Pae2sPhhHQoF63U5Gai2Bn1epoPWmmaKoug1UBoMrgwHabIVVCx2jdrKFwm67TZ2plldPQGg2cK5HheIUMbaZqKV9In6giDCy3MNYXECgKI2gICxoQAEsQItpNCHWKngMo01arTY/jFIzbutShJuXh1Fm9FImYiM7tTtKOtbO+toN9Nc+fQ5SGUOIVYl7HzPIH2YRZ0y2KZ+sVzBHn2v1mpMGx0DTaR3nzfwfGEJdybGkdo/wEigDyvxLzg4yiESvojZhfd49OAeLJ2degaSLIPOO6vwgiYaaRErTRREEdn8MeJbSVZ5M7nLdNExqFLaQwEfFfACQn1+HBWKSKb3MT4Sgstuh9vVDa+bQ4DORE6o6RlspzMk9TOPfr+fiLJCLFYr3TZSKNcI7+aJwWQmPM+TkqRg49tu65f/JcAAMwMas6WUKd8AAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-sql{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAh5JREFUeNp8kctrE1EUxr+ZyXMkoa1NBROaSkpTBE23PhZ25cql2y5duvAPUdGFS1FxIRRBXZlFQ9GVdDENIhGJxkDsw2mneZnM83ruNZlOmNoDhzlzz3d/9zv3Sowx8Ch/qlYK2XM3cEJsbH0+qjV/rd6/u6aN18b7RMFT+9aosP/Ex+0ae/puw7j36PlKEMAzctKJ3aGFamMHjV0d+wcGitkMrpWWp6hVIciEk2MAOwbUWjosx0UiFoWqJpGMx5DNzODq5aIPoa82AWBg/lyKLMH1PMp/a9XvLXLzG1cuFlBaWpiKxaIPSLY6CaC93ggQjyiQZRkeQSzLRovGaPciWLt5faSWEBoh6KBvOhiaNga0+Y9pwaFxvu7rfp8F5pWDt+qNMp2IijHGwddWCvN+33/CoAOP5nVdT9SdoQ1JkggiQ6Yvr7V60+9z7akA2gfH9cRF8hO5F5Ve4lQAF9uuK+qFsylkzsQxrcaQm04hdWkR83Mzfp9rQ3fAFzu9Ph6+WMfjl6/pGBdb2jbKmx8QlRjWy5vkyhUZBPgOeGNHN9AbDLGUz6He2hVj3Ll9C8/evsdgaMK0HV8bcmDTU0UUBYXcedR+NLGnH0I3jvDk1Rsy46FP4C/1BtrdntCGHNiOAzWZgEKQ5Qt5lIqLojbaXSQTcRy2OwT4SZqk0IYAOgkVWUE+lxX/zb0DpFNpkTzmZmfFtzewhHYcfwUYAMZmVaZQlLFHAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-tga{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnxJREFUeNp0U89PE0EU/ra725K22ILRGipb22pMG6JcSEQTbUIwnozxpBcvepeEP0KPogcT/wlNT17kIKbEmChFUYKGVtL0R2gLtNCl3Z1Z3+zSAlonmezOe/O+973vvZEsy4JYnqdPMu6RkSQYQ29JEkB+PZcrslrtPhQl23VZc8/tr9I1yMHg0EA8HrBM04lVFAhoY38fSSDQVN3pfKV8G7KcxZHl6v1xblqU3eLc3p2VFZjr6+gQgwsnhzGTuq6Nhs6kYZqXjwL0GFhEl3U60OfnwWs1GGtrUKNRsKkpeIIBpKIRtI1J7cX7hXRhc/MOhXw5DkCZGG2zXAajzFIoBMvng1ypIKOqmP30GW3OIEcimovzlxRy5RgAFwDEAIODkCcmIMdiQLsNdWwMZdJlg8pzEUt1aBhKq3XinxKYqF9yQbqRIqsMy+0Gyy47bKgUWXSLtDENE5wdtuqQATm50F1VnPbRGeEw8HXZbiV8fsDvI9ldju9vADAyihLEbrWAZhOoVp3z6iqBUiB1A4nEfwCEsbkL/M4TgE5n5jDx+oTEzp1d8m9tC8H6MaAB0imzx0NU/WKUYE+loEyawDBo2ui6TGfT6ANAxrvx87gYCGCxXEKVJvCWFsG3eh1vN/J4OD6Od4UC8o0G3TX7TGLHwI9iEQmvF9X6Fh7F4/iYy+GcLOMSlfEgGsP0qdNOmX0BiGKpVkV1bw/1nW2b/gCpf1PTcI+Y7eg6ps+G4bG4PR99SjAVo9HE4q+fKNE0vl5awuSohjeijbRefVjAtUgEQRK7Yhi9OKn7nKWZxxlSPWl3QwgnaIrW8QMhD542vUbx/W49m7sq4v4IMABOqi3Ej7bAEAAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-tgz{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnhJREFUeNpsU1trE0EYPbMzSTfdtInFtkkpiaXVWou2FRUEn/so6JugL/oH/Af+B1988if40jcFERQURNBSQdDWlLQN2lsue8neZsZvc7FoOrDszM75znfOmVmmtUYyvry++36yfOeS1qqzDtvH2P76ApPlW3Drb2sHex/uccHWAdbZX30kO2+B3siN3zhTnHuQ66+95i423jzFzOVljBdKOZNHazvVT7e5wF+SZBj9iZJ+3J11mbW2kR8T4LwFli5i4fqTUvnczTUp9RLtDhKgJx0q4dEwWAxrREKICHEsoYYXMXvlcWmquLgmY71yCkG/c0AkARgLMZpnMDMpGNzEYe0dGp6HwvmHpbHC1Wf9MnFCkHQOyYEPzSJwQ2B65Tm5NZG3Fshim6wbMNJn4bpHowMKtIqo2COgR2IcAptwjvcgo6i77igjEmVDqbY8xQJ1VwRULhiBI6+G9Zf3cbTziuzIDkmHSNqECTFgQScEcYuc2NA8TcdYwXD+GkK/TYVN+u72WrIudiAD8o6oAR2RRCmQMjis3CIy1iSpPySCXhFTXeyAgh4BR+JVw8pauLi0Cp4yCX9A90FQhnSBYtnF/k+Q+HYam9itfIZB3QvT8zj8XSW5EhNTs9ivbSLwPUzPLNPJBIMEKnaQYg6aB9+RGR5F5VsNgnNKXMI1NdJGG5WfHzFVLJ7k8c8xUngpVodlDSGbFYj8Y4yMpOG09lHf3yIFPzA3fwHZTAQVtU4JUTeFDrdgDdlI8wAz5Qy2KxswReI7QODZcOr0ZH3q2hIDBI7zq16tuk3FNPxAI4wN+pkoccYoE4YJU5EdUtM4Qst26v26PwIMAKj3P/2YUKgYAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-tiff{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmRJREFUeNp0UktPE1EU/qYzHWstlrYJNcWUElyUJsaNGh9B0g1Lo0v9Ey78EbrVxBhXuHShm25YGBJRQpAYBDEWpaEPEhksdVpbyjzveO4MfZDCTWbauefc736PIziOA77OPH2yJCcSGdg2uksQAKofFou/7VrtASRpvVNynj13f6XOhjg8HAlMTIQdy/LO+v3uYUPTkAHCTb+cK+0pdyGK6+hbvu4/xiyHbncYAwfR19ZgbG/DoO9LsSgeTd9JXoxfyMG2rvQDdBlwIZauQ5ufh12twioU4E+nYU1NIRCNIDs+Bt28mXzx8VNuZ796j9q/DgAwomwqClilAmF0FE4wCInAlkjO4y+r0JgNX2os6XPYS2q/cQyAcQatFjA0BPH6NYipccAwIGUy2CVJFZInkKlyJAqx3T4/IMGmJkeWIWSz5KgI5pdhb3yDXS5DSCYh8rTID8s0wexeVD0GtMd85KkkefFxUfE47M1NokbJkByEQl6tL+ouAI+MUwbFhnYbaJKc/Sqg0x4H4eDRGDA56fUOABA9/GsCpaIHwr8FOhQ823O5RfW66tUGADhNy3RNRDjcN41HLxdQ8J6jYTsOQLfOJBK4f+s2/uoathoNGKT1MtFeVHZxdWTEZfEq/wMKl3rCJOIzTV6ADs2R5ulYDDNkYjp0DhrF+zCVgkw31+v1UxjQZkNV0SADd2o1MIuc9gmY+/kLxb0/UFoHePd9A1qzeUoKpilx9xcLWzgg+u/zeVfuQqkM9bCN1ysrWKXxdtPgvScwUAm58XZ52W16QyPtifRUzi588GbEi1ztHPsvwAC4uC9qhnsZvwAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-txt{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAeJJREFUeNp8UrtOG1EQPfsyXiyzBguIJSyChZBBEFCKpKHLo6egpErNn8CHgH8gkZIiTSIXLhJAWCgkoMgRMSiRBSK29z4y9+I1d/HCrFb3MTPnnjkzlpQSynY+fP70fGF2gQuByCz6lfdd9Uurfvrrjes6762eb3tzQ69uFJwPsqOPC+MBEmxxphi4tlU5OGmsOzaBWLc+O9oIIVhScidkyGZ8vH62nHtSKlaI4cse6TjAfSaFBBcco0EWqyvzubmpyQrj/FXk75cQaSEMeMXU8xykPA/Hjd/6/LRcyjEpt2i7HAe4A2TeLZWKUOJaVLxj27j813EHGKCXaAJExu/4BOdiAED08riQD2riOrexyRoYc3CvsAbLGAAjZga7vgZG23WMCdBvoxKJc36TRBlMiaa2JByjNqqD8qkYc1pjDK7abey+/YhrWlfKswhpiCR96aEU9o5+QE3g2ovVWDm2Sc22bBQm8vrVpbkS9r+doPr1EOWZaQ0yFoxg2PcREosEAI4uvZhJpzFMP+cSXRbq+043RManez+tNWKMI6GN0g0Z04HFR+NoNC/0yx717efZOSbzY3AcR4Op2AGA5p/W31r9e0vNgSrh9OwCrpeCkqvZuqTybnpRqx/r2CjvvwADAJC/7lzAzQmwAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-wav{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAApFJREFUeNpsU1tPE0EYPXtpKbX0wqUQKVQMFdIXQBNCQBs06KP+B8ODGh+Mf4b/4IsGE54kxhcMBrkp7YOQgBRvSKG73fvsrt8Otoask0xmd+b7zpxzvm8E3/cRjPkniyulW0NFy2JoDkEAguOlpXJ9p3L8MBqVl4O9YHxae8pXuRlcGO7KPLhfTDVUqwUgigJMy4Whm6lEXHjxYf3XnByRN0QB/2KaH7btMlUxoRJAcyqKhdOaht7+DJ49n+2cvTnwynXcsb+kLwJ4rgfmMDDGWqvneXCZS9ND7mov5h9ND85M9y86Dpto5rUkuJ4Py3YDJpy6QGJPayqB+Njf+43XL220t0cwOZkfrNXsBUqZugDA6CbLdAiAwaek1ZU9LmP8Rh6S78GsGxjOp9FdzKJaVZIhBgGASzK21w/wbrnCk8euX+EMAjaaZuPHdwUdHVFYluuGPGCORwwYjg5rqOwccRk+3Ux0IEvntmsNG4ZmUayL/wAwKHUNfZfTKN0ZRaw9Cof8qJ/pMAyHy5KkAMTksSEJtnMenM7EMVMawbejMzJRh67bXEYiIXEAVTW50SEAhzqwfqrBcXx4VOhYm4RsNgHbsJFOyZTsQ1MN+hcohoUlkFiMT+TQFpMwXOjGpXgE+XwGk1N5pFJtKNCequgYGupCRBbCDOp0KBJc4VoP3dyBONW8uydBgBHUThqQKCk3mEZ/LoUG+RBioJO7VarAwEAntjYPiUUW9Hh4b2R7k9j98hN37xWx8fGAt3eIAdVMLn+uUv+b2KReSCZjZJiB9bV9jIz2ofr1BKvvd7G9dRC80lae0HzOt+cWVnrSKDrMJykifwNBpCgE/UAllEXufmDu8Zlffvvm8XSQ90eAAQA0pF7c08o4PAAAAABJRU5ErkJggg==');background-repeat:no-repeat;background-size:contain}.ipfs-xls{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmxJREFUeNpsU0trFEEQ/mamZ3Y2+0zIC2MmITEkUYgERFQErx5E8KTi1b/h79A/4SW3nCNeYggBYZVEMU/y3N3Z7M7OTD/G6lk2ruw20zRdU/XV91VVG0mSQK/3n1a/jky6d6Xs3G8WXS+Pw5N6LXjLLGuna/78oZKerGsYKtrDE16uJGL1L9gEOOcYd2dL1fNwrbL//aXN7J1efPMmkUqEFAk0A0VZNbFEaQCBscIkXj975y3NLq9xye8PBkAniHOFph+j2eC4rsdoB4LsFubGl/Hq8RtvYWpxTQi52o1jvWiGYaRZL0/auDgOkC/Z8BYL2Pqxidp1FZkhoDxpeaXA/Ujuj/4HoOxKKjiOiek7RUShRNQWaNYFQuMafrYCxiw4ozZKfqbYJ0EvRdl1DQyyTs8XCNTA6UELMwvDyLpZWIZNNlNLlQOK2LMJRJ+5AkuZ1S7CFFzJzk56GnUjQWlYkqCoBWFbonEVYcLLA4dNnB624GQsDBWIgfZJEgxkoChzSFWvn4VpQemDm2VwXQsXJwF1h6c+gxlQ5jgSiEUEt0wdIe7tMES+nEG2aCLiJMOIIWIr9e0DEELAMUrwRuchVAyTKimUwO75Jm6VF3Bv7imOaj+xd7UFKVS/BPJF1b/E4tgTrE49J60O5kceoNqowiuuYKa8ghHXA48U9MT2AQgyRvTThE30bQiaSGa4yLMJNFo+Dq/2cHt4CYlwyFf2S6BHwwrMw/avDbR5C1k7h1YQ4KH3Amf+AcZyEbZPv9CItzQD1l9EbtYOjv74v/d3O9RMPTDrsEwGIWN8q2yk7XNYRs9JrRv3V4ABADSGR6eQ0/NQAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-xlsx{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmlJREFUeNpsU8tqFEEUPVXdPY/ueWZIoiYZiSYKYhJc6EbduHOhgijo3t/wH1z6B0JAhOyMILhxo4kJGk1ASTAxwWF0Mpp5dHc9vFUzYwidaoqmq+8959xzbzGtNcx69PTS26ETmQtS9r4Hy/xv7MW7jV+th5yzVcaYPX/++It9u4NAv+CVR6tBUUTqMJsDcRzjZOZM8W9ZLKx+/XDb4e5/kH5In0lpIYWGUaC0YTZnBCAEKoVR3L36oDo7NbsglZwbqD6iQKOXFMcKUVfBkBAoQhlD5xxMDp/HrSv3q1JgYW3z0x0KXzkCYJaRZljru23aHWTzLiamAyytv0O9UYdf5PArqlppBfMUfu4oALErqZBKcUxMFRCHEp0DgW5Lo4N9NIN1dF0XXsVFOUyPJTzo+WBANDidjp8tgHGG3c0DnJ4uIRf4cOCBaW5KjY8xkZL72xpJ9QcFz5bVqHUJGHZL2YtNmKi06YCyiVFb4s/vEKMTAf1p4edOG6mMi1zR6wEpdUwX+vLDtkCzHoK7ptcM6ayLmGajvtex4PliyoIkFRjmUEASelB2rXQRSfjUCT9PlWpmW21iTGzCAyEkUixPRqXhe2V4zKczbdmybgkpJ0cGOuA6Y2MTCsKoi5HsNK7N3MN+uwYaWbxYfoLLkzdxcew6lrYWaZhm8PHHG3zffp1UwJSHz9vvkU8PodbcQYYYS5lxYkxTkGdVDQdV1Js1qPgYD6JIuIE7gsXVefIhIuM05k7dwMbeMmh87a18ufIMaVYyprrJLgje2Nr+1tzYXANnDnr3zRhHj37Vvy2wpXHtNAd5/wQYAD6WMuT2CwoVAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-xml{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAilJREFUeNqMks1PE0EYxh+g3W2t1G0sEqyISynUFJsSOShNwCamiYZED3LgIkcuxoN/iCZePZiYGD2aGD+i0F5KMChxlVaakAK2ykcAt+WzdLu7zkxo3WZL4pu8mXfmeeY3885ug67roPFh5nvc62m9hjoR+5LMp7MrkYf370qVtco+VtCUFpbj+jGR+JbWn76OyQ8ePwsZATQb8R/hanZgINgj9IqeuBFCw1Kt9OMBnNWCs24XwkG/QKYUEiGjVAPQof/rq0783pShET3ULQo8xz0iS5FaANmrHQH2DoqY+DSLSz6RzecWlnD9ymU47LYjd4O5BXqDTG4FM3NpTEkpdJ5rw0AowLRMbhUfp58gTOaD/UHmNQPI6YmvKWRX1zESHUJ/oBs2nmPa+Mgw0ZIM3tZyGoJwygzQNB2jNyJIZX7iB0lpPoM70UGmPX8zCU+rG8NDVxHwdiC5mKsPUFUN/gvtLLf39sFzVqaN3YrC6TjBauqhXhNA1TQoqloV7Da+pjZq1FsXUCamF29j6LvYhf3iISamZ3Fv9DZevouhRzzPfOG+3hpA9U9UyioOlTJ7pFeTCQS6RGzIebyf+oz5pSzWtmSW1EO9phvQ00slBRt/8qR3DoWdXbiczUiTzd52D+tdLmyTB14mx1rMAKVcRpEATjrsuElee/HXGmnFRyBOGD30C/nEDjNgs7CDpsYmnHG3YPegBCvHs9oYfm8nG9dJa5X4K8AAQzQX4KSN3wcAAAAASUVORK5CYII=');background-repeat:no-repeat;background-size:contain}.ipfs-yml{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAdxJREFUeNqMUl1rE0EUPbM7m5Y0Zptu21AwWwhYpfSDFh+kvvRd8N0Hf4I/xWdf/Q158F0QoQ+CVsFKaLSQpt/dpmvztTOzzky6cetOpWcZZvbO3MO5514SxzEU3r57/3GpWllM/tP4sL3TarROXuSo/SWJvX71Uu80Cfhlr/T4UdWFAVfdnmsTUtvdP35OUyQKVnJgXDBTcj9icAsTeLax7j/052qM81UjwW1QJXEhMF0qYnN90fdnvdogYmvJPU0/VBApD4hcDrWRcyikfB17srzgW7b9Rh1vEvxDlI4tVytaBSEEtmWh0xsUMwpwnWjqAlcxogiHd1wiQyCu87iI/+sJtf6+NXsgpd7FWCMB50KvkYMGMbLdZgLlfj+K9K4+FnFQ2x7WntIs50AbmiGwLILt+k+EvzvSNIHzdigdJ/AmXQRhiHv5POSwYmG+cqPVo0HqDxj8uTK2vn1Hfa+JmdIkvtZ/4fOPXU3WPDpFeNWVyUKryCiIGMN4zsH98gym3CIcOTwT+XHdXrdQQHAZotE8kBPpSqPNHtBOr48HUmLOcXRJT9dWNMGYJFby91pHOAvaykSaITg+bwefdhrteDRTMSwyrFCgI88E056Hy+4Ah2cXQZL3R4ABALUe7fqXWFN6AAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}.ipfs-zip{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAm9JREFUeNpsk0tv00AUhc+MY6dOmgeFJg1FoVVpUWlFC0s2IFF1jxBbhKj4BSxYdscPYcEmQmIDq0gsERIViy4TpD7VFzF1Ho5je2a4thOqNhlp5Mz4zudzzp0wpRTC8fPrk0/TC6+fDtYicLH97T1Kc2vQDcs+rH3eUAxVznn0fn1DRM8E+iOdv5ct3XmZG6yVlNj6solUbgVTt0q5FGtX6vXqC6VklTE+KAO/OODHSIQPRQpsXC+kkEz2ELA0ystv84tLzyucsbWByisAGf+QAS2CCDRRLMJMmxC+i8C4jdLCm/zM7OOKFGptcO6/BTpJ0yeQB0Y+mfKQuZZG0jQgeRbW8Xdomobs9LN8scc+UPHNy4Dwq8IljotIIQEm59/RoSyM1CKkXKZNBm7kIVgyM6wgAnSgRK9vqQfHPiMFDHqyFVsLR9Cm0o4YzoAASrSjCelQfRPb1Vc4qn0EY5L2W9GEaBLcxQgFHpGbkMIDJ69e+wjJ8VXqRgKid0r7ftQdxkRs9SqA2kgAm14SSIQh9uhuLGPMnKJs/5KquL1x0N0RCsizigoDaLqBdHoMiyvrlBsHVx1wphD4BCewoqxGKKDwAgtOy8JufYuk+5golGGaGZwc1sIGoDz3AOPZSVLaHgVwydoJDM1H4DbQODughB3YpOD44HfoHgnu4e7So0uAi0stHLJ3Aud8B9bpHu6vPoSu9TtDl6tUuoFiIYOgu0+158MKmOxomtyD3Qi/3MTR7i8K0EDG1GHO5DE3X4DvNahZlJOwEkOATvdPc2//hx3mXJ5lFJaF8K8bStd0YGfnOJbMGex21x6c+yfAAOlIPDJzr7cLAAAAAElFTkSuQmCC');background-repeat:no-repeat;background-size:contain}
8 - .narrow {width: 0px;}
9 - .padding { margin: 100px;}
10 - #header {
11 - background: #000;
12 - }
13 - #logo {
14 - height: 25px;
15 - margin: 10px;
16 - }
17 - .ipfs-icon {
18 - width:16px;
19 - }
20 - </style>
21 - <title>{{ .Path }}</title>
22 -</head>
23 -<body>
24 - <div id="header" class="row">
25 - <div class="col-xs-2">
26 - <div id="logo" class="ipfs-logo">&nbsp;</div>
27 - </div>
28 - </div>
29 - <br/>
30 - <div class="col-xs-12">
31 - <div class="panel panel-default">
32 - <div class="panel-heading">
33 - <strong>Index of {{ .Path }}</strong>
34 - </div>
35 - <table class="table table-striped">
36 - <tr>
37 - <td class="narrow">
38 - <div class="ipfs-icon ipfs-_blank">&nbsp;</div>
39 - </td>
40 - <td class="padding">
41 - <a href="{{.BackLink | urlEscape}}">..</a>
42 - </td>
43 - <td></td>
44 - </tr>
45 - {{ range .Listing }}
46 - <tr>
47 - <td>
48 - <div class="ipfs-icon {{iconFromExt .Name}}">&nbsp;</div>
49 - </td>
50 - <td>
51 - <a href="{{ .Path | urlEscape }}">{{ .Name }}</a>
52 - </td>
53 - <td>{{ .Size }}</td>
54 - </tr>
55 - {{ end }}
56 - </table>
57 - </div>
58 - </div>
59 -</body>
60 -</html>
vendor/dir-index-html-v1.0.0/gw-assets/bootstrap.min.css deleted
-5
@@ -1,5 +0,0 @@
1 -/*!
2 - * Bootstrap v3.3.4 (http://getbootstrap.com)
3 - * Copyright 2011-2015 Twitter, Inc.
4 - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
5 - *//*! normalize.css v3.0.2 | MIT License | git.io/normalize */html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}input{line-height:normal}input[type=checkbox],input[type=radio]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid silver}legend{padding:0;border:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0}/*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */@media print{*,:after,:before{color:#000!important;text-shadow:none!important;background:0 0!important;-webkit-box-shadow:none!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}a[href^="javascript:"]:after,a[href^="#"]:after{content:""}blockquote,pre{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}img,tr{page-break-inside:avoid}img{max-width:100%!important}h2,h3,p{orphans:3;widows:3}h2,h3{page-break-after:avoid}select{background:#fff!important}.navbar{display:none}.btn>.caret,.dropup>.btn>.caret{border-top-color:#000!important}.label{border:1px solid #000}.table{border-collapse:collapse!important}.table td,.table th{background-color:#fff!important}.table-bordered td,.table-bordered th{border:1px solid #ddd!important}}@font-face{font-family:'Glyphicons Halflings';src:url(../fonts/glyphicons-halflings-regular.eot);src:url(../fonts/glyphicons-halflings-regular.eot?#iefix) format('embedded-opentype'),url(../fonts/glyphicons-halflings-regular.woff2) format('woff2'),url(../fonts/glyphicons-halflings-regular.woff) format('woff'),url(../fonts/glyphicons-halflings-regular.ttf) format('truetype'),url(../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular) format('svg')}.glyphicon{position:relative;top:1px;display:inline-block;font-family:'Glyphicons Halflings';font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.glyphicon-asterisk:before{content:"\2a"}.glyphicon-plus:before{content:"\2b"}.glyphicon-eur:before,.glyphicon-euro:before{content:"\20ac"}.glyphicon-minus:before{content:"\2212"}.glyphicon-cloud:before{content:"\2601"}.glyphicon-envelope:before{content:"\2709"}.glyphicon-pencil:before{content:"\270f"}.glyphicon-glass:before{content:"\e001"}.glyphicon-music:before{content:"\e002"}.glyphicon-search:before{content:"\e003"}.glyphicon-heart:before{content:"\e005"}.glyphicon-star:before{content:"\e006"}.glyphicon-star-empty:before{content:"\e007"}.glyphicon-user:before{content:"\e008"}.glyphicon-film:before{content:"\e009"}.glyphicon-th-large:before{content:"\e010"}.glyphicon-th:before{content:"\e011"}.glyphicon-th-list:before{content:"\e012"}.glyphicon-ok:before{content:"\e013"}.glyphicon-remove:before{content:"\e014"}.glyphicon-zoom-in:before{content:"\e015"}.glyphicon-zoom-out:before{content:"\e016"}.glyphicon-off:before{content:"\e017"}.glyphicon-signal:before{content:"\e018"}.glyphicon-cog:before{content:"\e019"}.glyphicon-trash:before{content:"\e020"}.glyphicon-home:before{content:"\e021"}.glyphicon-file:before{content:"\e022"}.glyphicon-time:before{content:"\e023"}.glyphicon-road:before{content:"\e024"}.glyphicon-download-alt:before{content:"\e025"}.glyphicon-download:before{content:"\e026"}.glyphicon-upload:before{content:"\e027"}.glyphicon-inbox:before{content:"\e028"}.glyphicon-play-circle:before{content:"\e029"}.glyphicon-repeat:before{content:"\e030"}.glyphicon-refresh:before{content:"\e031"}.glyphicon-list-alt:before{content:"\e032"}.glyphicon-lock:before{content:"\e033"}.glyphicon-flag:before{content:"\e034"}.glyphicon-headphones:before{content:"\e035"}.glyphicon-volume-off:before{content:"\e036"}.glyphicon-volume-down:before{content:"\e037"}.glyphicon-volume-up:before{content:"\e038"}.glyphicon-qrcode:before{content:"\e039"}.glyphicon-barcode:before{content:"\e040"}.glyphicon-tag:before{content:"\e041"}.glyphicon-tags:before{content:"\e042"}.glyphicon-book:before{content:"\e043"}.glyphicon-bookmark:before{content:"\e044"}.glyphicon-print:before{content:"\e045"}.glyphicon-camera:before{content:"\e046"}.glyphicon-font:before{content:"\e047"}.glyphicon-bold:before{content:"\e048"}.glyphicon-italic:before{content:"\e049"}.glyphicon-text-height:before{content:"\e050"}.glyphicon-text-width:before{content:"\e051"}.glyphicon-align-left:before{content:"\e052"}.glyphicon-align-center:before{content:"\e053"}.glyphicon-align-right:before{content:"\e054"}.glyphicon-align-justify:before{content:"\e055"}.glyphicon-list:before{content:"\e056"}.glyphicon-indent-left:before{content:"\e057"}.glyphicon-indent-right:before{content:"\e058"}.glyphicon-facetime-video:before{content:"\e059"}.glyphicon-picture:before{content:"\e060"}.glyphicon-map-marker:before{content:"\e062"}.glyphicon-adjust:before{content:"\e063"}.glyphicon-tint:before{content:"\e064"}.glyphicon-edit:before{content:"\e065"}.glyphicon-share:before{content:"\e066"}.glyphicon-check:before{content:"\e067"}.glyphicon-move:before{content:"\e068"}.glyphicon-step-backward:before{content:"\e069"}.glyphicon-fast-backward:before{content:"\e070"}.glyphicon-backward:before{content:"\e071"}.glyphicon-play:before{content:"\e072"}.glyphicon-pause:before{content:"\e073"}.glyphicon-stop:before{content:"\e074"}.glyphicon-forward:before{content:"\e075"}.glyphicon-fast-forward:before{content:"\e076"}.glyphicon-step-forward:before{content:"\e077"}.glyphicon-eject:before{content:"\e078"}.glyphicon-chevron-left:before{content:"\e079"}.glyphicon-chevron-right:before{content:"\e080"}.glyphicon-plus-sign:before{content:"\e081"}.glyphicon-minus-sign:before{content:"\e082"}.glyphicon-remove-sign:before{content:"\e083"}.glyphicon-ok-sign:before{content:"\e084"}.glyphicon-question-sign:before{content:"\e085"}.glyphicon-info-sign:before{content:"\e086"}.glyphicon-screenshot:before{content:"\e087"}.glyphicon-remove-circle:before{content:"\e088"}.glyphicon-ok-circle:before{content:"\e089"}.glyphicon-ban-circle:before{content:"\e090"}.glyphicon-arrow-left:before{content:"\e091"}.glyphicon-arrow-right:before{content:"\e092"}.glyphicon-arrow-up:before{content:"\e093"}.glyphicon-arrow-down:before{content:"\e094"}.glyphicon-share-alt:before{content:"\e095"}.glyphicon-resize-full:before{content:"\e096"}.glyphicon-resize-small:before{content:"\e097"}.glyphicon-exclamation-sign:before{content:"\e101"}.glyphicon-gift:before{content:"\e102"}.glyphicon-leaf:before{content:"\e103"}.glyphicon-fire:before{content:"\e104"}.glyphicon-eye-open:before{content:"\e105"}.glyphicon-eye-close:before{content:"\e106"}.glyphicon-warning-sign:before{content:"\e107"}.glyphicon-plane:before{content:"\e108"}.glyphicon-calendar:before{content:"\e109"}.glyphicon-random:before{content:"\e110"}.glyphicon-comment:before{content:"\e111"}.glyphicon-magnet:before{content:"\e112"}.glyphicon-chevron-up:before{content:"\e113"}.glyphicon-chevron-down:before{content:"\e114"}.glyphicon-retweet:before{content:"\e115"}.glyphicon-shopping-cart:before{content:"\e116"}.glyphicon-folder-close:before{content:"\e117"}.glyphicon-folder-open:before{content:"\e118"}.glyphicon-resize-vertical:before{content:"\e119"}.glyphicon-resize-horizontal:before{content:"\e120"}.glyphicon-hdd:before{content:"\e121"}.glyphicon-bullhorn:before{content:"\e122"}.glyphicon-bell:before{content:"\e123"}.glyphicon-certificate:before{content:"\e124"}.glyphicon-thumbs-up:before{content:"\e125"}.glyphicon-thumbs-down:before{content:"\e126"}.glyphicon-hand-right:before{content:"\e127"}.glyphicon-hand-left:before{content:"\e128"}.glyphicon-hand-up:before{content:"\e129"}.glyphicon-hand-down:before{content:"\e130"}.glyphicon-circle-arrow-right:before{content:"\e131"}.glyphicon-circle-arrow-left:before{content:"\e132"}.glyphicon-circle-arrow-up:before{content:"\e133"}.glyphicon-circle-arrow-down:before{content:"\e134"}.glyphicon-globe:before{content:"\e135"}.glyphicon-wrench:before{content:"\e136"}.glyphicon-tasks:before{content:"\e137"}.glyphicon-filter:before{content:"\e138"}.glyphicon-briefcase:before{content:"\e139"}.glyphicon-fullscreen:before{content:"\e140"}.glyphicon-dashboard:before{content:"\e141"}.glyphicon-paperclip:before{content:"\e142"}.glyphicon-heart-empty:before{content:"\e143"}.glyphicon-link:before{content:"\e144"}.glyphicon-phone:before{content:"\e145"}.glyphicon-pushpin:before{content:"\e146"}.glyphicon-usd:before{content:"\e148"}.glyphicon-gbp:before{content:"\e149"}.glyphicon-sort:before{content:"\e150"}.glyphicon-sort-by-alphabet:before{content:"\e151"}.glyphicon-sort-by-alphabet-alt:before{content:"\e152"}.glyphicon-sort-by-order:before{content:"\e153"}.glyphicon-sort-by-order-alt:before{content:"\e154"}.glyphicon-sort-by-attributes:before{content:"\e155"}.glyphicon-sort-by-attributes-alt:before{content:"\e156"}.glyphicon-unchecked:before{content:"\e157"}.glyphicon-expand:before{content:"\e158"}.glyphicon-collapse-down:before{content:"\e159"}.glyphicon-collapse-up:before{content:"\e160"}.glyphicon-log-in:before{content:"\e161"}.glyphicon-flash:before{content:"\e162"}.glyphicon-log-out:before{content:"\e163"}.glyphicon-new-window:before{content:"\e164"}.glyphicon-record:before{content:"\e165"}.glyphicon-save:before{content:"\e166"}.glyphicon-open:before{content:"\e167"}.glyphicon-saved:before{content:"\e168"}.glyphicon-import:before{content:"\e169"}.glyphicon-export:before{content:"\e170"}.glyphicon-send:before{content:"\e171"}.glyphicon-floppy-disk:before{content:"\e172"}.glyphicon-floppy-saved:before{content:"\e173"}.glyphicon-floppy-remove:before{content:"\e174"}.glyphicon-floppy-save:before{content:"\e175"}.glyphicon-floppy-open:before{content:"\e176"}.glyphicon-credit-card:before{content:"\e177"}.glyphicon-transfer:before{content:"\e178"}.glyphicon-cutlery:before{content:"\e179"}.glyphicon-header:before{content:"\e180"}.glyphicon-compressed:before{content:"\e181"}.glyphicon-earphone:before{content:"\e182"}.glyphicon-phone-alt:before{content:"\e183"}.glyphicon-tower:before{content:"\e184"}.glyphicon-stats:before{content:"\e185"}.glyphicon-sd-video:before{content:"\e186"}.glyphicon-hd-video:before{content:"\e187"}.glyphicon-subtitles:before{content:"\e188"}.glyphicon-sound-stereo:before{content:"\e189"}.glyphicon-sound-dolby:before{content:"\e190"}.glyphicon-sound-5-1:before{content:"\e191"}.glyphicon-sound-6-1:before{content:"\e192"}.glyphicon-sound-7-1:before{content:"\e193"}.glyphicon-copyright-mark:before{content:"\e194"}.glyphicon-registration-mark:before{content:"\e195"}.glyphicon-cloud-download:before{content:"\e197"}.glyphicon-cloud-upload:before{content:"\e198"}.glyphicon-tree-conifer:before{content:"\e199"}.glyphicon-tree-deciduous:before{content:"\e200"}.glyphicon-cd:before{content:"\e201"}.glyphicon-save-file:before{content:"\e202"}.glyphicon-open-file:before{content:"\e203"}.glyphicon-level-up:before{content:"\e204"}.glyphicon-copy:before{content:"\e205"}.glyphicon-paste:before{content:"\e206"}.glyphicon-alert:before{content:"\e209"}.glyphicon-equalizer:before{content:"\e210"}.glyphicon-king:before{content:"\e211"}.glyphicon-queen:before{content:"\e212"}.glyphicon-pawn:before{content:"\e213"}.glyphicon-bishop:before{content:"\e214"}.glyphicon-knight:before{content:"\e215"}.glyphicon-baby-formula:before{content:"\e216"}.glyphicon-tent:before{content:"\26fa"}.glyphicon-blackboard:before{content:"\e218"}.glyphicon-bed:before{content:"\e219"}.glyphicon-apple:before{content:"\f8ff"}.glyphicon-erase:before{content:"\e221"}.glyphicon-hourglass:before{content:"\231b"}.glyphicon-lamp:before{content:"\e223"}.glyphicon-duplicate:before{content:"\e224"}.glyphicon-piggy-bank:before{content:"\e225"}.glyphicon-scissors:before{content:"\e226"}.glyphicon-bitcoin:before{content:"\e227"}.glyphicon-btc:before{content:"\e227"}.glyphicon-xbt:before{content:"\e227"}.glyphicon-yen:before{content:"\00a5"}.glyphicon-jpy:before{content:"\00a5"}.glyphicon-ruble:before{content:"\20bd"}.glyphicon-rub:before{content:"\20bd"}.glyphicon-scale:before{content:"\e230"}.glyphicon-ice-lolly:before{content:"\e231"}.glyphicon-ice-lolly-tasted:before{content:"\e232"}.glyphicon-education:before{content:"\e233"}.glyphicon-option-horizontal:before{content:"\e234"}.glyphicon-option-vertical:before{content:"\e235"}.glyphicon-menu-hamburger:before{content:"\e236"}.glyphicon-modal-window:before{content:"\e237"}.glyphicon-oil:before{content:"\e238"}.glyphicon-grain:before{content:"\e239"}.glyphicon-sunglasses:before{content:"\e240"}.glyphicon-text-size:before{content:"\e241"}.glyphicon-text-color:before{content:"\e242"}.glyphicon-text-background:before{content:"\e243"}.glyphicon-object-align-top:before{content:"\e244"}.glyphicon-object-align-bottom:before{content:"\e245"}.glyphicon-object-align-horizontal:before{content:"\e246"}.glyphicon-object-align-left:before{content:"\e247"}.glyphicon-object-align-vertical:before{content:"\e248"}.glyphicon-object-align-right:before{content:"\e249"}.glyphicon-triangle-right:before{content:"\e250"}.glyphicon-triangle-left:before{content:"\e251"}.glyphicon-triangle-bottom:before{content:"\e252"}.glyphicon-triangle-top:before{content:"\e253"}.glyphicon-console:before{content:"\e254"}.glyphicon-superscript:before{content:"\e255"}.glyphicon-subscript:before{content:"\e256"}.glyphicon-menu-left:before{content:"\e257"}.glyphicon-menu-right:before{content:"\e258"}.glyphicon-menu-down:before{content:"\e259"}.glyphicon-menu-up:before{content:"\e260"}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}:after,:before{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}html{font-size:10px;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:1.42857143;color:#333;background-color:#fff}button,input,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a{color:#337ab7;text-decoration:none}a:focus,a:hover{color:#23527c;text-decoration:underline}a:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}figure{margin:0}img{vertical-align:middle}.carousel-inner>.item>a>img,.carousel-inner>.item>img,.img-responsive,.thumbnail a>img,.thumbnail>img{display:block;max-width:100%;height:auto}.img-rounded{border-radius:6px}.img-thumbnail{display:inline-block;max-width:100%;height:auto;padding:4px;line-height:1.42857143;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.img-circle{border-radius:50%}hr{margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}[role=button]{cursor:pointer}.h1,.h2,.h3,.h4,.h5,.h6,h1,h2,h3,h4,h5,h6{font-family:inherit;font-weight:500;line-height:1.1;color:inherit}.h1 .small,.h1 small,.h2 .small,.h2 small,.h3 .small,.h3 small,.h4 .small,.h4 small,.h5 .small,.h5 small,.h6 .small,.h6 small,h1 .small,h1 small,h2 .small,h2 small,h3 .small,h3 small,h4 .small,h4 small,h5 .small,h5 small,h6 .small,h6 small{font-weight:400;line-height:1;color:#777}.h1,.h2,.h3,h1,h2,h3{margin-top:20px;margin-bottom:10px}.h1 .small,.h1 small,.h2 .small,.h2 small,.h3 .small,.h3 small,h1 .small,h1 small,h2 .small,h2 small,h3 .small,h3 small{font-size:65%}.h4,.h5,.h6,h4,h5,h6{margin-top:10px;margin-bottom:10px}.h4 .small,.h4 small,.h5 .small,.h5 small,.h6 .small,.h6 small,h4 .small,h4 small,h5 .small,h5 small,h6 .small,h6 small{font-size:75%}.h1,h1{font-size:36px}.h2,h2{font-size:30px}.h3,h3{font-size:24px}.h4,h4{font-size:18px}.h5,h5{font-size:14px}.h6,h6{font-size:12px}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:16px;font-weight:300;line-height:1.4}@media (min-width:768px){.lead{font-size:21px}}.small,small{font-size:85%}.mark,mark{padding:.2em;background-color:#fcf8e3}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}.text-justify{text-align:justify}.text-nowrap{white-space:nowrap}.text-lowercase{text-transform:lowercase}.text-uppercase{text-transform:uppercase}.text-capitalize{text-transform:capitalize}.text-muted{color:#777}.text-primary{color:#337ab7}a.text-primary:hover{color:#286090}.text-success{color:#3c763d}a.text-success:hover{color:#2b542c}.text-info{color:#31708f}a.text-info:hover{color:#245269}.text-warning{color:#8a6d3b}a.text-warning:hover{color:#66512c}.text-danger{color:#a94442}a.text-danger:hover{color:#843534}.bg-primary{color:#fff;background-color:#337ab7}a.bg-primary:hover{background-color:#286090}.bg-success{background-color:#dff0d8}a.bg-success:hover{background-color:#c1e2b3}.bg-info{background-color:#d9edf7}a.bg-info:hover{background-color:#afd9ee}.bg-warning{background-color:#fcf8e3}a.bg-warning:hover{background-color:#f7ecb5}.bg-danger{background-color:#f2dede}a.bg-danger:hover{background-color:#e4b9b9}.page-header{padding-bottom:9px;margin:40px 0 20px;border-bottom:1px solid #eee}ol,ul{margin-top:0;margin-bottom:10px}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;margin-left:-5px;list-style:none}.list-inline>li{display:inline-block;padding-right:5px;padding-left:5px}dl{margin-top:0;margin-bottom:20px}dd,dt{line-height:1.42857143}dt{font-weight:700}dd{margin-left:0}@media (min-width:768px){.dl-horizontal dt{float:left;width:160px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:180px}}abbr[data-original-title],abbr[title]{cursor:help;border-bottom:1px dotted #777}.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:10px 20px;margin:0 0 20px;font-size:17.5px;border-left:5px solid #eee}blockquote ol:last-child,blockquote p:last-child,blockquote ul:last-child{margin-bottom:0}blockquote .small,blockquote footer,blockquote small{display:block;font-size:80%;line-height:1.42857143;color:#777}blockquote .small:before,blockquote footer:before,blockquote small:before{content:'\2014 \00A0'}.blockquote-reverse,blockquote.pull-right{padding-right:15px;padding-left:0;text-align:right;border-right:5px solid #eee;border-left:0}.blockquote-reverse .small:before,.blockquote-reverse footer:before,.blockquote-reverse small:before,blockquote.pull-right .small:before,blockquote.pull-right footer:before,blockquote.pull-right small:before{content:''}.blockquote-reverse .small:after,.blockquote-reverse footer:after,.blockquote-reverse small:after,blockquote.pull-right .small:after,blockquote.pull-right footer:after,blockquote.pull-right small:after{content:'\00A0 \2014'}address{margin-bottom:20px;font-style:normal;line-height:1.42857143}code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,"Courier New",monospace}code{padding:2px 4px;font-size:90%;color:#c7254e;background-color:#f9f2f4;border-radius:4px}kbd{padding:2px 4px;font-size:90%;color:#fff;background-color:#333;border-radius:3px;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.25);box-shadow:inset 0 -1px 0 rgba(0,0,0,.25)}kbd kbd{padding:0;font-size:100%;font-weight:700;-webkit-box-shadow:none;box-shadow:none}pre{display:block;padding:9.5px;margin:0 0 10px;font-size:13px;line-height:1.42857143;color:#333;word-break:break-all;word-wrap:break-word;background-color:#f5f5f5;border:1px solid #ccc;border-radius:4px}pre code{padding:0;font-size:inherit;color:inherit;white-space:pre-wrap;background-color:transparent;border-radius:0}.pre-scrollable{max-height:340px;overflow-y:scroll}.container{padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}@media (min-width:768px){.container{width:750px}}@media (min-width:992px){.container{width:970px}}@media (min-width:1200px){.container{width:1170px}}.container-fluid{padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}.row{margin-right:-15px;margin-left:-15px}.col-lg-1,.col-lg-10,.col-lg-11,.col-lg-12,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-md-1,.col-md-10,.col-md-11,.col-md-12,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-sm-1,.col-sm-10,.col-sm-11,.col-sm-12,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-xs-1,.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9{position:relative;min-height:1px;padding-right:15px;padding-left:15px}.col-xs-1,.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9{float:left}.col-xs-12{width:100%}.col-xs-11{width:91.66666667%}.col-xs-10{width:83.33333333%}.col-xs-9{width:75%}.col-xs-8{width:66.66666667%}.col-xs-7{width:58.33333333%}.col-xs-6{width:50%}.col-xs-5{width:41.66666667%}.col-xs-4{width:33.33333333%}.col-xs-3{width:25%}.col-xs-2{width:16.66666667%}.col-xs-1{width:8.33333333%}.col-xs-pull-12{right:100%}.col-xs-pull-11{right:91.66666667%}.col-xs-pull-10{right:83.33333333%}.col-xs-pull-9{right:75%}.col-xs-pull-8{right:66.66666667%}.col-xs-pull-7{right:58.33333333%}.col-xs-pull-6{right:50%}.col-xs-pull-5{right:41.66666667%}.col-xs-pull-4{right:33.33333333%}.col-xs-pull-3{right:25%}.col-xs-pull-2{right:16.66666667%}.col-xs-pull-1{right:8.33333333%}.col-xs-pull-0{right:auto}.col-xs-push-12{left:100%}.col-xs-push-11{left:91.66666667%}.col-xs-push-10{left:83.33333333%}.col-xs-push-9{left:75%}.col-xs-push-8{left:66.66666667%}.col-xs-push-7{left:58.33333333%}.col-xs-push-6{left:50%}.col-xs-push-5{left:41.66666667%}.col-xs-push-4{left:33.33333333%}.col-xs-push-3{left:25%}.col-xs-push-2{left:16.66666667%}.col-xs-push-1{left:8.33333333%}.col-xs-push-0{left:auto}.col-xs-offset-12{margin-left:100%}.col-xs-offset-11{margin-left:91.66666667%}.col-xs-offset-10{margin-left:83.33333333%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-8{margin-left:66.66666667%}.col-xs-offset-7{margin-left:58.33333333%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-5{margin-left:41.66666667%}.col-xs-offset-4{margin-left:33.33333333%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-2{margin-left:16.66666667%}.col-xs-offset-1{margin-left:8.33333333%}.col-xs-offset-0{margin-left:0}@media (min-width:768px){.col-sm-1,.col-sm-10,.col-sm-11,.col-sm-12,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9{float:left}.col-sm-12{width:100%}.col-sm-11{width:91.66666667%}.col-sm-10{width:83.33333333%}.col-sm-9{width:75%}.col-sm-8{width:66.66666667%}.col-sm-7{width:58.33333333%}.col-sm-6{width:50%}.col-sm-5{width:41.66666667%}.col-sm-4{width:33.33333333%}.col-sm-3{width:25%}.col-sm-2{width:16.66666667%}.col-sm-1{width:8.33333333%}.col-sm-pull-12{right:100%}.col-sm-pull-11{right:91.66666667%}.col-sm-pull-10{right:83.33333333%}.col-sm-pull-9{right:75%}.col-sm-pull-8{right:66.66666667%}.col-sm-pull-7{right:58.33333333%}.col-sm-pull-6{right:50%}.col-sm-pull-5{right:41.66666667%}.col-sm-pull-4{right:33.33333333%}.col-sm-pull-3{right:25%}.col-sm-pull-2{right:16.66666667%}.col-sm-pull-1{right:8.33333333%}.col-sm-pull-0{right:auto}.col-sm-push-12{left:100%}.col-sm-push-11{left:91.66666667%}.col-sm-push-10{left:83.33333333%}.col-sm-push-9{left:75%}.col-sm-push-8{left:66.66666667%}.col-sm-push-7{left:58.33333333%}.col-sm-push-6{left:50%}.col-sm-push-5{left:41.66666667%}.col-sm-push-4{left:33.33333333%}.col-sm-push-3{left:25%}.col-sm-push-2{left:16.66666667%}.col-sm-push-1{left:8.33333333%}.col-sm-push-0{left:auto}.col-sm-offset-12{margin-left:100%}.col-sm-offset-11{margin-left:91.66666667%}.col-sm-offset-10{margin-left:83.33333333%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-8{margin-left:66.66666667%}.col-sm-offset-7{margin-left:58.33333333%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-5{margin-left:41.66666667%}.col-sm-offset-4{margin-left:33.33333333%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-2{margin-left:16.66666667%}.col-sm-offset-1{margin-left:8.33333333%}.col-sm-offset-0{margin-left:0}}@media (min-width:992px){.col-md-1,.col-md-10,.col-md-11,.col-md-12,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9{float:left}.col-md-12{width:100%}.col-md-11{width:91.66666667%}.col-md-10{width:83.33333333%}.col-md-9{width:75%}.col-md-8{width:66.66666667%}.col-md-7{width:58.33333333%}.col-md-6{width:50%}.col-md-5{width:41.66666667%}.col-md-4{width:33.33333333%}.col-md-3{width:25%}.col-md-2{width:16.66666667%}.col-md-1{width:8.33333333%}.col-md-pull-12{right:100%}.col-md-pull-11{right:91.66666667%}.col-md-pull-10{right:83.33333333%}.col-md-pull-9{right:75%}.col-md-pull-8{right:66.66666667%}.col-md-pull-7{right:58.33333333%}.col-md-pull-6{right:50%}.col-md-pull-5{right:41.66666667%}.col-md-pull-4{right:33.33333333%}.col-md-pull-3{right:25%}.col-md-pull-2{right:16.66666667%}.col-md-pull-1{right:8.33333333%}.col-md-pull-0{right:auto}.col-md-push-12{left:100%}.col-md-push-11{left:91.66666667%}.col-md-push-10{left:83.33333333%}.col-md-push-9{left:75%}.col-md-push-8{left:66.66666667%}.col-md-push-7{left:58.33333333%}.col-md-push-6{left:50%}.col-md-push-5{left:41.66666667%}.col-md-push-4{left:33.33333333%}.col-md-push-3{left:25%}.col-md-push-2{left:16.66666667%}.col-md-push-1{left:8.33333333%}.col-md-push-0{left:auto}.col-md-offset-12{margin-left:100%}.col-md-offset-11{margin-left:91.66666667%}.col-md-offset-10{margin-left:83.33333333%}.col-md-offset-9{margin-left:75%}.col-md-offset-8{margin-left:66.66666667%}.col-md-offset-7{margin-left:58.33333333%}.col-md-offset-6{margin-left:50%}.col-md-offset-5{margin-left:41.66666667%}.col-md-offset-4{margin-left:33.33333333%}.col-md-offset-3{margin-left:25%}.col-md-offset-2{margin-left:16.66666667%}.col-md-offset-1{margin-left:8.33333333%}.col-md-offset-0{margin-left:0}}@media (min-width:1200px){.col-lg-1,.col-lg-10,.col-lg-11,.col-lg-12,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9{float:left}.col-lg-12{width:100%}.col-lg-11{width:91.66666667%}.col-lg-10{width:83.33333333%}.col-lg-9{width:75%}.col-lg-8{width:66.66666667%}.col-lg-7{width:58.33333333%}.col-lg-6{width:50%}.col-lg-5{width:41.66666667%}.col-lg-4{width:33.33333333%}.col-lg-3{width:25%}.col-lg-2{width:16.66666667%}.col-lg-1{width:8.33333333%}.col-lg-pull-12{right:100%}.col-lg-pull-11{right:91.66666667%}.col-lg-pull-10{right:83.33333333%}.col-lg-pull-9{right:75%}.col-lg-pull-8{right:66.66666667%}.col-lg-pull-7{right:58.33333333%}.col-lg-pull-6{right:50%}.col-lg-pull-5{right:41.66666667%}.col-lg-pull-4{right:33.33333333%}.col-lg-pull-3{right:25%}.col-lg-pull-2{right:16.66666667%}.col-lg-pull-1{right:8.33333333%}.col-lg-pull-0{right:auto}.col-lg-push-12{left:100%}.col-lg-push-11{left:91.66666667%}.col-lg-push-10{left:83.33333333%}.col-lg-push-9{left:75%}.col-lg-push-8{left:66.66666667%}.col-lg-push-7{left:58.33333333%}.col-lg-push-6{left:50%}.col-lg-push-5{left:41.66666667%}.col-lg-push-4{left:33.33333333%}.col-lg-push-3{left:25%}.col-lg-push-2{left:16.66666667%}.col-lg-push-1{left:8.33333333%}.col-lg-push-0{left:auto}.col-lg-offset-12{margin-left:100%}.col-lg-offset-11{margin-left:91.66666667%}.col-lg-offset-10{margin-left:83.33333333%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-8{margin-left:66.66666667%}.col-lg-offset-7{margin-left:58.33333333%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-5{margin-left:41.66666667%}.col-lg-offset-4{margin-left:33.33333333%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-2{margin-left:16.66666667%}.col-lg-offset-1{margin-left:8.33333333%}.col-lg-offset-0{margin-left:0}}table{background-color:transparent}caption{padding-top:8px;padding-bottom:8px;color:#777;text-align:left}th{text-align:left}.table{width:100%;max-width:100%;margin-bottom:20px}.table>tbody>tr>td,.table>tbody>tr>th,.table>tfoot>tr>td,.table>tfoot>tr>th,.table>thead>tr>td,.table>thead>tr>th{padding:8px;line-height:1.42857143;vertical-align:top;border-top:1px solid #ddd}.table>thead>tr>th{vertical-align:bottom;border-bottom:2px solid #ddd}.table>caption+thead>tr:first-child>td,.table>caption+thead>tr:first-child>th,.table>colgroup+thead>tr:first-child>td,.table>colgroup+thead>tr:first-child>th,.table>thead:first-child>tr:first-child>td,.table>thead:first-child>tr:first-child>th{border-top:0}.table>tbody+tbody{border-top:2px solid #ddd}.table .table{background-color:#fff}.table-condensed>tbody>tr>td,.table-condensed>tbody>tr>th,.table-condensed>tfoot>tr>td,.table-condensed>tfoot>tr>th,.table-condensed>thead>tr>td,.table-condensed>thead>tr>th{padding:5px}.table-bordered{border:1px solid #ddd}.table-bordered>tbody>tr>td,.table-bordered>tbody>tr>th,.table-bordered>tfoot>tr>td,.table-bordered>tfoot>tr>th,.table-bordered>thead>tr>td,.table-bordered>thead>tr>th{border:1px solid #ddd}.table-bordered>thead>tr>td,.table-bordered>thead>tr>th{border-bottom-width:2px}.table-striped>tbody>tr:nth-of-type(odd){background-color:#f9f9f9}.table-hover>tbody>tr:hover{background-color:#f5f5f5}table col[class*=col-]{position:static;display:table-column;float:none}table td[class*=col-],table th[class*=col-]{position:static;display:table-cell;float:none}.table>tbody>tr.active>td,.table>tbody>tr.active>th,.table>tbody>tr>td.active,.table>tbody>tr>th.active,.table>tfoot>tr.active>td,.table>tfoot>tr.active>th,.table>tfoot>tr>td.active,.table>tfoot>tr>th.active,.table>thead>tr.active>td,.table>thead>tr.active>th,.table>thead>tr>td.active,.table>thead>tr>th.active{background-color:#f5f5f5}.table-hover>tbody>tr.active:hover>td,.table-hover>tbody>tr.active:hover>th,.table-hover>tbody>tr:hover>.active,.table-hover>tbody>tr>td.active:hover,.table-hover>tbody>tr>th.active:hover{background-color:#e8e8e8}.table>tbody>tr.success>td,.table>tbody>tr.success>th,.table>tbody>tr>td.success,.table>tbody>tr>th.success,.table>tfoot>tr.success>td,.table>tfoot>tr.success>th,.table>tfoot>tr>td.success,.table>tfoot>tr>th.success,.table>thead>tr.success>td,.table>thead>tr.success>th,.table>thead>tr>td.success,.table>thead>tr>th.success{background-color:#dff0d8}.table-hover>tbody>tr.success:hover>td,.table-hover>tbody>tr.success:hover>th,.table-hover>tbody>tr:hover>.success,.table-hover>tbody>tr>td.success:hover,.table-hover>tbody>tr>th.success:hover{background-color:#d0e9c6}.table>tbody>tr.info>td,.table>tbody>tr.info>th,.table>tbody>tr>td.info,.table>tbody>tr>th.info,.table>tfoot>tr.info>td,.table>tfoot>tr.info>th,.table>tfoot>tr>td.info,.table>tfoot>tr>th.info,.table>thead>tr.info>td,.table>thead>tr.info>th,.table>thead>tr>td.info,.table>thead>tr>th.info{background-color:#d9edf7}.table-hover>tbody>tr.info:hover>td,.table-hover>tbody>tr.info:hover>th,.table-hover>tbody>tr:hover>.info,.table-hover>tbody>tr>td.info:hover,.table-hover>tbody>tr>th.info:hover{background-color:#c4e3f3}.table>tbody>tr.warning>td,.table>tbody>tr.warning>th,.table>tbody>tr>td.warning,.table>tbody>tr>th.warning,.table>tfoot>tr.warning>td,.table>tfoot>tr.warning>th,.table>tfoot>tr>td.warning,.table>tfoot>tr>th.warning,.table>thead>tr.warning>td,.table>thead>tr.warning>th,.table>thead>tr>td.warning,.table>thead>tr>th.warning{background-color:#fcf8e3}.table-hover>tbody>tr.warning:hover>td,.table-hover>tbody>tr.warning:hover>th,.table-hover>tbody>tr:hover>.warning,.table-hover>tbody>tr>td.warning:hover,.table-hover>tbody>tr>th.warning:hover{background-color:#faf2cc}.table>tbody>tr.danger>td,.table>tbody>tr.danger>th,.table>tbody>tr>td.danger,.table>tbody>tr>th.danger,.table>tfoot>tr.danger>td,.table>tfoot>tr.danger>th,.table>tfoot>tr>td.danger,.table>tfoot>tr>th.danger,.table>thead>tr.danger>td,.table>thead>tr.danger>th,.table>thead>tr>td.danger,.table>thead>tr>th.danger{background-color:#f2dede}.table-hover>tbody>tr.danger:hover>td,.table-hover>tbody>tr.danger:hover>th,.table-hover>tbody>tr:hover>.danger,.table-hover>tbody>tr>td.danger:hover,.table-hover>tbody>tr>th.danger:hover{background-color:#ebcccc}.table-responsive{min-height:.01%;overflow-x:auto}@media screen and (max-width:767px){.table-responsive{width:100%;margin-bottom:15px;overflow-y:hidden;-ms-overflow-style:-ms-autohiding-scrollbar;border:1px solid #ddd}.table-responsive>.table{margin-bottom:0}.table-responsive>.table>tbody>tr>td,.table-responsive>.table>tbody>tr>th,.table-responsive>.table>tfoot>tr>td,.table-responsive>.table>tfoot>tr>th,.table-responsive>.table>thead>tr>td,.table-responsive>.table>thead>tr>th{white-space:nowrap}.table-responsive>.table-bordered{border:0}.table-responsive>.table-bordered>tbody>tr>td:first-child,.table-responsive>.table-bordered>tbody>tr>th:first-child,.table-responsive>.table-bordered>tfoot>tr>td:first-child,.table-responsive>.table-bordered>tfoot>tr>th:first-child,.table-responsive>.table-bordered>thead>tr>td:first-child,.table-responsive>.table-bordered>thead>tr>th:first-child{border-left:0}.table-responsive>.table-bordered>tbody>tr>td:last-child,.table-responsive>.table-bordered>tbody>tr>th:last-child,.table-responsive>.table-bordered>tfoot>tr>td:last-child,.table-responsive>.table-bordered>tfoot>tr>th:last-child,.table-responsive>.table-bordered>thead>tr>td:last-child,.table-responsive>.table-bordered>thead>tr>th:last-child{border-right:0}.table-responsive>.table-bordered>tbody>tr:last-child>td,.table-responsive>.table-bordered>tbody>tr:last-child>th,.table-responsive>.table-bordered>tfoot>tr:last-child>td,.table-responsive>.table-bordered>tfoot>tr:last-child>th{border-bottom:0}}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:inherit;color:#333;border:0;border-bottom:1px solid #e5e5e5}label{display:inline-block;max-width:100%;margin-bottom:5px;font-weight:700}input[type=search]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input[type=checkbox],input[type=radio]{margin:4px 0 0;margin-top:1px \9;line-height:normal}input[type=file]{display:block}input[type=range]{display:block;width:100%}select[multiple],select[size]{height:auto}input[type=file]:focus,input[type=checkbox]:focus,input[type=radio]:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}output{display:block;padding-top:7px;font-size:14px;line-height:1.42857143;color:#555}.form-control{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.42857143;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075);-webkit-transition:border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;-o-transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.form-control:focus{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.form-control::-moz-placeholder{color:#999;opacity:1}.form-control:-ms-input-placeholder{color:#999}.form-control::-webkit-input-placeholder{color:#999}.form-control[disabled],.form-control[readonly],fieldset[disabled] .form-control{background-color:#eee;opacity:1}.form-control[disabled],fieldset[disabled] .form-control{cursor:not-allowed}textarea.form-control{height:auto}input[type=search]{-webkit-appearance:none}@media screen and (-webkit-min-device-pixel-ratio:0){input[type=date],input[type=time],input[type=datetime-local],input[type=month]{line-height:34px}.input-group-sm input[type=date],.input-group-sm input[type=time],.input-group-sm input[type=datetime-local],.input-group-sm input[type=month],input[type=date].input-sm,input[type=time].input-sm,input[type=datetime-local].input-sm,input[type=month].input-sm{line-height:30px}.input-group-lg input[type=date],.input-group-lg input[type=time],.input-group-lg input[type=datetime-local],.input-group-lg input[type=month],input[type=date].input-lg,input[type=time].input-lg,input[type=datetime-local].input-lg,input[type=month].input-lg{line-height:46px}}.form-group{margin-bottom:15px}.checkbox,.radio{position:relative;display:block;margin-top:10px;margin-bottom:10px}.checkbox label,.radio label{min-height:20px;padding-left:20px;margin-bottom:0;font-weight:400;cursor:pointer}.checkbox input[type=checkbox],.checkbox-inline input[type=checkbox],.radio input[type=radio],.radio-inline input[type=radio]{position:absolute;margin-top:4px \9;margin-left:-20px}.checkbox+.checkbox,.radio+.radio{margin-top:-5px}.checkbox-inline,.radio-inline{position:relative;display:inline-block;padding-left:20px;margin-bottom:0;font-weight:400;vertical-align:middle;cursor:pointer}.checkbox-inline+.checkbox-inline,.radio-inline+.radio-inline{margin-top:0;margin-left:10px}fieldset[disabled] input[type=checkbox],fieldset[disabled] input[type=radio],input[type=checkbox].disabled,input[type=checkbox][disabled],input[type=radio].disabled,input[type=radio][disabled]{cursor:not-allowed}.checkbox-inline.disabled,.radio-inline.disabled,fieldset[disabled] .checkbox-inline,fieldset[disabled] .radio-inline{cursor:not-allowed}.checkbox.disabled label,.radio.disabled label,fieldset[disabled] .checkbox label,fieldset[disabled] .radio label{cursor:not-allowed}.form-control-static{min-height:34px;padding-top:7px;padding-bottom:7px;margin-bottom:0}.form-control-static.input-lg,.form-control-static.input-sm{padding-right:0;padding-left:0}.input-sm{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-sm{height:30px;line-height:30px}select[multiple].input-sm,textarea.input-sm{height:auto}.form-group-sm .form-control{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.form-group-sm .form-control{height:30px;line-height:30px}select[multiple].form-group-sm .form-control,textarea.form-group-sm .form-control{height:auto}.form-group-sm .form-control-static{height:30px;min-height:32px;padding:5px 10px;font-size:12px;line-height:1.5}.input-lg{height:46px;padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}select.input-lg{height:46px;line-height:46px}select[multiple].input-lg,textarea.input-lg{height:auto}.form-group-lg .form-control{height:46px;padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}select.form-group-lg .form-control{height:46px;line-height:46px}select[multiple].form-group-lg .form-control,textarea.form-group-lg .form-control{height:auto}.form-group-lg .form-control-static{height:46px;min-height:38px;padding:10px 16px;font-size:18px;line-height:1.3333333}.has-feedback{position:relative}.has-feedback .form-control{padding-right:42.5px}.form-control-feedback{position:absolute;top:0;right:0;z-index:2;display:block;width:34px;height:34px;line-height:34px;text-align:center;pointer-events:none}.input-lg+.form-control-feedback{width:46px;height:46px;line-height:46px}.input-sm+.form-control-feedback{width:30px;height:30px;line-height:30px}.has-success .checkbox,.has-success .checkbox-inline,.has-success .control-label,.has-success .help-block,.has-success .radio,.has-success .radio-inline,.has-success.checkbox label,.has-success.checkbox-inline label,.has-success.radio label,.has-success.radio-inline label{color:#3c763d}.has-success .form-control{border-color:#3c763d;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.has-success .form-control:focus{border-color:#2b542c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #67b168;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #67b168}.has-success .input-group-addon{color:#3c763d;background-color:#dff0d8;border-color:#3c763d}.has-success .form-control-feedback{color:#3c763d}.has-warning .checkbox,.has-warning .checkbox-inline,.has-warning .control-label,.has-warning .help-block,.has-warning .radio,.has-warning .radio-inline,.has-warning.checkbox label,.has-warning.checkbox-inline label,.has-warning.radio label,.has-warning.radio-inline label{color:#8a6d3b}.has-warning .form-control{border-color:#8a6d3b;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.has-warning .form-control:focus{border-color:#66512c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #c0a16b;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #c0a16b}.has-warning .input-group-addon{color:#8a6d3b;background-color:#fcf8e3;border-color:#8a6d3b}.has-warning .form-control-feedback{color:#8a6d3b}.has-error .checkbox,.has-error .checkbox-inline,.has-error .control-label,.has-error .help-block,.has-error .radio,.has-error .radio-inline,.has-error.checkbox label,.has-error.checkbox-inline label,.has-error.radio label,.has-error.radio-inline label{color:#a94442}.has-error .form-control{border-color:#a94442;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}.has-error .form-control:focus{border-color:#843534;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ce8483;box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ce8483}.has-error .input-group-addon{color:#a94442;background-color:#f2dede;border-color:#a94442}.has-error .form-control-feedback{color:#a94442}.has-feedback label~.form-control-feedback{top:25px}.has-feedback label.sr-only~.form-control-feedback{top:0}.help-block{display:block;margin-top:5px;margin-bottom:10px;color:#737373}@media (min-width:768px){.form-inline .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.form-inline .form-control{display:inline-block;width:auto;vertical-align:middle}.form-inline .form-control-static{display:inline-block}.form-inline .input-group{display:inline-table;vertical-align:middle}.form-inline .input-group .form-control,.form-inline .input-group .input-group-addon,.form-inline .input-group .input-group-btn{width:auto}.form-inline .input-group>.form-control{width:100%}.form-inline .control-label{margin-bottom:0;vertical-align:middle}.form-inline .checkbox,.form-inline .radio{display:inline-block;margin-top:0;margin-bottom:0;vertical-align:middle}.form-inline .checkbox label,.form-inline .radio label{padding-left:0}.form-inline .checkbox input[type=checkbox],.form-inline .radio input[type=radio]{position:relative;margin-left:0}.form-inline .has-feedback .form-control-feedback{top:0}}.form-horizontal .checkbox,.form-horizontal .checkbox-inline,.form-horizontal .radio,.form-horizontal .radio-inline{padding-top:7px;margin-top:0;margin-bottom:0}.form-horizontal .checkbox,.form-horizontal .radio{min-height:27px}.form-horizontal .form-group{margin-right:-15px;margin-left:-15px}@media (min-width:768px){.form-horizontal .control-label{padding-top:7px;margin-bottom:0;text-align:right}}.form-horizontal .has-feedback .form-control-feedback{right:15px}@media (min-width:768px){.form-horizontal .form-group-lg .control-label{padding-top:14.33px}}@media (min-width:768px){.form-horizontal .form-group-sm .control-label{padding-top:6px}}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:4px}.btn.active.focus,.btn.active:focus,.btn.focus,.btn:active.focus,.btn:active:focus,.btn:focus{outline:thin dotted;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.focus,.btn:focus,.btn:hover{color:#333;text-decoration:none}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.125);box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.btn.disabled,.btn[disabled],fieldset[disabled] .btn{pointer-events:none;cursor:not-allowed;filter:alpha(opacity=65);-webkit-box-shadow:none;box-shadow:none;opacity:.65}.btn-default{color:#333;background-color:#fff;border-color:#ccc}.btn-default.active,.btn-default.focus,.btn-default:active,.btn-default:focus,.btn-default:hover,.open>.dropdown-toggle.btn-default{color:#333;background-color:#e6e6e6;border-color:#adadad}.btn-default.active,.btn-default:active,.open>.dropdown-toggle.btn-default{background-image:none}.btn-default.disabled,.btn-default.disabled.active,.btn-default.disabled.focus,.btn-default.disabled:active,.btn-default.disabled:focus,.btn-default.disabled:hover,.btn-default[disabled],.btn-default[disabled].active,.btn-default[disabled].focus,.btn-default[disabled]:active,.btn-default[disabled]:focus,.btn-default[disabled]:hover,fieldset[disabled] .btn-default,fieldset[disabled] .btn-default.active,fieldset[disabled] .btn-default.focus,fieldset[disabled] .btn-default:active,fieldset[disabled] .btn-default:focus,fieldset[disabled] .btn-default:hover{background-color:#fff;border-color:#ccc}.btn-default .badge{color:#fff;background-color:#333}.btn-primary{color:#fff;background-color:#337ab7;border-color:#2e6da4}.btn-primary.active,.btn-primary.focus,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.open>.dropdown-toggle.btn-primary{color:#fff;background-color:#286090;border-color:#204d74}.btn-primary.active,.btn-primary:active,.open>.dropdown-toggle.btn-primary{background-image:none}.btn-primary.disabled,.btn-primary.disabled.active,.btn-primary.disabled.focus,.btn-primary.disabled:active,.btn-primary.disabled:focus,.btn-primary.disabled:hover,.btn-primary[disabled],.btn-primary[disabled].active,.btn-primary[disabled].focus,.btn-primary[disabled]:active,.btn-primary[disabled]:focus,.btn-primary[disabled]:hover,fieldset[disabled] .btn-primary,fieldset[disabled] .btn-primary.active,fieldset[disabled] .btn-primary.focus,fieldset[disabled] .btn-primary:active,fieldset[disabled] .btn-primary:focus,fieldset[disabled] .btn-primary:hover{background-color:#337ab7;border-color:#2e6da4}.btn-primary .badge{color:#337ab7;background-color:#fff}.btn-success{color:#fff;background-color:#5cb85c;border-color:#4cae4c}.btn-success.active,.btn-success.focus,.btn-success:active,.btn-success:focus,.btn-success:hover,.open>.dropdown-toggle.btn-success{color:#fff;background-color:#449d44;border-color:#398439}.btn-success.active,.btn-success:active,.open>.dropdown-toggle.btn-success{background-image:none}.btn-success.disabled,.btn-success.disabled.active,.btn-success.disabled.focus,.btn-success.disabled:active,.btn-success.disabled:focus,.btn-success.disabled:hover,.btn-success[disabled],.btn-success[disabled].active,.btn-success[disabled].focus,.btn-success[disabled]:active,.btn-success[disabled]:focus,.btn-success[disabled]:hover,fieldset[disabled] .btn-success,fieldset[disabled] .btn-success.active,fieldset[disabled] .btn-success.focus,fieldset[disabled] .btn-success:active,fieldset[disabled] .btn-success:focus,fieldset[disabled] .btn-success:hover{background-color:#5cb85c;border-color:#4cae4c}.btn-success .badge{color:#5cb85c;background-color:#fff}.btn-info{color:#fff;background-color:#5bc0de;border-color:#46b8da}.btn-info.active,.btn-info.focus,.btn-info:active,.btn-info:focus,.btn-info:hover,.open>.dropdown-toggle.btn-info{color:#fff;background-color:#31b0d5;border-color:#269abc}.btn-info.active,.btn-info:active,.open>.dropdown-toggle.btn-info{background-image:none}.btn-info.disabled,.btn-info.disabled.active,.btn-info.disabled.focus,.btn-info.disabled:active,.btn-info.disabled:focus,.btn-info.disabled:hover,.btn-info[disabled],.btn-info[disabled].active,.btn-info[disabled].focus,.btn-info[disabled]:active,.btn-info[disabled]:focus,.btn-info[disabled]:hover,fieldset[disabled] .btn-info,fieldset[disabled] .btn-info.active,fieldset[disabled] .btn-info.focus,fieldset[disabled] .btn-info:active,fieldset[disabled] .btn-info:focus,fieldset[disabled] .btn-info:hover{background-color:#5bc0de;border-color:#46b8da}.btn-info .badge{color:#5bc0de;background-color:#fff}.btn-warning{color:#fff;background-color:#f0ad4e;border-color:#eea236}.btn-warning.active,.btn-warning.focus,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.open>.dropdown-toggle.btn-warning{color:#fff;background-color:#ec971f;border-color:#d58512}.btn-warning.active,.btn-warning:active,.open>.dropdown-toggle.btn-warning{background-image:none}.btn-warning.disabled,.btn-warning.disabled.active,.btn-warning.disabled.focus,.btn-warning.disabled:active,.btn-warning.disabled:focus,.btn-warning.disabled:hover,.btn-warning[disabled],.btn-warning[disabled].active,.btn-warning[disabled].focus,.btn-warning[disabled]:active,.btn-warning[disabled]:focus,.btn-warning[disabled]:hover,fieldset[disabled] .btn-warning,fieldset[disabled] .btn-warning.active,fieldset[disabled] .btn-warning.focus,fieldset[disabled] .btn-warning:active,fieldset[disabled] .btn-warning:focus,fieldset[disabled] .btn-warning:hover{background-color:#f0ad4e;border-color:#eea236}.btn-warning .badge{color:#f0ad4e;background-color:#fff}.btn-danger{color:#fff;background-color:#d9534f;border-color:#d43f3a}.btn-danger.active,.btn-danger.focus,.btn-danger:active,.btn-danger:focus,.btn-danger:hover,.open>.dropdown-toggle.btn-danger{color:#fff;background-color:#c9302c;border-color:#ac2925}.btn-danger.active,.btn-danger:active,.open>.dropdown-toggle.btn-danger{background-image:none}.btn-danger.disabled,.btn-danger.disabled.active,.btn-danger.disabled.focus,.btn-danger.disabled:active,.btn-danger.disabled:focus,.btn-danger.disabled:hover,.btn-danger[disabled],.btn-danger[disabled].active,.btn-danger[disabled].focus,.btn-danger[disabled]:active,.btn-danger[disabled]:focus,.btn-danger[disabled]:hover,fieldset[disabled] .btn-danger,fieldset[disabled] .btn-danger.active,fieldset[disabled] .btn-danger.focus,fieldset[disabled] .btn-danger:active,fieldset[disabled] .btn-danger:focus,fieldset[disabled] .btn-danger:hover{background-color:#d9534f;border-color:#d43f3a}.btn-danger .badge{color:#d9534f;background-color:#fff}.btn-link{font-weight:400;color:#337ab7;border-radius:0}.btn-link,.btn-link.active,.btn-link:active,.btn-link[disabled],fieldset[disabled] .btn-link{background-color:transparent;-webkit-box-shadow:none;box-shadow:none}.btn-link,.btn-link:active,.btn-link:focus,.btn-link:hover{border-color:transparent}.btn-link:focus,.btn-link:hover{color:#23527c;text-decoration:underline;background-color:transparent}.btn-link[disabled]:focus,.btn-link[disabled]:hover,fieldset[disabled] .btn-link:focus,fieldset[disabled] .btn-link:hover{color:#777;text-decoration:none}.btn-group-lg>.btn,.btn-lg{padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}.btn-group-sm>.btn,.btn-sm{padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}.btn-group-xs>.btn,.btn-xs{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.btn-block{display:block;width:100%}.btn-block+.btn-block{margin-top:5px}input[type=button].btn-block,input[type=reset].btn-block,input[type=submit].btn-block{width:100%}.fade{opacity:0;-webkit-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{display:none}.collapse.in{display:block}tr.collapse.in{display:table-row}tbody.collapse.in{display:table-row-group}.collapsing{position:relative;height:0;overflow:hidden;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease;-webkit-transition-duration:.35s;-o-transition-duration:.35s;transition-duration:.35s;-webkit-transition-property:height,visibility;-o-transition-property:height,visibility;transition-property:height,visibility}.caret{display:inline-block;width:0;height:0;margin-left:2px;vertical-align:middle;border-top:4px dashed;border-right:4px solid transparent;border-left:4px solid transparent}.dropdown,.dropup{position:relative}.dropdown-toggle:focus{outline:0}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;font-size:14px;text-align:left;list-style:none;background-color:#fff;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #ccc;border:1px solid rgba(0,0,0,.15);border-radius:4px;-webkit-box-shadow:0 6px 12px rgba(0,0,0,.175);box-shadow:0 6px 12px rgba(0,0,0,.175)}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:400;line-height:1.42857143;color:#333;white-space:nowrap}.dropdown-menu>li>a:focus,.dropdown-menu>li>a:hover{color:#262626;text-decoration:none;background-color:#f5f5f5}.dropdown-menu>.active>a,.dropdown-menu>.active>a:focus,.dropdown-menu>.active>a:hover{color:#fff;text-decoration:none;background-color:#337ab7;outline:0}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:focus,.dropdown-menu>.disabled>a:hover{color:#777}.dropdown-menu>.disabled>a:focus,.dropdown-menu>.disabled>a:hover{text-decoration:none;cursor:not-allowed;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-menu-right{right:0;left:auto}.dropdown-menu-left{right:auto;left:0}.dropdown-header{display:block;padding:3px 20px;font-size:12px;line-height:1.42857143;color:#777;white-space:nowrap}.dropdown-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:990}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{content:"";border-top:0;border-bottom:4px solid}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:2px}@media (min-width:768px){.navbar-right .dropdown-menu{right:0;left:auto}.navbar-right .dropdown-menu-left{right:auto;left:0}}.btn-group,.btn-group-vertical{position:relative;display:inline-block;vertical-align:middle}.btn-group-vertical>.btn,.btn-group>.btn{position:relative;float:left}.btn-group-vertical>.btn.active,.btn-group-vertical>.btn:active,.btn-group-vertical>.btn:focus,.btn-group-vertical>.btn:hover,.btn-group>.btn.active,.btn-group>.btn:active,.btn-group>.btn:focus,.btn-group>.btn:hover{z-index:2}.btn-group .btn+.btn,.btn-group .btn+.btn-group,.btn-group .btn-group+.btn,.btn-group .btn-group+.btn-group{margin-left:-1px}.btn-toolbar{margin-left:-5px}.btn-toolbar .btn-group,.btn-toolbar .input-group{float:left}.btn-toolbar>.btn,.btn-toolbar>.btn-group,.btn-toolbar>.input-group{margin-left:5px}.btn-group>.btn:not(:first-child):not(:last-child):not(.dropdown-toggle){border-radius:0}.btn-group>.btn:first-child{margin-left:0}.btn-group>.btn:first-child:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn:last-child:not(:first-child),.btn-group>.dropdown-toggle:not(:first-child){border-top-left-radius:0;border-bottom-left-radius:0}.btn-group>.btn-group{float:left}.btn-group>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group>.btn-group:first-child:not(:last-child)>.btn:last-child,.btn-group>.btn-group:first-child:not(:last-child)>.dropdown-toggle{border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn-group:last-child:not(:first-child)>.btn:first-child{border-top-left-radius:0;border-bottom-left-radius:0}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group>.btn+.dropdown-toggle{padding-right:8px;padding-left:8px}.btn-group>.btn-lg+.dropdown-toggle{padding-right:12px;padding-left:12px}.btn-group.open .dropdown-toggle{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.125);box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.btn-group.open .dropdown-toggle.btn-link{-webkit-box-shadow:none;box-shadow:none}.btn .caret{margin-left:0}.btn-lg .caret{border-width:5px 5px 0;border-bottom-width:0}.dropup .btn-lg .caret{border-width:0 5px 5px}.btn-group-vertical>.btn,.btn-group-vertical>.btn-group,.btn-group-vertical>.btn-group>.btn{display:block;float:none;width:100%;max-width:100%}.btn-group-vertical>.btn-group>.btn{float:none}.btn-group-vertical>.btn+.btn,.btn-group-vertical>.btn+.btn-group,.btn-group-vertical>.btn-group+.btn,.btn-group-vertical>.btn-group+.btn-group{margin-top:-1px;margin-left:0}.btn-group-vertical>.btn:not(:first-child):not(:last-child){border-radius:0}.btn-group-vertical>.btn:first-child:not(:last-child){border-top-right-radius:4px;border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn:last-child:not(:first-child){border-top-left-radius:0;border-top-right-radius:0;border-bottom-left-radius:4px}.btn-group-vertical>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group-vertical>.btn-group:first-child:not(:last-child)>.btn:last-child,.btn-group-vertical>.btn-group:first-child:not(:last-child)>.dropdown-toggle{border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn-group:last-child:not(:first-child)>.btn:first-child{border-top-left-radius:0;border-top-right-radius:0}.btn-group-justified{display:table;width:100%;table-layout:fixed;border-collapse:separate}.btn-group-justified>.btn,.btn-group-justified>.btn-group{display:table-cell;float:none;width:1%}.btn-group-justified>.btn-group .btn{width:100%}.btn-group-justified>.btn-group .dropdown-menu{left:auto}[data-toggle=buttons]>.btn input[type=checkbox],[data-toggle=buttons]>.btn input[type=radio],[data-toggle=buttons]>.btn-group>.btn input[type=checkbox],[data-toggle=buttons]>.btn-group>.btn input[type=radio]{position:absolute;clip:rect(0,0,0,0);pointer-events:none}.input-group{position:relative;display:table;border-collapse:separate}.input-group[class*=col-]{float:none;padding-right:0;padding-left:0}.input-group .form-control{position:relative;z-index:2;float:left;width:100%;margin-bottom:0}.input-group-lg>.form-control,.input-group-lg>.input-group-addon,.input-group-lg>.input-group-btn>.btn{height:46px;padding:10px 16px;font-size:18px;line-height:1.3333333;border-radius:6px}select.input-group-lg>.form-control,select.input-group-lg>.input-group-addon,select.input-group-lg>.input-group-btn>.btn{height:46px;line-height:46px}select[multiple].input-group-lg>.form-control,select[multiple].input-group-lg>.input-group-addon,select[multiple].input-group-lg>.input-group-btn>.btn,textarea.input-group-lg>.form-control,textarea.input-group-lg>.input-group-addon,textarea.input-group-lg>.input-group-btn>.btn{height:auto}.input-group-sm>.form-control,.input-group-sm>.input-group-addon,.input-group-sm>.input-group-btn>.btn{height:30px;padding:5px 10px;font-size:12px;line-height:1.5;border-radius:3px}select.input-group-sm>.form-control,select.input-group-sm>.input-group-addon,select.input-group-sm>.input-group-btn>.btn{height:30px;line-height:30px}select[multiple].input-group-sm>.form-control,select[multiple].input-group-sm>.input-group-addon,select[multiple].input-group-sm>.input-group-btn>.btn,textarea.input-group-sm>.form-control,textarea.input-group-sm>.input-group-addon,textarea.input-group-sm>.input-group-btn>.btn{height:auto}.input-group .form-control,.input-group-addon,.input-group-btn{display:table-cell}.input-group .form-control:not(:first-child):not(:last-child),.input-group-addon:not(:first-child):not(:last-child),.input-group-btn:not(:first-child):not(:last-child){border-radius:0}.input-group-addon,.input-group-btn{width:1%;white-space:nowrap;vertical-align:middle}.input-group-addon{padding:6px 12px;font-size:14px;font-weight:400;line-height:1;color:#555;text-align:center;background-color:#eee;border:1px solid #ccc;border-radius:4px}.input-group-addon.input-sm{padding:5px 10px;font-size:12px;border-radius:3px}.input-group-addon.input-lg{padding:10px 16px;font-size:18px;border-radius:6px}.input-group-addon input[type=checkbox],.input-group-addon input[type=radio]{margin-top:0}.input-group .form-control:first-child,.input-group-addon:first-child,.input-group-btn:first-child>.btn,.input-group-btn:first-child>.btn-group>.btn,.input-group-btn:first-child>.dropdown-toggle,.input-group-btn:last-child>.btn-group:not(:last-child)>.btn,.input-group-btn:last-child>.btn:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.input-group-addon:first-child{border-right:0}.input-group .form-control:last-child,.input-group-addon:last-child,.input-group-btn:first-child>.btn-group:not(:first-child)>.btn,.input-group-btn:first-child>.btn:not(:first-child),.input-group-btn:last-child>.btn,.input-group-btn:last-child>.btn-group>.btn,.input-group-btn:last-child>.dropdown-toggle{border-top-left-radius:0;border-bottom-left-radius:0}.input-group-addon:last-child{border-left:0}.input-group-btn{position:relative;font-size:0;white-space:nowrap}.input-group-btn>.btn{position:relative}.input-group-btn>.btn+.btn{margin-left:-1px}.input-group-btn>.btn:active,.input-group-btn>.btn:focus,.input-group-btn>.btn:hover{z-index:2}.input-group-btn:first-child>.btn,.input-group-btn:first-child>.btn-group{margin-right:-1px}.input-group-btn:last-child>.btn,.input-group-btn:last-child>.btn-group{margin-left:-1px}.nav{padding-left:0;margin-bottom:0;list-style:none}.nav>li{position:relative;display:block}.nav>li>a{position:relative;display:block;padding:10px 15px}.nav>li>a:focus,.nav>li>a:hover{text-decoration:none;background-color:#eee}.nav>li.disabled>a{color:#777}.nav>li.disabled>a:focus,.nav>li.disabled>a:hover{color:#777;text-decoration:none;cursor:not-allowed;background-color:transparent}.nav .open>a,.nav .open>a:focus,.nav .open>a:hover{background-color:#eee;border-color:#337ab7}.nav .nav-divider{height:1px;margin:9px 0;overflow:hidden;background-color:#e5e5e5}.nav>li>a>img{max-width:none}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{float:left;margin-bottom:-1px}.nav-tabs>li>a{margin-right:2px;line-height:1.42857143;border:1px solid transparent;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover{border-color:#eee #eee #ddd}.nav-tabs>li.active>a,.nav-tabs>li.active>a:focus,.nav-tabs>li.active>a:hover{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-tabs.nav-justified{width:100%;border-bottom:0}.nav-tabs.nav-justified>li{float:none}.nav-tabs.nav-justified>li>a{margin-bottom:5px;text-align:center}.nav-tabs.nav-justified>.dropdown .dropdown-menu{top:auto;left:auto}@media (min-width:768px){.nav-tabs.nav-justified>li{display:table-cell;width:1%}.nav-tabs.nav-justified>li>a{margin-bottom:0}}.nav-tabs.nav-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:focus,.nav-tabs.nav-justified>.active>a:hover{border:1px solid #ddd}@media (min-width:768px){.nav-tabs.nav-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs.nav-justified>.active>a,.nav-tabs.nav-justified>.active>a:focus,.nav-tabs.nav-justified>.active>a:hover{border-bottom-color:#fff}}.nav-pills>li{float:left}.nav-pills>li>a{border-radius:4px}.nav-pills>li+li{margin-left:2px}.nav-pills>li.active>a,.nav-pills>li.active>a:focus,.nav-pills>li.active>a:hover{color:#fff;background-color:#337ab7}.nav-stacked>li{float:none}.nav-stacked>li+li{margin-top:2px;margin-left:0}.nav-justified{width:100%}.nav-justified>li{float:none}.nav-justified>li>a{margin-bottom:5px;text-align:center}.nav-justified>.dropdown .dropdown-menu{top:auto;left:auto}@media (min-width:768px){.nav-justified>li{display:table-cell;width:1%}.nav-justified>li>a{margin-bottom:0}}.nav-tabs-justified{border-bottom:0}.nav-tabs-justified>li>a{margin-right:0;border-radius:4px}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:focus,.nav-tabs-justified>.active>a:hover{border:1px solid #ddd}@media (min-width:768px){.nav-tabs-justified>li>a{border-bottom:1px solid #ddd;border-radius:4px 4px 0 0}.nav-tabs-justified>.active>a,.nav-tabs-justified>.active>a:focus,.nav-tabs-justified>.active>a:hover{border-bottom-color:#fff}}.tab-content>.tab-pane{display:none}.tab-content>.active{display:block}.nav-tabs .dropdown-menu{margin-top:-1px;border-top-left-radius:0;border-top-right-radius:0}.navbar{position:relative;min-height:50px;margin-bottom:20px;border:1px solid transparent}@media (min-width:768px){.navbar{border-radius:4px}}@media (min-width:768px){.navbar-header{float:left}}.navbar-collapse{padding-right:15px;padding-left:15px;overflow-x:visible;-webkit-overflow-scrolling:touch;border-top:1px solid transparent;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.1);box-shadow:inset 0 1px 0 rgba(255,255,255,.1)}.navbar-collapse.in{overflow-y:auto}@media (min-width:768px){.navbar-collapse{width:auto;border-top:0;-webkit-box-shadow:none;box-shadow:none}.navbar-collapse.collapse{display:block!important;height:auto!important;padding-bottom:0;overflow:visible!important}.navbar-collapse.in{overflow-y:visible}.navbar-fixed-bottom .navbar-collapse,.navbar-fixed-top .navbar-collapse,.navbar-static-top .navbar-collapse{padding-right:0;padding-left:0}}.navbar-fixed-bottom .navbar-collapse,.navbar-fixed-top .navbar-collapse{max-height:340px}@media (max-device-width:480px)and (orientation:landscape){.navbar-fixed-bottom .navbar-collapse,.navbar-fixed-top .navbar-collapse{max-height:200px}}.container-fluid>.navbar-collapse,.container-fluid>.navbar-header,.container>.navbar-collapse,.container>.navbar-header{margin-right:-15px;margin-left:-15px}@media (min-width:768px){.container-fluid>.navbar-collapse,.container-fluid>.navbar-header,.container>.navbar-collapse,.container>.navbar-header{margin-right:0;margin-left:0}}.navbar-static-top{z-index:1000;border-width:0 0 1px}@media (min-width:768px){.navbar-static-top{border-radius:0}}.navbar-fixed-bottom,.navbar-fixed-top{position:fixed;right:0;left:0;z-index:1030}@media (min-width:768px){.navbar-fixed-bottom,.navbar-fixed-top{border-radius:0}}.navbar-fixed-top{top:0;border-width:0 0 1px}.navbar-fixed-bottom{bottom:0;margin-bottom:0;border-width:1px 0 0}.navbar-brand{float:left;height:50px;padding:15px 15px;font-size:18px;line-height:20px}.navbar-brand:focus,.navbar-brand:hover{text-decoration:none}.navbar-brand>img{display:block}@media (min-width:768px){.navbar>.container .navbar-brand,.navbar>.container-fluid .navbar-brand{margin-left:-15px}}.navbar-toggle{position:relative;float:right;padding:9px 10px;margin-top:8px;margin-right:15px;margin-bottom:8px;background-color:transparent;background-image:none;border:1px solid transparent;border-radius:4px}.navbar-toggle:focus{outline:0}.navbar-toggle .icon-bar{display:block;width:22px;height:2px;border-radius:1px}.navbar-toggle .icon-bar+.icon-bar{margin-top:4px}@media (min-width:768px){.navbar-toggle{display:none}}.navbar-nav{margin:7.5px -15px}.navbar-nav>li>a{padding-top:10px;padding-bottom:10px;line-height:20px}@media (max-width:767px){.navbar-nav .open .dropdown-menu{position:static;float:none;width:auto;margin-top:0;background-color:transparent;border:0;-webkit-box-shadow:none;box-shadow:none}.navbar-nav .open .dropdown-menu .dropdown-header,.navbar-nav .open .dropdown-menu>li>a{padding:5px 15px 5px 25px}.navbar-nav .open .dropdown-menu>li>a{line-height:20px}.navbar-nav .open .dropdown-menu>li>a:focus,.navbar-nav .open .dropdown-menu>li>a:hover{background-image:none}}@media (min-width:768px){.navbar-nav{float:left;margin:0}.navbar-nav>li{float:left}.navbar-nav>li>a{padding-top:15px;padding-bottom:15px}}.navbar-form{padding:10px 15px;margin-top:8px;margin-right:-15px;margin-bottom:8px;margin-left:-15px;border-top:1px solid transparent;border-bottom:1px solid transparent;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.1),0 1px 0 rgba(255,255,255,.1);box-shadow:inset 0 1px 0 rgba(255,255,255,.1),0 1px 0 rgba(255,255,255,.1)}@media (min-width:768px){.navbar-form .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.navbar-form .form-control{display:inline-block;width:auto;vertical-align:middle}.navbar-form .form-control-static{display:inline-block}.navbar-form .input-group{display:inline-table;vertical-align:middle}.navbar-form .input-group .form-control,.navbar-form .input-group .input-group-addon,.navbar-form .input-group .input-group-btn{width:auto}.navbar-form .input-group>.form-control{width:100%}.navbar-form .control-label{margin-bottom:0;vertical-align:middle}.navbar-form .checkbox,.navbar-form .radio{display:inline-block;margin-top:0;margin-bottom:0;vertical-align:middle}.navbar-form .checkbox label,.navbar-form .radio label{padding-left:0}.navbar-form .checkbox input[type=checkbox],.navbar-form .radio input[type=radio]{position:relative;margin-left:0}.navbar-form .has-feedback .form-control-feedback{top:0}}@media (max-width:767px){.navbar-form .form-group{margin-bottom:5px}.navbar-form .form-group:last-child{margin-bottom:0}}@media (min-width:768px){.navbar-form{width:auto;padding-top:0;padding-bottom:0;margin-right:0;margin-left:0;border:0;-webkit-box-shadow:none;box-shadow:none}}.navbar-nav>li>.dropdown-menu{margin-top:0;border-top-left-radius:0;border-top-right-radius:0}.navbar-fixed-bottom .navbar-nav>li>.dropdown-menu{margin-bottom:0;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom-right-radius:0;border-bottom-left-radius:0}.navbar-btn{margin-top:8px;margin-bottom:8px}.navbar-btn.btn-sm{margin-top:10px;margin-bottom:10px}.navbar-btn.btn-xs{margin-top:14px;margin-bottom:14px}.navbar-text{margin-top:15px;margin-bottom:15px}@media (min-width:768px){.navbar-text{float:left;margin-right:15px;margin-left:15px}}@media (min-width:768px){.navbar-left{float:left!important}.navbar-right{float:right!important;margin-right:-15px}.navbar-right~.navbar-right{margin-right:0}}.navbar-default{background-color:#f8f8f8;border-color:#e7e7e7}.navbar-default .navbar-brand{color:#777}.navbar-default .navbar-brand:focus,.navbar-default .navbar-brand:hover{color:#5e5e5e;background-color:transparent}.navbar-default .navbar-text{color:#777}.navbar-default .navbar-nav>li>a{color:#777}.navbar-default .navbar-nav>li>a:focus,.navbar-default .navbar-nav>li>a:hover{color:#333;background-color:transparent}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.active>a:focus,.navbar-default .navbar-nav>.active>a:hover{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav>.disabled>a,.navbar-default .navbar-nav>.disabled>a:focus,.navbar-default .navbar-nav>.disabled>a:hover{color:#ccc;background-color:transparent}.navbar-default .navbar-toggle{border-color:#ddd}.navbar-default .navbar-toggle:focus,.navbar-default .navbar-toggle:hover{background-color:#ddd}.navbar-default .navbar-toggle .icon-bar{background-color:#888}.navbar-default .navbar-collapse,.navbar-default .navbar-form{border-color:#e7e7e7}.navbar-default .navbar-nav>.open>a,.navbar-default .navbar-nav>.open>a:focus,.navbar-default .navbar-nav>.open>a:hover{color:#555;background-color:#e7e7e7}@media (max-width:767px){.navbar-default .navbar-nav .open .dropdown-menu>li>a{color:#777}.navbar-default .navbar-nav .open .dropdown-menu>li>a:focus,.navbar-default .navbar-nav .open .dropdown-menu>li>a:hover{color:#333;background-color:transparent}.navbar-default .navbar-nav .open .dropdown-menu>.active>a,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:focus,.navbar-default .navbar-nav .open .dropdown-menu>.active>a:hover{color:#555;background-color:#e7e7e7}.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:focus,.navbar-default .navbar-nav .open .dropdown-menu>.disabled>a:hover{color:#ccc;background-color:transparent}}.navbar-default .navbar-link{color:#777}.navbar-default .navbar-link:hover{color:#333}.navbar-default .btn-link{color:#777}.navbar-default .btn-link:focus,.navbar-default .btn-link:hover{color:#333}.navbar-default .btn-link[disabled]:focus,.navbar-default .btn-link[disabled]:hover,fieldset[disabled] .navbar-default .btn-link:focus,fieldset[disabled] .navbar-default .btn-link:hover{color:#ccc}.navbar-inverse{background-color:#222;border-color:#080808}.navbar-inverse .navbar-brand{color:#9d9d9d}.navbar-inverse .navbar-brand:focus,.navbar-inverse .navbar-brand:hover{color:#fff;background-color:transparent}.navbar-inverse .navbar-text{color:#9d9d9d}.navbar-inverse .navbar-nav>li>a{color:#9d9d9d}.navbar-inverse .navbar-nav>li>a:focus,.navbar-inverse .navbar-nav>li>a:hover{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.active>a:focus,.navbar-inverse .navbar-nav>.active>a:hover{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav>.disabled>a,.navbar-inverse .navbar-nav>.disabled>a:focus,.navbar-inverse .navbar-nav>.disabled>a:hover{color:#444;background-color:transparent}.navbar-inverse .navbar-toggle{border-color:#333}.navbar-inverse .navbar-toggle:focus,.navbar-inverse .navbar-toggle:hover{background-color:#333}.navbar-inverse .navbar-toggle .icon-bar{background-color:#fff}.navbar-inverse .navbar-collapse,.navbar-inverse .navbar-form{border-color:#101010}.navbar-inverse .navbar-nav>.open>a,.navbar-inverse .navbar-nav>.open>a:focus,.navbar-inverse .navbar-nav>.open>a:hover{color:#fff;background-color:#080808}@media (max-width:767px){.navbar-inverse .navbar-nav .open .dropdown-menu>.dropdown-header{border-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu .divider{background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a{color:#9d9d9d}.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:focus,.navbar-inverse .navbar-nav .open .dropdown-menu>li>a:hover{color:#fff;background-color:transparent}.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:focus,.navbar-inverse .navbar-nav .open .dropdown-menu>.active>a:hover{color:#fff;background-color:#080808}.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:focus,.navbar-inverse .navbar-nav .open .dropdown-menu>.disabled>a:hover{color:#444;background-color:transparent}}.navbar-inverse .navbar-link{color:#9d9d9d}.navbar-inverse .navbar-link:hover{color:#fff}.navbar-inverse .btn-link{color:#9d9d9d}.navbar-inverse .btn-link:focus,.navbar-inverse .btn-link:hover{color:#fff}.navbar-inverse .btn-link[disabled]:focus,.navbar-inverse .btn-link[disabled]:hover,fieldset[disabled] .navbar-inverse .btn-link:focus,fieldset[disabled] .navbar-inverse .btn-link:hover{color:#444}.breadcrumb{padding:8px 15px;margin-bottom:20px;list-style:none;background-color:#f5f5f5;border-radius:4px}.breadcrumb>li{display:inline-block}.breadcrumb>li+li:before{padding:0 5px;color:#ccc;content:"/\00a0"}.breadcrumb>.active{color:#777}.pagination{display:inline-block;padding-left:0;margin:20px 0;border-radius:4px}.pagination>li{display:inline}.pagination>li>a,.pagination>li>span{position:relative;float:left;padding:6px 12px;margin-left:-1px;line-height:1.42857143;color:#337ab7;text-decoration:none;background-color:#fff;border:1px solid #ddd}.pagination>li:first-child>a,.pagination>li:first-child>span{margin-left:0;border-top-left-radius:4px;border-bottom-left-radius:4px}.pagination>li:last-child>a,.pagination>li:last-child>span{border-top-right-radius:4px;border-bottom-right-radius:4px}.pagination>li>a:focus,.pagination>li>a:hover,.pagination>li>span:focus,.pagination>li>span:hover{color:#23527c;background-color:#eee;border-color:#ddd}.pagination>.active>a,.pagination>.active>a:focus,.pagination>.active>a:hover,.pagination>.active>span,.pagination>.active>span:focus,.pagination>.active>span:hover{z-index:2;color:#fff;cursor:default;background-color:#337ab7;border-color:#337ab7}.pagination>.disabled>a,.pagination>.disabled>a:focus,.pagination>.disabled>a:hover,.pagination>.disabled>span,.pagination>.disabled>span:focus,.pagination>.disabled>span:hover{color:#777;cursor:not-allowed;background-color:#fff;border-color:#ddd}.pagination-lg>li>a,.pagination-lg>li>span{padding:10px 16px;font-size:18px}.pagination-lg>li:first-child>a,.pagination-lg>li:first-child>span{border-top-left-radius:6px;border-bottom-left-radius:6px}.pagination-lg>li:last-child>a,.pagination-lg>li:last-child>span{border-top-right-radius:6px;border-bottom-right-radius:6px}.pagination-sm>li>a,.pagination-sm>li>span{padding:5px 10px;font-size:12px}.pagination-sm>li:first-child>a,.pagination-sm>li:first-child>span{border-top-left-radius:3px;border-bottom-left-radius:3px}.pagination-sm>li:last-child>a,.pagination-sm>li:last-child>span{border-top-right-radius:3px;border-bottom-right-radius:3px}.pager{padding-left:0;margin:20px 0;text-align:center;list-style:none}.pager li{display:inline}.pager li>a,.pager li>span{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;border-radius:15px}.pager li>a:focus,.pager li>a:hover{text-decoration:none;background-color:#eee}.pager .next>a,.pager .next>span{float:right}.pager .previous>a,.pager .previous>span{float:left}.pager .disabled>a,.pager .disabled>a:focus,.pager .disabled>a:hover,.pager .disabled>span{color:#777;cursor:not-allowed;background-color:#fff}.label{display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em}a.label:focus,a.label:hover{color:#fff;text-decoration:none;cursor:pointer}.label:empty{display:none}.btn .label{position:relative;top:-1px}.label-default{background-color:#777}.label-default[href]:focus,.label-default[href]:hover{background-color:#5e5e5e}.label-primary{background-color:#337ab7}.label-primary[href]:focus,.label-primary[href]:hover{background-color:#286090}.label-success{background-color:#5cb85c}.label-success[href]:focus,.label-success[href]:hover{background-color:#449d44}.label-info{background-color:#5bc0de}.label-info[href]:focus,.label-info[href]:hover{background-color:#31b0d5}.label-warning{background-color:#f0ad4e}.label-warning[href]:focus,.label-warning[href]:hover{background-color:#ec971f}.label-danger{background-color:#d9534f}.label-danger[href]:focus,.label-danger[href]:hover{background-color:#c9302c}.badge{display:inline-block;min-width:10px;padding:3px 7px;font-size:12px;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;background-color:#777;border-radius:10px}.badge:empty{display:none}.btn .badge{position:relative;top:-1px}.btn-group-xs>.btn .badge,.btn-xs .badge{top:0;padding:1px 5px}a.badge:focus,a.badge:hover{color:#fff;text-decoration:none;cursor:pointer}.list-group-item.active>.badge,.nav-pills>.active>a>.badge{color:#337ab7;background-color:#fff}.list-group-item>.badge{float:right}.list-group-item>.badge+.badge{margin-right:5px}.nav-pills>li>a>.badge{margin-left:3px}.jumbotron{padding:30px 15px;margin-bottom:30px;color:inherit;background-color:#eee}.jumbotron .h1,.jumbotron h1{color:inherit}.jumbotron p{margin-bottom:15px;font-size:21px;font-weight:200}.jumbotron>hr{border-top-color:#d5d5d5}.container .jumbotron,.container-fluid .jumbotron{border-radius:6px}.jumbotron .container{max-width:100%}@media screen and (min-width:768px){.jumbotron{padding:48px 0}.container .jumbotron,.container-fluid .jumbotron{padding-right:60px;padding-left:60px}.jumbotron .h1,.jumbotron h1{font-size:63px}}.thumbnail{display:block;padding:4px;margin-bottom:20px;line-height:1.42857143;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:border .2s ease-in-out;-o-transition:border .2s ease-in-out;transition:border .2s ease-in-out}.thumbnail a>img,.thumbnail>img{margin-right:auto;margin-left:auto}a.thumbnail.active,a.thumbnail:focus,a.thumbnail:hover{border-color:#337ab7}.thumbnail .caption{padding:9px;color:#333}.alert{padding:15px;margin-bottom:20px;border:1px solid transparent;border-radius:4px}.alert h4{margin-top:0;color:inherit}.alert .alert-link{font-weight:700}.alert>p,.alert>ul{margin-bottom:0}.alert>p+p{margin-top:5px}.alert-dismissable,.alert-dismissible{padding-right:35px}.alert-dismissable .close,.alert-dismissible .close{position:relative;top:-2px;right:-21px;color:inherit}.alert-success{color:#3c763d;background-color:#dff0d8;border-color:#d6e9c6}.alert-success hr{border-top-color:#c9e2b3}.alert-success .alert-link{color:#2b542c}.alert-info{color:#31708f;background-color:#d9edf7;border-color:#bce8f1}.alert-info hr{border-top-color:#a6e1ec}.alert-info .alert-link{color:#245269}.alert-warning{color:#8a6d3b;background-color:#fcf8e3;border-color:#faebcc}.alert-warning hr{border-top-color:#f7e1b5}.alert-warning .alert-link{color:#66512c}.alert-danger{color:#a94442;background-color:#f2dede;border-color:#ebccd1}.alert-danger hr{border-top-color:#e4b9c0}.alert-danger .alert-link{color:#843534}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-o-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f5f5f5;border-radius:4px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.1);box-shadow:inset 0 1px 2px rgba(0,0,0,.1)}.progress-bar{float:left;width:0;height:100%;font-size:12px;line-height:20px;color:#fff;text-align:center;background-color:#337ab7;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);-webkit-transition:width .6s ease;-o-transition:width .6s ease;transition:width .6s ease}.progress-bar-striped,.progress-striped .progress-bar{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);-webkit-background-size:40px 40px;background-size:40px 40px}.progress-bar.active,.progress.active .progress-bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-bar-success{background-color:#5cb85c}.progress-striped .progress-bar-success{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.progress-bar-info{background-color:#5bc0de}.progress-striped .progress-bar-info{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.progress-bar-warning{background-color:#f0ad4e}.progress-striped .progress-bar-warning{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.progress-bar-danger{background-color:#d9534f}.progress-striped .progress-bar-danger{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.media{margin-top:15px}.media:first-child{margin-top:0}.media,.media-body{overflow:hidden;zoom:1}.media-body{width:10000px}.media-object{display:block}.media-right,.media>.pull-right{padding-left:10px}.media-left,.media>.pull-left{padding-right:10px}.media-body,.media-left,.media-right{display:table-cell;vertical-align:top}.media-middle{vertical-align:middle}.media-bottom{vertical-align:bottom}.media-heading{margin-top:0;margin-bottom:5px}.media-list{padding-left:0;list-style:none}.list-group{padding-left:0;margin-bottom:20px}.list-group-item{position:relative;display:block;padding:10px 15px;margin-bottom:-1px;background-color:#fff;border:1px solid #ddd}.list-group-item:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.list-group-item:last-child{margin-bottom:0;border-bottom-right-radius:4px;border-bottom-left-radius:4px}a.list-group-item{color:#555}a.list-group-item .list-group-item-heading{color:#333}a.list-group-item:focus,a.list-group-item:hover{color:#555;text-decoration:none;background-color:#f5f5f5}.list-group-item.disabled,.list-group-item.disabled:focus,.list-group-item.disabled:hover{color:#777;cursor:not-allowed;background-color:#eee}.list-group-item.disabled .list-group-item-heading,.list-group-item.disabled:focus .list-group-item-heading,.list-group-item.disabled:hover .list-group-item-heading{color:inherit}.list-group-item.disabled .list-group-item-text,.list-group-item.disabled:focus .list-group-item-text,.list-group-item.disabled:hover .list-group-item-text{color:#777}.list-group-item.active,.list-group-item.active:focus,.list-group-item.active:hover{z-index:2;color:#fff;background-color:#337ab7;border-color:#337ab7}.list-group-item.active .list-group-item-heading,.list-group-item.active .list-group-item-heading>.small,.list-group-item.active .list-group-item-heading>small,.list-group-item.active:focus .list-group-item-heading,.list-group-item.active:focus .list-group-item-heading>.small,.list-group-item.active:focus .list-group-item-heading>small,.list-group-item.active:hover .list-group-item-heading,.list-group-item.active:hover .list-group-item-heading>.small,.list-group-item.active:hover .list-group-item-heading>small{color:inherit}.list-group-item.active .list-group-item-text,.list-group-item.active:focus .list-group-item-text,.list-group-item.active:hover .list-group-item-text{color:#c7ddef}.list-group-item-success{color:#3c763d;background-color:#dff0d8}a.list-group-item-success{color:#3c763d}a.list-group-item-success .list-group-item-heading{color:inherit}a.list-group-item-success:focus,a.list-group-item-success:hover{color:#3c763d;background-color:#d0e9c6}a.list-group-item-success.active,a.list-group-item-success.active:focus,a.list-group-item-success.active:hover{color:#fff;background-color:#3c763d;border-color:#3c763d}.list-group-item-info{color:#31708f;background-color:#d9edf7}a.list-group-item-info{color:#31708f}a.list-group-item-info .list-group-item-heading{color:inherit}a.list-group-item-info:focus,a.list-group-item-info:hover{color:#31708f;background-color:#c4e3f3}a.list-group-item-info.active,a.list-group-item-info.active:focus,a.list-group-item-info.active:hover{color:#fff;background-color:#31708f;border-color:#31708f}.list-group-item-warning{color:#8a6d3b;background-color:#fcf8e3}a.list-group-item-warning{color:#8a6d3b}a.list-group-item-warning .list-group-item-heading{color:inherit}a.list-group-item-warning:focus,a.list-group-item-warning:hover{color:#8a6d3b;background-color:#faf2cc}a.list-group-item-warning.active,a.list-group-item-warning.active:focus,a.list-group-item-warning.active:hover{color:#fff;background-color:#8a6d3b;border-color:#8a6d3b}.list-group-item-danger{color:#a94442;background-color:#f2dede}a.list-group-item-danger{color:#a94442}a.list-group-item-danger .list-group-item-heading{color:inherit}a.list-group-item-danger:focus,a.list-group-item-danger:hover{color:#a94442;background-color:#ebcccc}a.list-group-item-danger.active,a.list-group-item-danger.active:focus,a.list-group-item-danger.active:hover{color:#fff;background-color:#a94442;border-color:#a94442}.list-group-item-heading{margin-top:0;margin-bottom:5px}.list-group-item-text{margin-bottom:0;line-height:1.3}.panel{margin-bottom:20px;background-color:#fff;border:1px solid transparent;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05)}.panel-body{padding:15px}.panel-heading{padding:10px 15px;border-bottom:1px solid transparent;border-top-left-radius:3px;border-top-right-radius:3px}.panel-heading>.dropdown .dropdown-toggle{color:inherit}.panel-title{margin-top:0;margin-bottom:0;font-size:16px;color:inherit}.panel-title>.small,.panel-title>.small>a,.panel-title>a,.panel-title>small,.panel-title>small>a{color:inherit}.panel-footer{padding:10px 15px;background-color:#f5f5f5;border-top:1px solid #ddd;border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel>.list-group,.panel>.panel-collapse>.list-group{margin-bottom:0}.panel>.list-group .list-group-item,.panel>.panel-collapse>.list-group .list-group-item{border-width:1px 0;border-radius:0}.panel>.list-group:first-child .list-group-item:first-child,.panel>.panel-collapse>.list-group:first-child .list-group-item:first-child{border-top:0;border-top-left-radius:3px;border-top-right-radius:3px}.panel>.list-group:last-child .list-group-item:last-child,.panel>.panel-collapse>.list-group:last-child .list-group-item:last-child{border-bottom:0;border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel-heading+.list-group .list-group-item:first-child{border-top-width:0}.list-group+.panel-footer{border-top-width:0}.panel>.panel-collapse>.table,.panel>.table,.panel>.table-responsive>.table{margin-bottom:0}.panel>.panel-collapse>.table caption,.panel>.table caption,.panel>.table-responsive>.table caption{padding-right:15px;padding-left:15px}.panel>.table-responsive:first-child>.table:first-child,.panel>.table:first-child{border-top-left-radius:3px;border-top-right-radius:3px}.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child,.panel>.table:first-child>tbody:first-child>tr:first-child,.panel>.table:first-child>thead:first-child>tr:first-child{border-top-left-radius:3px;border-top-right-radius:3px}.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child td:first-child,.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child th:first-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child td:first-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child th:first-child,.panel>.table:first-child>tbody:first-child>tr:first-child td:first-child,.panel>.table:first-child>tbody:first-child>tr:first-child th:first-child,.panel>.table:first-child>thead:first-child>tr:first-child td:first-child,.panel>.table:first-child>thead:first-child>tr:first-child th:first-child{border-top-left-radius:3px}.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child td:last-child,.panel>.table-responsive:first-child>.table:first-child>tbody:first-child>tr:first-child th:last-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child td:last-child,.panel>.table-responsive:first-child>.table:first-child>thead:first-child>tr:first-child th:last-child,.panel>.table:first-child>tbody:first-child>tr:first-child td:last-child,.panel>.table:first-child>tbody:first-child>tr:first-child th:last-child,.panel>.table:first-child>thead:first-child>tr:first-child td:last-child,.panel>.table:first-child>thead:first-child>tr:first-child th:last-child{border-top-right-radius:3px}.panel>.table-responsive:last-child>.table:last-child,.panel>.table:last-child{border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child,.panel>.table:last-child>tbody:last-child>tr:last-child,.panel>.table:last-child>tfoot:last-child>tr:last-child{border-bottom-right-radius:3px;border-bottom-left-radius:3px}.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child td:first-child,.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child th:first-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child td:first-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child th:first-child,.panel>.table:last-child>tbody:last-child>tr:last-child td:first-child,.panel>.table:last-child>tbody:last-child>tr:last-child th:first-child,.panel>.table:last-child>tfoot:last-child>tr:last-child td:first-child,.panel>.table:last-child>tfoot:last-child>tr:last-child th:first-child{border-bottom-left-radius:3px}.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child td:last-child,.panel>.table-responsive:last-child>.table:last-child>tbody:last-child>tr:last-child th:last-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child td:last-child,.panel>.table-responsive:last-child>.table:last-child>tfoot:last-child>tr:last-child th:last-child,.panel>.table:last-child>tbody:last-child>tr:last-child td:last-child,.panel>.table:last-child>tbody:last-child>tr:last-child th:last-child,.panel>.table:last-child>tfoot:last-child>tr:last-child td:last-child,.panel>.table:last-child>tfoot:last-child>tr:last-child th:last-child{border-bottom-right-radius:3px}.panel>.panel-body+.table,.panel>.panel-body+.table-responsive,.panel>.table+.panel-body,.panel>.table-responsive+.panel-body{border-top:1px solid #ddd}.panel>.table>tbody:first-child>tr:first-child td,.panel>.table>tbody:first-child>tr:first-child th{border-top:0}.panel>.table-bordered,.panel>.table-responsive>.table-bordered{border:0}.panel>.table-bordered>tbody>tr>td:first-child,.panel>.table-bordered>tbody>tr>th:first-child,.panel>.table-bordered>tfoot>tr>td:first-child,.panel>.table-bordered>tfoot>tr>th:first-child,.panel>.table-bordered>thead>tr>td:first-child,.panel>.table-bordered>thead>tr>th:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:first-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:first-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:first-child,.panel>.table-responsive>.table-bordered>thead>tr>td:first-child,.panel>.table-responsive>.table-bordered>thead>tr>th:first-child{border-left:0}.panel>.table-bordered>tbody>tr>td:last-child,.panel>.table-bordered>tbody>tr>th:last-child,.panel>.table-bordered>tfoot>tr>td:last-child,.panel>.table-bordered>tfoot>tr>th:last-child,.panel>.table-bordered>thead>tr>td:last-child,.panel>.table-bordered>thead>tr>th:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>td:last-child,.panel>.table-responsive>.table-bordered>tbody>tr>th:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>td:last-child,.panel>.table-responsive>.table-bordered>tfoot>tr>th:last-child,.panel>.table-responsive>.table-bordered>thead>tr>td:last-child,.panel>.table-responsive>.table-bordered>thead>tr>th:last-child{border-right:0}.panel>.table-bordered>tbody>tr:first-child>td,.panel>.table-bordered>tbody>tr:first-child>th,.panel>.table-bordered>thead>tr:first-child>td,.panel>.table-bordered>thead>tr:first-child>th,.panel>.table-responsive>.table-bordered>tbody>tr:first-child>td,.panel>.table-responsive>.table-bordered>tbody>tr:first-child>th,.panel>.table-responsive>.table-bordered>thead>tr:first-child>td,.panel>.table-responsive>.table-bordered>thead>tr:first-child>th{border-bottom:0}.panel>.table-bordered>tbody>tr:last-child>td,.panel>.table-bordered>tbody>tr:last-child>th,.panel>.table-bordered>tfoot>tr:last-child>td,.panel>.table-bordered>tfoot>tr:last-child>th,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>td,.panel>.table-responsive>.table-bordered>tbody>tr:last-child>th,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>td,.panel>.table-responsive>.table-bordered>tfoot>tr:last-child>th{border-bottom:0}.panel>.table-responsive{margin-bottom:0;border:0}.panel-group{margin-bottom:20px}.panel-group .panel{margin-bottom:0;border-radius:4px}.panel-group .panel+.panel{margin-top:5px}.panel-group .panel-heading{border-bottom:0}.panel-group .panel-heading+.panel-collapse>.list-group,.panel-group .panel-heading+.panel-collapse>.panel-body{border-top:1px solid #ddd}.panel-group .panel-footer{border-top:0}.panel-group .panel-footer+.panel-collapse .panel-body{border-bottom:1px solid #ddd}.panel-default{border-color:#ddd}.panel-default>.panel-heading{color:#333;background-color:#f5f5f5;border-color:#ddd}.panel-default>.panel-heading+.panel-collapse>.panel-body{border-top-color:#ddd}.panel-default>.panel-heading .badge{color:#f5f5f5;background-color:#333}.panel-default>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#ddd}.panel-primary{border-color:#337ab7}.panel-primary>.panel-heading{color:#fff;background-color:#337ab7;border-color:#337ab7}.panel-primary>.panel-heading+.panel-collapse>.panel-body{border-top-color:#337ab7}.panel-primary>.panel-heading .badge{color:#337ab7;background-color:#fff}.panel-primary>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#337ab7}.panel-success{border-color:#d6e9c6}.panel-success>.panel-heading{color:#3c763d;background-color:#dff0d8;border-color:#d6e9c6}.panel-success>.panel-heading+.panel-collapse>.panel-body{border-top-color:#d6e9c6}.panel-success>.panel-heading .badge{color:#dff0d8;background-color:#3c763d}.panel-success>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#d6e9c6}.panel-info{border-color:#bce8f1}.panel-info>.panel-heading{color:#31708f;background-color:#d9edf7;border-color:#bce8f1}.panel-info>.panel-heading+.panel-collapse>.panel-body{border-top-color:#bce8f1}.panel-info>.panel-heading .badge{color:#d9edf7;background-color:#31708f}.panel-info>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#bce8f1}.panel-warning{border-color:#faebcc}.panel-warning>.panel-heading{color:#8a6d3b;background-color:#fcf8e3;border-color:#faebcc}.panel-warning>.panel-heading+.panel-collapse>.panel-body{border-top-color:#faebcc}.panel-warning>.panel-heading .badge{color:#fcf8e3;background-color:#8a6d3b}.panel-warning>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#faebcc}.panel-danger{border-color:#ebccd1}.panel-danger>.panel-heading{color:#a94442;background-color:#f2dede;border-color:#ebccd1}.panel-danger>.panel-heading+.panel-collapse>.panel-body{border-top-color:#ebccd1}.panel-danger>.panel-heading .badge{color:#f2dede;background-color:#a94442}.panel-danger>.panel-footer+.panel-collapse>.panel-body{border-bottom-color:#ebccd1}.embed-responsive{position:relative;display:block;height:0;padding:0;overflow:hidden}.embed-responsive .embed-responsive-item,.embed-responsive embed,.embed-responsive iframe,.embed-responsive object,.embed-responsive video{position:absolute;top:0;bottom:0;left:0;width:100%;height:100%;border:0}.embed-responsive-16by9{padding-bottom:56.25%}.embed-responsive-4by3{padding-bottom:75%}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.05);box-shadow:inset 0 1px 1px rgba(0,0,0,.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,.15)}.well-lg{padding:24px;border-radius:6px}.well-sm{padding:9px;border-radius:3px}.close{float:right;font-size:21px;font-weight:700;line-height:1;color:#000;text-shadow:0 1px 0 #fff;filter:alpha(opacity=20);opacity:.2}.close:focus,.close:hover{color:#000;text-decoration:none;cursor:pointer;filter:alpha(opacity=50);opacity:.5}button.close{-webkit-appearance:none;padding:0;cursor:pointer;background:0 0;border:0}.modal-open{overflow:hidden}.modal{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1050;display:none;overflow:hidden;-webkit-overflow-scrolling:touch;outline:0}.modal.fade .modal-dialog{-webkit-transition:-webkit-transform .3s ease-out;-o-transition:-o-transform .3s ease-out;transition:transform .3s ease-out;-webkit-transform:translate(0,-25%);-ms-transform:translate(0,-25%);-o-transform:translate(0,-25%);transform:translate(0,-25%)}.modal.in .modal-dialog{-webkit-transform:translate(0,0);-ms-transform:translate(0,0);-o-transform:translate(0,0);transform:translate(0,0)}.modal-open .modal{overflow-x:hidden;overflow-y:auto}.modal-dialog{position:relative;width:auto;margin:10px}.modal-content{position:relative;background-color:#fff;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #999;border:1px solid rgba(0,0,0,.2);border-radius:6px;outline:0;-webkit-box-shadow:0 3px 9px rgba(0,0,0,.5);box-shadow:0 3px 9px rgba(0,0,0,.5)}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{filter:alpha(opacity=0);opacity:0}.modal-backdrop.in{filter:alpha(opacity=50);opacity:.5}.modal-header{min-height:16.43px;padding:15px;border-bottom:1px solid #e5e5e5}.modal-header .close{margin-top:-2px}.modal-title{margin:0;line-height:1.42857143}.modal-body{position:relative;padding:15px}.modal-footer{padding:15px;text-align:right;border-top:1px solid #e5e5e5}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.modal-footer .btn-block+.btn-block{margin-left:0}.modal-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}@media (min-width:768px){.modal-dialog{width:600px;margin:30px auto}.modal-content{-webkit-box-shadow:0 5px 15px rgba(0,0,0,.5);box-shadow:0 5px 15px rgba(0,0,0,.5)}.modal-sm{width:300px}}@media (min-width:992px){.modal-lg{width:900px}}.tooltip{position:absolute;z-index:1070;display:block;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:12px;font-weight:400;line-height:1.4;filter:alpha(opacity=0);opacity:0}.tooltip.in{filter:alpha(opacity=90);opacity:.9}.tooltip.top{padding:5px 0;margin-top:-3px}.tooltip.right{padding:0 5px;margin-left:3px}.tooltip.bottom{padding:5px 0;margin-top:3px}.tooltip.left{padding:0 5px;margin-left:-3px}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-width:5px 5px 0;border-top-color:#000}.tooltip.top-left .tooltip-arrow{right:5px;bottom:0;margin-bottom:-5px;border-width:5px 5px 0;border-top-color:#000}.tooltip.top-right .tooltip-arrow{bottom:0;left:5px;margin-bottom:-5px;border-width:5px 5px 0;border-top-color:#000}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-width:5px 5px 5px 0;border-right-color:#000}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-width:5px 0 5px 5px;border-left-color:#000}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-width:0 5px 5px;border-bottom-color:#000}.tooltip.bottom-left .tooltip-arrow{top:0;right:5px;margin-top:-5px;border-width:0 5px 5px;border-bottom-color:#000}.tooltip.bottom-right .tooltip-arrow{top:0;left:5px;margin-top:-5px;border-width:0 5px 5px;border-bottom-color:#000}.popover{position:absolute;top:0;left:0;z-index:1060;display:none;max-width:276px;padding:1px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;font-weight:400;line-height:1.42857143;text-align:left;white-space:normal;background-color:#fff;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #ccc;border:1px solid rgba(0,0,0,.2);border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2)}.popover.top{margin-top:-10px}.popover.right{margin-left:10px}.popover.bottom{margin-top:10px}.popover.left{margin-left:-10px}.popover-title{padding:8px 14px;margin:0;font-size:14px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;border-radius:5px 5px 0 0}.popover-content{padding:9px 14px}.popover>.arrow,.popover>.arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover>.arrow{border-width:11px}.popover>.arrow:after{content:"";border-width:10px}.popover.top>.arrow{bottom:-11px;left:50%;margin-left:-11px;border-top-color:#999;border-top-color:rgba(0,0,0,.25);border-bottom-width:0}.popover.top>.arrow:after{bottom:1px;margin-left:-10px;content:" ";border-top-color:#fff;border-bottom-width:0}.popover.right>.arrow{top:50%;left:-11px;margin-top:-11px;border-right-color:#999;border-right-color:rgba(0,0,0,.25);border-left-width:0}.popover.right>.arrow:after{bottom:-10px;left:1px;content:" ";border-right-color:#fff;border-left-width:0}.popover.bottom>.arrow{top:-11px;left:50%;margin-left:-11px;border-top-width:0;border-bottom-color:#999;border-bottom-color:rgba(0,0,0,.25)}.popover.bottom>.arrow:after{top:1px;margin-left:-10px;content:" ";border-top-width:0;border-bottom-color:#fff}.popover.left>.arrow{top:50%;right:-11px;margin-top:-11px;border-right-width:0;border-left-color:#999;border-left-color:rgba(0,0,0,.25)}.popover.left>.arrow:after{right:1px;bottom:-10px;content:" ";border-right-width:0;border-left-color:#fff}.carousel{position:relative}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel-inner>.item{position:relative;display:none;-webkit-transition:.6s ease-in-out left;-o-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel-inner>.item>a>img,.carousel-inner>.item>img{line-height:1}@media all and (transform-3d),(-webkit-transform-3d){.carousel-inner>.item{-webkit-transition:-webkit-transform .6s ease-in-out;-o-transition:-o-transform .6s ease-in-out;transition:transform .6s ease-in-out;-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-perspective:1000;perspective:1000}.carousel-inner>.item.active.right,.carousel-inner>.item.next{left:0;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)}.carousel-inner>.item.active.left,.carousel-inner>.item.prev{left:0;-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0)}.carousel-inner>.item.active,.carousel-inner>.item.next.left,.carousel-inner>.item.prev.right{left:0;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0)}}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{display:block}.carousel-inner>.active{left:0}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.carousel-inner>.next{left:100%}.carousel-inner>.prev{left:-100%}.carousel-inner>.next.left,.carousel-inner>.prev.right{left:0}.carousel-inner>.active.left{left:-100%}.carousel-inner>.active.right{left:100%}.carousel-control{position:absolute;top:0;bottom:0;left:0;width:15%;font-size:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,.6);filter:alpha(opacity=50);opacity:.5}.carousel-control.left{background-image:-webkit-linear-gradient(left,rgba(0,0,0,.5) 0,rgba(0,0,0,.0001) 100%);background-image:-o-linear-gradient(left,rgba(0,0,0,.5) 0,rgba(0,0,0,.0001) 100%);background-image:-webkit-gradient(linear,left top,right top,from(rgba(0,0,0,.5)),to(rgba(0,0,0,.0001)));background-image:linear-gradient(to right,rgba(0,0,0,.5) 0,rgba(0,0,0,.0001) 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1);background-repeat:repeat-x}.carousel-control.right{right:0;left:auto;background-image:-webkit-linear-gradient(left,rgba(0,0,0,.0001) 0,rgba(0,0,0,.5) 100%);background-image:-o-linear-gradient(left,rgba(0,0,0,.0001) 0,rgba(0,0,0,.5) 100%);background-image:-webkit-gradient(linear,left top,right top,from(rgba(0,0,0,.0001)),to(rgba(0,0,0,.5)));background-image:linear-gradient(to right,rgba(0,0,0,.0001) 0,rgba(0,0,0,.5) 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1);background-repeat:repeat-x}.carousel-control:focus,.carousel-control:hover{color:#fff;text-decoration:none;filter:alpha(opacity=90);outline:0;opacity:.9}.carousel-control .glyphicon-chevron-left,.carousel-control .glyphicon-chevron-right,.carousel-control .icon-next,.carousel-control .icon-prev{position:absolute;top:50%;z-index:5;display:inline-block}.carousel-control .glyphicon-chevron-left,.carousel-control .icon-prev{left:50%;margin-left:-10px}.carousel-control .glyphicon-chevron-right,.carousel-control .icon-next{right:50%;margin-right:-10px}.carousel-control .icon-next,.carousel-control .icon-prev{width:20px;height:20px;margin-top:-10px;font-family:serif;line-height:1}.carousel-control .icon-prev:before{content:'\2039'}.carousel-control .icon-next:before{content:'\203a'}.carousel-indicators{position:absolute;bottom:10px;left:50%;z-index:15;width:60%;padding-left:0;margin-left:-30%;text-align:center;list-style:none}.carousel-indicators li{display:inline-block;width:10px;height:10px;margin:1px;text-indent:-999px;cursor:pointer;background-color:#000 \9;background-color:rgba(0,0,0,0);border:1px solid #fff;border-radius:10px}.carousel-indicators .active{width:12px;height:12px;margin:0;background-color:#fff}.carousel-caption{position:absolute;right:15%;bottom:20px;left:15%;z-index:10;padding-top:20px;padding-bottom:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,.6)}.carousel-caption .btn{text-shadow:none}@media screen and (min-width:768px){.carousel-control .glyphicon-chevron-left,.carousel-control .glyphicon-chevron-right,.carousel-control .icon-next,.carousel-control .icon-prev{width:30px;height:30px;margin-top:-15px;font-size:30px}.carousel-control .glyphicon-chevron-left,.carousel-control .icon-prev{margin-left:-15px}.carousel-control .glyphicon-chevron-right,.carousel-control .icon-next{margin-right:-15px}.carousel-caption{right:20%;left:20%;padding-bottom:30px}.carousel-indicators{bottom:20px}}.btn-group-vertical>.btn-group:after,.btn-group-vertical>.btn-group:before,.btn-toolbar:after,.btn-toolbar:before,.clearfix:after,.clearfix:before,.container-fluid:after,.container-fluid:before,.container:after,.container:before,.dl-horizontal dd:after,.dl-horizontal dd:before,.form-horizontal .form-group:after,.form-horizontal .form-group:before,.modal-footer:after,.modal-footer:before,.nav:after,.nav:before,.navbar-collapse:after,.navbar-collapse:before,.navbar-header:after,.navbar-header:before,.navbar:after,.navbar:before,.pager:after,.pager:before,.panel-body:after,.panel-body:before,.row:after,.row:before{display:table;content:" "}.btn-group-vertical>.btn-group:after,.btn-toolbar:after,.clearfix:after,.container-fluid:after,.container:after,.dl-horizontal dd:after,.form-horizontal .form-group:after,.modal-footer:after,.nav:after,.navbar-collapse:after,.navbar-header:after,.navbar:after,.pager:after,.panel-body:after,.row:after{clear:both}.center-block{display:block;margin-right:auto;margin-left:auto}.pull-right{float:right!important}.pull-left{float:left!important}.hide{display:none!important}.show{display:block!important}.invisible{visibility:hidden}.text-hide{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.hidden{display:none!important}.affix{position:fixed}@-ms-viewport{width:device-width}.visible-lg,.visible-md,.visible-sm,.visible-xs{display:none!important}.visible-lg-block,.visible-lg-inline,.visible-lg-inline-block,.visible-md-block,.visible-md-inline,.visible-md-inline-block,.visible-sm-block,.visible-sm-inline,.visible-sm-inline-block,.visible-xs-block,.visible-xs-inline,.visible-xs-inline-block{display:none!important}@media (max-width:767px){.visible-xs{display:block!important}table.visible-xs{display:table}tr.visible-xs{display:table-row!important}td.visible-xs,th.visible-xs{display:table-cell!important}}@media (max-width:767px){.visible-xs-block{display:block!important}}@media (max-width:767px){.visible-xs-inline{display:inline!important}}@media (max-width:767px){.visible-xs-inline-block{display:inline-block!important}}@media (min-width:768px)and (max-width:991px){.visible-sm{display:block!important}table.visible-sm{display:table}tr.visible-sm{display:table-row!important}td.visible-sm,th.visible-sm{display:table-cell!important}}@media (min-width:768px)and (max-width:991px){.visible-sm-block{display:block!important}}@media (min-width:768px)and (max-width:991px){.visible-sm-inline{display:inline!important}}@media (min-width:768px)and (max-width:991px){.visible-sm-inline-block{display:inline-block!important}}@media (min-width:992px)and (max-width:1199px){.visible-md{display:block!important}table.visible-md{display:table}tr.visible-md{display:table-row!important}td.visible-md,th.visible-md{display:table-cell!important}}@media (min-width:992px)and (max-width:1199px){.visible-md-block{display:block!important}}@media (min-width:992px)and (max-width:1199px){.visible-md-inline{display:inline!important}}@media (min-width:992px)and (max-width:1199px){.visible-md-inline-block{display:inline-block!important}}@media (min-width:1200px){.visible-lg{display:block!important}table.visible-lg{display:table}tr.visible-lg{display:table-row!important}td.visible-lg,th.visible-lg{display:table-cell!important}}@media (min-width:1200px){.visible-lg-block{display:block!important}}@media (min-width:1200px){.visible-lg-inline{display:inline!important}}@media (min-width:1200px){.visible-lg-inline-block{display:inline-block!important}}@media (max-width:767px){.hidden-xs{display:none!important}}@media (min-width:768px)and (max-width:991px){.hidden-sm{display:none!important}}@media (min-width:992px)and (max-width:1199px){.hidden-md{display:none!important}}@media (min-width:1200px){.hidden-lg{display:none!important}}.visible-print{display:none!important}@media print{.visible-print{display:block!important}table.visible-print{display:table}tr.visible-print{display:table-row!important}td.visible-print,th.visible-print{display:table-cell!important}}.visible-print-block{display:none!important}@media print{.visible-print-block{display:block!important}}.visible-print-inline{display:none!important}@media print{.visible-print-inline{display:inline!important}}.visible-print-inline-block{display:none!important}@media print{.visible-print-inline-block{display:inline-block!important}}@media print{.hidden-print{display:none!important}}
\ No newline at end of file
vendor/dir-index-html-v1.0.0/gw-assets/icons.css deleted
-384
@@ -1,384 +0,0 @@
1 -
2 -.ipfs-_blank {
3 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAWBJREFUeNqEUj1LxEAQnd1MVA4lyIEWx6UIKEGUExGsbC3tLfwJ/hT/g7VlCnubqxXBwg/Q4hQP/LhKL5nZuBsvuGfW5MGyuzM7jzdvVuR5DgYnZ+f99ai7Vt5t9K9unu4HLweI3qWYxI6PDosdy0fhcntxO44CcOBzPA7mfEyuHwf7ntQk4jcnywOxIlfxOCNYaLVgb6cXbkTdhJXq2SIlNMC0xIqhHczDbi8OVzpLSUa0WebRfmigLHqj1EcPZnwf7gbDIrYVRyEinurj6jTBHyI7pqVrFQqEbt6TEmZ9v1NRAJNC1xTYxIQh/MmRUlmFQE3qWOW1nqB2TWk1/3tgJV0waVvkFIEeZbHq4ElyKzAmEXOx6gnEVJuWBzmkRJBRPYGZBDsVaOlpSgVJE2yVaAe/0kx/3azBRO0VsbMFZE3CDSZKweZfYIVg+DZ6v7h9GDVOwZPw/PoxKu/fAgwALbDAXf7DdQkAAAAASUVORK5CYII=');
4 - background-repeat: no-repeat;
5 - background-size: contain;
6 -}
7 -
8 -.ipfs-_page {
9 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmhJREFUeNpsUztv01AYPfdhOy/XTZ80VV1VoCqlA2zQqUgwMEErWBALv4GJDfEDmOEHsFTqVCTExAiiSI2QEKJKESVFFBWo04TESRzfy2c7LY/kLtf2d8+555zvM9NaI1ora5svby9OnbUEBxgDlIKiWjXQeLy19/X17sEtcPY2rtHS96/Hu0RvXXLz+cUzM87zShsI29DpHCYt4E6Box4IZzTnbDx7V74GjhOSfwgE0H2638K9h08A3iHGVbjTw7g6YmAyw/BgecHNGGJjvfQhIfmfIFDAXJpjuugi7djIFVI4P0plctgJQ0xnFe5eOO02OwEp2VkhSCnC8WOCdqgwnzFx4/IyppwRVN+XYXsecqZA1pB48ekAnw9/4GZx3L04N/GoTwEjX4cNH5vlPfjtAIYp8cWrQutxrC5Mod3VsXVTMFSqtaE+gl9dhaUxE2tXZiF7nYiiatJ3v5s8R/1yOCNLOuwjkELiTbmC9dJHpIaGASsDkoFQGJQwHWMcHWJYOmUj1OjvQotuytt5nHMLEGkCyx6QU384jwkUAd2sxJbS/QShZtg/8rHzzQOzSaFhxQrA6YgQMQHojCUlgnCAAvKFBoXXaHfArSCZDE0gyWJgFIKmvUFKO4MUNIk2a4+hODtDUVuJ/J732AKS6ZtImdTyAQQB3bZN8l9t75IFh0JMUdVKsohsUPqRgnka0tYgggYpCHkKGTsHI5NOMojB4iTICCepvX53AIEfQta1iUCmoTiBmdEri2RgddKFhuJoqb/af/yw/d3zTNM6UkaOfis62aUgddAbnz+rXuPY+Vnzjt9/CzAAbmLjCrfBiRgAAAAASUVORK5CYII=');
10 - background-repeat: no-repeat;
11 - background-size: contain;
12 -}
13 -
14 -.ipfs-aac {
15 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnhJREFUeNp0Uk1PE0EYftruVlvAUkhVEPoBcsEoLRJBY01MPHjCs3cvogcT/4qJJN5NvHhoohcOnPw4YEGIkCh+oLGBKm3Z7nZ3dme2vjOhTcjiJJvZzPvOM8/HG2q325Dr3kLp7Y1ibpIxjs4KhQBZfvV6s7K5Vb0bjeof5ZlcGysP1a51mifODybvzE8mzCbrAoTDIThMoGXZiZ4YSiurf+Z1XeuCqJ7Oj+sK3jQcNAmg8xkGQ71mYejcAB49vpmeuzJccl0+dUj6KIAvfHCPg3N+uAv4vg9BOxcCmfEzuP/genpmeqhEMgude10Jwm+DuUIyUdTlqu2byoMfX/dRermBeExHsTiWNi3+lMpzRwDki8zxCIATmzbevfmClukiP5NFhJgwkjeRTeLShdOoVJqnAgwkgCAZ6+UdLC9twjQZ8pdzioFkZBHY3q6B3l4dJEEEPOCeD4cYVH7Xsf15F+FImC775INAJBJSkVoWo0QY9YqgiR4ZZzRaGBkdwK3bFxGLRZUfB3Rm2x4x9CGtsUxH9QYkKICDFuLxKAozGZwdTqBRs2FbLlXbiPdECMCHadj/AaDXZNFqedCIvnRcS4UpRo7+hC5zUmw8Ope9wUFinvpmZ7NKt2RTmB4hKZo6n8qP4Oq1HBkKlVYAQBrUlziB0XQSif4YmQhksgNIJk9iaLhPaV9b/Um+uJSCdzyDbGZQRSkvjo+n4JNxubGUSsCj+ZCpODYjkGMAND2k7exUsfhkCd+29yguB88Wl7FW/o6tT7/gcXqAgGv7hhx1LWBireHVn79YP6ChQ3njb/eFlfWqGqT3H3ZlGIhGI2i2UO/U/wkwAAmoalcxlNA1AAAAAElFTkSuQmCC');
16 - background-repeat: no-repeat;
17 - background-size: contain;
18 -}
19 -
20 -.ipfs-ai {
21 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAk5JREFUeNpsU01vElEUPTPzZqBAQaSFQiJYUmlKYhoTF41L3Tbu/Q/+AvsX3Bp/gPsuWLrqyqQ7TUxMtAvF1tYGoXwNw7wv7zwYgtKX3Lw379575p5z77O01ohW+/DVh8zj7aYKhflGdG9ZsGwLNydffgVfr19YHvsEa+Zu/nxndob5StQK+dyzvZzyw/gKlmMj7IygFM+xvNcanp4/t5dAomXHBy2UUBOO2MAl/B9/cPb6PULuoHx0WM0e3GvpUOxD3wZAJWutZqYUYmqpSg5OMgH3YQObL59W0/ullpryR3HegkKEqiWBSGV4R3vQ7sIhScTZFTpHx3A215B5sluVY/WWMg7+ATB/lcLsKpTonHzD+OMFEuTz8ikkt9Kwt9YJZB38cpBdoQAZJdLvCGByfoPB6Xdk90pYy6Xg3c/DaWwArg09DaG5lCsUFN0pckZAojdC8m4auBqaALuSgez7VB1RtDSUWOQvUaBLFUzJBMJ2DwmPgd1Jwm0WoSgJfjDvrTKxtwAIyEkAOQ5hU//Zdg5uowDlUNMnwZLW0sSuUuACYhwQRwFvJxupCjEYUUccOkoaKmdOlZnY1TkgAcXAhxhOwLsDsHoN3u4O5JTDfVCH6I9nfjId3gIgSUATFJk/hVevGtOMwS0XwQ3AzB/FrlKg8Q27I2javVoZrFgwD4qVipAEyMlnaFArzaj/D0DiMXlJAFQyK2r8fnMMRZp4lQ1MaSL5tU/1kqAkMCh2tYI+7+kh70cjPbr4bEZ51jZr8TJnB9PJXpz3V4ABAPOQVJn2Q60GAAAAAElFTkSuQmCC');
22 - background-repeat: no-repeat;
23 - background-size: contain;
24 -}
25 -
26 -.ipfs-aiff {
27 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAohJREFUeNpkU9tqE1EUXZmZpE3aTBLbJFPTtFURtSCthr7UCyKKFJ/9An3og6Ag/oXfoUj7og9asCBYKT6UIPHaWtpq7NU2aZK5z5wZ9xxMpMwZDuewz9prr32ZiO/7CNaDx3OLt6fOjBqGg/aKRCIInp8+KzfKH7fudnVF58nE16el+/yU2mBFSWZKpWJKVc0OgUBo02K4NDmU6o75Mx+Wdu9IUXFeiOA/pn1xHeYaugVDdzpbp91qGlAKGTx8dC19/Wpxhjnsxj/RRwk85hGJC9d1O6fneWAuoztDYSSLe9OT6SuXB2ccx73Z9uukwDwfls1g0xZIY/Ad/Gnyt/XVfbyYrSDRE8PExHB6/8B6QuaxIwRBFMt0iIAiMx+LCys8jfGJEUik2WpZOD2SQf9oDtVqQwopCAiY66FS/om3b75CVS2MlU7AJ2WiJBCZjZ2dJuRkDJZFwFAR7UCBja3fNfxY2YEoCtRCj9em3Tpds6FpJseGCBxS0GgYGBzqw62p84gnYnAI2CSbSbPhEpFAaE2zODaUAlWWwDoS5DheGqbWpVE/0CmqCY9qkEyINBceb2uADRNQ8bSWAVVzIFKomCQim+0luS4yKYlsHlRyZo7EsSEC23K5vAsXh/H92zZkuRvxeBS5nEx2yp2KqhxPoV5TYS/8CtdApylM9sZQKKSQzyeRTseRV2QoAzIYY8jme5DN9fI0dQoUIjANGydP9VM7PZw9p/AiBpNYrdbw/t0yTJqRtdU9UrfJCUMpSJIgbWzsYe51BcViHzLHeqCRqhZ1YX1tFwNfZBxS9O3NWkAcHqR606k/n/3coKAoV/Y7vQ/OYCZevlrmv3c0GsFh06u3/f4KMABvSWfDHmbK2gAAAABJRU5ErkJggg==');
28 - background-repeat: no-repeat;
29 - background-size: contain;
30 -}
31 -
32 -.ipfs-avi {
33 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAm1JREFUeNpsU8tu00AUPXZcN0nzTpq2KQ3pAwkIAnWHqCoeexBb+AQ+ABZ8A2s+AIkdm266QUJIFWKBkHg1KpRHi5omJGkbJ3bGHj+4M1EQrTvSyGPPueeec++1EgQBxHp+/9mbyuriRZdxjJaiKBD3W+u1+p9a856max+gDO8ebT+WT20Ezi9NZi/crqadvn2MQBAGfpCOpqNru2937vxPIpY6Onjccx3Twck9MBiSU0ncfHirXFmZX3Md9wqCUwiEVN/zaQfHt0vfbBe5uQyuPVgpl5Zn11ybL4/i/lkICOw5niQRGQShoiqI6Bo43W2ub8n3hRtLZT7gTynk6gkCX9gAOxpAnxhHZDwC1/aI1EViJolu/QhKRMHZ1UX0Gr1USIEn5FPWHy+/wTokkrQOq2vBaHZBN4hmY9Jwfr4An/teiEB45ZZDwDiMhoExT0N+sYDCuUkkplLIlXP4/XEXdo+RUhdhBSSfUwtVTUG8MIHK9QVqI7D/uY6vr2pwmCPrkz+Tk9gwARWQ9WxppbXZhNnpw+ya4A5HZi6L4lIR8WyCcL6sTZiAWjWgAmpxkn5+kqTamK6WkCwmERmLDLvjB0ML9ikWXPLFuozYOap3L8HYN6DHdbS/d5CeTVBndBz87FCBLYkNTyIjBQemnIEsSY5lYrK1+UoWcToLMjEHAyIQ2BCBSx/NVh+ZUhrqmEqBebS3WyhdLg0zt/ugAaIklsSGLHCLa6zDMGhZ2HjyGsnpFPqNHnY2fmHv3R5SMymYbROszSQ2ROAY9qHiofvlxSc5xsKKqqnY3diRE9h4X5d/pzg7lnM4ivsrwADe9Wg/CQJgFAAAAABJRU5ErkJggg==');
34 - background-repeat: no-repeat;
35 - background-size: contain;
36 -}
37 -
38 -.ipfs-bmp {
39 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmZJREFUeNp0U+1rUlEY/13v9YV0vq2wttI5CdpL9aEGBZUDv0df668I6n+or0UQ/RuuD0EgVDAZrsKF4AR1a6COKW5qXvXec27PuVeda3bgcF6e8/ye5/d7niMZhgExnK9fbTrm5pbBGMZDkgCyq+VyhTUaT6Eo2ZHJePPWXJXRhez3B1yxmM/QdctXUSCgtV4Py4CvY3cky4e1x5DlLCaGbbzjXDcousG5OQe5HPRSCQPK4PpsEM/XH4WvhS4noeu3JwHGGRiULhsMoKZS4I0GtEIB9mgULJGA0+9DPBpBT7sffvf1W/Lg6OgJufw8C0CRGEXWazUwiiyFQjA8bsjVKjaJzovMD/Q5gxyJhG2cvyeXe2cAuADQNGBmBvLaGuTFRaDfh31lBTWi9pumjbK0B4JQul3vOQpM8JdskOLrdCvDcDjAsjtg5TIkoiKLaokMNR2cnZbqNAMycqG7XbHKR2fMzwO/dsxSwu0BiBJsNsv2LwAJAJCI5ux2gXYbqNetcz5PoORI1cDS0n8AxGW7A+zvEYBKZ2ZlcsEtJLbedMjePBaCTQMghx45ulyWkzxMVUQ2RMQhLfFO16YAqCrixPnm6iqKrRb2W23EfF4cUNSrHg90cr7hDyB33MTnSmUKALVs4uIlROjxg+AsPhGVl3fuIl2tIOB0Ya91gkOi9mxhAal0ekork1ic/kGLBORMxy2K1qS9V1ZQbNThIj2EGh+2tsyOnSai8r1UxMNIBB+LRTTULr4Uds0K1tU/uOLxIrmbNz8XXSrnASSpubG9fbKRyVh1n/zSw29t9oC1b47MfwUYAAUsLiWr4QUJAAAAAElFTkSuQmCC');
40 - background-repeat: no-repeat;
41 - background-size: contain;
42 -}
43 -
44 -.ipfs-c {
45 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAcxJREFUeNqEUk1rE0EYfmZnkgoJCaGNCehuJTalhJZSUZB66a0HwXsP/Qn+FM+9+hty0LNYCr2I7UVLIW0Fc0hpQpSS7O7MrO9MspuvVV8YMnk/nn2e5x0WRRFMvP/w6WSz5jbi/9NxfP693Wp3DrJCnMW5d28P7a+IE15lufR8o1ZEStwPhkWHsWbrZ+eNEPxsuubEF6m0TBv2Q4liPofXuzveulttSqW2UwH+GjqC0horpSL2njU89+FyMwjlTlxOJMTa9ZQHzDQIjgwdom9zLzfXPc75kbnOAswBJTlC2XrqQRMLxhi442DgB4UFBhgPpm3B5pgBHNUUxQKAHs8pHf3TEuFMetM9IKr/i2mWMwC0SnuSFTG2YKyppwKYVdGO7TFhzBqGIenVeLCUtfURgErucx5ECKREKBU4d3B718PHz6cICGT/1Qs8qpQtGOdyhtGEARWDQFqQJSeDL98u4VbLaKw9IRAJPwjtoJGlVAoDQ800+fRFTTYXcjlcXN2g++s36p5Lzzlve1iEROa8BGH1EbrSAeqrjxEqicHQt8/YSDHMpaNs7wJAp9vvfb287idboAVkRAa5fBYXP9rxO4Mgf0xvPPdHgAEA8OoGd40i1j0AAAAASUVORK5CYII=');
46 - background-repeat: no-repeat;
47 - background-size: contain;
48 -}
49 -
50 -.ipfs-cpp {
51 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAfJJREFUeNqEUs9PE0EU/mZ2WgqpXX+QIDFdalVslh8NlAOQaOKFAwfvHvwT/FM8e/U/MOnBmwcj8WD0ACEGghIkbU0baaEthe3OTJ0ZWV26q37JZt68ee/b9733yGAwgMbL12/fz+azbnAPY2Nrt7Zfqz9JMrYZ+J4/e2pOFjiciRvXlgp5GzHonXk2o6S8V6k/TjBrM/xGA4MLyeOSPZ8jkx7D+uqCU3Amy1yIYizB36AlCSkwfjWDR4uu40yMl/s+XwjeWThQQ4Z6QNSnSkYykcDXasP4lmfvOZTSF9q8TDBEFPbN5bOqCglCCCxK0TvvZyIV4CIxbgpC+4gm/PUmFCIE8iJPyME/e8Lon9j4HvyHYLjKSwRCSEUgf9+15mFbx8QS6CZJMzJ9SlBCwX3fJDLG4PX7ykcwkmQmJtpEhWa7g1dvNlSwjwelebz7tAXLolh0p/Fxe9fErK2WDFGEgKjxfNjegX0lDTc/heNuF99/HGEslcKXwyoazWNDdlCr6+DoJgrBzdI0T9rYO6yg2zszMlaKM3Dv5OBzbuyZuzm1B16U4Nzz2f3cFOx0Gq12F9cztpExncsqYoaHpSIKtx0zJdVIFpHQ6py29muNk1uTN829o/6SHEnh80HFaE6NjmLnWxUJy1LyTltB3k8BBgBeEeQTiWRskAAAAABJRU5ErkJggg==');
52 - background-repeat: no-repeat;
53 - background-size: contain;
54 -}
55 -
56 -.ipfs-css {
57 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAk1JREFUeNpsUktvUlEQ/u5DoCLl/RAKKKUvWmIxjYntQtcu3LvwJ/hTXLt16coFC2PsojEaMKZtCqFaTdGmjbS0CG3By+vei3OOBSGXSU7uzNyZ78z3zRF6vR6YvXzzPrMUCyf68bB9zO+VfpROn5hkOdfPPX/2lH/lfiLidztX5mN2jLGG0rKLENIE8liWpdzwP7HvqJqujmvudFU4bFY8Wk1FZsOBtKppd8YCDNu77CZevd3gflfTUFcUhP0ePLibiIR9rjSBpgwAfe4dVcV6dhtep4PH5msylGYLrzeybErcT85FYiH/CyPAf74gObC2vMhzsiRhPhpC6eQUM+EA1pJzILEnjRSuJsju7MJqsUCSRei6Dp3yXqcdGlHZ/rLPazQWGCn8+6YW4pAkEW0SjzUzanWlCa/LgcR0lNfovTEi6lcIkzesnM/R8RlN0INGp3h4DHoDsE5YRvQyiKiRSMzikRAOS2WoqoZWu41K7RwzlOOAVDMMMHhIGvFlRxJFrKYW0ep0IYgC3SDh4b1lTJjNfENsrazOAMAw680mPuW+8lFno1P4XDigRhOiwQAyJK7TbsNS/PaA7giAIAhYz2yRgBIfsVA8wIetPG6FAqhdNrC5u0f+TUyHgyMTDDToEt/ftQsEvW4EPG5OZcrvw0mlimarTXkPfpXPcNlQoGtjACgpryQXsPNtH/nvRXqBJpoKHMzGNkNB0Odls7LNyAYKpUq1dt1iuvB7fRDp9kr9D1xOFwkpoksXusmXaZWFn0coV89r/b6/AgwAkUENaQaRxswAAAAASUVORK5CYII=');
58 - background-repeat: no-repeat;
59 - background-size: contain;
60 -}
61 -
62 -.ipfs-dat {
63 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAfVJREFUeNqMU01PE1EUPe/Na0uptmlASg3MoiZgCA3hQ8PHAjbqwsS9C3+CP8W1W/+BSReyYUPwI4QAVkAgUEgIbVIg1FZb2pl5b3zv2cHBjsaTTOa+e989OffcGeK6LhTevFv+OJoZHPHOfrz/sl86KpWfhxnLe7lXL1/oN/MSZqonOXU/k0AA6lfNhEFIrlAsP2PMyPtr1AscLpyg5pbtIHErhqez4+awmc45nI8FEvwNaiQuBHqTcSxMjJhmX0/Osp1xr878FxWEzwMinxAzEA4xFIpnOjedHTKpYbxW4U2CP4j8uWxmUKsghMCgFI2mFe9QgHZj0Ba4yhFF+KvGJToIRLuPC/efnjD6+26wB1Lq/xgbSCBXKeWJG/OTdky8cWTdT3C9RmWSGk2XCLlWo4xTNbfN5qh7PpXM72GjZeHt0gpq9QbmH4whGb+NpU/reDQ7hcWVVXxvXOHxzCQopQEKXKEbL6o1ZIcy+LC5g62DY2zsHeC0fA4zndIrHOjvg2XbAQRSfsuy9XxC2qzi/H5B6/68W0AsGkW0KyJPBLbDO0fg3JX/CUM81i0bD6WKe6j9qOPJ3EMcF0tSNsFA6g6alqW+VtZBUL78Vtk+Oqne7U9rs5qOQCjSheJFBeFIFOfVujSUYu3rIc4uqxWv76cAAwCwbvRb3SgYxQAAAABJRU5ErkJggg==');
64 - background-repeat: no-repeat;
65 - background-size: contain;
66 -}
67 -
68 -.ipfs-dmg {
69 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAn9JREFUeNpsU01rE1EUPe9lkk47yWTStCmtNhFSWxos2EXVhSsRcasuxYV05V8Qf4DgD/AvCK5EV1oFI7iUBqmCNdDvppq2mWSSzEzy3vPOpFFq+uDNfR/3nnvueXeYUgrBWH1/9/NE7k5BKRnuRcfF2qdnmJq9DeF9tQ+2isuMsxXGWHh/a1mEVsPJSI5fSU3OPEj291IIlN49RXz0KqzEQjIeZS/L5Y/3wPGhDxIM/i/A7fZWgVG0t5EaG0ZUa0JGM8gvPrZmLt58QYwv91mfAqCIE0sAqgumBFITGQzpUYhuF0KfRa7waDyXXXolpVrsh/0tgSLDr5I+wUZo1UHCSkAficPzY6juFSmbRPrC/azjq+fkcO00gAqoU7B0ETKkfWbuCTjTYeq5oESAauexcTScX+ZACWFm0YQSLZKhHdr67+/wW0e0dgjYo3sCEXXybYtBDVSHLp2es3IpsILS24c42lkBg6DzRjgRzCDZ/xr0GNRJwwYiWgzt+hYMawleu0V3wbkT+kUirOc7IGJAz68R/Qak1BAlx3hqASPGBJRXpXOv58dkz3eAgQoOm4hyj57NgZm0MHvpBmK6QdUdg/DAg9cRkhicBSDaKJdeo1bdxmR2DtWDDUxl51HZ+QHTysD3XdQO95Gfv06aeGcAdBrY3Chi8lwO3768QWX7J5q1XWyVSxgajiOXLyBG2hzurRKV9lmt7ISNkkjo6HhNyjoK+2gXRsKE57ZIE2ot10Z1fz0Ue4ABVw3NMjnW14rInh8jTYywoTg3EOFpOM4mXNfH9PQUfGlrAwBOs3I8ljbtuMWhRWzIIPrkn+GcYcgIWEowbZ+0qB334/4IMADESjqbnHbH0gAAAABJRU5ErkJggg==');
70 - background-repeat: no-repeat;
71 - background-size: contain;
72 -}
73 -
74 -.ipfs-doc {
75 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAppJREFUeNpsU79PFEEU/mZ39vZu77g7DokcP04BBSUmiEKCSCxs7Ei00JAYO2NlTKyMrX+CJhaGwopSQ0dMtFEsbDRBgiZEQIF4IHcg+2t2Z8eZ5QDlnM1mZ9+8973vfe8NEUJArfSNhzPG0VIfeIiDRSDkw1cWVt3N8rhG6SdSO2Gvn8dfuueqZwuNZqk3Jxg7iNcIfBbgXD6ZC8u5qffzX8eoYeyDxC77uygKhcouovgVUQj1H4YB2ovNuD9+tTTU0zMVBmG/+C8AIYh8F361DL/yE5HnADKYlVdg6MDAmW7cuz5WGuw+PsWDYGAvbL8ECFUt4K7/AHd/I9c7BLaxinD2Ld5Zo7g78RLuRhlBS2cpWbGfStfhfwCEpK0nUjCbWuGsLciSOELPhkq/YgdY3l6HsLfRcLYf+pHNbH0JigEPkLAyMsiEJ7NrqQzM1i7wyhoMZqOhvQs6Z0ovXgdAJACRoulEg5HOwrOroKk0zOY2BDtVpTF0CU6kLkQJXa+BNEoG0lMSsBBKQXWNQktmoGcaYeSaQCIVWOvUYQAiWZFQtk5mSMoSzEILtBrTfEcviC5bwVwQmoh96wA0ic5dB57ngeoaTIPCdb34zDITYNLOOIeVSsW+dQC+7+NSWx6jJ4tY/rWNV7PfcGv0tBoPTM7M4eKJVgx2FTE9u4QPS6x+kHzfw/mOAjarW2hJG3hy8zIceweuY+PRtREMdzbjzcd5WBqPB6xeRGUMGRzHjWvMmxQ7tiOF1JBN6FiTd6Sy9RuFbHpX7MMMqOD088Ii+op5OUAO7jyeRGfBwrF8Cg8mXuDL4neMXzgFwhwZz+hf7a9d5yu3Z6DTPjVQIY9k7erO7Y63Lvc8ErEeyq6JaM6efjai4v4IMABI0DEPqPKkigAAAABJRU5ErkJggg==');
76 - background-repeat: no-repeat;
77 - background-size: contain;
78 -}
79 -
80 -.ipfs-dotx {
81 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAndJREFUeNpsU01rE1EUPTPzJk0y+WhMStW2qdVWxUVEQUF0I+4ELQiC7lz4N9z0T+hG9wrdZKUgLqulhrbSag1CKpT0g7RpYjqZmffle5NEKdMHlzfvvXvPPffcO4aUEno9f3Vt4dTp+BXOe+fB0u/NbVpv7h89NU1j1TCM8H7+xY9wJwPHZMbOjRadLAvE/2gToJTiTPx89k+OlVd/LT+0TPIPpO/SzyQk40xCMxBSZ9Z3CoAx5DOjeHT7SbE0XSpzwa8OWB9jINELolQg8AR0EgUKn1PIlIWpkUt4cPNxkTOU12trs8p95RiAXpqaztqou8q6SKQJJmZSqGwsodFsIJk1kcyLYv7IeafcLx4HUNkFF4jFTExMZ0B9DrfD4HUEusYhWs4GPEJg5wly/tBYRIOeDhpEwlS34xcyajdQr3UwOT2MlJOEBRuGNHWp9AQRVXDfQiFV/U5GBSiQ5p6ngBEa5z3fiIhC6g6IMDBwOdoHPkYnHPVyhN0tF7E4QSpr94CEOKELffq+y9Bq+DCJ7rWBoQQBVbPR2O6G4OlsLASJMtCZfQqm0NP5IVWnamdAkUxbyuIYtD7wWegb0YAzAVMkkI6NwPM9xEwHloyDGAmk7AKS9rAS0FKOdugbYeAHPu7OPEM+MY7q3hIKqTFQHmC3XcONc/fxdfMDrk/ew/edzyhvvTmBAddocVRqH3Frahau56qpZDho7+PnTgXffi/gbHYmLEvPSIQBp5JU62sYz13G609zKBXvoOMdYn2zgm7Xg2MVML/4Eu3uPgxhk2gXmNl8v/i2pcXTP8tKdTEcbWLZqDQXwu/l6pfwbEnSGsT9FWAA4mdHv2/9YJ4AAAAASUVORK5CYII=');
82 - background-repeat: no-repeat;
83 - background-size: contain;
84 -}
85 -
86 -.ipfs-dwg {
87 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAoFJREFUeNpsU0tPE2EUPfOg006hD4rQh8WgbCSwkKgbF2owujaCiQsXxpX+D6MmbtXEsHCLmIAbE6NLo8YlGIxREIshIqVl+mQ6j8/zFVCb4UtuZua795577rl3FCEE5Bl79vPd5LHYiOP7cH1AUWi85ytmvlas1bJ9E5ryBntH3BpuP/X9i7ovkluuiE8N9SDepaLpCcRCCqa/VDCaMuIjSWP25Upl6n+QDoCz6Yh7KKzh3sI2LuUimPtRRyaqodj0MDloYiITSTi+mH29Wu0AUf9CsZPJoW5czJl48LmCc5kIKo5Al67B9gUGYxrun+5NnMlFZ+GKiQADj2a7AquseLIvjMv5KMaSBu4sWVir+3i8VIVKYSby0UTdFU8Znu8AYBHQgVOJEN5uOXi4UsdawwU0FSf6TaSoyw6DRvukPkgGWpDKy4F8a3jImCrqFDFn6rhKPR4VGnhvOTAY3WLcjifcQAsqRfhUc/Gq1MKNbBh9nIAMDjEppocxs9HCMktfGTCwP/oOBkUKNk/qF3pDYC6Ktk8RfWzyaaoKrqdDaBDwya8W1m0/CPCR3kFy7CcnmWQRUJqcRJFUKtTnPCeR71LwoeYF92CYyVnCFZpCTrRtCv5to2St8SOrKxiPqEEA4fkYT+mI0rdoeUiH1XZVuQPpsIKqw2QmfifTsnOABiWySlH9uU0Hh2MqjsZV5LtpPSoGeN9rKnhBX7ehoOSLIIPfnGONXGMMWN7xUfVldYDbjM3mrh5HCDgS17DhHgDQcIU+XbBxnDTn1x1UuQcJ9iv7l5Q5e1zLGri92EDJFnoAgHtcfr6wbbVXUqq193+0z97n3UJt1+d51n7aHwEGAAHXJoAuZNlzAAAAAElFTkSuQmCC');
88 - background-repeat: no-repeat;
89 - background-size: contain;
90 -}
91 -
92 -.ipfs-dxf {
93 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAo5JREFUeNpsU0trE1EYPfNMmtdoH2kDNmJbaVFcaBVFpAsREQpFwY0bu3HjQnTj1mVd+ANcuC3qQixmry6E0kWFVIQ+bKy2tbFJm3emyXTujGca+4DkwsedfLnn3POd77uS67rw1vC79ek7fZEzpu3AYUqS9tKQGZPLpa3VXP0uFCmJ/8t9OLC3q/uJbcs5bkIybvdHoMsSbLKENRmvU2WcNnTjRFD7ML1WGSPJHI6sA4KRWMAWVDPxLYex3iCmfpuIh1QsFSyMxQO4GvXHHwOJ6XWSyIck8v6HQsnjAxFc7vTj2VwBg4aG78VdBHQFCk+dbVcxMdwev9gTSEC455sIBOu2KLsoJFzqasP9vjCeDBlYqzn4VXXwarGKZN7Crd5QfLDT/7KpBM84c9fFUFjFp2wdk6smflRsKKqMa7EgfJJ3Ac2OKlit2pEmBTQfngdpnupoU7BUtRGiiTe7fXiRqmK+KuDn6TpvYogmBRJcrOwIJLIWxmM+dOsyLKryQAaJpjJ1/AxrGO3SqdZt7kKZJrzJWBg5piHENuY8vV6e0UOye1TyftvC5l+gZB8SHJTwpSx4q4JeTUKaxhXoR57h7Rn+3iFolJ3xvPhab6HgJG/pJ7jsNP4sUX+jZiCgEsWd/DjH5IrSYpBUAr0yHpzSoXKOP25a6OBhndh0zcX1qIYM2RIbu6i0KiHD5B/GTMHG03kTGpEL7H80wHFOWwhqDZ+SpkBOtCDYJDhZE4gRcKNbYynAqbCMbXpwpVPFbEng0aKJGbYzK1p4wIegLlcEPmdt+DjXbzcsxFlCynRwwVAwW6hjqeg0Zt521SYCWCJvbe0Un29UDx7Hgrs3IEitHXkw3jOv2fl92D8BBgAJeyqBh90ENQAAAABJRU5ErkJggg==');
94 - background-repeat: no-repeat;
95 - background-size: contain;
96 -}
97 -
98 -.ipfs-eps {
99 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmlJREFUeNp0U01vElEUPfMFCEVArdoSqEA0KV246UJdUJM2Lo2JK/9FjXu3utJqTNz4D9worrsQExbFpAFT0TYp0CZ8pIAiyMfMvBnvm2Foa9uX3Lw7c98979x77hNM0wRf7ufPsq7Z2SQYw2QJAkDxQalUZa3WI8hy3gmZr15bu+z8kILBkCeRCJi6bufKMji0NhwiCQR6iitdatTvQ5LyOLLEiWcYukm3m4Zhmbq1BX13FyoxuH7xAlbvpqKRK1fT0PWbRwEmDEyiy1QVg/V1GO02tO1tKLEY2PIy3KEAlmJRDLXb0TeZL+n9g4MHlLJ5HIBuYnSzXq+DlcsQLk/D9Hoh1WrIUjlPcpsYGQzS3LWoaBhvKeXWMQCDA1D9pt8PaXERUjwOjEZQFhZQp9L2yERiqYRCkPt/z58ogTGqHQLE1BLgUmC6XGD5AlipBIFKkbhanKHGYLBDqQ4ZED0OAbfLlo8OIxwGvhVgyTHlA3xkomjH/gegBgDURMv6faDbBZpN+/tHkUApkdTA/PwZAPxntwdUyjYA/+ZMqJHjLgM9iv/6zRt2GgMaIE21aVIjnSm0DGPfmhzyde0UAE2Dj+p7urKCPvkZku9eJILOSMUnkvVhIo7GYIB3xSKYdhoA1erXGVKXpvFxZwdBonnD68PQ7YEwM4O4xwMPxc8RYE87g4FIcz+kvfmnA0YzIJIy77/m0OCqsTkkCTysKPjJG3viLei63Gm3kCO6UWqcMejjxecMPmxsoFKtYop6UNirYL9Wtc5OHqzznIXHq1na7OfMJROcK8a6O7MjW7nfzZdrd7jzT4ABACh3NGsh3GcdAAAAAElFTkSuQmCC');
100 - background-repeat: no-repeat;
101 - background-size: contain;
102 -}
103 -
104 -.ipfs-exe {
105 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAo1JREFUeNp0k8tPE1EUxr+ZzvRJO62lUAQaKIQ0FVJFjBBdoIkrDDHuXJi4NnHtX+HCjW408Q/QmHTRaCRRohIJifgiiBICTQu29mHfnc7MHc+MlECKdxZz595zf+c737nD6boOYzxJLC6Nhwej7e/24HkO779s7G6mMjcEwfKZ21+/d+em+RbagaFev28qEpZwzKg3ZckqCPH1nfS8hScIdyhBe6JqTG3PfyTTeLrwFhvbKdy9/xi5QglXL0yGJsKDccZY7LDIAwWHpSferWBh+RN8ni4UylVER8MY6PHj0uSpUK0hxzfTmWsUtnoEwO3rer64jEyxim6/Hy67DXaHExvJX3jw7CX8XjfORUdDlOohhU4fAVjILCPbm9V1yIqK2FgYt+ZmsZcv4lH8Nb5upXD7+hVMjIRQa8qeDg8UTYPU5cTcxSk4nS709XTD53ZhpD+IYMAPj+TBz93fZiz5oHV4AP1fGdlyHZIkIZkrI7GyhnK9CZXy+Aig6p1+HQAY003AcF8AVtGGfLWG9XTO4MLZ5cL0WAixoT4zVmPHADSiMo3hzHA/xgeDWFjbNg8H3A7kKnX0koEcPdTu/ylgRGZgOjNv38zoSXC8BZJDRKOlwGEV0VJVGM0y4joAPO1spXbx6sNHeD1uRIYGUCxVSRlDt1fC8rfvcDnsmJ+dOaLgoAs6AVLZPJJ7WdhEkUyT8GJpBflSBcVKDTvpDBw2GzQqQT1OgaZqUOhtFQUTUKnVTVWNpgy51YLVKph7sqKYkA4A1ScEfT66vm5kC3+ofh6Xz59FQ5bpkvE4QW3M5Apoyorhl9ABIKnFgNdTOh2NkJG6WSf9eRBJtmFwLDJmriUzeaOkYvvcXwEGAIVNH6cDA1DkAAAAAElFTkSuQmCC');
106 - background-repeat: no-repeat;
107 - background-size: contain;
108 -}
109 -
110 -.ipfs-flv {
111 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmtJREFUeNpsUl1PE0EUPbssLYUCXdpaC9gWoSTgAyFigiRGY+KjvuuTr/4A44MP/gx/gMYfwIsan0RjIjGiJIZgSIGFIoXSD0t3Z3dnd70zpITazuZmJzP3nnvumaMEQQCx3jx69SV3a3KWMxetpSgKxP3m242Do43SQy2k/YRydvds67n8a63k+FRSn7l/bdg5tdsAuM3he/5weDC8vLdqPLgIIpba2niux52mg//DqlsYSg3iztO7mczN3DJ3+ByCLgCBH4hOFEF7cDpzPCRyOpaeLGXSc2PL3HbnW3XaRQCPEgWI2MsRVAVqrwbX9bHxbhOKpiJ/bzpDOr2k68V2BtRNzMtqDEqPejY/4zSGjb54BM0mQ8k4xsDoIMauXxnqYOD7PmwScP31d0SS/eAuh1lrolFpIBQNQw2pqJdqsAlIceB1AJCIkkE/FZskXDQVRXw6IYHiE0nBEcaPXSSvJnGwWkQXAE4acAhbxPMJpOdHweoMhc9b2F8zwKizbdlyPLVH7QLg+JKBYzoorxzjz3oRzUoToaEw9KyO8XQW5AE5jrFT6AbAYVVNxCZ0Ka3So+DSTAoDiej5ywTySbls1OEDobhFlMcXxrHw+AbINEjNXgb7y6BndLhk8cRkHHbD7g4gEhiJFxsdhrDqaamBaDKKerGGSKwPI9kR9EZCaNA5ubE7A5s8IFhsrxQkgJhZoa/06xC5xRz2v+3BOjFlbqcGlquxsondT9vY+2pAJdeZR6fI355CgQCN2A4O1w7gkQ7cdLUOAKdhV6uFSv3kd/n8mT68eC8dKWLnY4FsfeZQh7nVVt0/AQYAsf5g+SvepeQAAAAASUVORK5CYII=');
112 - background-repeat: no-repeat;
113 - background-size: contain;
114 -}
115 -
116 -.ipfs-gif {
117 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmVJREFUeNp0U0tPE1EU/trplAqlL0laiw40xASByEJIZFGVnSvj1j+gWxNXJq7VrbrwF7h10cSNhMRHojEuACVBKmH6SJQyJeXRxzzv9dyZPiCtN5lMe8853znf953xcc4hztDzZ1+C6fQMHAfd4/MBFG+p6h/n4OAeAoGNToi/eOm+A50LKRaLh6amoty2vVpZdotNXccMEK3LwZxa2bsDSdrAqePv/mLM5tSdMwYBYqyvw9zdhUn/L59P4OGtG8qlZCoH254/DdCdQBCxqZu+ugqnWoW9swN5ehp2NotgIo6bGQWGtaS8+vQ5V9a0u5S+1gfABEilAqdUgm98HDwUQkDT8JXoPPq+BoM5kCYmFT9jryn1+hkAt7heBx8dhbSwACmTAUwTgdlZ/CVKJaLnI1GD8TikZiPSR8Gxib8chH95mZTxgwWHwH7+gFMswqcokIRbjMO2HDCnZ1VvArpjEmnKZc8+cZJJYGsLsMiZ8AgwEqaY6Mb6RQR33JFhGECzCRyfAFXNu9v+RVNRZWIMuDJNuYMAaDycUFGhCOgtuAtFVDA83G5A8TrFDw+F5QMAxAKJJxz2xnW3RPJGbm+rCyjotZetH4DGzaSSeDA3h4Zl4R0JOEZWTpIzF4n/m995bNdqZwB6m0gFft3Ak6vz+KYWwFsGlqIxXItEcDt1ARMEtKdVgZb+fwA0G2C2hXM0ZTZNRcSf0b1pmXi7uYnjI+Lfanm5fRQsK8BIxKcrK7i/uIgP+Tw+FlREqHN5fx/vyU4uHBE6UO4gDWqk/JFaLuMxcXeFk6TuJ90V0HOk1in7J8AAjmgkPfjU+isAAAAASUVORK5CYII=');
118 - background-repeat: no-repeat;
119 - background-size: contain;
120 -}
121 -
122 -.ipfs-h {
123 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAbRJREFUeNqMUk1Lw0AQnf0woK0ttVqp0hwqVCl+UBERT94F7x78Cf4Uz179DT14F8WbYHtRkBYRLNqDtdaPZLObuLs1NGlXcWDJZGbey+x7QUEQgIqT07PL5WKhHL5H46J+22q22vsWpbWwdnR4oJ80LNiz2czGUjENhvj4ctIE4Wrj8XmPUlKL9nCYcOFzE9j1OKSTCdjdrtiLdr7KhVgzEvwW6krC92E6k4Kd9bJt57JV5vFK2KfRQRV+RAMkzxglYI1RaDy2dW1rpWRjQo5VGicYIorWVooFvQVCCAjG8Omw1MgG8AM0uSBUDSnCfk/IGCHwf3DCD/7UhOLBrFkDuep/hDUSSCv1iYo4rIfqGwmUSNJjfYbBcQKhZw0aBMA4B48LwBhBt/cON80HmM9NQ6fXg/Wlku4TwmNWDzaQqzHG+0PSKod5cH5Vh2RiAhYKc8DlV1UPSyuFMGygVlMg1/P6BC6DqXQK8jNZDXAYA1f21V34wMXYFaiyVw0rJyzLgs3VMkxOjGtix/V0XWChZ0cI2i/dzvXdfTd0Qf91BMPrhyNzgKfOmxaWypqaDXHfAgwAtCL8XOfF47gAAAAASUVORK5CYII=');
124 - background-repeat: no-repeat;
125 - background-size: contain;
126 -}
127 -
128 -.ipfs-hpp {
129 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAehJREFUeNqEUk1v00AUHK/XKf1yZdESVRBXjRSRFqMQVBA5Ic5I3DnwE/gpnLnyG3LgXglx4UDDLZS0RWkDLiRxSusk9u6GXSembmLgWZbX7+2bnZl92mg0goo3b3ffO/ncdvyfjHef6q2Dlvs8Q2ktzr16+SL60jhhZ69bO8X8ClLC7w9XdKJVG8fuM0r1WrJG4gXjgqU1D0MGc2kBTytl+7a9XmWcl1IB/hZKEhccq5aJJ/e3bTu7Wg1CVo7rNLlRhUh4oMnXoDoyhoHGyWmUe+QUbELIa7W8CjAFlMzdzeckCwFN06ATAn8QmDMMMGlMuwWucpoCHNe4jBkAMenjYvRPTyi53JvuwX8AplleAeBcRFrH6rXIxLim9I/pi3QA1RhKaYxdjkN8IwalCMIwWs9ljMkh0wzk+9M7w179C3LZNXxve2h+c3Hu91HeKmD/6zHOLnw83ilB1/V0CeqU3Q81LC/O41b2Btx2N2JVP2riR8eTUxmi0TzBwrKZMsqMoz8MsDh/DWuWhUBKURLKxQIeOMWoptYPnS1c+INZBkwISomOSsmBZS7B+3WOzZvrKGzkMAiGqNy7g+LmRkRfekBnANy2163PZXrSbrQ6vch19Xz8fPDHyL39QzkHBKedXjfu+y3AAGU37INBJto1AAAAAElFTkSuQmCC');
130 - background-repeat: no-repeat;
131 - background-size: contain;
132 -}
133 -
134 -.ipfs-html {
135 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmBJREFUeNqEUktPE1EU/mY605a+hhZTBNKRDApNrWIRA4nEBUZdmCgLNi4MK5f+FNdu3bFv1J1EXODCR1JJSMTwpqUP6NiCpe10Zjz3hj5Mm3iSybl37jnf+c53jmDbNpi9eb+6Ftcisea909bWNzNb6dwzSXKkhIt/r14+515qBqmDA8HpqKagh53XaopblpIbe+knDpFAhPab2Dw0TKvRK7lmNODzePBgZlK9oUWSpmVNdpIU8T+jaMsyMaD4MDcZVa+NhJMN00w0n6V2nN3yQgdHWZag+LzYPTomIAtT0THVtPGanmb/BbjwLFkvn2IttYGYplKyDzsHh7gdmyAWfh5zVq0Guhg4RAHFUhmfvq3j134aXo8bd+ITnMFOOovU5jbGRoZwNxFn1cxuAIcDW/sZDjA/c4u+BNxOJyxqaenpI3z88gMfPn9Hv98HQZS6RazW6kjExvFi8TGdDSy/W0Emf4LS6R8sv11BmfzSwkPcm74Jo9Ei0GZgmkw8QCOao8OXcaz/5vSZnPdnp3ApqBBLkWJE0Ci7ASzbIhCLLQ1E0iOkBDh9NpUgiUejo8oNuJwyn0YPABtn51UYFFivG3yBGCNZkuDtc/MW+ZQI3OrYpBaARCKufk3B5XIiWyhiL5ODp8+FfFHH+KiKSqWKUL8fC/NznGlPBmz+24dZjKnD0CJDcMoyW0SqXuMtHBFw7rhIAD1ErNUNafxKBNevapwu65NpEQ4FqXIA+RMd6VwBP3cPSERb6gLIFIq61+UqGWaFdcrVt/lmAuWjAi2aiMFwmOYuIJ/N6M28vwIMAMoNDyg4rcU9AAAAAElFTkSuQmCC');
136 - background-repeat: no-repeat;
137 - background-size: contain;
138 -}
139 -
140 -.ipfs-ics {
141 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAhRJREFUeNqEUkFPE0EU/mZ2dra7bLNpi2AxQFKalkJrohICiYkXPagXrx78Df4K48GDBzmQePLMhUODNxQ5ciEkJVqDtJGmMWrCATRbd2ecoS5u3aovmezsvu9973vfPiKlhI4XL7c2r5YL81LIELEghLA3u/udxmHnPmfGW/Wuv+LpwwdneRYBx7PeWK0wOYYhcXxyckGV1fdbnbuMsXcklqPRJQxFMKz4RxDCtVO4s3xlRjWoB0FYjlQPEEBieChwKCRGMx5uLtaKs1P5ei8IKlGa/YkXMXYtlTEDlsnw/mMXhBJcqxSK6vlcpa4PEpCooUyIqs5M6hG1o2CUwqA091cFcYLf/sjzcX75EiQIojI9779CTYR4jwTBf+r7GAwh0AxCiL6JMT/04vQ79u8aI2O/7Jzg69o6Go8ewycUahtBpADhHKLnK/eVbkMdtROWIv80NQ2sPhncA9Htwn+9hZG0rY6DzFwJl+7dhs0ZstUy8rduwPS/wd/ehmi3kwq4zTHiWUgXp+EuL8FvNvFl5Rn4xAS86iyI2kY3n0Mv48ByrOQmancdi8I0Kcj3U5iuA29xAelKCUHrEIayzltagG2E4IwkFaQgSC6lYI09iN0d8It5uNV5nG5sgJdKYC0G8WoTOZvBISFNEBxnsuzD3GX4vfDsszzqAu0jkJQDedCGbB6AWg54pYbPo+NGVPdTgAEAqQq70PytIL0AAAAASUVORK5CYII=');
142 - background-repeat: no-repeat;
143 - background-size: contain;
144 -}
145 -
146 -.ipfs-iso {
147 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAjlJREFUeNp0kstrU0EUxr/k5qbJzdPYpGkpsUJoA2q1oLjTdiGiIC5cuXHlxv9BEOrStTvBnQvRrSAIsejCrlqpsURq2hCJNQ+TNLm5uc/x3MmzJh34mDNnvvnNzOE4GGOwx8+t9XQkfn0VE0Y5/7Z+kHm+dvOhtd3P9c/xwNZh7nWaMYtNUmX/Fct/vlN7/8J5aRRgyzm8xzpRDjGE2aVH4VTqdnoUYg/XkEhmy+Cx3DhA5tMzdFolvg5Mx3Fx9SmH0JIg79Zo3j4GADMIokJTKtjbfAKXU4Y/2NvSfyH75TFOxa9Cmr0XnlPFl5ReOQ6wNMDsoFX6AElqQlNV1KsOuNwS/AGFjEUIDhmn5+/DMM16/9igBowAzFKIswPJr6MjlxFP3sV04gaP7RzMPe6xvWM1gNUBM2UKYlBau3QghGphg29J3gDlLLilWNdD3gkvIIDRhD9yGe2mCV0V4HFXuCxT5Dlv8Dz3sIkAs03FalDxBMQSt9BRBMhNncuO7dyU28c9tnf8C/Q0ZtR4GImeQSj8APLRH772BWcgiFODffCv/t8H9tO0v3RjV7VqkeeXLlzDfvYjj88uXhl4JwIsrYxmLY/M1gYclIvGE9jZfNPrSCD3/QgLyeWTADV6wW9AryIcCkB0u1Aq/oCPumlufoF72vIheaLDr4wCLIOqrYnULA14PSoqpSJEAUilZrD77Sv3LK+cI0+Be8cAbbmAOrob0agtD491LYfkoqvnyZLsWRkA/gkwABL4S3L78XYyAAAAAElFTkSuQmCC');
148 - background-repeat: no-repeat;
149 - background-size: contain;
150 -}
151 -
152 -.ipfs-java {
153 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAjxJREFUeNp8U01v00AUnNiOEyepQyhQobRBSlVIoRCBEPTAjQsSEneE+An8FM5cuXLNoQduIAE3qopKNJAIIppA2jrOR93aa6/N8yZuUxyxkrXr3ffmzczbTQRBgHC83nj3ca28dD36nx6fvnzrNNrdp4oibyUmey9fPBezEgWVFuYLdyvlPGaMY4fl1aRS+9pqP5ElAkmcnknRwuO+Nyt5u/ETYfyj9WrpZnmpxn2/Ok1Swn/GvtnH5k4TLue4kNfxoFoprRQv1TzOb8cAIu3+ZD7oD/Hm7XuxzqRUNDtdkuLiTmW5tFxceBXlnXgQTAORSMt2oGezUJJJrK9dFWdEH7Ik4dB29LiESeUEJXd7/dAT3L+1ivlCHr8NEzutXTBvbJPPSdO/AH5wysChwM/1HzCGlmAzOrKxu2eCud6Z2Jke2MwThpUXL6Nn2ZAVFTlNw70bK0iRnGAq9qwHtOmTRpsx1NsHyKRVnNPnoMoK9kc2BjbD4vk5JGV5NkBoEPM4FFnCteJFWOS4ntHEfphQyKaFTWFLw704AJ26ZFx/ZEEi3YyY0O1Dmr4EKTUHA8hUnS6siI0DEHLYog+b28RCRuNXR/iQUpPUEQ+NVht6Lodnjx+GXYgDSFRnq97Ed2pXSlXhUSeGhxYc5sKlNXM5DGLR2TMwfZVPAIi+otGNWy1fEZUKeo4qc4ysI+F8VksLIJfYcD9QYgB/DNPMptWBlsnBIS86xmDMTBo/PWd0LB6VZfdEbJT3V4ABAA5HIzlv9dtdAAAAAElFTkSuQmCC');
154 - background-repeat: no-repeat;
155 - background-size: contain;
156 -}
157 -
158 -.ipfs-jpg {
159 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmlJREFUeNpsU8luUlEY/s4dmMpkWxRopGJNNbiwhk1tItbGtXHr0hcwmvgOdWld6Bu4coXumtREE3ZKu8FgOlC1kIoXtC3jPfdc/8PUIpzkBM7wf+f/hsts24YczuerGUc0moBlYTAYA+i8sbdXtAzjITRtq39kr73s/Gr9DTUYPOeamwvYnHdrdR0SnDebuCbswJGqpX+Uf92Hqm7hzFAG/4TgNr1uCwEJ0trcBC8U0Kb1/PQkHt9JxSLnL6TB+Y2zAIMOJBGLXmtsbEAYBsx8HnqCGKVScAX8uHf5EpqmGXv18VO6VDEe0PXsKABN8+AAgiabmYFNNJTDQ2RUFc8+Z9G0OPR4PKYwvKari0MAgiY/OQGCAajhMNR4nDZMaInrKBGl70SPMScck1NQG3X/CAWLE3/dAWV5hRRVIJxOWNksrP19sFgMqqAebUGYHMI6teq0A9oTVAhqu2sfbYYjsL7lCZ3683gA70T3TK7/B4BNoO020GwB9TpwfAz8LgMtWn/NkV8EHgoB81c7nYwCyBZlEVkHcqMTKFnkmehJTOPvEfCnKi0fAyADJKfXC/h83TaZTJjaa5lANLpOFqAXtlEAorAwO9u5syT5UxLfU0e3o1FMu1x4u7ODYq02BKAMAVSrSNLrK1MhLPj8mNF0vFm+C1ZvwKBwXXE4AGn1WAASazESwUW3BzUSMeJ2o1Aq4sPurvQYSRLwlhRR6mSaYyi0WlpAJrFRx3ouh5/lMt5lv8BLwXp0M4lSpYL17e2uK5wP6lj/c2ZPn2RI+YT8fDvqoyegVLyfG5kBKaQQOfvF2pLc+ifAABiQH3PEc1i/AAAAAElFTkSuQmCC');
160 - background-repeat: no-repeat;
161 - background-size: contain;
162 -}
163 -
164 -.ipfs-js {
165 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RUQ5ODY5Q0NGMTE4MTFFMTlDRjlDN0VBQTY3QTk0MTEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RUQ5ODY5Q0RGMTE4MTFFMTlDRjlDN0VBQTY3QTk0MTEiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpFRDk4NjlDQUYxMTgxMUUxOUNGOUM3RUFBNjdBOTQxMSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpFRDk4NjlDQkYxMTgxMUUxOUNGOUM3RUFBNjdBOTQxMSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PoT8zQ8AAAJdSURBVHjadFNbTxNREP52t7S0bktbKFAvTUVaw60YqkExUTD6oD74qC/yD/wp/gh885XEEI0RAyYQUiMpIBGMkYR6o23abi+73e2uc04v1LROMtnZPTPffvPNHMGyLDB7sbJ2ciUSli3U35smkK9t7x9v7n2dD/g8KUkUwWqeP3vKz23NxJGzgwOx0RC6mSgIo+WKuvP56MeUzy2nJEk8PWsGJVVTuhWbpgmHw47FB7d98Wg4mVWK52o1sxOg3Va3PmFp+Q2PdUquaFUM9/vw+O6cP3bxwm46Xwh1ALR3/vL1e+hGjcc9koScUsTSq3coVDQsXJ3wzo5HEs3clgZNMTVdx1T0Ep7cn6//QRQwMhzA6uZHLD5cIFEFSKIU+G8LK+tb0KsGZKcTJoEyP08AbpcLy6sbPKdQrigdAGaDwWxsDH1uGbliCYIgcM8WFPg8Mq5Pjzdyu4jYbCE44EepXMHuwXe+A8x3KKYxYsjvbUzmlPGpBmYdgI1oYjSMbL4Ao1YXMkcM2Dd2xnbAamPQAqg1GORLZdycmYTdJqFKk2DPR3fmwI4zBDrg9RADqxPAbPBif2WTSB584/3/TGegEOit+DRcvQ4OZJi1LgwIQKVCg2i6nb1I7H3Br3QWqT9pBAP9uDY5xjdSM3RqxeoUkfVnEOW8UkLykERTNXjkM7h3Iw6NNvHw6JjuhAhVrba0+QeALozcI9nQR0VvNxJc/ZmxCNGvIBQcpDG6udA22kyW29HC72wu8yG579ZoiSYuR/ly2+y9CA4NceWLmo717T1i5ULqJNtapL8CDACskxPFZRxLwQAAAABJRU5ErkJggg==');
166 - background-repeat: no-repeat;
167 - background-size: contain;
168 -}
169 -
170 -.ipfs-key {
171 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAlZJREFUeNpsU11PE0EUPbM7u/2AtJUWU6qiiSYYo5EmmPDCD9AH46sx8cEnja/+CB989z+Y+MKPgMiDsYQACcbaWBBogYD92t2Zud7ZlQZsbzKZ3bl3zj3n3IwgItjYeDO3MlWme0bjUth8e8/fO2tHzx3XqUEk50uft+Ndnhdmc3SlfNPkVZT8Cy600DoIISvVfKYtlvfX1p66XmoIYsMZdjJQWvEFbbsC/S5g2QhSkKUK7rx6OzvzqLpsovAhaAxA3DUBQn2TUFsl7KwTfm4Z9DoO5LW7uPXi9Wxpfn7ZKF09vyPxX2iWcNRkKGZz0mQWKoNs8AVB6x1yRY2pYnc2LLofuXTxMgAlmlXIfngCxNxEzM+DPv6NQa2BygLgZyX6JT83ngHTN5GAL0WSoUQkSQnXkyBh/k0GegTAaldM20sTKvet+yyhIZApECamL0jUSe3oFChx3TopM4TeEQP2gc6BgGIwb4KGNXRhCkMGxgg2kJeybRiZM45D8W61qEAknSmpHStBhywu0nFVupSCTAcM4ECwqapv+NQ6LS9JGALoMIIoPYDjZiEL1xHtbyO39AQUDaA7R1AH23DSeSA4hv5RG/VAhxomPYP8sw9A4TaC9iHkjUWmrtGvbyC18BLe3GP0m3WW4I5hEBEnPIStXzyuFIxb4EkMEJ79Qa/xHbKxCdM7xeCwzUZOjgEwnuzt7qLz6T3cySmQP43uzjeIiTJM6io6W19B/NLCKMVGCzkCoLR/0lrfOI2fNy/huKC1FTsK/rbGNeMRC8dHpHByfu+vAAMAL/0jvAVZQl0AAAAASUVORK5CYII=');
172 - background-repeat: no-repeat;
173 - background-size: contain;
174 -}
175 -
176 -.ipfs-less {
177 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RjZERjZENTJGMTE4MTFFMUIwOEVERjQ5MTZEMkVBREUiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RjZERjZENTNGMTE4MTFFMUIwOEVERjQ5MTZEMkVBREUiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpGNkRGNkQ1MEYxMTgxMUUxQjA4RURGNDkxNkQyRUFERSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpGNkRGNkQ1MUYxMTgxMUUxQjA4RURGNDkxNkQyRUFERSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pl1w97IAAAJhSURBVHjahJNLbxJRFMf/wPAIMIxMkUI7tS0VYqlGDLGhjdKkqyZ24cJFN925de+XcONHaHRj4k7TND6SGo1VWwmp2kSLhlqMDbQ87gzPYcY7k4GgoJ6bmdw598zvnvM/95pUVYVma+svcovx8yMnFZHAMJPJBJfDzq5vpX6+/vD5qo/z7DOMBdo/d26t6jFMJ3iY51jBz4M+LP6wxEw40Gy23qYzB3HO7fpmpZCOmfEfa7Xb4NxOrC4lvbPToe2yKE3K1PdPwNOtHdx79ESfq4qKkijB5/XgevIyHxEC24USmewDqD2ABxubaLRkfW6zMqjWGlh7/ByyAtxYnOPnL0Q2+gGGmKRaw8zUBJaTiS5QOO1FJnuIAM8hciaIWHgi8NcSNt+loVDY8JBXh2ojJAR1HbTSNFMUpV8Dxcjg0nSYBrtBxdLbqI1iheCUh9XXNGurAwCdEkb9QyBSFam9TDfoPZ1LUg1BH28IiwEARTVAQOzcFKRaHZpLoa9avY6L1Gfs0c32t4PU6W2lWsV8LAorw0Cs1nXftYWE3qZGqwWHzYp2zzlgetuolVFvtiDLbRRKFTAWCxx2G/KlMtXFhWPqOzsWHJwBx7rxKv2R7mwFz3lw9/5DLC/M4Us2RwV0g3U58XJnF7dvrsBOoX0Abbej/DFKRMKI30fTVGC32WA2m5H9cQQvhYi0vE/7Wdgczn6ARA9QPBrBszcp/XvpyqxebzQ0Tlsq6llxLhe9bD4cFMr9XdjLHpLv+SLGBYHAYiVu1kNOpAaRTWbCejgiw0zGhFGSK1aw+zXbvfK/BBgAPwADAs5GpGsAAAAASUVORK5CYII=');
178 - background-repeat: no-repeat;
179 - background-size: contain;
180 -}
181 -
182 -.ipfs-logo {
183 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAEACAYAAAAjlcdmAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAABCZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iCiAgICAgICAgICAgIHhtbG5zOmV4aWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20vZXhpZi8xLjAvIgogICAgICAgICAgICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iCiAgICAgICAgICAgIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyI+CiAgICAgICAgIDx0aWZmOlJlc29sdXRpb25Vbml0PjI8L3RpZmY6UmVzb2x1dGlvblVuaXQ+CiAgICAgICAgIDx0aWZmOkNvbXByZXNzaW9uPjU8L3RpZmY6Q29tcHJlc3Npb24+CiAgICAgICAgIDx0aWZmOlhSZXNvbHV0aW9uPjcyPC90aWZmOlhSZXNvbHV0aW9uPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICAgICA8dGlmZjpZUmVzb2x1dGlvbj43MjwvdGlmZjpZUmVzb2x1dGlvbj4KICAgICAgICAgPGV4aWY6UGl4ZWxYRGltZW5zaW9uPjY0MDwvZXhpZjpQaXhlbFhEaW1lbnNpb24+CiAgICAgICAgIDxleGlmOkNvbG9yU3BhY2U+MTwvZXhpZjpDb2xvclNwYWNlPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgICAgPGRjOnN1YmplY3Q+CiAgICAgICAgICAgIDxyZGY6QmFnLz4KICAgICAgICAgPC9kYzpzdWJqZWN0PgogICAgICAgICA8eG1wOk1vZGlmeURhdGU+MjAxNTowMjoxNiAwMDowMjo4ODwveG1wOk1vZGlmeURhdGU+CiAgICAgICAgIDx4bXA6Q3JlYXRvclRvb2w+UGl4ZWxtYXRvciAzLjMuMTwveG1wOkNyZWF0b3JUb29sPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KqqO/2AAAQABJREFUeAHtnQecXFXZ/+/W2dmd7Uk2mx469sJfQJHXKKCiiA2UEl+KRiyI8NrA8oIVeVVQEAERUQRRwAIIhmIihBAg1JhGetmS7X1nZ2d2/7/f3b2whE323LlT7sz8Dp+Hu5m559xzv/fO3N+c85znybNUcpLAWauePqpr544HRqLRorzR0ZP+fsYnHspJEDppERABERABEchBAnk5eM45fcpL1q2r3/3E6uuLSoIfiEaG8gmjoDgwOtCy57G6N7z2tFsXLdqd04B08iIgAiIgAiKQAwQkAHPgIvMUl6xeXdqyZdvFI9GRr+QV5JdEw2FrdGTEPvu8/HyrsKTEGhmORsNdHTcuPPrI/7nhiCMGcgSNTlMEREAEREAEco6ABGAOXPJP3P2Pk/vaO64vKiuto/DDtO+kZ51fWGgLwXBXV/fo4MCFSy84/7eT7qgXRUAEREAEREAEMpqABGBGX779d/6c5zcc2vTUqlsDlRVvgfDLGxke3n+F8Xfzi4qswkDA6mtu3lw6ve7Uu0/7+LNGFbWTCIiACIiACIhARhCQAMyIy+Suk+euXVvT8NiqnxaVlS3Oy8sriA0NWaOjo64aQT2rACIQ08Qjvbt33z9v0bH//fsjj2x31Yh2FgEREAEREAER8CUBCUBfXpb4OgU/v6LmDVu+NBIbvrSgpCQUGxy0oN/ia2y8Vj78AwuCQWu4r28o3Nl15UHvOuY78A80G0r0dGRVFgEREAEREAERSBYBCcBkkU1xu6c9tPz4ru1bfxOoqJwbxYif6XSvaTedaeGB1pZ2a9T64gNf/NztpnW1nwiIgAiIgAiIgL8ISAD663q47s2StWvn7Vz5xB8ClZXHjEQieTH6+bmc7jU+KKeF4R9IMdjb2PCf0LSaj9+9ePFG4/raUQREQAREQAREwBcEJAB9cRncd+KMVasq2tdu+GFRcfGSvMLCItvPz+N0r2kvGDbG9g+MDsf6W1r/XP+Oo8679aijekzraz8REAEREAEREIH0EpAATC//uI7+kdvvOCMSDl9dWFpabfv5xWJxteO1Un5Bge0fGOnp6Y90tH/z4a995ede21R9ERABERABERCB5BOQAEw+44Qd4VMrn3rznv+8cGtJZeXhsUgk4X5+8XaUU8IFxcUMG7O7qDiw+J+f+8zyeNtSPREQAREQAREQgeQTkABMPmPPR/j0mjV1u1c99euSUOgDsZGRfPj6uQ7r4rkTUzTAsDH5EIFYNTza07D78eqF8z/xl499TGnlpuCmt0VABERABEQgHQQkANNB3fCYZ23bVtL80CNfLygq+EZhSeAV6dsMm0j5bk5aueH+wWhvY+OvDzzzExfdvHBhOOUd0QFFQAREQAREQAT2SUACcJ9o0vvGR+74y8nhru7ri8vL62IRhHXZR/q2VPTSHt1Dmjh7hbHhAZlWrqA4YA12dHRHerv/Z/nXv/obw6raTQREQAREQAREIMkEJACTDNht82c9u+7gpiceu72kpubNI0NDeTEKP8OwLhRcpbU1tlCD8GIWD7eHf9X+hQgCHZpZbwXKy63Bzk6rf0+zRf9Do8KwMRCCnBru3d2wpShUfurSz57zjFFd7SQCIiACIiACIpA0AhKASUPrruHPvfBC9eZHHvt5oLLq9PyC/AKKLFMBl19QaAWn1VpldTPt8Cw8cqSv1xpoabGGenrcLxaBcCuC8AvWTkO70yyO5jmFo5H9zc3WYFu7NRKDODUodtgYiMCRaGyke8f2B+a86fWL/3jSSW0GVbWLCIiACIiACIhAEghIACYBqpsm37VsWWFw244v51l5lyJ3b1ksHIawMgzrAqFWUlVthWbNsopKSyc9bBTtDXV3WQjVYkUHwxgdxOgdRxRRd2LJY0gXrOZFH6yS6hqrOBSy+Nq+yvDAgNXX2GiFuzqNRyjtsDElJexLpG9P8y8K3nH0xcsXLTJTkfvqiF4XAREQAREQARFwTeCVKsB1dVXwQuCUfyw9vmfXrt+UVFfNdRvWhYIvVD8LYq36VWJuX31iejja6CRTyhzlo+1P9L2qXbQTxrRwX1OjRUFoWpywMf179rSPRqNffPiiC5RWzhSe9hMBERABERCBBBCQAEwARLdNnPfcxtnbVi6/vaS29h0QZK7St1E8lc2YYZXOqHvF1KzbPiRyfy5QGWjZY/Vjytk4BzH9A3EuFJ09O3euDZaWf/S+Ly55MZH9UlsiIAIiIAIiIAKTE5AAnJxLUl49Z8WG8oYXll9RWBY6t6CouIj+dKZ+fvSjK4U/XmldnVVYEkxK/7w2Gg0PWgN79lgDbW2uzouLV2JD4ZHeXTv/PveI48669USllfN6LVRfBERABERABPZHQAJwf3QS917eib+7ZcnIcOzHxaGySqzuNffzQx8CFRX2dG8xtplQ6G/IaWEuQDEt9A/MDwTgU9gzONje8qNHv3nx91EXzooqIiACIiACIiACiSYgAZhoonu1d9pDy4/u3LLpFqzuPZBx9IynSNFOIRZM2H5+NTUWRwAzqXBkM4xQNBSCXIhiWmz/QEwNI9zMntFo7NMP/8+X7zWtq/1EQAREQAREQATMCEgAmnFyvddZT66d2bBq2c3B6TNOgBjKs2PnTbL4YrKG6RdXBh+/Uvj6URBlcqHgZTiafvgIGgezpn8gwsZA9I52b9n8dKBy+qkPnP+ZbZnMQX0XAREQAREQAT8RkABM8NVYsnp16c7VT19aECy9AH5+xW7i+THjBkOwhOrrrcJ9hHVJcHdT1lyUYWOamrBqGAGqDYWwEz8wOhSO9e3aeethJ77/czcccYT5cuOUnZ0OJAIiIAIiIAKZRUACMIHX66SbbzktGo1ejRh6tXZYFxfp24pD5Yjnh4wblVUJ7JH/mmJMwr7GJjtQtWnvOCLKEcFwR2f/QEvztx699DtXmdbVfiIgAiIgAiIgAq8mIAH4aiauX1n8+OOHNz25+k9Yofv6keFoHH5+9VZJTW3G+fm5BjVeYcw/sN0eEXTrH5hfhLAx27bvyCuwzlj2ta89Fm8fVE8EREAEREAEcpmABKCHq79k48Zp25Y+dC3y9n4MmTXy6e9mGtaFo1qM5VeGsC78OxcLfQIRDNqOIWjqH8hpYfpFYhqZ/oGPVB9y0Ol3n3ZaYy7y0zmLgAiIgAiIQLwEJADjIHf+ffcFXtzV8LXCQMnFsCB81IyFH1OwBZG9g6t7s83PLw6UdpUx/8BGaxBZRew0dQYNUQiCvRUZ6B9G/MBfv/ltR1x09YknDhlU1S4iIAIiIAIikPMEJABd3gIn3/ank4Z6em8IVFfNjA1FsLJ12LiF4rKQVVY/087fu3cuXuNGsnVHppVDXuH+pmYr0t9nfJb5hUVWQaCYK427w+1tX4F/4I3GlbWjCIiACIiACOQoAQlAwwv/6ec3LNz56LI7g9Onv3kkgvRtFH6Gq1m5gKFs5kxk8pjuLteuYd+yabfRWAyZRFqt/uZmyw6dY3JyDBsDIWj7B+7YsTUvr+CUf33twmdMqmofERABERABEchFAhKAU1z1Jau3VG57fOnPiysrzoTIKHAT1oXZLYIQfRR/FIEq5gTImSJwEGJwBKLQpDhhY2LDkZHubdsfqK4/cPE9nz29zaSu9hEBERABERCBXCIgAbiPq33ppaP5T9Tf+CUrP/97xeUVoZjL9G0lVVW2n19RKLSPI+hlEwLDfX12NpFwV5fJ7vY+FN4FSCs31NU51NfYeNVx+f97yaWX5o0YN6AdRUAEREAERCDLCUgATnKBT7rttmPCHd1/wJTtfIwmuQrrUlRWZoUw4seAzvLzmwRuPC/RPxABpPswIjjc32/cwlhauWKrt2F3W39r83lPXH75XcaVtaMIiIAIiIAIZDEBCcAJF3fJunX1m5Y+dFvZ9On/BTB5zN3rys+vDn5+0+XnNwFpQv+0/QNb4R+4x6V/4FjYGKtr29Y1RYGiU5Z9/esbE9oxNSYCIiACIiACGUZAAhAXjOnbtqxcdUWgvGIJQosUxSJDxmFd6HcWRBBnpm8rKCnJsMufmd2NhcN2EOnBjnZX16mgOGBFBwdGunZs/+u0+XPPvvvcc3szk4B6LQIiIAIiIALeCBR4q575tY//+TWLe/e0PlhaO+1YjPbZizxMR/0CFRVW5fwF9iKPXA3mnI47gKxLEEsRKfcwPR+x6J85ZcE0MoNNY1o4L1RX/5pwd+8Fta95TbTh8ZXKJjIlPO0gAiIgAiKQbQRydgTwlAcffH3H2o13lM2YfihXmTKLh2kpxEgfV/YGa6flTPo2Uzap3o+ZVwbb2+wVw67TymGxSPeOnU2Rwd7Fj3/3uw+nuu86ngiIgAiIgAiki0DOCcDFzz8/o/Hh5TeVTp/xfis/jvRt02eMpW+DX5mKfwhQwNtp5Vpb7JE+k569lFZuZHS0c9OLq/OCxZ9ccfHFW03qah8REAEREAERyGQCOSMA4edXtO2xVZcVlZdfhBG8QCzCvL2G8eUQaBj5frG6t17p23x+t9tp5ZqbrHBHB2byR416m5ePsDHFRdbwwECsa8uWP7z+Yx/+zA1HHGE+JGx0FO0kAiIgAiIgAv4hkBMC8H3X/OojsdHR6xCUeQZHilylb4OfWWjWbCtQWemfq6aeTElgqLvb6mtssCKII2hamFaOoWNQr7d/186Ln7jqZ780rav9REAEREAERCCTCGS1ADzz6acPavj3o3eUz6x/0wh8xWw/P8NRIdvPb0adhdRv8vPLpDt6Ql9t/0CGjWnZYxn7B2K0lyIwH6u7O7du2R6NRs54/NJLV05oVn+KgAiIgAiIQMYTyEoBeO7atTXb7n/gV2XTZ3w8r6gw3136tkKrdAbStyGmH4WASuYTGPMPbLYGWphWLmp0Qk5auZHh6GjHpo2PlNRUnfGviy5qMKqsnURABERABETA5wSyLAzMaN67r6r9eri17e5gbe2bsLrXOJhzHkZ+gvDzq1ywAPl7sboXK0RVsoMAr2WgohJWYTGYNOMITlnGw8bk5eflIcbjAux/fs1hh09vWLnin5Z12ZTVtYMIiIAIiIAI+JlA1owAvu9XN7w3OjT0m9K6utmM92ZP9xqSZzy5MizwKKmuQo2sQWJ49rm2G9PKdSFsTJM7/0BOCyP+YO+unV3IL3zhU1f97OZcI6fzFQEREAERyB4CGa92zl6zZu72pQ/+OVQ/60hcljxO95oGci4oLrbj+SHnr0b8sueeNjoTO61cG/wDkV/YvmdMamGUmPcM76/OzZtehFfpJ1ZeeulzJlW1jwiIgAiIgAj4iUDGCsBTVq4Mtjy68qpQXd05SPFV6CZ9Wz6mBDnNSz+/gkDAT9dDfUkxAWYRYW7hwbY2+AcahgXCAhGmlYuFB0da16+/LzIcXvzcVVd1pbjrOpwIiIAIiIAIxE0gIx3d3vXTqz4ba29fCgH3dozG2Is8TEf9SqqqrIoFCy0Egran9OImp4pZQYDTuoHKKqu4HP6B0WGz1cLj/oGom1c+e84hxSUlX64+9LBA06rHl2UFFJ2ECIiACIhA1hPIqBHAD/7ud0eHu7pvDU6rW8ggzm78/AqDQQvTxPZCDwtTeSoi8CoCEHaDCCDd19RoRQcHX/X2vl7ganEGk+7dvaNtoLlpyZNXXvnXfe2r10VABERABETADwQyQgl9es2auq1LH7qtrK5uEQK05Y0wi8foiBE/288PU72c8uVoj4oITEWAi4g4JcypYVP/wLy8fCsf2UQsTCN3bt68ZnRk+JTHvv/9jVMdS++LgAiIgAiIQDoI+HoK+JS1a4tnzFlwOUb9bi+pqT0IU3R5fDjDC39KVozjVgrRV4npXk778t8qImBCgPcKV4YHcN8gX+DYtDBGB/dfRu0QM/xFVVo3s64oWPq56gMOPrz+/e+9v2n5cqWV2z88vSsCIiACIpBiAr4VgO/5yZVnDO1qeDg0a9Z7MGVbwJEY09yuAfhzVSyYPxbMWaN+Kb6lsudwHDEuqaq2ikJlFkedudBoqsJ7lD9SMPKcXzFv3usKorELaw8+ONr45BOPTVVX74uACIiACIhAqgj4bgr45D//7TW9u7beFZo567ARPkyRu9d0gQfTt4UYz6+2ViN+qbqDcuQ4TCsXbm+3+hA/0HVaOficdm3b0tTX3HrmM9dc9a8cQabTFAEREAER8DEB3wjAL6xfX7vmrr/8unz23JPzMXpC4ceHrkkpgBN+KXL2liJ3r9K3mRDTPvES4H05gNzCA8gxHOOPE4PCKWXelxjFHm1du2ZVdHTktGd/+tMdBlW1iwiIgAiIgAgkhUDaBeApf/5zQeumbT8orZv+5cLSsgAfsG7isZVUV9ure7nKV0UEUkWAq4S5Wjjc2Wn8Q4XxJykEw50d0faNG2+2wgOff/qGG8xUZKpOTMcRAREQARHICQJp9QF8z49//PGBgcFl5XPmnmDlFyCYs7mfX3Go3KqcvwDir16jfjlxq/rrJCnkSqprrKKyMis2FDFaLez4BxaWluZXzp//FtzzF9YcsHCw6emnV/nr7NQbERABERCBbCeQlhHAT/zjH4c0Pf+fOyvnzXs9AdtTaVOushy7FMzcEZrJsC5I36aVvdl+f2bE+dFVYRBp5fqYVg6ZRYwK/ALpusDSvmHjrkhX26dWX3PNcvsF/U8EREAEREAEkkwgpQLwrGefrdp239Jfl82q/yhSabny8xtL3zbdFn/wEUwyFjUvAu4JjGAEmyKQYtCNGwNHE6ORodGOtWtXRoeHTn/65z/f6f7oqiECIiACIiAC5gRSNgV8zPd/+I1IR9fdZfX1b7RGRvPcrO6lnx+ne7nQIw9+VCoi4EcCvDcDlZUWwxCNxKJmq4Ux8j2K4NEFBQV55XPnzisOlp1fPn9BffPqp+7z4zmqTyIgAiIgAtlBIOkjgMf9389OjlmjvwrNml3PqTJb+Bmyo38VffwYi03p2wyhaTd/EICwC3d1YqFIkzXc32/cJ44G0rWhe9vWnv7dDd94+rpf/sq4snYUAREQAREQAUMCSROAn/z3v+c2Pb7qbxVz4OyOo3B6zDSQM/38ypC+jZk8NOJneCW1my8JcHRvwEkrZ+gfmAf/QNvNAclH2jeu2963p/mTL9xwwxO+PEF1SgREQAREICMJJFwALlm9unT9/UuvR0Dm0zCCN5bBwzCeHwkWIZxL9cEHWwWBkowEqk6LwGQEuMK9H6OBA60txj+EOBLIXNaRvr7RtvVrl0faWj/5wi23tEzWvl4TAREQgWwjgEEjrpQLwSgICmH0AeOWr/Nv5oZlKC1uY+NbrsTrww9phdgCiP2VhArAd/7gRxeWVFR+L1hbW8Z0WGN5e/d3+Fe/F6ypsaoOPOjVb+gVEcgCAgO7d1ndEIJuClPS0QZaWiJtGzdc+9yvfnmhm/raVwREQAT8SAACj+JuOqweNhd2IGwWbNq4wf/LqoCVwij48seNf1O/MFvERKMQDMO6YR2wVlgbrB22FcYFdo2wVgjELmxzuiREAB500klvmX30MX+pXLBgPlc/uvHz25u+BODeRPTvbCIwiAwiXdu3xXVK9A/kavj2jRs6Nt/z97P2PPPMPXE1pEoiIAIikGICEHsUb/Nhh8DeMm6vxZYCsBwWgCW7UCD2wCgOd8H+A3sGtha2FaKQQjFnCodSPZfaw17zVMW8+fmMgWbq5+f5oGpABDKQgJfPB39YjWJkvebgQ2sWvPu4v0MA8ot0cwZiyJgu43oxxdC3YHNgHGnwa2HfIuPGKTA+6HphdBngCAhHO/jQ2wNrx4OO02UqIpBUAvj8UNi9AfZu2HtgFHwc3UtXoeapGTdONS4a78ggts3o73psGZh/JewFfE44gpi1JSECsOaQQ/Pp42RZ8Fr3XBIyKOm5F2pABJJCwDDg+b6OTQHJz1rNoYfxg1K2r/38/DrOgX3nQ6EC5kZUcQSBX9TP44s5Vf499DU6FcaHRSYXCsIBGKfGGnENOB22CfYMbANsB5hy6iwjCvo/Dx3laJKb+ycjzs1DJ/n52IPr+KKHNjxXxbXh9OzbYPzcnADjZ6cY5ufCH3oLx+1EbPkDaTfO5TFsH4Q9Aq78zGRVSYgAZHiXvIJEiD98mqOp+l7Pquuok8kAApG+XjtItPeuInbg2MKqxHzovHfIbQsUVQxvcwTMzTlQOPJL+FhYKhfDGKZ3Qa/8W/hdT8FNo6/VkTCndOKPnXjYcaX5Q7An8LDb6bzp0+3Z6Nc3YW7uH5+eSsK6xc/HzbAlCWvRRUO4f+qw+4dhn4AdDcvklZwUsfPH7XRs23B+j2L7V9iD+Hw0Y5vxJSECMJEUIr29iIG2zULAaKuwJJPvn0RSUVuZTICuEf3NWAGMcDDjwi2TTydRfed3D4Wg25IKPyG3fcr0/eloT3sjjOKhZVwM/g1//xMPu0Zs/Vb4gI7n/vHbeSS6PykfxR0XfotxIrx3Dk70CfmkPU5bf2Tc+GPpbvz9B9iT+Hxk7I8Q3wlAgMWDstUKd3dZZTNmWKUz6uwVkACtIgIZRcCOAYhFH/17kCPYdpHIqO4nu7Pxfmlqyi/ZV8ayZuAQJ43bLnwnc7HRrXjQrUz+oY2PEO/9Y3yADN2Rfp8pKbgvuIL307DPw7JV+E3Gch5e/CLsXNiD4MDZjIfw+aCbRUYV+gz4stDhvbehwWrfsN4abNfIiS8vkjo1OQFmAenssDpe3Gj17Nop8Tc5Jb2aGQQ4XcwH/MN40N0J+6/M6HbO9rIvFWeO+4BuGP+AXQnLJfE3ES/9Bj8Eu5cGJidMfDMT/vatAHTgRQcHra6tW63OTS9akW76L6uIgH8JMO1b5+ZNsM0M4OzfjqpnIuCOAP1xPgZ7YFwIvtVdde2dIgL9yTwOrn0l7Aoc458wikCVsfiE7wWIf4DNn2CvyxQovpsC3he4oZ4ei/6BCDIN/8BZ8g/cFyi9nhYCdqYP+PkNws+PsTBVRCBLCRTjvCgEj8OD7ufYXo2pL4aZUfEHgaQJQFzvg3CK18He449T9V0vqKe48nkd7D++690kHfL9CODEPuMGtB3pOzAtTKd6+lipiEA6CfAe7N+zx3ZV4FbiL51XQ8dOIYFKHOs7sKX4Xn5nCo+rQ+2fwOD+347vXVzjd6MmR/0k/vaPcABvc2o8I4pvBCB+RRoDi8E/sGfXLtvHKtzZiXryBzaGpx0TRmAILgm2n9/OHRZX+poW3utu7nfTdrWfCKSBADM63A2B8FmY+Zd4GjqaI4dMuADEdT0R7O6AHZgjDL2c5mpUfsFLA6ms65spYD4QC5DmagTxzWgmhT5WkS2brZKqKiuEaeGisoyMi2tyqtrHRwSiAwNWH/L5cqEHvhyNe+YIP9ZxU8/4ANpRBNJDoAqH5UrIw3Fffw33ObMCqKSeAL+MEjoFjOvJEb+bYcyeka7C+4kjazSutOXUH43nWwSjjuGWVgpLZ/y4v2bS/e8bAUjRx4ciRWB+fr4Vw9Sa0UMSdTgKGIGPYHDadKusrs4qCChUGD4EKgkmwJXpDOkygNAuI0jJZloc4cf9TX/cmLat/UTAJwQ4+ncBrADf2xfhnldE/9RfGIqihAlAXMcj0d4fYNNTcCo9OMZO2BbYtvG/d2PL1IVMY8jzcgQgR4icUSLOYk4UgBwFYn9njm9nYMuRywWw2bA6GP1Yk1E4HXl/MhpOVpu+EYA8QQq+KB6sFIAUgvy3IwynAkDfKz6cOSpTVjfTKp0+HdlJCqaqpvdFYEoCDN4c7mi3R/2i4fCU+0/cwRF/vJdpKiKQ5QQYHy2Ce/3ruPfNfyVlOZQUnR4F4GAijoXrV4t2roVRSCWjUMytgT0Oe3T8b6axoxBMeMH5cFSQfqv1sMNgb4FxJfuhsFmwRLgvrEA7m2AZU3wlAB1qFH20iUKQI4ImhasxGXuNQjA0a5YVqOTshIoIxEeAoYf6mhqtIaxAd1MmCj+N+rkhl3X77sAZcfQiEQ+YqeDwFy+/02kcCQnB0jEdchGOy/P+BUwltQQ8j7xCLPE++hGMIinRhbmn74b9HbYB35PuflHH2Zvx4/BYHFF8Dnb7+HlytPBw2FGwd8LeBKNIjKf8BcdxRibjqZ/yOr4UgA4FRwhyNLCwsNAWhaYPU/oHdm7aNBY2ZibSygUZs1FFBMwIcKSvH8JvsL3d1cidhJ8Z3xzZiw+Dz8Eeg6VCAPIYnBLjA5y+UMz7Ow22YNw42sGH3QEwisNklsvwgH0Gn4cVyTxInG1zlIbTdWSVTaUHJ0PzWk5BA5/22she9Zfh3xxRvB/3BH8Qpb2gHxxVah63ZbhfL8ffHA1kHuPjYf8FOwRm8tltwn4PwzKqpFwA8gFZXF5u8QFrmh6Lo3+s59Y/EBfUDhsT7uqyU8oxtVx+Ef1EVURgcgL07Rto2WP1t7RY9PkzLbw/aSymP1KctvPg8lBaU2PHtuTiEtPRbqe+tr4mMID7IhEP5YScJL4Ty9HQbNjbYcxc8A7YHFiiC6dersHxjsf5tya6cY/tfQ31l3psw2/V+eVDHxNPI2q4Xrxul8BMRA92m7Ksxx7fhd2F+8D8C3XKZhO/A/pHfg2wO2njLI7E3yfD+Fk5ELavsgz1d+3rTb++nlIBWBgoscrnzLZKqmusKMJm2CMsHVhJieneqQouRvz+gXio9zU2jE0LYzSwBA9bPnRVROAlAri/uJiI073DWOXrpuCDb4s/3qM0NyWAH0OhWbOt4goO1sA7OVRu9ezeZUWQUcRtW26Oq31TRsBXXzS4V+nLsGHcbsI9xumuD8DOhB0LS9SDH01Zb4R9GfZN/sNHZRgcEuIr56NzSlRXzkFDr09AY/wi/DXsW2Dttx8ARqeHfndhR/5QYKzLWmw5KngGbBGMLhZOoYC5y/lHJm1T8uXEVbnls2dbtYcdBvEFjnhgFpaUWJULD7BqDj7ECow//EzAcXSFC0VYnBFBk3rcx04rt208rVyvb36Um3Zf+yWJgO0uwPRtWza7En/4grD9VNkt3pduBFtRSdCqXrjQqjn0sJfEH9sphCDka5Xz5ln5cHtQEYFkEsA93AS7Ecfgw+3DsOWwRBbGB3xtIhtMQFuJFLkJ6I4/mhj/MXB+AnrDX9Bfgp2Heysjxd/eDHAe7bDb8fqHYPyh9AsYp49ZdsIesf/KsP8l/QlTBN+7mkMOtfKLiydFw5GPajz0wkih1YfsHqarLJ1pYS4UcesfqLRyk16KnHsxNhTGPddsp28zGYV2AOGLIO7p3kL8GCpDOsMgVqrn7Uvg4Z4Ozqiz3Rci4z92nGNrKwLJIIB7mtNzDOj8T2w5CsRRu0RMDXPk5Kto9xwcY+qpHuyskjYCnOpc4PHoFH+fx7X+ncd2fFkd58WRzWdouKeZCvECWB9eb8M240rSBWABRvr2Jf4cWoBnBRG2JVBViVAuLYizBv8rgwcfLoDtL8X6zmgghSFfn6pwnwGIzjBWeYbwMObxNeIyFbXseJ/31mBbK9IJNlvMKuOm8F6j8f4xuc+ctnlvMTRRGYRdAX4MTXWHjo5iRNGprK0IpIgA7u0IDnUd7u1/Y3st7F0wr+XjaOBq2NNeG1L95BDA9eYIzSc9tk6Bz/A/WSn+9maD89yK1y4Au6TrqL2Pnah/+6rj+UXF8BGcAx/B6rHQG1i8YfKQ5T57xw80daSnoz99rgYR5y1UD/9A+CdyilolOwkwPFBfozc/PzeLPCgWA3tlqpGwy857K5vOCvftenyvfgTn9EvY6R7Pjf5SZ8MkAD2CTGL1t6JtLnjwUm5GZd4vOVXwWRnzScvAs/aVAHT4MaVb9UEHW0NdnVYvH9ZwiDcpfDDT4gkbQ8f/zi1bkFau3SpDWrniULKjJJickfZJFAHeQ1zgwRXh+FVh3CwFHI0/MtwIPx6A93E5Y1FWVRsfTzuKgF8I4L7vwn3/WfSHo0McxfNSPoS2vo82Hb8pL22pbuIJMN9viYdmORr2TVxf8y9XDwdT1cQQ8KUAdE6ND87i8gpM1WK6bs8eK4aVwybFi38gBQJ9BIPTptlTw5zCVslcArEIVps377HvoVHDYOI8W4o+Gotb4cdFT0xJWIrUhMpGYyPU/zKUAD4DfRBun0f3D4C9xcNpzEXdd8Nu89CGqiaBAK4vdcAxHpv+Ce4ViXuPEFNd3dcCkDD4AGVqN04L80FO3y2mfZuq4KZ+hX8gH+Z8kPP1qQoXBAwgDtwQwoLw2PIPnIqY/97nNeS9wkUepj8cnLPgwiIW3ism98tL9XCv2vmoZ9LPL+C8rK0IZDQBfHe24nPAcC73wbxMjXCUSQLQf3cDF/swQHi8ZSMq3h5vZdVLHwHfC0AHDR+oFQiNEaytwVRekx2zzXlvf1s+wOP1D+QCgZf8AzGVZ/sH7u9ges8XBOg60NfUbEX6el31hz8SaG6FHw/CHyj0IS0q8/J8dNVd7SwCKSOAz8Wj+Fz8HgfkaGC85Ui0UYu22uNtQPWSQuANaLXOQ8t34pp2eqivqmkikDEC0OHDByz9A8MIIO0maC9H/2hx+wdu3mwLQPp0FZaWOt3R1kcEovDjtP38MHJLEWdaKPporON2urcI90IIPqMMLq4iAllOgLHPPgFjaJd4yjxUOgT2eDyVVSdpBF7voWX6Zd3job6qppFAxglAhxUfuIFKhI3BVC1TdyU7rRyPyxWkEfoHTp82Fs4Dvl4q6SfAldycsu/HfWASPsjpsSP8+G+KPzeikaFcShHShekF5efnENU2mwng87IRnxFmRoh3VTAXkzA7iASgv24U+nfGW7agIjPLqGQggYwVgGTNBy+n3YIQgxz5GWxvT35auVjUjh8X7oB/IHy95Oifvruefn72SDADiA+6y+zkiD+3wo8pBIMI5MxRPy72UBGBHCPwZ5wv48WNOcq6P/nXua+iGskigO8/Xsf5Htp/Ad+l3R7qq2oaCWS0AHS48UFcuWAhhGCtLQS5itekONPCdPrn1DDFgGn8QK4u7dm50xYgIeQXDsAHTCV1BDgSS9Fveq2dnk0Ufm6ne5mykMLPydvrtKmtCOQQAcby42rPWXGe88H4nsXHUOFC4uSX6GoVaHC2h0Y3eairqmkmkBUC0GHIB3MN0soNjgf7NR0VcoRgPP6Bdh5Z5JAtQciakPwDnUuRtC2vaT9G/OzR3hT5+RUinSGvbVBBwpN2XdVwxhBoQk/XwuIVgDNRl07UZsFdsaNKUgmUo3UvK9cY/08lQwlklQC0rwGc+TkSGKhgWrlm2zfM1C/MiR9IIchRQf6bo4JTFe5D0TnU22P7BpbCLyy/qGiqanrfBQFeQ/p6Mh6k6fV0mo87rAvTt+FaMhSQ0gQ6NLXNZQIYuYvh+24dGBwfJ4cq1KuESQDGCTDB1eiXSYu3ILK+SqYSyD4BOH4l+MAunz3HHrXpw4gRfcVMxVy8YWMoTHobG8bTyo2tDKXPmIoXAqO4dgzr4i19m8m1d3rJaWIuMuLUvlZ8O1S0FYGXCNDxP97CtHA0FX8QoPiL15mZoyMS8v64jnH1ImsFoEODD/CqAw60hmqn2SIi0msWG87LtHA0HLa6tm21Am1t9tShfMacq+Fu+1L6NoR1cVMo4GgUfW79/IrhQkA/P64wVxEBEZiUAKeB4y1BVKSp+IOAlxFACsBhf5yGehEPgawXgA4UPtD5cB+EKOPUMEWaSXGmhTmNWIhRRUcYmtTllHDkxV571WgZR5PgS6YyNQFm7rCn71tbjVZ1Oy16EX6FSPlnZ31BCkCN2jpEtRWBSQl4GfUpQIs0FX8QoAaId5qK9ZQr1R/XMa5e5IwAJB0+2OnTZaeVo38gBIaJPxlHkhwhGI9/4ABEJ3MM2/lhETtO/mST36vM1ctrYud9xiprN8WTn9/06WN+fvLbdINc++YugQGcOvNxxiPkmGA7p547Pr9NOIIXhcU7DazwFz6/wPvrXk5+ELlAo3zOXPh5IWwMfPbChlOMFIKe/AMbxo5lZ45g2BhMU6qMEeA16IefX6Tf3eDCxFE/N35+PKqdvm3WbIvZPFREQASMCVD8Tb06bvLmWG9k8rf0ahoIOAIw3kMviLei6qWfQE4KQAc7H/xpSSvHsDHKHWtfhmGmb3Mhwp1rN1H4ufXzU/o2h6K2IhAXAY78xfvrleKPAlLFHwQ4mkuL1+n5Tf44DfUiHgI5LQAdYE5auYFWpBNDmBG3aeUc/0DTsDE8Lke8hrq7rdLx6cdcyyoxEonYrAfazKbhnWvlCD/+263wY/o2exp+utK3OTy1FYE4CDDGVbx+YxKAcQBPYhWusKPVx3mMt2DmpQbfyx1x1le1NBKQAByHz7RyXKhRgmC/TqDhEfikTVX29g/kvylMTKYjmcqMgpNisGzmzJxIK8dzHuxox3Qv0rcZLsRxroEj/sjWhK9TLx/XlunbeH1zTWg7DLQVgQQS4Gq2eEcAI6irlaMJvBgem+pD/RbYa+Js5wDUezvs3jjrq1oaCUgA7gWfAqFi/gKrhGFjMDXJUTqTQkESr38gRxzttHLIZVyG3MYUodlYhrq7EIqnyTINxeMwmCj83I76cfV3CH5+xSEvwe6dnmgrAiIAAl4+TJxudOfoK+RJI4Dv1hE8uzbiAO+K8yAcCT4HbdzHtuJsQ9XSREACcB/gKRhqDj7EHp1zE4SYAoUWV1o5LICIbB73D8yixQlM30bhx5E/DN3tg/irX/Yi/F7y89Nim1eD1Ssi4I0A88fGWyj+KAJV/ENgNbryWQ/deR/qLoI97KENVU0DAQnA/UEfzwjBQM5MQzbQ0mLFhs1mL+ING8PucEqYo2Sl0xieBGFj4LuWiWUErMisH+xMwu045+gIP/7b7YhfAVZ4M9RPqcLtODi1FYFEE6jz0CAFoEYAPQBMQtXn0SYD48Yb048uAd/HKOBqfHebTZkl4STUpHsCEoAGzBi3j9OInJrlSFYYI1mc8p2qcB9OC1PQcESQ/6agMalLwWSnsEOOYfqu0YeNfoqZUOjnx9R7HDlNlZ8fGTOsTwhT6Aq4nQl3ifqYwQTmeuh7M+q6C/Lp4WCqakRgHfZaD3uz0d6T73QUXr4cz7Yv4rt4auf5ydvQqykmIAHoAjiFRdUBByCtXK29UGSop8eotiMEuVqYQtCZJjapHEVWjO4d2+3p03L6smE00s+FI5cUfqa+k865UMDRHJHsvG6yDYAJRbLSt5nQ0j4iED8BfD75K/Sg+FuwduFzPvWvZw8HUFV3BHA9+nFdH0ItLwKQBz0P1oa2/hdtyh+QRHxeJADjuEAUGhQdg1i04WaUyxF+cfkHQlh1vLhxPH7gLIs5jv1UONLX39yMVHtI32YwOur0naKPxjpup3uZvo1BtTk6qqDaDlFtRSCpBGag9QM9HGGbh7qqmjwCf0XT58PinQZ2evYt/FGJ7/NL8L3OFcYqPiYgARjvxYFoCSJvLMUgfdwGkcIs2f6BFEmDmFrlyGMZfNzo68asJsaFIgtTy1x1bPvkOUIN58JpbsbJs9PU4d+mhe0wfdsAUuuZnr/Tdrzp2+jnF2T8RPr5uTl/58DaioAIxEvgjag4O97KqMcVpyr+I/AUuvRv2HsT0DUKycPwvLoIIvA/CWhPTSSJgASgR7B2WrnZc6wg08ph6pO+bxRqUxXus3fYGDf+gb0IUcNVtXZauZoaO8/xvo45jNXFnJKN9PZYXJHL+Ib005tYmCeZ8fI4zV1cXmEL26Kysom7vPJv9D8M/8Q+jPqxfTdl4qifCSunbdZj0G6es/z8HCraikBKCZyIo8UbBLoXdV9MaW91MCMC+G6N4rv4eux8HCwRzubHo51laPP/sP012mewaRWfEZAATNAFGfMPPNAasvMLM6et2ei3My0cl38gpl27tm21AuNCsLi8/OWzgUAb6um2V+FyxHBvwffyjmN/8f0YDSt3uT/FLKe5OcoYqKh8xRTrcF/fWPo2wxiJzrEmCj+3073FZSEsxJllBaqqnOa0FQERSCEBPMyn4XAUgPGW3ahIU/EngX+gWw/C3peg7vF++THsdNw7V2P7VzwDlDEkQXAT0YwEYCIoTmiDAoVCbLC9zfaJ4yIOk+KM/jlp5RxhaFLXHt2DaAsibEwIGUWQJ8Pqa+AIYfyfNXslb1eXFYYFOeqGUU4KOGYuYcq8qQTlxH57EX6FCMzNLClBBObOlFXQE89df4tAFhH4AM7Fi//fc/guUJgQn94QuDYRCLUfoHvHwhLpZE63gRthX0H7f8D2b7B1ON7UU2XYUSV5BCQAk8CWQoVx6AJV1WPxA+EjZ/vcTXEsfDisifEDKZwcYThFVXvamcKM07IsJsebqk3nfcfvkAstGNvPTYnXz4++iMyTTI70TVQRARFIHwF8N3FxwGc89kCBgj0CTHZ1PHNW4FpfheNckoRjHYY2vw/7Bmw5jnMvto/ANuG4UWxVUkxAAjCJwClcyufMHYsfCJ+9MKdMIfKmKhSCe/sHUhialEQKv4nHc9suxSuN50IzLqhTMp6+bb8+iMYNakcREIEEEPgw2jjaQzsc+XvcQ31VTR0BTtseA+NIYDIKUwl+cNzoK/UcnhErsF0JWwPbLUEICikoEoApgEwhU420ckOYTuXiDdNFE840cDxhY1JwWpMeYqLwY//dFHJirEP5+bmhpn1FILkE8HBmcnKOCMW7+IMdfAKmBSAk4fOC7/AeXPMl6OZ9sAOS3F2KQYpNGgsXi/wHx38S21WwF2A70CczXyrsrGJOQALQnJXnPR3/QCc9GsOxmBRnWtjxD+S/8QExqZqyfRzhxwO6FX4cKXXC2sjPL2WXTAcSAVMCl2HH15vuvI/9/oTvCE3z7QOO317GtdqIZ8zZ6NedsOkp7F81jvXOceNhuXJ8wwRB+Dz+vQX9Uz5p0vFYJAA9AnRbnQKnDOnKSqqr7VRvDCZtsqCCgs8Rgm7Tyrnto9v9HfHHPtJMC0PPMIhzCFk8ChDUWUUERMBfBPB55kjQeR57tQv1/+mxDVVPMQF8rz+C638GDnsLzEv+Zy89Z2iL/zduX8B2ELYZ/eIIIV0KnoXRh5BCUcUlAQlAl8AStTsFT+WChbYAYn5h09RpFFiOfyBHBE19AxPV773bYR/YJ7ejfgygzby9jDmoIgIi4D8C4w//n6FnXp8Tf8ADutF/Z6geTUUA1+1B3AefxH6/hS2Yav8UvB/EMTgaTTsXxqnh7ejjU9hyyvgZ2Ab0m1PJKlMQ8PrBnqJ5vT0VAQqgGoSNCXd02rH3hgfMRrbdCq6p+hHv+277UYQUdmPBqznSnxfvYVVPBEQgSQTwMOVz4cuw78G8Ds23oI3fwFQylADE1HLcEyei+9fDOD3rpxJAZw4dtzOxZZiKBvR3Nbb0O+V2HawV52E+PYUKuVAkAH1xlccyXBQj8PIA0srRR9BtWjVfnMZ+OsH0bQwqzbAudrq5/eyrt0RABNJDAA/O1+LI34V9NEE9+C0evFsS1JaaSRMBXMP1uDdOxuG/D2M4oKI0dWWqw7JfC8bt49jGYHtgz6D/HCG0VxrjfNrwd84XCUAf3QIURiGsgi0ZzyYSRoYP3LQ+6qH7ruCDZp8Ps3gUys/PPUDVEIEUEMD3zCE4DKfUzoExg0MiyiY0cmUiGkpwG5n9pZpgGKbN4buc06pfwL3yILY/gL3GtG4a9yvAsWeN2wexpSDkCCHF4MOw5bDNODd3IStQKRuKBKAPryKFUtUBB1hDtTVIuYa0cki9lomlODSevq2yKhO7rz6LQFYTwEMwhBM8CkYfL47uJEr4oSmkI8JoER6sHH3xWykbP3eKg0wv9KMZBOeUhUnBsf4Gfo/huBfAPgtL5H2D5pJaeM3njdup2PbAHsf53IvtfTi3rdjmTJEA9PGlDkA40UdwsI1p5Zos07Ry6T6lsfRt9UhNh/RtWCSiIgIikH4CeMjx4ceQHm+CHQc7HvY6WDI+pLej3T/C/Fh+gU79EJaM8071+fKa/gTGXLspKxBKrTjYt3BP/QlbCkG6DNCxO9MKVyG+d9z+F+dzP/7mfbsc58gVx1ldJAB9fnkpoOg7V4Icw/3wDWS6N7dZOVJ1imPp22Ygpt8MKx+x/VREQARsp/SUYsBDjN/rAVgtbDZsLoyi7y2wN8IY0iOZK7DWo/2v4AFKh3w/Fp4/LVtK2oQXrvEaQPw07rkrsV0CoxCcA8vEwpHMxTAuJuGo4HXY3oNz7MI2K4sEYIZcVgqq8jlzbCHYvXWLNTyUshF/I0JFgYBVecCBVhGmfVVEQARsAhRZ38CDZOc4D/oZ0eiHNHHrvL73ltOozmv8e6KxbUfo8dcWBR99LSgGaBQ49H0qg9ExPlWlAwf6PB6ajak6oI5j3yNpxYDrvRYduAD3+o+x/TCMbgWM3+d1FTmaSHnhZ+vt4/bCuLj9M87RLERHyrsb/wElAONnl5aaFFjFCBvjNwHIPkn8peWW0EH9S4APkg/4t3sJ71kfWlyCB+XyhLesBjOCwLjwvxai6QZ0+K0w3v/vhTFuXxCWaeUN6PBvYRzl/BHO7x+ZdgL76282+EDs7/yy8r0RH64M9mOfsvLi66REwJ8EKP6+gAfkXf7snnqVSgK4D6KwJ2DfwXHfOW4XYXs3bBcs09ICvgN9/jtE4K9h8/F3VhSNAGbFZdRJiIAIiEDaCOzGkT+Dh/0/09YDHdi3BHBfRNC5p8ftSggo+qYeDuMUMada3wabBfO7HuGCm0/DjsM5XILz+iP+zujid+AZDVedFwEREIEsJ/AUzu+zeBg+m+XnqdNLEAHcK+1oasW4OYKQMQUpBI+GURj6WRAuQP9+DxHIhVWX4Xwy1jdQAhBXMNMK8+/6rfixT35jpP6IQBYR4BTeNTDG+uMDXUUE4iIwfv88iso0Jj/gCCEF4ZEwRxDW428/6RX25WuwQ9HfczP1M+AnoGCpYkKgACtu/Vb82Ce/MVJ/RCBLCDCLAoVfVjnEZ8m1yfjTmEQQMjzLZIKQU7LpLiejA+UQgf+Nfu9Od2fcHl8C0C0xH+xfFCq3cLP5Jk0c+8I+qYiACGQ1gQ04u5/BbsNnvj+rz1Qn5xsCuNfa0JlHxo3Pven4e29BOBOvpUsQvhvHvg39+hj62oq/M6ZIAGbMpXq5o4XBoB1oOeaTWICMUcg+qYiACGQdAcYhXAm7CcaguHwYq4hA2giMi6x/owM0CsIZ2EwUhEfg36kWhFzpfAP6shj944r4jCgSgBlxmV7ZSWbcCFRUICuIP35ssC/sk4oIiEDWENiGM1kKuwv2KB5qQ1lzZtl3IqkM9O07erg3W9Ap2nIIMMbe5Ajha2FcYXwsjIKwBpbswgDYl8K+kuwDJap9PbUTRTLF7ZRU1/hGALIvKiIgAhlNIIzeb4I9BrsPthIP1mxd3PE3nN9mWLqmDHHohBWew4qEtZbhDeGeZbYcRxAugyC8HP+eC2Mcvw/A3gPjiGGyyhdwTOYRvjdZB0hkuxKAiaSZwraKkRGkqKzMGu5PrysO+8C+qIiACGQMAaai64Ftgf0H9jjsSdgmPLjS+4WCTqSg/Arn+UAKjqNDpJkArjPv9e3jdivEGYM4vw92OuwYWKJDajD13RU4zpM4NoWor4sEoK8vz747l1dQYIVm1ltdyAuMm23fOybxHdzgdh/YFxUREIFXEaD/3G9gHEljbl7m6OVwOcNcVMHoOMsl/fwe5oeIxiksr4UhWmgRWBdsF2w3rAHGkS8u5qD424PPcC5O7TJ3skoOEsD9vgOnfT2emb/F9r9gn4N9CJbIhxiDXLPdy2C+LhKAvr48++9coLraClRVWeHOzv3vmKR3eWz2QUUERGCfBG7GQ4eLKOyCBw+/cylAOFJQBuPy+dLxv7l1jO9xHxr3p00UiBR3wzBnSyFHsUfrhfXBOMpH8dmHPnBfFREQARDA54GfmwfxeXwI2+NhF8PeBUtUOQ9t/wHH4Q8t3xYJQN9emqk7hpvLqpg7z4oODlrRMF14UlcKS0rsY7MPKiIgAvsk8Iqgnfi8OKNzA6jRsc9aekMERCDpBPB55PTZAxBrK7D9POxbsEqY18JVyGfD2J5vS6Lnv317otnaMQZgrly40MovSt1CMB6Lx1Tw52y9q3ReIiACIpA7BCAEB2A/wRlzOnhjgs78FAhLX6+QlABM0JVOZzPFCMJcdcABKRGBFH88Fo+pIgIiIAIiIALZQgAi8BGcC7N7rEnAOR2CNk5IQDtJa0ICMGloU9twoKLSqj7gwKSOynHEj8fgsVREQAREQAREINsIQARyBPB0GBdPeS0Uk74tEoC+vTTuO1aMgMw1Bx9iBcoTPzrHNtk2j6EiAiIgAiIgAtlKACKQ4ZHOh3FxlZdyJKaBkxl30EvfEh4Dx1NnVNk7AaZkq4ZQq5g3zyoofoX/eVyNsw22xTaV7i0uhKokAiIgAiKQYQQgAv+OLv/OY7fnof6bPbaRtOoaAUwa2vQ1zLh8ZXUzrdrDD7dKpzErTnyldNo0uw22pVh/8TFULREQAREQgYwlcAV63uKh9wzddISH+kmtKgGYVLzpbbyguNgqnT6dMY9cd4R1gqjLNlREQAREQAREINcI4DnIOH63ejzvN3isn7TqEoBJQ+v/hvPz8y2aigiIgAiIgAiIwKQEbserjNsZbzkUfoAM7O67oqe/7y5JYjuUniRxiT0HtSYCIiACIiACaSLwHI77godjcxFI/L5YHg48VVUJwKkI6X0REAEREAEREIGcJIBpYKaNe8TDyTNumi9jp0kAeriqqioCIiACIiACIpD1BJ7ycIbM5z3HQ/2kVZUATBpaNSwCIiACIiACIpAFBDbjHOL1A6TOkgDMgptApyACIiACIiACIpBbBNpxup0eTjnkoW7SqmoEMGlo1bAIiIAIiIAIiEAWEOjBOdDiLbXxVkxmPQnAZNJV2yIgAiIgAiIgAplOgAtBaPGWafFWTGY9CcBk0lXbIiACIiACIiACmU5gBCcQ83ASrO+7IgHou0uiDomACIiACIiACPiIALUS07rFW/bEWzGZ9SQAk0lXbYuACIiACIiACGQ6gSKcAC3ewkUkvisSgL67JOqQCIiACIiACIiAjwgE0JdiD/2JN4SMh0NOXVUCcGpG2kMEREAEREAERCB3CVTg1L1k8/Cygjhp1CUAk4ZWDYuACIiACIiACGQBgSqcA0VgPIWrh3fFUzHZdSQAk01Y7YuACIiACIiACGQygdnoPKeB4yldqNQST8Vk15EATDZhtS8CIiACIiACIpDJBF7vofPMINLhoX7SqkoAJg2tGhYBERABERABEcgCAm/2cA6tqNvroX7SqkoAJg2tGhYBERABERABEchkAqOjo0zj9gYP57AxLy8v6qF+0qpKACYNrRoWAREQAREQARHIcAJvQf8P8HAOT3qom9SqEoBJxavGRUAEREAEREAEMpjAieh7vFlAhlD3Ob+euwSgX6+M+iUCIiACIiACIpA2Apj+nYmDf8RDBxj+ZbOH+kmtKgGYVLxqXAREQAREQAREIEMJfAz9nu+h70/B/8+XK4B5ThKAHq6sqoqACIiACIiACGQfAYz+TcdZne/xzP7msX5Sq0sAJhWvGhcBERABERCBzCAA0ZMHky4Yu1xfxuZQD1duJ+o+4qF+0qvqQicdsQ4gAiIgAiIgAhlB4BD08u8QgYth5RnR4yR0Euf+HjTrdfRvGaZ/m5PQvYQ1KQGYMJRqSAREQAREQAQymsD70fsPwn4PexRC6AJYXUafkcvO43znoco1MC8CmKt/b4b5ukgA+vryqHO5SiDP4n8qIiACIpAaAhA+xTjSRycc7Y34+yrY43jvCthbYfGGQ5nQrH//xPnVo3e3wg7z2MuHUH+FxzaSXj3pAjA2NGSNDA8n/UR0ABHIJgKxobA1Eotl0ynpXBmX9xkAAByGSURBVERABPxNgILviEm6uBCvfRX2KOyfEEnnwBgeJasKzulAnNCfYMd4PDF+cV/j1+wfE8+tcOI/kvH38MCA1b5xgxWaOdMK1k6zrDyNaySDs9rMDgKj0WFrYM8eq7+11Yrph1N2XFSdhQhkBoEPo5vB/XSV7x03bjsgmDjK9Q/YCogd5rvN2IJz4XldCzs4ASdxP9r4VwLaSXoTSReAPIPo4KDVtW2bFe7stMrnzLUKg/u7x5J+zjqACPiSQKSnx+rZtdPijyYVERABEUgVAQgg+rud5OJ4jI137rhtR32ODlIMctsEQTiKre8L+j0DnfwK7HOwUAI6zJh/38b5RxLQVtKbSIkAdM4i3NVlP9zK58wZGw103tBWBHKcwGBjo9XT3KRp3xy/D3T6IpAmAkfjuIfHeewFqEdbDGuCrYGwegzbFbAXIIbasPVVQf8Y4+80GIWfV3+/ief2E5zvcxNf8PPfKRWABBGLRKzu7dut0diIVTqD4ltFBHKYwOio1bd7l9WHaV98KeUwCJ26CIhAGgkw40Ui9AAXUdBOgPELjVPFL2D7PIzb/8A4QtiNbUoL+sGpxzfBmNqNdhAskWUZGrs6kQ0mu61EXHDXfRwdGbGnunATWMHpFOIqIpB7BOgN29fQIPGXe5deZywCviEAYcQwL+9NQof4Fbdg3D403n4ftrtwzE3YboTtgG0b39KPsB8WhjbwtAIO7XOBayWMo0wUfVzYcSSMC1242jnRZSsaPA/95vllTEmLACQdisDunTusgkCxVVzB66QiArlFINzWBvHXrJG/3LrsOlsR8BuBRejQ/BR1in52nGree7p5EK9xqpjWBQHXhW07jKKQ2zBsCEbfOm5pFIlFsBJYAFYF44gSVyjPhTGe3ywYj5nM0onGz4X4ezGZB0lG22kTgDyZsZHAXVbNoWVWfmFau5IMtmpTBPZJIBYOW92Y+h3BDyEVERABEUgHAQgtjtKdko5j73VMTs9StNEyqXDE7wsQf8szqdNOX5MeB9A50L62XPHYj1EQFRHIGQLw9ett2K0wLzlzwXWiIuBbAlwAcbxve+fvjnHF71kQf3/0dzf33bu0C0B2baClxQ4Vs+9u6h0RyB4Ckb5eOyRS9pyRzkQERCBDCXAq9YkM7Xs6u92Eg58O8XdXOjvh9di+EIAj0ag12JbRcSS9XgfVzyEC4c4u+f3l0PXWqYqAXwlAwHDxwgdhn4I949d++qxfDHHzQbBb6rN+ue6OLwQge80YgRSCKiKQzQR4jw91079ZRQREQATSTwBCZgh2C3rybthnYE+mv1e+7AEXnVwD+xB4ZYVY9o0AjMIpPtLb68urrk6JQKII8B7nva4iAiIgAn4iAFHTDbsRfaIQ/Cjs7zCGZVEZi194GvicD6PvX1YU3whA0pQAzIp7SiexHwK6x/cDR2+JgAiknQAETj/sr7APozPHwn4AWwvLxZAFFHuXwd4NHndgm1XFV7FXomGGAlIRgewloHs8e6+tzkwEso0ARA+nOp9BuJgrsD0a9iEYVw0fCPPVABL6k8jCeIR3wq4BA4rfrCy+EoBMEzcai1l5BQVZCVsnldsEeG/zHlcRAREQgUwiABHUg/5y0cNSiMEabN8KY7q398AOhiU72DIOkZKyHUe5DfY7nHPGBXZ2SyghAjAvnz8EGE+Sqf88FMRHw81lt+ShFVUVAV8S4L2NGzwBfcuzxj5zGf1RKYoTBOvxyyaVJd6+8osxm0dJUnkN9j6Wl1ECXZO9abr4N4QRp0UfpOE7jVk4mNWDadbeBaMwnA1jYOdMKQxBsgz2V9hynF/OBCZOiABs37h+tO5Nb80bGcYIXkIecJly36ifIpBaAvhysvKLiq09z62hkhxI7dETdjT2/XkYV9XRTAsf3Lthw6YVErAf+/c0jCMgbvpKkUqfKS35BoQklJ1ok9fFTegI54cDBYxKAgjg+4gr2p4dt+vw/Gde10Nhbx63N2C7EFYNC8D8ULiwZTuM8Q8fhT2C89iKbc6VhAjAtnVr3xasmXZn5YIF80cwzTUyHO/3s/P5zLnroBPOGQLx3+P5RUVWPtwj2jdu6Njx8ENnA9mmTMSGL1t+QZyNh0VcMFA/EcOoRuhwLD4sTo+nr6nsp9HJZNFOYHsDrsmv4zklXZd4qJnVAdtu7MkwMnYoGVwjjtTWw+bCFsKYeWT+uDFPL/P3crSwFJbokVn+YGNoEfrzbYGth62DPQPbgL7ys53TJa4v4H0Re+cPfnRhSUXl94K1tWWMd+Y2rl9BcbE17TWvxQhHvDMu++pZ7r4e6euzOjasn3RkNt+euscwxST5aPHhsGoOO8wqDpXnLrwEnzl/GOHHkms/QObJpiFjTqRt44Zrn/vVLy9McNfUnAiIgAiklADEIUcLOTJIEUi/wtpx42sVMPoVUhg6ApHCgIKSRrE4NG4chaRzNfPytsP2wDiN6/zdOC5M8ZLKRAIJFYBseMnq1aXr7196fWhm/WlFZWUF9sKOSQTGxE5M/Lt0+nQrNGu2RTGo4p2ABKB3hologZ+DvsYGa6DVPOMN/fz4OcA1HG1bv3Z5pK31ky/ccktLIvqjNkRABERABHKbQMIFoIPzk//+99zGFSvvKp87/4j8/Ly8GKeFDf0DCwIBKzRzphWcNt1xdnea1dYlAQlAl8ASvPsofvwwzWFfc7MVG+IPVoOC0dcCjIKPxEYwertu60Bn+2nPX3edPaViUFu7iIAIiIAIiMCUBJImAJ0jL/rB5R/ILwncVFY/a4Zb/8DiUMgK1c+yAlUcKU56V50uZ9VWAjBdl3PUGurqtvqaGjmCZ9wJx8+vZ+eO3s4NG772/M03XWdcWTuKgAiIgAiIgCEBzqUntWz/10Ob/nvp0T/bcE9vLK+g8OiiUKgwDyOBmP+f8ricNgt3dljRwUGrIFCsaeEpib16BzIcbKMP7KsL/fxYJrsWfC84bRqY+2Xh1qv779dXhvv7rN5du+wpX/I3KVzckY+R76GurmjLM0/fFAg8duwTV/1Vo34m8LSPCIiACIiAawIpHVY769lnqzbfe/9vKmbP+TAEXT6d4jlFZlL4gKR/YFndTCtf/oEmyOx9NAJojMrzjiMQe/17mm0/P452mxT6+XHULzoUGW1bu2ZVNDxw2rO//OUOk7raRwREQAREQATiJZBSAeh08iO3/+Xwrt3b/lJeP/uwEYwE2mFjDEYEWb8QoyRl8g90UE65lQCcEpHnHRw/v374+UVd+PnZ070Yae3curmpb3fT4mev/+XDnjujBkRABERABETAgEBaBKDTr3f9+CdnFAZLf1E6rbZmJIr4gVGGBzMrDE8SmgX/wEr6B6rsi4AE4L7IJOb1oW74+TXSz4/hpsxKfiHi+RUWcGHIQNfmTZc9c+01V5jV1F4iIAIiIAIikBgCaRWAPAWEjSnatPTBH5TMqLsAYWOKORroZvqspLraXihSGGSoIJW9CUgA7k0kMf+mXyoXeIQ7O125MXDUL9LbG+tYv+722EDfkqdvuCFTs3kkBqRaEQEREAERSAuBtAtA56whBKe9+NCym0Oz6t+PxSKu/AMZMoP+gaUz6hRE2gE6vpUA3AuIx3/yB8pAyx7bz88ObWTQnuPnNxKLjnasX/+0BT+/x6+8crNBVe0iAiIgAiIgAkkh4BsB6JzdB2+5/Y39zQ1/Lp81+xDbP9BwFSXrF5aUIH5gvVVSW6v4geNAJQCdO8vbln5+4fZ2TNs2WdEwA8+bFS5YQhhMq3PL5ub+5pazn7n2F/80q6m9REAEREAERCB5BHwnAJ1TffePf7K4sLT05yXTplXb08JILWdaAuUVVtmseitQIf9ACUDTu2bf+w31dFv9jU3WUG/Pvnfa6x07fRtGpvubmgbh5/fdp6+95vK9dtE/RUAEREAERCBtBHwrAEnkrGXLSnY8/dxP4Oe3pCgYLGKYjcny1k5Gj9NuyEkM/8B6xBAsmWyXnHhNAjD+yxwbCsPPr8kaxMifcbgihnXBqN9wf/9Ix6ZNdxdasU89dsUV5itE4u+uaoqACIiACIiAMQFfC0DnLD69Zk3dlvv/+SdkEzk2L78gbySC+IGjZvEDmUuVYWNKp8/IyWlhCUDnLjLfUuwNtLZYDOtiGsg5L4/Cr8gajUWtzk0vroV4PGXVFVesNz+q9hQBERABERCB1BHICAHo4Hj/jTe+Y6in99ayuvr5fEjb8QOdN6fYMq0cg0hz1bA1ngFjiipZ8bYEoIvLiFiUXNXLYM7kZlq4spcjzj07t7f3Nzact/rqq+80rav9REAEREAERCAdBDJKADqAjr38ii8Eq6ouD1RVh+xpYRf+gSVVVXbYGKSkc5rL6q0EoNnlHYbgs8O6dHWZVcBetp8fRpjDbW2R1g3rf/bsNb+42LiydhQBERABERCBNBLISAFIXuesWFG+7cmnrg7W1J5RWFxSGIsMmftpIa0c89xyRLAAmUWyuUgA7v/qxpC5gyN+zJfsJv4kcyQjbdsIVvc+VDgSO/PRH/2odf9H0rsiIAIiIAIi4B8CGSsAHYRnr1kzd/v9D9xZNmv2/8uzRvPs2GyGaeVywT9QAtC5U165jcfPj64DjDnJ26tz84ubR0aipz7+ve89+8qW9S8REAEREAER8D+BjBeADuITrr32/daIdVOwdvrMGFLKufUPDM2anZVp5SQAnTvk5e1Y+rYG135+BUjh1tfU0NO9c/uFq6+66qaXW9RfIiACIiACIpBZBLJGABL7u5YtKyx8fs03ikpDlxSVh4K2f2AsZnRF8jC6U1JTY4eNQX5iozqZsJME4MtXKTo4YId1CXd0YBQPw3gGJR/uAgzrMtTVFe3etvXGkve/9/zlixaZB6U0OIZ2EQEREAEREIFUE8gqAejAO3ft2pot9y29PjRjxkfzCt2llaNjP0PGlNVlR1o5CUDLHg3u38P0bS3WiOGCoZfSt0WRvm3jxhWBytDpy7/+9d3OPaatCIiACIiACGQygawUgM4FOX3VqoObVqy8E2nl3sAA0va0sOHID9PKMX5gsHZaRscPzGUBSD+/wfY2O56fcfo2jAQzrEs+wrp0bH5xZ3Q4cvqq733vMeee0lYEREAEREAEsoFAVgtA5wKdcM2vPplXUPDLQFVVzchwFKNAw85bU26Ly8vtsDGBysxMK5erAtD282tqtCK95kk48uHjl19UaA22tvZ379j+7Sd/+n9XTnmDaAcREAEREAERyEACOSEAeV3O37QpsO7u+74bqK78cmFJsJgZHjhCZFLoH8iRQI4IFgaDJlV8s0+uCcDo4KA94seRP1M/P073ckX48EB/rPPFTbcf9v4TPn3zokVh31xEdUQEREAEREAEEkwgZwSgw23x88/P2P3Aw78rq69/L4Qd0spBCBpOCzMESOmMOtgMOwiw06aft7kiAOnbN9DSAttj2aGADC4KhT0XeOD6j3Zu3PjMaHHBJ1Z++9tbDKpqFxEQAREQARHIaAI5JwCdq3XKPfe8rXvH7ttKamsPpHhwEzamqLQUo4H1WDVcjdBw+U6TvtxmuwBkTuhwB9K3NTdhBG/A+BrYfn5Y8NPXsLsl0tdz7opLL73XuLJ2FAEREAEREIEMJ5CzAtC5bidce/0ShPq4oriisnJkOGK8SpT1AxWVVmjWLIt+gn4t2SwA6d/X19hoDfV0G+O307cVIX1bR3u4Z9fOy1dd/sPLjCtrRxEQAREQARHIEgI5LwB5HZesbizd/MgdPw1UV51bFCgpcuUfCP+x0mnTMSJYh7RyJb67LbJRAMaGwhjxQ1iXtlZzP07Hz29wYKRry9Z7qmYe+qn7v3Rmj+8umDokAiIgAiIgAikgIAE4AfKSdevqtyx98M+ldfXvQGJY92nlkFu4dPp0CyuOJ7Sa3j+zSQCOIqj3QGurnbuXIt2owM+PvpuI5WN1bdm8rqAw72PLL7lkg1Fd7SQCIiACIiACWUpAAnCSC3vyrX86brCz46bgtGlzuaDAlX9gWZkdNqakqgqiI/14s0IAYpFOuKsLWTwareH+/kmu2OQv0c+P4q+voaED2T++9NgPvnvr5HvqVREQAREQARHILQL+GaryEfeNf7lz6+K33fvzHfmP9iCA9DHFZWVcKmq0Wphicaiz0xpG2rFCTAkzvEg6C0fKBtvaJu0CV8GyTLYKmu9BAKP/gUnrpupFCr6enTusfog/01E/pm9jIO9IT0+ka/OmKxdFLz7hlu+9+4VU9VnHEQEREAEREAG/E0j/EJXPCS1ZvaVyyyP3XoPVwqdhNKnAjX8ghUiQ/oFIK1cQSI+QytQRwNjQEKZ690C8tmI23jCf87ifXzQSGe3esuWhiunzzrj/S+e0+vwWU/dEQAREQAREIOUEJAANkZ/z1AsH7Fr16F3IE/xGZBPJizGbiGn8QIwCMog0F4uk2j8w0wSg7ecH0dff3Gw84sep9gJm8SgssLp37tiWN5J3yrKLv/K04aXVbiIgAiIgAiKQcwQkAF1e8pN+e8uHI0Ph6+DjVxeLwD/QTVq5spCFANRWKv0DM0YAjvv59Tc1WZH+PuOrwvRtBcVFDALdgxRuX13xvUtvMK6sHUVABERABEQgRwn4O4qxDy/KPWcv/tsh82bPxyKRSyH+woXBUiwwNcNIYdO5ZbPVtXWLq6DFPsSQ0C4xgDOZkI2p+CNzskdImGjb+rXXHXbQwhkSfwm9LGpMBERABEQgiwloBNDDxT1706bpDUsfuqmkuuZELKTI52igaX5hBiRmyJgyhI7hatVkFT+PAHLBTP+eZju0C7OxmBQKP476Ydp3tGf7ticC9TNOfeCcc3aZ1NU+IiACIiACIiACYwQkABNwJ5z56BNvbHnhuduRGu4wt2nluFKY/oFccWs6kuimy34UgBTJXJlMP78ogjqblpfStzU2Nlgjo5/611cv/JdpXe0nAiIgAiIgAiLwMgEJwJdZeP7rA7++6cyR0ZFfIK1cNVcLm45q8cBMJxeCf2CgEvEDE1j8JgCHuhnPD35+SONmWjhaynA6SN820N/U/G1M9f7MtK72EwEREAEREAEReDUBCcBXM/H0ypLVq0t3PPHUdwtD5V+CaCliOBPTaWHG3iupqbFCM+utwtJST/1wKvtFAEbh59fX3AQR1zFp3EGnvxO3HBFl+BwwjPVs33r74R/8wJIbjjhiYOI++lsEREAEREAERMA9AQlA98yManzquedmN69cdUtJVfW74B+YZwcxNgwbwxGvshl1ViniB/JvLyXdApCjoAOI59ffssd8RJRhXTDiB0E82rNr5wtFleWnPHjeeZu8cFBdERABERABERCBlwlIAL7MIil/nXrfA+/o2bHt94GqmgMYO9BVWjmscrXDxmBU0Mna4baT6RKAzC7C0T6GdWFWFNNip2/DIo/+5qYWjPwtWfaNr/7dtK72EwEREAEREAERMCMgAWjGyeteee+78befQyM/Ki4LVYxEhoyzW/DA9AukfyD9BN2WdAhA+vfRz4/+fqaFWVPykXYu3N0VHtjT/OMV//vty1B31LS+9hMBERABERABETAnIAFozsrznues2FC++/nlPw1UVZ2dl5dfGIMQNPYPhD9cKVYKlyJsDPPcmpZUCsBoOIzpXoR1wQpfN+fFfMOjsehI17Zt98487G2fuuPU47tNz0/7iYAIiIAIiIAIuCcgAeiemeca57z44gEND/7rDyW1046KDUfy7NXChv6ByEds5xYuhY+gSVq5VAhAO30bfPyYuzeG2H5GBX5+9upeTPf27NqxIThr5qn3nXnmGqO62kkEREAEREAERMATAQlAT/i8Vf74HXe/v7+n8zfFobL62BDDxhiKJxy2CKuEQ/WzrJLqagZF3mdHhvv6rPYN6yddeev4FdJfb+/C92oOO9wqDoX2fuvlf9PPr7MT072NrjKb2OnbAsXWYGdnV7Sj+0v/uuQrt7zcqP4SAREQAREQARFINoF9K4dkH1nt2wTOWraspHVHw/9AcH2zIFAc5DSq6fQphR9WGVuhWbNsQTgZ0qGuLqtz86ZJBeBk+7/0GgXgQQdbmK5+6aWJfzB9W19joxXu6oSn3qsF5MR9nb/t9G2Yvh4eGBzGaOGvFh51xNdvXrTIPBK005C2IiACIiACIiACnghIAHrCl7jKTCvX+PC/rg5UVJ6CIb18ho0xFYKcSg3W1iKjSL0dPoW9Yl2Kvz4kzRgeHIyro0XBIMTlbFsEOllK2C+s0LUG29uNw7rY8fwQ1mUUSrFnx/ZltW9+05l/ed/7muLqlCqJgAiIgAiIgAh4JiAB6BlhYhs4+5lnXtOw6qlbg9Nq34hp4Tw3YWMYNLkMsQMLse1vacEq3MSspQhUViIu4QykbRsa8/PD1rTYYV2K6ee3a1tJZfnp93/mM6tM62o/ERABERABERCB5BCQAEwOV8+tnvzHP38k0tt3XXFl5YwY8uW6SStH/73J/Pq8dMptm/YCD+Q5Dre19mCa+Kv//ubFN3g5vuqKgAiIgAiIgAgkjoAEYOJYJrylU1auDA5u3PQdzOtemF9UGKAQNJ0WTnhnDBscS99WYmGqODrQ1PD7acce88U73v72+OagDY+p3URABERABERABNwRkAB0xyste5+1du3MxkdX/iZYUfG+kZHRfISOMV54kbIOY9SxoAjp2/KRvm33rifLF8w79Z5TT92ZsuPrQCIgAiIgAiIgAsYEJACNUaV/x9MfffSt7Rs23hqsrD6U/nhu/AOT2Xv6+dHvsHdPU0N+nvXfD37xiw8n83hqWwREQAREQAREwBsBCUBv/FJfe3Q076Q/3blkNBy+vCAYrIohbMxILJb6fuCITN9WwLAuvb0DA91dP1x+0Zd/iNA0ZjFh0tJjHVQEREAEREAERIAEJAAz9D44Y9Wqis71G3+EtHBL8kbzCqMu0sp5PWU7nh/Tt43GRnoaG/4y+53HnHvrUUf1eG1X9UVABERABERABFJDQAIwNZyTdpSznl13cPMTj/0uUF19FKaE8+xUbIaBmV13yvbzK7JTuPU17F5fVj/3k3ef/vEXXLejCiIgAiIgAiIgAmklIAGYVvyJO/ip997/3t6mhhuLK6vnxJLgH2jH84Of32DLno6RyPD5D110wW2J671aEgEREAEREAERSCUBCcBU0k7ysZasXl3U+J8NF46OjnynMFhaFg0Peg4bY0/3lgSt4b7eyEBb2y8OOW7RJTcccYR50uIkn7OaFwEREAEREAERcE9AAtA9M9/XOHft2prGx578ZXFF+SmjsVhBjP6BLqeFGfi5AH5+Vn7+aO+uXQ/P/H9vPu2Pixa1+f7k1UEREAEREAEREIEpCUgATokoc3dY/Pzzr2t54qlbSiqr30QRaBo2Zix9W8Dqa2rcWjyt+oz7zzxT6dsy9zZQz0VABERABETgVQQkAF+FJPte+Ohdfzt9qLf3F4XBYK3tHxiNTnqSY+nbAtZQT09ftK/3kocuvODqSXfUiyIgAiIgAiIgAhlNQAIwoy+feedPWbY2FN75zLes/KIv5xcWBKIT0srZfn7I24sVxNHBlqbf17z1fRfcsei1feata08REAEREAEREIFMIiABmElXKwF9XbJuXf3Oxx6/KVBeeQJEYD6bLAiUjPY17n6y9uADT73jpJOUvi0BnNWECIiACIiACPiZgASgn69OEvt2+qOPHzfQ3Hg3FokUxqKxT9x75ml/TeLh1LQIiIAIiIAIiICPCPx/9LZZ0UZyLiQAAAAASUVORK5CYII=');
184 - background-repeat: no-repeat;
185 - background-size: contain;
186 -}
187 -
188 -.ipfs-mid {
189 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnhJREFUeNpsU01PE1EUPdOZKWUotKUKFLEWkQ1EASGGxGBi4sIVrt27IixN/Cn+CxfVnQsXJiz8IAoqRBGEaMUUWzofnXkz781436QDkjKTyXuZe96595x3rxJFEeTzaKW6dmdpfIoxjuRRFECGn7/4Utvarj/syWgflU5s891qvGoJePJasfBgeSpnW+yEIJVS4DEBx3FzGT2qfvh0tJxOE4mCU0yy8X3BLdODRQTJZ5oMzYaD0UuDePzkbnnx1mjV9/lMp+izBKEIwQMOzvnJGoYhhBDgFKtMjmBl9XZ54WapSjLnknMnEkQYgflCVhKXLt+/dRMy2d5OHdVnPoxeHUtLV8u2w5/S78UzBJwLMC8gAsosIqy9/ga37WNmvgKVKmEkb7JSwI3pIdRq1kBXBZJAUKkb6wd49fIzbJthdn6cIhE0XUWbyP4cmshmdZAE0eUBD6gCN0DtZwM7Xw+RUlVEJCui7CmyPaS94zC06ZMedREERNA6djBWHsS9+9fRS3p9AraOXbhELMlUQju2G2O7JAQENk0XhpHG3MIVlEZzaDbdOKO8jWy/TraGsMmL4L8KTgnIfcfy4JBWeQNp0j10MQtB4EJOg6qFMI/bEH3pGNtF4LOAjHMxO1dGvW4jXzDi7Iw60TB0jJRyONhv4MdunbDneMA6BMPDA6iMFzExcQH9AxkUiwby+QzevtnF2OU8lBT1i8fOa2UO1/FwdGTHE2STHM/14+vlPOz0RxibKPfn9AHXZHBzYx866ZdTKkuVndhHuqenS1h/v4ffvxqyvbUuAtPizZ0Dp7X1fTs+FA9cMnWd4ZG90NOjomVFzeTcPwEGACDGeYddZX86AAAAAElFTkSuQmCC');
190 - background-repeat: no-repeat;
191 - background-size: contain;
192 -}
193 -
194 -.ipfs-mp3 {
195 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnxJREFUeNp0U89PE0EU/ra7XWxpSsFYIbVQf9REFBHkYBRIPJh4wrN3DsZ4MPGP8b/wUCIHEw5EY0w04o9ILcREGmwVgaXbbXdnd2bXNxPahGyczebtzrz3ve99740WRRHkWn5cebu4cH6SMY7e0jRAHr9c3WxsVvcemmbys9yT6+uHJ8oaPefypdPDD5Ymh5w26wMkEho8JtDtuEOZFCrvN/4uJZNGH0T59D58X/C27aFNAL3Xthmsww5GCyN4+uzu+OLtQsUPxPQx6ZMAoQjBAw7O+bEVCMMQgqygs+LFs1h+dGd8bna0QmXO9OL6JYgwAvOFZKKoy3V44CgNfv7Yx8oLH+lUEgvzF8Ydhz+n41snAGRG5gUEwClzhHdvttFxfNyYK0EnJozKK5eGcf1qHo1GOxtjwI+pfvm4g/W1qtJgerYE2SXJSIL9+W0jk0mCShAxDXgQKgbNXxZq35vQKCiKQkSUXdc1+gcch1FHGPmKuIgBCdc66qJQHMG9+1NIpUylxxHtuW6gEiTIu+N4yjdWgty0yTmdNjFzcwKjY0MU7MLt+IjoSad16FoIx3b/A0DZ7FYXnsdpAjUMDOjI5zPgfoBsRodhhGhZHfBBU/nGAGRtxWIOg5lT2NtrI5dL0SB5KJzLodloqXaOEatPGztKq5gG3S5DNjuAK5NjKJfPYKI0okBkSdemCiSgS/rkQNLSePtxBj4LSCwfFtE0krqqX7ZVMnu9XlMXy2l7ME0dzA3iANQyY6vWxC61UY41zTyNcYh6/QCNXQvzi5dR39nHVq1BUyuMGAARsF6tbbe4iKD1r7Om5iFBdmW1SsDflLiuB6sX90+AAQDHAW7dW0YnzgAAAABJRU5ErkJggg==');
196 - background-repeat: no-repeat;
197 - background-size: contain;
198 -}
199 -
200 -.ipfs-mp4 {
201 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnBJREFUeNpsk99r01AUx79psrTrujVtbceabnZs4DYRHSoMh6Dgq77rn+AfoA/+If4Bok+C0CfxVRDBh+I2NqZzrpS1DVvbtU3SJPcm8SSlsJlecsn9dT73nO85V/B9H0H78OLdt/LDlQ1uMYybIAgI9n99OWxoe83nkiz9hDDae330JvxL48O51Xxm/enNtKPbVwAh0Ec6kYpXat9Pnl2GBC02HrjM5Y7h4P8+7FtIFVJ49OrxUnl7ucIdfhv+BIDv+fBcj7p/tXMPrs2RXVTw4OX2UnFTrXCbbY7tpMsA13FDSDAOQ4gJEGUJLs0PPh9CkESsPrmxxEz2lra3rnpAt3G6adgdQhBpmeLkFodNmsjpOPoXBrQTDcmFFNS7i3MRDzzPCw/vva8ikU+COQxm14BBhvJcHLGpGPTOAJxxeLbrRgAkYujBdH4G5oWJWXUW19YL4XqunAMFhnq1BqWYgaY1MAHASQOiU96zKzkU76mwehaOvx6h9uMv7KFN3RopL4oTAI4HRh4wSl399xla+00YbR3yrIzM9SzSqgJJnoKcklGrH08CcJjnBtLLCsSEGGpSWJvHtDKNoFippsJ0ulIsDDUCCATMlBQkNuahEyiZTcLsmFBKaQxaOk53TlHeKkM70AjAooCghBOk9sKtIvqtPqS4FBaRnJSRX8tj2DOh3lFB5Qw2ZNFK5LRo6w4sKt2ggAzywidAMN/9uIPSZglBLDO5FF3mRD3wHE9qVRvoHrUpfn+UEQK0/7ShtwboHJ6jdH8RZxSC57hSVETb7e5/2u0FxqPHJow+8iZ4lYY2QGu3idhIxO7Y7p8AAwALCGZKEPBGCgAAAABJRU5ErkJggg==');
202 - background-repeat: no-repeat;
203 - background-size: contain;
204 -}
205 -
206 -.ipfs-mpg {
207 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnxJREFUeNpsU0tPE1EU/ubRdlqmnUBboa0UeUQDiUGCC1+JmrhxoXt/gBvXJi74If4AV0Y3sNKF0YUaICqoIfjgVShEiGF4tDOdO/fOeOaSKtie5GZu7pzz3e/c7ztKGIaI4vn9p+/P3h4e4a6Pv6EoQBDiy7P5rc1P1Xt6XP8M5ejXo6UJ+dWbuemeTGdpvNdiNe9YvQLe4Bi4PmTpRmyq8m71rp74BxKF2twIHvAo+f/l1T2Yp0zceHizfOZa/xRnfBRhG4CQqAYioBWeXDyA8Di6ei1ceXC1XBwrTXHPH2vW6ccBBBMI6BsSUEQzakGL6xB0tvjyBxRNxdCtc2Xf8R9TyaWTDOg2TjfVdw6hqIoE9B2GxkEDWlLH7s4ette2kSp0oDRezrQwCIIA3oGHr0/mKMmE53qo23W4+w5S+Q5ohob9X3tgHgO8ULQACC7gMx9mKQP30EW6mEHpYi8xcJEdzMucjfkKcrTfmqmiFYBxCF/Id+gayKJwoQjHdrA5v4HK7Cq44KjZNWpagaqp7QACks0H9znW365ia24DzoEDozOJbH8eVtGShXHTwNracnsG7q6LzsEuaAlNPm9h7DSSVjLyCMkppDI+GS2StQWA1RlKo0X56n2X+6QHkmkDakxF9WMVqWyK+s/BrthYfvWz1Ug+zUDcjMPMm0h3pxEjFma3CbIuCud7oMc0LL1ZgmElpGJtW3B+15HIGNITrMYIlOH7i0U41NrInREylYbu4R5qQbQBaAh95fVKZCnpQCnb9DrWZyrRERS6NDeUw+yHaXh7rt4C4B8y+9vkwn7kwKNRpDoa9aiFKBYnF+RcREqQ2e1m3R8BBgAy9kz9ysCE6QAAAABJRU5ErkJggg==');
208 - background-repeat: no-repeat;
209 - background-size: contain;
210 -}
211 -
212 -.ipfs-odf {
213 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAi5JREFUeNp0UktrU0EU/mbu3FfE1KRRUpWYheALNBURUVy7cy9UkO6KW/+Lbt0IPsFui4gLBbUqFaUuXETUKCYa0jS5yZ2ZO557b5MmTXpgmDPnfOc7jznMGINYPi0de5UvmpORxpjE/kbNqW005DVu8TWw1H758ZfkFgNgJmtyxSPRjJIj0QTW/RDiYGXGb7Dl32/eXrVsd0gSCx9miqC0ooCdp69g5Q/h6OLN0ty5ynIkwzMwUwh2FwMdcbDiCZQXlkqFCpEoPT/wih1YjLInANcD+/Ua9bu3wJlGvrBZCmet2+S6ME5g4oGlZ9A/I70XCDhhDexPNTFmswJBwcnuXkF86VSNZxVu0ukLSGnBcqlnN4HoCQIaIuIv7LUooMOgQ7q75LAAb59B9gCBHSKgqemRr94mMKmD24CfM8nb7THYGQNLpAkUkcb66JyGBFFEWRVL57gFEH5qj8Lxwca2qS3EZaugmzAw24dR/XQgwtsCSBjPIdWbUoE2UJLBnV8Ac/ciWHsK9/glWLnD6K2vgPszsOdOQdfeQ1c/ThKoTgDn9A3KUED/52d45xchZsvorD6Bf/Z60riV3Q9Z/0bbGU1uopYGkfERSQ3VbsMwl0qlqoIARmSoPYXWy0dor79LfBMEEd8jGs/uQ3Yl7PJFNFbuEXiV2riCf88fovXhBbo/vqP3t02/ZYmJFqTkzY160Go9uEMbFK8hR/NrdXtFuUVmnmySVGgO4v4LMAAjRgmO+SJJiQAAAABJRU5ErkJggg==');
214 - background-repeat: no-repeat;
215 - background-size: contain;
216 -}
217 -
218 -.ipfs-ods {
219 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAetJREFUeNqMUj1IHEEU/i7u7Z23e8tGgneGQPw3hZDkkhQiSuwMQREba4uUgpVlCrvEQhurkCoWqcQQ0oTAaYKNqJygGEwgHCSB6Knn7eXcdX/GmdHVPWYFP3gw78173/vmvYkQQsAwNvckq96UnyIEh7/d4t7uUd/8y+85P+bXSX4grkhI6nJYPW7LrXpBK2YxiSoShhu4Buq1NPofDeqdrZ3Z4cl7D4J3UtA5VyVAlmJoru9Af2ZAp1lcCQ3nqgiuKmbY3l/BH+MnHM9GVLP0Ww3KNA33CQoQQnL834Fj74PUGkANEIkCSSsa8gQqgYTIcB0PVsXB318GInRiCVWCkpRFAs+j5gKlA4t29Ggh4d0t04FKt9PQqF4UFgumSEA8ApeaElilWbYRVy/lsns/N1QBkxtENF4jxPxcgcB1CZVOrvMteK5IQDtJJIGh++PcX9iYwWjXK37+vP0WdYk0Ht99jtX8JywWFkQChw4tc+cZcvlF7rMze+ubbxN40fMalRMDP/6twaiUeK7wlZ0TD0a5hLTWxo2d45KKprqHKJslTsy209s2wnMFBTYNZjc/oLt9gPvLOx+hxVJIKS2YW5pCbSyJTGMK775O8VyBwDJd2LTDl/X5i8v3S7NVw9vJb51tITDEUwEGANCx2/rXEEFFAAAAAElFTkSuQmCC');
220 - background-repeat: no-repeat;
221 - background-size: contain;
222 -}
223 -
224 -.ipfs-odt {
225 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAepJREFUeNqMkz1II1EQx/+7Ca6JkqyYiJ8cKEpAQbBQFDm0sVOsFBS9wt5KOTgEG5twxVlZ+XEnKNiIghYKxx5nwEpIIXaiSAgKGmMi0d23u8+3T7OaZJEMLG9mmPnN/w1vBUopLPNNhRWXHOyDg0nx82TiJtZPlPVoNpftc2cTotcHtxx06kdXpSQ/BvzKESZzIDmAz6y+NojOjpDMZiqRPIgNoFyWM8DrKUV7axO+gcp4g7AzmquAdVNqOgL2z2I4id1B0wgeygOyt/rLL5buLwAIDgA9dY+L+DkuDQOCrkMgBsRglcMOqAGwIstMg8AkGsuZMNUMRMkLqE+QGloglvlA7uIOAKvZajR0qJkUj/XHe0BTIclVKKlrfKsj9qA8gA6wqSJzPaXlr7ky//tdLEUfawsBjExUFGVWbT7AxSa42H2LMfODmvd3wKb7RAMLYwM8nts8xJ/pEe7/3PmP2eGv3D+9usb35W0bINoA7RmjXSHsH0f5Z/mUSZ0Ir2JmsBtD80s8/rGyzWsLFTD5yUQCbfUBHl9d38LvkdDTXIuHVBo0k+bbt06qO+yAPGXwe/cA4wO9PN44jKDG70GougIzi2tQ00ms7/3lpwnBBgjZ37Kkd1Shht5XzBIFl/ufFtniT/lFgAEAU//g6kvdGBMAAAAASUVORK5CYII=');
226 - background-repeat: no-repeat;
227 - background-size: contain;
228 -}
229 -
230 -.ipfs-otp {
231 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAcJJREFUeNqMkssvA1EUxr+ZjkdbrfFKVD12ErYSRELY2fkH+BMsLcQaSwsrSzZi47EjJEQkEhYkFlhYSVtFpdqOqpk717l3jKZmiC+5mZlzv/s795wzCuccQncz3YeRBj4KHz0/RrOZe2NsZPP20o255zQ3EAxzEAC+6uzTw13G4TFQAakA/CWtIYbY0KBOrx7IvwDQqlHV1o3YxKTOvyAUvfQCfqmA3e4ikyS/zRAKvOot7eoSHEgZIHrCfQAfBqBaKQQDKScQAExd8emBANg+2U2CvNMkkgSqBmrCxFB8mujeoJBWwEqARcssKTAJEGrmaGrjqK1zvNknH4BtyxKl2VUpRxmj5W+x73q9AEaZrR/ND1EJluIpS3i9JQiA+a+hSq8HwJjTsLrRaWitPTCOlhEZn5N75sM1qigmlN+dB3u++Qao5W4TtbEXXIsiszGL4PA00itTsu6XnQWo0TjMTAJqfMDx/ryBJcaVzSNSH4fW0Q+rkIf5rsjRiid7yyN7uoXS3Zn0egE0NiORAN9bQ017D1Lri7CLlP2EDr3Rf7C/itzV2bfXA/igLDaRixfngFhSCooH2xVPCWBlwKcAAwBX1suA6te+hAAAAABJRU5ErkJggg==');
232 - background-repeat: no-repeat;
233 - background-size: contain;
234 -}
235 -
236 -.ipfs-ots {
237 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAfZJREFUeNqMUk1rE1EUPS8zmabJdDKB2glEwY9ExJYiBUEQpV25qgtBXfgbpEtXuujKf+AfEKRddOdOGHClbYVCvyKWaijT2mhjphk7Sd7Me76ZONp0EsiBYWbOvfe88+69hHOOAE9f3zTVnDKNHvhlsfqPw/rM0ovyWsRFdXJEpDIyRnSlVz0KSkmvabaJeXSJBEhgAJzTDNybmtUnS5Pmg/lrN07H5NM/f13FoMgpXDSuhiIiK3Qi6LUugX7FAbaPPsJqfIHHKCStqRsXVFPQuZgD9BBxjikSiRq41AAkgCQBzVf0+BWEBX7GBm0xgHHUqk1UbBuEcIydzyCZlOI9YEGuDxwduCCitS3Xh3viCZ4jrcq4PJ6DLHd67tjtuAAXib54dCPVEfQ5XIcik/0/2iDeOYz3ceCxrisMi904y0XiMQFfkB7lg6xFHwFxEqUMV0anUNBLWKm8xd3i4zBWOzmASx0UsiW831mA59Xjm+h7HCOygduXHqJatzA7Poey9QnXjTuoVD/j/sRcmDOWLgqnLC5A2wwST+Pn8T629lahSCo291bwu9XA7vcy3m2+gTaUR14thrk9BXasbdiOjSe3nmPpwys0xSi/HpbDd3bIQC6dx/q3ZbRb/j8BEi3Po5cTJpHI9CBNDEa++GyDBN9/BBgAwfDlCVUQaNAAAAAASUVORK5CYII=');
238 - background-repeat: no-repeat;
239 - background-size: contain;
240 -}
241 -
242 -.ipfs-ott {
243 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAdFJREFUeNqMU89r02AYfpJ0iVm7EqhVOxw7dDBEdpiCE1RoEZRddvUgbIex/Rs7eehppyF4LOzQu4MxwYp0HgShIuwwUVSCVtl0s13afl+SzzcpyZYmyF74eN583/s+PO+PSEIIeJZdrtQVI19Cgmk/Ph39bpllXq82g7sgLxVcyKNZpIx8Uj5u5zSjc9Gov8ZihCRC8D+7On4JczevGeTGSEIC4ctKJtB1DTPXi1iCCEkIm1EFlC2Em0iwtWfinXkIzjiO0jljtDC5TtflGIGUQMB+mfja/oPv2Rx9MMjpMdJxOXyXTwkcwIkewfqQ1QtQNB385zcI14FrtQexsSb6SRysZ4Fbf+F6eHwATc9gJGNAm5iCTL5n/LCVRGADNoeaGoHqyaXj5gqQlTODovcwNk5Aj6wXqV8eCo7EDhMonEHpW+dZC7gUG98D3geo7vkb01h9cAvPdt76OGy1xntUd3bjUxAk3+l2sHJ/FgtrT0MUJNfDSm0bjQ/72Hzxxo+NK+h3B7XRNO4UrwymQtMIkdTBU0m+sBOayLsn8Ka78mQDjx/e87HXPkb1+UsfP37+AmZ1fP/suknBb6nefVQXjl06TxMlJfWKNWr+Kv8TYAAkUueexJF47QAAAABJRU5ErkJggg==');
244 - background-repeat: no-repeat;
245 - background-size: contain;
246 -}
247 -
248 -.ipfs-pdf {
249 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmhJREFUeNp0U0trU0EYPTP35qYxaW6TlDapNKWGbgo2FkF8rARB6rboXusf0F/hyq2U4krFqugqSBeuAyL4SERBstHa0iR9JKZJ7mvu+M0tqZGkH3x8987jzDnnm2FSSqh4ns0VU1ybFzj674Wa3uWiWbfsFQb+jrGj8Xvbm0HlvYVRxhJprpmTlGmum+OMm5uNPZNbtjk3l82ey8++8oW4Jv/H/wdA456g2kvH99FyHNiuAz2dwflbN8YW8zMK5Go/CMfQkAhpGsyQgRCtlpE4jIULyC9fHzu7MPPEl/5ib6WOE0JJNRiHHg6j86mMjw/2gG4bkbY4PW4Yj2j64skA5FTHdaEMPiAJszt1sK0d4suJmY4k0+IDDGRfqmh0u5gejQc+fG8eYCIahRQCEfgQnIuhEkgtONE+dGxYxEDj1DhiEycZ+1YXdUpHCqTMJIYyEES5aXXQsi2kYlGEia5GtHVKn+amPBeCutPgfLALPuVu+xDVPw2EQyFEjHDghbpYNm1yKVVnYjTOerepn4E6XQmLGSPkPkOXWATMSDcjQEkAaqOu6+i/rccALtFL53LI3r0Nq1ZD4/MXZJaWYFer+PXiJc6s3IEgY3+uPYZHTAcAHM+DTE8gnM1CSyaCulv+GrRy8uYyElcu4XfhLVpkpNtn/DGA5Uu0abFH36WnzzCayWAkmYJvWeCkfb9SwY+NDbSoOx4bYqJF8rZqVRRXV/HhzWtUSmWwmWl0RmN4v76OUqGASrmMOkntSHF8MOs954dT08W248wzYsJDOujRBAaqqikTpRo/qqd0/dv97c3Lat9fAQYA4z8bX9nTsb8AAAAASUVORK5CYII=');
250 - background-repeat: no-repeat;
251 - background-size: contain;
252 -}
253 -
254 -.ipfs-php {
255 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAhNJREFUeNqMkltrE0EUx//ZbDaXNrvZzdIkbYOXGgxYQlCK2IIY6EufxGdB8Av44AdR8AP44JOPBR+Ego0PClUKTTXQSmkTYtOkmubSJrQ1e3H2yJSEJNIDs3PmP+f89pyZcdm2DcdWvn7LzkxFHmCIra7nm9ulg8yLZ09yXON55Dgjt1PM2iPs0+aW/frdh8bzV2/SvQBnCLiEqcFxLKSSodlrU9leiGPihWePBkgeEZO6ShC2dCAZNuf6ADb+ldQ5PUPx4BCFcgXfdwq4Ph1Dtd5CZi4Nw7SQiMdCXkl6yVIy/QBWgcU+yx/XsLK2cdHndqlK/lZxH/OpJO7fnsWY3z/YAq+g0TmHpoUH2vB5PXi8RD9Fo10aAmDJTgWyIuOupmK38rsPcOvqJO33XWEvwLJsmKxHRVEwf/MKWl/yUMf8mIloWN8rw+sP0D6PHQmYuzGNgCRiMZVA17IQV4OIaTI8buH/AJMFd02Tkp05PO4jnWvc57EDAINt7u1X8Pb9KgI+Lxbv3cFR8xjx6AQ+b+Txs/qL9KePlih2CMBCq92hg2qzt1AoV7H5YxdhdqhHzRbgcpFeqdUplpvQW4FhmAixZ/sws4BoWCM/qmsE5XqE3dDQCrqGAYWdejqZgK6GUD8+IV9VghBFN1RZJv3sT5diBwC15gncggCPJKF0WCPN8dun55jQdVpz3Ynl9leAAQAJhiGatD9AOgAAAABJRU5ErkJggg==');
256 - background-repeat: no-repeat;
257 - background-size: contain;
258 -}
259 -
260 -.ipfs-png {
261 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmtJREFUeNpsU9tOE1EUXXPp0CAUWmJbC04xBANNTF+kKhG8fID6aqL/gPEj9E0lIf6Dj30HL03wxQtVIC0QKrWxNG1Dk9Z2Oj1zxn1m0oIZTnIyZ8/ee+211z5Hsm0bYg29fLGpxWIJWBYGS5IA8ncKhT9Wvf4Yqprtu+w3q85X7f9QxseD/pmZMZsxN9fnc5JNw0ACGGv6tPSvyvEDKEoWZ5Y8OHHObKpucw4B0t3agnl4CJPs2YkQVu4s61ORaBqMJc8CDBiIRhhVM9bXYdVqYAcH8M3NgS0tQQsFcfdKHEbvlr6WyaR/V6uPKPy7B4DT7lUq4MUipMlJ2MPDUKtVfKZ2nn/5BoNbkONxXeb8LYXe/A9AJLNWCxgdhZJagDI9DZg9qIkEytRSkdqTSFQtGILSbgc8LViM+tc0yPfukzIyOJ359k9YR0eQdB2KmBbpwXoM3Dod1SkD+scpEapCI5DdpsJhIJcjajQZagcjI+5oLe4VkeQnyiZgdIH2X6BJ7dSqQLfrggjw0AQwP+/GegCIHppNoFAgEMO1RZKo7BQgRi3yN05cnwdA0BQMAgF3C6pnbuNg92M9AFT1diSCh6kb+FGvo2MxnBB9ocZxp4Mns1cde213B81e7xwAcl4jkaa0IUSjUdLJwkL0Ej6VSvArCt7l81iku6GrKnYEU89VJlSJRmR0Dax+fI9suYxSo4HlWIw6M3FBlnD9YhiXabyOsOeIqG7TzDeIYo6EDGp+ZPb2kKKqH8h+mkxiI5/D1/19J3bwYPvPWXq2skkiJVxesqt0XzghpKM8nRVV2Lv2q9eLIvSfAAMAaacnllcFBmYAAAAASUVORK5CYII=');
262 - background-repeat: no-repeat;
263 - background-size: contain;
264 -}
265 -
266 -.ipfs-ppt {
267 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAkhJREFUeNpsU11rE0EUPTM7ySZpmzT9DNamWAtFfSiCigr+AxF9zKtv/hvf/Aki+FEi6ov4ItWHPGiwiBUKoUqqTUJImmR3M7Mz3t0kNe1m4LIwc+65595zlxljEJzdR5uf5nLmsvZx6gSvtd9W9bjhF7jg5dH9nRc/wq8YXaTSJptb0xklx7IZoKUEz1zJ2DUU69/37vFYrDxegJ9U0lC+AoIIVGg9CL+vIObP48KDQn7x0sWiVnJrnEDg7KGk+i/Ac4iUM/R7BsmrSSxtXMfa3X7el8+Kjf3KfUJ+iRJQw4w0Tc8BRyWGRAZY3rBR/VlC+XED2ayDhZyXl03+hNA3TxNQshlGLAnE44zCIL1goXZwiMNvB1i6zbC0KuAsxNITWwgNMYPeLVJiFEO9ArjHAivrAjNzBr4f4vwIgdGD4YUACsZCE8AtYGWT5jCsGQw5wEYJzP/pj5RwYTA1b07eQmfZ8P0sgdaM2FlYwWkMgMpl6NQAO33GKM0wsQWflkh1uqGVmVWblsiDkQyqxwfag35SqcktaEWTUTHYNx4iGU/C29+BvX4Lpu/C7zYgFjegSY63WySsHyXwpYHU00ieu0bAOuJbBTArBkiXKiaAmTzcvRJUV9E8rOgqBwqlY8ASs/AadbRLb8CzeTjVClqft6FdB17tL7yeCbFRBYoLr6vR/PiSEl5BZJaBD0/R2nkOZqfQ2fsKt+0SEQ+GLSIEUvJm+6jbah2+pS2aon+4g/afd4SYJVuA7vvXdC/IHQtSoTnK+yfAAIEaId1m+vudAAAAAElFTkSuQmCC');
268 - background-repeat: no-repeat;
269 - background-size: contain;
270 -}
271 -
272 -.ipfs-psd {
273 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAqxJREFUeNpsU01ME0EYfbtdKKWGtoItRWgJHApCBE2I0YuoiSaaeDJeOJh41YN3TfTixcRwMfEk8eDJGA+Eg0YTTRRMg02KKFooCBbTlkJLS7f7P+u3K9Xo8iWT3Zn55s173/uGM00TVlwZfzJztD92iKO5ouvQGQPHcQDN380vlDPr65fdLj4Oa41i9sFt+ytgN7o7woGOrqgvvpLBaF8vWj1NUAwGTVNRM3mf5vU/zaU+XySQuTqIFXz9hxmGLkoS7r+YxvVnrzGzlgXPDOzUZPT4m3Dt/KlIuH9oUjXYEHZZ/wOgGQZi4TZcGI5hLb+FO++TSOSKcLtcMA0dI0EPrp4+HtnfG5skiUecDGwQE2MjAwiGWlFVNDz+tIyCokJhPKYSX7Gdz2I01hOJdnY9rJ/7UwPGTEiqjtbmJtw4MYx78S/4Wa3h5UoOYwPdIOp2Xi/t18rlFgcDw6o+ydiWVRwOBnCpL0oOAMmNEhLZIgSeoxwGSWcERon/M9DoBknTIdNQNAMnO4PIVGpIFXcwndlA2OtGc4MAxml27p4AIulWSIa9QVadiYSoJxhqBJivKgh5ad3k9gaw6JdlDaqq7q5wINY4F22HaLHSDZQkBW72O9cBYFEviBIURQH7a7MN0uDisUW12ZZcaGlmdq4DwCqeTo1zNtZuW7hUqGIw7MNqSUS2ImNsKEpSdEwt5lGhfQdAkQBEoub3NNrDJfAIeBuRrcrY5xGQ2RFJAjl00I8PCckJUCB9q1URBnk38XEJEuk41tmGwZAf66s1VOh2keqwoUnYpFxHH4iKIixkN3HzVQKP3iQR/5GDKMuYmE3h+fx3MHqh1sMafztHLuiCg0FAk0uFdLqcpGY5QEXbTC/j7mIaVjc18DxufUtBJ/vcggs+3ijVz/0SYABsJHPUtu/OYwAAAABJRU5ErkJggg==');
274 - background-repeat: no-repeat;
275 - background-size: contain;
276 -}
277 -
278 -.ipfs-py {
279 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAlVJREFUeNpsUktvEmEUPTPzTUFmgJK2UqXQFG3pA6OBLrQxamJcaYwuu3Dp0l9iXLvVtRuDpgt3JIYaTVSaxtRHsJq2xEJBHgXmifebMhECXzKZme+ee+65516h2+2Cn2cb2VwyHl12//vP2/zOQaF4uD7GWN69e/LogfNm7kUsPBFaXYwHMeK0OlpQEJApHJTuykzK98dE98O0bLM/UNgr4v32Dj1fwSQRt9dSsfmZcMa0rIv9ODaqYrPVxuPnL1Cu1aEbJu7fvIZUIo4bqeVYRzcyv/8c3SPYpwECt/dmu4ON3Ed4TymI+hQc1ZqoE+F+uQLDsnHlwkKMscJTgl4eJOi9fxZLePNhGx6ZQRRFqH4VjZaGSv0Y6cQcJLpra0ZguIWegqDiw7lYBBZV6xiGk9DQDLzK5bEyF4Hi9VLMsoYI7J6Es5PjeHjnOl5ubqHaaJGBEkzbxplQAKIgDmBHekDTgI+qKKqKLvNApgmEgyquLs1CoFn2Y4cIeLJpkjoCLkWnUSIF3JxISIUsCjAoxhWNJLBIJs3YeXj/08oYZkOKY65HllE/bkMmY504YUd40HUq2JSSyW6iVPmLiXE/ZMYQCU+hXK3h1toqdNN0sEObyKtqtDQ6kXDwcadDS2TBryp4nX2HxXjsJK6bDnZIAZem6Tp5YMMmicn5OC4lztNWtvB9cg+hQABtWjKL2jH/T3GgBcYDXEE6mcDM6SlaJAGMWkivLBC54ZgniZaDHSI4rNSqn7/t1vgkGJPwZXffSeCjk2iUWz9+nSTQN8e6ef8EGAClUi/qoiOc3wAAAABJRU5ErkJggg==');
280 - background-repeat: no-repeat;
281 - background-size: contain;
282 -}
283 -
284 -.ipfs-qt {
285 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnVJREFUeNpsU8tu00AUPU5sp41NkzRxpfSZqi0VIIQqEEJUZYXECvbwCWxYsuBD+ABUFrDrCnWBQEJdIWigBSr6pqRJ1ebhxrE9M7aZmSrQ4o505fHMnXPPPWdGiaIIYrx89GKpNDdxmXkU3aEoCsT+z8W1Sm21+jCpJctQTvaerj+TX7WbnJ+0cpfuX8mQtn8GgJ4AZtIFY2Hz3foDVRcgyt+cRHcS0IARh+D/8G0PpmVi7smd0dLs+AIjwTVEiANEYYQwCHlEZyJgIQKfoX84g9uPZ0cHZ4YWmE9nuufU0wABCSSImMsWEgqSuoqA/39/swZFTWLy7vQo7dDnfPvWWQa8GuOV3IYLJXmyzDzG2/ChZ3pwbHdQ267BKJoYuj7SF2MQhiF8LuDK/Gf0DKTBKINz1IbTbEMzU1ANDW7LAfEIQKIgBsBFlAx6LYOz6MAcvoDCtAVGGPKlAiIu/F55F33FDA6W93EOAOMaMOl7biKPwRtD8Foetj5sYPfTDtxjl1f3Ubo5jkQieQ4ACSUD2iE4XDpAdbUiW9D7UsiN9WNkZgxajwbd0LGzt3keAJPUc1N5SVeENT0Ao2BKV6QzwlZeRBSKAYhe3aYHcZWn7l1EfjyPypcK9LQGa8qCvW9j9+MvaasQOHaRhGWdhsNLR8hwodYWf6B4tYjDjSOovRqq32rSYq/lytw4A77o1V2ERiAtzY5kkUrrsH+3QF2KY87ArTtQuQ6nAf4x6FCV1D001+vYersBM2vA4y1Rm2D7/Rac/TZIw4d/6MrcGAPf9htN0miJh7Lyuoyvr8rQeP9iVJcrSKgJ+TrFcyYebXTP/RFgAFQobmIOBxbsAAAAAElFTkSuQmCC');
286 - background-repeat: no-repeat;
287 - background-size: contain;
288 -}
289 -
290 -.ipfs-rar {
291 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnpJREFUeNpsUktPE1EU/u68OgylZXi0hZACQU1LEKKCMcat7jTRnQsXxsQtv4E/4M74P1iriUaNCw1FgxpjCJQKKAU60+m8mJnrmSll4XCTc8+959zz3e88GOcc8aq9evChOHl/lvMoubvWX/z4+BwTlbvw7bXdg8b7h6LE1gGW+O88CRMt4XTlR6/rYxce5Xv3jlHH19fPkBu+gWy5mlcFb3Wn/umeKOEMJF5C7xCFbtA9dRXjFoYKGiTRAlPGUV1aKU9O3VwNQ74A8DQAIZxqAuAhBPIMFYpQVAVB4CPSZjEzv1weH5tbDQN+JQ2Abu488mnzIbAAA3o/VK2PwDJo7r5Fy7ZRuvi4PFS6+qIXdVYD8Jg6BUcuOD8BozSLlRWyicgVKkTMQWwUlFF0Ooe5FIPk57BD7G0SiywyjD8bCDyHsOkeeeR3SUxEkROmU6BfQYFJMHfhWXV8efkUrb13VPMTsrcTQSzxZ/+n0GVA6EGbSGdgG9vo15fg2nFgbO8k70SRdd+mahDT81vUxTZRlJBRMsjq89C0EXCvSf7TIBZ136YZUJEiE7LgJ2dN01BZuE0dkIhxE7KcQTK1QUj+cwAEyrPZ+IydzRoyah+mLy2isbWBweESJEnB9q+1RM9Ub9GQOWkABg8HjRr2d9Yh0hTlBlRsfn+D4vg0BvUC9rZqECUJuk7Tzr1zahCYlB6HJAREPwfbbMBzLBzsbUKVI0qBgQkc+SxgWUYaIAqOpKwKXJ6bgGlaaDV/YvHaFNrtDsKTfVSrJeqIg/bRNwjclFIALeP3saybhu8SC4VBHwnhBXXIKocYRXD9QzBi4Xgchmkd9+L+CTAAMqwy+ZzluBgAAAAASUVORK5CYII=');
292 - background-repeat: no-repeat;
293 - background-size: contain;
294 -}
295 -
296 -.ipfs-rb {
297 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAixJREFUeNqEUktvElEU/mag5f2yJhXLwxIt0kiqsVEXujP+A925cu1Pce3WtXVtYuJCF7KtTY0NrVQIpRVKeXTkMcO9F8+9ZVooJJ5kcmbmfOe733fO1YbDIWS8+/g1dycVX7W/xyO3vdsuVKqvnE7HZ230783rlyo7bVBicSGyfjsVwozomVbIPe/c+FmsPHfoRKJd1HT7hXHBZjVbA4aA14NnD9bC2VR8gwuxPi5Sx39Cp+M0XUP0ahhP1jLhW7HFD4zze3b93ILtXYyyVKlR8/5hFbnvO9gtlrGSjOF+OpXkYviWyo8mCS4R6bqO4p86vm3v4fC4DrPfw4unj1XN6JvBaQtjChzUXK43sVU4wNFJA43Tv/B73edQwTmfIhAjCVL6UdPAj1IVFSKhCdAcAI9rnjBiAjtBYEu3GEeh1sKJ0YXR68sVIujzIhzwY8DEBHZqiLRKkicQDfvABxaiQTc4Y/C65pCOXwcjcmlvJgHtlwi4epYifiQWgmoLZwPW6HQG07LgcOgKO0UglAKOTt/E+09fwAiUWU7QAE9xUK3jbvomsispZVHMVEDSZdHo9rCZ/4VIMKAu0XGjpU7d2S8hk0pCELHEzrjKnCQOYJoD+Dxu1RyiwUm5LaMDo9NFt2cqDLvY4oQFp/QpfT/MrmI5FkWebt+NpWto0j2QmQkOjZ9hpwhqjXZzM/+7LU+cc7lRrjXh8/lVLRK5ovLWXglOsiOxdt8/AQYAzv8qbmu6vgEAAAAASUVORK5CYII=');
298 - background-repeat: no-repeat;
299 - background-size: contain;
300 -}
301 -
302 -.ipfs-rtf {
303 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAe5JREFUeNqEU01PE0EYfnZmd5FSvgLYFuwWt9EgHyEaox68eDJevHvwJ/hTPHv1N/QgZ2NC4g3kUAQKFKGhjVKqRrvbnRlnht262FHfy+y8877PPM8z71pCCKh4/ebt+rJfXEz26Vjf2mnsN5rPKKWbVpx7+eK5Xu2kyMtNTd5d8MdhiJ9BOO7atFI9ajy1UyAqSPIRMR6ZmoNehNHMMB7fX/UWvEKFMbYKE8DfQnAhwRmmJkbx6M6S5+WmK2Evup2c9yUk2nnKA0XVcSiGXAe1k5beP1i+4RFCXqnPywB/AKVzK34RjHNYlgVKCH50w7EBBogbTa/AVM5SgBdn0gc2AMDjPsbFPz2xye9asweS6n+NTbG8BCCfUtLjff2WoVnVpAH6z6hMUtJE3EykYfpF4vUiL3QNS7FMeSAQRBHW3r1Hq91B+VoBQRji4+ExFsvz6Hz7jm7Yw5OH92AcJKW9G4SoHhzhy/lXbB98Qmm2oCXN5WawsV2TACEoJXqwTKOsb3BtR2ucmZxANpPB8JUhyPnHWDaDpfJ1eZFALzJJ4MKO5MEtv4TSXB7V/br8iQLMz+almRZWbvoo5q9qRlxwewCgeXbe3qrVO5ZkUD/9jJGRLPaOm6COi92TU1DbxYe9umRD0DrrtJO+XwIMABWp9nS+FgaoAAAAAElFTkSuQmCC');
304 - background-repeat: no-repeat;
305 - background-size: contain;
306 -}
307 -
308 -.ipfs-sass {
309 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MDNDMTBBM0JGMTE5MTFFMTg3N0NFOTIyMTQ2QzhBNkQiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MDNDMTBBM0NGMTE5MTFFMTg3N0NFOTIyMTQ2QzhBNkQiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDowM0MxMEEzOUYxMTkxMUUxODc3Q0U5MjIxNDZDOEE2RCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDowM0MxMEEzQUYxMTkxMUUxODc3Q0U5MjIxNDZDOEE2RCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Po72XUcAAAJcSURBVHjahFJdTxNBFD1bykc/ttvdtttWGgI0bYrUgDZoNYqRJ014kMRXHvwB/hQTH/wFhMREJfFBQxBjhMRIFEQSCAlQxKYGggiU3e3HbnfX2bFt1EU9k9m9mblz5p4zlzFNExYmpue/jmTSZw5PZAl1MAwDT0c7O72wvPdudeNakPNtOZ0tsM7cvzdOc5yN5LDAsTFRAJks/kC2PxFRVe39Si6f4byez62EpAEH/gNN18F53Ri/Ocxf7OtdLMpKT42s/ZPg1cISJp/P0tg0TBzLCoK8D7eHh4RkLLJ4cCz12AjMXwgez8yhqtVo3NbqRKlcxcSL16gZwJ2Ry8KVc8kZO0HdTKlURn+8G6PD2SZhLMQj96WAiMAh2RXFYKI78lcJcx9WYBCycICnpNbojUWpD5Y0C4Zh2D0w6hWc70uQZC+IWfQZrXF0IsHvY+meBd08haAhoVMMQFJKWF7PNZM+klhRyogGhbqxOIXAMOtEwGAqDqVcgbVkkE+5UsEAWavf0az2t0ZqvK2qabh6IU3joizDwTgwej1LdVfJXkdbK8mt2QkayO99A0/0trQ46I1lVcX+UREhnsP34yLp1AD1xibBMuntpzU8mJyi3Tc1O4+l9U06n7x8Q/8PHz1DrrALt8tlr0CrkbJMHTop9Sk5sLa1g8L+ARJdnShKClY3tunN69t5iGLYTlCtakjFY7gxNABdN3B37BaqqoYT8pyX0in4ORbRkIA46YlDRbUTbBZ2Jb/Pw4qiKFnapcpPo9pdbrg8DjAOBsFgELJmsGs7eWkkc5bu/xBgAHkWC6UPADTOAAAAAElFTkSuQmCC');
310 - background-repeat: no-repeat;
311 - background-size: contain;
312 -}
313 -
314 -.ipfs-scss {
315 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoV2luZG93cykiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RkM4QjYyNDVGMTE4MTFFMTlBREZCNDNEM0ExMTk0MUIiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RkM4QjYyNDZGMTE4MTFFMTlBREZCNDNEM0ExMTk0MUIiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpGQzhCNjI0M0YxMTgxMUUxOUFERkI0M0QzQTExOTQxQiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpGQzhCNjI0NEYxMTgxMUUxOUFERkI0M0QzQTExOTQxQiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pkf1yeMAAAJbSURBVHjahFNdTxNBFD0tLULpB91uodVWPmorUIxo0VSiNSExMYYHE33l0Ud/in+C+OSjYgjRGDBRCKJIUkIEWi0WKlja0ul22+5219lJ26gLeiezuXvn7rnnnrlrUFUVms3Mvd2bjIyezRVLBA0zGAzo6jhjm1te+7EU37rFO+w7JlMbtG+ePJ5mOaZmci/nsPl6ONBtw18WDQc9tZq0sp7YjTisXV/NFKRpRvzHpHodDqsF03djzuvDg6vHJWFAprF/Arxe/oins6+YryoqCiUBvNOO+7FrXMjnWc0WyIAOQP0N4Nn8IqqSzPx2swllsYqZl28gK8DDyRvcxKXQvB6gISYpiwgH+jEVi7YAfW4nEqk0PJwDofNejAX7Pae2sPhhHQoF63U5Gai2Bn1epoPWmmaKoug1UBoMrgwHabIVVCx2jdrKFwm67TZ2plldPQGg2cK5HheIUMbaZqKV9In6giDCy3MNYXECgKI2gICxoQAEsQItpNCHWKngMo01arTY/jFIzbutShJuXh1Fm9FImYiM7tTtKOtbO+toN9Nc+fQ5SGUOIVYl7HzPIH2YRZ0y2KZ+sVzBHn2v1mpMGx0DTaR3nzfwfGEJdybGkdo/wEigDyvxLzg4yiESvojZhfd49OAeLJ2degaSLIPOO6vwgiYaaRErTRREEdn8MeJbSVZ5M7nLdNExqFLaQwEfFfACQn1+HBWKSKb3MT4Sgstuh9vVDa+bQ4DORE6o6RlspzMk9TOPfr+fiLJCLFYr3TZSKNcI7+aJwWQmPM+TkqRg49tu65f/JcAAMwMas6WUKd8AAAAASUVORK5CYII=');
316 - background-repeat: no-repeat;
317 - background-size: contain;
318 -}
319 -
320 -.ipfs-sql {
321 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAh5JREFUeNp8kctrE1EUxr+ZyXMkoa1NBROaSkpTBE23PhZ25cql2y5duvAPUdGFS1FxIRRBXZlFQ9GVdDENIhGJxkDsw2mneZnM83ruNZlOmNoDhzlzz3d/9zv3Sowx8Ch/qlYK2XM3cEJsbH0+qjV/rd6/u6aN18b7RMFT+9aosP/Ex+0ae/puw7j36PlKEMAzctKJ3aGFamMHjV0d+wcGitkMrpWWp6hVIciEk2MAOwbUWjosx0UiFoWqJpGMx5DNzODq5aIPoa82AWBg/lyKLMH1PMp/a9XvLXLzG1cuFlBaWpiKxaIPSLY6CaC93ggQjyiQZRkeQSzLRovGaPciWLt5faSWEBoh6KBvOhiaNga0+Y9pwaFxvu7rfp8F5pWDt+qNMp2IijHGwddWCvN+33/CoAOP5nVdT9SdoQ1JkggiQ6Yvr7V60+9z7akA2gfH9cRF8hO5F5Ve4lQAF9uuK+qFsylkzsQxrcaQm04hdWkR83Mzfp9rQ3fAFzu9Ph6+WMfjl6/pGBdb2jbKmx8QlRjWy5vkyhUZBPgOeGNHN9AbDLGUz6He2hVj3Ll9C8/evsdgaMK0HV8bcmDTU0UUBYXcedR+NLGnH0I3jvDk1Rsy46FP4C/1BtrdntCGHNiOAzWZgEKQ5Qt5lIqLojbaXSQTcRy2OwT4SZqk0IYAOgkVWUE+lxX/zb0DpFNpkTzmZmfFtzewhHYcfwUYAMZmVaZQlLFHAAAAAElFTkSuQmCC');
322 - background-repeat: no-repeat;
323 - background-size: contain;
324 -}
325 -
326 -.ipfs-tga {
327 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnxJREFUeNp0U89PE0EU/ra725K22ILRGipb22pMG6JcSEQTbUIwnozxpBcvepeEP0KPogcT/wlNT17kIKbEmChFUYKGVtL0R2gLtNCl3Z1Z3+zSAlonmezOe/O+973vvZEsy4JYnqdPMu6RkSQYQ29JEkB+PZcrslrtPhQl23VZc8/tr9I1yMHg0EA8HrBM04lVFAhoY38fSSDQVN3pfKV8G7KcxZHl6v1xblqU3eLc3p2VFZjr6+gQgwsnhzGTuq6Nhs6kYZqXjwL0GFhEl3U60OfnwWs1GGtrUKNRsKkpeIIBpKIRtI1J7cX7hXRhc/MOhXw5DkCZGG2zXAajzFIoBMvng1ypIKOqmP30GW3OIEcimovzlxRy5RgAFwDEAIODkCcmIMdiQLsNdWwMZdJlg8pzEUt1aBhKq3XinxKYqF9yQbqRIqsMy+0Gyy47bKgUWXSLtDENE5wdtuqQATm50F1VnPbRGeEw8HXZbiV8fsDvI9ldju9vADAyihLEbrWAZhOoVp3z6iqBUiB1A4nEfwCEsbkL/M4TgE5n5jDx+oTEzp1d8m9tC8H6MaAB0imzx0NU/WKUYE+loEyawDBo2ui6TGfT6ANAxrvx87gYCGCxXEKVJvCWFsG3eh1vN/J4OD6Od4UC8o0G3TX7TGLHwI9iEQmvF9X6Fh7F4/iYy+GcLOMSlfEgGsP0qdNOmX0BiGKpVkV1bw/1nW2b/gCpf1PTcI+Y7eg6ps+G4bG4PR99SjAVo9HE4q+fKNE0vl5awuSohjeijbRefVjAtUgEQRK7Yhi9OKn7nKWZxxlSPWl3QwgnaIrW8QMhD542vUbx/W49m7sq4v4IMABOqi3Ej7bAEAAAAABJRU5ErkJggg==');
328 - background-repeat: no-repeat;
329 - background-size: contain;
330 -}
331 -
332 -.ipfs-tgz {
333 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAnhJREFUeNpsU1trE0EYPbMzSTfdtInFtkkpiaXVWou2FRUEn/so6JugL/oH/Af+B1988if40jcFERQURNBSQdDWlLQN2lsue8neZsZvc7FoOrDszM75znfOmVmmtUYyvry++36yfOeS1qqzDtvH2P76ApPlW3Drb2sHex/uccHWAdbZX30kO2+B3siN3zhTnHuQ66+95i423jzFzOVljBdKOZNHazvVT7e5wF+SZBj9iZJ+3J11mbW2kR8T4LwFli5i4fqTUvnczTUp9RLtDhKgJx0q4dEwWAxrREKICHEsoYYXMXvlcWmquLgmY71yCkG/c0AkARgLMZpnMDMpGNzEYe0dGp6HwvmHpbHC1Wf9MnFCkHQOyYEPzSJwQ2B65Tm5NZG3Fshim6wbMNJn4bpHowMKtIqo2COgR2IcAptwjvcgo6i77igjEmVDqbY8xQJ1VwRULhiBI6+G9Zf3cbTziuzIDkmHSNqECTFgQScEcYuc2NA8TcdYwXD+GkK/TYVN+u72WrIudiAD8o6oAR2RRCmQMjis3CIy1iSpPySCXhFTXeyAgh4BR+JVw8pauLi0Cp4yCX9A90FQhnSBYtnF/k+Q+HYam9itfIZB3QvT8zj8XSW5EhNTs9ivbSLwPUzPLNPJBIMEKnaQYg6aB9+RGR5F5VsNgnNKXMI1NdJGG5WfHzFVLJ7k8c8xUngpVodlDSGbFYj8Y4yMpOG09lHf3yIFPzA3fwHZTAQVtU4JUTeFDrdgDdlI8wAz5Qy2KxswReI7QODZcOr0ZH3q2hIDBI7zq16tuk3FNPxAI4wN+pkoccYoE4YJU5EdUtM4Qst26v26PwIMAKj3P/2YUKgYAAAAAElFTkSuQmCC');
334 - background-repeat: no-repeat;
335 - background-size: contain;
336 -}
337 -
338 -.ipfs-tiff {
339 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmRJREFUeNp0UktPE1EU/qYzHWstlrYJNcWUElyUJsaNGh9B0g1Lo0v9Ey78EbrVxBhXuHShm25YGBJRQpAYBDEWpaEPEhksdVpbyjzveO4MfZDCTWbauefc736PIziOA77OPH2yJCcSGdg2uksQAKofFou/7VrtASRpvVNynj13f6XOhjg8HAlMTIQdy/LO+v3uYUPTkAHCTb+cK+0pdyGK6+hbvu4/xiyHbncYAwfR19ZgbG/DoO9LsSgeTd9JXoxfyMG2rvQDdBlwIZauQ5ufh12twioU4E+nYU1NIRCNIDs+Bt28mXzx8VNuZ796j9q/DgAwomwqClilAmF0FE4wCInAlkjO4y+r0JgNX2os6XPYS2q/cQyAcQatFjA0BPH6NYipccAwIGUy2CVJFZInkKlyJAqx3T4/IMGmJkeWIWSz5KgI5pdhb3yDXS5DSCYh8rTID8s0wexeVD0GtMd85KkkefFxUfE47M1NokbJkByEQl6tL+ouAI+MUwbFhnYbaJKc/Sqg0x4H4eDRGDA56fUOABA9/GsCpaIHwr8FOhQ823O5RfW66tUGADhNy3RNRDjcN41HLxdQ8J6jYTsOQLfOJBK4f+s2/uoathoNGKT1MtFeVHZxdWTEZfEq/wMKl3rCJOIzTV6ADs2R5ulYDDNkYjp0DhrF+zCVgkw31+v1UxjQZkNV0SADd2o1MIuc9gmY+/kLxb0/UFoHePd9A1qzeUoKpilx9xcLWzgg+u/zeVfuQqkM9bCN1ysrWKXxdtPgvScwUAm58XZ52W16QyPtifRUzi588GbEi1ztHPsvwAC4uC9qhnsZvwAAAABJRU5ErkJggg==');
340 - background-repeat: no-repeat;
341 - background-size: contain;
342 -}
343 -
344 -.ipfs-txt {
345 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAeJJREFUeNp8UrtOG1EQPfsyXiyzBguIJSyChZBBEFCKpKHLo6egpErNn8CHgH8gkZIiTSIXLhJAWCgkoMgRMSiRBSK29z4y9+I1d/HCrFb3MTPnnjkzlpQSynY+fP70fGF2gQuByCz6lfdd9Uurfvrrjes6762eb3tzQ69uFJwPsqOPC+MBEmxxphi4tlU5OGmsOzaBWLc+O9oIIVhScidkyGZ8vH62nHtSKlaI4cse6TjAfSaFBBcco0EWqyvzubmpyQrj/FXk75cQaSEMeMXU8xykPA/Hjd/6/LRcyjEpt2i7HAe4A2TeLZWKUOJaVLxj27j813EHGKCXaAJExu/4BOdiAED08riQD2riOrexyRoYc3CvsAbLGAAjZga7vgZG23WMCdBvoxKJc36TRBlMiaa2JByjNqqD8qkYc1pjDK7abey+/YhrWlfKswhpiCR96aEU9o5+QE3g2ovVWDm2Sc22bBQm8vrVpbkS9r+doPr1EOWZaQ0yFoxg2PcREosEAI4uvZhJpzFMP+cSXRbq+043RManez+tNWKMI6GN0g0Z04HFR+NoNC/0yx717efZOSbzY3AcR4Op2AGA5p/W31r9e0vNgSrh9OwCrpeCkqvZuqTybnpRqx/r2CjvvwADAJC/7lzAzQmwAAAAAElFTkSuQmCC');
346 - background-repeat: no-repeat;
347 - background-size: contain;
348 -}
349 -
350 -.ipfs-wav {
351 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAApFJREFUeNpsU1tPE0EYPXtpKbX0wqUQKVQMFdIXQBNCQBs06KP+B8ODGh+Mf4b/4IsGE54kxhcMBrkp7YOQgBRvSKG73fvsrt8Otoask0xmd+b7zpxzvm8E3/cRjPkniyulW0NFy2JoDkEAguOlpXJ9p3L8MBqVl4O9YHxae8pXuRlcGO7KPLhfTDVUqwUgigJMy4Whm6lEXHjxYf3XnByRN0QB/2KaH7btMlUxoRJAcyqKhdOaht7+DJ49n+2cvTnwynXcsb+kLwJ4rgfmMDDGWqvneXCZS9ND7mov5h9ND85M9y86Dpto5rUkuJ4Py3YDJpy6QGJPayqB+Njf+43XL220t0cwOZkfrNXsBUqZugDA6CbLdAiAwaek1ZU9LmP8Rh6S78GsGxjOp9FdzKJaVZIhBgGASzK21w/wbrnCk8euX+EMAjaaZuPHdwUdHVFYluuGPGCORwwYjg5rqOwccRk+3Ux0IEvntmsNG4ZmUayL/wAwKHUNfZfTKN0ZRaw9Cof8qJ/pMAyHy5KkAMTksSEJtnMenM7EMVMawbejMzJRh67bXEYiIXEAVTW50SEAhzqwfqrBcXx4VOhYm4RsNgHbsJFOyZTsQ1MN+hcohoUlkFiMT+TQFpMwXOjGpXgE+XwGk1N5pFJtKNCequgYGupCRBbCDOp0KBJc4VoP3dyBONW8uydBgBHUThqQKCk3mEZ/LoUG+RBioJO7VarAwEAntjYPiUUW9Hh4b2R7k9j98hN37xWx8fGAt3eIAdVMLn+uUv+b2KReSCZjZJiB9bV9jIz2ofr1BKvvd7G9dRC80lae0HzOt+cWVnrSKDrMJykifwNBpCgE/UAllEXufmDu8Zlffvvm8XSQ90eAAQA0pF7c08o4PAAAAABJRU5ErkJggg==');
352 - background-repeat: no-repeat;
353 - background-size: contain;
354 -}
355 -
356 -.ipfs-xls {
357 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmxJREFUeNpsU0trFEEQ/mamZ3Y2+0zIC2MmITEkUYgERFQErx5E8KTi1b/h79A/4SW3nCNeYggBYZVEMU/y3N3Z7M7OTD/G6lk2ruw20zRdU/XV91VVG0mSQK/3n1a/jky6d6Xs3G8WXS+Pw5N6LXjLLGuna/78oZKerGsYKtrDE16uJGL1L9gEOOcYd2dL1fNwrbL//aXN7J1efPMmkUqEFAk0A0VZNbFEaQCBscIkXj975y3NLq9xye8PBkAniHOFph+j2eC4rsdoB4LsFubGl/Hq8RtvYWpxTQi52o1jvWiGYaRZL0/auDgOkC/Z8BYL2Pqxidp1FZkhoDxpeaXA/Ujuj/4HoOxKKjiOiek7RUShRNQWaNYFQuMafrYCxiw4ozZKfqbYJ0EvRdl1DQyyTs8XCNTA6UELMwvDyLpZWIZNNlNLlQOK2LMJRJ+5AkuZ1S7CFFzJzk56GnUjQWlYkqCoBWFbonEVYcLLA4dNnB624GQsDBWIgfZJEgxkoChzSFWvn4VpQemDm2VwXQsXJwF1h6c+gxlQ5jgSiEUEt0wdIe7tMES+nEG2aCLiJMOIIWIr9e0DEELAMUrwRuchVAyTKimUwO75Jm6VF3Bv7imOaj+xd7UFKVS/BPJF1b/E4tgTrE49J60O5kceoNqowiuuYKa8ghHXA48U9MT2AQgyRvTThE30bQiaSGa4yLMJNFo+Dq/2cHt4CYlwyFf2S6BHwwrMw/avDbR5C1k7h1YQ4KH3Amf+AcZyEbZPv9CItzQD1l9EbtYOjv74v/d3O9RMPTDrsEwGIWN8q2yk7XNYRs9JrRv3V4ABADSGR6eQ0/NQAAAAAElFTkSuQmCC');
358 - background-repeat: no-repeat;
359 - background-size: contain;
360 -}
361 -
362 -.ipfs-xlsx {
363 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmlJREFUeNpsU8tqFEEUPVXdPY/ueWZIoiYZiSYKYhJc6EbduHOhgijo3t/wH1z6B0JAhOyMILhxo4kJGk1ASTAxwWF0Mpp5dHc9vFUzYwidaoqmq+8959xzbzGtNcx69PTS26ETmQtS9r4Hy/xv7MW7jV+th5yzVcaYPX/++It9u4NAv+CVR6tBUUTqMJsDcRzjZOZM8W9ZLKx+/XDb4e5/kH5In0lpIYWGUaC0YTZnBCAEKoVR3L36oDo7NbsglZwbqD6iQKOXFMcKUVfBkBAoQhlD5xxMDp/HrSv3q1JgYW3z0x0KXzkCYJaRZljru23aHWTzLiamAyytv0O9UYdf5PArqlppBfMUfu4oALErqZBKcUxMFRCHEp0DgW5Lo4N9NIN1dF0XXsVFOUyPJTzo+WBANDidjp8tgHGG3c0DnJ4uIRf4cOCBaW5KjY8xkZL72xpJ9QcFz5bVqHUJGHZL2YtNmKi06YCyiVFb4s/vEKMTAf1p4edOG6mMi1zR6wEpdUwX+vLDtkCzHoK7ptcM6ayLmGajvtex4PliyoIkFRjmUEASelB2rXQRSfjUCT9PlWpmW21iTGzCAyEkUixPRqXhe2V4zKczbdmybgkpJ0cGOuA6Y2MTCsKoi5HsNK7N3MN+uwYaWbxYfoLLkzdxcew6lrYWaZhm8PHHG3zffp1UwJSHz9vvkU8PodbcQYYYS5lxYkxTkGdVDQdV1Js1qPgYD6JIuIE7gsXVefIhIuM05k7dwMbeMmh87a18ufIMaVYyprrJLgje2Nr+1tzYXANnDnr3zRhHj37Vvy2wpXHtNAd5/wQYAD6WMuT2CwoVAAAAAElFTkSuQmCC');
364 - background-repeat: no-repeat;
365 - background-size: contain;
366 -}
367 -
368 -.ipfs-xml {
369 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAilJREFUeNqMks1PE0EYxh+g3W2t1G0sEqyISynUFJsSOShNwCamiYZED3LgIkcuxoN/iCZePZiYGD2aGD+i0F5KMChxlVaakAK2ykcAt+WzdLu7zkxo3WZL4pu8mXfmeeY3885ug67roPFh5nvc62m9hjoR+5LMp7MrkYf370qVtco+VtCUFpbj+jGR+JbWn76OyQ8ePwsZATQb8R/hanZgINgj9IqeuBFCw1Kt9OMBnNWCs24XwkG/QKYUEiGjVAPQof/rq0783pShET3ULQo8xz0iS5FaANmrHQH2DoqY+DSLSz6RzecWlnD9ymU47LYjd4O5BXqDTG4FM3NpTEkpdJ5rw0AowLRMbhUfp58gTOaD/UHmNQPI6YmvKWRX1zESHUJ/oBs2nmPa+Mgw0ZIM3tZyGoJwygzQNB2jNyJIZX7iB0lpPoM70UGmPX8zCU+rG8NDVxHwdiC5mKsPUFUN/gvtLLf39sFzVqaN3YrC6TjBauqhXhNA1TQoqloV7Da+pjZq1FsXUCamF29j6LvYhf3iISamZ3Fv9DZevouhRzzPfOG+3hpA9U9UyioOlTJ7pFeTCQS6RGzIebyf+oz5pSzWtmSW1EO9phvQ00slBRt/8qR3DoWdXbiczUiTzd52D+tdLmyTB14mx1rMAKVcRpEATjrsuElee/HXGmnFRyBOGD30C/nEDjNgs7CDpsYmnHG3YPegBCvHs9oYfm8nG9dJa5X4K8AAQzQX4KSN3wcAAAAASUVORK5CYII=');
370 - background-repeat: no-repeat;
371 - background-size: contain;
372 -}
373 -
374 -.ipfs-yml {
375 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAdxJREFUeNqMUl1rE0EUPbM7m5Y0Zptu21AwWwhYpfSDFh+kvvRd8N0Hf4I/xWdf/Q158F0QoQ+CVsFKaLSQpt/dpmvztTOzzky6cetOpWcZZvbO3MO5514SxzEU3r57/3GpWllM/tP4sL3TarROXuSo/SWJvX71Uu80Cfhlr/T4UdWFAVfdnmsTUtvdP35OUyQKVnJgXDBTcj9icAsTeLax7j/052qM81UjwW1QJXEhMF0qYnN90fdnvdogYmvJPU0/VBApD4hcDrWRcyikfB17srzgW7b9Rh1vEvxDlI4tVytaBSEEtmWh0xsUMwpwnWjqAlcxogiHd1wiQyCu87iI/+sJtf6+NXsgpd7FWCMB50KvkYMGMbLdZgLlfj+K9K4+FnFQ2x7WntIs50AbmiGwLILt+k+EvzvSNIHzdigdJ/AmXQRhiHv5POSwYmG+cqPVo0HqDxj8uTK2vn1Hfa+JmdIkvtZ/4fOPXU3WPDpFeNWVyUKryCiIGMN4zsH98gym3CIcOTwT+XHdXrdQQHAZotE8kBPpSqPNHtBOr48HUmLOcXRJT9dWNMGYJFby91pHOAvaykSaITg+bwefdhrteDRTMSwyrFCgI88E056Hy+4Ah2cXQZL3R4ABALUe7fqXWFN6AAAAAElFTkSuQmCC');
376 - background-repeat: no-repeat;
377 - background-size: contain;
378 -}
379 -
380 -.ipfs-zip {
381 - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAm9JREFUeNpsk0tv00AUhc+MY6dOmgeFJg1FoVVpUWlFC0s2IFF1jxBbhKj4BSxYdscPYcEmQmIDq0gsERIViy4TpD7VFzF1Ho5je2a4thOqNhlp5Mz4zudzzp0wpRTC8fPrk0/TC6+fDtYicLH97T1Kc2vQDcs+rH3eUAxVznn0fn1DRM8E+iOdv5ct3XmZG6yVlNj6solUbgVTt0q5FGtX6vXqC6VklTE+KAO/OODHSIQPRQpsXC+kkEz2ELA0ystv84tLzyucsbWByisAGf+QAS2CCDRRLMJMmxC+i8C4jdLCm/zM7OOKFGptcO6/BTpJ0yeQB0Y+mfKQuZZG0jQgeRbW8Xdomobs9LN8scc+UPHNy4Dwq8IljotIIQEm59/RoSyM1CKkXKZNBm7kIVgyM6wgAnSgRK9vqQfHPiMFDHqyFVsLR9Cm0o4YzoAASrSjCelQfRPb1Vc4qn0EY5L2W9GEaBLcxQgFHpGbkMIDJ69e+wjJ8VXqRgKid0r7ftQdxkRs9SqA2kgAm14SSIQh9uhuLGPMnKJs/5KquL1x0N0RCsizigoDaLqBdHoMiyvrlBsHVx1wphD4BCewoqxGKKDwAgtOy8JufYuk+5golGGaGZwc1sIGoDz3AOPZSVLaHgVwydoJDM1H4DbQODughB3YpOD44HfoHgnu4e7So0uAi0stHLJ3Aud8B9bpHu6vPoSu9TtDl6tUuoFiIYOgu0+158MKmOxomtyD3Qi/3MTR7i8K0EDG1GHO5DE3X4DvNahZlJOwEkOATvdPc2//hx3mXJ5lFJaF8K8bStd0YGfnOJbMGex21x6c+yfAAOlIPDJzr7cLAAAAAElFTkSuQmCC');
382 - background-repeat: no-repeat;
383 - background-size: contain;
384 -}
vendor/dir-index-html-v1.0.0/knownIcons.txt deleted
-61
@@ -1,61 +0,0 @@
1 -.aac
2 -.aiff
3 -.ai
4 -.avi
5 -.bmp
6 -.c
7 -.cpp
8 -.css
9 -.dat
10 -.dmg
11 -.doc
12 -.dotx
13 -.dwg
14 -.dxf
15 -.eps
16 -.exe
17 -.flv
18 -.gif
19 -.h
20 -.hpp
21 -.html
22 -.ics
23 -.iso
24 -.java
25 -.jpg
26 -.js
27 -.key
28 -.less
29 -.mid
30 -.mp3
31 -.mp4
32 -.mpg
33 -.odf
34 -.ods
35 -.odt
36 -.otp
37 -.ots
38 -.ott
39 -.pdf
40 -.php
41 -.png
42 -.ppt
43 -.psd
44 -.py
45 -.qt
46 -.rar
47 -.rb
48 -.rtf
49 -.sass
50 -.scss
51 -.sql
52 -.tga
53 -.tgz
54 -.tiff
55 -.txt
56 -.wav
57 -.xls
58 -.xlsx
59 -.xml
60 -.yml
61 -.zip
vendor/dir-index-html-v1.0.0/package.json deleted
-4
@@ -1,4 +0,0 @@
1 -{
2 - "name": "dir-index-html",
3 - "version": "1.0.0"
4 -}