@routr/pgdata 2.0.8-alpha.18 → 2.0.8-alpha.20

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.
@@ -70,14 +70,16 @@ class ACLManager extends manager_1.EntityManager {
70
70
  }
71
71
  this.acl.deny.forEach((cidr) => {
72
72
  // 4 => IPv4
73
- if (!Validator.default.isIPRange(cidr, 4)) {
74
- throw new common_1.CommonErrors.BadRequestError(`${cidr} is not a valid cidr`);
73
+ if (!Validator.default.isIPRange(cidr, 4) &&
74
+ !Validator.default.isIP(cidr, 4)) {
75
+ throw new common_1.CommonErrors.BadRequestError(`${cidr} is not a valid cidr or ip`);
75
76
  }
76
77
  });
77
78
  this.acl.allow.forEach((cidr) => {
78
79
  // 4 => IPv4
79
- if (!Validator.default.isIPRange(cidr, 4)) {
80
- throw new common_1.CommonErrors.BadRequestError(`${cidr} is not a valid cidr`);
80
+ if (!Validator.default.isIPRange(cidr, 4) &&
81
+ !Validator.default.isIP(cidr, 4)) {
82
+ throw new common_1.CommonErrors.BadRequestError(`${cidr} is not a valid cidr or ip`);
81
83
  }
82
84
  });
83
85
  }
@@ -100,14 +102,16 @@ class ACLManager extends manager_1.EntityManager {
100
102
  }
101
103
  this.acl.deny.forEach((cidr) => {
102
104
  // 4 => IPv4
103
- if (!Validator.default.isIPRange(cidr, 4)) {
104
- throw new common_1.CommonErrors.BadRequestError(`${cidr} is not a valid cidr`);
105
+ if (!Validator.default.isIPRange(cidr, 4) &&
106
+ !Validator.default.isIP(cidr, 4)) {
107
+ throw new common_1.CommonErrors.BadRequestError(`${cidr} is not a valid cidr or ip`);
105
108
  }
106
109
  });
107
110
  this.acl.allow.forEach((cidr) => {
108
111
  // 4 => IPv4
109
- if (!Validator.default.isIPRange(cidr, 4)) {
110
- throw new common_1.CommonErrors.BadRequestError(`${cidr} is not a valid cidr`);
112
+ if (!Validator.default.isIPRange(cidr, 4) &&
113
+ !Validator.default.isIP(cidr, 4)) {
114
+ throw new common_1.CommonErrors.BadRequestError(`${cidr} is not a valid cidr or ip`);
111
115
  }
112
116
  });
113
117
  }
@@ -79,7 +79,17 @@ class PeerManager extends manager_1.EntityManager {
79
79
  // TODO: We will need a better way to validate this so is a valid SIP URI
80
80
  if (!this.peer.aor.startsWith("backend:") &&
81
81
  !this.peer.aor.startsWith("sip:")) {
82
- throw new common_1.CommonErrors.BadRequestError("the aorLink must start with backend: or sip:");
82
+ throw new common_1.CommonErrors.BadRequestError("the aor schema must start with `backend:` or `sip:`");
83
+ }
84
+ if (this.peer.aor.startsWith("backend:")) {
85
+ if (!this.peer.balancingAlgorithm) {
86
+ throw new common_1.CommonErrors.BadRequestError("when the aor schema is `backend:`, the balancing algorithm is required");
87
+ }
88
+ }
89
+ if (this.peer.aor.startsWith("sip:")) {
90
+ if (this.peer.balancingAlgorithm) {
91
+ throw new common_1.CommonErrors.BadRequestError("when the aor schema is `sip:`, the balancing algorithm is not allowed");
92
+ }
83
93
  }
84
94
  }
85
95
  validOrThrowUpdate() {
@@ -96,7 +106,17 @@ class PeerManager extends manager_1.EntityManager {
96
106
  // TODO: We will need a better way to validate this so is a valid SIP URI
97
107
  if (!this.peer.aor.startsWith("backend:") &&
98
108
  !this.peer.aor.startsWith("sip:")) {
99
- throw new common_1.CommonErrors.BadRequestError("the aorLink must start with backend: or sip:");
109
+ throw new common_1.CommonErrors.BadRequestError("the aor schema must start with `backend:` or `sip:`");
110
+ }
111
+ }
112
+ if (this.peer.aor.startsWith("backend:")) {
113
+ if (!this.peer.balancingAlgorithm) {
114
+ throw new common_1.CommonErrors.BadRequestError("when the aor schema is `backend:`, the balancing algorithm is required");
115
+ }
116
+ }
117
+ if (this.peer.aor.startsWith("sip:")) {
118
+ if (this.peer.balancingAlgorithm) {
119
+ throw new common_1.CommonErrors.BadRequestError("when the aor schema is `sip:`, the balancing algorithm is not allowed");
100
120
  }
101
121
  }
102
122
  }
@@ -109,6 +129,9 @@ class PeerManager extends manager_1.EntityManager {
109
129
  username: this.peer.username,
110
130
  aor: this.peer.aor,
111
131
  contactAddr: this.peer.contactAddr,
132
+ balancingAlgorithm: this.peer
133
+ .balancingAlgorithm,
134
+ withSessionAffinity: this.peer.withSessionAffinity,
112
135
  enabled: this.peer.enabled,
113
136
  credentialsRef: this.peer.credentialsRef,
114
137
  accessControlListRef: this.peer.accessControlListRef,
@@ -125,6 +148,8 @@ class PeerManager extends manager_1.EntityManager {
125
148
  username: peer.username,
126
149
  aor: peer.aor,
127
150
  contactAddr: peer.contactAddr,
151
+ balancingAlgorithm: peer.balancingAlgorithm,
152
+ withSessionAffinity: peer.withSessionAffinity,
128
153
  enabled: peer.enabled,
129
154
  credentialsRef: peer.credentialsRef,
130
155
  credentials: credentials_1.CredentialsManager.mapToDto(peer.credentials),
package/dist/service.js CHANGED
@@ -74,7 +74,7 @@ function pgDataService(config) {
74
74
  kinds.forEach((kind) => {
75
75
  const k = kind.toLowerCase();
76
76
  const delegate = prisma[kind];
77
- server.addService(common_1.CommonConnect.createService(k), {
77
+ server.addService(common_1.CommonConnect.createConnectService(k), {
78
78
  create: (0, create_1.create)(delegate.create, k),
79
79
  get: (0, get_1.get)(delegate.findUnique, k),
80
80
  findBy: (0, find_1.findBy)(delegate.findMany, k),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@routr/pgdata",
3
- "version": "2.0.8-alpha.18",
3
+ "version": "2.0.8-alpha.20",
4
4
  "description": "Postgres API Server for Routr Connect",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/routr#readme",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@fonoster/logger": "0.3.18",
23
- "@grpc/grpc-js": "^1.5.9",
23
+ "@grpc/grpc-js": "^1.8.4",
24
24
  "@opentelemetry/api": "^1.0.4",
25
25
  "@opentelemetry/exporter-jaeger": "^1.0.4",
26
26
  "@opentelemetry/instrumentation": "^0.27.0",
@@ -30,8 +30,8 @@
30
30
  "@opentelemetry/sdk-trace-node": "^1.0.4",
31
31
  "@opentelemetry/semantic-conventions": "^1.0.4",
32
32
  "@prisma/client": "^4.8.0",
33
- "@routr/common": "^2.0.8-alpha.18",
34
- "@routr/processor": "^2.0.8-alpha.18",
33
+ "@routr/common": "^2.0.8-alpha.20",
34
+ "@routr/processor": "^2.0.8-alpha.20",
35
35
  "google-protobuf": "^3.9.2",
36
36
  "pb-util": "^1.0.3",
37
37
  "validator": "^13.7.0"
@@ -54,5 +54,5 @@
54
54
  "@types/validator": "^13.7.10",
55
55
  "prisma": "^4.8.0"
56
56
  },
57
- "gitHead": "66ce6b3ed832bb8c549d344b3367aceed4b6da8f"
57
+ "gitHead": "a22ee8342d03f5dfe46fddba89ffe3e6d0d5deb6"
58
58
  }