Commit graph

296 commits

Author SHA1 Message Date
Juan Font ab61c87701 Also notify peers when deleting ephemerals 2021-08-12 21:53:37 +02:00
Juan Font c1e6157847 Expire ephemeral is internal 2021-08-12 21:45:40 +02:00
Juan Font 4c849539fc Expire the ephemeral nodes in the Serve method 2021-08-12 21:44:12 +02:00
Juan Font 9c2a630055
Merge pull request #81 from kradalby/integration-tests
Add Integration tests
2021-08-12 11:15:45 +02:00
Kristoffer Dalby 0e1ddf9715
Set longer timeout for integration tests 2021-08-12 07:36:38 +01:00
Kristoffer Dalby 54da1a4155
Commit the correct integration etc files 2021-08-12 07:05:26 +01:00
Kristoffer Dalby 7141e2ed70
Fix hostname passed to join command 2021-08-11 17:12:39 +01:00
Kristoffer Dalby c9e5048015 Merge remote-tracking branch 'upstream/main' into integration-tests 2021-08-08 17:57:28 +01:00
Kristoffer Dalby 4e077b053c Initial work, add integration tests
This commit adds integration tests to headscale. They are currently
quite simple, but it lays the groundwork for more comprehensive testing
and ensuring we dont break things with the official tailscale client.

The test works by leveraging Docker (via dockertest) to spin up a
Headscale container, and a number of tailscale containers (10).

Each tailscale container is joined to the headscale and then "passed on"
to the tests.

Currently three tests have been implemented:

- Have all tailscale containers join headscale (in the setup process)
- Get IP from each container (I plan to extend this with cross-ping)
- List nodes with headscales CLI and verify all has been registered

This test depends on Docker, and currently, I have not looked into
hooking it into Github Actions.
2021-08-08 17:50:32 +01:00
Kristoffer Dalby f973aef80c Add Dockerfile to build tailscale docker image for integration tests 2021-08-08 17:43:06 +01:00
Kristoffer Dalby a43bb1bb40 Improve Dockerfile
This commit makes several changes to the dockerfile:

- Add go.mod and go.sum in a seperate stage, subsequently calling `go
  mod download` to make it cache dependencies and speed up builds
- Use ubuntu:latest (28MB larger) instead of scratch, makes the image a
  lot easier to debug (e.g. it has a shell and a package manager)
- Change ENTRYPOINT to CMD, this makes the behaviour of the image
  slightly different from a CLI perspective, but makes interacting with
  the image from code, docker-compose and kubernetes easier.
2021-08-08 17:39:39 +01:00
Kristoffer Dalby d86123195c
Add a dockerignore file to speed up builds and make cachine better 2021-08-08 17:38:44 +01:00
Kristoffer Dalby 91ffd10192 Remove "Keys: " from create auth key output
This is based on the premis that "the user know what command they
executed" and therefor know that the output is the key.

This makes the command a lot more useful in scripts.
2021-08-08 17:37:23 +01:00
Kristoffer Dalby 642c7824a7
Add trace log for machine failing to parce ip in toNode 2021-08-08 17:37:04 +01:00
Kristoffer Dalby 149279f3d5 Add health endpoint
Allow us to tell when the server is up and running and can answer
requests
2021-08-08 17:36:25 +01:00
Juan Font 275214920f
Merge pull request #80 from juanfont/delete-pak
Add CLI command to mark preauthkeys as expired
2021-08-08 10:52:18 +02:00
Juan Font 0124899759 fixed linting x 2 2021-08-08 00:14:10 +02:00
Juan Font 033136cb9a fixed linting 2021-08-08 00:13:44 +02:00
Juan Font 05e08e0ac7 Added cmd to expire preauth keys (requested in #78) 2021-08-08 00:10:30 +02:00
Juan Font 226cb89d97 Added func to expire PAKs 2021-08-07 23:57:52 +02:00
Juan Font 3007c0ec4f
Merge pull request #79 from felixonmars/patch-1
Correct a typo in routes.go
2021-08-07 20:02:16 +02:00
Felix Yan 3fa1ac9c79
Correct a typo in routes.go 2021-08-08 01:52:01 +08:00
Juan Font bb2ccfddd9
Merge pull request #77 from kradalby/deadlierlocks
Remove more deadlocks
2021-08-07 01:05:01 +02:00
Kristoffer Dalby 99fd126219
Remove unused mutex 2021-08-06 21:11:38 +01:00
Kristoffer Dalby 15b8c8f4c5
Remove lock from keepAlive 2021-08-06 20:08:51 +01:00
Kristoffer Dalby 4243885246
Rewrite old lock error msg 2021-08-06 20:03:25 +01:00
Kristoffer Dalby 5bc5c5dc1b
Remove forgotten lock 2021-08-06 20:02:47 +01:00
Juan Font db4f49901e
Merge pull request #76 from kradalby/no-color-logs
Try to detect color support, make color configurable
2021-08-06 08:40:54 +02:00
Kristoffer Dalby 73a00c89ff Try to detect color support, make color configurable
This commit tries to detect if users can render colors in their terminal
and only enables color logs if that is true.

It also adds no-color.org's NO_COLOR env var support to allow it to be
disabled.
2021-08-06 07:29:57 +01:00
Juan Font 8a614dabc0 Headscale is from no-juan 2021-08-06 00:23:07 +02:00
Juan Font c95cf15731 Fixed log message 2021-08-06 00:21:34 +02:00
Juan Font e7ce902f9d
Merge pull request #75 from kradalby/syncmap
Fix deadlock issue
2021-08-06 00:19:34 +02:00
Juan Font d421c7b665
Merge pull request #74 from kradalby/deadlock-logging
Switch to a structured logger
2021-08-06 00:18:40 +02:00
Kristoffer Dalby 1abc68ccf4 Removes locks causing deadlock
This commit removes most of the locks in the PollingMap handler as there
was combinations that caused deadlocks. Instead of doing a plain map and
doing the locking ourselves, we use sync.Map which handles it for us.
2021-08-05 22:14:37 +01:00
Kristoffer Dalby 575b15e5fa
Add more trace logging 2021-08-05 21:47:06 +01:00
Kristoffer Dalby a8c8a358d0
Make log keys lowercase 2021-08-05 20:57:47 +01:00
Kristoffer Dalby cd2ca137c0
Make log_level user configurable 2021-08-05 19:19:25 +01:00
Kristoffer Dalby 0660867a16
Correct url 2021-08-05 18:58:15 +01:00
Kristoffer Dalby b1200140b8
Convert cli/utils.go 2021-08-05 18:26:49 +01:00
Kristoffer Dalby d10b57b317
Convert namespaces.go 2021-08-05 18:23:02 +01:00
Kristoffer Dalby 42bf566fff
Convert acls.go 2021-08-05 18:18:18 +01:00
Kristoffer Dalby 0bb2fabc6c
Convert missing from api.go 2021-08-05 18:16:21 +01:00
Kristoffer Dalby ee704f8ef3
Initial port to zerologger 2021-08-05 18:11:26 +01:00
Juan Font 4aad3b7933
Improved README.md on ip_prefix 2021-08-03 20:38:23 +02:00
Juan Font 6091373b53
Merge pull request #63 from juanfont/use-kv-for-updates
Added communication between Serve and CLI using KV table
2021-08-03 20:30:33 +02:00
Juan Font 3879120967
Merge pull request #72 from kradalby/ip-pool
Make IP Prefix configurable and available ip deterministic
2021-08-03 20:27:42 +02:00
Kristoffer Dalby 465669f650
Merge pull request #1 from kradalby/ip-pool-test
Fix empty ip issue and remove network/broadcast addresses
2021-08-03 10:12:09 +01:00
Kristoffer Dalby ea615e3a26
Do not issue "network" or "broadcast" addresses (0 or 255) 2021-08-03 10:06:42 +01:00
Kristoffer Dalby d3349aa4d1
Add test to ensure we can deal with empty ips from database 2021-08-03 09:26:28 +01:00
Kristoffer Dalby 73207decfd Check that IP is set before parsing
Machine is saved to db before it is assigned an ip, so we might have
empty ip fields coming back.
2021-08-03 07:42:11 +01:00