2022-05-06 13:28:09 +08:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gofrs/uuid"
|
|
|
|
)
|
|
|
|
|
2022-05-07 12:35:14 +08:00
|
|
|
var uuidNamespace, _ = uuid.FromString("00000000-0000-0000-0000-000000000000")
|
|
|
|
|
2022-05-06 13:28:09 +08:00
|
|
|
// UUIDMap https://github.com/XTLS/Xray-core/issues/158#issue-783294090
|
|
|
|
func UUIDMap(str string) (uuid.UUID, error) {
|
|
|
|
u, err := uuid.FromString(str)
|
|
|
|
if err != nil {
|
2022-05-14 23:45:10 +08:00
|
|
|
return uuid.NewV5(uuidNamespace, str), nil
|
2022-05-06 13:28:09 +08:00
|
|
|
}
|
|
|
|
return u, nil
|
|
|
|
}
|