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

Proxying doesn't work with mitmproxy #2294

Open
1 task done
miliog opened this issue Oct 2, 2023 · 7 comments
Open
1 task done

Proxying doesn't work with mitmproxy #2294

miliog opened this issue Oct 2, 2023 · 7 comments
Labels
bug Something isn't working cli About Typst's command line interface. needs-investigation More investigation is necessary.

Comments

@miliog
Copy link

miliog commented Oct 2, 2023

Description

Downloading packages via compile fails. For update, the proxy isn't being used at all.

Screenshot from 2023-10-02 22-18-45

Status 400 is coming from mitmproxy. It doesn't understand the HTTP request for some reason.

Below are all HTTP requests that successfully passed through mitmproxy:

Screenshot from 2023-10-02 22-22-02

Reproduction URL

No response

Operating system

Linux

Typst version

  • I am using the latest version of Typst
@miliog miliog added the bug Something isn't working label Oct 2, 2023
@laurmaedje laurmaedje added the cli About Typst's command line interface. label Oct 4, 2023
@laurmaedje
Copy link
Member

@zicklag any ideas?

@zicklag
Copy link
Contributor

zicklag commented Oct 4, 2023

Not off the top of my head. @miliog is this the proxy you're using mitmproxy?

I might be able to take a quick look at it...

@miliog
Copy link
Author

miliog commented Oct 4, 2023

...

Yes, that's the software that I used. You can just start it inside a terminal without any configuration and it will create a proxy for you at http://localhost:8080. The certificate is under ~/.mitmproxy/, as shown in my screenshot.

I was able to download packages via compile with other proxies before, though, just not with mitmproxy. However, update definitely ignores any proxy that I've tried so far and just uses the regular Internet connection.

@miliog
Copy link
Author

miliog commented Oct 7, 2023

I just looked at the code and I found out the reason for update at least:

        match ureq::get(&url).call() {
            Ok(response) => response
                .into_json()
                .map_err(|err| eco_format!("unable to parse JSON response: {err}")),
            Err(ureq::Error::Status(404, _)) => {
                bail!("release not found (searched at {url})")
            }
            Err(err) => bail!("failed to download release ({err})"),
        }

When downloading the tag, the proxy agent isn't being used. Downloading the release itself should be fine as it uses the download_with_progress function from download.rs, but if your environment blocks any connections without the use of a proxy, you won't be able to self-update the Typst executable.

I still don't know why mitmproxy in particular doesn't work even though curl can do it just fine.

@laurmaedje
Copy link
Member

Oh.. well, it's an easy fix at least.

@zicklag
Copy link
Contributor

zicklag commented Oct 8, 2023

I still don't know why mitmproxy in particular doesn't work even though curl can do it just fine.

Yeah, I think that's the only mystery, now. I can confirm that downloading packages works through a squid proxy, so there must be some nuance in the format of the proxy request that is made by the ureq library that we use for making requests.

I think it might be an issue for the ureq crate, if we can double-check with a minimal reproducible example that ureq requests just don't go through the mitmproxy correctly.

@laurmaedje laurmaedje added help wanted Extra attention is needed needs-investigation More investigation is necessary. and removed help wanted Extra attention is needed labels Nov 14, 2023
@laurmaedje
Copy link
Member

I've changed the release fetching to use the agent, too, so the only remaining issue is the mitmproxy thing.

@laurmaedje laurmaedje changed the title Proxy is not working for either compile or update Proxying doesn't work with mitmproxy Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli About Typst's command line interface. needs-investigation More investigation is necessary.
Projects
None yet
Development

No branches or pull requests

3 participants