Commit Graph

1655 Commits

Author SHA1 Message Date
Oleksandr Redko a537e47bfb Remove unnecessary build tag go1.21 (#1721) 2024-02-21 05:49:39 +01:00
gilwo aefd080674 adaptor ResponseWriter - adding Hijack method and pass proper fields (#1525)
* adding hijack method and pass proper fields

* adding hijack method and pass proper fields - adding tests

* improve hijack handling, use proper test for hijacking

* extend hijackhandler propogation to NewFastHTTPHandlerFunc

* align hijacking of fasthttp adaptor net request with fasthttp request, safe conn handling for proper release of resources and custom hijack handler for more controlled by hijacking implementation

* Implement actual behaviour of net/http Hijacker

---------

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2024-02-17 14:51:38 +08:00
dependabot[bot] 56cb753ff9 chore(deps): bump securego/gosec from 2.18.2 to 2.19.0 (#1720)
Bumps [securego/gosec](https://github.com/securego/gosec) from 2.18.2 to 2.19.0.
- [Release notes](https://github.com/securego/gosec/releases)
- [Changelog](https://github.com/securego/gosec/blob/master/.goreleaser.yml)
- [Commits](https://github.com/securego/gosec/compare/v2.18.2...v2.19.0)

---
updated-dependencies:
- dependency-name: securego/gosec
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-13 14:22:22 +08:00
Erik Dubbelboer bce576699a Prevent request smuggling (#1719)
* Prevent request smuggling

Prevent request smuggling when fasthttp is behind a reverse proxy that
might interprets headers differently by being stricter. Should also
prevent request smuggling when fasthttp is used as the reverse proxy.

* Make header value comparison case-insensitive
v1.52.0
2024-02-11 08:08:56 +01:00
Erik Dubbelboer 3327266342 Follow RFCs 7230 and 9112 for HTTP versions (#1710)
Require that HTTP versions match the following pattern: HTTP/[0-9]\.[0-9]
2024-02-11 07:55:31 +01:00
Erik Dubbelboer a8cb5d535f Bump dependencies (#1718) 2024-02-10 11:04:07 +01:00
Erik Dubbelboer 82bc7c48bd bump securego/gosec from 2.17.0 to 2.18.2 2024-02-10 10:45:52 +01:00
dependabot[bot] 20c2c4832e chore(deps): bump golangci/golangci-lint-action from 3 to 4 (#1711)
Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3 to 4.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-02-10 10:43:32 +01:00
Juan Calderon-Perez 9fa5688b68 Update all github actions, add go1.22 (#1707) 2024-02-10 10:32:59 +01:00
mopeneko b430b88e78 Implement GetRejectedConnectionsCount function (#1704)
* Implement `GetRejectedConnectionsCount`

* Implement test for `GetRejectedConnectionsCount`
2024-02-10 10:26:36 +01:00
Zhengkai Wang dfb7e62a3d add DisableDNSResolution for TCPDialer. Sometimes, users do not need to use DNS resolution because they have already determined that the requested address is a list of IP addresses. (#1702)
Co-authored-by: wangzhengkai.wzk <wangzhengkai.wzk@alibaba-inc.com>
2024-02-10 10:00:01 +01:00
Erik Dubbelboer 48dd2d0ce7 Try fixing oss-fuzz running out of memory and skipping a lot 2024-01-30 08:01:06 +01:00
Erik Dubbelboer 287e3616ba Make Fuzz tests deterministic
From the Go docs:
- Fuzz targets should be fast and deterministic so the fuzzing engine can work efficiently, and new failures and code coverage can be easily reproduced.
- Since the fuzz target is invoked in parallel across multiple workers and in nondeterministic order, the state of a fuzz target should not persist past the end of each call, and the behavior of a fuzz target should not depend on global state.
2024-01-20 05:10:41 +01:00
tyltr dd1f3b97e5 update build tag (#1695)
* update  go.sum

* update build tag
2024-01-18 04:41:42 +01:00
Erik Dubbelboer c205a253b4 Put a limit on the max body size for fuzzing 2024-01-16 05:07:21 +01:00
Erik Dubbelboer 435faf8698 Bump supported Go version in readme (#1690) 2024-01-14 02:46:41 +01:00
Erik Dubbelboer a04cd8c39f Move Fuzz tests into their own file
This is required for https://github.com/google/oss-fuzz/pull/11453
2024-01-09 13:01:31 +01:00
nickajacks1 2accefa5cb refactor: move manually created tchar table to bytesconv_table_gen (#1689) 2024-01-07 08:27:45 +01:00
AdamKorcz dbca6b454d Add CIFuzz (#1443)
Adds a workflow to run fasthttp's fuzzers in the CI.
2024-01-07 07:55:01 +01:00
nickajacks1 f0905a14d1 test: migrate remaining fuzzit tests to go 1.18 fuzzing (#1687) 2024-01-06 13:39:23 +08:00
nickajacks1 08c8d32471 test(expvarhandler): fix failure when using -count to run more than once (#1688) 2024-01-06 13:35:20 +08:00
Oleksandr Redko 28615eba55 Change empty string checks to be more idiomatic (#1684) 2024-01-04 15:05:38 +01:00
nickajacks1 fec7681cdb chore: move cookie fuzz test to go 1.18 fuzzing (#1686) 2024-01-04 15:04:50 +01:00
nickajacks1 868ee455d5 feat: add function to parse HTTP header parameters (#1685)
* feat: add function to parse HTTP header parameters

The implementation is based on RFC-9110 5.6.6.

* test: add fuzz for VisitHeaderParams
2024-01-02 09:43:40 +01:00
dependabot[bot] 9ba16466df chore(deps): bump golang.org/x/crypto from 0.14.0 to 0.17.0 (#1678)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.14.0 to 0.17.0.
- [Commits](https://github.com/golang/crypto/compare/v0.14.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-19 09:33:54 +08:00
Oleksandr Redko 9d6b470260 chore: Add missing dots at the end of comments (#1677) 2023-12-13 13:56:24 +08:00
Oleksandr Redko 12949de784 chore: Set max line length to 130 characters (#1676) 2023-12-05 19:49:41 +01:00
Jille Timmermans 0caa3b9bc1 writeBodyFixedSize: Only do an early flush if the reader is an *os.File (#1674)
or an *io.LimitedReader of an *os.File (because that's also supported by
https://cs.opensource.google/go/go/+/refs/tags/go1.21.4:src/bufio/bufio.go;l=784)

I think that having to flush less often outweighs the overhead of the
extra check. The appended data is known to be large, but it might still
save us a syscall by allowing it to buffer more.
2023-12-02 18:59:46 +01:00
Jille Timmermans 2ac2a3911b copyZeroAlloc: Try WriteTo and ReadFrom before acquiring a buffer (#1673)
These are the same statements at the beginning of io.CopyBuffer, but
by doing them ourselves first we trade off a little cpu for not holding
the 4kb buffer during the write.
2023-12-02 18:05:12 +01:00
Jille Timmermans 9b4e42affa bug: Flush the write buffer before putting it to the pool (#1672)
A few lines later we check if `s.ReduceMemoryUsage && hijackHandler == nil`
and call releaseWriter. We need to flush the buffer before returning it
to the pool to avoid the data getting lost.
2023-12-02 18:04:12 +01:00
Aviv Carmi 8ca7a9c89c add support for custom dial function with timeouts (#1669)
* add support for custom dial function with timeouts

* fix linting

---------

Co-authored-by: Aviv Carmi <aviv@perimeterx.com>
2023-11-27 13:46:43 +01:00
Oleksandr Redko f196617f55 chore: Use 'any' instead of 'interface{}' (#1666)
gofmt -w -r "interface{} -> any" -l .
2023-11-24 11:33:04 +01:00
Oleksandr Redko d3397c64ed Enable wastedassign, whitespace linters; fix issues (#1665) 2023-11-24 11:32:11 +01:00
Oleksandr Redko 8ecfc989d9 Enable dupword, unconvert linters (#1658) v1.51.0 2023-11-12 16:42:39 +01:00
Gusted 1834cecd7e Lazy load stackless functions (#1656)
- I noticed that fasthttp was taking up 1.8MB of heap memory, even
though it wasn't being used. This turned out to be the stackless
function: 1.80MB  github.com/valyala/fasthttp/stackless.NewFunc
- Lazy load the stackless functions with sync.Once, given this a simple
atomic read, it shouldn't affect performance for the fast-path (I
haven't seen benchmarks with compression enabled).
2023-11-12 16:36:57 +01:00
Erik Dubbelboer 3267649442 Fix spelling mistake
Fixes #1654
2023-11-10 11:33:33 +01:00
Oleksandr Redko 1242d8af15 chore: add golangci-lint config file for flexibility (#1649)
* chore: add golangci-lint config file for flexibility

https://golangci-lint.run/usage/configuration/#config-file

* chore: add golangci-lint config file for flexibility
2023-11-09 16:30:33 +01:00
Oleksandr Redko 7bd632cbde chore: Remove redundant build constraint (#1650) 2023-11-08 23:18:13 +01:00
Oleksandr Redko 4434c99758 chore: Rename coarseTime.go to coarsetime.go (#1651) 2023-11-08 23:13:59 +01:00
Tiago Peczenyj dfce853067 Skip fs cache based on config (#1644)
* add cache manager struce

* refactor cache by adding interface

* generalize ctor

* implement feature add unit tests

* fix code

* rename fs field as filesystem
2023-11-05 19:31:04 +01:00
Erik Dubbelboer 3ead307ea9 Don't fast fail when one test fails (#1645) 2023-11-05 19:25:59 +01:00
Tiago Peczenyj 5575d272de add support to go 1.21.x into test.yml (#1642)
* Update test.yml

add go 1.21.x into matrix go-version

* Drop support of go1.17 in test.yml
2023-11-05 19:10:02 +01:00
Tiago Peczenyj deda595822 fix benchmark panics on client_timing_test.go (#1643)
* Update client_timing_test.go

fix benchmark panics

* must gofumpt
2023-11-05 14:48:00 +01:00
Tiago Peczenyj 4010b16eef Add support to fs.fs on serve static files (#1640)
* substitute *os.File by fs.File

* refactor error handling by using the new recommended form

* finish implementation

* substitute seek(offset,0) by seek(offset, io.SeekStart)

* add unit test

* use io.SeekStart on Seek method
2023-11-05 14:46:42 +01:00
Scott Kidder 42bd7bb7e2 Allow redirect URI path to not be normalized. (#1638)
* Allow redirect URI path to not be normalized.

* Introduce DisableRedirectPathNormalizing field to Request

* Use field name as start of comment.

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

---------

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
2023-10-30 19:08:51 +01:00
chenyunfei 772e4aadb7 BUGFIX: HostClient.DialDualStack not work when using DoDeadline (#1634)
Co-authored-by: chenyunfei.cs <chenyunfei.cs@bytedance.com>
2023-10-21 12:38:07 +02:00
Erik Dubbelboer 24acb80b92 Update dependencies 2023-10-12 19:50:52 +02:00
Alexander Kolesov c6a17b9a57 Don't put hijackConn structure back to the pool on Close if KeepHijackedConns is enabled. (#1629) 2023-10-06 21:34:33 +02:00
xiluoxi 497922a21e reset request disableSpecialHeader (#1626) 2023-09-22 14:21:18 +02:00
Oleksandr Redko a5301d9edc Replace path.Join with filepath.Join in tests (#1623) 2023-09-18 20:13:37 +02:00