Skip to content

Commit 5df4609

Browse files
authored
Repository license for project report (#45)
* Create LICENSE * docs: Python comment for non-MIT licensed code
1 parent f036b1d commit 5df4609

File tree

6 files changed

+67
-34
lines changed

6 files changed

+67
-34
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Solomon Himelbloom
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BIN_NAME=diode
2-
BIN_VERSION=0.1.2
2+
BIN_VERSION=0.1.3
33
BIN_DATE=$(shell date +%FT%T%z)
44

55
all: build

sample/FendTcpClientExample.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
"""
1+
# Fend TCP and UDP Client/Server Example Python Test Scripts
2+
# Copyright (c) 2023 Fend Incorporated. All rights reserved.
3+
4+
"""
25
This is an example Python script provided to aid in the integration of a Fend Data Diode in a TCP Client/Server application.
36
47
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 @@
1114
For these scripts to function, the diode will need to be setup in TCP Client/Server mode. Please see the user manual
1215
on instruction for this setup process.
1316
14-
These scripts will continuously run until aborted.
17+
These scripts will continuously run until aborted.
1518
1619
The following is the expected step by step process of what the script does:
1720
1. The script creates a socket object named "client".
1821
2. A connection attempt to the diode is made.
1922
3. If the connection is made, the script enters a sending loop.
20-
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.
23+
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.
2124
5. The script will then wait for the diode to send its ACK before proceeding.
2225
6. The loop will continue until all the data has been chunked and transmitted.
2326
7. The script waits 1 second.
@@ -30,10 +33,10 @@
3033
from timeit import default_timer
3134

3235
# Change this to the IP address of your diode's Input Side IP Address.
33-
diodeInputSideIP = "192.168.1.99"
36+
diodeInputSideIP = "192.168.1.99"
3437

3538
# Change this to the Diode TCP Server Port in your diode's Input Side TCP Passthrough Settings.
36-
diodeTcpPassthroughPort = 50000
39+
diodeTcpPassthroughPort = 50000
3740

3841
# create a socket
3942
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -48,12 +51,12 @@
4851
try:
4952
while True:
5053
# Send data to diode
51-
if len(data) > 1460: # If the data you wish to send is larger than 1460 bytes, you need to chunk.
54+
if len(data) > 1460: # If the data you wish to send is larger than 1460 bytes, you need to chunk.
5255
index = 0
5356
while index < len(data):
5457
# Create chunk of 1460 chars
5558
chunk = data[index : index + 1460]
56-
59+
5760
# Send chunk to the diode's TCP server
5861
client.send(chunk.encode())
5962

@@ -81,4 +84,4 @@
8184
except TimeoutError:
8285
print("No response was received from the diode. Please check your settings and try again.")
8386
finally:
84-
client.close()
87+
client.close()

sample/FendTcpServerExample.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
"""
1+
# Fend TCP and UDP Client/Server Example Python Test Scripts
2+
# Copyright (c) 2023 Fend Incorporated. All rights reserved.
3+
4+
"""
25
This is an example Python script provided to aid in the integration of a Fend Data Diode in a TCP Client/Server application.
36
47
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 @@
710
For these scripts to function, the diode will need to be setup in TCP client/server mode. Please see the user manual
811
on instruction for this setup process.
912
10-
These scripts will continuously run until aborted.
13+
These scripts will continuously run until aborted.
1114
1215
The following is the expected step by step process of what the script does:
1316
1. The script creates a socket object named "server".
@@ -18,35 +21,35 @@
1821
"""
1922

2023
import socket
21-
24+
2225
# Change this to the Target TCP Server IP Address in your diode's Output Side TCP Client Settings.
2326
targetTcpServerIP = "192.168.1.20"
2427

2528
# Change this to the Target TCP Server Port in your diode's Output Side TCP Client Settings.
26-
targetTcpServerPort = 503
29+
targetTcpServerPort = 503
2730

2831
# Set up a TCP server
2932
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
3033
server.bind((targetTcpServerIP, targetTcpServerPort))
31-
34+
3235
# Begin listening
3336
server.listen(1)
34-
37+
3538
while True:
3639
print("Waiting for connection")
3740
connection, client = server.accept()
38-
41+
3942
try:
4043
# Print to console the connected client IP address
4144
print("Connected to client IP: {}".format(client))
42-
45+
4346
# Receive and print data 10 Kbytes at a time, as long as the client is sending something
4447
while True:
4548
data = connection.recv(10240)
4649
print(f"Received data: {data.decode()}")
47-
50+
4851
if not data:
4952
break
50-
53+
5154
finally:
52-
connection.close()
55+
connection.close()

sample/FendUdpClientExample.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
"""
1+
# Fend TCP and UDP Client/Server Example Python Test Scripts
2+
# Copyright (c) 2023 Fend Incorporated. All rights reserved.
3+
4+
"""
25
This is an example Python script provided to aid in the integration of a Fend Data Diode in a UDP Client/Server application.
36
47
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 @@
1114
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
1215
must be selected. Please see the user manualon instruction for this setup process.
1316
14-
These scripts will continuously run until aborted.
17+
These scripts will continuously run until aborted.
1518
1619
The following is the expected step by step process of what the script does:
1720
1. The script creates a socket object named "client".
1821
2. The script enters the sending loop.
19-
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.
22+
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.
2023
4. The script will then wait for the diode to send its ACK before proceeding.
2124
5. The loop will continue until all the data has been chunked and transmitted.
2225
6. The script waits 1 second.
@@ -29,10 +32,10 @@
2932
from timeit import default_timer
3033

3134
# Change this to the IP address of your diode's Input Side IP Address.
32-
diodeInputSideIP = "192.168.1.99"
35+
diodeInputSideIP = "192.168.1.99"
3336

3437
# Change this to the Diode UDP Server Port in your diode's Input Side UDP Passthrough Settings.
35-
diodeUDPPassthroughPort = 50000
38+
diodeUDPPassthroughPort = 50000
3639

3740
# create a socket
3841
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@@ -47,12 +50,12 @@
4750
try:
4851
while True:
4952
# Send data to diode
50-
if len(data) > 1460: # If the data you wish to send is larger than 1460 bytes, you need to chunk.
53+
if len(data) > 1460: # If the data you wish to send is larger than 1460 bytes, you need to chunk.
5154
index = 0
5255
while index < len(data):
5356
# Create chunk of 1460 chars
5457
chunk = data[index : index + 1460]
55-
58+
5659
# Send chunk to the diode's UDP server
5760
client.send(chunk.encode())
5861

@@ -80,4 +83,4 @@
8083
except TimeoutError:
8184
print("No response was received from the diode. Please check your settings and try again.")
8285
finally:
83-
client.close()
86+
client.close()

sample/FendUdpServerExample.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
"""
1+
# Fend TCP and UDP Client/Server Example Python Test Scripts
2+
# Copyright (c) 2023 Fend Incorporated. All rights reserved.
3+
4+
"""
25
This is an example Python script provided to aid in the integration of a Fend Data Diode in a UDP Client/Server application.
36
47
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 @@
710
For these scripts to function, the diode will need to be setup in UDP client/server mode. Please see the user manual
811
on instruction for this setup process.
912
10-
These scripts will continuously run until aborted.
13+
These scripts will continuously run until aborted.
1114
1215
The following is the expected step by step process of what the script does:
1316
1. The script creates a socket object named "server".
@@ -17,17 +20,17 @@
1720
"""
1821

1922
import socket
20-
23+
2124
# Change this to the Target UDP Server IP Address in your diode's Output Side UDP Client Settings.
2225
targetUDPServerIP = "192.168.1.20"
2326

2427
# Change this to the Target UDP Server Port in your diode's Output Side UDP Client Settings.
25-
targetUDPServerPort = 503
28+
targetUDPServerPort = 503
2629

2730
# Set up a UDP server
2831
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
2932
server.bind((targetUDPServerIP, targetUDPServerPort))
30-
33+
3134
# Receive and print data 10 Kbytes at a time, as long as the client is sending something
3235
try:
3336
while True:
@@ -37,4 +40,4 @@
3740
if not data:
3841
break
3942
finally:
40-
server.close()
43+
server.close()

0 commit comments

Comments
 (0)