Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RTAkland committed Sep 12, 2023
1 parent 09f979d commit f12a539
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/kotlin/cn/rtast/kwsify/Kwsify.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ class Kwsify(address: InetSocketAddress) : WebSocketServer(address) {
}

override fun onOpen(conn: WebSocket, handshake: ClientHandshake) {
println("New connection connected. ${conn.remoteSocketAddress}")
val validEndpoints = listOf("subscribe", "publish")
val endpoint = conn.resourceDescriptor.replace("/", "")
if (!validEndpoints.contains(endpoint)) {
conn.close(1000, "This endpoint is invalid.")
} else {
println("New connection connected. ${conn.remoteSocketAddress}")
}
}

override fun onClose(conn: WebSocket, code: Int, reason: String, remote: Boolean) {
Expand Down

0 comments on commit f12a539

Please sign in to comment.