Skip to content

Commit de0b86c

Browse files
committed
dialers,ipn: impl Handle()
1 parent b9055f2 commit de0b86c

File tree

10 files changed

+57
-5
lines changed

10 files changed

+57
-5
lines changed

intra/ipn/auto.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ func NewAutoProxy(ctx context.Context, pxr Proxies) *auto {
5555
return h
5656
}
5757

58+
// Handle implements Proxy.
59+
func (h *auto) Handle() uintptr {
60+
return core.Loc(h)
61+
}
62+
5863
// Dial implements Proxy.
5964
func (h *auto) Dial(network, addr string) (protect.Conn, error) {
6065
if h.status.Load() == END {

intra/ipn/base.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ func NewBaseProxy(c protect.Controller) *base {
3737
return h
3838
}
3939

40+
// Handle implements Proxy.
41+
func (h *base) Handle() uintptr {
42+
return core.Loc(h)
43+
}
44+
4045
// Dial implements the Proxy interface.
4146
func (h *base) Dial(network, addr string) (c protect.Conn, err error) {
4247
if h.status.Load() == END {

intra/ipn/exit.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ func NewExitProxy(c protect.Controller) *exit {
3535
return h
3636
}
3737

38+
// Handle implements Proxy.
39+
func (h *exit) Handle() uintptr {
40+
return core.Loc(h)
41+
}
42+
3843
// Dial implements Proxy.
3944
func (h *exit) Dial(network, addr string) (protect.Conn, error) {
4045
if h.status.Load() == END {

intra/ipn/ground.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package ipn
88

99
import (
1010
x "github.com/celzero/firestack/intra/backend"
11+
"github.com/celzero/firestack/intra/core"
1112
"github.com/celzero/firestack/intra/protect"
1213
)
1314

@@ -30,6 +31,11 @@ func NewGroundProxy() *ground {
3031
return h
3132
}
3233

34+
// Handle implements Proxy.
35+
func (h *ground) Handle() uintptr {
36+
return core.Loc(h)
37+
}
38+
3339
// Dial implements Proxy.
3440
func (h *ground) Dial(network, addr string) (protect.Conn, error) {
3541
return nil, errNoProxyResponse

intra/ipn/http1.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ func NewHTTPProxy(id string, c protect.Controller, po *settings.ProxyOptions) (*
7575
return h, nil
7676
}
7777

78+
// Handle implements Proxy.
79+
func (h *http1) Handle() uintptr {
80+
return core.Loc(h)
81+
}
82+
7883
// Dial implements Proxy.
7984
func (h *http1) Dial(network, addr string) (c protect.Conn, err error) {
8085
if h.status.Load() == END {

intra/ipn/piph2.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ func (t *piph2) claim(msg string) []string {
280280
return []string{t.token, byte2hex(msgmac)}
281281
}
282282

283+
// Handle implements Proxy.
284+
func (h *piph2) Handle() uintptr {
285+
return core.Loc(h)
286+
}
287+
283288
// Dial implements Proxy.
284289
func (t *piph2) Dial(network, addr string) (protect.Conn, error) {
285290
if t.status.Load() == END {

intra/ipn/pipws.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ func (t *pipws) claim(msg string) []string {
267267
return []string{t.token, byte2hex(msgmac)}
268268
}
269269

270+
// Handle implements Proxy.
271+
func (t *pipws) Handle() uintptr {
272+
return core.Loc(t)
273+
}
274+
270275
// Dial connects to addr via wsconn over this ws proxy
271276
func (t *pipws) Dial(network, addr string) (protect.Conn, error) {
272277
if t.status.Load() == END {
@@ -319,16 +324,16 @@ func (t *pipws) Dial(network, addr string) (protect.Conn, error) {
319324
return c, nil
320325
}
321326

322-
func (h *pipws) Dialer() protect.RDialer {
323-
return h
327+
func (t *pipws) Dialer() protect.RDialer {
328+
return t
324329
}
325330

326-
func (h *pipws) DNS() string {
331+
func (*pipws) DNS() string {
327332
return nodns
328333
}
329334

330-
func (h *pipws) ech() []byte {
331-
name := h.hostname
335+
func (t *pipws) ech() []byte {
336+
name := t.hostname
332337
if len(name) <= 0 {
333338
return nil
334339
} else if v, err := dialers.ECH(name); err != nil {

intra/ipn/socks5.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ func NewSocks5Proxy(id string, ctl protect.Controller, po *settings.ProxyOptions
142142
return h, nil
143143
}
144144

145+
// Handle implements Proxy.
146+
func (h *socks5) Handle() uintptr {
147+
return core.Loc(h)
148+
}
149+
145150
// Dial implements Proxy.
146151
func (h *socks5) Dial(network, addr string) (c protect.Conn, err error) {
147152
if h.status == END {

intra/ipn/wgproxy.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ type WgProxy interface {
122122
IpcSet(txt string) error
123123
}
124124

125+
// Handle implements Proxy.
126+
func (h *wgproxy) Handle() uintptr {
127+
return core.Loc(h)
128+
}
129+
125130
// Dial implements WgProxy
126131
func (h *wgproxy) Dial(network, address string) (c protect.Conn, err error) {
127132
// ProxyDial resolves address if needed; then dials into all resolved ips.

intra/protect/xdial.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type Listener = net.Listener
2828
type DialFn func(network, addr string) (net.Conn, error)
2929

3030
type RDialer interface {
31+
// Handle uniquely identifies the concrete type backing this dialer.
32+
Handle() uintptr
3133
// Dial creates a connection to the given address,
3234
// the resulting net.Conn must be a *net.TCPConn if
3335
// network is "tcp" or "tcp4" or "tcp6" and must be
@@ -74,6 +76,10 @@ var (
7476
errAccept = errors.New("cannot accept network")
7577
)
7678

79+
func (d *RDial) Handle() uintptr {
80+
return core.Loc(d)
81+
}
82+
7783
func (d *RDial) dial(network, addr string) (net.Conn, error) {
7884
usedialer := d.dialer != nil
7985
usedelegate := d.delegate != nil && core.IsNotNil(d.delegate)

0 commit comments

Comments
 (0)