Closed df-cryptostorm closed 9 years ago
Can you edit the code to redefine gExternalIP
as:
gExternalIP: do ->
cachedIP = null
faces = os.networkInterfaces()
default_iface = switch
when os.type() is 'Darwin' and faces.en0? then 'en0'
when os.type() is 'Linux' and faces.eth0? then 'eth0'
else _(faces).keys().find (x)-> !x.match /lo/
(iface=default_iface, cached=true,fam='IPv4',internal=false) ->
cachedIP = switch
when cached and cachedIP then cachedIP
else
unless ips = (faces = os.networkInterfaces())[iface]
throw new Error util.format("No such interface '%s'. Available: %j", iface, faces)
if (address = _.find(ips, {family:fam, internal:internal})?.address)
address
else
gLogger.warn "Couldn't find 'address' in:", ips
gLogger.error "Couldn't figure out external IP! Make SURE to manually set it in your configuration!".bold.red
"NOT AN IP! SEE: https://github.com/okTurtles/dnschain/issues/111#issuecomment-71958236"
Then edit your config to specify your external IP manually?
[dns]
externalIP = xxx.xxx.xxx.xxx
And let us know if that fixes it? You will need to restart DNSChain after editing the file.
With that code I get: TypeError: Cannot call method 'warn' of undefined at /usr/local/lib/node_modules/dnschain/src/lib/globals.coffee:80:37 referring to the line: gLogger.warn "Couldn't find 'address' in:", ips
(I did an npm install glogger
just in case that was the problem, still gives me the error).
My apologies, the following should work:
gExternalIP: do ->
cachedIP = null
faces = os.networkInterfaces()
default_iface = switch
when os.type() is 'Darwin' and faces.en0? then 'en0'
when os.type() is 'Linux' and faces.eth0? then 'eth0'
else _(faces).keys().find (x)-> !x.match /lo/
(iface=default_iface, cached=true,fam='IPv4',internal=false) ->
cachedIP = switch
when cached and cachedIP then cachedIP
else
unless ips = (faces = os.networkInterfaces())[iface]
throw new Error util.format("No such interface '%s'. Available: %j", iface, faces)
if (address = _.find(ips, {family:fam, internal:internal})?.address)
address
else
console.warn "Couldn't find 'address' in:".bold.red, ips
console.error "Couldn't figure out external IP! Make SURE to manually set it in your configuration!".bold.red
"NOT AN IP! SEE: https://github.com/okTurtles/dnschain/issues/111#issuecomment-71958236"
I forgot to mention, even though we block all incoming/outgoing/forwarded IPv6 with ip6tables, eth0 does have an IPv6 address assigned to it (though not an IPv4 one).
[dnschain@fenrir ~]$ dnschain Couldn't find 'address' in: [ { address: 'fe80::6e3b:e5ff:fe51:d1ec', family: 'IPv6', internal: false } ] Couldn't figure out external IP! Make SURE to manually set it in your configuration! 2015-01-29T03:10:49.074Z - info: [NMC] connected to namecoind: 127.0.0.1:8336 2015-01-29T03:10:49.076Z - info: [DNS] started DNS { port: 5333, host: '127.0.0.1', externalIP: '79.134.235.131', oldDNSMethod: 0, oldDNS: { address: '127.0.0.1', port: 53, type: 'udp' } } 2015-01-29T03:10:49.078Z - info: [HTTP] started HTTP { port: 8000, tlsPort: 4443, host: '0.0.0.0' } 2015-01-29T03:10:49.078Z - info: [DNSChain] DNSChain started and advertising on: 79.134.235.131
So it's functional, but I'm not sure if that "Couldn't figure out external IP! Make SURE to manually set it in your configuration!" is what's supposed to be shown.
@df-cryptostorm Yeah, that's because it's filtering by IPv4
... Are you trying to serve this over IPv6?
If so, try setting an IPv6 address in your config instead of an IPv4 and let us know if it works. We haven't yet attempted to make DNSChain IPv6 compatible, so I've no idea whether that will work.
No no, not trying to serve this over IPv6. Too many security issues exist at the moment for us to be able to run our VPN or other features over IPv6. Just doing IPv4.
If you're curious, the setup that we're trying is a public facing CurveDNS that forwards to the DNSChain (mainly for .bit) on 127.0.0.1:5333 then finally to the recursive/caching Unbound server on 127.0.0.1:53 (for normal DNS lookups). For now it's publicly accessible on the externalIP mentioned above if you want to check it out, but eventually we'll firewall it off so only VPN clients connected to this server can use it. I was also thinking that it would be neat to setup Unbound to forward .onion and .i2p to their respective servers so that our VPN clients can access .onion/.i2p/etc. sites without having to do anything other than connect to our VPN.
I've edited the error to say: "Couldn't figure out external IPv4 IP! Make SURE to manually set it in your configuration!" and changed it to a warning.
This change will make it into the next release.
I was also thinking that it would be neat to setup Unbound to forward .onion and .i2p to their respective servers so that our VPN clients can access .onion/.i2p/etc. sites without having to do anything other than connect to our VPN.
That's a great idea. :smile: :+1:
Nicely done, df :-)
We're getting close to releasing an update, so closing this to help with book-keeping and release notes.
[root@stage ~]# dnschain TypeError: Cannot read property 'address' of undefined at /usr/local/lib/nodemodules/dnschain/src/lib/globals.coffee:77:69 at .assign.gExternalIP (/usr/local/lib/node_modules/dnschain/src/lib/globals.coffee:91:13) at module.exports (/usr/local/lib/node_modules/dnschain/src/lib/config.coffee:49:25) at module.exports (/usr/local/lib/node_modules/dnschain/src/lib/globals.coffee:135:38) at Object. (/usr/local/lib/node_modules/dnschain/src/lib/dnschain.coffee:54:1)
at Object. (/usr/local/lib/node_modules/dnschain/src/lib/dnschain.coffee:1:1)
at Module._compile (module.js:456:26)
at Object.loadFile (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/register.js:16:19)
at Module.load (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/usr/local/lib/node_modules/dnschain/bin/dnschain:2:3)
at Object. (/usr/local/lib/node_modules/dnschain/bin/dnschain:4:4)
at Module._compile (module.js:456:26)
On this CentOS 6.x system, eth0 is enabled but no IP address is assigned to it. I think it was either left over from a previous ethernet card replacement or it's just the first one on a system with two ethernet cards. The default/main IP is assigned to eth1. A quick fix for me was changing line 69 of /usr/local/lib/node_modules/dnschain/src/lib/globals.coffee from:
to
I'm not too familiar with this language, but maybe in some future release some code could be added that'll loop through the available interfaces and skip the first one if no IP is assigned to it? While this no IP on eth0 behavior is somewhat unusual, I have seen it before as the default on several other Linux servers, so it's probably not specific to this particular server.