Skip to content

Commit 6264182

Browse files
committed
improve wsurl generation
1 parent f8f2fad commit 6264182

6 files changed

Lines changed: 31 additions & 7 deletions

File tree

OpenFlow/src/Config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export class Config {
9999
Config.nodered_image = Config.getEnv("nodered_image", "openiap/nodered");
100100
Config.saml_federation_metadata = Config.getEnv("saml_federation_metadata", "");
101101
Config.api_ws_url = Config.getEnv("api_ws_url", "");
102+
Config.nodered_ws_url = Config.getEnv("nodered_ws_url", "");
102103
Config.namespace = Config.getEnv("namespace", ""); // also sent to website
103104
Config.nodered_domain_schema = Config.getEnv("nodered_domain_schema", ""); // also sent to website
104105
Config.nodered_initial_liveness_delay = parseInt(Config.getEnv("nodered_initial_liveness_delay", "60"));
@@ -188,10 +189,13 @@ export class Config {
188189
public static nodered_image: string = Config.getEnv("nodered_image", "openiap/nodered");
189190
public static saml_federation_metadata: string = Config.getEnv("saml_federation_metadata", "");
190191
public static api_ws_url: string = Config.getEnv("api_ws_url", "");
192+
public static nodered_ws_url: string = Config.getEnv("nodered_ws_url", "");
191193
public static namespace: string = Config.getEnv("namespace", ""); // also sent to website
192194
public static nodered_domain_schema: string = Config.getEnv("nodered_domain_schema", ""); // also sent to website
193195
public static nodered_initial_liveness_delay: number = parseInt(Config.getEnv("nodered_initial_liveness_delay", "60"));
194196
public static nodered_allow_nodeselector: boolean = Config.parseBoolean(Config.getEnv("nodered_allow_nodeselector", "false"));
197+
public static nodered_requests_memory: string = Config.getEnv("nodered_requests_memory", "128Mi");
198+
public static nodered_limits_memory: string = Config.getEnv("nodered_limits_memory", "256Mi");
195199

196200
public static baseurl(): string {
197201
let result: string = "";

OpenFlow/src/LoginProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export class LoginProvider {
226226
_url = "wss://" + url.parse(baseurl).host;
227227
}
228228
_url += "/";
229-
if (NoderedUtil.IsNullEmpty(Config.api_ws_url)) {
229+
if (!NoderedUtil.IsNullEmpty(Config.api_ws_url)) {
230230
_url = Config.api_ws_url;
231231
if (!_url.endsWith("/")) _url += "/";
232232
}

OpenFlow/src/Messages/Message.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { lookup } from "mimetype";
33
import { SocketMessage } from "../SocketMessage";
44
import { Auth } from "../Auth";
55
import { Crypt } from "../Crypt";
6+
import * as url from "url";
67
import { Config } from "../Config";
78
import { Audit } from "../Audit";
89
import { LoginProvider } from "../LoginProvider";
@@ -1003,8 +1004,8 @@ export class Message {
10031004
let hasbilling: boolean = false;
10041005
resources.limits = {};
10051006
resources.requests = {};
1006-
resources.requests.memory = "70Mi";
1007-
resources.limits.memory = "256Mi";
1007+
resources.requests.memory = Config.nodered_requests_memory;
1008+
resources.limits.memory = Config.nodered_limits_memory;
10081009

10091010
if (user.nodered) {
10101011
try {
@@ -1072,6 +1073,25 @@ export class Message {
10721073

10731074
let api_ws_url = Config.baseurl();
10741075
if (!NoderedUtil.IsNullEmpty(Config.api_ws_url)) api_ws_url = Config.api_ws_url;
1076+
if (!NoderedUtil.IsNullEmpty(Config.nodered_ws_url)) api_ws_url = Config.nodered_ws_url;
1077+
1078+
let saml_baseurl = Config.protocol + "://" + hostname + "/";
1079+
1080+
let _samlparsed = url.parse(Config.saml_federation_metadata);
1081+
if (_samlparsed.protocol == "http:" || _samlparsed.protocol == "ws:") {
1082+
saml_baseurl = "http://" + hostname
1083+
if (_samlparsed.port && _samlparsed.port != "80") {
1084+
saml_baseurl += ":" + _samlparsed.port;
1085+
}
1086+
} else {
1087+
saml_baseurl = "https://" + hostname
1088+
if (_samlparsed.port && _samlparsed.port != "443") {
1089+
saml_baseurl += ":" + _samlparsed.port;
1090+
}
1091+
}
1092+
saml_baseurl += "/";
1093+
1094+
// _url = "ws://" + url.parse(baseurl).host;
10751095

10761096
// const api_ws_url = Config.api_ws_url;
10771097
// const api_ws_url = Config.baseurl();
@@ -1096,7 +1116,7 @@ export class Message {
10961116
env: [
10971117
{ name: "saml_federation_metadata", value: Config.saml_federation_metadata },
10981118
{ name: "saml_issuer", value: Config.saml_issuer },
1099-
{ name: "saml_baseurl", value: Config.protocol + "://" + hostname + "/" },
1119+
{ name: "saml_baseurl", value: saml_baseurl },
11001120
{ name: "nodered_id", value: name },
11011121
{ name: "nodered_sa", value: nodereduser.username },
11021122
{ name: "jwt", value: nodered_jwt },

OpenFlowNodeRED/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openiap/nodered",
3-
"version": "1.1.119",
3+
"version": "1.1.125",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.119
1+
1.1.125

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openiap/openflow",
3-
"version": "1.1.119",
3+
"version": "1.1.125",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)