Update On Wed Nov 12 19:37:33 CET 2025

This commit is contained in:
github-action[bot]
2025-11-12 19:37:33 +01:00
parent 923627574b
commit cd9974abe8
283 changed files with 59529 additions and 2168 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/pkg/errors"
dto "github.com/prometheus/client_model/go"
"github.com/prometheus/common/expfmt"
"github.com/prometheus/common/model"
"go.uber.org/zap"
)
@@ -71,7 +72,8 @@ func (r *readerImpl) fetchMetrics(ctx context.Context) (map[string]*dto.MetricFa
if err != nil {
return nil, errors.Wrap(err, "failed to read response body")
}
var parser expfmt.TextParser
// Use LegacyValidation for backward compatibility with older Prometheus metrics
// This prevents the "Invalid name validation scheme requested: unset" panic
parser := expfmt.NewTextParser(model.LegacyValidation)
return parser.TextToMetricFamilies(strings.NewReader(string(body)))
}

View File

@@ -89,26 +89,18 @@ func (xs *XrayServer) Setup() error {
return err
}
xs.instance = instance
if xs.cfg.SyncTrafficEndPoint != "" {
// find api port and server, hard code api Tag to `api`
var grpcEndPoint string
var proxyTags []string
for _, inbound := range xs.cfg.XRayConfig.InboundConfigs {
if inbound.Tag == XrayAPITag {
grpcEndPoint = fmt.Sprintf("%s:%d", inbound.ListenOn.String(), inbound.PortList.Range[0].From)
}
if InProxyTags(inbound.Tag) {
proxyTags = append(proxyTags, inbound.Tag)
}
}
if grpcEndPoint == "" {
return errors.New("can't find api port in config")
}
if len(proxyTags) == 0 {
return errors.New("can't find proxy tag in config")
}
xs.up = NewUserPool(grpcEndPoint, xs.cfg.SyncTrafficEndPoint, xs.cfg.GetMetricURL(), proxyTags)
xs.up = NewUserPool(xs.cfg.XRayConfig.API.Listen, xs.cfg.SyncTrafficEndPoint, xs.cfg.GetMetricURL(), proxyTags)
}
return nil
}

View File

@@ -6,7 +6,6 @@ import (
proxy "github.com/xtls/xray-core/app/proxyman/command"
"github.com/xtls/xray-core/common/serial"
"github.com/xtls/xray-core/proxy/shadowsocks"
"go.uber.org/zap"
)
@@ -15,18 +14,6 @@ func getEmailAndTrafficType(input string) (string, string) {
return s[1], s[len(s)-1]
}
func mappingCipher(in string) shadowsocks.CipherType {
switch in {
case "aes-128-gcm":
return shadowsocks.CipherType_AES_128_GCM
case "aes-256-gcm":
return shadowsocks.CipherType_AES_256_GCM
case "chacha20-ietf-poly1305":
return shadowsocks.CipherType_CHACHA20_POLY1305
}
return shadowsocks.CipherType_UNKNOWN
}
// AddInboundUser add user to inbound by tag
func AddInboundUser(ctx context.Context, c proxy.HandlerServiceClient, tag string, user *User) error {
_, err := c.AlterInbound(ctx, &proxy.AlterInboundRequest{
@@ -35,8 +22,11 @@ func AddInboundUser(ctx context.Context, c proxy.HandlerServiceClient, tag strin
&proxy.AddUserOperation{User: user.ToXrayUser()}),
})
if err != nil {
if strings.Contains(err.Error(), "already exists") {
zap.S().Named("xray").Infof("User %s already exists", user.GetEmail())
return nil
}
zap.S().Named("xray").Errorf("Failed to Add User: %s To Server Tag: %s", user.GetEmail(), tag)
return err
}
user.running = true
zap.S().Named("xray").Infof("Add User: %s To Server Tag: %s", user.GetEmail(), tag)

View File

@@ -13,7 +13,7 @@ import (
stats "github.com/xtls/xray-core/app/stats/command"
"github.com/xtls/xray-core/common/protocol"
"github.com/xtls/xray-core/common/serial"
"github.com/xtls/xray-core/proxy/shadowsocks"
"github.com/xtls/xray-core/proxy/shadowsocks_2022"
"github.com/xtls/xray-core/proxy/trojan"
"go.uber.org/zap"
"google.golang.org/grpc"
@@ -97,7 +97,8 @@ func (u *User) ToXrayUser() *protocol.User {
case ProtocolTrojan:
account = serial.ToTypedMessage(&trojan.Account{Password: u.Password})
case ProtocolSS:
account = serial.ToTypedMessage(&shadowsocks.Account{CipherType: mappingCipher(u.Method), Password: u.Password})
memoryAccount := &shadowsocks_2022.MemoryAccount{Key: u.Password}
account = serial.ToTypedMessage(memoryAccount.ToProto())
default:
zap.S().DPanicf("unknown protocol %s", u.Protocol)
return nil
@@ -297,8 +298,10 @@ func (up *UserPool) syncUserConfigsFromServer(ctx context.Context, proxyTag stri
}
func (up *UserPool) Start(ctx context.Context) error {
conn, err := grpc.DialContext(
context.Background(), up.grpcEndPoint, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock())
conn, err := grpc.NewClient(
up.grpcEndPoint,
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
return err
}