diff --git a/admin.css b/admin.css index c3fb2ba..af620f0 100644 --- a/admin.css +++ b/admin.css @@ -111,7 +111,8 @@ &.cl_ecosia::before { background-position-y: -340px } &.cl_webkit::before { background-position-y: -360px } &.cl_operaold::before { background-position-y: -380px } - &.cl_wget::before, &.cl_urllib::before { background-position-y: -400px } + &.cl_wget::before { background-position-y: -400px } + &.cl_python::before { background-position-y: -420px } &.cl_other::before { background-image: url('img/more.svg') } /* Captcha statuses */ @@ -119,6 +120,8 @@ &.cap_Y::before { background-position-y: -20px } &.cap_YN::before { background-position-y: -40px } &.cap_W::before { background-position-y: -60px } + &.cap_H::before { background-position-y: -80px } + &.cap_X::before { background-position-y: -100px } /* Country flags */ /* Note: flag images and CSS adapted from: https://github.com/lafeber/world-flags-sprite/ */ diff --git a/admin.js b/admin.js index eea32a0..00cecc9 100644 --- a/admin.js +++ b/admin.js @@ -389,7 +389,9 @@ BotMon.live = { _jsClient: false, // visitor has been seen logged by client js as well _client: BotMon.live.data.clients.match(nv.agent) ?? null, // client info _platform: BotMon.live.data.platforms.match(nv.agent), // platform info - _captcha: {'-': 0, 'Y': 0, 'N': 0, 'W':0} // captcha counter + _captcha: {'X': 0, 'Y': 0, 'N': 0, 'W':0, 'H': 0, + _str: function() { return (this.X > 0 ? 'X' : '') + (this.Y > 0 ? 'Y' : '') + (this.N > 0 ? 'N' : '') + (this.W > 0 ? 'W' : '') + (this.H > 0 ? 'H' : ''); } + } // captcha counter }}; model._visitors.push(visitor); }; @@ -540,6 +542,19 @@ BotMon.live = { _loadCount: 0, _tickCount: 0 }; + }, + + // helper function to make a human-readable title from the Captcha statuses: + _makeCaptchaTitle: function(cObj) { + const cStr = cObj._str(); + switch (cStr) { + case 'Y': + case 'NY': return "Blocked by captcha"; + case 'YN': return "Captcha solved"; + case 'W': return "IP Address whitelisted"; + case 'H': return "HEAD request, no captcha"; + default: return "Undefined: " + cStr; + } } }, @@ -2255,8 +2270,9 @@ BotMon.live = { _makeVisitorItem: function(data, type) { - // shortcut for neater code: + // shortcuts for neater code: const make = BotMon.t._makeElement; + const model = BotMon.live.data.model; let ipType = ( data.ip.indexOf(':') >= 0 ? '6' : '4' ); if (data.ip == '127.0.0.1' || data.ip == '::1' ) ipType = '0'; @@ -2349,11 +2365,14 @@ BotMon.live = { 'title': "Seen by: " + data._seenBy.join('+') }, data._seenBy.join(', '))); - const captchaCode = '' + ( data._captcha['Y'] > 0 ? 'Y' : '' ) + ( data._captcha['N'] > 0 ? 'N' : '' ) + ( data._captcha['W'] > 0 ? 'W' : '' ); - if (captchaCode !== '') { + // captcha status: + const cCode = ( data._captcha ? data._captcha._str() : ''); + if (cCode !== '') { + const cTitle = model._makeCaptchaTitle(data._captcha) span2.appendChild(make('span', { // captcha status - 'class': 'icon_only captcha cap_' + captchaCode, - }, captchaCode)); + 'class': 'icon_only captcha cap_' + cCode, + 'title': "Captcha-status: " + cTitle + }, cTitle)); } summary.appendChild(span2); @@ -2367,8 +2386,9 @@ BotMon.live = { _makeVisitorDetails: function(data, type) { - // shortcut for neater code: + // shortcuts for neater code: const make = BotMon.t._makeElement; + const model = BotMon.live.data.model; let ipType = ( data.ip.indexOf(':') >= 0 ? '6' : '4' ); if (data.ip == '127.0.0.1' || data.ip == '::1' ) ipType = '0'; @@ -2468,11 +2488,12 @@ BotMon.live = { 'title': "Country: " + data._country }, data._country + ' (' + data.geo + ')')); } + if (data.captcha && data.captcha !=='') { dl.appendChild(make('dt', {}, "Captcha-status:")); dl.appendChild(make('dd', { 'class': 'captcha' - }, data.captcha)); + }, model._makeCaptchaTitle(data._captcha))); } dl.appendChild(make('dt', {}, "Session ID:")); diff --git a/config/known-clients.json b/config/known-clients.json index 04ad822..9f35745 100644 --- a/config/known-clients.json +++ b/config/known-clients.json @@ -87,13 +87,13 @@ "id": "undici", "rx": ["undici"] }, - {"n": "GoHTTP-based crawler", + {"n": "GoHTTP-based bot", "id": "gohttp", "rx": ["Go\\-http\\-client\\/(\\d+)", "quic\\-go\\-HTTP\\/(\\d+)"] }, {"n": "Python URLlib-based crawler", - "id": "urllib", - "rx": ["Python\\-urllib\\/(\\d+\\.?\\d*)", "quic\\-go\\-HTTP\\/(\\d+)"] + "id": "python", + "rx": ["Python\\-?\\w*\\/(\\d+\\.?\\d*)"] }, {"n": "AppleWebKit", "id": "webkit", diff --git a/img/captcha.png b/img/captcha.png index f101af1..842decf 100644 Binary files a/img/captcha.png and b/img/captcha.png differ diff --git a/img/clients.png b/img/clients.png index c96355f..8cf182c 100644 Binary files a/img/clients.png and b/img/clients.png differ