From 0ef45fa3165248c4f5e6a7f57fb9218e326a35f1 Mon Sep 17 00:00:00 2001
From: Nigel Kukard <nkukard@lbsd.net>
Date: Sun, 30 Jun 2013 20:07:47 +0000
Subject: [PATCH] Set source of the user so we know where it came from

---
 opentrafficshaper/plugins/configmanager.pm | 2 ++
 opentrafficshaper/plugins/radius/radius.pm | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/opentrafficshaper/plugins/configmanager.pm b/opentrafficshaper/plugins/configmanager.pm
index a961251..300727b 100644
--- a/opentrafficshaper/plugins/configmanager.pm
+++ b/opentrafficshaper/plugins/configmanager.pm
@@ -284,6 +284,8 @@ sub session_tick {
 # - offline
 # - online
 # - unknown
+# Source 
+# - This is the source of the user, typically  plugin.ModuleName
 
 sub process_change {
 	my ($kernel, $user) = @_[KERNEL, ARG0];
diff --git a/opentrafficshaper/plugins/radius/radius.pm b/opentrafficshaper/plugins/radius/radius.pm
index 8b2aabb..311f7ab 100644
--- a/opentrafficshaper/plugins/radius/radius.pm
+++ b/opentrafficshaper/plugins/radius/radius.pm
@@ -221,6 +221,7 @@ sub server_read {
 		$trafficLimitRx = 256*1024;
 	}
 
+	# Build user
 	my $user = {
 		'Username' => $username,
 		'IP' => $pkt->attr('Framed-IP-Address'),
@@ -231,12 +232,13 @@ sub server_read {
 		'TrafficLimitTxBurst' => $trafficLimitTxBurst,
 		'TrafficLimitRxBurst' => $trafficLimitRxBurst,
 		'Status' => getStatus($pkt->rawattr('Acct-Status-Type')),
+		'Source' => "plugin.radius",
 	};
 
 	# Throw the change at the config manager
 	$kernel->post("configmanager" => "process_change" => $user);
 
-	$logger->log(LOG_DEBUG,"=> Code: $user->{'Status'}, User: $user->{'Username'}, IP: $user->{'IP'}, Group: $user->{'GroupID'}, Class: $user->{'ClassID'}, ".
+	$logger->log(LOG_DEBUG,"[RADIUS] Code: $user->{'Status'}, User: $user->{'Username'}, IP: $user->{'IP'}, Group: $user->{'GroupID'}, Class: $user->{'ClassID'}, ".
 			"Limits: ".prettyUndef($trafficLimitTx)."/".prettyUndef($trafficLimitRx).", Burst: ".prettyUndef($trafficLimitTxBurst)."/".prettyUndef($trafficLimitRxBurst));
 }
 
-- 
GitLab