defaults.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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.requests 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. "DNT": "1",
  176. "Accept-Language": "en-US,en;q=0.5",
  177. "Accept-Encoding": "gzip, deflate"
  178. }
  179. }
  180. }
  181. },
  182. "Tor": {
  183. "guard": {
  184. "enabled": False
  185. },
  186. "instancesView": InstancesView,
  187. "instancesFilter": {
  188. "networkTypes": [NetworkTypes.Tor],
  189. "asnPrivacy": False,
  190. "analytics": True
  191. },
  192. "settings": {
  193. "stats2": {
  194. "url": "http://searxspbitokayvkhzhsnljde7rqmn7rvoga6e4waeub3h7ug3nghoad.onion/"
  195. },
  196. "requests": {
  197. "useragents": [],
  198. "kwargs": {
  199. "proxies": {
  200. "http": "socks5h://127.0.0.1:9050",
  201. "https": "socks5h://127.0.0.1:9050"
  202. },
  203. "timeout": 30
  204. }
  205. }
  206. }
  207. },
  208. "i2p": {
  209. "guard": {
  210. "enabled": False
  211. },
  212. "instancesView": InstancesView,
  213. "instancesFilter": {
  214. "networkTypes": [NetworkTypes.I2P],
  215. "asnPrivacy": False
  216. },
  217. "settings": {
  218. "requests": {
  219. "useragents": [],
  220. "kwargs": {
  221. "proxies": {
  222. "http": "socks5h://127.0.0.1:4444",
  223. "https": "socks5h://127.0.0.1:4444"
  224. },
  225. "timeout": 120
  226. }
  227. }
  228. },
  229. "data": {
  230. "instances": {
  231. "http://ransack.i2p/": {"network_type": NetworkTypes.I2P},
  232. "http://searx.i2p/": {"network_type": NetworkTypes.I2P},
  233. "http://mqamk4cfykdvhw5kjez2gnvse56gmnqxn7vkvvbuor4k4j2lbbnq.b32.i2p/":
  234. {"network_type": NetworkTypes.I2P}
  235. }
  236. }
  237. }
  238. }