Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: golangci-lint
name: precious

on:
push:
Expand All @@ -9,14 +9,16 @@ on:
permissions: {}

jobs:
golangci:
precious:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # 9.2.0
- name: Setup mise
uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1
with:
version: latest
cache: true
- name: Run precious lint
run: precious lint --all
34 changes: 34 additions & 0 deletions .precious.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
exclude = [
".git",
]

[commands.golangci-lint-fmt]
type = "both"
cmd = ["golangci-lint", "fmt"]
lint-flags = "--diff"
ok-exit-codes = 0
invoke = "once"
include = ["**/*.go"]

[commands.golangci-lint]
type = "both"
cmd = ["golangci-lint", "run"]
tidy-flags = ["--fix"]
ok-exit-codes = 0
ignore-stderr = ".*"
invoke = "once"
path-args = "dir"
include = ["**/*.go"]

[commands.prettier-markdown]
type = "both"
cmd = ["prettier", "--prose-wrap", "always"]
lint-flags = ["--check"]
tidy-flags = ["--write"]
path-args = "absolute-file"
include = "**/*.md"
# doc/ contains pandoc man page sources that use definition list syntax
# (": " + 4-space indented continuations). Prettier doesn't understand
# this extension and strips the indentation, breaking man page rendering.
exclude = ["doc/**"]
ok-exit-codes = 0
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"proseWrap": "always",
"printWidth": 80,
"tabWidth": 2,
"useTabs": false
}
381 changes: 185 additions & 196 deletions CHANGELOG.md

Large diffs are not rendered by default.

50 changes: 26 additions & 24 deletions README.dev.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
# Releasing

* Make sure you have [`goreleaser`](https://goreleaser.com/), rpmbuild,
and pandoc installed. (rpmbuild is in the Ubuntu package `rpm`).
* Set release date in `CHANGELOG.md` and commit it.
* Ensure you can run `docker` commands as your user (e.g., `docker
images`).
* Ensure Docker is set up to do cross-compilation. You can verify this with
`docker buildx ls`. It should list `linux/arm64` as an available platform.
If not, follow [these instructions](https://docs.docker.com/build/building/multi-platform/).
* Log in to your Docker Hub account (be sure to be in our organization):
- Make sure you have [`goreleaser`](https://goreleaser.com/), rpmbuild, and
pandoc installed. (rpmbuild is in the Ubuntu package `rpm`).
- Set release date in `CHANGELOG.md` and commit it.
- Ensure you can run `docker` commands as your user (e.g., `docker images`).
- Ensure Docker is set up to do cross-compilation. You can verify this with
`docker buildx ls`. It should list `linux/arm64` as an available platform. If
not, follow
[these instructions](https://docs.docker.com/build/building/multi-platform/).
- Log in to your Docker Hub account (be sure to be in our organization):
`docker login`.
* Follow [these instructions](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry),
- Follow
[these instructions](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry),
to log in to `ghcr.io` with `docker login`.
* Run `GITHUB_TOKEN=<your token> ./dev-bin/release.sh`. For `goreleaser` you
- Run `GITHUB_TOKEN=<your token> ./dev-bin/release.sh`. For `goreleaser` you
will need a token with the `repo` scope. You may create a token
[here](https://github.com/settings/tokens/new).

Then release to our PPA:

* Switch to the `ubuntu-ppa` branch. Merge the released tag into it. e.g.
- Switch to the `ubuntu-ppa` branch. Merge the released tag into it. e.g.
`git merge v4.1.0`.
* Set up to release to launchpad. You can see some information about
- Set up to release to launchpad. You can see some information about
prerequisites for this
[here](https://github.com/maxmind/libmaxminddb/blob/main/README.dev.md).
* Ensure you have the `dh-golang`, `golang-any`, `devscripts`,
- Ensure you have the `dh-golang`, `golang-any`, `devscripts`,
`libfile-slurp-tiny-perl`, and `libdatetime-perl` packages installed.
* Delete `dist` directory.
* Check whether you need to update the `$DISTS` variable in
`dev-bin/ppa-release.sh`. We should include all currently supported
Ubuntu releases.
* Run `dev-bin/ppa-release.sh`
- Delete `dist` directory.
- Check whether you need to update the `$DISTS` variable in
`dev-bin/ppa-release.sh`. We should include all currently supported Ubuntu
releases.
- Run `dev-bin/ppa-release.sh`

Gotcha with PPA:

* If you get an error from `dput` like `No host ppa:maxmind/ppa found in
config`, you can create a `~/.dput.cf` with content like so:
- If you get an error from `dput` like
`No host ppa:maxmind/ppa found in config`, you can create a `~/.dput.cf` with
content like so:

```
[maxmind]
Expand All @@ -45,6 +47,6 @@ login = anonymous
allow_unsigned_uploads = 0
```

Then you can run the same `dput` command but with `dput maxmind [...]`
instead of `dput ppa:maxmind/ppa [...]` (I'm not sure how to make the
matching work with the original command).
Then you can run the same `dput` command but with `dput maxmind [...]` instead
of `dput ppa:maxmind/ppa [...]` (I'm not sure how to make the matching work with
the original command).
86 changes: 43 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
# GeoIP Update

The GeoIP Update program performs automatic updates of GeoIP2 and
GeoLite2 binary databases. CSV databases are _not_ supported.
The GeoIP Update program performs automatic updates of GeoIP2 and GeoLite2
binary databases. CSV databases are _not_ supported.

## Installation

We provide releases for Linux, macOS (darwin), and Windows. Please see the
[Releases](https://github.com/maxmind/geoipupdate/releases) tab for the
latest release.
[Releases](https://github.com/maxmind/geoipupdate/releases) tab for the latest
release.

After you install GeoIP Update, please refer to our
[documentation](https://dev.maxmind.com/geoip/updating-databases?lang=en) for information
about configuration.
[documentation](https://dev.maxmind.com/geoip/updating-databases?lang=en) for
information about configuration.

If you're upgrading from GeoIP Update 3.x, please see our [upgrade
guide](https://dev.maxmind.com/geoip/upgrading-geoip-update?lang=en).
If you're upgrading from GeoIP Update 3.x, please see our
[upgrade guide](https://dev.maxmind.com/geoip/upgrading-geoip-update?lang=en).

### Installing on Linux via the tarball

Download and extract the appropriate tarball for your system. You will end
up with a directory named something like `geoipupdate_5.0.0_linux_amd64`
depending on the version and architecture.
Download and extract the appropriate tarball for your system. You will end up
with a directory named something like `geoipupdate_5.0.0_linux_amd64` depending
on the version and architecture.

Copy `geoipupdate` to where you want it to live. To install it to
`/usr/local/bin/geoipupdate`, run the equivalent of `sudo cp
geoipupdate_5.0.0_linux_amd64/geoipupdate /usr/local/bin`.
`/usr/local/bin/geoipupdate`, run the equivalent of
`sudo cp geoipupdate_5.0.0_linux_amd64/geoipupdate /usr/local/bin`.

`geoipupdate` looks for the config file `/usr/local/etc/GeoIP.conf` by
default.
`geoipupdate` looks for the config file `/usr/local/etc/GeoIP.conf` by default.

### Installing on Ubuntu via PPA

MaxMind provides a PPA for recent versions of Ubuntu. To add the PPA to
your sources, run:
MaxMind provides a PPA for recent versions of Ubuntu. To add the PPA to your
sources, run:

```
$ sudo add-apt-repository ppa:maxmind/ppa
Expand All @@ -51,10 +50,10 @@ You can also use the tarball.

Download the appropriate .deb for your system.

Run `dpkg -i path/to/geoipupdate_5.0.0_linux_amd64.deb` (replacing the
version number and architecture as necessary). You will need to be root.
For Ubuntu you can prefix the command with `sudo`. This will install
`geoipupdate` to `/usr/bin/geoipupdate`.
Run `dpkg -i path/to/geoipupdate_5.0.0_linux_amd64.deb` (replacing the version
number and architecture as necessary). You will need to be root. For Ubuntu you
can prefix the command with `sudo`. This will install `geoipupdate` to
`/usr/bin/geoipupdate`.

`geoipupdate` looks for the config file `/etc/GeoIP.conf` by default.

Expand All @@ -64,16 +63,16 @@ You can also use the tarball.

Download the appropriate .rpm for your system.

Run `rpm -Uvhi path/to/geoipupdate_5.0.0_linux_amd64.rpm` (replacing the
version number and architecture as necessary). You will need to be root.
This will install `geoipupdate` to `/usr/bin/geoipupdate`.
Run `rpm -Uvhi path/to/geoipupdate_5.0.0_linux_amd64.rpm` (replacing the version
number and architecture as necessary). You will need to be root. This will
install `geoipupdate` to `/usr/bin/geoipupdate`.

`geoipupdate` looks for the config file `/etc/GeoIP.conf` by default.

### Installing on macOS (darwin) via the tarball

This is the same as installing on Linux via the tarball, except choose a
tarball with "darwin" in the name.
This is the same as installing on Linux via the tarball, except choose a tarball
with "darwin" in the name.

### Installing on macOS via Homebrew

Expand All @@ -86,15 +85,14 @@ $ brew install geoipupdate

### Installing on Windows

Download and extract the appropriate zip for your system. You will end up
with a directory named something like `geoipupdate_5.0.0_windows_amd64`
depending on the version and architecture.
Download and extract the appropriate zip for your system. You will end up with a
directory named something like `geoipupdate_5.0.0_windows_amd64` depending on
the version and architecture.

Copy `geoipupdate.exe` to where you want it to live.

`geoipupdate` looks for the config file
`\ProgramData\MaxMind\GeoIPUpdate\GeoIP.conf` on your system drive by
default.
`\ProgramData\MaxMind\GeoIPUpdate\GeoIP.conf` on your system drive by default.

### Installing via Docker

Expand All @@ -111,8 +109,8 @@ proto install geoipupdate

### Installation from source or Git

You need the Go compiler (1.25+). You can get it at the [Go
website](https://golang.org).
You need the Go compiler (1.25+). You can get it at the
[Go website](https://golang.org).

The easiest way is via `go install`:

Expand All @@ -122,31 +120,33 @@ This installs `geoipupdate` to `$GOPATH/bin/geoipupdate`.

# Configuring

Please see our [online guide](https://dev.maxmind.com/geoip/updating-databases?lang=en) for
Please see our
[online guide](https://dev.maxmind.com/geoip/updating-databases?lang=en) for
directions on how to configure GeoIP Update.

# Documentation

See our documentation for the [`geoipupdate` program](doc/geoipupdate.md)
and the [`GeoIP.conf` configuration file](doc/GeoIP.conf.md).
See our documentation for the [`geoipupdate` program](doc/geoipupdate.md) and
the [`GeoIP.conf` configuration file](doc/GeoIP.conf.md).

# Default config file and database directory paths

We define default paths for the config file and database directory. If
these defaults are not appropriate for you, you can change them at build
time using flags:
We define default paths for the config file and database directory. If these
defaults are not appropriate for you, you can change them at build time using
flags:

go build -ldflags "-X main.defaultConfigFile=/etc/GeoIP.conf \
-X main.defaultDatabaseDirectory=/usr/share/GeoIP"

# Bug Reports

Please report bugs by filing an issue with [our GitHub issue
tracker](https://github.com/maxmind/geoipupdate/issues).
Please report bugs by filing an issue with
[our GitHub issue tracker](https://github.com/maxmind/geoipupdate/issues).

# Copyright and License

This software is Copyright (c) 2018 - 2026 by MaxMind, Inc.

This is free software, licensed under the [Apache License, Version
2.0](LICENSE-APACHE) or the [MIT License](LICENSE-MIT), at your option.
This is free software, licensed under the
[Apache License, Version 2.0](LICENSE-APACHE) or the [MIT License](LICENSE-MIT),
at your option.
2 changes: 1 addition & 1 deletion client/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (c *Client) download(
req.Header.Add("User-Agent", "geoipupdate/"+vars.Version)
req.SetBasicAuth(strconv.Itoa(c.accountID), c.licenseKey)

response, err := c.httpClient.Do(req) //nolint:gosec // URL is from known config
response, err := c.httpClient.Do(req)
if err != nil {
return nil, time.Time{}, fmt.Errorf("performing download request: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion client/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (c *Client) getMetadata(
req.Header.Add("User-Agent", "geoipupdate/"+vars.Version)
req.SetBasicAuth(strconv.Itoa(c.accountID), c.licenseKey)

response, err := c.httpClient.Do(req) //nolint:gosec // URL is from known config
response, err := c.httpClient.Do(req)
if err != nil {
return nil, fmt.Errorf("performing metadata request: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/geoipupdate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func setConfigFromEnv(config *Config) error {
if value := os.Getenv("GEOIPUPDATE_ACCOUNT_ID_FILE"); value != "" {
var err error

accountID, err := os.ReadFile(filepath.Clean(value)) //nolint:gosec // path from env var
accountID, err := os.ReadFile(filepath.Clean(value))
if err != nil {
return fmt.Errorf("failed to open GEOIPUPDATE_ACCOUNT_ID_FILE: %w", err)
}
Expand Down Expand Up @@ -333,7 +333,7 @@ func setConfigFromEnv(config *Config) error {
if value := os.Getenv("GEOIPUPDATE_LICENSE_KEY_FILE"); value != "" {
var err error

licenseKey, err := os.ReadFile(filepath.Clean(value)) //nolint:gosec // path from env var
licenseKey, err := os.ReadFile(filepath.Clean(value))
if err != nil {
return fmt.Errorf("failed to open GEOIPUPDATE_LICENSE_KEY_FILE: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/geoipupdate/database/local_file_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (w *fileWriter) close() error {
}
}

err := os.Remove(w.file.Name()) //nolint:gosec // path from config
err := os.Remove(w.file.Name())
if err != nil && !errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("removing temporary file: %w", err)
}
Expand Down Expand Up @@ -222,7 +222,7 @@ func (w *fileWriter) syncAndRename(name string) error {
if err := w.file.Close(); err != nil {
return fmt.Errorf("closing temporary file: %w", err)
}
if err := os.Rename(w.file.Name(), name); err != nil { //nolint:gosec // path from config
if err := os.Rename(w.file.Name(), name); err != nil {
return fmt.Errorf("moving database into place: %w", err)
}
return nil
Expand Down
Loading
Loading