Documentation ¶
Overview ¶
Package tunnel provides functionality for creating HTTP tunnels and reverse proxies with teler WAF capabilities.
The main components of this package include the Tunnel type, which represents a tunneling configuration, and related functions and methods for tunnel setup and HTTP request handling.
To create a new tunnel, use the NewTunnel function, specifying the local port, destination address, and optional configuration parameters. The Tunnel type also provides the Tunnel.ServeHTTP method for handling incoming HTTP requests and proxying them to the destination, analyzing the incoming HTTP request from threats using the teler.Teler middleware.
Additional configuration options can be loaded from YAML or JSON files, allowing for customizing the teler WAF behavior.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tunnel ¶
type Tunnel struct { *httputil.ReverseProxy *teler.Teler Options teler.Options }
func NewTunnel ¶
NewTunnel creates a new Tunnel instance for proxying HTTP traffic.
Parameters:
- `port`: The local port on which the tunnel will listen for incoming requests.
- `dest`: The destination address to which incoming requests will be forwarded.
- `cfgPath`: The path to a configuration file for additional tunnel options.
- `optFormat`: The format of the configuration file ("yaml" or "json").
- `writer`: An optional io.Writer where tunnel log output will be written. Pass nil to use default teler logging only.
Please be aware that when you pass a custom `writer`, the teler.Options.NoStderr option value will be forcibly set to `true`, regardless of the `no_stderr` value that might be loaded from additional configuration options.
func (*Tunnel) ServeHTTP ¶
func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP is a method of the Tunnel type, which allows the Tunnel to implement the http.Handler interface.
This method forwards the incoming HTTP request to the httputil.ReverseProxy.ServeHTTP method, while also analyzing the incoming HTTP request from threats using the teler.Teler middleware.