mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-10-10 08:05:42 +00:00
masque: add address/port option to override endpoint
This commit is contained in:
@@ -111,10 +111,28 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
|
||||
logger.ErrorContext(ctx, E.New("failed to prepare TLS config: ", err))
|
||||
return
|
||||
}
|
||||
endpoint, err := appConfig.SelectEndpointFromConfig(options.UseHTTP2, options.UseIPv6, 443)
|
||||
if err != nil {
|
||||
logger.ErrorContext(ctx, E.New("failed to select endpoint: ", err))
|
||||
return
|
||||
var endpoint net.Addr
|
||||
if options.Address != "" {
|
||||
endpointPort := options.Port
|
||||
if endpointPort == 0 {
|
||||
endpointPort = 443
|
||||
}
|
||||
endpointIP := net.ParseIP(options.Address)
|
||||
if endpointIP == nil {
|
||||
logger.ErrorContext(ctx, E.New("invalid endpoint address: ", options.Address))
|
||||
return
|
||||
}
|
||||
if options.UseHTTP2 {
|
||||
endpoint = &net.TCPAddr{IP: endpointIP, Port: int(endpointPort)}
|
||||
} else {
|
||||
endpoint = &net.UDPAddr{IP: endpointIP, Port: int(endpointPort)}
|
||||
}
|
||||
} else {
|
||||
endpoint, err = appConfig.SelectEndpointFromConfig(options.UseHTTP2, options.UseIPv6, 443)
|
||||
if err != nil {
|
||||
logger.ErrorContext(ctx, E.New("failed to select endpoint: ", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
var udpTimeout time.Duration
|
||||
if options.UDPTimeout != 0 {
|
||||
|
||||
Reference in New Issue
Block a user