на сегодня я сдался

This commit is contained in:
2026-05-25 02:07:27 +03:00
parent 67cf3f661a
commit 0fc52dff5a
2 changed files with 7 additions and 8 deletions

View File

@ -9,7 +9,7 @@ import kotlinx.io.readByteArray
import java.io.FileInputStream
fun main(args: Array<String>) {
val host = "192.168.88.242"
val host = "192.168.88.227"
val port = 9093
when (args.firstOrNull()) {

View File

@ -11,7 +11,6 @@ fun startServer(port: Int) = runBlocking {
val server = ServerSocket(port)
println("Server started")
while (true) {
val client = server.accept()
println("${client.inetAddress} Client pairing")
@ -20,7 +19,7 @@ fun startServer(port: Int) = runBlocking {
println("${client.inetAddress} Client connected")
try {
handle(client)
handle(client, tun)
} catch (e: Exception) {
println("${client.inetAddress} Client disconnected: ${e.message}")
}
@ -28,7 +27,7 @@ fun startServer(port: Int) = runBlocking {
}
}
suspend fun handle(socket: Socket) {
suspend fun handle(socket: Socket, tun: TunDevice) {
val input = withContext(Dispatchers.IO) {
socket.getInputStream()
}
@ -53,10 +52,10 @@ suspend fun handle(socket: Socket) {
val response = forwardPacket(packet)
output.write(response.size shr 8)
output.write(response.size)
output.write(response)
//output.write(response.size shr 8)
//output.write(response.size)
//output.write(response)
tun.output.write(packet, 0, len)
}
}
}