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

[FR]: Ability to parse & read hosts file #402

Open
1 task done
lihenggui opened this issue Oct 11, 2023 · 0 comments
Open
1 task done

[FR]: Ability to parse & read hosts file #402

lihenggui opened this issue Oct 11, 2023 · 0 comments
Assignees

Comments

@lihenggui
Copy link
Owner

lihenggui commented Oct 11, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the problem

Blocker可以通过修改hosts文件来提供封禁特定的域名或者IP地址的功能。对于修改hosts这个功能来说,我们需要把对hosts修改这个操作放到core组中,作为一个独立的模块来进行封装。


In order for Blocker to offer support for blocking specific domains or IP addresses, it must possess the capability to manage the system hosts file. As for now, the application doesn't support it.
We should create a new module to provide the basic foundation for the hosts file modification.

Describe the solution

  1. core功能组下新建一个新模块,名叫hosts。这个模块包含了修改hosts文件的核心功能。
  2. 把hosts文件抽象成为一个Java/Kotlin对象进行表达
  3. 在这个模块内提供使用root权限来操控hosts文件添加想要阻止的域名或者ip。
    可以有的额外功能:把修改hosts文件的方法抽象成为一个接口,这样可以不修改上层的逻辑就使用不同的方式来修改hosts文件(比如使用Shizuku提供的权限,或者是Knox的管理权限来进行修改hosts文件)

  1. Create a new module called hosts under the core group, this module provides all core features to control the hosts file.
  2. Create an abstract representation of the hosts file within the Android system.
  3. Provide the ability to add and remove IPs and domains in the host by using the root permission gained by the application.

Nice to have: In addition to root mode utilization, consider incorporating an abstraction layer for alternative methods of managing the hosts file, such as Shizuku or Knox.

Additional context

对于每一个被操控的域名或者IP来说,他们有三种状态,这三种状态在hosts文件里的表达分别为(以localhost为例):
激活状态: 127.0.0.1 localhost
未激活但是在列表里等待操作的状态: #127.0.0.1 localhost
从列表删除里的状态: 列表里没有这一行


For each manipulated domain or IP, they have three states, which are represented in the hosts file as follows (using localhost as an example):

  1. Active state: 127.0.0.1 localhost
  2. Inactive but pending action in the list: #127.0.0.1 localhost
  3. Deleted from the list state: This line is not in the list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants