Make SSL the default for connecting to a new network.

This commit is contained in:
Valentin Lorentz 2016-02-21 13:04:26 +01:00
parent b33dadea9e
commit c3dd5f8b64
3 changed files with 18 additions and 15 deletions

View File

@ -56,13 +56,14 @@ class Network(callbacks.Plugin):
@internationalizeDocstring @internationalizeDocstring
def connect(self, irc, msg, args, opts, network, server, password): def connect(self, irc, msg, args, opts, network, server, password):
"""[--ssl] <network> [<host[:port]>] [<password>] """[--nossl] <network> [<host[:port]>] [<password>]
Connects to another network (which will be represented by the name Connects to another network (which will be represented by the name
provided in <network>) at <host:port>. If port is not provided, it provided in <network>) at <host:port>. If port is not provided, it
defaults to 6667, the default port for IRC. If password is defaults to 6697, the default port for IRC with SSL. If password is
provided, it will be sent to the server in a PASS command. If --ssl is provided, it will be sent to the server in a PASS command. If --nossl is
provided, an SSL connection will be attempted. provided, an SSL connection will not be attempted, and the port will
default to 6667.
""" """
if '.' in network: if '.' in network:
irc.error("Network names cannot have a '.' in them. " irc.error("Network names cannot have a '.' in them. "
@ -75,14 +76,16 @@ class Network(callbacks.Plugin):
# quite sure what to do about it. # quite sure what to do about it.
except callbacks.Error: except callbacks.Error:
pass pass
ssl = False ssl = True
for (opt, arg) in opts: for (opt, arg) in opts:
if opt == 'ssl': if opt == 'nossl':
ssl = True ssl = False
if server: if server:
if ':' in server: if ':' in server:
(server, port) = server.split(':') (server, port) = server.split(':')
port = int(port) port = int(port)
elif ssl:
port = 6697
else: else:
port = 6667 port = 6667
serverPort = (server, port) serverPort = (server, port)

View File

@ -389,15 +389,15 @@ def main():
output("""Found %s (%s).""" % (serverString, ip)) output("""Found %s (%s).""" % (serverString, ip))
if advanced: # conf.supybot.networks.<network>.ssl
# conf.supybot.networks.<network>.ssl output("""Most networks allow you to use a secure connection via SSL.
output("""Some servers allow you to use a secure connection via SSL. If you are not sure whether this network supports SSL or not, check
This requires having pyOpenSSL installed.""") its website.""")
if yn('Do you want to use an SSL connection?', default=False): if yn('Do you want to use an SSL connection?', default=True):
network.ssl.setValue(True) network.ssl.setValue(True)
output("""IRC servers almost always accept connections on port output("""IRC servers almost always accept connections on port
6667 (or 6697 when using SSL). They can, however, accept connections 6697 (or 6667 when not using SSL). They can, however, accept connections
anywhere their admins feel like they want to accept connections from.""") anywhere their admins feel like they want to accept connections from.""")
if yn('Does this server require connection on a non-standard port?', if yn('Does this server require connection on a non-standard port?',
default=False): default=False):

View File

@ -306,7 +306,7 @@ class ValidSaslMechanism(registry.OnlySomeStrings):
class SpaceSeparatedListOfSaslMechanisms(registry.SpaceSeparatedListOf): class SpaceSeparatedListOfSaslMechanisms(registry.SpaceSeparatedListOf):
Value = ValidSaslMechanism Value = ValidSaslMechanism
def registerNetwork(name, password='', ssl=False, sasl_username='', def registerNetwork(name, password='', ssl=True, sasl_username='',
sasl_password=''): sasl_password=''):
network = registerGroup(supybot.networks, name) network = registerGroup(supybot.networks, name)
registerGlobalValue(network, 'password', registry.String(password, registerGlobalValue(network, 'password', registry.String(password,