Terminal

在 GuixSystem 中配置 Shadowsocks 配置文件

  • December 7, 2020

我在配置 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

解決辦法是什麼?

編輯

有人比我在寫這篇文章時對原始碼有更好的了解,他設計了一個更新檔,該更新檔已送出給上游的 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))

$$ Since the above is obviously meant to be Guix code, you can freely use it under the GPLv3+, even though SO would normally mandate CC BY-SA. $$ 請注意,#t最近可能不再嚴格要求以結尾,但我認為您仍然會經常在 Guix 程式碼中找到它。

引用自:https://unix.stackexchange.com/questions/623324