alamin655 commited on
Commit
61eaa47
2 Parent(s): 867753a b9d651c

Merge pull request #204 from neon-mmd/feat-rate-limiter-for-websurfx

Browse files
Cargo.lock CHANGED
@@ -9,7 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
9
  checksum = "617a8268e3537fe1d8c9ead925fca49ef6400927ee7bc26750e90ecee14ce4b8"
10
  dependencies = [
11
  "bitflags 1.3.2",
12
- "bytes 1.4.0",
13
  "futures-core",
14
  "futures-sink",
15
  "memchr",
@@ -46,7 +46,7 @@ dependencies = [
46
  "actix-web",
47
  "askama_escape",
48
  "bitflags 1.3.2",
49
- "bytes 1.4.0",
50
  "derive_more",
51
  "futures-core",
52
  "http-range",
@@ -57,6 +57,18 @@ dependencies = [
57
  "pin-project-lite",
58
  ]
59
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  [[package]]
61
  name = "actix-http"
62
  version = "3.4.0"
@@ -68,10 +80,10 @@ dependencies = [
68
  "actix-service",
69
  "actix-utils",
70
  "ahash",
71
- "base64 0.21.3",
72
  "bitflags 2.4.0",
73
  "brotli",
74
- "bytes 1.4.0",
75
  "bytestring",
76
  "derive_more",
77
  "encoding_rs",
@@ -103,7 +115,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
103
  checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb"
104
  dependencies = [
105
  "quote 1.0.33",
106
- "syn 2.0.29",
107
  ]
108
 
109
  [[package]]
@@ -183,7 +195,7 @@ dependencies = [
183
  "actix-utils",
184
  "actix-web-codegen",
185
  "ahash",
186
- "bytes 1.4.0",
187
  "bytestring",
188
  "cfg-if 1.0.0",
189
  "cookie 0.16.2",
@@ -216,7 +228,7 @@ dependencies = [
216
  "actix-router",
217
  "proc-macro2 1.0.66",
218
  "quote 1.0.33",
219
- "syn 2.0.29",
220
  ]
221
 
222
  [[package]]
@@ -278,9 +290,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
278
 
279
  [[package]]
280
  name = "anstyle"
281
- version = "1.0.2"
282
  source = "registry+https://github.com/rust-lang/crates.io-index"
283
- checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea"
284
 
285
  [[package]]
286
  name = "anyhow"
@@ -314,7 +326,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0"
314
  dependencies = [
315
  "proc-macro2 1.0.66",
316
  "quote 1.0.33",
317
- "syn 2.0.29",
318
  ]
319
 
320
  [[package]]
@@ -358,9 +370,9 @@ dependencies = [
358
 
359
  [[package]]
360
  name = "base64"
361
- version = "0.21.3"
362
  source = "registry+https://github.com/rust-lang/crates.io-index"
363
- checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53"
364
 
365
  [[package]]
366
  name = "bit-set"
@@ -453,9 +465,9 @@ dependencies = [
453
 
454
  [[package]]
455
  name = "bytes"
456
- version = "1.4.0"
457
  source = "registry+https://github.com/rust-lang/crates.io-index"
458
- checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
459
 
460
  [[package]]
461
  name = "bytestring"
@@ -463,7 +475,7 @@ version = "1.3.0"
463
  source = "registry+https://github.com/rust-lang/crates.io-index"
464
  checksum = "238e4886760d98c4f899360c834fa93e62cf7f721ac3c2da375cbdf4b8679aae"
465
  dependencies = [
466
- "bytes 1.4.0",
467
  ]
468
 
469
  [[package]]
@@ -570,7 +582,7 @@ version = "4.6.6"
570
  source = "registry+https://github.com/rust-lang/crates.io-index"
571
  checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4"
572
  dependencies = [
573
- "bytes 1.4.0",
574
  "futures-core",
575
  "memchr",
576
  "pin-project-lite",
@@ -590,7 +602,7 @@ version = "0.12.0"
590
  source = "registry+https://github.com/rust-lang/crates.io-index"
591
  checksum = "888604f00b3db336d2af898ec3c1d5d0ddf5e6d462220f2ededc33a87ac4bbd5"
592
  dependencies = [
593
- "time 0.1.45",
594
  "url 1.7.2",
595
  ]
596
 
@@ -618,7 +630,7 @@ dependencies = [
618
  "publicsuffix",
619
  "serde",
620
  "serde_json",
621
- "time 0.1.45",
622
  "try_from",
623
  "url 1.7.2",
624
  ]
@@ -814,7 +826,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
814
  checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"
815
  dependencies = [
816
  "quote 1.0.33",
817
- "syn 2.0.29",
 
 
 
 
 
 
 
 
 
 
 
 
 
818
  ]
819
 
820
  [[package]]
@@ -950,9 +975,9 @@ dependencies = [
950
 
951
  [[package]]
952
  name = "error-stack"
953
- version = "0.4.0"
954
  source = "registry+https://github.com/rust-lang/crates.io-index"
955
- checksum = "e6a37ef405b504fc3b87a24fa52906d98cdd1a7d4e5ef2b49f0d5fead138fced"
956
  dependencies = [
957
  "anyhow",
958
  "rustc_version 0.4.0",
@@ -1147,7 +1172,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72"
1147
  dependencies = [
1148
  "proc-macro2 1.0.66",
1149
  "quote 1.0.33",
1150
- "syn 2.0.29",
1151
  ]
1152
 
1153
  [[package]]
@@ -1162,6 +1187,12 @@ version = "0.3.28"
1162
  source = "registry+https://github.com/rust-lang/crates.io-index"
1163
  checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65"
1164
 
 
 
 
 
 
 
1165
  [[package]]
1166
  name = "futures-util"
1167
  version = "0.3.28"
@@ -1225,6 +1256,24 @@ version = "0.28.0"
1225
  source = "registry+https://github.com/rust-lang/crates.io-index"
1226
  checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
1227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1228
  [[package]]
1229
  name = "h2"
1230
  version = "0.1.26"
@@ -1249,7 +1298,7 @@ version = "0.3.21"
1249
  source = "registry+https://github.com/rust-lang/crates.io-index"
1250
  checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833"
1251
  dependencies = [
1252
- "bytes 1.4.0",
1253
  "fnv",
1254
  "futures-core",
1255
  "futures-sink",
@@ -1289,6 +1338,12 @@ version = "0.12.3"
1289
  source = "registry+https://github.com/rust-lang/crates.io-index"
1290
  checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
1291
 
 
 
 
 
 
 
1292
  [[package]]
1293
  name = "hermit-abi"
1294
  version = "0.3.2"
@@ -1340,7 +1395,7 @@ version = "0.2.9"
1340
  source = "registry+https://github.com/rust-lang/crates.io-index"
1341
  checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482"
1342
  dependencies = [
1343
- "bytes 1.4.0",
1344
  "fnv",
1345
  "itoa 1.0.9",
1346
  ]
@@ -1363,7 +1418,7 @@ version = "0.4.5"
1363
  source = "registry+https://github.com/rust-lang/crates.io-index"
1364
  checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1"
1365
  dependencies = [
1366
- "bytes 1.4.0",
1367
  "http 0.2.9",
1368
  "pin-project-lite",
1369
  ]
@@ -1410,7 +1465,7 @@ dependencies = [
1410
  "log",
1411
  "net2",
1412
  "rustc_version 0.2.3",
1413
- "time 0.1.45",
1414
  "tokio 0.1.22",
1415
  "tokio-buf",
1416
  "tokio-executor",
@@ -1428,7 +1483,7 @@ version = "0.14.27"
1428
  source = "registry+https://github.com/rust-lang/crates.io-index"
1429
  checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468"
1430
  dependencies = [
1431
- "bytes 1.4.0",
1432
  "futures-channel",
1433
  "futures-core",
1434
  "futures-util",
@@ -1465,7 +1520,7 @@ version = "0.5.0"
1465
  source = "registry+https://github.com/rust-lang/crates.io-index"
1466
  checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
1467
  dependencies = [
1468
- "bytes 1.4.0",
1469
  "hyper 0.14.27",
1470
  "native-tls",
1471
  "tokio 1.32.0",
@@ -1511,7 +1566,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1511
  checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
1512
  dependencies = [
1513
  "autocfg 1.1.0",
1514
- "hashbrown",
1515
  ]
1516
 
1517
  [[package]]
@@ -1619,9 +1674,9 @@ dependencies = [
1619
 
1620
  [[package]]
1621
  name = "linux-raw-sys"
1622
- version = "0.4.5"
1623
  source = "registry+https://github.com/rust-lang/crates.io-index"
1624
- checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503"
1625
 
1626
  [[package]]
1627
  name = "local-channel"
@@ -1672,6 +1727,15 @@ version = "0.1.1"
1672
  source = "registry+https://github.com/rust-lang/crates.io-index"
1673
  checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
1674
 
 
 
 
 
 
 
 
 
 
1675
  [[package]]
1676
  name = "markup5ever"
1677
  version = "0.8.1"
@@ -1723,9 +1787,9 @@ checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
1723
 
1724
  [[package]]
1725
  name = "memchr"
1726
- version = "2.6.2"
1727
  source = "registry+https://github.com/rust-lang/crates.io-index"
1728
- checksum = "5486aed0026218e61b8a01d5fbd5a0a134649abb71a0e53b7bc088529dced86e"
1729
 
1730
  [[package]]
1731
  name = "memoffset"
@@ -1887,6 +1951,18 @@ version = "0.5.0"
1887
  source = "registry+https://github.com/rust-lang/crates.io-index"
1888
  checksum = "ab250442c86f1850815b5d268639dff018c0627022bc1940eb2d642ca1ce12f0"
1889
 
 
 
 
 
 
 
 
 
 
 
 
 
1890
  [[package]]
1891
  name = "num-traits"
1892
  version = "0.2.16"
@@ -1908,9 +1984,9 @@ dependencies = [
1908
 
1909
  [[package]]
1910
  name = "object"
1911
- version = "0.32.0"
1912
  source = "registry+https://github.com/rust-lang/crates.io-index"
1913
- checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe"
1914
  dependencies = [
1915
  "memchr",
1916
  ]
@@ -1950,7 +2026,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
1950
  dependencies = [
1951
  "proc-macro2 1.0.66",
1952
  "quote 1.0.33",
1953
- "syn 2.0.29",
1954
  ]
1955
 
1956
  [[package]]
@@ -1961,9 +2037,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
1961
 
1962
  [[package]]
1963
  name = "openssl-sys"
1964
- version = "0.9.92"
1965
  source = "registry+https://github.com/rust-lang/crates.io-index"
1966
- checksum = "db7e971c2c2bba161b2d2fdf37080177eff520b3bc044787c7f1f5f9e78d869b"
1967
  dependencies = [
1968
  "cc",
1969
  "libc",
@@ -2069,7 +2145,7 @@ dependencies = [
2069
  "pest_meta",
2070
  "proc-macro2 1.0.66",
2071
  "quote 1.0.33",
2072
- "syn 2.0.29",
2073
  ]
2074
 
2075
  [[package]]
@@ -2171,7 +2247,7 @@ dependencies = [
2171
  "phf_shared 0.11.2",
2172
  "proc-macro2 1.0.66",
2173
  "quote 1.0.33",
2174
- "syn 2.0.29",
2175
  ]
2176
 
2177
  [[package]]
@@ -2218,7 +2294,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
2218
  dependencies = [
2219
  "proc-macro2 1.0.66",
2220
  "quote 1.0.33",
2221
- "syn 2.0.29",
2222
  ]
2223
 
2224
  [[package]]
@@ -2307,6 +2383,22 @@ dependencies = [
2307
  "url 2.4.1",
2308
  ]
2309
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2310
  [[package]]
2311
  name = "quote"
2312
  version = "0.6.13"
@@ -2461,6 +2553,15 @@ dependencies = [
2461
  "rand_core 0.3.1",
2462
  ]
2463
 
 
 
 
 
 
 
 
 
 
2464
  [[package]]
2465
  name = "rayon"
2466
  version = "1.7.0"
@@ -2500,7 +2601,7 @@ checksum = "4f49cdc0bb3f412bf8e7d1bd90fe1d9eb10bc5c399ba90973c14662a27b3f8ba"
2500
  dependencies = [
2501
  "arc-swap",
2502
  "async-trait",
2503
- "bytes 1.4.0",
2504
  "combine",
2505
  "futures 0.3.28",
2506
  "futures-util",
@@ -2533,9 +2634,9 @@ dependencies = [
2533
 
2534
  [[package]]
2535
  name = "regex"
2536
- version = "1.9.4"
2537
  source = "registry+https://github.com/rust-lang/crates.io-index"
2538
- checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29"
2539
  dependencies = [
2540
  "aho-corasick",
2541
  "memchr",
@@ -2545,9 +2646,9 @@ dependencies = [
2545
 
2546
  [[package]]
2547
  name = "regex-automata"
2548
- version = "0.3.7"
2549
  source = "registry+https://github.com/rust-lang/crates.io-index"
2550
- checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629"
2551
  dependencies = [
2552
  "aho-corasick",
2553
  "memchr",
@@ -2583,7 +2684,7 @@ dependencies = [
2583
  "serde",
2584
  "serde_json",
2585
  "serde_urlencoded 0.5.5",
2586
- "time 0.1.45",
2587
  "tokio 0.1.22",
2588
  "tokio-executor",
2589
  "tokio-io",
@@ -2600,8 +2701,8 @@ version = "0.11.20"
2600
  source = "registry+https://github.com/rust-lang/crates.io-index"
2601
  checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1"
2602
  dependencies = [
2603
- "base64 0.21.3",
2604
- "bytes 1.4.0",
2605
  "encoding_rs",
2606
  "futures-core",
2607
  "futures-util",
@@ -2663,9 +2764,9 @@ dependencies = [
2663
 
2664
  [[package]]
2665
  name = "rustix"
2666
- version = "0.38.11"
2667
  source = "registry+https://github.com/rust-lang/crates.io-index"
2668
- checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453"
2669
  dependencies = [
2670
  "bitflags 2.4.0",
2671
  "errno",
@@ -2823,14 +2924,14 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
2823
  dependencies = [
2824
  "proc-macro2 1.0.66",
2825
  "quote 1.0.33",
2826
- "syn 2.0.29",
2827
  ]
2828
 
2829
  [[package]]
2830
  name = "serde_json"
2831
- version = "1.0.105"
2832
  source = "registry+https://github.com/rust-lang/crates.io-index"
2833
- checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360"
2834
  dependencies = [
2835
  "itoa 1.0.9",
2836
  "ryu",
@@ -3065,9 +3166,9 @@ dependencies = [
3065
 
3066
  [[package]]
3067
  name = "syn"
3068
- version = "2.0.29"
3069
  source = "registry+https://github.com/rust-lang/crates.io-index"
3070
- checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a"
3071
  dependencies = [
3072
  "proc-macro2 1.0.66",
3073
  "quote 1.0.33",
@@ -3131,22 +3232,22 @@ dependencies = [
3131
 
3132
  [[package]]
3133
  name = "thiserror"
3134
- version = "1.0.47"
3135
  source = "registry+https://github.com/rust-lang/crates.io-index"
3136
- checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f"
3137
  dependencies = [
3138
  "thiserror-impl",
3139
  ]
3140
 
3141
  [[package]]
3142
  name = "thiserror-impl"
3143
- version = "1.0.47"
3144
  source = "registry+https://github.com/rust-lang/crates.io-index"
3145
- checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b"
3146
  dependencies = [
3147
  "proc-macro2 1.0.66",
3148
  "quote 1.0.33",
3149
- "syn 2.0.29",
3150
  ]
3151
 
3152
  [[package]]
@@ -3157,12 +3258,11 @@ checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820"
3157
 
3158
  [[package]]
3159
  name = "time"
3160
- version = "0.1.45"
3161
  source = "registry+https://github.com/rust-lang/crates.io-index"
3162
- checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
3163
  dependencies = [
3164
  "libc",
3165
- "wasi 0.10.0+wasi-snapshot-preview1",
3166
  "winapi 0.3.9",
3167
  ]
3168
 
@@ -3245,7 +3345,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
3245
  checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9"
3246
  dependencies = [
3247
  "backtrace",
3248
- "bytes 1.4.0",
3249
  "libc",
3250
  "mio 0.8.8",
3251
  "num_cpus",
@@ -3307,7 +3407,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e"
3307
  dependencies = [
3308
  "proc-macro2 1.0.66",
3309
  "quote 1.0.33",
3310
- "syn 2.0.29",
3311
  ]
3312
 
3313
  [[package]]
@@ -3409,7 +3509,7 @@ version = "0.7.8"
3409
  source = "registry+https://github.com/rust-lang/crates.io-index"
3410
  checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d"
3411
  dependencies = [
3412
- "bytes 1.4.0",
3413
  "futures-core",
3414
  "futures-sink",
3415
  "pin-project-lite",
@@ -3579,9 +3679,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
3579
 
3580
  [[package]]
3581
  name = "walkdir"
3582
- version = "2.3.3"
3583
  source = "registry+https://github.com/rust-lang/crates.io-index"
3584
- checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698"
3585
  dependencies = [
3586
  "same-file",
3587
  "winapi-util",
@@ -3609,9 +3709,9 @@ dependencies = [
3609
 
3610
  [[package]]
3611
  name = "wasi"
3612
- version = "0.10.0+wasi-snapshot-preview1"
3613
  source = "registry+https://github.com/rust-lang/crates.io-index"
3614
- checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
3615
 
3616
  [[package]]
3617
  name = "wasi"
@@ -3640,7 +3740,7 @@ dependencies = [
3640
  "once_cell",
3641
  "proc-macro2 1.0.66",
3642
  "quote 1.0.33",
3643
- "syn 2.0.29",
3644
  "wasm-bindgen-shared",
3645
  ]
3646
 
@@ -3674,7 +3774,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b"
3674
  dependencies = [
3675
  "proc-macro2 1.0.66",
3676
  "quote 1.0.33",
3677
- "syn 2.0.29",
3678
  "wasm-bindgen-backend",
3679
  "wasm-bindgen-shared",
3680
  ]
@@ -3697,10 +3797,11 @@ dependencies = [
3697
 
3698
  [[package]]
3699
  name = "websurfx"
3700
- version = "0.19.0"
3701
  dependencies = [
3702
  "actix-cors",
3703
  "actix-files",
 
3704
  "actix-web",
3705
  "async-once-cell",
3706
  "async-trait",
 
9
  checksum = "617a8268e3537fe1d8c9ead925fca49ef6400927ee7bc26750e90ecee14ce4b8"
10
  dependencies = [
11
  "bitflags 1.3.2",
12
+ "bytes 1.5.0",
13
  "futures-core",
14
  "futures-sink",
15
  "memchr",
 
46
  "actix-web",
47
  "askama_escape",
48
  "bitflags 1.3.2",
49
+ "bytes 1.5.0",
50
  "derive_more",
51
  "futures-core",
52
  "http-range",
 
57
  "pin-project-lite",
58
  ]
59
 
60
+ [[package]]
61
+ name = "actix-governor"
62
+ version = "0.4.1"
63
+ source = "registry+https://github.com/rust-lang/crates.io-index"
64
+ checksum = "46ff2d40f2bc627b8054c5e20fa6b0b0cf9428699b54bd41634e9ae3098ad555"
65
+ dependencies = [
66
+ "actix-http",
67
+ "actix-web",
68
+ "futures 0.3.28",
69
+ "governor",
70
+ ]
71
+
72
  [[package]]
73
  name = "actix-http"
74
  version = "3.4.0"
 
80
  "actix-service",
81
  "actix-utils",
82
  "ahash",
83
+ "base64 0.21.4",
84
  "bitflags 2.4.0",
85
  "brotli",
86
+ "bytes 1.5.0",
87
  "bytestring",
88
  "derive_more",
89
  "encoding_rs",
 
115
  checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb"
116
  dependencies = [
117
  "quote 1.0.33",
118
+ "syn 2.0.32",
119
  ]
120
 
121
  [[package]]
 
195
  "actix-utils",
196
  "actix-web-codegen",
197
  "ahash",
198
+ "bytes 1.5.0",
199
  "bytestring",
200
  "cfg-if 1.0.0",
201
  "cookie 0.16.2",
 
228
  "actix-router",
229
  "proc-macro2 1.0.66",
230
  "quote 1.0.33",
231
+ "syn 2.0.32",
232
  ]
233
 
234
  [[package]]
 
290
 
291
  [[package]]
292
  name = "anstyle"
293
+ version = "1.0.3"
294
  source = "registry+https://github.com/rust-lang/crates.io-index"
295
+ checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46"
296
 
297
  [[package]]
298
  name = "anyhow"
 
326
  dependencies = [
327
  "proc-macro2 1.0.66",
328
  "quote 1.0.33",
329
+ "syn 2.0.32",
330
  ]
331
 
332
  [[package]]
 
370
 
371
  [[package]]
372
  name = "base64"
373
+ version = "0.21.4"
374
  source = "registry+https://github.com/rust-lang/crates.io-index"
375
+ checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2"
376
 
377
  [[package]]
378
  name = "bit-set"
 
465
 
466
  [[package]]
467
  name = "bytes"
468
+ version = "1.5.0"
469
  source = "registry+https://github.com/rust-lang/crates.io-index"
470
+ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
471
 
472
  [[package]]
473
  name = "bytestring"
 
475
  source = "registry+https://github.com/rust-lang/crates.io-index"
476
  checksum = "238e4886760d98c4f899360c834fa93e62cf7f721ac3c2da375cbdf4b8679aae"
477
  dependencies = [
478
+ "bytes 1.5.0",
479
  ]
480
 
481
  [[package]]
 
582
  source = "registry+https://github.com/rust-lang/crates.io-index"
583
  checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4"
584
  dependencies = [
585
+ "bytes 1.5.0",
586
  "futures-core",
587
  "memchr",
588
  "pin-project-lite",
 
602
  source = "registry+https://github.com/rust-lang/crates.io-index"
603
  checksum = "888604f00b3db336d2af898ec3c1d5d0ddf5e6d462220f2ededc33a87ac4bbd5"
604
  dependencies = [
605
+ "time 0.1.43",
606
  "url 1.7.2",
607
  ]
608
 
 
630
  "publicsuffix",
631
  "serde",
632
  "serde_json",
633
+ "time 0.1.43",
634
  "try_from",
635
  "url 1.7.2",
636
  ]
 
826
  checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"
827
  dependencies = [
828
  "quote 1.0.33",
829
+ "syn 2.0.32",
830
+ ]
831
+
832
+ [[package]]
833
+ name = "dashmap"
834
+ version = "5.5.3"
835
+ source = "registry+https://github.com/rust-lang/crates.io-index"
836
+ checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
837
+ dependencies = [
838
+ "cfg-if 1.0.0",
839
+ "hashbrown 0.14.0",
840
+ "lock_api 0.4.10",
841
+ "once_cell",
842
+ "parking_lot_core 0.9.8",
843
  ]
844
 
845
  [[package]]
 
975
 
976
  [[package]]
977
  name = "error-stack"
978
+ version = "0.4.1"
979
  source = "registry+https://github.com/rust-lang/crates.io-index"
980
+ checksum = "27a72baa257b5e0e2de241967bc5ee8f855d6072351042688621081d66b2a76b"
981
  dependencies = [
982
  "anyhow",
983
  "rustc_version 0.4.0",
 
1172
  dependencies = [
1173
  "proc-macro2 1.0.66",
1174
  "quote 1.0.33",
1175
+ "syn 2.0.32",
1176
  ]
1177
 
1178
  [[package]]
 
1187
  source = "registry+https://github.com/rust-lang/crates.io-index"
1188
  checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65"
1189
 
1190
+ [[package]]
1191
+ name = "futures-timer"
1192
+ version = "3.0.2"
1193
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1194
+ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c"
1195
+
1196
  [[package]]
1197
  name = "futures-util"
1198
  version = "0.3.28"
 
1256
  source = "registry+https://github.com/rust-lang/crates.io-index"
1257
  checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
1258
 
1259
+ [[package]]
1260
+ name = "governor"
1261
+ version = "0.5.1"
1262
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1263
+ checksum = "c390a940a5d157878dd057c78680a33ce3415bcd05b4799509ea44210914b4d5"
1264
+ dependencies = [
1265
+ "cfg-if 1.0.0",
1266
+ "dashmap",
1267
+ "futures 0.3.28",
1268
+ "futures-timer",
1269
+ "no-std-compat",
1270
+ "nonzero_ext",
1271
+ "parking_lot 0.12.1",
1272
+ "quanta",
1273
+ "rand 0.8.5",
1274
+ "smallvec 1.11.0",
1275
+ ]
1276
+
1277
  [[package]]
1278
  name = "h2"
1279
  version = "0.1.26"
 
1298
  source = "registry+https://github.com/rust-lang/crates.io-index"
1299
  checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833"
1300
  dependencies = [
1301
+ "bytes 1.5.0",
1302
  "fnv",
1303
  "futures-core",
1304
  "futures-sink",
 
1338
  source = "registry+https://github.com/rust-lang/crates.io-index"
1339
  checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
1340
 
1341
+ [[package]]
1342
+ name = "hashbrown"
1343
+ version = "0.14.0"
1344
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1345
+ checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
1346
+
1347
  [[package]]
1348
  name = "hermit-abi"
1349
  version = "0.3.2"
 
1395
  source = "registry+https://github.com/rust-lang/crates.io-index"
1396
  checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482"
1397
  dependencies = [
1398
+ "bytes 1.5.0",
1399
  "fnv",
1400
  "itoa 1.0.9",
1401
  ]
 
1418
  source = "registry+https://github.com/rust-lang/crates.io-index"
1419
  checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1"
1420
  dependencies = [
1421
+ "bytes 1.5.0",
1422
  "http 0.2.9",
1423
  "pin-project-lite",
1424
  ]
 
1465
  "log",
1466
  "net2",
1467
  "rustc_version 0.2.3",
1468
+ "time 0.1.43",
1469
  "tokio 0.1.22",
1470
  "tokio-buf",
1471
  "tokio-executor",
 
1483
  source = "registry+https://github.com/rust-lang/crates.io-index"
1484
  checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468"
1485
  dependencies = [
1486
+ "bytes 1.5.0",
1487
  "futures-channel",
1488
  "futures-core",
1489
  "futures-util",
 
1520
  source = "registry+https://github.com/rust-lang/crates.io-index"
1521
  checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
1522
  dependencies = [
1523
+ "bytes 1.5.0",
1524
  "hyper 0.14.27",
1525
  "native-tls",
1526
  "tokio 1.32.0",
 
1566
  checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
1567
  dependencies = [
1568
  "autocfg 1.1.0",
1569
+ "hashbrown 0.12.3",
1570
  ]
1571
 
1572
  [[package]]
 
1674
 
1675
  [[package]]
1676
  name = "linux-raw-sys"
1677
+ version = "0.4.7"
1678
  source = "registry+https://github.com/rust-lang/crates.io-index"
1679
+ checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128"
1680
 
1681
  [[package]]
1682
  name = "local-channel"
 
1727
  source = "registry+https://github.com/rust-lang/crates.io-index"
1728
  checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
1729
 
1730
+ [[package]]
1731
+ name = "mach"
1732
+ version = "0.3.2"
1733
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1734
+ checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa"
1735
+ dependencies = [
1736
+ "libc",
1737
+ ]
1738
+
1739
  [[package]]
1740
  name = "markup5ever"
1741
  version = "0.8.1"
 
1787
 
1788
  [[package]]
1789
  name = "memchr"
1790
+ version = "2.6.3"
1791
  source = "registry+https://github.com/rust-lang/crates.io-index"
1792
+ checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
1793
 
1794
  [[package]]
1795
  name = "memoffset"
 
1951
  source = "registry+https://github.com/rust-lang/crates.io-index"
1952
  checksum = "ab250442c86f1850815b5d268639dff018c0627022bc1940eb2d642ca1ce12f0"
1953
 
1954
+ [[package]]
1955
+ name = "no-std-compat"
1956
+ version = "0.4.1"
1957
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1958
+ checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c"
1959
+
1960
+ [[package]]
1961
+ name = "nonzero_ext"
1962
+ version = "0.3.0"
1963
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1964
+ checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21"
1965
+
1966
  [[package]]
1967
  name = "num-traits"
1968
  version = "0.2.16"
 
1984
 
1985
  [[package]]
1986
  name = "object"
1987
+ version = "0.32.1"
1988
  source = "registry+https://github.com/rust-lang/crates.io-index"
1989
+ checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
1990
  dependencies = [
1991
  "memchr",
1992
  ]
 
2026
  dependencies = [
2027
  "proc-macro2 1.0.66",
2028
  "quote 1.0.33",
2029
+ "syn 2.0.32",
2030
  ]
2031
 
2032
  [[package]]
 
2037
 
2038
  [[package]]
2039
  name = "openssl-sys"
2040
+ version = "0.9.93"
2041
  source = "registry+https://github.com/rust-lang/crates.io-index"
2042
+ checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d"
2043
  dependencies = [
2044
  "cc",
2045
  "libc",
 
2145
  "pest_meta",
2146
  "proc-macro2 1.0.66",
2147
  "quote 1.0.33",
2148
+ "syn 2.0.32",
2149
  ]
2150
 
2151
  [[package]]
 
2247
  "phf_shared 0.11.2",
2248
  "proc-macro2 1.0.66",
2249
  "quote 1.0.33",
2250
+ "syn 2.0.32",
2251
  ]
2252
 
2253
  [[package]]
 
2294
  dependencies = [
2295
  "proc-macro2 1.0.66",
2296
  "quote 1.0.33",
2297
+ "syn 2.0.32",
2298
  ]
2299
 
2300
  [[package]]
 
2383
  "url 2.4.1",
2384
  ]
2385
 
2386
+ [[package]]
2387
+ name = "quanta"
2388
+ version = "0.9.3"
2389
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2390
+ checksum = "20afe714292d5e879d8b12740aa223c6a88f118af41870e8b6196e39a02238a8"
2391
+ dependencies = [
2392
+ "crossbeam-utils 0.8.16",
2393
+ "libc",
2394
+ "mach",
2395
+ "once_cell",
2396
+ "raw-cpuid",
2397
+ "wasi 0.10.2+wasi-snapshot-preview1",
2398
+ "web-sys",
2399
+ "winapi 0.3.9",
2400
+ ]
2401
+
2402
  [[package]]
2403
  name = "quote"
2404
  version = "0.6.13"
 
2553
  "rand_core 0.3.1",
2554
  ]
2555
 
2556
+ [[package]]
2557
+ name = "raw-cpuid"
2558
+ version = "10.7.0"
2559
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2560
+ checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332"
2561
+ dependencies = [
2562
+ "bitflags 1.3.2",
2563
+ ]
2564
+
2565
  [[package]]
2566
  name = "rayon"
2567
  version = "1.7.0"
 
2601
  dependencies = [
2602
  "arc-swap",
2603
  "async-trait",
2604
+ "bytes 1.5.0",
2605
  "combine",
2606
  "futures 0.3.28",
2607
  "futures-util",
 
2634
 
2635
  [[package]]
2636
  name = "regex"
2637
+ version = "1.9.5"
2638
  source = "registry+https://github.com/rust-lang/crates.io-index"
2639
+ checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47"
2640
  dependencies = [
2641
  "aho-corasick",
2642
  "memchr",
 
2646
 
2647
  [[package]]
2648
  name = "regex-automata"
2649
+ version = "0.3.8"
2650
  source = "registry+https://github.com/rust-lang/crates.io-index"
2651
+ checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795"
2652
  dependencies = [
2653
  "aho-corasick",
2654
  "memchr",
 
2684
  "serde",
2685
  "serde_json",
2686
  "serde_urlencoded 0.5.5",
2687
+ "time 0.1.43",
2688
  "tokio 0.1.22",
2689
  "tokio-executor",
2690
  "tokio-io",
 
2701
  source = "registry+https://github.com/rust-lang/crates.io-index"
2702
  checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1"
2703
  dependencies = [
2704
+ "base64 0.21.4",
2705
+ "bytes 1.5.0",
2706
  "encoding_rs",
2707
  "futures-core",
2708
  "futures-util",
 
2764
 
2765
  [[package]]
2766
  name = "rustix"
2767
+ version = "0.38.13"
2768
  source = "registry+https://github.com/rust-lang/crates.io-index"
2769
+ checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662"
2770
  dependencies = [
2771
  "bitflags 2.4.0",
2772
  "errno",
 
2924
  dependencies = [
2925
  "proc-macro2 1.0.66",
2926
  "quote 1.0.33",
2927
+ "syn 2.0.32",
2928
  ]
2929
 
2930
  [[package]]
2931
  name = "serde_json"
2932
+ version = "1.0.106"
2933
  source = "registry+https://github.com/rust-lang/crates.io-index"
2934
+ checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2"
2935
  dependencies = [
2936
  "itoa 1.0.9",
2937
  "ryu",
 
3166
 
3167
  [[package]]
3168
  name = "syn"
3169
+ version = "2.0.32"
3170
  source = "registry+https://github.com/rust-lang/crates.io-index"
3171
+ checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2"
3172
  dependencies = [
3173
  "proc-macro2 1.0.66",
3174
  "quote 1.0.33",
 
3232
 
3233
  [[package]]
3234
  name = "thiserror"
3235
+ version = "1.0.48"
3236
  source = "registry+https://github.com/rust-lang/crates.io-index"
3237
+ checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7"
3238
  dependencies = [
3239
  "thiserror-impl",
3240
  ]
3241
 
3242
  [[package]]
3243
  name = "thiserror-impl"
3244
+ version = "1.0.48"
3245
  source = "registry+https://github.com/rust-lang/crates.io-index"
3246
+ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35"
3247
  dependencies = [
3248
  "proc-macro2 1.0.66",
3249
  "quote 1.0.33",
3250
+ "syn 2.0.32",
3251
  ]
3252
 
3253
  [[package]]
 
3258
 
3259
  [[package]]
3260
  name = "time"
3261
+ version = "0.1.43"
3262
  source = "registry+https://github.com/rust-lang/crates.io-index"
3263
+ checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438"
3264
  dependencies = [
3265
  "libc",
 
3266
  "winapi 0.3.9",
3267
  ]
3268
 
 
3345
  checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9"
3346
  dependencies = [
3347
  "backtrace",
3348
+ "bytes 1.5.0",
3349
  "libc",
3350
  "mio 0.8.8",
3351
  "num_cpus",
 
3407
  dependencies = [
3408
  "proc-macro2 1.0.66",
3409
  "quote 1.0.33",
3410
+ "syn 2.0.32",
3411
  ]
3412
 
3413
  [[package]]
 
3509
  source = "registry+https://github.com/rust-lang/crates.io-index"
3510
  checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d"
3511
  dependencies = [
3512
+ "bytes 1.5.0",
3513
  "futures-core",
3514
  "futures-sink",
3515
  "pin-project-lite",
 
3679
 
3680
  [[package]]
3681
  name = "walkdir"
3682
+ version = "2.4.0"
3683
  source = "registry+https://github.com/rust-lang/crates.io-index"
3684
+ checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
3685
  dependencies = [
3686
  "same-file",
3687
  "winapi-util",
 
3709
 
3710
  [[package]]
3711
  name = "wasi"
3712
+ version = "0.10.2+wasi-snapshot-preview1"
3713
  source = "registry+https://github.com/rust-lang/crates.io-index"
3714
+ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
3715
 
3716
  [[package]]
3717
  name = "wasi"
 
3740
  "once_cell",
3741
  "proc-macro2 1.0.66",
3742
  "quote 1.0.33",
3743
+ "syn 2.0.32",
3744
  "wasm-bindgen-shared",
3745
  ]
3746
 
 
3774
  dependencies = [
3775
  "proc-macro2 1.0.66",
3776
  "quote 1.0.33",
3777
+ "syn 2.0.32",
3778
  "wasm-bindgen-backend",
3779
  "wasm-bindgen-shared",
3780
  ]
 
3797
 
3798
  [[package]]
3799
  name = "websurfx"
3800
+ version = "0.20.0"
3801
  dependencies = [
3802
  "actix-cors",
3803
  "actix-files",
3804
+ "actix-governor",
3805
  "actix-web",
3806
  "async-once-cell",
3807
  "async-trait",
Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
  [package]
2
  name = "websurfx"
3
- version = "0.19.0"
4
  edition = "2021"
5
  description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind."
6
  repository = "https://github.com/neon-mmd/websurfx"
@@ -32,6 +32,7 @@ futures = {version="0.3.28"}
32
  dhat = {version="0.3.2", optional = true}
33
  mimalloc = { version = "0.1.38", default-features = false }
34
  async-once-cell = {version="0.5.3"}
 
35
 
36
  [dev-dependencies]
37
  rusty-hook = "^0.11.2"
 
1
  [package]
2
  name = "websurfx"
3
+ version = "0.20.0"
4
  edition = "2021"
5
  description = "An open-source alternative to Searx that provides clean, ad-free, and organic results with incredible speed while keeping privacy and security in mind."
6
  repository = "https://github.com/neon-mmd/websurfx"
 
32
  dhat = {version="0.3.2", optional = true}
33
  mimalloc = { version = "0.1.38", default-features = false }
34
  async-once-cell = {version="0.5.3"}
35
+ actix-governor = {version="0.4.1"}
36
 
37
  [dev-dependencies]
38
  rusty-hook = "^0.11.2"
src/config/parser.rs CHANGED
@@ -3,7 +3,7 @@
3
 
4
  use crate::handler::paths::{file_path, FileType};
5
 
6
- use super::parser_models::Style;
7
  use log::LevelFilter;
8
  use mlua::Lua;
9
  use std::{collections::HashMap, fs, thread::available_parallelism};
@@ -35,20 +35,10 @@ pub struct Config {
35
  pub upstream_search_engines: Vec<crate::engines::engine_models::EngineHandler>,
36
  pub request_timeout: u8,
37
  pub threads: u8,
 
38
  pub safe_search: u8,
39
  }
40
 
41
- /// Configuration options for the aggregator.
42
- ///
43
- /// # Fields
44
- ///
45
- /// * `random_delay` - It stores the option to whether enable or disable random delays between
46
- /// requests.
47
- #[derive(Clone)]
48
- pub struct AggregatorConfig {
49
- pub random_delay: bool,
50
- }
51
-
52
  impl Config {
53
  /// A function which parses the config.lua file and puts all the parsed options in the newly
54
  /// constructed Config struct and returns it.
@@ -90,6 +80,8 @@ impl Config {
90
  parsed_threads
91
  };
92
 
 
 
93
  let parsed_safe_search: u8 = globals.get::<_, u8>("safe_search")?;
94
  let safe_search: u8 = match parsed_safe_search {
95
  0..=4 => parsed_safe_search,
@@ -121,6 +113,10 @@ impl Config {
121
  .collect(),
122
  request_timeout: globals.get::<_, u8>("request_timeout")?,
123
  threads,
 
 
 
 
124
  safe_search,
125
  })
126
  }
 
3
 
4
  use crate::handler::paths::{file_path, FileType};
5
 
6
+ use super::parser_models::{AggregatorConfig, RateLimiter, Style};
7
  use log::LevelFilter;
8
  use mlua::Lua;
9
  use std::{collections::HashMap, fs, thread::available_parallelism};
 
35
  pub upstream_search_engines: Vec<crate::engines::engine_models::EngineHandler>,
36
  pub request_timeout: u8,
37
  pub threads: u8,
38
+ pub rate_limiter: RateLimiter,
39
  pub safe_search: u8,
40
  }
41
 
 
 
 
 
 
 
 
 
 
 
 
42
  impl Config {
43
  /// A function which parses the config.lua file and puts all the parsed options in the newly
44
  /// constructed Config struct and returns it.
 
80
  parsed_threads
81
  };
82
 
83
+ let rate_limiter = globals.get::<_, HashMap<String, u8>>("rate_limiter")?;
84
+
85
  let parsed_safe_search: u8 = globals.get::<_, u8>("safe_search")?;
86
  let safe_search: u8 = match parsed_safe_search {
87
  0..=4 => parsed_safe_search,
 
113
  .collect(),
114
  request_timeout: globals.get::<_, u8>("request_timeout")?,
115
  threads,
116
+ rate_limiter: RateLimiter {
117
+ number_of_requests: rate_limiter["number_of_requests"],
118
+ time_limit: rate_limiter["time_limit"],
119
+ },
120
  safe_search,
121
  })
122
  }
src/config/parser_models.rs CHANGED
@@ -36,3 +36,26 @@ impl Style {
36
  Style { theme, colorscheme }
37
  }
38
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  Style { theme, colorscheme }
37
  }
38
  }
39
+
40
+ /// Configuration options for the aggregator.
41
+ ///
42
+ /// # Fields
43
+ ///
44
+ /// * `random_delay` - It stores the option to whether enable or disable random delays between
45
+ /// requests.
46
+ #[derive(Clone)]
47
+ pub struct AggregatorConfig {
48
+ pub random_delay: bool,
49
+ }
50
+
51
+ /// Configuration options for the rate limiter middleware.
52
+ ///
53
+ /// # Fields
54
+ ///
55
+ /// * `number_of_requests` - The number of request that are allowed within a provided time limit.
56
+ /// * `time_limit` - The time limit in which the quantity of requests that should be accepted.
57
+ #[derive(Clone)]
58
+ pub struct RateLimiter {
59
+ pub number_of_requests: u8,
60
+ pub time_limit: u8,
61
+ }
src/lib.rs CHANGED
@@ -14,12 +14,8 @@ use crate::server::routes;
14
 
15
  use actix_cors::Cors;
16
  use actix_files as fs;
17
- use actix_web::{
18
- dev::Server,
19
- http::header,
20
- middleware::{Compress, Logger},
21
- web, App, HttpServer,
22
- };
23
  use config::parser::Config;
24
  use handlebars::Handlebars;
25
  use handler::paths::{file_path, FileType};
@@ -69,11 +65,17 @@ pub fn run(listener: TcpListener, config: Config) -> std::io::Result<Server> {
69
  ]);
70
 
71
  App::new()
 
72
  .app_data(handlebars_ref.clone())
73
  .app_data(web::Data::new(config.clone()))
74
  .wrap(cors)
75
- .wrap(Logger::default()) // added logging middleware for logging.
76
- .wrap(Compress::default()) // compress request headers to reduce memory usage.
 
 
 
 
 
77
  // Serve images and static files (css and js files).
78
  .service(
79
  fs::Files::new("/static", format!("{}/static", public_folder_path))
 
14
 
15
  use actix_cors::Cors;
16
  use actix_files as fs;
17
+ use actix_governor::{Governor, GovernorConfigBuilder};
18
+ use actix_web::{dev::Server, http::header, middleware::Logger, web, App, HttpServer};
 
 
 
 
19
  use config::parser::Config;
20
  use handlebars::Handlebars;
21
  use handler::paths::{file_path, FileType};
 
65
  ]);
66
 
67
  App::new()
68
+ .wrap(Logger::default()) // added logging middleware for logging.
69
  .app_data(handlebars_ref.clone())
70
  .app_data(web::Data::new(config.clone()))
71
  .wrap(cors)
72
+ .wrap(Governor::new(
73
+ &GovernorConfigBuilder::default()
74
+ .per_second(config.rate_limiter.time_limit as u64)
75
+ .burst_size(config.rate_limiter.number_of_requests as u32)
76
+ .finish()
77
+ .unwrap(),
78
+ ))
79
  // Serve images and static files (css and js files).
80
  .service(
81
  fs::Files::new("/static", format!("{}/static", public_folder_path))
websurfx/config.lua CHANGED
@@ -10,6 +10,10 @@ production_use = false -- whether to use production mode or not (in other words
10
  -- if production_use is set to true
11
  -- There will be a random delay before sending the request to the search engines, this is to prevent DDoSing the upstream search engines from a large number of simultaneous requests.
12
  request_timeout = 30 -- timeout for the search requests sent to the upstream search engines to be fetched (value in seconds).
 
 
 
 
13
 
14
  -- ### Search ###
15
  -- Filter results based on different levels. The levels provided are:
@@ -45,4 +49,7 @@ theme = "simple" -- the theme name which should be used for the website
45
  redis_url = "redis://127.0.0.1:8082" -- redis connection url address on which the client should connect on.
46
 
47
  -- ### Search Engines ###
48
- upstream_search_engines = { DuckDuckGo = true, Searx = false } -- select the upstream search engines from which the results should be fetched.
 
 
 
 
10
  -- if production_use is set to true
11
  -- There will be a random delay before sending the request to the search engines, this is to prevent DDoSing the upstream search engines from a large number of simultaneous requests.
12
  request_timeout = 30 -- timeout for the search requests sent to the upstream search engines to be fetched (value in seconds).
13
+ rate_limiter = {
14
+ number_of_requests = 20, -- The number of request that are allowed within a provided time limit.
15
+ time_limit = 3, -- The time limit in which the quantity of requests that should be accepted.
16
+ }
17
 
18
  -- ### Search ###
19
  -- Filter results based on different levels. The levels provided are:
 
49
  redis_url = "redis://127.0.0.1:8082" -- redis connection url address on which the client should connect on.
50
 
51
  -- ### Search Engines ###
52
+ upstream_search_engines = {
53
+ DuckDuckGo = true,
54
+ Searx = false,
55
+ } -- select the upstream search engines from which the results should be fetched.