X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fsvc_IP_Mixin.pm;h=c89245fe25b801e45b3d0fd21aeafd3f9d08fc2e;hp=abafe86adea2406fec39d3af821281a6ac8fb0be;hb=f822e27a1e00594332ffa487a1c284234c5580a6;hpb=65573c262573834104caa1bad0d2867150b8a12e diff --git a/FS/FS/svc_IP_Mixin.pm b/FS/FS/svc_IP_Mixin.pm index abafe86ad..c89245fe2 100644 --- a/FS/FS/svc_IP_Mixin.pm +++ b/FS/FS/svc_IP_Mixin.pm @@ -186,7 +186,9 @@ means "Framed-Route" if there's an attached router. sub radius_reply { my $self = shift; + my %reply = (); + if ( my $block = $self->attached_block ) { # block routed over dynamic IP: "192.168.100.0/29 0.0.0.0 1" # or @@ -196,21 +198,9 @@ sub radius_reply { ($self->ip_addr || '0.0.0.0') . ' 1'; } - if ( $self->router_routernum && FS::Conf->new->exists('radius-canopy') ) { - - my @addr_block = - qsearch('addr_block', { routernum => $self->router_routernum } ); - if ( @addr_block ) { - - #? - warn "Multiple address blocks attached to this service's router; using first" - if scalar(@addr_block) > 1; - - $reply{'Motorola-Canopy-Gateway'} = $addr_block[0]->ip_gateway + $reply{'Motorola-Canopy-Gateway'} = $self->addr_block->ip_gateway + if FS::Conf->new->exists('radius-canopy') && $self->addr_block; - } - - } %reply; } @@ -232,4 +222,41 @@ sub replace_check { ref($err_or_ref) ? '' : $err_or_ref; } +=item addr_status + +Returns the ping status record for this service's address, if there +is one. + +=cut + +sub addr_status { + my $self = shift; + my $addr = $self->ip_addr or return; + qsearchs('addr_status', { 'ip_addr' => $addr }); +} + +=item addr_status_color + +Returns the CSS color for the ping status of this service. + +=cut + +# subject to change; should also show high/low latency (yellow?) and +# staleness of data (probably means the daemon is not running) and packet +# loss (once we measure that) + +sub addr_status_color { + my $self = shift; + if ( my $addr_status = $self->addr_status ) { + if ( $addr_status->up ) { + return 'green'; + } else { + return 'red'; + } + } else { + return 'gray'; + } +} + + 1;