From bdc5991fa14452bbc5ebf00c6b38973dd9b5bb15 Mon Sep 17 00:00:00 2001 From: Massimo Melina Date: Sat, 6 Jun 2020 19:59:10 +0200 Subject: [PATCH] fix: display ipv6 address with brackets in log --- hslib.pas | 3 +++ main.pas | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hslib.pas b/hslib.pas index c87dfbf..8fc08d8 100644 --- a/hslib.pas +++ b/hslib.pas @@ -156,6 +156,7 @@ type P_requestCount: integer; P_destroying: boolean; // destroying is in progress P_sndBuf: integer; + P_v6: boolean; persistent: boolean; disconnecting: boolean; // disconnected() has been called lockCount: integer; // prevent freeing of the object @@ -219,6 +220,7 @@ type function initInputStream():boolean; property address:string read P_address; // other peer ip address property port:string read P_port; // other peer port + property v6:boolean read P_v6; property requestCount:integer read P_requestCount; property bytesToSend:int64 read getBytesToSend; property bytesToPost:int64 read getBytesToPost; @@ -978,6 +980,7 @@ limiters:=TObjectList.create; limiters.ownsObjects:=FALSE; P_address:=sock.GetPeerAddr(); P_port:=sock.GetPeerPort(); +P_v6:=pos(':', address) > 0; state:=HCS_IDLE; srv:=server; srv.conns.add(self); diff --git a/main.pas b/main.pas index 67ea05b..34ab0e8 100644 --- a/main.pas +++ b/main.pas @@ -4179,11 +4179,13 @@ if lines = '' then else rest:=reReplace(lines, '^', '> ')+CRLF; -addr:=''; if assigned(cd) and assigned(cd.conn) then addr:=nonEmptyConcat('', cd.user, '@') - +cd.address+':'+cd.conn.port - +nonEmptyConcat(' {', localDNSget(cd.address), '}'); + +ifThen(cd.conn.v6, '['+cd.address+']', cd.address) + +':'+cd.conn.port + +nonEmptyConcat(' {', localDNSget(cd.address), '}') +else + addr:=''; if (logFile.filename > '') and (logFile.apacheFormat = '') then begin @@ -11371,7 +11373,7 @@ pt:=logbox.caretpos; if pt.y >= logbox.lines.count then exit; s:=logbox.lines[pt.y]; -s:=reGet(s, '^.+ (\S+@)?(\S+):\d+ ', 2); +s:=reGet(s, '^.+ (\S+@)?\[?(\S+?)\]?:\d+ ', 2); if checkAddressSyntax(s,FALSE) then result:=s; end; // ipPointedInLog