├── .gitignore ├── LICENSE ├── README.md ├── console.go ├── doc.go ├── file.go ├── glide.lock ├── glide.yaml ├── harp.go ├── harp_test.go ├── log.go ├── migration.go ├── migration_test.go ├── pre-commit ├── pre-push ├── rollback.go ├── server.go ├── sync_file.go ├── test.sh ├── test ├── Dockerfile ├── app.go ├── app_argtag.go ├── app_filetag.go ├── deploy.sh ├── file ├── files │ ├── file1 │ ├── file2 │ ├── file3 │ └── files │ │ └── file1 ├── harp.json ├── harp2.json ├── harp3.json ├── id_rsa ├── id_rsa.pub ├── migration.go ├── migration.sh ├── migration2.go ├── migration3 │ └── main.go ├── restart.sh ├── test_version.go └── update_pkg.sh ├── utils.go ├── vendor ├── github.com │ ├── DisposaBoy │ │ └── JsonConfigReader │ │ │ ├── AUTHORS.md │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ ├── reader.go │ │ │ └── reader_test.go │ ├── cheggaaa │ │ └── pb │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── example_copy_test.go │ │ │ ├── example_multiple_test.go │ │ │ ├── example_test.go │ │ │ ├── format.go │ │ │ ├── format_test.go │ │ │ ├── pb.go │ │ │ ├── pb_appengine.go │ │ │ ├── pb_nix.go │ │ │ ├── pb_solaris.go │ │ │ ├── pb_test.go │ │ │ ├── pb_win.go │ │ │ ├── pb_x.go │ │ │ ├── pool.go │ │ │ ├── reader.go │ │ │ ├── runecount.go │ │ │ ├── runecount_test.go │ │ │ ├── termios_bsd.go │ │ │ └── termios_nix.go │ ├── chzyer │ │ └── readline │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── CHANGELOG.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── ansi_windows.go │ │ │ ├── char.go │ │ │ ├── complete.go │ │ │ ├── complete_helper.go │ │ │ ├── debug.go │ │ │ ├── doc.go │ │ │ ├── example │ │ │ ├── readline-demo │ │ │ │ └── readline-demo.go │ │ │ ├── readline-multiline │ │ │ │ └── readline-multiline.go │ │ │ └── readline-pass-strength │ │ │ │ └── readline-pass-strength.go │ │ │ ├── history.go │ │ │ ├── operation.go │ │ │ ├── password.go │ │ │ ├── rawreader_windows.go │ │ │ ├── readline.go │ │ │ ├── remote.go │ │ │ ├── runebuf.go │ │ │ ├── runes │ │ │ ├── runes.go │ │ │ └── runes_test.go │ │ │ ├── search.go │ │ │ ├── std.go │ │ │ ├── std_windows.go │ │ │ ├── terminal.go │ │ │ ├── utils.go │ │ │ ├── utils_test.go │ │ │ ├── utils_unix.go │ │ │ ├── utils_windows.go │ │ │ ├── vim.go │ │ │ └── windows_api.go │ ├── davecgh │ │ └── go-spew │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── cov_report.sh │ │ │ ├── spew │ │ │ ├── bypass.go │ │ │ ├── bypasssafe.go │ │ │ ├── common.go │ │ │ ├── common_test.go │ │ │ ├── config.go │ │ │ ├── doc.go │ │ │ ├── dump.go │ │ │ ├── dump_test.go │ │ │ ├── dumpcgo_test.go │ │ │ ├── dumpnocgo_test.go │ │ │ ├── example_test.go │ │ │ ├── format.go │ │ │ ├── format_test.go │ │ │ ├── internal_test.go │ │ │ ├── internalunsafe_test.go │ │ │ ├── spew.go │ │ │ ├── spew_test.go │ │ │ └── testdata │ │ │ │ └── dumpcgo.go │ │ │ └── test_coverage.txt │ ├── nbutton23 │ │ └── zxcvbn-go │ │ │ ├── .gitignore │ │ │ ├── Godeps │ │ │ ├── Godeps.json │ │ │ ├── Readme │ │ │ └── _workspace │ │ │ │ ├── .gitignore │ │ │ │ ├── Godeps │ │ │ │ ├── Godeps.json │ │ │ │ ├── Readme │ │ │ │ └── _workspace │ │ │ │ │ └── .gitignore │ │ │ │ └── src │ │ │ │ └── github.com │ │ │ │ ├── davecgh │ │ │ │ └── go-spew │ │ │ │ │ ├── LICENSE │ │ │ │ │ └── spew │ │ │ │ │ ├── bypass.go │ │ │ │ │ ├── bypasssafe.go │ │ │ │ │ ├── common.go │ │ │ │ │ ├── config.go │ │ │ │ │ ├── doc.go │ │ │ │ │ ├── dump.go │ │ │ │ │ ├── format.go │ │ │ │ │ └── spew.go │ │ │ │ ├── pmezard │ │ │ │ └── go-difflib │ │ │ │ │ ├── LICENSE │ │ │ │ │ └── difflib │ │ │ │ │ └── difflib.go │ │ │ │ └── stretchr │ │ │ │ └── testify │ │ │ │ ├── LICENSE │ │ │ │ ├── assert │ │ │ │ ├── assertion_forward.go │ │ │ │ ├── assertion_forward.go.tmpl │ │ │ │ ├── assertions.go │ │ │ │ ├── doc.go │ │ │ │ ├── errors.go │ │ │ │ ├── forward_assertions.go │ │ │ │ └── http_assertions.go │ │ │ │ └── vendor │ │ │ │ └── github.com │ │ │ │ ├── davecgh │ │ │ │ └── go-spew │ │ │ │ │ └── LICENSE │ │ │ │ ├── pmezard │ │ │ │ └── go-difflib │ │ │ │ │ └── LICENSE │ │ │ │ └── stretchr │ │ │ │ └── objx │ │ │ │ └── LICENSE.md │ │ │ ├── LICENSE.txt │ │ │ ├── README.md │ │ │ ├── adjacency │ │ │ ├── adjacmartix_test.go │ │ │ └── adjcmartix.go │ │ │ ├── data │ │ │ ├── bindata.go │ │ │ └── data │ │ │ │ ├── Dvorak.json │ │ │ │ ├── English.json │ │ │ │ ├── FemaleNames.json │ │ │ │ ├── Keypad.json │ │ │ │ ├── L33t.json │ │ │ │ ├── MacKeypad.json │ │ │ │ ├── MaleNames.json │ │ │ │ ├── Passwords.json │ │ │ │ ├── Qwerty.json │ │ │ │ └── Surnames.json │ │ │ ├── entropy │ │ │ ├── entropyCalculator.go │ │ │ └── entropyCalculator_test.go │ │ │ ├── frequency │ │ │ └── frequency.go │ │ │ ├── match │ │ │ └── match.go │ │ │ ├── matching │ │ │ ├── matching.go │ │ │ └── matching_test.go │ │ │ ├── scoring │ │ │ └── scoring.go │ │ │ ├── utils │ │ │ └── math │ │ │ │ ├── mathutils.go │ │ │ │ └── mathutils_test.go │ │ │ ├── zxcvbn.go │ │ │ └── zxcvbn_test.go │ ├── pmezard │ │ └── go-difflib │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ └── difflib │ │ │ ├── difflib.go │ │ │ └── difflib_test.go │ └── stretchr │ │ ├── objx │ │ ├── .gitignore │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── accessors.go │ │ ├── accessors_test.go │ │ ├── codegen │ │ │ ├── array-access.txt │ │ │ ├── index.html │ │ │ ├── template.txt │ │ │ └── types_list.txt │ │ ├── constants.go │ │ ├── conversions.go │ │ ├── conversions_test.go │ │ ├── doc.go │ │ ├── fixture_test.go │ │ ├── map.go │ │ ├── map_for_test.go │ │ ├── map_test.go │ │ ├── mutations.go │ │ ├── mutations_test.go │ │ ├── security.go │ │ ├── security_test.go │ │ ├── simple_example_test.go │ │ ├── tests.go │ │ ├── tests_test.go │ │ ├── type_specific_codegen.go │ │ ├── type_specific_codegen_test.go │ │ ├── value.go │ │ └── value_test.go │ │ └── testify │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── Godeps │ │ ├── Godeps.json │ │ └── Readme │ │ ├── LICENCE.txt │ │ ├── LICENSE │ │ ├── README.md │ │ ├── _codegen │ │ └── main.go │ │ ├── assert │ │ ├── assertion_forward.go │ │ ├── assertion_forward.go.tmpl │ │ ├── assertions.go │ │ ├── assertions_test.go │ │ ├── doc.go │ │ ├── errors.go │ │ ├── forward_assertions.go │ │ ├── forward_assertions_test.go │ │ ├── http_assertions.go │ │ └── http_assertions_test.go │ │ ├── doc.go │ │ ├── http │ │ ├── doc.go │ │ ├── test_response_writer.go │ │ └── test_round_tripper.go │ │ ├── mock │ │ ├── doc.go │ │ ├── mock.go │ │ └── mock_test.go │ │ ├── package_test.go │ │ ├── require │ │ ├── doc.go │ │ ├── forward_requirements.go │ │ ├── forward_requirements_test.go │ │ ├── require.go │ │ ├── require.go.tmpl │ │ ├── require_forward.go │ │ ├── require_forward.go.tmpl │ │ ├── requirements.go │ │ └── requirements_test.go │ │ ├── suite │ │ ├── doc.go │ │ ├── interfaces.go │ │ ├── suite.go │ │ └── suite_test.go │ │ └── vendor │ │ └── github.com │ │ ├── davecgh │ │ └── go-spew │ │ │ ├── LICENSE │ │ │ └── spew │ │ │ ├── bypass.go │ │ │ ├── bypasssafe.go │ │ │ ├── common.go │ │ │ ├── config.go │ │ │ ├── doc.go │ │ │ ├── dump.go │ │ │ ├── format.go │ │ │ └── spew.go │ │ ├── pmezard │ │ └── go-difflib │ │ │ ├── LICENSE │ │ │ └── difflib │ │ │ └── difflib.go │ │ └── stretchr │ │ └── objx │ │ ├── .gitignore │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── accessors.go │ │ ├── codegen │ │ ├── array-access.txt │ │ ├── index.html │ │ ├── template.txt │ │ └── types_list.txt │ │ ├── constants.go │ │ ├── conversions.go │ │ ├── doc.go │ │ ├── map.go │ │ ├── mutations.go │ │ ├── security.go │ │ ├── tests.go │ │ ├── type_specific_codegen.go │ │ └── value.go └── golang.org │ └── x │ └── crypto │ ├── .gitattributes │ ├── .gitignore │ ├── AUTHORS │ ├── CONTRIBUTING.md │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ ├── README │ ├── bcrypt │ ├── base64.go │ ├── bcrypt.go │ └── bcrypt_test.go │ ├── blowfish │ ├── block.go │ ├── blowfish_test.go │ ├── cipher.go │ └── const.go │ ├── bn256 │ ├── bn256.go │ ├── bn256_test.go │ ├── constants.go │ ├── curve.go │ ├── example_test.go │ ├── gfp12.go │ ├── gfp2.go │ ├── gfp6.go │ ├── optate.go │ └── twist.go │ ├── cast5 │ ├── cast5.go │ └── cast5_test.go │ ├── codereview.cfg │ ├── 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 │ ├── glide.lock │ ├── hkdf │ ├── example_test.go │ ├── hkdf.go │ └── hkdf_test.go │ ├── md4 │ ├── md4.go │ ├── md4_test.go │ └── md4block.go │ ├── nacl │ ├── box │ │ ├── box.go │ │ └── box_test.go │ └── secretbox │ │ ├── secretbox.go │ │ └── secretbox_test.go │ ├── ocsp │ ├── ocsp.go │ └── ocsp_test.go │ ├── openpgp │ ├── armor │ │ ├── armor.go │ │ ├── armor_test.go │ │ └── encode.go │ ├── canonical_text.go │ ├── canonical_text_test.go │ ├── clearsign │ │ ├── clearsign.go │ │ └── clearsign_test.go │ ├── elgamal │ │ ├── elgamal.go │ │ └── elgamal_test.go │ ├── errors │ │ └── errors.go │ ├── keys.go │ ├── keys_test.go │ ├── packet │ │ ├── compressed.go │ │ ├── compressed_test.go │ │ ├── config.go │ │ ├── encrypted_key.go │ │ ├── encrypted_key_test.go │ │ ├── literal.go │ │ ├── ocfb.go │ │ ├── ocfb_test.go │ │ ├── one_pass_signature.go │ │ ├── opaque.go │ │ ├── opaque_test.go │ │ ├── packet.go │ │ ├── packet_test.go │ │ ├── private_key.go │ │ ├── private_key_test.go │ │ ├── public_key.go │ │ ├── public_key_test.go │ │ ├── public_key_v3.go │ │ ├── public_key_v3_test.go │ │ ├── reader.go │ │ ├── signature.go │ │ ├── signature_test.go │ │ ├── signature_v3.go │ │ ├── signature_v3_test.go │ │ ├── symmetric_key_encrypted.go │ │ ├── symmetric_key_encrypted_test.go │ │ ├── symmetrically_encrypted.go │ │ ├── symmetrically_encrypted_test.go │ │ ├── userattribute.go │ │ ├── userattribute_test.go │ │ ├── userid.go │ │ └── userid_test.go │ ├── read.go │ ├── read_test.go │ ├── s2k │ │ ├── s2k.go │ │ └── s2k_test.go │ ├── write.go │ └── write_test.go │ ├── otr │ ├── libotr_test_helper.c │ ├── otr.go │ ├── otr_test.go │ └── smp.go │ ├── pbkdf2 │ ├── pbkdf2.go │ └── pbkdf2_test.go │ ├── pkcs12 │ ├── bmp-string.go │ ├── bmp-string_test.go │ ├── crypto.go │ ├── crypto_test.go │ ├── errors.go │ ├── internal │ │ └── rc2 │ │ │ ├── bench_test.go │ │ │ ├── rc2.go │ │ │ └── rc2_test.go │ ├── mac.go │ ├── mac_test.go │ ├── pbkdf.go │ ├── pbkdf_test.go │ ├── pkcs12.go │ ├── pkcs12_test.go │ └── safebags.go │ ├── poly1305 │ ├── const_amd64.s │ ├── poly1305.go │ ├── poly1305_amd64.s │ ├── poly1305_arm.s │ ├── poly1305_test.go │ ├── sum_amd64.go │ ├── sum_arm.go │ └── sum_ref.go │ ├── ripemd160 │ ├── ripemd160.go │ ├── ripemd160_test.go │ └── ripemd160block.go │ ├── salsa20 │ ├── salsa │ │ ├── hsalsa20.go │ │ ├── salsa2020_amd64.s │ │ ├── salsa208.go │ │ ├── salsa20_amd64.go │ │ ├── salsa20_ref.go │ │ └── salsa_test.go │ ├── salsa20.go │ └── salsa20_test.go │ ├── scrypt │ ├── scrypt.go │ └── scrypt_test.go │ ├── sha3 │ ├── doc.go │ ├── hashes.go │ ├── keccakf.go │ ├── register.go │ ├── sha3.go │ ├── sha3_test.go │ ├── shake.go │ ├── testdata │ │ └── keccakKats.json.deflate │ ├── xor.go │ ├── xor_generic.go │ └── xor_unaligned.go │ ├── ssh │ ├── agent │ │ ├── client.go │ │ ├── client_test.go │ │ ├── forward.go │ │ ├── keyring.go │ │ ├── keyring_test.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 │ ├── tea │ ├── cipher.go │ └── tea_test.go │ ├── twofish │ ├── twofish.go │ └── twofish_test.go │ ├── xtea │ ├── block.go │ ├── cipher.go │ └── xtea_test.go │ └── xts │ ├── xts.go │ └── xts_test.go └── version.go /.gitignore: -------------------------------------------------------------------------------- 1 | tmp 2 | harp 3 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 bom_d_van 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 | -------------------------------------------------------------------------------- /console.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "strings" 8 | "sync" 9 | 10 | "github.com/chzyer/readline" 11 | ) 12 | 13 | func startConsole(servers []*Server) { 14 | rl, err := readline.New("> ") 15 | if err != nil { 16 | panic(err) 17 | } 18 | defer rl.Close() 19 | 20 | type output struct { 21 | serv *Server 22 | output string 23 | } 24 | 25 | isTerminal := readline.IsTerminal(int(os.Stdin.Fd())) 26 | for { 27 | var line string 28 | var err error 29 | if isTerminal { 30 | line, err = rl.Readline() 31 | } else { 32 | lineb, er := ioutil.ReadAll(os.Stdin) 33 | line, err = string(lineb), er 34 | } 35 | if err != nil { // io.EOF 36 | break 37 | } 38 | 39 | outputc := make(chan output) 40 | var mutex sync.Mutex 41 | var count int 42 | var wg sync.WaitGroup 43 | wg.Add(1) 44 | go func() { 45 | for { 46 | mutex.Lock() 47 | output := <-outputc 48 | prompt := output.serv.prompt() 49 | if isTerminal { 50 | prompt += " " + line 51 | } 52 | if count > 0 && strings.TrimSpace(output.output) != "" { 53 | prompt = "\n" + prompt 54 | } 55 | fmt.Println(prompt) 56 | if strings.TrimSpace(output.output) != "" { 57 | fmt.Printf(output.output) 58 | } 59 | if count++; count >= len(servers) { 60 | break 61 | } 62 | mutex.Unlock() 63 | } 64 | wg.Done() 65 | }() 66 | 67 | for _, serv := range servers { 68 | wg.Add(1) 69 | go func(serv *Server) { 70 | outputc <- output{serv: serv, output: serv.exec(line)} 71 | wg.Done() 72 | }(serv) 73 | } 74 | wg.Wait() 75 | 76 | if !isTerminal { 77 | return 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /file.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "strconv" 5 | 6 | "encoding/json" 7 | ) 8 | 9 | type File struct { 10 | file 11 | } 12 | 13 | type file struct { 14 | Path string 15 | Excludeds []string 16 | Delete bool // delete extraneous files from dest dirs 17 | } 18 | 19 | // "rsync", "-P", "-az", "--delete", "-e", ssh, "tmp/"+appName, dst 20 | 21 | func (f *File) UnmarshalJSON(data []byte) (err error) { 22 | if !(len(data) > 2 && data[0] == '{' && data[len(data)-1] == '}') { 23 | f.Path, err = strconv.Unquote(string(data)) 24 | return 25 | } 26 | 27 | if err = json.Unmarshal(data, &f.file); err != nil { 28 | return 29 | } 30 | 31 | return 32 | } 33 | -------------------------------------------------------------------------------- /glide.lock: -------------------------------------------------------------------------------- 1 | hash: ebb14dfab26abfec7683a28cc4bf9d4f17d88d9e5f72d32ddea15df9a8b70630 2 | updated: 2016-02-19T18:30:03.278366301+08:00 3 | imports: 4 | - name: github.com/cheggaaa/pb 5 | version: 4788033326290f47bb40c29942fa8e919e2ee597 6 | - name: github.com/chzyer/readline 7 | version: 5aaa89df05e26e3f095ccd5a70f43b8600bcbe4a 8 | - name: github.com/davecgh/go-spew 9 | version: 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d 10 | subpackages: 11 | - spew 12 | - name: github.com/DisposaBoy/JsonConfigReader 13 | version: 33a99fdf1d5ee1f79b5077e9c06f955ad356d5f4 14 | - name: github.com/nbutton23/zxcvbn-go 15 | version: 5fb7f48ad1914518a3781e7bb7f2f3eb267e7ac9 16 | repo: https://github.com/nbutton23/zxcvbn-go 17 | - name: github.com/pmezard/go-difflib 18 | version: e8554b8641db39598be7f6342874b958f12ae1d4 19 | subpackages: 20 | - difflib 21 | - name: github.com/stretchr/objx 22 | version: cbeaeb16a013161a98496fad62933b1d21786672 23 | - name: github.com/stretchr/testify 24 | version: 38b5d653e3cad9252e69070a3fe23377ab380557 25 | subpackages: 26 | - assert 27 | - name: golang.org/x/crypto 28 | version: 1f22c0103821b9390939b6776727195525381532 29 | subpackages: 30 | - /ssh 31 | - ssh/agent 32 | devImports: [] 33 | -------------------------------------------------------------------------------- /glide.yaml: -------------------------------------------------------------------------------- 1 | package: github.com/bom-d-van/harp 2 | import: 3 | - package: github.com/DisposaBoy/JsonConfigReader 4 | - package: github.com/cheggaaa/pb 5 | - package: github.com/chzyer/readline 6 | - package: golang.org/x/crypto 7 | subpackages: 8 | - ssh 9 | - ssh/agent 10 | - package: AUTHORS 11 | - package: CONTRIBUTING.md 12 | - package: CONTRIBUTORS 13 | - package: LICENSE 14 | - package: PATENTS 15 | - package: README 16 | - package: bcrypt 17 | - package: blowfish 18 | - package: bn256 19 | - package: cast5 20 | - package: codereview.cfg 21 | - package: curve25519 22 | - package: hkdf 23 | - package: md4 24 | - package: nacl 25 | - package: ocsp 26 | - package: openpgp 27 | - package: otr 28 | - package: pbkdf2 29 | - package: pkcs12 30 | - package: poly1305 31 | - package: ripemd160 32 | - package: salsa20 33 | - package: scrypt 34 | - package: sha3 35 | - package: ssh 36 | - package: tea 37 | - package: twofish 38 | - package: xtea 39 | - package: xts 40 | -------------------------------------------------------------------------------- /harp_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func TestRetrieveServers(t *testing.T) { 6 | cfg.Servers = map[string][]*Server{ 7 | "prod": { 8 | &Server{ 9 | User: "app", 10 | Host: "192.168.59.103", 11 | Port: ":49153", 12 | }, 13 | &Server{ 14 | User: "app", 15 | Host: "192.168.59.103", 16 | Port: ":49154", 17 | }, 18 | }, 19 | "dev": { 20 | &Server{ 21 | User: "app", 22 | Host: "192.168.59.103", 23 | Port: ":49155", 24 | }, 25 | &Server{ 26 | User: "app", 27 | Host: "192.168.59.103", 28 | Port: ":49156", 29 | }, 30 | }, 31 | } 32 | option.serverSets = []string{"prod"} 33 | option.servers = []string{"app@192.168.59.103:49156"} 34 | servers := retrieveServers() 35 | if len(servers) != 3 { 36 | t.Error("failed to retrieve 3 correct servers") 37 | } 38 | for i, server := range servers { 39 | switch i { 40 | case 0: 41 | if server.String() != "app@192.168.59.103:49153" { 42 | t.Error("failed to retrieve server app@192.168.59.103:49153") 43 | } 44 | case 1: 45 | if server.String() != "app@192.168.59.103:49154" { 46 | t.Error("failed to retrieve server app@192.168.59.103:49154") 47 | } 48 | case 2: 49 | if server.String() != "app@192.168.59.103:49156" { 50 | t.Error("failed to retrieve server app@192.168.59.103:49156") 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /migration_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "reflect" 6 | "testing" 7 | ) 8 | 9 | func TestRetrieveMigrations(t *testing.T) { 10 | got := retrieveMigrations([]string{ 11 | "AppEnv=prod test/migration.go -arg1 val1 -arg2 val2", 12 | "AppEnv='pr od' AppEnv='pr od' test/migration.go -arg1 val1 -arg2 val2", 13 | "AppEnv='pr od' test/migration.go", 14 | }) 15 | 16 | expect := []Migration{ 17 | { 18 | File: "test/migration.go", 19 | Base: "migration.go", 20 | Envs: "AppEnv=prod", 21 | Args: "-arg1 val1 -arg2 val2", 22 | }, 23 | { 24 | File: "test/migration.go", 25 | Base: "migration.go", 26 | Envs: "AppEnv='pr od' AppEnv='pr od'", 27 | Args: "-arg1 val1 -arg2 val2", 28 | }, 29 | { 30 | File: "test/migration.go", 31 | Base: "migration.go", 32 | Envs: "AppEnv='pr od'", 33 | Args: "", 34 | }, 35 | } 36 | 37 | if !reflect.DeepEqual(expect, got) { 38 | t.Errorf("expect %s got %s", pretty(expect), pretty(got)) 39 | } 40 | } 41 | 42 | func pretty(v interface{}) string { 43 | r, err := json.MarshalIndent(v, "", " ") 44 | if err != nil { 45 | panic("failed to marshal indent: " + err.Error()) 46 | } 47 | return string(r) 48 | } 49 | -------------------------------------------------------------------------------- /pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # bumps up version number by one digit 4 | 5 | current=$(cat $GOPATH/src/github.com/bom-d-van/harp/version.go | grep -o "[0-9]\{1,\}") 6 | current=$(expr $current + 1) 7 | 8 | cat < $GOPATH/src/github.com/bom-d-van/harp/version.go 9 | package main 10 | 11 | const version = $current 12 | EOF 13 | 14 | git add $GOPATH/src/github.com/bom-d-van/harp/version.go 15 | -------------------------------------------------------------------------------- /pre-push: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # An example hook script to verify what is about to be pushed. Called by "git 4 | # push" after it has checked the remote status, but before anything has been 5 | # pushed. If this script exits with a non-zero status nothing will be pushed. 6 | # 7 | # This hook is called with the following parameters: 8 | # 9 | # $1 -- Name of the remote to which the push is being done 10 | # $2 -- URL to which the push is being done 11 | # 12 | # If pushing without using a named remote those arguments will be equal. 13 | # 14 | # Information about the commits which are being pushed is supplied as lines to 15 | # the standard input in the form: 16 | # 17 | # 18 | # 19 | # This sample shows how to prevent push of commits where the log message starts 20 | # with "WIP" (work in progress). 21 | 22 | set -e 23 | 24 | echo "install github.com/bom-d-van/harp" 25 | go install github.com/bom-d-van/harp 26 | -------------------------------------------------------------------------------- /test/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | MAINTAINER Sven Dowideit 3 | 4 | RUN apt-get update && apt-get install -y openssh-server 5 | RUN mkdir /var/run/sshd 6 | RUN echo 'root:root' | chpasswd 7 | RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config 8 | 9 | # SSH login fix. Otherwise user is kicked off after login 10 | RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd 11 | 12 | ENV NOTVISIBLE "in users profile" 13 | RUN echo "export VISIBLE=now" >> /etc/profile 14 | 15 | RUN locale-gen en_US.UTF-8 16 | 17 | RUN adduser --disabled-password --gecos "" app 18 | RUN ssh-keygen -q -t rsa -N '' -f /id_rsa 19 | RUN apt-get install rsync 20 | 21 | # TODO: generate ssh keys 22 | 23 | EXPOSE 22 24 | CMD ["/usr/sbin/sshd", "-D"] 25 | -------------------------------------------------------------------------------- /test/app.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "os" 7 | "time" 8 | ) 9 | 10 | func main() { 11 | var i int 12 | log.SetPrefix(fmt.Sprintf("%d %d: ", os.Getpid(), version)) 13 | log.Println("running", i) 14 | for { 15 | time.Sleep(time.Second * 5) 16 | i++ 17 | log.Println("running", i) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/app_argtag.go: -------------------------------------------------------------------------------- 1 | // +build argtag 2 | 3 | package main 4 | 5 | import ( 6 | "log" 7 | "time" 8 | ) 9 | 10 | func init() { 11 | log.Println("message from arg-tag") 12 | go func() { 13 | for { 14 | time.Sleep(time.Second * 5) 15 | log.Println("message from arg-tag") 16 | } 17 | }() 18 | } 19 | -------------------------------------------------------------------------------- /test/app_filetag.go: -------------------------------------------------------------------------------- 1 | // +build filetag 2 | 3 | package main 4 | 5 | import ( 6 | "log" 7 | "time" 8 | ) 9 | 10 | func init() { 11 | go func() { 12 | log.Println("message from file-tag") 13 | for { 14 | time.Sleep(time.Second * 5) 15 | log.Println("message from file-tag") 16 | } 17 | }() 18 | } 19 | -------------------------------------------------------------------------------- /test/deploy.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | 3 | echo `date` start >> test.log 4 | 5 | {{.SyncFiles}} 6 | {{.SaveRelease}} 7 | {{.RestartServer}} 8 | 9 | echo `date` done >> test.log 10 | sleep 1 11 | -------------------------------------------------------------------------------- /test/file: -------------------------------------------------------------------------------- 1 | file -------------------------------------------------------------------------------- /test/files/file1: -------------------------------------------------------------------------------- 1 | file1 2 | -------------------------------------------------------------------------------- /test/files/file2: -------------------------------------------------------------------------------- 1 | file2 2 | -------------------------------------------------------------------------------- /test/files/file3: -------------------------------------------------------------------------------- 1 | file2 2 | -------------------------------------------------------------------------------- /test/files/files/file1: -------------------------------------------------------------------------------- 1 | file1 2 | 2 3 | 3 4 | 4 5 | -------------------------------------------------------------------------------- /test/harp.json: -------------------------------------------------------------------------------- 1 | { 2 | "GOOS": "linux", 3 | "GOARCH": "amd64", 4 | // "log_path": "harp/{{.App.Name}}/log", 5 | "App": { 6 | "Name": "app", 7 | "ImportPath": "github.com/bom-d-van/harp/test", 8 | "DefaultExcludeds": ["*.swp"], 9 | // a comment 10 | // comment line 2 11 | "Files": [ 12 | "github.com/bom-d-van/harp/test/file", 13 | { 14 | "Path": "github.com/bom-d-van/harp/test/files", 15 | "Delete": true, // another comment 16 | "Excludeds": ["file1"] 17 | } 18 | ] 19 | }, 20 | "Servers": { 21 | "prod": [{ 22 | "ID": "pluto", 23 | "User": "app", 24 | "Host": "192.168.99.100", 25 | "Port": ":49153" 26 | }, { 27 | "ID": "neptune", 28 | "User": "app", 29 | "Host": "192.168.99.100", 30 | "Port": ":49154" 31 | }] 32 | } 33 | } -------------------------------------------------------------------------------- /test/harp2.json: -------------------------------------------------------------------------------- 1 | { 2 | "GOOS": "linux", 3 | "GOARCH": "amd64", 4 | "App": { 5 | "Name": "app", 6 | "ImportPath": "github.com/bom-d-van/harp/test", 7 | "DeployScript": "test/deploy.sh", 8 | "RestartScript": "test/restart.sh", 9 | "MigrationScript": "test/migration.sh", 10 | "BuildCmd": "docker run -t -v $GOPATH:/home/app golang /bin/sh -c 'cd /home/app/src/github.com/bom-d-van/harp; GOPATH=/home/app /usr/local/go/bin/go build -o /home/app/src/github.com/bom-d-van/harp/%s %s'", 11 | "Files": [ 12 | "github.com/bom-d-van/harp/test/files", 13 | "github.com/bom-d-van/harp/test/file" 14 | ] 15 | }, 16 | "Servers": { 17 | "prod": [{ 18 | "User": "app", 19 | "Host": "192.168.99.100", 20 | "Port": ":49153" 21 | }, { 22 | "User": "app", 23 | "Host": "192.168.99.100", 24 | "Port": ":49154" 25 | }] 26 | } 27 | } -------------------------------------------------------------------------------- /test/harp3.json: -------------------------------------------------------------------------------- 1 | { 2 | "GOOS": "linux", 3 | "GOARCH": "amd64", 4 | "App": { 5 | "Name": "app", 6 | "ImportPath": "github.com/bom-d-van/harp/test", 7 | "BuildArgs": "-tags filetag", 8 | "DefaultExcludeds": ["*.swp"], 9 | // a comment 10 | // comment line 2 11 | "Files": [ 12 | "github.com/bom-d-van/harp/test/file", 13 | { 14 | "Path": "github.com/bom-d-van/harp/test/files", 15 | "Delete": true, // another comment 16 | "Excludeds": ["file1"] 17 | } 18 | ] 19 | }, 20 | "Servers": { 21 | "prod": [{ 22 | "ID": "pluto", 23 | "User": "app", 24 | "Host": "192.168.99.100", 25 | "envs": {"e1": "1"}, 26 | "Port": ":49153" 27 | }, { 28 | "ID": "neptune", 29 | "User": "app", 30 | "Host": "192.168.99.100", 31 | "Port": ":49154" 32 | }] 33 | } 34 | } -------------------------------------------------------------------------------- /test/id_rsa: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEA2CU5EHZxOo4rScwUeTkQIbRjouDv6ml4fboQoOkTz9itmAc0 3 | V23nxb+PtMBqWwV2Qo+4ZrHVIf+iqBBJoKHfU1s4oYy3IIm/cogAbB7f7KfCJce3 4 | knqDGF5SJ2J7Z11SFcQtaXQ9AA5ZMJan7jEiQfO2yXwLPT+CGYP30+thPzIMKh0p 5 | cAihRnXx/DHlhdXScfNB3eh5HqNjtKFKs3jR2AK3AL1zRd95WO4Sm4YUDwaGVGev 6 | JR+V/M6lp1Bu8b6eJWW9bEBx5l3/Jqc3O8B07WlG2XEq8gd8BD8gAU9rlyVZj6BC 7 | csF4g/+FGqSU2HQssemoTgUngnnp2jE/dnIEZQIDAQABAoIBAQCaqa/2jrog60Ag 8 | c06nG2TmqTyufQRPmR7l4DEr4vwROvukkGsssHEreBJthU3VSchAgrSxj0hyJokO 9 | d3En5wx1ig2w047qUobSfmzG8STMI5JyFEHQJ6gM1Nk2Y2roIMeu2YyhK9LGan35 10 | naQWdcQMq0a9T+x+7CW8+khotMIGRAkaVHWgfdm+scCmK7lEcR10XG9/1ndt17/q 11 | v6Zas6nuvRa5W1tmOuTAuJA11cHD3VsN2jH+awvj+FEPFLaeLO4n57mXAFgYrmh+ 12 | lLTdhJhavTMSG3OfUpDAD98z+HlWMnZILp4Nr6Rq0rCIR/wpUBQ8X/3eXogRHR0p 13 | o1wr8O9BAoGBAPzJak2qwqaBDj8wQCOzWGPYwfuhwuoRUXfI0fRNdpqTwm0i5wau 14 | 91QPG8WFFM5gwIUP5wnRyAuQb6KurrhYa+dsC+xLvrqHiL2wNrQn2Y3IOshCWkPt 15 | Hgl5kGP+4JePMuwWwZ7hHnE1QrtMUAEhcdwXwJXH9ZSZ9X5kP1wK+0vxAoGBANrk 16 | kv/9ya6l1TtBfFCu91UIAsfhHM/gQqo672Gb/h5AUg4ZVFIxJj3usrRsqB2TVSYP 17 | ZV41L6qdb39laLerY7CAbMz1MgDdaIAfBJXHcM2y8YeE+qXpL0G8HEX5zG05MZog 18 | 9Vun4OOww6MtoBmUNkgVawVxImC0KLIxw7eWeYO1AoGBANBRTAFlT7PXdt4r7S9+ 19 | hMEDyBiOXgp26yRDooIptCv+yKMXuDuRxNDJAqHr4hGROhZt3IADGVAuX1E5k1Ln 20 | y0STjd/VLACb4Nwxc2NT07073PVbePexWKeGPq+pQ3yizdwxhK5h5qx0r+GaKfRE 21 | k4hFKrhEaOVlWyIlivFXO3CBAoGAMHdx8QqRkIEZgKBUVU0YaJR4gSdgCMsgF68q 22 | 99LhZnNZd9O17ukBDa9/lCGG692GegHosP5XypBHcs7Sa/CgByG4dX1JEBX2IIA9 23 | tKhPWsxnXFleYkQKeaScIgZYdEq4p+bqTNwUGHY4KzZb/63ogvdzFeZh9UWOyT3p 24 | lwnTaA0CgYBbDoDsn9Vk5Q64r5LawKUehFd1tMwqo+nltTdLH1Vi2l+LbCBSrXze 25 | xDbdufEpuH5GfPVOGiLNSpS6Uy8YwmgWBwTIQw84+5Tig95I6RyjXztbQWpVO+Wi 26 | BOSfasjb+ROadSqaH0ZX4HV62TNRp9Nn0Vy26gI33ILm/ma54meaig== 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /test/id_rsa.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYJTkQdnE6jitJzBR5ORAhtGOi4O/qaXh9uhCg6RPP2K2YBzRXbefFv4+0wGpbBXZCj7hmsdUh/6KoEEmgod9TWzihjLcgib9yiABsHt/sp8Ilx7eSeoMYXlInYntnXVIVxC1pdD0ADlkwlqfuMSJB87bJfAs9P4IZg/fT62E/MgwqHSlwCKFGdfH8MeWF1dJx80Hd6Hkeo2O0oUqzeNHYArcAvXNF33lY7hKbhhQPBoZUZ68lH5X8zqWnUG7xvp4lZb1sQHHmXf8mpzc7wHTtaUbZcSryB3wEPyABT2uXJVmPoEJywXiD/4UapJTYdCyx6ahOBSeCeenaMT92cgRl bom_d_van@Vans-MacBook-Pro-3.local 2 | -------------------------------------------------------------------------------- /test/migration.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | "os" 8 | "time" 9 | ) 10 | 11 | func main() { 12 | fmt.Println("AppEnv=" + os.Getenv("AppEnv")) 13 | fmt.Println("Args:", os.Args[1:]) 14 | for i := 0; i < 5; i++ { 15 | fmt.Println("logging", i) 16 | time.Sleep(time.Second * time.Duration(i)) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/migration.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | 3 | echo $(date) start >> migration.log 4 | 5 | {{.DefaultScript}} 6 | 7 | echo $(date) done >> migration.log 8 | -------------------------------------------------------------------------------- /test/migration2.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | "time" 8 | ) 9 | 10 | func main() { 11 | for i := 0; i < 5; i++ { 12 | fmt.Println("logging", i) 13 | time.Sleep(time.Second * time.Duration(i)) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/migration3/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | println("i am a migration pkg") 5 | } 6 | -------------------------------------------------------------------------------- /test/restart.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | 3 | echo $(date) start >> restart.log 4 | 5 | {{.RestartServer}} 6 | 7 | echo $(date) done >> restart.log 8 | -------------------------------------------------------------------------------- /test/test_version.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const version = 1 4 | -------------------------------------------------------------------------------- /test/update_pkg.sh: -------------------------------------------------------------------------------- 1 | current=$(cat $GOPATH/src/github.com/bom-d-van/harp/test/test_version.go | grep -o "[0-9]\{1,\}") 2 | current=$(expr $current + 1) 3 | 4 | cat < $GOPATH/src/github.com/bom-d-van/harp/test/test_version.go 5 | package main 6 | 7 | const version = $current 8 | EOF 9 | 10 | git add $GOPATH/src/github.com/bom-d-van/harp/version.go 11 | 12 | echo $current >> test/files/file1 13 | echo $current >> test/files/file2 14 | -------------------------------------------------------------------------------- /utils.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "archive/tar" 5 | "fmt" 6 | "io" 7 | "os" 8 | "time" 9 | 10 | "golang.org/x/crypto/ssh" 11 | ) 12 | 13 | func writeToTar(tarw *tar.Writer, name string, file io.Reader, fi os.FileInfo) { 14 | header := new(tar.Header) 15 | header.Name = name 16 | header.Size = fi.Size() 17 | header.Mode = int64(fi.Mode()) 18 | header.ModTime = fi.ModTime() 19 | 20 | err := tarw.WriteHeader(header) 21 | if err != nil { 22 | exitf("failed to write tar header for %s: %s", name, err) 23 | } 24 | 25 | _, err = io.Copy(tarw, file) 26 | if err != nil { 27 | exitf("failed to write %s into tar file: %s", name, err) 28 | } 29 | } 30 | 31 | func writeInfoToTar(tarw *tar.Writer, info string) { 32 | header := new(tar.Header) 33 | header.Name = fmt.Sprintf("src/%s/harp-build.info", cfg.App.ImportPath) 34 | header.Size = int64(len(info)) 35 | header.Mode = int64(0644) 36 | header.ModTime = time.Now() 37 | 38 | err := tarw.WriteHeader(header) 39 | if err != nil { 40 | exitf("failed to write tar header for %s: %s", header.Name, err) 41 | } 42 | 43 | _, err = tarw.Write([]byte(info)) 44 | if err != nil { 45 | exitf("failed to write %s into tar file: %s", header.Name, err) 46 | } 47 | } 48 | 49 | func runCmd(sshc *ssh.Client, cmd string) (output []byte) { 50 | session, err := sshc.NewSession() 51 | if err != nil { 52 | exitf("failed to create session: %s", err) 53 | } 54 | defer session.Close() 55 | 56 | output, err = session.CombinedOutput(cmd) 57 | if err != nil { 58 | exitf("failed to exec %s: %s %s", cmd, string(output), err) 59 | } 60 | 61 | return 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/DisposaBoy/JsonConfigReader/AUTHORS.md: -------------------------------------------------------------------------------- 1 | This is the official list of JsonConfigReader authors for copyright purposes. 2 | 3 | * DisposaBoy `https://github.com/DisposaBoy` 4 | * Steven Osborn `https://github.com/steve918` 5 | -------------------------------------------------------------------------------- /vendor/github.com/DisposaBoy/JsonConfigReader/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The JsonConfigReader Authors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /vendor/github.com/DisposaBoy/JsonConfigReader/README.md: -------------------------------------------------------------------------------- 1 | JsonConfigReader is a proxy for [golang's io.Reader](http://golang.org/pkg/io/#Reader) that strips line comments and trailing commas, allowing you to use json as a *reasonable* config format. 2 | 3 | Comments start with `//` and continue to the end of the line. 4 | 5 | If a trailing comma is in front of `]` or `}` it will be stripped as well. 6 | 7 | 8 | Given `settings.json` 9 | 10 | { 11 | "key": "value", // k:v 12 | 13 | // a list of numbers 14 | "list": [1, 2, 3], 15 | } 16 | 17 | 18 | You can read it in as a *normal* json file: 19 | 20 | package main 21 | 22 | import ( 23 | "encoding/json" 24 | "fmt" 25 | "github.com/DisposaBoy/JsonConfigReader" 26 | "os" 27 | ) 28 | 29 | func main() { 30 | var v interface{} 31 | f, _ := os.Open("settings.json") 32 | // wrap our reader before passing it to the json decoder 33 | r := JsonConfigReader.New(f) 34 | json.NewDecoder(r).Decode(&v) 35 | fmt.Println(v) 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/DisposaBoy/JsonConfigReader/reader.go: -------------------------------------------------------------------------------- 1 | package JsonConfigReader 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | ) 7 | 8 | type state struct { 9 | r io.Reader 10 | br *bytes.Reader 11 | } 12 | 13 | func isNL(c byte) bool { 14 | return c == '\n' || c == '\r' 15 | } 16 | 17 | func isWS(c byte) bool { 18 | return c == ' ' || c == '\t' || isNL(c) 19 | } 20 | 21 | func consumeComment(s []byte, i int) int { 22 | if i < len(s) && s[i] == '/' { 23 | s[i-1] = ' ' 24 | for ; i < len(s) && !isNL(s[i]); i += 1 { 25 | s[i] = ' ' 26 | } 27 | } 28 | return i 29 | } 30 | 31 | func prep(r io.Reader) (s []byte, err error) { 32 | buf := &bytes.Buffer{} 33 | _, err = io.Copy(buf, r) 34 | s = buf.Bytes() 35 | if err != nil { 36 | return 37 | } 38 | 39 | i := 0 40 | for i < len(s) { 41 | switch s[i] { 42 | case '"': 43 | i += 1 44 | for i < len(s) { 45 | if s[i] == '"' { 46 | i += 1 47 | break 48 | } else if s[i] == '\\' { 49 | i += 1 50 | } 51 | i += 1 52 | } 53 | case '/': 54 | i = consumeComment(s, i+1) 55 | case ',': 56 | j := i 57 | for { 58 | i += 1 59 | if i >= len(s) { 60 | break 61 | } else if s[i] == '}' || s[i] == ']' { 62 | s[j] = ' ' 63 | break 64 | } else if s[i] == '/' { 65 | i = consumeComment(s, i+1) 66 | } else if !isWS(s[i]) { 67 | break 68 | } 69 | } 70 | default: 71 | i += 1 72 | } 73 | } 74 | return 75 | } 76 | 77 | // Read acts as a proxy for the underlying reader and cleans p 78 | // of comments and trailing commas preceeding ] and } 79 | // comments are delimitted by // up until the end the line 80 | func (st *state) Read(p []byte) (n int, err error) { 81 | if st.br == nil { 82 | var s []byte 83 | if s, err = prep(st.r); err != nil { 84 | return 85 | } 86 | st.br = bytes.NewReader(s) 87 | } 88 | return st.br.Read(p) 89 | } 90 | 91 | // New returns an io.Reader acting as proxy to r 92 | func New(r io.Reader) io.Reader { 93 | return &state{r: r} 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/DisposaBoy/JsonConfigReader/reader_test.go: -------------------------------------------------------------------------------- 1 | package JsonConfigReader 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "strings" 7 | "testing" 8 | ) 9 | 10 | var tests = map[string]string{ 11 | `{ 12 | // a 13 | "x": "y", // b 14 | "x": "y", // c 15 | }`: `{ 16 | 17 | "x": "y", 18 | "x": "y" 19 | }`, 20 | 21 | `// serve a directory 22 | "l/test": [ 23 | { 24 | "handler": "fs", 25 | "dir": "../", 26 | // "strip_prefix": "", 27 | }, 28 | ],`: ` 29 | "l/test": [ 30 | { 31 | "handler": "fs", 32 | "dir": "../" 33 | 34 | } 35 | ],`, 36 | 37 | `[1, 2, 3]`: `[1, 2, 3]`, 38 | `[1, 2, 3, 4,]`: `[1, 2, 3, 4 ]`, 39 | `{"x":1}//[1, 2, 3, 4,]`: `{"x":1} `, 40 | `//////`: ` `, 41 | `{}/ /..`: `{}/ /..`, 42 | `{,}/ /..`: `{ }/ /..`, 43 | `{,}//..`: `{ } `, 44 | `{[],}`: `{[] }`, 45 | `{[,}`: `{[ }`, 46 | `[[",",],]`: `[["," ] ]`, 47 | `[",\"",]`: `[",\"" ]`, 48 | `[",\"\\\",]`: `[",\"\\\",]`, 49 | `[",//"]`: `[",//"]`, 50 | `[",//\" 51 | "],`: `[",//\" 52 | "],`, 53 | } 54 | 55 | func TestMain(t *testing.T) { 56 | for a, b := range tests { 57 | buf := &bytes.Buffer{} 58 | io.Copy(buf, New(strings.NewReader(a))) 59 | a = buf.String() 60 | if a != b { 61 | a = strings.Replace(a, " ", ".", -1) 62 | b = strings.Replace(b, " ", ".", -1) 63 | t.Errorf("reader failed to clean json: expected: `%s`, got `%s`", b, a) 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.4.2 4 | sudo: false 5 | os: 6 | - linux 7 | - osx 8 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2015, Sergey Cherepanov 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/example_copy_test.go: -------------------------------------------------------------------------------- 1 | package pb_test 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "net/http" 7 | "os" 8 | "strconv" 9 | "strings" 10 | "time" 11 | 12 | "github.com/cheggaaa/pb" 13 | ) 14 | 15 | func Example_copy() { 16 | // check args 17 | if len(os.Args) < 3 { 18 | printUsage() 19 | return 20 | } 21 | sourceName, destName := os.Args[1], os.Args[2] 22 | 23 | // check source 24 | var source io.Reader 25 | var sourceSize int64 26 | if strings.HasPrefix(sourceName, "http://") { 27 | // open as url 28 | resp, err := http.Get(sourceName) 29 | if err != nil { 30 | fmt.Printf("Can't get %s: %v\n", sourceName, err) 31 | return 32 | } 33 | defer resp.Body.Close() 34 | if resp.StatusCode != http.StatusOK { 35 | fmt.Printf("Server return non-200 status: %v\n", resp.Status) 36 | return 37 | } 38 | i, _ := strconv.Atoi(resp.Header.Get("Content-Length")) 39 | sourceSize = int64(i) 40 | source = resp.Body 41 | } else { 42 | // open as file 43 | s, err := os.Open(sourceName) 44 | if err != nil { 45 | fmt.Printf("Can't open %s: %v\n", sourceName, err) 46 | return 47 | } 48 | defer s.Close() 49 | // get source size 50 | sourceStat, err := s.Stat() 51 | if err != nil { 52 | fmt.Printf("Can't stat %s: %v\n", sourceName, err) 53 | return 54 | } 55 | sourceSize = sourceStat.Size() 56 | source = s 57 | } 58 | 59 | // create dest 60 | dest, err := os.Create(destName) 61 | if err != nil { 62 | fmt.Printf("Can't create %s: %v\n", destName, err) 63 | return 64 | } 65 | defer dest.Close() 66 | 67 | // create bar 68 | bar := pb.New(int(sourceSize)).SetUnits(pb.U_BYTES).SetRefreshRate(time.Millisecond * 10) 69 | bar.ShowSpeed = true 70 | bar.Start() 71 | 72 | // create proxy reader 73 | reader := bar.NewProxyReader(source) 74 | 75 | // and copy from reader 76 | io.Copy(dest, reader) 77 | bar.Finish() 78 | } 79 | 80 | func printUsage() { 81 | fmt.Println("copy [source file or url] [dest file]") 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/example_multiple_test.go: -------------------------------------------------------------------------------- 1 | package pb_test 2 | 3 | import ( 4 | "math/rand" 5 | "sync" 6 | "time" 7 | 8 | "github.com/cheggaaa/pb" 9 | ) 10 | 11 | func Example_multiple() { 12 | // create bars 13 | first := pb.New(200).Prefix("First ") 14 | second := pb.New(200).Prefix("Second ") 15 | third := pb.New(200).Prefix("Third ") 16 | // start pool 17 | pool, err := pb.StartPool(first, second, third) 18 | if err != nil { 19 | panic(err) 20 | } 21 | // update bars 22 | wg := new(sync.WaitGroup) 23 | for _, bar := range []*pb.ProgressBar{first, second, third} { 24 | wg.Add(1) 25 | go func(cb *pb.ProgressBar) { 26 | for n := 0; n < 200; n++ { 27 | cb.Increment() 28 | time.Sleep(time.Millisecond * time.Duration(rand.Intn(100))) 29 | } 30 | cb.Finish() 31 | wg.Done() 32 | }(bar) 33 | } 34 | wg.Wait() 35 | // close pool 36 | pool.Stop() 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/example_test.go: -------------------------------------------------------------------------------- 1 | package pb_test 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/cheggaaa/pb" 7 | ) 8 | 9 | func Example() { 10 | count := 5000 11 | bar := pb.New(count) 12 | 13 | // show percents (by default already true) 14 | bar.ShowPercent = true 15 | 16 | // show bar (by default already true) 17 | bar.ShowBar = true 18 | 19 | bar.ShowCounters = true 20 | 21 | bar.ShowTimeLeft = true 22 | 23 | // and start 24 | bar.Start() 25 | for i := 0; i < count; i++ { 26 | bar.Increment() 27 | time.Sleep(time.Millisecond) 28 | } 29 | bar.FinishPrint("The End!") 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/format.go: -------------------------------------------------------------------------------- 1 | package pb 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "time" 7 | ) 8 | 9 | type Units int 10 | 11 | const ( 12 | // U_NO are default units, they represent a simple value and are not formatted at all. 13 | U_NO Units = iota 14 | // U_BYTES units are formatted in a human readable way (b, Bb, Mb, ...) 15 | U_BYTES 16 | // U_DURATION units are formatted in a human readable way (3h14m15s) 17 | U_DURATION 18 | ) 19 | 20 | func Format(i int64) *formatter { 21 | return &formatter{n: i} 22 | } 23 | 24 | type formatter struct { 25 | n int64 26 | unit Units 27 | width int 28 | perSec bool 29 | } 30 | 31 | func (f *formatter) Value(n int64) *formatter { 32 | f.n = n 33 | return f 34 | } 35 | 36 | func (f *formatter) To(unit Units) *formatter { 37 | f.unit = unit 38 | return f 39 | } 40 | 41 | func (f *formatter) Width(width int) *formatter { 42 | f.width = width 43 | return f 44 | } 45 | 46 | func (f *formatter) PerSec() *formatter { 47 | f.perSec = true 48 | return f 49 | } 50 | 51 | func (f *formatter) String() (out string) { 52 | switch f.unit { 53 | case U_BYTES: 54 | return formatBytes(f.n) 55 | case U_DURATION: 56 | d := time.Duration(f.n) 57 | if d > time.Hour*24 { 58 | out = fmt.Sprintf("%dd", d/24/time.Hour) 59 | d -= (d / time.Hour / 24) * (time.Hour * 24) 60 | } 61 | out = fmt.Sprintf("%s%v", out, d) 62 | default: 63 | out = fmt.Sprintf(fmt.Sprintf("%%%dd", f.width), f.n) 64 | } 65 | if f.perSec { 66 | out += "/s" 67 | } 68 | return 69 | } 70 | 71 | // Convert bytes to human readable string. Like a 2 MB, 64.2 KB, 52 B 72 | func formatBytes(i int64) (result string) { 73 | switch { 74 | case i > (1024 * 1024 * 1024 * 1024): 75 | result = fmt.Sprintf("%.02f TB", float64(i)/1024/1024/1024/1024) 76 | case i > (1024 * 1024 * 1024): 77 | result = fmt.Sprintf("%.02f GB", float64(i)/1024/1024/1024) 78 | case i > (1024 * 1024): 79 | result = fmt.Sprintf("%.02f MB", float64(i)/1024/1024) 80 | case i > 1024: 81 | result = fmt.Sprintf("%.02f KB", float64(i)/1024) 82 | default: 83 | result = fmt.Sprintf("%d B", i) 84 | } 85 | result = strings.Trim(result, " ") 86 | return 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/format_test.go: -------------------------------------------------------------------------------- 1 | package pb_test 2 | 3 | import ( 4 | "fmt" 5 | "github.com/cheggaaa/pb" 6 | "strconv" 7 | "testing" 8 | "time" 9 | ) 10 | 11 | func Test_DefaultsToInteger(t *testing.T) { 12 | value := int64(1000) 13 | expected := strconv.Itoa(int(value)) 14 | actual := pb.Format(value).String() 15 | 16 | if actual != expected { 17 | t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual)) 18 | } 19 | } 20 | 21 | func Test_CanFormatAsInteger(t *testing.T) { 22 | value := int64(1000) 23 | expected := strconv.Itoa(int(value)) 24 | actual := pb.Format(value).To(pb.U_NO).String() 25 | 26 | if actual != expected { 27 | t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual)) 28 | } 29 | } 30 | 31 | func Test_CanFormatAsBytes(t *testing.T) { 32 | value := int64(1000) 33 | expected := "1000 B" 34 | actual := pb.Format(value).To(pb.U_BYTES).String() 35 | 36 | if actual != expected { 37 | t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual)) 38 | } 39 | } 40 | 41 | func Test_CanFormatDuration(t *testing.T) { 42 | value := 10 * time.Minute 43 | expected := "10m0s" 44 | actual := pb.Format(int64(value)).To(pb.U_DURATION).String() 45 | if actual != expected { 46 | t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual)) 47 | } 48 | } 49 | 50 | func Test_DefaultUnitsWidth(t *testing.T) { 51 | value := 10 52 | expected := " 10" 53 | actual := pb.Format(int64(value)).Width(7).String() 54 | if actual != expected { 55 | t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual)) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/pb_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package pb 4 | 5 | import "errors" 6 | 7 | // terminalWidth returns width of the terminal, which is not supported 8 | // and should always failed on appengine classic which is a sandboxed PaaS. 9 | func terminalWidth() (int, error) { 10 | return 0, errors.New("Not supported") 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/pb_nix.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd netbsd openbsd dragonfly 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | import "syscall" 7 | 8 | const sysIoctl = syscall.SYS_IOCTL 9 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/pb_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | const sysIoctl = 54 7 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/pb_test.go: -------------------------------------------------------------------------------- 1 | package pb 2 | 3 | import ( 4 | "strings" 5 | "testing" 6 | 7 | "github.com/fatih/color" 8 | "github.com/mattn/go-colorable" 9 | ) 10 | 11 | func Test_IncrementAddsOne(t *testing.T) { 12 | count := 5000 13 | bar := New(count) 14 | expected := 1 15 | actual := bar.Increment() 16 | 17 | if actual != expected { 18 | t.Errorf("Expected {%d} was {%d}", expected, actual) 19 | } 20 | } 21 | 22 | func Test_Width(t *testing.T) { 23 | count := 5000 24 | bar := New(count) 25 | width := 100 26 | bar.SetWidth(100).Callback = func(out string) { 27 | if len(out) != width { 28 | t.Errorf("Bar width expected {%d} was {%d}", len(out), width) 29 | } 30 | } 31 | bar.Start() 32 | bar.Increment() 33 | bar.Finish() 34 | } 35 | 36 | func Test_MultipleFinish(t *testing.T) { 37 | bar := New(5000) 38 | bar.Add(2000) 39 | bar.Finish() 40 | bar.Finish() 41 | } 42 | 43 | func Test_Format(t *testing.T) { 44 | bar := New(5000).Format(strings.Join([]string{ 45 | color.GreenString("["), 46 | color.New(color.BgGreen).SprintFunc()("o"), 47 | color.New(color.BgHiGreen).SprintFunc()("o"), 48 | color.New(color.BgRed).SprintFunc()("o"), 49 | color.GreenString("]"), 50 | }, "\x00")) 51 | w := colorable.NewColorableStdout() 52 | bar.Callback = func(out string) { 53 | w.Write([]byte(out)) 54 | } 55 | bar.Add(2000) 56 | bar.Finish() 57 | bar.Finish() 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/pb_win.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package pb 4 | 5 | import ( 6 | "os" 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | var tty = os.Stdin 12 | 13 | var ( 14 | kernel32 = syscall.NewLazyDLL("kernel32.dll") 15 | 16 | // GetConsoleScreenBufferInfo retrieves information about the 17 | // specified console screen buffer. 18 | // http://msdn.microsoft.com/en-us/library/windows/desktop/ms683171(v=vs.85).aspx 19 | procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo") 20 | ) 21 | 22 | type ( 23 | // Defines the coordinates of the upper left and lower right corners 24 | // of a rectangle. 25 | // See 26 | // http://msdn.microsoft.com/en-us/library/windows/desktop/ms686311(v=vs.85).aspx 27 | smallRect struct { 28 | Left, Top, Right, Bottom int16 29 | } 30 | 31 | // Defines the coordinates of a character cell in a console screen 32 | // buffer. The origin of the coordinate system (0,0) is at the top, left cell 33 | // of the buffer. 34 | // See 35 | // http://msdn.microsoft.com/en-us/library/windows/desktop/ms682119(v=vs.85).aspx 36 | coordinates struct { 37 | X, Y int16 38 | } 39 | 40 | word int16 41 | 42 | // Contains information about a console screen buffer. 43 | // http://msdn.microsoft.com/en-us/library/windows/desktop/ms682093(v=vs.85).aspx 44 | consoleScreenBufferInfo struct { 45 | dwSize coordinates 46 | dwCursorPosition coordinates 47 | wAttributes word 48 | srWindow smallRect 49 | dwMaximumWindowSize coordinates 50 | } 51 | ) 52 | 53 | // terminalWidth returns width of the terminal. 54 | func terminalWidth() (width int, err error) { 55 | var info consoleScreenBufferInfo 56 | _, _, e := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(syscall.Stdout), uintptr(unsafe.Pointer(&info)), 0) 57 | if e != 0 { 58 | return 0, error(e) 59 | } 60 | return int(info.dwSize.X), nil 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/pool.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd netbsd openbsd solaris dragonfly 2 | 3 | package pb 4 | 5 | import ( 6 | "fmt" 7 | "sync" 8 | "time" 9 | ) 10 | 11 | // Create and start new pool with given bars 12 | // You need call pool.Stop() after work 13 | func StartPool(pbs ...*ProgressBar) (pool *Pool, err error) { 14 | pool = new(Pool) 15 | if err = pool.start(); err != nil { 16 | return 17 | } 18 | pool.add(pbs...) 19 | return 20 | } 21 | 22 | type Pool struct { 23 | RefreshRate time.Duration 24 | bars []*ProgressBar 25 | quit chan int 26 | finishOnce sync.Once 27 | } 28 | 29 | func (p *Pool) add(pbs ...*ProgressBar) { 30 | for _, bar := range pbs { 31 | bar.ManualUpdate = true 32 | bar.NotPrint = true 33 | bar.Start() 34 | p.bars = append(p.bars, bar) 35 | } 36 | } 37 | 38 | func (p *Pool) start() (err error) { 39 | p.RefreshRate = DefaultRefreshRate 40 | quit, err := lockEcho() 41 | if err != nil { 42 | return 43 | } 44 | p.quit = make(chan int) 45 | go p.writer(quit) 46 | return 47 | } 48 | 49 | func (p *Pool) writer(finish chan int) { 50 | var first = true 51 | for { 52 | select { 53 | case <-time.After(p.RefreshRate): 54 | if p.print(first) { 55 | p.print(false) 56 | finish <- 1 57 | return 58 | } 59 | first = false 60 | case <-p.quit: 61 | finish <- 1 62 | return 63 | } 64 | } 65 | } 66 | 67 | func (p *Pool) print(first bool) bool { 68 | var out string 69 | if !first { 70 | out = fmt.Sprintf("\033[%dA", len(p.bars)) 71 | } 72 | isFinished := true 73 | for _, bar := range p.bars { 74 | if !bar.isFinish { 75 | isFinished = false 76 | } 77 | bar.Update() 78 | out += fmt.Sprintf("\r%s\n", bar.String()) 79 | } 80 | fmt.Print(out) 81 | return isFinished 82 | } 83 | 84 | // Restore terminal state and close pool 85 | func (p *Pool) Stop() error { 86 | // Wait until one final refresh has passed. 87 | time.Sleep(p.RefreshRate) 88 | 89 | p.finishOnce.Do(func() { 90 | close(p.quit) 91 | }) 92 | return unlockEcho() 93 | } 94 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/reader.go: -------------------------------------------------------------------------------- 1 | package pb 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | // It's proxy reader, implement io.Reader 8 | type Reader struct { 9 | io.Reader 10 | bar *ProgressBar 11 | } 12 | 13 | func (r *Reader) Read(p []byte) (n int, err error) { 14 | n, err = r.Reader.Read(p) 15 | r.bar.Add(n) 16 | return 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/runecount.go: -------------------------------------------------------------------------------- 1 | package pb 2 | 3 | import ( 4 | "regexp" 5 | "unicode/utf8" 6 | ) 7 | 8 | // Finds the control character sequences (like colors) 9 | var ctrlFinder = regexp.MustCompile("\x1b\x5b[0-9]+\x6d") 10 | 11 | func escapeAwareRuneCountInString(s string) int { 12 | n := utf8.RuneCountInString(s) 13 | for _, sm := range ctrlFinder.FindAllString(s, -1) { 14 | n -= len(sm) 15 | } 16 | return n 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/runecount_test.go: -------------------------------------------------------------------------------- 1 | package pb 2 | 3 | import "testing" 4 | 5 | func Test_RuneCount(t *testing.T) { 6 | s := string([]byte{ 7 | 27, 91, 51, 49, 109, // {Red} 8 | 72, 101, 108, 108, 111, // Hello 9 | 44, 32, // , 10 | 112, 108, 97, 121, 103, 114, 111, 117, 110, 100, // Playground 11 | 27, 91, 48, 109, // {Reset} 12 | }) 13 | if e, l := 17, escapeAwareRuneCountInString(s); l != e { 14 | t.Errorf("Invalid length %d, expected %d", l, e) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/termios_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd netbsd openbsd dragonfly 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | import "syscall" 7 | 8 | const ioctlReadTermios = syscall.TIOCGETA 9 | const ioctlWriteTermios = syscall.TIOCSETA 10 | -------------------------------------------------------------------------------- /vendor/github.com/cheggaaa/pb/termios_nix.go: -------------------------------------------------------------------------------- 1 | // +build linux solaris 2 | // +build !appengine 3 | 4 | package pb 5 | 6 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 7 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 8 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.tmp 3 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.5 4 | before_install: 5 | - go get golang.org/x/crypto/ssh/terminal 6 | script: 7 | - GOOS=windows go install github.com/chzyer/readline/example/... 8 | - GOOS=linux go install github.com/chzyer/readline/example/... 9 | - GOOS=darwin go install github.com/chzyer/readline/example/... 10 | - go test -v 11 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # ChangeLog 2 | 3 | ### 1.1 - 2015-11-20 4 | 5 | * #12 Add support for key ``/``/`` 6 | * Only enter raw mode as needed (calling `Readline()`), program will receive signal(e.g. Ctrl+C) if not interact with `readline`. 7 | * Bugs fixed for `PrefixCompleter` 8 | * Press `Ctrl+D` in empty line will cause `io.EOF` in error, Press `Ctrl+C` in anytime will cause `ErrInterrupt` instead of `io.EOF`, this will privodes a shell-like user experience. 9 | * Customable Interrupt/EOF prompt in `Config` 10 | * #17 Change atomic package to use 32bit function to let it runnable on arm 32bit devices 11 | * Provides a new password user experience(`readline.ReadPasswordEx()`). 12 | 13 | ### 1.0 - 2015-10-14 14 | 15 | * Initial public release. 16 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Chzyer 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/github.com/chzyer/readline/char.go: -------------------------------------------------------------------------------- 1 | package readline 2 | 3 | const ( 4 | CharLineStart = 1 5 | CharBackward = 2 6 | CharInterrupt = 3 7 | CharDelete = 4 8 | CharLineEnd = 5 9 | CharForward = 6 10 | CharBell = 7 11 | CharCtrlH = 8 12 | CharTab = 9 13 | CharCtrlJ = 10 14 | CharKill = 11 15 | CharEnter = 13 16 | CharNext = 14 17 | CharPrev = 16 18 | CharBckSearch = 18 19 | CharFwdSearch = 19 20 | CharTranspose = 20 21 | CharCtrlU = 21 22 | CharCtrlW = 23 23 | CharEsc = 27 24 | CharEscapeEx = 91 25 | CharBackspace = 127 26 | ) 27 | 28 | const ( 29 | MetaBackward rune = -iota - 1 30 | MetaForward 31 | MetaDelete 32 | MetaBackspace 33 | MetaTranspose 34 | ) 35 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/debug.go: -------------------------------------------------------------------------------- 1 | package readline 2 | 3 | import ( 4 | "container/list" 5 | "fmt" 6 | "os" 7 | "time" 8 | ) 9 | 10 | func sleep(n int) { 11 | Debug(n) 12 | time.Sleep(2000 * time.Millisecond) 13 | } 14 | 15 | // print a linked list to Debug() 16 | func debugList(l *list.List) { 17 | idx := 0 18 | for e := l.Front(); e != nil; e = e.Next() { 19 | Debug(idx, fmt.Sprintf("%+v", e.Value)) 20 | idx++ 21 | } 22 | } 23 | 24 | // append log info to another file 25 | func Debug(o ...interface{}) { 26 | f, _ := os.OpenFile("debug.tmp", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) 27 | fmt.Fprintln(f, o...) 28 | f.Close() 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/doc.go: -------------------------------------------------------------------------------- 1 | // Readline is a pure go implementation for GNU-Readline kind library. 2 | // 3 | // WHY: Readline will support most of features which GNU Readline is supported, and provide a pure go environment and a MIT license. 4 | // 5 | // example: 6 | // rl, err := readline.New("> ") 7 | // if err != nil { 8 | // panic(err) 9 | // } 10 | // defer rl.Close() 11 | // 12 | // for { 13 | // line, err := rl.Readline() 14 | // if err != nil { // io.EOF 15 | // break 16 | // } 17 | // println(line) 18 | // } 19 | // 20 | package readline 21 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/example/readline-multiline/readline-multiline.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/chzyer/readline" 7 | ) 8 | 9 | func main() { 10 | rl, err := readline.NewEx(&readline.Config{ 11 | Prompt: "> ", 12 | HistoryFile: "/tmp/readline-multiline", 13 | DisableAutoSaveHistory: true, 14 | }) 15 | if err != nil { 16 | panic(err) 17 | } 18 | defer rl.Close() 19 | 20 | var cmds []string 21 | for { 22 | line, err := rl.Readline() 23 | if err != nil { 24 | break 25 | } 26 | line = strings.TrimSpace(line) 27 | if len(line) == 0 { 28 | continue 29 | } 30 | cmds = append(cmds, line) 31 | if !strings.Contains(line, ";") { 32 | rl.SetPrompt(">>> ") 33 | continue 34 | } 35 | cmd := strings.Join(cmds, " ") 36 | cmds = cmds[:0] 37 | rl.SetPrompt("> ") 38 | rl.SaveHistory(cmd) 39 | println(cmd) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/password.go: -------------------------------------------------------------------------------- 1 | package readline 2 | 3 | type opPassword struct { 4 | o *Operation 5 | backupCfg *Config 6 | } 7 | 8 | func newOpPassword(o *Operation) *opPassword { 9 | return &opPassword{o: o} 10 | } 11 | 12 | func (o *opPassword) ExitPasswordMode() { 13 | o.o.SetConfig(o.backupCfg) 14 | o.backupCfg = nil 15 | } 16 | 17 | func (o *opPassword) EnterPasswordMode(cfg *Config) (err error) { 18 | o.backupCfg, err = o.o.SetConfig(cfg) 19 | return 20 | } 21 | 22 | func (o *opPassword) PasswordConfig() *Config { 23 | return &Config{ 24 | MaskRune: '*', 25 | InterruptPrompt: "\n", 26 | EOFPrompt: "\n", 27 | HistoryLimit: -1, 28 | 29 | Stdout: o.o.cfg.Stdout, 30 | Stderr: o.o.cfg.Stderr, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/remote.go: -------------------------------------------------------------------------------- 1 | package readline 2 | 3 | import ( 4 | "io" 5 | "net" 6 | "os" 7 | ) 8 | 9 | type Conn struct { 10 | Conn net.Conn 11 | Terminal *Terminal 12 | runChan chan error 13 | } 14 | 15 | func NewConn(conn net.Conn, t *Terminal) (*Conn, error) { 16 | return &Conn{ 17 | Conn: conn, 18 | Terminal: t, 19 | runChan: make(chan error), 20 | }, nil 21 | } 22 | 23 | func (c *Conn) Run() error { 24 | c.Terminal.EnterRawMode() 25 | go func() { 26 | _, err := io.Copy(c.Conn, os.Stdin) 27 | c.runChan <- err 28 | }() 29 | go func() { 30 | _, err := io.Copy(os.Stdout, c.Conn) 31 | c.runChan <- err 32 | }() 33 | err := <-c.runChan 34 | c.Terminal.ExitRawMode() 35 | return err 36 | } 37 | 38 | func Dial(network string, address string) (*Conn, error) { 39 | conn, err := net.Dial(network, address) 40 | if err != nil { 41 | return nil, err 42 | } 43 | var cfg Config 44 | t, err := NewTerminal(&cfg) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return NewConn(conn, t) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/runes/runes_test.go: -------------------------------------------------------------------------------- 1 | package runes 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | type twidth struct { 9 | r []rune 10 | length int 11 | } 12 | 13 | func TestRuneWidth(t *testing.T) { 14 | runes := []twidth{ 15 | {[]rune("☭"), 1}, 16 | {[]rune("a"), 1}, 17 | {[]rune("你"), 2}, 18 | {ColorFilter([]rune("☭\033[13;1m你")), 3}, 19 | } 20 | for _, r := range runes { 21 | if w := WidthAll(r.r); w != r.length { 22 | t.Fatal("result not expect", r.r, r.length, w) 23 | } 24 | } 25 | } 26 | 27 | type tagg struct { 28 | r [][]rune 29 | e [][]rune 30 | length int 31 | } 32 | 33 | func TestAggRunes(t *testing.T) { 34 | runes := []tagg{ 35 | { 36 | [][]rune{[]rune("ab"), []rune("a"), []rune("abc")}, 37 | [][]rune{[]rune("b"), []rune(""), []rune("bc")}, 38 | 1, 39 | }, 40 | { 41 | [][]rune{[]rune("addb"), []rune("ajkajsdf"), []rune("aasdfkc")}, 42 | [][]rune{[]rune("ddb"), []rune("jkajsdf"), []rune("asdfkc")}, 43 | 1, 44 | }, 45 | { 46 | [][]rune{[]rune("ddb"), []rune("ajksdf"), []rune("aasdfkc")}, 47 | [][]rune{[]rune("ddb"), []rune("ajksdf"), []rune("aasdfkc")}, 48 | 0, 49 | }, 50 | { 51 | [][]rune{[]rune("ddb"), []rune("ddajksdf"), []rune("ddaasdfkc")}, 52 | [][]rune{[]rune("b"), []rune("ajksdf"), []rune("aasdfkc")}, 53 | 2, 54 | }, 55 | } 56 | for _, r := range runes { 57 | same, off := Aggregate(r.r) 58 | if off != r.length { 59 | t.Fatal("result not expect", off) 60 | } 61 | if len(same) != off { 62 | t.Fatal("result not expect", same) 63 | } 64 | if !reflect.DeepEqual(r.r, r.e) { 65 | t.Fatal("result not expect") 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/std.go: -------------------------------------------------------------------------------- 1 | package readline 2 | 3 | import ( 4 | "io" 5 | "os" 6 | "sync" 7 | ) 8 | 9 | var ( 10 | Stdin io.ReadCloser = os.Stdin 11 | Stdout io.WriteCloser = os.Stdout 12 | Stderr io.WriteCloser = os.Stderr 13 | ) 14 | 15 | var ( 16 | std *Instance 17 | stdOnce sync.Once 18 | ) 19 | 20 | func getInstance() *Instance { 21 | stdOnce.Do(func() { 22 | std, _ = NewEx(&Config{ 23 | DisableAutoSaveHistory: true, 24 | }) 25 | }) 26 | return std 27 | } 28 | 29 | func SetHistoryPath(fp string) { 30 | ins := getInstance() 31 | cfg := ins.Config.Clone() 32 | cfg.HistoryFile = fp 33 | ins.SetConfig(cfg) 34 | } 35 | 36 | func AddHistory(content string) error { 37 | ins := getInstance() 38 | return ins.SaveHistory(content) 39 | } 40 | 41 | func Line(prompt string) (string, error) { 42 | ins := getInstance() 43 | ins.SetPrompt(prompt) 44 | return ins.Readline() 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/std_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package readline 4 | 5 | func init() { 6 | Stdin = NewRawReader() 7 | Stdout = NewANSIWriter(Stdout) 8 | Stderr = NewANSIWriter(Stderr) 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/utils_test.go: -------------------------------------------------------------------------------- 1 | package readline 2 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/utils_unix.go: -------------------------------------------------------------------------------- 1 | // +build darwin dragonfly freebsd linux,!appengine netbsd openbsd 2 | 3 | package readline 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | type winsize struct { 11 | Row uint16 12 | Col uint16 13 | Xpixel uint16 14 | Ypixel uint16 15 | } 16 | 17 | // get width of the terminal 18 | func getWidth(stdoutFd int) int { 19 | ws := &winsize{} 20 | retCode, _, errno := syscall.Syscall(syscall.SYS_IOCTL, 21 | uintptr(stdoutFd), 22 | uintptr(syscall.TIOCGWINSZ), 23 | uintptr(unsafe.Pointer(ws))) 24 | 25 | if int(retCode) == -1 { 26 | _ = errno 27 | return -1 28 | } 29 | return int(ws.Col) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/utils_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package readline 4 | 5 | func init() { 6 | isWindows = true 7 | } 8 | 9 | // get width of the terminal 10 | func getWidth(fd int) int { 11 | info, _ := GetConsoleScreenBufferInfo() 12 | if info == nil { 13 | return -1 14 | } 15 | return int(info.dwSize.x) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 1.2 3 | install: 4 | - go get -v code.google.com/p/go.tools/cmd/cover 5 | script: 6 | - go test -v -tags=disableunsafe ./spew 7 | - go test -v -tags=testcgo ./spew -covermode=count -coverprofile=profile.cov 8 | after_success: 9 | - go get -v github.com/mattn/goveralls 10 | - export PATH=$PATH:$HOME/gopath/bin 11 | - goveralls -coverprofile=profile.cov -service=travis-ci 12 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2013 Dave Collins 2 | 3 | Permission to use, copy, modify, and distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/cov_report.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script uses gocov to generate a test coverage report. 4 | # The gocov tool my be obtained with the following command: 5 | # go get github.com/axw/gocov/gocov 6 | # 7 | # It will be installed to $GOPATH/bin, so ensure that location is in your $PATH. 8 | 9 | # Check for gocov. 10 | if ! type gocov >/dev/null 2>&1; then 11 | echo >&2 "This script requires the gocov tool." 12 | echo >&2 "You may obtain it with the following command:" 13 | echo >&2 "go get github.com/axw/gocov/gocov" 14 | exit 1 15 | fi 16 | 17 | # Only run the cgo tests if gcc is installed. 18 | if type gcc >/dev/null 2>&1; then 19 | (cd spew && gocov test -tags testcgo | gocov report) 20 | else 21 | (cd spew && gocov test | gocov report) 22 | fi 23 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when either the code is running on Google App Engine or "-tags disableunsafe" 17 | // is added to the go build command line. 18 | // +build appengine disableunsafe 19 | 20 | package spew 21 | 22 | import "reflect" 23 | 24 | const ( 25 | // UnsafeDisabled is a build-time constant which specifies whether or 26 | // not access to the unsafe package is available. 27 | UnsafeDisabled = true 28 | ) 29 | 30 | // unsafeReflectValue typically converts the passed reflect.Value into a one 31 | // that bypasses the typical safety restrictions preventing access to 32 | // unaddressable and unexported data. However, doing this relies on access to 33 | // the unsafe package. This is a stub version which simply returns the passed 34 | // reflect.Value when the unsafe package is not available. 35 | func unsafeReflectValue(v reflect.Value) reflect.Value { 36 | return v 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when either cgo is not supported or "-tags testcgo" is not added to the go 17 | // test command line. This file intentionally does not setup any cgo tests in 18 | // this scenario. 19 | // +build !cgo !testcgo 20 | 21 | package spew_test 22 | 23 | func addCgoDumpTests() { 24 | // Don't add any tests for cgo since this file is only compiled when 25 | // there should not be any cgo tests. 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/.gitignore: -------------------------------------------------------------------------------- 1 | zxcvbn 2 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/nbutton23/zxcvbn-go", 3 | "GoVersion": "go1.5", 4 | "Packages": [ 5 | "./..." 6 | ], 7 | "Deps": [ 8 | { 9 | "ImportPath": "github.com/davecgh/go-spew/spew", 10 | "Rev": "5215b55f46b2b919f50a1df0eaa5886afe4e3b3d" 11 | }, 12 | { 13 | "ImportPath": "github.com/pmezard/go-difflib/difflib", 14 | "Rev": "e8554b8641db39598be7f6342874b958f12ae1d4" 15 | }, 16 | { 17 | "ImportPath": "github.com/stretchr/testify/assert", 18 | "Comment": "v1.1.1", 19 | "Rev": "38b5d653e3cad9252e69070a3fe23377ab380557" 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/.gitignore: -------------------------------------------------------------------------------- 1 | /pkg 2 | /bin 3 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/nbutton23/zxcvbn-go/Godeps/_workspace", 3 | "GoVersion": "go1.5", 4 | "Packages": [ 5 | "./..." 6 | ], 7 | "Deps": [] 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/Godeps/_workspace/.gitignore: -------------------------------------------------------------------------------- 1 | /pkg 2 | /bin 3 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/src/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2013 Dave Collins 2 | 3 | Permission to use, copy, modify, and distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/src/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when either the code is running on Google App Engine or "-tags disableunsafe" 17 | // is added to the go build command line. 18 | // +build appengine disableunsafe 19 | 20 | package spew 21 | 22 | import "reflect" 23 | 24 | const ( 25 | // UnsafeDisabled is a build-time constant which specifies whether or 26 | // not access to the unsafe package is available. 27 | UnsafeDisabled = true 28 | ) 29 | 30 | // unsafeReflectValue typically converts the passed reflect.Value into a one 31 | // that bypasses the typical safety restrictions preventing access to 32 | // unaddressable and unexported data. However, doing this relies on access to 33 | // the unsafe package. This is a stub version which simply returns the passed 34 | // reflect.Value when the unsafe package is not available. 35 | func unsafeReflectValue(v reflect.Value) reflect.Value { 36 | return v 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/src/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | 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 copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/src/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/src/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 4 | } 5 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/src/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/src/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/src/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl 17 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/src/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2013 Dave Collins 2 | 3 | Permission to use, copy, modify, and distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/src/github.com/stretchr/testify/vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | 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 copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/Godeps/_workspace/src/github.com/stretchr/testify/vendor/github.com/stretchr/objx/LICENSE.md: -------------------------------------------------------------------------------- 1 | objx - by Mat Ryer and Tyler Bunnell 2 | 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 2014 Stretchr, Inc. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) Nathan Button 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/adjacency/adjacmartix_test.go: -------------------------------------------------------------------------------- 1 | package adjacency 2 | 3 | import ( 4 | "github.com/nbutton23/zxcvbn-go/Godeps/_workspace/src/github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | /* 9 | nbutton: Really the value is not as important to me than they don't change, which happened during development. 10 | */ 11 | func TestCalculateDegreeQwert(t *testing.T) { 12 | avgDegreeQwert := BuildQwerty().CalculateAvgDegree() 13 | 14 | assert.Equal(t, float64(1.5319148936170213), avgDegreeQwert, "Avg degree for qwerty should be 1.5319148936170213") 15 | } 16 | 17 | func TestCalculateDegreeDvorak(t *testing.T) { 18 | avgDegreeQwert := BuildDvorak().CalculateAvgDegree() 19 | 20 | assert.Equal(t, float64(1.5319148936170213), avgDegreeQwert, "Avg degree for dvorak should be 1.53191489361702135") 21 | } 22 | 23 | func TestCalculateDegreeKeypad(t *testing.T) { 24 | avgDegreeQwert := BuildKeypad().CalculateAvgDegree() 25 | 26 | assert.Equal(t, float64(0.6333333333333333), avgDegreeQwert, "Avg degree for keypad should be 0.6333333333333333") 27 | } 28 | 29 | func TestCalculateDegreeMacKepad(t *testing.T) { 30 | avgDegreeQwert := BuildMacKeypad().CalculateAvgDegree() 31 | 32 | assert.Equal(t, float64(0.65625), avgDegreeQwert, "Avg degree for mackeyPad should be 0.65625") 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/data/data/L33t.json: -------------------------------------------------------------------------------- 1 | { 2 | "graph": { 3 | "a": [ 4 | "4", 5 | "@" 6 | ], 7 | "b": [ 8 | "8" 9 | ], 10 | "c": [ 11 | "(", 12 | "{", 13 | "[", 14 | "<" 15 | ], 16 | "e": [ 17 | "3" 18 | ], 19 | "g": [ 20 | "6", 21 | "9" 22 | ], 23 | "i": [ 24 | "1", 25 | "!", 26 | "|" 27 | ], 28 | "l": [ 29 | "1", 30 | "|", 31 | "7" 32 | ], 33 | "o": [ 34 | "0" 35 | ], 36 | "s": [ 37 | "$", 38 | "5" 39 | ], 40 | "t": [ 41 | "+", 42 | "7" 43 | ], 44 | "x": [ 45 | "%" 46 | ], 47 | "z": [ 48 | "2" 49 | ] 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/frequency/frequency.go: -------------------------------------------------------------------------------- 1 | package frequency 2 | 3 | import ( 4 | "encoding/json" 5 | "github.com/nbutton23/zxcvbn-go/data" 6 | "log" 7 | ) 8 | 9 | type FrequencyList struct { 10 | Name string 11 | List []string 12 | } 13 | 14 | var FrequencyLists = make(map[string]FrequencyList) 15 | 16 | func init() { 17 | maleFilePath := getAsset("data/MaleNames.json") 18 | femaleFilePath := getAsset("data/FemaleNames.json") 19 | surnameFilePath := getAsset("data/Surnames.json") 20 | englishFilePath := getAsset("data/English.json") 21 | passwordsFilePath := getAsset("data/Passwords.json") 22 | 23 | FrequencyLists["MaleNames"] = GetStringListFromAsset(maleFilePath, "MaleNames") 24 | FrequencyLists["FemaleNames"] = GetStringListFromAsset(femaleFilePath, "FemaleNames") 25 | FrequencyLists["Surname"] = GetStringListFromAsset(surnameFilePath, "Surname") 26 | FrequencyLists["English"] = GetStringListFromAsset(englishFilePath, "English") 27 | FrequencyLists["Passwords"] = GetStringListFromAsset(passwordsFilePath, "Passwords") 28 | 29 | } 30 | func getAsset(name string) []byte { 31 | data, err := zxcvbn_data.Asset(name) 32 | if err != nil { 33 | panic("Error getting asset " + name) 34 | } 35 | 36 | return data 37 | } 38 | func GetStringListFromAsset(data []byte, name string) FrequencyList { 39 | 40 | var tempList FrequencyList 41 | err := json.Unmarshal(data, &tempList) 42 | if err != nil { 43 | log.Fatal(err) 44 | } 45 | tempList.Name = name 46 | return tempList 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/match/match.go: -------------------------------------------------------------------------------- 1 | package match 2 | 3 | type Matches []Match 4 | 5 | func (s Matches) Len() int { 6 | return len(s) 7 | } 8 | func (s Matches) Swap(i, j int) { 9 | s[i], s[j] = s[j], s[i] 10 | } 11 | func (s Matches) Less(i, j int) bool { 12 | if s[i].I < s[j].I { 13 | return true 14 | } else if s[i].I == s[j].I { 15 | return s[i].J < s[j].J 16 | } else { 17 | return false 18 | } 19 | } 20 | 21 | type Match struct { 22 | Pattern string 23 | I, J int 24 | Token string 25 | DictionaryName string 26 | Entropy float64 27 | } 28 | 29 | type DateMatch struct { 30 | Pattern string 31 | I, J int 32 | Token string 33 | Separator string 34 | Day, Month, Year int64 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/utils/math/mathutils.go: -------------------------------------------------------------------------------- 1 | package zxcvbn_math 2 | 3 | import "math" 4 | 5 | /** 6 | I am surprised that I have to define these. . . Maybe i just didn't look hard enough for a lib. 7 | */ 8 | 9 | //http://blog.plover.com/math/choose.html 10 | func NChoseK(n, k float64) float64 { 11 | if k > n { 12 | return 0 13 | } else if k == 0 { 14 | return 1 15 | } 16 | 17 | var r float64 = 1 18 | 19 | for d := float64(1); d <= k; d++ { 20 | r *= n 21 | r /= d 22 | n-- 23 | } 24 | 25 | return r 26 | } 27 | 28 | func Round(val float64, roundOn float64, places int) (newVal float64) { 29 | var round float64 30 | pow := math.Pow(10, float64(places)) 31 | digit := pow * val 32 | _, div := math.Modf(digit) 33 | if div >= roundOn { 34 | round = math.Ceil(digit) 35 | } else { 36 | round = math.Floor(digit) 37 | } 38 | newVal = round / pow 39 | return 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/utils/math/mathutils_test.go: -------------------------------------------------------------------------------- 1 | package zxcvbn_math 2 | 3 | import ( 4 | "github.com/nbutton23/zxcvbn-go/Godeps/_workspace/src/github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestNchoseK100and2(t *testing.T) { 9 | nCk := NChoseK(100, 2) 10 | 11 | assert.Equal(t, float64(4950), nCk, "100 chose 2 should equal 4950") 12 | } 13 | 14 | func TestNChoseKwereNlessK(t *testing.T) { 15 | nCk := NChoseK(1, 2) 16 | 17 | assert.Equal(t, float64(0), nCk, "When n is less than k always 0") 18 | } 19 | 20 | func TestNChoseKWereKis0(t *testing.T) { 21 | nCk := NChoseK(50, 0) 22 | 23 | assert.Equal(t, float64(1), nCk, "When K is 0 then 1") 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/nbutton23/zxcvbn-go/zxcvbn.go: -------------------------------------------------------------------------------- 1 | package zxcvbn 2 | 3 | import ( 4 | "github.com/nbutton23/zxcvbn-go/matching" 5 | "github.com/nbutton23/zxcvbn-go/scoring" 6 | "github.com/nbutton23/zxcvbn-go/utils/math" 7 | "time" 8 | ) 9 | 10 | //func main() { 11 | // password :="Testaaatyhg890l33t" 12 | // fmt.Println(PasswordStrength(password, nil)) 13 | //} 14 | 15 | func PasswordStrength(password string, userInputs []string) scoring.MinEntropyMatch { 16 | start := time.Now() 17 | matches := matching.Omnimatch(password, userInputs) 18 | result := scoring.MinimumEntropyMatchSequence(password, matches) 19 | end := time.Now() 20 | 21 | calcTime := end.Nanosecond() - start.Nanosecond() 22 | result.CalcTime = zxcvbn_math.Round(float64(calcTime)*time.Nanosecond.Seconds(), .5, 3) 23 | return result 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.5 4 | - tip 5 | 6 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | 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 copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/README.md: -------------------------------------------------------------------------------- 1 | go-difflib 2 | ========== 3 | 4 | [![Build Status](https://travis-ci.org/pmezard/go-difflib.png?branch=master)](https://travis-ci.org/pmezard/go-difflib) 5 | [![GoDoc](https://godoc.org/github.com/pmezard/go-difflib/difflib?status.svg)](https://godoc.org/github.com/pmezard/go-difflib/difflib) 6 | 7 | Go-difflib is a partial port of python 3 difflib package. Its main goal 8 | was to make unified and context diff available in pure Go, mostly for 9 | testing purposes. 10 | 11 | The following class and functions (and related tests) have be ported: 12 | 13 | * `SequenceMatcher` 14 | * `unified_diff()` 15 | * `context_diff()` 16 | 17 | ## Installation 18 | 19 | ```bash 20 | $ go get github.com/pmezard/go-difflib/difflib 21 | ``` 22 | 23 | ### Quick Start 24 | 25 | Diffs are configured with Unified (or ContextDiff) structures, and can 26 | be output to an io.Writer or returned as a string. 27 | 28 | ```Go 29 | diff := UnifiedDiff{ 30 | A: difflib.SplitLines("foo\nbar\n"), 31 | B: difflib.SplitLines("foo\nbaz\n"), 32 | FromFile: "Original", 33 | ToFile: "Current", 34 | Context: 3, 35 | } 36 | text, _ := GetUnifiedDiffString(diff) 37 | fmt.Printf(text) 38 | ``` 39 | 40 | would output: 41 | 42 | ``` 43 | --- Original 44 | +++ Current 45 | @@ -1,3 +1,3 @@ 46 | foo 47 | -bar 48 | +baz 49 | ``` 50 | 51 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/LICENSE.md: -------------------------------------------------------------------------------- 1 | objx - by Mat Ryer and Tyler Bunnell 2 | 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 2014 Stretchr, Inc. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/README.md: -------------------------------------------------------------------------------- 1 | # objx 2 | 3 | * Jump into the [API Documentation](http://godoc.org/github.com/stretchr/objx) 4 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/codegen/array-access.txt: -------------------------------------------------------------------------------- 1 | case []{1}: 2 | a := object.([]{1}) 3 | if isSet { 4 | a[index] = value.({1}) 5 | } else { 6 | if index >= len(a) { 7 | if panics { 8 | panic(fmt.Sprintf("objx: Index %d is out of range because the []{1} only contains %d items.", index, len(a))) 9 | } 10 | return nil 11 | } else { 12 | return a[index] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/codegen/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Codegen 5 | 6 | 17 | 18 | 19 | 20 |

21 | Template 22 |

23 |

24 | Use {x} as a placeholder for each argument. 25 |

26 | 27 | 28 |

29 | Arguments (comma separated) 30 |

31 |

32 | One block per line 33 |

34 | 35 | 36 |

37 | Output 38 |

39 | 40 | 41 | 42 | 43 | 44 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/codegen/types_list.txt: -------------------------------------------------------------------------------- 1 | Interface,interface{},"something",nil,Inter 2 | Map,map[string]interface{},map[string]interface{}{"name":"Tyler"},nil,MSI 3 | ObjxMap,(Map),New(1),New(nil),ObjxMap 4 | Bool,bool,true,false,Bool 5 | String,string,"hello","",Str 6 | Int,int,1,0,Int 7 | Int8,int8,1,0,Int8 8 | Int16,int16,1,0,Int16 9 | Int32,int32,1,0,Int32 10 | Int64,int64,1,0,Int64 11 | Uint,uint,1,0,Uint 12 | Uint8,uint8,1,0,Uint8 13 | Uint16,uint16,1,0,Uint16 14 | Uint32,uint32,1,0,Uint32 15 | Uint64,uint64,1,0,Uint64 16 | Uintptr,uintptr,1,0,Uintptr 17 | Float32,float32,1,0,Float32 18 | Float64,float64,1,0,Float64 19 | Complex64,complex64,1,0,Complex64 20 | Complex128,complex128,1,0,Complex128 21 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/constants.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | const ( 4 | // PathSeparator is the character used to separate the elements 5 | // of the keypath. 6 | // 7 | // For example, `location.address.city` 8 | PathSeparator string = "." 9 | 10 | // SignatureSeparator is the character that is used to 11 | // separate the Base64 string from the security signature. 12 | SignatureSeparator = "_" 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/conversions_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestConversionJSON(t *testing.T) { 9 | 10 | jsonString := `{"name":"Mat"}` 11 | o := MustFromJSON(jsonString) 12 | 13 | result, err := o.JSON() 14 | 15 | if assert.NoError(t, err) { 16 | assert.Equal(t, jsonString, result) 17 | } 18 | 19 | assert.Equal(t, jsonString, o.MustJSON()) 20 | 21 | } 22 | 23 | func TestConversionJSONWithError(t *testing.T) { 24 | 25 | o := MSI() 26 | o["test"] = func() {} 27 | 28 | assert.Panics(t, func() { 29 | o.MustJSON() 30 | }) 31 | 32 | _, err := o.JSON() 33 | 34 | assert.Error(t, err) 35 | 36 | } 37 | 38 | func TestConversionBase64(t *testing.T) { 39 | 40 | o := New(map[string]interface{}{"name": "Mat"}) 41 | 42 | result, err := o.Base64() 43 | 44 | if assert.NoError(t, err) { 45 | assert.Equal(t, "eyJuYW1lIjoiTWF0In0=", result) 46 | } 47 | 48 | assert.Equal(t, "eyJuYW1lIjoiTWF0In0=", o.MustBase64()) 49 | 50 | } 51 | 52 | func TestConversionBase64WithError(t *testing.T) { 53 | 54 | o := MSI() 55 | o["test"] = func() {} 56 | 57 | assert.Panics(t, func() { 58 | o.MustBase64() 59 | }) 60 | 61 | _, err := o.Base64() 62 | 63 | assert.Error(t, err) 64 | 65 | } 66 | 67 | func TestConversionSignedBase64(t *testing.T) { 68 | 69 | o := New(map[string]interface{}{"name": "Mat"}) 70 | 71 | result, err := o.SignedBase64("key") 72 | 73 | if assert.NoError(t, err) { 74 | assert.Equal(t, "eyJuYW1lIjoiTWF0In0=_67ee82916f90b2c0d68c903266e8998c9ef0c3d6", result) 75 | } 76 | 77 | assert.Equal(t, "eyJuYW1lIjoiTWF0In0=_67ee82916f90b2c0d68c903266e8998c9ef0c3d6", o.MustSignedBase64("key")) 78 | 79 | } 80 | 81 | func TestConversionSignedBase64WithError(t *testing.T) { 82 | 83 | o := MSI() 84 | o["test"] = func() {} 85 | 86 | assert.Panics(t, func() { 87 | o.MustSignedBase64("key") 88 | }) 89 | 90 | _, err := o.SignedBase64("key") 91 | 92 | assert.Error(t, err) 93 | 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/map_for_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | var TestMap map[string]interface{} = map[string]interface{}{ 4 | "name": "Tyler", 5 | "address": map[string]interface{}{ 6 | "city": "Salt Lake City", 7 | "state": "UT", 8 | }, 9 | "numbers": []interface{}{"one", "two", "three", "four", "five"}, 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/mutations_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestExclude(t *testing.T) { 9 | 10 | d := make(Map) 11 | d["name"] = "Mat" 12 | d["age"] = 29 13 | d["secret"] = "ABC" 14 | 15 | excluded := d.Exclude([]string{"secret"}) 16 | 17 | assert.Equal(t, d["name"], excluded["name"]) 18 | assert.Equal(t, d["age"], excluded["age"]) 19 | assert.False(t, excluded.Has("secret"), "secret should be excluded") 20 | 21 | } 22 | 23 | func TestCopy(t *testing.T) { 24 | 25 | d1 := make(map[string]interface{}) 26 | d1["name"] = "Tyler" 27 | d1["location"] = "UT" 28 | 29 | d1Obj := New(d1) 30 | d2Obj := d1Obj.Copy() 31 | 32 | d2Obj["name"] = "Mat" 33 | 34 | assert.Equal(t, d1Obj.Get("name").Str(), "Tyler") 35 | assert.Equal(t, d2Obj.Get("name").Str(), "Mat") 36 | 37 | } 38 | 39 | func TestMerge(t *testing.T) { 40 | 41 | d := make(map[string]interface{}) 42 | d["name"] = "Mat" 43 | 44 | d1 := make(map[string]interface{}) 45 | d1["name"] = "Tyler" 46 | d1["location"] = "UT" 47 | 48 | dObj := New(d) 49 | d1Obj := New(d1) 50 | 51 | merged := dObj.Merge(d1Obj) 52 | 53 | assert.Equal(t, merged.Get("name").Str(), d1Obj.Get("name").Str()) 54 | assert.Equal(t, merged.Get("location").Str(), d1Obj.Get("location").Str()) 55 | assert.Empty(t, dObj.Get("location").Str()) 56 | 57 | } 58 | 59 | func TestMergeHere(t *testing.T) { 60 | 61 | d := make(map[string]interface{}) 62 | d["name"] = "Mat" 63 | 64 | d1 := make(map[string]interface{}) 65 | d1["name"] = "Tyler" 66 | d1["location"] = "UT" 67 | 68 | dObj := New(d) 69 | d1Obj := New(d1) 70 | 71 | merged := dObj.MergeHere(d1Obj) 72 | 73 | assert.Equal(t, dObj, merged, "With MergeHere, it should return the first modified map") 74 | assert.Equal(t, merged.Get("name").Str(), d1Obj.Get("name").Str()) 75 | assert.Equal(t, merged.Get("location").Str(), d1Obj.Get("location").Str()) 76 | assert.Equal(t, merged.Get("location").Str(), dObj.Get("location").Str()) 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/security.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "crypto/sha1" 5 | "encoding/hex" 6 | ) 7 | 8 | // HashWithKey hashes the specified string using the security 9 | // key. 10 | func HashWithKey(data, key string) string { 11 | hash := sha1.New() 12 | hash.Write([]byte(data + ":" + key)) 13 | return hex.EncodeToString(hash.Sum(nil)) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/security_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestHashWithKey(t *testing.T) { 9 | 10 | assert.Equal(t, "0ce84d8d01f2c7b6e0882b784429c54d280ea2d9", HashWithKey("abc", "def")) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/simple_example_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestSimpleExample(t *testing.T) { 9 | 10 | // build a map from a JSON object 11 | o := MustFromJSON(`{"name":"Mat","foods":["indian","chinese"], "location":{"county":"hobbiton","city":"the shire"}}`) 12 | 13 | // Map can be used as a straight map[string]interface{} 14 | assert.Equal(t, o["name"], "Mat") 15 | 16 | // Get an Value object 17 | v := o.Get("name") 18 | assert.Equal(t, v, &Value{data: "Mat"}) 19 | 20 | // Test the contained value 21 | assert.False(t, v.IsInt()) 22 | assert.False(t, v.IsBool()) 23 | assert.True(t, v.IsStr()) 24 | 25 | // Get the contained value 26 | assert.Equal(t, v.Str(), "Mat") 27 | 28 | // Get a default value if the contained value is not of the expected type or does not exist 29 | assert.Equal(t, 1, v.Int(1)) 30 | 31 | // Get a value by using array notation 32 | assert.Equal(t, "indian", o.Get("foods[0]").Data()) 33 | 34 | // Set a value by using array notation 35 | o.Set("foods[0]", "italian") 36 | assert.Equal(t, "italian", o.Get("foods[0]").Str()) 37 | 38 | // Get a value by using dot notation 39 | assert.Equal(t, "hobbiton", o.Get("location.county").Str()) 40 | 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/tests.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | // Has gets whether there is something at the specified selector 4 | // or not. 5 | // 6 | // If m is nil, Has will always return false. 7 | func (m Map) Has(selector string) bool { 8 | if m == nil { 9 | return false 10 | } 11 | return !m.Get(selector).IsNil() 12 | } 13 | 14 | // IsNil gets whether the data is nil or not. 15 | func (v *Value) IsNil() bool { 16 | return v == nil || v.data == nil 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/tests_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestHas(t *testing.T) { 9 | 10 | m := New(TestMap) 11 | 12 | assert.True(t, m.Has("name")) 13 | assert.True(t, m.Has("address.state")) 14 | assert.True(t, m.Has("numbers[4]")) 15 | 16 | assert.False(t, m.Has("address.state.nope")) 17 | assert.False(t, m.Has("address.nope")) 18 | assert.False(t, m.Has("nope")) 19 | assert.False(t, m.Has("numbers[5]")) 20 | 21 | m = nil 22 | assert.False(t, m.Has("nothing")) 23 | 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/value.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | // Value provides methods for extracting interface{} data in various 4 | // types. 5 | type Value struct { 6 | // data contains the raw data being managed by this Value 7 | data interface{} 8 | } 9 | 10 | // Data returns the raw data contained by this Value 11 | func (v *Value) Data() interface{} { 12 | return v.data 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/value_test.go: -------------------------------------------------------------------------------- 1 | package objx 2 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | 24 | .DS_Store 25 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.1 5 | - 1.2 6 | - 1.3 7 | - 1.4 8 | - 1.5 9 | - tip 10 | 11 | script: 12 | - go test -v ./... 13 | 14 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/stretchr/testify", 3 | "GoVersion": "go1.5", 4 | "Packages": [ 5 | "./..." 6 | ], 7 | "Deps": [ 8 | { 9 | "ImportPath": "github.com/davecgh/go-spew/spew", 10 | "Rev": "2df174808ee097f90d259e432cc04442cf60be21" 11 | }, 12 | { 13 | "ImportPath": "github.com/pmezard/go-difflib/difflib", 14 | "Rev": "d8ed2627bdf02c080bf22230dbb337003b7aba2d" 15 | }, 16 | { 17 | "ImportPath": "github.com/stretchr/objx", 18 | "Rev": "cbeaeb16a013161a98496fad62933b1d21786672" 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENCE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 4 | } 5 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/doc.go: -------------------------------------------------------------------------------- 1 | // Package testify is a set of packages that provide many tools for testifying that your code will behave as you intend. 2 | // 3 | // testify contains the following packages: 4 | // 5 | // The assert package provides a comprehensive set of assertion functions that tie in to the Go testing system. 6 | // 7 | // The http package contains tools to make it easier to test http activity using the Go testing system. 8 | // 9 | // The mock package provides a system by which it is possible to mock your objects and verify calls are happening as expected. 10 | // 11 | // The suite package provides a basic structure for using structs as testing suites, and methods on those structs as tests. It includes setup/teardown functionality in the way of interfaces. 12 | package testify 13 | 14 | // blank imports help docs. 15 | import ( 16 | // assert package 17 | _ "github.com/stretchr/testify/assert" 18 | // http package 19 | _ "github.com/stretchr/testify/http" 20 | // mock package 21 | _ "github.com/stretchr/testify/mock" 22 | ) 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/http/doc.go: -------------------------------------------------------------------------------- 1 | // A set of tools to make testing http activity using the Go testing system easier. 2 | package http 3 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/http/test_response_writer.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | // TestResponseWriter is a http.ResponseWriter object that keeps track of all activity 8 | // allowing you to make assertions about how it was used. 9 | // 10 | // DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead. 11 | type TestResponseWriter struct { 12 | 13 | // StatusCode is the last int written by the call to WriteHeader(int) 14 | StatusCode int 15 | 16 | // Output is a string containing the written bytes using the Write([]byte) func. 17 | Output string 18 | 19 | // header is the internal storage of the http.Header object 20 | header http.Header 21 | } 22 | 23 | // Header gets the http.Header describing the headers that were set in this response. 24 | func (rw *TestResponseWriter) Header() http.Header { 25 | 26 | if rw.header == nil { 27 | rw.header = make(http.Header) 28 | } 29 | 30 | return rw.header 31 | } 32 | 33 | // Write writes the specified bytes to Output. 34 | func (rw *TestResponseWriter) Write(bytes []byte) (int, error) { 35 | 36 | // assume 200 success if no header has been set 37 | if rw.StatusCode == 0 { 38 | rw.WriteHeader(200) 39 | } 40 | 41 | // add these bytes to the output string 42 | rw.Output = rw.Output + string(bytes) 43 | 44 | // return normal values 45 | return 0, nil 46 | 47 | } 48 | 49 | // WriteHeader stores the HTTP status code in the StatusCode. 50 | func (rw *TestResponseWriter) WriteHeader(i int) { 51 | rw.StatusCode = i 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/http/test_round_tripper.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "github.com/stretchr/testify/mock" 5 | "net/http" 6 | ) 7 | 8 | type TestRoundTripper struct { 9 | mock.Mock 10 | } 11 | 12 | func (t *TestRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { 13 | args := t.Called(req) 14 | return args.Get(0).(*http.Response), args.Error(1) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/mock/doc.go: -------------------------------------------------------------------------------- 1 | // Provides a system by which it is possible to mock your objects and verify calls are happening as expected. 2 | // 3 | // Example Usage 4 | // 5 | // The mock package provides an object, Mock, that tracks activity on another object. It is usually 6 | // embedded into a test object as shown below: 7 | // 8 | // type MyTestObject struct { 9 | // // add a Mock object instance 10 | // mock.Mock 11 | // 12 | // // other fields go here as normal 13 | // } 14 | // 15 | // When implementing the methods of an interface, you wire your functions up 16 | // to call the Mock.Called(args...) method, and return the appropriate values. 17 | // 18 | // For example, to mock a method that saves the name and age of a person and returns 19 | // the year of their birth or an error, you might write this: 20 | // 21 | // func (o *MyTestObject) SavePersonDetails(firstname, lastname string, age int) (int, error) { 22 | // args := o.Called(firstname, lastname, age) 23 | // return args.Int(0), args.Error(1) 24 | // } 25 | // 26 | // The Int, Error and Bool methods are examples of strongly typed getters that take the argument 27 | // index position. Given this argument list: 28 | // 29 | // (12, true, "Something") 30 | // 31 | // You could read them out strongly typed like this: 32 | // 33 | // args.Int(0) 34 | // args.Bool(1) 35 | // args.String(2) 36 | // 37 | // For objects of your own type, use the generic Arguments.Get(index) method and make a type assertion: 38 | // 39 | // return args.Get(0).(*MyObject), args.Get(1).(*AnotherObjectOfMine) 40 | // 41 | // This may cause a panic if the object you are getting is nil (the type assertion will fail), in those 42 | // cases you should check for nil first. 43 | package mock 44 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/package_test.go: -------------------------------------------------------------------------------- 1 | package testify 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestImports(t *testing.T) { 9 | if assert.Equal(t, 1, 1) != true { 10 | t.Error("Something is wrong.") 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/doc.go: -------------------------------------------------------------------------------- 1 | // Alternative testing tools which stop test execution if test failed. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using require in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/require" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // require.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // Assertions 21 | // 22 | // The `require` package have same global functions as in the `assert` package, 23 | // but instead of returning a boolean result they call `t.FailNow()`. 24 | // 25 | // Every assertion function also takes an optional string message as the final argument, 26 | // allowing custom error messages to be appended to the message the assertion method outputs. 27 | package require 28 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/forward_requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | type Assertions struct { 4 | t TestingT 5 | } 6 | 7 | func New(t TestingT) *Assertions { 8 | return &Assertions{ 9 | t: t, 10 | } 11 | } 12 | 13 | //go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl 14 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.Comment}} 2 | func {{.DocInfo.Name}}(t TestingT, {{.Params}}) { 3 | if !assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { 4 | t.FailNow() 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) { 3 | {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 4 | } 5 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | type TestingT interface { 4 | Errorf(format string, args ...interface{}) 5 | FailNow() 6 | } 7 | 8 | //go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl 9 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/suite/interfaces.go: -------------------------------------------------------------------------------- 1 | package suite 2 | 3 | import "testing" 4 | 5 | // TestingSuite can store and return the current *testing.T context 6 | // generated by 'go test'. 7 | type TestingSuite interface { 8 | T() *testing.T 9 | SetT(*testing.T) 10 | } 11 | 12 | // SetupAllSuite has a SetupSuite method, which will run before the 13 | // tests in the suite are run. 14 | type SetupAllSuite interface { 15 | SetupSuite() 16 | } 17 | 18 | // SetupTestSuite has a SetupTest method, which will run before each 19 | // test in the suite. 20 | type SetupTestSuite interface { 21 | SetupTest() 22 | } 23 | 24 | // TearDownAllSuite has a TearDownSuite method, which will run after 25 | // all the tests in the suite have been run. 26 | type TearDownAllSuite interface { 27 | TearDownSuite() 28 | } 29 | 30 | // TearDownTestSuite has a TearDownTest method, which will run after 31 | // each test in the suite. 32 | type TearDownTestSuite interface { 33 | TearDownTest() 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2013 Dave Collins 2 | 3 | Permission to use, copy, modify, and distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when either the code is running on Google App Engine or "-tags disableunsafe" 17 | // is added to the go build command line. 18 | // +build appengine disableunsafe 19 | 20 | package spew 21 | 22 | import "reflect" 23 | 24 | const ( 25 | // UnsafeDisabled is a build-time constant which specifies whether or 26 | // not access to the unsafe package is available. 27 | UnsafeDisabled = true 28 | ) 29 | 30 | // unsafeReflectValue typically converts the passed reflect.Value into a one 31 | // that bypasses the typical safety restrictions preventing access to 32 | // unaddressable and unexported data. However, doing this relies on access to 33 | // the unsafe package. This is a stub version which simply returns the passed 34 | // reflect.Value when the unsafe package is not available. 35 | func unsafeReflectValue(v reflect.Value) reflect.Value { 36 | return v 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | 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 copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/vendor/github.com/stretchr/objx/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/vendor/github.com/stretchr/objx/LICENSE.md: -------------------------------------------------------------------------------- 1 | objx - by Mat Ryer and Tyler Bunnell 2 | 3 | The MIT License (MIT) 4 | 5 | Copyright (c) 2014 Stretchr, Inc. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/vendor/github.com/stretchr/objx/README.md: -------------------------------------------------------------------------------- 1 | # objx 2 | 3 | * Jump into the [API Documentation](http://godoc.org/github.com/stretchr/objx) 4 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/vendor/github.com/stretchr/objx/codegen/array-access.txt: -------------------------------------------------------------------------------- 1 | case []{1}: 2 | a := object.([]{1}) 3 | if isSet { 4 | a[index] = value.({1}) 5 | } else { 6 | if index >= len(a) { 7 | if panics { 8 | panic(fmt.Sprintf("objx: Index %d is out of range because the []{1} only contains %d items.", index, len(a))) 9 | } 10 | return nil 11 | } else { 12 | return a[index] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/vendor/github.com/stretchr/objx/codegen/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Codegen 5 | 6 | 17 | 18 | 19 | 20 |

21 | Template 22 |

23 |

24 | Use {x} as a placeholder for each argument. 25 |

26 | 27 | 28 |

29 | Arguments (comma separated) 30 |

31 |

32 | One block per line 33 |

34 | 35 | 36 |

37 | Output 38 |

39 | 40 | 41 | 42 | 43 | 44 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/vendor/github.com/stretchr/objx/codegen/types_list.txt: -------------------------------------------------------------------------------- 1 | Interface,interface{},"something",nil,Inter 2 | Map,map[string]interface{},map[string]interface{}{"name":"Tyler"},nil,MSI 3 | ObjxMap,(Map),New(1),New(nil),ObjxMap 4 | Bool,bool,true,false,Bool 5 | String,string,"hello","",Str 6 | Int,int,1,0,Int 7 | Int8,int8,1,0,Int8 8 | Int16,int16,1,0,Int16 9 | Int32,int32,1,0,Int32 10 | Int64,int64,1,0,Int64 11 | Uint,uint,1,0,Uint 12 | Uint8,uint8,1,0,Uint8 13 | Uint16,uint16,1,0,Uint16 14 | Uint32,uint32,1,0,Uint32 15 | Uint64,uint64,1,0,Uint64 16 | Uintptr,uintptr,1,0,Uintptr 17 | Float32,float32,1,0,Float32 18 | Float64,float64,1,0,Float64 19 | Complex64,complex64,1,0,Complex64 20 | Complex128,complex128,1,0,Complex128 21 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/vendor/github.com/stretchr/objx/constants.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | const ( 4 | // PathSeparator is the character used to separate the elements 5 | // of the keypath. 6 | // 7 | // For example, `location.address.city` 8 | PathSeparator string = "." 9 | 10 | // SignatureSeparator is the character that is used to 11 | // separate the Base64 string from the security signature. 12 | SignatureSeparator = "_" 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/vendor/github.com/stretchr/objx/security.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "crypto/sha1" 5 | "encoding/hex" 6 | ) 7 | 8 | // HashWithKey hashes the specified string using the security 9 | // key. 10 | func HashWithKey(data, key string) string { 11 | hash := sha1.New() 12 | hash.Write([]byte(data + ":" + key)) 13 | return hex.EncodeToString(hash.Sum(nil)) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/vendor/github.com/stretchr/objx/tests.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | // Has gets whether there is something at the specified selector 4 | // or not. 5 | // 6 | // If m is nil, Has will always return false. 7 | func (m Map) Has(selector string) bool { 8 | if m == nil { 9 | return false 10 | } 11 | return !m.Get(selector).IsNil() 12 | } 13 | 14 | // IsNil gets whether the data is nil or not. 15 | func (v *Value) IsNil() bool { 16 | return v == nil || v.data == nil 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/vendor/github.com/stretchr/objx/value.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | // Value provides methods for extracting interface{} data in various 4 | // types. 5 | type Value struct { 6 | // data contains the raw data being managed by this Value 7 | data interface{} 8 | } 9 | 10 | // Data returns the raw data contained by this Value 11 | func (v *Value) Data() interface{} { 12 | return v.data 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/.gitattributes: -------------------------------------------------------------------------------- 1 | # Treat all files in this repo as binary, with no git magic updating 2 | # line endings. Windows users contributing to Go will need to use a 3 | # modern version of git and editors capable of LF line endings. 4 | # 5 | # We'll prevent accidental CRLF line endings from entering the repo 6 | # via the git-review gofmt checks. 7 | # 8 | # See golang.org/issue/9281 9 | 10 | * -text 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/.gitignore: -------------------------------------------------------------------------------- 1 | # Add no patterns to .hgignore except for files generated by the build. 2 | last-change 3 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Go 2 | 3 | Go is an open source project. 4 | 5 | It is the work of hundreds of contributors. We appreciate your help! 6 | 7 | 8 | ## Filing issues 9 | 10 | When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions: 11 | 12 | 1. What version of Go are you using (`go version`)? 13 | 2. What operating system and processor architecture are you using? 14 | 3. What did you do? 15 | 4. What did you expect to see? 16 | 5. What did you see instead? 17 | 18 | General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. 19 | The gophers there will answer or ask you to file an issue if you've tripped over a bug. 20 | 21 | ## Contributing code 22 | 23 | Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) 24 | before sending patches. 25 | 26 | **We do not accept GitHub pull requests** 27 | (we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review). 28 | 29 | Unless otherwise noted, the Go source files are distributed under 30 | the BSD-style license found in the LICENSE file. 31 | 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/README: -------------------------------------------------------------------------------- 1 | This repository holds supplementary Go cryptography libraries. 2 | 3 | To submit changes to this repository, see http://golang.org/doc/contribute.html. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/bcrypt/base64.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 bcrypt 6 | 7 | import "encoding/base64" 8 | 9 | const alphabet = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" 10 | 11 | var bcEncoding = base64.NewEncoding(alphabet) 12 | 13 | func base64Encode(src []byte) []byte { 14 | n := bcEncoding.EncodedLen(len(src)) 15 | dst := make([]byte, n) 16 | bcEncoding.Encode(dst, src) 17 | for dst[n-1] == '=' { 18 | n-- 19 | } 20 | return dst[:n] 21 | } 22 | 23 | func base64Decode(src []byte) ([]byte, error) { 24 | numOfEquals := 4 - (len(src) % 4) 25 | for i := 0; i < numOfEquals; i++ { 26 | src = append(src, '=') 27 | } 28 | 29 | dst := make([]byte, bcEncoding.DecodedLen(len(src))) 30 | n, err := bcEncoding.Decode(dst, src) 31 | if err != nil { 32 | return nil, err 33 | } 34 | return dst[:n], nil 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/bn256/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 | package bn256 6 | 7 | import ( 8 | "crypto/rand" 9 | ) 10 | 11 | func ExamplePair() { 12 | // This implements the tripartite Diffie-Hellman algorithm from "A One 13 | // Round Protocol for Tripartite Diffie-Hellman", A. Joux. 14 | // http://www.springerlink.com/content/cddc57yyva0hburb/fulltext.pdf 15 | 16 | // Each of three parties, a, b and c, generate a private value. 17 | a, _ := rand.Int(rand.Reader, Order) 18 | b, _ := rand.Int(rand.Reader, Order) 19 | c, _ := rand.Int(rand.Reader, Order) 20 | 21 | // Then each party calculates g₁ and g₂ times their private value. 22 | pa := new(G1).ScalarBaseMult(a) 23 | qa := new(G2).ScalarBaseMult(a) 24 | 25 | pb := new(G1).ScalarBaseMult(b) 26 | qb := new(G2).ScalarBaseMult(b) 27 | 28 | pc := new(G1).ScalarBaseMult(c) 29 | qc := new(G2).ScalarBaseMult(c) 30 | 31 | // Now each party exchanges its public values with the other two and 32 | // all parties can calculate the shared key. 33 | k1 := Pair(pb, qc) 34 | k1.ScalarMult(k1, a) 35 | 36 | k2 := Pair(pc, qa) 37 | k2.ScalarMult(k2, b) 38 | 39 | k3 := Pair(pa, qb) 40 | k3.ScalarMult(k3, c) 41 | 42 | // k1, k2 and k3 will all be equal. 43 | } 44 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/codereview.cfg: -------------------------------------------------------------------------------- 1 | issuerepo: golang/go 2 | -------------------------------------------------------------------------------- /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/glide.lock: -------------------------------------------------------------------------------- 1 | hash: 6d4d253be170ebbfeced38e19ffd60bce1c6ba510a3fcb64370c14ea284260ae 2 | updated: 2016-03-29T12:47:26.145433549+09:00 3 | imports: 4 | - name: AUTHORS 5 | version: "" 6 | - name: bcrypt 7 | version: "" 8 | - name: blowfish 9 | version: "" 10 | - name: bn256 11 | version: "" 12 | - name: cast5 13 | version: "" 14 | - name: codereview.cfg 15 | version: "" 16 | - name: CONTRIBUTING.md 17 | version: "" 18 | - name: CONTRIBUTORS 19 | version: "" 20 | - name: curve25519 21 | version: "" 22 | - name: github.com/cheggaaa/pb 23 | version: 226d21d43a305fac52b3a104ef83e721b15275e0 24 | - name: github.com/chzyer/readline 25 | version: 30b462e50b8f8a1172c3b2f780894c0db2ae2dcb 26 | - name: github.com/DisposaBoy/JsonConfigReader 27 | version: 33a99fdf1d5ee1f79b5077e9c06f955ad356d5f4 28 | - name: golang.org/x/crypto 29 | version: c7e3b0ebdd409a0d024e3d71801427ab0e05fb2e 30 | subpackages: 31 | - ssh 32 | - ssh/agent 33 | - blowfish 34 | - curve25519 35 | - nacl/secretbox 36 | - salsa20/salsa 37 | - poly1305 38 | - openpgp/armor 39 | - openpgp/errors 40 | - openpgp/packet 41 | - openpgp/s2k 42 | - cast5 43 | - openpgp/elgamal 44 | - pkcs12/internal/rc2 45 | - pbkdf2 46 | - name: hkdf 47 | version: "" 48 | - name: LICENSE 49 | version: "" 50 | - name: md4 51 | version: "" 52 | - name: nacl 53 | version: "" 54 | - name: ocsp 55 | version: "" 56 | - name: openpgp 57 | version: "" 58 | - name: otr 59 | version: "" 60 | - name: PATENTS 61 | version: "" 62 | - name: pbkdf2 63 | version: "" 64 | - name: pkcs12 65 | version: "" 66 | - name: poly1305 67 | version: "" 68 | - name: README 69 | version: "" 70 | - name: ripemd160 71 | version: "" 72 | - name: salsa20 73 | version: "" 74 | - name: scrypt 75 | version: "" 76 | - name: sha3 77 | version: "" 78 | - name: ssh 79 | version: "" 80 | - name: tea 81 | version: "" 82 | - name: twofish 83 | version: "" 84 | - name: xtea 85 | version: "" 86 | - name: xts 87 | version: "" 88 | devImports: [] 89 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/hkdf/example_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 hkdf_test 6 | 7 | import ( 8 | "bytes" 9 | "crypto/rand" 10 | "crypto/sha256" 11 | "fmt" 12 | "golang.org/x/crypto/hkdf" 13 | "io" 14 | ) 15 | 16 | // Usage example that expands one master key into three other cryptographically 17 | // secure keys. 18 | func Example_usage() { 19 | // Underlying hash function to use 20 | hash := sha256.New 21 | 22 | // Cryptographically secure master key. 23 | master := []byte{0x00, 0x01, 0x02, 0x03} // i.e. NOT this. 24 | 25 | // Non secret salt, optional (can be nil) 26 | // Recommended: hash-length sized random 27 | salt := make([]byte, hash().Size()) 28 | n, err := io.ReadFull(rand.Reader, salt) 29 | if n != len(salt) || err != nil { 30 | fmt.Println("error:", err) 31 | return 32 | } 33 | 34 | // Non secret context specific info, optional (can be nil). 35 | // Note, independent from the master key. 36 | info := []byte{0x03, 0x14, 0x15, 0x92, 0x65} 37 | 38 | // Create the key derivation function 39 | hkdf := hkdf.New(hash, master, salt, info) 40 | 41 | // Generate the required keys 42 | keys := make([][]byte, 3) 43 | for i := 0; i < len(keys); i++ { 44 | keys[i] = make([]byte, 24) 45 | n, err := io.ReadFull(hkdf, keys[i]) 46 | if n != len(keys[i]) || err != nil { 47 | fmt.Println("error:", err) 48 | return 49 | } 50 | } 51 | 52 | // Keys should contain 192 bit random keys 53 | for i := 1; i <= len(keys); i++ { 54 | fmt.Printf("Key #%d: %v\n", i, !bytes.Equal(keys[i-1], make([]byte, 24))) 55 | } 56 | 57 | // Output: 58 | // Key #1: true 59 | // Key #2: true 60 | // Key #3: true 61 | } 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/hkdf/hkdf.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 hkdf implements the HMAC-based Extract-and-Expand Key Derivation 6 | // Function (HKDF) as defined in RFC 5869. 7 | // 8 | // HKDF is a cryptographic key derivation function (KDF) with the goal of 9 | // expanding limited input keying material into one or more cryptographically 10 | // strong secret keys. 11 | // 12 | // RFC 5869: https://tools.ietf.org/html/rfc5869 13 | package hkdf // import "golang.org/x/crypto/hkdf" 14 | 15 | import ( 16 | "crypto/hmac" 17 | "errors" 18 | "hash" 19 | "io" 20 | ) 21 | 22 | type hkdf struct { 23 | expander hash.Hash 24 | size int 25 | 26 | info []byte 27 | counter byte 28 | 29 | prev []byte 30 | cache []byte 31 | } 32 | 33 | func (f *hkdf) Read(p []byte) (int, error) { 34 | // Check whether enough data can be generated 35 | need := len(p) 36 | remains := len(f.cache) + int(255-f.counter+1)*f.size 37 | if remains < need { 38 | return 0, errors.New("hkdf: entropy limit reached") 39 | } 40 | // Read from the cache, if enough data is present 41 | n := copy(p, f.cache) 42 | p = p[n:] 43 | 44 | // Fill the buffer 45 | for len(p) > 0 { 46 | f.expander.Reset() 47 | f.expander.Write(f.prev) 48 | f.expander.Write(f.info) 49 | f.expander.Write([]byte{f.counter}) 50 | f.prev = f.expander.Sum(f.prev[:0]) 51 | f.counter++ 52 | 53 | // Copy the new batch into p 54 | f.cache = f.prev 55 | n = copy(p, f.cache) 56 | p = p[n:] 57 | } 58 | // Save leftovers for next run 59 | f.cache = f.cache[n:] 60 | 61 | return need, nil 62 | } 63 | 64 | // New returns a new HKDF using the given hash, the secret keying material to expand 65 | // and optional salt and info fields. 66 | func New(hash func() hash.Hash, secret, salt, info []byte) io.Reader { 67 | if salt == nil { 68 | salt = make([]byte, hash().Size()) 69 | } 70 | extractor := hmac.New(hash, salt) 71 | extractor.Write(secret) 72 | prk := extractor.Sum(nil) 73 | 74 | return &hkdf{hmac.New(hash, prk), extractor.Size(), info, 1, nil, nil} 75 | } 76 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/openpgp/canonical_text.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 openpgp 6 | 7 | import "hash" 8 | 9 | // NewCanonicalTextHash reformats text written to it into the canonical 10 | // form and then applies the hash h. See RFC 4880, section 5.2.1. 11 | func NewCanonicalTextHash(h hash.Hash) hash.Hash { 12 | return &canonicalTextHash{h, 0} 13 | } 14 | 15 | type canonicalTextHash struct { 16 | h hash.Hash 17 | s int 18 | } 19 | 20 | var newline = []byte{'\r', '\n'} 21 | 22 | func (cth *canonicalTextHash) Write(buf []byte) (int, error) { 23 | start := 0 24 | 25 | for i, c := range buf { 26 | switch cth.s { 27 | case 0: 28 | if c == '\r' { 29 | cth.s = 1 30 | } else if c == '\n' { 31 | cth.h.Write(buf[start:i]) 32 | cth.h.Write(newline) 33 | start = i + 1 34 | } 35 | case 1: 36 | cth.s = 0 37 | } 38 | } 39 | 40 | cth.h.Write(buf[start:]) 41 | return len(buf), nil 42 | } 43 | 44 | func (cth *canonicalTextHash) Sum(in []byte) []byte { 45 | return cth.h.Sum(in) 46 | } 47 | 48 | func (cth *canonicalTextHash) Reset() { 49 | cth.h.Reset() 50 | cth.s = 0 51 | } 52 | 53 | func (cth *canonicalTextHash) Size() int { 54 | return cth.h.Size() 55 | } 56 | 57 | func (cth *canonicalTextHash) BlockSize() int { 58 | return cth.h.BlockSize() 59 | } 60 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/openpgp/canonical_text_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 openpgp 6 | 7 | import ( 8 | "bytes" 9 | "testing" 10 | ) 11 | 12 | type recordingHash struct { 13 | buf *bytes.Buffer 14 | } 15 | 16 | func (r recordingHash) Write(b []byte) (n int, err error) { 17 | return r.buf.Write(b) 18 | } 19 | 20 | func (r recordingHash) Sum(in []byte) []byte { 21 | return append(in, r.buf.Bytes()...) 22 | } 23 | 24 | func (r recordingHash) Reset() { 25 | panic("shouldn't be called") 26 | } 27 | 28 | func (r recordingHash) Size() int { 29 | panic("shouldn't be called") 30 | } 31 | 32 | func (r recordingHash) BlockSize() int { 33 | panic("shouldn't be called") 34 | } 35 | 36 | func testCanonicalText(t *testing.T, input, expected string) { 37 | r := recordingHash{bytes.NewBuffer(nil)} 38 | c := NewCanonicalTextHash(r) 39 | c.Write([]byte(input)) 40 | result := c.Sum(nil) 41 | if expected != string(result) { 42 | t.Errorf("input: %x got: %x want: %x", input, result, expected) 43 | } 44 | } 45 | 46 | func TestCanonicalText(t *testing.T) { 47 | testCanonicalText(t, "foo\n", "foo\r\n") 48 | testCanonicalText(t, "foo", "foo") 49 | testCanonicalText(t, "foo\r\n", "foo\r\n") 50 | testCanonicalText(t, "foo\r\nbar", "foo\r\nbar") 51 | testCanonicalText(t, "foo\r\nbar\n\n", "foo\r\nbar\r\n\r\n") 52 | } 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/openpgp/elgamal/elgamal_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 elgamal 6 | 7 | import ( 8 | "bytes" 9 | "crypto/rand" 10 | "math/big" 11 | "testing" 12 | ) 13 | 14 | // This is the 1024-bit MODP group from RFC 5114, section 2.1: 15 | const primeHex = "B10B8F96A080E01DDE92DE5EAE5D54EC52C99FBCFB06A3C69A6A9DCA52D23B616073E28675A23D189838EF1E2EE652C013ECB4AEA906112324975C3CD49B83BFACCBDD7D90C4BD7098488E9C219A73724EFFD6FAE5644738FAA31A4FF55BCCC0A151AF5F0DC8B4BD45BF37DF365C1A65E68CFDA76D4DA708DF1FB2BC2E4A4371" 16 | 17 | const generatorHex = "A4D1CBD5C3FD34126765A442EFB99905F8104DD258AC507FD6406CFF14266D31266FEA1E5C41564B777E690F5504F213160217B4B01B886A5E91547F9E2749F4D7FBD7D3B9A92EE1909D0D2263F80A76A6A24C087A091F531DBF0A0169B6A28AD662A4D18E73AFA32D779D5918D08BC8858F4DCEF97C2A24855E6EEB22B3B2E5" 18 | 19 | func fromHex(hex string) *big.Int { 20 | n, ok := new(big.Int).SetString(hex, 16) 21 | if !ok { 22 | panic("failed to parse hex number") 23 | } 24 | return n 25 | } 26 | 27 | func TestEncryptDecrypt(t *testing.T) { 28 | priv := &PrivateKey{ 29 | PublicKey: PublicKey{ 30 | G: fromHex(generatorHex), 31 | P: fromHex(primeHex), 32 | }, 33 | X: fromHex("42"), 34 | } 35 | priv.Y = new(big.Int).Exp(priv.G, priv.X, priv.P) 36 | 37 | message := []byte("hello world") 38 | c1, c2, err := Encrypt(rand.Reader, &priv.PublicKey, message) 39 | if err != nil { 40 | t.Errorf("error encrypting: %s", err) 41 | } 42 | message2, err := Decrypt(priv, c1, c2) 43 | if err != nil { 44 | t.Errorf("error decrypting: %s", err) 45 | } 46 | if !bytes.Equal(message2, message) { 47 | t.Errorf("decryption failed, got: %x, want: %x", message2, message) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/openpgp/packet/compressed_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 packet 6 | 7 | import ( 8 | "bytes" 9 | "encoding/hex" 10 | "io" 11 | "io/ioutil" 12 | "testing" 13 | ) 14 | 15 | func TestCompressed(t *testing.T) { 16 | packet, err := Read(readerFromHex(compressedHex)) 17 | if err != nil { 18 | t.Errorf("failed to read Compressed: %s", err) 19 | return 20 | } 21 | 22 | c, ok := packet.(*Compressed) 23 | if !ok { 24 | t.Error("didn't find Compressed packet") 25 | return 26 | } 27 | 28 | contents, err := ioutil.ReadAll(c.Body) 29 | if err != nil && err != io.EOF { 30 | t.Error(err) 31 | return 32 | } 33 | 34 | expected, _ := hex.DecodeString(compressedExpectedHex) 35 | if !bytes.Equal(expected, contents) { 36 | t.Errorf("got:%x want:%x", contents, expected) 37 | } 38 | } 39 | 40 | const compressedHex = "a3013b2d90c4e02b72e25f727e5e496a5e49b11e1700" 41 | const compressedExpectedHex = "cb1062004d14c8fe636f6e74656e74732e0a" 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/openpgp/packet/ocfb_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 packet 6 | 7 | import ( 8 | "bytes" 9 | "crypto/aes" 10 | "crypto/rand" 11 | "testing" 12 | ) 13 | 14 | var commonKey128 = []byte{0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c} 15 | 16 | func testOCFB(t *testing.T, resync OCFBResyncOption) { 17 | block, err := aes.NewCipher(commonKey128) 18 | if err != nil { 19 | t.Error(err) 20 | return 21 | } 22 | 23 | plaintext := []byte("this is the plaintext, which is long enough to span several blocks.") 24 | randData := make([]byte, block.BlockSize()) 25 | rand.Reader.Read(randData) 26 | ocfb, prefix := NewOCFBEncrypter(block, randData, resync) 27 | ciphertext := make([]byte, len(plaintext)) 28 | ocfb.XORKeyStream(ciphertext, plaintext) 29 | 30 | ocfbdec := NewOCFBDecrypter(block, prefix, resync) 31 | if ocfbdec == nil { 32 | t.Errorf("NewOCFBDecrypter failed (resync: %t)", resync) 33 | return 34 | } 35 | plaintextCopy := make([]byte, len(plaintext)) 36 | ocfbdec.XORKeyStream(plaintextCopy, ciphertext) 37 | 38 | if !bytes.Equal(plaintextCopy, plaintext) { 39 | t.Errorf("got: %x, want: %x (resync: %t)", plaintextCopy, plaintext, resync) 40 | } 41 | } 42 | 43 | func TestOCFB(t *testing.T) { 44 | testOCFB(t, OCFBNoResync) 45 | testOCFB(t, OCFBResync) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/openpgp/packet/one_pass_signature.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 packet 6 | 7 | import ( 8 | "crypto" 9 | "encoding/binary" 10 | "golang.org/x/crypto/openpgp/errors" 11 | "golang.org/x/crypto/openpgp/s2k" 12 | "io" 13 | "strconv" 14 | ) 15 | 16 | // OnePassSignature represents a one-pass signature packet. See RFC 4880, 17 | // section 5.4. 18 | type OnePassSignature struct { 19 | SigType SignatureType 20 | Hash crypto.Hash 21 | PubKeyAlgo PublicKeyAlgorithm 22 | KeyId uint64 23 | IsLast bool 24 | } 25 | 26 | const onePassSignatureVersion = 3 27 | 28 | func (ops *OnePassSignature) parse(r io.Reader) (err error) { 29 | var buf [13]byte 30 | 31 | _, err = readFull(r, buf[:]) 32 | if err != nil { 33 | return 34 | } 35 | if buf[0] != onePassSignatureVersion { 36 | err = errors.UnsupportedError("one-pass-signature packet version " + strconv.Itoa(int(buf[0]))) 37 | } 38 | 39 | var ok bool 40 | ops.Hash, ok = s2k.HashIdToHash(buf[2]) 41 | if !ok { 42 | return errors.UnsupportedError("hash function: " + strconv.Itoa(int(buf[2]))) 43 | } 44 | 45 | ops.SigType = SignatureType(buf[1]) 46 | ops.PubKeyAlgo = PublicKeyAlgorithm(buf[3]) 47 | ops.KeyId = binary.BigEndian.Uint64(buf[4:12]) 48 | ops.IsLast = buf[12] != 0 49 | return 50 | } 51 | 52 | // Serialize marshals the given OnePassSignature to w. 53 | func (ops *OnePassSignature) Serialize(w io.Writer) error { 54 | var buf [13]byte 55 | buf[0] = onePassSignatureVersion 56 | buf[1] = uint8(ops.SigType) 57 | var ok bool 58 | buf[2], ok = s2k.HashToHashId(ops.Hash) 59 | if !ok { 60 | return errors.UnsupportedError("hash type: " + strconv.Itoa(int(ops.Hash))) 61 | } 62 | buf[3] = uint8(ops.PubKeyAlgo) 63 | binary.BigEndian.PutUint64(buf[4:12], ops.KeyId) 64 | if ops.IsLast { 65 | buf[12] = 1 66 | } 67 | 68 | if err := serializeHeader(w, packetTypeOnePassSignature, len(buf)); err != nil { 69 | return err 70 | } 71 | _, err := w.Write(buf[:]) 72 | return err 73 | } 74 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/openpgp/packet/signature_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 packet 6 | 7 | import ( 8 | "bytes" 9 | "crypto" 10 | "encoding/hex" 11 | "testing" 12 | ) 13 | 14 | func TestSignatureRead(t *testing.T) { 15 | packet, err := Read(readerFromHex(signatureDataHex)) 16 | if err != nil { 17 | t.Error(err) 18 | return 19 | } 20 | sig, ok := packet.(*Signature) 21 | if !ok || sig.SigType != SigTypeBinary || sig.PubKeyAlgo != PubKeyAlgoRSA || sig.Hash != crypto.SHA1 { 22 | t.Errorf("failed to parse, got: %#v", packet) 23 | } 24 | } 25 | 26 | func TestSignatureReserialize(t *testing.T) { 27 | packet, _ := Read(readerFromHex(signatureDataHex)) 28 | sig := packet.(*Signature) 29 | out := new(bytes.Buffer) 30 | err := sig.Serialize(out) 31 | if err != nil { 32 | t.Errorf("error reserializing: %s", err) 33 | return 34 | } 35 | 36 | expected, _ := hex.DecodeString(signatureDataHex) 37 | if !bytes.Equal(expected, out.Bytes()) { 38 | t.Errorf("output doesn't match input (got vs expected):\n%s\n%s", hex.Dump(out.Bytes()), hex.Dump(expected)) 39 | } 40 | } 41 | 42 | const signatureDataHex = "c2c05c04000102000605024cb45112000a0910ab105c91af38fb158f8d07ff5596ea368c5efe015bed6e78348c0f033c931d5f2ce5db54ce7f2a7e4b4ad64db758d65a7a71773edeab7ba2a9e0908e6a94a1175edd86c1d843279f045b021a6971a72702fcbd650efc393c5474d5b59a15f96d2eaad4c4c426797e0dcca2803ef41c6ff234d403eec38f31d610c344c06f2401c262f0993b2e66cad8a81ebc4322c723e0d4ba09fe917e8777658307ad8329adacba821420741009dfe87f007759f0982275d028a392c6ed983a0d846f890b36148c7358bdb8a516007fac760261ecd06076813831a36d0459075d1befa245ae7f7fb103d92ca759e9498fe60ef8078a39a3beda510deea251ea9f0a7f0df6ef42060f20780360686f3e400e" 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/pkcs12/bmp-string.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package pkcs12 6 | 7 | import ( 8 | "errors" 9 | "unicode/utf16" 10 | ) 11 | 12 | // bmpString returns s encoded in UCS-2 with a zero terminator. 13 | func bmpString(s string) ([]byte, error) { 14 | // References: 15 | // https://tools.ietf.org/html/rfc7292#appendix-B.1 16 | // http://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane 17 | // - non-BMP characters are encoded in UTF 16 by using a surrogate pair of 16-bit codes 18 | // EncodeRune returns 0xfffd if the rune does not need special encoding 19 | // - the above RFC provides the info that BMPStrings are NULL terminated. 20 | 21 | ret := make([]byte, 0, 2*len(s)+2) 22 | 23 | for _, r := range s { 24 | if t, _ := utf16.EncodeRune(r); t != 0xfffd { 25 | return nil, errors.New("pkcs12: string contains characters that cannot be encoded in UCS-2") 26 | } 27 | ret = append(ret, byte(r/256), byte(r%256)) 28 | } 29 | 30 | return append(ret, 0, 0), nil 31 | } 32 | 33 | func decodeBMPString(bmpString []byte) (string, error) { 34 | if len(bmpString)%2 != 0 { 35 | return "", errors.New("pkcs12: odd-length BMP string") 36 | } 37 | 38 | // strip terminator if present 39 | if l := len(bmpString); l >= 2 && bmpString[l-1] == 0 && bmpString[l-2] == 0 { 40 | bmpString = bmpString[:l-2] 41 | } 42 | 43 | s := make([]uint16, 0, len(bmpString)/2) 44 | for len(bmpString) > 0 { 45 | s = append(s, uint16(bmpString[0])<<8+uint16(bmpString[1])) 46 | bmpString = bmpString[2:] 47 | } 48 | 49 | return string(utf16.Decode(s)), nil 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/pkcs12/bmp-string_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package pkcs12 6 | 7 | import ( 8 | "bytes" 9 | "encoding/hex" 10 | "testing" 11 | ) 12 | 13 | var bmpStringTests = []struct { 14 | in string 15 | expectedHex string 16 | shouldFail bool 17 | }{ 18 | {"", "0000", false}, 19 | // Example from https://tools.ietf.org/html/rfc7292#appendix-B. 20 | {"Beavis", "0042006500610076006900730000", false}, 21 | // Some characters from the "Letterlike Symbols Unicode block". 22 | {"\u2115 - Double-struck N", "21150020002d00200044006f00750062006c0065002d00730074007200750063006b0020004e0000", false}, 23 | // any character outside the BMP should trigger an error. 24 | {"\U0001f000 East wind (Mahjong)", "", true}, 25 | } 26 | 27 | func TestBMPString(t *testing.T) { 28 | for i, test := range bmpStringTests { 29 | expected, err := hex.DecodeString(test.expectedHex) 30 | if err != nil { 31 | t.Fatalf("#%d: failed to decode expectation", i) 32 | } 33 | 34 | out, err := bmpString(test.in) 35 | if err == nil && test.shouldFail { 36 | t.Errorf("#%d: expected to fail, but produced %x", i, out) 37 | continue 38 | } 39 | 40 | if err != nil && !test.shouldFail { 41 | t.Errorf("#%d: failed unexpectedly: %s", i, err) 42 | continue 43 | } 44 | 45 | if !test.shouldFail { 46 | if !bytes.Equal(out, expected) { 47 | t.Errorf("#%d: expected %s, got %x", i, test.expectedHex, out) 48 | continue 49 | } 50 | 51 | roundTrip, err := decodeBMPString(out) 52 | if err != nil { 53 | t.Errorf("#%d: decoding output gave an error: %s", i, err) 54 | continue 55 | } 56 | 57 | if roundTrip != test.in { 58 | t.Errorf("#%d: decoding output resulted in %q, but it should have been %q", i, roundTrip, test.in) 59 | continue 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/pkcs12/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package pkcs12 6 | 7 | import "errors" 8 | 9 | var ( 10 | // ErrDecryption represents a failure to decrypt the input. 11 | ErrDecryption = errors.New("pkcs12: decryption error, incorrect padding") 12 | 13 | // ErrIncorrectPassword is returned when an incorrect password is detected. 14 | // Usually, P12/PFX data is signed to be able to verify the password. 15 | ErrIncorrectPassword = errors.New("pkcs12: decryption password incorrect") 16 | ) 17 | 18 | // NotImplementedError indicates that the input is not currently supported. 19 | type NotImplementedError string 20 | 21 | func (e NotImplementedError) Error() string { 22 | return "pkcs12: " + string(e) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/pkcs12/internal/rc2/bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package rc2 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func BenchmarkEncrypt(b *testing.B) { 12 | r, _ := New([]byte{0, 0, 0, 0, 0, 0, 0, 0}, 64) 13 | b.ResetTimer() 14 | var src [8]byte 15 | for i := 0; i < b.N; i++ { 16 | r.Encrypt(src[:], src[:]) 17 | } 18 | } 19 | 20 | func BenchmarkDecrypt(b *testing.B) { 21 | r, _ := New([]byte{0, 0, 0, 0, 0, 0, 0, 0}, 64) 22 | b.ResetTimer() 23 | var src [8]byte 24 | for i := 0; i < b.N; i++ { 25 | r.Decrypt(src[:], src[:]) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/pkcs12/internal/rc2/rc2_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package rc2 6 | 7 | import ( 8 | "bytes" 9 | "encoding/hex" 10 | "testing" 11 | ) 12 | 13 | func TestEncryptDecrypt(t *testing.T) { 14 | 15 | // TODO(dgryski): add the rest of the test vectors from the RFC 16 | var tests = []struct { 17 | key string 18 | plain string 19 | cipher string 20 | t1 int 21 | }{ 22 | { 23 | "0000000000000000", 24 | "0000000000000000", 25 | "ebb773f993278eff", 26 | 63, 27 | }, 28 | { 29 | "ffffffffffffffff", 30 | "ffffffffffffffff", 31 | "278b27e42e2f0d49", 32 | 64, 33 | }, 34 | { 35 | "3000000000000000", 36 | "1000000000000001", 37 | "30649edf9be7d2c2", 38 | 64, 39 | }, 40 | { 41 | "88", 42 | "0000000000000000", 43 | "61a8a244adacccf0", 44 | 64, 45 | }, 46 | { 47 | "88bca90e90875a", 48 | "0000000000000000", 49 | "6ccf4308974c267f", 50 | 64, 51 | }, 52 | { 53 | "88bca90e90875a7f0f79c384627bafb2", 54 | "0000000000000000", 55 | "1a807d272bbe5db1", 56 | 64, 57 | }, 58 | { 59 | "88bca90e90875a7f0f79c384627bafb2", 60 | "0000000000000000", 61 | "2269552ab0f85ca6", 62 | 128, 63 | }, 64 | { 65 | "88bca90e90875a7f0f79c384627bafb216f80a6f85920584c42fceb0be255daf1e", 66 | "0000000000000000", 67 | "5b78d3a43dfff1f1", 68 | 129, 69 | }, 70 | } 71 | 72 | for _, tt := range tests { 73 | k, _ := hex.DecodeString(tt.key) 74 | p, _ := hex.DecodeString(tt.plain) 75 | c, _ := hex.DecodeString(tt.cipher) 76 | 77 | b, _ := New(k, tt.t1) 78 | 79 | var dst [8]byte 80 | 81 | b.Encrypt(dst[:], p) 82 | 83 | if !bytes.Equal(dst[:], c) { 84 | t.Errorf("encrypt failed: got % 2x wanted % 2x\n", dst, c) 85 | } 86 | 87 | b.Decrypt(dst[:], c) 88 | 89 | if !bytes.Equal(dst[:], p) { 90 | t.Errorf("decrypt failed: got % 2x wanted % 2x\n", dst, p) 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/pkcs12/mac.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package pkcs12 6 | 7 | import ( 8 | "crypto/hmac" 9 | "crypto/sha1" 10 | "crypto/x509/pkix" 11 | "encoding/asn1" 12 | ) 13 | 14 | type macData struct { 15 | Mac digestInfo 16 | MacSalt []byte 17 | Iterations int `asn1:"optional,default:1"` 18 | } 19 | 20 | // from PKCS#7: 21 | type digestInfo struct { 22 | Algorithm pkix.AlgorithmIdentifier 23 | Digest []byte 24 | } 25 | 26 | var ( 27 | oidSHA1 = asn1.ObjectIdentifier([]int{1, 3, 14, 3, 2, 26}) 28 | ) 29 | 30 | func verifyMac(macData *macData, message, password []byte) error { 31 | if !macData.Mac.Algorithm.Algorithm.Equal(oidSHA1) { 32 | return NotImplementedError("unknown digest algorithm: " + macData.Mac.Algorithm.Algorithm.String()) 33 | } 34 | 35 | key := pbkdf(sha1Sum, 20, 64, macData.MacSalt, password, macData.Iterations, 3, 20) 36 | 37 | mac := hmac.New(sha1.New, key) 38 | mac.Write(message) 39 | expectedMAC := mac.Sum(nil) 40 | 41 | if !hmac.Equal(macData.Mac.Digest, expectedMAC) { 42 | return ErrIncorrectPassword 43 | } 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/pkcs12/mac_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package pkcs12 6 | 7 | import ( 8 | "encoding/asn1" 9 | "testing" 10 | ) 11 | 12 | func TestVerifyMac(t *testing.T) { 13 | td := macData{ 14 | Mac: digestInfo{ 15 | Digest: []byte{0x18, 0x20, 0x3d, 0xff, 0x1e, 0x16, 0xf4, 0x92, 0xf2, 0xaf, 0xc8, 0x91, 0xa9, 0xba, 0xd6, 0xca, 0x9d, 0xee, 0x51, 0x93}, 16 | }, 17 | MacSalt: []byte{1, 2, 3, 4, 5, 6, 7, 8}, 18 | Iterations: 2048, 19 | } 20 | 21 | message := []byte{11, 12, 13, 14, 15} 22 | password, _ := bmpString("") 23 | 24 | td.Mac.Algorithm.Algorithm = asn1.ObjectIdentifier([]int{1, 2, 3}) 25 | err := verifyMac(&td, message, password) 26 | if _, ok := err.(NotImplementedError); !ok { 27 | t.Errorf("err: %v", err) 28 | } 29 | 30 | td.Mac.Algorithm.Algorithm = asn1.ObjectIdentifier([]int{1, 3, 14, 3, 2, 26}) 31 | err = verifyMac(&td, message, password) 32 | if err != ErrIncorrectPassword { 33 | t.Errorf("Expected incorrect password, got err: %v", err) 34 | } 35 | 36 | password, _ = bmpString("Sesame open") 37 | err = verifyMac(&td, message, password) 38 | if err != nil { 39 | t.Errorf("err: %v", err) 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/pkcs12/pbkdf_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package pkcs12 6 | 7 | import ( 8 | "bytes" 9 | "testing" 10 | ) 11 | 12 | func TestThatPBKDFWorksCorrectlyForLongKeys(t *testing.T) { 13 | cipherInfo := shaWithTripleDESCBC{} 14 | 15 | salt := []byte("\xff\xff\xff\xff\xff\xff\xff\xff") 16 | password, _ := bmpString("sesame") 17 | key := cipherInfo.deriveKey(salt, password, 2048) 18 | 19 | if expected := []byte("\x7c\xd9\xfd\x3e\x2b\x3b\xe7\x69\x1a\x44\xe3\xbe\xf0\xf9\xea\x0f\xb9\xb8\x97\xd4\xe3\x25\xd9\xd1"); bytes.Compare(key, expected) != 0 { 20 | t.Fatalf("expected key '%x', but found '%x'", expected, key) 21 | } 22 | } 23 | 24 | func TestThatPBKDFHandlesLeadingZeros(t *testing.T) { 25 | // This test triggers a case where I_j (in step 6C) ends up with leading zero 26 | // byte, meaning that len(Ijb) < v (leading zeros get stripped by big.Int). 27 | // This was previously causing bug whereby certain inputs would break the 28 | // derivation and produce the wrong output. 29 | key := pbkdf(sha1Sum, 20, 64, []byte("\xf3\x7e\x05\xb5\x18\x32\x4b\x4b"), []byte("\x00\x00"), 2048, 1, 24) 30 | expected := []byte("\x00\xf7\x59\xff\x47\xd1\x4d\xd0\x36\x65\xd5\x94\x3c\xb3\xc4\xa3\x9a\x25\x55\xc0\x2a\xed\x66\xe1") 31 | if bytes.Compare(key, expected) != 0 { 32 | t.Fatalf("expected key '%x', but found '%x'", expected, key) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/pkcs12/safebags.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package pkcs12 6 | 7 | import ( 8 | "crypto/x509" 9 | "encoding/asn1" 10 | "errors" 11 | ) 12 | 13 | var ( 14 | // see https://tools.ietf.org/html/rfc7292#appendix-D 15 | oidCertTypeX509Certificate = asn1.ObjectIdentifier([]int{1, 2, 840, 113549, 1, 9, 22, 1}) 16 | oidPKCS8ShroundedKeyBag = asn1.ObjectIdentifier([]int{1, 2, 840, 113549, 1, 12, 10, 1, 2}) 17 | oidCertBag = asn1.ObjectIdentifier([]int{1, 2, 840, 113549, 1, 12, 10, 1, 3}) 18 | ) 19 | 20 | type certBag struct { 21 | Id asn1.ObjectIdentifier 22 | Data []byte `asn1:"tag:0,explicit"` 23 | } 24 | 25 | func decodePkcs8ShroudedKeyBag(asn1Data, password []byte) (privateKey interface{}, err error) { 26 | pkinfo := new(encryptedPrivateKeyInfo) 27 | if err = unmarshal(asn1Data, pkinfo); err != nil { 28 | return nil, errors.New("pkcs12: error decoding PKCS#8 shrouded key bag: " + err.Error()) 29 | } 30 | 31 | pkData, err := pbDecrypt(pkinfo, password) 32 | if err != nil { 33 | return nil, errors.New("pkcs12: error decrypting PKCS#8 shrouded key bag: " + err.Error()) 34 | } 35 | 36 | ret := new(asn1.RawValue) 37 | if err = unmarshal(pkData, ret); err != nil { 38 | return nil, errors.New("pkcs12: error unmarshaling decrypted private key: " + err.Error()) 39 | } 40 | 41 | if privateKey, err = x509.ParsePKCS8PrivateKey(pkData); err != nil { 42 | return nil, errors.New("pkcs12: error parsing PKCS#8 private key: " + err.Error()) 43 | } 44 | 45 | return privateKey, nil 46 | } 47 | 48 | func decodeCertBag(asn1Data []byte) (x509Certificates []byte, err error) { 49 | bag := new(certBag) 50 | if err := unmarshal(asn1Data, bag); err != nil { 51 | return nil, errors.New("pkcs12: error decoding cert bag: " + err.Error()) 52 | } 53 | if !bag.Id.Equal(oidCertTypeX509Certificate) { 54 | return nil, NotImplementedError("only X509 certificates are supported") 55 | } 56 | return bag.Data, nil 57 | } 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/poly1305/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 ·SCALE(SB)/8, $0x37F4000000000000 11 | GLOBL ·SCALE(SB), 8, $8 12 | DATA ·TWO32(SB)/8, $0x41F0000000000000 13 | GLOBL ·TWO32(SB), 8, $8 14 | DATA ·TWO64(SB)/8, $0x43F0000000000000 15 | GLOBL ·TWO64(SB), 8, $8 16 | DATA ·TWO96(SB)/8, $0x45F0000000000000 17 | GLOBL ·TWO96(SB), 8, $8 18 | DATA ·ALPHA32(SB)/8, $0x45E8000000000000 19 | GLOBL ·ALPHA32(SB), 8, $8 20 | DATA ·ALPHA64(SB)/8, $0x47E8000000000000 21 | GLOBL ·ALPHA64(SB), 8, $8 22 | DATA ·ALPHA96(SB)/8, $0x49E8000000000000 23 | GLOBL ·ALPHA96(SB), 8, $8 24 | DATA ·ALPHA130(SB)/8, $0x4C08000000000000 25 | GLOBL ·ALPHA130(SB), 8, $8 26 | DATA ·DOFFSET0(SB)/8, $0x4330000000000000 27 | GLOBL ·DOFFSET0(SB), 8, $8 28 | DATA ·DOFFSET1(SB)/8, $0x4530000000000000 29 | GLOBL ·DOFFSET1(SB), 8, $8 30 | DATA ·DOFFSET2(SB)/8, $0x4730000000000000 31 | GLOBL ·DOFFSET2(SB), 8, $8 32 | DATA ·DOFFSET3(SB)/8, $0x4930000000000000 33 | GLOBL ·DOFFSET3(SB), 8, $8 34 | DATA ·DOFFSET3MINUSTWO128(SB)/8, $0x492FFFFE00000000 35 | GLOBL ·DOFFSET3MINUSTWO128(SB), 8, $8 36 | DATA ·HOFFSET0(SB)/8, $0x43300001FFFFFFFB 37 | GLOBL ·HOFFSET0(SB), 8, $8 38 | DATA ·HOFFSET1(SB)/8, $0x45300001FFFFFFFE 39 | GLOBL ·HOFFSET1(SB), 8, $8 40 | DATA ·HOFFSET2(SB)/8, $0x47300001FFFFFFFE 41 | GLOBL ·HOFFSET2(SB), 8, $8 42 | DATA ·HOFFSET3(SB)/8, $0x49300003FFFFFFFE 43 | GLOBL ·HOFFSET3(SB), 8, $8 44 | DATA ·ROUNDING(SB)/2, $0x137f 45 | GLOBL ·ROUNDING(SB), 8, $2 46 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/poly1305/poly1305.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 | /* 6 | Package poly1305 implements Poly1305 one-time message authentication code as specified in http://cr.yp.to/mac/poly1305-20050329.pdf. 7 | 8 | Poly1305 is a fast, one-time authentication function. It is infeasible for an 9 | attacker to generate an authenticator for a message without the key. However, a 10 | key must only be used for a single message. Authenticating two different 11 | messages with the same key allows an attacker to forge authenticators for other 12 | messages with the same key. 13 | 14 | Poly1305 was originally coupled with AES in order to make Poly1305-AES. AES was 15 | used with a fixed key in order to generate one-time keys from an nonce. 16 | However, in this package AES isn't used and the one-time key is specified 17 | directly. 18 | */ 19 | package poly1305 // import "golang.org/x/crypto/poly1305" 20 | 21 | import "crypto/subtle" 22 | 23 | // TagSize is the size, in bytes, of a poly1305 authenticator. 24 | const TagSize = 16 25 | 26 | // Verify returns true if mac is a valid authenticator for m with the given 27 | // key. 28 | func Verify(mac *[16]byte, m []byte, key *[32]byte) bool { 29 | var tmp [16]byte 30 | Sum(&tmp, m, key) 31 | return subtle.ConstantTimeCompare(tmp[:], mac[:]) == 1 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/poly1305/sum_amd64.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 amd64,!gccgo,!appengine 6 | 7 | package poly1305 8 | 9 | // This function is implemented in poly1305_amd64.s 10 | 11 | //go:noescape 12 | 13 | func poly1305(out *[16]byte, m *byte, mlen uint64, key *[32]byte) 14 | 15 | // Sum generates an authenticator for m using a one-time key and puts the 16 | // 16-byte result into out. Authenticating two different messages with the same 17 | // key allows an attacker to forge messages at will. 18 | func Sum(out *[16]byte, m []byte, key *[32]byte) { 19 | var mPtr *byte 20 | if len(m) > 0 { 21 | mPtr = &m[0] 22 | } 23 | poly1305(out, mPtr, uint64(len(m)), key) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/poly1305/sum_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,!gccgo,!appengine 6 | 7 | package poly1305 8 | 9 | // This function is implemented in poly1305_arm.s 10 | 11 | //go:noescape 12 | 13 | func poly1305_auth_armv6(out *[16]byte, m *byte, mlen uint32, key *[32]byte) 14 | 15 | // Sum generates an authenticator for m using a one-time key and puts the 16 | // 16-byte result into out. Authenticating two different messages with the same 17 | // key allows an attacker to forge messages at will. 18 | func Sum(out *[16]byte, m []byte, key *[32]byte) { 19 | var mPtr *byte 20 | if len(m) > 0 { 21 | mPtr = &m[0] 22 | } 23 | poly1305_auth_armv6(out, mPtr, uint32(len(m)), key) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ripemd160/ripemd160_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 ripemd160 6 | 7 | // Test vectors are from: 8 | // http://homes.esat.kuleuven.be/~bosselae/ripemd160.html 9 | 10 | import ( 11 | "fmt" 12 | "io" 13 | "testing" 14 | ) 15 | 16 | type mdTest struct { 17 | out string 18 | in string 19 | } 20 | 21 | var vectors = [...]mdTest{ 22 | {"9c1185a5c5e9fc54612808977ee8f548b2258d31", ""}, 23 | {"0bdc9d2d256b3ee9daae347be6f4dc835a467ffe", "a"}, 24 | {"8eb208f7e05d987a9b044a8e98c6b087f15a0bfc", "abc"}, 25 | {"5d0689ef49d2fae572b881b123a85ffa21595f36", "message digest"}, 26 | {"f71c27109c692c1b56bbdceb5b9d2865b3708dbc", "abcdefghijklmnopqrstuvwxyz"}, 27 | {"12a053384a9c0c88e405a06c27dcf49ada62eb2b", "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"}, 28 | {"b0e20b6e3116640286ed3a87a5713079b21f5189", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"}, 29 | {"9b752e45573d4b39f4dbd3323cab82bf63326bfb", "12345678901234567890123456789012345678901234567890123456789012345678901234567890"}, 30 | } 31 | 32 | func TestVectors(t *testing.T) { 33 | for i := 0; i < len(vectors); i++ { 34 | tv := vectors[i] 35 | md := New() 36 | for j := 0; j < 3; j++ { 37 | if j < 2 { 38 | io.WriteString(md, tv.in) 39 | } else { 40 | io.WriteString(md, tv.in[0:len(tv.in)/2]) 41 | md.Sum(nil) 42 | io.WriteString(md, tv.in[len(tv.in)/2:]) 43 | } 44 | s := fmt.Sprintf("%x", md.Sum(nil)) 45 | if s != tv.out { 46 | t.Fatalf("RIPEMD-160[%d](%s) = %s, expected %s", j, tv.in, s, tv.out) 47 | } 48 | md.Reset() 49 | } 50 | } 51 | } 52 | 53 | func TestMillionA(t *testing.T) { 54 | md := New() 55 | for i := 0; i < 100000; i++ { 56 | io.WriteString(md, "aaaaaaaaaa") 57 | } 58 | out := "52783243c1697bdbe16d37f97f68f08325dc1528" 59 | s := fmt.Sprintf("%x", md.Sum(nil)) 60 | if s != out { 61 | t.Fatalf("RIPEMD-160 (1 million 'a') = %s, expected %s", s, out) 62 | } 63 | md.Reset() 64 | } 65 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.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 amd64,!appengine,!gccgo 6 | 7 | package salsa 8 | 9 | // This function is implemented in salsa2020_amd64.s. 10 | 11 | //go:noescape 12 | 13 | func salsa2020XORKeyStream(out, in *byte, n uint64, nonce, key *byte) 14 | 15 | // XORKeyStream crypts bytes from in to out using the given key and counters. 16 | // In and out may be the same slice but otherwise should not overlap. Counter 17 | // contains the raw salsa20 counter bytes (both nonce and block counter). 18 | func XORKeyStream(out, in []byte, counter *[16]byte, key *[32]byte) { 19 | if len(in) == 0 { 20 | return 21 | } 22 | salsa2020XORKeyStream(&out[0], &in[0], uint64(len(in)), &counter[0], &key[0]) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/salsa20/salsa/salsa_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 salsa 6 | 7 | import "testing" 8 | 9 | func TestCore208(t *testing.T) { 10 | in := [64]byte{ 11 | 0x7e, 0x87, 0x9a, 0x21, 0x4f, 0x3e, 0xc9, 0x86, 12 | 0x7c, 0xa9, 0x40, 0xe6, 0x41, 0x71, 0x8f, 0x26, 13 | 0xba, 0xee, 0x55, 0x5b, 0x8c, 0x61, 0xc1, 0xb5, 14 | 0x0d, 0xf8, 0x46, 0x11, 0x6d, 0xcd, 0x3b, 0x1d, 15 | 0xee, 0x24, 0xf3, 0x19, 0xdf, 0x9b, 0x3d, 0x85, 16 | 0x14, 0x12, 0x1e, 0x4b, 0x5a, 0xc5, 0xaa, 0x32, 17 | 0x76, 0x02, 0x1d, 0x29, 0x09, 0xc7, 0x48, 0x29, 18 | 0xed, 0xeb, 0xc6, 0x8d, 0xb8, 0xb8, 0xc2, 0x5e} 19 | 20 | out := [64]byte{ 21 | 0xa4, 0x1f, 0x85, 0x9c, 0x66, 0x08, 0xcc, 0x99, 22 | 0x3b, 0x81, 0xca, 0xcb, 0x02, 0x0c, 0xef, 0x05, 23 | 0x04, 0x4b, 0x21, 0x81, 0xa2, 0xfd, 0x33, 0x7d, 24 | 0xfd, 0x7b, 0x1c, 0x63, 0x96, 0x68, 0x2f, 0x29, 25 | 0xb4, 0x39, 0x31, 0x68, 0xe3, 0xc9, 0xe6, 0xbc, 26 | 0xfe, 0x6b, 0xc5, 0xb7, 0xa0, 0x6d, 0x96, 0xba, 27 | 0xe4, 0x24, 0xcc, 0x10, 0x2c, 0x91, 0x74, 0x5c, 28 | 0x24, 0xad, 0x67, 0x3d, 0xc7, 0x61, 0x8f, 0x81, 29 | } 30 | 31 | Core208(&in, &in) 32 | if in != out { 33 | t.Errorf("expected %x, got %x", out, in) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/salsa20/salsa20.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 | /* 6 | Package salsa20 implements the Salsa20 stream cipher as specified in http://cr.yp.to/snuffle/spec.pdf. 7 | 8 | Salsa20 differs from many other stream ciphers in that it is message orientated 9 | rather than byte orientated. Keystream blocks are not preserved between calls, 10 | therefore each side must encrypt/decrypt data with the same segmentation. 11 | 12 | Another aspect of this difference is that part of the counter is exposed as 13 | an nonce in each call. Encrypting two different messages with the same (key, 14 | nonce) pair leads to trivial plaintext recovery. This is analogous to 15 | encrypting two different messages with the same key with a traditional stream 16 | cipher. 17 | 18 | This package also implements XSalsa20: a version of Salsa20 with a 24-byte 19 | nonce as specified in http://cr.yp.to/snuffle/xsalsa-20081128.pdf. Simply 20 | passing a 24-byte slice as the nonce triggers XSalsa20. 21 | */ 22 | package salsa20 // import "golang.org/x/crypto/salsa20" 23 | 24 | // TODO(agl): implement XORKeyStream12 and XORKeyStream8 - the reduced round variants of Salsa20. 25 | 26 | import ( 27 | "golang.org/x/crypto/salsa20/salsa" 28 | ) 29 | 30 | // XORKeyStream crypts bytes from in to out using the given key and nonce. In 31 | // and out may be the same slice but otherwise should not overlap. Nonce must 32 | // be either 8 or 24 bytes long. 33 | func XORKeyStream(out, in []byte, nonce []byte, key *[32]byte) { 34 | if len(out) < len(in) { 35 | in = in[:len(out)] 36 | } 37 | 38 | var subNonce [16]byte 39 | 40 | if len(nonce) == 24 { 41 | var subKey [32]byte 42 | var hNonce [16]byte 43 | copy(hNonce[:], nonce[:16]) 44 | salsa.HSalsa20(&subKey, &hNonce, key, &salsa.Sigma) 45 | copy(subNonce[:], nonce[16:]) 46 | key = &subKey 47 | } else if len(nonce) == 8 { 48 | copy(subNonce[:], nonce[:]) 49 | } else { 50 | panic("salsa20: nonce must be 8 or 24 bytes") 51 | } 52 | 53 | salsa.XORKeyStream(out, in, &subNonce, key) 54 | } 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/sha3/register.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 go1.4 6 | 7 | package sha3 8 | 9 | import ( 10 | "crypto" 11 | ) 12 | 13 | func init() { 14 | crypto.RegisterHash(crypto.SHA3_224, New224) 15 | crypto.RegisterHash(crypto.SHA3_256, New256) 16 | crypto.RegisterHash(crypto.SHA3_384, New384) 17 | crypto.RegisterHash(crypto.SHA3_512, New512) 18 | } 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/sha3/shake.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 sha3 6 | 7 | // This file defines the ShakeHash interface, and provides 8 | // functions for creating SHAKE instances, as well as utility 9 | // functions for hashing bytes to arbitrary-length output. 10 | 11 | import ( 12 | "io" 13 | ) 14 | 15 | // ShakeHash defines the interface to hash functions that 16 | // support arbitrary-length output. 17 | type ShakeHash interface { 18 | // Write absorbs more data into the hash's state. It panics if input is 19 | // written to it after output has been read from it. 20 | io.Writer 21 | 22 | // Read reads more output from the hash; reading affects the hash's 23 | // state. (ShakeHash.Read is thus very different from Hash.Sum) 24 | // It never returns an error. 25 | io.Reader 26 | 27 | // Clone returns a copy of the ShakeHash in its current state. 28 | Clone() ShakeHash 29 | 30 | // Reset resets the ShakeHash to its initial state. 31 | Reset() 32 | } 33 | 34 | func (d *state) Clone() ShakeHash { 35 | return d.clone() 36 | } 37 | 38 | // NewShake128 creates a new SHAKE128 variable-output-length ShakeHash. 39 | // Its generic security strength is 128 bits against all attacks if at 40 | // least 32 bytes of its output are used. 41 | func NewShake128() ShakeHash { return &state{rate: 168, dsbyte: 0x1f} } 42 | 43 | // NewShake256 creates a new SHAKE128 variable-output-length ShakeHash. 44 | // Its generic security strength is 256 bits against all attacks if 45 | // at least 64 bytes of its output are used. 46 | func NewShake256() ShakeHash { return &state{rate: 136, dsbyte: 0x1f} } 47 | 48 | // ShakeSum128 writes an arbitrary-length digest of data into hash. 49 | func ShakeSum128(hash, data []byte) { 50 | h := NewShake128() 51 | h.Write(data) 52 | h.Read(hash) 53 | } 54 | 55 | // ShakeSum256 writes an arbitrary-length digest of data into hash. 56 | func ShakeSum256(hash, data []byte) { 57 | h := NewShake256() 58 | h.Write(data) 59 | h.Read(hash) 60 | } 61 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/sha3/testdata/keccakKats.json.deflate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bom-d-van/harp/b48f6f9b63f168de49963b2c37e1a22092370132/vendor/golang.org/x/crypto/sha3/testdata/keccakKats.json.deflate -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/sha3/xor.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !amd64,!386 appengine 6 | 7 | package sha3 8 | 9 | var ( 10 | xorIn = xorInGeneric 11 | copyOut = copyOutGeneric 12 | xorInUnaligned = xorInGeneric 13 | copyOutUnaligned = copyOutGeneric 14 | ) 15 | 16 | const xorImplementationUnaligned = "generic" 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/sha3/xor_generic.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package sha3 6 | 7 | import "encoding/binary" 8 | 9 | // xorInGeneric xors the bytes in buf into the state; it 10 | // makes no non-portable assumptions about memory layout 11 | // or alignment. 12 | func xorInGeneric(d *state, buf []byte) { 13 | n := len(buf) / 8 14 | 15 | for i := 0; i < n; i++ { 16 | a := binary.LittleEndian.Uint64(buf) 17 | d.a[i] ^= a 18 | buf = buf[8:] 19 | } 20 | } 21 | 22 | // copyOutGeneric copies ulint64s to a byte buffer. 23 | func copyOutGeneric(d *state, b []byte) { 24 | for i := 0; len(b) >= 8; i++ { 25 | binary.LittleEndian.PutUint64(b, d.a[i]) 26 | b = b[8:] 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/sha3/xor_unaligned.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64 386 6 | // +build !appengine 7 | 8 | package sha3 9 | 10 | import "unsafe" 11 | 12 | func xorInUnaligned(d *state, buf []byte) { 13 | bw := (*[maxRate / 8]uint64)(unsafe.Pointer(&buf[0])) 14 | n := len(buf) 15 | if n >= 72 { 16 | d.a[0] ^= bw[0] 17 | d.a[1] ^= bw[1] 18 | d.a[2] ^= bw[2] 19 | d.a[3] ^= bw[3] 20 | d.a[4] ^= bw[4] 21 | d.a[5] ^= bw[5] 22 | d.a[6] ^= bw[6] 23 | d.a[7] ^= bw[7] 24 | d.a[8] ^= bw[8] 25 | } 26 | if n >= 104 { 27 | d.a[9] ^= bw[9] 28 | d.a[10] ^= bw[10] 29 | d.a[11] ^= bw[11] 30 | d.a[12] ^= bw[12] 31 | } 32 | if n >= 136 { 33 | d.a[13] ^= bw[13] 34 | d.a[14] ^= bw[14] 35 | d.a[15] ^= bw[15] 36 | d.a[16] ^= bw[16] 37 | } 38 | if n >= 144 { 39 | d.a[17] ^= bw[17] 40 | } 41 | if n >= 168 { 42 | d.a[18] ^= bw[18] 43 | d.a[19] ^= bw[19] 44 | d.a[20] ^= bw[20] 45 | } 46 | } 47 | 48 | func copyOutUnaligned(d *state, buf []byte) { 49 | ab := (*[maxRate]uint8)(unsafe.Pointer(&d.a[0])) 50 | copy(buf, ab[:]) 51 | } 52 | 53 | var ( 54 | xorIn = xorInUnaligned 55 | copyOut = copyOutUnaligned 56 | ) 57 | 58 | const xorImplementationUnaligned = "unaligned" 59 | -------------------------------------------------------------------------------- /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/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/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/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/xtea/block.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 | /* 6 | Implementation adapted from Needham and Wheeler's paper: 7 | http://www.cix.co.uk/~klockstone/xtea.pdf 8 | 9 | A precalculated look up table is used during encryption/decryption for values that are based purely on the key. 10 | */ 11 | 12 | package xtea 13 | 14 | // XTEA is based on 64 rounds. 15 | const numRounds = 64 16 | 17 | // blockToUint32 reads an 8 byte slice into two uint32s. 18 | // The block is treated as big endian. 19 | func blockToUint32(src []byte) (uint32, uint32) { 20 | r0 := uint32(src[0])<<24 | uint32(src[1])<<16 | uint32(src[2])<<8 | uint32(src[3]) 21 | r1 := uint32(src[4])<<24 | uint32(src[5])<<16 | uint32(src[6])<<8 | uint32(src[7]) 22 | return r0, r1 23 | } 24 | 25 | // uint32ToBlock writes two uint32s into an 8 byte data block. 26 | // Values are written as big endian. 27 | func uint32ToBlock(v0, v1 uint32, dst []byte) { 28 | dst[0] = byte(v0 >> 24) 29 | dst[1] = byte(v0 >> 16) 30 | dst[2] = byte(v0 >> 8) 31 | dst[3] = byte(v0) 32 | dst[4] = byte(v1 >> 24) 33 | dst[5] = byte(v1 >> 16) 34 | dst[6] = byte(v1 >> 8) 35 | dst[7] = byte(v1 >> 0) 36 | } 37 | 38 | // encryptBlock encrypts a single 8 byte block using XTEA. 39 | func encryptBlock(c *Cipher, dst, src []byte) { 40 | v0, v1 := blockToUint32(src) 41 | 42 | // Two rounds of XTEA applied per loop 43 | for i := 0; i < numRounds; { 44 | v0 += ((v1<<4 ^ v1>>5) + v1) ^ c.table[i] 45 | i++ 46 | v1 += ((v0<<4 ^ v0>>5) + v0) ^ c.table[i] 47 | i++ 48 | } 49 | 50 | uint32ToBlock(v0, v1, dst) 51 | } 52 | 53 | // decryptBlock decrypt a single 8 byte block using XTEA. 54 | func decryptBlock(c *Cipher, dst, src []byte) { 55 | v0, v1 := blockToUint32(src) 56 | 57 | // Two rounds of XTEA applied per loop 58 | for i := numRounds; i > 0; { 59 | i-- 60 | v1 -= ((v0<<4 ^ v0>>5) + v0) ^ c.table[i] 61 | i-- 62 | v0 -= ((v1<<4 ^ v1>>5) + v1) ^ c.table[i] 63 | } 64 | 65 | uint32ToBlock(v0, v1, dst) 66 | } 67 | -------------------------------------------------------------------------------- /version.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const version = 5 4 | --------------------------------------------------------------------------------