编辑

编辑

我在配置 Shadowsocks 配置文件时遇到这个问题:

$ ssserver -c profile.json
/gnu/store/yvjgk9n6xzpr32maq1mqw1ij2vhm9jxb-shadowsocks-2.8.2-0.e332ec9/lib/python3.8/site-packages/shadowsocks/common.py:221: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if addr is "":
/gnu/store/yvjgk9n6xzpr32maq1mqw1ij2vhm9jxb-shadowsocks-2.8.2-0.e332ec9/lib/python3.8/site-packages/shadowsocks/common.py:233: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if len(block) is 1:
/gnu/store/yvjgk9n6xzpr32maq1mqw1ij2vhm9jxb-shadowsocks-2.8.2-0.e332ec9/lib/python3.8/site-packages/shadowsocks/common.py:235: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  while (ip & 1) == 0 and ip is not 0:
INFO: loading config from profile.json
Traceback (most recent call last):
  File "/gnu/store/yvjgk9n6xzpr32maq1mqw1ij2vhm9jxb-shadowsocks-2.8.2-0.e332ec9/bin/.ssserver-real", line 11, in <module>
    load_entry_point('shadowsocks==3.0.0', 'console_scripts', 'ssserver')()
  File "/gnu/store/yvjgk9n6xzpr32maq1mqw1ij2vhm9jxb-shadowsocks-2.8.2-0.e332ec9/lib/python3.8/site-packages/shadowsocks/server.py", line 34, in main
    config = shell.get_config(False)
  File "/gnu/store/yvjgk9n6xzpr32maq1mqw1ij2vhm9jxb-shadowsocks-2.8.2-0.e332ec9/lib/python3.8/site-packages/shadowsocks/shell.py", line 355, in get_config
    check_config(config, is_local)
  File "/gnu/store/yvjgk9n6xzpr32maq1mqw1ij2vhm9jxb-shadowsocks-2.8.2-0.e332ec9/lib/python3.8/site-packages/shadowsocks/shell.py", line 210, in check_config
    cryptor.try_cipher(config['password'], config['method'],
  File "/gnu/store/yvjgk9n6xzpr32maq1mqw1ij2vhm9jxb-shadowsocks-2.8.2-0.e332ec9/lib/python3.8/site-packages/shadowsocks/cryptor.py", line 51, in try_cipher
    Cryptor(key, method, crypto_path)
  File "/gnu/store/yvjgk9n6xzpr32maq1mqw1ij2vhm9jxb-shadowsocks-2.8.2-0.e332ec9/lib/python3.8/site-packages/shadowsocks/cryptor.py", line 98, in __init__
    self.cipher = self.get_cipher(
  File "/gnu/store/yvjgk9n6xzpr32maq1mqw1ij2vhm9jxb-shadowsocks-2.8.2-0.e332ec9/lib/python3.8/site-packages/shadowsocks/cryptor.py", line 130, in get_cipher
    return m[METHOD_INFO_CRYPTO](method, key, iv, op, self.crypto_path)
  File "/gnu/store/yvjgk9n6xzpr32maq1mqw1ij2vhm9jxb-shadowsocks-2.8.2-0.e332ec9/lib/python3.8/site-packages/shadowsocks/crypto/openssl.py", line 150, in __init__
    OpenSSLCryptoBase.__init__(self, cipher_name, crypto_path)
  File "/gnu/store/yvjgk9n6xzpr32maq1mqw1ij2vhm9jxb-shadowsocks-2.8.2-0.e332ec9/lib/python3.8/site-packages/shadowsocks/crypto/openssl.py", line 98, in __init__
    load_openssl(crypto_path)
  File "/gnu/store/yvjgk9n6xzpr32maq1mqw1ij2vhm9jxb-shadowsocks-2.8.2-0.e332ec9/lib/python3.8/site-packages/shadowsocks/crypto/openssl.py", line 51, in load_openssl
    raise Exception('libcrypto(OpenSSL) not found with path %s' % path)
Exception: libcrypto(OpenSSL) not found with path None

解决办法是什么?

答案1

编辑

在撰写本文时,有人比我更了解源代码,他设计了一个补丁,已提交给 Guix 上游。换句话说,这个问题可能很快就会得到解决。

原帖

查看 Shadowsocks 的包定义,它看起来相当空洞,甚至没有列出 OpenSSL 作为输入或任何类似的东西。此外,shadowsocks 似乎希望您以某种配置保存所有这些路径。

config['crypto_path'] = {'openssl': config['libopenssl'],
                         'mbedtls': config['libmbedtls'],
                         'sodium': config['libsodium']}

这些技巧在传统发行版(例如基于 Debian 等的发行版)上可能非常聪明,但当与任何类型的功能包管理结合使用时,它们就会被彻底破坏。 Guix 处理此类问题的方法是在构建时使用substitute*.您的阶段可能如下所示:

  (add-after 'unpack 'patch-crypto-paths
    (lambda* (#:key inputs #:allow-other-keys)
      (substitute* "shadowsocks/shell.py"
        (("config\\['libopenssl'\\]") 
         (string-append (assoc-ref inputs "openssl") "/path/to/libopenssl"))
        [...])
      #t))

[由于上面的内容显然是 Guix 代码,因此您可以在 GPLv3+ 下自由使用它,即使 SO 通常会强制要求 CC BY-SA。]

#t请注意,最近可能不再严格要求以in 结尾,但我认为您仍然会在 Guix 代码中经常发现它。

相关内容