Skip to content

Commit 4cae7ab

Browse files
committed
Modified to only use a single file pointer
1 parent 3002e20 commit 4cae7ab

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ip2proxy-nodejs",
3-
"version": "1.0.2",
3+
"version": "1.1.0",
44
"description": "IP2Proxy proxy detection component",
55
"keywords": [
66
"vpn-detection",

src/ip2proxy.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ var net = require("net");
22
var fs = require("fs");
33
var bigInt = require("big-integer");
44

5-
var version = "1.0.0";
5+
var fd;
6+
7+
var version = "1.1.0";
68
var binfile = "";
79
var IPv4ColumnSize = 0;
810
var IPv6ColumnSize = 0;
@@ -68,9 +70,7 @@ var MSG_IPV6_UNSUPPORTED = "IPV6 ADDRESS MISSING IN IPV4 BIN";
6870
// Read binary data
6971
function readbin(readbytes, pos, readtype, isbigint) {
7072
var buff = new Buffer(readbytes);
71-
var fd = fs.openSync(binfile, 'r');
7273
totalread = fs.readSync(fd, buff, 0, readbytes, pos);
73-
fs.closeSync(fd);
7474

7575
if (totalread == readbytes) {
7676
switch (readtype) {
@@ -190,6 +190,8 @@ function loadbin() {
190190

191191
try {
192192
if (binfile && (binfile != "")) {
193+
fd = fs.openSync(binfile, 'r');
194+
193195
mydb._DBType = read8(1);
194196
mydb._DBColumn = read8(2);
195197
mydb._DBYear = read8(3);

0 commit comments

Comments
 (0)