@@ -24,21 +24,6 @@ internal static class LiveStats {
2424 private static readonly string [ ] PRINTER_TYPES = new string [ ] { "fax" , "multiprinter" , "ticket printer" , "printer" } ;
2525 private static readonly string [ ] SWITCH_TYPES = new string [ ] { "switch" , "router" , "firewall" } ;
2626
27- private static Dictionary < string , string > speedMap = new Dictionary < string , string > {
28- [ "10" ] = "10 Mbps" ,
29- [ "100" ] = "100 Mbps" ,
30- [ "1000" ] = "1 Gbps" ,
31- [ "2500" ] = "2.5 Gbps" ,
32- [ "5000" ] = "5 Gbps" ,
33- [ "10000" ] = "10 Gbps" ,
34- [ "25000" ] = "25 Gbps" ,
35- [ "40000" ] = "40 Gbps" ,
36- [ "100000" ] = "100 Gbps" ,
37- [ "200000" ] = "200 Gbps" ,
38- [ "400000" ] = "400 Gbps" ,
39- [ "800000" ] = "800 Gbps"
40- } ;
41-
4227 private static void WsWriteText ( WebSocket ws , [ StringSyntax ( StringSyntaxAttribute . Json ) ] string text , Lock mutex ) {
4328 lock ( mutex ) {
4429 WsWriteText ( ws , Encoding . UTF8 . GetBytes ( text ) , mutex ) ;
@@ -419,8 +404,7 @@ private static void SnmpQueryPrinter(WebSocket ws, Lock mutex, IPAddress ipAddre
419404
420405 if ( printerFormatted is not null ) {
421406 if ( printerFormatted . TryGetValue ( Protocols . Snmp . Oid . PRINTER_STATUS , out string snmpPrinterStatus ) ) {
422- string status = snmpPrinterStatus switch
423- {
407+ string status = snmpPrinterStatus switch {
424408 "1" => "Other" ,
425409 "2" => "Processing" ,
426410 "3" => "Idle" ,
@@ -460,7 +444,6 @@ private static void SnmpQuerySwitch(WebSocket ws, Lock mutex, IPAddress ipAddres
460444 }
461445
462446 Dictionary < string , string > parsedResult = Protocols . Snmp . Polling . ParseResponse ( result ) ;
463-
464447 if ( parsedResult is null ) {
465448 WsWriteText ( ws , "{\" switchInfo\" :{\" success\" :false}}"u8 . ToArray ( ) , mutex ) ;
466449 return ;
@@ -498,7 +481,7 @@ private static void SnmpQuerySwitch(WebSocket ws, Lock mutex, IPAddress ipAddres
498481 for ( int k = 0 ; k < 8 ; k ++ ) {
499482 if ( ( b & ( 1 << ( 7 - k ) ) ) != 0 ) {
500483 int portIndex = 8 * ( j - startIndex ) + ( k + 1 ) ;
501- if ( ! taggedMap . TryGetValue ( vlanId , out var ports ) ) {
484+ if ( ! taggedMap . TryGetValue ( vlanId , out List < int > ports ) ) {
502485 ports = new List < int > ( ) ;
503486 taggedMap [ vlanId ] = ports ;
504487 }
@@ -512,7 +495,7 @@ private static void SnmpQuerySwitch(WebSocket ws, Lock mutex, IPAddress ipAddres
512495
513496 foreach ( KeyValuePair < short , List < int > > pair in taggedMap ) {
514497 foreach ( int port in pair . Value ) {
515- taggedDic . TryGetValue ( port , out var existing ) ;
498+ taggedDic . TryGetValue ( port , out string existing ) ;
516499 taggedDic [ port ] = string . IsNullOrEmpty ( existing ) ? pair . Key . ToString ( ) : $ "{ existing } ,{ pair . Key . ToString ( ) } ";
517500 }
518501 }
@@ -572,7 +555,7 @@ private static void SnmpQuerySwitch(WebSocket ws, Lock mutex, IPAddress ipAddres
572555 if ( pair . Value != "6" ) continue ; //physical ports only
573556
574557 string rawSpeed = speedDic . TryGetValue ( pair . Key , out string s ) ? s : "N/A" ;
575- speedList . Add ( speedMap . TryGetValue ( rawSpeed , out string readableSpeed ) ? readableSpeed : "N/A" ) ;
558+ speedList . Add ( PortSpeedToString ( rawSpeed ) ) ;
576559
577560 untaggedList . Add ( untaggedDic . TryGetValue ( pair . Key , out string untaggedVlan ) ? untaggedVlan : "1" ) ;
578561 taggedList . Add ( taggedDic . TryGetValue ( pair . Key , out string taggedVlan ) ? taggedVlan : "1" ) ;
0 commit comments