Skip to content

Commit

Permalink
Merge pull request #228 from jrziviani/master
Browse files Browse the repository at this point in the history
Enable unix socket to work with token plugin
  • Loading branch information
DirectXMan12 authored Jun 30, 2016
2 parents 7d5d738 + 7f8baf5 commit 72ce5c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 10 additions & 0 deletions tests/test_websocketproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ def lookup(self, token):
self.assertEqual(host, "some host")
self.assertEqual(port, "some port")

def test_get_target_unix_socket(self):
class TestPlugin(token_plugins.BasePlugin):
def lookup(self, token):
return ("unix_socket", "/tmp/socket")

_, socket = self.handler.get_target(
TestPlugin(None), self.handler.path)

self.assertEqual(socket, "/tmp/socket")

def test_get_target_raises_error_on_unknown_token(self):
class TestPlugin(token_plugins.BasePlugin):
def lookup(self, token):
Expand Down
10 changes: 8 additions & 2 deletions websockify/websocketproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ def send_auth_error(self, ex):
self.end_headers()

def validate_connection(self):
if self.server.token_plugin:
(self.server.target_host, self.server.target_port) = self.get_target(self.server.token_plugin, self.path)
if self.server.token_plugin:
host, port = self.get_target(self.server.token_plugin, self.path)
if host == 'unix_socket':
self.server.unix_target = port

else:
self.server.target_host = host
self.server.target_port = port

if self.server.auth_plugin:
try:
Expand Down

0 comments on commit 72ce5c1

Please sign in to comment.