(vm: &VirtualMachine)
| 33 | |
| 34 | #[pyfunction] |
| 35 | fn _get_proxy_settings(vm: &VirtualMachine) -> PyResult<Option<PyDictRef>> { |
| 36 | let Some(proxy_dict) = proxy_dict() else { |
| 37 | return Ok(None); |
| 38 | }; |
| 39 | |
| 40 | let result = vm.ctx.new_dict(); |
| 41 | |
| 42 | let v = 0 |
| 43 | != proxy_dict |
| 44 | .find(unsafe { kSCPropNetProxiesExcludeSimpleHostnames }) |
| 45 | .and_then(|v| v.downcast::<CFNumber>()) |
| 46 | .and_then(|v| v.to_i32()) |
| 47 | .unwrap_or(0); |
| 48 | result.set_item("exclude_simple", vm.ctx.new_bool(v).into(), vm)?; |
| 49 | |
| 50 | if let Some(an_array) = proxy_dict |
| 51 | .find(unsafe { kSCPropNetProxiesExceptionsList }) |
| 52 | .and_then(|v| v.downcast::<CFArray>()) |
| 53 | { |
| 54 | let v = an_array |
| 55 | .into_iter() |
| 56 | .map(|s| { |
| 57 | unsafe { CFType::from_void(*s) } |
| 58 | .downcast::<CFString>() |
| 59 | .map(|s| PyStr::from(s.to_string())) |
| 60 | .to_pyobject(vm) |
| 61 | }) |
| 62 | .collect(); |
| 63 | result.set_item("exceptions", vm.ctx.new_tuple(v).into(), vm)?; |
| 64 | } |
| 65 | |
| 66 | Ok(Some(result)) |
| 67 | } |
| 68 | |
| 69 | #[pyfunction] |
| 70 | fn _get_proxies(vm: &VirtualMachine) -> PyResult<Option<PyDictRef>> { |
no test coverage detected