-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial work preparing for API/gRPC #204
Conversation
This commit adds protobuf files and tooling surrounding generating APIs and datatypes.
This commit moves the TLS configuration into a seperate function. It also wires up the gRPC interface and prepares handing the API endpoints to the grpc gateway.
This does not have to be reviewed, here is some reasoning: Go (and go mod) is designed for having code available and we need to check in the generated code to make sure it is "go gettable". If we dont we give ourselves a headache trying to setup all the ci, tests etc to install and generate the code before it runs. Because the code isnt there, the plugins needed to generate the code fail to install... I didnt find any good documentation for this, but there is this github comment: golang/go#34514 (comment)
This commit removed `golint`, its deprecated: https://github.com/golang/lint and golangci-lint has overlapping features.
@@ -18,22 +18,3 @@ jobs: | |||
# below, but it's still much faster in the end than installing | |||
# golangci-lint manually in the `Run lint` step. | |||
- uses: golangci/golangci-lint-action@v2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noice, an omnibus PR
@@ -222,7 +272,11 @@ func (h *Headscale) Serve() error { | |||
go h.scheduledDERPMapUpdateWorker(derpMapCancelChannel) | |||
} | |||
|
|||
s := &http.Server{ | |||
// I HATE THIS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too.
// The two following listeners will be served on the same port below gracefully. | ||
m := cmux.New(l) | ||
// Match gRPC requests here | ||
grpcListener := m.MatchWithWriters(cmux.HTTP2MatchHeaderFieldSendSettings("content-type", "application/grpc")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noice. And clever.
This PR starts the work on preparing for generating an API with Protobuf for HTTP and gRPC.
The idea is that this can be used for many things, but most importantly:
I need help testing that the TLS setup is still working as intended after moving it, @cure could you have a look?
Please note: This PR does not check in generated code, to compile locally, you need run
make generate
and follow the new steps in the README.