Skip to content

Commit

Permalink
Add Google DNS and request verification
Browse files Browse the repository at this point in the history
  • Loading branch information
evanyeyeye committed Apr 15, 2024
1 parent 4396c48 commit 553bd1d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion restful_tango/tangoREST.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ def convertJobObj(self, dirName, jobObj):
if "disable_network" in jobObj and isinstance(jobObj["disable_network"], bool):
disableNetwork = jobObj["disable_network"]

allowedOutgoingIPs = jobObj["allowed_outgoing_ips"]
allowedOutgoingIPs = None
if "allowed_outgoing_ips" in jobObj and isinstance(
jobObj["allowed_outgoing_ips"], list
):
allowedOutgoingIPs = jobObj["allowed_outgoing_ips"]

job = TangoJob(
name=name,
Expand Down
2 changes: 1 addition & 1 deletion tangoObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(
self.accessKeyId = accessKeyId
self.accessKey = accessKey
self.disableNetwork = disableNetwork
self.allowedOutgoingIPs = (allowedOutgoingIPs,)
self.allowedOutgoingIPs = allowedOutgoingIPs

def makeAssigned(self):
self.syncRemote()
Expand Down
3 changes: 3 additions & 0 deletions vmms/localDocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ def runJob(
args = args + ["-m", f"{vm.memory}m"]
if disableNetwork:
args = args + ["--network", "none"]
if not disableNetwork and allowedOutgoingIPs:
args = args + ["--dns", "8.8.8.8", "--cap-add=NET_ADMIN"]
args = args + [vm.image]
args = args + ["sh", "-c"]

Expand All @@ -180,6 +182,7 @@ def runJob(

iptablesCmd = ""
if not disableNetwork and allowedOutgoingIPs:
iptablesCmd += f"iptables -A OUTPUT -d 8.8.8.8 -j ACCEPT; "
for IP in allowedOutgoingIPs:
iptablesCmd += f"iptables -A OUTPUT -d {IP} -j ACCEPT; "
iptablesCmd += "iptables -A OUTPUT -j DROP;"
Expand Down

0 comments on commit 553bd1d

Please sign in to comment.