Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 78600db

Browse files
Merge pull request #686 from kisabaka/master
Add a way to provide STUN servers from AppRTC configuration directly
2 parents 21b0f27 + e10f89f commit 78600db

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ Instructions were performed on Ubuntu 14.04 using Python 2.7.6 and Go 1.6.3.
5151
* Change `WSS_INSTANCE_HOST_KEY` to the hostname and port Collider is listening too, e.g. `localhost:8089` or `otherHost:443`.
5252

5353
### TURN/STUN
54-
* **If using TURN and STUN servers directly**
54+
55+
* **If using TURN and STUN servers directly**
56+
57+
Either:
58+
5559
* Comment out `TURN_SERVER_OVERRIDE = []` and then uncomment `TURN_SERVER_OVERRIDE = [ { "urls":...]` three lines below and fill your TURN server details, e.g.
5660

5761
```python
@@ -72,13 +76,21 @@ Instructions were performed on Ubuntu 14.04 using Python 2.7.6 and Go 1.6.3.
7276
]
7377
```
7478

79+
* Or:
80+
81+
Set the the comma-separated list of STUN servers in app.yaml. e.g.
82+
83+
```
84+
ICE_SERVER_URLS: "stun:hostnameForYourStunServer,stun:hostnameForYourSecondStunServer"
85+
```
86+
7587
* **Else if using ICE Server provider [1]**
7688
* Change `ICE_SERVER_BASE_URL` to your ICE server provider host.
7789
* Change `ICE_SERVER_URL_TEMPLATE` to a path or empty string depending if your ICE server provider has a specific URL path or not.
7890
* Change `ICE_SERVER_API_KEY` to an API key or empty string depending if your ICE server provider requires an API key to access it or not.
7991

8092
```python
81-
ICE_SERVER_BASE_URL = 'https://networktraversal.googleapis.com'
93+
ICE_SERVER_BASE_URL = 'https://appr.tc'
8294
ICE_SERVER_URL_TEMPLATE = '%s/v1alpha/iceconfig?key=%s'
8395
ICE_SERVER_API_KEY = os.environ.get('ICE_SERVER_API_KEY')
8496
```

src/app_engine/app.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ env_variables:
4949
# Use appcfg.py --env_variable=ICE_SERVER_API_KEY:KEY \
5050
# in order to replace variables when deploying.
5151
ICE_SERVER_API_KEY: ""
52+
# Comma-separated list of ICE urls to return when no ice server
53+
# is specified.
54+
ICE_SERVER_URLS: ""
5255
# A message that is always displayed on the app page.
5356
# This is useful for cases like indicating to the user that this
5457
# is a demo deployment of the app.

src/app_engine/apprtc.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,16 @@ def checkIfRedirect(self):
594594
redirect_url = constants.REDIRECT_URL + self.request.path + parsed_args
595595
webapp2.redirect(redirect_url, permanent=True, abort=True)
596596

597+
class IceConfigurationPage(webapp2.RequestHandler):
598+
def post(self):
599+
ice_config = {}
600+
if constants.ICE_SERVER_OVERRIDE:
601+
ice_config = {"iceServers": constants.ICE_SERVER_OVERRIDE}
602+
else:
603+
ice_config = {"iceServers": [{"urls": constants.ICE_SERVER_URLS}]}
604+
self.response.write(json.dumps(ice_config))
605+
606+
597607
app = webapp2.WSGIApplication([
598608
('/', MainPage),
599609
('/a/', analytics_page.AnalyticsPage),
@@ -602,5 +612,6 @@ def checkIfRedirect(self):
602612
('/leave/([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_]+)', LeavePage),
603613
('/message/([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_]+)', MessagePage),
604614
('/params', ParamsPage),
615+
('/v1alpha/iceconfig', IceConfigurationPage),
605616
('/r/([a-zA-Z0-9-_]+)', RoomPage),
606617
], debug=True)

src/app_engine/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@
3838
# }
3939
# ]
4040

41-
ICE_SERVER_BASE_URL = 'https://networktraversal.googleapis.com'
41+
ICE_SERVER_BASE_URL = 'https://appr.tc'
4242
ICE_SERVER_URL_TEMPLATE = '%s/v1alpha/iceconfig?key=%s'
4343
ICE_SERVER_API_KEY = os.environ.get('ICE_SERVER_API_KEY')
4444
HEADER_MESSAGE = os.environ.get('HEADER_MESSAGE')
45+
ICE_SERVER_URLS = [url for url in os.environ.get('ICE_SERVER_URLS', '').split(',') if url]
4546

4647
# Dictionary keys in the collider instance info constant.
4748
WSS_INSTANCE_HOST_KEY = 'host_port_pair'

0 commit comments

Comments
 (0)