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 61384f67 authored by deuce's avatar deuce

Turn server.interface_ip_address into an array that contains all the

addresses specified in the Interface line of sbbs.ini for the server.
parent c43bbeb6
......@@ -4813,8 +4813,7 @@ void DLLCALL ftp_server(void* arg)
js_server_props.version_detail=ftp_ver();
js_server_props.clients=&active_clients.value;
js_server_props.options=&startup->options;
/* TODO: IPv6 */
js_server_props.interface_addr=&startup->outgoing4;
js_server_props.interfaces=&startup->interfaces;
#endif
uptime=0;
......
......@@ -41,7 +41,6 @@
enum {
SERVER_PROP_VER
,SERVER_PROP_VER_DETAIL
,SERVER_PROP_INTERFACE
,SERVER_PROP_OPTIONS
,SERVER_PROP_CLIENTS
};
......@@ -49,9 +48,7 @@ enum {
static JSBool js_server_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
{
jsval idval;
char* ip;
jsint tiny;
struct in_addr in_addr;
js_server_props_t* p;
if((p=(js_server_props_t*)JS_GetPrivate(cx,obj))==NULL)
......@@ -69,14 +66,6 @@ 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:
if(p->interface_addr!=NULL) {
in_addr.s_addr=*(p->interface_addr);
in_addr.s_addr=htonl(in_addr.s_addr);
if((ip=inet_ntoa(in_addr))!=NULL)
*vp = STRING_TO_JSVAL(JS_NewStringCopyZ(cx,ip));
}
break;
case SERVER_PROP_OPTIONS:
if(p->options!=NULL)
*vp=UINT_TO_JSVAL(*p->options);
......@@ -122,7 +111,6 @@ 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}
......@@ -133,17 +121,38 @@ static char* server_prop_desc[] = {
"server name and version number"
,"detailed version/build information"
,"IP address of bound network interface (<tt>0.0.0.0</tt> = <i>ANY</i>)"
,"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>)"
,NULL
};
#endif
static void remove_port_part(char *host)
{
char *p=strchr(host, 0)-1;
if (!isdigit(*p))
return;
for(; p >= host; p--) {
if (*p == ':') {
*p = 0;
return;
}
if (!isdigit(*p))
return;
}
}
static JSBool js_server_resolve(JSContext *cx, JSObject *obj, jsid id)
{
char* name=NULL;
JSBool ret;
jsval val;
char *str;
JSObject* newobj;
uint i;
js_server_props_t* props;
if(id != JSID_VOID && id != JSID_EMPTY) {
jsval idval;
......@@ -155,6 +164,36 @@ 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) free(name);
if((props=(js_server_props_t*)JS_GetPrivate(cx,obj))==NULL)
return(JS_FALSE);
if((newobj=JS_NewArrayObject(cx, 0, NULL))==NULL)
return(JS_FALSE);
if(!JS_SetParent(cx, newobj, obj))
return(JS_FALSE);
if(!JS_DefineProperty(cx, obj, "interface_ip_address", OBJECT_TO_JSVAL(newobj)
, NULL, NULL, JSPROP_ENUMERATE))
return(JS_FALSE);
for (i=0; (*props->interfaces)[i]; i++) {
str = strdup((*props->interfaces)[i]);
if (str == NULL)
return JS_FALSE;
remove_port_part(str);
val=STRING_TO_JSVAL(JS_NewStringCopyZ(cx,str));
free(str);
JS_SetElement(cx, newobj, i, &val);
}
JS_DeepFreezeObject(cx, newobj);
if(name) return(JS_TRUE);
}
ret = js_SyncResolve(cx, obj, name, js_server_properties, NULL, NULL, 0);
if(name)
free(name);
......
......@@ -5046,8 +5046,7 @@ void DLLCALL mail_server(void* arg)
js_server_props.version_detail=mail_ver();
js_server_props.clients=&active_clients.value;
js_server_props.options=&startup->options;
/* TODO: IPv6 */
js_server_props.interface_addr=&startup->outgoing4;
js_server_props.interfaces=&startup->interfaces;
uptime=0;
memset(&stats,0,sizeof(stats));
......
......@@ -4528,8 +4528,7 @@ void DLLCALL bbs_thread(void* arg)
js_server_props.version_detail=bbs_ver();
js_server_props.clients=&node_threads_running.value;
js_server_props.options=&startup->options;
/* TODO: IPv6 */
js_server_props.interface_addr=(uint32_t *)&startup->outgoing4.s_addr;
js_server_props.interfaces=&startup->telnet_interfaces;
uptime=0;
served=0;
......
......@@ -1135,7 +1135,7 @@ extern "C" {
typedef struct {
char version[128];
const char* version_detail;
uint32_t* interface_addr;
str_list_t* interfaces;
uint32_t* options;
uint32_t* clients;
} js_server_props_t;
......
......@@ -816,8 +816,8 @@ js_initcx(JSRuntime* js_runtime, SOCKET sock, service_client_t* service_client,
services_ver();
service_client->service->js_server_props.clients=
&service_client->service->clients;
service_client->service->js_server_props.interface_addr=
&service_client->service->interface_addr;
service_client->service->js_server_props.interfaces=
&service_client->service->interfaces;
service_client->service->js_server_props.options=
&service_client->service->options;
}
......@@ -1521,8 +1521,6 @@ static service_t* read_services_ini(const char* services_ini, service_t* service
SAFECOPY(serv.protocol,iniGetString(list,sec_list[i],"Protocol",sec_list[i],prot));
serv.set = NULL;
serv.interfaces=iniGetStringList(list,sec_list[i],"Interface",",",default_interfaces);
serv.outgoing4.s_addr=iniGetIpAddress(list,sec_list[i],"OutgoingV4",startup->outgoing4.s_addr);
serv.outgoing6=iniGetIp6Address(list,sec_list[i],"OutgoingV6",startup->outgoing6);
serv.max_clients=iniGetInteger(list,sec_list[i],"MaxClients",max_clients);
serv.listen_backlog=iniGetInteger(list,sec_list[i],"ListenBacklog",listen_backlog);
serv.stack_size=(uint32_t)iniGetBytes(list,sec_list[i],"StackSize",1,stack_size);
......@@ -1554,6 +1552,7 @@ static service_t* read_services_ini(const char* services_ini, service_t* service
/* JavaScript operating parameters */
sbbs_get_js_settings(list, sec_list[i], &serv.js, &startup->js);
/* TODO: Fix this up for IPv6 stuff etc... this is going to be ugly! */
for(j=0;j<*services;j++)
if(service[j].interface_addr==serv.interface_addr && service[j].port==serv.port
&& (service[j].options&SERVICE_OPT_UDP)==(serv.options&SERVICE_OPT_UDP))
......@@ -1829,8 +1828,6 @@ void DLLCALL services_thread(void* arg)
total_sockets=0;
for(i=0;i<(int)services && !startup->shutdown_now;i++) {
struct in_addr iaddr;
if (service[i].options & SERVICE_OPT_TLS) {
if (tls_context == -1)
continue;
......
......@@ -5836,8 +5836,7 @@ void DLLCALL web_server(void* arg)
js_server_props.version_detail=web_ver();
js_server_props.clients=&active_clients.value;
js_server_props.options=&startup->options;
/* TODO IPv6 */
js_server_props.interface_addr=&startup->outgoing4;
js_server_props.interfaces=&startup->interfaces;
uptime=0;
served=0;
......
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