nixos/shadowsocks: support plugins
This commit is contained in:
parent
e23ed2f21c
commit
d35cb15153
|
@ -11,8 +11,13 @@ let
|
||||||
method = cfg.encryptionMethod;
|
method = cfg.encryptionMethod;
|
||||||
mode = cfg.mode;
|
mode = cfg.mode;
|
||||||
user = "nobody";
|
user = "nobody";
|
||||||
fast_open = true;
|
fast_open = cfg.fastOpen;
|
||||||
} // optionalAttrs (cfg.password != null) { password = cfg.password; };
|
} // optionalAttrs (cfg.plugin != null) {
|
||||||
|
plugin = cfg.plugin;
|
||||||
|
plugin_opts = cfg.pluginOpts;
|
||||||
|
} // optionalAttrs (cfg.password != null) {
|
||||||
|
password = cfg.password;
|
||||||
|
};
|
||||||
|
|
||||||
configFile = pkgs.writeText "shadowsocks.json" (builtins.toJSON opts);
|
configFile = pkgs.writeText "shadowsocks.json" (builtins.toJSON opts);
|
||||||
|
|
||||||
|
@ -74,6 +79,14 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fastOpen = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
use TCP fast-open
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
encryptionMethod = mkOption {
|
encryptionMethod = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "chacha20-ietf-poly1305";
|
default = "chacha20-ietf-poly1305";
|
||||||
|
@ -82,6 +95,23 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
plugin = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
example = "\${pkgs.shadowsocks-v2ray-plugin}/bin/v2ray-plugin";
|
||||||
|
description = ''
|
||||||
|
SIP003 plugin for shadowsocks
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
pluginOpts = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "";
|
||||||
|
example = "server;host=example.com";
|
||||||
|
description = ''
|
||||||
|
Options to pass to the plugin if one was specified
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -99,7 +129,7 @@ in
|
||||||
description = "shadowsocks-libev Daemon";
|
description = "shadowsocks-libev Daemon";
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
path = [ pkgs.shadowsocks-libev ] ++ optional (cfg.passwordFile != null) pkgs.jq;
|
path = [ pkgs.shadowsocks-libev cfg.plugin ] ++ optional (cfg.passwordFile != null) pkgs.jq;
|
||||||
serviceConfig.PrivateTmp = true;
|
serviceConfig.PrivateTmp = true;
|
||||||
script = ''
|
script = ''
|
||||||
${optionalString (cfg.passwordFile != null) ''
|
${optionalString (cfg.passwordFile != null) ''
|
||||||
|
|
Loading…
Reference in New Issue