+ # Is he from a badip?
+ if (DXCIDR::find($host)) {
+ LogDbg('', "$call on $host is from a badip $host, disconnected");
+ $conn->disconnect;
+ return;
+ }
+
+ # set up the basic channel info for "Normal" Users
+ # is there one already connected to me - locally?
+
+ $dxchan = DXChannel::get($call);
+ my $newcall = $call;
+ if ($dxchan) {
+ if ($user && $user->is_node) {
+ already_conn($conn, $call, DXM::msg($lang, 'conother', $call, $main::mycall));
+ return;
+ }
+ if ($allowmultiple && $user->is_user) {
+ # determine whether we are a candidate, have we flip-flopped frequently enough?
+ my @lastconns = @{$user->connlist} if $user->connlist;
+ my $allow = 0;
+ if (@lastconns >= $DXUser::maxconnlist) {
+ $allow = $lastconns[-1]->[0] - $lastconns[0]->[0] < $min_reconnection_rate;
+ }
+ # search for a spare ssid
+ L1: for (my $count = $call =~ /-\d+$/?0:1; $allow && $count < $allowmultiple; ) { # remember we have one call already
+ my $lastid = 1;
+ for (; $lastid < $max_ssid && $count < $allowmultiple; ++$lastid) {
+ my $chan = DXChannel::get("$basecall-$lastid");
+ if ($chan) {
+ ++$count;
+ next;
+ }
+ # we have a free call-ssid, save it
+ $newcall = "$basecall-$lastid";
+ last L1;
+ }
+ }
+ }
+
+ # handle "normal" (non-multiple) connections in the existing way
+ if ($call eq $newcall) {
+ if ($bumpexisting) {
+ my $ip = $dxchan->hostname;
+ $dxchan->send_now('D', DXM::msg($lang, 'conbump', $call, $ip));
+ LogDbg('', "$call bumped off by $ip, disconnected");
+ $dxchan->disconnect;
+ } else {
+ already_conn($conn, $call, DXM::msg($lang, 'conother', $call, $main::mycall));
+ return;
+ }
+ }
+
+ # make sure that the conn has the (possibly) new callsign
+ $conn->conns($newcall);
+ $msg =~ s/$call/$newcall/;
+ }