go-shadowsocks2 icon indicating copy to clipboard operation
go-shadowsocks2 copied to clipboard

Feature Request: Config file support

Open invisiblearts opened this issue 8 years ago • 6 comments

Currently go-shadowsocks2 uses an ss:// URL as the way to import config, which is simplistic in desktop cases while not in server cases. Config file support enables us to write a universal systemd (or equivalents on other platforms) service that is good for distribution.

invisiblearts avatar Feb 23 '17 00:02 invisiblearts

It's trivial to load config from an environment file in systemd

file /path/to/go-shadowsocks.env

REMOTE_ADDR=ss://aes-128-gcm:password@host:port

file /etc/systemd/system/go-shadowsocks.service

[Unit]
Description=Shadowsocks2
Wants=network-online.target
After=network-online.target

[Service]
User=nobody
PermissionsStartOnly=true
EnvironmentFile=/path/to/go-shadowsocks2.env
ExecStart=/path/to/go-shadowsocks2 -s $REMOTE_ADDR
Nice=-10
KillMode=process
Restart=on-failure
ProtectSystem=full
ProtectHome=true
PrivateTmp=true
PrivateDevices=true
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

riobard avatar Feb 23 '17 02:02 riobard

Thanks, this do solve the problem for status quo. Yet still I am afraid that the ss:// URL is not optimal as a configuring way for it is not as clear as a ini/json. Also, I believe ss:// is universal, and there would be no place for implementation-specific configuration. Anyway, closed for now.

invisiblearts avatar Feb 24 '17 08:02 invisiblearts

This URL config syntax is being discussed in SIP002 https://github.com/shadowsocks/shadowsocks-org/issues/27

riobard avatar Feb 24 '17 08:02 riobard

Password on the command line is insecure, it can be grabbed by any user account from ps output. Please consider adding file configuration for it (or I can write a PR for it if that's acceptable)

tanji avatar Sep 18 '19 14:09 tanji

Reopen for reconsideration.

riobard avatar Sep 19 '19 04:09 riobard

Currently I want to migrate from python shadowsocks to golang one, so I'd prefer using the config I already have:

{
        "server": "example.com",
        "server_port": "1337",
        "local_port": "2285",
        "password": "pwd",
        "timeout": 600,
        "method": "aes-256-cfb"
}

Config shouldn't be necessarily in JSON, but it is very much needed for quick setup on multiple desktops.

v1rtl avatar Dec 06 '19 12:12 v1rtl