-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
844 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: Build | ||
|
||
'on': | ||
'push': | ||
'tags': | ||
- 'v*' | ||
'branches': | ||
- '*' | ||
'pull_request': | ||
|
||
jobs: | ||
tests: | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
GO111MODULE: "on" | ||
strategy: | ||
matrix: | ||
os: | ||
- windows-latest | ||
- macos-latest | ||
- ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.x | ||
|
||
- name: Run tests | ||
run: |- | ||
go test -race -v -bench=. -coverprofile=coverage.txt -covermode=atomic ./... | ||
- name: Upload coverage | ||
uses: codecov/codecov-action@v3 | ||
if: "success() && matrix.os == 'ubuntu-latest'" | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: ./coverage.txt | ||
|
||
build: | ||
needs: | ||
- tests | ||
runs-on: ubuntu-latest | ||
env: | ||
GO111MODULE: "on" | ||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.x | ||
|
||
- name: Prepare environment | ||
run: |- | ||
RELEASE_VERSION="${GITHUB_REF##*/}" | ||
if [[ "${RELEASE_VERSION}" != v* ]]; then RELEASE_VERSION='dev'; fi | ||
echo "RELEASE_VERSION=\"${RELEASE_VERSION}\"" >> $GITHUB_ENV | ||
# Win | ||
- run: GOOS=windows GOARCH=386 VERSION=${RELEASE_VERSION} make release | ||
- run: GOOS=windows GOARCH=amd64 VERSION=${RELEASE_VERSION} make release | ||
|
||
# MacOS | ||
- run: GOOS=darwin GOARCH=amd64 VERSION=${RELEASE_VERSION} make release | ||
|
||
# MacOS ARM | ||
- run: GOOS=darwin GOARCH=arm64 VERSION=${RELEASE_VERSION} make release | ||
|
||
# Linux X86 | ||
- run: GOOS=linux GOARCH=386 VERSION=${RELEASE_VERSION} make release | ||
- run: GOOS=linux GOARCH=amd64 VERSION=${RELEASE_VERSION} make release | ||
|
||
# Linux ARM | ||
- run: GOOS=linux GOARCH=arm GOARM=6 VERSION=${RELEASE_VERSION} make release | ||
- run: GOOS=linux GOARCH=arm64 VERSION=${RELEASE_VERSION} make release | ||
|
||
# Linux MIPS/MIPSLE | ||
- run: GOOS=linux GOARCH=mips GOMIPS=softfloat VERSION=${RELEASE_VERSION} make release | ||
- run: GOOS=linux GOARCH=mipsle GOMIPS=softfloat VERSION=${RELEASE_VERSION} make release | ||
|
||
# FreeBSD X86 | ||
- run: GOOS=freebsd GOARCH=386 VERSION=${RELEASE_VERSION} make release | ||
- run: GOOS=freebsd GOARCH=amd64 VERSION=${RELEASE_VERSION} make release | ||
|
||
# FreeBSD ARM/ARM64 | ||
- run: GOOS=freebsd GOARCH=arm GOARM=6 VERSION=${RELEASE_VERSION} make release | ||
- run: GOOS=freebsd GOARCH=arm64 VERSION=${RELEASE_VERSION} make release | ||
|
||
- run: ls -l build/snirelay-* | ||
|
||
- name: Create release | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
id: create_release | ||
uses: softprops/action-gh-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
body: See [CHANGELOG.md](./CHANGELOG.md) for the list of changes. | ||
draft: false | ||
prerelease: false | ||
files: | | ||
build/snirelay-*.tar.gz | ||
build/snirelay-*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
branches: | ||
- 'master' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
platforms: linux/amd64,linux/arm64,linux/386,linux/arm/v7 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: "VERSION=${GITHUB_REF##*/}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: golangci-lint | ||
'on': | ||
'push': | ||
'tags': | ||
- 'v*' | ||
'branches': | ||
- '*' | ||
'pull_request': | ||
|
||
jobs: | ||
golangci: | ||
runs-on: | ||
${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- macos-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: golangci-lint | ||
uses: golangci/[email protected] | ||
with: | ||
# This field is required. Dont set the patch version to always use | ||
# the latest patch version. | ||
version: v1.56.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
/.vscode | ||
/build | ||
/relay | ||
/snirelay | ||
/sni_mapping.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# snirelay changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog][keepachangelog], and this project | ||
adheres to [Semantic Versioning][semver]. | ||
|
||
[keepachangelog]: https://keepachangelog.com/en/1.0.0/ | ||
|
||
[semver]: https://semver.org/spec/v2.0.0.html | ||
|
||
## [Unreleased] | ||
|
||
[unreleased]: https://github.com/ameshkov/snirelay/compare/v1.0.0...HEAD | ||
|
||
## [1.0.0] - 2024-03-25 | ||
|
||
* First version of snirelay. | ||
|
||
[1.0.0]: https://github.com/ameshkov/snirelay/releases/tag/v1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Step 1: Use the official Golang image as the build environment. | ||
# This image includes all the tools needed to compile Go applications. | ||
FROM golang:1.22 as builder | ||
|
||
# Version will be passed as a part of the build. | ||
ARG VERSION=dev | ||
|
||
# Set the Current Working Directory inside the container. | ||
WORKDIR /app | ||
|
||
# Copy the local package files to the container's workspace. | ||
COPY . . | ||
|
||
# Build the Go app for a Linux system. The -o flag specifies the output binary | ||
# name. | ||
RUN VERSION=${VERSION} make build | ||
|
||
# Step 2: Use a builder image to get the latest certificates. | ||
FROM alpine:latest as certs | ||
|
||
# Download the latest CA certificates | ||
RUN apk --update add ca-certificates | ||
|
||
# Step 3: Use a Docker multi-stage build to create a lean production image. | ||
# Start from a scratch (empty) image to keep the image size small. | ||
FROM scratch | ||
|
||
# Copy the binary from the builder stage to the production image. | ||
COPY --from=builder /app/snirelay / | ||
|
||
# Copy the CA certificates from the certs image. | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
|
||
# Expose listen ports. | ||
EXPOSE 8443/tcp | ||
EXPOSE 8080/tcp | ||
|
||
ENTRYPOINT ["/snirelay", "-l", "0.0.0.0", "-p", "8080:8443"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Andrey Meshkov | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
NAME=snirelay | ||
BASE_BUILDDIR=build | ||
BUILDNAME=$(GOOS)-$(GOARCH) | ||
BUILDDIR=$(BASE_BUILDDIR)/$(BUILDNAME) | ||
VERSION?=v0.0-dev | ||
VERSIONPKG=github.com/ameshkov/snirelay/internal/version | ||
|
||
ifeq ($(GOOS),windows) | ||
ext=.exe | ||
archiveCmd=zip -9 -r $(NAME)-$(BUILDNAME)-$(VERSION).zip $(BUILDNAME) | ||
else | ||
ext= | ||
archiveCmd=tar czpvf $(NAME)-$(BUILDNAME)-$(VERSION).tar.gz $(BUILDNAME) | ||
endif | ||
|
||
.PHONY: default | ||
default: build | ||
|
||
build: clean | ||
CGO_ENABLED=0 go build -ldflags "-X $(VERSIONPKG).version=$(VERSION)" -o $(NAME) | ||
|
||
release: check-env-release | ||
mkdir -p $(BUILDDIR) | ||
cp LICENSE $(BUILDDIR)/ | ||
cp README.md $(BUILDDIR)/ | ||
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags "-X $(VERSIONPKG).version=$(VERSION)" -o $(BUILDDIR)/$(NAME)$(ext) | ||
cd $(BASE_BUILDDIR) ; $(archiveCmd) | ||
|
||
test: | ||
go test -race -v -bench=. ./... | ||
|
||
clean: | ||
go clean | ||
rm -rf $(BASE_BUILDDIR) | ||
|
||
check-env-release: | ||
@ if [ "$(GOOS)" = "" ]; then \ | ||
echo "Environment variable GOOS not set"; \ | ||
exit 1; \ | ||
fi | ||
@ if [ "$(GOARCH)" = "" ]; then \ | ||
echo "Environment variable GOARCH not set"; \ | ||
exit 1; \ | ||
fi |
Oops, something went wrong.