Skip to content

Commit

Permalink
Feature/correctly use https proxies (#150)
Browse files Browse the repository at this point in the history
* chore: add https-proxy-agent

* feat: apply HttpsProxyAgent when https_proxy environment variable is defined

* chore: version bump

* fix: bump libs
  • Loading branch information
jkoenig134 authored Apr 8, 2024
1 parent 06ab764 commit 94be2aa
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 79 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.9.4

- the `https_proxy` environment variable is now respected by the connector

## 3.9.3

- errors resulting from the backbone will now be correctly return a `500` http status code
Expand Down
151 changes: 79 additions & 72 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nmshd/connector",
"version": "3.9.3",
"version": "3.9.4",
"private": true,
"description": "The Enmeshed Connector",
"homepage": "https://enmeshed.eu/integrate",
Expand Down Expand Up @@ -70,20 +70,21 @@
"@nmshd/runtime": "4.3.7",
"agentkeepalive": "4.5.0",
"amqplib": "^0.10.3",
"axios": "^1.6.7",
"axios": "^1.6.8",
"compression": "1.7.4",
"cors": "2.8.5",
"express": "4.18.3",
"express": "4.19.2",
"helmet": "7.1.0",
"https-proxy-agent": "^7.0.4",
"json-stringify-safe": "5.0.1",
"jsonschema": "1.4.1",
"mqtt": "^5.4.0",
"mqtt": "^5.5.0",
"multer": "^1.4.5-lts.1",
"nconf": "0.12.1",
"on-headers": "1.0.2",
"rapidoc": "9.3.4",
"redis": "^4.6.13",
"reflect-metadata": "0.2.1",
"reflect-metadata": "0.2.2",
"swagger-ui-express": "5.0.0",
"typescript-ioc": "3.2.2",
"typescript-rest": "3.0.4",
Expand All @@ -105,7 +106,7 @@
"@types/lodash": "^4.17.0",
"@types/luxon": "^3.4.2",
"@types/nconf": "^0.10.6",
"@types/node": "^20.11.28",
"@types/node": "^20.12.4",
"@types/on-headers": "^1.0.3",
"@types/swagger-ui-express": "^4.1.6",
"@types/yamljs": "^0.2.34",
Expand All @@ -120,7 +121,7 @@
"prettier": "^3.2.5",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.4.2",
"typescript": "^5.4.3",
"typescript-rest-swagger": "github:nmshd/typescript-rest-swagger#1.2.1"
},
"overrides": {
Expand Down
6 changes: 6 additions & 0 deletions src/ConnectorRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ConsumptionServices, DataViewExpander, GetIdentityInfoResponse, ModuleC
import { AccountController, CoreErrors as TransportCoreErrors } from "@nmshd/transport";
import axios from "axios";
import fs from "fs";
import { HttpsProxyAgent } from "https-proxy-agent";
import { validate as validateSchema } from "jsonschema";
import path from "path";
import { ConnectorMode } from "./ConnectorMode";
Expand Down Expand Up @@ -85,6 +86,11 @@ export class ConnectorRuntime extends Runtime<ConnectorRuntimeConfig> {
const loggerFactory = new NodeLoggerFactory(connectorConfig.logging);
ConnectorLoggerFactory.init(loggerFactory);

if (process.env.https_proxy) {
const httpsProxy = process.env.https_proxy;
connectorConfig.transportLibrary.httpsAgent = new HttpsProxyAgent(httpsProxy);
}

const runtime = new ConnectorRuntime(connectorConfig, loggerFactory);
await runtime.init();

Expand Down

0 comments on commit 94be2aa

Please sign in to comment.