6 import ../make-test-python.nix ({ pkgs, lib, ... }: {
9 maintainers = with lib.maintainers; [ hmenke ];
14 boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
15 networking.useDHCP = false;
16 networking.interfaces.eth1.ipv4.addresses = [
17 { address = "192.168.0.1"; prefixLength = 24; }
19 networking.firewall.rejectPackets = true;
20 networking.firewall.allowedTCPPorts = [ 8488 ];
21 networking.firewall.allowedUDPPorts = [ 8488 ];
22 services.shadowsocks = {
24 encryptionMethod = "chacha20-ietf-poly1305";
25 password = "pa$$w0rd";
26 localAddress = [ "0.0.0.0" ];
30 } // lib.optionalAttrs (plugin != null) {
32 pluginOpts = "server;${pluginOpts}";
36 virtualHosts.server = {
37 locations."/".root = pkgs.writeTextDir "index.html" "It works!";
43 networking.useDHCP = false;
44 networking.interfaces.eth1.ipv4.addresses = [
45 { address = "192.168.0.2"; prefixLength = 24; }
47 systemd.services.shadowsocks-client = {
48 description = "connect to shadowsocks";
49 after = [ "network.target" ];
50 wantedBy = [ "multi-user.target" ];
51 path = with pkgs; [ shadowsocks-libev ];
58 -m chacha20-ietf-poly1305 \
60 ${lib.optionalString (plugin != null) ''
61 --plugin "${plugin}" --plugin-opts "${pluginOpts}"
71 server.wait_for_unit("shadowsocks-libev.service")
72 client.wait_for_unit("shadowsocks-client.service")
75 "${pkgs.curl}/bin/curl 192.168.0.1:80"
79 "${pkgs.curl}/bin/curl --socks5 localhost:1080 192.168.0.1:80"
81 assert msg == "It works!", "Could not connect through shadowsocks"