Fix generation of some hidden services

This commit is contained in:
Aaron Dewes 2022-02-13 20:27:06 +01:00
parent d5b4ff6bb2
commit 324077a453
2 changed files with 5 additions and 2 deletions

View File

@ -43,7 +43,7 @@ def createComposeConfigFromV2(app: dict, nodeRoot: str):
newApp = convertDataDirToVolumeGen2(newApp)
newApp = configureIps(newApp, networkingFile, envFile)
newApp = configureMainPort(newApp, nodeRoot)
configureHiddenServices(newApp, nodeRoot)
newApp = configureHiddenServices(newApp, nodeRoot)
finalConfig: AppStage4 = convertContainersToServices(newApp)
newApp = classToDict(finalConfig)
del newApp['metadata']

View File

@ -100,7 +100,7 @@ def configureIps(app: AppStage2, networkingFile: str, envFile: str):
return app
def configureHiddenServices(app: AppStage3, nodeRoot: str) -> None:
def configureHiddenServices(app: AppStage3, nodeRoot: str) -> AppStage3:
dotEnv = parse_dotenv(path.join(nodeRoot, ".env"))
hiddenServices = ""
@ -113,8 +113,11 @@ def configureHiddenServices(app: AppStage3, nodeRoot: str) -> None:
)
hiddenServices += getContainerHiddenService(
app.metadata, container, dotEnv[env_var], container.name == mainContainer.name)
if container.hiddenServicePorts:
del container.hiddenServicePorts
torDaemons = ["torrc-apps", "torrc-apps-2", "torrc-apps-3"]
torFileToAppend = torDaemons[random.randint(0, len(torDaemons) - 1)]
with open(path.join(nodeRoot, "tor", torFileToAppend), 'a') as f:
f.write(hiddenServices)
return app