Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

Fix app generation for the Samourai app #44

Merged
merged 1 commit into from
Jun 4, 2022

Conversation

AaronDewes
Copy link
Member

This also only loads the schema file for validation once instead for every app, which should improve the performance of the app validation

This also only loads the schema file for validation once instead for every app, which should improve the performance of the app validation
@AaronDewes AaronDewes added this to the Citadel 0.0.5 milestone Jun 3, 2022
Comment on lines +88 to +93
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))
Copy link
Member Author

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"
Copy link
Member Author

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
Copy link
Member Author

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),
Copy link
Member Author

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

Comment on lines +10 to +17
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)
Copy link
Member Author

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

@pwltr
Copy link
Contributor

pwltr commented Jun 3, 2022

Thanks for the annotations, clears things up! How do I best apply this and test? I checked out this branch, ran sudo ./scripts/app generate (+ download, update) and installed Samourai. Got the following error:

citadel@citadel-dev:~/citadel$ docker logs -f samourai-server-main-1
2022/06/03 18:58:18 [crit] 65#65: pread() "/etc/nginx/sites-enabled/dojo.conf" failed (21: Is a directory)
nginx: [crit] pread() "/etc/nginx/sites-enabled/dojo.conf" failed (21: Is a directory)

@AaronDewes
Copy link
Member Author

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 rm -rf app-data/samourai-server after the uninstall.

I could not reproduce this in my testing env, so I'm not fully sure

Copy link

@WilliamConnatser WilliamConnatser left a 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! :)

@WilliamConnatser WilliamConnatser merged commit 66c0ca3 into stable Jun 4, 2022
@AaronDewes AaronDewes deleted the fix/app-generation-samourai branch June 4, 2022 18:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants