From d7124d42a6a370b4906a09ca4a75c4d3f9e31fad Mon Sep 17 00:00:00 2001 From: Murtaza Aliakbar Date: Wed, 4 Oct 2023 21:28:03 +0530 Subject: [PATCH] split: m rename fns --- intra/doh/doh.go | 2 +- intra/ipn/piph2.go | 2 +- intra/ipn/pipws.go | 2 +- intra/split/redial.go | 20 ++++++++++---------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/intra/doh/doh.go b/intra/doh/doh.go index 3bf27e47..d6796b9e 100644 --- a/intra/doh/doh.go +++ b/intra/doh/doh.go @@ -86,7 +86,7 @@ type transport struct { var _ dnsx.Transport = (*transport)(nil) func (t *transport) dial(network, addr string) (net.Conn, error) { - return split.ReDial(t.dialer, network, addr) + return split.SplitDial(t.dialer, network, addr) } // NewTransport returns a POST-only DoH transport. diff --git a/intra/ipn/piph2.go b/intra/ipn/piph2.go index 026a7d08..923752db 100644 --- a/intra/ipn/piph2.go +++ b/intra/ipn/piph2.go @@ -144,7 +144,7 @@ func (t *piph2) dialtls(network, addr string, cfg *tls.Config) (net.Conn, error) } func (t *piph2) dial(network, addr string) (net.Conn, error) { - return split.ReDial(t.dialer, network, addr) + return split.SplitDial(t.dialer, network, addr) } func NewPipProxy(id string, ctl protect.Controller, po *settings.ProxyOptions) (Proxy, error) { diff --git a/intra/ipn/pipws.go b/intra/ipn/pipws.go index 79be70bf..17f5259f 100644 --- a/intra/ipn/pipws.go +++ b/intra/ipn/pipws.go @@ -53,7 +53,7 @@ func (c *pipwsconn) CloseRead() error { return c.Close() } func (c *pipwsconn) CloseWrite() error { return c.Close() } func (t *pipws) dial(network, addr string) (net.Conn, error) { - return split.ReDial(t.dialer, network, addr) + return split.SplitDial(t.dialer, network, addr) } func (t *pipws) wsconn(rurl, msg string) (c net.Conn, res *http.Response, err error) { diff --git a/intra/split/redial.go b/intra/split/redial.go index de982041..2b3fa244 100644 --- a/intra/split/redial.go +++ b/intra/split/redial.go @@ -17,7 +17,7 @@ import ( "github.com/celzero/firestack/intra/protect/ipmap" ) -type establishConnFunc func(*protect.RDial, string, netip.Addr, int) (net.Conn, error) +type connectFunc func(*protect.RDial, string, netip.Addr, int) (net.Conn, error) var ipm ipmap.IPMap = ipmap.NewIPMap() @@ -67,7 +67,7 @@ func Disconfirm(hostname string, ip net.Addr) bool { return false } -func dial(d *protect.RDial, proto string, ip netip.Addr, port int) (net.Conn, error) { +func connect(d *protect.RDial, proto string, ip netip.Addr, port int) (net.Conn, error) { switch proto { case "tcp", "tcp4", "tcp6": return d.DialTCP(proto, nil, tcpaddr(ip, port)) @@ -78,7 +78,7 @@ func dial(d *protect.RDial, proto string, ip netip.Addr, port int) (net.Conn, er } } -func splitdial(d *protect.RDial, proto string, ip netip.Addr, port int) (net.Conn, error) { +func splitconnect(d *protect.RDial, proto string, ip netip.Addr, port int) (net.Conn, error) { switch proto { case "tcp", "tcp4", "tcp6": if conn, err := DialWithSplitRetry(d, tcpaddr(ip, port)); err == nil { @@ -97,11 +97,7 @@ func splitdial(d *protect.RDial, proto string, ip netip.Addr, port int) (net.Con return nil, net.UnknownNetworkError(proto) } -func Dial(d *protect.RDial, network, addr string) (net.Conn, error) { - return commondial(d, network, addr, dial) -} - -func commondial(d *protect.RDial, network, addr string, connect establishConnFunc) (net.Conn, error) { +func commondial(d *protect.RDial, network, addr string, connect connectFunc) (net.Conn, error) { start := time.Now() log.D("commondial: dialing %s", addr) @@ -147,6 +143,10 @@ func commondial(d *protect.RDial, network, addr string, connect establishConnFun return d.Dial(network, addr) } -func ReDial(d *protect.RDial, network, addr string) (net.Conn, error) { - return commondial(d, network, addr, splitdial) +func SplitDial(d *protect.RDial, network, addr string) (net.Conn, error) { + return commondial(d, network, addr, splitconnect) +} + +func Dial(d *protect.RDial, network, addr string) (net.Conn, error) { + return commondial(d, network, addr, connect) }