Skip to content

Instantly share code, notes, and snippets.

@crawc
crawc / mpv-ipcam-monitor.sh
Created October 4, 2022 18:05 — forked from paius1/mpv-ipcam-monitor.sh
Script to view and Monitor rtsp:// stream from a security camera
#!/usr/bin/env bash
#
# Simple script to monitor a ipcam stream running on mpv
# using the ipc-server
# requires mpv, socat, and jq written for bash 4
# xwinwrap to run on the Desktop
# by gmail plgroves 2019
#
# script creates a kill script in same path as this script
# named This_script-kill
@crawc
crawc / udptextd.php
Created August 25, 2022 01:26 — forked from tiebingzhang/udptextd.php
An one-off PHP UDP server to listen on a UDP port and print the text received. Can be used as a very basic UDP log listener.
#!/usr/bin/php -f
<?php
error_reporting(~E_WARNING);
//Create a UDP socket
if(!($sock = socket_create(AF_INET, SOCK_DGRAM, 0))) {
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
die("Couldn't create socket: [$errorcode] $errormsg \n");
}
echo "Socket created \n";
@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 <[email protected]>
# 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