small fix in client, more docs
This commit is contained in:
parent
192f7e135f
commit
745eb9ccdf
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@ -5,6 +5,7 @@
|
|||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="17 (5)" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
32
README.md
32
README.md
@ -1,8 +1,32 @@
|
|||||||
# Kiloparsec
|
# Kiloparsec
|
||||||
|
|
||||||
_The protocol is under active development, early access stage. Please wait for alfa!_
|
The new generation of __PARanoid SECurity__ protocol, advanced, faster, more secure. It also allows connecting any "block device" transport to the same local interface. Out if the box it
|
||||||
|
provides the following transports:
|
||||||
|
|
||||||
The new generation of __PARanoid SECurity__ protocol, advanced, faster, more secure.
|
| name | JVM | JS | native |
|
||||||
|
|----------------|-----|----|--------|
|
||||||
|
| TCP/IP server | * | | |
|
||||||
|
| TCP/IP client | * | | |
|
||||||
|
| Websock server | * | | |
|
||||||
|
| Websock client | * | * | * |
|
||||||
|
|
||||||
|
## TCP/IP transport
|
||||||
|
|
||||||
|
It is the fastest. JVM implementation uses nio2 async sockets and optimizes TCP socket to play
|
||||||
|
well with blocks (smart NO_DELAY mode). It is multiplatform, nut lacks of async TCP/IP support
|
||||||
|
on natvic targetm this is where I need help having little time. I'd prefer to use something asyn like UV on native targets.
|
||||||
|
|
||||||
|
I know no existing way to implement it in KotlinJS for the modern browsers.
|
||||||
|
|
||||||
|
## Websock server
|
||||||
|
|
||||||
|
While it is much slower than pure TCP, it is still faster than any http-based transport. It uses binary frames based on the Ktor server framework to easily integrate with web services. We recommend using it instead of a classic HTTP API as it beats it in terms of speed and server load even with HTTP/2.
|
||||||
|
|
||||||
|
We recommend to create the `KiloInterface<S>` instance and connect it to the websock and tcp servers in real applications to get easy access from anywhere.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
# Details
|
||||||
|
|
||||||
It is not compatible with parsec family and no more based on an Universa crypto library. To better fit
|
It is not compatible with parsec family and no more based on an Universa crypto library. To better fit
|
||||||
the modern state of threats and rate of cyber crimes, KiloParsec uses more encryption and random key exchange on each
|
the modern state of threats and rate of cyber crimes, KiloParsec uses more encryption and random key exchange on each
|
||||||
@ -10,9 +34,9 @@ and every connection (while parsec caches session keys to avoid time-consuming k
|
|||||||
keys cryptography for session is shifted to use ed25519 curves which are supposed to provide agreeable strength with
|
keys cryptography for session is shifted to use ed25519 curves which are supposed to provide agreeable strength with
|
||||||
enough speed to protect every connection with a unique new keys. Also, we completely get rid of SHA2.
|
enough speed to protect every connection with a unique new keys. Also, we completely get rid of SHA2.
|
||||||
|
|
||||||
Kiloparsec also uses a denser binary format (bipack, no more key-values)
|
Kiloparsec also uses a denser binary format [bipack](https://gitea.sergeych.net/SergeychWorks/mp_bintools), no more key-values,
|
||||||
which reveals much less on the inner data structure, providing advanced
|
which reveals much less on the inner data structure, providing advanced
|
||||||
typed RPC interfaces with kotlinx.serialization.
|
typed RPC interfaces with kotlinx.serialization. There is also Rust implementation [bipack_ru](https://gitea.sergeych.net/DiWAN/bipack_ru).
|
||||||
The architecture allows connecting same functional interfaces to several various type channels at once.
|
The architecture allows connecting same functional interfaces to several various type channels at once.
|
||||||
|
|
||||||
Also, the difference from parsecs is that there are no more unencrypted layer commands available to users.
|
Also, the difference from parsecs is that there are no more unencrypted layer commands available to users.
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform") version "1.9.20"
|
kotlin("multiplatform") version "1.9.21"
|
||||||
id("org.jetbrains.kotlin.plugin.serialization") version "1.9.20"
|
id("org.jetbrains.kotlin.plugin.serialization") version "1.9.21"
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "net.sergeych"
|
group = "net.sergeych"
|
||||||
version = "0.1.0-SNAPSHOT"
|
version = "0.1.2-SNAPSHOT"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -26,7 +25,7 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
js(KotlinJsCompilerType.IR) {
|
js(IR) {
|
||||||
browser {
|
browser {
|
||||||
// commonWebpackConfig {
|
// commonWebpackConfig {
|
||||||
// cssSupport {
|
// cssSupport {
|
||||||
@ -63,8 +62,8 @@ kotlin {
|
|||||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
|
||||||
|
|
||||||
implementation("com.ionspin.kotlin:multiplatform-crypto-libsodium-bindings:0.9.0")
|
implementation("com.ionspin.kotlin:multiplatform-crypto-libsodium-bindings:0.9.0")
|
||||||
api("com.ionspin.kotlin:bignum:0.3.8")
|
api("com.ionspin.kotlin:bignum:0.3.9")
|
||||||
implementation("io.ktor:ktor-client-core:$ktor_version")
|
api("io.ktor:ktor-client-core:$ktor_version")
|
||||||
|
|
||||||
api("net.sergeych:mp_bintools:0.0.6-SNAPSHOT")
|
api("net.sergeych:mp_bintools:0.0.6-SNAPSHOT")
|
||||||
api("net.sergeych:mp_stools:1.4.1")
|
api("net.sergeych:mp_stools:1.4.1")
|
||||||
@ -84,7 +83,7 @@ kotlin {
|
|||||||
implementation("io.ktor:ktor-server-core-jvm:$ktor_version")
|
implementation("io.ktor:ktor-server-core-jvm:$ktor_version")
|
||||||
implementation("io.ktor:ktor-server-websockets-jvm:$ktor_version")
|
implementation("io.ktor:ktor-server-websockets-jvm:$ktor_version")
|
||||||
implementation("io.ktor:ktor-server-netty:$ktor_version")
|
implementation("io.ktor:ktor-server-netty:$ktor_version")
|
||||||
implementation("io.ktor:ktor-client-cio:$ktor_version")
|
api("io.ktor:ktor-client-cio:$ktor_version")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val jvmTest by getting
|
val jvmTest by getting
|
||||||
@ -101,4 +100,22 @@ kotlin {
|
|||||||
}
|
}
|
||||||
val nativeTest by getting
|
val nativeTest by getting
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
val mavenToken by lazy {
|
||||||
|
File("${System.getProperty("user.home")}/.gitea_token").readText()
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
credentials(HttpHeaderCredentials::class) {
|
||||||
|
name = "Authorization"
|
||||||
|
value = mavenToken
|
||||||
|
}
|
||||||
|
url = uri("https://gitea.sergeych.net/api/packages/SergeychWorks/maven")
|
||||||
|
authentication {
|
||||||
|
create("Authorization", HttpHeaderAuthentication::class)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class KiloClient<S>(
|
|||||||
val client = KiloClientConnection(localInterface, kc,secretKey)
|
val client = KiloClientConnection(localInterface, kc,secretKey)
|
||||||
deferredClient.complete(client)
|
deferredClient.complete(client)
|
||||||
client.run {
|
client.run {
|
||||||
_state.value = false
|
_state.value = it
|
||||||
}
|
}
|
||||||
debug { "client run finished" }
|
debug { "client run finished" }
|
||||||
} catch (_: RemoteInterface.ClosedException) {
|
} catch (_: RemoteInterface.ClosedException) {
|
||||||
|
@ -7,7 +7,13 @@ import net.sergeych.utools.unpack
|
|||||||
|
|
||||||
private var L1IdCounter = 0
|
private var L1IdCounter = 0
|
||||||
|
|
||||||
// todo: We don't need it deferred here
|
/**
|
||||||
|
* Represents a remote interface for interacting with a Kiloparsec service.
|
||||||
|
*
|
||||||
|
* @param S the scope type of the Kiloparsec service which will be used to call local functions remotely
|
||||||
|
* @property deferredParams a [CompletableDeferred] that resolves to the parameters required for making remote calls
|
||||||
|
* @property clientInterface a [LocalInterface] used to communicate with the local client
|
||||||
|
*/
|
||||||
class KiloRemoteInterface<S>(
|
class KiloRemoteInterface<S>(
|
||||||
private val deferredParams: CompletableDeferred<KiloParams<S>>,
|
private val deferredParams: CompletableDeferred<KiloParams<S>>,
|
||||||
private val clientInterface: LocalInterface<KiloScope<S>>,
|
private val clientInterface: LocalInterface<KiloScope<S>>,
|
||||||
|
@ -79,8 +79,8 @@ fun <S>websocketClient(
|
|||||||
}
|
}
|
||||||
val device = ProxyDevice(input,output) {
|
val device = ProxyDevice(input,output) {
|
||||||
input.close()
|
input.close()
|
||||||
// we need to explicitly close the coroutine job or it can hang active
|
// we need to explicitly close the coroutine job, or it can hang for a long time
|
||||||
// forever and leak resources:
|
// leaking resources.
|
||||||
job.cancel()
|
job.cancel()
|
||||||
}
|
}
|
||||||
KiloConnectionData(device, sessionMaker())
|
KiloConnectionData(device, sessionMaker())
|
||||||
|
@ -12,6 +12,7 @@ import net.sergeych.mp_logger.Log
|
|||||||
import java.net.InetAddress
|
import java.net.InetAddress
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class ClientTest {
|
class ClientTest {
|
||||||
|
|
||||||
@ -78,6 +79,7 @@ class ClientTest {
|
|||||||
val client = websocketClient<Unit>("ws://localhost:8080/kp")
|
val client = websocketClient<Unit>("ws://localhost:8080/kp")
|
||||||
println(1)
|
println(1)
|
||||||
assertEquals(true, client.call(cmdCheckConnected))
|
assertEquals(true, client.call(cmdCheckConnected))
|
||||||
|
assertTrue { client.state.value }
|
||||||
println(2)
|
println(2)
|
||||||
assertEquals("not set", client.call(cmdGetFoo))
|
assertEquals("not set", client.call(cmdGetFoo))
|
||||||
println(3)
|
println(3)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user