oh blya
This commit is contained in:
@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "su.sonoma"
|
group = "su.sonoma"
|
||||||
version = "1.0-SNAPSHOT"
|
version = "0.1"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -14,6 +14,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
implementation("io.ktor:ktor-network:3.1.3")
|
implementation("io.ktor:ktor-network:3.1.3")
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.22")
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,6 +22,26 @@ kotlin {
|
|||||||
jvmToolchain(25)
|
jvmToolchain(25)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.jar {
|
||||||
|
dependsOn("buildTunLib")
|
||||||
|
dependsOn(configurations.runtimeClasspath)
|
||||||
|
|
||||||
|
manifest {
|
||||||
|
attributes["Main-Class"] = "su.sonoma.MainKt"
|
||||||
|
}
|
||||||
|
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
|
||||||
|
from(sourceSets.main.get().output)
|
||||||
|
|
||||||
|
from({
|
||||||
|
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
|
||||||
|
})
|
||||||
|
|
||||||
|
archiveBaseName.set(rootProject.name)
|
||||||
|
archiveVersion.set(version.toString())
|
||||||
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
@ -35,6 +56,11 @@ tasks.register<JavaExec>("runServer") {
|
|||||||
"--add-opens=java.base/java.io=ALL-UNNAMED"
|
"--add-opens=java.base/java.io=ALL-UNNAMED"
|
||||||
)
|
)
|
||||||
dependsOn("buildTunLib")
|
dependsOn("buildTunLib")
|
||||||
|
|
||||||
|
systemProperty(
|
||||||
|
"java.library.path",
|
||||||
|
"${projectDir}/build/native/"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register<JavaExec>("runClient") {
|
tasks.register<JavaExec>("runClient") {
|
||||||
@ -47,6 +73,11 @@ tasks.register<JavaExec>("runClient") {
|
|||||||
"--add-opens=java.base/java.io=ALL-UNNAMED"
|
"--add-opens=java.base/java.io=ALL-UNNAMED"
|
||||||
)
|
)
|
||||||
dependsOn("buildTunLib")
|
dependsOn("buildTunLib")
|
||||||
|
|
||||||
|
systemProperty(
|
||||||
|
"java.library.path",
|
||||||
|
"${projectDir}/build/native/"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val javaHome = Jvm.current().javaHome.absolutePath
|
val javaHome = Jvm.current().javaHome.absolutePath
|
||||||
@ -75,3 +106,52 @@ tasks.register<Exec>("buildTunLib") {
|
|||||||
"-I$javaHome/include/linux"
|
"-I$javaHome/include/linux"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.register("generateRunScript") {
|
||||||
|
|
||||||
|
val output = layout.buildDirectory.file("tmp/${rootProject.name}")
|
||||||
|
val name = rootProject.name.plus('-').plus(version)
|
||||||
|
val jarName = name.plus(".jar")
|
||||||
|
|
||||||
|
outputs.file(output)
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
val script = output.get().asFile
|
||||||
|
|
||||||
|
script.parentFile.mkdirs()
|
||||||
|
|
||||||
|
script.writeText("""
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
java \
|
||||||
|
-Djava.library.path="." \
|
||||||
|
-jar "$jarName" "$@"
|
||||||
|
""".trimIndent())
|
||||||
|
|
||||||
|
script.setExecutable(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<Tar>("packageApp") {
|
||||||
|
group = "build"
|
||||||
|
|
||||||
|
destinationDirectory.set(layout.buildDirectory.dir("dist"))
|
||||||
|
|
||||||
|
compression = Compression.GZIP
|
||||||
|
|
||||||
|
dependsOn("jar")
|
||||||
|
dependsOn("generateRunScript")
|
||||||
|
|
||||||
|
val name = rootProject.name.plus('-').plus(version)
|
||||||
|
val jarName = name.plus(".jar")
|
||||||
|
|
||||||
|
archiveFileName.set("$name.tar.gz")
|
||||||
|
|
||||||
|
|
||||||
|
from("build/libs/$jarName")
|
||||||
|
|
||||||
|
from("build/native/libtun.so")
|
||||||
|
|
||||||
|
from("build/tmp/${rootProject.name}")
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
package su.sonoma
|
package su.sonoma
|
||||||
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import java.io.DataInputStream
|
import java.io.DataInputStream
|
||||||
import java.net.Socket
|
import java.net.Socket
|
||||||
|
|||||||
@ -1,13 +1,5 @@
|
|||||||
package su.sonoma
|
package su.sonoma
|
||||||
|
|
||||||
import io.ktor.network.selector.*
|
|
||||||
import io.ktor.network.sockets.*
|
|
||||||
import io.ktor.utils.io.*
|
|
||||||
import io.ktor.utils.io.core.readBytes
|
|
||||||
import kotlinx.coroutines.*
|
|
||||||
import kotlinx.io.readByteArray
|
|
||||||
import java.io.FileInputStream
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
val host = "192.168.88.227"
|
val host = "192.168.88.227"
|
||||||
val port = 9093
|
val port = 9093
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package su.sonoma
|
package su.sonoma
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
import java.io.FileDescriptor
|
import java.io.FileDescriptor
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
@ -12,9 +13,7 @@ class TunDevice(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
init {
|
init {
|
||||||
System.load(
|
System.loadLibrary("tun")
|
||||||
"${System.getProperty("user.dir")}/build/native/libtun.so"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user