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
|
http://127.0.0.1:8000
|
||||||
```
|
```
|
||||||
If you want to access lovebird from another computer on the same network then
|
If you want to access lovebird from another computer then `127.0.0.1` should be
|
||||||
`127.0.0.1` should be replaced with the IP address of the computer which LÖVE
|
replaced with the IP address of the computer which LÖVE is running on; the IP
|
||||||
is running on.
|
address of the other computer should be added to the
|
||||||
|
[lovebird.whitelist](#lovebirdwhitelist) table.
|
||||||
|
|
||||||
|
|
||||||
## Additional Functionality
|
## 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
|
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
|
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
|
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
|
### lovebird.wrapprint
|
||||||
Whether lovebird should wrap the `print()` function or not. If this is true
|
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()
|
### lovebird.clear()
|
||||||
Clears the contents of the console, returning it to an empty state.
|
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.allowhtml = false
|
||||||
lovebird.echoinput = true
|
lovebird.echoinput = true
|
||||||
lovebird.port = 8000
|
lovebird.port = 8000
|
||||||
lovebird.whitelist = { "127.0.0.1", "192.168.*.*" }
|
lovebird.whitelist = { "127.0.0.1" }
|
||||||
lovebird.maxlines = 200
|
lovebird.maxlines = 200
|
||||||
lovebird.updateinterval = .5
|
lovebird.updateinterval = .5
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ end
|
|||||||
<meta http-equiv="x-ua-compatible" content="IE=Edge"/>
|
<meta http-equiv="x-ua-compatible" content="IE=Edge"/>
|
||||||
<title>lovebird</title>
|
<title>lovebird</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-family: helvetica, verdana, sans;
|
font-family: helvetica, verdana, sans;
|
||||||
@ -197,7 +197,7 @@ end
|
|||||||
<div id="console" class="greybordered">
|
<div id="console" class="greybordered">
|
||||||
<div id="output"> <?lua echo(lovebird.buffer) ?> </div>
|
<div id="output"> <?lua echo(lovebird.buffer) ?> </div>
|
||||||
<div id="input">
|
<div id="input">
|
||||||
<form method="post"
|
<form method="post"
|
||||||
onkeydown="return onInputKeyDown(event);"
|
onkeydown="return onInputKeyDown(event);"
|
||||||
onsubmit="onInputSubmit(); return false;">
|
onsubmit="onInputSubmit(); return false;">
|
||||||
<input id="inputbox" name="input" type="text"></input>
|
<input id="inputbox" name="input" type="text"></input>
|
||||||
@ -292,11 +292,11 @@ end
|
|||||||
geturl("/buffer", function(text) {
|
geturl("/buffer", function(text) {
|
||||||
updateDivContent("status", "connected ●");
|
updateDivContent("status", "connected ●");
|
||||||
if (updateDivContent("output", text)) {
|
if (updateDivContent("output", text)) {
|
||||||
var div = document.getElementById("output");
|
var div = document.getElementById("output");
|
||||||
div.scrollTop = div.scrollHeight;
|
div.scrollTop = div.scrollHeight;
|
||||||
}
|
}
|
||||||
/* Update favicon */
|
/* Update favicon */
|
||||||
changeFavicon("data:image/png;base64," +
|
changeFavicon("data:image/png;base64," +
|
||||||
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAP1BMVEUAAAAAAAAAAAD////19fUO"+
|
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAP1BMVEUAAAAAAAAAAAD////19fUO"+
|
||||||
"Dg7v7+/h4eGzs7MlJSUeHh7n5+fY2NjJycnGxsa3t7eioqKfn5+QkJCHh4d+fn7zU+b5AAAAAnRS"+
|
"Dg7v7+/h4eGzs7MlJSUeHh7n5+fY2NjJycnGxsa3t7eioqKfn5+QkJCHh4d+fn7zU+b5AAAAAnRS"+
|
||||||
"TlPlAFWaypEAAABRSURBVBjTfc9HDoAwDERRQ+w0ern/WQkZaUBC4e/mrWzppH9VJjbjZg1Ii2rM"+
|
"TlPlAFWaypEAAABRSURBVBjTfc9HDoAwDERRQ+w0ern/WQkZaUBC4e/mrWzppH9VJjbjZg1Ii2rM"+
|
||||||
@ -306,7 +306,7 @@ end
|
|||||||
function(text) {
|
function(text) {
|
||||||
updateDivContent("status", "disconnected ○");
|
updateDivContent("status", "disconnected ○");
|
||||||
/* Update favicon */
|
/* Update favicon */
|
||||||
changeFavicon("data:image/png;base64," +
|
changeFavicon("data:image/png;base64," +
|
||||||
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAYFBMVEUAAAAAAAAAAADZ2dm4uLgM"+
|
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAYFBMVEUAAAAAAAAAAADZ2dm4uLgM"+
|
||||||
"DAz29vbz8/Pv7+/h4eHIyMiwsLBtbW0lJSUeHh4QEBDn5+fS0tLDw8O0tLSioqKfn5+QkJCHh4d+"+
|
"DAz29vbz8/Pv7+/h4eHIyMiwsLBtbW0lJSUeHh4QEBDn5+fS0tLDw8O0tLSioqKfn5+QkJCHh4d+"+
|
||||||
"fn5ycnJmZmZgYGBXV1dLS0tFRUUGBgZ0He44AAAAAnRSTlPlAFWaypEAAABeSURBVBjTfY9HDoAw"+
|
"fn5ycnJmZmZgYGBXV1dLS0tFRUUGBgZ0He44AAAAAnRSTlPlAFWaypEAAABeSURBVBjTfY9HDoAw"+
|
||||||
@ -321,7 +321,7 @@ end
|
|||||||
/* Environment variable view */
|
/* Environment variable view */
|
||||||
var envPath = "";
|
var envPath = "";
|
||||||
var refreshEnv = function() {
|
var refreshEnv = function() {
|
||||||
geturl("/env.json?p=" + envPath, function(text) {
|
geturl("/env.json?p=" + envPath, function(text) {
|
||||||
var json = eval("(" + text + ")");
|
var json = eval("(" + text + ")");
|
||||||
|
|
||||||
/* Header */
|
/* Header */
|
||||||
@ -360,7 +360,7 @@ end
|
|||||||
updateDivContent("envvars", html);
|
updateDivContent("envvars", html);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var setEnvPath = function(p) {
|
var setEnvPath = function(p) {
|
||||||
envPath = p;
|
envPath = p;
|
||||||
refreshEnv();
|
refreshEnv();
|
||||||
}
|
}
|
||||||
@ -380,7 +380,7 @@ lovebird.pages["buffer"] = [[ <?lua echo(lovebird.buffer) ?> ]]
|
|||||||
|
|
||||||
|
|
||||||
lovebird.pages["env.json"] = [[
|
lovebird.pages["env.json"] = [[
|
||||||
<?lua
|
<?lua
|
||||||
local t = _G
|
local t = _G
|
||||||
local p = req.parsedurl.query.p or ""
|
local p = req.parsedurl.query.p or ""
|
||||||
p = p:gsub("%.+", "."):match("^[%.]*(.*)[%.]*$")
|
p = p:gsub("%.+", "."):match("^[%.]*(.*)[%.]*$")
|
||||||
@ -399,20 +399,20 @@ lovebird.pages["env.json"] = [[
|
|||||||
"valid": true,
|
"valid": true,
|
||||||
"path": "<?lua echo(p) ?>",
|
"path": "<?lua echo(p) ?>",
|
||||||
"vars": [
|
"vars": [
|
||||||
<?lua
|
<?lua
|
||||||
local keys = {}
|
local keys = {}
|
||||||
for k in pairs(t) do
|
for k in pairs(t) do
|
||||||
if type(k) == "number" or type(k) == "string" then
|
if type(k) == "number" or type(k) == "string" then
|
||||||
table.insert(keys, k)
|
table.insert(keys, k)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.sort(keys, lovebird.compare)
|
table.sort(keys, lovebird.compare)
|
||||||
for _, k in pairs(keys) do
|
for _, k in pairs(keys) do
|
||||||
local v = t[k]
|
local v = t[k]
|
||||||
?>
|
?>
|
||||||
{
|
{
|
||||||
"key": "<?lua echo(k) ?>",
|
"key": "<?lua echo(k) ?>",
|
||||||
"value": <?lua echo(
|
"value": <?lua echo(
|
||||||
string.format("%q",
|
string.format("%q",
|
||||||
lovebird.truncate(
|
lovebird.truncate(
|
||||||
lovebird.htmlescape(
|
lovebird.htmlescape(
|
||||||
@ -442,7 +442,7 @@ function lovebird.init()
|
|||||||
end
|
end
|
||||||
-- Compile page templates
|
-- Compile page templates
|
||||||
for k, page in pairs(lovebird.pages) do
|
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)
|
"pages." .. k)
|
||||||
end
|
end
|
||||||
lovebird.inited = true
|
lovebird.inited = true
|
||||||
@ -564,7 +564,7 @@ function lovebird.recalcbuffer()
|
|||||||
str = '<span class="repeatcount">' .. line.count .. '</span> ' .. str
|
str = '<span class="repeatcount">' .. line.count .. '</span> ' .. str
|
||||||
end
|
end
|
||||||
if lovebird.timestamp then
|
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
|
str
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -605,7 +605,7 @@ function lovebird.onrequest(req, client)
|
|||||||
local page = req.parsedurl.path
|
local page = req.parsedurl.path
|
||||||
page = page ~= "" and page or "index"
|
page = page ~= "" and page or "index"
|
||||||
-- Handle "page not found"
|
-- 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"
|
return "HTTP/1.1 404\r\nContent-Length: 8\r\n\r\nBad page"
|
||||||
end
|
end
|
||||||
-- Handle page
|
-- Handle page
|
||||||
@ -689,7 +689,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function lovebird.update()
|
function lovebird.update()
|
||||||
if not lovebird.inited then lovebird.init() end
|
if not lovebird.inited then lovebird.init() end
|
||||||
-- Handle new connections
|
-- Handle new connections
|
||||||
while 1 do
|
while 1 do
|
||||||
-- Accept new connections
|
-- Accept new connections
|
||||||
@ -697,7 +697,7 @@ function lovebird.update()
|
|||||||
if not client then break end
|
if not client then break end
|
||||||
client:settimeout(0)
|
client:settimeout(0)
|
||||||
local addr = client:getsockname()
|
local addr = client:getsockname()
|
||||||
if lovebird.checkwhitelist(addr) then
|
if lovebird.checkwhitelist(addr) then
|
||||||
-- Connection okay -- create and add coroutine to set
|
-- Connection okay -- create and add coroutine to set
|
||||||
local conn = coroutine.wrap(function()
|
local conn = coroutine.wrap(function()
|
||||||
xpcall(function() lovebird.onconnect(client) end, function() end)
|
xpcall(function() lovebird.onconnect(client) end, function() end)
|
||||||
|
Loading…
Reference in New Issue
Block a user