Readme change and file cleanup
This commit is contained in:
parent
1bd3f586ec
commit
14f186d8e1
184
README.html
Normal file
184
README.html
Normal file
File diff suppressed because one or more lines are too long
@ -30,6 +30,8 @@ A simple and powerful way to make servers and clients
|
|||||||
- [ ] Threading - Simple threading ~~(UDP/AUDP Only)~~ Thanks to an updated multi library we can thread with ease
|
- [ ] Threading - Simple threading ~~(UDP/AUDP Only)~~ Thanks to an updated multi library we can thread with ease
|
||||||
- [ ] Priority handling
|
- [ ] Priority handling
|
||||||
|
|
||||||
|
# Note
|
||||||
|
You will see a bunch of files inside of the net folder. All that is stable is the init.lua and sft.lua file. Everything else is a work in progress. Plus I am planning on rewritting all of the modules to take advantage of the new threading features that are found in the new multi updates. PRogress on this will be made soon. I have just been away from my PC for a while.
|
||||||
# Usage
|
# Usage
|
||||||
server.lua
|
server.lua
|
||||||
```lua
|
```lua
|
||||||
|
|||||||
@ -1,53 +0,0 @@
|
|||||||
require("net.identity")
|
|
||||||
net:registerModule("email",{1,0,0})
|
|
||||||
smtp = require 'socket.smtp'
|
|
||||||
ssl = require 'ssl'
|
|
||||||
|
|
||||||
function net.email.init(from,user,pass)
|
|
||||||
net.OnServerCreated:connect(function(s)
|
|
||||||
s.from=from
|
|
||||||
s.user=user
|
|
||||||
s.pass=pass
|
|
||||||
function s:sendMessage(subject, body, dTable)
|
|
||||||
local msg = {
|
|
||||||
headers = {
|
|
||||||
from = '<'..dTable.email..'>'
|
|
||||||
to = dTable.nick..' <'..dTable.email..'>',
|
|
||||||
subject = subject
|
|
||||||
},
|
|
||||||
body = body
|
|
||||||
}
|
|
||||||
local ok, err = smtp.send {
|
|
||||||
from = '<'..self.from..'>',
|
|
||||||
rcpt = '<'..dTable.email..'>',
|
|
||||||
source = smtp.message(msg),
|
|
||||||
user = self.user,
|
|
||||||
password = self.pass,
|
|
||||||
server = 'smtp.gmail.com',
|
|
||||||
port = 465,
|
|
||||||
create = net.sslCreate
|
|
||||||
}
|
|
||||||
if not ok then
|
|
||||||
print("Mail send failed", err) -- better error handling required
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
function net.sslCreate()
|
|
||||||
local sock = socket.tcp()
|
|
||||||
return setmetatable({
|
|
||||||
connect = function(_, host, port)
|
|
||||||
local r, e = sock:connect(host, port)
|
|
||||||
if not r then return r, e end
|
|
||||||
sock = ssl.wrap(sock, {mode='client', protocol='tlsv1'})
|
|
||||||
return sock:dohandshake()
|
|
||||||
end
|
|
||||||
}, {
|
|
||||||
__index = function(t,n)
|
|
||||||
return function(_, ...)
|
|
||||||
return sock[n](sock, ...)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
net.OnServerCreated:connect(function(s)
|
|
||||||
print("The logging Module has been loaded onto the server!")
|
|
||||||
s.OnDataRecieved:fConnect(function(self,data,cid,ip,port)
|
|
||||||
log(tostring(ip)..":"..tostring(port),"Server-log.log")
|
|
||||||
log(data,"Server-log.log")
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
net:registerModule("p2p",{1,0,0})
|
|
||||||
net.p2p.peerdata={}
|
|
||||||
--[[
|
|
||||||
PID(peerID)=<CID|IP|PORT>
|
|
||||||
|
|
||||||
]]
|
|
||||||
function net.newP2PClient(host,port)
|
|
||||||
--
|
|
||||||
end
|
|
||||||
function net.aft:init() -- calling this initilizes the library and binds it to the servers and clients created
|
|
||||||
--Server Stuff
|
|
||||||
net.OnServerCreated:connect(function(s)
|
|
||||||
print("The aft(Advance File Transfer) Module has been loaded onto the server!")
|
|
||||||
if s.Type~="udp" then
|
|
||||||
print("As of right now p2p is only avaliable using udp!")
|
|
||||||
return "ERR_NOT_UDP"
|
|
||||||
end
|
|
||||||
s.OnDataRecieved(function(self,data,cid,ip,port) -- when the server recieves data this method is triggered
|
|
||||||
--
|
|
||||||
end,"p2p") -- some new stuff
|
|
||||||
end)
|
|
||||||
--Client Stuff
|
|
||||||
net.OnClientCreated:connect(function(c)
|
|
||||||
c.OnDataRecieved(function(self,data) -- when the client recieves data this method is triggered
|
|
||||||
--
|
|
||||||
end,"p2p")
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
if net.autoInit then
|
|
||||||
net.aft.init()
|
|
||||||
end
|
|
||||||
@ -1,48 +0,0 @@
|
|||||||
require("net")
|
|
||||||
--General Stuff
|
|
||||||
--[[ What this module does!
|
|
||||||
Adds
|
|
||||||
net.settings:init()
|
|
||||||
server:regSetting(namespace,setting)
|
|
||||||
]]
|
|
||||||
net:registerModule("settings",{1,0,0})
|
|
||||||
net.settings.config={}
|
|
||||||
function net.settings:init() -- calling this initilizes the library and binds it to the servers and clients created
|
|
||||||
--Server Stuff
|
|
||||||
net.OnServerCreated:connect(function(s)
|
|
||||||
print("The Settings Module has been loaded onto the server!")
|
|
||||||
s.OnDataRecieved(function(self,data,cid,ip,port) -- when the server recieves data this method is triggered
|
|
||||||
local namespace,args=data:match("!settings! (%s+) (.+)")
|
|
||||||
local args
|
|
||||||
if namespace then
|
|
||||||
for i,v in pairs(net.settings.config) do
|
|
||||||
args={data:match(v[1])}
|
|
||||||
if #args~=0 then
|
|
||||||
v[2]:Fire(self,data,cid,ip,port,unpack(args))
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end,"settings")
|
|
||||||
function s:regSetting(namespace,settings)
|
|
||||||
if not net.settings.config[namespace] then
|
|
||||||
net.settings.config[namespace]={}
|
|
||||||
end
|
|
||||||
local connection=multi:newConnection()
|
|
||||||
table.insert(net.settings.config[namespace],{"!settings! "..namespace.." "..settings,connection})
|
|
||||||
return connection
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
--Client Stuff
|
|
||||||
net.OnClientCreated:connect(function(c)
|
|
||||||
c.OnDataRecieved:(function(self,data) -- when the client recieves data this method is triggered
|
|
||||||
--First Lets make sure we are getting Setting data
|
|
||||||
end,"setings")
|
|
||||||
function sendSetting(namespace,args)
|
|
||||||
self:send("!settings! "..namespace.." "..args)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
if net.autoInit then
|
|
||||||
net.settings:init()
|
|
||||||
end
|
|
||||||
@ -1,37 +0,0 @@
|
|||||||
--[=[ About This Module!
|
|
||||||
This module is server side only! (Might add client side if requested)
|
|
||||||
Aim is to make each lane (thread) have no more than 'n' number of connections
|
|
||||||
This module hyjacks the multi:newConnection() function to seemlessly add support for threads without you having to change much
|
|
||||||
As long as each server-client connection is isolated you should be fine
|
|
||||||
The chatting module however IS NOT an isolated module, so take a look at how data was handled in that module to allow for both
|
|
||||||
threaded and non threaded use
|
|
||||||
|
|
||||||
How?
|
|
||||||
When this module is loaded all server creation is altered by passing a proxyServer instead of an actual server object
|
|
||||||
for example:
|
|
||||||
proxy=net:newTCPServer(12345)
|
|
||||||
proxy:OnDataRecieved(function(self,data,cid,ip,port)
|
|
||||||
self:send("My data!")
|
|
||||||
end)
|
|
||||||
the real server instance could be on any of the threads. Careful! While using this is seemless becareful of IO opperations!
|
|
||||||
]=]
|
|
||||||
--~ net:registerModule("threading",{1,0,0})
|
|
||||||
--~ if not(lanes) then error("Require the lanes module!") end
|
|
||||||
--~ local serverlinda = lanes.linda()
|
|
||||||
--~ net.threading.newServer=net.newServer -- store the original method
|
|
||||||
--~ net.threading.newTCPServer=net.newTCPServer -- store the original method
|
|
||||||
--~ net.threading.proxy={} -- namespace for the proxy stuff. Because of the desgin intention of both UDP/TCP servers Only one proxy is needed
|
|
||||||
lanes=require("lanes")
|
|
||||||
serverlinda = lanes.linda()
|
|
||||||
mt={
|
|
||||||
__index=function(t,k) print("IND",t,k) end,
|
|
||||||
__newindex=function(t,k,v) print("NewIND",t,k,v) end,
|
|
||||||
}
|
|
||||||
test={}
|
|
||||||
setmetatable(test,mt)
|
|
||||||
test.a="hi"
|
|
||||||
test.a=true
|
|
||||||
g=test['a']
|
|
||||||
print(test.b)
|
|
||||||
--~ setmetatable(net.threading.proxy,mt) -- set the proxies metatable, to prevent bleeding only create one server.
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user