mirror of
https://github.com/openwrt/packages.git
synced 2025-12-21 21:24:31 +04:00
tor-hs: put torrc_generated into in-memory folder /var/run/
On each tor-hs service restart it generates a config file /etc/tor/torrc_generated. The /etc/ is stored on a disk and kills it and slow. Instead create a dedicated tor service Runtime Dir in the temp /var/run/. It will be accessible only to the tor user. Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
This commit is contained in:
committed by
Josef Schlehofer
parent
2f505ed7d8
commit
94de72970e
@@ -1,5 +1,5 @@
|
|||||||
config tor-hs common
|
config tor-hs common
|
||||||
option GenConf "/etc/tor/torrc_generated"
|
option GenConf "/var/run/tor/torrc_generated"
|
||||||
option HSDir "/etc/tor/hidden_service"
|
option HSDir "/etc/tor/hidden_service"
|
||||||
option RestartTor 1
|
option RestartTor 1
|
||||||
option UpdateTorConf 1
|
option UpdateTorConf 1
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ STOP=52
|
|||||||
|
|
||||||
USE_PROCD=1
|
USE_PROCD=1
|
||||||
|
|
||||||
TORRC_FILE=/etc/tor/torrc_generated # file with torrc config
|
TORRC_FILE=/var/run/tor/torrc_generated # file with torrc config
|
||||||
HS_DIR_PATH=/etc/tor/hidden_service # onion services directory
|
HS_DIR_PATH=/etc/tor/hidden_service # onion services directory
|
||||||
TOR_USER=tor
|
TOR_USER=tor
|
||||||
|
|
||||||
@@ -92,15 +92,19 @@ parse_common_conf() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
|
# create runtime dir
|
||||||
|
mkdir -p -m 700 /var/run/tor
|
||||||
|
chown -R "$TOR_USER:$TOR_USER" /var/run/tor
|
||||||
config_load tor-hs
|
config_load tor-hs
|
||||||
validate_common_section || {
|
validate_common_section || {
|
||||||
echo "validation failed"
|
echo "validation failed"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
# clean config
|
|
||||||
echo -n "" > "$TORRC_FILE"
|
|
||||||
# load common config
|
# load common config
|
||||||
parse_common_conf
|
parse_common_conf
|
||||||
|
# clean config
|
||||||
|
echo -n "" > "$TORRC_FILE"
|
||||||
|
chown "$TOR_USER:$TOR_USER" "$TORRC_FILE"
|
||||||
# load hs service
|
# load hs service
|
||||||
config_foreach validate_hidden_service_section hidden-service parse_hs_conf
|
config_foreach validate_hidden_service_section hidden-service parse_hs_conf
|
||||||
# update tor config
|
# update tor config
|
||||||
@@ -111,7 +115,7 @@ start_service() {
|
|||||||
|
|
||||||
validate_common_section() {
|
validate_common_section() {
|
||||||
uci_validate_section tor-hs tor-hs common \
|
uci_validate_section tor-hs tor-hs common \
|
||||||
'GenConf:string:/etc/tor/torrc_generated' \
|
'GenConf:string:/var/run/tor/torrc_generated' \
|
||||||
'HSDir:string:/etc/tor/hidden_service' \
|
'HSDir:string:/etc/tor/hidden_service' \
|
||||||
'RestartTor:bool:1' \
|
'RestartTor:bool:1' \
|
||||||
'UpdateTorConf:bool:1'
|
'UpdateTorConf:bool:1'
|
||||||
|
|||||||
Reference in New Issue
Block a user