This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Copyright (C) 2016 The Linux Containers Project | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| function ::netmask2cidr() | |
| { | |
| case $1 in | |
| 0x*) | |
| local hex=${1#0x*} quad= | |
| while [ -n "${hex}" ]; do | |
| local lastbut2=${hex#??*} | |
| quad=${quad}${quad:+.}0x${hex%${lastbut2}*} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # $1 is a decimal number between 0-255 | |
| dec2bin () { | |
| [ -z "$1" ] && return | |
| D2B=({0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}) | |
| echo ${D2B[$1]} | |
| } | |
| # $1 is ip address (dotted quad) | |
| # $2 is netmask (dotted quad) | |
| calc_network () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Return netmask for a given network and CIDR. | |
| cidr_to_netmask() { | |
| value=$(( 0xffffffff ^ ((1 << (32 - $2)) - 1) )) | |
| echo "$(( (value >> 24) & 0xff )).$(( (value >> 16) & 0xff )).$(( (value >> 8) & 0xff )).$(( value & 0xff ))" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ############################ | |
| ## Methods | |
| ############################ | |
| prefix_to_bit_netmask() { | |
| prefix=$1; | |
| shift=$(( 32 - prefix )); | |
| bitmask="" | |
| for (( i=0; i < 32; i++ )); do | |
| num=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Calculates network and broadcast based on supplied ip address and netmask | |
| # Usage: broadcast_calc.sh 192.168.0.1 255.255.255.0 | |
| # Usage: broadcast_calc.sh 192.168.0.1/24 | |
| tonum() { | |
| if [[ $1 =~ ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+) ]]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ############################ | |
| ## Methods | |
| ############################ | |
| prefix_to_bit_netmask() { | |
| prefix=$1; | |
| shift=$(( 32 - prefix )); | |
| bitmask="" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ############################ | |
| ## Methods | |
| ############################ | |
| prefix_to_bit_netmask() { | |
| prefix=$1; | |
| shift=$(( 32 - prefix )); | |
| bitmask="" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo apt-get -y install gcc g++ make cmake doxygen pandoc awk sed perl python3 python-is-python3 m4 bison flex lzip lcov git zlib1g-dev libssl-dev libnghttp2-dev autoconf autoconf-archive autogen automake autopoint libtool pkg-config texinfo nettle-dev libunistring-dev gettext make libbz2-dev libbrotli-dev libzstd-dev liblz-dev libpcre2-dev libmicrohttpd-dev libgpgme-dev liblzma-dev libgnutls28-dev libgcrypt20-dev git-merge-changelog libidn2-0 libpsl-dev # libpcre3-dev nettle-bin lzma brotli zstd lzip | |
| cd ~/Downloads | |
| mkdir wget-dev | |
| cd wget-dev | |
| git clone https://gitlab.com/rockdaboot/libhsts | |
| cd libhsts | |
| autoreconf -fi | |
| ./configure | |
| make |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'socket' | |
| # echo server | |
| Socket.udp_server_loop(4444) do |data, src| | |
| src.reply data | |
| end | |
| # client | |
| addr = Socket.sockaddr_in(4444, "localhost") | |
| socket = Socket.new(:INET, :DGRAM) | |
| begin |