Skip to content

Instantly share code, notes, and snippets.

View andris9's full-sized avatar
🇪🇪

Andris Reinman andris9

🇪🇪
View GitHub Profile
@andris9
andris9 / ratelimit.js
Created January 8, 2024 13:53
Vaese mehe rate limit 1 tund
'use strict';
const Redis = require('ioredis');
const redis = new Redis({
port: 6379,
host: '127.0.0.1'
});
async function rateLimitedIp(ip) {
const rlKey = 'ratelimits';
@andris9
andris9 / submit.sh
Created November 29, 2023 09:28
Example script to submit large attachments to EmailEngine
#!/bin/bash
# This example script submits large attachments
# Usage
# 1. Edit the variables below
# 2. Run the script
# $ bash ./submit.sh
## EDIT THE FOLLOWING VALUES
@andris9
andris9 / transport.js
Created March 4, 2023 16:54
Custom DNS resolving with Nodemailer
// The following example sets up Nodemailer in a way that it does not perform any DNS resolving on its own
const hostname = 'smtp.gmail.com';
const resolved = (await dns.promises.resolve(hostname))[0];
const transporter = nodemailer.createTransport({
host: resolved, // <- IP address of the SMTP server
name: 'my.machine.hostname', // <- PTR name of sender's public IP address, ends up in the Recieved: header
tls: {
servername: hostname, // <- hostname of the SMTP server, needed to verify TLS
@andris9
andris9 / readme.md
Last active June 7, 2022 09:07
Test client for WildDuck WebAuthn API endpoints

Test client for WildDuck WebAuthn API endpoints

"use strict";
const fs = require("fs");
const http = require("http");
const API_PATH = "http://127.0.0.1:3000";
const ACCESS_TOKEN = "b2d73a529d602c0c9dfec62227a22151af04ca45227a7c7f5e24c35a6b004584";
const ACCOUNT_ID = "ekiri";
const ATTACHMENT_ID = "AAAAAQAABPsy";

Step 1. Register a new account

Register a new account with IMAP and SMTP settings (reference)

curl -XPOST "http://127.0.0.1:3000/v1/account" \
    -H "Authorization: Bearer f77cf263b70488c7a35bf1539fd544a81a88711ff74326ce9793022df08d91b9" \
    -H "Content-type: application/json" \
    -d '{
 "account": "example",
@andris9
andris9 / install-node-app.sh
Last active September 21, 2021 10:51
Run node.js app as a systemd service
#!/bin/bash
SERVICE_NAME=$1
DOMAIN_NAME=$2
HTTP_PORT=$3
SERVICE_USER=${4:-www-data}
DEPLOY_KEY=$5
NODE_ENV=${6:-production}
DEPLOY_USER="deploy"
// npm install bull bull-arena express
// node bull-ui.js
// open http://localhost:6789
const Arena = require("bull-arena");
const Bull = require("bull");
const express = require("express");
const app = express();
const router = express.Router();
@andris9
andris9 / onion.js
Created March 24, 2021 12:43
Generate onion v3 address from ed25519 public key
// npm install hi-base32 sha3
const base32 = require("hi-base32");
const { SHA3 } = require("sha3");
function verifyOnionAddress(addr) {
const suffixLength = ".onion".length;
if (!/\.onion$/i.test(addr) || addr.length != 56 + suffixLength) {
return false;
}
{
"dkim": {
"headerFrom": [
"info@srv.dev"
],
"envelopeFrom": "andris@ekiri.ee",
"results": [
{
"signingDomain": "out.srv.dev",
"selector": "smtp",