## websockify: WebSockets support for any application/server
websockify was formerly named wsproxy and was part of the
[noVNC](https://github.com/kanaka/noVNC) project.
At the most basic level, websockify just translates WebSockets traffic
to normal socket traffic. Websockify accepts the WebSockets handshake,
parses it, and then begins forwarding traffic between the client and
the target in both directions.
### WebSockets binary data
Starting with websockify 0.5.0, only the HyBi / IETF
6455 WebSocket protocol is supported.
Websockify negotiates whether to base64 encode traffic to and from the
client via the subprotocol header (Sec-WebSocket-Protocol). The valid
subprotocol values are 'binary' and 'base64' and if the client sends
both then the server (the python implementation) will prefer 'binary'.
The 'binary' subprotocol indicates that the data will be sent raw
using binary WebSocket frames. Some HyBi clients (such as the Flash
fallback and older Chrome and iOS versions) do not support binary data
which is why the negotiation is necessary.
### Encrypted WebSocket connections (wss://)
To encrypt the traffic using the WebSocket 'wss://' URI scheme you
need to generate a certificate for websockify to load. By default websockify
loads a certificate file name `self.pem` but the `--cert=CERT` option can
override the file name. You can generate a self-signed certificate using
openssl. When asked for the common name, use the hostname of the server where
the proxy will be running:
```
openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem
```
### Websock Javascript library
The `include/websock.js` Javascript library library provides a Websock
object that is similar to the standard WebSocket object but Websock
enables communication with raw TCP sockets (i.e. the binary stream)
via websockify. This is accomplished by base64 encoding the data
stream between Websock and websockify.
Websock has built-in receive queue buffering; the message event
does not contain actual data but is simply a notification that
there is new data available. Several rQ* methods are available to
read binary data off of the receive queue.
The Websock API is documented on the [websock.js API wiki page](https://github.com/kanaka/websockify/wiki/websock.js)
See the "Wrap a Program" section below for an example of using Websock
and websockify as a browser telnet client (`wstelnet.html`).
### Additional websockify features
These are not necessary for the basic operation.
* Daemonizing: When the `-D` option is specified, websockify runs
in the background as a daemon process.
* SSL (the wss:// WebSockets URI): This is detected automatically by
websockify by sniffing the first byte sent from the client and then
wrapping the socket if the data starts with '\x16' or '\x80'
(indicating SSL).
* Flash security policy: websockify detects flash security policy
requests (again by sniffing the first packet) and answers with an
appropriate flash security policy response (and then closes the
port). This means no separate flash security policy server is needed
for supporting the flash WebSockets fallback emulator.
* Session recording: This feature that allows recording of the traffic
sent and received from the client to a file using the `--record`
option.
* Mini-webserver: websockify can detect and respond to normal web
requests on the same port as the WebSockets proxy and Flash security
policy. This functionality is activate with the `--web DIR` option
where DIR is the root of the web directory to serve.
* Wrap a program: see the "Wrap a Program" section below.
### Implementations of websockify
The primary implementation of websockify is in python. There are
several alternate implementations in other languages (C, Node.js,
Clojure, Ruby) in the `other/` subdirectory (with varying levels of
functionality).
In addition there are several other external projects that implement
the websockify "protocol". See the alternate implementation [Feature
Matrix](https://github.com/kanaka/websockify/wiki/Feature_Matrix) for
more information.
### Wrap a Program
In addition to proxying from a source address to a target address
(which may be on a different system), websockify has the ability to
launch a program on the local system and proxy WebSockets traffic to
a normal TCP port owned/bound by the program.
The is accomplished with a small LD_PRELOAD library (`rebind.so`)
which intercepts bind() system calls by the program. The specified
port is moved to a new localhost/loopback free high port. websockify
then proxies WebSockets traffic directed to the original port to the
new (moved) port of the program.
The program wrap mode is invoked by replacing the target with `--`
followed by the program command line to wrap.
`./websockify 2023 -- PROGRAM ARGS`
The `--wrap-mode` option can be used to indicate what action to take
when the wrapped program exits or daemonizes.
Here is an example of using websockify to wrap the vncserver command
(which backgrounds itself) for use with
[noVNC](https://github.com/kanaka/noVNC):
`./websockify 5901 --wrap-mode=ignore -- vncserver -geometry 1024x768 :1`
Here is an example of wrapping telnetd (from krb5-telnetd).telnetd
exits after the connection closes so the wrap mode is set to respawn
the command:
`sudo ./websockify 2023 --wrap-mode=respawn -- telnetd -debug 2023`
The `wstelnet.html` page demonstrates a simple WebSockets based telnet
client.
### Building the Python ssl module (for python 2.5 and older)
* Install the build dependencies. On Ubuntu use this command:
`sudo aptitude install python-dev bluetooth-dev`
* Download, build the ssl module and symlink to it:
`cd websockify/`
`wget http://pypi.python.org/packages/source/s/ssl/ssl-1.15.tar.gz`
`tar xvzf ssl-1.15.tar.gz`
`cd ssl-1.15`
`make`
`cd ../`
`ln -sf ssl-1.15/build/lib.linux-*/ssl ssl`
没有合适的资源?快使用搜索试试~ 我知道了~
中国云操作系统最小内核开源项目,基于中国云标准API 中国云OS最小内核定位于打造成一个标准的最小化核心的基础云平台
共2000个文件
java:1975个
xml:12个
css:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 176 浏览量
2023-08-15
09:23:27
上传
评论
收藏 8.79MB ZIP 举报
温馨提示
中国云操作系统最小内核开源项目,基于中国云标准API。 中国云OS最小内核定位于打造成一个标准的最小化核心的基础云平台,功能组件包括计算、存储、网络、认证。
资源推荐
资源详情
资源评论
收起资源包目录
中国云操作系统最小内核开源项目,基于中国云标准API 中国云OS最小内核定位于打造成一个标准的最小化核心的基础云平台 (2000个子文件)
bootstrap.min.css 107KB
fontawesome.min.css 45KB
index.css 5KB
index.html 13KB
StoragePoolServiceImpl.java 69KB
SecuritySecurityClusterServiceImpl.java 54KB
NeutronProviderProxy.java 40KB
VolumeServiceImpl.java 30KB
ApiDocUtil.java 29KB
NeutronPortProvider.java 24KB
WorkFlowEngine.java 23KB
CinderProviderProxy.java 22KB
VmUtil.java 16KB
GcloudImageProvider.java 15KB
CephStorageDriver.java 14KB
RemoteNetworkDataSyncTimer.java 13KB
StorageFileDriver.java 13KB
CinderVolumeProvider.java 13KB
WorkFlowUtil.java 13KB
GlanceImageProvider.java 13KB
LvmStorageDriver.java 13KB
VolumeDao.java 12KB
SecuritySecurityClusterComponentServiceImpl.java 10KB
RemoteBlockStorageDataSyncTimer.java 10KB
NeutronSubnetProvider.java 10KB
LvmUtil.java 10KB
BaseWorkFlowCommand.java 10KB
ImageServiceImpl.java 9KB
NeutronSecurityGroupProvider.java 9KB
WorkFlowInstanceStep.java 9KB
SecurityClusterInstanceType.java 9KB
SnapshotServiceImpl.java 9KB
NetworkNodeUtil.java 9KB
NeutronRouterProvider.java 8KB
DetailInstance.java 8KB
MessageReceiver.java 8KB
NeutronFloatingIpProvider.java 8KB
GcloudVolumeProvider.java 8KB
CinderSnapshotProvider.java 8KB
NeutronNetworkProvider.java 8KB
QuartzConfiguration.java 8KB
WorkFlowInstanceStepDao.java 8KB
StoragePoolDao.java 8KB
CheckConnectStorageNodeTimer.java 8KB
LocalStorageDriver.java 7KB
GcloudIsoProvider.java 7KB
DiskCategoryDao.java 7KB
BaseWorkFlows.java 7KB
DiskQemuImgUtil.java 7KB
GcloudMqSimpleMessageConverter.java 7KB
SubnetDao.java 7KB
Volume.java 7KB
VmDetail.java 7KB
InstanceAttributesType.java 6KB
DisableSecurityClusterHaInitFlowCommand.java 6KB
DiskUtil.java 6KB
IsoServiceImpl.java 6KB
Iso.java 6KB
LocalPoolReportTimer.java 6KB
RedisNodesUtil.java 6KB
DetailNic.java 6KB
ApiCreateInstanceMsg.java 6KB
MqIdentity.java 6KB
AsyncBase.java 6KB
DetailDisk.java 6KB
BaseParams.java 6KB
StandardInstanceAttributesType.java 6KB
EipAddressSetType.java 6KB
BeanUtil.java 5KB
GcloudSnapshotProvider.java 5KB
GlanceProviderProxy.java 5KB
ApiUpdateLdapMsg.java 5KB
SimpleFlowChain.java 5KB
ComponentPackages.java 5KB
ApiCreateLdapMsg.java 5KB
IStoragePoolService.java 5KB
StorageLvmDriver.java 5KB
QuartzInitialize.java 5KB
StandardApiCreateInstanceMsg.java 5KB
NodeStoragePoolServiceImpl.java 5KB
Snapshot.java 5KB
StorageErrorCodes.java 5KB
ReflectionUtils.java 5KB
StorageMessageReceiver.java 5KB
RedisCacheContainer.java 5KB
SecurityClusterComponent.java 5KB
DetailEipAddressResponse.java 5KB
ResourceProviders.java 5KB
NetworkMessageReceiver.java 5KB
Image.java 5KB
SerializeUtils.java 5KB
FileStoreDriver.java 5KB
SnapshotDao.java 5KB
RemoteImagesDataSyncTimer.java 5KB
CustomAnnotations.java 4KB
DomainDetail.java 4KB
Consts.java 4KB
DetailIso.java 4KB
WorkFlowTemplate.java 4KB
UploadGlanceImageAsync.java 4KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6650
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功