Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement maximum response length #41

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions nic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,14 @@ minetest.register_node("digistuff:nic", {
user_agent = "Minetest Digilines Modem"
},
function(res)
if type(res.data) == "string" and parse_json then
-- parse json data and replace payload
res.data = minetest.parse_json(res.data)
if type(res.data) == "string" then
if parse_json then
-- parse json data and replace payload
res.data = minetest.parse_json(res.data)
else
local max_length = minetest.settings:get("digistuff_max_nic_length") or 5000
res.data = res.data:sub(-max_length)
end
end
digilines.receptor_send(pos, digilines.rules.default, channel, res)
end)
Expand Down
3 changes: 3 additions & 0 deletions settingstypes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[digistuff]

digistuff_max_nic_length (Maximum NIC response length) int 5000 2000 10000
Loading