Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua scripts are downloaded when QUIC is enabled #102

Open
linkerlin opened this issue Jun 23, 2022 · 15 comments
Open

Lua scripts are downloaded when QUIC is enabled #102

linkerlin opened this issue Jun 23, 2022 · 15 comments
Assignees
Labels
trying-to-reproduce-the-issue Not able to reproduce the issue yet

Comments

@linkerlin
Copy link

algernon --cache=images --redis=localhost:6379 -s /root/owrt_www :443
is OK.
algernon -u --cache=images --redis=localhost:6379 -s /root/owrt_www :443
will make *.lua can be downloaded.
@ current master code

@xyproto
Copy link
Owner

xyproto commented Jun 23, 2022

Thanks for reporting! I'll reproduce the issue and look into it.

@xyproto xyproto added bug This is a bug planning-to-reproduce-the-issue Planning to reproduce the issue and removed bug This is a bug labels Jun 23, 2022
@xyproto xyproto self-assigned this Jun 23, 2022
@xyproto xyproto added trying-to-reproduce-the-issue Not able to reproduce the issue yet and removed planning-to-reproduce-the-issue Planning to reproduce the issue labels Jun 23, 2022
@xyproto
Copy link
Owner

xyproto commented Jun 23, 2022

I'm currently unable to reproduce the issue. Here are the steps I tried:

git clone https://github.com/xyproto/algernon
cd algernon
go build -mod=vendor
sudo setcap cap_net_bind_service=+ep ./algernon
./algernon --cache=images -s samples :443

Then in another window ("Hello, Lua!" is the reply I got back from the server):

curl -k 'https://localhost/lua/'
Hello, Lua!
curl -k 'https://localhost/lua/index.lua'
Hello, Lua!

And then with ./algernon -u --cache=images -s samples :443, I get the same replies:

curl -k 'https://localhost/lua/'
Hello, Lua!
curl -k 'https://localhost/lua/index.lua'
Hello, Lua!

The same thing happens if I add a test.lua file and try to download it.

What are the steps to reproduce the issue?

@xyproto xyproto added the waiting-for-a-reply Waiting for a reply or clarification from the submitter of the issue label Jun 23, 2022
@linkerlin
Copy link
Author

Added a line :

content([=[text/html; charset=utf-8]=]);

fixed it.
weired.

@xyproto
Copy link
Owner

xyproto commented Jun 24, 2022

Declaring the content type at the top of a Lua script with a call to content is a good practice, but the lack of one should not cause the contents of the Lua script to be downloaded. If this happens, it's a bug, and I would very much like to fix it.

algernon/samples/index.lua only contains print("Hello, Lua!"), and the file is not downloaded. If I change it to something else like 2+3, the file is not downloaded either.

Please include the steps to reproduce the issue.

@xyproto xyproto changed the title QUIC enabled will make *.lua can be downloaded Lua scripts are downloaded when QUIC is enabled Jun 24, 2022
@linkerlin
Copy link
Author

Finally, I know why .
If I put -u at the first arg of arglist
algernon -u --cache=images --redis=localhost:6379 -s /root/owrt_www :443
problem reproduced!
And if I move the -u to the last of the arglist, everything is fine.
algernon --cache=images --redis=localhost:6379 -s -u /root/owrt_www :443

Maybe the init of Algernon is too complex without a lua script?
What about added a init.lua for the init of Algernon?

@tooolbox
Copy link
Collaborator

tooolbox commented Jun 27, 2022

Maybe the init of Algernon is too complex without a lua script?
What about added a init.lua for the init of Algernon?

You already proposed init.lua and that has its own merits but not as an imagined decomplication of the command-line flags. Seems like there's just a bug that needs to be fixed.

@xyproto
Copy link
Owner

xyproto commented Jun 27, 2022

When running both of these commands, everything works fine here:

  • ./algernon --cache=images -s -u samples :443
  • ./algernon -u --cache=images -s samples :443

Nothing I could find in the source code hints that the order of the -u flag should matter.

  • Which platform are you on?
  • Are you using the latest commit from the main branch and building with go build -mod=vendor?
  • Is there anything unusual about the Lua files in /root/owrt_www? Unusual permissions, uppercase filenames or unusual unicode symbols?

Please provide steps that I can follow to reproduce the issue here. I don't have /root/owrt_www and the files that are there.

@linkerlin
Copy link
Author

linkerlin commented Jun 27, 2022

  • go build -mod=vendor

DEBUG SITE
Click Hello Lua will download a lua-file;
Click Counter is OK.
Updated algernon from github and rebuld it with go build -mod=vendor.
algernon --cache=images --redis=localhost:6379 -s -u /root/owrt_www :443
DEBUG SITE
The samples is the same as algernon/samples from the source code.
Why?

@linkerlin
Copy link
Author

Added

content([=[text/html; charset=utf-8]=]);

to /samples/permissions/index.lua at line 0
fixed the download file problem.

@linkerlin
Copy link
Author

linkerlin commented Jun 29, 2022

Maybe added a checking for any http-response head missing content key
and added
content: "text/html; charset=utf-8"
as default
?

@linkerlin
Copy link
Author

Update:
change browser from chrome to safari, and problem disappeared.

@linkerlin
Copy link
Author

Update: change browser from chrome to safari, and problem disappeared.

Safari donnot connect to my site with QUIC.
So the -u option is the root cause.

@linkerlin
Copy link
Author

I have try to remove -u and the chrome also work .
What happened?

@xyproto
Copy link
Owner

xyproto commented Jul 2, 2022

  1. Is there anything unusual about the Lua files in /root/owrt_www? Unusual permissions, uppercase filenames or unusual unicode symbols?
  2. Please provide steps to reproduce the issue that will also work on systems that don't have /root/owrt_www, if possible.

I will try reproducing the issue in Chrome as well.

@linkerlin
Copy link
Author

  1. Is there anything unusual about the Lua files in /root/owrt_www? Unusual permissions, uppercase filenames or unusual unicode symbols?
  2. Please provide steps to reproduce the issue that will also work on systems that don't have /root/owrt_www, if possible.

I will try reproducing the issue in Chrome as well.

You're right.
When some bad-thing happened in a non-debug-mode algernon, it will triger a download .

@xyproto xyproto removed the waiting-for-a-reply Waiting for a reply or clarification from the submitter of the issue label Jul 22, 2023
Repository owner deleted a comment Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
trying-to-reproduce-the-issue Not able to reproduce the issue yet
Projects
None yet
Development

No branches or pull requests

3 participants