├── .gitignore ├── Dockerfile ├── Dockerfile.auto ├── Dockerfile.build ├── Makefile ├── commands ├── bundle │ ├── bundle.go │ └── generate.go ├── ca │ ├── ca.go │ └── generate.go ├── client │ ├── client.go │ └── generate.go └── server │ ├── generate.go │ └── server.go ├── main.go ├── readme.md ├── script ├── build ├── generate-sums ├── release └── test ├── test └── integration │ ├── certs.bats │ ├── cli.bats │ └── helpers.bash ├── utils └── utils.go ├── vendor.conf ├── vendor ├── github.com │ ├── codegangsta │ │ └── cli │ │ │ ├── LICENSE │ │ │ ├── app.go │ │ │ ├── category.go │ │ │ ├── cli.go │ │ │ ├── command.go │ │ │ ├── context.go │ │ │ ├── errors.go │ │ │ ├── flag.go │ │ │ ├── flag_generated.go │ │ │ ├── funcs.go │ │ │ └── help.go │ ├── ehazlett │ │ ├── simplelog │ │ │ ├── simple.go │ │ │ └── standard.go │ │ └── tlsutils │ │ │ └── tlsutils.go │ └── sirupsen │ │ └── logrus │ │ ├── LICENSE │ │ ├── alt_exit.go │ │ ├── doc.go │ │ ├── entry.go │ │ ├── exported.go │ │ ├── formatter.go │ │ ├── hooks.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 └── golang.org │ └── x │ └── sys │ ├── LICENSE │ ├── PATENTS │ └── unix │ ├── asm_darwin_386.s │ ├── asm_darwin_amd64.s │ ├── asm_darwin_arm.s │ ├── asm_darwin_arm64.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_mipsx.s │ ├── asm_linux_ppc64x.s │ ├── asm_linux_s390x.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 │ ├── bluetooth_linux.go │ ├── constants.go │ ├── env_unix.go │ ├── env_unset.go │ ├── flock.go │ ├── flock_linux_32bit.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── gccgo_linux_sparc64.go │ ├── mkpost.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_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_amd64_gc.go │ ├── syscall_linux_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_mipsx.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_s390x.go │ ├── syscall_linux_sparc64.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 │ ├── syscall_unix_gc.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_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_mips.go │ ├── zerrors_linux_mips64.go │ ├── zerrors_linux_mips64le.go │ ├── zerrors_linux_mipsle.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_linux_s390x.go │ ├── zerrors_linux_sparc64.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_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_mips.go │ ├── zsyscall_linux_mips64.go │ ├── zsyscall_linux_mips64le.go │ ├── zsyscall_linux_mipsle.go │ ├── zsyscall_linux_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_linux_s390x.go │ ├── zsyscall_linux_sparc64.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_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_mips.go │ ├── zsysnum_linux_mips64.go │ ├── zsysnum_linux_mips64le.go │ ├── zsysnum_linux_mipsle.go │ ├── zsysnum_linux_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_linux_s390x.go │ ├── zsysnum_linux_sparc64.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_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_mips.go │ ├── ztypes_linux_mips64.go │ ├── ztypes_linux_mips64le.go │ ├── ztypes_linux_mipsle.go │ ├── ztypes_linux_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_linux_s390x.go │ ├── ztypes_linux_sparc64.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 └── version └── version.go /.gitignore: -------------------------------------------------------------------------------- 1 | certm 2 | certm_* 3 | .idea/ -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | COPY certm /usr/local/bin/certm 3 | ENTRYPOINT ["certm"] -------------------------------------------------------------------------------- /Dockerfile.auto: -------------------------------------------------------------------------------- 1 | FROM golang:1.4-cross 2 | 3 | RUN go get github.com/tools/godep 4 | RUN go get github.com/aktau/github-release 5 | RUN go get github.com/mitchellh/gox 6 | 7 | RUN gox -build-toolchain 8 | 9 | ADD . /go/src/github.com/ehazlett/certm 10 | 11 | ENV BINARY_SHA 386f6e91114dc252a13b266fe2ac3a27e83bd0f7 12 | RUN curl -fL https://get.docker.com/builds/Linux/x86_64/docker-1.7.1 -o /usr/local/bin/docker \ 13 | && echo "$BINARY_SHA /usr/local/bin/docker" | sha1sum -c - 14 | 15 | RUN chmod +x /usr/local/bin/docker 16 | 17 | RUN (git clone https://github.com/sstephenson/bats.git && \ 18 | cd bats && ./install.sh /usr/local) 19 | 20 | ENV SHELL /bin/bash 21 | 22 | WORKDIR /go/src/github.com/ehazlett/certm 23 | RUN make && cp certm /bin/certm 24 | ENTRYPOINT ["/bin/certm"] 25 | -------------------------------------------------------------------------------- /Dockerfile.build: -------------------------------------------------------------------------------- 1 | FROM golang:1.4-cross 2 | 3 | RUN go get github.com/tools/godep 4 | RUN go get github.com/aktau/github-release 5 | RUN go get github.com/mitchellh/gox 6 | 7 | RUN gox -build-toolchain 8 | 9 | ADD . /go/src/github.com/ehazlett/certm 10 | 11 | ENV BINARY_SHA 386f6e91114dc252a13b266fe2ac3a27e83bd0f7 12 | RUN curl -fL https://get.docker.com/builds/Linux/x86_64/docker-1.7.1 -o /usr/local/bin/docker \ 13 | && echo "$BINARY_SHA /usr/local/bin/docker" | sha1sum -c - 14 | 15 | RUN chmod +x /usr/local/bin/docker 16 | 17 | RUN (git clone https://github.com/sstephenson/bats.git && \ 18 | cd bats && ./install.sh /usr/local) 19 | 20 | ENV SHELL /bin/bash 21 | 22 | WORKDIR /go/src/github.com/ehazlett/certm 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CGO_ENABLED=0 2 | GOOS=linux 3 | GOARCH=amd64 4 | APP=certm 5 | REPO=ehazlett/$(APP) 6 | TAG=${TAG:-latest} 7 | OS="darwin windows linux" 8 | ARCH="amd64 386" 9 | COMMIT=`git rev-parse --short HEAD` 10 | 11 | all: build 12 | 13 | clean: 14 | @rm -rf certm certm_* 15 | 16 | build: 17 | @go build -a -tags 'netgo' -ldflags "-w -X github.com/$(REPO)/version.GitCommit=$(COMMIT) -linkmode external -extldflags -static" . 18 | 19 | build-cross: 20 | @gox -os=$(OS) -arch=$(ARCH) -ldflags "-w -X github.com/$(REPO)/version.GitCommit=$(COMMIT) -linkmode external -extldflags -static" -output="certm_{{.OS}}_{{.Arch}}" 21 | 22 | image: build 23 | @echo Building image $(TAG) 24 | @docker build -t $(REPO):$(TAG) . 25 | 26 | release: deps build image 27 | @docker push $(REPO):$(TAG) 28 | 29 | test: 30 | @bats test/integration/cli.bats test/integration/certs.bats 31 | 32 | .PHONY: all build clean image test release 33 | -------------------------------------------------------------------------------- /commands/bundle/bundle.go: -------------------------------------------------------------------------------- 1 | package bundle 2 | 3 | import ( 4 | "github.com/codegangsta/cli" 5 | ) 6 | 7 | var CmdBundle = cli.Command{ 8 | Name: "bundle", 9 | Usage: "generate CA, server and client certs", 10 | Subcommands: []cli.Command{ 11 | cmdGenerate, 12 | }, 13 | } 14 | 15 | var cmdGenerate = cli.Command{ 16 | Name: "generate", 17 | Usage: "generate new bundle", 18 | Action: generate, 19 | Flags: []cli.Flag{ 20 | cli.StringSliceFlag{ 21 | Name: "host", 22 | Value: &cli.StringSlice{}, 23 | Usage: "SAN/IP SAN for certificate", 24 | }, 25 | cli.StringFlag{ 26 | Name: "org, o", 27 | Value: "unknown", 28 | Usage: "organization", 29 | }, 30 | cli.IntFlag{ 31 | Name: "bits, b", 32 | Value: 2048, 33 | Usage: "number of bits in the key (default: 2048)", 34 | }, 35 | cli.BoolFlag{ 36 | Name: "overwrite", 37 | Usage: "overwrite existing certificates and keys", 38 | }, 39 | }, 40 | } 41 | -------------------------------------------------------------------------------- /commands/bundle/generate.go: -------------------------------------------------------------------------------- 1 | package bundle 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "path/filepath" 7 | 8 | log "github.com/sirupsen/logrus" 9 | "github.com/codegangsta/cli" 10 | "github.com/ehazlett/certm/utils" 11 | "github.com/ehazlett/tlsutils" 12 | ) 13 | 14 | func generate(c *cli.Context) { 15 | outputDir := c.GlobalString("output-directory") 16 | if outputDir == "" { 17 | cli.ShowAppHelp(c) 18 | log.Fatalf("you must specify an output directory") 19 | } 20 | 21 | hosts := c.StringSlice("host") 22 | caCertPath := filepath.Join(outputDir, "ca.pem") 23 | caKeyPath := filepath.Join(outputDir, "ca-key.pem") 24 | serverCertPath := filepath.Join(outputDir, "server.pem") 25 | serverKeyPath := filepath.Join(outputDir, "server-key.pem") 26 | clientCertPath := filepath.Join(outputDir, "cert.pem") 27 | clientKeyPath := filepath.Join(outputDir, "key.pem") 28 | org := c.String("org") 29 | bits := c.Int("bits") 30 | overwrite := c.Bool("overwrite") 31 | 32 | log.Printf("generating ca: org=%s bits=%d", org, bits) 33 | 34 | log.Debugf("creating output dir: path=%s", outputDir) 35 | if err := os.MkdirAll(outputDir, 0700); err != nil { 36 | log.Fatal(err) 37 | } 38 | 39 | // ca cert 40 | if err := utils.CreateIfNotExists(caCertPath, overwrite); err != nil { 41 | log.Fatal(err) 42 | } 43 | 44 | // ca key 45 | if err := utils.CreateIfNotExists(caKeyPath, overwrite); err != nil { 46 | log.Fatal(err) 47 | } 48 | 49 | // server cert 50 | if err := utils.CreateIfNotExists(serverCertPath, overwrite); err != nil { 51 | log.Fatal(err) 52 | } 53 | 54 | // server key 55 | if err := utils.CreateIfNotExists(serverKeyPath, overwrite); err != nil { 56 | log.Fatal(err) 57 | } 58 | 59 | // client cert 60 | if err := utils.CreateIfNotExists(clientCertPath, overwrite); err != nil { 61 | log.Fatal(err) 62 | } 63 | 64 | // client key 65 | if err := utils.CreateIfNotExists(clientKeyPath, overwrite); err != nil { 66 | log.Fatal(err) 67 | } 68 | 69 | // generate ca 70 | caCert, caKey, err := tlsutils.GenerateCACertificate(org, bits) 71 | if err != nil { 72 | log.Fatal(err) 73 | } 74 | 75 | log.Debugf("creating ca certificate: path=%s", caCertPath) 76 | if err := ioutil.WriteFile(caCertPath, caCert, 0600); err != nil { 77 | log.Fatal(err) 78 | } 79 | 80 | log.Debugf("creating ca key: path=%s", caKeyPath) 81 | if err := ioutil.WriteFile(caKeyPath, caKey, 0600); err != nil { 82 | log.Fatal(err) 83 | } 84 | 85 | // generate client 86 | clientCert, clientKey, err := tlsutils.GenerateCertificate( 87 | nil, 88 | caCert, 89 | caKey, 90 | org, 91 | "", 92 | bits, 93 | ) 94 | if err != nil { 95 | log.Fatal(err) 96 | } 97 | 98 | log.Debugf("creating client certificate: path=%s", clientCertPath) 99 | if err := ioutil.WriteFile(clientCertPath, clientCert, 0600); err != nil { 100 | log.Fatal(err) 101 | } 102 | 103 | log.Debugf("creating client key: path=%s", clientKeyPath) 104 | if err := ioutil.WriteFile(clientKeyPath, clientKey, 0600); err != nil { 105 | log.Fatal(err) 106 | } 107 | 108 | // generate server 109 | serverCert, serverKey, err := tlsutils.GenerateCertificate( 110 | hosts, 111 | caCert, 112 | caKey, 113 | org, 114 | "", 115 | bits, 116 | ) 117 | if err != nil { 118 | log.Fatal(err) 119 | } 120 | 121 | log.Debugf("creating server certificate: path=%s", serverCertPath) 122 | if err := ioutil.WriteFile(serverCertPath, serverCert, 0600); err != nil { 123 | log.Fatal(err) 124 | } 125 | 126 | log.Debugf("creating server key: path=%s", serverKeyPath) 127 | if err := ioutil.WriteFile(serverKeyPath, serverKey, 0600); err != nil { 128 | log.Fatal(err) 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /commands/ca/ca.go: -------------------------------------------------------------------------------- 1 | package ca 2 | 3 | import ( 4 | "github.com/codegangsta/cli" 5 | ) 6 | 7 | var CmdCA = cli.Command{ 8 | Name: "ca", 9 | Usage: "CA certificate management", 10 | Subcommands: []cli.Command{ 11 | cmdGenerate, 12 | }, 13 | } 14 | 15 | var cmdGenerate = cli.Command{ 16 | Name: "generate", 17 | Usage: "generate new certificate", 18 | Action: generate, 19 | Flags: []cli.Flag{ 20 | cli.StringFlag{ 21 | Name: "org, o", 22 | Value: "unknown", 23 | Usage: "organization", 24 | }, 25 | cli.IntFlag{ 26 | Name: "bits, b", 27 | Value: 2048, 28 | Usage: "number of bits in the key (default: 2048)", 29 | }, 30 | cli.BoolFlag{ 31 | Name: "overwrite", 32 | Usage: "overwrite existing certificates and keys", 33 | }, 34 | }, 35 | } 36 | -------------------------------------------------------------------------------- /commands/ca/generate.go: -------------------------------------------------------------------------------- 1 | package ca 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "path/filepath" 7 | 8 | log "github.com/sirupsen/logrus" 9 | "github.com/codegangsta/cli" 10 | "github.com/ehazlett/certm/utils" 11 | "github.com/ehazlett/tlsutils" 12 | ) 13 | 14 | func generate(c *cli.Context) { 15 | outputDir := c.GlobalString("output-directory") 16 | if outputDir == "" { 17 | cli.ShowAppHelp(c) 18 | log.Fatalf("you must specify an output directory") 19 | } 20 | 21 | caCertPath := filepath.Join(outputDir, "ca.pem") 22 | caKeyPath := filepath.Join(outputDir, "ca-key.pem") 23 | org := c.String("org") 24 | bits := c.Int("bits") 25 | overwrite := c.Bool("overwrite") 26 | 27 | log.Printf("generating ca: org=%s bits=%d", org, bits) 28 | 29 | log.Debugf("creating output dir: path=%s", outputDir) 30 | if err := os.MkdirAll(outputDir, 0700); err != nil { 31 | log.Fatal(err) 32 | } 33 | 34 | // cert 35 | if err := utils.CreateIfNotExists(caCertPath, overwrite); err != nil { 36 | log.Fatal(err) 37 | } 38 | 39 | // key 40 | if err := utils.CreateIfNotExists(caKeyPath, overwrite); err != nil { 41 | log.Fatal(err) 42 | } 43 | 44 | cert, key, err := tlsutils.GenerateCACertificate(org, bits) 45 | if err != nil { 46 | log.Fatal(err) 47 | } 48 | 49 | log.Debugf("creating certificate: path=%s", caCertPath) 50 | if err := ioutil.WriteFile(caCertPath, cert, 0600); err != nil { 51 | log.Fatal(err) 52 | } 53 | 54 | log.Debugf("creating key: path=%s", caKeyPath) 55 | if err := ioutil.WriteFile(caKeyPath, key, 0600); err != nil { 56 | log.Fatal(err) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /commands/client/client.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/codegangsta/cli" 5 | ) 6 | 7 | var CmdClient = cli.Command{ 8 | Name: "client", 9 | Usage: "client certificate management", 10 | Subcommands: []cli.Command{ 11 | cmdGenerate, 12 | }, 13 | } 14 | 15 | var cmdGenerate = cli.Command{ 16 | Name: "generate", 17 | Usage: "generate new certificate", 18 | Action: generate, 19 | Flags: []cli.Flag{ 20 | cli.StringFlag{ 21 | Name: "ca-cert", 22 | Value: "", 23 | Usage: "CA certificate for signing (defaults to ca.pem in output dir)", 24 | }, 25 | cli.StringFlag{ 26 | Name: "ca-key", 27 | Value: "", 28 | Usage: "CA key for signing (defaults to ca-key.pem in output dir)", 29 | }, 30 | cli.StringFlag{ 31 | Name: "cert", 32 | Value: "", 33 | Usage: "certificate name (default: cert.pem)", 34 | }, 35 | cli.StringFlag{ 36 | Name: "key", 37 | Value: "", 38 | Usage: "key name (default: key.pem)", 39 | }, 40 | cli.StringFlag{ 41 | Name: "common-name, c", 42 | Value: "", 43 | Usage: "common name", 44 | }, 45 | cli.StringFlag{ 46 | Name: "org, o", 47 | Value: "unknown", 48 | Usage: "organization", 49 | }, 50 | cli.IntFlag{ 51 | Name: "bits, b", 52 | Value: 2048, 53 | Usage: "number of bits in the key (default: 2048)", 54 | }, 55 | cli.BoolFlag{ 56 | Name: "overwrite", 57 | Usage: "overwrite existing certificates and keys", 58 | }, 59 | }, 60 | } 61 | -------------------------------------------------------------------------------- /commands/client/generate.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "path/filepath" 7 | 8 | log "github.com/sirupsen/logrus" 9 | "github.com/codegangsta/cli" 10 | "github.com/ehazlett/certm/utils" 11 | "github.com/ehazlett/tlsutils" 12 | ) 13 | 14 | func generate(c *cli.Context) { 15 | outputDir := c.GlobalString("output-directory") 16 | if outputDir == "" { 17 | cli.ShowAppHelp(c) 18 | log.Fatalf("you must specify an output directory") 19 | } 20 | 21 | commonName := c.String("common-name") 22 | caCertPath := c.String("ca-cert") 23 | caKeyPath := c.String("ca-key") 24 | certPath := c.String("cert") 25 | keyPath := c.String("key") 26 | org := c.String("org") 27 | bits := c.Int("bits") 28 | overwrite := c.Bool("overwrite") 29 | 30 | if caCertPath == "" { 31 | caCertPath = filepath.Join(outputDir, "ca.pem") 32 | } 33 | 34 | if caKeyPath == "" { 35 | caKeyPath = filepath.Join(outputDir, "ca-key.pem") 36 | } 37 | 38 | if certPath == "" { 39 | certPath = filepath.Join(outputDir, "cert.pem") 40 | } 41 | 42 | if keyPath == "" { 43 | keyPath = filepath.Join(outputDir, "key.pem") 44 | } 45 | 46 | log.Printf("generating client certificate: cn=%q org=%s bits=%d cert=%q key=%q", 47 | commonName, 48 | org, 49 | bits, 50 | certPath, 51 | keyPath, 52 | ) 53 | 54 | log.Debugf("creating output dir: path=%s", outputDir) 55 | if err := os.MkdirAll(outputDir, 0700); err != nil { 56 | log.Fatal(err) 57 | } 58 | 59 | // cert 60 | if err := utils.CreateIfNotExists(certPath, overwrite); err != nil { 61 | log.Fatal(err) 62 | } 63 | 64 | // key 65 | if err := utils.CreateIfNotExists(keyPath, overwrite); err != nil { 66 | log.Fatal(err) 67 | } 68 | 69 | caCert, err := ioutil.ReadFile(caCertPath) 70 | if err != nil { 71 | log.Fatal(err) 72 | } 73 | 74 | caKey, err := ioutil.ReadFile(caKeyPath) 75 | if err != nil { 76 | log.Fatal(err) 77 | } 78 | 79 | cert, key, err := tlsutils.GenerateCertificate( 80 | nil, 81 | caCert, 82 | caKey, 83 | org, 84 | commonName, 85 | bits, 86 | ) 87 | if err != nil { 88 | log.Fatal(err) 89 | } 90 | 91 | log.Debugf("creating certificate: path=%s", certPath) 92 | if err := ioutil.WriteFile(certPath, cert, 0600); err != nil { 93 | log.Fatal(err) 94 | } 95 | 96 | log.Debugf("creating key: path=%s", keyPath) 97 | if err := ioutil.WriteFile(keyPath, key, 0600); err != nil { 98 | log.Fatal(err) 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /commands/server/generate.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "path/filepath" 7 | 8 | log "github.com/sirupsen/logrus" 9 | "github.com/codegangsta/cli" 10 | "github.com/ehazlett/certm/utils" 11 | "github.com/ehazlett/tlsutils" 12 | ) 13 | 14 | func generate(c *cli.Context) { 15 | outputDir := c.GlobalString("output-directory") 16 | if outputDir == "" { 17 | cli.ShowAppHelp(c) 18 | log.Fatalf("you must specify an output directory") 19 | } 20 | 21 | hosts := c.StringSlice("host") 22 | caCertPath := c.String("ca-cert") 23 | caKeyPath := c.String("ca-key") 24 | certPath := c.String("cert") 25 | keyPath := c.String("key") 26 | org := c.String("org") 27 | bits := c.Int("bits") 28 | overwrite := c.Bool("overwrite") 29 | 30 | if caCertPath == "" { 31 | caCertPath = filepath.Join(outputDir, "ca.pem") 32 | } 33 | 34 | if caKeyPath == "" { 35 | caKeyPath = filepath.Join(outputDir, "ca-key.pem") 36 | } 37 | 38 | if certPath == "" { 39 | certPath = filepath.Join(outputDir, "server.pem") 40 | } 41 | 42 | if keyPath == "" { 43 | keyPath = filepath.Join(outputDir, "server-key.pem") 44 | } 45 | 46 | log.Printf("generating server certificate: org=%s bits=%d", 47 | org, 48 | bits, 49 | ) 50 | 51 | log.Debugf("creating output dir: path=%s", outputDir) 52 | if err := os.MkdirAll(outputDir, 0700); err != nil { 53 | log.Fatal(err) 54 | } 55 | 56 | // cert 57 | if err := utils.CreateIfNotExists(certPath, overwrite); err != nil { 58 | log.Fatal(err) 59 | } 60 | 61 | // key 62 | if err := utils.CreateIfNotExists(keyPath, overwrite); err != nil { 63 | log.Fatal(err) 64 | } 65 | 66 | caCert, err := ioutil.ReadFile(caCertPath) 67 | if err != nil { 68 | log.Fatal(err) 69 | } 70 | 71 | caKey, err := ioutil.ReadFile(caKeyPath) 72 | if err != nil { 73 | log.Fatal(err) 74 | } 75 | 76 | cert, key, err := tlsutils.GenerateCertificate( 77 | hosts, 78 | caCert, 79 | caKey, 80 | org, 81 | "", 82 | bits, 83 | ) 84 | if err != nil { 85 | log.Fatal(err) 86 | } 87 | 88 | log.Debugf("creating certificate: path=%s", certPath) 89 | if err := ioutil.WriteFile(certPath, cert, 0600); err != nil { 90 | log.Fatal(err) 91 | } 92 | 93 | log.Debugf("creating key: path=%s", keyPath) 94 | if err := ioutil.WriteFile(keyPath, key, 0600); err != nil { 95 | log.Fatal(err) 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /commands/server/server.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/codegangsta/cli" 5 | ) 6 | 7 | var CmdServer = cli.Command{ 8 | Name: "server", 9 | Usage: "server certificate management", 10 | Subcommands: []cli.Command{ 11 | cmdGenerate, 12 | }, 13 | } 14 | 15 | var cmdGenerate = cli.Command{ 16 | Name: "generate", 17 | Usage: "generate new certificate", 18 | Action: generate, 19 | Flags: []cli.Flag{ 20 | cli.StringFlag{ 21 | Name: "ca-cert", 22 | Value: "", 23 | Usage: "CA certificate for signing (defaults to ca.pem in output dir)", 24 | }, 25 | cli.StringFlag{ 26 | Name: "ca-key", 27 | Value: "", 28 | Usage: "CA key for signing (defaults to ca-key.pem in output dir)", 29 | }, 30 | cli.StringFlag{ 31 | Name: "cert", 32 | Value: "", 33 | Usage: "certificate name (default: server.pem)", 34 | }, 35 | cli.StringFlag{ 36 | Name: "key", 37 | Value: "", 38 | Usage: "key name (default: server-key.pem)", 39 | }, 40 | cli.StringSliceFlag{ 41 | Name: "host", 42 | Value: &cli.StringSlice{}, 43 | Usage: "SAN/IP SAN for certificate", 44 | }, 45 | cli.StringFlag{ 46 | Name: "org, o", 47 | Value: "unknown", 48 | Usage: "organization", 49 | }, 50 | cli.IntFlag{ 51 | Name: "bits, b", 52 | Value: 2048, 53 | Usage: "number of bits in the key (default: 2048)", 54 | }, 55 | cli.BoolFlag{ 56 | Name: "overwrite", 57 | Usage: "overwrite existing certificates and keys", 58 | }, 59 | }, 60 | } 61 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | log "github.com/sirupsen/logrus" 7 | "github.com/codegangsta/cli" 8 | "github.com/ehazlett/certm/commands/bundle" 9 | "github.com/ehazlett/certm/commands/ca" 10 | "github.com/ehazlett/certm/commands/client" 11 | "github.com/ehazlett/certm/commands/server" 12 | "github.com/ehazlett/certm/version" 13 | "github.com/ehazlett/simplelog" 14 | ) 15 | 16 | func init() { 17 | // setup log formatter 18 | f := &simplelog.SimpleFormatter{} 19 | log.SetFormatter(f) 20 | } 21 | 22 | func main() { 23 | app := cli.NewApp() 24 | app.Name = os.Args[0] 25 | app.Usage = "certificate management" 26 | app.Version = version.FullVersion() 27 | app.Author = "@ehazlett" 28 | app.Email = "" 29 | app.Before = func(c *cli.Context) error { 30 | if c.Bool("debug") { 31 | log.SetLevel(log.DebugLevel) 32 | } 33 | return nil 34 | } 35 | app.Commands = []cli.Command{ 36 | ca.CmdCA, 37 | server.CmdServer, 38 | client.CmdClient, 39 | bundle.CmdBundle, 40 | } 41 | app.Flags = []cli.Flag{ 42 | cli.StringFlag{ 43 | Name: "output-directory, d", 44 | Value: "", 45 | Usage: "output directory for certs", 46 | }, 47 | cli.BoolFlag{ 48 | Name: "debug, D", 49 | Usage: "enable debug", 50 | }, 51 | } 52 | 53 | if err := app.Run(os.Args); err != nil { 54 | log.Fatal(err) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # CertM 2 | CertM is a simple tool to generate TLS certificates and keys. 3 | 4 | # Usage 5 | ## Show Help 6 | `docker run --rm ehazlett/certm -h` 7 | 8 | ## Generate CA 9 | `docker run --rm -v $(pwd)/certs:/certs ehazlett/certm -d /certs ca generate -o=local` 10 | 11 | This will generate a CA with the organization "local". 12 | 13 | ## Generate server certificate 14 | `docker run --rm -v $(pwd)/certs:/certs ehazlett/certm -d /certs server generate --host localhost --host 127.0.0.1 -o=local` 15 | 16 | This will generate a server certificate with a SAN of "localhost" and an 17 | IP SAN of "127.0.0.1" with the organization "local". 18 | 19 | ## Generate client certificate 20 | `docker run --rm -v $(pwd)/certs:/certs ehazlett/certm -d /certs client generate --common-name=ehazlett -o=local` 21 | 22 | This will generate a client certificate with the common name of "ehazlett". 23 | 24 | ## Generate CA, server and client certificates / keys 25 | `docker run --rm -v $(pwd)/certs:/certs ehazlett/certm -d /certs bundle generate --host 127.0.0.1 -o=local` 26 | 27 | This will generate a CA using the org "local", a server certificate with an 28 | IP SAN of "127.0.0.1" and a client certificate. 29 | 30 | ## Generate CA, client and server certificates/keys 31 | `docker run --rm -v $(pwd)/certs:/certs ehazlett/certm -d /certs bundle generate -o=local --host localhost --host 127.0.0.1 --host foo.local` 32 | 33 | This will generate a CA using the org "local", a client cert, and a server 34 | certificate that is valid using the DNS names "localhost" and "foo.local" as 35 | well as the IP "127.0.0.1" 36 | 37 | Server cert can be used for swarm and has cert extensions for both docker server and client. 38 | 39 | # Integration Tests 40 | To run integration tests, use `./script/test`. This will run the integration 41 | tests in a container to validate proper usage. 42 | -------------------------------------------------------------------------------- /script/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | TAG=${1:-} 4 | 5 | if [ -z "$TAG" ]; then 6 | echo "Usage: $0 " 7 | echo " Example: $0 0.0.1" 8 | exit 1 9 | fi 10 | 11 | rm -rf certm_* 12 | 13 | echo "Building $TAG" 14 | docker build -t certm-build -f Dockerfile.build . 15 | docker run --rm -e TAG -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/go/src/github.com/ehazlett/certm -w /go/src/github.com/ehazlett/certm certm-build make TAG=$TAG build image 16 | docker run --rm -e TAG -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/go/src/github.com/ehazlett/certm -w /go/src/github.com/ehazlett/certm certm-build make build-cross 17 | -------------------------------------------------------------------------------- /script/generate-sums: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | for BINARY in certm_*; do 5 | sha256sum $BINARY > $BINARY.sha256 6 | md5sum $BINARY >> $BINARY.md5 7 | done 8 | 9 | -------------------------------------------------------------------------------- /script/release: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | if [ -z "$1" ]; then 4 | echo "Usage: $0 " 5 | exit 1 6 | fi 7 | 8 | VERSION=$1 9 | 10 | if [ -z "$GITHUB_TOKEN" ]; then 11 | echo "GITHUB_TOKEN must be set for github-release" 12 | exit 1 13 | fi 14 | 15 | echo "Building" 16 | script/build $VERSION 17 | 18 | echo "Pushing to Hub" 19 | docker tag -f ehazlett/certm:$VERSION ehazlett/certm:latest 20 | docker push ehazlett/certm:$VERSION 21 | docker push ehazlett/certm:latest 22 | 23 | echo "Generating sums" 24 | docker run --rm -v `pwd`:/go/src/github.com/ehazlett/certm certm-build ./script/generate-sums 25 | 26 | echo "Creating Tag" 27 | git tag $VERSION 28 | echo "Pushing tag" 29 | git push --tags 30 | 31 | echo "Creating Release" 32 | docker run --rm -e GITHUB_TOKEN certm-build github-release release \ 33 | --user ehazlett \ 34 | --repo certm \ 35 | --tag $VERSION \ 36 | --name $VERSION \ 37 | --description "" \ 38 | --pre-release 39 | 40 | for BINARY in certm_*; do 41 | echo "Uploading $BINARY" 42 | docker run --rm -e GITHUB_TOKEN -v `pwd`:/go/src/github.com/ehazlett/certm \ 43 | certm-build github-release upload \ 44 | --user ehazlett \ 45 | --repo certm \ 46 | --tag $VERSION \ 47 | --name $BINARY \ 48 | --file $BINARY 49 | done 50 | -------------------------------------------------------------------------------- /script/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | docker build -t certm-build -f Dockerfile.build . 5 | 6 | docker run --rm -w /go/src/github.com/ehazlett/certm certm-build make test 7 | -------------------------------------------------------------------------------- /test/integration/certs.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load helpers 4 | 5 | @test "certs: valid generation" { 6 | run certgen $CERT_ORG $CERT_BIT_SIZE --host $CERT_SERVER_DNS --host $CERT_SERVER_IP 7 | [ "$status" -eq 0 ] 8 | } 9 | 10 | @test "certs: ca.pem should exist" { 11 | run test -e $CERT_TEST_DIR/ca.pem 12 | [ "$status" -eq 0 ] 13 | } 14 | 15 | @test "certs: ca-key.pem should exist" { 16 | run test -e $CERT_TEST_DIR/ca-key.pem 17 | [ "$status" -eq 0 ] 18 | } 19 | 20 | @test "certs: cert.pem should exist" { 21 | run test -e $CERT_TEST_DIR/cert.pem 22 | [ "$status" -eq 0 ] 23 | } 24 | 25 | @test "certs: key.pem should exist" { 26 | run test -e $CERT_TEST_DIR/key.pem 27 | [ "$status" -eq 0 ] 28 | } 29 | 30 | @test "certs: server.pem should exist" { 31 | run test -e $CERT_TEST_DIR/server.pem 32 | [ "$status" -eq 0 ] 33 | } 34 | 35 | @test "certs: server-key.pem should exist" { 36 | run test -e $CERT_TEST_DIR/server-key.pem 37 | [ "$status" -eq 0 ] 38 | } 39 | 40 | @test "certs: valid ca organization" { 41 | run openssl x509 -in $CERT_TEST_DIR/ca.pem -noout -text 42 | echo "$output" | grep "Issuer: O=$CERT_ORG" 43 | [ "$status" -eq 0 ] 44 | } 45 | 46 | @test "certs: valid ca bit size" { 47 | run openssl x509 -in $CERT_TEST_DIR/ca.pem -noout -text 48 | echo "$output" | grep "($CERT_BIT_SIZE bit)" 49 | [ "$status" -eq 0 ] 50 | } 51 | 52 | @test "certs: valid CA" { 53 | run openssl x509 -in $CERT_TEST_DIR/ca.pem -noout -text 54 | echo "$output" | grep "CA:TRUE" 55 | [ "$status" -eq 0 ] 56 | } 57 | 58 | @test "certs: valid client organization" { 59 | run openssl x509 -in $CERT_TEST_DIR/cert.pem -noout -text 60 | echo "$output" | grep "Issuer: O=$CERT_ORG" 61 | [ "$status" -eq 0 ] 62 | } 63 | 64 | @test "certs: valid client bit size" { 65 | run openssl x509 -in $CERT_TEST_DIR/cert.pem -noout -text 66 | echo "$output" | grep "($CERT_BIT_SIZE bit)" 67 | [ "$status" -eq 0 ] 68 | } 69 | 70 | @test "certs: client cert is not a CA" { 71 | run openssl x509 -in $CERT_TEST_DIR/cert.pem -noout -text 72 | echo "$output" | grep "CA:FALSE" 73 | [ "$status" -eq 0 ] 74 | } 75 | 76 | @test "certs: client cert has proper extended usage" { 77 | run openssl x509 -in $CERT_TEST_DIR/cert.pem -noout -text 78 | echo "$output" | grep "TLS Web Client Authentication" 79 | [ "$status" -eq 0 ] 80 | } 81 | 82 | @test "certs: valid server organization" { 83 | run openssl x509 -in $CERT_TEST_DIR/server.pem -noout -text 84 | echo "$output" | grep "Issuer: O=$CERT_ORG" 85 | [ "$status" -eq 0 ] 86 | } 87 | 88 | @test "certs: valid server bit size" { 89 | run openssl x509 -in $CERT_TEST_DIR/server.pem -noout -text 90 | echo "$output" | grep "($CERT_BIT_SIZE bit)" 91 | [ "$status" -eq 0 ] 92 | } 93 | 94 | @test "certs: server cert is not a CA" { 95 | run openssl x509 -in $CERT_TEST_DIR/server.pem -noout -text 96 | echo "$output" | grep "CA:FALSE" 97 | [ "$status" -eq 0 ] 98 | } 99 | 100 | @test "certs: server cert has proper extended usage" { 101 | run openssl x509 -in $CERT_TEST_DIR/server.pem -noout -text 102 | echo "$output" | grep "TLS Web Server Authentication" 103 | [ "$status" -eq 0 ] 104 | } 105 | 106 | @test "certs: server has correct DNS SAN" { 107 | run openssl x509 -in $CERT_TEST_DIR/server.pem -noout -text 108 | echo "$output" | grep "DNS:$CERT_SERVER_DNS" 109 | [ "$status" -eq 0 ] 110 | } 111 | 112 | @test "certs: server has correct IP SAN" { 113 | run openssl x509 -in $CERT_TEST_DIR/server.pem -noout -text 114 | echo "$output" | grep "IP Address:$CERT_SERVER_IP" 115 | [ "$status" -eq 0 ] 116 | } 117 | 118 | @test "certs: custom org/bits generation" { 119 | run certgen $CERT_CUSTOM_ORG $CERT_CUSTOM_BIT_SIZE 120 | [ "$status" -eq 0 ] 121 | } 122 | 123 | @test "certs: custom org valid" { 124 | run openssl x509 -in $CERT_TEST_DIR/ca.pem -noout -text 125 | echo "$output" | grep "Issuer: O=$CERT_CUSTOM_ORG" 126 | [ "$status" -eq 0 ] 127 | } 128 | 129 | @test "certs: custom ca bit size" { 130 | run openssl x509 -in $CERT_TEST_DIR/ca.pem -noout -text 131 | echo "$output" | grep "($CERT_CUSTOM_BIT_SIZE bit)" 132 | [ "$status" -eq 0 ] 133 | } 134 | -------------------------------------------------------------------------------- /test/integration/cli.bats: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bats 2 | 3 | load helpers 4 | 5 | @test "cli: show info" { 6 | run certm 7 | [ "$status" -eq 0 ] 8 | [[ ${lines[0]} =~ "NAME:" ]] 9 | } 10 | 11 | @test "cli: version" { 12 | run certm -v 13 | [ "$status" -eq 0 ] 14 | [[ ${lines[0]} =~ "version" ]] 15 | } 16 | -------------------------------------------------------------------------------- /test/integration/helpers.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Root directory of the repository. 4 | ROOT=${BATS_TEST_DIRNAME}/../.. 5 | CERT_TEST_DIR=/tmp/certs 6 | CERT_ORG=bats-test 7 | CERT_BIT_SIZE=2048 8 | CERT_SERVER_DNS=bats.test.local 9 | CERT_SERVER_IP=1.2.3.4 10 | CERT_CUSTOM_ORG=foo-org 11 | CERT_CUSTOM_BIT_SIZE=1024 12 | 13 | build() { 14 | pushd $ROOT >/dev/null 15 | godep go build 16 | popd >/dev/null 17 | } 18 | 19 | # build machine binary if needed 20 | if [ ! -e $MACHINE_ROOT/certm ]; then 21 | build 22 | fi 23 | 24 | certm() { 25 | ${ROOT}/certm "$@" 26 | } 27 | 28 | certgen() { 29 | if [ -e $CERT_TEST_DIR ]; then 30 | rm -rf $CERT_TEST_DIR 31 | fi 32 | certm -d $CERT_TEST_DIR bundle generate -o=$1 -b $2 ${*:3} --overwrite 33 | } 34 | -------------------------------------------------------------------------------- /utils/utils.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | func CreateIfNotExists(path string, overwrite bool) error { 9 | f, err := os.Stat(path) 10 | if err != nil { 11 | if !os.IsNotExist(err) { 12 | return err 13 | } 14 | } 15 | 16 | if f != nil { 17 | if !overwrite { 18 | return fmt.Errorf("ca cert/key exists. specify --overwrite to overwrite.") 19 | } 20 | 21 | if err := os.Remove(path); err != nil { 22 | return err 23 | } 24 | } 25 | 26 | nf, err := os.Create(path) 27 | if err != nil { 28 | return err 29 | } 30 | nf.Close() 31 | 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /vendor.conf: -------------------------------------------------------------------------------- 1 | github.com/codegangsta/cli 2526b57c56f30b50466c96c4133b1a4ad0f0191f 2 | github.com/ehazlett/simplelog 9fcd579ee7c6aae0b6ea538bc276dedf3ee98e6c 3 | github.com/ehazlett/tlsutils da9d5e1fe7c1ec8ce16562959f77035b2a26bff5 4 | github.com/sirupsen/logrus 7f4b1adc791766938c29457bed0703fb9134421a 5 | golang.org/x/sys e4594059fe4cde2daf423055a596c2cd1e6c9adf 6 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Jeremy Saenz & Contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/category.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // CommandCategories is a slice of *CommandCategory. 4 | type CommandCategories []*CommandCategory 5 | 6 | // CommandCategory is a category containing commands. 7 | type CommandCategory struct { 8 | Name string 9 | Commands Commands 10 | } 11 | 12 | func (c CommandCategories) Less(i, j int) bool { 13 | return c[i].Name < c[j].Name 14 | } 15 | 16 | func (c CommandCategories) Len() int { 17 | return len(c) 18 | } 19 | 20 | func (c CommandCategories) Swap(i, j int) { 21 | c[i], c[j] = c[j], c[i] 22 | } 23 | 24 | // AddCommand adds a command to a category. 25 | func (c CommandCategories) AddCommand(category string, command Command) CommandCategories { 26 | for _, commandCategory := range c { 27 | if commandCategory.Name == category { 28 | commandCategory.Commands = append(commandCategory.Commands, command) 29 | return c 30 | } 31 | } 32 | return append(c, &CommandCategory{Name: category, Commands: []Command{command}}) 33 | } 34 | 35 | // VisibleCommands returns a slice of the Commands with Hidden=false 36 | func (c *CommandCategory) VisibleCommands() []Command { 37 | ret := []Command{} 38 | for _, command := range c.Commands { 39 | if !command.Hidden { 40 | ret = append(ret, command) 41 | } 42 | } 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/cli.go: -------------------------------------------------------------------------------- 1 | // Package cli provides a minimal framework for creating and organizing command line 2 | // Go applications. cli is designed to be easy to understand and write, the most simple 3 | // cli application can be written as follows: 4 | // func main() { 5 | // cli.NewApp().Run(os.Args) 6 | // } 7 | // 8 | // Of course this application does not do much, so let's make this an actual application: 9 | // func main() { 10 | // app := cli.NewApp() 11 | // app.Name = "greet" 12 | // app.Usage = "say a greeting" 13 | // app.Action = func(c *cli.Context) error { 14 | // println("Greetings") 15 | // } 16 | // 17 | // app.Run(os.Args) 18 | // } 19 | package cli 20 | 21 | //go:generate python ./generate-flag-types cli -i flag-types.json -o flag_generated.go 22 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/context.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "errors" 5 | "flag" 6 | "reflect" 7 | "strings" 8 | "syscall" 9 | ) 10 | 11 | // Context is a type that is passed through to 12 | // each Handler action in a cli application. Context 13 | // can be used to retrieve context-specific Args and 14 | // parsed command-line options. 15 | type Context struct { 16 | App *App 17 | Command Command 18 | shellComplete bool 19 | flagSet *flag.FlagSet 20 | setFlags map[string]bool 21 | parentContext *Context 22 | } 23 | 24 | // NewContext creates a new context. For use in when invoking an App or Command action. 25 | func NewContext(app *App, set *flag.FlagSet, parentCtx *Context) *Context { 26 | c := &Context{App: app, flagSet: set, parentContext: parentCtx} 27 | 28 | if parentCtx != nil { 29 | c.shellComplete = parentCtx.shellComplete 30 | } 31 | 32 | return c 33 | } 34 | 35 | // NumFlags returns the number of flags set 36 | func (c *Context) NumFlags() int { 37 | return c.flagSet.NFlag() 38 | } 39 | 40 | // Set sets a context flag to a value. 41 | func (c *Context) Set(name, value string) error { 42 | return c.flagSet.Set(name, value) 43 | } 44 | 45 | // GlobalSet sets a context flag to a value on the global flagset 46 | func (c *Context) GlobalSet(name, value string) error { 47 | return globalContext(c).flagSet.Set(name, value) 48 | } 49 | 50 | // IsSet determines if the flag was actually set 51 | func (c *Context) IsSet(name string) bool { 52 | if c.setFlags == nil { 53 | c.setFlags = make(map[string]bool) 54 | 55 | c.flagSet.Visit(func(f *flag.Flag) { 56 | c.setFlags[f.Name] = true 57 | }) 58 | 59 | c.flagSet.VisitAll(func(f *flag.Flag) { 60 | if _, ok := c.setFlags[f.Name]; ok { 61 | return 62 | } 63 | c.setFlags[f.Name] = false 64 | }) 65 | 66 | // XXX hack to support IsSet for flags with EnvVar 67 | // 68 | // There isn't an easy way to do this with the current implementation since 69 | // whether a flag was set via an environment variable is very difficult to 70 | // determine here. Instead, we intend to introduce a backwards incompatible 71 | // change in version 2 to add `IsSet` to the Flag interface to push the 72 | // responsibility closer to where the information required to determine 73 | // whether a flag is set by non-standard means such as environment 74 | // variables is avaliable. 75 | // 76 | // See https://github.com/urfave/cli/issues/294 for additional discussion 77 | flags := c.Command.Flags 78 | if c.Command.Name == "" { // cannot == Command{} since it contains slice types 79 | if c.App != nil { 80 | flags = c.App.Flags 81 | } 82 | } 83 | for _, f := range flags { 84 | eachName(f.GetName(), func(name string) { 85 | if isSet, ok := c.setFlags[name]; isSet || !ok { 86 | return 87 | } 88 | 89 | val := reflect.ValueOf(f) 90 | if val.Kind() == reflect.Ptr { 91 | val = val.Elem() 92 | } 93 | 94 | envVarValue := val.FieldByName("EnvVar") 95 | if !envVarValue.IsValid() { 96 | return 97 | } 98 | 99 | eachName(envVarValue.String(), func(envVar string) { 100 | envVar = strings.TrimSpace(envVar) 101 | if _, ok := syscall.Getenv(envVar); ok { 102 | c.setFlags[name] = true 103 | return 104 | } 105 | }) 106 | }) 107 | } 108 | } 109 | 110 | return c.setFlags[name] 111 | } 112 | 113 | // GlobalIsSet determines if the global flag was actually set 114 | func (c *Context) GlobalIsSet(name string) bool { 115 | ctx := c 116 | if ctx.parentContext != nil { 117 | ctx = ctx.parentContext 118 | } 119 | 120 | for ; ctx != nil; ctx = ctx.parentContext { 121 | if ctx.IsSet(name) { 122 | return true 123 | } 124 | } 125 | return false 126 | } 127 | 128 | // FlagNames returns a slice of flag names used in this context. 129 | func (c *Context) FlagNames() (names []string) { 130 | for _, flag := range c.Command.Flags { 131 | name := strings.Split(flag.GetName(), ",")[0] 132 | if name == "help" { 133 | continue 134 | } 135 | names = append(names, name) 136 | } 137 | return 138 | } 139 | 140 | // GlobalFlagNames returns a slice of global flag names used by the app. 141 | func (c *Context) GlobalFlagNames() (names []string) { 142 | for _, flag := range c.App.Flags { 143 | name := strings.Split(flag.GetName(), ",")[0] 144 | if name == "help" || name == "version" { 145 | continue 146 | } 147 | names = append(names, name) 148 | } 149 | return 150 | } 151 | 152 | // Parent returns the parent context, if any 153 | func (c *Context) Parent() *Context { 154 | return c.parentContext 155 | } 156 | 157 | // value returns the value of the flag coressponding to `name` 158 | func (c *Context) value(name string) interface{} { 159 | return c.flagSet.Lookup(name).Value.(flag.Getter).Get() 160 | } 161 | 162 | // Args contains apps console arguments 163 | type Args []string 164 | 165 | // Args returns the command line arguments associated with the context. 166 | func (c *Context) Args() Args { 167 | args := Args(c.flagSet.Args()) 168 | return args 169 | } 170 | 171 | // NArg returns the number of the command line arguments. 172 | func (c *Context) NArg() int { 173 | return len(c.Args()) 174 | } 175 | 176 | // Get returns the nth argument, or else a blank string 177 | func (a Args) Get(n int) string { 178 | if len(a) > n { 179 | return a[n] 180 | } 181 | return "" 182 | } 183 | 184 | // First returns the first argument, or else a blank string 185 | func (a Args) First() string { 186 | return a.Get(0) 187 | } 188 | 189 | // Tail returns the rest of the arguments (not the first one) 190 | // or else an empty string slice 191 | func (a Args) Tail() []string { 192 | if len(a) >= 2 { 193 | return []string(a)[1:] 194 | } 195 | return []string{} 196 | } 197 | 198 | // Present checks if there are any arguments present 199 | func (a Args) Present() bool { 200 | return len(a) != 0 201 | } 202 | 203 | // Swap swaps arguments at the given indexes 204 | func (a Args) Swap(from, to int) error { 205 | if from >= len(a) || to >= len(a) { 206 | return errors.New("index out of range") 207 | } 208 | a[from], a[to] = a[to], a[from] 209 | return nil 210 | } 211 | 212 | func globalContext(ctx *Context) *Context { 213 | if ctx == nil { 214 | return nil 215 | } 216 | 217 | for { 218 | if ctx.parentContext == nil { 219 | return ctx 220 | } 221 | ctx = ctx.parentContext 222 | } 223 | } 224 | 225 | func lookupGlobalFlagSet(name string, ctx *Context) *flag.FlagSet { 226 | if ctx.parentContext != nil { 227 | ctx = ctx.parentContext 228 | } 229 | for ; ctx != nil; ctx = ctx.parentContext { 230 | if f := ctx.flagSet.Lookup(name); f != nil { 231 | return ctx.flagSet 232 | } 233 | } 234 | return nil 235 | } 236 | 237 | func copyFlag(name string, ff *flag.Flag, set *flag.FlagSet) { 238 | switch ff.Value.(type) { 239 | case *StringSlice: 240 | default: 241 | set.Set(name, ff.Value.String()) 242 | } 243 | } 244 | 245 | func normalizeFlags(flags []Flag, set *flag.FlagSet) error { 246 | visited := make(map[string]bool) 247 | set.Visit(func(f *flag.Flag) { 248 | visited[f.Name] = true 249 | }) 250 | for _, f := range flags { 251 | parts := strings.Split(f.GetName(), ",") 252 | if len(parts) == 1 { 253 | continue 254 | } 255 | var ff *flag.Flag 256 | for _, name := range parts { 257 | name = strings.Trim(name, " ") 258 | if visited[name] { 259 | if ff != nil { 260 | return errors.New("Cannot use two forms of the same flag: " + name + " " + ff.Name) 261 | } 262 | ff = set.Lookup(name) 263 | } 264 | } 265 | if ff == nil { 266 | continue 267 | } 268 | for _, name := range parts { 269 | name = strings.Trim(name, " ") 270 | if !visited[name] { 271 | copyFlag(name, ff, set) 272 | } 273 | } 274 | } 275 | return nil 276 | } 277 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/errors.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | // OsExiter is the function used when the app exits. If not set defaults to os.Exit. 11 | var OsExiter = os.Exit 12 | 13 | // ErrWriter is used to write errors to the user. This can be anything 14 | // implementing the io.Writer interface and defaults to os.Stderr. 15 | var ErrWriter io.Writer = os.Stderr 16 | 17 | // MultiError is an error that wraps multiple errors. 18 | type MultiError struct { 19 | Errors []error 20 | } 21 | 22 | // NewMultiError creates a new MultiError. Pass in one or more errors. 23 | func NewMultiError(err ...error) MultiError { 24 | return MultiError{Errors: err} 25 | } 26 | 27 | // Error implements the error interface. 28 | func (m MultiError) Error() string { 29 | errs := make([]string, len(m.Errors)) 30 | for i, err := range m.Errors { 31 | errs[i] = err.Error() 32 | } 33 | 34 | return strings.Join(errs, "\n") 35 | } 36 | 37 | type ErrorFormatter interface { 38 | Format(s fmt.State, verb rune) 39 | } 40 | 41 | // ExitCoder is the interface checked by `App` and `Command` for a custom exit 42 | // code 43 | type ExitCoder interface { 44 | error 45 | ExitCode() int 46 | } 47 | 48 | // ExitError fulfills both the builtin `error` interface and `ExitCoder` 49 | type ExitError struct { 50 | exitCode int 51 | message interface{} 52 | } 53 | 54 | // NewExitError makes a new *ExitError 55 | func NewExitError(message interface{}, exitCode int) *ExitError { 56 | return &ExitError{ 57 | exitCode: exitCode, 58 | message: message, 59 | } 60 | } 61 | 62 | // Error returns the string message, fulfilling the interface required by 63 | // `error` 64 | func (ee *ExitError) Error() string { 65 | return fmt.Sprintf("%v", ee.message) 66 | } 67 | 68 | // ExitCode returns the exit code, fulfilling the interface required by 69 | // `ExitCoder` 70 | func (ee *ExitError) ExitCode() int { 71 | return ee.exitCode 72 | } 73 | 74 | // HandleExitCoder checks if the error fulfills the ExitCoder interface, and if 75 | // so prints the error to stderr (if it is non-empty) and calls OsExiter with the 76 | // given exit code. If the given error is a MultiError, then this func is 77 | // called on all members of the Errors slice and calls OsExiter with the last exit code. 78 | func HandleExitCoder(err error) { 79 | if err == nil { 80 | return 81 | } 82 | 83 | if exitErr, ok := err.(ExitCoder); ok { 84 | if err.Error() != "" { 85 | if _, ok := exitErr.(ErrorFormatter); ok { 86 | fmt.Fprintf(ErrWriter, "%+v\n", err) 87 | } else { 88 | fmt.Fprintln(ErrWriter, err) 89 | } 90 | } 91 | OsExiter(exitErr.ExitCode()) 92 | return 93 | } 94 | 95 | if multiErr, ok := err.(MultiError); ok { 96 | code := handleMultiError(multiErr) 97 | OsExiter(code) 98 | return 99 | } 100 | 101 | if err.Error() != "" { 102 | if _, ok := err.(ErrorFormatter); ok { 103 | fmt.Fprintf(ErrWriter, "%+v\n", err) 104 | } else { 105 | fmt.Fprintln(ErrWriter, err) 106 | } 107 | } 108 | OsExiter(1) 109 | } 110 | 111 | func handleMultiError(multiErr MultiError) int { 112 | code := 1 113 | for _, merr := range multiErr.Errors { 114 | if multiErr2, ok := merr.(MultiError); ok { 115 | code = handleMultiError(multiErr2) 116 | } else { 117 | fmt.Fprintln(ErrWriter, merr) 118 | if exitErr, ok := merr.(ExitCoder); ok { 119 | code = exitErr.ExitCode() 120 | } 121 | } 122 | } 123 | return code 124 | } 125 | -------------------------------------------------------------------------------- /vendor/github.com/codegangsta/cli/funcs.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // BashCompleteFunc is an action to execute when the bash-completion flag is set 4 | type BashCompleteFunc func(*Context) 5 | 6 | // BeforeFunc is an action to execute before any subcommands are run, but after 7 | // the context is ready if a non-nil error is returned, no subcommands are run 8 | type BeforeFunc func(*Context) error 9 | 10 | // AfterFunc is an action to execute after any subcommands are run, but after the 11 | // subcommand has finished it is run even if Action() panics 12 | type AfterFunc func(*Context) error 13 | 14 | // ActionFunc is the action to execute when no subcommands are specified 15 | type ActionFunc func(*Context) error 16 | 17 | // CommandNotFoundFunc is executed if the proper command cannot be found 18 | type CommandNotFoundFunc func(*Context, string) 19 | 20 | // OnUsageErrorFunc is executed if an usage error occurs. This is useful for displaying 21 | // customized usage error messages. This function is able to replace the 22 | // original error messages. If this function is not set, the "Incorrect usage" 23 | // is displayed and the execution is interrupted. 24 | type OnUsageErrorFunc func(context *Context, err error, isSubcommand bool) error 25 | 26 | // FlagStringFunc is used by the help generation to display a flag, which is 27 | // expected to be a single line. 28 | type FlagStringFunc func(Flag) string 29 | -------------------------------------------------------------------------------- /vendor/github.com/ehazlett/simplelog/simple.go: -------------------------------------------------------------------------------- 1 | package simplelog 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | 7 | "github.com/sirupsen/logrus" 8 | ) 9 | 10 | type SimpleFormatter struct{} 11 | 12 | func (s *SimpleFormatter) Format(entry *logrus.Entry) ([]byte, error) { 13 | b := &bytes.Buffer{} 14 | fmt.Fprintf(b, entry.Message) 15 | b.WriteByte('\n') 16 | return b.Bytes(), nil 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/ehazlett/simplelog/standard.go: -------------------------------------------------------------------------------- 1 | package simplelog 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "strings" 7 | "time" 8 | 9 | "github.com/sirupsen/logrus" 10 | ) 11 | 12 | type StandardFormatter struct{} 13 | 14 | func (s *StandardFormatter) Format(entry *logrus.Entry) ([]byte, error) { 15 | b := &bytes.Buffer{} 16 | // 2015/09/28 17:06:03 17 | t := time.Now().Local() 18 | timestamp := fmt.Sprintf("%04d/%02d/%02d %02d:%02d:%02d", 19 | t.Year(), 20 | t.Month(), 21 | t.Day(), 22 | t.Hour(), 23 | t.Minute(), 24 | t.Second(), 25 | ) 26 | msg := fmt.Sprintf("%s [%s] %s", timestamp, strings.ToUpper(entry.Level.String()), entry.Message) 27 | fmt.Fprintf(b, msg) 28 | b.WriteByte('\n') 29 | return b.Bytes(), nil 30 | 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/ehazlett/tlsutils/tlsutils.go: -------------------------------------------------------------------------------- 1 | package tlsutils 2 | 3 | import ( 4 | "bytes" 5 | "crypto/rand" 6 | "crypto/rsa" 7 | "crypto/tls" 8 | "crypto/x509" 9 | "crypto/x509/pkix" 10 | "encoding/pem" 11 | "errors" 12 | "io/ioutil" 13 | "math/big" 14 | "net" 15 | "os" 16 | "path/filepath" 17 | "time" 18 | 19 | "github.com/sirupsen/logrus" 20 | ) 21 | 22 | var ( 23 | ErrNotRSAPrivateKey = errors.New("private key is not an RSA key") 24 | ) 25 | 26 | const ( 27 | systemCertPath = "/etc/ssl" 28 | ) 29 | 30 | func loadSystemCertificates(certPool *x509.CertPool) error { 31 | if _, err := os.Stat(systemCertPath); os.IsNotExist(err) { 32 | return nil 33 | } 34 | 35 | logrus.Debugf("loading system certificates: dir=%s", systemCertPath) 36 | 37 | return filepath.Walk(systemCertPath, func(path string, fi os.FileInfo, err error) error { 38 | if !fi.IsDir() { 39 | cert, err := ioutil.ReadFile(path) 40 | if err != nil { 41 | return err 42 | } 43 | 44 | certPool.AppendCertsFromPEM(cert) 45 | } 46 | return nil 47 | }) 48 | } 49 | 50 | // GetServerTLSConfig returns a TLS config for using with ListenAndServeTLS 51 | // This sets up the Root and Client CAs for verification 52 | func GetServerTLSConfig(caCert, serverCert, serverKey []byte, allowInsecure bool) (*tls.Config, error) { 53 | // TLS config 54 | var tlsConfig tls.Config 55 | tlsConfig.InsecureSkipVerify = allowInsecure 56 | certPool := x509.NewCertPool() 57 | 58 | // load system certs 59 | if err := loadSystemCertificates(certPool); err != nil { 60 | return nil, err 61 | } 62 | 63 | // append custom CA 64 | certPool.AppendCertsFromPEM(caCert) 65 | 66 | tlsConfig.RootCAs = certPool 67 | tlsConfig.ClientCAs = certPool 68 | 69 | logrus.Debugf("tls root CAs: %d", len(tlsConfig.RootCAs.Subjects())) 70 | 71 | // require client auth 72 | tlsConfig.ClientAuth = tls.VerifyClientCertIfGiven 73 | 74 | // server cert 75 | keypair, err := tls.X509KeyPair(serverCert, serverKey) 76 | if err != nil { 77 | return &tlsConfig, err 78 | 79 | } 80 | tlsConfig.Certificates = []tls.Certificate{keypair} 81 | 82 | if allowInsecure { 83 | tlsConfig.InsecureSkipVerify = true 84 | } 85 | 86 | return &tlsConfig, nil 87 | } 88 | 89 | func newCertificate(org, commonName string) (*x509.Certificate, error) { 90 | now := time.Now() 91 | // need to set notBefore slightly in the past to account for time 92 | // skew in the VMs otherwise the certs sometimes are not yet valid 93 | notBefore := time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute()-5, 0, 0, time.Local) 94 | notAfter := notBefore.Add(time.Hour * 24 * 1080) 95 | 96 | serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) 97 | serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) 98 | if err != nil { 99 | return nil, err 100 | 101 | } 102 | 103 | cert := &x509.Certificate{ 104 | SerialNumber: serialNumber, 105 | Subject: pkix.Name{ 106 | Organization: []string{org}, 107 | }, 108 | SignatureAlgorithm: x509.SHA256WithRSA, 109 | NotBefore: notBefore, 110 | NotAfter: notAfter, 111 | 112 | KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageKeyAgreement, 113 | BasicConstraintsValid: true, 114 | } 115 | 116 | if commonName != "" { 117 | cert.Subject.CommonName = commonName 118 | } 119 | 120 | return cert, nil 121 | 122 | } 123 | 124 | // GenerateCACertificate generates a new certificate authority from the specified org 125 | // and bit size and returns the certificate and key as []byte, []byte 126 | func GenerateCACertificate(org string, bits int) ([]byte, []byte, error) { 127 | template, err := newCertificate(org, "") 128 | if err != nil { 129 | return nil, nil, err 130 | } 131 | 132 | template.IsCA = true 133 | template.KeyUsage |= x509.KeyUsageCertSign 134 | template.KeyUsage |= x509.KeyUsageKeyEncipherment 135 | template.KeyUsage |= x509.KeyUsageKeyAgreement 136 | 137 | priv, err := rsa.GenerateKey(rand.Reader, bits) 138 | if err != nil { 139 | return nil, nil, err 140 | } 141 | 142 | derBytes, err := x509.CreateCertificate(rand.Reader, template, template, &priv.PublicKey, priv) 143 | if err != nil { 144 | return nil, nil, err 145 | } 146 | 147 | var certOut bytes.Buffer 148 | var keyOut bytes.Buffer 149 | 150 | pem.Encode(&certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}) 151 | pem.Encode(&keyOut, &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(priv)}) 152 | 153 | return certOut.Bytes(), keyOut.Bytes(), nil 154 | } 155 | 156 | // GenerateCertificate generates a new certificate signed using the provided 157 | // certificate authority certificate and key byte arrays. It will return 158 | // the generated certificate and key as []byte, []byte 159 | func GenerateCertificate(hosts []string, caCert []byte, caKey []byte, org string, commonName string, bits int) ([]byte, []byte, error) { 160 | template, err := newCertificate(org, commonName) 161 | if err != nil { 162 | return nil, nil, err 163 | } 164 | 165 | // client 166 | if len(hosts) == 1 && hosts[0] == "" { 167 | template.ExtKeyUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth} 168 | template.KeyUsage = x509.KeyUsageDigitalSignature 169 | } else { // server 170 | template.ExtKeyUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth} 171 | for _, h := range hosts { 172 | if ip := net.ParseIP(h); ip != nil { 173 | template.IPAddresses = append(template.IPAddresses, ip) 174 | } else { 175 | template.DNSNames = append(template.DNSNames, h) 176 | } 177 | } 178 | } 179 | 180 | tlsCert, err := tls.X509KeyPair(caCert, caKey) 181 | if err != nil { 182 | return nil, nil, err 183 | } 184 | 185 | priv, err := rsa.GenerateKey(rand.Reader, bits) 186 | if err != nil { 187 | return nil, nil, err 188 | } 189 | 190 | x509Cert, err := x509.ParseCertificate(tlsCert.Certificate[0]) 191 | if err != nil { 192 | return nil, nil, err 193 | } 194 | 195 | derBytes, err := x509.CreateCertificate(rand.Reader, template, x509Cert, &priv.PublicKey, tlsCert.PrivateKey) 196 | if err != nil { 197 | return nil, nil, err 198 | } 199 | 200 | var certOut bytes.Buffer 201 | var keyOut bytes.Buffer 202 | 203 | pem.Encode(&certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}) 204 | pem.Encode(&keyOut, &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(priv)}) 205 | 206 | return certOut.Bytes(), keyOut.Bytes(), nil 207 | } 208 | 209 | // GetPublicKey returns the RSA public key for the specified private key 210 | func GetPublicKey(priv interface{}) (*rsa.PublicKey, error) { 211 | if k, ok := priv.(*rsa.PrivateKey); ok { 212 | return &k.PublicKey, nil 213 | } 214 | 215 | return nil, ErrNotRSAPrivateKey 216 | } 217 | -------------------------------------------------------------------------------- /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/exported.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | var ( 8 | // std is the name of the standard logger in stdlib `log` 9 | std = New() 10 | ) 11 | 12 | func StandardLogger() *Logger { 13 | return std 14 | } 15 | 16 | // SetOutput sets the standard logger output. 17 | func SetOutput(out io.Writer) { 18 | std.mu.Lock() 19 | defer std.mu.Unlock() 20 | std.Out = out 21 | } 22 | 23 | // SetFormatter sets the standard logger formatter. 24 | func SetFormatter(formatter Formatter) { 25 | std.mu.Lock() 26 | defer std.mu.Unlock() 27 | std.Formatter = formatter 28 | } 29 | 30 | // SetLevel sets the standard logger level. 31 | func SetLevel(level Level) { 32 | std.mu.Lock() 33 | defer std.mu.Unlock() 34 | std.Level = level 35 | } 36 | 37 | // GetLevel returns the standard logger level. 38 | func GetLevel() Level { 39 | std.mu.Lock() 40 | defer std.mu.Unlock() 41 | return std.Level 42 | } 43 | 44 | // AddHook adds a hook to the standard logger hooks. 45 | func AddHook(hook Hook) { 46 | std.mu.Lock() 47 | defer std.mu.Unlock() 48 | std.Hooks.Add(hook) 49 | } 50 | 51 | // WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key. 52 | func WithError(err error) *Entry { 53 | return std.WithField(ErrorKey, err) 54 | } 55 | 56 | // WithField creates an entry from the standard logger and adds a field to 57 | // it. If you want multiple fields, use `WithFields`. 58 | // 59 | // Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal 60 | // or Panic on the Entry it returns. 61 | func WithField(key string, value interface{}) *Entry { 62 | return std.WithField(key, value) 63 | } 64 | 65 | // WithFields creates an entry from the standard logger and adds multiple 66 | // fields to it. This is simply a helper for `WithField`, invoking it 67 | // once for each field. 68 | // 69 | // Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal 70 | // or Panic on the Entry it returns. 71 | func WithFields(fields Fields) *Entry { 72 | return std.WithFields(fields) 73 | } 74 | 75 | // Debug logs a message at level Debug on the standard logger. 76 | func Debug(args ...interface{}) { 77 | std.Debug(args...) 78 | } 79 | 80 | // Print logs a message at level Info on the standard logger. 81 | func Print(args ...interface{}) { 82 | std.Print(args...) 83 | } 84 | 85 | // Info logs a message at level Info on the standard logger. 86 | func Info(args ...interface{}) { 87 | std.Info(args...) 88 | } 89 | 90 | // Warn logs a message at level Warn on the standard logger. 91 | func Warn(args ...interface{}) { 92 | std.Warn(args...) 93 | } 94 | 95 | // Warning logs a message at level Warn on the standard logger. 96 | func Warning(args ...interface{}) { 97 | std.Warning(args...) 98 | } 99 | 100 | // Error logs a message at level Error on the standard logger. 101 | func Error(args ...interface{}) { 102 | std.Error(args...) 103 | } 104 | 105 | // Panic logs a message at level Panic on the standard logger. 106 | func Panic(args ...interface{}) { 107 | std.Panic(args...) 108 | } 109 | 110 | // Fatal logs a message at level Fatal on the standard logger. 111 | func Fatal(args ...interface{}) { 112 | std.Fatal(args...) 113 | } 114 | 115 | // Debugf logs a message at level Debug on the standard logger. 116 | func Debugf(format string, args ...interface{}) { 117 | std.Debugf(format, args...) 118 | } 119 | 120 | // Printf logs a message at level Info on the standard logger. 121 | func Printf(format string, args ...interface{}) { 122 | std.Printf(format, args...) 123 | } 124 | 125 | // Infof logs a message at level Info on the standard logger. 126 | func Infof(format string, args ...interface{}) { 127 | std.Infof(format, args...) 128 | } 129 | 130 | // Warnf logs a message at level Warn on the standard logger. 131 | func Warnf(format string, args ...interface{}) { 132 | std.Warnf(format, args...) 133 | } 134 | 135 | // Warningf logs a message at level Warn on the standard logger. 136 | func Warningf(format string, args ...interface{}) { 137 | std.Warningf(format, args...) 138 | } 139 | 140 | // Errorf logs a message at level Error on the standard logger. 141 | func Errorf(format string, args ...interface{}) { 142 | std.Errorf(format, args...) 143 | } 144 | 145 | // Panicf logs a message at level Panic on the standard logger. 146 | func Panicf(format string, args ...interface{}) { 147 | std.Panicf(format, args...) 148 | } 149 | 150 | // Fatalf logs a message at level Fatal on the standard logger. 151 | func Fatalf(format string, args ...interface{}) { 152 | std.Fatalf(format, args...) 153 | } 154 | 155 | // Debugln logs a message at level Debug on the standard logger. 156 | func Debugln(args ...interface{}) { 157 | std.Debugln(args...) 158 | } 159 | 160 | // Println logs a message at level Info on the standard logger. 161 | func Println(args ...interface{}) { 162 | std.Println(args...) 163 | } 164 | 165 | // Infoln logs a message at level Info on the standard logger. 166 | func Infoln(args ...interface{}) { 167 | std.Infoln(args...) 168 | } 169 | 170 | // Warnln logs a message at level Warn on the standard logger. 171 | func Warnln(args ...interface{}) { 172 | std.Warnln(args...) 173 | } 174 | 175 | // Warningln logs a message at level Warn on the standard logger. 176 | func Warningln(args ...interface{}) { 177 | std.Warningln(args...) 178 | } 179 | 180 | // Errorln logs a message at level Error on the standard logger. 181 | func Errorln(args ...interface{}) { 182 | std.Errorln(args...) 183 | } 184 | 185 | // Panicln logs a message at level Panic on the standard logger. 186 | func Panicln(args ...interface{}) { 187 | std.Panicln(args...) 188 | } 189 | 190 | // Fatalln logs a message at level Fatal on the standard logger. 191 | func Fatalln(args ...interface{}) { 192 | std.Fatalln(args...) 193 | } 194 | -------------------------------------------------------------------------------- /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/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type fieldKey string 9 | type FieldMap map[fieldKey]string 10 | 11 | const ( 12 | FieldKeyMsg = "msg" 13 | FieldKeyLevel = "level" 14 | FieldKeyTime = "time" 15 | ) 16 | 17 | func (f FieldMap) resolve(key fieldKey) string { 18 | if k, ok := f[key]; ok { 19 | return k 20 | } 21 | 22 | return string(key) 23 | } 24 | 25 | type JSONFormatter struct { 26 | // TimestampFormat sets the format used for marshaling timestamps. 27 | TimestampFormat string 28 | 29 | // DisableTimestamp allows disabling automatic timestamps in output 30 | DisableTimestamp bool 31 | 32 | // FieldMap allows users to customize the names of keys for various fields. 33 | // As an example: 34 | // formatter := &JSONFormatter{ 35 | // FieldMap: FieldMap{ 36 | // FieldKeyTime: "@timestamp", 37 | // FieldKeyLevel: "@level", 38 | // FieldKeyLevel: "@message", 39 | // }, 40 | // } 41 | FieldMap FieldMap 42 | } 43 | 44 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 45 | data := make(Fields, len(entry.Data)+3) 46 | for k, v := range entry.Data { 47 | switch v := v.(type) { 48 | case error: 49 | // Otherwise errors are ignored by `encoding/json` 50 | // https://github.com/Sirupsen/logrus/issues/137 51 | data[k] = v.Error() 52 | default: 53 | data[k] = v 54 | } 55 | } 56 | prefixFieldClashes(data) 57 | 58 | timestampFormat := f.TimestampFormat 59 | if timestampFormat == "" { 60 | timestampFormat = DefaultTimestampFormat 61 | } 62 | 63 | if !f.DisableTimestamp { 64 | data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat) 65 | } 66 | data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message 67 | data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String() 68 | 69 | serialized, err := json.Marshal(data) 70 | if err != nil { 71 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 72 | } 73 | return append(serialized, '\n'), nil 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/logrus.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "strings" 7 | ) 8 | 9 | // Fields type, used to pass to `WithFields`. 10 | type Fields map[string]interface{} 11 | 12 | // Level type 13 | type Level uint8 14 | 15 | // Convert the Level to a string. E.g. PanicLevel becomes "panic". 16 | func (level Level) String() string { 17 | switch level { 18 | case DebugLevel: 19 | return "debug" 20 | case InfoLevel: 21 | return "info" 22 | case WarnLevel: 23 | return "warning" 24 | case ErrorLevel: 25 | return "error" 26 | case FatalLevel: 27 | return "fatal" 28 | case PanicLevel: 29 | return "panic" 30 | } 31 | 32 | return "unknown" 33 | } 34 | 35 | // ParseLevel takes a string level and returns the Logrus log level constant. 36 | func ParseLevel(lvl string) (Level, error) { 37 | switch strings.ToLower(lvl) { 38 | case "panic": 39 | return PanicLevel, nil 40 | case "fatal": 41 | return FatalLevel, nil 42 | case "error": 43 | return ErrorLevel, nil 44 | case "warn", "warning": 45 | return WarnLevel, nil 46 | case "info": 47 | return InfoLevel, nil 48 | case "debug": 49 | return DebugLevel, nil 50 | } 51 | 52 | var l Level 53 | return l, fmt.Errorf("not a valid logrus Level: %q", lvl) 54 | } 55 | 56 | // A constant exposing all logging levels 57 | var AllLevels = []Level{ 58 | PanicLevel, 59 | FatalLevel, 60 | ErrorLevel, 61 | WarnLevel, 62 | InfoLevel, 63 | DebugLevel, 64 | } 65 | 66 | // These are the different logging levels. You can set the logging level to log 67 | // on your instance of logger, obtained with `logrus.New()`. 68 | const ( 69 | // PanicLevel level, highest level of severity. Logs and then calls panic with the 70 | // message passed to Debug, Info, ... 71 | PanicLevel Level = iota 72 | // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the 73 | // logging level is set to Panic. 74 | FatalLevel 75 | // ErrorLevel level. Logs. Used for errors that should definitely be noted. 76 | // Commonly used for hooks to send errors to an error tracking service. 77 | ErrorLevel 78 | // WarnLevel level. Non-critical entries that deserve eyes. 79 | WarnLevel 80 | // InfoLevel level. General operational entries about what's going on inside the 81 | // application. 82 | InfoLevel 83 | // DebugLevel level. Usually only enabled when debugging. Very verbose logging. 84 | DebugLevel 85 | ) 86 | 87 | // Won't compile if StdLogger can't be realized by a log.Logger 88 | var ( 89 | _ StdLogger = &log.Logger{} 90 | _ StdLogger = &Entry{} 91 | _ StdLogger = &Logger{} 92 | ) 93 | 94 | // StdLogger is what your logrus-enabled library should take, that way 95 | // it'll accept a stdlib logger and a logrus logger. There's no standard 96 | // interface, this is the closest we get, unfortunately. 97 | type StdLogger interface { 98 | Print(...interface{}) 99 | Printf(string, ...interface{}) 100 | Println(...interface{}) 101 | 102 | Fatal(...interface{}) 103 | Fatalf(string, ...interface{}) 104 | Fatalln(...interface{}) 105 | 106 | Panic(...interface{}) 107 | Panicf(string, ...interface{}) 108 | Panicln(...interface{}) 109 | } 110 | 111 | // The FieldLogger interface generalizes the Entry and Logger types 112 | type FieldLogger interface { 113 | WithField(key string, value interface{}) *Entry 114 | WithFields(fields Fields) *Entry 115 | WithError(err error) *Entry 116 | 117 | Debugf(format string, args ...interface{}) 118 | Infof(format string, args ...interface{}) 119 | Printf(format string, args ...interface{}) 120 | Warnf(format string, args ...interface{}) 121 | Warningf(format string, args ...interface{}) 122 | Errorf(format string, args ...interface{}) 123 | Fatalf(format string, args ...interface{}) 124 | Panicf(format string, args ...interface{}) 125 | 126 | Debug(args ...interface{}) 127 | Info(args ...interface{}) 128 | Print(args ...interface{}) 129 | Warn(args ...interface{}) 130 | Warning(args ...interface{}) 131 | Error(args ...interface{}) 132 | Fatal(args ...interface{}) 133 | Panic(args ...interface{}) 134 | 135 | Debugln(args ...interface{}) 136 | Infoln(args ...interface{}) 137 | Println(args ...interface{}) 138 | Warnln(args ...interface{}) 139 | Warningln(args ...interface{}) 140 | Errorln(args ...interface{}) 141 | Fatalln(args ...interface{}) 142 | Panicln(args ...interface{}) 143 | } 144 | -------------------------------------------------------------------------------- /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(f io.Writer) 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 | "io" 13 | "os" 14 | "syscall" 15 | "unsafe" 16 | ) 17 | 18 | // IsTerminal returns true if stderr's file descriptor is a terminal. 19 | func IsTerminal(f io.Writer) bool { 20 | var termios Termios 21 | switch v := f.(type) { 22 | case *os.File: 23 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(v.Fd()), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 24 | return err == 0 25 | default: 26 | return false 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /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(f io.Writer) bool { 13 | var termios Termios 14 | switch v := f.(type) { 15 | case *os.File: 16 | _, err := unix.IoctlGetTermios(int(v.Fd()), unix.TCGETA) 17 | return err == nil 18 | default: 19 | return false 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /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 | "io" 12 | "os" 13 | "syscall" 14 | "unsafe" 15 | ) 16 | 17 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 18 | 19 | var ( 20 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 21 | ) 22 | 23 | // IsTerminal returns true if stderr's file descriptor is a terminal. 24 | func IsTerminal(f io.Writer) bool { 25 | switch v := f.(type) { 26 | case *os.File: 27 | var st uint32 28 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(v.Fd()), uintptr(unsafe.Pointer(&st)), 0) 29 | return r != 0 && e == 0 30 | default: 31 | return false 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/sirupsen/logrus/text_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "sort" 7 | "strings" 8 | "sync" 9 | "time" 10 | ) 11 | 12 | const ( 13 | nocolor = 0 14 | red = 31 15 | green = 32 16 | yellow = 33 17 | blue = 34 18 | gray = 37 19 | ) 20 | 21 | var ( 22 | baseTimestamp time.Time 23 | ) 24 | 25 | func init() { 26 | baseTimestamp = time.Now() 27 | } 28 | 29 | type TextFormatter struct { 30 | // Set to true to bypass checking for a TTY before outputting colors. 31 | ForceColors bool 32 | 33 | // Force disabling colors. 34 | DisableColors bool 35 | 36 | // Disable timestamp logging. useful when output is redirected to logging 37 | // system that already adds timestamps. 38 | DisableTimestamp bool 39 | 40 | // Enable logging the full timestamp when a TTY is attached instead of just 41 | // the time passed since beginning of execution. 42 | FullTimestamp bool 43 | 44 | // TimestampFormat to use for display when a full timestamp is printed 45 | TimestampFormat string 46 | 47 | // The fields are sorted by default for a consistent output. For applications 48 | // that log extremely frequently and don't use the JSON formatter this may not 49 | // be desired. 50 | DisableSorting bool 51 | 52 | // QuoteEmptyFields will wrap empty fields in quotes if true 53 | QuoteEmptyFields bool 54 | 55 | // QuoteCharacter can be set to the override the default quoting character " 56 | // with something else. For example: ', or `. 57 | QuoteCharacter string 58 | 59 | // Whether the logger's out is to a terminal 60 | isTerminal bool 61 | 62 | sync.Once 63 | } 64 | 65 | func (f *TextFormatter) init(entry *Entry) { 66 | if len(f.QuoteCharacter) == 0 { 67 | f.QuoteCharacter = "\"" 68 | } 69 | if entry.Logger != nil { 70 | f.isTerminal = IsTerminal(entry.Logger.Out) 71 | } 72 | } 73 | 74 | func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { 75 | var b *bytes.Buffer 76 | keys := make([]string, 0, len(entry.Data)) 77 | for k := range entry.Data { 78 | keys = append(keys, k) 79 | } 80 | 81 | if !f.DisableSorting { 82 | sort.Strings(keys) 83 | } 84 | if entry.Buffer != nil { 85 | b = entry.Buffer 86 | } else { 87 | b = &bytes.Buffer{} 88 | } 89 | 90 | prefixFieldClashes(entry.Data) 91 | 92 | f.Do(func() { f.init(entry) }) 93 | 94 | isColored := (f.ForceColors || f.isTerminal) && !f.DisableColors 95 | 96 | timestampFormat := f.TimestampFormat 97 | if timestampFormat == "" { 98 | timestampFormat = DefaultTimestampFormat 99 | } 100 | if isColored { 101 | f.printColored(b, entry, keys, timestampFormat) 102 | } else { 103 | if !f.DisableTimestamp { 104 | f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat)) 105 | } 106 | f.appendKeyValue(b, "level", entry.Level.String()) 107 | if entry.Message != "" { 108 | f.appendKeyValue(b, "msg", entry.Message) 109 | } 110 | for _, key := range keys { 111 | f.appendKeyValue(b, key, entry.Data[key]) 112 | } 113 | } 114 | 115 | b.WriteByte('\n') 116 | return b.Bytes(), nil 117 | } 118 | 119 | func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) { 120 | var levelColor int 121 | switch entry.Level { 122 | case DebugLevel: 123 | levelColor = gray 124 | case WarnLevel: 125 | levelColor = yellow 126 | case ErrorLevel, FatalLevel, PanicLevel: 127 | levelColor = red 128 | default: 129 | levelColor = blue 130 | } 131 | 132 | levelText := strings.ToUpper(entry.Level.String())[0:4] 133 | 134 | if f.DisableTimestamp { 135 | fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m %-44s ", levelColor, levelText, entry.Message) 136 | } else if !f.FullTimestamp { 137 | fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, int(entry.Time.Sub(baseTimestamp)/time.Second), entry.Message) 138 | } else { 139 | fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message) 140 | } 141 | for _, k := range keys { 142 | v := entry.Data[k] 143 | fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=", levelColor, k) 144 | f.appendValue(b, v) 145 | } 146 | } 147 | 148 | func (f *TextFormatter) needsQuoting(text string) bool { 149 | if f.QuoteEmptyFields && len(text) == 0 { 150 | return true 151 | } 152 | for _, ch := range text { 153 | if !((ch >= 'a' && ch <= 'z') || 154 | (ch >= 'A' && ch <= 'Z') || 155 | (ch >= '0' && ch <= '9') || 156 | ch == '-' || ch == '.') { 157 | return true 158 | } 159 | } 160 | return false 161 | } 162 | 163 | func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) { 164 | 165 | b.WriteString(key) 166 | b.WriteByte('=') 167 | f.appendValue(b, value) 168 | b.WriteByte(' ') 169 | } 170 | 171 | func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) { 172 | switch value := value.(type) { 173 | case string: 174 | if !f.needsQuoting(value) { 175 | b.WriteString(value) 176 | } else { 177 | fmt.Fprintf(b, "%s%v%s", f.QuoteCharacter, value, f.QuoteCharacter) 178 | } 179 | case error: 180 | errmsg := value.Error() 181 | if !f.needsQuoting(errmsg) { 182 | b.WriteString(errmsg) 183 | } else { 184 | fmt.Fprintf(b, "%s%v%s", f.QuoteCharacter, errmsg, f.QuoteCharacter) 185 | } 186 | default: 187 | fmt.Fprint(b, value) 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /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/golang.org/x/sys/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/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/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_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_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, 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-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 28 | JMP syscall·RawSyscall(SB) 29 | 30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 31 | JMP syscall·RawSyscall6(SB) 32 | -------------------------------------------------------------------------------- /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_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, 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/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /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 linux,mips linux,mipsle 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/gccgo_linux_sparc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,sparc64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern sysconf 12 | func realSysconf(name int) int64 13 | 14 | func sysconf(name int) (n int64, err syscall.Errno) { 15 | r := realSysconf(name) 16 | if r < 0 { 17 | return 0, syscall.GetErrno() 18 | } 19 | return r, 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mkpost.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs by mkall.sh. 12 | package main 13 | 14 | import ( 15 | "fmt" 16 | "go/format" 17 | "io/ioutil" 18 | "log" 19 | "os" 20 | "regexp" 21 | ) 22 | 23 | func main() { 24 | b, err := ioutil.ReadAll(os.Stdin) 25 | if err != nil { 26 | log.Fatal(err) 27 | } 28 | s := string(b) 29 | 30 | goarch := os.Getenv("GOARCH") 31 | goos := os.Getenv("GOOS") 32 | if goarch == "s390x" && goos == "linux" { 33 | // Export the types of PtraceRegs fields. 34 | re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)") 35 | s = re.ReplaceAllString(s, "Ptrace$1") 36 | 37 | // Replace padding fields inserted by cgo with blank identifiers. 38 | re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*") 39 | s = re.ReplaceAllString(s, "_") 40 | 41 | // Replace other unwanted fields with blank identifiers. 42 | re = regexp.MustCompile("X_[A-Za-z0-9_]*") 43 | s = re.ReplaceAllString(s, "_") 44 | 45 | // Replace the control_regs union with a blank identifier for now. 46 | re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64") 47 | s = re.ReplaceAllString(s, "_ [0]uint64") 48 | } 49 | 50 | // gofmt 51 | b, err = format.Source([]byte(s)) 52 | if err != nil { 53 | log.Fatal(err) 54 | } 55 | 56 | // Append this command to the header to show where the new file 57 | // came from. 58 | re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)") 59 | b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go")) 60 | 61 | fmt.Printf("%s", b) 62 | } 63 | -------------------------------------------------------------------------------- /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/sockcmsg_unix.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 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Socket control messages 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // Round the length of a raw sockaddr up to align it properly. 14 | func cmsgAlignOf(salen int) int { 15 | salign := sizeofPtr 16 | // NOTE: It seems like 64-bit Darwin and DragonFly BSD kernels 17 | // still require 32-bit aligned access to network subsystem. 18 | if darwin64Bit || dragonfly64Bit { 19 | salign = 4 20 | } 21 | return (salen + salign - 1) & ^(salign - 1) 22 | } 23 | 24 | // CmsgLen returns the value to store in the Len field of the Cmsghdr 25 | // structure, taking into account any necessary alignment. 26 | func CmsgLen(datalen int) int { 27 | return cmsgAlignOf(SizeofCmsghdr) + datalen 28 | } 29 | 30 | // CmsgSpace returns the number of bytes an ancillary element with 31 | // payload of the passed data length occupies. 32 | func CmsgSpace(datalen int) int { 33 | return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) 34 | } 35 | 36 | func cmsgData(h *Cmsghdr) unsafe.Pointer { 37 | return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr))) 38 | } 39 | 40 | // SocketControlMessage represents a socket control message. 41 | type SocketControlMessage struct { 42 | Header Cmsghdr 43 | Data []byte 44 | } 45 | 46 | // ParseSocketControlMessage parses b as an array of socket control 47 | // messages. 48 | func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { 49 | var msgs []SocketControlMessage 50 | i := 0 51 | for i+CmsgLen(0) <= len(b) { 52 | h, dbuf, err := socketControlMessageHeaderAndData(b[i:]) 53 | if err != nil { 54 | return nil, err 55 | } 56 | m := SocketControlMessage{Header: *h, Data: dbuf} 57 | msgs = append(msgs, m) 58 | i += cmsgAlignOf(int(h.Len)) 59 | } 60 | return msgs, nil 61 | } 62 | 63 | func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { 64 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 65 | if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) { 66 | return nil, nil, EINVAL 67 | } 68 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 69 | } 70 | 71 | // UnixRights encodes a set of open file descriptors into a socket 72 | // control message for sending to another process. 73 | func UnixRights(fds ...int) []byte { 74 | datalen := len(fds) * 4 75 | b := make([]byte, CmsgSpace(datalen)) 76 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 77 | h.Level = SOL_SOCKET 78 | h.Type = SCM_RIGHTS 79 | h.SetLen(CmsgLen(datalen)) 80 | data := cmsgData(h) 81 | for _, fd := range fds { 82 | *(*int32)(data) = int32(fd) 83 | data = unsafe.Pointer(uintptr(data) + 4) 84 | } 85 | return b 86 | } 87 | 88 | // ParseUnixRights decodes a socket control message that contains an 89 | // integer array of open file descriptors from another process. 90 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 91 | if m.Header.Level != SOL_SOCKET { 92 | return nil, EINVAL 93 | } 94 | if m.Header.Type != SCM_RIGHTS { 95 | return nil, EINVAL 96 | } 97 | fds := make([]int, len(m.Data)>>2) 98 | for i, j := 0, 0; i < len(m.Data); i += 4 { 99 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 100 | j++ 101 | } 102 | return fds, nil 103 | } 104 | -------------------------------------------------------------------------------- /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 | // ByteSliceFromString returns a NUL-terminated slice of bytes 25 | // containing the text of s. If s contains a NUL byte at any 26 | // location, it returns (nil, EINVAL). 27 | func ByteSliceFromString(s string) ([]byte, error) { 28 | for i := 0; i < len(s); i++ { 29 | if s[i] == 0 { 30 | return nil, EINVAL 31 | } 32 | } 33 | a := make([]byte, len(s)+1) 34 | copy(a, s) 35 | return a, nil 36 | } 37 | 38 | // BytePtrFromString returns a pointer to a NUL-terminated array of 39 | // bytes containing the text of s. If s contains a NUL byte at any 40 | // location, it returns (nil, EINVAL). 41 | func BytePtrFromString(s string) (*byte, error) { 42 | a, err := ByteSliceFromString(s) 43 | if err != nil { 44 | return nil, err 45 | } 46 | return &a[0], nil 47 | } 48 | 49 | // Single-word zero for use when we need a valid pointer to 0 bytes. 50 | // See mkunix.pl. 51 | var _zero uintptr 52 | 53 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 54 | return int64(ts.Sec), int64(ts.Nsec) 55 | } 56 | 57 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 58 | return int64(tv.Sec), int64(tv.Usec) * 1000 59 | } 60 | 61 | func (ts *Timespec) Nano() int64 { 62 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 63 | } 64 | 65 | func (tv *Timeval) Nano() int64 { 66 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 67 | } 68 | 69 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 70 | -------------------------------------------------------------------------------- /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_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_linux_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,linux 6 | 7 | package unix 8 | 9 | //sys Dup2(oldfd int, newfd int) (err error) 10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 11 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64 12 | //sys Fchown(fd int, uid int, gid int) (err error) 13 | //sys Fstat(fd int, stat *Stat_t) (err error) 14 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 15 | //sys Ftruncate(fd int, length int64) (err error) 16 | //sysnb Getegid() (egid int) 17 | //sysnb Geteuid() (euid int) 18 | //sysnb Getgid() (gid int) 19 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 20 | //sysnb Getuid() (uid int) 21 | //sysnb InotifyInit() (fd int, err error) 22 | //sys Ioperm(from int, num int, on int) (err error) 23 | //sys Iopl(level int) (err error) 24 | //sys Lchown(path string, uid int, gid int) (err error) 25 | //sys Listen(s int, n int) (err error) 26 | //sys Lstat(path string, stat *Stat_t) (err error) 27 | //sys Pause() (err error) 28 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 29 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 30 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 31 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 32 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 33 | //sys Setfsgid(gid int) (err error) 34 | //sys Setfsuid(uid int) (err error) 35 | //sysnb Setregid(rgid int, egid int) (err error) 36 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 37 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 38 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 39 | //sysnb Setreuid(ruid int, euid int) (err error) 40 | //sys Shutdown(fd int, how int) (err error) 41 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 42 | //sys Stat(path string, stat *Stat_t) (err error) 43 | //sys Statfs(path string, buf *Statfs_t) (err error) 44 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 45 | //sys Truncate(path string, length int64) (err error) 46 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 47 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 48 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 49 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 50 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 51 | //sysnb setgroups(n int, list *_Gid_t) (err error) 52 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 53 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 54 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 55 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 56 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 57 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 58 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 59 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 60 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 61 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 62 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 63 | 64 | func Gettimeofday(tv *Timeval) (err error) { 65 | errno := gettimeofday(tv) 66 | if errno != 0 { 67 | return errno 68 | } 69 | return nil 70 | } 71 | 72 | func Getpagesize() int { return 4096 } 73 | 74 | func Time(t *Time_t) (tt Time_t, err error) { 75 | var tv Timeval 76 | errno := gettimeofday(&tv) 77 | if errno != 0 { 78 | return 0, errno 79 | } 80 | if t != nil { 81 | *t = Time_t(tv.Sec) 82 | } 83 | return Time_t(tv.Sec), nil 84 | } 85 | 86 | //sys Utime(path string, buf *Utimbuf) (err error) 87 | 88 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 89 | 90 | func NsecToTimespec(nsec int64) (ts Timespec) { 91 | ts.Sec = nsec / 1e9 92 | ts.Nsec = nsec % 1e9 93 | return 94 | } 95 | 96 | func NsecToTimeval(nsec int64) (tv Timeval) { 97 | nsec += 999 // round up to microsecond 98 | tv.Sec = nsec / 1e9 99 | tv.Usec = nsec % 1e9 / 1e3 100 | return 101 | } 102 | 103 | //sysnb pipe(p *[2]_C_int) (err error) 104 | 105 | func Pipe(p []int) (err error) { 106 | if len(p) != 2 { 107 | return EINVAL 108 | } 109 | var pp [2]_C_int 110 | err = pipe(&pp) 111 | p[0] = int(pp[0]) 112 | p[1] = int(pp[1]) 113 | return 114 | } 115 | 116 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 117 | 118 | func Pipe2(p []int, flags int) (err error) { 119 | if len(p) != 2 { 120 | return EINVAL 121 | } 122 | var pp [2]_C_int 123 | err = pipe2(&pp, flags) 124 | p[0] = int(pp[0]) 125 | p[1] = int(pp[1]) 126 | return 127 | } 128 | 129 | func (r *PtraceRegs) PC() uint64 { return r.Rip } 130 | 131 | func (r *PtraceRegs) SetPC(pc uint64) { r.Rip = pc } 132 | 133 | func (iov *Iovec) SetLen(length int) { 134 | iov.Len = uint64(length) 135 | } 136 | 137 | func (msghdr *Msghdr) SetControllen(length int) { 138 | msghdr.Controllen = uint64(length) 139 | } 140 | 141 | func (cmsg *Cmsghdr) SetLen(length int) { 142 | cmsg.Len = uint64(length) 143 | } 144 | 145 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 146 | 147 | func Poll(fds []PollFd, timeout int) (n int, err error) { 148 | if len(fds) == 0 { 149 | return poll(nil, 0, timeout) 150 | } 151 | return poll(&fds[0], len(fds), timeout) 152 | } 153 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_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,linux 6 | 7 | package unix 8 | 9 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) = SYS_EPOLL_PWAIT 10 | //sys Fchown(fd int, uid int, gid int) (err error) 11 | //sys Fstat(fd int, stat *Stat_t) (err error) 12 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 13 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 14 | //sys Ftruncate(fd int, length int64) (err error) 15 | //sysnb Getegid() (egid int) 16 | //sysnb Geteuid() (euid int) 17 | //sysnb Getgid() (gid int) 18 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 19 | //sysnb Getuid() (uid int) 20 | //sys Listen(s int, n int) (err error) 21 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 22 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 23 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 24 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6 25 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 26 | //sys Setfsgid(gid int) (err error) 27 | //sys Setfsuid(uid int) (err error) 28 | //sysnb Setregid(rgid int, egid int) (err error) 29 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 30 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 31 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 32 | //sysnb Setreuid(ruid int, euid int) (err error) 33 | //sys Shutdown(fd int, how int) (err error) 34 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 35 | 36 | func Stat(path string, stat *Stat_t) (err error) { 37 | return Fstatat(AT_FDCWD, path, stat, 0) 38 | } 39 | 40 | func Lchown(path string, uid int, gid int) (err error) { 41 | return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW) 42 | } 43 | 44 | func Lstat(path string, stat *Stat_t) (err error) { 45 | return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW) 46 | } 47 | 48 | //sys Statfs(path string, buf *Statfs_t) (err error) 49 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 50 | //sys Truncate(path string, length int64) (err error) 51 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 52 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 53 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 54 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 55 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 56 | //sysnb setgroups(n int, list *_Gid_t) (err error) 57 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 58 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 59 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 60 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 61 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 62 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 63 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 64 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 65 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 66 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 67 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 68 | 69 | func Getpagesize() int { return 65536 } 70 | 71 | //sysnb Gettimeofday(tv *Timeval) (err error) 72 | 73 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 74 | 75 | func NsecToTimespec(nsec int64) (ts Timespec) { 76 | ts.Sec = nsec / 1e9 77 | ts.Nsec = nsec % 1e9 78 | return 79 | } 80 | 81 | func NsecToTimeval(nsec int64) (tv Timeval) { 82 | nsec += 999 // round up to microsecond 83 | tv.Sec = nsec / 1e9 84 | tv.Usec = nsec % 1e9 / 1e3 85 | return 86 | } 87 | 88 | func Time(t *Time_t) (Time_t, error) { 89 | var tv Timeval 90 | err := Gettimeofday(&tv) 91 | if err != nil { 92 | return 0, err 93 | } 94 | if t != nil { 95 | *t = Time_t(tv.Sec) 96 | } 97 | return Time_t(tv.Sec), nil 98 | } 99 | 100 | func Utime(path string, buf *Utimbuf) error { 101 | tv := []Timeval{ 102 | {Sec: buf.Actime}, 103 | {Sec: buf.Modtime}, 104 | } 105 | return Utimes(path, tv) 106 | } 107 | 108 | func Pipe(p []int) (err error) { 109 | if len(p) != 2 { 110 | return EINVAL 111 | } 112 | var pp [2]_C_int 113 | err = pipe2(&pp, 0) 114 | p[0] = int(pp[0]) 115 | p[1] = int(pp[1]) 116 | return 117 | } 118 | 119 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 120 | 121 | func Pipe2(p []int, flags int) (err error) { 122 | if len(p) != 2 { 123 | return EINVAL 124 | } 125 | var pp [2]_C_int 126 | err = pipe2(&pp, flags) 127 | p[0] = int(pp[0]) 128 | p[1] = int(pp[1]) 129 | return 130 | } 131 | 132 | func (r *PtraceRegs) PC() uint64 { return r.Pc } 133 | 134 | func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc } 135 | 136 | func (iov *Iovec) SetLen(length int) { 137 | iov.Len = uint64(length) 138 | } 139 | 140 | func (msghdr *Msghdr) SetControllen(length int) { 141 | msghdr.Controllen = uint64(length) 142 | } 143 | 144 | func (cmsg *Cmsghdr) SetLen(length int) { 145 | cmsg.Len = uint64(length) 146 | } 147 | 148 | func InotifyInit() (fd int, err error) { 149 | return InotifyInit1(0) 150 | } 151 | 152 | func Dup2(oldfd int, newfd int) (err error) { 153 | return Dup3(oldfd, newfd, 0) 154 | } 155 | 156 | func Pause() (err error) { 157 | _, _, e1 := Syscall6(SYS_PPOLL, 0, 0, 0, 0, 0, 0) 158 | if e1 != 0 { 159 | err = errnoErr(e1) 160 | } 161 | return 162 | } 163 | 164 | // TODO(dfc): constants that should be in zsysnum_linux_arm64.go, remove 165 | // these when the deprecated syscalls that the syscall package relies on 166 | // are removed. 167 | const ( 168 | SYS_GETPGRP = 1060 169 | SYS_UTIMES = 1037 170 | SYS_FUTIMESAT = 1066 171 | SYS_PAUSE = 1061 172 | SYS_USTAT = 1070 173 | SYS_UTIME = 1063 174 | SYS_LCHOWN = 1032 175 | SYS_TIME = 1062 176 | SYS_EPOLL_CREATE = 1042 177 | SYS_EPOLL_WAIT = 1069 178 | ) 179 | 180 | func Poll(fds []PollFd, timeout int) (n int, err error) { 181 | var ts *Timespec 182 | if timeout >= 0 { 183 | ts = new(Timespec) 184 | *ts = NsecToTimespec(int64(timeout) * 1e6) 185 | } 186 | if len(fds) == 0 { 187 | return ppoll(nil, 0, ts, nil) 188 | } 189 | return ppoll(&fds[0], len(fds), ts, nil) 190 | } 191 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_mips64x.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 linux 6 | // +build mips64 mips64le 7 | 8 | package unix 9 | 10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 11 | //sys Fchown(fd int, uid int, gid int) (err error) 12 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 13 | //sys Ftruncate(fd int, length int64) (err error) 14 | //sysnb Getegid() (egid int) 15 | //sysnb Geteuid() (euid int) 16 | //sysnb Getgid() (gid int) 17 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 18 | //sysnb Getuid() (uid int) 19 | //sys Lchown(path string, uid int, gid int) (err error) 20 | //sys Listen(s int, n int) (err error) 21 | //sys Pause() (err error) 22 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 23 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 24 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 25 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS_PSELECT6 26 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 27 | //sys Setfsgid(gid int) (err error) 28 | //sys Setfsuid(uid int) (err error) 29 | //sysnb Setregid(rgid int, egid int) (err error) 30 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 31 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 32 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 33 | //sysnb Setreuid(ruid int, euid int) (err error) 34 | //sys Shutdown(fd int, how int) (err error) 35 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 36 | //sys Statfs(path string, buf *Statfs_t) (err error) 37 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 38 | //sys Truncate(path string, length int64) (err error) 39 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 40 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 41 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 42 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 43 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 44 | //sysnb setgroups(n int, list *_Gid_t) (err error) 45 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 46 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 47 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 48 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 49 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 50 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 51 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 52 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 53 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 54 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 55 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 56 | 57 | func Getpagesize() int { return 65536 } 58 | 59 | //sysnb Gettimeofday(tv *Timeval) (err error) 60 | 61 | func Time(t *Time_t) (tt Time_t, err error) { 62 | var tv Timeval 63 | err = Gettimeofday(&tv) 64 | if err != nil { 65 | return 0, err 66 | } 67 | if t != nil { 68 | *t = Time_t(tv.Sec) 69 | } 70 | return Time_t(tv.Sec), nil 71 | } 72 | 73 | //sys Utime(path string, buf *Utimbuf) (err error) 74 | 75 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 76 | 77 | func NsecToTimespec(nsec int64) (ts Timespec) { 78 | ts.Sec = nsec / 1e9 79 | ts.Nsec = nsec % 1e9 80 | return 81 | } 82 | 83 | func NsecToTimeval(nsec int64) (tv Timeval) { 84 | nsec += 999 // round up to microsecond 85 | tv.Sec = nsec / 1e9 86 | tv.Usec = nsec % 1e9 / 1e3 87 | return 88 | } 89 | 90 | func Pipe(p []int) (err error) { 91 | if len(p) != 2 { 92 | return EINVAL 93 | } 94 | var pp [2]_C_int 95 | err = pipe2(&pp, 0) 96 | p[0] = int(pp[0]) 97 | p[1] = int(pp[1]) 98 | return 99 | } 100 | 101 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 102 | 103 | func Pipe2(p []int, flags int) (err error) { 104 | if len(p) != 2 { 105 | return EINVAL 106 | } 107 | var pp [2]_C_int 108 | err = pipe2(&pp, flags) 109 | p[0] = int(pp[0]) 110 | p[1] = int(pp[1]) 111 | return 112 | } 113 | 114 | func Ioperm(from int, num int, on int) (err error) { 115 | return ENOSYS 116 | } 117 | 118 | func Iopl(level int) (err error) { 119 | return ENOSYS 120 | } 121 | 122 | type stat_t struct { 123 | Dev uint32 124 | Pad0 [3]int32 125 | Ino uint64 126 | Mode uint32 127 | Nlink uint32 128 | Uid uint32 129 | Gid uint32 130 | Rdev uint32 131 | Pad1 [3]uint32 132 | Size int64 133 | Atime uint32 134 | Atime_nsec uint32 135 | Mtime uint32 136 | Mtime_nsec uint32 137 | Ctime uint32 138 | Ctime_nsec uint32 139 | Blksize uint32 140 | Pad2 uint32 141 | Blocks int64 142 | } 143 | 144 | //sys fstat(fd int, st *stat_t) (err error) 145 | //sys lstat(path string, st *stat_t) (err error) 146 | //sys stat(path string, st *stat_t) (err error) 147 | 148 | func Fstat(fd int, s *Stat_t) (err error) { 149 | st := &stat_t{} 150 | err = fstat(fd, st) 151 | fillStat_t(s, st) 152 | return 153 | } 154 | 155 | func Lstat(path string, s *Stat_t) (err error) { 156 | st := &stat_t{} 157 | err = lstat(path, st) 158 | fillStat_t(s, st) 159 | return 160 | } 161 | 162 | func Stat(path string, s *Stat_t) (err error) { 163 | st := &stat_t{} 164 | err = stat(path, st) 165 | fillStat_t(s, st) 166 | return 167 | } 168 | 169 | func fillStat_t(s *Stat_t, st *stat_t) { 170 | s.Dev = st.Dev 171 | s.Ino = st.Ino 172 | s.Mode = st.Mode 173 | s.Nlink = st.Nlink 174 | s.Uid = st.Uid 175 | s.Gid = st.Gid 176 | s.Rdev = st.Rdev 177 | s.Size = st.Size 178 | s.Atim = Timespec{int64(st.Atime), int64(st.Atime_nsec)} 179 | s.Mtim = Timespec{int64(st.Mtime), int64(st.Mtime_nsec)} 180 | s.Ctim = Timespec{int64(st.Ctime), int64(st.Ctime_nsec)} 181 | s.Blksize = st.Blksize 182 | s.Blocks = st.Blocks 183 | } 184 | 185 | func (r *PtraceRegs) PC() uint64 { return r.Regs[64] } 186 | 187 | func (r *PtraceRegs) SetPC(pc uint64) { r.Regs[64] = pc } 188 | 189 | func (iov *Iovec) SetLen(length int) { 190 | iov.Len = uint64(length) 191 | } 192 | 193 | func (msghdr *Msghdr) SetControllen(length int) { 194 | msghdr.Controllen = uint64(length) 195 | } 196 | 197 | func (cmsg *Cmsghdr) SetLen(length int) { 198 | cmsg.Len = uint64(length) 199 | } 200 | 201 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 202 | 203 | func Poll(fds []PollFd, timeout int) (n int, err error) { 204 | if len(fds) == 0 { 205 | return poll(nil, 0, timeout) 206 | } 207 | return poll(&fds[0], len(fds), timeout) 208 | } 209 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.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 linux 6 | // +build ppc64 ppc64le 7 | 8 | package unix 9 | 10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 11 | //sys Dup2(oldfd int, newfd int) (err error) 12 | //sys Fchown(fd int, uid int, gid int) (err error) 13 | //sys Fstat(fd int, stat *Stat_t) (err error) 14 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 15 | //sys Ftruncate(fd int, length int64) (err error) 16 | //sysnb Getegid() (egid int) 17 | //sysnb Geteuid() (euid int) 18 | //sysnb Getgid() (gid int) 19 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT 20 | //sysnb Getuid() (uid int) 21 | //sysnb InotifyInit() (fd int, err error) 22 | //sys Ioperm(from int, num int, on int) (err error) 23 | //sys Iopl(level int) (err error) 24 | //sys Lchown(path string, uid int, gid int) (err error) 25 | //sys Listen(s int, n int) (err error) 26 | //sys Lstat(path string, stat *Stat_t) (err error) 27 | //sys Pause() (err error) 28 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 29 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 30 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 31 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 32 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 33 | //sys Setfsgid(gid int) (err error) 34 | //sys Setfsuid(uid int) (err error) 35 | //sysnb Setregid(rgid int, egid int) (err error) 36 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 37 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 38 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 39 | //sysnb Setreuid(ruid int, euid int) (err error) 40 | //sys Shutdown(fd int, how int) (err error) 41 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 42 | //sys Stat(path string, stat *Stat_t) (err error) 43 | //sys Statfs(path string, buf *Statfs_t) (err error) 44 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2 45 | //sys Truncate(path string, length int64) (err error) 46 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 47 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 48 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 49 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 50 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 51 | //sysnb setgroups(n int, list *_Gid_t) (err error) 52 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 53 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 54 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 55 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 56 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 57 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 58 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 59 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 60 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 61 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 62 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 63 | 64 | func Getpagesize() int { return 65536 } 65 | 66 | //sysnb Gettimeofday(tv *Timeval) (err error) 67 | //sysnb Time(t *Time_t) (tt Time_t, err error) 68 | 69 | //sys Utime(path string, buf *Utimbuf) (err error) 70 | 71 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 72 | 73 | func NsecToTimespec(nsec int64) (ts Timespec) { 74 | ts.Sec = nsec / 1e9 75 | ts.Nsec = nsec % 1e9 76 | return 77 | } 78 | 79 | func NsecToTimeval(nsec int64) (tv Timeval) { 80 | nsec += 999 // round up to microsecond 81 | tv.Sec = nsec / 1e9 82 | tv.Usec = nsec % 1e9 / 1e3 83 | return 84 | } 85 | 86 | func (r *PtraceRegs) PC() uint64 { return r.Nip } 87 | 88 | func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc } 89 | 90 | func (iov *Iovec) SetLen(length int) { 91 | iov.Len = uint64(length) 92 | } 93 | 94 | func (msghdr *Msghdr) SetControllen(length int) { 95 | msghdr.Controllen = uint64(length) 96 | } 97 | 98 | func (cmsg *Cmsghdr) SetLen(length int) { 99 | cmsg.Len = uint64(length) 100 | } 101 | 102 | //sysnb pipe(p *[2]_C_int) (err error) 103 | 104 | func Pipe(p []int) (err error) { 105 | if len(p) != 2 { 106 | return EINVAL 107 | } 108 | var pp [2]_C_int 109 | err = pipe(&pp) 110 | p[0] = int(pp[0]) 111 | p[1] = int(pp[1]) 112 | return 113 | } 114 | 115 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 116 | 117 | func Pipe2(p []int, flags int) (err error) { 118 | if len(p) != 2 { 119 | return EINVAL 120 | } 121 | var pp [2]_C_int 122 | err = pipe2(&pp, flags) 123 | p[0] = int(pp[0]) 124 | p[1] = int(pp[1]) 125 | return 126 | } 127 | 128 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 129 | 130 | func Poll(fds []PollFd, timeout int) (n int, err error) { 131 | if len(fds) == 0 { 132 | return poll(nil, 0, timeout) 133 | } 134 | return poll(&fds[0], len(fds), timeout) 135 | } 136 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_sparc64.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 sparc64,linux 6 | 7 | package unix 8 | 9 | import ( 10 | "sync/atomic" 11 | "syscall" 12 | ) 13 | 14 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 15 | //sys Dup2(oldfd int, newfd int) (err error) 16 | //sys Fchown(fd int, uid int, gid int) (err error) 17 | //sys Fstat(fd int, stat *Stat_t) (err error) 18 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 19 | //sys Ftruncate(fd int, length int64) (err error) 20 | //sysnb Getegid() (egid int) 21 | //sysnb Geteuid() (euid int) 22 | //sysnb Getgid() (gid int) 23 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 24 | //sysnb Getuid() (uid int) 25 | //sysnb InotifyInit() (fd int, err error) 26 | //sys Lchown(path string, uid int, gid int) (err error) 27 | //sys Listen(s int, n int) (err error) 28 | //sys Lstat(path string, stat *Stat_t) (err error) 29 | //sys Pause() (err error) 30 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 31 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 32 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 33 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 34 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 35 | //sys Setfsgid(gid int) (err error) 36 | //sys Setfsuid(uid int) (err error) 37 | //sysnb Setregid(rgid int, egid int) (err error) 38 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 39 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 40 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 41 | //sysnb Setreuid(ruid int, euid int) (err error) 42 | //sys Shutdown(fd int, how int) (err error) 43 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 44 | //sys Stat(path string, stat *Stat_t) (err error) 45 | //sys Statfs(path string, buf *Statfs_t) (err error) 46 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) 47 | //sys Truncate(path string, length int64) (err error) 48 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 49 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 50 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 51 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 52 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 53 | //sysnb setgroups(n int, list *_Gid_t) (err error) 54 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 55 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 56 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 57 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 58 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 59 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 60 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 61 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 62 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 63 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 64 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 65 | 66 | func sysconf(name int) (n int64, err syscall.Errno) 67 | 68 | // pageSize caches the value of Getpagesize, since it can't change 69 | // once the system is booted. 70 | var pageSize int64 // accessed atomically 71 | 72 | func Getpagesize() int { 73 | n := atomic.LoadInt64(&pageSize) 74 | if n == 0 { 75 | n, _ = sysconf(_SC_PAGESIZE) 76 | atomic.StoreInt64(&pageSize, n) 77 | } 78 | return int(n) 79 | } 80 | 81 | func Ioperm(from int, num int, on int) (err error) { 82 | return ENOSYS 83 | } 84 | 85 | func Iopl(level int) (err error) { 86 | return ENOSYS 87 | } 88 | 89 | //sysnb Gettimeofday(tv *Timeval) (err error) 90 | 91 | func Time(t *Time_t) (tt Time_t, err error) { 92 | var tv Timeval 93 | err = Gettimeofday(&tv) 94 | if err != nil { 95 | return 0, err 96 | } 97 | if t != nil { 98 | *t = Time_t(tv.Sec) 99 | } 100 | return Time_t(tv.Sec), nil 101 | } 102 | 103 | //sys Utime(path string, buf *Utimbuf) (err error) 104 | 105 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 106 | 107 | func NsecToTimespec(nsec int64) (ts Timespec) { 108 | ts.Sec = nsec / 1e9 109 | ts.Nsec = nsec % 1e9 110 | return 111 | } 112 | 113 | func NsecToTimeval(nsec int64) (tv Timeval) { 114 | nsec += 999 // round up to microsecond 115 | tv.Sec = nsec / 1e9 116 | tv.Usec = int32(nsec % 1e9 / 1e3) 117 | return 118 | } 119 | 120 | func (r *PtraceRegs) PC() uint64 { return r.Tpc } 121 | 122 | func (r *PtraceRegs) SetPC(pc uint64) { r.Tpc = pc } 123 | 124 | func (iov *Iovec) SetLen(length int) { 125 | iov.Len = uint64(length) 126 | } 127 | 128 | func (msghdr *Msghdr) SetControllen(length int) { 129 | msghdr.Controllen = uint64(length) 130 | } 131 | 132 | func (cmsg *Cmsghdr) SetLen(length int) { 133 | cmsg.Len = uint64(length) 134 | } 135 | 136 | //sysnb pipe(p *[2]_C_int) (err error) 137 | 138 | func Pipe(p []int) (err error) { 139 | if len(p) != 2 { 140 | return EINVAL 141 | } 142 | var pp [2]_C_int 143 | err = pipe(&pp) 144 | p[0] = int(pp[0]) 145 | p[1] = int(pp[1]) 146 | return 147 | } 148 | 149 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 150 | 151 | func Pipe2(p []int, flags int) (err error) { 152 | if len(p) != 2 { 153 | return EINVAL 154 | } 155 | var pp [2]_C_int 156 | err = pipe2(&pp, flags) 157 | p[0] = int(pp[0]) 158 | p[1] = int(pp[1]) 159 | return 160 | } 161 | 162 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 163 | 164 | func Poll(fds []PollFd, timeout int) (n int, err error) { 165 | if len(fds) == 0 { 166 | return poll(nil, 0, timeout) 167 | } 168 | return poll(&fds[0], len(fds), timeout) 169 | } 170 | -------------------------------------------------------------------------------- /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/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_darwin.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 ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define __DARWIN_UNIX03 0 18 | #define KERNEL 19 | #define _DARWIN_USE_64_BIT_INODE 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | enum { 52 | sizeofPtr = sizeof(void*), 53 | }; 54 | 55 | union sockaddr_all { 56 | struct sockaddr s1; // this one gets used for fields 57 | struct sockaddr_in s2; // these pad it out 58 | struct sockaddr_in6 s3; 59 | struct sockaddr_un s4; 60 | struct sockaddr_dl s5; 61 | }; 62 | 63 | struct sockaddr_any { 64 | struct sockaddr addr; 65 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 66 | }; 67 | 68 | */ 69 | import "C" 70 | 71 | // Machine characteristics; for internal use. 72 | 73 | const ( 74 | sizeofPtr = C.sizeofPtr 75 | sizeofShort = C.sizeof_short 76 | sizeofInt = C.sizeof_int 77 | sizeofLong = C.sizeof_long 78 | sizeofLongLong = C.sizeof_longlong 79 | ) 80 | 81 | // Basic types 82 | 83 | type ( 84 | _C_short C.short 85 | _C_int C.int 86 | _C_long C.long 87 | _C_long_long C.longlong 88 | ) 89 | 90 | // Time 91 | 92 | type Timespec C.struct_timespec 93 | 94 | type Timeval C.struct_timeval 95 | 96 | type Timeval32 C.struct_timeval32 97 | 98 | // Processes 99 | 100 | type Rusage C.struct_rusage 101 | 102 | type Rlimit C.struct_rlimit 103 | 104 | type _Gid_t C.gid_t 105 | 106 | // Files 107 | 108 | type Stat_t C.struct_stat64 109 | 110 | type Statfs_t C.struct_statfs64 111 | 112 | type Flock_t C.struct_flock 113 | 114 | type Fstore_t C.struct_fstore 115 | 116 | type Radvisory_t C.struct_radvisory 117 | 118 | type Fbootstraptransfer_t C.struct_fbootstraptransfer 119 | 120 | type Log2phys_t C.struct_log2phys 121 | 122 | type Fsid C.struct_fsid 123 | 124 | type Dirent C.struct_dirent 125 | 126 | // Sockets 127 | 128 | type RawSockaddrInet4 C.struct_sockaddr_in 129 | 130 | type RawSockaddrInet6 C.struct_sockaddr_in6 131 | 132 | type RawSockaddrUnix C.struct_sockaddr_un 133 | 134 | type RawSockaddrDatalink C.struct_sockaddr_dl 135 | 136 | type RawSockaddr C.struct_sockaddr 137 | 138 | type RawSockaddrAny C.struct_sockaddr_any 139 | 140 | type _Socklen C.socklen_t 141 | 142 | type Linger C.struct_linger 143 | 144 | type Iovec C.struct_iovec 145 | 146 | type IPMreq C.struct_ip_mreq 147 | 148 | type IPv6Mreq C.struct_ipv6_mreq 149 | 150 | type Msghdr C.struct_msghdr 151 | 152 | type Cmsghdr C.struct_cmsghdr 153 | 154 | type Inet4Pktinfo C.struct_in_pktinfo 155 | 156 | type Inet6Pktinfo C.struct_in6_pktinfo 157 | 158 | type IPv6MTUInfo C.struct_ip6_mtuinfo 159 | 160 | type ICMPv6Filter C.struct_icmp6_filter 161 | 162 | const ( 163 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 164 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 165 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 166 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 167 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 168 | SizeofLinger = C.sizeof_struct_linger 169 | SizeofIPMreq = C.sizeof_struct_ip_mreq 170 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 171 | SizeofMsghdr = C.sizeof_struct_msghdr 172 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 173 | SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo 174 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 175 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 176 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 177 | ) 178 | 179 | // Ptrace requests 180 | 181 | const ( 182 | PTRACE_TRACEME = C.PT_TRACE_ME 183 | PTRACE_CONT = C.PT_CONTINUE 184 | PTRACE_KILL = C.PT_KILL 185 | ) 186 | 187 | // Events (kqueue, kevent) 188 | 189 | type Kevent_t C.struct_kevent 190 | 191 | // Select 192 | 193 | type FdSet C.fd_set 194 | 195 | // Routing and interface messages 196 | 197 | const ( 198 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 199 | SizeofIfData = C.sizeof_struct_if_data 200 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 201 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr 202 | SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2 203 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 204 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 205 | ) 206 | 207 | type IfMsghdr C.struct_if_msghdr 208 | 209 | type IfData C.struct_if_data 210 | 211 | type IfaMsghdr C.struct_ifa_msghdr 212 | 213 | type IfmaMsghdr C.struct_ifma_msghdr 214 | 215 | type IfmaMsghdr2 C.struct_ifma_msghdr2 216 | 217 | type RtMsghdr C.struct_rt_msghdr 218 | 219 | type RtMetrics C.struct_rt_metrics 220 | 221 | // Berkeley packet filter 222 | 223 | const ( 224 | SizeofBpfVersion = C.sizeof_struct_bpf_version 225 | SizeofBpfStat = C.sizeof_struct_bpf_stat 226 | SizeofBpfProgram = C.sizeof_struct_bpf_program 227 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 228 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 229 | ) 230 | 231 | type BpfVersion C.struct_bpf_version 232 | 233 | type BpfStat C.struct_bpf_stat 234 | 235 | type BpfProgram C.struct_bpf_program 236 | 237 | type BpfInsn C.struct_bpf_insn 238 | 239 | type BpfHdr C.struct_bpf_hdr 240 | 241 | // Terminal handling 242 | 243 | type Termios C.struct_termios 244 | 245 | // fchmodat-like syscalls. 246 | 247 | const ( 248 | AT_FDCWD = C.AT_FDCWD 249 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 250 | ) 251 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_dragonfly.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 ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | enum { 47 | sizeofPtr = sizeof(void*), 48 | }; 49 | 50 | union sockaddr_all { 51 | struct sockaddr s1; // this one gets used for fields 52 | struct sockaddr_in s2; // these pad it out 53 | struct sockaddr_in6 s3; 54 | struct sockaddr_un s4; 55 | struct sockaddr_dl s5; 56 | }; 57 | 58 | struct sockaddr_any { 59 | struct sockaddr addr; 60 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 61 | }; 62 | 63 | */ 64 | import "C" 65 | 66 | // Machine characteristics; for internal use. 67 | 68 | const ( 69 | sizeofPtr = C.sizeofPtr 70 | sizeofShort = C.sizeof_short 71 | sizeofInt = C.sizeof_int 72 | sizeofLong = C.sizeof_long 73 | sizeofLongLong = C.sizeof_longlong 74 | ) 75 | 76 | // Basic types 77 | 78 | type ( 79 | _C_short C.short 80 | _C_int C.int 81 | _C_long C.long 82 | _C_long_long C.longlong 83 | ) 84 | 85 | // Time 86 | 87 | type Timespec C.struct_timespec 88 | 89 | type Timeval C.struct_timeval 90 | 91 | // Processes 92 | 93 | type Rusage C.struct_rusage 94 | 95 | type Rlimit C.struct_rlimit 96 | 97 | type _Gid_t C.gid_t 98 | 99 | // Files 100 | 101 | const ( // Directory mode bits 102 | S_IFMT = C.S_IFMT 103 | S_IFIFO = C.S_IFIFO 104 | S_IFCHR = C.S_IFCHR 105 | S_IFDIR = C.S_IFDIR 106 | S_IFBLK = C.S_IFBLK 107 | S_IFREG = C.S_IFREG 108 | S_IFLNK = C.S_IFLNK 109 | S_IFSOCK = C.S_IFSOCK 110 | S_ISUID = C.S_ISUID 111 | S_ISGID = C.S_ISGID 112 | S_ISVTX = C.S_ISVTX 113 | S_IRUSR = C.S_IRUSR 114 | S_IWUSR = C.S_IWUSR 115 | S_IXUSR = C.S_IXUSR 116 | ) 117 | 118 | type Stat_t C.struct_stat 119 | 120 | type Statfs_t C.struct_statfs 121 | 122 | type Flock_t C.struct_flock 123 | 124 | type Dirent C.struct_dirent 125 | 126 | type Fsid C.struct_fsid 127 | 128 | // Sockets 129 | 130 | type RawSockaddrInet4 C.struct_sockaddr_in 131 | 132 | type RawSockaddrInet6 C.struct_sockaddr_in6 133 | 134 | type RawSockaddrUnix C.struct_sockaddr_un 135 | 136 | type RawSockaddrDatalink C.struct_sockaddr_dl 137 | 138 | type RawSockaddr C.struct_sockaddr 139 | 140 | type RawSockaddrAny C.struct_sockaddr_any 141 | 142 | type _Socklen C.socklen_t 143 | 144 | type Linger C.struct_linger 145 | 146 | type Iovec C.struct_iovec 147 | 148 | type IPMreq C.struct_ip_mreq 149 | 150 | type IPv6Mreq C.struct_ipv6_mreq 151 | 152 | type Msghdr C.struct_msghdr 153 | 154 | type Cmsghdr C.struct_cmsghdr 155 | 156 | type Inet6Pktinfo C.struct_in6_pktinfo 157 | 158 | type IPv6MTUInfo C.struct_ip6_mtuinfo 159 | 160 | type ICMPv6Filter C.struct_icmp6_filter 161 | 162 | const ( 163 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 164 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 165 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 166 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 167 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 168 | SizeofLinger = C.sizeof_struct_linger 169 | SizeofIPMreq = C.sizeof_struct_ip_mreq 170 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 171 | SizeofMsghdr = C.sizeof_struct_msghdr 172 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 173 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 174 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 175 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 176 | ) 177 | 178 | // Ptrace requests 179 | 180 | const ( 181 | PTRACE_TRACEME = C.PT_TRACE_ME 182 | PTRACE_CONT = C.PT_CONTINUE 183 | PTRACE_KILL = C.PT_KILL 184 | ) 185 | 186 | // Events (kqueue, kevent) 187 | 188 | type Kevent_t C.struct_kevent 189 | 190 | // Select 191 | 192 | type FdSet C.fd_set 193 | 194 | // Routing and interface messages 195 | 196 | const ( 197 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 198 | SizeofIfData = C.sizeof_struct_if_data 199 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 200 | SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr 201 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 202 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 203 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 204 | ) 205 | 206 | type IfMsghdr C.struct_if_msghdr 207 | 208 | type IfData C.struct_if_data 209 | 210 | type IfaMsghdr C.struct_ifa_msghdr 211 | 212 | type IfmaMsghdr C.struct_ifma_msghdr 213 | 214 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 215 | 216 | type RtMsghdr C.struct_rt_msghdr 217 | 218 | type RtMetrics C.struct_rt_metrics 219 | 220 | // Berkeley packet filter 221 | 222 | const ( 223 | SizeofBpfVersion = C.sizeof_struct_bpf_version 224 | SizeofBpfStat = C.sizeof_struct_bpf_stat 225 | SizeofBpfProgram = C.sizeof_struct_bpf_program 226 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 227 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 228 | ) 229 | 230 | type BpfVersion C.struct_bpf_version 231 | 232 | type BpfStat C.struct_bpf_stat 233 | 234 | type BpfProgram C.struct_bpf_program 235 | 236 | type BpfInsn C.struct_bpf_insn 237 | 238 | type BpfHdr C.struct_bpf_hdr 239 | 240 | // Terminal handling 241 | 242 | type Termios C.struct_termios 243 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_netbsd.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 ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | enum { 49 | sizeofPtr = sizeof(void*), 50 | }; 51 | 52 | union sockaddr_all { 53 | struct sockaddr s1; // this one gets used for fields 54 | struct sockaddr_in s2; // these pad it out 55 | struct sockaddr_in6 s3; 56 | struct sockaddr_un s4; 57 | struct sockaddr_dl s5; 58 | }; 59 | 60 | struct sockaddr_any { 61 | struct sockaddr addr; 62 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 63 | }; 64 | 65 | */ 66 | import "C" 67 | 68 | // Machine characteristics; for internal use. 69 | 70 | const ( 71 | sizeofPtr = C.sizeofPtr 72 | sizeofShort = C.sizeof_short 73 | sizeofInt = C.sizeof_int 74 | sizeofLong = C.sizeof_long 75 | sizeofLongLong = C.sizeof_longlong 76 | ) 77 | 78 | // Basic types 79 | 80 | type ( 81 | _C_short C.short 82 | _C_int C.int 83 | _C_long C.long 84 | _C_long_long C.longlong 85 | ) 86 | 87 | // Time 88 | 89 | type Timespec C.struct_timespec 90 | 91 | type Timeval C.struct_timeval 92 | 93 | // Processes 94 | 95 | type Rusage C.struct_rusage 96 | 97 | type Rlimit C.struct_rlimit 98 | 99 | type _Gid_t C.gid_t 100 | 101 | // Files 102 | 103 | type Stat_t C.struct_stat 104 | 105 | type Statfs_t C.struct_statfs 106 | 107 | type Flock_t C.struct_flock 108 | 109 | type Dirent C.struct_dirent 110 | 111 | type Fsid C.fsid_t 112 | 113 | // Sockets 114 | 115 | type RawSockaddrInet4 C.struct_sockaddr_in 116 | 117 | type RawSockaddrInet6 C.struct_sockaddr_in6 118 | 119 | type RawSockaddrUnix C.struct_sockaddr_un 120 | 121 | type RawSockaddrDatalink C.struct_sockaddr_dl 122 | 123 | type RawSockaddr C.struct_sockaddr 124 | 125 | type RawSockaddrAny C.struct_sockaddr_any 126 | 127 | type _Socklen C.socklen_t 128 | 129 | type Linger C.struct_linger 130 | 131 | type Iovec C.struct_iovec 132 | 133 | type IPMreq C.struct_ip_mreq 134 | 135 | type IPv6Mreq C.struct_ipv6_mreq 136 | 137 | type Msghdr C.struct_msghdr 138 | 139 | type Cmsghdr C.struct_cmsghdr 140 | 141 | type Inet6Pktinfo C.struct_in6_pktinfo 142 | 143 | type IPv6MTUInfo C.struct_ip6_mtuinfo 144 | 145 | type ICMPv6Filter C.struct_icmp6_filter 146 | 147 | const ( 148 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 149 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 150 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 151 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 152 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 153 | SizeofLinger = C.sizeof_struct_linger 154 | SizeofIPMreq = C.sizeof_struct_ip_mreq 155 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 156 | SizeofMsghdr = C.sizeof_struct_msghdr 157 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 158 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 159 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 160 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 161 | ) 162 | 163 | // Ptrace requests 164 | 165 | const ( 166 | PTRACE_TRACEME = C.PT_TRACE_ME 167 | PTRACE_CONT = C.PT_CONTINUE 168 | PTRACE_KILL = C.PT_KILL 169 | ) 170 | 171 | // Events (kqueue, kevent) 172 | 173 | type Kevent_t C.struct_kevent 174 | 175 | // Select 176 | 177 | type FdSet C.fd_set 178 | 179 | // Routing and interface messages 180 | 181 | const ( 182 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 183 | SizeofIfData = C.sizeof_struct_if_data 184 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 185 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 186 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 187 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 188 | ) 189 | 190 | type IfMsghdr C.struct_if_msghdr 191 | 192 | type IfData C.struct_if_data 193 | 194 | type IfaMsghdr C.struct_ifa_msghdr 195 | 196 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 197 | 198 | type RtMsghdr C.struct_rt_msghdr 199 | 200 | type RtMetrics C.struct_rt_metrics 201 | 202 | type Mclpool C.struct_mclpool 203 | 204 | // Berkeley packet filter 205 | 206 | const ( 207 | SizeofBpfVersion = C.sizeof_struct_bpf_version 208 | SizeofBpfStat = C.sizeof_struct_bpf_stat 209 | SizeofBpfProgram = C.sizeof_struct_bpf_program 210 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 211 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 212 | ) 213 | 214 | type BpfVersion C.struct_bpf_version 215 | 216 | type BpfStat C.struct_bpf_stat 217 | 218 | type BpfProgram C.struct_bpf_program 219 | 220 | type BpfInsn C.struct_bpf_insn 221 | 222 | type BpfHdr C.struct_bpf_hdr 223 | 224 | type BpfTimeval C.struct_bpf_timeval 225 | 226 | // Terminal handling 227 | 228 | type Termios C.struct_termios 229 | 230 | // Sysctl 231 | 232 | type Sysctlnode C.struct_sysctlnode 233 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_openbsd.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 ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | enum { 48 | sizeofPtr = sizeof(void*), 49 | }; 50 | 51 | union sockaddr_all { 52 | struct sockaddr s1; // this one gets used for fields 53 | struct sockaddr_in s2; // these pad it out 54 | struct sockaddr_in6 s3; 55 | struct sockaddr_un s4; 56 | struct sockaddr_dl s5; 57 | }; 58 | 59 | struct sockaddr_any { 60 | struct sockaddr addr; 61 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 62 | }; 63 | 64 | */ 65 | import "C" 66 | 67 | // Machine characteristics; for internal use. 68 | 69 | const ( 70 | sizeofPtr = C.sizeofPtr 71 | sizeofShort = C.sizeof_short 72 | sizeofInt = C.sizeof_int 73 | sizeofLong = C.sizeof_long 74 | sizeofLongLong = C.sizeof_longlong 75 | ) 76 | 77 | // Basic types 78 | 79 | type ( 80 | _C_short C.short 81 | _C_int C.int 82 | _C_long C.long 83 | _C_long_long C.longlong 84 | ) 85 | 86 | // Time 87 | 88 | type Timespec C.struct_timespec 89 | 90 | type Timeval C.struct_timeval 91 | 92 | // Processes 93 | 94 | type Rusage C.struct_rusage 95 | 96 | type Rlimit C.struct_rlimit 97 | 98 | type _Gid_t C.gid_t 99 | 100 | // Files 101 | 102 | const ( // Directory mode bits 103 | S_IFMT = C.S_IFMT 104 | S_IFIFO = C.S_IFIFO 105 | S_IFCHR = C.S_IFCHR 106 | S_IFDIR = C.S_IFDIR 107 | S_IFBLK = C.S_IFBLK 108 | S_IFREG = C.S_IFREG 109 | S_IFLNK = C.S_IFLNK 110 | S_IFSOCK = C.S_IFSOCK 111 | S_ISUID = C.S_ISUID 112 | S_ISGID = C.S_ISGID 113 | S_ISVTX = C.S_ISVTX 114 | S_IRUSR = C.S_IRUSR 115 | S_IWUSR = C.S_IWUSR 116 | S_IXUSR = C.S_IXUSR 117 | ) 118 | 119 | type Stat_t C.struct_stat 120 | 121 | type Statfs_t C.struct_statfs 122 | 123 | type Flock_t C.struct_flock 124 | 125 | type Dirent C.struct_dirent 126 | 127 | type Fsid C.fsid_t 128 | 129 | // Sockets 130 | 131 | type RawSockaddrInet4 C.struct_sockaddr_in 132 | 133 | type RawSockaddrInet6 C.struct_sockaddr_in6 134 | 135 | type RawSockaddrUnix C.struct_sockaddr_un 136 | 137 | type RawSockaddrDatalink C.struct_sockaddr_dl 138 | 139 | type RawSockaddr C.struct_sockaddr 140 | 141 | type RawSockaddrAny C.struct_sockaddr_any 142 | 143 | type _Socklen C.socklen_t 144 | 145 | type Linger C.struct_linger 146 | 147 | type Iovec C.struct_iovec 148 | 149 | type IPMreq C.struct_ip_mreq 150 | 151 | type IPv6Mreq C.struct_ipv6_mreq 152 | 153 | type Msghdr C.struct_msghdr 154 | 155 | type Cmsghdr C.struct_cmsghdr 156 | 157 | type Inet6Pktinfo C.struct_in6_pktinfo 158 | 159 | type IPv6MTUInfo C.struct_ip6_mtuinfo 160 | 161 | type ICMPv6Filter C.struct_icmp6_filter 162 | 163 | const ( 164 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 165 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 166 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 167 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 168 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 169 | SizeofLinger = C.sizeof_struct_linger 170 | SizeofIPMreq = C.sizeof_struct_ip_mreq 171 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 172 | SizeofMsghdr = C.sizeof_struct_msghdr 173 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 174 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 175 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 176 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 177 | ) 178 | 179 | // Ptrace requests 180 | 181 | const ( 182 | PTRACE_TRACEME = C.PT_TRACE_ME 183 | PTRACE_CONT = C.PT_CONTINUE 184 | PTRACE_KILL = C.PT_KILL 185 | ) 186 | 187 | // Events (kqueue, kevent) 188 | 189 | type Kevent_t C.struct_kevent 190 | 191 | // Select 192 | 193 | type FdSet C.fd_set 194 | 195 | // Routing and interface messages 196 | 197 | const ( 198 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 199 | SizeofIfData = C.sizeof_struct_if_data 200 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 201 | SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr 202 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 203 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 204 | ) 205 | 206 | type IfMsghdr C.struct_if_msghdr 207 | 208 | type IfData C.struct_if_data 209 | 210 | type IfaMsghdr C.struct_ifa_msghdr 211 | 212 | type IfAnnounceMsghdr C.struct_if_announcemsghdr 213 | 214 | type RtMsghdr C.struct_rt_msghdr 215 | 216 | type RtMetrics C.struct_rt_metrics 217 | 218 | type Mclpool C.struct_mclpool 219 | 220 | // Berkeley packet filter 221 | 222 | const ( 223 | SizeofBpfVersion = C.sizeof_struct_bpf_version 224 | SizeofBpfStat = C.sizeof_struct_bpf_stat 225 | SizeofBpfProgram = C.sizeof_struct_bpf_program 226 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 227 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 228 | ) 229 | 230 | type BpfVersion C.struct_bpf_version 231 | 232 | type BpfStat C.struct_bpf_stat 233 | 234 | type BpfProgram C.struct_bpf_program 235 | 236 | type BpfInsn C.struct_bpf_insn 237 | 238 | type BpfHdr C.struct_bpf_hdr 239 | 240 | type BpfTimeval C.struct_bpf_timeval 241 | 242 | // Terminal handling 243 | 244 | type Termios C.struct_termios 245 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/types_solaris.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 ignore 6 | 7 | /* 8 | Input to cgo -godefs. See also mkerrors.sh and mkall.sh 9 | */ 10 | 11 | // +godefs map struct_in_addr [4]byte /* in_addr */ 12 | // +godefs map struct_in6_addr [16]byte /* in6_addr */ 13 | 14 | package unix 15 | 16 | /* 17 | #define KERNEL 18 | // These defines ensure that builds done on newer versions of Solaris are 19 | // backwards-compatible with older versions of Solaris and 20 | // OpenSolaris-based derivatives. 21 | #define __USE_SUNOS_SOCKETS__ // msghdr 22 | #define __USE_LEGACY_PROTOTYPES__ // iovec 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | 56 | enum { 57 | sizeofPtr = sizeof(void*), 58 | }; 59 | 60 | union sockaddr_all { 61 | struct sockaddr s1; // this one gets used for fields 62 | struct sockaddr_in s2; // these pad it out 63 | struct sockaddr_in6 s3; 64 | struct sockaddr_un s4; 65 | struct sockaddr_dl s5; 66 | }; 67 | 68 | struct sockaddr_any { 69 | struct sockaddr addr; 70 | char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; 71 | }; 72 | 73 | */ 74 | import "C" 75 | 76 | // Machine characteristics; for internal use. 77 | 78 | const ( 79 | sizeofPtr = C.sizeofPtr 80 | sizeofShort = C.sizeof_short 81 | sizeofInt = C.sizeof_int 82 | sizeofLong = C.sizeof_long 83 | sizeofLongLong = C.sizeof_longlong 84 | PathMax = C.PATH_MAX 85 | MaxHostNameLen = C.MAXHOSTNAMELEN 86 | ) 87 | 88 | // Basic types 89 | 90 | type ( 91 | _C_short C.short 92 | _C_int C.int 93 | _C_long C.long 94 | _C_long_long C.longlong 95 | ) 96 | 97 | // Time 98 | 99 | type Timespec C.struct_timespec 100 | 101 | type Timeval C.struct_timeval 102 | 103 | type Timeval32 C.struct_timeval32 104 | 105 | type Tms C.struct_tms 106 | 107 | type Utimbuf C.struct_utimbuf 108 | 109 | // Processes 110 | 111 | type Rusage C.struct_rusage 112 | 113 | type Rlimit C.struct_rlimit 114 | 115 | type _Gid_t C.gid_t 116 | 117 | // Files 118 | 119 | const ( // Directory mode bits 120 | S_IFMT = C.S_IFMT 121 | S_IFIFO = C.S_IFIFO 122 | S_IFCHR = C.S_IFCHR 123 | S_IFDIR = C.S_IFDIR 124 | S_IFBLK = C.S_IFBLK 125 | S_IFREG = C.S_IFREG 126 | S_IFLNK = C.S_IFLNK 127 | S_IFSOCK = C.S_IFSOCK 128 | S_ISUID = C.S_ISUID 129 | S_ISGID = C.S_ISGID 130 | S_ISVTX = C.S_ISVTX 131 | S_IRUSR = C.S_IRUSR 132 | S_IWUSR = C.S_IWUSR 133 | S_IXUSR = C.S_IXUSR 134 | ) 135 | 136 | type Stat_t C.struct_stat 137 | 138 | type Flock_t C.struct_flock 139 | 140 | type Dirent C.struct_dirent 141 | 142 | // Sockets 143 | 144 | type RawSockaddrInet4 C.struct_sockaddr_in 145 | 146 | type RawSockaddrInet6 C.struct_sockaddr_in6 147 | 148 | type RawSockaddrUnix C.struct_sockaddr_un 149 | 150 | type RawSockaddrDatalink C.struct_sockaddr_dl 151 | 152 | type RawSockaddr C.struct_sockaddr 153 | 154 | type RawSockaddrAny C.struct_sockaddr_any 155 | 156 | type _Socklen C.socklen_t 157 | 158 | type Linger C.struct_linger 159 | 160 | type Iovec C.struct_iovec 161 | 162 | type IPMreq C.struct_ip_mreq 163 | 164 | type IPv6Mreq C.struct_ipv6_mreq 165 | 166 | type Msghdr C.struct_msghdr 167 | 168 | type Cmsghdr C.struct_cmsghdr 169 | 170 | type Inet6Pktinfo C.struct_in6_pktinfo 171 | 172 | type IPv6MTUInfo C.struct_ip6_mtuinfo 173 | 174 | type ICMPv6Filter C.struct_icmp6_filter 175 | 176 | const ( 177 | SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in 178 | SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 179 | SizeofSockaddrAny = C.sizeof_struct_sockaddr_any 180 | SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un 181 | SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl 182 | SizeofLinger = C.sizeof_struct_linger 183 | SizeofIPMreq = C.sizeof_struct_ip_mreq 184 | SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq 185 | SizeofMsghdr = C.sizeof_struct_msghdr 186 | SizeofCmsghdr = C.sizeof_struct_cmsghdr 187 | SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo 188 | SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo 189 | SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter 190 | ) 191 | 192 | // Select 193 | 194 | type FdSet C.fd_set 195 | 196 | // Misc 197 | 198 | type Utsname C.struct_utsname 199 | 200 | type Ustat_t C.struct_ustat 201 | 202 | const ( 203 | AT_FDCWD = C.AT_FDCWD 204 | AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW 205 | AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW 206 | AT_REMOVEDIR = C.AT_REMOVEDIR 207 | AT_EACCESS = C.AT_EACCESS 208 | ) 209 | 210 | // Routing and interface messages 211 | 212 | const ( 213 | SizeofIfMsghdr = C.sizeof_struct_if_msghdr 214 | SizeofIfData = C.sizeof_struct_if_data 215 | SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr 216 | SizeofRtMsghdr = C.sizeof_struct_rt_msghdr 217 | SizeofRtMetrics = C.sizeof_struct_rt_metrics 218 | ) 219 | 220 | type IfMsghdr C.struct_if_msghdr 221 | 222 | type IfData C.struct_if_data 223 | 224 | type IfaMsghdr C.struct_ifa_msghdr 225 | 226 | type RtMsghdr C.struct_rt_msghdr 227 | 228 | type RtMetrics C.struct_rt_metrics 229 | 230 | // Berkeley packet filter 231 | 232 | const ( 233 | SizeofBpfVersion = C.sizeof_struct_bpf_version 234 | SizeofBpfStat = C.sizeof_struct_bpf_stat 235 | SizeofBpfProgram = C.sizeof_struct_bpf_program 236 | SizeofBpfInsn = C.sizeof_struct_bpf_insn 237 | SizeofBpfHdr = C.sizeof_struct_bpf_hdr 238 | ) 239 | 240 | type BpfVersion C.struct_bpf_version 241 | 242 | type BpfStat C.struct_bpf_stat 243 | 244 | type BpfProgram C.struct_bpf_program 245 | 246 | type BpfInsn C.struct_bpf_insn 247 | 248 | type BpfTimeval C.struct_bpf_timeval 249 | 250 | type BpfHdr C.struct_bpf_hdr 251 | 252 | // sysconf information 253 | 254 | const _SC_PAGESIZE = C._SC_PAGESIZE 255 | 256 | // Terminal handling 257 | 258 | type Termios C.struct_termios 259 | 260 | type Termio C.struct_termio 261 | 262 | type Winsize C.struct_winsize 263 | -------------------------------------------------------------------------------- /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/golang.org/x/sys/unix/ztypes_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_netbsd.go 3 | 4 | // +build 386,netbsd 5 | 6 | package unix 7 | 8 | const ( 9 | sizeofPtr = 0x4 10 | sizeofShort = 0x2 11 | sizeofInt = 0x4 12 | sizeofLong = 0x4 13 | sizeofLongLong = 0x8 14 | ) 15 | 16 | type ( 17 | _C_short int16 18 | _C_int int32 19 | _C_long int32 20 | _C_long_long int64 21 | ) 22 | 23 | type Timespec struct { 24 | Sec int64 25 | Nsec int32 26 | } 27 | 28 | type Timeval struct { 29 | Sec int64 30 | Usec int32 31 | } 32 | 33 | type Rusage struct { 34 | Utime Timeval 35 | Stime Timeval 36 | Maxrss int32 37 | Ixrss int32 38 | Idrss int32 39 | Isrss int32 40 | Minflt int32 41 | Majflt int32 42 | Nswap int32 43 | Inblock int32 44 | Oublock int32 45 | Msgsnd int32 46 | Msgrcv int32 47 | Nsignals int32 48 | Nvcsw int32 49 | Nivcsw int32 50 | } 51 | 52 | type Rlimit struct { 53 | Cur uint64 54 | Max uint64 55 | } 56 | 57 | type _Gid_t uint32 58 | 59 | type Stat_t struct { 60 | Dev uint64 61 | Mode uint32 62 | Ino uint64 63 | Nlink uint32 64 | Uid uint32 65 | Gid uint32 66 | Rdev uint64 67 | Atimespec Timespec 68 | Mtimespec Timespec 69 | Ctimespec Timespec 70 | Birthtimespec Timespec 71 | Size int64 72 | Blocks int64 73 | Blksize uint32 74 | Flags uint32 75 | Gen uint32 76 | Spare [2]uint32 77 | } 78 | 79 | type Statfs_t [0]byte 80 | 81 | type Flock_t struct { 82 | Start int64 83 | Len int64 84 | Pid int32 85 | Type int16 86 | Whence int16 87 | } 88 | 89 | type Dirent struct { 90 | Fileno uint64 91 | Reclen uint16 92 | Namlen uint16 93 | Type uint8 94 | Name [512]int8 95 | Pad_cgo_0 [3]byte 96 | } 97 | 98 | type Fsid struct { 99 | X__fsid_val [2]int32 100 | } 101 | 102 | type RawSockaddrInet4 struct { 103 | Len uint8 104 | Family uint8 105 | Port uint16 106 | Addr [4]byte /* in_addr */ 107 | Zero [8]int8 108 | } 109 | 110 | type RawSockaddrInet6 struct { 111 | Len uint8 112 | Family uint8 113 | Port uint16 114 | Flowinfo uint32 115 | Addr [16]byte /* in6_addr */ 116 | Scope_id uint32 117 | } 118 | 119 | type RawSockaddrUnix struct { 120 | Len uint8 121 | Family uint8 122 | Path [104]int8 123 | } 124 | 125 | type RawSockaddrDatalink struct { 126 | Len uint8 127 | Family uint8 128 | Index uint16 129 | Type uint8 130 | Nlen uint8 131 | Alen uint8 132 | Slen uint8 133 | Data [12]int8 134 | } 135 | 136 | type RawSockaddr struct { 137 | Len uint8 138 | Family uint8 139 | Data [14]int8 140 | } 141 | 142 | type RawSockaddrAny struct { 143 | Addr RawSockaddr 144 | Pad [92]int8 145 | } 146 | 147 | type _Socklen uint32 148 | 149 | type Linger struct { 150 | Onoff int32 151 | Linger int32 152 | } 153 | 154 | type Iovec struct { 155 | Base *byte 156 | Len uint32 157 | } 158 | 159 | type IPMreq struct { 160 | Multiaddr [4]byte /* in_addr */ 161 | Interface [4]byte /* in_addr */ 162 | } 163 | 164 | type IPv6Mreq struct { 165 | Multiaddr [16]byte /* in6_addr */ 166 | Interface uint32 167 | } 168 | 169 | type Msghdr struct { 170 | Name *byte 171 | Namelen uint32 172 | Iov *Iovec 173 | Iovlen int32 174 | Control *byte 175 | Controllen uint32 176 | Flags int32 177 | } 178 | 179 | type Cmsghdr struct { 180 | Len uint32 181 | Level int32 182 | Type int32 183 | } 184 | 185 | type Inet6Pktinfo struct { 186 | Addr [16]byte /* in6_addr */ 187 | Ifindex uint32 188 | } 189 | 190 | type IPv6MTUInfo struct { 191 | Addr RawSockaddrInet6 192 | Mtu uint32 193 | } 194 | 195 | type ICMPv6Filter struct { 196 | Filt [8]uint32 197 | } 198 | 199 | const ( 200 | SizeofSockaddrInet4 = 0x10 201 | SizeofSockaddrInet6 = 0x1c 202 | SizeofSockaddrAny = 0x6c 203 | SizeofSockaddrUnix = 0x6a 204 | SizeofSockaddrDatalink = 0x14 205 | SizeofLinger = 0x8 206 | SizeofIPMreq = 0x8 207 | SizeofIPv6Mreq = 0x14 208 | SizeofMsghdr = 0x1c 209 | SizeofCmsghdr = 0xc 210 | SizeofInet6Pktinfo = 0x14 211 | SizeofIPv6MTUInfo = 0x20 212 | SizeofICMPv6Filter = 0x20 213 | ) 214 | 215 | const ( 216 | PTRACE_TRACEME = 0x0 217 | PTRACE_CONT = 0x7 218 | PTRACE_KILL = 0x8 219 | ) 220 | 221 | type Kevent_t struct { 222 | Ident uint32 223 | Filter uint32 224 | Flags uint32 225 | Fflags uint32 226 | Data int64 227 | Udata int32 228 | } 229 | 230 | type FdSet struct { 231 | Bits [8]uint32 232 | } 233 | 234 | const ( 235 | SizeofIfMsghdr = 0x98 236 | SizeofIfData = 0x84 237 | SizeofIfaMsghdr = 0x18 238 | SizeofIfAnnounceMsghdr = 0x18 239 | SizeofRtMsghdr = 0x78 240 | SizeofRtMetrics = 0x50 241 | ) 242 | 243 | type IfMsghdr struct { 244 | Msglen uint16 245 | Version uint8 246 | Type uint8 247 | Addrs int32 248 | Flags int32 249 | Index uint16 250 | Pad_cgo_0 [2]byte 251 | Data IfData 252 | Pad_cgo_1 [4]byte 253 | } 254 | 255 | type IfData struct { 256 | Type uint8 257 | Addrlen uint8 258 | Hdrlen uint8 259 | Pad_cgo_0 [1]byte 260 | Link_state int32 261 | Mtu uint64 262 | Metric uint64 263 | Baudrate uint64 264 | Ipackets uint64 265 | Ierrors uint64 266 | Opackets uint64 267 | Oerrors uint64 268 | Collisions uint64 269 | Ibytes uint64 270 | Obytes uint64 271 | Imcasts uint64 272 | Omcasts uint64 273 | Iqdrops uint64 274 | Noproto uint64 275 | Lastchange Timespec 276 | } 277 | 278 | type IfaMsghdr struct { 279 | Msglen uint16 280 | Version uint8 281 | Type uint8 282 | Addrs int32 283 | Flags int32 284 | Metric int32 285 | Index uint16 286 | Pad_cgo_0 [6]byte 287 | } 288 | 289 | type IfAnnounceMsghdr struct { 290 | Msglen uint16 291 | Version uint8 292 | Type uint8 293 | Index uint16 294 | Name [16]int8 295 | What uint16 296 | } 297 | 298 | type RtMsghdr struct { 299 | Msglen uint16 300 | Version uint8 301 | Type uint8 302 | Index uint16 303 | Pad_cgo_0 [2]byte 304 | Flags int32 305 | Addrs int32 306 | Pid int32 307 | Seq int32 308 | Errno int32 309 | Use int32 310 | Inits int32 311 | Pad_cgo_1 [4]byte 312 | Rmx RtMetrics 313 | } 314 | 315 | type RtMetrics struct { 316 | Locks uint64 317 | Mtu uint64 318 | Hopcount uint64 319 | Recvpipe uint64 320 | Sendpipe uint64 321 | Ssthresh uint64 322 | Rtt uint64 323 | Rttvar uint64 324 | Expire int64 325 | Pksent int64 326 | } 327 | 328 | type Mclpool [0]byte 329 | 330 | const ( 331 | SizeofBpfVersion = 0x4 332 | SizeofBpfStat = 0x80 333 | SizeofBpfProgram = 0x8 334 | SizeofBpfInsn = 0x8 335 | SizeofBpfHdr = 0x14 336 | ) 337 | 338 | type BpfVersion struct { 339 | Major uint16 340 | Minor uint16 341 | } 342 | 343 | type BpfStat struct { 344 | Recv uint64 345 | Drop uint64 346 | Capt uint64 347 | Padding [13]uint64 348 | } 349 | 350 | type BpfProgram struct { 351 | Len uint32 352 | Insns *BpfInsn 353 | } 354 | 355 | type BpfInsn struct { 356 | Code uint16 357 | Jt uint8 358 | Jf uint8 359 | K uint32 360 | } 361 | 362 | type BpfHdr struct { 363 | Tstamp BpfTimeval 364 | Caplen uint32 365 | Datalen uint32 366 | Hdrlen uint16 367 | Pad_cgo_0 [2]byte 368 | } 369 | 370 | type BpfTimeval struct { 371 | Sec int32 372 | Usec int32 373 | } 374 | 375 | type Termios struct { 376 | Iflag uint32 377 | Oflag uint32 378 | Cflag uint32 379 | Lflag uint32 380 | Cc [20]uint8 381 | Ispeed int32 382 | Ospeed int32 383 | } 384 | 385 | type Sysctlnode struct { 386 | Flags uint32 387 | Num int32 388 | Name [32]int8 389 | Ver uint32 390 | X__rsvd uint32 391 | Un [16]byte 392 | X_sysctl_size [8]byte 393 | X_sysctl_func [8]byte 394 | X_sysctl_parent [8]byte 395 | X_sysctl_desc [8]byte 396 | } 397 | -------------------------------------------------------------------------------- /version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | var ( 4 | // Version should be updated by hand at each release 5 | Version = "0.2.0" 6 | 7 | // GITCOMMIT will be overwritten automatically by the build system 8 | GitCommit = "HEAD" 9 | ) 10 | 11 | func FullVersion() string { 12 | return Version + " (" + GitCommit + ")" 13 | } 14 | --------------------------------------------------------------------------------