-
Notifications
You must be signed in to change notification settings - Fork 0
/
kcp_impl.go
38 lines (30 loc) · 972 Bytes
/
kcp_impl.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
//go:build !ios
package chained
import (
"context"
"net"
"github.com/getlantern/common/config"
"github.com/getlantern/errors"
"github.com/getlantern/kcpwrapper"
"github.com/getlantern/flashlight/v7/ops"
)
// KCPConfig adapts kcpwrapper.DialerConfig to the currently deployed
// configurations in order to provide backward-compatibility.
type KCPConfig struct {
kcpwrapper.DialerConfig `mapstructure:",squash"`
RemoteAddr string `json:"remoteaddr"`
}
type kcpImpl struct {
nopCloser
reportDialCore reportDialCoreFn
addr string
dialKCP func(ctx context.Context, addr string) (net.Conn, error)
}
func newKCPImpl(pc *config.ProxyConfig, reportDialCore reportDialCoreFn) (proxyImpl, error) {
return nil, errors.New("KCP not supported")
}
func (impl *kcpImpl) dialServer(op *ops.Op, ctx context.Context) (net.Conn, error) {
return impl.reportDialCore(op, func() (net.Conn, error) {
return impl.dialKCP(ctx, impl.addr)
})
}