Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
6fb0b80
Update webapp.js
ethanaobrien Apr 13, 2021
4b8a350
Update manifest.json
ethanaobrien Apr 13, 2021
69c1330
Update handlers.js
ethanaobrien Apr 13, 2021
e8e878c
Update options.js
ethanaobrien Apr 13, 2021
21f5d60
Update index.js
ethanaobrien Apr 13, 2021
2766460
Update README.md
ethanaobrien Apr 13, 2021
e6f85a9
Update options.js
ethanaobrien Apr 13, 2021
b9f8a44
Update options.js
ethanaobrien Apr 13, 2021
c152e43
Changed index of current directory message to path
ethanaobrien Apr 22, 2021
2834de1
Update webapp.js
ethanaobrien Apr 22, 2021
d8d2eab
Update directory-listing-template.html
ethanaobrien Apr 27, 2021
44738e1
Update handlers.js
ethanaobrien Apr 27, 2021
a3e5f8f
Update handlers.js
ethanaobrien Apr 27, 2021
93393ef
Update directory-listing-template.html
ethanaobrien Apr 27, 2021
f7ad649
Update package.json
ethanaobrien Apr 29, 2021
91c53f8
Fix #226
ethanaobrien Apr 29, 2021
3c34628
Add delete support
ethanaobrien Apr 29, 2021
95395df
Add delete support
ethanaobrien Apr 29, 2021
2b9faa1
Add delete support
ethanaobrien Apr 29, 2021
9a453a7
Add delete support
ethanaobrien Apr 29, 2021
f59c533
Add Custom 404 support
ethanaobrien Apr 29, 2021
35bc1c1
Add Custom 404 support
ethanaobrien Apr 29, 2021
f40d5ea
Add Custom 404 support
ethanaobrien Apr 29, 2021
d34645e
Fix #263
ethanaobrien Apr 29, 2021
65305ed
Clean up
ethanaobrien Apr 29, 2021
1b75741
Add 404 variable feature
ethanaobrien Apr 29, 2021
af24b6f
Add 404 variable feature
ethanaobrien Apr 29, 2021
1091ae1
Add 404 variable feature
ethanaobrien Apr 29, 2021
09a1394
Fix #267
ethanaobrien May 3, 2021
2c910eb
Update handlers.js
ethanaobrien May 3, 2021
1e25659
UI Cleanup
ethanaobrien May 3, 2021
6d51d3f
Update index.js
ethanaobrien May 3, 2021
e6b6bcd
Update handlers.js
ethanaobrien May 3, 2021
2712cda
Update index.js
ethanaobrien May 3, 2021
6325345
Update options.js
ethanaobrien May 3, 2021
73c92d8
Added gz mime type
ethanaobrien May 3, 2021
2e4ebcb
Update options.js
ethanaobrien May 3, 2021
7fd3009
Update options.js
ethanaobrien May 3, 2021
ba37439
Update options.js
ethanaobrien May 3, 2021
252a640
Update handlers.js
ethanaobrien May 3, 2021
b91d452
Fix 404 mimetype
ethanaobrien May 4, 2021
3333534
Fix 404 mimetype
ethanaobrien May 4, 2021
dcda51f
Fix no .html mimetype
ethanaobrien May 4, 2021
eb0479b
Add some more mimetypes
ethanaobrien May 4, 2021
b957884
Create README.md
ethanaobrien May 5, 2021
05b46ab
Update README.md
ethanaobrien May 5, 2021
975667e
add wsc.htaccess support
ethanaobrien May 5, 2021
b0e28bd
Update README.md
ethanaobrien May 5, 2021
50446c0
Update README.md
ethanaobrien May 5, 2021
db382bc
Update README.md
ethanaobrien May 5, 2021
3cf47ce
Add 401
ethanaobrien May 6, 2021
f783733
Add 401 feature to htaccess
ethanaobrien May 6, 2021
f6831fe
Secutity fixes with rendering directory listing when wsc.htaccess pre…
ethanaobrien May 6, 2021
af4eb44
Add invalid json string failsafe
ethanaobrien May 6, 2021
8feffc7
Update README.md
ethanaobrien May 6, 2021
03074ac
Change this.is404html variable to this.useDefaultMime
ethanaobrien May 6, 2021
0fa72e0
Add setting this.useDefaultMime on startup
ethanaobrien May 6, 2021
f17761c
Fix 401 mimetype and change 404 mimetype variable
ethanaobrien May 6, 2021
c0fd8a9
Clean console
ethanaobrien May 6, 2021
dd7b548
Added security fix
ethanaobrien May 6, 2021
9ad1c25
Update README.md
ethanaobrien May 6, 2021
0b26c47
Fix Security for no .html option
ethanaobrien May 6, 2021
8f6c446
Update README.md
ethanaobrien May 6, 2021
e1f1a3d
Update handlers.js
ethanaobrien May 6, 2021
f04bed1
Update README.md
ethanaobrien May 6, 2021
e5bc531
Added 403 to htaccess
ethanaobrien May 7, 2021
803f204
Added 403 to htaccess
ethanaobrien May 7, 2021
0abe5ac
Fix Typo
ethanaobrien May 7, 2021
8e06cb4
Clean logging
ethanaobrien May 7, 2021
57755d2
Cleaner sending
ethanaobrien May 7, 2021
85d68d4
Fix Typo
ethanaobrien May 7, 2021
e22ec58
Add Custom 403 and 401 pages
ethanaobrien May 7, 2021
e93589f
Critical UI Bug Fix
ethanaobrien May 7, 2021
349c163
Fix 401 index.html bug
ethanaobrien May 7, 2021
6ccfa67
Add Additional Info
ethanaobrien May 11, 2021
47f1df5
Fix console.assert error with no .html option
ethanaobrien May 13, 2021
484f6f1
How could I forget this
ethanaobrien May 13, 2021
431bc53
Added htaccess security features
ethanaobrien May 14, 2021
844507d
More Htaccess Features, Added better handling for no .html when htacc…
ethanaobrien May 16, 2021
2f164e3
Fixed code not displaying
ethanaobrien May 16, 2021
1da986b
Add Size and Date Modified to directory listing
ethanaobrien May 17, 2021
d30b0de
removed duplicate code
ethanaobrien May 17, 2021
0cf7aae
Cleanup
ethanaobrien May 17, 2021
7bb4ecb
Read Metadata error will continue function
ethanaobrien May 17, 2021
859dd40
Custom 400 page
ethanaobrien May 18, 2021
0d452ca
One last bug I found
ethanaobrien May 19, 2021
8485f4c
Remove console.log()
ethanaobrien May 19, 2021
9a32bae
My last htaccess feature (In this pr)
ethanaobrien May 20, 2021
93c1fc5
Htaccess Bug Squash
ethanaobrien May 21, 2021
403a350
I squashed a bug
ethanaobrien May 22, 2021
df138fc
Fix 2 bugs I mentioned
ethanaobrien May 22, 2021
3883e94
Change some outdated info
ethanaobrien May 22, 2021
b601fc8
Update htaccess handler
ethanaobrien May 23, 2021
61b007a
Update handlers.js
ethanaobrien May 23, 2021
1863b53
auth
ethanaobrien May 23, 2021
7df38dc
Add cache control option
ethanaobrien May 25, 2021
18217ea
Why did I set it to the directory and not the file?
ethanaobrien May 25, 2021
ca5d2c1
Syntax cleanup
ethanaobrien May 25, 2021
e977e9f
Fix outdated description
ethanaobrien May 25, 2021
d0cd60e
Update README.md
ethanaobrien May 25, 2021
c6ec47e
More htaccess features
ethanaobrien May 26, 2021
a24c711
I apparently don't know how to use git
ethanaobrien May 26, 2021
67370a6
Update outdated description
ethanaobrien May 26, 2021
3c3ff61
Bug fix
ethanaobrien May 26, 2021
cdd0760
Cleanup, Htaccess feature, no .htm
ethanaobrien Jun 3, 2021
2356a92
Bug
ethanaobrien Jun 6, 2021
0ef16d7
LOTS and LOTS of cleanup
ethanaobrien Jun 13, 2021
201da7b
Sequrity fix (#274)
ethanaobrien Jun 13, 2021
b4ffcd9
Bug Fix
ethanaobrien Jun 14, 2021
3502691
Bug Fix
ethanaobrien Jun 14, 2021
f7fb364
post
ethanaobrien Jun 16, 2021
4f72a80
More Cleanup
ethanaobrien Jun 16, 2021
3025d20
Bug Fix
ethanaobrien Jun 26, 2021
0a2fa88
bug fix
ethanaobrien Jun 26, 2021
f0f29e8
htaccess security fix (json directory listing)
ethanaobrien Jun 26, 2021
b4a89ed
Server Side POST handler
ethanaobrien Jun 29, 2021
370578e
Forgot to push new utils.js
ethanaobrien Jun 29, 2021
f95d9de
Re-fix bug
ethanaobrien Jun 29, 2021
5fa805d
Log to file
ethanaobrien Jun 29, 2021
26cf1c3
Log to file
ethanaobrien Jun 30, 2021
f7c7be3
Chunked Encoding
ethanaobrien Jun 30, 2021
e16515c
Forgot to fix this
ethanaobrien Jun 30, 2021
85c73e2
Fix syntax/description
ethanaobrien Jun 30, 2021
07268af
Bug fix
ethanaobrien Jun 30, 2021
60e3602
Added security for server side post and get requests, added older dev…
ethanaobrien Jul 6, 2021
606a9fd
Forgot that this.error function existed
ethanaobrien Jul 6, 2021
4a15bbc
IP Blocking
ethanaobrien Jul 6, 2021
d185650
bug fix
ethanaobrien Jul 6, 2021
5b95b85
Security & feature
ethanaobrien Jul 7, 2021
c30ae1f
Syntax fix
ethanaobrien Jul 7, 2021
3663ad1
Server clean up on method not supported
ethanaobrien Jul 8, 2021
d743270
Last minute changes
ethanaobrien Jul 9, 2021
e2eab3d
Minor fixes
ethanaobrien Jul 11, 2021
78a63c6
Chunked Encoding Bug Fix
ethanaobrien Jul 12, 2021
3f5acf3
Chunked Encoding Bug Fix
ethanaobrien Jul 12, 2021
0fc514c
Bug Fix
ethanaobrien Jul 12, 2021
d59a8e4
Update Description
ethanaobrien Jul 12, 2021
508e74c
Bug fix
ethanaobrien Jul 12, 2021
4f4d5ce
Fixed .html extension on SSJS bug
ethanaobrien Jul 13, 2021
cb514a6
Add some things
ethanaobrien Jul 16, 2021
e5b4546
Bug Fixes
ethanaobrien Jul 16, 2021
8147e4d
Update htaccess and post
ethanaobrien Jul 16, 2021
a7a003c
Bug Fix
ethanaobrien Jul 20, 2021
502a09e
Bug fix
ethanaobrien Jul 20, 2021
a6308e5
Replace tabs with spaces
ethanaobrien Jul 20, 2021
0802c0b
bug fix
ethanaobrien Jul 20, 2021
d016613
bug fix
ethanaobrien Jul 20, 2021
87155a8
Last change
ethanaobrien Jul 25, 2021
420df8c
Compatibility Support
ethanaobrien Jul 29, 2021
0d1a5d0
Update simple-web-server links
ethanaobrien Aug 2, 2021
c4c7f9e
Bug fix
ethanaobrien Aug 13, 2021
812f21c
Bug Fix
ethanaobrien Aug 21, 2021
04abbb6
Fix a not smart thingy I did
ethanaobrien Aug 26, 2021
70a0f93
Some work
ethanaobrien Feb 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update htaccess and post
  • Loading branch information
ethanaobrien committed Jul 16, 2021
commit 8147e4df28c09d32258e3abe08bde0ee7917eb04
19 changes: 11 additions & 8 deletions handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@
this.htaccessError.bind(this)('missing request path')
return
}
if (origdata[i].type == 403 && origdata[i].request_path == filerequested) {
this.error('<h1>403 - Forbidden</h1>', 403)
return
}
if ((origdata[i].request_path == filerequested && origdata[i].type == 'POSTkey') ||
(origdata[i].request_path == filerequested && origdata[i].type == 'serverSideJavaScript')) {
this.error('bad request', 403)
Expand Down Expand Up @@ -263,6 +267,10 @@
var authdata = origdata[i]
var auth = true
}
if (origdata[i].type == 403 && origdata[i].request_path == filerequested) {
this.error('<h1>403 - Forbidden</h1>', 403)
return
}
if (origdata[i].type == 'POSTkey' && ! filefound) {
if (this.request.origpath.split('/').pop() == origdata[i].original_request_path ||
(origdata[i].original_request_path.split('.').pop() == 'html' &&
Expand Down Expand Up @@ -767,14 +775,16 @@
this.responseLength = 0
this.writeHeaders(data.type)
this.finish()
} else if (data.type == 403) {
} else if (data.type == 'denyDirectAccess') {
var method = this.request.headers['sec-fetch-dest']
//console.log(method)
if (method == "document") {
this.error('<h1>403 - Forbidden</h1>', 403)
} else {
excludedothtmlcheck.bind(this)()
}
} else if (data.type == 403) {
this.error('<h1>403 - Forbidden</h1>', 403)
} else if (data.type == 'directory listing') {
function finished(results) {
if (this.request.arguments.json == '1' ||
Expand All @@ -788,9 +798,7 @@
this.renderDirectoryListingTemplate(results)
}
}

this.getDirContents(entry, finished.bind(this))

} else if (data.type == 'send directory contents') {
if (! data.dir_to_send || data.dir_to_send.replace(' ', '') == '') {
data.dir_to_send = './'
Expand Down Expand Up @@ -1344,14 +1352,9 @@
results.isFile = false
callback(results)
})
} else if (file && ! file.error) {
file.file(function(file) {
callback(file)
})
} else {
callback(file)
}

}.bind(this))
},
writeFile: function(path, data, allowReplaceFile, callback) {
Expand Down
23 changes: 18 additions & 5 deletions howTo/HTACCESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<p>302 - Found. Tells the server that when chosen file is requested to move to a different directory or file. Not cached by the browser</p>
<p>307 - Temporary Redirect. Tells the server that when chosen file is requested to move to a different directory or file. Not cached by the browser.</p>
<p>401 - Unauthorized. The page will require login. For some reason, I cannot find how to clear the cache of the authorization header, which means that once you type it in, the browser will not ask for a login, unless you have multiple password protected pages with different passwords, The authentication header will change whenever you enter a different password.</p>
<p>403 - Forbidden. This will deny direct access to image/video/audio files. This option only works if https is enabled or if the user is on a localhost address.</p>
<p>403 - blocks any request to the file</p>
<p>denyDirectAccess - This will deny direct access to image/video/audio files. This option only works if https is enabled or if the user is on a localhost address.</p>
<p>Render Directory Listing - Ignores the value of 404 instead of directory listing and renders the directory listing</p>
<p>Deny deleting for a specific file or directory - Ignores value of delete option and will deny delete to requested file</p>
<p>Allow deleting for certian file - Ignores value of delete option and will allow deleting requested file</p>
Expand Down Expand Up @@ -102,14 +103,14 @@ To use option for all files, the value of request path will be 'all files' It sh
]
```
<br>
<h2>403 Example</h2>
<h2>denyDirectAccess Example</h2>
<p>This will deny direct access to image/video/audio files. This option only works if https is enabled or if the user is on a localhost address.</p>

```
[
{
"request_path": "name of file you want to modify",
"type": 403
"type": "denyDirectAccess"
}
]
```
Expand Down Expand Up @@ -173,6 +174,18 @@ To use option for all files, the value of request path will be 'all files' It sh
]
```
<br>
<h2>403 - Block File</h2>
<p>Just blocks the file</p>

```
[
{
"request_path": "name of file you want to modify",
"type": 403
}
]
```
<br>
<h2>Versioning</h2>
<p>Versions of a file</p>

Expand Down Expand Up @@ -249,7 +262,7 @@ The end result will be
[
{
"request_path": "name of file you want to modify",
"type": "send directory contents"
"type": "send directory contents",
"dir_to_send": "../somepath/"
}
]
Expand Down Expand Up @@ -285,7 +298,7 @@ This feature CANNOT use the `all files` value for the `request_path` field. You
[
{
"request_path": "name of file you want to modify",
"type": "serverSideJavaScript"
"type": "serverSideJavaScript",
"key": "ATonOfRaNdOmNumbersAndLetters"
}
]
Expand Down
44 changes: 32 additions & 12 deletions howTo/post.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.

<h1>How to use Server Side POST</h1>
<br>
<h2>How it works</h2>
Expand Down Expand Up @@ -85,20 +85,25 @@ Instead of `Cookie: name=value`, you would put `res.setHeader('Cookie', 'name=va

`res.getFile(path, callback)`: function
This function will read a file. Relative urls are supported.
If the requested path is a directory, the callback function will be called with a listing of all the files in a directory. If you would like to use a file from there you must use the file.file() function.
If the requested path is a directory, the callback function will be called with a listing of all the files in a directory.
To call the file use the `file.file()` function
Example:
```
`res.getFile('../test.txt', function(file) {
if (file.isFile) {
//if the file is a file, you can read and do whatever. You will need to use a FileReader to read the file.
}
if (file.isDirectory) {
// This will return an array of all of the files in the directory. To use a file (as you do with file.isFile) you must use file.file() as shown below
file[5].file(function(file) {
console.log(file)
})
}
}
if (file.error) {
console.log('error')
} else if (file.isFile) {
file.file(function(file) { // you must use the file.file() function to call the file.

//if the file is a file, you can read and do whatever. You will need to use a FileReader to read the file.
})
} else if (file.isDirectory) {
// This will return an array of all of the files in the directory. To use a file you must use file.file() as shown below
file[2].file(function(file) {
console.log(file)
})
}
})
```

`res.contentType(type)`: function
Expand All @@ -120,6 +125,21 @@ callback: function will be excecuted to tell you if there was an error or succes
`res.writeCode(httpCode)`: function
Call this to respond with no message. Dont forget to finish with `res.end()`

`res.renderFileContents`: function
Once you have called the file with `res.getFile()` (DO NOT use the `file.file()` function) use `res.renderFileContents()` to render the file
Example:
```
`res.getFile('../somefile.html', function(file) {
if (file.error) {
console.log('error')
} else if (file.isFile) {
res.renderFileContents(file)
} else if (file.isDirectory) {
res.renderFileContents(file[2])
}
})
```

<h2>Chunked encoding</h2>

`res.writeChunk`: function
Expand Down