Skip to content

Commit 026d943

Browse files
committed
chore(pkg/wireguard): replace bash script with native code
There is no reason to use bash, or even to call out to the shell for most of what was happening. Replacing it allows for better error handling, clarity and reliability. Fixes: #79
1 parent 8565ade commit 026d943

File tree

4 files changed

+60
-2042
lines changed

4 files changed

+60
-2042
lines changed

cmd/agent/main.go

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package main
33
import (
44
"flag"
55
"fmt"
6+
"log"
7+
"os"
8+
69
"github.com/go-logr/stdr"
710
"github.com/jodevsa/wireguard-operator/internal/iptables"
811
"github.com/jodevsa/wireguard-operator/pkg/agent"
912
"github.com/jodevsa/wireguard-operator/pkg/wireguard"
10-
"log"
11-
"os"
1213
)
1314

1415
func main() {
@@ -23,42 +24,42 @@ func main() {
2324
flag.StringVar(&wgUserspaceImplementationFallback, "wg-userspace-implementation-fallback", "wireguard-go", "The userspace implementation of wireguard to fallback to")
2425
flag.IntVar(&wireguardListenPort, "wg-listen-port", 51820, "the UDP port wireguard is listening on")
2526
flag.IntVar(&verbosity, "v", 1, "the verbosity level")
26-
flag.BoolVar(&wgUseUserspaceImpl, "wg-use-userspace-implementation", false, "Use userspace implementation")
27+
flag.BoolVar(&wgUseUserspaceImpl, "wg-use-userspace-implementation", true, "Use userspace implementation")
2728
flag.Parse()
2829

2930
println(fmt.Sprintf(
30-
`
31-
.:::::::::::::::::::::::::...::::::::::::::::::::.
32-
.::::::::::::::::::::.:^7J5PBGY!^::::::::::::::::::::.
33-
:::::::::::::::::::::~?J??5&@@@@@&G!~~~::::::::::::::::. WG Agent Configuration
34-
::::::::::::::::::::::^7&@@@@@@@@@@@@&&&G^:::::::::::::::. ------------------------------------------
35-
.::::::::::::::::::::::!J#@@@@@@@BBBGPPG7:::::::::::::::::. wg-iface: %s
36-
.:::::::::::::::::::::^?Y5#@@@@@@5^...::::::::::::::::::::: state: %s
37-
.::::::::::::::::::::::..:!7Y#@@@@@#Y~:.::::::::::::::::::. wg-listen-port: %d
38-
.:::::::::::::::::::.:^!?JYYJ?JG&@@@@@#7::::::::::::::::::. wg-use-userspace-implementation: %v
39-
.:::::::::::::::::.^J#@@@@@@@@@&#B&@@@@@G:::::::::::::::::. wg-userspace-implementation-fallback: %s
40-
.:::::::::::::::::J@@@@@@@@@@@@@@@&G@@@@@J.:::::::::::::::.
41-
.::::::::::::::::5@@@@@#?~~~7P@@@@@&B@@@@P.:::::::::::::::.
42-
.:::::::::::::::^@@@@@P..::::.~@@@@B&@@@@!::::::::::::::::.
43-
.:::::::::::::::~@@@@@J.::::::^@@@#&@@@@P:::::::::::::::::.
44-
.::::::::::::::::B@@@@@P!^:.:~G&&&@@@@@5::::::::::::::::::.
45-
.:::::::::::::::::G@@@@@&#BB&@@@@@@@@B~.::::::::::::::::::.
46-
.::::::::::::::::..~G&&&@@@@@@@@@&&&&&P^.:::::::::::::::::.
47-
.::::::::::::::.:~YGGY&@@@@@&GY7JB@@@@@@7:::::::::::::::::.
48-
.::::::::::::::?&@@@B&@@@@#!:..:::~B@@@@@~::::::::::::::::.
49-
.:::::::::::::J&#P5?5@@@@@:.::::::::&@@@@5.:::::::::::::::.
50-
.:::::::::::::^:....J@@@@@~.::::::.^@@@@@5.::::::::::::::::
51-
.::::::::::::::::::::&@@@@@Y~::::^J&@@@@&^::::::::::::::::.
52-
::::::::::::::::::::^B@@@@@@&##&@@@@@@#~:::::::::::::::::.
53-
:::::::::::::::::::::7B@@@@@@@@@@@@#?::::::::::::::::::.
54-
.::::::::::::::::::::.^7YGB##BGY7^:.:::::::::::::::::.
55-
.:::::::::::::::::::::..::::..::::::::::::::::::..
56-
.....:...............................:.....
31+
`
32+
.:::::::::::::::::::::::::...::::::::::::::::::::.
33+
.::::::::::::::::::::.:^7J5PBGY!^::::::::::::::::::::.
34+
:::::::::::::::::::::~?J??5&@@@@@&G!~~~::::::::::::::::. WG Agent Configuration
35+
::::::::::::::::::::::^7&@@@@@@@@@@@@&&&G^:::::::::::::::. ------------------------------------------
36+
.::::::::::::::::::::::!J#@@@@@@@BBBGPPG7:::::::::::::::::. wg-iface: %s
37+
.:::::::::::::::::::::^?Y5#@@@@@@5^...::::::::::::::::::::: state: %s
38+
.::::::::::::::::::::::..:!7Y#@@@@@#Y~:.::::::::::::::::::. wg-listen-port: %d
39+
.:::::::::::::::::::.:^!?JYYJ?JG&@@@@@#7::::::::::::::::::. wg-use-userspace-implementation: %v
40+
.:::::::::::::::::.^J#@@@@@@@@@&#B&@@@@@G:::::::::::::::::. wg-userspace-implementation-fallback: %s
41+
.:::::::::::::::::J@@@@@@@@@@@@@@@&G@@@@@J.:::::::::::::::.
42+
.::::::::::::::::5@@@@@#?~~~7P@@@@@&B@@@@P.:::::::::::::::.
43+
.:::::::::::::::^@@@@@P..::::.~@@@@B&@@@@!::::::::::::::::.
44+
.:::::::::::::::~@@@@@J.::::::^@@@#&@@@@P:::::::::::::::::.
45+
.::::::::::::::::B@@@@@P!^:.:~G&&&@@@@@5::::::::::::::::::.
46+
.:::::::::::::::::G@@@@@&#BB&@@@@@@@@B~.::::::::::::::::::.
47+
.::::::::::::::::..~G&&&@@@@@@@@@&&&&&P^.:::::::::::::::::.
48+
.::::::::::::::.:~YGGY&@@@@@&GY7JB@@@@@@7:::::::::::::::::.
49+
.::::::::::::::?&@@@B&@@@@#!:..:::~B@@@@@~::::::::::::::::.
50+
.:::::::::::::J&#P5?5@@@@@:.::::::::&@@@@5.:::::::::::::::.
51+
.:::::::::::::^:....J@@@@@~.::::::.^@@@@@5.::::::::::::::::
52+
.::::::::::::::::::::&@@@@@Y~::::^J&@@@@&^::::::::::::::::.
53+
::::::::::::::::::::^B@@@@@@&##&@@@@@@#~:::::::::::::::::.
54+
:::::::::::::::::::::7B@@@@@@@@@@@@#?::::::::::::::::::.
55+
.::::::::::::::::::::.^7YGB##BGY7^:.:::::::::::::::::.
56+
.:::::::::::::::::::::..::::..::::::::::::::::::..
57+
.....:...............................:.....
5758
58-
/ \ / \/ _____/ / _ \ / ___\ ____ _____/ |_
59-
\ \/\/ / \ ___ / /_\ \ / /_/ _/ __ \ / \ __\
60-
\ /\ \_\ \ / | \\___ /\ ___/| | | |
61-
\__/\ / \______ / \____|__ /_____/ \___ |___| |__|
59+
/ \ / \/ _____/ / _ \ / ___\ ____ _____/ |_
60+
\ \/\/ / \ ___ / /_\ \ / /_/ _/ __ \ / \ __\
61+
\ /\ \_\ \ / | \\___ /\ ___/| | | |
62+
\__/\ / \______ / \____|__ /_____/ \___ |___| |__|
6263
\/ \/ \/ \/ \/
6364
`, iface, configFilePath, wireguardListenPort, wgUseUserspaceImpl, wgUserspaceImplementationFallback))
6465

0 commit comments

Comments
 (0)