Skip to content

Instantly share code, notes, and snippets.

View pavel-odintsov's full-sized avatar
🛡️
On mission to deliver affordable DDoS protection

Pavel Odintsov pavel-odintsov

🛡️
On mission to deliver affordable DDoS protection
View GitHub Profile
@pavel-odintsov
pavel-odintsov / pps.sh
Last active August 27, 2023 20:21
Simple script to print packet rate for interface
#!/bin/bash
# Interval of calculation in seconds
INTERVAL="1"
if [ -z "$1" ]; then
echo
echo usage: $0 [network-interface]
echo
echo e.g. $0 eth0
@pavel-odintsov
pavel-odintsov / irq_balance_habrahabr.sh
Created June 25, 2015 12:25
irq_balance_habrahabr.sh
#!/bin/bash
# from http://habrahabr.ru/post/108240/
ncpus=`grep -ciw ^processor /proc/cpuinfo`
test "$ncpus" -gt 1 || exit 1
n=0
for irq in `cat /proc/interrupts | grep eth | awk '{print $1}' | sed s/\://g`
do
f="/proc/irq/$irq/smp_affinity"
package qxp;
use strict;
# code from: https://code.google.com/p/qxp/source/browse/qxp/qxp.pm
sub H($){pack'H*',$_[0]}
sub by{map{[splice@_,1,$_[0]]}!($#_%$_[0])..$#_/$_[0]}
sub is($){$_ eq$_[0]}
sub cat{join'',@_}
sub list{@_}
@pavel-odintsov
pavel-odintsov / pps.sh
Created November 3, 2015 11:41 — forked from evgenypim/pps.sh
pps.sh for habrahabr
#!/bin/bash
INTERVAL="1" # update interval in seconds
if [ -z "$1" ]; then
echo
echo usage: $0 [network-interface]
echo
echo e.g. $0 eth0
echo
@pavel-odintsov
pavel-odintsov / vimrc
Last active May 8, 2022 13:23
vimrc_odintsov
"
" First of all, pleae install latest vim for convinience: https://launchpad.net/~jonathonf/+archive/ubuntu/vim
" Then install vim go
" git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go
"
" Fix arrow keys that display A B C D on remote shell:
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
@pavel-odintsov
pavel-odintsov / patricia_performance_tests.cpp
Last active February 20, 2022 21:04
Patricia performance test for Medium
#include <arpa/inet.h>
#include <fstream>
#include <iostream>
#include <math.h>
#include <netinet/in.h>
#include <stdint.h>
#include <stdio.h>
#include <string>
#include <sys/socket.h>
#include <sys/time.h>
@pavel-odintsov
pavel-odintsov / traffic_structures_performance_tests.cpp
Created February 21, 2022 23:25
Example code to reproduce libsparsehash segmentation faults
#include <functional>
#include <iomanip>
#include <iostream>
#include <locale.h>
#include <map>
#include <stdint.h>
#include <sys/time.h>
#include <unistd.h>
#include "../fastnetmon_types.h"
@pavel-odintsov
pavel-odintsov / signal_prefix.pl
Created April 13, 2022 15:47
FastNetMon Advanced callback script to announce specific signal prefix when we detect an attack
#!/usr/bin/perl
use strict;
use warnings;
use JSON;
use Data::Dumper;
my $community = '65000:777';
Element size: 248 bytes
Total structure size: 2365 Mbytes
std::map: 5.5 mega ops per second
std::map big endian keys full scan: 17.2 mega ops per second
std::map big endian keys: 1.3 mega ops per second
std::map big endian keys full scan: 6.3 mega ops per second
CPU: AMD Ryzen 5 3600 6-Core Processor
Boost 1.78
Element size: 248 bytes
Total structure size: 2365 Mbytes
std::map: 5.1 mega ops per second
std::map big endian keys full scan: 17.3 mega ops per second