Commit e562d227 authored by Rob Swindell's avatar Rob Swindell

Merge branch 'master' into 'master'

Enable obtaining source IP address if HAproxy is used

See merge request sbbs/sbbs!11
parents ace3997a ee0e526c
Pipeline #757 passed with stage
in 16 minutes and 35 seconds
......@@ -137,6 +137,7 @@
; NO_RECYCLE
; GET_IDENT
; MUTE
; HAPROXY_PROTO
Options = XTRN_MINIMIZED | ALLOW_RLOGIN | ALLOW_SSH
[Mail] SMTP/POP3 Mail Server
......
......@@ -6233,7 +6233,7 @@ void DLLCALL ftp_server(void* arg)
/* now wait for connection */
client_addr_len = sizeof(client_addr);
client_socket = xpms_accept(ftp_set, &client_addr, &client_addr_len, startup->sem_chk_freq*1000, NULL);
client_socket = xpms_accept(ftp_set, &client_addr, &client_addr_len, startup->sem_chk_freq*1000, XPMS_FLAGS_NONE, NULL);
if(client_socket == INVALID_SOCKET)
continue;
......
......@@ -691,7 +691,7 @@ js_accept(JSContext *cx, uintN argc, jsval *arglist)
rc=JS_SUSPENDREQUEST(cx);
if(p->set) {
if((new_socket=xpms_accept(p->set,&(p->remote_addr),&addrlen,XPMS_FOREVER,NULL))==INVALID_SOCKET) {
if((new_socket=xpms_accept(p->set,&(p->remote_addr),&addrlen,XPMS_FOREVER,XPMS_FLAGS_NONE,NULL))==INVALID_SOCKET) {
p->last_error=ERROR_VALUE;
dbprintf(TRUE, p, "accept failed with error %d",ERROR_VALUE);
JS_RESUMEREQUEST(cx, rc);
......
......@@ -6340,7 +6340,7 @@ void DLLCALL mail_server(void* arg)
/* now wait for connection */
client_addr_len = sizeof(client_addr);
client_socket = xpms_accept(mail_set,&client_addr, &client_addr_len, startup->sem_chk_freq*1000, (void**)&servprot);
client_socket = xpms_accept(mail_set,&client_addr, &client_addr_len, startup->sem_chk_freq*1000, XPMS_FLAGS_NONE, (void**)&servprot);
if(client_socket != INVALID_SOCKET) {
bool is_smtp = (servprot != servprot_pop3 && servprot != servprot_pop3s);
if(startup->socket_open!=NULL)
......
......@@ -5384,7 +5384,7 @@ NO_SSH:
/* now wait for connection */
client_addr_len = sizeof(client_addr);
client_socket=xpms_accept(ts_set, &client_addr
,&client_addr_len, startup->sem_chk_freq*1000, &ts_cb);
,&client_addr_len, startup->sem_chk_freq*1000, (startup->options & BBS_OPT_HAPROXY_PROTO) ? XPMS_ACCEPT_FLAG_HAPROXY : XPMS_FLAGS_NONE, &ts_cb);
if(terminate_server) /* terminated */
break;
......
......@@ -190,6 +190,7 @@ static struct init_field {
#define BBS_OPT_ALLOW_SSH (1<<12) /* Allow logins via BSD SSH */
#define BBS_OPT_NO_DOS (1<<13) /* Don't attempt to run 16-bit DOS programs */
#define BBS_OPT_NO_NEWDAY_EVENTS (1<<14) /* Don't check for a new day in event thread */
#define BBS_OPT_HAPROXY_PROTO (1<<26) /* Incoming requests are via HAproxy */
#define BBS_OPT_NO_RECYCLE (1<<27) /* Disable recycling of server */
#define BBS_OPT_GET_IDENT (1<<28) /* Get Identity (RFC 1413) */
#define BBS_OPT_NO_JAVASCRIPT (1<<29) /* JavaScript disabled */
......@@ -197,7 +198,7 @@ static struct init_field {
/* bbs_startup_t.options bits that require re-init/recycle when changed */
#define BBS_INIT_OPTS (BBS_OPT_ALLOW_RLOGIN|BBS_OPT_ALLOW_SSH|BBS_OPT_NO_EVENTS|BBS_OPT_NO_SPY_SOCKETS \
|BBS_OPT_NO_JAVASCRIPT)
|BBS_OPT_NO_JAVASCRIPT|BBS_OPT_HAPROXY_PROTO)
#if defined(STARTUP_INI_BITDESC_TABLES)
static ini_bitdesc_t bbs_options[] = {
......@@ -218,6 +219,7 @@ static ini_bitdesc_t bbs_options[] = {
{ BBS_OPT_NO_RECYCLE ,"NO_RECYCLE" },
{ BBS_OPT_GET_IDENT ,"GET_IDENT" },
{ BBS_OPT_NO_JAVASCRIPT ,"NO_JAVASCRIPT" },
{ BBS_OPT_HAPROXY_PROTO ,"HAPROXY_PROTO" },
{ BBS_OPT_MUTE ,"MUTE" },
/* terminator */
{ 0 ,NULL }
......
......@@ -7188,7 +7188,7 @@ void DLLCALL web_server(void* arg)
/* now wait for connection */
client_addr_len = sizeof(client_addr);
client_socket = xpms_accept(ws_set, &client_addr, &client_addr_len, startup->sem_chk_freq*1000, &acc_type);
client_socket = xpms_accept(ws_set, &client_addr, &client_addr_len, startup->sem_chk_freq*1000, XPMS_FLAGS_NONE, &acc_type);
if(client_socket == INVALID_SOCKET)
continue;
......
/* haproxy.h */
/* HAPROXY PROTOCOL constant definitions */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
/* HAPROXY PROTO BINARY DEFINITIONS */
#define HAPROXY_AFINET 0x1 /* IPv4 Connection */
#define HAPROXY_AFINET6 0x2 /* IPv6 Connection */
/* HAPROXY COMMANDS */
#define HAPROXY_LOCAL 0x0 /* Connections instigated by the proxy, eg: health-check */
#define HAPROXY_PROXY 0x1 /* Relay connections */
This diff is collapsed.
......@@ -26,6 +26,8 @@ struct xpms_set {
};
#define XPMS_FOREVER UINT_MAX
#define XPMS_FLAGS_NONE 0
#define XPMS_ACCEPT_FLAG_HAPROXY (1<<0)
#ifdef __cplusplus
extern "C" {
......@@ -44,7 +46,7 @@ DLLEXPORT BOOL DLLCALL xpms_add_chararray_list(struct xpms_set *xpms_set, int do
int protocol, const char *list, uint16_t default_port, const char *prot,
void (*sock_init)(SOCKET, void *), int(*bind_init)(BOOL), void *cbdata);
DLLEXPORT SOCKET DLLCALL xpms_accept(struct xpms_set *, union xp_sockaddr * addr,
socklen_t * addrlen, unsigned int timeout, void **cb_data);
socklen_t * addrlen, unsigned int timeout, uint32_t flags, void **cb_data);
#ifdef __cplusplus
}
......
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