-
Notifications
You must be signed in to change notification settings - Fork 60
/
common.go
42 lines (35 loc) · 1.21 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
36
37
38
39
40
41
42
package config
type commonOpts struct {
// Restrictions placed on the origin of incoming connections to the edge.
CIDRRestrictions *cidrRestrictions
// The version of PROXY protocol to use with this tunnel, zero if not
// using.
ProxyProto ProxyProtoVersion
// Tunnel-specific opaque metadata. Viewable via the API.
Metadata string
// Tunnel backend metadata. Viewable via the dashboard and API, but has no
// bearing on tunnel behavior.
// If not set, defaults to a URI in the format `app://hostname/path/to/executable?pid=12345`
ForwardsTo string
// The protocol that's forwarded from the ngrok edge.
// Currently only relevant for HTTP/1.1 vs HTTP/2, since there's a potential
// change-of-protocol happening at our edge.
ForwardsProto string
// Policy that define rules that should be applied to incoming or outgoing
// connections to the edge.
Policy *policy
}
type CommonOptionsFunc func(cfg *commonOpts)
type CommonOption interface {
ApplyCommon(cfg *commonOpts)
}
func (of CommonOptionsFunc) ApplyCommon(cfg *commonOpts) {
of(cfg)
}
func (cfg *commonOpts) getForwardsTo() string {
if cfg.ForwardsTo == "" {
return defaultForwardsTo()
}
return cfg.ForwardsTo
}
func (cfg *commonOpts) tunnelOptions() {}