Compare commits

...

4 Commits

Author SHA1 Message Date
Pmoranga
e0b00af49d
Merge 213e1d7b0f0981e68e4181b7c209a984b710eb6e into 0680b4ff05a4e7b385416f3d87b5e0d234de8e7c 2025-01-10 11:35:21 +07:00
Dmitry Shurupov
0680b4ff05
Merge pull request #293 from ogumemura/patch-1
Fix username validation regex to correctly recognize hyphen (-)
2025-01-10 11:31:42 +07:00
Shobu UMEMURA
8fc518dba8
Fix username validation regex to correctly recognize hyphen (-)
This pull request corrects the regular expression used for username validation to correctly recognize hyphens (-).

Changes Made:
Changed the regex pattern from ^([a-zA-Z0-9_.-@])+$ to ^([a-zA-Z0-9_.\-@])+$.

Reason for Change:
In the previous regex, the hyphen (-) within the character class was interpreted as a range operator, not as a literal character. This caused usernames with hyphens to be incorrectly marked as invalid.
By escaping the hyphen (\-), the regex now correctly recognizes it as a literal character. This ensures that usernames containing hyphens are validated properly.

Points of Verification:
Confirmed that usernames containing hyphens are now correctly recognized and pass the validation.
Verified that other characters (letters, numbers, underscores, dots, and at signs) are still being properly validated.
2024-09-28 17:57:02 +09:00
Pmoranga
213e1d7b0f Fix Replication
Fixes issue when set to `slave` mode, also fix creation of subdirectories
from the assets received and fix probe port when waiting to slave process
to finish.
2023-04-19 19:00:46 -03:00
3 changed files with 23 additions and 11 deletions

View File

@ -288,6 +288,17 @@ func extractFromArchive(archive, path string) error {
log.Fatalf("extractFromArchive: Mkdir() failed: %s", err.Error()) log.Fatalf("extractFromArchive: Mkdir() failed: %s", err.Error())
} }
case tar.TypeReg: case tar.TypeReg:
s := strings.Split(header.Name, "/")
dir := ""
for len(s) > 1 {
dir, s = dir+"/"+s[0], s[1:]
if _, err := os.Stat(path + dir); os.IsNotExist(err) {
if err := os.Mkdir(path+dir, 0755); err != nil {
log.Fatalf("extractFromArchive: Mkdir() subdir failed: %s", err.Error())
}
}
}
outFile, err := os.Create(path + "/" + header.Name) outFile, err := os.Create(path + "/" + header.Name)
if err != nil { if err != nil {
log.Fatalf("extractFromArchive: Create() failed: %s", err.Error()) log.Fatalf("extractFromArchive: Create() failed: %s", err.Error())

21
main.go
View File

@ -9,11 +9,7 @@ import (
"encoding/pem" "encoding/pem"
"errors" "errors"
"fmt" "fmt"
"github.com/google/uuid"
"io/ioutil" "io/ioutil"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"net" "net"
"net/http" "net/http"
"os" "os"
@ -25,6 +21,11 @@ import (
"time" "time"
"unicode/utf8" "unicode/utf8"
"github.com/google/uuid"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"github.com/gobuffalo/packr/v2" "github.com/gobuffalo/packr/v2"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
@ -34,7 +35,7 @@ import (
) )
const ( const (
usernameRegexp = `^([a-zA-Z0-9_.-@])+$` usernameRegexp = `^([a-zA-Z0-9_.\-@])+$`
passwordMinLength = 6 passwordMinLength = 6
certsArchiveFileName = "certs.tar.gz" certsArchiveFileName = "certs.tar.gz"
ccdArchiveFileName = "ccd.tar.gz" ccdArchiveFileName = "ccd.tar.gz"
@ -520,6 +521,11 @@ func main() {
ovpnAdmin.mgmtInterfaces[parts[0]] = parts[len(parts)-1] ovpnAdmin.mgmtInterfaces[parts[0]] = parts[len(parts)-1]
} }
if ovpnAdmin.role == "slave" {
ovpnAdmin.syncDataFromMaster()
go ovpnAdmin.syncWithMaster()
}
ovpnAdmin.mgmtSetTimeFormat() ovpnAdmin.mgmtSetTimeFormat()
ovpnAdmin.registerMetrics() ovpnAdmin.registerMetrics()
@ -547,11 +553,6 @@ func main() {
ovpnAdmin.modules = append(ovpnAdmin.modules, "ccd") ovpnAdmin.modules = append(ovpnAdmin.modules, "ccd")
} }
if ovpnAdmin.role == "slave" {
ovpnAdmin.syncDataFromMaster()
go ovpnAdmin.syncWithMaster()
}
ovpnAdmin.templates = packr.New("template", "./templates") ovpnAdmin.templates = packr.New("template", "./templates")
staticBox := packr.New("static", "./frontend/static") staticBox := packr.New("static", "./frontend/static")

View File

@ -15,7 +15,7 @@ if [ -e "$SERVER_CERT" ]; then
else else
if [ ${OVPN_ROLE:-"master"} = "slave" ]; then if [ ${OVPN_ROLE:-"master"} = "slave" ]; then
echo "Waiting for initial sync data from master" echo "Waiting for initial sync data from master"
while [ $(wget -q localhost/api/sync/last/try -O - | wc -m) -lt 1 ] while [ $(wget -q localhost:${OVPN_LISTEN_PORT:-8080}/api/sync/last/try -O - | wc -m) -lt 1 ]
do do
sleep 5 sleep 5
done done