Skip to content

Instantly share code, notes, and snippets.

@crawc
crawc / iptables.txt
Created February 8, 2022 16:52 — forked from warewolf/iptables.txt
iptables based rate limiting
-A INPUT -i eth0 -p udp -m udp --dport 5060 -j SIP
#
-A SIP -i eth0 -p udp -m udp --dport 5060 -m string --string "INVITE" --algo bm --from 23 --to 28 -m comment --comment "Catch SIP INVITEs" -j SIPINVITE
-A SIP -i eth0 -p udp -m udp --dport 5060 -m string --string "REGISTER" --algo bm --from 23 --to 30 -m comment --comment "Catch SIP REGISTERs" -j SIPREGISTER
-A SIP -m comment --comment "Catch and accept everything else" -j ACCEPT
#
-A SIPINVITE -m hashlimit --hashlimit-upto 4/min --hashlimit-burst 4 --hashlimit-mode srcip,dstip,dstport --hashlimit-name anon-sip-rateinv --hashlimit-srcmask 24 -m comment --comment "Rate limit SIP invites" -j ACCEPT
-A SIPINVITE -m limit --limit 10/min -j LOG --log-prefix "SIPINV DROP: "
-A SIPINVITE -m comment --comment "Rate limit exceeded, reject" -j REJECT
#
@crawc
crawc / originate_call.php
Created September 8, 2021 20:38 — forked from anpel/originate_call.php
Originate a call from Asterisk using PHP and Asterisk Manager Interface
/**
* Once this scipt is executed it will connect to the local port you have assigned to
* Asterisk (default: 5038) and send an authentication request. If successfull, it will
* send a second request to originate your call.
*
* The internal SIP line $internalPhoneline will be dialed, and when picked up the
* $target phone will be dialed using your outbound calls context ($context).
*
* Of course, you can modify the commands sent to the asterisk manager interface to suit your needs.
* you can find more about the available options at:
@crawc
crawc / test-php-basic-auth.php
Created June 28, 2021 13:58 — forked from rchrd2/test-php-basic-auth.php
PHP basic auth example
<?php
function require_auth() {
$AUTH_USER = 'admin';
$AUTH_PASS = 'admin';
header('Cache-Control: no-cache, must-revalidate, max-age=0');
$has_supplied_credentials = !(empty($_SERVER['PHP_AUTH_USER']) && empty($_SERVER['PHP_AUTH_PW']));
$is_not_authenticated = (
!$has_supplied_credentials ||
$_SERVER['PHP_AUTH_USER'] != $AUTH_USER ||
$_SERVER['PHP_AUTH_PW'] != $AUTH_PASS
@crawc
crawc / cloudsend.sh
Created February 8, 2021 23:31 — forked from tavinus/cloudsend.sh
Send files to Nextcloud/Owncloud shared folder using curl
#!/usr/bin/env bash
############################################################
# MIGRATED TO REPOSITORY
# https://github.com/tavinus/cloudsend.sh
#
# This gist will NOT be updated anymore
############################################################
############################################################
@crawc
crawc / rate_to_influx.sh
Last active December 24, 2021 15:27 — forked from lfdominguez/rate_to_influx.sh
Send traffics stats by ip from pfsense to influxdb
#!/bin/sh
#
# Author: Luis Felipe Domínguez Vega <ldominguezvega@gmail.com>
# https://gist.github.com/lfdominguez/08de623d9f9c0fa84e6b4d5d0d25025c
# Program to use with the rate software to send to InfluxDB the
# rate of each IP on interface
#
# rate_to_influx <influxdb_url> <influxdb_database> <local_network> <interface>
# rate_to_influx http://127.0.0.1:8086 network 192.168.0.0/24 re1
pushgatewayip="192.168.1.2:9091"
network="192.168.1.0/24"
rate -i bce1 -r 1 -e -n -Ab -a 255 -c "${network}" -d | while read -r line; do
host=`echo $line | cut -d':' -f1`
downloadrate=`echo $line | cut -d':' -f4`
uploadrate=`echo $line | cut -d':' -f5`
if [ ! -z "$downloadrate" -a "$downloadrate" != " " ]; then
echo "download_rate_bits $downloadrate" | curl --data-binary @- "${pushgatewayip}/metrics/job/pfsense/instance/${host}"
@crawc
crawc / index.html
Created June 23, 2020 20:13 — forked from diogocapela/index.html
Starter Template CDN Template Bootstrap 4
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Starter Template</title>
<meta name="description" content="">
@crawc
crawc / 00-cloud-config.yml
Created March 8, 2020 22:11 — forked from janeczku/00-cloud-config.yml
Annotated RancherOS Cloud-init configuration snippets
#cloud-config
# Set the hostname for this machine (takes precedence over hostname assigned by DHCP lease).
hostname: myhost
# Authorize SSH keys for the `rancher` sudoer user
ssh_authorized_keys:
- ssh-rsa AAA...ZZZ example1@rancher
@crawc
crawc / _usage.md
Created January 1, 2020 20:30 — forked from tbranyen/_usage.md
OpenWeatherMap / Weather Icons integration
  1. Include Weather Icons in your app: https://github.com/erikflowers/weather-icons

  2. Include the below JSON in your application, for example purposes, lets assume it's a global named weatherIcons.

  3. Make a request to OpenWeatherMap:

req = $.getJSON('http://api.openweathermap.org/data/2.5/weather?q=London,uk&callback=?');
@crawc
crawc / 00-genieacs.md
Created August 18, 2019 16:23 — forked from AfroThundr3007730/00-genieacs.md
My notes on setting up and configuring GenieACS.

Config files to get GenieACS up and running on Debian Testing, complete with GUI, Nginx SSL proxy, and systemd services.

Following the documentation here for dependencies, here for initial setup, then the wiki here for Nginx and SSL, should get you most of the way there. After that, I had a lot of googling to do, the results of which you can find below.

Filename Description
01-install.sh The installation instructions and commands.
02-config.json The genieacs services configuration.
03-openssl.cnf The openssl certificate configuration.
04-.env The environmental variables for genieacs-gui.