Skip to content

Commit

Permalink
Merge branch 'release/0.13.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
nwtgck committed Aug 20, 2019
2 parents b523bf8 + f2bfd12 commit 5fef423
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 44 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

## [Unreleased]

## [0.13.1] - 2019-08-20
### Changed
* Allow cross-origin for 400 responses

## [0.13.0] - 2019-08-19
### Fixed
* Add `X-Content-Type-Options: nosniff` header for disabling sniffing
Expand Down Expand Up @@ -216,7 +220,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
* Docker automated build on Docker Hub
* Support HTTPS

[Unreleased]: https://github.com/nwtgck/piping-server/compare/v0.13.0...HEAD
[Unreleased]: https://github.com/nwtgck/piping-server/compare/v0.13.1...HEAD
[0.13.1]: https://github.com/nwtgck/piping-server/compare/v0.13.0...v0.13.1
[0.13.0]: https://github.com/nwtgck/piping-server/compare/v0.12.0...v0.13.0
[0.12.0]: https://github.com/nwtgck/piping-server/compare/v0.11.6...v0.12.0
[0.11.6]: https://github.com/nwtgck/piping-server/compare/v0.11.5...v0.11.6
Expand Down
70 changes: 39 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,50 @@
# piping-server
[![npm](https://img.shields.io/npm/v/piping-server.svg)](https://www.npmjs.com/package/piping-server) [![CodeFactor](https://www.codefactor.io/repository/github/nwtgck/piping-server/badge)](https://www.codefactor.io/repository/github/nwtgck/piping-server) [![CircleCI](https://circleci.com/gh/nwtgck/piping-server.svg?style=shield)](https://circleci.com/gh/nwtgck/piping-server) [![Build status](https://ci.appveyor.com/api/projects/status/g075o30d5pp4m0pa?svg=true)](https://ci.appveyor.com/project/nwtgck/piping-server) [![Docker Automated build](https://img.shields.io/docker/automated/nwtgck/piping-server.svg)](https://hub.docker.com/r/nwtgck/piping-server/)
# Piping Server
[![npm](https://img.shields.io/npm/v/piping-server.svg)](https://www.npmjs.com/package/piping-server) [![CodeFactor](https://www.codefactor.io/repository/github/nwtgck/piping-server/badge)](https://www.codefactor.io/repository/github/nwtgck/piping-server) [![CircleCI](https://circleci.com/gh/nwtgck/piping-server.svg?style=shield)](https://circleci.com/gh/nwtgck/piping-server) [![Build status](https://ci.appveyor.com/api/projects/status/g075o30d5pp4m0pa?svg=true)](https://ci.appveyor.com/project/nwtgck/piping-server) [![GitHub Actions](https://github.com/nwtgck/piping-server/workflows/Node%20CI/badge.svg)](https://github.com/nwtgck/piping-server/actions) [![Docker Automated build](https://img.shields.io/docker/automated/nwtgck/piping-server.svg)](https://hub.docker.com/r/nwtgck/piping-server/)
[![](https://images.microbadger.com/badges/image/nwtgck/piping-server.svg)](https://microbadger.com/images/nwtgck/piping-server "Get your own image badge on microbadger.com") [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=nwtgck/piping-server)](https://dependabot.com)

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)

Streaming Data Transfer Server over HTTP/HTTPS

![piping server transfer](demo_images/piping-server.gif)

## Design Philosophy

Piping server is designed to realize the following three ideas.

1. Account-free
1. Install-free
1. Engineer friendly

Usually, when you want to send data to someone, you need to have an account in the common service among you and his/her.
In addition, the service may require you to install specific software to share the data.
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)

Streaming Data Transfer Server over HTTP/HTTPS

Piping server is designed to solve the problems above.
Piping server allows you to use without any account and frees you from additional software installation because the server is available with Web browsers, `curl` and `wget` commands, which are widely pre-installed in Unix-like OS.
Because of HTTP/HTTPS, users can send data across different devices such as Windows, macOS, Unix, Linux, iOS, Android and any device which uses HTTP.
Furthermore, pipe in Unix-like OS allows you to send data in a more efficient and secure way.
![Piping Server transfer](demo_images/piping-server.gif)

## Transfer example
## How to transfer data?

Suppose a Piping server is running on <https://piping.glitch.me>. You can send "hello.txt" to a receiver.
Suppose a Piping Server is running on <https://piping.ml>. You can send "hello.txt" to a receiver.

```bash
# Send
cat hello.txt | curl -T - https://piping.glitch.me/mysecret
cat hello.txt | curl -T - https://piping.ml/mysecret
```

```bash
# Get
curl https://piping.glitch.me/mysecret > myhello.txt
curl https://piping.ml/mysecret > myhello.txt
```

## Multiple Transfer

Piping server supports multiple receiver. The following moving image is an example. Use query parameter "?n=3" to allow 3 receivers for example.
Piping Server supports multiple receiver. The following moving image is an example. Use query parameter "?n=3" to allow 3 receivers for example.

![Piping server multiple transfer](demo_images/piping-server-multi-transfer.gif)
![Piping Server multiple transfer](demo_images/piping-server-multi-transfer.gif)

## Design Philosophy

Piping Server is designed to realize the following ideas.

1. No account
1. No installation
1. Never store data
1. Engineer friendly

Usually, when you want to send data to someone, you need to have an account in the common service among you and his/her.
In addition, the service may require you to install specific software to share the data.


Piping Server is designed to solve the problems above.
Piping Server allows you to use without any account and frees you from additional software installation because the server is available with Web browsers, `curl` and `wget` commands, which are widely pre-installed in Unix-like OS.
Because of HTTP/HTTPS, users can send data across different devices such as Windows, macOS, Unix, Linux, iOS, Android and any device which uses HTTP.
Furthermore, pipe in Unix-like OS allows you to send data in a more efficient and secure way.

## Engineer Friendly Help

Expand All @@ -61,7 +62,7 @@ curl piping.ml/version

### Heroku deployment

Click the botton below to deploy a Piping server to Heroku.
Click the button below to deploy a Piping Server to Heroku.

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)

Expand All @@ -74,7 +75,7 @@ npm install -g piping-server
# Run a server
piping-server
```
Then, a Piping server is running on <http://localhost:8080>.
Then, a Piping Server is running on <http://localhost:8080>.

### Command-line Options

Expand All @@ -93,7 +94,7 @@ Options:

### Run on Docker

Run a Piping server on <http://localhost:8181> by the following command.
Run a Piping Server on <http://localhost:8181> by the following command.

```bash
docker run -p 8181:8080 nwtgck/piping-server
Expand All @@ -110,3 +111,10 @@ You can run a server in background and it automatically always restarts.
```bash
docker run -p 8181:80 -d --restart=always nwtgck/piping-server --http-port=80
```

## More about Piping Server

[Ecosystem around Piping Server · nwtgck/piping-server Wiki](https://github.com/nwtgck/piping-server/wiki/Ecosystem-around-Piping-Server)
This contains end-to-end encrypted chat/file transfer/screen sharing/voice chat/drawing share and some English and Japanese posts.

Piping Server is simple and streams any kind of data, not limited to a file.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "piping-server",
"version": "0.13.0",
"version": "0.13.1",
"description": "Streaming Data Transfer Server over HTTP/HTTPS",
"bin": {
"piping-server": "dist/src/index.js"
Expand Down
38 changes: 28 additions & 10 deletions src/piping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const indexPage: string =
// tslint:disable-next-line:no-shadowed-variable
function generateHelpPage(url: string): string {
return (
`Help for piping-server ${VERSION}
`Help for Piping Server ${VERSION}
(Repository: https://github.com/nwtgck/piping-server)
======= Get =======
Expand Down Expand Up @@ -232,7 +232,9 @@ export class Server {
case "POST":
case "PUT":
if (RESERVED_PATHS.includes(reqPath)) {
res.writeHead(400);
res.writeHead(400, {
"Access-Control-Allow-Origin": "*"
});
res.end(`[ERROR] Cannot send to the reserved path '${reqPath}'. (e.g. '/mypath123')\n` as any);
} else {
// Handle a sender
Expand Down Expand Up @@ -449,10 +451,14 @@ export class Server {
const nReceivers = Server.getNReceivers(req.url);
// If the number of receivers is invalid
if (nReceivers <= 0) {
res.writeHead(400);
res.writeHead(400, {
"Access-Control-Allow-Origin": "*"
});
res.end(`[ERROR] n should > 0, but n = ${nReceivers}.\n` as any);
} else if (reqPath in this.pathToEstablished) {
res.writeHead(400);
res.writeHead(400, {
"Access-Control-Allow-Origin": "*"
});
res.end(`[ERROR] Connection on '${reqPath}' has been established already.\n` as any);
} else {
// If the path connection is connecting
Expand Down Expand Up @@ -482,13 +488,17 @@ export class Server {
this.runPipe(reqPath, pipe);
}
} else {
res.writeHead(400);
res.writeHead(400, {
"Access-Control-Allow-Origin": "*"
});
res.end(
`[ERROR] The number of receivers should be ${unestablishedPipe.nReceivers} but ${nReceivers}.\n` as any
);
}
} else {
res.writeHead(400);
res.writeHead(400, {
"Access-Control-Allow-Origin": "*"
});
res.end(`[ERROR] Another sender has been connected on '${reqPath}'.\n` as any);
}
} else {
Expand Down Expand Up @@ -521,10 +531,14 @@ export class Server {
const nReceivers = Server.getNReceivers(req.url);
// If the number of receivers is invalid
if (nReceivers <= 0) {
res.writeHead(400);
res.writeHead(400, {
"Access-Control-Allow-Origin": "*"
});
res.end(`[ERROR] n should > 0, but n = ${nReceivers}.\n` as any);
} else if (reqPath in this.pathToEstablished) {
res.writeHead(400);
res.writeHead(400, {
"Access-Control-Allow-Origin": "*"
});
res.end(`[ERROR] Connection on '${reqPath}' has been established already.\n` as any);
} else {
// If the path connection is connecting
Expand Down Expand Up @@ -554,11 +568,15 @@ export class Server {
this.runPipe(reqPath, pipe);
}
} else {
res.writeHead(400);
res.writeHead(400, {
"Access-Control-Allow-Origin": "*"
});
res.end("[ERROR] The number of receivers has reached limits.\n" as any);
}
} else {
res.writeHead(400);
res.writeHead(400, {
"Access-Control-Allow-Origin": "*"
});
res.end(
`[ERROR] The number of receivers should be ${unestablishedPipe.nReceivers} but ${nReceivers}.\n` as any
);
Expand Down
15 changes: 15 additions & 0 deletions test/piping.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ describe("piping.Server", () => {
});
// Should be failed
assert.strictEqual(req.statusCode, 400);
assert.strictEqual(req.headers["access-control-allow-origin"], "*");
}
});
});
Expand Down Expand Up @@ -488,6 +489,7 @@ describe("piping.Server", () => {

// Should be rejected
assert.strictEqual(sendData.statusCode, 400);
assert.strictEqual(sendData.headers["access-control-allow-origin"], "*");

// Quit get request
getReq1.abort();
Expand All @@ -508,6 +510,7 @@ describe("piping.Server", () => {

// Should be rejected
assert.strictEqual(sendData.statusCode, 400);
assert.strictEqual(sendData.headers["access-control-allow-origin"], "*");

// Quit get request
getReq1.abort();
Expand Down Expand Up @@ -536,6 +539,7 @@ describe("piping.Server", () => {

// Should be rejected
assert.strictEqual(data1.statusCode, 400);
assert.strictEqual(data1.headers["access-control-allow-origin"], "*");

// Quit send request
sendReq.abort();
Expand Down Expand Up @@ -564,6 +568,7 @@ describe("piping.Server", () => {

// Should be rejected
assert.strictEqual(data1.statusCode, 400);
assert.strictEqual(data1.headers["access-control-allow-origin"], "*");

// Quit send request
sendReq.abort();
Expand All @@ -589,6 +594,7 @@ describe("piping.Server", () => {
);
// Should be rejected
assert.strictEqual((await getReqPromise3).statusCode, 400);
assert.strictEqual((await getReqPromise3).headers["access-control-allow-origin"], "*");
// Quit get requests
getReq1.abort();
getReq2.abort();
Expand All @@ -614,6 +620,7 @@ describe("piping.Server", () => {
);
// Should be rejected
assert.strictEqual((await getReqPromise3).statusCode, 400);
assert.strictEqual((await getReqPromise3).headers["access-control-allow-origin"], "*");
// Quit get requests
getReq1.abort();
getReq2.abort();
Expand All @@ -638,6 +645,7 @@ describe("piping.Server", () => {

// Should be rejected
assert.strictEqual(sendData.statusCode, 400);
assert.strictEqual(sendData.headers["access-control-allow-origin"], "*");

// Quit get requests
getReq1.abort();
Expand All @@ -663,6 +671,7 @@ describe("piping.Server", () => {

// Should be rejected
assert.strictEqual(sendData.statusCode, 400);
assert.strictEqual(sendData.headers["access-control-allow-origin"], "*");

// Quit get requests
getReq1.abort();
Expand Down Expand Up @@ -694,6 +703,7 @@ describe("piping.Server", () => {

// Should be rejected
assert.strictEqual(data2.statusCode, 400);
assert.strictEqual(data2.headers["access-control-allow-origin"], "*");

// Quit get request
getReq1.abort();
Expand Down Expand Up @@ -726,6 +736,7 @@ describe("piping.Server", () => {

// Should be rejected
assert.strictEqual(data2.statusCode, 400);
assert.strictEqual(data2.headers["access-control-allow-origin"], "*");

// Quit get request
getReq1.abort();
Expand Down Expand Up @@ -768,6 +779,7 @@ describe("piping.Server", () => {

// Should be bad request
assert.strictEqual(data3.statusCode, 400);
assert.strictEqual(data3.headers["access-control-allow-origin"], "*");
});

// tslint:disable-next-line:max-line-length
Expand Down Expand Up @@ -795,6 +807,7 @@ describe("piping.Server", () => {

// Should be bad request
assert.strictEqual(data3.statusCode, 400);
assert.strictEqual(data3.headers["access-control-allow-origin"], "*");
});

it("should unregister a sender before establishing", async () => {
Expand Down Expand Up @@ -860,6 +873,7 @@ describe("piping.Server", () => {

// Should be rejected
assert.strictEqual(res.statusCode, 400);
assert.strictEqual(res.headers["access-control-allow-origin"], "*");
});

it("should not allow n=-1", async () => {
Expand All @@ -870,6 +884,7 @@ describe("piping.Server", () => {

// Should be rejected
assert.strictEqual(res.statusCode, 400);
assert.strictEqual(res.headers["access-control-allow-origin"], "*");
});
});

Expand Down

0 comments on commit 5fef423

Please sign in to comment.