Skip to content

Commit

Permalink
up proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Yi-love committed Nov 18, 2016
1 parent b71002a commit dc8a66e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
# dns-proxy-server
dns proxy server

dns server depend `os` , `dns` , `dgram` module on Node.js eenvironment。use `dgram` module create proxy server ,
`lookup()` function and `resolve4()` funtion will be resolve domain to ipv4.

```
npm install dns-proxy-server -g
```

### cmd

```
dnsproxy ip port
dnsproxy[ ip[ port]]
```

### arguments

* `ip` : ipv4 address , default depend on system.
* `port`: dns server bind the port if provide, default `53`.

### example

```
dnsproxy
//or
dnsproxy 8.8.8.8
//or
dnsproxy 8.8.8.8 53
```
3 changes: 2 additions & 1 deletion bin/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ if ( process.argv.length === 2 ) {
ip = process.argv[2];
port = process.argv[3];
}else{
console.log('arguments invalid. please use `dnsproxy[,ip[,port]]`');
console.log('arguments invalid. please use `dnsproxy[ ip[ port]]`');
return;
}

proxy.createProxyServer(ip , port);
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ exports.createProxyServer = function(ip , port){
rs = respond(rinfo);
dns.lookup( rq.domain , function(err , address , family){
if ( address !== void 0 ) {
console.log('address: ' , address);
console.log('address: ' , address , rq.domain);
return rs(rq , address);
}else{
dns.resolve4(rq.domain, function(error, addresses){
console.log('dns resolve4 server...');
if ( addresses === void 0 ) {
return console.log('missing...' , rq.domain);
}
console.log('address*: ' , addresses);
console.log('address[net]: ' , addresses , rq.domain);
return rs(rq , addresses);
});
}
Expand Down
8 changes: 4 additions & 4 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ var numify = function(ip) {
return parseInt(n, 10);
});

var result = 0;
var base = 1;

for (var i = ip.length-1; i >= 0; i--) {
var result = 0 ,base = 1;

for ( var i = ip.length-1; i >= 0; i-- ) {
result += ip[i]*base;
base *= 256;
}
// result = ip[0]*(1<<24) + ip[1]*(1<<16) + ip[2]*(1<<8) + ip[3];
return result;
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dns-proxy-server",
"version": "1.1.0",
"version": "1.1.1",
"description": "dns proxy server",
"main": "index.js",
"bin": {
Expand Down

0 comments on commit dc8a66e

Please sign in to comment.