Jonathan Turner 9 tahun lalu
induk
melakukan
358e1cbd7f
1 mengubah file dengan 16 tambahan dan 14 penghapusan
  1. 16 14
      client/session.go

+ 16 - 14
client/session.go

@@ -16,6 +16,22 @@ type Session struct {
 	SessionKeyExpiration time.Time
 }
 
+//Enable the automatic renewal for the client's TGT session.
+func (cl *Client) EnableAutoSessionRenewal() {
+	go func() {
+		for {
+			//Wait until one minute before endtime
+			w := (cl.Session.EndTime.Sub(time.Now()) * 5) / 6
+			if w < 0 {
+				return
+			}
+			time.Sleep(w)
+			cl.updateTGT()
+		}
+	}()
+}
+
+//Renew the client's TGT session.
 func (cl *Client) RenewTGT() error {
 	spn := types.PrincipalName{
 		NameType:   nametype.KRB_NT_SRV_INST,
@@ -36,20 +52,6 @@ func (cl *Client) RenewTGT() error {
 	return nil
 }
 
-func (cl *Client) EnableAutoSessionRenewal() {
-	go func() {
-		for {
-			//Wait until one minute before endtime
-			w := (cl.Session.EndTime.Sub(time.Now()) * 5) / 6
-			if w < 0 {
-				return
-			}
-			time.Sleep(w)
-			cl.updateTGT()
-		}
-	}()
-}
-
 func (cl *Client) updateTGT() error {
 	if time.Now().Before(cl.Session.RenewTill) {
 		err := cl.RenewTGT()