├── .DEREK.yml ├── .dockerignore ├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── build.yaml │ └── publish.yaml ├── .gitignore ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── README.md ├── go.mod ├── go.sum ├── handler ├── handler.go ├── handler_test.go ├── nats_config.go └── nats_queue.go ├── main.go ├── main_test.go ├── nats ├── client.go └── client_test.go ├── readconfig.go ├── readconfig_test.go ├── types.go ├── vendor ├── github.com │ ├── gogo │ │ └── protobuf │ │ │ ├── AUTHORS │ │ │ ├── CONTRIBUTORS │ │ │ ├── LICENSE │ │ │ ├── gogoproto │ │ │ ├── Makefile │ │ │ ├── doc.go │ │ │ ├── gogo.pb.go │ │ │ ├── gogo.pb.golden │ │ │ ├── gogo.proto │ │ │ └── helper.go │ │ │ ├── proto │ │ │ ├── Makefile │ │ │ ├── clone.go │ │ │ ├── custom_gogo.go │ │ │ ├── decode.go │ │ │ ├── deprecated.go │ │ │ ├── discard.go │ │ │ ├── duration.go │ │ │ ├── duration_gogo.go │ │ │ ├── encode.go │ │ │ ├── encode_gogo.go │ │ │ ├── equal.go │ │ │ ├── extensions.go │ │ │ ├── extensions_gogo.go │ │ │ ├── lib.go │ │ │ ├── lib_gogo.go │ │ │ ├── message_set.go │ │ │ ├── pointer_reflect.go │ │ │ ├── pointer_reflect_gogo.go │ │ │ ├── pointer_unsafe.go │ │ │ ├── pointer_unsafe_gogo.go │ │ │ ├── properties.go │ │ │ ├── properties_gogo.go │ │ │ ├── skip_gogo.go │ │ │ ├── table_marshal.go │ │ │ ├── table_marshal_gogo.go │ │ │ ├── table_merge.go │ │ │ ├── table_unmarshal.go │ │ │ ├── table_unmarshal_gogo.go │ │ │ ├── text.go │ │ │ ├── text_gogo.go │ │ │ ├── text_parser.go │ │ │ ├── timestamp.go │ │ │ ├── timestamp_gogo.go │ │ │ ├── wrappers.go │ │ │ └── wrappers_gogo.go │ │ │ └── protoc-gen-gogo │ │ │ └── descriptor │ │ │ ├── Makefile │ │ │ ├── descriptor.go │ │ │ ├── descriptor.pb.go │ │ │ ├── descriptor_gostring.gen.go │ │ │ └── helper.go │ ├── klauspost │ │ └── compress │ │ │ ├── LICENSE │ │ │ └── flate │ │ │ ├── deflate.go │ │ │ ├── dict_decoder.go │ │ │ ├── fast_encoder.go │ │ │ ├── huffman_bit_writer.go │ │ │ ├── huffman_code.go │ │ │ ├── huffman_sortByFreq.go │ │ │ ├── huffman_sortByLiteral.go │ │ │ ├── inflate.go │ │ │ ├── inflate_gen.go │ │ │ ├── level1.go │ │ │ ├── level2.go │ │ │ ├── level3.go │ │ │ ├── level4.go │ │ │ ├── level5.go │ │ │ ├── level6.go │ │ │ ├── matchlen_amd64.go │ │ │ ├── matchlen_amd64.s │ │ │ ├── matchlen_generic.go │ │ │ ├── regmask_amd64.go │ │ │ ├── regmask_other.go │ │ │ ├── stateless.go │ │ │ └── token.go │ ├── nats-io │ │ ├── nats.go │ │ │ ├── .gitignore │ │ │ ├── .golangci.yaml │ │ │ ├── .travis.yml │ │ │ ├── .words │ │ │ ├── .words.readme │ │ │ ├── CODE-OF-CONDUCT.md │ │ │ ├── CONTRIBUTING.md │ │ │ ├── GOVERNANCE.md │ │ │ ├── LICENSE │ │ │ ├── MAINTAINERS.md │ │ │ ├── README.md │ │ │ ├── context.go │ │ │ ├── dependencies.md │ │ │ ├── enc.go │ │ │ ├── encoders │ │ │ │ └── builtin │ │ │ │ │ ├── default_enc.go │ │ │ │ │ ├── gob_enc.go │ │ │ │ │ └── json_enc.go │ │ │ ├── go_test.mod │ │ │ ├── go_test.sum │ │ │ ├── internal │ │ │ │ └── parser │ │ │ │ │ └── parse.go │ │ │ ├── js.go │ │ │ ├── jserrors.go │ │ │ ├── jsm.go │ │ │ ├── kv.go │ │ │ ├── legacy_jetstream.md │ │ │ ├── nats.go │ │ │ ├── netchan.go │ │ │ ├── object.go │ │ │ ├── parser.go │ │ │ ├── rand.go │ │ │ ├── testing_internal.go │ │ │ ├── timer.go │ │ │ ├── util │ │ │ │ ├── tls.go │ │ │ │ └── tls_go17.go │ │ │ └── ws.go │ │ ├── nkeys │ │ │ ├── .gitignore │ │ │ ├── .goreleaser.yml │ │ │ ├── GOVERNANCE.md │ │ │ ├── LICENSE │ │ │ ├── MAINTAINERS.md │ │ │ ├── README.md │ │ │ ├── TODO.md │ │ │ ├── crc16.go │ │ │ ├── creds_utils.go │ │ │ ├── dependencies.md │ │ │ ├── errors.go │ │ │ ├── keypair.go │ │ │ ├── nkeys.go │ │ │ ├── public.go │ │ │ ├── strkey.go │ │ │ └── xkeys.go │ │ ├── nuid │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── GOVERNANCE.md │ │ │ ├── LICENSE │ │ │ ├── MAINTAINERS.md │ │ │ ├── README.md │ │ │ └── nuid.go │ │ └── stan.go │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── CODE-OF-CONDUCT.md │ │ │ ├── GOVERNANCE.md │ │ │ ├── LICENSE │ │ │ ├── MAINTAINERS.md │ │ │ ├── README.md │ │ │ ├── dependencies.md │ │ │ ├── go_tests.mod │ │ │ ├── go_tests.sum │ │ │ ├── pb │ │ │ ├── protocol.pb.go │ │ │ └── protocol.proto │ │ │ ├── stan.go │ │ │ └── sub.go │ └── openfaas │ │ └── faas-provider │ │ ├── LICENSE │ │ └── types │ │ ├── config.go │ │ ├── function_deployment.go │ │ ├── function_status.go │ │ ├── queue.go │ │ ├── read_config.go │ │ ├── requests.go │ │ ├── secret.go │ │ └── system_events.go ├── golang.org │ └── x │ │ ├── crypto │ │ ├── LICENSE │ │ ├── PATENTS │ │ ├── blake2b │ │ │ ├── blake2b.go │ │ │ ├── blake2bAVX2_amd64.go │ │ │ ├── blake2bAVX2_amd64.s │ │ │ ├── blake2b_amd64.s │ │ │ ├── blake2b_generic.go │ │ │ ├── blake2b_ref.go │ │ │ ├── blake2x.go │ │ │ └── register.go │ │ ├── curve25519 │ │ │ └── curve25519.go │ │ ├── internal │ │ │ ├── alias │ │ │ │ ├── alias.go │ │ │ │ └── alias_purego.go │ │ │ └── poly1305 │ │ │ │ ├── mac_noasm.go │ │ │ │ ├── poly1305.go │ │ │ │ ├── sum_amd64.go │ │ │ │ ├── sum_amd64.s │ │ │ │ ├── sum_generic.go │ │ │ │ ├── sum_ppc64x.go │ │ │ │ ├── sum_ppc64x.s │ │ │ │ ├── sum_s390x.go │ │ │ │ └── sum_s390x.s │ │ ├── nacl │ │ │ ├── box │ │ │ │ └── box.go │ │ │ └── secretbox │ │ │ │ └── secretbox.go │ │ └── salsa20 │ │ │ └── salsa │ │ │ ├── hsalsa20.go │ │ │ ├── salsa208.go │ │ │ ├── salsa20_amd64.go │ │ │ ├── salsa20_amd64.s │ │ │ ├── salsa20_noasm.go │ │ │ └── salsa20_ref.go │ │ └── sys │ │ ├── LICENSE │ │ ├── PATENTS │ │ └── cpu │ │ ├── asm_aix_ppc64.s │ │ ├── asm_darwin_x86_gc.s │ │ ├── byteorder.go │ │ ├── cpu.go │ │ ├── cpu_aix.go │ │ ├── cpu_arm.go │ │ ├── cpu_arm64.go │ │ ├── cpu_arm64.s │ │ ├── cpu_darwin_x86.go │ │ ├── cpu_gc_arm64.go │ │ ├── cpu_gc_s390x.go │ │ ├── cpu_gc_x86.go │ │ ├── cpu_gc_x86.s │ │ ├── cpu_gccgo_arm64.go │ │ ├── cpu_gccgo_s390x.go │ │ ├── cpu_gccgo_x86.c │ │ ├── cpu_gccgo_x86.go │ │ ├── cpu_linux.go │ │ ├── cpu_linux_arm.go │ │ ├── cpu_linux_arm64.go │ │ ├── cpu_linux_mips64x.go │ │ ├── cpu_linux_noinit.go │ │ ├── cpu_linux_ppc64x.go │ │ ├── cpu_linux_riscv64.go │ │ ├── cpu_linux_s390x.go │ │ ├── cpu_loong64.go │ │ ├── cpu_mips64x.go │ │ ├── cpu_mipsx.go │ │ ├── cpu_netbsd_arm64.go │ │ ├── cpu_openbsd_arm64.go │ │ ├── cpu_openbsd_arm64.s │ │ ├── cpu_other_arm.go │ │ ├── cpu_other_arm64.go │ │ ├── cpu_other_mips64x.go │ │ ├── cpu_other_ppc64x.go │ │ ├── cpu_other_riscv64.go │ │ ├── cpu_other_x86.go │ │ ├── cpu_ppc64x.go │ │ ├── cpu_riscv64.go │ │ ├── cpu_s390x.go │ │ ├── cpu_s390x.s │ │ ├── cpu_wasm.go │ │ ├── cpu_x86.go │ │ ├── cpu_zos.go │ │ ├── cpu_zos_s390x.go │ │ ├── endian_big.go │ │ ├── endian_little.go │ │ ├── hwcap_linux.go │ │ ├── parse.go │ │ ├── proc_cpuinfo_linux.go │ │ ├── runtime_auxv.go │ │ ├── runtime_auxv_go121.go │ │ ├── syscall_aix_gccgo.go │ │ ├── syscall_aix_ppc64_gc.go │ │ └── syscall_darwin_x86_gc.go └── modules.txt └── version └── version.go /.DEREK.yml: -------------------------------------------------------------------------------- 1 | redirect: https://raw.githubusercontent.com/openfaas/faas/master/.DEREK.yml -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | /.git 2 | /nats-queue-worker 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Expected Behaviour 4 | 5 | 6 | 7 | ## Current Behaviour 8 | 9 | 10 | 11 | ## Possible Solution 12 | 13 | 14 | 15 | ## Steps to Reproduce (for bugs) 16 | 17 | 18 | 1. 19 | 2. 20 | 3. 21 | 4. 22 | 23 | ## Context 24 | 25 | 26 | 27 | ## Your Environment 28 | 29 | * Docker version `docker version` (e.g. Docker 17.0.05 ): 30 | 31 | * Are you using Docker Swarm or Kubernetes (FaaS-netes)? 32 | 33 | * Operating System and version (e.g. Linux, Windows, MacOS): 34 | 35 | * Link to your project or a code example to reproduce issue: 36 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | 6 | ## Motivation and Context 7 | 8 | 9 | - [ ] I have raised an issue to propose this change ([required](https://github.com/openfaas/faas/blob/master/CONTRIBUTING.md)) 10 | 11 | ## How Has This Been Tested? 12 | 13 | 14 | 15 | 16 | ## Types of changes 17 | 18 | - [ ] Bug fix (non-breaking change which fixes an issue) 19 | - [ ] New feature (non-breaking change which adds functionality) 20 | - [ ] Breaking change (fix or feature that would cause existing functionality to change) 21 | 22 | ## Checklist: 23 | 24 | 25 | - [ ] My code follows the code style of this project. 26 | - [ ] My change requires a change to the documentation. 27 | - [ ] I have updated the documentation accordingly. 28 | - [ ] I've read the [CONTRIBUTION](https://github.com/openfaas/faas/blob/master/CONTRIBUTING.md) guide 29 | - [ ] I have signed-off my commits with `git commit -s` 30 | - [ ] I have added tests to cover my changes. 31 | - [ ] All new and existing tests passed. 32 | -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | branches: 6 | - '*' 7 | pull_request: 8 | branches: 9 | - '*' 10 | 11 | jobs: 12 | build: 13 | concurrency: 14 | group: ${{ github.ref }} 15 | cancel-in-progress: true 16 | 17 | runs-on: ubuntu-latest 18 | 19 | steps: 20 | - uses: actions/checkout@master 21 | - name: Install Go 22 | uses: actions/setup-go@master 23 | with: 24 | go-version: 1.23.x 25 | - name: Set up QEMU 26 | uses: docker/setup-qemu-action@v3 27 | - name: Set up Docker Buildx 28 | uses: docker/setup-buildx-action@v3 29 | 30 | - name: Get TAG 31 | id: get_tag 32 | run: echo TAG="latest-dev">> $GITHUB_ENV 33 | 34 | - name: Get git commit 35 | id: get_git_commit 36 | run: echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV 37 | - name: Get version 38 | id: get_version 39 | run: echo "VERSION=$(git describe --tags --dirty)" >> $GITHUB_ENV 40 | - name: Get Repo Owner 41 | id: get_repo_owner 42 | run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" > $GITHUB_ENV 43 | 44 | - name: Build multi-arch container image 45 | uses: docker/build-push-action@v5 46 | with: 47 | context: . 48 | file: ./Dockerfile 49 | outputs: "type=image,push=false" 50 | platforms: linux/amd64,linux/arm/v7,linux/arm64 51 | build-args: | 52 | VERSION=${{ env.TAG }} 53 | GIT_COMMIT=${{ github.sha }} 54 | tags: | 55 | ghcr.io/${{ env.REPO_OWNER }}/queue-worker:${{ github.sha }} 56 | -------------------------------------------------------------------------------- /.github/workflows/publish.yaml: -------------------------------------------------------------------------------- 1 | name: publish 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@master 13 | - name: Install Go 14 | uses: actions/setup-go@master 15 | with: 16 | go-version: 1.23.x 17 | - name: Set up QEMU 18 | uses: docker/setup-qemu-action@v3 19 | - name: Set up Docker Buildx 20 | uses: docker/setup-buildx-action@v3 21 | 22 | - name: Get TAG 23 | id: get_tag 24 | run: echo TAG=${GITHUB_REF#refs/tags/} >> $GITHUB_ENV 25 | 26 | - name: Get git commit 27 | id: get_git_commit 28 | run: echo "GIT_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV 29 | - name: Get version 30 | id: get_version 31 | run: echo "VERSION=$(git describe --tags --dirty)" >> $GITHUB_ENV 32 | - name: Get Repo Owner 33 | id: get_repo_owner 34 | run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" > $GITHUB_ENV 35 | 36 | 37 | - name: Login to Docker Registry 38 | uses: docker/login-action@v3 39 | with: 40 | username: ${{ github.repository_owner }} 41 | password: ${{ secrets.GITHUB_TOKEN }} 42 | registry: ghcr.io 43 | - name: Publish multi-arch containers to GHCR 44 | uses: docker/build-push-action@v5 45 | with: 46 | context: . 47 | file: ./Dockerfile 48 | outputs: "type=registry,push=true" 49 | platforms: linux/amd64,linux/arm64 50 | build-args: | 51 | VERSION=${{ env.TAG }} 52 | GIT_COMMIT=${{ github.sha }} 53 | tags: | 54 | ghcr.io/${{ env.REPO_OWNER }}/queue-worker:${{ env.TAG }} 55 | ghcr.io/${{ env.REPO_OWNER }}/queue-worker:${{ github.sha }} 56 | ghcr.io/${{ env.REPO_OWNER }}/queue-worker:latest 57 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.dll 4 | *.so 5 | *.dylib 6 | 7 | # Test binary, build with `go test -c` 8 | *.test 9 | 10 | # Output of the go coverage tool, specifically when used with LiteIDE 11 | *.out 12 | 13 | # Go 14 | .glide/ 15 | .idea 16 | .DS_Store 17 | 18 | nats-queue-worker 19 | queue-worker 20 | Dockerfile.local 21 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | ### License 4 | 5 | This project is licensed under the MIT License. 6 | 7 | ## Guidelines 8 | 9 | See guide for [FaaS](https://github.com/openfaas/faas/blob/master/CONTRIBUTING.md) here. 10 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.23-alpine as build 3 | 4 | ENV GO111MODULE=on 5 | ENV CGO_ENABLED=0 6 | 7 | ARG TARGETPLATFORM 8 | ARG BUILDPLATFORM 9 | ARG TARGETOS 10 | ARG TARGETARCH 11 | 12 | RUN apk add --no-cache git 13 | 14 | WORKDIR /go/src/github.com/openfaas/nats-queue-worker 15 | 16 | COPY vendor vendor 17 | COPY handler handler 18 | COPY version version 19 | COPY nats nats 20 | COPY go.mod . 21 | COPY go.sum . 22 | COPY main.go . 23 | COPY types.go . 24 | COPY readconfig.go . 25 | COPY readconfig_test.go . 26 | 27 | # Run a gofmt and exclude all vendored code. 28 | RUN test -z "$(gofmt -l $(find . -type f -name '*.go' -not -path "./vendor/*"))" 29 | RUN go test $(go list ./... | grep -v integration | grep -v /vendor/ | grep -v /template/) -cover 30 | 31 | RUN CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build --ldflags "-s -w \ 32 | -X \"github.com/openfaas/nats-queue-worker/version.GitCommit=${GIT_COMMIT}\" \ 33 | -X \"github.com/openfaas/nats-queue-worker/version.Version=${VERSION}\"" \ 34 | -a -installsuffix cgo -o worker . 35 | 36 | # we can't add user in next stage because it's from scratch 37 | # ca-certificates and tmp folder are also missing in scratch 38 | # so we add all of it here and copy files in next stage 39 | FROM --platform=${BUILDPLATFORM:-linux/amd64} gcr.io/distroless/static:nonroot 40 | 41 | WORKDIR / 42 | USER nonroot:nonroot 43 | COPY --from=build /go/src/github.com/openfaas/nats-queue-worker/worker . 44 | CMD ["/worker"] 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016-2017 Alex Ellis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Notice 2 | 3 | [NATS Streaming](https://github.com/nats-io/nats-streaming-server) was deprecated in June 2023 by Synadia, and will receive no more updates, including for critical security issues. 4 | 5 | Migrate to OpenFaaS Standard for NATS JetStream, learn more: 6 | 7 | * [Docs: JetStream for OpenFaaS](https://docs.openfaas.com/openfaas-pro/jetstream/) 8 | * [Announcement: The Next Generation of Queuing: JetStream for OpenFaaS](https://www.openfaas.com/blog/jetstream-for-openfaas/) 9 | 10 | ## queue-worker (Community Edition) for NATS Streaming 11 | 12 | [![Go Report Card](https://goreportcard.com/badge/github.com/openfaas/nats-queue-worker)](https://goreportcard.com/badge/github.com/openfaas/nats-queue-worker) 13 | [![Build Status](https://travis-ci.com/openfaas/nats-queue-worker.svg?branch=master)](https://travis-ci.com/openfaas/nats-queue-worker) 14 | 15 | [![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/openfaas/nats-queue-worker?tab=overview) 16 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 17 | [![OpenFaaS](https://img.shields.io/badge/openfaas-serverless-blue.svg)](https://www.openfaas.com) 18 | [![Derek App](https://alexellis.o6s.io/badge?owner=openfaas&repo=nats-queue-worker)](https://github.com/alexellis/derek/) 19 | 20 | The queue-worker (Community Edition) processes asynchronous function invocation requests, you can read more about this in the [async documentation](https://docs.openfaas.com/reference/async/) 21 | 22 | ## Usage 23 | 24 | Screenshots from keynote / video - find out more over at https://www.openfaas.com/ 25 | 26 | screen shot 2017-10-26 at 15 55 25 27 | 28 | screen shot 2017-10-26 at 15 55 19 29 | 30 | screen shot 2017-10-26 at 15 55 06 31 | 32 | ### Configuration 33 | 34 | | Parameter | Description | Default | 35 | | ----------------------- | ---------------------------------- | ---------------------------------------------------------- | 36 | | `write_debug` | Print verbose logs | `false` | 37 | | `faas_gateway_address` | Address of gateway DNS name | `gateway` | 38 | | `faas_gateway_port` | Port of gateway service | `8080` | 39 | | `faas_max_reconnect` | An integer of the amount of reconnection attempts when the NATS connection is lost | `120` | 40 | | `faas_nats_address` | The host at which NATS Streaming can be reached | `nats` | 41 | | `faas_nats_port` | The port at which NATS Streaming can be reached | `4222` | 42 | | `faas_nats_cluster_name` | The name of the target NATS Streaming cluster | `faas-cluster` | 43 | | `faas_reconnect_delay` | Delay between retrying to connect to NATS | `2s` | 44 | | `faas_print_body` | Print the body of the function invocation | `false` | 45 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/openfaas/nats-queue-worker 2 | 3 | go 1.23 4 | toolchain go1.24.1 5 | 6 | require ( 7 | github.com/nats-io/stan.go v0.10.4 8 | github.com/openfaas/faas-provider v0.25.4 9 | ) 10 | 11 | require ( 12 | github.com/gogo/protobuf v1.3.2 // indirect 13 | github.com/klauspost/compress v1.17.11 // indirect 14 | github.com/nats-io/nats-server/v2 v2.10.22 // indirect 15 | github.com/nats-io/nats-streaming-server v0.25.6 // indirect 16 | github.com/nats-io/nats.go v1.37.0 // indirect 17 | github.com/nats-io/nkeys v0.4.8 // indirect 18 | github.com/nats-io/nuid v1.0.1 // indirect 19 | golang.org/x/crypto v0.35.0 // indirect 20 | golang.org/x/sys v0.30.0 // indirect 21 | ) 22 | -------------------------------------------------------------------------------- /handler/handler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "sync" 7 | ) 8 | 9 | const sharedQueue = "faas-request" 10 | 11 | // CreateNATSQueue ready for asynchronous message processing of paylods of 12 | // up to a maximum of 256KB in size. 13 | func CreateNATSQueue(address string, port int, clusterName, channel string, clientConfig NATSConfig) (*NATSQueue, error) { 14 | var err error 15 | natsURL := fmt.Sprintf("nats://%s:%d", address, port) 16 | log.Printf("Opening connection to %s\n", natsURL) 17 | 18 | clientID := clientConfig.GetClientID() 19 | 20 | // If 'channel' is empty, use the previous default. 21 | if channel == "" { 22 | channel = sharedQueue 23 | } 24 | 25 | queue1 := NATSQueue{ 26 | ClientID: clientID, 27 | ClusterID: clusterName, 28 | NATSURL: natsURL, 29 | Topic: channel, 30 | maxReconnect: clientConfig.GetMaxReconnect(), 31 | reconnectDelay: clientConfig.GetReconnectDelay(), 32 | ncMutex: &sync.RWMutex{}, 33 | } 34 | 35 | err = queue1.connect() 36 | 37 | return &queue1, err 38 | } 39 | -------------------------------------------------------------------------------- /handler/handler_test.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "os" 5 | "strings" 6 | "testing" 7 | 8 | "github.com/openfaas/nats-queue-worker/nats" 9 | ) 10 | 11 | func Test_GetClientID_ContainsHostname(t *testing.T) { 12 | c := DefaultNATSConfig{} 13 | 14 | val := c.GetClientID() 15 | 16 | hostname, _ := os.Hostname() 17 | encodedHostname := nats.GetClientID(hostname) 18 | if !strings.HasSuffix(val, encodedHostname) { 19 | t.Errorf("GetClientID should contain hostname as suffix, got: %s", val) 20 | t.Fail() 21 | } 22 | } 23 | 24 | func TestCreategetClientID(t *testing.T) { 25 | clientID := getClientID("computer-a") 26 | want := "faas-publisher-computer-a" 27 | if clientID != want { 28 | t.Logf("Want clientID: `%s`, but got: `%s`\n", want, clientID) 29 | t.Fail() 30 | } 31 | } 32 | 33 | func TestCreategetClientIDWhenHostHasUnsupportedCharacters(t *testing.T) { 34 | clientID := getClientID("computer-a.acme.com") 35 | want := "faas-publisher-computer-a_acme_com" 36 | if clientID != want { 37 | t.Logf("Want clientID: `%s`, but got: `%s`\n", want, clientID) 38 | t.Fail() 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /handler/nats_config.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "os" 5 | "time" 6 | 7 | "github.com/openfaas/nats-queue-worker/nats" 8 | ) 9 | 10 | type NATSConfig interface { 11 | GetClientID() string 12 | GetMaxReconnect() int 13 | GetReconnectDelay() time.Duration 14 | } 15 | 16 | type DefaultNATSConfig struct { 17 | maxReconnect int 18 | reconnectDelay time.Duration 19 | } 20 | 21 | func NewDefaultNATSConfig(maxReconnect int, reconnectDelay time.Duration) DefaultNATSConfig { 22 | return DefaultNATSConfig{maxReconnect, reconnectDelay} 23 | } 24 | 25 | // GetClientID returns the ClientID assigned to this producer/consumer. 26 | func (DefaultNATSConfig) GetClientID() string { 27 | val, _ := os.Hostname() 28 | return getClientID(val) 29 | } 30 | 31 | func (c DefaultNATSConfig) GetMaxReconnect() int { 32 | return c.maxReconnect 33 | } 34 | 35 | func (c DefaultNATSConfig) GetReconnectDelay() time.Duration { 36 | return c.reconnectDelay 37 | } 38 | 39 | func getClientID(hostname string) string { 40 | return "faas-publisher-" + nats.GetClientID(hostname) 41 | } 42 | -------------------------------------------------------------------------------- /handler/nats_queue.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log" 7 | "sync" 8 | "time" 9 | 10 | stan "github.com/nats-io/stan.go" 11 | ftypes "github.com/openfaas/faas-provider/types" 12 | ) 13 | 14 | // NATSQueue queue for work 15 | type NATSQueue struct { 16 | nc stan.Conn 17 | ncMutex *sync.RWMutex 18 | maxReconnect int 19 | reconnectDelay time.Duration 20 | 21 | // ClientID for NATS Streaming 22 | ClientID string 23 | 24 | // ClusterID in NATS Streaming 25 | ClusterID string 26 | 27 | // NATSURL URL to connect to NATS 28 | NATSURL string 29 | 30 | // Topic to respond to 31 | Topic string 32 | } 33 | 34 | // Queue request for processing 35 | func (q *NATSQueue) Queue(req *ftypes.QueueRequest) error { 36 | callId := "" 37 | 38 | if v := req.Header.Get("X-Call-Id"); len(v) > 0 { 39 | callId = v 40 | } 41 | max := 256 * 1000 42 | if len(req.Body) > max { 43 | return fmt.Errorf("request body too large for OpenFaaS CE (%d bytes), maximum: %d bytes", len(req.Body), 256*1000) 44 | } 45 | 46 | log.Printf("[%s] Queueing (%d) bytes for: %s.\n", callId, len(req.Body), req.Function) 47 | 48 | out, err := json.Marshal(req) 49 | if err != nil { 50 | log.Println(err) 51 | } 52 | 53 | q.ncMutex.RLock() 54 | nc := q.nc 55 | q.ncMutex.RUnlock() 56 | 57 | queueName := q.Topic 58 | if len(req.QueueName) > 0 { 59 | queueName = req.QueueName 60 | } 61 | 62 | return nc.Publish(queueName, out) 63 | } 64 | 65 | func (q *NATSQueue) connect() error { 66 | log.Printf("Connect: %s\n", q.NATSURL) 67 | 68 | nc, err := stan.Connect( 69 | q.ClusterID, 70 | q.ClientID, 71 | stan.NatsURL(q.NATSURL), 72 | stan.SetConnectionLostHandler(func(conn stan.Conn, err error) { 73 | log.Printf("Disconnected from %s\n", q.NATSURL) 74 | 75 | q.reconnect() 76 | }), 77 | ) 78 | 79 | if err != nil { 80 | return err 81 | } 82 | 83 | q.ncMutex.Lock() 84 | q.nc = nc 85 | q.ncMutex.Unlock() 86 | 87 | return nil 88 | } 89 | 90 | func (q *NATSQueue) reconnect() { 91 | log.Printf("Reconnect\n") 92 | 93 | for i := 0; i < q.maxReconnect; i++ { 94 | time.Sleep(time.Duration(i) * q.reconnectDelay) 95 | 96 | if err := q.connect(); err == nil { 97 | log.Printf("Reconnecting (%d/%d) to %s. OK\n", i+1, q.maxReconnect, q.NATSURL) 98 | 99 | return 100 | } 101 | 102 | log.Printf("Reconnecting (%d/%d) to %s failed\n", i+1, q.maxReconnect, q.NATSURL) 103 | } 104 | 105 | log.Printf("Reached reconnection limit (%d) for %s\n", q.maxReconnect, q.NATSURL) 106 | 107 | } 108 | -------------------------------------------------------------------------------- /main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | ftypes "github.com/openfaas/faas-provider/types" 7 | ) 8 | 9 | func Test_makeFunctionURL_DefaultPathQS_IncludesGWAddress(t *testing.T) { 10 | config := QueueWorkerConfig{ 11 | FunctionSuffix: "", 12 | GatewayAddress: "gateway", 13 | GatewayPort: 8080, 14 | } 15 | req := ftypes.QueueRequest{ 16 | Function: "function1", 17 | Path: "/", 18 | } 19 | 20 | fnURL := makeFunctionURL(&req, &config, req.Path, req.QueryString) 21 | wantURL := "http://gateway:8080/function/function1/" 22 | if fnURL != wantURL { 23 | t.Errorf("want %s, got %s", wantURL, fnURL) 24 | } 25 | } 26 | 27 | func Test_makeFunctionURL_DefaultPathQS_WithQS(t *testing.T) { 28 | config := QueueWorkerConfig{ 29 | FunctionSuffix: "", 30 | GatewayAddress: "gateway", 31 | GatewayPort: 8080, 32 | } 33 | req := ftypes.QueueRequest{ 34 | Function: "function1", 35 | QueryString: "user=1", 36 | } 37 | 38 | fnURL := makeFunctionURL(&req, &config, req.Path, req.QueryString) 39 | wantURL := "http://gateway:8080/function/function1/?user=1" 40 | if fnURL != wantURL { 41 | t.Errorf("want %s, got %s", wantURL, fnURL) 42 | } 43 | } 44 | 45 | func Test_makeFunctionURL_DefaultPathQS_WithPath(t *testing.T) { 46 | config := QueueWorkerConfig{ 47 | FunctionSuffix: "", 48 | GatewayAddress: "gateway", 49 | GatewayPort: 8080, 50 | } 51 | req := ftypes.QueueRequest{ 52 | Function: "function1", 53 | Path: "/resources/main.css", 54 | } 55 | 56 | fnURL := makeFunctionURL(&req, &config, req.Path, req.QueryString) 57 | wantURL := "http://gateway:8080/function/function1/resources/main.css" 58 | if fnURL != wantURL { 59 | t.Errorf("want %s, got %s", wantURL, fnURL) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /nats/client.go: -------------------------------------------------------------------------------- 1 | package nats 2 | 3 | import "regexp" 4 | 5 | var supportedCharacters = regexp.MustCompile("[^a-zA-Z0-9-_]+") 6 | 7 | func GetClientID(value string) string { 8 | return supportedCharacters.ReplaceAllString(value, "_") 9 | } 10 | -------------------------------------------------------------------------------- /nats/client_test.go: -------------------------------------------------------------------------------- 1 | package nats 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestGetClientID(t *testing.T) { 8 | clientID := GetClientID("computer-a") 9 | want := "computer-a" 10 | if clientID != want { 11 | t.Logf("Want clientID: `%s`, but got: `%s`\n", want, clientID) 12 | t.Fail() 13 | } 14 | } 15 | 16 | func TestGetClientIDWhenHostHasUnsupportedCharacters(t *testing.T) { 17 | clientID := GetClientID("computer-a.acme.com") 18 | want := "computer-a_acme_com" 19 | if clientID != want { 20 | t.Logf("Want clientID: `%s`, but got: `%s`\n", want, clientID) 21 | t.Fail() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /readconfig_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | "time" 7 | ) 8 | 9 | func Test_ReadConfig_IncorrectPortValue(t *testing.T) { 10 | 11 | readConfig := ReadConfig{} 12 | 13 | os.Setenv("faas_gateway_port", "8080a") 14 | _, err := readConfig.Read() 15 | want := "converting faas_gateway_port 8080a to int error: strconv.Atoi: parsing \"8080a\": invalid syntax" 16 | 17 | if err.Error() != want { 18 | t.Errorf("basicfaas_gateway_port want %q, got %q", want, err.Error()) 19 | 20 | } 21 | } 22 | 23 | func Test_ReadConfig(t *testing.T) { 24 | 25 | readConfig := ReadConfig{} 26 | 27 | os.Setenv("faas_nats_address", "test_nats") 28 | os.Setenv("faas_nats_port", "1234") 29 | os.Setenv("faas_nats_cluster_name", "example-nats-cluster") 30 | os.Setenv("faas_nats_channel", "foo") 31 | os.Setenv("faas_nats_queue_group", "bar") 32 | os.Setenv("faas_gateway_address", "test_gatewayaddr") 33 | os.Setenv("faas_gateway_port", "8080") 34 | os.Setenv("faas_print_body", "true") 35 | os.Setenv("write_debug", "true") 36 | os.Setenv("max_inflight", "10") 37 | os.Setenv("ack_wait", "10ms") 38 | 39 | config, _ := readConfig.Read() 40 | 41 | want := "test_nats" 42 | if config.NatsAddress != want { 43 | t.Logf("NatsAddress want `%s`, got `%s`\n", want, config.NatsAddress) 44 | t.Fail() 45 | } 46 | 47 | wantNatsPort := 1234 48 | if config.NatsPort != wantNatsPort { 49 | t.Logf("NatsPort want `%d`, got `%d`\n", wantNatsPort, config.NatsPort) 50 | t.Fail() 51 | } 52 | 53 | wantNatsClusterName := "example-nats-cluster" 54 | if config.NatsClusterName != wantNatsClusterName { 55 | t.Logf("NatsClusterName want `%s`, got `%s`\n", wantNatsClusterName, config.NatsClusterName) 56 | t.Fail() 57 | } 58 | 59 | want = "test_gatewayaddr" 60 | if config.GatewayAddress != want { 61 | t.Logf("GatewayAddress want `%s`, got `%s`\n", want, config.GatewayAddress) 62 | t.Fail() 63 | } 64 | 65 | wantGatewayPort := 8080 66 | if config.GatewayPort != wantGatewayPort { 67 | t.Logf("GatewayPort want `%d`, got `%d`\n", wantGatewayPort, config.GatewayPort) 68 | t.Fail() 69 | } 70 | 71 | want = "test_gatewayaddr:8080" 72 | if config.GatewayAddressURL() != want { 73 | t.Logf("GatewayAddressURL want `%s`, got `%s`\n", want, config.GatewayAddressURL()) 74 | t.Fail() 75 | } 76 | 77 | if config.DebugPrintBody != true { 78 | t.Logf("DebugPrintBody want `%v`, got `%v`\n", true, config.DebugPrintBody) 79 | t.Fail() 80 | } 81 | 82 | if config.WriteDebug != true { 83 | t.Logf("WriteDebug want `%v`, got `%v`\n", true, config.WriteDebug) 84 | t.Fail() 85 | } 86 | 87 | wantAckWait := time.Millisecond * 10 88 | if config.AckWait != wantAckWait { 89 | t.Logf("maxInflight want `%v`, got `%v`\n", wantAckWait, config.AckWait) 90 | t.Fail() 91 | } 92 | 93 | os.Unsetenv("max_inflight") 94 | os.Unsetenv("ack_wait") 95 | 96 | config, _ = readConfig.Read() 97 | 98 | wantAckWait = time.Second * 30 99 | if config.AckWait != wantAckWait { 100 | t.Logf("maxInflight want `%v`, got `%v`\n", wantAckWait, config.AckWait) 101 | t.Fail() 102 | } 103 | 104 | os.Setenv("max_inflight", "10.00") 105 | os.Setenv("ack_wait", "10") 106 | 107 | config, _ = readConfig.Read() 108 | 109 | wantAckWait = time.Second * 30 110 | if config.AckWait != wantAckWait { 111 | t.Logf("ackWait want `%v`, got `%v`\n", wantAckWait, config.AckWait) 112 | t.Fail() 113 | } 114 | } 115 | 116 | func Test_ReadConfig_NatsQueueGroup(t *testing.T) { 117 | readConfig := ReadConfig{} 118 | 119 | os.Setenv("faas_nats_queue_group", "") 120 | cfg, _ := readConfig.Read() 121 | 122 | want := "faas" 123 | if cfg.NatsQueueGroup != want { 124 | t.Errorf("NatsQueueGroup want %v, got %v", want, cfg.NatsQueueGroup) 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of GoGo authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS file, which 3 | # lists people. For example, employees are listed in CONTRIBUTORS, 4 | # but not in AUTHORS, because the employer holds the copyright. 5 | 6 | # Names should be added to this file as one of 7 | # Organization's name 8 | # Individual's name 9 | # Individual's name 10 | 11 | # Please keep the list sorted. 12 | 13 | Sendgrid, Inc 14 | Vastech SA (PTY) LTD 15 | Walter Schulze 16 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Anton Povarov 2 | Brian Goff 3 | Clayton Coleman 4 | Denis Smirnov 5 | DongYun Kang 6 | Dwayne Schultz 7 | Georg Apitz 8 | Gustav Paul 9 | Johan Brandhorst 10 | John Shahid 11 | John Tuley 12 | Laurent 13 | Patrick Lee 14 | Peter Edge 15 | Roger Johansson 16 | Sam Nguyen 17 | Sergio Arbeo 18 | Stephen J Day 19 | Tamir Duberstein 20 | Todd Eisenberger 21 | Tormod Erevik Lea 22 | Vyacheslav Kim 23 | Walter Schulze 24 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, The GoGo Authors. All rights reserved. 2 | 3 | Protocol Buffers for Go with Gadgets 4 | 5 | Go support for Protocol Buffers - Google's data interchange format 6 | 7 | Copyright 2010 The Go Authors. All rights reserved. 8 | https://github.com/golang/protobuf 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are 12 | met: 13 | 14 | * Redistributions of source code must retain the above copyright 15 | notice, this list of conditions and the following disclaimer. 16 | * Redistributions in binary form must reproduce the above 17 | copyright notice, this list of conditions and the following disclaimer 18 | in the documentation and/or other materials provided with the 19 | distribution. 20 | * Neither the name of Google Inc. nor the names of its 21 | contributors may be used to endorse or promote products derived from 22 | this software without specific prior written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | 36 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/gogoproto/Makefile: -------------------------------------------------------------------------------- 1 | # Protocol Buffers for Go with Gadgets 2 | # 3 | # Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | # http://github.com/gogo/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 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 | 29 | regenerate: 30 | go install github.com/gogo/protobuf/protoc-gen-gogo 31 | protoc --gogo_out=Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:../../../../ --proto_path=../../../../:../protobuf/:. *.proto 32 | 33 | restore: 34 | cp gogo.pb.golden gogo.pb.go 35 | 36 | preserve: 37 | cp gogo.pb.go gogo.pb.golden 38 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/gogoproto/gogo.pb.golden: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. 2 | // source: gogo.proto 3 | // DO NOT EDIT! 4 | 5 | package gogoproto 6 | 7 | import proto "github.com/gogo/protobuf/proto" 8 | import json "encoding/json" 9 | import math "math" 10 | import google_protobuf "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" 11 | 12 | // Reference proto, json, and math imports to suppress error if they are not otherwise used. 13 | var _ = proto.Marshal 14 | var _ = &json.SyntaxError{} 15 | var _ = math.Inf 16 | 17 | var E_Nullable = &proto.ExtensionDesc{ 18 | ExtendedType: (*google_protobuf.FieldOptions)(nil), 19 | ExtensionType: (*bool)(nil), 20 | Field: 51235, 21 | Name: "gogoproto.nullable", 22 | Tag: "varint,51235,opt,name=nullable", 23 | } 24 | 25 | var E_Embed = &proto.ExtensionDesc{ 26 | ExtendedType: (*google_protobuf.FieldOptions)(nil), 27 | ExtensionType: (*bool)(nil), 28 | Field: 51236, 29 | Name: "gogoproto.embed", 30 | Tag: "varint,51236,opt,name=embed", 31 | } 32 | 33 | var E_Customtype = &proto.ExtensionDesc{ 34 | ExtendedType: (*google_protobuf.FieldOptions)(nil), 35 | ExtensionType: (*string)(nil), 36 | Field: 51237, 37 | Name: "gogoproto.customtype", 38 | Tag: "bytes,51237,opt,name=customtype", 39 | } 40 | 41 | func init() { 42 | proto.RegisterExtension(E_Nullable) 43 | proto.RegisterExtension(E_Embed) 44 | proto.RegisterExtension(E_Customtype) 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | install: 33 | go install 34 | 35 | test: install generate-test-pbs 36 | go test 37 | 38 | 39 | generate-test-pbs: 40 | make install 41 | make -C test_proto 42 | make -C proto3_proto 43 | make 44 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/custom_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 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 | 29 | package proto 30 | 31 | import "reflect" 32 | 33 | type custom interface { 34 | Marshal() ([]byte, error) 35 | Unmarshal(data []byte) error 36 | Size() int 37 | } 38 | 39 | var customType = reflect.TypeOf((*custom)(nil)).Elem() 40 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/deprecated.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2018 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package proto 33 | 34 | import "errors" 35 | 36 | // Deprecated: do not use. 37 | type Stats struct{ Emalloc, Dmalloc, Encode, Decode, Chit, Cmiss, Size uint64 } 38 | 39 | // Deprecated: do not use. 40 | func GetStats() Stats { return Stats{} } 41 | 42 | // Deprecated: do not use. 43 | func MarshalMessageSet(interface{}) ([]byte, error) { 44 | return nil, errors.New("proto: not implemented") 45 | } 46 | 47 | // Deprecated: do not use. 48 | func UnmarshalMessageSet([]byte, interface{}) error { 49 | return errors.New("proto: not implemented") 50 | } 51 | 52 | // Deprecated: do not use. 53 | func MarshalMessageSetJSON(interface{}) ([]byte, error) { 54 | return nil, errors.New("proto: not implemented") 55 | } 56 | 57 | // Deprecated: do not use. 58 | func UnmarshalMessageSetJSON([]byte, interface{}) error { 59 | return errors.New("proto: not implemented") 60 | } 61 | 62 | // Deprecated: do not use. 63 | func RegisterMessageSetType(Message, int32, string) {} 64 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/duration_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2016, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 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 | 29 | package proto 30 | 31 | import ( 32 | "reflect" 33 | "time" 34 | ) 35 | 36 | var durationType = reflect.TypeOf((*time.Duration)(nil)).Elem() 37 | 38 | type duration struct { 39 | Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` 40 | Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` 41 | } 42 | 43 | func (m *duration) Reset() { *m = duration{} } 44 | func (*duration) ProtoMessage() {} 45 | func (*duration) String() string { return "duration" } 46 | 47 | func init() { 48 | RegisterType((*duration)(nil), "gogo.protobuf.proto.duration") 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/encode_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 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 | 29 | package proto 30 | 31 | func NewRequiredNotSetError(field string) *RequiredNotSetError { 32 | return &RequiredNotSetError{field} 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/lib_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 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 | 29 | package proto 30 | 31 | import ( 32 | "encoding/json" 33 | "strconv" 34 | ) 35 | 36 | type Sizer interface { 37 | Size() int 38 | } 39 | 40 | type ProtoSizer interface { 41 | ProtoSize() int 42 | } 43 | 44 | func MarshalJSONEnum(m map[int32]string, value int32) ([]byte, error) { 45 | s, ok := m[value] 46 | if !ok { 47 | s = strconv.Itoa(int(value)) 48 | } 49 | return json.Marshal(s) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/pointer_reflect_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 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 | 29 | // +build purego appengine js 30 | 31 | // This file contains an implementation of proto field accesses using package reflect. 32 | // It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can 33 | // be used on App Engine. 34 | 35 | package proto 36 | 37 | import ( 38 | "reflect" 39 | ) 40 | 41 | // TODO: untested, so probably incorrect. 42 | 43 | func (p pointer) getRef() pointer { 44 | return pointer{v: p.v.Addr()} 45 | } 46 | 47 | func (p pointer) appendRef(v pointer, typ reflect.Type) { 48 | slice := p.getSlice(typ) 49 | elem := v.asPointerTo(typ).Elem() 50 | newSlice := reflect.Append(slice, elem) 51 | slice.Set(newSlice) 52 | } 53 | 54 | func (p pointer) getSlice(typ reflect.Type) reflect.Value { 55 | sliceTyp := reflect.SliceOf(typ) 56 | slice := p.asPointerTo(sliceTyp) 57 | slice = slice.Elem() 58 | return slice 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/pointer_unsafe_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 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 | 29 | // +build !purego,!appengine,!js 30 | 31 | // This file contains the implementation of the proto field accesses using package unsafe. 32 | 33 | package proto 34 | 35 | import ( 36 | "reflect" 37 | "unsafe" 38 | ) 39 | 40 | func (p pointer) getRef() pointer { 41 | return pointer{p: (unsafe.Pointer)(&p.p)} 42 | } 43 | 44 | func (p pointer) appendRef(v pointer, typ reflect.Type) { 45 | slice := p.getSlice(typ) 46 | elem := v.asPointerTo(typ).Elem() 47 | newSlice := reflect.Append(slice, elem) 48 | slice.Set(newSlice) 49 | } 50 | 51 | func (p pointer) getSlice(typ reflect.Type) reflect.Value { 52 | sliceTyp := reflect.SliceOf(typ) 53 | slice := p.asPointerTo(sliceTyp) 54 | slice = slice.Elem() 55 | return slice 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/properties_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2018, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 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 | 29 | package proto 30 | 31 | import ( 32 | "reflect" 33 | ) 34 | 35 | var sizerType = reflect.TypeOf((*Sizer)(nil)).Elem() 36 | var protosizerType = reflect.TypeOf((*ProtoSizer)(nil)).Elem() 37 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/skip_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 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 | 29 | package proto 30 | 31 | import ( 32 | "fmt" 33 | "io" 34 | ) 35 | 36 | func Skip(data []byte) (n int, err error) { 37 | l := len(data) 38 | index := 0 39 | for index < l { 40 | var wire uint64 41 | for shift := uint(0); ; shift += 7 { 42 | if index >= l { 43 | return 0, io.ErrUnexpectedEOF 44 | } 45 | b := data[index] 46 | index++ 47 | wire |= (uint64(b) & 0x7F) << shift 48 | if b < 0x80 { 49 | break 50 | } 51 | } 52 | wireType := int(wire & 0x7) 53 | switch wireType { 54 | case 0: 55 | for { 56 | if index >= l { 57 | return 0, io.ErrUnexpectedEOF 58 | } 59 | index++ 60 | if data[index-1] < 0x80 { 61 | break 62 | } 63 | } 64 | return index, nil 65 | case 1: 66 | index += 8 67 | return index, nil 68 | case 2: 69 | var length int 70 | for shift := uint(0); ; shift += 7 { 71 | if index >= l { 72 | return 0, io.ErrUnexpectedEOF 73 | } 74 | b := data[index] 75 | index++ 76 | length |= (int(b) & 0x7F) << shift 77 | if b < 0x80 { 78 | break 79 | } 80 | } 81 | index += length 82 | return index, nil 83 | case 3: 84 | for { 85 | var innerWire uint64 86 | var start int = index 87 | for shift := uint(0); ; shift += 7 { 88 | if index >= l { 89 | return 0, io.ErrUnexpectedEOF 90 | } 91 | b := data[index] 92 | index++ 93 | innerWire |= (uint64(b) & 0x7F) << shift 94 | if b < 0x80 { 95 | break 96 | } 97 | } 98 | innerWireType := int(innerWire & 0x7) 99 | if innerWireType == 4 { 100 | break 101 | } 102 | next, err := Skip(data[start:]) 103 | if err != nil { 104 | return 0, err 105 | } 106 | index = start + next 107 | } 108 | return index, nil 109 | case 4: 110 | return index, nil 111 | case 5: 112 | index += 4 113 | return index, nil 114 | default: 115 | return 0, fmt.Errorf("proto: illegal wireType %d", wireType) 116 | } 117 | } 118 | panic("unreachable") 119 | } 120 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/text_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2013, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 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 | 29 | package proto 30 | 31 | import ( 32 | "fmt" 33 | "reflect" 34 | ) 35 | 36 | func (tm *TextMarshaler) writeEnum(w *textWriter, v reflect.Value, props *Properties) error { 37 | m, ok := enumStringMaps[props.Enum] 38 | if !ok { 39 | if err := tm.writeAny(w, v, props); err != nil { 40 | return err 41 | } 42 | } 43 | key := int32(0) 44 | if v.Kind() == reflect.Ptr { 45 | key = int32(v.Elem().Int()) 46 | } else { 47 | key = int32(v.Int()) 48 | } 49 | s, ok := m[key] 50 | if !ok { 51 | if err := tm.writeAny(w, v, props); err != nil { 52 | return err 53 | } 54 | } 55 | _, err := fmt.Fprint(w, s) 56 | return err 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/proto/timestamp_gogo.go: -------------------------------------------------------------------------------- 1 | // Protocol Buffers for Go with Gadgets 2 | // 3 | // Copyright (c) 2016, The GoGo Authors. All rights reserved. 4 | // http://github.com/gogo/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 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 | 29 | package proto 30 | 31 | import ( 32 | "reflect" 33 | "time" 34 | ) 35 | 36 | var timeType = reflect.TypeOf((*time.Time)(nil)).Elem() 37 | 38 | type timestamp struct { 39 | Seconds int64 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"` 40 | Nanos int32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"` 41 | } 42 | 43 | func (m *timestamp) Reset() { *m = timestamp{} } 44 | func (*timestamp) ProtoMessage() {} 45 | func (*timestamp) String() string { return "timestamp" } 46 | 47 | func init() { 48 | RegisterType((*timestamp)(nil), "gogo.protobuf.proto.timestamp") 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/gogo/protobuf/protoc-gen-gogo/descriptor/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | regenerate: 33 | go install github.com/gogo/protobuf/protoc-gen-gogo 34 | go install github.com/gogo/protobuf/protoc-gen-gostring 35 | protoc --gogo_out=. -I=../../protobuf/google/protobuf ../../protobuf/google/protobuf/descriptor.proto 36 | protoc --gostring_out=. -I=../../protobuf/google/protobuf ../../protobuf/google/protobuf/descriptor.proto 37 | -------------------------------------------------------------------------------- /vendor/github.com/klauspost/compress/flate/matchlen_amd64.go: -------------------------------------------------------------------------------- 1 | //go:build amd64 && !appengine && !noasm && gc 2 | // +build amd64,!appengine,!noasm,gc 3 | 4 | // Copyright 2019+ Klaus Post. All rights reserved. 5 | // License information can be found in the LICENSE file. 6 | 7 | package flate 8 | 9 | // matchLen returns how many bytes match in a and b 10 | // 11 | // It assumes that: 12 | // 13 | // len(a) <= len(b) and len(a) > 0 14 | // 15 | //go:noescape 16 | func matchLen(a []byte, b []byte) int 17 | -------------------------------------------------------------------------------- /vendor/github.com/klauspost/compress/flate/matchlen_amd64.s: -------------------------------------------------------------------------------- 1 | // Copied from S2 implementation. 2 | 3 | //go:build !appengine && !noasm && gc && !noasm 4 | 5 | #include "textflag.h" 6 | 7 | // func matchLen(a []byte, b []byte) int 8 | TEXT ·matchLen(SB), NOSPLIT, $0-56 9 | MOVQ a_base+0(FP), AX 10 | MOVQ b_base+24(FP), CX 11 | MOVQ a_len+8(FP), DX 12 | 13 | // matchLen 14 | XORL SI, SI 15 | CMPL DX, $0x08 16 | JB matchlen_match4_standalone 17 | 18 | matchlen_loopback_standalone: 19 | MOVQ (AX)(SI*1), BX 20 | XORQ (CX)(SI*1), BX 21 | JZ matchlen_loop_standalone 22 | 23 | #ifdef GOAMD64_v3 24 | TZCNTQ BX, BX 25 | #else 26 | BSFQ BX, BX 27 | #endif 28 | SHRL $0x03, BX 29 | LEAL (SI)(BX*1), SI 30 | JMP gen_match_len_end 31 | 32 | matchlen_loop_standalone: 33 | LEAL -8(DX), DX 34 | LEAL 8(SI), SI 35 | CMPL DX, $0x08 36 | JAE matchlen_loopback_standalone 37 | 38 | matchlen_match4_standalone: 39 | CMPL DX, $0x04 40 | JB matchlen_match2_standalone 41 | MOVL (AX)(SI*1), BX 42 | CMPL (CX)(SI*1), BX 43 | JNE matchlen_match2_standalone 44 | LEAL -4(DX), DX 45 | LEAL 4(SI), SI 46 | 47 | matchlen_match2_standalone: 48 | CMPL DX, $0x02 49 | JB matchlen_match1_standalone 50 | MOVW (AX)(SI*1), BX 51 | CMPW (CX)(SI*1), BX 52 | JNE matchlen_match1_standalone 53 | LEAL -2(DX), DX 54 | LEAL 2(SI), SI 55 | 56 | matchlen_match1_standalone: 57 | CMPL DX, $0x01 58 | JB gen_match_len_end 59 | MOVB (AX)(SI*1), BL 60 | CMPB (CX)(SI*1), BL 61 | JNE gen_match_len_end 62 | INCL SI 63 | 64 | gen_match_len_end: 65 | MOVQ SI, ret+48(FP) 66 | RET 67 | -------------------------------------------------------------------------------- /vendor/github.com/klauspost/compress/flate/matchlen_generic.go: -------------------------------------------------------------------------------- 1 | //go:build !amd64 || appengine || !gc || noasm 2 | // +build !amd64 appengine !gc noasm 3 | 4 | // Copyright 2019+ Klaus Post. All rights reserved. 5 | // License information can be found in the LICENSE file. 6 | 7 | package flate 8 | 9 | import ( 10 | "encoding/binary" 11 | "math/bits" 12 | ) 13 | 14 | // matchLen returns the maximum common prefix length of a and b. 15 | // a must be the shortest of the two. 16 | func matchLen(a, b []byte) (n int) { 17 | for ; len(a) >= 8 && len(b) >= 8; a, b = a[8:], b[8:] { 18 | diff := binary.LittleEndian.Uint64(a) ^ binary.LittleEndian.Uint64(b) 19 | if diff != 0 { 20 | return n + bits.TrailingZeros64(diff)>>3 21 | } 22 | n += 8 23 | } 24 | 25 | for i := range a { 26 | if a[i] != b[i] { 27 | break 28 | } 29 | n++ 30 | } 31 | return n 32 | 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/klauspost/compress/flate/regmask_amd64.go: -------------------------------------------------------------------------------- 1 | package flate 2 | 3 | const ( 4 | // Masks for shifts with register sizes of the shift value. 5 | // This can be used to work around the x86 design of shifting by mod register size. 6 | // It can be used when a variable shift is always smaller than the register size. 7 | 8 | // reg8SizeMaskX - shift value is 8 bits, shifted is X 9 | reg8SizeMask8 = 7 10 | reg8SizeMask16 = 15 11 | reg8SizeMask32 = 31 12 | reg8SizeMask64 = 63 13 | 14 | // reg16SizeMaskX - shift value is 16 bits, shifted is X 15 | reg16SizeMask8 = reg8SizeMask8 16 | reg16SizeMask16 = reg8SizeMask16 17 | reg16SizeMask32 = reg8SizeMask32 18 | reg16SizeMask64 = reg8SizeMask64 19 | 20 | // reg32SizeMaskX - shift value is 32 bits, shifted is X 21 | reg32SizeMask8 = reg8SizeMask8 22 | reg32SizeMask16 = reg8SizeMask16 23 | reg32SizeMask32 = reg8SizeMask32 24 | reg32SizeMask64 = reg8SizeMask64 25 | 26 | // reg64SizeMaskX - shift value is 64 bits, shifted is X 27 | reg64SizeMask8 = reg8SizeMask8 28 | reg64SizeMask16 = reg8SizeMask16 29 | reg64SizeMask32 = reg8SizeMask32 30 | reg64SizeMask64 = reg8SizeMask64 31 | 32 | // regSizeMaskUintX - shift value is uint, shifted is X 33 | regSizeMaskUint8 = reg8SizeMask8 34 | regSizeMaskUint16 = reg8SizeMask16 35 | regSizeMaskUint32 = reg8SizeMask32 36 | regSizeMaskUint64 = reg8SizeMask64 37 | ) 38 | -------------------------------------------------------------------------------- /vendor/github.com/klauspost/compress/flate/regmask_other.go: -------------------------------------------------------------------------------- 1 | //go:build !amd64 2 | // +build !amd64 3 | 4 | package flate 5 | 6 | const ( 7 | // Masks for shifts with register sizes of the shift value. 8 | // This can be used to work around the x86 design of shifting by mod register size. 9 | // It can be used when a variable shift is always smaller than the register size. 10 | 11 | // reg8SizeMaskX - shift value is 8 bits, shifted is X 12 | reg8SizeMask8 = 0xff 13 | reg8SizeMask16 = 0xff 14 | reg8SizeMask32 = 0xff 15 | reg8SizeMask64 = 0xff 16 | 17 | // reg16SizeMaskX - shift value is 16 bits, shifted is X 18 | reg16SizeMask8 = 0xffff 19 | reg16SizeMask16 = 0xffff 20 | reg16SizeMask32 = 0xffff 21 | reg16SizeMask64 = 0xffff 22 | 23 | // reg32SizeMaskX - shift value is 32 bits, shifted is X 24 | reg32SizeMask8 = 0xffffffff 25 | reg32SizeMask16 = 0xffffffff 26 | reg32SizeMask32 = 0xffffffff 27 | reg32SizeMask64 = 0xffffffff 28 | 29 | // reg64SizeMaskX - shift value is 64 bits, shifted is X 30 | reg64SizeMask8 = 0xffffffffffffffff 31 | reg64SizeMask16 = 0xffffffffffffffff 32 | reg64SizeMask32 = 0xffffffffffffffff 33 | reg64SizeMask64 = 0xffffffffffffffff 34 | 35 | // regSizeMaskUintX - shift value is uint, shifted is X 36 | regSizeMaskUint8 = ^uint(0) 37 | regSizeMaskUint16 = ^uint(0) 38 | regSizeMaskUint32 = ^uint(0) 39 | regSizeMaskUint64 = ^uint(0) 40 | ) 41 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/.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 | 24 | # Emacs 25 | *~ 26 | \#*\# 27 | .\#* 28 | 29 | # vi/vim 30 | .??*.swp 31 | 32 | # Mac 33 | .DS_Store 34 | 35 | # Eclipse 36 | .project 37 | .settings/ 38 | 39 | # bin 40 | 41 | # Goland 42 | .idea 43 | 44 | # VS Code 45 | .vscode -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/.golangci.yaml: -------------------------------------------------------------------------------- 1 | issues: 2 | max-issues-per-linter: 0 3 | max-same-issues: 0 4 | exclude-rules: 5 | - linters: 6 | - errcheck 7 | text: "Unsubscribe" 8 | - linters: 9 | - errcheck 10 | text: "Drain" 11 | - linters: 12 | - errcheck 13 | text: "msg.Ack" 14 | - linters: 15 | - errcheck 16 | text: "watcher.Stop" 17 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - "1.22.x" 4 | - "1.21.x" 5 | go_import_path: github.com/nats-io/nats.go 6 | install: 7 | - go get -t ./... 8 | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin 9 | - if [[ "$TRAVIS_GO_VERSION" =~ 1.22 ]]; then 10 | go install github.com/mattn/goveralls@latest; 11 | go install github.com/wadey/gocovmerge@latest; 12 | go install honnef.co/go/tools/cmd/staticcheck@latest; 13 | go install github.com/client9/misspell/cmd/misspell@latest; 14 | fi 15 | before_script: 16 | - $(exit $(go fmt ./... | wc -l)) 17 | - go vet -modfile=go_test.mod ./... 18 | - if [[ "$TRAVIS_GO_VERSION" =~ 1.22 ]]; then 19 | find . -type f -name "*.go" | xargs misspell -error -locale US; 20 | GOFLAGS="-mod=mod -modfile=go_test.mod" staticcheck ./...; 21 | fi 22 | - golangci-lint run ./jetstream/... 23 | script: 24 | - go test -modfile=go_test.mod -v -run=TestNoRace -p=1 ./... --failfast -vet=off 25 | - if [[ "$TRAVIS_GO_VERSION" =~ 1.22 ]]; then ./scripts/cov.sh TRAVIS; else go test -modfile=go_test.mod -race -v -p=1 ./... --failfast -vet=off -tags=internal_testing; fi 26 | after_success: 27 | - if [[ "$TRAVIS_GO_VERSION" =~ 1.22 ]]; then $HOME/gopath/bin/goveralls -coverprofile=acc.out -service travis-ci; fi 28 | 29 | jobs: 30 | include: 31 | - name: "Go: 1.22.x (nats-server@main)" 32 | go: "1.22.x" 33 | before_script: 34 | - go get -modfile go_test.mod github.com/nats-io/nats-server/v2@main 35 | allow_failures: 36 | - name: "Go: 1.22.x (nats-server@main)" 37 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/.words: -------------------------------------------------------------------------------- 1 | 1 2 | 3 | derek 4 | dlc 5 | ivan 6 | 7 | acknowledgement/SM 8 | arity 9 | deduplication/S 10 | demarshal/SDG 11 | durables 12 | iff 13 | observable/S 14 | redelivery/S 15 | retransmitting 16 | retry/SB 17 | 18 | SlowConsumer 19 | 20 | AppendInt 21 | ReadMIMEHeader 22 | 23 | clientProtoZero 24 | jetstream 25 | v1 26 | v2 27 | 28 | ack/SGD 29 | auth 30 | authToken 31 | chans 32 | creds 33 | config/S 34 | cseq 35 | impl 36 | msgh 37 | msgId 38 | mux/S 39 | nack 40 | ptr 41 | puback 42 | scanf 43 | stderr 44 | stdout 45 | structs 46 | tm 47 | todo 48 | unsub/S 49 | 50 | permessage 51 | permessage-deflate 52 | urlA 53 | urlB 54 | websocket 55 | ws 56 | wss 57 | 58 | NKey 59 | pList 60 | 61 | backend/S 62 | backoff/S 63 | decompressor/CGS 64 | inflight 65 | inlined 66 | lookups 67 | reconnection/MS 68 | redeliver/ADGS 69 | responder/S 70 | rewrap/S 71 | rollup/S 72 | unreceive/DRSZGB 73 | variadic 74 | wakeup/S 75 | whitespace 76 | wrap/AS 77 | 78 | omitempty 79 | 80 | apache 81 | html 82 | ietf 83 | www 84 | 85 | sum256 86 | 32bit/S 87 | 64bit/S 88 | 64k 89 | 128k 90 | 512k 91 | 92 | hacky 93 | handroll/D 94 | 95 | rfc6455 96 | rfc7692 97 | 0x00 98 | 0xff 99 | 20x 100 | 40x 101 | 50x 102 | 103 | ErrXXX 104 | 105 | atlanta 106 | eu 107 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/.words.readme: -------------------------------------------------------------------------------- 1 | The .words file is used by gospel (v1.2+), which wraps the Hunspell libraries 2 | but populates the dictionary with identifiers from the Go source. 3 | 4 | 5 | 6 | Alas, no comments are allowed in the .words file and newer versions of gospel 7 | error out on seeing them. This is really a hunspell restriction. 8 | 9 | We assume en_US hunspell dictionaries are installed and used. 10 | The /AFFIXRULES are defined in en_US.aff (eg: /usr/share/hunspell/en_US.aff) 11 | Invoke `hunspell -D` to see the actual locations. 12 | 13 | Words which are in the base dictionary can't have extra affix rules added to 14 | them, so we have to start with the affixed variant we want to add. 15 | Thus `creds` rather than `cred/S` and so on. 16 | 17 | So we can't use receive/DRSZGBU, adding 'U', to allow unreceive and variants, 18 | we have to use unreceive as the stem. 19 | 20 | We can't define our own affix or compound rules, 21 | to capture rfc\d{3,} or 0x[0-9A-Fa-f]{2} 22 | 23 | The spelling tokenizer doesn't take "permessage-deflate" as allowing for ... 24 | "permessage-deflate", which is an RFC7692 registered extension for websockets. 25 | We have to explicitly list "permessage". 26 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/CODE-OF-CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Community Code of Conduct 2 | 3 | NATS follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). 4 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/GOVERNANCE.md: -------------------------------------------------------------------------------- 1 | # NATS Go Client Governance 2 | 3 | NATS Go Client (go-nats) is part of the NATS project and is subject to the [NATS Governance](https://github.com/nats-io/nats-general/blob/master/GOVERNANCE.md). -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | # Maintainers 2 | 3 | Maintainership is on a per project basis. 4 | 5 | ### Maintainers 6 | - Derek Collison [@derekcollison](https://github.com/derekcollison) 7 | - Ivan Kozlovic [@kozlovic](https://github.com/kozlovic) 8 | - Waldemar Quevedo [@wallyqs](https://github.com/wallyqs) 9 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/dependencies.md: -------------------------------------------------------------------------------- 1 | # External Dependencies 2 | 3 | This file lists the dependencies used in this repository. 4 | 5 | | Dependency | License | 6 | |-----------------------------------|--------------| 7 | | Go | BSD 3-Clause | 8 | | github.com/golang/protobuf/proto | BSD-3-Clause | 9 | | github.com/klauspost/compress | BSD-3-Clause | 10 | | github.com/nats-io/nats-server/v2 | Apache-2.0 | 11 | | github.com/nats-io/nkeys | Apache-2.0 | 12 | | github.com/nats-io/nuid | Apache-2.0 | 13 | | go.uber.org/goleak | MIT | 14 | | golang.org/x/text | BSD-3-Clause | 15 | | google.golang.org/protobuf | BSD-3-Clause | 16 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/encoders/builtin/default_enc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012-2023 The NATS Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package builtin 15 | 16 | import ( 17 | "bytes" 18 | "fmt" 19 | "reflect" 20 | "strconv" 21 | "unsafe" 22 | ) 23 | 24 | // DefaultEncoder implementation for EncodedConn. 25 | // This encoder will leave []byte and string untouched, but will attempt to 26 | // turn numbers into appropriate strings that can be decoded. It will also 27 | // properly encoded and decode bools. If will encode a struct, but if you want 28 | // to properly handle structures you should use JsonEncoder. 29 | // 30 | // Deprecated: Encoded connections are no longer supported. 31 | type DefaultEncoder struct { 32 | // Empty 33 | } 34 | 35 | var trueB = []byte("true") 36 | var falseB = []byte("false") 37 | var nilB = []byte("") 38 | 39 | // Encode 40 | // 41 | // Deprecated: Encoded connections are no longer supported. 42 | func (je *DefaultEncoder) Encode(subject string, v any) ([]byte, error) { 43 | switch arg := v.(type) { 44 | case string: 45 | bytes := *(*[]byte)(unsafe.Pointer(&arg)) 46 | return bytes, nil 47 | case []byte: 48 | return arg, nil 49 | case bool: 50 | if arg { 51 | return trueB, nil 52 | } else { 53 | return falseB, nil 54 | } 55 | case nil: 56 | return nilB, nil 57 | default: 58 | var buf bytes.Buffer 59 | fmt.Fprintf(&buf, "%+v", arg) 60 | return buf.Bytes(), nil 61 | } 62 | } 63 | 64 | // Decode 65 | // 66 | // Deprecated: Encoded connections are no longer supported. 67 | func (je *DefaultEncoder) Decode(subject string, data []byte, vPtr any) error { 68 | // Figure out what it's pointing to... 69 | sData := *(*string)(unsafe.Pointer(&data)) 70 | switch arg := vPtr.(type) { 71 | case *string: 72 | *arg = sData 73 | return nil 74 | case *[]byte: 75 | *arg = data 76 | return nil 77 | case *int: 78 | n, err := strconv.ParseInt(sData, 10, 64) 79 | if err != nil { 80 | return err 81 | } 82 | *arg = int(n) 83 | return nil 84 | case *int32: 85 | n, err := strconv.ParseInt(sData, 10, 64) 86 | if err != nil { 87 | return err 88 | } 89 | *arg = int32(n) 90 | return nil 91 | case *int64: 92 | n, err := strconv.ParseInt(sData, 10, 64) 93 | if err != nil { 94 | return err 95 | } 96 | *arg = int64(n) 97 | return nil 98 | case *float32: 99 | n, err := strconv.ParseFloat(sData, 32) 100 | if err != nil { 101 | return err 102 | } 103 | *arg = float32(n) 104 | return nil 105 | case *float64: 106 | n, err := strconv.ParseFloat(sData, 64) 107 | if err != nil { 108 | return err 109 | } 110 | *arg = float64(n) 111 | return nil 112 | case *bool: 113 | b, err := strconv.ParseBool(sData) 114 | if err != nil { 115 | return err 116 | } 117 | *arg = b 118 | return nil 119 | default: 120 | vt := reflect.TypeOf(arg).Elem() 121 | return fmt.Errorf("nats: Default Encoder can't decode to type %s", vt) 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/encoders/builtin/gob_enc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013-2023 The NATS Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package builtin 15 | 16 | import ( 17 | "bytes" 18 | "encoding/gob" 19 | ) 20 | 21 | // GobEncoder is a Go specific GOB Encoder implementation for EncodedConn. 22 | // This encoder will use the builtin encoding/gob to Marshal 23 | // and Unmarshal most types, including structs. 24 | // 25 | // Deprecated: Encoded connections are no longer supported. 26 | type GobEncoder struct { 27 | // Empty 28 | } 29 | 30 | // FIXME(dlc) - This could probably be more efficient. 31 | 32 | // Encode 33 | // 34 | // Deprecated: Encoded connections are no longer supported. 35 | func (ge *GobEncoder) Encode(subject string, v any) ([]byte, error) { 36 | b := new(bytes.Buffer) 37 | enc := gob.NewEncoder(b) 38 | if err := enc.Encode(v); err != nil { 39 | return nil, err 40 | } 41 | return b.Bytes(), nil 42 | } 43 | 44 | // Decode 45 | // 46 | // Deprecated: Encoded connections are no longer supported. 47 | func (ge *GobEncoder) Decode(subject string, data []byte, vPtr any) (err error) { 48 | dec := gob.NewDecoder(bytes.NewBuffer(data)) 49 | err = dec.Decode(vPtr) 50 | return 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/encoders/builtin/json_enc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012-2023 The NATS Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package builtin 15 | 16 | import ( 17 | "encoding/json" 18 | "strings" 19 | ) 20 | 21 | // JsonEncoder is a JSON Encoder implementation for EncodedConn. 22 | // This encoder will use the builtin encoding/json to Marshal 23 | // and Unmarshal most types, including structs. 24 | // 25 | // Deprecated: Encoded connections are no longer supported. 26 | type JsonEncoder struct { 27 | // Empty 28 | } 29 | 30 | // Encode 31 | // 32 | // Deprecated: Encoded connections are no longer supported. 33 | func (je *JsonEncoder) Encode(subject string, v any) ([]byte, error) { 34 | b, err := json.Marshal(v) 35 | if err != nil { 36 | return nil, err 37 | } 38 | return b, nil 39 | } 40 | 41 | // Decode 42 | // 43 | // Deprecated: Encoded connections are no longer supported. 44 | func (je *JsonEncoder) Decode(subject string, data []byte, vPtr any) (err error) { 45 | switch arg := vPtr.(type) { 46 | case *string: 47 | // If they want a string and it is a JSON string, strip quotes 48 | // This allows someone to send a struct but receive as a plain string 49 | // This cast should be efficient for Go 1.3 and beyond. 50 | str := string(data) 51 | if strings.HasPrefix(str, `"`) && strings.HasSuffix(str, `"`) { 52 | *arg = str[1 : len(str)-1] 53 | } else { 54 | *arg = str 55 | } 56 | case *[]byte: 57 | *arg = data 58 | default: 59 | err = json.Unmarshal(data, arg) 60 | } 61 | return 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/go_test.mod: -------------------------------------------------------------------------------- 1 | module github.com/nats-io/nats.go 2 | 3 | go 1.21 4 | 5 | toolchain go1.22.5 6 | 7 | require ( 8 | github.com/golang/protobuf v1.4.2 9 | github.com/klauspost/compress v1.17.9 10 | github.com/nats-io/jwt v1.2.2 11 | github.com/nats-io/nats-server/v2 v2.10.17 12 | github.com/nats-io/nkeys v0.4.7 13 | github.com/nats-io/nuid v1.0.1 14 | go.uber.org/goleak v1.3.0 15 | golang.org/x/text v0.16.0 16 | google.golang.org/protobuf v1.23.0 17 | ) 18 | 19 | require ( 20 | github.com/minio/highwayhash v1.0.2 // indirect 21 | github.com/nats-io/jwt/v2 v2.5.7 // indirect 22 | golang.org/x/crypto v0.24.0 // indirect 23 | golang.org/x/sys v0.21.0 // indirect 24 | golang.org/x/time v0.5.0 // indirect 25 | ) 26 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/internal/parser/parse.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020-2022 The NATS Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package parser 15 | 16 | import ( 17 | "errors" 18 | "fmt" 19 | ) 20 | 21 | const ( 22 | AckDomainTokenPos = iota + 2 23 | AckAccHashTokenPos 24 | AckStreamTokenPos 25 | AckConsumerTokenPos 26 | AckNumDeliveredTokenPos 27 | AckStreamSeqTokenPos 28 | AckConsumerSeqTokenPos 29 | AckTimestampSeqTokenPos 30 | AckNumPendingTokenPos 31 | ) 32 | 33 | var ErrInvalidSubjectFormat = errors.New("invalid format of ACK subject") 34 | 35 | // Quick parser for positive numbers in ack reply encoding. 36 | // NOTE: This parser does not detect uint64 overflow 37 | func ParseNum(d string) (n uint64) { 38 | if len(d) == 0 { 39 | return 0 40 | } 41 | 42 | // ASCII numbers 0-9 43 | const ( 44 | asciiZero = 48 45 | asciiNine = 57 46 | ) 47 | 48 | for _, dec := range d { 49 | if dec < asciiZero || dec > asciiNine { 50 | return 0 51 | } 52 | n = n*10 + uint64(dec) - asciiZero 53 | } 54 | return 55 | } 56 | 57 | func GetMetadataFields(subject string) ([]string, error) { 58 | v1TokenCounts, v2TokenCounts := 9, 12 59 | 60 | var start int 61 | tokens := make([]string, 0, v2TokenCounts) 62 | for i := 0; i < len(subject); i++ { 63 | if subject[i] == '.' { 64 | tokens = append(tokens, subject[start:i]) 65 | start = i + 1 66 | } 67 | } 68 | tokens = append(tokens, subject[start:]) 69 | // 70 | // Newer server will include the domain name and account hash in the subject, 71 | // and a token at the end. 72 | // 73 | // Old subject was: 74 | // $JS.ACK....... 75 | // 76 | // New subject would be: 77 | // $JS.ACK.......... 78 | // 79 | // v1 has 9 tokens, v2 has 12, but we must not be strict on the 12th since 80 | // it may be removed in the future. Also, the library has no use for it. 81 | // The point is that a v2 ACK subject is valid if it has at least 11 tokens. 82 | // 83 | tokensLen := len(tokens) 84 | // If lower than 9 or more than 9 but less than 11, report an error 85 | if tokensLen < v1TokenCounts || (tokensLen > v1TokenCounts && tokensLen < v2TokenCounts-1) { 86 | return nil, ErrInvalidSubjectFormat 87 | } 88 | if tokens[0] != "$JS" || tokens[1] != "ACK" { 89 | return nil, fmt.Errorf("%w: subject should start with $JS.ACK", ErrInvalidSubjectFormat) 90 | } 91 | // For v1 style, we insert 2 empty tokens (domain and hash) so that the 92 | // rest of the library references known fields at a constant location. 93 | if tokensLen == v1TokenCounts { 94 | // Extend the array (we know the backend is big enough) 95 | tokens = append(tokens[:AckDomainTokenPos+2], tokens[AckDomainTokenPos:]...) 96 | // Clear the domain and hash tokens 97 | tokens[AckDomainTokenPos], tokens[AckAccHashTokenPos] = "", "" 98 | 99 | } else if tokens[AckDomainTokenPos] == "_" { 100 | // If domain is "_", replace with empty value. 101 | tokens[AckDomainTokenPos] = "" 102 | } 103 | return tokens, nil 104 | } 105 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/legacy_jetstream.md: -------------------------------------------------------------------------------- 1 | # Legacy JetStream API 2 | 3 | This is a documentation for the legacy JetStream API. A README for the current 4 | API can be found [here](jetstream/README.md) 5 | 6 | ## JetStream Basic Usage 7 | 8 | ```go 9 | import "github.com/nats-io/nats.go" 10 | 11 | // Connect to NATS 12 | nc, _ := nats.Connect(nats.DefaultURL) 13 | 14 | // Create JetStream Context 15 | js, _ := nc.JetStream(nats.PublishAsyncMaxPending(256)) 16 | 17 | // Simple Stream Publisher 18 | js.Publish("ORDERS.scratch", []byte("hello")) 19 | 20 | // Simple Async Stream Publisher 21 | for i := 0; i < 500; i++ { 22 | js.PublishAsync("ORDERS.scratch", []byte("hello")) 23 | } 24 | select { 25 | case <-js.PublishAsyncComplete(): 26 | case <-time.After(5 * time.Second): 27 | fmt.Println("Did not resolve in time") 28 | } 29 | 30 | // Simple Async Ephemeral Consumer 31 | js.Subscribe("ORDERS.*", func(m *nats.Msg) { 32 | fmt.Printf("Received a JetStream message: %s\n", string(m.Data)) 33 | }) 34 | 35 | // Simple Sync Durable Consumer (optional SubOpts at the end) 36 | sub, err := js.SubscribeSync("ORDERS.*", nats.Durable("MONITOR"), nats.MaxDeliver(3)) 37 | m, err := sub.NextMsg(timeout) 38 | 39 | // Simple Pull Consumer 40 | sub, err := js.PullSubscribe("ORDERS.*", "MONITOR") 41 | msgs, err := sub.Fetch(10) 42 | 43 | // Unsubscribe 44 | sub.Unsubscribe() 45 | 46 | // Drain 47 | sub.Drain() 48 | ``` 49 | 50 | ## JetStream Basic Management 51 | 52 | ```go 53 | import "github.com/nats-io/nats.go" 54 | 55 | // Connect to NATS 56 | nc, _ := nats.Connect(nats.DefaultURL) 57 | 58 | // Create JetStream Context 59 | js, _ := nc.JetStream() 60 | 61 | // Create a Stream 62 | js.AddStream(&nats.StreamConfig{ 63 | Name: "ORDERS", 64 | Subjects: []string{"ORDERS.*"}, 65 | }) 66 | 67 | // Update a Stream 68 | js.UpdateStream(&nats.StreamConfig{ 69 | Name: "ORDERS", 70 | MaxBytes: 8, 71 | }) 72 | 73 | // Create a Consumer 74 | js.AddConsumer("ORDERS", &nats.ConsumerConfig{ 75 | Durable: "MONITOR", 76 | }) 77 | 78 | // Delete Consumer 79 | js.DeleteConsumer("ORDERS", "MONITOR") 80 | 81 | // Delete Stream 82 | js.DeleteStream("ORDERS") 83 | ``` 84 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/rand.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The NATS Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build !go1.20 15 | // +build !go1.20 16 | 17 | // A Go client for the NATS messaging system (https://nats.io). 18 | package nats 19 | 20 | import ( 21 | "math/rand" 22 | "time" 23 | ) 24 | 25 | func init() { 26 | // This is not needed since Go 1.20 because now rand.Seed always happens 27 | // by default (uses runtime.fastrand64 instead as source). 28 | rand.Seed(time.Now().UnixNano()) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/testing_internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 The NATS Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build internal_testing 15 | // +build internal_testing 16 | 17 | // Functions in this file are only available when building nats.go with the 18 | // internal_testing build tag. They are used by the nats.go test suite. 19 | package nats 20 | 21 | // AddMsgFilter adds a message filter for the given subject 22 | // to the connection. The filter will be called for each 23 | // message received on the subject. If the filter returns 24 | // nil, the message will be dropped. 25 | func (nc *Conn) AddMsgFilter(subject string, filter msgFilter) { 26 | nc.subsMu.Lock() 27 | defer nc.subsMu.Unlock() 28 | 29 | if nc.filters == nil { 30 | nc.filters = make(map[string]msgFilter) 31 | } 32 | nc.filters[subject] = filter 33 | } 34 | 35 | // RemoveMsgFilter removes a message filter for the given subject. 36 | func (nc *Conn) RemoveMsgFilter(subject string) { 37 | nc.subsMu.Lock() 38 | defer nc.subsMu.Unlock() 39 | 40 | if nc.filters != nil { 41 | delete(nc.filters, subject) 42 | if len(nc.filters) == 0 { 43 | nc.filters = nil 44 | } 45 | } 46 | } 47 | 48 | // IsJSControlMessage returns true if the message is a JetStream control message. 49 | func IsJSControlMessage(msg *Msg) (bool, int) { 50 | return isJSControlMessage(msg) 51 | } 52 | 53 | // CloseTCPConn closes the underlying TCP connection. 54 | // It can be used to simulate a disconnect. 55 | func (nc *Conn) CloseTCPConn() { 56 | nc.mu.Lock() 57 | defer nc.mu.Unlock() 58 | nc.conn.Close() 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/timer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017-2022 The NATS Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package nats 15 | 16 | import ( 17 | "sync" 18 | "time" 19 | ) 20 | 21 | // global pool of *time.Timer's. can be used by multiple goroutines concurrently. 22 | var globalTimerPool timerPool 23 | 24 | // timerPool provides GC-able pooling of *time.Timer's. 25 | // can be used by multiple goroutines concurrently. 26 | type timerPool struct { 27 | p sync.Pool 28 | } 29 | 30 | // Get returns a timer that completes after the given duration. 31 | func (tp *timerPool) Get(d time.Duration) *time.Timer { 32 | if t, ok := tp.p.Get().(*time.Timer); ok && t != nil { 33 | t.Reset(d) 34 | return t 35 | } 36 | 37 | return time.NewTimer(d) 38 | } 39 | 40 | // Put pools the given timer. 41 | // 42 | // There is no need to call t.Stop() before calling Put. 43 | // 44 | // Put will try to stop the timer before pooling. If the 45 | // given timer already expired, Put will read the unreceived 46 | // value if there is one. 47 | func (tp *timerPool) Put(t *time.Timer) { 48 | if !t.Stop() { 49 | select { 50 | case <-t.C: 51 | default: 52 | } 53 | } 54 | 55 | tp.p.Put(t) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/util/tls.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017-2022 The NATS Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build go1.8 15 | // +build go1.8 16 | 17 | package util 18 | 19 | import "crypto/tls" 20 | 21 | // CloneTLSConfig returns a copy of c. 22 | func CloneTLSConfig(c *tls.Config) *tls.Config { 23 | if c == nil { 24 | return &tls.Config{} 25 | } 26 | 27 | return c.Clone() 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nats.go/util/tls_go17.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2022 The NATS Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | //go:build go1.7 && !go1.8 15 | // +build go1.7,!go1.8 16 | 17 | package util 18 | 19 | import ( 20 | "crypto/tls" 21 | ) 22 | 23 | // CloneTLSConfig returns a copy of c. Only the exported fields are copied. 24 | // This is temporary, until this is provided by the language. 25 | // https://go-review.googlesource.com/#/c/28075/ 26 | func CloneTLSConfig(c *tls.Config) *tls.Config { 27 | return &tls.Config{ 28 | Rand: c.Rand, 29 | Time: c.Time, 30 | Certificates: c.Certificates, 31 | NameToCertificate: c.NameToCertificate, 32 | GetCertificate: c.GetCertificate, 33 | RootCAs: c.RootCAs, 34 | NextProtos: c.NextProtos, 35 | ServerName: c.ServerName, 36 | ClientAuth: c.ClientAuth, 37 | ClientCAs: c.ClientCAs, 38 | InsecureSkipVerify: c.InsecureSkipVerify, 39 | CipherSuites: c.CipherSuites, 40 | PreferServerCipherSuites: c.PreferServerCipherSuites, 41 | SessionTicketsDisabled: c.SessionTicketsDisabled, 42 | SessionTicketKey: c.SessionTicketKey, 43 | ClientSessionCache: c.ClientSessionCache, 44 | MinVersion: c.MinVersion, 45 | MaxVersion: c.MaxVersion, 46 | CurvePreferences: c.CurvePreferences, 47 | DynamicRecordSizingDisabled: c.DynamicRecordSizingDisabled, 48 | Renegotiation: c.Renegotiation, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nkeys/.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.dll 4 | *.so 5 | *.dylib 6 | build/ 7 | 8 | # Test binary, build with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 15 | .glide/ 16 | .idea/ 17 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nkeys/.goreleaser.yml: -------------------------------------------------------------------------------- 1 | project_name: nkeys 2 | release: 3 | github: 4 | owner: nats-io 5 | name: nkeys 6 | name_template: '{{.Tag}}' 7 | draft: true 8 | builds: 9 | - id: nk 10 | main: ./nk/main.go 11 | ldflags: "-X main.Version={{.Tag}}_{{.Commit}}" 12 | binary: nk 13 | goos: 14 | - darwin 15 | - linux 16 | - windows 17 | - freebsd 18 | goarch: 19 | - amd64 20 | - arm 21 | - arm64 22 | - 386 23 | - mips64le 24 | - s390x 25 | goarm: 26 | - 6 27 | - 7 28 | ignore: 29 | - goos: darwin 30 | goarch: 386 31 | - goos: freebsd 32 | goarch: arm 33 | - goos: freebsd 34 | goarch: arm64 35 | - goos: freebsd 36 | goarch: 386 37 | 38 | dist: build 39 | 40 | archives: 41 | - name_template: '{{ .ProjectName }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm 42 | }}v{{ .Arm }}{{ end }}' 43 | wrap_in_directory: true 44 | format: zip 45 | files: 46 | - README.md 47 | - LICENSE 48 | 49 | checksum: 50 | name_template: '{{ .ProjectName }}-v{{ .Version }}-checksums.txt' 51 | 52 | snapshot: 53 | name_template: 'dev' 54 | 55 | nfpms: 56 | - file_name_template: '{{ .ProjectName }}-v{{ .Version }}-{{ .Arch }}{{ if .Arm 57 | }}v{{ .Arm }}{{ end }}' 58 | maintainer: nats.io 59 | description: NKeys utility cli program 60 | vendor: nats-io 61 | bindir: /usr/local/bin 62 | formats: 63 | - deb -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nkeys/GOVERNANCE.md: -------------------------------------------------------------------------------- 1 | # NATS NKEYS Governance 2 | 3 | NATS NKEYS is part of the NATS project and is subject to the [NATS Governance](https://github.com/nats-io/nats-general/blob/master/GOVERNANCE.md). -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nkeys/MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | # Maintainers 2 | 3 | Maintainership is on a per project basis. 4 | 5 | ### Maintainers 6 | - Derek Collison [@derekcollison](https://github.com/derekcollison) 7 | - Ivan Kozlovic [@kozlovic](https://github.com/kozlovic) 8 | - Waldemar Quevedo [@wallyqs](https://github.com/wallyqs) 9 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nkeys/README.md: -------------------------------------------------------------------------------- 1 | # NKEYS 2 | 3 | [![License Apache 2](https://img.shields.io/badge/License-Apache2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) 4 | [![Go Report Card](https://goreportcard.com/badge/github.com/nats-io/nkeys)](https://goreportcard.com/report/github.com/nats-io/nkeys) 5 | [![Build Status](https://github.com/nats-io/nkeys/actions/workflows/release.yaml/badge.svg)](https://github.com/nats-io/nkeys/actions/workflows/release.yaml/badge.svg) 6 | [![GoDoc](https://godoc.org/github.com/nats-io/nkeys?status.svg)](https://godoc.org/github.com/nats-io/nkeys) 7 | [![Coverage Status](https://coveralls.io/repos/github/nats-io/nkeys/badge.svg?branch=main&service=github)](https://coveralls.io/github/nats-io/nkeys?branch=main) 8 | 9 | A public-key signature system based on [Ed25519](https://ed25519.cr.yp.to/) for the NATS ecosystem. 10 | 11 | ## About 12 | 13 | The NATS ecosystem will be moving to [Ed25519](https://ed25519.cr.yp.to/) keys for identity, authentication and authorization for entities such as Accounts, Users, Servers and Clusters. 14 | 15 | Ed25519 is fast and resistant to side channel attacks. Generation of a seed key is all that is needed to be stored and kept safe, as the seed can generate both the public and private keys. 16 | 17 | The NATS system will utilize Ed25519 keys, meaning that NATS systems will never store or even have access to any private keys. Authentication will utilize a random challenge response mechanism. 18 | 19 | Dealing with 32 byte and 64 byte raw keys can be challenging. NKEYS is designed to formulate keys in a much friendlier fashion and references work done in cryptocurrencies, specifically [Stellar](https://www.stellar.org/). Bitcoin and others used a form of Base58 (or Base58Check) to encode raw keys. Stellar utilized a more traditional Base32 with a CRC16 and a version or prefix byte. NKEYS utilizes a similar format where the prefix will be 1 byte for public and private keys and will be 2 bytes for seeds. The base32 encoding of these prefixes will yield friendly human readable prefixes, e.g. '**N**' = server, '**C**' = cluster, '**O**' = operator, '**A**' = account, and '**U**' = user. '**P**' is used for private keys. For seeds, the first encoded prefix is '**S**', and the second character will be the type for the public key, e.g. "**SU**" is a seed for a user key pair, "**SA**" is a seed for an account key pair. 20 | 21 | ## Installation 22 | 23 | Use the `go` command: 24 | 25 | $ go get github.com/nats-io/nkeys 26 | 27 | ## nk - Command Line Utility 28 | 29 | Located under the nk [directory](https://github.com/nats-io/nkeys/tree/master/nk). 30 | 31 | ## Basic API Usage 32 | ```go 33 | 34 | // Create a new User KeyPair 35 | user, _ := nkeys.CreateUser() 36 | 37 | // Sign some data with a full key pair user. 38 | data := []byte("Hello World") 39 | sig, _ := user.Sign(data) 40 | 41 | // Verify the signature. 42 | err = user.Verify(data, sig) 43 | 44 | // Access the seed, the only thing that needs to be stored and kept safe. 45 | // seed = "SUAKYRHVIOREXV7EUZTBHUHL7NUMHPMAS7QMDU3GTIUWEI5LDNOXD43IZY" 46 | seed, _ := user.Seed() 47 | 48 | // Access the public key which can be shared. 49 | // publicKey = "UD466L6EBCM3YY5HEGHJANNTN4LSKTSUXTH7RILHCKEQMQHTBNLHJJXT" 50 | publicKey, _ := user.PublicKey() 51 | 52 | // Create a full User who can sign and verify from a private seed. 53 | user, _ = nkeys.FromSeed(seed) 54 | 55 | // Create a User who can only verify signatures via a public key. 56 | user, _ = nkeys.FromPublicKey(publicKey) 57 | 58 | // Create a User KeyPair with our own random data. 59 | var rawSeed [32]byte 60 | _, err := io.ReadFull(rand.Reader, rawSeed[:]) // Or some other random source. 61 | user2, _ := nkeys.FromRawSeed(PrefixByteUser, rawSeed) 62 | 63 | ``` 64 | 65 | ## License 66 | 67 | Unless otherwise noted, the NATS source files are distributed 68 | under the Apache Version 2.0 license found in the LICENSE file. 69 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nkeys/TODO.md: -------------------------------------------------------------------------------- 1 | 2 | # General 3 | 4 | - [ ] Child key derivation 5 | - [ ] Hardware support, e.g. YubiHSM 6 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nkeys/crc16.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The NATS Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package nkeys 15 | 16 | // An implementation of crc16 according to CCITT standards for XMODEM. 17 | 18 | var crc16tab = [256]uint16{ 19 | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 20 | 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 21 | 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 22 | 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 23 | 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 24 | 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 25 | 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 26 | 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 27 | 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 28 | 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 29 | 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 30 | 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 31 | 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 32 | 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 33 | 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 34 | 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 35 | 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 36 | 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 37 | 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 38 | 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 39 | 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 40 | 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 41 | 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 42 | 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 43 | 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 44 | 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 45 | 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 46 | 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 47 | 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 48 | 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 49 | 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 50 | 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0, 51 | } 52 | 53 | // crc16 returns the 2-byte crc for the data provided. 54 | func crc16(data []byte) uint16 { 55 | var crc uint16 56 | for _, b := range data { 57 | crc = ((crc << 8) & 0xffff) ^ crc16tab[((crc>>8)^uint16(b))&0x00FF] 58 | } 59 | return crc 60 | } 61 | 62 | // validate will check the calculated crc16 checksum for data against the expected. 63 | func validate(data []byte, expected uint16) error { 64 | if crc16(data) != expected { 65 | return ErrInvalidChecksum 66 | } 67 | return nil 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nkeys/creds_utils.go: -------------------------------------------------------------------------------- 1 | package nkeys 2 | 3 | import ( 4 | "bytes" 5 | "regexp" 6 | "strings" 7 | ) 8 | 9 | var userConfigRE = regexp.MustCompile(`\s*(?:(?:[-]{3,}.*[-]{3,}\r?\n)([\w\-.=]+)(?:\r?\n[-]{3,}.*[-]{3,}\r?\n))`) 10 | 11 | // ParseDecoratedJWT takes a creds file and returns the JWT portion. 12 | func ParseDecoratedJWT(contents []byte) (string, error) { 13 | items := userConfigRE.FindAllSubmatch(contents, -1) 14 | if len(items) == 0 { 15 | return string(contents), nil 16 | } 17 | // First result should be the user JWT. 18 | // We copy here so that if the file contained a seed file too we wipe appropriately. 19 | raw := items[0][1] 20 | tmp := make([]byte, len(raw)) 21 | copy(tmp, raw) 22 | return strings.TrimSpace(string(tmp)), nil 23 | } 24 | 25 | // ParseDecoratedNKey takes a creds file, finds the NKey portion and creates a 26 | // key pair from it. 27 | func ParseDecoratedNKey(contents []byte) (KeyPair, error) { 28 | var seed []byte 29 | 30 | items := userConfigRE.FindAllSubmatch(contents, -1) 31 | if len(items) > 1 { 32 | seed = items[1][1] 33 | } else { 34 | lines := bytes.Split(contents, []byte("\n")) 35 | for _, line := range lines { 36 | if bytes.HasPrefix(bytes.TrimSpace(line), []byte("SO")) || 37 | bytes.HasPrefix(bytes.TrimSpace(line), []byte("SA")) || 38 | bytes.HasPrefix(bytes.TrimSpace(line), []byte("SU")) { 39 | seed = line 40 | break 41 | } 42 | } 43 | } 44 | if seed == nil { 45 | return nil, ErrNoSeedFound 46 | } 47 | if !bytes.HasPrefix(seed, []byte("SO")) && 48 | !bytes.HasPrefix(seed, []byte("SA")) && 49 | !bytes.HasPrefix(seed, []byte("SU")) { 50 | return nil, ErrInvalidNkeySeed 51 | } 52 | kp, err := FromSeed(seed) 53 | if err != nil { 54 | return nil, err 55 | } 56 | return kp, nil 57 | } 58 | 59 | // ParseDecoratedUserNKey takes a creds file, finds the NKey portion and creates a 60 | // key pair from it. Similar to ParseDecoratedNKey but fails for non-user keys. 61 | func ParseDecoratedUserNKey(contents []byte) (KeyPair, error) { 62 | nk, err := ParseDecoratedNKey(contents) 63 | if err != nil { 64 | return nil, err 65 | } 66 | seed, err := nk.Seed() 67 | if err != nil { 68 | return nil, err 69 | } 70 | if !bytes.HasPrefix(seed, []byte("SU")) { 71 | return nil, ErrInvalidUserSeed 72 | } 73 | kp, err := FromSeed(seed) 74 | if err != nil { 75 | return nil, err 76 | } 77 | return kp, nil 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nkeys/dependencies.md: -------------------------------------------------------------------------------- 1 | # External Dependencies 2 | 3 | This file lists the dependencies used in this repository. 4 | 5 | | Dependency | License | 6 | |-|-| 7 | | Go | BSD 3-Clause "New" or "Revised" License | 8 | | golang.org/x/crypto v0.3.0 | BSD 3-Clause "New" or "Revised" License | 9 | | golang.org/x/net v0.2.0 | BSD 3-Clause "New" or "Revised" License | 10 | | golang.org/x/sys v0.2.0 | BSD 3-Clause "New" or "Revised" License | 11 | | golang.org/x/term v0.2.0 | BSD 3-Clause "New" or "Revised" License | 12 | | golang.org/x/text v0.4.0 | BSD 3-Clause "New" or "Revised" License | 13 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nkeys/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 The NATS Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package nkeys 15 | 16 | // Errors 17 | const ( 18 | ErrInvalidPrefixByte = nkeysError("nkeys: invalid prefix byte") 19 | ErrInvalidKey = nkeysError("nkeys: invalid key") 20 | ErrInvalidPublicKey = nkeysError("nkeys: invalid public key") 21 | ErrInvalidPrivateKey = nkeysError("nkeys: invalid private key") 22 | ErrInvalidSeedLen = nkeysError("nkeys: invalid seed length") 23 | ErrInvalidSeed = nkeysError("nkeys: invalid seed") 24 | ErrInvalidEncoding = nkeysError("nkeys: invalid encoded key") 25 | ErrInvalidSignature = nkeysError("nkeys: signature verification failed") 26 | ErrCannotSign = nkeysError("nkeys: can not sign, no private key available") 27 | ErrPublicKeyOnly = nkeysError("nkeys: no seed or private key available") 28 | ErrIncompatibleKey = nkeysError("nkeys: incompatible key") 29 | ErrInvalidChecksum = nkeysError("nkeys: invalid checksum") 30 | ErrNoSeedFound = nkeysError("nkeys: no nkey seed found") 31 | ErrInvalidNkeySeed = nkeysError("nkeys: doesn't contain a seed nkey") 32 | ErrInvalidUserSeed = nkeysError("nkeys: doesn't contain an user seed nkey") 33 | ErrInvalidRecipient = nkeysError("nkeys: not a valid recipient public curve key") 34 | ErrInvalidSender = nkeysError("nkeys: not a valid sender public curve key") 35 | ErrInvalidCurveKey = nkeysError("nkeys: not a valid curve key") 36 | ErrInvalidCurveSeed = nkeysError("nkeys: not a valid curve seed") 37 | ErrInvalidEncrypted = nkeysError("nkeys: encrypted input is not valid") 38 | ErrInvalidEncVersion = nkeysError("nkeys: encrypted input wrong version") 39 | ErrCouldNotDecrypt = nkeysError("nkeys: could not decrypt input") 40 | ErrInvalidCurveKeyOperation = nkeysError("nkeys: curve key is not valid for sign/verify") 41 | ErrInvalidNKeyOperation = nkeysError("nkeys: only curve key can seal/open") 42 | ErrCannotOpen = nkeysError("nkeys: cannot open no private curve key available") 43 | ErrCannotSeal = nkeysError("nkeys: cannot seal no private curve key available") 44 | ) 45 | 46 | type nkeysError string 47 | 48 | func (e nkeysError) Error() string { 49 | return string(e) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nkeys/nkeys.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2019 The NATS Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | // Package nkeys is an Ed25519 based public-key signature system that simplifies keys and seeds 15 | // and performs signing and verification. 16 | // It also supports encryption via x25519 keys and is compatible with https://pkg.go.dev/golang.org/x/crypto/nacl/box. 17 | package nkeys 18 | 19 | import "io" 20 | 21 | // Version is our current version 22 | const Version = "0.4.7" 23 | 24 | // KeyPair provides the central interface to nkeys. 25 | type KeyPair interface { 26 | Seed() ([]byte, error) 27 | PublicKey() (string, error) 28 | PrivateKey() ([]byte, error) 29 | // Sign is only supported on Non CurveKeyPairs 30 | Sign(input []byte) ([]byte, error) 31 | // Verify is only supported on Non CurveKeyPairs 32 | Verify(input []byte, sig []byte) error 33 | Wipe() 34 | // Seal is only supported on CurveKeyPair 35 | Seal(input []byte, recipient string) ([]byte, error) 36 | // SealWithRand is only supported on CurveKeyPair 37 | SealWithRand(input []byte, recipient string, rr io.Reader) ([]byte, error) 38 | // Open is only supported on CurveKey 39 | Open(input []byte, sender string) ([]byte, error) 40 | } 41 | 42 | // CreateUser will create a User typed KeyPair. 43 | func CreateUser() (KeyPair, error) { 44 | return CreatePair(PrefixByteUser) 45 | } 46 | 47 | // CreateAccount will create an Account typed KeyPair. 48 | func CreateAccount() (KeyPair, error) { 49 | return CreatePair(PrefixByteAccount) 50 | } 51 | 52 | // CreateServer will create a Server typed KeyPair. 53 | func CreateServer() (KeyPair, error) { 54 | return CreatePair(PrefixByteServer) 55 | } 56 | 57 | // CreateCluster will create a Cluster typed KeyPair. 58 | func CreateCluster() (KeyPair, error) { 59 | return CreatePair(PrefixByteCluster) 60 | } 61 | 62 | // CreateOperator will create an Operator typed KeyPair. 63 | func CreateOperator() (KeyPair, error) { 64 | return CreatePair(PrefixByteOperator) 65 | } 66 | 67 | // FromPublicKey will create a KeyPair capable of verifying signatures. 68 | func FromPublicKey(public string) (KeyPair, error) { 69 | raw, err := decode([]byte(public)) 70 | if err != nil { 71 | return nil, err 72 | } 73 | pre := PrefixByte(raw[0]) 74 | if err := checkValidPublicPrefixByte(pre); err != nil { 75 | return nil, ErrInvalidPublicKey 76 | } 77 | return &pub{pre, raw[1:]}, nil 78 | } 79 | 80 | // FromSeed will create a KeyPair capable of signing and verifying signatures. 81 | func FromSeed(seed []byte) (KeyPair, error) { 82 | prefix, _, err := DecodeSeed(seed) 83 | if err != nil { 84 | return nil, err 85 | } 86 | if prefix == PrefixByteCurve { 87 | return FromCurveSeed(seed) 88 | } 89 | copy := append([]byte{}, seed...) 90 | return &kp{copy}, nil 91 | } 92 | 93 | // FromRawSeed will create a KeyPair from the raw 32 byte seed for a given type. 94 | func FromRawSeed(prefix PrefixByte, rawSeed []byte) (KeyPair, error) { 95 | seed, err := EncodeSeed(prefix, rawSeed) 96 | if err != nil { 97 | return nil, err 98 | } 99 | return &kp{seed}, nil 100 | } 101 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nkeys/public.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018-2024 The NATS Authors 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package nkeys 15 | 16 | import ( 17 | "crypto/ed25519" 18 | "crypto/rand" 19 | "io" 20 | ) 21 | 22 | // A KeyPair from a public key capable of verifying only. 23 | type pub struct { 24 | pre PrefixByte 25 | pub ed25519.PublicKey 26 | } 27 | 28 | // PublicKey will return the encoded public key associated with the KeyPair. 29 | // All KeyPairs have a public key. 30 | func (p *pub) PublicKey() (string, error) { 31 | pk, err := Encode(p.pre, p.pub) 32 | if err != nil { 33 | return "", err 34 | } 35 | return string(pk), nil 36 | } 37 | 38 | // Seed will return an error since this is not available for public key only KeyPairs. 39 | func (p *pub) Seed() ([]byte, error) { 40 | return nil, ErrPublicKeyOnly 41 | } 42 | 43 | // PrivateKey will return an error since this is not available for public key only KeyPairs. 44 | func (p *pub) PrivateKey() ([]byte, error) { 45 | return nil, ErrPublicKeyOnly 46 | } 47 | 48 | // Sign will return an error since this is not available for public key only KeyPairs. 49 | func (p *pub) Sign(input []byte) ([]byte, error) { 50 | return nil, ErrCannotSign 51 | } 52 | 53 | // Verify will verify the input against a signature utilizing the public key. 54 | func (p *pub) Verify(input []byte, sig []byte) error { 55 | if !ed25519.Verify(p.pub, input, sig) { 56 | return ErrInvalidSignature 57 | } 58 | return nil 59 | } 60 | 61 | // Wipe will randomize the public key and erase the pre byte. 62 | func (p *pub) Wipe() { 63 | p.pre = '0' 64 | io.ReadFull(rand.Reader, p.pub) 65 | } 66 | 67 | func (p *pub) Seal(input []byte, recipient string) ([]byte, error) { 68 | if p.pre == PrefixByteCurve { 69 | return nil, ErrCannotSeal 70 | } 71 | return nil, ErrInvalidNKeyOperation 72 | } 73 | func (p *pub) SealWithRand(input []byte, _recipient string, rr io.Reader) ([]byte, error) { 74 | if p.pre == PrefixByteCurve { 75 | return nil, ErrCannotSeal 76 | } 77 | return nil, ErrInvalidNKeyOperation 78 | } 79 | 80 | func (p *pub) Open(input []byte, sender string) ([]byte, error) { 81 | if p.pre == PrefixByteCurve { 82 | return nil, ErrCannotOpen 83 | } 84 | return nil, ErrInvalidNKeyOperation 85 | } 86 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nuid/.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 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nuid/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - 1.9.x 5 | - 1.10.x 6 | 7 | install: 8 | - go get -t ./... 9 | - go get github.com/mattn/goveralls 10 | 11 | script: 12 | - go fmt ./... 13 | - go vet ./... 14 | - go test -v 15 | - go test -v --race 16 | - go test -v -covermode=count -coverprofile=coverage.out 17 | - $HOME/gopath/bin/goveralls -coverprofile coverage.out -service travis-ci 18 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nuid/GOVERNANCE.md: -------------------------------------------------------------------------------- 1 | # NATS NUID Governance 2 | 3 | NATS NUID is part of the NATS project and is subject to the [NATS Governance](https://github.com/nats-io/nats-general/blob/master/GOVERNANCE.md). -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nuid/MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | # Maintainers 2 | 3 | Maintainership is on a per project basis. 4 | 5 | ### Core-maintainers 6 | - Derek Collison [@derekcollison](https://github.com/derekcollison) -------------------------------------------------------------------------------- /vendor/github.com/nats-io/nuid/README.md: -------------------------------------------------------------------------------- 1 | # NUID 2 | 3 | [![License Apache 2](https://img.shields.io/badge/License-Apache2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) 4 | [![ReportCard](http://goreportcard.com/badge/nats-io/nuid)](http://goreportcard.com/report/nats-io/nuid) 5 | [![Build Status](https://travis-ci.org/nats-io/nuid.svg?branch=master)](http://travis-ci.org/nats-io/nuid) 6 | [![Release](https://img.shields.io/badge/release-v1.0.1-1eb0fc.svg)](https://github.com/nats-io/nuid/releases/tag/v1.0.1) 7 | [![GoDoc](http://godoc.org/github.com/nats-io/nuid?status.png)](http://godoc.org/github.com/nats-io/nuid) 8 | [![Coverage Status](https://coveralls.io/repos/github/nats-io/nuid/badge.svg?branch=master)](https://coveralls.io/github/nats-io/nuid?branch=master) 9 | 10 | A highly performant unique identifier generator. 11 | 12 | ## Installation 13 | 14 | Use the `go` command: 15 | 16 | $ go get github.com/nats-io/nuid 17 | 18 | ## Basic Usage 19 | ```go 20 | 21 | // Utilize the global locked instance 22 | nuid := nuid.Next() 23 | 24 | // Create an instance, these are not locked. 25 | n := nuid.New() 26 | nuid = n.Next() 27 | 28 | // Generate a new crypto/rand seeded prefix. 29 | // Generally not needed, happens automatically. 30 | n.RandomizePrefix() 31 | ``` 32 | 33 | ## Performance 34 | NUID needs to be very fast to generate and be truly unique, all while being entropy pool friendly. 35 | NUID uses 12 bytes of crypto generated data (entropy draining), and 10 bytes of pseudo-random 36 | sequential data that increments with a pseudo-random increment. 37 | 38 | Total length of a NUID string is 22 bytes of base 62 ascii text, so 62^22 or 39 | 2707803647802660400290261537185326956544 possibilities. 40 | 41 | NUID can generate identifiers as fast as 60ns, or ~16 million per second. There is an associated 42 | benchmark you can use to test performance on your own hardware. 43 | 44 | ## License 45 | 46 | Unless otherwise noted, the NATS source files are distributed 47 | under the Apache Version 2.0 license found in the LICENSE file. 48 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/stan.go/.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 | *.test 24 | *.prof 25 | 26 | # Eclipse stuff 27 | .project 28 | .settings/ 29 | .idea -------------------------------------------------------------------------------- /vendor/github.com/nats-io/stan.go/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.19.x 4 | - 1.18.x 5 | go_import_path: github.com/nats-io/stan.go 6 | install: 7 | - if [[ "$TRAVIS_GO_VERSION" =~ 1.19 ]]; then go install honnef.co/go/tools/cmd/staticcheck@latest; fi 8 | - go install github.com/client9/misspell/cmd/misspell@latest 9 | before_script: 10 | - $(exit $(go fmt ./... | wc -l)) 11 | - go vet -modfile go_tests.mod ./... 12 | - find . -type f -name "*.go" | grep -v "/pb/" | xargs misspell -error -locale US 13 | - if [[ "$TRAVIS_GO_VERSION" =~ 1.19 ]]; then staticcheck -tests=false ./...; fi 14 | script: 15 | - go test -v -race . -modfile go_tests.mod 16 | after_success: 17 | - if [[ "$TRAVIS_GO_VERSION" =~ 1.19 ]]; then ./scripts/cov.sh TRAVIS; fi 18 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/stan.go/CODE-OF-CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Community Code of Conduct 2 | 3 | NATS follows the [CNCF Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md). 4 | 5 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/stan.go/GOVERNANCE.md: -------------------------------------------------------------------------------- 1 | # NATS Streaming Governance 2 | 3 | NATS Streaming is part of the NATS project and is subject to the [NATS Governance](https://github.com/nats-io/nats-general/blob/master/GOVERNANCE.md). -------------------------------------------------------------------------------- /vendor/github.com/nats-io/stan.go/MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | # Maintainers 2 | 3 | Maintainership is on a per project basis. 4 | 5 | ### Maintainers 6 | - Derek Collison [@derekcollison](https://github.com/derekcollison) 7 | - Ivan Kozlovic [@kozlovic](https://github.com/kozlovic) 8 | - Alberto Ricart [@aricart](https://github.com/aricart) 9 | - Colin Sullivan [@ColinSullivan1](https://github.com/ColinSullivan1) 10 | - Waldemar Quevedo [@wallyqs](https://github.com/wallyqs) 11 | - R.I. Pienaar [@ripienaar](https://github.com/ripienaar) 12 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/stan.go/dependencies.md: -------------------------------------------------------------------------------- 1 | # External Dependencies 2 | 3 | This file lists the dependencies used in this repository. 4 | 5 | | Dependency | License | 6 | |-|-| 7 | | Go | BSD 3-Clause "New" or "Revised" License | 8 | | github.com/nats-io/stan.go | Apache License 2.0 | 9 | | github.com/gogo/protobuf v1.3.2 | Go | 10 | | github.com/kisielk/errcheck v1.5.0 | MIT | 11 | | github.com/kisielk/gotool v1.0.0 | MIT | 12 | | github.com/nats-io/nats.go v1.11.0 | Apache License 2.0 | 13 | | github.com/nats-io/nkeys v0.3.0 | Apache License 2.0 | 14 | | github.com/nats-io/nuid v1.0.1 | Apache License 2.0 | 15 | | github.com/yuin/goldmark v1.2.1 | MIT | 16 | | golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b | BSD 3-Clause "New" or "Revised" License | 17 | | golang.org/x/mod v0.3.0 | BSD 3-Clause "New" or "Revised" License | 18 | | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 | BSD 3-Clause "New" or "Revised" License | 19 | | golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 | BSD 3-Clause "New" or "Revised" License | 20 | | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 | BSD 3-Clause "New" or "Revised" License | 21 | | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 | BSD 3-Clause "New" or "Revised" License | 22 | | golang.org/x/text v0.3.3 | BSD 3-Clause "New" or "Revised" License | 23 | | golang.org/x/tools v0.0.0-20210106214847-113979e3529a | BSD 3-Clause "New" or "Revised" License | 24 | | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 | BSD 3-Clause "New" or "Revised" License | 25 | -------------------------------------------------------------------------------- /vendor/github.com/nats-io/stan.go/go_tests.mod: -------------------------------------------------------------------------------- 1 | module github.com/nats-io/stan.go 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/gogo/protobuf v1.3.2 7 | github.com/nats-io/nats-server/v2 v2.9.11 8 | github.com/nats-io/nats-streaming-server v0.25.3-0.20230111211943-d51efd049657 9 | github.com/nats-io/nats.go v1.22.1 10 | github.com/nats-io/nuid v1.0.1 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Alex Ellis 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/openfaas/faas-provider/types/config.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "net/http" 5 | "time" 6 | ) 7 | 8 | const ( 9 | defaultReadTimeout = 10 * time.Second 10 | defaultMaxIdleConns = 1024 11 | ) 12 | 13 | // FaaSHandlers provide handlers for OpenFaaS 14 | type FaaSHandlers struct { 15 | // ListNamespace lists namespaces which are annotated for OpenFaaS 16 | ListNamespaces http.HandlerFunc 17 | 18 | // MutateNamespace mutates a namespace to be annotated for OpenFaaS 19 | // each namespace must contain an annotation of "openfaas=1" 20 | MutateNamespace http.HandlerFunc 21 | 22 | // FunctionProxy provides the function invocation proxy logic. Use proxy.NewHandlerFunc to 23 | // use the standard OpenFaaS proxy implementation or provide completely custom proxy logic. 24 | FunctionProxy http.HandlerFunc 25 | 26 | // FunctionLister lists deployed functions within a namespace 27 | FunctionLister http.HandlerFunc 28 | 29 | // DeployFunction deploys a function which doesn't exist 30 | DeployFunction http.HandlerFunc 31 | 32 | // UpdateFunction updates an existing function 33 | UpdateFunction http.HandlerFunc 34 | 35 | DeleteFunction http.HandlerFunc 36 | 37 | FunctionStatus http.HandlerFunc 38 | 39 | ScaleFunction http.HandlerFunc 40 | 41 | Secrets http.HandlerFunc 42 | 43 | // Logs provides streaming json logs of functions 44 | Logs http.HandlerFunc 45 | 46 | // Health defines the default health endpoint bound to "/healthz 47 | // If the handler is not set, then the "/healthz" path will not be configured 48 | Health http.HandlerFunc 49 | 50 | Info http.HandlerFunc 51 | 52 | Telemetry http.HandlerFunc 53 | } 54 | 55 | // FaaSConfig set config for HTTP handlers 56 | type FaaSConfig struct { 57 | // TCPPort is the public port for the API. 58 | TCPPort *int 59 | // HTTP timeout for reading a request from clients. 60 | ReadTimeout time.Duration 61 | // HTTP timeout for writing a response from functions. 62 | WriteTimeout time.Duration 63 | // EnableHealth enables/disables the default health endpoint bound to "/healthz". 64 | // 65 | // Deprecated: basic auth is enabled automatcally by setting the HealthHandler in the FaaSHandlers 66 | // struct. This value is not longer read or used. 67 | EnableHealth bool 68 | // EnableBasicAuth enforces basic auth on the API. If set, reads secrets from file-system 69 | // location specificed in `SecretMountPath`. 70 | EnableBasicAuth bool 71 | // SecretMountPath specifies where to read secrets from for embedded basic auth. 72 | SecretMountPath string 73 | // MaxIdleConns with a default value of 1024, can be used for tuning HTTP proxy performance. 74 | MaxIdleConns int 75 | // MaxIdleConnsPerHost with a default value of 1024, can be used for tuning HTTP proxy performance. 76 | MaxIdleConnsPerHost int 77 | } 78 | 79 | // GetReadTimeout is a helper to safely return the configured ReadTimeout or the default value of 10s 80 | func (c *FaaSConfig) GetReadTimeout() time.Duration { 81 | if c.ReadTimeout <= 0*time.Second { 82 | return defaultReadTimeout 83 | } 84 | return c.ReadTimeout 85 | } 86 | 87 | // GetMaxIdleConns is a helper to safely return the configured MaxIdleConns or the default value of 1024 88 | func (c *FaaSConfig) GetMaxIdleConns() int { 89 | if c.MaxIdleConns < 1 { 90 | return defaultMaxIdleConns 91 | } 92 | 93 | return c.MaxIdleConns 94 | } 95 | 96 | // GetMaxIdleConns is a helper to safely return the configured MaxIdleConns or the default value which 97 | // should then match the MaxIdleConns 98 | func (c *FaaSConfig) GetMaxIdleConnsPerHost() int { 99 | if c.MaxIdleConnsPerHost < 1 { 100 | return c.GetMaxIdleConns() 101 | } 102 | 103 | return c.MaxIdleConnsPerHost 104 | } 105 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/types/function_deployment.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // FunctionDeployment represents a request to create or update a Function. 4 | type FunctionDeployment struct { 5 | 6 | // Service is the name of the function deployment 7 | Service string `json:"service"` 8 | 9 | // Image is a fully-qualified container image 10 | Image string `json:"image"` 11 | 12 | // Namespace for the function, if supported by the faas-provider 13 | Namespace string `json:"namespace,omitempty"` 14 | 15 | // EnvProcess overrides the fprocess environment variable and can be used 16 | // with the watchdog 17 | EnvProcess string `json:"envProcess,omitempty"` 18 | 19 | // EnvVars can be provided to set environment variables for the function runtime. 20 | EnvVars map[string]string `json:"envVars,omitempty"` 21 | 22 | // Constraints are specific to the faas-provider. 23 | Constraints []string `json:"constraints,omitempty"` 24 | 25 | // Secrets list of secrets to be made available to function 26 | Secrets []string `json:"secrets,omitempty"` 27 | 28 | // Labels are metadata for functions which may be used by the 29 | // faas-provider or the gateway 30 | Labels *map[string]string `json:"labels,omitempty"` 31 | 32 | // Annotations are metadata for functions which may be used by the 33 | // faas-provider or the gateway 34 | Annotations *map[string]string `json:"annotations,omitempty"` 35 | 36 | // Limits for function 37 | Limits *FunctionResources `json:"limits,omitempty"` 38 | 39 | // Requests of resources requested by function 40 | Requests *FunctionResources `json:"requests,omitempty"` 41 | 42 | // ReadOnlyRootFilesystem removes write-access from the root filesystem 43 | // mount-point. 44 | ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem,omitempty"` 45 | } 46 | 47 | // FunctionResources Memory and CPU 48 | type FunctionResources struct { 49 | Memory string `json:"memory,omitempty"` 50 | CPU string `json:"cpu,omitempty"` 51 | 52 | NvidiaGPU string `json:"nvidia.com/gpu,omitempty"` 53 | AmdGPU string `json:"amd.com/gpu,omitempty"` 54 | IntelGPU string `json:"intel.com/gpu,omitempty"` 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/types/function_status.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import "time" 4 | 5 | // FunctionStatus exported for system/functions endpoint 6 | type FunctionStatus struct { 7 | 8 | // Name is the name of the function deployment 9 | Name string `json:"name"` 10 | 11 | // Image is a fully-qualified container image 12 | Image string `json:"image"` 13 | 14 | // Namespace for the function, if supported by the faas-provider 15 | Namespace string `json:"namespace,omitempty"` 16 | 17 | // EnvProcess overrides the fprocess environment variable and can be used 18 | // with the watchdog 19 | EnvProcess string `json:"envProcess,omitempty"` 20 | 21 | // EnvVars set environment variables for the function runtime 22 | EnvVars map[string]string `json:"envVars,omitempty"` 23 | 24 | // Constraints are specific to the faas-provider 25 | Constraints []string `json:"constraints,omitempty"` 26 | 27 | // Secrets list of secrets to be made available to function 28 | Secrets []string `json:"secrets,omitempty"` 29 | 30 | // Labels are metadata for functions which may be used by the 31 | // faas-provider or the gateway 32 | Labels *map[string]string `json:"labels,omitempty"` 33 | 34 | // Annotations are metadata for functions which may be used by the 35 | // faas-provider or the gateway 36 | Annotations *map[string]string `json:"annotations,omitempty"` 37 | 38 | // Limits for function 39 | Limits *FunctionResources `json:"limits,omitempty"` 40 | 41 | // Requests of resources requested by function 42 | Requests *FunctionResources `json:"requests,omitempty"` 43 | 44 | // ReadOnlyRootFilesystem removes write-access from the root filesystem 45 | // mount-point. 46 | ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem,omitempty"` 47 | 48 | // ================ 49 | // Fields for status 50 | // ================ 51 | 52 | // InvocationCount count of invocations 53 | InvocationCount float64 `json:"invocationCount,omitempty"` 54 | 55 | // Replicas desired within the cluster 56 | Replicas uint64 `json:"replicas,omitempty"` 57 | 58 | // AvailableReplicas is the count of replicas ready to receive 59 | // invocations as reported by the faas-provider 60 | AvailableReplicas uint64 `json:"availableReplicas,omitempty"` 61 | 62 | // CreatedAt is the time read back from the faas backend's 63 | // data store for when the function or its container was created. 64 | CreatedAt time.Time `json:"createdAt,omitempty"` 65 | 66 | // Usage represents CPU and RAM used by all of the 67 | // functions' replicas. Divide by AvailableReplicas for an 68 | // average value per replica. 69 | Usage *FunctionUsage `json:"usage,omitempty"` 70 | } 71 | 72 | // FunctionUsage represents CPU and RAM used by all of the 73 | // functions' replicas. 74 | // 75 | // CPU is measured in seconds consumed since the last measurement 76 | // RAM is measured in total bytes consumed 77 | // 78 | type FunctionUsage struct { 79 | // CPU is the increase in CPU usage since the last measurement 80 | // equivalent to Kubernetes' concept of millicores. 81 | CPU float64 `json:"cpu,omitempty"` 82 | 83 | //TotalMemoryBytes is the total memory usage in bytes. 84 | TotalMemoryBytes float64 `json:"totalMemoryBytes,omitempty"` 85 | } 86 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/types/queue.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "net/http" 5 | "net/url" 6 | ) 7 | 8 | // Request for asynchronous processing 9 | type QueueRequest struct { 10 | // Header from HTTP request 11 | Header http.Header `json:"Header,omitempty"` 12 | 13 | // Host from HTTP request 14 | Host string `json:"Host,omitempty"` 15 | 16 | // Body from HTTP request to use for invocation 17 | Body []byte `json:"Body,omitempty"` 18 | 19 | // Method from HTTP request 20 | Method string `json:"Method"` 21 | 22 | // Path from HTTP request 23 | Path string `json:"Path,omitempty"` 24 | 25 | // QueryString from HTTP request 26 | QueryString string `json:"QueryString,omitempty"` 27 | 28 | // Function name to invoke 29 | Function string `json:"Function"` 30 | 31 | // QueueName to publish the request to, leave blank 32 | // for default. 33 | QueueName string `json:"QueueName,omitempty"` 34 | 35 | // Annotations defines a collection of meta-data that can be used by 36 | // the queue worker when processing the queued request. 37 | Annotations map[string]string `json:"Annotations,omitempty"` 38 | 39 | // Used by queue worker to submit a result 40 | CallbackURL *url.URL `json:"CallbackUrl,omitempty"` 41 | } 42 | 43 | // RequestQueuer can public a request to be executed asynchronously 44 | type RequestQueuer interface { 45 | Queue(req *QueueRequest) error 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/types/requests.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) Alex Ellis 2017. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | package types 5 | 6 | // ScaleServiceRequest scales the service to the requested replica count. 7 | type ScaleServiceRequest struct { 8 | ServiceName string `json:"serviceName"` 9 | Replicas uint64 `json:"replicas"` 10 | Namespace string `json:"namespace,omitempty"` 11 | } 12 | 13 | // DeleteFunctionRequest delete a deployed function 14 | type DeleteFunctionRequest struct { 15 | FunctionName string `json:"functionName"` 16 | Namespace string `json:"namespace,omitempty"` 17 | } 18 | 19 | // ProviderInfo provides information about the configured provider 20 | type ProviderInfo struct { 21 | Name string `json:"provider"` 22 | Version *VersionInfo `json:"version"` 23 | Orchestration string `json:"orchestration"` 24 | } 25 | 26 | // VersionInfo provides the commit message, sha and release version number 27 | type VersionInfo struct { 28 | CommitMessage string `json:"commit_message,omitempty"` 29 | SHA string `json:"sha"` 30 | Release string `json:"release"` 31 | } 32 | 33 | // FunctionNamespace is the namespace for a function 34 | type FunctionNamespace struct { 35 | Name string `json:"name"` 36 | 37 | Annotations map[string]string `json:"annotations,omitempty"` 38 | Labels map[string]string `json:"labels,omitempty"` 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/types/secret.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // Secret for underlying orchestrator 4 | type Secret struct { 5 | // Name of the secret 6 | Name string `json:"name"` 7 | 8 | // Namespace if applicable for the secret 9 | Namespace string `json:"namespace,omitempty"` 10 | 11 | // Value is a string representing the string's value 12 | Value string `json:"value,omitempty"` 13 | 14 | // RawValue can be used to provide binary data when 15 | // Value is not set 16 | RawValue []byte `json:"rawValue,omitempty"` 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/openfaas/faas-provider/types/system_events.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import "time" 4 | 5 | const ( 6 | TypeFunctionUsage = "function_usage" 7 | TypeAPIAccess = "api_access" 8 | ) 9 | 10 | type Event interface { 11 | EventType() string 12 | } 13 | 14 | type FunctionUsageEvent struct { 15 | Namespace string `json:"namespace"` 16 | FunctionName string `json:"function_name"` 17 | Started time.Time `json:"started"` 18 | Duration time.Duration `json:"duration"` 19 | MemoryBytes int64 `json:"memory_bytes"` 20 | } 21 | 22 | func (e FunctionUsageEvent) EventType() string { 23 | return TypeFunctionUsage 24 | } 25 | 26 | type APIAccessEvent struct { 27 | Actor *Actor `json:"actor,omitempty"` 28 | Path string `json:"path"` 29 | Method string `json:"method"` 30 | Actions []string `json:"actions"` 31 | ResponseCode int `json:"response_code"` 32 | CustomMessage string `json:"custom_message,omitempty"` 33 | Namespace string `json:"namespace,omitempty"` 34 | Time time.Time `json:"time"` 35 | } 36 | 37 | func (e APIAccessEvent) EventType() string { 38 | return TypeAPIAccess 39 | } 40 | 41 | // Actor is the user that triggered an event. 42 | // Get from OIDC claims, we can add any of the default OIDC profile or email claim fields if desired. 43 | type Actor struct { 44 | // OIDC subject, a unique identifier of the user. 45 | Sub string `json:"sub"` 46 | // Full name of the subject, can be the name of a user of OpenFaaS component. 47 | Name string `json:"name,omitempty"` 48 | // OpenFaaS issuer 49 | Issuer string `json:"issuer,omitempty"` 50 | // Federated issuer 51 | FedIssuer string `json:"fed_issuer,omitempty"` 52 | } 53 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2009 The Go Authors. 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 LLC nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/blake2b/blake2bAVX2_amd64.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 && gc && !purego 6 | 7 | package blake2b 8 | 9 | import "golang.org/x/sys/cpu" 10 | 11 | func init() { 12 | useAVX2 = cpu.X86.HasAVX2 13 | useAVX = cpu.X86.HasAVX 14 | useSSE4 = cpu.X86.HasSSE41 15 | } 16 | 17 | //go:noescape 18 | func hashBlocksAVX2(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) 19 | 20 | //go:noescape 21 | func hashBlocksAVX(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) 22 | 23 | //go:noescape 24 | func hashBlocksSSE4(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) 25 | 26 | func hashBlocks(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) { 27 | switch { 28 | case useAVX2: 29 | hashBlocksAVX2(h, c, flag, blocks) 30 | case useAVX: 31 | hashBlocksAVX(h, c, flag, blocks) 32 | case useSSE4: 33 | hashBlocksSSE4(h, c, flag, blocks) 34 | default: 35 | hashBlocksGeneric(h, c, flag, blocks) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/blake2b/blake2b_ref.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 || purego || !gc 6 | 7 | package blake2b 8 | 9 | func hashBlocks(h *[8]uint64, c *[2]uint64, flag uint64, blocks []byte) { 10 | hashBlocksGeneric(h, c, flag, blocks) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/blake2b/register.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 | package blake2b 6 | 7 | import ( 8 | "crypto" 9 | "hash" 10 | ) 11 | 12 | func init() { 13 | newHash256 := func() hash.Hash { 14 | h, _ := New256(nil) 15 | return h 16 | } 17 | newHash384 := func() hash.Hash { 18 | h, _ := New384(nil) 19 | return h 20 | } 21 | 22 | newHash512 := func() hash.Hash { 23 | h, _ := New512(nil) 24 | return h 25 | } 26 | 27 | crypto.RegisterHash(crypto.BLAKE2b_256, newHash256) 28 | crypto.RegisterHash(crypto.BLAKE2b_384, newHash384) 29 | crypto.RegisterHash(crypto.BLAKE2b_512, newHash512) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/curve25519/curve25519.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 curve25519 provides an implementation of the X25519 function, which 6 | // performs scalar multiplication on the elliptic curve known as Curve25519. 7 | // See RFC 7748. 8 | // 9 | // This package is a wrapper for the X25519 implementation 10 | // in the crypto/ecdh package. 11 | package curve25519 12 | 13 | import "crypto/ecdh" 14 | 15 | // ScalarMult sets dst to the product scalar * point. 16 | // 17 | // Deprecated: when provided a low-order point, ScalarMult will set dst to all 18 | // zeroes, irrespective of the scalar. Instead, use the X25519 function, which 19 | // will return an error. 20 | func ScalarMult(dst, scalar, point *[32]byte) { 21 | if _, err := x25519(dst, scalar[:], point[:]); err != nil { 22 | // The only error condition for x25519 when the inputs are 32 bytes long 23 | // is if the output would have been the all-zero value. 24 | for i := range dst { 25 | dst[i] = 0 26 | } 27 | } 28 | } 29 | 30 | // ScalarBaseMult sets dst to the product scalar * base where base is the 31 | // standard generator. 32 | // 33 | // It is recommended to use the X25519 function with Basepoint instead, as 34 | // copying into fixed size arrays can lead to unexpected bugs. 35 | func ScalarBaseMult(dst, scalar *[32]byte) { 36 | curve := ecdh.X25519() 37 | priv, err := curve.NewPrivateKey(scalar[:]) 38 | if err != nil { 39 | panic("curve25519: internal error: scalarBaseMult was not 32 bytes") 40 | } 41 | copy(dst[:], priv.PublicKey().Bytes()) 42 | } 43 | 44 | const ( 45 | // ScalarSize is the size of the scalar input to X25519. 46 | ScalarSize = 32 47 | // PointSize is the size of the point input to X25519. 48 | PointSize = 32 49 | ) 50 | 51 | // Basepoint is the canonical Curve25519 generator. 52 | var Basepoint []byte 53 | 54 | var basePoint = [32]byte{9} 55 | 56 | func init() { Basepoint = basePoint[:] } 57 | 58 | // X25519 returns the result of the scalar multiplication (scalar * point), 59 | // according to RFC 7748, Section 5. scalar, point and the return value are 60 | // slices of 32 bytes. 61 | // 62 | // scalar can be generated at random, for example with crypto/rand. point should 63 | // be either Basepoint or the output of another X25519 call. 64 | // 65 | // If point is Basepoint (but not if it's a different slice with the same 66 | // contents) a precomputed implementation might be used for performance. 67 | func X25519(scalar, point []byte) ([]byte, error) { 68 | // Outline the body of function, to let the allocation be inlined in the 69 | // caller, and possibly avoid escaping to the heap. 70 | var dst [32]byte 71 | return x25519(&dst, scalar, point) 72 | } 73 | 74 | func x25519(dst *[32]byte, scalar, point []byte) ([]byte, error) { 75 | curve := ecdh.X25519() 76 | pub, err := curve.NewPublicKey(point) 77 | if err != nil { 78 | return nil, err 79 | } 80 | priv, err := curve.NewPrivateKey(scalar) 81 | if err != nil { 82 | return nil, err 83 | } 84 | out, err := priv.ECDH(pub) 85 | if err != nil { 86 | return nil, err 87 | } 88 | copy(dst[:], out) 89 | return dst[:], nil 90 | } 91 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/alias/alias.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 !purego 6 | 7 | // Package alias implements memory aliasing tests. 8 | package alias 9 | 10 | import "unsafe" 11 | 12 | // AnyOverlap reports whether x and y share memory at any (not necessarily 13 | // corresponding) index. The memory beyond the slice length is ignored. 14 | func AnyOverlap(x, y []byte) bool { 15 | return len(x) > 0 && len(y) > 0 && 16 | uintptr(unsafe.Pointer(&x[0])) <= uintptr(unsafe.Pointer(&y[len(y)-1])) && 17 | uintptr(unsafe.Pointer(&y[0])) <= uintptr(unsafe.Pointer(&x[len(x)-1])) 18 | } 19 | 20 | // InexactOverlap reports whether x and y share memory at any non-corresponding 21 | // index. The memory beyond the slice length is ignored. Note that x and y can 22 | // have different lengths and still not have any inexact overlap. 23 | // 24 | // InexactOverlap can be used to implement the requirements of the crypto/cipher 25 | // AEAD, Block, BlockMode and Stream interfaces. 26 | func InexactOverlap(x, y []byte) bool { 27 | if len(x) == 0 || len(y) == 0 || &x[0] == &y[0] { 28 | return false 29 | } 30 | return AnyOverlap(x, y) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/alias/alias_purego.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 purego 6 | 7 | // Package alias implements memory aliasing tests. 8 | package alias 9 | 10 | // This is the Google App Engine standard variant based on reflect 11 | // because the unsafe package and cgo are disallowed. 12 | 13 | import "reflect" 14 | 15 | // AnyOverlap reports whether x and y share memory at any (not necessarily 16 | // corresponding) index. The memory beyond the slice length is ignored. 17 | func AnyOverlap(x, y []byte) bool { 18 | return len(x) > 0 && len(y) > 0 && 19 | reflect.ValueOf(&x[0]).Pointer() <= reflect.ValueOf(&y[len(y)-1]).Pointer() && 20 | reflect.ValueOf(&y[0]).Pointer() <= reflect.ValueOf(&x[len(x)-1]).Pointer() 21 | } 22 | 23 | // InexactOverlap reports whether x and y share memory at any non-corresponding 24 | // index. The memory beyond the slice length is ignored. Note that x and y can 25 | // have different lengths and still not have any inexact overlap. 26 | // 27 | // InexactOverlap can be used to implement the requirements of the crypto/cipher 28 | // AEAD, Block, BlockMode and Stream interfaces. 29 | func InexactOverlap(x, y []byte) bool { 30 | if len(x) == 0 || len(y) == 0 || &x[0] == &y[0] { 31 | return false 32 | } 33 | return AnyOverlap(x, y) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.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 (!amd64 && !ppc64le && !ppc64 && !s390x) || !gc || purego 6 | 7 | package poly1305 8 | 9 | type mac struct{ macGeneric } 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.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 gc && !purego 6 | 7 | package poly1305 8 | 9 | //go:noescape 10 | func update(state *macState, msg []byte) 11 | 12 | // mac is a wrapper for macGeneric that redirects calls that would have gone to 13 | // updateGeneric to update. 14 | // 15 | // Its Write and Sum methods are otherwise identical to the macGeneric ones, but 16 | // using function pointers would carry a major performance cost. 17 | type mac struct{ macGeneric } 18 | 19 | func (h *mac) Write(p []byte) (int, error) { 20 | nn := len(p) 21 | if h.offset > 0 { 22 | n := copy(h.buffer[h.offset:], p) 23 | if h.offset+n < TagSize { 24 | h.offset += n 25 | return nn, nil 26 | } 27 | p = p[n:] 28 | h.offset = 0 29 | update(&h.macState, h.buffer[:]) 30 | } 31 | if n := len(p) - (len(p) % TagSize); n > 0 { 32 | update(&h.macState, p[:n]) 33 | p = p[n:] 34 | } 35 | if len(p) > 0 { 36 | h.offset += copy(h.buffer[h.offset:], p) 37 | } 38 | return nn, nil 39 | } 40 | 41 | func (h *mac) Sum(out *[16]byte) { 42 | state := h.macState 43 | if h.offset > 0 { 44 | update(&state, h.buffer[:h.offset]) 45 | } 46 | finalize(out, &state.h, &state.s) 47 | } 48 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/poly1305/sum_amd64.s: -------------------------------------------------------------------------------- 1 | // Code generated by command: go run sum_amd64_asm.go -out ../sum_amd64.s -pkg poly1305. DO NOT EDIT. 2 | 3 | //go:build gc && !purego 4 | 5 | // func update(state *macState, msg []byte) 6 | TEXT ·update(SB), $0-32 7 | MOVQ state+0(FP), DI 8 | MOVQ msg_base+8(FP), SI 9 | MOVQ msg_len+16(FP), R15 10 | MOVQ (DI), R8 11 | MOVQ 8(DI), R9 12 | MOVQ 16(DI), R10 13 | MOVQ 24(DI), R11 14 | MOVQ 32(DI), R12 15 | CMPQ R15, $0x10 16 | JB bytes_between_0_and_15 17 | 18 | loop: 19 | ADDQ (SI), R8 20 | ADCQ 8(SI), R9 21 | ADCQ $0x01, R10 22 | LEAQ 16(SI), SI 23 | 24 | multiply: 25 | MOVQ R11, AX 26 | MULQ R8 27 | MOVQ AX, BX 28 | MOVQ DX, CX 29 | MOVQ R11, AX 30 | MULQ R9 31 | ADDQ AX, CX 32 | ADCQ $0x00, DX 33 | MOVQ R11, R13 34 | IMULQ R10, R13 35 | ADDQ DX, R13 36 | MOVQ R12, AX 37 | MULQ R8 38 | ADDQ AX, CX 39 | ADCQ $0x00, DX 40 | MOVQ DX, R8 41 | MOVQ R12, R14 42 | IMULQ R10, R14 43 | MOVQ R12, AX 44 | MULQ R9 45 | ADDQ AX, R13 46 | ADCQ DX, R14 47 | ADDQ R8, R13 48 | ADCQ $0x00, R14 49 | MOVQ BX, R8 50 | MOVQ CX, R9 51 | MOVQ R13, R10 52 | ANDQ $0x03, R10 53 | MOVQ R13, BX 54 | ANDQ $-4, BX 55 | ADDQ BX, R8 56 | ADCQ R14, R9 57 | ADCQ $0x00, R10 58 | SHRQ $0x02, R14, R13 59 | SHRQ $0x02, R14 60 | ADDQ R13, R8 61 | ADCQ R14, R9 62 | ADCQ $0x00, R10 63 | SUBQ $0x10, R15 64 | CMPQ R15, $0x10 65 | JAE loop 66 | 67 | bytes_between_0_and_15: 68 | TESTQ R15, R15 69 | JZ done 70 | MOVQ $0x00000001, BX 71 | XORQ CX, CX 72 | XORQ R13, R13 73 | ADDQ R15, SI 74 | 75 | flush_buffer: 76 | SHLQ $0x08, BX, CX 77 | SHLQ $0x08, BX 78 | MOVB -1(SI), R13 79 | XORQ R13, BX 80 | DECQ SI 81 | DECQ R15 82 | JNZ flush_buffer 83 | ADDQ BX, R8 84 | ADCQ CX, R9 85 | ADCQ $0x00, R10 86 | MOVQ $0x00000010, R15 87 | JMP multiply 88 | 89 | done: 90 | MOVQ R8, (DI) 91 | MOVQ R9, 8(DI) 92 | MOVQ R10, 16(DI) 93 | RET 94 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64x.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 gc && !purego && (ppc64 || ppc64le) 6 | 7 | package poly1305 8 | 9 | //go:noescape 10 | func update(state *macState, msg []byte) 11 | 12 | // mac is a wrapper for macGeneric that redirects calls that would have gone to 13 | // updateGeneric to update. 14 | // 15 | // Its Write and Sum methods are otherwise identical to the macGeneric ones, but 16 | // using function pointers would carry a major performance cost. 17 | type mac struct{ macGeneric } 18 | 19 | func (h *mac) Write(p []byte) (int, error) { 20 | nn := len(p) 21 | if h.offset > 0 { 22 | n := copy(h.buffer[h.offset:], p) 23 | if h.offset+n < TagSize { 24 | h.offset += n 25 | return nn, nil 26 | } 27 | p = p[n:] 28 | h.offset = 0 29 | update(&h.macState, h.buffer[:]) 30 | } 31 | if n := len(p) - (len(p) % TagSize); n > 0 { 32 | update(&h.macState, p[:n]) 33 | p = p[n:] 34 | } 35 | if len(p) > 0 { 36 | h.offset += copy(h.buffer[h.offset:], p) 37 | } 38 | return nn, nil 39 | } 40 | 41 | func (h *mac) Sum(out *[16]byte) { 42 | state := h.macState 43 | if h.offset > 0 { 44 | update(&state, h.buffer[:h.offset]) 45 | } 46 | finalize(out, &state.h, &state.s) 47 | } 48 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/internal/poly1305/sum_s390x.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 gc && !purego 6 | 7 | package poly1305 8 | 9 | import ( 10 | "golang.org/x/sys/cpu" 11 | ) 12 | 13 | // updateVX is an assembly implementation of Poly1305 that uses vector 14 | // instructions. It must only be called if the vector facility (vx) is 15 | // available. 16 | // 17 | //go:noescape 18 | func updateVX(state *macState, msg []byte) 19 | 20 | // mac is a replacement for macGeneric that uses a larger buffer and redirects 21 | // calls that would have gone to updateGeneric to updateVX if the vector 22 | // facility is installed. 23 | // 24 | // A larger buffer is required for good performance because the vector 25 | // implementation has a higher fixed cost per call than the generic 26 | // implementation. 27 | type mac struct { 28 | macState 29 | 30 | buffer [16 * TagSize]byte // size must be a multiple of block size (16) 31 | offset int 32 | } 33 | 34 | func (h *mac) Write(p []byte) (int, error) { 35 | nn := len(p) 36 | if h.offset > 0 { 37 | n := copy(h.buffer[h.offset:], p) 38 | if h.offset+n < len(h.buffer) { 39 | h.offset += n 40 | return nn, nil 41 | } 42 | p = p[n:] 43 | h.offset = 0 44 | if cpu.S390X.HasVX { 45 | updateVX(&h.macState, h.buffer[:]) 46 | } else { 47 | updateGeneric(&h.macState, h.buffer[:]) 48 | } 49 | } 50 | 51 | tail := len(p) % len(h.buffer) // number of bytes to copy into buffer 52 | body := len(p) - tail // number of bytes to process now 53 | if body > 0 { 54 | if cpu.S390X.HasVX { 55 | updateVX(&h.macState, p[:body]) 56 | } else { 57 | updateGeneric(&h.macState, p[:body]) 58 | } 59 | } 60 | h.offset = copy(h.buffer[:], p[body:]) // copy tail bytes - can be 0 61 | return nn, nil 62 | } 63 | 64 | func (h *mac) Sum(out *[TagSize]byte) { 65 | state := h.macState 66 | remainder := h.buffer[:h.offset] 67 | 68 | // Use the generic implementation if we have 2 or fewer blocks left 69 | // to sum. The vector implementation has a higher startup time. 70 | if cpu.S390X.HasVX && len(remainder) > 2*TagSize { 71 | updateVX(&state, remainder) 72 | } else if len(remainder) > 0 { 73 | updateGeneric(&state, remainder) 74 | } 75 | finalize(out, &state.h, &state.s) 76 | } 77 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.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 amd64 && !purego && gc 6 | 7 | package salsa 8 | 9 | //go:noescape 10 | 11 | // salsa2020XORKeyStream is implemented in salsa20_amd64.s. 12 | func salsa2020XORKeyStream(out, in *byte, n uint64, nonce, key *byte) 13 | 14 | // XORKeyStream crypts bytes from in to out using the given key and counters. 15 | // In and out must overlap entirely or not at all. Counter 16 | // contains the raw salsa20 counter bytes (both nonce and block counter). 17 | func XORKeyStream(out, in []byte, counter *[16]byte, key *[32]byte) { 18 | if len(in) == 0 { 19 | return 20 | } 21 | _ = out[len(in)-1] 22 | salsa2020XORKeyStream(&out[0], &in[0], uint64(len(in)), &counter[0], &key[0]) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/salsa20/salsa/salsa20_noasm.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 !amd64 || purego || !gc 6 | 7 | package salsa 8 | 9 | // XORKeyStream crypts bytes from in to out using the given key and counters. 10 | // In and out must overlap entirely or not at all. Counter 11 | // contains the raw salsa20 counter bytes (both nonce and block counter). 12 | func XORKeyStream(out, in []byte, counter *[16]byte, key *[32]byte) { 13 | genericXORKeyStream(out, in, counter, key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2009 The Go Authors. 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 LLC 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/cpu/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 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for ppc64, AIX are implemented in runtime/syscall_aix.go 11 | // 12 | 13 | TEXT ·syscall6(SB),NOSPLIT,$0-88 14 | JMP syscall·syscall6(SB) 15 | 16 | TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSyscall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/asm_darwin_x86_gc.s: -------------------------------------------------------------------------------- 1 | // Copyright 2024 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 && amd64 && gc 6 | 7 | #include "textflag.h" 8 | 9 | TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 10 | JMP libc_sysctl(SB) 11 | GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 12 | DATA ·libc_sysctl_trampoline_addr(SB)/8, $libc_sysctl_trampoline<>(SB) 13 | 14 | TEXT libc_sysctlbyname_trampoline<>(SB),NOSPLIT,$0-0 15 | JMP libc_sysctlbyname(SB) 16 | GLOBL ·libc_sysctlbyname_trampoline_addr(SB), RODATA, $8 17 | DATA ·libc_sysctlbyname_trampoline_addr(SB)/8, $libc_sysctlbyname_trampoline<>(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/byteorder.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 cpu 6 | 7 | import ( 8 | "runtime" 9 | ) 10 | 11 | // byteOrder is a subset of encoding/binary.ByteOrder. 12 | type byteOrder interface { 13 | Uint32([]byte) uint32 14 | Uint64([]byte) uint64 15 | } 16 | 17 | type littleEndian struct{} 18 | type bigEndian struct{} 19 | 20 | func (littleEndian) Uint32(b []byte) uint32 { 21 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 22 | return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 23 | } 24 | 25 | func (littleEndian) Uint64(b []byte) uint64 { 26 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 27 | return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | 28 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 29 | } 30 | 31 | func (bigEndian) Uint32(b []byte) uint32 { 32 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 33 | return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 34 | } 35 | 36 | func (bigEndian) Uint64(b []byte) uint64 { 37 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 38 | return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | 39 | uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 40 | } 41 | 42 | // hostByteOrder returns littleEndian on little-endian machines and 43 | // bigEndian on big-endian machines. 44 | func hostByteOrder() byteOrder { 45 | switch runtime.GOARCH { 46 | case "386", "amd64", "amd64p32", 47 | "alpha", 48 | "arm", "arm64", 49 | "loong64", 50 | "mipsle", "mips64le", "mips64p32le", 51 | "nios2", 52 | "ppc64le", 53 | "riscv", "riscv64", 54 | "sh": 55 | return littleEndian{} 56 | case "armbe", "arm64be", 57 | "m68k", 58 | "mips", "mips64", "mips64p32", 59 | "ppc", "ppc64", 60 | "s390", "s390x", 61 | "shbe", 62 | "sparc", "sparc64": 63 | return bigEndian{} 64 | } 65 | panic("unknown architecture") 66 | } 67 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_aix.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 6 | 7 | package cpu 8 | 9 | const ( 10 | // getsystemcfg constants 11 | _SC_IMPL = 2 12 | _IMPL_POWER8 = 0x10000 13 | _IMPL_POWER9 = 0x20000 14 | ) 15 | 16 | func archInit() { 17 | impl := getsystemcfg(_SC_IMPL) 18 | if impl&_IMPL_POWER8 != 0 { 19 | PPC64.IsPOWER8 = true 20 | } 21 | if impl&_IMPL_POWER9 != 0 { 22 | PPC64.IsPOWER8 = true 23 | PPC64.IsPOWER9 = true 24 | } 25 | 26 | Initialized = true 27 | } 28 | 29 | func getsystemcfg(label int) (n uint64) { 30 | r0, _ := callgetsystemcfg(label) 31 | n = uint64(r0) 32 | return 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_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 | package cpu 6 | 7 | const cacheLineSize = 32 8 | 9 | // HWCAP/HWCAP2 bits. 10 | // These are specific to Linux. 11 | const ( 12 | hwcap_SWP = 1 << 0 13 | hwcap_HALF = 1 << 1 14 | hwcap_THUMB = 1 << 2 15 | hwcap_26BIT = 1 << 3 16 | hwcap_FAST_MULT = 1 << 4 17 | hwcap_FPA = 1 << 5 18 | hwcap_VFP = 1 << 6 19 | hwcap_EDSP = 1 << 7 20 | hwcap_JAVA = 1 << 8 21 | hwcap_IWMMXT = 1 << 9 22 | hwcap_CRUNCH = 1 << 10 23 | hwcap_THUMBEE = 1 << 11 24 | hwcap_NEON = 1 << 12 25 | hwcap_VFPv3 = 1 << 13 26 | hwcap_VFPv3D16 = 1 << 14 27 | hwcap_TLS = 1 << 15 28 | hwcap_VFPv4 = 1 << 16 29 | hwcap_IDIVA = 1 << 17 30 | hwcap_IDIVT = 1 << 18 31 | hwcap_VFPD32 = 1 << 19 32 | hwcap_LPAE = 1 << 20 33 | hwcap_EVTSTRM = 1 << 21 34 | 35 | hwcap2_AES = 1 << 0 36 | hwcap2_PMULL = 1 << 1 37 | hwcap2_SHA1 = 1 << 2 38 | hwcap2_SHA2 = 1 << 3 39 | hwcap2_CRC32 = 1 << 4 40 | ) 41 | 42 | func initOptions() { 43 | options = []option{ 44 | {Name: "pmull", Feature: &ARM.HasPMULL}, 45 | {Name: "sha1", Feature: &ARM.HasSHA1}, 46 | {Name: "sha2", Feature: &ARM.HasSHA2}, 47 | {Name: "swp", Feature: &ARM.HasSWP}, 48 | {Name: "thumb", Feature: &ARM.HasTHUMB}, 49 | {Name: "thumbee", Feature: &ARM.HasTHUMBEE}, 50 | {Name: "tls", Feature: &ARM.HasTLS}, 51 | {Name: "vfp", Feature: &ARM.HasVFP}, 52 | {Name: "vfpd32", Feature: &ARM.HasVFPD32}, 53 | {Name: "vfpv3", Feature: &ARM.HasVFPv3}, 54 | {Name: "vfpv3d16", Feature: &ARM.HasVFPv3D16}, 55 | {Name: "vfpv4", Feature: &ARM.HasVFPv4}, 56 | {Name: "half", Feature: &ARM.HasHALF}, 57 | {Name: "26bit", Feature: &ARM.Has26BIT}, 58 | {Name: "fastmul", Feature: &ARM.HasFASTMUL}, 59 | {Name: "fpa", Feature: &ARM.HasFPA}, 60 | {Name: "edsp", Feature: &ARM.HasEDSP}, 61 | {Name: "java", Feature: &ARM.HasJAVA}, 62 | {Name: "iwmmxt", Feature: &ARM.HasIWMMXT}, 63 | {Name: "crunch", Feature: &ARM.HasCRUNCH}, 64 | {Name: "neon", Feature: &ARM.HasNEON}, 65 | {Name: "idivt", Feature: &ARM.HasIDIVT}, 66 | {Name: "idiva", Feature: &ARM.HasIDIVA}, 67 | {Name: "lpae", Feature: &ARM.HasLPAE}, 68 | {Name: "evtstrm", Feature: &ARM.HasEVTSTRM}, 69 | {Name: "aes", Feature: &ARM.HasAES}, 70 | {Name: "crc32", Feature: &ARM.HasCRC32}, 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_arm64.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 | 7 | #include "textflag.h" 8 | 9 | // func getisar0() uint64 10 | TEXT ·getisar0(SB),NOSPLIT,$0-8 11 | // get Instruction Set Attributes 0 into x0 12 | // mrs x0, ID_AA64ISAR0_EL1 = d5380600 13 | WORD $0xd5380600 14 | MOVD R0, ret+0(FP) 15 | RET 16 | 17 | // func getisar1() uint64 18 | TEXT ·getisar1(SB),NOSPLIT,$0-8 19 | // get Instruction Set Attributes 1 into x0 20 | // mrs x0, ID_AA64ISAR1_EL1 = d5380620 21 | WORD $0xd5380620 22 | MOVD R0, ret+0(FP) 23 | RET 24 | 25 | // func getpfr0() uint64 26 | TEXT ·getpfr0(SB),NOSPLIT,$0-8 27 | // get Processor Feature Register 0 into x0 28 | // mrs x0, ID_AA64PFR0_EL1 = d5380400 29 | WORD $0xd5380400 30 | MOVD R0, ret+0(FP) 31 | RET 32 | 33 | // func getzfr0() uint64 34 | TEXT ·getzfr0(SB),NOSPLIT,$0-8 35 | // get SVE Feature Register 0 into x0 36 | // mrs x0, ID_AA64ZFR0_EL1 = d5380480 37 | WORD $0xd5380480 38 | MOVD R0, ret+0(FP) 39 | RET 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_darwin_x86.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 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 && amd64 && gc 6 | 7 | package cpu 8 | 9 | // darwinSupportsAVX512 checks Darwin kernel for AVX512 support via sysctl 10 | // call (see issue 43089). It also restricts AVX512 support for Darwin to 11 | // kernel version 21.3.0 (MacOS 12.2.0) or later (see issue 49233). 12 | // 13 | // Background: 14 | // Darwin implements a special mechanism to economize on thread state when 15 | // AVX512 specific registers are not in use. This scheme minimizes state when 16 | // preempting threads that haven't yet used any AVX512 instructions, but adds 17 | // special requirements to check for AVX512 hardware support at runtime (e.g. 18 | // via sysctl call or commpage inspection). See issue 43089 and link below for 19 | // full background: 20 | // https://github.com/apple-oss-distributions/xnu/blob/xnu-11215.1.10/osfmk/i386/fpu.c#L214-L240 21 | // 22 | // Additionally, all versions of the Darwin kernel from 19.6.0 through 21.2.0 23 | // (corresponding to MacOS 10.15.6 - 12.1) have a bug that can cause corruption 24 | // of the AVX512 mask registers (K0-K7) upon signal return. For this reason 25 | // AVX512 is considered unsafe to use on Darwin for kernel versions prior to 26 | // 21.3.0, where a fix has been confirmed. See issue 49233 for full background. 27 | func darwinSupportsAVX512() bool { 28 | return darwinSysctlEnabled([]byte("hw.optional.avx512f\x00")) && darwinKernelVersionCheck(21, 3, 0) 29 | } 30 | 31 | // Ensure Darwin kernel version is at least major.minor.patch, avoiding dependencies 32 | func darwinKernelVersionCheck(major, minor, patch int) bool { 33 | var release [256]byte 34 | err := darwinOSRelease(&release) 35 | if err != nil { 36 | return false 37 | } 38 | 39 | var mmp [3]int 40 | c := 0 41 | Loop: 42 | for _, b := range release[:] { 43 | switch { 44 | case b >= '0' && b <= '9': 45 | mmp[c] = 10*mmp[c] + int(b-'0') 46 | case b == '.': 47 | c++ 48 | if c > 2 { 49 | return false 50 | } 51 | case b == 0: 52 | break Loop 53 | default: 54 | return false 55 | } 56 | } 57 | if c != 2 { 58 | return false 59 | } 60 | return mmp[0] > major || mmp[0] == major && (mmp[1] > minor || mmp[1] == minor && mmp[2] >= patch) 61 | } 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gc_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 gc 6 | 7 | package cpu 8 | 9 | func getisar0() uint64 10 | func getisar1() uint64 11 | func getpfr0() uint64 12 | func getzfr0() uint64 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gc_s390x.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 gc 6 | 7 | package cpu 8 | 9 | // haveAsmFunctions reports whether the other functions in this file can 10 | // be safely called. 11 | func haveAsmFunctions() bool { return true } 12 | 13 | // The following feature detection functions are defined in cpu_s390x.s. 14 | // They are likely to be expensive to call so the results should be cached. 15 | func stfle() facilityList 16 | func kmQuery() queryResult 17 | func kmcQuery() queryResult 18 | func kmctrQuery() queryResult 19 | func kmaQuery() queryResult 20 | func kimdQuery() queryResult 21 | func klmdQuery() queryResult 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gc_x86.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 (386 || amd64 || amd64p32) && gc 6 | 7 | package cpu 8 | 9 | // cpuid is implemented in cpu_gc_x86.s for gc compiler 10 | // and in cpu_gccgo.c for gccgo. 11 | func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) 12 | 13 | // xgetbv with ecx = 0 is implemented in cpu_gc_x86.s for gc compiler 14 | // and in cpu_gccgo.c for gccgo. 15 | func xgetbv() (eax, edx uint32) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gc_x86.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 (386 || amd64 || amd64p32) && gc 6 | 7 | #include "textflag.h" 8 | 9 | // func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) 10 | TEXT ·cpuid(SB), NOSPLIT, $0-24 11 | MOVL eaxArg+0(FP), AX 12 | MOVL ecxArg+4(FP), CX 13 | CPUID 14 | MOVL AX, eax+8(FP) 15 | MOVL BX, ebx+12(FP) 16 | MOVL CX, ecx+16(FP) 17 | MOVL DX, edx+20(FP) 18 | RET 19 | 20 | // func xgetbv() (eax, edx uint32) 21 | TEXT ·xgetbv(SB), NOSPLIT, $0-8 22 | MOVL $0, CX 23 | XGETBV 24 | MOVL AX, eax+0(FP) 25 | MOVL DX, edx+4(FP) 26 | RET 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gccgo_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 gccgo 6 | 7 | package cpu 8 | 9 | func getisar0() uint64 { return 0 } 10 | func getisar1() uint64 { return 0 } 11 | func getpfr0() uint64 { return 0 } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.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 gccgo 6 | 7 | package cpu 8 | 9 | // haveAsmFunctions reports whether the other functions in this file can 10 | // be safely called. 11 | func haveAsmFunctions() bool { return false } 12 | 13 | // TODO(mundaym): the following feature detection functions are currently 14 | // stubs. See https://golang.org/cl/162887 for how to fix this. 15 | // They are likely to be expensive to call so the results should be cached. 16 | func stfle() facilityList { panic("not implemented for gccgo") } 17 | func kmQuery() queryResult { panic("not implemented for gccgo") } 18 | func kmcQuery() queryResult { panic("not implemented for gccgo") } 19 | func kmctrQuery() queryResult { panic("not implemented for gccgo") } 20 | func kmaQuery() queryResult { panic("not implemented for gccgo") } 21 | func kimdQuery() queryResult { panic("not implemented for gccgo") } 22 | func klmdQuery() queryResult { panic("not implemented for gccgo") } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c: -------------------------------------------------------------------------------- 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 (386 || amd64 || amd64p32) && gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | // Need to wrap __get_cpuid_count because it's declared as static. 12 | int 13 | gccgoGetCpuidCount(uint32_t leaf, uint32_t subleaf, 14 | uint32_t *eax, uint32_t *ebx, 15 | uint32_t *ecx, uint32_t *edx) 16 | { 17 | return __get_cpuid_count(leaf, subleaf, eax, ebx, ecx, edx); 18 | } 19 | 20 | #pragma GCC diagnostic ignored "-Wunknown-pragmas" 21 | #pragma GCC push_options 22 | #pragma GCC target("xsave") 23 | #pragma clang attribute push (__attribute__((target("xsave"))), apply_to=function) 24 | 25 | // xgetbv reads the contents of an XCR (Extended Control Register) 26 | // specified in the ECX register into registers EDX:EAX. 27 | // Currently, the only supported value for XCR is 0. 28 | void 29 | gccgoXgetbv(uint32_t *eax, uint32_t *edx) 30 | { 31 | uint64_t v = _xgetbv(0); 32 | *eax = v & 0xffffffff; 33 | *edx = v >> 32; 34 | } 35 | 36 | #pragma clang attribute pop 37 | #pragma GCC pop_options 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.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 (386 || amd64 || amd64p32) && gccgo 6 | 7 | package cpu 8 | 9 | //extern gccgoGetCpuidCount 10 | func gccgoGetCpuidCount(eaxArg, ecxArg uint32, eax, ebx, ecx, edx *uint32) 11 | 12 | func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) { 13 | var a, b, c, d uint32 14 | gccgoGetCpuidCount(eaxArg, ecxArg, &a, &b, &c, &d) 15 | return a, b, c, d 16 | } 17 | 18 | //extern gccgoXgetbv 19 | func gccgoXgetbv(eax, edx *uint32) 20 | 21 | func xgetbv() (eax, edx uint32) { 22 | var a, d uint32 23 | gccgoXgetbv(&a, &d) 24 | return a, d 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_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 | //go:build !386 && !amd64 && !amd64p32 && !arm64 6 | 7 | package cpu 8 | 9 | func archInit() { 10 | if err := readHWCAP(); err != nil { 11 | return 12 | } 13 | doinit() 14 | Initialized = true 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_linux_arm.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 cpu 6 | 7 | func doinit() { 8 | ARM.HasSWP = isSet(hwCap, hwcap_SWP) 9 | ARM.HasHALF = isSet(hwCap, hwcap_HALF) 10 | ARM.HasTHUMB = isSet(hwCap, hwcap_THUMB) 11 | ARM.Has26BIT = isSet(hwCap, hwcap_26BIT) 12 | ARM.HasFASTMUL = isSet(hwCap, hwcap_FAST_MULT) 13 | ARM.HasFPA = isSet(hwCap, hwcap_FPA) 14 | ARM.HasVFP = isSet(hwCap, hwcap_VFP) 15 | ARM.HasEDSP = isSet(hwCap, hwcap_EDSP) 16 | ARM.HasJAVA = isSet(hwCap, hwcap_JAVA) 17 | ARM.HasIWMMXT = isSet(hwCap, hwcap_IWMMXT) 18 | ARM.HasCRUNCH = isSet(hwCap, hwcap_CRUNCH) 19 | ARM.HasTHUMBEE = isSet(hwCap, hwcap_THUMBEE) 20 | ARM.HasNEON = isSet(hwCap, hwcap_NEON) 21 | ARM.HasVFPv3 = isSet(hwCap, hwcap_VFPv3) 22 | ARM.HasVFPv3D16 = isSet(hwCap, hwcap_VFPv3D16) 23 | ARM.HasTLS = isSet(hwCap, hwcap_TLS) 24 | ARM.HasVFPv4 = isSet(hwCap, hwcap_VFPv4) 25 | ARM.HasIDIVA = isSet(hwCap, hwcap_IDIVA) 26 | ARM.HasIDIVT = isSet(hwCap, hwcap_IDIVT) 27 | ARM.HasVFPD32 = isSet(hwCap, hwcap_VFPD32) 28 | ARM.HasLPAE = isSet(hwCap, hwcap_LPAE) 29 | ARM.HasEVTSTRM = isSet(hwCap, hwcap_EVTSTRM) 30 | ARM.HasAES = isSet(hwCap2, hwcap2_AES) 31 | ARM.HasPMULL = isSet(hwCap2, hwcap2_PMULL) 32 | ARM.HasSHA1 = isSet(hwCap2, hwcap2_SHA1) 33 | ARM.HasSHA2 = isSet(hwCap2, hwcap2_SHA2) 34 | ARM.HasCRC32 = isSet(hwCap2, hwcap2_CRC32) 35 | } 36 | 37 | func isSet(hwc uint, value uint) bool { 38 | return hwc&value != 0 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_linux_mips64x.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 linux && (mips64 || mips64le) 6 | 7 | package cpu 8 | 9 | // HWCAP bits. These are exposed by the Linux kernel 5.4. 10 | const ( 11 | // CPU features 12 | hwcap_MIPS_MSA = 1 << 1 13 | ) 14 | 15 | func doinit() { 16 | // HWCAP feature bits 17 | MIPS64X.HasMSA = isSet(hwCap, hwcap_MIPS_MSA) 18 | } 19 | 20 | func isSet(hwc uint, value uint) bool { 21 | return hwc&value != 0 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_linux_noinit.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 linux && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !s390x && !riscv64 6 | 7 | package cpu 8 | 9 | func doinit() {} 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_linux_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 && (ppc64 || ppc64le) 6 | 7 | package cpu 8 | 9 | // HWCAP/HWCAP2 bits. These are exposed by the kernel. 10 | const ( 11 | // ISA Level 12 | _PPC_FEATURE2_ARCH_2_07 = 0x80000000 13 | _PPC_FEATURE2_ARCH_3_00 = 0x00800000 14 | 15 | // CPU features 16 | _PPC_FEATURE2_DARN = 0x00200000 17 | _PPC_FEATURE2_SCV = 0x00100000 18 | ) 19 | 20 | func doinit() { 21 | // HWCAP2 feature bits 22 | PPC64.IsPOWER8 = isSet(hwCap2, _PPC_FEATURE2_ARCH_2_07) 23 | PPC64.IsPOWER9 = isSet(hwCap2, _PPC_FEATURE2_ARCH_3_00) 24 | PPC64.HasDARN = isSet(hwCap2, _PPC_FEATURE2_DARN) 25 | PPC64.HasSCV = isSet(hwCap2, _PPC_FEATURE2_SCV) 26 | } 27 | 28 | func isSet(hwc uint, value uint) bool { 29 | return hwc&value != 0 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_linux_s390x.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 cpu 6 | 7 | const ( 8 | // bit mask values from /usr/include/bits/hwcap.h 9 | hwcap_ZARCH = 2 10 | hwcap_STFLE = 4 11 | hwcap_MSA = 8 12 | hwcap_LDISP = 16 13 | hwcap_EIMM = 32 14 | hwcap_DFP = 64 15 | hwcap_ETF3EH = 256 16 | hwcap_VX = 2048 17 | hwcap_VXE = 8192 18 | ) 19 | 20 | func initS390Xbase() { 21 | // test HWCAP bit vector 22 | has := func(featureMask uint) bool { 23 | return hwCap&featureMask == featureMask 24 | } 25 | 26 | // mandatory 27 | S390X.HasZARCH = has(hwcap_ZARCH) 28 | 29 | // optional 30 | S390X.HasSTFLE = has(hwcap_STFLE) 31 | S390X.HasLDISP = has(hwcap_LDISP) 32 | S390X.HasEIMM = has(hwcap_EIMM) 33 | S390X.HasETF3EH = has(hwcap_ETF3EH) 34 | S390X.HasDFP = has(hwcap_DFP) 35 | S390X.HasMSA = has(hwcap_MSA) 36 | S390X.HasVX = has(hwcap_VX) 37 | if S390X.HasVX { 38 | S390X.HasVXE = has(hwcap_VXE) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_loong64.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 loong64 6 | 7 | package cpu 8 | 9 | const cacheLineSize = 64 10 | 11 | func initOptions() { 12 | } 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_mips64x.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 mips64 || mips64le 6 | 7 | package cpu 8 | 9 | const cacheLineSize = 32 10 | 11 | func initOptions() { 12 | options = []option{ 13 | {Name: "msa", Feature: &MIPS64X.HasMSA}, 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_mipsx.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 mips || mipsle 6 | 7 | package cpu 8 | 9 | const cacheLineSize = 32 10 | 11 | func initOptions() {} 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.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 | package cpu 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | // Minimal copy of functionality from x/sys/unix so the cpu package can call 13 | // sysctl without depending on x/sys/unix. 14 | 15 | const ( 16 | // From OpenBSD's sys/sysctl.h. 17 | _CTL_MACHDEP = 7 18 | 19 | // From OpenBSD's machine/cpu.h. 20 | _CPU_ID_AA64ISAR0 = 2 21 | _CPU_ID_AA64ISAR1 = 3 22 | ) 23 | 24 | // Implemented in the runtime package (runtime/sys_openbsd3.go) 25 | func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 26 | 27 | //go:linkname syscall_syscall6 syscall.syscall6 28 | 29 | func sysctl(mib []uint32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { 30 | _, _, errno := syscall_syscall6(libc_sysctl_trampoline_addr, uintptr(unsafe.Pointer(&mib[0])), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) 31 | if errno != 0 { 32 | return errno 33 | } 34 | return nil 35 | } 36 | 37 | var libc_sysctl_trampoline_addr uintptr 38 | 39 | //go:cgo_import_dynamic libc_sysctl sysctl "libc.so" 40 | 41 | func sysctlUint64(mib []uint32) (uint64, bool) { 42 | var out uint64 43 | nout := unsafe.Sizeof(out) 44 | if err := sysctl(mib, (*byte)(unsafe.Pointer(&out)), &nout, nil, 0); err != nil { 45 | return 0, false 46 | } 47 | return out, true 48 | } 49 | 50 | func doinit() { 51 | setMinimalFeatures() 52 | 53 | // Get ID_AA64ISAR0 and ID_AA64ISAR1 from sysctl. 54 | isar0, ok := sysctlUint64([]uint32{_CTL_MACHDEP, _CPU_ID_AA64ISAR0}) 55 | if !ok { 56 | return 57 | } 58 | isar1, ok := sysctlUint64([]uint32{_CTL_MACHDEP, _CPU_ID_AA64ISAR1}) 59 | if !ok { 60 | return 61 | } 62 | parseARM64SystemRegisters(isar0, isar1, 0) 63 | 64 | Initialized = true 65 | } 66 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.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 | #include "textflag.h" 6 | 7 | TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 8 | JMP libc_sysctl(SB) 9 | 10 | GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 11 | DATA ·libc_sysctl_trampoline_addr(SB)/8, $libc_sysctl_trampoline<>(SB) 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_other_arm.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 !linux && arm 6 | 7 | package cpu 8 | 9 | func archInit() {} 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_other_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 !linux && !netbsd && !openbsd && arm64 6 | 7 | package cpu 8 | 9 | func doinit() {} 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_other_mips64x.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 !linux && (mips64 || mips64le) 6 | 7 | package cpu 8 | 9 | func archInit() { 10 | Initialized = true 11 | } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_other_ppc64x.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 !aix && !linux && (ppc64 || ppc64le) 6 | 7 | package cpu 8 | 9 | func archInit() { 10 | PPC64.IsPOWER8 = true 11 | Initialized = true 12 | } 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_other_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 !linux && riscv64 6 | 7 | package cpu 8 | 9 | func archInit() { 10 | Initialized = true 11 | } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_other_x86.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 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 || amd64p32 || (amd64 && (!darwin || !gc)) 6 | 7 | package cpu 8 | 9 | func darwinSupportsAVX512() bool { 10 | panic("only implemented for gc && amd64 && darwin") 11 | } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_ppc64x.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 ppc64 || ppc64le 6 | 7 | package cpu 8 | 9 | const cacheLineSize = 128 10 | 11 | func initOptions() { 12 | options = []option{ 13 | {Name: "darn", Feature: &PPC64.HasDARN}, 14 | {Name: "scv", Feature: &PPC64.HasSCV}, 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_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 6 | 7 | package cpu 8 | 9 | const cacheLineSize = 64 10 | 11 | func initOptions() { 12 | options = []option{ 13 | {Name: "fastmisaligned", Feature: &RISCV64.HasFastMisaligned}, 14 | {Name: "c", Feature: &RISCV64.HasC}, 15 | {Name: "v", Feature: &RISCV64.HasV}, 16 | {Name: "zba", Feature: &RISCV64.HasZba}, 17 | {Name: "zbb", Feature: &RISCV64.HasZbb}, 18 | {Name: "zbs", Feature: &RISCV64.HasZbs}, 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_s390x.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 | 7 | #include "textflag.h" 8 | 9 | // func stfle() facilityList 10 | TEXT ·stfle(SB), NOSPLIT|NOFRAME, $0-32 11 | MOVD $ret+0(FP), R1 12 | MOVD $3, R0 // last doubleword index to store 13 | XC $32, (R1), (R1) // clear 4 doublewords (32 bytes) 14 | WORD $0xb2b01000 // store facility list extended (STFLE) 15 | RET 16 | 17 | // func kmQuery() queryResult 18 | TEXT ·kmQuery(SB), NOSPLIT|NOFRAME, $0-16 19 | MOVD $0, R0 // set function code to 0 (KM-Query) 20 | MOVD $ret+0(FP), R1 // address of 16-byte return value 21 | WORD $0xB92E0024 // cipher message (KM) 22 | RET 23 | 24 | // func kmcQuery() queryResult 25 | TEXT ·kmcQuery(SB), NOSPLIT|NOFRAME, $0-16 26 | MOVD $0, R0 // set function code to 0 (KMC-Query) 27 | MOVD $ret+0(FP), R1 // address of 16-byte return value 28 | WORD $0xB92F0024 // cipher message with chaining (KMC) 29 | RET 30 | 31 | // func kmctrQuery() queryResult 32 | TEXT ·kmctrQuery(SB), NOSPLIT|NOFRAME, $0-16 33 | MOVD $0, R0 // set function code to 0 (KMCTR-Query) 34 | MOVD $ret+0(FP), R1 // address of 16-byte return value 35 | WORD $0xB92D4024 // cipher message with counter (KMCTR) 36 | RET 37 | 38 | // func kmaQuery() queryResult 39 | TEXT ·kmaQuery(SB), NOSPLIT|NOFRAME, $0-16 40 | MOVD $0, R0 // set function code to 0 (KMA-Query) 41 | MOVD $ret+0(FP), R1 // address of 16-byte return value 42 | WORD $0xb9296024 // cipher message with authentication (KMA) 43 | RET 44 | 45 | // func kimdQuery() queryResult 46 | TEXT ·kimdQuery(SB), NOSPLIT|NOFRAME, $0-16 47 | MOVD $0, R0 // set function code to 0 (KIMD-Query) 48 | MOVD $ret+0(FP), R1 // address of 16-byte return value 49 | WORD $0xB93E0024 // compute intermediate message digest (KIMD) 50 | RET 51 | 52 | // func klmdQuery() queryResult 53 | TEXT ·klmdQuery(SB), NOSPLIT|NOFRAME, $0-16 54 | MOVD $0, R0 // set function code to 0 (KLMD-Query) 55 | MOVD $ret+0(FP), R1 // address of 16-byte return value 56 | WORD $0xB93F0024 // compute last message digest (KLMD) 57 | RET 58 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_wasm.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 wasm 6 | 7 | package cpu 8 | 9 | // We're compiling the cpu package for an unknown (software-abstracted) CPU. 10 | // Make CacheLinePad an empty struct and hope that the usual struct alignment 11 | // rules are good enough. 12 | 13 | const cacheLineSize = 0 14 | 15 | func initOptions() {} 16 | 17 | func archInit() {} 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_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 | package cpu 6 | 7 | func archInit() { 8 | doinit() 9 | Initialized = true 10 | } 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/cpu_zos_s390x.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 | package cpu 6 | 7 | func initS390Xbase() { 8 | // get the facilities list 9 | facilities := stfle() 10 | 11 | // mandatory 12 | S390X.HasZARCH = facilities.Has(zarch) 13 | S390X.HasSTFLE = facilities.Has(stflef) 14 | S390X.HasLDISP = facilities.Has(ldisp) 15 | S390X.HasEIMM = facilities.Has(eimm) 16 | 17 | // optional 18 | S390X.HasETF3EH = facilities.Has(etf3eh) 19 | S390X.HasDFP = facilities.Has(dfp) 20 | S390X.HasMSA = facilities.Has(msa) 21 | S390X.HasVX = facilities.Has(vx) 22 | if S390X.HasVX { 23 | S390X.HasVXE = facilities.Has(vxe) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | 7 | package cpu 8 | 9 | // IsBigEndian records whether the GOARCH's byte order is big endian. 10 | const IsBigEndian = true 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 || wasm 6 | 7 | package cpu 8 | 9 | // IsBigEndian records whether the GOARCH's byte order is big endian. 10 | const IsBigEndian = false 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/hwcap_linux.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 cpu 6 | 7 | import ( 8 | "os" 9 | ) 10 | 11 | const ( 12 | _AT_HWCAP = 16 13 | _AT_HWCAP2 = 26 14 | 15 | procAuxv = "/proc/self/auxv" 16 | 17 | uintSize = int(32 << (^uint(0) >> 63)) 18 | ) 19 | 20 | // For those platforms don't have a 'cpuid' equivalent we use HWCAP/HWCAP2 21 | // These are initialized in cpu_$GOARCH.go 22 | // and should not be changed after they are initialized. 23 | var hwCap uint 24 | var hwCap2 uint 25 | 26 | func readHWCAP() error { 27 | // For Go 1.21+, get auxv from the Go runtime. 28 | if a := getAuxv(); len(a) > 0 { 29 | for len(a) >= 2 { 30 | tag, val := a[0], uint(a[1]) 31 | a = a[2:] 32 | switch tag { 33 | case _AT_HWCAP: 34 | hwCap = val 35 | case _AT_HWCAP2: 36 | hwCap2 = val 37 | } 38 | } 39 | return nil 40 | } 41 | 42 | buf, err := os.ReadFile(procAuxv) 43 | if err != nil { 44 | // e.g. on android /proc/self/auxv is not accessible, so silently 45 | // ignore the error and leave Initialized = false. On some 46 | // architectures (e.g. arm64) doinit() implements a fallback 47 | // readout and will set Initialized = true again. 48 | return err 49 | } 50 | bo := hostByteOrder() 51 | for len(buf) >= 2*(uintSize/8) { 52 | var tag, val uint 53 | switch uintSize { 54 | case 32: 55 | tag = uint(bo.Uint32(buf[0:])) 56 | val = uint(bo.Uint32(buf[4:])) 57 | buf = buf[8:] 58 | case 64: 59 | tag = uint(bo.Uint64(buf[0:])) 60 | val = uint(bo.Uint64(buf[8:])) 61 | buf = buf[16:] 62 | } 63 | switch tag { 64 | case _AT_HWCAP: 65 | hwCap = val 66 | case _AT_HWCAP2: 67 | hwCap2 = val 68 | } 69 | } 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/parse.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 | package cpu 6 | 7 | import "strconv" 8 | 9 | // parseRelease parses a dot-separated version number. It follows the semver 10 | // syntax, but allows the minor and patch versions to be elided. 11 | // 12 | // This is a copy of the Go runtime's parseRelease from 13 | // https://golang.org/cl/209597. 14 | func parseRelease(rel string) (major, minor, patch int, ok bool) { 15 | // Strip anything after a dash or plus. 16 | for i := 0; i < len(rel); i++ { 17 | if rel[i] == '-' || rel[i] == '+' { 18 | rel = rel[:i] 19 | break 20 | } 21 | } 22 | 23 | next := func() (int, bool) { 24 | for i := 0; i < len(rel); i++ { 25 | if rel[i] == '.' { 26 | ver, err := strconv.Atoi(rel[:i]) 27 | rel = rel[i+1:] 28 | return ver, err == nil 29 | } 30 | } 31 | ver, err := strconv.Atoi(rel) 32 | rel = "" 33 | return ver, err == nil 34 | } 35 | if major, ok = next(); !ok || rel == "" { 36 | return 37 | } 38 | if minor, ok = next(); !ok || rel == "" { 39 | return 40 | } 41 | patch, ok = next() 42 | return 43 | } 44 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/proc_cpuinfo_linux.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 && arm64 6 | 7 | package cpu 8 | 9 | import ( 10 | "errors" 11 | "io" 12 | "os" 13 | "strings" 14 | ) 15 | 16 | func readLinuxProcCPUInfo() error { 17 | f, err := os.Open("/proc/cpuinfo") 18 | if err != nil { 19 | return err 20 | } 21 | defer f.Close() 22 | 23 | var buf [1 << 10]byte // enough for first CPU 24 | n, err := io.ReadFull(f, buf[:]) 25 | if err != nil && err != io.ErrUnexpectedEOF { 26 | return err 27 | } 28 | in := string(buf[:n]) 29 | const features = "\nFeatures : " 30 | i := strings.Index(in, features) 31 | if i == -1 { 32 | return errors.New("no CPU features found") 33 | } 34 | in = in[i+len(features):] 35 | if i := strings.Index(in, "\n"); i != -1 { 36 | in = in[:i] 37 | } 38 | m := map[string]*bool{} 39 | 40 | initOptions() // need it early here; it's harmless to call twice 41 | for _, o := range options { 42 | m[o.Name] = o.Feature 43 | } 44 | // The EVTSTRM field has alias "evstrm" in Go, but Linux calls it "evtstrm". 45 | m["evtstrm"] = &ARM64.HasEVTSTRM 46 | 47 | for _, f := range strings.Fields(in) { 48 | if p, ok := m[f]; ok { 49 | *p = true 50 | } 51 | } 52 | return nil 53 | } 54 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/runtime_auxv.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 cpu 6 | 7 | // getAuxvFn is non-nil on Go 1.21+ (via runtime_auxv_go121.go init) 8 | // on platforms that use auxv. 9 | var getAuxvFn func() []uintptr 10 | 11 | func getAuxv() []uintptr { 12 | if getAuxvFn == nil { 13 | return nil 14 | } 15 | return getAuxvFn() 16 | } 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/runtime_auxv_go121.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 go1.21 6 | 7 | package cpu 8 | 9 | import ( 10 | _ "unsafe" // for linkname 11 | ) 12 | 13 | //go:linkname runtime_getAuxv runtime.getAuxv 14 | func runtime_getAuxv() []uintptr 15 | 16 | func init() { 17 | getAuxvFn = runtime_getAuxv 18 | } 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/syscall_aix_gccgo.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 | // Recreate a getsystemcfg syscall handler instead of 6 | // using the one provided by x/sys/unix to avoid having 7 | // the dependency between them. (See golang.org/issue/32102) 8 | // Moreover, this file will be used during the building of 9 | // gccgo's libgo and thus must not used a CGo method. 10 | 11 | //go:build aix && gccgo 12 | 13 | package cpu 14 | 15 | import ( 16 | "syscall" 17 | ) 18 | 19 | //extern getsystemcfg 20 | func gccgoGetsystemcfg(label uint32) (r uint64) 21 | 22 | func callgetsystemcfg(label int) (r1 uintptr, e1 syscall.Errno) { 23 | r1 = uintptr(gccgoGetsystemcfg(uint32(label))) 24 | e1 = syscall.GetErrno() 25 | return 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.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 | // Minimal copy of x/sys/unix so the cpu package can make a 6 | // system call on AIX without depending on x/sys/unix. 7 | // (See golang.org/issue/32102) 8 | 9 | //go:build aix && ppc64 && gc 10 | 11 | package cpu 12 | 13 | import ( 14 | "syscall" 15 | "unsafe" 16 | ) 17 | 18 | //go:cgo_import_dynamic libc_getsystemcfg getsystemcfg "libc.a/shr_64.o" 19 | 20 | //go:linkname libc_getsystemcfg libc_getsystemcfg 21 | 22 | type syscallFunc uintptr 23 | 24 | var libc_getsystemcfg syscallFunc 25 | 26 | type errno = syscall.Errno 27 | 28 | // Implemented in runtime/syscall_aix.go. 29 | func rawSyscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err errno) 30 | func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err errno) 31 | 32 | func callgetsystemcfg(label int) (r1 uintptr, e1 errno) { 33 | r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_getsystemcfg)), 1, uintptr(label), 0, 0, 0, 0, 0) 34 | return 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/cpu/syscall_darwin_x86_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 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 | // Minimal copy of x/sys/unix so the cpu package can make a 6 | // system call on Darwin without depending on x/sys/unix. 7 | 8 | //go:build darwin && amd64 && gc 9 | 10 | package cpu 11 | 12 | import ( 13 | "syscall" 14 | "unsafe" 15 | ) 16 | 17 | type _C_int int32 18 | 19 | // adapted from unix.Uname() at x/sys/unix/syscall_darwin.go L419 20 | func darwinOSRelease(release *[256]byte) error { 21 | // from x/sys/unix/zerrors_openbsd_amd64.go 22 | const ( 23 | CTL_KERN = 0x1 24 | KERN_OSRELEASE = 0x2 25 | ) 26 | 27 | mib := []_C_int{CTL_KERN, KERN_OSRELEASE} 28 | n := unsafe.Sizeof(*release) 29 | 30 | return sysctl(mib, &release[0], &n, nil, 0) 31 | } 32 | 33 | type Errno = syscall.Errno 34 | 35 | var _zero uintptr // Single-word zero for use when we need a valid pointer to 0 bytes. 36 | 37 | // from x/sys/unix/zsyscall_darwin_amd64.go L791-807 38 | func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error { 39 | var _p0 unsafe.Pointer 40 | if len(mib) > 0 { 41 | _p0 = unsafe.Pointer(&mib[0]) 42 | } else { 43 | _p0 = unsafe.Pointer(&_zero) 44 | } 45 | if _, _, err := syscall_syscall6( 46 | libc_sysctl_trampoline_addr, 47 | uintptr(_p0), 48 | uintptr(len(mib)), 49 | uintptr(unsafe.Pointer(old)), 50 | uintptr(unsafe.Pointer(oldlen)), 51 | uintptr(unsafe.Pointer(new)), 52 | uintptr(newlen), 53 | ); err != 0 { 54 | return err 55 | } 56 | 57 | return nil 58 | } 59 | 60 | var libc_sysctl_trampoline_addr uintptr 61 | 62 | // adapted from internal/cpu/cpu_arm64_darwin.go 63 | func darwinSysctlEnabled(name []byte) bool { 64 | out := int32(0) 65 | nout := unsafe.Sizeof(out) 66 | if ret := sysctlbyname(&name[0], (*byte)(unsafe.Pointer(&out)), &nout, nil, 0); ret != nil { 67 | return false 68 | } 69 | return out > 0 70 | } 71 | 72 | //go:cgo_import_dynamic libc_sysctl sysctl "/usr/lib/libSystem.B.dylib" 73 | 74 | var libc_sysctlbyname_trampoline_addr uintptr 75 | 76 | // adapted from runtime/sys_darwin.go in the pattern of sysctl() above, as defined in x/sys/unix 77 | func sysctlbyname(name *byte, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error { 78 | if _, _, err := syscall_syscall6( 79 | libc_sysctlbyname_trampoline_addr, 80 | uintptr(unsafe.Pointer(name)), 81 | uintptr(unsafe.Pointer(old)), 82 | uintptr(unsafe.Pointer(oldlen)), 83 | uintptr(unsafe.Pointer(new)), 84 | uintptr(newlen), 85 | 0, 86 | ); err != 0 { 87 | return err 88 | } 89 | 90 | return nil 91 | } 92 | 93 | //go:cgo_import_dynamic libc_sysctlbyname sysctlbyname "/usr/lib/libSystem.B.dylib" 94 | 95 | // Implemented in the runtime package (runtime/sys_darwin.go) 96 | func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) 97 | 98 | //go:linkname syscall_syscall6 syscall.syscall6 99 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/gogo/protobuf v1.3.2 2 | ## explicit; go 1.15 3 | github.com/gogo/protobuf/gogoproto 4 | github.com/gogo/protobuf/proto 5 | github.com/gogo/protobuf/protoc-gen-gogo/descriptor 6 | # github.com/klauspost/compress v1.17.11 7 | ## explicit; go 1.21 8 | github.com/klauspost/compress/flate 9 | # github.com/nats-io/nats-server/v2 v2.10.22 10 | ## explicit; go 1.21.0 11 | # github.com/nats-io/nats-streaming-server v0.25.6 12 | ## explicit; go 1.20 13 | # github.com/nats-io/nats.go v1.37.0 14 | ## explicit; go 1.20 15 | github.com/nats-io/nats.go 16 | github.com/nats-io/nats.go/encoders/builtin 17 | github.com/nats-io/nats.go/internal/parser 18 | github.com/nats-io/nats.go/util 19 | # github.com/nats-io/nkeys v0.4.8 20 | ## explicit; go 1.20 21 | github.com/nats-io/nkeys 22 | # github.com/nats-io/nuid v1.0.1 23 | ## explicit 24 | github.com/nats-io/nuid 25 | # github.com/nats-io/stan.go v0.10.4 26 | ## explicit; go 1.14 27 | github.com/nats-io/stan.go 28 | github.com/nats-io/stan.go/pb 29 | # github.com/openfaas/faas-provider v0.25.4 30 | ## explicit; go 1.20 31 | github.com/openfaas/faas-provider/types 32 | # golang.org/x/crypto v0.35.0 33 | ## explicit; go 1.23.0 34 | golang.org/x/crypto/blake2b 35 | golang.org/x/crypto/curve25519 36 | golang.org/x/crypto/internal/alias 37 | golang.org/x/crypto/internal/poly1305 38 | golang.org/x/crypto/nacl/box 39 | golang.org/x/crypto/nacl/secretbox 40 | golang.org/x/crypto/salsa20/salsa 41 | # golang.org/x/sys v0.30.0 42 | ## explicit; go 1.18 43 | golang.org/x/sys/cpu 44 | -------------------------------------------------------------------------------- /version/version.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | var ( 4 | // Version release version of the provider 5 | Version string 6 | 7 | // GitCommit SHA of the last git commit 8 | GitCommit string 9 | 10 | // DevVersion string for the development version 11 | DevVersion = "dev" 12 | ) 13 | 14 | // BuildVersion returns current version of the provider 15 | func BuildVersion() string { 16 | if len(Version) == 0 { 17 | return DevVersion 18 | } 19 | return Version 20 | } 21 | 22 | // GetReleaseInfo includes the SHA and the release version 23 | func GetReleaseInfo() (sha, release string) { 24 | return GitCommit, BuildVersion() 25 | } 26 | --------------------------------------------------------------------------------