From 7b5926d8656629656e67ec1b238d1c65d9bf675a Mon Sep 17 00:00:00 2001 From: = Date: Wed, 5 Mar 2025 02:14:00 +0530 Subject: [PATCH] feat: quick fix for quic --- .../check-api-for-breaking-changes.yml | 12 ++--- Dockerfile.standalone-infisical | 1 + backend/Dockerfile | 53 +++++++++---------- cli/packages/gateway/relay.go | 15 +----- .../gateway/udp_listener/listener_unix.go | 26 +++++++++ .../gateway/udp_listener/listener_windows.go | 18 +++++++ 6 files changed, 79 insertions(+), 46 deletions(-) create mode 100644 cli/packages/gateway/udp_listener/listener_unix.go create mode 100644 cli/packages/gateway/udp_listener/listener_windows.go diff --git a/.github/workflows/check-api-for-breaking-changes.yml b/.github/workflows/check-api-for-breaking-changes.yml index c4cb6e451..f0dcfc8cb 100644 --- a/.github/workflows/check-api-for-breaking-changes.yml +++ b/.github/workflows/check-api-for-breaking-changes.yml @@ -32,10 +32,10 @@ jobs: run: touch .env && docker compose -f docker-compose.dev.yml up -d db redis - name: Start the server run: | - echo "SECRET_SCANNING_GIT_APP_ID=793712" >> .env - echo "SECRET_SCANNING_PRIVATE_KEY=some-random" >> .env - echo "SECRET_SCANNING_WEBHOOK_SECRET=some-random" >> .env - docker run --name infisical-api -d -p 4000:4000 -e DB_CONNECTION_URI=$DB_CONNECTION_URI -e REDIS_URL=$REDIS_URL -e JWT_AUTH_SECRET=$JWT_AUTH_SECRET -e ENCRYPTION_KEY=$ENCRYPTION_KEY --env-file .env --entrypoint '/bin/sh' infisical-api -c "npm run migration:latest && ls && node dist/main.mjs" + echo "SECRET_SCANNING_GIT_APP_ID=793712" >> .env + echo "SECRET_SCANNING_PRIVATE_KEY=some-random" >> .env + echo "SECRET_SCANNING_WEBHOOK_SECRET=some-random" >> .env + docker run --name infisical-api -d -p 4000:4000 -e DB_CONNECTION_URI=$DB_CONNECTION_URI -e REDIS_URL=$REDIS_URL -e JWT_AUTH_SECRET=$JWT_AUTH_SECRET -e ENCRYPTION_KEY=$ENCRYPTION_KEY --env-file .env --entrypoint '/bin/sh' infisical-api env: REDIS_URL: redis://172.17.0.1:6379 DB_CONNECTION_URI: postgres://infisical:infisical@172.17.0.1:5432/infisical?sslmode=disable @@ -43,7 +43,7 @@ jobs: ENCRYPTION_KEY: 4bnfe4e407b8921c104518903515b218 - uses: actions/setup-go@v5 with: - go-version: '1.21.5' + go-version: "1.21.5" - name: Wait for container to be stable and check logs run: | SECONDS=0 @@ -61,7 +61,7 @@ jobs: sleep 2 SECONDS=$((SECONDS+2)) done - + if [ $HEALTHY -ne 1 ]; then echo "Container did not become healthy in time" exit 1 diff --git a/Dockerfile.standalone-infisical b/Dockerfile.standalone-infisical index 7da4a6caf..6d582ce76 100644 --- a/Dockerfile.standalone-infisical +++ b/Dockerfile.standalone-infisical @@ -122,6 +122,7 @@ RUN apt-get update && apt-get install -y \ unixodbc-dev \ libc-dev \ freetds-dev \ + wget \ openssh-client \ && rm -rf /var/lib/apt/lists/* diff --git a/backend/Dockerfile b/backend/Dockerfile index 5db874e75..0edfdfb84 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,23 +1,22 @@ # Build stage -FROM node:20-alpine AS build +FROM node:20-slim AS build WORKDIR /app # Required for pkcs11js -RUN apk --update add \ - python3 \ - make \ - g++ \ - openssh +RUN apt-get update && apt-get install -y \ + python3 \ + make \ + g++ \ + openssh-client -# install dependencies for TDS driver (required for SAP ASE dynamic secrets) -RUN apk add --no-cache \ +# Install dependencies for TDS driver (required for SAP ASE dynamic secrets) +RUN apt-get install -y \ unixodbc \ - freetds \ + freetds-bin \ + freetds-dev \ unixodbc-dev \ - libc-dev \ - freetds-dev - + libc-dev COPY package*.json ./ RUN npm ci --only-production @@ -26,36 +25,36 @@ COPY . . RUN npm run build # Production stage -FROM node:20-alpine +FROM node:20-slim WORKDIR /app ENV npm_config_cache /home/node/.npm COPY package*.json ./ -RUN apk --update add \ - python3 \ - make \ - g++ +RUN apt-get update && apt-get install -y \ + python3 \ + make \ + g++ -# install dependencies for TDS driver (required for SAP ASE dynamic secrets) -RUN apk add --no-cache \ +# Install dependencies for TDS driver (required for SAP ASE dynamic secrets) +RUN apt-get install -y \ unixodbc \ - freetds \ + freetds-bin \ + freetds-dev \ unixodbc-dev \ - libc-dev \ - freetds-dev + libc-dev - -RUN printf "[FreeTDS]\nDescription = FreeTDS Driver\nDriver = /usr/lib/libtdsodbc.so\nSetup = /usr/lib/libtdsodbc.so\nFileUsage = 1\n" > /etc/odbcinst.ini +RUN printf "[FreeTDS]\nDescription = FreeTDS Driver\nDriver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so\nSetup = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so\nFileUsage = 1\n" > /etc/odbcinst.ini RUN npm ci --only-production && npm cache clean --force COPY --from=build /app . -RUN apk add --no-cache bash curl && curl -1sLf \ - 'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.alpine.sh' | bash \ - && apk add infisical=0.8.1 && apk add --no-cache git +# Install Infisical CLI +RUN apt-get install -y curl bash && \ + curl -1sLf 'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.deb.sh' | bash && \ + apt-get update && apt-get install -y infisical=0.8.1 git HEALTHCHECK --interval=10s --timeout=3s --start-period=10s \ CMD node healthcheck.js diff --git a/cli/packages/gateway/relay.go b/cli/packages/gateway/relay.go index e9ad9b3b6..52636d2d3 100644 --- a/cli/packages/gateway/relay.go +++ b/cli/packages/gateway/relay.go @@ -12,10 +12,10 @@ import ( "strconv" "syscall" + udplistener "github.com/Infisical/infisical-merge/packages/gateway/udp_listener" "github.com/pion/logging" "github.com/pion/turn/v4" "github.com/rs/zerolog/log" - "golang.org/x/sys/unix" "gopkg.in/yaml.v2" ) @@ -115,18 +115,7 @@ func (g *GatewayRelay) Run() error { // this allows us to add logging, storage or modify inbound/outbound traffic // UDP listeners share the same local address:port with setting SO_REUSEPORT and the kernel // will load-balance received packets per the IP 5-tuple - listenerConfig := &net.ListenConfig{ - Control: func(network, address string, conn syscall.RawConn) error { // nolint: revive - var operr error - if err = conn.Control(func(fd uintptr) { - operr = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1) - }); err != nil { - return err - } - - return operr - }, - } + listenerConfig := udplistener.SetupListenerConfig() publicIP := g.Config.PublicIP relayAddressGenerator := &turn.RelayAddressGeneratorPortRange{ diff --git a/cli/packages/gateway/udp_listener/listener_unix.go b/cli/packages/gateway/udp_listener/listener_unix.go new file mode 100644 index 000000000..8de2828b4 --- /dev/null +++ b/cli/packages/gateway/udp_listener/listener_unix.go @@ -0,0 +1,26 @@ +//go:build !windows +// +build !windows + +package udplistener + +import ( + "net" + "syscall" + + "golang.org/x/sys/unix" + // other imports +) + +func SetupListenerConfig() *net.ListenConfig { + return &net.ListenConfig{ + Control: func(network, address string, conn syscall.RawConn) error { + var operr error + if err := conn.Control(func(fd uintptr) { + operr = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, unix.SO_REUSEPORT, 1) + }); err != nil { + return err + } + return operr + }, + } +} diff --git a/cli/packages/gateway/udp_listener/listener_windows.go b/cli/packages/gateway/udp_listener/listener_windows.go new file mode 100644 index 000000000..4904d12e0 --- /dev/null +++ b/cli/packages/gateway/udp_listener/listener_windows.go @@ -0,0 +1,18 @@ +//go:build windows +// +build windows + +package udplistener + +import ( + "fmt" + "net" + "syscall" +) + +func SetupListenerConfig() *net.ListenConfig { + return &net.ListenConfig{ + Control: func(network, address string, conn syscall.RawConn) error { + return fmt.Errorf("Infisical relay not supported for windows.") + }, + } +}