Skip to content

Conversation

@enoch85
Copy link
Member

@enoch85 enoch85 commented Sep 12, 2024

@szaimen GeoIP is your implementation, but it doesn't automatically fetch latest geofile. To solve that, I made this.

I found that https://www.miyuru.lk/geoiplegacy actually posts the month and year it's been updated, so I thought that we could scrape that info with curl, and then compare with the current file on the system - and that's what this change does.

Please give your opinion. Maybe there's a smarter way?

@szaimen This is your implementation, but I think this would be possible.

I found that https://www.miyuru.lk/geoiplegacy actually posts the month and year it's been updated, so I thougt that we could scrape that info with curl, and then compare with the current file on the system - and that's what this script does.

Please give your opinion.

Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
@enoch85
Copy link
Member Author

enoch85 commented Sep 13, 2024

Note to self: check connectivity before proceeding.

Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
@enoch85
Copy link
Member Author

enoch85 commented Sep 13, 2024

Tested and works, I'll merge this now!

@enoch85 enoch85 merged commit 9d7f90c into main Sep 13, 2024
@enoch85 enoch85 deleted the geoblock-update branch September 13, 2024 16:17
@szaimen
Copy link
Collaborator

szaimen commented Sep 15, 2024

Hi @enoch85,

sorry for coming back to you so late. I was very busy.

The reason why I did not implement it like this was this warning on https://www.miyuru.lk/geoiplegacy:
image
So I used Github as a relay basically.

@szaimen
Copy link
Collaborator

szaimen commented Sep 15, 2024

Btw, yesterday was my server automatically updated and it ran into the following issue:
image
This lead to ipv4 connections not working correctly anymore.
So it seems like there is something wrong with your implementation.
Shall I open a bug report?

@enoch85
Copy link
Member Author

enoch85 commented Sep 15, 2024

Hi @enoch85,

sorry for coming back to you so late. I was very busy.

The reason why I did not implement it like this was this warning on [image] So I used Github as a relay basically.

Valid point. I actually asked the owner of the website myself, and he's fine with it! :)

This lead to ipv4 connections not working correctly anymore.

So the filename has to be GeoIP.dat? I find it strange that you can't set you own name in the config...

@szaimen
Copy link
Collaborator

szaimen commented Sep 15, 2024

This lead to ipv4 connections not working correctly anymore.

So the filename has to be GeoIP.dat? I find it strange that you can't set you own name in the config...

No, the problem is that the geoip file that is on my system does not match the apache config. Somehow this got messed up after your PR...

@enoch85
Copy link
Member Author

enoch85 commented Sep 15, 2024

So, what's the output of:

ls -l /usr/share/GeoIP
cat /etc/apache2/apache2.conf

@szaimen
Copy link
Collaborator

szaimen commented Sep 15, 2024

I posted the information in the screenshot above already...

@enoch85
Copy link
Member Author

enoch85 commented Sep 15, 2024

Sorry...

I'll have another look and check if we can fix it, probably an easy fix. :)

@enoch85
Copy link
Member Author

enoch85 commented Sep 15, 2024

Can you try to run this:

#!/bin/bash
source /var/scripts/fetch_lib.sh

# Get newest dat files for geoblock.sh
if grep -q "^#Geoip-block" /etc/apache2/apache2.conf
then
    if get_newest_dat_files
    then
        if grep -c GeoIP.dat /etc/apache2/apache2.conf
        then
            if [ ! -f /usr/share/GeoIP/GeoIPv4.dat ]
            then
                if download_geoip_dat 4 v4
                then
                    sed -i "s|GeoIPDBFile /usr/share/GeoIP/GeoIP.dat|GeoIPDBFile /usr/share/GeoIP/GeoIPv4.dat|g" /etc/apache2/apache2.conf
                fi
            fi
        fi
        check_command systemctl restart apache2
    fi
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants