mirror of
https://github.com/openziti/zrok.git
synced 2024-11-07 08:44:14 +01:00
support for request logging in the socks implementation (#558)
This commit is contained in:
parent
3afbb6dc9a
commit
7380a907d2
@ -41,7 +41,7 @@ func NewBackend(cfg *BackendConfig) (*Backend, error) {
|
||||
return &Backend{
|
||||
cfg: cfg,
|
||||
listener: listener,
|
||||
server: &Server{},
|
||||
server: &Server{Requests: cfg.Requests},
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"github.com/openziti/zrok/endpoints"
|
||||
"github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net"
|
||||
@ -86,6 +87,9 @@ type Server struct {
|
||||
// Username and Password, if set, are the credential clients must provide.
|
||||
Username string
|
||||
Password string
|
||||
|
||||
// For notifying user-facing components about activity
|
||||
Requests chan *endpoints.Request
|
||||
}
|
||||
|
||||
func (s *Server) dial(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
@ -171,6 +175,14 @@ func (c *Conn) handleRequest() error {
|
||||
}
|
||||
c.request = req
|
||||
|
||||
if c.srv.Requests != nil {
|
||||
c.srv.Requests <- &endpoints.Request{
|
||||
Stamp: time.Now(),
|
||||
Method: "CONNECT",
|
||||
Path: fmt.Sprintf("%v:%d", c.request.destination, c.request.port),
|
||||
}
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
srv, err := c.srv.dial(
|
||||
|
Loading…
Reference in New Issue
Block a user