Jigsaw-Code / Intra

An experimental tool that allows you to test new DNS-over-HTTPS services on Android
Apache License 2.0
1.56k stars 263 forks source link

fix: cancel all outgoing requests when disconnect to prevent ANR #501

Closed jyyi1 closed 9 months ago

jyyi1 commented 9 months ago

In this PR, I fixed an ANR issue by adding a context.Context object to the doh.Transport.Query method. This ctx will be passed to all network related calls, and it will be cancelled when user Disconnects.

But if we just simply add ctx to the method, gomobile requires we export all related packages (e.g., time) that are used by context.Context, which is not applicable. Therefore we refactored the go code structure and introduced a new backend package that will be the only interface that Java code can use.

In addition, I retired github.com/eycorsican/go-tun2socks/common/log and introduced our own logging package.

TODO Items

The refactoring of backend package is not done yet (for example, intra, intra/split and intra/protect are still exported to Java), but it will involve a lot of changes that are not related to this PR, therefore I would postpone them to future changes.