From d8fc5cf65856b9a26024a4c22593b9e8466fa322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E5=98=89=E4=BF=8A?= Date: Tue, 2 Jul 2013 13:31:10 +0800 Subject: [PATCH] Add an option: bind pyapns to a specified IP address --- example_conf.json | 1 + pyapns.tac | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/example_conf.json b/example_conf.json index 3d41b63..cbc7403 100644 --- a/example_conf.json +++ b/example_conf.json @@ -1,4 +1,5 @@ { + "host": "localhost", "port": 7077, "rest_port": 8088, "autoprovision": [ diff --git a/pyapns.tac b/pyapns.tac index 621ce3a..fd6404c 100644 --- a/pyapns.tac +++ b/pyapns.tac @@ -35,6 +35,11 @@ if 'autoprovision' in config: application = twisted.application.service.Application("pyapns application") +if 'host' in config: + host = config['host'] +else: + host = '' + # XML-RPC server support ------------------------------------------------------ if 'port' in config: @@ -47,7 +52,7 @@ resource.putChild('', xml_service) site = twisted.web.server.Site(resource) -server = twisted.application.internet.TCPServer(port, site) +server = twisted.application.internet.TCPServer(port, site, interface=host) server.setServiceParent(application) # rest service support -------------------------------------------------------- @@ -58,5 +63,5 @@ else: site = twisted.web.server.Site(pyapns.rest_service.default_resource) -server = twisted.application.internet.TCPServer(rest_port, site) +server = twisted.application.internet.TCPServer(rest_port, site, interface=host) server.setServiceParent(application)