Skip to content

Commit

Permalink
Devel (#24)
Browse files Browse the repository at this point in the history
* Changes in decoding the command NO due to FW 1.9a

* Version change and minor fixes

* Minor comments fixes

---------

Co-authored-by: Marco Simone Zuppone <m.zuppone@computer.org>
  • Loading branch information
mszeu and Marco Simone Zuppone committed Sep 27, 2023
1 parent 2d9c243 commit 670b84d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# PayShieldPressureTest

<img src=images/supporting-member-badge.png width=100>
<img src=images/supporting-member-badge.png width=100 alt="logo of Python Foundation Supporting Member">

The **pressureTest.py** Python script creates a workload on the **Thales payShield 10k** and **9k** appliances.
The script can be useful during demonstrations of the monitoring features of the appliance and can be used in every case
you need to generate a workload for testing purposes.

It requires **Python 3**. It was tested on **Python 3.10.2** using a **payShield 10k** with firmware **1.7**.
It requires **Python 3**. It was tested on **Python 3.10.2** using a **payShield 10k** with firmware **1.7a**.

## Version

**1.3**
**1.3.1**

## Usage

Expand Down Expand Up @@ -103,7 +103,7 @@ The possible choices are:

C:\Test>python pressureTest.py 192.168.0.36 --nc --times 2

PayShield stress utility, version 1.3, by Marco S. Zuppone - msz@msz.eu - https://msz.eu
PayShield stress utility, version 1.3.1, by Marco S. Zuppone - msz@msz.eu - https://msz.eu
To get more info about the usage invoke it with the -h option This software is open source, and it is under the Affero
AGPL 3.0 license

Expand Down
16 changes: 10 additions & 6 deletions pressureTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import Tuple, Dict
from types import FunctionType

VERSION = "1.3"
VERSION = "1.3.1"


class PayConnector:
Expand Down Expand Up @@ -233,13 +233,18 @@ def decode_no(response_to_decode: bytes, head_len: int):
str_pointer = str_pointer + 1
print("Type of connection: ", NET_PROTO.get(response_to_decode[str_pointer:str_pointer + 1], "Unknown"))
str_pointer = str_pointer + 1
print("Number of TCP sockets: ", response_to_decode[str_pointer:str_pointer + 2])
str_pointer = str_pointer + 2
if len(response_to_decode) > (24 + head_len): # FW 1.8a or more
socket_field_len = 4 # From FW 1.8a the Number of TCP sockets is 4 character long instead of 2
else:
socket_field_len = 2
print("Number of TCP sockets: ", response_to_decode[str_pointer:str_pointer + socket_field_len])
str_pointer = str_pointer + socket_field_len
print("Firmware number: ", response_to_decode[str_pointer:str_pointer + 9])
str_pointer = str_pointer + 9
print("Reserved: ", response_to_decode[str_pointer:str_pointer + 1])
str_pointer = str_pointer + 1
print("Reserved: ", response_to_decode[str_pointer:str_pointer + 4])

else: # Mode 01
str_pointer = str_pointer + 2
if response_to_decode[str_pointer:str_pointer + 1] == '0':
Expand Down Expand Up @@ -1003,8 +1008,8 @@ def common_parser(response_to_decode: bytes, head_len: int) -> Tuple[str, int, i

parser = argparse.ArgumentParser(
description="Generates workload on PayShield 10k and 9k for the sake of testing and demonstration.",
epilog="For any questions, feedback, suggestions or send money (yes...it's a dream, I know), you can contact the "
"author at msz@msz.eu")
epilog="For any questions, feedback, suggestions or send money (yes...it's a dream, I know), you can contact "
"the author at msz@msz.eu")
parser.add_argument("host", help="Ip address or hostname of the payShield")
group = parser.add_mutually_exclusive_group()
parser.add_argument("--port", "-p", help="The host port. "
Expand Down Expand Up @@ -1050,7 +1055,6 @@ def common_parser(response_to_decode: bytes, head_len: int) -> Tuple[str, int, i
parser.add_argument("--decode", help="If specified the reply of the payShield is interpreted "
"if a decoder function for that command has been implemented.",
action="store_true")

parser.add_argument("--times", help="How many times to repeat the operation "
"If not specified the default is 1000.", type=int, default=1000)
parser.add_argument("--proto", help="Accepted values are tcp, udp or tls. The default is tcp", default="tcp",
Expand Down

0 comments on commit 670b84d

Please sign in to comment.