[BETA] Filter by country - version 1.0.8

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Scam Warning
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
User avatar
</Solidjeuh>
Registered User
Posts: 1732
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by </Solidjeuh> » Wed Jun 05, 2019 3:03 pm

That's why there are test users :D

User avatar
MarkDHamill
Registered User
Posts: 3942
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by MarkDHamill » Wed Jun 05, 2019 3:13 pm

Indeed. What I really need is a good production test. It seems that rejected hits get double counted, maybe some sort of page refresh thing.
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
</Solidjeuh>
Registered User
Posts: 1732
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by </Solidjeuh> » Wed Jun 05, 2019 3:30 pm

I tried this with my VPN.

I blocked "Poland" and the setting that users cannot login.
Then I set my VPN to "Poland", and I was able to login into my forum.

It was working good before the last update

User avatar
MarkDHamill
Registered User
Posts: 3942
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by MarkDHamill » Wed Jun 05, 2019 3:40 pm

It's unclear to me if it's not working as expected. VPNs I think would count as out of country logins, so if that setting is enabled you should be able to login.

I'm having a conversation with MaxMind about including their Anonymous IP database in the extension, for those willing to pay for it. I'm looking for a free license to use for development.
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
</Solidjeuh>
Registered User
Posts: 1732
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by </Solidjeuh> » Wed Jun 05, 2019 3:46 pm

Okay, I disabled my VPN, and blocked my country "Belgium".
And was still able to login

User avatar
MarkDHamill
Registered User
Posts: 3942
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by MarkDHamill » Wed Jun 05, 2019 3:49 pm

Presumably the database is good. What country do you get when you go here?

https://whatismycountry.com
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
</Solidjeuh>
Registered User
Posts: 1732
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by </Solidjeuh> » Wed Jun 05, 2019 3:54 pm

MarkDHamill wrote:
Wed Jun 05, 2019 3:49 pm
Presumably the database is good. What country do you get when you go here?

https://whatismycountry.com
Image

User avatar
MarkDHamill
Registered User
Posts: 3942
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by MarkDHamill » Wed Jun 05, 2019 4:06 pm

I guess I need to look at my logic again. It's pretty simple.

The filter_by_country() function in event/main_listener.php is where traffic is blocked or allowed. If you feel up to it to do some debugging to document where it fails, I'd appreciate it. If the IP is not in the MaxMind database, the catch() logic starting around line 173 will get executed.

Code: Select all

		catch (\Exception $e)
		{
			switch ($e->getCode())
			{
				case 'AddressNotFoundException':           	// IP not found in the Maxmind Country database
					$exception = true;
					$country_code = '??';
				break;
				default:
					$error = true;                          // Something highly unexpected happened
				break;
			}
		}
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

fagbutlil
I've Been Banned!
Posts: 77
Joined: Wed Mar 07, 2018 10:56 pm

Re: [ALPHA] Filter by country - version 1.0.1

Post by fagbutlil » Wed Jun 05, 2019 4:57 pm

</Solidjeuh> wrote:
Wed Jun 05, 2019 3:46 pm
Okay, I disabled my VPN, and blocked my country "Belgium".
And was still able to login
Did you log out then back in to get a new session after turning vpn off.

User avatar
</Solidjeuh>
Registered User
Posts: 1732
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by </Solidjeuh> » Wed Jun 05, 2019 5:07 pm

fagbutlil wrote:
Wed Jun 05, 2019 4:57 pm
Did you log out then back in to get a new session after turning vpn off.
Yeah I did. Also cleared forum & browser cache.
Tried with a Russian IP. Some are blocked, some are not.
So there must be something wrong... ?

Sorry, I'm not that smart MarkDHamill :lol:

User avatar
MarkDHamill
Registered User
Posts: 3942
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by MarkDHamill » Wed Jun 05, 2019 7:40 pm

Can you send me the IP you used for Belgium? That will let me debug it. You can PM me.
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
canonknipser
Registered User
Posts: 2096
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by canonknipser » Wed Jun 05, 2019 7:42 pm

</Solidjeuh> wrote:
Wed Jun 05, 2019 5:07 pm
So there must be something wrong... ?
Maybe the data source is not filled with all possible IP / country combinations, but only those who count as "negativ"? Just a guess: You are too polite, so your belgian IP is not on the bad boy list
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB

User avatar
MarkDHamill
Registered User
Posts: 3942
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by MarkDHamill » Wed Jun 05, 2019 7:44 pm

The database is proprietary. I suspect it works by saying a range of IPs belong to an ISP in a particular country.
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
</Solidjeuh>
Registered User
Posts: 1732
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by </Solidjeuh> » Wed Jun 05, 2019 8:24 pm

PM with my IP send.

I just tried again. Disable the ext & delete data.
Re-install, block Belgium and the setting to not allow logins.
Logged out from the forum, cleared cache via FTP & browser cache.
Close Firefox. Then went back to my forum, and I was able to login.
No message showed up that I was blocked, all was normal.

User avatar
MarkDHamill
Registered User
Posts: 3942
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: [ALPHA] Filter by country - version 1.0.1

Post by MarkDHamill » Wed Jun 05, 2019 9:01 pm

My testing suggests is it operating normally. I forced the IP to be the one sent in the PM

Country Belgium - Restricted
Allow registered users to login from restricted countries - No
Action to take if the user’s IP address is not found in MaxMind database - Restrict
Result: Blocked

Country Belgium - Restricted
Allow registered users to login from restricted countries - No
Action to take if the user’s IP address is not found in MaxMind database - Allowed
Result: Blocked

Country Belgium - Allowed
Allow registered users to login from restricted countries - No
Action to take if the user’s IP address is not found in MaxMind database - Restrict
Result: Allowed

Country Belgium - Allowed
Allow registered users to login from restricted countries - No
Action to take if the user’s IP address is not found in MaxMind database - Allowed
Result: Allowed

MaxMind is definitely interpreting the IP I was given as coming from Belgium.
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

Post Reply

Return to “Extensions in Development”