Skip to content

Commit

Permalink
Rueidis base (#1008)
Browse files Browse the repository at this point in the history
* updated Deprecated comments

* moved redis config t seperate file

* added more ruedis options

* fmt,lint&test

* init ruedis

* ruedis init

* ruedis rework

* go mod tidy

* redis unit test 1

* changed redis config validation

* go generate

* unshadow

* removed all redis unit tests

* fix e2e tests

* removed one e2e test as it fails(even when a similar setup works in my test environment)

* e2e timing problem

* build(deps): bump github.com/docker/docker

Bumps [github.com/docker/docker](https://github.com/docker/docker) from 23.0.1+incompatible to 23.0.3+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](moby/moby@v23.0.1...v23.0.3)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

* build(deps): bump gorm.io/gorm

Bumps [gorm.io/gorm](https://github.com/go-gorm/gorm) from 1.24.7-0.20230306060331-85eaf9eeda11 to 1.25.0.
- [Release notes](https://github.com/go-gorm/gorm/releases)
- [Commits](https://github.com/go-gorm/gorm/commits/v1.25.0)

---
updated-dependencies:
- dependency-name: gorm.io/gorm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* build(deps): bump github.com/prometheus/client_golang

Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.14.0 to 1.15.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](prometheus/client_golang@v1.14.0...v1.15.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* build(deps): bump gorm.io/driver/sqlite from 1.4.4 to 1.5.0

Bumps [gorm.io/driver/sqlite](https://github.com/go-gorm/sqlite) from 1.4.4 to 1.5.0.
- [Release notes](https://github.com/go-gorm/sqlite/releases)
- [Commits](go-gorm/sqlite@v1.4.4...v1.5.0)

---
updated-dependencies:
- dependency-name: gorm.io/driver/sqlite
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* build(deps): bump gorm.io/driver/mysql from 1.4.7 to 1.5.0

Bumps [gorm.io/driver/mysql](https://github.com/go-gorm/mysql) from 1.4.7 to 1.5.0.
- [Release notes](https://github.com/go-gorm/mysql/releases)
- [Commits](go-gorm/mysql@v1.4.7...v1.5.0)

---
updated-dependencies:
- dependency-name: gorm.io/driver/mysql
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* build(deps): bump github.com/swaggo/swag from 1.8.12 to 1.16.1

Bumps [github.com/swaggo/swag](https://github.com/swaggo/swag) from 1.8.12 to 1.16.1.
- [Release notes](https://github.com/swaggo/swag/releases)
- [Changelog](https://github.com/swaggo/swag/blob/master/.goreleaser.yml)
- [Commits](swaggo/swag@v1.8.12...v1.16.1)

---
updated-dependencies:
- dependency-name: github.com/swaggo/swag
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* build(deps): bump github.com/alicebob/miniredis/v2 from 2.30.1 to 2.30.2

Bumps [github.com/alicebob/miniredis/v2](https://github.com/alicebob/miniredis) from 2.30.1 to 2.30.2.
- [Release notes](https://github.com/alicebob/miniredis/releases)
- [Changelog](https://github.com/alicebob/miniredis/blob/master/CHANGELOG.md)
- [Commits](alicebob/miniredis@v2.30.1...v2.30.2)

---
updated-dependencies:
- dependency-name: github.com/alicebob/miniredis/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Goreleaser fix (#1003)

* use zig for goreleaser

* added test workflow

* Revert "added test workflow"

This reverts commit 9c55c5f.

* added goreleaser test

* autorun goreleaser tests

* add pseudo tag for goreleaser

* added test

* added arm test

* arch test

* missing qemu setup?

* test alternate run

* test rework

* path fix?

* 18 won't run

* another test

* permission fix

* amd64 matrix

* added macos

* added windows test

* consolidate unix tests

* fix path

* fix path2

* matrix consolidation

* +x fails on macos

* fix runner

* windows fix

* Update .github/workflows/goreleaser-test.yml

Co-authored-by: ThinkChaos <[email protected]>

* Update .github/workflows/goreleaser-test.yml

Co-authored-by: ThinkChaos <[email protected]>

* Update .github/workflows/goreleaser-test.yml

Co-authored-by: ThinkChaos <[email protected]>

* Update .github/workflows/goreleaser-test.yml

Co-authored-by: ThinkChaos <[email protected]>

* auto test binaries on release

---------

Co-authored-by: ThinkChaos <[email protected]>

* build(deps): bump github.com/avast/retry-go/v4 from 4.3.3 to 4.3.4

Bumps [github.com/avast/retry-go/v4](https://github.com/avast/retry-go) from 4.3.3 to 4.3.4.
- [Release notes](https://github.com/avast/retry-go/releases)
- [Commits](avast/retry-go@4.3.3...4.3.4)

---
updated-dependencies:
- dependency-name: github.com/avast/retry-go/v4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* go mod tidy

* don't store context in client

* Update redis/redis.go

Co-authored-by: ThinkChaos <[email protected]>

* Update redis/redis.go

Co-authored-by: ThinkChaos <[email protected]>

* moved ClientOptions getter to config package

* moved validation functions

* linter fix

* log warnings about config ignore

* log fetch error

* %w is not supported

* build(deps): bump github.com/prometheus/client_golang

Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.15.0 to 1.15.1.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](prometheus/client_golang@v1.15.0...v1.15.1)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* retry.Do implementation

* log redis config if enabled

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: ThinkChaos <[email protected]>
  • Loading branch information
3 people authored May 5, 2023
1 parent 8d48a21 commit 804ba05
Show file tree
Hide file tree
Showing 24 changed files with 617 additions and 1,125 deletions.
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
51 changes: 14 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,8 @@ func validateConfig(cfg *Config) {
fixDeprecatedLog(cfg)

fixDeprecatedPorts(cfg)

return cfg.Redis.validateConfig()
}

// 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

0 comments on commit 804ba05

Please sign in to comment.