├── .gitignore ├── README.md ├── main.go └── vendor ├── comail.io └── go │ └── colog │ ├── LICENSE │ ├── README.md │ ├── colog.go │ ├── colog_bench_test.go │ ├── colog_test.go │ ├── interfaces.go │ ├── json_formatter.go │ ├── json_formatter_test.go │ ├── std_extractor.go │ ├── std_extractor_test.go │ ├── std_formatter.go │ ├── std_formatter_test.go │ ├── tty.go │ ├── tty_bsd.go │ ├── tty_linux.go │ └── tty_windows.go ├── github.com ├── bgentry │ └── speakeasy │ │ ├── LICENSE_WINDOWS │ │ ├── Readme.md │ │ ├── example │ │ └── main.go │ │ ├── speakeasy.go │ │ ├── speakeasy_unix.go │ │ └── speakeasy_windows.go ├── cpuguy83 │ └── go-md2man │ │ └── md2man │ │ ├── md2man.go │ │ └── roff.go ├── inconshreveable │ └── mousetrap │ │ ├── LICENSE │ │ ├── README.md │ │ ├── trap_others.go │ │ ├── trap_windows.go │ │ └── trap_windows_1.4.go ├── kr │ └── pty │ │ ├── License │ │ ├── README.md │ │ ├── doc.go │ │ ├── ioctl.go │ │ ├── ioctl_bsd.go │ │ ├── mktypes.bash │ │ ├── pty_darwin.go │ │ ├── pty_freebsd.go │ │ ├── pty_linux.go │ │ ├── pty_unsupported.go │ │ ├── run.go │ │ ├── types.go │ │ ├── types_freebsd.go │ │ ├── util.go │ │ ├── ztypes_386.go │ │ ├── ztypes_amd64.go │ │ ├── ztypes_arm.go │ │ ├── ztypes_arm64.go │ │ ├── ztypes_freebsd_386.go │ │ ├── ztypes_freebsd_amd64.go │ │ ├── ztypes_freebsd_arm.go │ │ ├── ztypes_ppc64.go │ │ ├── ztypes_ppc64le.go │ │ └── ztypes_s390x.go ├── russross │ └── blackfriday │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── block.go │ │ ├── block_test.go │ │ ├── html.go │ │ ├── inline.go │ │ ├── inline_test.go │ │ ├── latex.go │ │ ├── markdown.go │ │ ├── ref_test.go │ │ ├── smartypants.go │ │ └── testdata │ │ ├── Amps and angle encoding.html │ │ ├── Amps and angle encoding.text │ │ ├── Auto links.html │ │ ├── Auto links.text │ │ ├── Backslash escapes.html │ │ ├── Backslash escapes.text │ │ ├── Blockquotes with code blocks.html │ │ ├── Blockquotes with code blocks.text │ │ ├── Code Blocks.html │ │ ├── Code Blocks.text │ │ ├── Code Spans.html │ │ ├── Code Spans.text │ │ ├── Hard-wrapped paragraphs with list-like lines no empty line before block.html │ │ ├── Hard-wrapped paragraphs with list-like lines no empty line before block.text │ │ ├── Hard-wrapped paragraphs with list-like lines.html │ │ ├── Hard-wrapped paragraphs with list-like lines.text │ │ ├── Horizontal rules.html │ │ ├── Horizontal rules.text │ │ ├── Inline HTML (Advanced).html │ │ ├── Inline HTML (Advanced).text │ │ ├── Inline HTML (Simple).html │ │ ├── Inline HTML (Simple).text │ │ ├── Inline HTML comments.html │ │ ├── Inline HTML comments.text │ │ ├── Links, inline style.html │ │ ├── Links, inline style.text │ │ ├── Links, reference style.html │ │ ├── Links, reference style.text │ │ ├── Links, shortcut references.html │ │ ├── Links, shortcut references.text │ │ ├── Literal quotes in titles.html │ │ ├── Literal quotes in titles.text │ │ ├── Markdown Documentation - Basics.html │ │ ├── Markdown Documentation - Basics.text │ │ ├── Markdown Documentation - Syntax.html │ │ ├── Markdown Documentation - Syntax.text │ │ ├── Nested blockquotes.html │ │ ├── Nested blockquotes.text │ │ ├── Ordered and unordered lists.html │ │ ├── Ordered and unordered lists.text │ │ ├── Strong and em together.html │ │ ├── Strong and em together.text │ │ ├── Tabs.html │ │ ├── Tabs.text │ │ ├── Tidyness.html │ │ └── Tidyness.text ├── shurcooL │ └── sanitized_anchor_name │ │ ├── README.md │ │ ├── main.go │ │ └── main_test.go └── spf13 │ ├── cobra │ ├── LICENSE.txt │ ├── README.md │ ├── bash_completions.go │ ├── bash_completions.md │ ├── bash_completions_test.go │ ├── cobra.go │ ├── cobra_test.go │ ├── command.go │ ├── command_test.go │ ├── doc_util.go │ ├── examples_test.go │ ├── man_docs.go │ ├── man_docs.md │ ├── man_docs_test.go │ ├── md_docs.go │ ├── md_docs.md │ └── md_docs_test.go │ └── pflag │ ├── LICENSE │ ├── README.md │ ├── bool.go │ ├── bool_test.go │ ├── count.go │ ├── count_test.go │ ├── duration.go │ ├── example_test.go │ ├── export_test.go │ ├── flag.go │ ├── flag_test.go │ ├── float32.go │ ├── float64.go │ ├── golangflag.go │ ├── golangflag_test.go │ ├── int.go │ ├── int32.go │ ├── int64.go │ ├── int8.go │ ├── int_slice.go │ ├── int_slice_test.go │ ├── ip.go │ ├── ip_test.go │ ├── ipmask.go │ ├── ipnet.go │ ├── ipnet_test.go │ ├── string.go │ ├── string_slice.go │ ├── string_slice_test.go │ ├── uint.go │ ├── uint16.go │ ├── uint32.go │ ├── uint64.go │ ├── uint8.go │ └── verify │ ├── all.sh │ ├── gofmt.sh │ └── golint.sh ├── golang.org └── x │ └── crypto │ ├── curve25519 │ ├── const_amd64.s │ ├── cswap_amd64.s │ ├── curve25519.go │ ├── curve25519_test.go │ ├── doc.go │ ├── freeze_amd64.s │ ├── ladderstep_amd64.s │ ├── mont25519_amd64.go │ ├── mul_amd64.s │ └── square_amd64.s │ └── ssh │ ├── agent │ ├── client.go │ ├── client_test.go │ ├── forward.go │ ├── keyring.go │ ├── server.go │ ├── server_test.go │ └── testdata_test.go │ ├── benchmark_test.go │ ├── buffer.go │ ├── buffer_test.go │ ├── certs.go │ ├── certs_test.go │ ├── channel.go │ ├── cipher.go │ ├── cipher_test.go │ ├── client.go │ ├── client_auth.go │ ├── client_auth_test.go │ ├── client_test.go │ ├── common.go │ ├── connection.go │ ├── doc.go │ ├── example_test.go │ ├── handshake.go │ ├── handshake_test.go │ ├── kex.go │ ├── kex_test.go │ ├── keys.go │ ├── keys_test.go │ ├── mac.go │ ├── mempipe_test.go │ ├── messages.go │ ├── messages_test.go │ ├── mux.go │ ├── mux_test.go │ ├── server.go │ ├── session.go │ ├── session_test.go │ ├── tcpip.go │ ├── tcpip_test.go │ ├── terminal │ ├── terminal.go │ ├── terminal_test.go │ ├── util.go │ ├── util_bsd.go │ ├── util_linux.go │ └── util_windows.go │ ├── test │ ├── agent_unix_test.go │ ├── cert_test.go │ ├── doc.go │ ├── forward_unix_test.go │ ├── session_test.go │ ├── tcpip_test.go │ ├── test_unix_test.go │ └── testdata_test.go │ ├── testdata │ ├── doc.go │ └── keys.go │ ├── testdata_test.go │ ├── transport.go │ └── transport_test.go └── manifest /.gitignore: -------------------------------------------------------------------------------- 1 | /rssh 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rssh 2 | 3 | This program is a simple reverse shell over SSH. Essentially, it opens a 4 | connection to a remote computer over SSH, starts listening on a port on the 5 | remote computer, and when connections are made to that port, starts a command 6 | locally and copies data to and from it. 7 | 8 | ## Why? 9 | 10 | This is useful in the cases where you cannot listen on the local computer 11 | (restricted firewall, NAT, whatever), but still want to use SSH. Using this 12 | command, you can emulate this: 13 | 14 | On the local machine (where you want the shell): 15 | 16 | ./rssh -a '127.0.0.1:2222' -u user -i id_remote_rsa IP.OF.REMOTE.MACHINE 17 | 18 | This creates a listening socket on the `localhost` of the remote machine. 19 | Then, on the remote machine, you can run: 20 | 21 | nc -c 127.0.0.1 2222 22 | 23 | Which will give you shell. Note that the `-c` flag is important, to ensure 24 | that EOF is properly propagated over the network connection and to the remote 25 | host. 26 | -------------------------------------------------------------------------------- /vendor/comail.io/go/colog/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 comail 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 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, 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 THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/comail.io/go/colog/colog_bench_test.go: -------------------------------------------------------------------------------- 1 | package colog 2 | 3 | import ( 4 | "log" 5 | "testing" 6 | ) 7 | 8 | func BenchmarkLoggerNoFlags(b *testing.B) { 9 | logger := log.New(new(nilWriter), "", 0) 10 | for i := 0; i <= b.N; i++ { 11 | logger.Println("error: benchmark") 12 | } 13 | } 14 | 15 | func BenchmarkLoggerWithFlags(b *testing.B) { 16 | logger := log.New(new(nilWriter), "", log.Llongfile|log.Ldate) 17 | for i := 0; i <= b.N; i++ { 18 | logger.Println("error: benchmark") 19 | } 20 | } 21 | 22 | func BenchmarkCoLogPlainNoFlags(b *testing.B) { 23 | doBench(b, "error: benchmark", 0, false, false) 24 | } 25 | 26 | func BenchmarkCoLogPlainWithFlags(b *testing.B) { 27 | doBench(b, "error: benchmark", log.Llongfile|log.Ldate, false, false) 28 | } 29 | 30 | func BenchmarkCoLogPlainWithFlagsAndFields(b *testing.B) { 31 | doBench(b, "error: benchmark KeyName1='Key Value1'", log.Llongfile|log.Ldate, true, false) 32 | } 33 | 34 | func BenchmarkCoLogColorNoFlags(b *testing.B) { 35 | doBench(b, "error: benchmark", 0, false, true) 36 | } 37 | 38 | func BenchmarkCoLogColorWithFlags(b *testing.B) { 39 | doBench(b, "error: benchmark", log.Llongfile|log.Ldate, false, true) 40 | } 41 | 42 | func BenchmarkCoLogColorWithFlagsAndFields(b *testing.B) { 43 | doBench(b, "error: benchmark KeyName1='Key Value1'", log.Llongfile|log.Ldate, true, true) 44 | } 45 | 46 | func doBench(b *testing.B, message string, flag int, fields bool, colors bool) { 47 | cl := NewCoLog(new(nilWriter), "", flag) 48 | cl.ParseFields(fields) 49 | cl.SetFormatter(&StdFormatter{Flag: flag, Colors: colors}) 50 | // fmt.Printf("flags %d \n", cl.formatter.Flags()) 51 | logger := cl.NewLogger() 52 | for i := 0; i <= b.N; i++ { 53 | logger.Println(message) 54 | } 55 | } 56 | 57 | type nilWriter struct{} 58 | 59 | func (nw *nilWriter) Write(p []byte) (n int, err error) { return 0, nil } 60 | -------------------------------------------------------------------------------- /vendor/comail.io/go/colog/interfaces.go: -------------------------------------------------------------------------------- 1 | package colog 2 | 3 | // Hook is the interface to be implemented by event hooks 4 | type Hook interface { 5 | Levels() []Level // returns the set of levels for which the hook should be triggered 6 | Fire(*Entry) error // triggers the hook, this function will be called for every eligible log entry 7 | } 8 | 9 | // Formatter interface must be implemented by message formatters 10 | // Format(*Entry) will be called and the resulting bytes sent to output 11 | type Formatter interface { 12 | Format(*Entry) ([]byte, error) // The actual formatter called every time 13 | SetFlags(flags int) // Like the standard log.SetFlags(flags int) 14 | Flags() int // Like the standard log.Flags() int 15 | } 16 | 17 | // ColorFormatter interface can be implemented by formatters 18 | // to get notifications on whether the output supports color 19 | type ColorFormatter interface { 20 | Formatter 21 | ColorSupported(yes bool) 22 | } 23 | 24 | // ColorSupporter interface can be implemented by "smart" 25 | // outputs that want to handle color display themselves 26 | type ColorSupporter interface { 27 | ColorSupported() bool 28 | } 29 | 30 | // Extractor interface must be implemented by data extractors 31 | // the extractor reads the message and tries to extract key-value 32 | // pairs from the message and sets the in the entry 33 | type Extractor interface { 34 | Extract(*Entry) error 35 | } 36 | -------------------------------------------------------------------------------- /vendor/comail.io/go/colog/json_formatter.go: -------------------------------------------------------------------------------- 1 | package colog 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log" 7 | "strconv" 8 | "sync" 9 | ) 10 | 11 | // JSONFormatter serializes entries to JSON 12 | // TimeFormat can be any Go time format, if empty 13 | // it will mimic the standard logger format 14 | // LevelAsNum will use a numeric string "1", "2",... 15 | // for as levels instead of "trace", "debug", .. 16 | type JSONFormatter struct { 17 | mu sync.Mutex 18 | TimeFormat string 19 | LevelAsNum bool 20 | Flag int 21 | } 22 | 23 | // JSONEntry is an entry with the final JSON field types 24 | // We can not just implement the Marshaller interface since 25 | // some of the process depends on runtime options 26 | type JSONEntry struct { 27 | Level string `json:"level,omitempty"` 28 | Time string `json:"time,omitempty"` 29 | Host string `json:"host,omitempty"` 30 | Prefix string `json:"prefix,omitempty"` 31 | File string `json:"file,omitempty"` 32 | Line int `json:"line,omitempty"` 33 | Message string `json:"message,omitempty"` 34 | Fields Fields `json:"fields,omitempty"` 35 | } 36 | 37 | // Format takes and entry and returns the formatted output in bytes 38 | func (jf *JSONFormatter) Format(e *Entry) ([]byte, error) { 39 | 40 | file, line := jf.fileLine(e) 41 | date := jf.date(e) 42 | 43 | var level string 44 | if jf.LevelAsNum { 45 | level = strconv.Itoa(int(e.Level)) 46 | } else { 47 | level = e.Level.String() 48 | } 49 | 50 | je := &JSONEntry{ 51 | Level: level, 52 | Time: date, 53 | Host: e.Host, 54 | Prefix: e.Prefix, 55 | File: file, 56 | Line: line, 57 | Message: string(e.Message), 58 | Fields: e.Fields, 59 | } 60 | 61 | data, err := json.Marshal(je) 62 | return append(data, '\n'), err 63 | } 64 | 65 | // Flags returns the output flags for the formatter. 66 | func (jf *JSONFormatter) Flags() int { 67 | return jf.Flag 68 | } 69 | 70 | // SetFlags sets the output flags for the formatter. 71 | func (jf *JSONFormatter) SetFlags(flags int) { 72 | jf.Flag = flags 73 | } 74 | 75 | func (jf *JSONFormatter) fileLine(e *Entry) (file string, line int) { 76 | if jf.Flag&(log.Lshortfile|log.Llongfile) == 0 { 77 | return 78 | } 79 | 80 | file = e.File 81 | line = e.Line 82 | if jf.Flag&log.Lshortfile != 0 { 83 | short := file 84 | for i := len(file) - 1; i > 0; i-- { 85 | if file[i] == '/' { 86 | short = file[i+1:] 87 | break 88 | } 89 | } 90 | file = short 91 | } 92 | 93 | return file, line 94 | } 95 | 96 | func (jf *JSONFormatter) date(e *Entry) (date string) { 97 | if jf.TimeFormat != "" { 98 | return e.Time.Format(jf.TimeFormat) 99 | } 100 | 101 | if jf.Flag&(log.Ldate|log.Ltime|log.Lmicroseconds) == 0 { 102 | return "" 103 | } 104 | 105 | if jf.Flag&log.Ldate != 0 { 106 | year, month, day := e.Time.Date() 107 | date = fmt.Sprintf("%d/%d/%d", year, month, day) 108 | } 109 | 110 | if jf.Flag&(log.Ltime|log.Lmicroseconds) != 0 { 111 | hour, min, sec := e.Time.Clock() 112 | date = fmt.Sprintf("%s %d:%d:%d", date, hour, min, sec) 113 | if jf.Flag&log.Lmicroseconds != 0 { 114 | date = fmt.Sprintf("%s.%d", date, e.Time.Nanosecond()) 115 | 116 | } 117 | } 118 | 119 | return date 120 | } 121 | -------------------------------------------------------------------------------- /vendor/comail.io/go/colog/std_extractor.go: -------------------------------------------------------------------------------- 1 | package colog 2 | 3 | import ( 4 | "bytes" 5 | "regexp" 6 | ) 7 | 8 | // regex to extract key-value (or quoted value) from the logged message 9 | // if you can do this better please make a pull request 10 | // this is just the result of lots of trial and error 11 | var fieldsRegex = `(?P([\pL0-9_]+))\s*=\s*((?P([\pL0-9_]+))|(?P("[^"]*"|'[^']*')))` 12 | 13 | // StdExtractor implements a regex based extractor for key-value pairs 14 | // both unquoted foo=bar and quoted foo="some bar" are supported 15 | type StdExtractor struct { 16 | rxFields *regexp.Regexp 17 | } 18 | 19 | // Extract finds key-value pairs in the message and sets them as Fields 20 | // in the entry removing the pairs from the message. 21 | func (se *StdExtractor) Extract(e *Entry) error { 22 | if se.rxFields == nil { 23 | se.rxFields = regexp.MustCompile(fieldsRegex) 24 | } 25 | matches := se.rxFields.FindAllSubmatch(e.Message, -1) 26 | if matches == nil { 27 | return nil 28 | } 29 | 30 | var key, value []byte 31 | captures := make(map[string]interface{}) 32 | 33 | // Look for positions with: fmt.Printf("%#v \n", rxFields.SubexpNames()) 34 | // Will find positions []string{"", "key", "", "", "value", "", "quoted", ""} 35 | // 1 4 6 36 | 37 | for _, match := range matches { 38 | // First group, simple key-value detected 39 | if len(match[1]) > 0 && len(match[4]) > 0 { 40 | key, value = match[1], match[4] 41 | } 42 | 43 | // Second group, quoted value detected 44 | if len(match[1]) > 0 && len(match[6]) > 0 { 45 | key, value = match[1], match[6] 46 | value = value[1 : len(value)-1] // remove quotes, first and last character 47 | } 48 | 49 | captures[string(key)] = string(value) 50 | } 51 | 52 | if captures != nil { 53 | // Eliminate key=value from text and trim from the right 54 | e.Message = bytes.TrimRight(se.rxFields.ReplaceAll(e.Message, nil), " \n") 55 | for k, v := range captures { 56 | e.Fields[k] = v 57 | } 58 | } 59 | 60 | return nil 61 | } 62 | -------------------------------------------------------------------------------- /vendor/comail.io/go/colog/std_extractor_test.go: -------------------------------------------------------------------------------- 1 | package colog 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | type extractInOut struct { 8 | in string 9 | outMsg string 10 | outData map[string]interface{} 11 | } 12 | 13 | var extractorTests = []extractInOut{ 14 | { 15 | "some message foo=bar", 16 | "some message", 17 | map[string]interface{}{"foo": "bar"}, 18 | }, 19 | { 20 | "some message foo=42 foo2='other bar'", 21 | "some message", 22 | map[string]interface{}{ 23 | "foo": "42", 24 | "foo2": "other bar", 25 | }, 26 | }, 27 | { 28 | "some foo=42 otherfoo='other bar' mixed text", 29 | "some mixed text", 30 | map[string]interface{}{ 31 | "foo": "42", 32 | "otherfoo": "other bar", 33 | }, 34 | }, 35 | } 36 | 37 | func TestStdExtractor(t *testing.T) { 38 | stde := StdExtractor{} 39 | for _, tt := range extractorTests { 40 | e := &Entry{ 41 | Message: []byte(tt.in), 42 | Fields: make(Fields), 43 | } 44 | stde.Extract(e) 45 | if string(e.Message) != tt.outMsg { 46 | t.Errorf("Extract error:\n %s\n %s", string(e.Message), tt.outMsg) 47 | } 48 | for k, v := range tt.outData { 49 | if e.Fields[k] != v { 50 | t.Errorf("Invalid data value %s\n %s vs %s", k, v, e.Fields[k]) 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/comail.io/go/colog/tty.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package colog 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | // Use variable indirection for test stubbing 11 | var isTerminal = isTerminalFunc 12 | var terminalWidth = terminalWidthFunc 13 | 14 | // isTerminalFunc returns true if the given file descriptor is a terminal. 15 | func isTerminalFunc(fd int) bool { 16 | var termios syscall.Termios 17 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 18 | return err == 0 19 | } 20 | 21 | // terminalWidthFunc returns the width in characters of the terminal. 22 | func terminalWidthFunc(fd int) (width int) { 23 | var dimensions [4]uint16 24 | 25 | _, _, errno := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&dimensions)), 0, 0, 0) 26 | if errno != 0 { 27 | return -1 28 | } 29 | 30 | return int(dimensions[1]) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/comail.io/go/colog/tty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin dragonfly freebsd netbsd openbsd 2 | 3 | package colog 4 | 5 | import "syscall" 6 | 7 | const ioctlReadTermios = syscall.TIOCGETA 8 | -------------------------------------------------------------------------------- /vendor/comail.io/go/colog/tty_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | 3 | package colog 4 | 5 | const ioctlReadTermios = 0x5401 6 | -------------------------------------------------------------------------------- /vendor/comail.io/go/colog/tty_windows.go: -------------------------------------------------------------------------------- 1 | package colog 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | // Use variable indirection for test stubbing 9 | var isTerminal = isTerminalFunc 10 | var terminalWidth = terminalWidthFunc 11 | 12 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 13 | var procInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") 14 | var procMode = kernel32.NewProc("GetConsoleMode") 15 | 16 | // Not applicable in windows 17 | // define constant to avoid compilation error 18 | const ioctlReadTermios = 0x0 19 | 20 | // isTerminalFunc returns true if the given file descriptor is a terminal. 21 | func isTerminalFunc(fd int) bool { 22 | var st uint32 23 | r, _, errno := syscall.Syscall(procMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 24 | if errno != 0 { 25 | return false 26 | } 27 | 28 | return r != 0 29 | } 30 | 31 | type short int16 32 | type word uint16 33 | 34 | type coord struct { 35 | x short 36 | y short 37 | } 38 | type rectangle struct { 39 | left short 40 | top short 41 | right short 42 | bottom short 43 | } 44 | 45 | type termInfo struct { 46 | size coord 47 | cursorPosition coord 48 | attributes word 49 | window rectangle 50 | maximumWindowSize coord 51 | } 52 | 53 | // terminalWidthFunc returns the width in characters of the terminal. 54 | func terminalWidthFunc(fd int) (width int) { 55 | var info termInfo 56 | _, _, errno := syscall.Syscall(procInfo.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&info)), 0) 57 | if errno != 0 { 58 | return -1 59 | } 60 | 61 | return int(info.size.x) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/bgentry/speakeasy/Readme.md: -------------------------------------------------------------------------------- 1 | # Speakeasy 2 | 3 | This package provides cross-platform Go (#golang) helpers for taking user input 4 | from the terminal while not echoing the input back (similar to `getpasswd`). The 5 | package uses syscalls to avoid any dependence on cgo, and is therefore 6 | compatible with cross-compiling. 7 | 8 | [![GoDoc](https://godoc.org/github.com/bgentry/speakeasy?status.png)][godoc] 9 | 10 | ## Unicode 11 | 12 | Multi-byte unicode characters work successfully on Mac OS X. On Windows, 13 | however, this may be problematic (as is UTF in general on Windows). Other 14 | platforms have not been tested. 15 | 16 | ## License 17 | 18 | The code herein was not written by me, but was compiled from two separate open 19 | source packages. Unix portions were imported from [gopass][gopass], while 20 | Windows portions were imported from the [CloudFoundry Go CLI][cf-cli]'s 21 | [Windows terminal helpers][cf-ui-windows]. 22 | 23 | The [license for the windows portion](./LICENSE_WINDOWS) has been copied exactly 24 | from the source (though I attempted to fill in the correct owner in the 25 | boilerplate copyright notice). 26 | 27 | [cf-cli]: https://github.com/cloudfoundry/cli "CloudFoundry Go CLI" 28 | [cf-ui-windows]: https://github.com/cloudfoundry/cli/blob/master/src/cf/terminal/ui_windows.go "CloudFoundry Go CLI Windows input helpers" 29 | [godoc]: https://godoc.org/github.com/bgentry/speakeasy "speakeasy on Godoc.org" 30 | [gopass]: https://code.google.com/p/gopass "gopass" 31 | -------------------------------------------------------------------------------- /vendor/github.com/bgentry/speakeasy/example/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/bgentry/speakeasy" 8 | ) 9 | 10 | func main() { 11 | password, err := speakeasy.Ask("Please enter a password: ") 12 | if err != nil { 13 | fmt.Println(err) 14 | os.Exit(1) 15 | } 16 | fmt.Printf("Password result: %q\n", password) 17 | fmt.Printf("Password len: %d\n", len(password)) 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/bgentry/speakeasy/speakeasy.go: -------------------------------------------------------------------------------- 1 | package speakeasy 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | // Ask the user to enter a password with input hidden. prompt is a string to 11 | // display before the user's input. Returns the provided password, or an error 12 | // if the command failed. 13 | func Ask(prompt string) (password string, err error) { 14 | return FAsk(os.Stdout, prompt) 15 | } 16 | 17 | // Same as the Ask function, except it is possible to specify the file to write 18 | // the prompt to. 19 | func FAsk(file *os.File, prompt string) (password string, err error) { 20 | if prompt != "" { 21 | fmt.Fprint(file, prompt) // Display the prompt. 22 | } 23 | password, err = getPassword() 24 | 25 | // Carriage return after the user input. 26 | fmt.Fprintln(file, "") 27 | return 28 | } 29 | 30 | func readline() (value string, err error) { 31 | var valb []byte 32 | var n int 33 | b := make([]byte, 1) 34 | for { 35 | // read one byte at a time so we don't accidentally read extra bytes 36 | n, err = os.Stdin.Read(b) 37 | if err != nil && err != io.EOF { 38 | return "", err 39 | } 40 | if n == 0 || b[0] == '\n' { 41 | break 42 | } 43 | valb = append(valb, b[0]) 44 | } 45 | 46 | return strings.TrimSuffix(string(valb), "\r"), nil 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/bgentry/speakeasy/speakeasy_unix.go: -------------------------------------------------------------------------------- 1 | // based on https://code.google.com/p/gopass 2 | // Author: johnsiilver@gmail.com (John Doak) 3 | // 4 | // Original code is based on code by RogerV in the golang-nuts thread: 5 | // https://groups.google.com/group/golang-nuts/browse_thread/thread/40cc41e9d9fc9247 6 | 7 | // +build darwin freebsd linux netbsd openbsd solaris 8 | 9 | package speakeasy 10 | 11 | import ( 12 | "fmt" 13 | "os" 14 | "os/signal" 15 | "strings" 16 | "syscall" 17 | ) 18 | 19 | const sttyArg0 = "/bin/stty" 20 | 21 | var ( 22 | sttyArgvEOff = []string{"stty", "-echo"} 23 | sttyArgvEOn = []string{"stty", "echo"} 24 | ) 25 | 26 | // getPassword gets input hidden from the terminal from a user. This is 27 | // accomplished by turning off terminal echo, reading input from the user and 28 | // finally turning on terminal echo. 29 | func getPassword() (password string, err error) { 30 | sig := make(chan os.Signal, 10) 31 | brk := make(chan bool) 32 | 33 | // File descriptors for stdin, stdout, and stderr. 34 | fd := []uintptr{os.Stdin.Fd(), os.Stdout.Fd(), os.Stderr.Fd()} 35 | 36 | // Setup notifications of termination signals to channel sig, create a process to 37 | // watch for these signals so we can turn back on echo if need be. 38 | signal.Notify(sig, syscall.SIGHUP, syscall.SIGINT, syscall.SIGKILL, syscall.SIGQUIT, 39 | syscall.SIGTERM) 40 | go catchSignal(fd, sig, brk) 41 | 42 | // Turn off the terminal echo. 43 | pid, err := echoOff(fd) 44 | if err != nil { 45 | return "", err 46 | } 47 | 48 | // Turn on the terminal echo and stop listening for signals. 49 | defer signal.Stop(sig) 50 | defer close(brk) 51 | defer echoOn(fd) 52 | 53 | syscall.Wait4(pid, nil, 0, nil) 54 | 55 | line, err := readline() 56 | if err == nil { 57 | password = strings.TrimSpace(line) 58 | } else { 59 | err = fmt.Errorf("failed during password entry: %s", err) 60 | } 61 | 62 | return password, err 63 | } 64 | 65 | // echoOff turns off the terminal echo. 66 | func echoOff(fd []uintptr) (int, error) { 67 | pid, err := syscall.ForkExec(sttyArg0, sttyArgvEOff, &syscall.ProcAttr{Dir: "", Files: fd}) 68 | if err != nil { 69 | return 0, fmt.Errorf("failed turning off console echo for password entry:\n\t%s", err) 70 | } 71 | return pid, nil 72 | } 73 | 74 | // echoOn turns back on the terminal echo. 75 | func echoOn(fd []uintptr) { 76 | // Turn on the terminal echo. 77 | pid, e := syscall.ForkExec(sttyArg0, sttyArgvEOn, &syscall.ProcAttr{Dir: "", Files: fd}) 78 | if e == nil { 79 | syscall.Wait4(pid, nil, 0, nil) 80 | } 81 | } 82 | 83 | // catchSignal tries to catch SIGKILL, SIGQUIT and SIGINT so that we can turn 84 | // terminal echo back on before the program ends. Otherwise the user is left 85 | // with echo off on their terminal. 86 | func catchSignal(fd []uintptr, sig chan os.Signal, brk chan bool) { 87 | select { 88 | case <-sig: 89 | echoOn(fd) 90 | os.Exit(-1) 91 | case <-brk: 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /vendor/github.com/bgentry/speakeasy/speakeasy_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package speakeasy 4 | 5 | import ( 6 | "os" 7 | "syscall" 8 | ) 9 | 10 | // SetConsoleMode function can be used to change value of ENABLE_ECHO_INPUT: 11 | // http://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx 12 | const ENABLE_ECHO_INPUT = 0x0004 13 | 14 | func getPassword() (password string, err error) { 15 | hStdin := syscall.Handle(os.Stdin.Fd()) 16 | var oldMode uint32 17 | 18 | err = syscall.GetConsoleMode(hStdin, &oldMode) 19 | if err != nil { 20 | return 21 | } 22 | 23 | var newMode uint32 = (oldMode &^ ENABLE_ECHO_INPUT) 24 | 25 | err = setConsoleMode(hStdin, newMode) 26 | defer setConsoleMode(hStdin, oldMode) 27 | if err != nil { 28 | return 29 | } 30 | 31 | return readline() 32 | } 33 | 34 | func setConsoleMode(console syscall.Handle, mode uint32) (err error) { 35 | dll := syscall.MustLoadDLL("kernel32") 36 | proc := dll.MustFindProc("SetConsoleMode") 37 | r, _, err := proc.Call(uintptr(console), uintptr(mode)) 38 | 39 | if r == 0 { 40 | return err 41 | } 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/cpuguy83/go-md2man/md2man/md2man.go: -------------------------------------------------------------------------------- 1 | package md2man 2 | 3 | import ( 4 | "github.com/russross/blackfriday" 5 | ) 6 | 7 | func Render(doc []byte) []byte { 8 | renderer := RoffRenderer(0) 9 | extensions := 0 10 | extensions |= blackfriday.EXTENSION_NO_INTRA_EMPHASIS 11 | extensions |= blackfriday.EXTENSION_TABLES 12 | extensions |= blackfriday.EXTENSION_FENCED_CODE 13 | extensions |= blackfriday.EXTENSION_AUTOLINK 14 | extensions |= blackfriday.EXTENSION_SPACE_HEADERS 15 | extensions |= blackfriday.EXTENSION_FOOTNOTES 16 | extensions |= blackfriday.EXTENSION_TITLEBLOCK 17 | 18 | return blackfriday.Markdown(doc, renderer, extensions) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Alan Shreve 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 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/README.md: -------------------------------------------------------------------------------- 1 | # mousetrap 2 | 3 | mousetrap is a tiny library that answers a single question. 4 | 5 | On a Windows machine, was the process invoked by someone double clicking on 6 | the executable file while browsing in explorer? 7 | 8 | ### Motivation 9 | 10 | Windows developers unfamiliar with command line tools will often "double-click" 11 | the executable for a tool. Because most CLI tools print the help and then exit 12 | when invoked without arguments, this is often very frustrating for those users. 13 | 14 | mousetrap provides a way to detect these invocations so that you can provide 15 | more helpful behavior and instructions on how to run the CLI tool. To see what 16 | this looks like, both from an organizational and a technical perspective, see 17 | https://inconshreveable.com/09-09-2014/sweat-the-small-stuff/ 18 | 19 | ### The interface 20 | 21 | The library exposes a single interface: 22 | 23 | func StartedByExplorer() (bool) 24 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/trap_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package mousetrap 4 | 5 | // StartedByExplorer returns true if the program was invoked by the user 6 | // double-clicking on the executable from explorer.exe 7 | // 8 | // It is conservative and returns false if any of the internal calls fail. 9 | // It does not guarantee that the program was run from a terminal. It only can tell you 10 | // whether it was launched from explorer.exe 11 | // 12 | // On non-Windows platforms, it always returns false. 13 | func StartedByExplorer() bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/trap_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | // +build !go1.4 3 | 4 | package mousetrap 5 | 6 | import ( 7 | "fmt" 8 | "os" 9 | "syscall" 10 | "unsafe" 11 | ) 12 | 13 | const ( 14 | // defined by the Win32 API 15 | th32cs_snapprocess uintptr = 0x2 16 | ) 17 | 18 | var ( 19 | kernel = syscall.MustLoadDLL("kernel32.dll") 20 | CreateToolhelp32Snapshot = kernel.MustFindProc("CreateToolhelp32Snapshot") 21 | Process32First = kernel.MustFindProc("Process32FirstW") 22 | Process32Next = kernel.MustFindProc("Process32NextW") 23 | ) 24 | 25 | // ProcessEntry32 structure defined by the Win32 API 26 | type processEntry32 struct { 27 | dwSize uint32 28 | cntUsage uint32 29 | th32ProcessID uint32 30 | th32DefaultHeapID int 31 | th32ModuleID uint32 32 | cntThreads uint32 33 | th32ParentProcessID uint32 34 | pcPriClassBase int32 35 | dwFlags uint32 36 | szExeFile [syscall.MAX_PATH]uint16 37 | } 38 | 39 | func getProcessEntry(pid int) (pe *processEntry32, err error) { 40 | snapshot, _, e1 := CreateToolhelp32Snapshot.Call(th32cs_snapprocess, uintptr(0)) 41 | if snapshot == uintptr(syscall.InvalidHandle) { 42 | err = fmt.Errorf("CreateToolhelp32Snapshot: %v", e1) 43 | return 44 | } 45 | defer syscall.CloseHandle(syscall.Handle(snapshot)) 46 | 47 | var processEntry processEntry32 48 | processEntry.dwSize = uint32(unsafe.Sizeof(processEntry)) 49 | ok, _, e1 := Process32First.Call(snapshot, uintptr(unsafe.Pointer(&processEntry))) 50 | if ok == 0 { 51 | err = fmt.Errorf("Process32First: %v", e1) 52 | return 53 | } 54 | 55 | for { 56 | if processEntry.th32ProcessID == uint32(pid) { 57 | pe = &processEntry 58 | return 59 | } 60 | 61 | ok, _, e1 = Process32Next.Call(snapshot, uintptr(unsafe.Pointer(&processEntry))) 62 | if ok == 0 { 63 | err = fmt.Errorf("Process32Next: %v", e1) 64 | return 65 | } 66 | } 67 | } 68 | 69 | func getppid() (pid int, err error) { 70 | pe, err := getProcessEntry(os.Getpid()) 71 | if err != nil { 72 | return 73 | } 74 | 75 | pid = int(pe.th32ParentProcessID) 76 | return 77 | } 78 | 79 | // StartedByExplorer returns true if the program was invoked by the user double-clicking 80 | // on the executable from explorer.exe 81 | // 82 | // It is conservative and returns false if any of the internal calls fail. 83 | // It does not guarantee that the program was run from a terminal. It only can tell you 84 | // whether it was launched from explorer.exe 85 | func StartedByExplorer() bool { 86 | ppid, err := getppid() 87 | if err != nil { 88 | return false 89 | } 90 | 91 | pe, err := getProcessEntry(ppid) 92 | if err != nil { 93 | return false 94 | } 95 | 96 | name := syscall.UTF16ToString(pe.szExeFile[:]) 97 | return name == "explorer.exe" 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | // +build go1.4 3 | 4 | package mousetrap 5 | 6 | import ( 7 | "os" 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func getProcessEntry(pid int) (*syscall.ProcessEntry32, error) { 13 | snapshot, err := syscall.CreateToolhelp32Snapshot(syscall.TH32CS_SNAPPROCESS, 0) 14 | if err != nil { 15 | return nil, err 16 | } 17 | defer syscall.CloseHandle(snapshot) 18 | var procEntry syscall.ProcessEntry32 19 | procEntry.Size = uint32(unsafe.Sizeof(procEntry)) 20 | if err = syscall.Process32First(snapshot, &procEntry); err != nil { 21 | return nil, err 22 | } 23 | for { 24 | if procEntry.ProcessID == uint32(pid) { 25 | return &procEntry, nil 26 | } 27 | err = syscall.Process32Next(snapshot, &procEntry) 28 | if err != nil { 29 | return nil, err 30 | } 31 | } 32 | } 33 | 34 | // StartedByExplorer returns true if the program was invoked by the user double-clicking 35 | // on the executable from explorer.exe 36 | // 37 | // It is conservative and returns false if any of the internal calls fail. 38 | // It does not guarantee that the program was run from a terminal. It only can tell you 39 | // whether it was launched from explorer.exe 40 | func StartedByExplorer() bool { 41 | pe, err := getProcessEntry(os.Getppid()) 42 | if err != nil { 43 | return false 44 | } 45 | return "explorer.exe" == syscall.UTF16ToString(pe.ExeFile[:]) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/License: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Keith Rarick 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to 9 | 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 13 | be included in all copies or substantial portions of the 14 | Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 17 | KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 18 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 19 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 20 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 22 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/README.md: -------------------------------------------------------------------------------- 1 | # pty 2 | 3 | Pty is a Go package for using unix pseudo-terminals. 4 | 5 | ## Install 6 | 7 | go get github.com/kr/pty 8 | 9 | ## Example 10 | 11 | ```go 12 | package main 13 | 14 | import ( 15 | "github.com/kr/pty" 16 | "io" 17 | "os" 18 | "os/exec" 19 | ) 20 | 21 | func main() { 22 | c := exec.Command("grep", "--color=auto", "bar") 23 | f, err := pty.Start(c) 24 | if err != nil { 25 | panic(err) 26 | } 27 | 28 | go func() { 29 | f.Write([]byte("foo\n")) 30 | f.Write([]byte("bar\n")) 31 | f.Write([]byte("baz\n")) 32 | f.Write([]byte{4}) // EOT 33 | }() 34 | io.Copy(os.Stdout, f) 35 | } 36 | ``` 37 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/doc.go: -------------------------------------------------------------------------------- 1 | // Package pty provides functions for working with Unix terminals. 2 | package pty 3 | 4 | import ( 5 | "errors" 6 | "os" 7 | ) 8 | 9 | // ErrUnsupported is returned if a function is not 10 | // available on the current platform. 11 | var ErrUnsupported = errors.New("unsupported") 12 | 13 | // Opens a pty and its corresponding tty. 14 | func Open() (pty, tty *os.File, err error) { 15 | return open() 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ioctl.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import "syscall" 4 | 5 | func ioctl(fd, cmd, ptr uintptr) error { 6 | _, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr) 7 | if e != 0 { 8 | return e 9 | } 10 | return nil 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ioctl_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin dragonfly freebsd netbsd openbsd 2 | 3 | package pty 4 | 5 | // from 6 | const ( 7 | _IOC_VOID uintptr = 0x20000000 8 | _IOC_OUT uintptr = 0x40000000 9 | _IOC_IN uintptr = 0x80000000 10 | _IOC_IN_OUT uintptr = _IOC_OUT | _IOC_IN 11 | _IOC_DIRMASK = _IOC_VOID | _IOC_OUT | _IOC_IN 12 | 13 | _IOC_PARAM_SHIFT = 13 14 | _IOC_PARAM_MASK = (1 << _IOC_PARAM_SHIFT) - 1 15 | ) 16 | 17 | func _IOC_PARM_LEN(ioctl uintptr) uintptr { 18 | return (ioctl >> 16) & _IOC_PARAM_MASK 19 | } 20 | 21 | func _IOC(inout uintptr, group byte, ioctl_num uintptr, param_len uintptr) uintptr { 22 | return inout | (param_len&_IOC_PARAM_MASK)<<16 | uintptr(group)<<8 | ioctl_num 23 | } 24 | 25 | func _IO(group byte, ioctl_num uintptr) uintptr { 26 | return _IOC(_IOC_VOID, group, ioctl_num, 0) 27 | } 28 | 29 | func _IOR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { 30 | return _IOC(_IOC_OUT, group, ioctl_num, param_len) 31 | } 32 | 33 | func _IOW(group byte, ioctl_num uintptr, param_len uintptr) uintptr { 34 | return _IOC(_IOC_IN, group, ioctl_num, param_len) 35 | } 36 | 37 | func _IOWR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { 38 | return _IOC(_IOC_IN_OUT, group, ioctl_num, param_len) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/mktypes.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | GOOSARCH="${GOOS}_${GOARCH}" 4 | case "$GOOSARCH" in 5 | _* | *_ | _) 6 | echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2 7 | exit 1 8 | ;; 9 | esac 10 | 11 | GODEFS="go tool cgo -godefs" 12 | 13 | $GODEFS types.go |gofmt > ztypes_$GOARCH.go 14 | 15 | case $GOOS in 16 | freebsd) 17 | $GODEFS types_$GOOS.go |gofmt > ztypes_$GOOSARCH.go 18 | ;; 19 | esac 20 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_darwin.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | func open() (pty, tty *os.File, err error) { 11 | p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) 12 | if err != nil { 13 | return nil, nil, err 14 | } 15 | 16 | sname, err := ptsname(p) 17 | if err != nil { 18 | return nil, nil, err 19 | } 20 | 21 | err = grantpt(p) 22 | if err != nil { 23 | return nil, nil, err 24 | } 25 | 26 | err = unlockpt(p) 27 | if err != nil { 28 | return nil, nil, err 29 | } 30 | 31 | t, err := os.OpenFile(sname, os.O_RDWR, 0) 32 | if err != nil { 33 | return nil, nil, err 34 | } 35 | return p, t, nil 36 | } 37 | 38 | func ptsname(f *os.File) (string, error) { 39 | n := make([]byte, _IOC_PARM_LEN(syscall.TIOCPTYGNAME)) 40 | 41 | err := ioctl(f.Fd(), syscall.TIOCPTYGNAME, uintptr(unsafe.Pointer(&n[0]))) 42 | if err != nil { 43 | return "", err 44 | } 45 | 46 | for i, c := range n { 47 | if c == 0 { 48 | return string(n[:i]), nil 49 | } 50 | } 51 | return "", errors.New("TIOCPTYGNAME string not NUL-terminated") 52 | } 53 | 54 | func grantpt(f *os.File) error { 55 | return ioctl(f.Fd(), syscall.TIOCPTYGRANT, 0) 56 | } 57 | 58 | func unlockpt(f *os.File) error { 59 | return ioctl(f.Fd(), syscall.TIOCPTYUNLK, 0) 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_freebsd.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | func posix_openpt(oflag int) (fd int, err error) { 11 | r0, _, e1 := syscall.Syscall(syscall.SYS_POSIX_OPENPT, uintptr(oflag), 0, 0) 12 | fd = int(r0) 13 | if e1 != 0 { 14 | err = e1 15 | } 16 | return 17 | } 18 | 19 | func open() (pty, tty *os.File, err error) { 20 | fd, err := posix_openpt(syscall.O_RDWR | syscall.O_CLOEXEC) 21 | if err != nil { 22 | return nil, nil, err 23 | } 24 | 25 | p := os.NewFile(uintptr(fd), "/dev/pts") 26 | sname, err := ptsname(p) 27 | if err != nil { 28 | return nil, nil, err 29 | } 30 | 31 | t, err := os.OpenFile("/dev/"+sname, os.O_RDWR, 0) 32 | if err != nil { 33 | return nil, nil, err 34 | } 35 | return p, t, nil 36 | } 37 | 38 | func isptmaster(fd uintptr) (bool, error) { 39 | err := ioctl(fd, syscall.TIOCPTMASTER, 0) 40 | return err == nil, err 41 | } 42 | 43 | var ( 44 | emptyFiodgnameArg fiodgnameArg 45 | ioctl_FIODGNAME = _IOW('f', 120, unsafe.Sizeof(emptyFiodgnameArg)) 46 | ) 47 | 48 | func ptsname(f *os.File) (string, error) { 49 | master, err := isptmaster(f.Fd()) 50 | if err != nil { 51 | return "", err 52 | } 53 | if !master { 54 | return "", syscall.EINVAL 55 | } 56 | 57 | const n = _C_SPECNAMELEN + 1 58 | var ( 59 | buf = make([]byte, n) 60 | arg = fiodgnameArg{Len: n, Buf: (*byte)(unsafe.Pointer(&buf[0]))} 61 | ) 62 | err = ioctl(f.Fd(), ioctl_FIODGNAME, uintptr(unsafe.Pointer(&arg))) 63 | if err != nil { 64 | return "", err 65 | } 66 | 67 | for i, c := range buf { 68 | if c == 0 { 69 | return string(buf[:i]), nil 70 | } 71 | } 72 | return "", errors.New("FIODGNAME string not NUL-terminated") 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_linux.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "os" 5 | "strconv" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | func open() (pty, tty *os.File, err error) { 11 | p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) 12 | if err != nil { 13 | return nil, nil, err 14 | } 15 | 16 | sname, err := ptsname(p) 17 | if err != nil { 18 | return nil, nil, err 19 | } 20 | 21 | err = unlockpt(p) 22 | if err != nil { 23 | return nil, nil, err 24 | } 25 | 26 | t, err := os.OpenFile(sname, os.O_RDWR|syscall.O_NOCTTY, 0) 27 | if err != nil { 28 | return nil, nil, err 29 | } 30 | return p, t, nil 31 | } 32 | 33 | func ptsname(f *os.File) (string, error) { 34 | var n _C_uint 35 | err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))) 36 | if err != nil { 37 | return "", err 38 | } 39 | return "/dev/pts/" + strconv.Itoa(int(n)), nil 40 | } 41 | 42 | func unlockpt(f *os.File) error { 43 | var u _C_int 44 | // use TIOCSPTLCK with a zero valued arg to clear the slave pty lock 45 | return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux,!darwin,!freebsd 2 | 3 | package pty 4 | 5 | import ( 6 | "os" 7 | ) 8 | 9 | func open() (pty, tty *os.File, err error) { 10 | return nil, nil, ErrUnsupported 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/run.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "os" 5 | "os/exec" 6 | "syscall" 7 | ) 8 | 9 | // Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, 10 | // and c.Stderr, calls c.Start, and returns the File of the tty's 11 | // corresponding pty. 12 | func Start(c *exec.Cmd) (pty *os.File, err error) { 13 | pty, tty, err := Open() 14 | if err != nil { 15 | return nil, err 16 | } 17 | defer tty.Close() 18 | c.Stdout = tty 19 | c.Stdin = tty 20 | c.Stderr = tty 21 | if c.SysProcAttr == nil { 22 | c.SysProcAttr = &syscall.SysProcAttr{} 23 | } 24 | c.SysProcAttr.Setctty = true 25 | c.SysProcAttr.Setsid = true 26 | err = c.Start() 27 | if err != nil { 28 | pty.Close() 29 | return nil, err 30 | } 31 | return pty, err 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/types.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package pty 4 | 5 | import "C" 6 | 7 | type ( 8 | _C_int C.int 9 | _C_uint C.uint 10 | ) 11 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/types_freebsd.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package pty 4 | 5 | /* 6 | #include 7 | #include 8 | */ 9 | import "C" 10 | 11 | const ( 12 | _C_SPECNAMELEN = C.SPECNAMELEN /* max length of devicename */ 13 | ) 14 | 15 | type fiodgnameArg C.struct_fiodgname_arg 16 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/util.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "os" 5 | "syscall" 6 | "unsafe" 7 | ) 8 | 9 | // Getsize returns the number of rows (lines) and cols (positions 10 | // in each line) in terminal t. 11 | func Getsize(t *os.File) (rows, cols int, err error) { 12 | var ws winsize 13 | err = windowrect(&ws, t.Fd()) 14 | return int(ws.ws_row), int(ws.ws_col), err 15 | } 16 | 17 | type winsize struct { 18 | ws_row uint16 19 | ws_col uint16 20 | ws_xpixel uint16 21 | ws_ypixel uint16 22 | } 23 | 24 | func windowrect(ws *winsize, fd uintptr) error { 25 | _, _, errno := syscall.Syscall( 26 | syscall.SYS_IOCTL, 27 | fd, 28 | syscall.TIOCGWINSZ, 29 | uintptr(unsafe.Pointer(ws)), 30 | ) 31 | if errno != 0 { 32 | return syscall.Errno(errno) 33 | } 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_386.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | package pty 5 | 6 | type ( 7 | _C_int int32 8 | _C_uint uint32 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | package pty 5 | 6 | type ( 7 | _C_int int32 8 | _C_uint uint32 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_arm.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | package pty 5 | 6 | type ( 7 | _C_int int32 8 | _C_uint uint32 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_arm64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | // +build arm64 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_freebsd.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Len int32 12 | Buf *byte 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_freebsd.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Len int32 12 | Pad_cgo_0 [4]byte 13 | Buf *byte 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_freebsd.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Len int32 12 | Buf *byte 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_ppc64.go: -------------------------------------------------------------------------------- 1 | // +build ppc64 2 | 3 | // Created by cgo -godefs - DO NOT EDIT 4 | // cgo -godefs types.go 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_ppc64le.go: -------------------------------------------------------------------------------- 1 | // +build ppc64le 2 | 3 | // Created by cgo -godefs - DO NOT EDIT 4 | // cgo -godefs types.go 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_s390x.go: -------------------------------------------------------------------------------- 1 | // +build s390x 2 | 3 | // Created by cgo -godefs - DO NOT EDIT 4 | // cgo -godefs types.go 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Blackfriday is distributed under the Simplified BSD License: 2 | 3 | > Copyright © 2011 Russ Ross 4 | > All rights reserved. 5 | > 6 | > Redistribution and use in source and binary forms, with or without 7 | > modification, are permitted provided that the following conditions 8 | > are met: 9 | > 10 | > 1. Redistributions of source code must retain the above copyright 11 | > notice, this list of conditions and the following disclaimer. 12 | > 13 | > 2. Redistributions in binary form must reproduce the above 14 | > copyright notice, this list of conditions and the following 15 | > disclaimer in the documentation and/or other materials provided with 16 | > the distribution. 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 21 | > FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | > COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | > INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 | > BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | > LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | > CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | > LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 | > ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | > POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Amps and angle encoding.html: -------------------------------------------------------------------------------- 1 |

AT&T has an ampersand in their name.

2 | 3 |

AT&T is another way to write it.

4 | 5 |

This & that.

6 | 7 |

4 < 5.

8 | 9 |

6 > 5.

10 | 11 |

Here's a link with an ampersand in the URL.

12 | 13 |

Here's a link with an amersand in the link text: AT&T.

14 | 15 |

Here's an inline link.

16 | 17 |

Here's an inline link.

18 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Amps and angle encoding.text: -------------------------------------------------------------------------------- 1 | AT&T has an ampersand in their name. 2 | 3 | AT&T is another way to write it. 4 | 5 | This & that. 6 | 7 | 4 < 5. 8 | 9 | 6 > 5. 10 | 11 | Here's a [link] [1] with an ampersand in the URL. 12 | 13 | Here's a link with an amersand in the link text: [AT&T] [2]. 14 | 15 | Here's an inline [link](/script?foo=1&bar=2). 16 | 17 | Here's an inline [link](). 18 | 19 | 20 | [1]: http://example.com/?foo=1&bar=2 21 | [2]: http://att.com/ "AT&T" -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Auto links.html: -------------------------------------------------------------------------------- 1 |

Link: http://example.com/.

2 | 3 |

With an ampersand: http://example.com/?foo=1&bar=2

4 | 5 | 10 | 11 |
12 |

Blockquoted: http://example.com/

13 |
14 | 15 |

Auto-links should not occur here: <http://example.com/>

16 | 17 |
or here: <http://example.com/>
18 | 
19 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Auto links.text: -------------------------------------------------------------------------------- 1 | Link: . 2 | 3 | With an ampersand: 4 | 5 | * In a list? 6 | * 7 | * It should. 8 | 9 | > Blockquoted: 10 | 11 | Auto-links should not occur here: `` 12 | 13 | or here: -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Backslash escapes.html: -------------------------------------------------------------------------------- 1 |

These should all get escaped:

2 | 3 |

Backslash: \

4 | 5 |

Backtick: `

6 | 7 |

Asterisk: *

8 | 9 |

Underscore: _

10 | 11 |

Left brace: {

12 | 13 |

Right brace: }

14 | 15 |

Left bracket: [

16 | 17 |

Right bracket: ]

18 | 19 |

Left paren: (

20 | 21 |

Right paren: )

22 | 23 |

Greater-than: >

24 | 25 |

Hash: #

26 | 27 |

Period: .

28 | 29 |

Bang: !

30 | 31 |

Plus: +

32 | 33 |

Minus: -

34 | 35 |

Tilde: ~

36 | 37 |

These should not, because they occur within a code block:

38 | 39 |
Backslash: \\
 40 | 
 41 | Backtick: \`
 42 | 
 43 | Asterisk: \*
 44 | 
 45 | Underscore: \_
 46 | 
 47 | Left brace: \{
 48 | 
 49 | Right brace: \}
 50 | 
 51 | Left bracket: \[
 52 | 
 53 | Right bracket: \]
 54 | 
 55 | Left paren: \(
 56 | 
 57 | Right paren: \)
 58 | 
 59 | Greater-than: \>
 60 | 
 61 | Hash: \#
 62 | 
 63 | Period: \.
 64 | 
 65 | Bang: \!
 66 | 
 67 | Plus: \+
 68 | 
 69 | Minus: \-
 70 | 
 71 | Tilde: \~
 72 | 
73 | 74 |

Nor should these, which occur in code spans:

75 | 76 |

Backslash: \\

77 | 78 |

Backtick: \`

79 | 80 |

Asterisk: \*

81 | 82 |

Underscore: \_

83 | 84 |

Left brace: \{

85 | 86 |

Right brace: \}

87 | 88 |

Left bracket: \[

89 | 90 |

Right bracket: \]

91 | 92 |

Left paren: \(

93 | 94 |

Right paren: \)

95 | 96 |

Greater-than: \>

97 | 98 |

Hash: \#

99 | 100 |

Period: \.

101 | 102 |

Bang: \!

103 | 104 |

Plus: \+

105 | 106 |

Minus: \-

107 | 108 |

Tilde: \~

109 | 110 |

These should get escaped, even though they're matching pairs for 111 | other Markdown constructs:

112 | 113 |

*asterisks*

114 | 115 |

_underscores_

116 | 117 |

`backticks`

118 | 119 |

This is a code span with a literal backslash-backtick sequence: \`

120 | 121 |

This is a tag with unescaped backticks bar.

122 | 123 |

This is a tag with backslashes bar.

124 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Backslash escapes.text: -------------------------------------------------------------------------------- 1 | These should all get escaped: 2 | 3 | Backslash: \\ 4 | 5 | Backtick: \` 6 | 7 | Asterisk: \* 8 | 9 | Underscore: \_ 10 | 11 | Left brace: \{ 12 | 13 | Right brace: \} 14 | 15 | Left bracket: \[ 16 | 17 | Right bracket: \] 18 | 19 | Left paren: \( 20 | 21 | Right paren: \) 22 | 23 | Greater-than: \> 24 | 25 | Hash: \# 26 | 27 | Period: \. 28 | 29 | Bang: \! 30 | 31 | Plus: \+ 32 | 33 | Minus: \- 34 | 35 | Tilde: \~ 36 | 37 | 38 | 39 | These should not, because they occur within a code block: 40 | 41 | Backslash: \\ 42 | 43 | Backtick: \` 44 | 45 | Asterisk: \* 46 | 47 | Underscore: \_ 48 | 49 | Left brace: \{ 50 | 51 | Right brace: \} 52 | 53 | Left bracket: \[ 54 | 55 | Right bracket: \] 56 | 57 | Left paren: \( 58 | 59 | Right paren: \) 60 | 61 | Greater-than: \> 62 | 63 | Hash: \# 64 | 65 | Period: \. 66 | 67 | Bang: \! 68 | 69 | Plus: \+ 70 | 71 | Minus: \- 72 | 73 | Tilde: \~ 74 | 75 | 76 | Nor should these, which occur in code spans: 77 | 78 | Backslash: `\\` 79 | 80 | Backtick: `` \` `` 81 | 82 | Asterisk: `\*` 83 | 84 | Underscore: `\_` 85 | 86 | Left brace: `\{` 87 | 88 | Right brace: `\}` 89 | 90 | Left bracket: `\[` 91 | 92 | Right bracket: `\]` 93 | 94 | Left paren: `\(` 95 | 96 | Right paren: `\)` 97 | 98 | Greater-than: `\>` 99 | 100 | Hash: `\#` 101 | 102 | Period: `\.` 103 | 104 | Bang: `\!` 105 | 106 | Plus: `\+` 107 | 108 | Minus: `\-` 109 | 110 | Tilde: `\~` 111 | 112 | 113 | These should get escaped, even though they're matching pairs for 114 | other Markdown constructs: 115 | 116 | \*asterisks\* 117 | 118 | \_underscores\_ 119 | 120 | \`backticks\` 121 | 122 | This is a code span with a literal backslash-backtick sequence: `` \` `` 123 | 124 | This is a tag with unescaped backticks bar. 125 | 126 | This is a tag with backslashes bar. 127 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Blockquotes with code blocks.html: -------------------------------------------------------------------------------- 1 |
2 |

Example:

3 | 4 |
sub status {
 5 |     print "working";
 6 | }
 7 | 
8 | 9 |

Or:

10 | 11 |
sub status {
12 |     return "working";
13 | }
14 | 
15 |
16 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Blockquotes with code blocks.text: -------------------------------------------------------------------------------- 1 | > Example: 2 | > 3 | > sub status { 4 | > print "working"; 5 | > } 6 | > 7 | > Or: 8 | > 9 | > sub status { 10 | > return "working"; 11 | > } 12 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Code Blocks.html: -------------------------------------------------------------------------------- 1 |
code block on the first line
 2 | 
3 | 4 |

Regular text.

5 | 6 |
code block indented by spaces
 7 | 
8 | 9 |

Regular text.

10 | 11 |
the lines in this block  
12 | all contain trailing spaces  
13 | 
14 | 15 |

Regular Text.

16 | 17 |
code block on the last line
18 | 
19 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Code Blocks.text: -------------------------------------------------------------------------------- 1 | code block on the first line 2 | 3 | Regular text. 4 | 5 | code block indented by spaces 6 | 7 | Regular text. 8 | 9 | the lines in this block 10 | all contain trailing spaces 11 | 12 | Regular Text. 13 | 14 | code block on the last line -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Code Spans.html: -------------------------------------------------------------------------------- 1 |

<test a=" content of attribute ">

2 | 3 |

Fix for backticks within HTML tag: like this

4 | 5 |

Here's how you put `backticks` in a code span.

6 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Code Spans.text: -------------------------------------------------------------------------------- 1 | `` 2 | 3 | Fix for backticks within HTML tag: like this 4 | 5 | Here's how you put `` `backticks` `` in a code span. 6 | 7 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Hard-wrapped paragraphs with list-like lines no empty line before block.html: -------------------------------------------------------------------------------- 1 |

In Markdown 1.0.0 and earlier. Version

2 | 3 |
    4 |
  1. This line turns into a list item. 5 | Because a hard-wrapped line in the 6 | middle of a paragraph looked like a 7 | list item.
  2. 8 |
9 | 10 |

Here's one with a bullet.

11 | 12 |
    13 |
  • criminey.
  • 14 |
15 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Hard-wrapped paragraphs with list-like lines no empty line before block.text: -------------------------------------------------------------------------------- 1 | In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item. 6 | 7 | Here's one with a bullet. 8 | * criminey. 9 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Hard-wrapped paragraphs with list-like lines.html: -------------------------------------------------------------------------------- 1 |

In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item.

6 | 7 |

Here's one with a bullet. 8 | * criminey.

9 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Hard-wrapped paragraphs with list-like lines.text: -------------------------------------------------------------------------------- 1 | In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item. 6 | 7 | Here's one with a bullet. 8 | * criminey. 9 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Horizontal rules.html: -------------------------------------------------------------------------------- 1 |

Dashes:

2 | 3 |
4 | 5 |
6 | 7 |
8 | 9 |
10 | 11 |
---
12 | 
13 | 14 |
15 | 16 |
17 | 18 |
19 | 20 |
21 | 22 |
- - -
23 | 
24 | 25 |

Asterisks:

26 | 27 |
28 | 29 |
30 | 31 |
32 | 33 |
34 | 35 |
***
36 | 
37 | 38 |
39 | 40 |
41 | 42 |
43 | 44 |
45 | 46 |
* * *
47 | 
48 | 49 |

Underscores:

50 | 51 |
52 | 53 |
54 | 55 |
56 | 57 |
58 | 59 |
___
60 | 
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
_ _ _
71 | 
72 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Horizontal rules.text: -------------------------------------------------------------------------------- 1 | Dashes: 2 | 3 | --- 4 | 5 | --- 6 | 7 | --- 8 | 9 | --- 10 | 11 | --- 12 | 13 | - - - 14 | 15 | - - - 16 | 17 | - - - 18 | 19 | - - - 20 | 21 | - - - 22 | 23 | 24 | Asterisks: 25 | 26 | *** 27 | 28 | *** 29 | 30 | *** 31 | 32 | *** 33 | 34 | *** 35 | 36 | * * * 37 | 38 | * * * 39 | 40 | * * * 41 | 42 | * * * 43 | 44 | * * * 45 | 46 | 47 | Underscores: 48 | 49 | ___ 50 | 51 | ___ 52 | 53 | ___ 54 | 55 | ___ 56 | 57 | ___ 58 | 59 | _ _ _ 60 | 61 | _ _ _ 62 | 63 | _ _ _ 64 | 65 | _ _ _ 66 | 67 | _ _ _ 68 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Inline HTML (Advanced).html: -------------------------------------------------------------------------------- 1 |

Simple block on one line:

2 | 3 |
foo
4 | 5 |

And nested without indentation:

6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Inline HTML (Advanced).text: -------------------------------------------------------------------------------- 1 | Simple block on one line: 2 | 3 |
foo
4 | 5 | And nested without indentation: 6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Inline HTML (Simple).html: -------------------------------------------------------------------------------- 1 |

Here's a simple block:

2 | 3 |
4 | foo 5 |
6 | 7 |

This should be a code block, though:

8 | 9 |
<div>
10 |     foo
11 | </div>
12 | 
13 | 14 |

As should this:

15 | 16 |
<div>foo</div>
17 | 
18 | 19 |

Now, nested:

20 | 21 |
22 |
23 |
24 | foo 25 |
26 |
27 |
28 | 29 |

This should just be an HTML comment:

30 | 31 | 32 | 33 |

Multiline:

34 | 35 | 39 | 40 |

Code block:

41 | 42 |
<!-- Comment -->
43 | 
44 | 45 |

Just plain comment, with trailing spaces on the line:

46 | 47 | 48 | 49 |

Code:

50 | 51 |
<hr />
52 | 
53 | 54 |

Hr's:

55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
71 | 72 |
73 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Inline HTML (Simple).text: -------------------------------------------------------------------------------- 1 | Here's a simple block: 2 | 3 |
4 | foo 5 |
6 | 7 | This should be a code block, though: 8 | 9 |
10 | foo 11 |
12 | 13 | As should this: 14 | 15 |
foo
16 | 17 | Now, nested: 18 | 19 |
20 |
21 |
22 | foo 23 |
24 |
25 |
26 | 27 | This should just be an HTML comment: 28 | 29 | 30 | 31 | Multiline: 32 | 33 | 37 | 38 | Code block: 39 | 40 | 41 | 42 | Just plain comment, with trailing spaces on the line: 43 | 44 | 45 | 46 | Code: 47 | 48 |
49 | 50 | Hr's: 51 | 52 |
53 | 54 |
55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Inline HTML comments.html: -------------------------------------------------------------------------------- 1 |

Paragraph one.

2 | 3 | 4 | 5 | 8 | 9 |

Paragraph two.

10 | 11 | 12 | 13 |

The end.

14 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Inline HTML comments.text: -------------------------------------------------------------------------------- 1 | Paragraph one. 2 | 3 | 4 | 5 | 8 | 9 | Paragraph two. 10 | 11 | 12 | 13 | The end. 14 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Links, inline style.html: -------------------------------------------------------------------------------- 1 |

Just a URL.

2 | 3 |

URL and title.

4 | 5 |

URL and title.

6 | 7 |

URL and title.

8 | 9 |

URL and title.

10 | 11 |

[Empty]().

12 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Links, inline style.text: -------------------------------------------------------------------------------- 1 | Just a [URL](/url/). 2 | 3 | [URL and title](/url/ "title"). 4 | 5 | [URL and title](/url/ "title preceded by two spaces"). 6 | 7 | [URL and title](/url/ "title preceded by a tab"). 8 | 9 | [URL and title](/url/ "title has spaces afterward" ). 10 | 11 | 12 | [Empty](). 13 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Links, reference style.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | 5 |

Foo bar.

6 | 7 |

With embedded [brackets].

8 | 9 |

Indented once.

10 | 11 |

Indented twice.

12 | 13 |

Indented thrice.

14 | 15 |

Indented [four][] times.

16 | 17 |
[four]: /url
18 | 
19 | 20 |
21 | 22 |

this should work

23 | 24 |

So should this.

25 | 26 |

And this.

27 | 28 |

And this.

29 | 30 |

And this.

31 | 32 |

But not [that] [].

33 | 34 |

Nor [that][].

35 | 36 |

Nor [that].

37 | 38 |

[Something in brackets like this should work]

39 | 40 |

[Same with this.]

41 | 42 |

In this case, this points to something else.

43 | 44 |

Backslashing should suppress [this] and [this].

45 | 46 |
47 | 48 |

Here's one where the link 49 | breaks across lines.

50 | 51 |

Here's another where the link 52 | breaks across lines, but with a line-ending space.

53 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Links, reference style.text: -------------------------------------------------------------------------------- 1 | Foo [bar] [1]. 2 | 3 | Foo [bar][1]. 4 | 5 | Foo [bar] 6 | [1]. 7 | 8 | [1]: /url/ "Title" 9 | 10 | 11 | With [embedded [brackets]] [b]. 12 | 13 | 14 | Indented [once][]. 15 | 16 | Indented [twice][]. 17 | 18 | Indented [thrice][]. 19 | 20 | Indented [four][] times. 21 | 22 | [once]: /url 23 | 24 | [twice]: /url 25 | 26 | [thrice]: /url 27 | 28 | [four]: /url 29 | 30 | 31 | [b]: /url/ 32 | 33 | * * * 34 | 35 | [this] [this] should work 36 | 37 | So should [this][this]. 38 | 39 | And [this] []. 40 | 41 | And [this][]. 42 | 43 | And [this]. 44 | 45 | But not [that] []. 46 | 47 | Nor [that][]. 48 | 49 | Nor [that]. 50 | 51 | [Something in brackets like [this][] should work] 52 | 53 | [Same with [this].] 54 | 55 | In this case, [this](/somethingelse/) points to something else. 56 | 57 | Backslashing should suppress \[this] and [this\]. 58 | 59 | [this]: foo 60 | 61 | 62 | * * * 63 | 64 | Here's one where the [link 65 | breaks] across lines. 66 | 67 | Here's another where the [link 68 | breaks] across lines, but with a line-ending space. 69 | 70 | 71 | [link breaks]: /url/ 72 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Links, shortcut references.html: -------------------------------------------------------------------------------- 1 |

This is the simple case.

2 | 3 |

This one has a line 4 | break.

5 | 6 |

This one has a line 7 | break with a line-ending space.

8 | 9 |

this and the other

10 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Links, shortcut references.text: -------------------------------------------------------------------------------- 1 | This is the [simple case]. 2 | 3 | [simple case]: /simple 4 | 5 | 6 | 7 | This one has a [line 8 | break]. 9 | 10 | This one has a [line 11 | break] with a line-ending space. 12 | 13 | [line break]: /foo 14 | 15 | 16 | [this] [that] and the [other] 17 | 18 | [this]: /this 19 | [that]: /that 20 | [other]: /other 21 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Literal quotes in titles.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Literal quotes in titles.text: -------------------------------------------------------------------------------- 1 | Foo [bar][]. 2 | 3 | Foo [bar](/url/ "Title with "quotes" inside"). 4 | 5 | 6 | [bar]: /url/ "Title with "quotes" inside" 7 | 8 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Nested blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

foo

3 | 4 |
5 |

bar

6 |
7 | 8 |

foo

9 |
10 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Nested blockquotes.text: -------------------------------------------------------------------------------- 1 | > foo 2 | > 3 | > > bar 4 | > 5 | > foo 6 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Ordered and unordered lists.html: -------------------------------------------------------------------------------- 1 |

Unordered

2 | 3 |

Asterisks tight:

4 | 5 |
    6 |
  • asterisk 1
  • 7 |
  • asterisk 2
  • 8 |
  • asterisk 3
  • 9 |
10 | 11 |

Asterisks loose:

12 | 13 |
    14 |
  • asterisk 1

  • 15 | 16 |
  • asterisk 2

  • 17 | 18 |
  • asterisk 3

  • 19 |
20 | 21 |
22 | 23 |

Pluses tight:

24 | 25 |
    26 |
  • Plus 1
  • 27 |
  • Plus 2
  • 28 |
  • Plus 3
  • 29 |
30 | 31 |

Pluses loose:

32 | 33 |
    34 |
  • Plus 1

  • 35 | 36 |
  • Plus 2

  • 37 | 38 |
  • Plus 3

  • 39 |
40 | 41 |
42 | 43 |

Minuses tight:

44 | 45 |
    46 |
  • Minus 1
  • 47 |
  • Minus 2
  • 48 |
  • Minus 3
  • 49 |
50 | 51 |

Minuses loose:

52 | 53 |
    54 |
  • Minus 1

  • 55 | 56 |
  • Minus 2

  • 57 | 58 |
  • Minus 3

  • 59 |
60 | 61 |

Ordered

62 | 63 |

Tight:

64 | 65 |
    66 |
  1. First
  2. 67 |
  3. Second
  4. 68 |
  5. Third
  6. 69 |
70 | 71 |

and:

72 | 73 |
    74 |
  1. One
  2. 75 |
  3. Two
  4. 76 |
  5. Three
  6. 77 |
78 | 79 |

Loose using tabs:

80 | 81 |
    82 |
  1. First

  2. 83 | 84 |
  3. Second

  4. 85 | 86 |
  5. Third

  6. 87 |
88 | 89 |

and using spaces:

90 | 91 |
    92 |
  1. One

  2. 93 | 94 |
  3. Two

  4. 95 | 96 |
  5. Three

  6. 97 |
98 | 99 |

Multiple paragraphs:

100 | 101 |
    102 |
  1. Item 1, graf one.

    103 | 104 |

    Item 2. graf two. The quick brown fox jumped over the lazy dog's 105 | back.

  2. 106 | 107 |
  3. Item 2.

  4. 108 | 109 |
  5. Item 3.

  6. 110 |
111 | 112 |

Nested

113 | 114 |
    115 |
  • Tab 116 | 117 |
      118 |
    • Tab 119 | 120 |
        121 |
      • Tab
      • 122 |
    • 123 |
  • 124 |
125 | 126 |

Here's another:

127 | 128 |
    129 |
  1. First
  2. 130 |
  3. Second: 131 | 132 |
      133 |
    • Fee
    • 134 |
    • Fie
    • 135 |
    • Foe
    • 136 |
  4. 137 |
  5. Third
  6. 138 |
139 | 140 |

Same thing but with paragraphs:

141 | 142 |
    143 |
  1. First

  2. 144 | 145 |
  3. Second:

    146 | 147 |
      148 |
    • Fee
    • 149 |
    • Fie
    • 150 |
    • Foe
    • 151 |
  4. 152 | 153 |
  5. Third

  6. 154 |
155 | 156 |

This was an error in Markdown 1.0.1:

157 | 158 |
    159 |
  • this

    160 | 161 |
      162 |
    • sub
    • 163 |
    164 | 165 |

    that

  • 166 |
167 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Ordered and unordered lists.text: -------------------------------------------------------------------------------- 1 | ## Unordered 2 | 3 | Asterisks tight: 4 | 5 | * asterisk 1 6 | * asterisk 2 7 | * asterisk 3 8 | 9 | 10 | Asterisks loose: 11 | 12 | * asterisk 1 13 | 14 | * asterisk 2 15 | 16 | * asterisk 3 17 | 18 | * * * 19 | 20 | Pluses tight: 21 | 22 | + Plus 1 23 | + Plus 2 24 | + Plus 3 25 | 26 | 27 | Pluses loose: 28 | 29 | + Plus 1 30 | 31 | + Plus 2 32 | 33 | + Plus 3 34 | 35 | * * * 36 | 37 | 38 | Minuses tight: 39 | 40 | - Minus 1 41 | - Minus 2 42 | - Minus 3 43 | 44 | 45 | Minuses loose: 46 | 47 | - Minus 1 48 | 49 | - Minus 2 50 | 51 | - Minus 3 52 | 53 | 54 | ## Ordered 55 | 56 | Tight: 57 | 58 | 1. First 59 | 2. Second 60 | 3. Third 61 | 62 | and: 63 | 64 | 1. One 65 | 2. Two 66 | 3. Three 67 | 68 | 69 | Loose using tabs: 70 | 71 | 1. First 72 | 73 | 2. Second 74 | 75 | 3. Third 76 | 77 | and using spaces: 78 | 79 | 1. One 80 | 81 | 2. Two 82 | 83 | 3. Three 84 | 85 | Multiple paragraphs: 86 | 87 | 1. Item 1, graf one. 88 | 89 | Item 2. graf two. The quick brown fox jumped over the lazy dog's 90 | back. 91 | 92 | 2. Item 2. 93 | 94 | 3. Item 3. 95 | 96 | 97 | 98 | ## Nested 99 | 100 | * Tab 101 | * Tab 102 | * Tab 103 | 104 | Here's another: 105 | 106 | 1. First 107 | 2. Second: 108 | * Fee 109 | * Fie 110 | * Foe 111 | 3. Third 112 | 113 | Same thing but with paragraphs: 114 | 115 | 1. First 116 | 117 | 2. Second: 118 | * Fee 119 | * Fie 120 | * Foe 121 | 122 | 3. Third 123 | 124 | 125 | This was an error in Markdown 1.0.1: 126 | 127 | * this 128 | 129 | * sub 130 | 131 | that 132 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Strong and em together.html: -------------------------------------------------------------------------------- 1 |

This is strong and em.

2 | 3 |

So is this word.

4 | 5 |

This is strong and em.

6 | 7 |

So is this word.

8 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Strong and em together.text: -------------------------------------------------------------------------------- 1 | ***This is strong and em.*** 2 | 3 | So is ***this*** word. 4 | 5 | ___This is strong and em.___ 6 | 7 | So is ___this___ word. 8 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Tabs.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • this is a list item 3 | indented with tabs

  • 4 | 5 |
  • this is a list item 6 | indented with spaces

  • 7 |
8 | 9 |

Code:

10 | 11 |
this code block is indented by one tab
12 | 
13 | 14 |

And:

15 | 16 |
    this code block is indented by two tabs
17 | 
18 | 19 |

And:

20 | 21 |
+   this is an example list item
22 |     indented with tabs
23 | 
24 | +   this is an example list item
25 |     indented with spaces
26 | 
27 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Tabs.text: -------------------------------------------------------------------------------- 1 | + this is a list item 2 | indented with tabs 3 | 4 | + this is a list item 5 | indented with spaces 6 | 7 | Code: 8 | 9 | this code block is indented by one tab 10 | 11 | And: 12 | 13 | this code block is indented by two tabs 14 | 15 | And: 16 | 17 | + this is an example list item 18 | indented with tabs 19 | 20 | + this is an example list item 21 | indented with spaces 22 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Tidyness.html: -------------------------------------------------------------------------------- 1 |
2 |

A list within a blockquote:

3 | 4 |
    5 |
  • asterisk 1
  • 6 |
  • asterisk 2
  • 7 |
  • asterisk 3
  • 8 |
9 |
10 | -------------------------------------------------------------------------------- /vendor/github.com/russross/blackfriday/testdata/Tidyness.text: -------------------------------------------------------------------------------- 1 | > A list within a blockquote: 2 | > 3 | > * asterisk 1 4 | > * asterisk 2 5 | > * asterisk 3 6 | -------------------------------------------------------------------------------- /vendor/github.com/shurcooL/sanitized_anchor_name/README.md: -------------------------------------------------------------------------------- 1 | # sanitized_anchor_name [![Build Status](https://travis-ci.org/shurcooL/sanitized_anchor_name.svg?branch=master)](https://travis-ci.org/shurcooL/sanitized_anchor_name) [![GoDoc](https://godoc.org/github.com/shurcooL/sanitized_anchor_name?status.svg)](https://godoc.org/github.com/shurcooL/sanitized_anchor_name) 2 | 3 | Package sanitized_anchor_name provides a func to create sanitized anchor names. 4 | 5 | Its logic can be reused by multiple packages to create interoperable anchor names and links to those anchors. 6 | 7 | At this time, it does not try to ensure that generated anchor names are unique, that responsibility falls on the caller. 8 | 9 | Installation 10 | ------------ 11 | 12 | ```bash 13 | go get -u github.com/shurcooL/sanitized_anchor_name 14 | ``` 15 | 16 | Example 17 | ------- 18 | 19 | ```Go 20 | anchorName := sanitized_anchor_name.Create("This is a header") 21 | 22 | fmt.Println(anchorName) 23 | 24 | // Output: 25 | // this-is-a-header 26 | ``` 27 | 28 | License 29 | ------- 30 | 31 | - [MIT License](http://opensource.org/licenses/mit-license.php) 32 | -------------------------------------------------------------------------------- /vendor/github.com/shurcooL/sanitized_anchor_name/main.go: -------------------------------------------------------------------------------- 1 | // Package sanitized_anchor_name provides a func to create sanitized anchor names. 2 | // 3 | // Its logic can be reused by multiple packages to create interoperable anchor names 4 | // and links to those anchors. 5 | // 6 | // At this time, it does not try to ensure that generated anchor names 7 | // are unique, that responsibility falls on the caller. 8 | package sanitized_anchor_name // import "github.com/shurcooL/sanitized_anchor_name" 9 | 10 | import "unicode" 11 | 12 | // Create returns a sanitized anchor name for the given text. 13 | func Create(text string) string { 14 | var anchorName []rune 15 | var futureDash = false 16 | for _, r := range []rune(text) { 17 | switch { 18 | case unicode.IsLetter(r) || unicode.IsNumber(r): 19 | if futureDash && len(anchorName) > 0 { 20 | anchorName = append(anchorName, '-') 21 | } 22 | futureDash = false 23 | anchorName = append(anchorName, unicode.ToLower(r)) 24 | default: 25 | futureDash = true 26 | } 27 | } 28 | return string(anchorName) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/shurcooL/sanitized_anchor_name/main_test.go: -------------------------------------------------------------------------------- 1 | package sanitized_anchor_name_test 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/shurcooL/sanitized_anchor_name" 7 | ) 8 | 9 | func ExampleCreate() { 10 | anchorName := sanitized_anchor_name.Create("This is a header") 11 | 12 | fmt.Println(anchorName) 13 | 14 | // Output: 15 | // this-is-a-header 16 | } 17 | 18 | func ExampleCreate2() { 19 | fmt.Println(sanitized_anchor_name.Create("This is a header")) 20 | fmt.Println(sanitized_anchor_name.Create("This is also a header")) 21 | fmt.Println(sanitized_anchor_name.Create("main.go")) 22 | fmt.Println(sanitized_anchor_name.Create("Article 123")) 23 | fmt.Println(sanitized_anchor_name.Create("<- Let's try this, shall we?")) 24 | fmt.Printf("%q\n", sanitized_anchor_name.Create(" ")) 25 | fmt.Println(sanitized_anchor_name.Create("Hello, 世界")) 26 | 27 | // Output: 28 | // this-is-a-header 29 | // this-is-also-a-header 30 | // main-go 31 | // article-123 32 | // let-s-try-this-shall-we 33 | // "" 34 | // hello-世界 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/bash_completions_test.go: -------------------------------------------------------------------------------- 1 | package cobra 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "os" 7 | "strings" 8 | "testing" 9 | ) 10 | 11 | var _ = fmt.Println 12 | var _ = os.Stderr 13 | 14 | func checkOmit(t *testing.T, found, unexpected string) { 15 | if strings.Contains(found, unexpected) { 16 | t.Errorf("Unexpected response.\nGot: %q\nBut should not have!\n", unexpected) 17 | } 18 | } 19 | 20 | func check(t *testing.T, found, expected string) { 21 | if !strings.Contains(found, expected) { 22 | t.Errorf("Unexpected response.\nExpecting to contain: \n %q\nGot:\n %q\n", expected, found) 23 | } 24 | } 25 | 26 | // World worst custom function, just keep telling you to enter hello! 27 | const ( 28 | bash_completion_func = `__custom_func() { 29 | COMPREPLY=( "hello" ) 30 | } 31 | ` 32 | ) 33 | 34 | func TestBashCompletions(t *testing.T) { 35 | c := initializeWithRootCmd() 36 | cmdEcho.AddCommand(cmdTimes) 37 | c.AddCommand(cmdEcho, cmdPrint, cmdDeprecated) 38 | 39 | // custom completion function 40 | c.BashCompletionFunction = bash_completion_func 41 | 42 | // required flag 43 | c.MarkFlagRequired("introot") 44 | 45 | // valid nouns 46 | validArgs := []string{"pods", "nodes", "services", "replicationControllers"} 47 | c.ValidArgs = validArgs 48 | 49 | // filename 50 | var flagval string 51 | c.Flags().StringVar(&flagval, "filename", "", "Enter a filename") 52 | c.MarkFlagFilename("filename", "json", "yaml", "yml") 53 | 54 | // filename extensions 55 | var flagvalExt string 56 | c.Flags().StringVar(&flagvalExt, "filename-ext", "", "Enter a filename (extension limited)") 57 | c.MarkFlagFilename("filename-ext") 58 | 59 | // subdirectories in a given directory 60 | var flagvalTheme string 61 | c.Flags().StringVar(&flagvalTheme, "theme", "", "theme to use (located in /themes/THEMENAME/)") 62 | c.Flags().SetAnnotation("theme", BashCompSubdirsInDir, []string{"themes"}) 63 | 64 | out := new(bytes.Buffer) 65 | c.GenBashCompletion(out) 66 | str := out.String() 67 | 68 | check(t, str, "_cobra-test") 69 | check(t, str, "_cobra-test_echo") 70 | check(t, str, "_cobra-test_echo_times") 71 | check(t, str, "_cobra-test_print") 72 | 73 | // check for required flags 74 | check(t, str, `must_have_one_flag+=("--introot=")`) 75 | // check for custom completion function 76 | check(t, str, `COMPREPLY=( "hello" )`) 77 | // check for required nouns 78 | check(t, str, `must_have_one_noun+=("pods")`) 79 | // check for filename extension flags 80 | check(t, str, `flags_completion+=("_filedir")`) 81 | // check for filename extension flags 82 | check(t, str, `flags_completion+=("__handle_filename_extension_flag json|yaml|yml")`) 83 | // check for subdirs_in_dir flags 84 | check(t, str, `flags_completion+=("__handle_subdirs_in_dir_flag themes")`) 85 | 86 | checkOmit(t, str, cmdDeprecated.Name()) 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/command_test.go: -------------------------------------------------------------------------------- 1 | package cobra 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | // test to ensure hidden commands run as intended 9 | func TestHiddenCommandExecutes(t *testing.T) { 10 | 11 | // ensure that outs does not already equal what the command will be setting it 12 | // to, if it did this test would not actually be testing anything... 13 | if outs == "hidden" { 14 | t.Errorf("outs should NOT EQUAL hidden") 15 | } 16 | 17 | cmdHidden.Execute() 18 | 19 | // upon running the command, the value of outs should now be 'hidden' 20 | if outs != "hidden" { 21 | t.Errorf("Hidden command failed to run!") 22 | } 23 | } 24 | 25 | // test to ensure hidden commands do not show up in usage/help text 26 | func TestHiddenCommandIsHidden(t *testing.T) { 27 | if cmdHidden.IsAvailableCommand() { 28 | t.Errorf("Hidden command found!") 29 | } 30 | } 31 | 32 | func TestStripFlags(t *testing.T) { 33 | tests := []struct { 34 | input []string 35 | output []string 36 | }{ 37 | { 38 | []string{"foo", "bar"}, 39 | []string{"foo", "bar"}, 40 | }, 41 | { 42 | []string{"foo", "--bar", "-b"}, 43 | []string{"foo"}, 44 | }, 45 | { 46 | []string{"-b", "foo", "--bar", "bar"}, 47 | []string{}, 48 | }, 49 | { 50 | []string{"-i10", "echo"}, 51 | []string{"echo"}, 52 | }, 53 | { 54 | []string{"-i=10", "echo"}, 55 | []string{"echo"}, 56 | }, 57 | { 58 | []string{"--int=100", "echo"}, 59 | []string{"echo"}, 60 | }, 61 | { 62 | []string{"-ib", "echo", "-bfoo", "baz"}, 63 | []string{"echo", "baz"}, 64 | }, 65 | { 66 | []string{"-i=baz", "bar", "-i", "foo", "blah"}, 67 | []string{"bar", "blah"}, 68 | }, 69 | { 70 | []string{"--int=baz", "-bbar", "-i", "foo", "blah"}, 71 | []string{"blah"}, 72 | }, 73 | { 74 | []string{"--cat", "bar", "-i", "foo", "blah"}, 75 | []string{"bar", "blah"}, 76 | }, 77 | { 78 | []string{"-c", "bar", "-i", "foo", "blah"}, 79 | []string{"bar", "blah"}, 80 | }, 81 | { 82 | []string{"--persist", "bar"}, 83 | []string{"bar"}, 84 | }, 85 | { 86 | []string{"-p", "bar"}, 87 | []string{"bar"}, 88 | }, 89 | } 90 | 91 | cmdPrint := &Command{ 92 | Use: "print [string to print]", 93 | Short: "Print anything to the screen", 94 | Long: `an utterly useless command for testing.`, 95 | Run: func(cmd *Command, args []string) { 96 | tp = args 97 | }, 98 | } 99 | 100 | var flagi int 101 | var flagstr string 102 | var flagbool bool 103 | cmdPrint.PersistentFlags().BoolVarP(&flagbool, "persist", "p", false, "help for persistent one") 104 | cmdPrint.Flags().IntVarP(&flagi, "int", "i", 345, "help message for flag int") 105 | cmdPrint.Flags().StringVarP(&flagstr, "bar", "b", "bar", "help message for flag string") 106 | cmdPrint.Flags().BoolVarP(&flagbool, "cat", "c", false, "help message for flag bool") 107 | 108 | for _, test := range tests { 109 | output := stripFlags(test.input, cmdPrint) 110 | if !reflect.DeepEqual(test.output, output) { 111 | t.Errorf("expected: %v, got: %v", test.output, output) 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/doc_util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Red Hat Inc. All rights reserved. 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 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package cobra 15 | 16 | // Test to see if we have a reason to print See Also information in docs 17 | // Basically this is a test for a parent commend or a subcommand which is 18 | // both not deprecated and not the autogenerated help command. 19 | func (cmd *Command) hasSeeAlso() bool { 20 | if cmd.HasParent() { 21 | return true 22 | } 23 | children := cmd.Commands() 24 | if len(children) == 0 { 25 | return false 26 | } 27 | for _, c := range children { 28 | if !c.IsAvailableCommand() || c == cmd.helpCommand { 29 | continue 30 | } 31 | return true 32 | } 33 | return false 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/examples_test.go: -------------------------------------------------------------------------------- 1 | package cobra_test 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | 7 | "github.com/spf13/cobra" 8 | ) 9 | 10 | func ExampleCommand_GenManTree() { 11 | cmd := &cobra.Command{ 12 | Use: "test", 13 | Short: "my test program", 14 | } 15 | header := &cobra.GenManHeader{ 16 | Title: "MINE", 17 | Section: "3", 18 | } 19 | cmd.GenManTree(header, "/tmp") 20 | } 21 | 22 | func ExampleCommand_GenMan() { 23 | cmd := &cobra.Command{ 24 | Use: "test", 25 | Short: "my test program", 26 | } 27 | header := &cobra.GenManHeader{ 28 | Title: "MINE", 29 | Section: "3", 30 | } 31 | out := new(bytes.Buffer) 32 | cmd.GenMan(header, out) 33 | fmt.Print(out.String()) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/man_docs.md: -------------------------------------------------------------------------------- 1 | # Generating Man Pages For Your Own cobra.Command 2 | 3 | Generating bash completions from a cobra command is incredibly easy. An example is as follows: 4 | 5 | ```go 6 | package main 7 | 8 | import ( 9 | "github.com/spf13/cobra" 10 | ) 11 | 12 | func main() { 13 | cmd := &cobra.Command{ 14 | Use: "test", 15 | Short: "my test program", 16 | } 17 | header := &cobra.GenManHeader{ 18 | Title: "MINE", 19 | Section: "3", 20 | } 21 | cmd.GenManTree(header, "/tmp") 22 | } 23 | ``` 24 | 25 | That will get you a man page `/tmp/test.1` 26 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/man_docs_test.go: -------------------------------------------------------------------------------- 1 | package cobra 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "os" 7 | "strings" 8 | "testing" 9 | ) 10 | 11 | var _ = fmt.Println 12 | var _ = os.Stderr 13 | 14 | func translate(in string) string { 15 | return strings.Replace(in, "-", "\\-", -1) 16 | } 17 | 18 | func TestGenManDoc(t *testing.T) { 19 | c := initializeWithRootCmd() 20 | // Need two commands to run the command alphabetical sort 21 | cmdEcho.AddCommand(cmdTimes, cmdEchoSub, cmdDeprecated) 22 | c.AddCommand(cmdPrint, cmdEcho) 23 | cmdRootWithRun.PersistentFlags().StringVarP(&flags2a, "rootflag", "r", "two", strtwoParentHelp) 24 | 25 | out := new(bytes.Buffer) 26 | 27 | header := &GenManHeader{ 28 | Title: "Project", 29 | Section: "2", 30 | } 31 | // We generate on a subcommand so we have both subcommands and parents 32 | cmdEcho.GenMan(header, out) 33 | found := out.String() 34 | 35 | // Make sure parent has - in CommandPath() in SEE ALSO: 36 | parentPath := cmdEcho.Parent().CommandPath() 37 | dashParentPath := strings.Replace(parentPath, " ", "-", -1) 38 | expected := translate(dashParentPath) 39 | expected = expected + "(" + header.Section + ")" 40 | checkStringContains(t, found, expected) 41 | 42 | // Our description 43 | expected = translate(cmdEcho.Name()) 44 | checkStringContains(t, found, expected) 45 | 46 | // Better have our example 47 | expected = translate(cmdEcho.Name()) 48 | checkStringContains(t, found, expected) 49 | 50 | // A local flag 51 | expected = "boolone" 52 | checkStringContains(t, found, expected) 53 | 54 | // persistent flag on parent 55 | expected = "rootflag" 56 | checkStringContains(t, found, expected) 57 | 58 | // We better output info about our parent 59 | expected = translate(cmdRootWithRun.Name()) 60 | checkStringContains(t, found, expected) 61 | 62 | // And about subcommands 63 | expected = translate(cmdEchoSub.Name()) 64 | checkStringContains(t, found, expected) 65 | 66 | unexpected := translate(cmdDeprecated.Name()) 67 | checkStringOmits(t, found, unexpected) 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/md_docs.md: -------------------------------------------------------------------------------- 1 | # Generating Markdown Docs For Your Own cobra.Command 2 | 3 | ## Generate markdown docs for the entire command tree 4 | 5 | This program can actually generate docs for the kubectl command in the kubernetes project 6 | 7 | ```go 8 | package main 9 | 10 | import ( 11 | "io/ioutil" 12 | "os" 13 | 14 | "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd" 15 | "github.com/spf13/cobra" 16 | ) 17 | 18 | func main() { 19 | kubectl := cmd.NewFactory(nil).NewKubectlCommand(os.Stdin, ioutil.Discard, ioutil.Discard) 20 | cobra.GenMarkdownTree(kubectl, "./") 21 | } 22 | ``` 23 | 24 | This will generate a whole series of files, one for each command in the tree, in the directory specified (in this case "./") 25 | 26 | ## Generate markdown docs for a single command 27 | 28 | You may wish to have more control over the output, or only generate for a single command, instead of the entire command tree. If this is the case you may prefer to `GenMarkdown` instead of `GenMarkdownTree` 29 | 30 | ```go 31 | out := new(bytes.Buffer) 32 | cobra.GenMarkdown(cmd, out) 33 | ``` 34 | 35 | This will write the markdown doc for ONLY "cmd" into the out, buffer. 36 | 37 | ## Customize the output 38 | 39 | Both `GenMarkdown` and `GenMarkdownTree` have alternate versions with callbacks to get some control of the output: 40 | 41 | ```go 42 | func GenMarkdownTreeCustom(cmd *Command, dir string, filePrepender func(string) string, linkHandler func(string) string) { 43 | //... 44 | } 45 | ``` 46 | 47 | ```go 48 | func GenMarkdownCustom(cmd *Command, out *bytes.Buffer, linkHandler func(string) string) { 49 | //... 50 | } 51 | ``` 52 | 53 | The `filePrepender` will prepend the return value given the full filepath to the rendered Markdown file. A common use case is to add front matter to use the generated documentation with [Hugo](http://gohugo.io/): 54 | 55 | ```go 56 | const fmTemplate = `--- 57 | date: %s 58 | title: "%s" 59 | slug: %s 60 | url: %s 61 | --- 62 | ` 63 | 64 | filePrepender := func(filename string) string { 65 | now := time.Now().Format(time.RFC3339) 66 | name := filepath.Base(filename) 67 | base := strings.TrimSuffix(name, path.Ext(name)) 68 | url := "/commands/" + strings.ToLower(base) + "/" 69 | return fmt.Sprintf(fmTemplate, now, strings.Replace(base, "_", " ", -1), base, url) 70 | } 71 | ``` 72 | 73 | The `linkHandler` can be used to customize the rendered internal links to the commands, given a filename: 74 | 75 | ```go 76 | linkHandler := func(name string) string { 77 | base := strings.TrimSuffix(name, path.Ext(name)) 78 | return "/commands/" + strings.ToLower(base) + "/" 79 | } 80 | ``` 81 | 82 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/md_docs_test.go: -------------------------------------------------------------------------------- 1 | package cobra 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "os" 7 | "strings" 8 | "testing" 9 | ) 10 | 11 | var _ = fmt.Println 12 | var _ = os.Stderr 13 | 14 | func TestGenMdDoc(t *testing.T) { 15 | c := initializeWithRootCmd() 16 | // Need two commands to run the command alphabetical sort 17 | cmdEcho.AddCommand(cmdTimes, cmdEchoSub, cmdDeprecated) 18 | c.AddCommand(cmdPrint, cmdEcho) 19 | cmdRootWithRun.PersistentFlags().StringVarP(&flags2a, "rootflag", "r", "two", strtwoParentHelp) 20 | 21 | out := new(bytes.Buffer) 22 | 23 | // We generate on s subcommand so we have both subcommands and parents 24 | GenMarkdown(cmdEcho, out) 25 | found := out.String() 26 | 27 | // Our description 28 | expected := cmdEcho.Long 29 | if !strings.Contains(found, expected) { 30 | t.Errorf("Unexpected response.\nExpecting to contain: \n %q\nGot:\n %q\n", expected, found) 31 | } 32 | 33 | // Better have our example 34 | expected = cmdEcho.Example 35 | if !strings.Contains(found, expected) { 36 | t.Errorf("Unexpected response.\nExpecting to contain: \n %q\nGot:\n %q\n", expected, found) 37 | } 38 | 39 | // A local flag 40 | expected = "boolone" 41 | if !strings.Contains(found, expected) { 42 | t.Errorf("Unexpected response.\nExpecting to contain: \n %q\nGot:\n %q\n", expected, found) 43 | } 44 | 45 | // persistent flag on parent 46 | expected = "rootflag" 47 | if !strings.Contains(found, expected) { 48 | t.Errorf("Unexpected response.\nExpecting to contain: \n %q\nGot:\n %q\n", expected, found) 49 | } 50 | 51 | // We better output info about our parent 52 | expected = cmdRootWithRun.Short 53 | if !strings.Contains(found, expected) { 54 | t.Errorf("Unexpected response.\nExpecting to contain: \n %q\nGot:\n %q\n", expected, found) 55 | } 56 | 57 | // And about subcommands 58 | expected = cmdEchoSub.Short 59 | if !strings.Contains(found, expected) { 60 | t.Errorf("Unexpected response.\nExpecting to contain: \n %q\nGot:\n %q\n", expected, found) 61 | } 62 | 63 | unexpected := cmdDeprecated.Short 64 | if strings.Contains(found, unexpected) { 65 | t.Errorf("Unexpected response.\nFound: %v\nBut should not have!!\n", unexpected) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Alex Ogier. All rights reserved. 2 | Copyright (c) 2012 The Go Authors. All rights reserved. 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 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/bool.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // optional interface to indicate boolean flags that can be 9 | // supplied without "=value" text 10 | type boolFlag interface { 11 | Value 12 | IsBoolFlag() bool 13 | } 14 | 15 | // -- bool Value 16 | type boolValue bool 17 | 18 | func newBoolValue(val bool, p *bool) *boolValue { 19 | *p = val 20 | return (*boolValue)(p) 21 | } 22 | 23 | func (b *boolValue) Set(s string) error { 24 | v, err := strconv.ParseBool(s) 25 | *b = boolValue(v) 26 | return err 27 | } 28 | 29 | func (b *boolValue) Type() string { 30 | return "bool" 31 | } 32 | 33 | func (b *boolValue) String() string { return fmt.Sprintf("%v", *b) } 34 | 35 | func (b *boolValue) IsBoolFlag() bool { return true } 36 | 37 | func boolConv(sval string) (interface{}, error) { 38 | return strconv.ParseBool(sval) 39 | } 40 | 41 | // GetBool return the bool value of a flag with the given name 42 | func (f *FlagSet) GetBool(name string) (bool, error) { 43 | val, err := f.getFlagType(name, "bool", boolConv) 44 | if err != nil { 45 | return false, err 46 | } 47 | return val.(bool), nil 48 | } 49 | 50 | // BoolVar defines a bool flag with specified name, default value, and usage string. 51 | // The argument p points to a bool variable in which to store the value of the flag. 52 | func (f *FlagSet) BoolVar(p *bool, name string, value bool, usage string) { 53 | f.BoolVarP(p, name, "", value, usage) 54 | } 55 | 56 | // BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash. 57 | func (f *FlagSet) BoolVarP(p *bool, name, shorthand string, value bool, usage string) { 58 | flag := f.VarPF(newBoolValue(value, p), name, shorthand, usage) 59 | flag.NoOptDefVal = "true" 60 | } 61 | 62 | // BoolVar defines a bool flag with specified name, default value, and usage string. 63 | // The argument p points to a bool variable in which to store the value of the flag. 64 | func BoolVar(p *bool, name string, value bool, usage string) { 65 | BoolVarP(p, name, "", value, usage) 66 | } 67 | 68 | // BoolVarP is like BoolVar, but accepts a shorthand letter that can be used after a single dash. 69 | func BoolVarP(p *bool, name, shorthand string, value bool, usage string) { 70 | flag := CommandLine.VarPF(newBoolValue(value, p), name, shorthand, usage) 71 | flag.NoOptDefVal = "true" 72 | } 73 | 74 | // Bool defines a bool flag with specified name, default value, and usage string. 75 | // The return value is the address of a bool variable that stores the value of the flag. 76 | func (f *FlagSet) Bool(name string, value bool, usage string) *bool { 77 | return f.BoolP(name, "", value, usage) 78 | } 79 | 80 | // BoolP is like Bool, but accepts a shorthand letter that can be used after a single dash. 81 | func (f *FlagSet) BoolP(name, shorthand string, value bool, usage string) *bool { 82 | p := new(bool) 83 | f.BoolVarP(p, name, shorthand, value, usage) 84 | return p 85 | } 86 | 87 | // Bool defines a bool flag with specified name, default value, and usage string. 88 | // The return value is the address of a bool variable that stores the value of the flag. 89 | func Bool(name string, value bool, usage string) *bool { 90 | return BoolP(name, "", value, usage) 91 | } 92 | 93 | // BoolP is like Bool, but accepts a shorthand letter that can be used after a single dash. 94 | func BoolP(name, shorthand string, value bool, usage string) *bool { 95 | b := CommandLine.BoolP(name, shorthand, value, usage) 96 | return b 97 | } 98 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/count.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- count Value 9 | type countValue int 10 | 11 | func newCountValue(val int, p *int) *countValue { 12 | *p = val 13 | return (*countValue)(p) 14 | } 15 | 16 | func (i *countValue) Set(s string) error { 17 | v, err := strconv.ParseInt(s, 0, 64) 18 | // -1 means that no specific value was passed, so increment 19 | if v == -1 { 20 | *i = countValue(*i + 1) 21 | } else { 22 | *i = countValue(v) 23 | } 24 | return err 25 | } 26 | 27 | func (i *countValue) Type() string { 28 | return "count" 29 | } 30 | 31 | func (i *countValue) String() string { return fmt.Sprintf("%v", *i) } 32 | 33 | func countConv(sval string) (interface{}, error) { 34 | i, err := strconv.Atoi(sval) 35 | if err != nil { 36 | return nil, err 37 | } 38 | return i, nil 39 | } 40 | 41 | // GetCount return the int value of a flag with the given name 42 | func (f *FlagSet) GetCount(name string) (int, error) { 43 | val, err := f.getFlagType(name, "count", countConv) 44 | if err != nil { 45 | return 0, err 46 | } 47 | return val.(int), nil 48 | } 49 | 50 | // CountVar defines a count flag with specified name, default value, and usage string. 51 | // The argument p points to an int variable in which to store the value of the flag. 52 | // A count flag will add 1 to its value evey time it is found on the command line 53 | func (f *FlagSet) CountVar(p *int, name string, usage string) { 54 | f.CountVarP(p, name, "", usage) 55 | } 56 | 57 | // CountVarP is like CountVar only take a shorthand for the flag name. 58 | func (f *FlagSet) CountVarP(p *int, name, shorthand string, usage string) { 59 | flag := f.VarPF(newCountValue(0, p), name, shorthand, usage) 60 | flag.NoOptDefVal = "-1" 61 | } 62 | 63 | // CountVar like CountVar only the flag is placed on the CommandLine instead of a given flag set 64 | func CountVar(p *int, name string, usage string) { 65 | CommandLine.CountVar(p, name, usage) 66 | } 67 | 68 | // CountVarP is like CountVar only take a shorthand for the flag name. 69 | func CountVarP(p *int, name, shorthand string, usage string) { 70 | CommandLine.CountVarP(p, name, shorthand, usage) 71 | } 72 | 73 | // Count defines a count flag with specified name, default value, and usage string. 74 | // The return value is the address of an int variable that stores the value of the flag. 75 | // A count flag will add 1 to its value evey time it is found on the command line 76 | func (f *FlagSet) Count(name string, usage string) *int { 77 | p := new(int) 78 | f.CountVarP(p, name, "", usage) 79 | return p 80 | } 81 | 82 | // CountP is like Count only takes a shorthand for the flag name. 83 | func (f *FlagSet) CountP(name, shorthand string, usage string) *int { 84 | p := new(int) 85 | f.CountVarP(p, name, shorthand, usage) 86 | return p 87 | } 88 | 89 | // Count like Count only the flag is placed on the CommandLine isntead of a given flag set 90 | func Count(name string, usage string) *int { 91 | return CommandLine.CountP(name, "", usage) 92 | } 93 | 94 | // CountP is like Count only takes a shorthand for the flag name. 95 | func CountP(name, shorthand string, usage string) *int { 96 | return CommandLine.CountP(name, shorthand, usage) 97 | } 98 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/count_test.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "testing" 7 | ) 8 | 9 | var _ = fmt.Printf 10 | 11 | func setUpCount(c *int) *FlagSet { 12 | f := NewFlagSet("test", ContinueOnError) 13 | f.CountVarP(c, "verbose", "v", "a counter") 14 | return f 15 | } 16 | 17 | func TestCount(t *testing.T) { 18 | testCases := []struct { 19 | input []string 20 | success bool 21 | expected int 22 | }{ 23 | {[]string{"-vvv"}, true, 3}, 24 | {[]string{"-v", "-v", "-v"}, true, 3}, 25 | {[]string{"-v", "--verbose", "-v"}, true, 3}, 26 | {[]string{"-v=3", "-v"}, true, 4}, 27 | {[]string{"-v=a"}, false, 0}, 28 | } 29 | 30 | devnull, _ := os.Open(os.DevNull) 31 | os.Stderr = devnull 32 | for i := range testCases { 33 | var count int 34 | f := setUpCount(&count) 35 | 36 | tc := &testCases[i] 37 | 38 | err := f.Parse(tc.input) 39 | if err != nil && tc.success == true { 40 | t.Errorf("expected success, got %q", err) 41 | continue 42 | } else if err == nil && tc.success == false { 43 | t.Errorf("expected failure, got success") 44 | continue 45 | } else if tc.success { 46 | c, err := f.GetCount("verbose") 47 | if err != nil { 48 | t.Errorf("Got error trying to fetch the counter flag") 49 | } 50 | if c != tc.expected { 51 | t.Errorf("expected %q, got %q", tc.expected, c) 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/duration.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | // -- time.Duration Value 8 | type durationValue time.Duration 9 | 10 | func newDurationValue(val time.Duration, p *time.Duration) *durationValue { 11 | *p = val 12 | return (*durationValue)(p) 13 | } 14 | 15 | func (d *durationValue) Set(s string) error { 16 | v, err := time.ParseDuration(s) 17 | *d = durationValue(v) 18 | return err 19 | } 20 | 21 | func (d *durationValue) Type() string { 22 | return "duration" 23 | } 24 | 25 | func (d *durationValue) String() string { return (*time.Duration)(d).String() } 26 | 27 | func durationConv(sval string) (interface{}, error) { 28 | return time.ParseDuration(sval) 29 | } 30 | 31 | // GetDuration return the duration value of a flag with the given name 32 | func (f *FlagSet) GetDuration(name string) (time.Duration, error) { 33 | val, err := f.getFlagType(name, "duration", durationConv) 34 | if err != nil { 35 | return 0, err 36 | } 37 | return val.(time.Duration), nil 38 | } 39 | 40 | // DurationVar defines a time.Duration flag with specified name, default value, and usage string. 41 | // The argument p points to a time.Duration variable in which to store the value of the flag. 42 | func (f *FlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string) { 43 | f.VarP(newDurationValue(value, p), name, "", usage) 44 | } 45 | 46 | // DurationVarP is like DurationVar, but accepts a shorthand letter that can be used after a single dash. 47 | func (f *FlagSet) DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string) { 48 | f.VarP(newDurationValue(value, p), name, shorthand, usage) 49 | } 50 | 51 | // DurationVar defines a time.Duration flag with specified name, default value, and usage string. 52 | // The argument p points to a time.Duration variable in which to store the value of the flag. 53 | func DurationVar(p *time.Duration, name string, value time.Duration, usage string) { 54 | CommandLine.VarP(newDurationValue(value, p), name, "", usage) 55 | } 56 | 57 | // DurationVarP is like DurationVar, but accepts a shorthand letter that can be used after a single dash. 58 | func DurationVarP(p *time.Duration, name, shorthand string, value time.Duration, usage string) { 59 | CommandLine.VarP(newDurationValue(value, p), name, shorthand, usage) 60 | } 61 | 62 | // Duration defines a time.Duration flag with specified name, default value, and usage string. 63 | // The return value is the address of a time.Duration variable that stores the value of the flag. 64 | func (f *FlagSet) Duration(name string, value time.Duration, usage string) *time.Duration { 65 | p := new(time.Duration) 66 | f.DurationVarP(p, name, "", value, usage) 67 | return p 68 | } 69 | 70 | // DurationP is like Duration, but accepts a shorthand letter that can be used after a single dash. 71 | func (f *FlagSet) DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration { 72 | p := new(time.Duration) 73 | f.DurationVarP(p, name, shorthand, value, usage) 74 | return p 75 | } 76 | 77 | // Duration defines a time.Duration flag with specified name, default value, and usage string. 78 | // The return value is the address of a time.Duration variable that stores the value of the flag. 79 | func Duration(name string, value time.Duration, usage string) *time.Duration { 80 | return CommandLine.DurationP(name, "", value, usage) 81 | } 82 | 83 | // DurationP is like Duration, but accepts a shorthand letter that can be used after a single dash. 84 | func DurationP(name, shorthand string, value time.Duration, usage string) *time.Duration { 85 | return CommandLine.DurationP(name, shorthand, value, usage) 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/example_test.go: -------------------------------------------------------------------------------- 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 | // These examples demonstrate more intricate uses of the flag package. 6 | package pflag_test 7 | 8 | import ( 9 | "errors" 10 | "fmt" 11 | "strings" 12 | "time" 13 | 14 | flag "github.com/spf13/pflag" 15 | ) 16 | 17 | // Example 1: A single string flag called "species" with default value "gopher". 18 | var species = flag.String("species", "gopher", "the species we are studying") 19 | 20 | // Example 2: A flag with a shorthand letter. 21 | var gopherType = flag.StringP("gopher_type", "g", "pocket", "the variety of gopher") 22 | 23 | // Example 3: A user-defined flag type, a slice of durations. 24 | type interval []time.Duration 25 | 26 | // String is the method to format the flag's value, part of the flag.Value interface. 27 | // The String method's output will be used in diagnostics. 28 | func (i *interval) String() string { 29 | return fmt.Sprint(*i) 30 | } 31 | 32 | func (i *interval) Type() string { 33 | return "interval" 34 | } 35 | 36 | // Set is the method to set the flag value, part of the flag.Value interface. 37 | // Set's argument is a string to be parsed to set the flag. 38 | // It's a comma-separated list, so we split it. 39 | func (i *interval) Set(value string) error { 40 | // If we wanted to allow the flag to be set multiple times, 41 | // accumulating values, we would delete this if statement. 42 | // That would permit usages such as 43 | // -deltaT 10s -deltaT 15s 44 | // and other combinations. 45 | if len(*i) > 0 { 46 | return errors.New("interval flag already set") 47 | } 48 | for _, dt := range strings.Split(value, ",") { 49 | duration, err := time.ParseDuration(dt) 50 | if err != nil { 51 | return err 52 | } 53 | *i = append(*i, duration) 54 | } 55 | return nil 56 | } 57 | 58 | // Define a flag to accumulate durations. Because it has a special type, 59 | // we need to use the Var function and therefore create the flag during 60 | // init. 61 | 62 | var intervalFlag interval 63 | 64 | func init() { 65 | // Tie the command-line flag to the intervalFlag variable and 66 | // set a usage message. 67 | flag.Var(&intervalFlag, "deltaT", "comma-separated list of intervals to use between events") 68 | } 69 | 70 | func Example() { 71 | // All the interesting pieces are with the variables declared above, but 72 | // to enable the flag package to see the flags defined there, one must 73 | // execute, typically at the start of main (not init!): 74 | // flag.Parse() 75 | // We don't run it here because this is not a main function and 76 | // the testing suite has already parsed the flags. 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/export_test.go: -------------------------------------------------------------------------------- 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 pflag 6 | 7 | import ( 8 | "io/ioutil" 9 | "os" 10 | ) 11 | 12 | // Additional routines compiled into the package only during testing. 13 | 14 | // ResetForTesting clears all flag state and sets the usage function as directed. 15 | // After calling ResetForTesting, parse errors in flag handling will not 16 | // exit the program. 17 | func ResetForTesting(usage func()) { 18 | CommandLine = &FlagSet{ 19 | name: os.Args[0], 20 | errorHandling: ContinueOnError, 21 | output: ioutil.Discard, 22 | } 23 | Usage = usage 24 | } 25 | 26 | // GetCommandLine returns the default FlagSet. 27 | func GetCommandLine() *FlagSet { 28 | return CommandLine 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/float32.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- float32 Value 9 | type float32Value float32 10 | 11 | func newFloat32Value(val float32, p *float32) *float32Value { 12 | *p = val 13 | return (*float32Value)(p) 14 | } 15 | 16 | func (f *float32Value) Set(s string) error { 17 | v, err := strconv.ParseFloat(s, 32) 18 | *f = float32Value(v) 19 | return err 20 | } 21 | 22 | func (f *float32Value) Type() string { 23 | return "float32" 24 | } 25 | 26 | func (f *float32Value) String() string { return fmt.Sprintf("%v", *f) } 27 | 28 | func float32Conv(sval string) (interface{}, error) { 29 | v, err := strconv.ParseFloat(sval, 32) 30 | if err != nil { 31 | return 0, err 32 | } 33 | return float32(v), nil 34 | } 35 | 36 | // GetFloat32 return the float32 value of a flag with the given name 37 | func (f *FlagSet) GetFloat32(name string) (float32, error) { 38 | val, err := f.getFlagType(name, "float32", float32Conv) 39 | if err != nil { 40 | return 0, err 41 | } 42 | return val.(float32), nil 43 | } 44 | 45 | // Float32Var defines a float32 flag with specified name, default value, and usage string. 46 | // The argument p points to a float32 variable in which to store the value of the flag. 47 | func (f *FlagSet) Float32Var(p *float32, name string, value float32, usage string) { 48 | f.VarP(newFloat32Value(value, p), name, "", usage) 49 | } 50 | 51 | // Float32VarP is like Float32Var, but accepts a shorthand letter that can be used after a single dash. 52 | func (f *FlagSet) Float32VarP(p *float32, name, shorthand string, value float32, usage string) { 53 | f.VarP(newFloat32Value(value, p), name, shorthand, usage) 54 | } 55 | 56 | // Float32Var defines a float32 flag with specified name, default value, and usage string. 57 | // The argument p points to a float32 variable in which to store the value of the flag. 58 | func Float32Var(p *float32, name string, value float32, usage string) { 59 | CommandLine.VarP(newFloat32Value(value, p), name, "", usage) 60 | } 61 | 62 | // Float32VarP is like Float32Var, but accepts a shorthand letter that can be used after a single dash. 63 | func Float32VarP(p *float32, name, shorthand string, value float32, usage string) { 64 | CommandLine.VarP(newFloat32Value(value, p), name, shorthand, usage) 65 | } 66 | 67 | // Float32 defines a float32 flag with specified name, default value, and usage string. 68 | // The return value is the address of a float32 variable that stores the value of the flag. 69 | func (f *FlagSet) Float32(name string, value float32, usage string) *float32 { 70 | p := new(float32) 71 | f.Float32VarP(p, name, "", value, usage) 72 | return p 73 | } 74 | 75 | // Float32P is like Float32, but accepts a shorthand letter that can be used after a single dash. 76 | func (f *FlagSet) Float32P(name, shorthand string, value float32, usage string) *float32 { 77 | p := new(float32) 78 | f.Float32VarP(p, name, shorthand, value, usage) 79 | return p 80 | } 81 | 82 | // Float32 defines a float32 flag with specified name, default value, and usage string. 83 | // The return value is the address of a float32 variable that stores the value of the flag. 84 | func Float32(name string, value float32, usage string) *float32 { 85 | return CommandLine.Float32P(name, "", value, usage) 86 | } 87 | 88 | // Float32P is like Float32, but accepts a shorthand letter that can be used after a single dash. 89 | func Float32P(name, shorthand string, value float32, usage string) *float32 { 90 | return CommandLine.Float32P(name, shorthand, value, usage) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/float64.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- float64 Value 9 | type float64Value float64 10 | 11 | func newFloat64Value(val float64, p *float64) *float64Value { 12 | *p = val 13 | return (*float64Value)(p) 14 | } 15 | 16 | func (f *float64Value) Set(s string) error { 17 | v, err := strconv.ParseFloat(s, 64) 18 | *f = float64Value(v) 19 | return err 20 | } 21 | 22 | func (f *float64Value) Type() string { 23 | return "float64" 24 | } 25 | 26 | func (f *float64Value) String() string { return fmt.Sprintf("%v", *f) } 27 | 28 | func float64Conv(sval string) (interface{}, error) { 29 | return strconv.ParseFloat(sval, 64) 30 | } 31 | 32 | // GetFloat64 return the float64 value of a flag with the given name 33 | func (f *FlagSet) GetFloat64(name string) (float64, error) { 34 | val, err := f.getFlagType(name, "float64", float64Conv) 35 | if err != nil { 36 | return 0, err 37 | } 38 | return val.(float64), nil 39 | } 40 | 41 | // Float64Var defines a float64 flag with specified name, default value, and usage string. 42 | // The argument p points to a float64 variable in which to store the value of the flag. 43 | func (f *FlagSet) Float64Var(p *float64, name string, value float64, usage string) { 44 | f.VarP(newFloat64Value(value, p), name, "", usage) 45 | } 46 | 47 | // Float64VarP is like Float64Var, but accepts a shorthand letter that can be used after a single dash. 48 | func (f *FlagSet) Float64VarP(p *float64, name, shorthand string, value float64, usage string) { 49 | f.VarP(newFloat64Value(value, p), name, shorthand, usage) 50 | } 51 | 52 | // Float64Var defines a float64 flag with specified name, default value, and usage string. 53 | // The argument p points to a float64 variable in which to store the value of the flag. 54 | func Float64Var(p *float64, name string, value float64, usage string) { 55 | CommandLine.VarP(newFloat64Value(value, p), name, "", usage) 56 | } 57 | 58 | // Float64VarP is like Float64Var, but accepts a shorthand letter that can be used after a single dash. 59 | func Float64VarP(p *float64, name, shorthand string, value float64, usage string) { 60 | CommandLine.VarP(newFloat64Value(value, p), name, shorthand, usage) 61 | } 62 | 63 | // Float64 defines a float64 flag with specified name, default value, and usage string. 64 | // The return value is the address of a float64 variable that stores the value of the flag. 65 | func (f *FlagSet) Float64(name string, value float64, usage string) *float64 { 66 | p := new(float64) 67 | f.Float64VarP(p, name, "", value, usage) 68 | return p 69 | } 70 | 71 | // Float64P is like Float64, but accepts a shorthand letter that can be used after a single dash. 72 | func (f *FlagSet) Float64P(name, shorthand string, value float64, usage string) *float64 { 73 | p := new(float64) 74 | f.Float64VarP(p, name, shorthand, value, usage) 75 | return p 76 | } 77 | 78 | // Float64 defines a float64 flag with specified name, default value, and usage string. 79 | // The return value is the address of a float64 variable that stores the value of the flag. 80 | func Float64(name string, value float64, usage string) *float64 { 81 | return CommandLine.Float64P(name, "", value, usage) 82 | } 83 | 84 | // Float64P is like Float64, but accepts a shorthand letter that can be used after a single dash. 85 | func Float64P(name, shorthand string, value float64, usage string) *float64 { 86 | return CommandLine.Float64P(name, shorthand, value, usage) 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/golangflag.go: -------------------------------------------------------------------------------- 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 pflag 6 | 7 | import ( 8 | goflag "flag" 9 | "fmt" 10 | "reflect" 11 | "strings" 12 | ) 13 | 14 | var _ = fmt.Print 15 | 16 | // flagValueWrapper implements pflag.Value around a flag.Value. The main 17 | // difference here is the addition of the Type method that returns a string 18 | // name of the type. As this is generally unknown, we approximate that with 19 | // reflection. 20 | type flagValueWrapper struct { 21 | inner goflag.Value 22 | flagType string 23 | } 24 | 25 | // We are just copying the boolFlag interface out of goflag as that is what 26 | // they use to decide if a flag should get "true" when no arg is given. 27 | type goBoolFlag interface { 28 | goflag.Value 29 | IsBoolFlag() bool 30 | } 31 | 32 | func wrapFlagValue(v goflag.Value) Value { 33 | // If the flag.Value happens to also be a pflag.Value, just use it directly. 34 | if pv, ok := v.(Value); ok { 35 | return pv 36 | } 37 | 38 | pv := &flagValueWrapper{ 39 | inner: v, 40 | } 41 | 42 | t := reflect.TypeOf(v) 43 | if t.Kind() == reflect.Interface || t.Kind() == reflect.Ptr { 44 | t = t.Elem() 45 | } 46 | 47 | pv.flagType = strings.TrimSuffix(t.Name(), "Value") 48 | return pv 49 | } 50 | 51 | func (v *flagValueWrapper) String() string { 52 | return v.inner.String() 53 | } 54 | 55 | func (v *flagValueWrapper) Set(s string) error { 56 | return v.inner.Set(s) 57 | } 58 | 59 | func (v *flagValueWrapper) Type() string { 60 | return v.flagType 61 | } 62 | 63 | // PFlagFromGoFlag will return a *pflag.Flag given a *flag.Flag 64 | func PFlagFromGoFlag(goflag *goflag.Flag) *Flag { 65 | // Remember the default value as a string; it won't change. 66 | flag := &Flag{ 67 | Name: goflag.Name, 68 | Usage: goflag.Usage, 69 | Value: wrapFlagValue(goflag.Value), 70 | // Looks like golang flags don't set DefValue correctly :-( 71 | //DefValue: goflag.DefValue, 72 | DefValue: goflag.Value.String(), 73 | } 74 | if fv, ok := goflag.Value.(goBoolFlag); ok && fv.IsBoolFlag() { 75 | flag.NoOptDefVal = "true" 76 | } 77 | return flag 78 | } 79 | 80 | // AddGoFlag will add the given *flag.Flag to the pflag.FlagSet 81 | func (f *FlagSet) AddGoFlag(goflag *goflag.Flag) { 82 | if f.Lookup(goflag.Name) != nil { 83 | return 84 | } 85 | newflag := PFlagFromGoFlag(goflag) 86 | f.AddFlag(newflag) 87 | } 88 | 89 | // AddGoFlagSet will add the given *flag.FlagSet to the pflag.FlagSet 90 | func (f *FlagSet) AddGoFlagSet(newSet *goflag.FlagSet) { 91 | if newSet == nil { 92 | return 93 | } 94 | newSet.VisitAll(func(goflag *goflag.Flag) { 95 | f.AddGoFlag(goflag) 96 | }) 97 | } 98 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/golangflag_test.go: -------------------------------------------------------------------------------- 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 pflag 6 | 7 | import ( 8 | goflag "flag" 9 | "testing" 10 | ) 11 | 12 | func TestGoflags(t *testing.T) { 13 | goflag.String("stringFlag", "stringFlag", "stringFlag") 14 | goflag.Bool("boolFlag", false, "boolFlag") 15 | 16 | f := NewFlagSet("test", ContinueOnError) 17 | 18 | f.AddGoFlagSet(goflag.CommandLine) 19 | err := f.Parse([]string{"--stringFlag=bob", "--boolFlag"}) 20 | if err != nil { 21 | t.Fatal("expected no error; get", err) 22 | } 23 | 24 | getString, err := f.GetString("stringFlag") 25 | if err != nil { 26 | t.Fatal("expected no error; get", err) 27 | } 28 | if getString != "bob" { 29 | t.Fatalf("expected getString=bob but got getString=%s", getString) 30 | } 31 | 32 | getBool, err := f.GetBool("boolFlag") 33 | if err != nil { 34 | t.Fatal("expected no error; get", err) 35 | } 36 | if getBool != true { 37 | t.Fatalf("expected getBool=true but got getBool=%v", getBool) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/int.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- int Value 9 | type intValue int 10 | 11 | func newIntValue(val int, p *int) *intValue { 12 | *p = val 13 | return (*intValue)(p) 14 | } 15 | 16 | func (i *intValue) Set(s string) error { 17 | v, err := strconv.ParseInt(s, 0, 64) 18 | *i = intValue(v) 19 | return err 20 | } 21 | 22 | func (i *intValue) Type() string { 23 | return "int" 24 | } 25 | 26 | func (i *intValue) String() string { return fmt.Sprintf("%v", *i) } 27 | 28 | func intConv(sval string) (interface{}, error) { 29 | return strconv.Atoi(sval) 30 | } 31 | 32 | // GetInt return the int value of a flag with the given name 33 | func (f *FlagSet) GetInt(name string) (int, error) { 34 | val, err := f.getFlagType(name, "int", intConv) 35 | if err != nil { 36 | return 0, err 37 | } 38 | return val.(int), nil 39 | } 40 | 41 | // IntVar defines an int flag with specified name, default value, and usage string. 42 | // The argument p points to an int variable in which to store the value of the flag. 43 | func (f *FlagSet) IntVar(p *int, name string, value int, usage string) { 44 | f.VarP(newIntValue(value, p), name, "", usage) 45 | } 46 | 47 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash. 48 | func (f *FlagSet) IntVarP(p *int, name, shorthand string, value int, usage string) { 49 | f.VarP(newIntValue(value, p), name, shorthand, usage) 50 | } 51 | 52 | // IntVar defines an int flag with specified name, default value, and usage string. 53 | // The argument p points to an int variable in which to store the value of the flag. 54 | func IntVar(p *int, name string, value int, usage string) { 55 | CommandLine.VarP(newIntValue(value, p), name, "", usage) 56 | } 57 | 58 | // IntVarP is like IntVar, but accepts a shorthand letter that can be used after a single dash. 59 | func IntVarP(p *int, name, shorthand string, value int, usage string) { 60 | CommandLine.VarP(newIntValue(value, p), name, shorthand, usage) 61 | } 62 | 63 | // Int defines an int flag with specified name, default value, and usage string. 64 | // The return value is the address of an int variable that stores the value of the flag. 65 | func (f *FlagSet) Int(name string, value int, usage string) *int { 66 | p := new(int) 67 | f.IntVarP(p, name, "", value, usage) 68 | return p 69 | } 70 | 71 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash. 72 | func (f *FlagSet) IntP(name, shorthand string, value int, usage string) *int { 73 | p := new(int) 74 | f.IntVarP(p, name, shorthand, value, usage) 75 | return p 76 | } 77 | 78 | // Int defines an int flag with specified name, default value, and usage string. 79 | // The return value is the address of an int variable that stores the value of the flag. 80 | func Int(name string, value int, usage string) *int { 81 | return CommandLine.IntP(name, "", value, usage) 82 | } 83 | 84 | // IntP is like Int, but accepts a shorthand letter that can be used after a single dash. 85 | func IntP(name, shorthand string, value int, usage string) *int { 86 | return CommandLine.IntP(name, shorthand, value, usage) 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/int32.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- int32 Value 9 | type int32Value int32 10 | 11 | func newInt32Value(val int32, p *int32) *int32Value { 12 | *p = val 13 | return (*int32Value)(p) 14 | } 15 | 16 | func (i *int32Value) Set(s string) error { 17 | v, err := strconv.ParseInt(s, 0, 32) 18 | *i = int32Value(v) 19 | return err 20 | } 21 | 22 | func (i *int32Value) Type() string { 23 | return "int32" 24 | } 25 | 26 | func (i *int32Value) String() string { return fmt.Sprintf("%v", *i) } 27 | 28 | func int32Conv(sval string) (interface{}, error) { 29 | v, err := strconv.ParseInt(sval, 0, 32) 30 | if err != nil { 31 | return 0, err 32 | } 33 | return int32(v), nil 34 | } 35 | 36 | // GetInt32 return the int32 value of a flag with the given name 37 | func (f *FlagSet) GetInt32(name string) (int32, error) { 38 | val, err := f.getFlagType(name, "int32", int32Conv) 39 | if err != nil { 40 | return 0, err 41 | } 42 | return val.(int32), nil 43 | } 44 | 45 | // Int32Var defines an int32 flag with specified name, default value, and usage string. 46 | // The argument p points to an int32 variable in which to store the value of the flag. 47 | func (f *FlagSet) Int32Var(p *int32, name string, value int32, usage string) { 48 | f.VarP(newInt32Value(value, p), name, "", usage) 49 | } 50 | 51 | // Int32VarP is like Int32Var, but accepts a shorthand letter that can be used after a single dash. 52 | func (f *FlagSet) Int32VarP(p *int32, name, shorthand string, value int32, usage string) { 53 | f.VarP(newInt32Value(value, p), name, shorthand, usage) 54 | } 55 | 56 | // Int32Var defines an int32 flag with specified name, default value, and usage string. 57 | // The argument p points to an int32 variable in which to store the value of the flag. 58 | func Int32Var(p *int32, name string, value int32, usage string) { 59 | CommandLine.VarP(newInt32Value(value, p), name, "", usage) 60 | } 61 | 62 | // Int32VarP is like Int32Var, but accepts a shorthand letter that can be used after a single dash. 63 | func Int32VarP(p *int32, name, shorthand string, value int32, usage string) { 64 | CommandLine.VarP(newInt32Value(value, p), name, shorthand, usage) 65 | } 66 | 67 | // Int32 defines an int32 flag with specified name, default value, and usage string. 68 | // The return value is the address of an int32 variable that stores the value of the flag. 69 | func (f *FlagSet) Int32(name string, value int32, usage string) *int32 { 70 | p := new(int32) 71 | f.Int32VarP(p, name, "", value, usage) 72 | return p 73 | } 74 | 75 | // Int32P is like Int32, but accepts a shorthand letter that can be used after a single dash. 76 | func (f *FlagSet) Int32P(name, shorthand string, value int32, usage string) *int32 { 77 | p := new(int32) 78 | f.Int32VarP(p, name, shorthand, value, usage) 79 | return p 80 | } 81 | 82 | // Int32 defines an int32 flag with specified name, default value, and usage string. 83 | // The return value is the address of an int32 variable that stores the value of the flag. 84 | func Int32(name string, value int32, usage string) *int32 { 85 | return CommandLine.Int32P(name, "", value, usage) 86 | } 87 | 88 | // Int32P is like Int32, but accepts a shorthand letter that can be used after a single dash. 89 | func Int32P(name, shorthand string, value int32, usage string) *int32 { 90 | return CommandLine.Int32P(name, shorthand, value, usage) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/int64.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- int64 Value 9 | type int64Value int64 10 | 11 | func newInt64Value(val int64, p *int64) *int64Value { 12 | *p = val 13 | return (*int64Value)(p) 14 | } 15 | 16 | func (i *int64Value) Set(s string) error { 17 | v, err := strconv.ParseInt(s, 0, 64) 18 | *i = int64Value(v) 19 | return err 20 | } 21 | 22 | func (i *int64Value) Type() string { 23 | return "int64" 24 | } 25 | 26 | func (i *int64Value) String() string { return fmt.Sprintf("%v", *i) } 27 | 28 | func int64Conv(sval string) (interface{}, error) { 29 | return strconv.ParseInt(sval, 0, 64) 30 | } 31 | 32 | // GetInt64 return the int64 value of a flag with the given name 33 | func (f *FlagSet) GetInt64(name string) (int64, error) { 34 | val, err := f.getFlagType(name, "int64", int64Conv) 35 | if err != nil { 36 | return 0, err 37 | } 38 | return val.(int64), nil 39 | } 40 | 41 | // Int64Var defines an int64 flag with specified name, default value, and usage string. 42 | // The argument p points to an int64 variable in which to store the value of the flag. 43 | func (f *FlagSet) Int64Var(p *int64, name string, value int64, usage string) { 44 | f.VarP(newInt64Value(value, p), name, "", usage) 45 | } 46 | 47 | // Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash. 48 | func (f *FlagSet) Int64VarP(p *int64, name, shorthand string, value int64, usage string) { 49 | f.VarP(newInt64Value(value, p), name, shorthand, usage) 50 | } 51 | 52 | // Int64Var defines an int64 flag with specified name, default value, and usage string. 53 | // The argument p points to an int64 variable in which to store the value of the flag. 54 | func Int64Var(p *int64, name string, value int64, usage string) { 55 | CommandLine.VarP(newInt64Value(value, p), name, "", usage) 56 | } 57 | 58 | // Int64VarP is like Int64Var, but accepts a shorthand letter that can be used after a single dash. 59 | func Int64VarP(p *int64, name, shorthand string, value int64, usage string) { 60 | CommandLine.VarP(newInt64Value(value, p), name, shorthand, usage) 61 | } 62 | 63 | // Int64 defines an int64 flag with specified name, default value, and usage string. 64 | // The return value is the address of an int64 variable that stores the value of the flag. 65 | func (f *FlagSet) Int64(name string, value int64, usage string) *int64 { 66 | p := new(int64) 67 | f.Int64VarP(p, name, "", value, usage) 68 | return p 69 | } 70 | 71 | // Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash. 72 | func (f *FlagSet) Int64P(name, shorthand string, value int64, usage string) *int64 { 73 | p := new(int64) 74 | f.Int64VarP(p, name, shorthand, value, usage) 75 | return p 76 | } 77 | 78 | // Int64 defines an int64 flag with specified name, default value, and usage string. 79 | // The return value is the address of an int64 variable that stores the value of the flag. 80 | func Int64(name string, value int64, usage string) *int64 { 81 | return CommandLine.Int64P(name, "", value, usage) 82 | } 83 | 84 | // Int64P is like Int64, but accepts a shorthand letter that can be used after a single dash. 85 | func Int64P(name, shorthand string, value int64, usage string) *int64 { 86 | return CommandLine.Int64P(name, shorthand, value, usage) 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/int8.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- int8 Value 9 | type int8Value int8 10 | 11 | func newInt8Value(val int8, p *int8) *int8Value { 12 | *p = val 13 | return (*int8Value)(p) 14 | } 15 | 16 | func (i *int8Value) Set(s string) error { 17 | v, err := strconv.ParseInt(s, 0, 8) 18 | *i = int8Value(v) 19 | return err 20 | } 21 | 22 | func (i *int8Value) Type() string { 23 | return "int8" 24 | } 25 | 26 | func (i *int8Value) String() string { return fmt.Sprintf("%v", *i) } 27 | 28 | func int8Conv(sval string) (interface{}, error) { 29 | v, err := strconv.ParseInt(sval, 0, 8) 30 | if err != nil { 31 | return 0, err 32 | } 33 | return int8(v), nil 34 | } 35 | 36 | // GetInt8 return the int8 value of a flag with the given name 37 | func (f *FlagSet) GetInt8(name string) (int8, error) { 38 | val, err := f.getFlagType(name, "int8", int8Conv) 39 | if err != nil { 40 | return 0, err 41 | } 42 | return val.(int8), nil 43 | } 44 | 45 | // Int8Var defines an int8 flag with specified name, default value, and usage string. 46 | // The argument p points to an int8 variable in which to store the value of the flag. 47 | func (f *FlagSet) Int8Var(p *int8, name string, value int8, usage string) { 48 | f.VarP(newInt8Value(value, p), name, "", usage) 49 | } 50 | 51 | // Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash. 52 | func (f *FlagSet) Int8VarP(p *int8, name, shorthand string, value int8, usage string) { 53 | f.VarP(newInt8Value(value, p), name, shorthand, usage) 54 | } 55 | 56 | // Int8Var defines an int8 flag with specified name, default value, and usage string. 57 | // The argument p points to an int8 variable in which to store the value of the flag. 58 | func Int8Var(p *int8, name string, value int8, usage string) { 59 | CommandLine.VarP(newInt8Value(value, p), name, "", usage) 60 | } 61 | 62 | // Int8VarP is like Int8Var, but accepts a shorthand letter that can be used after a single dash. 63 | func Int8VarP(p *int8, name, shorthand string, value int8, usage string) { 64 | CommandLine.VarP(newInt8Value(value, p), name, shorthand, usage) 65 | } 66 | 67 | // Int8 defines an int8 flag with specified name, default value, and usage string. 68 | // The return value is the address of an int8 variable that stores the value of the flag. 69 | func (f *FlagSet) Int8(name string, value int8, usage string) *int8 { 70 | p := new(int8) 71 | f.Int8VarP(p, name, "", value, usage) 72 | return p 73 | } 74 | 75 | // Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash. 76 | func (f *FlagSet) Int8P(name, shorthand string, value int8, usage string) *int8 { 77 | p := new(int8) 78 | f.Int8VarP(p, name, shorthand, value, usage) 79 | return p 80 | } 81 | 82 | // Int8 defines an int8 flag with specified name, default value, and usage string. 83 | // The return value is the address of an int8 variable that stores the value of the flag. 84 | func Int8(name string, value int8, usage string) *int8 { 85 | return CommandLine.Int8P(name, "", value, usage) 86 | } 87 | 88 | // Int8P is like Int8, but accepts a shorthand letter that can be used after a single dash. 89 | func Int8P(name, shorthand string, value int8, usage string) *int8 { 90 | return CommandLine.Int8P(name, shorthand, value, usage) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/ip.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "strings" 7 | ) 8 | 9 | var _ = strings.TrimSpace 10 | 11 | // -- net.IP value 12 | type ipValue net.IP 13 | 14 | func newIPValue(val net.IP, p *net.IP) *ipValue { 15 | *p = val 16 | return (*ipValue)(p) 17 | } 18 | 19 | func (i *ipValue) String() string { return net.IP(*i).String() } 20 | func (i *ipValue) Set(s string) error { 21 | ip := net.ParseIP(strings.TrimSpace(s)) 22 | if ip == nil { 23 | return fmt.Errorf("failed to parse IP: %q", s) 24 | } 25 | *i = ipValue(ip) 26 | return nil 27 | } 28 | 29 | func (i *ipValue) Type() string { 30 | return "ip" 31 | } 32 | 33 | func ipConv(sval string) (interface{}, error) { 34 | ip := net.ParseIP(sval) 35 | if ip != nil { 36 | return ip, nil 37 | } 38 | return nil, fmt.Errorf("invalid string being converted to IP address: %s", sval) 39 | } 40 | 41 | // GetIP return the net.IP value of a flag with the given name 42 | func (f *FlagSet) GetIP(name string) (net.IP, error) { 43 | val, err := f.getFlagType(name, "ip", ipConv) 44 | if err != nil { 45 | return nil, err 46 | } 47 | return val.(net.IP), nil 48 | } 49 | 50 | // IPVar defines an net.IP flag with specified name, default value, and usage string. 51 | // The argument p points to an net.IP variable in which to store the value of the flag. 52 | func (f *FlagSet) IPVar(p *net.IP, name string, value net.IP, usage string) { 53 | f.VarP(newIPValue(value, p), name, "", usage) 54 | } 55 | 56 | // IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash. 57 | func (f *FlagSet) IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) { 58 | f.VarP(newIPValue(value, p), name, shorthand, usage) 59 | } 60 | 61 | // IPVar defines an net.IP flag with specified name, default value, and usage string. 62 | // The argument p points to an net.IP variable in which to store the value of the flag. 63 | func IPVar(p *net.IP, name string, value net.IP, usage string) { 64 | CommandLine.VarP(newIPValue(value, p), name, "", usage) 65 | } 66 | 67 | // IPVarP is like IPVar, but accepts a shorthand letter that can be used after a single dash. 68 | func IPVarP(p *net.IP, name, shorthand string, value net.IP, usage string) { 69 | CommandLine.VarP(newIPValue(value, p), name, shorthand, usage) 70 | } 71 | 72 | // IP defines an net.IP flag with specified name, default value, and usage string. 73 | // The return value is the address of an net.IP variable that stores the value of the flag. 74 | func (f *FlagSet) IP(name string, value net.IP, usage string) *net.IP { 75 | p := new(net.IP) 76 | f.IPVarP(p, name, "", value, usage) 77 | return p 78 | } 79 | 80 | // IPP is like IP, but accepts a shorthand letter that can be used after a single dash. 81 | func (f *FlagSet) IPP(name, shorthand string, value net.IP, usage string) *net.IP { 82 | p := new(net.IP) 83 | f.IPVarP(p, name, shorthand, value, usage) 84 | return p 85 | } 86 | 87 | // IP defines an net.IP flag with specified name, default value, and usage string. 88 | // The return value is the address of an net.IP variable that stores the value of the flag. 89 | func IP(name string, value net.IP, usage string) *net.IP { 90 | return CommandLine.IPP(name, "", value, usage) 91 | } 92 | 93 | // IPP is like IP, but accepts a shorthand letter that can be used after a single dash. 94 | func IPP(name, shorthand string, value net.IP, usage string) *net.IP { 95 | return CommandLine.IPP(name, shorthand, value, usage) 96 | } 97 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/ip_test.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "os" 7 | "testing" 8 | ) 9 | 10 | func setUpIP(ip *net.IP) *FlagSet { 11 | f := NewFlagSet("test", ContinueOnError) 12 | f.IPVar(ip, "address", net.ParseIP("0.0.0.0"), "IP Address") 13 | return f 14 | } 15 | 16 | func TestIP(t *testing.T) { 17 | testCases := []struct { 18 | input string 19 | success bool 20 | expected string 21 | }{ 22 | {"0.0.0.0", true, "0.0.0.0"}, 23 | {" 0.0.0.0 ", true, "0.0.0.0"}, 24 | {"1.2.3.4", true, "1.2.3.4"}, 25 | {"127.0.0.1", true, "127.0.0.1"}, 26 | {"255.255.255.255", true, "255.255.255.255"}, 27 | {"", false, ""}, 28 | {"0", false, ""}, 29 | {"localhost", false, ""}, 30 | {"0.0.0", false, ""}, 31 | {"0.0.0.", false, ""}, 32 | {"0.0.0.0.", false, ""}, 33 | {"0.0.0.256", false, ""}, 34 | {"0 . 0 . 0 . 0", false, ""}, 35 | } 36 | 37 | devnull, _ := os.Open(os.DevNull) 38 | os.Stderr = devnull 39 | for i := range testCases { 40 | var addr net.IP 41 | f := setUpIP(&addr) 42 | 43 | tc := &testCases[i] 44 | 45 | arg := fmt.Sprintf("--address=%s", tc.input) 46 | err := f.Parse([]string{arg}) 47 | if err != nil && tc.success == true { 48 | t.Errorf("expected success, got %q", err) 49 | continue 50 | } else if err == nil && tc.success == false { 51 | t.Errorf("expected failure") 52 | continue 53 | } else if tc.success { 54 | ip, err := f.GetIP("address") 55 | if err != nil { 56 | t.Errorf("Got error trying to fetch the IP flag: %v", err) 57 | } 58 | if ip.String() != tc.expected { 59 | t.Errorf("expected %q, got %q", tc.expected, ip.String()) 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/ipnet_test.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "os" 7 | "testing" 8 | ) 9 | 10 | func setUpIPNet(ip *net.IPNet) *FlagSet { 11 | f := NewFlagSet("test", ContinueOnError) 12 | _, def, _ := net.ParseCIDR("0.0.0.0/0") 13 | f.IPNetVar(ip, "address", *def, "IP Address") 14 | return f 15 | } 16 | 17 | func TestIPNet(t *testing.T) { 18 | testCases := []struct { 19 | input string 20 | success bool 21 | expected string 22 | }{ 23 | {"0.0.0.0/0", true, "0.0.0.0/0"}, 24 | {" 0.0.0.0/0 ", true, "0.0.0.0/0"}, 25 | {"1.2.3.4/8", true, "1.0.0.0/8"}, 26 | {"127.0.0.1/16", true, "127.0.0.0/16"}, 27 | {"255.255.255.255/19", true, "255.255.224.0/19"}, 28 | {"255.255.255.255/32", true, "255.255.255.255/32"}, 29 | {"", false, ""}, 30 | {"/0", false, ""}, 31 | {"0", false, ""}, 32 | {"0/0", false, ""}, 33 | {"localhost/0", false, ""}, 34 | {"0.0.0/4", false, ""}, 35 | {"0.0.0./8", false, ""}, 36 | {"0.0.0.0./12", false, ""}, 37 | {"0.0.0.256/16", false, ""}, 38 | {"0.0.0.0 /20", false, ""}, 39 | {"0.0.0.0/ 24", false, ""}, 40 | {"0 . 0 . 0 . 0 / 28", false, ""}, 41 | {"0.0.0.0/33", false, ""}, 42 | } 43 | 44 | devnull, _ := os.Open(os.DevNull) 45 | os.Stderr = devnull 46 | for i := range testCases { 47 | var addr net.IPNet 48 | f := setUpIPNet(&addr) 49 | 50 | tc := &testCases[i] 51 | 52 | arg := fmt.Sprintf("--address=%s", tc.input) 53 | err := f.Parse([]string{arg}) 54 | if err != nil && tc.success == true { 55 | t.Errorf("expected success, got %q", err) 56 | continue 57 | } else if err == nil && tc.success == false { 58 | t.Errorf("expected failure") 59 | continue 60 | } else if tc.success { 61 | ip, err := f.GetIPNet("address") 62 | if err != nil { 63 | t.Errorf("Got error trying to fetch the IP flag: %v", err) 64 | } 65 | if ip.String() != tc.expected { 66 | t.Errorf("expected %q, got %q", tc.expected, ip.String()) 67 | } 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/string.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import "fmt" 4 | 5 | // -- string Value 6 | type stringValue string 7 | 8 | func newStringValue(val string, p *string) *stringValue { 9 | *p = val 10 | return (*stringValue)(p) 11 | } 12 | 13 | func (s *stringValue) Set(val string) error { 14 | *s = stringValue(val) 15 | return nil 16 | } 17 | func (s *stringValue) Type() string { 18 | return "string" 19 | } 20 | 21 | func (s *stringValue) String() string { return fmt.Sprintf("%s", *s) } 22 | 23 | func stringConv(sval string) (interface{}, error) { 24 | return sval, nil 25 | } 26 | 27 | // GetString return the string value of a flag with the given name 28 | func (f *FlagSet) GetString(name string) (string, error) { 29 | val, err := f.getFlagType(name, "string", stringConv) 30 | if err != nil { 31 | return "", err 32 | } 33 | return val.(string), nil 34 | } 35 | 36 | // StringVar defines a string flag with specified name, default value, and usage string. 37 | // The argument p points to a string variable in which to store the value of the flag. 38 | func (f *FlagSet) StringVar(p *string, name string, value string, usage string) { 39 | f.VarP(newStringValue(value, p), name, "", usage) 40 | } 41 | 42 | // StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash. 43 | func (f *FlagSet) StringVarP(p *string, name, shorthand string, value string, usage string) { 44 | f.VarP(newStringValue(value, p), name, shorthand, usage) 45 | } 46 | 47 | // StringVar defines a string flag with specified name, default value, and usage string. 48 | // The argument p points to a string variable in which to store the value of the flag. 49 | func StringVar(p *string, name string, value string, usage string) { 50 | CommandLine.VarP(newStringValue(value, p), name, "", usage) 51 | } 52 | 53 | // StringVarP is like StringVar, but accepts a shorthand letter that can be used after a single dash. 54 | func StringVarP(p *string, name, shorthand string, value string, usage string) { 55 | CommandLine.VarP(newStringValue(value, p), name, shorthand, usage) 56 | } 57 | 58 | // String defines a string flag with specified name, default value, and usage string. 59 | // The return value is the address of a string variable that stores the value of the flag. 60 | func (f *FlagSet) String(name string, value string, usage string) *string { 61 | p := new(string) 62 | f.StringVarP(p, name, "", value, usage) 63 | return p 64 | } 65 | 66 | // StringP is like String, but accepts a shorthand letter that can be used after a single dash. 67 | func (f *FlagSet) StringP(name, shorthand string, value string, usage string) *string { 68 | p := new(string) 69 | f.StringVarP(p, name, shorthand, value, usage) 70 | return p 71 | } 72 | 73 | // String defines a string flag with specified name, default value, and usage string. 74 | // The return value is the address of a string variable that stores the value of the flag. 75 | func String(name string, value string, usage string) *string { 76 | return CommandLine.StringP(name, "", value, usage) 77 | } 78 | 79 | // StringP is like String, but accepts a shorthand letter that can be used after a single dash. 80 | func StringP(name, shorthand string, value string, usage string) *string { 81 | return CommandLine.StringP(name, shorthand, value, usage) 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/uint.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- uint Value 9 | type uintValue uint 10 | 11 | func newUintValue(val uint, p *uint) *uintValue { 12 | *p = val 13 | return (*uintValue)(p) 14 | } 15 | 16 | func (i *uintValue) Set(s string) error { 17 | v, err := strconv.ParseUint(s, 0, 64) 18 | *i = uintValue(v) 19 | return err 20 | } 21 | 22 | func (i *uintValue) Type() string { 23 | return "uint" 24 | } 25 | 26 | func (i *uintValue) String() string { return fmt.Sprintf("%v", *i) } 27 | 28 | func uintConv(sval string) (interface{}, error) { 29 | v, err := strconv.ParseUint(sval, 0, 0) 30 | if err != nil { 31 | return 0, err 32 | } 33 | return uint(v), nil 34 | } 35 | 36 | // GetUint return the uint value of a flag with the given name 37 | func (f *FlagSet) GetUint(name string) (uint, error) { 38 | val, err := f.getFlagType(name, "uint", uintConv) 39 | if err != nil { 40 | return 0, err 41 | } 42 | return val.(uint), nil 43 | } 44 | 45 | // UintVar defines a uint flag with specified name, default value, and usage string. 46 | // The argument p points to a uint variable in which to store the value of the flag. 47 | func (f *FlagSet) UintVar(p *uint, name string, value uint, usage string) { 48 | f.VarP(newUintValue(value, p), name, "", usage) 49 | } 50 | 51 | // UintVarP is like UintVar, but accepts a shorthand letter that can be used after a single dash. 52 | func (f *FlagSet) UintVarP(p *uint, name, shorthand string, value uint, usage string) { 53 | f.VarP(newUintValue(value, p), name, shorthand, usage) 54 | } 55 | 56 | // UintVar defines a uint flag with specified name, default value, and usage string. 57 | // The argument p points to a uint variable in which to store the value of the flag. 58 | func UintVar(p *uint, name string, value uint, usage string) { 59 | CommandLine.VarP(newUintValue(value, p), name, "", usage) 60 | } 61 | 62 | // UintVarP is like UintVar, but accepts a shorthand letter that can be used after a single dash. 63 | func UintVarP(p *uint, name, shorthand string, value uint, usage string) { 64 | CommandLine.VarP(newUintValue(value, p), name, shorthand, usage) 65 | } 66 | 67 | // Uint defines a uint flag with specified name, default value, and usage string. 68 | // The return value is the address of a uint variable that stores the value of the flag. 69 | func (f *FlagSet) Uint(name string, value uint, usage string) *uint { 70 | p := new(uint) 71 | f.UintVarP(p, name, "", value, usage) 72 | return p 73 | } 74 | 75 | // UintP is like Uint, but accepts a shorthand letter that can be used after a single dash. 76 | func (f *FlagSet) UintP(name, shorthand string, value uint, usage string) *uint { 77 | p := new(uint) 78 | f.UintVarP(p, name, shorthand, value, usage) 79 | return p 80 | } 81 | 82 | // Uint defines a uint flag with specified name, default value, and usage string. 83 | // The return value is the address of a uint variable that stores the value of the flag. 84 | func Uint(name string, value uint, usage string) *uint { 85 | return CommandLine.UintP(name, "", value, usage) 86 | } 87 | 88 | // UintP is like Uint, but accepts a shorthand letter that can be used after a single dash. 89 | func UintP(name, shorthand string, value uint, usage string) *uint { 90 | return CommandLine.UintP(name, shorthand, value, usage) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/uint16.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- uint16 value 9 | type uint16Value uint16 10 | 11 | func newUint16Value(val uint16, p *uint16) *uint16Value { 12 | *p = val 13 | return (*uint16Value)(p) 14 | } 15 | func (i *uint16Value) String() string { return fmt.Sprintf("%d", *i) } 16 | func (i *uint16Value) Set(s string) error { 17 | v, err := strconv.ParseUint(s, 0, 16) 18 | *i = uint16Value(v) 19 | return err 20 | } 21 | 22 | func (i *uint16Value) Type() string { 23 | return "uint16" 24 | } 25 | 26 | func uint16Conv(sval string) (interface{}, error) { 27 | v, err := strconv.ParseUint(sval, 0, 16) 28 | if err != nil { 29 | return 0, err 30 | } 31 | return uint16(v), nil 32 | } 33 | 34 | // GetUint16 return the uint16 value of a flag with the given name 35 | func (f *FlagSet) GetUint16(name string) (uint16, error) { 36 | val, err := f.getFlagType(name, "uint16", uint16Conv) 37 | if err != nil { 38 | return 0, err 39 | } 40 | return val.(uint16), nil 41 | } 42 | 43 | // Uint16Var defines a uint flag with specified name, default value, and usage string. 44 | // The argument p points to a uint variable in which to store the value of the flag. 45 | func (f *FlagSet) Uint16Var(p *uint16, name string, value uint16, usage string) { 46 | f.VarP(newUint16Value(value, p), name, "", usage) 47 | } 48 | 49 | // Uint16VarP is like Uint16Var, but accepts a shorthand letter that can be used after a single dash. 50 | func (f *FlagSet) Uint16VarP(p *uint16, name, shorthand string, value uint16, usage string) { 51 | f.VarP(newUint16Value(value, p), name, shorthand, usage) 52 | } 53 | 54 | // Uint16Var defines a uint flag with specified name, default value, and usage string. 55 | // The argument p points to a uint variable in which to store the value of the flag. 56 | func Uint16Var(p *uint16, name string, value uint16, usage string) { 57 | CommandLine.VarP(newUint16Value(value, p), name, "", usage) 58 | } 59 | 60 | // Uint16VarP is like Uint16Var, but accepts a shorthand letter that can be used after a single dash. 61 | func Uint16VarP(p *uint16, name, shorthand string, value uint16, usage string) { 62 | CommandLine.VarP(newUint16Value(value, p), name, shorthand, usage) 63 | } 64 | 65 | // Uint16 defines a uint flag with specified name, default value, and usage string. 66 | // The return value is the address of a uint variable that stores the value of the flag. 67 | func (f *FlagSet) Uint16(name string, value uint16, usage string) *uint16 { 68 | p := new(uint16) 69 | f.Uint16VarP(p, name, "", value, usage) 70 | return p 71 | } 72 | 73 | // Uint16P is like Uint16, but accepts a shorthand letter that can be used after a single dash. 74 | func (f *FlagSet) Uint16P(name, shorthand string, value uint16, usage string) *uint16 { 75 | p := new(uint16) 76 | f.Uint16VarP(p, name, shorthand, value, usage) 77 | return p 78 | } 79 | 80 | // Uint16 defines a uint flag with specified name, default value, and usage string. 81 | // The return value is the address of a uint variable that stores the value of the flag. 82 | func Uint16(name string, value uint16, usage string) *uint16 { 83 | return CommandLine.Uint16P(name, "", value, usage) 84 | } 85 | 86 | // Uint16P is like Uint16, but accepts a shorthand letter that can be used after a single dash. 87 | func Uint16P(name, shorthand string, value uint16, usage string) *uint16 { 88 | return CommandLine.Uint16P(name, shorthand, value, usage) 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/uint32.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- uint16 value 9 | type uint32Value uint32 10 | 11 | func newUint32Value(val uint32, p *uint32) *uint32Value { 12 | *p = val 13 | return (*uint32Value)(p) 14 | } 15 | func (i *uint32Value) String() string { return fmt.Sprintf("%d", *i) } 16 | func (i *uint32Value) Set(s string) error { 17 | v, err := strconv.ParseUint(s, 0, 32) 18 | *i = uint32Value(v) 19 | return err 20 | } 21 | 22 | func (i *uint32Value) Type() string { 23 | return "uint32" 24 | } 25 | 26 | func uint32Conv(sval string) (interface{}, error) { 27 | v, err := strconv.ParseUint(sval, 0, 32) 28 | if err != nil { 29 | return 0, err 30 | } 31 | return uint32(v), nil 32 | } 33 | 34 | // GetUint32 return the uint32 value of a flag with the given name 35 | func (f *FlagSet) GetUint32(name string) (uint32, error) { 36 | val, err := f.getFlagType(name, "uint32", uint32Conv) 37 | if err != nil { 38 | return 0, err 39 | } 40 | return val.(uint32), nil 41 | } 42 | 43 | // Uint32Var defines a uint32 flag with specified name, default value, and usage string. 44 | // The argument p points to a uint32 variable in which to store the value of the flag. 45 | func (f *FlagSet) Uint32Var(p *uint32, name string, value uint32, usage string) { 46 | f.VarP(newUint32Value(value, p), name, "", usage) 47 | } 48 | 49 | // Uint32VarP is like Uint32Var, but accepts a shorthand letter that can be used after a single dash. 50 | func (f *FlagSet) Uint32VarP(p *uint32, name, shorthand string, value uint32, usage string) { 51 | f.VarP(newUint32Value(value, p), name, shorthand, usage) 52 | } 53 | 54 | // Uint32Var defines a uint32 flag with specified name, default value, and usage string. 55 | // The argument p points to a uint32 variable in which to store the value of the flag. 56 | func Uint32Var(p *uint32, name string, value uint32, usage string) { 57 | CommandLine.VarP(newUint32Value(value, p), name, "", usage) 58 | } 59 | 60 | // Uint32VarP is like Uint32Var, but accepts a shorthand letter that can be used after a single dash. 61 | func Uint32VarP(p *uint32, name, shorthand string, value uint32, usage string) { 62 | CommandLine.VarP(newUint32Value(value, p), name, shorthand, usage) 63 | } 64 | 65 | // Uint32 defines a uint32 flag with specified name, default value, and usage string. 66 | // The return value is the address of a uint32 variable that stores the value of the flag. 67 | func (f *FlagSet) Uint32(name string, value uint32, usage string) *uint32 { 68 | p := new(uint32) 69 | f.Uint32VarP(p, name, "", value, usage) 70 | return p 71 | } 72 | 73 | // Uint32P is like Uint32, but accepts a shorthand letter that can be used after a single dash. 74 | func (f *FlagSet) Uint32P(name, shorthand string, value uint32, usage string) *uint32 { 75 | p := new(uint32) 76 | f.Uint32VarP(p, name, shorthand, value, usage) 77 | return p 78 | } 79 | 80 | // Uint32 defines a uint32 flag with specified name, default value, and usage string. 81 | // The return value is the address of a uint32 variable that stores the value of the flag. 82 | func Uint32(name string, value uint32, usage string) *uint32 { 83 | return CommandLine.Uint32P(name, "", value, usage) 84 | } 85 | 86 | // Uint32P is like Uint32, but accepts a shorthand letter that can be used after a single dash. 87 | func Uint32P(name, shorthand string, value uint32, usage string) *uint32 { 88 | return CommandLine.Uint32P(name, shorthand, value, usage) 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/uint64.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- uint64 Value 9 | type uint64Value uint64 10 | 11 | func newUint64Value(val uint64, p *uint64) *uint64Value { 12 | *p = val 13 | return (*uint64Value)(p) 14 | } 15 | 16 | func (i *uint64Value) Set(s string) error { 17 | v, err := strconv.ParseUint(s, 0, 64) 18 | *i = uint64Value(v) 19 | return err 20 | } 21 | 22 | func (i *uint64Value) Type() string { 23 | return "uint64" 24 | } 25 | 26 | func (i *uint64Value) String() string { return fmt.Sprintf("%v", *i) } 27 | 28 | func uint64Conv(sval string) (interface{}, error) { 29 | v, err := strconv.ParseUint(sval, 0, 64) 30 | if err != nil { 31 | return 0, err 32 | } 33 | return uint64(v), nil 34 | } 35 | 36 | // GetUint64 return the uint64 value of a flag with the given name 37 | func (f *FlagSet) GetUint64(name string) (uint64, error) { 38 | val, err := f.getFlagType(name, "uint64", uint64Conv) 39 | if err != nil { 40 | return 0, err 41 | } 42 | return val.(uint64), nil 43 | } 44 | 45 | // Uint64Var defines a uint64 flag with specified name, default value, and usage string. 46 | // The argument p points to a uint64 variable in which to store the value of the flag. 47 | func (f *FlagSet) Uint64Var(p *uint64, name string, value uint64, usage string) { 48 | f.VarP(newUint64Value(value, p), name, "", usage) 49 | } 50 | 51 | // Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash. 52 | func (f *FlagSet) Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) { 53 | f.VarP(newUint64Value(value, p), name, shorthand, usage) 54 | } 55 | 56 | // Uint64Var defines a uint64 flag with specified name, default value, and usage string. 57 | // The argument p points to a uint64 variable in which to store the value of the flag. 58 | func Uint64Var(p *uint64, name string, value uint64, usage string) { 59 | CommandLine.VarP(newUint64Value(value, p), name, "", usage) 60 | } 61 | 62 | // Uint64VarP is like Uint64Var, but accepts a shorthand letter that can be used after a single dash. 63 | func Uint64VarP(p *uint64, name, shorthand string, value uint64, usage string) { 64 | CommandLine.VarP(newUint64Value(value, p), name, shorthand, usage) 65 | } 66 | 67 | // Uint64 defines a uint64 flag with specified name, default value, and usage string. 68 | // The return value is the address of a uint64 variable that stores the value of the flag. 69 | func (f *FlagSet) Uint64(name string, value uint64, usage string) *uint64 { 70 | p := new(uint64) 71 | f.Uint64VarP(p, name, "", value, usage) 72 | return p 73 | } 74 | 75 | // Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash. 76 | func (f *FlagSet) Uint64P(name, shorthand string, value uint64, usage string) *uint64 { 77 | p := new(uint64) 78 | f.Uint64VarP(p, name, shorthand, value, usage) 79 | return p 80 | } 81 | 82 | // Uint64 defines a uint64 flag with specified name, default value, and usage string. 83 | // The return value is the address of a uint64 variable that stores the value of the flag. 84 | func Uint64(name string, value uint64, usage string) *uint64 { 85 | return CommandLine.Uint64P(name, "", value, usage) 86 | } 87 | 88 | // Uint64P is like Uint64, but accepts a shorthand letter that can be used after a single dash. 89 | func Uint64P(name, shorthand string, value uint64, usage string) *uint64 { 90 | return CommandLine.Uint64P(name, shorthand, value, usage) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/uint8.go: -------------------------------------------------------------------------------- 1 | package pflag 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // -- uint8 Value 9 | type uint8Value uint8 10 | 11 | func newUint8Value(val uint8, p *uint8) *uint8Value { 12 | *p = val 13 | return (*uint8Value)(p) 14 | } 15 | 16 | func (i *uint8Value) Set(s string) error { 17 | v, err := strconv.ParseUint(s, 0, 8) 18 | *i = uint8Value(v) 19 | return err 20 | } 21 | 22 | func (i *uint8Value) Type() string { 23 | return "uint8" 24 | } 25 | 26 | func (i *uint8Value) String() string { return fmt.Sprintf("%v", *i) } 27 | 28 | func uint8Conv(sval string) (interface{}, error) { 29 | v, err := strconv.ParseUint(sval, 0, 8) 30 | if err != nil { 31 | return 0, err 32 | } 33 | return uint8(v), nil 34 | } 35 | 36 | // GetUint8 return the uint8 value of a flag with the given name 37 | func (f *FlagSet) GetUint8(name string) (uint8, error) { 38 | val, err := f.getFlagType(name, "uint8", uint8Conv) 39 | if err != nil { 40 | return 0, err 41 | } 42 | return val.(uint8), nil 43 | } 44 | 45 | // Uint8Var defines a uint8 flag with specified name, default value, and usage string. 46 | // The argument p points to a uint8 variable in which to store the value of the flag. 47 | func (f *FlagSet) Uint8Var(p *uint8, name string, value uint8, usage string) { 48 | f.VarP(newUint8Value(value, p), name, "", usage) 49 | } 50 | 51 | // Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash. 52 | func (f *FlagSet) Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) { 53 | f.VarP(newUint8Value(value, p), name, shorthand, usage) 54 | } 55 | 56 | // Uint8Var defines a uint8 flag with specified name, default value, and usage string. 57 | // The argument p points to a uint8 variable in which to store the value of the flag. 58 | func Uint8Var(p *uint8, name string, value uint8, usage string) { 59 | CommandLine.VarP(newUint8Value(value, p), name, "", usage) 60 | } 61 | 62 | // Uint8VarP is like Uint8Var, but accepts a shorthand letter that can be used after a single dash. 63 | func Uint8VarP(p *uint8, name, shorthand string, value uint8, usage string) { 64 | CommandLine.VarP(newUint8Value(value, p), name, shorthand, usage) 65 | } 66 | 67 | // Uint8 defines a uint8 flag with specified name, default value, and usage string. 68 | // The return value is the address of a uint8 variable that stores the value of the flag. 69 | func (f *FlagSet) Uint8(name string, value uint8, usage string) *uint8 { 70 | p := new(uint8) 71 | f.Uint8VarP(p, name, "", value, usage) 72 | return p 73 | } 74 | 75 | // Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash. 76 | func (f *FlagSet) Uint8P(name, shorthand string, value uint8, usage string) *uint8 { 77 | p := new(uint8) 78 | f.Uint8VarP(p, name, shorthand, value, usage) 79 | return p 80 | } 81 | 82 | // Uint8 defines a uint8 flag with specified name, default value, and usage string. 83 | // The return value is the address of a uint8 variable that stores the value of the flag. 84 | func Uint8(name string, value uint8, usage string) *uint8 { 85 | return CommandLine.Uint8P(name, "", value, usage) 86 | } 87 | 88 | // Uint8P is like Uint8, but accepts a shorthand letter that can be used after a single dash. 89 | func Uint8P(name, shorthand string, value uint8, usage string) *uint8 { 90 | return CommandLine.Uint8P(name, shorthand, value, usage) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/verify/all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | set -o pipefail 6 | 7 | ROOT=$(dirname "${BASH_SOURCE}")/.. 8 | 9 | # Some useful colors. 10 | if [[ -z "${color_start-}" ]]; then 11 | declare -r color_start="\033[" 12 | declare -r color_red="${color_start}0;31m" 13 | declare -r color_yellow="${color_start}0;33m" 14 | declare -r color_green="${color_start}0;32m" 15 | declare -r color_norm="${color_start}0m" 16 | fi 17 | 18 | SILENT=true 19 | 20 | function is-excluded { 21 | for e in $EXCLUDE; do 22 | if [[ $1 -ef ${BASH_SOURCE} ]]; then 23 | return 24 | fi 25 | if [[ $1 -ef "$ROOT/hack/$e" ]]; then 26 | return 27 | fi 28 | done 29 | return 1 30 | } 31 | 32 | while getopts ":v" opt; do 33 | case $opt in 34 | v) 35 | SILENT=false 36 | ;; 37 | \?) 38 | echo "Invalid flag: -$OPTARG" >&2 39 | exit 1 40 | ;; 41 | esac 42 | done 43 | 44 | if $SILENT ; then 45 | echo "Running in the silent mode, run with -v if you want to see script logs." 46 | fi 47 | 48 | EXCLUDE="all.sh" 49 | 50 | ret=0 51 | for t in `ls $ROOT/verify/*.sh` 52 | do 53 | if is-excluded $t ; then 54 | echo "Skipping $t" 55 | continue 56 | fi 57 | if $SILENT ; then 58 | echo -e "Verifying $t" 59 | if bash "$t" &> /dev/null; then 60 | echo -e "${color_green}SUCCESS${color_norm}" 61 | else 62 | echo -e "${color_red}FAILED${color_norm}" 63 | ret=1 64 | fi 65 | else 66 | bash "$t" || ret=1 67 | fi 68 | done 69 | exit $ret 70 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/verify/gofmt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | set -o pipefail 6 | 7 | ROOT=$(dirname "${BASH_SOURCE}")/.. 8 | 9 | pushd "${ROOT}" > /dev/null 10 | 11 | GOFMT=${GOFMT:-"gofmt"} 12 | bad_files=$(find . -name '*.go' | xargs $GOFMT -s -l) 13 | if [[ -n "${bad_files}" ]]; then 14 | echo "!!! '$GOFMT' needs to be run on the following files: " 15 | echo "${bad_files}" 16 | exit 1 17 | fi 18 | 19 | # ex: ts=2 sw=2 et filetype=sh 20 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/verify/golint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ROOT=$(dirname "${BASH_SOURCE}")/.. 4 | GOLINT=${GOLINT:-"golint"} 5 | 6 | pushd "${ROOT}" > /dev/null 7 | bad_files=$($GOLINT -min_confidence=0.9 ./...) 8 | if [[ -n "${bad_files}" ]]; then 9 | echo "!!! '$GOLINT' problems: " 10 | echo "${bad_files}" 11 | exit 1 12 | fi 13 | popd > /dev/null 14 | 15 | # ex: ts=2 sw=2 et filetype=sh 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/const_amd64.s: -------------------------------------------------------------------------------- 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 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | DATA ·REDMASK51(SB)/8, $0x0007FFFFFFFFFFFF 11 | GLOBL ·REDMASK51(SB), 8, $8 12 | 13 | DATA ·_121666_213(SB)/8, $996687872 14 | GLOBL ·_121666_213(SB), 8, $8 15 | 16 | DATA ·_2P0(SB)/8, $0xFFFFFFFFFFFDA 17 | GLOBL ·_2P0(SB), 8, $8 18 | 19 | DATA ·_2P1234(SB)/8, $0xFFFFFFFFFFFFE 20 | GLOBL ·_2P1234(SB), 8, $8 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/cswap_amd64.s: -------------------------------------------------------------------------------- 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 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | // func cswap(inout *[5]uint64, v uint64) 11 | TEXT ·cswap(SB),7,$0 12 | MOVQ inout+0(FP),DI 13 | MOVQ v+8(FP),SI 14 | 15 | CMPQ SI,$1 16 | MOVQ 0(DI),SI 17 | MOVQ 80(DI),DX 18 | MOVQ 8(DI),CX 19 | MOVQ 88(DI),R8 20 | MOVQ SI,R9 21 | CMOVQEQ DX,SI 22 | CMOVQEQ R9,DX 23 | MOVQ CX,R9 24 | CMOVQEQ R8,CX 25 | CMOVQEQ R9,R8 26 | MOVQ SI,0(DI) 27 | MOVQ DX,80(DI) 28 | MOVQ CX,8(DI) 29 | MOVQ R8,88(DI) 30 | MOVQ 16(DI),SI 31 | MOVQ 96(DI),DX 32 | MOVQ 24(DI),CX 33 | MOVQ 104(DI),R8 34 | MOVQ SI,R9 35 | CMOVQEQ DX,SI 36 | CMOVQEQ R9,DX 37 | MOVQ CX,R9 38 | CMOVQEQ R8,CX 39 | CMOVQEQ R9,R8 40 | MOVQ SI,16(DI) 41 | MOVQ DX,96(DI) 42 | MOVQ CX,24(DI) 43 | MOVQ R8,104(DI) 44 | MOVQ 32(DI),SI 45 | MOVQ 112(DI),DX 46 | MOVQ 40(DI),CX 47 | MOVQ 120(DI),R8 48 | MOVQ SI,R9 49 | CMOVQEQ DX,SI 50 | CMOVQEQ R9,DX 51 | MOVQ CX,R9 52 | CMOVQEQ R8,CX 53 | CMOVQEQ R9,R8 54 | MOVQ SI,32(DI) 55 | MOVQ DX,112(DI) 56 | MOVQ CX,40(DI) 57 | MOVQ R8,120(DI) 58 | MOVQ 48(DI),SI 59 | MOVQ 128(DI),DX 60 | MOVQ 56(DI),CX 61 | MOVQ 136(DI),R8 62 | MOVQ SI,R9 63 | CMOVQEQ DX,SI 64 | CMOVQEQ R9,DX 65 | MOVQ CX,R9 66 | CMOVQEQ R8,CX 67 | CMOVQEQ R9,R8 68 | MOVQ SI,48(DI) 69 | MOVQ DX,128(DI) 70 | MOVQ CX,56(DI) 71 | MOVQ R8,136(DI) 72 | MOVQ 64(DI),SI 73 | MOVQ 144(DI),DX 74 | MOVQ 72(DI),CX 75 | MOVQ 152(DI),R8 76 | MOVQ SI,R9 77 | CMOVQEQ DX,SI 78 | CMOVQEQ R9,DX 79 | MOVQ CX,R9 80 | CMOVQEQ R8,CX 81 | CMOVQEQ R9,R8 82 | MOVQ SI,64(DI) 83 | MOVQ DX,144(DI) 84 | MOVQ CX,72(DI) 85 | MOVQ R8,152(DI) 86 | MOVQ DI,AX 87 | MOVQ SI,DX 88 | RET 89 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/curve25519_test.go: -------------------------------------------------------------------------------- 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 curve25519 6 | 7 | import ( 8 | "fmt" 9 | "testing" 10 | ) 11 | 12 | const expectedHex = "89161fde887b2b53de549af483940106ecc114d6982daa98256de23bdf77661a" 13 | 14 | func TestBaseScalarMult(t *testing.T) { 15 | var a, b [32]byte 16 | in := &a 17 | out := &b 18 | a[0] = 1 19 | 20 | for i := 0; i < 200; i++ { 21 | ScalarBaseMult(out, in) 22 | in, out = out, in 23 | } 24 | 25 | result := fmt.Sprintf("%x", in[:]) 26 | if result != expectedHex { 27 | t.Errorf("incorrect result: got %s, want %s", result, expectedHex) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/doc.go: -------------------------------------------------------------------------------- 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 curve25519 provides an implementation of scalar multiplication on 6 | // the elliptic curve known as curve25519. See http://cr.yp.to/ecdh.html 7 | package curve25519 // import "golang.org/x/crypto/curve25519" 8 | 9 | // basePoint is the x coordinate of the generator of the curve. 10 | var basePoint = [32]byte{9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 11 | 12 | // ScalarMult sets dst to the product in*base where dst and base are the x 13 | // coordinates of group points and all values are in little-endian form. 14 | func ScalarMult(dst, in, base *[32]byte) { 15 | scalarMult(dst, in, base) 16 | } 17 | 18 | // ScalarBaseMult sets dst to the product in*base where dst and base are the x 19 | // coordinates of group points, base is the standard generator and all values 20 | // are in little-endian form. 21 | func ScalarBaseMult(dst, in *[32]byte) { 22 | ScalarMult(dst, in, &basePoint) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/freeze_amd64.s: -------------------------------------------------------------------------------- 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 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | // func freeze(inout *[5]uint64) 11 | TEXT ·freeze(SB),7,$96-8 12 | MOVQ inout+0(FP), DI 13 | 14 | MOVQ SP,R11 15 | MOVQ $31,CX 16 | NOTQ CX 17 | ANDQ CX,SP 18 | ADDQ $32,SP 19 | 20 | MOVQ R11,0(SP) 21 | MOVQ R12,8(SP) 22 | MOVQ R13,16(SP) 23 | MOVQ R14,24(SP) 24 | MOVQ R15,32(SP) 25 | MOVQ BX,40(SP) 26 | MOVQ BP,48(SP) 27 | MOVQ 0(DI),SI 28 | MOVQ 8(DI),DX 29 | MOVQ 16(DI),CX 30 | MOVQ 24(DI),R8 31 | MOVQ 32(DI),R9 32 | MOVQ ·REDMASK51(SB),AX 33 | MOVQ AX,R10 34 | SUBQ $18,R10 35 | MOVQ $3,R11 36 | REDUCELOOP: 37 | MOVQ SI,R12 38 | SHRQ $51,R12 39 | ANDQ AX,SI 40 | ADDQ R12,DX 41 | MOVQ DX,R12 42 | SHRQ $51,R12 43 | ANDQ AX,DX 44 | ADDQ R12,CX 45 | MOVQ CX,R12 46 | SHRQ $51,R12 47 | ANDQ AX,CX 48 | ADDQ R12,R8 49 | MOVQ R8,R12 50 | SHRQ $51,R12 51 | ANDQ AX,R8 52 | ADDQ R12,R9 53 | MOVQ R9,R12 54 | SHRQ $51,R12 55 | ANDQ AX,R9 56 | IMUL3Q $19,R12,R12 57 | ADDQ R12,SI 58 | SUBQ $1,R11 59 | JA REDUCELOOP 60 | MOVQ $1,R12 61 | CMPQ R10,SI 62 | CMOVQLT R11,R12 63 | CMPQ AX,DX 64 | CMOVQNE R11,R12 65 | CMPQ AX,CX 66 | CMOVQNE R11,R12 67 | CMPQ AX,R8 68 | CMOVQNE R11,R12 69 | CMPQ AX,R9 70 | CMOVQNE R11,R12 71 | NEGQ R12 72 | ANDQ R12,AX 73 | ANDQ R12,R10 74 | SUBQ R10,SI 75 | SUBQ AX,DX 76 | SUBQ AX,CX 77 | SUBQ AX,R8 78 | SUBQ AX,R9 79 | MOVQ SI,0(DI) 80 | MOVQ DX,8(DI) 81 | MOVQ CX,16(DI) 82 | MOVQ R8,24(DI) 83 | MOVQ R9,32(DI) 84 | MOVQ 0(SP),R11 85 | MOVQ 8(SP),R12 86 | MOVQ 16(SP),R13 87 | MOVQ 24(SP),R14 88 | MOVQ 32(SP),R15 89 | MOVQ 40(SP),BX 90 | MOVQ 48(SP),BP 91 | MOVQ R11,SP 92 | MOVQ DI,AX 93 | MOVQ SI,DX 94 | RET 95 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/square_amd64.s: -------------------------------------------------------------------------------- 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 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | // func square(out, in *[5]uint64) 11 | TEXT ·square(SB),7,$96-16 12 | MOVQ out+0(FP), DI 13 | MOVQ in+8(FP), SI 14 | 15 | MOVQ SP,R11 16 | MOVQ $31,CX 17 | NOTQ CX 18 | ANDQ CX,SP 19 | ADDQ $32, SP 20 | 21 | MOVQ R11,0(SP) 22 | MOVQ R12,8(SP) 23 | MOVQ R13,16(SP) 24 | MOVQ R14,24(SP) 25 | MOVQ R15,32(SP) 26 | MOVQ BX,40(SP) 27 | MOVQ BP,48(SP) 28 | MOVQ 0(SI),AX 29 | MULQ 0(SI) 30 | MOVQ AX,CX 31 | MOVQ DX,R8 32 | MOVQ 0(SI),AX 33 | SHLQ $1,AX 34 | MULQ 8(SI) 35 | MOVQ AX,R9 36 | MOVQ DX,R10 37 | MOVQ 0(SI),AX 38 | SHLQ $1,AX 39 | MULQ 16(SI) 40 | MOVQ AX,R11 41 | MOVQ DX,R12 42 | MOVQ 0(SI),AX 43 | SHLQ $1,AX 44 | MULQ 24(SI) 45 | MOVQ AX,R13 46 | MOVQ DX,R14 47 | MOVQ 0(SI),AX 48 | SHLQ $1,AX 49 | MULQ 32(SI) 50 | MOVQ AX,R15 51 | MOVQ DX,BX 52 | MOVQ 8(SI),AX 53 | MULQ 8(SI) 54 | ADDQ AX,R11 55 | ADCQ DX,R12 56 | MOVQ 8(SI),AX 57 | SHLQ $1,AX 58 | MULQ 16(SI) 59 | ADDQ AX,R13 60 | ADCQ DX,R14 61 | MOVQ 8(SI),AX 62 | SHLQ $1,AX 63 | MULQ 24(SI) 64 | ADDQ AX,R15 65 | ADCQ DX,BX 66 | MOVQ 8(SI),DX 67 | IMUL3Q $38,DX,AX 68 | MULQ 32(SI) 69 | ADDQ AX,CX 70 | ADCQ DX,R8 71 | MOVQ 16(SI),AX 72 | MULQ 16(SI) 73 | ADDQ AX,R15 74 | ADCQ DX,BX 75 | MOVQ 16(SI),DX 76 | IMUL3Q $38,DX,AX 77 | MULQ 24(SI) 78 | ADDQ AX,CX 79 | ADCQ DX,R8 80 | MOVQ 16(SI),DX 81 | IMUL3Q $38,DX,AX 82 | MULQ 32(SI) 83 | ADDQ AX,R9 84 | ADCQ DX,R10 85 | MOVQ 24(SI),DX 86 | IMUL3Q $19,DX,AX 87 | MULQ 24(SI) 88 | ADDQ AX,R9 89 | ADCQ DX,R10 90 | MOVQ 24(SI),DX 91 | IMUL3Q $38,DX,AX 92 | MULQ 32(SI) 93 | ADDQ AX,R11 94 | ADCQ DX,R12 95 | MOVQ 32(SI),DX 96 | IMUL3Q $19,DX,AX 97 | MULQ 32(SI) 98 | ADDQ AX,R13 99 | ADCQ DX,R14 100 | MOVQ ·REDMASK51(SB),SI 101 | SHLQ $13,R8:CX 102 | ANDQ SI,CX 103 | SHLQ $13,R10:R9 104 | ANDQ SI,R9 105 | ADDQ R8,R9 106 | SHLQ $13,R12:R11 107 | ANDQ SI,R11 108 | ADDQ R10,R11 109 | SHLQ $13,R14:R13 110 | ANDQ SI,R13 111 | ADDQ R12,R13 112 | SHLQ $13,BX:R15 113 | ANDQ SI,R15 114 | ADDQ R14,R15 115 | IMUL3Q $19,BX,DX 116 | ADDQ DX,CX 117 | MOVQ CX,DX 118 | SHRQ $51,DX 119 | ADDQ R9,DX 120 | ANDQ SI,CX 121 | MOVQ DX,R8 122 | SHRQ $51,DX 123 | ADDQ R11,DX 124 | ANDQ SI,R8 125 | MOVQ DX,R9 126 | SHRQ $51,DX 127 | ADDQ R13,DX 128 | ANDQ SI,R9 129 | MOVQ DX,AX 130 | SHRQ $51,DX 131 | ADDQ R15,DX 132 | ANDQ SI,AX 133 | MOVQ DX,R10 134 | SHRQ $51,DX 135 | IMUL3Q $19,DX,DX 136 | ADDQ DX,CX 137 | ANDQ SI,R10 138 | MOVQ CX,0(DI) 139 | MOVQ R8,8(DI) 140 | MOVQ R9,16(DI) 141 | MOVQ AX,24(DI) 142 | MOVQ R10,32(DI) 143 | MOVQ 0(SP),R11 144 | MOVQ 8(SP),R12 145 | MOVQ 16(SP),R13 146 | MOVQ 24(SP),R14 147 | MOVQ 32(SP),R15 148 | MOVQ 40(SP),BX 149 | MOVQ 48(SP),BP 150 | MOVQ R11,SP 151 | MOVQ DI,AX 152 | MOVQ SI,DX 153 | RET 154 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/agent/forward.go: -------------------------------------------------------------------------------- 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 agent 6 | 7 | import ( 8 | "errors" 9 | "io" 10 | "net" 11 | "sync" 12 | 13 | "golang.org/x/crypto/ssh" 14 | ) 15 | 16 | // RequestAgentForwarding sets up agent forwarding for the session. 17 | // ForwardToAgent or ForwardToRemote should be called to route 18 | // the authentication requests. 19 | func RequestAgentForwarding(session *ssh.Session) error { 20 | ok, err := session.SendRequest("auth-agent-req@openssh.com", true, nil) 21 | if err != nil { 22 | return err 23 | } 24 | if !ok { 25 | return errors.New("forwarding request denied") 26 | } 27 | return nil 28 | } 29 | 30 | // ForwardToAgent routes authentication requests to the given keyring. 31 | func ForwardToAgent(client *ssh.Client, keyring Agent) error { 32 | channels := client.HandleChannelOpen(channelType) 33 | if channels == nil { 34 | return errors.New("agent: already have handler for " + channelType) 35 | } 36 | 37 | go func() { 38 | for ch := range channels { 39 | channel, reqs, err := ch.Accept() 40 | if err != nil { 41 | continue 42 | } 43 | go ssh.DiscardRequests(reqs) 44 | go func() { 45 | ServeAgent(keyring, channel) 46 | channel.Close() 47 | }() 48 | } 49 | }() 50 | return nil 51 | } 52 | 53 | const channelType = "auth-agent@openssh.com" 54 | 55 | // ForwardToRemote routes authentication requests to the ssh-agent 56 | // process serving on the given unix socket. 57 | func ForwardToRemote(client *ssh.Client, addr string) error { 58 | channels := client.HandleChannelOpen(channelType) 59 | if channels == nil { 60 | return errors.New("agent: already have handler for " + channelType) 61 | } 62 | conn, err := net.Dial("unix", addr) 63 | if err != nil { 64 | return err 65 | } 66 | conn.Close() 67 | 68 | go func() { 69 | for ch := range channels { 70 | channel, reqs, err := ch.Accept() 71 | if err != nil { 72 | continue 73 | } 74 | go ssh.DiscardRequests(reqs) 75 | go forwardUnixSocket(channel, addr) 76 | } 77 | }() 78 | return nil 79 | } 80 | 81 | func forwardUnixSocket(channel ssh.Channel, addr string) { 82 | conn, err := net.Dial("unix", addr) 83 | if err != nil { 84 | return 85 | } 86 | 87 | var wg sync.WaitGroup 88 | wg.Add(2) 89 | go func() { 90 | io.Copy(conn, channel) 91 | conn.(*net.UnixConn).CloseWrite() 92 | wg.Done() 93 | }() 94 | go func() { 95 | io.Copy(channel, conn) 96 | channel.CloseWrite() 97 | wg.Done() 98 | }() 99 | 100 | wg.Wait() 101 | conn.Close() 102 | channel.Close() 103 | } 104 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/agent/server_test.go: -------------------------------------------------------------------------------- 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 agent 6 | 7 | import ( 8 | "testing" 9 | 10 | "golang.org/x/crypto/ssh" 11 | ) 12 | 13 | func TestServer(t *testing.T) { 14 | c1, c2, err := netPipe() 15 | if err != nil { 16 | t.Fatalf("netPipe: %v", err) 17 | } 18 | defer c1.Close() 19 | defer c2.Close() 20 | client := NewClient(c1) 21 | 22 | go ServeAgent(NewKeyring(), c2) 23 | 24 | testAgentInterface(t, client, testPrivateKeys["rsa"], nil, 0) 25 | } 26 | 27 | func TestLockServer(t *testing.T) { 28 | testLockAgent(NewKeyring(), t) 29 | } 30 | 31 | func TestSetupForwardAgent(t *testing.T) { 32 | a, b, err := netPipe() 33 | if err != nil { 34 | t.Fatalf("netPipe: %v", err) 35 | } 36 | 37 | defer a.Close() 38 | defer b.Close() 39 | 40 | _, socket, cleanup := startAgent(t) 41 | defer cleanup() 42 | 43 | serverConf := ssh.ServerConfig{ 44 | NoClientAuth: true, 45 | } 46 | serverConf.AddHostKey(testSigners["rsa"]) 47 | incoming := make(chan *ssh.ServerConn, 1) 48 | go func() { 49 | conn, _, _, err := ssh.NewServerConn(a, &serverConf) 50 | if err != nil { 51 | t.Fatalf("Server: %v", err) 52 | } 53 | incoming <- conn 54 | }() 55 | 56 | conf := ssh.ClientConfig{} 57 | conn, chans, reqs, err := ssh.NewClientConn(b, "", &conf) 58 | if err != nil { 59 | t.Fatalf("NewClientConn: %v", err) 60 | } 61 | client := ssh.NewClient(conn, chans, reqs) 62 | 63 | if err := ForwardToRemote(client, socket); err != nil { 64 | t.Fatalf("SetupForwardAgent: %v", err) 65 | } 66 | 67 | server := <-incoming 68 | ch, reqs, err := server.OpenChannel(channelType, nil) 69 | if err != nil { 70 | t.Fatalf("OpenChannel(%q): %v", channelType, err) 71 | } 72 | go ssh.DiscardRequests(reqs) 73 | 74 | agentClient := NewClient(ch) 75 | testAgentInterface(t, agentClient, testPrivateKeys["rsa"], nil, 0) 76 | conn.Close() 77 | } 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/agent/testdata_test.go: -------------------------------------------------------------------------------- 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 | // IMPLEMENTOR NOTE: To avoid a package loop, this file is in three places: 6 | // ssh/, ssh/agent, and ssh/test/. It should be kept in sync across all three 7 | // instances. 8 | 9 | package agent 10 | 11 | import ( 12 | "crypto/rand" 13 | "fmt" 14 | 15 | "golang.org/x/crypto/ssh" 16 | "golang.org/x/crypto/ssh/testdata" 17 | ) 18 | 19 | var ( 20 | testPrivateKeys map[string]interface{} 21 | testSigners map[string]ssh.Signer 22 | testPublicKeys map[string]ssh.PublicKey 23 | ) 24 | 25 | func init() { 26 | var err error 27 | 28 | n := len(testdata.PEMBytes) 29 | testPrivateKeys = make(map[string]interface{}, n) 30 | testSigners = make(map[string]ssh.Signer, n) 31 | testPublicKeys = make(map[string]ssh.PublicKey, n) 32 | for t, k := range testdata.PEMBytes { 33 | testPrivateKeys[t], err = ssh.ParseRawPrivateKey(k) 34 | if err != nil { 35 | panic(fmt.Sprintf("Unable to parse test key %s: %v", t, err)) 36 | } 37 | testSigners[t], err = ssh.NewSignerFromKey(testPrivateKeys[t]) 38 | if err != nil { 39 | panic(fmt.Sprintf("Unable to create signer for test key %s: %v", t, err)) 40 | } 41 | testPublicKeys[t] = testSigners[t].PublicKey() 42 | } 43 | 44 | // Create a cert and sign it for use in tests. 45 | testCert := &ssh.Certificate{ 46 | Nonce: []byte{}, // To pass reflect.DeepEqual after marshal & parse, this must be non-nil 47 | ValidPrincipals: []string{"gopher1", "gopher2"}, // increases test coverage 48 | ValidAfter: 0, // unix epoch 49 | ValidBefore: ssh.CertTimeInfinity, // The end of currently representable time. 50 | Reserved: []byte{}, // To pass reflect.DeepEqual after marshal & parse, this must be non-nil 51 | Key: testPublicKeys["ecdsa"], 52 | SignatureKey: testPublicKeys["rsa"], 53 | Permissions: ssh.Permissions{ 54 | CriticalOptions: map[string]string{}, 55 | Extensions: map[string]string{}, 56 | }, 57 | } 58 | testCert.SignCert(rand.Reader, testSigners["rsa"]) 59 | testPrivateKeys["cert"] = testPrivateKeys["ecdsa"] 60 | testSigners["cert"], err = ssh.NewCertSigner(testCert, testSigners["ecdsa"]) 61 | if err != nil { 62 | panic(fmt.Sprintf("Unable to create certificate signer: %v", err)) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/benchmark_test.go: -------------------------------------------------------------------------------- 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 ssh 6 | 7 | import ( 8 | "errors" 9 | "io" 10 | "net" 11 | "testing" 12 | ) 13 | 14 | type server struct { 15 | *ServerConn 16 | chans <-chan NewChannel 17 | } 18 | 19 | func newServer(c net.Conn, conf *ServerConfig) (*server, error) { 20 | sconn, chans, reqs, err := NewServerConn(c, conf) 21 | if err != nil { 22 | return nil, err 23 | } 24 | go DiscardRequests(reqs) 25 | return &server{sconn, chans}, nil 26 | } 27 | 28 | func (s *server) Accept() (NewChannel, error) { 29 | n, ok := <-s.chans 30 | if !ok { 31 | return nil, io.EOF 32 | } 33 | return n, nil 34 | } 35 | 36 | func sshPipe() (Conn, *server, error) { 37 | c1, c2, err := netPipe() 38 | if err != nil { 39 | return nil, nil, err 40 | } 41 | 42 | clientConf := ClientConfig{ 43 | User: "user", 44 | } 45 | serverConf := ServerConfig{ 46 | NoClientAuth: true, 47 | } 48 | serverConf.AddHostKey(testSigners["ecdsa"]) 49 | done := make(chan *server, 1) 50 | go func() { 51 | server, err := newServer(c2, &serverConf) 52 | if err != nil { 53 | done <- nil 54 | } 55 | done <- server 56 | }() 57 | 58 | client, _, reqs, err := NewClientConn(c1, "", &clientConf) 59 | if err != nil { 60 | return nil, nil, err 61 | } 62 | 63 | server := <-done 64 | if server == nil { 65 | return nil, nil, errors.New("server handshake failed.") 66 | } 67 | go DiscardRequests(reqs) 68 | 69 | return client, server, nil 70 | } 71 | 72 | func BenchmarkEndToEnd(b *testing.B) { 73 | b.StopTimer() 74 | 75 | client, server, err := sshPipe() 76 | if err != nil { 77 | b.Fatalf("sshPipe: %v", err) 78 | } 79 | 80 | defer client.Close() 81 | defer server.Close() 82 | 83 | size := (1 << 20) 84 | input := make([]byte, size) 85 | output := make([]byte, size) 86 | b.SetBytes(int64(size)) 87 | done := make(chan int, 1) 88 | 89 | go func() { 90 | newCh, err := server.Accept() 91 | if err != nil { 92 | b.Fatalf("Client: %v", err) 93 | } 94 | ch, incoming, err := newCh.Accept() 95 | go DiscardRequests(incoming) 96 | for i := 0; i < b.N; i++ { 97 | if _, err := io.ReadFull(ch, output); err != nil { 98 | b.Fatalf("ReadFull: %v", err) 99 | } 100 | } 101 | ch.Close() 102 | done <- 1 103 | }() 104 | 105 | ch, in, err := client.OpenChannel("speed", nil) 106 | if err != nil { 107 | b.Fatalf("OpenChannel: %v", err) 108 | } 109 | go DiscardRequests(in) 110 | 111 | b.ResetTimer() 112 | b.StartTimer() 113 | for i := 0; i < b.N; i++ { 114 | if _, err := ch.Write(input); err != nil { 115 | b.Fatalf("WriteFull: %v", err) 116 | } 117 | } 118 | ch.Close() 119 | b.StopTimer() 120 | 121 | <-done 122 | } 123 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/buffer.go: -------------------------------------------------------------------------------- 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 ssh 6 | 7 | import ( 8 | "io" 9 | "sync" 10 | ) 11 | 12 | // buffer provides a linked list buffer for data exchange 13 | // between producer and consumer. Theoretically the buffer is 14 | // of unlimited capacity as it does no allocation of its own. 15 | type buffer struct { 16 | // protects concurrent access to head, tail and closed 17 | *sync.Cond 18 | 19 | head *element // the buffer that will be read first 20 | tail *element // the buffer that will be read last 21 | 22 | closed bool 23 | } 24 | 25 | // An element represents a single link in a linked list. 26 | type element struct { 27 | buf []byte 28 | next *element 29 | } 30 | 31 | // newBuffer returns an empty buffer that is not closed. 32 | func newBuffer() *buffer { 33 | e := new(element) 34 | b := &buffer{ 35 | Cond: newCond(), 36 | head: e, 37 | tail: e, 38 | } 39 | return b 40 | } 41 | 42 | // write makes buf available for Read to receive. 43 | // buf must not be modified after the call to write. 44 | func (b *buffer) write(buf []byte) { 45 | b.Cond.L.Lock() 46 | e := &element{buf: buf} 47 | b.tail.next = e 48 | b.tail = e 49 | b.Cond.Signal() 50 | b.Cond.L.Unlock() 51 | } 52 | 53 | // eof closes the buffer. Reads from the buffer once all 54 | // the data has been consumed will receive os.EOF. 55 | func (b *buffer) eof() error { 56 | b.Cond.L.Lock() 57 | b.closed = true 58 | b.Cond.Signal() 59 | b.Cond.L.Unlock() 60 | return nil 61 | } 62 | 63 | // Read reads data from the internal buffer in buf. Reads will block 64 | // if no data is available, or until the buffer is closed. 65 | func (b *buffer) Read(buf []byte) (n int, err error) { 66 | b.Cond.L.Lock() 67 | defer b.Cond.L.Unlock() 68 | 69 | for len(buf) > 0 { 70 | // if there is data in b.head, copy it 71 | if len(b.head.buf) > 0 { 72 | r := copy(buf, b.head.buf) 73 | buf, b.head.buf = buf[r:], b.head.buf[r:] 74 | n += r 75 | continue 76 | } 77 | // if there is a next buffer, make it the head 78 | if len(b.head.buf) == 0 && b.head != b.tail { 79 | b.head = b.head.next 80 | continue 81 | } 82 | 83 | // if at least one byte has been copied, return 84 | if n > 0 { 85 | break 86 | } 87 | 88 | // if nothing was read, and there is nothing outstanding 89 | // check to see if the buffer is closed. 90 | if b.closed { 91 | err = io.EOF 92 | break 93 | } 94 | // out of buffers, wait for producer 95 | b.Cond.Wait() 96 | } 97 | return 98 | } 99 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/buffer_test.go: -------------------------------------------------------------------------------- 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 ssh 6 | 7 | import ( 8 | "io" 9 | "testing" 10 | ) 11 | 12 | var alphabet = []byte("abcdefghijklmnopqrstuvwxyz") 13 | 14 | func TestBufferReadwrite(t *testing.T) { 15 | b := newBuffer() 16 | b.write(alphabet[:10]) 17 | r, _ := b.Read(make([]byte, 10)) 18 | if r != 10 { 19 | t.Fatalf("Expected written == read == 10, written: 10, read %d", r) 20 | } 21 | 22 | b = newBuffer() 23 | b.write(alphabet[:5]) 24 | r, _ = b.Read(make([]byte, 10)) 25 | if r != 5 { 26 | t.Fatalf("Expected written == read == 5, written: 5, read %d", r) 27 | } 28 | 29 | b = newBuffer() 30 | b.write(alphabet[:10]) 31 | r, _ = b.Read(make([]byte, 5)) 32 | if r != 5 { 33 | t.Fatalf("Expected written == 10, read == 5, written: 10, read %d", r) 34 | } 35 | 36 | b = newBuffer() 37 | b.write(alphabet[:5]) 38 | b.write(alphabet[5:15]) 39 | r, _ = b.Read(make([]byte, 10)) 40 | r2, _ := b.Read(make([]byte, 10)) 41 | if r != 10 || r2 != 5 || 15 != r+r2 { 42 | t.Fatal("Expected written == read == 15") 43 | } 44 | } 45 | 46 | func TestBufferClose(t *testing.T) { 47 | b := newBuffer() 48 | b.write(alphabet[:10]) 49 | b.eof() 50 | _, err := b.Read(make([]byte, 5)) 51 | if err != nil { 52 | t.Fatal("expected read of 5 to not return EOF") 53 | } 54 | b = newBuffer() 55 | b.write(alphabet[:10]) 56 | b.eof() 57 | r, err := b.Read(make([]byte, 5)) 58 | r2, err2 := b.Read(make([]byte, 10)) 59 | if r != 5 || r2 != 5 || err != nil || err2 != nil { 60 | t.Fatal("expected reads of 5 and 5") 61 | } 62 | 63 | b = newBuffer() 64 | b.write(alphabet[:10]) 65 | b.eof() 66 | r, err = b.Read(make([]byte, 5)) 67 | r2, err2 = b.Read(make([]byte, 10)) 68 | r3, err3 := b.Read(make([]byte, 10)) 69 | if r != 5 || r2 != 5 || r3 != 0 || err != nil || err2 != nil || err3 != io.EOF { 70 | t.Fatal("expected reads of 5 and 5 and 0, with EOF") 71 | } 72 | 73 | b = newBuffer() 74 | b.write(make([]byte, 5)) 75 | b.write(make([]byte, 10)) 76 | b.eof() 77 | r, err = b.Read(make([]byte, 9)) 78 | r2, err2 = b.Read(make([]byte, 3)) 79 | r3, err3 = b.Read(make([]byte, 3)) 80 | r4, err4 := b.Read(make([]byte, 10)) 81 | if err != nil || err2 != nil || err3 != nil || err4 != io.EOF { 82 | t.Fatalf("Expected EOF on forth read only, err=%v, err2=%v, err3=%v, err4=%v", err, err2, err3, err4) 83 | } 84 | if r != 9 || r2 != 3 || r3 != 3 || r4 != 0 { 85 | t.Fatal("Expected written == read == 15", r, r2, r3, r4) 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/client_test.go: -------------------------------------------------------------------------------- 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 ssh 6 | 7 | import ( 8 | "net" 9 | "testing" 10 | ) 11 | 12 | func testClientVersion(t *testing.T, config *ClientConfig, expected string) { 13 | clientConn, serverConn := net.Pipe() 14 | defer clientConn.Close() 15 | receivedVersion := make(chan string, 1) 16 | go func() { 17 | version, err := readVersion(serverConn) 18 | if err != nil { 19 | receivedVersion <- "" 20 | } else { 21 | receivedVersion <- string(version) 22 | } 23 | serverConn.Close() 24 | }() 25 | NewClientConn(clientConn, "", config) 26 | actual := <-receivedVersion 27 | if actual != expected { 28 | t.Fatalf("got %s; want %s", actual, expected) 29 | } 30 | } 31 | 32 | func TestCustomClientVersion(t *testing.T) { 33 | version := "Test-Client-Version-0.0" 34 | testClientVersion(t, &ClientConfig{ClientVersion: version}, version) 35 | } 36 | 37 | func TestDefaultClientVersion(t *testing.T) { 38 | testClientVersion(t, &ClientConfig{}, packageVersion) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/doc.go: -------------------------------------------------------------------------------- 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 ssh implements an SSH client and server. 7 | 8 | SSH is a transport security protocol, an authentication protocol and a 9 | family of application protocols. The most typical application level 10 | protocol is a remote shell and this is specifically implemented. However, 11 | the multiplexed nature of SSH is exposed to users that wish to support 12 | others. 13 | 14 | References: 15 | [PROTOCOL.certkeys]: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys?rev=HEAD 16 | [SSH-PARAMETERS]: http://www.iana.org/assignments/ssh-parameters/ssh-parameters.xml#ssh-parameters-1 17 | */ 18 | package ssh // import "golang.org/x/crypto/ssh" 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/kex_test.go: -------------------------------------------------------------------------------- 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 ssh 6 | 7 | // Key exchange tests. 8 | 9 | import ( 10 | "crypto/rand" 11 | "reflect" 12 | "testing" 13 | ) 14 | 15 | func TestKexes(t *testing.T) { 16 | type kexResultErr struct { 17 | result *kexResult 18 | err error 19 | } 20 | 21 | for name, kex := range kexAlgoMap { 22 | a, b := memPipe() 23 | 24 | s := make(chan kexResultErr, 1) 25 | c := make(chan kexResultErr, 1) 26 | var magics handshakeMagics 27 | go func() { 28 | r, e := kex.Client(a, rand.Reader, &magics) 29 | a.Close() 30 | c <- kexResultErr{r, e} 31 | }() 32 | go func() { 33 | r, e := kex.Server(b, rand.Reader, &magics, testSigners["ecdsa"]) 34 | b.Close() 35 | s <- kexResultErr{r, e} 36 | }() 37 | 38 | clientRes := <-c 39 | serverRes := <-s 40 | if clientRes.err != nil { 41 | t.Errorf("client: %v", clientRes.err) 42 | } 43 | if serverRes.err != nil { 44 | t.Errorf("server: %v", serverRes.err) 45 | } 46 | if !reflect.DeepEqual(clientRes.result, serverRes.result) { 47 | t.Errorf("kex %q: mismatch %#v, %#v", name, clientRes.result, serverRes.result) 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/mac.go: -------------------------------------------------------------------------------- 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 ssh 6 | 7 | // Message authentication support 8 | 9 | import ( 10 | "crypto/hmac" 11 | "crypto/sha1" 12 | "crypto/sha256" 13 | "hash" 14 | ) 15 | 16 | type macMode struct { 17 | keySize int 18 | new func(key []byte) hash.Hash 19 | } 20 | 21 | // truncatingMAC wraps around a hash.Hash and truncates the output digest to 22 | // a given size. 23 | type truncatingMAC struct { 24 | length int 25 | hmac hash.Hash 26 | } 27 | 28 | func (t truncatingMAC) Write(data []byte) (int, error) { 29 | return t.hmac.Write(data) 30 | } 31 | 32 | func (t truncatingMAC) Sum(in []byte) []byte { 33 | out := t.hmac.Sum(in) 34 | return out[:len(in)+t.length] 35 | } 36 | 37 | func (t truncatingMAC) Reset() { 38 | t.hmac.Reset() 39 | } 40 | 41 | func (t truncatingMAC) Size() int { 42 | return t.length 43 | } 44 | 45 | func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() } 46 | 47 | var macModes = map[string]*macMode{ 48 | "hmac-sha2-256": {32, func(key []byte) hash.Hash { 49 | return hmac.New(sha256.New, key) 50 | }}, 51 | "hmac-sha1": {20, func(key []byte) hash.Hash { 52 | return hmac.New(sha1.New, key) 53 | }}, 54 | "hmac-sha1-96": {20, func(key []byte) hash.Hash { 55 | return truncatingMAC{12, hmac.New(sha1.New, key)} 56 | }}, 57 | } 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/mempipe_test.go: -------------------------------------------------------------------------------- 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 ssh 6 | 7 | import ( 8 | "io" 9 | "sync" 10 | "testing" 11 | ) 12 | 13 | // An in-memory packetConn. It is safe to call Close and writePacket 14 | // from different goroutines. 15 | type memTransport struct { 16 | eof bool 17 | pending [][]byte 18 | write *memTransport 19 | sync.Mutex 20 | *sync.Cond 21 | } 22 | 23 | func (t *memTransport) readPacket() ([]byte, error) { 24 | t.Lock() 25 | defer t.Unlock() 26 | for { 27 | if len(t.pending) > 0 { 28 | r := t.pending[0] 29 | t.pending = t.pending[1:] 30 | return r, nil 31 | } 32 | if t.eof { 33 | return nil, io.EOF 34 | } 35 | t.Cond.Wait() 36 | } 37 | } 38 | 39 | func (t *memTransport) closeSelf() error { 40 | t.Lock() 41 | defer t.Unlock() 42 | if t.eof { 43 | return io.EOF 44 | } 45 | t.eof = true 46 | t.Cond.Broadcast() 47 | return nil 48 | } 49 | 50 | func (t *memTransport) Close() error { 51 | err := t.write.closeSelf() 52 | t.closeSelf() 53 | return err 54 | } 55 | 56 | func (t *memTransport) writePacket(p []byte) error { 57 | t.write.Lock() 58 | defer t.write.Unlock() 59 | if t.write.eof { 60 | return io.EOF 61 | } 62 | c := make([]byte, len(p)) 63 | copy(c, p) 64 | t.write.pending = append(t.write.pending, c) 65 | t.write.Cond.Signal() 66 | return nil 67 | } 68 | 69 | func memPipe() (a, b packetConn) { 70 | t1 := memTransport{} 71 | t2 := memTransport{} 72 | t1.write = &t2 73 | t2.write = &t1 74 | t1.Cond = sync.NewCond(&t1.Mutex) 75 | t2.Cond = sync.NewCond(&t2.Mutex) 76 | return &t1, &t2 77 | } 78 | 79 | func TestMemPipe(t *testing.T) { 80 | a, b := memPipe() 81 | if err := a.writePacket([]byte{42}); err != nil { 82 | t.Fatalf("writePacket: %v", err) 83 | } 84 | if err := a.Close(); err != nil { 85 | t.Fatal("Close: ", err) 86 | } 87 | p, err := b.readPacket() 88 | if err != nil { 89 | t.Fatal("readPacket: ", err) 90 | } 91 | if len(p) != 1 || p[0] != 42 { 92 | t.Fatalf("got %v, want {42}", p) 93 | } 94 | p, err = b.readPacket() 95 | if err != io.EOF { 96 | t.Fatalf("got %v, %v, want EOF", p, err) 97 | } 98 | } 99 | 100 | func TestDoubleClose(t *testing.T) { 101 | a, _ := memPipe() 102 | err := a.Close() 103 | if err != nil { 104 | t.Errorf("Close: %v", err) 105 | } 106 | err = a.Close() 107 | if err != io.EOF { 108 | t.Errorf("expect EOF on double close.") 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/tcpip_test.go: -------------------------------------------------------------------------------- 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 ssh 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestAutoPortListenBroken(t *testing.T) { 12 | broken := "SSH-2.0-OpenSSH_5.9hh11" 13 | works := "SSH-2.0-OpenSSH_6.1" 14 | if !isBrokenOpenSSHVersion(broken) { 15 | t.Errorf("version %q not marked as broken", broken) 16 | } 17 | if isBrokenOpenSSHVersion(works) { 18 | t.Errorf("version %q marked as broken", works) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go: -------------------------------------------------------------------------------- 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 terminal 8 | 9 | import "syscall" 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | const ioctlWriteTermios = syscall.TIOCSETA 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_linux.go: -------------------------------------------------------------------------------- 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 terminal 6 | 7 | // These constants are declared here, rather than importing 8 | // them from the syscall package as some syscall packages, even 9 | // on linux, for example gccgo, do not declare them. 10 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 11 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/test/agent_unix_test.go: -------------------------------------------------------------------------------- 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 netbsd openbsd 6 | 7 | package test 8 | 9 | import ( 10 | "bytes" 11 | "testing" 12 | 13 | "golang.org/x/crypto/ssh" 14 | "golang.org/x/crypto/ssh/agent" 15 | ) 16 | 17 | func TestAgentForward(t *testing.T) { 18 | server := newServer(t) 19 | defer server.Shutdown() 20 | conn := server.Dial(clientConfig()) 21 | defer conn.Close() 22 | 23 | keyring := agent.NewKeyring() 24 | if err := keyring.Add(agent.AddedKey{PrivateKey: testPrivateKeys["dsa"]}); err != nil { 25 | t.Fatalf("Error adding key: %s", err) 26 | } 27 | if err := keyring.Add(agent.AddedKey{ 28 | PrivateKey: testPrivateKeys["dsa"], 29 | ConfirmBeforeUse: true, 30 | LifetimeSecs: 3600, 31 | }); err != nil { 32 | t.Fatalf("Error adding key with constraints: %s", err) 33 | } 34 | pub := testPublicKeys["dsa"] 35 | 36 | sess, err := conn.NewSession() 37 | if err != nil { 38 | t.Fatalf("NewSession: %v", err) 39 | } 40 | if err := agent.RequestAgentForwarding(sess); err != nil { 41 | t.Fatalf("RequestAgentForwarding: %v", err) 42 | } 43 | 44 | if err := agent.ForwardToAgent(conn, keyring); err != nil { 45 | t.Fatalf("SetupForwardKeyring: %v", err) 46 | } 47 | out, err := sess.CombinedOutput("ssh-add -L") 48 | if err != nil { 49 | t.Fatalf("running ssh-add: %v, out %s", err, out) 50 | } 51 | key, _, _, _, err := ssh.ParseAuthorizedKey(out) 52 | if err != nil { 53 | t.Fatalf("ParseAuthorizedKey(%q): %v", out, err) 54 | } 55 | 56 | if !bytes.Equal(key.Marshal(), pub.Marshal()) { 57 | t.Fatalf("got key %s, want %s", ssh.MarshalAuthorizedKey(key), ssh.MarshalAuthorizedKey(pub)) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/test/cert_test.go: -------------------------------------------------------------------------------- 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 netbsd openbsd 6 | 7 | package test 8 | 9 | import ( 10 | "crypto/rand" 11 | "testing" 12 | 13 | "golang.org/x/crypto/ssh" 14 | ) 15 | 16 | func TestCertLogin(t *testing.T) { 17 | s := newServer(t) 18 | defer s.Shutdown() 19 | 20 | // Use a key different from the default. 21 | clientKey := testSigners["dsa"] 22 | caAuthKey := testSigners["ecdsa"] 23 | cert := &ssh.Certificate{ 24 | Key: clientKey.PublicKey(), 25 | ValidPrincipals: []string{username()}, 26 | CertType: ssh.UserCert, 27 | ValidBefore: ssh.CertTimeInfinity, 28 | } 29 | if err := cert.SignCert(rand.Reader, caAuthKey); err != nil { 30 | t.Fatalf("SetSignature: %v", err) 31 | } 32 | 33 | certSigner, err := ssh.NewCertSigner(cert, clientKey) 34 | if err != nil { 35 | t.Fatalf("NewCertSigner: %v", err) 36 | } 37 | 38 | conf := &ssh.ClientConfig{ 39 | User: username(), 40 | } 41 | conf.Auth = append(conf.Auth, ssh.PublicKeys(certSigner)) 42 | client, err := s.TryDial(conf) 43 | if err != nil { 44 | t.Fatalf("TryDial: %v", err) 45 | } 46 | client.Close() 47 | } 48 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/test/doc.go: -------------------------------------------------------------------------------- 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 | // This package contains integration tests for the 6 | // golang.org/x/crypto/ssh package. 7 | package test // import "golang.org/x/crypto/ssh/test" 8 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/test/tcpip_test.go: -------------------------------------------------------------------------------- 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 !windows 6 | 7 | package test 8 | 9 | // direct-tcpip functional tests 10 | 11 | import ( 12 | "io" 13 | "net" 14 | "testing" 15 | ) 16 | 17 | func TestDial(t *testing.T) { 18 | server := newServer(t) 19 | defer server.Shutdown() 20 | sshConn := server.Dial(clientConfig()) 21 | defer sshConn.Close() 22 | 23 | l, err := net.Listen("tcp", "127.0.0.1:0") 24 | if err != nil { 25 | t.Fatalf("Listen: %v", err) 26 | } 27 | defer l.Close() 28 | 29 | go func() { 30 | for { 31 | c, err := l.Accept() 32 | if err != nil { 33 | break 34 | } 35 | 36 | io.WriteString(c, c.RemoteAddr().String()) 37 | c.Close() 38 | } 39 | }() 40 | 41 | conn, err := sshConn.Dial("tcp", l.Addr().String()) 42 | if err != nil { 43 | t.Fatalf("Dial: %v", err) 44 | } 45 | defer conn.Close() 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/test/testdata_test.go: -------------------------------------------------------------------------------- 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 | // IMPLEMENTOR NOTE: To avoid a package loop, this file is in three places: 6 | // ssh/, ssh/agent, and ssh/test/. It should be kept in sync across all three 7 | // instances. 8 | 9 | package test 10 | 11 | import ( 12 | "crypto/rand" 13 | "fmt" 14 | 15 | "golang.org/x/crypto/ssh" 16 | "golang.org/x/crypto/ssh/testdata" 17 | ) 18 | 19 | var ( 20 | testPrivateKeys map[string]interface{} 21 | testSigners map[string]ssh.Signer 22 | testPublicKeys map[string]ssh.PublicKey 23 | ) 24 | 25 | func init() { 26 | var err error 27 | 28 | n := len(testdata.PEMBytes) 29 | testPrivateKeys = make(map[string]interface{}, n) 30 | testSigners = make(map[string]ssh.Signer, n) 31 | testPublicKeys = make(map[string]ssh.PublicKey, n) 32 | for t, k := range testdata.PEMBytes { 33 | testPrivateKeys[t], err = ssh.ParseRawPrivateKey(k) 34 | if err != nil { 35 | panic(fmt.Sprintf("Unable to parse test key %s: %v", t, err)) 36 | } 37 | testSigners[t], err = ssh.NewSignerFromKey(testPrivateKeys[t]) 38 | if err != nil { 39 | panic(fmt.Sprintf("Unable to create signer for test key %s: %v", t, err)) 40 | } 41 | testPublicKeys[t] = testSigners[t].PublicKey() 42 | } 43 | 44 | // Create a cert and sign it for use in tests. 45 | testCert := &ssh.Certificate{ 46 | Nonce: []byte{}, // To pass reflect.DeepEqual after marshal & parse, this must be non-nil 47 | ValidPrincipals: []string{"gopher1", "gopher2"}, // increases test coverage 48 | ValidAfter: 0, // unix epoch 49 | ValidBefore: ssh.CertTimeInfinity, // The end of currently representable time. 50 | Reserved: []byte{}, // To pass reflect.DeepEqual after marshal & parse, this must be non-nil 51 | Key: testPublicKeys["ecdsa"], 52 | SignatureKey: testPublicKeys["rsa"], 53 | Permissions: ssh.Permissions{ 54 | CriticalOptions: map[string]string{}, 55 | Extensions: map[string]string{}, 56 | }, 57 | } 58 | testCert.SignCert(rand.Reader, testSigners["rsa"]) 59 | testPrivateKeys["cert"] = testPrivateKeys["ecdsa"] 60 | testSigners["cert"], err = ssh.NewCertSigner(testCert, testSigners["ecdsa"]) 61 | if err != nil { 62 | panic(fmt.Sprintf("Unable to create certificate signer: %v", err)) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/testdata/doc.go: -------------------------------------------------------------------------------- 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 | // This package contains test data shared between the various subpackages of 6 | // the golang.org/x/crypto/ssh package. Under no circumstance should 7 | // this data be used for production code. 8 | package testdata // import "golang.org/x/crypto/ssh/testdata" 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/testdata/keys.go: -------------------------------------------------------------------------------- 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 testdata 6 | 7 | var PEMBytes = map[string][]byte{ 8 | "dsa": []byte(`-----BEGIN DSA PRIVATE KEY----- 9 | MIIBuwIBAAKBgQD6PDSEyXiI9jfNs97WuM46MSDCYlOqWw80ajN16AohtBncs1YB 10 | lHk//dQOvCYOsYaE+gNix2jtoRjwXhDsc25/IqQbU1ahb7mB8/rsaILRGIbA5WH3 11 | EgFtJmXFovDz3if6F6TzvhFpHgJRmLYVR8cqsezL3hEZOvvs2iH7MorkxwIVAJHD 12 | nD82+lxh2fb4PMsIiaXudAsBAoGAQRf7Q/iaPRn43ZquUhd6WwvirqUj+tkIu6eV 13 | 2nZWYmXLlqFQKEy4Tejl7Wkyzr2OSYvbXLzo7TNxLKoWor6ips0phYPPMyXld14r 14 | juhT24CrhOzuLMhDduMDi032wDIZG4Y+K7ElU8Oufn8Sj5Wge8r6ANmmVgmFfynr 15 | FhdYCngCgYEA3ucGJ93/Mx4q4eKRDxcWD3QzWyqpbRVRRV1Vmih9Ha/qC994nJFz 16 | DQIdjxDIT2Rk2AGzMqFEB68Zc3O+Wcsmz5eWWzEwFxaTwOGWTyDqsDRLm3fD+QYj 17 | nOwuxb0Kce+gWI8voWcqC9cyRm09jGzu2Ab3Bhtpg8JJ8L7gS3MRZK4CFEx4UAfY 18 | Fmsr0W6fHB9nhS4/UXM8 19 | -----END DSA PRIVATE KEY----- 20 | `), 21 | "ecdsa": []byte(`-----BEGIN EC PRIVATE KEY----- 22 | MHcCAQEEINGWx0zo6fhJ/0EAfrPzVFyFC9s18lBt3cRoEDhS3ARooAoGCCqGSM49 23 | AwEHoUQDQgAEi9Hdw6KvZcWxfg2IDhA7UkpDtzzt6ZqJXSsFdLd+Kx4S3Sx4cVO+ 24 | 6/ZOXRnPmNAlLUqjShUsUBBngG0u2fqEqA== 25 | -----END EC PRIVATE KEY----- 26 | `), 27 | "rsa": []byte(`-----BEGIN RSA PRIVATE KEY----- 28 | MIIBOwIBAAJBALdGZxkXDAjsYk10ihwU6Id2KeILz1TAJuoq4tOgDWxEEGeTrcld 29 | r/ZwVaFzjWzxaf6zQIJbfaSEAhqD5yo72+sCAwEAAQJBAK8PEVU23Wj8mV0QjwcJ 30 | tZ4GcTUYQL7cF4+ezTCE9a1NrGnCP2RuQkHEKxuTVrxXt+6OF15/1/fuXnxKjmJC 31 | nxkCIQDaXvPPBi0c7vAxGwNY9726x01/dNbHCE0CBtcotobxpwIhANbbQbh3JHVW 32 | 2haQh4fAG5mhesZKAGcxTyv4mQ7uMSQdAiAj+4dzMpJWdSzQ+qGHlHMIBvVHLkqB 33 | y2VdEyF7DPCZewIhAI7GOI/6LDIFOvtPo6Bj2nNmyQ1HU6k/LRtNIXi4c9NJAiAr 34 | rrxx26itVhJmcvoUhOjwuzSlP2bE5VHAvkGB352YBg== 35 | -----END RSA PRIVATE KEY----- 36 | `), 37 | "user": []byte(`-----BEGIN EC PRIVATE KEY----- 38 | MHcCAQEEILYCAeq8f7V4vSSypRw7pxy8yz3V5W4qg8kSC3zJhqpQoAoGCCqGSM49 39 | AwEHoUQDQgAEYcO2xNKiRUYOLEHM7VYAp57HNyKbOdYtHD83Z4hzNPVC4tM5mdGD 40 | PLL8IEwvYu2wq+lpXfGQnNMbzYf9gspG0w== 41 | -----END EC PRIVATE KEY----- 42 | `), 43 | } 44 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/testdata_test.go: -------------------------------------------------------------------------------- 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 | // IMPLEMENTOR NOTE: To avoid a package loop, this file is in three places: 6 | // ssh/, ssh/agent, and ssh/test/. It should be kept in sync across all three 7 | // instances. 8 | 9 | package ssh 10 | 11 | import ( 12 | "crypto/rand" 13 | "fmt" 14 | 15 | "golang.org/x/crypto/ssh/testdata" 16 | ) 17 | 18 | var ( 19 | testPrivateKeys map[string]interface{} 20 | testSigners map[string]Signer 21 | testPublicKeys map[string]PublicKey 22 | ) 23 | 24 | func init() { 25 | var err error 26 | 27 | n := len(testdata.PEMBytes) 28 | testPrivateKeys = make(map[string]interface{}, n) 29 | testSigners = make(map[string]Signer, n) 30 | testPublicKeys = make(map[string]PublicKey, n) 31 | for t, k := range testdata.PEMBytes { 32 | testPrivateKeys[t], err = ParseRawPrivateKey(k) 33 | if err != nil { 34 | panic(fmt.Sprintf("Unable to parse test key %s: %v", t, err)) 35 | } 36 | testSigners[t], err = NewSignerFromKey(testPrivateKeys[t]) 37 | if err != nil { 38 | panic(fmt.Sprintf("Unable to create signer for test key %s: %v", t, err)) 39 | } 40 | testPublicKeys[t] = testSigners[t].PublicKey() 41 | } 42 | 43 | // Create a cert and sign it for use in tests. 44 | testCert := &Certificate{ 45 | Nonce: []byte{}, // To pass reflect.DeepEqual after marshal & parse, this must be non-nil 46 | ValidPrincipals: []string{"gopher1", "gopher2"}, // increases test coverage 47 | ValidAfter: 0, // unix epoch 48 | ValidBefore: CertTimeInfinity, // The end of currently representable time. 49 | Reserved: []byte{}, // To pass reflect.DeepEqual after marshal & parse, this must be non-nil 50 | Key: testPublicKeys["ecdsa"], 51 | SignatureKey: testPublicKeys["rsa"], 52 | Permissions: Permissions{ 53 | CriticalOptions: map[string]string{}, 54 | Extensions: map[string]string{}, 55 | }, 56 | } 57 | testCert.SignCert(rand.Reader, testSigners["rsa"]) 58 | testPrivateKeys["cert"] = testPrivateKeys["ecdsa"] 59 | testSigners["cert"], err = NewCertSigner(testCert, testSigners["ecdsa"]) 60 | if err != nil { 61 | panic(fmt.Sprintf("Unable to create certificate signer: %v", err)) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/transport_test.go: -------------------------------------------------------------------------------- 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 ssh 6 | 7 | import ( 8 | "bytes" 9 | "crypto/rand" 10 | "encoding/binary" 11 | "strings" 12 | "testing" 13 | ) 14 | 15 | func TestReadVersion(t *testing.T) { 16 | longversion := strings.Repeat("SSH-2.0-bla", 50)[:253] 17 | cases := map[string]string{ 18 | "SSH-2.0-bla\r\n": "SSH-2.0-bla", 19 | "SSH-2.0-bla\n": "SSH-2.0-bla", 20 | longversion + "\r\n": longversion, 21 | } 22 | 23 | for in, want := range cases { 24 | result, err := readVersion(bytes.NewBufferString(in)) 25 | if err != nil { 26 | t.Errorf("readVersion(%q): %s", in, err) 27 | } 28 | got := string(result) 29 | if got != want { 30 | t.Errorf("got %q, want %q", got, want) 31 | } 32 | } 33 | } 34 | 35 | func TestReadVersionError(t *testing.T) { 36 | longversion := strings.Repeat("SSH-2.0-bla", 50)[:253] 37 | cases := []string{ 38 | longversion + "too-long\r\n", 39 | } 40 | for _, in := range cases { 41 | if _, err := readVersion(bytes.NewBufferString(in)); err == nil { 42 | t.Errorf("readVersion(%q) should have failed", in) 43 | } 44 | } 45 | } 46 | 47 | func TestExchangeVersionsBasic(t *testing.T) { 48 | v := "SSH-2.0-bla" 49 | buf := bytes.NewBufferString(v + "\r\n") 50 | them, err := exchangeVersions(buf, []byte("xyz")) 51 | if err != nil { 52 | t.Errorf("exchangeVersions: %v", err) 53 | } 54 | 55 | if want := "SSH-2.0-bla"; string(them) != want { 56 | t.Errorf("got %q want %q for our version", them, want) 57 | } 58 | } 59 | 60 | func TestExchangeVersions(t *testing.T) { 61 | cases := []string{ 62 | "not\x000allowed", 63 | "not allowed\n", 64 | } 65 | for _, c := range cases { 66 | buf := bytes.NewBufferString("SSH-2.0-bla\r\n") 67 | if _, err := exchangeVersions(buf, []byte(c)); err == nil { 68 | t.Errorf("exchangeVersions(%q): should have failed", c) 69 | } 70 | } 71 | } 72 | 73 | type closerBuffer struct { 74 | bytes.Buffer 75 | } 76 | 77 | func (b *closerBuffer) Close() error { 78 | return nil 79 | } 80 | 81 | func TestTransportMaxPacketWrite(t *testing.T) { 82 | buf := &closerBuffer{} 83 | tr := newTransport(buf, rand.Reader, true) 84 | huge := make([]byte, maxPacket+1) 85 | err := tr.writePacket(huge) 86 | if err == nil { 87 | t.Errorf("transport accepted write for a huge packet.") 88 | } 89 | } 90 | 91 | func TestTransportMaxPacketReader(t *testing.T) { 92 | var header [5]byte 93 | huge := make([]byte, maxPacket+128) 94 | binary.BigEndian.PutUint32(header[0:], uint32(len(huge))) 95 | // padding. 96 | header[4] = 0 97 | 98 | buf := &closerBuffer{} 99 | buf.Write(header[:]) 100 | buf.Write(huge) 101 | 102 | tr := newTransport(buf, rand.Reader, true) 103 | _, err := tr.readPacket() 104 | if err == nil { 105 | t.Errorf("transport succeeded reading huge packet.") 106 | } else if !strings.Contains(err.Error(), "large") { 107 | t.Errorf("got %q, should mention %q", err.Error(), "large") 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /vendor/manifest: -------------------------------------------------------------------------------- 1 | { 2 | "version": 0, 3 | "dependencies": [ 4 | { 5 | "importpath": "comail.io/go/colog", 6 | "repository": "https://github.com/comail/colog.git", 7 | "revision": "83af66bac88aecb569b3867c950a5a3a9b5f991b", 8 | "branch": "master" 9 | }, 10 | { 11 | "importpath": "github.com/bgentry/speakeasy", 12 | "repository": "https://github.com/bgentry/speakeasy", 13 | "revision": "36e9cfdd690967f4f690c6edcc9ffacd006014a0", 14 | "branch": "master" 15 | }, 16 | { 17 | "importpath": "github.com/cpuguy83/go-md2man/md2man", 18 | "repository": "https://github.com/cpuguy83/go-md2man", 19 | "revision": "71acacd42f85e5e82f70a55327789582a5200a90", 20 | "branch": "master", 21 | "path": "/md2man" 22 | }, 23 | { 24 | "importpath": "github.com/inconshreveable/mousetrap", 25 | "repository": "https://github.com/inconshreveable/mousetrap", 26 | "revision": "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75", 27 | "branch": "master" 28 | }, 29 | { 30 | "importpath": "github.com/kr/pty", 31 | "repository": "https://github.com/kr/pty", 32 | "revision": "f7ee69f31298ecbe5d2b349c711e2547a617d398", 33 | "branch": "master" 34 | }, 35 | { 36 | "importpath": "github.com/russross/blackfriday", 37 | "repository": "https://github.com/russross/blackfriday", 38 | "revision": "8cec3a854e68dba10faabbe31c089abf4a3e57a6", 39 | "branch": "master" 40 | }, 41 | { 42 | "importpath": "github.com/shurcooL/sanitized_anchor_name", 43 | "repository": "https://github.com/shurcooL/sanitized_anchor_name", 44 | "revision": "244f5ac324cb97e1987ef901a0081a77bfd8e845", 45 | "branch": "master" 46 | }, 47 | { 48 | "importpath": "github.com/spf13/cobra", 49 | "repository": "https://github.com/spf13/cobra", 50 | "revision": "d732ab3a34e6e9e6b5bdac80707c2b6bad852936", 51 | "branch": "master" 52 | }, 53 | { 54 | "importpath": "github.com/spf13/pflag", 55 | "repository": "https://github.com/spf13/pflag", 56 | "revision": "b084184666e02084b8ccb9b704bf0d79c466eb1d", 57 | "branch": "master" 58 | }, 59 | { 60 | "importpath": "golang.org/x/crypto/curve25519", 61 | "repository": "https://go.googlesource.com/crypto", 62 | "revision": "c8b9e6388ef638d5a8a9d865c634befdc46a6784", 63 | "branch": "master", 64 | "path": "/curve25519" 65 | }, 66 | { 67 | "importpath": "golang.org/x/crypto/ssh", 68 | "repository": "https://go.googlesource.com/crypto", 69 | "revision": "c8b9e6388ef638d5a8a9d865c634befdc46a6784", 70 | "branch": "master", 71 | "path": "/ssh" 72 | } 73 | ] 74 | } --------------------------------------------------------------------------------