From patchwork Tue May 8 01:23:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Peter_M=C3=BCller?= X-Patchwork-Id: 1760 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.i.ipfire.org (Postfix) with ESMTP id B41EE60D14 for ; Mon, 7 May 2018 17:25:17 +0200 (CEST) Received: from mail01.i.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 444CF10F62E5; Mon, 7 May 2018 16:25:17 +0100 (BST) Authentication-Results: mail01.i.ipfire.org; dkim=pass header.d=link38.eu; dmarc=pass (policy=none) header.from=link38.eu; spf=pass smtp.mailfrom=peter.mueller@link38.eu Received: from mx-nbg.link38.eu (mx-nbg.link38.eu [IPv6:2a03:4000:6:432c:1f9e:48:ac3:199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mx-nbg.link38.eu", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 370E31000088 for ; Mon, 7 May 2018 16:24:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=link38.eu; s=201803; t=1525706670; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references; bh=vkBw8jnxFpigA/HOlR4AHI7/kxpzZ9AzdjpUBIFC7QQ=; b=L8e9shtZ/HHlZ+jMYQ0enb+0B71pZ2uhH1u2ajjbQ5U+CIvX3SFeENiUgv/rGi80AWcKFm QiRFO66dqEAp6pttv4Qx3HdPi4h5g6ZAqYyhyrYr2pIBUMbQajcVvJh4nzu2r7xYlG5Rtx M1o8dBxfV1GzNocGHy1TUVzAuGo9JDmQc0wBK6xrfIuFaHFMfNyiEfjO0G8njz24ow12HW t6gU8Okbg487LfzfwSNttcsxyi404D75AzXQ2TiU7Ib/cqfXzu/gBQQNECn5TJokDrB6jG Twg/I7mNrxh9kbGk5iuIMY50QCRXvrACZ7UK0b0Py5k8xyx2KGa9CYOFTGIK6Q== To: "IPFire: Development-List" From: =?utf-8?q?Peter_M=C3=BCller?= Subject: [PATCH] display country data for remote IPs on ovpnmain.cgi Openpgp: preference=signencrypt Message-ID: <032299de-afbb-e1df-c405-b87c37111c70@link38.eu> Date: Mon, 7 May 2018 17:23:52 +0200 MIME-Version: 1.0 X-Spamd-Result: default: False [-9.64 / 11.00]; ASN(0.00)[asn:197540, ipnet:2a03:4000::/32, country:DE]; DKIM_TRACE(0.00)[link38.eu:+]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2a03:4000:6:432c:1f9e:48:ac3:199]; BAYES_HAM(-3.00)[100.00%]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; HAS_ATTACHMENT(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DMARC_POLICY_ALLOW(-0.25)[link38.eu,none]; MX_GOOD(-0.01)[cached: mx-nbg.link38.eu]; RCVD_COUNT_ZERO(0.00)[0]; IP_SCORE(-3.78)[ip: (-9.88), ipnet: 2a03:4000::/32(-4.94), asn: 197540(-3.96), country: DE(-0.09)]; RCPT_COUNT_ONE(0.00)[1]; MIME_GOOD(-0.20)[multipart/signed,multipart/mixed,text/plain]; R_DKIM_ALLOW(-0.20)[link38.eu]; MID_RHS_MATCH_FROM(0.00)[]; TO_DN_ALL(0.00)[]; RCVD_IN_DNSWL_MED(-2.00)[9.9.1.0.3.c.a.0.8.4.0.0.e.9.f.1.c.2.3.4.6.0.0.0.0.0.0.4.3.0.a.2.list.dnswl.org : 127.0.6.2] X-Spam-Status: No, score=-9.64 X-Rspamd-Server: mail01.i.ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" This makes debugging easier, especially when it comes to GeoIP related firewall rules and database related issues such as #11482. Signed-off-by: Peter Müller --- config/rootfiles/core/121/filelists/files | 1 + html/cgi-bin/ovpnmain.cgi | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/config/rootfiles/core/121/filelists/files b/config/rootfiles/core/121/filelists/files index 4ce37f9ed..654460b72 100644 --- a/config/rootfiles/core/121/filelists/files +++ b/config/rootfiles/core/121/filelists/files @@ -1,3 +1,4 @@ etc/system-release etc/issue etc/ssl/certs/ca-bundle.crt +srv/web/ipfire/cgi-bin/ovpnmain.cgi diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi index 94e723ba2..eac962e6c 100644 --- a/html/cgi-bin/ovpnmain.cgi +++ b/html/cgi-bin/ovpnmain.cgi @@ -35,6 +35,7 @@ require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; require "${General::swroot}/countries.pl"; +require "${General::swroot}/geoip-functions.pl"; # enable only the following on debugging purpose #use warnings; @@ -2991,6 +2992,7 @@ END $Lang::tr{'common name'} $Lang::tr{'real address'} + $Lang::tr{'country'} $Lang::tr{'virtual address'} $Lang::tr{'loged in at'} $Lang::tr{'bytes sent'} @@ -3030,6 +3032,11 @@ END $users[$uid]{'BytesSent'} = &sizeformat($match[4]); $users[$uid]{'Since'} = $match[5]; $users[$uid]{'Proto'} = $proto; + + # get country code for "RealAddress"... + my $ccode = &GeoIP::lookup((split ':', $users[$uid]{'RealAddress'})[0]); + my $flag_icon = &GeoIP::get_flag_icon($ccode); + $users[$uid]{'Country'} = "$ccode"; $uid++; } } @@ -3056,7 +3063,8 @@ END } print "$users[$idx-1]{'CommonName'}"; print "$users[$idx-1]{'RealAddress'}"; - print "$users[$idx-1]{'VirtualAddress'}"; + print "$users[$idx-1]{'Country'}"; + print "$users[$idx-1]{'VirtualAddress'}"; print "$users[$idx-1]{'Since'}"; print "$users[$idx-1]{'BytesSent'}"; print "$users[$idx-1]{'BytesReceived'}";