Commit Graph

129 Commits

Author SHA1 Message Date
kaiyou a0882dad49 Use the custom etc/hosts banner 2020-05-27 23:26:29 +02:00
kaiyou f1de2def7f Add Banner and StatePath settings
Banner is used to carry a custom etc/hosts banner while StatePath holds
the path to cluster state storage.
2020-05-27 23:26:29 +02:00
Leo Antunes 7910b5c379 ci: add MIPS* arches to releases; bump go 1.14.3
refs #47
2020-05-27 17:49:10 +02:00
kaiyou 61988692a1 Parse arguments in the tests entrypoint
Add an argument parsing routine to the tests entrypoint, and use it
to parse the interface name, passed to
wireguard-go.
2020-05-21 10:17:48 +02:00
Leo Antunes 2fe308cd1d tests: fix e2e image build 2020-05-19 23:00:54 +02:00
kaiyou 49c0d7f802 Make statePath a variable (temporary)
This is a temporary fix until the state path is made
configurable.
2020-05-13 13:52:54 +02:00
kaiyou 66b0321bf7 Fail more explicitely in cluster state tests
Co-authored-by: Leo Antunes <leo@costela.net>
2020-05-13 13:52:54 +02:00
kaiyou e9b9239eae Reinstante cluster.LocalNode
This makes for more straightforward calls. Also, generate
the localNode directly in wg.New.
2020-05-13 13:52:54 +02:00
kaiyou a0aa0bcc0e Fix unit tests due to unexported assignOverlayAddr 2020-05-13 13:52:54 +02:00
kaiyou 5b6923c272 Unexporter AssignOverlayAddress
Instead, the overlay address is assigned upon creation.
Also, the wireguard state is responsible for populating
the local node object.
2020-05-13 13:52:54 +02:00
kaiyou c50011bc36 Use errors.Wrap instead of manual formatting 2020-05-13 13:52:54 +02:00
kaiyou 32a300ffeb Rename node.Decode and node.Encode
EncodeMeta and DecodeMeta are more explicit.
2020-05-13 13:52:54 +02:00
kaiyou 078946dbdd Use localNode to store the local node name
Also rename setupDelegate to SetLocalNode, so that
main can call SetLocalNode then Update().
2020-05-13 13:52:54 +02:00
kaiyou 28a31efc1f Rename saveState to state.save 2020-05-13 13:52:54 +02:00
kaiyou d85fb84398 Unexport state from the cluster package 2020-05-13 13:52:54 +02:00
kaiyou 9ddcbb7914 Apply suggestions from code review
Review suggestions in the documentation

Co-authored-by: Leo Antunes <leo@costela.net>
2020-05-13 13:52:54 +02:00
kaiyou faf1c35d96 Implement the delegate interface on Node
Implementing on Node makes a bit more sense than implementing on Cluster
even if the difference in code is insignificant.
2020-05-13 13:52:54 +02:00
kaiyou f715cfa787 Remove the unneeded writeToEtcHosts function 2020-05-13 13:52:54 +02:00
kaiyou 61104a9272 Add some comments to the main function 2020-05-13 13:52:54 +02:00
kaiyou b0e41d5c35 Rename WgState to State and NewWgState to New
This also caused renaming local variables to avoid
conflicting with the wg package name itself.
2020-05-13 13:52:54 +02:00
kaiyou 5d1acc1fab Add documentation to public functions and types 2020-05-13 13:52:54 +02:00
kaiyou 3a882eb112 Generate the local node directly in main.go
Instead of using a trivial function, simply generate the
local node from main.go, manually assign fields from the
nodeMeta struct.
2020-05-13 13:52:54 +02:00
kaiyou 0162f9da2c Add unit tests for state functions
Currently unit tests only succeed if the state path
is writeable, since it is hardcoded.
2020-05-13 13:52:54 +02:00
kaiyou 13e1515f7d Split cluster into multiple files 2020-05-13 13:52:54 +02:00
kaiyou 622cfce1ad Add unit tests for node encoding/decoding 2020-05-13 13:52:54 +02:00
kaiyou 46da51b7aa Implement node function as type functions
This means nodeMeta can be private again, and also makes it
easier to pass a Node object to the cluster for local meta,
instead of a generic byte[] function.

For later updating, that node is passed using Update() instead
of New().
2020-05-13 13:52:54 +02:00
kaiyou dadfbee083 Split the application into modules
Splitting into modules will help keep concerns separate,
at the cost of a slightly more verbose code.
2020-05-13 13:52:54 +02:00
kaiyou 740a9c44c6 Update dependencies 2020-05-13 13:52:54 +02:00
kaiyou a5a55e9447 Properly wrap errors from config.go
Co-authored-by: Leo Antunes <leo@costela.net>
2020-05-13 13:52:54 +02:00
kaiyou 7adb944f92 Properly wrap errors from config.go
Co-authored-by: Leo Antunes <leo@costela.net>
2020-05-13 13:52:54 +02:00
kaiyou bce8a0451a Move the bindAddress computation to config parsing 2020-05-13 13:52:54 +02:00
kaiyou 9fdab65237 Revert "Move the metadata parsing code to node.go"
This reverts commit ac6289b5bf95e8903ea90ddf807832a2358371b0.
2020-05-13 13:52:54 +02:00
kaiyou beae4f2044 Restore comment about a "showkey" subcommand 2020-05-13 13:52:54 +02:00
kaiyou 00c9d5ec76 Create the node slice with the proper length
Co-authored-by: Leo Antunes <leo@costela.net>
2020-05-13 13:52:54 +02:00
kaiyou b0bfeb1f8e Move the metadata parsing code to node.go 2020-05-13 13:52:54 +02:00
kaiyou 0e799d6074 Parse metadata outside of cluster.go
Move the calls for metadata decoding from the cluster
membership management loop to the main loop. This task
was not directly related to the cluster, and was adding
complexity, including the need for multierr structures.
2020-05-13 13:52:54 +02:00
kaiyou 366f906d5d Do not pass the config object to newCluster
Decouple the config structure from the cluster management and
stop passing the config object around.
2020-05-13 13:52:54 +02:00
kaiyou 97525f4b10 Stop using wireguard in cluster.go
The wireguard is mostly used to compute metadata.
Metadata is now computed by main.go and encoded in
node.go, the cluster only receives a function generating
the binary metadata.
2020-05-13 13:52:54 +02:00
kaiyou 0d93439d0d Move node related stuff to node.go
The cornerstone for exchanging data is the node
structure and associated metadata. Moving it to a
separate file (maybe later a separate module) will help
decoupling.
2020-05-13 13:52:54 +02:00
kaiyou 5772640cf9 Fix a simple typo 2020-05-13 13:52:54 +02:00
kaiyou f2e53dd869 Lower the complexity of newCluster()
Move the computation of clusterKey and bindAddress
to separate functions.
2020-05-13 13:52:54 +02:00
kaiyou 7c398181a7 Remove unused go-windows-terminal-sequences 2020-05-13 13:52:54 +02:00
Leo Antunes 249456e19f ci: fix format for multiple env vars 2020-05-10 13:27:49 +02:00
Leo Antunes 61a20848f3 ci: ensure disabled CGO; simplify cache path 2020-05-10 13:24:07 +02:00
Leo Antunes f51493ad73 ci: bump dist to bionic 2020-05-10 13:19:27 +02:00
Leo Antunes a9626edc74 ci: fix jobs vs matrix 2020-05-10 13:15:24 +02:00
Leo Antunes 9d057e93f5 ci: bump go to 1.14 2020-05-10 13:15:24 +02:00
Leo Antunes 4f169bc270 etchosts: also use errors.Wrap as rest of project 2020-05-10 13:15:24 +02:00
Leo Antunes 20888b1a9b migrate to travis-ci.com 2020-05-10 13:15:24 +02:00
dependabot-preview[bot] 7c9067667d Bump github.com/sirupsen/logrus from 1.5.0 to 1.6.0
Bumps [github.com/sirupsen/logrus](https://github.com/sirupsen/logrus) from 1.5.0 to 1.6.0.
- [Release notes](https://github.com/sirupsen/logrus/releases)
- [Changelog](https://github.com/sirupsen/logrus/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sirupsen/logrus/compare/v1.5.0...v1.6.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-04 21:36:45 +02:00