algernon icon indicating copy to clipboard operation
algernon copied to clipboard

Lua scripts are downloaded when QUIC is enabled

Open linkerlin opened this issue 3 years ago • 15 comments

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

linkerlin avatar Jun 23 '22 05:06 linkerlin

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

xyproto avatar Jun 23 '22 07:06 xyproto

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 avatar Jun 23 '22 09:06 xyproto

Added a line :

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

fixed it. weired.

linkerlin avatar Jun 24 '22 05:06 linkerlin

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 avatar Jun 24 '22 10:06 xyproto

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?

linkerlin avatar Jun 27 '22 06:06 linkerlin

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.

tooolbox avatar Jun 27 '22 20:06 tooolbox

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.

xyproto avatar Jun 27 '22 21:06 xyproto

  • 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 avatar Jun 27 '22 23:06 linkerlin

Added

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

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

linkerlin avatar Jun 29 '22 05:06 linkerlin

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

linkerlin avatar Jun 29 '22 10:06 linkerlin

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

linkerlin avatar Jul 01 '22 01:07 linkerlin

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 avatar Jul 01 '22 02:07 linkerlin

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

linkerlin avatar Jul 01 '22 02:07 linkerlin

  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.

xyproto avatar Jul 02 '22 15:07 xyproto

  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 .

linkerlin avatar Jul 03 '22 04:07 linkerlin