mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-12 00:17:56 -05:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6b869738c | ||
|
|
a169050947 | ||
|
|
873fdc55ed | ||
|
|
f78a575f66 | ||
|
|
d33a619905 | ||
|
|
3951a79359 | ||
|
|
6fa026fc94 | ||
|
|
47161a65d4 | ||
|
|
cf39362014 | ||
|
|
4d01b2c84c | ||
|
|
82271921db | ||
|
|
1150eb50e9 | ||
|
|
9c1e73c752 |
24
.github/workflows/ci.yml
vendored
Normal file
24
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test-node:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [10.x, 12.x, 14.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
env:
|
||||
CI: true
|
||||
12
.travis.yml
12
.travis.yml
@@ -1,12 +0,0 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- '8'
|
||||
- '10'
|
||||
notifications:
|
||||
irc: "irc.freenode.org#socket.io"
|
||||
git:
|
||||
depth: 1
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
15
CHANGELOG.md
Normal file
15
CHANGELOG.md
Normal file
@@ -0,0 +1,15 @@
|
||||
## [2.4.1](https://github.com/socketio/socket.io/compare/2.4.0...2.4.1) (2021-01-07)
|
||||
|
||||
|
||||
### Reverts
|
||||
|
||||
* fix(security): do not allow all origins by default ([a169050](https://github.com/socketio/socket.io/commit/a1690509470e9dd5559cec4e60908ca6c23e9ba0))
|
||||
|
||||
|
||||
# [2.4.0](https://github.com/socketio/socket.io/compare/2.3.0...2.4.0) (2021-01-04)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **security:** do not allow all origins by default ([f78a575](https://github.com/socketio/socket.io/commit/f78a575f66ab693c3ea96ea88429ddb1a44c86c7))
|
||||
* properly overwrite the query sent in the handshake ([d33a619](https://github.com/socketio/socket.io/commit/d33a619905a4905c153d4fec337c74da5b533a9e))
|
||||
@@ -2,7 +2,7 @@
|
||||
# socket.io
|
||||
|
||||
[](#backers) [](#sponsors)
|
||||
[](https://travis-ci.org/socketio/socket.io)
|
||||
[](https://github.com/socketio/socket.io/actions)
|
||||
[](https://david-dm.org/socketio/socket.io)
|
||||
[](https://david-dm.org/socketio/socket.io#info=devDependencies)
|
||||
[](https://www.npmjs.com/package/socket.io)
|
||||
|
||||
@@ -78,7 +78,7 @@ Exposed by `require('socket.io')`.
|
||||
- `path` _(String)_: name of the path to capture (`/socket.io`)
|
||||
- `serveClient` _(Boolean)_: whether to serve the client files (`true`)
|
||||
- `adapter` _(Adapter)_: the adapter to use. Defaults to an instance of the `Adapter` that ships with socket.io which is memory based. See [socket.io-adapter](https://github.com/socketio/socket.io-adapter)
|
||||
- `origins` _(String)_: the allowed origins (`*`)
|
||||
- `origins` _(String)_: the allowed origins (`*:*`)
|
||||
- `parser` _(Parser)_: the parser to use. Defaults to an instance of the `Parser` that ships with socket.io. See [socket.io-parser](https://github.com/socketio/socket.io-parser).
|
||||
|
||||
Works with and without `new`:
|
||||
@@ -635,7 +635,7 @@ Emits an event to the socket identified by the string name. Any other parameters
|
||||
|
||||
```js
|
||||
socket.emit('hello', 'world');
|
||||
socket.emit('with-binary', 1, '2', { 3: '4', 5: new Buffer(6) });
|
||||
socket.emit('with-binary', 1, '2', { 3: '4', 5: Buffer.alloc(6) });
|
||||
```
|
||||
|
||||
The `ack` argument is optional and will be called with the client's answer.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"main": "index.js",
|
||||
"author": "Grant Timmerman",
|
||||
"private": true,
|
||||
"license": "BSD",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"express": "4.13.4",
|
||||
"socket.io": "^1.7.2",
|
||||
|
||||
@@ -14,7 +14,7 @@ They are tested with various payloads:
|
||||
|
||||
- string: `['1', '2', ... '1000']`
|
||||
- numeric: `[1, 2, ... 1000]`
|
||||
- binary: `new Buffer(1000), where buf[i] = i`
|
||||
- binary: `Buffer.allocUnsafe(1000), where buf[i] = i`
|
||||
|
||||
## How to use
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ let server4 = io(3004, {
|
||||
|
||||
let string = [];
|
||||
let numeric = [];
|
||||
let binary = new Buffer(1e3);
|
||||
let binary = Buffer.allocUnsafe(1e3);
|
||||
for (var i = 0; i < 1e3; i++) {
|
||||
string.push('' + i);
|
||||
numeric.push(i);
|
||||
|
||||
@@ -116,7 +116,7 @@ Socket.prototype.buildHandshake = function(query){
|
||||
function buildQuery(){
|
||||
var requestQuery = url.parse(self.request.url, true).query;
|
||||
//if socket-specific query exist, replace query strings in requestQuery
|
||||
return Object.assign({}, query, requestQuery);
|
||||
return Object.assign({}, requestQuery, query);
|
||||
}
|
||||
return {
|
||||
headers: this.request.headers,
|
||||
|
||||
3352
package-lock.json
generated
Normal file
3352
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "socket.io",
|
||||
"version": "2.2.0",
|
||||
"version": "2.4.1",
|
||||
"description": "node.js realtime framework server",
|
||||
"keywords": [
|
||||
"realtime",
|
||||
@@ -25,11 +25,11 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "~4.1.0",
|
||||
"engine.io": "~3.3.1",
|
||||
"engine.io": "~3.5.0",
|
||||
"has-binary2": "~1.0.2",
|
||||
"socket.io-adapter": "~1.1.0",
|
||||
"socket.io-client": "2.2.0",
|
||||
"socket.io-parser": "~3.3.0"
|
||||
"socket.io-client": "2.4.0",
|
||||
"socket.io-parser": "~3.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"expect.js": "0.3.1",
|
||||
|
||||
@@ -23,7 +23,7 @@ function client(srv, nsp, opts){
|
||||
|
||||
describe('socket.io', function(){
|
||||
|
||||
it('should be the same version as client', function(){
|
||||
it.skip('should be the same version as client', function(){
|
||||
var version = require('../package').version;
|
||||
expect(version).to.be(require('socket.io-client/package').version);
|
||||
});
|
||||
@@ -1126,7 +1126,7 @@ describe('socket.io', function(){
|
||||
sio.on('connection', function(s){
|
||||
fs.readFile(join(__dirname, 'support', 'doge.jpg'), function(err, data){
|
||||
if (err) return done(err);
|
||||
var buf = new Buffer('asdfasdf', 'utf8');
|
||||
var buf = Buffer.from('asdfasdf', 'utf8');
|
||||
s.emit('multiple', 1, data, '3', [4], buf, [data, 'swag', buf]);
|
||||
});
|
||||
});
|
||||
@@ -1143,7 +1143,7 @@ describe('socket.io', function(){
|
||||
expect(Buffer.isBuffer(a)).to.be(true);
|
||||
done();
|
||||
});
|
||||
var buf = new Buffer('abcdefg', 'utf8');
|
||||
var buf = Buffer.from('abcdefg', 'utf8');
|
||||
socket.emit('buff', buf);
|
||||
});
|
||||
});
|
||||
@@ -1168,7 +1168,7 @@ describe('socket.io', function(){
|
||||
});
|
||||
fs.readFile(join(__dirname, 'support', 'doge.jpg'), function(err, data){
|
||||
if (err) return done(err);
|
||||
var buf = new Buffer('asdfasdf', 'utf8');
|
||||
var buf = Buffer.from('asdfasdf', 'utf8');
|
||||
socket.emit('multiple', 1, data, '3', [4], buf, [data, 'swag', buf]);
|
||||
});
|
||||
});
|
||||
@@ -1496,7 +1496,7 @@ describe('socket.io', function(){
|
||||
expect(Buffer.isBuffer(buf)).to.be(true);
|
||||
fn(1, 2);
|
||||
});
|
||||
socket.emit('woot', new Buffer(3), function(a, b){
|
||||
socket.emit('woot', Buffer.alloc(3), function(a, b){
|
||||
expect(a).to.be(1);
|
||||
expect(b).to.be(2);
|
||||
done();
|
||||
@@ -1515,7 +1515,7 @@ describe('socket.io', function(){
|
||||
expect(Buffer.isBuffer(a)).to.be(true);
|
||||
fn();
|
||||
});
|
||||
s.emit('hi', new Buffer(4), function(){
|
||||
s.emit('hi', Buffer.alloc(4), function(){
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -1529,7 +1529,7 @@ describe('socket.io', function(){
|
||||
var socket = client(srv);
|
||||
sio.on('connection', function(s){
|
||||
socket.on('hi', function(fn){
|
||||
fn(new Buffer(1));
|
||||
fn(Buffer.alloc(1));
|
||||
});
|
||||
s.emit('hi', function(a){
|
||||
expect(Buffer.isBuffer(a)).to.be(true);
|
||||
@@ -1546,7 +1546,7 @@ describe('socket.io', function(){
|
||||
var socket = client(srv);
|
||||
sio.on('connection', function(s){
|
||||
s.on('woot', function(fn){
|
||||
fn(new Buffer(2));
|
||||
fn(Buffer.alloc(2));
|
||||
});
|
||||
socket.emit('woot', function(a){
|
||||
expect(Buffer.isBuffer(a)).to.be(true);
|
||||
@@ -1621,8 +1621,25 @@ describe('socket.io', function(){
|
||||
expect(s.handshake.query.key2).to.be('&=bb');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should see the query options sent in the Socket.IO handshake (specific to the given socket)', (done) => {
|
||||
const srv = http();
|
||||
const sio = io(srv);
|
||||
const socket = client(srv, '/namespace',{ query: { key1: 'a', key2: 'b' }}); // manager-specific query option
|
||||
socket.query = { key2: 'c' }; // socket-specific query option
|
||||
|
||||
const success = () => {
|
||||
sio.close();
|
||||
socket.close();
|
||||
done();
|
||||
}
|
||||
|
||||
sio.of('/namespace').on('connection', (s) => {
|
||||
expect(s.handshake.query.key1).to.be('a'); // in the query params
|
||||
expect(s.handshake.query.key2).to.be('c'); // in the Socket.IO handshake
|
||||
success();
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle very large json', function(done){
|
||||
@@ -1899,7 +1916,7 @@ describe('socket.io', function(){
|
||||
});
|
||||
|
||||
function emit(){
|
||||
sio.emit('bin', new Buffer(10));
|
||||
sio.emit('bin', Buffer.alloc(10));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -2083,8 +2100,8 @@ describe('socket.io', function(){
|
||||
socket.join(room, fn);
|
||||
});
|
||||
socket.on('broadcast', function(){
|
||||
socket.broadcast.to('test').emit('bin', new Buffer(5));
|
||||
socket.emit('bin2', new Buffer(5));
|
||||
socket.broadcast.to('test').emit('bin', Buffer.alloc(5));
|
||||
socket.emit('bin2', Buffer.alloc(5));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user