Skip to content

[pull] master from tylertreat:master #1

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

Merged
merged 18 commits into from
Apr 14, 2023
Merged
Changes from 2 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
7 changes: 4 additions & 3 deletions throttler/pfctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const (
pfctlCreateAnchor = `(cat /etc/pf.conf && echo "dummynet-anchor \"mop\"" && echo "anchor \"mop\"") | sudo pfctl -f -`
pfctlTeardown = `sudo pfctl -f /etc/pf.conf`
dnctl = `sudo dnctl pipe 1 config`
pfctlCreateDummynet = `echo $'dummynet in all pipe 1'`
pfctlCreateDummynet = `echo $'dummynet in on %s all pipe 1'`
pfctlExecuteInline = `%s | sudo pfctl -a mop -f - `
pfctlEnableFirewall = `sudo pfctl -E`
pfctlEnableFwRegex = `pf enabled`
Expand Down Expand Up @@ -58,11 +58,12 @@ func (i *pfctlThrottler) setup(c *Config) error {
}

// Add 'execute' portion of the command
cmd := fmt.Sprintf(pfctlExecuteInline, pfctlCreateDummynet)
input := fmt.Sprintf(pfctlCreateDummynet, c.Device)
cmd := fmt.Sprintf(pfctlExecuteInline, input)

err = i.c.execute(cmd)
if err != nil {
return errors.New(fmt.Sprintf("Could not create dummynet using: `%s`. Error: %s", pfctlCreateDummynet, err.Error()))
return errors.New(fmt.Sprintf("Could not create dummynet using: `%s`. Error: %s", input, err.Error()))
}

// Apply the shaping etc.
Expand Down