├── .ci └── deploy.sh ├── .drone.yml ├── .gitignore ├── CHANGELOG.md ├── Godeps ├── Godeps.json └── Readme ├── LICENSE ├── Makefile ├── README.md ├── data ├── envdb-1.png ├── envdb-2.png ├── envdb-3.png └── envdb.gif ├── envdb ├── bindata_assetfs.go ├── daemon.go ├── database.go ├── database_test.go ├── envdb_test.go ├── helpers.go ├── http-handle.go ├── http.go ├── log.go ├── node.go ├── node_config.go ├── node_database.go ├── query.go ├── query_database.go ├── server.go ├── server_config.go ├── server_test.go ├── settings_database.go ├── system_information.go ├── user_database.go ├── version.go └── web │ ├── favicon.ico │ ├── favicon.png │ ├── index.html │ ├── layout.html │ ├── login.html │ └── public │ ├── css │ ├── envdb.css │ ├── font-awesome.css │ ├── fonts.css │ └── grid.css │ ├── favicon.png │ ├── fonts │ ├── avenir │ │ ├── AvenirNextLTPro-Bold.eot │ │ ├── AvenirNextLTPro-Bold.svg │ │ ├── AvenirNextLTPro-Bold.ttf │ │ ├── AvenirNextLTPro-Bold.woff │ │ ├── AvenirNextLTPro-BoldCn.eot │ │ ├── AvenirNextLTPro-BoldCn.svg │ │ ├── AvenirNextLTPro-BoldCn.ttf │ │ ├── AvenirNextLTPro-BoldCn.woff │ │ ├── AvenirNextLTPro-Cn.eot │ │ ├── AvenirNextLTPro-Cn.svg │ │ ├── AvenirNextLTPro-Cn.ttf │ │ ├── AvenirNextLTPro-Cn.woff │ │ ├── AvenirNextLTPro-Demi.eot │ │ ├── AvenirNextLTPro-Demi.svg │ │ ├── AvenirNextLTPro-Demi.ttf │ │ ├── AvenirNextLTPro-Demi.woff │ │ ├── AvenirNextLTPro-DemiCn.eot │ │ ├── AvenirNextLTPro-DemiCn.svg │ │ ├── AvenirNextLTPro-DemiCn.ttf │ │ ├── AvenirNextLTPro-DemiCn.woff │ │ ├── AvenirNextLTPro-Heavy.eot │ │ ├── AvenirNextLTPro-Heavy.svg │ │ ├── AvenirNextLTPro-Heavy.ttf │ │ ├── AvenirNextLTPro-Heavy.woff │ │ ├── AvenirNextLTPro-HeavyCn.eot │ │ ├── AvenirNextLTPro-HeavyCn.svg │ │ ├── AvenirNextLTPro-HeavyCn.ttf │ │ ├── AvenirNextLTPro-HeavyCn.woff │ │ ├── AvenirNextLTPro-Medium.eot │ │ ├── AvenirNextLTPro-Medium.svg │ │ ├── AvenirNextLTPro-Medium.ttf │ │ ├── AvenirNextLTPro-Medium.woff │ │ ├── AvenirNextLTPro-MediumCn.eot │ │ ├── AvenirNextLTPro-MediumCn.svg │ │ ├── AvenirNextLTPro-MediumCn.ttf │ │ ├── AvenirNextLTPro-MediumCn.woff │ │ ├── AvenirNextLTPro-Regular.eot │ │ ├── AvenirNextLTPro-Regular.svg │ │ ├── AvenirNextLTPro-Regular.ttf │ │ ├── AvenirNextLTPro-Regular.woff │ │ ├── AvenirNextLTPro-UltLt.eot │ │ ├── AvenirNextLTPro-UltLt.svg │ │ ├── AvenirNextLTPro-UltLt.ttf │ │ ├── AvenirNextLTPro-UltLt.woff │ │ ├── AvenirNextLTPro-UltLtCn.eot │ │ ├── AvenirNextLTPro-UltLtCn.svg │ │ ├── AvenirNextLTPro-UltLtCn.ttf │ │ ├── AvenirNextLTPro-UltLtCn.woff │ │ └── font.css │ ├── fa │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ └── fontawesome-webfont.woff │ └── lato │ │ ├── hr │ │ ├── Lato-hr.eot │ │ ├── Lato-hr.html │ │ ├── Lato-hr.svg │ │ ├── Lato-hr.ttf │ │ └── Lato-hr.woff │ │ ├── light │ │ ├── Lato-Light.eot │ │ ├── Lato-Light.html │ │ ├── Lato-Light.svg │ │ ├── Lato-Light.ttf │ │ └── Lato-Light.woff │ │ └── reg │ │ ├── Lato-Regular.eot │ │ ├── Lato-Regular.html │ │ ├── Lato-Regular.svg │ │ ├── Lato-Regular.ttf │ │ └── Lato-Regular.woff │ ├── images │ ├── envdb.png │ ├── loading.gif │ └── login-bg.jpg │ └── js │ ├── ace-sql.js │ ├── ace-theme.js │ ├── ace-tools.js │ ├── ace.js │ ├── csv.js │ ├── dataTables-fixedheader.js │ ├── dataTables.js │ ├── envdb.js │ ├── gotalk.js │ ├── handlebars.js │ ├── jquery.js │ ├── limp.js │ ├── list.js │ ├── pace.js │ ├── snippets │ ├── sql.js │ └── text.js │ └── table-sort.js ├── main.go └── vendor ├── github.com ├── BurntSushi │ └── toml │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── COMPATIBLE │ │ ├── COPYING │ │ ├── Makefile │ │ ├── README.md │ │ ├── decode.go │ │ ├── decode_meta.go │ │ ├── doc.go │ │ ├── encode.go │ │ ├── encoding_types.go │ │ ├── encoding_types_1.1.go │ │ ├── lex.go │ │ ├── parse.go │ │ ├── session.vim │ │ ├── type_check.go │ │ └── type_fields.go ├── DataDog │ └── gohai │ │ ├── LICENSE │ │ ├── cpu │ │ ├── cpu.go │ │ ├── cpu_darwin.go │ │ ├── cpu_linux.go │ │ └── cpu_windows.go │ │ ├── filesystem │ │ ├── filesystem.go │ │ ├── filesystem_common.go │ │ ├── filesystem_darwin.go │ │ ├── filesystem_linux.go │ │ └── filesystem_windows.go │ │ ├── memory │ │ ├── memory.go │ │ ├── memory_darwin.go │ │ ├── memory_linux.go │ │ └── memory_windows.go │ │ ├── network │ │ ├── network.go │ │ ├── network_common.go │ │ └── network_windows.go │ │ ├── platform │ │ ├── platform.go │ │ ├── platform_common.go │ │ ├── platform_darwin.go │ │ ├── platform_linux.go │ │ └── platform_windows.go │ │ └── windowsutils │ │ └── utils.go ├── alecthomas │ ├── template │ │ ├── LICENSE │ │ ├── README.md │ │ ├── doc.go │ │ ├── exec.go │ │ ├── funcs.go │ │ ├── helper.go │ │ ├── parse │ │ │ ├── lex.go │ │ │ ├── node.go │ │ │ └── parse.go │ │ └── template.go │ └── units │ │ ├── COPYING │ │ ├── README.md │ │ ├── bytes.go │ │ ├── doc.go │ │ ├── si.go │ │ └── util.go ├── elazarl │ └── go-bindata-assetfs │ │ ├── LICENSE │ │ ├── README.md │ │ ├── assetfs.go │ │ └── doc.go ├── go-xorm │ ├── core │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── README.md │ │ ├── benchmark.sh │ │ ├── cache.go │ │ ├── column.go │ │ ├── converstion.go │ │ ├── db.go │ │ ├── dialect.go │ │ ├── driver.go │ │ ├── error.go │ │ ├── filter.go │ │ ├── ilogger.go │ │ ├── index.go │ │ ├── mapper.go │ │ ├── pk.go │ │ ├── scan.go │ │ ├── table.go │ │ └── type.go │ └── xorm │ │ ├── .gitignore │ │ ├── .gitmodules │ │ ├── .gopmfile │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── README_CN.md │ │ ├── VERSION │ │ ├── doc.go │ │ ├── engine.go │ │ ├── error.go │ │ ├── gen_reserved.sh │ │ ├── goracle_driver.go │ │ ├── helpers.go │ │ ├── logger.go │ │ ├── lru_cacher.go │ │ ├── memory_store.go │ │ ├── mssql_dialect.go │ │ ├── mymysql_driver.go │ │ ├── mysql_dialect.go │ │ ├── mysql_driver.go │ │ ├── oci8_driver.go │ │ ├── odbc_driver.go │ │ ├── oracle_dialect.go │ │ ├── postgres_dialect.go │ │ ├── pq_driver.go │ │ ├── processors.go │ │ ├── rows.go │ │ ├── session.go │ │ ├── sqlite3_dialect.go │ │ ├── sqlite3_driver.go │ │ ├── statement.go │ │ ├── syslogger.go │ │ └── xorm.go ├── gorilla │ ├── context │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── context.go │ │ └── doc.go │ ├── mux │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── doc.go │ │ ├── mux.go │ │ ├── regexp.go │ │ └── route.go │ ├── securecookie │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── doc.go │ │ ├── fuzz.go │ │ └── securecookie.go │ └── sessions │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── doc.go │ │ ├── sessions.go │ │ └── store.go ├── howeyc │ └── gopass │ │ ├── .travis.yml │ │ ├── README.md │ │ └── pass.go ├── kardianos │ └── osext │ │ ├── LICENSE │ │ ├── README.md │ │ ├── osext.go │ │ ├── osext_plan9.go │ │ ├── osext_procfs.go │ │ ├── osext_sysctl.go │ │ └── osext_windows.go ├── mattn │ └── go-sqlite3 │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── backup.go │ │ ├── callback.go │ │ ├── doc.go │ │ ├── error.go │ │ ├── sqlite3-binding.c │ │ ├── sqlite3-binding.h │ │ ├── sqlite3.go │ │ ├── sqlite3_fts5.go │ │ ├── sqlite3_icu.go │ │ ├── sqlite3_json1.go │ │ ├── sqlite3_libsqlite3.go │ │ ├── sqlite3_load_extension.go │ │ ├── sqlite3_omit_load_extension.go │ │ ├── sqlite3_other.go │ │ ├── sqlite3_windows.go │ │ └── sqlite3ext.h ├── mephux │ └── gotalk │ │ ├── README.md │ │ ├── handle.go │ │ ├── js │ │ ├── .gitignore │ │ ├── README.md │ │ ├── build-browser.js │ │ ├── gotalk.js │ │ ├── gotalk.js.go │ │ └── gotalk.js.map │ │ ├── limits.go │ │ ├── protocol.go │ │ ├── request.go │ │ ├── response.go │ │ ├── server.go │ │ ├── sock.go │ │ └── websocket.go ├── nu7hatch │ └── gouuid │ │ ├── .gitignore │ │ ├── COPYING │ │ ├── README.md │ │ └── uuid.go └── sevlyar │ └── go-daemon │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── command.go │ ├── daemon_posix.go │ ├── lock_file_posix.go │ └── signal.go ├── golang.org └── x │ ├── crypto │ ├── LICENSE │ ├── PATENTS │ └── ssh │ │ └── terminal │ │ ├── terminal.go │ │ ├── util.go │ │ ├── util_bsd.go │ │ ├── util_linux.go │ │ ├── util_plan9.go │ │ └── util_windows.go │ └── net │ ├── LICENSE │ ├── PATENTS │ └── websocket │ ├── client.go │ ├── hybi.go │ ├── server.go │ └── websocket.go └── gopkg.in └── alecthomas └── kingpin.v2 ├── .travis.yml ├── COPYING ├── README.md ├── actions.go ├── app.go ├── args.go ├── cmd.go ├── completions.go ├── doc.go ├── flags.go ├── global.go ├── guesswidth.go ├── guesswidth_unix.go ├── model.go ├── parser.go ├── parsers.go ├── templates.go ├── usage.go ├── values.go ├── values.json └── values_generated.go /.ci/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | NAME="envdb" 5 | BRANCH="master" 6 | 7 | VERSION=$(cat .Version) 8 | OLD_VERSION=$VERSION 9 | YANK_OLD_VERSIONS=true 10 | 11 | PREFIX="mephux/$NAME" 12 | RELEASE_PATH="release" 13 | 14 | DEB="${NAME}_${OLD_VERSION}_amd64.deb" 15 | DEB386="${NAME}_${OLD_VERSION}_386.deb" 16 | 17 | if [ "$DRONE_BRANCH" = "$BRANCH" ] && [ "$DRONE_PR" != "true" ]; then 18 | echo "MASTER BRANCH: Deploying..." 19 | 20 | # if [ "$YANK_OLD_VERSIONS" = true ]; then 21 | 22 | # package_cloud yank $PREFIX/ubuntu/lucid $DEB 23 | # package_cloud yank $PREFIX/ubuntu/hardy $DEB 24 | # package_cloud yank $PREFIX/ubuntu/utopic $DEB 25 | # package_cloud yank $PREFIX/ubuntu/precise $DEB 26 | # package_cloud yank $PREFIX/ubuntu/trusty $DEB 27 | 28 | # package_cloud yank $PREFIX/ubuntu/lucid $DEB386 29 | # package_cloud yank $PREFIX/ubuntu/hardy $DEB386 30 | # package_cloud yank $PREFIX/ubuntu/utopic $DEB386 31 | # package_cloud yank $PREFIX/ubuntu/precise $DEB386 32 | # package_cloud yank $PREFIX/ubuntu/trusty $DEB386 33 | 34 | # package_cloud yank $PREFIX/debian/squeeze $DEB 35 | # package_cloud yank $PREFIX/debian/jessie $DEB 36 | # package_cloud yank $PREFIX/debian/wheezy $DEB 37 | 38 | # package_cloud yank $PREFIX/debian/squeeze $DEB386 39 | # package_cloud yank $PREFIX/debian/jessie $DEB386 40 | # package_cloud yank $PREFIX/debian/wheezy $DEB386 41 | 42 | # fi 43 | 44 | # # 45 | # # Push New Packages 46 | # # 47 | 48 | # # Ubuntu - Push - amd64 49 | # package_cloud push $PREFIX/ubuntu/lucid $RELEASE_PATH/$NAME-amd64.deb 50 | # package_cloud push $PREFIX/ubuntu/hardy $RELEASE_PATH/$NAME-amd64.deb 51 | # package_cloud push $PREFIX/ubuntu/utopic $RELEASE_PATH/$NAME-amd64.deb 52 | # package_cloud push $PREFIX/ubuntu/precise $RELEASE_PATH/$NAME-amd64.deb 53 | # package_cloud push $PREFIX/ubuntu/trusty $RELEASE_PATH/$NAME-amd64.deb 54 | 55 | # # Ubuntu - Push - 386 56 | # package_cloud push $PREFIX/ubuntu/lucid $RELEASE_PATH/$NAME-386.deb 57 | # package_cloud push $PREFIX/ubuntu/hardy $RELEASE_PATH/$NAME-386.deb 58 | # package_cloud push $PREFIX/ubuntu/utopic $RELEASE_PATH/$NAME-386.deb 59 | # package_cloud push $PREFIX/ubuntu/precise $RELEASE_PATH/$NAME-386.deb 60 | # package_cloud push $PREFIX/ubuntu/trusty $RELEASE_PATH/$NAME-386.deb 61 | 62 | # # Debian - Push - amd64 63 | # package_cloud push $PREFIX/debian/squeeze $RELEASE_PATH/$NAME-amd64.deb 64 | # package_cloud push $PREFIX/debian/jessie $RELEASE_PATH/$NAME-amd64.deb 65 | # package_cloud push $PREFIX/debian/wheezy $RELEASE_PATH/$NAME-amd64.deb 66 | 67 | # # Debian - Push - 386 68 | # package_cloud push $PREFIX/debian/squeeze $RELEASE_PATH/$NAME-386.deb 69 | # package_cloud push $PREFIX/debian/jessie $RELEASE_PATH/$NAME-386.deb 70 | # package_cloud push $PREFIX/debian/wheezy $RELEASE_PATH/$NAME-386.deb 71 | 72 | 73 | # Upload To Github 74 | # curl -L -o /tmp/github-release.tar.bz2 https://github.com/aktau/github-release/releases/download/v0.5.2/linux-amd64-github-release.tar.bz2 75 | # tar jxf /tmp/github-release.tar.bz2 -C /tmp/ && sudo mv /tmp/bin/linux/amd64/github-release /usr/local/bin/github-release 76 | 77 | # github-release release -u mephux -r envdb -t v$(cat .Version) -n "v$(cat .Version)" -d "" || true 78 | fi 79 | -------------------------------------------------------------------------------- /.drone.yml: -------------------------------------------------------------------------------- 1 | image: mephux/docker-golang 2 | branches: 3 | - master 4 | - develop 5 | git: 6 | path: github.com/mephux/envdb 7 | script: 8 | - go get github.com/jteeuwen/go-bindata/... 9 | - go get github.com/elazarl/go-bindata-assetfs/... 10 | - make 11 | - ./bin/envdb --version 12 | - make package 13 | notify: 14 | email: 15 | recipients: 16 | - dustin.webber@gmail.com 17 | publish: 18 | github: 19 | branch: master 20 | script: 21 | artifacts: 22 | - release 23 | tag: v$(cat .Version) 24 | token: $$GITHUB_TOKEN 25 | user: mephux 26 | repo: envdb 27 | when: 28 | branch: master 29 | pull_requests: false 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.db 3 | *.db/ 4 | *.txt 5 | *.pid 6 | *.log 7 | bin/ 8 | 9 | log/ 10 | pkg/ 11 | release/ 12 | .Version 13 | package/ 14 | 15 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 16 | *.o 17 | *.a 18 | *.so 19 | 20 | # Folders 21 | _obj 22 | _test 23 | 24 | # Architecture specific extensions/prefixes 25 | *.[568vq] 26 | [568vq].out 27 | 28 | *.cgo1.go 29 | *.cgo2.c 30 | _cgo_defun.c 31 | _cgo_gotypes.go 32 | _cgo_export.* 33 | 34 | _testmain.go 35 | 36 | *.exe 37 | *.test 38 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 0.4.1 2015-05-13 4 | 5 | + Add loading indicator for system information 6 | request 7 | + bug fixes 8 | + store envdb version for nodes 9 | + Allow nodes list to scroll if needed. 10 | + Update MakeFile version parsing logic. 11 | + Revert removing debug symbols from build 12 | 13 | ## 0.4.0 2015-04-18 14 | 15 | + Add system information window for node. 16 | Right click node and select `system information`. 17 | + bug fixes 18 | 19 | ## 0.3.1 2015-04-18 20 | 21 | + Fix table sort - respect query order by first. 22 | + perf limit added to query response. Limit by 10k. 23 | + better query debug output for node scope queries. 24 | + minor UI fixes. 25 | + rename osquery.go to query.go 26 | 27 | ## 0.3.0 - 2015-04-16 28 | 29 | + fix bug with node template not showing os icon 30 | + when clicking a table in a node view - add select query to editor 31 | + Truncate node metadata in node listing. 32 | + Editor comments, new lines and pop last valid for current search. 33 | + Way better error messages for query syntax issues. 34 | + Add a few new default queries: 35 | * Third-party kernel extensions (OS X) 36 | * Startup items (OS X) 37 | * Interface information 38 | * Shell history 39 | * All users with groups 40 | + minor bug fixes 41 | 42 | - socket verbose output for errors returned from handlers 43 | 44 | ## 0.2.4 - 2015-04-16 45 | 46 | + better debug output for node request/time of query 47 | + daemon support for server 48 | + minor bug fixes 49 | 50 | ## 0.2.3 - 2015-04-13 51 | 52 | + os icon for node button 53 | + better query loading indicator. 54 | + readme updates 55 | -------------------------------------------------------------------------------- /Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export GO15VENDOREXPERIMENT=1 2 | 3 | DEPS = $(go list -f '{{range .TestImports}}{{.}} {{end}}' ./... | grep -v /vendor/) 4 | WEBSITE="github.com/mephux/envdb" 5 | DESCRIPTION="Ask your environment questions." 6 | NAME="envdb" 7 | 8 | BUILDVERSION=$(shell cat VERSION) 9 | GO_VERSION=$(shell go version) 10 | 11 | # Get the git commit 12 | SHA=$(shell git rev-parse --short HEAD) 13 | BUILD_COUNT=$(shell git rev-list --count HEAD) 14 | 15 | BUILD_TAG="${BUILD_COUNT}.${SHA}" 16 | 17 | build: lint generate 18 | @echo "Building..." 19 | @mkdir -p bin/ 20 | @go build \ 21 | -ldflags "-X main.Build=${BUILD_TAG}" \ 22 | ${ARGS} \ 23 | -o bin/envdb 24 | 25 | server-linux: generate 26 | @echo "Building server..." 27 | @mkdir -p bin/ 28 | @GOOS=linux GOARCH=amd64 go build \ 29 | -ldflags "-X main.Build=${BUILD_TAG}" \ 30 | -o bin/csos-server 31 | 32 | generate: clean 33 | @echo "Running go generate..." 34 | @go generate $$(go list ./... | grep -v /vendor/) 35 | 36 | lint: 37 | @go vet $$(go list ./... | grep -v /vendor/) 38 | # @for pkg in $$(go list ./... |grep -v /vendor/ |grep -v /kuber/) ; do \ 39 | # golint -min_confidence=1 $$pkg ; \ 40 | # done 41 | 42 | package: setup strip rpm64 43 | 44 | setup: 45 | @mkdir -p package/root/usr/bin 46 | @mkdir -p package/output/ 47 | @cp -R ./bin/envdb package/root/usr/bin 48 | @./bin/envdb --version 2> VERSION 49 | 50 | test: 51 | go list ./... | xargs -n1 go test 52 | 53 | strip: 54 | strip bin/envdb 55 | 56 | rpm64: 57 | fpm -s dir -t rpm -n $(NAME) -v $(BUILDVERSION) -p package/output/envdb-$(BUILDVERSION)-amd64.rpm \ 58 | --rpm-compression bzip2 --rpm-os linux \ 59 | --force \ 60 | --url $(WEBSITE) \ 61 | --description $(DESCRIPTION) \ 62 | -m "Dustin Willis Webber " \ 63 | --vendor "Dustin Willis Webber" -a amd64 \ 64 | --exclude */**.gitkeep \ 65 | package/root/=/ 66 | 67 | deb64: 68 | fpm -s dir -t deb -n $(NAME) -v $(BUILDVERSION) -p package/output/envdb-$(BUILDVERSION)-amd64.deb \ 69 | --deb-compression bzip2 --deb-os linux \ 70 | --force \ 71 | --url $(WEBSITE) \ 72 | --description $(DESCRIPTION) \ 73 | -m "Dustin Willis Webber " \ 74 | --vendor "Dustin Willis Webber" -a amd64 \ 75 | --exclude */**.gitkeep \ 76 | package/root/=/ 77 | 78 | clean: 79 | rm -rf doc/ 80 | rm -rf package/ 81 | rm -rf bin/ 82 | rm -rf envdb/bindata.go 83 | rm -rf VERSION 84 | 85 | .PHONY: build 86 | -------------------------------------------------------------------------------- /data/envdb-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/data/envdb-1.png -------------------------------------------------------------------------------- /data/envdb-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/data/envdb-2.png -------------------------------------------------------------------------------- /data/envdb-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/data/envdb-3.png -------------------------------------------------------------------------------- /data/envdb.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/data/envdb.gif -------------------------------------------------------------------------------- /envdb/daemon.go: -------------------------------------------------------------------------------- 1 | package envdb 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "os/signal" 7 | "syscall" 8 | 9 | "github.com/sevlyar/go-daemon" 10 | ) 11 | 12 | // Daemon wrapper for the daemon.Context struct 13 | type Daemon struct { 14 | d *daemon.Context 15 | } 16 | 17 | // Running will check if the daemon is running or not 18 | func (daemon *Daemon) Running() (bool, *os.Process, error) { 19 | d, err := daemon.d.Search() 20 | 21 | if err != nil { 22 | return false, d, err 23 | } 24 | 25 | if err := d.Signal(syscall.Signal(0)); err != nil { 26 | return false, d, err 27 | } 28 | 29 | return true, d, nil 30 | } 31 | 32 | // StartServer starts the servers (http/tcp) as a daemon process. 33 | func (daemon *Daemon) StartServer(svr *Server, svrWebPort int) { 34 | 35 | if ok, p, _ := daemon.Running(); ok { 36 | fmt.Printf("%s server is already running. PID: %d\n", Name, p.Pid) 37 | return 38 | } 39 | 40 | fmt.Printf("Starting %s server in daemon mode\n", Name) 41 | Log.SetLevel(DebugLevel) 42 | 43 | d, err := daemon.d.Reborn() 44 | 45 | if err != nil { 46 | Log.Fatal(err) 47 | } 48 | 49 | if d != nil { 50 | return 51 | } 52 | 53 | defer daemon.d.Release() 54 | 55 | go func() { 56 | if err := svr.Run(svrWebPort); err != nil { 57 | Log.Error(err) 58 | } 59 | }() 60 | 61 | sigChan := make(chan os.Signal, 1) 62 | signal.Notify(sigChan, 63 | syscall.SIGINT, 64 | syscall.SIGTERM, 65 | syscall.SIGQUIT) 66 | 67 | for { 68 | select { 69 | case sig := <-sigChan: 70 | Log.Debug("Go Signal: ", sig) 71 | svr.Shutdown() 72 | os.Exit(0) 73 | } 74 | } 75 | 76 | } 77 | 78 | // Status will get the current status of the daemon. 79 | func (daemon *Daemon) Status() { 80 | 81 | if ok, p, _ := daemon.Running(); ok { 82 | fmt.Printf("%s server is running. PID: %d\n", Name, p.Pid) 83 | } else { 84 | daemon.d.Release() 85 | fmt.Printf("%s server is NOT running.\n", Name) 86 | } 87 | } 88 | 89 | // Stop will shutdown and stop the daemon process 90 | func (daemon *Daemon) Stop() { 91 | if ok, p, _ := daemon.Running(); ok { 92 | fmt.Printf("Attempting to shutdown %s server. PID: %d\n", Name, p.Pid) 93 | if err := p.Signal(syscall.Signal(syscall.SIGQUIT)); err != nil { 94 | Log.Fatal(err) 95 | } 96 | } else { 97 | daemon.d.Release() 98 | fmt.Printf("%s server is not running.\n", Name) 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /envdb/database.go: -------------------------------------------------------------------------------- 1 | package envdb 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path" 7 | 8 | "github.com/go-xorm/xorm" 9 | _ "github.com/mattn/go-sqlite3" 10 | // _ "github.com/cznic/ql/driver" 11 | // _ "github.com/go-xorm/ql" 12 | ) 13 | 14 | var ( 15 | x *xorm.Engine 16 | tables []interface{} 17 | ) 18 | 19 | // DBInit will initialize the database and add default values. 20 | func DBInit(storePath, logPath string) error { 21 | tables = append(tables, new(NodeDb), new(QueryDb), new(SettingsDb), 22 | new(UserDb)) 23 | 24 | if err := SetEngine(storePath, logPath); err != nil { 25 | return err 26 | } 27 | 28 | s, err := DbSettings() 29 | 30 | if err != nil { 31 | Log.Error("Unable to create database settings.") 32 | return err 33 | } 34 | 35 | if !s.Setup { 36 | 37 | user := &UserDb{ 38 | Name: "Administrator", 39 | Email: "admin@envdb.io", 40 | Password: "envdb", 41 | } 42 | 43 | if err := CreateUser(user); err != nil { 44 | Log.Fatal("Unable to create default admin user.") 45 | } 46 | 47 | if err := LoadDefaultSavedQueries(); err != nil { 48 | Log.Error("Unable to load default saved queries.") 49 | Log.Errorf("Error: %s", err) 50 | } 51 | 52 | s.Setup = true 53 | 54 | if err := s.Update(); err != nil { 55 | Log.Errorf("Unable to update settings: %s", err) 56 | } 57 | } 58 | 59 | return nil 60 | } 61 | 62 | func getEngine(DbPath string) (*xorm.Engine, error) { 63 | cnnstr := "" 64 | os.MkdirAll(path.Dir(DbPath), os.ModePerm) 65 | cnnstr = "file:" + DbPath + "?cache=shared&mode=rwc" 66 | // cnnstr = DbPath 67 | 68 | return xorm.NewEngine("sqlite3", cnnstr) 69 | } 70 | 71 | // SetEngine will setup and connect to the database. 72 | func SetEngine(DbPath string, LogPath string) (err error) { 73 | x, err = getEngine(DbPath) 74 | 75 | if err != nil { 76 | return fmt.Errorf("connect to database: %v", err) 77 | } 78 | 79 | logPath := path.Join(LogPath, "critical-stack-intel-sql.log") 80 | 81 | os.MkdirAll(path.Dir(logPath), os.ModePerm) 82 | 83 | f, err := os.Create(logPath) 84 | 85 | if err != nil { 86 | return fmt.Errorf("models.init(fail to create critical-stack-intel-sql.log): %v", err) 87 | } 88 | 89 | x.SetLogger(xorm.NewSimpleLogger(f)) 90 | 91 | x.ShowSQL = false 92 | x.ShowInfo = false 93 | x.ShowDebug = false 94 | x.ShowErr = false 95 | x.ShowWarn = false 96 | 97 | if err = x.StoreEngine("InnoDB").Sync2(tables...); err != nil { 98 | return fmt.Errorf("sync database struct error: %v", err) 99 | } 100 | 101 | return nil 102 | } 103 | -------------------------------------------------------------------------------- /envdb/database_test.go: -------------------------------------------------------------------------------- 1 | package envdb 2 | 3 | import "testing" 4 | 5 | func TestServer_Database(t *testing.T) { 6 | if x == nil { 7 | t.Fatal("No database engine found. Sqlite error.") 8 | } 9 | 10 | if x.DriverName() != "sqlite3" { 11 | t.Fatal("Database is using the wrong engine.") 12 | } 13 | } 14 | 15 | func TestServer_Database_DefaultUser(t *testing.T) { 16 | user, err := FindUserByEmail("admin@envdb.io") 17 | 18 | if err != nil { 19 | t.Fatal("NewServer should create a default user.") 20 | } 21 | 22 | if !user.Admin { 23 | t.Fatal("User should has admin rights.") 24 | } 25 | 26 | if !user.ValidatePassword("envdb") { 27 | t.Fatal("Default user has incorrect password.") 28 | } 29 | } 30 | 31 | func TestServer_Database_FindAllUsers(t *testing.T) { 32 | users, err := FindAllUsers() 33 | 34 | if err != nil { 35 | t.Fatal(err) 36 | } 37 | 38 | if len(users) < 1 { 39 | t.Fatal("No users found") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /envdb/envdb_test.go: -------------------------------------------------------------------------------- 1 | package envdb 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path" 7 | "testing" 8 | "time" 9 | ) 10 | 11 | var ( 12 | testServer *Server 13 | testServerError error 14 | 15 | testNode Node 16 | testNodeConfig *NodeConfig 17 | testNodeConfigError error 18 | ) 19 | 20 | func TestMain(m *testing.M) { 21 | TestMode = true 22 | *quiet = true 23 | initLogger() 24 | 25 | testServer, testServerError = NewServer(3636) 26 | 27 | if testServerError != nil { 28 | fmt.Println(testServerError) 29 | os.Exit(-1) 30 | } 31 | 32 | go func() { 33 | if err := testServer.Run(8080); err != nil { 34 | fmt.Println(err) 35 | os.Exit(-1) 36 | } 37 | }() 38 | 39 | testNode = Node{ 40 | Name: "test", 41 | Host: "localhost", 42 | Port: 3636, 43 | RetryCount: 50, 44 | } 45 | 46 | testNodeConfig, testNodeConfigError = NewNodeConfig() 47 | 48 | if testNodeConfigError != nil { 49 | fmt.Println(testNodeConfigError) 50 | os.Exit(-1) 51 | } 52 | 53 | testNode.Config = testNodeConfig 54 | 55 | go func() { 56 | if err := testNode.Run(); err != nil { 57 | fmt.Println(err) 58 | os.Exit(-1) 59 | } 60 | }() 61 | 62 | // wait for node to get setup. 63 | time.Sleep(time.Second * 1) 64 | 65 | code := m.Run() 66 | 67 | testServer.Shutdown() 68 | 69 | os.Exit(code) 70 | } 71 | 72 | func TestServer(t *testing.T) { 73 | 74 | p, err := HomeDir() 75 | 76 | if err != nil { 77 | t.Fatal("Unable to get home path.") 78 | } 79 | 80 | if testServer.Port != 3636 { 81 | t.Fatal("Server has wrong port set.") 82 | } 83 | 84 | pp := path.Join(p, "."+Name) 85 | ps := path.Join(DefaultServerPath, "store.db") 86 | pl := path.Join(DefaultServerPath, "logs") 87 | 88 | if testServer.Config.Path != pp { 89 | t.Fatal("Server path is wrong.") 90 | } 91 | 92 | if testServer.Config.StorePath != ps { 93 | t.Fatal("Server store path is wrong.") 94 | } 95 | 96 | if testServer.Config.LogPath != pl { 97 | t.Fatal("Server log path is wrong.") 98 | } 99 | } 100 | 101 | func TestNode(t *testing.T) { 102 | 103 | if testNode.Port != 3636 { 104 | t.Fatal("Node has wrong port set.") 105 | } 106 | 107 | if testNode.Name != "test" { 108 | t.Fatal("Node name is wrong.") 109 | } 110 | 111 | if testNode.Host != "localhost" { 112 | t.Fatal("Node host is wrong.") 113 | } 114 | 115 | if testNode.RetryCount != 50 { 116 | t.Fatal("Node retry count is wrong.") 117 | } 118 | 119 | p, err := HomeDir() 120 | 121 | if err != nil { 122 | t.Fatal("Unable to get home path.") 123 | } 124 | 125 | p1 := path.Join(p, "."+Name) 126 | p2 := path.Join(DefaultNodePath, "node.cache") 127 | 128 | if testNode.Config.Path != p1 { 129 | t.Fatal("Node path is wrong.") 130 | } 131 | 132 | if testNode.Config.CacheFile != p2 { 133 | t.Fatal("Node cache file path is wrong.") 134 | } 135 | 136 | if testNode.Server() != "localhost:3636" { 137 | t.Fatal("Node has the wrong server to connect to.") 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /envdb/helpers.go: -------------------------------------------------------------------------------- 1 | package envdb 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "regexp" 7 | "runtime" 8 | "strconv" 9 | "strings" 10 | ) 11 | 12 | const ( 13 | // Email regex 14 | Email string = "^(((([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+(\\.([a-zA-Z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])([a-zA-Z]|\\d|-|\\.|_|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*([a-zA-Z]|\\d|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.)+(([a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])|(([a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])([a-zA-Z]|\\d|-|\\.|_|~|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])*([a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.?$" 15 | ) 16 | 17 | var ( 18 | rxEmail = regexp.MustCompile(Email) 19 | ) 20 | 21 | // IsEmail checks a string to validate 22 | // its a proper email address 23 | func IsEmail(str string) bool { 24 | // TODO uppercase letters are not supported 25 | return rxEmail.MatchString(str) 26 | } 27 | 28 | // HomeDir returns path of '~'(in Linux) on Windows, 29 | // it returns error when the variable does not exist. 30 | func HomeDir() (home string, err error) { 31 | if runtime.GOOS == "windows" { 32 | home = os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") 33 | if home == "" { 34 | home = os.Getenv("USERPROFILE") 35 | } 36 | } else { 37 | home = os.Getenv("HOME") 38 | } 39 | 40 | if len(home) == 0 { 41 | return "", errors.New("cannot specify home directory because it's empty") 42 | } 43 | 44 | return home, nil 45 | } 46 | 47 | // IsExist checks whether a file or directory exists. 48 | // It returns false when the file or directory does not exist. 49 | func IsExist(path string) bool { 50 | _, err := os.Stat(path) 51 | return err == nil || os.IsExist(err) 52 | } 53 | 54 | // VersionCheck 55 | func VersionCheck(base, version string) bool { 56 | if version == base { 57 | return true 58 | } 59 | 60 | sv := strings.Split(version, ".") 61 | cv := strings.Split(base, ".") 62 | 63 | if len(sv) != 3 { 64 | return false 65 | } 66 | 67 | svi, err := strconv.Atoi(sv[0]) 68 | 69 | cvi, err := strconv.Atoi(cv[0]) 70 | 71 | if err != nil { 72 | return false 73 | } 74 | 75 | if svi < cvi { 76 | return false 77 | } 78 | 79 | svi2, err := strconv.Atoi(sv[1]) 80 | 81 | cvi2, err := strconv.Atoi(cv[1]) 82 | 83 | if err != nil { 84 | return false 85 | } 86 | 87 | if svi2 < cvi2 { 88 | return false 89 | } 90 | 91 | svi3, err := strconv.Atoi(sv[1]) 92 | 93 | cvi3, err := strconv.Atoi(cv[1]) 94 | 95 | if err != nil { 96 | return false 97 | } 98 | 99 | if svi3 < cvi3 { 100 | return false 101 | } 102 | 103 | return true 104 | } 105 | -------------------------------------------------------------------------------- /envdb/node_config.go: -------------------------------------------------------------------------------- 1 | package envdb 2 | 3 | import ( 4 | "bytes" 5 | "os" 6 | "path" 7 | 8 | "github.com/BurntSushi/toml" 9 | ) 10 | 11 | var ( 12 | // DefaultNodePath node path 13 | DefaultNodePath = "" 14 | 15 | // DefaultCacheFile stores the node connection id. 16 | DefaultCacheFile = "" 17 | ) 18 | 19 | // NodeConfig holds all node configuration values 20 | type NodeConfig struct { 21 | Path string 22 | CacheFile string 23 | Cache *NodeCache 24 | HasCache bool 25 | } 26 | 27 | // NodeCache holds the node connection id. 28 | // This could also hold a lot of other information in 29 | // the future. 30 | type NodeCache struct { 31 | Id string 32 | } 33 | 34 | // NewNodeConfig new node configuration. 35 | func NewNodeConfig() (*NodeConfig, error) { 36 | config := &NodeConfig{} 37 | 38 | p, err := HomeDir() 39 | 40 | if err != nil { 41 | return config, err 42 | } 43 | 44 | Log.Debugf("Home path set to %s.", p) 45 | 46 | DefaultNodePath = path.Join(p, "."+Name) 47 | DefaultCacheFile = path.Join(DefaultNodePath, "node.cache") 48 | 49 | Log.Debugf("Default Node Config Path: %s.", DefaultNodePath) 50 | Log.Debugf("Default Node Cache File: %s.", DefaultCacheFile) 51 | 52 | if err := os.MkdirAll(DefaultNodePath, 0777); err != nil { 53 | return config, err 54 | } 55 | 56 | config.Path = DefaultNodePath 57 | config.CacheFile = DefaultCacheFile 58 | config.HasCache = false 59 | config.Cache = &NodeCache{} 60 | 61 | if IsExist(DefaultCacheFile) { 62 | if _, err := toml.DecodeFile(DefaultCacheFile, config.Cache); err != nil { 63 | return config, err 64 | } 65 | 66 | config.HasCache = true 67 | } 68 | 69 | return config, err 70 | } 71 | 72 | // WriteCache Write node cache to disk. 73 | func (config NodeConfig) WriteCache() error { 74 | var cache bytes.Buffer 75 | 76 | e := toml.NewEncoder(&cache) 77 | 78 | if err := e.Encode(config.Cache); err != nil { 79 | return err 80 | } 81 | 82 | f, err := os.Create(config.CacheFile) 83 | defer f.Close() 84 | 85 | if err != nil { 86 | return err 87 | } 88 | 89 | if _, err := f.WriteString(cache.String()); err != nil { 90 | return err 91 | } 92 | 93 | f.Sync() 94 | 95 | return err 96 | } 97 | -------------------------------------------------------------------------------- /envdb/server_test.go: -------------------------------------------------------------------------------- 1 | package envdb 2 | 3 | import "testing" 4 | 5 | func TestServer_Server(t *testing.T) { 6 | if testServer.Socket.Addr() != "[::]:3636" { 7 | t.Fatal("TCP Server is not listening.") 8 | } 9 | } 10 | 11 | func TestServer_Server_Nodes(t *testing.T) { 12 | 13 | if len(testServer.Nodes) != 1 { 14 | t.Fatal("TCP Server has no connected nodes.") 15 | } 16 | 17 | node, err := testServer.GetNodeById(testNode.Id) 18 | 19 | if err != nil { 20 | t.Fatal("Couldn't find node in server Nodes map") 21 | } 22 | 23 | if node.Name != "test" { 24 | t.Fatal("Connected node has the wrong name") 25 | } 26 | 27 | if !node.Online { 28 | t.Fatal("Node is set to offline") 29 | } 30 | 31 | if !testServer.Alive(node.Id) { 32 | t.Fatal("Node is not properly connected to server.") 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /envdb/settings_database.go: -------------------------------------------------------------------------------- 1 | package envdb 2 | 3 | // Settings database table 4 | type SettingsDb struct { 5 | Id int64 6 | Setup bool 7 | } 8 | 9 | // Initialize the database settings 10 | func DbSettings() (*SettingsDb, error) { 11 | s := &SettingsDb{Id: 1} 12 | 13 | Log.Debugf("Looking for %s database settings.", Name) 14 | has, err := x.Get(s) 15 | 16 | if err != nil { 17 | return nil, err 18 | } else if !has { 19 | Log.Debug("Couldn't find settings. Creating a new settings row.") 20 | 21 | sess := x.NewSession() 22 | defer sess.Close() 23 | 24 | if err := sess.Begin(); err != nil { 25 | return nil, err 26 | } 27 | 28 | if _, err := sess.Insert(s); err != nil { 29 | sess.Rollback() 30 | return nil, err 31 | } 32 | 33 | err := sess.Commit() 34 | 35 | if err != nil { 36 | return nil, err 37 | } 38 | } 39 | 40 | return s, nil 41 | } 42 | 43 | // Update settings in the database 44 | func (s *SettingsDb) Update() error { 45 | sess := x.NewSession() 46 | defer sess.Close() 47 | 48 | if err := sess.Begin(); err != nil { 49 | return err 50 | } 51 | 52 | if _, err := sess.Id(s.Id).AllCols().Update(s); err != nil { 53 | sess.Rollback() 54 | return err 55 | } 56 | 57 | err := sess.Commit() 58 | 59 | if err != nil { 60 | return err 61 | } 62 | 63 | return nil 64 | } 65 | -------------------------------------------------------------------------------- /envdb/system_information.go: -------------------------------------------------------------------------------- 1 | package envdb 2 | 3 | import ( 4 | "github.com/DataDog/gohai/cpu" 5 | "github.com/DataDog/gohai/filesystem" 6 | "github.com/DataDog/gohai/memory" 7 | "github.com/DataDog/gohai/network" 8 | "github.com/DataDog/gohai/platform" 9 | ) 10 | 11 | type Collector interface { 12 | Name() string 13 | Collect() (interface{}, error) 14 | } 15 | 16 | var collectors = []Collector{ 17 | &cpu.Cpu{}, 18 | &filesystem.FileSystem{}, 19 | &memory.Memory{}, 20 | &network.Network{}, 21 | &platform.Platform{}, 22 | } 23 | 24 | func SystemInformation() (result map[string]interface{}, err error) { 25 | result = make(map[string]interface{}) 26 | 27 | for _, collector := range collectors { 28 | c, err := collector.Collect() 29 | if err != nil { 30 | Log.Warnf("[%s] %s", collector.Name(), err) 31 | continue 32 | } 33 | result[collector.Name()] = c 34 | } 35 | 36 | return 37 | } 38 | -------------------------------------------------------------------------------- /envdb/version.go: -------------------------------------------------------------------------------- 1 | package envdb 2 | 3 | var ( 4 | // DevMode Development mode switch. If true 5 | // debug logging and serving assets from disk 6 | // is enabled. 7 | DevMode bool 8 | 9 | // TestMode 10 | TestMode bool 11 | 12 | // TimeFormat global time format string 13 | TimeFormat = "15:04:05" 14 | 15 | // Build holds the git commit that was compiled. 16 | // This will be filled in by the compiler. 17 | Build string 18 | ) 19 | 20 | const ( 21 | // Name application name 22 | Name = "envdb" 23 | 24 | // Version application version number 25 | Version = "0.4.1" 26 | 27 | // DefaultServerPort the default tcp server port 28 | DefaultServerPort = 3636 29 | 30 | // DefaultWebServerPort the default web server port 31 | DefaultWebServerPort = 8080 32 | ) 33 | -------------------------------------------------------------------------------- /envdb/web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/favicon.ico -------------------------------------------------------------------------------- /envdb/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/favicon.png -------------------------------------------------------------------------------- /envdb/web/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%.Name%> <% .Version %> 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | <% if eq .Section "home" %> 25 | 26 | <% end %> 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | <% template "body" . %> 36 | 37 | -------------------------------------------------------------------------------- /envdb/web/login.html: -------------------------------------------------------------------------------- 1 | <% define "body" %> 2 | 3 | 4 |
5 | 6 |
7 | 8 | 15 | 16 |
17 | 18 |
19 |
20 | 21 | 22 |
23 | 24 |
25 | 26 | 27 |
28 |
29 | 30 |

31 | 32 |

33 |
34 | 35 | 36 |
37 | 38 |
39 | 40 | 46 | 47 | 48 | <% end %> 49 | -------------------------------------------------------------------------------- /envdb/web/public/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/favicon.png -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Bold.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Bold.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Bold.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-BoldCn.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-BoldCn.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-BoldCn.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-BoldCn.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-BoldCn.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-BoldCn.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Cn.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Cn.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Cn.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Cn.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Cn.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Cn.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Demi.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Demi.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Demi.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Demi.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Demi.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Demi.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-DemiCn.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-DemiCn.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-DemiCn.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-DemiCn.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-DemiCn.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-DemiCn.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Heavy.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Heavy.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Heavy.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Heavy.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Heavy.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Heavy.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-HeavyCn.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-HeavyCn.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-HeavyCn.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-HeavyCn.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-HeavyCn.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-HeavyCn.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Medium.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Medium.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Medium.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Medium.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Medium.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-MediumCn.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-MediumCn.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-MediumCn.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-MediumCn.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-MediumCn.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-MediumCn.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Regular.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Regular.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-Regular.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-UltLt.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-UltLt.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-UltLt.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-UltLt.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-UltLt.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-UltLt.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-UltLtCn.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-UltLtCn.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-UltLtCn.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-UltLtCn.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/avenir/AvenirNextLTPro-UltLtCn.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/avenir/AvenirNextLTPro-UltLtCn.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/fa/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/fa/FontAwesome.otf -------------------------------------------------------------------------------- /envdb/web/public/fonts/fa/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/fa/fontawesome-webfont.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/fa/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/fa/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/fa/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/fa/fontawesome-webfont.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/lato/hr/Lato-hr.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/lato/hr/Lato-hr.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/lato/hr/Lato-hr.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Demo Lato 6 | 22 | 23 | 24 | 25 |

26 | Ea fore firmissimum ab ubi ea illustriora. Qui nisi deserunt cohaerescant. Nam 27 | legam domesticarum o illum aliquip excepteur et mandaremus e fore litteris ut do 28 | enim tempor proident. Ullamco quis amet pariatur minim, offendit despicationes 29 | in fabulas se aut quem tempor, aut mandaremus ad quamquam. Ut velit laboris 30 | exercitation iis a te dolore sunt quorum. Quamquam philosophari ad ullamco. 31 | Veniam laboris eruditionem id id velit occaecat eu probant eram varias e duis, 32 | ut e firmissimum. 33 |

34 |
35 | Generated using the @font-face Generator at font-face-generator.com 36 |
37 | 38 | 39 | -------------------------------------------------------------------------------- /envdb/web/public/fonts/lato/hr/Lato-hr.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/lato/hr/Lato-hr.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/lato/hr/Lato-hr.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/lato/hr/Lato-hr.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/lato/light/Lato-Light.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/lato/light/Lato-Light.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/lato/light/Lato-Light.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Demo Lato 6 | 22 | 23 | 24 | 25 |

26 | Ea fore firmissimum ab ubi ea illustriora. Qui nisi deserunt cohaerescant. Nam 27 | legam domesticarum o illum aliquip excepteur et mandaremus e fore litteris ut do 28 | enim tempor proident. Ullamco quis amet pariatur minim, offendit despicationes 29 | in fabulas se aut quem tempor, aut mandaremus ad quamquam. Ut velit laboris 30 | exercitation iis a te dolore sunt quorum. Quamquam philosophari ad ullamco. 31 | Veniam laboris eruditionem id id velit occaecat eu probant eram varias e duis, 32 | ut e firmissimum. 33 |

34 |
35 | Generated using the @font-face Generator at font-face-generator.com 36 |
37 | 38 | 39 | -------------------------------------------------------------------------------- /envdb/web/public/fonts/lato/light/Lato-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/lato/light/Lato-Light.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/lato/light/Lato-Light.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/lato/light/Lato-Light.woff -------------------------------------------------------------------------------- /envdb/web/public/fonts/lato/reg/Lato-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/lato/reg/Lato-Regular.eot -------------------------------------------------------------------------------- /envdb/web/public/fonts/lato/reg/Lato-Regular.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Demo Lato 6 | 22 | 23 | 24 | 25 |

26 | Ea fore firmissimum ab ubi ea illustriora. Qui nisi deserunt cohaerescant. Nam 27 | legam domesticarum o illum aliquip excepteur et mandaremus e fore litteris ut do 28 | enim tempor proident. Ullamco quis amet pariatur minim, offendit despicationes 29 | in fabulas se aut quem tempor, aut mandaremus ad quamquam. Ut velit laboris 30 | exercitation iis a te dolore sunt quorum. Quamquam philosophari ad ullamco. 31 | Veniam laboris eruditionem id id velit occaecat eu probant eram varias e duis, 32 | ut e firmissimum. 33 |

34 |
35 | Generated using the @font-face Generator at font-face-generator.com 36 |
37 | 38 | 39 | -------------------------------------------------------------------------------- /envdb/web/public/fonts/lato/reg/Lato-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/lato/reg/Lato-Regular.ttf -------------------------------------------------------------------------------- /envdb/web/public/fonts/lato/reg/Lato-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/fonts/lato/reg/Lato-Regular.woff -------------------------------------------------------------------------------- /envdb/web/public/images/envdb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/images/envdb.png -------------------------------------------------------------------------------- /envdb/web/public/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/images/loading.gif -------------------------------------------------------------------------------- /envdb/web/public/images/login-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djcas9/envdb/3957c101db2c1cc0f5c5b2144d12be0335f4bc0d/envdb/web/public/images/login-bg.jpg -------------------------------------------------------------------------------- /envdb/web/public/js/ace-theme.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/theme/clouds",["require","exports","module","ace/lib/dom"], function(require, exports, module) { 2 | 3 | exports.isDark = false; 4 | exports.cssClass = "ace-clouds"; 5 | exports.cssText = ".ace-clouds .ace_gutter {\ 6 | background: #ebebeb;\ 7 | color: #333\ 8 | }\ 9 | .ace-clouds .ace_print-margin {\ 10 | width: 1px;\ 11 | background: #e8e8e8\ 12 | }\ 13 | .ace-clouds {\ 14 | background-color: #FFFFFF;\ 15 | color: #000000\ 16 | }\ 17 | .ace-clouds .ace_cursor {\ 18 | color: #000000\ 19 | }\ 20 | .ace-clouds .ace_marker-layer .ace_selection {\ 21 | background: #BDD5FC\ 22 | }\ 23 | .ace-clouds.ace_multiselect .ace_selection.ace_start {\ 24 | box-shadow: 0 0 3px 0px #FFFFFF;\ 25 | border-radius: 2px\ 26 | }\ 27 | .ace-clouds .ace_marker-layer .ace_step {\ 28 | background: rgb(255, 255, 0)\ 29 | }\ 30 | .ace-clouds .ace_marker-layer .ace_bracket {\ 31 | margin: -1px 0 0 -1px;\ 32 | border: 1px solid #BFBFBF\ 33 | }\ 34 | .ace-clouds .ace_marker-layer .ace_active-line {\ 35 | background: #FFFBD1\ 36 | }\ 37 | .ace-clouds .ace_gutter-active-line {\ 38 | background-color : #dcdcdc\ 39 | }\ 40 | .ace-clouds .ace_marker-layer .ace_selected-word {\ 41 | border: 1px solid #BDD5FC\ 42 | }\ 43 | .ace-clouds .ace_invisible {\ 44 | color: #BFBFBF\ 45 | }\ 46 | .ace-clouds .ace_keyword,\ 47 | .ace-clouds .ace_meta,\ 48 | .ace-clouds .ace_support.ace_constant.ace_property-value {\ 49 | color: #AF956F\ 50 | }\ 51 | .ace-clouds .ace_keyword.ace_operator {\ 52 | color: #484848\ 53 | }\ 54 | .ace-clouds .ace_keyword.ace_other.ace_unit {\ 55 | color: #96DC5F\ 56 | }\ 57 | .ace-clouds .ace_constant.ace_language {\ 58 | color: #39946A\ 59 | }\ 60 | .ace-clouds .ace_constant.ace_numeric {\ 61 | color: #46A609\ 62 | }\ 63 | .ace-clouds .ace_constant.ace_character.ace_entity {\ 64 | color: #BF78CC\ 65 | }\ 66 | .ace-clouds .ace_invalid {\ 67 | background-color: #FF002A\ 68 | }\ 69 | .ace-clouds .ace_fold {\ 70 | background-color: #AF956F;\ 71 | border-color: #000000\ 72 | }\ 73 | .ace-clouds .ace_storage,\ 74 | .ace-clouds .ace_support.ace_class,\ 75 | .ace-clouds .ace_support.ace_function,\ 76 | .ace-clouds .ace_support.ace_other,\ 77 | .ace-clouds .ace_support.ace_type {\ 78 | color: #C52727\ 79 | }\ 80 | .ace-clouds .ace_string {\ 81 | color: #5D90CD\ 82 | }\ 83 | .ace-clouds .ace_comment {\ 84 | color: #BCC8BA\ 85 | }\ 86 | .ace-clouds .ace_entity.ace_name.ace_tag,\ 87 | .ace-clouds .ace_entity.ace_other.ace_attribute-name {\ 88 | color: #606060\ 89 | }\ 90 | .ace-clouds .ace_indent-guide {\ 91 | background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y\ 92 | }"; 93 | 94 | var dom = require("../lib/dom"); 95 | dom.importCssString(exports.cssText, exports.cssClass); 96 | }); 97 | -------------------------------------------------------------------------------- /envdb/web/public/js/csv.js: -------------------------------------------------------------------------------- 1 | jQuery.fn.table2CSV = function(options) { 2 | var options = jQuery.extend({ 3 | separator: ',', 4 | header: [], 5 | delivery: 'popup' // popup, value 6 | }, 7 | options); 8 | 9 | var csvData = []; 10 | var headerArr = []; 11 | var el = this; 12 | 13 | //header 14 | var numCols = options.header.length; 15 | var tmpRow = []; // construct header avalible array 16 | 17 | if (numCols > 0) { 18 | for (var i = 0; i < numCols; i++) { 19 | tmpRow[tmpRow.length] = formatData(options.header[i]); 20 | } 21 | } else { 22 | $(el).filter(':visible').find('th').each(function() { 23 | if ($(this).css('display') != 'none') tmpRow[tmpRow.length] = formatData($(this).html()); 24 | }); 25 | } 26 | 27 | row2CSV(tmpRow); 28 | 29 | // actual data 30 | $(el).find('tr').each(function() { 31 | var tmpRow = []; 32 | $(this).filter(':visible').find('td').each(function() { 33 | if ($(this).css('display') != 'none') tmpRow[tmpRow.length] = formatData($(this).html()); 34 | }); 35 | row2CSV(tmpRow); 36 | }); 37 | if (options.delivery == 'popup') { 38 | var mydata = csvData.join('\n'); 39 | return popup(mydata); 40 | } else { 41 | var mydata = csvData.join('\n'); 42 | return mydata; 43 | } 44 | 45 | function row2CSV(tmpRow) { 46 | var tmp = tmpRow.join('') // to remove any blank rows 47 | // alert(tmp); 48 | if (tmpRow.length > 0 && tmp != '') { 49 | var mystr = tmpRow.join(options.separator); 50 | csvData[csvData.length] = mystr; 51 | } 52 | } 53 | function formatData(input) { 54 | // replace " with “ 55 | var regexp = new RegExp(/["]/g); 56 | var output = input.replace(regexp, "“"); 57 | //HTML 58 | var regexp = new RegExp(/\<[^\<]+\>/g); 59 | var output = output.replace(regexp, ""); 60 | if (output == "") return ''; 61 | return '"' + $.trim(output) + '"'; 62 | } 63 | function popup(data) { 64 | var generator = window.open('', 'csv', 'height=400,width=600'); 65 | generator.document.write('CSV'); 66 | generator.document.write(''); 67 | generator.document.write(''); 70 | generator.document.write(''); 71 | generator.document.close(); 72 | return true; 73 | } 74 | }; 75 | -------------------------------------------------------------------------------- /envdb/web/public/js/snippets/sql.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/sql",["require","exports","module"], function(require, exports, module) { 2 | "use strict"; 3 | 4 | exports.snippetText = "snippet tbl\n\ 5 | create table ${1:table} (\n\ 6 | ${2:columns}\n\ 7 | );\n\ 8 | snippet col\n\ 9 | ${1:name} ${2:type} ${3:default ''} ${4:not null}\n\ 10 | snippet ccol\n\ 11 | ${1:name} varchar2(${2:size}) ${3:default ''} ${4:not null}\n\ 12 | snippet ncol\n\ 13 | ${1:name} number ${3:default 0} ${4:not null}\n\ 14 | snippet dcol\n\ 15 | ${1:name} date ${3:default sysdate} ${4:not null}\n\ 16 | snippet ind\n\ 17 | create index ${3:$1_$2} on ${1:table}(${2:column});\n\ 18 | snippet uind\n\ 19 | create unique index ${1:name} on ${2:table}(${3:column});\n\ 20 | snippet tblcom\n\ 21 | comment on table ${1:table} is '${2:comment}';\n\ 22 | snippet colcom\n\ 23 | comment on column ${1:table}.${2:column} is '${3:comment}';\n\ 24 | snippet addcol\n\ 25 | alter table ${1:table} add (${2:column} ${3:type});\n\ 26 | snippet seq\n\ 27 | create sequence ${1:name} start with ${2:1} increment by ${3:1} minvalue ${4:1};\n\ 28 | snippet s*\n\ 29 | select * from ${1:table}\n\ 30 | "; 31 | exports.scope = "sql"; 32 | 33 | }); 34 | -------------------------------------------------------------------------------- /envdb/web/public/js/snippets/text.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/snippets/text",["require","exports","module"], function(require, exports, module) { 2 | "use strict"; 3 | 4 | exports.snippetText =undefined; 5 | exports.scope = "text"; 6 | 7 | }) 8 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/.gitignore: -------------------------------------------------------------------------------- 1 | TAGS 2 | tags 3 | .*.swp 4 | tomlcheck/tomlcheck 5 | toml.test 6 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.1 4 | - 1.2 5 | - tip 6 | install: 7 | - go install ./... 8 | - go get github.com/BurntSushi/toml-test 9 | script: 10 | - export PATH="$PATH:$HOME/gopath/bin" 11 | - make test 12 | 13 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/COMPATIBLE: -------------------------------------------------------------------------------- 1 | Compatible with TOML version 2 | [v0.2.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) 3 | 4 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/COPYING: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. 14 | 15 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/Makefile: -------------------------------------------------------------------------------- 1 | install: 2 | go install ./... 3 | 4 | test: install 5 | go test -v 6 | toml-test toml-test-decoder 7 | toml-test -encoder toml-test-encoder 8 | 9 | fmt: 10 | gofmt -w *.go */*.go 11 | colcheck *.go */*.go 12 | 13 | tags: 14 | find ./ -name '*.go' -print0 | xargs -0 gotags > TAGS 15 | 16 | push: 17 | git push origin master 18 | git push github master 19 | 20 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package toml provides facilities for decoding and encoding TOML configuration 3 | files via reflection. There is also support for delaying decoding with 4 | the Primitive type, and querying the set of keys in a TOML document with the 5 | MetaData type. 6 | 7 | The specification implemented: https://github.com/mojombo/toml 8 | 9 | The sub-command github.com/BurntSushi/toml/cmd/tomlv can be used to verify 10 | whether a file is a valid TOML document. It can also be used to print the 11 | type of each key in a TOML document. 12 | 13 | Testing 14 | 15 | There are two important types of tests used for this package. The first is 16 | contained inside '*_test.go' files and uses the standard Go unit testing 17 | framework. These tests are primarily devoted to holistically testing the 18 | decoder and encoder. 19 | 20 | The second type of testing is used to verify the implementation's adherence 21 | to the TOML specification. These tests have been factored into their own 22 | project: https://github.com/BurntSushi/toml-test 23 | 24 | The reason the tests are in a separate project is so that they can be used by 25 | any implementation of TOML. Namely, it is language agnostic. 26 | */ 27 | package toml 28 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/encoding_types.go: -------------------------------------------------------------------------------- 1 | // +build go1.2 2 | 3 | package toml 4 | 5 | // In order to support Go 1.1, we define our own TextMarshaler and 6 | // TextUnmarshaler types. For Go 1.2+, we just alias them with the 7 | // standard library interfaces. 8 | 9 | import ( 10 | "encoding" 11 | ) 12 | 13 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 14 | // so that Go 1.1 can be supported. 15 | type TextMarshaler encoding.TextMarshaler 16 | 17 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 18 | // here so that Go 1.1 can be supported. 19 | type TextUnmarshaler encoding.TextUnmarshaler 20 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/encoding_types_1.1.go: -------------------------------------------------------------------------------- 1 | // +build !go1.2 2 | 3 | package toml 4 | 5 | // These interfaces were introduced in Go 1.2, so we add them manually when 6 | // compiling for Go 1.1. 7 | 8 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 9 | // so that Go 1.1 can be supported. 10 | type TextMarshaler interface { 11 | MarshalText() (text []byte, err error) 12 | } 13 | 14 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 15 | // here so that Go 1.1 can be supported. 16 | type TextUnmarshaler interface { 17 | UnmarshalText(text []byte) error 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/session.vim: -------------------------------------------------------------------------------- 1 | au BufWritePost *.go silent!make tags > /dev/null 2>&1 2 | -------------------------------------------------------------------------------- /vendor/github.com/BurntSushi/toml/type_check.go: -------------------------------------------------------------------------------- 1 | package toml 2 | 3 | // tomlType represents any Go type that corresponds to a TOML type. 4 | // While the first draft of the TOML spec has a simplistic type system that 5 | // probably doesn't need this level of sophistication, we seem to be militating 6 | // toward adding real composite types. 7 | type tomlType interface { 8 | typeString() string 9 | } 10 | 11 | // typeEqual accepts any two types and returns true if they are equal. 12 | func typeEqual(t1, t2 tomlType) bool { 13 | if t1 == nil || t2 == nil { 14 | return false 15 | } 16 | return t1.typeString() == t2.typeString() 17 | } 18 | 19 | func typeIsHash(t tomlType) bool { 20 | return typeEqual(t, tomlHash) || typeEqual(t, tomlArrayHash) 21 | } 22 | 23 | type tomlBaseType string 24 | 25 | func (btype tomlBaseType) typeString() string { 26 | return string(btype) 27 | } 28 | 29 | func (btype tomlBaseType) String() string { 30 | return btype.typeString() 31 | } 32 | 33 | var ( 34 | tomlInteger tomlBaseType = "Integer" 35 | tomlFloat tomlBaseType = "Float" 36 | tomlDatetime tomlBaseType = "Datetime" 37 | tomlString tomlBaseType = "String" 38 | tomlBool tomlBaseType = "Bool" 39 | tomlArray tomlBaseType = "Array" 40 | tomlHash tomlBaseType = "Hash" 41 | tomlArrayHash tomlBaseType = "ArrayHash" 42 | ) 43 | 44 | // typeOfPrimitive returns a tomlType of any primitive value in TOML. 45 | // Primitive values are: Integer, Float, Datetime, String and Bool. 46 | // 47 | // Passing a lexer item other than the following will cause a BUG message 48 | // to occur: itemString, itemBool, itemInteger, itemFloat, itemDatetime. 49 | func (p *parser) typeOfPrimitive(lexItem item) tomlType { 50 | switch lexItem.typ { 51 | case itemInteger: 52 | return tomlInteger 53 | case itemFloat: 54 | return tomlFloat 55 | case itemDatetime: 56 | return tomlDatetime 57 | case itemString: 58 | return tomlString 59 | case itemMultilineString: 60 | return tomlString 61 | case itemRawString: 62 | return tomlString 63 | case itemRawMultilineString: 64 | return tomlString 65 | case itemBool: 66 | return tomlBool 67 | } 68 | p.bug("Cannot infer primitive type of lex item '%s'.", lexItem) 69 | panic("unreachable") 70 | } 71 | 72 | // typeOfArray returns a tomlType for an array given a list of types of its 73 | // values. 74 | // 75 | // In the current spec, if an array is homogeneous, then its type is always 76 | // "Array". If the array is not homogeneous, an error is generated. 77 | func (p *parser) typeOfArray(types []tomlType) tomlType { 78 | // Empty arrays are cool. 79 | if len(types) == 0 { 80 | return tomlArray 81 | } 82 | 83 | theType := types[0] 84 | for _, t := range types[1:] { 85 | if !typeEqual(theType, t) { 86 | p.panicf("Array contains values of type '%s' and '%s', but "+ 87 | "arrays must be homogeneous.", theType, t) 88 | } 89 | } 90 | return tomlArray 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright © 2015 Kentaro Kuribayashi 3 | Copyright (c) 2014-2015, Datadog 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/cpu/cpu.go: -------------------------------------------------------------------------------- 1 | package cpu 2 | 3 | type Cpu struct{} 4 | 5 | const name = "cpu" 6 | 7 | func (self *Cpu) Name() string { 8 | return name 9 | } 10 | 11 | func (self *Cpu) Collect() (result interface{}, err error) { 12 | result, err = getCpuInfo() 13 | return 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/cpu/cpu_darwin.go: -------------------------------------------------------------------------------- 1 | package cpu 2 | 3 | import ( 4 | "os/exec" 5 | "strconv" 6 | "strings" 7 | ) 8 | 9 | var cpuMap = map[string]string{ 10 | "machdep.cpu.vendor": "vendor_id", 11 | "machdep.cpu.brand_string": "model_name", 12 | "hw.physicalcpu": "cpu_cores", 13 | "hw.logicalcpu": "cpu_logical_processors", 14 | "hw.cpufrequency": "mhz", 15 | "machdep.cpu.family": "family", 16 | "machdep.cpu.model": "model", 17 | "machdep.cpu.stepping": "stepping", 18 | } 19 | 20 | func getCpuInfo() (cpuInfo map[string]string, err error) { 21 | 22 | cpuInfo = make(map[string]string) 23 | 24 | for option, key := range cpuMap { 25 | out, err := exec.Command("sysctl", "-n", option).Output() 26 | if err != nil { 27 | return cpuInfo, err 28 | } 29 | cpuInfo[key] = strings.Trim(string(out), "\n") 30 | } 31 | 32 | mhz, err := strconv.Atoi(cpuInfo["mhz"]) 33 | if err != nil { 34 | return cpuInfo, err 35 | } 36 | cpuInfo["mhz"] = strconv.Itoa(mhz / 1000000) 37 | 38 | return 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/cpu/cpu_linux.go: -------------------------------------------------------------------------------- 1 | package cpu 2 | 3 | import ( 4 | "bufio" 5 | "os" 6 | "regexp" 7 | ) 8 | 9 | var cpuMap = map[string]string{ 10 | "vendor_id": "vendor_id", 11 | "model name": "model_name", 12 | "cpu cores": "cpu_cores", 13 | "siblings": "cpu_logical_processors", 14 | "cpu MHz\t": "mhz", 15 | "cache size": "cache_size", 16 | "cpu family": "family", 17 | "model\t": "model", 18 | "stepping": "stepping", 19 | } 20 | 21 | func getCpuInfo() (cpuInfo map[string]string, err error) { 22 | file, err := os.Open("/proc/cpuinfo") 23 | 24 | if err != nil { 25 | return 26 | } 27 | 28 | var lines []string 29 | scanner := bufio.NewScanner(file) 30 | 31 | for scanner.Scan() { 32 | lines = append(lines, scanner.Text()) 33 | } 34 | 35 | if scanner.Err() != nil { 36 | err = scanner.Err() 37 | return 38 | } 39 | 40 | cpuInfo = make(map[string]string) 41 | 42 | for _, line := range lines[1:] { 43 | pair := regexp.MustCompile("\t: ").Split(line, 2) 44 | 45 | key, ok := cpuMap[pair[0]] 46 | if ok { 47 | cpuInfo[key] = pair[1] 48 | } 49 | } 50 | 51 | return 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/cpu/cpu_windows.go: -------------------------------------------------------------------------------- 1 | package cpu 2 | 3 | import ( 4 | utils "github.com/DataDog/gohai/windowsutils" 5 | // "strconv" 6 | "fmt" 7 | "regexp" 8 | "strings" 9 | ) 10 | 11 | var cpuMap = map[string]string{ 12 | "machdep.cpu.vendor": "vendor_id", 13 | "machdep.cpu.brand_string": "model_name", 14 | "hw.physicalcpu": "cpu_cores", 15 | "hw.logicalcpu": "cpu_logical_processors", 16 | "hw.cpufrequency": "mhz", 17 | "machdep.cpu.family": "family", 18 | "machdep.cpu.model": "model", 19 | "machdep.cpu.stepping": "stepping", 20 | } 21 | 22 | func getCpuInfo() (cpuInfo map[string]string, err error) { 23 | 24 | cpuInfo = make(map[string]string) 25 | 26 | cpu, err := utils.WindowsWMICommand("CPU", 27 | "CurrentClockSpeed", "Name", "NumberOfCores", 28 | "NumberOfLogicalProcessors", "Caption", "Manufacturer") 29 | if err != nil { 30 | return 31 | } 32 | cpuInfo["mhz"] = cpu["CurrentClockSpeed"] 33 | cpuInfo["model_name"] = cpu["Name"] 34 | cpuInfo["cpu_cores"] = cpu["NumberOfCores"] 35 | cpuInfo["cpu_logical_processors"] = cpu["NumberOfLogicalProcessors"] 36 | cpuInfo["vendor_id"] = cpu["Manufacturer"] 37 | 38 | caption := fmt.Sprintf(" %s ", cpu["Caption"]) 39 | cpuInfo["family"] = extract(caption, "Family") 40 | cpuInfo["model"] = extract(caption, "Model") 41 | cpuInfo["stepping"] = extract(caption, "Stepping") 42 | 43 | return 44 | } 45 | 46 | func extract(caption, field string) string { 47 | re := regexp.MustCompile(fmt.Sprintf("%s [0-9]* ", field)) 48 | return strings.Split(re.FindStringSubmatch(caption)[0], " ")[1] 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/filesystem/filesystem.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin 2 | 3 | package filesystem 4 | 5 | import ( 6 | "fmt" 7 | "log" 8 | "os/exec" 9 | "regexp" 10 | "strings" 11 | "time" 12 | ) 13 | 14 | func getFileSystemInfo() (interface{}, error) { 15 | /* Grab filesystem data from df */ 16 | cmd := exec.Command("df", dfOptions...) 17 | 18 | outCh := make(chan []byte, 1) 19 | errCh := make(chan error, 1) 20 | 21 | var out interface{} 22 | var err error 23 | 24 | go func() { 25 | _out, _err := cmd.Output() 26 | if _err != nil { 27 | errCh <- fmt.Errorf("df failed to collect filesystem data: %s", _err) 28 | return 29 | } 30 | outCh <- _out 31 | }() 32 | 33 | WAIT: 34 | for { 35 | select { 36 | case res := <-outCh: 37 | if res != nil { 38 | out, err = parseDfOutput(string(res)) 39 | } else { 40 | out, err = nil, fmt.Errorf("df failed to collect filesystem data") 41 | } 42 | break WAIT 43 | case err = <-errCh: 44 | out = nil 45 | break WAIT 46 | case <-time.After(2 * time.Second): 47 | // Kill the process if it takes too long 48 | if killErr := cmd.Process.Kill(); killErr != nil { 49 | log.Fatal("failed to kill:", killErr) 50 | // Force goroutine to exit 51 | <-outCh 52 | } 53 | } 54 | } 55 | 56 | return out, err 57 | } 58 | 59 | func parseDfOutput(out string) (interface{}, error) { 60 | lines := strings.Split(out, "\n") 61 | var fileSystemInfo []interface{} = make([]interface{}, len(lines)-2) 62 | for i, line := range lines[1:] { 63 | values := regexp.MustCompile("\\s+").Split(line, expectedLength) 64 | if len(values) == expectedLength { 65 | fileSystemInfo[i] = updatefileSystemInfo(values) 66 | } 67 | } 68 | return fileSystemInfo, nil 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/filesystem/filesystem_common.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | type FileSystem struct{} 4 | 5 | const name = "filesystem" 6 | 7 | func (self *FileSystem) Name() string { 8 | return name 9 | } 10 | 11 | func (self *FileSystem) Collect() (result interface{}, err error) { 12 | result, err = getFileSystemInfo() 13 | return 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/filesystem/filesystem_darwin.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | var dfOptions = []string{"-l", "-k"} 4 | var expectedLength = 9 5 | 6 | func updatefileSystemInfo(values []string) map[string]string { 7 | return map[string]string{ 8 | "name": values[0], 9 | "kb_size": values[1], 10 | "mounted_on": values[8], 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/filesystem/filesystem_linux.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | var dfOptions = []string{"-l"} 4 | var expectedLength = 6 5 | 6 | func updatefileSystemInfo(values []string) map[string]string { 7 | return map[string]string{ 8 | "name": values[0], 9 | "kb_size": values[1], 10 | "mounted_on": values[5], 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/filesystem/filesystem_windows.go: -------------------------------------------------------------------------------- 1 | package filesystem 2 | 3 | import ( 4 | utils "github.com/DataDog/gohai/windowsutils" 5 | "strconv" 6 | ) 7 | 8 | func getFileSystemInfo() (interface{}, error) { 9 | 10 | volumes, err := utils.WindowsWMIMultilineCommand("VOLUME", "Name", "Capacity", "DriveLetter") 11 | if err != nil { 12 | return nil, err 13 | } 14 | var fileSystemInfo = make([]interface{}, len(volumes)) 15 | for i, volume := range volumes { 16 | var capacity string 17 | intCapacity, err := strconv.ParseInt(volume["Capacity"], 10, 64) 18 | if err != nil { 19 | capacity = "Unknown" 20 | } else { 21 | capacity = strconv.FormatInt(intCapacity/1024.0, 10) 22 | } 23 | fileSystemInfo[i] = map[string]interface{}{ 24 | "name": volume["Name"], 25 | "kb_size": capacity, 26 | "mounted_on": volume["DriveLetter"], 27 | } 28 | } 29 | 30 | return fileSystemInfo, nil 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/memory/memory.go: -------------------------------------------------------------------------------- 1 | package memory 2 | 3 | type Memory struct{} 4 | 5 | const name = "memory" 6 | 7 | func (self *Memory) Name() string { 8 | return name 9 | } 10 | 11 | func (self *Memory) Collect() (result interface{}, err error) { 12 | result, err = getMemoryInfo() 13 | return 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/memory/memory_darwin.go: -------------------------------------------------------------------------------- 1 | package memory 2 | 3 | import ( 4 | "os/exec" 5 | "regexp" 6 | "strings" 7 | ) 8 | 9 | func getMemoryInfo() (memoryInfo map[string]string, err error) { 10 | memoryInfo = make(map[string]string) 11 | 12 | out, err := exec.Command("sysctl", "-n", "hw.memsize").Output() 13 | if err != nil { 14 | return memoryInfo, err 15 | } 16 | memoryInfo["total"] = strings.Trim(string(out), "\n") 17 | 18 | out, err = exec.Command("sysctl", "-n", "vm.swapusage").Output() 19 | if err != nil { 20 | return memoryInfo, err 21 | } 22 | swap := regexp.MustCompile("total = ").Split(string(out), 2)[1] 23 | memoryInfo["swap_total"] = strings.Split(swap, " ")[0] 24 | 25 | return 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/memory/memory_linux.go: -------------------------------------------------------------------------------- 1 | package memory 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | "regexp" 8 | ) 9 | 10 | var memMap = map[string]string{ 11 | "MemTotal": "total", 12 | "SwapTotal": "swap_total", 13 | } 14 | 15 | func getMemoryInfo() (memoryInfo map[string]string, err error) { 16 | file, err := os.Open("/proc/meminfo") 17 | 18 | if err != nil { 19 | return 20 | } 21 | 22 | var lines []string 23 | scanner := bufio.NewScanner(file) 24 | 25 | for scanner.Scan() { 26 | lines = append(lines, scanner.Text()) 27 | } 28 | 29 | if scanner.Err() != nil { 30 | err = scanner.Err() 31 | return 32 | } 33 | 34 | memoryInfo = make(map[string]string) 35 | 36 | for _, line := range lines { 37 | pair := regexp.MustCompile(": +").Split(line, 2) 38 | values := regexp.MustCompile(" +").Split(pair[1], 2) 39 | 40 | key, ok := memMap[pair[0]] 41 | if ok { 42 | memoryInfo[key] = fmt.Sprintf("%s%s", values[0], values[1]) 43 | } 44 | } 45 | 46 | return 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/memory/memory_windows.go: -------------------------------------------------------------------------------- 1 | package memory 2 | 3 | import ( 4 | utils "github.com/DataDog/gohai/windowsutils" 5 | ) 6 | 7 | func getMemoryInfo() (memoryInfo map[string]string, err error) { 8 | memoryInfo = make(map[string]string) 9 | computerSystem, err := utils.WindowsWMICommand("COMPUTERSYSTEM", "TotalPhysicalMemory") 10 | if err != nil { 11 | return 12 | } 13 | memoryInfo["total"] = computerSystem["TotalPhysicalMemory"] 14 | 15 | return 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/network/network.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin 2 | 3 | package network 4 | 5 | func getNetworkInfo() (networkInfo map[string]interface{}, err error) { 6 | networkInfo = make(map[string]interface{}) 7 | 8 | macaddress, err := macAddress() 9 | if err != nil { 10 | return networkInfo, err 11 | } 12 | networkInfo["macaddress"] = macaddress 13 | 14 | ipAddress, err := externalIpAddress() 15 | if err != nil { 16 | return networkInfo, err 17 | } 18 | networkInfo["ipaddress"] = ipAddress 19 | 20 | ipAddressV6, err := externalIpv6Address() 21 | if err != nil { 22 | return networkInfo, err 23 | } 24 | // We append an IPv6 address to the payload only if IPv6 is enabled 25 | if ipAddressV6 != "" { 26 | networkInfo["ipaddressv6"] = ipAddressV6 27 | } 28 | 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/network/network_windows.go: -------------------------------------------------------------------------------- 1 | package network 2 | 3 | import ( 4 | "errors" 5 | "os/exec" 6 | "strings" 7 | ) 8 | 9 | func getNetworkInfo() (networkInfo map[string]interface{}, err error) { 10 | networkInfo = make(map[string]interface{}) 11 | 12 | out, err := exec.Command("ipconfig", "-all").CombinedOutput() 13 | if err != nil { 14 | return 15 | } 16 | 17 | networkInfo, err = parseIpConfig(string(out)) 18 | return 19 | } 20 | 21 | func parseIpConfig(out string) (networkInfo map[string]interface{}, err error) { 22 | // The hardest part is that we want the 3 addresses to come from the same block 23 | // or else, it wouldn't really make sense. Also we assume that only one 24 | // interface is seriously enabled and has IPv4 at least 25 | networkInfo = make(map[string]interface{}) 26 | var ip, mac, ipv6 string 27 | 28 | lines := strings.Split(string(out), "\n") 29 | gottablock := false 30 | for _, line := range lines { 31 | // The line below is here in case we have to convert some Unicode to ASCII 32 | // It shouldn't do anything on Windows but when running the tests (for 33 | // Windows) on a Unix based-system, it's essential. 34 | line = strings.Replace(line, "\x00", "", -1) 35 | 36 | if strings.Contains(line, "IPv4") { 37 | ip = line 38 | gottablock = true 39 | } else if strings.Contains(line, "Physical Address") && mac == "" { 40 | mac = line 41 | } else if strings.Contains(line, "IPv6") && ipv6 == "" { 42 | ipv6 = line 43 | } 44 | // Whenever we reach the end of a block 45 | if isEmptyString(line) { 46 | if gottablock && mac != "" { 47 | break 48 | } else { // Or something's wrong... let's try again with the next block 49 | gottablock = false 50 | ip, mac, ipv6 = "", "", "" 51 | } 52 | } 53 | } 54 | 55 | elt := strings.Split(ip, ": ") 56 | if len(elt) >= 2 { 57 | networkInfo["ipaddress"] = strings.Trim(strings.Trim(elt[1], "\r"), "(Preferred) ") 58 | } else { 59 | return networkInfo, errors.New("not connected to the network") 60 | } 61 | 62 | // We're sure to have a mac address at this point, no paranoia check needed 63 | elt = strings.Split(mac, ": ") 64 | networkInfo["macaddress"] = strings.Trim(strings.Trim(elt[1], "\r"), "(Preferred) ") 65 | 66 | // But some interfaces still don't like IPv6 (or have it turned off) 67 | elt = strings.Split(ipv6, ": ") 68 | if len(elt) >= 2 { 69 | networkInfo["ipaddressv6"] = strings.Replace(strings.Trim(elt[1], "\r"), "(Preferred) ", "", -1) 70 | } else { 71 | networkInfo["ipaddressv6"] = "" 72 | } 73 | return 74 | } 75 | 76 | func isEmptyString(val string) bool { 77 | return val == "\r" || val == "" 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/platform/platform.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin 2 | 3 | package platform 4 | 5 | import ( 6 | "fmt" 7 | "os/exec" 8 | "regexp" 9 | "strings" 10 | ) 11 | 12 | func getArchInfo() (archInfo map[string]interface{}, err error) { 13 | archInfo = make(map[string]interface{}) 14 | 15 | out, err := exec.Command("uname", unameOptions...).Output() 16 | if err != nil { 17 | return nil, err 18 | } 19 | line := fmt.Sprintf("%s", out) 20 | values := regexp.MustCompile(" +").Split(line, 7) 21 | updateArchInfo(archInfo, values) 22 | 23 | out, err = exec.Command("uname", "-v").Output() 24 | if err != nil { 25 | return nil, err 26 | } 27 | archInfo["kernel_version"] = strings.Trim(string(out), "\n") 28 | 29 | return 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/platform/platform_common.go: -------------------------------------------------------------------------------- 1 | package platform 2 | 3 | import ( 4 | "fmt" 5 | "os/exec" 6 | "regexp" 7 | "runtime" 8 | "strings" 9 | ) 10 | 11 | type Platform struct{} 12 | 13 | const name = "platform" 14 | 15 | func (self *Platform) Name() string { 16 | return name 17 | } 18 | 19 | func (self *Platform) Collect() (result interface{}, err error) { 20 | result, err = getPlatformInfo() 21 | return 22 | } 23 | 24 | func getPlatformInfo() (platformInfo map[string]interface{}, err error) { 25 | 26 | platformInfo, err = getArchInfo() 27 | if err != nil { 28 | return platformInfo, err 29 | } 30 | 31 | platformInfo["goV"] = strings.Replace(runtime.Version(), "go", "", -1) 32 | pythonV, err := getPythonVersion() 33 | if err != nil { 34 | return platformInfo, err 35 | } 36 | platformInfo["pythonV"] = pythonV 37 | 38 | platformInfo["GOOS"] = runtime.GOOS 39 | platformInfo["GOOARCH"] = runtime.GOARCH 40 | 41 | return 42 | } 43 | 44 | func getPythonVersion() (string, error) { 45 | out, err := exec.Command("python", "-V").CombinedOutput() 46 | if err != nil { 47 | return "", err 48 | } 49 | version := fmt.Sprintf("%s", out) 50 | values := regexp.MustCompile("Python (.*)\n").FindStringSubmatch(version) 51 | return strings.Trim(values[1], "\r"), nil 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/platform/platform_darwin.go: -------------------------------------------------------------------------------- 1 | package platform 2 | 3 | import "strings" 4 | 5 | var unameOptions = []string{"-s", "-n", "-r", "-m", "-p"} 6 | 7 | func updateArchInfo(archInfo map[string]interface{}, values []string) { 8 | archInfo["kernel_name"] = values[0] 9 | archInfo["hostname"] = values[1] 10 | archInfo["kernel_release"] = values[2] 11 | archInfo["machine"] = values[3] 12 | archInfo["processor"] = strings.Trim(values[4], "\n") 13 | archInfo["os"] = values[0] 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/platform/platform_linux.go: -------------------------------------------------------------------------------- 1 | package platform 2 | 3 | import "strings" 4 | 5 | var unameOptions = []string{"-s", "-n", "-r", "-m", "-p", "-i", "-o"} 6 | 7 | func updateArchInfo(archInfo map[string]interface{}, values []string) { 8 | archInfo["kernel_name"] = values[0] 9 | archInfo["hostname"] = values[1] 10 | archInfo["kernel_release"] = values[2] 11 | archInfo["machine"] = values[3] 12 | archInfo["processor"] = values[4] 13 | archInfo["hardware_platform"] = values[5] 14 | archInfo["os"] = strings.Trim(values[6], "\n") 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/DataDog/gohai/platform/platform_windows.go: -------------------------------------------------------------------------------- 1 | package platform 2 | 3 | import ( 4 | utils "github.com/DataDog/gohai/windowsutils" 5 | ) 6 | 7 | func getArchInfo() (systemInfo map[string]interface{}, err error) { 8 | systemInfo = make(map[string]interface{}) 9 | 10 | computerSystem, err := utils.WindowsWMICommand("COMPUTERSYSTEM", "Name", "SystemType") 11 | if err != nil { 12 | return 13 | } 14 | systemInfo["hostname"] = computerSystem["Name"] 15 | systemInfo["machine"] = computerSystem["SystemType"] 16 | 17 | os, err := utils.WindowsWMICommand("OS", "Version", "Caption") 18 | if err != nil { 19 | return 20 | } 21 | systemInfo["kernel_release"] = os["Version"] 22 | systemInfo["os"] = os["Caption"] 23 | 24 | systemInfo["kernel_name"] = "Windows" 25 | 26 | return 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/template/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/template/README.md: -------------------------------------------------------------------------------- 1 | # Go's `text/template` package with newline elision 2 | 3 | This is a fork of Go 1.4's [text/template](http://golang.org/pkg/text/template/) package with one addition: a backslash immediately after a closing delimiter will delete all subsequent newlines until a non-newline. 4 | 5 | eg. 6 | 7 | ``` 8 | {{if true}}\ 9 | hello 10 | {{end}}\ 11 | ``` 12 | 13 | Will result in: 14 | 15 | ``` 16 | hello\n 17 | ``` 18 | 19 | Rather than: 20 | 21 | ``` 22 | \n 23 | hello\n 24 | \n 25 | ``` 26 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/units/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 Alec Thomas 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/units/README.md: -------------------------------------------------------------------------------- 1 | # Units - Helpful unit multipliers and functions for Go 2 | 3 | The goal of this package is to have functionality similar to the [time](http://golang.org/pkg/time/) package. 4 | 5 | It allows for code like this: 6 | 7 | ```go 8 | n, err := ParseBase2Bytes("1KB") 9 | // n == 1024 10 | n = units.Mebibyte * 512 11 | ``` 12 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/units/bytes.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | // Base2Bytes is the old non-SI power-of-2 byte scale (1024 bytes in a kilobyte, 4 | // etc.). 5 | type Base2Bytes int64 6 | 7 | // Base-2 byte units. 8 | const ( 9 | Kibibyte Base2Bytes = 1024 10 | KiB = Kibibyte 11 | Mebibyte = Kibibyte * 1024 12 | MiB = Mebibyte 13 | Gibibyte = Mebibyte * 1024 14 | GiB = Gibibyte 15 | Tebibyte = Gibibyte * 1024 16 | TiB = Tebibyte 17 | Pebibyte = Tebibyte * 1024 18 | PiB = Pebibyte 19 | Exbibyte = Pebibyte * 1024 20 | EiB = Exbibyte 21 | ) 22 | 23 | var ( 24 | bytesUnitMap = MakeUnitMap("iB", "B", 1024) 25 | oldBytesUnitMap = MakeUnitMap("B", "B", 1024) 26 | ) 27 | 28 | // ParseBase2Bytes supports both iB and B in base-2 multipliers. That is, KB 29 | // and KiB are both 1024. 30 | func ParseBase2Bytes(s string) (Base2Bytes, error) { 31 | n, err := ParseUnit(s, bytesUnitMap) 32 | if err != nil { 33 | n, err = ParseUnit(s, oldBytesUnitMap) 34 | } 35 | return Base2Bytes(n), err 36 | } 37 | 38 | func (b Base2Bytes) String() string { 39 | return ToString(int64(b), 1024, "iB", "B") 40 | } 41 | 42 | var ( 43 | metricBytesUnitMap = MakeUnitMap("B", "B", 1000) 44 | ) 45 | 46 | // MetricBytes are SI byte units (1000 bytes in a kilobyte). 47 | type MetricBytes SI 48 | 49 | // SI base-10 byte units. 50 | const ( 51 | Kilobyte MetricBytes = 1000 52 | KB = Kilobyte 53 | Megabyte = Kilobyte * 1000 54 | MB = Megabyte 55 | Gigabyte = Megabyte * 1000 56 | GB = Gigabyte 57 | Terabyte = Gigabyte * 1000 58 | TB = Terabyte 59 | Petabyte = Terabyte * 1000 60 | PB = Petabyte 61 | Exabyte = Petabyte * 1000 62 | EB = Exabyte 63 | ) 64 | 65 | // ParseMetricBytes parses base-10 metric byte units. That is, KB is 1000 bytes. 66 | func ParseMetricBytes(s string) (MetricBytes, error) { 67 | n, err := ParseUnit(s, metricBytesUnitMap) 68 | return MetricBytes(n), err 69 | } 70 | 71 | func (m MetricBytes) String() string { 72 | return ToString(int64(m), 1000, "B", "B") 73 | } 74 | 75 | // ParseStrictBytes supports both iB and B suffixes for base 2 and metric, 76 | // respectively. That is, KiB represents 1024 and KB represents 1000. 77 | func ParseStrictBytes(s string) (int64, error) { 78 | n, err := ParseUnit(s, bytesUnitMap) 79 | if err != nil { 80 | n, err = ParseUnit(s, metricBytesUnitMap) 81 | } 82 | return int64(n), err 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/units/doc.go: -------------------------------------------------------------------------------- 1 | // Package units provides helpful unit multipliers and functions for Go. 2 | // 3 | // The goal of this package is to have functionality similar to the time [1] package. 4 | // 5 | // 6 | // [1] http://golang.org/pkg/time/ 7 | // 8 | // It allows for code like this: 9 | // 10 | // n, err := ParseBase2Bytes("1KB") 11 | // // n == 1024 12 | // n = units.Mebibyte * 512 13 | package units 14 | -------------------------------------------------------------------------------- /vendor/github.com/alecthomas/units/si.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | // SI units. 4 | type SI int64 5 | 6 | // SI unit multiples. 7 | const ( 8 | Kilo SI = 1000 9 | Mega = Kilo * 1000 10 | Giga = Mega * 1000 11 | Tera = Giga * 1000 12 | Peta = Tera * 1000 13 | Exa = Peta * 1000 14 | ) 15 | 16 | func MakeUnitMap(suffix, shortSuffix string, scale int64) map[string]float64 { 17 | return map[string]float64{ 18 | shortSuffix: 1, 19 | "K" + suffix: float64(scale), 20 | "M" + suffix: float64(scale * scale), 21 | "G" + suffix: float64(scale * scale * scale), 22 | "T" + suffix: float64(scale * scale * scale * scale), 23 | "P" + suffix: float64(scale * scale * scale * scale * scale), 24 | "E" + suffix: float64(scale * scale * scale * scale * scale * scale), 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/elazarl/go-bindata-assetfs/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Elazar Leibovich 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /vendor/github.com/elazarl/go-bindata-assetfs/README.md: -------------------------------------------------------------------------------- 1 | # go-bindata-assetfs 2 | 3 | Serve embedded files from [jteeuwen/go-bindata](https://github.com/jteeuwen/go-bindata) with `net/http`. 4 | 5 | [GoDoc](http://godoc.org/github.com/elazarl/go-bindata-assetfs) 6 | 7 | ### Installation 8 | 9 | Install with 10 | 11 | $ go get github.com/jteeuwen/go-bindata/... 12 | $ go get github.com/elazarl/go-bindata-assetfs/... 13 | 14 | ### Creating embedded data 15 | 16 | Usage is identical to [jteeuwen/go-bindata](https://github.com/jteeuwen/go-bindata) usage, 17 | instead of running `go-bindata` run `go-bindata-assetfs`. 18 | 19 | The tool will create a `bindata_assetfs.go` file, which contains the embedded data. 20 | 21 | A typical use case is 22 | 23 | $ go-bindata-assetfs data/... 24 | 25 | ### Using assetFS in your code 26 | 27 | The generated file provides an `assetFS()` function that returns a `http.Filesystem` 28 | wrapping the embedded files. What you usually want to do is: 29 | 30 | http.Handle("/", http.FileServer(assetFS())) 31 | 32 | This would run an HTTP server serving the embedded files. 33 | 34 | ## Without running binary tool 35 | 36 | You can always just run the `go-bindata` tool, and then 37 | 38 | use 39 | 40 | import "github.com/elazarl/go-bindata-assetfs" 41 | ... 42 | http.Handle("/", 43 | http.FileServer( 44 | &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, AssetInfo: AssetInfo, Prefix: "data"})) 45 | 46 | to serve files embedded from the `data` directory. 47 | -------------------------------------------------------------------------------- /vendor/github.com/elazarl/go-bindata-assetfs/doc.go: -------------------------------------------------------------------------------- 1 | // assetfs allows packages to serve static content embedded 2 | // with the go-bindata tool with the standard net/http package. 3 | // 4 | // See https://github.com/jteeuwen/go-bindata for more information 5 | // about embedding binary data with go-bindata. 6 | // 7 | // Usage example, after running 8 | // $ go-bindata data/... 9 | // use: 10 | // http.Handle("/", 11 | // http.FileServer( 12 | // &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: "data"})) 13 | package assetfs 14 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/core/.gitignore: -------------------------------------------------------------------------------- 1 | *.db 2 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/core/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 - 2015 Lunny Xiao 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/core/README.md: -------------------------------------------------------------------------------- 1 | Core is a lightweight wrapper of sql.DB. 2 | 3 | # Open 4 | ```Go 5 | db, _ := core.Open(db, connstr) 6 | ``` 7 | 8 | # SetMapper 9 | ```Go 10 | db.SetMapper(SameMapper()) 11 | ``` 12 | 13 | ## Scan usage 14 | 15 | ### Scan 16 | ```Go 17 | rows, _ := db.Query() 18 | for rows.Next() { 19 | rows.Scan() 20 | } 21 | ``` 22 | 23 | ### ScanMap 24 | ```Go 25 | rows, _ := db.Query() 26 | for rows.Next() { 27 | rows.ScanMap() 28 | ``` 29 | 30 | ### ScanSlice 31 | 32 | You can use `[]string`, `[][]byte`, `[]interface{}`, `[]*string`, `[]sql.NullString` to ScanSclice. Notice, slice's length should be equal or less than select columns. 33 | 34 | ```Go 35 | rows, _ := db.Query() 36 | cols, _ := rows.Columns() 37 | for rows.Next() { 38 | var s = make([]string, len(cols)) 39 | rows.ScanSlice(&s) 40 | } 41 | ``` 42 | 43 | ```Go 44 | rows, _ := db.Query() 45 | cols, _ := rows.Columns() 46 | for rows.Next() { 47 | var s = make([]*string, len(cols)) 48 | rows.ScanSlice(&s) 49 | } 50 | ``` 51 | 52 | ### ScanStruct 53 | ```Go 54 | rows, _ := db.Query() 55 | for rows.Next() { 56 | rows.ScanStructByName() 57 | rows.ScanStructByIndex() 58 | } 59 | ``` 60 | 61 | ## Query usage 62 | ```Go 63 | rows, err := db.Query("select * from table where name = ?", name) 64 | 65 | user = User{ 66 | Name:"lunny", 67 | } 68 | rows, err := db.QueryStruct("select * from table where name = ?Name", 69 | &user) 70 | 71 | var user = map[string]interface{}{ 72 | "name": "lunny", 73 | } 74 | rows, err = db.QueryMap("select * from table where name = ?name", 75 | &user) 76 | ``` 77 | 78 | ## QueryRow usage 79 | ```Go 80 | row := db.QueryRow("select * from table where name = ?", name) 81 | 82 | user = User{ 83 | Name:"lunny", 84 | } 85 | row := db.QueryRowStruct("select * from table where name = ?Name", 86 | &user) 87 | 88 | var user = map[string]interface{}{ 89 | "name": "lunny", 90 | } 91 | row = db.QueryRowMap("select * from table where name = ?name", 92 | &user) 93 | ``` 94 | 95 | ## Exec usage 96 | ```Go 97 | db.Exec("insert into user (`name`, title, age, alias, nick_name,created) values (?,?,?,?,?,?)", name, title, age, alias...) 98 | 99 | user = User{ 100 | Name:"lunny", 101 | Title:"test", 102 | Age: 18, 103 | } 104 | result, err = db.ExecStruct("insert into user (`name`, title, age, alias, nick_name,created) values (?Name,?Title,?Age,?Alias,?NickName,?Created)", 105 | &user) 106 | 107 | var user = map[string]interface{}{ 108 | "Name": "lunny", 109 | "Title": "test", 110 | "Age": 18, 111 | } 112 | result, err = db.ExecMap("insert into user (`name`, title, age, alias, nick_name,created) values (?Name,?Title,?Age,?Alias,?NickName,?Created)", 113 | &user) 114 | ``` -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/core/benchmark.sh: -------------------------------------------------------------------------------- 1 | go test -v -bench=. -run=XXX 2 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/core/cache.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "time" 7 | "bytes" 8 | "encoding/gob" 9 | ) 10 | 11 | const ( 12 | // default cache expired time 13 | CacheExpired = 60 * time.Minute 14 | // not use now 15 | CacheMaxMemory = 256 16 | // evey ten minutes to clear all expired nodes 17 | CacheGcInterval = 10 * time.Minute 18 | // each time when gc to removed max nodes 19 | CacheGcMaxRemoved = 20 20 | ) 21 | 22 | var ( 23 | ErrCacheMiss = errors.New("xorm/cache: key not found.") 24 | ErrNotStored = errors.New("xorm/cache: not stored.") 25 | ) 26 | 27 | // CacheStore is a interface to store cache 28 | type CacheStore interface { 29 | // key is primary key or composite primary key 30 | // value is struct's pointer 31 | // key format : -p--... 32 | Put(key string, value interface{}) error 33 | Get(key string) (interface{}, error) 34 | Del(key string) error 35 | } 36 | 37 | // Cacher is an interface to provide cache 38 | // id format : u--... 39 | type Cacher interface { 40 | GetIds(tableName, sql string) interface{} 41 | GetBean(tableName string, id string) interface{} 42 | PutIds(tableName, sql string, ids interface{}) 43 | PutBean(tableName string, id string, obj interface{}) 44 | DelIds(tableName, sql string) 45 | DelBean(tableName string, id string) 46 | ClearIds(tableName string) 47 | ClearBeans(tableName string) 48 | } 49 | 50 | func encodeIds(ids []PK) (string, error) { 51 | buf := new(bytes.Buffer) 52 | enc := gob.NewEncoder(buf) 53 | err := enc.Encode(ids) 54 | 55 | return buf.String(), err 56 | } 57 | 58 | 59 | func decodeIds(s string) ([]PK, error) { 60 | pks := make([]PK, 0) 61 | 62 | dec := gob.NewDecoder(bytes.NewBufferString(s)) 63 | err := dec.Decode(&pks) 64 | 65 | return pks, err 66 | } 67 | 68 | func GetCacheSql(m Cacher, tableName, sql string, args interface{}) ([]PK, error) { 69 | bytes := m.GetIds(tableName, GenSqlKey(sql, args)) 70 | if bytes == nil { 71 | return nil, errors.New("Not Exist") 72 | } 73 | return decodeIds(bytes.(string)) 74 | } 75 | 76 | func PutCacheSql(m Cacher, ids []PK, tableName, sql string, args interface{}) error { 77 | bytes, err := encodeIds(ids) 78 | if err != nil { 79 | return err 80 | } 81 | m.PutIds(tableName, GenSqlKey(sql, args), bytes) 82 | return nil 83 | } 84 | 85 | func GenSqlKey(sql string, args interface{}) string { 86 | return fmt.Sprintf("%v-%v", sql, args) 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/core/converstion.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | // Conversion is an interface. A type implements Conversion will according 4 | // the custom method to fill into database and retrieve from database. 5 | type Conversion interface { 6 | FromDB([]byte) error 7 | ToDB() ([]byte, error) 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/core/driver.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | type Driver interface { 4 | Parse(string, string) (*Uri, error) 5 | } 6 | 7 | var ( 8 | drivers = map[string]Driver{} 9 | ) 10 | 11 | func RegisterDriver(driverName string, driver Driver) { 12 | if driver == nil { 13 | panic("core: Register driver is nil") 14 | } 15 | if _, dup := drivers[driverName]; dup { 16 | panic("core: Register called twice for driver " + driverName) 17 | } 18 | drivers[driverName] = driver 19 | } 20 | 21 | func QueryDriver(driverName string) Driver { 22 | return drivers[driverName] 23 | } 24 | 25 | func RegisteredDriverSize() int { 26 | return len(drivers) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/core/error.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import "errors" 4 | 5 | var ( 6 | ErrNoMapPointer = errors.New("mp should be a map's pointer") 7 | ErrNoStructPointer = errors.New("mp should be a struct's pointer") 8 | //ErrNotExist = errors.New("Not exist") 9 | //ErrIgnore = errors.New("Ignore") 10 | ) 11 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/core/filter.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // Filter is an interface to filter SQL 9 | type Filter interface { 10 | Do(sql string, dialect Dialect, table *Table) string 11 | } 12 | 13 | // QuoteFilter filter SQL replace ` to database's own quote character 14 | type QuoteFilter struct { 15 | } 16 | 17 | func (s *QuoteFilter) Do(sql string, dialect Dialect, table *Table) string { 18 | return strings.Replace(sql, "`", dialect.QuoteStr(), -1) 19 | } 20 | 21 | // IdFilter filter SQL replace (id) to primary key column name 22 | type IdFilter struct { 23 | } 24 | 25 | type Quoter struct { 26 | dialect Dialect 27 | } 28 | 29 | func NewQuoter(dialect Dialect) *Quoter { 30 | return &Quoter{dialect} 31 | } 32 | 33 | func (q *Quoter) Quote(content string) string { 34 | return q.dialect.QuoteStr() + content + q.dialect.QuoteStr() 35 | } 36 | 37 | func (i *IdFilter) Do(sql string, dialect Dialect, table *Table) string { 38 | quoter := NewQuoter(dialect) 39 | if table != nil && len(table.PrimaryKeys) == 1 { 40 | sql = strings.Replace(sql, "`(id)`", quoter.Quote(table.PrimaryKeys[0]), -1) 41 | sql = strings.Replace(sql, quoter.Quote("(id)"), quoter.Quote(table.PrimaryKeys[0]), -1) 42 | return strings.Replace(sql, "(id)", quoter.Quote(table.PrimaryKeys[0]), -1) 43 | } 44 | return sql 45 | } 46 | 47 | // SeqFilter filter SQL replace ?, ? ... to $1, $2 ... 48 | type SeqFilter struct { 49 | Prefix string 50 | Start int 51 | } 52 | 53 | func (s *SeqFilter) Do(sql string, dialect Dialect, table *Table) string { 54 | segs := strings.Split(sql, "?") 55 | size := len(segs) 56 | res := "" 57 | for i, c := range segs { 58 | if i < size-1 { 59 | res += c + fmt.Sprintf("%s%v", s.Prefix, i+s.Start) 60 | } 61 | } 62 | res += segs[size-1] 63 | return res 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/core/ilogger.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | type LogLevel int 4 | 5 | const ( 6 | // !nashtsai! following level also match syslog.Priority value 7 | LOG_UNKNOWN LogLevel = iota - 2 8 | LOG_OFF LogLevel = iota - 1 9 | LOG_ERR LogLevel = iota + 3 10 | LOG_WARNING 11 | LOG_INFO LogLevel = iota + 6 12 | LOG_DEBUG 13 | ) 14 | 15 | // logger interface 16 | type ILogger interface { 17 | Debug(v ...interface{}) (err error) 18 | Debugf(format string, v ...interface{}) (err error) 19 | Err(v ...interface{}) (err error) 20 | Errf(format string, v ...interface{}) (err error) 21 | Info(v ...interface{}) (err error) 22 | Infof(format string, v ...interface{}) (err error) 23 | Warning(v ...interface{}) (err error) 24 | Warningf(format string, v ...interface{}) (err error) 25 | 26 | Level() LogLevel 27 | SetLevel(l LogLevel) (err error) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/core/index.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | "strings" 7 | ) 8 | 9 | const ( 10 | IndexType = iota + 1 11 | UniqueType 12 | ) 13 | 14 | // database index 15 | type Index struct { 16 | IsRegular bool 17 | Name string 18 | Type int 19 | Cols []string 20 | } 21 | 22 | func (index *Index) XName(tableName string) string { 23 | if !strings.HasPrefix(index.Name, "UQE_") && 24 | !strings.HasPrefix(index.Name, "IDX_") { 25 | if index.Type == UniqueType { 26 | return fmt.Sprintf("UQE_%v_%v", tableName, index.Name) 27 | } 28 | return fmt.Sprintf("IDX_%v_%v", tableName, index.Name) 29 | } 30 | return index.Name 31 | } 32 | 33 | // add columns which will be composite index 34 | func (index *Index) AddColumn(cols ...string) { 35 | for _, col := range cols { 36 | index.Cols = append(index.Cols, col) 37 | } 38 | } 39 | 40 | func (index *Index) Equal(dst *Index) bool { 41 | if index.Type != dst.Type { 42 | return false 43 | } 44 | if len(index.Cols) != len(dst.Cols) { 45 | return false 46 | } 47 | sort.StringSlice(index.Cols).Sort() 48 | sort.StringSlice(dst.Cols).Sort() 49 | 50 | for i := 0; i < len(index.Cols); i++ { 51 | if index.Cols[i] != dst.Cols[i] { 52 | return false 53 | } 54 | } 55 | return true 56 | } 57 | 58 | // new an index 59 | func NewIndex(name string, indexType int) *Index { 60 | return &Index{true, name, indexType, make([]string, 0)} 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/core/pk.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "bytes" 5 | "encoding/gob" 6 | ) 7 | 8 | type PK []interface{} 9 | 10 | func NewPK(pks ...interface{}) *PK { 11 | p := PK(pks) 12 | return &p 13 | } 14 | 15 | func (p *PK) ToString() (string, error) { 16 | buf := new(bytes.Buffer) 17 | enc := gob.NewEncoder(buf) 18 | err := enc.Encode(*p) 19 | return buf.String(), err 20 | } 21 | 22 | func (p *PK) FromString(content string) error { 23 | dec := gob.NewDecoder(bytes.NewBufferString(content)) 24 | err := dec.Decode(p) 25 | return err 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/core/scan.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "database/sql/driver" 5 | "fmt" 6 | "time" 7 | ) 8 | 9 | type NullTime time.Time 10 | 11 | var ( 12 | _ driver.Valuer = NullTime{} 13 | ) 14 | 15 | func (ns *NullTime) Scan(value interface{}) error { 16 | if value == nil { 17 | return nil 18 | } 19 | return convertTime(ns, value) 20 | } 21 | 22 | // Value implements the driver Valuer interface. 23 | func (ns NullTime) Value() (driver.Value, error) { 24 | if (time.Time)(ns).IsZero() { 25 | return nil, nil 26 | } 27 | return (time.Time)(ns).Format("2006-01-02 15:04:05"), nil 28 | } 29 | 30 | func convertTime(dest *NullTime, src interface{}) error { 31 | // Common cases, without reflect. 32 | switch s := src.(type) { 33 | case string: 34 | t, err := time.Parse("2006-01-02 15:04:05", s) 35 | if err != nil { 36 | return err 37 | } 38 | *dest = NullTime(t) 39 | return nil 40 | case []uint8: 41 | t, err := time.Parse("2006-01-02 15:04:05", string(s)) 42 | if err != nil { 43 | return err 44 | } 45 | *dest = NullTime(t) 46 | return nil 47 | case nil: 48 | default: 49 | return fmt.Errorf("unsupported driver -> Scan pair: %T -> %T", src, dest) 50 | } 51 | return nil 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | *.db 6 | 7 | # Folders 8 | _obj 9 | _test 10 | 11 | # Architecture specific extensions/prefixes 12 | *.[568vq] 13 | [568vq].out 14 | 15 | *.cgo1.go 16 | *.cgo2.c 17 | _cgo_defun.c 18 | _cgo_gotypes.go 19 | _cgo_export.* 20 | 21 | _testmain.go 22 | 23 | *.exe 24 | vendor 25 | 26 | *.log 27 | .vendor 28 | temp_test.go 29 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "docs/manual-en-US"] 2 | path = docs/manual-en-US 3 | url = https://github.com/go-xorm/manual-en-US.git 4 | [submodule "docs/manual-zh-CN"] 5 | path = docs/manual-zh-CN 6 | url = https://github.com/go-xorm/manual-zh-CN.git 7 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/.gopmfile: -------------------------------------------------------------------------------- 1 | [target] 2 | path = github.com/go-xorm/xorm -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to xorm 2 | 3 | `xorm` has a backlog of [pull requests](https://help.github.com/articles/using-pull-requests), but contributions are still very 4 | much welcome. You can help with patch review, submitting bug reports, 5 | or adding new functionality. There is no formal style guide, but 6 | please conform to the style of existing code and general Go formatting 7 | conventions when submitting patches. 8 | 9 | * [fork a repo](https://help.github.com/articles/fork-a-repo) 10 | * [creating a pull request ](https://help.github.com/articles/creating-a-pull-request) 11 | 12 | ### Sign your codes with comments 13 | ``` 14 | // !! your comments 15 | 16 | e.g., 17 | 18 | // !lunny! this is comments made by lunny 19 | ``` 20 | 21 | ### Patch review 22 | 23 | Help review existing open [pull requests](https://help.github.com/articles/using-pull-requests) by commenting on the code or 24 | proposed functionality. 25 | 26 | ### Bug reports 27 | 28 | We appreciate any bug reports, but especially ones with self-contained 29 | (doesn't depend on code outside of xorm), minimal (can't be simplified 30 | further) test cases. It's especially helpful if you can submit a pull 31 | request with just the failing test case (you'll probably want to 32 | pattern it after the tests in 33 | [base.go](https://github.com/go-xorm/tests/blob/master/base.go) AND 34 | [benchmark.go](https://github.com/go-xorm/tests/blob/master/benchmark.go). 35 | 36 | If you implements a new database interface, you maybe need to add a _test.go file. 37 | For example, [mysql_test.go](https://github.com/go-xorm/tests/blob/master/mysql/mysql_test.go) 38 | 39 | ### New functionality 40 | 41 | There are a number of pending patches for new functionality, so 42 | additional feature patches will take a while to merge. Still, patches 43 | are generally reviewed based on usefulness and complexity in addition 44 | to time-in-queue, so if you have a knockout idea, take a shot. Feel 45 | free to open an issue discussion your proposed patch beforehand. 46 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 - 2015 The Xorm Authors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/VERSION: -------------------------------------------------------------------------------- 1 | xorm v0.4.5.0113 2 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "errors" 9 | ) 10 | 11 | var ( 12 | ErrParamsType error = errors.New("Params type error") 13 | ErrTableNotFound error = errors.New("Not found table") 14 | ErrUnSupportedType error = errors.New("Unsupported type error") 15 | ErrNotExist error = errors.New("Not exist error") 16 | ErrCacheFailed error = errors.New("Cache failed") 17 | ErrNeedDeletedCond error = errors.New("Delete need at least one condition") 18 | ErrNotImplemented error = errors.New("Not implemented.") 19 | ) 20 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/gen_reserved.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -f $1 ];then 3 | cat $1| awk '{printf("\""$1"\":true,\n")}' 4 | else 5 | echo "argument $1 if not a file!" 6 | fi 7 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/goracle_driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "errors" 9 | "regexp" 10 | 11 | "github.com/go-xorm/core" 12 | ) 13 | 14 | // func init() { 15 | // core.RegisterDriver("goracle", &goracleDriver{}) 16 | // } 17 | 18 | type goracleDriver struct { 19 | } 20 | 21 | func (cfg *goracleDriver) Parse(driverName, dataSourceName string) (*core.Uri, error) { 22 | db := &core.Uri{DbType: core.ORACLE} 23 | dsnPattern := regexp.MustCompile( 24 | `^(?:(?P.*?)(?::(?P.*))?@)?` + // [user[:password]@] 25 | `(?:(?P[^\(]*)(?:\((?P[^\)]*)\))?)?` + // [net[(addr)]] 26 | `\/(?P.*?)` + // /dbname 27 | `(?:\?(?P[^\?]*))?$`) // [?param1=value1¶mN=valueN] 28 | matches := dsnPattern.FindStringSubmatch(dataSourceName) 29 | //tlsConfigRegister := make(map[string]*tls.Config) 30 | names := dsnPattern.SubexpNames() 31 | 32 | for i, match := range matches { 33 | switch names[i] { 34 | case "dbname": 35 | db.DbName = match 36 | } 37 | } 38 | if db.DbName == "" { 39 | return nil, errors.New("dbname is empty") 40 | } 41 | return db, nil 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/logger.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "fmt" 9 | "io" 10 | "log" 11 | 12 | "github.com/go-xorm/core" 13 | ) 14 | 15 | const ( 16 | DEFAULT_LOG_PREFIX = "[xorm]" 17 | DEFAULT_LOG_FLAG = log.Ldate | log.Lmicroseconds 18 | DEFAULT_LOG_LEVEL = core.LOG_DEBUG 19 | ) 20 | 21 | type SimpleLogger struct { 22 | DEBUG *log.Logger 23 | ERR *log.Logger 24 | INFO *log.Logger 25 | WARN *log.Logger 26 | level core.LogLevel 27 | } 28 | 29 | func NewSimpleLogger(out io.Writer) *SimpleLogger { 30 | return NewSimpleLogger2(out, DEFAULT_LOG_PREFIX, DEFAULT_LOG_FLAG) 31 | } 32 | 33 | func NewSimpleLogger2(out io.Writer, prefix string, flag int) *SimpleLogger { 34 | return NewSimpleLogger3(out, prefix, flag, DEFAULT_LOG_LEVEL) 35 | } 36 | 37 | func NewSimpleLogger3(out io.Writer, prefix string, flag int, l core.LogLevel) *SimpleLogger { 38 | return &SimpleLogger{ 39 | DEBUG: log.New(out, fmt.Sprintf("%s [debug] ", prefix), flag), 40 | ERR: log.New(out, fmt.Sprintf("%s [error] ", prefix), flag), 41 | INFO: log.New(out, fmt.Sprintf("%s [info] ", prefix), flag), 42 | WARN: log.New(out, fmt.Sprintf("%s [warn] ", prefix), flag), 43 | level: l, 44 | } 45 | } 46 | 47 | func (s *SimpleLogger) Err(v ...interface{}) (err error) { 48 | if s.level > core.LOG_OFF && s.level <= core.LOG_ERR { 49 | s.ERR.Println(v...) 50 | } 51 | return 52 | } 53 | 54 | func (s *SimpleLogger) Errf(format string, v ...interface{}) (err error) { 55 | if s.level > core.LOG_OFF && s.level <= core.LOG_ERR { 56 | s.ERR.Printf(format, v...) 57 | } 58 | return 59 | } 60 | 61 | func (s *SimpleLogger) Debug(v ...interface{}) (err error) { 62 | if s.level > core.LOG_OFF && s.level <= core.LOG_DEBUG { 63 | s.DEBUG.Println(v...) 64 | } 65 | return 66 | } 67 | 68 | func (s *SimpleLogger) Debugf(format string, v ...interface{}) (err error) { 69 | if s.level > core.LOG_OFF && s.level >= core.LOG_DEBUG { 70 | s.DEBUG.Printf(format, v...) 71 | } 72 | return 73 | } 74 | 75 | func (s *SimpleLogger) Info(v ...interface{}) (err error) { 76 | if s.level > core.LOG_OFF && s.level >= core.LOG_INFO { 77 | s.INFO.Println(v...) 78 | } 79 | return 80 | } 81 | 82 | func (s *SimpleLogger) Infof(format string, v ...interface{}) (err error) { 83 | if s.level > core.LOG_OFF && s.level >= core.LOG_INFO { 84 | s.INFO.Printf(format, v...) 85 | } 86 | return 87 | } 88 | 89 | func (s *SimpleLogger) Warning(v ...interface{}) (err error) { 90 | if s.level > core.LOG_OFF && s.level >= core.LOG_WARNING { 91 | s.WARN.Println(v...) 92 | } 93 | return 94 | } 95 | 96 | func (s *SimpleLogger) Warningf(format string, v ...interface{}) (err error) { 97 | if s.level > core.LOG_OFF && s.level >= core.LOG_WARNING { 98 | s.WARN.Printf(format, v...) 99 | } 100 | return 101 | } 102 | 103 | func (s *SimpleLogger) Level() core.LogLevel { 104 | return s.level 105 | } 106 | 107 | func (s *SimpleLogger) SetLevel(l core.LogLevel) (err error) { 108 | s.level = l 109 | return 110 | } 111 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/memory_store.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "sync" 9 | 10 | "github.com/go-xorm/core" 11 | ) 12 | 13 | var _ core.CacheStore = NewMemoryStore() 14 | 15 | // memory store 16 | type MemoryStore struct { 17 | store map[interface{}]interface{} 18 | mutex sync.RWMutex 19 | } 20 | 21 | func NewMemoryStore() *MemoryStore { 22 | return &MemoryStore{store: make(map[interface{}]interface{})} 23 | } 24 | 25 | func (s *MemoryStore) Put(key string, value interface{}) error { 26 | s.mutex.Lock() 27 | defer s.mutex.Unlock() 28 | s.store[key] = value 29 | return nil 30 | } 31 | 32 | func (s *MemoryStore) Get(key string) (interface{}, error) { 33 | s.mutex.RLock() 34 | defer s.mutex.RUnlock() 35 | if v, ok := s.store[key]; ok { 36 | return v, nil 37 | } 38 | 39 | return nil, ErrNotExist 40 | } 41 | 42 | func (s *MemoryStore) Del(key string) error { 43 | s.mutex.Lock() 44 | defer s.mutex.Unlock() 45 | delete(s.store, key) 46 | return nil 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/mymysql_driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "errors" 9 | "strings" 10 | "time" 11 | 12 | "github.com/go-xorm/core" 13 | ) 14 | 15 | // func init() { 16 | // core.RegisterDriver("mymysql", &mymysqlDriver{}) 17 | // } 18 | 19 | type mymysqlDriver struct { 20 | } 21 | 22 | func (p *mymysqlDriver) Parse(driverName, dataSourceName string) (*core.Uri, error) { 23 | db := &core.Uri{DbType: core.MYSQL} 24 | 25 | pd := strings.SplitN(dataSourceName, "*", 2) 26 | if len(pd) == 2 { 27 | // Parse protocol part of URI 28 | p := strings.SplitN(pd[0], ":", 2) 29 | if len(p) != 2 { 30 | return nil, errors.New("Wrong protocol part of URI") 31 | } 32 | db.Proto = p[0] 33 | options := strings.Split(p[1], ",") 34 | db.Raddr = options[0] 35 | for _, o := range options[1:] { 36 | kv := strings.SplitN(o, "=", 2) 37 | var k, v string 38 | if len(kv) == 2 { 39 | k, v = kv[0], kv[1] 40 | } else { 41 | k, v = o, "true" 42 | } 43 | switch k { 44 | case "laddr": 45 | db.Laddr = v 46 | case "timeout": 47 | to, err := time.ParseDuration(v) 48 | if err != nil { 49 | return nil, err 50 | } 51 | db.Timeout = to 52 | default: 53 | return nil, errors.New("Unknown option: " + k) 54 | } 55 | } 56 | // Remove protocol part 57 | pd = pd[1:] 58 | } 59 | // Parse database part of URI 60 | dup := strings.SplitN(pd[0], "/", 3) 61 | if len(dup) != 3 { 62 | return nil, errors.New("Wrong database part of URI") 63 | } 64 | db.DbName = dup[0] 65 | db.User = dup[1] 66 | db.Passwd = dup[2] 67 | 68 | return db, nil 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/mysql_driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "regexp" 9 | "strings" 10 | 11 | "github.com/go-xorm/core" 12 | ) 13 | 14 | // func init() { 15 | // core.RegisterDriver("mysql", &mysqlDriver{}) 16 | // } 17 | 18 | type mysqlDriver struct { 19 | } 20 | 21 | func (p *mysqlDriver) Parse(driverName, dataSourceName string) (*core.Uri, error) { 22 | dsnPattern := regexp.MustCompile( 23 | `^(?:(?P.*?)(?::(?P.*))?@)?` + // [user[:password]@] 24 | `(?:(?P[^\(]*)(?:\((?P[^\)]*)\))?)?` + // [net[(addr)]] 25 | `\/(?P.*?)` + // /dbname 26 | `(?:\?(?P[^\?]*))?$`) // [?param1=value1¶mN=valueN] 27 | matches := dsnPattern.FindStringSubmatch(dataSourceName) 28 | //tlsConfigRegister := make(map[string]*tls.Config) 29 | names := dsnPattern.SubexpNames() 30 | 31 | uri := &core.Uri{DbType: core.MYSQL} 32 | 33 | for i, match := range matches { 34 | switch names[i] { 35 | case "dbname": 36 | uri.DbName = match 37 | case "params": 38 | if len(match) > 0 { 39 | kvs := strings.Split(match, "&") 40 | for _, kv := range kvs { 41 | splits := strings.Split(kv, "=") 42 | if len(splits) == 2 { 43 | switch splits[0] { 44 | case "charset": 45 | uri.Charset = splits[1] 46 | } 47 | } 48 | } 49 | } 50 | 51 | } 52 | } 53 | return uri, nil 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/oci8_driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "errors" 9 | "regexp" 10 | 11 | "github.com/go-xorm/core" 12 | ) 13 | 14 | // func init() { 15 | // core.RegisterDriver("oci8", &oci8Driver{}) 16 | // } 17 | 18 | type oci8Driver struct { 19 | } 20 | 21 | //dataSourceName=user/password@ipv4:port/dbname 22 | //dataSourceName=user/password@[ipv6]:port/dbname 23 | func (p *oci8Driver) Parse(driverName, dataSourceName string) (*core.Uri, error) { 24 | db := &core.Uri{DbType: core.ORACLE} 25 | dsnPattern := regexp.MustCompile( 26 | `^(?P.*)\/(?P.*)@` + // user:password@ 27 | `(?P.*)` + // ip:port 28 | `\/(?P.*)`) // dbname 29 | matches := dsnPattern.FindStringSubmatch(dataSourceName) 30 | names := dsnPattern.SubexpNames() 31 | for i, match := range matches { 32 | switch names[i] { 33 | case "dbname": 34 | db.DbName = match 35 | } 36 | } 37 | if db.DbName == "" { 38 | return nil, errors.New("dbname is empty") 39 | } 40 | return db, nil 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/odbc_driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "errors" 9 | "strings" 10 | 11 | "github.com/go-xorm/core" 12 | ) 13 | 14 | // func init() { 15 | // core.RegisterDriver("odbc", &odbcDriver{}) 16 | // } 17 | 18 | type odbcDriver struct { 19 | } 20 | 21 | func (p *odbcDriver) Parse(driverName, dataSourceName string) (*core.Uri, error) { 22 | kv := strings.Split(dataSourceName, ";") 23 | var dbName string 24 | 25 | for _, c := range kv { 26 | vv := strings.Split(strings.TrimSpace(c), "=") 27 | if len(vv) == 2 { 28 | switch strings.ToLower(vv[0]) { 29 | case "database": 30 | dbName = vv[1] 31 | } 32 | } 33 | } 34 | if dbName == "" { 35 | return nil, errors.New("no db name provided") 36 | } 37 | return &core.Uri{DbName: dbName, DbType: core.MSSQL}, nil 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/pq_driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "errors" 9 | "fmt" 10 | "net/url" 11 | "sort" 12 | "strings" 13 | 14 | "github.com/go-xorm/core" 15 | ) 16 | 17 | // func init() { 18 | // core.RegisterDriver("postgres", &pqDriver{}) 19 | // } 20 | 21 | type pqDriver struct { 22 | } 23 | 24 | type values map[string]string 25 | 26 | func (vs values) Set(k, v string) { 27 | vs[k] = v 28 | } 29 | 30 | func (vs values) Get(k string) (v string) { 31 | return vs[k] 32 | } 33 | 34 | func errorf(s string, args ...interface{}) { 35 | panic(fmt.Errorf("pq: %s", fmt.Sprintf(s, args...))) 36 | } 37 | 38 | func parseURL(connstr string) (string, error) { 39 | u, err := url.Parse(connstr) 40 | if err != nil { 41 | return "", err 42 | } 43 | 44 | if u.Scheme != "postgresql" && u.Scheme != "postgres" { 45 | return "", fmt.Errorf("invalid connection protocol: %s", u.Scheme) 46 | } 47 | 48 | var kvs []string 49 | escaper := strings.NewReplacer(` `, `\ `, `'`, `\'`, `\`, `\\`) 50 | accrue := func(k, v string) { 51 | if v != "" { 52 | kvs = append(kvs, k+"="+escaper.Replace(v)) 53 | } 54 | } 55 | 56 | if u.User != nil { 57 | v := u.User.Username() 58 | accrue("user", v) 59 | 60 | v, _ = u.User.Password() 61 | accrue("password", v) 62 | } 63 | 64 | i := strings.Index(u.Host, ":") 65 | if i < 0 { 66 | accrue("host", u.Host) 67 | } else { 68 | accrue("host", u.Host[:i]) 69 | accrue("port", u.Host[i+1:]) 70 | } 71 | 72 | if u.Path != "" { 73 | accrue("dbname", u.Path[1:]) 74 | } 75 | 76 | q := u.Query() 77 | for k := range q { 78 | accrue(k, q.Get(k)) 79 | } 80 | 81 | sort.Strings(kvs) // Makes testing easier (not a performance concern) 82 | return strings.Join(kvs, " "), nil 83 | } 84 | 85 | func parseOpts(name string, o values) { 86 | if len(name) == 0 { 87 | return 88 | } 89 | 90 | name = strings.TrimSpace(name) 91 | 92 | ps := strings.Split(name, " ") 93 | for _, p := range ps { 94 | kv := strings.Split(p, "=") 95 | if len(kv) < 2 { 96 | errorf("invalid option: %q", p) 97 | } 98 | o.Set(kv[0], kv[1]) 99 | } 100 | } 101 | 102 | func (p *pqDriver) Parse(driverName, dataSourceName string) (*core.Uri, error) { 103 | db := &core.Uri{DbType: core.POSTGRES} 104 | o := make(values) 105 | var err error 106 | if strings.HasPrefix(dataSourceName, "postgresql://") || strings.HasPrefix(dataSourceName, "postgres://") { 107 | dataSourceName, err = parseURL(dataSourceName) 108 | if err != nil { 109 | return nil, err 110 | } 111 | } 112 | parseOpts(dataSourceName, o) 113 | 114 | db.DbName = o.Get("dbname") 115 | if db.DbName == "" { 116 | return nil, errors.New("dbname is empty") 117 | } 118 | return db, nil 119 | } 120 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/processors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | // Executed before an object is initially persisted to the database 8 | type BeforeInsertProcessor interface { 9 | BeforeInsert() 10 | } 11 | 12 | // Executed before an object is updated 13 | type BeforeUpdateProcessor interface { 14 | BeforeUpdate() 15 | } 16 | 17 | // Executed before an object is deleted 18 | type BeforeDeleteProcessor interface { 19 | BeforeDelete() 20 | } 21 | 22 | type BeforeSetProcessor interface { 23 | BeforeSet(string, Cell) 24 | } 25 | 26 | type AfterSetProcessor interface { 27 | AfterSet(string, Cell) 28 | } 29 | 30 | // !nashtsai! TODO enable BeforeValidateProcessor when xorm start to support validations 31 | //// Executed before an object is validated 32 | //type BeforeValidateProcessor interface { 33 | // BeforeValidate() 34 | //} 35 | // -- 36 | 37 | // Executed after an object is persisted to the database 38 | type AfterInsertProcessor interface { 39 | AfterInsert() 40 | } 41 | 42 | // Executed after an object has been updated 43 | type AfterUpdateProcessor interface { 44 | AfterUpdate() 45 | } 46 | 47 | // Executed after an object has been deleted 48 | type AfterDeleteProcessor interface { 49 | AfterDelete() 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/sqlite3_driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "github.com/go-xorm/core" 9 | ) 10 | 11 | // func init() { 12 | // core.RegisterDriver("sqlite3", &sqlite3Driver{}) 13 | // } 14 | 15 | type sqlite3Driver struct { 16 | } 17 | 18 | func (p *sqlite3Driver) Parse(driverName, dataSourceName string) (*core.Uri, error) { 19 | return &core.Uri{DbType: core.SQLITE, DbName: dataSourceName}, nil 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/go-xorm/xorm/syslogger.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !windows,!nacl,!plan9 6 | 7 | package xorm 8 | 9 | import ( 10 | "fmt" 11 | "log/syslog" 12 | 13 | "github.com/go-xorm/core" 14 | ) 15 | 16 | type SyslogLogger struct { 17 | w *syslog.Writer 18 | } 19 | 20 | func NewSyslogLogger(w *syslog.Writer) *SyslogLogger { 21 | return &SyslogLogger{w: w} 22 | } 23 | 24 | func (s *SyslogLogger) Debug(v ...interface{}) (err error) { 25 | return s.w.Debug(fmt.Sprint(v...)) 26 | } 27 | 28 | func (s *SyslogLogger) Debugf(format string, v ...interface{}) (err error) { 29 | return s.w.Debug(fmt.Sprintf(format, v...)) 30 | } 31 | 32 | func (s *SyslogLogger) Err(v ...interface{}) (err error) { 33 | return s.w.Err(fmt.Sprint(v...)) 34 | } 35 | 36 | func (s *SyslogLogger) Errf(format string, v ...interface{}) (err error) { 37 | return s.w.Err(fmt.Sprintf(format, v...)) 38 | } 39 | 40 | func (s *SyslogLogger) Info(v ...interface{}) (err error) { 41 | return s.w.Info(fmt.Sprint(v...)) 42 | } 43 | 44 | func (s *SyslogLogger) Infof(format string, v ...interface{}) (err error) { 45 | return s.w.Info(fmt.Sprintf(format, v...)) 46 | } 47 | 48 | func (s *SyslogLogger) Warning(v ...interface{}) (err error) { 49 | return s.w.Warning(fmt.Sprint(v...)) 50 | } 51 | 52 | func (s *SyslogLogger) Warningf(format string, v ...interface{}) (err error) { 53 | return s.w.Warning(fmt.Sprintf(format, v...)) 54 | } 55 | 56 | func (s *SyslogLogger) Level() core.LogLevel { 57 | return core.LOG_UNKNOWN 58 | } 59 | 60 | // SetLevel always return error, as current log/syslog package doesn't allow to set priority level after syslog.Writer created 61 | func (s *SyslogLogger) SetLevel(l core.LogLevel) (err error) { 62 | return fmt.Errorf("unable to set syslog level") 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | go: 5 | - 1.3 6 | - 1.4 7 | - 1.5 8 | - tip 9 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/README.md: -------------------------------------------------------------------------------- 1 | context 2 | ======= 3 | [![Build Status](https://travis-ci.org/gorilla/context.png?branch=master)](https://travis-ci.org/gorilla/context) 4 | 5 | gorilla/context is a general purpose registry for global request variables. 6 | 7 | Read the full documentation here: http://www.gorillatoolkit.org/pkg/context 8 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package context stores values shared during a request lifetime. 7 | 8 | For example, a router can set variables extracted from the URL and later 9 | application handlers can access those values, or it can be used to store 10 | sessions values to be saved at the end of a request. There are several 11 | others common uses. 12 | 13 | The idea was posted by Brad Fitzpatrick to the go-nuts mailing list: 14 | 15 | http://groups.google.com/group/golang-nuts/msg/e2d679d303aa5d53 16 | 17 | Here's the basic usage: first define the keys that you will need. The key 18 | type is interface{} so a key can be of any type that supports equality. 19 | Here we define a key using a custom int type to avoid name collisions: 20 | 21 | package foo 22 | 23 | import ( 24 | "github.com/gorilla/context" 25 | ) 26 | 27 | type key int 28 | 29 | const MyKey key = 0 30 | 31 | Then set a variable. Variables are bound to an http.Request object, so you 32 | need a request instance to set a value: 33 | 34 | context.Set(r, MyKey, "bar") 35 | 36 | The application can later access the variable using the same key you provided: 37 | 38 | func MyHandler(w http.ResponseWriter, r *http.Request) { 39 | // val is "bar". 40 | val := context.Get(r, foo.MyKey) 41 | 42 | // returns ("bar", true) 43 | val, ok := context.GetOk(r, foo.MyKey) 44 | // ... 45 | } 46 | 47 | And that's all about the basic usage. We discuss some other ideas below. 48 | 49 | Any type can be stored in the context. To enforce a given type, make the key 50 | private and wrap Get() and Set() to accept and return values of a specific 51 | type: 52 | 53 | type key int 54 | 55 | const mykey key = 0 56 | 57 | // GetMyKey returns a value for this package from the request values. 58 | func GetMyKey(r *http.Request) SomeType { 59 | if rv := context.Get(r, mykey); rv != nil { 60 | return rv.(SomeType) 61 | } 62 | return nil 63 | } 64 | 65 | // SetMyKey sets a value for this package in the request values. 66 | func SetMyKey(r *http.Request, val SomeType) { 67 | context.Set(r, mykey, val) 68 | } 69 | 70 | Variables must be cleared at the end of a request, to remove all values 71 | that were stored. This can be done in an http.Handler, after a request was 72 | served. Just call Clear() passing the request: 73 | 74 | context.Clear(r) 75 | 76 | ...or use ClearHandler(), which conveniently wraps an http.Handler to clear 77 | variables at the end of a request lifetime. 78 | 79 | The Routers from the packages gorilla/mux and gorilla/pat call Clear() 80 | so if you are using either of them you don't need to clear the context manually. 81 | */ 82 | package context 83 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | matrix: 5 | include: 6 | - go: 1.2 7 | - go: 1.3 8 | - go: 1.4 9 | - go: 1.5 10 | - go: 1.6 11 | - go: tip 12 | 13 | install: 14 | - go get golang.org/x/tools/cmd/vet 15 | 16 | script: 17 | - go get -t -v ./... 18 | - diff -u <(echo -n) <(gofmt -d .) 19 | - go tool vet . 20 | - go test -v -race ./... 21 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/securecookie/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | go: 5 | - 1.3 6 | - 1.4 7 | - 1.5 8 | - tip 9 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/securecookie/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/securecookie/README.md: -------------------------------------------------------------------------------- 1 | securecookie 2 | ============ 3 | [![GoDoc](https://godoc.org/github.com/gorilla/securecookie?status.svg)](https://godoc.org/github.com/gorilla/securecookie) [![Build Status](https://travis-ci.org/gorilla/securecookie.png?branch=master)](https://travis-ci.org/gorilla/securecookie) 4 | 5 | securecookie encodes and decodes authenticated and optionally encrypted 6 | cookie values. 7 | 8 | Secure cookies can't be forged, because their values are validated using HMAC. 9 | When encrypted, the content is also inaccessible to malicious eyes. It is still 10 | recommended that sensitive data not be stored in cookies, and that HTTPS be used 11 | to prevent cookie [replay attacks](https://en.wikipedia.org/wiki/Replay_attack). 12 | 13 | ## Examples 14 | 15 | To use it, first create a new SecureCookie instance: 16 | 17 | ```go 18 | // Hash keys should be at least 32 bytes long 19 | var hashKey = []byte("very-secret") 20 | // Block keys should be 16 bytes (AES-128) or 32 bytes (AES-256) long. 21 | // Shorter keys may weaken the encryption used. 22 | var blockKey = []byte("a-lot-secret") 23 | var s = securecookie.New(hashKey, blockKey) 24 | ``` 25 | 26 | The hashKey is required, used to authenticate the cookie value using HMAC. 27 | It is recommended to use a key with 32 or 64 bytes. 28 | 29 | The blockKey is optional, used to encrypt the cookie value -- set it to nil 30 | to not use encryption. If set, the length must correspond to the block size 31 | of the encryption algorithm. For AES, used by default, valid lengths are 32 | 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256. 33 | 34 | Strong keys can be created using the convenience function GenerateRandomKey(). 35 | 36 | Once a SecureCookie instance is set, use it to encode a cookie value: 37 | 38 | ```go 39 | func SetCookieHandler(w http.ResponseWriter, r *http.Request) { 40 | value := map[string]string{ 41 | "foo": "bar", 42 | } 43 | if encoded, err := s.Encode("cookie-name", value); err == nil { 44 | cookie := &http.Cookie{ 45 | Name: "cookie-name", 46 | Value: encoded, 47 | Path: "/", 48 | } 49 | http.SetCookie(w, cookie) 50 | } 51 | } 52 | ``` 53 | 54 | Later, use the same SecureCookie instance to decode and validate a cookie 55 | value: 56 | 57 | ```go 58 | func ReadCookieHandler(w http.ResponseWriter, r *http.Request) { 59 | if cookie, err := r.Cookie("cookie-name"); err == nil { 60 | value := make(map[string]string) 61 | if err = s2.Decode("cookie-name", cookie.Value, &value); err == nil { 62 | fmt.Fprintf(w, "The value of foo is %q", value["foo"]) 63 | } 64 | } 65 | } 66 | ``` 67 | 68 | We stored a map[string]string, but secure cookies can hold any value that 69 | can be encoded using `encoding/gob`. To store custom types, they must be 70 | registered first using gob.Register(). For basic types this is not needed; 71 | it works out of the box. An optional JSON encoder that uses `encoding/json` is 72 | available for types compatible with JSON. 73 | 74 | ## License 75 | 76 | BSD licensed. See the LICENSE file for details. 77 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/securecookie/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package gorilla/securecookie encodes and decodes authenticated and optionally 7 | encrypted cookie values. 8 | 9 | Secure cookies can't be forged, because their values are validated using HMAC. 10 | When encrypted, the content is also inaccessible to malicious eyes. 11 | 12 | To use it, first create a new SecureCookie instance: 13 | 14 | var hashKey = []byte("very-secret") 15 | var blockKey = []byte("a-lot-secret") 16 | var s = securecookie.New(hashKey, blockKey) 17 | 18 | The hashKey is required, used to authenticate the cookie value using HMAC. 19 | It is recommended to use a key with 32 or 64 bytes. 20 | 21 | The blockKey is optional, used to encrypt the cookie value -- set it to nil 22 | to not use encryption. If set, the length must correspond to the block size 23 | of the encryption algorithm. For AES, used by default, valid lengths are 24 | 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256. 25 | 26 | Strong keys can be created using the convenience function GenerateRandomKey(). 27 | 28 | Once a SecureCookie instance is set, use it to encode a cookie value: 29 | 30 | func SetCookieHandler(w http.ResponseWriter, r *http.Request) { 31 | value := map[string]string{ 32 | "foo": "bar", 33 | } 34 | if encoded, err := s.Encode("cookie-name", value); err == nil { 35 | cookie := &http.Cookie{ 36 | Name: "cookie-name", 37 | Value: encoded, 38 | Path: "/", 39 | } 40 | http.SetCookie(w, cookie) 41 | } 42 | } 43 | 44 | Later, use the same SecureCookie instance to decode and validate a cookie 45 | value: 46 | 47 | func ReadCookieHandler(w http.ResponseWriter, r *http.Request) { 48 | if cookie, err := r.Cookie("cookie-name"); err == nil { 49 | value := make(map[string]string) 50 | if err = s2.Decode("cookie-name", cookie.Value, &value); err == nil { 51 | fmt.Fprintf(w, "The value of foo is %q", value["foo"]) 52 | } 53 | } 54 | } 55 | 56 | We stored a map[string]string, but secure cookies can hold any value that 57 | can be encoded using encoding/gob. To store custom types, they must be 58 | registered first using gob.Register(). For basic types this is not needed; 59 | it works out of the box. 60 | */ 61 | package securecookie 62 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/securecookie/fuzz.go: -------------------------------------------------------------------------------- 1 | // +build gofuzz 2 | 3 | package securecookie 4 | 5 | var hashKey = []byte("very-secret12345") 6 | var blockKey = []byte("a-lot-secret1234") 7 | var s = New(hashKey, blockKey) 8 | 9 | type Cookie struct { 10 | B bool 11 | I int 12 | S string 13 | } 14 | 15 | func Fuzz(data []byte) int { 16 | datas := string(data) 17 | var c Cookie 18 | if err := s.Decode("fuzz", datas, &c); err != nil { 19 | return 0 20 | } 21 | if _, err := s.Encode("fuzz", c); err != nil { 22 | panic(err) 23 | } 24 | return 1 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/sessions/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | go: 5 | - 1.3 6 | - 1.4 7 | - 1.5 8 | - tip 9 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/sessions/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/howeyc/gopass/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | os: 4 | - linux 5 | - osx 6 | 7 | go: 8 | - 1.3 9 | - 1.4 10 | - 1.5 11 | - tip 12 | -------------------------------------------------------------------------------- /vendor/github.com/howeyc/gopass/README.md: -------------------------------------------------------------------------------- 1 | # getpasswd in Go [![GoDoc](https://godoc.org/github.com/howeyc/gopass?status.svg)](https://godoc.org/github.com/howeyc/gopass) [![Build Status](https://secure.travis-ci.org/howeyc/gopass.png?branch=master)](http://travis-ci.org/howeyc/gopass) 2 | 3 | Retrieve password from user terminal or piped input without echo. 4 | 5 | Verified on BSD, Linux, and Windows. 6 | 7 | Example: 8 | ```go 9 | package main 10 | 11 | import "fmt" 12 | import "github.com/howeyc/gopass" 13 | 14 | func main() { 15 | fmt.Printf("Password: ") 16 | 17 | // Silent. For printing *'s use gopass.GetPasswdMasked() 18 | pass, err := gopass.GetPasswd() 19 | if err != nil { 20 | // Handle gopass.ErrInterrupted or getch() read error 21 | } 22 | 23 | // Do something with pass 24 | } 25 | ``` 26 | 27 | Caution: Multi-byte characters not supported! 28 | -------------------------------------------------------------------------------- /vendor/github.com/howeyc/gopass/pass.go: -------------------------------------------------------------------------------- 1 | package gopass 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "io" 7 | "os" 8 | 9 | "golang.org/x/crypto/ssh/terminal" 10 | ) 11 | 12 | var defaultGetCh = func() (byte, error) { 13 | buf := make([]byte, 1) 14 | if n, err := os.Stdin.Read(buf); n == 0 || err != nil { 15 | if err != nil { 16 | return 0, err 17 | } 18 | return 0, io.EOF 19 | } 20 | return buf[0], nil 21 | } 22 | 23 | var ( 24 | maxLength = 512 25 | ErrInterrupted = errors.New("interrupted") 26 | ErrMaxLengthExceeded = fmt.Errorf("maximum byte limit (%v) exceeded", maxLength) 27 | 28 | // Provide variable so that tests can provide a mock implementation. 29 | getch = defaultGetCh 30 | ) 31 | 32 | // getPasswd returns the input read from terminal. 33 | // If masked is true, typing will be matched by asterisks on the screen. 34 | // Otherwise, typing will echo nothing. 35 | func getPasswd(masked bool) ([]byte, error) { 36 | var err error 37 | var pass, bs, mask []byte 38 | if masked { 39 | bs = []byte("\b \b") 40 | mask = []byte("*") 41 | } 42 | 43 | if terminal.IsTerminal(int(os.Stdin.Fd())) { 44 | if oldState, err := terminal.MakeRaw(int(os.Stdin.Fd())); err != nil { 45 | return pass, err 46 | } else { 47 | defer terminal.Restore(int(os.Stdin.Fd()), oldState) 48 | } 49 | } 50 | 51 | // Track total bytes read, not just bytes in the password. This ensures any 52 | // errors that might flood the console with nil or -1 bytes infinitely are 53 | // capped. 54 | var counter int 55 | for counter = 0; counter <= maxLength; counter++ { 56 | if v, e := getch(); e != nil { 57 | err = e 58 | break 59 | } else if v == 127 || v == 8 { 60 | if l := len(pass); l > 0 { 61 | pass = pass[:l-1] 62 | fmt.Print(string(bs)) 63 | } 64 | } else if v == 13 || v == 10 { 65 | break 66 | } else if v == 3 { 67 | err = ErrInterrupted 68 | break 69 | } else if v != 0 { 70 | pass = append(pass, v) 71 | fmt.Print(string(mask)) 72 | } 73 | } 74 | 75 | if counter > maxLength { 76 | err = ErrMaxLengthExceeded 77 | } 78 | 79 | fmt.Println() 80 | return pass, err 81 | } 82 | 83 | // GetPasswd returns the password read from the terminal without echoing input. 84 | // The returned byte array does not include end-of-line characters. 85 | func GetPasswd() ([]byte, error) { 86 | return getPasswd(false) 87 | } 88 | 89 | // GetPasswdMasked returns the password read from the terminal, echoing asterisks. 90 | // The returned byte array does not include end-of-line characters. 91 | func GetPasswdMasked() ([]byte, error) { 92 | return getPasswd(true) 93 | } 94 | -------------------------------------------------------------------------------- /vendor/github.com/kardianos/osext/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/kardianos/osext/README.md: -------------------------------------------------------------------------------- 1 | ### Extensions to the "os" package. 2 | 3 | ## Find the current Executable and ExecutableFolder. 4 | 5 | There is sometimes utility in finding the current executable file 6 | that is running. This can be used for upgrading the current executable 7 | or finding resources located relative to the executable file. Both 8 | working directory and the os.Args[0] value are arbitrary and cannot 9 | be relied on; os.Args[0] can be "faked". 10 | 11 | Multi-platform and supports: 12 | * Linux 13 | * OS X 14 | * Windows 15 | * Plan 9 16 | * BSDs. 17 | -------------------------------------------------------------------------------- /vendor/github.com/kardianos/osext/osext.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Extensions to the standard "os" package. 6 | package osext 7 | 8 | import "path/filepath" 9 | 10 | var cx, ce = executableClean() 11 | 12 | func executableClean() (string, error) { 13 | p, err := executable() 14 | return filepath.Clean(p), err 15 | } 16 | 17 | // Executable returns an absolute path that can be used to 18 | // re-invoke the current program. 19 | // It may not be valid after the current program exits. 20 | func Executable() (string, error) { 21 | return cx, ce 22 | } 23 | 24 | // Returns same path as Executable, returns just the folder 25 | // path. Excludes the executable name and any trailing slash. 26 | func ExecutableFolder() (string, error) { 27 | p, err := Executable() 28 | if err != nil { 29 | return "", err 30 | } 31 | 32 | return filepath.Dir(p), nil 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/kardianos/osext/osext_plan9.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package osext 6 | 7 | import ( 8 | "os" 9 | "strconv" 10 | "syscall" 11 | ) 12 | 13 | func executable() (string, error) { 14 | f, err := os.Open("/proc/" + strconv.Itoa(os.Getpid()) + "/text") 15 | if err != nil { 16 | return "", err 17 | } 18 | defer f.Close() 19 | return syscall.Fd2path(int(f.Fd())) 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/kardianos/osext/osext_procfs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux netbsd solaris dragonfly 6 | 7 | package osext 8 | 9 | import ( 10 | "errors" 11 | "fmt" 12 | "os" 13 | "runtime" 14 | "strings" 15 | ) 16 | 17 | func executable() (string, error) { 18 | switch runtime.GOOS { 19 | case "linux": 20 | const deletedTag = " (deleted)" 21 | execpath, err := os.Readlink("/proc/self/exe") 22 | if err != nil { 23 | return execpath, err 24 | } 25 | execpath = strings.TrimSuffix(execpath, deletedTag) 26 | execpath = strings.TrimPrefix(execpath, deletedTag) 27 | return execpath, nil 28 | case "netbsd": 29 | return os.Readlink("/proc/curproc/exe") 30 | case "dragonfly": 31 | return os.Readlink("/proc/curproc/file") 32 | case "solaris": 33 | return os.Readlink(fmt.Sprintf("/proc/%d/path/a.out", os.Getpid())) 34 | } 35 | return "", errors.New("ExecPath not implemented for " + runtime.GOOS) 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/kardianos/osext/osext_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package osext 6 | 7 | import ( 8 | "syscall" 9 | "unicode/utf16" 10 | "unsafe" 11 | ) 12 | 13 | var ( 14 | kernel = syscall.MustLoadDLL("kernel32.dll") 15 | getModuleFileNameProc = kernel.MustFindProc("GetModuleFileNameW") 16 | ) 17 | 18 | // GetModuleFileName() with hModule = NULL 19 | func executable() (exePath string, err error) { 20 | return getModuleFileName() 21 | } 22 | 23 | func getModuleFileName() (string, error) { 24 | var n uint32 25 | b := make([]uint16, syscall.MAX_PATH) 26 | size := uint32(len(b)) 27 | 28 | r0, _, e1 := getModuleFileNameProc.Call(0, uintptr(unsafe.Pointer(&b[0])), uintptr(size)) 29 | n = uint32(r0) 30 | if n == 0 { 31 | return "", e1 32 | } 33 | return string(utf16.Decode(b[0:n])), nil 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-sqlite3/.gitignore: -------------------------------------------------------------------------------- 1 | *.db 2 | *.exe 3 | *.dll 4 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-sqlite3/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: required 3 | dist: trusty 4 | go: 5 | - 1.5 6 | - 1.6 7 | - tip 8 | before_install: 9 | - go get github.com/mattn/goveralls 10 | - go get golang.org/x/tools/cmd/cover 11 | script: 12 | - $HOME/gopath/bin/goveralls -repotoken 3qJVUE0iQwqnCbmNcDsjYu1nh4J4KIFXx 13 | - go test -v . -tags "libsqlite3" 14 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-sqlite3/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-sqlite3/README.md: -------------------------------------------------------------------------------- 1 | go-sqlite3 2 | ========== 3 | 4 | [![Build Status](https://travis-ci.org/mattn/go-sqlite3.svg?branch=master)](https://travis-ci.org/mattn/go-sqlite3) 5 | [![Coverage Status](https://coveralls.io/repos/mattn/go-sqlite3/badge.svg?branch=master)](https://coveralls.io/r/mattn/go-sqlite3?branch=master) 6 | [![GoDoc](https://godoc.org/github.com/mattn/go-sqlite3?status.svg)](http://godoc.org/github.com/mattn/go-sqlite3) 7 | 8 | Description 9 | ----------- 10 | 11 | sqlite3 driver conforming to the built-in database/sql interface 12 | 13 | Installation 14 | ------------ 15 | 16 | This package can be installed with the go get command: 17 | 18 | go get github.com/mattn/go-sqlite3 19 | 20 | _go-sqlite3_ is *cgo* package. 21 | If you want to build your app using go-sqlite3, you need gcc. 22 | However, if you install _go-sqlite3_ with `go install github.com/mattn/go-sqlite3`, you don't need gcc to build your app anymore. 23 | 24 | Documentation 25 | ------------- 26 | 27 | API documentation can be found here: http://godoc.org/github.com/mattn/go-sqlite3 28 | 29 | Examples can be found under the `./_example` directory 30 | 31 | FAQ 32 | --- 33 | 34 | * Want to build go-sqlite3 with libsqlite3 on my linux. 35 | 36 | Use `go build --tags "libsqlite3 linux"` 37 | 38 | * Want to build go-sqlite3 with libsqlite3 on OS X. 39 | 40 | Install sqlite3 from homebrew: `brew install sqlite3` 41 | 42 | Use `go build --tags "libsqlite3 darwin"` 43 | 44 | * Want to build go-sqlite3 with icu extension. 45 | 46 | Use `go build --tags "icu"` 47 | 48 | * Can't build go-sqlite3 on windows 64bit. 49 | 50 | > Probably, you are using go 1.0, go1.0 has a problem when it comes to compiling/linking on windows 64bit. 51 | > See: https://github.com/mattn/go-sqlite3/issues/27 52 | 53 | * Getting insert error while query is opened. 54 | 55 | > You can pass some arguments into the connection string, for example, a URI. 56 | > See: https://github.com/mattn/go-sqlite3/issues/39 57 | 58 | * Do you want to cross compile? mingw on Linux or Mac? 59 | 60 | > See: https://github.com/mattn/go-sqlite3/issues/106 61 | > See also: http://www.limitlessfx.com/cross-compile-golang-app-for-windows-from-linux.html 62 | 63 | * Want to get time.Time with current locale 64 | 65 | Use `loc=auto` in SQLite3 filename schema like `file:foo.db?loc=auto`. 66 | 67 | License 68 | ------- 69 | 70 | MIT: http://mattn.mit-license.org/2012 71 | 72 | sqlite3-binding.c, sqlite3-binding.h, sqlite3ext.h 73 | 74 | The -binding suffix was added to avoid build failures under gccgo. 75 | 76 | In this repository, those files are an amalgamation of code that was copied from SQLite3. The license of that code is the same as the license of SQLite3. 77 | 78 | Author 79 | ------ 80 | 81 | Yasuhiro Matsumoto (a.k.a mattn) 82 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-sqlite3/backup.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package sqlite3 7 | 8 | /* 9 | #ifndef USE_LIBSQLITE3 10 | #include 11 | #else 12 | #include 13 | #endif 14 | #include 15 | */ 16 | import "C" 17 | import ( 18 | "runtime" 19 | "unsafe" 20 | ) 21 | 22 | type SQLiteBackup struct { 23 | b *C.sqlite3_backup 24 | } 25 | 26 | func (c *SQLiteConn) Backup(dest string, conn *SQLiteConn, src string) (*SQLiteBackup, error) { 27 | destptr := C.CString(dest) 28 | defer C.free(unsafe.Pointer(destptr)) 29 | srcptr := C.CString(src) 30 | defer C.free(unsafe.Pointer(srcptr)) 31 | 32 | if b := C.sqlite3_backup_init(c.db, destptr, conn.db, srcptr); b != nil { 33 | bb := &SQLiteBackup{b: b} 34 | runtime.SetFinalizer(bb, (*SQLiteBackup).Finish) 35 | return bb, nil 36 | } 37 | return nil, c.lastError() 38 | } 39 | 40 | // Backs up for one step. Calls the underlying `sqlite3_backup_step` function. 41 | // This function returns a boolean indicating if the backup is done and 42 | // an error signalling any other error. Done is returned if the underlying C 43 | // function returns SQLITE_DONE (Code 101) 44 | func (b *SQLiteBackup) Step(p int) (bool, error) { 45 | ret := C.sqlite3_backup_step(b.b, C.int(p)) 46 | if ret == C.SQLITE_DONE { 47 | return true, nil 48 | } else if ret != 0 && ret != C.SQLITE_LOCKED && ret != C.SQLITE_BUSY { 49 | return false, Error{Code: ErrNo(ret)} 50 | } 51 | return false, nil 52 | } 53 | 54 | func (b *SQLiteBackup) Remaining() int { 55 | return int(C.sqlite3_backup_remaining(b.b)) 56 | } 57 | 58 | func (b *SQLiteBackup) PageCount() int { 59 | return int(C.sqlite3_backup_pagecount(b.b)) 60 | } 61 | 62 | func (b *SQLiteBackup) Finish() error { 63 | return b.Close() 64 | } 65 | 66 | func (b *SQLiteBackup) Close() error { 67 | ret := C.sqlite3_backup_finish(b.b) 68 | if ret != 0 { 69 | return Error{Code: ErrNo(ret)} 70 | } 71 | b.b = nil 72 | runtime.SetFinalizer(b, nil) 73 | return nil 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-sqlite3/sqlite3_fts5.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | // +build fts5 6 | 7 | package sqlite3 8 | 9 | /* 10 | #cgo CFLAGS: -DSQLITE_ENABLE_FTS5 11 | #cgo LDFLAGS: -lm 12 | */ 13 | import "C" 14 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-sqlite3/sqlite3_icu.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | // +build icu 6 | 7 | package sqlite3 8 | 9 | /* 10 | #cgo LDFLAGS: -licuuc -licui18n 11 | #cgo CFLAGS: -DSQLITE_ENABLE_ICU 12 | */ 13 | import "C" 14 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-sqlite3/sqlite3_json1.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | // +build json1 6 | 7 | package sqlite3 8 | 9 | /* 10 | #cgo CFLAGS: -DSQLITE_ENABLE_JSON1 11 | */ 12 | import "C" 13 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-sqlite3/sqlite3_libsqlite3.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | // +build libsqlite3 6 | 7 | package sqlite3 8 | 9 | /* 10 | #cgo CFLAGS: -DUSE_LIBSQLITE3 11 | #cgo linux LDFLAGS: -lsqlite3 12 | #cgo darwin LDFLAGS: -L/usr/local/opt/sqlite/lib -lsqlite3 13 | */ 14 | import "C" 15 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-sqlite3/sqlite3_load_extension.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | // +build !sqlite_omit_load_extension 6 | 7 | package sqlite3 8 | 9 | /* 10 | #include 11 | #include 12 | */ 13 | import "C" 14 | import ( 15 | "errors" 16 | "unsafe" 17 | ) 18 | 19 | func (c *SQLiteConn) loadExtensions(extensions []string) error { 20 | rv := C.sqlite3_enable_load_extension(c.db, 1) 21 | if rv != C.SQLITE_OK { 22 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db))) 23 | } 24 | 25 | for _, extension := range extensions { 26 | cext := C.CString(extension) 27 | defer C.free(unsafe.Pointer(cext)) 28 | rv = C.sqlite3_load_extension(c.db, cext, nil, nil) 29 | if rv != C.SQLITE_OK { 30 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db))) 31 | } 32 | } 33 | 34 | rv = C.sqlite3_enable_load_extension(c.db, 0) 35 | if rv != C.SQLITE_OK { 36 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db))) 37 | } 38 | return nil 39 | } 40 | 41 | func (c *SQLiteConn) LoadExtension(lib string, entry string) error { 42 | rv := C.sqlite3_enable_load_extension(c.db, 1) 43 | if rv != C.SQLITE_OK { 44 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db))) 45 | } 46 | 47 | clib := C.CString(lib) 48 | defer C.free(unsafe.Pointer(clib)) 49 | centry := C.CString(entry) 50 | defer C.free(unsafe.Pointer(centry)) 51 | 52 | rv = C.sqlite3_load_extension(c.db, clib, centry, nil) 53 | if rv != C.SQLITE_OK { 54 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db))) 55 | } 56 | 57 | rv = C.sqlite3_enable_load_extension(c.db, 0) 58 | if rv != C.SQLITE_OK { 59 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db))) 60 | } 61 | 62 | return nil 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-sqlite3/sqlite3_omit_load_extension.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | // +build sqlite_omit_load_extension 6 | 7 | package sqlite3 8 | 9 | /* 10 | #cgo CFLAGS: -DSQLITE_OMIT_LOAD_EXTENSION 11 | */ 12 | import "C" 13 | import ( 14 | "errors" 15 | ) 16 | 17 | func (c *SQLiteConn) loadExtensions(extensions []string) error { 18 | return errors.New("Extensions have been disabled for static builds") 19 | } 20 | 21 | func (c *SQLiteConn) LoadExtension(lib string, entry string) error { 22 | return errors.New("Extensions have been disabled for static builds") 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-sqlite3/sqlite3_other.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | // +build !windows 6 | 7 | package sqlite3 8 | 9 | /* 10 | #cgo CFLAGS: -I. 11 | #cgo linux LDFLAGS: -ldl 12 | */ 13 | import "C" 14 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-sqlite3/sqlite3_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | // +build windows 6 | 7 | package sqlite3 8 | 9 | /* 10 | #cgo CFLAGS: -I. -fno-stack-check -fno-stack-protector -mno-stack-arg-probe 11 | #cgo windows,386 CFLAGS: -D_USE_32BIT_TIME_T 12 | #cgo LDFLAGS: -lmingwex -lmingw32 13 | */ 14 | import "C" 15 | -------------------------------------------------------------------------------- /vendor/github.com/mephux/gotalk/js/.gitignore: -------------------------------------------------------------------------------- 1 | .*.js -------------------------------------------------------------------------------- /vendor/github.com/mephux/gotalk/request.go: -------------------------------------------------------------------------------- 1 | package gotalk 2 | 3 | type Request struct { 4 | MsgType 5 | Op string 6 | Data []byte 7 | } 8 | 9 | // Creates a new single request 10 | func NewRequest(op string, buf []byte) *Request { 11 | return &Request{MsgTypeSingleReq, op, buf} 12 | } 13 | 14 | type StreamRequest struct { 15 | sock *Sock 16 | op string 17 | id string 18 | started bool // request started? 19 | } 20 | 21 | func (r *StreamRequest) Write(b []byte) error { 22 | if r.started == false { 23 | r.started = true 24 | if err := r.sock.writeMsg(MsgTypeStreamReq, r.id, r.op, 0, b); err != nil { 25 | r.finalize() 26 | return err 27 | } 28 | } else { 29 | if err := r.sock.writeMsg(MsgTypeStreamReqPart, r.id, "", 0, b); err != nil { 30 | r.finalize() 31 | return err 32 | } 33 | } 34 | return nil 35 | } 36 | 37 | func (r *StreamRequest) End() error { 38 | err := r.sock.writeMsg(MsgTypeStreamReqPart, r.id, "", 0, nil) 39 | if err != nil { 40 | r.finalize() 41 | } 42 | return err 43 | } 44 | 45 | func (r *StreamRequest) finalize() { 46 | if r.id != "" { 47 | r.sock.deallocResChan(r.id) 48 | r.id = "" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/mephux/gotalk/response.go: -------------------------------------------------------------------------------- 1 | package gotalk 2 | import "time" 3 | 4 | type Response struct { 5 | MsgType 6 | Data []byte 7 | Wait time.Duration // only valid when IsRetry()==true 8 | } 9 | 10 | // Returns a string describing the error, when IsError()==true 11 | func (r *Response) Error() string { 12 | return string(r.Data) 13 | } 14 | 15 | // True if this response is a requestor error (ErrorResult) 16 | func (r *Response) IsError() bool { 17 | return r.MsgType == MsgTypeErrorRes 18 | } 19 | 20 | // True if response is a "server can't handle it right now, please retry" (RetryResult) 21 | func (r *Response) IsRetry() bool { 22 | return r.MsgType == MsgTypeRetryRes 23 | } 24 | 25 | // True if this is part of a streaming response (StreamResult) 26 | func (r *Response) IsStreaming() bool { 27 | return r.MsgType == MsgTypeStreamRes 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/nu7hatch/gouuid/.gitignore: -------------------------------------------------------------------------------- 1 | _obj 2 | _test 3 | *.6 4 | *.out 5 | _testmain.go 6 | \#* 7 | .\#* 8 | *.log 9 | _cgo* 10 | *.o 11 | *.a 12 | -------------------------------------------------------------------------------- /vendor/github.com/nu7hatch/gouuid/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011 by Krzysztof Kowalik 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. -------------------------------------------------------------------------------- /vendor/github.com/nu7hatch/gouuid/README.md: -------------------------------------------------------------------------------- 1 | # Pure Go UUID implementation 2 | 3 | This package provides immutable UUID structs and the functions 4 | NewV3, NewV4, NewV5 and Parse() for generating versions 3, 4 5 | and 5 UUIDs as specified in [RFC 4122](http://www.ietf.org/rfc/rfc4122.txt). 6 | 7 | ## Installation 8 | 9 | Use the `go` tool: 10 | 11 | $ go get github.com/nu7hatch/gouuid 12 | 13 | ## Usage 14 | 15 | See [documentation and examples](http://godoc.org/github.com/nu7hatch/gouuid) 16 | for more information. 17 | 18 | ## Copyright 19 | 20 | Copyright (C) 2011 by Krzysztof Kowalik . See [COPYING](https://github.com/nu7hatch/gouuid/tree/master/COPYING) 21 | file for details. 22 | -------------------------------------------------------------------------------- /vendor/github.com/sevlyar/go-daemon/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 1.1 4 | -------------------------------------------------------------------------------- /vendor/github.com/sevlyar/go-daemon/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 Sergey Yarmonov 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /vendor/github.com/sevlyar/go-daemon/README.md: -------------------------------------------------------------------------------- 1 | # go-daemon [![Build Status](https://travis-ci.org/sevlyar/go-daemon.png?branch=master)](https://travis-ci.org/sevlyar/go-daemon) [![GoDoc](https://godoc.org/github.com/sevlyar/go-daemon?status.png)](https://godoc.org/github.com/sevlyar/go-daemon) 2 | 3 | Library for writing system daemons in golang. 4 | 5 | ## Installation 6 | 7 | go get github.com/sevlyar/go-daemon 8 | 9 | ## Idea 10 | 11 | ```go 12 | func main() { 13 | Pre() 14 | 15 | context := new(Context) 16 | child, _ := context.Reborn() 17 | 18 | if child != nil { 19 | PostParent() 20 | } else { 21 | defer context.Release() 22 | PostChild() 23 | } 24 | } 25 | ``` 26 | 27 | ![](img/idea.png) 28 | 29 | ## History 30 | 31 | ### 14.01.12 32 | * released new major version, old version moved to github.com/sevlyar/go-daemon/oldapi 33 | 34 | -------------------------------------------------------------------------------- /vendor/github.com/sevlyar/go-daemon/command.go: -------------------------------------------------------------------------------- 1 | package daemon 2 | 3 | import ( 4 | "os" 5 | ) 6 | 7 | // AddCommand is wrapper on AddFlag and SetSigHandler functions. 8 | func AddCommand(f Flag, sig os.Signal, handler SignalHandlerFunc) { 9 | if f != nil { 10 | AddFlag(f, sig) 11 | } 12 | if handler != nil { 13 | SetSigHandler(handler, sig) 14 | } 15 | } 16 | 17 | // Flag is the interface implemented by an object that has two state: 18 | // 'set' and 'unset'. 19 | type Flag interface { 20 | IsSet() bool 21 | } 22 | 23 | // BoolFlag returns new object that implements interface Flag and 24 | // has state 'set' when var with the given address is true. 25 | func BoolFlag(f *bool) Flag { 26 | return &boolFlag{f} 27 | } 28 | 29 | // StringFlag returns new object that implements interface Flag and 30 | // has state 'set' when var with the given address equals given value of v. 31 | func StringFlag(f *string, v string) Flag { 32 | return &stringFlag{f, v} 33 | } 34 | 35 | type boolFlag struct { 36 | b *bool 37 | } 38 | 39 | func (f *boolFlag) IsSet() bool { 40 | if f == nil { 41 | return false 42 | } 43 | return *f.b 44 | } 45 | 46 | type stringFlag struct { 47 | s *string 48 | v string 49 | } 50 | 51 | func (f *stringFlag) IsSet() bool { 52 | if f == nil { 53 | return false 54 | } 55 | return *f.s == f.v 56 | } 57 | 58 | var flags = make(map[Flag]os.Signal) 59 | 60 | // Flags returns flags that was added by the function AddFlag. 61 | func Flags() map[Flag]os.Signal { 62 | return flags 63 | } 64 | 65 | // AddFlag adds the flag and signal to the internal map. 66 | func AddFlag(f Flag, sig os.Signal) { 67 | flags[f] = sig 68 | } 69 | 70 | // SendCommands sends active signals to the given process. 71 | func SendCommands(p *os.Process) (err error) { 72 | for _, sig := range signals() { 73 | if err = p.Signal(sig); err != nil { 74 | return 75 | } 76 | } 77 | return 78 | } 79 | 80 | // ActiveFlags returns flags that has the state 'set'. 81 | func ActiveFlags() (ret []Flag) { 82 | ret = make([]Flag, 0, 1) 83 | for f := range flags { 84 | if f.IsSet() { 85 | ret = append(ret, f) 86 | } 87 | } 88 | return 89 | } 90 | 91 | func signals() (ret []os.Signal) { 92 | ret = make([]os.Signal, 0, 1) 93 | for f, sig := range flags { 94 | if f.IsSet() { 95 | ret = append(ret, sig) 96 | } 97 | } 98 | return 99 | } 100 | -------------------------------------------------------------------------------- /vendor/github.com/sevlyar/go-daemon/signal.go: -------------------------------------------------------------------------------- 1 | package daemon 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "os/signal" 7 | "syscall" 8 | ) 9 | 10 | // ErrStop should be returned signal handler function 11 | // for termination of handling signals. 12 | var ErrStop = errors.New("stop serve signals") 13 | 14 | // SignalHandlerFunc is the interface for signal handler functions. 15 | type SignalHandlerFunc func(sig os.Signal) (err error) 16 | 17 | // func SetSigHandler sets handler for the given signals. 18 | // SIGTERM has the default handler, he returns ErrStop. 19 | func SetSigHandler(handler SignalHandlerFunc, signals ...os.Signal) { 20 | for _, sig := range signals { 21 | handlers[sig] = handler 22 | } 23 | } 24 | 25 | // func ServeSignals calls handlers for system signals. 26 | func ServeSignals() (err error) { 27 | signals := make([]os.Signal, 0, len(handlers)) 28 | for sig, _ := range handlers { 29 | signals = append(signals, sig) 30 | } 31 | 32 | ch := make(chan os.Signal, 8) 33 | signal.Notify(ch, signals...) 34 | 35 | for sig := range ch { 36 | err = handlers[sig](sig) 37 | if err != nil { 38 | break 39 | } 40 | } 41 | 42 | signal.Stop(ch) 43 | 44 | if err == ErrStop { 45 | err = nil 46 | } 47 | 48 | return 49 | } 50 | 51 | var handlers = make(map[os.Signal]SignalHandlerFunc) 52 | 53 | func init() { 54 | handlers[syscall.SIGTERM] = sigtermDefaultHandler 55 | } 56 | 57 | func sigtermDefaultHandler(sig os.Signal) error { 58 | return ErrStop 59 | } 60 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd netbsd openbsd 6 | 7 | package terminal 8 | 9 | import "syscall" 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | const ioctlWriteTermios = syscall.TIOCSETA 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package terminal 6 | 7 | // These constants are declared here, rather than importing 8 | // them from the syscall package as some syscall packages, even 9 | // on linux, for example gccgo, do not declare them. 10 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 11 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_plan9.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package terminal provides support functions for dealing with terminals, as 6 | // commonly found on UNIX systems. 7 | // 8 | // Putting a terminal into raw mode is the most common requirement: 9 | // 10 | // oldState, err := terminal.MakeRaw(0) 11 | // if err != nil { 12 | // panic(err) 13 | // } 14 | // defer terminal.Restore(0, oldState) 15 | package terminal 16 | 17 | import ( 18 | "fmt" 19 | "runtime" 20 | ) 21 | 22 | type State struct{} 23 | 24 | // IsTerminal returns true if the given file descriptor is a terminal. 25 | func IsTerminal(fd int) bool { 26 | return false 27 | } 28 | 29 | // MakeRaw put the terminal connected to the given file descriptor into raw 30 | // mode and returns the previous state of the terminal so that it can be 31 | // restored. 32 | func MakeRaw(fd int) (*State, error) { 33 | return nil, fmt.Errorf("terminal: MakeRaw not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 34 | } 35 | 36 | // GetState returns the current state of a terminal which may be useful to 37 | // restore the terminal after a signal. 38 | func GetState(fd int) (*State, error) { 39 | return nil, fmt.Errorf("terminal: GetState not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 40 | } 41 | 42 | // Restore restores the terminal connected to the given file descriptor to a 43 | // previous state. 44 | func Restore(fd int, state *State) error { 45 | return fmt.Errorf("terminal: Restore not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 46 | } 47 | 48 | // GetSize returns the dimensions of the given terminal. 49 | func GetSize(fd int) (width, height int, err error) { 50 | return 0, 0, fmt.Errorf("terminal: GetSize not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 51 | } 52 | 53 | // ReadPassword reads a line of input from a terminal without local echo. This 54 | // is commonly used for inputting passwords and other sensitive data. The slice 55 | // returned does not include the \n. 56 | func ReadPassword(fd int) ([]byte, error) { 57 | return nil, fmt.Errorf("terminal: ReadPassword not implemented on %s/%s", runtime.GOOS, runtime.GOARCH) 58 | } 59 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/websocket/client.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package websocket 6 | 7 | import ( 8 | "bufio" 9 | "crypto/tls" 10 | "io" 11 | "net" 12 | "net/http" 13 | "net/url" 14 | ) 15 | 16 | // DialError is an error that occurs while dialling a websocket server. 17 | type DialError struct { 18 | *Config 19 | Err error 20 | } 21 | 22 | func (e *DialError) Error() string { 23 | return "websocket.Dial " + e.Config.Location.String() + ": " + e.Err.Error() 24 | } 25 | 26 | // NewConfig creates a new WebSocket config for client connection. 27 | func NewConfig(server, origin string) (config *Config, err error) { 28 | config = new(Config) 29 | config.Version = ProtocolVersionHybi13 30 | config.Location, err = url.ParseRequestURI(server) 31 | if err != nil { 32 | return 33 | } 34 | config.Origin, err = url.ParseRequestURI(origin) 35 | if err != nil { 36 | return 37 | } 38 | config.Header = http.Header(make(map[string][]string)) 39 | return 40 | } 41 | 42 | // NewClient creates a new WebSocket client connection over rwc. 43 | func NewClient(config *Config, rwc io.ReadWriteCloser) (ws *Conn, err error) { 44 | br := bufio.NewReader(rwc) 45 | bw := bufio.NewWriter(rwc) 46 | err = hybiClientHandshake(config, br, bw) 47 | if err != nil { 48 | return 49 | } 50 | buf := bufio.NewReadWriter(br, bw) 51 | ws = newHybiClientConn(config, buf, rwc) 52 | return 53 | } 54 | 55 | // Dial opens a new client connection to a WebSocket. 56 | func Dial(url_, protocol, origin string) (ws *Conn, err error) { 57 | config, err := NewConfig(url_, origin) 58 | if err != nil { 59 | return nil, err 60 | } 61 | if protocol != "" { 62 | config.Protocol = []string{protocol} 63 | } 64 | return DialConfig(config) 65 | } 66 | 67 | var portMap = map[string]string{ 68 | "ws": "80", 69 | "wss": "443", 70 | } 71 | 72 | func parseAuthority(location *url.URL) string { 73 | if _, ok := portMap[location.Scheme]; ok { 74 | if _, _, err := net.SplitHostPort(location.Host); err != nil { 75 | return net.JoinHostPort(location.Host, portMap[location.Scheme]) 76 | } 77 | } 78 | return location.Host 79 | } 80 | 81 | // DialConfig opens a new client connection to a WebSocket with a config. 82 | func DialConfig(config *Config) (ws *Conn, err error) { 83 | var client net.Conn 84 | if config.Location == nil { 85 | return nil, &DialError{config, ErrBadWebSocketLocation} 86 | } 87 | if config.Origin == nil { 88 | return nil, &DialError{config, ErrBadWebSocketOrigin} 89 | } 90 | switch config.Location.Scheme { 91 | case "ws": 92 | client, err = net.Dial("tcp", parseAuthority(config.Location)) 93 | 94 | case "wss": 95 | client, err = tls.Dial("tcp", parseAuthority(config.Location), config.TlsConfig) 96 | 97 | default: 98 | err = ErrBadScheme 99 | } 100 | if err != nil { 101 | goto Error 102 | } 103 | 104 | ws, err = NewClient(config, client) 105 | if err != nil { 106 | client.Close() 107 | goto Error 108 | } 109 | return 110 | 111 | Error: 112 | return nil, &DialError{config, err} 113 | } 114 | -------------------------------------------------------------------------------- /vendor/gopkg.in/alecthomas/kingpin.v2/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | install: go get -t -v ./... 4 | go: 1.2 5 | -------------------------------------------------------------------------------- /vendor/gopkg.in/alecthomas/kingpin.v2/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 Alec Thomas 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/gopkg.in/alecthomas/kingpin.v2/actions.go: -------------------------------------------------------------------------------- 1 | package kingpin 2 | 3 | // Action callback executed at various stages after all values are populated. 4 | // The application, commands, arguments and flags all have corresponding 5 | // actions. 6 | type Action func(*ParseContext) error 7 | 8 | type actionMixin struct { 9 | actions []Action 10 | preActions []Action 11 | } 12 | 13 | type actionApplier interface { 14 | applyActions(*ParseContext) error 15 | applyPreActions(*ParseContext) error 16 | } 17 | 18 | func (a *actionMixin) addAction(action Action) { 19 | a.actions = append(a.actions, action) 20 | } 21 | 22 | func (a *actionMixin) addPreAction(action Action) { 23 | a.preActions = append(a.preActions, action) 24 | } 25 | 26 | func (a *actionMixin) applyActions(context *ParseContext) error { 27 | for _, action := range a.actions { 28 | if err := action(context); err != nil { 29 | return err 30 | } 31 | } 32 | return nil 33 | } 34 | 35 | func (a *actionMixin) applyPreActions(context *ParseContext) error { 36 | for _, preAction := range a.preActions { 37 | if err := preAction(context); err != nil { 38 | return err 39 | } 40 | } 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /vendor/gopkg.in/alecthomas/kingpin.v2/args.go: -------------------------------------------------------------------------------- 1 | package kingpin 2 | 3 | import "fmt" 4 | 5 | type argGroup struct { 6 | args []*ArgClause 7 | } 8 | 9 | func newArgGroup() *argGroup { 10 | return &argGroup{} 11 | } 12 | 13 | func (a *argGroup) have() bool { 14 | return len(a.args) > 0 15 | } 16 | 17 | // GetArg gets an argument definition. 18 | // 19 | // This allows existing arguments to be modified after definition but before parsing. Useful for 20 | // modular applications. 21 | func (a *argGroup) GetArg(name string) *ArgClause { 22 | for _, arg := range a.args { 23 | if arg.name == name { 24 | return arg 25 | } 26 | } 27 | return nil 28 | } 29 | 30 | func (a *argGroup) Arg(name, help string) *ArgClause { 31 | arg := newArg(name, help) 32 | a.args = append(a.args, arg) 33 | return arg 34 | } 35 | 36 | func (a *argGroup) init() error { 37 | required := 0 38 | seen := map[string]struct{}{} 39 | previousArgMustBeLast := false 40 | for i, arg := range a.args { 41 | if previousArgMustBeLast { 42 | return fmt.Errorf("Args() can't be followed by another argument '%s'", arg.name) 43 | } 44 | if arg.consumesRemainder() { 45 | previousArgMustBeLast = true 46 | } 47 | if _, ok := seen[arg.name]; ok { 48 | return fmt.Errorf("duplicate argument '%s'", arg.name) 49 | } 50 | seen[arg.name] = struct{}{} 51 | if arg.required && required != i { 52 | return fmt.Errorf("required arguments found after non-required") 53 | } 54 | if arg.required { 55 | required++ 56 | } 57 | if err := arg.init(); err != nil { 58 | return err 59 | } 60 | } 61 | return nil 62 | } 63 | 64 | type ArgClause struct { 65 | actionMixin 66 | parserMixin 67 | name string 68 | help string 69 | defaultValues []string 70 | required bool 71 | } 72 | 73 | func newArg(name, help string) *ArgClause { 74 | a := &ArgClause{ 75 | name: name, 76 | help: help, 77 | } 78 | return a 79 | } 80 | 81 | func (a *ArgClause) consumesRemainder() bool { 82 | if r, ok := a.value.(remainderArg); ok { 83 | return r.IsCumulative() 84 | } 85 | return false 86 | } 87 | 88 | // Required arguments must be input by the user. They can not have a Default() value provided. 89 | func (a *ArgClause) Required() *ArgClause { 90 | a.required = true 91 | return a 92 | } 93 | 94 | // Default values for this argument. They *must* be parseable by the value of the argument. 95 | func (a *ArgClause) Default(values ...string) *ArgClause { 96 | a.defaultValues = values 97 | return a 98 | } 99 | 100 | func (a *ArgClause) Action(action Action) *ArgClause { 101 | a.addAction(action) 102 | return a 103 | } 104 | 105 | func (a *ArgClause) PreAction(action Action) *ArgClause { 106 | a.addPreAction(action) 107 | return a 108 | } 109 | 110 | func (a *ArgClause) init() error { 111 | if a.required && len(a.defaultValues) > 0 { 112 | return fmt.Errorf("required argument '%s' with unusable default value", a.name) 113 | } 114 | if a.value == nil { 115 | return fmt.Errorf("no parser defined for arg '%s'", a.name) 116 | } 117 | return nil 118 | } 119 | -------------------------------------------------------------------------------- /vendor/gopkg.in/alecthomas/kingpin.v2/completions.go: -------------------------------------------------------------------------------- 1 | package kingpin 2 | 3 | // HintAction is a function type who is expected to return a slice of possible 4 | // command line arguments. 5 | type HintAction func() []string 6 | type completionsMixin struct { 7 | hintActions []HintAction 8 | builtinHintActions []HintAction 9 | } 10 | 11 | func (a *completionsMixin) addHintAction(action HintAction) { 12 | a.hintActions = append(a.hintActions, action) 13 | } 14 | 15 | // Allow adding of HintActions which are added internally, ie, EnumVar 16 | func (a *completionsMixin) addHintActionBuiltin(action HintAction) { 17 | a.builtinHintActions = append(a.builtinHintActions, action) 18 | } 19 | 20 | func (a *completionsMixin) resolveCompletions() []string { 21 | var hints []string 22 | 23 | options := a.builtinHintActions 24 | if len(a.hintActions) > 0 { 25 | // User specified their own hintActions. Use those instead. 26 | options = a.hintActions 27 | } 28 | 29 | for _, hintAction := range options { 30 | hints = append(hints, hintAction()...) 31 | } 32 | return hints 33 | } 34 | -------------------------------------------------------------------------------- /vendor/gopkg.in/alecthomas/kingpin.v2/doc.go: -------------------------------------------------------------------------------- 1 | // Package kingpin provides command line interfaces like this: 2 | // 3 | // $ chat 4 | // usage: chat [] [] [ ...] 5 | // 6 | // Flags: 7 | // --debug enable debug mode 8 | // --help Show help. 9 | // --server=127.0.0.1 server address 10 | // 11 | // Commands: 12 | // help 13 | // Show help for a command. 14 | // 15 | // post [] 16 | // Post a message to a channel. 17 | // 18 | // register 19 | // Register a new user. 20 | // 21 | // $ chat help post 22 | // usage: chat [] post [] [] 23 | // 24 | // Post a message to a channel. 25 | // 26 | // Flags: 27 | // --image=IMAGE image to post 28 | // 29 | // Args: 30 | // channel to post to 31 | // [] text to post 32 | // $ chat post --image=~/Downloads/owls.jpg pics 33 | // 34 | // From code like this: 35 | // 36 | // package main 37 | // 38 | // import "gopkg.in/alecthomas/kingpin.v1" 39 | // 40 | // var ( 41 | // debug = kingpin.Flag("debug", "enable debug mode").Default("false").Bool() 42 | // serverIP = kingpin.Flag("server", "server address").Default("127.0.0.1").IP() 43 | // 44 | // register = kingpin.Command("register", "Register a new user.") 45 | // registerNick = register.Arg("nick", "nickname for user").Required().String() 46 | // registerName = register.Arg("name", "name of user").Required().String() 47 | // 48 | // post = kingpin.Command("post", "Post a message to a channel.") 49 | // postImage = post.Flag("image", "image to post").ExistingFile() 50 | // postChannel = post.Arg("channel", "channel to post to").Required().String() 51 | // postText = post.Arg("text", "text to post").String() 52 | // ) 53 | // 54 | // func main() { 55 | // switch kingpin.Parse() { 56 | // // Register user 57 | // case "register": 58 | // println(*registerNick) 59 | // 60 | // // Post message 61 | // case "post": 62 | // if *postImage != nil { 63 | // } 64 | // if *postText != "" { 65 | // } 66 | // } 67 | // } 68 | package kingpin 69 | -------------------------------------------------------------------------------- /vendor/gopkg.in/alecthomas/kingpin.v2/global.go: -------------------------------------------------------------------------------- 1 | package kingpin 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | ) 7 | 8 | var ( 9 | // CommandLine is the default Kingpin parser. 10 | CommandLine = New(filepath.Base(os.Args[0]), "") 11 | // Global help flag. Exposed for user customisation. 12 | HelpFlag = CommandLine.HelpFlag 13 | // Top-level help command. Exposed for user customisation. May be nil. 14 | HelpCommand = CommandLine.HelpCommand 15 | // Global version flag. Exposed for user customisation. May be nil. 16 | VersionFlag = CommandLine.VersionFlag 17 | ) 18 | 19 | // Command adds a new command to the default parser. 20 | func Command(name, help string) *CmdClause { 21 | return CommandLine.Command(name, help) 22 | } 23 | 24 | // Flag adds a new flag to the default parser. 25 | func Flag(name, help string) *FlagClause { 26 | return CommandLine.Flag(name, help) 27 | } 28 | 29 | // Arg adds a new argument to the top-level of the default parser. 30 | func Arg(name, help string) *ArgClause { 31 | return CommandLine.Arg(name, help) 32 | } 33 | 34 | // Parse and return the selected command. Will call the termination handler if 35 | // an error is encountered. 36 | func Parse() string { 37 | selected := MustParse(CommandLine.Parse(os.Args[1:])) 38 | if selected == "" && CommandLine.cmdGroup.have() { 39 | Usage() 40 | CommandLine.terminate(0) 41 | } 42 | return selected 43 | } 44 | 45 | // Errorf prints an error message to stderr. 46 | func Errorf(format string, args ...interface{}) { 47 | CommandLine.Errorf(format, args...) 48 | } 49 | 50 | // Fatalf prints an error message to stderr and exits. 51 | func Fatalf(format string, args ...interface{}) { 52 | CommandLine.Fatalf(format, args...) 53 | } 54 | 55 | // FatalIfError prints an error and exits if err is not nil. The error is printed 56 | // with the given prefix. 57 | func FatalIfError(err error, format string, args ...interface{}) { 58 | CommandLine.FatalIfError(err, format, args...) 59 | } 60 | 61 | // FatalUsage prints an error message followed by usage information, then 62 | // exits with a non-zero status. 63 | func FatalUsage(format string, args ...interface{}) { 64 | CommandLine.FatalUsage(format, args...) 65 | } 66 | 67 | // FatalUsageContext writes a printf formatted error message to stderr, then 68 | // usage information for the given ParseContext, before exiting. 69 | func FatalUsageContext(context *ParseContext, format string, args ...interface{}) { 70 | CommandLine.FatalUsageContext(context, format, args...) 71 | } 72 | 73 | // Usage prints usage to stderr. 74 | func Usage() { 75 | CommandLine.Usage(os.Args[1:]) 76 | } 77 | 78 | // Set global usage template to use (defaults to DefaultUsageTemplate). 79 | func UsageTemplate(template string) *Application { 80 | return CommandLine.UsageTemplate(template) 81 | } 82 | 83 | // MustParse can be used with app.Parse(args) to exit with an error if parsing fails. 84 | func MustParse(command string, err error) string { 85 | if err != nil { 86 | Fatalf("%s, try --help", err) 87 | } 88 | return command 89 | } 90 | 91 | // Version adds a flag for displaying the application version number. 92 | func Version(version string) *Application { 93 | return CommandLine.Version(version) 94 | } 95 | -------------------------------------------------------------------------------- /vendor/gopkg.in/alecthomas/kingpin.v2/guesswidth.go: -------------------------------------------------------------------------------- 1 | // +build appengine !linux,!freebsd,!darwin,!dragonfly,!netbsd,!openbsd 2 | 3 | package kingpin 4 | 5 | import "io" 6 | 7 | func guessWidth(w io.Writer) int { 8 | return 80 9 | } 10 | -------------------------------------------------------------------------------- /vendor/gopkg.in/alecthomas/kingpin.v2/guesswidth_unix.go: -------------------------------------------------------------------------------- 1 | // +build !appengine,linux freebsd darwin dragonfly netbsd openbsd 2 | 3 | package kingpin 4 | 5 | import ( 6 | "io" 7 | "os" 8 | "strconv" 9 | "syscall" 10 | "unsafe" 11 | ) 12 | 13 | func guessWidth(w io.Writer) int { 14 | // check if COLUMNS env is set to comply with 15 | // http://pubs.opengroup.org/onlinepubs/009604499/basedefs/xbd_chap08.html 16 | colsStr := os.Getenv("COLUMNS") 17 | if colsStr != "" { 18 | if cols, err := strconv.Atoi(colsStr); err == nil { 19 | return cols 20 | } 21 | } 22 | 23 | if t, ok := w.(*os.File); ok { 24 | fd := t.Fd() 25 | var dimensions [4]uint16 26 | 27 | if _, _, err := syscall.Syscall6( 28 | syscall.SYS_IOCTL, 29 | uintptr(fd), 30 | uintptr(syscall.TIOCGWINSZ), 31 | uintptr(unsafe.Pointer(&dimensions)), 32 | 0, 0, 0, 33 | ); err == 0 { 34 | return int(dimensions[1]) 35 | } 36 | } 37 | return 80 38 | } 39 | -------------------------------------------------------------------------------- /vendor/gopkg.in/alecthomas/kingpin.v2/values.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"type": "bool", "parser": "strconv.ParseBool(s)"}, 3 | {"type": "string", "parser": "s, error(nil)", "format": "string(*f.v)", "plural": "Strings"}, 4 | {"type": "uint", "parser": "strconv.ParseUint(s, 0, 64)", "plural": "Uints"}, 5 | {"type": "uint8", "parser": "strconv.ParseUint(s, 0, 8)"}, 6 | {"type": "uint16", "parser": "strconv.ParseUint(s, 0, 16)"}, 7 | {"type": "uint32", "parser": "strconv.ParseUint(s, 0, 32)"}, 8 | {"type": "uint64", "parser": "strconv.ParseUint(s, 0, 64)"}, 9 | {"type": "int", "parser": "strconv.ParseFloat(s, 64)", "plural": "Ints"}, 10 | {"type": "int8", "parser": "strconv.ParseInt(s, 0, 8)"}, 11 | {"type": "int16", "parser": "strconv.ParseInt(s, 0, 16)"}, 12 | {"type": "int32", "parser": "strconv.ParseInt(s, 0, 32)"}, 13 | {"type": "int64", "parser": "strconv.ParseInt(s, 0, 64)"}, 14 | {"type": "float64", "parser": "strconv.ParseFloat(s, 64)"}, 15 | {"type": "float32", "parser": "strconv.ParseFloat(s, 32)"}, 16 | {"name": "Duration", "type": "time.Duration", "no_value_parser": true}, 17 | {"name": "IP", "type": "net.IP", "no_value_parser": true}, 18 | {"name": "TCPAddr", "Type": "*net.TCPAddr", "plural": "TCPList", "no_value_parser": true}, 19 | {"name": "ExistingFile", "Type": "string", "plural": "ExistingFiles", "no_value_parser": true}, 20 | {"name": "ExistingDir", "Type": "string", "plural": "ExistingDirs", "no_value_parser": true}, 21 | {"name": "ExistingFileOrDir", "Type": "string", "plural": "ExistingFilesOrDirs", "no_value_parser": true}, 22 | {"name": "Regexp", "Type": "*regexp.Regexp", "parser": "regexp.Compile(s)"}, 23 | {"name": "ResolvedIP", "Type": "net.IP", "parser": "resolveHost(s)", "help": "Resolve a hostname or IP to an IP."}, 24 | {"name": "HexBytes", "Type": "[]byte", "parser": "hex.DecodeString(s)", "help": "Bytes as a hex string."} 25 | ] 26 | --------------------------------------------------------------------------------