Compare commits
3 Commits
4ef792a06d
...
0d01b03ddc
Author | SHA1 | Date | |
---|---|---|---|
0d01b03ddc | |||
cf0cf32642 | |||
c7213d4cbe |
@ -126,7 +126,7 @@ function fs.mounts() -- returns a table containing the mount points of all mount
|
||||
return rt
|
||||
end
|
||||
|
||||
function fs.address(path) -- returns the address of the filesystem at a given path, if applicable
|
||||
function fs.address(path) -- returns the address of the filesystem at a given path, if applicable; do not expect a sensical response
|
||||
local fsi,_ = fs.resolve(path)
|
||||
return fsmounts[fsi].address
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
do
|
||||
local tTasks,nPid,nTimeout,cPid = {},1,1,0 -- table of tasks, next process ID, event timeout, current PID
|
||||
local tTasks,nPid,nTimeout,cPid = {},1,0.25,0 -- table of tasks, next process ID, event timeout, current PID
|
||||
function os.spawn(f,n) -- creates a process from function *f* with name *n*
|
||||
tTasks[nPid] = {
|
||||
c=coroutine.create(f), -- actual coroutine
|
||||
|
@ -10,7 +10,6 @@ cfg.peers = {}
|
||||
cfg.rtimer = 5
|
||||
cfg.katimer = 30
|
||||
local listeners = {}
|
||||
local timers = {}
|
||||
local proxies = {}
|
||||
|
||||
local function loadcfg()
|
||||
@ -84,7 +83,7 @@ local function createTunnel(host,port,addr,raddr)
|
||||
end
|
||||
proxy.connect()
|
||||
proxy.last = computer.uptime()
|
||||
return proxy, read
|
||||
return proxy
|
||||
end
|
||||
|
||||
vt = {}
|
||||
@ -94,9 +93,8 @@ function start()
|
||||
print(string.format("Connecting to %s:%d",v.host,v.port))
|
||||
v.addr = v.addr or vcomponent.uuid()
|
||||
v.raddr = v.raddr or vcomponent.uuid()
|
||||
local px,tr = createTunnel(v.host, v.port, v.addr, v.raddr)
|
||||
local px = createTunnel(v.host, v.port, v.addr, v.raddr)
|
||||
vcomponent.register(v.addr, "tunnel", px)
|
||||
timers[v.addr] = tr
|
||||
proxies[v.addr] = px
|
||||
end
|
||||
for k,v in pairs(os.tasks()) do
|
||||
@ -106,12 +104,6 @@ function start()
|
||||
end
|
||||
end
|
||||
function vt.stop()
|
||||
for k,v in pairs(listeners) do
|
||||
event.ignore(v[1],v[2])
|
||||
end
|
||||
for k,v in pairs(timers) do
|
||||
event.cancel(v)
|
||||
end
|
||||
for k,v in pairs(proxies) do
|
||||
vcomponent.unregister(k)
|
||||
end
|
||||
@ -157,21 +149,14 @@ end
|
||||
vt.start = start
|
||||
_G.libs.vtunnel = vt
|
||||
|
||||
print(pcall(start))
|
||||
start()
|
||||
local last = computer.uptime()
|
||||
while true do
|
||||
local tE = {coroutine.yield()}
|
||||
if computer.uptime() > last + cfg.rtimer then
|
||||
for k,v in pairs(timers) do
|
||||
print(pcall(v))
|
||||
for k,v in pairs(proxies) do
|
||||
v.read()
|
||||
end
|
||||
last = computer.uptime()
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
_G.vtunnel = {}
|
||||
|
||||
_G.vtunnel.start = start
|
||||
_G.vtunnel.delpeer = delpeer
|
||||
]]
|
||||
|
Loading…
Reference in New Issue
Block a user