2020-06-16 10:06:31 +01:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
#
|
|
|
|
# InspIRCd -- Internet Relay Chat Daemon
|
|
|
|
#
|
2021-08-27 09:38:22 +01:00
|
|
|
# Copyright (C) 2021 Matt Schatz <genius3000@g3k.solutions>
|
2024-06-07 10:37:56 +01:00
|
|
|
# Copyright (C) 2020-2022, 2024 Sadie Powell <sadie@witchery.services>
|
2020-06-16 10:06:31 +01:00
|
|
|
#
|
|
|
|
# This file is part of InspIRCd. InspIRCd is free software: you can
|
|
|
|
# redistribute it and/or modify it under the terms of the GNU General Public
|
|
|
|
# License as published by the Free Software Foundation, version 2.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
2021-02-28 19:20:08 +00:00
|
|
|
use v5.26.0;
|
2020-06-16 10:06:31 +01:00
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
|
|
|
|
use IO::Socket();
|
|
|
|
use IO::Socket::SSL();
|
|
|
|
|
|
|
|
use constant {
|
|
|
|
CC_BOLD => -t STDOUT ? "\e[1m" : '',
|
|
|
|
CC_RESET => -t STDOUT ? "\e[0m" : '',
|
|
|
|
CC_GREEN => -t STDOUT ? "\e[1;32m" : '',
|
|
|
|
CC_RED => -t STDOUT ? "\e[1;31m" : '',
|
|
|
|
};
|
|
|
|
|
|
|
|
if (scalar @ARGV < 2) {
|
|
|
|
say STDERR "Usage: $0 <hostip> <port> [selfsigned]";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# By default STDOUT is only flushed at the end of each line. This sucks for our
|
|
|
|
# needs so we disable it.
|
|
|
|
STDOUT->autoflush(1);
|
|
|
|
|
2022-11-26 06:35:24 +00:00
|
|
|
# If a server closes the connection whilst an SSL session is being initiated we
|
|
|
|
# want EPIPE instead of SIGPIPE.
|
|
|
|
$SIG{PIPE} = 'IGNORE';
|
|
|
|
|
2020-06-16 10:06:31 +01:00
|
|
|
my $hostip = shift @ARGV;
|
2021-06-20 03:37:18 -06:00
|
|
|
if ($hostip =~ /[^A-Za-z0-9.:-]/) {
|
2020-06-16 10:06:31 +01:00
|
|
|
say STDERR "Error: invalid hostname or IP address: $hostip";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $port = shift @ARGV;
|
|
|
|
if ($port =~ /\D/ || $port < 1 || $port > 65535) {
|
|
|
|
say STDERR "Error: invalid TCP port: $port";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $self_signed = shift // '' eq 'selfsigned';
|
|
|
|
|
|
|
|
print "Checking whether ${\CC_BOLD}$hostip/$port${\CC_RESET} is reachable ... ";
|
|
|
|
my $sock = IO::Socket::INET->new(
|
|
|
|
PeerAddr => $hostip,
|
|
|
|
PeerPort => $port,
|
|
|
|
);
|
|
|
|
|
|
|
|
unless ($sock) {
|
|
|
|
say <<"EOM";
|
|
|
|
${\CC_RED}no${\CC_RESET}
|
|
|
|
|
|
|
|
It seems like the server endpoint you specified is not reachable! Make sure that:
|
|
|
|
|
|
|
|
* You have specified a <bind> tag in your config for this endpoint.
|
|
|
|
* You have rehashed or restarted the server since adding the <bind> tag.
|
|
|
|
* If you are using a firewall incoming connections on TCP port $port are allowed.
|
|
|
|
* The endpoint your server is listening on is not local or private.
|
|
|
|
|
2022-11-26 06:35:24 +00:00
|
|
|
The error provided by the socket library was:
|
|
|
|
|
|
|
|
$IO::Socket::errstr
|
|
|
|
|
2022-11-30 11:04:30 +00:00
|
|
|
See https://docs.inspircd.org/4/configuration/#bind for more information.
|
2020-06-16 10:06:31 +01:00
|
|
|
EOM
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
say "${\CC_GREEN}yes${\CC_RESET}";
|
|
|
|
print "Checking whether ${\CC_BOLD}$hostip/$port${\CC_RESET} is using plaintext ... ";
|
|
|
|
my $error = $sock->recv(my $data, 1);
|
|
|
|
|
2022-11-26 06:35:24 +00:00
|
|
|
if (!defined $error || $data eq '') {
|
2020-06-16 10:06:31 +01:00
|
|
|
say <<"EOM";
|
|
|
|
${\CC_RED}error${\CC_RESET}
|
|
|
|
|
|
|
|
It seems like the server dropped the connection before sending anything! Make sure that:
|
|
|
|
|
|
|
|
* The endpoint you specified is actually your IRC server.
|
|
|
|
* If you are using a firewall incoming data on TCP port $port are allowed.
|
2022-11-26 06:35:24 +00:00
|
|
|
* The IP address you are connecting from has not been banned from the server.
|
2020-06-16 10:06:31 +01:00
|
|
|
|
2022-11-30 11:04:30 +00:00
|
|
|
See https://docs.inspircd.org/4/configuration/#bind for more information.
|
2020-06-16 10:06:31 +01:00
|
|
|
EOM
|
|
|
|
exit 1;
|
|
|
|
} elsif ($data =~ /[A-Z:@]/) {
|
|
|
|
say <<"EOM";
|
|
|
|
${\CC_RED}yes${\CC_RESET}
|
|
|
|
|
|
|
|
It appears that the server endpoint is using plaintext! Make sure that:
|
|
|
|
|
|
|
|
* You have one or more of the following modules loaded:
|
|
|
|
- ssl_gnutls
|
|
|
|
- ssl_openssl
|
|
|
|
|
2021-12-08 12:32:29 +00:00
|
|
|
* The value of <bind:sslprofile> is the same as an <sslprofile:name> field.
|
2020-12-04 18:18:07 +00:00
|
|
|
|
2021-04-08 11:29:16 +01:00
|
|
|
* The value of <sslprofile:provider> for your used TLS profile is set to
|
2024-04-01 14:44:34 +01:00
|
|
|
"gnutls" if using the ssl_gnutls module or "openssl" if using the
|
|
|
|
ssl_openssl module.
|
2020-06-16 10:06:31 +01:00
|
|
|
|
2021-04-08 11:29:16 +01:00
|
|
|
* If you have your TLS configuration in a file other than inspircd.conf then
|
2020-06-16 10:06:31 +01:00
|
|
|
that file is included by inspircd.conf.
|
|
|
|
|
|
|
|
See the following links for more information:
|
|
|
|
|
2022-05-18 16:49:20 +01:00
|
|
|
https://docs.inspircd.org/4/modules/ssl_gnutls/#configuration
|
|
|
|
https://docs.inspircd.org/4/modules/ssl_openssl/#configuration
|
2020-06-16 10:06:31 +01:00
|
|
|
EOM
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sock->close();
|
|
|
|
say "${\CC_GREEN}no${\CC_RESET}";
|
2021-04-08 11:29:16 +01:00
|
|
|
print "Checking whether ${\CC_BOLD}$hostip/$port${\CC_RESET} can have an TLS session negotiated ... ";
|
2020-06-16 10:06:31 +01:00
|
|
|
$sock = IO::Socket::SSL->new(
|
|
|
|
PeerAddr => $hostip,
|
|
|
|
PeerPort => $port,
|
|
|
|
SSL_hostname => $hostip,
|
|
|
|
SSL_verify_mode => $self_signed ? IO::Socket::SSL::SSL_VERIFY_NONE : IO::Socket::SSL::SSL_VERIFY_PEER,
|
|
|
|
);
|
|
|
|
|
|
|
|
unless ($sock) {
|
|
|
|
say <<"EOM";
|
|
|
|
${\CC_RED}no${\CC_RESET}
|
|
|
|
|
|
|
|
It appears that something is wrong with your server. Make sure that:
|
|
|
|
|
2024-04-01 14:44:34 +01:00
|
|
|
* You are not using an old version of GnuTLS or OpenSSL which only supports
|
|
|
|
deprecated algorithms like SSLv3.
|
2021-11-23 23:04:08 +00:00
|
|
|
* If you are using a self-signed certificate (not recommended) that you passed
|
|
|
|
the `selfsigned` argument to this script.
|
2020-06-16 10:06:31 +01:00
|
|
|
|
2021-04-08 11:29:16 +01:00
|
|
|
The error provided by the TLS library was:
|
2020-06-16 10:06:31 +01:00
|
|
|
|
|
|
|
$IO::Socket::SSL::SSL_ERROR
|
|
|
|
EOM
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
say <<"EOM";
|
|
|
|
${\CC_GREEN}yes${\CC_RESET}
|
|
|
|
|
2021-04-08 11:29:16 +01:00
|
|
|
It seems like TLS is working fine on your server. If you are having trouble
|
2020-06-16 10:06:31 +01:00
|
|
|
connecting try using a different client or connecting from a different host.
|
|
|
|
|
|
|
|
You may also find running some of the following commands to be helpful:
|
|
|
|
|
|
|
|
gnutls-cli-debug --port $port $hostip
|
|
|
|
openssl s_client -connect $hostip:$port -debug -security_debug
|
|
|
|
|
|
|
|
If you need any help working out what is wrong then visit our support channel
|
2024-10-13 09:41:26 +01:00
|
|
|
at ircs://irc.teranova.net/inspircd.
|
2020-06-16 10:06:31 +01:00
|
|
|
EOM
|