Compare commits

...

13 Commits

Author SHA1 Message Date
James Coglan dc392490a8 Bump version to 0.11.0 and drop support for Node < 0.8. 2016-02-24 08:34:09 +00:00
James Coglan 0feee7974c Bump the copyright year. 2016-02-06 19:15:41 +00:00
James Coglan 91d8e1ad41 Use https: URLs for github.com in package.json. 2016-02-06 18:11:32 +00:00
James Coglan c27fee0680 Document the net option to the Client class. 2016-02-06 18:11:17 +00:00
James Coglan 061494bc2c Introduce a 'net' option that can be used to pass through options to net.connect(). 2016-02-06 15:51:18 +00:00
James Coglan 958d3a458f Use the same guarded assignment pattern for all socket options we interfere with. 2016-02-06 13:43:56 +00:00
James Coglan 2d945cff5d Merge pull request #50 from lazyfrosch/support-sni
Support SNI communication with a webserver
2016-02-06 13:42:43 +00:00
Markus Frosch d3340cdd63 Support SNI communication with a webserver
The option servername has to be set in order for connecting to a
webserver that requires SNI for certificate selection.

Also see here:
https://nodejs.org/api/tls.html#tls_tls_connect_port_host_options_callback
2015-12-21 11:23:48 +01:00
James Coglan 0d15d7a3ec Add checks for the headers and status to the tests. 2015-11-25 22:24:52 +00:00
James Coglan cdc7f0891b Remove deflate config from example server; I must have accidentally committed this. 2015-11-25 21:58:09 +00:00
James Coglan f8c5b86e10 Create CODE_OF_CONDUCT.md. 2015-11-08 12:15:58 +00:00
James Coglan 53db3d6c25 Test on Node 5. 2015-11-05 21:22:50 +00:00
James Coglan dcb3375dda Run tests on major versions of iojs and node 4. 2015-10-17 13:01:07 +01:00
7 changed files with 48 additions and 24 deletions
+6 -1
View File
@@ -1,7 +1,12 @@
sudo: false
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.12"
- "iojs"
- "iojs-1"
- "iojs-2"
- "iojs-3"
- "4"
- "5"
+4
View File
@@ -1,3 +1,7 @@
### 0.11.0 / 2016-02-24
* Introduce a `net` option to the `Client` class for setting things like, say, `servername`
### 0.10.0 / 2015-07-08
* Add the standard `code` and `reason` parameters to the `close` method
+4
View File
@@ -0,0 +1,4 @@
# Code of Conduct
All projects under the [Faye](https://github.com/faye) umbrella are covered by
the [Code of Conduct](https://github.com/faye/code-of-conduct).
+10 -7
View File
@@ -9,7 +9,7 @@ This is a general-purpose WebSocket implementation extracted from the
[Faye](http://faye.jcoglan.com) project. It provides classes for easily building
WebSocket servers and clients in Node. It does not provide a server itself, but
rather makes it easy to handle WebSocket connections within an existing
[Node](http://nodejs.org/) application. It does not provide any abstraction
[Node](https://nodejs.org/) application. It does not provide any abstraction
other than the standard [WebSocket API](http://dev.w3.org/html5/websockets/).
It also provides an abstraction for handling
@@ -130,8 +130,8 @@ var ws = new WebSocket.Client('ws://www.example.com/', [], {
});
```
The `tls` value is a Node 'TLS options' object that will be passed to
[`tls.connect()`](http://nodejs.org/api/tls.html#tls_tls_connect_options_callback).
The `tls` value is an object that will be passed to
[`tls.connect()`](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback).
## Subprotocol negotiation
@@ -198,9 +198,12 @@ var ws = new WebSocket.Client(url, protocols, options);
The client accepts some additional options:
* `proxy` - settings for a proxy as described above
* `tls` - a Node 'TLS options' object containing TLS settings for the origin
server, this will be passed to
[`tls.connect()`](http://nodejs.org/api/tls.html#tls_tls_connect_options_callback)
* `net` - an object containing settings for the origin server that will be
passed to
[`net.connect()`](https://nodejs.org/api/net.html#net_socket_connect_options_connectlistener)
* `tls` - an object containing TLS settings for the origin server, this will be
passed to
[`tls.connect()`](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback)
* `ca` - (legacy) a shorthand for passing `{tls: {ca: value}}`
@@ -316,7 +319,7 @@ some data over the wire to keep the connection alive.
(The MIT License)
Copyright (c) 2010-2015 James Coglan
Copyright (c) 2010-2016 James Coglan
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the 'Software'), to deal in
+15 -10
View File
@@ -22,20 +22,25 @@ var Client = function(_url, protocols, options) {
});
}, this);
var proxy = options.proxy || {},
endpoint = url.parse(proxy.origin || this.url),
port = endpoint.port || DEFAULT_PORTS[endpoint.protocol],
secure = SECURE_PROTOCOLS.indexOf(endpoint.protocol) >= 0,
onConnect = function() { self._onConnect() },
originTLS = options.tls || {},
socketTLS = proxy.origin ? (proxy.tls || {}) : originTLS,
self = this;
var proxy = options.proxy || {},
endpoint = url.parse(proxy.origin || this.url),
port = endpoint.port || DEFAULT_PORTS[endpoint.protocol],
secure = SECURE_PROTOCOLS.indexOf(endpoint.protocol) >= 0,
onConnect = function() { self._onConnect() },
netOptions = options.net || {},
originTLS = options.tls || {},
socketTLS = proxy.origin ? (proxy.tls || {}) : originTLS,
self = this;
netOptions.host = socketTLS.host = endpoint.hostname;
netOptions.port = socketTLS.port = port;
originTLS.ca = originTLS.ca || options.ca;
socketTLS.servername = socketTLS.servername || endpoint.hostname;
this._stream = secure
? tls.connect(port, endpoint.hostname, socketTLS, onConnect)
: net.connect(port, endpoint.hostname, onConnect);
? tls.connect(socketTLS, onConnect)
: net.connect(netOptions, onConnect);
if (proxy.origin) this._configureProxy(proxy, originTLS);
+4 -4
View File
@@ -1,12 +1,12 @@
{ "name" : "faye-websocket"
, "description" : "Standards-compliant WebSocket server and client"
, "homepage" : "http://github.com/faye/faye-websocket-node"
, "homepage" : "https://github.com/faye/faye-websocket-node"
, "author" : "James Coglan <jcoglan@gmail.com> (http://jcoglan.com/)"
, "keywords" : ["websocket", "eventsource"]
, "license" : "MIT"
, "version" : "0.10.0"
, "engines" : {"node": ">=0.4.0"}
, "version" : "0.11.0"
, "engines" : {"node": ">=0.8.0"}
, "main" : "./lib/faye/websocket"
, "dependencies" : {"websocket-driver": ">=0.5.1"}
, "devDependencies" : {"jstest": "", "pace": "", "permessage-deflate": ""}
@@ -17,5 +17,5 @@
, "url" : "git://github.com/faye/faye-websocket-node.git"
}
, "bugs" : "http://github.com/faye/faye-websocket-node/issues"
, "bugs" : "https://github.com/faye/faye-websocket-node/issues"
}
+5 -2
View File
@@ -73,8 +73,11 @@ var WebSocketSteps = test.asyncSteps({
this._ws.close()
},
check_open: function(callback) {
check_open: function(status, headers, callback) {
this.assert( this._open )
this.assertEqual( status, this._ws.statusCode )
for (var name in headers)
this.assertEqual( headers[name], this._ws.headers[name.toLowerCase()] )
callback()
},
@@ -154,7 +157,7 @@ test.describe("Client", function() { with(this) {
sharedBehavior("socket client", function() { with(this) {
it("can open a connection", function() { with(this) {
open_socket(socket_url, protocols)
check_open()
check_open(101, {"Upgrade": "websocket"})
check_protocol("echo")
}})