diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2019-10-29 13:18:16 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2019-10-29 13:18:16 +0000 |
| commit | d9eafa21ad1d6ad340b5744d69e9fc68ce2083cb (patch) | |
| tree | c5e4c1ce74094b5feebbca944e316fb2833fe027 /build | |
| parent | small styling fixes (diff) | |
| download | mmm-d9eafa21ad1d6ad340b5744d69e9fc68ce2083cb.tar.gz mmm-d9eafa21ad1d6ad340b5744d69e9fc68ce2083cb.zip | |
add sandbox
Diffstat (limited to 'build')
| -rw-r--r-- | build/server.moon | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/build/server.moon b/build/server.moon index 68cf4db..d101d0b 100644 --- a/build/server.moon +++ b/build/server.moon @@ -29,6 +29,8 @@ class Server opts.onstream = @\stream opts.onerror = @\error + @editable_paths = opts.editable_paths + @server = server.listen opts listen: => @@ -81,6 +83,10 @@ class Server -- fileder not found 404, "fileder '#{path}' not found" + if method != 'GET' and method != 'HEAD' + if not @editable_paths or not path\match @editable_paths + return 403, 'editing not allowed' + switch method when 'GET', 'HEAD' val = switch facet.name @@ -153,9 +159,13 @@ class Server msg = "#{msg}: #{err}" if err -- usage: --- moon server.moon [STORE] [host] [port] -{ store, host, port } = arg +-- moon server.moon [STORE] [host] [port] [editable-paths] +-- * STORE: see mmm/mmmfs/stores/init.moon:get_store +-- * host: interface to bind to (default localhost, set to 0.0.0.0 for public hosting) +-- * port: port to serve from, default 8000 +-- * editable-paths: Lua pattern to match paths in which editing is allowed, default none +{ store, host, port, editable_paths } = arg store = get_store store -server = Server store, :host, port: port and tonumber port +server = Server store, :host, :editable_paths, port: port and tonumber port server\listen! |
