Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stability Update 20220425 #45

Merged
merged 11 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/tool_shlock_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ while [ $# -gt $MINPARAMS ]; do # Until you run out of parameters . . .

case "$1" in
-p|--pid) shift ; export PID_VALUE="${1}" ;;
-v|--verbose) IS_VERBOSE_MODE=1 ;;
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved
-f|--file) shift ; export LOCK_FILE="${1}" ;;
-*) echo "$0: \"${1}\" Argument Unrecognized!" 1>&2 || false ;;
esac
Expand All @@ -82,14 +81,14 @@ done
fi

if [[ ( -e "${LOCK_FILE}" ) ]] ; then
if [[ ( "$PID_VALUE}" -eq $(head -n 1 "${LOCK_FILE}") ) ]] ; then
if [[ ( "${PID_VALUE}" -eq $(head -n 1 "${LOCK_FILE}") ) ]] ; then
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved
EXIT_CODE=0 ;
else
EXIT_CODE=$(head -n 1 "${LOCK_FILE}") ;
fi
fi

if [[ $# -eq 0 ]] ; then
if [[ ( $# -eq 0 ) ]] ; then
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved
echo -n "${PID_VALUE:-$PPID}" > "${LOCK_FILE}" ; wait ;
test -e "${LOCK_FILE}" || false ;
EXIT_CODE=0 ;
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ PHONY: must_be_root cleanup

build:
$(QUIET)$(ECHO) "INFO: No need to build. Try 'make -f Makefile install'"
$(QUIET)$(PYTHON) setup.py build
$(QUIET)$(PYTHON) setup.py bdist_wheel --universal
$(QUIET)$(PYTHON) -W ignore setup.py build
$(QUIET)$(PYTHON) -W ignore setup.py bdist_wheel --universal
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved
$(QUITE)$(WAIT)
$(QUIET)$(ECHO) "build DONE."

Expand All @@ -98,8 +98,8 @@ uninstall:
$(QUIET)$(ECHO) "$@: Done."

purge: clean uninstall
$(QUIET)$(PYTHON) ./setup.py uninstall 2>/dev/null || true
$(QUIET)$(PYTHON) ./setup.py clean || true
$(QUIET)$(PYTHON) -W ignore ./setup.py uninstall 2>/dev/null || true
$(QUIET)$(PYTHON) -W ignore ./setup.py clean || true
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved
$(QUIET)$(RMDIR) ./build/ 2>/dev/null || true
$(QUIET)$(RMDIR) ./dist/ 2>/dev/null || true
$(QUIET)$(RMDIR) ./.eggs/ 2>/dev/null || true
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ Continuous integration testing is handled by github actions and the generous Cir

### Stable (Mainstream):

[![Stable-CircleCI](https://circleci.com/gh/reactive-firewall/multicast/tree/stable.svg?style=svg)](https://circleci.com/gh/reactive-firewall/multicast/tree/stable)
[![Stable-CI](https://github.com/reactive-firewall/multicast/actions/workflows/Tests.yml/badge.svg?branch=stable)](https://github.com/reactive-firewall/multicast/actions/workflows/Tests.yml)
[![Stable-Appveyor](https://ci.appveyor.com/api/projects/status/0h5vuexyty9lbl81/branch/stable?svg=true)](https://ci.appveyor.com/project/reactive-firewall/multicast/branch/stable)
[![stable-code-coverage](https://codecov.io/gh/reactive-firewall/multicast/branch/stable/graph/badge.svg)](https://codecov.io/gh/reactive-firewall/multicast/branch/stable/)
[![Stable CircleCI](https://circleci.com/gh/reactive-firewall/multicast/tree/stable.svg?style=svg)](https://circleci.com/gh/reactive-firewall/multicast/tree/stable)
[![Stable CI](https://github.com/reactive-firewall/multicast/actions/workflows/Tests.yml/badge.svg?branch=stable)](https://github.com/reactive-firewall/multicast/actions/workflows/Tests.yml)
[![Stable Appveyor](https://ci.appveyor.com/api/projects/status/0h5vuexyty9lbl81/branch/stable?svg=true)](https://ci.appveyor.com/project/reactive-firewall/multicast/branch/stable)
[![Stable Code Coverage](https://codecov.io/gh/reactive-firewall/multicast/branch/stable/graph/badge.svg)](https://codecov.io/gh/reactive-firewall/multicast/branch/stable/)
[![CodeQL](https://github.com/reactive-firewall/multicast/actions/workflows/codeql-analysis.yml/badge.svg?branch=stable)](https://github.com/reactive-firewall/multicast/actions/workflows/codeql-analysis.yml)
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved

## FAQ

Expand All @@ -44,6 +45,7 @@ Continuous integration testing is handled by github actions and the generous Cir
# cd /MY-AWSOME-DEV-PATH
git clone https://github.com/reactive-firewall/multicast.git multicast
cd ./multicast
# checkout stable
# make clean ; make test ; make clean ;
make install ;
python3 -m multicast --help ;
Expand Down
75 changes: 66 additions & 9 deletions multicast/recv.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,71 @@ def parseArgs(arguments=None):
return parser.parse_args(arguments)


def joinstep(groups, port, iface=None, bind_group=None, isock=None):
"""Will join the given multicast group(s).

The JOIN function. Will start to listen on the given port of an interface for multicast
messages to the given group(s).
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved

Minimal Acceptance Testing:

First setup test fixtures by importing multicast.

>>> import multicast
>>> multicast.recv is not None
True
>>>

Testcase 1: Stability testing.

>>> import multicast
>>>
>>> multicast.recv is None
False
>>>
>>> multicast.recv.joinstep is None
False
>>> type(multicast.recv.joinstep)
<class 'function'>
>>> multicast.recv.joinstep(None, 59991) #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS
<socket.socket...>
>>> tst_fxtr = multicast.__MCAST_DEFAULT_GROUP
>>> multicast.recv.joinstep([tst_fxtr], 59991) #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS
<socket.socket...>
>>> multicast.recv.joinstep(
... [tst_fxtr], 59991, None, tst_fxtr
... ) #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS
<socket.socket...>
>>> sk_fxtr = genSocket()
>>> multicast.recv.joinstep(
... [tst_fxtr], 59991, None, tst_fxtr, sk_fxtr
... ) #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS
<socket.socket...>
>>> sk_fxtr.close()
>>>
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved


"""
if groups is None:
groups = []
if isock is None:
sock = genSocket()
else:
sock = isock.dup()
try:
sock.bind(('224.0.0.1' if bind_group is None else bind_group, port))
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved
for group in groups:
mreq = struct.pack(
'4sl' if iface is None else '4s4s',
socket.inet_aton(group),
socket.INADDR_ANY if iface is None else socket.inet_aton(iface)
)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
except Exception as err: # pragma: no branch
raise NotImplementedError("""[CWE-440] Not Implemented.""", err) # pragma: no cover
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved
return sock


def hearstep(groups, port, iface=None, bind_group=None):
"""Will listen on the given port of an interface for multicast messages to the given group(s).

Expand Down Expand Up @@ -313,18 +378,10 @@ def hearstep(groups, port, iface=None, bind_group=None):
"""
if groups is None:
groups = []
sock = genSocket()
sock = joinstep(groups, port, iface, bind_group, None)
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved
msgbuffer = str(__BLANK)
chunk = None
try:
sock.bind(('224.0.0.1' if bind_group is None else bind_group, port))
for group in groups:
mreq = struct.pack(
'4sl' if iface is None else '4s4s',
socket.inet_aton(group),
socket.INADDR_ANY if iface is None else socket.inet_aton(iface)
)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
while True:
chunk = sock.recv(1316)
if not (chunk is None): # pragma: no branch
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved
[build-system]
requires = ["setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta:__legacy__"
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ long_description_content_type = text/markdown
home_page = https://github.com/reactive-firewall/multicast
download_url = https://github.com/reactive-firewall/multicast.git
license = MIT
license_file = LICENSE.md
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved
license_files =
LICENSE[.md]*

Expand Down
17 changes: 15 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,17 @@
"""

try:
import os, warnings
warnings.simplefilter("default") # Change the filter in this process
os.environ["PYTHONWARNINGS"] = "default" # Also affect subprocesses
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved
from setuptools import setup
from setuptools import find_packages
from setuptools.config import read_configuration
with warnings.catch_warnings():
warnings.simplefilter("ignore")
try:
from setuptools.config import read_configuration
except Exception:
from setuptools.config.setupcfg import read_configuration
except Exception:
raise NotImplementedError("""[CWE-440] Not Implemented.""")

Expand Down Expand Up @@ -78,7 +86,12 @@ def readFile(filename):
requirements = None


conf_dict = read_configuration("""setup.cfg""", ignore_option_errors=True)
conf_dict = None


with warnings.catch_warnings():
warnings.simplefilter("ignore")
conf_dict = read_configuration("""setup.cfg""", ignore_option_errors=True)
reactive-firewall marked this conversation as resolved.
Show resolved Hide resolved


readme = readFile("""README.md""")
Expand Down