From 2dd8b61dfa9f34d706ac61f96d71b8d1087442e6 Mon Sep 17 00:00:00 2001 From: Tom de Bruijn Date: Tue, 18 Jul 2023 15:20:16 +0200 Subject: [PATCH] Add bindAddress config option for the agent (#919) This feature has been available in the agent's standalone mode for a while now. I'm cleaning up old issues and picking up this small one. Part of https://github.com/appsignal/appsignal-agent/issues/915 --- .changesets/allow-bind_address-configuration.md | 6 ++++++ src/__tests__/config.test.ts | 3 +++ src/config/configmap.ts | 3 +++ src/config/options.ts | 1 + 4 files changed, 13 insertions(+) create mode 100644 .changesets/allow-bind_address-configuration.md diff --git a/.changesets/allow-bind_address-configuration.md b/.changesets/allow-bind_address-configuration.md new file mode 100644 index 00000000..65fc0a91 --- /dev/null +++ b/.changesets/allow-bind_address-configuration.md @@ -0,0 +1,6 @@ +--- +bump: "patch" +type: "add" +--- + +Allow configuration of the agent's TCP and UDP servers using the `bindAddress` config option. This is by default set to `127.0.0.1`, which only makes it accessible from the same host. If you want it to be accessible from other machines, use `0.0.0.0` or a specific IP address. diff --git a/src/__tests__/config.test.ts b/src/__tests__/config.test.ts index 7cf5bf61..735cf890 100644 --- a/src/__tests__/config.test.ts +++ b/src/__tests__/config.test.ts @@ -257,6 +257,7 @@ describe("Configuration", () => { expect(env("_APPSIGNAL_ACTIVE")).toBeUndefined() expect(env("_APPSIGNAL_APP_ENV")).toBeDefined() expect(env("_APPSIGNAL_APP_NAME")).toBeUndefined() + expect(env("_APPSIGNAL_BIND_ADDRESS")).toBeUndefined() expect(env("_APPSIGNAL_CA_FILE_PATH")).toMatch(/cert\/cacert\.pem$/) expect(env("_APPSIGNAL_DNS_SERVERS")).toBeUndefined() expect(env("_APPSIGNAL_ENABLE_HOST_METRICS")).toEqual("true") @@ -302,6 +303,7 @@ describe("Configuration", () => { new Configuration({ name, active: true, + bindAddress: "0.0.0.0", pushApiKey, dnsServers: ["8.8.8.8", "8.8.4.4"], enableHostMetrics: false, @@ -328,6 +330,7 @@ describe("Configuration", () => { it("writes configuration values to the environment", () => { expect(env("_APPSIGNAL_ACTIVE")).toEqual("true") expect(env("_APPSIGNAL_APP_NAME")).toEqual(name) + expect(env("_APPSIGNAL_BIND_ADDRESS")).toEqual("0.0.0.0") expect(env("_APPSIGNAL_DNS_SERVERS")).toEqual("8.8.8.8,8.8.4.4") expect(env("_APPSIGNAL_ENABLE_HOST_METRICS")).toEqual("true") expect(env("_APPSIGNAL_ENABLE_STATSD")).toEqual("true") diff --git a/src/config/configmap.ts b/src/config/configmap.ts index a2119198..1835e4b0 100644 --- a/src/config/configmap.ts +++ b/src/config/configmap.ts @@ -4,6 +4,7 @@ export const ENV_TO_KEY_MAPPING: Record = { APPSIGNAL_ACTIVE: "active", APPSIGNAL_APP_ENV: "environment", APPSIGNAL_APP_NAME: "name", + APPSIGNAL_BIND_ADDRESS: "bindAddress", APPSIGNAL_CA_FILE_PATH: "caFilePath", APPSIGNAL_DISABLE_DEFAULT_INSTRUMENTATIONS: "disableDefaultInstrumentations", APPSIGNAL_DNS_SERVERS: "dnsServers", @@ -39,6 +40,7 @@ export const PRIVATE_ENV_MAPPING: Record = { _APPSIGNAL_ACTIVE: "active", _APPSIGNAL_APP_ENV: "environment", _APPSIGNAL_APP_NAME: "name", + _APPSIGNAL_BIND_ADDRESS: "bindAddress", _APPSIGNAL_CA_FILE_PATH: "caFilePath", _APPSIGNAL_DNS_SERVERS: "dnsServers", _APPSIGNAL_ENABLE_HOST_METRICS: "enableHostMetrics", @@ -68,6 +70,7 @@ export const PRIVATE_ENV_MAPPING: Record = { export const JS_TO_RUBY_MAPPING: Record = { active: "active", + bindAddress: "bind_address", pushApiKey: "push_api_key", caFilePath: "ca_file_path", disableDefaultInstrumentations: "disable_default_instrumentations", diff --git a/src/config/options.ts b/src/config/options.ts index 81c374f4..88fd46d7 100644 --- a/src/config/options.ts +++ b/src/config/options.ts @@ -2,6 +2,7 @@ import type { DefaultInstrumentationName } from "../client" export type AppsignalOptions = { active: boolean + bindAddress: string caFilePath: string disableDefaultInstrumentations: DefaultInstrumentationName[] | boolean dnsServers: string[]