1- using System ;
1+ using Caliburn . Micro ;
2+ using SimpleDnsCrypt . Helper ;
3+ using System ;
24
35namespace SimpleDnsCrypt . Models
46{
@@ -23,26 +25,51 @@ public enum QueryLogReturnCode
2325 PARSE_ERROR ,
2426 NXDOMAIN ,
2527 RESPONSE_ERROR ,
26- SERVER_ERROR
28+ SERVER_ERROR ,
29+ CLOAK
2730 }
2831
2932 public class QueryLogLine : LogLine
3033 {
34+ private static readonly ILog Log = LogManagerHelper . Factory ( ) ;
3135 public DateTime Date { get ; set ; }
3236 public string Address { get ; set ; }
3337 public string Remote { get ; set ; }
3438 public QueryLogLineType Type { get ; set ; }
3539 public QueryLogReturnCode ReturnCode { get ; set ; }
40+ public bool Cached { get ; set ; }
41+ public string CachedText {
42+ get
43+ {
44+ if ( Cached )
45+ {
46+ return "cached" ;
47+ }
48+ else
49+ {
50+ return "live" ;
51+ }
52+ }
53+ }
54+ public long Duration { get ; set ; }
55+ public string DurationText
56+ {
57+ get
58+ {
59+ return $ "{ Duration } ms";
60+ }
61+ }
62+ public string Server { get ; set ; }
3663
3764 public QueryLogLine ( string line )
3865 {
3966 try
4067 {
4168 //this only works with the ltsv log format:
42- //time:1516734518 host:::1 message:stackoverflow.com type:A
69+ //time:1559589175 host:::1 message:www.test.de type:AAAA return:SYNTH cached:0 duration:0 server:freetsa.org
4370 var stringSeparators = new [ ] { "\t " } ;
4471 var parts = line . Split ( stringSeparators , StringSplitOptions . RemoveEmptyEntries ) ;
45- if ( parts . Length != 5 ) return ;
72+ if ( parts . Length != 8 ) return ;
4673 if ( parts [ 0 ] . StartsWith ( "time:" ) )
4774 {
4875 Date = UnixTimeStampToDateTime ( Convert . ToDouble ( parts [ 0 ] . Split ( new [ ] { ":" } , StringSplitOptions . RemoveEmptyEntries ) [ 1 ] ) ) ;
@@ -75,9 +102,22 @@ public QueryLogLine(string line)
75102 {
76103 Type = QueryLogLineType . Unknown ;
77104 }
105+ if ( parts [ 5 ] . StartsWith ( "cached:" ) )
106+ {
107+ Cached = Convert . ToBoolean ( Convert . ToInt16 ( parts [ 5 ] . Split ( new [ ] { ":" } , StringSplitOptions . RemoveEmptyEntries ) [ 1 ] . Trim ( ) ) ) ;
108+ }
109+ if ( parts [ 6 ] . StartsWith ( "duration:" ) )
110+ {
111+ Duration = Convert . ToInt64 ( parts [ 6 ] . Split ( new [ ] { ":" } , StringSplitOptions . RemoveEmptyEntries ) [ 1 ] . Trim ( ) ) ;
112+ }
113+ if ( parts [ 7 ] . StartsWith ( "server:" ) )
114+ {
115+ Server = parts [ 7 ] . Split ( new [ ] { ":" } , StringSplitOptions . RemoveEmptyEntries ) [ 1 ] . Trim ( ) ;
116+ }
78117 }
79- catch ( Exception )
118+ catch ( Exception exception )
80119 {
120+ Log . Error ( exception ) ;
81121 }
82122 }
83123 }
0 commit comments