Files
orly/cmd/lerproxy/timeout/conn.go
mleku a51e86f4c4 update: reorganize imports, add URL rewriting support, and minor refactoring
- cmd/lerproxy/reverse/proxy.go
  - Reorganized imports for logical grouping.

- cmd/lerproxy/main.go
  - Added URL rewriting capability and updated command-line usage documentation.
  - Reorganized imports for consistency.
  - Replaced `context.T` with `context.Context` for standardization.
  - Updated timeout handling logic to use `context.WithTimeout`.

- pkg/protocol/ws/connection.go
  - Replaced `fmt.Errorf` with `errorf.E` for error formatting.

- cmd/lerproxy/util/util.go
  - Renamed file for better clarity.
  - Removed unnecessary package documentation.

- cmd/lerproxy/hsts/proxy.go
  - Removed redundant package comments.

- cmd/lerproxy/tcpkeepalive/listener.go
  - Removed redundant package comments.
  - Adjusted import order.

- cmd/lerproxy/buf/bufpool.go
  - Removed unnecessary package comments.

- cmd/lerproxy/README.md
  - Updated package usage examples and installation instructions.
  - Removed outdated and unnecessary instructions.
2025-08-18 20:13:14 +01:00

32 lines
587 B
Go

package timeout
import (
"net"
"orly.dev/pkg/utils/chk"
"time"
)
// Conn extends deadline after successful read or write operations
type Conn struct {
time.Duration
*net.TCPConn
}
func (c Conn) Read(b []byte) (n int, e error) {
if n, e = c.TCPConn.Read(b); !chk.E(e) {
if e = c.SetDeadline(c.getTimeout()); chk.E(e) {
}
}
return
}
func (c Conn) Write(b []byte) (n int, e error) {
if n, e = c.TCPConn.Write(b); !chk.E(e) {
if e = c.SetDeadline(c.getTimeout()); chk.E(e) {
}
}
return
}
func (c Conn) getTimeout() (t time.Time) { return time.Now().Add(c.Duration) }