1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-11-23 10:38:05 +11:00

bridge improvements, mostly configuration

This commit is contained in:
Izaya 2018-04-06 16:51:45 +10:00
parent 57345b6598
commit f254ededac
3 changed files with 11 additions and 6 deletions

View File

@ -21,13 +21,15 @@ The protocol is documented [here](vtunnel-protocol.md)
At present, all you need to do is run bridge.lua, for example:
```
lua53 bridge.lua
lua53 bridge.lua [port] [timeout]
```
### Client
#### OPPM
Not yet functional, but when it is:
```
oppm install vtunnel
```

View File

@ -1,6 +1,10 @@
local socket = require "socket"
local imt = require "interminitel"
local tArgs = {...}
local port, timeout = tonumber(tArgs[1]) or 4096, tonumber(tArgs[2]) or 60
local clients, coroutines, messages = {}, {}, {}
local function spawn(f)
@ -28,8 +32,6 @@ function reprint(...)
end
end
reprint(imt.encodePacket("Hello, world!",123))
local function hasValidPacket(s)
local w, res = pcall(imt.decodePacket,s)
if res then return true end
@ -37,8 +39,9 @@ end
hasValidPacket("")
function socketLoop()
local server = socket.bind("*", 4096)
local server = socket.bind("*", port)
server:settimeout(0)
print("vTunnel bridge server listening on port "..tostring(port))
while true do
local client,err = server:accept()
if client then
@ -66,7 +69,7 @@ function clientLoop()
client.conn:close()
clients[id] = nil
end
if client.last+3000 < os.time() then
if client.last+timeout < os.time() then
print("Dropping client "..tostring(id).." for inactivity")
client.conn:close()
clients[id] = nil

View File

@ -54,4 +54,4 @@ By default, the bridge server:
- uses port 4096, as Minitel does on OpenComputers networks
- drops clients after 60 seconds of inactivity
This can be configured by **FIXME.**
This can be configured by appending a port number and timeout (in seconds) to the command you use to launch the bridge.