Skip to content

Commit

Permalink
Merge pull request #2 from siemens/develop
Browse files Browse the repository at this point in the history
macos X support
  • Loading branch information
thediveo authored Sep 11, 2023
2 parents f16822f + 99cc183 commit 8f9d0b7
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/buildandtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ jobs:

- name: Test Go packages
run: go test -v -p 1 ./...

- name: Build for Windows
run: GOOS=windows GOARCH=amd64 go build -v ./cmd/cshargextcap

- name: Build for Darwin
run: GOOS=darwin GOARCH=arm64 go build -v ./cmd/cshargextcap
1 change: 1 addition & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ builds:
targets:
- linux_amd64_v1
- linux_arm64
- darwin_arm64
tags:
- netgo
- osusergo
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Head over to our
arm64) and distro package format (Debian, Alpine, Fedora). Install the
downloaded package as usual.

- **Mac OS**: download the `.tar.gz` archive for Darwin arm64. Extract the contained `cshargextcap` plugin binary and copy/move it to `/Applications/Wireshark.app/Contents/MacOS/extcap`.

- **Windows**: download the ZIP archive for Windows amd64. Double click in file
explorer to open its contents, then double click on the installer `.exe`. You
don't need to extract the other files, as the installer perfectly works on its
Expand Down
2 changes: 1 addition & 1 deletion defs_version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packaging/windows/pluginversion.nsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
!define VERSION "0.15.6-4-g2ca25de"
!define FILEVERSION "0.15.6.0"
!define VERSION "0.9.1-4-g9413ea6"
!define FILEVERSION "0.9.1.0"
!define COPYRIGHT "Copyright © Siemens 2023"
!define BINARYPATH "/cshargextcap/dist/windows_windows_amd64_v1"
!define BINARYNAME "cshargextcap-amd64.exe"
Expand Down
9 changes: 5 additions & 4 deletions pipe/checker_notwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ package pipe

import (
"os"
"syscall"

"golang.org/x/sys/unix"

log "github.com/sirupsen/logrus"
)
Expand All @@ -19,14 +20,14 @@ import (
// This implementation leverages [syscall.Select].
func WaitTillBreak(fifo *os.File) {
log.Debug("constantly monitoring packet capture fifo status...")
fds := syscall.FdSet{}
fds := unix.FdSet{}
for {
// Check the fifo becomming readable, which signals that it has been
// closed. In this case, ex-termi-nate ;) Oh, and remember to correctly
// initialize the fdset each time before calling select() ... well, just
// because that's a good idea to do. :(
fds.Bits[fifo.Fd()>>3] |= 0x01 << (fifo.Fd() & 7)
n, err := syscall.Select(
fds.Set(int(fifo.Fd()))
n, err := unix.Select(
int(fifo.Fd())+1, // highest fd is our file descriptor.
&fds, nil, nil, // only watch readable.
nil, // no timeout, ever.
Expand Down
31 changes: 31 additions & 0 deletions pipe/checker_notwin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// (c) Siemens AG 2023
//
// SPDX-License-Identifier: MIT

package pipe

import (
"os"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/thediveo/success"
)

var _ = Describe("pipes", func() {

It("detects when a pipe breaks", func() {
r, w := Successful2R(os.Pipe())
defer r.Close()
go func() {
GinkgoHelper()
time.Sleep(2 * time.Second)
Expect(w.Close()).To(Succeed())
}()
start := time.Now()
WaitTillBreak(r)
Expect(time.Since(start).Milliseconds()).To(BeNumerically(">", 1500))
})

})
21 changes: 21 additions & 0 deletions pipe/package_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// (c) Siemens AG 2023
//
// SPDX-License-Identifier: MIT

package pipe

import (
"testing"

log "github.com/sirupsen/logrus"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func TestContainerSharkExtCap(t *testing.T) {
log.SetLevel(log.DebugLevel)

RegisterFailHandler(Fail)
RunSpecs(t, "cshargextcap/pipe")
}

0 comments on commit 8f9d0b7

Please sign in to comment.