adds client library
This commit is contained in:
parent
6e5244ed45
commit
f240662e40
32
centralLoggingSystem/loggerClient.lua
Normal file
32
centralLoggingSystem/loggerClient.lua
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
local loggerClient = {}
|
||||||
|
|
||||||
|
settings.define("logger.AES.key", {
|
||||||
|
description = "AES key used for encryption",
|
||||||
|
type = "number"
|
||||||
|
})
|
||||||
|
|
||||||
|
settings.define("logger.modemSide", {
|
||||||
|
description = "The side of the modem (for pocket computers this is 'back')",
|
||||||
|
type = "string"
|
||||||
|
})
|
||||||
|
|
||||||
|
settings.define("logger.channel", {
|
||||||
|
description = "The channel used",
|
||||||
|
type = "number"
|
||||||
|
})
|
||||||
|
|
||||||
|
local AES = require("/AES")
|
||||||
|
|
||||||
|
local key = settings.get("logger.AES.key") or error("No AES Key set")
|
||||||
|
local modemSide = settings.get("logger.modemSide") or error("No modem found")
|
||||||
|
local channel = settings.get("logger.channel") or error("No channel set")
|
||||||
|
|
||||||
|
local modem = peripheral.wrap(modemSide)
|
||||||
|
|
||||||
|
function loggerClient.log(sender, message)
|
||||||
|
local message = textutils.serialize({sender = sender, message = message})
|
||||||
|
local encrypted = AES.ECB_256(AES.encrypt, key, message)
|
||||||
|
modem.transmit(channel, channel, encrypted)
|
||||||
|
end
|
||||||
|
|
||||||
|
return loggerClient
|
@ -11,6 +11,18 @@ Logs data sent to it by various computers and prints it on printed pieces of pap
|
|||||||
7. Choose a channel number and set the channel by changing the `channel` variable.
|
7. Choose a channel number and set the channel by changing the `channel` variable.
|
||||||
|
|
||||||
# Client Setup
|
# Client Setup
|
||||||
|
1. download `loggerClient.lua` and put it on your computer.
|
||||||
|
2. attach a modem to the computer and note what side it is on.
|
||||||
|
3. set the settings `logger.AES.key`, `logger.modemSide` and `logger.channel`.
|
||||||
|
4. download the AES dependency and put it in the root directory.
|
||||||
|
5. use `require` to include to use this library.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
```lua
|
||||||
|
local logger = require("/loggerClient")
|
||||||
|
|
||||||
|
logger.log("testLogger", "this is a test log")
|
||||||
|
```
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
- [Lua_AES](https://github.com/idiomic/Lua_AES)
|
- [Lua_AES](https://github.com/idiomic/Lua_AES)
|
||||||
|
Loading…
Reference in New Issue
Block a user