Force SSL Configuration Parameter

Adds a new optional config parameter "force_ssl" that applies the SSL wrapper
regardless of the specified port. The previous logic only allowed for SSL
on port 6697. This change is intended to be backwards compatible with
existing configs.

Added *.egg  ignore patterns to .gitignore

Change-Id: I6fe6d9ad2d8461d759a63123af79f229b8f8b6f2
This commit is contained in:
Matthew Montgomery 2014-05-23 08:12:34 -05:00
parent 575b062cbd
commit 6208bd982f
3 changed files with 9 additions and 4 deletions

3
.gitignore vendored
View File

@ -1,9 +1,10 @@
.tox
AUTHORS
ChangeLog
*.egg
*egg-info
dist/*
build/*
*.pyc
doc/build/*
doc/source/api/*
doc/source/api/*

View File

@ -17,6 +17,7 @@ when starting the bot. It should look like::
pass=PASSWORD
server=irc.freenode.net
port=6667
force_ssl=True or False (Defaults to False)
server_password=SERVERPASS
channel_config=/path/to/yaml/config

View File

@ -22,6 +22,7 @@ nick=NICKNAME
pass=PASSWORD
server=irc.freenode.net
port=6667
force_ssl=false
server_password=SERVERPASS
channel_config=/path/to/yaml/config
@ -75,8 +76,8 @@ irc.client.ServerConnection.buffer_class.errors = 'replace'
class GerritBot(irc.bot.SingleServerIRCBot):
def __init__(self, channels, nickname, password, server, port=6667,
server_password=None):
if port == 6697:
force_ssl=False, server_password=None):
if force_ssl or port == 6697:
factory = irc.connection.Factory(wrapper=ssl.wrap_socket)
super(GerritBot, self).__init__([(server, port, server_password)],
nickname, nickname,
@ -296,7 +297,8 @@ class ChannelConfig(object):
def _main():
config = ConfigParser.ConfigParser({'server_password': None})
config = ConfigParser.ConfigParser({'force_ssl': 'false',
'server_password': None})
config.read(sys.argv[1])
setup_logging(config)
@ -315,6 +317,7 @@ def _main():
config.get('ircbot', 'pass'),
config.get('ircbot', 'server'),
config.getint('ircbot', 'port'),
config.getboolean('ircbot', 'force_ssl'),
config.get('ircbot', 'server_password'))
g = Gerrit(bot,
channel_config,