Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "dnsproxy", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "A simple DNS proxy server for Node.js", | ||
@@ -9,5 +9,2 @@ "main": "proxy.js", | ||
}, | ||
"scripts": { | ||
"test": "sudo node test.js" | ||
}, | ||
"repository": { | ||
@@ -14,0 +11,0 @@ "type": "git", |
19
proxy.js
@@ -317,2 +317,4 @@ 'use strict'; | ||
//debug(rinfo.address, ":", "------ request ------"); | ||
if (msg.isAnswer() || msg.opcode() != 0) return; // 非标准查询请求 | ||
@@ -340,3 +342,5 @@ | ||
do { | ||
//debug(rinfo.address, ":", "want", domain); | ||
while (true) { | ||
if (addresses.hasOwnProperty(key)) { //尝试直接回复 | ||
@@ -349,8 +353,11 @@ address = addresses[key]; | ||
} | ||
} else { // 没有直接匹配的域名,尝试添加 * 匹配 | ||
} else if (parts.length) { // 没有直接匹配的域名,尝试添加 * 匹配 | ||
parts[0] = "*"; | ||
key = parts.join("."); | ||
parts.shift(); | ||
key = "*." + parts.join("."); | ||
} else { | ||
break; | ||
} | ||
} while (parts.length); | ||
}; | ||
@@ -361,2 +368,5 @@ resolve(domain); //向上游服务器请求地址 | ||
function pushAnswer(domain, address) { | ||
//debug(rinfo.address, ":", domain, "->", address); | ||
var rdata = encodeAddress(address); | ||
@@ -395,2 +405,3 @@ if (rdata) { | ||
function sendResponse() { | ||
//debug(rinfo.address, ":", "------ response ------"); | ||
var length; | ||
@@ -397,0 +408,0 @@ msg.flags = DNS_MESSAGE_FLAG_QR | DNS_MESSAGE_FLAG_AA | DNS_MESSAGE_FLAG_RD | DNS_MESSAGE_FLAG_RA; |
@@ -7,4 +7,3 @@ node-dnsproxy | ||
## Installation | ||
## 安装 | ||
## Installation 安装 | ||
@@ -17,4 +16,3 @@ ``` shell | ||
## Usage | ||
## 使用 | ||
## Usage 使用 | ||
@@ -34,23 +32,26 @@ ``` text | ||
## Pan-analytic | ||
## 泛解析 | ||
## Pan-analytic 泛解析 | ||
``` shell | ||
sudo dnsproxy -a *.a.com:127.0.0.1 *.b.a.com:127.0.0.2 & | ||
dig @localhost xx.a.com # return 127.0.0.1 | ||
dig @localhost xx.b.a.com # return 127.0.0.2 | ||
sudo dnsproxy -a "*.a.com:127.0.0.1" "*.b.a.com:127.0.0.2" "*:127.0.0.3" & | ||
dig @localhost xx.a.com # return 127.0.0.1 | ||
dig @localhost xx.b.a.com # return 127.0.0.2 | ||
dig @localhost any.other.domain # return 127.0.0.3 | ||
``` | ||
## Who am I | ||
## 我是谁 | ||
## Who am I 我是谁 | ||
When "ip" configuration is "localhost", node-dnsproxy returns the requesting host IP address | ||
当"ip"配置为"localhost"时,node-dnsproxy 返回请求主机的ip地址 | ||
When "ip" configuration is "proxyhost", node-dnsproxy returns the binding IP address of the server | ||
当"ip"配置为"proxyhost"时,node-dnsproxy 返回服务器绑定的ip地址 | ||
``` shell | ||
# start server on 192.168.1.1 | ||
sudo dnsproxy -a who.am.i:localhost who.you.are:proxyhost & | ||
sudo dnsproxy -a who.am.i:localhost who.are.you:proxyhost & | ||
# run on 192.168.1.2 | ||
dig @192.168.1.1 who.am.i # return 192.168.1.2 | ||
dig @192.168.1.1 who.you.are # return 192.168.1.1 | ||
dig @192.168.1.1 who.are.you # return 192.168.1.1 | ||
# run on 192.168.1.3 | ||
dig @192.168.1.1 who.am.i # return 192.168.1.3 | ||
dig @192.168.1.1 who.you.are # return 192.168.1.1 | ||
dig @192.168.1.1 who.are.you # return 192.168.1.1 | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19115
449
55