Skip to content

network-utilities/range-ipv4-address

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Range IPv4 Address

range-ipv4-address.sh, contains a function that returns IP address with range.

The following covers how to install this branch as a submodule within your own project, and parameters that range-ipv4-address.sh currently responds to.

Byte size of range-ipv4-address.sh Open Issues Open Pull Requests Latest commits


Table of Contents


Quick Start

Bash Variables

_module_https_url='https://github.com/network-utilities/range-ipv4-address.git'
_module_relative_path='modules/range-ipv4-address'

Git Commands

cd "<your-git-project-path>"

git checkout master
git submodule add -b master --name range-ipv4-address "${_module_https_url}" "${_module_relative_path}"

Edit Your ReadMe File

Suggested additions so everyone has a good time with submodules

Clone with the following to avoid incomplete downloads


    git clone --recurse-submodules <url-for-your-project>


Update/upgrade submodules via


    git submodule update --init --recursive --merge

Example Usage

Example of sourcing and utilize range_ipv4_address features

example_usage.sh

#!/usr/bin/env bash


## Find true directory this script resides in
__SOURCE__="${BASH_SOURCE[0]}"
while [[ -h "${__SOURCE__}" ]]; do
    __SOURCE__="$(find "${__SOURCE__}" -type l -ls | sed -n 's@^.* -> \(.*\)@\1@p')"
done
__DIR__="$(cd -P "$(dirname "${__SOURCE__}")" && pwd)"


## Source module code within this script
source "${__DIR__}/modules/range-ipv4-address/range-ipv4-address.sh"


_ranged_ipv4_address="$(range_ipv4_address '192.168.0.5')"
printf 'IPv4 Address: %s\n' "${_ranged_ipv4_address}"

Test that things work!

Commit and Push

git add .gitmodules
git add modules/range-ipv4-address
git add README.md


git commit -F- <<'EOF'
:heavy_plus_sign: Adds network-utilities/range-ipv4-address#1 submodule


**Edits**


- `README.md` file, documentation updates for submodules


**Additions**

- `.gitmodules` file, tracks other Git repository code utilized by this project

- `modules/range-ipv4-address` submodule, Git tracked dependency
EOF


git push origin master

🎉 Excellent 🎉 your repository is now ready to begin unitizing code from this project!


Range IPv4 Address API

Lists listening ports for given service and protocol via netstat

Param Type Description
$1 string required Local NAT IP address to calculate range for

Returns: string, IP address

Throws Parameter_Error: range_ipv4_address not provided an IP address, when first parameter is not defined

Example: as a string

_ranged_ipv4_address="$(range_ipv4_address 'sshd')"

printf 'IPv4 Address: %s\n' "${_ranged_ipv4_address}"
#> IPv4 Address: 192.168.0.5/16

Attribution


License

Range IPv4 Address submodule quick start documentation
Copyright (C) 2019  S0AndS0

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation; version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
by `jesin`
on