Compare commits

..

No commits in common. "ff5ff867945f663cc1d7823c4b62a393227789fb" and "7853e6174e656058079a56b1b324d3fdec12326c" have entirely different histories.

6 changed files with 17 additions and 63 deletions

View File

@ -1 +0,0 @@
.vscode

View File

@ -57,11 +57,15 @@ Packet format is uniform between master <-> slaves and is structured like so:
### Slave Node Initialization
* The slave starts up
* The slave receives a `ping` packet from a master server. The slave compares it to any stored `/pairednetwork` file in the root of the filesystem:
* If the file exists and the ID does not match, processing is halted
* The `networkid` of the packet is stored as `/pairednetwork`
* The slave responds with a `pong` packet.
### Master Node Initialization
* The master node starts up
* The master node sends a packet with type `ping`.
* The master node sends a packet with type `ping` and `networkid` initialized to its CC ID.
* The master node listens for `pong` packets for a configurable timeout.
* The `sourceid` of all `pong` packets is recorded for statistics displays. This cached data is only used for user display. Node availability is evaluated at request time.

View File

@ -1,49 +0,0 @@
-- Salt's ComputerCraft Storage Network Script
--
-- For information on this script, physical in-world setup, and configuration,
-- see: https://git.desu.ltd/salt/mc-scripts/src/branch/master/storage-net
-- Default configuration values. Override in config.lua. DO NOT CHANGE HERE
mode = "undefined" -- The mode of function for this node
networkid = 0 -- Unique ID for this network
port_broadcast = 42914 -- Port for M->S traffic
port_return = 42915 -- Port for S->M traffic
-- This loads config.lua. See masterconfig.lua and slaveconfig.lua for example
-- configurations.
require "config"
-- Startup diagnostics
print("Salt's CC Storage Net")
print("Computer ID: " .. os.getComputerID())
print("Computer " .. os.getComputerID() .. " running as " .. mode)
-- Common functions
function c_mainLoop(loopfunc)
-- Loops a thing forever
while true do
loopfunc()
sleep(1)
end
end
-- Master functions
function m_loop()
-- The main loop of the master server
end
-- Slave functions
function s_loop()
-- The main loop of any slave nodes
end
-- Application entrypoint
function main ()
if (mode == "master") then
c_mainLoop(m_loop)
elseif (mode == "slave") then
c_mainLoop(s_loop)
else
error("Invalid mode: " .. mode .. ", please configure this node appropriately")
end
end
main()

View File

@ -10,17 +10,19 @@ mcroot="$HOME/.var/app/org.prismlauncher.PrismLauncher/data/PrismLauncher/instan
world="New World"
masterid="0"
slaves=("1" "8" "9")
slaveid="1"
_ccroot="$mcroot/.minecraft/saves/$world/computercraft/computer"
echo "Root: $_ccroot"
for computer in "$masterid" ${slaves[*]}; do
echo "Deploying to: $computer"
mkdir -p "$_ccroot/$computer"
cp common.lua "$_ccroot/$computer/autostart.lua"
done
cp masterconfig.lua "$_ccroot/$masterid/config.lua"
for slave in ${slaves[*]}; do
echo "Deploying slave config: $slave"
cp slaveconfig.lua "$_ccroot/$slave/config.lua"
for computer in $masterid $slaveid; do
:
done
if [ -f master.lua ]; then
echo "Deploying master to $masterid"
cp master.lua "$_ccroot/$masterid/autostart.lua"
fi
if [ -f slave.lua ]; then
echo "Deploying slave to $slaveid"
cp slave.lua "$_ccroot/$slaveid/autostart.lua"
fi

View File

@ -1 +0,0 @@
mode = "master"

View File

@ -1 +0,0 @@
mode = "slave"