├── .gitignore ├── .travis.yml ├── Makefile ├── README.md ├── api.go ├── bin └── package.sh ├── driver.go ├── img └── logo.png ├── main.go └── vendor ├── github.com ├── Azure │ └── go-ansiterm │ │ ├── LICENSE │ │ ├── constants.go │ │ ├── context.go │ │ ├── csi_entry_state.go │ │ ├── csi_param_state.go │ │ ├── escape_intermediate_state.go │ │ ├── escape_state.go │ │ ├── event_handler.go │ │ ├── ground_state.go │ │ ├── osc_string_state.go │ │ ├── parser.go │ │ ├── parser_action_helpers.go │ │ ├── parser_actions.go │ │ ├── states.go │ │ ├── utilities.go │ │ └── winterm │ │ ├── ansi.go │ │ ├── api.go │ │ ├── attr_translation.go │ │ ├── cursor_helpers.go │ │ ├── erase_helpers.go │ │ ├── scroll_helper.go │ │ ├── utilities.go │ │ └── win_event_handler.go ├── Sirupsen │ └── logrus │ │ ├── LICENSE │ │ ├── alt_exit.go │ │ ├── doc.go │ │ ├── entry.go │ │ ├── examples │ │ ├── basic │ │ │ └── basic.go │ │ └── hook │ │ │ └── hook.go │ │ ├── exported.go │ │ ├── formatter.go │ │ ├── hooks.go │ │ ├── hooks │ │ ├── syslog │ │ │ └── syslog.go │ │ └── test │ │ │ └── test.go │ │ ├── json_formatter.go │ │ ├── logger.go │ │ ├── logrus.go │ │ ├── terminal_appengine.go │ │ ├── terminal_bsd.go │ │ ├── terminal_linux.go │ │ ├── terminal_notwindows.go │ │ ├── terminal_solaris.go │ │ ├── terminal_windows.go │ │ ├── text_formatter.go │ │ └── writer.go ├── docker │ ├── docker │ │ └── pkg │ │ │ ├── system │ │ │ ├── LICENSE │ │ │ ├── chtimes.go │ │ │ ├── chtimes_unix.go │ │ │ ├── chtimes_windows.go │ │ │ ├── errors.go │ │ │ ├── events_windows.go │ │ │ ├── filesys.go │ │ │ ├── filesys_windows.go │ │ │ ├── lstat.go │ │ │ ├── lstat_windows.go │ │ │ ├── meminfo.go │ │ │ ├── meminfo_linux.go │ │ │ ├── meminfo_unsupported.go │ │ │ ├── meminfo_windows.go │ │ │ ├── mknod.go │ │ │ ├── mknod_windows.go │ │ │ ├── path_unix.go │ │ │ ├── path_windows.go │ │ │ ├── stat.go │ │ │ ├── stat_freebsd.go │ │ │ ├── stat_linux.go │ │ │ ├── stat_openbsd.go │ │ │ ├── stat_solaris.go │ │ │ ├── stat_unsupported.go │ │ │ ├── stat_windows.go │ │ │ ├── syscall_unix.go │ │ │ ├── syscall_windows.go │ │ │ ├── umask.go │ │ │ ├── umask_windows.go │ │ │ ├── utimes_darwin.go │ │ │ ├── utimes_freebsd.go │ │ │ ├── utimes_linux.go │ │ │ ├── utimes_unsupported.go │ │ │ ├── xattrs_linux.go │ │ │ └── xattrs_unsupported.go │ │ │ └── term │ │ │ ├── LICENSE │ │ │ ├── ascii.go │ │ │ ├── tc_linux_cgo.go │ │ │ ├── tc_other.go │ │ │ ├── tc_solaris_cgo.go │ │ │ ├── term.go │ │ │ ├── term_solaris.go │ │ │ ├── term_unix.go │ │ │ ├── term_windows.go │ │ │ ├── termios_darwin.go │ │ │ ├── termios_freebsd.go │ │ │ ├── termios_linux.go │ │ │ ├── termios_openbsd.go │ │ │ └── windows │ │ │ ├── ansi_reader.go │ │ │ ├── ansi_writer.go │ │ │ ├── console.go │ │ │ └── windows.go │ └── machine │ │ ├── libmachine │ │ ├── drivers │ │ │ ├── LICENSE │ │ │ ├── base.go │ │ │ ├── check.go │ │ │ ├── drivers.go │ │ │ ├── notsupported.go │ │ │ ├── plugin │ │ │ │ ├── LICENSE │ │ │ │ ├── localbinary │ │ │ │ │ └── plugin.go │ │ │ │ └── register_driver.go │ │ │ ├── rpc │ │ │ │ ├── client_driver.go │ │ │ │ └── server_driver.go │ │ │ ├── serial.go │ │ │ └── utils.go │ │ ├── log │ │ │ ├── LICENSE │ │ │ ├── fmt_machine_logger.go │ │ │ ├── history_recorder.go │ │ │ ├── log.go │ │ │ └── machine_logger.go │ │ ├── mcnflag │ │ │ ├── LICENSE │ │ │ └── flag.go │ │ ├── mcnutils │ │ │ ├── LICENSE │ │ │ ├── b2d.go │ │ │ └── utils.go │ │ ├── ssh │ │ │ ├── LICENSE │ │ │ ├── client.go │ │ │ ├── keys.go │ │ │ └── sshtest │ │ │ │ └── fake_client.go │ │ ├── state │ │ │ ├── LICENSE │ │ │ └── state.go │ │ └── version │ │ │ ├── LICENSE │ │ │ └── version.go │ │ └── version │ │ ├── LICENSE │ │ └── version.go └── ovh │ └── go-ovh │ └── ovh │ ├── LICENSE │ ├── configuration.go │ ├── consumer_key.go │ ├── error.go │ └── ovh.go ├── golang.org └── x │ ├── crypto │ ├── curve25519 │ │ ├── LICENSE │ │ ├── const_amd64.s │ │ ├── cswap_amd64.s │ │ ├── curve25519.go │ │ ├── doc.go │ │ ├── freeze_amd64.s │ │ ├── ladderstep_amd64.s │ │ ├── mont25519_amd64.go │ │ ├── mul_amd64.s │ │ └── square_amd64.s │ └── ssh │ │ ├── LICENSE │ │ ├── agent │ │ ├── client.go │ │ ├── forward.go │ │ ├── keyring.go │ │ └── server.go │ │ ├── buffer.go │ │ ├── certs.go │ │ ├── channel.go │ │ ├── cipher.go │ │ ├── client.go │ │ ├── client_auth.go │ │ ├── common.go │ │ ├── connection.go │ │ ├── doc.go │ │ ├── handshake.go │ │ ├── kex.go │ │ ├── keys.go │ │ ├── mac.go │ │ ├── messages.go │ │ ├── mux.go │ │ ├── server.go │ │ ├── session.go │ │ ├── tcpip.go │ │ ├── terminal │ │ ├── terminal.go │ │ ├── util.go │ │ ├── util_bsd.go │ │ ├── util_linux.go │ │ └── util_windows.go │ │ ├── test │ │ └── doc.go │ │ └── transport.go │ └── sys │ └── unix │ ├── LICENSE │ ├── asm.s │ ├── asm_darwin_386.s │ ├── asm_darwin_amd64.s │ ├── asm_darwin_arm.s │ ├── asm_darwin_arm64.s │ ├── asm_dragonfly_386.s │ ├── asm_dragonfly_amd64.s │ ├── asm_freebsd_386.s │ ├── asm_freebsd_amd64.s │ ├── asm_freebsd_arm.s │ ├── asm_linux_386.s │ ├── asm_linux_amd64.s │ ├── asm_linux_arm.s │ ├── asm_linux_arm64.s │ ├── asm_linux_mips64x.s │ ├── asm_linux_ppc64x.s │ ├── asm_netbsd_386.s │ ├── asm_netbsd_amd64.s │ ├── asm_netbsd_arm.s │ ├── asm_openbsd_386.s │ ├── asm_openbsd_amd64.s │ ├── asm_solaris_amd64.s │ ├── constants.go │ ├── env_unix.go │ ├── env_unset.go │ ├── flock.go │ ├── flock_linux_32bit.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── race.go │ ├── race0.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── str.go │ ├── syscall.go │ ├── syscall_bsd.go │ ├── syscall_darwin.go │ ├── syscall_darwin_386.go │ ├── syscall_darwin_amd64.go │ ├── syscall_darwin_arm.go │ ├── syscall_darwin_arm64.go │ ├── syscall_dragonfly.go │ ├── syscall_dragonfly_386.go │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_linux.go │ ├── syscall_linux_386.go │ ├── syscall_linux_amd64.go │ ├── syscall_linux_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_netbsd.go │ ├── syscall_netbsd_386.go │ ├── syscall_netbsd_amd64.go │ ├── syscall_netbsd_arm.go │ ├── syscall_no_getwd.go │ ├── syscall_openbsd.go │ ├── syscall_openbsd_386.go │ ├── syscall_openbsd_amd64.go │ ├── syscall_solaris.go │ ├── syscall_solaris_amd64.go │ ├── syscall_unix.go │ ├── types_darwin.go │ ├── types_dragonfly.go │ ├── types_freebsd.go │ ├── types_linux.go │ ├── types_netbsd.go │ ├── types_openbsd.go │ ├── types_solaris.go │ ├── zerrors_darwin_386.go │ ├── zerrors_darwin_amd64.go │ ├── zerrors_darwin_arm.go │ ├── zerrors_darwin_arm64.go │ ├── zerrors_dragonfly_386.go │ ├── zerrors_dragonfly_amd64.go │ ├── zerrors_freebsd_386.go │ ├── zerrors_freebsd_amd64.go │ ├── zerrors_freebsd_arm.go │ ├── zerrors_linux_386.go │ ├── zerrors_linux_amd64.go │ ├── zerrors_linux_arm.go │ ├── zerrors_linux_arm64.go │ ├── zerrors_linux_mips64.go │ ├── zerrors_linux_mips64le.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_openbsd_386.go │ ├── zerrors_openbsd_amd64.go │ ├── zerrors_solaris_amd64.go │ ├── zsyscall_darwin_386.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_arm.go │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_dragonfly_386.go │ ├── zsyscall_dragonfly_amd64.go │ ├── zsyscall_freebsd_386.go │ ├── zsyscall_freebsd_amd64.go │ ├── zsyscall_freebsd_arm.go │ ├── zsyscall_linux_386.go │ ├── zsyscall_linux_amd64.go │ ├── zsyscall_linux_arm.go │ ├── zsyscall_linux_arm64.go │ ├── zsyscall_linux_mips64.go │ ├── zsyscall_linux_mips64le.go │ ├── zsyscall_linux_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_openbsd_386.go │ ├── zsyscall_openbsd_amd64.go │ ├── zsyscall_solaris_amd64.go │ ├── zsysctl_openbsd.go │ ├── zsysnum_darwin_386.go │ ├── zsysnum_darwin_amd64.go │ ├── zsysnum_darwin_arm.go │ ├── zsysnum_darwin_arm64.go │ ├── zsysnum_dragonfly_386.go │ ├── zsysnum_dragonfly_amd64.go │ ├── zsysnum_freebsd_386.go │ ├── zsysnum_freebsd_amd64.go │ ├── zsysnum_freebsd_arm.go │ ├── zsysnum_linux_386.go │ ├── zsysnum_linux_amd64.go │ ├── zsysnum_linux_arm.go │ ├── zsysnum_linux_arm64.go │ ├── zsysnum_linux_mips64.go │ ├── zsysnum_linux_mips64le.go │ ├── zsysnum_linux_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_solaris_amd64.go │ ├── ztypes_darwin_386.go │ ├── ztypes_darwin_amd64.go │ ├── ztypes_darwin_arm.go │ ├── ztypes_darwin_arm64.go │ ├── ztypes_dragonfly_386.go │ ├── ztypes_dragonfly_amd64.go │ ├── ztypes_freebsd_386.go │ ├── ztypes_freebsd_amd64.go │ ├── ztypes_freebsd_arm.go │ ├── ztypes_linux_386.go │ ├── ztypes_linux_amd64.go │ ├── ztypes_linux_arm.go │ ├── ztypes_linux_arm64.go │ ├── ztypes_linux_mips64.go │ ├── ztypes_linux_mips64le.go │ ├── ztypes_linux_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_netbsd_386.go │ ├── ztypes_netbsd_amd64.go │ ├── ztypes_netbsd_arm.go │ ├── ztypes_openbsd_386.go │ ├── ztypes_openbsd_amd64.go │ └── ztypes_solaris_amd64.go ├── gopkg.in ├── airbrake │ └── gobrake.v2 │ │ ├── LICENSE │ │ ├── gobrake.go │ │ ├── notice.go │ │ ├── notifier.go │ │ └── util.go ├── gemnasium │ └── logrus-airbrake-hook.v2 │ │ ├── LICENSE │ │ └── airbrake.go └── ini.v1 │ ├── LICENSE │ ├── ini.go │ ├── key.go │ ├── parser.go │ ├── section.go │ └── struct.go └── manifest /.gitignore: -------------------------------------------------------------------------------- 1 | docker-machine-driver-ovh* 2 | ovh.conf 3 | *.swp 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.7 4 | 5 | install: true 6 | script: "./bin/package.sh" 7 | 8 | deploy: 9 | provider: releases 10 | skip_cleanup: true 11 | api_key: 12 | secure: cb8hpYYUDstAgce5n9KEiXysWMj3ln7MO4BhtFQ90AH54zg/mNJ2aTGZoSkd5h5u5u0jdU4C9kXTcN8VzFpcSR11YInFl2j+P16JtkKbOTqkBuEO+56QZH04c1t4LUjonmPhyyi1Ru1WSbA7ohr13MN/mPbLziJhhytU37tcQxNc3VQ+gGrDsVTjE/E5MzEGzpZtCEU3tA8gFK/FbknI67m80tby0GiZLAuEmt4K8HfAmTC1bwxzg2qFnduRfKhg9HiQaS/xFUGqT3MqSW86k9bS7cWqdPItH8oEMdToUOv1cwpuVsLqjMZXjzZCvnbQ8ynbAPxWUHza9KHtBTXpf8dpAYiv0PXbmU+zA0s0RZg6pyxNrPw+ldfQY6FgeKz69j+O3NfCXSr+qqZTisARcmKzlx5KQpfmm6mzieFUe/n6Yr8FXkZjqZMecMDjdyJGfBG7CdWTQGXvAvfmtpKt7Jw5ZRWqIWvPCHIElAws/HQbac31SflWLlkTaTYKVdImUzfGftgLNjwFRzwDKuJS+wFYN8QMNb8MQYArr0R9RUVinksvCvBI5VPBLCKKGG0KSh+BDa89y5e2CZ4gjC0tllIGdJItYcCrpKiOFsTP+HxKcsysctxYryA9HvTcp8S4Tg7Lp9L2fVhCowBs0d7qAAt7mPJ009nYQ9sOWoEfTh4= 13 | file_glob: true 14 | file: 'pkg/docker-machine-driver-ovh-*.tar.gz' 15 | on: 16 | repo: yadutaf/docker-machine-driver-ovh 17 | tags: true 18 | 19 | notifications: 20 | email: 21 | recipients: 22 | - jt+travis-docker-machine@yadutaf.fr 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PKG = "docker-machine-driver-ovh" 2 | DEPS = $(shell go list -f '{{range .Imports}}{{.}} {{end}}' ./... | tr ' ' '\n' | grep "github.com" | grep -v $(PKG) | sort | uniq | tr '\n' ' ') 3 | 4 | vendor: 5 | go get -u github.com/FiloSottile/gvt 6 | for dep in $(DEPS); do \ 7 | $$GOPATH/bin/gvt fetch $$dep; \ 8 | done 9 | 10 | .PHONY: vendor 11 | -------------------------------------------------------------------------------- /bin/package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | OS="darwin linux windows" 6 | ARCH="amd64" 7 | VERSION=${TRAVIS_TAG:-latest} 8 | PRODUCT="docker-machine-driver-ovh" 9 | PKG_ROOT="pkg" 10 | BUILD_ROOT="build" 11 | 12 | echo "➜ Building version $VERSION of $PRODUCT in $GOPATH" 13 | mkdir -p $PKG_ROOT 14 | mkdir -p $BUILD_ROOT 15 | 16 | echo "➜ Getting build dependencies" 17 | go get 18 | go get -u github.com/golang/lint/golint 19 | 20 | echo "➜ Ensuring code quality" 21 | pkgs=$(go list ./... | grep -v 'vendor') 22 | go vet $pkgs 23 | golint $pkgs 24 | 25 | for GOOS in $OS; do 26 | for GOARCH in $ARCH; do 27 | name="${PRODUCT}-${VERSION}-${GOOS}-${GOARCH}" 28 | archive="${name}.tar.gz" 29 | checksum="${archive}.md5" 30 | build_path="${BUILD_ROOT}/${name}" 31 | location="${build_path}/${PRODUCT}" 32 | 33 | echo "➜ Releasing ${PRODUCT} for ${GOOS}-${GOARCH}" 34 | echo "⤷ Build" 35 | export GOOS=$GOOS 36 | export GOARCH=$GOARCH 37 | go build -o $location 38 | 39 | echo "⤷ Package" 40 | tar -czf $PKG_ROOT/$archive -C $build_path $PRODUCT 41 | 42 | echo "⤷ Checksum" 43 | cd $PKG_ROOT && md5sum $archive > $checksum && cd .. 44 | done 45 | done 46 | 47 | echo "➜ Cleaning" 48 | rm -rf $BUILD_ROOT 49 | 50 | echo "Build completed." 51 | -------------------------------------------------------------------------------- /img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yadutaf/docker-machine-driver-ovh/7b5edb6b077405e4c9d27c4ad58991680dd3d836/img/logo.png -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/docker/machine/libmachine/drivers" 5 | "github.com/docker/machine/libmachine/drivers/plugin" 6 | ) 7 | 8 | // Default values for docker-machine-driver-ovh 9 | const ( 10 | DefaultSecurityGroup = "default" 11 | DefaultProjectName = "docker-machine" 12 | DefaultFlavorName = "vps-ssd-1" 13 | DefaultRegionName = "GRA1" 14 | DefaultImageName = "Ubuntu 16.04" 15 | DefaultSSHUserName = "ubuntu" 16 | DefaultBillingPeriod = "hourly" 17 | ) 18 | 19 | func main() { 20 | plugin.RegisterDriver(&Driver{ 21 | BaseDriver: &drivers.BaseDriver{ 22 | SSHUser: DefaultSSHUserName, 23 | SSHPort: 22, 24 | }}) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Microsoft Corporation 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/context.go: -------------------------------------------------------------------------------- 1 | package ansiterm 2 | 3 | type ansiContext struct { 4 | currentChar byte 5 | paramBuffer []byte 6 | interBuffer []byte 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/csi_entry_state.go: -------------------------------------------------------------------------------- 1 | package ansiterm 2 | 3 | type csiEntryState struct { 4 | baseState 5 | } 6 | 7 | func (csiState csiEntryState) Handle(b byte) (s state, e error) { 8 | logger.Infof("CsiEntry::Handle %#x", b) 9 | 10 | nextState, err := csiState.baseState.Handle(b) 11 | if nextState != nil || err != nil { 12 | return nextState, err 13 | } 14 | 15 | switch { 16 | case sliceContains(alphabetics, b): 17 | return csiState.parser.ground, nil 18 | case sliceContains(csiCollectables, b): 19 | return csiState.parser.csiParam, nil 20 | case sliceContains(executors, b): 21 | return csiState, csiState.parser.execute() 22 | } 23 | 24 | return csiState, nil 25 | } 26 | 27 | func (csiState csiEntryState) Transition(s state) error { 28 | logger.Infof("CsiEntry::Transition %s --> %s", csiState.Name(), s.Name()) 29 | csiState.baseState.Transition(s) 30 | 31 | switch s { 32 | case csiState.parser.ground: 33 | return csiState.parser.csiDispatch() 34 | case csiState.parser.csiParam: 35 | switch { 36 | case sliceContains(csiParams, csiState.parser.context.currentChar): 37 | csiState.parser.collectParam() 38 | case sliceContains(intermeds, csiState.parser.context.currentChar): 39 | csiState.parser.collectInter() 40 | } 41 | } 42 | 43 | return nil 44 | } 45 | 46 | func (csiState csiEntryState) Enter() error { 47 | csiState.parser.clear() 48 | return nil 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/csi_param_state.go: -------------------------------------------------------------------------------- 1 | package ansiterm 2 | 3 | type csiParamState struct { 4 | baseState 5 | } 6 | 7 | func (csiState csiParamState) Handle(b byte) (s state, e error) { 8 | logger.Infof("CsiParam::Handle %#x", b) 9 | 10 | nextState, err := csiState.baseState.Handle(b) 11 | if nextState != nil || err != nil { 12 | return nextState, err 13 | } 14 | 15 | switch { 16 | case sliceContains(alphabetics, b): 17 | return csiState.parser.ground, nil 18 | case sliceContains(csiCollectables, b): 19 | csiState.parser.collectParam() 20 | return csiState, nil 21 | case sliceContains(executors, b): 22 | return csiState, csiState.parser.execute() 23 | } 24 | 25 | return csiState, nil 26 | } 27 | 28 | func (csiState csiParamState) Transition(s state) error { 29 | logger.Infof("CsiParam::Transition %s --> %s", csiState.Name(), s.Name()) 30 | csiState.baseState.Transition(s) 31 | 32 | switch s { 33 | case csiState.parser.ground: 34 | return csiState.parser.csiDispatch() 35 | } 36 | 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/escape_intermediate_state.go: -------------------------------------------------------------------------------- 1 | package ansiterm 2 | 3 | type escapeIntermediateState struct { 4 | baseState 5 | } 6 | 7 | func (escState escapeIntermediateState) Handle(b byte) (s state, e error) { 8 | logger.Infof("escapeIntermediateState::Handle %#x", b) 9 | nextState, err := escState.baseState.Handle(b) 10 | if nextState != nil || err != nil { 11 | return nextState, err 12 | } 13 | 14 | switch { 15 | case sliceContains(intermeds, b): 16 | return escState, escState.parser.collectInter() 17 | case sliceContains(executors, b): 18 | return escState, escState.parser.execute() 19 | case sliceContains(escapeIntermediateToGroundBytes, b): 20 | return escState.parser.ground, nil 21 | } 22 | 23 | return escState, nil 24 | } 25 | 26 | func (escState escapeIntermediateState) Transition(s state) error { 27 | logger.Infof("escapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name()) 28 | escState.baseState.Transition(s) 29 | 30 | switch s { 31 | case escState.parser.ground: 32 | return escState.parser.escDispatch() 33 | } 34 | 35 | return nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/escape_state.go: -------------------------------------------------------------------------------- 1 | package ansiterm 2 | 3 | type escapeState struct { 4 | baseState 5 | } 6 | 7 | func (escState escapeState) Handle(b byte) (s state, e error) { 8 | logger.Infof("escapeState::Handle %#x", b) 9 | nextState, err := escState.baseState.Handle(b) 10 | if nextState != nil || err != nil { 11 | return nextState, err 12 | } 13 | 14 | switch { 15 | case b == ANSI_ESCAPE_SECONDARY: 16 | return escState.parser.csiEntry, nil 17 | case b == ANSI_OSC_STRING_ENTRY: 18 | return escState.parser.oscString, nil 19 | case sliceContains(executors, b): 20 | return escState, escState.parser.execute() 21 | case sliceContains(escapeToGroundBytes, b): 22 | return escState.parser.ground, nil 23 | case sliceContains(intermeds, b): 24 | return escState.parser.escapeIntermediate, nil 25 | } 26 | 27 | return escState, nil 28 | } 29 | 30 | func (escState escapeState) Transition(s state) error { 31 | logger.Infof("Escape::Transition %s --> %s", escState.Name(), s.Name()) 32 | escState.baseState.Transition(s) 33 | 34 | switch s { 35 | case escState.parser.ground: 36 | return escState.parser.escDispatch() 37 | case escState.parser.escapeIntermediate: 38 | return escState.parser.collectInter() 39 | } 40 | 41 | return nil 42 | } 43 | 44 | func (escState escapeState) Enter() error { 45 | escState.parser.clear() 46 | return nil 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/event_handler.go: -------------------------------------------------------------------------------- 1 | package ansiterm 2 | 3 | type AnsiEventHandler interface { 4 | // Print 5 | Print(b byte) error 6 | 7 | // Execute C0 commands 8 | Execute(b byte) error 9 | 10 | // CUrsor Up 11 | CUU(int) error 12 | 13 | // CUrsor Down 14 | CUD(int) error 15 | 16 | // CUrsor Forward 17 | CUF(int) error 18 | 19 | // CUrsor Backward 20 | CUB(int) error 21 | 22 | // Cursor to Next Line 23 | CNL(int) error 24 | 25 | // Cursor to Previous Line 26 | CPL(int) error 27 | 28 | // Cursor Horizontal position Absolute 29 | CHA(int) error 30 | 31 | // Vertical line Position Absolute 32 | VPA(int) error 33 | 34 | // CUrsor Position 35 | CUP(int, int) error 36 | 37 | // Horizontal and Vertical Position (depends on PUM) 38 | HVP(int, int) error 39 | 40 | // Text Cursor Enable Mode 41 | DECTCEM(bool) error 42 | 43 | // Origin Mode 44 | DECOM(bool) error 45 | 46 | // 132 Column Mode 47 | DECCOLM(bool) error 48 | 49 | // Erase in Display 50 | ED(int) error 51 | 52 | // Erase in Line 53 | EL(int) error 54 | 55 | // Insert Line 56 | IL(int) error 57 | 58 | // Delete Line 59 | DL(int) error 60 | 61 | // Insert Character 62 | ICH(int) error 63 | 64 | // Delete Character 65 | DCH(int) error 66 | 67 | // Set Graphics Rendition 68 | SGR([]int) error 69 | 70 | // Pan Down 71 | SU(int) error 72 | 73 | // Pan Up 74 | SD(int) error 75 | 76 | // Device Attributes 77 | DA([]string) error 78 | 79 | // Set Top and Bottom Margins 80 | DECSTBM(int, int) error 81 | 82 | // Index 83 | IND() error 84 | 85 | // Reverse Index 86 | RI() error 87 | 88 | // Flush updates from previous commands 89 | Flush() error 90 | } 91 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/ground_state.go: -------------------------------------------------------------------------------- 1 | package ansiterm 2 | 3 | type groundState struct { 4 | baseState 5 | } 6 | 7 | func (gs groundState) Handle(b byte) (s state, e error) { 8 | gs.parser.context.currentChar = b 9 | 10 | nextState, err := gs.baseState.Handle(b) 11 | if nextState != nil || err != nil { 12 | return nextState, err 13 | } 14 | 15 | switch { 16 | case sliceContains(printables, b): 17 | return gs, gs.parser.print() 18 | 19 | case sliceContains(executors, b): 20 | return gs, gs.parser.execute() 21 | } 22 | 23 | return gs, nil 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/osc_string_state.go: -------------------------------------------------------------------------------- 1 | package ansiterm 2 | 3 | type oscStringState struct { 4 | baseState 5 | } 6 | 7 | func (oscState oscStringState) Handle(b byte) (s state, e error) { 8 | logger.Infof("OscString::Handle %#x", b) 9 | nextState, err := oscState.baseState.Handle(b) 10 | if nextState != nil || err != nil { 11 | return nextState, err 12 | } 13 | 14 | switch { 15 | case isOscStringTerminator(b): 16 | return oscState.parser.ground, nil 17 | } 18 | 19 | return oscState, nil 20 | } 21 | 22 | // See below for OSC string terminators for linux 23 | // http://man7.org/linux/man-pages/man4/console_codes.4.html 24 | func isOscStringTerminator(b byte) bool { 25 | 26 | if b == ANSI_BEL || b == 0x5C { 27 | return true 28 | } 29 | 30 | return false 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/parser_action_helpers.go: -------------------------------------------------------------------------------- 1 | package ansiterm 2 | 3 | import ( 4 | "strconv" 5 | ) 6 | 7 | func parseParams(bytes []byte) ([]string, error) { 8 | paramBuff := make([]byte, 0, 0) 9 | params := []string{} 10 | 11 | for _, v := range bytes { 12 | if v == ';' { 13 | if len(paramBuff) > 0 { 14 | // Completed parameter, append it to the list 15 | s := string(paramBuff) 16 | params = append(params, s) 17 | paramBuff = make([]byte, 0, 0) 18 | } 19 | } else { 20 | paramBuff = append(paramBuff, v) 21 | } 22 | } 23 | 24 | // Last parameter may not be terminated with ';' 25 | if len(paramBuff) > 0 { 26 | s := string(paramBuff) 27 | params = append(params, s) 28 | } 29 | 30 | logger.Infof("Parsed params: %v with length: %d", params, len(params)) 31 | return params, nil 32 | } 33 | 34 | func parseCmd(context ansiContext) (string, error) { 35 | return string(context.currentChar), nil 36 | } 37 | 38 | func getInt(params []string, dflt int) int { 39 | i := getInts(params, 1, dflt)[0] 40 | logger.Infof("getInt: %v", i) 41 | return i 42 | } 43 | 44 | func getInts(params []string, minCount int, dflt int) []int { 45 | ints := []int{} 46 | 47 | for _, v := range params { 48 | i, _ := strconv.Atoi(v) 49 | // Zero is mapped to the default value in VT100. 50 | if i == 0 { 51 | i = dflt 52 | } 53 | ints = append(ints, i) 54 | } 55 | 56 | if len(ints) < minCount { 57 | remaining := minCount - len(ints) 58 | for i := 0; i < remaining; i++ { 59 | ints = append(ints, dflt) 60 | } 61 | } 62 | 63 | logger.Infof("getInts: %v", ints) 64 | 65 | return ints 66 | } 67 | 68 | func (ap *AnsiParser) modeDispatch(param string, set bool) error { 69 | switch param { 70 | case "?3": 71 | return ap.eventHandler.DECCOLM(set) 72 | case "?6": 73 | return ap.eventHandler.DECOM(set) 74 | case "?25": 75 | return ap.eventHandler.DECTCEM(set) 76 | } 77 | return nil 78 | } 79 | 80 | func (ap *AnsiParser) hDispatch(params []string) error { 81 | if len(params) == 1 { 82 | return ap.modeDispatch(params[0], true) 83 | } 84 | 85 | return nil 86 | } 87 | 88 | func (ap *AnsiParser) lDispatch(params []string) error { 89 | if len(params) == 1 { 90 | return ap.modeDispatch(params[0], false) 91 | } 92 | 93 | return nil 94 | } 95 | 96 | func getEraseParam(params []string) int { 97 | param := getInt(params, 0) 98 | if param < 0 || 3 < param { 99 | param = 0 100 | } 101 | 102 | return param 103 | } 104 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/states.go: -------------------------------------------------------------------------------- 1 | package ansiterm 2 | 3 | type stateID int 4 | 5 | type state interface { 6 | Enter() error 7 | Exit() error 8 | Handle(byte) (state, error) 9 | Name() string 10 | Transition(state) error 11 | } 12 | 13 | type baseState struct { 14 | name string 15 | parser *AnsiParser 16 | } 17 | 18 | func (base baseState) Enter() error { 19 | return nil 20 | } 21 | 22 | func (base baseState) Exit() error { 23 | return nil 24 | } 25 | 26 | func (base baseState) Handle(b byte) (s state, e error) { 27 | 28 | switch { 29 | case b == CSI_ENTRY: 30 | return base.parser.csiEntry, nil 31 | case b == DCS_ENTRY: 32 | return base.parser.dcsEntry, nil 33 | case b == ANSI_ESCAPE_PRIMARY: 34 | return base.parser.escape, nil 35 | case b == OSC_STRING: 36 | return base.parser.oscString, nil 37 | case sliceContains(toGroundBytes, b): 38 | return base.parser.ground, nil 39 | } 40 | 41 | return nil, nil 42 | } 43 | 44 | func (base baseState) Name() string { 45 | return base.name 46 | } 47 | 48 | func (base baseState) Transition(s state) error { 49 | if s == base.parser.ground { 50 | execBytes := []byte{0x18} 51 | execBytes = append(execBytes, 0x1A) 52 | execBytes = append(execBytes, getByteRange(0x80, 0x8F)...) 53 | execBytes = append(execBytes, getByteRange(0x91, 0x97)...) 54 | execBytes = append(execBytes, 0x99) 55 | execBytes = append(execBytes, 0x9A) 56 | 57 | if sliceContains(execBytes, base.parser.context.currentChar) { 58 | return base.parser.execute() 59 | } 60 | } 61 | 62 | return nil 63 | } 64 | 65 | type dcsEntryState struct { 66 | baseState 67 | } 68 | 69 | type errorState struct { 70 | baseState 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/utilities.go: -------------------------------------------------------------------------------- 1 | package ansiterm 2 | 3 | import ( 4 | "strconv" 5 | ) 6 | 7 | func sliceContains(bytes []byte, b byte) bool { 8 | for _, v := range bytes { 9 | if v == b { 10 | return true 11 | } 12 | } 13 | 14 | return false 15 | } 16 | 17 | func convertBytesToInteger(bytes []byte) int { 18 | s := string(bytes) 19 | i, _ := strconv.Atoi(s) 20 | return i 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/winterm/cursor_helpers.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package winterm 4 | 5 | const ( 6 | horizontal = iota 7 | vertical 8 | ) 9 | 10 | func (h *windowsAnsiEventHandler) getCursorWindow(info *CONSOLE_SCREEN_BUFFER_INFO) SMALL_RECT { 11 | if h.originMode { 12 | sr := h.effectiveSr(info.Window) 13 | return SMALL_RECT{ 14 | Top: sr.top, 15 | Bottom: sr.bottom, 16 | Left: 0, 17 | Right: info.Size.X - 1, 18 | } 19 | } else { 20 | return SMALL_RECT{ 21 | Top: info.Window.Top, 22 | Bottom: info.Window.Bottom, 23 | Left: 0, 24 | Right: info.Size.X - 1, 25 | } 26 | } 27 | } 28 | 29 | // setCursorPosition sets the cursor to the specified position, bounded to the screen size 30 | func (h *windowsAnsiEventHandler) setCursorPosition(position COORD, window SMALL_RECT) error { 31 | position.X = ensureInRange(position.X, window.Left, window.Right) 32 | position.Y = ensureInRange(position.Y, window.Top, window.Bottom) 33 | err := SetConsoleCursorPosition(h.fd, position) 34 | if err != nil { 35 | return err 36 | } 37 | logger.Infof("Cursor position set: (%d, %d)", position.X, position.Y) 38 | return err 39 | } 40 | 41 | func (h *windowsAnsiEventHandler) moveCursorVertical(param int) error { 42 | return h.moveCursor(vertical, param) 43 | } 44 | 45 | func (h *windowsAnsiEventHandler) moveCursorHorizontal(param int) error { 46 | return h.moveCursor(horizontal, param) 47 | } 48 | 49 | func (h *windowsAnsiEventHandler) moveCursor(moveMode int, param int) error { 50 | info, err := GetConsoleScreenBufferInfo(h.fd) 51 | if err != nil { 52 | return err 53 | } 54 | 55 | position := info.CursorPosition 56 | switch moveMode { 57 | case horizontal: 58 | position.X += int16(param) 59 | case vertical: 60 | position.Y += int16(param) 61 | } 62 | 63 | if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil { 64 | return err 65 | } 66 | 67 | return nil 68 | } 69 | 70 | func (h *windowsAnsiEventHandler) moveCursorLine(param int) error { 71 | info, err := GetConsoleScreenBufferInfo(h.fd) 72 | if err != nil { 73 | return err 74 | } 75 | 76 | position := info.CursorPosition 77 | position.X = 0 78 | position.Y += int16(param) 79 | 80 | if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil { 81 | return err 82 | } 83 | 84 | return nil 85 | } 86 | 87 | func (h *windowsAnsiEventHandler) moveCursorColumn(param int) error { 88 | info, err := GetConsoleScreenBufferInfo(h.fd) 89 | if err != nil { 90 | return err 91 | } 92 | 93 | position := info.CursorPosition 94 | position.X = int16(param) - 1 95 | 96 | if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil { 97 | return err 98 | } 99 | 100 | return nil 101 | } 102 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/winterm/erase_helpers.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package winterm 4 | 5 | import "github.com/Azure/go-ansiterm" 6 | 7 | func (h *windowsAnsiEventHandler) clearRange(attributes uint16, fromCoord COORD, toCoord COORD) error { 8 | // Ignore an invalid (negative area) request 9 | if toCoord.Y < fromCoord.Y { 10 | return nil 11 | } 12 | 13 | var err error 14 | 15 | var coordStart = COORD{} 16 | var coordEnd = COORD{} 17 | 18 | xCurrent, yCurrent := fromCoord.X, fromCoord.Y 19 | xEnd, yEnd := toCoord.X, toCoord.Y 20 | 21 | // Clear any partial initial line 22 | if xCurrent > 0 { 23 | coordStart.X, coordStart.Y = xCurrent, yCurrent 24 | coordEnd.X, coordEnd.Y = xEnd, yCurrent 25 | 26 | err = h.clearRect(attributes, coordStart, coordEnd) 27 | if err != nil { 28 | return err 29 | } 30 | 31 | xCurrent = 0 32 | yCurrent += 1 33 | } 34 | 35 | // Clear intervening rectangular section 36 | if yCurrent < yEnd { 37 | coordStart.X, coordStart.Y = xCurrent, yCurrent 38 | coordEnd.X, coordEnd.Y = xEnd, yEnd-1 39 | 40 | err = h.clearRect(attributes, coordStart, coordEnd) 41 | if err != nil { 42 | return err 43 | } 44 | 45 | xCurrent = 0 46 | yCurrent = yEnd 47 | } 48 | 49 | // Clear remaining partial ending line 50 | coordStart.X, coordStart.Y = xCurrent, yCurrent 51 | coordEnd.X, coordEnd.Y = xEnd, yEnd 52 | 53 | err = h.clearRect(attributes, coordStart, coordEnd) 54 | if err != nil { 55 | return err 56 | } 57 | 58 | return nil 59 | } 60 | 61 | func (h *windowsAnsiEventHandler) clearRect(attributes uint16, fromCoord COORD, toCoord COORD) error { 62 | region := SMALL_RECT{Top: fromCoord.Y, Left: fromCoord.X, Bottom: toCoord.Y, Right: toCoord.X} 63 | width := toCoord.X - fromCoord.X + 1 64 | height := toCoord.Y - fromCoord.Y + 1 65 | size := uint32(width) * uint32(height) 66 | 67 | if size <= 0 { 68 | return nil 69 | } 70 | 71 | buffer := make([]CHAR_INFO, size) 72 | 73 | char := CHAR_INFO{ansiterm.FILL_CHARACTER, attributes} 74 | for i := 0; i < int(size); i++ { 75 | buffer[i] = char 76 | } 77 | 78 | err := WriteConsoleOutput(h.fd, buffer, COORD{X: width, Y: height}, COORD{X: 0, Y: 0}, ®ion) 79 | if err != nil { 80 | return err 81 | } 82 | 83 | return nil 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/Azure/go-ansiterm/winterm/utilities.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package winterm 4 | 5 | // AddInRange increments a value by the passed quantity while ensuring the values 6 | // always remain within the supplied min / max range. 7 | func addInRange(n int16, increment int16, min int16, max int16) int16 { 8 | return ensureInRange(n+increment, min, max) 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Eskildsen 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/alt_exit.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // The following code was sourced and modified from the 4 | // https://bitbucket.org/tebeka/atexit package governed by the following license: 5 | // 6 | // Copyright (c) 2012 Miki Tebeka . 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | // this software and associated documentation files (the "Software"), to deal in 10 | // the Software without restriction, including without limitation the rights to 11 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 12 | // the Software, and to permit persons to whom the Software is furnished to do so, 13 | // subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 20 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 21 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 22 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | import ( 26 | "fmt" 27 | "os" 28 | ) 29 | 30 | var handlers = []func(){} 31 | 32 | func runHandler(handler func()) { 33 | defer func() { 34 | if err := recover(); err != nil { 35 | fmt.Fprintln(os.Stderr, "Error: Logrus exit handler error:", err) 36 | } 37 | }() 38 | 39 | handler() 40 | } 41 | 42 | func runHandlers() { 43 | for _, handler := range handlers { 44 | runHandler(handler) 45 | } 46 | } 47 | 48 | // Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code) 49 | func Exit(code int) { 50 | runHandlers() 51 | os.Exit(code) 52 | } 53 | 54 | // RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke 55 | // all handlers. The handlers will also be invoked when any Fatal log entry is 56 | // made. 57 | // 58 | // This method is useful when a caller wishes to use logrus to log a fatal 59 | // message but also needs to gracefully shutdown. An example usecase could be 60 | // closing database connections, or sending a alert that the application is 61 | // closing. 62 | func RegisterExitHandler(handler func()) { 63 | handlers = append(handlers, handler) 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package logrus is a structured logger for Go, completely API compatible with the standard library logger. 3 | 4 | 5 | The simplest way to use Logrus is simply the package-level exported logger: 6 | 7 | package main 8 | 9 | import ( 10 | log "github.com/Sirupsen/logrus" 11 | ) 12 | 13 | func main() { 14 | log.WithFields(log.Fields{ 15 | "animal": "walrus", 16 | "number": 1, 17 | "size": 10, 18 | }).Info("A walrus appears") 19 | } 20 | 21 | Output: 22 | time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 23 | 24 | For a full guide visit https://github.com/Sirupsen/logrus 25 | */ 26 | package logrus 27 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/examples/basic/basic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | ) 6 | 7 | var log = logrus.New() 8 | 9 | func init() { 10 | log.Formatter = new(logrus.JSONFormatter) 11 | log.Formatter = new(logrus.TextFormatter) // default 12 | log.Level = logrus.DebugLevel 13 | } 14 | 15 | func main() { 16 | defer func() { 17 | err := recover() 18 | if err != nil { 19 | log.WithFields(logrus.Fields{ 20 | "omg": true, 21 | "err": err, 22 | "number": 100, 23 | }).Fatal("The ice breaks!") 24 | } 25 | }() 26 | 27 | log.WithFields(logrus.Fields{ 28 | "animal": "walrus", 29 | "number": 8, 30 | }).Debug("Started observing beach") 31 | 32 | log.WithFields(logrus.Fields{ 33 | "animal": "walrus", 34 | "size": 10, 35 | }).Info("A group of walrus emerges from the ocean") 36 | 37 | log.WithFields(logrus.Fields{ 38 | "omg": true, 39 | "number": 122, 40 | }).Warn("The group's number increased tremendously!") 41 | 42 | log.WithFields(logrus.Fields{ 43 | "temperature": -4, 44 | }).Debug("Temperature changes") 45 | 46 | log.WithFields(logrus.Fields{ 47 | "animal": "orca", 48 | "size": 9009, 49 | }).Panic("It's over 9000!") 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/examples/hook/hook.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | "gopkg.in/gemnasium/logrus-airbrake-hook.v2" 6 | ) 7 | 8 | var log = logrus.New() 9 | 10 | func init() { 11 | log.Formatter = new(logrus.TextFormatter) // default 12 | log.Hooks.Add(airbrake.NewHook(123, "xyz", "development")) 13 | } 14 | 15 | func main() { 16 | log.WithFields(logrus.Fields{ 17 | "animal": "walrus", 18 | "size": 10, 19 | }).Info("A group of walrus emerges from the ocean") 20 | 21 | log.WithFields(logrus.Fields{ 22 | "omg": true, 23 | "number": 122, 24 | }).Warn("The group's number increased tremendously!") 25 | 26 | log.WithFields(logrus.Fields{ 27 | "omg": true, 28 | "number": 100, 29 | }).Fatal("The ice breaks!") 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "time" 4 | 5 | const DefaultTimestampFormat = time.RFC3339 6 | 7 | // The Formatter interface is used to implement a custom Formatter. It takes an 8 | // `Entry`. It exposes all the fields, including the default ones: 9 | // 10 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. 11 | // * `entry.Data["time"]`. The timestamp. 12 | // * `entry.Data["level"]. The level the entry was logged at. 13 | // 14 | // Any additional fields added with `WithField` or `WithFields` are also in 15 | // `entry.Data`. Format is expected to return an array of bytes which are then 16 | // logged to `logger.Out`. 17 | type Formatter interface { 18 | Format(*Entry) ([]byte, error) 19 | } 20 | 21 | // This is to not silently overwrite `time`, `msg` and `level` fields when 22 | // dumping it. If this code wasn't there doing: 23 | // 24 | // logrus.WithField("level", 1).Info("hello") 25 | // 26 | // Would just silently drop the user provided level. Instead with this code 27 | // it'll logged as: 28 | // 29 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."} 30 | // 31 | // It's not exported because it's still using Data in an opinionated way. It's to 32 | // avoid code duplication between the two default formatters. 33 | func prefixFieldClashes(data Fields) { 34 | if t, ok := data["time"]; ok { 35 | data["fields.time"] = t 36 | } 37 | 38 | if m, ok := data["msg"]; ok { 39 | data["fields.msg"] = m 40 | } 41 | 42 | if l, ok := data["level"]; ok { 43 | data["fields.level"] = l 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // A hook to be fired when logging on the logging levels returned from 4 | // `Levels()` on your implementation of the interface. Note that this is not 5 | // fired in a goroutine or a channel with workers, you should handle such 6 | // functionality yourself if your call is non-blocking and you don't wish for 7 | // the logging calls for levels returned from `Levels()` to block. 8 | type Hook interface { 9 | Levels() []Level 10 | Fire(*Entry) error 11 | } 12 | 13 | // Internal type for storing the hooks on a logger instance. 14 | type LevelHooks map[Level][]Hook 15 | 16 | // Add a hook to an instance of logger. This is called with 17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. 18 | func (hooks LevelHooks) Add(hook Hook) { 19 | for _, level := range hook.Levels() { 20 | hooks[level] = append(hooks[level], hook) 21 | } 22 | } 23 | 24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire 25 | // appropriate hooks for a log entry. 26 | func (hooks LevelHooks) Fire(level Level, entry *Entry) error { 27 | for _, hook := range hooks[level] { 28 | if err := hook.Fire(entry); err != nil { 29 | return err 30 | } 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!nacl,!plan9 2 | 3 | package logrus_syslog 4 | 5 | import ( 6 | "fmt" 7 | "github.com/Sirupsen/logrus" 8 | "log/syslog" 9 | "os" 10 | ) 11 | 12 | // SyslogHook to send logs via syslog. 13 | type SyslogHook struct { 14 | Writer *syslog.Writer 15 | SyslogNetwork string 16 | SyslogRaddr string 17 | } 18 | 19 | // Creates a hook to be added to an instance of logger. This is called with 20 | // `hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_DEBUG, "")` 21 | // `if err == nil { log.Hooks.Add(hook) }` 22 | func NewSyslogHook(network, raddr string, priority syslog.Priority, tag string) (*SyslogHook, error) { 23 | w, err := syslog.Dial(network, raddr, priority, tag) 24 | return &SyslogHook{w, network, raddr}, err 25 | } 26 | 27 | func (hook *SyslogHook) Fire(entry *logrus.Entry) error { 28 | line, err := entry.String() 29 | if err != nil { 30 | fmt.Fprintf(os.Stderr, "Unable to read entry, %v", err) 31 | return err 32 | } 33 | 34 | switch entry.Level { 35 | case logrus.PanicLevel: 36 | return hook.Writer.Crit(line) 37 | case logrus.FatalLevel: 38 | return hook.Writer.Crit(line) 39 | case logrus.ErrorLevel: 40 | return hook.Writer.Err(line) 41 | case logrus.WarnLevel: 42 | return hook.Writer.Warning(line) 43 | case logrus.InfoLevel: 44 | return hook.Writer.Info(line) 45 | case logrus.DebugLevel: 46 | return hook.Writer.Debug(line) 47 | default: 48 | return nil 49 | } 50 | } 51 | 52 | func (hook *SyslogHook) Levels() []logrus.Level { 53 | return logrus.AllLevels 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks/test/test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "io/ioutil" 5 | 6 | "github.com/Sirupsen/logrus" 7 | ) 8 | 9 | // test.Hook is a hook designed for dealing with logs in test scenarios. 10 | type Hook struct { 11 | Entries []*logrus.Entry 12 | } 13 | 14 | // Installs a test hook for the global logger. 15 | func NewGlobal() *Hook { 16 | 17 | hook := new(Hook) 18 | logrus.AddHook(hook) 19 | 20 | return hook 21 | 22 | } 23 | 24 | // Installs a test hook for a given local logger. 25 | func NewLocal(logger *logrus.Logger) *Hook { 26 | 27 | hook := new(Hook) 28 | logger.Hooks.Add(hook) 29 | 30 | return hook 31 | 32 | } 33 | 34 | // Creates a discarding logger and installs the test hook. 35 | func NewNullLogger() (*logrus.Logger, *Hook) { 36 | 37 | logger := logrus.New() 38 | logger.Out = ioutil.Discard 39 | 40 | return logger, NewLocal(logger) 41 | 42 | } 43 | 44 | func (t *Hook) Fire(e *logrus.Entry) error { 45 | t.Entries = append(t.Entries, e) 46 | return nil 47 | } 48 | 49 | func (t *Hook) Levels() []logrus.Level { 50 | return logrus.AllLevels 51 | } 52 | 53 | // LastEntry returns the last entry that was logged or nil. 54 | func (t *Hook) LastEntry() (l *logrus.Entry) { 55 | 56 | if i := len(t.Entries) - 1; i < 0 { 57 | return nil 58 | } else { 59 | return t.Entries[i] 60 | } 61 | 62 | } 63 | 64 | // Reset removes all Entries from this test hook. 65 | func (t *Hook) Reset() { 66 | t.Entries = make([]*logrus.Entry, 0) 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type JSONFormatter struct { 9 | // TimestampFormat sets the format used for marshaling timestamps. 10 | TimestampFormat string 11 | } 12 | 13 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 14 | data := make(Fields, len(entry.Data)+3) 15 | for k, v := range entry.Data { 16 | switch v := v.(type) { 17 | case error: 18 | // Otherwise errors are ignored by `encoding/json` 19 | // https://github.com/Sirupsen/logrus/issues/137 20 | data[k] = v.Error() 21 | default: 22 | data[k] = v 23 | } 24 | } 25 | prefixFieldClashes(data) 26 | 27 | timestampFormat := f.TimestampFormat 28 | if timestampFormat == "" { 29 | timestampFormat = DefaultTimestampFormat 30 | } 31 | 32 | data["time"] = entry.Time.Format(timestampFormat) 33 | data["msg"] = entry.Message 34 | data["level"] = entry.Level.String() 35 | 36 | serialized, err := json.Marshal(data) 37 | if err != nil { 38 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 39 | } 40 | return append(serialized, '\n'), nil 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package logrus 4 | 5 | // IsTerminal returns true if stderr's file descriptor is a terminal. 6 | func IsTerminal() bool { 7 | return true 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package logrus 5 | 6 | import "syscall" 7 | 8 | const ioctlReadTermios = syscall.TIOCGETA 9 | 10 | type Termios syscall.Termios 11 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build !appengine 7 | 8 | package logrus 9 | 10 | import "syscall" 11 | 12 | const ioctlReadTermios = syscall.TCGETS 13 | 14 | type Termios syscall.Termios 15 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build linux darwin freebsd openbsd netbsd dragonfly 7 | // +build !appengine 8 | 9 | package logrus 10 | 11 | import ( 12 | "syscall" 13 | "unsafe" 14 | ) 15 | 16 | // IsTerminal returns true if stderr's file descriptor is a terminal. 17 | func IsTerminal() bool { 18 | fd := syscall.Stderr 19 | var termios Termios 20 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 21 | return err == 0 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris,!appengine 2 | 3 | package logrus 4 | 5 | import ( 6 | "os" 7 | 8 | "golang.org/x/sys/unix" 9 | ) 10 | 11 | // IsTerminal returns true if the given file descriptor is a terminal. 12 | func IsTerminal() bool { 13 | _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA) 14 | return err == nil 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build windows,!appengine 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTerminal returns true if stderr's file descriptor is a terminal. 22 | func IsTerminal() bool { 23 | fd := syscall.Stderr 24 | var st uint32 25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 26 | return r != 0 && e == 0 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/writer.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "runtime" 7 | ) 8 | 9 | func (logger *Logger) Writer() *io.PipeWriter { 10 | return logger.WriterLevel(InfoLevel) 11 | } 12 | 13 | func (logger *Logger) WriterLevel(level Level) *io.PipeWriter { 14 | reader, writer := io.Pipe() 15 | 16 | var printFunc func(args ...interface{}) 17 | switch level { 18 | case DebugLevel: 19 | printFunc = logger.Debug 20 | case InfoLevel: 21 | printFunc = logger.Info 22 | case WarnLevel: 23 | printFunc = logger.Warn 24 | case ErrorLevel: 25 | printFunc = logger.Error 26 | case FatalLevel: 27 | printFunc = logger.Fatal 28 | case PanicLevel: 29 | printFunc = logger.Panic 30 | default: 31 | printFunc = logger.Print 32 | } 33 | 34 | go logger.writerScanner(reader, printFunc) 35 | runtime.SetFinalizer(writer, writerFinalizer) 36 | 37 | return writer 38 | } 39 | 40 | func (logger *Logger) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) { 41 | scanner := bufio.NewScanner(reader) 42 | for scanner.Scan() { 43 | printFunc(scanner.Text()) 44 | } 45 | if err := scanner.Err(); err != nil { 46 | logger.Errorf("Error while reading from Writer: %s", err) 47 | } 48 | reader.Close() 49 | } 50 | 51 | func writerFinalizer(writer *io.PipeWriter) { 52 | writer.Close() 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/chtimes.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "os" 5 | "syscall" 6 | "time" 7 | "unsafe" 8 | ) 9 | 10 | var ( 11 | maxTime time.Time 12 | ) 13 | 14 | func init() { 15 | if unsafe.Sizeof(syscall.Timespec{}.Nsec) == 8 { 16 | // This is a 64 bit timespec 17 | // os.Chtimes limits time to the following 18 | maxTime = time.Unix(0, 1<<63-1) 19 | } else { 20 | // This is a 32 bit timespec 21 | maxTime = time.Unix(1<<31-1, 0) 22 | } 23 | } 24 | 25 | // Chtimes changes the access time and modified time of a file at the given path 26 | func Chtimes(name string, atime time.Time, mtime time.Time) error { 27 | unixMinTime := time.Unix(0, 0) 28 | unixMaxTime := maxTime 29 | 30 | // If the modified time is prior to the Unix Epoch, or after the 31 | // end of Unix Time, os.Chtimes has undefined behavior 32 | // default to Unix Epoch in this case, just in case 33 | 34 | if atime.Before(unixMinTime) || atime.After(unixMaxTime) { 35 | atime = unixMinTime 36 | } 37 | 38 | if mtime.Before(unixMinTime) || mtime.After(unixMaxTime) { 39 | mtime = unixMinTime 40 | } 41 | 42 | if err := os.Chtimes(name, atime, mtime); err != nil { 43 | return err 44 | } 45 | 46 | // Take platform specific action for setting create time. 47 | if err := setCTime(name, mtime); err != nil { 48 | return err 49 | } 50 | 51 | return nil 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/chtimes_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "time" 7 | ) 8 | 9 | //setCTime will set the create time on a file. On Unix, the create 10 | //time is updated as a side effect of setting the modified time, so 11 | //no action is required. 12 | func setCTime(path string, ctime time.Time) error { 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/chtimes_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | "time" 8 | ) 9 | 10 | //setCTime will set the create time on a file. On Windows, this requires 11 | //calling SetFileTime and explicitly including the create time. 12 | func setCTime(path string, ctime time.Time) error { 13 | ctimespec := syscall.NsecToTimespec(ctime.UnixNano()) 14 | pathp, e := syscall.UTF16PtrFromString(path) 15 | if e != nil { 16 | return e 17 | } 18 | h, e := syscall.CreateFile(pathp, 19 | syscall.FILE_WRITE_ATTRIBUTES, syscall.FILE_SHARE_WRITE, nil, 20 | syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS, 0) 21 | if e != nil { 22 | return e 23 | } 24 | defer syscall.Close(h) 25 | c := syscall.NsecToFiletime(syscall.TimespecToNsec(ctimespec)) 26 | return syscall.SetFileTime(h, &c, nil, nil) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/errors.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | var ( 8 | // ErrNotSupportedPlatform means the platform is not supported. 9 | ErrNotSupportedPlatform = errors.New("platform and architecture is not supported") 10 | ) 11 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/events_windows.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | // This file implements syscalls for Win32 events which are not implemented 4 | // in golang. 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | var ( 12 | procCreateEvent = modkernel32.NewProc("CreateEventW") 13 | procOpenEvent = modkernel32.NewProc("OpenEventW") 14 | procSetEvent = modkernel32.NewProc("SetEvent") 15 | procResetEvent = modkernel32.NewProc("ResetEvent") 16 | procPulseEvent = modkernel32.NewProc("PulseEvent") 17 | ) 18 | 19 | // CreateEvent implements win32 CreateEventW func in golang. It will create an event object. 20 | func CreateEvent(eventAttributes *syscall.SecurityAttributes, manualReset bool, initialState bool, name string) (handle syscall.Handle, err error) { 21 | namep, _ := syscall.UTF16PtrFromString(name) 22 | var _p1 uint32 23 | if manualReset { 24 | _p1 = 1 25 | } 26 | var _p2 uint32 27 | if initialState { 28 | _p2 = 1 29 | } 30 | r0, _, e1 := procCreateEvent.Call(uintptr(unsafe.Pointer(eventAttributes)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(namep))) 31 | use(unsafe.Pointer(namep)) 32 | handle = syscall.Handle(r0) 33 | if handle == syscall.InvalidHandle { 34 | err = e1 35 | } 36 | return 37 | } 38 | 39 | // OpenEvent implements win32 OpenEventW func in golang. It opens an event object. 40 | func OpenEvent(desiredAccess uint32, inheritHandle bool, name string) (handle syscall.Handle, err error) { 41 | namep, _ := syscall.UTF16PtrFromString(name) 42 | var _p1 uint32 43 | if inheritHandle { 44 | _p1 = 1 45 | } 46 | r0, _, e1 := procOpenEvent.Call(uintptr(desiredAccess), uintptr(_p1), uintptr(unsafe.Pointer(namep))) 47 | use(unsafe.Pointer(namep)) 48 | handle = syscall.Handle(r0) 49 | if handle == syscall.InvalidHandle { 50 | err = e1 51 | } 52 | return 53 | } 54 | 55 | // SetEvent implements win32 SetEvent func in golang. 56 | func SetEvent(handle syscall.Handle) (err error) { 57 | return setResetPulse(handle, procSetEvent) 58 | } 59 | 60 | // ResetEvent implements win32 ResetEvent func in golang. 61 | func ResetEvent(handle syscall.Handle) (err error) { 62 | return setResetPulse(handle, procResetEvent) 63 | } 64 | 65 | // PulseEvent implements win32 PulseEvent func in golang. 66 | func PulseEvent(handle syscall.Handle) (err error) { 67 | return setResetPulse(handle, procPulseEvent) 68 | } 69 | 70 | func setResetPulse(handle syscall.Handle, proc *syscall.LazyProc) (err error) { 71 | r0, _, _ := proc.Call(uintptr(handle)) 72 | if r0 != 0 { 73 | err = syscall.Errno(r0) 74 | } 75 | return 76 | } 77 | 78 | var temp unsafe.Pointer 79 | 80 | // use ensures a variable is kept alive without the GC freeing while still needed 81 | func use(p unsafe.Pointer) { 82 | temp = p 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/filesys.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "os" 7 | "path/filepath" 8 | ) 9 | 10 | // MkdirAll creates a directory named path along with any necessary parents, 11 | // with permission specified by attribute perm for all dir created. 12 | func MkdirAll(path string, perm os.FileMode) error { 13 | return os.MkdirAll(path, perm) 14 | } 15 | 16 | // IsAbs is a platform-specific wrapper for filepath.IsAbs. 17 | func IsAbs(path string) bool { 18 | return filepath.IsAbs(path) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/filesys_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | import ( 6 | "os" 7 | "path/filepath" 8 | "regexp" 9 | "strings" 10 | "syscall" 11 | ) 12 | 13 | // MkdirAll implementation that is volume path aware for Windows. 14 | func MkdirAll(path string, perm os.FileMode) error { 15 | if re := regexp.MustCompile(`^\\\\\?\\Volume{[a-z0-9-]+}$`); re.MatchString(path) { 16 | return nil 17 | } 18 | 19 | // The rest of this method is copied from os.MkdirAll and should be kept 20 | // as-is to ensure compatibility. 21 | 22 | // Fast path: if we can tell whether path is a directory or file, stop with success or error. 23 | dir, err := os.Stat(path) 24 | if err == nil { 25 | if dir.IsDir() { 26 | return nil 27 | } 28 | return &os.PathError{ 29 | Op: "mkdir", 30 | Path: path, 31 | Err: syscall.ENOTDIR, 32 | } 33 | } 34 | 35 | // Slow path: make sure parent exists and then call Mkdir for path. 36 | i := len(path) 37 | for i > 0 && os.IsPathSeparator(path[i-1]) { // Skip trailing path separator. 38 | i-- 39 | } 40 | 41 | j := i 42 | for j > 0 && !os.IsPathSeparator(path[j-1]) { // Scan backward over element. 43 | j-- 44 | } 45 | 46 | if j > 1 { 47 | // Create parent 48 | err = MkdirAll(path[0:j-1], perm) 49 | if err != nil { 50 | return err 51 | } 52 | } 53 | 54 | // Parent now exists; invoke Mkdir and use its result. 55 | err = os.Mkdir(path, perm) 56 | if err != nil { 57 | // Handle arguments like "foo/." by 58 | // double-checking that directory doesn't exist. 59 | dir, err1 := os.Lstat(path) 60 | if err1 == nil && dir.IsDir() { 61 | return nil 62 | } 63 | return err 64 | } 65 | return nil 66 | } 67 | 68 | // IsAbs is a platform-specific wrapper for filepath.IsAbs. On Windows, 69 | // golang filepath.IsAbs does not consider a path \windows\system32 as absolute 70 | // as it doesn't start with a drive-letter/colon combination. However, in 71 | // docker we need to verify things such as WORKDIR /windows/system32 in 72 | // a Dockerfile (which gets translated to \windows\system32 when being processed 73 | // by the daemon. This SHOULD be treated as absolute from a docker processing 74 | // perspective. 75 | func IsAbs(path string) bool { 76 | if !filepath.IsAbs(path) { 77 | if !strings.HasPrefix(path, string(os.PathSeparator)) { 78 | return false 79 | } 80 | } 81 | return true 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/lstat.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // Lstat takes a path to a file and returns 10 | // a system.StatT type pertaining to that file. 11 | // 12 | // Throws an error if the file does not exist 13 | func Lstat(path string) (*StatT, error) { 14 | s := &syscall.Stat_t{} 15 | if err := syscall.Lstat(path, s); err != nil { 16 | return nil, err 17 | } 18 | return fromStatT(s) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/lstat_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | import ( 6 | "os" 7 | ) 8 | 9 | // Lstat calls os.Lstat to get a fileinfo interface back. 10 | // This is then copied into our own locally defined structure. 11 | // Note the Linux version uses fromStatT to do the copy back, 12 | // but that not strictly necessary when already in an OS specific module. 13 | func Lstat(path string) (*StatT, error) { 14 | fi, err := os.Lstat(path) 15 | if err != nil { 16 | return nil, err 17 | } 18 | 19 | return &StatT{ 20 | name: fi.Name(), 21 | size: fi.Size(), 22 | mode: fi.Mode(), 23 | modTime: fi.ModTime(), 24 | isDir: fi.IsDir()}, nil 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/meminfo.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | // MemInfo contains memory statistics of the host system. 4 | type MemInfo struct { 5 | // Total usable RAM (i.e. physical RAM minus a few reserved bits and the 6 | // kernel binary code). 7 | MemTotal int64 8 | 9 | // Amount of free memory. 10 | MemFree int64 11 | 12 | // Total amount of swap space available. 13 | SwapTotal int64 14 | 15 | // Amount of swap space that is currently unused. 16 | SwapFree int64 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/meminfo_linux.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "os" 7 | "strconv" 8 | "strings" 9 | 10 | "github.com/docker/go-units" 11 | ) 12 | 13 | // ReadMemInfo retrieves memory statistics of the host system and returns a 14 | // MemInfo type. 15 | func ReadMemInfo() (*MemInfo, error) { 16 | file, err := os.Open("/proc/meminfo") 17 | if err != nil { 18 | return nil, err 19 | } 20 | defer file.Close() 21 | return parseMemInfo(file) 22 | } 23 | 24 | // parseMemInfo parses the /proc/meminfo file into 25 | // a MemInfo object given an io.Reader to the file. 26 | // Throws error if there are problems reading from the file 27 | func parseMemInfo(reader io.Reader) (*MemInfo, error) { 28 | meminfo := &MemInfo{} 29 | scanner := bufio.NewScanner(reader) 30 | for scanner.Scan() { 31 | // Expected format: ["MemTotal:", "1234", "kB"] 32 | parts := strings.Fields(scanner.Text()) 33 | 34 | // Sanity checks: Skip malformed entries. 35 | if len(parts) < 3 || parts[2] != "kB" { 36 | continue 37 | } 38 | 39 | // Convert to bytes. 40 | size, err := strconv.Atoi(parts[1]) 41 | if err != nil { 42 | continue 43 | } 44 | bytes := int64(size) * units.KiB 45 | 46 | switch parts[0] { 47 | case "MemTotal:": 48 | meminfo.MemTotal = bytes 49 | case "MemFree:": 50 | meminfo.MemFree = bytes 51 | case "SwapTotal:": 52 | meminfo.SwapTotal = bytes 53 | case "SwapFree:": 54 | meminfo.SwapFree = bytes 55 | } 56 | 57 | } 58 | 59 | // Handle errors that may have occurred during the reading of the file. 60 | if err := scanner.Err(); err != nil { 61 | return nil, err 62 | } 63 | 64 | return meminfo, nil 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/meminfo_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux,!windows 2 | 3 | package system 4 | 5 | // ReadMemInfo is not supported on platforms other than linux and windows. 6 | func ReadMemInfo() (*MemInfo, error) { 7 | return nil, ErrNotSupportedPlatform 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/meminfo_windows.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | var ( 9 | modkernel32 = syscall.NewLazyDLL("kernel32.dll") 10 | 11 | procGlobalMemoryStatusEx = modkernel32.NewProc("GlobalMemoryStatusEx") 12 | ) 13 | 14 | // https://msdn.microsoft.com/en-us/library/windows/desktop/aa366589(v=vs.85).aspx 15 | // https://msdn.microsoft.com/en-us/library/windows/desktop/aa366770(v=vs.85).aspx 16 | type memorystatusex struct { 17 | dwLength uint32 18 | dwMemoryLoad uint32 19 | ullTotalPhys uint64 20 | ullAvailPhys uint64 21 | ullTotalPageFile uint64 22 | ullAvailPageFile uint64 23 | ullTotalVirtual uint64 24 | ullAvailVirtual uint64 25 | ullAvailExtendedVirtual uint64 26 | } 27 | 28 | // ReadMemInfo retrieves memory statistics of the host system and returns a 29 | // MemInfo type. 30 | func ReadMemInfo() (*MemInfo, error) { 31 | msi := &memorystatusex{ 32 | dwLength: 64, 33 | } 34 | r1, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(msi))) 35 | if r1 == 0 { 36 | return &MemInfo{}, nil 37 | } 38 | return &MemInfo{ 39 | MemTotal: int64(msi.ullTotalPhys), 40 | MemFree: int64(msi.ullAvailPhys), 41 | SwapTotal: int64(msi.ullTotalPageFile), 42 | SwapFree: int64(msi.ullAvailPageFile), 43 | }, nil 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/mknod.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // Mknod creates a filesystem node (file, device special file or named pipe) named path 10 | // with attributes specified by mode and dev. 11 | func Mknod(path string, mode uint32, dev int) error { 12 | return syscall.Mknod(path, mode, dev) 13 | } 14 | 15 | // Mkdev is used to build the value of linux devices (in /dev/) which specifies major 16 | // and minor number of the newly created device special file. 17 | // Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes. 18 | // They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major, 19 | // then the top 12 bits of the minor. 20 | func Mkdev(major int64, minor int64) uint32 { 21 | return uint32(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff)) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/mknod_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | // Mknod is not implemented on Windows. 6 | func Mknod(path string, mode uint32, dev int) error { 7 | return ErrNotSupportedPlatform 8 | } 9 | 10 | // Mkdev is not implemented on Windows. 11 | func Mkdev(major int64, minor int64) uint32 { 12 | panic("Mkdev not implemented on Windows.") 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/path_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | // DefaultPathEnv is unix style list of directories to search for 6 | // executables. Each directory is separated from the next by a colon 7 | // ':' character . 8 | const DefaultPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 9 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/path_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | // DefaultPathEnv is deliberately empty on Windows as the default path will be set by 6 | // the container. Docker has no context of what the default path should be. 7 | const DefaultPathEnv = "" 8 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/stat.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // StatT type contains status of a file. It contains metadata 10 | // like permission, owner, group, size, etc about a file. 11 | type StatT struct { 12 | mode uint32 13 | uid uint32 14 | gid uint32 15 | rdev uint64 16 | size int64 17 | mtim syscall.Timespec 18 | } 19 | 20 | // Mode returns file's permission mode. 21 | func (s StatT) Mode() uint32 { 22 | return s.mode 23 | } 24 | 25 | // UID returns file's user id of owner. 26 | func (s StatT) UID() uint32 { 27 | return s.uid 28 | } 29 | 30 | // GID returns file's group id of owner. 31 | func (s StatT) GID() uint32 { 32 | return s.gid 33 | } 34 | 35 | // Rdev returns file's device ID (if it's special file). 36 | func (s StatT) Rdev() uint64 { 37 | return s.rdev 38 | } 39 | 40 | // Size returns file's size. 41 | func (s StatT) Size() int64 { 42 | return s.size 43 | } 44 | 45 | // Mtim returns file's last modification time. 46 | func (s StatT) Mtim() syscall.Timespec { 47 | return s.mtim 48 | } 49 | 50 | // GetLastModification returns file's last modification time. 51 | func (s StatT) GetLastModification() syscall.Timespec { 52 | return s.Mtim() 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/stat_freebsd.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | // fromStatT converts a syscall.Stat_t type to a system.Stat_t type 8 | func fromStatT(s *syscall.Stat_t) (*StatT, error) { 9 | return &StatT{size: s.Size, 10 | mode: uint32(s.Mode), 11 | uid: s.Uid, 12 | gid: s.Gid, 13 | rdev: uint64(s.Rdev), 14 | mtim: s.Mtimespec}, nil 15 | } 16 | 17 | // Stat takes a path to a file and returns 18 | // a system.Stat_t type pertaining to that file. 19 | // 20 | // Throws an error if the file does not exist 21 | func Stat(path string) (*StatT, error) { 22 | s := &syscall.Stat_t{} 23 | if err := syscall.Stat(path, s); err != nil { 24 | return nil, err 25 | } 26 | return fromStatT(s) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/stat_linux.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | // fromStatT converts a syscall.Stat_t type to a system.Stat_t type 8 | func fromStatT(s *syscall.Stat_t) (*StatT, error) { 9 | return &StatT{size: s.Size, 10 | mode: s.Mode, 11 | uid: s.Uid, 12 | gid: s.Gid, 13 | rdev: s.Rdev, 14 | mtim: s.Mtim}, nil 15 | } 16 | 17 | // FromStatT exists only on linux, and loads a system.StatT from a 18 | // syscal.Stat_t. 19 | func FromStatT(s *syscall.Stat_t) (*StatT, error) { 20 | return fromStatT(s) 21 | } 22 | 23 | // Stat takes a path to a file and returns 24 | // a system.StatT type pertaining to that file. 25 | // 26 | // Throws an error if the file does not exist 27 | func Stat(path string) (*StatT, error) { 28 | s := &syscall.Stat_t{} 29 | if err := syscall.Stat(path, s); err != nil { 30 | return nil, err 31 | } 32 | return fromStatT(s) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/stat_openbsd.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | // fromStatT creates a system.StatT type from a syscall.Stat_t type 8 | func fromStatT(s *syscall.Stat_t) (*StatT, error) { 9 | return &StatT{size: s.Size, 10 | mode: uint32(s.Mode), 11 | uid: s.Uid, 12 | gid: s.Gid, 13 | rdev: uint64(s.Rdev), 14 | mtim: s.Mtim}, nil 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/stat_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // fromStatT creates a system.StatT type from a syscall.Stat_t type 10 | func fromStatT(s *syscall.Stat_t) (*StatT, error) { 11 | return &StatT{size: s.Size, 12 | mode: uint32(s.Mode), 13 | uid: s.Uid, 14 | gid: s.Gid, 15 | rdev: uint64(s.Rdev), 16 | mtim: s.Mtim}, nil 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/stat_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux,!windows,!freebsd,!solaris,!openbsd 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // fromStatT creates a system.StatT type from a syscall.Stat_t type 10 | func fromStatT(s *syscall.Stat_t) (*StatT, error) { 11 | return &StatT{size: s.Size, 12 | mode: uint32(s.Mode), 13 | uid: s.Uid, 14 | gid: s.Gid, 15 | rdev: uint64(s.Rdev), 16 | mtim: s.Mtimespec}, nil 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/stat_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | import ( 6 | "os" 7 | "time" 8 | ) 9 | 10 | // StatT type contains status of a file. It contains metadata 11 | // like name, permission, size, etc about a file. 12 | type StatT struct { 13 | name string 14 | size int64 15 | mode os.FileMode 16 | modTime time.Time 17 | isDir bool 18 | } 19 | 20 | // Name returns file's name. 21 | func (s StatT) Name() string { 22 | return s.name 23 | } 24 | 25 | // Size returns file's size. 26 | func (s StatT) Size() int64 { 27 | return s.size 28 | } 29 | 30 | // Mode returns file's permission mode. 31 | func (s StatT) Mode() os.FileMode { 32 | return s.mode 33 | } 34 | 35 | // ModTime returns file's last modification time. 36 | func (s StatT) ModTime() time.Time { 37 | return s.modTime 38 | } 39 | 40 | // IsDir returns whether file is actually a directory. 41 | func (s StatT) IsDir() bool { 42 | return s.isDir 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/syscall_unix.go: -------------------------------------------------------------------------------- 1 | // +build linux freebsd 2 | 3 | package system 4 | 5 | import "syscall" 6 | 7 | // Unmount is a platform-specific helper function to call 8 | // the unmount syscall. 9 | func Unmount(dest string) error { 10 | return syscall.Unmount(dest, 0) 11 | } 12 | 13 | // CommandLineToArgv should not be used on Unix. 14 | // It simply returns commandLine in the only element in the returned array. 15 | func CommandLineToArgv(commandLine string) ([]string, error) { 16 | return []string{commandLine}, nil 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/syscall_windows.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | var ( 9 | ntuserApiset = syscall.NewLazyDLL("ext-ms-win-ntuser-window-l1-1-0") 10 | ) 11 | 12 | // OSVersion is a wrapper for Windows version information 13 | // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx 14 | type OSVersion struct { 15 | Version uint32 16 | MajorVersion uint8 17 | MinorVersion uint8 18 | Build uint16 19 | } 20 | 21 | // GetOSVersion gets the operating system version on Windows. Note that 22 | // docker.exe must be manifested to get the correct version information. 23 | func GetOSVersion() OSVersion { 24 | var err error 25 | osv := OSVersion{} 26 | osv.Version, err = syscall.GetVersion() 27 | if err != nil { 28 | // GetVersion never fails. 29 | panic(err) 30 | } 31 | osv.MajorVersion = uint8(osv.Version & 0xFF) 32 | osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF) 33 | osv.Build = uint16(osv.Version >> 16) 34 | return osv 35 | } 36 | 37 | // Unmount is a platform-specific helper function to call 38 | // the unmount syscall. Not supported on Windows 39 | func Unmount(dest string) error { 40 | return nil 41 | } 42 | 43 | // CommandLineToArgv wraps the Windows syscall to turn a commandline into an argument array. 44 | func CommandLineToArgv(commandLine string) ([]string, error) { 45 | var argc int32 46 | 47 | argsPtr, err := syscall.UTF16PtrFromString(commandLine) 48 | if err != nil { 49 | return nil, err 50 | } 51 | 52 | argv, err := syscall.CommandLineToArgv(argsPtr, &argc) 53 | if err != nil { 54 | return nil, err 55 | } 56 | defer syscall.LocalFree(syscall.Handle(uintptr(unsafe.Pointer(argv)))) 57 | 58 | newArgs := make([]string, argc) 59 | for i, v := range (*argv)[:argc] { 60 | newArgs[i] = string(syscall.UTF16ToString((*v)[:])) 61 | } 62 | 63 | return newArgs, nil 64 | } 65 | 66 | // HasWin32KSupport determines whether containers that depend on win32k can 67 | // run on this machine. Win32k is the driver used to implement windowing. 68 | func HasWin32KSupport() bool { 69 | // For now, check for ntuser API support on the host. In the future, a host 70 | // may support win32k in containers even if the host does not support ntuser 71 | // APIs. 72 | return ntuserApiset.Load() == nil 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/umask.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // Umask sets current process's file mode creation mask to newmask 10 | // and returns oldmask. 11 | func Umask(newmask int) (oldmask int, err error) { 12 | return syscall.Umask(newmask), nil 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/umask_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | // Umask is not supported on the windows platform. 6 | func Umask(newmask int) (oldmask int, err error) { 7 | // should not be called on cli code path 8 | return 0, ErrNotSupportedPlatform 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/utimes_darwin.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import "syscall" 4 | 5 | // LUtimesNano is not supported by darwin platform. 6 | func LUtimesNano(path string, ts []syscall.Timespec) error { 7 | return ErrNotSupportedPlatform 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/utimes_freebsd.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | // LUtimesNano is used to change access and modification time of the specified path. 9 | // It's used for symbol link file because syscall.UtimesNano doesn't support a NOFOLLOW flag atm. 10 | func LUtimesNano(path string, ts []syscall.Timespec) error { 11 | var _path *byte 12 | _path, err := syscall.BytePtrFromString(path) 13 | if err != nil { 14 | return err 15 | } 16 | 17 | if _, _, err := syscall.Syscall(syscall.SYS_LUTIMES, uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), 0); err != 0 && err != syscall.ENOSYS { 18 | return err 19 | } 20 | 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/utimes_linux.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | // LUtimesNano is used to change access and modification time of the specified path. 9 | // It's used for symbol link file because syscall.UtimesNano doesn't support a NOFOLLOW flag atm. 10 | func LUtimesNano(path string, ts []syscall.Timespec) error { 11 | // These are not currently available in syscall 12 | atFdCwd := -100 13 | atSymLinkNoFollow := 0x100 14 | 15 | var _path *byte 16 | _path, err := syscall.BytePtrFromString(path) 17 | if err != nil { 18 | return err 19 | } 20 | 21 | if _, _, err := syscall.Syscall6(syscall.SYS_UTIMENSAT, uintptr(atFdCwd), uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), uintptr(atSymLinkNoFollow), 0, 0); err != 0 && err != syscall.ENOSYS { 22 | return err 23 | } 24 | 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/utimes_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux,!freebsd,!darwin 2 | 3 | package system 4 | 5 | import "syscall" 6 | 7 | // LUtimesNano is not supported on platforms other than linux, freebsd and darwin. 8 | func LUtimesNano(path string, ts []syscall.Timespec) error { 9 | return ErrNotSupportedPlatform 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/xattrs_linux.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | // Lgetxattr retrieves the value of the extended attribute identified by attr 9 | // and associated with the given path in the file system. 10 | // It will returns a nil slice and nil error if the xattr is not set. 11 | func Lgetxattr(path string, attr string) ([]byte, error) { 12 | pathBytes, err := syscall.BytePtrFromString(path) 13 | if err != nil { 14 | return nil, err 15 | } 16 | attrBytes, err := syscall.BytePtrFromString(attr) 17 | if err != nil { 18 | return nil, err 19 | } 20 | 21 | dest := make([]byte, 128) 22 | destBytes := unsafe.Pointer(&dest[0]) 23 | sz, _, errno := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0) 24 | if errno == syscall.ENODATA { 25 | return nil, nil 26 | } 27 | if errno == syscall.ERANGE { 28 | dest = make([]byte, sz) 29 | destBytes := unsafe.Pointer(&dest[0]) 30 | sz, _, errno = syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0) 31 | } 32 | if errno != 0 { 33 | return nil, errno 34 | } 35 | 36 | return dest[:sz], nil 37 | } 38 | 39 | var _zero uintptr 40 | 41 | // Lsetxattr sets the value of the extended attribute identified by attr 42 | // and associated with the given path in the file system. 43 | func Lsetxattr(path string, attr string, data []byte, flags int) error { 44 | pathBytes, err := syscall.BytePtrFromString(path) 45 | if err != nil { 46 | return err 47 | } 48 | attrBytes, err := syscall.BytePtrFromString(attr) 49 | if err != nil { 50 | return err 51 | } 52 | var dataBytes unsafe.Pointer 53 | if len(data) > 0 { 54 | dataBytes = unsafe.Pointer(&data[0]) 55 | } else { 56 | dataBytes = unsafe.Pointer(&_zero) 57 | } 58 | _, _, errno := syscall.Syscall6(syscall.SYS_LSETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(dataBytes), uintptr(len(data)), uintptr(flags), 0) 59 | if errno != 0 { 60 | return errno 61 | } 62 | return nil 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/system/xattrs_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package system 4 | 5 | // Lgetxattr is not supported on platforms other than linux. 6 | func Lgetxattr(path string, attr string) ([]byte, error) { 7 | return nil, ErrNotSupportedPlatform 8 | } 9 | 10 | // Lsetxattr is not supported on platforms other than linux. 11 | func Lsetxattr(path string, attr string, data []byte, flags int) error { 12 | return ErrNotSupportedPlatform 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/ascii.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // ASCII list the possible supported ASCII key sequence 9 | var ASCII = []string{ 10 | "ctrl-@", 11 | "ctrl-a", 12 | "ctrl-b", 13 | "ctrl-c", 14 | "ctrl-d", 15 | "ctrl-e", 16 | "ctrl-f", 17 | "ctrl-g", 18 | "ctrl-h", 19 | "ctrl-i", 20 | "ctrl-j", 21 | "ctrl-k", 22 | "ctrl-l", 23 | "ctrl-m", 24 | "ctrl-n", 25 | "ctrl-o", 26 | "ctrl-p", 27 | "ctrl-q", 28 | "ctrl-r", 29 | "ctrl-s", 30 | "ctrl-t", 31 | "ctrl-u", 32 | "ctrl-v", 33 | "ctrl-w", 34 | "ctrl-x", 35 | "ctrl-y", 36 | "ctrl-z", 37 | "ctrl-[", 38 | "ctrl-\\", 39 | "ctrl-]", 40 | "ctrl-^", 41 | "ctrl-_", 42 | } 43 | 44 | // ToBytes converts a string representing a suite of key-sequence to the corresponding ASCII code. 45 | func ToBytes(keys string) ([]byte, error) { 46 | codes := []byte{} 47 | next: 48 | for _, key := range strings.Split(keys, ",") { 49 | if len(key) != 1 { 50 | for code, ctrl := range ASCII { 51 | if ctrl == key { 52 | codes = append(codes, byte(code)) 53 | continue next 54 | } 55 | } 56 | if key == "DEL" { 57 | codes = append(codes, 127) 58 | } else { 59 | return nil, fmt.Errorf("Unknown character: '%s'", key) 60 | } 61 | } else { 62 | codes = append(codes, byte(key[0])) 63 | } 64 | } 65 | return codes, nil 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/tc_linux_cgo.go: -------------------------------------------------------------------------------- 1 | // +build linux,cgo 2 | 3 | package term 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | // #include 11 | import "C" 12 | 13 | // Termios is the Unix API for terminal I/O. 14 | // It is passthrough for syscall.Termios in order to make it portable with 15 | // other platforms where it is not available or handled differently. 16 | type Termios syscall.Termios 17 | 18 | // MakeRaw put the terminal connected to the given file descriptor into raw 19 | // mode and returns the previous state of the terminal so that it can be 20 | // restored. 21 | func MakeRaw(fd uintptr) (*State, error) { 22 | var oldState State 23 | if err := tcget(fd, &oldState.termios); err != 0 { 24 | return nil, err 25 | } 26 | 27 | newState := oldState.termios 28 | 29 | C.cfmakeraw((*C.struct_termios)(unsafe.Pointer(&newState))) 30 | if err := tcset(fd, &newState); err != 0 { 31 | return nil, err 32 | } 33 | return &oldState, nil 34 | } 35 | 36 | func tcget(fd uintptr, p *Termios) syscall.Errno { 37 | ret, err := C.tcgetattr(C.int(fd), (*C.struct_termios)(unsafe.Pointer(p))) 38 | if ret != 0 { 39 | return err.(syscall.Errno) 40 | } 41 | return 0 42 | } 43 | 44 | func tcset(fd uintptr, p *Termios) syscall.Errno { 45 | ret, err := C.tcsetattr(C.int(fd), C.TCSANOW, (*C.struct_termios)(unsafe.Pointer(p))) 46 | if ret != 0 { 47 | return err.(syscall.Errno) 48 | } 49 | return 0 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/tc_other.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !linux !cgo 3 | // +build !solaris !cgo 4 | 5 | package term 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func tcget(fd uintptr, p *Termios) syscall.Errno { 13 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(p))) 14 | return err 15 | } 16 | 17 | func tcset(fd uintptr, p *Termios) syscall.Errno { 18 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, setTermios, uintptr(unsafe.Pointer(p))) 19 | return err 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/tc_solaris_cgo.go: -------------------------------------------------------------------------------- 1 | // +build solaris,cgo 2 | 3 | package term 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | // #include 11 | import "C" 12 | 13 | // Termios is the Unix API for terminal I/O. 14 | // It is passthrough for syscall.Termios in order to make it portable with 15 | // other platforms where it is not available or handled differently. 16 | type Termios syscall.Termios 17 | 18 | // MakeRaw put the terminal connected to the given file descriptor into raw 19 | // mode and returns the previous state of the terminal so that it can be 20 | // restored. 21 | func MakeRaw(fd uintptr) (*State, error) { 22 | var oldState State 23 | if err := tcget(fd, &oldState.termios); err != 0 { 24 | return nil, err 25 | } 26 | 27 | newState := oldState.termios 28 | 29 | newState.Iflag &^= (syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON | syscall.IXANY) 30 | newState.Oflag &^= syscall.OPOST 31 | newState.Lflag &^= (syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN) 32 | newState.Cflag &^= (syscall.CSIZE | syscall.PARENB) 33 | newState.Cflag |= syscall.CS8 34 | 35 | /* 36 | VMIN is the minimum number of characters that needs to be read in non-canonical mode for it to be returned 37 | Since VMIN is overloaded with another element in canonical mode when we switch modes it defaults to 4. It 38 | needs to be explicitly set to 1. 39 | */ 40 | newState.Cc[C.VMIN] = 1 41 | newState.Cc[C.VTIME] = 0 42 | 43 | if err := tcset(fd, &newState); err != 0 { 44 | return nil, err 45 | } 46 | return &oldState, nil 47 | } 48 | 49 | func tcget(fd uintptr, p *Termios) syscall.Errno { 50 | ret, err := C.tcgetattr(C.int(fd), (*C.struct_termios)(unsafe.Pointer(p))) 51 | if ret != 0 { 52 | return err.(syscall.Errno) 53 | } 54 | return 0 55 | } 56 | 57 | func tcset(fd uintptr, p *Termios) syscall.Errno { 58 | ret, err := C.tcsetattr(C.int(fd), C.TCSANOW, (*C.struct_termios)(unsafe.Pointer(p))) 59 | if ret != 0 { 60 | return err.(syscall.Errno) 61 | } 62 | return 0 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/term.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | // Package term provides provides structures and helper functions to work with 4 | // terminal (state, sizes). 5 | package term 6 | 7 | import ( 8 | "errors" 9 | "io" 10 | "os" 11 | "os/signal" 12 | "syscall" 13 | ) 14 | 15 | var ( 16 | // ErrInvalidState is returned if the state of the terminal is invalid. 17 | ErrInvalidState = errors.New("Invalid terminal state") 18 | ) 19 | 20 | // State represents the state of the terminal. 21 | type State struct { 22 | termios Termios 23 | } 24 | 25 | // Winsize represents the size of the terminal window. 26 | type Winsize struct { 27 | Height uint16 28 | Width uint16 29 | x uint16 30 | y uint16 31 | } 32 | 33 | // StdStreams returns the standard streams (stdin, stdout, stedrr). 34 | func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) { 35 | return os.Stdin, os.Stdout, os.Stderr 36 | } 37 | 38 | // GetFdInfo returns the file descriptor for an os.File and indicates whether the file represents a terminal. 39 | func GetFdInfo(in interface{}) (uintptr, bool) { 40 | var inFd uintptr 41 | var isTerminalIn bool 42 | if file, ok := in.(*os.File); ok { 43 | inFd = file.Fd() 44 | isTerminalIn = IsTerminal(inFd) 45 | } 46 | return inFd, isTerminalIn 47 | } 48 | 49 | // IsTerminal returns true if the given file descriptor is a terminal. 50 | func IsTerminal(fd uintptr) bool { 51 | var termios Termios 52 | return tcget(fd, &termios) == 0 53 | } 54 | 55 | // RestoreTerminal restores the terminal connected to the given file descriptor 56 | // to a previous state. 57 | func RestoreTerminal(fd uintptr, state *State) error { 58 | if state == nil { 59 | return ErrInvalidState 60 | } 61 | if err := tcset(fd, &state.termios); err != 0 { 62 | return err 63 | } 64 | return nil 65 | } 66 | 67 | // SaveState saves the state of the terminal connected to the given file descriptor. 68 | func SaveState(fd uintptr) (*State, error) { 69 | var oldState State 70 | if err := tcget(fd, &oldState.termios); err != 0 { 71 | return nil, err 72 | } 73 | 74 | return &oldState, nil 75 | } 76 | 77 | // DisableEcho applies the specified state to the terminal connected to the file 78 | // descriptor, with echo disabled. 79 | func DisableEcho(fd uintptr, state *State) error { 80 | newState := state.termios 81 | newState.Lflag &^= syscall.ECHO 82 | 83 | if err := tcset(fd, &newState); err != 0 { 84 | return err 85 | } 86 | handleInterrupt(fd, state) 87 | return nil 88 | } 89 | 90 | // SetRawTerminal puts the terminal connected to the given file descriptor into 91 | // raw mode and returns the previous state. 92 | func SetRawTerminal(fd uintptr) (*State, error) { 93 | oldState, err := MakeRaw(fd) 94 | if err != nil { 95 | return nil, err 96 | } 97 | handleInterrupt(fd, oldState) 98 | return oldState, err 99 | } 100 | 101 | func handleInterrupt(fd uintptr, state *State) { 102 | sigchan := make(chan os.Signal, 1) 103 | signal.Notify(sigchan, os.Interrupt) 104 | 105 | go func() { 106 | _ = <-sigchan 107 | RestoreTerminal(fd, state) 108 | }() 109 | } 110 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/term_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | 3 | package term 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | /* 11 | #include 12 | #include 13 | #include 14 | 15 | // Small wrapper to get rid of variadic args of ioctl() 16 | int my_ioctl(int fd, int cmd, struct winsize *ws) { 17 | return ioctl(fd, cmd, ws); 18 | } 19 | */ 20 | import "C" 21 | 22 | // GetWinsize returns the window size based on the specified file descriptor. 23 | func GetWinsize(fd uintptr) (*Winsize, error) { 24 | ws := &Winsize{} 25 | ret, err := C.my_ioctl(C.int(fd), C.int(syscall.TIOCGWINSZ), (*C.struct_winsize)(unsafe.Pointer(ws))) 26 | // Skip retval = 0 27 | if ret == 0 { 28 | return ws, nil 29 | } 30 | return ws, err 31 | } 32 | 33 | // SetWinsize tries to set the specified window size for the specified file descriptor. 34 | func SetWinsize(fd uintptr, ws *Winsize) error { 35 | ret, err := C.my_ioctl(C.int(fd), C.int(syscall.TIOCSWINSZ), (*C.struct_winsize)(unsafe.Pointer(ws))) 36 | // Skip retval = 0 37 | if ret == 0 { 38 | return nil 39 | } 40 | return err 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/term_unix.go: -------------------------------------------------------------------------------- 1 | // +build !solaris,!windows 2 | 3 | package term 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | // GetWinsize returns the window size based on the specified file descriptor. 11 | func GetWinsize(fd uintptr) (*Winsize, error) { 12 | ws := &Winsize{} 13 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(ws))) 14 | // Skipp errno = 0 15 | if err == 0 { 16 | return ws, nil 17 | } 18 | return ws, err 19 | } 20 | 21 | // SetWinsize tries to set the specified window size for the specified file descriptor. 22 | func SetWinsize(fd uintptr, ws *Winsize) error { 23 | _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCSWINSZ), uintptr(unsafe.Pointer(ws))) 24 | // Skipp errno = 0 25 | if err == 0 { 26 | return nil 27 | } 28 | return err 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/termios_darwin.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | const ( 9 | getTermios = syscall.TIOCGETA 10 | setTermios = syscall.TIOCSETA 11 | ) 12 | 13 | // Termios magic numbers, passthrough to the ones defined in syscall. 14 | const ( 15 | IGNBRK = syscall.IGNBRK 16 | PARMRK = syscall.PARMRK 17 | INLCR = syscall.INLCR 18 | IGNCR = syscall.IGNCR 19 | ECHONL = syscall.ECHONL 20 | CSIZE = syscall.CSIZE 21 | ICRNL = syscall.ICRNL 22 | ISTRIP = syscall.ISTRIP 23 | PARENB = syscall.PARENB 24 | ECHO = syscall.ECHO 25 | ICANON = syscall.ICANON 26 | ISIG = syscall.ISIG 27 | IXON = syscall.IXON 28 | BRKINT = syscall.BRKINT 29 | INPCK = syscall.INPCK 30 | OPOST = syscall.OPOST 31 | CS8 = syscall.CS8 32 | IEXTEN = syscall.IEXTEN 33 | ) 34 | 35 | // Termios is the Unix API for terminal I/O. 36 | type Termios struct { 37 | Iflag uint64 38 | Oflag uint64 39 | Cflag uint64 40 | Lflag uint64 41 | Cc [20]byte 42 | Ispeed uint64 43 | Ospeed uint64 44 | } 45 | 46 | // MakeRaw put the terminal connected to the given file descriptor into raw 47 | // mode and returns the previous state of the terminal so that it can be 48 | // restored. 49 | func MakeRaw(fd uintptr) (*State, error) { 50 | var oldState State 51 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { 52 | return nil, err 53 | } 54 | 55 | newState := oldState.termios 56 | newState.Iflag &^= (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON) 57 | newState.Oflag &^= OPOST 58 | newState.Lflag &^= (ECHO | ECHONL | ICANON | ISIG | IEXTEN) 59 | newState.Cflag &^= (CSIZE | PARENB) 60 | newState.Cflag |= CS8 61 | newState.Cc[syscall.VMIN] = 1 62 | newState.Cc[syscall.VTIME] = 0 63 | 64 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&newState))); err != 0 { 65 | return nil, err 66 | } 67 | 68 | return &oldState, nil 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/termios_freebsd.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | const ( 9 | getTermios = syscall.TIOCGETA 10 | setTermios = syscall.TIOCSETA 11 | ) 12 | 13 | // Termios magic numbers, passthrough to the ones defined in syscall. 14 | const ( 15 | IGNBRK = syscall.IGNBRK 16 | PARMRK = syscall.PARMRK 17 | INLCR = syscall.INLCR 18 | IGNCR = syscall.IGNCR 19 | ECHONL = syscall.ECHONL 20 | CSIZE = syscall.CSIZE 21 | ICRNL = syscall.ICRNL 22 | ISTRIP = syscall.ISTRIP 23 | PARENB = syscall.PARENB 24 | ECHO = syscall.ECHO 25 | ICANON = syscall.ICANON 26 | ISIG = syscall.ISIG 27 | IXON = syscall.IXON 28 | BRKINT = syscall.BRKINT 29 | INPCK = syscall.INPCK 30 | OPOST = syscall.OPOST 31 | CS8 = syscall.CS8 32 | IEXTEN = syscall.IEXTEN 33 | ) 34 | 35 | // Termios is the Unix API for terminal I/O. 36 | type Termios struct { 37 | Iflag uint32 38 | Oflag uint32 39 | Cflag uint32 40 | Lflag uint32 41 | Cc [20]byte 42 | Ispeed uint32 43 | Ospeed uint32 44 | } 45 | 46 | // MakeRaw put the terminal connected to the given file descriptor into raw 47 | // mode and returns the previous state of the terminal so that it can be 48 | // restored. 49 | func MakeRaw(fd uintptr) (*State, error) { 50 | var oldState State 51 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { 52 | return nil, err 53 | } 54 | 55 | newState := oldState.termios 56 | newState.Iflag &^= (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON) 57 | newState.Oflag &^= OPOST 58 | newState.Lflag &^= (ECHO | ECHONL | ICANON | ISIG | IEXTEN) 59 | newState.Cflag &^= (CSIZE | PARENB) 60 | newState.Cflag |= CS8 61 | newState.Cc[syscall.VMIN] = 1 62 | newState.Cc[syscall.VTIME] = 0 63 | 64 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&newState))); err != 0 { 65 | return nil, err 66 | } 67 | 68 | return &oldState, nil 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/termios_linux.go: -------------------------------------------------------------------------------- 1 | // +build !cgo 2 | 3 | package term 4 | 5 | import ( 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | const ( 11 | getTermios = syscall.TCGETS 12 | setTermios = syscall.TCSETS 13 | ) 14 | 15 | // Termios is the Unix API for terminal I/O. 16 | type Termios struct { 17 | Iflag uint32 18 | Oflag uint32 19 | Cflag uint32 20 | Lflag uint32 21 | Cc [20]byte 22 | Ispeed uint32 23 | Ospeed uint32 24 | } 25 | 26 | // MakeRaw put the terminal connected to the given file descriptor into raw 27 | // mode and returns the previous state of the terminal so that it can be 28 | // restored. 29 | func MakeRaw(fd uintptr) (*State, error) { 30 | var oldState State 31 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, getTermios, uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { 32 | return nil, err 33 | } 34 | 35 | newState := oldState.termios 36 | 37 | newState.Iflag &^= (syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON) 38 | newState.Oflag &^= syscall.OPOST 39 | newState.Lflag &^= (syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN) 40 | newState.Cflag &^= (syscall.CSIZE | syscall.PARENB) 41 | newState.Cflag |= syscall.CS8 42 | 43 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, setTermios, uintptr(unsafe.Pointer(&newState))); err != 0 { 44 | return nil, err 45 | } 46 | return &oldState, nil 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/termios_openbsd.go: -------------------------------------------------------------------------------- 1 | package term 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | const ( 9 | getTermios = syscall.TIOCGETA 10 | setTermios = syscall.TIOCSETA 11 | ) 12 | 13 | // Termios magic numbers, passthrough to the ones defined in syscall. 14 | const ( 15 | IGNBRK = syscall.IGNBRK 16 | PARMRK = syscall.PARMRK 17 | INLCR = syscall.INLCR 18 | IGNCR = syscall.IGNCR 19 | ECHONL = syscall.ECHONL 20 | CSIZE = syscall.CSIZE 21 | ICRNL = syscall.ICRNL 22 | ISTRIP = syscall.ISTRIP 23 | PARENB = syscall.PARENB 24 | ECHO = syscall.ECHO 25 | ICANON = syscall.ICANON 26 | ISIG = syscall.ISIG 27 | IXON = syscall.IXON 28 | BRKINT = syscall.BRKINT 29 | INPCK = syscall.INPCK 30 | OPOST = syscall.OPOST 31 | CS8 = syscall.CS8 32 | IEXTEN = syscall.IEXTEN 33 | ) 34 | 35 | // Termios is the Unix API for terminal I/O. 36 | type Termios struct { 37 | Iflag uint32 38 | Oflag uint32 39 | Cflag uint32 40 | Lflag uint32 41 | Cc [20]byte 42 | Ispeed uint32 43 | Ospeed uint32 44 | } 45 | 46 | // MakeRaw put the terminal connected to the given file descriptor into raw 47 | // mode and returns the previous state of the terminal so that it can be 48 | // restored. 49 | func MakeRaw(fd uintptr) (*State, error) { 50 | var oldState State 51 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { 52 | return nil, err 53 | } 54 | 55 | newState := oldState.termios 56 | newState.Iflag &^= (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON) 57 | newState.Oflag &^= OPOST 58 | newState.Lflag &^= (ECHO | ECHONL | ICANON | ISIG | IEXTEN) 59 | newState.Cflag &^= (CSIZE | PARENB) 60 | newState.Cflag |= CS8 61 | newState.Cc[syscall.VMIN] = 1 62 | newState.Cc[syscall.VTIME] = 0 63 | 64 | if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&newState))); err != 0 { 65 | return nil, err 66 | } 67 | 68 | return &oldState, nil 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/windows/ansi_writer.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package windows 4 | 5 | import ( 6 | "io/ioutil" 7 | "os" 8 | 9 | ansiterm "github.com/Azure/go-ansiterm" 10 | "github.com/Azure/go-ansiterm/winterm" 11 | "github.com/Sirupsen/logrus" 12 | ) 13 | 14 | var logger *logrus.Logger 15 | 16 | // ansiWriter wraps a standard output file (e.g., os.Stdout) providing ANSI sequence translation. 17 | type ansiWriter struct { 18 | file *os.File 19 | fd uintptr 20 | infoReset *winterm.CONSOLE_SCREEN_BUFFER_INFO 21 | command []byte 22 | escapeSequence []byte 23 | inAnsiSequence bool 24 | parser *ansiterm.AnsiParser 25 | } 26 | 27 | func newAnsiWriter(nFile int) *ansiWriter { 28 | logFile := ioutil.Discard 29 | 30 | if isDebugEnv := os.Getenv(ansiterm.LogEnv); isDebugEnv == "1" { 31 | logFile, _ = os.Create("ansiReaderWriter.log") 32 | } 33 | 34 | logger = &logrus.Logger{ 35 | Out: logFile, 36 | Formatter: new(logrus.TextFormatter), 37 | Level: logrus.DebugLevel, 38 | } 39 | 40 | file, fd := winterm.GetStdFile(nFile) 41 | info, err := winterm.GetConsoleScreenBufferInfo(fd) 42 | if err != nil { 43 | return nil 44 | } 45 | 46 | parser := ansiterm.CreateParser("Ground", winterm.CreateWinEventHandler(fd, file)) 47 | logger.Infof("newAnsiWriter: parser %p", parser) 48 | 49 | aw := &ansiWriter{ 50 | file: file, 51 | fd: fd, 52 | infoReset: info, 53 | command: make([]byte, 0, ansiterm.ANSI_MAX_CMD_LENGTH), 54 | escapeSequence: []byte(ansiterm.KEY_ESC_CSI), 55 | parser: parser, 56 | } 57 | 58 | logger.Infof("newAnsiWriter: aw.parser %p", aw.parser) 59 | logger.Infof("newAnsiWriter: %v", aw) 60 | return aw 61 | } 62 | 63 | func (aw *ansiWriter) Fd() uintptr { 64 | return aw.fd 65 | } 66 | 67 | // Write writes len(p) bytes from p to the underlying data stream. 68 | func (aw *ansiWriter) Write(p []byte) (total int, err error) { 69 | if len(p) == 0 { 70 | return 0, nil 71 | } 72 | 73 | logger.Infof("Write: % x", p) 74 | logger.Infof("Write: %s", string(p)) 75 | return aw.parser.Parse(p) 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/windows/console.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package windows 4 | 5 | import ( 6 | "io" 7 | "os" 8 | "syscall" 9 | 10 | "github.com/Azure/go-ansiterm/winterm" 11 | 12 | ansiterm "github.com/Azure/go-ansiterm" 13 | "github.com/Sirupsen/logrus" 14 | "io/ioutil" 15 | ) 16 | 17 | // ConEmuStreams returns prepared versions of console streams, 18 | // for proper use in ConEmu terminal. 19 | // The ConEmu terminal emulates ANSI on output streams well by default. 20 | func ConEmuStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) { 21 | if IsConsole(os.Stdin.Fd()) { 22 | stdIn = newAnsiReader(syscall.STD_INPUT_HANDLE) 23 | } else { 24 | stdIn = os.Stdin 25 | } 26 | 27 | stdOut = os.Stdout 28 | stdErr = os.Stderr 29 | 30 | // WARNING (BEGIN): sourced from newAnsiWriter 31 | 32 | logFile := ioutil.Discard 33 | 34 | if isDebugEnv := os.Getenv(ansiterm.LogEnv); isDebugEnv == "1" { 35 | logFile, _ = os.Create("ansiReaderWriter.log") 36 | } 37 | 38 | logger = &logrus.Logger{ 39 | Out: logFile, 40 | Formatter: new(logrus.TextFormatter), 41 | Level: logrus.DebugLevel, 42 | } 43 | 44 | // WARNING (END): sourced from newAnsiWriter 45 | 46 | return stdIn, stdOut, stdErr 47 | } 48 | 49 | // ConsoleStreams returns a wrapped version for each standard stream referencing a console, 50 | // that handles ANSI character sequences. 51 | func ConsoleStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) { 52 | if IsConsole(os.Stdin.Fd()) { 53 | stdIn = newAnsiReader(syscall.STD_INPUT_HANDLE) 54 | } else { 55 | stdIn = os.Stdin 56 | } 57 | 58 | if IsConsole(os.Stdout.Fd()) { 59 | stdOut = newAnsiWriter(syscall.STD_OUTPUT_HANDLE) 60 | } else { 61 | stdOut = os.Stdout 62 | } 63 | 64 | if IsConsole(os.Stderr.Fd()) { 65 | stdErr = newAnsiWriter(syscall.STD_ERROR_HANDLE) 66 | } else { 67 | stdErr = os.Stderr 68 | } 69 | 70 | return stdIn, stdOut, stdErr 71 | } 72 | 73 | // GetHandleInfo returns file descriptor and bool indicating whether the file is a console. 74 | func GetHandleInfo(in interface{}) (uintptr, bool) { 75 | switch t := in.(type) { 76 | case *ansiReader: 77 | return t.Fd(), true 78 | case *ansiWriter: 79 | return t.Fd(), true 80 | } 81 | 82 | var inFd uintptr 83 | var isTerminal bool 84 | 85 | if file, ok := in.(*os.File); ok { 86 | inFd = file.Fd() 87 | isTerminal = IsConsole(inFd) 88 | } 89 | return inFd, isTerminal 90 | } 91 | 92 | // IsConsole returns true if the given file descriptor is a Windows Console. 93 | // The code assumes that GetConsoleMode will return an error for file descriptors that are not a console. 94 | func IsConsole(fd uintptr) bool { 95 | _, e := winterm.GetConsoleMode(fd) 96 | return e == nil 97 | } 98 | -------------------------------------------------------------------------------- /vendor/github.com/docker/docker/pkg/term/windows/windows.go: -------------------------------------------------------------------------------- 1 | // These files implement ANSI-aware input and output streams for use by the Docker Windows client. 2 | // When asked for the set of standard streams (e.g., stdin, stdout, stderr), the code will create 3 | // and return pseudo-streams that convert ANSI sequences to / from Windows Console API calls. 4 | 5 | package windows 6 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/base.go: -------------------------------------------------------------------------------- 1 | package drivers 2 | 3 | import ( 4 | "errors" 5 | "path/filepath" 6 | ) 7 | 8 | const ( 9 | DefaultSSHUser = "root" 10 | DefaultSSHPort = 22 11 | DefaultEngineInstallURL = "https://get.docker.com" 12 | ) 13 | 14 | // BaseDriver - Embed this struct into drivers to provide the common set 15 | // of fields and functions. 16 | type BaseDriver struct { 17 | IPAddress string 18 | MachineName string 19 | SSHUser string 20 | SSHPort int 21 | SSHKeyPath string 22 | StorePath string 23 | SwarmMaster bool 24 | SwarmHost string 25 | SwarmDiscovery string 26 | } 27 | 28 | // DriverName returns the name of the driver 29 | func (d *BaseDriver) DriverName() string { 30 | return "unknown" 31 | } 32 | 33 | // GetMachineName returns the machine name 34 | func (d *BaseDriver) GetMachineName() string { 35 | return d.MachineName 36 | } 37 | 38 | // GetIP returns the ip 39 | func (d *BaseDriver) GetIP() (string, error) { 40 | if d.IPAddress == "" { 41 | return "", errors.New("IP address is not set") 42 | } 43 | return d.IPAddress, nil 44 | } 45 | 46 | // GetSSHKeyPath returns the ssh key path 47 | func (d *BaseDriver) GetSSHKeyPath() string { 48 | if d.SSHKeyPath == "" { 49 | d.SSHKeyPath = d.ResolveStorePath("id_rsa") 50 | } 51 | return d.SSHKeyPath 52 | } 53 | 54 | // GetSSHPort returns the ssh port, 22 if not specified 55 | func (d *BaseDriver) GetSSHPort() (int, error) { 56 | if d.SSHPort == 0 { 57 | d.SSHPort = DefaultSSHPort 58 | } 59 | 60 | return d.SSHPort, nil 61 | } 62 | 63 | // GetSSHUsername returns the ssh user name, root if not specified 64 | func (d *BaseDriver) GetSSHUsername() string { 65 | if d.SSHUser == "" { 66 | d.SSHUser = DefaultSSHUser 67 | } 68 | return d.SSHUser 69 | } 70 | 71 | // PreCreateCheck is called to enforce pre-creation steps 72 | func (d *BaseDriver) PreCreateCheck() error { 73 | return nil 74 | } 75 | 76 | // ResolveStorePath returns the store path where the machine is 77 | func (d *BaseDriver) ResolveStorePath(file string) string { 78 | return filepath.Join(d.StorePath, "machines", d.MachineName, file) 79 | } 80 | 81 | // SetSwarmConfigFromFlags configures the driver for swarm 82 | func (d *BaseDriver) SetSwarmConfigFromFlags(flags DriverOptions) { 83 | d.SwarmMaster = flags.Bool("swarm-master") 84 | d.SwarmHost = flags.String("swarm-host") 85 | d.SwarmDiscovery = flags.String("swarm-discovery") 86 | } 87 | 88 | func EngineInstallURLFlagSet(flags DriverOptions) bool { 89 | engineInstallURLFlag := flags.String("engine-install-url") 90 | return engineInstallURLFlag != DefaultEngineInstallURL && engineInstallURLFlag != "" 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/check.go: -------------------------------------------------------------------------------- 1 | package drivers 2 | 3 | import "github.com/docker/machine/libmachine/mcnflag" 4 | 5 | // CheckDriverOptions implements DriverOptions and is used to validate flag parsing 6 | type CheckDriverOptions struct { 7 | FlagsValues map[string]interface{} 8 | CreateFlags []mcnflag.Flag 9 | InvalidFlags []string 10 | } 11 | 12 | func (o *CheckDriverOptions) String(key string) string { 13 | for _, flag := range o.CreateFlags { 14 | if flag.String() == key { 15 | f, ok := flag.(mcnflag.StringFlag) 16 | if !ok { 17 | o.InvalidFlags = append(o.InvalidFlags, flag.String()) 18 | } 19 | 20 | value, present := o.FlagsValues[key].(string) 21 | if present { 22 | return value 23 | } 24 | return f.Value 25 | } 26 | } 27 | 28 | return "" 29 | } 30 | 31 | func (o *CheckDriverOptions) StringSlice(key string) []string { 32 | for _, flag := range o.CreateFlags { 33 | if flag.String() == key { 34 | f, ok := flag.(mcnflag.StringSliceFlag) 35 | if !ok { 36 | o.InvalidFlags = append(o.InvalidFlags, flag.String()) 37 | } 38 | 39 | value, present := o.FlagsValues[key].([]string) 40 | if present { 41 | return value 42 | } 43 | return f.Value 44 | } 45 | } 46 | 47 | return nil 48 | } 49 | 50 | func (o *CheckDriverOptions) Int(key string) int { 51 | for _, flag := range o.CreateFlags { 52 | if flag.String() == key { 53 | f, ok := flag.(mcnflag.IntFlag) 54 | if !ok { 55 | o.InvalidFlags = append(o.InvalidFlags, flag.String()) 56 | } 57 | 58 | value, present := o.FlagsValues[key].(int) 59 | if present { 60 | return value 61 | } 62 | return f.Value 63 | } 64 | } 65 | 66 | return 0 67 | } 68 | 69 | func (o *CheckDriverOptions) Bool(key string) bool { 70 | for _, flag := range o.CreateFlags { 71 | if flag.String() == key { 72 | _, ok := flag.(mcnflag.BoolFlag) 73 | if !ok { 74 | o.InvalidFlags = append(o.InvalidFlags, flag.String()) 75 | } 76 | } 77 | } 78 | 79 | value, present := o.FlagsValues[key].(bool) 80 | if present { 81 | return value 82 | } 83 | return false 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/drivers.go: -------------------------------------------------------------------------------- 1 | package drivers 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/docker/machine/libmachine/log" 7 | "github.com/docker/machine/libmachine/mcnflag" 8 | "github.com/docker/machine/libmachine/state" 9 | ) 10 | 11 | // Driver defines how a host is created and controlled. Different types of 12 | // driver represent different ways hosts can be created (e.g. different 13 | // hypervisors, different cloud providers) 14 | type Driver interface { 15 | // Create a host using the driver's config 16 | Create() error 17 | 18 | // DriverName returns the name of the driver 19 | DriverName() string 20 | 21 | // GetCreateFlags returns the mcnflag.Flag slice representing the flags 22 | // that can be set, their descriptions and defaults. 23 | GetCreateFlags() []mcnflag.Flag 24 | 25 | // GetIP returns an IP or hostname that this host is available at 26 | // e.g. 1.2.3.4 or docker-host-d60b70a14d3a.cloudapp.net 27 | GetIP() (string, error) 28 | 29 | // GetMachineName returns the name of the machine 30 | GetMachineName() string 31 | 32 | // GetSSHHostname returns hostname for use with ssh 33 | GetSSHHostname() (string, error) 34 | 35 | // GetSSHKeyPath returns key path for use with ssh 36 | GetSSHKeyPath() string 37 | 38 | // GetSSHPort returns port for use with ssh 39 | GetSSHPort() (int, error) 40 | 41 | // GetSSHUsername returns username for use with ssh 42 | GetSSHUsername() string 43 | 44 | // GetURL returns a Docker compatible host URL for connecting to this host 45 | // e.g. tcp://1.2.3.4:2376 46 | GetURL() (string, error) 47 | 48 | // GetState returns the state that the host is in (running, stopped, etc) 49 | GetState() (state.State, error) 50 | 51 | // Kill stops a host forcefully 52 | Kill() error 53 | 54 | // PreCreateCheck allows for pre-create operations to make sure a driver is ready for creation 55 | PreCreateCheck() error 56 | 57 | // Remove a host 58 | Remove() error 59 | 60 | // Restart a host. This may just call Stop(); Start() if the provider does not 61 | // have any special restart behaviour. 62 | Restart() error 63 | 64 | // SetConfigFromFlags configures the driver with the object that was returned 65 | // by RegisterCreateFlags 66 | SetConfigFromFlags(opts DriverOptions) error 67 | 68 | // Start a host 69 | Start() error 70 | 71 | // Stop a host gracefully 72 | Stop() error 73 | } 74 | 75 | var ErrHostIsNotRunning = errors.New("Host is not running") 76 | 77 | type DriverOptions interface { 78 | String(key string) string 79 | StringSlice(key string) []string 80 | Int(key string) int 81 | Bool(key string) bool 82 | } 83 | 84 | func MachineInState(d Driver, desiredState state.State) func() bool { 85 | return func() bool { 86 | currentState, err := d.GetState() 87 | if err != nil { 88 | log.Debugf("Error getting machine state: %s", err) 89 | } 90 | if currentState == desiredState { 91 | return true 92 | } 93 | return false 94 | } 95 | } 96 | 97 | // MustBeRunning will return an error if the machine is not in a running state. 98 | func MustBeRunning(d Driver) error { 99 | s, err := d.GetState() 100 | if err != nil { 101 | return err 102 | } 103 | 104 | if s != state.Running { 105 | return ErrHostIsNotRunning 106 | } 107 | 108 | return nil 109 | } 110 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/notsupported.go: -------------------------------------------------------------------------------- 1 | package drivers 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/docker/machine/libmachine/mcnflag" 7 | "github.com/docker/machine/libmachine/state" 8 | ) 9 | 10 | type DriverNotSupported struct { 11 | *BaseDriver 12 | Name string 13 | } 14 | 15 | type NotSupported struct { 16 | DriverName string 17 | } 18 | 19 | func (e NotSupported) Error() string { 20 | return fmt.Sprintf("Driver %q not supported on this platform.", e.DriverName) 21 | } 22 | 23 | // NewDriverNotSupported creates a placeholder Driver that replaces 24 | // a driver that is not supported on a given platform. eg fusion on linux. 25 | func NewDriverNotSupported(driverName, hostName, storePath string) Driver { 26 | return &DriverNotSupported{ 27 | BaseDriver: &BaseDriver{ 28 | MachineName: hostName, 29 | StorePath: storePath, 30 | }, 31 | Name: driverName, 32 | } 33 | } 34 | 35 | func (d *DriverNotSupported) DriverName() string { 36 | return d.Name 37 | } 38 | 39 | func (d *DriverNotSupported) PreCreateCheck() error { 40 | return NotSupported{d.DriverName()} 41 | } 42 | 43 | func (d *DriverNotSupported) GetCreateFlags() []mcnflag.Flag { 44 | return nil 45 | } 46 | 47 | func (d *DriverNotSupported) SetConfigFromFlags(flags DriverOptions) error { 48 | return NotSupported{d.DriverName()} 49 | } 50 | 51 | func (d *DriverNotSupported) GetURL() (string, error) { 52 | return "", NotSupported{d.DriverName()} 53 | } 54 | 55 | func (d *DriverNotSupported) GetSSHHostname() (string, error) { 56 | return "", NotSupported{d.DriverName()} 57 | } 58 | 59 | func (d *DriverNotSupported) GetState() (state.State, error) { 60 | return state.Error, NotSupported{d.DriverName()} 61 | } 62 | 63 | func (d *DriverNotSupported) Create() error { 64 | return NotSupported{d.DriverName()} 65 | } 66 | 67 | func (d *DriverNotSupported) Remove() error { 68 | return NotSupported{d.DriverName()} 69 | } 70 | 71 | func (d *DriverNotSupported) Start() error { 72 | return NotSupported{d.DriverName()} 73 | } 74 | 75 | func (d *DriverNotSupported) Stop() error { 76 | return NotSupported{d.DriverName()} 77 | } 78 | 79 | func (d *DriverNotSupported) Restart() error { 80 | return NotSupported{d.DriverName()} 81 | } 82 | 83 | func (d *DriverNotSupported) Kill() error { 84 | return NotSupported{d.DriverName()} 85 | } 86 | 87 | func (d *DriverNotSupported) Upgrade() error { 88 | return NotSupported{d.DriverName()} 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/plugin/register_driver.go: -------------------------------------------------------------------------------- 1 | package plugin 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "net/http" 7 | "net/rpc" 8 | "os" 9 | "time" 10 | 11 | "github.com/docker/machine/libmachine/drivers" 12 | "github.com/docker/machine/libmachine/drivers/plugin/localbinary" 13 | "github.com/docker/machine/libmachine/drivers/rpc" 14 | "github.com/docker/machine/libmachine/log" 15 | "github.com/docker/machine/libmachine/version" 16 | ) 17 | 18 | var ( 19 | heartbeatTimeout = 10 * time.Second 20 | ) 21 | 22 | func RegisterDriver(d drivers.Driver) { 23 | if os.Getenv(localbinary.PluginEnvKey) != localbinary.PluginEnvVal { 24 | fmt.Fprintf(os.Stderr, `This is a Docker Machine plugin binary. 25 | Plugin binaries are not intended to be invoked directly. 26 | Please use this plugin through the main 'docker-machine' binary. 27 | (API version: %d) 28 | `, version.APIVersion) 29 | os.Exit(1) 30 | } 31 | 32 | log.SetDebug(true) 33 | os.Setenv("MACHINE_DEBUG", "1") 34 | 35 | rpcd := rpcdriver.NewRPCServerDriver(d) 36 | rpc.RegisterName(rpcdriver.RPCServiceNameV0, rpcd) 37 | rpc.RegisterName(rpcdriver.RPCServiceNameV1, rpcd) 38 | rpc.HandleHTTP() 39 | 40 | listener, err := net.Listen("tcp", "127.0.0.1:0") 41 | if err != nil { 42 | fmt.Fprintf(os.Stderr, "Error loading RPC server: %s\n", err) 43 | os.Exit(1) 44 | } 45 | defer listener.Close() 46 | 47 | fmt.Println(listener.Addr()) 48 | 49 | go http.Serve(listener, nil) 50 | 51 | for { 52 | select { 53 | case <-rpcd.CloseCh: 54 | log.Debug("Closing plugin on server side") 55 | os.Exit(0) 56 | case <-rpcd.HeartbeatCh: 57 | continue 58 | case <-time.After(heartbeatTimeout): 59 | // TODO: Add heartbeat retry logic 60 | os.Exit(1) 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/drivers/utils.go: -------------------------------------------------------------------------------- 1 | package drivers 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/docker/machine/libmachine/log" 7 | "github.com/docker/machine/libmachine/mcnutils" 8 | "github.com/docker/machine/libmachine/ssh" 9 | ) 10 | 11 | func GetSSHClientFromDriver(d Driver) (ssh.Client, error) { 12 | address, err := d.GetSSHHostname() 13 | if err != nil { 14 | return nil, err 15 | } 16 | 17 | port, err := d.GetSSHPort() 18 | if err != nil { 19 | return nil, err 20 | } 21 | 22 | var auth *ssh.Auth 23 | if d.GetSSHKeyPath() == "" { 24 | auth = &ssh.Auth{} 25 | } else { 26 | auth = &ssh.Auth{ 27 | Keys: []string{d.GetSSHKeyPath()}, 28 | } 29 | } 30 | 31 | client, err := ssh.NewClient(d.GetSSHUsername(), address, port, auth) 32 | return client, err 33 | 34 | } 35 | 36 | func RunSSHCommandFromDriver(d Driver, command string) (string, error) { 37 | client, err := GetSSHClientFromDriver(d) 38 | if err != nil { 39 | return "", err 40 | } 41 | 42 | log.Debugf("About to run SSH command:\n%s", command) 43 | 44 | output, err := client.Output(command) 45 | log.Debugf("SSH cmd err, output: %v: %s", err, output) 46 | if err != nil { 47 | return "", fmt.Errorf(`Something went wrong running an SSH command! 48 | command : %s 49 | err : %v 50 | output : %s 51 | `, command, err, output) 52 | } 53 | 54 | return output, nil 55 | } 56 | 57 | func sshAvailableFunc(d Driver) func() bool { 58 | return func() bool { 59 | log.Debug("Getting to WaitForSSH function...") 60 | if _, err := RunSSHCommandFromDriver(d, "exit 0"); err != nil { 61 | log.Debugf("Error getting ssh command 'exit 0' : %s", err) 62 | return false 63 | } 64 | return true 65 | } 66 | } 67 | 68 | func WaitForSSH(d Driver) error { 69 | // Try to dial SSH for 30 seconds before timing out. 70 | if err := mcnutils.WaitFor(sshAvailableFunc(d)); err != nil { 71 | return fmt.Errorf("Too many retries waiting for SSH to be available. Last error: %s", err) 72 | } 73 | return nil 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/log/fmt_machine_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | ) 8 | 9 | type FmtMachineLogger struct { 10 | outWriter io.Writer 11 | errWriter io.Writer 12 | debug bool 13 | history *HistoryRecorder 14 | } 15 | 16 | // NewFmtMachineLogger creates a MachineLogger implementation used by the drivers 17 | func NewFmtMachineLogger() MachineLogger { 18 | return &FmtMachineLogger{ 19 | outWriter: os.Stdout, 20 | errWriter: os.Stderr, 21 | debug: false, 22 | history: NewHistoryRecorder(), 23 | } 24 | } 25 | 26 | func (ml *FmtMachineLogger) SetDebug(debug bool) { 27 | ml.debug = debug 28 | } 29 | 30 | func (ml *FmtMachineLogger) SetOutWriter(out io.Writer) { 31 | ml.outWriter = out 32 | } 33 | 34 | func (ml *FmtMachineLogger) SetErrWriter(err io.Writer) { 35 | ml.errWriter = err 36 | } 37 | 38 | func (ml *FmtMachineLogger) Debug(args ...interface{}) { 39 | ml.history.Record(args...) 40 | if ml.debug { 41 | fmt.Fprintln(ml.errWriter, args...) 42 | } 43 | } 44 | 45 | func (ml *FmtMachineLogger) Debugf(fmtString string, args ...interface{}) { 46 | ml.history.Recordf(fmtString, args...) 47 | if ml.debug { 48 | fmt.Fprintf(ml.errWriter, fmtString+"\n", args...) 49 | } 50 | } 51 | 52 | func (ml *FmtMachineLogger) Error(args ...interface{}) { 53 | ml.history.Record(args...) 54 | fmt.Fprintln(ml.errWriter, args...) 55 | } 56 | 57 | func (ml *FmtMachineLogger) Errorf(fmtString string, args ...interface{}) { 58 | ml.history.Recordf(fmtString, args...) 59 | fmt.Fprintf(ml.errWriter, fmtString+"\n", args...) 60 | } 61 | 62 | func (ml *FmtMachineLogger) Info(args ...interface{}) { 63 | ml.history.Record(args...) 64 | fmt.Fprintln(ml.outWriter, args...) 65 | } 66 | 67 | func (ml *FmtMachineLogger) Infof(fmtString string, args ...interface{}) { 68 | ml.history.Recordf(fmtString, args...) 69 | fmt.Fprintf(ml.outWriter, fmtString+"\n", args...) 70 | } 71 | 72 | func (ml *FmtMachineLogger) Warn(args ...interface{}) { 73 | ml.history.Record(args...) 74 | fmt.Fprintln(ml.outWriter, args...) 75 | } 76 | 77 | func (ml *FmtMachineLogger) Warnf(fmtString string, args ...interface{}) { 78 | ml.history.Recordf(fmtString, args...) 79 | fmt.Fprintf(ml.outWriter, fmtString+"\n", args...) 80 | } 81 | 82 | func (ml *FmtMachineLogger) History() []string { 83 | return ml.history.records 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/log/history_recorder.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | type HistoryRecorder struct { 9 | lock *sync.Mutex 10 | records []string 11 | } 12 | 13 | func NewHistoryRecorder() *HistoryRecorder { 14 | return &HistoryRecorder{ 15 | lock: &sync.Mutex{}, 16 | records: []string{}, 17 | } 18 | } 19 | 20 | func (ml *HistoryRecorder) History() []string { 21 | return ml.records 22 | } 23 | 24 | func (ml *HistoryRecorder) Record(args ...interface{}) { 25 | ml.lock.Lock() 26 | defer ml.lock.Unlock() 27 | ml.records = append(ml.records, fmt.Sprint(args...)) 28 | } 29 | 30 | func (ml *HistoryRecorder) Recordf(fmtString string, args ...interface{}) { 31 | ml.lock.Lock() 32 | defer ml.lock.Unlock() 33 | ml.records = append(ml.records, fmt.Sprintf(fmtString, args...)) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/log/log.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "io" 5 | "regexp" 6 | ) 7 | 8 | const redactedText = "" 9 | 10 | var ( 11 | logger = NewFmtMachineLogger() 12 | 13 | // (?s) enables '.' to match '\n' -- see https://golang.org/pkg/regexp/syntax/ 14 | certRegex = regexp.MustCompile("(?s)-----BEGIN CERTIFICATE-----.*-----END CERTIFICATE-----") 15 | keyRegex = regexp.MustCompile("(?s)-----BEGIN RSA PRIVATE KEY-----.*-----END RSA PRIVATE KEY-----") 16 | ) 17 | 18 | func stripSecrets(original []string) []string { 19 | stripped := []string{} 20 | for _, line := range original { 21 | line = certRegex.ReplaceAllString(line, redactedText) 22 | line = keyRegex.ReplaceAllString(line, redactedText) 23 | stripped = append(stripped, line) 24 | } 25 | return stripped 26 | } 27 | 28 | func Debug(args ...interface{}) { 29 | logger.Debug(args...) 30 | } 31 | 32 | func Debugf(fmtString string, args ...interface{}) { 33 | logger.Debugf(fmtString, args...) 34 | } 35 | 36 | func Error(args ...interface{}) { 37 | logger.Error(args...) 38 | } 39 | 40 | func Errorf(fmtString string, args ...interface{}) { 41 | logger.Errorf(fmtString, args...) 42 | } 43 | 44 | func Info(args ...interface{}) { 45 | logger.Info(args...) 46 | } 47 | 48 | func Infof(fmtString string, args ...interface{}) { 49 | logger.Infof(fmtString, args...) 50 | } 51 | 52 | func Warn(args ...interface{}) { 53 | logger.Warn(args...) 54 | } 55 | 56 | func Warnf(fmtString string, args ...interface{}) { 57 | logger.Warnf(fmtString, args...) 58 | } 59 | 60 | func SetDebug(debug bool) { 61 | logger.SetDebug(debug) 62 | } 63 | 64 | func SetOutWriter(out io.Writer) { 65 | logger.SetOutWriter(out) 66 | } 67 | 68 | func SetErrWriter(err io.Writer) { 69 | logger.SetErrWriter(err) 70 | } 71 | 72 | func History() []string { 73 | return stripSecrets(logger.History()) 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/log/machine_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import "io" 4 | 5 | type MachineLogger interface { 6 | SetDebug(debug bool) 7 | 8 | SetOutWriter(io.Writer) 9 | SetErrWriter(io.Writer) 10 | 11 | Debug(args ...interface{}) 12 | Debugf(fmtString string, args ...interface{}) 13 | 14 | Error(args ...interface{}) 15 | Errorf(fmtString string, args ...interface{}) 16 | 17 | Info(args ...interface{}) 18 | Infof(fmtString string, args ...interface{}) 19 | 20 | Warn(args ...interface{}) 21 | Warnf(fmtString string, args ...interface{}) 22 | 23 | History() []string 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/mcnflag/flag.go: -------------------------------------------------------------------------------- 1 | package mcnflag 2 | 3 | import "fmt" 4 | 5 | type Flag interface { 6 | fmt.Stringer 7 | Default() interface{} 8 | } 9 | 10 | type StringFlag struct { 11 | Name string 12 | Usage string 13 | EnvVar string 14 | Value string 15 | } 16 | 17 | // TODO: Could this be done more succinctly using embedding? 18 | func (f StringFlag) String() string { 19 | return f.Name 20 | } 21 | 22 | func (f StringFlag) Default() interface{} { 23 | return f.Value 24 | } 25 | 26 | type StringSliceFlag struct { 27 | Name string 28 | Usage string 29 | EnvVar string 30 | Value []string 31 | } 32 | 33 | // TODO: Could this be done more succinctly using embedding? 34 | func (f StringSliceFlag) String() string { 35 | return f.Name 36 | } 37 | 38 | func (f StringSliceFlag) Default() interface{} { 39 | return f.Value 40 | } 41 | 42 | type IntFlag struct { 43 | Name string 44 | Usage string 45 | EnvVar string 46 | Value int 47 | } 48 | 49 | // TODO: Could this be done more succinctly using embedding? 50 | func (f IntFlag) String() string { 51 | return f.Name 52 | } 53 | 54 | func (f IntFlag) Default() interface{} { 55 | return f.Value 56 | } 57 | 58 | type BoolFlag struct { 59 | Name string 60 | Usage string 61 | EnvVar string 62 | } 63 | 64 | // TODO: Could this be done more succinctly using embedding? 65 | func (f BoolFlag) String() string { 66 | return f.Name 67 | } 68 | 69 | func (f BoolFlag) Default() interface{} { 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/mcnutils/utils.go: -------------------------------------------------------------------------------- 1 | package mcnutils 2 | 3 | import ( 4 | "crypto/rand" 5 | "encoding/hex" 6 | "fmt" 7 | "io" 8 | "os" 9 | "runtime" 10 | "strconv" 11 | "time" 12 | ) 13 | 14 | // GetHomeDir returns the home directory 15 | // TODO: Having this here just strikes me as dangerous, but some of the drivers 16 | // depend on it ;_; 17 | func GetHomeDir() string { 18 | if runtime.GOOS == "windows" { 19 | return os.Getenv("USERPROFILE") 20 | } 21 | return os.Getenv("HOME") 22 | } 23 | 24 | func GetUsername() string { 25 | u := "unknown" 26 | osUser := "" 27 | 28 | switch runtime.GOOS { 29 | case "darwin", "linux": 30 | osUser = os.Getenv("USER") 31 | case "windows": 32 | osUser = os.Getenv("USERNAME") 33 | } 34 | 35 | if osUser != "" { 36 | u = osUser 37 | } 38 | 39 | return u 40 | } 41 | 42 | func CopyFile(src, dst string) error { 43 | in, err := os.Open(src) 44 | if err != nil { 45 | return err 46 | } 47 | 48 | defer in.Close() 49 | 50 | out, err := os.Create(dst) 51 | if err != nil { 52 | return err 53 | } 54 | 55 | defer out.Close() 56 | 57 | if _, err = io.Copy(out, in); err != nil { 58 | return err 59 | } 60 | 61 | fi, err := os.Stat(src) 62 | if err != nil { 63 | return err 64 | } 65 | 66 | if err := os.Chmod(dst, fi.Mode()); err != nil { 67 | return err 68 | } 69 | 70 | return nil 71 | } 72 | 73 | func WaitForSpecificOrError(f func() (bool, error), maxAttempts int, waitInterval time.Duration) error { 74 | for i := 0; i < maxAttempts; i++ { 75 | stop, err := f() 76 | if err != nil { 77 | return err 78 | } 79 | if stop { 80 | return nil 81 | } 82 | time.Sleep(waitInterval) 83 | } 84 | return fmt.Errorf("Maximum number of retries (%d) exceeded", maxAttempts) 85 | } 86 | 87 | func WaitForSpecific(f func() bool, maxAttempts int, waitInterval time.Duration) error { 88 | return WaitForSpecificOrError(func() (bool, error) { 89 | return f(), nil 90 | }, maxAttempts, waitInterval) 91 | } 92 | 93 | func WaitFor(f func() bool) error { 94 | return WaitForSpecific(f, 60, 3*time.Second) 95 | } 96 | 97 | // TruncateID returns a shorten id 98 | // Following two functions are from github.com/docker/docker/utils module. It 99 | // was way overkill to include the whole module, so we just have these bits 100 | // that we're using here. 101 | func TruncateID(id string) string { 102 | shortLen := 12 103 | if len(id) < shortLen { 104 | shortLen = len(id) 105 | } 106 | return id[:shortLen] 107 | } 108 | 109 | // GenerateRandomID returns an unique id 110 | func GenerateRandomID() string { 111 | for { 112 | id := make([]byte, 32) 113 | if _, err := io.ReadFull(rand.Reader, id); err != nil { 114 | panic(err) // This shouldn't happen 115 | } 116 | value := hex.EncodeToString(id) 117 | // if we try to parse the truncated for as an int and we don't have 118 | // an error then the value is all numeric and causes issues when 119 | // used as a hostname. ref #3869 120 | if _, err := strconv.ParseInt(TruncateID(value), 10, 64); err == nil { 121 | continue 122 | } 123 | return value 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/ssh/sshtest/fake_client.go: -------------------------------------------------------------------------------- 1 | package sshtest 2 | 3 | import "io" 4 | 5 | type CmdResult struct { 6 | Out string 7 | Err error 8 | } 9 | 10 | type FakeClient struct { 11 | ActivatedShell []string 12 | Outputs map[string]CmdResult 13 | } 14 | 15 | func (fsc *FakeClient) Output(command string) (string, error) { 16 | outerr := fsc.Outputs[command] 17 | return outerr.Out, outerr.Err 18 | } 19 | 20 | func (fsc *FakeClient) Shell(args ...string) error { 21 | fsc.ActivatedShell = args 22 | return nil 23 | } 24 | 25 | func (fsc *FakeClient) Start(command string) (io.ReadCloser, io.ReadCloser, error) { 26 | return nil, nil, nil 27 | } 28 | 29 | func (fsc *FakeClient) Wait() error { 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/state/state.go: -------------------------------------------------------------------------------- 1 | package state 2 | 3 | // State represents the state of a host 4 | type State int 5 | 6 | const ( 7 | None State = iota 8 | Running 9 | Paused 10 | Saved 11 | Stopped 12 | Stopping 13 | Starting 14 | Error 15 | Timeout 16 | ) 17 | 18 | var states = []string{ 19 | "", 20 | "Running", 21 | "Paused", 22 | "Saved", 23 | "Stopped", 24 | "Stopping", 25 | "Starting", 26 | "Error", 27 | "Timeout", 28 | } 29 | 30 | // Given a State type, returns its string representation 31 | func (s State) String() string { 32 | if int(s) >= 0 && int(s) < len(states) { 33 | return states[s] 34 | } 35 | return "" 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/libmachine/version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | var ( 4 | // APIVersion dictates which version of the libmachine API this is. 5 | APIVersion = 1 6 | 7 | // ConfigVersion dictates which version of the config.json format is 8 | // used. It needs to be bumped if there is a breaking change, and 9 | // therefore migration, introduced to the config file format. 10 | ConfigVersion = 3 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/docker/machine/version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | var ( 9 | // Version should be updated by hand at each release 10 | Version = "0.7.0-rc2" 11 | 12 | // GitCommit will be overwritten automatically by the build system 13 | GitCommit = "HEAD" 14 | ) 15 | 16 | // FullVersion formats the version to be printed 17 | func FullVersion() string { 18 | return fmt.Sprintf("%s, build %s", Version, GitCommit) 19 | } 20 | 21 | // RC checks if the Machine version is a release candidate or not 22 | func RC() bool { 23 | return strings.Contains(Version, "rc") 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/ovh/go-ovh/ovh/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-2016, OVH SAS. 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 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of OVH SAS nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY OVH SAS AND CONTRIBUTORS ``AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL OVH SAS AND CONTRIBUTORS BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | -------------------------------------------------------------------------------- /vendor/github.com/ovh/go-ovh/ovh/error.go: -------------------------------------------------------------------------------- 1 | package ovh 2 | 3 | import "fmt" 4 | 5 | // APIError represents an error that can occurred while calling the API. 6 | type APIError struct { 7 | // Error message. 8 | Message string 9 | // HTTP code. 10 | Code int 11 | } 12 | 13 | func (err *APIError) Error() string { 14 | return fmt.Sprintf("Error %d: %q", err.Code, err.Message) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/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/curve25519/const_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | DATA ·REDMASK51(SB)/8, $0x0007FFFFFFFFFFFF 11 | GLOBL ·REDMASK51(SB), 8, $8 12 | 13 | DATA ·_121666_213(SB)/8, $996687872 14 | GLOBL ·_121666_213(SB), 8, $8 15 | 16 | DATA ·_2P0(SB)/8, $0xFFFFFFFFFFFDA 17 | GLOBL ·_2P0(SB), 8, $8 18 | 19 | DATA ·_2P1234(SB)/8, $0xFFFFFFFFFFFFE 20 | GLOBL ·_2P1234(SB), 8, $8 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/cswap_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | // func cswap(inout *[5]uint64, v uint64) 11 | TEXT ·cswap(SB),7,$0 12 | MOVQ inout+0(FP),DI 13 | MOVQ v+8(FP),SI 14 | 15 | CMPQ SI,$1 16 | MOVQ 0(DI),SI 17 | MOVQ 80(DI),DX 18 | MOVQ 8(DI),CX 19 | MOVQ 88(DI),R8 20 | MOVQ SI,R9 21 | CMOVQEQ DX,SI 22 | CMOVQEQ R9,DX 23 | MOVQ CX,R9 24 | CMOVQEQ R8,CX 25 | CMOVQEQ R9,R8 26 | MOVQ SI,0(DI) 27 | MOVQ DX,80(DI) 28 | MOVQ CX,8(DI) 29 | MOVQ R8,88(DI) 30 | MOVQ 16(DI),SI 31 | MOVQ 96(DI),DX 32 | MOVQ 24(DI),CX 33 | MOVQ 104(DI),R8 34 | MOVQ SI,R9 35 | CMOVQEQ DX,SI 36 | CMOVQEQ R9,DX 37 | MOVQ CX,R9 38 | CMOVQEQ R8,CX 39 | CMOVQEQ R9,R8 40 | MOVQ SI,16(DI) 41 | MOVQ DX,96(DI) 42 | MOVQ CX,24(DI) 43 | MOVQ R8,104(DI) 44 | MOVQ 32(DI),SI 45 | MOVQ 112(DI),DX 46 | MOVQ 40(DI),CX 47 | MOVQ 120(DI),R8 48 | MOVQ SI,R9 49 | CMOVQEQ DX,SI 50 | CMOVQEQ R9,DX 51 | MOVQ CX,R9 52 | CMOVQEQ R8,CX 53 | CMOVQEQ R9,R8 54 | MOVQ SI,32(DI) 55 | MOVQ DX,112(DI) 56 | MOVQ CX,40(DI) 57 | MOVQ R8,120(DI) 58 | MOVQ 48(DI),SI 59 | MOVQ 128(DI),DX 60 | MOVQ 56(DI),CX 61 | MOVQ 136(DI),R8 62 | MOVQ SI,R9 63 | CMOVQEQ DX,SI 64 | CMOVQEQ R9,DX 65 | MOVQ CX,R9 66 | CMOVQEQ R8,CX 67 | CMOVQEQ R9,R8 68 | MOVQ SI,48(DI) 69 | MOVQ DX,128(DI) 70 | MOVQ CX,56(DI) 71 | MOVQ R8,136(DI) 72 | MOVQ 64(DI),SI 73 | MOVQ 144(DI),DX 74 | MOVQ 72(DI),CX 75 | MOVQ 152(DI),R8 76 | MOVQ SI,R9 77 | CMOVQEQ DX,SI 78 | CMOVQEQ R9,DX 79 | MOVQ CX,R9 80 | CMOVQEQ R8,CX 81 | CMOVQEQ R9,R8 82 | MOVQ SI,64(DI) 83 | MOVQ DX,144(DI) 84 | MOVQ CX,72(DI) 85 | MOVQ R8,152(DI) 86 | MOVQ DI,AX 87 | MOVQ SI,DX 88 | RET 89 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package curve25519 provides an implementation of scalar multiplication on 6 | // the elliptic curve known as curve25519. See http://cr.yp.to/ecdh.html 7 | package curve25519 // import "golang.org/x/crypto/curve25519" 8 | 9 | // basePoint is the x coordinate of the generator of the curve. 10 | var basePoint = [32]byte{9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 11 | 12 | // ScalarMult sets dst to the product in*base where dst and base are the x 13 | // coordinates of group points and all values are in little-endian form. 14 | func ScalarMult(dst, in, base *[32]byte) { 15 | scalarMult(dst, in, base) 16 | } 17 | 18 | // ScalarBaseMult sets dst to the product in*base where dst and base are the x 19 | // coordinates of group points, base is the standard generator and all values 20 | // are in little-endian form. 21 | func ScalarBaseMult(dst, in *[32]byte) { 22 | ScalarMult(dst, in, &basePoint) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/freeze_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | // func freeze(inout *[5]uint64) 11 | TEXT ·freeze(SB),7,$96-8 12 | MOVQ inout+0(FP), DI 13 | 14 | MOVQ SP,R11 15 | MOVQ $31,CX 16 | NOTQ CX 17 | ANDQ CX,SP 18 | ADDQ $32,SP 19 | 20 | MOVQ R11,0(SP) 21 | MOVQ R12,8(SP) 22 | MOVQ R13,16(SP) 23 | MOVQ R14,24(SP) 24 | MOVQ R15,32(SP) 25 | MOVQ BX,40(SP) 26 | MOVQ BP,48(SP) 27 | MOVQ 0(DI),SI 28 | MOVQ 8(DI),DX 29 | MOVQ 16(DI),CX 30 | MOVQ 24(DI),R8 31 | MOVQ 32(DI),R9 32 | MOVQ ·REDMASK51(SB),AX 33 | MOVQ AX,R10 34 | SUBQ $18,R10 35 | MOVQ $3,R11 36 | REDUCELOOP: 37 | MOVQ SI,R12 38 | SHRQ $51,R12 39 | ANDQ AX,SI 40 | ADDQ R12,DX 41 | MOVQ DX,R12 42 | SHRQ $51,R12 43 | ANDQ AX,DX 44 | ADDQ R12,CX 45 | MOVQ CX,R12 46 | SHRQ $51,R12 47 | ANDQ AX,CX 48 | ADDQ R12,R8 49 | MOVQ R8,R12 50 | SHRQ $51,R12 51 | ANDQ AX,R8 52 | ADDQ R12,R9 53 | MOVQ R9,R12 54 | SHRQ $51,R12 55 | ANDQ AX,R9 56 | IMUL3Q $19,R12,R12 57 | ADDQ R12,SI 58 | SUBQ $1,R11 59 | JA REDUCELOOP 60 | MOVQ $1,R12 61 | CMPQ R10,SI 62 | CMOVQLT R11,R12 63 | CMPQ AX,DX 64 | CMOVQNE R11,R12 65 | CMPQ AX,CX 66 | CMOVQNE R11,R12 67 | CMPQ AX,R8 68 | CMOVQNE R11,R12 69 | CMPQ AX,R9 70 | CMOVQNE R11,R12 71 | NEGQ R12 72 | ANDQ R12,AX 73 | ANDQ R12,R10 74 | SUBQ R10,SI 75 | SUBQ AX,DX 76 | SUBQ AX,CX 77 | SUBQ AX,R8 78 | SUBQ AX,R9 79 | MOVQ SI,0(DI) 80 | MOVQ DX,8(DI) 81 | MOVQ CX,16(DI) 82 | MOVQ R8,24(DI) 83 | MOVQ R9,32(DI) 84 | MOVQ 0(SP),R11 85 | MOVQ 8(SP),R12 86 | MOVQ 16(SP),R13 87 | MOVQ 24(SP),R14 88 | MOVQ 32(SP),R15 89 | MOVQ 40(SP),BX 90 | MOVQ 48(SP),BP 91 | MOVQ R11,SP 92 | MOVQ DI,AX 93 | MOVQ SI,DX 94 | RET 95 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/square_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This code was translated into a form compatible with 6a from the public 6 | // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html 7 | 8 | // +build amd64,!gccgo,!appengine 9 | 10 | // func square(out, in *[5]uint64) 11 | TEXT ·square(SB),7,$96-16 12 | MOVQ out+0(FP), DI 13 | MOVQ in+8(FP), SI 14 | 15 | MOVQ SP,R11 16 | MOVQ $31,CX 17 | NOTQ CX 18 | ANDQ CX,SP 19 | ADDQ $32, SP 20 | 21 | MOVQ R11,0(SP) 22 | MOVQ R12,8(SP) 23 | MOVQ R13,16(SP) 24 | MOVQ R14,24(SP) 25 | MOVQ R15,32(SP) 26 | MOVQ BX,40(SP) 27 | MOVQ BP,48(SP) 28 | MOVQ 0(SI),AX 29 | MULQ 0(SI) 30 | MOVQ AX,CX 31 | MOVQ DX,R8 32 | MOVQ 0(SI),AX 33 | SHLQ $1,AX 34 | MULQ 8(SI) 35 | MOVQ AX,R9 36 | MOVQ DX,R10 37 | MOVQ 0(SI),AX 38 | SHLQ $1,AX 39 | MULQ 16(SI) 40 | MOVQ AX,R11 41 | MOVQ DX,R12 42 | MOVQ 0(SI),AX 43 | SHLQ $1,AX 44 | MULQ 24(SI) 45 | MOVQ AX,R13 46 | MOVQ DX,R14 47 | MOVQ 0(SI),AX 48 | SHLQ $1,AX 49 | MULQ 32(SI) 50 | MOVQ AX,R15 51 | MOVQ DX,BX 52 | MOVQ 8(SI),AX 53 | MULQ 8(SI) 54 | ADDQ AX,R11 55 | ADCQ DX,R12 56 | MOVQ 8(SI),AX 57 | SHLQ $1,AX 58 | MULQ 16(SI) 59 | ADDQ AX,R13 60 | ADCQ DX,R14 61 | MOVQ 8(SI),AX 62 | SHLQ $1,AX 63 | MULQ 24(SI) 64 | ADDQ AX,R15 65 | ADCQ DX,BX 66 | MOVQ 8(SI),DX 67 | IMUL3Q $38,DX,AX 68 | MULQ 32(SI) 69 | ADDQ AX,CX 70 | ADCQ DX,R8 71 | MOVQ 16(SI),AX 72 | MULQ 16(SI) 73 | ADDQ AX,R15 74 | ADCQ DX,BX 75 | MOVQ 16(SI),DX 76 | IMUL3Q $38,DX,AX 77 | MULQ 24(SI) 78 | ADDQ AX,CX 79 | ADCQ DX,R8 80 | MOVQ 16(SI),DX 81 | IMUL3Q $38,DX,AX 82 | MULQ 32(SI) 83 | ADDQ AX,R9 84 | ADCQ DX,R10 85 | MOVQ 24(SI),DX 86 | IMUL3Q $19,DX,AX 87 | MULQ 24(SI) 88 | ADDQ AX,R9 89 | ADCQ DX,R10 90 | MOVQ 24(SI),DX 91 | IMUL3Q $38,DX,AX 92 | MULQ 32(SI) 93 | ADDQ AX,R11 94 | ADCQ DX,R12 95 | MOVQ 32(SI),DX 96 | IMUL3Q $19,DX,AX 97 | MULQ 32(SI) 98 | ADDQ AX,R13 99 | ADCQ DX,R14 100 | MOVQ ·REDMASK51(SB),SI 101 | SHLQ $13,R8:CX 102 | ANDQ SI,CX 103 | SHLQ $13,R10:R9 104 | ANDQ SI,R9 105 | ADDQ R8,R9 106 | SHLQ $13,R12:R11 107 | ANDQ SI,R11 108 | ADDQ R10,R11 109 | SHLQ $13,R14:R13 110 | ANDQ SI,R13 111 | ADDQ R12,R13 112 | SHLQ $13,BX:R15 113 | ANDQ SI,R15 114 | ADDQ R14,R15 115 | IMUL3Q $19,BX,DX 116 | ADDQ DX,CX 117 | MOVQ CX,DX 118 | SHRQ $51,DX 119 | ADDQ R9,DX 120 | ANDQ SI,CX 121 | MOVQ DX,R8 122 | SHRQ $51,DX 123 | ADDQ R11,DX 124 | ANDQ SI,R8 125 | MOVQ DX,R9 126 | SHRQ $51,DX 127 | ADDQ R13,DX 128 | ANDQ SI,R9 129 | MOVQ DX,AX 130 | SHRQ $51,DX 131 | ADDQ R15,DX 132 | ANDQ SI,AX 133 | MOVQ DX,R10 134 | SHRQ $51,DX 135 | IMUL3Q $19,DX,DX 136 | ADDQ DX,CX 137 | ANDQ SI,R10 138 | MOVQ CX,0(DI) 139 | MOVQ R8,8(DI) 140 | MOVQ R9,16(DI) 141 | MOVQ AX,24(DI) 142 | MOVQ R10,32(DI) 143 | MOVQ 0(SP),R11 144 | MOVQ 8(SP),R12 145 | MOVQ 16(SP),R13 146 | MOVQ 24(SP),R14 147 | MOVQ 32(SP),R15 148 | MOVQ 40(SP),BX 149 | MOVQ 48(SP),BP 150 | MOVQ R11,SP 151 | MOVQ DI,AX 152 | MOVQ SI,DX 153 | RET 154 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/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/ssh/agent/forward.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package agent 6 | 7 | import ( 8 | "errors" 9 | "io" 10 | "net" 11 | "sync" 12 | 13 | "golang.org/x/crypto/ssh" 14 | ) 15 | 16 | // RequestAgentForwarding sets up agent forwarding for the session. 17 | // ForwardToAgent or ForwardToRemote should be called to route 18 | // the authentication requests. 19 | func RequestAgentForwarding(session *ssh.Session) error { 20 | ok, err := session.SendRequest("auth-agent-req@openssh.com", true, nil) 21 | if err != nil { 22 | return err 23 | } 24 | if !ok { 25 | return errors.New("forwarding request denied") 26 | } 27 | return nil 28 | } 29 | 30 | // ForwardToAgent routes authentication requests to the given keyring. 31 | func ForwardToAgent(client *ssh.Client, keyring Agent) error { 32 | channels := client.HandleChannelOpen(channelType) 33 | if channels == nil { 34 | return errors.New("agent: already have handler for " + channelType) 35 | } 36 | 37 | go func() { 38 | for ch := range channels { 39 | channel, reqs, err := ch.Accept() 40 | if err != nil { 41 | continue 42 | } 43 | go ssh.DiscardRequests(reqs) 44 | go func() { 45 | ServeAgent(keyring, channel) 46 | channel.Close() 47 | }() 48 | } 49 | }() 50 | return nil 51 | } 52 | 53 | const channelType = "auth-agent@openssh.com" 54 | 55 | // ForwardToRemote routes authentication requests to the ssh-agent 56 | // process serving on the given unix socket. 57 | func ForwardToRemote(client *ssh.Client, addr string) error { 58 | channels := client.HandleChannelOpen(channelType) 59 | if channels == nil { 60 | return errors.New("agent: already have handler for " + channelType) 61 | } 62 | conn, err := net.Dial("unix", addr) 63 | if err != nil { 64 | return err 65 | } 66 | conn.Close() 67 | 68 | go func() { 69 | for ch := range channels { 70 | channel, reqs, err := ch.Accept() 71 | if err != nil { 72 | continue 73 | } 74 | go ssh.DiscardRequests(reqs) 75 | go forwardUnixSocket(channel, addr) 76 | } 77 | }() 78 | return nil 79 | } 80 | 81 | func forwardUnixSocket(channel ssh.Channel, addr string) { 82 | conn, err := net.Dial("unix", addr) 83 | if err != nil { 84 | return 85 | } 86 | 87 | var wg sync.WaitGroup 88 | wg.Add(2) 89 | go func() { 90 | io.Copy(conn, channel) 91 | conn.(*net.UnixConn).CloseWrite() 92 | wg.Done() 93 | }() 94 | go func() { 95 | io.Copy(channel, conn) 96 | channel.CloseWrite() 97 | wg.Done() 98 | }() 99 | 100 | wg.Wait() 101 | conn.Close() 102 | channel.Close() 103 | } 104 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/buffer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | import ( 8 | "io" 9 | "sync" 10 | ) 11 | 12 | // buffer provides a linked list buffer for data exchange 13 | // between producer and consumer. Theoretically the buffer is 14 | // of unlimited capacity as it does no allocation of its own. 15 | type buffer struct { 16 | // protects concurrent access to head, tail and closed 17 | *sync.Cond 18 | 19 | head *element // the buffer that will be read first 20 | tail *element // the buffer that will be read last 21 | 22 | closed bool 23 | } 24 | 25 | // An element represents a single link in a linked list. 26 | type element struct { 27 | buf []byte 28 | next *element 29 | } 30 | 31 | // newBuffer returns an empty buffer that is not closed. 32 | func newBuffer() *buffer { 33 | e := new(element) 34 | b := &buffer{ 35 | Cond: newCond(), 36 | head: e, 37 | tail: e, 38 | } 39 | return b 40 | } 41 | 42 | // write makes buf available for Read to receive. 43 | // buf must not be modified after the call to write. 44 | func (b *buffer) write(buf []byte) { 45 | b.Cond.L.Lock() 46 | e := &element{buf: buf} 47 | b.tail.next = e 48 | b.tail = e 49 | b.Cond.Signal() 50 | b.Cond.L.Unlock() 51 | } 52 | 53 | // eof closes the buffer. Reads from the buffer once all 54 | // the data has been consumed will receive os.EOF. 55 | func (b *buffer) eof() error { 56 | b.Cond.L.Lock() 57 | b.closed = true 58 | b.Cond.Signal() 59 | b.Cond.L.Unlock() 60 | return nil 61 | } 62 | 63 | // Read reads data from the internal buffer in buf. Reads will block 64 | // if no data is available, or until the buffer is closed. 65 | func (b *buffer) Read(buf []byte) (n int, err error) { 66 | b.Cond.L.Lock() 67 | defer b.Cond.L.Unlock() 68 | 69 | for len(buf) > 0 { 70 | // if there is data in b.head, copy it 71 | if len(b.head.buf) > 0 { 72 | r := copy(buf, b.head.buf) 73 | buf, b.head.buf = buf[r:], b.head.buf[r:] 74 | n += r 75 | continue 76 | } 77 | // if there is a next buffer, make it the head 78 | if len(b.head.buf) == 0 && b.head != b.tail { 79 | b.head = b.head.next 80 | continue 81 | } 82 | 83 | // if at least one byte has been copied, return 84 | if n > 0 { 85 | break 86 | } 87 | 88 | // if nothing was read, and there is nothing outstanding 89 | // check to see if the buffer is closed. 90 | if b.closed { 91 | err = io.EOF 92 | break 93 | } 94 | // out of buffers, wait for producer 95 | b.Cond.Wait() 96 | } 97 | return 98 | } 99 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package ssh implements an SSH client and server. 7 | 8 | SSH is a transport security protocol, an authentication protocol and a 9 | family of application protocols. The most typical application level 10 | protocol is a remote shell and this is specifically implemented. However, 11 | the multiplexed nature of SSH is exposed to users that wish to support 12 | others. 13 | 14 | References: 15 | [PROTOCOL.certkeys]: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys?rev=HEAD 16 | [SSH-PARAMETERS]: http://www.iana.org/assignments/ssh-parameters/ssh-parameters.xml#ssh-parameters-1 17 | */ 18 | package ssh // import "golang.org/x/crypto/ssh" 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/mac.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | // Message authentication support 8 | 9 | import ( 10 | "crypto/hmac" 11 | "crypto/sha1" 12 | "crypto/sha256" 13 | "hash" 14 | ) 15 | 16 | type macMode struct { 17 | keySize int 18 | new func(key []byte) hash.Hash 19 | } 20 | 21 | // truncatingMAC wraps around a hash.Hash and truncates the output digest to 22 | // a given size. 23 | type truncatingMAC struct { 24 | length int 25 | hmac hash.Hash 26 | } 27 | 28 | func (t truncatingMAC) Write(data []byte) (int, error) { 29 | return t.hmac.Write(data) 30 | } 31 | 32 | func (t truncatingMAC) Sum(in []byte) []byte { 33 | out := t.hmac.Sum(in) 34 | return out[:len(in)+t.length] 35 | } 36 | 37 | func (t truncatingMAC) Reset() { 38 | t.hmac.Reset() 39 | } 40 | 41 | func (t truncatingMAC) Size() int { 42 | return t.length 43 | } 44 | 45 | func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() } 46 | 47 | var macModes = map[string]*macMode{ 48 | "hmac-sha2-256": {32, func(key []byte) hash.Hash { 49 | return hmac.New(sha256.New, key) 50 | }}, 51 | "hmac-sha1": {20, func(key []byte) hash.Hash { 52 | return hmac.New(sha1.New, key) 53 | }}, 54 | "hmac-sha1-96": {20, func(key []byte) hash.Hash { 55 | return truncatingMAC{12, hmac.New(sha1.New, key)} 56 | }}, 57 | } 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd netbsd openbsd 6 | 7 | package terminal 8 | 9 | import "syscall" 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | const ioctlWriteTermios = syscall.TIOCSETA 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package terminal 6 | 7 | // These constants are declared here, rather than importing 8 | // them from the syscall package as some syscall packages, even 9 | // on linux, for example gccgo, do not declare them. 10 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 11 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/test/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This package contains integration tests for the 6 | // golang.org/x/crypto/ssh package. 7 | package test // import "golang.org/x/crypto/ssh/test" 8 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/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/sys/unix/asm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | TEXT ·use(SB),NOSPLIT,$0 10 | RET 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_386.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-32 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-44 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-56 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-32 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-44 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·socketcall(SB),NOSPLIT,$0-36 29 | JMP syscall·socketcall(SB) 30 | 31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 32 | JMP syscall·rawsocketcall(SB) 33 | 34 | TEXT ·seek(SB),NOSPLIT,$0-28 35 | JMP syscall·seek(SB) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 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 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-64 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.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 darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.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 darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *((*Ucred)(cmsgData(h))) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.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 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.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 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix // import "golang.org/x/sys/unix" 23 | 24 | import "unsafe" 25 | 26 | // ByteSliceFromString returns a NUL-terminated slice of bytes 27 | // containing the text of s. If s contains a NUL byte at any 28 | // location, it returns (nil, EINVAL). 29 | func ByteSliceFromString(s string) ([]byte, error) { 30 | for i := 0; i < len(s); i++ { 31 | if s[i] == 0 { 32 | return nil, EINVAL 33 | } 34 | } 35 | a := make([]byte, len(s)+1) 36 | copy(a, s) 37 | return a, nil 38 | } 39 | 40 | // BytePtrFromString returns a pointer to a NUL-terminated array of 41 | // bytes containing the text of s. If s contains a NUL byte at any 42 | // location, it returns (nil, EINVAL). 43 | func BytePtrFromString(s string) (*byte, error) { 44 | a, err := ByteSliceFromString(s) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return &a[0], nil 49 | } 50 | 51 | // Single-word zero for use when we need a valid pointer to 0 bytes. 52 | // See mkunix.pl. 53 | var _zero uintptr 54 | 55 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 56 | return int64(ts.Sec), int64(ts.Nsec) 57 | } 58 | 59 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 60 | return int64(tv.Sec), int64(tv.Usec) * 1000 61 | } 62 | 63 | func (ts *Timespec) Nano() int64 { 64 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 65 | } 66 | 67 | func (tv *Timeval) Nano() int64 { 68 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 69 | } 70 | 71 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 72 | 73 | // use is a no-op, but the compiler cannot see that it is. 74 | // Calling use(p) ensures that p is kept live until that point. 75 | //go:noescape 76 | func use(p unsafe.Pointer) 77 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.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 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.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 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) 15 | 16 | func Getpagesize() int { return 4096 } 17 | 18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 19 | 20 | func NsecToTimespec(nsec int64) (ts Timespec) { 21 | ts.Sec = nsec / 1e9 22 | ts.Nsec = nsec % 1e9 23 | return 24 | } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func NsecToTimeval(nsec int64) (tv Timeval) { 23 | nsec += 999 // round up to microsecond 24 | tv.Usec = int32(nsec % 1e9 / 1e3) 25 | tv.Sec = int32(nsec / 1e9) 26 | return 27 | } 28 | 29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 30 | func Gettimeofday(tv *Timeval) (err error) { 31 | // The tv passed to gettimeofday must be non-nil 32 | // but is otherwise unused. The answers come back 33 | // in the two registers. 34 | sec, usec, err := gettimeofday(tv) 35 | tv.Sec = int32(sec) 36 | tv.Usec = int32(usec) 37 | return err 38 | } 39 | 40 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 41 | k.Ident = uint32(fd) 42 | k.Filter = int16(mode) 43 | k.Flags = uint16(flags) 44 | } 45 | 46 | func (iov *Iovec) SetLen(length int) { 47 | iov.Len = uint32(length) 48 | } 49 | 50 | func (msghdr *Msghdr) SetControllen(length int) { 51 | msghdr.Controllen = uint32(length) 52 | } 53 | 54 | func (cmsg *Cmsghdr) SetLen(length int) { 55 | cmsg.Len = uint32(length) 56 | } 57 | 58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 59 | var length = uint64(count) 60 | 61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 62 | 63 | written = int(length) 64 | 65 | if e1 != 0 { 66 | err = e1 67 | } 68 | return 69 | } 70 | 71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_386.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 | // +build 386,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.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 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.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 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.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 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.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 arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.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 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.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 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.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 arm,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_no_getwd.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 dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.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 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.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 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = nsec / 1e9 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.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 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 10 | 11 | func NsecToTimespec(nsec int64) (ts Timespec) { 12 | ts.Sec = nsec / 1e9 13 | ts.Nsec = nsec % 1e9 14 | return 15 | } 16 | 17 | func NsecToTimeval(nsec int64) (tv Timeval) { 18 | nsec += 999 // round up to microsecond 19 | tv.Usec = nsec % 1e9 / 1e3 20 | tv.Sec = int64(nsec / 1e9) 21 | return 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (cmsg *Cmsghdr) SetLen(length int) { 29 | cmsg.Len = uint32(length) 30 | } 31 | 32 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 33 | // TODO(aram): implement this, see issue 5847. 34 | panic("unimplemented") 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/gopkg.in/airbrake/gobrake.v2/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 The Gobrake 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/gopkg.in/airbrake/gobrake.v2/gobrake.go: -------------------------------------------------------------------------------- 1 | package gobrake 2 | 3 | import ( 4 | "log" 5 | "os" 6 | ) 7 | 8 | var logger *log.Logger 9 | 10 | func init() { 11 | SetLogger(log.New(os.Stderr, "gobrake: ", log.LstdFlags)) 12 | } 13 | 14 | func SetLogger(l *log.Logger) { 15 | logger = l 16 | } 17 | -------------------------------------------------------------------------------- /vendor/gopkg.in/airbrake/gobrake.v2/notice.go: -------------------------------------------------------------------------------- 1 | package gobrake 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "os" 7 | "path/filepath" 8 | "runtime" 9 | ) 10 | 11 | var defaultContext map[string]interface{} 12 | 13 | func getDefaultContext() map[string]interface{} { 14 | if defaultContext != nil { 15 | return defaultContext 16 | } 17 | 18 | defaultContext = map[string]interface{}{ 19 | "notifier": map[string]interface{}{ 20 | "name": "gobrake", 21 | "version": "2.0.4", 22 | "url": "https://github.com/airbrake/gobrake", 23 | }, 24 | 25 | "language": runtime.Version(), 26 | "os": runtime.GOOS, 27 | "architecture": runtime.GOARCH, 28 | } 29 | if s, err := os.Hostname(); err == nil { 30 | defaultContext["hostname"] = s 31 | } 32 | if s, ok := os.LookupEnv("GOPATH"); ok { 33 | list := filepath.SplitList(s) 34 | // TODO: multiple root dirs? 35 | defaultContext["rootDirectory"] = list[0] 36 | } 37 | return defaultContext 38 | } 39 | 40 | type Error struct { 41 | Type string `json:"type"` 42 | Message string `json:"message"` 43 | Backtrace []StackFrame `json:"backtrace"` 44 | } 45 | 46 | type Notice struct { 47 | Errors []Error `json:"errors"` 48 | Context map[string]interface{} `json:"context"` 49 | Env map[string]interface{} `json:"environment"` 50 | Session map[string]interface{} `json:"session"` 51 | Params map[string]interface{} `json:"params"` 52 | } 53 | 54 | func (n *Notice) String() string { 55 | if len(n.Errors) == 0 { 56 | return fmt.Sprint(n) 57 | } 58 | e := n.Errors[0] 59 | return fmt.Sprintf("%s: %s", e.Type, e.Message) 60 | } 61 | 62 | func NewNotice(e interface{}, req *http.Request, depth int) *Notice { 63 | notice := &Notice{ 64 | Errors: []Error{{ 65 | Type: fmt.Sprintf("%T", e), 66 | Message: fmt.Sprint(e), 67 | Backtrace: stack(depth), 68 | }}, 69 | Context: map[string]interface{}{}, 70 | Env: map[string]interface{}{}, 71 | Session: map[string]interface{}{}, 72 | Params: map[string]interface{}{}, 73 | } 74 | 75 | for k, v := range getDefaultContext() { 76 | notice.Context[k] = v 77 | } 78 | 79 | if req != nil { 80 | notice.Context["url"] = req.URL.String() 81 | if ua := req.Header.Get("User-Agent"); ua != "" { 82 | notice.Context["userAgent"] = ua 83 | } 84 | 85 | for k, v := range req.Header { 86 | if len(v) == 1 { 87 | notice.Env[k] = v[0] 88 | } else { 89 | notice.Env[k] = v 90 | } 91 | } 92 | 93 | if err := req.ParseForm(); err == nil { 94 | for k, v := range req.Form { 95 | if len(v) == 1 { 96 | notice.Params[k] = v[0] 97 | } else { 98 | notice.Params[k] = v 99 | } 100 | } 101 | } 102 | } 103 | 104 | return notice 105 | } 106 | -------------------------------------------------------------------------------- /vendor/gopkg.in/airbrake/gobrake.v2/util.go: -------------------------------------------------------------------------------- 1 | package gobrake 2 | 3 | import ( 4 | "runtime" 5 | "strings" 6 | ) 7 | 8 | func stackFilter(packageName, funcName string, file string, line int) bool { 9 | return packageName == "runtime" && funcName == "panic" 10 | } 11 | 12 | type StackFrame struct { 13 | File string `json:"file"` 14 | Line int `json:"line"` 15 | Func string `json:"function"` 16 | } 17 | 18 | func stack(depth int) []StackFrame { 19 | stack := []StackFrame{} 20 | for i := depth; ; i++ { 21 | pc, file, line, ok := runtime.Caller(i) 22 | if !ok { 23 | break 24 | } 25 | packageName, funcName := packageFuncName(pc) 26 | if stackFilter(packageName, funcName, file, line) { 27 | stack = stack[:0] 28 | continue 29 | } 30 | stack = append(stack, StackFrame{ 31 | File: file, 32 | Line: line, 33 | Func: funcName, 34 | }) 35 | } 36 | 37 | return stack 38 | } 39 | 40 | func packageFuncName(pc uintptr) (string, string) { 41 | f := runtime.FuncForPC(pc) 42 | if f == nil { 43 | return "", "" 44 | } 45 | 46 | packageName := "" 47 | funcName := f.Name() 48 | 49 | if ind := strings.LastIndex(funcName, "/"); ind > 0 { 50 | packageName += funcName[:ind+1] 51 | funcName = funcName[ind+1:] 52 | } 53 | if ind := strings.Index(funcName, "."); ind > 0 { 54 | packageName += funcName[:ind] 55 | funcName = funcName[ind+1:] 56 | } 57 | 58 | return packageName, funcName 59 | } 60 | -------------------------------------------------------------------------------- /vendor/gopkg.in/gemnasium/logrus-airbrake-hook.v2/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Gemnasium 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/gopkg.in/gemnasium/logrus-airbrake-hook.v2/airbrake.go: -------------------------------------------------------------------------------- 1 | package airbrake // import "gopkg.in/gemnasium/logrus-airbrake-hook.v2" 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "net/http" 7 | "os" 8 | 9 | "github.com/Sirupsen/logrus" 10 | "gopkg.in/airbrake/gobrake.v2" 11 | ) 12 | 13 | // AirbrakeHook to send exceptions to an exception-tracking service compatible 14 | // with the Airbrake API. 15 | type airbrakeHook struct { 16 | Airbrake *gobrake.Notifier 17 | } 18 | 19 | func NewHook(projectID int64, apiKey, env string) *airbrakeHook { 20 | airbrake := gobrake.NewNotifier(projectID, apiKey) 21 | airbrake.AddFilter(func(notice *gobrake.Notice) *gobrake.Notice { 22 | if env == "development" { 23 | return nil 24 | } 25 | notice.Context["environment"] = env 26 | return notice 27 | }) 28 | hook := &airbrakeHook{ 29 | Airbrake: airbrake, 30 | } 31 | return hook 32 | } 33 | 34 | func (hook *airbrakeHook) Fire(entry *logrus.Entry) error { 35 | var notifyErr error 36 | err, ok := entry.Data["error"].(error) 37 | if ok { 38 | notifyErr = err 39 | } else { 40 | notifyErr = errors.New(entry.Message) 41 | } 42 | var req *http.Request 43 | for k, v := range entry.Data { 44 | if r, ok := v.(*http.Request); ok { 45 | req = r 46 | delete(entry.Data, k) 47 | break 48 | } 49 | } 50 | notice := hook.Airbrake.Notice(notifyErr, req, 3) 51 | for k, v := range entry.Data { 52 | notice.Context[k] = fmt.Sprintf("%s", v) 53 | } 54 | 55 | hook.sendNotice(notice) 56 | return nil 57 | } 58 | 59 | func (hook *airbrakeHook) sendNotice(notice *gobrake.Notice) { 60 | if _, err := hook.Airbrake.SendNotice(notice); err != nil { 61 | fmt.Fprintf(os.Stderr, "Failed to send error to Airbrake: %v\n", err) 62 | } 63 | } 64 | 65 | func (hook *airbrakeHook) Levels() []logrus.Level { 66 | return []logrus.Level{ 67 | logrus.ErrorLevel, 68 | logrus.FatalLevel, 69 | logrus.PanicLevel, 70 | } 71 | } 72 | --------------------------------------------------------------------------------