mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
WebClient/REST API: add sharing support
This commit is contained in:
11
util/util.go
11
util/util.go
@@ -28,6 +28,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/lithammer/shortuuid/v3"
|
||||
"github.com/rs/xid"
|
||||
"golang.org/x/crypto/ssh"
|
||||
|
||||
@@ -431,6 +433,15 @@ func GenerateRandomBytes(length int) []byte {
|
||||
return b[:length]
|
||||
}
|
||||
|
||||
// GenerateUniqueID retuens an unique ID
|
||||
func GenerateUniqueID() string {
|
||||
u, err := uuid.NewRandom()
|
||||
if err != nil {
|
||||
return xid.New().String()
|
||||
}
|
||||
return shortuuid.DefaultEncoder.Encode(u)
|
||||
}
|
||||
|
||||
// HTTPListenAndServe is a wrapper for ListenAndServe that support both tcp
|
||||
// and Unix-domain sockets
|
||||
func HTTPListenAndServe(srv *http.Server, address string, port int, isTLS bool, logSender string) error {
|
||||
|
||||
Reference in New Issue
Block a user