From a37fe34bc17f2f3d122da6b121ed83ef8ee7b0fa Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Fri, 5 Oct 2018 14:30:43 -0700 Subject: automate xena/xperimental build --- vendor/github.com/GeertJohan/yubigo/.gitignore | 5 - vendor/github.com/GeertJohan/yubigo/LICENSE | 22 - vendor/github.com/GeertJohan/yubigo/readme.md | 84 --- vendor/github.com/GeertJohan/yubigo/yubigo.go | 565 --------------------- vendor/github.com/hypersleep/easyssh/.gitignore | 24 - vendor/github.com/hypersleep/easyssh/README.md | 13 - vendor/github.com/hypersleep/easyssh/easyssh.go | 225 -------- vendor/github.com/kr/pretty/.gitignore | 4 - vendor/github.com/kr/pretty/License | 21 - vendor/github.com/kr/pretty/Readme | 9 - vendor/github.com/kr/pretty/diff.go | 265 ---------- vendor/github.com/kr/pretty/formatter.go | 328 ------------ vendor/github.com/kr/pretty/go.mod | 3 - vendor/github.com/kr/pretty/pretty.go | 108 ---- vendor/github.com/kr/pretty/zero.go | 41 -- vendor/github.com/kr/text/License | 19 - vendor/github.com/kr/text/Readme | 3 - vendor/github.com/kr/text/doc.go | 3 - vendor/github.com/kr/text/go.mod | 3 - vendor/github.com/kr/text/indent.go | 74 --- vendor/github.com/kr/text/wrap.go | 86 ---- vendor/github.com/mzohreva/GoGraphviz/LICENSE | 21 - .../mzohreva/GoGraphviz/graphviz/attributes.go | 40 -- .../mzohreva/GoGraphviz/graphviz/graphviz.go | 249 --------- 24 files changed, 2215 deletions(-) delete mode 100644 vendor/github.com/GeertJohan/yubigo/.gitignore delete mode 100644 vendor/github.com/GeertJohan/yubigo/LICENSE delete mode 100644 vendor/github.com/GeertJohan/yubigo/readme.md delete mode 100644 vendor/github.com/GeertJohan/yubigo/yubigo.go delete mode 100644 vendor/github.com/hypersleep/easyssh/.gitignore delete mode 100644 vendor/github.com/hypersleep/easyssh/README.md delete mode 100644 vendor/github.com/hypersleep/easyssh/easyssh.go delete mode 100644 vendor/github.com/kr/pretty/.gitignore delete mode 100644 vendor/github.com/kr/pretty/License delete mode 100644 vendor/github.com/kr/pretty/Readme delete mode 100644 vendor/github.com/kr/pretty/diff.go delete mode 100644 vendor/github.com/kr/pretty/formatter.go delete mode 100644 vendor/github.com/kr/pretty/go.mod delete mode 100644 vendor/github.com/kr/pretty/pretty.go delete mode 100644 vendor/github.com/kr/pretty/zero.go delete mode 100644 vendor/github.com/kr/text/License delete mode 100644 vendor/github.com/kr/text/Readme delete mode 100644 vendor/github.com/kr/text/doc.go delete mode 100644 vendor/github.com/kr/text/go.mod delete mode 100644 vendor/github.com/kr/text/indent.go delete mode 100644 vendor/github.com/kr/text/wrap.go delete mode 100644 vendor/github.com/mzohreva/GoGraphviz/LICENSE delete mode 100644 vendor/github.com/mzohreva/GoGraphviz/graphviz/attributes.go delete mode 100644 vendor/github.com/mzohreva/GoGraphviz/graphviz/graphviz.go (limited to 'vendor/github.com') diff --git a/vendor/github.com/GeertJohan/yubigo/.gitignore b/vendor/github.com/GeertJohan/yubigo/.gitignore deleted file mode 100644 index e6d7d4e..0000000 --- a/vendor/github.com/GeertJohan/yubigo/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/yubigo -/yubigo.sublime-project -/yubigo.sublime-workspace -/test -.apikey \ No newline at end of file diff --git a/vendor/github.com/GeertJohan/yubigo/LICENSE b/vendor/github.com/GeertJohan/yubigo/LICENSE deleted file mode 100644 index cb489ee..0000000 --- a/vendor/github.com/GeertJohan/yubigo/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2012, Geert-Johan Riemer -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -2. 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. - -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 OWNER 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. diff --git a/vendor/github.com/GeertJohan/yubigo/readme.md b/vendor/github.com/GeertJohan/yubigo/readme.md deleted file mode 100644 index 73b2f7e..0000000 --- a/vendor/github.com/GeertJohan/yubigo/readme.md +++ /dev/null @@ -1,84 +0,0 @@ - -## yubigo - -Yubigo is a Yubikey client API library that provides an easy way to integrate the Yubikey into any Go application. - -## Installation - -Installation is simple. Use go get: -`go get github.com/GeertJohan/yubigo` - -## Usage - -Make sure to import the library: `import "github.com/GeertJohan/yubigo"` - -For use with the default Yubico servers, make sure you have an API key. [Request a key][getapikey]. - -**Basic OTP checking usage:** -```go - -// create a new yubiAuth instance with id and key -yubiAuth, err := yubigo.NewYubiAuth("1234", "fdsaffqaf4vrc2q3cds=") -if err != nil { - // probably an invalid key was given - log.Fatalln(err) -} - -// verify an OTP string -result, ok, err := yubiAuth.Verify("ccccccbetgjevivbklihljgtbenbfrefccveiglnjfbc") -if err != nil { - log.Fatalln(err) -} - -if ok { - // succes!! The OTP is valid! - log.Printf("Used query was: %s\n", result.GetRequestQuery()) // this query string includes the url of the api-server that responded first. -} else { - // fail! The OTP is invalid or has been used before. - log.Println("The given OTP is invalid!!!") -} -``` - - -**Do not verify HTTPS certificate:** -```go -// Disable HTTPS cert verification. Use true to enable again. -yubiAuth.HttpsVerifyCertificate(false) -``` - - -**HTTP instead of HTTPS:** -```go -// Disable HTTPS. Use true to enable again. -yubiAuth.UseHttps(false) -``` - - -**Custom API server:** -```go -// Set a list of n servers, each server as host + path. -// Do not prepend with protocol -yubiAuth.SetApiServerList("api0.server.com/api/verify", "api1.server.com/api/verify", "otherserver.com/api/verify") -``` - -## Licence - -This project is licensed under a Simplified BSD license. Please read the [LICENSE file][license]. - - -## Todo - - Test files - - More documentation - - Getters/Setters for some options on the YubiAuth object. - -## Protocol & Package documentation - -This project is implementing a pure-Go Yubico OTP Validation Client and is following the [Yubico Validation Protocol Version 2.0][validationProtocolV20]. - -You will find "go doc"-like [package documentation at go.pkgdoc.org][pkgdoc]. - - - [license]: https://github.com/GeertJohan/yubigo/blob/master/LICENSE - [getapikey]: https://upgrade.yubico.com/getapikey/ - [pkgdoc]: http://go.pkgdoc.org/github.com/GeertJohan/yubigo - [validationProtocolV20]: http://code.google.com/p/yubikey-val-server-php/wiki/ValidationProtocolV20 \ No newline at end of file diff --git a/vendor/github.com/GeertJohan/yubigo/yubigo.go b/vendor/github.com/GeertJohan/yubigo/yubigo.go deleted file mode 100644 index f317679..0000000 --- a/vendor/github.com/GeertJohan/yubigo/yubigo.go +++ /dev/null @@ -1,565 +0,0 @@ -package yubigo - -import ( - "bufio" - "crypto/hmac" - "crypto/sha1" - "crypto/tls" - "encoding/base64" - "errors" - "fmt" - "io" - "log" - "math/rand" - "net/http" - "regexp" - "sort" - "strings" - "sync" - "time" -) - -var ( - dvorakToQwerty = strings.NewReplacer( - "j", "c", "x", "b", "e", "d", ".", "e", "u", "f", "i", "g", "d", "h", "c", "i", - "h", "j", "t", "k", "n", "l", "b", "n", "p", "r", "y", "t", "g", "u", "k", "v", - "J", "C", "X", "B", "E", "D", ".", "E", "U", "F", "I", "G", "D", "H", "C", "I", - "H", "J", "T", "K", "N", "L", "B", "N", "P", "R", "Y", "T", "G", "U", "K", "V") - matchDvorak = regexp.MustCompile(`^[jxe.uidchtnbpygkJXE.UIDCHTNBPYGK]{32,48}$`) - matchQwerty = regexp.MustCompile(`^[cbdefghijklnrtuvCBDEFGHIJKLNRTUV]{32,48}$`) - signatureUrlFix = regexp.MustCompile(`\+`) -) - -// Package variable used to override the http client used for communication -// with Yubico. If nil the standard http.Client will be used - if overriding -// you need to ensure the transport options are set. -var HTTPClient *http.Client = nil - -// Parse and verify the given OTP string into prefix (identity) and ciphertext. -// Function returns a non-nil error when given OTP is not in valid format. -// NOTE: This function does NOT verify if the OTP is correct and unused/unique. -func ParseOTP(otp string) (prefix string, ciphertext string, err error) { - if len(otp) < 32 || len(otp) > 48 { - err = errors.New("OTP has wrong length.") - return - } - - // When otp matches dvorak-otp, then translate to qwerty. - if matchDvorak.MatchString(otp) { - otp = dvorakToQwerty.Replace(otp) - } - - // Verify that otp matches qwerty expectations - if !matchQwerty.MatchString(otp) { - err = errors.New("Given string is not a valid Yubikey OTP. It contains invalid characters and/or the length is wrong.") - return - } - - l := len(otp) - prefix = otp[0 : l-32] - ciphertext = otp[l-32 : l] - return -} - -type YubiAuth struct { - id string - key []byte - apiServerList []string - protocol string - verifyCertificate bool - workers []*verifyWorker - use sync.Mutex - debug bool -} - -type verifyWorker struct { - ya *YubiAuth // YubiAuth this worker belongs to - id int // Worker id - client *http.Client // http client standing by ready for work - apiServer string // API server URL - work chan *workRequest // Channel on which the worker receives work - stop chan bool // Channel for stop signal -} - -type workRequest struct { - paramString *string - resultChan chan *workResult -} - -type workResult struct { - response *http.Response - requestQuery string - err error // indicates a failing server/network. This doesn't mean the OTP is invalid. -} - -func (vw *verifyWorker) process() { - if vw.ya.debug { - log.Printf("worker[%d]: Started.\n", vw.id) - } - for { - select { - case w := <-vw.work: - - // Create url - url := vw.ya.protocol + vw.apiServer + *w.paramString - - if vw.ya.debug { - log.Printf("worker[%d]: Have work. Requesting: %s\n", vw.id, url) - } - - // Create request - request, err := http.NewRequest("GET", url, nil) - if err != nil { - w.resultChan <- &workResult{ - response: nil, - requestQuery: url, - err: fmt.Errorf("Could not create http request. Error: %s\n", err), - } - continue - } - request.Header.Add("User-Agent", "github.com/GeertJohan/yubigo") - - // Call server - response, err := vw.client.Do(request) - - // If we received an error from the client, return that (wrapped) on the channel. - if err != nil { - w.resultChan <- &workResult{ - response: nil, - requestQuery: url, - err: fmt.Errorf("Http client error: %s\n", err), - } - if vw.ya.debug { - log.Printf("worker[%d]: Http client error: %s", vw.id, err) - } - continue - } - - // It seems everything is ok! return the response (wrapped) on the channel. - if vw.ya.debug { - log.Printf("worker[%d] Received result from api server. Sending on channel.", vw.id) - } - w.resultChan <- &workResult{ - response: response, - requestQuery: url, - err: nil, - } - continue - case <-vw.stop: - if vw.ya.debug { - log.Printf("worker[%d]: received stop signal.\n", vw.id) - } - return - } - } -} - -// Create a yubiAuth instance with given API-id and API-key. -// Returns an error when the key could not be base64 decoded. -// To use yubigo with the Yubico Web Service (default api servers), create an API id+key here: https://upgrade.yubico.com/getapikey/ -// Debugging is disabled. For debugging: use NewYubiAuthDebug(..) -func NewYubiAuth(id string, key string) (auth *YubiAuth, err error) { - return NewYubiAuthDebug(id, key, false) -} - -// Create a yubiAuth instance for given API-id and API-key. -// Has third parameter `debug`. When debug is true this YubiAuth instance will spam the console with logging messages. -// Returns an error when the key could not be base64 decoded. -// To use yubigo with the Yubico Web Service (default api servers), create an API id+key here: https://upgrade.yubico.com/getapikey/ -func NewYubiAuthDebug(id string, key string, debug bool) (auth *YubiAuth, err error) { - keyBytes, err := base64.StdEncoding.DecodeString(key) - if err != nil { - err = fmt.Errorf("Given key seems to be invalid. Could not base64_decode. Error: %s\n", err) - return - } - - if debug { - log.Printf("NewYubiAuthDebug: Given key is base64 decodable. Creating new YubiAuth instance with api id '%s'.\n", id) - } - - auth = &YubiAuth{ - id: id, - key: keyBytes, - - apiServerList: []string{"api.yubico.com/wsapi/2.0/verify", - "api2.yubico.com/wsapi/2.0/verify", - "api3.yubico.com/wsapi/2.0/verify", - "api4.yubico.com/wsapi/2.0/verify", - "api5.yubico.com/wsapi/2.0/verify"}, - - protocol: "https://", - verifyCertificate: true, - - debug: debug, - } - - if debug { - log.Printf("NewYubiAuthDebug: Using yubico web servers: %#v\n", auth.apiServerList) - log.Println("NewYubiAuthDebug: Going to build workers.") - } - - // Build workers - auth.buildWorkers() - - // All done :) - return -} - -// Stops existing workers and creates new ones. -func (ya *YubiAuth) buildWorkers() { - // Unexported (internal) method, so no locking. - - // create tls config - tlsConfig := &tls.Config{} - if !ya.verifyCertificate { - tlsConfig.InsecureSkipVerify = true - } - - // stop all existing workers - for _, worker := range ya.workers { - worker.stop <- true - } - - // create new (empty) slice with exact capacity - ya.workers = make([]*verifyWorker, 0, len(ya.apiServerList)) - - // start new workers. One for each apiServerString - for id, apiServer := range ya.apiServerList { - // create worker instance with new http.Client instance - worker := &verifyWorker{ - ya: ya, - id: id, - apiServer: apiServer + "?", - work: make(chan *workRequest), - stop: make(chan bool), - } - - if HTTPClient == nil { - worker.client = &http.Client{ - Transport: &http.Transport{ - TLSClientConfig: tlsConfig, - }, - } - } else { - worker.client = HTTPClient - } - - ya.workers = append(ya.workers, worker) - - // start worker process in new goroutine - go worker.process() - } -} - -// Use this method to specify a list of servers for verification. -// Each server string should contain host + path. -// Example: "api.yubico.com/wsapi/2.0/verify". -func (ya *YubiAuth) SetApiServerList(urls ...string) { - // Lock - ya.use.Lock() - defer ya.use.Unlock() - - // save setting - ya.apiServerList = urls - - // rebuild workers (api server url's have changed) - ya.buildWorkers() -} - -// Retrieve the the ist of servers that are being used for verification. -func (ya *YubiAuth) GetApiServerList() []string { - return ya.apiServerList -} - -// Enable or disable the use of https -func (ya *YubiAuth) UseHttps(useHttps bool) { - // Lock - ya.use.Lock() - defer ya.use.Unlock() - - // change setting - if useHttps { - ya.protocol = "https://" - } else { - ya.protocol = "http://" - } - - // no need to rebuild workers, they re-read ya.protocol on each request. -} - -// Enable or disable https certificate verification -// Disable this at your own risk. -func (ya *YubiAuth) HttpsVerifyCertificate(verifyCertificate bool) { - // Lock - ya.use.Lock() - defer ya.use.Unlock() - - // save setting - ya.verifyCertificate = verifyCertificate - - // rebuild workers (client has to be changed) - ya.buildWorkers() -} - -// The verify method calls the API with given OTP and returns if the OTP is valid or not. -// This method will return an error if something unexpected happens -// If no error was returned, the returned 'ok bool' indicates if the OTP is valid -// if the 'ok bool' is true, additional informtion can be found in the returned YubiResponse object -func (ya *YubiAuth) Verify(otp string) (yr *YubiResponse, ok bool, err error) { - // Lock - ya.use.Lock() - defer ya.use.Unlock() - - // check the OTP - _, _, err = ParseOTP(otp) - if err != nil { - return nil, false, err - } - - // create slice to store parameters for this verification request - paramSlice := make([]string, 0) - paramSlice = append(paramSlice, "id="+ya.id) - paramSlice = append(paramSlice, "otp="+otp) - - // Create 40 characters nonce - rand.Seed(time.Now().UnixNano()) - k := make([]rune, 40) - for i := 0; i < 40; i++ { - c := rand.Intn(35) - if c < 10 { - c += 48 // numbers (0-9) (0+48 == 48 == '0', 9+48 == 57 == '9') - } else { - c += 87 // lower case alphabets (a-z) (10+87 == 97 == 'a', 35+87 == 122 = 'z') - } - k[i] = rune(c) - } - nonce := string(k) - paramSlice = append(paramSlice, "nonce="+nonce) - - // These settings are hardcoded in the library for now. - //++ TODO(GeertJohan): add these values to the yubiAuth object and create getters/setters - // paramSlice = append(paramSlice, "timestamp=1") - paramSlice = append(paramSlice, "sl=secure") - - //++ TODO(GeertJohan): Add timeout support? - //++ //paramSlice = append(paramSlice, "timeout=") - - // sort the slice - sort.Strings(paramSlice) - - // create parameter string - paramString := strings.Join(paramSlice, "&") - - // generate signature - if len(ya.key) > 0 { - hmacenc := hmac.New(sha1.New, ya.key) - _, err := hmacenc.Write([]byte(paramString)) - if err != nil { - return nil, false, fmt.Errorf("Could not calculate signature. Error: %s\n", err) - } - signature := base64.StdEncoding.EncodeToString(hmacenc.Sum([]byte{})) - signature = signatureUrlFix.ReplaceAllString(signature, `%2B`) - paramString = paramString + "&h=" + signature - } - - // create result channel, buffersize equals the amount of workers. - resultChan := make(chan *workResult, len(ya.workers)) - - // create workRequest instance - wr := &workRequest{ - paramString: ¶mString, - resultChan: resultChan, - } - - // send workRequest to each worker - for _, worker := range ya.workers { - worker.work <- wr - } - - // count the errors so we can handle when all servers fail (network fail for instance) - errCount := 0 - - // local result var, will contain the first result we have - var result *workResult - - // keep looping until we have a good result - for { - // listen for result from a worker - result = <-resultChan - - // check for error - if result.err != nil { - // increment error counter - errCount++ - - if ya.debug { - // debug logging - log.Printf("A server (%s) gave error back: %s\n", result.requestQuery, result.err) - } - - if errCount == len(ya.apiServerList) { - // All workers are done, there's nothing left to try. we return an error. - return nil, false, errors.New("None of the servers responded properly.") - } - - // we have an error, but not all workers responded yet, so lets wait for the next result. - continue - } - - // create a yubiResult from the workers response. - yr, err = newYubiResponse(result) - if err != nil { - return nil, false, err - } - - // Check for "REPLAYED_REQUEST" result. - if status, _ := yr.resultParameters["status"]; status == "REPLAYED_REQUEST" { - // The result status is "REPLAYED_REQUEST". - // This means that the server for this request got sync with an other server before our request. - // Lets wait for the result from the other server. - // See: http://forum.yubico.com/viewtopic.php?f=3&t=701 - - // increment error counter - errCount++ - - if ya.debug { - // debug logging - log.Println("Got replayed request: ", result.response.Body) - } - - if errCount == len(ya.apiServerList) { - // All workers are done, there' is nothing left to try. We return an error. - return nil, false, errors.New("None of the servers responded properly.") - } - - // We have a replayed request, but not all workers responded yet, so lets wait for the next result. - continue - } - - // No error or REPLAYED_REQUEST. Seems like we have a proper result. - break - } - - // check status - status, ok := yr.resultParameters["status"] - if !ok || status != "OK" { - switch status { - case "BAD_OTP": - return yr, false, nil - case "REPLAYED_OTP": - return yr, false, errors.New("The OTP is valid, but has been used before. If you receive this error, you might be the victim of a man-in-the-middle attack.") - case "BAD_SIGNATURE": - return yr, false, errors.New("Signature verification at the api server failed. The used id/key combination could be invalid or is not activated (yet).") - case "NO_SUCH_CLIENT": - return yr, false, errors.New("The api server does not accept the given id. It might be invalid or is not activated (yet).") - case "OPERATION_NOT_ALLOWED": - return yr, false, errors.New("The api server does not allow the given api id to verify OTPs.") - case "BACKEND_ERROR": - return yr, false, errors.New("The api server seems to be broken. Please contact the api servers system administration (yubico servers? contact yubico).") - case "NOT_ENOUGH_ANSWERS": - return yr, false, errors.New("The api server could not get requested number of syncs during before timeout") - case "REPLAYED_REQUEST": - panic("Unexpected. This status should've been catched in the worker response loop.") - return yr, false, errors.New("The api server has seen this unique request before. If you receive this error, you might be the victim of a man-in-the-middle attack.") - default: - return yr, false, fmt.Errorf("Unknown status parameter (%s) sent by api server.", status) - } - } - - // check otp - otpCheck, ok := yr.resultParameters["otp"] - if !ok || otp != otpCheck { - return nil, false, errors.New("Could not validate otp value from server response.") - } - - // check nonce - nonceCheck, ok := yr.resultParameters["nonce"] - if !ok || nonce != nonceCheck { - return nil, false, errors.New("Could not validate nonce value from server response.") - } - - // check attached signature with remake of that signature, if key is actually in use. - if len(ya.key) > 0 { - receivedSignature, ok := yr.resultParameters["h"] - if !ok || len(receivedSignature) == 0 { - return nil, false, errors.New("No signature hash was attached by the api server, we do expect one though. This might be a hacking attempt.") - } - - // create a slice with the same size-1 as the parameters map (we're leaving the hash itself out of it's replica calculation) - receivedValuesSlice := make([]string, 0, len(yr.resultParameters)-1) - for key, value := range yr.resultParameters { - if key != "h" { - receivedValuesSlice = append(receivedValuesSlice, key+"="+value) - } - } - sort.Strings(receivedValuesSlice) - receivedValuesString := strings.Join(receivedValuesSlice, "&") - hmacenc := hmac.New(sha1.New, ya.key) - _, err := hmacenc.Write([]byte(receivedValuesString)) - if err != nil { - return nil, false, fmt.Errorf("Could not calculate signature replica. Error: %s\n", err) - } - recievedSignatureReplica := base64.StdEncoding.EncodeToString(hmacenc.Sum([]byte{})) - - if receivedSignature != recievedSignatureReplica { - return nil, false, errors.New("The received signature hash is not valid. This might be a hacking attempt.") - } - } - - // we're done! - yr.validOTP = true - return yr, true, nil - -} - -// Contains details about yubikey OTP verification. -type YubiResponse struct { - requestQuery string - resultParameters map[string]string - validOTP bool -} - -func newYubiResponse(result *workResult) (*YubiResponse, error) { - bodyReader := bufio.NewReader(result.response.Body) - yr := &YubiResponse{} - yr.resultParameters = make(map[string]string) - yr.requestQuery = result.requestQuery - for { - // read through the response lines - line, err := bodyReader.ReadString('\n') - - // handle error, which at one point should be an expected io.EOF (end of file) - if err != nil { - if err == io.EOF { - break // successfully done with reading lines, lets break this for loop - } - return nil, fmt.Errorf("Could not read result body from the server. Error: %s\n", err) - } - - // parse result lines, split on first '=', trim \n and \r - keyvalue := strings.SplitN(line, "=", 2) - if len(keyvalue) == 2 { - yr.resultParameters[keyvalue[0]] = strings.Trim(keyvalue[1], "\n\r") - } - } - return yr, nil -} - -// Returns wether the verification was successful -func (yr *YubiResponse) IsValidOTP() bool { - return yr.validOTP -} - -// Get the requestQuery that was used during verification. -func (yr *YubiResponse) GetRequestQuery() string { - return yr.requestQuery -} - -// Retrieve a parameter from the api's response -func (yr *YubiResponse) GetResultParameter(key string) (value string) { - value, ok := yr.resultParameters[key] - if !ok { - value = "" - } - return value -} diff --git a/vendor/github.com/hypersleep/easyssh/.gitignore b/vendor/github.com/hypersleep/easyssh/.gitignore deleted file mode 100644 index daf913b..0000000 --- a/vendor/github.com/hypersleep/easyssh/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/vendor/github.com/hypersleep/easyssh/README.md b/vendor/github.com/hypersleep/easyssh/README.md deleted file mode 100644 index 96f5cb3..0000000 --- a/vendor/github.com/hypersleep/easyssh/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# easyssh - -## Description - -Package easyssh provides a simple implementation of some SSH protocol features in Go. -You can simply run command on remote server or upload a file even simple than native console SSH client. -Do not need to think about Dials, sessions, defers and public keys...Let easyssh will be think about it! - -## So easy to use! - -[Run a command on remote server and get STDOUT output](https://github.com/hypersleep/easyssh/blob/master/example/run.go) - -[Upload a file to remote server](https://github.com/hypersleep/easyssh/blob/master/example/scp.go) diff --git a/vendor/github.com/hypersleep/easyssh/easyssh.go b/vendor/github.com/hypersleep/easyssh/easyssh.go deleted file mode 100644 index c530eea..0000000 --- a/vendor/github.com/hypersleep/easyssh/easyssh.go +++ /dev/null @@ -1,225 +0,0 @@ -// Package easyssh provides a simple implementation of some SSH protocol -// features in Go. You can simply run a command on a remote server or get a file -// even simpler than native console SSH client. You don't need to think about -// Dials, sessions, defers, or public keys... Let easyssh think about it! -package easyssh - -import ( - "bufio" - "fmt" - "io" - "io/ioutil" - "net" - "os" - "os/user" - "path/filepath" - "time" - - "golang.org/x/crypto/ssh" - "golang.org/x/crypto/ssh/agent" -) - -// Contains main authority information. -// User field should be a name of user on remote server (ex. john in ssh john@example.com). -// Server field should be a remote machine address (ex. example.com in ssh john@example.com) -// Key is a path to private key on your local machine. -// Port is SSH server port on remote machine. -// Note: easyssh looking for private key in user's home directory (ex. /home/john + Key). -// Then ensure your Key begins from '/' (ex. /.ssh/id_rsa) -type MakeConfig struct { - User string - Server string - Key string - Port string - Password string -} - -// returns ssh.Signer from user you running app home path + cutted key path. -// (ex. pubkey,err := getKeyFile("/.ssh/id_rsa") ) -func getKeyFile(keypath string) (ssh.Signer, error) { - usr, err := user.Current() - if err != nil { - return nil, err - } - - file := usr.HomeDir + keypath - buf, err := ioutil.ReadFile(file) - if err != nil { - return nil, err - } - - pubkey, err := ssh.ParsePrivateKey(buf) - if err != nil { - return nil, err - } - - return pubkey, nil -} - -// connects to remote server using MakeConfig struct and returns *ssh.Session -func (ssh_conf *MakeConfig) connect() (*ssh.Session, error) { - // auths holds the detected ssh auth methods - auths := []ssh.AuthMethod{} - - // figure out what auths are requested, what is supported - if ssh_conf.Password != "" { - auths = append(auths, ssh.Password(ssh_conf.Password)) - } - - if sshAgent, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK")); err == nil { - auths = append(auths, ssh.PublicKeysCallback(agent.NewClient(sshAgent).Signers)) - defer sshAgent.Close() - } - - if pubkey, err := getKeyFile(ssh_conf.Key); err == nil { - auths = append(auths, ssh.PublicKeys(pubkey)) - } - - config := &ssh.ClientConfig{ - User: ssh_conf.User, - Auth: auths, - } - - client, err := ssh.Dial("tcp", ssh_conf.Server+":"+ssh_conf.Port, config) - if err != nil { - return nil, err - } - - session, err := client.NewSession() - if err != nil { - return nil, err - } - - return session, nil -} - -// Stream returns one channel that combines the stdout and stderr of the command -// as it is run on the remote machine, and another that sends true when the -// command is done. The sessions and channels will then be closed. -func (ssh_conf *MakeConfig) Stream(command string, timeout int) (stdout chan string, stderr chan string, done chan bool, err error) { - // connect to remote host - session, err := ssh_conf.connect() - if err != nil { - return stdout, stderr, done, err - } - // connect to both outputs (they are of type io.Reader) - outReader, err := session.StdoutPipe() - if err != nil { - return stdout, stderr, done, err - } - errReader, err := session.StderrPipe() - if err != nil { - return stdout, stderr, done, err - } - // combine outputs, create a line-by-line scanner - stdoutReader := io.MultiReader(outReader) - stderrReader := io.MultiReader(errReader) - err = session.Start(command) - stdoutScanner := bufio.NewScanner(stdoutReader) - stderrScanner := bufio.NewScanner(stderrReader) - // continuously send the command's output over the channel - stdoutChan := make(chan string) - stderrChan := make(chan string) - done = make(chan bool) - - go func(stdoutScanner, stderrScanner *bufio.Scanner, stdoutChan, stderrChan chan string, done chan bool) { - defer close(stdoutChan) - defer close(stderrChan) - defer close(done) - - timeoutChan := time.After(time.Duration(timeout) * time.Second) - res := make(chan bool, 1) - - go func() { - for stdoutScanner.Scan() { - stdoutChan <- stdoutScanner.Text() - } - for stderrScanner.Scan() { - stderrChan <- stderrScanner.Text() - } - // close all of our open resources - res <- true - }() - - select { - case <-res: - stdoutChan <- "" - stderrChan <- "" - done <- true - case <-timeoutChan: - stdoutChan <- "" - stderrChan <- "Run Command Timeout!" - done <- false - } - - session.Close() - }(stdoutScanner, stderrScanner, stdoutChan, stderrChan, done) - return stdoutChan, stderrChan, done, err -} - -// Runs command on remote machine and returns its stdout as a string -func (ssh_conf *MakeConfig) Run(command string, timeout int) (outStr string, errStr string, isTimeout bool, err error) { - stdoutChan, stderrChan, doneChan, err := ssh_conf.Stream(command, timeout) - if err != nil { - return outStr, errStr, isTimeout, err - } - // read from the output channel until the done signal is passed - stillGoing := true - for stillGoing { - select { - case isTimeout = <-doneChan: - stillGoing = false - case outline := <-stdoutChan: - outStr += outline + "\n" - case errline := <-stderrChan: - errStr += errline + "\n" - } - } - // return the concatenation of all signals from the output channel - return outStr, errStr, isTimeout, err -} - -// Scp uploads sourceFile to remote machine like native scp console app. -func (ssh_conf *MakeConfig) Scp(sourceFile string, etargetFile string) error { - session, err := ssh_conf.connect() - - if err != nil { - return err - } - defer session.Close() - - targetFile := filepath.Base(etargetFile) - - src, srcErr := os.Open(sourceFile) - - if srcErr != nil { - return srcErr - } - - srcStat, statErr := src.Stat() - - if statErr != nil { - return statErr - } - - go func() { - w, _ := session.StdinPipe() - - fmt.Fprintln(w, "C0644", srcStat.Size(), targetFile) - - if srcStat.Size() > 0 { - io.Copy(w, src) - fmt.Fprint(w, "\x00") - w.Close() - } else { - fmt.Fprint(w, "\x00") - w.Close() - } - }() - - if err := session.Run(fmt.Sprintf("scp -tr %s", etargetFile)); err != nil { - return err - } - - return nil -} diff --git a/vendor/github.com/kr/pretty/.gitignore b/vendor/github.com/kr/pretty/.gitignore deleted file mode 100644 index 1f0a99f..0000000 --- a/vendor/github.com/kr/pretty/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -[568].out -_go* -_test* -_obj diff --git a/vendor/github.com/kr/pretty/License b/vendor/github.com/kr/pretty/License deleted file mode 100644 index 05c783c..0000000 --- a/vendor/github.com/kr/pretty/License +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright 2012 Keith Rarick - -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: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -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. diff --git a/vendor/github.com/kr/pretty/Readme b/vendor/github.com/kr/pretty/Readme deleted file mode 100644 index c589fc6..0000000 --- a/vendor/github.com/kr/pretty/Readme +++ /dev/null @@ -1,9 +0,0 @@ -package pretty - - import "github.com/kr/pretty" - - Package pretty provides pretty-printing for Go values. - -Documentation - - http://godoc.org/github.com/kr/pretty diff --git a/vendor/github.com/kr/pretty/diff.go b/vendor/github.com/kr/pretty/diff.go deleted file mode 100644 index 6aa7f74..0000000 --- a/vendor/github.com/kr/pretty/diff.go +++ /dev/null @@ -1,265 +0,0 @@ -package pretty - -import ( - "fmt" - "io" - "reflect" -) - -type sbuf []string - -func (p *sbuf) Printf(format string, a ...interface{}) { - s := fmt.Sprintf(format, a...) - *p = append(*p, s) -} - -// Diff returns a slice where each element describes -// a difference between a and b. -func Diff(a, b interface{}) (desc []string) { - Pdiff((*sbuf)(&desc), a, b) - return desc -} - -// wprintfer calls Fprintf on w for each Printf call -// with a trailing newline. -type wprintfer struct{ w io.Writer } - -func (p *wprintfer) Printf(format string, a ...interface{}) { - fmt.Fprintf(p.w, format+"\n", a...) -} - -// Fdiff writes to w a description of the differences between a and b. -func Fdiff(w io.Writer, a, b interface{}) { - Pdiff(&wprintfer{w}, a, b) -} - -type Printfer interface { - Printf(format string, a ...interface{}) -} - -// Pdiff prints to p a description of the differences between a and b. -// It calls Printf once for each difference, with no trailing newline. -// The standard library log.Logger is a Printfer. -func Pdiff(p Printfer, a, b interface{}) { - diffPrinter{w: p}.diff(reflect.ValueOf(a), reflect.ValueOf(b)) -} - -type Logfer interface { - Logf(format string, a ...interface{}) -} - -// logprintfer calls Fprintf on w for each Printf call -// with a trailing newline. -type logprintfer struct{ l Logfer } - -func (p *logprintfer) Printf(format string, a ...interface{}) { - p.l.Logf(format, a...) -} - -// Ldiff prints to l a description of the differences between a and b. -// It calls Logf once for each difference, with no trailing newline. -// The standard library testing.T and testing.B are Logfers. -func Ldiff(l Logfer, a, b interface{}) { - Pdiff(&logprintfer{l}, a, b) -} - -type diffPrinter struct { - w Printfer - l string // label -} - -func (w diffPrinter) printf(f string, a ...interface{}) { - var l string - if w.l != "" { - l = w.l + ": " - } - w.w.Printf(l+f, a...) -} - -func (w diffPrinter) diff(av, bv reflect.Value) { - if !av.IsValid() && bv.IsValid() { - w.printf("nil != %# v", formatter{v: bv, quote: true}) - return - } - if av.IsValid() && !bv.IsValid() { - w.printf("%# v != nil", formatter{v: av, quote: true}) - return - } - if !av.IsValid() && !bv.IsValid() { - return - } - - at := av.Type() - bt := bv.Type() - if at != bt { - w.printf("%v != %v", at, bt) - return - } - - switch kind := at.Kind(); kind { - case reflect.Bool: - if a, b := av.Bool(), bv.Bool(); a != b { - w.printf("%v != %v", a, b) - } - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - if a, b := av.Int(), bv.Int(); a != b { - w.printf("%d != %d", a, b) - } - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - if a, b := av.Uint(), bv.Uint(); a != b { - w.printf("%d != %d", a, b) - } - case reflect.Float32, reflect.Float64: - if a, b := av.Float(), bv.Float(); a != b { - w.printf("%v != %v", a, b) - } - case reflect.Complex64, reflect.Complex128: - if a, b := av.Complex(), bv.Complex(); a != b { - w.printf("%v != %v", a, b) - } - case reflect.Array: - n := av.Len() - for i := 0; i < n; i++ { - w.relabel(fmt.Sprintf("[%d]", i)).diff(av.Index(i), bv.Index(i)) - } - case reflect.Chan, reflect.Func, reflect.UnsafePointer: - if a, b := av.Pointer(), bv.Pointer(); a != b { - w.printf("%#x != %#x", a, b) - } - case reflect.Interface: - w.diff(av.Elem(), bv.Elem()) - case reflect.Map: - ak, both, bk := keyDiff(av.MapKeys(), bv.MapKeys()) - for _, k := range ak { - w := w.relabel(fmt.Sprintf("[%#v]", k)) - w.printf("%q != (missing)", av.MapIndex(k)) - } - for _, k := range both { - w := w.relabel(fmt.Sprintf("[%#v]", k)) - w.diff(av.MapIndex(k), bv.MapIndex(k)) - } - for _, k := range bk { - w := w.relabel(fmt.Sprintf("[%#v]", k)) - w.printf("(missing) != %q", bv.MapIndex(k)) - } - case reflect.Ptr: - switch { - case av.IsNil() && !bv.IsNil(): - w.printf("nil != %# v", formatter{v: bv, quote: true}) - case !av.IsNil() && bv.IsNil(): - w.printf("%# v != nil", formatter{v: av, quote: true}) - case !av.IsNil() && !bv.IsNil(): - w.diff(av.Elem(), bv.Elem()) - } - case reflect.Slice: - lenA := av.Len() - lenB := bv.Len() - if lenA != lenB { - w.printf("%s[%d] != %s[%d]", av.Type(), lenA, bv.Type(), lenB) - break - } - for i := 0; i < lenA; i++ { - w.relabel(fmt.Sprintf("[%d]", i)).diff(av.Index(i), bv.Index(i)) - } - case reflect.String: - if a, b := av.String(), bv.String(); a != b { - w.printf("%q != %q", a, b) - } - case reflect.Struct: - for i := 0; i < av.NumField(); i++ { - w.relabel(at.Field(i).Name).diff(av.Field(i), bv.Field(i)) - } - default: - panic("unknown reflect Kind: " + kind.String()) - } -} - -func (d diffPrinter) relabel(name string) (d1 diffPrinter) { - d1 = d - if d.l != "" && name[0] != '[' { - d1.l += "." - } - d1.l += name - return d1 -} - -// keyEqual compares a and b for equality. -// Both a and b must be valid map keys. -func keyEqual(av, bv reflect.Value) bool { - if !av.IsValid() && !bv.IsValid() { - return true - } - if !av.IsValid() || !bv.IsValid() || av.Type() != bv.Type() { - return false - } - switch kind := av.Kind(); kind { - case reflect.Bool: - a, b := av.Bool(), bv.Bool() - return a == b - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - a, b := av.Int(), bv.Int() - return a == b - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - a, b := av.Uint(), bv.Uint() - return a == b - case reflect.Float32, reflect.Float64: - a, b := av.Float(), bv.Float() - return a == b - case reflect.Complex64, reflect.Complex128: - a, b := av.Complex(), bv.Complex() - return a == b - case reflect.Array: - for i := 0; i < av.Len(); i++ { - if !keyEqual(av.Index(i), bv.Index(i)) { - return false - } - } - return true - case reflect.Chan, reflect.UnsafePointer, reflect.Ptr: - a, b := av.Pointer(), bv.Pointer() - return a == b - case reflect.Interface: - return keyEqual(av.Elem(), bv.Elem()) - case reflect.String: - a, b := av.String(), bv.String() - return a == b - case reflect.Struct: - for i := 0; i < av.NumField(); i++ { - if !keyEqual(av.Field(i), bv.Field(i)) { - return false - } - } - return true - default: - panic("invalid map key type " + av.Type().String()) - } -} - -func keyDiff(a, b []reflect.Value) (ak, both, bk []reflect.Value) { - for _, av := range a { - inBoth := false - for _, bv := range b { - if keyEqual(av, bv) { - inBoth = true - both = append(both, av) - break - } - } - if !inBoth { - ak = append(ak, av) - } - } - for _, bv := range b { - inBoth := false - for _, av := range a { - if keyEqual(av, bv) { - inBoth = true - break - } - } - if !inBoth { - bk = append(bk, bv) - } - } - return -} diff --git a/vendor/github.com/kr/pretty/formatter.go b/vendor/github.com/kr/pretty/formatter.go deleted file mode 100644 index a317d7b..0000000 --- a/vendor/github.com/kr/pretty/formatter.go +++ /dev/null @@ -1,328 +0,0 @@ -package pretty - -import ( - "fmt" - "io" - "reflect" - "strconv" - "text/tabwriter" - - "github.com/kr/text" -) - -type formatter struct { - v reflect.Value - force bool - quote bool -} - -// Formatter makes a wrapper, f, that will format x as go source with line -// breaks and tabs. Object f responds to the "%v" formatting verb when both the -// "#" and " " (space) flags are set, for example: -// -// fmt.Sprintf("%# v", Formatter(x)) -// -// If one of these two flags is not set, or any other verb is used, f will -// format x according to the usual rules of package fmt. -// In particular, if x satisfies fmt.Formatter, then x.Format will be called. -func Formatter(x interface{}) (f fmt.Formatter) { - return formatter{v: reflect.ValueOf(x), quote: true} -} - -func (fo formatter) String() string { - return fmt.Sprint(fo.v.Interface()) // unwrap it -} - -func (fo formatter) passThrough(f fmt.State, c rune) { - s := "%" - for i := 0; i < 128; i++ { - if f.Flag(i) { - s += string(i) - } - } - if w, ok := f.Width(); ok { - s += fmt.Sprintf("%d", w) - } - if p, ok := f.Precision(); ok { - s += fmt.Sprintf(".%d", p) - } - s += string(c) - fmt.Fprintf(f, s, fo.v.Interface()) -} - -func (fo formatter) Format(f fmt.State, c rune) { - if fo.force || c == 'v' && f.Flag('#') && f.Flag(' ') { - w := tabwriter.NewWriter(f, 4, 4, 1, ' ', 0) - p := &printer{tw: w, Writer: w, visited: make(map[visit]int)} - p.printValue(fo.v, true, fo.quote) - w.Flush() - return - } - fo.passThrough(f, c) -} - -type printer struct { - io.Writer - tw *tabwriter.Writer - visited map[visit]int - depth int -} - -func (p *printer) indent() *printer { - q := *p - q.tw = tabwriter.NewWriter(p.Writer, 4, 4, 1, ' ', 0) - q.Writer = text.NewIndentWriter(q.tw, []byte{'\t'}) - return &q -} - -func (p *printer) printInline(v reflect.Value, x interface{}, showType bool) { - if showType { - io.WriteString(p, v.Type().String()) - fmt.Fprintf(p, "(%#v)", x) - } else { - fmt.Fprintf(p, "%#v", x) - } -} - -// printValue must keep track of already-printed pointer values to avoid -// infinite recursion. -type visit struct { - v uintptr - typ reflect.Type -} - -func (p *printer) printValue(v reflect.Value, showType, quote bool) { - if p.depth > 10 { - io.WriteString(p, "!%v(DEPTH EXCEEDED)") - return - } - - switch v.Kind() { - case reflect.Bool: - p.printInline(v, v.Bool(), showType) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - p.printInline(v, v.Int(), showType) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - p.printInline(v, v.Uint(), showType) - case reflect.Float32, reflect.Float64: - p.printInline(v, v.Float(), showType) - case reflect.Complex64, reflect.Complex128: - fmt.Fprintf(p, "%#v", v.Complex()) - case reflect.String: - p.fmtString(v.String(), quote) - case reflect.Map: - t := v.Type() - if showType { - io.WriteString(p, t.String()) - } - writeByte(p, '{') - if nonzero(v) { - expand := !canInline(v.Type()) - pp := p - if expand { - writeByte(p, '\n') - pp = p.indent() - } - keys := v.MapKeys() - for i := 0; i < v.Len(); i++ { - showTypeInStruct := true - k := keys[i] - mv := v.MapIndex(k) - pp.printValue(k, false, true) - writeByte(pp, ':') - if expand { - writeByte(pp, '\t') - } - showTypeInStruct = t.Elem().Kind() == reflect.Interface - pp.printValue(mv, showTypeInStruct, true) - if expand { - io.WriteString(pp, ",\n") - } else if i < v.Len()-1 { - io.WriteString(pp, ", ") - } - } - if expand { - pp.tw.Flush() - } - } - writeByte(p, '}') - case reflect.Struct: - t := v.Type() - if v.CanAddr() { - addr := v.UnsafeAddr() - vis := visit{addr, t} - if vd, ok := p.visited[vis]; ok && vd < p.depth { - p.fmtString(t.String()+"{(CYCLIC REFERENCE)}", false) - break // don't print v again - } - p.visited[vis] = p.depth - } - - if showType { - io.WriteString(p, t.String()) - } - writeByte(p, '{') - if nonzero(v) { - expand := !canInline(v.Type()) - pp := p - if expand { - writeByte(p, '\n') - pp = p.indent() - } - for i := 0; i < v.NumField(); i++ { - showTypeInStruct := true - if f := t.Field(i); f.Name != "" { - io.WriteString(pp, f.Name) - writeByte(pp, ':') - if expand { - writeByte(pp, '\t') - } - showTypeInStruct = labelType(f.Type) - } - pp.printValue(getField(v, i), showTypeInStruct, true) - if expand { - io.WriteString(pp, ",\n") - } else if i < v.NumField()-1 { - io.WriteString(pp, ", ") - } - } - if expand { - pp.tw.Flush() - } - } - writeByte(p, '}') - case reflect.Interface: - switch e := v.Elem(); { - case e.Kind() == reflect.Invalid: - io.WriteString(p, "nil") - case e.IsValid(): - pp := *p - pp.depth++ - pp.printValue(e, showType, true) - default: - io.WriteString(p, v.Type().String()) - io.WriteString(p, "(nil)") - } - case reflect.Array, reflect.Slice: - t := v.Type() - if showType { - io.WriteString(p, t.String()) - } - if v.Kind() == reflect.Slice && v.IsNil() && showType { - io.WriteString(p, "(nil)") - break - } - if v.Kind() == reflect.Slice && v.IsNil() { - io.WriteString(p, "nil") - break - } - writeByte(p, '{') - expand := !canInline(v.Type()) - pp := p - if expand { - writeByte(p, '\n') - pp = p.indent() - } - for i := 0; i < v.Len(); i++ { - showTypeInSlice := t.Elem().Kind() == reflect.Interface - pp.printValue(v.Index(i), showTypeInSlice, true) - if expand { - io.WriteString(pp, ",\n") - } else if i < v.Len()-1 { - io.WriteString(pp, ", ") - } - } - if expand { - pp.tw.Flush() - } - writeByte(p, '}') - case reflect.Ptr: - e := v.Elem() - if !e.IsValid() { - writeByte(p, '(') - io.WriteString(p, v.Type().String()) - io.WriteString(p, ")(nil)") - } else { - pp := *p - pp.depth++ - writeByte(pp, '&') - pp.printValue(e, true, true) - } - case reflect.Chan: - x := v.Pointer() - if showType { - writeByte(p, '(') - io.WriteString(p, v.Type().String()) - fmt.Fprintf(p, ")(%#v)", x) - } else { - fmt.Fprintf(p, "%#v", x) - } - case reflect.Func: - io.WriteString(p, v.Type().String()) - io.WriteString(p, " {...}") - case reflect.UnsafePointer: - p.printInline(v, v.Pointer(), showType) - case reflect.Invalid: - io.WriteString(p, "nil") - } -} - -func canInline(t reflect.Type) bool { - switch t.Kind() { - case reflect.Map: - return !canExpand(t.Elem()) - case reflect.Struct: - for i := 0; i < t.NumField(); i++ { - if canExpand(t.Field(i).Type) { - return false - } - } - return true - case reflect.Interface: - return false - case reflect.Array, reflect.Slice: - return !canExpand(t.Elem()) - case reflect.Ptr: - return false - case reflect.Chan, reflect.Func, reflect.UnsafePointer: - return false - } - return true -} - -func canExpand(t reflect.Type) bool { - switch t.Kind() { - case reflect.Map, reflect.Struct, - reflect.Interface, reflect.Array, reflect.Slice, - reflect.Ptr: - return true - } - return false -} - -func labelType(t reflect.Type) bool { - switch t.Kind() { - case reflect.Interface, reflect.Struct: - return true - } - return false -} - -func (p *printer) fmtString(s string, quote bool) { - if quote { - s = strconv.Quote(s) - } - io.WriteString(p, s) -} - -func writeByte(w io.Writer, b byte) { - w.Write([]byte{b}) -} - -func getField(v reflect.Value, i int) reflect.Value { - val := v.Field(i) - if val.Kind() == reflect.Interface && !val.IsNil() { - val = val.Elem() - } - return val -} diff --git a/vendor/github.com/kr/pretty/go.mod b/vendor/github.com/kr/pretty/go.mod deleted file mode 100644 index 1e29533..0000000 --- a/vendor/github.com/kr/pretty/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module "github.com/kr/pretty" - -require "github.com/kr/text" v0.1.0 diff --git a/vendor/github.com/kr/pretty/pretty.go b/vendor/github.com/kr/pretty/pretty.go deleted file mode 100644 index 49423ec..0000000 --- a/vendor/github.com/kr/pretty/pretty.go +++ /dev/null @@ -1,108 +0,0 @@ -// Package pretty provides pretty-printing for Go values. This is -// useful during debugging, to avoid wrapping long output lines in -// the terminal. -// -// It provides a function, Formatter, that can be used with any -// function that accepts a format string. It also provides -// convenience wrappers for functions in packages fmt and log. -package pretty - -import ( - "fmt" - "io" - "log" - "reflect" -) - -// Errorf is a convenience wrapper for fmt.Errorf. -// -// Calling Errorf(f, x, y) is equivalent to -// fmt.Errorf(f, Formatter(x), Formatter(y)). -func Errorf(format string, a ...interface{}) error { - return fmt.Errorf(format, wrap(a, false)...) -} - -// Fprintf is a convenience wrapper for fmt.Fprintf. -// -// Calling Fprintf(w, f, x, y) is equivalent to -// fmt.Fprintf(w, f, Formatter(x), Formatter(y)). -func Fprintf(w io.Writer, format string, a ...interface{}) (n int, error error) { - return fmt.Fprintf(w, format, wrap(a, false)...) -} - -// Log is a convenience wrapper for log.Printf. -// -// Calling Log(x, y) is equivalent to -// log.Print(Formatter(x), Formatter(y)), but each operand is -// formatted with "%# v". -func Log(a ...interface{}) { - log.Print(wrap(a, true)...) -} - -// Logf is a convenience wrapper for log.Printf. -// -// Calling Logf(f, x, y) is equivalent to -// log.Printf(f, Formatter(x), Formatter(y)). -func Logf(format string, a ...interface{}) { - log.Printf(format, wrap(a, false)...) -} - -// Logln is a convenience wrapper for log.Printf. -// -// Calling Logln(x, y) is equivalent to -// log.Println(Formatter(x), Formatter(y)), but each operand is -// formatted with "%# v". -func Logln(a ...interface{}) { - log.Println(wrap(a, true)...) -} - -// Print pretty-prints its operands and writes to standard output. -// -// Calling Print(x, y) is equivalent to -// fmt.Print(Formatter(x), Formatter(y)), but each operand is -// formatted with "%# v". -func Print(a ...interface{}) (n int, errno error) { - return fmt.Print(wrap(a, true)...) -} - -// Printf is a convenience wrapper for fmt.Printf. -// -// Calling Printf(f, x, y) is equivalent to -// fmt.Printf(f, Formatter(x), Formatter(y)). -func Printf(format string, a ...interface{}) (n int, errno error) { - return fmt.Printf(format, wrap(a, false)...) -} - -// Println pretty-prints its operands and writes to standard output. -// -// Calling Print(x, y) is equivalent to -// fmt.Println(Formatter(x), Formatter(y)), but each operand is -// formatted with "%# v". -func Println(a ...interface{}) (n int, errno error) { - return fmt.Println(wrap(a, true)...) -} - -// Sprint is a convenience wrapper for fmt.Sprintf. -// -// Calling Sprint(x, y) is equivalent to -// fmt.Sprint(Formatter(x), Formatter(y)), but each operand is -// formatted with "%# v". -func Sprint(a ...interface{}) string { - return fmt.Sprint(wrap(a, true)...) -} - -// Sprintf is a convenience wrapper for fmt.Sprintf. -// -// Calling Sprintf(f, x, y) is equivalent to -// fmt.Sprintf(f, Formatter(x), Formatter(y)). -func Sprintf(format string, a ...interface{}) string { - return fmt.Sprintf(format, wrap(a, false)...) -} - -func wrap(a []interface{}, force bool) []interface{} { - w := make([]interface{}, len(a)) - for i, x := range a { - w[i] = formatter{v: reflect.ValueOf(x), force: force} - } - return w -} diff --git a/vendor/github.com/kr/pretty/zero.go b/vendor/github.com/kr/pretty/zero.go deleted file mode 100644 index abb5b6f..0000000 --- a/vendor/github.com/kr/pretty/zero.go +++ /dev/null @@ -1,41 +0,0 @@ -package pretty - -import ( - "reflect" -) - -func nonzero(v reflect.Value) bool { - switch v.Kind() { - case reflect.Bool: - return v.Bool() - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return v.Int() != 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return v.Uint() != 0 - case reflect.Float32, reflect.Float64: - return v.Float() != 0 - case reflect.Complex64, reflect.Complex128: - return v.Complex() != complex(0, 0) - case reflect.String: - return v.String() != "" - case reflect.Struct: - for i := 0; i < v.NumField(); i++ { - if nonzero(getField(v, i)) { - return true - } - } - return false - case reflect.Array: - for i := 0; i < v.Len(); i++ { - if nonzero(v.Index(i)) { - return true - } - } - return false - case reflect.Map, reflect.Interface, reflect.Slice, reflect.Ptr, reflect.Chan, reflect.Func: - return !v.IsNil() - case reflect.UnsafePointer: - return v.Pointer() != 0 - } - return true -} diff --git a/vendor/github.com/kr/text/License b/vendor/github.com/kr/text/License deleted file mode 100644 index 480a328..0000000 --- a/vendor/github.com/kr/text/License +++ /dev/null @@ -1,19 +0,0 @@ -Copyright 2012 Keith Rarick - -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: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -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. diff --git a/vendor/github.com/kr/text/Readme b/vendor/github.com/kr/text/Readme deleted file mode 100644 index 7e6e7c0..0000000 --- a/vendor/github.com/kr/text/Readme +++ /dev/null @@ -1,3 +0,0 @@ -This is a Go package for manipulating paragraphs of text. - -See http://go.pkgdoc.org/github.com/kr/text for full documentation. diff --git a/vendor/github.com/kr/text/doc.go b/vendor/github.com/kr/text/doc.go deleted file mode 100644 index cf4c198..0000000 --- a/vendor/github.com/kr/text/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package text provides rudimentary functions for manipulating text in -// paragraphs. -package text diff --git a/vendor/github.com/kr/text/go.mod b/vendor/github.com/kr/text/go.mod deleted file mode 100644 index fa0528b..0000000 --- a/vendor/github.com/kr/text/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module "github.com/kr/text" - -require "github.com/kr/pty" v1.1.1 diff --git a/vendor/github.com/kr/text/indent.go b/vendor/github.com/kr/text/indent.go deleted file mode 100644 index 4ebac45..0000000 --- a/vendor/github.com/kr/text/indent.go +++ /dev/null @@ -1,74 +0,0 @@ -package text - -import ( - "io" -) - -// Indent inserts prefix at the beginning of each non-empty line of s. The -// end-of-line marker is NL. -func Indent(s, prefix string) string { - return string(IndentBytes([]byte(s), []byte(prefix))) -} - -// IndentBytes inserts prefix at the beginning of each non-empty line of b. -// The end-of-line marker is NL. -func IndentBytes(b, prefix []byte) []byte { - var res []byte - bol := true - for _, c := range b { - if bol && c != '\n' { - res = append(res, prefix...) - } - res = append(res, c) - bol = c == '\n' - } - return res -} - -// Writer indents each line of its input. -type indentWriter struct { - w io.Writer - bol bool - pre [][]byte - sel int - off int -} - -// NewIndentWriter makes a new write filter that indents the input -// lines. Each line is prefixed in order with the corresponding -// element of pre. If there are more lines than elements, the last -// element of pre is repeated for each subsequent line. -func NewIndentWriter(w io.Writer, pre ...[]byte) io.Writer { - return &indentWriter{ - w: w, - pre: pre, - bol: true, - } -} - -// The only errors returned are from the underlying indentWriter. -func (w *indentWriter) Write(p []byte) (n int, err error) { - for _, c := range p { - if w.bol { - var i int - i, err = w.w.Write(w.pre[w.sel][w.off:]) - w.off += i - if err != nil { - return n, err - } - } - _, err = w.w.Write([]byte{c}) - if err != nil { - return n, err - } - n++ - w.bol = c == '\n' - if w.bol { - w.off = 0 - if w.sel < len(w.pre)-1 { - w.sel++ - } - } - } - return n, nil -} diff --git a/vendor/github.com/kr/text/wrap.go b/vendor/github.com/kr/text/wrap.go deleted file mode 100644 index b09bb03..0000000 --- a/vendor/github.com/kr/text/wrap.go +++ /dev/null @@ -1,86 +0,0 @@ -package text - -import ( - "bytes" - "math" -) - -var ( - nl = []byte{'\n'} - sp = []byte{' '} -) - -const defaultPenalty = 1e5 - -// Wrap wraps s into a paragraph of lines of length lim, with minimal -// raggedness. -func Wrap(s string, lim int) string { - return string(WrapBytes([]byte(s), lim)) -} - -// WrapBytes wraps b into a paragraph of lines of length lim, with minimal -// raggedness. -func WrapBytes(b []byte, lim int) []byte { - words := bytes.Split(bytes.Replace(bytes.TrimSpace(b), nl, sp, -1), sp) - var lines [][]byte - for _, line := range WrapWords(words, 1, lim, defaultPenalty) { - lines = append(lines, bytes.Join(line, sp)) - } - return bytes.Join(lines, nl) -} - -// WrapWords is the low-level line-breaking algorithm, useful if you need more -// control over the details of the text wrapping process. For most uses, either -// Wrap or WrapBytes will be sufficient and more convenient. -// -// WrapWords splits a list of words into lines with minimal "raggedness", -// treating each byte as one unit, accounting for spc units between adjacent -// words on each line, and attempting to limit lines to lim units. Raggedness -// is the total error over all lines, where error is the square of the -// difference of the length of the line and lim. Too-long lines (which only -// happen when a single word is longer than lim units) have pen penalty units -// added to the error. -func WrapWords(words [][]byte, spc, lim, pen int) [][][]byte { - n := len(words) - - length := make([][]int, n) - for i := 0; i < n; i++ { - length[i] = make([]int, n) - length[i][i] = len(words[i]) - for j := i + 1; j < n; j++ { - length[i][j] = length[i][j-1] + spc + len(words[j]) - } - } - - nbrk := make([]int, n) - cost := make([]int, n) - for i := range cost { - cost[i] = math.MaxInt32 - } - for i := n - 1; i >= 0; i-- { - if length[i][n-1] <= lim || i == n-1 { - cost[i] = 0 - nbrk[i] = n - } else { - for j := i + 1; j < n; j++ { - d := lim - length[i][j-1] - c := d*d + cost[j] - if length[i][j-1] > lim { - c += pen // too-long lines get a worse penalty - } - if c < cost[i] { - cost[i] = c - nbrk[i] = j - } - } - } - } - - var lines [][][]byte - i := 0 - for i < n { - lines = append(lines, words[i:nbrk[i]]) - i = nbrk[i] - } - return lines -} diff --git a/vendor/github.com/mzohreva/GoGraphviz/LICENSE b/vendor/github.com/mzohreva/GoGraphviz/LICENSE deleted file mode 100644 index ba20291..0000000 --- a/vendor/github.com/mzohreva/GoGraphviz/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Mohsen Zohrevandi - -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: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -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. diff --git a/vendor/github.com/mzohreva/GoGraphviz/graphviz/attributes.go b/vendor/github.com/mzohreva/GoGraphviz/graphviz/attributes.go deleted file mode 100644 index a56468e..0000000 --- a/vendor/github.com/mzohreva/GoGraphviz/graphviz/attributes.go +++ /dev/null @@ -1,40 +0,0 @@ -package graphviz - -// Common attribute names -const ( - Shape = "shape" - Style = "style" - Color = "color" - FillColor = "fillcolor" - FontName = "fontname" - FontSize = "fontsize" - FontColor = "fontcolor" - NodeSep = "nodesep" -) - -// Common values for shape attribute -const ( - ShapeBox = "box" - ShapePolygon = "polygon" - ShapeEllipse = "ellipse" - ShapeOval = "oval" - ShapeCircle = "circle" - ShapePoint = "point" - ShapeEgg = "egg" - ShapeTriangle = "triangle" - ShapeNone = "none" - ShapeDiamond = "diamond" - ShapeRectangle = "rectangle" - ShapeSquare = "square" -) - -// Common values for style attribute -const ( - StyleSolid = "solid" - StyleDashed = "dashed" - StyleDotted = "dotted" - StyleBold = "bold" - StyleRounded = "rounded" - StyleFilled = "filled" - StyleStriped = "striped" -) diff --git a/vendor/github.com/mzohreva/GoGraphviz/graphviz/graphviz.go b/vendor/github.com/mzohreva/GoGraphviz/graphviz/graphviz.go deleted file mode 100644 index 29b7025..0000000 --- a/vendor/github.com/mzohreva/GoGraphviz/graphviz/graphviz.go +++ /dev/null @@ -1,249 +0,0 @@ -// Package graphviz provides an easy-to-use API for visualizing graphs -// using Graphviz (http://graphviz.org). -// It can generate graph descriptions in DOT language which can be made -// into a picture using various Graphviz tools such as dot, neato, ... -package graphviz - -import ( - "fmt" - "io" - "os/exec" -) - -// Graph represents a set of