-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support GeoLite2 ASN DB, which is availably only as tarball #16
Conversation
As I noted in DEVELOP.md, I prefer keeping the dependency list to a minimum. How would you feel about? :
if (/\.tar\.gz$/.test(opts.path)) {
myUntarFunction();
return;
}
var file = fs.createWriteStream(dest + '.tmp');
...
|
Interesting. I just added the GeoLite2-ASN declaration to config.js and was surprised to find that it downloaded the file just fine:
|
- sprinkle in some ES6 syntax - drop node 4 testing, add node 9
- sprinkle in some ES6 syntax - drop node 4 testing, add node 9
Codecov Report
@@ Coverage Diff @@
## master #16 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 1 1
Lines 6 6
Branches 1 1
=====================================
Hits 6 6 Continue to review full report at Codecov.
|
Thanks for the quick response! I have switched dependencies to I am less sure about the optionalDependency setup's benefits -- the default config state will wind up with that code always getting invoked. I love zero-dependency packages too but I think Maxmind's decision (and likely future policy?) has made that untenable. But I defer to your sense of this. If you will accept
You had success adding the gzipped tarball to the config with the existing code because the code gunzips the file and then renames whatever comes out to the desired output filename. The tarball is a valid gzip so no error is thrown. But in this case the result will be a (misnamed) uncompressed tar file, not a valid mmdb. Ideally that would have been caught by tests. The test script as it stands checks for the ability to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better, thanks! There's a few more issues I've commented on inline.
package.json
Outdated
@@ -8,7 +8,6 @@ | |||
"url": "http://matt.simerson.net" | |||
}, | |||
"contributors": { | |||
"name": "Carl Banbury", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
restore this line please.
bin/maxmind-geolite-mirror
Outdated
const fs = require('fs'); | ||
const http = require('http'); | ||
const zlib = require('zlib'); | ||
|
||
const path = require('path'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please restore the blank line here and include path in the top list of "built-in" modules. config
is separated by whitespace because it's a local dependency.
bin/maxmind-geolite-mirror
Outdated
const config = require('../lib/config'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please restore all the blank lines. Whitespace is free and I prefer it.
bin/maxmind-geolite-mirror
Outdated
function httpReqOpts () { | ||
return { | ||
method: 'HEAD', | ||
hostname: config.hostName, | ||
port: config.hostPort, | ||
headers: { | ||
'User-Agent': config.userAgent, | ||
'User-Agent': config.userAgent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please restore the dangling comma.
Apologies to Mr. Banbury -- I thought he was removed in your merge to master. The excision wasn't intentional. The killed blank lines were the result of an overly greedy regex attempting to satisfy the trailing whitespace linting rule. We will have to agree to disagree on the wisdom of trailing commas but I have made the change you requested. |
As an optionalDependency, the package will still get installed. The only difference is that if the install fails for some reason, npm can still successfully install this package.
Uh oh! That's no good. A test case is definitely preferable to catch this. There are a couple ways it could be done. One that doesn't would be to "taste" the file with the I don't have strong biases against dev deps but I do like to keep the package nice and small, and downloading an entire tarball from maxmind just to test would likely bloat the test times a fair bit. Dropping a sample file in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. I'll create a new issue regarding a test for tarball.
Sounds good. I will keep an eye out for this; in order to account for the seemingly-correct behavior you observed I believe it will be necessary to stub |
unlike the other databases,
curl -I http://geolite.maxmind.com/download/geoip/database/GeoLite2-ASN.mmdb.gz
returns a 404. It is available as a .tar.gz file linked from https://dev.maxmind.com/geoip/geoip2/geolite2/ . In order to support this, I've added handling forconfig.geoIpDbs
entries that point to gzipped tarballs.