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/pterm/pterm" | ||||||
| 	"github.com/rs/zerolog/log" | 	"github.com/rs/zerolog/log" | ||||||
| 	"github.com/spf13/cobra" | 	"github.com/spf13/cobra" | ||||||
| 	"github.com/spf13/viper" |  | ||||||
| 	"google.golang.org/protobuf/types/known/timestamppb" | 	"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{} | 		request := &v1.CreateApiKeyRequest{} | ||||||
| 
 | 
 | ||||||
| 		duration, _ := cmd.Flags().GetDuration("expiration") | 		duration, _ := cmd.Flags().GetDuration("expiration") | ||||||
| 		location, _ := time.LoadLocation(viper.GetString("TZ")) | 		expiration := headscale.NowFromTZEnv().Add(duration) | ||||||
| 		expiration := time.Now().In(location).Add(duration) |  | ||||||
| 
 | 
 | ||||||
| 		log.Trace().Dur("expiration", duration).Msg("expiration has been set") | 		log.Trace().Dur("expiration", duration).Msg("expiration has been set") | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -5,11 +5,11 @@ import ( | |||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
|  | 	"github.com/juanfont/headscale" | ||||||
| 	v1 "github.com/juanfont/headscale/gen/go/headscale/v1" | 	v1 "github.com/juanfont/headscale/gen/go/headscale/v1" | ||||||
| 	"github.com/pterm/pterm" | 	"github.com/pterm/pterm" | ||||||
| 	"github.com/rs/zerolog/log" | 	"github.com/rs/zerolog/log" | ||||||
| 	"github.com/spf13/cobra" | 	"github.com/spf13/cobra" | ||||||
| 	"github.com/spf13/viper" |  | ||||||
| 	"google.golang.org/protobuf/types/known/timestamppb" | 	"google.golang.org/protobuf/types/known/timestamppb" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| @ -150,8 +150,7 @@ var createPreAuthKeyCmd = &cobra.Command{ | |||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		duration, _ := cmd.Flags().GetDuration("expiration") | 		duration, _ := cmd.Flags().GetDuration("expiration") | ||||||
| 		location, _ := time.LoadLocation(viper.GetString("TZ")) | 		expiration := headscale.NowFromTZEnv().Add(duration) | ||||||
| 		expiration := time.Now().In(location).Add(duration) |  | ||||||
| 
 | 
 | ||||||
| 		log.Trace().Dur("expiration", duration).Msg("expiration has been set") | 		log.Trace().Dur("expiration", duration).Msg("expiration has been set") | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -7,6 +7,7 @@ import ( | |||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"github.com/efekarakus/termcolor" | 	"github.com/efekarakus/termcolor" | ||||||
|  | 	"github.com/juanfont/headscale" | ||||||
| 	"github.com/juanfont/headscale/cmd/headscale/cli" | 	"github.com/juanfont/headscale/cmd/headscale/cli" | ||||||
| 	"github.com/rs/zerolog" | 	"github.com/rs/zerolog" | ||||||
| 	"github.com/rs/zerolog/log" | 	"github.com/rs/zerolog/log" | ||||||
| @ -45,8 +46,7 @@ func main() { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	zerolog.TimestampFunc = func() time.Time { | 	zerolog.TimestampFunc = func() time.Time { | ||||||
| 		location, _ := time.LoadLocation(viper.GetString("TZ")) | 		return headscale.NowFromTZEnv() | ||||||
| 		return time.Now().In(location) |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	log.Logger = log.Output(zerolog.ConsoleWriter{ | 	log.Logger = log.Output(zerolog.ConsoleWriter{ | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user