web-server-chrome icon indicating copy to clipboard operation
web-server-chrome copied to clipboard

Feature Updates and Bug Fixes

Open ethanaobrien opened this issue 4 years ago • 21 comments

Resolves #262 - (Adds option to show a 404 error instead of rendering the directory listing) Resolves #203 - You can click the name button to flip the order. - Is not sorted alphabetically on load. Resolves #261 - I just had to change react and react-dom to version 17.0.2 - The ui seems to work faster now tbh. Resolves #266 - When https option changes, the web server shuts down, and turns back on. Using callbacks to prevent race conditions Resolves #135 - I added the code that @er2er Commented with. Also added delete option under upload option Resolves #182 - Added support for custom 404, 403, 401, and 400 pages. (Also added failsafe for when user put in wrong path of html file), also, I added a feature that will send the client a script element so that the author of the site can customize the page. (Only 404) Its hard to explain, just take a look. (If I were you and If I could word it better I would change the name of the option in options.js) Resolves #263 - Fixed incorrect displayed protocol Resolves #267 - Will only create background window if web server is turned on Possibly Resolves #258 - will look for index.html file without case sensitivity Resolves #269 - Rewrite options and 404 options render as the https options do. Resolves #186 - Option to omit .html extension from user request path (Not the file itself). When this option is enabled and a file ending in .html is called, the browser will re-direct the file (Using 307 so the browser does not cache) to use not the html extension. Resolves #177 - Added gz file type to mime.js Resolves #191 (This was VERY difficult) - Added support for wsc.htaccess. It is similar to .htaccess. Not fully implemented. The problem in #191 is technically resolved above More details can be found here. Note: In /react-ui/js/index.js the instructions on how to use a wsc.htaccess file would have been too big so I put a message when feature enabled saying "For more info on how to use wsc.htaccess files, go here" and the text "Here" has a link to here. You might want to replace that link to the htaccess readme in your repository (or we could copy it into the wiki). If the wsc.htaccess file is not a valid json file, there is a failsafe. Resolves #42 - Add date modified and size to directory listing. Performance does not suffer. Resolves #130 - Add cache-control header option in advanced settings. Resolves #274 - Fixed Resolves #276 - Created a customizable server side post handler Resolves #45 - Option to log to a file Resolves #299 - adds post handler

Since Kyle seems inactive on github, you can download the zip archive below, go to chrome://extensions, turn on developer mode, and click "load unpacked" and select the directory that contains the extracted zip file

Tested by me. I changed the version in the manifest to 2.5.3, you can change it if you like. (I think it should be higher with the amount of features added)

I also just replaced the broken image in the readme with the default logo in the readme

If you dont like the message it gives when there is no index.html, you can easily change it in the handlers.js file

Also, I dont know if it is just me, but when packing the app I had to add npm install after the cd ../react-ui step.

Zip archive of compiled app (I try to keep this up to date): https://drive.google.com/file/d/12Ewzalvx5ZMdleWcGnms4XFnHWC4j65_/view?usp=sharing

I would recommend that you re-compile the app on your end. The zip is just for testing

I also changed the Index of current directory message to the path of the user

(When Fixing Fix #266 I accidentally marked the contribute as #226)

@kzahel #266 needs to be fixed asap - This bug causes https to only work on chromebook without constantly restarting google chrome

ethanaobrien avatar Apr 13 '21 18:04 ethanaobrien

Hi @ethanaobrien thanks so much for all the activity on this project. I'll take a look at your branch in a bit. I haven't been investing much because of chrome apps being sunsetted within a year or so. Support for osx/windows has already ended (though it keeps working). I would expect that by the end of the year some chrome update will just disable apps (and make this no longer work). Still, I think you're doing some great changes here.

kzahel avatar May 05 '21 07:05 kzahel

Also keep in mind having a huge pull request that is not specific to any single issue makes it much harder to evaluate the changes. I would definitely prefer smaller pull requests in the future.

kzahel avatar May 05 '21 07:05 kzahel

@kzahel Ok, Thank you! I will do that in the future. I am probably done with this :/ Cant think of anything else (Except for the htaccess feature I am working on)

I did catch a bug for users not on chrome os with the https setting auto restarting. With the custom 404 page, I made sure every file (Like .js files) render as an html and not code.

Sorry for the mess! I will do multiple smaller ones in the future! (I didnt think about that at the time)

And yeah, I get your inactivity. I continue on this project because It is the easiest web server for me to use. I plan on continuing to use it after the chrome apps stop working (Using an old version from the chromium archives) If you would like, I would gratefully take over this project!

I am going to post one more update to a feature that I am working on. Its beta so it may be buggy, the reason why I dont make a second pull request is because this depends on a way that I re-organized some of the code

ethanaobrien avatar May 05 '21 13:05 ethanaobrien

@kzahel I added support for this wsc.htaccess feature that I have been working on. The reason why the commit labeled "add wsc.htaccess support" does not say Verified next to it is because I used git to push my changes

If I make any more changes (as of when I am editing this) They are bug fixes or htaccess features. The main thing I had to fix is the transferred mimetype when no .html extension is present, the mimetype when you get a 401 - Unauthorized page for a file such as index.js, and the mimetype when you request a .js file and it is not found.

My favorite thing to implement was the htaccess feature. It adds so much possibility to the functionality of the web server! In the end the htaccess feature turned out to be really simple(ish) but in the beginning I was extremely over complicating things. The hardest thing was starting it. Now that the base handling is layed out it would take like 5 - 10 minutes to add another feature. (It took me 15 minutes to add the 403 feature) Its awesome!! Also, The reason the wsc.htaccess file (More info in the first message of the pull request.) is a json file is because its kinda the easiest thing to read in javascript. There is a failsafe for when the json is not valid. When the user requests a wsc.htaccess file you will get a 403 - Forbidden error. When the directory listing is rendered, wsc.htaccess files are not displayed. The amazing thing about how I implemented this is that the way I organized everything it doesnt slow down the web server that much. It may take like 50 more milliseconds, but the performance difference should not be noticeable. This makes the web server seem like an actual server! The Possibilities are endless! I put in what I could think of (Basic Authentication (401), 301, 302, 307, and 403) For a more detailed description, read the first message of the pull request! Part of me thinks that I should have a separate .js file for this feature. It would make it cleaner. The only thing is I wouldnt know how to import the handlers.

I have lots of planned features for htaccess!!

I also updated the directory listing with the updated google directory listing template. The parent directory button will not show if the request path is /.

The react-ui/index.js file may look a little messy. With the way the https options rendered I wanted to do this with the other options that had sub options to make the ui cleaner and now it may look messy but once you really get to know it it is pretty simple.

I use the this.useDefaultMime variable to tell the webapp.js whether to use the default mimetype or not. When rendering the 401 page or when rendering the 404 page, this value is set to false, Right after this.close() the value is set right back to false. When the web server starts up, background.js sets the value to true.

Also, I had to re-organize some of the code in the handlers.js. The onEntry function is now divided into 3 functions. The main one is onEntryMain(), the second one is excludedothtmlcheck() and the third one (that calls the other functions when needed) checks for the htaccess setting. If the htaccess setting is turned off (Or when htaccess needs to render a file) the excludedothtmlcheck() function is called. This then checks the exclude .html option, if it is set to false it goes right to the onEntryMain() function. Also, if there is no file that would use .html being called it calls the onEntryMain(). When a file is found, I used the this.renderFileContents(file) script to render the contents of the .html file.

If you have any other questions about what I changed, just ask me! I can explain what I did and my logic behind it! Also, (Its on my github profile) I am only 16 and I am self taught, so I am really sorry if I messed anything up. I tested everything and everything should work. Just now, because of typing this, I am just realizing all that I have built.

Also, when digging through the webapp.js I found an option called this.opts.auth that password protected the server. Is there a reason this is not implemented? I tested it and it works, the only thing that would need to be implemented is the UI, which would be fairly simple.

And again, I want to say sorry for the mess, when I started I didn't think about doing 1 pull request for each feature and it just turned into a mess. I feel like kinda bad about that. And then by the time you pointed it out I had a bunch of dependencies I coded in and yeah, I'm just sorry about that. Even below this comment I got really messy with fixing security and Adding more htaccess features. I'm sorry about that. Unless I find a bug that makes the web server unusable, I will not make another commit until this is merged. Sorry about the mess :/

Also, Just so you know. There were 2 commits below that I had to undo because I found that they broke the web server. Commit 0b26c47, and 8f6c446 are the commits that I made the change, and then I unmade the change in commits e1f1a3d, and f04bed1. I'm really sorry about all this mess. I can only edit through the web browser half the time which makes the commits messy. Please forgive me. In the future, I will test my changes and use git if I can to push my changes.

ethanaobrien avatar May 05 '21 23:05 ethanaobrien

@kzahel one of my comments got berried by the commits. Click the view more to see it. Sorry about the mess

ethanaobrien avatar May 15 '21 19:05 ethanaobrien

@kzahel Think about the size and date modified in directory listing as like a payback for the huge mess. I hope you like the features I added :)

ethanaobrien avatar May 17 '21 21:05 ethanaobrien

@kzahel I have finished this. Every feature is in and I have gone looking and squashed all of the bugs.

I will not let the amount of commits get out of control in the future. For this I am sorry.

ethanaobrien avatar May 19 '21 03:05 ethanaobrien

Hi @ethanaobrien . I haven't had a chance to check out your branch and test it yet. I see you are still making a few final commits. I get a lot of email notifications from you now. If something is more urgent, feel free to @ me. I will try to make some time this weekend to take a look at all your changes. Thanks again for all the comments in the issues, I will also try and make a pass and close some issues and do some updating as you pointed out in those various issues.

kzahel avatar May 21 '21 12:05 kzahel

Awesome! But yeah. I've decided not to make any more commits until this pr gets looked at so that is what I am going to wait for.

Thank you

I thought about moving the htaccess handler from handlers.js to webapp.js, but this would make the delete and put features impossible. (it also makes more sense to have the htaccess handler in with the rest of the handlers)

Bugs that I have found that I need to fix:

When directory listing empty, the handler will error --FIXED I am not going to do the advanced ui for the not advanced options - it seems to have broken the startup option -- FIXED

(No current known bugs)

ethanaobrien avatar May 21 '21 13:05 ethanaobrien

Also, when (and if) you merge this, before you put it on the chrome web store there is a link to the htaccess readme that you will need to put into the react-ui/js/index.js folder. There is also a link in the readme (Should this be moved to a wiki page?)

Also - I changed the version in the manifest.json to 0.5.3. (In my opinion, with how many features I added, it should be higher)

Just for a not fun fact - I am running chrome os 91 (beta channel) and I see the start to the Chrome Apps deprecation. The start on login no longer works :/ (I checked, I didnt break anything)

If you encounter any bugs in the new htaccess handler, please let me know. I tested the basics but I still could have missed something. (Not Likely)

ethanaobrien avatar May 22 '21 03:05 ethanaobrien

I'll wait to merge until you want me to; in case you want to make any final changes in this PR. I'll plan on doing a release after merging and testing a little bit more.

kzahel avatar May 23 '21 07:05 kzahel

@kzahel Everything has been finished and it is ready to merge! I was bored and decided to resolve #130 because I knew it was extremely simple. If the user sets an invalid header option for Cache-Control, the receiving browser will ignore it.

Also, I saw all the comments you left on the other issues and I want to say thank you!

(Dont forget to approve the commits I made)

AND MOST IMPORTANTLY, I know I've said this many times, I just dont want you to forget, Change the links to go to your htaccess readme instead of my htaccess readme. (Readme: line 28; react-ui/js/index.js: Line 410

ethanaobrien avatar May 23 '21 16:05 ethanaobrien

@kzahel In my latest 2 commits, I have added a htaccess feature to send additional headers and I have re done all of the for() statements that are scanning the htaccess file. I cleaned up handlers.js by making a utils.js file. I also added another htaccess feature to send the current directory with the requested file. I hope you like it!

100% ready to merge

Also, Just so you know, School for me ends tomorrow and I will be less active during the summer.

Also, I plan on adding 3 more things

  1. no .htm option - FINISHED
  2. htaccess failsafe (For when user leaves out values) - FINISHED
  3. an htaccess feature (It's a surprise) - FINISHED

Also, when you publish, please take a look at also publishing it to the microsoft edge store. I asked a question here and microsoft has announced no deprecation. (See #271 )

ethanaobrien avatar May 26 '21 16:05 ethanaobrien

@kzahel Please don't forget about this pr. Also, I found a way (In my latest commit) to restart the web server!

ethanaobrien avatar Jun 13 '21 00:06 ethanaobrien

Accidentally marked commit 26cf1c3 as Log to file - Meant to say Added folder creation for log to file and replaced all tabs with groups of 4 spaces

ethanaobrien avatar Jun 30 '21 14:06 ethanaobrien

Just so you know, this will always be ready to merge. I'm going to keep doing things as they come to mind until this is merged.

ethanaobrien avatar Jul 07 '21 15:07 ethanaobrien

I see you keep committing :-) I liked the changes you made when I tested it last but I haven't had the time to look at your most recent changes.

I will do my best to actually test it again, merge, and make a release this coming weekend (no promises though)

kzahel avatar Jul 07 '21 19:07 kzahel

@kzahel Thank you, Below I am going to provide some info on the ip feature

The ip feature will only show the users ip if not on a local address (you need to use port forwarding) I opened my server yesterday to run some tests (and opened port forwarding) and, using the log to file feature, I was able to catch some spam requests. One is listed below.

clearIdle

209.141.47.35: Request GET /config/getuser?index=0 

36 response code 404 clen 1260 

http conn close

I just think it is funny when I see requests like these (Because I've tested and caught every way possible to do anything even remotely like this)

I also used this method to test my ip blocking feature.

Thank you! This is a really fun project!

ethanaobrien avatar Jul 08 '21 19:07 ethanaobrien

@kzahel Because of this. I will no longer be working on this. You can merge this when you are ready!

ethanaobrien avatar Jul 25 '21 01:07 ethanaobrien

@kzahel Do you think you could look into merging this?

ethanaobrien avatar Feb 25 '22 21:02 ethanaobrien

Marked as draft since I don't entirely think this should be merged

ethanaobrien avatar Feb 23 '24 03:02 ethanaobrien