Defender app update (harbour-defender) - my very own ‘Sailfish Devember’

@peterleinchen I have several suggestions for the new release, would you like to hear them?

It seems I’ve messed something up and now I can’t block ads anymore (even though the list loaded successfully). Could someone help me out, please?

Edit: I fixed it in the end

I’d like to hear them :slight_smile:

Plus a counter instead of the indefinite progress. How many passed and how many remaining. Just the other day I had to once again quit updating because it had been going on for days and I had no idea where it was.

One could obtain a Content-Length header and count?

I don’t know. I surely hope so. It might have nothing to do with HTTP headers but rather the volume of sources if kept as objects.

Possibly also a noob question: I installed version 0.6 for the first time on SF 4.4. By default I see no sources at all and I don’t see a file /etc/defender.conf. Do I have to add it manually to get sources or is it a bug?

I have the same problems since the 4.4 version of the OS.
It was running fine on previous versions of the OS.

Defender is simply broken on 4.4. For more info you can check out this thread Block ads on Sailfish 4.4 Both sandboxing and other browser things have changed
New issues have been created too: Issues · peterleinchen/harbour-defender · GitHub
But Peter is not the original developer of Defender, he has been keeping it alive for some time, but if anyone could help with rewriting the Python code, it would be a massive help.


Note that only the GUI part is broken (mostly due to jailfish stuff); the service itself still works (in defender, the actual engine is separate from the GUI).

So you can manually edit / restore from backup the file .config/harbour-defender/defender.conf (warning, it will be overwritten on defender GUI’s start up).
Then touch ~/.config/harbour-defender/update to use the .path automatic trigger (this in turn will automatically call devel-su systemctl status harbour-defender.service for you).

Android will disable ads immediately if it has already been restarted after defender’s installation (so its /etc/hosts is mapped to Sailfish’ file).

Sailfish Browser will disable ads next time it is fully restarted (warning, the pre-cache might still have an older copy of /etc/hosts in cache ; you might want to kill any pre-cached instance, or restart the Silica UI or reboot the whole phone)


Out of curiosity, i’ve disabled sailjail for defender and the gui is finally working where i can select which list to apply

Except i’ve selected the youtube no ads list and i’m still having ads on that?is the list not working, or maybe defender is still somehow not working?

(yes, i’ve let the phone update the list)


Can someone provide step by step guide to get this working?After adding with editor app lines to disable sailjail and rebooting device.Then in Defender app it starts neverending update process.Over 12 hrs and still going on.Doing something wrong?


For this Defender configuration file


What do you add or input in? Do you add these ad-block list, and lines, exit and save, for example, from here?

Or ‘defender.conf’ is for something else?

And what about within this folder


Do we add ad-block lines pertaining hosts, like from here? And what we do name them?

And then we do have


What difference is between what is within ‘etc/hosts’ folder, and ‘~/.config/harbour-defender/’ folder, and ‘etc/defender.conf’ file.


1 Like

The hosts ‘file’ is local ip → name lookup table:

causes that ‘’ to reslove to local host.

I only use the hosts file. This doesn’t work with android.

It’s an .INI-like file, one section per source,
and a propertry to enable the source.

I’m using the lists “Unified by StevenBlack” and “Disconnect-me Simple” for both Ads and tracker.

So, mine looks like this:

wlanonly = no

sourceenabled = yes

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = no

sourceenabled = yes

sourceenabled = yes

sourceenabled = no
1 Like

( is an unresolvable address, not the local-host :wink: )

@X0X0 :
In the case of Defender: the deamon of defender will automatically auto-fill this file with all the necessary entries so all the etc. get similarly block.

You don’t need to edit this, Defender will do it for you based on what you’ve turned on or off in the .conf file.

In the case of Defender, it will setup an mount inside /var/lib/lxc/aliendalvik/extra_config:

lxc.mount.entry = /system/etc/hosts system/etc/hosts none bind,ro 0 0

Thus your system wide hosts file will be mounted inside the LXC container used by AlienDalvik, and it will also auto-fill that /system/etc/hosts for you, too, so that in fine ads are disabled in most apps.

(Note: this can partially break functionality of some freemium Android games. The “watch an ad to get past this check-point” or “watch an ad to earn extra diamonds/coins/whatever” will typically not work. Some games are still completeable despite this, other are utterly broken).

Two aspects to think about to get rid of ads:

  1. Making sure the list is actually used.
  2. Disabling everything inside Youtube.

Regarding 1:

  • the simplest is to just reboot Sailfish. (So you’re sure that Defender is running, and you’re sure that the browser is using the latest /etc/hosts which got generated by Defender).
  • try browsing to
    • it should fail with “Unable to connect

Regarding 2:

  • this is saddly a limitation of the tech used by Defender: limitation of hosts files.
  • host can only block the entire access to specific servers (in my test above, e.g., block access to
  • it’s much less sophisticated than uBlock or AdBlock Plus which are able to change the behaviour of the Javascript code running inside the page.
  • some ads on youtube are indeed fetched from different servers: these will be blocked by defender.
  • some ads are served by the regular servers (e.g., the player will receive a list of video segments to play, one of them is a pre-roll ad). It’s not possible with hosts to just block the ad, while at the same time still getting the rest of the videos, both from the exact same server.

Possible workarounds:

  • use a native SailfishOS youtube app, like microtube.
    • that one understands the info output by youtube and can be much clever about what is is blocking.
  • use Firefox for Android in Alien-dalvik and install uBlock Origin (unlike Chromium, android version of Firefox can supports add-ons).
  • or use Bromite in Alien-dalvik (an open-source fork of Chromium available on F-Droid) that is modified to include and run Adblock even on mobile (as mentioned the original Chromium doesn’t allow add-ons on Android).
    • uBlock and AdBlock are much more sofisticated and will be able to selectively block ads instead of blanket blocking a whole server.
1 Like

of course. mea culpa :wink: you could also make if but that’s nonsense. Thanks for the detailed outline!

I also noticed that some sites, for instance the German news magazine Spiegel, recently switched to proxy ads over their main domain. And of course, youtube. Working on that one. Still, I’m generally happy with 50K line hosts file :slight_smile:


While testing the community version of SFOS (on a Pinephone Pro) I notice a different cyclic dependency.

See issue 8.

The more recent version of (kernel and thus of) systemd available there means that systemd automatically detects and solves the dependency.
But it solves it by deactivating which is a rather basic unit.

Another difference is that the unlocking service is named differently in the Community edition.

edit: here is the PR