Commit Graph

85 Commits

Author SHA1 Message Date
Kristoffer Dalby 68dc2a70db Update neighbours if node is expired or refreshed
In addition, only pass the map of registered and not expired nodes to
clients.
2021-11-22 19:51:16 +00:00
Kristoffer Dalby 021c464148 Add cache for requested expiry times
This commit adds a sentral cache to keep track of clients whom has
requested an expiry time, but were we need to keep hold of it until the
second request comes in.
2021-11-22 19:32:52 +00:00
Kristoffer Dalby e600ead3e9 Make sure nodes can reauthenticate
This commit fixes an issue where nodes were not able to reauthenticate.
2021-11-22 19:32:11 +00:00
Kristoffer Dalby 5cbd4513a4 Simplify register function if 2021-11-22 17:21:56 +00:00
Kristoffer Dalby bd1d1b1a3b Implement ExpireMachine rpc 2021-11-21 13:40:19 +00:00
Kristoffer Dalby 9aac1fb255 Remove expiry logic, this needs to be redone 2021-11-19 09:02:29 +00:00
Kristoffer Dalby 106b1e7e8d Create constants for other reg methods 2021-11-18 17:51:54 +00:00
Kristoffer Dalby d6739386a0
Get rid of dynamic errors 2021-11-15 19:18:14 +00:00
Kristoffer Dalby 25b790d025
Add and fix forcetypeassert 2021-11-15 18:42:44 +00:00
Kristoffer Dalby 715542ac1c
Add and fix stylecheck (golint replacement) 2021-11-15 17:24:24 +00:00
Kristoffer Dalby 0c005a6b01
Add and fix errname 2021-11-15 16:33:16 +00:00
Kristoffer Dalby 0c45f8d252
Add and fix errorlint 2021-11-15 16:26:41 +00:00
Kristoffer Dalby 333be80f9c
Fix rest of var name in main code 2021-11-15 16:15:50 +00:00
Kristoffer Dalby 471c0b4993
Initial work eliminating one/two letter variables 2021-11-14 20:32:03 +01:00
Kristoffer Dalby 85f28a3f4a
Remove all instances of undefined numbers (gonmd) 2021-11-14 18:31:51 +01:00
Kristoffer Dalby 796072a5a4
Add and fix ifshort 2021-11-14 18:09:22 +01:00
Kristoffer Dalby 89eb13c6cb
Add and fix nlreturn (new line return) 2021-11-14 16:46:09 +01:00
Kristoffer Dalby 2634215f12 golangci-lint --fix 2021-11-13 08:39:04 +00:00
Kristoffer Dalby 03b7ec62ca Go format with shorter lines 2021-11-13 08:36:45 +00:00
Kristoffer Dalby 787814ea89 Consolidate machine related lookups
This commit moves the routes lookup functions to be subcommands of
Machine, making them a lot simpler and more specific/composable.

It also moves the register command from cli.go into machine, so we can
clear out the extra file.

Finally a toProto function has been added to convert between the machine
database model and the proto/rpc model.
2021-11-04 22:11:38 +00:00
Kristoffer Dalby cbf3f5d640 Resolve merge conflict 2021-10-30 15:33:01 +00:00
Raal Goff 2d252da221 suggested documentation and comments 2021-10-29 21:35:07 +08:00
Kristoffer Dalby da14750396
Merge branch 'main' into main 2021-10-19 15:26:18 +01:00
Juan Font Alonso 8094e6fdef Preload the Namespace from SharedMachines 2021-10-17 11:59:08 +02:00
unreality afbfc1d370
Merge branch 'main' into main 2021-10-16 22:31:37 +08:00
Juan Font Alonso fa8cd96108 Get peers from namespaces where shared nodes are shared to
This is rather shameful. Shared nodes should have never worked without this.
2021-10-12 17:20:14 +02:00
Juan Font Alonso 48f5a9a18c Fix error 500 when deleting shared node (fixes #133) 2021-10-10 23:55:03 +02:00
Raal Goff 74e6c1479e updates from code review 2021-10-10 17:22:42 +08:00
Juan Font c4487b73c4
Merge branch 'main' into magic-dns-support 2021-10-09 12:24:07 +02:00
Kristoffer Dalby 2997f4d251
Merge branch 'main' into main 2021-10-08 22:21:41 +01:00
Kristoffer Dalby 06f56411dd
Update machine.go 2021-10-07 15:45:45 +01:00
Kristoffer Dalby f0c54490ed Allow multiple namespaces to be checked for state at the same time 2021-10-06 22:06:07 +00:00
Kristoffer Dalby 95f726fb31 Fix logic 2021-10-06 19:56:14 +00:00
Kristoffer Dalby ba391bc2ed Account for updates in shared namespaces 2021-10-06 19:32:15 +00:00
Raal Goff c487591437 use go-oidc instead of verifying and extracting tokens ourselves, rename oidc_endpoint to oidc_issuer to be more inline with spec 2021-10-06 17:19:15 +08:00
Kristoffer Dalby a01a0d1039 Remove unstable update channel, replace with state updates 2021-10-05 16:24:46 +00:00
Juan Font c9a411e341 Preload namespace 2021-10-05 17:47:21 +02:00
Juan Font Alonso a0fa652449 MagicDNS changes merged back 2021-10-04 23:49:16 +02:00
Kristoffer Dalby 2eb57e6288 Clean up pointer usage consistency.
This tries to make the same functions emit and consume the same type of
data all over the application.

If a function transform data, it should emit new data, not a pointer.
2021-10-04 17:39:01 +00:00
Kristoffer Dalby 1d5b090579 Initial work on Prometheus metrics
This commit adds some Prometheus metrics to /metrics in headscale.

It will add the standard go metrics, some automatic gin metrics and some
initial headscale specific ones.

Some of them has been added to aid debugging #97 (loop bug)

In the future, we can use the metrics to get rid of the sleep in the
integration tests by checking that our expected number of nodes has been
registered:

```
headscale_machine_registrations_total
```
2021-10-04 16:28:07 +00:00
Kristoffer Dalby 1bddf1147b
Resolve merge conflict 2021-10-03 11:01:13 +01:00
Kristoffer Dalby 3c3189caa6
Move toNode, add type helpers, split peers and shared
This commit moves toNode to the bottom of the file, and adds a helper
function for lists of Machines to be converted.

It also adds string helpers for Machines and lists of machines.

Lastly it splits getPeers into getDirectPeers, which exist in the same
namespace, and getShared, which is nodes shared with the namespace.

getPeers is kept as a function putting together the two lists for
convenience.
2021-10-02 22:03:34 +01:00
Kristoffer Dalby 0d4a006536
Consitently use Machine pointers
This commit rewrites a bunch of the code to always use *Machine instead
of a mix of both, and a mix of tailcfg.Node and Machine.

Now we use *Machine, and if tailcfg.Node is needed, it is converted just
before needed.
2021-10-02 22:00:09 +01:00
Kristoffer Dalby 0475eb6ef7
Move DB call of pollmap to Machine inside a function 2021-10-02 21:58:28 +01:00
Kristoffer Dalby 39abc4e973
Clarify error messages for nodes that are not connected
If a node does not have an update channel, it is probably not connected,
clarify the log messages and make sure we dont print that it was updated
successfully (continue, not return)
2021-10-02 15:38:53 +01:00
Kristoffer Dalby 6ffea2225d
Attempt to close failed streams
If we have a failed write toward any of our connections, attempt to
close the connection by returning "false" as in unsuccessful stream
2021-10-02 15:28:19 +01:00
Juan Font b83894abd6 Add support for taildrop (#118) 2021-09-24 09:49:29 +02:00
Juan Font b937f9b762
Update machine.go
Added comment on toNode
2021-09-10 00:30:02 +02:00
Juan Font 55f3e07bd4
Apply suggestions from code review
Removed one letter variables

Co-authored-by: Kristoffer Dalby <kradalby@kradalby.no>
2021-09-10 00:26:46 +02:00
Juan Font 2780623076 Renamed SharedNode to SharedMachine 2021-09-06 14:43:43 +02:00