@@ -132,7 +132,7 @@ func (s *sessionRpcServer) start(ctx context.Context) error {
132132 continue
133133 }
134134
135- if sess .Expiry .Before (time .Now ()) {
135+ if sess .Expiry .Before (time .Now (). UTC () ) {
136136 continue
137137 }
138138
@@ -190,7 +190,7 @@ func (s *sessionRpcServer) AddSession(ctx context.Context,
190190 req * litrpc.AddSessionRequest ) (* litrpc.AddSessionResponse , error ) {
191191
192192 expiry := time .Unix (int64 (req .ExpiryTimestampSeconds ), 0 )
193- if time .Now ().After (expiry ) {
193+ if time .Now ().UTC (). After (expiry ) {
194194 return nil , fmt .Errorf ("expiry must be in the future" )
195195 }
196196
@@ -364,7 +364,7 @@ func (s *sessionRpcServer) resumeSession(ctx context.Context,
364364 }
365365
366366 // Don't resume an expired session.
367- if sess .Expiry .Before (time .Now ()) {
367+ if sess .Expiry .Before (time .Now (). UTC () ) {
368368 log .Debugf ("Not resuming session %x with expiry %s" ,
369369 pubKeyBytes , sess .Expiry )
370370
@@ -440,15 +440,15 @@ func (s *sessionRpcServer) resumeSession(ctx context.Context,
440440 // we do not yet have a static remote pub key for.
441441 if sess .RemotePublicKey == nil {
442442 deadline := sess .CreatedAt .Add (s .cfg .firstConnectionDeadline )
443- if deadline .Before (time .Now ()) {
443+ if deadline .Before (time .Now (). UTC () ) {
444444 log .Debugf ("Deadline for session %x has already " +
445445 "passed. Revoking session" , pubKeyBytes )
446446
447447 return s .cfg .db .RevokeSession (pubKey )
448448 }
449449
450450 // Start the deadline timer.
451- deadlineDuration := time .Until ( deadline )
451+ deadlineDuration := deadline . Sub ( time .Now (). UTC () )
452452 deadlineTimer := time .AfterFunc (deadlineDuration , func () {
453453 close (firstConnTimout )
454454 })
@@ -489,7 +489,7 @@ func (s *sessionRpcServer) resumeSession(ctx context.Context,
489489 go func () {
490490 defer s .wg .Done ()
491491
492- ticker := time .NewTimer (time .Until ( sess . Expiry ))
492+ ticker := time .NewTimer (sess . Expiry . Sub ( time .Now (). UTC () ))
493493 defer ticker .Stop ()
494494
495495 select {
@@ -839,7 +839,7 @@ func (s *sessionRpcServer) AddAutopilotSession(ctx context.Context,
839839 }
840840
841841 expiry := time .Unix (int64 (req .ExpiryTimestampSeconds ), 0 )
842- if time .Now ().After (expiry ) {
842+ if time .Now ().UTC (). After (expiry ) {
843843 return nil , fmt .Errorf ("expiry must be in the future" )
844844 }
845845
0 commit comments