Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion destinations.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ func NewHTTPProxyDestination(dst *Destination, dstURL *url.URL, cfg *tls.Config,

func (d *HTTPDestination) Run(ctx context.Context) error {
srv := &http.Server{
Handler: d.handler,
Handler: d.handler,
ReadHeaderTimeout: 30 * time.Second,
IdleTimeout: 120 * time.Second,
}

go func() {
Expand Down
5 changes: 4 additions & 1 deletion pkg/statusc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import (
"fmt"
"net"
"net/http"
"time"

"github.com/connet-dev/connet/pkg/slogc"
)

func Run[T any](ctx context.Context, addr *net.TCPAddr, f func(ctx context.Context) (T, error)) error {
srv := &http.Server{
Addr: addr.String(),
Addr: addr.String(),
ReadHeaderTimeout: 10 * time.Second,
IdleTimeout: 120 * time.Second,
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
stat, err := f(r.Context())
if err == nil {
Expand Down
15 changes: 10 additions & 5 deletions sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/http"
"net/http/httputil"
"net/url"
"time"

"github.com/connet-dev/connet/model"
"github.com/connet-dev/connet/pkg/netc"
Expand Down Expand Up @@ -166,8 +167,10 @@ func (s *HTTPSource) Run(ctx context.Context) error {
targetURL.Host = endpoint

srv := &http.Server{
Addr: s.srcURL.Host,
TLSConfig: s.cfg,
Addr: s.srcURL.Host,
TLSConfig: s.cfg,
ReadHeaderTimeout: 10 * time.Second,
IdleTimeout: 120 * time.Second,
Handler: &httputil.ReverseProxy{
Rewrite: func(pr *httputil.ProxyRequest) {
pr.SetURL(&targetURL)
Expand Down Expand Up @@ -259,9 +262,11 @@ func (s *WSSource) Run(ctx context.Context) error {
mux.HandleFunc(path, s.handle)

srv := &http.Server{
Addr: s.srcURL.Host,
TLSConfig: s.cfg,
Handler: mux,
Addr: s.srcURL.Host,
TLSConfig: s.cfg,
ReadHeaderTimeout: 10 * time.Second,
IdleTimeout: 120 * time.Second,
Handler: mux,
}

go func() {
Expand Down