aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkongr45gpen <electrovesta@gmail.com>2018-01-06 13:18:18 +0200
committerkongr45gpen <electrovesta@gmail.com>2018-01-06 13:19:18 +0200
commit4ac15ab8421c2c92322e715ffd1550203b212a21 (patch)
tree03fffd2c756411aaeaf188223ca4b946b71cd4d3
parente04c3d95dd46a40af04e31a0020aec5f02043da3 (diff)
downloadsupybot_github-4ac15ab8421c2c92322e715ffd1550203b212a21.tar.gz
supybot_github-4ac15ab8421c2c92322e715ffd1550203b212a21.tar.bz2
supybot_github-4ac15ab8421c2c92322e715ffd1550203b212a21.zip
Add configuration value to specify the binding address of the HTTP server
Implements #24
-rw-r--r--config.py4
-rw-r--r--docs/configuration.rst15
-rw-r--r--plugin.py5
-rw-r--r--test.py10
4 files changed, 27 insertions, 7 deletions
diff --git a/config.py b/config.py
index b7faba3..31c11bc 100644
--- a/config.py
+++ b/config.py
@@ -59,6 +59,10 @@ conf.registerChannelValue(Github, 'showSuccessfulDeployMessages',
registry.String('always',
"""Whether to show successful deployment messages - can be never, change or always"""))
+conf.registerGlobalValue(Github, 'address',
+ registry.String('',
+ """The IP address or hostname to which the HTTP server will bind. The default empty value ('') should work for most cases."""))
+
conf.registerGlobalValue(Github, 'port',
registry.Integer(8093,
"""The port where Github will send HTTP requests"""))
diff --git a/docs/configuration.rst b/docs/configuration.rst
index 25c8849..f916f40 100644
--- a/docs/configuration.rst
+++ b/docs/configuration.rst
@@ -60,9 +60,22 @@ Available configuration values
:Type: String
:Scope: `Global`
+``address``
+ The IP address or hostname that the HTTP server receiving event information
+ will bind to. The default empty value of ``''`` or ``0.0.0.0`` will work for
+ almost all cases.
+
+ :Default value: ````
+ :Type: String
+ :Scope: `Global`
+
+ A plugin reload will be required so that changes in this value can be applied.
+
``port``
The port which will be used by the HTTP server to receive event information
- from Github and other services
+ from Github and other services.
+
+ A plugin reload will be required so that changes in this value can be applied.
:Default value: `8093`
:Type: Integer
diff --git a/plugin.py b/plugin.py
index cbcd7d5..166e353 100644
--- a/plugin.py
+++ b/plugin.py
@@ -58,6 +58,7 @@ class Github(callbacks.Plugin):
This should describe how to use this plugin."""
threaded = True
+ address = Utility.configValue('address')
port = Utility.configValue('port')
messages = []
pass
@@ -69,7 +70,7 @@ class Github(callbacks.Plugin):
def ServerStart(self, httpd):
try:
- log.info('Server Starts - %s:%s' % ('', self.port))
+ log.info('Server Starts - %s:%s' % (self.address, self.port))
httpd.serve_forever()
except:
return
@@ -79,7 +80,7 @@ class Github(callbacks.Plugin):
self.__parent = super(Github, self)
self.__parent.__init__(irc)
server_class = BaseHTTPServer.HTTPServer
- self.httpd = server_class(('', self.port), RequestHandler.GithubHandler)
+ self.httpd = server_class((self.address, self.port), RequestHandler.GithubHandler)
t = threading.Thread(target=self.ServerStart, args=(self.httpd,))
t.daemon = False
t.start()
diff --git a/test.py b/test.py
index 443f548..67aa1f4 100644
--- a/test.py
+++ b/test.py
@@ -7,17 +7,19 @@ from local.testing.ExpectationPluginTestCase import *
class GithubTestCase(ExpectationPluginTestCase):
plugins = ('Github',)
port = 27230
+ address = '127.0.0.1'
files = {}
config = { 'plugins.github.shortUrl': False,
'plugins.github.hidePush': False
}
def setUp(self):
- # Set a different port from the default one to make testing while a
- # supybot-github instance is running possible - we don't use the config
- # variable because supybot's test framework sets the value after the
- # plugin has been loaded
+ # Set a different port and address from the default one to make
+ # testing while a supybot-github instance is running possible - we
+ # don't use the config variable because supybot's test framework sets
+ # the value after the plugin has been loaded
conf.supybot.plugins.get("Github").get('port').setValue(self.port)
+ conf.supybot.plugins.get("Github").get('address').setValue(self.address)
PluginTestCase.setUp(self)

© 2014-2024 Faster IT GmbH | imprint | privacy policy