Page 1 of 1

Enabling web-domain-proxy

Posted: Sat Oct 19, 2013 11:39 pm
by Graham
I'm trying to add a web domain proxy via the api.

It works fine using the command line:

Code: Select all

v-add-web-domain-proxy ted test.test.com
but when I try this through the API I get an error:

Error: argument extentions is not valid (empty)

Code: Select all

function createWebDomainProxy($server,$admuser,$admpa,$proxyDomain)
{
	// Prepare variables
	$postvars1 = array(
	  'user' => $admuser,
	  'password' => $admpa,
	  'cmd' => 'v-add-web-domain-proxy',
	  'arg1' => 'ted',
	  'arg2' => $proxyDomain
	);
	$postdata = http_build_query($postvars1);
//echo $postdata;
	// Get current status
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, 'https://' . $server . ':8083/api/');
	curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
	curl_setopt($curl, CURLOPT_POST, true);
	curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
	$answer = curl_exec($curl);
	return $answer;
}
$server = '192.0.0.0';
$admuser = 'admin';
$admpa = 'topsecret';
$domain = 'test.test.com'
echo createWebDomainProxy($server,$admuser,$admpa,$domain);

Re: Enabling web-domain-proxy

Posted: Sun Oct 20, 2013 12:00 am
by Graham
It doesn't appear to like commas in the extensions argument via the api, even the default ones in the v-add-web-domain-proxy script (when I don't pass extensions in the api).

If I change my script to add arg3 and arg4, it only runs if arg4 contains a single extension.

This works:

Code: Select all

'arg4' => 'htm'
This doesn't:

Code: Select all

'arg4' => 'jpg, htm'

Re: Enabling web-domain-proxy

Posted: Sun Oct 20, 2013 12:37 am
by Graham
This does:

Code: Select all

	  'arg4' => 'jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm',//DEBUG ME
Is there a requirement with the api that all arguments need to be provided (even if blank)?
It looks like arg4 in v-add-web-domain-proxy doesn't like comma space
htm, jpeg, jpg = BAD
htm,jpeg,jpg = GOOD

Re: Enabling web-domain-proxy

Posted: Sun Oct 20, 2013 7:59 am
by skid
Well you already figured out how it works :) Extension list should be always defined and spaces are not allowed

Re: Enabling web-domain-proxy

Posted: Sun Oct 20, 2013 9:59 am
by Graham
skid wrote:Well you already figured out how it works :) Extension list should be always defined and spaces are not allowed
I'm getting there skid (slowly). :)

The default extension list (that's used when none are specified) does contain spaces though, this causes the script to error.

Re: Enabling web-domain-proxy

Posted: Sun Oct 20, 2013 3:31 pm
by skid
I see. The web interface have some basic validation logic and it chops spaces and carriage returns prior sending.