diff --git a/.github/workflows/create-lists.yml b/.github/workflows/create-lists.yml index 100589f..ac182e1 100644 --- a/.github/workflows/create-lists.yml +++ b/.github/workflows/create-lists.yml @@ -30,7 +30,8 @@ jobs: -v ${{ github.workspace }}/Categories:/app/Categories \ -v ${{ github.workspace }}/Services:/app/Services \ -v ${{ github.workspace }}/SRS:/app/SRS \ - itdoginfo/compilesrs:0.1.4 + -v ${{ github.workspace }}/DAT:/app/DAT \ + itdoginfo/compilesrs:0.1.5 - name: Check Russia/inside-dnsmasq-ipset uses: itdoginfo/dnsmasq-action@0.1 @@ -78,5 +79,7 @@ jobs: - name: Release uses: softprops/action-gh-release@v2.1.0 with: - files: "${{ github.workspace }}/SRS/*.srs" + files: | + "${{ github.workspace }}/SRS/*.srs" + "${{ github.workspace }}/DAT/*.dat" tag_name: ${{ env.TAG_NAME }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 602f3be..e218d2b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ antifilter-domains.lst uablacklist-domains.lst zaboronahelp-domains.lst SRS -JSON \ No newline at end of file +JSON +DAT \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 0c35b51..7372553 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,18 @@ FROM ghcr.io/sagernet/sing-box:v1.10.7 AS sing-box +FROM golang:1.22.12-alpine3.21 AS go-builder + +WORKDIR /app + +RUN CGO_ENABLED=0 GOOS=linux go install -ldflags="-s -w" \ + github.com/v2fly/domain-list-community@20250207120917 + FROM python:3.10.16-alpine3.21 COPY --from=sing-box /usr/local/bin/sing-box /bin/sing-box +COPY --from=go-builder /go/bin/domain-list-community /bin/domain-list-community + RUN pip install --no-cache-dir tldextract WORKDIR /app diff --git a/convert.py b/convert.py index 950de92..e4a77e5 100755 --- a/convert.py +++ b/convert.py @@ -306,6 +306,40 @@ def generate_srs_subnets(input_file, output_json_directory='JSON', compiled_outp except subprocess.CalledProcessError as e: print(f"Compile error {output_file_path}: {e}") +def prepare_dat_domains(domains_or_dirs, output_name): + output_lists_directory = 'geosite_data' + + os.makedirs(output_lists_directory, exist_ok=True) + + extracted_domains = [] + + if all(os.path.isdir(d) for d in domains_or_dirs): + for directory in domains_or_dirs: + for filename in os.listdir(directory): + file_path = os.path.join(directory, filename) + + if os.path.isfile(file_path): + with open(file_path, 'r', encoding='utf-8') as file: + attribute = os.path.splitext(filename)[0] + extracted_domains.extend(f"{line.strip()} @{attribute}" for line in file if line.strip()) + else: + extracted_domains = domains_or_dirs + + output_file_path = os.path.join(output_lists_directory, output_name) + with open(output_file_path, 'w', encoding='utf-8') as file: + file.writelines(f"{name}\n" for name in extracted_domains) + +def generate_dat_domains(data_path='geosite_data', output_name='geosite.dat', output_directory='DAT'): + os.makedirs(output_directory, exist_ok=True) + + try: + subprocess.run( + ["domain-list-community", f"-datapath={data_path}", f"-outputname={output_name}", f"-outputdir={output_directory}"], + check=True + ) + except subprocess.CalledProcessError as e: + print(f"Compile error geosite.dat: {e}") + if __name__ == '__main__': # Russia inside Path("Russia").mkdir(parents=True, exist_ok=True) @@ -362,4 +396,10 @@ if __name__ == '__main__': # Sing-box subnets generate_srs_subnets(DiscordSubnets) generate_srs_subnets(TwitterSubnets) - generate_srs_subnets(MetaSubnets) \ No newline at end of file + generate_srs_subnets(MetaSubnets) + + # Xray domains + prepare_dat_domains(directories, 'russia-inside') + prepare_dat_domains(russia_outside, 'russia-outside') + prepare_dat_domains(ukraine_inside, 'ukraine-inside') + generate_dat_domains() \ No newline at end of file