我正在开发类似于 banatag 的服务。在新功能开发过程中,我发现了 Gmail 无法解释的行为(正如我所想)。
我将尝试在图片中解释我的问题:
通过 URL 将其添加到电子邮件中。图片地址http://eggplant-tag.appspot.com/request?FT1R3WECWNTM2ZGUDXRMA8VOXJ4F6TI4
什么要求这张图片(标签)? 我看到两种可能性:
页面向我的服务发出 AJAX 请求,这就是我看到我的 IP 的原因。但在这种情况下,为什么我在 Developer Console 的 Network 选项卡中看不到此请求?
Google Image Proxy 服务请求我的服务,但为什么在这种情况下请求中有我的 IP?
我的IP:
[更新] 将处理请求的类的一部分添加到 image(tag):
...
request.remoteAddress = str(self.request.remote_addr)# save remote address
request.put()
...
self.response.write(simpleImageData) #write to body binary data of 1x1 transparent image
self.response.headers[ 'Content-Type' ] = 'image/png'
self.response.headers[ 'Cache-Control' ] = 'no-cache, no-store, must-revalidate'
self.response.headers[ 'Pragma' ] = 'no-cache'
self.response.headers[ 'Expires' ] = '0'
[更新 2]
我使用 wireshark 找到了对我的服务的请求,但没有任何请求。这就是为什么主要问题是 Google 用户内容如何模拟我的 IP 地址?
最佳答案
Google Image Proxy 的工作原理已在网络上进行了彻底分析,例如 https://litmus.com/blog/gmail-adds-image-caching-what-you-need-to-know和 https://blog.filippo.io/how-the-new-gmail-image-proxy-works-and-what-this-means-for-you/ -- googleusercontent 站点是 GIP 使用的缓存/cdn(除其他外)。
Google App Engine 的唯一相关性可能是您如何配置您没有向我们展示的 app.yaml
,即该图像是作为静态文件提供的,还是通过逻辑提供的在您的应用程序代码中——如果是后者,您的代码在提供图像时是否有任何日志记录调用。根据您显示的有限数据,我猜想是前者(因此文件存在于 Google 的静态文件服务器上并由其提供服务,而不是在您自己的实例上的应用程序代码旁边),这将消除任何神秘感......
关于python - Gmail 是如何做到的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34770630/