Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rueidis base #1008

Merged
merged 41 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a92fdd3
updated Deprecated comments
kwitsch Mar 31, 2023
83eba7c
moved redis config t seperate file
kwitsch Mar 31, 2023
5d2420a
added more ruedis options
kwitsch Mar 31, 2023
56d181c
fmt,lint&test
kwitsch Apr 1, 2023
3d04477
init ruedis
kwitsch Apr 1, 2023
fe575d6
ruedis init
kwitsch Apr 1, 2023
693617e
ruedis rework
kwitsch Apr 1, 2023
b162f92
go mod tidy
kwitsch Apr 1, 2023
1761801
redis unit test 1
kwitsch Apr 1, 2023
a748b73
changed redis config validation
kwitsch Apr 1, 2023
583c632
go generate
kwitsch Apr 2, 2023
56d075a
unshadow
kwitsch Apr 14, 2023
f09cebc
removed all redis unit tests
kwitsch Apr 14, 2023
f4d1722
fix e2e tests
kwitsch Apr 14, 2023
4b13807
removed one e2e test as it fails(even when a similar setup works in m…
kwitsch Apr 14, 2023
7442d08
e2e timing problem
kwitsch Apr 14, 2023
5fc02bb
build(deps): bump github.com/docker/docker
dependabot[bot] Apr 5, 2023
c786d41
build(deps): bump gorm.io/gorm
dependabot[bot] Apr 12, 2023
2205aa7
build(deps): bump github.com/prometheus/client_golang
dependabot[bot] Apr 14, 2023
d0c6a1d
build(deps): bump gorm.io/driver/sqlite from 1.4.4 to 1.5.0
dependabot[bot] Apr 19, 2023
c7d6cca
build(deps): bump gorm.io/driver/mysql from 1.4.7 to 1.5.0
dependabot[bot] Apr 19, 2023
2866932
build(deps): bump github.com/swaggo/swag from 1.8.12 to 1.16.1
dependabot[bot] Apr 19, 2023
ed00064
build(deps): bump github.com/alicebob/miniredis/v2 from 2.30.1 to 2.30.2
dependabot[bot] Apr 19, 2023
1d25cca
Goreleaser fix (#1003)
kwitsch Apr 26, 2023
e4f467c
build(deps): bump github.com/avast/retry-go/v4 from 4.3.3 to 4.3.4
dependabot[bot] Apr 24, 2023
dded3ef
Merge remote-tracking branch 'origin/main' into rueidis-base
kwitsch Apr 30, 2023
e1d1443
go mod tidy
kwitsch Apr 30, 2023
3bc152f
don't store context in client
kwitsch Apr 30, 2023
634a6da
Update redis/redis.go
kwitsch May 1, 2023
144a6a8
Update redis/redis.go
kwitsch May 1, 2023
e1447a5
moved ClientOptions getter to config package
kwitsch May 2, 2023
ea517f1
Merge branch 'rueidis-base' of https://github.com/kwitsch/blocky-dev …
kwitsch May 2, 2023
9e0f789
moved validation functions
kwitsch May 2, 2023
146f0b5
linter fix
kwitsch May 2, 2023
3e5094c
log warnings about config ignore
kwitsch May 2, 2023
4ae0204
log fetch error
kwitsch May 2, 2023
d1c7c2f
%w is not supported
kwitsch May 3, 2023
1b478d0
build(deps): bump github.com/prometheus/client_golang
dependabot[bot] May 4, 2023
ad1ce3a
retry.Do implementation
kwitsch May 5, 2023
5eb9371
Merge branch 'main' into rueidis-base
kwitsch May 5, 2023
13c8577
log redis config if enabled
kwitsch May 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions .github/workflows/goreleaser-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: GoReleaser Test

on:
push:
tags:
- v*
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build binaries with goreleaser
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod

- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2

- name: Run GoReleaser check
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: check

- name: Run GoReleaser build
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: build --clean --snapshot

- name: Upload dist folder
uses: actions/upload-artifact@v3
with:
name: dist_folder
path: dist
retention-days: 1

tests:
name: Test binaries
runs-on: ${{matrix.runner}}
needs: build
strategy:
matrix:
distro: [ubuntu16.04, ubuntu18.04, ubuntu20.04, ubuntu22.04, bullseye, buster, stretch]
arch: [armv7,aarch64]
os: [linux]
runner: [ubuntu-latest]
include:
- distro: stretch
runner: ubuntu-latest
arch: armv6
os: linux
- distro: buster
runner: ubuntu-latest
arch: armv6
os: linux
- distro: bullseye
runner: ubuntu-latest
arch: armv6
os: linux
- distro: ubuntu20.04
runner: ubuntu-20.04
arch: amd64
os: linux
- distro: ubuntu22.04
runner: ubuntu-22.04
arch: amd64
os: linux
- distro: macos
runner: macos-11
arch: amd64
os: darwin
- distro: macos
runner: macos-12
arch: amd64
os: darwin
- distro: windows
runner: windows-latest
arch: amd64
os: windows

steps:
- name: Download dist folder
id: download
uses: actions/download-artifact@v3
with:
name: dist_folder

- name: Get binary path
id: get_path
if: matrix.os != 'windows'
shell: bash
run: |
archs=(["aarch64"]="arm64" ["armv6"]="arm_6" ["armv7"]="arm_7" ["amd64"]="amd64_v1")
BINPATH="${{steps.download.outputs.download-path}}/blocky_${{ matrix.os }}_${archs[ ${{ matrix.arch }} ]}/blocky"
echo "bin=${BINPATH}" >> "$GITHUB_OUTPUT"
echo "Binary path: ${BINPATH}"

- name: Enable execution
if: matrix.os != 'windows'
shell: bash
run: |
chmod +x '${{ steps.get_path.outputs.bin }}'

- name: Test binary on ${{ matrix.arch }}
if: matrix.arch != 'amd64'
uses: uraimo/run-on-arch-action@v2
with:
distro: ${{ matrix.distro }}
arch: ${{ matrix.arch }}
dockerRunArgs: |
--volume "${{steps.download.outputs.download-path}}:${{steps.download.outputs.download-path}}"
shell: /bin/sh
run: |
'${{ steps.get_path.outputs.bin }}' version

- name: Test binary on amd64
if: matrix.arch == 'amd64' && matrix.os != 'windows'
shell: bash
run: |
'${{ steps.get_path.outputs.bin }}' version

- name: Test windows binary
if: matrix.os == 'windows'
shell: cmd
run: |
${{steps.download.outputs.download-path}}\blocky_windows_amd64_v1\blocky.exe version
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
Expand Down
12 changes: 11 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ project_name: blocky
before:
hooks:
- go mod tidy
- go install github.com/dosgo/zigtool/zigcc@latest
- go install github.com/dosgo/zigtool/zigcpp@latest
builds:
- goos:
- linux
Expand All @@ -24,7 +26,15 @@ builds:
- goos: windows
goarch: arm64
ldflags:
- -w -s -X github.com/0xERR0R/blocky/util.Version=v{{.Version}} -X github.com/0xERR0R/blocky/util.BuildTime={{time "20060102-150405"}}
- -w
- -s
- -X github.com/0xERR0R/blocky/util.Version=v{{.Version}}
- -X github.com/0xERR0R/blocky/util.BuildTime={{time "20060102-150405"}}
- -X github.com/0xERR0R/blocky/util.Architecture={{.Arch}}{{.Arm}}
env:
- CGO_ENABLED=0
- CC=zigcc
- CXX=zigcpp
release:
draft: true
archives:
Expand Down
53 changes: 16 additions & 37 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (b *BootstrappedUpstreamConfig) UnmarshalYAML(unmarshal func(interface{}) e

// Config main configuration
//
//nolint:maligned
//nolint:maligned,lll
type Config struct {
Upstream ParallelBestConfig `yaml:"upstream"`
UpstreamTimeout Duration `yaml:"upstreamTimeout" default:"2s"`
Expand All @@ -181,24 +181,15 @@ type Config struct {
FqdnOnly FqdnOnlyConfig `yaml:",inline"`
Filtering FilteringConfig `yaml:"filtering"`
Ede EdeConfig `yaml:"ede"`
// Deprecated
DisableIPv6 bool `yaml:"disableIPv6" default:"false"`
// Deprecated
LogLevel log.Level `yaml:"logLevel" default:"info"`
// Deprecated
LogFormat log.FormatType `yaml:"logFormat" default:"text"`
// Deprecated
LogPrivacy bool `yaml:"logPrivacy" default:"false"`
// Deprecated
LogTimestamp bool `yaml:"logTimestamp" default:"true"`
// Deprecated
DNSPorts ListenConfig `yaml:"port" default:"53"`
// Deprecated
HTTPPorts ListenConfig `yaml:"httpPort"`
// Deprecated
HTTPSPorts ListenConfig `yaml:"httpsPort"`
// Deprecated
TLSPorts ListenConfig `yaml:"tlsPort"`
DisableIPv6 bool `yaml:"disableIPv6" default:"false"` // Deprecated: use Filtering with TypeAAAA
LogLevel log.Level `yaml:"logLevel" default:"info"` // Deprecated: use Log.Level
LogFormat log.FormatType `yaml:"logFormat" default:"text"` // Deprecated: use Log.Format
LogPrivacy bool `yaml:"logPrivacy" default:"false"` // Deprecated: use Log.Privacy
LogTimestamp bool `yaml:"logTimestamp" default:"true"` // Deprecated: use Log.Timestamp
DNSPorts ListenConfig `yaml:"port" default:"53"` // Deprecated: use Ports.DNS
HTTPPorts ListenConfig `yaml:"httpPort"` // Deprecated: use Ports.HTTP
HTTPSPorts ListenConfig `yaml:"httpsPort"` // Deprecated: use Ports.HTTPS
TLSPorts ListenConfig `yaml:"tlsPort"` // Deprecated: use Ports.TLS
}

type PortsConfig struct {
Expand Down Expand Up @@ -230,20 +221,6 @@ type (
}
)

// RedisConfig configuration for the redis connection
type RedisConfig struct {
Address string `yaml:"address"`
Username string `yaml:"username" default:""`
Password string `yaml:"password" default:""`
Database int `yaml:"database" default:"0"`
Required bool `yaml:"required" default:"false"`
ConnectionAttempts int `yaml:"connectionAttempts" default:"3"`
ConnectionCooldown Duration `yaml:"connectionCooldown" default:"1s"`
SentinelUsername string `yaml:"sentinelUsername" default:""`
SentinelPassword string `yaml:"sentinelPassword" default:""`
SentinelAddresses []string `yaml:"sentinelAddresses"`
}

type (
FqdnOnlyConfig = toEnable
EdeConfig = toEnable
Expand Down Expand Up @@ -374,12 +351,10 @@ func unmarshalConfig(data []byte, cfg *Config) error {
return fmt.Errorf("wrong file structure: %w", err)
}

validateConfig(cfg)

return nil
return validateConfig(cfg)
}

func validateConfig(cfg *Config) {
func validateConfig(cfg *Config) error {
if cfg.DisableIPv6 {
log.Log().Warnf("'disableIPv6' is deprecated. Please use 'filtering.queryTypes' with 'AAAA' instead.")

Expand All @@ -400,6 +375,10 @@ func validateConfig(cfg *Config) {
fixDeprecatedLog(cfg)

fixDeprecatedPorts(cfg)

fixDeprecatedRedis(cfg)

return validateRedisConfig(cfg)
}

// fixDeprecatedLog ensures backwards compatibility for logging options
Expand Down
31 changes: 30 additions & 1 deletion config/config_enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading