####################################################################
# Perl interface to CommuniGate Pro CLI.
#
-# Version 2.8.0
+# Version 2.8.2
#
# Original location: <http://www.communigate.com/CGPerl/>
# Revision history: <http://www.communigate.com/CGPerl/History.html>
# [Get|Set]ClientIPs
# [Get|Set]WhiteHoleIPs
# [Get|Set]Protection
+# [Get|Set]Network
# [Get|Set]Banned
# [Get|Set]ClusterLANIPs
# [Get|Set]ClusterClientIPs
# [Get|Set]ClusterWhiteHoleIPs
# [Get|Set]ClusterProtection
+# [Get|Set]ClusterNetwork
# GetClusterBanned
# [Get|Set][Server|Cluster]Rules
use Digest::MD5;
use vars qw($VERSION);
-$VERSION = '2.8.0';
+$VERSION = '2.8.2';
$CGP::SECURE_LOGIN = 1;
if($this->{isSecureLogin} && $this->{isWebUserLogin});
#print %$params;
- bless $this;
+ bless $this, $class;
$this->{connParams}=$params;
if(!(defined $params->{'connectNow'}) || $params->{'connectNow'}) {
}
sub SetAccountPassword {
- my ($this, $accountName, $newPass) = @_;
- croak 'usage CGP::CLI->SetAccountPassword($accountName, $newPassword)'
+ my ($this, $accountName, $newPass,$check) = @_;
+ croak 'usage CGP::CLI->SetAccountPassword($accountName, $newPassword,$check)'
unless defined $accountName && defined $newPass;
- $this->send('SetAccountPassword '.$accountName.' TO '.$this->printWords($newPass));
+ my $line = 'SetAccountPassword '.$accountName.' PASSWORD '.$this->printWords($newPass);
+ $line .= ' CHECK' if($check);
+ $this->send($line);
$this->_parseResponse();
}
return undef unless $this->_parseResponse();
$this->parseWords($this->getWords);
}
+sub GetNetwork {
+ my ( $this ) = @_;
+ $this->send('GetNetwork');
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
sub GetBanned {
my ( $this ) = @_;
$this->send ('SetProtection '.$this->printWords($settings));
$this->_parseResponse();
}
+sub SetNetwork {
+ my ( $this, $settings ) = @_;
+ croak 'usage CGP::CLI->SetNetwork(\%settings)'
+ unless defined $settings;
+ $this->send ('SetNetwork '.$this->printWords($settings));
+ $this->_parseResponse();
+}
sub SetBanned {
my ( $this, $settings ) = @_;
return undef unless $this->_parseResponse();
$this->parseWords($this->getWords);
}
+sub GetClusterNetwork {
+ my ( $this ) = @_;
+ $this->send('GetClusterNetwork');
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
sub GetClusterBanned {
my ( $this ) = @_;
$this->send('GetClusterBanned');
$this->send ('SetClusterProtection '.$this->printWords($settings));
$this->_parseResponse();
}
+sub SetClusterNetwork {
+ my ( $this, $settings ) = @_;
+ croak 'usage CGP::CLI->SetClusterNetwork(\%settings)'
+ unless defined $settings;
+ $this->send ('SetClusterNetwork '.$this->printWords($settings));
+ $this->_parseResponse();
+}
sub GetServerRules {
my $this = shift;
$this->_parseResponse();
}
+#############################################
+# Directory Administration commands
+
+sub ListDirectoryUnits {
+ my ($this, $shared) = @_;
+ my $line = 'ListDirectoryUnits';
+ $line .= ' SHARED' if $shared;
+ $this->send($line);
+ $this->_parseResponse();
+}
+
+sub CreateDirectoryUnit {
+ my ($this, $unitName,$mountPoint,$shared,$remote) = @_;
+ croak 'usage CGP::CLI->CreateDirectoryUnit($unitName,$mountPoint,[$shared,[$remote]])'
+ unless defined $unitName && defined $mountPoint;
+ my $line = 'CreateDirectoryUnit '.$unitName;
+ $line .= ' SHARED' if $shared;
+ $line .= ' REMOTE' if $remote;
+ $line .= ' '.$mountPoint;
+ $this->send($line);
+ $this->_parseResponse();
+}
+
+sub RelocateDirectoryUnit {
+ my ($this, $unitName,$newMountPoint,$shared) = @_;
+ croak 'usage CGP::CLI->RelocateDirectoryUnit($unitName,$newMountPoint,[$shared])'
+ unless defined $unitName && defined $newMountPoint;
+ my $line = 'RelocateDirectoryUnit '.$unitName;
+ $line .= ' SHARED' if $shared;
+ $line .= ' '.$newMountPoint;
+}
+
+sub DeleteDirectoryUnit {
+ my ($this, $unitName,$shared) = @_;
+ croak 'usage CGP::CLI->DeleteDirectoryUnit($unitName,[$shared])'
+ unless defined $unitName;
+ my $line = 'DeleteDirectoryUnit '.$unitName;
+ $line .= ' SHARED' if $shared;
+ $this->send($line);
+ $this->_parseResponse();
+}
+
+sub GetDirectoryUnit {
+ my ($this, $unitName,$shared) = @_;
+ croak 'usage CGP::CLI->GetDirectoryUnit($unitName,[$shared])'
+ unless defined $unitName;
+ my $line = 'GetDirectoryUnit '.$unitName;
+ $line .= ' SHARED' if $shared;
+ $this->send($line);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+sub SetDirectoryUnit {
+ my ($this, $unitName,$newSettings,$shared) = @_;
+ croak 'usage CGP::CLI->SetDirectoryUnit($unitName,$newSettings,[$shared])'
+ unless defined $unitName && defined $newSettings;
+ my $line = 'SetDirectoryUnit '.$unitName;
+ $line .= ' SHARED' if $shared;
+ $line .= ' '.$this->printWords($newSettings);
+ $this->send($line);
+ $this->_parseResponse();
+}
+
+sub GetDirectoryAccessRights {
+ my ($this, $shared) = @_;
+ my $line = 'GetDirectoryAccessRights';
+ $line .= ' SHARED' if $shared;
+ $this->send($line);
+ return undef unless $this->_parseResponse();
+ $this->parseWords($this->getWords);
+}
+
+sub SetDirectoryAccessRights {
+ my ($this, $unitName,$newRights,$shared) = @_;
+ croak 'usage CGP::CLI->SetDirectoryAccessRights($newRights,[$shared])'
+ unless defined $newRights;
+ my $line = 'SetDirectoryAccessRights';
+ $line .= ' SHARED' if $shared;
+ $line .= ' '.$this->printWords($newRights);
+ $this->send($line);
+ $this->_parseResponse();
+}
+
#############################################
# Miscellaneous commands
sub readWord {
my $this = shift;
- my $isQuoted=0;
- my $isBlock=0;
+ my ($isQuoted,$isBlock,$isUnkData)=(0,0,0);
my $result="";
$this->skipSpaces();
$isQuoted=1; ++$this->{'span'};
} elsif(substr($this->{'data'},$this->{'span'},1) eq '[') {
$isBlock=1;
+ } elsif(substr($this->{'data'},$this->{'span'},2) eq '#(') {
+ $isUnkData=1;
+ $result='#(';
+ $this->{'span'}+=2;
}
while($this->{'span'} < $this->{'len'}) {
my $ch=substr($this->{'data'},$this->{'span'},1);
}
}
+ } elsif($isUnkData) {
+ if($ch eq ')') {
+ $result .= $ch;
+ ++$this->{'span'};
+ $this->skipSpaces();
+ last;
+ }
} elsif($ch =~ /[-a-zA-Z0-9\x80-\xff_\.\@\!\#\%\:]/) {
} else {
last;
++$this->{'span'};
last;
} else {
- my $theKey=$this->readKey();
+ my $theKey=$this->readKey();
$this->skipSpaces();
if(substr($this->{'data'},$this->{'span'},1) ne '=') { croak "CGPro output format error:",substr($this->{'data'},$this->{'span'},10); }
++$this->{'span'};