func checkSocketAuthentication(s *bitmonster.Socket) { // Get the auth socket value. av := getAuthSocketValue(s) if av == nil { return } // Skip if not authenticated. if !av.isAuth { return } // Debug log. log.L.WithFields(logrus.Fields{ "remoteAddress": s.RemoteAddr(), }).Debugf("auth: reauthentication requested") // Trigger the event to reauthenticate. eventReauth.TriggerSocket(s) // Start a timeout to logout the socket session. av.reauthTimer = time.AfterFunc(reauthTimeout, func() { // Reset the socket authentication values. resetAuthSocketValue(s) }) }
// resetAuthSocketValue removes the socket authentication values and triggers // the socket Check method. func resetAuthSocketValue(s *bitmonster.Socket) { // Debug log. log.L.WithFields(logrus.Fields{ "remoteAddress": s.RemoteAddr(), }).Debugf("auth: authentication state resetted") // Get the auth socket value. av := getAuthSocketValue(s) if av != nil { // Stop the reauth timer if present. if av.reauthTimer != nil { av.reauthTimer.Stop() } } // Remove the socket auth value to delete the authenticated infos. s.DeleteValue(authSocketValueKey) // Clear the cache. clearCache(s) // Rerun the event hooks. // This will unbind events which require authentication. s.Check() }