Love hate relationship with conan.io

Introduction

conan was supposed to finally solve the decade long issue of getting your build dependencies on Windows (and Linux but to a lesser extent because package managers have already solved that problem there).

Before that you either had to build from source or find pre-built binaries from sometimes questionable sources. Building from source is a major PITA because each dependency has different steps, requires different tooling, has it's own dependencies.. Luckily most projects have finally standardized on using CMake (or Meson) so at least we're heading in a good direction there.

When I started to get into conan my expectations were at the level of package managers I already knew: maven, which I consider the gold standard that has worked well for decades and npm, not because I consider it a great solution but because it's relatively simple to understand and use.

Before we dive into my issues with conan, I must acknowledge that vcpkg exists and is supposedly easier to use but I've never tried it so I can't comment on that.

conanfile.txt

Before you even begin you are given two choices, use a txt or a python file which is mistake number one, don't give a choice but enforce a standard. Conanfile.txt is completely useless for anything more than a hello_world.cpp and should never have existed. As soon as you want to do anything remotely useful in a real world scenario you need to use conanfile.py. You usually find that out several hours into the project and then need to rewrite your .txt to .py.

Which bring me to my next point..

conanfile.py

I think having your dependencies described as a static configuration file like pom.xml or package.json makes more sense and is safer. It enforces a certain schema and order. Instead, you can basically write full python code and shoot yourself in the foot. Yes, it is powerful but why do you need all that power? A well designed schema should cover 95% of use cases which require no dynamic scripting, and the final 5% can be solved with other means like hooks and plugins.

Also, it requires you to learn some python which I have been trying to avoid all my life, somewhat successfully so far.

conan 2.0

It is not very confidence inducing when you have a v2 which breaks heavily with v1 and relatively early in project cycle. While the changes all seem good on paper, I am yet to dabble into truly advanced stuff so from my perspective, it breaks the cli compatibility, has a ton of missing packages which will take years to port and every time I search for something on google I am getting results for v1 because of historic google bias.

conan index

Index is backlogged for months (years?), pull requests going stale and lingering, not getting merged even if they are essentially ready. Many packages which were present in v1 are still missing in v2 and this will block you from upgrading to 2.0. Check if all your dependencies are ported before you upgrade!

Github stats are showing a slightly optimistic trend in that more pull requests are resolved than open each month so hopefully there will be some backlog resolution this year. It seems there are not enough reviewers available and I am not sure what the plan is to resolve that.

Another issue I have is that many build combinations are simply missing. I am not even talking any exotic architectures here, just normal targets like Windows amd64 or x86 with the latest Visual Studio or Debian stable on the Linux side. This is without any custom options for a specific package being set. I'd say that I am building packages locally more often than getting binaries. which kind of defeats the purpose of a package manager.

At least the local builds seem to work fine most of the time and my 16 core Ryzen doesn't seem to care.

Too many ways you can integrate with CMake

In many ways when I started with v1, it felt like conan tried to be more than just a package manager but dictate how you should rework your CMake project to accommodate it into the workflow or even overlap with CMake functionality in certain areas.

2.0 promises to finally integrate with CMake without touching CMakeLists.txt or very close to that using presets. Yay!

Bizarre bugs

How can a recipe building for Windows host produce a libsomething.a but it is really just a .lib in hiding?

 

I hope I wasn't being too harsh on conan and I am hoping some of the issues will improve through time. My next goal is to try and package up some of my old libraries and go through the submission process. I am certainly not giving up on conan anytime soon.

Cen
GitHub
Eurobattle.net
Lagabuse.com
Bnetdocs

Hogwarts Legacy quick review

I would never expect a game such as this to be anything nearly as good as it actually is.

I would put it in a category of games such as Witcher, Mass Effect and Skyrim, but  one level below these legendary games overall. Being a fan of Harry Potter universe helps a lot to enjoy this game..

 

8/10

Potentially heavy spoilers below.

The good:

  • Great graphics overall.
  • Cloth graphics and physics look great, relic robes look incredible.
  • Hogwarts is a 1:1 replica of the movie set, you can see the effort put into it.
  • The map overall is well designed and true open world.
  • The plot overall is interesting enough.
  • Soundtrack is good, not Skyrim or Witcher level good but I could recall at least 2 themes and that's an achievement.
  • Combat is balanced and at times challenging.
  • Niamh trial quest.
  • Having a completely open world game and allowing you to fly almost anywhere is daring and it just works.
  • Not really a fan of puzzles but accio trials are decent enough.

The meh:

  • The whole southern coast seems unnecessary. Also, giving you a powerful mount just before the game ends is kind of pointless.
  • Merlin trials and gear slots are a complete bore fest and grind. Am I supposed to be enjoying that? Reduce the trials in half and I could accept it.
  • Demiguise Statue quest.. ugh.
  • Natsai quest line is uninspiring and fades in comparison with the Sebastian quest line.
  • Anne story line is unresolved even though there are two big directions we could end up going. The relic plot line is completely derailed without being able to do anything about it and the option to use ancient magic is never explored even though it is hinted at heavily through the Isidora story. That could be a major decision left on the player but we are never given the opportunity. There is even a third way when we discover that Rookwood was responsible but nothing happens with his death.. the curse does not go away. You could be given a choice to not kill him or to torture him to release the curse etc.. I am just making things up in the heat of the moment but there are many options left on the table.
  • Ancient magic trials are quite boring.
  • About 10 hours too long.
  • The whole room of requirement is quite an achievement but unless you are a die hard fan of the game the whole thing could be easily cut without much loss, perhaps a step too far.
  • Rookwood and Harlow are not really built up as villains properly. They are impersonal and in some of the early missions we don't even encounter them (castle escape for example). Rookwood has a possibility of a redemption but we are never given the choice.
  • Black does nothing all game except for being the designated  idiot.

The bad:

  • Alohomora mini game is a complete waste of time. At least lockpicking in Skyrim requires some skill.
  • Player's character has no backstory. All we know is that we are a very talented student and that's about it, we just drop out of the sky. No family background, no prior event recalls, nothing. In Mass Effect for example, you could pick your background and it would be recalled in conversation from time to time, making the character more real.
  • Player's character has no personality, mostly because our dialog choices do not really matter and most choices are between neutral good to neutral evil. It would benefit from some Mass Effect level of choices and commander Shepard's sass level.
  • No romance options. Movies and books are quite heavy on relationships and this is missing. It would only take a few extra dialog options and scenes.
Cen
GitHub
Eurobattle.net
Lagabuse.com
Bnetdocs

Protecting your vBulletin 4 registration against spambots with email domain whitelist

If you are still hosting a vBulletin 4 forum for whatever the reason may be, you are probably experiencing the spambot hell. Captcha plugins are out of date or simply bypassed and protections like human verification questions just do not seem to work. You could throw Cloudflare in front for some bot detection and that is probably a good idea.

I observed that the major hole in arresting the bots from even registering is the use of various random domains and subdomains in their emails. You do have an email banlist option in Admin CP but that really does not cut it because there is no support for regex and there are infinite domains to block. An email whitelist would be much better because you then force the spammers to create email accounts at major email providers like gmail and outlook which slows them down.

That will block legitimate users who use personal email domains but that is usually a small minority that can be handled on case by case basis. It depends on your use case if you can accept that.

There are no email whitelist plugins out there so I decided to just dig into the vBulletin code and hardcode it.. how hard can it be? Turns out it's easy.

The function that handles the email ban list can be found under the name is_banned_email in a includes/functions_user.php.

Right before the return statement, we can hardcode our email domain whitelist as an additional protection:

// custom addition: email whitelist
$email_domain_whitelist = [
    /* Default domains included */
    "aol.com", "att.net", "facebook.com", "gmail.com", "gmx.com", "googlemail.com",
    "google.com", "hotmail.com", "hotmail.co.uk", "mac.com", "me.com", "mail.com", "msn.com",
    "live.com", "sbcglobal.net", "verizon.net",

    /* Other global domains */
    "email.com", "games.com" /* AOL */, "hush.com", "hushmail.com", "icloud.com", "inbox.com",
    "lavabit.com", "love.com" /* AOL */, "outlook.com", "pobox.com", "rocketmail.com" /* Yahoo */,
    "safe-mail.net", "wow.com" /* AOL */, "ygm.com" /* AOL */, "ymail.com" /* Yahoo */, "zoho.com", "fastmail.fm",
    "yandex.com","iname.com",

    /* United States ISP domains */
    "bellsouth.net", "charter.net", "comcast.net", "cox.net", "earthlink.net", "juno.com",

    /* British ISP domains */
    "btinternet.com", "virginmedia.com", "blueyonder.co.uk", "freeserve.co.uk", "live.co.uk",
    "ntlworld.com", "o2.co.uk", "orange.net", "sky.com", "talktalk.co.uk", "tiscali.co.uk",
    "virgin.net", "wanadoo.co.uk", "bt.com",

    /* Domains used in Asia */
    "sina.com", "qq.com", "naver.com", "hanmail.net", "daum.net", "nate.com",

    /* French ISP domains */
    "hotmail.fr", "live.fr", "laposte.net", "wanadoo.fr", "orange.fr", "gmx.fr", "sfr.fr", "neuf.fr", "free.fr",

    /* German ISP domains */
    "gmx.de", "hotmail.de", "live.de", "online.de", "t-online.de" /* T-Mobile */, "web.de",

    /* Russian ISP domains */
    "mail.ru", "rambler.ru", "yandex.ru", "ya.ru", "list.ru",

    /* Domains used in Brazil */
    "hotmail.com.br", "outlook.com.br", "uol.com.br", "bol.com.br", "terra.com.br", "ig.com.br", 
    "itelefonica.com.br", "r7.com", "zipmail.com.br", "globo.com", "globomail.com", "oi.com.br",
    
    /* personal domains */
    "czech.click"
];

$emailParts = explode('@', $email);

if (count($emailParts) === 2) {
    $domain = $emailParts[1];
    if (!in_array($domain, $email_domain_whitelist)) {
        return 1;
    }
}

Cen
GitHub
Eurobattle.net
Lagabuse.com
Bnetdocs

Automatically resize cloud VM filesystem when disk size increases on Linux

One of the good things that cloud brings is that you can easily increase size of your VM disks as they fill up. Unfortunately the process is a bit manual because you also need to resize your filesystem in order to see the change. GCP has this process documented.

We can automate this with a udev rule. This was tested on GCP and Ubuntu 20.04 with ext4.

Add a new rule, for example in

/usr/lib/udev/rules.d/34-resize-filesystem.rules

add

SUBSYSTEM=="block", ENV{RESIZE}=="1", ACTION=="change", RUN+="/bin/sh -c 'resize2fs /dev/$name'"

Followed by

udevadm control --reload-rules

This rule listens for change events in block device subsystem and filters by the RESIZE property. If conditions are met, it will adjust your filesystem to use the rest of the free space.

You can make the udev rule more specific to target only sdb or sdc for example. I could not find a good documentation on udev rules that would explain exactly which event properties need to use the == selector (for example SUBSYSTEM), which are considered ENV (supposedly these are any custom properties) and which should use an ATTRS filter.

The property could possibly differ depending on OS and cloud provider, so before adding the rule, you can listen for the events and see the full event output while you change the disk size with

udevadm monitor --udev --property --subsystem-match=block
Cen
GitHub
Eurobattle.net
Lagabuse.com
Bnetdocs

Using extra mouse buttons to quickly switch to a task in KDE

I had a bright idea to use my extra 2 mouse buttons to quickly switch to a task in Debian KDE, for example to terminal or browser. Since the mouse is in the palm of your hand most of the time this is quite a bit faster than actually clicking on a task or hitting a key combo on your keyboard.

I started by pinning Konsole and Firefox to taskbar positions 1 and 2 and then went to

System Settings -> Shortcuts -> Plasma -> Activate Task Manager entry 1

Shortcuts like Meta+1, Meta+2 etc already exists so I thought I can simply add an alternative shortcut. Unfortunately, this configurator does not detect the mouse buttons (nothing happens if you click and key is not recorded).

Fortunately, KDE also has a nice feature in your Mouse settings to remap the extra buttons to anything you like in

System Settings -> Input devices -> Mouse -> Re-Bind Additional Mouse Buttons

In there, I simply assigned one button to Meta+1 and the other button to Meta+2. I can see plenty of other useful possibilities like mapping the button to shift through different windows of a task etc.

The mouse I use is Roccat KONE Aimo which also has a third button labeled T3 (and a plus/minus buttons which are bound for DPI sensitivity by default) but T3 does not get picked up by the configurator even after disabling EasyShift (which basically remaps the whole mouse when pressed so all the buttons can have a different function temporarily). The surprising thing is that if I map that button to some functionality like Browser Home (in Windows Roccat driver) it does actually work in a Linux Browser, so I am not sure why KDE Mouse configuratior does not detect this button.

 

Update: I found an alternative way of doing this which also enables T3. On Windows, using the Roccat driver software, assign each mouse button a shortcut. Try to find something that is not used by anything. I ended up with something like alt+ctrl+Page Up/Down/End.

Then in KDE shortcuts, assign an alternative to Meta+1 by clicking the button. This time, the button is recorded as the assigned shortcut.

Cen
GitHub
Eurobattle.net
Lagabuse.com
Bnetdocs

Divide and Conquer, Medieval II: Total War mod (DaC) experience

Divide and Conquer is a Medieval II: Total War Kingdoms mod in Lord of the Rings setting. Technically a "sub" mod of Third Age: Total War, but at this point it is fair to say it is a mod on it's own since it greatly imroves and expands almost every aspect of TaTW.

I have finished TaTW campaign 3 times before so when the nostalgia kicked in again I decided to give DAC a try.

Setup

Version: 4.6.7
Difficulty: hard (I personally find the "very hard" setting just a grind with no added value in this case, hard is plenty of a challenge)
Faction: Rohan
Style of play: try to follow the lore

Rohan Campaign playthrough – the beginning

I chose Rohan since I've already done High Elves, Dwarves and Gondor in TaTW. Events described here are as they unfolded in my playthrough but there can be major differences depending on faction politics.

You begin with a handful of known generals such as Theoden, Theodred, Eomer, Hama, Gamling and others. Your initial campaign will revolve entirely around defending and defeating Isengard which will attack almost immediatelly. You need to send all your available armies to Westfold (Foldburg) and defend it at all cost. Losing the region will set you back tens of turns so try to hold out. Place two general units since they are overpowered. You can do a bit of research on the side but most of your spending will go to replenishing the armies to defend wave after wave of attacks. Eventually Saruman himself may lead a siege and by killing Saruman the whole Isengard will fold into rebel territory.

In every captured settlement, the number one building you should always upgrade first is culture and then masonry. You need to convert non-native culture to your own and that takes tens of turns so you want to speed that up as much as possible.

You then proceed to expand further west and defeat the Dunlendings.

You should probably forge an alliance with Clans of Enedwaith to get some help here and secure your west border for the rest of the campaign. Create trade agreements with all the neighbouring nations, even some of the dark forces are acceptable in the beginning when you need to build up your income.

The next natural progression is to go further into the Misty Mountains and defeat the goblins there. At this point Moria will probably be divided so you can gift West Moria back to Dwarves of Khazad Dum and forge an alliance.

Building up your income

Depending on how other factions are progressing, you will probably have the whole west border secured with Enedwaith, Dunedain and High Elves at your borders (forge alliances if possible). This is still not big enough region for sufficient income so you can skip over High Elves and continue your conquest on Remnants of Angmar. Another possibility is to take Dol Guldur which is relatively easy to take but has a slightly negative position. First, if you retake any settlement which belonged to Woodland Realm you should gift it back or they might think about reclaiming it by declaring war on you. The second negative is that you get a likely border with Easterlings. If you take Dol Guldur, take the 2-3 cities inside the safety of forests and do not expand further east, except maybe for one single stronghold (with ballista towers). Having a major war with Easterlings is the absolute number one mistake as it drains a lot of your resources and you will make almost no advances into their vast no-choke point territories.

To War!!!

This far into the game Gondor can start having trouble defending itself so with sufficient income from your expansion you should be able to finance war against Mordor. You still have expansion options on the north to Snow Orcs or Ered Luin (which choose the dark side in an early Blue Wizard event) but if Gondor is getting in trouble you should not wait any longer.

I personally was a bit late and Minas Tirith already fell so I had to re-conquer it which is an unnecessary delay.

You won't be able to resist the urge to recreate the scene

War against Mordor is pretty much the same with whatever faction you are playing, except maybe Dale and Dwarves of Erebor (which can backdoor into Mordor from the east). It is all about creating choke points and progressing eastwards settlement by settlement.

I happened to get some Gondor AI reinforcements which felt nice. Allied forces will join you if they are nearby or call you to help mid-turn

Let's focus on the campaign map around Minas Tirith for a bit.

It is all about the choke points

As you arrive to the east, you should take Galebrin (not seen on the picture, region north of Cair Andros) which is a small useless village in the The Dead Marshes and give it to an ally or a neutral faction as a gift. This will block Easterlings or Mordor advancing on your native land across Anduin which is a total waste of time and a distraction so it is an utmost priority to seal that off.

You should also take Calenhad because you want as many cities as possible on the east to develop your armies closer to the war front. Training armies in Rohan and moving them to Gondor takes many turns and is inefficient. If Calenhad is still owned by Gondor when you arrive you can easily swap it with any region you recapture or just buy it off if finance allows it.

Next one is Cair Andros which you also do not really want to own because it creates a secondary target to Osgiliath. Once you take whole Osgiliath, Cair Andros can probably be owned by Gondor since Mordor will have full focus on you and not even attack there. If it is still attacked and falls when owned by Gondor, gift it to a neutral party.

Leave Minas Tirith to Gondor. It does not make much sense tactically but if you are into lore it makes sense to do that. It also leaves them some good income to fight their own wars.

Osgiliath is your primary choke point for quite a lot of turns but is relatively easy to defend because the battle map is hard to navigate and has narrow paths.

A single bridge leads to East Osgiliath

This setup makes Osgiliath the only route you need to defend. Once Osgiliath gets army production, you can continue on Minas Morgul. You continue this step by step progression, waiting for conquered cities to be able to produce army and then take the next one.

How insanely good modding is that?? Siege of Minas Morgul
Glitching up the mountain for an epic view of Minas Morgul

At some point after Minas Morgul and Cirith Ungol you can capture the two cities to the south for extra production. You can gift the settlement below Ostithil to Gondor or neutral party to avoid a second front with Haradrim.

When Gondor is safe from Mordor they will start thriving and go into big expansion into Harad and Rhun. You don't really need to worry about those two factions unless you arrive late and they already progress deep into south Gondor regions.

With Rohan taking the brunt of the Mordor forces, Gondor is free to take care of their southern borders and go on a war path

Once you have Minas Morgul (and Cirith Ungol) you might feel a bit exposed because you will also get attacked from the Black gate, usually on Osgiliath. You can take a bit of a rest by gifting Cirith Ungol to a neutral party but that might not last long since Mordor tends to attack them anyway and this can last just a few turns. Depending on diplomatic relations you could buy yourself quite a bit of time like this though.

The question of taking Barad Dur is just a matter of time then. Being this close has an annoying effect that each defeated Nazgul commander respawns in Barad Dur and is ready for another siege in a very short time, so you are almost constantly defending against 10 star commanders. You should defend with equally strong commanders to avoid any unnecessary fleeing troops.

You may also encounter Sauron as a commander. As a unit almost impossible to kill, unless you get a catapult kill, but defeating his army will send him fleeing and weaken the faction.

Sauron Encounter

Once you start taking cities inside Mordor it gets increasingly easier to finish it off.

Final Assault
Siege of Barad Dur, get those catapults!

Once a faction is on their last stand, the capital will be filled up with army and can be pretty hard to conquer, especially if it is not an open type terrain like dwarven caves. Barad Dur is basically one small tunnel with only two access points. Bringing catapults to fire directly into the tunnel slope is a must or you will simply run out of time even with enough units in battle. You simply can't kill 3700+ units, a lot of them of heavy type, encamped in such a small area before the clock runs out.

Incredible views

What could go wrong?

Gifting regions to neutral parties works for some time but eventually everyone is at war with Mordor. These can buy you a lot of turns of peace or Mordor might just attack them immediatelly. Depending on your luck, you could start getting attacked by Mordor or Easterlings through Dead Marshes on your core territory where you have your main production and mostly undefended cities.

Another possible drain is attacking Snow Orcs or Ered Luin when you are already neck deep into eastern war. Your northern production takes quite some time to get up to speed and these two factions are holed up in dwarven caves which are hard to capture.

Beautiful dwarven battle maps

You essentially need full armies and catapults to have any chances to break through heavy units in time.

These are a PITA to capture

Rohan in itself is not a particularly powerful faction when it comes to units. You have almost no heavy infantry except Guards of Meduseld which can only be produced in Edoras. Your heavy cavalry is good but not much better than any other heavy cavalry and your archers are poor. In these cave scenarios, you have no advantages. The whole unit production of DAC is very slow, you need many fully upgraded settlements just to be able to retrain damaged armies every turn. A lot of times you won't be able to retrain due to lack of unit availability and you need to send units to far away settlements.

Gondor inflicting maximum pain

Finally, the biggest problem is how to avoid a major war with Easterlings. If you expand into Dol Guldur you get a border sooner or later (Dale tends to be pushed back). You can usually defend there with fully upgraded walls (ballista towers). You can potentially conquer one of their strongholds nearby and have it as a gravity point. Ballista towers can generally clear their armies a lot before they even break through the walls so defending is quite easy but it is problematic to replenish the defending army in the period when settlement can not yet produce units. You should absolutely not push deeper into their territory while you are fighting Mordor, they will push you back and probably crush you. By staying in close proximity you drain a bit of their resources and help Dale not getting eradicated this way.

Easterlings are basically an overpowered version of Rohan. Their cavalry is on par, archers are better and they have more heavy units so you have no particular advantages over them in battles.

After end

You can have some more fun after bringing down Barad Dur. I personally finished up on the east and then defeated Ered Luin for a good measure.

Ered Luin Resolve

Weird things can also happen with other factions. In my case, Dwarves of Khazad Dum went on a war path and completely eradicated Lothlorien and the Vale, leaving dozens of armies on my borders. If you don't watch your relationships (like trespassing without Military Access) you get yourself an enemy you can't handle.

Dwarves overpowered Lothlorien and Vale of Anduin, leaving dozens of armies

Game event dialogs

Throughout the campaign you get events and commander traits as you conquer important settlements. Your commander will receive a title of the last big conquest or generic title such as Aggressive or Defender, depending if they are conquering regions or defending a lot. This attention to detail is incredible.

Theodred conquers Dol Guldur

These events with very nice descriptions make the campaign feel alive.

Morannon broken

As factions are near destruction or completely destroyed you also get these.

For Frodo!!!
Ered Luin Dwindles

Trait Descriptions

Trait descriptions are LOTR based and absolutely brilliant. Some samples below.

Eomer Command
Glorfindel Renown
Eomer Loyalty
Theoden Acumen

Soundtrack

Soundtrack is absolutely brilliant. It includes LOTR movies soundtrack, The Hobbit trilogy soundtrack, LOTR Online, Battle of Middle Earth and many more for different factions. The best of all, almost all of the picked themes work nicely with the battle scenarios and campaign map, as if they were custom made just for this mod and they really give you that Middle Earth feeling while playing.

Someone made a playlist on YouTube.

 

All we have to decide is what to do with the time that is given us..

DAC is one of the best mods I played in my life and is everything a Total War and a LOTR fan could wish for. The soundtrack, attention to detail, city models and the campaign maps, everything just screams of incredible effort to make this mod as good as it is. If you haven't yet, give it a try.

Cen
GitHub
Eurobattle.net
Lagabuse.com
Bnetdocs

Building Qt 5.15 on Windows with OpenSSL

I have written about the many problems of building Qt 5 with OpenSSL in the past. Several years later, it is time to upgrade to latest Qt 5.15 which is presumably the last in the Qt 5 series. This time I decided to drop the Windows XP support since it is just too much work to get working and XP market share is much lower today than it was 5 years ago.

Since the Qt build documentation is still lacking here is the latest text of the ordeal.

First thing first, install Strawberry Perl and Python 2 (yeah.. really).

For speedier builds, also install jom. We will also need vcpkg to get the OpenSSL binaries. Needless to say, all these tools need to be in your system PATH.

Now get the code:

git clone git://code.qt.io/qt/qt5.git
cd qt5
git checkout v5.15
perl init-repository

I think you can tell the init-repository script to not download some of the modules you don't need (it pulls 12GB of data!) but I couldn't be bothered to find the flags for that. You can probably avoid it by downloading the source archive instead of doing it via git.

Today we finally have the C/C++ package managers available to not bother bulding the dependencies anymore. Vcpkg and conan are both great tools that do the job. So forget about building OpenSSL, just install the binaries with vcpkg:

./vcpkg.exe install openssl

In your user env, add

OPENSSL_LIBS=-llibssl -llibcrypto

Now we can run the configure script inside the qt5 folder. First we do a release build and we link to openssl (run in Visual Studio cmd):

.\configure.bat -v -release -opensource -nomake examples -opengl desktop -platform win32-msvc2015 -openssl -openssl-linked -I C:/Users/me/git/vcpkg/installed/x86-windows/include -L C:/Users/me/git/vcpkg/installed/x86-windows/lib

Change the location of OpenSSL include and lib folders to whatever your vcpkg installation directory is. I am still targeting msvc2015 for now but I plan to transition to 2019 eventually.

If you change around the configure parameters, make sure to delete config.cache file since in my experience it likes to save unwanted information from previous runs.

Build it with jom:

jom
jom install

Now you have a release build and you can add it in Qt Creator under Tools->Options->Qt Versions by giving it the path to C:\Qt\Qt-5.15.1\bin\qmake.exe.

If you also need debug build of Qt, you can repeat the configure and build step by replacing -release flag with -debug (remember to delete config.cache first).

An there you have it.. Qt built from source with OpenSSL support. Once you build your program you will also have to copy all the relavant .dll files into the .exe build directory (Qt5Core.dll, Qt5Gui.dll, Qt5Network.dll…). The amount of libraries you need to copy depends on what you are actually using in your code. You will also need to copy libcrypto-1_1.dll and libssl-1_1.dll from the vcpkg install directory.

For debug builds you need to copy the debug libraries (Qt5Cored.dll) instead.

The future appears to be even brighter now that bincrafters have packaged Qt as a conan recipe. Which means the next time I need to depend on Qt, I will run a single conan command and get the proper build automagically delivered to my PC along with all the transitive dependencies. The future is now.

 

 

Cen
GitHub
Eurobattle.net
Lagabuse.com
Bnetdocs

An OpenSprinkler success story

I wanted to automate the watering system at home preferably using open-source and DIY systems. The initial plan was to go with plain RPi, OpenHAB and some GPIO code driving the sprinkler valves but the problem was creating a useful UI to control the system since OpenHAB is too clunky and generic looking. I was also not quite ready diving deep into embedded programming and OpenHAB programming model. OpenSprinkler  seemed to have everything I needed, a RPi hat with all the correct electrical outputs and an open source firmware and android app I could modify myself if needed. In the end, programming the sequences myself and trying to make a decent UI would be just too much work for a small pet project so I went with a ready solution.

The requirements

  1. Three separate zones around the house, max 7 sprinklers per zone.
  2. Each zone must be turned on separately due to the pressure requirement for the sprinklers to work.
  3. Pump that drives the water must be turned on automatically with each zone valve.

Setting up the OSPi

OpenSprinkler offers fully assembled systems but I decided to go the DYI route using my own RPi and just buying the OSPi hat.

  • RPi 4 Model B 2GB
  • RPi official charger
  • OSPi (VAC)
  • 32GB SD card
  • Orbit 57056 2-Pin European Transformer

Finding a 24VAC power supply with EU plug was quite a challenge, the listed model from Orbit was one of the rare ones I could find online (on Amazon).

It is mentioned in OpenSprinkler documentation that a separate power supply for RPi is recommended. This was confirmed while testing where I saw dmesg errors about voltage not being sufficient and RPi rebooting endlessly. I ended up using the official RPi charger and the 24VAC charger at the same time.

Installing raspbian and OSPi firmware was easy with no problems encountered. Assembling the OSPi was also not problematic, other than drilling some holes into the supplied enclosure for the USB cable and WiFi adapter.

The WiFi

The built in WiFi on RPi would not work even half of the required distance and was simply horrendous. Onboard WiFi can be disabled by modifying /boot/config.txt and adding

dtoverlay=disable-wifi
in the [all] section.

After checking compatibility lists and reviews for RPi compatible USB WiFi adapters I went with Edimax EW-7811UN. I disabled the integrated card and configured the /boot/wpa_supplicant.conf to connect to the dedicated WiFi extender AP as a priority.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
 ssid="Home_Ext"
 psk="pass"
 id_str="ext1"
 priority=5
}


network={
 ssid="Home"
 psk="pass"
 id_str="main"
 priority=10
}

In the end I managed to achieve a not so great but stable signal from the house to controller box at around -60db. For the WiFi extender I went super cheap using TP-LINK TL-WR840N (15EUR) and positioning it with no walls blocking the signal other than a single garage door. I also added a small script to sudo cron to automatically restart RPi in case of any network downtime.

ping -c4 192.168.1.1 > /dev/null

if [ $? != 0 ]
then
  sudo /sbin/shutdown -r now
else
  echo $(date) "Internet is UP"
fi

Driving the Pump

Looking for a relay to turn the pump on and off I decided to go with an off delay relay as an extra safety that will automatically turn off after the selected period of time. This is just in case OSPi goes haywire and does not turn off as scheduled or someone makes a mistake of turning the sprinklers on for too long. Pump draining all the water and running dry is a very bad scenario I would like to avoid. The model is a Tracon multifunction relay AC/DC 12-240V driven by 24VAC OSPi.

Putting it together

Relay is connected to OSPi port 0 (master zone) which is always turned on with either valve 1, 2 or 3. Relay drives the first power socket for the pump. The other two sockets are for Orbit 24VAC and RPi charger. This way the pump can be disconnected at any time and used manually.

The valves

24VAC valves are quite common. I found three candidates from Orbit, Rainbird and Cleber. In the end it came down to price and availability, so I went with 3x Rainbird CP075 off eBay, roughly 30$ each.

Finally, to connect the valves to OSPi I got some 4×0.75mm cable and some waterproof clips to connect them on the valve side. These are automatic clips put in a box full of gel which seals it when closed.

Operation and conclusion

It turns out the OSPi firmware and app has the exact functions I need to drive the setup. Master zone translates perfectly into the pump relay. For each valve, the "continuous" setting (which is default) allows you to setup a single schedule program and OSPi will automatically drive each valve one after another and not all at once (which would not work due to low pressure). Without the continuous setting one would have to write a separate program for each valve which is a bit clunky.

One thing that does not work quite as good is automatic rain delay. The idea is, if sprinklers are scheduled to work today but there is a rain forecast, delay the program for some time, like a day. Unfortunately, if it does not rain at all, delay is still present. It would appear that OSPi only checks the forecasts but does not adjust the delay according to actual mm of rain that has fallen. I need to research this function in more depth to figure out the exact behavior and whether I can improve upon it.

Another glitch that appears once a month or so is that OSPi is randomly not accessible. This is fixed with the main router reboot. I am not sure yet what exactly causes the problem, whether the auto-reboot script works.. more investigation is needed. It probably boils down to not so great WiFi connection.

In the end I am quite happy I went with the OpenSprinkler and not a full DIY solution. It saved time, does everything I require and I am able to modify it if ever needed.

 

2023 update

After the system being dormant through winter of 2022/2023, the RPi would no longer boot. The Sandisk Ultra SD card seems to have got corrupted for some reason so I had to re-image and reconfigure OSPI again. I replaced the card with a Sandisk Industrial series card which are supposedly more tolerant to heat and cold. We'll see how long this one lasts.

Other than that the system is still working great.

Cen
GitHub
Eurobattle.net
Lagabuse.com
Bnetdocs

Debugging Laravel in Eclipse PDT

I don't use PHP enough to justify buying a PHPStorm license so I am using Eclipse PDT instead. I am a bit rusty with Eclipse and PHP so I couldn't really find anything on Google about debugging Laravel projects in Eclipse. Finally figured it out, here is how.

Examples are done on Eclipse IDE Version: 2019-12 (4.14.0).

First, configure XDebug with Eclipse. On Fedora you can install it via

sudo dnf install php-xdebug

Check that XDebug remote is enabled with phpinfo() test site, if not add the following line to your php.ini:

xdebug.remote_enable = 1

Now in Eclipse, we first add a server. In Window->Preferences->PHP->Servers add a new server like this:

Document root is our Laravel public folder and base URL is the default host and port of

php artisan serve

Now check your Debug settings in PHP->Debug, select the newly created server and check that XDebug is set as the debugger:

If XDebug is not present here, configure it under PHP->Debug->Debuggers first.

Finally, under General->Web Browser, we select an external web browser to launch our website instead of integrated Eclipse Browser.

We are done with Preferences so close it. Next to the Debug button in main Eclipse toolbar, click on the arrow for the dropdown and select Debug configurations…

Create a new PHP Web Application config like this.

We point the file to public index and map it to root URL (default by artisan serve). Under Debugger tab check that XDebug is selected.

Now go to the terminal and serve your laravel app as you would with

php artisan serve

Finally, run the "web" Debug configuration from Eclipse. Eclipse should go into the Debug mode and open up your site in your selected browser. You can now place your breakpoints in controllers or wherever and things just work like you would expect.

Cen
GitHub
Eurobattle.net
Lagabuse.com
Bnetdocs

Apache http to https redirect – use 307

Who knew that a simple thing like HTTP redirects would be so complicated? It turns out clients will just change POST to GET on 301 (Postman, curl, everyone?), same with 302 which really behaves like 303 and that is also an old implementation "bug". Yeah, seriously.

If you have a REST API with POST (or other non-GET) request endpoints (who doesn't?) this behaviour will completely destroy everything.  Many guides (top google results) out there for configuring Apache redirect do not mention this problem. The code of choice would be 308 Permanent Redirect but that is fairly new so I would not risk it, older clients don't know it exists. The only thing left is 307 which does not allow changing methods on redirect – exactly how it should be.

Solution:

<VirtualHost *:80>
    ServerName example.com
    Redirect 307 / https://example.com/
</VirtualHost>

 

Cen
GitHub
Eurobattle.net
Lagabuse.com
Bnetdocs