SpoofDPI icon indicating copy to clipboard operation
SpoofDPI copied to clipboard

Configuration file support

Open dtcyganok opened this issue 1 year ago • 4 comments

Description

It would be nice to have an ability to control the SpoofDPI behavior (all of the CLI options) via config file. Usually it's quite an expected feature and a lot of CLI apps have such a feature.

dtcyganok avatar Sep 09 '24 17:09 dtcyganok

  • it would also be nice to be able to run the application in daemon mode

gray1717 avatar Sep 11 '24 12:09 gray1717

We can create a config file of the following format:

proxy:
    addr: "127.0.0.1"
    port: 8080
    connection:
        timeout: 1
        https:
            window-size: 0
    system-proxy: false
    patterns:
        - "example.com"
dns:
    addr: "8.8.8.8"
    port: 53
    enable-doh: false
    ip-v4-only: false
output:
    silent: false
    debug: false

and specify the path to it via -config-file option.

Source Precedence
Defaults 0
File 1
Flags 2

@xvzc

Ledorub avatar Sep 12 '24 16:09 Ledorub

@Ledorub that's nice! I'd also suggest to read the config file by default instead of using option -config-file. It'd be way more conventional. And it would be nice to have the global/system and the local/user config files on linux systems.

dtcyganok avatar Sep 12 '24 21:09 dtcyganok

@Ledorub that's nice! I'd also suggest to read the config file by default instead of using option -config-file. It'd be way more conventional. And it would be nice to have the global/system and the local/user config files on linux systems.

To make use of the service instead of loading it with the -config-file switch, you can do something like this:

Edit /etc/conf.d/spoofdpi file and define your config options below the already existing ones. For example like this:

LISTEN_ADDR=127.0.0.1
PORT=8080
WINDOW_SIZE=0
DNS_ADDR="my.dns.resolver.com" # This is just an example, not a real DNS resolver.

Then edit /usr/lib/systemd/system/spoofdpi.service or wherever the service file for SpoofDPI in your system is. Go to the line which starts with ExecStart and modify the command the service will run here. For example mine looks like:

ExecStart=/usr/bin/spoofdpi -silent -dns-addr $DNS_ADDR -enable-doh -addr $LISTEN_ADDR -port $PORT -window-size $WINDOW_SIZE

I added -enable-doh option here and used DNS_ADDR env var from the config file I previously edited.

Now you can start or enable your service like for example if your system uses systemd: systemctl enable spoofdpi and it will auto-run with your config when you boot your system.

And in the same sense, you can also use the -config-file switch in the service file to use the format above that @Ledorub shared.

Turab avatar Apr 02 '25 15:04 Turab

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Nov 26 '25 02:11 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Dec 03 '25 02:12 github-actions[bot]