# Inline script loaded several times with mitmproxy/mitmdump log option

**URL:** https://discourse.mitmproxy.org/t/inline-script-loaded-several-times-with-mitmproxy-mitmdump-log-option/238
**Category:** help
**Created:** [November 18, 2016, 9:57pm UTC](https://discourse.mitmproxy.org/t/inline-script-loaded-several-times-with-mitmproxy-mitmdump-log-option/238 "2016-11-18T21:57:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![phackt](https://avatars.discourse-cdn.com/v4/letter/p/bc79bd/32.png) [@phackt](https://discourse.mitmproxy.org/u/phackt)
#### Post date: [November 18, 2016, 9:57pm UTC](https://discourse.mitmproxy.org/t/inline-script-loaded-several-times-with-mitmproxy-mitmdump-log-option/238/1 "2016-11-18T21:57:05Z")

</div>

Hello, i’m facing an issue with mitmproxy/mitmdump v0.18.1 and v0.18.2 (everything was working fine with v0.17.1).

When you run this command:  
`mitmproxy --script ./sslstrip.py --eventlog`

You surf on [http://www.ameli.fr](http://www.ameli.fr), click on “Mon compte ameli”, the page is well displayed (stripping has been well done)

Now run:  
`mitmproxy --script ./sslstrip.py --eventlog -a test.log`  
You surf on [http://www.ameli.fr](http://www.ameli.fr), click on “Mon compte ameli”, we have a HttpReadDisconnect(‘Server disconnected’,) issue because the script sslstrip.py is reloaded, so the variable secure\_hosts is reinitialized (empty).

So this behavior happens only when mitmproxy (or mitmdump) is writing to file. This issue has been reproduced with the flowwriter.py inline script too in addition to sslstrip.py.

I created an issue for that [https://github.com/mitmproxy/mitmproxy/issues/1750](https://github.com/mitmproxy/mitmproxy/issues/1750), so any help should be appreciated or if this behavior has already been identified ?

**EDIT**

**Seems things are working with git master v0.19**

Thanks in advance,

---

<div class="post-metadata">

### Author: ![netadair](https://avatars.discourse-cdn.com/v4/letter/n/b77776/32.png) [@netadair](https://discourse.mitmproxy.org/u/netadair)
#### Post date: [December 9, 2016, 8:06pm UTC](https://discourse.mitmproxy.org/t/inline-script-loaded-several-times-with-mitmproxy-mitmdump-log-option/238/2 "2016-12-09T20:06:40Z")

</div>

Hi,

this reloading comes from the fact that the script and the log output reside in the same directory. The change of a file in the directory triggers the script reloading.

BR  
Michael

---

<div class="post-metadata">

### Author: ![phackt](https://avatars.discourse-cdn.com/v4/letter/p/bc79bd/32.png) [@phackt](https://discourse.mitmproxy.org/u/phackt)
#### Post date: [December 9, 2016, 9:17pm UTC](https://discourse.mitmproxy.org/t/inline-script-loaded-several-times-with-mitmproxy-mitmdump-log-option/238/3 "2016-12-09T21:17:14Z")

</div>

Hello Michael,

Thanks for your answer, it seems that i do not have this issue with git master (v0.19). it’s quite weird to reload every scripts due to a directory update. By the way i changed my directories structure.

Cheers,

---

<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: [December 12, 2016, 5:18pm UTC](https://discourse.mitmproxy.org/t/inline-script-loaded-several-times-with-mitmproxy-mitmdump-log-option/238/4 "2016-12-12T17:18:35Z")

</div>

Yes, sorry about the current behaviour - it is not quite optimal in some cases. We plan to change it to reload on changes to \*.py files only:

> <https://github.com/mitmproxy/mitmproxy/issues/1828>
>
> Hi folks,
> I upgraded my local mitmproxy using pip from 0.17 to 0.18.2 and now my script does not work anymore. The...

---

<div class="post-metadata">

### Author: ![phackt](https://avatars.discourse-cdn.com/v4/letter/p/bc79bd/32.png) [@phackt](https://discourse.mitmproxy.org/u/phackt)
#### Post date: [December 12, 2016, 6:40pm UTC](https://discourse.mitmproxy.org/t/inline-script-loaded-several-times-with-mitmproxy-mitmdump-log-option/238/5 "2016-12-12T18:40:47Z")

</div>

OK great thanks Maximilian
