-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/legacy-random_release-wrapper
- Loading branch information
Showing
11 changed files
with
543 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package geoip | ||
|
||
import ( | ||
"archive/tar" | ||
"compress/gzip" | ||
"io" | ||
"strings" | ||
|
||
"github.com/rs/zerolog" | ||
) | ||
|
||
func extractTarGzArchive(log *zerolog.Logger, dst io.Writer, src io.Reader) (e error) { | ||
var rd *gzip.Reader | ||
if rd, e = gzip.NewReader(src); e != nil { | ||
return | ||
} | ||
|
||
return extractTarArchive(log, dst, rd) | ||
} | ||
|
||
func extractTarArchive(log *zerolog.Logger, dst io.Writer, src io.Reader) (e error) { | ||
tr := tar.NewReader(src) | ||
for { | ||
var hdr *tar.Header | ||
hdr, e = tr.Next() | ||
|
||
if e == io.EOF { | ||
break // End of archive | ||
} else if e != nil { | ||
return | ||
} | ||
|
||
log.Trace().Msg("found file in maxmind tar archive - " + hdr.Name) | ||
if !strings.HasSuffix(hdr.Name, "mmdb") { | ||
continue | ||
} | ||
|
||
log.Trace().Msg("found mmdb file, copy to temporary file") | ||
|
||
var written int64 | ||
if written, e = io.Copy(dst, tr); e != nil { // skipcq: GO-S2110 decompression bomb isn't possible here | ||
return | ||
} | ||
|
||
log.Debug().Msgf("parsed response has written in temporary file with %d bytes", written) | ||
break | ||
} | ||
|
||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.