Skip to content

Instantly share code, notes, and snippets.

@Phandorin
Phandorin / tokens.md
Created December 16, 2024 22:11 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@Phandorin
Phandorin / bridge-diff-subnet.sh
Created October 3, 2024 14:07 — forked from glenselle/bridge-diff-subnet.sh
Raspberry PI4 Wifi to Eth Bridge
#!/usr/bin/env bash
set -e
[ $EUID -ne 0 ] && echo "run as root" >&2 && exit 1
apt-get update && apt install -y dnsmasq
# Create a directory where we will store our `iptables` forwarding rules.
mkdir -p /etc/iptables
@Phandorin
Phandorin / Wireguard_optimal_mtu.md
Last active October 17, 2024 07:17 — forked from nitred/optimal_mtu.md
Wireguard Optimal MTU

About

  • I faced bandwidth issues between a WG Peer and a WG server. Download bandwidth when downloading from WG Server to WG peer was reduced significantly and upload bandwidth was practically non existent.
  • I found a few reddit posts that said that we need to choose the right MTU. So I wrote a script to find an optimal MTU.
  • Ideally I would have liked to have run all possible MTU configurations for both WG Server and WG Peer but for simplicity I choose to fix the WG Server to the original 1420 MTU and tried all MTUs from 1280 to 1500 for the WG Peer.

Testing

  • On WG server, I started an iperf3 server
  • On WG peer, I wrote a script that does the following:
    • wg-quick down wg0
  • Edit MTU in the /etc/wireguard/wg0.conf file
@Phandorin
Phandorin / make-wg-client.sh
Created June 7, 2023 08:26 — forked from pR0Ps/make-wg-client.sh
Script to generate wireguard configs for clients to allow them to connect to the local wireguard server
#!/bin/bash
#######
# Setup
#######
### Enable IPv4/6 forwarding:
# # In /etc/sysctl.d/30-ipforward.conf :
# net.ipv4.ip_forward=1
# net.ipv6.conf.default.forwarding=1
# net.ipv6.conf.all.forwarding=1
@Phandorin
Phandorin / ssh_client.go
Created July 18, 2019 14:57 — forked from iamralch/ssh_client.go
SSH client in GO
package main
import (
"fmt"
"io"
"io/ioutil"
"net"
"os"
"strings"
@Phandorin
Phandorin / aaencode.cxx
Created September 28, 2017 08:33 — forked from mattn/aaencode.cxx
C++版aaencode/jjencode
// MSVC: cl /wd4819 /EHsc aaencode.cxx
// gcc: g++ -o aaencode aaencode.cxx
//
// usage: aaencode < foo.js # jjencode
// aaencode -aa < foo.js # aaencode
#include <sstream>
#include <iostream>
#include <string>