@evanp/activitypub-bot 0.41.0 → 0.41.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/activitypub-bot.js +5 -4
- package/lib/safeagent.js +10 -1
- package/package.json +1 -1
package/bin/activitypub-bot.js
CHANGED
|
@@ -87,11 +87,12 @@ const REDIS_URL = normalize(values['redis-url']) || process.env.REDIS_URL || und
|
|
|
87
87
|
const TRUST_PROXY_RAW = normalize(values['trust-proxy']) || process.env.TRUST_PROXY
|
|
88
88
|
const TRUST_PROXY = (() => {
|
|
89
89
|
if (TRUST_PROXY_RAW == null) return undefined
|
|
90
|
-
const
|
|
90
|
+
const trimmed = TRUST_PROXY_RAW.trim()
|
|
91
|
+
const num = Number.parseInt(trimmed, 10)
|
|
92
|
+
if (!Number.isNaN(num) && String(num) === trimmed) return num
|
|
93
|
+
const bool = parseBoolean(trimmed)
|
|
91
94
|
if (bool !== undefined) return bool
|
|
92
|
-
|
|
93
|
-
if (!Number.isNaN(num) && String(num) === TRUST_PROXY_RAW.trim()) return num
|
|
94
|
-
return TRUST_PROXY_RAW
|
|
95
|
+
return trimmed
|
|
95
96
|
})()
|
|
96
97
|
const ALLOW_PRIVATE = values['allow-private'] ||
|
|
97
98
|
('ALLOW_PRIVATE' in process.env)
|
package/lib/safeagent.js
CHANGED
|
@@ -27,7 +27,16 @@ export class SafeAgent extends https.Agent {
|
|
|
27
27
|
if (isPrivateIP(address)) {
|
|
28
28
|
return callback(new PrivateNetworkError(address))
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
try {
|
|
31
|
+
const socket = super.createConnection({
|
|
32
|
+
...options,
|
|
33
|
+
host: address,
|
|
34
|
+
servername: options.servername || options.hostname
|
|
35
|
+
})
|
|
36
|
+
callback(null, socket)
|
|
37
|
+
} catch (e) {
|
|
38
|
+
callback(e)
|
|
39
|
+
}
|
|
31
40
|
})
|
|
32
41
|
}
|
|
33
42
|
}
|