friendly-bits / geoip-shell

User-friendly and flexible geoip blocker for Linux
GNU General Public License v3.0
85 stars 3 forks source link

Connection attempt to the RIPE server failed. (Ubuntu 16.04 install) #18

Open vanboom opened 1 day ago

vanboom commented 1 day ago

Hi - and thank you for a fantastic capability. I have it working on a Debian 12 server and now I am attempting to set up on an Ubuntu 16.04 server and getting a failure.

Checking connectivity... fetch: Error: Connection attempt to the RIPE server failed.

The URL that it is attempting is: stat.ripe.net/data/country-resource-list/data.json?v4_format=prefix&resource=nl

If I try to wget that, I get

Resolving stat.ripe.net (stat.ripe.net)... 193.0.6.150, 2001:67c:2e8:22::c100:696
Connecting to stat.ripe.net (stat.ripe.net)|193.0.6.150|:80... connected.
HTTP request sent, awaiting response... 400 Bad Request
2024-10-12 11:56:44 ERROR 400: Bad Request.

Same for https...

Resolving stat.ripe.net (stat.ripe.net)... 193.0.6.150, 2001:67c:2e8:22::c100:696
Connecting to stat.ripe.net (stat.ripe.net)|193.0.6.150|:443... connected.
HTTP request sent, awaiting response... 400 Bad Request
2024-10-12 11:57:12 ERROR 400: Bad Request.

I am trying to understand the cause of the error, has anyone else resolved this on 16.04?

Thank you!

friendly-bits commented 1 day ago

Hi, please post output of:

curl --version
wget --version
wget --max-redirect=10 --tries=2 --timeout=10 --spider "https://stat.ripe.net/data/country-resource-list/data.json?v4_format=prefix&resource=nl"
vanboom commented 1 day ago

Thank you! curl --version

curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets

wget --version

GNU Wget 1.17.1 built on linux-gnu.

+digest -gpgme +https +ipv6 +iri +large-file -metalink +nls +ntlm 
+opie -psl +ssl/openssl 

wget ripe URL

Spider mode enabled. Check if remote file exists.
--2024-10-12 13:10:52--  https://stat.ripe.net/data/country-resource-list/data.json?v4_format=prefix&resource=nl
Resolving stat.ripe.net (stat.ripe.net)... 193.0.6.150, 2001:67c:2e8:22::c100:696
Connecting to stat.ripe.net (stat.ripe.net)|193.0.6.150|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 316421 (309K) [application/json]
Remote file exists.

Thank you!

friendly-bits commented 23 hours ago

This looks normal. What's the output of

curl -L -f --fail-early --retry 2 --connect-timeout 10 -s --head "https://stat.ripe.net/data/country-resource-list/data.json?v4_format=prefix&resource=nl"; echo $?
vanboom commented 22 hours ago
curl: option --fail-early: is unknown

If I leave the '--fail-early' option out, it returns 200 OK.

curl -L -f --fail early --retry 2 --connect-timeout 10 -s --head "https://stat.ripe.net/data/country-resource-list/data.json?v4_format=prefix&resource=nl"; echo $?

returns

HTTP/1.1 200 OK
Server: nginx
Date: Sat, 12 Oct 2024 19:12:20 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 316418
Connection: keep-alive
Vary: Cookie, Accept-Encoding
Access-Control-Allow-Origin: *
x-frame-options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Permissions-Policy: interest-cohort=()
strict-transport-security: max-age=31536000; includeSubdomains

0
vanboom commented 22 hours ago

Yep, it was --fail-early. Changing that to --fail early in the geoip-shell-fetch.sh script fixed the issue. Looks like this version of curl does not support --fail-early. I will see if I can upgrade it.

friendly-bits commented 21 hours ago

Great. I'll look into changing the script to check for this option and not use it if it's not supported.

friendly-bits commented 21 hours ago

Could you test with the current 'main' (not the release)? I implemented the aforementioned check in it.

friendly-bits commented 2 hours ago

Changing that to --fail early

Also, if you want to use a manually edited version of the script then you should simply remove the --fail-early option, rather than changing it to --fail early which is a hybrid of a valid option (--fail) which geoip-shell already uses (in its shortened form: -f), and an invalid string (early) which is not supposed to be in the curl command.