mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-07-20 06:18:06 +03:00
Compare commits
3 Commits
v1.12.22-e
...
v1.12.22-e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1b7aa81cd | ||
|
|
195e941c35 | ||
|
|
35bc351564 |
@@ -71,6 +71,13 @@ func (c *Range) UnmarshalJSON(content []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Range) String() string {
|
||||
if c.From == c.To {
|
||||
return strconv.FormatInt(int64(c.From), 10)
|
||||
}
|
||||
return fmt.Sprintf("%d-%d", c.From, c.To)
|
||||
}
|
||||
|
||||
func (c Range) Rand() int32 {
|
||||
return int32(crypto.RandBetween(int64(c.From), int64(c.To)))
|
||||
}
|
||||
|
||||
@@ -97,18 +97,22 @@ func ProxyDisplayName(proxyType string) string {
|
||||
return "TUIC"
|
||||
case TypeHysteria2:
|
||||
return "Hysteria2"
|
||||
case TypeBond:
|
||||
return "Bond"
|
||||
case TypeMieru:
|
||||
return "Mieru"
|
||||
case TypeAnyTLS:
|
||||
return "AnyTLS"
|
||||
case TypeFailover:
|
||||
return "Failover"
|
||||
case TypeSelector:
|
||||
return "Selector"
|
||||
case TypeURLTest:
|
||||
return "URLTest"
|
||||
case TypeTunnelClient:
|
||||
return "Tunnel Client"
|
||||
return "Tunnel client"
|
||||
case TypeTunnelServer:
|
||||
return "Tunnel Server"
|
||||
return "Tunnel server"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package option
|
||||
import (
|
||||
"net/netip"
|
||||
|
||||
Xbadoption "github.com/sagernet/sing-box/common/xray/json/badoption"
|
||||
"github.com/sagernet/sing/common/json/badoption"
|
||||
)
|
||||
|
||||
@@ -84,24 +85,24 @@ type LegacyWireGuardPeer struct {
|
||||
}
|
||||
|
||||
type WireGuardAmnezia struct {
|
||||
JC int `json:"jc,omitempty"`
|
||||
JMin int `json:"jmin,omitempty"`
|
||||
JMax int `json:"jmax,omitempty"`
|
||||
S1 int `json:"s1,omitempty"`
|
||||
S2 int `json:"s2,omitempty"`
|
||||
S3 int `json:"s3,omitempty"`
|
||||
S4 int `json:"s4,omitempty"`
|
||||
H1 uint32 `json:"h1,omitempty"`
|
||||
H2 uint32 `json:"h2,omitempty"`
|
||||
H3 uint32 `json:"h3,omitempty"`
|
||||
H4 uint32 `json:"h4,omitempty"`
|
||||
I1 string `json:"i1,omitempty"`
|
||||
I2 string `json:"i2,omitempty"`
|
||||
I3 string `json:"i3,omitempty"`
|
||||
I4 string `json:"i4,omitempty"`
|
||||
I5 string `json:"i5,omitempty"`
|
||||
J1 string `json:"j1,omitempty"`
|
||||
J2 string `json:"j2,omitempty"`
|
||||
J3 string `json:"j3,omitempty"`
|
||||
ITime int64 `json:"itime,omitempty"`
|
||||
JC int `json:"jc,omitempty"`
|
||||
JMin int `json:"jmin,omitempty"`
|
||||
JMax int `json:"jmax,omitempty"`
|
||||
S1 int `json:"s1,omitempty"`
|
||||
S2 int `json:"s2,omitempty"`
|
||||
S3 int `json:"s3,omitempty"`
|
||||
S4 int `json:"s4,omitempty"`
|
||||
H1 *Xbadoption.Range `json:"h1,omitempty"`
|
||||
H2 *Xbadoption.Range `json:"h2,omitempty"`
|
||||
H3 *Xbadoption.Range `json:"h3,omitempty"`
|
||||
H4 *Xbadoption.Range `json:"h4,omitempty"`
|
||||
I1 string `json:"i1,omitempty"`
|
||||
I2 string `json:"i2,omitempty"`
|
||||
I3 string `json:"i3,omitempty"`
|
||||
I4 string `json:"i4,omitempty"`
|
||||
I5 string `json:"i5,omitempty"`
|
||||
J1 string `json:"j1,omitempty"`
|
||||
J2 string `json:"j2,omitempty"`
|
||||
J3 string `json:"j3,omitempty"`
|
||||
ITime int64 `json:"itime,omitempty"`
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
|
||||
return nil, E.New("missing tags")
|
||||
}
|
||||
inbound := &Inbound{
|
||||
Adapter: inbound.NewAdapter(C.TypeTunnelServer, tag),
|
||||
Adapter: inbound.NewAdapter(C.TypeBond, tag),
|
||||
logger: logger,
|
||||
router: uot.NewRouter(router, logger),
|
||||
conns: cache.New(C.TCPConnectTimeout, time.Second),
|
||||
|
||||
@@ -62,7 +62,7 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
|
||||
return nil, E.New("invalid ratios")
|
||||
}
|
||||
outbound := &Outbound{
|
||||
Adapter: outbound.NewAdapter(C.TypeTunnelClient, tag, []string{N.NetworkTCP, N.NetworkUDP}, []string{}),
|
||||
Adapter: outbound.NewAdapter(C.TypeBond, tag, []string{N.NetworkTCP, N.NetworkUDP}, []string{}),
|
||||
ctx: ctx,
|
||||
outbounds: outbounds,
|
||||
downloadRatios: downloadRatios,
|
||||
|
||||
@@ -100,6 +100,9 @@ func (s *Failover) ListenPacket(ctx context.Context, destination M.Socksaddr) (n
|
||||
s.logger.ErrorContext(ctx, err)
|
||||
continue
|
||||
}
|
||||
s.mtx.Lock()
|
||||
defer s.mtx.Unlock()
|
||||
s.lastUsedOutbound = outbound.Tag()
|
||||
return conn, nil
|
||||
}
|
||||
return nil, err
|
||||
|
||||
@@ -202,17 +202,17 @@ func (e *Endpoint) Start(resolve bool) error {
|
||||
if e.options.Amnezia.S4 > 0 {
|
||||
ipcConf += "\ns4=" + strconv.Itoa(e.options.Amnezia.S4)
|
||||
}
|
||||
if e.options.Amnezia.H1 > 0 {
|
||||
ipcConf += "\nh1=" + strconv.FormatUint(uint64(e.options.Amnezia.H1), 10)
|
||||
if e.options.Amnezia.H1 != nil {
|
||||
ipcConf += "\nh1=" + e.options.Amnezia.H1.String()
|
||||
}
|
||||
if e.options.Amnezia.H2 > 0 {
|
||||
ipcConf += "\nh2=" + strconv.FormatUint(uint64(e.options.Amnezia.H2), 10)
|
||||
if e.options.Amnezia.H2 != nil {
|
||||
ipcConf += "\nh2=" + e.options.Amnezia.H2.String()
|
||||
}
|
||||
if e.options.Amnezia.H3 > 0 {
|
||||
ipcConf += "\nh3=" + strconv.FormatUint(uint64(e.options.Amnezia.H3), 10)
|
||||
if e.options.Amnezia.H3 != nil {
|
||||
ipcConf += "\nh3=" + e.options.Amnezia.H3.String()
|
||||
}
|
||||
if e.options.Amnezia.H4 > 0 {
|
||||
ipcConf += "\nh4=" + strconv.FormatUint(uint64(e.options.Amnezia.H4), 10)
|
||||
if e.options.Amnezia.H4 != nil {
|
||||
ipcConf += "\nh4=" + e.options.Amnezia.H4.String()
|
||||
}
|
||||
if e.options.Amnezia.I1 != "" {
|
||||
ipcConf += "\ni1=" + e.options.Amnezia.I1
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"net/netip"
|
||||
"time"
|
||||
|
||||
Xbadoption "github.com/sagernet/sing-box/common/xray/json/badoption"
|
||||
tun "github.com/sagernet/sing-tun"
|
||||
"github.com/sagernet/sing/common/logger"
|
||||
M "github.com/sagernet/sing/common/metadata"
|
||||
@@ -49,10 +50,10 @@ type AmneziaOptions struct {
|
||||
S2 int
|
||||
S3 int
|
||||
S4 int
|
||||
H1 uint32
|
||||
H2 uint32
|
||||
H3 uint32
|
||||
H4 uint32
|
||||
H1 *Xbadoption.Range
|
||||
H2 *Xbadoption.Range
|
||||
H3 *Xbadoption.Range
|
||||
H4 *Xbadoption.Range
|
||||
I1 string
|
||||
I2 string
|
||||
I3 string
|
||||
|
||||
Reference in New Issue
Block a user