| 1599 | |
| 1600 | #[pymethod] |
| 1601 | fn session_stats(&self, vm: &VirtualMachine) -> PyResult<PyObjectRef> { |
| 1602 | // Return session statistics |
| 1603 | // NOTE: This is a partial implementation - rustls doesn't expose all OpenSSL stats |
| 1604 | let dict = vm.ctx.new_dict(); |
| 1605 | |
| 1606 | // Number of sessions currently in the cache |
| 1607 | let session_count = self.client_session_cache.read().len() as i32; |
| 1608 | dict.set_item("number", vm.ctx.new_int(session_count).into(), vm)?; |
| 1609 | |
| 1610 | // Client-side statistics (not tracked separately in this implementation) |
| 1611 | dict.set_item("connect", vm.ctx.new_int(0).into(), vm)?; |
| 1612 | dict.set_item("connect_good", vm.ctx.new_int(0).into(), vm)?; |
| 1613 | dict.set_item("connect_renegotiate", vm.ctx.new_int(0).into(), vm)?; // rustls doesn't support renegotiation |
| 1614 | |
| 1615 | // Server-side statistics |
| 1616 | let accept_count = self.accept_count.load(Ordering::SeqCst) as i32; |
| 1617 | dict.set_item("accept", vm.ctx.new_int(accept_count).into(), vm)?; |
| 1618 | dict.set_item("accept_good", vm.ctx.new_int(accept_count).into(), vm)?; // Assume all accepts are good |
| 1619 | dict.set_item("accept_renegotiate", vm.ctx.new_int(0).into(), vm)?; // rustls doesn't support renegotiation |
| 1620 | |
| 1621 | // Session reuse statistics |
| 1622 | let hits = self.session_hits.load(Ordering::SeqCst) as i32; |
| 1623 | dict.set_item("hits", vm.ctx.new_int(hits).into(), vm)?; |
| 1624 | |
| 1625 | // Misses, timeouts, and cache_full are not tracked in this implementation |
| 1626 | dict.set_item("misses", vm.ctx.new_int(0).into(), vm)?; |
| 1627 | dict.set_item("timeouts", vm.ctx.new_int(0).into(), vm)?; |
| 1628 | dict.set_item("cache_full", vm.ctx.new_int(0).into(), vm)?; |
| 1629 | |
| 1630 | Ok(dict.into()) |
| 1631 | } |
| 1632 | |
| 1633 | #[pygetset] |
| 1634 | fn sni_callback(&self) -> Option<PyObjectRef> { |