add bypass
This commit is contained in:
@ -20,13 +20,13 @@ func (r *Route) Connect(ctx context.Context) (conn net.Conn, err error) {
|
||||
}
|
||||
|
||||
node := r.nodes[0]
|
||||
cc, err := node.Transport().Dial(ctx, r.nodes[0].Addr())
|
||||
cc, err := node.transport.Dial(ctx, r.nodes[0].Addr())
|
||||
if err != nil {
|
||||
node.marker.Mark()
|
||||
return
|
||||
}
|
||||
|
||||
cn, err := node.Transport().Handshake(ctx, cc)
|
||||
cn, err := node.transport.Handshake(ctx, cc)
|
||||
if err != nil {
|
||||
cc.Close()
|
||||
node.marker.Mark()
|
||||
@ -36,7 +36,7 @@ func (r *Route) Connect(ctx context.Context) (conn net.Conn, err error) {
|
||||
|
||||
preNode := node
|
||||
for _, node := range r.nodes[1:] {
|
||||
cc, err = preNode.Transport().Connect(ctx, cn, "tcp", node.Addr())
|
||||
cc, err = preNode.transport.Connect(ctx, cn, "tcp", node.Addr())
|
||||
if err != nil {
|
||||
cn.Close()
|
||||
node.marker.Mark()
|
||||
@ -68,7 +68,7 @@ func (r *Route) Dial(ctx context.Context, network, address string) (net.Conn, er
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cc, err := r.Last().Transport().Connect(ctx, conn, network, address)
|
||||
cc, err := r.Last().transport.Connect(ctx, conn, network, address)
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
return nil, err
|
||||
@ -93,9 +93,19 @@ func (r *Route) IsEmpty() bool {
|
||||
return r == nil || len(r.nodes) == 0
|
||||
}
|
||||
|
||||
func (r Route) Last() *Node {
|
||||
func (r *Route) Last() *Node {
|
||||
if r.IsEmpty() {
|
||||
return nil
|
||||
}
|
||||
return r.nodes[len(r.nodes)-1]
|
||||
}
|
||||
|
||||
func (r *Route) Path() (path []*Node) {
|
||||
for _, node := range r.nodes {
|
||||
if node.transport != nil && node.transport.route != nil {
|
||||
path = append(path, node.transport.route.Path()...)
|
||||
}
|
||||
path = append(path, node)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user