defaults.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. ########################################################################
  2. # Searx-Qt - Lightweight desktop application for Searx.
  3. # Copyright (C) 2020-2022 CYBERDEViL
  4. #
  5. # This file is part of Searx-Qt.
  6. #
  7. # Searx-Qt is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # Searx-Qt is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. #
  20. ########################################################################
  21. from searxqt.core.guard import ConsequenceType
  22. from searxqt.core.http import ErrorType
  23. from searxqt.core.handler import NetworkTypes
  24. """ This can be used to set default settings for new profiles.
  25. Only what is defined below is supported at the moment. The Presets dict below
  26. is the relevant part.
  27. """
  28. Guard = {
  29. "enabled": True,
  30. "storeLog": True, # This won't do anything unless enabled is set to True
  31. "maxLogDays": 7,
  32. "rules": [
  33. # The order of this list does mather!
  34. # Wrong status code (!200)
  35. # ____________________________________________________________________
  36. ## 429 - To many requests
  37. { # Blacklist 8x status code 429
  38. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 8, 'period': 0, 'status': 429},
  39. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 0}
  40. }, { # Timeout 4x status code 429 for 1 day
  41. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 4, 'period': 0, 'status': 429},
  42. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  43. }, { # Timeout 3x status code 429 for 60min
  44. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 3, 'period': 0, 'status': 429},
  45. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 60}
  46. ## 403 - Forbidden
  47. }, { # Blacklist
  48. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 1, 'period': 0, 'status': 403},
  49. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 0}
  50. ## 400 - Bad request
  51. }, { # Blacklist 3x status code 400
  52. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 3, 'period': 0, 'status': 400},
  53. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 1440}
  54. }, { # Timeout 1x status code 400
  55. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 1, 'period': 0, 'status': 400},
  56. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  57. ## Status code catch all other
  58. }, { # Timeout 1x status code 429 for 10min
  59. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 1, 'period': 0, 'status': None},
  60. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 10}
  61. # HttpError
  62. # ____________________________________________________________________
  63. }, { # Blacklist 6x error
  64. 'condition': {'errorType': ErrorType.HttpError, 'amount': 6, 'period': 0, 'status': None},
  65. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 0}
  66. }, { # Timeout 4x for 1 day
  67. 'condition': {'errorType': ErrorType.HttpError, 'amount': 4, 'period': 0, 'status': None},
  68. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  69. }, { # Timeout 1x for 10min
  70. 'condition': {'errorType': ErrorType.HttpError, 'amount': 1, 'period': 0, 'status': None},
  71. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 30}
  72. # Timeout
  73. # ____________________________________________________________________
  74. }, { # Blacklist 6x
  75. 'condition': {'errorType': ErrorType.Timeout, 'amount': 6, 'period': 0, 'status': None},
  76. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 0}
  77. }, { # Timeout 4x for 1 day
  78. 'condition': {'errorType': ErrorType.Timeout, 'amount': 4, 'period': 0, 'status': None},
  79. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  80. }, { # Timeout 3x for 2 hours
  81. 'condition': {'errorType': ErrorType.Timeout, 'amount': 3, 'period': 0, 'status': None},
  82. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 120}
  83. }, { # Timeout 2x for 20min
  84. 'condition': {'errorType': ErrorType.Timeout, 'amount': 2, 'period': 0, 'status': None},
  85. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 30}
  86. }, { # Timeout 1x for 10min
  87. 'condition': {'errorType': ErrorType.Timeout, 'amount': 1, 'period': 0, 'status': None},
  88. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 10}
  89. # DecodeError
  90. # ____________________________________________________________________
  91. }, { # Blacklist 6x error
  92. 'condition': {'errorType': ErrorType.DecodeError, 'amount': 6, 'period': 0, 'status': None},
  93. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 0}
  94. }, { # Timeout 2x for 1 day
  95. 'condition': {'errorType': ErrorType.DecodeError, 'amount': 2, 'period': 0, 'status': None},
  96. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  97. }, { # Timeout 1x for 10min
  98. 'condition': {'errorType': ErrorType.DecodeError, 'amount': 1, 'period': 0, 'status': None},
  99. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 10}
  100. # NoResults
  101. # ____________________________________________________________________
  102. }, { # Timeout 4x for 60min.
  103. 'condition': {'errorType': ErrorType.NoResults, 'amount': 4, 'period': 0, 'status': None},
  104. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 60}
  105. }, { # Timeout 3x for 10min.
  106. 'condition': {'errorType': ErrorType.NoResults, 'amount': 3, 'period': 0, 'status': None},
  107. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 10}
  108. }, { # Timeout 2x for 3min.
  109. 'condition': {'errorType': ErrorType.NoResults, 'amount': 2, 'period': 0, 'status': None},
  110. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 3}
  111. }, { # Timeout 1x for 1min.
  112. 'condition': {'errorType': ErrorType.NoResults, 'amount': 1, 'period': 0, 'status': None},
  113. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1}
  114. # SSLError
  115. # ____________________________________________________________________
  116. }, { # Timeout 6x for 1 week.
  117. 'condition': {'errorType': ErrorType.SSLError, 'amount': 6, 'period': 0, 'status': None},
  118. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 10080}
  119. }, { # Timeout 4x for 1 day.
  120. 'condition': {'errorType': ErrorType.SSLError, 'amount': 4, 'period': 0, 'status': None},
  121. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  122. }, { # Timeout 3x for 60min.
  123. 'condition': {'errorType': ErrorType.SSLError, 'amount': 3, 'period': 0, 'status': None},
  124. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 60}
  125. }, { # Timeout 1x for 30min.
  126. 'condition': {'errorType': ErrorType.SSLError, 'amount': 1, 'period': 0, 'status': None},
  127. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 30}
  128. # InvalidSchema
  129. # this is probably a bug in Searx-Qt, please report when this happends.
  130. # ____________________________________________________________________
  131. }, { # Timeout until restart
  132. 'condition': {'errorType': ErrorType.InvalidSchema, 'amount': 0, 'period': 0, 'status': None},
  133. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 0}
  134. # ConnectionError
  135. # ____________________________________________________________________
  136. }, { # Blacklist 6x
  137. 'condition': {'errorType': ErrorType.ConnectionError, 'amount': 6, 'period': 0, 'status': None},
  138. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 0}
  139. }, { # Timeout 2x or 1 day
  140. 'condition': {'errorType': ErrorType.ConnectionError, 'amount': 2, 'period': 0, 'status': None},
  141. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  142. }, { # Timeout 1x for 2 hours
  143. 'condition': {'errorType': ErrorType.ConnectionError, 'amount': 1, 'period': 0, 'status': None},
  144. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 120}
  145. }
  146. ]
  147. }
  148. InstancesView = {
  149. # Hide all columns except the instance it's url and version.
  150. "hiddenColumnIndexes": [2,3,4,5,6,7,8,9,10]
  151. }
  152. Presets = {
  153. "Web": {
  154. "guard": Guard,
  155. "instancesView": InstancesView,
  156. "instancesFilter": {
  157. "networkTypes": [NetworkTypes.Web],
  158. "version": {
  159. "min": "1.0.0",
  160. "git": True,
  161. "dirty": False,
  162. "extra": False,
  163. "unknown": False,
  164. "invalid": False
  165. },
  166. "analytics": True
  167. },
  168. "settings": {
  169. "requests": {
  170. "useragents": [
  171. "Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 iceweasel/121.0.1",
  172. "searx-qt"
  173. ],
  174. "extraHeaders": [
  175. "Accept: text/html",
  176. "DNT: 1",
  177. "Accept-Language: en-US,en;q=0.5",
  178. "Accept-Encoding: gzip, deflate",
  179. "Connection: keep-alive"
  180. ]
  181. }
  182. }
  183. },
  184. "Tor": {
  185. "guard": {
  186. "enabled": False
  187. },
  188. "instancesView": InstancesView,
  189. "instancesFilter": {
  190. "networkTypes": [NetworkTypes.Tor],
  191. "asnPrivacy": False,
  192. "analytics": True
  193. },
  194. "settings": {
  195. "stats2": {
  196. "url": "http://searxspbitokayvkhzhsnljde7rqmn7rvoga6e4waeub3h7ug3nghoad.onion/"
  197. },
  198. "requests": {
  199. "useragents": [],
  200. "kwargs": {
  201. "proxies": {
  202. "http": "socks5h://127.0.0.1:9050",
  203. "https": "socks5h://127.0.0.1:9050"
  204. },
  205. "timeout": 30
  206. }
  207. }
  208. }
  209. },
  210. "i2p": {
  211. "guard": {
  212. "enabled": False
  213. },
  214. "instancesView": InstancesView,
  215. "instancesFilter": {
  216. "networkTypes": [NetworkTypes.I2P],
  217. "asnPrivacy": False
  218. },
  219. "settings": {
  220. "requests": {
  221. "useragents": [],
  222. "kwargs": {
  223. "proxies": {
  224. "http": "socks5h://127.0.0.1:4444",
  225. "https": "socks5h://127.0.0.1:4444"
  226. },
  227. "timeout": 120
  228. }
  229. }
  230. },
  231. "data": {
  232. "instances": {
  233. "http://ransack.i2p/": {"network_type": NetworkTypes.I2P},
  234. "http://searx.i2p/": {"network_type": NetworkTypes.I2P},
  235. "http://mqamk4cfykdvhw5kjez2gnvse56gmnqxn7vkvvbuor4k4j2lbbnq.b32.i2p/":
  236. {"network_type": NetworkTypes.I2P}
  237. }
  238. }
  239. }
  240. }