Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use IPInfo as secondary source #2683

Merged
merged 9 commits into from
Sep 22, 2024
Merged

Use IPInfo as secondary source #2683

merged 9 commits into from
Sep 22, 2024

Conversation

enoch85
Copy link
Member

@enoch85 enoch85 commented Sep 22, 2024

Fix #2682

Fix #2682

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 22, 2024

Hmm, this doesn't seem to work. Allowing "SE" in the list still blocks it when trying to reach the site.

@abdullahdevrel Are your mmdb different from Maxminds?

@enoch85
Copy link
Member Author

enoch85 commented Sep 22, 2024

Example from CSV:

start_ip	end_ip	country	country_name	continent	continent_name
1.0.0.0	1.0.0.255	AU	Australia	OC	Oceania
1.0.1.0	1.0.3.255	CN	China	AS	Asia
1.0.4.0	1.0.7.255	AU	Australia	OC	Oceania
1.0.8.0	1.0.15.255	CN	China	AS	Asia
1.0.16.0	1.0.31.255	JP	Japan	AS	Asia

In the Apache conf, we use different "tags". This might not work after all?

@enoch85
Copy link
Member Author

enoch85 commented Sep 22, 2024

@enoch85
Copy link
Member Author

enoch85 commented Sep 22, 2024

So, since IPInfo doesn't run it's own Apache module, I'm afraid this won't work. :|

@abdullahdevrel
Copy link

@enoch85 Thank you for reviewing. The scheme is different from MaxMind's, and you have found the post that I would have linked.

I believe the Apache module (https://github.com/maxmind/mod_maxminddb) is schema agnostic, like all the other MMDB reader libraries out there (https://community.ipinfo.io/t/list-of-mmdb-reader-libraries/2821).

Looking at this bit of code:

vm/network/geoblock.sh

Lines 224 to 227 in 6a111c7

MaxMindDBFile DB $GEOBLOCK_DIR/GeoLite2-Country.mmdb
MaxMindDBEnv MM_CONTINENT_CODE DB/continent/code
MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code

So, with respect to our database schema, I assume this will be:

  MaxMindDBEnv MM_CONTINENT_CODE DB/continent
  MaxMindDBEnv MM_COUNTRY_CODE DB/country

Can you see if it would work?

@enoch85
Copy link
Member Author

enoch85 commented Sep 22, 2024

Yes, I can confirm, the change works.

Now I need to get my head around how we want to do this...

@enoch85
Copy link
Member Author

enoch85 commented Sep 22, 2024

Found a solution!

<IfModule mod_maxminddb.c>
  MaxMindDBEnable On

  # Check for IPinfo mmdb
  <IfFile "/usr/share/GeoIP/IPInfo-Country.mmdb">
    MaxMindDBFile DB /usr/share/GeoIP/IPInfo-Country.mmdb
    MaxMindDBEnv MM_CONTINENT_CODE DB/continent
    MaxMindDBEnv MM_COUNTRY_CODE DB/country
  </IfFile>
  # Check for Maxmind mmdb
  <IfFile "/usr/share/GeoIP/GeoLite2-Country.mmdb">
    MaxMindDBFile DB /usr/share/GeoIP/GeoLite2-Country.mmdb
    MaxMindDBEnv MM_CONTINENT_CODE DB/continent/code
    MaxMindDBEnv MM_COUNTRY_CODE DB/country/iso_code
  </IfFile>
</IfModule>

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

enoch85 commented Sep 22, 2024

OK, so this is tested and works!

@abdullahdevrel Please confirm that the "attribution requirements" are enough.

Signed-off-by: Daniel Hansson <[email protected]>
lib.sh Show resolved Hide resolved
@enoch85 enoch85 merged commit 7b1130a into main Sep 22, 2024
7 checks passed
@enoch85 enoch85 deleted the IPInfo branch September 22, 2024 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Using IPinfo IP to Country database
2 participants