diff --git a/client/cmd/status.go b/client/cmd/status.go index d090f4dda..119944d08 100644 --- a/client/cmd/status.go +++ b/client/cmd/status.go @@ -249,7 +249,7 @@ func mapPeers(peers []*proto.PeerState) peersStateOutput { IP: pbPeerState.GetIP(), PubKey: pbPeerState.GetPubKey(), Status: pbPeerState.GetConnStatus(), - LastStatusUpdate: timeLocal.UTC(), + LastStatusUpdate: timeLocal, ConnType: connType, Direct: pbPeerState.GetDirect(), IceCandidateType: iceCandidateType{ diff --git a/management/server/file_store.go b/management/server/file_store.go index 1815cf6fe..1765eb917 100644 --- a/management/server/file_store.go +++ b/management/server/file_store.go @@ -227,7 +227,7 @@ func (s *FileStore) persist(file string) error { // AcquireGlobalLock acquires global lock across all the accounts and returns a function that releases the lock func (s *FileStore) AcquireGlobalLock() (unlock func()) { log.Debugf("acquiring global lock") - start := time.Now().UTC() + start := time.Now() s.globalAccountLock.Lock() unlock = func() { @@ -241,7 +241,7 @@ func (s *FileStore) AcquireGlobalLock() (unlock func()) { // AcquireAccountLock acquires account lock and returns a function that releases the lock func (s *FileStore) AcquireAccountLock(accountID string) (unlock func()) { log.Debugf("acquiring lock for account %s", accountID) - start := time.Now().UTC() + start := time.Now() value, _ := s.accountLocks.LoadOrStore(accountID, &sync.Mutex{}) mtx := value.(*sync.Mutex) mtx.Lock() diff --git a/management/server/grpcserver.go b/management/server/grpcserver.go index b92704435..0c8dad246 100644 --- a/management/server/grpcserver.go +++ b/management/server/grpcserver.go @@ -98,7 +98,7 @@ func (s *GRPCServer) GetServerKey(ctx context.Context, req *proto.Empty) (*proto if s.appMetrics != nil { s.appMetrics.GRPCMetrics().CountGetKeyRequest() } - now := time.Now().UTC().Add(24 * time.Hour) + now := time.Now().Add(24 * time.Hour) secs := int64(now.Second()) nanos := int32(now.Nanosecond()) expiresAt := ×tamp.Timestamp{Seconds: secs, Nanos: nanos} diff --git a/management/server/http/middleware/auth_middleware.go b/management/server/http/middleware/auth_middleware.go index 09771deb4..a8c81012a 100644 --- a/management/server/http/middleware/auth_middleware.go +++ b/management/server/http/middleware/auth_middleware.go @@ -117,7 +117,7 @@ func (m *AuthMiddleware) CheckPATFromRequest(w http.ResponseWriter, r *http.Requ if err != nil { return fmt.Errorf("invalid Token: %w", err) } - if time.Now().UTC().After(pat.ExpirationDate) { + if time.Now().After(pat.ExpirationDate) { return fmt.Errorf("token expired") } diff --git a/management/server/idp/auth0.go b/management/server/idp/auth0.go index 89158e164..bb4d3e321 100644 --- a/management/server/idp/auth0.go +++ b/management/server/idp/auth0.go @@ -152,7 +152,7 @@ func NewAuth0Manager(config Auth0ClientConfig, appMetrics telemetry.AppMetrics) // jwtStillValid returns true if the token still valid and have enough time to be used and get a response from Auth0 func (c *Auth0Credentials) jwtStillValid() bool { - return !c.jwtToken.expiresInTime.IsZero() && time.Now().UTC().Add(5*time.Second).Before(c.jwtToken.expiresInTime) + return !c.jwtToken.expiresInTime.IsZero() && time.Now().Add(5*time.Second).Before(c.jwtToken.expiresInTime) } // requestJWTToken performs request to get jwt token diff --git a/management/server/idp/auth0_test.go b/management/server/idp/auth0_test.go index ab86f3986..75ff1d080 100644 --- a/management/server/idp/auth0_test.go +++ b/management/server/idp/auth0_test.go @@ -65,7 +65,7 @@ func (mc *mockAuth0Credentials) Authenticate() (JWTToken, error) { } func newTestJWT(t *testing.T, expInt int) string { - now := time.Now().UTC() + now := time.Now() token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ "iat": now.Unix(), "exp": now.Add(time.Duration(expInt) * time.Second).Unix(), @@ -209,13 +209,13 @@ func TestAuth0_JwtStillValid(t *testing.T) { } jwtStillValidTestCase1 := jwtStillValidTest{ name: "JWT still valid", - inputTime: time.Now().UTC().Add(10 * time.Second), + inputTime: time.Now().Add(10 * time.Second), expectedResult: true, message: "should be true", } jwtStillValidTestCase2 := jwtStillValidTest{ name: "JWT is invalid", - inputTime: time.Now().UTC(), + inputTime: time.Now(), expectedResult: false, message: "should be false", } @@ -251,7 +251,7 @@ func TestAuth0_Authenticate(t *testing.T) { authenticateTestCase1 := authenticateTest{ name: "Get Cached token", - inputExpireToken: time.Now().UTC().Add(30 * time.Second), + inputExpireToken: time.Now().Add(30 * time.Second), helper: JsonParser{}, // expectedFuncExitErrDiff: fmt.Errorf("unable to get token, statusCode 400"), expectedCode: 200, diff --git a/management/server/idp/keycloak.go b/management/server/idp/keycloak.go index 8ae09fc99..a0c004db2 100644 --- a/management/server/idp/keycloak.go +++ b/management/server/idp/keycloak.go @@ -119,7 +119,7 @@ func NewKeycloakManager(config KeycloakClientConfig, appMetrics telemetry.AppMet // jwtStillValid returns true if the token still valid and have enough time to be used and get a response from keycloak. func (kc *KeycloakCredentials) jwtStillValid() bool { - return !kc.jwtToken.expiresInTime.IsZero() && time.Now().UTC().Add(5*time.Second).Before(kc.jwtToken.expiresInTime) + return !kc.jwtToken.expiresInTime.IsZero() && time.Now().Add(5*time.Second).Before(kc.jwtToken.expiresInTime) } // requestJWTToken performs request to get jwt token. diff --git a/management/server/idp/keycloak_test.go b/management/server/idp/keycloak_test.go index 6cff7f56a..141937c62 100644 --- a/management/server/idp/keycloak_test.go +++ b/management/server/idp/keycloak_test.go @@ -199,13 +199,13 @@ func TestKeycloakJwtStillValid(t *testing.T) { jwtStillValidTestCase1 := jwtStillValidTest{ name: "JWT still valid", - inputTime: time.Now().UTC().Add(10 * time.Second), + inputTime: time.Now().Add(10 * time.Second), expectedResult: true, message: "should be true", } jwtStillValidTestCase2 := jwtStillValidTest{ name: "JWT is invalid", - inputTime: time.Now().UTC(), + inputTime: time.Now(), expectedResult: false, message: "should be false", } @@ -240,7 +240,7 @@ func TestKeycloakAuthenticate(t *testing.T) { authenticateTestCase1 := authenticateTest{ name: "Get Cached token", - inputExpireToken: time.Now().UTC().Add(30 * time.Second), + inputExpireToken: time.Now().Add(30 * time.Second), helper: JsonParser{}, expectedFuncExitErrDiff: nil, expectedCode: 200, diff --git a/management/server/management_test.go b/management/server/management_test.go index 25ce4fb0d..aaaba1799 100644 --- a/management/server/management_test.go +++ b/management/server/management_test.go @@ -371,7 +371,7 @@ var _ = Describe("Management service", func() { for i := 0; i < additionalPeers; i++ { key, _ := wgtypes.GenerateKey() loginPeerWithValidSetupKey(serverPubKey, key, client) - rand.Seed(time.Now().UTC().UnixNano()) + rand.Seed(time.Now().UnixNano()) n := rand.Intn(200) time.Sleep(time.Duration(n) * time.Millisecond) } diff --git a/management/server/metrics/selfhosted.go b/management/server/metrics/selfhosted.go index 751e07fba..2c7e943ac 100644 --- a/management/server/metrics/selfhosted.go +++ b/management/server/metrics/selfhosted.go @@ -67,7 +67,7 @@ type Worker struct { // NewWorker returns a metrics worker func NewWorker(ctx context.Context, id string, dataSource DataSource, connManager ConnManager) *Worker { - currentTime := time.Now().UTC() + currentTime := time.Now() return &Worker{ ctx: ctx, id: id, @@ -90,7 +90,7 @@ func (w *Worker) Run() { if err != nil { log.Error(err) } - w.lastRun = time.Now().UTC() + w.lastRun = time.Now() } } } @@ -149,7 +149,7 @@ func (w *Worker) generatePayload(apiKey string) pushPayload { DistinctID: w.id, Event: PayloadEvent, Properties: properties, - Timestamp: time.Now().UTC(), + Timestamp: time.Now(), } } @@ -172,7 +172,7 @@ func (w *Worker) generateProperties() properties { peerActiveVersions []string osUIClients map[string]int ) - start := time.Now().UTC() + start := time.Now() metricsProperties := make(properties) osPeers = make(map[string]int) osUIClients = make(map[string]int) diff --git a/management/server/network.go b/management/server/network.go index 2fe99338f..5237fa441 100644 --- a/management/server/network.go +++ b/management/server/network.go @@ -50,7 +50,7 @@ func NewNetwork() *Network { n := iplib.NewNet4(net.ParseIP("100.64.0.0"), NetSize) sub, _ := n.Subnet(SubnetSize) - s := rand.NewSource(time.Now().UTC().Unix()) + s := rand.NewSource(time.Now().Unix()) r := rand.New(s) intn := r.Intn(len(sub)) @@ -101,7 +101,7 @@ func AllocatePeerIP(ipNet net.IPNet, takenIps []net.IP) (net.IP, error) { } // pick a random IP - s := rand.NewSource(time.Now().UTC().Unix()) + s := rand.NewSource(time.Now().Unix()) r := rand.New(s) intn := r.Intn(len(ips)) diff --git a/management/server/peer.go b/management/server/peer.go index cb0112d37..b4b918083 100644 --- a/management/server/peer.go +++ b/management/server/peer.go @@ -144,7 +144,7 @@ func (p *Peer) LoginExpired(expiresIn time.Duration) (bool, time.Duration) { return false, 0 } expiresAt := p.LastLogin.Add(expiresIn) - now := time.Now().UTC() + now := time.Now() timeLeft := expiresAt.Sub(now) return timeLeft <= 0, timeLeft } diff --git a/management/server/setupkey.go b/management/server/setupkey.go index cce819056..bfba05839 100644 --- a/management/server/setupkey.go +++ b/management/server/setupkey.go @@ -148,7 +148,7 @@ func (key *SetupKey) IsRevoked() bool { // IsExpired if key was expired func (key *SetupKey) IsExpired() bool { - return time.Now().UTC().After(key.ExpiresAt) + return time.Now().After(key.ExpiresAt) } // IsOverUsed if the key was used too many times. SetupKey.UsageLimit == 0 indicates the unlimited usage. diff --git a/management/server/turncredentials.go b/management/server/turncredentials.go index 8db885853..1114aeeab 100644 --- a/management/server/turncredentials.go +++ b/management/server/turncredentials.go @@ -46,7 +46,7 @@ func NewTimeBasedAuthSecretsManager(updateManager *PeersUpdateManager, config *T func (m *TimeBasedAuthSecretsManager) GenerateCredentials() TURNCredentials { mac := hmac.New(sha1.New, []byte(m.config.Secret)) - timeAuth := time.Now().UTC().Add(m.config.CredentialsTTL.Duration).Unix() + timeAuth := time.Now().Add(m.config.CredentialsTTL.Duration).Unix() username := fmt.Sprint(timeAuth)