简体   繁体   English

PacketZoom如何工作?

[英]How does PacketZoom work?

I want to track all HTTP requests from my android app (including the requests made by libraries used in the app), by just adding some kind of interceptor. 我想通过添加某种拦截器来跟踪我的android应用程序中的所有HTTP请求(包括应用程序中使用的库发出的请求)。 But it isn't obvious how should I do it. 但是我不应该怎么做。 Here is a SDK which claims that it does optimisations on network requests, so you just have to add it to your project and it automatically captures all http requests and optimises them. 这是一个声称可以对网络请求进行优化的SDK,因此您只需将其添加到项目中,即可自动捕获所有http请求并对其进行优化。 https://packetzoom.com/index.html?utm_expid=79277288-12.gxkHaG0PSAG0KVsLa3JdzA.0&utm_referrer=https%3A%2F%2Fpacketzoom.com%2F https://packetzoom.com/index.html?utm_expid=79277288-12.gxkHaG0PSAG0KVsLa3JdzA.0&utm_referrer=https%3A%2F%2Fpacketzoom.com%2F

How does it work? 它是如何工作的? If they implemented their functionality of optimisations then it means all HTTP requests are somehow trackable. 如果他们实现了优化功能,则意味着所有HTTP请求都可以以某种方式进行跟踪。 I guess they've done it through JNI, but I fail to find any working solution. 我想他们已经通过JNI做到了,但是我找不到任何可行的解决方案。

Packetzoom engineer is here. Packetzoom工程师在这里。 There are few approaches to intercepting all requests from the app: 拦截应用程序中所有请求的方法很少:

  1. You implement local http proxy server which can run as separate service and use ProxySelector.setDefault API to redirect all requests to your proxy. 您实现可作为单独服务运行的本地http代理服务器,并使用ProxySelector.setDefault API将所有请求重定向到您的代理。 This generally works well with popular libraries like OkHttp and HttpUrlConnection . 这通常可以与OkHttpHttpUrlConnection之类的流行库配合使用
    However, you won't be able to see https traffic since it's encrypted and your proxy has to support HTTP CONNECT method to provide a tunnel for https. 但是,您将无法看到https流量,因为它已加密,并且您的代理必须支持HTTP CONNECT方法才能为https提供隧道。

  2. The second approach is to use URLStreamHandlerFactory API . 第二种方法是使用URLStreamHandlerFactory API

to register custom HTTP/HTTPS protocol handlers. 注册自定义HTTP / HTTPS协议处理程序。 This approach is limited to work only with HttpUrlConnection API but you can get access to original HTTPS requests. 这种方法仅限于仅与HttpUrlConnection API一起使用,但是您可以访问原始HTTPS请求。

By the way, PacketZoom is now offering free HttpOptimizer service which monitors the performance of all your requests and also dynamically applies proper config parameters for your HTTP client (like timeouts, concurrency, cache) based on network type, location, carrier. 顺便说一句,PacketZoom现在提供免费的HttpOptimizer服务,该服务监视所有请求的性能,并根据网络类型,位置,运营商为HTTP客户端动态应用适当的配置参数(例如超时,并发,缓存)。 You also have visibility to all traffic from 3rd party SDK and how much data they consume. 您还可以查看来自第三方SDK的所有流量及其消耗的数据量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM