Commit 76ed860d authored by Mike Hibler's avatar Mike Hibler

Change API interface to connect via the node IP rather than "localhost".

In the current FreeNAS, the only options for configuring the web server
are to listen on a specific IP or to listen on INADDR_ANY. If you do the
former, then you cannot connect via "localhost". If you do the latter,
then any experiment with an iSCSI blockstore could connect (via its
per-blockstore VLAN/subnet/IP). While authentication is required to
connect, the latter still makes me nervous.

Note that I didn't have to change the "Dave API" to not use localhost
as it appears to hook in below the web server.
parent 77e40177
......@@ -131,6 +131,7 @@ my $ALIASMASK = "";
my $LINUX_MKFS = "/usr/local/sbin/mke2fs";
my $FBSD_MKFS = "/sbin/newfs";
my $API_AUTHINFO = "$ETCDIR/freenas-api.auth";
my $API_SERVERIP = "/var/emulab/boot/myip";
# storageconfig constants
# XXX: should go somewhere more general
......@@ -158,6 +159,7 @@ my %cliverbs = (
my $debug = 0;
my $auth;
my $server;
sub freenasPoolList();
sub freenasVolumeList($;$);
......@@ -245,6 +247,19 @@ sub freenasRequest($;$$$$$)
$auth = $1;
# XXX use the node's IP rather than "localhost" if possible
if (!$server) {
$server = "localhost";
if (-e "$API_SERVERIP" && open(FD, "<$API_SERVERIP")) {
$server = <FD>;
chomp $server;
if ($server =~ /^(\d+\.\d+\.\d+\.\d+)$/) {
$server = $1;
$method = "GET"
if (!defined($method));
......@@ -261,7 +276,7 @@ sub freenasRequest($;$$$$$)
my $url = "http://localhost/api/v1.0/$resource/$paramstr";
my $url = "http://$server/api/v1.0/$resource/$paramstr";
print STDERR "freenasRequest: URL: $url\nCONTENT: $datastr\n"
if ($debug);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment