mirror of
https://github.com/openziti/zrok.git
synced 2024-11-22 08:03:49 +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{
|
return &Backend{
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
listener: listener,
|
listener: listener,
|
||||||
server: &Server{},
|
server: &Server{Requests: cfg.Requests},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/openziti/zrok/endpoints"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
@ -86,6 +87,9 @@ type Server struct {
|
|||||||
// Username and Password, if set, are the credential clients must provide.
|
// Username and Password, if set, are the credential clients must provide.
|
||||||
Username string
|
Username string
|
||||||
Password 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) {
|
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
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
srv, err := c.srv.dial(
|
srv, err := c.srv.dial(
|
||||||
|
Loading…
Reference in New Issue
Block a user