Skip to content

Commit

Permalink
Add an option: bind pyapns to a specified IP address
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyao committed Jul 2, 2013
1 parent 241e9b1 commit d8fc5cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions example_conf.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"host": "localhost",
"port": 7077,
"rest_port": 8088,
"autoprovision": [
Expand Down
9 changes: 7 additions & 2 deletions pyapns.tac
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 --------------------------------------------------------
Expand All @@ -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)

0 comments on commit d8fc5cf

Please sign in to comment.