[GH-ISSUE #1149] Ability to import a list of sites from "one domain per line" plain text file #405

Open
opened 2026-10-13 20:20:53 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @Korb on GitHub (Oct 11, 2024).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/1149

Currently, when using site-based split tunneling [1], adding a list of sites is done by writing a json file [2]. Given that in most cases the user has a list of domains separated by a line break, there is no reason why the user should not be allowed to import exactly such a text file into Amnezia VPN Client instead of having to understand the json syntax as applied to Amnezia VPN Client or adding dozens of domains of local organizations and authorities one by one without using import.

[1] Allows you to select which sites you want to access through the VPN
[2] Only the sites listed here will be accessed through the VPN / Addresses from the list should not be accessed via VPN

Originally created by @Korb on GitHub (Oct 11, 2024). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/1149 Currently, when using site-based split tunneling [1], adding a list of sites is done by writing a `json` file [2]. Given that in most cases the user has a list of domains separated by a line break, there is no reason why the user should not be allowed to import exactly such a text file into Amnezia VPN Client instead of having to understand the json syntax as applied to Amnezia VPN Client or adding dozens of domains of local organizations and authorities one by one without using import. _[1] Allows you to select which sites you want to access through the VPN [2] Only the sites listed here will be accessed through the VPN / Addresses from the list should not be accessed via VPN_
Author
Owner

@bergentroll commented on GitHub (Mar 16, 2026):

Amnezia JSON is rather simple and can be made in a something like that way.

list2amnezia.py
#! /usr/bin/env python3

"""
Convert plain text domains list to Amnezia JSON

Usage:
    python3 list2amnezia.py my_list.txt

Input file CAN contains:
    - 1 hostname per line
    - 1 IP or subnet per line
    - Comments started with # (to be ignored)
    - Empty lines (to be ignored)

Requires python>=3.6
"""

import json
import sys
from pathlib import Path

INDENT=4

def main(input_file: str) -> None:
    inp_p = Path(input_file).absolute()
    with inp_p.open('r') as f:
        result = []
        for line in f.readlines():
            val = line.strip()
            if not val:
                continue
            if val.startswith('#'):
                comm = val.lstrip("#").lstrip()
                print(f'Comment: `{comm}`')
                continue
            # Current AmntziaVPN==4.8.14.5 expors IPs as hostnames
            result.append({'hostname': val, 'ip': ''})


    out_p = inp_p.with_suffix('.json')
    with Path(out_p).open('w') as f:
        json.dump(result, fp=f, indent=INDENT)

    print(f'{inp_p.name} -> {out_p.name}: OK')


if __name__ == '__main__':
    if len(sys.argv) != 2:
        dosa = '\nExpected exactly 1 input file as an argument\n'
        print(dosa, file=sys.stderr)
        sys.exit(1)
    main(sys.argv[1])

(Until it is no an official solution.)

<!-- gh-comment-id:4065774624 --> @bergentroll commented on GitHub (Mar 16, 2026): Amnezia JSON is rather simple and can be made in a something like that way. <details> <summary>list2amnezia.py</summary> ```python #! /usr/bin/env python3 """ Convert plain text domains list to Amnezia JSON Usage: python3 list2amnezia.py my_list.txt Input file CAN contains: - 1 hostname per line - 1 IP or subnet per line - Comments started with # (to be ignored) - Empty lines (to be ignored) Requires python>=3.6 """ import json import sys from pathlib import Path INDENT=4 def main(input_file: str) -> None: inp_p = Path(input_file).absolute() with inp_p.open('r') as f: result = [] for line in f.readlines(): val = line.strip() if not val: continue if val.startswith('#'): comm = val.lstrip("#").lstrip() print(f'Comment: `{comm}`') continue # Current AmntziaVPN==4.8.14.5 expors IPs as hostnames result.append({'hostname': val, 'ip': ''}) out_p = inp_p.with_suffix('.json') with Path(out_p).open('w') as f: json.dump(result, fp=f, indent=INDENT) print(f'{inp_p.name} -> {out_p.name}: OK') if __name__ == '__main__': if len(sys.argv) != 2: dosa = '\nExpected exactly 1 input file as an argument\n' print(dosa, file=sys.stderr) sys.exit(1) main(sys.argv[1]) ``` </details> (Until it is no an official solution.)
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amnezia-client#405
No description provided.