Skip to content

Commit

Permalink
feat: unix package
Browse files Browse the repository at this point in the history
Signed-off-by: Niklas Treml <[email protected]>
  • Loading branch information
niklastreml committed Aug 5, 2024
1 parent 247730b commit aa347ef
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/e2e_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
sudo add-apt-repository ppa:katharaframework/kathara
sudo apt-get update
sudo apt-get install -y python3 python3-pip jq kathara
sudo apt-get install -y jq kathara
- name: Setup kathara
run: |
echo '{
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ of the hop that dropped a packet, will not be available. To enable this function
sudo sparrow run --config config.yaml
```

- allow sparrow to create raw sockets, by assignging the `CAP_NET_RAW` capability to the sparrow binary:
- allow sparrow to create raw sockets, by assigning the `CAP_NET_RAW` capability to the sparrow binary:
```bash
sudo setcap 'cap_net_raw=ep' sparrow
```
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ require (
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/sys v0.20.0
golang.org/x/text v0.15.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
8 changes: 5 additions & 3 deletions pkg/checks/traceroute/traceroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"syscall"
"time"

"golang.org/x/sys/unix"

"github.com/caas-team/sparrow/internal/helper"
"github.com/caas-team/sparrow/internal/logger"
"golang.org/x/net/icmp"
Expand Down Expand Up @@ -41,7 +43,7 @@ func tcpHop(addr net.Addr, ttl int, timeout time.Duration) (net.Conn, int, error
Control: func(_, _ string, c syscall.RawConn) error {
var opErr error
if err := c.Control(func(fd uintptr) {
opErr = syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_TTL, ttl)
opErr = unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_TTL, ttl)
}); err != nil {
return err
}
Expand All @@ -51,7 +53,7 @@ func tcpHop(addr net.Addr, ttl int, timeout time.Duration) (net.Conn, int, error

// Attempt to connect to the target host
conn, err := dialer.Dial("tcp", addr.String())
if !errors.Is(err, syscall.EADDRINUSE) {
if !errors.Is(err, unix.EADDRINUSE) {
return conn, port, err
}
}
Expand Down Expand Up @@ -199,7 +201,7 @@ func traceroute(ctx context.Context, addr net.Addr, ttl int, timeout time.Durati
func newIcmpListener() (bool, *icmp.PacketConn, error) {
icmpListener, err := icmp.ListenPacket("ip4:icmp", "0.0.0.0")
if err != nil {
if !errors.Is(err, syscall.EPERM) {
if !errors.Is(err, unix.EPERM) {
return false, nil, err
}
return false, nil, nil
Expand Down

0 comments on commit aa347ef

Please sign in to comment.