From 8f69ce3a4971a56138a5900e83015954ac915f0b Mon Sep 17 00:00:00 2001 From: Yun Zheng Hu Date: Fri, 4 Oct 2024 17:26:35 +0200 Subject: [PATCH] Make pcap-broker go installable (#8) This mainly adds a main.go file in the project root so it's easier to install pcap-broker using `go install`: $ go install github.com/fox-it/pcap-broker@latest Or install the main branch: $ go install github.com/fox-it/pcap-broker@main --- Dockerfile | 2 +- README.md | 17 +++++++++++++++-- cmd/pcap-broker/main.go | 4 ++-- main.go | 9 +++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 main.go diff --git a/Dockerfile b/Dockerfile index 6ff131c..a0f9753 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,6 @@ WORKDIR /app COPY . /app RUN go mod download -RUN go build ./cmd/pcap-broker +RUN go build . ENTRYPOINT ["./pcap-broker"] diff --git a/README.md b/README.md index ce11172..df5fed2 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,16 @@ More information on PCAP-over-IP can be found here: ## Building -To build `pcap-broker`: +Building `pcap-broker` requires the `libpcap` development headers, on Debian you can install it with: ```shell -$ go build ./cmd/pcap-broker +$ apt install libpcap-dev +``` + +To build from source, clone this repository and run: + +```shell +$ go build . $ ./pcap-broker --help ``` @@ -29,6 +35,13 @@ $ docker build -t pcap-broker . $ docker run -it pcap-broker --help ``` +Alternatively, install directly using `go`: + +```shell +$ go install github.com/fox-it/pcap-broker@latest +$ pcap-broker --help +``` + ## Running ```shell diff --git a/cmd/pcap-broker/main.go b/cmd/pcap-broker/main.go index 8872044..9b16da9 100644 --- a/cmd/pcap-broker/main.go +++ b/cmd/pcap-broker/main.go @@ -1,4 +1,4 @@ -package main +package pcap_broker import ( "context" @@ -34,7 +34,7 @@ var ( json = flag.Bool("json", false, "enable json logging") ) -func main() { +func Main() { flag.Parse() if !*json { diff --git a/main.go b/main.go new file mode 100644 index 0000000..325fc7e --- /dev/null +++ b/main.go @@ -0,0 +1,9 @@ +package main + +import ( + pcap_broker "github.com/fox-it/pcap-broker/cmd/pcap-broker" +) + +func main() { + pcap_broker.Main() +}