diff options
author | Leah Neukirchen <leah@vuxu.org> | 2024-07-10 18:58:44 +0200 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2024-07-10 18:58:44 +0200 |
commit | d2daffcdcd51ecd79e79c0c22f7936f037b637c1 (patch) | |
tree | bd71a6da57e5d063bb143d4e3731fa85cc9cdea0 /main.c | |
parent | 653dc9cd6836d505abc1cf988b7e7186ff742f6d (diff) | |
download | nano-exporter-d2daffcdcd51ecd79e79c0c22f7936f037b637c1.tar.gz nano-exporter-d2daffcdcd51ecd79e79c0c22f7936f037b637c1.tar.xz nano-exporter-d2daffcdcd51ecd79e79c0c22f7936f037b637c1.zip |
support binding to a specific host address
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/main.c b/main.c index 7e37094..9e747c0 100644 --- a/main.c +++ b/main.c @@ -67,11 +67,13 @@ static const struct collector *collectors[] = { struct config { const char *port; + const char *host; bool print; }; const struct config default_config = { .port = "9100", + .host = 0, .print = false, }; @@ -95,7 +97,7 @@ int main(int argc, char *argv[]) { return 0; } - scrape_server *server = scrape_listen(cfg.port); + scrape_server *server = scrape_listen(cfg.host, cfg.port); if (!server) return 1; @@ -154,6 +156,11 @@ static bool initialize(int argc, char *argv[], struct config *cfg, struct collec goto next_arg; } + if (strncmp(argv[arg], "--host=", 7) == 0) { + cfg->host = &argv[arg][7]; + goto next_arg; + } + if (strncmp(argv[arg], "--stdout", 8) == 0) { cfg->print = true; goto next_arg; |