Skip to content
Snippets Groups Projects
Forked from opentrafficshaper / opentrafficshaper
416 commits behind the upstream repository.
opentrafficshaperd 7.01 KiB
#!/usr/bin/perl
# Main OpenTrafficShaper program
# Copyright (C) 2007-2013, AllWorldIT
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

use strict;
use warnings;


# Set the dirs we look for library files in
use lib('/usr/local/lib/opentrafficshaper-1.0','/usr/lib/opentrafficshaper-1.0',
		'/usr/lib64/opentrafficshaper-1.0','opentrafficshaper','awitpt');

# System stuff we need
use Config::IniFiles;
use Getopt::Long;
use POE;
use Time::HiRes qw(time);

# Our own stuff
use opentrafficshaper::version;
use opentrafficshaper::logger;
use Radius::Dictionary;
use Radius::Packet;


# Main config
my $globals;
# We just create the logger first, its only using STDERR here
my $logger = new opentrafficshaper::logger;



# Process basically starts here
$logger->log(LOG_NOTICE,"[MAIN] OpenTrafficShaper v".VERSION." - Copyright (c) 2007-2013, AllWorldIT");
parseCfgCmdLine();
init();




# This is our configuration processing session
# TODO: Current just a trigger
POE::Session->create(
  inline_states => {
	_start => sub {
	  $_[KERNEL]->delay(tick => 5);
	},

	tick => sub {
	  print STDERR "tick at ", time(), ":  users = ". (keys %{$globals->{'users'}})  ."\n";
	  $_[KERNEL]->delay(tick => 5);
	},
  }
);