-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix magic dns and uppercase letters #387
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
Changes from 4 commits
44a5372
6f172a6
dcf3ea5
1114449
6cc8bbc
f19c048
2b68c90
41efe98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -83,7 +83,18 @@ func (h *Headscale) PollNetMapHandler(ctx *gin.Context) { | |||
| Str("machine", machine.Name). | ||||
| Msg("Found machine in database") | ||||
|
|
||||
| machine.Name = req.Hostinfo.Hostname | ||||
| hname, err := NormalizeName( | ||||
| req.Hostinfo.Hostname, | ||||
| h.cfg.OIDC.StripEmaildomain, | ||||
| ) | ||||
| if err != nil { | ||||
| log.Error(). | ||||
| Caller(). | ||||
| Str("func", "handleAuthKey"). | ||||
| Str("hostinfo.name", req.Hostinfo.Hostname). | ||||
| Err(err) | ||||
| } | ||||
| machine.Name = hname | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, doing this here feels kind of wrong, I think doing it here: Would be more correct, as this is when the machine registers. However we need a migration path. It could potentially be done in the DB migration, what do you think? We should probably also make a tracking ticket of a unique constraint for a machine name per user, so we dont have collisions.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, that was my first intention. When I found this solution I thought that we could get rid of the need of a database migration, but the For the machine name per user I think it would be more a unique name on all the headscale instance. If we tag a machine, this machine should not be accessed by the name of the user that created it (it's currently not implemented).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After re-reading the code. What should we do in this place ? If we keep previous behavior, normalized Line 126 in 435ee36
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could migrate all of them on server start up as part of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After some tests each time we update the hostname with I could not find solid proof in reasonable time from the code of
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we need it in both places?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that would be better yes !
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets give it a go then :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I'll made the modifications on the name of the function and add this code to both places tonight. |
||||
| machine.HostInfo = HostInfo(*req.Hostinfo) | ||||
| machine.DiscoKey = DiscoPublicKeyStripPrefix(req.DiscoKey) | ||||
| now := time.Now().UTC() | ||||
|
|
||||
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.
I think as mentioned this is a bit to generic, for a unknown user to understand the context, it needs to either have
FQDNor Domain or some reference to the RFC and limitations in the name.