1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# lullaby
> a large multi-purpose library for lua (primarily 5.4) revolving around threading and cryptography, and including network, math, io, and table functions
heres an example of a webserver to return a [sha0](https://en.wikipedia.org/wiki/SHA-0) hash of an input
<blockquote>
```lua
llib = require "lullaby"
local port = 8080
MAX_LENGTH = 2048
llib.net.listen(function(server)
--listen to post requests at localhost:8080 (root directory)
server:POST("/", function(res, req)
--creates a sha0 hash object
local hash = llib.crypto.sha0()
--loads an extra 2048 characters from the request body (the body is not guaranteed to be >= 2048 characters, reasoning in docs)
req:roll(MAX_LENGTH)
--incremental hashes allow updating via addition, in this case adding the body and getting a string from it
hash = (hash + req.Body):final()
--send the hash to the client, closes connection, but thread is live until it ends
res:send(hash)
end)
end, port)
```
</blockquote>
## building
build with `make`, output is `./lullaby.so` or (win)`./lullaby.dll`
windows works through msys2
---
[some docs](docs/)
## todo:
* (working on seperatley) gui for graphs
* finish up http server
* https
* ~~check memory saftey~~ (*should* be good) (now work on indirect & more lifetime stuff)
* memory optimizations (its getting there)
* settings (parse/read files, etc..)
* define usage of new routes inside of routes, and allow route removal
* connection limit
* allow choosing what to copy over to the thread, or not to copy the global state at all
* allow stopping the server
* more doxygen like docs, everywhere
* thread-safe wrapper object
* threads
* encode tests (and fix sprintf ub)
----
# credits
* [luaproc](https://github.com/askyrme/luaproc) helped with multithreading
|