Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit b39eccf7 authored by deuce's avatar deuce

Restore server.interface_ip_address as the first IPv4 address and mark as

obsolete.  If there is no IPv4 address, return "255.255.255.255".

Rename the array to interface_ip_addr_list.
parent 3004076f
......@@ -41,15 +41,19 @@
enum {
SERVER_PROP_VER
,SERVER_PROP_VER_DETAIL
,SERVER_PROP_INTERFACE
,SERVER_PROP_OPTIONS
,SERVER_PROP_CLIENTS
};
static JSBool js_server_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
{
jsval idval;
jsint tiny;
jsval idval;
jsint tiny;
js_server_props_t* p;
char * * interface;
char * ipv4;
char * colon;
if((p=(js_server_props_t*)JS_GetPrivate(cx,obj))==NULL)
return(JS_FALSE);
......@@ -65,6 +69,19 @@ static JSBool js_server_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
if(p->version_detail!=NULL)
*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,p->version_detail));
break;
case SERVER_PROP_INTERFACE:
for (interface = *p->interfaces; *interface; interface++) {
if (strchr(*interface, '.')) {
ipv4 = strdup(*interface);
if ((colon = strchr(ipv4, ':')))
*colon = 0;
*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,ipv4));
free(ipv4);
return JS_TRUE;
}
}
*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,"255.255.255.255"));
break;
case SERVER_PROP_OPTIONS:
if(p->options!=NULL)
*vp=UINT_TO_JSVAL(*p->options);
......@@ -110,6 +127,7 @@ static jsSyncPropertySpec js_server_properties[] = {
{ "version", SERVER_PROP_VER, PROP_FLAGS, 310 },
{ "version_detail", SERVER_PROP_VER_DETAIL, PROP_FLAGS, 310 },
{ "interface_ip_address", SERVER_PROP_INTERFACE, PROP_FLAGS, 311 },
{ "options", SERVER_PROP_OPTIONS, JSPROP_ENUMERATE, 311 },
{ "clients", SERVER_PROP_CLIENTS, PROP_FLAGS, 311 },
{0}
......@@ -120,6 +138,7 @@ static char* server_prop_desc[] = {
"server name and version number"
,"detailed version/build information"
,"First bound IPv4 address (<tt>0.0.0.0</tt> = <i>ANY</i>) (obsolete since 3.17, see interface_ip_addr_list)"
,"bit-field of server-specific startup options"
,"number of active clients (if available)"
,"Array of IP addresses of bound network interface (<tt>0.0.0.0</tt> = <i>ANY</i>)"
......@@ -164,7 +183,7 @@ static JSBool js_server_resolve(JSContext *cx, JSObject *obj, jsid id)
}
/* interface_ip_address property */
if(name==NULL || strcmp(name, "interface_ip_address")==0) {
if(name==NULL || strcmp(name, "interface_ip_addr_list")==0) {
if(name) free(name);
if((props=(js_server_props_t*)JS_GetPrivate(cx,obj))==NULL)
......@@ -176,7 +195,7 @@ static JSBool js_server_resolve(JSContext *cx, JSObject *obj, jsid id)
if(!JS_SetParent(cx, newobj, obj))
return(JS_FALSE);
if(!JS_DefineProperty(cx, obj, "interface_ip_address", OBJECT_TO_JSVAL(newobj)
if(!JS_DefineProperty(cx, obj, "interface_ip_addr_list", OBJECT_TO_JSVAL(newobj)
, NULL, NULL, JSPROP_ENUMERATE))
return(JS_FALSE);
......
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