0
0
mirror of https://github.com/TrianguloY/UrlChecker.git synced 2024-09-19 11:52:14 +02:00

fix and extend hosts syntax

for #370
This commit is contained in:
TrianguloY 2024-08-22 17:53:51 +02:00
parent d79720feba
commit d04cd4e06e
3 changed files with 11 additions and 8 deletions

View File

@ -90,10 +90,13 @@ public class Hosts {
Log.d("HOSTS", "Downloading " + file);
HttpUtils.streamFromUrl(file, line -> {
var parts = line.replaceAll("#.*", "").trim().split(" +");
if (parts.length != 2) return;
// valid, add
add(parts[1], Pair.create(label, color), replace);
var parts = line.replaceAll("#.*", "").trim().split("\\s+");
// everything except the first entry is a possible host
for (int i = 1; i < parts.length; i++) {
add(parts[i], Pair.create(label, color), replace);
}
// just the host, special syntax
if (parts.length == 1) add(parts[0], Pair.create(label, color), replace);
});
}
if (entry.has("hosts")) {

View File

@ -272,7 +272,7 @@ Hay algunos enlaces cuyo único propósito es redirigirte a otro enlace. Si el e
<string name="mLog_empty">Sin datos</string>
<!-- -->
<string name="mHosts_name">Etiquetador de hosts</string>
<string name="mHosts_desc">Este módulo etiqueta hosts, configurado al especificarlos directamente o al usar un fichero remoto tipo hosts. Puedes usarlo para avisar sobre sitios peligrosos o especiales. La configuración incluida corresponde a los hosts de StevenBlack (software dañino, noticias falsas, juego/apuestas y contenido de adulto) de https://github.com/StevenBlack/hosts</string>
<string name="mHosts_desc">"Este módulo etiqueta hosts, configurado al especificarlos directamente o al usar un fichero remoto tipo hosts. Puedes usarlo para avisar sobre sitios peligrosos o especiales. La configuración incluida corresponde a los hosts de StevenBlack (software dañino, noticias falsas, juego/apuestas y contenido de adulto) de https://github.com/StevenBlack/hosts. Nota: subdominios también se comprobarán, con lo que 'x.y.z' e 'y.z' serán detectados para la entrada 'y.z'"</string>
<string name="mHosts_malware">software dañino</string>
<string name="mHosts_info">Host:</string>
<string name="mHosts_noLabel">sin etiqueta</string>
@ -283,7 +283,7 @@ Hay algunos enlaces cuyo único propósito es redirigirte a otro enlace. Si el e
<string name="mHosts_uninitialized">Catálogo de hosts sin inicializar. Pulsa para generarlo</string>
<string name="mHosts_parseError">No se puede analizar la URL del host</string>
<string name="mHosts_editor">Configuración de hosts. Formato: Lista de objectos en los que la clave es la etiqueta de los hosts y el contenido incluye los siguientes campos opcionales:
\n- file: Enlace a un fichero remoto tipo hosts para descargar. Todos los hosts válidos que incluya serán añadidos.
\n- file: Enlace a un fichero remoto tipo hosts para descargar. Todos los hosts válidos que incluya serán añadidos. Las líneas deben seguir el formato host: \'ip host [alias…]\', aunque aquellas con solo \'host\' también son validas.
\n- hosts: Lista de hosts (strings) para añadir.
\n- color: El color de la etiqueta. Un string de color de Android (#AARRGGBB, #RRGGBB o un color válido). Rojo \'peligro\' por defecto.
\n- replace: si es \'false\' hosts existentes no serán reemplazados. Notar que los objetos se evalúan de arriba a abajo. \'true\' por defecto.

View File

@ -324,7 +324,7 @@ This module has been deprecated in favor of the 'Uri parts' module"</string>
<string name="mLog_unlimited">Unlimited</string>
<!-- -->
<string name="mHosts_name">Hosts labeler</string>
<string name="mHosts_desc">"This module labels hosts, configured either by specifying them manually or by using a remote hosts-like file. You can use it to warn about dangerous or special sites. The builtin configuration specifies StevenBlack's hosts (adware/malware, fakenews, gambling and adult content) from https://github.com/StevenBlack/hosts"</string>
<string name="mHosts_desc">"This module labels hosts, configured either by specifying them manually or by using a remote hosts-like file. You can use it to warn about dangerous or special sites. The builtin configuration specifies StevenBlack's hosts (adware/malware, fakenews, gambling and adult content) from https://github.com/StevenBlack/hosts. Note: subdomains will also be checked, so 'x.y.z' and 'y.z' will be detected for the entry 'y.z'"</string>
<string name="mHosts_malware">adware/malware</string>
<string name="mHosts_info">Host:</string>
<string name="mHosts_noLabel">no label</string>
@ -335,7 +335,7 @@ This module has been deprecated in favor of the 'Uri parts' module"</string>
<string name="mHosts_uninitialized">Hosts database uninitialized. Press to build</string>
<string name="mHosts_parseError">Can not parse URL host</string>
<string name="mHosts_editor">"Hosts configuration. Format: List of objects where the key is the hosts label and the content includes the following optional values:
- file: An url of a remote hosts-file to download. All valid hosts present will be added.
- file: An url of a remote hosts-file to download. All valid hosts present will be added. The lines should follow the hosts syntax: 'ip host [alias…]', but those with only 'host' are valid too.
- hosts: List of raw hosts (strings) to add.
- color: The label's color. An Android color string (#AARRGGBB, #RRGGBB or a valid color name). Defaults to a 'danger' red.
- replace: if false existing hosts won't be replaced. Note that objects are evaluated from top to bottom. True by default.