Fix bug #106: Show OS/CPU info in !version.
This can be controlled by the configuration variable "show_banner_sys_info" which is enabled by default.
This commit is contained in:
parent
6992043f9d
commit
915cb56448
|
@ -19,9 +19,12 @@ server_bind_addr=any
|
||||||
# The maximum amount of users allowed on the hub.
|
# The maximum amount of users allowed on the hub.
|
||||||
max_users=500
|
max_users=500
|
||||||
|
|
||||||
# If 1, will show a "This hub is running uhub/version".
|
# If 1, will show a "Powered by uHub/{VERSION}".
|
||||||
show_banner=1
|
show_banner=1
|
||||||
|
|
||||||
|
# If enabled then operating system and cpu architecture is part of the banner.
|
||||||
|
show_banner_sys_info=1
|
||||||
|
|
||||||
# Allow only registered users on the hub if set to 1.
|
# Allow only registered users on the hub if set to 1.
|
||||||
registered_users_only=0
|
registered_users_only=0
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,7 @@
|
||||||
#define DEF_MAX_SEND_BUFFER 131072
|
#define DEF_MAX_SEND_BUFFER 131072
|
||||||
#define DEF_MAX_SEND_BUFFER_SOFT 98304
|
#define DEF_MAX_SEND_BUFFER_SOFT 98304
|
||||||
#define DEF_SHOW_BANNER 1
|
#define DEF_SHOW_BANNER 1
|
||||||
|
#define DEF_SHOW_BANNER_SYS_INFO 1
|
||||||
#define DEF_REGISTERED_USERS_ONLY 0
|
#define DEF_REGISTERED_USERS_ONLY 0
|
||||||
#define DEF_CHAT_ONLY 0
|
#define DEF_CHAT_ONLY 0
|
||||||
#define DEF_CHAT_IS_PRIVILEGED 0
|
#define DEF_CHAT_IS_PRIVILEGED 0
|
||||||
|
@ -193,6 +194,7 @@ void config_defaults(struct hub_config* config)
|
||||||
DEFAULT_INTEGER(max_send_buffer, DEF_MAX_SEND_BUFFER);
|
DEFAULT_INTEGER(max_send_buffer, DEF_MAX_SEND_BUFFER);
|
||||||
DEFAULT_INTEGER(max_send_buffer_soft, DEF_MAX_SEND_BUFFER_SOFT);
|
DEFAULT_INTEGER(max_send_buffer_soft, DEF_MAX_SEND_BUFFER_SOFT);
|
||||||
DEFAULT_BOOLEAN(show_banner, DEF_SHOW_BANNER);
|
DEFAULT_BOOLEAN(show_banner, DEF_SHOW_BANNER);
|
||||||
|
DEFAULT_BOOLEAN(show_banner_sys_info, DEF_SHOW_BANNER_SYS_INFO);
|
||||||
DEFAULT_BOOLEAN(chat_only, DEF_CHAT_ONLY);
|
DEFAULT_BOOLEAN(chat_only, DEF_CHAT_ONLY);
|
||||||
DEFAULT_BOOLEAN(chat_is_privileged, DEF_CHAT_IS_PRIVILEGED);
|
DEFAULT_BOOLEAN(chat_is_privileged, DEF_CHAT_IS_PRIVILEGED);
|
||||||
DEFAULT_BOOLEAN(low_bandwidth_mode, DEF_LOW_BANDWIDTH_MODE);
|
DEFAULT_BOOLEAN(low_bandwidth_mode, DEF_LOW_BANDWIDTH_MODE);
|
||||||
|
@ -268,6 +270,7 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
||||||
GET_INT (max_send_buffer);
|
GET_INT (max_send_buffer);
|
||||||
GET_INT (max_send_buffer_soft);
|
GET_INT (max_send_buffer_soft);
|
||||||
GET_BOOL(show_banner);
|
GET_BOOL(show_banner);
|
||||||
|
GET_BOOL(show_banner_sys_info);
|
||||||
GET_BOOL(chat_only);
|
GET_BOOL(chat_only);
|
||||||
GET_BOOL(chat_is_privileged);
|
GET_BOOL(chat_is_privileged);
|
||||||
GET_BOOL(low_bandwidth_mode);
|
GET_BOOL(low_bandwidth_mode);
|
||||||
|
@ -421,6 +424,7 @@ void dump_config(struct hub_config* config, int ignore_defaults)
|
||||||
DUMP_INT (max_send_buffer, DEF_MAX_SEND_BUFFER);
|
DUMP_INT (max_send_buffer, DEF_MAX_SEND_BUFFER);
|
||||||
DUMP_INT (max_send_buffer_soft, DEF_MAX_SEND_BUFFER_SOFT);
|
DUMP_INT (max_send_buffer_soft, DEF_MAX_SEND_BUFFER_SOFT);
|
||||||
DUMP_BOOL(show_banner, DEF_SHOW_BANNER);
|
DUMP_BOOL(show_banner, DEF_SHOW_BANNER);
|
||||||
|
DUMP_BOOL(show_banner_sys_info, DEF_SHOW_BANNER_SYS_INFO);
|
||||||
DUMP_BOOL(chat_only, DEF_CHAT_ONLY);
|
DUMP_BOOL(chat_only, DEF_CHAT_ONLY);
|
||||||
DUMP_BOOL(chat_is_privileged, DEF_CHAT_IS_PRIVILEGED);
|
DUMP_BOOL(chat_is_privileged, DEF_CHAT_IS_PRIVILEGED);
|
||||||
DUMP_BOOL(low_bandwidth_mode, DEF_LOW_BANDWIDTH_MODE);
|
DUMP_BOOL(low_bandwidth_mode, DEF_LOW_BANDWIDTH_MODE);
|
||||||
|
|
|
@ -28,6 +28,7 @@ struct hub_config
|
||||||
char* server_alt_ports; /**<<< "Comma separated list of alternative ports to listen to (default: '')" */
|
char* server_alt_ports; /**<<< "Comma separated list of alternative ports to listen to (default: '')" */
|
||||||
int hub_enabled; /**<<< "Is server enabled (default: 1)" */
|
int hub_enabled; /**<<< "Is server enabled (default: 1)" */
|
||||||
int show_banner; /**<<< "Show banner on connect (default: 1)" */
|
int show_banner; /**<<< "Show banner on connect (default: 1)" */
|
||||||
|
int show_banner_sys_info; /**<<< "Show banner system information (default: 1). Has no effect unless show_banner is enabled." */
|
||||||
int max_users; /**<<< "Maximum number of users allowed on the hub (default: 500)" */
|
int max_users; /**<<< "Maximum number of users allowed on the hub (default: 500)" */
|
||||||
int registered_users_only; /**<<< "Allow registered users only (default: 0)" */
|
int registered_users_only; /**<<< "Allow registered users only (default: 0)" */
|
||||||
int chat_only; /**<<< "Allow chat only operation on hub (default: 0)" */
|
int chat_only; /**<<< "Allow chat only operation on hub (default: 0)" */
|
||||||
|
|
|
@ -684,17 +684,15 @@ void hub_shutdown_service(struct hub_info* hub)
|
||||||
g_hub = 0;
|
g_hub = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SERVER "" PRODUCT "/" VERSION ""
|
|
||||||
|
|
||||||
void hub_set_variables(struct hub_info* hub, struct acl_handle* acl)
|
void hub_set_variables(struct hub_info* hub, struct acl_handle* acl)
|
||||||
{
|
{
|
||||||
int fd, ret;
|
int fd, ret;
|
||||||
char buf[MAX_RECV_BUF];
|
char buf[MAX_RECV_BUF];
|
||||||
char* tmp;
|
char* tmp;
|
||||||
char* server = adc_msg_escape(SERVER); /* FIXME: OOM */
|
char* server = adc_msg_escape(PRODUCT_STRING); /* FIXME: OOM */
|
||||||
|
|
||||||
hub->acl = acl;
|
hub->acl = acl;
|
||||||
hub->command_info = adc_msg_construct(ADC_CMD_IINF, 15 + strlen(server));
|
hub->command_info = adc_msg_construct(ADC_CMD_IINF, 15);
|
||||||
if (hub->command_info)
|
if (hub->command_info)
|
||||||
{
|
{
|
||||||
adc_msg_add_named_argument(hub->command_info, ADC_INF_FLAG_CLIENT_TYPE, ADC_CLIENT_TYPE_HUB);
|
adc_msg_add_named_argument(hub->command_info, ADC_INF_FLAG_CLIENT_TYPE, ADC_CLIENT_TYPE_HUB);
|
||||||
|
@ -748,10 +746,13 @@ void hub_set_variables(struct hub_info* hub, struct acl_handle* acl)
|
||||||
adc_msg_add_argument(hub->command_support, ADC_PROTO_SUPPORT);
|
adc_msg_add_argument(hub->command_support, ADC_PROTO_SUPPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
hub->command_banner = adc_msg_construct(ADC_CMD_ISTA, 25 + strlen(server));
|
hub->command_banner = adc_msg_construct(ADC_CMD_ISTA, 100 + strlen(server));
|
||||||
if (hub->command_banner)
|
if (hub->command_banner)
|
||||||
{
|
{
|
||||||
tmp = adc_msg_escape("Powered by " SERVER);
|
if (hub->config->show_banner_sys_info)
|
||||||
|
tmp = adc_msg_escape("Powered by " PRODUCT_STRING " on " OPSYS "/" CPUINFO);
|
||||||
|
else
|
||||||
|
tmp = adc_msg_escape("Powered by " PRODUCT_STRING);
|
||||||
adc_msg_add_argument(hub->command_banner, "000");
|
adc_msg_add_argument(hub->command_banner, "000");
|
||||||
adc_msg_add_argument(hub->command_banner, tmp);
|
adc_msg_add_argument(hub->command_banner, tmp);
|
||||||
hub_free(tmp);
|
hub_free(tmp);
|
||||||
|
|
|
@ -190,8 +190,8 @@ int check_configuration(int dump)
|
||||||
|
|
||||||
void print_version()
|
void print_version()
|
||||||
{
|
{
|
||||||
fprintf(stdout, "" PRODUCT " " VERSION "\n");
|
fprintf(stdout, PRODUCT_STRING "\n");
|
||||||
fprintf(stdout, "Copyright (C) 2007-2009, Jan Vidar Krey <janvidar@extatic.org>\n"
|
fprintf(stdout, COPYRIGHT "\n"
|
||||||
"This is free software with ABSOLUTELY NO WARRANTY.\n\n");
|
"This is free software with ABSOLUTELY NO WARRANTY.\n\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
95
src/system.h
95
src/system.h
|
@ -44,6 +44,10 @@
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) || (defined(__APPLE__) && defined(__MACH__))
|
||||||
|
#define BSD_LIKE
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__CYGWIN__) || defined(__MINGW32__)
|
#if defined(__CYGWIN__) || defined(__MINGW32__)
|
||||||
#ifndef WINSOCK
|
#ifndef WINSOCK
|
||||||
#define WINSOCK
|
#define WINSOCK
|
||||||
|
@ -113,7 +117,7 @@
|
||||||
#include <sys/epoll.h>
|
#include <sys/epoll.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
#ifdef BSD_LIKE
|
||||||
#define USE_KQUEUE
|
#define USE_KQUEUE
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -123,11 +127,98 @@
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__sun__)
|
#if defined(BSD_LIKE) || defined(__sun__)
|
||||||
#undef HAVE_STRNDUP
|
#undef HAVE_STRNDUP
|
||||||
#undef HAVE_MEMMEM
|
#undef HAVE_MEMMEM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Detect operating system info.
|
||||||
|
* See: http://predef.sourceforge.net/
|
||||||
|
*/
|
||||||
|
#if defined(__linux__)
|
||||||
|
#define OPSYS "Linux"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(__MINGW32__) || defined(_WIN64) || defined(__WIN32__) || defined(__WINDOWS__)
|
||||||
|
#define OPSYS "Windows"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__) && defined(__MACH__)
|
||||||
|
#define OPSYS "MacOSX"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
|
#define OPSYS "FreeBSD"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__OpenBSD__)
|
||||||
|
#define OPSYS "OpenBSD"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__NetBSD__)
|
||||||
|
#define OPSYS "NetBSD"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__sun__)
|
||||||
|
#if defined(__SVR4) || defined(__svr4__)
|
||||||
|
#define OPSYS "Solaris"
|
||||||
|
#else
|
||||||
|
#define OPSYS "SunOS"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__HAIKU__)
|
||||||
|
#define OPSYS "Haiku"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Detect CPUs */
|
||||||
|
#if defined(__alpha__) || defined(__alpha)
|
||||||
|
#define CPUINFO "Alpha"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || defined(__amd64) || defined(_M_X64)
|
||||||
|
#define CPUINFO "AMD64"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__arm__) || defined(__thumb__) || defined(_ARM) || defined(__TARGET_ARCH_ARM)
|
||||||
|
#define CPUINFO "ARM"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__i386__) || defined(__i386) || defined(i386) || defined(_M_IX86) || defined(__X86__) || defined(_X86_) || defined(__I86__) || defined(__INTEL__) || defined(__THW_INTEL__)
|
||||||
|
#define CPUINFO "i386"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__ia64__) || defined(_IA64) || defined(__IA64__) || defined(__ia64) || defined(_M_IA64)
|
||||||
|
#define CPUINFO "IA64"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__hppa__) || defined(__hppa)
|
||||||
|
#define CPUINFO "PARISC"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__m68k__) || defined(M68000)
|
||||||
|
#define CPUINFO "M68K"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__mips__) || defined(mips) || defined(__mips) || defined(__MIPS__)
|
||||||
|
#define CPUINFO "MIPS"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__POWERPC__) || defined(__ppc__) || defined(_ARCH_PPC) || defined(__powerpc) || defined(__powerpc__)
|
||||||
|
#define CPUINFO "PowerPC"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__sparc__) || defined(__sparc)
|
||||||
|
#define CPUINFO "SPARC"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__sh__)
|
||||||
|
#define CPUINFO "SuperH"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Misc */
|
||||||
#ifdef MSG_NOSIGNAL
|
#ifdef MSG_NOSIGNAL
|
||||||
#define UHUB_SEND_SIGNAL MSG_NOSIGNAL
|
#define UHUB_SEND_SIGNAL MSG_NOSIGNAL
|
||||||
#else
|
#else
|
||||||
|
|
16
version.h
16
version.h
|
@ -2,16 +2,18 @@
|
||||||
#define PRODUCT "uHub"
|
#define PRODUCT "uHub"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GIT_REVISION
|
#ifndef VERSION
|
||||||
#define REVISION ""
|
#define VERSION "0.3.0"
|
||||||
#else
|
|
||||||
#define REVISION " (git: " GIT_REVISION ")"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef VERSION
|
#ifndef GIT_REVISION
|
||||||
#define VERSION "0.3.0" REVISION
|
#define REVISION ""
|
||||||
|
#define PRODUCT_STRING PRODUCT "/" VERSION
|
||||||
|
#else
|
||||||
|
#define REVISION "(git: " GIT_REVISION ")"
|
||||||
|
#define PRODUCT_STRING PRODUCT "/" VERSION " " REVISION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef COPYRIGHT
|
#ifndef COPYRIGHT
|
||||||
#define COPYRIGHT "Copyright (c) 2007-2009, Jan Vidar Krey <janvidar@extatic.org>"
|
#define COPYRIGHT "Copyright (c) 2007-2010, Jan Vidar Krey <janvidar@extatic.org>"
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue