From 67c7bee093dcf129bea60ad807b9af7622d38b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20P=C3=BCschel?= Date: Sat, 16 Nov 2024 14:26:17 +0100 Subject: [PATCH 1/3] upgrade minimum Go version to 1.22 and upgrade dependencies Upgrade minimum Go version to 1.22 to allow upgrading to the latest etcd version, which requires 1.22 . Also update all other direct dependencies. --- .github/workflows/build.yml | 2 +- go.mod | 24 +++++++++-------- go.sum | 51 ++++++++++++++++++------------------- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db821f8..540f5b0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.19' + go-version: '1.22' - uses: actions/checkout@v4 diff --git a/go.mod b/go.mod index 80dc47c..57e1d66 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,12 @@ module github.com/ffbs/etcd-tools -go 1.19 +go 1.22 + +toolchain go1.22.9 require ( - github.com/spf13/cobra v1.8.0 - go.etcd.io/etcd/client/v3 v3.5.11 + github.com/spf13/cobra v1.8.1 + go.etcd.io/etcd/client/v3 v3.5.17 go.seankhliao.com/signify v0.0.0-20200507101447-944db0e32d56 golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 ) @@ -14,7 +16,7 @@ require ( github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/ebfe/bcrypt_pbkdf v0.0.0-20140212075826-3c8d2dcb253a // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/native v1.1.0 // indirect @@ -22,20 +24,20 @@ require ( github.com/mdlayher/netlink v1.7.2 // indirect github.com/mdlayher/socket v0.4.1 // indirect github.com/spf13/pflag v1.0.5 // indirect - go.etcd.io/etcd/api/v3 v3.5.11 // indirect - go.etcd.io/etcd/client/pkg/v3 v3.5.11 // indirect + go.etcd.io/etcd/api/v3 v3.5.17 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.5.17 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.17.0 // indirect - golang.org/x/crypto v0.14.0 // indirect - golang.org/x/net v0.17.0 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b // indirect google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/grpc v1.59.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect ) diff --git a/go.sum b/go.sum index 8a3e69d..c2042db 100644 --- a/go.sum +++ b/go.sum @@ -2,7 +2,7 @@ github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmf github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -11,10 +11,8 @@ github.com/ebfe/bcrypt_pbkdf v0.0.0-20140212075826-3c8d2dcb253a/go.mod h1:/CZpbh github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= 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/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -30,27 +28,29 @@ github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U= github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA= github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721 h1:RlZweED6sbSArvlE924+mUcZuXKLBHA35U7LN621Bws= +github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721/go.mod h1:Ickgr2WtCLZ2MDGd4Gr0geeCH5HybhRJbonOgQpvSxc= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.etcd.io/etcd/api/v3 v3.5.11 h1:B54KwXbWDHyD3XYAwprxNzTe7vlhR69LuBgZnMVvS7E= -go.etcd.io/etcd/api/v3 v3.5.11/go.mod h1:Ot+o0SWSyT6uHhA56al1oCED0JImsRiU9Dc26+C2a+4= -go.etcd.io/etcd/client/pkg/v3 v3.5.11 h1:bT2xVspdiCj2910T0V+/KHcVKjkUrCZVtk8J2JF2z1A= -go.etcd.io/etcd/client/pkg/v3 v3.5.11/go.mod h1:seTzl2d9APP8R5Y2hFL3NVlD6qC/dOT+3kvrqPyTas4= -go.etcd.io/etcd/client/v3 v3.5.11 h1:ajWtgoNSZJ1gmS8k+icvPtqsqEav+iUorF7b0qozgUU= -go.etcd.io/etcd/client/v3 v3.5.11/go.mod h1:a6xQUEqFJ8vztO1agJh/KQKOMfFI8og52ZconzcDJwE= +go.etcd.io/etcd/api/v3 v3.5.17 h1:cQB8eb8bxwuxOilBpMJAEo8fAONyrdXTHUNcMd8yT1w= +go.etcd.io/etcd/api/v3 v3.5.17/go.mod h1:d1hvkRuXkts6PmaYk2Vrgqbv7H4ADfAKhyJqHNLJCB4= +go.etcd.io/etcd/client/pkg/v3 v3.5.17 h1:XxnDXAWq2pnxqx76ljWwiQ9jylbpC4rvkAeRVOUKKVw= +go.etcd.io/etcd/client/pkg/v3 v3.5.17/go.mod h1:4DqK1TKacp/86nJk4FLQqo6Mn2vvQFBmruW3pP14H/w= +go.etcd.io/etcd/client/v3 v3.5.17 h1:o48sINNeWz5+pjy/Z0+HKpj/xSnBkuVhVvXkjEXbqZY= +go.etcd.io/etcd/client/v3 v3.5.17/go.mod h1:j2d4eXTHWkT2ClBgnnEPm/Wuu7jsqku41v9DZ3OtjQo= go.seankhliao.com/signify v0.0.0-20200507101447-944db0e32d56 h1:cxKBAD60IIoTj/HhIXiV7sFuETeRBswEpXfk/app5gA= go.seankhliao.com/signify v0.0.0-20200507101447-944db0e32d56/go.mod h1:znWJjz3zy8V4//AaXXYKk7fp6NZrKOmHGbVmL15wwbU= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= @@ -62,16 +62,16 @@ go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -80,12 +80,12 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -106,13 +106,12 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From 375dbb2a90d96d22f5a1aa7b6fbab82202e1e774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20P=C3=BCschel?= Date: Sat, 16 Nov 2024 16:22:08 +0100 Subject: [PATCH 2/3] concentratorconfig/etcdconfigweb: add cobra arg parsing Add cobra argument parsing to concentratorconfig and etcdconfigweb to show the available configuration options to the user. Also allow changing some hardcoded values/paths using command line arguments. --- concentratorconfig/main.go | 81 ++++++++++++++++++++++---------- etcdconfigweb/main.go | 58 ++++++++++++++++------- etcdutility/cmd_showoverrides.go | 13 +++-- ffbs/etcd.go | 4 +- 4 files changed, 110 insertions(+), 46 deletions(-) diff --git a/concentratorconfig/main.go b/concentratorconfig/main.go index a2f86f3..2ff928c 100644 --- a/concentratorconfig/main.go +++ b/concentratorconfig/main.go @@ -6,8 +6,9 @@ If an error occurs, it will print it and won't update any node. Pass the simulate argument to only show the wireguard interface changes that would be applied. When it is started this way, it exits after printing the changes. -The program expects a fixed Wireguard interface name (see [WG_DEVICENAME]) and -an etcd configuration file at a fixed location (see [github.com/ffbs/etcd-tools/ffbs.CreateEtcdConnection]). +The program expects by default a Wireguard interface named "wg-nodes" +and an etcd configuration file at "/etc/etcd-client.json". +These can be changed using command line flags. */ package main @@ -24,12 +25,11 @@ import ( "github.com/ffbs/etcd-tools/ffbs" + "github.com/spf13/cobra" "golang.zx2c4.com/wireguard/wgctrl" "golang.zx2c4.com/wireguard/wgctrl/wgtypes" ) -const WG_DEVICENAME = "wg-nodes" - func sortIPNet(s []net.IPNet) { sort.Slice(s, func(i, j int) bool { res := bytes.Compare(s[i].IP[:], s[j].IP[:]) @@ -41,17 +41,12 @@ func sortIPNet(s []net.IPNet) { }) } -func calculateWGPeerUpdates(etcd *ffbs.EtcdHandler, wg *wgctrl.Client) ([]wgtypes.PeerConfig, error) { +func calculateWGPeerUpdates(etcd *ffbs.EtcdHandler, dev *wgtypes.Device) ([]wgtypes.PeerConfig, error) { nodes, defNode, err := etcd.GetAllNodeInfo(context.Background()) if err != nil { return nil, err } - dev, err := wg.Device(WG_DEVICENAME) - if err != nil { - return nil, err - } - updates := make([]wgtypes.PeerConfig, 0, 10) // remove and update existing nodes @@ -139,18 +134,15 @@ func calculateWGPeerUpdates(etcd *ffbs.EtcdHandler, wg *wgctrl.Client) ([]wgtype return updates, nil } -func main() { - simulate := false - if len(os.Args) > 1 { - switch os.Args[1] { - case "simulate": - simulate = true - default: - log.Fatalln("unknown arguments. Currently only 'simulate' is supported") - } - } +type CLIConfig struct { + EtcdConfig string + UpdateInterval time.Duration + WGDeviceName string + Simulate bool +} - etcd, err := ffbs.CreateEtcdConnection() +func run(config *CLIConfig) { + etcd, err := ffbs.CreateEtcdConnection(config.EtcdConfig) if err != nil { log.Fatalln("Couldn't setup etcd connection:", err) } @@ -163,12 +155,18 @@ func main() { for { // misusing a loop to break at any moment and still run the sleep call for { - updates, err := calculateWGPeerUpdates(etcd, wg) + dev, err := wg.Device(config.WGDeviceName) + if err != nil { + log.Println("Error getting Wireguard device", config.WGDeviceName, "and got error:", err) + break + } + + updates, err := calculateWGPeerUpdates(etcd, dev) if err != nil { log.Println("Error trying to determine the node updates:", err) break } - if simulate { + if config.Simulate { fmt.Printf("Peer updates: %v\n", updates) return } @@ -176,13 +174,46 @@ func main() { break } - if err := wg.ConfigureDevice(WG_DEVICENAME, wgtypes.Config{Peers: updates}); err != nil { + if err := wg.ConfigureDevice(config.WGDeviceName, wgtypes.Config{Peers: updates}); err != nil { log.Println("Error trying to apply the node updates:", err) break } log.Println("Updated", len(updates), "peers") break } - time.Sleep(60 * time.Second) + time.Sleep(config.UpdateInterval) + } +} + +func main() { + var config CLIConfig + + rootCmd := &cobra.Command{ + Use: "concentratorconfig", + Short: "Configure the Wireguard interface based on the etcd KV configuration", + Run: func(cmd *cobra.Command, args []string) { + run(&config) + }, + } + + rootCmd.PersistentFlags().StringVarP(&config.EtcdConfig, "etcdconfig", "e", "/etc/etcd-client.json", "Path to the etcd client configuration file") + rootCmd.MarkFlagFilename("etcdconfig", "json") + rootCmd.PersistentFlags().DurationVarP(&config.UpdateInterval, "interval", "i", 60*time.Second, "Interval to update the wireguard configuration from the etcd store") + rootCmd.PersistentFlags().StringVarP(&config.WGDeviceName, "devicename", "d", "wg-nodes", "Wireguard device name to update the configuration") + + simulateCmd := &cobra.Command{ + Use: "simulate", + Short: "Simulate updating of the wireguard devices, but don't apply them", + Run: func(cmd *cobra.Command, args []string) { + config.Simulate = true + run(&config) + }, + } + + rootCmd.AddCommand(simulateCmd) + + if err := rootCmd.Execute(); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) } } diff --git a/etcdconfigweb/main.go b/etcdconfigweb/main.go index afb893d..a891da7 100644 --- a/etcdconfigweb/main.go +++ b/etcdconfigweb/main.go @@ -1,12 +1,10 @@ /* etcdconfigweb provides an http interface to query and register nodes from the etcd KV store. -By default it will listen on port 8080 on any interface. You can change this by passing an argument -like ":1234", which would configure to listen on port 1234 on any interface or "127.0.0.1:1234" to only listen -on the IPv4 local address "127.0.0.1" on port "1234". - -It expects an etcd configuration file at a fixed location (see [github.com/ffbs/etcd-tools/ffbs.CreateEtcdConnection]) -and a signify private key to sign the requests at "/etc/ffbs/node-config.sec" +By default it will listen on port 8080 on any interface. +It expects an etcd configuration file (by default at "/etc/etcd-client.json") +and a signify private key to sign the requests (by default at "/etc/ffbs/node-config.sec"). +You can change these settings using command line options. As it doesn't need any root capabilities, it should be considered to run this executable as a normal user. @@ -17,25 +15,29 @@ The HTTP server supports two endpoints: package main import ( + "fmt" "log" "net/http" "os" "github.com/ffbs/etcd-tools/ffbs" + + "github.com/spf13/cobra" ) -func main() { - etcd, err := ffbs.CreateEtcdConnection() +type CLIConfig struct { + ListenAddr string + Key string + EtcdConfig string +} + +func run(config *CLIConfig) { + etcd, err := ffbs.CreateEtcdConnection(config.EtcdConfig) if err != nil { log.Fatalln("Couldn't setup etcd connection: ", err) } - servingAddr := ":8080" - if len(os.Args) > 1 { - servingAddr = os.Args[1] - } - - signer, err := NewSignifySignerFromPrivateKeyFile("/etc/ffbs/node-config.sec") + signer, err := NewSignifySignerFromPrivateKeyFile(config.Key) if err != nil { log.Fatalln("Couldn't parse signify private key:", err) } @@ -45,6 +47,30 @@ func main() { http.Handle("/config", &ConfigHandler{tracker: metrics, signer: signer, etcdHandler: etcd}) http.Handle("/etcd_status", metrics) - log.Println("Starting server on", servingAddr) - log.Fatal("Error running webserver:", http.ListenAndServe(servingAddr, nil)) + log.Println("Starting server on", config.ListenAddr) + log.Fatal("Error running webserver:", http.ListenAndServe(config.ListenAddr, nil)) +} + +func main() { + var config CLIConfig + + rootCmd := &cobra.Command{ + Use: "etcdconfigweb", + Short: "Provide an HTTP interface to query and register nodes from the etcd KV store", + Args: cobra.NoArgs, + Run: func(cmd *cobra.Command, args []string) { + run(&config) + }, + } + + rootCmd.PersistentFlags().StringVarP(&config.ListenAddr, "listen", "l", ":8080", "HTTP listening address to bind to") + rootCmd.PersistentFlags().StringVarP(&config.Key, "key", "k", "/etc/ffbs/node-config.sec", "Path to signify private key file to sign responses") + rootCmd.MarkFlagFilename("key", "sec") + rootCmd.PersistentFlags().StringVarP(&config.EtcdConfig, "etcdconfig", "e", "/etc/etcd-client.json", "Path to the etcd client configuration file") + rootCmd.MarkFlagFilename("etcdconfig", "json") + + if err := rootCmd.Execute(); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } } diff --git a/etcdutility/cmd_showoverrides.go b/etcdutility/cmd_showoverrides.go index 31d7808..cbc799c 100644 --- a/etcdutility/cmd_showoverrides.go +++ b/etcdutility/cmd_showoverrides.go @@ -12,17 +12,24 @@ import ( ) func init() { + var etcdConfig string + cmd := &cobra.Command{ Use: "showoverrides", Short: "Shows all Pubkeys overriding a default value", - Run: showoverrides, + Run: func(cmd *cobra.Command, args []string) { + showoverrides(etcdConfig) + }, } + cmd.PersistentFlags().StringVarP(&etcdConfig, "etcdconfig", "e", "/etc/etcd-client.json", "Path to the etcd client configuration file") + cmd.MarkFlagFilename("etcdconfig", "json") + rootCmd.AddCommand(cmd) } -func showoverrides(cmd *cobra.Command, args []string) { - etcd, err := ffbs.CreateEtcdConnection() +func showoverrides(etcdConfig string) { + etcd, err := ffbs.CreateEtcdConnection(etcdConfig) if err != nil { log.Fatalln("Couldn't setup etcd connection:", err) } diff --git a/ffbs/etcd.go b/ffbs/etcd.go index 97d6185..177a874 100644 --- a/ffbs/etcd.go +++ b/ffbs/etcd.go @@ -25,8 +25,8 @@ type EtcdConfigFile struct { // This function will only allow the configured CACert and // ignores system root certificate authorities when connecting // to the etcd server. -func CreateEtcdConnection() (*EtcdHandler, error) { - f, err := os.Open("/etc/etcd-client.json") +func CreateEtcdConnection(configFile string) (*EtcdHandler, error) { + f, err := os.Open(configFile) if err != nil { return nil, err } From fcde0ffd2024717fd2056ddc6ce599acf9cbf152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20P=C3=BCschel?= Date: Sat, 16 Nov 2024 17:04:49 +0100 Subject: [PATCH 3/3] test the IP address and subnet generation Test the IP address and subnet generation to avoid breaking the existing generation when updating or refactoring it. Given that the subnet generation uses some binary operations, it is hard to spot potential errors. For this usecase the function generating the subnet was externalized to be accessible from the test code instead of an inlined function. --- .github/workflows/build.yml | 3 ++- etcdconfigweb/config.go | 50 +++++++++++++++++++----------------- etcdconfigweb/config_test.go | 31 ++++++++++++++++++++++ go.mod | 4 +++ go.sum | 1 + 5 files changed, 64 insertions(+), 25 deletions(-) create mode 100644 etcdconfigweb/config_test.go diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 540f5b0..9ff5789 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,8 +20,9 @@ jobs: git diff --exit-code go vet ./... - - name: Build project + - name: Build and test project run: | + go test ./... mkdir bin GOBIN="$PWD/bin" CGO_ENABLED=0 go install ./... diff --git a/etcdconfigweb/config.go b/etcdconfigweb/config.go index d974903..a2b91c4 100644 --- a/etcdconfigweb/config.go +++ b/etcdconfigweb/config.go @@ -34,6 +34,31 @@ var MISSING_V6MTU = errors.New("Missing v6mtu query parameter") var MISSING_PUBKEY = errors.New("Missing pubkey query parameter") var MISSING_NONCE = errors.New("Missing nonce query parameter") +func generateNodeAddressesAndRanges(info *ffbs.NodeInfo) { + const V4_BASE uint32 = 10 << 24 + const V4_RANGE_SIZE uint8 = 10 + const V6_BASE_HIGH uint64 = 0x20010bf70381 << 16 + + num := *info.ID + + var v4Addr [net.IPv4len]byte + binary.BigEndian.PutUint32(v4Addr[:], V4_BASE|(uint32(num)< 22-8 = 14 bits of freedom + id := uint64(16383) + node := ffbs.NodeInfo{ID: &id} + generateNodeAddressesAndRanges(&node) + assert.Equal(t, "10.255.252.1", *node.Address4) + assert.Equal(t, "10.255.252.0/22", *node.Range4) + assert.Equal(t, "2001:bf7:381:3fff::1", *node.Address6) + assert.Equal(t, "2001:bf7:381:3fff::/64", *node.Range6) +} diff --git a/go.mod b/go.mod index 57e1d66..b70dbf5 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ toolchain go1.22.9 require ( github.com/spf13/cobra v1.8.1 + github.com/stretchr/testify v1.9.0 go.etcd.io/etcd/client/v3 v3.5.17 go.seankhliao.com/signify v0.0.0-20200507101447-944db0e32d56 golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 @@ -14,6 +15,7 @@ require ( require ( github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/ebfe/bcrypt_pbkdf v0.0.0-20140212075826-3c8d2dcb253a // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.4 // indirect @@ -23,6 +25,7 @@ require ( github.com/mdlayher/genetlink v1.3.2 // indirect github.com/mdlayher/netlink v1.7.2 // indirect github.com/mdlayher/socket v0.4.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spf13/pflag v1.0.5 // indirect go.etcd.io/etcd/api/v3 v3.5.17 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.17 // indirect @@ -40,4 +43,5 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/grpc v1.59.0 // indirect google.golang.org/protobuf v1.33.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index c2042db..2596a95 100644 --- a/go.sum +++ b/go.sum @@ -108,6 +108,7 @@ google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=