Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,12 @@ func RequestConfig(conn net.Conn, localPort, deviceID, password string) (string,

return resp, nil
}

// SendAuth авторизует рабочую DTLS-сессию, которая не запрашивает WireGuard-конфиг.
func SendAuth(conn net.Conn, deviceID, password string) error {
payload := fmt.Sprintf("AUTH:%s|%s", deviceID, password)
if _, err := conn.Write([]byte(payload)); err != nil {
return fmt.Errorf("отправка AUTH: %w", err)
}
return nil
}
4 changes: 4 additions & 0 deletions core/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ func RunSession(
} else {
log.Printf("[ВОРКЕР #%d] Сервер ещё не выдал WireGuard-конфиг, повторим позже", sessionID)
}
} else {
if authErr := SendAuth(dtlsConn, deviceID, password); authErr != nil {
log.Printf("[ВОРКЕР #%d] Ошибка авторизации: %v", sessionID, authErr)
}
}

emitReady()
Expand Down