Merge branch 'main' into c-lightning

This commit is contained in:
Aaron Dewes 2022-02-19 17:10:52 +01:00
commit ed6bd73968
13 changed files with 58 additions and 22 deletions

View File

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

View File

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

View File

@ -64,6 +64,10 @@ def getContainerHiddenService(
hiddenServices = "# {} {} Hidden Service\nHiddenServiceDir /var/lib/tor/app-{}-{}\n".format( hiddenServices = "# {} {} Hidden Service\nHiddenServiceDir /var/lib/tor/app-{}-{}\n".format(
metadata.name, container.name, metadata.id, container.name metadata.name, container.name, metadata.id, container.name
) )
initialHiddenServices = "# {} {} Hidden Service\nHiddenServiceDir /var/lib/tor/app-{}-{}\n".format(
metadata.name, container.name, metadata.id, container.name
)
otherHiddenServices = ""
for key, value in container.hiddenServicePorts.items(): for key, value in container.hiddenServicePorts.items():
if isinstance(key, int): if isinstance(key, int):
hiddenServices += "HiddenServicePort {} {}:{}".format( hiddenServices += "HiddenServicePort {} {}:{}".format(
@ -73,19 +77,23 @@ def getContainerHiddenService(
else: else:
additionalHiddenServices[key] = value additionalHiddenServices[key] = value
for key, value in additionalHiddenServices.items(): for key, value in additionalHiddenServices.items():
hiddenServices += "\n" otherHiddenServices += "\n"
if isinstance(value, int): if isinstance(value, int):
hiddenServices += "# {} {} {} Hidden Service\nHiddenServiceDir /var/lib/tor/app-{}-{}\n".format( 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, container.name
) )
hiddenServices += "HiddenServicePort {} {}:{}".format( otherHiddenServices += "HiddenServicePort {} {}:{}".format(
key, containerIp, value key, containerIp, value
) )
elif isinstance(value, list): elif isinstance(value, list):
hiddenServices += getHiddenServiceMultiPort( otherHiddenServices += getHiddenServiceMultiPort(
key, metadata.id, containerIp, value "{} {}".format(metadata.name, key), "{}-{}".format(metadata.id, key), containerIp, value
) )
return hiddenServices
if hiddenServices == initialHiddenServices:
return otherHiddenServices
else :
return hiddenServices + "\n" + otherHiddenServices
del container.hiddenServicePorts del container.hiddenServicePorts
return "" return ""

View File

@ -194,7 +194,7 @@ def compose(app, arguments):
composeFile = os.path.join(appsDir, app, "docker-compose.yml") composeFile = os.path.join(appsDir, app, "docker-compose.yml")
commonComposeFile = os.path.join(appSystemDir, "docker-compose.common.yml") commonComposeFile = os.path.join(appSystemDir, "docker-compose.common.yml")
os.environ["APP_DOMAIN"] = subprocess.check_output( os.environ["APP_DOMAIN"] = subprocess.check_output(
"hostname -s 2>/dev/null || echo 'citadel'", shell=True).decode("utf-8") + ".local" "hostname -s 2>/dev/null || echo 'citadel'", shell=True).decode("utf-8").strip() + ".local"
os.environ["APP_HIDDEN_SERVICE"] = subprocess.check_output("cat {} 2>/dev/null || echo 'notyetset.onion'".format( os.environ["APP_HIDDEN_SERVICE"] = subprocess.check_output("cat {} 2>/dev/null || echo 'notyetset.onion'".format(
os.path.join(nodeRoot, "tor", "data", "app-{}/hostname".format(app))), shell=True).decode("utf-8").strip() os.path.join(nodeRoot, "tor", "data", "app-{}/hostname".format(app))), shell=True).decode("utf-8").strip()
os.environ["APP_SEED"] = deriveEntropy("app-{}-seed".format(app)) os.environ["APP_SEED"] = deriveEntropy("app-{}-seed".format(app))

View File

@ -59,7 +59,7 @@ services:
ports: ports:
- ${NGINX_PORT}:80 - ${NGINX_PORT}:80
- 433:433 - 433:433
- 443:443 - ${NGINX_SSL_PORT}:443
networks: networks:
default: default:
ipv4_address: $NGINX_IP ipv4_address: $NGINX_IP

View File

@ -2,5 +2,5 @@
"version": "0.5.21", "version": "0.5.21",
"name": "Citadel 0.5.21", "name": "Citadel 0.5.21",
"requires": ">=0.5.5", "requires": ">=0.5.5",
"notes": "This update includes a lot of internal improvements to the app system. This update also prepares for letting you to update individual apps instead of all at once." "notes": "Please note: This update is not suitable for notes running the c-lightning beta. This update includes a lot of internal improvements to the app system. This update also prepares for letting you to update individual apps instead of all at once."
} }

View File

@ -47,7 +47,7 @@ key = args.key
node_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) node_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
nginx_config_file = os.path.join(node_root, 'nginx', 'nginx.conf') nginx_config_file = os.path.join(node_root, 'nginx', 'nginx.conf')
registry_file = os.path.join(node_root, 'apps', 'apps.json') registry_file = os.path.join(node_root, 'apps', 'registry.json')
with open(registry_file) as file: with open(registry_file) as file:
registry = json.load(file) registry = json.load(file)
@ -98,7 +98,7 @@ if port == None:
print("Error: No port found for {}".format(service)) print("Error: No port found for {}".format(service))
exit(1) exit(1)
if service == "btcpay-server" or service == "lnbits": if service == "btcpay-server":
port = 1234 port = 1234
if service == "lnme": if service == "lnme":

View File

@ -140,6 +140,13 @@ cat <<EOF > ${BACKUP_STATUS_FILE}
EOF EOF
exit exit
fi fi
if [[ $BITCOIN_NETWORK == "signet" ]]; then
rm -rf "${BACKUP_ROOT}"
cat <<EOF > ${BACKUP_STATUS_FILE}
{"status": "skipped", "timestamp": $(date +%s000)}
EOF
exit
fi
if [[ $BITCOIN_NETWORK == "regtest" ]]; then if [[ $BITCOIN_NETWORK == "regtest" ]]; then
rm -rf "${BACKUP_ROOT}" rm -rf "${BACKUP_ROOT}"
cat <<EOF > ${BACKUP_STATUS_FILE} cat <<EOF > ${BACKUP_STATUS_FILE}

26
scripts/configure vendored
View File

@ -75,14 +75,14 @@ if os.path.isfile('../.citadel'):
status_dir = os.path.join(CITADEL_ROOT, '..', 'statuses') status_dir = os.path.join(CITADEL_ROOT, '..', 'statuses')
updating = True updating = True
# Configure for mainnet or testnet or regtest depending # Configure for appropriate network depending
# upon the user-supplied value of $NETWORK # upon the user-supplied value of $NETWORK
# If the network is not specified, then use the mainnet # If the network is not specified, then use the mainnet
BITCOIN_NETWORK=os.environ.get('NETWORK') or 'mainnet' BITCOIN_NETWORK=os.environ.get('NETWORK') or 'mainnet'
# Check if network neither mainnet nor testnet nor regtest # Check if network neither mainnet nor testnet nor regtest
if BITCOIN_NETWORK not in ['mainnet', 'testnet', 'regtest']: if BITCOIN_NETWORK not in ['mainnet', 'testnet', 'signet', 'regtest']:
print('Error: Network must be either mainnet, testnet, or regtest!') print('Error: Network must be either mainnet, testnet, signet or regtest!')
exit(1) exit(1)
with open(os.path.join(CITADEL_ROOT, "info.json"), 'r') as file: with open(os.path.join(CITADEL_ROOT, "info.json"), 'r') as file:
@ -145,6 +145,7 @@ if os.path.isfile('../use-core-upstream') or os.path.isfile('./use-core-upstream
########################################################## ##########################################################
NGINX_PORT=os.environ.get('NGINX_PORT') or "80" NGINX_PORT=os.environ.get('NGINX_PORT') or "80"
NGINX_SSL_PORT=os.environ.get('NGINX_SSL_PORT') or "443"
UPDATE_CHANNEL="main" UPDATE_CHANNEL="main"
if reconfiguring: if reconfiguring:
@ -155,8 +156,8 @@ if reconfiguring:
BITCOIN_NETWORK=os.environ.get('OVERWRITE_NETWORK') or dotenv['BITCOIN_NETWORK'] BITCOIN_NETWORK=os.environ.get('OVERWRITE_NETWORK') or dotenv['BITCOIN_NETWORK']
# Check if network neither mainnet nor testnet nor regtest # Check if network neither mainnet nor testnet nor regtest
if BITCOIN_NETWORK not in ['mainnet', 'testnet', 'regtest']: if BITCOIN_NETWORK not in ['mainnet', 'testnet', 'signet', 'regtest']:
print('Error: Network must be either mainnet, testnet, or regtest!') print('Error: Network must be either mainnet, testnet, signet or regtest!')
exit(1) exit(1)
print("Using {} network".format(BITCOIN_NETWORK)) print("Using {} network".format(BITCOIN_NETWORK))
print() print()
@ -168,6 +169,11 @@ if reconfiguring:
TOR_PASSWORD=dotenv['TOR_PASSWORD'] TOR_PASSWORD=dotenv['TOR_PASSWORD']
TOR_HASHED_PASSWORD=dotenv['TOR_HASHED_PASSWORD'] TOR_HASHED_PASSWORD=dotenv['TOR_HASHED_PASSWORD']
NGINX_PORT=dotenv['NGINX_PORT'] NGINX_PORT=dotenv['NGINX_PORT']
NGINX_SSL_PORT="443"
if 'NGINX_SSL_PORT' in dotenv:
NGINX_SSL_PORT=dotenv['NGINX_SSL_PORT']
if NGINX_SSL_PORT == "80" and NGINX_PORT == "80":
NGINX_SSL_PORT="443"
if 'UPDATE_CHANNEL' in dotenv: if 'UPDATE_CHANNEL' in dotenv:
UPDATE_CHANNEL=dotenv['UPDATE_CHANNEL'] UPDATE_CHANNEL=dotenv['UPDATE_CHANNEL']
else: else:
@ -252,6 +258,14 @@ elif BITCOIN_NETWORK == "testnet":
NEUTRINO_PEERS=''' NEUTRINO_PEERS='''
[neutrino] [neutrino]
neutrino.addpeer=testnet1-btcd.zaphq.io neutrino.addpeer=testnet1-btcd.zaphq.io
neutrino.addpeer=testnet2-btcd.zaphq.io
'''
elif BITCOIN_NETWORK == "signet":
BITCOIN_RPC_PORT=38332
BITCOIN_P2P_PORT=38333
NEUTRINO_PEERS='''
[neutrino]
neutrino.addpeer=testnet1-btcd.zaphq.io
neutrino.addpeer=testnet2-btcd.zaphq.io neutrino.addpeer=testnet2-btcd.zaphq.io
''' '''
elif BITCOIN_NETWORK == "regtest": elif BITCOIN_NETWORK == "regtest":
@ -264,6 +278,8 @@ else:
NETWORK_SECTION="" NETWORK_SECTION=""
if BITCOIN_NETWORK != "mainnet": if BITCOIN_NETWORK != "mainnet":
NETWORK_SECTION = "[{}]".format(BITCOIN_NETWORK) NETWORK_SECTION = "[{}]".format(BITCOIN_NETWORK)
if BITCOIN_NETWORK == "testnet":
NETWORK_SECTION = "[test]"
# IP addresses for services # IP addresses for services
NETWORK_IP="10.21.21.0" NETWORK_IP="10.21.21.0"

View File

@ -44,7 +44,7 @@ fi
# Configure Citadel if it isn't already configured # Configure Citadel if it isn't already configured
if [[ ! -f "${CITADEL_ROOT}/statuses/configured" ]]; then if [[ ! -f "${CITADEL_ROOT}/statuses/configured" ]]; then
NGINX_PORT=${NGINX_PORT:-80} NETWORK="${NETWORK:-mainnet}" "${CITADEL_ROOT}/scripts/configure" NGINX_PORT=${NGINX_PORT:-80} NGINX_SSL_PORT=${NGINX_SSL_PORT:-443} NETWORK="${NETWORK:-mainnet}" "${CITADEL_ROOT}/scripts/configure"
fi fi
echo echo

View File

@ -8,6 +8,7 @@ NETWORK_IP=<network-ip>
GATEWAY_IP=<gateway-ip> GATEWAY_IP=<gateway-ip>
NGINX_IP=<nginx-ip> NGINX_IP=<nginx-ip>
NGINX_PORT=<nginx-port> NGINX_PORT=<nginx-port>
NGINX_SSL_PORT=<nginx-ssl-port>
DASHBOARD_IP=<dashboard-ip> DASHBOARD_IP=<dashboard-ip>
MANAGER_IP=<manager-ip> MANAGER_IP=<manager-ip>
MIDDLEWARE_IP=<middleware-ip> MIDDLEWARE_IP=<middleware-ip>

View File

@ -9,7 +9,7 @@
proxy=<tor-proxy-ip>:<tor-proxy-port> proxy=<tor-proxy-ip>:<tor-proxy-port>
listen=1 listen=1
# Mainnet/Testnet/regtest # Mainnet/Testnet/Signet/regtest
<bitcoin-network>=1 <bitcoin-network>=1
# Connections # Connections
@ -21,7 +21,6 @@ rpcauth=<bitcoin-rpc-auth>
dbcache=200 dbcache=200
maxmempool=300 maxmempool=300
# zmq # zmq
zmqpubrawblock=tcp://0.0.0.0:<bitcoin-zmq-rawblock-port> zmqpubrawblock=tcp://0.0.0.0:<bitcoin-zmq-rawblock-port>
zmqpubrawtx=tcp://0.0.0.0:<bitcoin-zmq-rawtx-port> zmqpubrawtx=tcp://0.0.0.0:<bitcoin-zmq-rawtx-port>
@ -40,6 +39,8 @@ peerblockfilters=1
<external-ip> <external-ip>
# NOTE: The options addnode, connect, port, bind, rpcport, rpcbind and wallet
# only apply to mainnet unless they appear in the appropriate section below.
<network-section> <network-section>
bind=<bitcoin-ip> bind=<bitcoin-ip>
port=<bitcoin-p2p-port> port=<bitcoin-p2p-port>

View File

@ -29,7 +29,7 @@ accept-amp=true
protocol.wumbo-channels=true protocol.wumbo-channels=true
[Bitcoind] [Bitcoind]
bitcoind.rpchost=<bitcoin-ip> bitcoind.rpchost=<bitcoin-ip>:<bitcoin-rpc-port>
bitcoind.rpcuser=<bitcoin-rpc-user> bitcoind.rpcuser=<bitcoin-rpc-user>
bitcoind.rpcpass=<bitcoin-rpc-pass> bitcoind.rpcpass=<bitcoin-rpc-pass>
bitcoind.zmqpubrawblock=tcp://<bitcoin-ip>:<bitcoin-zmq-rawblock-port> bitcoind.zmqpubrawblock=tcp://<bitcoin-ip>:<bitcoin-zmq-rawblock-port>