void OnTriggerStay(Collider other) { if (other.gameObject.CompareTag("TARGET_PLANET")) { ProbeMonitor.SendProbeTriggerEvent(probeType, TriggerType.TRIGGER_STAY); } }
private static async Task MonitoringMode(bool on = true) { if (on) { Console.WriteLine($"-- Enabling Monitor mode on {Device.Name}"); var wifiOffResult = await CliWrap.Cli.Wrap("sudo").WithArguments($"nmcli radio wifi off").WithValidation(CliWrap.CommandResultValidation.None).ExecuteAsync(); Console.WriteLine($"-- Disabling the WiFi chip took {wifiOffResult.RunTime.TotalMilliseconds}ms"); var wifiOnResult = await CliWrap.Cli.Wrap("sudo").WithArguments($"nmcli radio wifi on").WithValidation(CliWrap.CommandResultValidation.None).ExecuteAsync(); Console.WriteLine($"-- Enabling the WiFi chip took {wifiOnResult.RunTime.TotalMilliseconds}ms"); var wwanOnResult = await CliWrap.Cli.Wrap("sudo").WithArguments($"nmcli radio wwan on").WithValidation(CliWrap.CommandResultValidation.None).ExecuteAsync(); Console.WriteLine($"-- Enabling the modem took {wwanOnResult.RunTime.TotalMilliseconds}ms"); var lteUpResult = await CliWrap.Cli.Wrap("sudo").WithArguments($"nmcli connection PublicIP up").WithValidation(CliWrap.CommandResultValidation.None).ExecuteAsync(); Console.WriteLine($"-- Connecting to 4G took {lteUpResult.RunTime.TotalMilliseconds}ms"); var devDownResult = await CliWrap.Cli.Wrap("sudo").WithArguments($"ip link set {Device.Name} down").WithValidation(CliWrap.CommandResultValidation.None).ExecuteAsync(); Console.WriteLine($"-- Taking down {Device.Name} took {devDownResult.RunTime.TotalMilliseconds}ms"); var modeResult = await CliWrap.Cli.Wrap("sudo").WithArguments($"iwconfig {Device.Name} mode Monitor").WithValidation(CliWrap.CommandResultValidation.None).ExecuteAsync(); Console.WriteLine($"-- Switching {Device.Name} to Monitor Mode took {modeResult.RunTime.TotalMilliseconds}ms"); var setMacResult = await CliWrap.Cli.Wrap("sudo").WithArguments($"ip link set dev {Device.Name} address DE:AD:BE:EF:13:37").WithValidation(CliWrap.CommandResultValidation.None).ExecuteAsync(); Console.WriteLine($"-- Setting {Device.Name} MAC to DE:AD:BE:EF:13:37 took {setMacResult.RunTime.TotalMilliseconds}ms"); var devUpResult = await CliWrap.Cli.Wrap("sudo").WithArguments($"ip link set {Device.Name} up").WithValidation(CliWrap.CommandResultValidation.None).ExecuteAsync(); Console.WriteLine($"-- Bringing up {Device.Name} took {devUpResult.RunTime.TotalMilliseconds}ms"); BeaconMonitor = new BeaconMonitor("beacons.log"); ProbeMonitor = new ProbeMonitor("probes.log"); Device.OnPacketArrival += Device_OnPacketArrival; Device.Open(DeviceMode.Promiscuous, 2000, MonitorMode.Inactive); Device.StartCapture(); Console.CancelKeyPress += async(a, b) => await MonitoringMode(false); } else { Console.WriteLine($"-- Disabling Monitor mode on {Device.Name}"); Device.StopCapture(); Console.WriteLine("-- Capture stopped."); await CliWrap.Cli.Wrap("sudo").WithArguments($"ip link set {Device.Name} down").WithValidation(CliWrap.CommandResultValidation.None).ExecuteAsync(); await CliWrap.Cli.Wrap("sudo").WithArguments($"iwconfig {Device.Name} mode Managed").WithValidation(CliWrap.CommandResultValidation.None).ExecuteAsync(); await CliWrap.Cli.Wrap("sudo").WithArguments($"ip link set dev {Device.Name} address 12:7:00:00:00:01").WithValidation(CliWrap.CommandResultValidation.None).ExecuteAsync(); await CliWrap.Cli.Wrap("sudo").WithArguments($"ip link set {Device.Name} up").WithValidation(CliWrap.CommandResultValidation.None).ExecuteAsync(); } }
void OnTriggerExit(Collider other) { ProbeMonitor.SendProbeTriggerEvent(probeType, TriggerType.TRIGGER_EXIT); }
// from docs: https://docs.unity3d.com/ScriptReference/Rigidbody.OnCollisionEnter.html // Collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached. void OnTriggerEnter(Collider other) { ProbeMonitor.SendProbeTriggerEvent(probeType, TriggerType.TRIGGER_ENTER); }