mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-08-02 20:14:16 +03:00
Update sing-box core
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"net/netip"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
@@ -58,6 +57,21 @@ func NewRuleAction(ctx context.Context, logger logger.ContextLogger, action opti
|
||||
TLSFragmentFallbackDelay: time.Duration(action.RouteOptionsOptions.TLSFragmentFallbackDelay),
|
||||
TLSRecordFragment: action.RouteOptionsOptions.TLSRecordFragment,
|
||||
}, nil
|
||||
case C.RuleActionTypeBypass:
|
||||
return &RuleActionBypass{
|
||||
Outbound: action.BypassOptions.Outbound,
|
||||
RuleActionRouteOptions: RuleActionRouteOptions{
|
||||
OverrideAddress: M.ParseSocksaddrHostPort(action.BypassOptions.OverrideAddress, 0),
|
||||
OverridePort: action.BypassOptions.OverridePort,
|
||||
NetworkStrategy: (*C.NetworkStrategy)(action.BypassOptions.NetworkStrategy),
|
||||
FallbackDelay: time.Duration(action.BypassOptions.FallbackDelay),
|
||||
UDPDisableDomainUnmapping: action.BypassOptions.UDPDisableDomainUnmapping,
|
||||
UDPConnect: action.BypassOptions.UDPConnect,
|
||||
TLSFragment: action.BypassOptions.TLSFragment,
|
||||
TLSFragmentFallbackDelay: time.Duration(action.BypassOptions.TLSFragmentFallbackDelay),
|
||||
TLSRecordFragment: action.BypassOptions.TLSRecordFragment,
|
||||
},
|
||||
}, nil
|
||||
case C.RuleActionTypeDirect:
|
||||
directDialer, err := dialer.New(ctx, option.DialerOptions(action.DirectOptions), false)
|
||||
if err != nil {
|
||||
@@ -160,6 +174,25 @@ func (r *RuleActionRoute) String() string {
|
||||
return F.ToString("route(", strings.Join(descriptions, ","), ")")
|
||||
}
|
||||
|
||||
type RuleActionBypass struct {
|
||||
Outbound string
|
||||
RuleActionRouteOptions
|
||||
}
|
||||
|
||||
func (r *RuleActionBypass) Type() string {
|
||||
return C.RuleActionTypeBypass
|
||||
}
|
||||
|
||||
func (r *RuleActionBypass) String() string {
|
||||
if r.Outbound == "" {
|
||||
return "bypass()"
|
||||
}
|
||||
var descriptions []string
|
||||
descriptions = append(descriptions, r.Outbound)
|
||||
descriptions = append(descriptions, r.Descriptions()...)
|
||||
return F.ToString("bypass(", strings.Join(descriptions, ","), ")")
|
||||
}
|
||||
|
||||
type RuleActionRouteOptions struct {
|
||||
OverrideAddress M.Socksaddr
|
||||
OverridePort uint16
|
||||
@@ -307,6 +340,23 @@ func IsRejected(err error) bool {
|
||||
return errors.As(err, &rejected)
|
||||
}
|
||||
|
||||
type BypassedError struct {
|
||||
Cause error
|
||||
}
|
||||
|
||||
func (b *BypassedError) Error() string {
|
||||
return "bypassed"
|
||||
}
|
||||
|
||||
func (b *BypassedError) Unwrap() error {
|
||||
return b.Cause
|
||||
}
|
||||
|
||||
func IsBypassed(err error) bool {
|
||||
var bypassed *BypassedError
|
||||
return errors.As(err, &bypassed)
|
||||
}
|
||||
|
||||
type RuleActionReject struct {
|
||||
Method string
|
||||
NoDrop bool
|
||||
@@ -330,9 +380,11 @@ func (r *RuleActionReject) Error(ctx context.Context) error {
|
||||
var returnErr error
|
||||
switch r.Method {
|
||||
case C.RuleActionRejectMethodDefault:
|
||||
returnErr = &RejectedError{syscall.ECONNREFUSED}
|
||||
returnErr = &RejectedError{tun.ErrReset}
|
||||
case C.RuleActionRejectMethodDrop:
|
||||
return &RejectedError{tun.ErrDrop}
|
||||
case C.RuleActionRejectMethodReply:
|
||||
return nil
|
||||
default:
|
||||
panic(F.ToString("unknown reject method: ", r.Method))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user