@@ -504,21 +504,23 @@ func (c *Config) Override(o *Config, fn string) {
504
504
505
505
// update the Outbound in slice if the only one in overide config has same tag
506
506
if len (o .OutboundConfigs ) > 0 {
507
- if len (c .OutboundConfigs ) > 0 && len (o .OutboundConfigs ) == 1 {
508
- if idx := c .findOutboundTag (o .OutboundConfigs [0 ].Tag ); idx > - 1 {
509
- c .OutboundConfigs [idx ] = o .OutboundConfigs [0 ]
510
- ctllog .Println ("[" , fn , "] updated outbound with tag: " , o .OutboundConfigs [0 ].Tag )
507
+ outboundPrepends := []OutboundDetourConfig {}
508
+ for i := range o .OutboundConfigs {
509
+ if idx := c .findOutboundTag (o .OutboundConfigs [i ].Tag ); idx > - 1 {
510
+ c .OutboundConfigs [idx ] = o .OutboundConfigs [i ]
511
+ newError ("[" , fn , "] updated outbound with tag: " , o .OutboundConfigs [i ].Tag ).AtInfo ().WriteToLog ()
511
512
} else {
512
513
if strings .Contains (strings .ToLower (fn ), "tail" ) {
513
- c .OutboundConfigs = append (c .OutboundConfigs , o .OutboundConfigs [0 ])
514
- ctllog . Println ("[" , fn , "] appended outbound with tag: " , o .OutboundConfigs [0 ].Tag )
514
+ c .OutboundConfigs = append (c .OutboundConfigs , o .OutboundConfigs [i ])
515
+ newError ("[" , fn , "] appended outbound with tag: " , o .OutboundConfigs [i ].Tag ). AtInfo (). WriteToLog ( )
515
516
} else {
516
- c . OutboundConfigs = append (o . OutboundConfigs , c .OutboundConfigs ... )
517
- ctllog . Println ("[" , fn , "] prepended outbound with tag: " , o .OutboundConfigs [0 ].Tag )
517
+ outboundPrepends = append (outboundPrepends , o .OutboundConfigs [ i ] )
518
+ newError ("[" , fn , "] prepend outbound with tag: " , o .OutboundConfigs [i ].Tag ). AtInfo (). WriteToLog ( )
518
519
}
519
520
}
520
- } else {
521
- c .OutboundConfigs = o .OutboundConfigs
521
+ }
522
+ if ! strings .Contains (strings .ToLower (fn ), "tail" ) && len (outboundPrepends ) > 0 {
523
+ c .OutboundConfigs = append (outboundPrepends , c .OutboundConfigs ... )
522
524
}
523
525
}
524
526
}
0 commit comments