Skip to content

Commit 66eae92

Browse files
authored
Axcwg verification update 1.2.1
2 parents 990f84e + ba8a357 commit 66eae92

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
1.2.0-FIX_2
22

3-
<a href="https://github.com/Bumer-32/I-Want-To-Control-My-Server/issues/10">Fixed wrong working with filesystem for linux users</a> (Thank you <a href="https://github.com/AXCWG">AXCWG</a>)
3+
<a href="https://github.com/Bumer-32/I-Want-To-Control-My-Server/pull/12">3-time validation & login status check</a> (Thank you <a href="https://github.com/AXCWG">AXCWG</a>)

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fabric_version=0.107.0+1.21.3
1111
fabric_kotlin_version=1.12.3+kotlin.2.0.21
1212

1313
# Mod Properties
14-
mod_version=1.2.0-FIX_2
14+
mod_version=1.2.1
1515
maven_group=ua.pp.lumivoid.iwtcms
1616
archives_base_name=iwtcms
1717

src/main/kotlin/ua/pp/lumivoid/iwtcms/server/ClientHandler.kt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class ClientHandler(client: Socket?, private val server: Server) {
1818
private val writer: OutputStream = this.client.getOutputStream()
1919
private var running = false
2020
private var authorized = false
21+
private var times_tried = 0;
22+
2123

2224
fun run() {
2325
running = true
@@ -58,7 +60,7 @@ class ClientHandler(client: Socket?, private val server: Server) {
5860

5961
private fun command(data: String) {
6062
when {
61-
data == "iwtcms_shutdown" -> {
63+
data == "iwtcms_shutdown" -> {
6264
shutdown()
6365
}
6466

@@ -67,13 +69,24 @@ class ClientHandler(client: Socket?, private val server: Server) {
6769
}
6870

6971
data.startsWith("iwtcms_login") -> {
72+
if(authorized){
73+
write("Already logged in. \n")
74+
return
75+
}
7076
val loginData = data.split(" ")
7177

7278
if (loginData[1].replace("\n", "") == Constants.passwordHash) {
7379
authorized = true
7480
write("iwtcms_login_success\n")
7581
} else {
7682
write("iwtcms_login_failed\n", false)
83+
times_tried++
84+
if(times_tried > 2){
85+
write(("Maximum retries. Login failed. \n"), false)
86+
shutdown();
87+
logger.info("Login attempt failed for 3 wrong password input: ${client.inetAddress}")
88+
89+
}
7790
}
7891

7992
}
@@ -89,7 +102,10 @@ class ClientHandler(client: Socket?, private val server: Server) {
89102

90103
try {
91104
if (MinecraftServerHandler.server != null) {
92-
MinecraftServerHandler.server!!.commandManager.executeWithPrefix(MinecraftServerHandler.server!!.commandSource, data)
105+
MinecraftServerHandler.server!!.commandManager.executeWithPrefix(
106+
MinecraftServerHandler.server!!.commandSource,
107+
data
108+
)
93109
}
94110
} catch (e: Exception) {
95111
e.stackTrace.forEach { logger.error(it.toString()) }

0 commit comments

Comments
 (0)