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 --- docker.go | 23 + go.mod | 8 +- go.sum | 6 - tools/dokku/.gitignore | 1 - tools/dokku/README.md | 55 -- tools/dokku/config.go | 11 - tools/dokku/dokku.cfg.sample | 2 - tools/dokku/main.go | 64 --- tools/graphirot/README.md | 3 - tools/graphirot/main.go | 100 ---- tools/graphirot/tree.svg | 198 -------- tools/imagesize/.gitignore | 2 - tools/imagesize/main.go | 147 ------ tools/yk/main.go | 48 -- 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 --------- vendor/gopkg.in/gcfg.v1/LICENSE | 28 - vendor/gopkg.in/gcfg.v1/README | 4 - vendor/gopkg.in/gcfg.v1/doc.go | 145 ------ vendor/gopkg.in/gcfg.v1/errors.go | 57 --- vendor/gopkg.in/gcfg.v1/read.go | 257 ---------- vendor/gopkg.in/gcfg.v1/scanner/errors.go | 121 ----- vendor/gopkg.in/gcfg.v1/scanner/scanner.go | 342 ------------- vendor/gopkg.in/gcfg.v1/set.go | 329 ------------ vendor/gopkg.in/gcfg.v1/token/position.go | 435 ---------------- vendor/gopkg.in/gcfg.v1/token/serialize.go | 56 -- vendor/gopkg.in/gcfg.v1/token/token.go | 83 --- vendor/gopkg.in/gcfg.v1/types/bool.go | 23 - vendor/gopkg.in/gcfg.v1/types/doc.go | 4 - vendor/gopkg.in/gcfg.v1/types/enum.go | 44 -- vendor/gopkg.in/gcfg.v1/types/int.go | 86 ---- vendor/gopkg.in/gcfg.v1/types/scan.go | 23 - vendor/gopkg.in/warnings.v0/LICENSE | 24 - vendor/gopkg.in/warnings.v0/README | 77 --- vendor/gopkg.in/warnings.v0/warnings.go | 194 ------- vendor/modules.txt | 17 - 58 files changed, 25 insertions(+), 5207 deletions(-) create mode 100644 docker.go delete mode 100644 tools/dokku/.gitignore delete mode 100644 tools/dokku/README.md delete mode 100644 tools/dokku/config.go delete mode 100644 tools/dokku/dokku.cfg.sample delete mode 100644 tools/dokku/main.go delete mode 100644 tools/graphirot/README.md delete mode 100644 tools/graphirot/main.go delete mode 100644 tools/graphirot/tree.svg delete mode 100644 tools/imagesize/.gitignore delete mode 100644 tools/imagesize/main.go delete mode 100644 tools/yk/main.go 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 delete mode 100644 vendor/gopkg.in/gcfg.v1/LICENSE delete mode 100644 vendor/gopkg.in/gcfg.v1/README delete mode 100644 vendor/gopkg.in/gcfg.v1/doc.go delete mode 100644 vendor/gopkg.in/gcfg.v1/errors.go delete mode 100644 vendor/gopkg.in/gcfg.v1/read.go delete mode 100644 vendor/gopkg.in/gcfg.v1/scanner/errors.go delete mode 100644 vendor/gopkg.in/gcfg.v1/scanner/scanner.go delete mode 100644 vendor/gopkg.in/gcfg.v1/set.go delete mode 100644 vendor/gopkg.in/gcfg.v1/token/position.go delete mode 100644 vendor/gopkg.in/gcfg.v1/token/serialize.go delete mode 100644 vendor/gopkg.in/gcfg.v1/token/token.go delete mode 100644 vendor/gopkg.in/gcfg.v1/types/bool.go delete mode 100644 vendor/gopkg.in/gcfg.v1/types/doc.go delete mode 100644 vendor/gopkg.in/gcfg.v1/types/enum.go delete mode 100644 vendor/gopkg.in/gcfg.v1/types/int.go delete mode 100644 vendor/gopkg.in/gcfg.v1/types/scan.go delete mode 100644 vendor/gopkg.in/warnings.v0/LICENSE delete mode 100644 vendor/gopkg.in/warnings.v0/README delete mode 100644 vendor/gopkg.in/warnings.v0/warnings.go diff --git a/docker.go b/docker.go new file mode 100644 index 0000000..420177a --- /dev/null +++ b/docker.go @@ -0,0 +1,23 @@ +//+build ignore + +// Makes the docker image xena/xperimental. +package main + +import ( + "context" + "log" + + "github.com/Xe/x/internal" +) + +func main() { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + tag := "xena/xperimental:" + internal.DateTag + + internal.ShouldWork(ctx, nil, internal.WD, "docker", "build", "-t", tag, ".") + internal.ShouldWork(ctx, nil, internal.WD, "docker", "push", tag) + + log.Printf("use %s", tag) +} diff --git a/go.mod b/go.mod index ed1ff35..c962a37 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module github.com/Xe/x require ( - github.com/GeertJohan/yubigo v0.0.0-20140521141543-b1764f04aa9b + github.com/GeertJohan/yubigo v0.0.0-20140521141543-b1764f04aa9b // indirect github.com/McKael/madon v2.3.0+incompatible github.com/Xe/ln v0.1.2 github.com/aclements/go-moremath v0.0.0-20180329182055-b1aff36309c7 // indirect @@ -26,7 +26,6 @@ require ( github.com/google/gops v0.3.5 github.com/gorilla/websocket v1.4.0 // indirect github.com/hullerob/go.farbfeld v0.0.0-20160317142651-b572f0728b69 - github.com/hypersleep/easyssh v0.0.0-20170212134900-70879c819ea1 github.com/jaytaylor/html2text v0.0.0-20180606194806-57d518f124b0 github.com/joeshaw/envdecode v0.0.0-20180312135643-c9e015854467 github.com/joho/godotenv v1.3.0 @@ -35,8 +34,7 @@ require ( github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e // indirect github.com/klauspost/crc32 v0.0.0-20170628072449-bab58d77464a // indirect github.com/klauspost/reedsolomon v0.0.0-20180704173009-925cb01d6510 // indirect - github.com/kr/pretty v0.1.0 - github.com/mzohreva/GoGraphviz v0.0.0-20180226085351-533f4a37d9c6 + github.com/mzohreva/GoGraphviz v0.0.0-20180226085351-533f4a37d9c6 // indirect github.com/olekukonko/tablewriter v0.0.0-20180912035003-be2c049b30cc // indirect github.com/pborman/uuid v1.2.0 github.com/peterh/liner v1.1.0 @@ -55,8 +53,6 @@ require ( golang.org/x/oauth2 v0.0.0-20181003184128-c57b0facaced golang.org/x/sys v0.0.0-20181004145325-8469e314837c // indirect google.golang.org/appengine v1.2.0 // indirect - gopkg.in/gcfg.v1 v1.2.3 gopkg.in/irc.v1 v1.3.0 - gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.2.1 // indirect ) diff --git a/go.sum b/go.sum index d250676..96d2c21 100644 --- a/go.sum +++ b/go.sum @@ -73,8 +73,6 @@ github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoA github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/hullerob/go.farbfeld v0.0.0-20160317142651-b572f0728b69 h1:oVHYt/ne+aIKsvK4QhnDeCNz9PNn1FbXLtdsX8qZG34= github.com/hullerob/go.farbfeld v0.0.0-20160317142651-b572f0728b69/go.mod h1:mQEoc766DxPTAwQ54neWTK/lFqIeSO7OU6bqZsceglw= -github.com/hypersleep/easyssh v0.0.0-20170212134900-70879c819ea1 h1:dF6rYzan4BixdI4y84azrhnk+XMxyeAPZw8lmOglhBM= -github.com/hypersleep/easyssh v0.0.0-20170212134900-70879c819ea1/go.mod h1:3hqqigaRGbAy6sYHeVLQcGLIBtYmwARNWSn4/TqH8SA= github.com/jaytaylor/html2text v0.0.0-20180606194806-57d518f124b0 h1:xqgexXAGQgY3HAjNPSaCqn5Aahbo5TKsmhp8VRfr1iQ= github.com/jaytaylor/html2text v0.0.0-20180606194806-57d518f124b0/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= @@ -194,13 +192,9 @@ google.golang.org/genproto v0.0.0-20180731170733-daca94659cb5/go.mod h1:JiN7NxoA google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/gcfg.v1 v1.2.3 h1:m8OOJ4ccYHnx2f4gQwpno8nAX5OGOh7RLaaz0pj3Ogs= -gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/irc.v1 v1.3.0 h1:28A0njDuHNueatbQZsRB78CaU8sueA8JWIXVvue60sg= gopkg.in/irc.v1 v1.3.0/go.mod h1:yXDeqklL7+ht3OdUIo0r8WaraGQyjyD+/92R1YxNZxM= -gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= diff --git a/tools/dokku/.gitignore b/tools/dokku/.gitignore deleted file mode 100644 index ae9366d..0000000 --- a/tools/dokku/.gitignore +++ /dev/null @@ -1 +0,0 @@ -dokku diff --git a/tools/dokku/README.md b/tools/dokku/README.md deleted file mode 100644 index a017917..0000000 --- a/tools/dokku/README.md +++ /dev/null @@ -1,55 +0,0 @@ -Dokku -===== - -This is a simple command line tool to interface with Dokku servers. This is -a port of my shell extension -[`dokku.zsh`](https://github.com/Xe/dotfiles/blob/master/.zsh/dokku.zsh) to -a nice Go binary. - -This takes a configuration file for defining multiple servers: - -```ini -[server "default"] -user = dokku -host = panel.apps.xeserv.us -sshkey = /.ssh/id_rsa -``` - -By default it will imply that the SSH key is `~/.ssh/id_rsa` and that the -username is `dokku`. By default the server named `default` will be used for -command execution. - -TODO ----- - -- [ ] Allow interactive commands -- [ ] Directly pipe stdin and stdout to the ssh connection - ---- - -``` -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -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 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. - -For more information, please refer to -``` diff --git a/tools/dokku/config.go b/tools/dokku/config.go deleted file mode 100644 index 74c5e0b..0000000 --- a/tools/dokku/config.go +++ /dev/null @@ -1,11 +0,0 @@ -package main - -type Config struct { - Server map[string]*Server -} - -type Server struct { - SSHKey string // if blank default key will be used. - Host string // hostname of the dokku server - User string // if blank username will be dokku -} diff --git a/tools/dokku/dokku.cfg.sample b/tools/dokku/dokku.cfg.sample deleted file mode 100644 index b914ebe..0000000 --- a/tools/dokku/dokku.cfg.sample +++ /dev/null @@ -1,2 +0,0 @@ -[server "default"] -host = panel.apps.xeserv.us diff --git a/tools/dokku/main.go b/tools/dokku/main.go deleted file mode 100644 index 796083d..0000000 --- a/tools/dokku/main.go +++ /dev/null @@ -1,64 +0,0 @@ -package main // christine.website/go/tools/dokku - -import ( - "flag" - "fmt" - "log" - "os" - "strings" - - "github.com/hypersleep/easyssh" - gcfg "gopkg.in/gcfg.v1" -) - -var ( - cfgPath = flag.String("cfg", "", "configuration path, default is ~/.dokku.cfg") - serverName = flag.String("server", "default", "server to use out of dokku config") -) - -func main() { - flag.Parse() - - if *cfgPath == "" { - *cfgPath = os.Getenv("HOME") + "/.dokku.cfg" - } - - var cfg Config - err := gcfg.ReadFileInto(&cfg, *cfgPath) - if err != nil { - log.Fatal(err) - } - - var server *Server - var ok bool - - if server, ok = cfg.Server[*serverName]; !ok { - log.Fatalf("server %s not defined in configuration file %s", *serverName, *cfgPath) - } - - if server.User == "" { - server.User = "dokku" - } - - if server.SSHKey == "" { - server.SSHKey = "/.ssh/id_rsa" - } - - ssh := &easyssh.MakeConfig{ - User: server.User, - Server: server.Host, - Key: server.SSHKey, - } - - command := strings.Join(flag.Args(), " ") - - stdout, stderr, _, err := ssh.Run(command, 360) - if err != nil { - log.Fatal(err) - } - - fmt.Print(stdout) - fmt.Println() - fmt.Print(stderr) - fmt.Println() -} diff --git a/tools/graphirot/README.md b/tools/graphirot/README.md deleted file mode 100644 index beb7f7b..0000000 --- a/tools/graphirot/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# graphirot - -A really, really bad idea to find out what happens when you translate the tree of life to graphviz. diff --git a/tools/graphirot/main.go b/tools/graphirot/main.go deleted file mode 100644 index bf0964a..0000000 --- a/tools/graphirot/main.go +++ /dev/null @@ -1,100 +0,0 @@ -package main - -import ( - "os" - - "github.com/mzohreva/GoGraphviz/graphviz" -) - -func main() { - g := graphviz.Graph{} - - keter := g.AddNode("Keter") - binah := g.AddNode("Binah") - chokmah := g.AddNode("Chokmah") - daat := g.AddNode("Da'at") - gevurah := g.AddNode("Gevurah") - hesed := g.AddNode("Hesed") - tiferet := g.AddNode("Tilferet") - hod := g.AddNode("Hod") - netzah := g.AddNode("Netzah") - yesod := g.AddNode("Yesod") - malkhut := g.AddNode("Malkhut") - - g.NodeAttribute(keter, "group", "g1") - g.NodeAttribute(binah, "group", "g2") - g.NodeAttribute(chokmah, "group", "g2") - g.NodeAttribute(daat, "group", "g3") - g.NodeAttribute(gevurah, "group", "g4") - g.NodeAttribute(hesed, "group", "g4") - g.NodeAttribute(tiferet, "group", "g5") - g.NodeAttribute(hod, "group", "g6") - g.NodeAttribute(netzah, "group", "g6") - g.NodeAttribute(yesod, "group", "g7") - g.NodeAttribute(malkhut, "group", "g8") - - invisLink := func(a, b int) { - e := g.AddEdge(a, b, "") - g.EdgeAttribute(e, "style", "invis") - } - invisLink(daat, keter) - invisLink(daat, binah) - invisLink(daat, chokmah) - invisLink(daat, tiferet) - - g.AddEdge(keter, binah, "") - g.AddEdge(keter, chokmah, "") - g.AddEdge(keter, tiferet, "") - - g.AddEdge(binah, chokmah, "") - g.AddEdge(binah, keter, "") - g.AddEdge(binah, gevurah, "") - g.AddEdge(binah, tiferet, "") - g.AddEdge(binah, hesed, "") - - g.AddEdge(chokmah, keter, "") - g.AddEdge(chokmah, binah, "") - g.AddEdge(chokmah, tiferet, "") - g.AddEdge(chokmah, hesed, "") - - g.AddEdge(gevurah, binah, "") - g.AddEdge(gevurah, chokmah, "") - g.AddEdge(gevurah, hesed, "") - g.AddEdge(gevurah, tiferet, "") - g.AddEdge(gevurah, hod, "") - - g.AddEdge(hesed, chokmah, "") - g.AddEdge(hesed, binah, "") - g.AddEdge(hesed, gevurah, "") - g.AddEdge(hesed, hod, "") - g.AddEdge(hesed, netzah, "") - - g.AddEdge(tiferet, keter, "") - g.AddEdge(tiferet, binah, "") - g.AddEdge(tiferet, gevurah, "") - g.AddEdge(tiferet, hesed, "") - g.AddEdge(tiferet, hod, "") - g.AddEdge(tiferet, netzah, "") - g.AddEdge(tiferet, yesod, "") - - g.AddEdge(hod, gevurah, "") - g.AddEdge(hod, tiferet, "") - g.AddEdge(hod, netzah, "") - g.AddEdge(hod, yesod, "") - - g.AddEdge(netzah, hesed, "") - g.AddEdge(netzah, tiferet, "") - g.AddEdge(netzah, hod, "") - g.AddEdge(netzah, yesod, "") - - g.AddEdge(yesod, hod, "") - g.AddEdge(yesod, tiferet, "") - g.AddEdge(yesod, netzah, "") - g.AddEdge(yesod, malkhut, "") - - g.MakeSameRank(binah, chokmah) - g.MakeSameRank(gevurah, hesed) - g.MakeSameRank(hod, netzah) - - g.GenerateDOT(os.Stdout) -} diff --git a/tools/graphirot/tree.svg b/tools/graphirot/tree.svg deleted file mode 100644 index 9eeff5b..0000000 --- a/tools/graphirot/tree.svg +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - -%0 - - - -n0 - -Keter - - - -n1 - -Binah - - - -n0--n1 - - - - -n2 - -Chokmah - - - -n0--n2 - - - - -n6 - -Tilferet - - - -n0--n6 - - - - -n1--n2 - - - - -n4 - -Gevurah - - - -n1--n4 - - - - -n5 - -Hesed - - - -n1--n5 - - - - -n1--n6 - - - - -n2--n5 - - - - -n2--n6 - - - - -n3 - -Da'at - - - - - - - -n4--n2 - - - - -n4--n5 - - - - -n4--n6 - - - - -n7 - -Hod - - - -n4--n7 - - - - -n5--n7 - - - - -n8 - -Netzah - - - -n5--n8 - - - - -n6--n5 - - - - -n6--n7 - - - - -n6--n8 - - - - -n9 - -Yesod - - - -n6--n9 - - - - -n7--n8 - - - - -n7--n9 - - - - -n8--n9 - - - - -n10 - -Malkhut - - - -n9--n10 - - - - diff --git a/tools/imagesize/.gitignore b/tools/imagesize/.gitignore deleted file mode 100644 index 2f711bd..0000000 --- a/tools/imagesize/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -imagesize -output diff --git a/tools/imagesize/main.go b/tools/imagesize/main.go deleted file mode 100644 index 21c7f7c..0000000 --- a/tools/imagesize/main.go +++ /dev/null @@ -1,147 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "image" - _ "image/gif" - _ "image/jpeg" - _ "image/png" - "io" - "log" - "os" - "path/filepath" - "strings" -) - -var ( - format = flag.String("format", "jpg", "Image format to prefer") - outputDir = flag.String("output", "./output", "Where to write validated images to") - where = flag.String("where", ".", "Directory to scan for unvalidated images") - minWidth = flag.Int("minsize", 2559, "Minimum width") // Width of SP3 display - debugFlag = flag.Bool("debug", false, "panic() on error?") -) - -func main() { - flag.Parse() - log.Printf("Debug: %v", *debugFlag) - - // discard error value. XXX fix this? - os.Mkdir(*outputDir, 0755) - - err := filepath.Walk(*where, validate) - if err != nil { - if *debugFlag { - panic(err) - } else { - log.Fatal(err) - } - } -} - -// validate takes a walked directory entry and sees if the image is big enough. -func validate(path string, info os.FileInfo, err error) error { - if info.IsDir() { - return nil - } - - fin, err := os.Open(path) - if err != nil { - return err - } - defer fin.Close() - - if *debugFlag { - log.Println(path) - } - - defer func() { - if r := recover(); r != nil { - log.Printf("%q: %v", path, r) - } - }() - - img, format, err := image.DecodeConfig(fin) - if err != nil { - return err - } - - if img.Width > *minWidth { - err = CopyFile(path, *outputDir+"/"+filepath.Base(strings.TrimSuffix(info.Name(), filepath.Ext(path))+"."+format)) - if err != nil { - return err - } - } - - return nil -} - -// CopyFile copies a file from src to dst. If src and dst files exist, and are -// the same, then return success. Otherise, attempt to create a hard link -// between the two files. If that fail, copy the file contents from src to dst. -func CopyFile(src, dst string) (err error) { - sfi, err := os.Stat(src) - if err != nil { - return - } - - if !sfi.Mode().IsRegular() { - // cannot copy non-regular files (e.g., directories, - // symlinks, devices, etc.) - return fmt.Errorf("CopyFile: non-regular source file %s (%q)", sfi.Name(), sfi.Mode().String()) - } - - dfi, err := os.Stat(dst) - if err != nil { - if !os.IsNotExist(err) { - return - } - } else { - if !(dfi.Mode().IsRegular()) { - return fmt.Errorf("CopyFile: non-regular destination file %s (%q)", dfi.Name(), dfi.Mode().String()) - } - - if os.SameFile(sfi, dfi) { - return - } - } - if err = os.Link(src, dst); err == nil { - return - } - - err = copyFileContents(src, dst) - return - -} - -// copyFileContents copies the contents of the file named src to the file named -// by dst. The file will be created if it does not already exist. If the -// destination file exists, all it's contents will be replaced by the contents -// of the source file. -func copyFileContents(src, dst string) (err error) { - in, err := os.Open(src) - if err != nil { - return - } - defer in.Close() - - out, err := os.Create(dst) - if err != nil { - return - } - - defer func() { - cerr := out.Close() - - if err == nil { - err = cerr - } - }() - - if _, err = io.Copy(out, in); err != nil { - return - } - - err = out.Sync() - return -} diff --git a/tools/yk/main.go b/tools/yk/main.go deleted file mode 100644 index 56e8417..0000000 --- a/tools/yk/main.go +++ /dev/null @@ -1,48 +0,0 @@ -package main - -import ( - "bufio" - "fmt" - "log" - "os" - "strings" - - "github.com/GeertJohan/yubigo" - _ "github.com/joho/godotenv/autoload" - "github.com/kr/pretty" -) - -func main() { - yubiAuth, err := yubigo.NewYubiAuth(os.Getenv("YUBIKEY_CLIENT_ID"), os.Getenv("YUBIKEY_SECRET_KEY")) - if err != nil { - log.Fatal(err) - } - _ = yubiAuth - - reader := bufio.NewReader(os.Stdin) - fmt.Print("yk> ") - text, err := reader.ReadString(byte('\n')) - if err != nil { - log.Fatal(err) - } - - text = strings.TrimSpace(text) - - resp, _, err := yubiAuth.Verify(text) - if err != nil { - log.Fatal(err) - } - - pretty.Println(resp) - - if !resp.IsValidOTP() { - log.Fatal("invalid OTP") - } - - prefix, _, err := yubigo.ParseOTP(text) - if err != nil { - log.Fatal(err) - } - - log.Printf("uid: %s", prefix) -} 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 betw