Page 3 of 15

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 3:03 pm
by </Solidjeuh>
That's why there are test users :D

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 3:13 pm
by MarkDHamill
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.

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 3:30 pm
by </Solidjeuh>
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

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 3:40 pm
by MarkDHamill
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.

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 3:46 pm
by </Solidjeuh>
Okay, I disabled my VPN, and blocked my country "Belgium".
And was still able to login

Re: [ALPHA] Filter by country - version 1.0.1

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

https://whatismycountry.com

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 3:54 pm
by </Solidjeuh>
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

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 4:06 pm
by MarkDHamill
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;
			}
		}

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 4:57 pm
by fagbutlil
</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.

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 5:07 pm
by </Solidjeuh>
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:

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 7:40 pm
by MarkDHamill
Can you send me the IP you used for Belgium? That will let me debug it. You can PM me.

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 7:42 pm
by canonknipser
</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

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 7:44 pm
by MarkDHamill
The database is proprietary. I suspect it works by saying a range of IPs belong to an ISP in a particular country.

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 8:24 pm
by </Solidjeuh>
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.

Re: [ALPHA] Filter by country - version 1.0.1

Posted: Wed Jun 05, 2019 9:01 pm
by MarkDHamill
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.