Browse Source

remove duplicated targeted dispatch

Shelikhoo 4 years ago
parent
commit
e38839aaf9
1 changed files with 3 additions and 31 deletions
  1. 3 31
      app/dispatcher/default.go

+ 3 - 31
app/dispatcher/default.go

@@ -208,15 +208,11 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin
 		ctx = session.ContextWithContent(ctx, content)
 		ctx = session.ContextWithContent(ctx, content)
 	}
 	}
 
 
-	handler := session.HandlerFromContext(ctx)
 	sniffingRequest := content.SniffingRequest
 	sniffingRequest := content.SniffingRequest
 	switch {
 	switch {
 	case !sniffingRequest.Enabled:
 	case !sniffingRequest.Enabled:
-		if handler != nil {
-			go d.targetedDispatch(ctx, outbound, handler.Tag)
-		} else {
-			go d.routedDispatch(ctx, outbound, destination)
-		}
+		go d.routedDispatch(ctx, outbound, destination)
+
 	case destination.Network != net.Network_TCP:
 	case destination.Network != net.Network_TCP:
 		// Only metadata sniff will be used for non tcp connection
 		// Only metadata sniff will be used for non tcp connection
 		result, err := sniffer(ctx, nil, true)
 		result, err := sniffer(ctx, nil, true)
@@ -246,11 +242,7 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin
 				destination.Address = net.ParseAddress(domain)
 				destination.Address = net.ParseAddress(domain)
 				ob.Target = destination
 				ob.Target = destination
 			}
 			}
-			if handler != nil {
-				d.targetedDispatch(ctx, outbound, handler.Tag)
-			} else {
-				d.routedDispatch(ctx, outbound, destination)
-			}
+			d.routedDispatch(ctx, outbound, destination)
 		}()
 		}()
 	}
 	}
 	return inbound, nil
 	return inbound, nil
@@ -301,26 +293,6 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool) (Sni
 	}
 	}
 	return contentResult, contentErr
 	return contentResult, contentErr
 }
 }
-
-// TODO Pending removal for tagged connection
-func (d *DefaultDispatcher) targetedDispatch(ctx context.Context, link *transport.Link, tag string) {
-	handler := d.ohm.GetHandler(tag)
-	if handler == nil {
-		newError("outbound handler [", tag, "] not exist").AtError().WriteToLog(session.ExportIDToError(ctx))
-		common.Close(link.Writer)
-		common.Interrupt(link.Reader)
-		return
-	}
-	if accessMessage := log.AccessMessageFromContext(ctx); accessMessage != nil {
-		if tag := handler.Tag(); tag != "" {
-			accessMessage.Detour = tag
-		}
-		log.Record(accessMessage)
-	}
-
-	handler.Dispatch(ctx, link)
-}
-
 func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.Link, destination net.Destination) {
 func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.Link, destination net.Destination) {
 	var handler outbound.Handler
 	var handler outbound.Handler