Skip to content

Commit 7f7603d

Browse files
committed
Added support for PROXYLESS env var
1 parent c4298f4 commit 7f7603d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

common/lanternconfig.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@ const (
1515

1616
// TrackingID is the Google Analytics tracking ID.
1717
TrackingID = "UA-21815217-12"
18+
19+
PROXYLESS = "proxyless"
1820
)
1921

2022
var transports = loadTransports()
23+
var proxyless = true
2124

2225
func loadTransports() []string {
26+
proxylessEnv := os.Getenv("PROXYLESS")
27+
if proxylessEnv == "false" {
28+
proxyless = false
29+
}
2330
env := os.Getenv("LANTERN_TRANSPORTS")
2431
if env == "" {
2532
return []string{}
@@ -35,5 +42,9 @@ func loadTransports() []string {
3542
// specified transport is supported. If there is no LANTERN_TRANSPORTS environment variable defined,
3643
// all transports are supported.
3744
func SupportsTransport(transport string) bool {
38-
return len(transports) == 0 || slices.Contains(transports, transport)
45+
return slices.Contains(transports, transport) || len(transports) == 0
46+
}
47+
48+
func SupportsProxyless() bool {
49+
return proxyless
3950
}

dialer/parallel_dialer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func newParallelPreferProxyless(proxyless proxyless, d Dialer, opts *Options) Di
2323
}
2424

2525
func (d *parallelDialer) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
26-
if !common.SupportsTransport("proxyless") {
26+
if !common.SupportsProxyless() {
2727
log.Debugf("Proxyless transport not supported, falling back to default dialer for %s", addr)
2828
// If the proxyless transport is not supported, we fall back to the default dialer.
2929
return d.dialer.DialContext(ctx, network, addr)

0 commit comments

Comments
 (0)