administration.lua 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. -- mod governor by mckaygerhard, administration specific code
  2. -- Copyright 2023
  3. ----------------------------------------------------------------------------
  4. -- this program can be used free but cannot be used commertially or
  5. -- modified for, licenced CC-BY-SA-NC 4.0 unless explicit permission
  6. -- This program is distributed in the hope that it will be useful,
  7. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. ----------------------------------------------------------------------------
  10. --[[ init privileges registrations ]]
  11. minetest.register_privilege("governing", {
  12. description = "can do geoip lookups on players for governing",
  13. give_to_singleplayer = false
  14. })
  15. if not governing.modgeoip then
  16. minetest.register_privilege("geoip", {
  17. description = "governing: ip checks + lookups on players",
  18. give_to_singleplayer = false
  19. })
  20. end
  21. --[[ end privileges registrations ]]
  22. gapi.extraversion = {
  23. "2.0.4", -- multicraft
  24. "dragonfire", -- many based clients by example teamclient
  25. "f8fd5c11b", -- Merge pull request #59 from PrairieAstronomer/readme_irrlicht_change
  26. "c66ae6717", -- Add exact irrlichtmt version to the clone command
  27. "296cce39d", -- Fix upstream merge issues
  28. "350b6d175", -- Install lua_async dependency
  29. "393c83928", -- Don't include client/game.h on server build
  30. "ccd4c504d", -- Ship dragonfireclient with selected high-quality mods
  31. "147aaf326", -- Fix build instructions
  32. "b09fc5de5", -- Add spider
  33. "d404517d2", -- Make LuaVoxelManipulator available to CSM API
  34. "1ccf88e80", -- minetest.dig_node: Remove node
  35. "950d2c9b3", -- Add ClientObjectRef:remove and return true in on_object_add callback to remove newly added object
  36. "fb4815c66", -- Merge pull request #35 from arydevy/patch-1
  37. "f12288814", -- Merge pull request #42 from Minetest-j45/master
  38. "f3082146c", -- remove irrlicht from lid dir (accident)
  39. "a3925db22", -- add airjump and remove unused headers
  40. "7824a4956", -- Merge pull request #1 from EliasFleckenstein03/master
  41. "35445d24f", -- Make set_pitch and set_yaw more accurate by not rounding it to integers
  42. "5131675a6", -- Add guards to stop server build fail
  43. "96a37aed3", -- Add minetest.get_send_speed
  44. "d08242316", -- Fix format
  45. "ce0d81a82", -- Change default cheat menu entry height
  46. "b7abc8df2", -- Add on_object_add callback
  47. "4f613bbf5", -- Include tile definitions in get_node_def; Client-side minetest.object_refs table
  48. "c86dcd0f6", -- Add on_object_hp_change callback and nametag images
  49. "b84ed7d0b", -- Call on_object_properties_change callback when adding object to scene
  50. "26cfbda65", -- Add on_object_properties_change callback
  51. "6dc7a65d9", -- Add ClientObjectRef:set_properties
  52. "7d7d4d675", -- Add ClientObjectRef.get_properties
  53. "ea8fa30b6", -- Changed README.md to fit the dragonfire client
  54. "c47eae316", -- Add table.combine to luacheckrc
  55. "83d09ffaf", -- Complete documentation
  56. "e0b4859e7", -- Add ClientObjectRef:remove
  57. "63f7c96ec", -- Fix legit_speed
  58. "5c06763e8", -- Add noise to client CSM API
  59. "7613d9bfe", -- Update .wielded command to output the entire itemstring; add LocalPlayer:get_hotbar_size
  60. "bc79c2344", -- CSM: Use server-like (and safe) HTTP API instead of Mainmenu-like
  61. "166968232", -- Port formspec API from waspsaliva This API is inofficial and undocumented; invalid usage causes the game to crash. Use at own risk!
  62. "e391ee435", -- Forcefully place items when minetest.place_node is used
  63. "546ab256b", -- Update buildbot to new MineClone2 repo and set the game name to MineClone2 rather than mineclone2
  64. "d3780cefd", -- Attempt to fix SEGFAULT in push_inventory
  65. "d1c84ada2", -- Merge minetest changes
  66. "74f5f033e", -- Add Custom version string
  67. "b2f629d8d", -- Logo improvements
  68. "78b7d1019", -- Add dragonfire logo
  69. "19e0528e3", -- Add minetest.get_nearby_objects
  70. "47d0882cc", -- Fix line containing only whitespace
  71. "4fedc3a31", -- Add minetest.interact
  72. "dc67f669e", -- Make the Cheat Menu size configureable
  73. "906845a87", -- Add minetest.registered_items and minetest.registered_nodes (Doesn't do anything yet)
  74. "3a4325902", -- Fixed crash by adding legacy stuff to defaultsettings (for now)
  75. "53c991c5f", -- Fixed crash due to missing entry in defaultsettings.cpp
  76. "0c6e0c717", -- Reorganize categories
  77. "e8faa2afb", -- Rework Range
  78. "a4d914ba2", -- Make GitHub Actions Happy try 3
  79. "a34c61093", -- Make GitHub Actions Happy try 2
  80. "f783f5939", -- Make GitHub Actions Happy try 1
  81. "8b58465aa", -- Remove obsolete code from clientenvironment
  82. "35c15567a", -- Update builtin/settingtypes.txt to the new philosophy
  83. "0c9e7466e", -- New Cheat Philosophy
  84. "a1e61e561", -- World Cheats improvements; Add BlockLava; Readd minetest.request_http_api for Compatibility
  85. "56d536ea5", -- Update CheatDB URL again
  86. "ce47003cc", -- Update defaults for ContentDB (->CheatDB)
  87. "89995efee", -- CheatDB Support & Enable/Disable CSMs in Main Menu
  88. "3df23e23c", -- Small AutoTool Fix
  89. "8b3eaf5b0", -- Lua API: Particle callbacks; Add NoWeather
  90. "0a285dd33", -- Remove NextItem
  91. "4695222bc", -- Fix and Improve AutoTool
  92. "5bead7daa", -- Added minetest.close_formspec
  93. "f825cf0e3", -- Fixed Minimap position
  94. "eaa8a5132", -- Fixed FastPlace and AutoPlace
  95. "b4e475726", -- Added configureable Colors for PlayerESP and EntityESP
  96. "549025f6a", -- EntityESP, EntityTracers, PlayerESP, PlayerTracers
  97. "eb6aca8b4", -- Merged Minetest
  98. "8de51dae9", -- Fixed crash when attempting to access nonexistant inventory from Lua API
  99. "a65251a7a", -- Fixed glowing GenericCAOs being rendered completely back when Fullbright is enabled
  100. "eaec3645b", -- Added ClientObjectRef:get_hp()
  101. "fb4d54ee3", -- Added minetest.register_on_play_sound
  102. "50629cc6a", -- Improved Scaffold
  103. "3d74e17cc", -- Added AutoSlip (-> Credit to Code-Sploit)
  104. "f9c632466", -- Added JetPack and AutoHit (-> Credits to Code-Sploit and cora)
  105. "843239c0b", -- Added Speed/Jump/Gravity Override
  106. "598e9bdbc", -- Update Credits
  107. "7d327def8", -- Improved AutoSneak
  108. "82216e147", -- LocalPlayer:set_physics_override; minetest.register_on_recieve_physics_override
  109. "4dd5ecfc5", -- Added setpitch & setyaw commands; AutoSprint
  110. "b65db98bd", -- Added OnlyTracePlayers
  111. "e16bbc1fb", -- Merge pull request #14 from corarona/master
  112. "1780adeea", -- lua-api: fix get/set_pitch
  113. "3e7c5d720", -- Possibility to use cheat menu while pressing other keys
  114. "0aa63aafc", -- Fixed warning
  115. "9db80fc6f", -- Run Lint Script
  116. "91ad0d049", -- Merge pull request #10 from corarona/master
  117. "6bda686c0", -- MapBlockMesh Performance Improvement
  118. "1bab49049", -- add LUA_FCT
  119. "6efa8a758", -- add g/s pitch and make_screenshot in lua api
  120. "46237330d", -- Several Enhancements
  121. "60a9ff6ff", -- api-screenshot: change function name to make_screenshot
  122. "1f56317d5", -- Added NodeESP
  123. "75ecaa217", -- Fix and run the Lint autocorrect script
  124. "6ccb5835f", -- Revert "Make Lint Happy"
  125. "244713971", -- Added script that automaticall corrects lint style
  126. "07e61e115", -- Fix github build problems #3
  127. "3af10766f", -- Fix github build problems #2
  128. "16d302c9a", -- Fix github build problems
  129. "ad148587d", -- Make Lint Happy
  130. "1145b05ea", -- Updated Credits
  131. "c9221730d", -- Updated Cheat Menu Color Design
  132. "1799d5aa9", -- Cheat Menu Improvements Change
  133. "fba7dc216", -- Merge pull request #8 from realOneplustwo/master
  134. "a7dc1135e", -- Added CheatHUD
  135. "f1d9ac014", -- Moved Killaura to Lua; Added ForceField; Added Friendlist; Added ClientObjectRef:is_local_player(); Documented LocalPlayer:get_object()
  136. "06b72069d", -- Fixed ColorChat
  137. "62958bd60", -- Reverted accidental commit in wrong repo
  138. "00d51fbd5", -- Armor textures support
  139. "7cbe42b1d", -- Re-Added Chat Effects
  140. "28f6a7970", -- lua api: add set/get_pitch
  141. "4f9797b6e", -- lua api: add core.take_screenshot()
  142. "8e9e76a50", -- Revert "Add Block Formspec Hack"
  143. "6652d7ac2", -- Add Block Formspec Hack
  144. "8bc7d49b3", -- Added Nuke
  145. "62cf9b466", -- Fix compile error
  146. "519f98c65", -- Merge pull request #3 from JosiahWI/ui_revamp
  147. "f236476af", -- Fix errors in cheatMenu.
  148. "7af3dee31", -- Merge pull request #2 from JosiahWI/ui_revamp
  149. "ea88dde4b", -- Added Strip, AutoRefill, indexing for InventoryActions and Wield Index starts at 1 now
  150. "7aff09ab2", -- Fix overindent!
  151. "aea9b36ef", -- Improved Colours
  152. "1ef72ad9c", -- Fix indentation style.
  153. "586241008", -- Add missing return.
  154. "b211e90ff", -- Prepare cheatMenu::draw function for easier UI changes.
  155. "e22e334e9", -- Merge pull request #1 from JosiahWI/ui_revamp
  156. "f605308ee", -- Improve drawEntry.
  157. "130d476f6", -- Changed Cheat Menu UI
  158. "f1ff05bf5", -- Added ThroughWalls, InventoryActions API and AutoTotem
  159. "1a7d3d818", -- Extended ClientObjectRef; Improved CrystalPvP
  160. "1e4f35492", -- This is the last try for lint...
  161. "7e0f8fba0", -- Another Lint commit
  162. "151e5782e", -- Lint is still not happy...
  163. "28a560684", -- Added the API additions from waspsaliva
  164. "c1aea404b", -- Lint is bitch
  165. "3a718f12b", -- Make lint happy; Remove stupid redirector
  166. "3b596a96e", -- Fixed Github build problems
  167. "847198edb", -- Edited .gitignore properly; fixed armor invulnarability in the server code.
  168. "bbcd24954", -- New Mod System
  169. "80f416d51", -- Added AttachmentFloat
  170. "cb1915efa", -- Added minetest.drop_selected_item(), Improved AutoEject
  171. "43ee069db", -- Improved X-Ray, added AutoEject
  172. "faa32610e", -- Added ESP, fixed Tracers, improved Jesus
  173. "ee88f4b94", -- Improved Tracers
  174. "c36ff3edb", -- Added AutoSneak and improved X-Ray MapBlock updating
  175. "0a2c90f4c", -- Only draw tracers to objects that are not attached (that fixes tracers to armor)
  176. "044a12666", -- Added Tracers, NoSlow and NoForceRotate; GUI Colors changed
  177. "b9f8f0a23", -- The Robot Update
  178. "af085acbd", -- Added Schematicas
  179. "0730ed216", -- Delete my stupid test mod lol
  180. "772c9629e", -- Unrestricted HTTP API for Client, Server and Main Menu
  181. "9b1030cac", -- Added minetest.get_inventory(location)
  182. "2321e3da4", -- Removed console output spammed by minetest.find_node_near
  183. "90f66dad8", -- Removed experimental code
  184. "8b4d27141", -- Fixed typo in clientmods/inventory/mod.conf
  185. "d8b8c1d31", -- Added Documentation for Additional API
  186. "6e6c68ba0", -- Added Chat Spam, Replace and settingtypes.txt for Clientmods
  187. "79d0314d7", -- Update Buildbots
  188. "770bde9c6", -- idk
  189. "e245151c5", -- Improved World hacks
  190. "19205f6b3", -- Improved World Hacks, added API functions
  191. "73b89703f", -- Improved World hacks, added fill
  192. "248dedaba", -- Added floationg water to BlockWater
  193. "9dc3eb777", -- Fixed broken Chatcommands
  194. "80371bc16", -- Added .listwarps
  195. "1c29f21e0", -- Imporoved set_wield_index() to include camera update
  196. "3bed0981d", -- UI Update; Added AutoTool
  197. "622d54726", -- Added DestroyWater (:P anon)
  198. "9019e18b9", -- Some Updates
  199. "107dec6c0", -- Added Coords
  200. "f1760622e", -- Added BrightNight
  201. "2675bcca1", -- Added more cheats
  202. "3d980cf57", -- Improved Xray and Fullbright
  203. "f7a042223", -- Added cheat Menu
  204. "344fddc17", -- Improved Killaura and Chat position
  205. "678559bb6", -- removed leagcy clientmods
  206. "9194165cf", -- Added autodig, moved chat
  207. "064c25caa", -- Added EntitySpeed
  208. "5a8610c2f", -- Added customizable keybindings, improved freecam, added special inventory keybind (by default ender inventory)
  209. "83f59484d", -- Fixed 5.4.0-dev build
  210. "ffe3c2ae0", -- Update to minetest 5.4.0-dev
  211. "45aa2516b", -- Added settings
  212. "f22339ed8", -- Removed fast killaura
  213. "408e39a1d", -- Added Anti Knockback
  214. "eee0f960b", -- Removed minetest.conf.old
  215. "39d7567c1", -- Fixed Crash
  216. "305e0e0d3", -- Auto disable smooth lighting when fullbright is active
  217. "6796baec6", -- Defaultsettings
  218. "5a2bf6634", -- Added Clientmods
  219. "e610149c0", -- Initial Commit
  220. "68f9263a2", -- Hacked Client
  221. "90d885506", -- GalwayGirl Client
  222. }
  223. --[[
  224. To update commit list: save commit logs for master branches of minetest in mt.log and dragonfire in df.log
  225. $ git log --oneline origin/master > mt.log; git log --oneline dragonfire/master > df.log (both in same remo using git remote)
  226. Find and drop commits that seems to exist in both remotes, print rest of it:
  227. $ sort -k3 <(awk '{print NR" "$0}' df.log mt.log mt.log) | uniq -uf2 | sort -nk1 | sed -r 's/^[^ ]+ ([^ ]+) (.*)$/\t"\1", -- \2/'
  228. Replace above entries with output
  229. --]]
  230. function gapi.isdf(stringversion)
  231. for _,ev in ipairs(gapi.extraversion) do
  232. local pp = stringversion:find(ev)
  233. if pp then
  234. return ev -- loop into table of commmits and find the compared version string if are a devel buil, or just compare the version string
  235. end
  236. end
  237. end
  238. function gapi.is_player(player)
  239. return (type(player) == "userdata" or type(player) == "table") -- check player for real, a player is also a datatable
  240. end
  241. function governing.is_creative(name)
  242. if creative then
  243. return creative.is_creative(name)
  244. else
  245. return minetest.check_player_privs(name, {creative = true}) or creative_mode_cache
  246. end
  247. end
  248. function gapi.format_result_geoip(result)
  249. local txt = " Place: "
  250. if result then
  251. if result.status == "success" and result.data and result.data.geo then
  252. if result.data.geo.ip then
  253. if result.data.geo.ip == "127.0.0.1" then return txt .. " seems localhost " ..".. <_< ." end
  254. end
  255. if result.data.geo.continent_name then
  256. if result.data.geo.continent_name ~= "" then txt = txt .. result.data.geo.continent_name .."," end
  257. end
  258. if result.data.geo.country_name then
  259. if result.data.geo.country_name ~= "" then txt = txt .. result.data.geo.country_name .."," end
  260. end
  261. if result.data.geo.region_name then
  262. if result.data.geo.region_name ~= "" then txt = txt .. result.data.geo.region_name .. "," end
  263. end
  264. if result.data.geo.city then
  265. if result.data.geo.city ~= "" then txt = txt .. result.data.geo.city .."" end
  266. end
  267. if result.data.geo.timezone then
  268. if result.data.geo.timezone ~= "" then txt = txt .. " Timezone: " .. result.data.geo.timezone end
  269. end
  270. if result.data.geo.asn then
  271. if result.data.geo.asn ~= "" then txt = txt .. " ASN: " .. result.data.geo.asn end
  272. end
  273. if result.data.geo.isp then
  274. if result.data.geo.isp ~= "" then txt = txt .. " ISP: " .. result.data.geo.isp end
  275. end
  276. if result.data.geo.ip then
  277. if result.data.geo.ip ~= "" then txt = txt .. " IP: " .. result.data.geo.ip end
  278. end
  279. return txt
  280. else
  281. return false
  282. end
  283. else
  284. return false
  285. end
  286. end
  287. function gapi.format_result_checkip(result)
  288. local txt = " Place: "
  289. local flg = ""
  290. if result then
  291. if result.message then
  292. return result.message .. ".. <_< . if no key, use /geoip command"
  293. end
  294. if result.security then
  295. if result.security.vpn then
  296. if result.security.vpn ~= "true" then flg = flg .. "+VPN" end
  297. end
  298. if result.security.proxy then
  299. if result.security.proxy ~= "true" then flg = flg .. "+PRX" end
  300. end
  301. if result.security.tor then
  302. if result.security.tor ~= "true" then flg = flg .. "+TOR" end
  303. end
  304. if result.security.relay then
  305. if result.security.tor ~= "true" then flg = flg .. "+REL" end
  306. end
  307. end
  308. if result.location then
  309. if result.location then
  310. if result.location.continent ~= "" then txt = txt .. result.location.continent_name .."," end
  311. end
  312. if result.location.country then
  313. if result.location.country ~= "" then txt = txt .. result.location.country .."," end
  314. end
  315. if result.location.region then
  316. if result.location.region ~= "" then txt = txt .. result.location.region .. "," end
  317. end
  318. if result.location.city then
  319. if result.location.city ~= "" then txt = txt .. result.location.city .." " end
  320. end
  321. if result.location.time_zone then
  322. if result.location.time_zone ~= "" then txt = txt .. "Timezone: " .. result.location.time_zone end
  323. end
  324. end
  325. if result.network then
  326. if result.network.autonomous_system_number then
  327. if result.network.autonomous_system_number ~= "" then txt = txt .. " ASN: " .. result.network.autonomous_system_number end
  328. end
  329. if result.network.autonomous_system_organization then
  330. if result.network.autonomous_system_organization ~= "" then txt = txt .. " ISP: " .. result.network.autonomous_system_organization end
  331. end
  332. end
  333. if result.ip then
  334. if result.ip ~= "" then txt = txt .. " IP: " .. result.ip end
  335. end
  336. return flg .. txt
  337. else
  338. return false
  339. end
  340. end
  341. governing.joinplayer_callback = function(playername, result)end