File tree Expand file tree Collapse file tree 1 file changed +0
-41
lines changed Expand file tree Collapse file tree 1 file changed +0
-41
lines changed Original file line number Diff line number Diff line change 1
1
import functools
2
- import ipaddress
3
2
import json
4
3
import logging
5
4
import os
@@ -110,46 +109,6 @@ def get_architecture():
110
109
return arch
111
110
112
111
113
- def generate_ipv4_addr (subnet ):
114
- """
115
- Generate a valid random IPv4 address within the given subnet.
116
-
117
- :param subnet: Subnet in CIDR notation (e.g., '100.0.0.0/8')
118
- :return: Random IP address within the subnet
119
- """
120
- reserved_ips = [
121
- "0.0.0.0/8" ,
122
- "10.0.0.0/8" ,
123
- "100.64.0.0/10" ,
124
- "127.0.0.0/8" ,
125
- "169.254.0.0/16" ,
126
- "172.16.0.0/12" ,
127
- "192.0.0.0/24" ,
128
- "192.0.2.0/24" ,
129
- "192.88.99.0/24" ,
130
- "192.168.0.0/16" ,
131
- "198.18.0.0/15" ,
132
- "198.51.100.0/24" ,
133
- "203.0.113.0/24" ,
134
- "224.0.0.0/4" ,
135
- ]
136
-
137
- def is_public (ip ):
138
- for reserved in reserved_ips :
139
- if ipaddress .ip_address (ip ) in ipaddress .ip_network (reserved , strict = False ):
140
- return False
141
- return True
142
-
143
- network = ipaddress .ip_network (subnet , strict = False )
144
-
145
- # Generate a random IP within the subnet range
146
- while True :
147
- ip_int = random .randint (int (network .network_address ), int (network .broadcast_address ))
148
- ip_str = str (ipaddress .ip_address (ip_int ))
149
- if is_public (ip_str ):
150
- return ip_str
151
-
152
-
153
112
def sanitize_tc_netem_command (command : str ) -> bool :
154
113
"""
155
114
Sanitize the tc-netem command to ensure it's valid and safe to execute, as we run it as root on a container.
You can’t perform that action at this time.
0 commit comments