relay: don't require allocate(): first message creates the Channel

this enables pre-generated (human-offline-created) codes, as long as
they use a channel id high enough to avoid colliding with any allocated
ones.
This commit is contained in:
Brian Warner 2015-04-09 22:46:18 -05:00
parent c8d2fc8750
commit 3aa7e22708

View File

@ -205,9 +205,9 @@ class Relay(resource.Resource):
"invalid channel id")
channel_id = int(path)
if not channel_id in self.channels:
return resource.ErrorPage(http.NOT_FOUND,
"invalid channel id",
"invalid channel id")
log.msg("claimed #%d, now have %d channels" %
(channel_id, len(self.channels)))
self.channels[channel_id] = Channel(channel_id, self)
return self.channels[channel_id]
def free_child(self, channel_id):