mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-05-30 05:04:07 +00:00
implement FACK protocol command and ackXFTPChunk
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
||||
import {verifyIdentityProof} from "./crypto/identity.js"
|
||||
import {generateX25519KeyPair, encodePubKeyX25519, dh} from "./crypto/keys.js"
|
||||
import {
|
||||
encodeFNEW, encodeFADD, encodeFPUT, encodeFGET, encodeFDEL, encodePING,
|
||||
encodeFNEW, encodeFADD, encodeFPUT, encodeFGET, encodeFACK, encodeFDEL, encodePING,
|
||||
decodeResponse, type FileResponse, type FileInfo, type XFTPErrorType
|
||||
} from "./protocol/commands.js"
|
||||
import {decryptReceivedChunk} from "./download.js"
|
||||
@@ -430,6 +430,13 @@ export async function deleteXFTPChunk(
|
||||
if (response.type !== "FROk") throw new Error("unexpected response: " + response.type)
|
||||
}
|
||||
|
||||
export async function ackXFTPChunk(
|
||||
agent: XFTPClientAgent, server: XFTPServer, rpKey: Uint8Array, rId: Uint8Array
|
||||
): Promise<void> {
|
||||
const {response} = await sendXFTPCommand(agent, server, rpKey, rId, encodeFACK())
|
||||
if (response.type !== "FROk") throw new Error("unexpected response: " + response.type)
|
||||
}
|
||||
|
||||
export async function pingXFTP(agent: XFTPClientAgent, server: XFTPServer): Promise<void> {
|
||||
const client = await getXFTPServerClient(agent, server)
|
||||
const corrId = new Uint8Array(0)
|
||||
|
||||
@@ -73,6 +73,8 @@ export function encodeFPUT(): Uint8Array { return ascii("FPUT") }
|
||||
|
||||
export function encodeFDEL(): Uint8Array { return ascii("FDEL") }
|
||||
|
||||
export function encodeFACK(): Uint8Array { return ascii("FACK") }
|
||||
|
||||
export function encodeFGET(rcvDhKey: Uint8Array): Uint8Array {
|
||||
return concatBytes(ascii("FGET"), SPACE, encodeBytes(rcvDhKey))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user