Page 23 of 24

Re: [3.3][RC] Filter by country - version 1.0.13

Posted: Sun Jul 05, 2020 3:23 pm
by MarkDHamill
I have noticed in my testing that what can often happen is that two entries in the phpbb_fbc_stats table can occur for the same country a second apart.

I still don't understand why the core.user_setup_after event seems to be called more than once when accessing a page. I tie into the event to prohibit or allow access by country. One workaround it simply to see if there is a similar statistic logged a second earlier and if so not save the statistic. This seems to work but might potentially create an under count of statistics on very highly trafficked boards. For example, it's possible with some sort of denial of service attack coming from a country like Belarus only one page request will get recorded over two seconds when there really were more than that occurring in a very short period of time.

Toward that end I have added a configuration variable where this value can be set in the extension's settings page, defaulting to one second. It is possible that if you have a slow database you might want to up the setting to two or more second. Zero disables it.

Re: [3.3][RC] Filter by country - version 1.0.13

Posted: Sun Jul 05, 2020 3:46 pm
by RMcGirr83
Not sure where you're getting that it's called twice. From my testing on my test forum, it's only called once per user.

Re: [3.3][RC] Filter by country - version 1.0.13

Posted: Sun Jul 05, 2020 3:48 pm
by MarkDHamill
Thanks for your testing. It seems to happen sporadically when access is allowed, not when it is rejected. But it seems kind of random.

[3.3][RC] Filter by country - version 1.0.15

Posted: Mon Jul 06, 2020 2:23 pm
by MarkDHamill
Version 1.0.15 is released. See the first post for download links.

Since the last version was 1.0.13, you might be wondering why this is 1.0.15. I committed 1.0.14 and realized I left out a few things, so I added them.

Changes from version 1.0.13:
  • As requested, you can now see in the statistics those who logged in from a restricted country if that feature is allowed.
  • Users have noticed what appears to be a lot of excess statistics being collected. It appears that the event the extension uses is getting called twice in some circumstances. The work around is to not allow a statistic to be created if it was added "recently". Recently defaults to 1 second. You can change this interval on the settings page. Setting it to 0 disables it.
  • As requested, you can now easily reset the statistics. Look for a button on the statistics page.
  • As in the patch, to avoid a SQL error you can't insert the same country more than once at a time. This happened if the same IP was in multiple HTTP headers.
  • There is a convenient button to blank out the test IP field on the settings page.
  • A bug in the login link was fixed.
  • If you are blocked because your country is unknown, this is noted in the error message.
Overall, this release seems much more consistent and straightforward, so hopefully no errors will be noted. Please test and if no issues I will submit the extension for another review.

A list of all changes from version 1.0.13 is here.

Re: [3.3][RC] Filter by country - version 1.0.15

Posted: Mon Jul 06, 2020 4:03 pm
by janus_zonstraal
Installed 1.0.15
Only lay-out looks strange to me?
Screenshot_2020-07-06 Filter by country.png

Re: [3.3][RC] Filter by country - version 1.0.15

Posted: Mon Jul 06, 2020 4:33 pm
by bug-i
ah, I know what boosts the page requests in my stats. I am using the popular mchat-module: https://www.phpbb.com/customise/db/exte ... extension/

Mchat refreshes itself every 5 seconds (standard is 10), nevertheless this means that every 5 (10) seconds every user will generate an new page request, even if the user is "inactive" and just visits the mainpage (where mchat is visible).

Technically - nothings wrong with Filter by country, it does what it is supposed to do, so no urgent need to fix this, but it would be nice to have the option the have "clean" stats without "passive" page refreshes by mchat.

----

additionally with version 15 stats are counted wrong with vpn. I just tested it and my allowed visit with restricted country is counted wrong into Restricted page requests although I can access the forum. This should be fixed.

Re: [3.3][RC] Filter by country - version 1.0.15

Posted: Mon Jul 06, 2020 4:43 pm
by MarkDHamill
janus_zonstraal wrote:
Mon Jul 06, 2020 4:03 pm
Installed 1.0.15
Only lay-out looks strange to me?
Screenshot_2020-07-06 Filter by country.png
Odd my editor didn't pick that up. In /adm/style/acp_filterbycountry_body.html after line 58:

Code: Select all

			<dd><input type="number" id="phpbbservices_filterbycountry_seconds" name="phpbbservices_filterbycountry_seconds" value="{{ FBC_SECONDS }}" min="0" />			</dd>
add below:

Code: Select all

		</dl>
Then purge the cache.

Re: [3.3][RC] Filter by country - version 1.0.15

Posted: Mon Jul 06, 2020 4:50 pm
by MarkDHamill
bug-i wrote:
Mon Jul 06, 2020 4:33 pm
additionally with version 15 stats are counted wrong with vpn. I just tested it and my allowed visit with restricted country is counted wrong into Restricted page requests although I can access the forum. This should be fixed.
If the country would otherwise be restricted but "Allow registered users to login from restricted countries" is set to Yes, then if you are already logged in using the IP associated with a restricted country, it will count as an "Allowed page requests from restricted countries" hit on the Statistics page. If you are not logged in and this is set to Yes, you should get a link in the blocked message to the login page, which should work. No other links should work.

Remember multiple IPs are possible because multiple headers are checked. So one IP might be allowed, but another may not be allowed. In this case, access is restricted unless the above is true. Both hits should be recorded.

Re: [3.3][RC] Filter by country - version 1.0.15

Posted: Mon Jul 06, 2020 5:39 pm
by bug-i
nope. Just cleared all stats and used a czech and swiss vpn for testing (and accessed the forum properly). Thats a screenshot what a I see in the stats. I think this is not correct, and the czech and swiss visits should have been counted into "Allowed page requests from restricted countries" and not into "Restricted page requests"
stats2.png

Re: [3.3][RC] Filter by country - version 1.0.15

Posted: Mon Jul 06, 2020 6:46 pm
by janus_zonstraal
Looks better now ;)

Re: [3.3][RC] Filter by country - version 1.0.15

Posted: Mon Jul 06, 2020 7:23 pm
by MarkDHamill
bug-i wrote:
Mon Jul 06, 2020 5:39 pm
nope. Just cleared all stats and used a czech and swiss vpn for testing (and accessed the forum properly). Thats a screenshot what a I see in the stats. I think this is not correct, and the czech and swiss visits should have been counted into "Allowed page requests from restricted countries" and not into "Restricted page requests"

stats2.png
What are the IP(s) involved? You can test MaxMind's evaluation of an IP here:

https://www.maxmind.com/en/geoip-demo/

Re: [3.3][RC] Filter by country - version 1.0.15

Posted: Mon Jul 06, 2020 7:35 pm
by bug-i
MarkDHamill wrote:
Mon Jul 06, 2020 7:23 pm
What are the IP(s) involved? You can test MaxMind's evaluation of an IP here:

https://www.maxmind.com/en/geoip-demo/
this doesnt matter. I used on purpose via vpn a swiss and czech ip which are blocked in my configuartion. As a have selected yes for "Allow registered users to login from restricted countries:" -> I had access to my board and my visits from both countries should have been counted into "allowed page request from restricted countries" not into "restricted page requests".

Re: [3.3][RC] Filter by country - version 1.0.15

Posted: Mon Jul 06, 2020 10:59 pm
by MarkDHamill
bug-i wrote:
Mon Jul 06, 2020 7:35 pm
MarkDHamill wrote:
Mon Jul 06, 2020 7:23 pm
What are the IP(s) involved? You can test MaxMind's evaluation of an IP here:

https://www.maxmind.com/en/geoip-demo/
this doesnt matter. I used on purpose via vpn a swiss and czech ip which are blocked in my configuartion. As a have selected yes for "Allow registered users to login from restricted countries:" -> I had access to my board and my visits from both countries should have been counted into "allowed page request from restricted countries" not into "restricted page requests".
Thank you for reporting the issue. Apparently I didn't think through the logic for when the countries are allowed properly. It needs to reflect the logic for when countries are rejected. So in /event/main_listener.php change line 285 from:

Code: Select all

				$this_request_type = constants::ACP_FBC_REQUEST_RESTRICT;	// Not in one of the selected countries, so reject
to:

Code: Select all

				// If not from one of the selected countries, possibly allow in if they are already logged in
				$this_request_type = ($apply_outside) ? constants::ACP_FBC_REQUEST_OUTSIDE : constants::ACP_FBC_REQUEST_RESTRICT;

Re: [3.3][RC] Filter by country - version 1.0.15

Posted: Mon Jul 06, 2020 11:52 pm
by Tread
Nice ext but way too easy to get around with a vpn maybe try blocking the browser language code for a country or part of a country.

Image

Re: [3.3][RC] Filter by country - version 1.0.15

Posted: Tue Jul 07, 2020 5:56 am
by bug-i
MarkDHamill wrote:
Mon Jul 06, 2020 10:59 pm
Thank you for reporting the issue. Apparently I didn't think through the logic for when the countries are allowed properly. It needs to reflect the logic for when countries are rejected. So in /event/main_listener.php change line 285 from:
Thanks! Now it works! @all: Remember to clear board cache, otherwise changes probably do not have immediate impact.