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

Add list parsing feature for gravity #1559

Merged
merged 10 commits into from
May 20, 2023
Merged

Add list parsing feature for gravity #1559

merged 10 commits into from
May 20, 2023

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented May 14, 2023

What does this implement/fix?

This PR implements a list parsing feature into FTL that is intended to be used with gravity. Its main advantage is a stream-lined approach directly writing everything directly into the new database during analysis. There is no detour over huge allocated memory blocks or temporary files.

Related issue or feature (if applicable): N/A

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories developmental branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

@DL6ER DL6ER marked this pull request as ready for review May 14, 2023 07:55
@DL6ER DL6ER requested a review from a team May 14, 2023 07:55
rdwebdesign
rdwebdesign previously approved these changes May 19, 2023
Copy link
Member

@rdwebdesign rdwebdesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested inside a container and it is working as expected.

@github-actions
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions
Copy link

Conflicts have been resolved.

@DL6ER DL6ER requested a review from rdwebdesign May 20, 2023 12:42
@DL6ER DL6ER added the PR: Approval Required Open Pull Request, needs approval label May 20, 2023
@DL6ER DL6ER requested a review from a team May 20, 2023 12:43
@DL6ER DL6ER merged commit 69ecc2c into development May 20, 2023
@DL6ER DL6ER deleted the new/parseList branch May 20, 2023 16:48
while(isspace(line[0]))
line++;

// Skip comments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is some duplicate code L166-186. This is still part of gravity.sh
gravity_ParseFileIntoDomains()

https://github.com/pi-hole/pi-hole/blob/73733308ba0f1c4e2cc5fb0c4aac6a9027349e48/gravity.sh#L639-L664

Does not hurt to keep it, just wanted to report.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is duplicated, we should remove it from FTL for minimal speed gain.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, rethinking this, we can also remove gravity_ParseFileIntoDomains() from gravity.sh and use the code here that should be a lot faster.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this would be something for pi-hole/pi-hole#5275

@rdwebdesign
Copy link
Member

rdwebdesign commented May 22, 2023

@DL6ER

I think I approved too soon.

I noticed the output here is saying ignored 13 non-domain entries, but only one entry is shown.

  [i] Target: https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
  [✓] Status: Retrieval successful
  [✓] Parsed 183821 exact domains and 0 ABP-style domains (ignored 13 non-domain entries)
      Sample of non-domain entries:
        - "0.0.0.0"

Comparing to master, should be only 1 entry.
I think the other 12 lines are in the "false positive" list, but they are still counted.

EDIT:

The original function excludes false positives from non-domains count.

@DL6ER
Copy link
Member Author

DL6ER commented May 23, 2023

@rdwebdesign This is expected and correct behavior. Each non-domain is counted but then only unique ones are shown. So, if there are 13 entries with 0.0.0.0 this is exactly what you are seeing here:

  [✓] Parsed 183821 exact domains and 0 ABP-style domains (ignored 13 non-domain entries)
      Sample of non-domain entries:
        - "0.0.0.0"

I'm always open to improving wording in case this isn't clear right now.

@yubiuser
Copy link
Member

Maybe simply changing the message to

"Sample of non-domain entries (duplicates removed)"

@DL6ER DL6ER mentioned this pull request May 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Approval Required Open Pull Request, needs approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants