Skip to content

Commit e3c8210

Browse files
committed
commit of version 0.1.0
1 parent f86a7f3 commit e3c8210

File tree

10 files changed

+808
-25
lines changed

10 files changed

+808
-25
lines changed

.gitignore

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,3 @@
1-
# Logs
2-
logs
3-
*.log
4-
5-
# Runtime data
6-
pids
7-
*.pid
8-
*.seed
9-
10-
# Directory for instrumented libs generated by jscoverage/JSCover
11-
lib-cov
12-
13-
# Coverage directory used by tools like istanbul
14-
coverage
15-
16-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17-
.grunt
18-
19-
# Compiled binary addons (http://nodejs.org/api/addons.html)
20-
build/Release
21-
22-
# Dependency directory
23-
# Deployed apps should consider commenting this line out:
24-
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
251
node_modules
2+
#WebStorm project files
3+
.idea/

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.gitignore
2+
#WebStorm project files
3+
.idea/

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,41 @@
1-
proxy.stream
1+
proxy-stream
22
============
33

44
It's a nodejs proxy, implemented steam interface, supports socks4, socks4a, socks5 and http.
5+
6+
## How to use
7+
8+
Use `new Proxy({ type: 'direct' })` to create a proxy stream.
9+
10+
###Example 1: direct access
11+
12+
It start an proxy on port 2000;
13+
14+
```js
15+
var net = require('net');
16+
var Proxy = require('proxy.stream').Proxy;
17+
net.createServer(function (s) {
18+
var proxy = new Proxy(); //it's equal to new Proxy({ type: 'direct' })
19+
s.pipe(proxy).pipe(s);
20+
}).listen(2000, function () {
21+
console.log('http/socks4/socks5 proxy listening on port 2000');
22+
});
23+
```
24+
25+
###Example 2: access throw another proxy
26+
27+
It turns the socks5 proxy [localhost:2000] to another proxy supports http/socks4/socks5!
28+
29+
```js
30+
var net = require('net');
31+
var Proxy = require('proxy.stream').Proxy;
32+
net.createServer(function (s) {
33+
s.pipe(new Proxy({ type: 'socks5', host: 'localhost', port: 2000 })).pipe(s);
34+
}).listen(8080, function () {
35+
console.log('http/socks4/socks5 proxy listening on port 8080');
36+
});
37+
```
38+
39+
###More
40+
41+
This is a stream, it can be used simply in multiple scenarios.

example.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Author : Lijian Qiu
2+
// Email : loye.qiu@gmail.com
3+
// Description : examples of creating proxy server
4+
5+
var net = require('net');
6+
7+
var Proxy = require('./').Proxy;
8+
9+
//Example 1: direct access
10+
net.createServer(function (s) {
11+
var proxy = new Proxy(); //it's equal to new Proxy({ type: 'direct' })
12+
s.pipe(proxy).pipe(s);
13+
}).listen(2000, function () {
14+
console.log('http/socks4/socks5 proxy listening on port 2000');
15+
});
16+
17+
//Example 2: access throw another proxy
18+
net.createServer(function (s) {
19+
s.pipe(new Proxy({ type: 'socks5', host: 'localhost', port: 2000 })).pipe(s);
20+
}).listen(8080, function () {
21+
console.log('http/socks4/socks5 proxy listening on port 8080');
22+
});

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Author : Lijian Qiu
2+
// Email : loye.qiu@gmail.com
3+
// Description :
4+
5+
6+
//exports
7+
exports.Proxy = require('./lib/proxy').Proxy;

0 commit comments

Comments
 (0)