Permalink
Browse files

getting rid of the require.paths silliness.

  • Loading branch information...
1 parent 04f5e6b commit 50427edd7f0e3f7ecc2ba7dbc62a8348effedb78 @itsnotlupus committed Jul 17, 2011
Showing with 26 additions and 22 deletions.
  1. +10 −1 build.sh
  2. +1 −1 lib/ndns/ndns_client.js
  3. +3 −3 lib/nmcdns.js
  4. +6 −5 lib/nmcresolver.js
  5. +3 −3 lib/nmcsocks.js
  6. +2 −2 lib/tester.js
  7. +1 −7 nmcsocks
View
11 build.sh
@@ -24,13 +24,22 @@ cp lib/*.js flat/
cp lib/ndns/*.js flat/
cp node_modules/optimist/index.js flat/optimist.js
cp node_modules/optimist/node_modules/wordwrap/index.js flat/wordwrap.js
-cat node_modules/binary/index.js | perl -pe 's{./lib/vars.js}{vars}g' > flat/binary.js
+#cat node_modules/binary/index.js | perl -pe 's{./lib/vars.js}{vars}g' > flat/binary.js
+cp node_modules/binary/index.js flat/binary.js
cp node_modules/binary/lib/vars.js flat/vars.js
cp node_modules/binary/node_modules/put/index.js flat/put.js
cp node_modules/binary/node_modules/buffers/index.js flat/buffers.js
cp node_modules/binary/node_modules/chainsaw/index.js flat/chainsaw.js
cp node_modules/binary/node_modules/chainsaw/node_modules/traverse/index.js flat/traverse.js
cp lib/_third_party_main.js flat/_third_party_main.js
+cp lib/_dcrypt.js flat/dcrypt.js
+# convert all require("./path/file") to require("file")
+cd flat
+for file in *
+do
+ perl -pi -e 's{require\(['\''"][^"'\'']+/([^"'\''/]+)['\''"]\)}{require("$1")}g' "$file"
+done
+cd ..
echo "* Unzipping node.js tarball."
rm -rf tmp/
View
2 lib/ndns/ndns_client.js
@@ -1,4 +1,4 @@
-var ndns = require('ndns');
+var ndns = require('./ndns');
/**
* resolver points to a ndns client when necessary.
View
6 lib/nmcdns.js
@@ -5,10 +5,10 @@
* Anyway yes NmcSocks is also a DNS server. sorry.
*/
-var ndns = require("ndns");
+var ndns = require("./ndns/ndns");
var net = require("net");
-var resolver = require("nmcresolver");
-var Wait = require("Wait");
+var resolver = require("./nmcresolver");
+var Wait = require("./Wait");
function startServer(port, host, callback) {
View
11 lib/nmcresolver.js
@@ -15,8 +15,9 @@
*/
var dns = require("dns");
-var ndns = require("ndns_client");
+var ndns = require("./ndns/ndns_client");
var net = require("net");
+var nmcrpc = require("./nmcrpc");
// if true, disable external DNS resolution
var private_mode = false;
@@ -117,7 +118,7 @@ function getRecord(key, sub, callback) {
}
}
- require("nmcrpc").call("name_scan", [key, 1], nameHandler);
+ nmcrpc.call("name_scan", [key, 1], nameHandler);
function nameHandler(err, data) {
if (err) { return callback(err); }
@@ -321,14 +322,14 @@ function resolveFromValue(host, type, parent, chunks, value, counter, callback)
if (value.ip && (type==types.ANY || type==types.IPV4)) {
ip = value.ip;
// if it's not an ipv4 address, we ignore it.
- if (require("net").isIP(oneOf(ip))==4) {
+ if (net.isIP(oneOf(ip))==4) {
return callback(null, ip);
}
}
if (value.ip6 && (type==types.ANY || type==types.IPV6)) {
ip = value.ip6;
// if it's not an ipv6 address, we ignore it.
- if (require("net").isIP(oneOf(ip))==6) {
+ if (net.isIP(oneOf(ip))==6) {
return callback(null, ip);
}
}
@@ -373,7 +374,7 @@ function resolveWithDNS(host, server, callback) {
function testMode() {
testing = true;
- testData = require("name_scan");
+ testData = require("./name_scan");
}
// allow for easy command line testing.
// # node resolve.js some.domain.name
View
6 lib/nmcsocks.js
@@ -3,8 +3,8 @@ const VERSION = "0.4";
var net = require("net");
var binary = require("binary");
-var resolver = require("nmcresolver");
-var rpc = require("nmcrpc");
+var resolver = require("./nmcresolver");
+var rpc = require("./nmcrpc");
var argv = require("optimist")
.usage("Start a NameCoin Socks 5 Proxy.\nUsage: $0")
@@ -144,7 +144,7 @@ function chainProxyTester(next) {
}
function startDNSServer() {
- require("nmcdns").startServer(argv.dnsport, argv.dnsip, function() {
+ require("./nmcdns").startServer(argv.dnsport, argv.dnsip, function() {
console.log("DNS Server started on "+argv.dnsip+":"+argv.dnsport);
});
}
View
4 lib/tester.js
@@ -2,8 +2,8 @@
* something to test the nmcresolver only.
*/
-var resolver = require("nmcresolver");
-var Wait = require("Wait");
+var resolver = require("./nmcresolver");
+var Wait = require("./Wait");
var tests = [
{ query:"example1.bit", type:"ANY", answer:["test.com."] },
View
8 nmcsocks
@@ -1,10 +1,4 @@
#!/usr/bin/env node
-require.paths.unshift(__dirname+"/lib");
-require.paths.unshift(__dirname+"/lib/ndns");
-
-//require.paths.unshift(__dirname+"/flat");
-
-module.exports = require("nmcsocks");
-
+require("./lib/nmcsocks");

0 comments on commit 50427ed

Please sign in to comment.