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

blocky 0.20 (new formula) #120963

Closed
wants to merge 10 commits into from
Closed
Changes from 5 commits
Commits
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
65 changes: 65 additions & 0 deletions Formula/blocky.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
class Blocky < Formula
desc "Fast and lightweight DNS proxy as ad-blocker with many features"
homepage "https://0xerr0r.github.io/blocky"
url "https://github.com//0xerr0r/blocky/archive/refs/tags/v0.20.tar.gz"
This conversation was marked as resolved.
Show resolved Hide resolved
sha256 "aae5346e9c1ce4b326b9e578939aa26ddca39338d79d0ddb3eb079ae7a949e87"
license "Apache-2.0"
head "https://github.com/0xerr0r/blocky.git", branch: "development"

depends_on "go" => :build

def install
system "go", "build", *std_go_args, "-o", sbin/"blocky"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
system "go", "build", *std_go_args, "-o", sbin/"blocky"
ldflags = %W[
-s -w
-X github.com/0xERR0R/blocky/util.Version=#{version}
-X github.com/0xERR0R/blocky/util.BuildTime=#{time.iso8601}
]
system "go", "build", *std_go_args(ldflags:ldflags, output: sbin/"blocky")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The binary can runs in both client and server mode, so why not create the binary in bin, and symlink to sbin for server usage?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do need both version and buildtime for version output, unfortunately, it looks like architecture is not dynamically overridable

$ /opt/homebrew/Cellar/blocky/0.20/sbin/blocky version
blocky
Version: 0.20
Build time: 2022-11-12T20:39:38Z
Architecture: undefined

Copy link
Author

@ghost ghost Jan 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A symlink was added for sbin to the version path. Was that what you were suggesting?

Copy link
Author

@ghost ghost Jan 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Architecture used to be set with ${ARCHITECTURE} but now it's ${GOARCH}${GOARM}.

0xERR0R/blocky@e6dd093

https://github.com/0xERR0R/blocky/blob/master/Makefile#L15-L20

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should setup those build environment variables.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A relatively comprehensive list of Golang-related environment variables - https://pkg.go.dev/cmd/go#hdr-Environment_variables.


config_yml = if build.head?
<<~EOF_HEAD
# Reference the example config in the docs for all options
# https://github.com/0xERR0R/blocky/blob/development/docs/config.yml

ports:
dns: "127.0.0.1:53,[::1]:53"

upstream:
default:
- 1.1.1.1
- 1.0.0.1

bootstrapDns:
- tcp+udp:1.1.1.1
- https://1.1.1.1/dns-query
EOF_HEAD
else
<<~EOF_STABLE
# Reference the example config in the docs for all options
# https://github.com/0xERR0R/blocky/blob/v0.20/docs/config.yml

port: "127.0.0.1:53,[::1]:53"

upstream:
default:
- 1.1.1.1
- 1.0.0.1

bootstrapDns: tcp+udp:1.1.1.1
EOF_STABLE
end

File.write "config.yml", config_yml

(etc/"blocky").mkpath
etc.install "config.yml" => "blocky/config.yml"
chenrui333 marked this conversation as resolved.
Show resolved Hide resolved
end

service do
run [opt_sbin/"blocky", "--config", etc/"blocky/config.yml"]
keep_alive true
require_root true
end

test do
system sbin/"blocky version"

out = shell_output("#{sbin}/blocky healthcheck", 1)
assert_match(/^NOT OK$/, out)
This conversation was marked as resolved.
Show resolved Hide resolved
end
end