Skip to content

Commit

Permalink
chore(lint): fix linting in Comcast lib
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed May 11, 2019
1 parent 72e4787 commit 71489f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
25 changes: 12 additions & 13 deletions symptom/throttler/pfctl.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package throttler

import (
"errors"
"fmt"
"strconv"
"strings"
Expand Down Expand Up @@ -48,21 +47,21 @@ func (i *pfctlThrottler) setup(c *Config) error {
// Enable firewall
err := i.c.execute(pfctlEnableFirewall)
if err != nil {
return errors.New(fmt.Sprintf("Could not enable firewall using: `%s`. Error: %s", pfctlEnableFirewall, err.Error()))
return fmt.Errorf("Could not enable firewall using: `%s`. Error: %s", pfctlEnableFirewall, err.Error())
}

// Add the dummynet and anchor
err = i.c.execute(pfctlCreateAnchor)
if err != nil {
return errors.New(fmt.Sprintf("Could not create anchor rule for dummynet using: `%s`. Error: %s", pfctlCreateAnchor, err.Error()))
return fmt.Errorf("Could not create anchor rule for dummynet using: `%s`. Error: %s", pfctlCreateAnchor, err.Error())
}

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

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 fmt.Errorf("Could not create dummynet using: `%s`. Error: %s", pfctlCreateDummynet, err.Error())
}

// Apply the shaping etc.
Expand All @@ -81,19 +80,19 @@ func (i *pfctlThrottler) teardown(_ *Config) error {
// Reset firewall rules, leave it running
err := i.c.execute(pfctlTeardown)
if err != nil {
return errors.New(fmt.Sprintf("Could not remove firewall rules using: `%s`. Error: %s", pfctlTeardown, err.Error()))
return fmt.Errorf("Could not remove firewall rules using: `%s`. Error: %s", pfctlTeardown, err.Error())
}

// Turn off the firewall, discarding any rules
err = i.c.execute(pfctlDisableFirewall)
if err != nil {
return errors.New(fmt.Sprintf("Could not disable firewall using: `%s`. Error: %s", pfctlDisableFirewall, err.Error()))
return fmt.Errorf("Could not disable firewall using: `%s`. Error: %s", pfctlDisableFirewall, err.Error())
}

// Disable dnctl rules
err = i.c.execute(dnctlTeardown)
if err != nil {
return errors.New(fmt.Sprintf("Could not disable dnctl rules using: `%s`. Error: %s", dnctlTeardown, err.Error()))
return fmt.Errorf("Could not disable dnctl rules using: `%s`. Error: %s", dnctlTeardown, err.Error())
}

return nil
Expand Down Expand Up @@ -142,15 +141,15 @@ func addIpsAndProtoToCommands(ipVersion int, cmds []string, ips []string, protos

for _, cmd := range cmds {
for _, ip := range ips {
srcIpFlag := "src-ip"
dstIpFlag := "dst-ip"
srcIPFlag := "src-ip"
dstIPFlag := "dst-ip"
if ipVersion == 6 {
srcIpFlag = "src-ip6"
dstIpFlag = "dst-ip6"
srcIPFlag = "src-ip6"
dstIPFlag = "dst-ip6"
}

commands = append(commands, addProtoToCommands(ipVersion, fmt.Sprintf("%s %s %s", cmd, srcIpFlag, ip), protos)...)
commands = append(commands, addProtoToCommands(ipVersion, fmt.Sprintf("%s %s %s", cmd, dstIpFlag, ip), protos)...)
commands = append(commands, addProtoToCommands(ipVersion, fmt.Sprintf("%s %s %s", cmd, srcIPFlag, ip), protos)...)
commands = append(commands, addProtoToCommands(ipVersion, fmt.Sprintf("%s %s %s", cmd, dstIPFlag, ip), protos)...)
}
}

Expand Down
6 changes: 2 additions & 4 deletions symptom/throttler/tc.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,8 @@ func (t *tcThrottler) teardown(cfg *Config) error {
}

// The root node to append the filters
if err := delRootQDisc(cfg, t.c); err != nil {
return err
}
return nil
err := delRootQDisc(cfg, t.c)
return err
}

func delIptablesRules(cfg *Config, c commander) error {
Expand Down

0 comments on commit 71489f0

Please sign in to comment.