Changeset fe53e75 for fedkit


Ignore:
Timestamp:
May 18, 2008 9:54:18 PM (16 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
48f7524
Parents:
6115f88
Message:

split out the ssh tunnels to simplify debugging

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedkit/fed-tun.pl

    r6115f88 rfe53e75  
    6464my $type;
    6565my $tunnelcfg;
    66 my $ssh_port_fwds = "";
     66my @ssh_port_fwds;              # Queue of ssh portforwarders to start.  The
     67                                # -L or -R is in here.
    6768my $remote_script_dir;          # location of the other sides fed-tun.pl
    6869my $event_repeater;             # The pathname of the event repeater
     
    109110
    110111    if (defined($opts{'fsname'})) {
    111         $ssh_port_fwds = "-R :$SMBFS_PORT:$opts{'fsname'}:$SMBFS_PORT ";
     112        push(@ssh_port_fwds,"-R :$SMBFS_PORT:$opts{'fsname'}:$SMBFS_PORT");
    112113    }
    113114
    114115    if (defined($opts{'bossname'})) {
    115         $ssh_port_fwds .= "-R :$TMCD_PORT:$opts{'bossname'}:$TMCD_PORT ";
     116        push(@ssh_port_fwds, "-R :$TMCD_PORT:$opts{'bossname'}:$TMCD_PORT");
    116117    }
    117118
    118119    if (defined($opts{'eventservername'})) {
    119         $ssh_port_fwds .= "-R :$remote_pubsub_port:$opts{'eventservername'}:" .
    120             "$PUBSUB_PORT ";
     120        push(@ssh_port_fwds,"-R ".
     121            ":$remote_pubsub_port:$opts{'eventservername'}:$PUBSUB_PORT");
    121122    }
    122123    if (defined($opts{'remoteeventservername'})) {
    123         $ssh_port_fwds .= "-L :$remote_pubsub_port:" .
    124             "$opts{'remoteeventservername'}:$PUBSUB_PORT ";
    125     }
    126 
    127     $ssh_port_fwds = "" if ($opts{'type'} eq 'experiment');
    128 
    129     print "ssh_port_fwds = $ssh_port_fwds\n" if ($debug);
     124        push(@ssh_port_fwds,"-L :$remote_pubsub_port:" .
     125            "$opts{'remoteeventservername'}:$PUBSUB_PORT");
     126    }
     127
     128    @ssh_port_fwds = () if ($opts{'type'} eq 'experiment');
     129
     130    print "ssh_port_fwds = ", join("\n",@ssh_port_fwds), "\n" if ($debug);
    130131}
    131132
     
    172173
    173174    if ($type eq "control") {
    174         system("$SSH $ssh_port_fwds -Nno \"StrictHostKeyChecking no\" $opts{'peer'} &"); #or die "Failed to run ssh";
     175        foreach my $fwd (@ssh_port_fwds) {
     176            system("$SSH -N $fwd -Nno \"StrictHostKeyChecking no\" ".
     177                "$opts{'peer'} &"); #or die "Failed to run ssh";
     178        }
    175179
    176180        exit;
     
    184188        my $bridge = "bridge" . $count;
    185189        my $tun = "tap" . $count;
     190        my $cmd;
    186191
    187192        print "Found $iface, $addr, to bridge on $bridge\n" if ($debug);
     
    191196        # In order to check for problems, we open it this way and read
    192197        # the expected single line of output when the tunnel is connected.
    193 
    194         print "$SSH -w $count:$count $ssh_port_fwds -o \"StrictHostKeyChecking no\" $opts{'peer'}  \"$remote_script_dir/fed-tun.pl $remote_config_file -r $addr $count\"\n" if $debug;
    195         open($SSHCMD[$count], "$SSH -w $count:$count $ssh_port_fwds -o \"StrictHostKeyChecking no\" $opts{'peer'}  \"$remote_script_dir/fed-tun.pl $remote_config_file -r $addr $count\" |") or die "Failed to run ssh";
     198        # To make debugging easier and to degrade more gracefully, I've split
     199        # these out into multiple processes.
     200       
     201        foreach my $fwd (@ssh_port_fwds) {
     202            $cmd = "$SSH -N $fwd -o \"StrictHostKeyChecking no\" ".
     203                "$opts{'peer'} &";
     204
     205            print "$cmd\n" if $debug;
     206            system("$cmd"); # or die "Failed to run ssh";
     207        }
     208        $cmd =  "$SSH -w $count:$count -o \"StrictHostKeyChecking no\" " .
     209            "$opts{'peer'}  \"$remote_script_dir/fed-tun.pl " .
     210            "$remote_config_file -r $addr $count\" & |";
     211
     212        print "$cmd\n" if $debug;
     213
     214        open($SSHCMD[$count], $cmd)
     215           or die "Failed to run ssh";
    196216
    197217        my $check = <$SSHCMD[$count]>;  # Make sure something ran...
     
    200220        &setup_bridging($tun, $bridge, $iface, $addr);
    201221        $count++;
    202         $ssh_port_fwds = "";  # only do this on the first connection
     222        @ssh_port_fwds = ();  # only do this on the first connection
    203223    }
    204224    close(IFFILE);
     
    245265    # event repeater.
    246266
    247     my $file = new IO::File(">/tmp/remote");
    248     print($file "hello!!!\n") if $file;
    249267    if ( $count == 0 && $type ne "experiment" ) {
    250268        my $remote_pubsub_port = $PUBSUB_PORT - 1;  # There will be a local
     
    252270                                                    # dodge the port on the
    253271                                                    # remote tunnel node.
    254         print($file "In here!\n");
    255272        # Make sure we have the relevant parameters
    256273        die "Missing event repeater params (No config file ?)\n"
     
    270287        warn "Event repeater returned $?\n" if $?;
    271288    }
    272     $file->close() if $file;
    273289} else {
    274290    print "inactive end of a connection, finishing" if ($debug);
Note: See TracChangeset for help on using the changeset viewer.