Skip to content

Commit 9892b22

Browse files
committed
refactor: Remove unnecessary exception documentation
1 parent 022b198 commit 9892b22

File tree

3 files changed

+5
-29
lines changed

3 files changed

+5
-29
lines changed

Jiyu_udp_attack/ip_analyze.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ def ip_to_tuple(ip: str) -> tuple[int, int, int, int]:
1212
1313
Returns:
1414
tuple[int, int, int, int]: A tuple representing the four octets of the IP address.
15-
16-
Raises:
17-
TypeError: If the input is not a string.
18-
ValueError: If the input is not a valid IP address format.
1915
"""
2016
if not isinstance(ip, str):
2117
raise TypeError(f"Expected string, got {type(ip).__name__}")
@@ -38,10 +34,6 @@ def ip_analyze(ip: str) -> list[str]:
3834
3935
Returns:
4036
list[str]: A list of valid IP addresses.
41-
42-
Raises:
43-
TypeError: If the input is not a string.
44-
ValueError: If the input is not a valid IP address or range.
4537
"""
4638
if not isinstance(ip, str):
4739
raise TypeError(f"Expected string, got {type(ip).__name__}")

Jiyu_udp_attack/packet.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def format_data(data: str, max_length: Optional[int] = None) -> bytes:
1313
1414
Args:
1515
msg (str): The input string to format.
16-
max_length (int, optional): The maximum length of the resulting byte array. Defaults to 800.
16+
max_length (int, optional): The maximum length of the output byte array.
1717
1818
Returns:
1919
bytes: The formatted byte array, padded with null bytes if necessary.
@@ -26,7 +26,10 @@ def format_data(data: str, max_length: Optional[int] = None) -> bytes:
2626
raise TypeError(f"Expected int, got {type(max_length).__name__}")
2727
if max_length <= 0:
2828
raise ValueError(f"Invalid maximum length: {max_length}")
29-
return data.encode("utf-16le").ljust(max_length, b"\x00")[:max_length]
29+
padded_bytes = data.encode("utf-16le").ljust(max_length, b"\x00")
30+
if len(padded_bytes) > max_length:
31+
raise ValueError(f"Data exceeds maximum length: {len(padded_bytes)} > {max_length}")
32+
return padded_bytes
3033

3134

3235
def pkg_message(msg: str) -> bytes:
@@ -38,9 +41,6 @@ def pkg_message(msg: str) -> bytes:
3841
3942
Returns:
4043
bytes: The packaged message as a byte array, including a header and padding.
41-
42-
Raises:
43-
ValueError: If the message length exceeds 800 bytes or if the header length is incorrect
4444
"""
4545
data = format_data(msg, 800)
4646
head = (
@@ -67,15 +67,6 @@ def pkg_execute(
6767
6868
Returns:
6969
bytes: The packaged command as a byte array, including a header and formatted data.
70-
71-
Raises:
72-
ValueError: If the executable file or arguments exceed their respective length limits,
73-
or if an invalid mode is specified.
74-
TypeError: If the executable file or arguments are not strings.
75-
76-
Note:
77-
The function constructs a specific header and formats the executable file and arguments
78-
into byte arrays, ensuring they fit within defined length limits.
7970
"""
8071
head = (
8172
b"DMOC\x00\x00\x01\x00n\x03\x00\x00"
@@ -106,10 +97,6 @@ def pkg_website(url: str) -> bytes:
10697
10798
Returns:
10899
bytes: The packaged URL as a byte array, including a header and padding.
109-
110-
Raises:
111-
ValueError: If the URL length exceeds 800 bytes.
112-
TypeError: If the URL is not a string.
113100
"""
114101
data = format_data(url)
115102

Jiyu_udp_attack/sender.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ def send_packet(
139139
dst_port (int): The destination port number.
140140
payload (bytes): The data payload to include in the packet.
141141
142-
Raises:
143-
scapy.error.Scapy_Exception: If there is an error sending the packet.
144-
145142
Note:
146143
This function uses Scapy to construct and send the packet.
147144
Ensure that Scapy is installed and properly configured in your environment.

0 commit comments

Comments
 (0)