diff --git a/connect-vpn/action.yml b/connect-vpn/action.yml index 621afe4..29f8e25 100644 --- a/connect-vpn/action.yml +++ b/connect-vpn/action.yml @@ -142,12 +142,18 @@ runs: OTP=$(oathtool --totp "$SEED") ;; base64) - # base64 키를 디코딩 → raw 바이트를 hex로 변환 → oathtool에 hex로 전달 - SEED_HEX=$(printf '%s' "$SEED" | base64 -d 2>/dev/null | od -An -v -tx1 | tr -d ' \n') - if [ -z "$SEED_HEX" ]; then + # base64가 raw secret을 감싼 경우와 base32 문자열을 감싼 경우를 모두 지원 + DECODED_SEED=$(printf '%s' "$SEED" | base64 -d 2>/dev/null || true) + if [ -z "$DECODED_SEED" ]; then echo "base64 디코딩 실패: 시드가 올바른 base64인지 확인"; exit 1 fi - OTP=$(oathtool --totp "$SEED_HEX") + DECODED_BASE32=$(printf '%s' "$DECODED_SEED" | tr -d '[:space:]' | tr 'a-z' 'A-Z') + if printf '%s' "$DECODED_BASE32" | grep -Eq '^[A-Z2-7]+=*$'; then + OTP=$(oathtool --totp -b "$DECODED_BASE32") + else + SEED_HEX=$(printf '%s' "$SEED" | base64 -d 2>/dev/null | od -An -v -tx1 | tr -d ' \n') + OTP=$(oathtool --totp "$SEED_HEX") + fi ;; *) echo "잘못된 otp-seed-format: $OTP_SEED_FORMAT (base32|hex|base64)"; exit 1 @@ -177,7 +183,7 @@ runs: # 연결은 백그라운드 데몬에서 비동기로 진행 → --info를 폴링해 완료 대기 echo "연결 완료 대기 중 (최대 ${TIMEOUT}초)..." - DISCONNECTED_PATTERN="not connected|Client not connected|Please login|Unable to open message queue|disconnected|로그인" + DISCONNECTED_PATTERN="not connected|Client not connected|Please login|Unable to open message queue|disconnected|logon failed|로그인" for i in $(seq 1 "$TIMEOUT"); do INFO=$($SUDO f5fpc --info 2>&1 || true) if [ "$i" -eq 1 ] || [ $((i % 5)) -eq 0 ]; then @@ -188,6 +194,11 @@ runs: echo "(f5fpc --info 출력 없음)" fi fi + if echo "$INFO" | grep -Eqi "logon failed"; then + echo "VPN 로그인 실패:" + echo "$INFO" + exit 1 + fi if echo "$INFO" | grep -Eqi "$DISCONNECTED_PATTERN"; then sleep 1 continue