mirror of
https://github.com/kepler155c/opus
synced 2025-01-03 20:30:28 +00:00
protected network services
This commit is contained in:
parent
62a3bc1360
commit
7749e14cad
@ -14,14 +14,7 @@ local function getProxy(path)
|
||||
return proxy
|
||||
end
|
||||
|
||||
Event.addRoutine(function()
|
||||
print('proxy: listening on port 188')
|
||||
while true do
|
||||
local socket = Socket.server(188)
|
||||
|
||||
print('proxy: connection from ' .. socket.dhost)
|
||||
|
||||
Event.addRoutine(function()
|
||||
local function proxyConnection(socket)
|
||||
local path = socket:read(2)
|
||||
if path then
|
||||
local api = getProxy(path)
|
||||
@ -40,7 +33,6 @@ Event.addRoutine(function()
|
||||
end
|
||||
socket:write(methods)
|
||||
|
||||
local s, m = pcall(function()
|
||||
while true do
|
||||
local data = socket:read()
|
||||
if not data then
|
||||
@ -49,12 +41,24 @@ Event.addRoutine(function()
|
||||
end
|
||||
socket:write({ api[data[1]](table.unpack(data, 2)) })
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
Event.addRoutine(function()
|
||||
print('proxy: listening on port 188')
|
||||
while true do
|
||||
local socket = Socket.server(188)
|
||||
|
||||
print('proxy: connection from ' .. socket.dhost)
|
||||
|
||||
Event.addRoutine(function()
|
||||
local s, m = pcall(proxyConnection, socket)
|
||||
print('proxy: closing connection to ' .. socket.dhost)
|
||||
socket:close()
|
||||
if not s and m then
|
||||
print('Proxy error')
|
||||
_G.printError(m)
|
||||
end
|
||||
end
|
||||
socket:close()
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
@ -67,8 +67,13 @@ Event.addRoutine(function()
|
||||
|
||||
Event.addRoutine(function()
|
||||
print('samba: connection from ' .. socket.dhost)
|
||||
sambaConnection(socket)
|
||||
local s, m = pcall(sambaConnection, socket)
|
||||
print('samba: closing connection to ' .. socket.dhost)
|
||||
socket:close()
|
||||
if not s and m then
|
||||
print('Samba error')
|
||||
_G.printError(m)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
@ -106,8 +106,12 @@ Event.addRoutine(function()
|
||||
|
||||
Event.addRoutine(function()
|
||||
print('snmp: connection from ' .. socket.dhost)
|
||||
snmpConnection(socket)
|
||||
local s, m = pcall(snmpConnection, socket)
|
||||
print('snmp: closing connection to ' .. socket.dhost)
|
||||
if not s and m then
|
||||
print('snmp error')
|
||||
_G.printError(m)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
@ -76,7 +76,11 @@ Event.addRoutine(function()
|
||||
print('telnet: connection from ' .. socket.dhost)
|
||||
|
||||
Event.addRoutine(function()
|
||||
telnetHost(socket)
|
||||
local s, m = pcall(telnetHost, socket)
|
||||
if not s and m then
|
||||
print('Telnet error')
|
||||
_G.printError(m)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
@ -4,14 +4,7 @@ local Security = require('security')
|
||||
local Socket = require('socket')
|
||||
local Util = require('util')
|
||||
|
||||
Event.addRoutine(function()
|
||||
|
||||
print('trust: listening on port 19')
|
||||
while true do
|
||||
local socket = Socket.server(19)
|
||||
|
||||
print('trust: connection from ' .. socket.dhost)
|
||||
|
||||
local function trustConnection(socket)
|
||||
local data = socket:read(2)
|
||||
if data then
|
||||
local password = Security.getPassword()
|
||||
@ -30,6 +23,21 @@ Event.addRoutine(function()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.addRoutine(function()
|
||||
|
||||
print('trust: listening on port 19')
|
||||
while true do
|
||||
local socket = Socket.server(19)
|
||||
|
||||
print('trust: connection from ' .. socket.dhost)
|
||||
|
||||
local s, m = pcall(trustConnection, socket)
|
||||
socket:close()
|
||||
if not s and m then
|
||||
print('Trust error')
|
||||
_G.printError(m)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
@ -63,7 +63,11 @@ Event.addRoutine(function()
|
||||
|
||||
-- no new process - only 1 connection allowed
|
||||
-- due to term size issues
|
||||
vncHost(socket)
|
||||
local s, m = pcall(vncHost, socket)
|
||||
socket:close()
|
||||
if not s and m then
|
||||
print('vnc error')
|
||||
_G.printError(m)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user