Skip to content

Commit

Permalink
test_modules: add tcp module
Browse files Browse the repository at this point in the history
This patch adds the TCP module. In experimentation, it was determined a UDP module is impossible.

Signed-off-by: Amy Parker <amy@amyip.net>
  • Loading branch information
amyipdev committed Jul 28, 2023
1 parent 0539c97 commit 1310a90
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 1 deletion.
4 changes: 3 additions & 1 deletion srv/test_modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from . import ping
from . import httpt
from . import ssvplwc
from . import tcpt

modules = {
"ping": ping.ping_t,
"http": httpt.http_t,
"ssvplwc": ssvplwc.ssvplwc_t
"ssvplwc": ssvplwc.ssvplwc_t,
"tcp": tcpt.tcp_t
}


Expand Down
22 changes: 22 additions & 0 deletions srv/test_modules/httpt.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# ssvp: server statistics viewer project
# Copyright (C) 2023 Amy Parker <amy@amyip.net>
#
# 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; either version 3 of the License, or
# (at your option) any later version.
#
# 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA or visit the
# GNU Project at https://gnu.org/licenses. The GNU Affero General Public
# License version 3 is available at, for your convenience,
# https://www.gnu.org/licenses/agpl-3.0.en.html.

import requests

methods = {
Expand Down
22 changes: 22 additions & 0 deletions srv/test_modules/ping.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# ssvp: server statistics viewer project
# Copyright (C) 2023 Amy Parker <amy@amyip.net>
#
# 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; either version 3 of the License, or
# (at your option) any later version.
#
# 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA or visit the
# GNU Project at https://gnu.org/licenses. The GNU Affero General Public
# License version 3 is available at, for your convenience,
# https://www.gnu.org/licenses/agpl-3.0.en.html.

import ping3


Expand Down
22 changes: 22 additions & 0 deletions srv/test_modules/ssvplwc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# ssvp: server statistics viewer project
# Copyright (C) 2023 Amy Parker <amy@amyip.net>
#
# 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; either version 3 of the License, or
# (at your option) any later version.
#
# 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA or visit the
# GNU Project at https://gnu.org/licenses. The GNU Affero General Public
# License version 3 is available at, for your convenience,
# https://www.gnu.org/licenses/agpl-3.0.en.html.

import socket


Expand Down
33 changes: 33 additions & 0 deletions srv/test_modules/tcpt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# ssvp: server statistics viewer project
# Copyright (C) 2023 Amy Parker <amy@amyip.net>
#
# 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; either version 3 of the License, or
# (at your option) any later version.
#
# 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, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA or visit the
# GNU Project at https://gnu.org/licenses. The GNU Affero General Public
# License version 3 is available at, for your convenience,
# https://www.gnu.org/licenses/agpl-3.0.en.html.

import socket


def tcp_t(srv: dict) -> bool:
ss = socket.socket()
try:
ss.connect((srv["ip"], int(srv["args"])))
ss.close()
return True
except ConnectionRefusedError:
return False

0 comments on commit 1310a90

Please sign in to comment.