Skip to content

Commit

Permalink
encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Jan 11, 2024
1 parent 906c416 commit c780f2b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions deserialize_chunk.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ local param1, param2, node_data

-- deserializes the chunk to the world
function mapsync.deserialize_chunk(chunk_pos, filename, vmanip)
-- TODO: check for key.json
-- mapsync.parse_chunk_key(filename)
-- if encrypted: decrypt if key available or move to pending queue
local chunk, err_msg = mapsync.parse_chunk(filename)
if not chunk then
return false, err_msg
Expand Down
15 changes: 12 additions & 3 deletions serialize_chunk.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ function mapsync.serialize_chunk(chunk_pos, filename)
return true
end

-- get key manifest from zip before overwriting
local key_manifest = mapsync.parse_chunk_key(filename)

-- open zip for writing
local f = global_env.io.open(filename, "wb")
if not f then
Expand Down Expand Up @@ -92,9 +95,15 @@ function mapsync.serialize_chunk(chunk_pos, filename)
end
end

zip:add("mapdata.bin", table.concat(mapdata))
zip:add("metadata.json", minetest.write_json(metadata))
zip:add("manifest.json", minetest.write_json(manifest))
if key_manifest then
-- encrypt and add key manifest
-- TODO
else
-- store plain
zip:add("mapdata.bin", table.concat(mapdata))
zip:add("metadata.json", minetest.write_json(metadata))
zip:add("manifest.json", minetest.write_json(manifest))
end

zip:close()
f:close()
Expand Down

0 comments on commit c780f2b

Please sign in to comment.