@@ -80,8 +80,10 @@ pub struct SessionState {
8080 pub connection_id : u32 ,
8181 // secret for this session
8282 pub secret : u32 ,
83- // client address, immutable
84- pub host : String ,
83+ // client ip, immutable
84+ pub client_ip : String ,
85+ // client port, immutable
86+ pub client_port : u16 ,
8587 // client protocol, mysql/postgresql, immutable
8688 pub protocol : DatabaseProtocol ,
8789
@@ -104,7 +106,8 @@ pub struct SessionState {
104106impl SessionState {
105107 pub fn new (
106108 connection_id : u32 ,
107- host : String ,
109+ client_ip : String ,
110+ client_port : u16 ,
108111 protocol : DatabaseProtocol ,
109112 auth_context : Option < AuthContextRef > ,
110113 ) -> Self {
@@ -113,7 +116,8 @@ impl SessionState {
113116 Self {
114117 connection_id,
115118 secret : rng. gen ( ) ,
116- host,
119+ client_ip,
120+ client_port,
117121 protocol,
118122 variables : RwLockSync :: new ( None ) ,
119123 properties : RwLockSync :: new ( SessionProperties :: new ( None , None ) ) ,
@@ -395,9 +399,9 @@ impl Session {
395399 usesysid : 0 ,
396400 usename : self . state . user ( ) ,
397401 application_name,
398- client_addr : None ,
402+ client_addr : self . state . client_ip . clone ( ) ,
399403 client_hostname : None ,
400- client_port : None ,
404+ client_port : self . state . client_port . clone ( ) ,
401405 query,
402406 }
403407 }
@@ -406,7 +410,7 @@ impl Session {
406410 pub fn to_process_list ( self : & Arc < Self > ) -> SessionProcessList {
407411 SessionProcessList {
408412 id : self . state . connection_id ,
409- host : self . state . host . clone ( ) ,
413+ host : self . state . client_ip . clone ( ) ,
410414 user : self . state . user ( ) ,
411415 database : self . state . database ( ) ,
412416 }
@@ -430,8 +434,8 @@ pub struct SessionStatActivity {
430434 pub usesysid : u32 ,
431435 pub usename : Option < String > ,
432436 pub application_name : Option < String > ,
433- pub client_addr : Option < String > ,
437+ pub client_addr : String ,
434438 pub client_hostname : Option < String > ,
435- pub client_port : Option < String > ,
439+ pub client_port : u16 ,
436440 pub query : Option < String > ,
437441}
0 commit comments