浏览代码

[enh] allow morty proxy without hmac key

Adam Tauber 8 年前
父节点
当前提交
a67a4bf2c0
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. 7
    3
      searx/webapp.py

+ 7
- 3
searx/webapp.py 查看文件

@@ -253,11 +253,15 @@ def proxify(url):
253 253
     if not settings.get('result_proxy'):
254 254
         return url
255 255
 
256
-    h = hmac.new(settings['result_proxy']['key'], url.encode('utf-8'), hashlib.sha256).hexdigest()
256
+    url_params = dict(mortyurl=url.encode('utf-8'))
257
+
258
+    if settings['result_proxy'].get('key'):
259
+        url_params['mortyhash'] = hmac.new(settings['result_proxy']['key'],
260
+                                           url.encode('utf-8'),
261
+                                           hashlib.sha256).hexdigest()
257 262
 
258 263
     return '{0}?{1}'.format(settings['result_proxy']['url'],
259
-                            urlencode(dict(mortyurl=url.encode('utf-8'),
260
-                                           mortyhash=h)))
264
+                            urlencode(url_params))
261 265
 
262 266
 
263 267
 def image_proxify(url):