-
-
Notifications
You must be signed in to change notification settings - Fork 11
Fix app generation for the Samourai app #44
Conversation
This also only loads the schema file for validation once instead for every app, which should improve the performance of the app validation
for tcpPort in container.requiredPorts: | ||
container.ports.append("{}:{}".format(tcpPort, tcpPort)) | ||
del container.requiredPorts | ||
for container in newApp.containers: | ||
for udpPort in container.requiredUdpPorts: | ||
container.ports.append("{}/udp".format(udpPort)) | ||
container.ports.append("{}/udp:{}/udp".format(udpPort, udpPort)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To document these changes somewhat, I thought if the port on the inside and outside was the same, directly having the port in the ports section without a target port would be enough, but it seems like docker needs this explicit definition.
) | ||
otherHiddenServices += "HiddenServicePort {} {}:{}".format( | ||
value, containerIp, value | ||
) | ||
otherHiddenServices += "\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was moved (from line 80) to make the generated torrc files prettier and does not really fix a bug.
if isinstance(value, int): | ||
otherHiddenServices += "# {} {} {} Hidden Service\nHiddenServiceDir /var/lib/tor/app-{}-{}\n".format( | ||
metadata.name, container.name, key, metadata.id, container.name | ||
metadata.name, container.name, key, metadata.id, key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the names for the generated hidden service directories.
@@ -47,15 +47,15 @@ def getContainerHiddenService( | |||
if isinstance(container.hiddenServicePorts, int): | |||
return getHiddenServiceString( | |||
"{} {}".format(metadata.name, container.name), | |||
metadata.id, | |||
metadata.id if isMainContainer else "{}-{}".format(metadata.id, container.name), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds the container name if the container is not the main container to ensure there are no conflicts between containers
scriptDir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..") | ||
|
||
with open(os.path.join(scriptDir, 'app-standard-v1.yml'), 'r') as f: | ||
schemaVersion1 = yaml.safe_load(f) | ||
with open(os.path.join(scriptDir, 'app-standard-v2.yml'), 'r') as f: | ||
schemaVersion2 = yaml.safe_load(f) | ||
with open(os.path.join(scriptDir, 'app-standard-v3.yml'), 'r') as f: | ||
schemaVersion3 = yaml.safe_load(f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures schema files are only loaded once
Thanks for the annotations, clears things up! How do I best apply this and test? I checked out this branch, ran
|
Can you try uninstalling the app, checking out this branch, running the start script, then installing again? It seems like the app didn't get copied into app-data properly, so please also make sure to I could not reproduce this in my testing env, so I'm not fully sure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and working in my dev environment. Nice work! :)
This also only loads the schema file for validation once instead for every app, which should improve the performance of the app validation