Deployed 461a645
with MkDocs version: 1.1.2
This commit is contained in:
@ -111,6 +111,11 @@
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="nav-item" data-level="2"><a href="#echo-server" class="nav-link">echo server</a>
|
||||
<ul class="nav flex-column">
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="nav-item" data-level="2"><a href="#websocket-proxy" class="nav-link">Websocket proxy</a>
|
||||
<ul class="nav flex-column">
|
||||
</ul>
|
||||
@ -311,6 +316,53 @@ Sec-WebSocket-Extensions: permessage-deflate; server_max_window_bits=15; client_
|
||||
Server: Python/3.7 websockets/8.0.2
|
||||
Upgrade: websocket
|
||||
</code></pre>
|
||||
<p>It is possible to pass custom HTTP header when doing the connection handshake,
|
||||
the remote server might process them to implement a simple authorization
|
||||
scheme.</p>
|
||||
<pre><code>src$ ws connect -H Authorization:supersecret ws://localhost:8008
|
||||
Type Ctrl-D to exit prompt...
|
||||
[2020-12-17 22:35:08.732] [info] Authorization: supersecret
|
||||
Connecting to url: ws://localhost:8008
|
||||
> [2020-12-17 22:35:08.736] [info] ws_connect: connected
|
||||
[2020-12-17 22:35:08.736] [info] Uri: /
|
||||
[2020-12-17 22:35:08.736] [info] Headers:
|
||||
[2020-12-17 22:35:08.736] [info] Connection: Upgrade
|
||||
[2020-12-17 22:35:08.736] [info] Sec-WebSocket-Accept: 2yaTFcdwn8KL6IzSMj2u6Le7KTg=
|
||||
[2020-12-17 22:35:08.736] [info] Sec-WebSocket-Extensions: permessage-deflate; server_max_window_bits=15; client_max_window_bits=15
|
||||
[2020-12-17 22:35:08.736] [info] Server: ixwebsocket/11.0.4 macos ssl/SecureTransport zlib 1.2.11
|
||||
[2020-12-17 22:35:08.736] [info] Upgrade: websocket
|
||||
[2020-12-17 22:35:08.736] [info] Received 25 bytes
|
||||
ws_connect: received message: Authorization suceeded!
|
||||
[2020-12-17 22:35:08.736] [info] Received pong ixwebsocket::heartbeat::30s::0
|
||||
hello
|
||||
> [2020-12-17 22:35:25.157] [info] Received 7 bytes
|
||||
ws_connect: received message: hello
|
||||
</code></pre>
|
||||
<p>If the wrong header is passed in, the server would close the connection with a custom close code (>4000, and <4999).</p>
|
||||
<pre><code>[2020-12-17 22:39:37.044] [info] Upgrade: websocket
|
||||
ws_connect: connection closed: code 4001 reason Permission denied
|
||||
</code></pre>
|
||||
<h2 id="echo-server">echo server</h2>
|
||||
<p>The ws echo server will respond what the client just sent him. If we use the
|
||||
simple --http_authorization_header we can enforce that client need to pass a
|
||||
special value in the Authorization header to connect.</p>
|
||||
<pre><code>$ ws echo_server --http_authorization_header supersecret
|
||||
[2020-12-17 22:35:06.192] [info] Listening on 127.0.0.1:8008
|
||||
[2020-12-17 22:35:08.735] [info] New connection
|
||||
[2020-12-17 22:35:08.735] [info] remote ip: 127.0.0.1
|
||||
[2020-12-17 22:35:08.735] [info] id: 0
|
||||
[2020-12-17 22:35:08.735] [info] Uri: /
|
||||
[2020-12-17 22:35:08.735] [info] Headers:
|
||||
[2020-12-17 22:35:08.735] [info] Authorization: supersecret
|
||||
[2020-12-17 22:35:08.735] [info] Connection: Upgrade
|
||||
[2020-12-17 22:35:08.735] [info] Host: localhost:8008
|
||||
[2020-12-17 22:35:08.735] [info] Sec-WebSocket-Extensions: permessage-deflate; server_max_window_bits=15; client_max_window_bits=15
|
||||
[2020-12-17 22:35:08.735] [info] Sec-WebSocket-Key: eFF2Gf25dC7eC15Ab1135G==
|
||||
[2020-12-17 22:35:08.735] [info] Sec-WebSocket-Version: 13
|
||||
[2020-12-17 22:35:08.735] [info] Upgrade: websocket
|
||||
[2020-12-17 22:35:08.735] [info] User-Agent: ixwebsocket/11.0.4 macos ssl/SecureTransport zlib 1.2.11
|
||||
[2020-12-17 22:35:25.157] [info] Received 7 bytes
|
||||
</code></pre>
|
||||
<h2 id="websocket-proxy">Websocket proxy</h2>
|
||||
<pre><code>ws proxy_server --remote_host ws://127.0.0.1:9000 -v
|
||||
Listening on 127.0.0.1:8008
|
||||
|
Reference in New Issue
Block a user