implement FACK protocol command and ackXFTPChunk

This commit is contained in:
shum
2026-02-18 14:37:59 +00:00
parent ca2781a485
commit 17995b3cfc
2 changed files with 10 additions and 1 deletions
+8 -1
View File
@@ -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)
+2
View File
@@ -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))
}