Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local event = require("event")
- local term = require("term")
- local modem = component.modem
- local RECEIVE_PORT = 13
- local BROADCAST_STATION_PORT = 17
- local RAID_ID = "77e"
- modem.open(RECEIVE_PORT)
- modem.open(BROADCAST_STATION_PORT)
- term.clear()
- print("[SERVER]: Сервер запущен.")
- local function handler()
- local packet = {event.pull("modem_message")}
- if packet[4] == RECEIVE_PORT then
- print("[SERVER]: Получен запрос от клиента. IP: " .. packet[3] .. ".")
- local handle = io.open("/mnt/" .. RAID_ID .. "/connection.log", "a")
- handle:write("[TA]: " .. packet[6] .. " | [TP]: " .. packet[7] .. " | [SA]: " .. packet[3] .. " | [SP]: " .. packet[8] .. " | [DATA]: " .. packet[9] .. "\n")
- handle:flush()
- handle:close()
- modem.send(packet[6], packet[7], packet[3], packet[8], packet[9])
- modem.broadcast(BROADCAST_STATION_PORT, packet[6], packet[7], packet[3], packet[8], packet[9])
- end
- if packet[4] == BROADCAST_STATION_PORT then
- modem.send(packet[6], packet[7], packet[8], packet[9], packet[10])
- end
- end
- while true do
- pcall(handler)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement