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