Skip to content

Commit

Permalink
Merge pull request #81 from marcelGoerentz/development
Browse files Browse the repository at this point in the history
Add the latest feature
  • Loading branch information
marcelGoerentz authored Jan 27, 2025
2 parents 88f7bb7 + 0609fc4 commit 5278883
Show file tree
Hide file tree
Showing 32 changed files with 1,873 additions and 1,694 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
contents: write
outputs:
new_version: ${{ steps.set-build-number.outputs.new_version }}
env:
PRIVATE_KEY: ${{ secrets.SIGNING_KEY }}

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
new_version: ${{ steps.set-build-number.outputs.new_version }}
env:
PRIVATE_KEY: ${{ secrets.SIGNING_KEY }}

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
Expand Down Expand Up @@ -59,6 +63,7 @@ jobs:
- name: Build binaries
run: |
go mod tidy && go mod vendor
echo "$PRIVATE_KEY=${{ secrets.SIGNING_KEY }}" >> $GITHUB_ENV
bash ${GITHUB_WORKSPACE}/Utility/create_binaries.sh beta
- name: Create a Release
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
contents: write
outputs:
new_version: ${{ steps.set-build-number.outputs.new_version }}
env:
PRIVATE_KEY: ${{ secrets.SIGNING_KEY }}

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
Expand Down Expand Up @@ -47,6 +50,7 @@ jobs:
- name: Build binaries
run: |
go mod tidy && go mod vendor
echo "$PRIVATE_KEY=${{ secrets.SIGNING_KEY }}" >> $GITHUB_ENV
bash ${GITHUB_WORKSPACE}/Utility/create_binaries.sh
- name: Create a Release
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ FROM base AS beta
RUN go build -tags beta .

FROM ${BUILD_FLAG} AS builder
ARG BRANCH
RUN echo "Build ${BRANCH} version"
ARG BUILD_FLAG
RUN echo "Build ${BUILD_FLAG} version"

# Second stage. Creating an image
# -----------------------------------------------------------------------------
Expand Down
61 changes: 58 additions & 3 deletions Utility/create_binaries.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,46 @@
#!/bin/bash

set -e

if [ -z "$PRIVATE_KEY" ]; then
echo "PRIVATE_KEY environment variable is not set. Exiting..."
exit 1
fi

function exitOnFailure {
echo "Build failed for ${1}/${2}. Exiting..."
rm threadfin_privkey.pem
exit 1
}

function verifySignature {
# Variables
binary_file="dist/${1}"
signature_file="signature.bin"
original_file="original_binary"
signature_size=256

# Extract the signature (assuming the signature is 256 bytes long)
tail -c $signature_size "$binary_file" > "$signature_file"

# Extract the original binary content
head -c -$signature_size "$binary_file" > "$original_file"

# Verify the signature
if ! openssl dgst -sha256 -verify threadfin_pubkey.pem -signature "$signature_file" "$original_file"; then
echo "Signature verification failed for ${1}. Exiting..."
exit 1
fi

# Clean up
rm "$signature_file" "$original_file"
}

os_list=("darwin" "freebsd" "linux" "windows")
arch_list=("amd64" "arm64")

echo "$PRIVATE_KEY" > threadfin_privkey.pem

for os in "${os_list[@]}"; do
export GOOS=$os
for arch in "${arch_list[@]}"; do
Expand All @@ -12,14 +50,31 @@ for os in "${os_list[@]}"; do
bin_string="${bin_string}_beta"
fi
bin_string="${bin_string}_${os}_${arch}"
sha_string="${bin_string}"
if [ "$os" = "windows" ]; then
bin_string="${bin_string}.exe"
fi
echo "Building ${bin_string}"
if [ "$1" = "beta" ]; then
go build -o "dist/${bin_string}" -tags beta
if ! go build -o "dist/${bin_string}" -tags beta; then
exitOnFailure "$os" "$arch"
fi
else
go build -o "dist/${bin_string}"
if ! go build -o "dist/${bin_string}"; then
exitOnFailure "$os" "$arch"
fi
fi

echo "Signing the binary"
openssl dgst -sha256 -sign threadfin_privkey.pem -out signature.bin "dist/${bin_string}"
cat signature.bin >> "dist/${bin_string}"

echo "Verify signature"
verifySignature "$bin_string"

echo "Calculating sha256 for ${bin_string}"
sha256sum "dist/${bin_string}" > "dist/${sha_string}.sha256"
done
done
done

rm threadfin_privkey.pem
22 changes: 22 additions & 0 deletions src/buffer-interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package src

import "io"

type BufferInterface interface {
StartBuffer(stream *Stream) error
StopBuffer()
CloseBuffer()
HandleByteOutput(stdOut io.ReadCloser)
PrepareBufferFolder(folder string) error
GetBufTmpFiles() []string
GetBufferedSize() int
addBufferedFilesToPipe()
DeleteOldestSegment()
CheckBufferFolder() (bool, error)
CheckBufferedFile(file string) (bool, error)
writeToPipe(file string) error
writeBytesToPipe(data []byte) error
GetPipeReader() *io.PipeReader
GetStopChan() chan struct{}
SetStopChan(chan struct{})
}
Loading

0 comments on commit 5278883

Please sign in to comment.