mirror of
				https://github.com/juanfont/headscale.git
				synced 2025-10-28 10:51:44 +01:00 
			
		
		
		
	Merge branch 'main' into flake-build-env
This commit is contained in:
		
						commit
						d43fec7f96
					
				
							
								
								
									
										43
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								README.md
									
									
									
									
									
								
							| @ -262,6 +262,13 @@ make build | ||||
|             <sub style="font-size:14px"><b>Hoàng Đức Hiếu</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/mevansam> | ||||
|             <img src=https://avatars.githubusercontent.com/u/403630?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Mevan Samaratunga/> | ||||
|             <br /> | ||||
|             <sub style="font-size:14px"><b>Mevan Samaratunga</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/dragetd> | ||||
|             <img src=https://avatars.githubusercontent.com/u/3639577?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Michael G./> | ||||
| @ -283,6 +290,8 @@ make build | ||||
|             <sub style="font-size:14px"><b>Casey Marshall</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
| </tr> | ||||
| <tr> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/SilverBut> | ||||
|             <img src=https://avatars.githubusercontent.com/u/6560655?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Silver Bullet/> | ||||
| @ -290,8 +299,6 @@ make build | ||||
|             <sub style="font-size:14px"><b>Silver Bullet</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
| </tr> | ||||
| <tr> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/majst01> | ||||
|             <img src=https://avatars.githubusercontent.com/u/410110?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Stefan Majer/> | ||||
| @ -327,6 +334,8 @@ make build | ||||
|             <sub style="font-size:14px"><b>Artem Klevtsov</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
| </tr> | ||||
| <tr> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/awoimbee> | ||||
|             <img src=https://avatars.githubusercontent.com/u/22431493?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Arthur Woimbée/> | ||||
| @ -334,8 +343,6 @@ make build | ||||
|             <sub style="font-size:14px"><b>Arthur Woimbée</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
| </tr> | ||||
| <tr> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/stensonb> | ||||
|             <img src=https://avatars.githubusercontent.com/u/933389?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Bryan Stenson/> | ||||
| @ -371,6 +378,8 @@ make build | ||||
|             <sub style="font-size:14px"><b>Jamie Greeff</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
| </tr> | ||||
| <tr> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/jimt> | ||||
|             <img src=https://avatars.githubusercontent.com/u/180326?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Jim Tittsler/> | ||||
| @ -378,8 +387,6 @@ make build | ||||
|             <sub style="font-size:14px"><b>Jim Tittsler</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
| </tr> | ||||
| <tr> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/piec> | ||||
|             <img src=https://avatars.githubusercontent.com/u/781471?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Pierre Carru/> | ||||
| @ -415,6 +422,8 @@ make build | ||||
|             <sub style="font-size:14px"><b>Shaanan Cohney</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
| </tr> | ||||
| <tr> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/m-tanner-dev0> | ||||
|             <img src=https://avatars.githubusercontent.com/u/97977342?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Tanner/> | ||||
| @ -422,8 +431,6 @@ make build | ||||
|             <sub style="font-size:14px"><b>Tanner</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
| </tr> | ||||
| <tr> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/Teteros> | ||||
|             <img src=https://avatars.githubusercontent.com/u/5067989?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Teteros/> | ||||
| @ -452,6 +459,15 @@ make build | ||||
|             <sub style="font-size:14px"><b>Tjerk Woudsma</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/y0ngb1n> | ||||
|             <img src=https://avatars.githubusercontent.com/u/25719408?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Yang Bin/> | ||||
|             <br /> | ||||
|             <sub style="font-size:14px"><b>Yang Bin</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
| </tr> | ||||
| <tr> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/zekker6> | ||||
|             <img src=https://avatars.githubusercontent.com/u/1367798?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Zakhar Bessarab/> | ||||
| @ -466,8 +482,13 @@ make build | ||||
|             <sub style="font-size:14px"><b>ZiYuan</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
| </tr> | ||||
| <tr> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/bravechamp> | ||||
|             <img src=https://avatars.githubusercontent.com/u/48980452?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=bravechamp/> | ||||
|             <br /> | ||||
|             <sub style="font-size:14px"><b>bravechamp</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/derelm> | ||||
|             <img src=https://avatars.githubusercontent.com/u/465155?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=derelm/> | ||||
| @ -489,6 +510,8 @@ make build | ||||
|             <sub style="font-size:14px"><b>lion24</b></sub> | ||||
|         </a> | ||||
|     </td> | ||||
| </tr> | ||||
| <tr> | ||||
|     <td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0"> | ||||
|         <a href=https://github.com/pernila> | ||||
|             <img src=https://avatars.githubusercontent.com/u/12460060?v=4 width="100;"  style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=pernila/> | ||||
|  | ||||
							
								
								
									
										77
									
								
								api.go
									
									
									
									
									
								
							
							
						
						
									
										77
									
								
								api.go
									
									
									
									
									
								
							| @ -568,8 +568,13 @@ func (h *Headscale) handleAuthKey( | ||||
| 			Str("func", "handleAuthKey"). | ||||
| 			Str("machine", registerRequest.Hostinfo.Hostname). | ||||
| 			Msg("Failed authentication via AuthKey") | ||||
| 		machineRegistrations.WithLabelValues("new", RegisterMethodAuthKey, "error", pak.Namespace.Name). | ||||
| 			Inc() | ||||
| 
 | ||||
| 		if pak != nil { | ||||
| 			machineRegistrations.WithLabelValues("new", RegisterMethodAuthKey, "error", pak.Namespace.Name). | ||||
| 				Inc() | ||||
| 		} else { | ||||
| 			machineRegistrations.WithLabelValues("new", RegisterMethodAuthKey, "error").Inc() | ||||
| 		} | ||||
| 
 | ||||
| 		return | ||||
| 	} | ||||
| @ -580,35 +585,51 @@ func (h *Headscale) handleAuthKey( | ||||
| 		Msg("Authentication key was valid, proceeding to acquire IP addresses") | ||||
| 
 | ||||
| 	nodeKey := NodePublicKeyStripPrefix(registerRequest.NodeKey) | ||||
| 	now := time.Now().UTC() | ||||
| 
 | ||||
| 	machineToRegister := Machine{ | ||||
| 		Name:           registerRequest.Hostinfo.Hostname, | ||||
| 		NamespaceID:    pak.Namespace.ID, | ||||
| 		MachineKey:     machineKeyStr, | ||||
| 		RegisterMethod: RegisterMethodAuthKey, | ||||
| 		Expiry:         ®isterRequest.Expiry, | ||||
| 		NodeKey:        nodeKey, | ||||
| 		LastSeen:       &now, | ||||
| 		AuthKeyID:      uint(pak.ID), | ||||
| 	} | ||||
| 
 | ||||
| 	machine, err := h.RegisterMachine( | ||||
| 		machineToRegister, | ||||
| 	) | ||||
| 	if err != nil { | ||||
| 		log.Error(). | ||||
| 	// retrieve machine information if it exist
 | ||||
| 	// The error is not important, because if it does not
 | ||||
| 	// exist, then this is a new machine and we will move
 | ||||
| 	// on to registration.
 | ||||
| 	machine, _ := h.GetMachineByMachineKey(machineKey) | ||||
| 	if machine != nil { | ||||
| 		log.Trace(). | ||||
| 			Caller(). | ||||
| 			Err(err). | ||||
| 			Msg("could not register machine") | ||||
| 		machineRegistrations.WithLabelValues("new", RegisterMethodAuthKey, "error", pak.Namespace.Name). | ||||
| 			Inc() | ||||
| 		ctx.String( | ||||
| 			http.StatusInternalServerError, | ||||
| 			"could not register machine", | ||||
| 		) | ||||
| 			Str("machine", machine.Name). | ||||
| 			Msg("machine already registered, refreshing with new auth key") | ||||
| 
 | ||||
| 		return | ||||
| 		machine.NodeKey = nodeKey | ||||
| 		machine.AuthKeyID = uint(pak.ID) | ||||
| 		h.RefreshMachine(machine, registerRequest.Expiry) | ||||
| 	} else { | ||||
| 		now := time.Now().UTC() | ||||
| 		machineToRegister := Machine{ | ||||
| 			Name:           registerRequest.Hostinfo.Hostname, | ||||
| 			NamespaceID:    pak.Namespace.ID, | ||||
| 			MachineKey:     machineKeyStr, | ||||
| 			RegisterMethod: RegisterMethodAuthKey, | ||||
| 			Expiry:         ®isterRequest.Expiry, | ||||
| 			NodeKey:        nodeKey, | ||||
| 			LastSeen:       &now, | ||||
| 			AuthKeyID:      uint(pak.ID), | ||||
| 		} | ||||
| 
 | ||||
| 		machine, err = h.RegisterMachine( | ||||
| 			machineToRegister, | ||||
| 		) | ||||
| 		if err != nil { | ||||
| 			log.Error(). | ||||
| 				Caller(). | ||||
| 				Err(err). | ||||
| 				Msg("could not register machine") | ||||
| 			machineRegistrations.WithLabelValues("new", RegisterMethodAuthKey, "error", pak.Namespace.Name). | ||||
| 				Inc() | ||||
| 			ctx.String( | ||||
| 				http.StatusInternalServerError, | ||||
| 				"could not register machine", | ||||
| 			) | ||||
| 
 | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	h.UsePreAuthKey(pak) | ||||
|  | ||||
							
								
								
									
										2
									
								
								app.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								app.go
									
									
									
									
									
								
							| @ -409,8 +409,6 @@ func (h *Headscale) httpAuthenticationMiddleware(ctx *gin.Context) { | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	ctx.AbortWithStatus(http.StatusUnauthorized) | ||||
| 
 | ||||
| 	valid, err := h.ValidateAPIKey(strings.TrimPrefix(authHeader, AuthPrefix)) | ||||
| 	if err != nil { | ||||
| 		log.Error(). | ||||
|  | ||||
| @ -55,6 +55,7 @@ docker run \ | ||||
|   --rm \ | ||||
|   --volume $(pwd)/config:/etc/headscale/ \ | ||||
|   --publish 127.0.0.1:8080:8080 \ | ||||
|   --publish 127.0.0.1:9090:9090 \ | ||||
|   headscale/headscale:<VERSION> \ | ||||
|   headscale serve | ||||
| 
 | ||||
| @ -80,7 +81,7 @@ docker ps | ||||
| Verify `headscale` is available: | ||||
| 
 | ||||
| ```shell | ||||
| curl http://127.0.0.1:8080/metrics | ||||
| curl http://127.0.0.1:9090/metrics | ||||
| ``` | ||||
| 
 | ||||
| 6. Create a namespace ([tailnet](https://tailscale.com/kb/1136/tailnet/)): | ||||
|  | ||||
| @ -67,7 +67,7 @@ To run `headscale` in the background, please follow the steps in the [SystemD se | ||||
| Verify `headscale` is available: | ||||
| 
 | ||||
| ```shell | ||||
| curl http://127.0.0.1:8080/metrics | ||||
| curl http://127.0.0.1:9090/metrics | ||||
| ``` | ||||
| 
 | ||||
| 8. Create a namespace ([tailnet](https://tailscale.com/kb/1136/tailnet/)): | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user