Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ab2c9d068 | |||
| 098482a890 | |||
| 0a48a40796 | |||
| 3c24e24d71 | |||
| 45dc2291bf | |||
| b019d303d4 | |||
| f64f4e08fe | |||
| cf09cfa743 | |||
| 00cf3959a2 | |||
| 0db3e18227 | |||
| 0094450ca8 |
@@ -2,32 +2,34 @@ module git.jpi.io/amery/jpictl
|
||||
|
||||
go 1.19
|
||||
|
||||
replace asciigoat.org/ini => ../../../asciigoat.org/ini
|
||||
|
||||
require (
|
||||
asciigoat.org/ini v0.2.5
|
||||
darvaza.org/core v0.10.0
|
||||
darvaza.org/resolver v0.5.8
|
||||
darvaza.org/sidecar v0.0.8
|
||||
darvaza.org/slog v0.5.4
|
||||
darvaza.org/slog/handlers/discard v0.4.6
|
||||
darvaza.org/core v0.12.0
|
||||
darvaza.org/resolver v0.9.2
|
||||
darvaza.org/sidecar v0.4.0
|
||||
darvaza.org/slog v0.5.7
|
||||
darvaza.org/slog/handlers/discard v0.4.11
|
||||
github.com/gofrs/uuid/v5 v5.0.0
|
||||
github.com/hack-pad/hackpadfs v0.2.1
|
||||
github.com/libdns/cloudflare v0.1.0
|
||||
github.com/libdns/libdns v0.2.1
|
||||
github.com/mgechev/revive v1.3.4
|
||||
github.com/spf13/cobra v1.7.0
|
||||
golang.org/x/crypto v0.14.0
|
||||
golang.org/x/net v0.17.0
|
||||
gopkg.in/gcfg.v1 v1.2.3
|
||||
github.com/mgechev/revive v1.3.7
|
||||
github.com/spf13/cobra v1.8.0
|
||||
golang.org/x/crypto v0.20.0
|
||||
golang.org/x/net v0.21.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
asciigoat.org/core v0.3.9 // indirect
|
||||
darvaza.org/slog/handlers/filter v0.4.6 // indirect
|
||||
darvaza.org/slog/handlers/zerolog v0.4.6 // indirect
|
||||
darvaza.org/cache/x/simplelru v0.1.8 // indirect
|
||||
darvaza.org/slog/handlers/filter v0.4.9 // indirect
|
||||
darvaza.org/slog/handlers/zerolog v0.4.9 // indirect
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
github.com/chavacava/garif v0.1.0 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/fatih/color v1.16.0 // indirect
|
||||
github.com/fatih/structtag v1.2.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
@@ -35,18 +37,18 @@ require (
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.15 // indirect
|
||||
github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517 // indirect
|
||||
github.com/miekg/dns v1.1.56 // indirect
|
||||
github.com/miekg/dns v1.1.58 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/rivo/uniseg v0.4.4 // indirect
|
||||
github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97 // indirect
|
||||
github.com/rs/zerolog v1.31.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/rogpeppe/go-internal v1.11.0 // indirect
|
||||
github.com/rs/zerolog v1.32.0 // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
golang.org/x/mod v0.13.0 // indirect
|
||||
golang.org/x/sys v0.13.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
golang.org/x/tools v0.14.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
golang.org/x/mod v0.15.0 // indirect
|
||||
golang.org/x/sync v0.6.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/tools v0.18.0 // indirect
|
||||
)
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
asciigoat.org/core v0.3.9 h1:hgDDz4ecm3ZvehX++m8A/IzAt+B5oDPiRtxatzfUHPQ=
|
||||
asciigoat.org/core v0.3.9/go.mod h1:CAaHwyw8MpAq4a1MYtN2dxJrsK+hmIdW50OndaQZYPI=
|
||||
asciigoat.org/ini v0.2.5 h1:4gRIp9rU+XQt8+HMqZO5R7GavMv9Yl2+N+je6djDIAE=
|
||||
asciigoat.org/ini v0.2.5/go.mod h1:gmXzJ9XFqf1NLk5nQkj04USQ4tMtdRJHNQX6vp3DzjU=
|
||||
darvaza.org/core v0.10.0 h1:/nQOSWnMgWW8ZJmv3AEdTgIK+Pg4lkPd+VNejL84q3M=
|
||||
darvaza.org/core v0.10.0/go.mod h1:72iWMVoXjMHjsPSlctDzA7yKzwXsj5dO+se6F9B3ERs=
|
||||
darvaza.org/resolver v0.5.8 h1:y410WQ3vRCgE7437eyA55cNMZRP32qYXiokLejkFQeg=
|
||||
darvaza.org/resolver v0.5.8/go.mod h1:QnfX+eSZZZbmnE3n+6w4gfqXDH1Gj2MWJVQxhlQDHq8=
|
||||
darvaza.org/sidecar v0.0.8 h1:vsWK2SZfBYzU999brmT8gzVeCRKbuNQZOVdG5zxjO6U=
|
||||
darvaza.org/sidecar v0.0.8/go.mod h1:G96TMPge2jqpKMpaCWc9zwdfaJTmko7dMMWXwDsdocM=
|
||||
darvaza.org/slog v0.5.4 h1:xzlWVzYh4tuZLnj4A9tOHXfn/SAEIkApXPvK3YDiW9g=
|
||||
darvaza.org/slog v0.5.4/go.mod h1:QFtY3QoQ7xxww85umlEKPcMCNzqNrHYqnj53KehsmBU=
|
||||
darvaza.org/slog/handlers/discard v0.4.6 h1:TatHJn34y6eKQzNRHSo6lGZnJg4SLOGaWstlvwwOyrE=
|
||||
darvaza.org/slog/handlers/discard v0.4.6/go.mod h1:AG8WKr7m11NPPzvHW/b8nCT5RvYR9RZcIT/NWUOoMAo=
|
||||
darvaza.org/slog/handlers/filter v0.4.6 h1:AI5AQDyXS534QeXIV54pAKxplA6AVZNr4H2PEmAXT0k=
|
||||
darvaza.org/slog/handlers/filter v0.4.6/go.mod h1:MGTKdlnA/FanOn3GU2mltzwBn41HgSxxNeWUQEKFbl8=
|
||||
darvaza.org/slog/handlers/zerolog v0.4.6 h1:Di+FXUD2R2pKUrynaidyXzS0WsrEiwbL11LQlQzwZv4=
|
||||
darvaza.org/slog/handlers/zerolog v0.4.6/go.mod h1:r5B9/FQ256R3Wo5vFLOa2YarM2P8WOjVjFn8xHikNjk=
|
||||
darvaza.org/cache/x/simplelru v0.1.8 h1:rvFucut4wKYbsYc994yR3P0M08NqlsvZxr5G4QK82tw=
|
||||
darvaza.org/cache/x/simplelru v0.1.8/go.mod h1:Mv1isOJTcXYK+aK0AvUe+/3KpRTXDsYga6rdTS/upNs=
|
||||
darvaza.org/core v0.12.0 h1:LLtYh9RZJSd0sgPTDocofCc4H5jbutSUQgPbKt+8gcI=
|
||||
darvaza.org/core v0.12.0/go.mod h1:47Ydh67KnzjLNu1mzX3r2zpphbxQqEaihMsUq5GflQ4=
|
||||
darvaza.org/resolver v0.9.2 h1:sUX6LZ1eN5TzJW7L4m7HM+BvwBeWl8dYYDGVSe+AIhk=
|
||||
darvaza.org/resolver v0.9.2/go.mod h1:XWqPhrxoOKNzRuSozOwmE1M6QVqQL28jEdxylnIO8Nw=
|
||||
darvaza.org/sidecar v0.4.0 h1:wHghxzLsiT82WDBBUf34aTqtOvRBg4UbxVIJgKNXRVA=
|
||||
darvaza.org/sidecar v0.4.0/go.mod h1:fUzjcFM4rN3bSEl4BKvok3MLpZWEhEa9+0/egmtpfMY=
|
||||
darvaza.org/slog v0.5.7 h1:JWC0OqvzR435AidIRDp4T9kdWTURWkUjzP4R78Koq1Q=
|
||||
darvaza.org/slog v0.5.7/go.mod h1:12L03t+KYhsZ9IbfF+8if5w9Y91af2par+bSzeBVqIQ=
|
||||
darvaza.org/slog/handlers/discard v0.4.11 h1:wr34OnDoRaMV1eGgW7yUaupQxjkTnuHrJmYRPj64RHM=
|
||||
darvaza.org/slog/handlers/discard v0.4.11/go.mod h1:ynxyLmZzZ5mP4ACLhQs4MEuDyhkIzjz6DfBHUjhnIK4=
|
||||
darvaza.org/slog/handlers/filter v0.4.9 h1:xD8OBwlJytpiwTSDDZqUuNSOsJuaManXQiOj9WEStr8=
|
||||
darvaza.org/slog/handlers/filter v0.4.9/go.mod h1:t+sjcf1c46kAdf1TRiQmop91xlkteZrC4WDXoVwHgP8=
|
||||
darvaza.org/slog/handlers/zerolog v0.4.9 h1:08FjRnwRGtJsLLBnbgxVorb/bkgm5QEM/LXD2cxeCbM=
|
||||
darvaza.org/slog/handlers/zerolog v0.4.9/go.mod h1:PZYfx6eOxQfD+cXJQp52iwKgcD30QVYHoXxOCojAOdw=
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/chavacava/garif v0.1.0 h1:2JHa3hbYf5D9dsgseMKAmc/MZ109otzgNFk5s87H9Pc=
|
||||
github.com/chavacava/garif v0.1.0/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+UIPD+Gww=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
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=
|
||||
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
|
||||
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
||||
github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4=
|
||||
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
@@ -37,11 +37,8 @@ github.com/hack-pad/hackpadfs v0.2.1 h1:FelFhIhv26gyjujoA/yeFO+6YGlqzmc9la/6iKMI
|
||||
github.com/hack-pad/hackpadfs v0.2.1/go.mod h1:khQBuCEwGXWakkmq8ZiFUvUZz84ZkJ2KNwKvChs4OrU=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
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 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/libdns/cloudflare v0.1.0 h1:93WkJaGaiXCe353LHEP36kAWCUw0YjFqwhkBkU2/iic=
|
||||
@@ -60,10 +57,10 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ
|
||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517 h1:zpIH83+oKzcpryru8ceC6BxnoG8TBrhgAvRg8obzup0=
|
||||
github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517/go.mod h1:KQ7+USdGKfpPjXk4Ga+5XxQM4Lm4e3gAogrreFAYpOg=
|
||||
github.com/mgechev/revive v1.3.4 h1:k/tO3XTaWY4DEHal9tWBkkUMJYO/dLDVyMmAQxmIMDc=
|
||||
github.com/mgechev/revive v1.3.4/go.mod h1:W+pZCMu9qj8Uhfs1iJMQsEFLRozUfvwFwqVvRbSNLVw=
|
||||
github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE=
|
||||
github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY=
|
||||
github.com/mgechev/revive v1.3.7 h1:502QY0vQGe9KtYJ9FpxMz9rL+Fc/P13CI5POL4uHCcE=
|
||||
github.com/mgechev/revive v1.3.7/go.mod h1:RJ16jUbF0OWC3co/+XTxmFNgEpUPwnnA0BRllX2aDNA=
|
||||
github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4=
|
||||
github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
@@ -74,17 +71,19 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
||||
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/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
|
||||
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97 h1:3RPlVWzZ/PDqmVuf/FKHARG5EMid/tl7cv54Sw/QRVY=
|
||||
github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
|
||||
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
|
||||
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
|
||||
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
||||
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
||||
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
|
||||
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
|
||||
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
|
||||
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
|
||||
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=
|
||||
@@ -94,30 +93,26 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
|
||||
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
|
||||
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
|
||||
golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg=
|
||||
golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ=
|
||||
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA=
|
||||
golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
|
||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
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/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
|
||||
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
|
||||
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
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.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
|
||||
golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/gcfg.v1 v1.2.3 h1:m8OOJ4ccYHnx2f4gQwpno8nAX5OGOh7RLaaz0pj3Ogs=
|
||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
||||
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
+12
-47
@@ -2,10 +2,9 @@ package ceph
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"net/netip"
|
||||
"log"
|
||||
|
||||
"asciigoat.org/ini/basic"
|
||||
"asciigoat.org/ini/parser"
|
||||
|
||||
"darvaza.org/core"
|
||||
)
|
||||
@@ -36,61 +35,27 @@ func loadGlobalConfSection(out *Config, src *basic.Section) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// revive:disable:cyclomatic
|
||||
// revive:disable:cognitive-complexity
|
||||
|
||||
func loadGlobalConfField(cfg *GlobalConfig, field basic.Field) error {
|
||||
// revive:enable:cyclomatic
|
||||
// revive:enable:cognitive-complexity
|
||||
log.Printf("%s[%q] = %q", "global", field.Key, field.Value)
|
||||
|
||||
// TODO: refactor when asciigoat's ini parser learns to do reflection
|
||||
key, value := field.Key, field.Value
|
||||
|
||||
switch field.Key {
|
||||
switch key {
|
||||
case "fsid":
|
||||
if !core.IsZero(cfg.FSID) {
|
||||
return core.Wrap(fs.ErrInvalid, "duplicate field %q", field.Key)
|
||||
}
|
||||
|
||||
err := cfg.FSID.UnmarshalText([]byte(field.Value))
|
||||
switch {
|
||||
case err != nil:
|
||||
return core.Wrap(err, field.Key)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
return configFieldHandler(&cfg.FSID, key, value)
|
||||
case "mon_host":
|
||||
entries, _ := parser.SplitCommaArray(field.Value)
|
||||
for _, s := range entries {
|
||||
var addr netip.Addr
|
||||
|
||||
if err := addr.UnmarshalText([]byte(s)); err != nil {
|
||||
return core.Wrap(err, field.Key)
|
||||
}
|
||||
|
||||
cfg.MonitorsAddr = append(cfg.MonitorsAddr, addr)
|
||||
}
|
||||
return nil
|
||||
return configFieldHandler(&cfg.MonitorsAddr, key, value)
|
||||
case "mon_initial_members":
|
||||
entries, _ := parser.SplitCommaArray(field.Value)
|
||||
cfg.Monitors = append(cfg.Monitors, entries...)
|
||||
return nil
|
||||
return configFieldHandler(&cfg.Monitors, key, value)
|
||||
case "cluster_network":
|
||||
if !core.IsZero(cfg.ClusterNetwork) {
|
||||
err := core.Wrap(fs.ErrInvalid, "fields before the first section")
|
||||
return err
|
||||
}
|
||||
|
||||
err := cfg.ClusterNetwork.UnmarshalText([]byte(field.Value))
|
||||
switch {
|
||||
case err != nil:
|
||||
return core.Wrap(err, field.Key)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
return configFieldHandler(&cfg.ClusterNetwork, key, value)
|
||||
default:
|
||||
return core.Wrap(fs.ErrNotExist, "field %q unknown", key)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func configFieldHandler(vi any, key, value string) error
|
||||
|
||||
func newConfigFromDocument(doc *basic.Document) (*Config, error) {
|
||||
var out Config
|
||||
|
||||
|
||||
+87
-26
@@ -2,17 +2,25 @@ package cluster
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"path"
|
||||
"sort"
|
||||
|
||||
"darvaza.org/core"
|
||||
)
|
||||
|
||||
const (
|
||||
// ZoneRegionsFileName indicates the file containing
|
||||
// region names as references
|
||||
ZoneRegionsFileName = "regions"
|
||||
)
|
||||
|
||||
func (m *Cluster) scan(opts *ScanOptions) error {
|
||||
for _, fn := range []func(*ScanOptions) error{
|
||||
m.scanDirectory,
|
||||
m.scanMachines,
|
||||
m.scanZoneIDs,
|
||||
m.scanSort,
|
||||
m.initRegions,
|
||||
m.scanGateways,
|
||||
m.scanCephMonitors,
|
||||
} {
|
||||
@@ -24,7 +32,7 @@ func (m *Cluster) scan(opts *ScanOptions) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Cluster) scanDirectory(_ *ScanOptions) error {
|
||||
func (m *Cluster) scanDirectory(opts *ScanOptions) error {
|
||||
// each directory is a zone
|
||||
entries, err := fs.ReadDir(m.dir, ".")
|
||||
if err != nil {
|
||||
@@ -33,16 +41,14 @@ func (m *Cluster) scanDirectory(_ *ScanOptions) error {
|
||||
|
||||
for _, e := range entries {
|
||||
if e.IsDir() {
|
||||
z, err := m.newZone(e.Name())
|
||||
ok, err := m.scanSubdirectory(opts, e.Name())
|
||||
switch {
|
||||
case err != nil:
|
||||
return core.Wrap(err, e.Name())
|
||||
case z.Machines.Len() == 0:
|
||||
z.warn(nil).
|
||||
WithField("zone", z.Name).
|
||||
case !ok:
|
||||
m.warn(nil).
|
||||
WithField("zone", e.Name()).
|
||||
Print("empty")
|
||||
default:
|
||||
m.Zones = append(m.Zones, z)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +56,27 @@ func (m *Cluster) scanDirectory(_ *ScanOptions) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Cluster) scanSubdirectory(_ *ScanOptions, name string) (bool, error) {
|
||||
z, err := m.newZone(name)
|
||||
switch {
|
||||
case err != nil:
|
||||
// somewhere went wrong scanning the subdirectory
|
||||
return false, err
|
||||
case z.Machines.Len() > 0:
|
||||
// zones have machines and the regions they belong
|
||||
m.Zones = append(m.Zones, z)
|
||||
return true, nil
|
||||
case len(z.Regions) > 0:
|
||||
// regions have no machines but can include
|
||||
// other regions
|
||||
m.appendRegionRegions(name, z.Regions...)
|
||||
return true, nil
|
||||
default:
|
||||
// empty
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Cluster) newZone(name string) (*Zone, error) {
|
||||
z := &Zone{
|
||||
zones: m,
|
||||
@@ -154,34 +181,68 @@ func (z *Zone) scan() error {
|
||||
}
|
||||
|
||||
for _, e := range entries {
|
||||
if e.IsDir() {
|
||||
m := &Machine{
|
||||
zone: z,
|
||||
logger: z,
|
||||
Name: e.Name(),
|
||||
}
|
||||
name := e.Name()
|
||||
|
||||
m.debug().
|
||||
WithField("node", m.Name).
|
||||
switch {
|
||||
case name == ZoneRegionsFileName:
|
||||
err = z.loadRegions()
|
||||
case e.IsDir():
|
||||
err = z.scanSubdirectory(name)
|
||||
default:
|
||||
z.warn(nil).
|
||||
WithField("zone", z.Name).
|
||||
Print("found")
|
||||
WithField("filename", name).
|
||||
Print("unknown")
|
||||
}
|
||||
|
||||
if err := m.init(); err != nil {
|
||||
m.error(err).
|
||||
WithField("node", m.Name).
|
||||
WithField("zone", z.Name).
|
||||
Print()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
z.Machines = append(z.Machines, m)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (z *Zone) loadRegions() error {
|
||||
filename := path.Join(z.Name, ZoneRegionsFileName)
|
||||
regions, err := z.zones.ReadLines(filename)
|
||||
|
||||
if err == nil {
|
||||
// parsed
|
||||
err = z.appendRegions(regions...)
|
||||
if err != nil {
|
||||
err = core.Wrap(err, filename)
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (z *Zone) scanSubdirectory(name string) error {
|
||||
m := &Machine{
|
||||
zone: z,
|
||||
logger: z,
|
||||
Name: name,
|
||||
}
|
||||
|
||||
m.debug().
|
||||
WithField("node", m.Name).
|
||||
WithField("zone", z.Name).
|
||||
Print("found")
|
||||
|
||||
if err := m.init(); err != nil {
|
||||
m.error(err).
|
||||
WithField("node", m.Name).
|
||||
WithField("zone", z.Name).
|
||||
Print()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
z.Machines = append(z.Machines, m)
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetGateway returns the first gateway found, if none
|
||||
// files will be created to enable the first [Machine] to
|
||||
// be one
|
||||
|
||||
@@ -27,7 +27,7 @@ type ScanOptions struct {
|
||||
// the DNS resolver to get PublicAddresses of nodes.
|
||||
// Default is true
|
||||
func ResolvePublicAddresses(resolve bool) ScanOption {
|
||||
return func(m *Cluster, opt *ScanOptions) error {
|
||||
return func(_ *Cluster, opt *ScanOptions) error {
|
||||
opt.DontResolvePublicAddresses = !resolve
|
||||
return nil
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func ResolvePublicAddresses(resolve bool) ScanOption {
|
||||
// WithLookuper specifies what resolver.Lookuper to use to
|
||||
// find public addresses
|
||||
func WithLookuper(h resolver.Lookuper) ScanOption {
|
||||
return func(m *Cluster, opt *ScanOptions) error {
|
||||
return func(m *Cluster, _ *ScanOptions) error {
|
||||
if h == nil {
|
||||
return fs.ErrInvalid
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func WithLookuper(h resolver.Lookuper) ScanOption {
|
||||
// public addresses. if nil is passed, the [net.Resolver] will be used.
|
||||
// The default is using Cloudflare's 1.1.1.1.
|
||||
func WithResolver(h resolver.Resolver) ScanOption {
|
||||
return func(m *Cluster, opt *ScanOptions) error {
|
||||
return func(m *Cluster, _ *ScanOptions) error {
|
||||
if h == nil {
|
||||
h = resolver.SystemResolver(true)
|
||||
}
|
||||
|
||||
+100
-3
@@ -1,5 +1,10 @@
|
||||
package cluster
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var (
|
||||
_ MachineIterator = (*Region)(nil)
|
||||
_ ZoneIterator = (*Region)(nil)
|
||||
@@ -68,7 +73,7 @@ func (m *Cluster) initRegions(_ *ScanOptions) error {
|
||||
|
||||
// bind first level regions and their zones
|
||||
for name, zones := range regions {
|
||||
m.syncRegions(name, zones...)
|
||||
m.setRegionZones(name, zones...)
|
||||
}
|
||||
|
||||
// and combine zones to produce larger regions
|
||||
@@ -81,8 +86,10 @@ func (m *Cluster) initRegions(_ *ScanOptions) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Cluster) syncRegions(name string, zones ...*Zone) {
|
||||
for _, r := range m.Regions {
|
||||
func (m *Cluster) setRegionZones(name string, zones ...*Zone) {
|
||||
for i := range m.Regions {
|
||||
r := &m.Regions[i]
|
||||
|
||||
if r.Name == name {
|
||||
// found
|
||||
r.m = m
|
||||
@@ -99,6 +106,38 @@ func (m *Cluster) syncRegions(name string, zones ...*Zone) {
|
||||
})
|
||||
}
|
||||
|
||||
func (m *Cluster) appendRegionRegions(name string, subs ...string) {
|
||||
for i := range m.Regions {
|
||||
r := &m.Regions[i]
|
||||
|
||||
if name == r.Name {
|
||||
// found
|
||||
r.Regions = append(r.Regions, subs...)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// new
|
||||
m.Regions = append(m.Regions, Region{
|
||||
Name: name,
|
||||
Regions: subs,
|
||||
})
|
||||
}
|
||||
|
||||
func (z *Zone) appendRegions(regions ...string) error {
|
||||
for _, s := range regions {
|
||||
// TODO: validate
|
||||
z.debug().
|
||||
WithField("zone", z.Name).
|
||||
WithField("region", s).
|
||||
Print("attached")
|
||||
|
||||
z.Regions = append(z.Regions, s)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Cluster) finishRegion(r *Region) {
|
||||
if r.m != nil {
|
||||
// ready
|
||||
@@ -132,3 +171,61 @@ func (m *Cluster) getRegion(name string) (*Region, bool) {
|
||||
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// SyncRegions writes to the file system the regions this [Zone]
|
||||
// belongs to.
|
||||
func (z *Zone) SyncRegions() error {
|
||||
err := z.syncZoneRegions()
|
||||
if err == nil {
|
||||
z.ForEachMachine(func(p *Machine) bool {
|
||||
if p.IsActive() {
|
||||
err = p.RemoveFile("region")
|
||||
} else {
|
||||
err = p.WriteStringFile("none\n", "region")
|
||||
}
|
||||
return err != nil
|
||||
})
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (z *Zone) syncZoneRegions() error {
|
||||
name := filepath.Join(z.Name, "regions")
|
||||
|
||||
if len(z.Regions) > 0 {
|
||||
var buf bytes.Buffer
|
||||
|
||||
for _, s := range z.Regions {
|
||||
_, _ = buf.WriteString(s)
|
||||
_, _ = buf.WriteRune('\n')
|
||||
}
|
||||
|
||||
return z.zones.WriteStringFile(buf.String(), name)
|
||||
}
|
||||
|
||||
return z.zones.RemoveFile(name)
|
||||
}
|
||||
|
||||
// SyncRegions writes to the file system the regions covered
|
||||
// by this meta-region
|
||||
func (r *Region) SyncRegions() error {
|
||||
name := filepath.Join(r.Name, "regions")
|
||||
|
||||
if len(r.Regions) > 0 {
|
||||
var buf bytes.Buffer
|
||||
|
||||
for _, s := range r.Regions {
|
||||
_, _ = buf.WriteString(s)
|
||||
_, _ = buf.WriteRune('\n')
|
||||
}
|
||||
|
||||
if err := r.m.MkdirAll(r.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return r.m.WriteStringFile(buf.String(), name)
|
||||
}
|
||||
|
||||
return r.m.RemoveFile(name)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ func (m *Cluster) SyncAll() error {
|
||||
m.SyncMkdirAll,
|
||||
m.SyncAllWireguard,
|
||||
m.SyncAllCeph,
|
||||
m.SyncAllRegions,
|
||||
m.WriteHosts,
|
||||
} {
|
||||
if err := fn(); err != nil {
|
||||
@@ -58,3 +59,24 @@ func (m *Cluster) SyncAllCeph() error {
|
||||
|
||||
return m.WriteCephConfig(cfg)
|
||||
}
|
||||
|
||||
// SyncAllRegions rewrites all region data
|
||||
func (m *Cluster) SyncAllRegions() error {
|
||||
var err error
|
||||
|
||||
m.ForEachZone(func(z *Zone) bool {
|
||||
err := z.SyncRegions()
|
||||
return err != nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
m.ForEachRegion(func(r *Region) bool {
|
||||
err = r.SyncRegions()
|
||||
return err != nil
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
+10
-113
@@ -2,7 +2,6 @@ package wireguard
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/netip"
|
||||
@@ -10,8 +9,8 @@ import (
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"asciigoat.org/ini/basic"
|
||||
"darvaza.org/core"
|
||||
"gopkg.in/gcfg.v1"
|
||||
)
|
||||
|
||||
var configTemplate = template.Must(template.New("config").Funcs(template.FuncMap{
|
||||
@@ -79,7 +78,7 @@ type PeerConfig struct {
|
||||
Name string
|
||||
PublicKey PublicKey
|
||||
Endpoint EndpointAddress
|
||||
AllowedIPs []netip.Prefix
|
||||
AllowedIPs []netip.Prefix `ini:",comma"`
|
||||
}
|
||||
|
||||
// EndpointAddress is a host:port pair to reach the Peer
|
||||
@@ -132,100 +131,6 @@ func (ep *EndpointAddress) FromString(s string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type intermediateConfig struct {
|
||||
Interface interfaceConfig
|
||||
Peer peersConfig
|
||||
}
|
||||
|
||||
func (v *intermediateConfig) Export() (*Config, error) {
|
||||
var out Config
|
||||
var err error
|
||||
|
||||
// Interface
|
||||
out.Interface, err = v.Interface.Export()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Peers
|
||||
peers, ok := v.PeersCount()
|
||||
if !ok {
|
||||
return nil, errors.New("inconsistent Peer data")
|
||||
}
|
||||
|
||||
for i := 0; i < peers; i++ {
|
||||
p, err := v.ExportPeer(i)
|
||||
if err != nil {
|
||||
err = core.Wrap(err, "Peer[%v]:", i)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out.Peer = append(out.Peer, p)
|
||||
}
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
type interfaceConfig struct {
|
||||
Address netip.Addr
|
||||
PrivateKey string
|
||||
ListenPort uint16
|
||||
}
|
||||
|
||||
func (p interfaceConfig) Export() (InterfaceConfig, error) {
|
||||
var err error
|
||||
|
||||
out := InterfaceConfig{
|
||||
Address: p.Address,
|
||||
ListenPort: p.ListenPort,
|
||||
}
|
||||
|
||||
if p.PrivateKey != "" {
|
||||
out.PrivateKey, err = PrivateKeyFromBase64(p.PrivateKey)
|
||||
if err != nil {
|
||||
err = core.Wrap(err, "PrivateKey")
|
||||
return InterfaceConfig{}, err
|
||||
}
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
type peersConfig struct {
|
||||
PublicKey []string
|
||||
Endpoint []string
|
||||
AllowedIPs []string
|
||||
}
|
||||
|
||||
func (v *intermediateConfig) ExportPeer(i int) (PeerConfig, error) {
|
||||
var out PeerConfig
|
||||
|
||||
// Endpoint
|
||||
s := v.Peer.Endpoint[i]
|
||||
err := out.Endpoint.FromString(s)
|
||||
if err != nil {
|
||||
err = core.Wrap(err, "Endpoint")
|
||||
return out, err
|
||||
}
|
||||
|
||||
// PublicKey
|
||||
out.PublicKey, err = PublicKeyFromBase64(v.Peer.PublicKey[i])
|
||||
if err != nil {
|
||||
err = core.Wrap(err, "PublicKey")
|
||||
return out, err
|
||||
}
|
||||
|
||||
// AllowedIPs
|
||||
s = v.Peer.AllowedIPs[i]
|
||||
out.AllowedIPs, err = parseAllowedIPs(s)
|
||||
if err != nil {
|
||||
err = core.Wrap(err, "AllowedIPs")
|
||||
return out, err
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func parseAllowedIPs(data string) ([]netip.Prefix, error) {
|
||||
var out []netip.Prefix
|
||||
|
||||
@@ -242,25 +147,17 @@ func parseAllowedIPs(data string) ([]netip.Prefix, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (v *intermediateConfig) PeersCount() (int, bool) {
|
||||
c0 := len(v.Peer.Endpoint)
|
||||
c1 := len(v.Peer.PublicKey)
|
||||
c2 := len(v.Peer.AllowedIPs)
|
||||
|
||||
if c0 != c1 || c1 != c2 {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
return c0, true
|
||||
}
|
||||
|
||||
// NewConfigFromReader parses a wgN.conf file
|
||||
func NewConfigFromReader(r io.Reader) (*Config, error) {
|
||||
temp := &intermediateConfig{}
|
||||
|
||||
if err := gcfg.ReadInto(temp, r); err != nil {
|
||||
doc, err := basic.Decode(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return temp.Export()
|
||||
cfg, err := newConfigFromDocument(doc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package wireguard
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"log"
|
||||
|
||||
"asciigoat.org/ini/basic"
|
||||
"darvaza.org/core"
|
||||
)
|
||||
|
||||
type sectionHandler func(*Config, *basic.Section) error
|
||||
|
||||
var sectionMap = map[string]func(*Config, *basic.Section) error{
|
||||
"Interface": loadInterfaceConfSection,
|
||||
"Peer": loadPeerConfSection,
|
||||
}
|
||||
|
||||
func loadConfSection(out *Config, src *basic.Section) error {
|
||||
h, ok := sectionMap[src.Key]
|
||||
if !ok {
|
||||
return core.Wrap(fs.ErrInvalid, "unknown section %q", src.Key)
|
||||
}
|
||||
|
||||
return h(out, src)
|
||||
}
|
||||
|
||||
func loadInterfaceConfSection(out *Config, src *basic.Section) error {
|
||||
var cfg InterfaceConfig
|
||||
|
||||
for _, field := range src.Fields {
|
||||
if err := loadInterfaceConfField(&cfg, field); err != nil {
|
||||
return core.Wrap(err, "Interface")
|
||||
}
|
||||
}
|
||||
|
||||
out.Interface = cfg
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadPeerConfSection(out *Config, src *basic.Section) error {
|
||||
var cfg PeerConfig
|
||||
|
||||
for _, field := range src.Fields {
|
||||
if err := loadPeerConfField(&cfg, field); err != nil {
|
||||
return core.Wrap(err, "Peer[%v]", len(out.Peer))
|
||||
}
|
||||
}
|
||||
|
||||
out.Peer = append(out.Peer, cfg)
|
||||
return nil
|
||||
}
|
||||
|
||||
func configFieldHandler(vi any, key, value string) error
|
||||
|
||||
func loadInterfaceConfField(cfg *InterfaceConfig, field basic.Field) error {
|
||||
log.Printf("%s[%q] = %q", "Interface", field.Key, field.Value)
|
||||
|
||||
key, value := field.Key, field.Value
|
||||
|
||||
switch key {
|
||||
case "Address":
|
||||
return configFieldHandler(&cfg.Address, key, value)
|
||||
case "PrivateKey":
|
||||
return configFieldHandler(&cfg.PrivateKey, key, value)
|
||||
case "ListenPort":
|
||||
return configFieldHandler(&cfg.ListenPort, key, value)
|
||||
default:
|
||||
return core.Wrap(fs.ErrInvalid, "unknown field %q", key)
|
||||
}
|
||||
}
|
||||
|
||||
func loadPeerConfField(cfg *PeerConfig, field basic.Field) error {
|
||||
log.Printf("%s[%q] = %q", "Peer", field.Key, field.Value)
|
||||
|
||||
key, value := field.Key, field.Value
|
||||
|
||||
switch key {
|
||||
case "PublicKey":
|
||||
return configFieldHandler(&cfg.PublicKey, key, value)
|
||||
case "Endpoint":
|
||||
return configFieldHandler(&cfg.Endpoint, key, value)
|
||||
case "AllowedIPs":
|
||||
return configFieldHandler(&cfg.AllowedIPs, key, value)
|
||||
default:
|
||||
return core.Wrap(fs.ErrInvalid, "unknown field %q", field.Key)
|
||||
}
|
||||
}
|
||||
|
||||
func newConfigFromDocument(doc *basic.Document) (*Config, error) {
|
||||
var out Config
|
||||
|
||||
if len(doc.Global) > 0 {
|
||||
err := core.Wrap(fs.ErrInvalid, "fields before the first section")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i := range doc.Sections {
|
||||
src := &doc.Sections[i]
|
||||
if err := loadConfSection(&out, src); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
Reference in New Issue
Block a user