| 1 | ## Domain Registry Interface, EPP Protocol (STD 69) | ||
| 2 | ## | ||
| 3 | ## Copyright (c) 2005-2011,2013-2014,2016,2018 Patrick Mevzek <netdri@dotandco.com>. All rights reserved. | ||
| 4 | ## | ||
| 5 | ## This file is part of Net::DRI | ||
| 6 | ## | ||
| 7 | ## Net::DRI is free software; you can redistribute it and/or modify | ||
| 8 | ## it under the terms of the GNU General Public License as published by | ||
| 9 | ## the Free Software Foundation; either version 2 of the License, or | ||
| 10 | ## (at your option) any later version. | ||
| 11 | ## | ||
| 12 | ## See the LICENSE file that comes with this distribution for more details. | ||
| 13 | #################################################################################################### | ||
| 14 | |||
| 15 | package Net::DRI::Protocol::EPP; | ||
| 16 | |||
| 17 | 76 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | 76 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | 76 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | 76 | ▶ | use version 0.77; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 21 | |||
| 22 | 76 | ▶ | use base qw(Net::DRI::Protocol); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 23 | |||
| 24 | use Net::DRI::Util; | ||
| 25 | use Net::DRI::Protocol::EPP::Message; | ||
| 26 | use Net::DRI::Protocol::EPP::Core::Status; | ||
| 27 | |||
| 28 | =pod | ||
| 29 | |||
| 30 | =head1 NAME | ||
| 31 | |||
| 32 | Net::DRI::Protocol::EPP - EPP Protocol (STD 69 aka RFC 5730,5731,5732,5733,5734 and RFC 3735) for Net::DRI | ||
| 33 | |||
| 34 | =head1 DESCRIPTION | ||
| 35 | |||
| 36 | Please see the README file for details. | ||
| 37 | |||
| 38 | =head1 SUPPORT | ||
| 39 | |||
| 40 | For now, support questions should be sent to: | ||
| 41 | |||
| 42 | E<lt>netdri@dotandco.comE<gt> | ||
| 43 | |||
| 44 | Please also see the SUPPORT file in the distribution. | ||
| 45 | |||
| 46 | =head1 SEE ALSO | ||
| 47 | |||
| 48 | E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt> | ||
| 49 | |||
| 50 | =head1 AUTHOR | ||
| 51 | |||
| 52 | Patrick Mevzek, E<lt>netdri@dotandco.comE<gt> | ||
| 53 | |||
| 54 | =head1 COPYRIGHT | ||
| 55 | |||
| 56 | Copyright (c) 2005-2011,2013-2014,2016,2018 Patrick Mevzek <netdri@dotandco.com>. | ||
| 57 | All rights reserved. | ||
| 58 | |||
| 59 | This program is free software; you can redistribute it and/or modify | ||
| 60 | it under the terms of the GNU General Public License as published by | ||
| 61 | the Free Software Foundation; either version 2 of the License, or | ||
| 62 | (at your option) any later version. | ||
| 63 | |||
| 64 | See the LICENSE file that comes with this distribution for more details. | ||
| 65 | |||
| 66 | =cut | ||
| 67 | |||
| 68 | #################################################################################################### | ||
| 69 | |||
| 70 | sub new | ||
| 71 | { | ||
| 72 | my ($c,$ctx,$rp)=@_; | ||
| 73 | my $drd=$ctx->{registry}->driver(); | ||
| 74 | my $self=$c->SUPER::new($ctx); | ||
| 75 | $self->name('EPP'); | ||
| 76 | my $version=Net::DRI::Util::check_equal($rp->{version},['1.0'],'1.0'); | ||
| 77 | $self->version($version); | ||
| 78 | |||
| 79 | foreach my $o (qw/ip status/) { $self->capabilities('host_update',$o,['add','del']); } | ||
| 80 | $self->capabilities('host_update','name',['set']); | ||
| 81 | $self->capabilities('contact_update','status',['add','del']); | ||
| 82 | $self->capabilities('contact_update','info',['set']); | ||
| 83 | foreach my $o (qw/ns status contact/) { $self->capabilities('domain_update',$o,['add','del']); } | ||
| 84 | foreach my $o (qw/registrant auth/) { $self->capabilities('domain_update',$o,['set']); } | ||
| 85 | |||
| 86 | $self->{hostasattr}=$drd->info('host_as_attr') || 0; | ||
| 87 | $self->{contacti18n}=$drd->info('contact_i18n') || 7; ## bitwise OR with 1=LOC only, 2=INT only, 4=LOC+INT only | ||
| 88 | $self->{defaulti18ntype}=undef; ## only needed for registries not following truely EPP standard, like .CZ | ||
| 89 | $self->{usenullauth}=$drd->info('use_null_auth') || 0; ## See RFC4931 ยง3.2.5 | ||
| 90 | $self->ns({ epp => 'urn:ietf:params:xml:ns:epp-1.0', | ||
| 91 | domain => 'urn:ietf:params:xml:ns:domain-1.0', | ||
| 92 | contact => 'urn:ietf:params:xml:ns:contact-1.0', | ||
| 93 | }); | ||
| 94 | |||
| 95 | $drd->set_factories($self) if $drd->can('set_factories'); | ||
| 96 | $self->factories('message',sub { my $m=Net::DRI::Protocol::EPP::Message->new(@_); $m->ns($self->ns()); $m->version($version); return $m; }); | ||
| 97 | $self->factories('status',sub { return Net::DRI::Protocol::EPP::Core::Status->new(); }); | ||
| 98 | |||
| 99 | $self->_load($rp); | ||
| 100 | $self->setup($rp); | ||
| 101 | return $self; | ||
| 102 | } | ||
| 103 | |||
| 104 | my $BASE='Net::DRI::Protocol::EPP::Extensions::'; | ||
| 105 | |||
| 106 | sub _load | ||
| 107 | { | ||
| 108 | my ($self,$rp)=@_; | ||
| 109 | my $extramods=$rp->{extensions}; | ||
| 110 | my @class=$self->core_modules($rp); | ||
| 111 | push @class,map { $BASE.$_; } $self->default_extensions($rp) if $self->can('default_extensions'); | ||
| 112 | push @class,map { my $f=$_; if ($f=~m/^([^+])(.+)$/) { $f = $1 eq '-' ? '-'.$BASE.$2 : $BASE.$1.$2; } $f; } (ref $extramods ? @$extramods : ($extramods)) if defined $extramods && $extramods; | ||
| 113 | return $self->SUPER::_load(@class); | ||
| 114 | } | ||
| 115 | |||
| 116 | sub setup {} ## subclass as needed | ||
| 117 | |||
| 118 | sub core_modules | ||
| 119 | { | ||
| 120 | my ($self,$rp)=@_; | ||
| 121 | my @core=qw/Session RegistryMessage Domain Contact/; | ||
| 122 | if (! $self->{hostasattr}) | ||
| 123 | { | ||
| 124 | push @core,'Host'; | ||
| 125 | $self->ns({host => 'urn:ietf:params:xml:ns:host-1.0'}); | ||
| 126 | } | ||
| 127 | return map { 'Net::DRI::Protocol::EPP::Core::'.$_ } @core; | ||
| 128 | } | ||
| 129 | |||
| 130 | sub core_contact_types { return qw/admin tech billing/; } | ||
| 131 | |||
| 132 | sub ns | ||
| 133 | { | ||
| 134 | my ($self,$add)=@_; | ||
| 135 | $self->{ns}={ ref $self->{ns} ? %{$self->{ns}} : (), %$add } if defined $add && ref $add eq 'HASH'; | ||
| 136 | return $self->{ns}; | ||
| 137 | } | ||
| 138 | |||
| 139 | ## Called during server greeting parse | ||
| 140 | sub switch_to_highest_namespace_version | ||
| 141 | { | ||
| 142 | my ($self,$nsalias)=@_; | ||
| 143 | |||
| 144 | my $ns=$self->message()->ns($nsalias); | ||
| 145 | Net::DRI::Exception::err_invalid_parameters("No namespace defined for alias \"$nsalias\"") unless defined $ns; | ||
| 146 | my ($basens)=($ns=~m/^(\S+)-[\d.]+$/); | ||
| 147 | my $rs=$self->default_parameters()->{server}; | ||
| 148 | my @ns=grep { m/^${basens}-\S+$/ } @{$rs->{extensions_selected}}; | ||
| 149 | Net::DRI::Exception::err_invalid_parameters("No extension found under namespace ${basens}-*") unless @ns; | ||
| 150 | |||
| 151 | my $version; | ||
| 152 | foreach my $ns (@ns) | ||
| 153 | { | ||
| 154 | my ($v)=($ns=~m/^\S+-([\d.]+)$/); | ||
| 155 | $version=0+$v if ! defined $version || version->parse('v'.(0+$v)) > version->parse('v'.$version); ## needed for fees (fees-0.4 fees-0.7 fees-0.11 etc...) | ||
| 156 | } | ||
| 157 | |||
| 158 | my $fullns=$basens.'-'.$version; | ||
| 159 | if (@ns > 1) | ||
| 160 | { | ||
| 161 | $self->log_output('info','protocol',{action=>'greeting',direction=>'in',trid=>$self->message()->cltrid(),message=>sprintf('More than one "%s" extension announced by server, selecting "%s"',$nsalias,$fullns)}); | ||
| 162 | } else | ||
| 163 | { | ||
| 164 | $self->log_output('info','protocol',{action=>'greeting',direction=>'in',trid=>$self->message()->cltrid(),message=>sprintf('For "%s" extension, using "%s"',$nsalias,$fullns)}); | ||
| 165 | } | ||
| 166 | |||
| 167 | $self->ns({ $nsalias => $fullns }); | ||
| 168 | $self->message()->ns($self->ns()); ## not necessary, just to make sure | ||
| 169 | ## remove all other versions of same namespace | ||
| 170 | $rs->{extensions_selected}=[ grep { ! m/^${basens}-([\d.]+)$/ || $1 eq $version } @{$rs->{extensions_selected}} ]; | ||
| 171 | return; | ||
| 172 | } | ||
| 173 | |||
| 174 | sub transport_default | ||
| 175 | { | ||
| 176 | my ($self)=@_; | ||
| 177 | return (protocol_connection => 'Net::DRI::Protocol::EPP::Connection', protocol_version => 1); | ||
| 178 | } | ||
| 179 | |||
| 180 | #################################################################################################### | ||
| 181 | 1; | ||