mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
Show warnings when network is set to public on windows (#1425)
This commit is contained in:
@@ -1242,6 +1242,7 @@ status_system-StatusSteamVRDisconnected = { $type ->
|
||||
}
|
||||
status_system-StatusTrackerError = The { $trackerName } tracker has an error.
|
||||
status_system-StatusUnassignedHMD = The VR headset should be assigned as a head tracker.
|
||||
status_system-StatusPublicNetwork = Your network profile is currently set to Public. This is not recomended for SlimeVR to function properly. <PublicFixLink>See how to fix it here.</PublicFixLink>
|
||||
|
||||
|
||||
## Firmware tool globals
|
||||
|
||||
@@ -21,6 +21,7 @@ import { ClearMountingButton } from './ClearMountingButton';
|
||||
import { ToggleableSkeletonVisualizerWidget } from './widgets/SkeletonVisualizerWidget';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { flatTrackersAtom } from '@/store/app-store';
|
||||
import { A } from './commons/A';
|
||||
|
||||
function UnprioritizedStatuses() {
|
||||
const { l10n } = useLocalization();
|
||||
@@ -38,6 +39,11 @@ function UnprioritizedStatuses() {
|
||||
id={`status_system-${StatusData[status.dataType]}`}
|
||||
vars={parseStatusToLocale(status, trackers, l10n)}
|
||||
key={status.id}
|
||||
elems={{
|
||||
PublicFixLink: (
|
||||
<A href="https://docs.slimevr.dev/common-issues.html#the-trackers-are-connected-to-my-wi-fi-but-dont-turn-up-on-slimevr"></A>
|
||||
),
|
||||
}}
|
||||
>
|
||||
<TipBox whitespace={false} hideIcon>
|
||||
{`Warning, you should fix ${StatusData[status.dataType]}`}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
RpcMessage,
|
||||
StartWifiProvisioningRequestT,
|
||||
StatusData,
|
||||
StopWifiProvisioningRequestT,
|
||||
WifiProvisioningStatus,
|
||||
WifiProvisioningStatusResponseT,
|
||||
@@ -15,7 +16,7 @@ import { ArrowLink } from '@/components/commons/ArrowLink';
|
||||
import { Button } from '@/components/commons/Button';
|
||||
import { LoaderIcon, SlimeState } from '@/components/commons/icon/LoaderIcon';
|
||||
import { ProgressBar } from '@/components/commons/ProgressBar';
|
||||
import { TipBox } from '@/components/commons/TipBox';
|
||||
import { TipBox, WarningBox } from '@/components/commons/TipBox';
|
||||
import { Typography } from '@/components/commons/Typography';
|
||||
import { TrackerCard } from '@/components/tracker/TrackerCard';
|
||||
import { useIsRestCalibrationTrackers } from '@/hooks/imu-logic';
|
||||
@@ -23,6 +24,8 @@ import './ConnectTracker.scss';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { connectedIMUTrackersAtom } from '@/store/app-store';
|
||||
import { BaseModal } from '@/components/commons/BaseModal';
|
||||
import { useStatusContext } from '@/hooks/status-system';
|
||||
import { A } from '@/components/commons/A';
|
||||
|
||||
const statusLabelMap = {
|
||||
[WifiProvisioningStatus.NONE]:
|
||||
@@ -72,6 +75,8 @@ const statusProgressMap = {
|
||||
|
||||
export function ConnectTrackersPage() {
|
||||
const { l10n } = useLocalization();
|
||||
const { statuses } = useStatusContext();
|
||||
|
||||
const connectedIMUTrackers = useAtomValue(connectedIMUTrackersAtom);
|
||||
const { applyProgress, state } = useOnboarding();
|
||||
const navigate = useNavigate();
|
||||
@@ -159,6 +164,12 @@ export function ConnectTrackersPage() {
|
||||
[connectedIMUTrackers.length]
|
||||
);
|
||||
|
||||
const filteredStatuses = useMemo(() => {
|
||||
return Object.entries(statuses).filter(
|
||||
([, value]) => value.dataType == StatusData.StatusPublicNetwork
|
||||
);
|
||||
}, [statuses]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<BaseModal
|
||||
@@ -231,7 +242,23 @@ export function ConnectTrackersPage() {
|
||||
>
|
||||
<TipBox>Conditional tip</TipBox>
|
||||
</Localized>
|
||||
|
||||
{filteredStatuses.map(([, status]) => (
|
||||
<div className="pt-4">
|
||||
<Localized
|
||||
key={status.id}
|
||||
id={`status_system-${StatusData[status.dataType]}`}
|
||||
elems={{
|
||||
PublicFixLink: (
|
||||
<A href="https://docs.slimevr.dev/common-issues.html#the-trackers-are-connected-to-my-wi-fi-but-dont-turn-up-on-slimevr"></A>
|
||||
),
|
||||
}}
|
||||
>
|
||||
<WarningBox whitespace={false}>
|
||||
{`Warning, you should fix ${StatusData[status.dataType]}`}
|
||||
</WarningBox>
|
||||
</Localized>
|
||||
</div>
|
||||
))}
|
||||
<div
|
||||
className={classNames(
|
||||
'rounded-xl h-24 flex gap-2 p-3 lg:w-full mt-4 relative',
|
||||
|
||||
@@ -36,11 +36,10 @@ function SceneRenderer({
|
||||
mag: Vector3Object;
|
||||
model: string;
|
||||
}) {
|
||||
const magDir = new Vector3(mag.x, mag.y, mag.z);
|
||||
const magLen = magDir.length();
|
||||
const magMag = Math.sqrt(magLen / 100); // normalize magnituge
|
||||
if (magLen > 0)
|
||||
magDir.multiplyScalar(1/ magLen);
|
||||
const magDir = new Vector3(mag.x, mag.y, mag.z);
|
||||
const magLen = magDir.length();
|
||||
const magMag = Math.sqrt(magLen / 100); // normalize magnituge
|
||||
if (magLen > 0) magDir.multiplyScalar(1 / magLen);
|
||||
|
||||
return (
|
||||
<Canvas
|
||||
@@ -118,9 +117,7 @@ export function IMUVisualizerWidget({ tracker }: { tracker: TrackerDataT }) {
|
||||
tracker?.linearAcceleration ||
|
||||
tracker?.rawAcceleration ||
|
||||
new THREE.Vector3();
|
||||
const mag =
|
||||
tracker?.rawMagneticVector ||
|
||||
new THREE.Vector3();
|
||||
const mag = tracker?.rawMagneticVector || new THREE.Vector3();
|
||||
|
||||
return (
|
||||
<div className="bg-background-70 flex flex-col p-3 rounded-lg gap-2">
|
||||
@@ -167,9 +164,7 @@ export function IMUVisualizerWidget({ tracker }: { tracker: TrackerDataT }) {
|
||||
<Typography color="secondary">
|
||||
{l10n.getString('tracker-infos-magnetometer')}
|
||||
</Typography>
|
||||
<Typography>
|
||||
{formatVector3(tracker.rawMagneticVector, 1)}
|
||||
</Typography>
|
||||
<Typography>{formatVector3(tracker.rawMagneticVector, 1)}</Typography>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ export function parseStatusToLocale(
|
||||
case StatusData.NONE:
|
||||
case StatusData.StatusTrackerReset:
|
||||
case StatusData.StatusUnassignedHMD:
|
||||
case StatusData.StatusPublicNetwork:
|
||||
return {};
|
||||
case StatusData.StatusSteamVRDisconnected: {
|
||||
const data = status.data as StatusSteamVRDisconnectedT;
|
||||
|
||||
@@ -129,6 +129,8 @@ fun main(args: Array<String>) {
|
||||
)
|
||||
vrServer.start()
|
||||
|
||||
NetworkProfileChecker(vrServer)
|
||||
|
||||
// Start service for USB HID trackers
|
||||
TrackersHID(
|
||||
"Sensors HID service",
|
||||
@@ -143,6 +145,7 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vrServer.join()
|
||||
scanner.join()
|
||||
LogManager.closeLogger()
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package dev.slimevr.desktop
|
||||
|
||||
import dev.slimevr.VRServer
|
||||
import io.eiren.util.OperatingSystem
|
||||
import solarxr_protocol.rpc.StatusData
|
||||
import solarxr_protocol.rpc.StatusDataUnion
|
||||
import solarxr_protocol.rpc.StatusPublicNetworkT
|
||||
import java.io.BufferedReader
|
||||
import java.io.InputStreamReader
|
||||
import java.util.*
|
||||
import kotlin.concurrent.scheduleAtFixedRate
|
||||
|
||||
enum class NetworkProfile {
|
||||
PRIVATE,
|
||||
PUBLIC,
|
||||
}
|
||||
|
||||
fun checkNetworkProfile(): NetworkProfile? {
|
||||
if (OperatingSystem.currentPlatform != OperatingSystem.WINDOWS) {
|
||||
return null
|
||||
}
|
||||
try {
|
||||
// Full command as a single string
|
||||
val command = "powershell.exe -Command \"(Get-NetConnectionProfile).NetworkCategory\""
|
||||
|
||||
// Use ProcessBuilder with the full command passed through the shell
|
||||
val processBuilder = ProcessBuilder(command.split(" "))
|
||||
processBuilder.redirectErrorStream(true)
|
||||
val process = processBuilder.start()
|
||||
|
||||
// Capture the output
|
||||
val output = BufferedReader(InputStreamReader(process.inputStream)).useLines { lines ->
|
||||
lines.joinToString("\n")
|
||||
}
|
||||
val exitCode = process.waitFor()
|
||||
if (exitCode != 0) {
|
||||
return null
|
||||
}
|
||||
return when (output.trim()) {
|
||||
"Private" -> NetworkProfile.PRIVATE
|
||||
"Public" -> NetworkProfile.PUBLIC
|
||||
else -> null
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
class NetworkProfileChecker(private val server: VRServer) {
|
||||
private val updateTickTimer = Timer("NetworkProfileCheck")
|
||||
private var lastPublicNetworkStatus: UInt = 0u
|
||||
private var currentNetworkProfile: NetworkProfile? = null
|
||||
|
||||
init {
|
||||
if (OperatingSystem.currentPlatform == OperatingSystem.WINDOWS) {
|
||||
this.updateTickTimer.scheduleAtFixedRate(0, 3000) {
|
||||
val profile = checkNetworkProfile()
|
||||
if (profile != currentNetworkProfile) {
|
||||
currentNetworkProfile = profile
|
||||
if (lastPublicNetworkStatus == 0u && profile == NetworkProfile.PUBLIC) {
|
||||
lastPublicNetworkStatus = server.statusSystem.addStatus(
|
||||
StatusDataUnion().apply {
|
||||
type = StatusData.StatusPublicNetwork
|
||||
value = StatusPublicNetworkT()
|
||||
},
|
||||
false,
|
||||
)
|
||||
} else if (lastPublicNetworkStatus != 0u && profile != NetworkProfile.PUBLIC) {
|
||||
server.statusSystem.removeStatus(lastPublicNetworkStatus)
|
||||
lastPublicNetworkStatus = 0u
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Submodule solarxr-protocol updated: 7aa68a1b42...8e9be687c7
Reference in New Issue
Block a user