fix: sing内核删除用户逻辑不正确BUG

This commit is contained in:
wyx2685
2025-01-05 20:57:18 +09:00
parent 29e0d7e56e
commit c755e9800b
6 changed files with 267 additions and 247 deletions

View File

@@ -299,7 +299,7 @@ func (n *Hysteria2node) getMasqHandler(tlsconfig *server.TLSConfig, conn net.Pac
req.Header.Set("X-Forwarded-For", clientIP)
}
if !c.Masquerade.Proxy.RewriteHost {
if c.Masquerade.Proxy.RewriteHost {
req.Host = req.URL.Host
}
},

View File

@@ -29,7 +29,6 @@ type Sing struct {
hookServer *HookServer
router adapter.Router
logFactory log.Factory
inbounds map[string]adapter.Inbound
}
func init() {

View File

@@ -114,7 +114,7 @@ type UserDeleter interface {
func (b *Sing) DelUsers(users []panel.UserInfo, tag string) error {
var del UserDeleter
if i, ok := b.inbounds[tag]; ok {
if i, found := b.box.Inbound().Get(tag); found {
switch i.Type() {
case "vmess":
del = i.(*vmess.Inbound)

View File

@@ -45,8 +45,14 @@ func (r *cachedReader) Cache(b *buf.Buffer) {
if !mb.IsEmpty() {
r.cache, _ = buf.MergeMulti(r.cache, mb)
}
b.Clear()
rawBytes := b.Extend(buf.Size)
cacheLen := r.cache.Len()
if cacheLen <= b.Cap() {
b.Clear()
} else {
b.Release()
*b = *buf.NewWithSize(cacheLen)
}
rawBytes := b.Extend(cacheLen)
n := r.cache.Copy(rawBytes)
b.Resize(0, int32(n))
r.Unlock()
@@ -106,7 +112,7 @@ func init() {
common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
d := new(DefaultDispatcher)
if err := core.RequireFeatures(ctx, func(om outbound.Manager, router routing.Router, pm policy.Manager, sm stats.Manager, dc dns.Client) error {
core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) {
core.OptionalFeatures(ctx, func(fdns dns.FakeDNSEngine) {
d.fdns = fdns
})
return d.Init(config.(*Config), om, router, pm, sm, dc)