# Few questions

**URL:** <https://discourse.mitmproxy.org/t/few-questions/424>\
**Category:** help\
**Created:** [March 24, 2017, 12:57pm UTC](https://discourse.mitmproxy.org/t/few-questions/424 "2017-03-24T12:57:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mradr](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Mradr](https://discourse.mitmproxy.org/u/Mradr)\
**Post date:** [March 24, 2017, 12:57pm UTC](https://discourse.mitmproxy.org/t/few-questions/424/1 "2017-03-24T12:57:28Z")

</div>

Looking into using mitmproxy for a filtering script for a few locations.

I was wondering if there is a way to program mitmproxy to block images from loading on a webpage? I did look at the examples and saw one that flip images around, but I was not able to get this script to work. I have been able to get others to work and I am currently writing a new one already.

Next question would be how do I get the user\_agent? I like to know if the data traffic is coming a mobile device or a desktop computer (windows, mac, linxus, etc)

Last question, is there a way to get the IP or maybe link the flow to a connection/user so we may limit or open permissions base off the connection? We may already have a way to read the packets and pull some information off the packets to assign user permission level access, but need a way to link said information to the IP that is talking.

---

<div class="post-metadata">

**Author:** ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)\
**Post date:** [March 26, 2017, 12:48pm UTC](https://discourse.mitmproxy.org/t/few-questions/424/2 "2017-03-26T12:48:09Z")

</div>

> [@Mradr](#):
>
> I was wondering if there is a way to program mitmproxy to block images from loading on a webpage? I did look at the examples and saw one that flip images around, but I was not able to get this script to work. I have been able to get others to work and I am currently writing a new one already.

You can call `flow.kill()` on resources you want to stop from loading.

> [@Mradr](#):
>
> Next question would be how do I get the user\_agent? I like to know if the data traffic is coming a mobile device or a desktop computer (windows, mac, linxus, etc)

`flow.request.headers["user-agent"]`

> [@Mradr](#):
>
> Last question, is there a way to get the IP or maybe link the flow to a connection/user so we may limit or open permissions base off the connection? We may already have a way to read the packets and pull some information off the packets to assign user permission level access, but need a way to link said information to the IP that is talking.

You can either use the proxyauth addon (stores credentials in `flow.metadata` or take a look at the client information in ´flow.client\_conn`.

---

<div class="post-metadata">

**Author:** ![Mradr1](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mradr1/32/211_2.png) [@Mradr1](https://discourse.mitmproxy.org/u/Mradr1)\
**Post date:** [April 6, 2017, 8:09pm UTC](https://discourse.mitmproxy.org/t/few-questions/424/3 "2017-04-06T20:09:41Z")

</div>

Thank you so much! Got it all working on this part.

One more question, is there a way to add to the ignore list while on the fly? We’re making a web portal for easy access. From there, I am allowing users on the fly control of the proxy. That part is working - but not sure if you have a “safe” expose way to add items to the ignore list on the fly for example for hsts certificate pinning locations?

---

<div class="post-metadata">

**Author:** ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)\
**Post date:** [April 8, 2017, 10:17pm UTC](https://discourse.mitmproxy.org/t/few-questions/424/4 "2017-04-08T22:17:44Z")

</div>

With the next release you’ll hopefully be able to just add entries to options.ignore\_hosts, but I don’t think we expose functionality for this yet. If it doesn’t work with 3.0, you are welcome to file an issue for this on GitHub!

---

<div class="post-metadata">

**Author:** ![Mradr1](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mradr1/32/211_2.png) [@Mradr1](https://discourse.mitmproxy.org/u/Mradr1)\
**Post date:** [April 8, 2017, 10:49pm UTC](https://discourse.mitmproxy.org/t/few-questions/424/5 "2017-04-08T22:49:44Z")

</div>

Oh I see… mmm is there not a way to pass the master “self” to the -s option? From there I could just link into the self.check\_ignore option by reloading it.

---

<div class="post-metadata">

**Author:** ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)\
**Post date:** [April 8, 2017, 11:07pm UTC](https://discourse.mitmproxy.org/t/few-questions/424/6 "2017-04-08T23:07:50Z")

</div>

you are looking for `from mitmproxy.ctx import master` I think. 🙂

---

<div class="post-metadata">

**Author:** ![Mradr1](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mradr1/32/211_2.png) [@Mradr1](https://discourse.mitmproxy.org/u/Mradr1)\
**Post date:** [April 8, 2017, 11:32pm UTC](https://discourse.mitmproxy.org/t/few-questions/424/7 "2017-04-08T23:32:43Z")

</div>

> [@mhils](#):
>
> options.ignore\_hosts

Got it! Thanks so much!

---

<div class="post-metadata">

**Author:** ![Mradr1](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mradr1/32/211_2.png) [@Mradr1](https://discourse.mitmproxy.org/u/Mradr1)\
**Post date:** [April 16, 2017, 8:55am UTC](https://discourse.mitmproxy.org/t/few-questions/424/8 "2017-04-16T08:55:15Z")

</div>

Sorry xD Two more of the one more questions then I think I have everything I will ever want working:

One) How do I disable the log or redirect it?  
Two) is there a way for http.HTTPResponse.make to work with HTTPS? Or do I just have to redirect each time change the url instead?
