mirror of
https://github.com/shadowsocks/ShadowsocksX-NG.git
synced 2026-10-29 05:33:45 +00:00
fix(sip008): emit UUID identifiers in lowercase
This commit is contained in:
@@ -182,19 +182,19 @@ private struct SIP008ExportIdentity {
|
||||
private static let namespace = UUID(uuidString: "0d89e9f8-8f0e-4a55-941a-77d61736eaa3")!
|
||||
|
||||
func groupID(for nodeID: NodeID) -> String {
|
||||
Self.version5(name: "group:\(nodeID.rawValue)").uuidString
|
||||
Self.version5(name: "group:\(nodeID.rawValue)").uuidString.lowercased()
|
||||
}
|
||||
|
||||
func serverID(for entry: CatalogEntry) -> String {
|
||||
if entry.source == .manual, let id = UUID(uuidString: entry.id.rawValue) {
|
||||
return id.uuidString
|
||||
return id.uuidString.lowercased()
|
||||
}
|
||||
if entry.source == .subscription,
|
||||
let providerID = subscriptionServerID(entry.id), let id = UUID(uuidString: providerID)
|
||||
{
|
||||
return id.uuidString
|
||||
return id.uuidString.lowercased()
|
||||
}
|
||||
return Self.version5(name: "server:\(entry.id.rawValue)").uuidString
|
||||
return Self.version5(name: "server:\(entry.id.rawValue)").uuidString.lowercased()
|
||||
}
|
||||
|
||||
private func subscriptionServerID(_ nodeID: NodeID) -> String? {
|
||||
|
||||
@@ -15,7 +15,7 @@ struct NodeID: Hashable, Codable, Sendable {
|
||||
init(rawValue: String) { self.rawValue = rawValue }
|
||||
|
||||
/// 手动新建节点身份。
|
||||
static func fresh() -> NodeID { NodeID(rawValue: UUID().uuidString) }
|
||||
static func fresh() -> NodeID { NodeID(rawValue: UUID().uuidString.lowercased()) }
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
rawValue = try decoder.singleValueContainer().decode(String.self)
|
||||
|
||||
@@ -104,9 +104,9 @@ final class ConfigurationGroupExportTests: XCTestCase {
|
||||
let rootIDs = rootServers.compactMap { $0["id"] as? String }
|
||||
let nestedIDs = nestedServers.compactMap { $0["id"] as? String }
|
||||
|
||||
XCTAssertEqual(rootIDs[0], providerID.uppercased())
|
||||
XCTAssertEqual(rootIDs[1], nestedProviderID.uppercased())
|
||||
XCTAssertEqual(nestedIDs, [nestedProviderID.uppercased()])
|
||||
XCTAssertEqual(rootIDs[0], providerID)
|
||||
XCTAssertEqual(rootIDs[1], nestedProviderID)
|
||||
XCTAssertEqual(nestedIDs, [nestedProviderID])
|
||||
let repeatedRootIDs = try jsonServers(in: repeatedRootDraft).compactMap { $0["id"] as? String }
|
||||
XCTAssertEqual(rootIDs[2], repeatedRootIDs[2], "无 provider UUID 的服务器身份稳定")
|
||||
XCTAssertNotNil(UUID(uuidString: try XCTUnwrap(rootIDs[2])))
|
||||
|
||||
Reference in New Issue
Block a user