-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Complete parcel collection (#29)
For example, here's how a private endpoint could use this: ```kotlin val port = 13276 // On Android; 276 on desktop val client = PoWebClient.initLocal(port) // Specify the cert and private key of each endpoint. Needed to complete the handshake. val nonceSigners = arrayOf( NonceSigner(endpointCertificate, endpointKeyPair.private) ) runBlocking { client.use { client.collectParcels(nonceSigners).map { val parcel = try { it.deserializeAndValidateParcel() } catch (exc: RelaynetException) { it.ack() logWarning("Invalid parcel received", exc) return@map } val path = generateRandomPath() File(path).writeBytes(it.parcelSerialized) saveToDB(parcel, path) // ACK once the parcel has been safely processed/stored it.ack() } } } ``` `collectParcels()` takes an optional argument (`StreamingMode`). It defaults to `StreamingMode.KeepAlive`.
- Loading branch information
Showing
18 changed files
with
838 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
package tech.relaycorp.poweb | ||
|
||
public class PoWebException(message: String, cause: Throwable? = null) : Exception(message, cause) | ||
public abstract class PoWebException internal constructor( | ||
message: String, | ||
cause: Throwable? = null | ||
) : Exception(message, cause) | ||
|
||
/** | ||
* Base class for connectivity errors and errors caused by the server. | ||
*/ | ||
public sealed class ServerException(message: String, cause: Throwable?) : | ||
PoWebException(message, cause) | ||
|
||
/** | ||
* Error before or while connected to the server. | ||
* | ||
* The client should retry later. | ||
*/ | ||
public class ServerConnectionException(message: String, cause: Throwable? = null) : | ||
ServerException(message, cause) | ||
|
||
/** | ||
* The server sent an invalid message. | ||
* | ||
* The server didn't adhere to the protocol. Retrying later is unlikely to make a difference. | ||
*/ | ||
public class InvalidServerMessageException(message: String, cause: Throwable) : | ||
ServerException(message, cause) | ||
|
||
/** | ||
* The client made a mistake while specifying the nonce signer(s). | ||
*/ | ||
public class NonceSignerException(message: String) : PoWebException(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/main/kotlin/tech/relaycorp/poweb/handshake/InvalidChallengeException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package tech.relaycorp.poweb.handshake | ||
|
||
public class InvalidChallengeException(message: String) : Exception(message) |
3 changes: 0 additions & 3 deletions
3
src/main/kotlin/tech/relaycorp/poweb/handshake/InvalidMessageException.kt
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
src/main/kotlin/tech/relaycorp/poweb/handshake/InvalidResponseException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package tech.relaycorp.poweb.handshake | ||
|
||
public class InvalidResponseException(message: String) : Exception(message) |
15 changes: 0 additions & 15 deletions
15
src/main/kotlin/tech/relaycorp/poweb/handshake/NonceSigner.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.