Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] read the tor file completely to get hs info to delete or print #51

Closed
nyxnor opened this issue Feb 11, 2022 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@nyxnor
Copy link
Owner

nyxnor commented Feb 11, 2022

I am no longer satisfied with grepping 7 lines starting from match:

"${su_cmd}" grep -A 7 -E "^HiddenServiceDir ${tor_data_dir_services}/${service}$|^HiddenServiceDir ${tor_data_dir_services}/${service}/$" "${file}" | while IFS= read -r line; do

I used 7 as an arbitrary number and I could choose any other arbitrary number. But the solution is to read the file until the configuration is not HiddenService anymore or it is HiddenServiceDir of another service.

The other problem is the sed deleting lines. Before, every line was unique with HiddenServiceDir and HiddenServicePort, but HiddenServiceVersion is the same for every onion service, this means that when deleting a service, it would be deleting every version line from every service.

@nyxnor nyxnor added the bug Something isn't working label Feb 11, 2022
@nyxnor nyxnor changed the title [BUG] read the tor file completelt to get hs info to delete or print [BUG] read the tor file completely to get hs info to delete or print Feb 11, 2022
@nyxnor
Copy link
Owner Author

nyxnor commented Feb 11, 2022

@nyxnor
Copy link
Owner Author

nyxnor commented Feb 11, 2022

fixed on 5be0329

the problem is that it cannot contain lines not starting with HiddenService between the blocks, for example, a commented line would make this fail, or an empty line also.

Works

HiddenServiceDir /var/lib/tor/services/ssh
HiddenServiceVersion 3				
HiddenServicePort 22 127.0.0.1:22

Fail:

HiddenServiceDir /var/lib/tor/services/ssh
HiddenServiceVersion 3				

HiddenServicePort 22 127.0.0.1:22

Fail:

HiddenServiceDir /var/lib/tor/services/ssh
HiddenServiceVersion 3				
HiddenServicePort 22 127.0.0.1:22
#HiddenServicePort 80 127.0.0.1:80

before, this would fail even harder, as stated on the first port.
A fix for this will be done when I can imagine a proper solution.

@nyxnor
Copy link
Owner Author

nyxnor commented Feb 11, 2022

A fix for this will be done when I can imagine a proper soluti

how, just how? It is not easy to know when to stop parsing.

@nyxnor
Copy link
Owner Author

nyxnor commented Aug 20, 2022

I'm thinking of:

  • reading dump config to get the service block, service_block print "${service}" "${tor_dump_config_hs}" already does that.
  • then compare against the block found on the torrc.
  • maybe try to loop till the last line of the service block printed by service_block()?

@nyxnor nyxnor reopened this Aug 20, 2022
@nyxnor nyxnor pinned this issue Aug 20, 2022
@nyxnor
Copy link
Owner Author

nyxnor commented Sep 14, 2022

problem is that the script creates and deletes correctly if there is no manual intervention on the hiddenservice block. There is no clean way to removing a block if user has made breaking changes to it.

@nyxnor nyxnor closed this as completed Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant