Remove ktor-network dependency use native socket
This commit is contained in:
21 files changed
+649
-179
No files matched your search
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright © 2025 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 9/29/25
|
||||
*/
|
||||
|
||||
|
||||
package test
|
||||
|
||||
import cn.rtast.nmdns.broadcast
|
||||
import cn.rtast.nmdns.randomMacAddress
|
||||
import cn.rtast.nmdns.registerService
|
||||
import cn.rtast.nmdns.sleep1
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlin.test.Test
|
||||
|
||||
class LinuxTest {
|
||||
@Test
|
||||
fun `test on linux`() {
|
||||
runBlocking {
|
||||
val service = registerService(
|
||||
serviceType = "_airplay._tcp.local.",
|
||||
serviceName = "AP@RTAST",
|
||||
hostname = "rtakland.local.",
|
||||
ipAddress = "192.168.10.104",
|
||||
port = 7001,
|
||||
bindAddress = "192.168.10.104",
|
||||
mdnsPort = 5356,
|
||||
txtRecords = listOf(
|
||||
"deviceid=${randomMacAddress()}",
|
||||
"model=AppleTV3,2C",
|
||||
"features=0x5A7FFFF7,0x1E",
|
||||
"srcvers=220.68",
|
||||
"pk=f3769a660475d27b4f6040381d784645e13e21c53e6d2da6a8c3d757086fc336"
|
||||
)
|
||||
)
|
||||
while (true) {
|
||||
service.broadcast()
|
||||
sleep1(2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright © 2025 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 9/29/25
|
||||
*/
|
||||
|
||||
|
||||
package test
|
||||
|
||||
import cn.rtast.nmdns.randomMacAddress
|
||||
import cn.rtast.nmdns.registerService
|
||||
import cn.rtast.nmdns.sleep1
|
||||
import kotlin.test.Test
|
||||
|
||||
class TestLinux {
|
||||
@Test
|
||||
fun `test on linux`() {
|
||||
val service = registerService(
|
||||
serviceType = "_airplay._tcp.local.",
|
||||
serviceName = "AP@RTAST",
|
||||
hostname = "rtakland.local.",
|
||||
ipAddress = "192.168.10.104",
|
||||
port = 7001,
|
||||
bindAddress = "192.168.10.104",
|
||||
mdnsPort = 5356,
|
||||
txtRecords = listOf(
|
||||
"deviceid=${randomMacAddress()}",
|
||||
"model=AppleTV3,2C",
|
||||
"features=0x5A7FFFF7,0x1E",
|
||||
"srcvers=220.68",
|
||||
"pk=f3769a660475d27b4f6040381d784645e13e21c53e6d2da6a8c3d757086fc336"
|
||||
)
|
||||
)
|
||||
while (true) {
|
||||
service.broadcast()
|
||||
sleep1(2)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright © 2025 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 9/30/25
|
||||
*/
|
||||
|
||||
|
||||
package test
|
||||
|
||||
import cn.rtast.nmdns.randomMacAddress
|
||||
import kotlin.test.Test
|
||||
|
||||
class TestMacAddr {
|
||||
|
||||
@Test
|
||||
fun `test generate mac address`() {
|
||||
println(randomMacAddress())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright © 2025 RTAkland
|
||||
* Author: RTAkland
|
||||
* Date: 9/30/25
|
||||
*/
|
||||
|
||||
|
||||
package test
|
||||
|
||||
import cn.rtast.nmdns.buildPacket
|
||||
import cn.rtast.nmdns.createSocket
|
||||
import cn.rtast.nmdns.randomMacAddress
|
||||
import cn.rtast.nmdns.sleep1
|
||||
import kotlin.test.Test
|
||||
|
||||
class TestNative {
|
||||
|
||||
@Test
|
||||
fun `test native socket`() {
|
||||
val packet = buildPacket(
|
||||
serviceType = "_airplay._tcp.local.",
|
||||
serviceName = "AP@RTAST._airplay._tcp.local.",
|
||||
hostname = "rtakland.local.",
|
||||
ip = "192.168.10.104",
|
||||
port = 7001,
|
||||
txtRecords = listOf(
|
||||
"deviceid=${randomMacAddress()}",
|
||||
"model=AppleTV3,2C",
|
||||
"features=0x5A7FFFF7,0x1E",
|
||||
"srcvers=220.68",
|
||||
"pk=f3769a660475d27b4f6040381d784645e13e21c53e6d2da6a8c3d757086fc336"
|
||||
)
|
||||
)
|
||||
|
||||
val service = createSocket()
|
||||
.bind("192.168.10.104", 4546)
|
||||
while (true) {
|
||||
service.send(packet.copyOf())
|
||||
sleep1(2)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user