Skip to content

Commit

Permalink
split: m rename fns
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Oct 4, 2023
1 parent 084aa6a commit d7124d4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion intra/doh/doh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion intra/ipn/piph2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion intra/ipn/pipws.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
20 changes: 10 additions & 10 deletions intra/split/redial.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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))
Expand All @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}

0 comments on commit d7124d4

Please sign in to comment.