From 5df4609f499295aee1e4f931abe2461a1cf23e1c Mon Sep 17 00:00:00 2001 From: Solomon Himelbloom <7608183+TechSolomon@users.noreply.github.com> Date: Sun, 21 Apr 2024 16:30:04 -0800 Subject: [PATCH] Repository license for project report (#45) * Create LICENSE * docs: Python comment for non-MIT licensed code --- LICENSE | 21 +++++++++++++++++++++ Makefile | 2 +- sample/FendTcpClientExample.py | 19 +++++++++++-------- sample/FendTcpServerExample.py | 25 ++++++++++++++----------- sample/FendUdpClientExample.py | 19 +++++++++++-------- sample/FendUdpServerExample.py | 15 +++++++++------ 6 files changed, 67 insertions(+), 34 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0f41a46 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Solomon Himelbloom + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile index 6477a9e..3f9fbc0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BIN_NAME=diode -BIN_VERSION=0.1.2 +BIN_VERSION=0.1.3 BIN_DATE=$(shell date +%FT%T%z) all: build diff --git a/sample/FendTcpClientExample.py b/sample/FendTcpClientExample.py index 888317a..8a7ce17 100644 --- a/sample/FendTcpClientExample.py +++ b/sample/FendTcpClientExample.py @@ -1,4 +1,7 @@ -""" +# Fend TCP and UDP Client/Server Example Python Test Scripts +# Copyright (c) 2023 Fend Incorporated. All rights reserved. + +""" This is an example Python script provided to aid in the integration of a Fend Data Diode in a TCP Client/Server application. For this example a simple socket is extabilshed with the diode's TCP server and a test message is continuously sent to the input side @@ -11,13 +14,13 @@ For these scripts to function, the diode will need to be setup in TCP Client/Server mode. Please see the user manual on instruction for this setup process. -These scripts will continuously run until aborted. +These scripts will continuously run until aborted. The following is the expected step by step process of what the script does: 1. The script creates a socket object named "client". 2. A connection attempt to the diode is made. 3. If the connection is made, the script enters a sending loop. -4. This loop will check to see if the data is larger than 1460 bytes. If so, it will get a chunk and send that. +4. This loop will check to see if the data is larger than 1460 bytes. If so, it will get a chunk and send that. 5. The script will then wait for the diode to send its ACK before proceeding. 6. The loop will continue until all the data has been chunked and transmitted. 7. The script waits 1 second. @@ -30,10 +33,10 @@ from timeit import default_timer # Change this to the IP address of your diode's Input Side IP Address. -diodeInputSideIP = "192.168.1.99" +diodeInputSideIP = "192.168.1.99" # Change this to the Diode TCP Server Port in your diode's Input Side TCP Passthrough Settings. -diodeTcpPassthroughPort = 50000 +diodeTcpPassthroughPort = 50000 # create a socket client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -48,12 +51,12 @@ try: while True: # Send data to diode - if len(data) > 1460: # If the data you wish to send is larger than 1460 bytes, you need to chunk. + if len(data) > 1460: # If the data you wish to send is larger than 1460 bytes, you need to chunk. index = 0 while index < len(data): # Create chunk of 1460 chars chunk = data[index : index + 1460] - + # Send chunk to the diode's TCP server client.send(chunk.encode()) @@ -81,4 +84,4 @@ except TimeoutError: print("No response was received from the diode. Please check your settings and try again.") finally: - client.close() \ No newline at end of file + client.close() diff --git a/sample/FendTcpServerExample.py b/sample/FendTcpServerExample.py index 5e53a44..0626a55 100644 --- a/sample/FendTcpServerExample.py +++ b/sample/FendTcpServerExample.py @@ -1,4 +1,7 @@ -""" +# Fend TCP and UDP Client/Server Example Python Test Scripts +# Copyright (c) 2023 Fend Incorporated. All rights reserved. + +""" This is an example Python script provided to aid in the integration of a Fend Data Diode in a TCP Client/Server application. For this example a simple socket is opened and listens for the diode's TCP client to connect. When data is received it is printed to @@ -7,7 +10,7 @@ For these scripts to function, the diode will need to be setup in TCP client/server mode. Please see the user manual on instruction for this setup process. -These scripts will continuously run until aborted. +These scripts will continuously run until aborted. The following is the expected step by step process of what the script does: 1. The script creates a socket object named "server". @@ -18,35 +21,35 @@ """ import socket - + # Change this to the Target TCP Server IP Address in your diode's Output Side TCP Client Settings. targetTcpServerIP = "192.168.1.20" # Change this to the Target TCP Server Port in your diode's Output Side TCP Client Settings. -targetTcpServerPort = 503 +targetTcpServerPort = 503 # Set up a TCP server server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server.bind((targetTcpServerIP, targetTcpServerPort)) - + # Begin listening server.listen(1) - + while True: print("Waiting for connection") connection, client = server.accept() - + try: # Print to console the connected client IP address print("Connected to client IP: {}".format(client)) - + # Receive and print data 10 Kbytes at a time, as long as the client is sending something while True: data = connection.recv(10240) print(f"Received data: {data.decode()}") - + if not data: break - + finally: - connection.close() \ No newline at end of file + connection.close() diff --git a/sample/FendUdpClientExample.py b/sample/FendUdpClientExample.py index 33f3683..d0fe461 100644 --- a/sample/FendUdpClientExample.py +++ b/sample/FendUdpClientExample.py @@ -1,4 +1,7 @@ -""" +# Fend TCP and UDP Client/Server Example Python Test Scripts +# Copyright (c) 2023 Fend Incorporated. All rights reserved. + +""" This is an example Python script provided to aid in the integration of a Fend Data Diode in a UDP Client/Server application. For this example a simple socket is extabilshed with the diode's UDP server and a test message is continuously sent to the input side @@ -11,12 +14,12 @@ For these scripts to function, the diode will need to be setup in UDP Client/Server mode. In addition, the "Reply with an ACK" option must be selected. Please see the user manualon instruction for this setup process. -These scripts will continuously run until aborted. +These scripts will continuously run until aborted. The following is the expected step by step process of what the script does: 1. The script creates a socket object named "client". 2. The script enters the sending loop. -3. This loop will check to see if the data is larger than 1460 bytes. If so, it will get a chunk and send that. +3. This loop will check to see if the data is larger than 1460 bytes. If so, it will get a chunk and send that. 4. The script will then wait for the diode to send its ACK before proceeding. 5. The loop will continue until all the data has been chunked and transmitted. 6. The script waits 1 second. @@ -29,10 +32,10 @@ from timeit import default_timer # Change this to the IP address of your diode's Input Side IP Address. -diodeInputSideIP = "192.168.1.99" +diodeInputSideIP = "192.168.1.99" # Change this to the Diode UDP Server Port in your diode's Input Side UDP Passthrough Settings. -diodeUDPPassthroughPort = 50000 +diodeUDPPassthroughPort = 50000 # create a socket client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -47,12 +50,12 @@ try: while True: # Send data to diode - if len(data) > 1460: # If the data you wish to send is larger than 1460 bytes, you need to chunk. + if len(data) > 1460: # If the data you wish to send is larger than 1460 bytes, you need to chunk. index = 0 while index < len(data): # Create chunk of 1460 chars chunk = data[index : index + 1460] - + # Send chunk to the diode's UDP server client.send(chunk.encode()) @@ -80,4 +83,4 @@ except TimeoutError: print("No response was received from the diode. Please check your settings and try again.") finally: - client.close() \ No newline at end of file + client.close() diff --git a/sample/FendUdpServerExample.py b/sample/FendUdpServerExample.py index 0e83578..4857521 100644 --- a/sample/FendUdpServerExample.py +++ b/sample/FendUdpServerExample.py @@ -1,4 +1,7 @@ -""" +# Fend TCP and UDP Client/Server Example Python Test Scripts +# Copyright (c) 2023 Fend Incorporated. All rights reserved. + +""" This is an example Python script provided to aid in the integration of a Fend Data Diode in a UDP Client/Server application. For this example a simple socket is opened and listens for the diode's UDP client to connect. When data is received it is printed to @@ -7,7 +10,7 @@ For these scripts to function, the diode will need to be setup in UDP client/server mode. Please see the user manual on instruction for this setup process. -These scripts will continuously run until aborted. +These scripts will continuously run until aborted. The following is the expected step by step process of what the script does: 1. The script creates a socket object named "server". @@ -17,17 +20,17 @@ """ import socket - + # Change this to the Target UDP Server IP Address in your diode's Output Side UDP Client Settings. targetUDPServerIP = "192.168.1.20" # Change this to the Target UDP Server Port in your diode's Output Side UDP Client Settings. -targetUDPServerPort = 503 +targetUDPServerPort = 503 # Set up a UDP server server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) server.bind((targetUDPServerIP, targetUDPServerPort)) - + # Receive and print data 10 Kbytes at a time, as long as the client is sending something try: while True: @@ -37,4 +40,4 @@ if not data: break finally: - server.close() \ No newline at end of file + server.close()