├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── chain └── chain.go ├── config └── unwrappers.json ├── go.mod ├── go.sum ├── main.go ├── queryparam └── queryparam.go ├── templates └── index.html ├── theunwrapper.png ├── unwrap └── unwrap.go └── vendor ├── github.com ├── deckarep │ └── golang-set │ │ └── v2 │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── README.md │ │ ├── iterator.go │ │ ├── new_improved.jpeg │ │ ├── set.go │ │ ├── sorted.go │ │ ├── threadsafe.go │ │ └── threadunsafe.go ├── mattn │ ├── go-colorable │ │ ├── LICENSE │ │ ├── README.md │ │ ├── colorable_appengine.go │ │ ├── colorable_others.go │ │ ├── colorable_windows.go │ │ ├── go.test.sh │ │ └── noncolorable.go │ └── go-isatty │ │ ├── LICENSE │ │ ├── README.md │ │ ├── doc.go │ │ ├── go.test.sh │ │ ├── isatty_bsd.go │ │ ├── isatty_others.go │ │ ├── isatty_plan9.go │ │ ├── isatty_solaris.go │ │ ├── isatty_tcgets.go │ │ └── isatty_windows.go └── rs │ └── zerolog │ ├── .gitignore │ ├── CNAME │ ├── LICENSE │ ├── README.md │ ├── _config.yml │ ├── array.go │ ├── console.go │ ├── context.go │ ├── ctx.go │ ├── encoder.go │ ├── encoder_cbor.go │ ├── encoder_json.go │ ├── event.go │ ├── fields.go │ ├── globals.go │ ├── go112.go │ ├── hook.go │ ├── internal │ ├── cbor │ │ ├── README.md │ │ ├── base.go │ │ ├── cbor.go │ │ ├── decode_stream.go │ │ ├── string.go │ │ ├── time.go │ │ └── types.go │ └── json │ │ ├── base.go │ │ ├── bytes.go │ │ ├── string.go │ │ ├── time.go │ │ └── types.go │ ├── log.go │ ├── log │ └── log.go │ ├── not_go112.go │ ├── pretty.png │ ├── sampler.go │ ├── syslog.go │ └── writer.go ├── golang.org └── x │ └── sys │ ├── LICENSE │ ├── PATENTS │ └── unix │ ├── .gitignore │ ├── README.md │ ├── affinity_linux.go │ ├── aliases.go │ ├── asm_aix_ppc64.s │ ├── asm_bsd_386.s │ ├── asm_bsd_amd64.s │ ├── asm_bsd_arm.s │ ├── asm_bsd_arm64.s │ ├── asm_bsd_ppc64.s │ ├── asm_bsd_riscv64.s │ ├── asm_linux_386.s │ ├── asm_linux_amd64.s │ ├── asm_linux_arm.s │ ├── asm_linux_arm64.s │ ├── asm_linux_loong64.s │ ├── asm_linux_mips64x.s │ ├── asm_linux_mipsx.s │ ├── asm_linux_ppc64x.s │ ├── asm_linux_riscv64.s │ ├── asm_linux_s390x.s │ ├── asm_openbsd_mips64.s │ ├── asm_solaris_amd64.s │ ├── asm_zos_s390x.s │ ├── bluetooth_linux.go │ ├── cap_freebsd.go │ ├── constants.go │ ├── dev_aix_ppc.go │ ├── dev_aix_ppc64.go │ ├── dev_darwin.go │ ├── dev_dragonfly.go │ ├── dev_freebsd.go │ ├── dev_linux.go │ ├── dev_netbsd.go │ ├── dev_openbsd.go │ ├── dev_zos.go │ ├── dirent.go │ ├── endian_big.go │ ├── endian_little.go │ ├── env_unix.go │ ├── epoll_zos.go │ ├── fcntl.go │ ├── fcntl_darwin.go │ ├── fcntl_linux_32bit.go │ ├── fdset.go │ ├── fstatfs_zos.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── ifreq_linux.go │ ├── ioctl.go │ ├── ioctl_linux.go │ ├── ioctl_zos.go │ ├── mkall.sh │ ├── mkerrors.sh │ ├── pagesize_unix.go │ ├── pledge_openbsd.go │ ├── ptrace_darwin.go │ ├── ptrace_ios.go │ ├── race.go │ ├── race0.go │ ├── readdirent_getdents.go │ ├── readdirent_getdirentries.go │ ├── sockcmsg_dragonfly.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── sockcmsg_unix_other.go │ ├── syscall.go │ ├── syscall_aix.go │ ├── syscall_aix_ppc.go │ ├── syscall_aix_ppc64.go │ ├── syscall_bsd.go │ ├── syscall_darwin.go │ ├── syscall_darwin_amd64.go │ ├── syscall_darwin_arm64.go │ ├── syscall_darwin_libSystem.go │ ├── syscall_dragonfly.go │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_freebsd_arm64.go │ ├── syscall_freebsd_riscv64.go │ ├── syscall_hurd.go │ ├── syscall_hurd_386.go │ ├── syscall_illumos.go │ ├── syscall_linux.go │ ├── syscall_linux_386.go │ ├── syscall_linux_alarm.go │ ├── syscall_linux_amd64.go │ ├── syscall_linux_amd64_gc.go │ ├── syscall_linux_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_gc.go │ ├── syscall_linux_gc_386.go │ ├── syscall_linux_gc_arm.go │ ├── syscall_linux_gccgo_386.go │ ├── syscall_linux_gccgo_arm.go │ ├── syscall_linux_loong64.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_mipsx.go │ ├── syscall_linux_ppc.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_riscv64.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_netbsd_arm64.go │ ├── syscall_openbsd.go │ ├── syscall_openbsd_386.go │ ├── syscall_openbsd_amd64.go │ ├── syscall_openbsd_arm.go │ ├── syscall_openbsd_arm64.go │ ├── syscall_openbsd_libc.go │ ├── syscall_openbsd_mips64.go │ ├── syscall_openbsd_ppc64.go │ ├── syscall_openbsd_riscv64.go │ ├── syscall_solaris.go │ ├── syscall_solaris_amd64.go │ ├── syscall_unix.go │ ├── syscall_unix_gc.go │ ├── syscall_unix_gc_ppc64x.go │ ├── syscall_zos_s390x.go │ ├── sysvshm_linux.go │ ├── sysvshm_unix.go │ ├── sysvshm_unix_other.go │ ├── timestruct.go │ ├── unveil_openbsd.go │ ├── xattr_bsd.go │ ├── zerrors_aix_ppc.go │ ├── zerrors_aix_ppc64.go │ ├── zerrors_darwin_amd64.go │ ├── zerrors_darwin_arm64.go │ ├── zerrors_dragonfly_amd64.go │ ├── zerrors_freebsd_386.go │ ├── zerrors_freebsd_amd64.go │ ├── zerrors_freebsd_arm.go │ ├── zerrors_freebsd_arm64.go │ ├── zerrors_freebsd_riscv64.go │ ├── zerrors_linux.go │ ├── zerrors_linux_386.go │ ├── zerrors_linux_amd64.go │ ├── zerrors_linux_arm.go │ ├── zerrors_linux_arm64.go │ ├── zerrors_linux_loong64.go │ ├── zerrors_linux_mips.go │ ├── zerrors_linux_mips64.go │ ├── zerrors_linux_mips64le.go │ ├── zerrors_linux_mipsle.go │ ├── zerrors_linux_ppc.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_linux_riscv64.go │ ├── zerrors_linux_s390x.go │ ├── zerrors_linux_sparc64.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_netbsd_arm64.go │ ├── zerrors_openbsd_386.go │ ├── zerrors_openbsd_amd64.go │ ├── zerrors_openbsd_arm.go │ ├── zerrors_openbsd_arm64.go │ ├── zerrors_openbsd_mips64.go │ ├── zerrors_openbsd_ppc64.go │ ├── zerrors_openbsd_riscv64.go │ ├── zerrors_solaris_amd64.go │ ├── zerrors_zos_s390x.go │ ├── zptrace_armnn_linux.go │ ├── zptrace_linux_arm64.go │ ├── zptrace_mipsnn_linux.go │ ├── zptrace_mipsnnle_linux.go │ ├── zptrace_x86_linux.go │ ├── zsyscall_aix_ppc.go │ ├── zsyscall_aix_ppc64.go │ ├── zsyscall_aix_ppc64_gc.go │ ├── zsyscall_aix_ppc64_gccgo.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_amd64.s │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_darwin_arm64.s │ ├── zsyscall_dragonfly_amd64.go │ ├── zsyscall_freebsd_386.go │ ├── zsyscall_freebsd_amd64.go │ ├── zsyscall_freebsd_arm.go │ ├── zsyscall_freebsd_arm64.go │ ├── zsyscall_freebsd_riscv64.go │ ├── zsyscall_illumos_amd64.go │ ├── zsyscall_linux.go │ ├── zsyscall_linux_386.go │ ├── zsyscall_linux_amd64.go │ ├── zsyscall_linux_arm.go │ ├── zsyscall_linux_arm64.go │ ├── zsyscall_linux_loong64.go │ ├── zsyscall_linux_mips.go │ ├── zsyscall_linux_mips64.go │ ├── zsyscall_linux_mips64le.go │ ├── zsyscall_linux_mipsle.go │ ├── zsyscall_linux_ppc.go │ ├── zsyscall_linux_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_linux_riscv64.go │ ├── zsyscall_linux_s390x.go │ ├── zsyscall_linux_sparc64.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_netbsd_arm64.go │ ├── zsyscall_openbsd_386.go │ ├── zsyscall_openbsd_386.s │ ├── zsyscall_openbsd_amd64.go │ ├── zsyscall_openbsd_amd64.s │ ├── zsyscall_openbsd_arm.go │ ├── zsyscall_openbsd_arm.s │ ├── zsyscall_openbsd_arm64.go │ ├── zsyscall_openbsd_arm64.s │ ├── zsyscall_openbsd_mips64.go │ ├── zsyscall_openbsd_mips64.s │ ├── zsyscall_openbsd_ppc64.go │ ├── zsyscall_openbsd_ppc64.s │ ├── zsyscall_openbsd_riscv64.go │ ├── zsyscall_openbsd_riscv64.s │ ├── zsyscall_solaris_amd64.go │ ├── zsyscall_zos_s390x.go │ ├── zsysctl_openbsd_386.go │ ├── zsysctl_openbsd_amd64.go │ ├── zsysctl_openbsd_arm.go │ ├── zsysctl_openbsd_arm64.go │ ├── zsysctl_openbsd_mips64.go │ ├── zsysctl_openbsd_ppc64.go │ ├── zsysctl_openbsd_riscv64.go │ ├── zsysnum_darwin_amd64.go │ ├── zsysnum_darwin_arm64.go │ ├── zsysnum_dragonfly_amd64.go │ ├── zsysnum_freebsd_386.go │ ├── zsysnum_freebsd_amd64.go │ ├── zsysnum_freebsd_arm.go │ ├── zsysnum_freebsd_arm64.go │ ├── zsysnum_freebsd_riscv64.go │ ├── zsysnum_linux_386.go │ ├── zsysnum_linux_amd64.go │ ├── zsysnum_linux_arm.go │ ├── zsysnum_linux_arm64.go │ ├── zsysnum_linux_loong64.go │ ├── zsysnum_linux_mips.go │ ├── zsysnum_linux_mips64.go │ ├── zsysnum_linux_mips64le.go │ ├── zsysnum_linux_mipsle.go │ ├── zsysnum_linux_ppc.go │ ├── zsysnum_linux_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_linux_riscv64.go │ ├── zsysnum_linux_s390x.go │ ├── zsysnum_linux_sparc64.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_netbsd_arm64.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_openbsd_arm.go │ ├── zsysnum_openbsd_arm64.go │ ├── zsysnum_openbsd_mips64.go │ ├── zsysnum_openbsd_ppc64.go │ ├── zsysnum_openbsd_riscv64.go │ ├── zsysnum_zos_s390x.go │ ├── ztypes_aix_ppc.go │ ├── ztypes_aix_ppc64.go │ ├── ztypes_darwin_amd64.go │ ├── ztypes_darwin_arm64.go │ ├── ztypes_dragonfly_amd64.go │ ├── ztypes_freebsd_386.go │ ├── ztypes_freebsd_amd64.go │ ├── ztypes_freebsd_arm.go │ ├── ztypes_freebsd_arm64.go │ ├── ztypes_freebsd_riscv64.go │ ├── ztypes_linux.go │ ├── ztypes_linux_386.go │ ├── ztypes_linux_amd64.go │ ├── ztypes_linux_arm.go │ ├── ztypes_linux_arm64.go │ ├── ztypes_linux_loong64.go │ ├── ztypes_linux_mips.go │ ├── ztypes_linux_mips64.go │ ├── ztypes_linux_mips64le.go │ ├── ztypes_linux_mipsle.go │ ├── ztypes_linux_ppc.go │ ├── ztypes_linux_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_linux_riscv64.go │ ├── ztypes_linux_s390x.go │ ├── ztypes_linux_sparc64.go │ ├── ztypes_netbsd_386.go │ ├── ztypes_netbsd_amd64.go │ ├── ztypes_netbsd_arm.go │ ├── ztypes_netbsd_arm64.go │ ├── ztypes_openbsd_386.go │ ├── ztypes_openbsd_amd64.go │ ├── ztypes_openbsd_arm.go │ ├── ztypes_openbsd_arm64.go │ ├── ztypes_openbsd_mips64.go │ ├── ztypes_openbsd_ppc64.go │ ├── ztypes_openbsd_riscv64.go │ ├── ztypes_solaris_amd64.go │ └── ztypes_zos_s390x.go └── modules.txt /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.19 as builder 2 | RUN echo ${TARGETARCH} 3 | RUN mkdir -p /build 4 | COPY ./ /build/ 5 | WORKDIR /build/ 6 | 7 | FROM builder AS builder-amd64 8 | RUN env GOOS=linux GOARCH=amd64 make clean bin/theunwrapper 9 | 10 | FROM builder AS builder-arm64 11 | RUN env GOOS=linux GOARCH=arm64 make clean bin/theunwrapper 12 | 13 | FROM builder-${TARGETARCH} AS build 14 | 15 | FROM alpine:latest 16 | RUN apk add gcompat 17 | COPY --from=build /build/bin/theunwrapper /bin/theunwrapper 18 | ENTRYPOINT ["/bin/theunwrapper", "-log-format=pretty"] 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2023 Daniel Harper 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | run: bin/theunwrapper 2 | @@./bin/theunwrapper 3 | 4 | bin/theunwrapper: 5 | go build -o bin/theunwrapper . 6 | 7 | clean: 8 | rm -rf bin/* 9 | 10 | .PHONY: docker 11 | docker: 12 | docker buildx build --platform linux/arm64,linux/amd64 -f Dockerfile -t ${REGISTRY}/theunwrapper --push . 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Unwrapper 2 | 3 | Note, I wrote this in haste over a weekend so the code is not high quality and untested. 4 | 5 | See this blog post for more information: https://djharper.dev/post/2023/01/29/intercepting-t.co-links-using-dns-rewrites/ 6 | 7 | ## What 8 | 9 | A system that can walk short link services like t.co to get the underlying link. 10 | 11 | Can be used in conjunction with a reverse proxy that sets the `X-Forwarded-Host` header, and presents the user with a page with the cleaned link. 12 | 13 | ![Image](theunwrapper.png) 14 | 15 | ## Supports 16 | 17 | Mainly wrote this for t.co but also supports others, see config file here: https://github.com/djhworld/theunwrapper/blob/main/config/unwrappers.json 18 | 19 | ## This is dumb and stupid 20 | 21 | Can't argue with that. 22 | 23 | -------------------------------------------------------------------------------- /chain/chain.go: -------------------------------------------------------------------------------- 1 | package chain 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "net/http" 7 | "net/url" 8 | 9 | "github.com/djhworld/theunwrapper/queryparam" 10 | "github.com/djhworld/theunwrapper/unwrap" 11 | "github.com/rs/zerolog/log" 12 | ) 13 | 14 | var ( 15 | ErrNoUnwrapperFound = errors.New("no unwrapper found") 16 | ) 17 | 18 | func New(r *http.Request, unwrappers map[string]*unwrap.Unwrapper) (*ChainedUnwrapper, error) { 19 | var ( 20 | host string 21 | start *unwrap.Unwrapper 22 | ) 23 | 24 | host = r.Header.Get("X-Forwarded-Host") 25 | if host == "" { 26 | host = r.Host 27 | } 28 | 29 | if host != "" { 30 | start = unwrappers[host] 31 | if start == nil { 32 | return nil, ErrNoUnwrapperFound 33 | } else { 34 | log.Info().Msgf("using unwrapper for: %s", start.Host()) 35 | } 36 | } else { 37 | return nil, ErrNoUnwrapperFound 38 | } 39 | 40 | return &ChainedUnwrapper{ 41 | ur: r.URL, 42 | unwrapper: start, 43 | chain: []ChainEntry{}, 44 | unwrappers: unwrappers, 45 | visitList: make(map[string]struct{}), 46 | }, nil 47 | } 48 | 49 | // ChainEntry describes the transition from moving to one URL to the next, given 50 | // the unwrapper that was used 51 | type ChainEntry struct { 52 | From url.URL 53 | To url.URL 54 | Using unwrap.Unwrapper 55 | } 56 | 57 | type ChainedUnwrapper struct { 58 | ur *url.URL 59 | unwrapper *unwrap.Unwrapper 60 | chain []ChainEntry 61 | visitList map[string]struct{} 62 | unwrappers map[string]*unwrap.Unwrapper 63 | err error 64 | } 65 | 66 | // Err returns the last error set 67 | func (c *ChainedUnwrapper) Err() error { 68 | return c.err 69 | } 70 | 71 | // Err returns the currently set URL 72 | func (c *ChainedUnwrapper) Last() *url.URL { 73 | return c.ur 74 | } 75 | 76 | // Err returns a slice of ChainEntry structs that describe the 77 | // hops visited before finding the final URL 78 | func (c *ChainedUnwrapper) Visited() []ChainEntry { 79 | return c.chain 80 | } 81 | 82 | // Next will visit the next endpoint in the chain. 83 | // Returns false when the end of the chain is reached or if there is an error 84 | func (c *ChainedUnwrapper) Next() bool { 85 | // try to ensure we don't visit the same URL twice 86 | if _, ok := c.visitList[c.ur.String()]; ok { 87 | log.Error().Msg("cycle detected!") 88 | c.err = errors.New("cycle detetected") 89 | return false 90 | } 91 | 92 | var path string 93 | if allowedParams := c.unwrapper.PermittedQueryParams(); allowedParams.Cardinality() > 0 { 94 | newUr := queryparam.Permit(*c.ur, allowedParams) 95 | path = fmt.Sprintf("%s?%s", c.ur.Path[1:], newUr.RawQuery) 96 | } else { 97 | path = c.ur.Path[1:] 98 | } 99 | 100 | endpoint, result, err := c.unwrapper.Do(path) 101 | if err != nil { 102 | c.err = err 103 | return false 104 | } 105 | c.visitList[endpoint.String()] = struct{}{} 106 | 107 | if result != nil { 108 | c.chain = append(c.chain, ChainEntry{From: *endpoint, To: *result, Using: *c.unwrapper}) 109 | if r, ok := c.unwrappers[result.Host]; ok { 110 | c.unwrapper = r 111 | c.ur = result 112 | return true 113 | } 114 | } else { 115 | log.Error().Msg("failed to lookup!") 116 | c.unwrapper = nil 117 | return false 118 | } 119 | 120 | log.Debug().Msgf("finished, found: %s", result) 121 | 122 | c.unwrapper = nil 123 | c.ur = result 124 | return false 125 | } 126 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/djhworld/theunwrapper 2 | 3 | go 1.19 4 | 5 | require ( 6 | github.com/deckarep/golang-set/v2 v2.6.0 7 | github.com/rs/zerolog v1.29.0 8 | ) 9 | 10 | require ( 11 | github.com/mattn/go-colorable v0.1.13 // indirect 12 | github.com/mattn/go-isatty v0.0.17 // indirect 13 | golang.org/x/sys v0.4.0 // indirect 14 | ) 15 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= 2 | github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= 3 | github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= 4 | github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= 5 | github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= 6 | github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= 7 | github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= 8 | github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= 9 | github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= 10 | github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= 11 | github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= 12 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 13 | github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= 14 | github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= 15 | github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= 16 | golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 17 | golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 18 | golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 19 | golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= 20 | golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 21 | -------------------------------------------------------------------------------- /queryparam/queryparam.go: -------------------------------------------------------------------------------- 1 | package queryparam 2 | 3 | import ( 4 | "fmt" 5 | "net/url" 6 | "strings" 7 | 8 | mapset "github.com/deckarep/golang-set/v2" 9 | "github.com/rs/zerolog/log" 10 | ) 11 | 12 | var badQueryParams = map[string]struct{}{ 13 | "cmp": {}, 14 | "d_id": {}, 15 | "ref": {}, 16 | "source": {}, 17 | "utm": {}, 18 | "xtor": {}, 19 | "ito": {}, 20 | "ocid": {}, 21 | "ftag": {}, 22 | "linkid": {}, 23 | "cid": {}, 24 | "smid": {}, 25 | "smtyp": {}, 26 | "taid": {}, 27 | "uniqueid": {}, // seen on: cnet 28 | "servicetype": {}, // seen on: cnet 29 | "posttype": {}, // seen on: cnet 30 | "thetime": {}, // seen on: cnet 31 | "mkevt": {}, 32 | "siteid": {}, 33 | "fscl_post": {}, 34 | "norover": {}, 35 | "mkrid": {}, 36 | "mkcid": {}, 37 | "amdata": {}, 38 | "hash": {}, 39 | "cm_sp": {}, 40 | "tpcc": {}, // seen on: techcrunch 41 | "cmpid": {}, // seen on: bloomberg 42 | "reflink": {}, // seen on: Wall Street Journal/WSJ 43 | "dcmp": {}, // seen on: skynews 44 | "sh": {}, // seen on: forbes 45 | "tag": {}, // seen on: amazon 46 | "linkcode": {}, // seen on: amazon 47 | "ref_": {}, // seen on: amazon 48 | "psc": {}, // seen on: amazon 49 | "th": {}, // seen on: amazon 50 | "keywords": {}, // seen on: amazon 51 | "sprefix": {}, // seen on: amazon 52 | "sr": {}, // seen on: amazon 53 | "qid": {}, // seen on: amazon 54 | "crid": {}, // seen on: amazon 55 | } 56 | 57 | var badQueryParamPrefixes = []string{ 58 | "utm_", // google analytics? 59 | "at_", 60 | "ns_", 61 | "WT.", // seen on: gatesnotes 62 | } 63 | 64 | func Strip(ur url.URL) *url.URL { 65 | q := ur.Query() 66 | 67 | if len(q) > 0 { 68 | var stripCount int = 0 69 | for k, v := range q { 70 | msg := fmt.Sprintf("query parameter [%s=%s]", k, v) 71 | if _, ok := badQueryParams[strings.ToLower(k)]; ok { 72 | q.Del(k) 73 | msg = msg + "...stripping" 74 | stripCount++ 75 | log.Debug().Msg(msg) 76 | continue 77 | } 78 | 79 | var stripped bool 80 | for _, prefix := range badQueryParamPrefixes { 81 | if strings.HasPrefix(k, prefix) { 82 | q.Del(k) 83 | msg = msg + "...stripping" 84 | log.Debug().Msg(msg) 85 | stripCount++ 86 | stripped = true 87 | break 88 | } 89 | } 90 | if !stripped { 91 | log.Debug().Msg(msg + "...keeping") 92 | } 93 | } 94 | ur.RawQuery = q.Encode() 95 | log.Debug().Msgf("stripped %d query params from link", stripCount) 96 | } 97 | 98 | if ur.Fragment != "" { 99 | ur.Fragment = "" 100 | } 101 | if ur.RawFragment != "" { 102 | ur.RawFragment = "" 103 | } 104 | 105 | return &ur 106 | } 107 | 108 | // Permit will strip all query parameters except the ones in the allowlist 109 | func Permit(ur url.URL, allowlist mapset.Set[string]) *url.URL { 110 | q := ur.Query() 111 | 112 | if len(q) > 0 { 113 | var stripCount int = 0 114 | for k, _ := range q { 115 | if !allowlist.Contains(k) { 116 | q.Del(k) 117 | stripCount++ 118 | continue 119 | } 120 | } 121 | ur.RawQuery = q.Encode() 122 | log.Info().Msgf("stripped %d query params from link", stripCount) 123 | } 124 | 125 | if ur.Fragment != "" { 126 | ur.Fragment = "" 127 | } 128 | if ur.RawFragment != "" { 129 | ur.RawFragment = "" 130 | } 131 | 132 | return &ur 133 | } 134 | -------------------------------------------------------------------------------- /theunwrapper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djhworld/theunwrapper/93e92395e4a961b87e4e3c74326a0fb2aada077c/theunwrapper.png -------------------------------------------------------------------------------- /unwrap/unwrap.go: -------------------------------------------------------------------------------- 1 | package unwrap 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "fmt" 7 | "net" 8 | "net/http" 9 | "net/url" 10 | "time" 11 | 12 | mapset "github.com/deckarep/golang-set/v2" 13 | "github.com/rs/zerolog/log" 14 | ) 15 | 16 | type Unwrapper struct { 17 | host string 18 | description string 19 | permittedQueryParams mapset.Set[string] 20 | httpClient *http.Client 21 | } 22 | 23 | func New(host, description, upstreamDNSIPPort string, permittedQueryParams []string) *Unwrapper { 24 | // Setup dialer to use upstream DNS 25 | dialer := &net.Dialer{ 26 | Resolver: &net.Resolver{ 27 | PreferGo: true, 28 | Dial: func(ctx context.Context, network, address string) (net.Conn, error) { 29 | d := net.Dialer{ 30 | Timeout: time.Duration(5000) * time.Millisecond, 31 | } 32 | return d.DialContext(ctx, "udp", upstreamDNSIPPort) 33 | }, 34 | }, 35 | } 36 | 37 | transport := *(http.DefaultTransport.(*http.Transport)) 38 | transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) { 39 | return dialer.DialContext(ctx, network, addr) 40 | } 41 | 42 | client := http.Client{ 43 | Transport: &transport, 44 | CheckRedirect: func(req *http.Request, via []*http.Request) error { 45 | // Don't follow redirects 46 | return http.ErrUseLastResponse 47 | }, 48 | Timeout: 3 * time.Second, 49 | } 50 | 51 | permittedQPs := mapset.NewSet[string]() 52 | for _, qp := range permittedQueryParams { 53 | permittedQPs.Add(qp) 54 | } 55 | 56 | return &Unwrapper{ 57 | host: host, 58 | description: description, 59 | permittedQueryParams: permittedQPs, 60 | httpClient: &client, 61 | } 62 | } 63 | 64 | func (c *Unwrapper) Host() string { 65 | return c.host 66 | } 67 | 68 | func (c *Unwrapper) Description() string { 69 | return c.description 70 | } 71 | 72 | func (c *Unwrapper) PermittedQueryParams() mapset.Set[string] { 73 | return c.permittedQueryParams 74 | } 75 | 76 | // Do will perform a HEAD request for the given host and path, and check for the 77 | // Location header, if this exists the url contained within will be returned. 78 | func (c *Unwrapper) Do(path string) (*url.URL, *url.URL, error) { 79 | endpointStr := fmt.Sprintf("https://%s/%s", c.host, path) 80 | endpoint, _ := url.Parse(endpointStr) 81 | log.Info().Msgf("visiting: %s", endpoint.String()) 82 | 83 | // Testing the new HTTP client with the custom DNS resolver. 84 | resp, err := c.httpClient.Head(endpoint.String()) 85 | if err != nil { 86 | log.Error().Msgf("error doing HEAD on: %s err: %s", endpoint, err) 87 | return endpoint, nil, err 88 | } 89 | 90 | location, ok := resp.Header["Location"] 91 | 92 | if !ok { 93 | log.Error().Msgf("nil location header from: %s", endpoint.String()) 94 | return endpoint, nil, errors.New("no location header found") 95 | } else if len(location) == 0 { 96 | log.Error().Msgf("empty location header from: %s", endpoint.String()) 97 | return endpoint, nil, errors.New("location header empty") 98 | } 99 | 100 | out, err := url.Parse(location[0]) 101 | if err != nil { 102 | log.Error().Msgf("error parsing location url: %s from: %s", location[0], endpoint.String()) 103 | return endpoint, nil, errors.New("error parsing location url") 104 | } 105 | return endpoint, out, nil 106 | } 107 | -------------------------------------------------------------------------------- /vendor/github.com/deckarep/golang-set/v2/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | .idea -------------------------------------------------------------------------------- /vendor/github.com/deckarep/golang-set/v2/LICENSE: -------------------------------------------------------------------------------- 1 | Open Source Initiative OSI - The MIT License (MIT):Licensing 2 | 3 | The MIT License (MIT) 4 | Copyright (c) 2013 - 2022 Ralph Caraveo (deckarep@gmail.com) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to 9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10 | of the Software, and to permit persons to whom the Software is furnished to do 11 | so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. -------------------------------------------------------------------------------- /vendor/github.com/deckarep/golang-set/v2/iterator.go: -------------------------------------------------------------------------------- 1 | /* 2 | Open Source Initiative OSI - The MIT License (MIT):Licensing 3 | 4 | The MIT License (MIT) 5 | Copyright (c) 2013 - 2022 Ralph Caraveo (deckarep@gmail.com) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of 8 | this software and associated documentation files (the "Software"), to deal in 9 | the Software without restriction, including without limitation the rights to 10 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 11 | of the Software, and to permit persons to whom the Software is furnished to do 12 | so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | */ 25 | 26 | package mapset 27 | 28 | // Iterator defines an iterator over a Set, its C channel can be used to range over the Set's 29 | // elements. 30 | type Iterator[T comparable] struct { 31 | C <-chan T 32 | stop chan struct{} 33 | } 34 | 35 | // Stop stops the Iterator, no further elements will be received on C, C will be closed. 36 | func (i *Iterator[T]) Stop() { 37 | // Allows for Stop() to be called multiple times 38 | // (close() panics when called on already closed channel) 39 | defer func() { 40 | recover() 41 | }() 42 | 43 | close(i.stop) 44 | 45 | // Exhaust any remaining elements. 46 | for range i.C { 47 | } 48 | } 49 | 50 | // newIterator returns a new Iterator instance together with its item and stop channels. 51 | func newIterator[T comparable]() (*Iterator[T], chan<- T, <-chan struct{}) { 52 | itemChan := make(chan T) 53 | stopChan := make(chan struct{}) 54 | return &Iterator[T]{ 55 | C: itemChan, 56 | stop: stopChan, 57 | }, itemChan, stopChan 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/deckarep/golang-set/v2/new_improved.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djhworld/theunwrapper/93e92395e4a961b87e4e3c74326a0fb2aada077c/vendor/github.com/deckarep/golang-set/v2/new_improved.jpeg -------------------------------------------------------------------------------- /vendor/github.com/deckarep/golang-set/v2/sorted.go: -------------------------------------------------------------------------------- 1 | //go:build go1.21 2 | // +build go1.21 3 | 4 | /* 5 | Open Source Initiative OSI - The MIT License (MIT):Licensing 6 | 7 | The MIT License (MIT) 8 | Copyright (c) 2013 - 2023 Ralph Caraveo (deckarep@gmail.com) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy of 11 | this software and associated documentation files (the "Software"), to deal in 12 | the Software without restriction, including without limitation the rights to 13 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 14 | of the Software, and to permit persons to whom the Software is furnished to do 15 | so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | */ 28 | 29 | package mapset 30 | 31 | import ( 32 | "cmp" 33 | "slices" 34 | ) 35 | 36 | // Sorted returns a sorted slice of a set of any ordered type in ascending order. 37 | // When sorting floating-point numbers, NaNs are ordered before other values. 38 | func Sorted[E cmp.Ordered](set Set[E]) []E { 39 | s := set.ToSlice() 40 | slices.Sort(s) 41 | return s 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/README.md: -------------------------------------------------------------------------------- 1 | # go-colorable 2 | 3 | [![Build Status](https://github.com/mattn/go-colorable/workflows/test/badge.svg)](https://github.com/mattn/go-colorable/actions?query=workflow%3Atest) 4 | [![Codecov](https://codecov.io/gh/mattn/go-colorable/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-colorable) 5 | [![GoDoc](https://godoc.org/github.com/mattn/go-colorable?status.svg)](http://godoc.org/github.com/mattn/go-colorable) 6 | [![Go Report Card](https://goreportcard.com/badge/mattn/go-colorable)](https://goreportcard.com/report/mattn/go-colorable) 7 | 8 | Colorable writer for windows. 9 | 10 | For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.) 11 | This package is possible to handle escape sequence for ansi color on windows. 12 | 13 | ## Too Bad! 14 | 15 | ![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/bad.png) 16 | 17 | 18 | ## So Good! 19 | 20 | ![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/good.png) 21 | 22 | ## Usage 23 | 24 | ```go 25 | logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true}) 26 | logrus.SetOutput(colorable.NewColorableStdout()) 27 | 28 | logrus.Info("succeeded") 29 | logrus.Warn("not correct") 30 | logrus.Error("something error") 31 | logrus.Fatal("panic") 32 | ``` 33 | 34 | You can compile above code on non-windows OSs. 35 | 36 | ## Installation 37 | 38 | ``` 39 | $ go get github.com/mattn/go-colorable 40 | ``` 41 | 42 | # License 43 | 44 | MIT 45 | 46 | # Author 47 | 48 | Yasuhiro Matsumoto (a.k.a mattn) 49 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_appengine.go: -------------------------------------------------------------------------------- 1 | //go:build appengine 2 | // +build appengine 3 | 4 | package colorable 5 | 6 | import ( 7 | "io" 8 | "os" 9 | 10 | _ "github.com/mattn/go-isatty" 11 | ) 12 | 13 | // NewColorable returns new instance of Writer which handles escape sequence. 14 | func NewColorable(file *os.File) io.Writer { 15 | if file == nil { 16 | panic("nil passed instead of *os.File to NewColorable()") 17 | } 18 | 19 | return file 20 | } 21 | 22 | // NewColorableStdout returns new instance of Writer which handles escape sequence for stdout. 23 | func NewColorableStdout() io.Writer { 24 | return os.Stdout 25 | } 26 | 27 | // NewColorableStderr returns new instance of Writer which handles escape sequence for stderr. 28 | func NewColorableStderr() io.Writer { 29 | return os.Stderr 30 | } 31 | 32 | // EnableColorsStdout enable colors if possible. 33 | func EnableColorsStdout(enabled *bool) func() { 34 | if enabled != nil { 35 | *enabled = true 36 | } 37 | return func() {} 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_others.go: -------------------------------------------------------------------------------- 1 | //go:build !windows && !appengine 2 | // +build !windows,!appengine 3 | 4 | package colorable 5 | 6 | import ( 7 | "io" 8 | "os" 9 | 10 | _ "github.com/mattn/go-isatty" 11 | ) 12 | 13 | // NewColorable returns new instance of Writer which handles escape sequence. 14 | func NewColorable(file *os.File) io.Writer { 15 | if file == nil { 16 | panic("nil passed instead of *os.File to NewColorable()") 17 | } 18 | 19 | return file 20 | } 21 | 22 | // NewColorableStdout returns new instance of Writer which handles escape sequence for stdout. 23 | func NewColorableStdout() io.Writer { 24 | return os.Stdout 25 | } 26 | 27 | // NewColorableStderr returns new instance of Writer which handles escape sequence for stderr. 28 | func NewColorableStderr() io.Writer { 29 | return os.Stderr 30 | } 31 | 32 | // EnableColorsStdout enable colors if possible. 33 | func EnableColorsStdout(enabled *bool) func() { 34 | if enabled != nil { 35 | *enabled = true 36 | } 37 | return func() {} 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/go.test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | echo "" > coverage.txt 5 | 6 | for d in $(go list ./... | grep -v vendor); do 7 | go test -race -coverprofile=profile.out -covermode=atomic "$d" 8 | if [ -f profile.out ]; then 9 | cat profile.out >> coverage.txt 10 | rm profile.out 11 | fi 12 | done 13 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/noncolorable.go: -------------------------------------------------------------------------------- 1 | package colorable 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | ) 7 | 8 | // NonColorable holds writer but removes escape sequence. 9 | type NonColorable struct { 10 | out io.Writer 11 | } 12 | 13 | // NewNonColorable returns new instance of Writer which removes escape sequence from Writer. 14 | func NewNonColorable(w io.Writer) io.Writer { 15 | return &NonColorable{out: w} 16 | } 17 | 18 | // Write writes data on console 19 | func (w *NonColorable) Write(data []byte) (n int, err error) { 20 | er := bytes.NewReader(data) 21 | var plaintext bytes.Buffer 22 | loop: 23 | for { 24 | c1, err := er.ReadByte() 25 | if err != nil { 26 | plaintext.WriteTo(w.out) 27 | break loop 28 | } 29 | if c1 != 0x1b { 30 | plaintext.WriteByte(c1) 31 | continue 32 | } 33 | _, err = plaintext.WriteTo(w.out) 34 | if err != nil { 35 | break loop 36 | } 37 | c2, err := er.ReadByte() 38 | if err != nil { 39 | break loop 40 | } 41 | if c2 != 0x5b { 42 | continue 43 | } 44 | 45 | for { 46 | c, err := er.ReadByte() 47 | if err != nil { 48 | break loop 49 | } 50 | if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { 51 | break 52 | } 53 | } 54 | } 55 | 56 | return len(data), nil 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/README.md: -------------------------------------------------------------------------------- 1 | # go-isatty 2 | 3 | [![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty) 4 | [![Codecov](https://codecov.io/gh/mattn/go-isatty/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-isatty) 5 | [![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master) 6 | [![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty) 7 | 8 | isatty for golang 9 | 10 | ## Usage 11 | 12 | ```go 13 | package main 14 | 15 | import ( 16 | "fmt" 17 | "github.com/mattn/go-isatty" 18 | "os" 19 | ) 20 | 21 | func main() { 22 | if isatty.IsTerminal(os.Stdout.Fd()) { 23 | fmt.Println("Is Terminal") 24 | } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) { 25 | fmt.Println("Is Cygwin/MSYS2 Terminal") 26 | } else { 27 | fmt.Println("Is Not Terminal") 28 | } 29 | } 30 | ``` 31 | 32 | ## Installation 33 | 34 | ``` 35 | $ go get github.com/mattn/go-isatty 36 | ``` 37 | 38 | ## License 39 | 40 | MIT 41 | 42 | ## Author 43 | 44 | Yasuhiro Matsumoto (a.k.a mattn) 45 | 46 | ## Thanks 47 | 48 | * k-takata: base idea for IsCygwinTerminal 49 | 50 | https://github.com/k-takata/go-iscygpty 51 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/go.test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | echo "" > coverage.txt 5 | 6 | for d in $(go list ./... | grep -v vendor); do 7 | go test -race -coverprofile=profile.out -covermode=atomic "$d" 8 | if [ -f profile.out ]; then 9 | cat profile.out >> coverage.txt 10 | rm profile.out 11 | fi 12 | done 13 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | //go:build (darwin || freebsd || openbsd || netbsd || dragonfly || hurd) && !appengine 2 | // +build darwin freebsd openbsd netbsd dragonfly hurd 3 | // +build !appengine 4 | 5 | package isatty 6 | 7 | import "golang.org/x/sys/unix" 8 | 9 | // IsTerminal return true if the file descriptor is terminal. 10 | func IsTerminal(fd uintptr) bool { 11 | _, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA) 12 | return err == nil 13 | } 14 | 15 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 16 | // terminal. This is also always false on this environment. 17 | func IsCygwinTerminal(fd uintptr) bool { 18 | return false 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_others.go: -------------------------------------------------------------------------------- 1 | //go:build appengine || js || nacl || wasm 2 | // +build appengine js nacl wasm 3 | 4 | package isatty 5 | 6 | // IsTerminal returns true if the file descriptor is terminal which 7 | // is always false on js and appengine classic which is a sandboxed PaaS. 8 | func IsTerminal(fd uintptr) bool { 9 | return false 10 | } 11 | 12 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 13 | // terminal. This is also always false on this environment. 14 | func IsCygwinTerminal(fd uintptr) bool { 15 | return false 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_plan9.go: -------------------------------------------------------------------------------- 1 | //go:build plan9 2 | // +build plan9 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | func IsTerminal(fd uintptr) bool { 12 | path, err := syscall.Fd2path(int(fd)) 13 | if err != nil { 14 | return false 15 | } 16 | return path == "/dev/cons" || path == "/mnt/term/dev/cons" 17 | } 18 | 19 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 20 | // terminal. This is also always false on this environment. 21 | func IsCygwinTerminal(fd uintptr) bool { 22 | return false 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_solaris.go: -------------------------------------------------------------------------------- 1 | //go:build solaris && !appengine 2 | // +build solaris,!appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "golang.org/x/sys/unix" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | // see: https://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libc/port/gen/isatty.c 12 | func IsTerminal(fd uintptr) bool { 13 | _, err := unix.IoctlGetTermio(int(fd), unix.TCGETA) 14 | return err == nil 15 | } 16 | 17 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 18 | // terminal. This is also always false on this environment. 19 | func IsCygwinTerminal(fd uintptr) bool { 20 | return false 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_tcgets.go: -------------------------------------------------------------------------------- 1 | //go:build (linux || aix || zos) && !appengine 2 | // +build linux aix zos 3 | // +build !appengine 4 | 5 | package isatty 6 | 7 | import "golang.org/x/sys/unix" 8 | 9 | // IsTerminal return true if the file descriptor is terminal. 10 | func IsTerminal(fd uintptr) bool { 11 | _, err := unix.IoctlGetTermios(int(fd), unix.TCGETS) 12 | return err == nil 13 | } 14 | 15 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 16 | // terminal. This is also always false on this environment. 17 | func IsCygwinTerminal(fd uintptr) bool { 18 | return false 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | tmp 10 | 11 | # Architecture specific extensions/prefixes 12 | *.[568vq] 13 | [568vq].out 14 | 15 | *.cgo1.go 16 | *.cgo2.c 17 | _cgo_defun.c 18 | _cgo_gotypes.go 19 | _cgo_export.* 20 | 21 | _testmain.go 22 | 23 | *.exe 24 | *.test 25 | *.prof 26 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/CNAME: -------------------------------------------------------------------------------- 1 | zerolog.io -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Olivier Poitrey 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/rs/zerolog/_config.yml: -------------------------------------------------------------------------------- 1 | remote_theme: rs/gh-readme 2 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/ctx.go: -------------------------------------------------------------------------------- 1 | package zerolog 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | var disabledLogger *Logger 8 | 9 | func init() { 10 | SetGlobalLevel(TraceLevel) 11 | l := Nop() 12 | disabledLogger = &l 13 | } 14 | 15 | type ctxKey struct{} 16 | 17 | // WithContext returns a copy of ctx with the receiver attached. The Logger 18 | // attached to the provided Context (if any) will not be effected. If the 19 | // receiver's log level is Disabled it will only be attached to the returned 20 | // Context if the provided Context has a previously attached Logger. If the 21 | // provided Context has no attached Logger, a Disabled Logger will not be 22 | // attached. 23 | // 24 | // Note: to modify the existing Logger attached to a Context (instead of 25 | // replacing it in a new Context), use UpdateContext with the following 26 | // notation: 27 | // 28 | // ctx := r.Context() 29 | // l := zerolog.Ctx(ctx) 30 | // l.UpdateContext(func(c Context) Context { 31 | // return c.Str("bar", "baz") 32 | // }) 33 | // 34 | func (l Logger) WithContext(ctx context.Context) context.Context { 35 | if _, ok := ctx.Value(ctxKey{}).(*Logger); !ok && l.level == Disabled { 36 | // Do not store disabled logger. 37 | return ctx 38 | } 39 | return context.WithValue(ctx, ctxKey{}, &l) 40 | } 41 | 42 | // Ctx returns the Logger associated with the ctx. If no logger 43 | // is associated, DefaultContextLogger is returned, unless DefaultContextLogger 44 | // is nil, in which case a disabled logger is returned. 45 | func Ctx(ctx context.Context) *Logger { 46 | if l, ok := ctx.Value(ctxKey{}).(*Logger); ok { 47 | return l 48 | } else if l = DefaultContextLogger; l != nil { 49 | return l 50 | } 51 | return disabledLogger 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/encoder.go: -------------------------------------------------------------------------------- 1 | package zerolog 2 | 3 | import ( 4 | "net" 5 | "time" 6 | ) 7 | 8 | type encoder interface { 9 | AppendArrayDelim(dst []byte) []byte 10 | AppendArrayEnd(dst []byte) []byte 11 | AppendArrayStart(dst []byte) []byte 12 | AppendBeginMarker(dst []byte) []byte 13 | AppendBool(dst []byte, val bool) []byte 14 | AppendBools(dst []byte, vals []bool) []byte 15 | AppendBytes(dst, s []byte) []byte 16 | AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool) []byte 17 | AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte 18 | AppendEndMarker(dst []byte) []byte 19 | AppendFloat32(dst []byte, val float32) []byte 20 | AppendFloat64(dst []byte, val float64) []byte 21 | AppendFloats32(dst []byte, vals []float32) []byte 22 | AppendFloats64(dst []byte, vals []float64) []byte 23 | AppendHex(dst, s []byte) []byte 24 | AppendIPAddr(dst []byte, ip net.IP) []byte 25 | AppendIPPrefix(dst []byte, pfx net.IPNet) []byte 26 | AppendInt(dst []byte, val int) []byte 27 | AppendInt16(dst []byte, val int16) []byte 28 | AppendInt32(dst []byte, val int32) []byte 29 | AppendInt64(dst []byte, val int64) []byte 30 | AppendInt8(dst []byte, val int8) []byte 31 | AppendInterface(dst []byte, i interface{}) []byte 32 | AppendInts(dst []byte, vals []int) []byte 33 | AppendInts16(dst []byte, vals []int16) []byte 34 | AppendInts32(dst []byte, vals []int32) []byte 35 | AppendInts64(dst []byte, vals []int64) []byte 36 | AppendInts8(dst []byte, vals []int8) []byte 37 | AppendKey(dst []byte, key string) []byte 38 | AppendLineBreak(dst []byte) []byte 39 | AppendMACAddr(dst []byte, ha net.HardwareAddr) []byte 40 | AppendNil(dst []byte) []byte 41 | AppendObjectData(dst []byte, o []byte) []byte 42 | AppendString(dst []byte, s string) []byte 43 | AppendStrings(dst []byte, vals []string) []byte 44 | AppendTime(dst []byte, t time.Time, format string) []byte 45 | AppendTimes(dst []byte, vals []time.Time, format string) []byte 46 | AppendUint(dst []byte, val uint) []byte 47 | AppendUint16(dst []byte, val uint16) []byte 48 | AppendUint32(dst []byte, val uint32) []byte 49 | AppendUint64(dst []byte, val uint64) []byte 50 | AppendUint8(dst []byte, val uint8) []byte 51 | AppendUints(dst []byte, vals []uint) []byte 52 | AppendUints16(dst []byte, vals []uint16) []byte 53 | AppendUints32(dst []byte, vals []uint32) []byte 54 | AppendUints64(dst []byte, vals []uint64) []byte 55 | AppendUints8(dst []byte, vals []uint8) []byte 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/encoder_cbor.go: -------------------------------------------------------------------------------- 1 | // +build binary_log 2 | 3 | package zerolog 4 | 5 | // This file contains bindings to do binary encoding. 6 | 7 | import ( 8 | "github.com/rs/zerolog/internal/cbor" 9 | ) 10 | 11 | var ( 12 | _ encoder = (*cbor.Encoder)(nil) 13 | 14 | enc = cbor.Encoder{} 15 | ) 16 | 17 | func init() { 18 | // using closure to reflect the changes at runtime. 19 | cbor.JSONMarshalFunc = func(v interface{}) ([]byte, error) { 20 | return InterfaceMarshalFunc(v) 21 | } 22 | } 23 | 24 | func appendJSON(dst []byte, j []byte) []byte { 25 | return cbor.AppendEmbeddedJSON(dst, j) 26 | } 27 | 28 | // decodeIfBinaryToString - converts a binary formatted log msg to a 29 | // JSON formatted String Log message. 30 | func decodeIfBinaryToString(in []byte) string { 31 | return cbor.DecodeIfBinaryToString(in) 32 | } 33 | 34 | func decodeObjectToStr(in []byte) string { 35 | return cbor.DecodeObjectToStr(in) 36 | } 37 | 38 | // decodeIfBinaryToBytes - converts a binary formatted log msg to a 39 | // JSON formatted Bytes Log message. 40 | func decodeIfBinaryToBytes(in []byte) []byte { 41 | return cbor.DecodeIfBinaryToBytes(in) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/encoder_json.go: -------------------------------------------------------------------------------- 1 | // +build !binary_log 2 | 3 | package zerolog 4 | 5 | // encoder_json.go file contains bindings to generate 6 | // JSON encoded byte stream. 7 | 8 | import ( 9 | "github.com/rs/zerolog/internal/json" 10 | ) 11 | 12 | var ( 13 | _ encoder = (*json.Encoder)(nil) 14 | 15 | enc = json.Encoder{} 16 | ) 17 | 18 | func init() { 19 | // using closure to reflect the changes at runtime. 20 | json.JSONMarshalFunc = func(v interface{}) ([]byte, error) { 21 | return InterfaceMarshalFunc(v) 22 | } 23 | } 24 | 25 | func appendJSON(dst []byte, j []byte) []byte { 26 | return append(dst, j...) 27 | } 28 | 29 | func decodeIfBinaryToString(in []byte) string { 30 | return string(in) 31 | } 32 | 33 | func decodeObjectToStr(in []byte) string { 34 | return string(in) 35 | } 36 | 37 | func decodeIfBinaryToBytes(in []byte) []byte { 38 | return in 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/go112.go: -------------------------------------------------------------------------------- 1 | // +build go1.12 2 | 3 | package zerolog 4 | 5 | // Since go 1.12, some auto generated init functions are hidden from 6 | // runtime.Caller. 7 | const contextCallerSkipFrameCount = 2 8 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/hook.go: -------------------------------------------------------------------------------- 1 | package zerolog 2 | 3 | // Hook defines an interface to a log hook. 4 | type Hook interface { 5 | // Run runs the hook with the event. 6 | Run(e *Event, level Level, message string) 7 | } 8 | 9 | // HookFunc is an adaptor to allow the use of an ordinary function 10 | // as a Hook. 11 | type HookFunc func(e *Event, level Level, message string) 12 | 13 | // Run implements the Hook interface. 14 | func (h HookFunc) Run(e *Event, level Level, message string) { 15 | h(e, level, message) 16 | } 17 | 18 | // LevelHook applies a different hook for each level. 19 | type LevelHook struct { 20 | NoLevelHook, TraceHook, DebugHook, InfoHook, WarnHook, ErrorHook, FatalHook, PanicHook Hook 21 | } 22 | 23 | // Run implements the Hook interface. 24 | func (h LevelHook) Run(e *Event, level Level, message string) { 25 | switch level { 26 | case TraceLevel: 27 | if h.TraceHook != nil { 28 | h.TraceHook.Run(e, level, message) 29 | } 30 | case DebugLevel: 31 | if h.DebugHook != nil { 32 | h.DebugHook.Run(e, level, message) 33 | } 34 | case InfoLevel: 35 | if h.InfoHook != nil { 36 | h.InfoHook.Run(e, level, message) 37 | } 38 | case WarnLevel: 39 | if h.WarnHook != nil { 40 | h.WarnHook.Run(e, level, message) 41 | } 42 | case ErrorLevel: 43 | if h.ErrorHook != nil { 44 | h.ErrorHook.Run(e, level, message) 45 | } 46 | case FatalLevel: 47 | if h.FatalHook != nil { 48 | h.FatalHook.Run(e, level, message) 49 | } 50 | case PanicLevel: 51 | if h.PanicHook != nil { 52 | h.PanicHook.Run(e, level, message) 53 | } 54 | case NoLevel: 55 | if h.NoLevelHook != nil { 56 | h.NoLevelHook.Run(e, level, message) 57 | } 58 | } 59 | } 60 | 61 | // NewLevelHook returns a new LevelHook. 62 | func NewLevelHook() LevelHook { 63 | return LevelHook{} 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/internal/cbor/README.md: -------------------------------------------------------------------------------- 1 | ## Reference: 2 | CBOR Encoding is described in [RFC7049](https://tools.ietf.org/html/rfc7049) 3 | 4 | ## Comparison of JSON vs CBOR 5 | 6 | Two main areas of reduction are: 7 | 8 | 1. CPU usage to write a log msg 9 | 2. Size (in bytes) of log messages. 10 | 11 | 12 | CPU Usage savings are below: 13 | ``` 14 | name JSON time/op CBOR time/op delta 15 | Info-32 15.3ns ± 1% 11.7ns ± 3% -23.78% (p=0.000 n=9+10) 16 | ContextFields-32 16.2ns ± 2% 12.3ns ± 3% -23.97% (p=0.000 n=9+9) 17 | ContextAppend-32 6.70ns ± 0% 6.20ns ± 0% -7.44% (p=0.000 n=9+9) 18 | LogFields-32 66.4ns ± 0% 24.6ns ± 2% -62.89% (p=0.000 n=10+9) 19 | LogArrayObject-32 911ns ±11% 768ns ± 6% -15.64% (p=0.000 n=10+10) 20 | LogFieldType/Floats-32 70.3ns ± 2% 29.5ns ± 1% -57.98% (p=0.000 n=10+10) 21 | LogFieldType/Err-32 14.0ns ± 3% 12.1ns ± 8% -13.20% (p=0.000 n=8+10) 22 | LogFieldType/Dur-32 17.2ns ± 2% 13.1ns ± 1% -24.27% (p=0.000 n=10+9) 23 | LogFieldType/Object-32 54.3ns ±11% 52.3ns ± 7% ~ (p=0.239 n=10+10) 24 | LogFieldType/Ints-32 20.3ns ± 2% 15.1ns ± 2% -25.50% (p=0.000 n=9+10) 25 | LogFieldType/Interfaces-32 642ns ±11% 621ns ± 9% ~ (p=0.118 n=10+10) 26 | LogFieldType/Interface(Objects)-32 635ns ±13% 632ns ± 9% ~ (p=0.592 n=10+10) 27 | LogFieldType/Times-32 294ns ± 0% 27ns ± 1% -90.71% (p=0.000 n=10+9) 28 | LogFieldType/Durs-32 121ns ± 0% 33ns ± 2% -72.44% (p=0.000 n=9+9) 29 | LogFieldType/Interface(Object)-32 56.6ns ± 8% 52.3ns ± 8% -7.54% (p=0.007 n=10+10) 30 | LogFieldType/Errs-32 17.8ns ± 3% 16.1ns ± 2% -9.71% (p=0.000 n=10+9) 31 | LogFieldType/Time-32 40.5ns ± 1% 12.7ns ± 6% -68.66% (p=0.000 n=8+9) 32 | LogFieldType/Bool-32 12.0ns ± 5% 10.2ns ± 2% -15.18% (p=0.000 n=10+8) 33 | LogFieldType/Bools-32 17.2ns ± 2% 12.6ns ± 4% -26.63% (p=0.000 n=10+10) 34 | LogFieldType/Int-32 12.3ns ± 2% 11.2ns ± 4% -9.27% (p=0.000 n=9+10) 35 | LogFieldType/Float-32 16.7ns ± 1% 12.6ns ± 2% -24.42% (p=0.000 n=7+9) 36 | LogFieldType/Str-32 12.7ns ± 7% 11.3ns ± 7% -10.88% (p=0.000 n=10+9) 37 | LogFieldType/Strs-32 20.3ns ± 3% 18.2ns ± 3% -10.25% (p=0.000 n=9+10) 38 | LogFieldType/Interface-32 183ns ±12% 175ns ± 9% ~ (p=0.078 n=10+10) 39 | ``` 40 | 41 | Log message size savings is greatly dependent on the number and type of fields in the log message. 42 | Assuming this log message (with an Integer, timestamp and string, in addition to level). 43 | 44 | `{"level":"error","Fault":41650,"time":"2018-04-01T15:18:19-07:00","message":"Some Message"}` 45 | 46 | Two measurements were done for the log file sizes - one without any compression, second 47 | using [compress/zlib](https://golang.org/pkg/compress/zlib/). 48 | 49 | Results for 10,000 log messages: 50 | 51 | | Log Format | Plain File Size (in KB) | Compressed File Size (in KB) | 52 | | :--- | :---: | :---: | 53 | | JSON | 920 | 28 | 54 | | CBOR | 550 | 28 | 55 | 56 | The example used to calculate the above data is available in [Examples](examples). 57 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/internal/cbor/base.go: -------------------------------------------------------------------------------- 1 | package cbor 2 | 3 | // JSONMarshalFunc is used to marshal interface to JSON encoded byte slice. 4 | // Making it package level instead of embedded in Encoder brings 5 | // some extra efforts at importing, but avoids value copy when the functions 6 | // of Encoder being invoked. 7 | // DO REMEMBER to set this variable at importing, or 8 | // you might get a nil pointer dereference panic at runtime. 9 | var JSONMarshalFunc func(v interface{}) ([]byte, error) 10 | 11 | type Encoder struct{} 12 | 13 | // AppendKey adds a key (string) to the binary encoded log message 14 | func (e Encoder) AppendKey(dst []byte, key string) []byte { 15 | if len(dst) < 1 { 16 | dst = e.AppendBeginMarker(dst) 17 | } 18 | return e.AppendString(dst, key) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/internal/cbor/cbor.go: -------------------------------------------------------------------------------- 1 | // Package cbor provides primitives for storing different data 2 | // in the CBOR (binary) format. CBOR is defined in RFC7049. 3 | package cbor 4 | 5 | import "time" 6 | 7 | const ( 8 | majorOffset = 5 9 | additionalMax = 23 10 | 11 | // Non Values. 12 | additionalTypeBoolFalse byte = 20 13 | additionalTypeBoolTrue byte = 21 14 | additionalTypeNull byte = 22 15 | 16 | // Integer (+ve and -ve) Sub-types. 17 | additionalTypeIntUint8 byte = 24 18 | additionalTypeIntUint16 byte = 25 19 | additionalTypeIntUint32 byte = 26 20 | additionalTypeIntUint64 byte = 27 21 | 22 | // Float Sub-types. 23 | additionalTypeFloat16 byte = 25 24 | additionalTypeFloat32 byte = 26 25 | additionalTypeFloat64 byte = 27 26 | additionalTypeBreak byte = 31 27 | 28 | // Tag Sub-types. 29 | additionalTypeTimestamp byte = 01 30 | 31 | // Extended Tags - from https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml 32 | additionalTypeTagNetworkAddr uint16 = 260 33 | additionalTypeTagNetworkPrefix uint16 = 261 34 | additionalTypeEmbeddedJSON uint16 = 262 35 | additionalTypeTagHexString uint16 = 263 36 | 37 | // Unspecified number of elements. 38 | additionalTypeInfiniteCount byte = 31 39 | ) 40 | const ( 41 | majorTypeUnsignedInt byte = iota << majorOffset // Major type 0 42 | majorTypeNegativeInt // Major type 1 43 | majorTypeByteString // Major type 2 44 | majorTypeUtf8String // Major type 3 45 | majorTypeArray // Major type 4 46 | majorTypeMap // Major type 5 47 | majorTypeTags // Major type 6 48 | majorTypeSimpleAndFloat // Major type 7 49 | ) 50 | 51 | const ( 52 | maskOutAdditionalType byte = (7 << majorOffset) 53 | maskOutMajorType byte = 31 54 | ) 55 | 56 | const ( 57 | float32Nan = "\xfa\x7f\xc0\x00\x00" 58 | float32PosInfinity = "\xfa\x7f\x80\x00\x00" 59 | float32NegInfinity = "\xfa\xff\x80\x00\x00" 60 | float64Nan = "\xfb\x7f\xf8\x00\x00\x00\x00\x00\x00" 61 | float64PosInfinity = "\xfb\x7f\xf0\x00\x00\x00\x00\x00\x00" 62 | float64NegInfinity = "\xfb\xff\xf0\x00\x00\x00\x00\x00\x00" 63 | ) 64 | 65 | // IntegerTimeFieldFormat indicates the format of timestamp decoded 66 | // from an integer (time in seconds). 67 | var IntegerTimeFieldFormat = time.RFC3339 68 | 69 | // NanoTimeFieldFormat indicates the format of timestamp decoded 70 | // from a float value (time in seconds and nanoseconds). 71 | var NanoTimeFieldFormat = time.RFC3339Nano 72 | 73 | func appendCborTypePrefix(dst []byte, major byte, number uint64) []byte { 74 | byteCount := 8 75 | var minor byte 76 | switch { 77 | case number < 256: 78 | byteCount = 1 79 | minor = additionalTypeIntUint8 80 | 81 | case number < 65536: 82 | byteCount = 2 83 | minor = additionalTypeIntUint16 84 | 85 | case number < 4294967296: 86 | byteCount = 4 87 | minor = additionalTypeIntUint32 88 | 89 | default: 90 | byteCount = 8 91 | minor = additionalTypeIntUint64 92 | 93 | } 94 | 95 | dst = append(dst, major|minor) 96 | byteCount-- 97 | for ; byteCount >= 0; byteCount-- { 98 | dst = append(dst, byte(number>>(uint(byteCount)*8))) 99 | } 100 | return dst 101 | } 102 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/internal/cbor/string.go: -------------------------------------------------------------------------------- 1 | package cbor 2 | 3 | import "fmt" 4 | 5 | // AppendStrings encodes and adds an array of strings to the dst byte array. 6 | func (e Encoder) AppendStrings(dst []byte, vals []string) []byte { 7 | major := majorTypeArray 8 | l := len(vals) 9 | if l <= additionalMax { 10 | lb := byte(l) 11 | dst = append(dst, major|lb) 12 | } else { 13 | dst = appendCborTypePrefix(dst, major, uint64(l)) 14 | } 15 | for _, v := range vals { 16 | dst = e.AppendString(dst, v) 17 | } 18 | return dst 19 | } 20 | 21 | // AppendString encodes and adds a string to the dst byte array. 22 | func (Encoder) AppendString(dst []byte, s string) []byte { 23 | major := majorTypeUtf8String 24 | 25 | l := len(s) 26 | if l <= additionalMax { 27 | lb := byte(l) 28 | dst = append(dst, major|lb) 29 | } else { 30 | dst = appendCborTypePrefix(dst, majorTypeUtf8String, uint64(l)) 31 | } 32 | return append(dst, s...) 33 | } 34 | 35 | // AppendStringers encodes and adds an array of Stringer values 36 | // to the dst byte array. 37 | func (e Encoder) AppendStringers(dst []byte, vals []fmt.Stringer) []byte { 38 | if len(vals) == 0 { 39 | return e.AppendArrayEnd(e.AppendArrayStart(dst)) 40 | } 41 | dst = e.AppendArrayStart(dst) 42 | dst = e.AppendStringer(dst, vals[0]) 43 | if len(vals) > 1 { 44 | for _, val := range vals[1:] { 45 | dst = e.AppendStringer(dst, val) 46 | } 47 | } 48 | return e.AppendArrayEnd(dst) 49 | } 50 | 51 | // AppendStringer encodes and adds the Stringer value to the dst 52 | // byte array. 53 | func (e Encoder) AppendStringer(dst []byte, val fmt.Stringer) []byte { 54 | if val == nil { 55 | return e.AppendNil(dst) 56 | } 57 | return e.AppendString(dst, val.String()) 58 | } 59 | 60 | // AppendBytes encodes and adds an array of bytes to the dst byte array. 61 | func (Encoder) AppendBytes(dst, s []byte) []byte { 62 | major := majorTypeByteString 63 | 64 | l := len(s) 65 | if l <= additionalMax { 66 | lb := byte(l) 67 | dst = append(dst, major|lb) 68 | } else { 69 | dst = appendCborTypePrefix(dst, major, uint64(l)) 70 | } 71 | return append(dst, s...) 72 | } 73 | 74 | // AppendEmbeddedJSON adds a tag and embeds input JSON as such. 75 | func AppendEmbeddedJSON(dst, s []byte) []byte { 76 | major := majorTypeTags 77 | minor := additionalTypeEmbeddedJSON 78 | 79 | // Append the TAG to indicate this is Embedded JSON. 80 | dst = append(dst, major|additionalTypeIntUint16) 81 | dst = append(dst, byte(minor>>8)) 82 | dst = append(dst, byte(minor&0xff)) 83 | 84 | // Append the JSON Object as Byte String. 85 | major = majorTypeByteString 86 | 87 | l := len(s) 88 | if l <= additionalMax { 89 | lb := byte(l) 90 | dst = append(dst, major|lb) 91 | } else { 92 | dst = appendCborTypePrefix(dst, major, uint64(l)) 93 | } 94 | return append(dst, s...) 95 | } 96 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/internal/cbor/time.go: -------------------------------------------------------------------------------- 1 | package cbor 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | func appendIntegerTimestamp(dst []byte, t time.Time) []byte { 8 | major := majorTypeTags 9 | minor := additionalTypeTimestamp 10 | dst = append(dst, major|minor) 11 | secs := t.Unix() 12 | var val uint64 13 | if secs < 0 { 14 | major = majorTypeNegativeInt 15 | val = uint64(-secs - 1) 16 | } else { 17 | major = majorTypeUnsignedInt 18 | val = uint64(secs) 19 | } 20 | dst = appendCborTypePrefix(dst, major, val) 21 | return dst 22 | } 23 | 24 | func (e Encoder) appendFloatTimestamp(dst []byte, t time.Time) []byte { 25 | major := majorTypeTags 26 | minor := additionalTypeTimestamp 27 | dst = append(dst, major|minor) 28 | secs := t.Unix() 29 | nanos := t.Nanosecond() 30 | var val float64 31 | val = float64(secs)*1.0 + float64(nanos)*1e-9 32 | return e.AppendFloat64(dst, val) 33 | } 34 | 35 | // AppendTime encodes and adds a timestamp to the dst byte array. 36 | func (e Encoder) AppendTime(dst []byte, t time.Time, unused string) []byte { 37 | utc := t.UTC() 38 | if utc.Nanosecond() == 0 { 39 | return appendIntegerTimestamp(dst, utc) 40 | } 41 | return e.appendFloatTimestamp(dst, utc) 42 | } 43 | 44 | // AppendTimes encodes and adds an array of timestamps to the dst byte array. 45 | func (e Encoder) AppendTimes(dst []byte, vals []time.Time, unused string) []byte { 46 | major := majorTypeArray 47 | l := len(vals) 48 | if l == 0 { 49 | return e.AppendArrayEnd(e.AppendArrayStart(dst)) 50 | } 51 | if l <= additionalMax { 52 | lb := byte(l) 53 | dst = append(dst, major|lb) 54 | } else { 55 | dst = appendCborTypePrefix(dst, major, uint64(l)) 56 | } 57 | 58 | for _, t := range vals { 59 | dst = e.AppendTime(dst, t, unused) 60 | } 61 | return dst 62 | } 63 | 64 | // AppendDuration encodes and adds a duration to the dst byte array. 65 | // useInt field indicates whether to store the duration as seconds (integer) or 66 | // as seconds+nanoseconds (float). 67 | func (e Encoder) AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool) []byte { 68 | if useInt { 69 | return e.AppendInt64(dst, int64(d/unit)) 70 | } 71 | return e.AppendFloat64(dst, float64(d)/float64(unit)) 72 | } 73 | 74 | // AppendDurations encodes and adds an array of durations to the dst byte array. 75 | // useInt field indicates whether to store the duration as seconds (integer) or 76 | // as seconds+nanoseconds (float). 77 | func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte { 78 | major := majorTypeArray 79 | l := len(vals) 80 | if l == 0 { 81 | return e.AppendArrayEnd(e.AppendArrayStart(dst)) 82 | } 83 | if l <= additionalMax { 84 | lb := byte(l) 85 | dst = append(dst, major|lb) 86 | } else { 87 | dst = appendCborTypePrefix(dst, major, uint64(l)) 88 | } 89 | for _, d := range vals { 90 | dst = e.AppendDuration(dst, d, unit, useInt) 91 | } 92 | return dst 93 | } 94 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/internal/json/base.go: -------------------------------------------------------------------------------- 1 | package json 2 | 3 | // JSONMarshalFunc is used to marshal interface to JSON encoded byte slice. 4 | // Making it package level instead of embedded in Encoder brings 5 | // some extra efforts at importing, but avoids value copy when the functions 6 | // of Encoder being invoked. 7 | // DO REMEMBER to set this variable at importing, or 8 | // you might get a nil pointer dereference panic at runtime. 9 | var JSONMarshalFunc func(v interface{}) ([]byte, error) 10 | 11 | type Encoder struct{} 12 | 13 | // AppendKey appends a new key to the output JSON. 14 | func (e Encoder) AppendKey(dst []byte, key string) []byte { 15 | if dst[len(dst)-1] != '{' { 16 | dst = append(dst, ',') 17 | } 18 | return append(e.AppendString(dst, key), ':') 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/internal/json/bytes.go: -------------------------------------------------------------------------------- 1 | package json 2 | 3 | import "unicode/utf8" 4 | 5 | // AppendBytes is a mirror of appendString with []byte arg 6 | func (Encoder) AppendBytes(dst, s []byte) []byte { 7 | dst = append(dst, '"') 8 | for i := 0; i < len(s); i++ { 9 | if !noEscapeTable[s[i]] { 10 | dst = appendBytesComplex(dst, s, i) 11 | return append(dst, '"') 12 | } 13 | } 14 | dst = append(dst, s...) 15 | return append(dst, '"') 16 | } 17 | 18 | // AppendHex encodes the input bytes to a hex string and appends 19 | // the encoded string to the input byte slice. 20 | // 21 | // The operation loops though each byte and encodes it as hex using 22 | // the hex lookup table. 23 | func (Encoder) AppendHex(dst, s []byte) []byte { 24 | dst = append(dst, '"') 25 | for _, v := range s { 26 | dst = append(dst, hex[v>>4], hex[v&0x0f]) 27 | } 28 | return append(dst, '"') 29 | } 30 | 31 | // appendBytesComplex is a mirror of the appendStringComplex 32 | // with []byte arg 33 | func appendBytesComplex(dst, s []byte, i int) []byte { 34 | start := 0 35 | for i < len(s) { 36 | b := s[i] 37 | if b >= utf8.RuneSelf { 38 | r, size := utf8.DecodeRune(s[i:]) 39 | if r == utf8.RuneError && size == 1 { 40 | if start < i { 41 | dst = append(dst, s[start:i]...) 42 | } 43 | dst = append(dst, `\ufffd`...) 44 | i += size 45 | start = i 46 | continue 47 | } 48 | i += size 49 | continue 50 | } 51 | if noEscapeTable[b] { 52 | i++ 53 | continue 54 | } 55 | // We encountered a character that needs to be encoded. 56 | // Let's append the previous simple characters to the byte slice 57 | // and switch our operation to read and encode the remainder 58 | // characters byte-by-byte. 59 | if start < i { 60 | dst = append(dst, s[start:i]...) 61 | } 62 | switch b { 63 | case '"', '\\': 64 | dst = append(dst, '\\', b) 65 | case '\b': 66 | dst = append(dst, '\\', 'b') 67 | case '\f': 68 | dst = append(dst, '\\', 'f') 69 | case '\n': 70 | dst = append(dst, '\\', 'n') 71 | case '\r': 72 | dst = append(dst, '\\', 'r') 73 | case '\t': 74 | dst = append(dst, '\\', 't') 75 | default: 76 | dst = append(dst, '\\', 'u', '0', '0', hex[b>>4], hex[b&0xF]) 77 | } 78 | i++ 79 | start = i 80 | } 81 | if start < len(s) { 82 | dst = append(dst, s[start:]...) 83 | } 84 | return dst 85 | } 86 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/internal/json/time.go: -------------------------------------------------------------------------------- 1 | package json 2 | 3 | import ( 4 | "strconv" 5 | "time" 6 | ) 7 | 8 | const ( 9 | // Import from zerolog/global.go 10 | timeFormatUnix = "" 11 | timeFormatUnixMs = "UNIXMS" 12 | timeFormatUnixMicro = "UNIXMICRO" 13 | timeFormatUnixNano = "UNIXNANO" 14 | ) 15 | 16 | // AppendTime formats the input time with the given format 17 | // and appends the encoded string to the input byte slice. 18 | func (e Encoder) AppendTime(dst []byte, t time.Time, format string) []byte { 19 | switch format { 20 | case timeFormatUnix: 21 | return e.AppendInt64(dst, t.Unix()) 22 | case timeFormatUnixMs: 23 | return e.AppendInt64(dst, t.UnixNano()/1000000) 24 | case timeFormatUnixMicro: 25 | return e.AppendInt64(dst, t.UnixNano()/1000) 26 | case timeFormatUnixNano: 27 | return e.AppendInt64(dst, t.UnixNano()) 28 | } 29 | return append(t.AppendFormat(append(dst, '"'), format), '"') 30 | } 31 | 32 | // AppendTimes converts the input times with the given format 33 | // and appends the encoded string list to the input byte slice. 34 | func (Encoder) AppendTimes(dst []byte, vals []time.Time, format string) []byte { 35 | switch format { 36 | case timeFormatUnix: 37 | return appendUnixTimes(dst, vals) 38 | case timeFormatUnixMs: 39 | return appendUnixNanoTimes(dst, vals, 1000000) 40 | case timeFormatUnixMicro: 41 | return appendUnixNanoTimes(dst, vals, 1000) 42 | case timeFormatUnixNano: 43 | return appendUnixNanoTimes(dst, vals, 1) 44 | } 45 | if len(vals) == 0 { 46 | return append(dst, '[', ']') 47 | } 48 | dst = append(dst, '[') 49 | dst = append(vals[0].AppendFormat(append(dst, '"'), format), '"') 50 | if len(vals) > 1 { 51 | for _, t := range vals[1:] { 52 | dst = append(t.AppendFormat(append(dst, ',', '"'), format), '"') 53 | } 54 | } 55 | dst = append(dst, ']') 56 | return dst 57 | } 58 | 59 | func appendUnixTimes(dst []byte, vals []time.Time) []byte { 60 | if len(vals) == 0 { 61 | return append(dst, '[', ']') 62 | } 63 | dst = append(dst, '[') 64 | dst = strconv.AppendInt(dst, vals[0].Unix(), 10) 65 | if len(vals) > 1 { 66 | for _, t := range vals[1:] { 67 | dst = strconv.AppendInt(append(dst, ','), t.Unix(), 10) 68 | } 69 | } 70 | dst = append(dst, ']') 71 | return dst 72 | } 73 | 74 | func appendUnixNanoTimes(dst []byte, vals []time.Time, div int64) []byte { 75 | if len(vals) == 0 { 76 | return append(dst, '[', ']') 77 | } 78 | dst = append(dst, '[') 79 | dst = strconv.AppendInt(dst, vals[0].UnixNano()/div, 10) 80 | if len(vals) > 1 { 81 | for _, t := range vals[1:] { 82 | dst = strconv.AppendInt(append(dst, ','), t.UnixNano()/div, 10) 83 | } 84 | } 85 | dst = append(dst, ']') 86 | return dst 87 | } 88 | 89 | // AppendDuration formats the input duration with the given unit & format 90 | // and appends the encoded string to the input byte slice. 91 | func (e Encoder) AppendDuration(dst []byte, d time.Duration, unit time.Duration, useInt bool) []byte { 92 | if useInt { 93 | return strconv.AppendInt(dst, int64(d/unit), 10) 94 | } 95 | return e.AppendFloat64(dst, float64(d)/float64(unit)) 96 | } 97 | 98 | // AppendDurations formats the input durations with the given unit & format 99 | // and appends the encoded string list to the input byte slice. 100 | func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte { 101 | if len(vals) == 0 { 102 | return append(dst, '[', ']') 103 | } 104 | dst = append(dst, '[') 105 | dst = e.AppendDuration(dst, vals[0], unit, useInt) 106 | if len(vals) > 1 { 107 | for _, d := range vals[1:] { 108 | dst = e.AppendDuration(append(dst, ','), d, unit, useInt) 109 | } 110 | } 111 | dst = append(dst, ']') 112 | return dst 113 | } 114 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/not_go112.go: -------------------------------------------------------------------------------- 1 | // +build !go1.12 2 | 3 | package zerolog 4 | 5 | const contextCallerSkipFrameCount = 3 6 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/pretty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/djhworld/theunwrapper/93e92395e4a961b87e4e3c74326a0fb2aada077c/vendor/github.com/rs/zerolog/pretty.png -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/sampler.go: -------------------------------------------------------------------------------- 1 | package zerolog 2 | 3 | import ( 4 | "math/rand" 5 | "sync/atomic" 6 | "time" 7 | ) 8 | 9 | var ( 10 | // Often samples log every ~ 10 events. 11 | Often = RandomSampler(10) 12 | // Sometimes samples log every ~ 100 events. 13 | Sometimes = RandomSampler(100) 14 | // Rarely samples log every ~ 1000 events. 15 | Rarely = RandomSampler(1000) 16 | ) 17 | 18 | // Sampler defines an interface to a log sampler. 19 | type Sampler interface { 20 | // Sample returns true if the event should be part of the sample, false if 21 | // the event should be dropped. 22 | Sample(lvl Level) bool 23 | } 24 | 25 | // RandomSampler use a PRNG to randomly sample an event out of N events, 26 | // regardless of their level. 27 | type RandomSampler uint32 28 | 29 | // Sample implements the Sampler interface. 30 | func (s RandomSampler) Sample(lvl Level) bool { 31 | if s <= 0 { 32 | return false 33 | } 34 | if rand.Intn(int(s)) != 0 { 35 | return false 36 | } 37 | return true 38 | } 39 | 40 | // BasicSampler is a sampler that will send every Nth events, regardless of 41 | // their level. 42 | type BasicSampler struct { 43 | N uint32 44 | counter uint32 45 | } 46 | 47 | // Sample implements the Sampler interface. 48 | func (s *BasicSampler) Sample(lvl Level) bool { 49 | n := s.N 50 | if n == 1 { 51 | return true 52 | } 53 | c := atomic.AddUint32(&s.counter, 1) 54 | return c%n == 1 55 | } 56 | 57 | // BurstSampler lets Burst events pass per Period then pass the decision to 58 | // NextSampler. If Sampler is not set, all subsequent events are rejected. 59 | type BurstSampler struct { 60 | // Burst is the maximum number of event per period allowed before calling 61 | // NextSampler. 62 | Burst uint32 63 | // Period defines the burst period. If 0, NextSampler is always called. 64 | Period time.Duration 65 | // NextSampler is the sampler used after the burst is reached. If nil, 66 | // events are always rejected after the burst. 67 | NextSampler Sampler 68 | 69 | counter uint32 70 | resetAt int64 71 | } 72 | 73 | // Sample implements the Sampler interface. 74 | func (s *BurstSampler) Sample(lvl Level) bool { 75 | if s.Burst > 0 && s.Period > 0 { 76 | if s.inc() <= s.Burst { 77 | return true 78 | } 79 | } 80 | if s.NextSampler == nil { 81 | return false 82 | } 83 | return s.NextSampler.Sample(lvl) 84 | } 85 | 86 | func (s *BurstSampler) inc() uint32 { 87 | now := time.Now().UnixNano() 88 | resetAt := atomic.LoadInt64(&s.resetAt) 89 | var c uint32 90 | if now > resetAt { 91 | c = 1 92 | atomic.StoreUint32(&s.counter, c) 93 | newResetAt := now + s.Period.Nanoseconds() 94 | reset := atomic.CompareAndSwapInt64(&s.resetAt, resetAt, newResetAt) 95 | if !reset { 96 | // Lost the race with another goroutine trying to reset. 97 | c = atomic.AddUint32(&s.counter, 1) 98 | } 99 | } else { 100 | c = atomic.AddUint32(&s.counter, 1) 101 | } 102 | return c 103 | } 104 | 105 | // LevelSampler applies a different sampler for each level. 106 | type LevelSampler struct { 107 | TraceSampler, DebugSampler, InfoSampler, WarnSampler, ErrorSampler Sampler 108 | } 109 | 110 | func (s LevelSampler) Sample(lvl Level) bool { 111 | switch lvl { 112 | case TraceLevel: 113 | if s.TraceSampler != nil { 114 | return s.TraceSampler.Sample(lvl) 115 | } 116 | case DebugLevel: 117 | if s.DebugSampler != nil { 118 | return s.DebugSampler.Sample(lvl) 119 | } 120 | case InfoLevel: 121 | if s.InfoSampler != nil { 122 | return s.InfoSampler.Sample(lvl) 123 | } 124 | case WarnLevel: 125 | if s.WarnSampler != nil { 126 | return s.WarnSampler.Sample(lvl) 127 | } 128 | case ErrorLevel: 129 | if s.ErrorSampler != nil { 130 | return s.ErrorSampler.Sample(lvl) 131 | } 132 | } 133 | return true 134 | } 135 | -------------------------------------------------------------------------------- /vendor/github.com/rs/zerolog/syslog.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !binary_log 3 | 4 | package zerolog 5 | 6 | import ( 7 | "io" 8 | ) 9 | 10 | // See http://cee.mitre.org/language/1.0-beta1/clt.html#syslog 11 | // or https://www.rsyslog.com/json-elasticsearch/ 12 | const ceePrefix = "@cee:" 13 | 14 | // SyslogWriter is an interface matching a syslog.Writer struct. 15 | type SyslogWriter interface { 16 | io.Writer 17 | Debug(m string) error 18 | Info(m string) error 19 | Warning(m string) error 20 | Err(m string) error 21 | Emerg(m string) error 22 | Crit(m string) error 23 | } 24 | 25 | type syslogWriter struct { 26 | w SyslogWriter 27 | prefix string 28 | } 29 | 30 | // SyslogLevelWriter wraps a SyslogWriter and call the right syslog level 31 | // method matching the zerolog level. 32 | func SyslogLevelWriter(w SyslogWriter) LevelWriter { 33 | return syslogWriter{w, ""} 34 | } 35 | 36 | // SyslogCEEWriter wraps a SyslogWriter with a SyslogLevelWriter that adds a 37 | // MITRE CEE prefix for JSON syslog entries, compatible with rsyslog 38 | // and syslog-ng JSON logging support. 39 | // See https://www.rsyslog.com/json-elasticsearch/ 40 | func SyslogCEEWriter(w SyslogWriter) LevelWriter { 41 | return syslogWriter{w, ceePrefix} 42 | } 43 | 44 | func (sw syslogWriter) Write(p []byte) (n int, err error) { 45 | var pn int 46 | if sw.prefix != "" { 47 | pn, err = sw.w.Write([]byte(sw.prefix)) 48 | if err != nil { 49 | return pn, err 50 | } 51 | } 52 | n, err = sw.w.Write(p) 53 | return pn + n, err 54 | } 55 | 56 | // WriteLevel implements LevelWriter interface. 57 | func (sw syslogWriter) WriteLevel(level Level, p []byte) (n int, err error) { 58 | switch level { 59 | case TraceLevel: 60 | case DebugLevel: 61 | err = sw.w.Debug(sw.prefix + string(p)) 62 | case InfoLevel: 63 | err = sw.w.Info(sw.prefix + string(p)) 64 | case WarnLevel: 65 | err = sw.w.Warning(sw.prefix + string(p)) 66 | case ErrorLevel: 67 | err = sw.w.Err(sw.prefix + string(p)) 68 | case FatalLevel: 69 | err = sw.w.Emerg(sw.prefix + string(p)) 70 | case PanicLevel: 71 | err = sw.w.Crit(sw.prefix + string(p)) 72 | case NoLevel: 73 | err = sw.w.Info(sw.prefix + string(p)) 74 | default: 75 | panic("invalid level") 76 | } 77 | // Any CEE prefix is not part of the message, so we don't include its length 78 | n = len(p) 79 | return 80 | } 81 | -------------------------------------------------------------------------------- /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/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | unix.test 3 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/affinity_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | // CPU affinity functions 6 | 7 | package unix 8 | 9 | import ( 10 | "math/bits" 11 | "unsafe" 12 | ) 13 | 14 | const cpuSetSize = _CPU_SETSIZE / _NCPUBITS 15 | 16 | // CPUSet represents a CPU affinity mask. 17 | type CPUSet [cpuSetSize]cpuMask 18 | 19 | func schedAffinity(trap uintptr, pid int, set *CPUSet) error { 20 | _, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(*set)), uintptr(unsafe.Pointer(set))) 21 | if e != 0 { 22 | return errnoErr(e) 23 | } 24 | return nil 25 | } 26 | 27 | // SchedGetaffinity gets the CPU affinity mask of the thread specified by pid. 28 | // If pid is 0 the calling thread is used. 29 | func SchedGetaffinity(pid int, set *CPUSet) error { 30 | return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set) 31 | } 32 | 33 | // SchedSetaffinity sets the CPU affinity mask of the thread specified by pid. 34 | // If pid is 0 the calling thread is used. 35 | func SchedSetaffinity(pid int, set *CPUSet) error { 36 | return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set) 37 | } 38 | 39 | // Zero clears the set s, so that it contains no CPUs. 40 | func (s *CPUSet) Zero() { 41 | for i := range s { 42 | s[i] = 0 43 | } 44 | } 45 | 46 | func cpuBitsIndex(cpu int) int { 47 | return cpu / _NCPUBITS 48 | } 49 | 50 | func cpuBitsMask(cpu int) cpuMask { 51 | return cpuMask(1 << (uint(cpu) % _NCPUBITS)) 52 | } 53 | 54 | // Set adds cpu to the set s. 55 | func (s *CPUSet) Set(cpu int) { 56 | i := cpuBitsIndex(cpu) 57 | if i < len(s) { 58 | s[i] |= cpuBitsMask(cpu) 59 | } 60 | } 61 | 62 | // Clear removes cpu from the set s. 63 | func (s *CPUSet) Clear(cpu int) { 64 | i := cpuBitsIndex(cpu) 65 | if i < len(s) { 66 | s[i] &^= cpuBitsMask(cpu) 67 | } 68 | } 69 | 70 | // IsSet reports whether cpu is in the set s. 71 | func (s *CPUSet) IsSet(cpu int) bool { 72 | i := cpuBitsIndex(cpu) 73 | if i < len(s) { 74 | return s[i]&cpuBitsMask(cpu) != 0 75 | } 76 | return false 77 | } 78 | 79 | // Count returns the number of CPUs in the set s. 80 | func (s *CPUSet) Count() int { 81 | c := 0 82 | for _, b := range s { 83 | c += bits.OnesCount64(uint64(b)) 84 | } 85 | return c 86 | } 87 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/aliases.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos) && go1.9 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | // +build go1.9 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | type Signal = syscall.Signal 14 | type Errno = syscall.Errno 15 | type SysProcAttr = syscall.SysProcAttr 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_aix_ppc64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for ppc64, AIX are implemented in runtime/syscall_aix.go 12 | // 13 | 14 | TEXT ·syscall6(SB),NOSPLIT,$0-88 15 | JMP syscall·syscall6(SB) 16 | 17 | TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 18 | JMP syscall·rawSyscall6(SB) 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_bsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 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 | //go:build (freebsd || netbsd || openbsd) && gc 6 | // +build freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // System call support for 386 BSD 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_bsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 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 | //go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && gc 6 | // +build darwin dragonfly freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // System call support for AMD64 BSD 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_bsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 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 | //go:build (freebsd || netbsd || openbsd) && gc 6 | // +build freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // System call support for ARM BSD 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_bsd_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 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 | //go:build (darwin || freebsd || netbsd || openbsd) && gc 6 | // +build darwin freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // System call support for ARM64 BSD 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_bsd_ppc64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2022 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 | //go:build (darwin || freebsd || netbsd || openbsd) && gc 6 | // +build darwin freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System call support for ppc64, BSD 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 ·Syscall9(SB),NOSPLIT,$0-104 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 28 | JMP syscall·RawSyscall(SB) 29 | 30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 31 | JMP syscall·RawSyscall6(SB) 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_bsd_riscv64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2021 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 | //go:build (darwin || freebsd || netbsd || openbsd) && gc 6 | // +build darwin freebsd netbsd openbsd 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // System call support for RISCV64 BSD 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_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 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for 386, Linux 12 | // 13 | 14 | // See ../runtime/sys_linux_386.s for the reason why we always use int 0x80 15 | // instead of the glibc-specific "CALL 0x10(GS)". 16 | #define INVOKE_SYSCALL INT $0x80 17 | 18 | // Just jump to package syscall's implementation for all these functions. 19 | // The runtime may know about them. 20 | 21 | TEXT ·Syscall(SB),NOSPLIT,$0-28 22 | JMP syscall·Syscall(SB) 23 | 24 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 25 | JMP syscall·Syscall6(SB) 26 | 27 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 28 | CALL runtime·entersyscall(SB) 29 | MOVL trap+0(FP), AX // syscall entry 30 | MOVL a1+4(FP), BX 31 | MOVL a2+8(FP), CX 32 | MOVL a3+12(FP), DX 33 | MOVL $0, SI 34 | MOVL $0, DI 35 | INVOKE_SYSCALL 36 | MOVL AX, r1+16(FP) 37 | MOVL DX, r2+20(FP) 38 | CALL runtime·exitsyscall(SB) 39 | RET 40 | 41 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 42 | JMP syscall·RawSyscall(SB) 43 | 44 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 45 | JMP syscall·RawSyscall6(SB) 46 | 47 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 48 | MOVL trap+0(FP), AX // syscall entry 49 | MOVL a1+4(FP), BX 50 | MOVL a2+8(FP), CX 51 | MOVL a3+12(FP), DX 52 | MOVL $0, SI 53 | MOVL $0, DI 54 | INVOKE_SYSCALL 55 | MOVL AX, r1+16(FP) 56 | MOVL DX, r2+20(FP) 57 | RET 58 | 59 | TEXT ·socketcall(SB),NOSPLIT,$0-36 60 | JMP syscall·socketcall(SB) 61 | 62 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 63 | JMP syscall·rawsocketcall(SB) 64 | 65 | TEXT ·seek(SB),NOSPLIT,$0-28 66 | JMP syscall·seek(SB) 67 | -------------------------------------------------------------------------------- /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 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for AMD64, Linux 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 | JMP syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | JMP syscall·Syscall6(SB) 22 | 23 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 24 | CALL runtime·entersyscall(SB) 25 | MOVQ a1+8(FP), DI 26 | MOVQ a2+16(FP), SI 27 | MOVQ a3+24(FP), DX 28 | MOVQ $0, R10 29 | MOVQ $0, R8 30 | MOVQ $0, R9 31 | MOVQ trap+0(FP), AX // syscall entry 32 | SYSCALL 33 | MOVQ AX, r1+32(FP) 34 | MOVQ DX, r2+40(FP) 35 | CALL runtime·exitsyscall(SB) 36 | RET 37 | 38 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 39 | JMP syscall·RawSyscall(SB) 40 | 41 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 42 | JMP syscall·RawSyscall6(SB) 43 | 44 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 45 | MOVQ a1+8(FP), DI 46 | MOVQ a2+16(FP), SI 47 | MOVQ a3+24(FP), DX 48 | MOVQ $0, R10 49 | MOVQ $0, R8 50 | MOVQ $0, R9 51 | MOVQ trap+0(FP), AX // syscall entry 52 | SYSCALL 53 | MOVQ AX, r1+32(FP) 54 | MOVQ DX, r2+40(FP) 55 | RET 56 | 57 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 58 | JMP syscall·gettimeofday(SB) 59 | -------------------------------------------------------------------------------- /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 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for arm, Linux 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 ·SyscallNoError(SB),NOSPLIT,$0-24 24 | BL runtime·entersyscall(SB) 25 | MOVW trap+0(FP), R7 26 | MOVW a1+4(FP), R0 27 | MOVW a2+8(FP), R1 28 | MOVW a3+12(FP), R2 29 | MOVW $0, R3 30 | MOVW $0, R4 31 | MOVW $0, R5 32 | SWI $0 33 | MOVW R0, r1+16(FP) 34 | MOVW $0, R0 35 | MOVW R0, r2+20(FP) 36 | BL runtime·exitsyscall(SB) 37 | RET 38 | 39 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 40 | B syscall·RawSyscall(SB) 41 | 42 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 43 | B syscall·RawSyscall6(SB) 44 | 45 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 46 | MOVW trap+0(FP), R7 // syscall entry 47 | MOVW a1+4(FP), R0 48 | MOVW a2+8(FP), R1 49 | MOVW a3+12(FP), R2 50 | SWI $0 51 | MOVW R0, r1+16(FP) 52 | MOVW $0, R0 53 | MOVW R0, r2+20(FP) 54 | RET 55 | 56 | TEXT ·seek(SB),NOSPLIT,$0-28 57 | B syscall·seek(SB) 58 | -------------------------------------------------------------------------------- /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 | //go:build linux && arm64 && gc 6 | // +build linux 7 | // +build arm64 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // Just jump to package syscall's implementation for all these functions. 13 | // The runtime may know about them. 14 | 15 | TEXT ·Syscall(SB),NOSPLIT,$0-56 16 | B syscall·Syscall(SB) 17 | 18 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 19 | B syscall·Syscall6(SB) 20 | 21 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 22 | BL runtime·entersyscall(SB) 23 | MOVD a1+8(FP), R0 24 | MOVD a2+16(FP), R1 25 | MOVD a3+24(FP), R2 26 | MOVD $0, R3 27 | MOVD $0, R4 28 | MOVD $0, R5 29 | MOVD trap+0(FP), R8 // syscall entry 30 | SVC 31 | MOVD R0, r1+32(FP) // r1 32 | MOVD R1, r2+40(FP) // r2 33 | BL runtime·exitsyscall(SB) 34 | RET 35 | 36 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 37 | B syscall·RawSyscall(SB) 38 | 39 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 40 | B syscall·RawSyscall6(SB) 41 | 42 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 43 | MOVD a1+8(FP), R0 44 | MOVD a2+16(FP), R1 45 | MOVD a3+24(FP), R2 46 | MOVD $0, R3 47 | MOVD $0, R4 48 | MOVD $0, R5 49 | MOVD trap+0(FP), R8 // syscall entry 50 | SVC 51 | MOVD R0, r1+32(FP) 52 | MOVD R1, r2+40(FP) 53 | RET 54 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_loong64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2022 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 | //go:build linux && loong64 && gc 6 | // +build linux 7 | // +build loong64 8 | // +build gc 9 | 10 | #include "textflag.h" 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 ·SyscallNoError(SB),NOSPLIT,$0-48 23 | JAL runtime·entersyscall(SB) 24 | MOVV a1+8(FP), R4 25 | MOVV a2+16(FP), R5 26 | MOVV a3+24(FP), R6 27 | MOVV R0, R7 28 | MOVV R0, R8 29 | MOVV R0, R9 30 | MOVV trap+0(FP), R11 // syscall entry 31 | SYSCALL 32 | MOVV R4, r1+32(FP) 33 | MOVV R0, r2+40(FP) // r2 is not used. Always set to 0 34 | JAL runtime·exitsyscall(SB) 35 | RET 36 | 37 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 38 | JMP syscall·RawSyscall(SB) 39 | 40 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 41 | JMP syscall·RawSyscall6(SB) 42 | 43 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 44 | MOVV a1+8(FP), R4 45 | MOVV a2+16(FP), R5 46 | MOVV a3+24(FP), R6 47 | MOVV R0, R7 48 | MOVV R0, R8 49 | MOVV R0, R9 50 | MOVV trap+0(FP), R11 // syscall entry 51 | SYSCALL 52 | MOVV R4, r1+32(FP) 53 | MOVV R0, r2+40(FP) // r2 is not used. Always set to 0 54 | RET 55 | -------------------------------------------------------------------------------- /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 | //go:build linux && (mips64 || mips64le) && gc 6 | // +build linux 7 | // +build mips64 mips64le 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // 13 | // System calls for mips64, Linux 14 | // 15 | 16 | // Just jump to package syscall's implementation for all these functions. 17 | // The runtime may know about them. 18 | 19 | TEXT ·Syscall(SB),NOSPLIT,$0-56 20 | JMP syscall·Syscall(SB) 21 | 22 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 23 | JMP syscall·Syscall6(SB) 24 | 25 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 26 | JAL runtime·entersyscall(SB) 27 | MOVV a1+8(FP), R4 28 | MOVV a2+16(FP), R5 29 | MOVV a3+24(FP), R6 30 | MOVV R0, R7 31 | MOVV R0, R8 32 | MOVV R0, R9 33 | MOVV trap+0(FP), R2 // syscall entry 34 | SYSCALL 35 | MOVV R2, r1+32(FP) 36 | MOVV R3, r2+40(FP) 37 | JAL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 41 | JMP syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 44 | JMP syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 47 | MOVV a1+8(FP), R4 48 | MOVV a2+16(FP), R5 49 | MOVV a3+24(FP), R6 50 | MOVV R0, R7 51 | MOVV R0, R8 52 | MOVV R0, R9 53 | MOVV trap+0(FP), R2 // syscall entry 54 | SYSCALL 55 | MOVV R2, r1+32(FP) 56 | MOVV R3, r2+40(FP) 57 | RET 58 | -------------------------------------------------------------------------------- /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 | //go:build linux && (mips || mipsle) && gc 6 | // +build linux 7 | // +build mips mipsle 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // 13 | // System calls for mips, Linux 14 | // 15 | 16 | // Just jump to package syscall's implementation for all these functions. 17 | // The runtime may know about them. 18 | 19 | TEXT ·Syscall(SB),NOSPLIT,$0-28 20 | JMP syscall·Syscall(SB) 21 | 22 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 23 | JMP syscall·Syscall6(SB) 24 | 25 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 26 | JMP syscall·Syscall9(SB) 27 | 28 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-24 29 | JAL runtime·entersyscall(SB) 30 | MOVW a1+4(FP), R4 31 | MOVW a2+8(FP), R5 32 | MOVW a3+12(FP), R6 33 | MOVW R0, R7 34 | MOVW trap+0(FP), R2 // syscall entry 35 | SYSCALL 36 | MOVW R2, r1+16(FP) // r1 37 | MOVW R3, r2+20(FP) // r2 38 | JAL runtime·exitsyscall(SB) 39 | RET 40 | 41 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 42 | JMP syscall·RawSyscall(SB) 43 | 44 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 45 | JMP syscall·RawSyscall6(SB) 46 | 47 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24 48 | MOVW a1+4(FP), R4 49 | MOVW a2+8(FP), R5 50 | MOVW a3+12(FP), R6 51 | MOVW trap+0(FP), R2 // syscall entry 52 | SYSCALL 53 | MOVW R2, r1+16(FP) 54 | MOVW R3, r2+20(FP) 55 | RET 56 | -------------------------------------------------------------------------------- /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 | //go:build linux && (ppc64 || ppc64le) && gc 6 | // +build linux 7 | // +build ppc64 ppc64le 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // 13 | // System calls for ppc64, Linux 14 | // 15 | 16 | // Just jump to package syscall's implementation for all these functions. 17 | // The runtime may know about them. 18 | 19 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 20 | BL runtime·entersyscall(SB) 21 | MOVD a1+8(FP), R3 22 | MOVD a2+16(FP), R4 23 | MOVD a3+24(FP), R5 24 | MOVD R0, R6 25 | MOVD R0, R7 26 | MOVD R0, R8 27 | MOVD trap+0(FP), R9 // syscall entry 28 | SYSCALL R9 29 | MOVD R3, r1+32(FP) 30 | MOVD R4, r2+40(FP) 31 | BL runtime·exitsyscall(SB) 32 | RET 33 | 34 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 35 | MOVD a1+8(FP), R3 36 | MOVD a2+16(FP), R4 37 | MOVD a3+24(FP), R5 38 | MOVD R0, R6 39 | MOVD R0, R7 40 | MOVD R0, R8 41 | MOVD trap+0(FP), R9 // syscall entry 42 | SYSCALL R9 43 | MOVD R3, r1+32(FP) 44 | MOVD R4, r2+40(FP) 45 | RET 46 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_riscv64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 | //go:build riscv64 && gc 6 | // +build riscv64 7 | // +build gc 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for linux/riscv64. 13 | // 14 | // Where available, just jump to package syscall's implementation of 15 | // these functions. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | JMP syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | JMP syscall·Syscall6(SB) 22 | 23 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 24 | CALL runtime·entersyscall(SB) 25 | MOV a1+8(FP), A0 26 | MOV a2+16(FP), A1 27 | MOV a3+24(FP), A2 28 | MOV trap+0(FP), A7 // syscall entry 29 | ECALL 30 | MOV A0, r1+32(FP) // r1 31 | MOV A1, r2+40(FP) // r2 32 | CALL runtime·exitsyscall(SB) 33 | RET 34 | 35 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 36 | JMP syscall·RawSyscall(SB) 37 | 38 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 39 | JMP syscall·RawSyscall6(SB) 40 | 41 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 42 | MOV a1+8(FP), A0 43 | MOV a2+16(FP), A1 44 | MOV a3+24(FP), A2 45 | MOV trap+0(FP), A7 // syscall entry 46 | ECALL 47 | MOV A0, r1+32(FP) 48 | MOV A1, r2+40(FP) 49 | RET 50 | -------------------------------------------------------------------------------- /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 | //go:build linux && s390x && gc 6 | // +build linux 7 | // +build s390x 8 | // +build gc 9 | 10 | #include "textflag.h" 11 | 12 | // 13 | // System calls for s390x, Linux 14 | // 15 | 16 | // Just jump to package syscall's implementation for all these functions. 17 | // The runtime may know about them. 18 | 19 | TEXT ·Syscall(SB),NOSPLIT,$0-56 20 | BR syscall·Syscall(SB) 21 | 22 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 23 | BR syscall·Syscall6(SB) 24 | 25 | TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 26 | BL runtime·entersyscall(SB) 27 | MOVD a1+8(FP), R2 28 | MOVD a2+16(FP), R3 29 | MOVD a3+24(FP), R4 30 | MOVD $0, R5 31 | MOVD $0, R6 32 | MOVD $0, R7 33 | MOVD trap+0(FP), R1 // syscall entry 34 | SYSCALL 35 | MOVD R2, r1+32(FP) 36 | MOVD R3, r2+40(FP) 37 | BL runtime·exitsyscall(SB) 38 | RET 39 | 40 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 41 | BR syscall·RawSyscall(SB) 42 | 43 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 44 | BR syscall·RawSyscall6(SB) 45 | 46 | TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 47 | MOVD a1+8(FP), R2 48 | MOVD a2+16(FP), R3 49 | MOVD a3+24(FP), R4 50 | MOVD $0, R5 51 | MOVD $0, R6 52 | MOVD $0, R7 53 | MOVD trap+0(FP), R1 // syscall entry 54 | SYSCALL 55 | MOVD R2, r1+32(FP) 56 | MOVD R3, r2+40(FP) 57 | RET 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for mips64, OpenBSD 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 | JMP syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | JMP syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | JMP syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | JMP syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | JMP syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /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 | //go:build gc 6 | // +build gc 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 12 | // 13 | 14 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 15 | JMP syscall·sysvicall6(SB) 16 | 17 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 18 | JMP syscall·rawSysvicall6(SB) 19 | -------------------------------------------------------------------------------- /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 | HCI_CHANNEL_LOGGING = 4 27 | ) 28 | 29 | // Socketoption Level 30 | const ( 31 | SOL_BLUETOOTH = 0x112 32 | SOL_HCI = 0x0 33 | SOL_L2CAP = 0x6 34 | SOL_RFCOMM = 0x12 35 | SOL_SCO = 0x11 36 | ) 37 | -------------------------------------------------------------------------------- /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 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | package unix 9 | 10 | const ( 11 | R_OK = 0x4 12 | W_OK = 0x2 13 | X_OK = 0x1 14 | ) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build aix && ppc 6 | // +build aix,ppc 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used by AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev >> 16) & 0xffff) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32(dev & 0xffff) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | return uint64(((major) << 16) | (minor)) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build aix && ppc64 6 | // +build aix,ppc64 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used AIX. 10 | 11 | package unix 12 | 13 | // Major returns the major component of a Linux device number. 14 | func Major(dev uint64) uint32 { 15 | return uint32((dev & 0x3fffffff00000000) >> 32) 16 | } 17 | 18 | // Minor returns the minor component of a Linux device number. 19 | func Minor(dev uint64) uint32 { 20 | return uint32((dev & 0x00000000ffffffff) >> 0) 21 | } 22 | 23 | // Mkdev returns a Linux device number generated from the given major and minor 24 | // components. 25 | func Mkdev(major, minor uint32) uint64 { 26 | var DEVNO64 uint64 27 | DEVNO64 = 0x8000000000000000 28 | return ((uint64(major) << 32) | (uint64(minor) & 0x00000000FFFFFFFF) | DEVNO64) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Darwin's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a Darwin device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev >> 24) & 0xff) 13 | } 14 | 15 | // Minor returns the minor component of a Darwin device number. 16 | func Minor(dev uint64) uint32 { 17 | return uint32(dev & 0xffffff) 18 | } 19 | 20 | // Mkdev returns a Darwin device number generated from the given major and minor 21 | // components. 22 | func Mkdev(major, minor uint32) uint64 { 23 | return (uint64(major) << 24) | uint64(minor) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Dragonfly's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a DragonFlyBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a DragonFlyBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in FreeBSD's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a FreeBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a FreeBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a FreeBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used by the Linux kernel and glibc. 7 | // 8 | // The information below is extracted and adapted from bits/sysmacros.h in the 9 | // glibc sources: 10 | // 11 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 12 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 13 | // number and m is a hex digit of the minor number. This is backward compatible 14 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 15 | // backward compatible with the Linux kernel, which for some architectures uses 16 | // 32-bit dev_t, encoded as mmmM MMmm. 17 | 18 | package unix 19 | 20 | // Major returns the major component of a Linux device number. 21 | func Major(dev uint64) uint32 { 22 | major := uint32((dev & 0x00000000000fff00) >> 8) 23 | major |= uint32((dev & 0xfffff00000000000) >> 32) 24 | return major 25 | } 26 | 27 | // Minor returns the minor component of a Linux device number. 28 | func Minor(dev uint64) uint32 { 29 | minor := uint32((dev & 0x00000000000000ff) >> 0) 30 | minor |= uint32((dev & 0x00000ffffff00000) >> 12) 31 | return minor 32 | } 33 | 34 | // Mkdev returns a Linux device number generated from the given major and minor 35 | // components. 36 | func Mkdev(major, minor uint32) uint64 { 37 | dev := (uint64(major) & 0x00000fff) << 8 38 | dev |= (uint64(major) & 0xfffff000) << 32 39 | dev |= (uint64(minor) & 0x000000ff) << 0 40 | dev |= (uint64(minor) & 0xffffff00) << 12 41 | return dev 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in NetBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a NetBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x000fff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of a NetBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xfff00000) >> 12) 19 | return minor 20 | } 21 | 22 | // Mkdev returns a NetBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x000fff00 26 | dev |= (uint64(minor) << 12) & 0xfff00000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in OpenBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of an OpenBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x0000ff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of an OpenBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xffff0000) >> 8) 19 | return minor 20 | } 21 | 22 | // Mkdev returns an OpenBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x0000ff00 26 | dev |= (uint64(minor) << 8) & 0xffff0000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_zos.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 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 | //go:build zos && s390x 6 | // +build zos,s390x 7 | 8 | // Functions to access/create device major and minor numbers matching the 9 | // encoding used by z/OS. 10 | // 11 | // The information below is extracted and adapted from macros. 12 | 13 | package unix 14 | 15 | // Major returns the major component of a z/OS device number. 16 | func Major(dev uint64) uint32 { 17 | return uint32((dev >> 16) & 0x0000FFFF) 18 | } 19 | 20 | // Minor returns the minor component of a z/OS device number. 21 | func Minor(dev uint64) uint32 { 22 | return uint32(dev & 0x0000FFFF) 23 | } 24 | 25 | // Mkdev returns a z/OS device number generated from the given major and minor 26 | // components. 27 | func Mkdev(major, minor uint32) uint64 { 28 | return (uint64(major) << 16) | uint64(minor) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dirent.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 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | package unix 9 | 10 | import "unsafe" 11 | 12 | // readInt returns the size-bytes unsigned integer in native byte order at offset off. 13 | func readInt(b []byte, off, size uintptr) (u uint64, ok bool) { 14 | if len(b) < int(off+size) { 15 | return 0, false 16 | } 17 | if isBigEndian { 18 | return readIntBE(b[off:], size), true 19 | } 20 | return readIntLE(b[off:], size), true 21 | } 22 | 23 | func readIntBE(b []byte, size uintptr) uint64 { 24 | switch size { 25 | case 1: 26 | return uint64(b[0]) 27 | case 2: 28 | _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808 29 | return uint64(b[1]) | uint64(b[0])<<8 30 | case 4: 31 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 32 | return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24 33 | case 8: 34 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 35 | return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | 36 | uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 37 | default: 38 | panic("syscall: readInt with unsupported size") 39 | } 40 | } 41 | 42 | func readIntLE(b []byte, size uintptr) uint64 { 43 | switch size { 44 | case 1: 45 | return uint64(b[0]) 46 | case 2: 47 | _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808 48 | return uint64(b[0]) | uint64(b[1])<<8 49 | case 4: 50 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 51 | return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 52 | case 8: 53 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 54 | return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | 55 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 56 | default: 57 | panic("syscall: readInt with unsupported size") 58 | } 59 | } 60 | 61 | // ParseDirent parses up to max directory entries in buf, 62 | // appending the names to names. It returns the number of 63 | // bytes consumed from buf, the number of entries added 64 | // to names, and the new names slice. 65 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { 66 | origlen := len(buf) 67 | count = 0 68 | for max != 0 && len(buf) > 0 { 69 | reclen, ok := direntReclen(buf) 70 | if !ok || reclen > uint64(len(buf)) { 71 | return origlen, count, names 72 | } 73 | rec := buf[:reclen] 74 | buf = buf[reclen:] 75 | ino, ok := direntIno(rec) 76 | if !ok { 77 | break 78 | } 79 | if ino == 0 { // File absent in directory. 80 | continue 81 | } 82 | const namoff = uint64(unsafe.Offsetof(Dirent{}.Name)) 83 | namlen, ok := direntNamlen(rec) 84 | if !ok || namoff+namlen > uint64(len(rec)) { 85 | break 86 | } 87 | name := rec[namoff : namoff+namlen] 88 | for i, c := range name { 89 | if c == 0 { 90 | name = name[:i] 91 | break 92 | } 93 | } 94 | // Check for useless names before allocating a string. 95 | if string(name) == "." || string(name) == ".." { 96 | continue 97 | } 98 | max-- 99 | count++ 100 | names = append(names, string(name)) 101 | } 102 | return origlen - len(buf), count, names 103 | } 104 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.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 | //go:build armbe || arm64be || m68k || mips || mips64 || mips64p32 || ppc || ppc64 || s390 || s390x || shbe || sparc || sparc64 6 | // +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64 7 | 8 | package unix 9 | 10 | const isBigEndian = true 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.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 | //go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh 6 | // +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh 7 | 8 | package unix 9 | 10 | const isBigEndian = false 11 | -------------------------------------------------------------------------------- /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 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | // Unix environment variables. 9 | 10 | package unix 11 | 12 | import "syscall" 13 | 14 | func Getenv(key string) (value string, found bool) { 15 | return syscall.Getenv(key) 16 | } 17 | 18 | func Setenv(key, value string) error { 19 | return syscall.Setenv(key, value) 20 | } 21 | 22 | func Clearenv() { 23 | syscall.Clearenv() 24 | } 25 | 26 | func Environ() []string { 27 | return syscall.Environ() 28 | } 29 | 30 | func Unsetenv(key string) error { 31 | return syscall.Unsetenv(key) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl.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 | //go:build dragonfly || freebsd || linux || netbsd || openbsd 6 | // +build dragonfly freebsd linux netbsd openbsd 7 | 8 | package unix 9 | 10 | import "unsafe" 11 | 12 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 13 | // systems by fcntl_linux_32bit.go to be SYS_FCNTL64. 14 | var fcntl64Syscall uintptr = SYS_FCNTL 15 | 16 | func fcntl(fd int, cmd, arg int) (int, error) { 17 | valptr, _, errno := Syscall(fcntl64Syscall, uintptr(fd), uintptr(cmd), uintptr(arg)) 18 | var err error 19 | if errno != 0 { 20 | err = errno 21 | } 22 | return int(valptr), err 23 | } 24 | 25 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 26 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 27 | return fcntl(int(fd), cmd, arg) 28 | } 29 | 30 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 31 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 32 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 33 | if errno == 0 { 34 | return nil 35 | } 36 | return errno 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 "unsafe" 8 | 9 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 10 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 11 | return fcntl(int(fd), cmd, arg) 12 | } 13 | 14 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 15 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 16 | _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk)))) 17 | return err 18 | } 19 | 20 | // FcntlFstore performs a fcntl syscall for the F_PREALLOCATE command. 21 | func FcntlFstore(fd uintptr, cmd int, fstore *Fstore_t) error { 22 | _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(fstore)))) 23 | return err 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fcntl_linux_32bit.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 | //go:build (linux && 386) || (linux && arm) || (linux && mips) || (linux && mipsle) || (linux && ppc) 6 | // +build linux,386 linux,arm linux,mips linux,mipsle linux,ppc 7 | 8 | package unix 9 | 10 | func init() { 11 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 12 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 13 | fcntl64Syscall = SYS_FCNTL64 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/fdset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | package unix 9 | 10 | // Set adds fd to the set fds. 11 | func (fds *FdSet) Set(fd int) { 12 | fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS)) 13 | } 14 | 15 | // Clear removes fd from the set fds. 16 | func (fds *FdSet) Clear(fd int) { 17 | fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS)) 18 | } 19 | 20 | // IsSet returns whether fd is in the set fds. 21 | func (fds *FdSet) IsSet(fd int) bool { 22 | return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0 23 | } 24 | 25 | // Zero clears the set fds. 26 | func (fds *FdSet) Zero() { 27 | for i := range fds.Bits { 28 | fds.Bits[i] = 0 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /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 | //go:build gccgo && !aix && !hurd 6 | // +build gccgo,!aix,!hurd 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | // We can't use the gc-syntax .s files for gccgo. On the plus side 13 | // much of the functionality can be written directly in Go. 14 | 15 | func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr) 16 | 17 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 18 | 19 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 20 | syscall.Entersyscall() 21 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 22 | syscall.Exitsyscall() 23 | return r, 0 24 | } 25 | 26 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 27 | syscall.Entersyscall() 28 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 29 | syscall.Exitsyscall() 30 | return r, 0, syscall.Errno(errno) 31 | } 32 | 33 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 34 | syscall.Entersyscall() 35 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 36 | syscall.Exitsyscall() 37 | return r, 0, syscall.Errno(errno) 38 | } 39 | 40 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 41 | syscall.Entersyscall() 42 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 43 | syscall.Exitsyscall() 44 | return r, 0, syscall.Errno(errno) 45 | } 46 | 47 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { 48 | r := realSyscallNoError(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 49 | return r, 0 50 | } 51 | 52 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 53 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 54 | return r, 0, syscall.Errno(errno) 55 | } 56 | 57 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 58 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 59 | return r, 0, syscall.Errno(errno) 60 | } 61 | -------------------------------------------------------------------------------- /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,!hurd 6 | // +build !aix,!hurd 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define _STRINGIFY2_(x) #x 13 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 14 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 15 | 16 | // Call syscall from C code because the gccgo support for calling from 17 | // Go to C does not support varargs functions. 18 | 19 | struct ret { 20 | uintptr_t r; 21 | uintptr_t err; 22 | }; 23 | 24 | struct ret 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 | __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscall"); 26 | 27 | struct ret 28 | 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) 29 | { 30 | struct ret r; 31 | 32 | errno = 0; 33 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 34 | r.err = errno; 35 | return r; 36 | } 37 | 38 | uintptr_t gccgoRealSyscallNoError(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) 39 | __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscallNoError"); 40 | 41 | uintptr_t 42 | gccgoRealSyscallNoError(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) 43 | { 44 | return syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 45 | } 46 | -------------------------------------------------------------------------------- /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 | //go:build gccgo && linux && amd64 6 | // +build gccgo,linux,amd64 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //extern gettimeofday 13 | func realGettimeofday(*Timeval, *byte) int32 14 | 15 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 16 | r := realGettimeofday(tv, nil) 17 | if r < 0 { 18 | return syscall.GetErrno() 19 | } 20 | return 0 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build aix || darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd || solaris 6 | // +build aix darwin dragonfly freebsd hurd linux netbsd openbsd solaris 7 | 8 | package unix 9 | 10 | import ( 11 | "runtime" 12 | "unsafe" 13 | ) 14 | 15 | // ioctl itself should not be exposed directly, but additional get/set 16 | // functions for specific types are permissible. 17 | 18 | // IoctlSetInt performs an ioctl operation which sets an integer value 19 | // on fd, using the specified request number. 20 | func IoctlSetInt(fd int, req uint, value int) error { 21 | return ioctl(fd, req, uintptr(value)) 22 | } 23 | 24 | // IoctlSetPointerInt performs an ioctl operation which sets an 25 | // integer value on fd, using the specified request number. The ioctl 26 | // argument is called with a pointer to the integer value, rather than 27 | // passing the integer value directly. 28 | func IoctlSetPointerInt(fd int, req uint, value int) error { 29 | v := int32(value) 30 | return ioctl(fd, req, uintptr(unsafe.Pointer(&v))) 31 | } 32 | 33 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 34 | // 35 | // To change fd's window size, the req argument should be TIOCSWINSZ. 36 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 37 | // TODO: if we get the chance, remove the req parameter and 38 | // hardcode TIOCSWINSZ. 39 | err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) 40 | runtime.KeepAlive(value) 41 | return err 42 | } 43 | 44 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 45 | // 46 | // The req value will usually be TCSETA or TIOCSETA. 47 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 48 | // TODO: if we get the chance, remove the req parameter. 49 | err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) 50 | runtime.KeepAlive(value) 51 | return err 52 | } 53 | 54 | // IoctlGetInt performs an ioctl operation which gets an integer value 55 | // from fd, using the specified request number. 56 | // 57 | // A few ioctl requests use the return value as an output parameter; 58 | // for those, IoctlRetInt should be used instead of this function. 59 | func IoctlGetInt(fd int, req uint) (int, error) { 60 | var value int 61 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 62 | return value, err 63 | } 64 | 65 | func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { 66 | var value Winsize 67 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 68 | return &value, err 69 | } 70 | 71 | func IoctlGetTermios(fd int, req uint) (*Termios, error) { 72 | var value Termios 73 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 74 | return &value, err 75 | } 76 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ioctl_zos.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 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 | //go:build zos && s390x 6 | // +build zos,s390x 7 | 8 | package unix 9 | 10 | import ( 11 | "runtime" 12 | "unsafe" 13 | ) 14 | 15 | // ioctl itself should not be exposed directly, but additional get/set 16 | // functions for specific types are permissible. 17 | 18 | // IoctlSetInt performs an ioctl operation which sets an integer value 19 | // on fd, using the specified request number. 20 | func IoctlSetInt(fd int, req uint, value int) error { 21 | return ioctl(fd, req, uintptr(value)) 22 | } 23 | 24 | // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument. 25 | // 26 | // To change fd's window size, the req argument should be TIOCSWINSZ. 27 | func IoctlSetWinsize(fd int, req uint, value *Winsize) error { 28 | // TODO: if we get the chance, remove the req parameter and 29 | // hardcode TIOCSWINSZ. 30 | err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) 31 | runtime.KeepAlive(value) 32 | return err 33 | } 34 | 35 | // IoctlSetTermios performs an ioctl on fd with a *Termios. 36 | // 37 | // The req value is expected to be TCSETS, TCSETSW, or TCSETSF 38 | func IoctlSetTermios(fd int, req uint, value *Termios) error { 39 | if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) { 40 | return ENOSYS 41 | } 42 | err := Tcsetattr(fd, int(req), value) 43 | runtime.KeepAlive(value) 44 | return err 45 | } 46 | 47 | // IoctlGetInt performs an ioctl operation which gets an integer value 48 | // from fd, using the specified request number. 49 | // 50 | // A few ioctl requests use the return value as an output parameter; 51 | // for those, IoctlRetInt should be used instead of this function. 52 | func IoctlGetInt(fd int, req uint) (int, error) { 53 | var value int 54 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 55 | return value, err 56 | } 57 | 58 | func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { 59 | var value Winsize 60 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) 61 | return &value, err 62 | } 63 | 64 | // IoctlGetTermios performs an ioctl on fd with a *Termios. 65 | // 66 | // The req value is expected to be TCGETS 67 | func IoctlGetTermios(fd int, req uint) (*Termios, error) { 68 | var value Termios 69 | if req != TCGETS { 70 | return &value, ENOSYS 71 | } 72 | err := Tcgetattr(fd, &value) 73 | return &value, err 74 | } 75 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/pagesize_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 7 | 8 | // For Unix, get the pagesize from the runtime. 9 | 10 | package unix 11 | 12 | import "syscall" 13 | 14 | func Getpagesize() int { 15 | return syscall.Getpagesize() 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ptrace_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 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 | //go:build darwin && !ios 6 | // +build darwin,!ios 7 | 8 | package unix 9 | 10 | func ptrace(request int, pid int, addr uintptr, data uintptr) error { 11 | return ptrace1(request, pid, addr, data) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/ptrace_ios.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 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 | //go:build ios 6 | // +build ios 7 | 8 | package unix 9 | 10 | func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { 11 | return ENOTSUP 12 | } 13 | -------------------------------------------------------------------------------- /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 | //go:build (darwin && race) || (linux && race) || (freebsd && race) 6 | // +build darwin,race linux,race freebsd,race 7 | 8 | package unix 9 | 10 | import ( 11 | "runtime" 12 | "unsafe" 13 | ) 14 | 15 | const raceenabled = true 16 | 17 | func raceAcquire(addr unsafe.Pointer) { 18 | runtime.RaceAcquire(addr) 19 | } 20 | 21 | func raceReleaseMerge(addr unsafe.Pointer) { 22 | runtime.RaceReleaseMerge(addr) 23 | } 24 | 25 | func raceReadRange(addr unsafe.Pointer, len int) { 26 | runtime.RaceReadRange(addr, len) 27 | } 28 | 29 | func raceWriteRange(addr unsafe.Pointer, len int) { 30 | runtime.RaceWriteRange(addr, len) 31 | } 32 | -------------------------------------------------------------------------------- /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 | //go:build aix || (darwin && !race) || (linux && !race) || (freebsd && !race) || netbsd || openbsd || solaris || dragonfly || zos 6 | // +build aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly zos 7 | 8 | package unix 9 | 10 | import ( 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = false 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | } 18 | 19 | func raceReleaseMerge(addr unsafe.Pointer) { 20 | } 21 | 22 | func raceReadRange(addr unsafe.Pointer, len int) { 23 | } 24 | 25 | func raceWriteRange(addr unsafe.Pointer, len int) { 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/readdirent_getdents.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 | //go:build aix || dragonfly || freebsd || linux || netbsd || openbsd 6 | // +build aix dragonfly freebsd linux netbsd openbsd 7 | 8 | package unix 9 | 10 | // ReadDirent reads directory entries from fd and writes them into buf. 11 | func ReadDirent(fd int, buf []byte) (n int, err error) { 12 | return Getdents(fd, buf) 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/readdirent_getdirentries.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 | //go:build darwin 6 | // +build darwin 7 | 8 | package unix 9 | 10 | import "unsafe" 11 | 12 | // ReadDirent reads directory entries from fd and writes them into buf. 13 | func ReadDirent(fd int, buf []byte) (n int, err error) { 14 | // Final argument is (basep *uintptr) and the syscall doesn't take nil. 15 | // 64 bits should be enough. (32 bits isn't even on 386). Since the 16 | // actual system call is getdirentries64, 64 is a good guess. 17 | // TODO(rsc): Can we use a single global basep for all calls? 18 | var base = (*uintptr)(unsafe.Pointer(new(uint64))) 19 | return Getdirentries(fd, buf, base) 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 | // Round the length of a raw sockaddr up to align it properly. 8 | func cmsgAlignOf(salen int) int { 9 | salign := SizeofPtr 10 | if SizeofPtr == 8 && !supportsABI(_dragonflyABIChangeVersion) { 11 | // 64-bit Dragonfly before the September 2019 ABI changes still requires 12 | // 32-bit aligned access to network subsystem. 13 | salign = 4 14 | } 15 | return (salen + salign - 1) & ^(salign - 1) 16 | } 17 | -------------------------------------------------------------------------------- /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)(h.data(0)) = *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 | 38 | // PktInfo4 encodes Inet4Pktinfo into a socket control message of type IP_PKTINFO. 39 | func PktInfo4(info *Inet4Pktinfo) []byte { 40 | b := make([]byte, CmsgSpace(SizeofInet4Pktinfo)) 41 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 42 | h.Level = SOL_IP 43 | h.Type = IP_PKTINFO 44 | h.SetLen(CmsgLen(SizeofInet4Pktinfo)) 45 | *(*Inet4Pktinfo)(h.data(0)) = *info 46 | return b 47 | } 48 | 49 | // PktInfo6 encodes Inet6Pktinfo into a socket control message of type IPV6_PKTINFO. 50 | func PktInfo6(info *Inet6Pktinfo) []byte { 51 | b := make([]byte, CmsgSpace(SizeofInet6Pktinfo)) 52 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 53 | h.Level = SOL_IPV6 54 | h.Type = IPV6_PKTINFO 55 | h.SetLen(CmsgLen(SizeofInet6Pktinfo)) 56 | *(*Inet6Pktinfo)(h.data(0)) = *info 57 | return b 58 | } 59 | 60 | // ParseOrigDstAddr decodes a socket control message containing the original 61 | // destination address. To receive such a message the IP_RECVORIGDSTADDR or 62 | // IPV6_RECVORIGDSTADDR option must be enabled on the socket. 63 | func ParseOrigDstAddr(m *SocketControlMessage) (Sockaddr, error) { 64 | switch { 65 | case m.Header.Level == SOL_IP && m.Header.Type == IP_ORIGDSTADDR: 66 | pp := (*RawSockaddrInet4)(unsafe.Pointer(&m.Data[0])) 67 | sa := new(SockaddrInet4) 68 | p := (*[2]byte)(unsafe.Pointer(&pp.Port)) 69 | sa.Port = int(p[0])<<8 + int(p[1]) 70 | sa.Addr = pp.Addr 71 | return sa, nil 72 | 73 | case m.Header.Level == SOL_IPV6 && m.Header.Type == IPV6_ORIGDSTADDR: 74 | pp := (*RawSockaddrInet6)(unsafe.Pointer(&m.Data[0])) 75 | sa := new(SockaddrInet6) 76 | p := (*[2]byte)(unsafe.Pointer(&pp.Port)) 77 | sa.Port = int(p[0])<<8 + int(p[1]) 78 | sa.ZoneId = pp.Scope_id 79 | sa.Addr = pp.Addr 80 | return sa, nil 81 | 82 | default: 83 | return nil, EINVAL 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /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 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | // Socket control messages 9 | 10 | package unix 11 | 12 | import ( 13 | "unsafe" 14 | ) 15 | 16 | // CmsgLen returns the value to store in the Len field of the Cmsghdr 17 | // structure, taking into account any necessary alignment. 18 | func CmsgLen(datalen int) int { 19 | return cmsgAlignOf(SizeofCmsghdr) + datalen 20 | } 21 | 22 | // CmsgSpace returns the number of bytes an ancillary element with 23 | // payload of the passed data length occupies. 24 | func CmsgSpace(datalen int) int { 25 | return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) 26 | } 27 | 28 | func (h *Cmsghdr) data(offset uintptr) unsafe.Pointer { 29 | return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr)) + offset) 30 | } 31 | 32 | // SocketControlMessage represents a socket control message. 33 | type SocketControlMessage struct { 34 | Header Cmsghdr 35 | Data []byte 36 | } 37 | 38 | // ParseSocketControlMessage parses b as an array of socket control 39 | // messages. 40 | func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { 41 | var msgs []SocketControlMessage 42 | i := 0 43 | for i+CmsgLen(0) <= len(b) { 44 | h, dbuf, err := socketControlMessageHeaderAndData(b[i:]) 45 | if err != nil { 46 | return nil, err 47 | } 48 | m := SocketControlMessage{Header: *h, Data: dbuf} 49 | msgs = append(msgs, m) 50 | i += cmsgAlignOf(int(h.Len)) 51 | } 52 | return msgs, nil 53 | } 54 | 55 | // ParseOneSocketControlMessage parses a single socket control message from b, returning the message header, 56 | // message data (a slice of b), and the remainder of b after that single message. 57 | // When there are no remaining messages, len(remainder) == 0. 58 | func ParseOneSocketControlMessage(b []byte) (hdr Cmsghdr, data []byte, remainder []byte, err error) { 59 | h, dbuf, err := socketControlMessageHeaderAndData(b) 60 | if err != nil { 61 | return Cmsghdr{}, nil, nil, err 62 | } 63 | if i := cmsgAlignOf(int(h.Len)); i < len(b) { 64 | remainder = b[i:] 65 | } 66 | return *h, dbuf, remainder, nil 67 | } 68 | 69 | func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { 70 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 71 | if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) { 72 | return nil, nil, EINVAL 73 | } 74 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 75 | } 76 | 77 | // UnixRights encodes a set of open file descriptors into a socket 78 | // control message for sending to another process. 79 | func UnixRights(fds ...int) []byte { 80 | datalen := len(fds) * 4 81 | b := make([]byte, CmsgSpace(datalen)) 82 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 83 | h.Level = SOL_SOCKET 84 | h.Type = SCM_RIGHTS 85 | h.SetLen(CmsgLen(datalen)) 86 | for i, fd := range fds { 87 | *(*int32)(h.data(4 * uintptr(i))) = int32(fd) 88 | } 89 | return b 90 | } 91 | 92 | // ParseUnixRights decodes a socket control message that contains an 93 | // integer array of open file descriptors from another process. 94 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 95 | if m.Header.Level != SOL_SOCKET { 96 | return nil, EINVAL 97 | } 98 | if m.Header.Type != SCM_RIGHTS { 99 | return nil, EINVAL 100 | } 101 | fds := make([]int, len(m.Data)>>2) 102 | for i, j := 0, 0; i < len(m.Data); i += 4 { 103 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 104 | j++ 105 | } 106 | return fds, nil 107 | } 108 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 | //go:build aix || darwin || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin freebsd linux netbsd openbsd solaris zos 7 | 8 | package unix 9 | 10 | import ( 11 | "runtime" 12 | ) 13 | 14 | // Round the length of a raw sockaddr up to align it properly. 15 | func cmsgAlignOf(salen int) int { 16 | salign := SizeofPtr 17 | 18 | // dragonfly needs to check ABI version at runtime, see cmsgAlignOf in 19 | // sockcmsg_dragonfly.go 20 | switch runtime.GOOS { 21 | case "aix": 22 | // There is no alignment on AIX. 23 | salign = 1 24 | case "darwin", "ios", "illumos", "solaris": 25 | // NOTE: It seems like 64-bit Darwin, Illumos and Solaris 26 | // kernels still require 32-bit aligned access to network 27 | // subsystem. 28 | if SizeofPtr == 8 { 29 | salign = 4 30 | } 31 | case "netbsd", "openbsd": 32 | // NetBSD and OpenBSD armv7 require 64-bit alignment. 33 | if runtime.GOARCH == "arm" { 34 | salign = 8 35 | } 36 | // NetBSD aarch64 requires 128-bit alignment. 37 | if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm64" { 38 | salign = 16 39 | } 40 | case "zos": 41 | // z/OS socket macros use [32-bit] sizeof(int) alignment, 42 | // not pointer width. 43 | salign = SizeofInt 44 | } 45 | 46 | return (salen + salign - 1) & ^(salign - 1) 47 | } 48 | -------------------------------------------------------------------------------- /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 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | // Package unix contains an interface to the low-level operating system 9 | // primitives. OS details vary depending on the underlying system, and 10 | // by default, godoc will display OS-specific documentation for the current 11 | // system. If you want godoc to display OS documentation for another 12 | // system, set $GOOS and $GOARCH to the desired system. For example, if 13 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 14 | // to freebsd and $GOARCH to arm. 15 | // 16 | // The primary use of this package is inside other packages that provide a more 17 | // portable interface to the system, such as "os", "time" and "net". Use 18 | // those packages rather than this one if you can. 19 | // 20 | // For details of the functions and data types in this package consult 21 | // the manuals for the appropriate operating system. 22 | // 23 | // These calls return err == nil to indicate success; otherwise 24 | // err represents an operating system error describing the failure and 25 | // holds a value of type syscall.Errno. 26 | package unix // import "golang.org/x/sys/unix" 27 | 28 | import ( 29 | "bytes" 30 | "strings" 31 | "unsafe" 32 | ) 33 | 34 | // ByteSliceFromString returns a NUL-terminated slice of bytes 35 | // containing the text of s. If s contains a NUL byte at any 36 | // location, it returns (nil, EINVAL). 37 | func ByteSliceFromString(s string) ([]byte, error) { 38 | if strings.IndexByte(s, 0) != -1 { 39 | return nil, EINVAL 40 | } 41 | a := make([]byte, len(s)+1) 42 | copy(a, s) 43 | return a, nil 44 | } 45 | 46 | // BytePtrFromString returns a pointer to a NUL-terminated array of 47 | // bytes containing the text of s. If s contains a NUL byte at any 48 | // location, it returns (nil, EINVAL). 49 | func BytePtrFromString(s string) (*byte, error) { 50 | a, err := ByteSliceFromString(s) 51 | if err != nil { 52 | return nil, err 53 | } 54 | return &a[0], nil 55 | } 56 | 57 | // ByteSliceToString returns a string form of the text represented by the slice s, with a terminating NUL and any 58 | // bytes after the NUL removed. 59 | func ByteSliceToString(s []byte) string { 60 | if i := bytes.IndexByte(s, 0); i != -1 { 61 | s = s[:i] 62 | } 63 | return string(s) 64 | } 65 | 66 | // BytePtrToString takes a pointer to a sequence of text and returns the corresponding string. 67 | // If the pointer is nil, it returns the empty string. It assumes that the text sequence is terminated 68 | // at a zero byte; if the zero byte is not present, the program may crash. 69 | func BytePtrToString(p *byte) string { 70 | if p == nil { 71 | return "" 72 | } 73 | if *p == 0 { 74 | return "" 75 | } 76 | 77 | // Find NUL terminator. 78 | n := 0 79 | for ptr := unsafe.Pointer(p); *(*byte)(ptr) != 0; n++ { 80 | ptr = unsafe.Pointer(uintptr(ptr) + 1) 81 | } 82 | 83 | return string(unsafe.Slice(p, n)) 84 | } 85 | 86 | // Single-word zero for use when we need a valid pointer to 0 bytes. 87 | var _zero uintptr 88 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build aix && ppc 6 | // +build aix,ppc 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = getrlimit64 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) = setrlimit64 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek64 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func Fstat(fd int, stat *Stat_t) error { 41 | return fstat(fd, stat) 42 | } 43 | 44 | func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error { 45 | return fstatat(dirfd, path, stat, flags) 46 | } 47 | 48 | func Lstat(path string, stat *Stat_t) error { 49 | return lstat(path, stat) 50 | } 51 | 52 | func Stat(path string, statptr *Stat_t) error { 53 | return stat(path, statptr) 54 | } 55 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build aix && ppc64 6 | // +build aix,ppc64 7 | 8 | package unix 9 | 10 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) 11 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 12 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = lseek 13 | 14 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) = mmap64 15 | 16 | func setTimespec(sec, nsec int64) Timespec { 17 | return Timespec{Sec: sec, Nsec: nsec} 18 | } 19 | 20 | func setTimeval(sec, usec int64) Timeval { 21 | return Timeval{Sec: int64(sec), Usec: int32(usec)} 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // In order to only have Timespec structure, type of Stat_t's fields 41 | // Atim, Mtim and Ctim is changed from StTimespec to Timespec during 42 | // ztypes generation. 43 | // On ppc64, Timespec.Nsec is an int64 while StTimespec.Nsec is an 44 | // int32, so the fields' value must be modified. 45 | func fixStatTimFields(stat *Stat_t) { 46 | stat.Atim.Nsec >>= 32 47 | stat.Mtim.Nsec >>= 32 48 | stat.Ctim.Nsec >>= 32 49 | } 50 | 51 | func Fstat(fd int, stat *Stat_t) error { 52 | err := fstat(fd, stat) 53 | if err != nil { 54 | return err 55 | } 56 | fixStatTimFields(stat) 57 | return nil 58 | } 59 | 60 | func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error { 61 | err := fstatat(dirfd, path, stat, flags) 62 | if err != nil { 63 | return err 64 | } 65 | fixStatTimFields(stat) 66 | return nil 67 | } 68 | 69 | func Lstat(path string, stat *Stat_t) error { 70 | err := lstat(path, stat) 71 | if err != nil { 72 | return err 73 | } 74 | fixStatTimFields(stat) 75 | return nil 76 | } 77 | 78 | func Stat(path string, statptr *Stat_t) error { 79 | err := stat(path, statptr) 80 | if err != nil { 81 | return err 82 | } 83 | fixStatTimFields(statptr) 84 | return nil 85 | } 86 | -------------------------------------------------------------------------------- /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 | //go:build amd64 && darwin 6 | // +build amd64,darwin 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func setTimespec(sec, nsec int64) Timespec { 13 | return Timespec{Sec: sec, Nsec: nsec} 14 | } 15 | 16 | func setTimeval(sec, usec int64) Timeval { 17 | return Timeval{Sec: sec, Usec: int32(usec)} 18 | } 19 | 20 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 21 | k.Ident = uint64(fd) 22 | k.Filter = int16(mode) 23 | k.Flags = uint16(flags) 24 | } 25 | 26 | func (iov *Iovec) SetLen(length int) { 27 | iov.Len = uint64(length) 28 | } 29 | 30 | func (msghdr *Msghdr) SetControllen(length int) { 31 | msghdr.Controllen = uint32(length) 32 | } 33 | 34 | func (msghdr *Msghdr) SetIovlen(length int) { 35 | msghdr.Iovlen = int32(length) 36 | } 37 | 38 | func (cmsg *Cmsghdr) SetLen(length int) { 39 | cmsg.Len = uint32(length) 40 | } 41 | 42 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 43 | 44 | //sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64 45 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64 46 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64 47 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64 48 | //sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64 49 | //sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace 50 | //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 51 | //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64 52 | -------------------------------------------------------------------------------- /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 | //go:build arm64 && darwin 6 | // +build arm64,darwin 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func setTimespec(sec, nsec int64) Timespec { 13 | return Timespec{Sec: sec, Nsec: nsec} 14 | } 15 | 16 | func setTimeval(sec, usec int64) Timeval { 17 | return Timeval{Sec: sec, Usec: int32(usec)} 18 | } 19 | 20 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 21 | k.Ident = uint64(fd) 22 | k.Filter = int16(mode) 23 | k.Flags = uint16(flags) 24 | } 25 | 26 | func (iov *Iovec) SetLen(length int) { 27 | iov.Len = uint64(length) 28 | } 29 | 30 | func (msghdr *Msghdr) SetControllen(length int) { 31 | msghdr.Controllen = uint32(length) 32 | } 33 | 34 | func (msghdr *Msghdr) SetIovlen(length int) { 35 | msghdr.Iovlen = int32(length) 36 | } 37 | 38 | func (cmsg *Cmsghdr) SetLen(length int) { 39 | cmsg.Len = uint32(length) 40 | } 41 | 42 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 43 | 44 | //sys Fstat(fd int, stat *Stat_t) (err error) 45 | //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) 46 | //sys Fstatfs(fd int, stat *Statfs_t) (err error) 47 | //sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT 48 | //sys Lstat(path string, stat *Stat_t) (err error) 49 | //sys ptrace1(request int, pid int, addr uintptr, data uintptr) (err error) = SYS_ptrace 50 | //sys Stat(path string, stat *Stat_t) (err error) 51 | //sys Statfs(path string, stat *Statfs_t) (err error) 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_libSystem.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build darwin && go1.12 6 | // +build darwin,go1.12 7 | 8 | package unix 9 | 10 | import _ "unsafe" 11 | 12 | // Implemented in the runtime package (runtime/sys_darwin.go) 13 | func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 14 | func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 15 | func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 16 | func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) // 32-bit only 17 | func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 18 | func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 19 | func syscall_syscallPtr(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 20 | 21 | //go:linkname syscall_syscall syscall.syscall 22 | //go:linkname syscall_syscall6 syscall.syscall6 23 | //go:linkname syscall_syscall6X syscall.syscall6X 24 | //go:linkname syscall_syscall9 syscall.syscall9 25 | //go:linkname syscall_rawSyscall syscall.rawSyscall 26 | //go:linkname syscall_rawSyscall6 syscall.rawSyscall6 27 | //go:linkname syscall_syscallPtr syscall.syscallPtr 28 | -------------------------------------------------------------------------------- /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 | //go:build amd64 && dragonfly 6 | // +build amd64,dragonfly 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: sec, Nsec: nsec} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: sec, Usec: usec} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint64(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint64(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | -------------------------------------------------------------------------------- /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 | //go:build 386 && freebsd 6 | // +build 386,freebsd 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint32(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint32(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | 59 | func PtraceGetFsBase(pid int, fsbase *int64) (err error) { 60 | return ptrace(PT_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) 61 | } 62 | 63 | func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 64 | ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint32(countin)} 65 | err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 66 | return int(ioDesc.Len), err 67 | } 68 | -------------------------------------------------------------------------------- /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 | //go:build amd64 && freebsd 6 | // +build amd64,freebsd 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: sec, Nsec: nsec} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: sec, Usec: usec} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint64(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint64(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | 59 | func PtraceGetFsBase(pid int, fsbase *int64) (err error) { 60 | return ptrace(PT_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) 61 | } 62 | 63 | func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 64 | ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint64(countin)} 65 | err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 66 | return int(ioDesc.Len), err 67 | } 68 | -------------------------------------------------------------------------------- /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 | //go:build arm && freebsd 6 | // +build arm,freebsd 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: sec, Nsec: int32(nsec)} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: sec, Usec: int32(usec)} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint32(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint32(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | 59 | func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 60 | ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint32(countin)} 61 | err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 62 | return int(ioDesc.Len), err 63 | } 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build arm64 && freebsd 6 | // +build arm64,freebsd 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: sec, Nsec: nsec} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: sec, Usec: usec} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint64(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint64(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | 59 | func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 60 | ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint64(countin)} 61 | err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 62 | return int(ioDesc.Len), err 63 | } 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 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 | //go:build riscv64 && freebsd 6 | // +build riscv64,freebsd 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func setTimespec(sec, nsec int64) Timespec { 16 | return Timespec{Sec: sec, Nsec: nsec} 17 | } 18 | 19 | func setTimeval(sec, usec int64) Timeval { 20 | return Timeval{Sec: sec, Usec: usec} 21 | } 22 | 23 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 24 | k.Ident = uint64(fd) 25 | k.Filter = int16(mode) 26 | k.Flags = uint16(flags) 27 | } 28 | 29 | func (iov *Iovec) SetLen(length int) { 30 | iov.Len = uint64(length) 31 | } 32 | 33 | func (msghdr *Msghdr) SetControllen(length int) { 34 | msghdr.Controllen = uint32(length) 35 | } 36 | 37 | func (msghdr *Msghdr) SetIovlen(length int) { 38 | msghdr.Iovlen = int32(length) 39 | } 40 | 41 | func (cmsg *Cmsghdr) SetLen(length int) { 42 | cmsg.Len = uint32(length) 43 | } 44 | 45 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 46 | var writtenOut uint64 = 0 47 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 48 | 49 | written = int(writtenOut) 50 | 51 | if e1 != 0 { 52 | err = e1 53 | } 54 | return 55 | } 56 | 57 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 58 | 59 | func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 60 | ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint64(countin)} 61 | err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 62 | return int(ioDesc.Len), err 63 | } 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_hurd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 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 | //go:build hurd 6 | // +build hurd 7 | 8 | package unix 9 | 10 | /* 11 | #include 12 | int ioctl(int, unsigned long int, uintptr_t); 13 | */ 14 | import "C" 15 | 16 | func ioctl(fd int, req uint, arg uintptr) (err error) { 17 | r0, er := C.ioctl(C.int(fd), C.ulong(req), C.uintptr_t(arg)) 18 | if r0 == -1 && er != nil { 19 | err = er 20 | } 21 | return 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_hurd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 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 | //go:build 386 && hurd 6 | // +build 386,hurd 7 | 8 | package unix 9 | 10 | const ( 11 | TIOCGETA = 0x62251713 12 | ) 13 | 14 | type Winsize struct { 15 | Row uint16 16 | Col uint16 17 | Xpixel uint16 18 | Ypixel uint16 19 | } 20 | 21 | type Termios struct { 22 | Iflag uint32 23 | Oflag uint32 24 | Cflag uint32 25 | Lflag uint32 26 | Cc [20]uint8 27 | Ispeed int32 28 | Ospeed int32 29 | } 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_illumos.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 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 | // illumos system calls not present on Solaris. 6 | 7 | //go:build amd64 && illumos 8 | // +build amd64,illumos 9 | 10 | package unix 11 | 12 | import ( 13 | "unsafe" 14 | ) 15 | 16 | func bytes2iovec(bs [][]byte) []Iovec { 17 | iovecs := make([]Iovec, len(bs)) 18 | for i, b := range bs { 19 | iovecs[i].SetLen(len(b)) 20 | if len(b) > 0 { 21 | iovecs[i].Base = &b[0] 22 | } else { 23 | iovecs[i].Base = (*byte)(unsafe.Pointer(&_zero)) 24 | } 25 | } 26 | return iovecs 27 | } 28 | 29 | //sys readv(fd int, iovs []Iovec) (n int, err error) 30 | 31 | func Readv(fd int, iovs [][]byte) (n int, err error) { 32 | iovecs := bytes2iovec(iovs) 33 | n, err = readv(fd, iovecs) 34 | return n, err 35 | } 36 | 37 | //sys preadv(fd int, iovs []Iovec, off int64) (n int, err error) 38 | 39 | func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) { 40 | iovecs := bytes2iovec(iovs) 41 | n, err = preadv(fd, iovecs, off) 42 | return n, err 43 | } 44 | 45 | //sys writev(fd int, iovs []Iovec) (n int, err error) 46 | 47 | func Writev(fd int, iovs [][]byte) (n int, err error) { 48 | iovecs := bytes2iovec(iovs) 49 | n, err = writev(fd, iovecs) 50 | return n, err 51 | } 52 | 53 | //sys pwritev(fd int, iovs []Iovec, off int64) (n int, err error) 54 | 55 | func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) { 56 | iovecs := bytes2iovec(iovs) 57 | n, err = pwritev(fd, iovecs, off) 58 | return n, err 59 | } 60 | 61 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) = libsocket.accept4 62 | 63 | func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) { 64 | var rsa RawSockaddrAny 65 | var len _Socklen = SizeofSockaddrAny 66 | nfd, err = accept4(fd, &rsa, &len, flags) 67 | if err != nil { 68 | return 69 | } 70 | if len > SizeofSockaddrAny { 71 | panic("RawSockaddrAny too small") 72 | } 73 | sa, err = anyToSockaddr(fd, &rsa) 74 | if err != nil { 75 | Close(nfd) 76 | nfd = 0 77 | } 78 | return 79 | } 80 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_alarm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 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 | //go:build linux && (386 || amd64 || mips || mipsle || mips64 || mipsle || ppc64 || ppc64le || ppc || s390x || sparc64) 6 | // +build linux 7 | // +build 386 amd64 mips mipsle mips64 mipsle ppc64 ppc64le ppc s390x sparc64 8 | 9 | package unix 10 | 11 | // SYS_ALARM is not defined on arm or riscv, but is available for other GOARCH 12 | // values. 13 | 14 | //sys Alarm(seconds uint) (remaining uint, err error) 15 | -------------------------------------------------------------------------------- /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 | //go:build amd64 && linux && gc 6 | // +build amd64,linux,gc 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_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build linux && gc 6 | // +build linux,gc 7 | 8 | package unix 9 | 10 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 11 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 12 | 13 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 14 | // fail. 15 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build linux && gc && 386 6 | // +build linux,gc,386 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | // Underlying system call writes to newoffset via pointer. 13 | // Implemented in assembly to avoid allocation. 14 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 15 | 16 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 17 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.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 | //go:build arm && gc && linux 6 | // +build arm,gc,linux 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | // Underlying system call writes to newoffset via pointer. 13 | // Implemented in assembly to avoid allocation. 14 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build linux && gccgo && 386 6 | // +build linux,gccgo,386 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 16 | var newoffset int64 17 | offsetLow := uint32(offset & 0xffffffff) 18 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 19 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 20 | return newoffset, err 21 | } 22 | 23 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 24 | fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 25 | return int(fd), err 26 | } 27 | 28 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) { 29 | fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0) 30 | return int(fd), err 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_gccgo_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build linux && gccgo && arm 6 | // +build linux,gccgo,arm 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | func seek(fd int, offset int64, whence int) (int64, syscall.Errno) { 16 | var newoffset int64 17 | offsetLow := uint32(offset & 0xffffffff) 18 | offsetHigh := uint32((offset >> 32) & 0xffffffff) 19 | _, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0) 20 | return newoffset, err 21 | } 22 | -------------------------------------------------------------------------------- /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 | //go:build 386 && netbsd 6 | // +build 386,netbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: int32(nsec)} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint32(fd) 20 | k.Filter = uint32(mode) 21 | k.Flags = uint32(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | -------------------------------------------------------------------------------- /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 | //go:build amd64 && netbsd 6 | // +build amd64,netbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = uint32(mode) 21 | k.Flags = uint32(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | -------------------------------------------------------------------------------- /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 | //go:build arm && netbsd 6 | // +build arm,netbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: int32(nsec)} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint32(fd) 20 | k.Filter = uint32(mode) 21 | k.Flags = uint32(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 | //go:build arm64 && netbsd 6 | // +build arm64,netbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = uint32(mode) 21 | k.Flags = uint32(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = int32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | -------------------------------------------------------------------------------- /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 | //go:build 386 && openbsd 6 | // +build 386,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: int32(nsec)} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint32(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/386 the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 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 | //go:build amd64 && openbsd 6 | // +build amd64,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: usec} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | //go:build arm && openbsd 6 | // +build arm,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: int32(nsec)} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: int32(usec)} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint32(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint32(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/arm the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 | //go:build arm64 && openbsd 6 | // +build arm64,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: usec} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/amd64 the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_libc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 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 | //go:build openbsd 6 | // +build openbsd 7 | 8 | package unix 9 | 10 | import _ "unsafe" 11 | 12 | // Implemented in the runtime package (runtime/sys_openbsd3.go) 13 | func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 14 | func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 15 | func syscall_syscall10(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 uintptr) (r1, r2 uintptr, err Errno) 16 | func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) 17 | func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 18 | 19 | //go:linkname syscall_syscall syscall.syscall 20 | //go:linkname syscall_syscall6 syscall.syscall6 21 | //go:linkname syscall_syscall10 syscall.syscall10 22 | //go:linkname syscall_rawSyscall syscall.rawSyscall 23 | //go:linkname syscall_rawSyscall6 syscall.rawSyscall6 24 | 25 | func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) { 26 | return syscall_syscall10(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, 0) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_mips64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 | func setTimespec(sec, nsec int64) Timespec { 8 | return Timespec{Sec: sec, Nsec: nsec} 9 | } 10 | 11 | func setTimeval(sec, usec int64) Timeval { 12 | return Timeval{Sec: sec, Usec: usec} 13 | } 14 | 15 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 16 | k.Ident = uint64(fd) 17 | k.Filter = int16(mode) 18 | k.Flags = uint16(flags) 19 | } 20 | 21 | func (iov *Iovec) SetLen(length int) { 22 | iov.Len = uint64(length) 23 | } 24 | 25 | func (msghdr *Msghdr) SetControllen(length int) { 26 | msghdr.Controllen = uint32(length) 27 | } 28 | 29 | func (msghdr *Msghdr) SetIovlen(length int) { 30 | msghdr.Iovlen = uint32(length) 31 | } 32 | 33 | func (cmsg *Cmsghdr) SetLen(length int) { 34 | cmsg.Len = uint32(length) 35 | } 36 | 37 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 38 | // of OpenBSD the syscall is called sysctl instead of __sysctl. 39 | const SYS___SYSCTL = SYS_SYSCTL 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_ppc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 | //go:build ppc64 && openbsd 6 | // +build ppc64,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: usec} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/ppc64 the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_riscv64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 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 | //go:build riscv64 && openbsd 6 | // +build riscv64,openbsd 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: usec} 16 | } 17 | 18 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 19 | k.Ident = uint64(fd) 20 | k.Filter = int16(mode) 21 | k.Flags = uint16(flags) 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (msghdr *Msghdr) SetControllen(length int) { 29 | msghdr.Controllen = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetIovlen(length int) { 33 | msghdr.Iovlen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 41 | // of openbsd/riscv64 the syscall is called sysctl instead of __sysctl. 42 | const SYS___SYSCTL = SYS_SYSCTL 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 | //go:build amd64 && solaris 6 | // +build amd64,solaris 7 | 8 | package unix 9 | 10 | func setTimespec(sec, nsec int64) Timespec { 11 | return Timespec{Sec: sec, Nsec: nsec} 12 | } 13 | 14 | func setTimeval(sec, usec int64) Timeval { 15 | return Timeval{Sec: sec, Usec: usec} 16 | } 17 | 18 | func (iov *Iovec) SetLen(length int) { 19 | iov.Len = uint64(length) 20 | } 21 | 22 | func (msghdr *Msghdr) SetIovlen(length int) { 23 | msghdr.Iovlen = int32(length) 24 | } 25 | 26 | func (cmsg *Cmsghdr) SetLen(length int) { 27 | cmsg.Len = uint32(length) 28 | } 29 | -------------------------------------------------------------------------------- /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 | //go:build (darwin || dragonfly || freebsd || (linux && !ppc64 && !ppc64le) || netbsd || openbsd || solaris) && gc 6 | // +build darwin dragonfly freebsd linux,!ppc64,!ppc64le netbsd openbsd solaris 7 | // +build gc 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | //go:build linux && (ppc64le || ppc64) && gc 6 | // +build linux 7 | // +build ppc64le ppc64 8 | // +build gc 9 | 10 | package unix 11 | 12 | import "syscall" 13 | 14 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 15 | return syscall.Syscall(trap, a1, a2, a3) 16 | } 17 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | return syscall.Syscall6(trap, a1, a2, a3, a4, a5, a6) 19 | } 20 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 21 | return syscall.RawSyscall(trap, a1, a2, a3) 22 | } 23 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 24 | return syscall.RawSyscall6(trap, a1, a2, a3, a4, a5, a6) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sysvshm_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 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 | //go:build linux 6 | // +build linux 7 | 8 | package unix 9 | 10 | import "runtime" 11 | 12 | // SysvShmCtl performs control operations on the shared memory segment 13 | // specified by id. 14 | func SysvShmCtl(id, cmd int, desc *SysvShmDesc) (result int, err error) { 15 | if runtime.GOARCH == "arm" || 16 | runtime.GOARCH == "mips64" || runtime.GOARCH == "mips64le" { 17 | cmd |= ipc_64 18 | } 19 | 20 | return shmctl(id, cmd, desc) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sysvshm_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 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 | //go:build (darwin && !ios) || linux 6 | // +build darwin,!ios linux 7 | 8 | package unix 9 | 10 | import "unsafe" 11 | 12 | // SysvShmAttach attaches the Sysv shared memory segment associated with the 13 | // shared memory identifier id. 14 | func SysvShmAttach(id int, addr uintptr, flag int) ([]byte, error) { 15 | addr, errno := shmat(id, addr, flag) 16 | if errno != nil { 17 | return nil, errno 18 | } 19 | 20 | // Retrieve the size of the shared memory to enable slice creation 21 | var info SysvShmDesc 22 | 23 | _, err := SysvShmCtl(id, IPC_STAT, &info) 24 | if err != nil { 25 | // release the shared memory if we can't find the size 26 | 27 | // ignoring error from shmdt as there's nothing sensible to return here 28 | shmdt(addr) 29 | return nil, err 30 | } 31 | 32 | // Use unsafe to convert addr into a []byte. 33 | b := unsafe.Slice((*byte)(unsafe.Pointer(addr)), int(info.Segsz)) 34 | return b, nil 35 | } 36 | 37 | // SysvShmDetach unmaps the shared memory slice returned from SysvShmAttach. 38 | // 39 | // It is not safe to use the slice after calling this function. 40 | func SysvShmDetach(data []byte) error { 41 | if len(data) == 0 { 42 | return EINVAL 43 | } 44 | 45 | return shmdt(uintptr(unsafe.Pointer(&data[0]))) 46 | } 47 | 48 | // SysvShmGet returns the Sysv shared memory identifier associated with key. 49 | // If the IPC_CREAT flag is specified a new segment is created. 50 | func SysvShmGet(key, size, flag int) (id int, err error) { 51 | return shmget(key, size, flag) 52 | } 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sysvshm_unix_other.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 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 | //go:build darwin && !ios 6 | // +build darwin,!ios 7 | 8 | package unix 9 | 10 | // SysvShmCtl performs control operations on the shared memory segment 11 | // specified by id. 12 | func SysvShmCtl(id, cmd int, desc *SysvShmDesc) (result int, err error) { 13 | return shmctl(id, cmd, desc) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/timestruct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 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 | //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos 6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos 7 | 8 | package unix 9 | 10 | import "time" 11 | 12 | // TimespecToNSec returns the time stored in ts as nanoseconds. 13 | func TimespecToNsec(ts Timespec) int64 { return ts.Nano() } 14 | 15 | // NsecToTimespec converts a number of nanoseconds into a Timespec. 16 | func NsecToTimespec(nsec int64) Timespec { 17 | sec := nsec / 1e9 18 | nsec = nsec % 1e9 19 | if nsec < 0 { 20 | nsec += 1e9 21 | sec-- 22 | } 23 | return setTimespec(sec, nsec) 24 | } 25 | 26 | // TimeToTimespec converts t into a Timespec. 27 | // On some 32-bit systems the range of valid Timespec values are smaller 28 | // than that of time.Time values. So if t is out of the valid range of 29 | // Timespec, it returns a zero Timespec and ERANGE. 30 | func TimeToTimespec(t time.Time) (Timespec, error) { 31 | sec := t.Unix() 32 | nsec := int64(t.Nanosecond()) 33 | ts := setTimespec(sec, nsec) 34 | 35 | // Currently all targets have either int32 or int64 for Timespec.Sec. 36 | // If there were a new target with floating point type for it, we have 37 | // to consider the rounding error. 38 | if int64(ts.Sec) != sec { 39 | return Timespec{}, ERANGE 40 | } 41 | return ts, nil 42 | } 43 | 44 | // TimevalToNsec returns the time stored in tv as nanoseconds. 45 | func TimevalToNsec(tv Timeval) int64 { return tv.Nano() } 46 | 47 | // NsecToTimeval converts a number of nanoseconds into a Timeval. 48 | func NsecToTimeval(nsec int64) Timeval { 49 | nsec += 999 // round up to microsecond 50 | usec := nsec % 1e9 / 1e3 51 | sec := nsec / 1e9 52 | if usec < 0 { 53 | usec += 1e6 54 | sec-- 55 | } 56 | return setTimeval(sec, usec) 57 | } 58 | 59 | // Unix returns the time stored in ts as seconds plus nanoseconds. 60 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 61 | return int64(ts.Sec), int64(ts.Nsec) 62 | } 63 | 64 | // Unix returns the time stored in tv as seconds plus nanoseconds. 65 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 66 | return int64(tv.Sec), int64(tv.Usec) * 1000 67 | } 68 | 69 | // Nano returns the time stored in ts as nanoseconds. 70 | func (ts *Timespec) Nano() int64 { 71 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 72 | } 73 | 74 | // Nano returns the time stored in tv as nanoseconds. 75 | func (tv *Timeval) Nano() int64 { 76 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 77 | } 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/unveil_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 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 | // Unveil implements the unveil syscall. 13 | // For more information see unveil(2). 14 | // Note that the special case of blocking further 15 | // unveil calls is handled by UnveilBlock. 16 | func Unveil(path string, flags string) error { 17 | pathPtr, err := syscall.BytePtrFromString(path) 18 | if err != nil { 19 | return err 20 | } 21 | flagsPtr, err := syscall.BytePtrFromString(flags) 22 | if err != nil { 23 | return err 24 | } 25 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(unsafe.Pointer(pathPtr)), uintptr(unsafe.Pointer(flagsPtr)), 0) 26 | if e != 0 { 27 | return e 28 | } 29 | return nil 30 | } 31 | 32 | // UnveilBlock blocks future unveil calls. 33 | // For more information see unveil(2). 34 | func UnveilBlock() error { 35 | // Both pointers must be nil. 36 | var pathUnsafe, flagsUnsafe unsafe.Pointer 37 | _, _, e := syscall.Syscall(SYS_UNVEIL, uintptr(pathUnsafe), uintptr(flagsUnsafe), 0) 38 | if e != 0 { 39 | return e 40 | } 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_armnn_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair("arm", "arm64"). DO NOT EDIT. 2 | 3 | //go:build linux && (arm || arm64) 4 | // +build linux 5 | // +build arm arm64 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // PtraceRegsArm is the registers used by arm binaries. 12 | type PtraceRegsArm struct { 13 | Uregs [18]uint32 14 | } 15 | 16 | // PtraceGetRegsArm fetches the registers used by arm binaries. 17 | func PtraceGetRegsArm(pid int, regsout *PtraceRegsArm) error { 18 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 19 | } 20 | 21 | // PtraceSetRegsArm sets the registers used by arm binaries. 22 | func PtraceSetRegsArm(pid int, regs *PtraceRegsArm) error { 23 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 24 | } 25 | 26 | // PtraceRegsArm64 is the registers used by arm64 binaries. 27 | type PtraceRegsArm64 struct { 28 | Regs [31]uint64 29 | Sp uint64 30 | Pc uint64 31 | Pstate uint64 32 | } 33 | 34 | // PtraceGetRegsArm64 fetches the registers used by arm64 binaries. 35 | func PtraceGetRegsArm64(pid int, regsout *PtraceRegsArm64) error { 36 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 37 | } 38 | 39 | // PtraceSetRegsArm64 sets the registers used by arm64 binaries. 40 | func PtraceSetRegsArm64(pid int, regs *PtraceRegsArm64) error { 41 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_linux_arm64.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtraceRegSet("arm64"). DO NOT EDIT. 2 | 3 | package unix 4 | 5 | import "unsafe" 6 | 7 | // PtraceGetRegSetArm64 fetches the registers used by arm64 binaries. 8 | func PtraceGetRegSetArm64(pid, addr int, regsout *PtraceRegsArm64) error { 9 | iovec := Iovec{(*byte)(unsafe.Pointer(regsout)), uint64(unsafe.Sizeof(*regsout))} 10 | return ptrace(PTRACE_GETREGSET, pid, uintptr(addr), uintptr(unsafe.Pointer(&iovec))) 11 | } 12 | 13 | // PtraceSetRegSetArm64 sets the registers used by arm64 binaries. 14 | func PtraceSetRegSetArm64(pid, addr int, regs *PtraceRegsArm64) error { 15 | iovec := Iovec{(*byte)(unsafe.Pointer(regs)), uint64(unsafe.Sizeof(*regs))} 16 | return ptrace(PTRACE_SETREGSET, pid, uintptr(addr), uintptr(unsafe.Pointer(&iovec))) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_mipsnn_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair("mips", "mips64"). DO NOT EDIT. 2 | 3 | //go:build linux && (mips || mips64) 4 | // +build linux 5 | // +build mips mips64 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // PtraceRegsMips is the registers used by mips binaries. 12 | type PtraceRegsMips struct { 13 | Regs [32]uint64 14 | Lo uint64 15 | Hi uint64 16 | Epc uint64 17 | Badvaddr uint64 18 | Status uint64 19 | Cause uint64 20 | } 21 | 22 | // PtraceGetRegsMips fetches the registers used by mips binaries. 23 | func PtraceGetRegsMips(pid int, regsout *PtraceRegsMips) error { 24 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 25 | } 26 | 27 | // PtraceSetRegsMips sets the registers used by mips binaries. 28 | func PtraceSetRegsMips(pid int, regs *PtraceRegsMips) error { 29 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 30 | } 31 | 32 | // PtraceRegsMips64 is the registers used by mips64 binaries. 33 | type PtraceRegsMips64 struct { 34 | Regs [32]uint64 35 | Lo uint64 36 | Hi uint64 37 | Epc uint64 38 | Badvaddr uint64 39 | Status uint64 40 | Cause uint64 41 | } 42 | 43 | // PtraceGetRegsMips64 fetches the registers used by mips64 binaries. 44 | func PtraceGetRegsMips64(pid int, regsout *PtraceRegsMips64) error { 45 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 46 | } 47 | 48 | // PtraceSetRegsMips64 sets the registers used by mips64 binaries. 49 | func PtraceSetRegsMips64(pid int, regs *PtraceRegsMips64) error { 50 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_mipsnnle_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair("mipsle", "mips64le"). DO NOT EDIT. 2 | 3 | //go:build linux && (mipsle || mips64le) 4 | // +build linux 5 | // +build mipsle mips64le 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // PtraceRegsMipsle is the registers used by mipsle binaries. 12 | type PtraceRegsMipsle struct { 13 | Regs [32]uint64 14 | Lo uint64 15 | Hi uint64 16 | Epc uint64 17 | Badvaddr uint64 18 | Status uint64 19 | Cause uint64 20 | } 21 | 22 | // PtraceGetRegsMipsle fetches the registers used by mipsle binaries. 23 | func PtraceGetRegsMipsle(pid int, regsout *PtraceRegsMipsle) error { 24 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 25 | } 26 | 27 | // PtraceSetRegsMipsle sets the registers used by mipsle binaries. 28 | func PtraceSetRegsMipsle(pid int, regs *PtraceRegsMipsle) error { 29 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 30 | } 31 | 32 | // PtraceRegsMips64le is the registers used by mips64le binaries. 33 | type PtraceRegsMips64le struct { 34 | Regs [32]uint64 35 | Lo uint64 36 | Hi uint64 37 | Epc uint64 38 | Badvaddr uint64 39 | Status uint64 40 | Cause uint64 41 | } 42 | 43 | // PtraceGetRegsMips64le fetches the registers used by mips64le binaries. 44 | func PtraceGetRegsMips64le(pid int, regsout *PtraceRegsMips64le) error { 45 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 46 | } 47 | 48 | // PtraceSetRegsMips64le sets the registers used by mips64le binaries. 49 | func PtraceSetRegsMips64le(pid int, regs *PtraceRegsMips64le) error { 50 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace_x86_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair("386", "amd64"). DO NOT EDIT. 2 | 3 | //go:build linux && (386 || amd64) 4 | // +build linux 5 | // +build 386 amd64 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // PtraceRegs386 is the registers used by 386 binaries. 12 | type PtraceRegs386 struct { 13 | Ebx int32 14 | Ecx int32 15 | Edx int32 16 | Esi int32 17 | Edi int32 18 | Ebp int32 19 | Eax int32 20 | Xds int32 21 | Xes int32 22 | Xfs int32 23 | Xgs int32 24 | Orig_eax int32 25 | Eip int32 26 | Xcs int32 27 | Eflags int32 28 | Esp int32 29 | Xss int32 30 | } 31 | 32 | // PtraceGetRegs386 fetches the registers used by 386 binaries. 33 | func PtraceGetRegs386(pid int, regsout *PtraceRegs386) error { 34 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 35 | } 36 | 37 | // PtraceSetRegs386 sets the registers used by 386 binaries. 38 | func PtraceSetRegs386(pid int, regs *PtraceRegs386) error { 39 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 40 | } 41 | 42 | // PtraceRegsAmd64 is the registers used by amd64 binaries. 43 | type PtraceRegsAmd64 struct { 44 | R15 uint64 45 | R14 uint64 46 | R13 uint64 47 | R12 uint64 48 | Rbp uint64 49 | Rbx uint64 50 | R11 uint64 51 | R10 uint64 52 | R9 uint64 53 | R8 uint64 54 | Rax uint64 55 | Rcx uint64 56 | Rdx uint64 57 | Rsi uint64 58 | Rdi uint64 59 | Orig_rax uint64 60 | Rip uint64 61 | Cs uint64 62 | Eflags uint64 63 | Rsp uint64 64 | Ss uint64 65 | Fs_base uint64 66 | Gs_base uint64 67 | Ds uint64 68 | Es uint64 69 | Fs uint64 70 | Gs uint64 71 | } 72 | 73 | // PtraceGetRegsAmd64 fetches the registers used by amd64 binaries. 74 | func PtraceGetRegsAmd64(pid int, regsout *PtraceRegsAmd64) error { 75 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 76 | } 77 | 78 | // PtraceSetRegsAmd64 sets the registers used by amd64 binaries. 79 | func PtraceSetRegsAmd64(pid int, regs *PtraceRegsAmd64) error { 80 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 81 | } 82 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go: -------------------------------------------------------------------------------- 1 | // go run mksyscall_solaris.go -illumos -tags illumos,amd64 syscall_illumos.go 2 | // Code generated by the command above; see README.md. DO NOT EDIT. 3 | 4 | //go:build illumos && amd64 5 | // +build illumos,amd64 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | //go:cgo_import_dynamic libc_readv readv "libc.so" 14 | //go:cgo_import_dynamic libc_preadv preadv "libc.so" 15 | //go:cgo_import_dynamic libc_writev writev "libc.so" 16 | //go:cgo_import_dynamic libc_pwritev pwritev "libc.so" 17 | //go:cgo_import_dynamic libc_accept4 accept4 "libsocket.so" 18 | 19 | //go:linkname procreadv libc_readv 20 | //go:linkname procpreadv libc_preadv 21 | //go:linkname procwritev libc_writev 22 | //go:linkname procpwritev libc_pwritev 23 | //go:linkname procaccept4 libc_accept4 24 | 25 | var ( 26 | procreadv, 27 | procpreadv, 28 | procwritev, 29 | procpwritev, 30 | procaccept4 syscallFunc 31 | ) 32 | 33 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 34 | 35 | func readv(fd int, iovs []Iovec) (n int, err error) { 36 | var _p0 *Iovec 37 | if len(iovs) > 0 { 38 | _p0 = &iovs[0] 39 | } 40 | r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procreadv)), 3, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(iovs)), 0, 0, 0) 41 | n = int(r0) 42 | if e1 != 0 { 43 | err = e1 44 | } 45 | return 46 | } 47 | 48 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 49 | 50 | func preadv(fd int, iovs []Iovec, off int64) (n int, err error) { 51 | var _p0 *Iovec 52 | if len(iovs) > 0 { 53 | _p0 = &iovs[0] 54 | } 55 | r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procpreadv)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(iovs)), uintptr(off), 0, 0) 56 | n = int(r0) 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 64 | 65 | func writev(fd int, iovs []Iovec) (n int, err error) { 66 | var _p0 *Iovec 67 | if len(iovs) > 0 { 68 | _p0 = &iovs[0] 69 | } 70 | r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procwritev)), 3, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(iovs)), 0, 0, 0) 71 | n = int(r0) 72 | if e1 != 0 { 73 | err = e1 74 | } 75 | return 76 | } 77 | 78 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 79 | 80 | func pwritev(fd int, iovs []Iovec, off int64) (n int, err error) { 81 | var _p0 *Iovec 82 | if len(iovs) > 0 { 83 | _p0 = &iovs[0] 84 | } 85 | r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procpwritev)), 4, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(len(iovs)), uintptr(off), 0, 0) 86 | n = int(r0) 87 | if e1 != 0 { 88 | err = e1 89 | } 90 | return 91 | } 92 | 93 | // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT 94 | 95 | func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) { 96 | r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procaccept4)), 4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0) 97 | fd = int(r0) 98 | if e1 != 0 { 99 | err = e1 100 | } 101 | return 102 | } 103 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/deckarep/golang-set/v2 v2.6.0 2 | ## explicit; go 1.18 3 | github.com/deckarep/golang-set/v2 4 | # github.com/mattn/go-colorable v0.1.13 5 | ## explicit; go 1.15 6 | github.com/mattn/go-colorable 7 | # github.com/mattn/go-isatty v0.0.17 8 | ## explicit; go 1.15 9 | github.com/mattn/go-isatty 10 | # github.com/rs/zerolog v1.29.0 11 | ## explicit; go 1.15 12 | github.com/rs/zerolog 13 | github.com/rs/zerolog/internal/cbor 14 | github.com/rs/zerolog/internal/json 15 | github.com/rs/zerolog/log 16 | # golang.org/x/sys v0.4.0 17 | ## explicit; go 1.17 18 | golang.org/x/sys/unix 19 | --------------------------------------------------------------------------------