mirror of
				https://github.com/juanfont/headscale.git
				synced 2025-10-28 10:51:44 +01:00 
			
		
		
		
	import from headscale, use NowFromTZEnv to get time.
This commit is contained in:
		
							parent
							
								
									91b1d0d877
								
							
						
					
					
						commit
						7bf5b48d9f
					
				| @ -10,7 +10,6 @@ import ( | ||||
| 	"github.com/pterm/pterm" | ||||
| 	"github.com/rs/zerolog/log" | ||||
| 	"github.com/spf13/cobra" | ||||
| 	"github.com/spf13/viper" | ||||
| 	"google.golang.org/protobuf/types/known/timestamppb" | ||||
| ) | ||||
| 
 | ||||
| @ -120,8 +119,7 @@ If you loose a key, create a new one and revoke (expire) the old one.`, | ||||
| 		request := &v1.CreateApiKeyRequest{} | ||||
| 
 | ||||
| 		duration, _ := cmd.Flags().GetDuration("expiration") | ||||
| 		location, _ := time.LoadLocation(viper.GetString("TZ")) | ||||
| 		expiration := time.Now().In(location).Add(duration) | ||||
| 		expiration := headscale.NowFromTZEnv().Add(duration) | ||||
| 
 | ||||
| 		log.Trace().Dur("expiration", duration).Msg("expiration has been set") | ||||
| 
 | ||||
|  | ||||
| @ -5,11 +5,11 @@ import ( | ||||
| 	"strconv" | ||||
| 	"time" | ||||
| 
 | ||||
| 	"github.com/juanfont/headscale" | ||||
| 	v1 "github.com/juanfont/headscale/gen/go/headscale/v1" | ||||
| 	"github.com/pterm/pterm" | ||||
| 	"github.com/rs/zerolog/log" | ||||
| 	"github.com/spf13/cobra" | ||||
| 	"github.com/spf13/viper" | ||||
| 	"google.golang.org/protobuf/types/known/timestamppb" | ||||
| ) | ||||
| 
 | ||||
| @ -150,8 +150,7 @@ var createPreAuthKeyCmd = &cobra.Command{ | ||||
| 		} | ||||
| 
 | ||||
| 		duration, _ := cmd.Flags().GetDuration("expiration") | ||||
| 		location, _ := time.LoadLocation(viper.GetString("TZ")) | ||||
| 		expiration := time.Now().In(location).Add(duration) | ||||
| 		expiration := headscale.NowFromTZEnv().Add(duration) | ||||
| 
 | ||||
| 		log.Trace().Dur("expiration", duration).Msg("expiration has been set") | ||||
| 
 | ||||
|  | ||||
| @ -7,6 +7,7 @@ import ( | ||||
| 	"time" | ||||
| 
 | ||||
| 	"github.com/efekarakus/termcolor" | ||||
| 	"github.com/juanfont/headscale" | ||||
| 	"github.com/juanfont/headscale/cmd/headscale/cli" | ||||
| 	"github.com/rs/zerolog" | ||||
| 	"github.com/rs/zerolog/log" | ||||
| @ -45,8 +46,7 @@ func main() { | ||||
| 	} | ||||
| 
 | ||||
| 	zerolog.TimestampFunc = func() time.Time { | ||||
| 		location, _ := time.LoadLocation(viper.GetString("TZ")) | ||||
| 		return time.Now().In(location) | ||||
| 		return headscale.NowFromTZEnv() | ||||
| 	} | ||||
| 
 | ||||
| 	log.Logger = log.Output(zerolog.ConsoleWriter{ | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user