Skip to content

Commit

Permalink
Merge pull request #2535 from openziti/alphanumber-id-prefix
Browse files Browse the repository at this point in the history
Require first character of generated ids to be alphanumberic. Fixes #2534
  • Loading branch information
plorenz authored Nov 12, 2024
2 parents ef4ac01 + 6d42467 commit 31af3f7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 1 addition & 6 deletions controller/idgen/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,15 @@ func New() string {

type Generator interface {
NextId() (string, error)
NextAlphaNumericPrefixedId() (string, error)
}

type shortIdGenerator struct {
*shortid.Shortid
}

func (self *shortIdGenerator) NextId() (string, error) {
return self.Generate()
}

func (self *shortIdGenerator) NextAlphaNumericPrefixedId() (string, error) {
for {
id, err := self.NextId()
id, err := self.Generate()
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion controller/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ func (network *Network) CreateCircuit(params model.CreateCircuitParams) (*model.
instanceId, serviceId := parseInstanceIdAndService(service)

// 1: Allocate Circuit Identifier
circuitId, err := network.circuitIdGenerator.NextAlphaNumericPrefixedId()
circuitId, err := network.circuitIdGenerator.NextId()
if err != nil {
network.CircuitFailedEvent(circuitId, params, startTime, nil, nil, CircuitFailureIdGenerationError)
return nil, err
Expand Down

0 comments on commit 31af3f7

Please sign in to comment.