Skip to content

Commit

Permalink
Removed "192.168.*.*" from whitelist, updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
rxi committed Jul 24, 2016
1 parent 0ce551b commit 78afff0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
11 changes: 6 additions & 5 deletions README.md
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 changes: 19 additions & 19 deletions lovebird.lua
Expand Up @@ -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

Expand All @@ -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;
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -292,11 +292,11 @@ end
geturl("/buffer", function(text) {
updateDivContent("status", "connected &#9679;");
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"+
Expand All @@ -306,7 +306,7 @@ end
function(text) {
updateDivContent("status", "disconnected &#9675;");
/* Update favicon */
changeFavicon("data:image/png;base64," +
changeFavicon("data:image/png;base64," +
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAYFBMVEUAAAAAAAAAAADZ2dm4uLgM"+
"DAz29vbz8/Pv7+/h4eHIyMiwsLBtbW0lJSUeHh4QEBDn5+fS0tLDw8O0tLSioqKfn5+QkJCHh4d+"+
"fn5ycnJmZmZgYGBXV1dLS0tFRUUGBgZ0He44AAAAAnRSTlPlAFWaypEAAABeSURBVBjTfY9HDoAw"+
Expand All @@ -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 */
Expand Down Expand Up @@ -360,7 +360,7 @@ end
updateDivContent("envvars", html);
});
}
var setEnvPath = function(p) {
var setEnvPath = function(p) {
envPath = p;
refreshEnv();
}
Expand All @@ -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("^[%.]*(.*)[%.]*$")
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -689,15 +689,15 @@ 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
local client = lovebird.server:accept()
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)
Expand Down

0 comments on commit 78afff0

Please sign in to comment.