-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.go
35 lines (28 loc) · 1.14 KB
/
common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// package proxy provides the implementations of the client and server proxies
package proxy
import (
"crypto/tls"
"net/http"
"time"
"github.com/davecgh/go-spew/spew"
"github.com/getlantern/golog"
)
var (
log = golog.LoggerFor("flashlight.proxy")
)
// ProxyConfig encapsulates common proxy configuration
type ProxyConfig struct {
ShouldDumpHeaders bool // whether or not to dump headers of requests and responses
Addr string // listen address in form of host:port
ReadTimeout time.Duration // (optional) timeout for read ops
WriteTimeout time.Duration // (optional) timeout for write ops
TLSConfig *tls.Config // (optional) TLS configuration for inbound connections, if nil then DEFAULT_TLS_SERVER_CONFIG is used
}
const (
X_LANTERN_PUBLIC_IP = "X-LANTERN-PUBLIC-IP" // Client's public IP as seen by the proxy
HR = "--------------------------------------------------------------------------------"
)
// DumpHeaders logs the given headers (request or response).
func DumpHeaders(category string, headers *http.Header) {
log.Debugf("%s Headers\n%s\n%s\n%s\n\n", category, HR, spew.Sdump(headers), HR)
}