refractium 3.0.12

Extensible low-level reverse proxy for port multiplexing and protocol-based routing
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
name: Refinery Build
"on":
  push:
    tags:
      - v*
  release:
    types:
      - created
jobs:
  build:
    name: ${{ matrix.artifact }} (${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.abi || 'default' }})
    runs-on: ${{ matrix.runs_on }}
    permissions:
      contents: read
    env: {}
    strategy:
      fail-fast: false
      matrix:
        include:
          - artifact: refractium
            artifact_type: bin
            os: linux
            arch: x86_64
            runs_on: ubuntu-24.04
            output_name: refractium-linux-x86_64
            artifact_bin: refractium
            target_triple: x86_64-unknown-linux-gnu
            package_type: tar.gz
            packages:
              - bin
            has_deb: false
            has_rpm: false
            has_msi: false
            has_archive: false
            has_bin: true
            include_files: []
            apt_packages: []
            bin_ext: ""
            headers: false
            linker_env: []
            features: []
            features_str: ""
            default_features: true
            abi: gnu
          - artifact: refractium
            artifact_type: bin
            os: linux
            arch: arm64
            runs_on: ubuntu-24.04-arm
            output_name: refractium-linux-arm64
            artifact_bin: refractium
            target_triple: aarch64-unknown-linux-gnu
            package_type: tar.gz
            packages:
              - bin
            has_deb: false
            has_rpm: false
            has_msi: false
            has_archive: false
            has_bin: true
            include_files: []
            apt_packages:
              - gcc-aarch64-linux-gnu
            bin_ext: ""
            headers: false
            linker: aarch64-linux-gnu-gcc
            linker_env:
              - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
            features: []
            features_str: ""
            default_features: true
            abi: gnu
          - artifact: refractium
            artifact_type: bin
            os: windows
            arch: x86_64
            runs_on: windows-2025
            output_name: refractium-windows-x86_64
            artifact_bin: refractium
            target_triple: x86_64-pc-windows-msvc
            package_type: zip
            packages:
              - bin
            has_deb: false
            has_rpm: false
            has_msi: false
            has_archive: false
            has_bin: true
            include_files: []
            apt_packages: []
            bin_ext: .exe
            headers: false
            linker_env: []
            features: []
            features_str: ""
            default_features: true
            abi: msvc
          - artifact: refractium
            artifact_type: bin
            os: windows
            arch: arm64
            runs_on: windows-11-arm
            output_name: refractium-windows-arm64
            artifact_bin: refractium
            target_triple: aarch64-pc-windows-msvc
            package_type: zip
            packages:
              - bin
            has_deb: false
            has_rpm: false
            has_msi: false
            has_archive: false
            has_bin: true
            include_files: []
            apt_packages: []
            bin_ext: .exe
            headers: false
            linker_env: []
            features: []
            features_str: ""
            default_features: true
            abi: msvc
          - artifact: refractium
            artifact_type: bin
            os: macos
            arch: x86_64
            runs_on: macos-26
            output_name: refractium-macos-x86_64
            artifact_bin: refractium
            target_triple: x86_64-apple-darwin
            package_type: tar.gz
            packages:
              - bin
            has_deb: false
            has_rpm: false
            has_msi: false
            has_archive: false
            has_bin: true
            include_files: []
            apt_packages: []
            bin_ext: ""
            headers: false
            linker_env: []
            features: []
            features_str: ""
            default_features: true
          - artifact: refractium
            artifact_type: bin
            os: macos
            arch: arm64
            runs_on: macos-26
            output_name: refractium-macos-arm64
            artifact_bin: refractium
            target_triple: aarch64-apple-darwin
            package_type: tar.gz
            packages:
              - bin
            has_deb: false
            has_rpm: false
            has_msi: false
            has_archive: false
            has_bin: true
            include_files: []
            apt_packages: []
            bin_ext: ""
            headers: false
            linker_env: []
            features: []
            features_str: ""
            default_features: true
    steps:
      - name: Checkout
        uses: actions/checkout@v6
      - name: Setup Rust
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          target: ${{ matrix.target_triple }}
          cache: true
          toolchain: stable
      - name: Install cbindgen
        uses: taiki-e/install-action@v2
        if: matrix.headers == true
        with:
          tool: cbindgen
      - name: Configure Linker and System Dependencies
        if: join(matrix.apt_packages, '') != '' || join(matrix.linker_env, '') != ''
        run: |-
          PKGS="${{ join(matrix.apt_packages, ' ') }}"
          if [ -n "$PKGS" ] && [ "${{ runner.os }}" = "Linux" ]; then
            sudo apt-get update && sudo apt-get install --no-install-recommends -y $PKGS
          fi

          for env_var in "${{ join(matrix.linker_env, '" "') }}"; do
            if [ -n "$env_var" ]; then
              echo "$env_var" >> "$GITHUB_ENV"
            fi
          done
        shell: bash
      - name: Install System Dependencies (Windows) [WiX]
        if: runner.os == 'Windows' && matrix.has_msi
        run: >-
          choco install wixtoolset -y

          $wixDir = Get-ChildItem "${env:ProgramFiles}\WiX*", "C:\Program Files (x86)\WiX*" -Directory -ErrorAction
          SilentlyContinue | Sort-Object Name -Descending | Select-Object -First 1

          if ($wixDir -and (Test-Path "$($wixDir.FullName)\bin\candle.exe")) {
            Add-Content $env:GITHUB_PATH "$($wixDir.FullName)\bin"
          }
        shell: powershell
      - name: Set up MinGW (x86_64)
        if: runner.os == 'Windows' && matrix.abi == 'gnu' && matrix.arch == 'x86_64'
        uses: egor-tensin/setup-mingw@v3
        with:
          platform: x64
      - name: Set up MinGW (i686)
        if: runner.os == 'Windows' && matrix.abi == 'gnu' && matrix.arch == 'x86'
        uses: egor-tensin/setup-mingw@v3
        with:
          platform: x86
      - name: Build
        run: |-
          CMD="cargo build --release"
          CMD="$CMD --target ${{ matrix.target_triple }}"
          FEATURES="${{ matrix.features_str }}"
          if [ -n "$FEATURES" ]; then
            CMD="$CMD --features \"$FEATURES\""
          fi
          NO_DEFAULT="${{ matrix.default_features }}"
          if [ "$NO_DEFAULT" = "false" ]; then
            CMD="$CMD --no-default-features"
          fi
          eval "$CMD"
        shell: bash
      - name: Prepare Binary
        run: |-
          SRC="target/${{ matrix.target_triple }}/release/${{ matrix.artifact_bin }}${{ matrix.bin_ext }}"
          DST_ORIG="target/release/${{ matrix.artifact_bin }}${{ matrix.bin_ext }}"
          DST_RENAMED="target/release/${{ matrix.output_name }}${{ matrix.bin_ext }}"

          mkdir -p target/release
          cp "$SRC" "$DST_ORIG"
          cp "$SRC" "$DST_RENAMED"
        shell: bash
        if: matrix.artifact_type == 'bin'
      - name: Prepare Library
        run: |-
          SRCDIR="target/${{ matrix.target_triple }}/release"
          DSTDIR="target/release"
          mkdir -p "$DSTDIR"

          copy_lib() {
            local src_file="$1"
            local dst_orig_file="$2"
            local dst_renamed_file="$3"
            if [ -f "$src_file" ]; then
              cp "$src_file" "$DSTDIR/$dst_orig_file"
              cp "$src_file" "$DSTDIR/$dst_renamed_file"
            fi
          }

          NAME="${{ matrix.artifact_bin }}"
          OUT="${{ matrix.output_name }}"

          copy_lib "$SRCDIR/lib${NAME}.so" "lib${NAME}.so" "${OUT}.so"
          copy_lib "$SRCDIR/lib${NAME}.dylib" "lib${NAME}.dylib" "${OUT}.dylib"
          copy_lib "$SRCDIR/lib${NAME}.a" "lib${NAME}.a" "${OUT}.a"
          copy_lib "$SRCDIR/${NAME}.dll" "${NAME}.dll" "${OUT}.dll"
          copy_lib "$SRCDIR/${NAME}.lib" "${NAME}.lib" "${OUT}.lib"
          copy_lib "$SRCDIR/lib${NAME}.dll.a" "lib${NAME}.dll.a" "${OUT}.dll.a"
          copy_lib "$SRCDIR/${NAME}.wasm" "${NAME}.wasm" "${OUT}.wasm"

          if [ "${{ matrix.headers }}" = "true" ]; then
            if [ -f "cbindgen.toml" ]; then
              cbindgen --config cbindgen.toml --crate "${NAME}" --output "$DSTDIR/${OUT}.h"
            else
              cbindgen --crate "${NAME}" --output "$DSTDIR/${OUT}.h"
            fi
          fi
        shell: bash
        if: matrix.artifact_type == 'lib'
      - name: Copy Extra Files
        run: |-
          for f in ${{ join(matrix.include_files, ' ') }}; do
            if [ -f "$f" ]; then
              cp "$f" "target/release/"
            fi
          done
        shell: bash
      - name: Export Binary
        run: |-
          mkdir -p _packages
          cp "target/release/${{ matrix.output_name }}${{ matrix.bin_ext }}" "_packages/"
        shell: bash
        if: matrix.artifact_type == 'bin'
      - name: Export Library
        run: |-
          mkdir -p _packages
          cp target/release/${{ matrix.output_name }}.* _packages/ 2>/dev/null || true
        shell: bash
        if: matrix.artifact_type == 'lib' && (matrix.has_bin || !matrix.has_archive)
      - name: Package Binary
        run: |-
          ARCHIVE_DIR="${PWD}/_packages"
          mkdir -p "$ARCHIVE_DIR"
          STAGING_DIR="target/archive_staging/${{ matrix.output_name }}"
          mkdir -p "$STAGING_DIR"
          cp "target/release/${{ matrix.output_name }}${{ matrix.bin_ext }}" "$STAGING_DIR/"
          for f in ${{ join(matrix.include_files, ' ') }}; do
            if [ -f "$f" ]; then
              cp "$f" "$STAGING_DIR/"
            fi
          done
          if [ "${{ matrix.os }}" = "windows" ]; then
            (cd "$STAGING_DIR" && 7z a -tzip "$ARCHIVE_DIR/${{ matrix.output_name }}.zip" .) > /dev/null
          else
            tar -czf "$ARCHIVE_DIR/${{ matrix.output_name }}.tar.gz" -C "$STAGING_DIR" .
          fi
        shell: bash
        if: matrix.artifact_type == 'bin' && matrix.has_archive
      - name: Package Library
        run: |-
          ARCHIVE_DIR="${PWD}/_packages"
          mkdir -p "$ARCHIVE_DIR"
          STAGING_DIR="target/archive_staging/${{ matrix.output_name }}"
          mkdir -p "$STAGING_DIR"
          cp target/release/lib${{ matrix.artifact_bin }}.* "$STAGING_DIR/" 2>/dev/null || true
          cp target/release/${{ matrix.artifact_bin }}.* "$STAGING_DIR/" 2>/dev/null || true
          cp target/release/${{ matrix.output_name }}.* "$STAGING_DIR/" 2>/dev/null || true
          for f in ${{ join(matrix.include_files, ' ') }}; do
            if [ -f "$f" ]; then
              cp "$f" "$STAGING_DIR/"
            fi
          done
          if [ "${{ matrix.os }}" = "windows" ]; then
            (cd "$STAGING_DIR" && 7z a -tzip "$ARCHIVE_DIR/${{ matrix.output_name }}.zip" .) > /dev/null
          else
            tar -czf "$ARCHIVE_DIR/${{ matrix.output_name }}.tar.gz" -C "$STAGING_DIR" .
          fi
        shell: bash
        if: matrix.artifact_type == 'lib' && matrix.has_archive
      - name: Install cargo-deb
        uses: taiki-e/install-action@v2
        if: ${{ matrix.has_deb }}
        with:
          tool: cargo-deb
      - name: Build .deb package
        run: |-
          mkdir -p _packages
          cargo deb --target ${{ matrix.target_triple }} --no-build -o _packages/
          for f in _packages/*.deb; do
            [ -f "$f" ] && mv "$f" "_packages/${{ matrix.output_name }}.deb"
          done
        shell: bash
        if: ${{ matrix.has_deb }}
      - name: Install cargo-generate-rpm
        uses: taiki-e/install-action@v2
        if: ${{ matrix.has_rpm }}
        with:
          tool: cargo-generate-rpm
      - name: Build .rpm package
        run: |-
          mkdir -p _packages
          cargo generate-rpm -o _packages/
          for f in _packages/*.rpm; do
            [ -f "$f" ] && mv "$f" "_packages/${{ matrix.output_name }}.rpm"
          done
        shell: bash
        if: ${{ matrix.has_rpm }}
      - name: Install cargo-wix
        uses: taiki-e/install-action@v2
        if: ${{ matrix.has_msi }}
        with:
          tool: cargo-wix
      - name: Build .msi package
        run: |-
          if (!(Test-Path _packages)) { New-Item -ItemType Directory -Path _packages }
          cargo wix --target ${{ matrix.target_triple }} -o _packages/
          $msi = Get-ChildItem "_packages\*.msi" | Select-Object -First 1
          if ($msi) { Rename-Item -Path $msi.FullName -NewName "${{ matrix.output_name }}.msi" }
        shell: pwsh
        if: ${{ matrix.has_msi }}
      - name: Upload Artifact
        uses: actions/upload-artifact@v7
        with:
          name: ${{ matrix.output_name }}
          path: _packages/
  release:
    name: Release Artifacts
    needs:
      - build
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    permissions:
      contents: write
      packages: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
      - name: Build and push Docker image
        uses: ./.github/actions/docker-publish
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Publish to crates.io
        uses: ./.github/actions/publish-crates-io
        env:
          CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
      - name: Download Artifacts
        uses: actions/download-artifact@v8
        with:
          merge-multiple: true
          path: ./artifacts
      - name: Display structure
        run: find ./artifacts -type f | sort
        shell: bash
      - name: Publish Release
        uses: softprops/action-gh-release@v3
        with:
          fail_on_unmatched_files: true
          files: ./artifacts/*
          generate_release_notes: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}