Skip to content

Commit

Permalink
Add build for multiple architectures, streamline process
Browse files Browse the repository at this point in the history
  • Loading branch information
Kioubit committed Dec 28, 2021
1 parent 1ec9477 commit b7c5e6a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.iml
.idea
bin/
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Makefile for PNDPD

BINARY=pndpd
MODULES=
VERSION=`git describe --tags`
LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD}"

build:
go build -tags=${MODULES} -o bin/${BINARY} .

release:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags=${MODULES} ${LDFLAGS} -o bin/${BINARY}_linux_amd64.bin .

release-all:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags=${MODULES} ${LDFLAGS} -o bin/${BINARY}_linux_amd64.bin
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -tags=${MODULES} ${LDFLAGS} -o bin/${BINARY}_linux_arm64.bin
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -tags=${MODULES} ${LDFLAGS} -o bin/${BINARY}_linux_arm.bin

clean:
find bin/ -type f -delete
if [ -d "bin/" ]; then rm -d bin/ ;fi
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ pndpd proxy <interface1> <interface2> <optional whitelist of CIDRs separated by
More options and additional documentation in the example config file (``pndpd.conf ``).

## Developing

### Building
For building, the version of go needs to be installed that is specified in the go.mod file. A makefile is available. Optionally adjust the modules variable to include/exclude modules from the modules directory.
````
make build
make release
````
### Adding Modules
It is easy to add functionality to PNDPD. For additions outside the core functionality you only need to keep the following methods in mind:
````
Expand Down
18 changes: 10 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,10 @@ import (
_ "pndpd/modules/userInterface"
)

// waitForSignal Waits (blocking) for the program to be interrupted by the OS
func waitForSignal() {
var sigCh = make(chan os.Signal, 1)
signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM)
<-sigCh
close(sigCh)
}
var Version = "Development"

func main() {
fmt.Println("PNDPD Version 1.2.1 - Kioubit 2021")
fmt.Println("PNDPD Version", Version, "- Kioubit 2021")

if len(os.Args) <= 2 {
printUsage()
Expand Down Expand Up @@ -64,3 +58,11 @@ func printUsage() {
}
}
}

// waitForSignal Waits (blocking) for the program to be interrupted by the OS
func waitForSignal() {
var sigCh = make(chan os.Signal, 1)
signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM)
<-sigCh
close(sigCh)
}
2 changes: 1 addition & 1 deletion pndpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ responder {
}

// Proxy example
// Create an NDP proxy that for proxying NDP between iface1 ("eth0") and iface2 ("eth1")
// Create an NDP proxy for proxying NDP between iface1 ("eth0") and iface2 ("eth1")
// The whitelist is applied on iface2
proxy {
iface1 eth0
Expand Down

0 comments on commit b7c5e6a

Please sign in to comment.