Skip to content

Commit 553bd1d

Browse files
committed
Add Google DNS and request verification
1 parent 4396c48 commit 553bd1d

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

restful_tango/tangoREST.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,11 @@ def convertJobObj(self, dirName, jobObj):
169169
if "disable_network" in jobObj and isinstance(jobObj["disable_network"], bool):
170170
disableNetwork = jobObj["disable_network"]
171171

172-
allowedOutgoingIPs = jobObj["allowed_outgoing_ips"]
172+
allowedOutgoingIPs = None
173+
if "allowed_outgoing_ips" in jobObj and isinstance(
174+
jobObj["allowed_outgoing_ips"], list
175+
):
176+
allowedOutgoingIPs = jobObj["allowed_outgoing_ips"]
173177

174178
job = TangoJob(
175179
name=name,

tangoObjects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def __init__(
115115
self.accessKeyId = accessKeyId
116116
self.accessKey = accessKey
117117
self.disableNetwork = disableNetwork
118-
self.allowedOutgoingIPs = (allowedOutgoingIPs,)
118+
self.allowedOutgoingIPs = allowedOutgoingIPs
119119

120120
def makeAssigned(self):
121121
self.syncRemote()

vmms/localDocker.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ def runJob(
165165
args = args + ["-m", f"{vm.memory}m"]
166166
if disableNetwork:
167167
args = args + ["--network", "none"]
168+
if not disableNetwork and allowedOutgoingIPs:
169+
args = args + ["--dns", "8.8.8.8", "--cap-add=NET_ADMIN"]
168170
args = args + [vm.image]
169171
args = args + ["sh", "-c"]
170172

@@ -180,6 +182,7 @@ def runJob(
180182

181183
iptablesCmd = ""
182184
if not disableNetwork and allowedOutgoingIPs:
185+
iptablesCmd += f"iptables -A OUTPUT -d 8.8.8.8 -j ACCEPT; "
183186
for IP in allowedOutgoingIPs:
184187
iptablesCmd += f"iptables -A OUTPUT -d {IP} -j ACCEPT; "
185188
iptablesCmd += "iptables -A OUTPUT -j DROP;"

0 commit comments

Comments
 (0)