Język polski

pull/878/head
Mord0reK 2025-11-11 20:44:08 +07:00 committed by GitHub
parent 36d5ae023f
commit b61adae978
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 90 additions and 90 deletions

@ -51,7 +51,7 @@ type failedAuthAttempt struct {
func generateSessionToken(username string, secret []byte, now time.Time) (string, error) {
if len(secret) != AUTH_SECRET_KEY_LENGTH {
return "", fmt.Errorf("secret key length is not %d bytes", AUTH_SECRET_KEY_LENGTH)
return "", fmt.Errorf("długość tajnego klucza (secret key) jest nieprawidłowa: %d bajtów", AUTH_SECRET_KEY_LENGTH)
}
usernameHash, err := computeUsernameHash(username, secret)
@ -76,7 +76,7 @@ func generateSessionToken(username string, secret []byte, now time.Time) (string
func computeUsernameHash(username string, secret []byte) ([]byte, error) {
if len(secret) != AUTH_SECRET_KEY_LENGTH {
return nil, fmt.Errorf("secret key length is not %d bytes", AUTH_SECRET_KEY_LENGTH)
return nil, fmt.Errorf("długość tajnego klucza (secret key) jest nieprawidłowa: %d bajtów", AUTH_SECRET_KEY_LENGTH)
}
h := hmac.New(sha256.New, secret[AUTH_TOKEN_SECRET_LENGTH:])
@ -92,11 +92,11 @@ func verifySessionToken(token string, secretBytes []byte, now time.Time) ([]byte
}
if len(tokenBytes) != AUTH_TOKEN_DATA_LENGTH+32 {
return nil, false, fmt.Errorf("token length is invalid")
return nil, false, fmt.Errorf("długość tokena jest nieprawidłowa")
}
if len(secretBytes) != AUTH_SECRET_KEY_LENGTH {
return nil, false, fmt.Errorf("secret key length is not %d bytes", AUTH_SECRET_KEY_LENGTH)
return nil, false, fmt.Errorf("długość tajnego klucza (secret key) jest nieprawidłowa: %d bajtów", AUTH_SECRET_KEY_LENGTH)
}
usernameHashBytes := tokenBytes[0:AUTH_USERNAME_HASH_LENGTH]
@ -108,12 +108,12 @@ func verifySessionToken(token string, secretBytes []byte, now time.Time) ([]byte
expectedSignatureBytes := h.Sum(nil)
if !hmac.Equal(expectedSignatureBytes, providedSignatureBytes) {
return nil, false, fmt.Errorf("signature does not match")
return nil, false, fmt.Errorf("podpis (sygnatura) się nie zgadza")
}
expiresTimestamp := int64(binary.LittleEndian.Uint32(timestampBytes))
if now.Unix() > expiresTimestamp {
return nil, false, fmt.Errorf("token has expired")
return nil, false, fmt.Errorf("token wygasł")
}
return usernameHashBytes,
@ -197,7 +197,7 @@ func (a *application) handleAuthenticationAttempt(w http.ResponseWriter, r *http
logAuthFailure := func() {
log.Printf(
"Failed login attempt for user '%s' from %s",
"Nieudana próba logowania użytkownika '%s' z %s",
creds.Username, ip,
)
}
@ -232,7 +232,7 @@ func (a *application) handleAuthenticationAttempt(w http.ResponseWriter, r *http
token, err := generateSessionToken(creds.Username, a.authSecretKey, time.Now())
if err != nil {
log.Printf("Could not compute session token during login attempt: %v", err)
log.Printf("Nie udało się obliczyć tokena sesji podczas próby logowania: %v", err)
time.Sleep(waitOnFailure)
w.WriteHeader(http.StatusUnauthorized)
return
@ -275,7 +275,7 @@ func (a *application) isAuthorized(w http.ResponseWriter, r *http.Request) bool
if shouldRegenerate {
newToken, err := generateSessionToken(username, a.authSecretKey, time.Now())
if err != nil {
log.Printf("Could not compute session token during regeneration: %v", err)
log.Printf("Nie udało się obliczyć tokena sesji podczas regeneracji: %v", err)
return false
}

@ -10,16 +10,16 @@ import (
func TestAuthTokenGenerationAndVerification(t *testing.T) {
secret, err := makeAuthSecretKey(AUTH_SECRET_KEY_LENGTH)
if err != nil {
t.Fatalf("Failed to generate secret key: %v", err)
t.Fatalf("Nie udało się wygenerować tajnego klucza (secret key): %v", err)
}
secretBytes, err := base64.StdEncoding.DecodeString(secret)
if err != nil {
t.Fatalf("Failed to decode secret key: %v", err)
t.Fatalf("Nie udało się zdekodować tajnego klucza (secret key): %v", err)
}
if len(secretBytes) != AUTH_SECRET_KEY_LENGTH {
t.Fatalf("Secret key length is not %d bytes", AUTH_SECRET_KEY_LENGTH)
t.Fatalf("Tajny klucz (secret key) ma nieprawidłową długość: %d bajtów", AUTH_SECRET_KEY_LENGTH)
}
now := time.Now()
@ -27,48 +27,48 @@ func TestAuthTokenGenerationAndVerification(t *testing.T) {
token, err := generateSessionToken(username, secretBytes, now)
if err != nil {
t.Fatalf("Failed to generate session token: %v", err)
t.Fatalf("Nie udało się wygenerować tokena sesji: %v", err)
}
usernameHashBytes, shouldRegen, err := verifySessionToken(token, secretBytes, now)
if err != nil {
t.Fatalf("Failed to verify session token: %v", err)
t.Fatalf("Nie udało się zweryfikować tokena sesji: %v", err)
}
if shouldRegen {
t.Fatal("Token should not need to be regenerated immediately after generation")
t.Fatal("Token nie powinien wymagać natychmiastowej regeneracji po wygenerowaniu")
}
computedUsernameHash, err := computeUsernameHash(username, secretBytes)
if err != nil {
t.Fatalf("Failed to compute username hash: %v", err)
t.Fatalf("Nie udało się obliczyć hasha nazwy użytkownika: %v", err)
}
if !bytes.Equal(usernameHashBytes, computedUsernameHash) {
t.Fatal("Username hash does not match the expected value")
t.Fatal("Hash nazwy użytkownika nie zgadza się z oczekiwaną wartością")
}
// Test token regeneration
timeRightAfterRegenPeriod := now.Add(AUTH_TOKEN_VALID_PERIOD - AUTH_TOKEN_REGEN_BEFORE + 2*time.Second)
_, shouldRegen, err = verifySessionToken(token, secretBytes, timeRightAfterRegenPeriod)
if err != nil {
t.Fatalf("Token verification should not fail during regeneration period, err: %v", err)
t.Fatalf("Weryfikacja tokena nie powinna nie powieść się w okresie regeneracji, err: %v", err)
}
if !shouldRegen {
t.Fatal("Token should have been marked for regeneration")
t.Fatal("Token powinien być oznaczony do regeneracji")
}
// Test token expiration
_, _, err = verifySessionToken(token, secretBytes, now.Add(AUTH_TOKEN_VALID_PERIOD+2*time.Second))
if err == nil {
t.Fatal("Expected token verification to fail after token expiration")
t.Fatal("Oczekiwano, że weryfikacja tokena nie powiedzie się po wygaśnięciu tokena")
}
// Test tampered token
decodedToken, err := base64.StdEncoding.DecodeString(token)
if err != nil {
t.Fatalf("Failed to decode token: %v", err)
t.Fatalf("Nie udało się zdekodować tokena: %v", err)
}
// If any of the bytes are off by 1, the token should be considered invalid
@ -79,7 +79,7 @@ func TestAuthTokenGenerationAndVerification(t *testing.T) {
_, _, err = verifySessionToken(base64.StdEncoding.EncodeToString(tampered), secretBytes, now)
if err == nil {
t.Fatalf("Expected token verification to fail for tampered token at index %d", i)
t.Fatalf("Oczekiwano, że weryfikacja tokena nie powiedzie się dla zmienionego tokena na indeksie %d", i)
}
}
}

@ -44,17 +44,17 @@ func parseCliOptions() (*cliOptions, error) {
flags.Usage = func() {
fmt.Println("Usage: glance [options] command")
fmt.Println("\nOptions:")
fmt.Println("\nOpcje:")
flags.PrintDefaults()
fmt.Println("\nCommands:")
fmt.Println(" config:validate Validate the config file")
fmt.Println(" config:print Print the parsed config file with embedded includes")
fmt.Println(" password:hash <pwd> Hash a password")
fmt.Println(" secret:make Generate a random secret key")
fmt.Println(" sensors:print List all sensors")
fmt.Println(" mountpoint:info Print information about a given mountpoint path")
fmt.Println(" diagnose Run diagnostic checks")
fmt.Println("\nPolecenia:")
fmt.Println(" config:validate Sprawdzenie poprawności pliku konfiguracyjnego")
fmt.Println(" config:print Wyświetlenie sparsowanego pliku konfiguracyjnego z wbudowanymi include'ami")
fmt.Println(" password:hash <pwd> Zahashowanie hasła")
fmt.Println(" secret:make Wygenerowanie losowego tajnego klucza")
fmt.Println(" sensors:print Wyświetlenie wszystkich czujników")
fmt.Println(" mountpoint:info Wyświetlenie informacji o danym punkcie montowania")
fmt.Println(" diagnose Uruchomienie kontroli diagnostycznych")
}
configPath := flags.String("config", "glance.yml", "Set config path")
@ -110,23 +110,23 @@ func cliSensorsPrint() int {
tempSensors, err := sensors.SensorsTemperatures()
if err != nil {
if warns, ok := err.(*sensors.Warnings); ok {
fmt.Printf("Could not retrieve information for some sensors (%v):\n", err)
fmt.Printf("Nie można było pobrać informacji o niektórych czujnikach (%v):\n", err)
for _, w := range warns.List {
fmt.Printf(" - %v\n", w)
}
fmt.Println()
} else {
fmt.Printf("Failed to retrieve sensor information: %v\n", err)
fmt.Printf("Nie udało się pobrać informacji o czujnikach: %v\n", err)
return 1
}
}
if len(tempSensors) == 0 {
fmt.Println("No sensors found")
fmt.Println("Nie znaleziono czujników")
return 0
}
fmt.Println("Sensors found:")
fmt.Println("Znalezione czujniki:")
for _, sensor := range tempSensors {
fmt.Printf(" %s: %.1f°C\n", sensor.SensorKey, sensor.Temperature)
}
@ -137,7 +137,7 @@ func cliSensorsPrint() int {
func cliMountpointInfo(requestedPath string) int {
usage, err := disk.Usage(requestedPath)
if err != nil {
fmt.Printf("Failed to retrieve info for path %s: %v\n", requestedPath, err)
fmt.Printf("Nie udało się pobrać informacji o ścieżce %s: %v\n", requestedPath, err)
if warns, ok := err.(*disk.Warnings); ok {
for _, w := range warns.List {
fmt.Printf(" - %v\n", w)
@ -147,9 +147,9 @@ func cliMountpointInfo(requestedPath string) int {
return 1
}
fmt.Println("Path:", usage.Path)
fmt.Println("FS type:", ternary(usage.Fstype == "", "unknown", usage.Fstype))
fmt.Printf("Used percent: %.1f%%\n", usage.UsedPercent)
fmt.Println("Ścieżka:", usage.Path)
fmt.Println("Typ systemu plików:", ternary(usage.Fstype == "", "unknown", usage.Fstype))
fmt.Printf("Wykorzystanie: %.1f%%\n", usage.UsedPercent)
return 0
}

@ -2,8 +2,8 @@ import { directions, easeOutQuint, slideFade } from "./animations.js";
import { elem, repeat, text } from "./templating.js";
const FULL_MONTH_SLOTS = 7*6;
const WEEKDAY_ABBRS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
const MONTH_NAMES = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
const WEEKDAY_ABBRS = ["Nd", "Pon", "Wt", "Śr", "Cz", "Pt", "So"];
const MONTH_NAMES = ["Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień"];
const leftArrowSvg = `<svg stroke="var(--color-text-base)" fill="none" viewBox="0 0 24 24" stroke-width="1.5" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 19.5 8.25 12l7.5-7.5" />
@ -85,7 +85,7 @@ function Header(nextClicked, prevClicked, undoClicked) {
undo = button()
.hide()
.classes("calendar-undo-button")
.attr("title", "Back to current month")
.attr("title", "Wróć do aktualnego miesiąca")
.on("click", undoClicked)
.html(undoArrowSvg)
);
@ -94,14 +94,14 @@ function Header(nextClicked, prevClicked, undoClicked) {
.classes("flex", "gap-7", "items-center")
.append(
button()
.attr("title", "Previous month")
.attr("title", "Poprzedni miesiąc")
.on("click", prevClicked)
.html(leftArrowSvg),
monthNumber = elem()
.classes("color-highlight")
.styles({ marginTop: "0.1rem" }),
button()
.attr("title", "Next month")
.attr("title", "Następny miesiąc")
.on("click", nextClicked)
.html(rightArrowSvg),
);

@ -26,11 +26,11 @@ const state = {
};
const lang = {
showPassword: "Show password",
hidePassword: "Hide password",
incorrectCredentials: "Incorrect username or password",
rateLimited: "Too many login attempts, try again in a few minutes",
unknownError: "An error occurred, please try again",
showPassword: "Pokaż hasło",
hidePassword: "Ukryj hasło",
incorrectCredentials: "Niepoprawna nazwa użytkownika lub hasło",
rateLimited: "Zbyt wiele prób logowania, spróbuj ponownie za kilka minut",
unknownError: "Wystąpił błąd, spróbuj ponownie",
};
container.clearStyles("display");

@ -340,8 +340,8 @@ function setupLazyImages() {
}
function attachExpandToggleButton(collapsibleContainer) {
const showMoreText = "Show more";
const showLessText = "Show less";
const showMoreText = "Pokaż więcej";
const showLessText = "Pokaż mniej";
let expanded = false;
const button = document.createElement("button");
@ -498,8 +498,8 @@ function afterContentReady(callback) {
contentReadyCallbacks.push(callback);
}
const weekDayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
const monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
const weekDayNames = ['Niedziela', 'Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota'];
const monthNames = ['Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień'];
function makeSettableTimeElement(element, hourFormat) {
const fragment = document.createDocumentFragment();

@ -5,21 +5,21 @@
<div class="flex text-center justify-between dns-stats-totals">
<div>
<div class="color-highlight size-h3">{{ .Stats.TotalQueries | formatNumber }}</div>
<div class="size-h6">QUERIES</div>
<div class="size-h6">Zapytania</div>
</div>
<div>
<div class="color-highlight size-h3">{{ .Stats.BlockedPercent }}%</div>
<div class="size-h6">BLOCKED</div>
<div class="size-h6">Zablokowane</div>
</div>
{{ if gt .Stats.ResponseTime 0 }}
<div>
<div class="color-highlight size-h3">{{ .Stats.ResponseTime | formatNumber }}ms</div>
<div class="size-h6">LATENCY</div>
<div class="size-h6">Opóźnienie</div>
</div>
{{ else }}
<div class="cursor-help" data-popover-type="text" data-popover-text="Total number of blocked domains from all adlists" data-popover-max-width="200px" data-popover-text-align="center">
<div class="color-highlight size-h3">{{ .Stats.DomainsBlocked | formatApproxNumber }}</div>
<div class="size-h6">DOMAINS</div>
<div class="size-h6">Domeny</div>
</div>
{{ end }}
</div>
@ -46,11 +46,11 @@
<div class="flex text-center justify-between gap-25">
<div>
<div class="color-highlight size-h3">{{ $column.Queries | formatNumber }}</div>
<div class="size-h6">QUERIES</div>
<div class="size-h6">Zapytania</div>
</div>
<div>
<div class="color-highlight size-h3">{{ $column.PercentBlocked }}%</div>
<div class="size-h6">BLOCKED</div>
<div class="size-h6">Zablokowane</div>
</div>
</div>
</div>
@ -73,7 +73,7 @@
{{ if and (not .HideTopDomains) .Stats.TopBlockedDomains }}
<details class="details {{ if $showGraph }}margin-top-40{{ else }}margin-top-15{{ end }}">
<summary class="summary">Top blocked domains</summary>
<summary class="summary">Najczęściej zablokowane domeny</summary>
<ul class="list list-gap-4 list-with-transition size-h5">
{{ range .Stats.TopBlockedDomains }}
<li class="flex justify-between gap-10">

@ -3,7 +3,7 @@
{{ define "widget-content" }}
<div class="widget-small-content-bounds">
<div class="size-h2 color-highlight text-center">{{ .Weather.WeatherCodeAsString }}</div>
<div class="size-h4 text-center">Feels like {{ .Weather.ApparentTemperature }}°{{ if eq .Units "metric" }}C{{ else }}F{{ end }}</div>
<div class="size-h4 text-center">Odczuwalna {{ .Weather.ApparentTemperature }}°{{ if eq .Units "metric" }}C{{ else }}F{{ end }}</div>
<div class="weather-columns flex margin-top-15 justify-center">
{{ range $i, $column := .Weather.Columns }}

@ -30,7 +30,7 @@ type weatherWidget struct {
}
var timeLabels12h = [12]string{"2am", "4am", "6am", "8am", "10am", "12pm", "2pm", "4pm", "6pm", "8pm", "10pm", "12am"}
var timeLabels24h = [12]string{"02:00", "04:00", "06:00", "08:00", "10:00", "12:00", "14:00", "16:00", "18:00", "20:00", "22:00", "00:00"}
var timeLabels24h = [12]string{"2:00", "4:00", "6:00", "8:00", "10:00", "12:00", "14:00", "16:00", "18:00", "20:00", "22:00", "00:00"}
func (widget *weatherWidget) initialize() error {
widget.withTitle("Weather").withCacheOnTheHour()
@ -295,32 +295,32 @@ func fetchWeatherForOpenMeteoPlace(place *openMeteoPlaceResponseJson, units stri
}
var weatherCodeTable = map[int]string{
0: "Clear Sky",
1: "Mainly Clear",
2: "Partly Cloudy",
3: "Overcast",
45: "Fog",
48: "Rime Fog",
51: "Drizzle",
53: "Drizzle",
55: "Drizzle",
56: "Drizzle",
57: "Drizzle",
61: "Rain",
63: "Moderate Rain",
65: "Heavy Rain",
66: "Freezing Rain",
67: "Freezing Rain",
71: "Snow",
73: "Moderate Snow",
75: "Heavy Snow",
77: "Snow Grains",
80: "Rain",
81: "Moderate Rain",
82: "Heavy Rain",
85: "Snow",
86: "Snow",
95: "Thunderstorm",
96: "Thunderstorm",
99: "Thunderstorm",
0: "Bezchmurnie",
1: "Głównie bezchmurnie",
2: "Częściowe zachmurzenie",
3: "Pochmurno",
45: "Mgła",
48: "Mgła szronowa",
51: "Mżawka lekka",
53: "Mżawka",
55: "Mżawka gęsta",
56: "Mżawka marznąca lekka",
57: "Mżawka marznąca gęsta",
61: "Deszcz",
63: "Umiarkowany deszcz",
65: "Intensywny deszcz",
66: "Deszcz marznący lekki",
67: "Deszcz marznący intensywny",
71: "Śnieg",
73: "Umiarkowany śnieg",
75: "Intensywny śnieg",
77: "Ziarna śniegu",
80: "Deszcz",
81: "Umiarkowany deszcz",
82: "Intensywny deszcz",
85: "Śnieg",
86: "Śnieg",
95: "Burza",
96: "Burza",
99: "Burza",
}