From 9d31008d2957c07889fb44662d3db29910f0ed51 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Tue, 15 Nov 2022 22:47:53 +0100 Subject: [PATCH 1/6] Remove unnecessary require --- go.mod | 1 - go.sum | 14 -------------- 2 files changed, 15 deletions(-) diff --git a/go.mod b/go.mod index fd10532..e548eb9 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module git.ruekov.eu/ruakij/routingtabletowg go 1.19 require ( - github.com/jsimonetti/rtnetlink v1.2.3 github.com/vishvananda/netlink v1.1.0 golang.org/x/sys v0.1.0 golang.zx2c4.com/wireguard/wgctrl v0.0.0-20221104135756-97bc4ad4a1cb diff --git a/go.sum b/go.sum index 52f109c..dddec04 100644 --- a/go.sum +++ b/go.sum @@ -1,19 +1,9 @@ -github.com/cilium/ebpf v0.9.3/go.mod h1:w27N4UjpaQ9X/DGrSugxUG+H+NhgntDuPb5lCzxCn8A= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/josharian/native v1.0.0 h1:Ts/E8zCSEsG17dUqv7joXJFybuMLjQfWE04tsBODTxk= github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= -github.com/jsimonetti/rtnetlink v1.2.3 h1:JntWIxmljlDswWwebzpZCz2Aa3t2kThJ79f658zgsPU= -github.com/jsimonetti/rtnetlink v1.2.3/go.mod h1:5r5Rj9WEseVOUzDk5RN9v0gVXbkBz9XtENwhC6PwvtU= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mdlayher/genetlink v1.2.0 h1:4yrIkRV5Wfk1WfpWTcoOlGmsWgQj3OtQN9ZsbrE+XtU= github.com/mdlayher/genetlink v1.2.0/go.mod h1:ra5LDov2KrUCZJiAtEvXXZBxGMInICMXIwshlJ+qRxQ= github.com/mdlayher/netlink v1.6.0/go.mod h1:0o3PlBmGst1xve7wQ7j/hwpNaFaH4qCRyWCdcZk8/vA= @@ -23,7 +13,6 @@ github.com/mdlayher/socket v0.1.1/go.mod h1:mYV5YIZAfHh4dzDVzI8x8tWLWCliuX8Mon5A github.com/mdlayher/socket v0.2.3 h1:XZA2X2TjdOwNoNPVPclRCURoX/hokBY8nkTmRZFEheM= github.com/mdlayher/socket v0.2.3/go.mod h1:bz12/FozYNH/VbvC3q7TRIK/Y6dH1kCKsXaUeXi/FmY= github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721 h1:RlZweED6sbSArvlE924+mUcZuXKLBHA35U7LN621Bws= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df h1:OviZH7qLw/7ZovXvuNyL3XQl8UFofeikI1NW1Gypu7k= @@ -51,7 +40,6 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -66,5 +54,3 @@ golang.zx2c4.com/wireguard v0.0.0-20220920152132-bb719d3a6e2c h1:Okh6a1xpnJslG9M golang.zx2c4.com/wireguard v0.0.0-20220920152132-bb719d3a6e2c/go.mod h1:enML0deDxY1ux+B6ANGiwtg0yAJi1rctkTpcHNAVPyg= golang.zx2c4.com/wireguard/wgctrl v0.0.0-20221104135756-97bc4ad4a1cb h1:9aqVcYEDHmSNb0uOWukxV5lHV09WqiSiCuhEgWNETLY= golang.zx2c4.com/wireguard/wgctrl v0.0.0-20221104135756-97bc4ad4a1cb/go.mod h1:mQqgjkW8GQQcJQsbBvK890TKqUK1DfKWkuBGbOkuMHQ= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= From d0840e617127d115cbf048705e6f9ec6cd0afcff Mon Sep 17 00:00:00 2001 From: Ruakij Date: Tue, 15 Nov 2022 22:48:10 +0100 Subject: [PATCH 2/6] Swap check for slightly better performance --- lib/iproute2mapping/mapping.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iproute2mapping/mapping.go b/lib/iproute2mapping/mapping.go index 5b2e6c0..7cb0686 100644 --- a/lib/iproute2mapping/mapping.go +++ b/lib/iproute2mapping/mapping.go @@ -55,7 +55,7 @@ func readFromFile(filePath string) (mapByName map[string]int, mapById map[int]st // Go through file line-by-line for scanner.Scan() { text := scanner.Text() - if(strings.HasPrefix(text, "#") || text == ""){ + if(text == "" || strings.HasPrefix(text, "#")){ continue } From f136bcb207316fba076e2c5fe7755fac3ae30a90 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Tue, 15 Nov 2022 22:49:06 +0100 Subject: [PATCH 3/6] Fix wrong docker-service and image name --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 33ee5c1..e9ac395 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,8 @@ Additionally the capability `NET_ADMIN` is required for interacting with interfa version: '3' services: - routingTableWGTranslator: - image: ruakij/RoutingTableWGTranslator + routingtabletowg: + image: ruakij/routingtabletowg restart: unless-stopped network_mode: host cap_add: From d0e6fa65d21da12024122365e6b4ef2cb05b2c14 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Thu, 17 Nov 2022 14:51:18 +0100 Subject: [PATCH 4/6] Fix error-reporting --- lib/iproute2mapping/mapping.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/iproute2mapping/mapping.go b/lib/iproute2mapping/mapping.go index 7cb0686..284dfd3 100644 --- a/lib/iproute2mapping/mapping.go +++ b/lib/iproute2mapping/mapping.go @@ -32,9 +32,9 @@ func init() { for mapType, filePath := range filePaths{ ByName[mapType], ById[mapType], err = readFromFile(filePath) if(err != nil){ - Errors = []error{ - fmt.Errorf("failed reading iproute2 mapping-file '%s': %s", filePath, err), - }; + Errors = append(Errors, + fmt.Errorf("failed reading mapping-file '%s': %s", filePath, err), + ); } } } From 180f11cb86129c877dcd42841403f5d659bd218c Mon Sep 17 00:00:00 2001 From: Ruakij Date: Thu, 17 Nov 2022 14:51:38 +0100 Subject: [PATCH 5/6] Add warning-output for errors in iproute2mapping --- cmd/app/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/app/main.go b/cmd/app/main.go index e75798b..14c9eda 100644 --- a/cmd/app/main.go +++ b/cmd/app/main.go @@ -37,6 +37,11 @@ func main() { iface := os.Getenv("INTERFACE") //MANAGE_ALL = os.Getenv("MANAGE_ALL") + // Check if ip2Map has init-errors + for _, err := range ip2Map.Errors { + logger.Warn.Printf("iproute2mapping: %s", err) + } + // Parse filter-env-vars filterProtocolStr := os.Getenv("FILTER_PROTOCOL") filterProtocol, err := ip2Map.TryGetId(ip2Map.PROTOCOL, filterProtocolStr) From d5886fcb4ab35c3c607b7094eb342f5a57bd34a0 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Thu, 17 Nov 2022 14:51:53 +0100 Subject: [PATCH 6/6] Add iproute2 as packet --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 83bfc56..09f604d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,9 @@ FROM alpine:3 AS base WORKDIR /app +# Install necessary packages +RUN apk add --no-cache iproute2 + # ---- Build ---- FROM golang:1.19-alpine AS build