Skip to content

Commit

Permalink
Fixing syscall requests to unix.
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhan-uysal committed Jul 13, 2024
1 parent 89ccd54 commit 6d15740
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ build:
@echo "GOOS = $(GOOS)"
@echo "GOARCH = $(GOARCH)"
@echo "CGO_ENABLED = $(CGO_ENABLED)"
@go build -o $(BIN_DIR)/$(PROJECT_NAME)-$(GOOS)-$(GOARCH) -v -x $(SRC_DIR)/$(PROJECT_NAME)
@GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(BIN_DIR)/$(PROJECT_NAME)-$(GOOS)-$(GOARCH) -v -x $(SRC_DIR)/$(PROJECT_NAME)
@echo "Built!"

clean:
Expand Down
3 changes: 1 addition & 2 deletions pkg/pingo/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"net"
"syscall"
"time"

"github.com/code-brew-lab/pingo/pkg/netcore"
Expand All @@ -18,7 +17,7 @@ type Request struct {
}

func NewRequest(ip net.IP) (*Request, error) {
fd, err := unix.Socket(syscall.AF_INET, syscall.SOCK_RAW, syscall.IPPROTO_ICMP)
fd, err := unix.Socket(unix.AF_INET, unix.SOCK_RAW, unix.IPPROTO_ICMP)
if err != nil {
return nil, fmt.Errorf("pingo.NewRequest: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/pingo/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package pingo
import (
"context"
"fmt"
"syscall"
"time"

"github.com/code-brew-lab/pingo/pkg/netcore"
"golang.org/x/sys/unix"
)

func Read(ctx context.Context, fd int, id netcore.ID, timeout time.Duration) (<-chan *netcore.Datagram, <-chan error) {
Expand Down Expand Up @@ -46,7 +46,7 @@ func Read(ctx context.Context, fd int, id netcore.ID, timeout time.Duration) (<-

func read(fd int) (*netcore.Datagram, error) {
buff := make([]byte, 1024)
numRead, err := syscall.Read(fd, buff)
numRead, err := unix.Read(fd, buff)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 6d15740

Please sign in to comment.