Skip to content

Commit

Permalink
Add IP address blocking #163
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrivoruchko committed Apr 25, 2021
1 parent ca5802b commit cf84dd0
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ internal class ClientData(
}

@Synchronized
fun onPinCheck(isPinValid: Boolean) {
fun onPinCheck(isPinValid: Boolean, blockAddress: Boolean) {
if (isPinValid.not()) {
pinCheckAttempt += 1
if (pinCheckAttempt >= DEFAULT_WRONG_PIN_MAX_COUNT) setBlocked()
if (blockAddress && pinCheckAttempt >= DEFAULT_WRONG_PIN_MAX_COUNT) setBlocked()
} else if (isBlocked.not()) {
isPinValidated = isPinValid
pinCheckAttempt = 0
Expand Down Expand Up @@ -104,7 +104,7 @@ internal class ClientData(

internal fun onDisconnected(id: Long) = clients[id]?.setDisconnected()

internal fun onPinCheck(id: Long, isPinValid: Boolean) = clients[id]?.onPinCheck(isPinValid)
internal fun onPinCheck(id: Long, isPinValid: Boolean) = clients[id]?.onPinCheck(isPinValid, blockAddress)

internal fun isClientAuthorized(id: Long): Boolean = clients[id]?.isPinValidated ?: false

Expand Down

0 comments on commit cf84dd0

Please sign in to comment.