mirror of
https://github.com/rxi/lovebird.git
synced 2024-11-15 22:54:21 +00:00
Removed "192.168.*.*" from whitelist, updated README
This commit is contained in:
parent
0ce551bacd
commit
78afff0835
11
README.md
11
README.md
@ -14,9 +14,10 @@ The console can then be accessed by opening the following URL in a web browser:
|
||||
```
|
||||
http://127.0.0.1:8000
|
||||
```
|
||||
If you want to access lovebird from another computer on the same network then
|
||||
`127.0.0.1` should be replaced with the IP address of the computer which LÖVE
|
||||
is running on.
|
||||
If you want to access lovebird from another computer then `127.0.0.1` should be
|
||||
replaced with the IP address of the computer which LÖVE is running on; the IP
|
||||
address of the other computer should be added to the
|
||||
[lovebird.whitelist](#lovebirdwhitelist) table.
|
||||
|
||||
|
||||
## Additional Functionality
|
||||
@ -34,7 +35,8 @@ The port which lovebird listens for connections on. By default this is `8000`
|
||||
A table of hosts which lovebird will accept connections from. Any connection
|
||||
made from a host which is not on the whitelist is logged and closed
|
||||
immediately. If `lovebird.whitelist` is set to nil then all connections are
|
||||
accepted. The default is `{ "127.0.0.1", "192.168.*.*" }`.
|
||||
accepted. The default is `{ "127.0.0.1" }`. To allow *all* computers on the
|
||||
local network access to lovebird, `"192.168.*.*"` can be added to this table.
|
||||
|
||||
### lovebird.wrapprint
|
||||
Whether lovebird should wrap the `print()` function or not. If this is true
|
||||
@ -64,4 +66,3 @@ true this function is automatically called when print() is called.
|
||||
|
||||
### lovebird.clear()
|
||||
Clears the contents of the console, returning it to an empty state.
|
||||
|
||||
|
38
lovebird.lua
38
lovebird.lua
@ -24,7 +24,7 @@ lovebird.timestamp = true
|
||||
lovebird.allowhtml = false
|
||||
lovebird.echoinput = true
|
||||
lovebird.port = 8000
|
||||
lovebird.whitelist = { "127.0.0.1", "192.168.*.*" }
|
||||
lovebird.whitelist = { "127.0.0.1" }
|
||||
lovebird.maxlines = 200
|
||||
lovebird.updateinterval = .5
|
||||
|
||||
@ -51,7 +51,7 @@ end
|
||||
<meta http-equiv="x-ua-compatible" content="IE=Edge"/>
|
||||
<title>lovebird</title>
|
||||
<style>
|
||||
body {
|
||||
body {
|
||||
margin: 0px;
|
||||
font-size: 14px;
|
||||
font-family: helvetica, verdana, sans;
|
||||
@ -197,7 +197,7 @@ end
|
||||
<div id="console" class="greybordered">
|
||||
<div id="output"> <?lua echo(lovebird.buffer) ?> </div>
|
||||
<div id="input">
|
||||
<form method="post"
|
||||
<form method="post"
|
||||
onkeydown="return onInputKeyDown(event);"
|
||||
onsubmit="onInputSubmit(); return false;">
|
||||
<input id="inputbox" name="input" type="text"></input>
|
||||
@ -292,11 +292,11 @@ end
|
||||
geturl("/buffer", function(text) {
|
||||
updateDivContent("status", "connected ●");
|
||||
if (updateDivContent("output", text)) {
|
||||
var div = document.getElementById("output");
|
||||
var div = document.getElementById("output");
|
||||
div.scrollTop = div.scrollHeight;
|
||||
}
|
||||
/* Update favicon */
|
||||
changeFavicon("data:image/png;base64," +
|
||||
changeFavicon("data:image/png;base64," +
|
||||
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAP1BMVEUAAAAAAAAAAAD////19fUO"+
|
||||
"Dg7v7+/h4eGzs7MlJSUeHh7n5+fY2NjJycnGxsa3t7eioqKfn5+QkJCHh4d+fn7zU+b5AAAAAnRS"+
|
||||
"TlPlAFWaypEAAABRSURBVBjTfc9HDoAwDERRQ+w0ern/WQkZaUBC4e/mrWzppH9VJjbjZg1Ii2rM"+
|
||||
@ -306,7 +306,7 @@ end
|
||||
function(text) {
|
||||
updateDivContent("status", "disconnected ○");
|
||||
/* Update favicon */
|
||||
changeFavicon("data:image/png;base64," +
|
||||
changeFavicon("data:image/png;base64," +
|
||||
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAYFBMVEUAAAAAAAAAAADZ2dm4uLgM"+
|
||||
"DAz29vbz8/Pv7+/h4eHIyMiwsLBtbW0lJSUeHh4QEBDn5+fS0tLDw8O0tLSioqKfn5+QkJCHh4d+"+
|
||||
"fn5ycnJmZmZgYGBXV1dLS0tFRUUGBgZ0He44AAAAAnRSTlPlAFWaypEAAABeSURBVBjTfY9HDoAw"+
|
||||
@ -321,7 +321,7 @@ end
|
||||
/* Environment variable view */
|
||||
var envPath = "";
|
||||
var refreshEnv = function() {
|
||||
geturl("/env.json?p=" + envPath, function(text) {
|
||||
geturl("/env.json?p=" + envPath, function(text) {
|
||||
var json = eval("(" + text + ")");
|
||||
|
||||
/* Header */
|
||||
@ -360,7 +360,7 @@ end
|
||||
updateDivContent("envvars", html);
|
||||
});
|
||||
}
|
||||
var setEnvPath = function(p) {
|
||||
var setEnvPath = function(p) {
|
||||
envPath = p;
|
||||
refreshEnv();
|
||||
}
|
||||
@ -380,7 +380,7 @@ lovebird.pages["buffer"] = [[ <?lua echo(lovebird.buffer) ?> ]]
|
||||
|
||||
|
||||
lovebird.pages["env.json"] = [[
|
||||
<?lua
|
||||
<?lua
|
||||
local t = _G
|
||||
local p = req.parsedurl.query.p or ""
|
||||
p = p:gsub("%.+", "."):match("^[%.]*(.*)[%.]*$")
|
||||
@ -399,20 +399,20 @@ lovebird.pages["env.json"] = [[
|
||||
"valid": true,
|
||||
"path": "<?lua echo(p) ?>",
|
||||
"vars": [
|
||||
<?lua
|
||||
<?lua
|
||||
local keys = {}
|
||||
for k in pairs(t) do
|
||||
for k in pairs(t) do
|
||||
if type(k) == "number" or type(k) == "string" then
|
||||
table.insert(keys, k)
|
||||
end
|
||||
end
|
||||
table.sort(keys, lovebird.compare)
|
||||
for _, k in pairs(keys) do
|
||||
for _, k in pairs(keys) do
|
||||
local v = t[k]
|
||||
?>
|
||||
{
|
||||
{
|
||||
"key": "<?lua echo(k) ?>",
|
||||
"value": <?lua echo(
|
||||
"value": <?lua echo(
|
||||
string.format("%q",
|
||||
lovebird.truncate(
|
||||
lovebird.htmlescape(
|
||||
@ -442,7 +442,7 @@ function lovebird.init()
|
||||
end
|
||||
-- Compile page templates
|
||||
for k, page in pairs(lovebird.pages) do
|
||||
lovebird.pages[k] = lovebird.template(page, "lovebird, req",
|
||||
lovebird.pages[k] = lovebird.template(page, "lovebird, req",
|
||||
"pages." .. k)
|
||||
end
|
||||
lovebird.inited = true
|
||||
@ -564,7 +564,7 @@ function lovebird.recalcbuffer()
|
||||
str = '<span class="repeatcount">' .. line.count .. '</span> ' .. str
|
||||
end
|
||||
if lovebird.timestamp then
|
||||
str = os.date('<span class="timestamp">%H:%M:%S</span> ', line.time) ..
|
||||
str = os.date('<span class="timestamp">%H:%M:%S</span> ', line.time) ..
|
||||
str
|
||||
end
|
||||
end
|
||||
@ -605,7 +605,7 @@ function lovebird.onrequest(req, client)
|
||||
local page = req.parsedurl.path
|
||||
page = page ~= "" and page or "index"
|
||||
-- Handle "page not found"
|
||||
if not lovebird.pages[page] then
|
||||
if not lovebird.pages[page] then
|
||||
return "HTTP/1.1 404\r\nContent-Length: 8\r\n\r\nBad page"
|
||||
end
|
||||
-- Handle page
|
||||
@ -689,7 +689,7 @@ end
|
||||
|
||||
|
||||
function lovebird.update()
|
||||
if not lovebird.inited then lovebird.init() end
|
||||
if not lovebird.inited then lovebird.init() end
|
||||
-- Handle new connections
|
||||
while 1 do
|
||||
-- Accept new connections
|
||||
@ -697,7 +697,7 @@ function lovebird.update()
|
||||
if not client then break end
|
||||
client:settimeout(0)
|
||||
local addr = client:getsockname()
|
||||
if lovebird.checkwhitelist(addr) then
|
||||
if lovebird.checkwhitelist(addr) then
|
||||
-- Connection okay -- create and add coroutine to set
|
||||
local conn = coroutine.wrap(function()
|
||||
xpcall(function() lovebird.onconnect(client) end, function() end)
|
||||
|
Loading…
Reference in New Issue
Block a user