taoky / tsumugu

🧵 A HTTP(S) mirroring tool written in Rust, proposed for ustcmirror
https://crates.io/crates/tsumugu
MIT License
17 stars 2 forks source link

Want to add a custom header parameter #17

Closed Yifengzis closed 1 week ago

Yifengzis commented 1 week ago

Want to add a custom header parameter

taoky commented 1 week ago

I could add this feature with more args, but I'm curious about the real-life scenario for adding a custom header -- tsumugu currently already supports adding a user agent.

taoky commented 1 week ago

OK,我会考虑最近添加这个特性。

(PS,我不确定你的评论里面的认证信息是否敏感,如果是的话建议自行删除)

taoky commented 1 week ago

Tested with:

htpasswd -c htpasswd username
server {
    listen 80;

    root /usr/share/nginx/html;

    location / {
        autoindex on;
        autoindex_exact_size off;  # Optional, to show file sizes in KB/MB
        autoindex_localtime on;    # Optional, to show local time
        auth_basic "Restricted Area";
        auth_basic_user_file /etc/nginx/.htpasswd;
    }
}
podman --rm -p 8080:80 -v $(pwd)/htpasswd:/etc/nginx/.htpasswd -v $(pwd)/basic-nginx.conf:/etc/nginx/conf.d/default.conf -v /tmp/:/usr/share/nginx/html:ro nginx

And OK:

$ cargo run -- list --parser nginx --header "Authorization: Basic dXNlcm5hbWU6IA==" http://localhost:8080/
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.09s
     Running `target/debug/tsumugu list --parser nginx --header 'Authorization: Basic dXNlcm5hbWU6IA==' 'http://localhost:8080/'`
Relative: /
Exclusion: Ok
http://localhost:8080/093d805e-3528-4c28-b00e-0ec168709b14/ Directory (none) 2024-11-17 07:33:00 093d805e-3528-4c28-b00e-0ec168709b14
...

我现在发个新版吧。

taoky commented 1 week ago

https://github.com/taoky/tsumugu/releases/tag/20241123