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

blocky 0.20 (new formula) #120963

wants to merge 10 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 18, 2023

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

https://github.com/0xERR0R/blocky

@BrewTestBot BrewTestBot added go Go use is a significant feature of the PR or issue new formula PR adds a new formula to Homebrew/homebrew-core labels Jan 18, 2023
@ghost
Copy link
Author

ghost commented Jan 18, 2023

blocky is gaining popularity as an adblocking DNS server.

The configurations included in the formula (for HEAD and stable) don't provide adblocking; only a basic DNS proxy is configured however users can build off of that functional setup. The service runs on port 53 as root instead of the default unprivileged 5353 port because MacOS doesn't allow a port to be specified using networksetup (sudo networksetup -setdnsservers Wi-Fi 127.0.0.1).

Formula/blocky.rb Outdated Show resolved Hide resolved
Formula/blocky.rb Outdated Show resolved Hide resolved
Formula/blocky.rb Outdated Show resolved Hide resolved
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.

log-to-code and others added 3 commits January 19, 2023 12:39
Formula/blocky.rb Outdated Show resolved Hide resolved
Co-authored-by: Rui Chen <rui@chenrui.dev>
Comment on lines 22 to 56
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
log:
level: info
format: text
timestamp: true
privacy: false
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
logLevel: info
logFormat: text
logTimestamp: true
logPrivacy: false
EOF_STABLE
end
Copy link
Member

Choose a reason for hiding this comment

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

If upstream doesn't ship one, homebrew shouldn't either

Copy link
Author

@ghost ghost Jan 20, 2023

Choose a reason for hiding this comment

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

The issue is that the service listens on 0.0.0.0 by default, leaving users vulnerable to external requests to sensitive or prohibited domains in their country. What do you recommend?

Copy link
Member

Choose a reason for hiding this comment

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

I recommend upstream ship a config file or change the default.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, let's PR that config into the upstream, it would benefit the other package managers as well. :)

Copy link
Author

Choose a reason for hiding this comment

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

I submitted that request to the blocky project. 0xERR0R/blocky#839

Copy link
Author

@ghost ghost Jan 22, 2023

Choose a reason for hiding this comment

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

We need to wait for a new release with the latest config format changes because some fields have changed in HEAD from the 0.20 release. For instance port is now ports and logLevel/logFormat/logTimestamp are now in the log hash.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good, thanks!! 👍

Copy link
Author

Choose a reason for hiding this comment

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

Doesn't macOS ask users if they want to allow the service to accept incoming network connections? Maybe running blocky without a default config is acceptable since the user decides if they want to allow external access.

@chenrui333 chenrui333 changed the title blocky (new formula) blocky 0.20 (new formula) Jan 20, 2023
@github-actions
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label Feb 14, 2023
@github-actions github-actions bot closed this Feb 22, 2023
@github-actions github-actions bot added the outdated PR was locked due to age label Mar 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
go Go use is a significant feature of the PR or issue new formula PR adds a new formula to Homebrew/homebrew-core outdated PR was locked due to age stale No recent activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants