Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shadowsocks service: support plugins #96127

Merged
merged 3 commits into from Aug 26, 2020
Merged

Conversation

hmenke
Copy link
Member

@hmenke hmenke commented Aug 23, 2020

Motivation for this change

Some firewalls performs deep packet inspection to block VPN traffic, such as the Greaf Firewall (GFW) of the Chinese government. Therefore it is required to obfuscate the traffic which can be done using the v2ray software. The v2ray-plugin for the shadowsocks VPN was introduced in #95567. This PR makes the shadowsocks service for NixOS aware of plugins.

Personally, I'm using this in production for myself and for a friend in Beijing for a couple of months without problems. This is what my configuration roughly looks like:

{
  networking.firewall = {
    enable = true;
    allowedTCPPorts = [ 8488 ];
    allowedUDPPorts = [ 8488 ];
  };
  services.shadowsocks = {
    enable = true;
    encryptionMethod = "chacha20-ietf-poly1305";
    passwordFile = "/path/to/shadowsocks/key";
    localAddress = [ "0.0.0.0" ];
    port = 8488;
    mode = "tcp_and_udp";
    plugin = "${pkgs.shadowsocks-v2ray-plugin}/bin/v2ray-plugin";
    pluginOpts = "server;host=henrimenke.com";
  };
}
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@hmenke
Copy link
Member Author

hmenke commented Aug 23, 2020

@ahrzb @abbradar

@hmenke
Copy link
Member Author

hmenke commented Aug 24, 2020

Result of nixpkgs-review pr 96127 1

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/267

@Lassulus
Copy link
Member

can you add examples to the options also? If you have time, you could maybe add a nixos test for the service.

@hmenke
Copy link
Member Author

hmenke commented Aug 26, 2020

@Lassulus I have added examples and a test.

@hmenke
Copy link
Member Author

hmenke commented Aug 26, 2020

@ofborg test shadowsocks

@hmenke
Copy link
Member Author

hmenke commented Aug 26, 2020

@ofborg test shadowsocks

@hmenke
Copy link
Member Author

hmenke commented Aug 26, 2020

Test currently fails due to #96197

@Lassulus
Copy link
Member

perfect, thanks!

@Lassulus Lassulus merged commit 12baef5 into NixOS:master Aug 26, 2020
@hmenke hmenke deleted the shadowsocks branch August 27, 2020 21:36
@Mrmaxmeier
Copy link
Contributor

Heads-Up: It looks like this breaks the default shadowsocks.enable = true setup:

error: The option value `systemd.services.shadowsocks-libev.path.[definition 1-entry 2]' in `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/services/networking/shadowsocks.nix' is not of type `package or string'.

@hmenke
Copy link
Member Author

hmenke commented Sep 8, 2020

@Mrmaxmeier Thank you for reporting this. It should be fixed by #97478, please review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants