defaults.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. ExtraHeaders = [
  29. "Accept: text/html",
  30. "DNT: 1",
  31. "Accept-Language: en-US,en;q=0.5",
  32. "Accept-Encoding: gzip, deflate",
  33. "Connection: keep-alive"
  34. ]
  35. Guard = {
  36. "enabled": True,
  37. "storeLog": True, # This won't do anything unless enabled is set to True
  38. "maxLogDays": 7,
  39. "rules": [
  40. # The order of this list does matter!
  41. # Wrong status code (!200)
  42. # ____________________________________________________________________
  43. ## 429 - To many requests
  44. { # Blacklist 8x status code 429
  45. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 8, 'period': 0, 'status': 429},
  46. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 0}
  47. }, { # Timeout 4x status code 429 for 1 day
  48. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 4, 'period': 0, 'status': 429},
  49. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  50. }, { # Timeout 3x status code 429 for 60min
  51. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 3, 'period': 0, 'status': 429},
  52. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 60}
  53. ## 403 - Forbidden
  54. }, { # Blacklist
  55. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 1, 'period': 0, 'status': 403},
  56. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 0}
  57. ## 400 - Bad request
  58. }, { # Blacklist 3x status code 400
  59. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 3, 'period': 0, 'status': 400},
  60. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 1440}
  61. }, { # Timeout 1x status code 400
  62. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 1, 'period': 0, 'status': 400},
  63. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  64. ## Status code catch all other
  65. }, { # Timeout 1x status code 429 for 10min
  66. 'condition': {'errorType': ErrorType.WrongStatus, 'amount': 1, 'period': 0, 'status': None},
  67. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 10}
  68. # HttpError
  69. # ____________________________________________________________________
  70. }, { # Blacklist 6x error
  71. 'condition': {'errorType': ErrorType.HttpError, 'amount': 6, 'period': 0, 'status': None},
  72. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 0}
  73. }, { # Timeout 4x for 1 day
  74. 'condition': {'errorType': ErrorType.HttpError, 'amount': 4, 'period': 0, 'status': None},
  75. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  76. }, { # Timeout 1x for 10min
  77. 'condition': {'errorType': ErrorType.HttpError, 'amount': 1, 'period': 0, 'status': None},
  78. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 30}
  79. # Timeout
  80. # ____________________________________________________________________
  81. }, { # Blacklist 6x
  82. 'condition': {'errorType': ErrorType.Timeout, 'amount': 6, 'period': 0, 'status': None},
  83. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 0}
  84. }, { # Timeout 4x for 1 day
  85. 'condition': {'errorType': ErrorType.Timeout, 'amount': 4, 'period': 0, 'status': None},
  86. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  87. }, { # Timeout 3x for 2 hours
  88. 'condition': {'errorType': ErrorType.Timeout, 'amount': 3, 'period': 0, 'status': None},
  89. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 120}
  90. }, { # Timeout 2x for 20min
  91. 'condition': {'errorType': ErrorType.Timeout, 'amount': 2, 'period': 0, 'status': None},
  92. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 30}
  93. }, { # Timeout 1x for 10min
  94. 'condition': {'errorType': ErrorType.Timeout, 'amount': 1, 'period': 0, 'status': None},
  95. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 10}
  96. # DecodeError
  97. # ____________________________________________________________________
  98. }, { # Blacklist 6x error
  99. 'condition': {'errorType': ErrorType.DecodeError, 'amount': 6, 'period': 0, 'status': None},
  100. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 0}
  101. }, { # Timeout 2x for 1 day
  102. 'condition': {'errorType': ErrorType.DecodeError, 'amount': 2, 'period': 0, 'status': None},
  103. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  104. }, { # Timeout 1x for 10min
  105. 'condition': {'errorType': ErrorType.DecodeError, 'amount': 1, 'period': 0, 'status': None},
  106. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 10}
  107. # NoResults
  108. # ____________________________________________________________________
  109. }, { # Timeout 4x for 60min.
  110. 'condition': {'errorType': ErrorType.NoResults, 'amount': 4, 'period': 0, 'status': None},
  111. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 60}
  112. }, { # Timeout 3x for 10min.
  113. 'condition': {'errorType': ErrorType.NoResults, 'amount': 3, 'period': 0, 'status': None},
  114. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 10}
  115. }, { # Timeout 2x for 3min.
  116. 'condition': {'errorType': ErrorType.NoResults, 'amount': 2, 'period': 0, 'status': None},
  117. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 3}
  118. }, { # Timeout 1x for 1min.
  119. 'condition': {'errorType': ErrorType.NoResults, 'amount': 1, 'period': 0, 'status': None},
  120. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1}
  121. # SSLError
  122. # ____________________________________________________________________
  123. }, { # Timeout 6x for 1 week.
  124. 'condition': {'errorType': ErrorType.SSLError, 'amount': 6, 'period': 0, 'status': None},
  125. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 10080}
  126. }, { # Timeout 4x for 1 day.
  127. 'condition': {'errorType': ErrorType.SSLError, 'amount': 4, 'period': 0, 'status': None},
  128. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  129. }, { # Timeout 3x for 60min.
  130. 'condition': {'errorType': ErrorType.SSLError, 'amount': 3, 'period': 0, 'status': None},
  131. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 60}
  132. }, { # Timeout 1x for 30min.
  133. 'condition': {'errorType': ErrorType.SSLError, 'amount': 1, 'period': 0, 'status': None},
  134. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 30}
  135. # InvalidSchema
  136. # this is probably a bug in Searx-Qt, please report when this happens.
  137. # ____________________________________________________________________
  138. }, { # Timeout until restart
  139. 'condition': {'errorType': ErrorType.InvalidSchema, 'amount': 0, 'period': 0, 'status': None},
  140. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 0}
  141. # ConnectionError
  142. # ____________________________________________________________________
  143. }, { # Blacklist 6x
  144. 'condition': {'errorType': ErrorType.ConnectionError, 'amount': 6, 'period': 0, 'status': None},
  145. 'consequence': {'type': ConsequenceType.Blacklist, 'duration': 0}
  146. }, { # Timeout 2x or 1 day
  147. 'condition': {'errorType': ErrorType.ConnectionError, 'amount': 2, 'period': 0, 'status': None},
  148. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 1440}
  149. }, { # Timeout 1x for 2 hours
  150. 'condition': {'errorType': ErrorType.ConnectionError, 'amount': 1, 'period': 0, 'status': None},
  151. 'consequence': {'type': ConsequenceType.Timeout, 'duration': 120}
  152. }
  153. ]
  154. }
  155. InstancesView = {
  156. # Hide all columns except the instance it's url and version.
  157. "hiddenColumnIndexes": [2,3,4,5,6,7,8,9,10]
  158. }
  159. Presets = {
  160. "Web": {
  161. "guard": Guard,
  162. "instancesView": InstancesView,
  163. "instancesFilter": {
  164. "networkTypes": [NetworkTypes.Web],
  165. "version": {
  166. "min": "1.0.0",
  167. "git": True,
  168. "dirty": False,
  169. "extra": False,
  170. "unknown": False,
  171. "invalid": False
  172. },
  173. "analytics": True
  174. },
  175. "settings": {
  176. "requests": {
  177. "useragents": [
  178. "Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 iceweasel/121.0.1",
  179. "searx-qt"
  180. ],
  181. "extraHeaders": ExtraHeaders
  182. }
  183. }
  184. },
  185. "Tor": {
  186. "guard": {
  187. "enabled": False
  188. },
  189. "instancesView": InstancesView,
  190. "instancesFilter": {
  191. "networkTypes": [NetworkTypes.Tor],
  192. "asnPrivacy": False,
  193. "analytics": True
  194. },
  195. "settings": {
  196. "stats2": {
  197. "url": "http://searxspbitokayvkhzhsnljde7rqmn7rvoga6e4waeub3h7ug3nghoad.onion/"
  198. },
  199. "requests": {
  200. "useragents": [
  201. "Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 iceweasel/121.0.1"
  202. ],
  203. "extraHeaders": ExtraHeaders,
  204. "proxyEnabled": True,
  205. "proxyAddress": "127.0.0.1:9050",
  206. "proxyType": 7,
  207. "timeout": 30
  208. }
  209. }
  210. },
  211. "i2p": {
  212. "guard": {
  213. "enabled": False
  214. },
  215. "instancesView": InstancesView,
  216. "instancesFilter": {
  217. "networkTypes": [NetworkTypes.I2P],
  218. "asnPrivacy": False
  219. },
  220. "settings": {
  221. "requests": {
  222. "useragents": [
  223. "Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 iceweasel/121.0.1"
  224. ],
  225. "extraHeaders": ExtraHeaders,
  226. "proxyEnabled": True,
  227. "proxyAddress": "127.0.0.1:4444",
  228. "proxyType": 7,
  229. "timeout": 120
  230. }
  231. },
  232. "data": {
  233. "instances": {
  234. "http://ransack.i2p/": {"network_type": NetworkTypes.I2P},
  235. "http://searx.i2p/": {"network_type": NetworkTypes.I2P},
  236. "http://mqamk4cfykdvhw5kjez2gnvse56gmnqxn7vkvvbuor4k4j2lbbnq.b32.i2p/":
  237. {"network_type": NetworkTypes.I2P}
  238. }
  239. }
  240. }
  241. }