ramm 0.0.32 → 0.0.34

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/dist/ramm.js CHANGED
@@ -225,7 +225,10 @@ var addNftPodmanRule = async () => {
225
225
  await execCommand("nft insert rule inet ramm prerouting iifname @podman_interfaces accept");
226
226
  };
227
227
  // src/nft.ts
228
- var createNftTable = ({ allowedIpV4 }) => {
228
+ var createNftTable = ({
229
+ allowedIpV4,
230
+ allowedPorts
231
+ }) => {
229
232
  const nftTable = `table inet ramm {
230
233
  set allowed_ipv4 {
231
234
  type ipv4_addr
@@ -240,8 +243,10 @@ var createNftTable = ({ allowedIpV4 }) => {
240
243
  ip saddr @allowed_ipv4 tcp dport 22 accept
241
244
  tcp dport 22 ct state new limit rate over 700/minute burst 5 packets drop
242
245
  tcp dport 22 accept
243
- tcp dport 80 accept
244
- tcp dport 443 accept
246
+ ${allowedPorts.map((port) => {
247
+ return `tcp dport ${port} accept`;
248
+ }).join(`
249
+ `)}
245
250
  }
246
251
 
247
252
  chain local_chain {
@@ -258,10 +263,11 @@ var createNftTable = ({ allowedIpV4 }) => {
258
263
  return nftTable;
259
264
  };
260
265
  var setupNftable = async ({
261
- allowedIpV4
266
+ allowedIpV4,
267
+ allowedPorts
262
268
  }) => {
263
269
  await execCommand("nft flush ruleset");
264
- const nftTable = createNftTable({ allowedIpV4 });
270
+ const nftTable = createNftTable({ allowedIpV4, allowedPorts });
265
271
  await execCommand(`nft -f - <<EOF
266
272
  ${nftTable}
267
273
  EOF`);
@@ -356,8 +362,9 @@ var getServerFingerprint = async (context) => {
356
362
  return stdout.replace("localhost", context.domain);
357
363
  };
358
364
  var saveSshFingerptint = async (filePath, context) => {
365
+ const normalizedPath = normalizePath(filePath);
359
366
  const fingerprint = await getServerFingerprint(context);
360
- await writeIfNewCompletely(filePath, fingerprint);
367
+ await writeIfNewCompletely(filePath, normalizedPath);
361
368
  };
362
369
  async function createSshKey(filePath, comment) {
363
370
  printFunction(`${createSshKey.name} ${filePath}`);
@@ -1,4 +1,5 @@
1
1
  export declare const localNftChainName = "local_chain";
2
- export declare const setupNftable: ({ allowedIpV4, }: {
2
+ export declare const setupNftable: ({ allowedIpV4, allowedPorts, }: {
3
3
  allowedIpV4: string[];
4
+ allowedPorts: string[];
4
5
  }) => Promise<void>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ramm",
3
3
  "type": "module",
4
- "version": "0.0.32",
4
+ "version": "0.0.34",
5
5
  "scripts": {
6
6
  "build": "bun build ./src/ramm.ts --target bun --outdir ./dist && cp ./src/bun.sh ./dist/bun.sh",
7
7
  "types": "tsc --project tsconfig.types.json"