1
0
mirror of https://github.com/juanfont/headscale.git synced 2025-08-01 13:46:49 +02:00

fix: apply code review suggestions

This commit is contained in:
seiuneko 2025-05-16 21:50:56 +08:00
parent 2e3662ba68
commit 6cd33d493f
No known key found for this signature in database
GPG Key ID: A5A75952899A0179
5 changed files with 10 additions and 6 deletions

View File

@ -2,6 +2,11 @@
## Next
### Changes
- Support client verify for DERP
[#2046](https://github.com/juanfont/headscale/pull/2046)
## 0.26.0 (2025-05-14)
### BREAKING

View File

@ -85,7 +85,7 @@ derp:
region_code: "headscale"
region_name: "Headscale Embedded DERP"
# Verify clients to this DERP server using the Headscale node list
# Only allow clients associated with this server access
verify_clients: true
# Listens over UDP at the configured address for STUN connections - to help with NAT traversal.

View File

@ -227,7 +227,7 @@ func NewHeadscale(cfg *types.Config) (*Headscale, error) {
}
if cfg.DERP.ServerVerifyClients {
t := http.DefaultTransport.(*http.Transport)
t := http.DefaultTransport.(*http.Transport) //nolint:forcetypeassert
t.RegisterProtocol(
derpServer.DerpVerifyScheme,
derpServer.NewDERPVerifyTransport(app.handleVerifyRequest),

View File

@ -384,10 +384,7 @@ type DERPVerifyTransport struct {
func (t *DERPVerifyTransport) RoundTrip(req *http.Request) (*http.Response, error) {
buf := new(bytes.Buffer)
if err := t.handleVerifyRequest(req, buf); err != nil {
log.Error().
Caller().
Err(err).
Msg("Failed to handle verify request")
log.Error().Caller().Err(err).Msg("Failed to handle client verify request: ")
return nil, err
}

View File

@ -101,6 +101,8 @@ func DERPVerify(
c := derphttp.NewRegionClient(nodeKey, t.Logf, netmon.NewStatic(), func() *tailcfg.DERPRegion {
return &region
})
defer c.Close()
var result error
if err := c.Connect(context.Background()); err != nil {
result = fmt.Errorf("client Connect: %w", err)