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

Add windows support #940

Merged
merged 1 commit into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.rpm
*.dep
*.pkg
*.exe

*.out

Expand Down
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ FPMCOMMON= \
-s dir \
-C /tmp/gor-build \

release: release-x64 release-mac
release: release-x64 release-mac release-windows

release-bin:
docker run -v `pwd`:$(SOURCE_PATH) -t --env GOOS=linux --env GOARCH=amd64 -i $(CONTAINER) go build -o $(BIN_NAME) -tags netgo $(LDFLAGS)
Expand Down Expand Up @@ -58,11 +58,25 @@ release-mac:
fpm $(FPMCOMMON) -a amd64 -t osxpkg ./=/usr/local/bin
rm -rf /tmp/gor-build

release-windows:
echo $(pwd)
docker run -it --rm \
-v `pwd`:/go/src/github.com/buger/goreplay \
-w /go/src/github.com/buger/goreplay \
-e CGO_ENABLED=1 \
docker.elastic.co/beats-dev/golang-crossbuild:1.16.4-main \
--build-cmd "VERSION=make build" \
-p "windows/amd64"

mv ./gor ./gor-$(VERSION)$(PREFIX).exe

build:
go build -o $(BIN_NAME) $(LDFLAGS)

install:
go install $(MAC_LDFLAGS)

build:
build-env:
docker build -t $(CONTAINER) -f Dockerfile.dev .

profile:
Expand Down
4 changes: 2 additions & 2 deletions capture/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"runtime"
"sync"
"syscall"
"time"

"github.com/buger/goreplay/size"
Expand All @@ -18,7 +19,6 @@ import (
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
"golang.org/x/sys/unix"
)

// PacketHandler is a function that is used to handle packets
Expand Down Expand Up @@ -335,7 +335,7 @@ func (l *Listener) read(handler PacketHandler) {
if enext, ok := err.(pcap.NextError); ok && enext == pcap.NextErrorTimeoutExpired {
continue
}
if eno, ok := err.(unix.Errno); ok && eno.Temporary() {
if eno, ok := err.(syscall.Errno); ok && eno.Temporary() {
continue
}
if enet, ok := err.(*net.OpError); ok && (enet.Temporary() || enet.Timeout()) {
Expand Down